awinogrodzki / next-firebase-auth-edge

Next.js Firebase Authentication for Edge and Node.js runtimes. Compatible with latest Next.js features.
https://next-firebase-auth-edge-docs.vercel.app/
MIT License
499 stars 43 forks source link

Error in middleware running on Vercel #6

Closed steve-marmalade closed 1 year ago

steve-marmalade commented 1 year ago

Hey there, thanks for putting this library together.

I am getting the following error when using the middleware on Vercel. Any idea what could be happening here?

/api/login
09:56:09:46
 Error: Imported HMAC key length (20) must be a non-zero value up to 7 bits less than, and no greater than, the bit length of the raw key data (56).
    at node_modules/next-firebase-auth-edge/lib/auth/rotating-credential.js:23:0 {
  stack: 'Error: Imported HMAC key length (20) must be a non-zero value up to 7 bits less than, and no greater than, the bit length of the raw key data (56).\n    at c.signKey (worker.js:14:37337)',
  code: 0,
  name: 'DataError',
  message: 'Imported HMAC key length (20) must be a non-zero value up to 7 bits less than, and no greater than, the bit length of the raw key data (56).'
}

/api/login
09:56:09:38
TypeError: Cannot read properties of undefined (reading 'replace')
    at node_modules/next-firebase-auth-edge/lib/auth/jwt/utils.js:49:0
    at node_modules/next-firebase-auth-edge/lib/auth/jwt/utils.js:29:0
    at node_modules/next-firebase-auth-edge/lib/auth/jwt/decode.js:7:0
    at node_modules/next-firebase-auth-edge/lib/auth/signature-verifier.js:145:0
    at node_modules/next-firebase-auth-edge/lib/auth/token-verifier.js:62:0
    at node_modules/next-firebase-auth-edge/lib/auth/token-verifier.js:56:0
    at node_modules/next-firebase-auth-edge/lib/auth/token-verifier.js:50:0
    at node_modules/next-firebase-auth-edge/lib/auth/index.js:96:0
    at node_modules/next-firebase-auth-edge/lib/auth/index.js:132:0
    at node_modules/next-firebase-auth-edge/lib/next/cookies.js:24:36

2022-12-18T09:58:47,900232590-05:00

awinogrodzki commented 1 year ago

👋 @steve-marmalade

Thanks for the feedback. Turns out I was passing incorrect key length when signing keys using rotating credentials.

It's already fixed by https://github.com/ensite-in/next-firebase-auth-edge/pull/7

Fix was released in v0.2.13