Skip to content
Wallet and Entity Collection draft updates
Documentation menu

6.2. Issue a Trust Mark after accreditation

Feature guides / 6. Trust Marks · Example context

The Verifier Auditor approves Car Rental Company after an assessment. Its host then calls issueTrustMark; public retrieval requests never perform that approval. Trust Marks; Mark claims.

Issue and retain the evidence

TrustAnchor, Intermediate, and a Leaf configured as an issuer expose the same managed issuance operation:

import type { TrustAnchor, Intermediate } from "@oidfed/authority";
import type { Leaf } from "@oidfed/leaf";

export async function issueVerifierMark(auditor: Leaf | TrustAnchor | Intermediate) {
  return auditor.issueTrustMark(
    "https://car-rental.example",
    "https://licence-federation.example/marks/approved-verifier",
    { ttlSeconds: 600, renewal: "renew", additionalClaims: { "organization_name#fr": "Car Rental Company" } },
  );
}

Default renewal: "reuse" returns an eligible stored JWT. Conflicting explicit options fail instead of being silently ignored. Use renewal: "renew" to issue another mark. Status and revocation can address all issuances. Lifetime precedence is per-call, per-type trustMarkDefaults, issuer-service defaults (configured as trustMarkIssuer.defaults on a host), then the library default of 86,400 seconds. Authorities can also set trustMarkTtlSeconds as a fallback below nested issuer defaults. noExpiry: true explicitly omits exp and conflicts with a TTL at the same level.

logoUri, ref, and additionalClaims support framework information without allowing reserved claims to be overwritten. trustMarkProfiles recognizes additional JWT typ values for named mark types. The host keyring receives the issuer, subject, and Trust Mark type when selecting a signing key. The selected key must be in the issuer’s current Federation Entity Keys.

For a host that only needs a signed JWT, core exports signTrustMark({ issuer, subject, trustMarkType, signer, ...options }). It does not store or approve accreditation. Use TrustMarkIssuerService and a FederationStorage adapter for managed issuance. On a Leaf, supply the storage at the host level and configure issuance policy through trustMarkIssuer. Production storage must provide durable, serializable transactions.

Approve, issue, then deliver

The Verifier Auditor first records its accreditation decision for Car Rental Company. The issuance call then produces and retains the signed evidence under the configured lifetime and delegation. Deliver the JWT through an agreed channel or let the holder retrieve the already-issued mark from the issuer's endpoint.

If issuance fails, leave the approval workflow in a state that can be retried without claiming a JWT exists. If delivery fails after issuance, retrieving the stored mark avoids inventing a second accreditation decision. Use renewal deliberately when new evidence is required; a public retrieval request must not grant accreditation to an arbitrary requester.

Standalone signing and managed hosting

signTrustMark() and signTrustMarkDelegation() accept an issuer, subject, type, KeyringEntry, optional clock, and either ttlSeconds or noExpiry: true. Mark signing also accepts logoUri, ref, delegation, additionalClaims, and recognized profile options. Delegation signing accepts ref and additional claims. Reserved claim collisions are rejected. JSON extension names are preserved safely, including language-tagged names. Standalone signing does not establish accreditation or persist a record.

TrustMarkIssuerService supplies shared managed issuance for Leaf and Authority hosts. For a development issuer, use MemoryFederationStorage with Trust Mark, snapshot, and transaction capabilities. Run managed issuance with a consistent snapshot and a serializable transaction. Storage contract assessTrustMarkStatus(jwt) returns an unsigned status payload and, for active marks, an optional verificationExpiresAt; an unknown instance returns undefined. statusResponse(jwt) signs that assessment. Both apply the configured status policy. Active assessments are rechecked after asynchronous work; a response that expires during signing is discarded and the operation fails. Neither result should be treated as fresh indefinitely.

