Skip to content
Wallet and Entity Collection draft updates
Documentation menu

16.8. Validate a verifier’s presentation request

Feature guides / 16. Wallet workflows · Example context

Maya's wallet receives a link from Car Rental Company. Before fetching a Request Object or asking Maya to disclose anything, it establishes verifier trust and the authorized request location.

How to use it

Use prepareAuthorizationRequest() on the outer request, then completeAuthorizationRequest() with the signed JWT fetched by the host. Keep the original preparation object. Preparation does not accept the final request; completion binds it to the saved verifier evidence and applies effective query policy. VP request URI.

When several discovered paths reach Car Rental Company, completion chooses the shortest path whose own keys and policy accept the request by default. A configured chainSelection selects among those eligible paths after completion checks; incomplete discovery fails before a custom selector runs. An unusable embedded hint can fall back to online discovery within the same budget. An explicitly supplied trustChain stays authoritative, and offline operation never performs that fallback. Federation acceptance still leaves session checks, including OpenID4VP's applicable state requirements, to your protocol engine.

import type { CryptoEngine } from "@oidfed/crypto";
import { CredentialVerifierRole, type WalletAuthorizationRequest } from "@oidfed/wallet";
import type { TrustAnchorSet } from "@oidfed/core";

export async function verifyPresentationRequest(
  engine: CryptoEngine,
  outer: WalletAuthorizationRequest, anchors: TrustAnchorSet,
  retrieve: (approvedUri: string) => Promise<string>,
) {
  const prepared = await CredentialVerifierRole.prepareAuthorizationRequest(outer, anchors, { engine });
  if (!prepared.ok) return prepared;
  const jwt = outer.request ?? (prepared.value.requestUri
    ? await retrieve(prepared.value.requestUri) : undefined);
  if (!jwt) throw new Error("No Request Object available");
  return CredentialVerifierRole.completeAuthorizationRequest(prepared.value, jwt);
}

What your application owns

The retrieve callback must implement the selected GET/POST exchange, transport limits, and any wallet metadata/nonce behavior required by the protocol. It is not permission to fetch arbitrary unvalidated URLs.

Use the completed request together with effectiveQueries; the library removes untrusted client metadata and query fields superseded by immediate-Superior metadata. Without that override, the sanitized request still carries the active query while effectiveQueries may describe a separate federation-published scenario list. Apply the framework matching rules before disclosure.

Before a final UI redirect, CredentialVerifierRole.validateResponseRedirect() checks the destination against saved verifier metadata. The wallet still owns consent and credential selection.

Stop before disclosure on a failed completion

The preparation step identifies usable verifier evidence and the approved retrieval context. The host retrieves the signed request using its transport controls, then completes validation with the original handle. Only a successful completion produces the effective query and verifier context used in the next stage.

If evidence expired or completion rejects the request, restart the relevant trust workflow or stop the interaction. Do not reuse a prepared handle as a permanent verifier approval. Wallet Provider still binds the request to its protocol session, checks required state and nonce behavior in that engine, and asks Maya for consent before releasing a presentation.

Complete a request with authenticated context

import type { CryptoEngine } from "@oidfed/crypto";
import { CredentialVerifierRole, type ValidatedWalletRequest } from "@oidfed/wallet";
import { type TrustAnchorSet } from "@oidfed/core";

export async function receivePresentationRequest(
  engine: CryptoEngine,
  outerClientId: string,
  requestObjectUri: string,
  trustAnchors: TrustAnchorSet,
  walletNonce: string,
  vpEngine: { retrieveRequestObject: (uri: string, walletNonce: string) => Promise<string>; process: (request: ValidatedWalletRequest) => Promise<void> },
) {
  const prepared = await CredentialVerifierRole.prepareAuthorizationRequest(
    {
      client_id: outerClientId,
      request_uri: requestObjectUri,
      request_uri_method: "post",
    },
    trustAnchors,
    { engine },
  );
  if (!prepared.ok) throw new Error(prepared.error.description);

  // The application's OpenID4VP engine performs the authorized GET or POST.
  const requestUri = prepared.value.requestUri;
  if (!requestUri) throw new Error("Prepared Request Object URI is missing");
  const jwt = await vpEngine.retrieveRequestObject(requestUri, walletNonce);
  const checked = await CredentialVerifierRole.completeAuthorizationRequest(
    prepared.value,
    jwt,
    { walletNonce },
  );
  if (!checked.ok) throw new Error(checked.error.description);

  await vpEngine.process(checked.value);
}

maxRequestAgeSeconds is an optional wallet freshness policy. When set, completion requires iat within the configured window and clock-skew tolerance. Supplied expiry and activation claims retain RFC 7519 semantics. Request creation rejects invalid dates, expired output, and an empty nbf/exp interval. Completion rechecks expiry after callbacks; retained redirect validation also observes the request's applicable expiry and age limit.

Preparation checks the federation chain, effective signing keys, and registered Request Object endpoint. It returns an opaque preparation handle, not a fully validated chain. Completion checks the signed object, its type, the full prefixed client identifier, applicable wallet nonce, audience, endpoints, and pending DCQL policies. It rejects expired or cancelled preparation.

When discovery returns several paths, completion selects the shortest path that passes those checks by default. A custom chainSelection receives only eligible paths; incomplete discovery rejects before that selector runs. Explicitly supplied chains remain authoritative. An embedded chain is tried first; if it fails the request's federation checks, online operation can discover another path within the same budget. Keys and permissions from different paths are never combined. Policy callbacks may run for more than one candidate.

