Closed ayushghatkar8080 closed 2 months ago
Hello @ayushghatkar8080, server v9.0.3 first tries to find the crypto module at globalThis.crypto
before trying to import Node's crypto
module. That error you're seeing is telling me that, for some reason, globalThis.crypto
is not resolving within the Next.js Edge runtime. The Next.js docs say it should be available, though:
https://nextjs.org/docs/app/api-reference/edge
Can you check and see what the value of globalThis.crypto
is in your code before trying to import SimpleWebAuthn?
Thank you, As it was not the problem of webauthn
Describe the issue
Hello there when i was building my webapp with next-auth i got some error regarding @simplewebauthn/server """
./node_modules/@simplewebauthn/server/esm/helpers/iso/isoCrypto/getWebCrypto.js A Node.js module is loaded ('crypto' at line 46) which is not supported in the Edge Runtime. Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
Import trace for requested module: ./node_modules/@simplewebauthn/server/esm/helpers/iso/isoCrypto/getWebCrypto.js ./node_modules/@simplewebauthn/server/esm/helpers/iso/isoCrypto/verifyEC2.js ./node_modules/@simplewebauthn/server/esm/metadata/verifyJWT.js ./node_modules/@simplewebauthn/server/esm/services/metadataService.js ./node_modules/@simplewebauthn/server/esm/index.js
"""
Reproduction Steps
1.write a basic nextjs project 2.make a basic simplewebauthn passkey system 3.build command with nextjs
Expected behavior
i thing your code is not compatible with vercel/jextjs's new edge time
Dependencies
SimpleWebAuthn Libraries
"@simplewebauthn/browser": "^9.0.1", "@simplewebauthn/server": "^9.0.3",
Output from Nextjs
▲ Next.js 14.2.5
Environments: .env
Creating an optimized production build ...
./node_modules/@simplewebauthn/server/esm/helpers/iso/isoCrypto/getWebCrypto.js A Node.js module is loaded ('crypto' at line 46) which is not supported in the Edge Runtime. Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
Import trace for requested module: ./node_modules/@simplewebauthn/server/esm/helpers/iso/isoCrypto/getWebCrypto.js ./node_modules/@simplewebauthn/server/esm/helpers/iso/isoCrypto/verifyEC2.js ./node_modules/@simplewebauthn/server/esm/metadata/verifyJWT.js ./node_modules/@simplewebauthn/server/esm/services/metadataService.js ./node_modules/@simplewebauthn/server/esm/index.js ./node_modules/next-auth/node_modules/@auth/core/providers/webauthn.js ./node_modules/next-auth/node_modules/@auth/core/providers/passkey.js ./node_modules/next-auth/providers/passkey.js ./auth.ts
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules ✓ Linting and checking validity of types
✓ Collecting page data ✓ Generating static pages (20/20) ✓ Collecting build traces ✓ Finalizing page optimization
Route (app) Size First Load JS ┌ ○ / 6.79 kB 200 kB ├ ƒ /api/auth/[...nextauth] 0 B 0 B ├ ○ /api/auth/error 187 B 190 kB