A pass at the Pos Ronda gate: a JWT split and read for real. Does reading its payload need a key, and what happens when its content is changed? An interactive…
Why it matters
Misreading "JWT is encrypted" is a real security bug: people put a password or personal data in the payload, or trust the payload on the client without verifying the signature. Knowing decode is not verify stops both, and reading exp as seconds stops accepting expired tokens.
The key idea
Decode is base64, verify is the signature
Common mistakes
Putting sensitive data in the payload The payload is just base64url, read by anyone. Never put a password, PIN, or personal data there. Treat it as public, and encrypt (Web Crypto) what is truly secret.
Trusting the payload on the client without verifying Without verifying the signature, the payload can be forged: change role to admin and re-encode. Verify on the server with the secret before trusting the contents.
Reading exp as millisecondsexp, iat, nbf are in epoch SECONDS. Use new Date(exp * 1000) and compare with Math.floor(Date.now() / 1000). Forget the 1000, and everything looks like 1970.
Try it in this playground
Open the payload with no key The header & payload become JSON at once. Anyone holding the pass reads it.
Change role and re-encode The payload changes, yet it still reads cleanly: decode is not verify.
Read exp against the clock Epoch seconds become a readable time; if it is past, it is flagged expired.
Find a secret in the payload A PIN in the payload reads in an instant. The payload is no place for a secret.