Skip to content
Wallet and Entity Collection draft updates
Documentation menu

16.7. Create a signed driving licence presentation request

Feature guides / 16. Wallet workflows · Example context

Car Rental Company asks Maya to prove driving licence. Its request should identify the verifier, bind the response to a fresh interaction, and request the agreed credential data.

How to use it

CredentialVerifierRole.createAuthorizationRequest() signs a Request Object with the verifier's protocol key. For direct_post it requires response_uri and disallows redirect_uri in the request. The query below is supplied by the application's selected driving licence profile. Wallet verifier requests.

On an attached role instance, a chain configured in the role's options is used without repeating it on every call. Anchors come from the call, the role's dedicated setting, its options, or the host, in that order.

import type { CryptoEngine, KeyringEntry } from "@oidfed/crypto";
import { CredentialVerifierRole, type DcqlQuery } from "@oidfed/wallet";

export async function requestDrivingLicence(
  engine: CryptoEngine,
  signer: KeyringEntry,
  query: DcqlQuery,
  nonce: string,
) {
  return CredentialVerifierRole.createAuthorizationRequest("https://car-rental.example", {
    response_type: "vp_token", response_mode: "direct_post",
    response_uri: "https://car-rental.example/presentation", nonce, dcql_query: query,
  }, signer, { engine });
}

Supply the licence query from the protocol engine

For an mDL-format licence, an application can request a defined element from its namespace. The host owns the actual query and its matching and disclosure rules:

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

export const licenceQuery: DcqlQuery = {
  credentials: [{
    id: "driving_licence", format: "mso_mdoc",
    meta: { doctype_value: "org.iso.18013.5.1.mDL" },
    claims: [{ path: ["org.iso.18013.5.1", "driving_privileges"] }],
  }],
};
// Pass licenceQuery to the request-creation operation above.

This selects credential data; it does not encode, sign, or validate an mDL. Those operations belong to the host's credential-format implementation. Other-format examples describe separate supported integrations, not interchangeable licence encodings.

What your application owns

Generate and store a fresh session nonce, host the request if using a request URI, and verify the returned presentation through the protocol engine. When attaching a signing chain, restrict anchors to those accepted by the wallet when known. The library validates the supplied chain's signer identity, but does not implement an automatic wallet-metadata exchange to choose every recipient's anchor.

Select evidence the wallet can validate

Car Rental Company prepares its federation-backed signed request using a chain the target wallet can accept. Learn the wallet's trust and format information through the protocol's supported mechanisms or prior configuration; this library does not perform the Request URI POST exchange for you.

Keep the signed payload and the outer request parameters consistent, and attach only the verified chain for the signing entity. The request-creation helper does not implement the verifier's response endpoint or validate the returned presentation. Those steps belong to Car Rental Company's presentation protocol engine.

Request parameters and recipient-compatible anchors

Request scopes follow RFC 6749 §3.3: a request may contain space-separated tokens, while a credential configuration advertises one token. Recognized DCQL authority constraints validate Federation Entity Identifiers and base64url aki values; custom authority types remain open.

The keys in vp_formats_supported must be nonblank. Unknown DCQL format strings are preserved for the host to interpret. Format-specific capability fields are optional and extension fields are preserved. Completion checks active query formats against effective vp_formats_supported; creation applies the same check when supplied with a validated chain and a concrete query or scope mapping. Superior query overrides determine which queries are active. Credential-format processing and cryptographic capability checks belong to the application.

import type { CryptoEngine, KeyringEntry } from "@oidfed/crypto";
import { CredentialVerifierRole, type DcqlQuery } from "@oidfed/wallet";

export async function createPresentationRequest(
  engine: CryptoEngine,
  verifierEntityId: string,
  sessionNonce: string,
  presentationQuery: DcqlQuery,
  protocolSigner: KeyringEntry,
) {
  const created = await CredentialVerifierRole.createAuthorizationRequest(
    verifierEntityId,
    {
      response_type: "vp_token",
      response_mode: "direct_post",
      response_uri: "https://verifier.example/response",
      nonce: sessionNonce,
      dcql_query: presentationQuery,
    },
    protocolSigner,
    { engine },
  );
  if (!created.ok) throw new Error(created.error.description);
  const requestObject = created.value;
  return created;
}

The helper sets the openid_federation: client identifier and wallet audience, validates the request parameters, and signs with the supplied protocol signer. direct_post requires response_uri and prohibits redirect_uri in the Authorization Request (OpenID4VP §8.2). The same rules apply to direct_post.jwt. A request cannot contain both URI parameters. The helper requires redirect_uri for fragment and accepts nonblank extension response modes for application-defined processing. Mode names are compared exactly.

