Skip to content
Wallet and Entity Collection draft updates
Documentation menu

9.3. Refresh evidence before it expires

Feature guides / 9. Updates, rollover, and revocation · Example context

Umeå University OP's chain was valid when Maya opened LIGO Wiki. A later request must not keep using that decision indefinitely.

How to use it

Re-run the host's discoverEntity() when its saved evidence expires or your application chooses to reassess it. OIDC and Wallet roles perform trust processing as part of their operations; registrations and sessions still need the host's own renewal policy. Valid cached statements can be reused, so reassessment does not guarantee an HTTP request to every authority. Evidence expiry; Transient failures.

import type { Leaf } from "@oidfed/leaf";
import { entityId } from "@oidfed/core";

export async function refreshUmeaOp(ligoWiki: Leaf) {
  const result = await ligoWiki.discoverEntity(entityId("https://op.umu.example"));
  if (!result.ok) return result;
  // Replace saved evidence only after success; use this result's trustChain.expiresAt.
  return result;
}

What your application owns

Schedule refreshes or perform them before a dependent operation. Define how the application handles unavailable replacement evidence; an error is not permission to extend expiry. Registration and credential decisions can have additional lifetimes. Passing a controllable clock helps tests but production clocks still need accurate time. Cache expiration and evidence expiration serve different purposes. Use the same clock for host operations and saved evidence. For the standalone refresh helper, its legacy fourth clock argument takes precedence if supplied. A failed forced refresh never returns the old chain as a successful result, and offline: true still blocks network retrieval during forced refresh. HTTP transports and proxies can still impose their own caching.

A refreshed anchor EC does not change the trusted keys in your TrustAnchorSet. Removing a subordinate also does not guarantee that the next ordinary refresh detects it: an unexpired cached Subordinate Statement can remain usable. Choose your refresh and incident-response policy with that delay in mind.

Refresh before the next dependent action

Save LIGO Wiki's accepted chain with its expiration and schedule a refresh according to your freshness policy. A fresh result can contain changed metadata or accreditation even when the entity identifier stays the same.

On refresh failure, distinguish an expired chain from a still-fresh chain your application chose to reevaluate early. Do not extend expiresAt locally. Decide whether the operation can wait for recovery or must stop, and avoid retaining registrations beyond the federation evidence on which they depend.

Force fresh retrieval before expiry

The host's discovery method has no forceRefresh option. When an operator specifically needs to bypass existing statement-cache entries, core's refreshTrustChain() provides that distinct capability. Pass the previously validated chain and the same approved anchors and trust options used by its host. This function has no access to a host's private configuration, and the host still owns protocol-specific checks before using changed metadata.

import type { CryptoEngine } from "@oidfed/crypto";
import { refreshTrustChain, type ValidatedTrustChain, type TrustAnchorSet } from "@oidfed/core";

export async function forceRefreshUmeaOp(
  engine: CryptoEngine,
  chain: ValidatedTrustChain,
  anchors: TrustAnchorSet,
) {
  const result = await refreshTrustChain(chain, anchors, { engine, forceRefresh: true });
  if (!result.ok) return result;
  return result; // Replace the stored decision only with this validated result.
}

Refresh behavior and cache bypass

refreshTrustChain(chain, trustAnchors, options) returns the same chain while it remains unexpired. Once it expires, it resolves and validates replacement evidence. Unexpired Entity Statements can still come from the cache, as §10.2 permits; a refresh does not necessarily contact every authority.

Use { forceRefresh: true } when you want to check for changes before expiry. This bypasses pre-existing Entity Configuration and Subordinate Statement entries for that operation. Statements fetched during the operation can be reused and are written back with their normal TTLs. The shared cache is neither cleared nor disposed. This is the library's refresh contract, not a specification requirement to bypass valid caches. Your injected HTTP transport and upstream proxies can have their own caches.

options.clock governs the expiry decision, statement validation, and calculation of cache TTLs. The existing fourth clock argument remains supported and takes precedence when both are supplied. A host-provided cache still owns its own expiration scheduling; use compatible clocks in tests.

Failed fresh retrieval or validation returns an error; it does not return the previous chain as a successful refresh. Forced refresh respects cancellation, fetch limits, authentication, and offline. With offline: true, it cannot fetch replacements from the network; old statement-cache entries do not satisfy a forced refresh. A network-denying httpClient also prevents retrieval. Your application decides when to call refresh and how to handle unavailable evidence.

Refreshing an anchor's EC does not replace the caller's TrustAnchorSet. Independently establish which new keys to trust before changing that configuration. See the independent comparison example.

Next: 9.4. Choose crypto and signing custody

View source on GitHub