-
Couldn't load subscription status.
- Fork 402
fix(nextjs): replace crypto-js with crypto-es, precompile and inline #5024
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
Conversation
🦋 Changeset detectedLatest commit: 1b1447a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
!snapshot |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
!snapshot |
|
Hey @jacekradko - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@2.1.17-snapshot.v20250128032734 --save-exact
npm i @clerk/backend@1.23.9-snapshot.v20250128032734 --save-exact
npm i @clerk/chrome-extension@2.2.3-snapshot.v20250128032734 --save-exact
npm i @clerk/clerk-js@5.50.1-snapshot.v20250128032734 --save-exact
npm i @clerk/elements@0.22.17-snapshot.v20250128032734 --save-exact
npm i @clerk/clerk-expo@2.7.1-snapshot.v20250128032734 --save-exact
npm i @clerk/expo-passkeys@0.1.16-snapshot.v20250128032734 --save-exact
npm i @clerk/express@1.3.44-snapshot.v20250128032734 --save-exact
npm i @clerk/fastify@2.1.17-snapshot.v20250128032734 --save-exact
npm i @clerk/localizations@3.10.2-snapshot.v20250128032734 --save-exact
npm i @clerk/nextjs@6.10.4-snapshot.v20250128032734 --save-exact
npm i @clerk/nuxt@1.0.13-snapshot.v20250128032734 --save-exact
npm i @clerk/clerk-react@5.22.8-snapshot.v20250128032734 --save-exact
npm i @clerk/react-router@1.0.3-snapshot.v20250128032734 --save-exact
npm i @clerk/remix@4.4.19-snapshot.v20250128032734 --save-exact
npm i @clerk/shared@2.20.16-snapshot.v20250128032734 --save-exact
npm i @clerk/tanstack-start@0.8.18-snapshot.v20250128032734 --save-exact
npm i @clerk/testing@1.4.17-snapshot.v20250128032734 --save-exact
npm i @clerk/themes@2.2.14-snapshot.v20250128032734 --save-exact
npm i @clerk/types@4.44.2-snapshot.v20250128032734 --save-exact
npm i @clerk/ui@0.3.18-snapshot.v20250128032734 --save-exact
npm i @clerk/vue@1.1.8-snapshot.v20250128032734 --save-exact |
Co-authored-by: Jacek Radko <jacek@clerk.dev>
| @@ -0,0 +1,5 @@ | |||
| import { AES } from 'crypto-es/lib/aes'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this file to crypto-es.js ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good call
| async function hashString(str: string) { | ||
| const encoder = new TextEncoder(); | ||
| const data = encoder.encode(str); | ||
| const hashBuffer = await crypto.subtle.digest('SHA-256', data); | ||
| const hashArray = Array.from(new Uint8Array(hashBuffer)); | ||
| const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); | ||
| return hashHex.slice(0, 16); // Take only the first 16 characters | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The funny thing is that initially I did this with the web api, but switched to crypto-js for consistency.
|
!snapshot |
|
Hey @brkalow - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@2.1.17-snapshot.v20250129203459 --save-exact
npm i @clerk/backend@1.23.9-snapshot.v20250129203459 --save-exact
npm i @clerk/chrome-extension@2.2.3-snapshot.v20250129203459 --save-exact
npm i @clerk/clerk-js@5.50.1-snapshot.v20250129203459 --save-exact
npm i @clerk/elements@0.22.17-snapshot.v20250129203459 --save-exact
npm i @clerk/clerk-expo@2.7.1-snapshot.v20250129203459 --save-exact
npm i @clerk/expo-passkeys@0.1.16-snapshot.v20250129203459 --save-exact
npm i @clerk/express@1.3.44-snapshot.v20250129203459 --save-exact
npm i @clerk/fastify@2.1.17-snapshot.v20250129203459 --save-exact
npm i @clerk/localizations@3.10.2-snapshot.v20250129203459 --save-exact
npm i @clerk/nextjs@6.10.4-snapshot.v20250129203459 --save-exact
npm i @clerk/nuxt@1.0.13-snapshot.v20250129203459 --save-exact
npm i @clerk/clerk-react@5.22.8-snapshot.v20250129203459 --save-exact
npm i @clerk/react-router@1.0.3-snapshot.v20250129203459 --save-exact
npm i @clerk/remix@4.4.19-snapshot.v20250129203459 --save-exact
npm i @clerk/shared@2.20.16-snapshot.v20250129203459 --save-exact
npm i @clerk/tanstack-start@0.9.0-snapshot.v20250129203459 --save-exact
npm i @clerk/testing@1.4.17-snapshot.v20250129203459 --save-exact
npm i @clerk/themes@2.2.14-snapshot.v20250129203459 --save-exact
npm i @clerk/types@4.44.2-snapshot.v20250129203459 --save-exact
npm i @clerk/ui@0.3.18-snapshot.v20250129203459 --save-exact
npm i @clerk/vue@1.1.8-snapshot.v20250129203459 --save-exact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at https://unpkg.com/browse/@clerk/nextjs@6.10.4-snapshot.v20250129203459/dist/esm/vendor/crypto-es.js -- seems fine 👍
|
Should the title of the PR be updated to reflect the changes ? |
|
!snapshot |
|
Hey @panteliselef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.0.4-snapshot.v20250303105446 --save-exact
npm i @clerk/astro@2.3.0-snapshot.v20250303105446 --save-exact
npm i @clerk/backend@1.24.3-snapshot.v20250303105446 --save-exact
npm i @clerk/chrome-extension@2.2.11-snapshot.v20250303105446 --save-exact
npm i @clerk/clerk-js@5.54.0-snapshot.v20250303105446 --save-exact
npm i @clerk/elements@0.23.0-snapshot.v20250303105446 --save-exact
npm i @clerk/clerk-expo@2.8.0-snapshot.v20250303105446 --save-exact
npm i @clerk/expo-passkeys@0.1.22-snapshot.v20250303105446 --save-exact
npm i @clerk/express@1.3.50-snapshot.v20250303105446 --save-exact
npm i @clerk/fastify@2.1.23-snapshot.v20250303105446 --save-exact
npm i @clerk/localizations@3.10.8-snapshot.v20250303105446 --save-exact
npm i @clerk/nextjs@6.12.1-snapshot.v20250303105446 --save-exact
npm i @clerk/nuxt@1.2.1-snapshot.v20250303105446 --save-exact
npm i @clerk/clerk-react@5.24.0-snapshot.v20250303105446 --save-exact
npm i @clerk/react-router@1.1.1-snapshot.v20250303105446 --save-exact
npm i @clerk/remix@4.5.1-snapshot.v20250303105446 --save-exact
npm i @clerk/shared@3.0.0-snapshot.v20250303105446 --save-exact
npm i @clerk/tanstack-start@0.10.1-snapshot.v20250303105446 --save-exact
npm i @clerk/testing@1.4.24-snapshot.v20250303105446 --save-exact
npm i @clerk/themes@2.2.20-snapshot.v20250303105446 --save-exact
npm i @clerk/types@4.47.0-snapshot.v20250303105446 --save-exact
npm i @clerk/ui@0.3.25-snapshot.v20250303105446 --save-exact
npm i @clerk/vue@1.3.0-snapshot.v20250303105446 --save-exact |
Description
Replaces our usage of
crypto-jswithcrypto-es, and attempts to precompile our usage of the library. This addresses an issue we are seeing where in some cases the implementation of the crypto-js methods we are using were erroring when imported across different runtimes. This also reduces our dependency surface area.fixes #4989
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change