Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cryptoNode: fall back to Node.js crypto when webcrypto not available #98

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

legobeat
Copy link
Contributor

@legobeat legobeat commented Aug 30, 2024

While Node.js v14 does have a built-in node:crypto with the required randomBytes, it is not exported under crypto.webcrypto. This adds a fallback to use the built-in crypto when webcrypto is not available.

@legobeat legobeat mentioned this pull request Aug 30, 2024
@@ -1,7 +1,9 @@
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
// We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the mention of browsers, as those are importing from crypto.ts and should not be arriving here AIUI

@legobeat legobeat marked this pull request as ready for review August 30, 2024 04:37
@legobeat legobeat force-pushed the crypto-node-compat branch from c311875 to 6d3aa0a Compare August 30, 2024 04:39
@paulmillr paulmillr merged commit b505154 into paulmillr:main Aug 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants