jwt.verify() returns numeric payload claims as strings
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js, typescript
- Domain
- authentication, backend, security
Research direction
Start by running the reported jwt.sign() and jwt.verify() snippet in the repository's existing test setup, then trace the verify() entry point to see how the decoded payload is represented. Confirm whether a numeric id remains a number at runtime and add a regression test covering this behavior; done means the test and the reported example agree on the claim type.
Written by the indexing model from the issue text.
Description
Explanation:
I hope you doing great guys
When I use "verify()" in Typescript it is going to return string for everything even the one was a number in the "sign()" object payload.
Summary of the issue:
When signing a JWT with a numeric id claim, jwt.verify() appears to return the claim as a string instead of a number.
A small copy of my code:
const token = jwt.sign(
{ id: 67 },
secret
);
const decoded = jwt.verify(token, secret) as { id: number };
console.log(typeof decoded.id);
Expected behavior:
number
Actual behavior:
string
I checked the value before calling "jwt.sign()" and was confirmed to be a number .
Environment
Node.js: v20.20.2
Package: [jsonwebtoken, @types/jsonwebtoken]
Package version: [^9.0.3, ^9.0.10]
OS: window 11
I hope you have a great day.
- Dominant language
- JavaScript
- Stars
- 18.2k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/node-jsonwebtoken
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
auth0/node-jsonwebtoken#1000 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
auth0/node-jsonwebtoken#1048 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 65/100
auth0/node-jsonwebtoken#1046 ·
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
auth0/node-jsonwebtoken#1034 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
auth0/node-jsonwebtoken#1032 ·
All issues in auth0/node-jsonwebtoken
Similar issues
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
amponce/archive-movie-browser#354 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
saayam-for-all/webapp#1870 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Imageomics/OpenCite#66 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
chr15m/twiiit.com#20 ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
antropos17/Aegis#629 ·
Maintainers usually reply within 4 days