Trust Mark retrieval, listing, status, and historical-key clients accept authentication. Built-in private_key_jwt requires { method: "private_key_jwt", clientId, audience, signer }; audience is the responder's Entity Identifier. Custom methods provide { method, audience, prepare }, returning form parameters and/or headers. Authenticated requests use POST and reject redirects. Federation endpoint clients use Fetch’s manual redirect mode and reject 3xx responses themselves, including on edge runtimes that do not support redirect: "error". The library does not follow the Location header or resend credentials to it. additionalParameters supports extension strings or arrays while preventing replacement of protocol selectors and credentials. Fixed endpoint query parameters must agree with supplied values.

Server integrations share EndpointAuthentication: register credential parameter/header names and an authenticate callback returning Result<{ entityId }>. Optional synchronous detect handles transport-specific credentials. transportEvidence may return verified transport facts directly or asynchronously. The verifier awaits it, then copies and freezes the evidence. A throw, rejected promise, or value that cannot be copied rejects authentication before the endpoint runs. Identity headers from the caller are not proof. Use authenticatedEndpointCaller(request) in a wrapped handler to retrieve the verified identity. Supplied credentials never silently fall back to anonymous access.

Issue marks from a Leaf host

A Leaf can issue Trust Marks without serving authority fetch/list endpoints. Configure trustMarkIssuer with a TrustMarkStore, and publish whichever Trust Mark endpoints the host serves:

import { Leaf } from "@oidfed/leaf";
import { describeStorageRequirements, MemoryFederationStorage } from "@oidfed/core";
import { type CryptoContext } from "@oidfed/core";

export async function issueFromLeaf(crypto: CryptoContext, subject: string, type: string) {
  const auditor = await Leaf.create({
    entityId: "https://auditor.example",
    authorityHints: ["https://licence-federation.example"],
    crypto,
    metadata: { federation_entity: {
      federation_trust_mark_endpoint: "https://auditor.example/marks",
      federation_trust_mark_status_endpoint: "https://auditor.example/mark-status",
      federation_trust_mark_list_endpoint: "https://auditor.example/mark-list",
    } },
    storage: new MemoryFederationStorage({ namespace: "https://auditor.example", capabilities: describeStorageRequirements("trustMarkWrite") }),
    trustMarkIssuer: {
      trustMarkDefaults: { "https://licence-federation.example/marks/approved-verifier": { ttlSeconds: 600 } },
      // Supply issuerEvidence and delegations when the framework declares an owner.
    },
  });
  const jwt = await auditor.issueTrustMark(subject, type);
  await auditor.revokeTrustMark(type, subject);
}

issueTrustMark, listTrustMarksForSubject, listTrustMarkedEntities, revokeTrustMark, and setTrustMarkDelegations use the same lifecycle service as Authority. Nested configuration also supports signer selection, profiles through options.trustMarkProfiles, status policy, endpoint request extensions, and authentication. Production hosts need durable transactional storage; the memory store is process-local.

A Leaf that receives accreditation uses attachTrustMark(jwt, { issuerEvidence, expectedTrustMarkType }). It checks the mark for the Leaf's Entity Identifier before signing a replacement EC. Duplicate JWT attachment is idempotent; replacement: "same-issuer-and-type" removes the pair's other marks even when the replacement JWT is already attached. Unrelated marks stay published. fetchAndAttachTrustMark({ issuer, trustMarkType, trustAnchors, options }) establishes trust, fetches, validates, and publishes in one operation. A failed signer leaves the previous publication/cache intact.

getTrustMarks() returns detached references. removeTrustMark({ jwt }) can remove an expired or invalid publication without fetching anything. It does not revoke the issuer's stored accreditation.

For Leaf-hosted Trust Mark endpoints, endpoint_auth_signing_alg_values_supported limits the algorithms accepted for private_key_jwt. If trustMarkIssuer.authentication.allowedAlgorithms is also set, both restrictions apply. A configuration with no common algorithm fails at construction. Omitting the metadata field does not select an implicit algorithm.

Next: 6.3. Delegate Trust Mark issuance

View source on GitHub