3.1. Validate a chain before using its metadata
Feature guides / 3. Trust chains · Example context
Finding Umeå University OP's statements gives LIGO Wiki material to verify. The application needs authenticated effective metadata before it uses endpoints or makes a registration decision.
How to use it
Use your host's discoverEntityFromChain() to validate received statements against its configured anchors and options. It returns a Result containing a DiscoveryResult on success. For OIDC registration or Wallet processing, use the corresponding role operation so the protocol-specific checks also run. You do not need to resolve and apply policy separately. Validation procedure.
import type { Leaf } from "@oidfed/leaf";
import { entityId } from "@oidfed/core";
export async function validateReceivedChain(
ligoWiki: Leaf, statements: readonly string[],
configurations: ReadonlyMap<string, string>,
) {
const result = await ligoWiki.discoverEntityFromChain(
entityId("https://op.umu.example"), statements, { entityConfigurations: configurations },
);
if (!result.ok) return result;
// The host checked the target identity, path, constraints, and metadata policy.
return result; // result.value contains resolvedMetadata and the validated trustChain.
}
Core's validateTrustChain() remains useful for custom verification tools that need individual validation errors. Its result uses valid rather than ok; the chain API describes that lower-level contract. Host discovery methods compose that validation and bind the supplied chain to the requested entity.
What your application owns
Use protocol-role validation before consuming protocol metadata; core cannot replace every protocol engine. A valid chain also does not mean every published Trust Mark was verified. Inspect trustMarkEvaluations or apply explicit requirements. shortestChain(), longestExpiry(), and preferTrustAnchor() operate on already validated choices; changing selection policy must not skip validation.
Deep extension JSON cannot suppress duplicate-policy checks. When processing cannot safely finish, validation returns a failure result, including in the two-phase prepare/complete flow.
Use the result for the operation you checked
LIGO Wiki should retain the selected chain, its resolved metadata, anchor identifier, and expiration together. Reading endpoint or algorithm values from the original untrusted configuration after validation defeats the purpose of applying Superior metadata and policy.
On rejection, report the validation errors to operational diagnostics and stop the dependent action. Do not retry by deleting a constraint, changing the anchor set, or accepting the decoded leaf metadata. A transport problem may justify another bounded attempt; a policy or identity failure needs configuration or evidence to change. Before a later operation, check whether the saved evidence is still fresh.
Candidate discovery and chain checks
Duplicate policy members are checked in the original JWT JSON using an iterative scanner. Deep extension data cannot erase a detected duplicate. If metadata cannot be processed safely, chain validation and its prepare/complete APIs return their normal failure result; callers do not receive a stack-overflow exception.
resolveTrustChains() builds candidate paths. Pass each candidate to validateTrustChain() to check signatures, expiry, constraints, and metadata policy. Use discoverEntity() when you want a validated, selected chain in one call.
Validation rejects a path that visits an Entity more than once, as required by Federation §17.1 and §10.1. The optional closing Trust Anchor Entity Configuration describes the final Entity in that path. Separate candidate paths may share Entities.
When the chain includes the Trust Anchor's Entity Configuration, its signature must verify against both the configured anchor keys and its own jwks (Federation §3.2, §4). The configured keys establish trust; the self-signature check confirms that the EC's published key matches its signature. During rollover, the EC can publish additional keys while retaining the key that signs it, following §11.2.
Every Subordinate Statement must name an issuer listed in its subject's Entity Configuration authority_hints (§3.2(6)). Validation reuses the chain's subject EC and looks up the intermediate ECs by exact Entity Identifier. Each resolved candidate exposes entityConfigurations; pass this map in the validation options to reuse discovery's ECs. These are auxiliary inputs and do not change the serialized statements array.
For independently supplied chains, provide signed intermediate EC JWTs through entityConfigurations: ReadonlyMap<string, string>, or allow validation to retrieve missing ECs using the configured HTTP client and cache. Each EC's identity, claims, time limits, self-signature, and signature against the subject keys attested in the chain are checked before its hints are used. Missing, invalid, or unavailable evidence fails validation. A fully local validation can use maxTotalFetches: 0; missing evidence then fails without network access. Additional retrievals are serial, cancellable, and bounded by maxTotalFetches, including failed HTTP calls. Invalid chain signatures are rejected before additional EC retrievals.
The returned validated chain's expiresAt is capped by the ECs supporting these relationship checks, so consumers refresh before any supporting evidence expires. Prepared validation retains the supporting signed ECs for completion and rechecks their validity.
To start discovery from a supplied signed Entity Configuration, pass entityConfigurationJwt in ResolveTrustChainsOptions. The resolver validates the identity, structure, time claims, and self-signature of the supplied EC and every fetched EC before following its authority hints or endpoints. It leaves the cached published EC unchanged. For a supplied explicit-registration request, also pass explicitRegistrationAudience with the expected OP Entity Identifier; its aud must match. This context applies only to the supplied JWT; fetched ECs follow ordinary publication rules. An audience without a supplied JWT is rejected. Discovery still produces candidate paths that require final validation against configured Trust Anchors.
During each resolveTrustChains() call, candidate paths share pending and completed statement retrievals, following Federation §10.1. Entity Configurations are identified by their exact Entity Identifier; Subordinate Statements by their issuer and subject. A failed retrieval is shared for that call and can be retried by a later call. Repeated values in each authority-hint list are collapsed after the raw hint-count limit is applied. Each path keeps its own loop checks, so converging paths remain available.
maxTotalFetches limits calls to the HTTP client, including failed requests. Cached, supplied, and shared statements consume no HTTP budget; a fully cached resolution can run with maxTotalFetches: 0. maxResolutionSteps separately bounds branch expansion, including paths that reuse statements. It accepts a positive safe integer and defaults to DEFAULT_MAX_RESOLUTION_STEPS (1000). Each admitted hint counts as one step after filtering and loop checks. When a limit prevents further work, the result includes incomplete: true, an error, and any candidates already found. These local safeguards bound discovery work; each returned candidate still needs validation.
For explicit registration, validateTrustChain() accepts explicitRegistrationRequest: { jwt, audience }. It authenticates the supplied path and the registration JWT against that path's attested federation keys. The supplied path's EC provides evidence of the relationship; its metadata does not determine whether the tailored registration metadata is acceptable. Metadata resolution then uses the actual request and the path's superior statements, as required by Federation §12.2.2. The returned chain contains the submitted request as its first statement. The OIDC role handles registration transport, peer-chain checks, candidate selection, and response processing.
validateCriticalClaims(payload, understoodClaims?) checks the payload crit rules in §3.1.1. validateEntityStatementTimeClaims(payload, options?) checks required statement timestamps against the configured clock and skew. Both helpers return a Result; use them alongside signature and profile validation.