I get "The required JS dependency "crypto" is not available, it was required by node_modules/keycloak-js/dist/keycloak.js" error when upgrading from shadow-cljs 2.28.23 to 3.0.0 . I guess the error comes because keycloak-js https://github.com/keycloak/keycloak-js/blob/0541a724af0598c4d805480c7666060e91d11133/lib/keycloak.js#L1622-L1628 the https://developer.mozilla.org/en-US/docs/Web/API/Crypto. We target the browser, so I understand it should be available with no external dependencies required. What am I missing? I have been searching the message history, but didn't find a solution.
which keycloak-js version? it almost certainly does a require("crypto") which is a node-only package. 3.x removed the automatic polyfilling for that, which you can get back manually if needed
my guess a keycloak update would also fix it. the version you linked doesn't have a require and directly uses the web crypto stuff. guessing the old version you have doesn't
I'm using 25.0.6. I can't upgrade that easilly because it has to match the Keycloak server version. Looking for the source code, it seems they changed the repo
you can use the same (but now manual) polyfill method from before
npm install crypto-browserify and in the build config set :js-options {:resolve {"crypto" {:target :npm :require "crypto-browserify"}}}
crypto-browserify being the polyfill package
I see the old version uses the require yes
Ok, great. Thanks a lot !
FWIW I found crypto working when I used directly without a require - with Node.js: (js/crypto.getRandomValues array)