jose.jwtVerify - ReferenceError: CryptoKey is not defined #411
Replies: 4 comments 5 replies
-
Prepare a working example that can be built and run if you wish to get assistance please. |
Beta Was this translation helpful? Give feedback.
-
Have the same issue with CryptoKey. |
Beta Was this translation helpful? Give feedback.
-
I met the same problem as you, but in fact he is not a problem。 because this API can only run in localhost and HTTPS environments. therefore, the scenario where you make an error may be running in the HTTP environment |
Beta Was this translation helpful? Give feedback.
-
I tried import { Crypto } from '@peculiar/webcrypto'
global.crypto = new Crypto() but for what i was doing a better alternative was const cryptoAlt = require('crypto').webcrypto
const cryptoKey = require('crypto').webcrypto.CryptoKey
global.crypto = cryptoAlt
global.CryptoKey = cryptoKey |
Beta Was this translation helpful? Give feedback.
-
On local (ng serve) it works perfectly with this code
jose.jwtVerify(observer['token'], new TextEncoder().encode(environment.jwtKey)).then(...)
But when I build the application to put it on the server, I got an error :
ReferenceError: CryptoKey is not defined
So I don't really know how to solve that...
I even do a npm i crypto just in case, but it doesn't solve the problem
Version:
angular : 13.2.1
jose : 4.8.1
Beta Was this translation helpful? Give feedback.
All reactions