Skip to main content

Module jwt

Module jwt 

Source
Expand description

JWT token implementation with Ed25519 (EdDSA) signatures.

Implements a minimal JWT encoder/decoder for API authentication. Uses Ed25519 signatures for stateless token validation.

§Token Format

Standard RFC 7519 JWT:

  • Header: {"alg":"EdDSA","typ":"JWT"}
  • Payload: Claims (sub, exp, iat)
  • Signature: Ed25519 over base64url(header).base64url(payload)

Structs§

CompositeJwtDispatch
Parser-produced dispatch for a composite JWT. Its fields are private so callers cannot supply metadata that disagrees with the signed header.
ProtectedHeader
Duplicate-detecting, closed protected JOSE header used for security dispatch.

Enums§

JwkThumbprintInput
Input for RFC 7638 JWK Thumbprint computation.
JwtError
Errors from JWT operations

Constants§

RFC9068_ACCESS_TOKEN_TYPES
The two exact access-token type forms resource servers must accept under RFC 9068 section 4. Matching is intentionally case- and whitespace-sensitive.

Functions§

composite_kid
Compute the RFC 7638 thumbprint for one exact composite public-key pair.
decode
Decode and verify a JWT token issued by the local node.
decode_composite
Decode and verify a composite ML-DSA-65-Ed25519 JWT.
decode_ml_dsa_65
Decode and verify a JWT signed with ML-DSA-65 (alg: "ML-DSA-65").
decode_unverified
Decode a JWT without verifying the signature.
decode_with_any_key
Try every supplied Ed25519 key for a JWT that has no kid.
decode_with_any_key_lenient
Lenient-audience twin of decode_with_any_key. This remains restricted to kid-less JWTs; only the absent-audience behavior differs.
decode_with_federation_candidates
Verify a federation JWT without losing its JWKS kid binding.
decode_with_key
Decode a JWT using a caller-supplied verifying key (for multi-issuer support).
encode
Encode a user/client OAuth 2.0 access token (typ: "at+jwt", RFC 9068). Includes kid in the JOSE header for key rotation support. Automatically assigns a jti if the claims don’t already have one.
encode_id_token
Encode and sign an OIDC ID Token (EdDSA with kid in header).
encode_service_jwt
Encode a WIMSE Workload Identity Token (typ: "wit+jwt") for service JWTs. Includes kid in the JOSE header for key rotation support. Automatically assigns a jti if the claims don’t already have one.
encode_service_jwt_hybrid
Encode a composite ML-DSA-65-Ed25519 service WIT (typ: "wit+jwt").
header_alg
Extract the alg from a JWT’s JOSE header without verifying the signature.
header_kid
Extract the kid from a JWT’s JOSE header without verifying the signature.
is_rfc9068_access_token_type
Return whether typ is exactly one of the RFC 9068 access-token forms.
jwk_thumbprint
Compute the RFC 7638 JWK Thumbprint for any supported key type.
kid_for_key
Compute the JWT kid for an Ed25519 signing key using RFC 7638 JWK Thumbprint.
parse_composite_dispatch
Parse composite dispatch exactly once and enforce the caller’s allowed types.
parse_protected_header
Parse a JWT protected header exactly once for security dispatch.