Closed ryanwalters closed 3 months ago
Hi mate. Did you load the JWKS into the cache first? That's required if you want to use 'verifySync'.
But it looks like you can make your Next code work by just switching to 'verify' (which is async and you need to await it). If you use 'verify' the fetching of the JWKS happens automatically (can't do that for 'verifySync' as it's, well, sync).
Also please check the main README, if you CTRL-F for verifySync you'll find more info on how this is intended to work.
Thanks @ottokruse, I had missed that part of the readme. I had expected the sync functionality to work the same as async, without the need to manually load the jwks.json. I think we can close this one out for the time being, thanks!
Describe the bug I am attempting to verify an access token using the
verifySync()
function within a Next.js 14 app router application. However, I receive the following error:Versions Which version of
aws-jwt-verify
are you using? 4.0.1 Are you using the library in Node.js or in the Web browser? Node.js If Node.js, which version of Node.js are you using? (Should be at least 16) v20.12.0 If Web browser, which web browser and which version of it are you using? If using TypeScript, which version of TypeScript are you using? (Should be at least 4) v5.3.3To Reproduce
npm install
NEXT_PUBLIC_CLIENT_ID
NEXT_PUBLIC_USER_POOL_ID
NEXT_PUBLIC_ACCESS_TOKEN
(please make sure this is a valid access token for this test's purposes)npm run dev
http://localhost:3000
Expected Result The console logs the result of
verifySync()
.Actual Result Throws
JwksNotAvailableInCacheError
.