@real-life/trust-protocol 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ceremony.js","sourceRoot":"","sources":["../../src/encounter/ceremony.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,4DAA4D;AAC5D,wEAAwE;AACxE,yEAAyE;AACzE,gCAAgC;AAChC,EAAE;AACF,uCAAuC;AACvC,uEAAuE;AACvE,2EAA2E;AAC3E,wEAAwE;AACxE,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,iEAAiE;AACjE,uEAAuE;AACvE,uEAAuE;AACvE,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,oEAAoE;AACpE,2EAA2E;AAC3E,0EAA0E;AAC1E,uEAAuE;AACvE,iEAAiE;AACjE,uEAAuE;AACvE,mEAAmE;AACnE,iEAAiE;AACjE,0EAA0E;AAC1E,+DAA+D;AAC/D,sEAAsE;AACtE,yEAAyE;AACzE,oCAAoC;AACpC,2EAA2E;AAC3E,mEAAmE;AACnE,sEAAsE;AACtE,4BAA4B;AAC5B,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,0EAA0E;AAC1E,uEAAuE;AACvE,kEAAkE;AAClE,wDAAwD;AACxD,EAAE;AACF,+DAA+D;AAC/D,yEAAyE;AACzE,0EAA0E;AAC1E,gEAAgE;AAChE,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,0EAA0E;AAC1E,yEAAyE;AACzE,sEAAsE;AACtE,yEAAyE;AACzE,uEAAuE;AACvE,0EAA0E;AAC1E,wEAAwE;AACxE,2EAA2E;AAC3E,oEAAoE;AACpE,sEAAsE;AACtE,oEAAoE;AACpE,qEAAqE;AACrE,qEAAqE;AACrE,kEAAkE;AAClE,wEAAwE;AACx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,OAAO;YAClC,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,OAAO;YAClC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,UAAU;YACxC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,UAAU;SACzC,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAClF,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;QAClE,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,kBAAkB;KAC9B,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// encounter/ceremony — the Encounter ceremony on the holder (lib Stage 2,\n// PR 7a; Encounter 0.31 §5–§7 on Delivery 0.81 §4.1–4.3). Graduated from\n// probe/encounter.ts (show, scan, counter, captureSentCard,\n// receiveEncounter, resolve) onto HolderState and the engine; the probe\n// stays as it is for the simulators until PR 7b. The pure checks are the\n// root module's (encounter.ts).\n//\n// What it registers (encounterModule):\n// human acts encounter.show a displayed card under a fresh pair\n// label with a fresh own challenge (5.3):\n// the label and its relationship nonce\n// into the register before display (4110,\n// Identity 6.1), the key's lastShown in\n// `addresses` (Delivery §5), the challenge\n// held open; event encounter.shown carries\n// the card, the optical payload\n// encounter.scan the scanner's step (5.8 trunk 2–3):\n// the displayed card checked, a fresh\n// label and own challenge c_A, the record\n// (5.5), the step credential and the sent\n// card, the fresh tuple (Trust openTuple:\n// its prior candidates frozen, its\n// continuity probe pending, 6820) and the\n// bundle into the outbox, in one commit;\n// event encounter.scanned carries the\n// sent card for the optical leg\n// encounter.capture the optical leg (5.8, 5710): a sent\n// card presented to the displayer\n// encounter.counter the counter-step (5.8 step 4)\n// tasks encounter-bundle/0.1 (proof absent, Delivery 4.1; channel\n// binding: the bundle establishes the tuple) and\n// encounter-credential-delivery/0.1 (proof absent, 4.3;\n// the tuple binding); both signature-class: their acks are\n// signed (receive.ts)\n// decision encounter-confirm: accept issues the counter-step, decline\n// closes the prompt (the edge stays one-sided, 5750)\n// retain tick drops the challenges past their age bound (5200,\n// 5210, 5230)\n//\n// The commit discipline of the probe (prepare, verify, commit under a\n// lock set) is the engine's: preparation is async against a snapshot,\n// apply is synchronous on that same snapshot, and the commit is a CAS on\n// its version (engine.ts). A state that moved is a CAS conflict and the\n// receive re-enters at stage 1, which re-checks the effect cache at stage\n// 4 (Delivery 6.2's waiter rule). So the provisional resolution of 4.1\n// and the authoritative one coincide: apply resolves once, on the\n// snapshot the commit lands on, and selects the branch.\n//\n// Choices this file makes where spec and note leave them open:\n// - ids: the contact and the relationship of a ceremony-born tuple are\n// named after the own fresh pair label, `c-<digest>` and `r-<digest>`\n// (the label's digest component): unique by freshness (4.4)\n// - the aging latch (5260, 5270): an aged value is removed (5210, 5230:\n// no challenge history beyond open values and records), so it never\n// resolves open again. tick removes every aged value; a bundle or an\n// optical card refused because its authoritative resolution found its\n// bound value aged commits that removal and the raised lastWhen even\n// though it refuses — the Encounter latch exception of the engine\n// (receive.ts TaskRefusal.latch): no cache entry, no ack, no journal\n// - the scanner's own challenge c_A goes straight to its record: the\n// record and the issuance commit together (5630: record, then issue);\n// nothing is released before the commit, so \"record before issuing\"\n// holds and no resumable half-state exists (the probe's bundlePending)\n// - the bundle's effect on `open` creates the record, accepts the\n// credential, opens the fresh tuple and the confirm prompt in one\n// commit; the prompt is \"arrival is not acceptance: this device\n// decides\" — accept issues the counter-step. It expires when the\n// counter credential could no longer be accepted: the end of the\n// issuance window of the challenge it binds, c_A (5.6 step 6)\n// - the credential delivery's defined effect (4.3, buffering) and the\n// 5.6 acceptance commit together; the ack does not depend on the\n// acceptance's outcome and the outcome is never signaled (7.4): the\n// document is acknowledged and its thread reserved either way\n// - encounter.counter picks the newest record of the contact on the\n// displayer side whose own credential is not issued; a new issuance\n// needs an active tuple (tuple-deactivated), its document waits for\n// the bundle's thread where the record arose on the optical leg (5780)\n// and goes out with the bundle's record-aware effect\n// - encounter.capture of a card already recorded with the same material\n// is an idempotent success (5430): the act commits its journal entry only\n// - no automatic optical switch (5690 RECOMMENDS ack-wait as its\n// trigger): the app shows the sent card (encounter.scanned) when it\n// sees the bundle undelivered (deliveryStatus)\nimport { b64uOf, iso, jcs, makeValidator, sameDigest } from '../core.js'\nimport type { Json, JsonObject } from '../core.js'\nimport { diSignWith, diVerify, digestBytes, digestDoc } from '../crypto.js'\nimport { seal } from '../delivery.js'\nimport {\n BUNDLE_TYPE, CEREMONY, CHALLENGE_MAX_AGE, SKEW_TOLERANCE, DELIVERY_TYPE, acceptTail, bundleForm, cardBody, cardOk, challengeAged, challengeOf, credHead,\n credentialBody, deliveryForm, dispositionOf, futureOk, issuanceEnd, issuanceOpen, windowOk,\n} from '../encounter.js'\nimport type { CredError, RecordFacts } from '../encounter.js'\nimport { SCHEMAS } from '../schemas.js'\nimport { withPairNonce } from '../identity-state.js'\nimport { tupleByRkid } from '../receive.js'\nimport type { Channel, TaskRefusal } from '../receive.js'\nimport type { Applied, CommandDef, DecisionDef, EventDraft, HolderModule, OutboundDraft, PrepareCtx, Refusal, TaskHandler } from '../engine.js'\nimport type { EnactmentRecord, HeldCredential, HolderState, Millis, Prompt } from '../state.js'\nimport { openTuple } from '../trust/continuity.js'\nimport { entryOf, findContact, tupleByLabel } from '../trust/state.js'\n\nexport { BUNDLE_TYPE, DELIVERY_TYPE }\n\n/** The command names of the human acts. */\nexport const ENCOUNTER_COMMANDS = Object.freeze({\n show: 'encounter.show',\n scan: 'encounter.scan',\n capture: 'encounter.capture',\n counter: 'encounter.counter',\n})\n\nexport interface ShowInput { name?: string }\nexport interface ScanInput { card: Json, name?: string }\nexport interface CaptureInput { card: Json }\nexport interface CounterInput { contactId: string }\n\nconst V = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => V.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\nconst refuse = (reason: TaskRefusal['reason'], ref?: string): TaskRefusal => ({ ok: false, reason, ...(ref ? { ref } : {}) })\nconst no = (code: Refusal['code'], ref?: string): Refusal => ({ ok: false, code, ...(ref ? { ref } : {}) })\nconst isRefusal = (x: unknown): x is Refusal | TaskRefusal => (x as Refusal)?.ok === false\ntype Card = Record<string, any>\n\n/** The contact and relationship ids of the tuple under an own pair label. */\nexport const idsOf = (label: string): { contactId: string, relId: string } => {\n const d = label.slice('pair/'.length)\n return { contactId: 'c-' + d, relId: 'r-' + d }\n}\n\n/** The prompt that asks to confirm the enactment of record `own`. */\nexport const confirmPromptId = (own: string): string => 'encounter:' + own\n\n/** The own-challenge resolution (5240): recorded, open, else unknown. */\nexport function resolve (state: Readonly<HolderState>, value: string, when: Millis): 'recorded' | 'open' | 'unknown' {\n if (Object.hasOwn(state.encounter.records, value)) return 'recorded'\n const c = Object.hasOwn(state.encounter.challenges, value) ? state.encounter.challenges[value] : undefined\n return !c || challengeAged(c.tCh, when) ? 'unknown' : 'open'\n}\n\n/** The aging latch (5260, 5270): where a resolution finds a held value\n * past its age bound, the state with that value removed — committed even\n * by a refusal (receive.ts, the Encounter latch exception), so a clock\n * that moves back never resolves it open again; else undefined. */\nfunction latchOf (state: Readonly<HolderState>, value: string, when: Millis): HolderState | undefined {\n const c = Object.hasOwn(state.encounter.challenges, value) ? state.encounter.challenges[value] : undefined\n if (!c || !challengeAged(c.tCh, when) || Object.hasOwn(state.encounter.records, value)) return undefined\n const challenges = { ...state.encounter.challenges }\n delete challenges[value]\n return { ...state, encounter: { ...state.encounter, challenges } }\n}\n\n/** 5170: a challenge value consumed or held — on either side of any\n * record, or among the own open challenges — enters no new enactment. */\nconst challengeUsed = (state: Readonly<HolderState>, value: string): boolean =>\n Object.hasOwn(state.encounter.challenges, value) || Object.values(state.encounter.records).some((r) => r.own === value || r.peer === value)\n\nconst facts = (r: Readonly<EnactmentRecord>): RecordFacts => ({ counterpart: r.counterpart, ceremony: r.ceremony, tCh: r.tCh, bind: r.bind })\n\n/** Is the thread used: by a record (its bundle's or a later one) or the outbox? (Delivery 3, 4.1) */\nfunction threadInUse (state: Readonly<HolderState>, id: string): boolean {\n for (const r of Object.values(state.encounter.records)) if (r.thread === id || Object.hasOwn(r.threads, id)) return true\n return Object.values(state.outbox).some((o) => o.threadId === id)\n}\n\n/** The original bundle of a thread, re-evaluated (4.2: after the cache's\n * retention) or re-issued on its own fresh thread: not a new document on\n * a used thread. */\nfunction sameOpeningBundle (state: Readonly<HolderState>, anchor: string, threadId: string, digest: string): boolean {\n for (const r of Object.values(state.encounter.records)) {\n if (r.counterpart !== anchor) continue\n if (r.thread === threadId && r.bundleDigest !== null && sameDigest(r.bundleDigest, digest)) return true\n if (Object.hasOwn(r.threads, threadId) && sameDigest(r.threads[threadId], digest)) return true\n }\n return false\n}\n\n/** The record of the tuple under an own pair label. */\nconst recordOfLabel = (state: Readonly<HolderState>, label: string): EnactmentRecord | undefined =>\n Object.values(state.encounter.records).find((r) => r.label === label)\n\nconst withRecord = (state: HolderState, r: EnactmentRecord): HolderState =>\n ({ ...state, encounter: { ...state.encounter, records: { ...state.encounter.records, [r.own]: r } } })\n\n/** The entry a record's tuple feeds, and its relationship (by the tuple: a\n * chaining may have moved it, 6220). */\nfunction placeOf (state: Readonly<HolderState>, r: Readonly<EnactmentRecord>): { contactId: string, relationshipId: string } {\n const at = tupleByLabel(state, r.label)\n if (!at) return { contactId: idsOf(r.label).contactId, relationshipId: r.relId }\n return { contactId: entryOf(state, at.rel)?.id ?? at.tuple.entryId, relationshipId: at.rel.id }\n}\n\nconst sealWith = (ctx: PrepareCtx, doc: Json, keyAgreement: string) =>\n seal(doc, keyAgreement, { ephSeed: ctx.entropy.bytes('seal.eph', 32), nonce: ctx.entropy.bytes('seal.nonce', 12) }, ctx.crypto.subtle)\n\nconst signer = (ctx: PrepareCtx, label: string) => (b: Uint8Array) => ctx.keys.sign(label, b)\n\n/** The display name a card carries: the input's, else the own profile's, at most 200 characters (6090). */\nconst nameFor = (state: Readonly<HolderState>, name: unknown): string | undefined => {\n const n = typeof name === 'string' ? name : (state.profile.body as { name?: unknown } | null)?.name\n return typeof n === 'string' && n.length ? [...n].slice(0, 200).join('') : undefined\n}\n\n/** A fresh pair label from 32 fresh nonce bytes (Identity 6.1, Encounter 4.4). */\nasync function freshLabel (ctx: PrepareCtx): Promise<{ label: string, nonce: string }> {\n const n = ctx.entropy.bytes('founding.nonce', 32)\n return { label: 'pair/' + await digestBytes(n, ctx.crypto.subtle), nonce: b64uOf(n) }\n}\n\n// ── show ───────────────────────────────────────────────────────────────\n\ninterface ShowPrep { label: string, nonce: string, rkid: string, value: string, card: Json }\n\nconst showDef: CommandDef<ShowInput, ShowPrep> = {\n human: true,\n async prepare (ctx, input) {\n const { label, nonce } = await freshLabel(ctx)\n const own = await ctx.keys.anchorOf(label)\n const value = challengeOf(ctx.entropy.bytes('challenge', 17))\n const at = iso(ctx.when)\n const name = nameFor(ctx.snapshot, input?.name)\n const body = cardBody(own, { ...(name !== undefined ? { name } : {}), challenge: { value, issuedAt: at } })\n const card = await diSignWith(own.anchor, signer(ctx, label), body as unknown as Record<string, Json>, at, ctx.crypto.subtle) as unknown as Json\n return { label, nonce, rkid: own.keyAgreement, value, card }\n },\n apply (state, prepared, _input, when) {\n const p = prepared.value\n // fresh-always (4.4, 4150) and single use (5140): fresh entropy never\n // repeats; a repeat is a broken entropy source, not a human's refusal\n if (state.register.labels.includes(p.label) || tupleByLabel(state, p.label)) throw new Error(`encounter.show: the pair label ${p.label} is not fresh`)\n if (resolve(state, p.value, when) !== 'unknown' || Object.hasOwn(state.encounter.challenges, p.value)) throw new Error('encounter.show: the challenge value is not fresh')\n return {\n state: {\n ...state,\n // 4110: the label in the register before the card is displayed\n register: withPairNonce(state.register, p.label, p.nonce),\n addresses: { ...state.addresses, keys: { ...state.addresses.keys, [p.rkid]: { label: p.label, lastShown: when } } },\n encounter: { ...state.encounter, challenges: { ...state.encounter.challenges, [p.value]: { value: p.value, tCh: when, label: p.label, card: p.card as JsonObject } } },\n },\n events: [{ type: 'encounter.shown', challenge: p.value, card: p.card as JsonObject }],\n }\n },\n}\n\n// ── scan ───────────────────────────────────────────────────────────────\n\ntype ScanPrep =\n | Refusal\n | {\n peer: Card, label: string, nonce: string, rkid: string, own: string, bind: string, threadId: string,\n credential: Json, credDigest: string, sentCard: Json, doc: { digest: string, envelope: OutboundDraft['envelope'] },\n }\n\nconst scanDef: CommandDef<ScanInput, ScanPrep> = {\n human: true,\n async prepare (ctx, input) {\n const peer = input?.card as Card\n if ((await cardOk(peer, ctx.crypto.subtle)) !== null) return no('card-invalid', 'RLTP-ENC-6010')\n // a displayed card carries neither sentTo nor boundTo (6070)\n if (peer.sentTo !== undefined || peer.boundTo !== undefined) return no('card-invalid', 'RLTP-ENC-6070')\n const S = ctx.crypto.subtle\n const { label, nonce } = await freshLabel(ctx)\n const me = await ctx.keys.anchorOf(label)\n // c_A: fresh, created now, never the displayed value (5150, 5160)\n let own = challengeOf(ctx.entropy.bytes('challenge', 17))\n for (let i = 0; own === peer.challenge.value && i < 4; i++) own = challengeOf(ctx.entropy.bytes('challenge', 17))\n if (own === peer.challenge.value) throw new Error('encounter.scan: no fresh challenge distinct from the displayed one')\n const bind = await digestDoc({ ceremony: CEREMONY, challenges: [own, peer.challenge.value].sort() }, S)\n const at = iso(ctx.when)\n const sign = signer(ctx, label)\n const credential = await diSignWith(me.anchor, sign, credentialBody(me.anchor, peer.anchor, CEREMONY, peer.challenge.value, bind, at), at, S) as unknown as Json\n const name = nameFor(ctx.snapshot, input?.name)\n const sent = cardBody(me, { ...(name !== undefined ? { name } : {}), challenge: { value: own, issuedAt: at }, sentTo: peer.anchor, boundTo: peer.challenge.value })\n const sentCard = await diSignWith(me.anchor, sign, sent as unknown as Record<string, Json>, at, S) as unknown as Json\n const threadId = ctx.entropy.id('thread.id')\n const doc = { id: ctx.entropy.id('doc.id'), type: BUNDLE_TYPE, issuer: me.anchor, recipient: peer.anchor, threadId, issuedAt: at, payload: { card: sentCard, credential } }\n return {\n peer, label, nonce, rkid: me.keyAgreement, own, bind, threadId, credential, credDigest: await digestDoc(credential, S), sentCard,\n doc: { digest: await digestDoc(doc, S), envelope: await sealWith(ctx, doc as unknown as Json, peer.keyAgreement) },\n }\n },\n apply (state, prepared, _input, when) {\n const p = prepared.value\n if (isRefusal(p)) return p\n const peerValue = p.peer.challenge.value as string\n // 5.3 single use from the scanner's side: a displayed value already in\n // one of the own records never enters a second enactment (5170)\n if (challengeUsed(state, peerValue)) return no('already-scanned', 'RLTP-ENC-5170')\n if (state.register.labels.includes(p.label) || tupleByLabel(state, p.label)) throw new Error(`encounter.scan: the pair label ${p.label} is not fresh`)\n if (resolve(state, p.own, when) !== 'unknown') throw new Error('encounter.scan: the own challenge is not fresh')\n if (threadInUse(state, p.threadId)) throw new Error('encounter.scan: the thread is not fresh')\n // the credential binds c_B: issued only inside its window (5.6 step 6)\n if (!issuanceOpen(Date.parse(p.peer.challenge.issuedAt), when)) return no('stale-issuance', 'RLTP-ENC-5530')\n const ids = idsOf(p.label)\n const opened = openTuple(state, {\n relId: ids.relId, contactId: ids.contactId, ownPairLabel: p.label, counterpartAnchor: p.peer.anchor,\n counterpartKeyAgreement: p.peer.keyAgreement, provenance: { kind: 'ceremony' }, nonce: p.nonce,\n }, p.rkid, when)\n const record: EnactmentRecord = {\n ceremony: CEREMONY, own: p.own, tCh: when, peer: peerValue, counterpart: p.peer.anchor, card: p.peer as JsonObject, bind: p.bind,\n at: when, label: p.label, relId: ids.relId, role: 'scanner', out: { digest: p.credDigest, credential: p.credential as JsonObject }, in: null,\n thread: p.threadId, bundleDigest: p.doc.digest, threads: {}, sentCard: p.sentCard as JsonObject | null, counterPending: false,\n }\n return {\n state: withRecord(opened.state, record),\n outbound: [{\n digest: p.doc.digest, envelope: p.doc.envelope, type: BUNDLE_TYPE, threadId: p.threadId,\n recipient: { contactId: ids.contactId, rkid: p.rkid, keyAgreement: p.peer.keyAgreement },\n }],\n events: [\n ...(opened.events ?? []),\n { type: 'encounter.recorded', contactId: ids.contactId, relationshipId: ids.relId, role: 'scanner' },\n { type: 'encounter.scanned', contactId: ids.contactId, card: p.sentCard as JsonObject },\n ],\n duties: opened.duties,\n }\n },\n}\n\n// ── the optical leg: capture a sent card (5.8, 5710) ───────────────────\n\ntype CapturePrep = Refusal | { card: Card, label: string, bind: string }\n\nconst captureDef: CommandDef<CaptureInput, CapturePrep> = {\n human: true,\n async prepare (ctx, input) {\n const card = input?.card as Card\n if ((await cardOk(card, ctx.crypto.subtle)) !== null) return no('card-invalid', 'RLTP-ENC-6010')\n if (typeof card.sentTo !== 'string' || typeof card.boundTo !== 'string') return no('card-invalid', 'RLTP-ENC-6030')\n if (card.challenge.value === card.boundTo) return no('card-invalid', 'RLTP-ENC-5160')\n // sentTo = the own anchor that displayed boundTo (6050, 4.4)\n const s = ctx.snapshot.encounter\n const label = Object.hasOwn(s.records, card.boundTo) ? s.records[card.boundTo].label\n : Object.hasOwn(s.challenges, card.boundTo) ? s.challenges[card.boundTo].label : null\n if (label !== null && (await ctx.keys.anchorOf(label)).anchor !== card.sentTo) return no('card-invalid', 'RLTP-ENC-6050')\n return { card, label: label ?? '', bind: await digestDoc({ ceremony: CEREMONY, challenges: [card.boundTo, card.challenge.value].sort() }, ctx.crypto.subtle) }\n },\n apply (state, prepared, _input, when) {\n const p = prepared.value\n if (isRefusal(p)) return p\n const { card } = p\n const st = resolve(state, card.boundTo, when)\n if (st === 'unknown') {\n const latch = latchOf(state, card.boundTo, when)\n return { ...no('gate-expired', 'RLTP-ENC-5460'), ...(latch ? { latch } : {}) }\n }\n if (st === 'recorded') {\n // the taxonomy of 5.5 (5430–5450)\n const r = state.encounter.records[card.boundTo]\n if (r.counterpart !== card.anchor) return no('consumed-challenge', 'RLTP-ENC-5440')\n if (jcs(r.card) !== jcs(card)) return no('card-mismatch', 'RLTP-ENC-5450')\n return { state: state as HolderState }\n }\n const ch = state.encounter.challenges[card.boundTo]\n if (challengeUsed(state, card.challenge.value)) return no('consumed-challenge', 'RLTP-ENC-5170')\n if (!futureOk(ch.tCh, when)) return no('gate-future', 'RLTP-ENC-5390')\n return recordCreating(state, { label: ch.label, own: ch.value, tCh: ch.tCh, card, bind: p.bind, rkid: rkidOf(state, ch.label), when, in: null, thread: null, digest: null })\n },\n}\n\n/** The own key-agreement id a label derives under, from `addresses`. */\nfunction rkidOf (state: Readonly<HolderState>, label: string): string {\n for (const [rkid, k] of Object.entries(state.addresses.keys)) if (k.label === label) return rkid\n throw new Error(`encounter: no address key for ${label}`)\n}\n\n/** The displayer's record-creating effect (5.5, 5650, 5710): the record,\n * the fresh tuple, the challenge superseded (5220), the confirm prompt. */\nfunction recordCreating (state: Readonly<HolderState>, x: {\n label: string, own: string, tCh: Millis, card: Card, bind: string, rkid: string, when: Millis,\n in: { digest: string, credential: Json } | null, thread: string | null, digest: string | null,\n}): Applied {\n const ids = idsOf(x.label)\n const nonce = Object.hasOwn(state.register.pairNonces, x.label) ? state.register.pairNonces[x.label] : undefined\n const opened = openTuple(state, {\n relId: ids.relId, contactId: ids.contactId, ownPairLabel: x.label, counterpartAnchor: x.card.anchor,\n counterpartKeyAgreement: x.card.keyAgreement, provenance: { kind: 'ceremony' }, ...(nonce !== undefined ? { nonce } : {}),\n }, x.rkid, x.when)\n const record: EnactmentRecord = {\n ceremony: CEREMONY, own: x.own, tCh: x.tCh, peer: x.card.challenge.value, counterpart: x.card.anchor, card: x.card as JsonObject, bind: x.bind,\n at: x.when, label: x.label, relId: ids.relId, role: 'displayer', out: null, in: x.in as HeldCredential | null, thread: x.thread, bundleDigest: x.digest,\n threads: {}, sentCard: null, counterPending: false,\n }\n const challenges = { ...opened.state.encounter.challenges }\n delete challenges[x.own]\n const prompt: Prompt = {\n id: confirmPromptId(x.own), kind: 'encounter-confirm', contactId: ids.contactId, openedAt: x.when,\n // the counter credential binds c_A: acceptable only inside its window (5.6 step 6)\n expiresAt: issuanceEnd(Date.parse(x.card.challenge.issuedAt)),\n }\n const next = withRecord({ ...opened.state, encounter: { ...opened.state.encounter, challenges } }, record)\n return {\n state: { ...next, prompts: { ...next.prompts, [prompt.id]: prompt } },\n events: [\n ...(opened.events ?? []),\n { type: 'encounter.recorded', contactId: ids.contactId, relationshipId: ids.relId, role: 'displayer' },\n ...(x.in ? [{ type: 'encounter.accepted', contactId: ids.contactId, relationshipId: ids.relId, mutual: false } as EventDraft] : []),\n { type: 'prompt.opened', promptId: prompt.id, kind: 'encounter-confirm' },\n ],\n duties: opened.duties,\n }\n}\n\n// ── the counter-step (5.8 step 4, 5750–5780) ───────────────────────────\n\ninterface CounterDoc { digest: string, envelope: OutboundDraft['envelope'], threadId: string }\ntype CounterPrep = Refusal | { own: string, credential: Json, digest: string, doc: CounterDoc | null }\n\n/** The counter-step's delivery document in the bundle's thread (4.3, 5760). */\nasync function counterDoc (ctx: PrepareCtx, r: Readonly<EnactmentRecord>, issuer: string, credential: Json, threadId: string): Promise<CounterDoc> {\n const doc = {\n id: ctx.entropy.id('doc.id'), type: DELIVERY_TYPE, issuer, recipient: r.counterpart, threadId, issuedAt: iso(ctx.when),\n ceremony: { step: 'counter', enactment: r.bind }, payload: { credential },\n }\n return { digest: await digestDoc(doc, ctx.crypto.subtle), envelope: await sealWith(ctx, doc as unknown as Json, (r.card as Card).keyAgreement), threadId }\n}\n\n/** The displayer's record of a contact the counter-step issues on: the\n * newest whose own credential is not issued. */\nfunction counterRecord (state: Readonly<HolderState>, contactId: string): EnactmentRecord | Refusal {\n const c = findContact(state, contactId)\n if (!c) return no('unknown-contact')\n const ids = new Set([c.id, ...c.aliases])\n const mine = Object.values(state.encounter.records).filter((r) => r.role === 'displayer' && ids.has(placeOf(state, r).contactId))\n if (!mine.length) return no('no-record')\n const open = mine.filter((r) => r.out === null).sort((a, b) => b.at - a.at)\n return open.length ? open[0] : no('already-issued')\n}\n\nasync function prepareCounter (ctx: PrepareCtx, r: Readonly<EnactmentRecord>): Promise<CounterPrep> {\n const S = ctx.crypto.subtle\n const me = await ctx.keys.anchorOf(r.label)\n const at = iso(ctx.when)\n // the subject's challenge is c_A, the record's peer value (5320)\n const credential = await diSignWith(me.anchor, signer(ctx, r.label), credentialBody(me.anchor, r.counterpart, CEREMONY, r.peer, r.bind, at), at, S) as unknown as Json\n return { own: r.own, credential, digest: await digestDoc(credential, S), doc: r.thread !== null ? await counterDoc(ctx, r, me.anchor, credential, r.thread) : null }\n}\n\n/** The counter-step's effect: the own credential committed (5770), its\n * document out where the bundle's thread is known, else pending (5780);\n * the confirm prompt of the record closes. */\nfunction applyCounter (state: Readonly<HolderState>, p: CounterPrep, when: Millis, closePrompt: boolean): Applied | Refusal {\n if (isRefusal(p)) return p\n const r = state.encounter.records[p.own]\n if (!r || r.role !== 'displayer') return no('no-record')\n if (r.out !== null) return no('already-issued')\n const at = tupleByLabel(state, r.label)\n if (!at || at.tuple.deactivated) return no('tuple-deactivated')\n if (!issuanceOpen(Date.parse((r.card as Card).challenge.issuedAt), when)) return no('stale-issuance', 'RLTP-ENC-5530')\n if ((p.doc === null) !== (r.thread === null)) throw new Error('encounter.counter: prepared on another thread state')\n const place = placeOf(state, r)\n let next = withRecord(state as HolderState, { ...r, out: { digest: p.digest, credential: p.credential as JsonObject }, counterPending: p.doc === null })\n const events: EventDraft[] = []\n const pid = confirmPromptId(r.own)\n if (closePrompt && Object.hasOwn(next.prompts, pid)) {\n const prompts = { ...next.prompts }\n delete prompts[pid]\n next = { ...next, prompts }\n events.push({ type: 'prompt.decided', promptId: pid, kind: 'encounter-confirm', choice: 'accept' })\n }\n return {\n state: next,\n outbound: p.doc ? [{ digest: p.doc.digest, envelope: p.doc.envelope, type: DELIVERY_TYPE, threadId: p.doc.threadId, recipient: { contactId: place.contactId, rkid: at.tuple.rkid, keyAgreement: at.tuple.counterpartKeyAgreement } }] : [],\n events,\n }\n}\n\nconst counterDef: CommandDef<CounterInput, CounterPrep> = {\n human: true,\n async prepare (ctx, input) {\n const r = counterRecord(ctx.snapshot, input?.contactId)\n return isRefusal(r) ? r : prepareCounter(ctx, r)\n },\n apply: (state, prepared, _input, when) => applyCounter(state, prepared.value, when, true),\n}\n\n/** encounter-confirm: accept issues the counter-step; decline only closes. */\nconst confirmDecision: DecisionDef<CounterPrep | null> = {\n async prepare (ctx, prompt, choice) {\n if (choice !== 'accept') return null\n const r = ctx.snapshot.encounter.records[prompt.id.slice('encounter:'.length)]\n return r ? prepareCounter(ctx, r) : no('no-record')\n },\n apply (state, prompt, choice, when, prepared) {\n if (choice === 'decline') return { state: state as HolderState }\n // the prompts module closes the prompt and announces the decision\n return applyCounter(state, prepared.value ?? no('no-record'), when, false)\n },\n}\n\n// ── encounter-bundle/0.1 (Delivery 4.1) ────────────────────────────────\n\ninterface BundlePayload { card: Card, credential: Card }\ninterface BundlePrep { bind: string, credDigest: string, counter: CounterDoc | null, st: 'open' | 'recorded' | 'unknown' }\n\n/** Delivery 4.1 checks 5–6 under a resolution that found the value held:\n * the ceremony (5520), the enacting anchor (4100), the enactment binding\n * (5560), the issuance window (5530); null when they pass. */\nfunction checks56 (state: Readonly<HolderState>, credential: Record<string, any>, own: string, st: 'open' | 'recorded', bind: string, rkid: string): TaskRefusal | null {\n const held = st === 'open' ? state.encounter.challenges[own] : state.encounter.records[own]\n if (credential.credentialSubject.ceremony !== CEREMONY) return refuse('validation-failed', 'RLTP-ENC-5520')\n // the enacting anchor is the one that displayed the bound challenge (4.4)\n if (held.label !== state.addresses.keys[rkid]?.label) return refuse('validation-failed', 'RLTP-ENC-4100')\n if (!sameDigest(credential.credentialSubject.enactmentBinding, bind)) return refuse('validation-failed', 'RLTP-ENC-5560')\n if (!windowOk(credential, held.tCh)) return refuse('stale-issuance', 'RLTP-ENC-5530')\n return null\n}\n\nconst bundleTask: TaskHandler<BundlePayload, BundlePrep> = {\n proof: 'absent',\n decode: (payload) => (schemaOk('payload-encounter-bundle.schema.json', payload) ? payload as BundlePayload : refuse('malformed')),\n // check 1 (structure, outer/inner, credential format), then the binding:\n // the arrival tuple where the record exists and the issuer is its\n // counterpart, else the bundle itself — it establishes the tuple (4.1),\n // its issuer = card.anchor = credential.issuer\n channel (state, doc, rkid): Channel | TaskRefusal {\n const f = bundleForm(doc)\n if (f) return refuse(f.reason)\n const at = tupleByRkid(state, rkid)\n if (at && doc.issuer === at.tuple.counterpartAnchor) return { keyAgreement: at.tuple.counterpartKeyAgreement, contactId: entryOf(state, at.rel)?.id ?? at.rel.contactId }\n // another issuer on a recorded display key: the record decides at stage\n // 9 (consumed-challenge, 4.1); its ack is never produced\n const k = state.addresses.keys[rkid]\n if (!k || !k.label.startsWith('pair/')) return refuse('validation-failed')\n return { keyAgreement: doc.payload.card.keyAgreement, contactId: idsOf(k.label).contactId }\n },\n // checks 2–4: card proof, credential proof, addressee (no state touched);\n // then check 5 the provisional resolution and, where it found the value\n // held, checks 5–6 at stage 8 (an unknown value goes to stage 9)\n async prepare (ctx, doc, arrival) {\n const { card, credential } = doc.payload\n if (!(await diVerify(card, card.anchor, ctx.crypto.subtle))) return refuse('validation-failed', 'RLTP-ENC-6020')\n const h = await credHead(credential, doc.recipient, false, ctx.crypto.subtle)\n if (h) return refuse(dispositionOf(h), errRef(h))\n const S = ctx.crypto.subtle\n const own = credential.credentialSubject.challenge as string\n const r = Object.hasOwn(ctx.snapshot.encounter.records, own) ? ctx.snapshot.encounter.records[own] : undefined\n // a counter-step issued on the optical leg waited for this thread (5780)\n const counter = r && r.counterPending && r.out && r.counterpart === card.anchor\n ? await counterDoc(ctx, r, doc.recipient, r.out.credential, r.thread ?? doc.threadId) : null\n const bind = await digestDoc({ ceremony: CEREMONY, challenges: [own, card.challenge.value].sort() }, S)\n const st = resolve(ctx.snapshot, own, ctx.when)\n if (st !== 'unknown') {\n const bad = checks56(ctx.snapshot, credential, own, st, bind, arrival.rkid)\n if (bad) return bad\n }\n return { bind, credDigest: await digestDoc(credential, S), counter, st }\n },\n // the authoritative resolution and the branch it selects (4.1); checks\n // 5–6 again only where it differs from the provisional one\n apply (state, prepared, doc, arrival) {\n const p = prepared.value\n const { card, credential } = doc.payload\n const when = arrival.when\n const own = credential.credentialSubject.challenge as string\n const st = resolve(state, own, when)\n if (st === 'unknown') {\n const latch = latchOf(state, own, when)\n return { ...refuse('validation-failed', 'RLTP-ENC-5240'), ...(latch ? { latch } : {}) }\n }\n const held = st === 'open' ? state.encounter.challenges[own] : state.encounter.records[own]\n if (st !== p.st) {\n const bad = checks56(state, credential, own, st, p.bind, arrival.rkid)\n if (bad) return bad\n }\n if (threadInUse(state, doc.threadId) && !sameOpeningBundle(state, card.anchor, doc.threadId, arrival.digest)) return refuse('validation-failed')\n if (st === 'open') {\n if (challengeUsed(state, card.challenge.value)) return refuse('validation-failed', 'RLTP-ENC-5170')\n if (!futureOk(held.tCh, when)) return refuse('gate-future', 'RLTP-ENC-5390')\n return recordCreating(state, {\n label: held.label, own, tCh: held.tCh, card, bind: p.bind, rkid: arrival.rkid, when,\n in: { digest: p.credDigest, credential: credential as Json }, thread: doc.threadId, digest: arrival.digest,\n })\n }\n // recorded: the record decides (4.1)\n const r = held as EnactmentRecord\n if (r.counterpart !== card.anchor) return refuse('consumed-challenge', 'RLTP-ENC-5440')\n if (jcs(r.card) !== jcs(card)) return refuse('validation-failed', 'RLTP-ENC-5730')\n const e = acceptTail(credential, facts(r), 'bundle')\n if (e) return refuse(dispositionOf(e), errRef(e))\n if (r.in && !sameDigest(r.in.digest, p.credDigest)) return refuse('validation-failed', 'RLTP-ENC-5570')\n // the record-aware effect: no gate, no second record (5740)\n const thread = r.thread ?? doc.threadId\n const next: EnactmentRecord = {\n ...r,\n in: r.in ?? { digest: p.credDigest, credential: credential as JsonObject },\n thread,\n bundleDigest: r.bundleDigest ?? arrival.digest,\n threads: thread === doc.threadId ? r.threads : { ...r.threads, [doc.threadId]: arrival.digest },\n counterPending: r.counterPending && !p.counter,\n }\n const place = placeOf(state, r)\n const at = tupleByLabel(state, r.label)\n const events: EventDraft[] = r.in ? [] : [{ type: 'encounter.accepted', contactId: place.contactId, relationshipId: place.relationshipId, mutual: r.out !== null }]\n const outbound: OutboundDraft[] = p.counter && at\n ? [{ digest: p.counter.digest, envelope: p.counter.envelope, type: DELIVERY_TYPE, threadId: p.counter.threadId, recipient: { contactId: place.contactId, rkid: at.tuple.rkid, keyAgreement: at.tuple.counterpartKeyAgreement } }]\n : []\n return { state: withRecord(state as HolderState, next), events, outbound }\n },\n}\n\nconst errRef = (e: CredError): string => ({\n ERR_VERSION: 'RLTP-ENC-5480', ERR_SIG: 'RLTP-ENC-5490', ERR_ADDRESSEE: 'RLTP-ENC-5500', ERR_NO_RECORD: 'RLTP-ENC-5510',\n ERR_CEREMONY: 'RLTP-ENC-5520', ERR_STALE_ISSUANCE: 'RLTP-ENC-5530', ERR_BINDING: 'RLTP-ENC-5560', ERR_CONFLICT: 'RLTP-ENC-5570',\n} as const)[e]\n\n// ── encounter-credential-delivery/0.1 (Delivery 4.3) ───────────────────\n\ninterface DeliveryPayload { credential: Card }\ninterface DeliveryPrep { verdict: CredError | null, credDigest: string }\n\nconst deliveryTask: TaskHandler<DeliveryPayload, DeliveryPrep> = {\n proof: 'absent',\n // bound to the enactment record on its tuple (below): a late counter\n // credential is taken against the record even where a chaining has\n // deactivated that tuple since (4.2; encounter review 2/14); no new\n // issuance goes out on it\n pinned: true,\n decode: (payload) => (schemaOk('payload-encounter-credential-delivery.schema.json', payload) ? payload as DeliveryPayload : refuse('malformed')),\n async prepare (ctx, doc, arrival) {\n const f = deliveryForm(doc)\n if (f) return refuse('validation-failed', 'RLTP-ENC-5760')\n // the relationship channel to the issuer: a record on the arrival tuple\n const at = tupleByRkid(ctx.snapshot, arrival.rkid)\n if (!at || !recordOfLabel(ctx.snapshot, at.tuple.ownPairLabel)) return refuse('validation-failed')\n // 5.6 steps 1–3, no state touched; the rest runs in the transaction\n return { verdict: await credHead(doc.payload.credential, doc.recipient, true, ctx.crypto.subtle), credDigest: await digestDoc(doc.payload.credential, ctx.crypto.subtle) }\n },\n apply (state, prepared, doc, arrival) {\n const at = tupleByRkid(state, arrival.rkid)!\n const r = recordOfLabel(state, at.tuple.ownPairLabel)!\n // the thread rule of 4.3: counter in the bundle's thread, deliver outside it\n const step = (doc.ceremony as { step?: unknown } | undefined)?.step\n const inBundle = r.thread !== null && doc.threadId === r.thread\n if (step === 'counter' && !inBundle) return refuse('validation-failed', 'RLTP-ENC-5760')\n if (step === 'deliver' && inBundle) return refuse('validation-failed')\n if (!inBundle && threadInUse(state, doc.threadId)) return refuse('validation-failed')\n // the defined effect: buffering (the thread reserved); acceptance (5.6)\n // in the same transaction, its outcome never signaled (7.4)\n const cred = doc.payload.credential\n const p = prepared.value\n const bound = Object.hasOwn(state.encounter.records, cred.credentialSubject.challenge) ? state.encounter.records[cred.credentialSubject.challenge] : undefined\n let e: CredError | null = p.verdict ?? acceptTail(cred, bound && bound.label === r.label ? facts(bound) : undefined, 'credential')\n if (!e && r.in && !sameDigest(r.in.digest, p.credDigest)) e = 'ERR_CONFLICT'\n let next: EnactmentRecord = inBundle ? r : { ...r, threads: { ...r.threads, [doc.threadId]: arrival.digest } }\n const events: EventDraft[] = []\n if (!e && !r.in) {\n next = { ...next, in: { digest: p.credDigest, credential: cred as JsonObject } }\n const place = placeOf(state, r)\n events.push({ type: 'encounter.accepted', contactId: place.contactId, relationshipId: place.relationshipId, mutual: r.out !== null })\n }\n return { state: next === r ? state as HolderState : withRecord(state as HolderState, next), events }\n },\n}\n\n// ── retention: the aging latch's end (5200–5230) ───────────────────────\n\nfunction retainChallenges (state: Readonly<HolderState>, when: Millis): HolderState {\n const aged = Object.values(state.encounter.challenges).filter((c) => challengeAged(c.tCh, when))\n if (!aged.length) return state as HolderState\n const challenges = { ...state.encounter.challenges }\n for (const c of aged) delete challenges[c.value]\n return { ...state, encounter: { ...state.encounter, challenges } }\n}\n\n/** When retainChallenges drops an aged challenge (5.3): the first whole\n * second past its maximum age and the skew (the timer contract, engine.ts). */\nconst challengeDeadlines = (state: Readonly<HolderState>): Millis[] =>\n Object.values(state.encounter.challenges).map((c) => (Math.floor(c.tCh / 1000) + (CHALLENGE_MAX_AGE + SKEW_TOLERANCE) / 1000 + 1) * 1000)\n\n/** The encounter module createHolder registers. */\nexport function encounterModule (): HolderModule {\n return Object.freeze({\n name: 'encounter',\n commands: Object.freeze({\n [ENCOUNTER_COMMANDS.show]: showDef,\n [ENCOUNTER_COMMANDS.scan]: scanDef,\n [ENCOUNTER_COMMANDS.capture]: captureDef,\n [ENCOUNTER_COMMANDS.counter]: counterDef,\n }),\n tasks: Object.freeze({ [BUNDLE_TYPE]: bundleTask, [DELIVERY_TYPE]: deliveryTask }),\n decisions: Object.freeze({ 'encounter-confirm': confirmDecision }),\n retain: retainChallenges,\n deadlines: challengeDeadlines,\n })\n}\n"]}
1
+ {"version":3,"file":"ceremony.js","sourceRoot":"","sources":["../../src/encounter/ceremony.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,4DAA4D;AAC5D,wEAAwE;AACxE,yEAAyE;AACzE,gCAAgC;AAChC,EAAE;AACF,uCAAuC;AACvC,uEAAuE;AACvE,2EAA2E;AAC3E,wEAAwE;AACxE,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,uEAAuE;AACvE,0EAA0E;AAC1E,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,yEAAyE;AACzE,mDAAmD;AACnD,uEAAuE;AACvE,uEAAuE;AACvE,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,oEAAoE;AACpE,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,2DAA2D;AAC3D,2EAA2E;AAC3E,uDAAuD;AACvD,uEAAuE;AACvE,mEAAmE;AACnE,iEAAiE;AACjE,0EAA0E;AAC1E,+DAA+D;AAC/D,sEAAsE;AACtE,yEAAyE;AACzE,oCAAoC;AACpC,2EAA2E;AAC3E,mEAAmE;AACnE,sEAAsE;AACtE,4BAA4B;AAC5B,EAAE;AACF,sEAAsE;AACtE,sEAAsE;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31 §5–§7 on Delivery 0.81 §4.1–4.3). Graduated from\n// probe/encounter.ts (show, scan, counter, captureSentCard,\n// receiveEncounter, resolve) onto HolderState and the engine; the probe\n// stays as it is for the simulators until PR 7b. The pure checks are the\n// root module's (encounter.ts).\n//\n// What it registers (encounterModule):\n// human acts encounter.show a displayed card under a fresh pair\n// label with a fresh own challenge (5.3):\n// the label and its relationship nonce\n// into the register before display (4110,\n// Identity 6.1), the key's lastShown in\n// `addresses` (Delivery §5), the challenge\n// held open; with a carrier offer the\n// card carries its delivery hints (6080)\n// and its carrier nonce enters the\n// register under the relationship the\n// card opens (Identity §7a.3); event\n// encounter.shown carries the card, the\n// optical payload\n// encounter.scan the scanner's step (5.8 trunk 2–3):\n// the displayed card checked, a fresh\n// label and own challenge c_A, the record\n// (5.5), the step credential and the sent\n// card, the fresh tuple (Trust openTuple:\n// its prior candidates frozen, its\n// continuity probe pending, 6820) and the\n// bundle into the outbox, in one commit;\n// a carrier offer as with show, its hints\n// in the sent card; event\n// encounter.scanned carries the sent card\n// for the optical leg\n// encounter.capture the optical leg (5.8, 5710): a sent\n// card presented to the displayer\n// encounter.counter the counter-step (5.8 step 4)\n// tasks encounter-bundle/0.1 (proof absent, Delivery 4.1; channel\n// binding: the bundle establishes the tuple) and\n// encounter-credential-delivery/0.1 (proof absent, 4.3;\n// the tuple binding); both signature-class: their acks are\n// signed (receive.ts)\n// decision encounter-confirm: accept issues the counter-step, decline\n// closes the prompt (the edge stays one-sided, 5750)\n// retain tick drops the challenges past their age bound (5200,\n// 5210, 5230)\n//\n// The commit discipline of the probe (prepare, verify, commit under a\n// lock set) is the engine's: preparation is async against a snapshot,\n// apply is synchronous on that same snapshot, and the commit is a CAS on\n// its version (engine.ts). A state that moved is a CAS conflict and the\n// receive re-enters at stage 1, which re-checks the effect cache at stage\n// 4 (Delivery 6.2's waiter rule). So the provisional resolution of 4.1\n// and the authoritative one coincide: apply resolves once, on the\n// snapshot the commit lands on, and selects the branch.\n//\n// Choices this file makes where spec and note leave them open:\n// - ids: the contact and the relationship of a ceremony-born tuple are\n// named after the own fresh pair label, `c-<digest>` and `r-<digest>`\n// (the label's digest component): unique by freshness (4.4)\n// - the aging latch (5260, 5270): an aged value is removed (5210, 5230:\n// no challenge history beyond open values and records), so it never\n// resolves open again. tick removes every aged value; a bundle or an\n// optical card refused because its authoritative resolution found its\n// bound value aged commits that removal and the raised lastWhen even\n// though it refuses — the Encounter latch exception of the engine\n// (receive.ts TaskRefusal.latch): no cache entry, no ack, no journal\n// - the scanner's own challenge c_A goes straight to its record: the\n// record and the issuance commit together (5630: record, then issue);\n// nothing is released before the commit, so \"record before issuing\"\n// holds and no resumable half-state exists (the probe's bundlePending)\n// - the bundle's effect on `open` creates the record, accepts the\n// credential, opens the fresh tuple and the confirm prompt in one\n// commit; the prompt is \"arrival is not acceptance: this device\n// decides\" — accept issues the counter-step. It expires when the\n// counter credential could no longer be accepted: the end of the\n// issuance window of the challenge it binds, c_A (5.6 step 6)\n// - the credential delivery's defined effect (4.3, buffering) and the\n// 5.6 acceptance commit together; the ack does not depend on the\n// acceptance's outcome and the outcome is never signaled (7.4): the\n// document is acknowledged and its thread reserved either way\n// - encounter.counter picks the newest record of the contact on the\n// displayer side whose own credential is not issued; a new issuance\n// needs an active tuple (tuple-deactivated), its document waits for\n// the bundle's thread where the record arose on the optical leg (5780)\n// and goes out with the bundle's record-aware effect\n// - the carrier offer {nonce, deliveryHints}: the app draws the carrier\n// nonce N and builds the hints from it (an adapter derives the wire\n// identities from root, carrier and N), so the offer is plain act\n// input, bound and journaled with the act; the library checks 6090 on\n// the hints (card-invalid), N's form and freshness (carrier-nonce-\n// invalid: 32 bytes, held nowhere in the register), and interprets no\n// hint. N enters the register at show already, under the relationship\n// id the card's label opens, as the label and its pair nonce do (4110);\n// a card that ages unscanned leaves it there, like its label (the\n// register only grows)\n// - encounter.capture of a card already recorded with the same material\n// is an idempotent success (5430): the act commits its journal entry only\n// - no automatic optical switch (5690 RECOMMENDS ack-wait as its\n// trigger): the app shows the sent card (encounter.scanned) when it\n// sees the bundle undelivered (deliveryStatus)\nimport { b64uOf, fromB64u, iso, jcs, makeValidator, sameDigest } from '../core.js'\nimport type { Json, JsonObject } from '../core.js'\nimport { diSignWith, diVerify, digestBytes, digestDoc } from '../crypto.js'\nimport { seal } from '../delivery.js'\nimport {\n BUNDLE_TYPE, CEREMONY, CHALLENGE_MAX_AGE, SKEW_TOLERANCE, DELIVERY_TYPE, acceptTail, bundleForm, cardBody, cardOk, challengeAged, challengeOf, credHead,\n credentialBody, deliveryForm, dispositionOf, futureOk, issuanceEnd, issuanceOpen, windowOk,\n} from '../encounter.js'\nimport type { CredError, RecordFacts } from '../encounter.js'\nimport { SCHEMAS } from '../schemas.js'\nimport { carrierNonceHeld, withCarrierNonce, withPairNonce } from '../identity-state.js'\nimport { tupleByRkid } from '../receive.js'\nimport type { Channel, TaskRefusal } from '../receive.js'\nimport type { Applied, CommandDef, DecisionDef, EventDraft, HolderModule, OutboundDraft, PrepareCtx, Refusal, TaskHandler } from '../engine.js'\nimport type { EnactmentRecord, HeldCredential, HolderState, Millis, Prompt } from '../state.js'\nimport { openTuple } from '../trust/continuity.js'\nimport { entryOf, findContact, tupleByLabel } from '../trust/state.js'\n\nexport { BUNDLE_TYPE, DELIVERY_TYPE }\n\n/** The command names of the human acts. */\nexport const ENCOUNTER_COMMANDS = Object.freeze({\n show: 'encounter.show',\n scan: 'encounter.scan',\n capture: 'encounter.capture',\n counter: 'encounter.counter',\n})\n\n/** The carrier offer as the act binds it: the relationship's carrier\n * nonce N (Identity §7a.3) in canonical base64url, and the delivery hints\n * the app built from it (Encounter 6080; their form is the carrier\n * profile's, the library interprets none). */\nexport interface CarrierOfferInput { nonce: string, deliveryHints: string[] }\nexport interface ShowInput { name?: string, carrier?: CarrierOfferInput }\nexport interface ScanInput { card: Json, name?: string, carrier?: CarrierOfferInput }\nexport interface CaptureInput { card: Json }\nexport interface CounterInput { contactId: string }\n\nconst V = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => V.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\nconst refuse = (reason: TaskRefusal['reason'], ref?: string): TaskRefusal => ({ ok: false, reason, ...(ref ? { ref } : {}) })\nconst no = (code: Refusal['code'], ref?: string): Refusal => ({ ok: false, code, ...(ref ? { ref } : {}) })\nconst isRefusal = (x: unknown): x is Refusal | TaskRefusal => (x as Refusal)?.ok === false\ntype Card = Record<string, any>\n\n/** The contact and relationship ids of the tuple under an own pair label. */\nexport const idsOf = (label: string): { contactId: string, relId: string } => {\n const d = label.slice('pair/'.length)\n return { contactId: 'c-' + d, relId: 'r-' + d }\n}\n\n/** The prompt that asks to confirm the enactment of record `own`. */\nexport const confirmPromptId = (own: string): string => 'encounter:' + own\n\n/** The own-challenge resolution (5240): recorded, open, else unknown. */\nexport function resolve (state: Readonly<HolderState>, value: string, when: Millis): 'recorded' | 'open' | 'unknown' {\n if (Object.hasOwn(state.encounter.records, value)) return 'recorded'\n const c = Object.hasOwn(state.encounter.challenges, value) ? state.encounter.challenges[value] : undefined\n return !c || challengeAged(c.tCh, when) ? 'unknown' : 'open'\n}\n\n/** The aging latch (5260, 5270): where a resolution finds a held value\n * past its age bound, the state with that value removed — committed even\n * by a refusal (receive.ts, the Encounter latch exception), so a clock\n * that moves back never resolves it open again; else undefined. */\nfunction latchOf (state: Readonly<HolderState>, value: string, when: Millis): HolderState | undefined {\n const c = Object.hasOwn(state.encounter.challenges, value) ? state.encounter.challenges[value] : undefined\n if (!c || !challengeAged(c.tCh, when) || Object.hasOwn(state.encounter.records, value)) return undefined\n const challenges = { ...state.encounter.challenges }\n delete challenges[value]\n return { ...state, encounter: { ...state.encounter, challenges } }\n}\n\n/** 5170: a challenge value consumed or held — on either side of any\n * record, or among the own open challenges — enters no new enactment. */\nconst challengeUsed = (state: Readonly<HolderState>, value: string): boolean =>\n Object.hasOwn(state.encounter.challenges, value) || Object.values(state.encounter.records).some((r) => r.own === value || r.peer === value)\n\nconst facts = (r: Readonly<EnactmentRecord>): RecordFacts => ({ counterpart: r.counterpart, ceremony: r.ceremony, tCh: r.tCh, bind: r.bind })\n\n/** Is the thread used: by a record (its bundle's or a later one) or the outbox? (Delivery 3, 4.1) */\nfunction threadInUse (state: Readonly<HolderState>, id: string): boolean {\n for (const r of Object.values(state.encounter.records)) if (r.thread === id || Object.hasOwn(r.threads, id)) return true\n return Object.values(state.outbox).some((o) => o.threadId === id)\n}\n\n/** The original bundle of a thread, re-evaluated (4.2: after the cache's\n * retention) or re-issued on its own fresh thread: not a new document on\n * a used thread. */\nfunction sameOpeningBundle (state: Readonly<HolderState>, anchor: string, threadId: string, digest: string): boolean {\n for (const r of Object.values(state.encounter.records)) {\n if (r.counterpart !== anchor) continue\n if (r.thread === threadId && r.bundleDigest !== null && sameDigest(r.bundleDigest, digest)) return true\n if (Object.hasOwn(r.threads, threadId) && sameDigest(r.threads[threadId], digest)) return true\n }\n return false\n}\n\n/** The record of the tuple under an own pair label. */\nconst recordOfLabel = (state: Readonly<HolderState>, label: string): EnactmentRecord | undefined =>\n Object.values(state.encounter.records).find((r) => r.label === label)\n\nconst withRecord = (state: HolderState, r: EnactmentRecord): HolderState =>\n ({ ...state, encounter: { ...state.encounter, records: { ...state.encounter.records, [r.own]: r } } })\n\n/** The entry a record's tuple feeds, and its relationship (by the tuple: a\n * chaining may have moved it, 6220). */\nfunction placeOf (state: Readonly<HolderState>, r: Readonly<EnactmentRecord>): { contactId: string, relationshipId: string } {\n const at = tupleByLabel(state, r.label)\n if (!at) return { contactId: idsOf(r.label).contactId, relationshipId: r.relId }\n return { contactId: entryOf(state, at.rel)?.id ?? at.tuple.entryId, relationshipId: at.rel.id }\n}\n\n/** The register with the offer's carrier nonce under `relId`, or unchanged without an offer. */\nconst carrierOf = (r: HolderState['register'], relId: string, carrier: CarrierOfferInput | undefined): HolderState['register'] =>\n carrier === undefined ? r : withCarrierNonce(r, relId, carrier.nonce)\n\nconst sealWith = (ctx: PrepareCtx, doc: Json, keyAgreement: string) =>\n seal(doc, keyAgreement, { ephSeed: ctx.entropy.bytes('seal.eph', 32), nonce: ctx.entropy.bytes('seal.nonce', 12) }, ctx.crypto.subtle)\n\nconst signer = (ctx: PrepareCtx, label: string) => (b: Uint8Array) => ctx.keys.sign(label, b)\n\n/** The display name a card carries: the input's, else the own profile's, at most 200 characters (6090). */\nconst nameFor = (state: Readonly<HolderState>, name: unknown): string | undefined => {\n const n = typeof name === 'string' ? name : (state.profile.body as { name?: unknown } | null)?.name\n return typeof n === 'string' && n.length ? [...n].slice(0, 200).join('') : undefined\n}\n\n/** The carrier offer's own checks, before anything is signed: at least\n * one hint, each a string (else card-invalid without a ref: an empty offer\n * announces nothing, a card without hints needs no offer); the bounds of\n * 6090 (at most eight, each at most 512 characters); then N's form (32\n * bytes, canonical base64url). null where there is no offer or it passes. */\nfunction offerRefusal (carrier: unknown): Refusal | null {\n if (carrier === undefined) return null\n const c = carrier as { nonce?: unknown, deliveryHints?: unknown } | null\n const h = c?.deliveryHints\n // an offer announces its carrier: no hint (a card without hints is a card\n // without an offer, 6080) or a hint that is no string is no offer\n if (!Array.isArray(h) || h.length < 1 || !h.every((x) => typeof x === 'string')) return no('card-invalid')\n if (h.length > 8 || !h.every((x) => [...x].length <= 512)) return no('card-invalid', 'RLTP-ENC-6090')\n const n = c?.nonce\n if (typeof n !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(n) || b64uOf(fromB64u(n)) !== n) return no('carrier-nonce-invalid')\n return null\n}\n\n/** N is fresh (Identity §7a.3): no carrier or pair nonce of the register, and not this act's pair nonce. */\nconst nonceStale = (state: Readonly<HolderState>, carrier: CarrierOfferInput | undefined, pairNonce: string): boolean =>\n carrier !== undefined && (carrier.nonce === pairNonce || carrierNonceHeld(state.register, carrier.nonce))\n\n/** A fresh pair label from 32 fresh nonce bytes (Identity 6.1, Encounter 4.4). */\nasync function freshLabel (ctx: PrepareCtx): Promise<{ label: string, nonce: string }> {\n const n = ctx.entropy.bytes('founding.nonce', 32)\n return { label: 'pair/' + await digestBytes(n, ctx.crypto.subtle), nonce: b64uOf(n) }\n}\n\n// ── show ───────────────────────────────────────────────────────────────\n\ntype ShowPrep = Refusal | { label: string, nonce: string, rkid: string, value: string, card: Json }\n\nconst showDef: CommandDef<ShowInput, ShowPrep> = {\n human: true,\n async prepare (ctx, input) {\n const offer = offerRefusal(input?.carrier)\n if (offer) return offer\n const { label, nonce } = await freshLabel(ctx)\n const own = await ctx.keys.anchorOf(label)\n const value = challengeOf(ctx.entropy.bytes('challenge', 17))\n const at = iso(ctx.when)\n const name = nameFor(ctx.snapshot, input?.name)\n const hints = input?.carrier !== undefined ? { deliveryHints: input.carrier.deliveryHints } : {}\n const body = cardBody(own, { ...(name !== undefined ? { name } : {}), ...hints, challenge: { value, issuedAt: at } })\n const card = await diSignWith(own.anchor, signer(ctx, label), body as unknown as Record<string, Json>, at, ctx.crypto.subtle) as unknown as Json\n return { label, nonce, rkid: own.keyAgreement, value, card }\n },\n apply (state, prepared, input, when) {\n const p = prepared.value\n if (isRefusal(p)) return p\n if (nonceStale(state, input?.carrier, p.nonce)) return no('carrier-nonce-invalid')\n // fresh-always (4.4, 4150) and single use (5140): fresh entropy never\n // repeats; a repeat is a broken entropy source, not a human's refusal\n if (state.register.labels.includes(p.label) || tupleByLabel(state, p.label)) throw new Error(`encounter.show: the pair label ${p.label} is not fresh`)\n if (resolve(state, p.value, when) !== 'unknown' || Object.hasOwn(state.encounter.challenges, p.value)) throw new Error('encounter.show: the challenge value is not fresh')\n return {\n state: {\n ...state,\n // 4110: the label in the register before the card is displayed;\n // the carrier nonce beside it, under the relationship the card opens\n register: carrierOf(withPairNonce(state.register, p.label, p.nonce), idsOf(p.label).relId, input?.carrier),\n addresses: { ...state.addresses, keys: { ...state.addresses.keys, [p.rkid]: { label: p.label, lastShown: when } } },\n encounter: { ...state.encounter, challenges: { ...state.encounter.challenges, [p.value]: { value: p.value, tCh: when, label: p.label, card: p.card as JsonObject } } },\n },\n events: [{ type: 'encounter.shown', challenge: p.value, card: p.card as JsonObject }],\n }\n },\n}\n\n// ── scan ───────────────────────────────────────────────────────────────\n\ntype ScanPrep =\n | Refusal\n | {\n peer: Card, label: string, nonce: string, rkid: string, own: string, bind: string, threadId: string,\n credential: Json, credDigest: string, sentCard: Json, doc: { digest: string, envelope: OutboundDraft['envelope'] },\n }\n\nconst scanDef: CommandDef<ScanInput, ScanPrep> = {\n human: true,\n async prepare (ctx, input) {\n const peer = input?.card as Card\n if ((await cardOk(peer, ctx.crypto.subtle)) !== null) return no('card-invalid', 'RLTP-ENC-6010')\n // a displayed card carries neither sentTo nor boundTo (6070)\n if (peer.sentTo !== undefined || peer.boundTo !== undefined) return no('card-invalid', 'RLTP-ENC-6070')\n const offer = offerRefusal(input?.carrier)\n if (offer) return offer\n const S = ctx.crypto.subtle\n const { label, nonce } = await freshLabel(ctx)\n const me = await ctx.keys.anchorOf(label)\n // c_A: fresh, created now, never the displayed value (5150, 5160)\n let own = challengeOf(ctx.entropy.bytes('challenge', 17))\n for (let i = 0; own === peer.challenge.value && i < 4; i++) own = challengeOf(ctx.entropy.bytes('challenge', 17))\n if (own === peer.challenge.value) throw new Error('encounter.scan: no fresh challenge distinct from the displayed one')\n const bind = await digestDoc({ ceremony: CEREMONY, challenges: [own, peer.challenge.value].sort() }, S)\n const at = iso(ctx.when)\n const sign = signer(ctx, label)\n const credential = await diSignWith(me.anchor, sign, credentialBody(me.anchor, peer.anchor, CEREMONY, peer.challenge.value, bind, at), at, S) as unknown as Json\n const name = nameFor(ctx.snapshot, input?.name)\n const hints = input?.carrier !== undefined ? { deliveryHints: input.carrier.deliveryHints } : {}\n const sent = cardBody(me, { ...(name !== undefined ? { name } : {}), ...hints, challenge: { value: own, issuedAt: at }, sentTo: peer.anchor, boundTo: peer.challenge.value })\n const sentCard = await diSignWith(me.anchor, sign, sent as unknown as Record<string, Json>, at, S) as unknown as Json\n const threadId = ctx.entropy.id('thread.id')\n const doc = { id: ctx.entropy.id('doc.id'), type: BUNDLE_TYPE, issuer: me.anchor, recipient: peer.anchor, threadId, issuedAt: at, payload: { card: sentCard, credential } }\n return {\n peer, label, nonce, rkid: me.keyAgreement, own, bind, threadId, credential, credDigest: await digestDoc(credential, S), sentCard,\n doc: { digest: await digestDoc(doc, S), envelope: await sealWith(ctx, doc as unknown as Json, peer.keyAgreement) },\n }\n },\n apply (state, prepared, input, when) {\n const p = prepared.value\n if (isRefusal(p)) return p\n if (nonceStale(state, input?.carrier, p.nonce)) return no('carrier-nonce-invalid')\n const peerValue = p.peer.challenge.value as string\n // 5.3 single use from the scanner's side: a displayed value already in\n // one of the own records never enters a second enactment (5170)\n if (challengeUsed(state, peerValue)) return no('already-scanned', 'RLTP-ENC-5170')\n if (state.register.labels.includes(p.label) || tupleByLabel(state, p.label)) throw new Error(`encounter.scan: the pair label ${p.label} is not fresh`)\n if (resolve(state, p.own, when) !== 'unknown') throw new Error('encounter.scan: the own challenge is not fresh')\n if (threadInUse(state, p.threadId)) throw new Error('encounter.scan: the thread is not fresh')\n // the credential binds c_B: issued only inside its window (5.6 step 6)\n if (!issuanceOpen(Date.parse(p.peer.challenge.issuedAt), when)) return no('stale-issuance', 'RLTP-ENC-5530')\n const ids = idsOf(p.label)\n const opened = openTuple(state, {\n relId: ids.relId, contactId: ids.contactId, ownPairLabel: p.label, counterpartAnchor: p.peer.anchor,\n counterpartKeyAgreement: p.peer.keyAgreement, provenance: { kind: 'ceremony' }, nonce: p.nonce,\n }, p.rkid, when)\n const record: EnactmentRecord = {\n ceremony: CEREMONY, own: p.own, tCh: when, peer: peerValue, counterpart: p.peer.anchor, card: p.peer as JsonObject, bind: p.bind,\n at: when, label: p.label, relId: ids.relId, role: 'scanner', out: { digest: p.credDigest, credential: p.credential as JsonObject }, in: null,\n thread: p.threadId, bundleDigest: p.doc.digest, threads: {}, sentCard: p.sentCard as JsonObject | null, counterPending: false,\n }\n return {\n state: withRecord({ ...opened.state, register: carrierOf(opened.state.register, ids.relId, input?.carrier) }, record),\n outbound: [{\n digest: p.doc.digest, envelope: p.doc.envelope, type: BUNDLE_TYPE, threadId: p.threadId,\n recipient: { contactId: ids.contactId, rkid: p.rkid, keyAgreement: p.peer.keyAgreement },\n }],\n events: [\n ...(opened.events ?? []),\n { type: 'encounter.recorded', contactId: ids.contactId, relationshipId: ids.relId, role: 'scanner' },\n { type: 'encounter.scanned', contactId: ids.contactId, card: p.sentCard as JsonObject },\n ],\n duties: opened.duties,\n }\n },\n}\n\n// ── the optical leg: capture a sent card (5.8, 5710) ───────────────────\n\ntype CapturePrep = Refusal | { card: Card, label: string, bind: string }\n\nconst captureDef: CommandDef<CaptureInput, CapturePrep> = {\n human: true,\n async prepare (ctx, input) {\n const card = input?.card as Card\n if ((await cardOk(card, ctx.crypto.subtle)) !== null) return no('card-invalid', 'RLTP-ENC-6010')\n if (typeof card.sentTo !== 'string' || typeof card.boundTo !== 'string') return no('card-invalid', 'RLTP-ENC-6030')\n if (card.challenge.value === card.boundTo) return no('card-invalid', 'RLTP-ENC-5160')\n // sentTo = the own anchor that displayed boundTo (6050, 4.4)\n const s = ctx.snapshot.encounter\n const label = Object.hasOwn(s.records, card.boundTo) ? s.records[card.boundTo].label\n : Object.hasOwn(s.challenges, card.boundTo) ? s.challenges[card.boundTo].label : null\n if (label !== null && (await ctx.keys.anchorOf(label)).anchor !== card.sentTo) return no('card-invalid', 'RLTP-ENC-6050')\n return { card, label: label ?? '', bind: await digestDoc({ ceremony: CEREMONY, challenges: [card.boundTo, card.challenge.value].sort() }, ctx.crypto.subtle) }\n },\n apply (state, prepared, _input, when) {\n const p = prepared.value\n if (isRefusal(p)) return p\n const { card } = p\n const st = resolve(state, card.boundTo, when)\n if (st === 'unknown') {\n const latch = latchOf(state, card.boundTo, when)\n return { ...no('gate-expired', 'RLTP-ENC-5460'), ...(latch ? { latch } : {}) }\n }\n if (st === 'recorded') {\n // the taxonomy of 5.5 (5430–5450)\n const r = state.encounter.records[card.boundTo]\n if (r.counterpart !== card.anchor) return no('consumed-challenge', 'RLTP-ENC-5440')\n if (jcs(r.card) !== jcs(card)) return no('card-mismatch', 'RLTP-ENC-5450')\n return { state: state as HolderState }\n }\n const ch = state.encounter.challenges[card.boundTo]\n if (challengeUsed(state, card.challenge.value)) return no('consumed-challenge', 'RLTP-ENC-5170')\n if (!futureOk(ch.tCh, when)) return no('gate-future', 'RLTP-ENC-5390')\n return recordCreating(state, { label: ch.label, own: ch.value, tCh: ch.tCh, card, bind: p.bind, rkid: rkidOf(state, ch.label), when, in: null, thread: null, digest: null })\n },\n}\n\n/** The own key-agreement id a label derives under, from `addresses`. */\nfunction rkidOf (state: Readonly<HolderState>, label: string): string {\n for (const [rkid, k] of Object.entries(state.addresses.keys)) if (k.label === label) return rkid\n throw new Error(`encounter: no address key for ${label}`)\n}\n\n/** The displayer's record-creating effect (5.5, 5650, 5710): the record,\n * the fresh tuple, the challenge superseded (5220), the confirm prompt. */\nfunction recordCreating (state: Readonly<HolderState>, x: {\n label: string, own: string, tCh: Millis, card: Card, bind: string, rkid: string, when: Millis,\n in: { digest: string, credential: Json } | null, thread: string | null, digest: string | null,\n}): Applied {\n const ids = idsOf(x.label)\n const nonce = Object.hasOwn(state.register.pairNonces, x.label) ? state.register.pairNonces[x.label] : undefined\n const opened = openTuple(state, {\n relId: ids.relId, contactId: ids.contactId, ownPairLabel: x.label, counterpartAnchor: x.card.anchor,\n counterpartKeyAgreement: x.card.keyAgreement, provenance: { kind: 'ceremony' }, ...(nonce !== undefined ? { nonce } : {}),\n }, x.rkid, x.when)\n const record: EnactmentRecord = {\n ceremony: CEREMONY, own: x.own, tCh: x.tCh, peer: x.card.challenge.value, counterpart: x.card.anchor, card: x.card as JsonObject, bind: x.bind,\n at: x.when, label: x.label, relId: ids.relId, role: 'displayer', out: null, in: x.in as HeldCredential | null, thread: x.thread, bundleDigest: x.digest,\n threads: {}, sentCard: null, counterPending: false,\n }\n const challenges = { ...opened.state.encounter.challenges }\n delete challenges[x.own]\n const prompt: Prompt = {\n id: confirmPromptId(x.own), kind: 'encounter-confirm', contactId: ids.contactId, openedAt: x.when,\n // the counter credential binds c_A: acceptable only inside its window (5.6 step 6)\n expiresAt: issuanceEnd(Date.parse(x.card.challenge.issuedAt)),\n }\n const next = withRecord({ ...opened.state, encounter: { ...opened.state.encounter, challenges } }, record)\n return {\n state: { ...next, prompts: { ...next.prompts, [prompt.id]: prompt } },\n events: [\n ...(opened.events ?? []),\n { type: 'encounter.recorded', contactId: ids.contactId, relationshipId: ids.relId, role: 'displayer' },\n ...(x.in ? [{ type: 'encounter.accepted', contactId: ids.contactId, relationshipId: ids.relId, mutual: false } as EventDraft] : []),\n { type: 'prompt.opened', promptId: prompt.id, kind: 'encounter-confirm' },\n ],\n duties: opened.duties,\n }\n}\n\n// ── the counter-step (5.8 step 4, 5750–5780) ───────────────────────────\n\ninterface CounterDoc { digest: string, envelope: OutboundDraft['envelope'], threadId: string }\ntype CounterPrep = Refusal | { own: string, credential: Json, digest: string, doc: CounterDoc | null }\n\n/** The counter-step's delivery document in the bundle's thread (4.3, 5760). */\nasync function counterDoc (ctx: PrepareCtx, r: Readonly<EnactmentRecord>, issuer: string, credential: Json, threadId: string): Promise<CounterDoc> {\n const doc = {\n id: ctx.entropy.id('doc.id'), type: DELIVERY_TYPE, issuer, recipient: r.counterpart, threadId, issuedAt: iso(ctx.when),\n ceremony: { step: 'counter', enactment: r.bind }, payload: { credential },\n }\n return { digest: await digestDoc(doc, ctx.crypto.subtle), envelope: await sealWith(ctx, doc as unknown as Json, (r.card as Card).keyAgreement), threadId }\n}\n\n/** The displayer's record of a contact the counter-step issues on: the\n * newest whose own credential is not issued. */\nfunction counterRecord (state: Readonly<HolderState>, contactId: string): EnactmentRecord | Refusal {\n const c = findContact(state, contactId)\n if (!c) return no('unknown-contact')\n const ids = new Set([c.id, ...c.aliases])\n const mine = Object.values(state.encounter.records).filter((r) => r.role === 'displayer' && ids.has(placeOf(state, r).contactId))\n if (!mine.length) return no('no-record')\n const open = mine.filter((r) => r.out === null).sort((a, b) => b.at - a.at)\n return open.length ? open[0] : no('already-issued')\n}\n\nasync function prepareCounter (ctx: PrepareCtx, r: Readonly<EnactmentRecord>): Promise<CounterPrep> {\n const S = ctx.crypto.subtle\n const me = await ctx.keys.anchorOf(r.label)\n const at = iso(ctx.when)\n // the subject's challenge is c_A, the record's peer value (5320)\n const credential = await diSignWith(me.anchor, signer(ctx, r.label), credentialBody(me.anchor, r.counterpart, CEREMONY, r.peer, r.bind, at), at, S) as unknown as Json\n return { own: r.own, credential, digest: await digestDoc(credential, S), doc: r.thread !== null ? await counterDoc(ctx, r, me.anchor, credential, r.thread) : null }\n}\n\n/** The counter-step's effect: the own credential committed (5770), its\n * document out where the bundle's thread is known, else pending (5780);\n * the confirm prompt of the record closes. */\nfunction applyCounter (state: Readonly<HolderState>, p: CounterPrep, when: Millis, closePrompt: boolean): Applied | Refusal {\n if (isRefusal(p)) return p\n const r = state.encounter.records[p.own]\n if (!r || r.role !== 'displayer') return no('no-record')\n if (r.out !== null) return no('already-issued')\n const at = tupleByLabel(state, r.label)\n if (!at || at.tuple.deactivated) return no('tuple-deactivated')\n if (!issuanceOpen(Date.parse((r.card as Card).challenge.issuedAt), when)) return no('stale-issuance', 'RLTP-ENC-5530')\n if ((p.doc === null) !== (r.thread === null)) throw new Error('encounter.counter: prepared on another thread state')\n const place = placeOf(state, r)\n let next = withRecord(state as HolderState, { ...r, out: { digest: p.digest, credential: p.credential as JsonObject }, counterPending: p.doc === null })\n const events: EventDraft[] = []\n const pid = confirmPromptId(r.own)\n if (closePrompt && Object.hasOwn(next.prompts, pid)) {\n const prompts = { ...next.prompts }\n delete prompts[pid]\n next = { ...next, prompts }\n events.push({ type: 'prompt.decided', promptId: pid, kind: 'encounter-confirm', choice: 'accept' })\n }\n return {\n state: next,\n outbound: p.doc ? [{ digest: p.doc.digest, envelope: p.doc.envelope, type: DELIVERY_TYPE, threadId: p.doc.threadId, recipient: { contactId: place.contactId, rkid: at.tuple.rkid, keyAgreement: at.tuple.counterpartKeyAgreement } }] : [],\n events,\n }\n}\n\nconst counterDef: CommandDef<CounterInput, CounterPrep> = {\n human: true,\n async prepare (ctx, input) {\n const r = counterRecord(ctx.snapshot, input?.contactId)\n return isRefusal(r) ? r : prepareCounter(ctx, r)\n },\n apply: (state, prepared, _input, when) => applyCounter(state, prepared.value, when, true),\n}\n\n/** encounter-confirm: accept issues the counter-step; decline only closes. */\nconst confirmDecision: DecisionDef<CounterPrep | null> = {\n async prepare (ctx, prompt, choice) {\n if (choice !== 'accept') return null\n const r = ctx.snapshot.encounter.records[prompt.id.slice('encounter:'.length)]\n return r ? prepareCounter(ctx, r) : no('no-record')\n },\n apply (state, prompt, choice, when, prepared) {\n if (choice === 'decline') return { state: state as HolderState }\n // the prompts module closes the prompt and announces the decision\n return applyCounter(state, prepared.value ?? no('no-record'), when, false)\n },\n}\n\n// ── encounter-bundle/0.1 (Delivery 4.1) ────────────────────────────────\n\ninterface BundlePayload { card: Card, credential: Card }\ninterface BundlePrep { bind: string, credDigest: string, counter: CounterDoc | null, st: 'open' | 'recorded' | 'unknown' }\n\n/** Delivery 4.1 checks 5–6 under a resolution that found the value held:\n * the ceremony (5520), the enacting anchor (4100), the enactment binding\n * (5560), the issuance window (5530); null when they pass. */\nfunction checks56 (state: Readonly<HolderState>, credential: Record<string, any>, own: string, st: 'open' | 'recorded', bind: string, rkid: string): TaskRefusal | null {\n const held = st === 'open' ? state.encounter.challenges[own] : state.encounter.records[own]\n if (credential.credentialSubject.ceremony !== CEREMONY) return refuse('validation-failed', 'RLTP-ENC-5520')\n // the enacting anchor is the one that displayed the bound challenge (4.4)\n if (held.label !== state.addresses.keys[rkid]?.label) return refuse('validation-failed', 'RLTP-ENC-4100')\n if (!sameDigest(credential.credentialSubject.enactmentBinding, bind)) return refuse('validation-failed', 'RLTP-ENC-5560')\n if (!windowOk(credential, held.tCh)) return refuse('stale-issuance', 'RLTP-ENC-5530')\n return null\n}\n\nconst bundleTask: TaskHandler<BundlePayload, BundlePrep> = {\n proof: 'absent',\n decode: (payload) => (schemaOk('payload-encounter-bundle.schema.json', payload) ? payload as BundlePayload : refuse('malformed')),\n // check 1 (structure, outer/inner, credential format), then the binding:\n // the arrival tuple where the record exists and the issuer is its\n // counterpart, else the bundle itself — it establishes the tuple (4.1),\n // its issuer = card.anchor = credential.issuer\n channel (state, doc, rkid): Channel | TaskRefusal {\n const f = bundleForm(doc)\n if (f) return refuse(f.reason)\n const at = tupleByRkid(state, rkid)\n if (at && doc.issuer === at.tuple.counterpartAnchor) return { keyAgreement: at.tuple.counterpartKeyAgreement, contactId: entryOf(state, at.rel)?.id ?? at.rel.contactId }\n // another issuer on a recorded display key: the record decides at stage\n // 9 (consumed-challenge, 4.1); its ack is never produced\n const k = state.addresses.keys[rkid]\n if (!k || !k.label.startsWith('pair/')) return refuse('validation-failed')\n return { keyAgreement: doc.payload.card.keyAgreement, contactId: idsOf(k.label).contactId }\n },\n // checks 2–4: card proof, credential proof, addressee (no state touched);\n // then check 5 the provisional resolution and, where it found the value\n // held, checks 5–6 at stage 8 (an unknown value goes to stage 9)\n async prepare (ctx, doc, arrival) {\n const { card, credential } = doc.payload\n if (!(await diVerify(card, card.anchor, ctx.crypto.subtle))) return refuse('validation-failed', 'RLTP-ENC-6020')\n const h = await credHead(credential, doc.recipient, false, ctx.crypto.subtle)\n if (h) return refuse(dispositionOf(h), errRef(h))\n const S = ctx.crypto.subtle\n const own = credential.credentialSubject.challenge as string\n const r = Object.hasOwn(ctx.snapshot.encounter.records, own) ? ctx.snapshot.encounter.records[own] : undefined\n // a counter-step issued on the optical leg waited for this thread (5780)\n const counter = r && r.counterPending && r.out && r.counterpart === card.anchor\n ? await counterDoc(ctx, r, doc.recipient, r.out.credential, r.thread ?? doc.threadId) : null\n const bind = await digestDoc({ ceremony: CEREMONY, challenges: [own, card.challenge.value].sort() }, S)\n const st = resolve(ctx.snapshot, own, ctx.when)\n if (st !== 'unknown') {\n const bad = checks56(ctx.snapshot, credential, own, st, bind, arrival.rkid)\n if (bad) return bad\n }\n return { bind, credDigest: await digestDoc(credential, S), counter, st }\n },\n // the authoritative resolution and the branch it selects (4.1); checks\n // 5–6 again only where it differs from the provisional one\n apply (state, prepared, doc, arrival) {\n const p = prepared.value\n const { card, credential } = doc.payload\n const when = arrival.when\n const own = credential.credentialSubject.challenge as string\n const st = resolve(state, own, when)\n if (st === 'unknown') {\n const latch = latchOf(state, own, when)\n return { ...refuse('validation-failed', 'RLTP-ENC-5240'), ...(latch ? { latch } : {}) }\n }\n const held = st === 'open' ? state.encounter.challenges[own] : state.encounter.records[own]\n if (st !== p.st) {\n const bad = checks56(state, credential, own, st, p.bind, arrival.rkid)\n if (bad) return bad\n }\n if (threadInUse(state, doc.threadId) && !sameOpeningBundle(state, card.anchor, doc.threadId, arrival.digest)) return refuse('validation-failed')\n if (st === 'open') {\n if (challengeUsed(state, card.challenge.value)) return refuse('validation-failed', 'RLTP-ENC-5170')\n if (!futureOk(held.tCh, when)) return refuse('gate-future', 'RLTP-ENC-5390')\n return recordCreating(state, {\n label: held.label, own, tCh: held.tCh, card, bind: p.bind, rkid: arrival.rkid, when,\n in: { digest: p.credDigest, credential: credential as Json }, thread: doc.threadId, digest: arrival.digest,\n })\n }\n // recorded: the record decides (4.1)\n const r = held as EnactmentRecord\n if (r.counterpart !== card.anchor) return refuse('consumed-challenge', 'RLTP-ENC-5440')\n if (jcs(r.card) !== jcs(card)) return refuse('validation-failed', 'RLTP-ENC-5730')\n const e = acceptTail(credential, facts(r), 'bundle')\n if (e) return refuse(dispositionOf(e), errRef(e))\n if (r.in && !sameDigest(r.in.digest, p.credDigest)) return refuse('validation-failed', 'RLTP-ENC-5570')\n // the record-aware effect: no gate, no second record (5740)\n const thread = r.thread ?? doc.threadId\n const next: EnactmentRecord = {\n ...r,\n in: r.in ?? { digest: p.credDigest, credential: credential as JsonObject },\n thread,\n bundleDigest: r.bundleDigest ?? arrival.digest,\n threads: thread === doc.threadId ? r.threads : { ...r.threads, [doc.threadId]: arrival.digest },\n counterPending: r.counterPending && !p.counter,\n }\n const place = placeOf(state, r)\n const at = tupleByLabel(state, r.label)\n const events: EventDraft[] = r.in ? [] : [{ type: 'encounter.accepted', contactId: place.contactId, relationshipId: place.relationshipId, mutual: r.out !== null }]\n const outbound: OutboundDraft[] = p.counter && at\n ? [{ digest: p.counter.digest, envelope: p.counter.envelope, type: DELIVERY_TYPE, threadId: p.counter.threadId, recipient: { contactId: place.contactId, rkid: at.tuple.rkid, keyAgreement: at.tuple.counterpartKeyAgreement } }]\n : []\n return { state: withRecord(state as HolderState, next), events, outbound }\n },\n}\n\nconst errRef = (e: CredError): string => ({\n ERR_VERSION: 'RLTP-ENC-5480', ERR_SIG: 'RLTP-ENC-5490', ERR_ADDRESSEE: 'RLTP-ENC-5500', ERR_NO_RECORD: 'RLTP-ENC-5510',\n ERR_CEREMONY: 'RLTP-ENC-5520', ERR_STALE_ISSUANCE: 'RLTP-ENC-5530', ERR_BINDING: 'RLTP-ENC-5560', ERR_CONFLICT: 'RLTP-ENC-5570',\n} as const)[e]\n\n// ── encounter-credential-delivery/0.1 (Delivery 4.3) ───────────────────\n\ninterface DeliveryPayload { credential: Card }\ninterface DeliveryPrep { verdict: CredError | null, credDigest: string }\n\nconst deliveryTask: TaskHandler<DeliveryPayload, DeliveryPrep> = {\n proof: 'absent',\n // bound to the enactment record on its tuple (below): a late counter\n // credential is taken against the record even where a chaining has\n // deactivated that tuple since (4.2; encounter review 2/14); no new\n // issuance goes out on it\n pinned: true,\n decode: (payload) => (schemaOk('payload-encounter-credential-delivery.schema.json', payload) ? payload as DeliveryPayload : refuse('malformed')),\n async prepare (ctx, doc, arrival) {\n const f = deliveryForm(doc)\n if (f) return refuse('validation-failed', 'RLTP-ENC-5760')\n // the relationship channel to the issuer: a record on the arrival tuple\n const at = tupleByRkid(ctx.snapshot, arrival.rkid)\n if (!at || !recordOfLabel(ctx.snapshot, at.tuple.ownPairLabel)) return refuse('validation-failed')\n // 5.6 steps 1–3, no state touched; the rest runs in the transaction\n return { verdict: await credHead(doc.payload.credential, doc.recipient, true, ctx.crypto.subtle), credDigest: await digestDoc(doc.payload.credential, ctx.crypto.subtle) }\n },\n apply (state, prepared, doc, arrival) {\n const at = tupleByRkid(state, arrival.rkid)!\n const r = recordOfLabel(state, at.tuple.ownPairLabel)!\n // the thread rule of 4.3: counter in the bundle's thread, deliver outside it\n const step = (doc.ceremony as { step?: unknown } | undefined)?.step\n const inBundle = r.thread !== null && doc.threadId === r.thread\n if (step === 'counter' && !inBundle) return refuse('validation-failed', 'RLTP-ENC-5760')\n if (step === 'deliver' && inBundle) return refuse('validation-failed')\n if (!inBundle && threadInUse(state, doc.threadId)) return refuse('validation-failed')\n // the defined effect: buffering (the thread reserved); acceptance (5.6)\n // in the same transaction, its outcome never signaled (7.4)\n const cred = doc.payload.credential\n const p = prepared.value\n const bound = Object.hasOwn(state.encounter.records, cred.credentialSubject.challenge) ? state.encounter.records[cred.credentialSubject.challenge] : undefined\n let e: CredError | null = p.verdict ?? acceptTail(cred, bound && bound.label === r.label ? facts(bound) : undefined, 'credential')\n if (!e && r.in && !sameDigest(r.in.digest, p.credDigest)) e = 'ERR_CONFLICT'\n let next: EnactmentRecord = inBundle ? r : { ...r, threads: { ...r.threads, [doc.threadId]: arrival.digest } }\n const events: EventDraft[] = []\n if (!e && !r.in) {\n next = { ...next, in: { digest: p.credDigest, credential: cred as JsonObject } }\n const place = placeOf(state, r)\n events.push({ type: 'encounter.accepted', contactId: place.contactId, relationshipId: place.relationshipId, mutual: r.out !== null })\n }\n return { state: next === r ? state as HolderState : withRecord(state as HolderState, next), events }\n },\n}\n\n// ── retention: the aging latch's end (5200–5230) ───────────────────────\n\nfunction retainChallenges (state: Readonly<HolderState>, when: Millis): HolderState {\n const aged = Object.values(state.encounter.challenges).filter((c) => challengeAged(c.tCh, when))\n if (!aged.length) return state as HolderState\n const challenges = { ...state.encounter.challenges }\n for (const c of aged) delete challenges[c.value]\n return { ...state, encounter: { ...state.encounter, challenges } }\n}\n\n/** When retainChallenges drops an aged challenge (5.3): the first whole\n * second past its maximum age and the skew (the timer contract, engine.ts). */\nconst challengeDeadlines = (state: Readonly<HolderState>): Millis[] =>\n Object.values(state.encounter.challenges).map((c) => (Math.floor(c.tCh / 1000) + (CHALLENGE_MAX_AGE + SKEW_TOLERANCE) / 1000 + 1) * 1000)\n\n/** The encounter module createHolder registers. */\nexport function encounterModule (): HolderModule {\n return Object.freeze({\n name: 'encounter',\n commands: Object.freeze({\n [ENCOUNTER_COMMANDS.show]: showDef,\n [ENCOUNTER_COMMANDS.scan]: scanDef,\n [ENCOUNTER_COMMANDS.capture]: captureDef,\n [ENCOUNTER_COMMANDS.counter]: counterDef,\n }),\n tasks: Object.freeze({ [BUNDLE_TYPE]: bundleTask, [DELIVERY_TYPE]: deliveryTask }),\n decisions: Object.freeze({ 'encounter-confirm': confirmDecision }),\n retain: retainChallenges,\n deadlines: challengeDeadlines,\n })\n}\n"]}
@@ -34,11 +34,13 @@ export interface Challenge {
34
34
  */
35
35
  export type CardFields = {
36
36
  name?: string;
37
+ deliveryHints?: string[];
37
38
  challenge?: Challenge;
38
39
  sentTo?: undefined;
39
40
  boundTo?: undefined;
40
41
  } | {
41
42
  name?: string;
43
+ deliveryHints?: string[];
42
44
  challenge?: Challenge;
43
45
  sentTo: string;
44
46
  boundTo: string;
@@ -49,6 +51,8 @@ export interface CardBody {
49
51
  anchor: string;
50
52
  keyAgreement: string;
51
53
  name?: string;
54
+ /** Encounter 6080, 6090: opaque strings whose form the carrier profile that names them defines */
55
+ deliveryHints?: string[];
52
56
  challenge?: Challenge;
53
57
  sentTo?: string;
54
58
  boundTo?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"encounter.d.ts","sourceRoot":"","sources":["../src/encounter.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAiB,GAAG,EAA6B,MAAM,WAAW,CAAA;AAE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,EAAE,GAAG,EAAE,YAAY,UAAO,GAAG,SAAS,GAAG,IAAI,CAU5E;AAED,mEAAmE;AACnE,wBAAsB,QAAQ,CAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,UAAO,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAMrI;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAI3D;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAAG,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAEjG;;yCAEyC;AACzC,wBAAgB,UAAU,CAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAQrH;AAED;mCACmC;AACnC,eAAO,MAAM,aAAa,GAAI,GAAG,SAAS,KAAG,gBAAgB,GAAG,mBAA4F,CAAA;AAE5J;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAE,GAAG,EAAE,GAAG,GAAG;IAAE,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAc5G;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAOrD"}
package/dist/encounter.js CHANGED
@@ -46,7 +46,7 @@ const challengeOfUnchecked = (bytes17) => b64uOf(bytes17).slice(0, 22);
46
46
  // cards carry no @context (the proof carries none either — W3C-true)
47
47
  export const signCard = (ctx, body, created) => diSign(ctx, body, created);
48
48
  export function cardBody(ctx, fields = {}) {
49
- const { name, challenge, sentTo, boundTo } = fields;
49
+ const { name, deliveryHints, challenge, sentTo, boundTo } = fields;
50
50
  // runtime guard for JS callers the union cannot reach: the sent-card
51
51
  // profile is atomic — half of it is not a card of either profile
52
52
  if ((sentTo === undefined) !== (boundTo === undefined))
@@ -54,6 +54,8 @@ export function cardBody(ctx, fields = {}) {
54
54
  const b = { version: CARD_VERSION, anchor: ctx.anchor, keyAgreement: ctx.keyAgreement };
55
55
  if (name !== undefined)
56
56
  b.name = name;
57
+ if (deliveryHints !== undefined)
58
+ b.deliveryHints = [...deliveryHints];
57
59
  if (challenge !== undefined)
58
60
  b.challenge = challenge;
59
61
  if (sentTo !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"encounter.js","sourceRoot":"","sources":["../src/encounter.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,kEAAkE;AAClE,wEAAwE;AACxE,0CAA0C;AAC1C,EAAE;AACF,kEAAkE;AAClE,uEAAuE;AACvE,mCAAmC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAElF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,CAAA;AAEd,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,qBAAqB,CAAA;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAA;AAC5C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAA;AAC3D;gEACgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,iDAAiD,CAAA;AAC5E,oFAAoF;AACpF,MAAM,CAAC,MAAM,YAAY,GAAsB,MAAM,CAAC,MAAM,C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OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// encounter — the Encounter Layer: how two people record that they met.\n//\n// The one registered ceremony (encounter-scan), the contact card each\n// side displays, the challenge that makes an enactment fresh, the\n// enactment binding both sides compute independently, and the encounter\n// credential each issues about the other.\n//\n// The binding is what makes the pair an enactment rather than two\n// unrelated claims: both sides derive it from the same two challenges,\n// sorted, so neither can steer it.\nimport { digestDoc, diSign, diVerify, edRawOfAnchor, xRawOfMk } from './crypto.js'\nimport type { Signer } from './crypto.js'\nimport { b64uOf, calOK, iso, makeValidator, sameDigest } from './core.js'\nimport { SCHEMAS } from './schemas.js'\nexport { iso }\n\n// ── wire builders (Encounter 0.31: card 0.25, credential 0.26) ─────────\nexport const CEREMONY = 'encounter-scan@0.25'\nexport const CARD_VERSION = 'rltp-card/0.25'\n/** The credential form this library issues (Encounter 7.2). */\nexport const CRED_FORMAT = 'rltp-encounter-credential/0.26'\n/** The DTG credential context, DTG Credentials WD 0.6.0 (exact bytes; the\n * document is pinned by SHA-256 in contexts/dtg-v1.jsonld). */\nexport const DTG_CONTEXT = 'https://registry.trustoverip.org/dtg/context/v1'\n/** The pinned context set of the 0.26 credential (Encounter 2.3, RLTP-ENC-2250). */\nexport const CRED_CONTEXT: readonly string[] = Object.freeze(['https://www.w3.org/ns/credentials/v2', DTG_CONTEXT, 'https://real-life.org/rltp/v1'])\n/** Every credential format a verifier of this version knows, with its schema\n * file. A held 0.25 credential stays valid under its own format (7.3, 12). */\nexport const CRED_FORMATS: Readonly<Record<string, string>> = Object.freeze({\n 'rltp-encounter-credential/0.26': 'encounter-credential-0.26.schema.json',\n 'rltp-encounter-credential/0.25': 'encounter-credential-0.25.schema.json',\n})\n/** The schema file a credential is validated against, by the format it\n * names — null for an unknown format (ERR_VERSION at 5.6 step 1). */\nexport const credentialSchemaOf = (cred: unknown): string | null => {\n const f = (cred as { credentialSubject?: { format?: unknown } } | null)?.credentialSubject?.format\n return typeof f === 'string' && Object.prototype.hasOwnProperty.call(CRED_FORMATS, f) ? CRED_FORMATS[f] : null\n}\nexport const binding = (ceremony: string, c1: string, c2: string): Promise<string> => digestDoc({ ceremony, challenges: [c1, c2].sort() })\nexport const challengeOf = (bytes17: Uint8Array): string => {\n // a producer never emits what every conformant receiver must reject:\n // the challenge is EXACTLY 17 random bytes (>= 128 bits, Encounter §5)\n if (!(bytes17 instanceof Uint8Array) || bytes17.length !== 17) throw new Error('challenge entropy must be exactly 17 bytes')\n return challengeOfUnchecked(bytes17)\n}\nconst challengeOfUnchecked = (bytes17: Uint8Array): string => b64uOf(bytes17).slice(0, 22)\n\n// cards carry no @context (the proof carries none either — W3C-true)\nexport const signCard = (ctx: Signer, body: CardBody, created: string) => diSign(ctx, body, created)\n\n/** The challenge a displayed card carries: fresh value, whole-second issue time. */\nexport interface Challenge { value: string, issuedAt: string }\n\n/**\n * The spec knows exactly two disjoint card profiles (Encounter §5):\n * a DISPLAYED card offers a challenge; a SENT card names its recipient\n * AND the challenge it answers — always both, never one (M-2, review 1:\n * the fields travel together or the card is neither profile).\n */\nexport type CardFields =\n | { name?: string, challenge?: Challenge, sentTo?: undefined, boundTo?: undefined }\n | { name?: string, challenge?: Challenge, sentTo: string, boundTo: string }\n\n/** A card body as it goes under the signature. */\nexport interface CardBody {\n version: string\n anchor: string\n keyAgreement: string\n name?: string\n challenge?: Challenge\n sentTo?: string\n boundTo?: string\n}\n\nexport function cardBody (ctx: { anchor: string, keyAgreement: string }, fields: CardFields = {}): CardBody {\n const { name, challenge, sentTo, boundTo } = fields as { name?: string, challenge?: Challenge, sentTo?: string, boundTo?: string }\n // runtime guard for JS callers the union cannot reach: the sent-card\n // profile is atomic — half of it is not a card of either profile\n if ((sentTo === undefined) !== (boundTo === undefined)) throw new Error('a sent card carries sentTo AND boundTo together (Encounter §5)')\n const b: CardBody = { version: CARD_VERSION, anchor: ctx.anchor, keyAgreement: ctx.keyAgreement }\n if (name !== undefined) b.name = name\n if (challenge !== undefined) b.challenge = challenge\n if (sentTo !== undefined) { b.sentTo = sentTo; b.boundTo = boundTo }\n return b\n}\n/** The unsigned body of a step credential (Encounter 7.2): issuer, the\n * subject, the subject's challenge and the enactment binding. */\nexport const credentialBody = (\n issuerAnchor: string, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) => ({\n '@context': [...CRED_CONTEXT],\n type: ['VerifiableCredential', 'DTGCredential', 'RelationshipCredential', 'EncounterCredential'],\n issuer: issuerAnchor,\n // the issuer is a fresh pair anchor, known to exactly one counterparty (4.4)\n issuerScope: 'pairwise',\n validFrom: whenIso,\n credentialSubject: { id: subjectAnchor, format: CRED_FORMAT, ceremony, challenge: subjectChallenge, enactmentBinding },\n})\nexport async function issueCredential (\n ctx: Signer, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) {\n return diSign(ctx, credentialBody(ctx.anchor, subjectAnchor, ceremony, subjectChallenge, enactmentBinding, whenIso), whenIso)\n}\n\n\n// ── the ceremony's pure checks (Encounter 0.31 §5–§7, Delivery 4.1/4.3) ──\n// The task types, the §9 constants, the whole-second time rules, the card\n// check, the 5.6 credential checks in their normative order, and the\n// outer/inner forms of the two carriers. State-free: what needs the\n// own-challenge state or the records is the holder's (encounter/ceremony.ts).\nconst TT = 'https://real-life.org/trust-tasks/'\n/** The scanner's sent card and step credential (Delivery 4.1). */\nexport const BUNDLE_TYPE = TT + 'encounter-bundle/0.1'\n/** The counter-step or a standalone credential delivery (Delivery 4.3). */\nexport const DELIVERY_TYPE = TT + 'encounter-credential-delivery/0.1'\n// Encounter §9 operational constants (ms)\nexport const CHALLENGE_MAX_AGE = 5 * 60_000 // PT5M\nexport const ISSUANCE_WINDOW = 24 * 3_600_000 // PT24H\nexport const SKEW_TOLERANCE = 5 * 60_000 // PT5M\n\nconst VAL = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => VAL.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\n\n/** Whole seconds (2.3). */\nconst sec = (ms: number): number => Math.floor(ms / 1000)\nconst secIso = (t: string): number => Math.floor(Date.parse(t) / 1000)\n/** 5.5's explicit future check: t_ch ≤ now + skew, whole seconds. */\nexport const futureOk = (tCh: number, now: number): boolean => sec(tCh) <= sec(now) + SKEW_TOLERANCE / 1000\n/** Is a challenge issued at tCh past its age bound at `now` (5190)? */\nexport const challengeAged = (tCh: number, now: number): boolean => sec(now) > sec(tCh) + (CHALLENGE_MAX_AGE + SKEW_TOLERANCE) / 1000\n/** The producer's mirror of 5.6 step 6: may a credential binding a\n * challenge issued at tChMs still be issued now? */\nexport const issuanceOpen = (tChMs: number, now: number): boolean => {\n const skew = SKEW_TOLERANCE / 1000\n return sec(now) >= sec(tChMs) - skew && sec(now) <= sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n}\n/** The last millisecond a credential binding a challenge issued at tChMs may carry (5.6 step 6). */\nexport const issuanceEnd = (tChMs: number): number => (sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW + SKEW_TOLERANCE) / 1000) * 1000 + 999\n\n/** Producer-side profile discipline (Delivery 3): UUID v4 ids and threads. */\nconst UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\nexport const uuidOk = (v: unknown): boolean => typeof v === 'string' && UUID_V4.test(v)\n\nexport const CARD_SCHEMA = 'contact-card-0.25.schema.json'\n/** A card for an enactment (Encounter 6): schema-valid, its version known,\n * a challenge, calendar-valid times, keys that decode, the proof under the\n * anchor. null when it passes, else the reason. */\nexport async function cardOk (card: any, subtle?: SubtleCrypto): Promise<string | null> {\n if (!schemaOk(CARD_SCHEMA, card)) return 'card fails contact-card-0.25 schema'\n if (card.version !== CARD_VERSION) return 'card version unknown'\n if (!card.challenge) return 'card without challenge (enactment use requires one)'\n if (!calOK(card.challenge.issuedAt) || !calOK(card.proof?.created)) return 'card: calendar-invalid timestamp'\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return 'card keyAgreement does not decode (x25519-pub + 32 bytes, 2.3)'\n if (!(await diVerify(card, card.anchor, subtle))) return 'card proof'\n return null\n}\n\n/** The 5.6 rejection codes. */\nexport type CredError = 'ERR_VERSION' | 'ERR_SIG' | 'ERR_ADDRESSEE' | 'ERR_NO_RECORD' | 'ERR_CEREMONY' | 'ERR_STALE_ISSUANCE' | 'ERR_BINDING' | 'ERR_CONFLICT'\n\n/** 5.6 step 1, format: a KNOWN format validated against ITS schema (0.26,\n * or a held 0.25 — 7.3, 12), ceremony and version known, calendar-valid\n * times, the digest a multihash, keys that decode (2.3). `ceremonyHere`:\n * 5.6 checks the ceremony at step 1; a bundle checks it at Delivery 4.1's\n * check 5. */\nexport function credFormat (cred: any, ceremonyHere = true): CredError | null {\n const schema = credentialSchemaOf(cred)\n if (schema === null || !schemaOk(schema, cred)) return 'ERR_VERSION'\n if (ceremonyHere && cred.credentialSubject.ceremony !== CEREMONY) return 'ERR_VERSION'\n if (!calOK(cred.validFrom) || !calOK(cred.proof?.created)) return 'ERR_VERSION'\n if (!sameDigest(cred.credentialSubject.enactmentBinding, cred.credentialSubject.enactmentBinding)) return 'ERR_VERSION'\n if (!edRawOfAnchor(cred.issuer) || !edRawOfAnchor(cred.credentialSubject.id)) return 'ERR_VERSION'\n const vm = String(cred.proof?.verificationMethod ?? ''), hash = vm.indexOf('#')\n if (hash < 0 || !edRawOfAnchor(vm.slice(0, hash)) || !edRawOfAnchor('did:key:' + vm.slice(hash + 1))) return 'ERR_VERSION'\n return null\n}\n\n/** 5.6 steps 1–3: format, signature, addressee (`localAnchor`). */\nexport async function credHead (cred: any, localAnchor: string, ceremonyHere = true, subtle?: SubtleCrypto): Promise<CredError | null> {\n const f = credFormat(cred, ceremonyHere)\n if (f) return f\n if (!(await diVerify(cred, cred.issuer, subtle))) return 'ERR_SIG'\n if (cred.credentialSubject.id !== localAnchor) return 'ERR_ADDRESSEE'\n return null\n}\n\n/** 5.6 step 6: the issuance window, whole seconds, inclusive, skew widens. */\nexport function windowOk (cred: any, tChMs: number): boolean {\n const tCh = sec(tChMs), vf = secIso(cred.validFrom), cr = secIso(cred.proof.created), skew = SKEW_TOLERANCE / 1000\n const lo = tCh - skew, hi = tCh + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n return !(vf < lo || vf > hi || cr < lo || cr > hi || cr < vf - skew)\n}\n\n/** What 5.6 steps 4–7 read of a record. */\nexport interface RecordFacts { counterpart: string, ceremony: string, tCh: number, bind: string }\n\n/** 5.6 steps 4–7 against a record, synchronous. `order`: 'credential' —\n * 5.6: record, ceremony, window, binding; 'bundle' — Delivery 4.1:\n * record, ceremony, binding, window. */\nexport function acceptTail (cred: any, rec: RecordFacts | undefined, order: 'credential' | 'bundle'): CredError | null {\n if (!rec || rec.counterpart !== cred.issuer) return 'ERR_NO_RECORD'\n if (cred.credentialSubject.ceremony !== rec.ceremony) return 'ERR_CEREMONY'\n const bindOk = sameDigest(cred.credentialSubject.enactmentBinding, rec.bind)\n if (order === 'bundle' && !bindOk) return 'ERR_BINDING'\n if (!windowOk(cred, rec.tCh)) return 'ERR_STALE_ISSUANCE'\n if (!bindOk) return 'ERR_BINDING'\n return null\n}\n\n/** Delivery 4.1/4.3: ERR_STALE_ISSUANCE is stale-issuance, every other\n * rejection validation-failed. */\nexport const dispositionOf = (e: CredError): 'stale-issuance' | 'validation-failed' => (e === 'ERR_STALE_ISSUANCE' ? 'stale-issuance' : 'validation-failed')\n\n/**\n * The bundle's context-free checks of Delivery 4.1 check 1 (stage 8,\n * after the payload schema): calendars, the outer/inner equalities, the\n * sent card's binding, a present ceremony.enactment, the card's version\n * and keys, the credential's format (its ceremony at check 5). null when\n * they pass, else the reason, with the 4.1 disposition.\n */\nexport function bundleForm (doc: any): { reason: 'validation-failed' | 'stale-issuance', why: string } | null {\n const { card, credential } = doc.payload\n const v = (why: string) => ({ reason: 'validation-failed' as const, why })\n if (!calOK(doc.issuedAt) || !calOK(card.challenge?.issuedAt) || !calOK(card.proof?.created)) return v('calendar-invalid issuedAt')\n if (doc.issuer !== card.anchor || card.anchor !== credential.issuer) return v('outer binding (issuer = card.anchor = credential.issuer)')\n if (credential.credentialSubject?.id !== doc.recipient) return v('outer binding (recipient = subject)')\n if (card.sentTo !== doc.recipient || card.boundTo !== credential.credentialSubject.challenge) return v('sent card binding (sentTo/boundTo)')\n if (card.challenge.value === card.boundTo) return v('sent challenge equals the displayed challenge (5.3)')\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, credential.credentialSubject.enactmentBinding)) return v('ceremony.enactment recomputes not')\n if (card.version !== CARD_VERSION || !card.challenge) return v('card version/challenge')\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return v('card keys do not decode')\n const f = credFormat(credential, false)\n if (f) return { reason: dispositionOf(f), why: f }\n return null\n}\n\n/** The credential delivery's outer/inner consistency (Delivery 4.3). */\nexport function deliveryForm (doc: any): string | null {\n const cred = doc.payload.credential\n if (!calOK(doc.issuedAt)) return 'calendar-invalid issuedAt'\n if (doc.issuer !== cred.issuer) return 'outer binding (issuer = credential.issuer)'\n if (cred.credentialSubject?.id !== doc.recipient) return 'outer binding (recipient = subject)'\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, cred.credentialSubject.enactmentBinding)) return 'ceremony.enactment recomputes not'\n return null\n}\n"]}
1
+ {"version":3,"file":"encounter.js","sourceRoot":"","sources":["../src/encounter.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,kEAAkE;AAClE,wEAAwE;AACxE,0CAA0C;AAC1C,EAAE;AACF,kEAAkE;AAClE,uEAAuE;AACvE,mCAAmC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAElF,OAAO,EAAE,M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AAO,IAAI,CAAA;AACb,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAE,GAAQ;IACpC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAA;IACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,2BAA2B,CAAA;IAC5D,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,4CAA4C,CAAA;IACnF,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,GAAG,CAAC,SAAS;QAAE,OAAO,qCAAqC,CAAA;IAC9F,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC;QAAE,OAAO,mCAAmC,CAAA;IACrK,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// encounter — the Encounter Layer: how two people record that they met.\n//\n// The one registered ceremony (encounter-scan), the contact card each\n// side displays, the challenge that makes an enactment fresh, the\n// enactment binding both sides compute independently, and the encounter\n// credential each issues about the other.\n//\n// The binding is what makes the pair an enactment rather than two\n// unrelated claims: both sides derive it from the same two challenges,\n// sorted, so neither can steer it.\nimport { digestDoc, diSign, diVerify, edRawOfAnchor, xRawOfMk } from './crypto.js'\nimport type { Signer } from './crypto.js'\nimport { b64uOf, calOK, iso, makeValidator, sameDigest } from './core.js'\nimport { SCHEMAS } from './schemas.js'\nexport { iso }\n\n// ── wire builders (Encounter 0.31: card 0.25, credential 0.26) ─────────\nexport const CEREMONY = 'encounter-scan@0.25'\nexport const CARD_VERSION = 'rltp-card/0.25'\n/** The credential form this library issues (Encounter 7.2). */\nexport const CRED_FORMAT = 'rltp-encounter-credential/0.26'\n/** The DTG credential context, DTG Credentials WD 0.6.0 (exact bytes; the\n * document is pinned by SHA-256 in contexts/dtg-v1.jsonld). */\nexport const DTG_CONTEXT = 'https://registry.trustoverip.org/dtg/context/v1'\n/** The pinned context set of the 0.26 credential (Encounter 2.3, RLTP-ENC-2250). */\nexport const CRED_CONTEXT: readonly string[] = Object.freeze(['https://www.w3.org/ns/credentials/v2', DTG_CONTEXT, 'https://real-life.org/rltp/v1'])\n/** Every credential format a verifier of this version knows, with its schema\n * file. A held 0.25 credential stays valid under its own format (7.3, 12). */\nexport const CRED_FORMATS: Readonly<Record<string, string>> = Object.freeze({\n 'rltp-encounter-credential/0.26': 'encounter-credential-0.26.schema.json',\n 'rltp-encounter-credential/0.25': 'encounter-credential-0.25.schema.json',\n})\n/** The schema file a credential is validated against, by the format it\n * names — null for an unknown format (ERR_VERSION at 5.6 step 1). */\nexport const credentialSchemaOf = (cred: unknown): string | null => {\n const f = (cred as { credentialSubject?: { format?: unknown } } | null)?.credentialSubject?.format\n return typeof f === 'string' && Object.prototype.hasOwnProperty.call(CRED_FORMATS, f) ? CRED_FORMATS[f] : null\n}\nexport const binding = (ceremony: string, c1: string, c2: string): Promise<string> => digestDoc({ ceremony, challenges: [c1, c2].sort() })\nexport const challengeOf = (bytes17: Uint8Array): string => {\n // a producer never emits what every conformant receiver must reject:\n // the challenge is EXACTLY 17 random bytes (>= 128 bits, Encounter §5)\n if (!(bytes17 instanceof Uint8Array) || bytes17.length !== 17) throw new Error('challenge entropy must be exactly 17 bytes')\n return challengeOfUnchecked(bytes17)\n}\nconst challengeOfUnchecked = (bytes17: Uint8Array): string => b64uOf(bytes17).slice(0, 22)\n\n// cards carry no @context (the proof carries none either — W3C-true)\nexport const signCard = (ctx: Signer, body: CardBody, created: string) => diSign(ctx, body, created)\n\n/** The challenge a displayed card carries: fresh value, whole-second issue time. */\nexport interface Challenge { value: string, issuedAt: string }\n\n/**\n * The spec knows exactly two disjoint card profiles (Encounter §5):\n * a DISPLAYED card offers a challenge; a SENT card names its recipient\n * AND the challenge it answers — always both, never one (M-2, review 1:\n * the fields travel together or the card is neither profile).\n */\nexport type CardFields =\n | { name?: string, deliveryHints?: string[], challenge?: Challenge, sentTo?: undefined, boundTo?: undefined }\n | { name?: string, deliveryHints?: string[], challenge?: Challenge, sentTo: string, boundTo: string }\n\n/** A card body as it goes under the signature. */\nexport interface CardBody {\n version: string\n anchor: string\n keyAgreement: string\n name?: string\n /** Encounter 6080, 6090: opaque strings whose form the carrier profile that names them defines */\n deliveryHints?: string[]\n challenge?: Challenge\n sentTo?: string\n boundTo?: string\n}\n\nexport function cardBody (ctx: { anchor: string, keyAgreement: string }, fields: CardFields = {}): CardBody {\n const { name, deliveryHints, challenge, sentTo, boundTo } = fields as { name?: string, deliveryHints?: string[], challenge?: Challenge, sentTo?: string, boundTo?: string }\n // runtime guard for JS callers the union cannot reach: the sent-card\n // profile is atomic — half of it is not a card of either profile\n if ((sentTo === undefined) !== (boundTo === undefined)) throw new Error('a sent card carries sentTo AND boundTo together (Encounter §5)')\n const b: CardBody = { version: CARD_VERSION, anchor: ctx.anchor, keyAgreement: ctx.keyAgreement }\n if (name !== undefined) b.name = name\n if (deliveryHints !== undefined) b.deliveryHints = [...deliveryHints]\n if (challenge !== undefined) b.challenge = challenge\n if (sentTo !== undefined) { b.sentTo = sentTo; b.boundTo = boundTo }\n return b\n}\n/** The unsigned body of a step credential (Encounter 7.2): issuer, the\n * subject, the subject's challenge and the enactment binding. */\nexport const credentialBody = (\n issuerAnchor: string, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) => ({\n '@context': [...CRED_CONTEXT],\n type: ['VerifiableCredential', 'DTGCredential', 'RelationshipCredential', 'EncounterCredential'],\n issuer: issuerAnchor,\n // the issuer is a fresh pair anchor, known to exactly one counterparty (4.4)\n issuerScope: 'pairwise',\n validFrom: whenIso,\n credentialSubject: { id: subjectAnchor, format: CRED_FORMAT, ceremony, challenge: subjectChallenge, enactmentBinding },\n})\nexport async function issueCredential (\n ctx: Signer, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) {\n return diSign(ctx, credentialBody(ctx.anchor, subjectAnchor, ceremony, subjectChallenge, enactmentBinding, whenIso), whenIso)\n}\n\n\n// ── the ceremony's pure checks (Encounter 0.31 §5–§7, Delivery 4.1/4.3) ──\n// The task types, the §9 constants, the whole-second time rules, the card\n// check, the 5.6 credential checks in their normative order, and the\n// outer/inner forms of the two carriers. State-free: what needs the\n// own-challenge state or the records is the holder's (encounter/ceremony.ts).\nconst TT = 'https://real-life.org/trust-tasks/'\n/** The scanner's sent card and step credential (Delivery 4.1). */\nexport const BUNDLE_TYPE = TT + 'encounter-bundle/0.1'\n/** The counter-step or a standalone credential delivery (Delivery 4.3). */\nexport const DELIVERY_TYPE = TT + 'encounter-credential-delivery/0.1'\n// Encounter §9 operational constants (ms)\nexport const CHALLENGE_MAX_AGE = 5 * 60_000 // PT5M\nexport const ISSUANCE_WINDOW = 24 * 3_600_000 // PT24H\nexport const SKEW_TOLERANCE = 5 * 60_000 // PT5M\n\nconst VAL = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => VAL.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\n\n/** Whole seconds (2.3). */\nconst sec = (ms: number): number => Math.floor(ms / 1000)\nconst secIso = (t: string): number => Math.floor(Date.parse(t) / 1000)\n/** 5.5's explicit future check: t_ch ≤ now + skew, whole seconds. */\nexport const futureOk = (tCh: number, now: number): boolean => sec(tCh) <= sec(now) + SKEW_TOLERANCE / 1000\n/** Is a challenge issued at tCh past its age bound at `now` (5190)? */\nexport const challengeAged = (tCh: number, now: number): boolean => sec(now) > sec(tCh) + (CHALLENGE_MAX_AGE + SKEW_TOLERANCE) / 1000\n/** The producer's mirror of 5.6 step 6: may a credential binding a\n * challenge issued at tChMs still be issued now? */\nexport const issuanceOpen = (tChMs: number, now: number): boolean => {\n const skew = SKEW_TOLERANCE / 1000\n return sec(now) >= sec(tChMs) - skew && sec(now) <= sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n}\n/** The last millisecond a credential binding a challenge issued at tChMs may carry (5.6 step 6). */\nexport const issuanceEnd = (tChMs: number): number => (sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW + SKEW_TOLERANCE) / 1000) * 1000 + 999\n\n/** Producer-side profile discipline (Delivery 3): UUID v4 ids and threads. */\nconst UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\nexport const uuidOk = (v: unknown): boolean => typeof v === 'string' && UUID_V4.test(v)\n\nexport const CARD_SCHEMA = 'contact-card-0.25.schema.json'\n/** A card for an enactment (Encounter 6): schema-valid, its version known,\n * a challenge, calendar-valid times, keys that decode, the proof under the\n * anchor. null when it passes, else the reason. */\nexport async function cardOk (card: any, subtle?: SubtleCrypto): Promise<string | null> {\n if (!schemaOk(CARD_SCHEMA, card)) return 'card fails contact-card-0.25 schema'\n if (card.version !== CARD_VERSION) return 'card version unknown'\n if (!card.challenge) return 'card without challenge (enactment use requires one)'\n if (!calOK(card.challenge.issuedAt) || !calOK(card.proof?.created)) return 'card: calendar-invalid timestamp'\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return 'card keyAgreement does not decode (x25519-pub + 32 bytes, 2.3)'\n if (!(await diVerify(card, card.anchor, subtle))) return 'card proof'\n return null\n}\n\n/** The 5.6 rejection codes. */\nexport type CredError = 'ERR_VERSION' | 'ERR_SIG' | 'ERR_ADDRESSEE' | 'ERR_NO_RECORD' | 'ERR_CEREMONY' | 'ERR_STALE_ISSUANCE' | 'ERR_BINDING' | 'ERR_CONFLICT'\n\n/** 5.6 step 1, format: a KNOWN format validated against ITS schema (0.26,\n * or a held 0.25 — 7.3, 12), ceremony and version known, calendar-valid\n * times, the digest a multihash, keys that decode (2.3). `ceremonyHere`:\n * 5.6 checks the ceremony at step 1; a bundle checks it at Delivery 4.1's\n * check 5. */\nexport function credFormat (cred: any, ceremonyHere = true): CredError | null {\n const schema = credentialSchemaOf(cred)\n if (schema === null || !schemaOk(schema, cred)) return 'ERR_VERSION'\n if (ceremonyHere && cred.credentialSubject.ceremony !== CEREMONY) return 'ERR_VERSION'\n if (!calOK(cred.validFrom) || !calOK(cred.proof?.created)) return 'ERR_VERSION'\n if (!sameDigest(cred.credentialSubject.enactmentBinding, cred.credentialSubject.enactmentBinding)) return 'ERR_VERSION'\n if (!edRawOfAnchor(cred.issuer) || !edRawOfAnchor(cred.credentialSubject.id)) return 'ERR_VERSION'\n const vm = String(cred.proof?.verificationMethod ?? ''), hash = vm.indexOf('#')\n if (hash < 0 || !edRawOfAnchor(vm.slice(0, hash)) || !edRawOfAnchor('did:key:' + vm.slice(hash + 1))) return 'ERR_VERSION'\n return null\n}\n\n/** 5.6 steps 1–3: format, signature, addressee (`localAnchor`). */\nexport async function credHead (cred: any, localAnchor: string, ceremonyHere = true, subtle?: SubtleCrypto): Promise<CredError | null> {\n const f = credFormat(cred, ceremonyHere)\n if (f) return f\n if (!(await diVerify(cred, cred.issuer, subtle))) return 'ERR_SIG'\n if (cred.credentialSubject.id !== localAnchor) return 'ERR_ADDRESSEE'\n return null\n}\n\n/** 5.6 step 6: the issuance window, whole seconds, inclusive, skew widens. */\nexport function windowOk (cred: any, tChMs: number): boolean {\n const tCh = sec(tChMs), vf = secIso(cred.validFrom), cr = secIso(cred.proof.created), skew = SKEW_TOLERANCE / 1000\n const lo = tCh - skew, hi = tCh + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n return !(vf < lo || vf > hi || cr < lo || cr > hi || cr < vf - skew)\n}\n\n/** What 5.6 steps 4–7 read of a record. */\nexport interface RecordFacts { counterpart: string, ceremony: string, tCh: number, bind: string }\n\n/** 5.6 steps 4–7 against a record, synchronous. `order`: 'credential' —\n * 5.6: record, ceremony, window, binding; 'bundle' — Delivery 4.1:\n * record, ceremony, binding, window. */\nexport function acceptTail (cred: any, rec: RecordFacts | undefined, order: 'credential' | 'bundle'): CredError | null {\n if (!rec || rec.counterpart !== cred.issuer) return 'ERR_NO_RECORD'\n if (cred.credentialSubject.ceremony !== rec.ceremony) return 'ERR_CEREMONY'\n const bindOk = sameDigest(cred.credentialSubject.enactmentBinding, rec.bind)\n if (order === 'bundle' && !bindOk) return 'ERR_BINDING'\n if (!windowOk(cred, rec.tCh)) return 'ERR_STALE_ISSUANCE'\n if (!bindOk) return 'ERR_BINDING'\n return null\n}\n\n/** Delivery 4.1/4.3: ERR_STALE_ISSUANCE is stale-issuance, every other\n * rejection validation-failed. */\nexport const dispositionOf = (e: CredError): 'stale-issuance' | 'validation-failed' => (e === 'ERR_STALE_ISSUANCE' ? 'stale-issuance' : 'validation-failed')\n\n/**\n * The bundle's context-free checks of Delivery 4.1 check 1 (stage 8,\n * after the payload schema): calendars, the outer/inner equalities, the\n * sent card's binding, a present ceremony.enactment, the card's version\n * and keys, the credential's format (its ceremony at check 5). null when\n * they pass, else the reason, with the 4.1 disposition.\n */\nexport function bundleForm (doc: any): { reason: 'validation-failed' | 'stale-issuance', why: string } | null {\n const { card, credential } = doc.payload\n const v = (why: string) => ({ reason: 'validation-failed' as const, why })\n if (!calOK(doc.issuedAt) || !calOK(card.challenge?.issuedAt) || !calOK(card.proof?.created)) return v('calendar-invalid issuedAt')\n if (doc.issuer !== card.anchor || card.anchor !== credential.issuer) return v('outer binding (issuer = card.anchor = credential.issuer)')\n if (credential.credentialSubject?.id !== doc.recipient) return v('outer binding (recipient = subject)')\n if (card.sentTo !== doc.recipient || card.boundTo !== credential.credentialSubject.challenge) return v('sent card binding (sentTo/boundTo)')\n if (card.challenge.value === card.boundTo) return v('sent challenge equals the displayed challenge (5.3)')\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, credential.credentialSubject.enactmentBinding)) return v('ceremony.enactment recomputes not')\n if (card.version !== CARD_VERSION || !card.challenge) return v('card version/challenge')\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return v('card keys do not decode')\n const f = credFormat(credential, false)\n if (f) return { reason: dispositionOf(f), why: f }\n return null\n}\n\n/** The credential delivery's outer/inner consistency (Delivery 4.3). */\nexport function deliveryForm (doc: any): string | null {\n const cred = doc.payload.credential\n if (!calOK(doc.issuedAt)) return 'calendar-invalid issuedAt'\n if (doc.issuer !== cred.issuer) return 'outer binding (issuer = credential.issuer)'\n if (cred.credentialSubject?.id !== doc.recipient) return 'outer binding (recipient = subject)'\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, cred.credentialSubject.enactmentBinding)) return 'ceremony.enactment recomputes not'\n return null\n}\n"]}