Skip to content
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

Trying to use verify throws an error in base64url lib: Cannot read properties of undefined (reading 'toString') #349

Open
Rob117 opened this issue Feb 10, 2022 · 0 comments

Comments

@Rob117
Copy link

Rob117 commented Feb 10, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant