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

feat(core): crypto compatibility for Workers #547

Merged
merged 13 commits into from
Nov 12, 2024
Merged

Conversation

vejja
Copy link
Collaborator

@vejja vejja commented Nov 11, 2024

Resolves #541

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR replaces the NodeJS cryptographic primitives used in this codebase by their equivalents from the Javascript WebCrypto API.

The fundamental reason for this rewrite is to provide full compatibility with Worker-based environments, where Node's crypto module might not always be available.

The issue was first raised with Cloudflare's Workers. While manual configuration of Cloudflare worker settings (via their nodejs_compatibility flag) is possible, we believe it is better to offer a universal approach that will offer strong cryptographic guarantees in all environments.

Note: as part of this update, the NodeJS minimal version needs to be updated to v20. This is required to ensure that crypto is available in the global scope.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

Copy link

vercel bot commented Nov 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-security ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 5:35pm

@vejja vejja self-assigned this Nov 11, 2024
@vejja vejja changed the base branch from chore/2.1.0 to main November 11, 2024 17:16
@vejja vejja marked this pull request as ready for review November 11, 2024 17:17
@vejja vejja requested a review from Baroshem November 11, 2024 17:18
@vejja vejja linked an issue Nov 11, 2024 that may be closed by this pull request
@vejja
Copy link
Collaborator Author

vejja commented Nov 11, 2024

@Baroshem for some reason I had troubles rebasing the branch onto 2.1.0 - sorrry the commit timeline looks awful, but actually the amount of changes is very small

Copy link
Owner

@Baroshem Baroshem left a comment

Choose a reason for hiding this comment

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

Nice job @vejja !

No worries about the commit history. Glad you have managed to make it work. Proceed with merging when you feel ready. @brewwa would you be able to test this branch? :)

@vejja
Copy link
Collaborator Author

vejja commented Nov 12, 2024

Hey Jakub, I tested it on a private repo that @brewaa provided, and it works on Cloudflare. Will merge

@vejja vejja merged commit f3706ab into chore/2.1.0 Nov 12, 2024
3 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.

Nonce doesn't change per request in production build
4 participants