By default, the expected Request Object audience is https://self-issued.me/v2 for static wallet discovery. Set walletIssuer to the issuer from dynamically obtained Wallet metadata; acquiring that metadata belongs to the host. An optional Request Object iss is ignored according to OpenID4VP. Protocol parameters come from the signed object; outer request parameters cannot override them. For inline delivery, supply request during preparation and complete with that same JWT. Preparation rejects an incorrect JWT type before using its discovery hints.

The application's transport must enforce OpenID4VP's GET/POST rules, response media type, and HTTP-error handling. It must perform session binding and any remaining protocol checks. Requests with transaction data require a verifyTransactionData callback to validate the transaction type and its contents after the library's request checks pass. Credential selection, selective disclosure, presentation verification, and actual Holder Binding remain protocol-engine responsibilities.

Federation acceptance does not establish complete OpenID4VP protocol validity. In particular, your protocol engine handles the state requirements for presentations without holder binding: generation, entropy, freshness, session storage, and matching the returned value. The existing request-creation helper checks for missing state where it can determine that requirement; completion is not a substitute for the engine's session checks.

Before invoking verifyTransactionData, the library checks that every transaction credential ID belongs to the active presentation query. The callback's queries contains the signed request query or the application's scopeQuery mapping; when superior metadata overrides the request, it contains that effective list. The published authorization list remains available through effectiveQueries and queryPolicy. DCQL claim sets may include an empty alternative to request no selectively disclosable claims.

Completion rejects transaction data referencing a dc+sd-jwt query with require_cryptographic_holder_binding: false, as required by Appendix B.3.3. An omitted flag defaults to true (§6.1). Unrelated queries may disable binding. When separate superior scenarios reuse a credential ID, oidfed checks every matching definition, so a binding-disabled SD-JWT match causes rejection regardless of scenario order.

The original encoded transaction strings remain available in request.transaction_data; the callback receives decoded objects with their extension fields. The protocol engine must construct and verify the required cryptographic bindings, including hashes over the original encoded strings when using the profile in Appendix B.3.3.1.

Only registered request, response, and redirect endpoints are allowed. After direct_post, check a Response Endpoint's returned redirect before following it:

import { CredentialVerifierRole, type ValidatedWalletRequest } from "@oidfed/wallet";

export async function checkResponseRedirect(checkedRequest: ValidatedWalletRequest, responseRedirectUri: string) {
  const redirect = CredentialVerifierRole.validateResponseRedirect(
    checkedRequest,
    responseRedirectUri,
  );
  if (!redirect.ok) throw new Error(redirect.error.description);
  return redirect;
}

DCQL processing follows Wallet Draft 05 §7.1.1. A superior-provided metadata list overrides request queries. Otherwise, metadata policies apply to the verifier's published queries, or to client_metadata.dcql_query when those queries are absent. The latter is implemented as a narrow wallet-profile exception to OpenID4VP's general instruction to ignore client_metadata for openid_federation. This is an interpretation of the two texts; it does not permit request-supplied keys or endpoints.

effectiveQueries contains the policy-processed federation query list when available, or the validated request query otherwise. querySource identifies superior metadata, verifier metadata, metadata policy, or the request. The returned request and the queryPolicy callback receive the same sanitized fields: client_metadata is always removed; a superior metadata override also removes dcql_query, dcql_queries, and scope.

Removing the plural request field is a defensive library choice. Wallet Draft 05 §7.1.1 explicitly requires ignoring the singular dcql_query, while §11.1.1 registers dcql_queries for authorization requests without defining its evaluation. Without a superior override, the library preserves the plural field as an uninterpreted extension. It never uses that field to compute effectiveQueries or satisfy OpenID4VP's requirement for dcql_query or scope.

For received DCQL, completion ignores later claim queries with the same path, following OpenID4VP §6.1. It keeps the first claim’s constraints and redirects references in claim_sets to that claim, preserving alternative order and empty alternatives. Federation policies run on the original input before this normalization. Creation and metadata publication still reject duplicate paths.

A leaf-published scenario list remains separate from the selected signed query. Without a superior override, completion validates that query even when metadata lists authorized scenarios. Scope-based requests require the application's mapped scopeQuery at completion. Bind that mapping to the verified request’s scope before acting on the result; the API accepts the mapped query as an object. The protocol engine must apply the authorization context when selecting credentials. An optional queryPolicy callback enforces framework restrictions using the selected request and the effective list. For example, a framework can require an inline query to equal one authorized scenario, using structural JSON equality, or permit a defined refinement. A policy-approved contextual query does not by itself authorize a different active query. Wallet §6.3.1 leaves this profile choice to the framework; configure the callback or enforce it in the protocol engine before releasing credentials.

For an inline-only application profile, this callback requires a federation-supplied scenario list and an exact match. sameJson is the application's structural JSON comparator: object property order is irrelevant and array order is preserved. Handle mapped scopes and superior overrides according to your profile if you support them.

import type { AuthorizationRequestOptions } from "@oidfed/wallet";

// Supply the host's JSON comparison; do not compare objects by property order.
export function exactFrameworkQuery(sameJson: (left: unknown, right: unknown) => boolean): AuthorizationRequestOptions["queryPolicy"] {
  return ({ request, queries, chain }) =>
    Array.isArray(chain.resolvedMetadata.openid_credential_verifier?.dcql_queries) &&
    request.dcql_query !== undefined &&
    queries.some((allowed) => sameJson(allowed, request.dcql_query));
}

Keep the original preparation handle until completion, and complete it before its expiration. The handle belongs to the current process; copying it into another object or storing it as JSON does not preserve the retained evidence. Preparation alone does not accept the request.

Next: 16.9. Apply effective DCQL and framework query policy

View source on GitHub