crypto is not defined
microshine opened this issue · 3 comments
microshine commented
I'm using jose-jwe
from nodejs application. I've got this error on jose-jwe
module initialization.
I see it can be fixed by setting global variable crypto
.
Maybe it would be better to check if crypto
is defined before to use it. This will allow to use setCrypto
after module initialization (no need to set global before import
construction).
example
import * as jose from "jose-jwe";
import * as CryptoOssl from "node-webcrypto-ossl";
jose.setCrypto(new CryptoOssl());
If I set crypto
to global before to import jose-jwe
, I've got eslint error
eslint: Import in body of module; reorder to top. (import/first)
alokmenghrajani commented
Seems reasonable to have a setCrypto
method. Want to send a PR?
rehandalal commented
I see this is fixed in master. Any chance of getting a new release?
alokmenghrajani commented
This fix is in v0.1.6, which I just released.