Host-facing OID4VP verifier API.
Presentation requests are persisted before their signed request object is
published. Wallet direct POST and DC API page submissions share response
decryption; the session's stored request determines its flow. Hosts read
the completed result once through
presentation_result/2 (single-use: the read consumes the session).
Request objects continue to use the main AttestoPhoenix.Config.keystore/1; their protected
alg is derived from that key by Attesto.JWS.sign_current. Encrypted modes
generate a fresh ECDH-ES recipient key per session and do not change
request-object signing policy.
Summary
Functions
Complete a DC API session using the page's DigitalCredential.data object.
Verify and atomically complete an OID4VP direct-post presentation response,
returning {:ok, %{"redirect_uri" => redirect_uri}} or {:error, reason}.
Create a verifier presentation session and its signed request object.
Read a pending request for its transport. DC API returns the protocol and
data object for navigator.credentials.get; redirects return a compact JWS.
The session's stored signed request records the mode and expected origin.
Read and consume the verified result of a completed presentation session.
Types
@type create_attrs() :: %{ :dcql_query => map(), :expected_query_ids => [String.t()], optional(:issuer_trust) => Attesto.PresentationSession.issuer_trust(), optional(:response_mode) => String.t(), optional(:client_id_scheme) => String.t() }
Functions
@spec complete_dc_api_response(AttestoPhoenix.Config.t(), String.t(), map()) :: {:ok, map()} | {:error, :invalid_request | :misconfigured}
Complete a DC API session using the page's DigitalCredential.data object.
id comes from the session-specific POST URL returned at creation. The JWE
kid must match it. No wallet state or supplied origin is used. Returns a
single-use response_code for presentation_result/2; no wallet redirect.
@spec complete_presentation_response( AttestoPhoenix.Config.t(), AttestoPhoenix.Verifier.PresentationResponse.t() | map() ) :: {:ok, %{required(String.t()) => String.t()}} | {:error, :invalid_request | :misconfigured}
Verify and atomically complete an OID4VP direct-post presentation response,
returning {:ok, %{"redirect_uri" => redirect_uri}} or {:error, reason}.
@spec create_presentation_request(AttestoPhoenix.Config.t(), create_attrs()) :: {:ok, create_result()} | {:error, term()}
Create a verifier presentation session and its signed request object.
Redirects remain the default: the returned id is the OID4VP state and
request_uri serves the signed request object.
Select response_mode: "dc_api.jwt" for Digital Credentials API sessions.
:verifier_dc_api_origin must be configured at boot. The result also includes
dc_api_request (protocol and data.request, OpenID4VP 1.0 §§A.1, A.3.2.1)
and response_uri, the session-specific URL to which the page posts
DigitalCredential.data. GET request_uri returns the same descriptor.
The signed request records dc_api.jwt and the configured expected_origins
(§A.2); it contains neither state nor response_uri. The origin is not a
per-request attribute. Plain dc_api is unsupported (HAIP 1.0 §5.2).
Hosts bind creation, submission, and result consumption to their browser session and enforce CSRF protection on browser actions.
With :verifier_trusted_certificates, omit :issuer_trust: every session
uses the configured anchors and a per-request override is refused. Otherwise
:issuer_trust retains its existing meaning, with :verifier_issuer_trust
providing an optional default.
@spec presentation_request(AttestoPhoenix.Config.t(), String.t()) :: {:ok, :dc_api, map()} | {:ok, :redirect, String.t()} | :error
Read a pending request for its transport. DC API returns the protocol and
data object for navigator.credentials.get; redirects return a compact JWS.
The session's stored signed request records the mode and expected origin.
@spec presentation_result(AttestoPhoenix.Config.t(), String.t()) :: {:ok, map()} | :error
Read and consume the verified result of a completed presentation session.
Single-use: the completed session is removed on read, so the response_code
the browser carries to the completion page cannot be replayed to re-read the
presented claims. Returns :error on a second read, or an unknown, pending,
or expired session.