Skip to content
Wallet and Entity Collection draft updates
Documentation menu

8.1. Find candidate trust chains

Feature guides / 8. Discovery and caching · Example context

LIGO Wiki receives Umeå University OP's Entity Identifier and needs a path to an accepted anchor. Umeå University OP may have several superiors, so discovery can produce more than one candidate.

How to use it

Call discoverEntity() on your configured Leaf, TrustAnchor, or Intermediate. It composes traversal, validation, policy, and selection using that host's anchors and options. If the next action is OIDC registration or Wallet processing, use the role operation instead; it applies the protocol's eligibility checks as well. Direct core traversal is useful only when a diagnostic tool actually needs every raw candidate. Chain discovery; Path selection.

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

export async function discoverUmeaOp(ligoWiki: Leaf) {
  const result = await ligoWiki.discoverEntity(entityId("https://op.umu.example"));
  if (!result.ok) return result;
  return result; // Selected, validated evidence; not an unverified candidate list.
}

What your application owns

Set fetch and depth budgets, cancellation, and allowed network destinations for your environment. An incomplete traversal does not prove no other valid path exists. The host's discoverEntity() chooses the shortest valid path unless you configure chainSelection. Neither API is a global federation crawler without resource limits.

When an anchor belongs to a wider federation

Suppose eduGAIN belongs to a regional federation that LIGO Wiki also trusts. Discovery records the chain ending at eduGAIN, then follows its superior hints to look for the regional chain too. Another intermediate can sit between those anchors without being a configured anchor itself.

Both candidates need validation. If the regional service is unavailable or the request budget runs out, the completed campus chain remains available; inspect errors and incomplete before deciding whether it meets your application's needs.

Inspect discovery without accepting it

Core's resolveTrustChains() exposes raw candidates and branch errors for diagnostics, a capability the selected-result class API does not expose. It returns chains, errors, and incomplete; those candidates still require validation. Use each candidate's entityConfigurations when passing its statements to a host's discoverEntityFromChain(). Do not rebuild this pipeline for ordinary registration or wallet operations.

A discovery result can explain why LIGO Wiki found no usable path: unreachable endpoints, limits, or invalid evidence are different operational problems. Keep the discovered candidates and diagnostic context separate from accepted protocol metadata.

After resolving candidates, validate them against the configured anchors and use the path selected for this operation. A partial graph can be insufficient for a custom selector that needs all eligible candidates. Do not turn an incomplete search into a claim that a preferred path does not exist.

What is DiscoveryResult and how is it used?

DiscoveryResult is a branded value containing a selected validated trust chain, resolved metadata, and trust marks. The bound leaf.discoverEntity() and the standalone Core helper both return it. The RP role's automaticallyRegister() and explicitlyRegister() methods perform discovery internally; createAuthorizationRequest() takes an existing DiscoveryResult.

Discover paths beyond a configured anchor

A configured Trust Anchor can also have superiors, as described in Federation §4.1. Its signed authority_hints declares those relationships; the configured anchor keys establish trust for your application. An anchor with superiors may also publish trust_anchor_hints. An anchor without superiors must omit both claims, and either array must be nonempty when present (§3.1.2).

When the requested entity is a configured anchor, resolveTrustChains() includes its own Entity Configuration as a direct candidate. When traversal reaches a configured anchor from a subordinate, it likewise records that candidate and continues through any superior hints. For example, a university under a national anchor can produce a second chain to a regional anchor when both anchors are trusted. Unconfigured intermediates can connect those anchors; only the final anchor must belong to the configured trust set.

The longer chain contains the linking Subordinate Statements; the national anchor's EC is supporting evidence, not an extra self-signed statement in its middle. Each candidate still needs validation against its selected anchor's keys. This lets resolveTrustChainForAnchor() select the higher anchor, including when the nearer anchor's pinned keys are stale but the higher chain validates independently.

Following higher paths can require more requests. Existing fetch, depth, step, and cancellation limits still apply. Errors or work limits on a superior path remain visible in errors and, when applicable, incomplete; they do not discard completed candidates. The application decides whether an available validated chain is sufficient or it needs more complete discovery.

The core chain API exposes raw discovery for tools that need all candidates. The ordinary application workflow above already performs validation and selection; do not add a second validation loop after it.

Supplied chains are limited to 100 statements by default, including their Entity Configurations. Set maxChainLength to a positive safe integer for deployments requiring longer chains. This resource budget follows Federation §18.1; maxChainDepth separately limits discovery traversal.

Next: 8.2. Cache evidence without extending its lifetime

View source on GitHub