6.4. Validate accreditation before relying on it
Feature guides / 6. Trust Marks · Example context
Maya's wallet receives Car Rental Company's mark. It first establishes who may speak for that accreditation framework, then validates the mark for Car Rental Company.
Discover the holder and require accreditation
Use the Wallet role to establish holder trust and validate its protocol metadata. Configure trustMarkVerification so the same operation establishes issuer trust and evaluates the published marks. Core's checkTrustMarkRequirements() adds the application's explicit accreditation gate; the role's successful discovery alone does not require a mark. OIDC registration also offers declarative trustMarkRequirements on the provider role.
import type { CryptoEngine } from "@oidfed/crypto";
import { CredentialVerifierRole } from "@oidfed/wallet";
import { checkTrustMarkRequirements, type TrustAnchorSet } from "@oidfed/core";
export async function accreditedCarRental(
engine: CryptoEngine,
drivingLicenceAnchors: TrustAnchorSet, accreditationAnchors: TrustAnchorSet,
) {
const discovered = await CredentialVerifierRole.discover("https://car-rental.example", drivingLicenceAnchors, {
engine,
trustMarkVerification: { mode: "resolve", trustAnchors: accreditationAnchors },
});
if (!discovered.ok) return discovered;
const required = checkTrustMarkRequirements(discovered.value.trustChain, {
requiredTypes: ["https://licence-federation.example/marks/approved-verifier"],
});
if (!required.ok) return required;
return discovered;
}
The accreditation anchors may differ from the holder's federation anchors. The verified marks retain issuer evidence containing authenticated issuer policy, owner keys, chain evidence, and an expiry. Serialized evidence must be revalidated with establishTrustMarkIssuerTrust() before use; complete supplied statements and ECs support offline revalidation.
An application that establishes accreditation outside Federation can supply an explicit kind: "out-of-band" context with pinned issuer, allowed types, keys, and any owner policy. This is the §17.5 choice; it does not disable signatures, subject binding, time checks, or delegation validation.
For chain discovery, options.trustMarkVerification: { mode: "resolve", trustAnchors: accreditationAnchors } opts into issuer discovery. Supplying issuerEvidence permits evaluation without discovery. Optional invalid marks do not invalidate an otherwise valid holder chain. Use checkTrustMarkRequirements(chain, { requiredTypes: [type] }) to make accreditation an application requirement. Evidence includes the original JWT, frozen claims, and verificationExpiresAt; a cached holder chain cannot extend that deadline.
A Resolve response speaks for its selected Trust Anchor. Even if your application separately trusts an auditor, the resolver includes that auditor's mark only when the selected anchor authorizes it and its owner/delegation rules hold. The issuer can have its own authenticated chain; it does not need to appear in the holder's chain. Standalone verification can still use explicitly configured out-of-band accreditation trust.
If a Trust Mark contains delegation, the value must be a valid delegation JWT. An empty string is invalid even when the selected anchor does not declare an owner. Omit the claim when no delegation is used.
Separate the holder from the accreditor
A valid chain for Car Rental Company establishes federation trust in the holder. The Verifier Auditor may have a different chain and even a different configured accreditation anchor. Establish issuer evidence using the trust arrangement your application actually accepts, then validate the mark's signature, subject, type, delegation, and lifetime.
Keep validation results with the original JWT when a later status check concerns that exact mark. Do not create an evidence-shaped object from unverified keys or deserialize a saved object and assume it retains its runtime provenance. When evidence expires, reacquire it and rerun the operation before relying on the mark again.
Trust Marks in a validated chain
validateTrustChain() reports chain validity separately from Trust Mark trust, following Federation §3.2 and §17.5. Mandatory reference syntax checks, including matching the reference's type to the JWT's type, remain part of chain validation. An expired mark or unavailable issuer evidence appears in the mark results while an otherwise valid chain remains valid.
For a valid chain, trustMarkEvaluations contains one result per published subject mark, in reference order. Each result identifies its referenceIndex and trustMarkType:
verifiedincludes the validatedmark.invalidincludes the validationerror.unevaluatedincludes areasonanddescription: issuer policy or trusted keys were unavailable, or evaluation was reserved for a separate step.
chain.trustMarks contains only verified marks. Verification describes the evidence at validation time; active status is checked separately. Chain expiry remains the earliest Entity Statement expiry under §10.4.
Use checkTrustMarkRequirements() to apply your application's accreditation requirements:
import type { Leaf } from "@oidfed/leaf";
import { checkTrustMarkRequirements, entityId } from "@oidfed/core";
export async function requireAccreditation(host: Leaf, statements: readonly string[]) {
const result = await host.discoverEntityFromChain(entityId("https://op.umu.example"), statements, {
trustMarkVerification: { mode: "resolve" },
});
if (!result.ok) return result;
const required = checkTrustMarkRequirements(result.value.trustChain, {
requiredTypes: ["https://accreditation.example/university"],
});
return required.ok ? result : required;
}
Each required type needs at least one verified mark whose dates remain valid. Set requireAllPublished: true to require every published mark to pass as an additional application policy; an empty publication satisfies that option, so use requiredTypes when a mark must exist. Both checks apply when combined. The helper rejects expired chain evidence and rechecks mark and delegation dates using the supplied clock and clock skew. The helper uses the supplied evidence. Obtain fresh issuer evidence and check active status when your policy requires it.
By default, chain validation uses the included anchor EC's issuer and owner declarations and independently trusted keys already available to it. An omitted anchor EC or undeclared type leaves the mark unevaluated. To discover issuer trust automatically, pass trustMarkVerification: { mode: "resolve" }. Supply a separate trustAnchors map inside that option when the accreditation framework differs from the holder's federation. Discovery shares the operation's fetch budget, cache, cancellation, and offline controls.
For an independently delivered JWT that is not being consumed through holder discovery or attachment, core supplies a standalone verification API. Establish issuer trust explicitly before using its claims:
import type { CryptoEngine } from "@oidfed/crypto";
import { establishTrustMarkIssuerTrust, validateTrustMarkWithIssuer } from "@oidfed/core";
import { type TrustAnchorSet } from "@oidfed/core";
export async function validateAuditorMark(
engine: CryptoEngine,
trustAnchors: TrustAnchorSet,
rawTrustMarkJwt: string,
) {
const issuerResult = await establishTrustMarkIssuerTrust({
issuer: "https://auditor.example",
trustMarkType: "https://licence-federation.example/marks/approved-verifier",
trustAnchors,
options: { engine, httpClient: fetch },
});
if (!issuerResult.ok) throw new Error(issuerResult.error.description);
const result = await validateTrustMarkWithIssuer(rawTrustMarkJwt, issuerResult.value, {
engine,
expectedSubject: "https://car-rental.example",
expectedTrustMarkType: "https://licence-federation.example/marks/approved-verifier",
});
if (!result.ok) throw new Error(result.error.description);
const { jwt, claims, verificationExpiresAt } = result.value;
return result;
}
FederationTrustMarkIssuerEvidence retains authenticated chain statements, intermediate ECs, issuer policy, owner keys, and the proof's expiry. Its provenance is checked in memory. To restore serialized evidence, call establishTrustMarkIssuerTrust() again with trustChain, entityConfigurations: new Map(Object.entries(saved.entityConfigurations)), and the configured anchors. With complete local evidence, options.offline: true prevents network access during revalidation. A zero fetch budget is another way to require supplied or cached evidence. A plain object labelled kind: "federation" is insufficient. Marks verified through this API retain their issuerEvidence for later status checks. trustMarkIssuerContext(context, type, options) checks that context and returns detached keys, owner policy, endpoint metadata, and any issuer-proof expiry in a Result; it does not validate a mark or establish new trust.
For accreditation established outside Federation, pass an explicit { kind: "out-of-band", issuer, allowedTrustMarkTypes, keys, trustMarkOwners?, metadata? } context to validateTrustMarkWithIssuer(). The application owns those trust inputs under §17.5. Signature, subject, type, time, and owner delegation checks still apply. Never construct this context from unverified JWT claims or self-published keys alone.
An owner declaration requires a valid owner-signed delegation even when owner and issuer identify the same entity. An explicit empty issuer array permits any independently trusted issuer for that type; a nonempty array restricts it to the listed identifiers. These rules come from §3.1.2 and §7.3.
Federation issuer evidence returned by establishTrustMarkIssuerTrust also carries process-local provenance. Keep the original object while it remains valid. Copying it, including through JSON or structuredClone, does not preserve that provenance. Across a process boundary, transfer signed statements and establish evidence again.