Skip to content
Wallet and Entity Collection draft updates
Documentation menu

16.1. Compose a wallet federation participant

Feature guides / 16. Wallet workflows · Example context

Driving Licence Federation connects Licensing Authority, Wallet Provider, and Car Rental Company. Licensing Authority issues driving licence credentials, Wallet Provider provides wallet software, and Car Rental Company requests presentations. Maya's wallet instance is not automatically a new federation host.

How to use it

Use CredentialIssuerRole, WalletProviderRole, and CredentialVerifierRole for the corresponding metadata and trust workflows. Attach roles to an authority or Leaf where the deployment has a federation identity. Static methods support wallet applications that do not host an EC. Wallet actors; Entity types.

import { CredentialVerifierRole } from "@oidfed/wallet";
import { Leaf } from "@oidfed/leaf";
import type { CryptoContext, JWKSet, TrustAnchorSet } from "@oidfed/core";

export async function carRental(keys: CryptoContext, protocolKeys: JWKSet, anchors: TrustAnchorSet) {
  const role = new CredentialVerifierRole({ metadata: {
    vp_formats_supported: { "mso_mdoc": { issuerauth_alg_values: [-7], deviceauth_alg_values: [-7] } }, jwks: protocolKeys,
    response_uris: ["https://car-rental.example/presentation"],
    redirect_uris: ["https://car-rental.example/done"],
  } });
  return await Leaf.create({
    entityId: "https://car-rental.example", authorityHints: ["https://licence-federation.example"],
    metadata: { federation_entity: {} }, crypto: keys, trustAnchors: anchors, roles: [role],
  });
}

What your application owns

The host owns the wallet UI, consent, credential storage, issuance protocols, and format-specific verification. The host supplies the licence registry, credential-format engine, and rental eligibility rules. Use protocol keys for presentation and attestation operations and federation keys for Entity Statements. Metadata publication permits superior completion; effective discovery checks the completed role metadata.

Keep provider, instance, issuer, and verifier distinct

Wallet Provider's federation entity represents the Wallet Provider. Maya's wallet instance is the subject of a Wallet Attestation and has its own proof key. Licensing Authority issues the driving licence credential, while Car Rental Company requests a presentation. Give each actor the configuration and trust inputs for its own role.

Publish role metadata through the selected Leaf or Authority and inspect its effective value after policy. Constructing a role does not provision a wallet instance, enroll Maya in the licence scheme, or start an issuance exchange. Those remain actions of the surrounding applications.

Metadata ownership and prepared request handles

Wallet roles copy constructor metadata. A host captures a separate copy after the role initializes, so changing the original configuration afterward does not change what that host publishes. Construct a replacement host to change general metadata. Per-call options override role options, which override host options; explicit trust anchors take precedence over configured defaults.

parsePublicationMetadata() checks supplied fields while allowing Superior completion. parseMetadata() checks effective protocol metadata. Neither establishes federation trust on its own.

Keep the original handle returned by prepareAuthorizationRequest() and pass it to completeAuthorizationRequest() before it expires. The handle refers to evidence held in the current process; a clone or JSON round trip cannot restore it. Preparation alone does not accept the request. Completion checks the signed JWT and contextual policies using the retained evidence, and returns a Result.

Credential and presentation processing remain application responsibilities. For example, verifyCredential() establishes issuer trust and invokes the verifier supplied by the host; the host implements credential-format, proof, and status checks.

Publication checks and role composition

WalletProviderRole uses openid_wallet_provider, CredentialIssuerRole uses openid_credential_issuer, and CredentialVerifierRole uses openid_credential_verifier. The same roles can be attached to TrustAnchor and Intermediate. Create a fresh role instance for each host.

Hosts compose role metadata with their own metadata, then call the optional EntityRole.validateMetadata hook before publication. Role configuration takes precedence over fields supplied by the host. Wallet roles validate supplied fields, including exact equality between a supplied credential_issuer and the host's Entity Identifier. Publication accepts partial or empty blocks so a superior can complete them, as allowed by Federation §5 and Wallet §7.1.

Effective provider and verifier metadata require vp_formats_supported. Issuers require credential_issuer, credential_endpoint, and credential_configurations_supported, with the nested requirements from OpenID4VCI. Metadata extensions are preserved. Each role exposes parseMetadata(value) for completed effective metadata and parsePublicationMetadata(value) for a partial publication. Both return a synchronous { success, data } or { success: false, error } result without a host or network calls. Publication parsing checks supplied fields and nested objects while allowing missing top-level fields that a Superior can complete.

The package exports WalletProviderPublicationMetadata, CredentialIssuerPublicationMetadata, and CredentialVerifierPublicationMetadata, inferred from the same schemas used by the publication hooks:

import {
  CredentialIssuerRole,
  type CredentialIssuerPublicationMetadata,
} from "@oidfed/wallet";

const draft: CredentialIssuerPublicationMetadata = {
  credential_issuer: "https://issuer.example",
};
const result = CredentialIssuerRole.parsePublicationMetadata(draft);
if (!result.success) {
  // Each issue has a path and message for the supplied metadata block.
  const issues = result.error.issues;
}

The verifier's parseMetadata() uses the same received-metadata rules as discovery, including acceptance of repeated DCQL claim paths. parsePublicationMetadata() and outbound Request Object creation reject repeated paths. Parsing leaves received queries intact; request processing normalizes them after federation policy evaluation. A parser result does not authenticate the entity or establish trust.

Issuer discovery and CredentialIssuerRole.parseMetadata() validate completed encryption metadata. An advertised credential_request_encryption.jwks needs at least one key with a nonempty encryption alg whose declared use and key_ops permit encryption or key agreement, as required for key selection by OpenID4VCI §10. Mixed sets are accepted. Known signing algorithms and none cannot satisfy this check; extension algorithms remain available to the application’s crypto implementation. Required response encryption also needs request-encryption support, since §8.2 requires encrypted transport of the response-encryption parameters. Publication allows a superior to supply these missing encryption fields. The application chooses a usable algorithm and performs encryption.

Issuer claim descriptions follow the credential format. OpenID4VCI mdoc paths start with namespace and data-element strings and can continue into CBOR maps, including integer keys, or arrays. JSON paths use nonnegative array indices. OpenID4VP mdoc query paths contain exactly the namespace and data-element strings.

Claim-path wildcards are preserved when hosts publish metadata and when core validates the signed statements. Federation rejects null direct metadata parameter values; nested null values are governed by the relevant protocol schema, including claim-path syntax.

Protocol metadata can publish an empty JWK Set. Verification needs usable protocol keys, so an empty resolved set returns an error before credential or attestation verification callbacks run. It does not cause a fallback to another key source.

Next: 16.2. Discover a trusted wallet participant

View source on GitHub