2.2. Build and sign Entity Statements
Feature guides / 2. Entity Statements · Example context
Umeå University signs an assertion about Umeå University OP; Umeå University OP signs its own EC. The two JWTs have different claim placement rules even though both are Entity Statements.
How to use it
Use Leaf.getEntityConfiguration() for the participant's own statement and TrustAnchor.getSubordinateStatement() or Intermediate.getSubordinateStatement() for an enrolled subordinate. These hosts select their configured signer, construct valid claims, and sign the result. Their handleRequest() methods expose the corresponding HTTP endpoints. Entity Statements; Validation.
import type { TrustAnchor, Intermediate } from "@oidfed/authority";
import type { Leaf } from "@oidfed/leaf";
import { entityId } from "@oidfed/core";
export async function publishUmeaOpStatements(authority: TrustAnchor | Intermediate, umeaOp: Leaf) {
// UmeaOp was enrolled through authority.registerSubordinate() with approved keys.
const configuration = await umeaOp.getEntityConfiguration();
const subordinateStatement = await authority.getSubordinateStatement(entityId("https://op.umu.example"));
return { configuration, subordinateStatement };
}
Add an agreed federation extension
Umeå University and Umeå University OP might agree on an access-profile claim that tells receiving applications which additional access rules to apply. That agreement, and the code enforcing those rules, belong to the federation. Once both sides implement it, the authority can publish it in Umeå University OP's Subordinate Statement:
import type { TrustAnchor, Intermediate } from "@oidfed/authority";
import { entityId, type JWKSet } from "@oidfed/core";
export async function enrollUmeaOp(authority: TrustAnchor | Intermediate, umeaOpKeys: JWKSet) {
await authority.registerSubordinate({
entityId: entityId("https://op.umu.example"),
jwks: umeaOpKeys,
additionalClaims: { "https://edugain.example/claims/access-profile": "research-v1" },
crit: ["https://edugain.example/claims/access-profile"],
});
}
The standalone builders and signers accept the same two options. additionalClaims becomes top-level JWT claims; crit lists those a recipient must understand and process. A recipient that does not support this profile rejects the statement. For an informational extension that can safely be ignored, leave it out of crit.
Use JSON values and the dedicated builder options for standard claims. The library rejects reserved-name collisions, missing critical claims, repeated names, and empty crit arrays before publication. It also copies the extension values, so editing a configuration object after construction cannot silently change a later statement.
To change the authority's stored extension, call updateSubordinate() with a replacement additionalClaims map. Update crit in the same call if its membership changes. Existing signed statements retain their original claims until they expire; an update affects newly issued statements.
What your application owns
Signing establishes who issued the claims, not whether your operator should have approved them. Keep subject public keys separate from the issuer's signer. Custom critical claims need explicit understanding on the receiving side; adding crit must not turn an unknown claim into something the library enforces. Raw decode utilities are for inspection, while verifyEntityStatement checks a signature against supplied keys. Full chain validation supplies the federation trust decision.
Treat signing as publication
A Subordinate Statement speaks about one named subject. For Umeå University OP, the Superior's payload must use Umeå's identifier and the federation keys the Superior is prepared to attest. Protocol metadata and Federation Entity Keys serve different purposes; placing protocol signing keys in the statement's federation jwks changes what the authority is vouching for.
Use the builder's errors to stop publication before signing. After producing a JWT, inspect its issuer, subject, and expiration and validate it as part of the intended chain. A signature proves who issued the statement; it does not make contradictory metadata or policy usable. Extension claims that require processing need corresponding consumer support before you mark them critical.
Standalone publishers and inspection
A custom publisher without a managed host can use core's specialized signEntityConfiguration() and signSubordinateStatement() functions. They validate payload construction before signing; the generic signEntityStatement() requires the caller to validate its own profile. These are advanced publisher APIs, not additional steps needed after a host method. See the statement API for their contracts.
For inspection, decodeEntityConfiguration() and decodeSubordinateStatement() check JWT type and payload shape without authenticating the signature. Use them to inspect your own publication. Remote statements still need chain validation through a host or protocol role before their metadata is trusted.
Extension claims and critical processing
A federation can define extra top-level Entity Statement claims. Configure a host's own EC with additionalClaims, or pass them on a subordinate registration as shown above. Standalone core builders and signers accept the same options. Use crit when recipients must understand and process an extension, as required by Federation §13.4.
The extra claims must be JSON object data. They are copied deeply and cannot replace standard claims, including optional ones such as metadata or authority_hints. Use the dedicated options for those fields. An explicitly empty crit, repeated names, standard names, and names absent from additionalClaims fail before signing. Omit crit for extensions that recipients may ignore. JSON member names such as __proto__ remain ordinary own properties; they do not change object prototypes.
prepareEntityStatementExtensions({ additionalClaims, crit }) exposes the same validation and detached copy for custom publishers. It returns an EntityStatementExtensions options object and throws for invalid input. Leaf, TrustAnchor, and Intermediate use it when accepting their own EC configuration; Authority also validates extensions before writing subordinate records.
On receipt, options.understoodCriticalClaims declares which extensions your application implements. It does not install a handler or enforce their meaning. Process each authenticated statement's extension according to your federation's rules before relying on the result. Leaving a name out rejects a statement that lists it in crit.
Entity Statement, signed JWK Set, and explicit-registration timestamps accept finite NumericDates, including fractions and dates at or before the Unix epoch, as defined in RFC 7519 §2. Time validation still enforces issuance and expiry against the configured clock. Entity Statement builders preserve the supplied issuedAt and require a positive integer ttlSeconds.
Entity Statement builders use positive safe-integer TTLs. Trust Marks and Subordinate Events responses accept positive finite TTLs, including fractions. assertPositiveTtlSeconds throws TypeError for an invalid duration. Publication still checks the resulting expiration against its issuance time.