Error `Unexpected end of data` when parsing a JWT
See original GitHub issueBug severity 5
Describe the bug Not able to parse a simple JWT.
To Reproduce Steps to reproduce the behaviour:
- Try to Handle a Message that is a self-signed JWT:
const message: IMessage = await agent.handleMessage({
raw: verifiableCredential.proof.jwt,
save: false,
});
eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJjcmVkZW50aWFsU3ViamVjdCI6eyJpZGVudGl0eUFsaWFzIjoibG9jYWxob3N0OmJjZjcxMjA0LWQzMDEtNGU3OC1iNWQ3LTViNmMyMWFjNmUwMiJ9LCJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl19LCJuYmYiOjE2MjEzNDE3OTgsImlzcyI6ImRpZDp3ZWI6bG9jYWxob3N0OmJjZjcxMjA0LWQzMDEtNGU3OC1iNWQ3LTViNmMyMWFjNmUwMiJ9.3045022100ba25a2e0661ea63a659e19e54b36cd32f307e65fe7a44beaddfc35ea07a602670220325075c71d34d52fbc1f4abc53c655cae3748e2300b3bb990db323cfb18d1aee
Observed behaviour
Getting an exception: 'Unsupported message type'
However, when debegging the following error is the actual one:
'Unexpected end of data'
stack:'SyntaxError: Unexpected end of data
at decode (/home/muhammad/Repositories/interop-microservice/node_modules/multibase/src/rfc4648.js:52:11)
at Object.decode (/home/muhammad/Repositories/interop-microservice/node_modules/multibase/src/rfc4648.js:118:14)
at Base.decode (/home/muhammad/Repositories/interop-microservice/node_modules/multibase/src/base.js:46:23)
at Object.u8a [as fromString] (/home/muhammad/Repositories/interop-microservice/node_modules/uint8arrays/from-string.js:46…ad/Repositories/interop-microservice/node_modules/did-jwt/src/VerifierAlgorithm.ts:11:30)
at VerifierAlgorithm (/home/muhammad/Repositories/interop-microservice/node_modules/did-jwt/src/VerifierAlgorithm.ts:54:34)
at verifyJWSDecoded (/home/muhammad/Repositories/interop-microservice/node_modules/did-jwt/src/JWT.ts:239:38)
at /home/muhammad/Repositories/interop-microservice/node_modules/did-jwt/src/JWT.ts:304:44
at processTicksAndRejections (internal/process/task_queues.js:93:5)
```
**Expected behaviour**
To be able to parse the JWT and save the message in the local DB.
**Additional context**
Add any other context about the problem here.
**Versions (please complete the following information):**
- Veramo: 1.2.0
- Node Version: 12.13.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
Yes, that should be ok.
Also, to help with debugging in VSCode make sure to enable sourcemaps and to include node_modules: Here’s an example launch configuration used for running a Jest test file called
custom.kms.test.ts
I hope it helps
unfortunately, I’m out of ideas. I can’t suggest anything more without knowing how your backend is producing the signature.
It doesn’t look like it’a a problem with veramo, but a problem with the signature encoding. Without knowing more about what you are working with, there’s nothing that can be done from our end 😦