Skip to content
Wallet and Entity Collection draft updates
Documentation menu

5.5. Complete validation with authenticated protocol context

Feature guides / 5. Federation policy · Example context

Car Rental Company's presentation request contributes query information that must be checked together with federation policy. The application cannot make a final decision while required context is still missing.

How to use it

Use CredentialVerifierRole.prepareAuthorizationRequest() and completeAuthorizationRequest() for a Wallet presentation request. The role composes federation preparation, Request Object verification, and contextual policy completion. Keep the original preparation handle and supply the signed JWT through the host's approved retrieval path; preparation alone never accepts the request. Policy enforcement; Wallet request policy.

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

export async function validateDrivingLicenceRequest(
  engine: CryptoEngine,
  outer: WalletAuthorizationRequest, signedRequestJwt: string, anchors: TrustAnchorSet,
) {
  const prepared = await CredentialVerifierRole.prepareAuthorizationRequest(outer, anchors, { engine });
  if (!prepared.ok) return prepared;
  // For request_uri, retrieve only prepared.value.requestUri using the host transport.
  return CredentialVerifierRole.completeAuthorizationRequest(prepared.value, signedRequestJwt);
}

What your application owns

Preparation is not final acceptance. Complete using authenticated input and respect the saved evidence lifetime; do not manufacture or mutate preparation objects. Deferred issuer or registration-endpoint requirements must be satisfied before final effective metadata is used. Custom constraints can run again on completion. The host must not perform acceptance side effects merely because preparation succeeded.

Separate preparation from acceptance

A prepared chain gives Wallet Provider authenticated context for the remaining checks. It is not permission to disclose credentials or continue a registration. Supply only the protocol values whose origin and authenticity the current stage has established.

Keep the original preparation handle and complete it within its evidence lifetime. Do not serialize it into a job queue and reconstruct an equivalent-looking object in another process. If an operation crosses that boundary, retain the signed inputs and restart the validation workflow there. A completion error stops the dependent protocol action.

Custom protocol integrations

Use core's two-phase API only when implementing a protocol integration without an existing role workflow. The Wallet role already performs these steps; calling them again would create a second validation path.

Prepared evidence and completion rules

prepareTrustChainValidation(statements, trustAnchors, options) authenticates chain evidence while reserving explicitly named policy inputs that are absent from published metadata. Specify them through deferredClaims, an array of { entityType, parameter } pairs. Unrelated policies and policies for published values must pass during preparation.

The returned PreparedTrustChain is an opaque handle with pending claims and preliminary effective metadata. It is distinct from ValidatedTrustChain and DiscoveryResult. Call completeTrustChainValidation(prepared, contextualMetadata) to finish the policies against the original evidence. Only reserved fields can receive contextual values. Completion revalidates the chain, expiry, and cancellation; request-derived metadata stays outside signed statement payloads and shared discovery caches.

validateTrustChain keeps its existing strict behavior and never defers required inputs. Wallet roles use the staged APIs for request-dependent DCQL checks; see the wallet guide.

Composed hosts and Entity Statement builders check supplied OP/AS issuer values against the statement subject and prohibit jwks, jwks_uri, and signed_jwks_uri inside federation_entity metadata (Federation §§5.1.3–5.2.1). These checks allow partial metadata for superiors to complete. Federation Entity Keys belong in the statement’s top-level jwks.

Entity Identifiers reject query and fragment delimiters, including empty trailing ? and #, under Federation §1.2. Percent-encoded characters remain part of the identifier. Key URL helpers also enforce their fragment-free URL contract, including an empty #; that URL policy is separate from the Entity Identifier rules.

EntityRole.validateMetadata(metadata, context) is an optional synchronous hook. Hosts invoke it on detached composed role metadata before publication. Existing roles can omit it.

findInvalidMetadataNullPaths(metadata) returns the paths of forbidden null values. Statement builders, chain validation, and authority publication share this check. It rejects null entity-type blocks and direct metadata parameter values, following Federation §5. Nested objects and arrays may contain null; protocol-specific schemas, including wallet claim-path syntax, can impose additional restrictions.

Next: 6. Trust Marks

View source on GitHub