Closed iosdeveloper closed 10 months ago
Tried to reproduce using this Worker: https://github.com/tsndr/jwt-test
Which resulted in this response:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0IiwibW9yZSI6IkB0ZXN0IiwiaWF0IjoxNzAwMTM3MzUzfQ._yucoh2EkUExiPmI5ugUfxs-BAPpoyKmJ-MrHZdGq8Q",
"decoded": {
"header": null,
"payload": {
"sub": "test",
"more": "@test",
"iat": 1700137353
}
},
"verified": true
}
I found out the hard way that you can't use the
@
character in the payload. Thesign
function will generate a valid token, but thedecode
function will returnnull
and thevalid
function will be false (or throwPARSE_ERROR
). UsingencodeURIComponent
or%40
instead will fix it, but it doesn't seem that one should have to encode every payload before passing it tosign
.edit: Using secret string, e.g.
423e72ec59e3735d6e0cd5ed16707ba87659ff9aa0b938228fbeda5594c82867
.