4.2. Validate protocol metadata for forms and consumers
Feature guides / 4. Metadata · Example context
An operator edits Umeå University OP's OP metadata in a form. Field errors should appear before publication, while the registration client must check the completed metadata it actually uses.
How to use it
OIDC/OAuth and wallet roles expose parsePublicationMetadata() and parseMetadata(). They can run independently of a host. Their validation issues contain paths and messages suitable for field-level feedback. A metadata editor still supplies its own form controls; no form-generation API is promised. Protocol metadata requirements; Wallet metadata; Protected resource metadata.
Pass { algorithmRegistry } to either parser when the deployment registers a custom JWS algorithm. The parser uses the registry to recognize signing keys in an inline JWK Set. If the set contains both signing and encryption keys, every key needs a use value. Hosts pass their registry to attached roles. The standalone Core OAuth authorization server parsers accept the same option.
import { OidcProviderRole, OAuthResourceRole } from "@oidfed/oidc";
import { CredentialIssuerRole } from "@oidfed/wallet";
export function validateEffectiveMetadata(op: unknown, issuer: unknown, resource: unknown) {
return {
op: OidcProviderRole.parseMetadata(op),
credentialIssuer: CredentialIssuerRole.parseMetadata(issuer),
federationResource: OAuthResourceRole.parseMetadata(resource),
resourceDocument: OAuthResourceRole.parseMetadata(resource, { profile: "rfc9728" }),
};
}
What your application owns
The five OIDC/OAuth roles cover openid_relying_party, openid_provider, oauth_client, oauth_authorization_server, and oauth_resource. Wallet roles cover provider, credential issuer, and verifier metadata. Core covers federation_entity and provides the shared AS parser. Federation oauth_resource metadata and an RFC 9728 resource document have different required-field rules. Parsing is neither identity binding nor trust establishment; use the role's protocol workflow for those checks. The library does not reject legitimate unknown fields merely because they are extensions.
Validate at the appropriate boundary
Use a role's publication parser when editing the fields that Umeå University OP will publish. Use its effective parser after assembling the metadata that a consumer will actually use. A successful federation chain result does not mean every application protocol requirement has been checked by a bare core caller.
Extension fields can remain in metadata without becoming automatically understood by the application. For fields your deployment uses, add its own profile checks after the protocol checks. Show parser issue paths in the editor, but avoid displaying raw secrets or entire configuration objects in error messages.
Protocol metadata
Federation §6.1 places protocol type checks after metadata resolution. Attach the matching OIDC/OAuth or wallet role to check composed publication metadata, and use its protocol APIs to validate effective metadata before consumption. A partial publication can omit fields supplied by a Superior; the resolved result must satisfy the protocol's requirements.
If you use bare Leaf/Authority metadata or consume validateTrustChain() results directly, invoke the matching OIDC/OAuth role parser or wallet parser yourself. OAuth AS validation is shared through core so wallet and OIDC need no dependency on each other. Keep application-specific extension validation and embedded signed-metadata processing in your application.
Validate shared authorization-server metadata
parseOAuthAuthorizationServerMetadata(raw) checks effective OAuth AS metadata against RFC 8414 and the supported registered extensions. parseOAuthAuthorizationServerPublicationMetadata(raw) checks supplied publication fields while allowing missing fields that a Superior can complete. Both return a synchronous success/error result and preserve unknown extension members.
For Wallet federation metadata, pass { profile: "openid4vci" } as the effective parser's second argument. OpenID4VCI §12.2.4 allows an AS that advertises only the pre-authorized-code grant to omit response_types_supported. The VCI result type reflects that optional field. The default "oauth" profile keeps the ordinary requirement, and neither profile inserts a replacement value. This option validates metadata only; it does not implement a grant flow.
This shared validator lives in core because both OIDC registration and wallet credential-issuer discovery consume OAuth AS metadata. The protocol packages call it at their own boundaries; generic validateTrustChain() and discoverEntity() do not automatically apply protocol schemas. Hosts can call the parser independently after resolving metadata. Endpoint requirements account for grant types, including implicit-only and pre-authorized-only servers, without adding default values to the returned object.
Parsing neither authenticates an issuer nor verifies signed_metadata. It also makes no endpoint requests. Use the protocol roles for automatic validation during publication and protocol operations.
Parse publication and effective OIDC metadata
Each OIDC/OAuth role has two static parsers: parseMetadata(raw) for effective metadata and parsePublicationMetadata(raw) for a publication that Superiors may complete. Both return { success: true, data } or { success: false, error } without making network requests.
import {
OidcProviderRole,
type OpenIDProviderPublicationMetadata,
} from "@oidfed/oidc";
export async function validateOpMetadata(resolvedMetadata: Record<string, unknown>) {
const draft: OpenIDProviderPublicationMetadata = {
client_registration_types_supported: ["explicit"],
};
const publication = OidcProviderRole.parsePublicationMetadata(draft);
const effective = OidcProviderRole.parseMetadata(resolvedMetadata.openid_provider);
if (!effective.success) {
// Inspect effective.error.issues before using any endpoints or capabilities.
}
return { publication, effective };
}
The same methods exist on OidcRelyingPartyRole, OAuthAuthorizationServerRole, OAuthClientRole, and OAuthResourceRole. Each role also has a corresponding exported *PublicationMetadata type, inferred from its publication schema: OpenIDRelyingPartyPublicationMetadata, OpenIDProviderPublicationMetadata, OAuthAuthorizationServerPublicationMetadata, OAuthClientPublicationMetadata, and OAuthResourcePublicationMetadata. OIDCFederationPublicationMetadata uses these types for its blocks. The AS publication type matches the shared core definition. Resource metadata defaults to the federation profile, which permits common informational fields without a resource parameter. Use OAuthResourceRole.parseMetadata(raw, { profile: "rfc9728" }) to require a complete RFC 9728 resource document.
Attaching a role to a Leaf or Authority checks its composed publication automatically. Missing protocol fields can be completed by a Superior; malformed supplied fields are rejected. Registration checks effective metadata after Superior overrides and policy application, before using endpoints or signing requests. Role-driven discovery can select another conformant path; malformed caller-supplied discovery results and invalid supplied chains are errors.
Unknown extension fields are preserved. Registered fields are checked against their protocol definitions, and federation registration-type arrays remain open to extension values. Explicit-registration responses use single-valued selections in place of RP Metadata Choices inputs; selections and protocol defaults must satisfy the RP's advertised choices.
These checks establish metadata conformance. Issuer trust, endpoint availability, and the validity of embedded signed_metadata or software_statement JWTs require separate checks. Continue to authenticate federation evidence before using parsed metadata. Bare Leaf/Authority hosts without a matching protocol role perform federation validation only; applications can call these parsers explicitly.