Verify JWT Secured Authorization Response Mode (JARM) responses, the
client-side mirror of Attesto.JARM.response_jwt/4.
When a client requests a JWT response mode, the authorization server returns
the authorization response as a single signed JWT (the response parameter).
This verifies that JWT - signature, issuer, audience, and expiry - and returns
the response parameters (FAPI 2.0 Message Signing §5.4 / the JARM spec). It is
a verifier, not a flow runner: the host extracts response from the redirect
(or form post) and passes it here.
Checks (JARM §2.4)
- Signature verifies against one of the authorization server's JWKS keys,
restricted to an algorithm allow-list (
:accepted_algs, default the FAPI algorithms PS256/ES256/EdDSA/Ed25519 -noneis never accepted). RSA keys require at least 2048 bits under every policy. The default FAPI policy restricts legacyEdDSAto Ed25519. When the JWT header carries akid, exactly one suitable matching key must exist. issequals the expected authorization server identifier (:issuer).audequals, or (an all-string array) contains, the client'sclient_id(:client_id); a mixed-typeaudarray is malformed.iat, when present, is a non-negative NumericDate not meaningfully in the future (a 60-second clock-skew tolerance).nbf, when present, is a non-negative NumericDate no later than the same clock-skew window.expis present and in the future.
On success it returns {:ok, claims}, the full claim set - the caller reads
the response parameters (code/state on success, or error/
error_description/state on an error response).
Summary
Functions
Verify a JARM response JWT against the authorization server's jwks,
returning {:ok, claims} or {:error, reason}.
Types
@type error() ::
:invalid_jwks
| :missing_issuer
| :missing_client_id
| :unsupported_alg
| :invalid_token
| :invalid_signature
| :ambiguous_key
| :weak_key
| :unsupported_critical_header
| :invalid_policy
| :invalid_issuer
| :invalid_audience
| :invalid_iat
| :invalid_nbf
| :not_yet_valid
| :missing_exp
| :expired
Functions
@spec verify(String.t(), jwks(), [verify_opt()]) :: {:ok, map()} | {:error, error()}
Verify a JARM response JWT against the authorization server's jwks,
returning {:ok, claims} or {:error, reason}.
Required options: :issuer (the expected authorization server identifier) and
:client_id (the expected audience). Optional: :accepted_algs (default the
FAPI algorithms) and :now (Unix seconds, for tests). Supplying an explicit
:accepted_algs list selects a non-FAPI algorithm policy unless
:enforce_fapi_alg_policy is also true. RSA verification requires at least
2048 bits under either policy (RFC 7518 §3.3).