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 -noneis never accepted). When the JWT header carries akid, only the matching key is tried. 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).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_signature
| :invalid_issuer
| :invalid_audience
| :invalid_iat
| :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).