Supplied response and redirect URIs must be HTTPS URLs, matching Wallet Draft 05 §6.3.1. Invalid response parameters return invalid_request before signing or trust-chain preparation. Without a supplied trustChain, creation needs no discovery; with one, provide pinned trustAnchors for its validation. Endpoint authorization is checked by the receiving wallet against the effective federation metadata during completion (§7.1.1). The application's OpenID4VP engine handles request delivery and response processing, including encryption for direct_post.jwt.

For the shared-anchor flow described in Wallet Draft 05 §9, the application selects a verifier chain ending at an anchor accepted by the target Wallet. Obtain the Wallet's accepted anchor identifiers through the deployment's metadata or configuration mechanism: OpenID4VP §10.2 permits dynamic, out-of-band, and static metadata. Request URI POST and metadata acquisition belong to the application's protocol engine.

Restrict the verifier's locally pinned anchors to that intersection before signing. In this example, locallyPinnedAnchors is a TrustAnchorSet, walletAcceptedAnchorIds is an application-provided ReadonlySet<string>, and selectedVerifierChain contains the signed statements already selected for this Wallet. These variable names do not define new wallet_metadata parameters. Retain the locally configured keys; Wallet-advertised identifiers constrain which local pins may be used.

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

export async function createRequestForWalletAnchors(
  engine: CryptoEngine,
  locallyPinnedAnchors: TrustAnchorSet,
  walletAcceptedAnchorIds: ReadonlySet<string>,
  verifierEntityId: string,
  presentationRequest: Readonly<Record<string, unknown>>,
  protocolSigner: KeyringEntry,
  selectedVerifierChain: readonly string[],
) {
  const sharedTrustAnchors = new Map(
    [...locallyPinnedAnchors].filter(([id]) => walletAcceptedAnchorIds.has(id)),
  );
  if (sharedTrustAnchors.size === 0) {
    throw new Error("No shared Trust Anchor with the target Wallet");
  }

  const createdForWallet = await CredentialVerifierRole.createAuthorizationRequest(
    verifierEntityId,
    presentationRequest,
    protocolSigner,
    {
      engine,
      trustChain: selectedVerifierChain,
      trustAnchors: sharedTrustAnchors,
    },
  );
  if (!createdForWallet.ok) throw new Error(createdForWallet.error.description);
  return createdForWallet;
}

The restricted pins enforce the selection: a supplied chain ending at any other anchor is rejected before the signer is invoked. The helper does not automatically choose a replacement chain. The application must select a compatible chain or stop when no shared anchor exists.

When transaction_data is present, creation checks its structure, credential references, and the SD-JWT holder-binding requirement before signing. AuthorizationRequestCreationOptions.scopeQuery supplies the application's DCQL mapping for a signed scope. This mapping is required for scope-based transaction requests unless a validated supplied chain provides a superior query override. Inline dcql_query takes precedence over this local mapping. The mapping stays local; the signed request retains its scope and original encoded transaction strings. Scope-based creation without transaction data needs no mapping.

Creation requires state when a known active query sets require_cryptographic_holder_binding: false, except for dc_api and dc_api.jwt (OpenID4VP §5.3). It checks the superior override, inline query, or supplied scope mapping. For an opaque scope without a mapping, the application must enforce this condition. The application generates fresh state with at least 128 bits of entropy, binds it to the session, and checks the returned value.

The SD-JWT check prevents the helper from signing requests the receiving wallet must reject under OpenID4VP Appendix B.3.3. The local mapping requirement is an oidfed API contract: the application must supply the query corresponding to its scope. Creation uses effective superior queries when available from the validated supplied chain; otherwise it checks the inline or mapped query. The receiving wallet applies its own federation evidence and application checks. The verifyTransactionData and queryPolicy callbacks run during completion.

Authorization Request redirect_uri and response_uri values must be fragment-free, including an empty trailing # (RFC 6749 §3.1.2, OpenID4VP §8.2). The same rule applies to registered response_uris. Query strings and percent-encoded %23 remain valid.

Registered redirect_uris can contain fragments for redirects returned after a direct-post response; OpenID4VP §8.2 permits a random value in that fragment. Request Object URLs can also contain fragment hashes, as recommended by OpenID Connect Registration §2. Endpoint authorization compares the complete registered strings exactly.

Metadata fields that require HTTPS, including endpoint and key-reference URLs, reject userinfo and empty @ delimiters. This adopts the receiver rejection policy recommended by RFC 9110 §4.2.4; that section also prohibits senders from generating HTTP(S) target or field URIs containing userinfo. The same check applies to response and redirect URIs in Authorization Requests.

Next: 16.8. Validate a verifier’s presentation request

View source on GitHub