Support automatic detection of crypto for node 19 and above #438
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #414
Since Node 19
globalThis.crypto
now contains an instance toCrypto
. This is still true in Node 22. Prior to Node 19 (eg in Node 18) this it wasglobalThis.crypto.webcrypto
. Note that in Node 18,globalThis.crypto
is not an instance ofCrypto
but contains both asubtle
member and awebcrypto
member.See https://nodejs.org/docs/latest-v19.x/api/webcrypto.html#web-crypto-api
This isn't caught by tests as the engine gets initialized separately
PKI.js/test/utils.ts
Lines 53 to 59 in 06f154a