LanguageValues and typesStandard typesSecurity
Jwt
On this page
A signed token: three parts joined by ..
Use it for a token you receive. crypto.verify_jwt checks it and gives its JwtClaims. Don't read one without checking it.
Shape
One secret value, with no parts.
Example
var example: Jwt = Jwt("eyJhbGciOiJFZERTQSJ9.RXhhbXBsZSBvZiBFZDI1NTE5IHNpZ25pbmc.hgyY0il_MGCjP0JzlnLWG1PPOt7-09PGcvMg3AIbQR6dWbhijcNR4ki4iylGjg5BhVsPt9g7sVvpAr_MuM0KAg")assert example == example
In a real app it arrives from outside, such as in a request, rather than as text you write in your code.
text.parse(raw, as: Jwt) reads one from text that comes from outside. Text that isn't one at all fails malformed.
Good to know
- It is a secret, so it is never sent, logged, stored or shown.
- A token with no signature is refused.
==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
A string when it arrives, and written redacted when it leaves, in a request, a response or json.write:
"<redacted Jwt>"Details
Text form, storage, how it is shown, and operations
Jwt is in the group Security, and has been in Jadpo since 0.1.0.
Text form
text.parse reads one from its text as it is typed. text.from and text.format don't take it, so nothing writes it.
How it is stored
It is never stored.
How it is shown to people
text.format doesn't take it: a Jwt is never shown.
Operations
crypto.verify_jwt(token: Jwt, keys: List<Jwk>, issuer: Text?, audience: Text?, as: Type?) -> JwtClaims: The registered claims oftokenonce it holds: signed by one ofkeyswith that key's own algorithm (Ed25519, RS256 for an RSA key, ES256 for a P-256 key), never the one the token names, sononeand every other algorithm failinvalid_signature; not expired, not used before itsnbfand not issued later than now, against the clock with 30 seconds' leeway (expired,not_yet_valid); issued byissuerwhen one is given (wrong_issuer); and foraudience, or for no audience when none is given (wrong_audience). A token that isn't one, or has noexp, ismalformed. Withas:, an object type of the application's, it gives instead the token's claims the type names, read asjson.readreads it, a registered one asJwtClaimsholds it, and failsmismatchwhen they aren't the type. It reads the clock, so it is called only in actions.
It also takes text.parse, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-jwt.md.Built from Jadpo main at aee2e8f.