node-jose
node-jose copied to clipboard
Trying to use verify throws an error in base64url lib: Cannot read properties of undefined (reading 'toString')
It seems like I might be doing something wrong, but I'm not sure what.
I have a jws token (compact), and when I try to run the following:
const jws = fs.readFileSync(path.resolve('token.txt')).toString()
const token = await nodeJose.JWS.createVerify().verify(jws, {allowEmbeddedKey: true});
I get:
TypeError: Cannot read properties of undefined (reading 'toString')
at toBase64 (/Users/rob/vision/cloud-functions/kichi/functions/node_modules/base64url/dist/base64url.js:17:27)
at Object.toBuffer [as decode] (/Users/rob/vision/cloud-functions/kichi/functions/node_modules/base64url/dist/base64url.js:29:24)
at /Users/rob/vision/cloud-functions/kichi/functions/node_modules/node-jose/lib/jws/verify.js:94:35
at Array.map (<anonymous>)
at JWSVerifier.value (/Users/rob/vision/cloud-functions/kichi/functions/node_modules/node-jose/lib/jws/verify.js:88:25)
at decodeToken (/Users/rob/vision/cloud-functions/kichi/functions/src/test.js:17:42)
at Object.<anonymous> (/Users/rob/vision/cloud-functions/kichi/functions/src/test.js:28:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
If I console.log
the output of jws
I get a well-formed token string that seems to decode properly (according to jwt.io), so I don't think that the token itself is undefined.
Is this a library error, or am I doing something wrong?