@real-life/trust-protocol 0.7.0 → 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.
@@ -12,8 +12,13 @@
12
12
  // into the register before display (4110,
13
13
  // Identity 6.1), the key's lastShown in
14
14
  // `addresses` (Delivery §5), the challenge
15
- // held open; event encounter.shown carries
16
- // the card, the optical payload
15
+ // held open; with a carrier offer the
16
+ // card carries its delivery hints (6080)
17
+ // and its carrier nonce enters the
18
+ // register under the relationship the
19
+ // card opens (Identity §7a.3); event
20
+ // encounter.shown carries the card, the
21
+ // optical payload
17
22
  // encounter.scan the scanner's step (5.8 trunk 2–3):
18
23
  // the displayed card checked, a fresh
19
24
  // label and own challenge c_A, the record
@@ -22,8 +27,10 @@
22
27
  // its prior candidates frozen, its
23
28
  // continuity probe pending, 6820) and the
24
29
  // bundle into the outbox, in one commit;
25
- // event encounter.scanned carries the
26
- // sent card for the optical leg
30
+ // a carrier offer as with show, its hints
31
+ // in the sent card; event
32
+ // encounter.scanned carries the sent card
33
+ // for the optical leg
27
34
  // encounter.capture the optical leg (5.8, 5710): a sent
28
35
  // card presented to the displayer
29
36
  // encounter.counter the counter-step (5.8 step 4)
@@ -76,17 +83,27 @@
76
83
  // needs an active tuple (tuple-deactivated), its document waits for
77
84
  // the bundle's thread where the record arose on the optical leg (5780)
78
85
  // and goes out with the bundle's record-aware effect
86
+ // - the carrier offer {nonce, deliveryHints}: the app draws the carrier
87
+ // nonce N and builds the hints from it (an adapter derives the wire
88
+ // identities from root, carrier and N), so the offer is plain act
89
+ // input, bound and journaled with the act; the library checks 6090 on
90
+ // the hints (card-invalid), N's form and freshness (carrier-nonce-
91
+ // invalid: 32 bytes, held nowhere in the register), and interprets no
92
+ // hint. N enters the register at show already, under the relationship
93
+ // id the card's label opens, as the label and its pair nonce do (4110);
94
+ // a card that ages unscanned leaves it there, like its label (the
95
+ // register only grows)
79
96
  // - encounter.capture of a card already recorded with the same material
80
97
  // is an idempotent success (5430): the act commits its journal entry only
81
98
  // - no automatic optical switch (5690 RECOMMENDS ack-wait as its
82
99
  // trigger): the app shows the sent card (encounter.scanned) when it
83
100
  // sees the bundle undelivered (deliveryStatus)
84
- import { b64uOf, iso, jcs, makeValidator, sameDigest } from '../core.js';
101
+ import { b64uOf, fromB64u, iso, jcs, makeValidator, sameDigest } from '../core.js';
85
102
  import { diSignWith, diVerify, digestBytes, digestDoc } from '../crypto.js';
86
103
  import { seal } from '../delivery.js';
87
104
  import { BUNDLE_TYPE, CEREMONY, CHALLENGE_MAX_AGE, SKEW_TOLERANCE, DELIVERY_TYPE, acceptTail, bundleForm, cardBody, cardOk, challengeAged, challengeOf, credHead, credentialBody, deliveryForm, dispositionOf, futureOk, issuanceEnd, issuanceOpen, windowOk, } from '../encounter.js';
88
105
  import { SCHEMAS } from '../schemas.js';
89
- import { withPairNonce } from '../identity-state.js';
106
+ import { carrierNonceHeld, withCarrierNonce, withPairNonce } from '../identity-state.js';
90
107
  import { tupleByRkid } from '../receive.js';
91
108
  import { openTuple } from '../trust/continuity.js';
92
109
  import { entryOf, findContact, tupleByLabel } from '../trust/state.js';
@@ -165,6 +182,8 @@ function placeOf(state, r) {
165
182
  return { contactId: idsOf(r.label).contactId, relationshipId: r.relId };
166
183
  return { contactId: entryOf(state, at.rel)?.id ?? at.tuple.entryId, relationshipId: at.rel.id };
167
184
  }
185
+ /** The register with the offer's carrier nonce under `relId`, or unchanged without an offer. */
186
+ const carrierOf = (r, relId, carrier) => carrier === undefined ? r : withCarrierNonce(r, relId, carrier.nonce);
168
187
  const sealWith = (ctx, doc, keyAgreement) => seal(doc, keyAgreement, { ephSeed: ctx.entropy.bytes('seal.eph', 32), nonce: ctx.entropy.bytes('seal.nonce', 12) }, ctx.crypto.subtle);
169
188
  const signer = (ctx, label) => (b) => ctx.keys.sign(label, b);
170
189
  /** The display name a card carries: the input's, else the own profile's, at most 200 characters (6090). */
@@ -172,6 +191,29 @@ const nameFor = (state, name) => {
172
191
  const n = typeof name === 'string' ? name : state.profile.body?.name;
173
192
  return typeof n === 'string' && n.length ? [...n].slice(0, 200).join('') : undefined;
174
193
  };
194
+ /** The carrier offer's own checks, before anything is signed: at least
195
+ * one hint, each a string (else card-invalid without a ref: an empty offer
196
+ * announces nothing, a card without hints needs no offer); the bounds of
197
+ * 6090 (at most eight, each at most 512 characters); then N's form (32
198
+ * bytes, canonical base64url). null where there is no offer or it passes. */
199
+ function offerRefusal(carrier) {
200
+ if (carrier === undefined)
201
+ return null;
202
+ const c = carrier;
203
+ const h = c?.deliveryHints;
204
+ // an offer announces its carrier: no hint (a card without hints is a card
205
+ // without an offer, 6080) or a hint that is no string is no offer
206
+ if (!Array.isArray(h) || h.length < 1 || !h.every((x) => typeof x === 'string'))
207
+ return no('card-invalid');
208
+ if (h.length > 8 || !h.every((x) => [...x].length <= 512))
209
+ return no('card-invalid', 'RLTP-ENC-6090');
210
+ const n = c?.nonce;
211
+ if (typeof n !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(n) || b64uOf(fromB64u(n)) !== n)
212
+ return no('carrier-nonce-invalid');
213
+ return null;
214
+ }
215
+ /** N is fresh (Identity §7a.3): no carrier or pair nonce of the register, and not this act's pair nonce. */
216
+ const nonceStale = (state, carrier, pairNonce) => carrier !== undefined && (carrier.nonce === pairNonce || carrierNonceHeld(state.register, carrier.nonce));
175
217
  /** A fresh pair label from 32 fresh nonce bytes (Identity 6.1, Encounter 4.4). */
176
218
  async function freshLabel(ctx) {
177
219
  const n = ctx.entropy.bytes('founding.nonce', 32);
@@ -180,17 +222,25 @@ async function freshLabel(ctx) {
180
222
  const showDef = {
181
223
  human: true,
182
224
  async prepare(ctx, input) {
225
+ const offer = offerRefusal(input?.carrier);
226
+ if (offer)
227
+ return offer;
183
228
  const { label, nonce } = await freshLabel(ctx);
184
229
  const own = await ctx.keys.anchorOf(label);
185
230
  const value = challengeOf(ctx.entropy.bytes('challenge', 17));
186
231
  const at = iso(ctx.when);
187
232
  const name = nameFor(ctx.snapshot, input?.name);
188
- const body = cardBody(own, { ...(name !== undefined ? { name } : {}), challenge: { value, issuedAt: at } });
233
+ const hints = input?.carrier !== undefined ? { deliveryHints: input.carrier.deliveryHints } : {};
234
+ const body = cardBody(own, { ...(name !== undefined ? { name } : {}), ...hints, challenge: { value, issuedAt: at } });
189
235
  const card = await diSignWith(own.anchor, signer(ctx, label), body, at, ctx.crypto.subtle);
190
236
  return { label, nonce, rkid: own.keyAgreement, value, card };
191
237
  },
192
- apply(state, prepared, _input, when) {
238
+ apply(state, prepared, input, when) {
193
239
  const p = prepared.value;
240
+ if (isRefusal(p))
241
+ return p;
242
+ if (nonceStale(state, input?.carrier, p.nonce))
243
+ return no('carrier-nonce-invalid');
194
244
  // fresh-always (4.4, 4150) and single use (5140): fresh entropy never
195
245
  // repeats; a repeat is a broken entropy source, not a human's refusal
196
246
  if (state.register.labels.includes(p.label) || tupleByLabel(state, p.label))
@@ -200,8 +250,9 @@ const showDef = {
200
250
  return {
201
251
  state: {
202
252
  ...state,
203
- // 4110: the label in the register before the card is displayed
204
- register: withPairNonce(state.register, p.label, p.nonce),
253
+ // 4110: the label in the register before the card is displayed;
254
+ // the carrier nonce beside it, under the relationship the card opens
255
+ register: carrierOf(withPairNonce(state.register, p.label, p.nonce), idsOf(p.label).relId, input?.carrier),
205
256
  addresses: { ...state.addresses, keys: { ...state.addresses.keys, [p.rkid]: { label: p.label, lastShown: when } } },
206
257
  encounter: { ...state.encounter, challenges: { ...state.encounter.challenges, [p.value]: { value: p.value, tCh: when, label: p.label, card: p.card } } },
207
258
  },
@@ -218,6 +269,9 @@ const scanDef = {
218
269
  // a displayed card carries neither sentTo nor boundTo (6070)
219
270
  if (peer.sentTo !== undefined || peer.boundTo !== undefined)
220
271
  return no('card-invalid', 'RLTP-ENC-6070');
272
+ const offer = offerRefusal(input?.carrier);
273
+ if (offer)
274
+ return offer;
221
275
  const S = ctx.crypto.subtle;
222
276
  const { label, nonce } = await freshLabel(ctx);
223
277
  const me = await ctx.keys.anchorOf(label);
@@ -232,7 +286,8 @@ const scanDef = {
232
286
  const sign = signer(ctx, label);
233
287
  const credential = await diSignWith(me.anchor, sign, credentialBody(me.anchor, peer.anchor, CEREMONY, peer.challenge.value, bind, at), at, S);
234
288
  const name = nameFor(ctx.snapshot, input?.name);
235
- const sent = cardBody(me, { ...(name !== undefined ? { name } : {}), challenge: { value: own, issuedAt: at }, sentTo: peer.anchor, boundTo: peer.challenge.value });
289
+ const hints = input?.carrier !== undefined ? { deliveryHints: input.carrier.deliveryHints } : {};
290
+ const sent = cardBody(me, { ...(name !== undefined ? { name } : {}), ...hints, challenge: { value: own, issuedAt: at }, sentTo: peer.anchor, boundTo: peer.challenge.value });
236
291
  const sentCard = await diSignWith(me.anchor, sign, sent, at, S);
237
292
  const threadId = ctx.entropy.id('thread.id');
238
293
  const doc = { id: ctx.entropy.id('doc.id'), type: BUNDLE_TYPE, issuer: me.anchor, recipient: peer.anchor, threadId, issuedAt: at, payload: { card: sentCard, credential } };
@@ -241,10 +296,12 @@ const scanDef = {
241
296
  doc: { digest: await digestDoc(doc, S), envelope: await sealWith(ctx, doc, peer.keyAgreement) },
242
297
  };
243
298
  },
244
- apply(state, prepared, _input, when) {
299
+ apply(state, prepared, input, when) {
245
300
  const p = prepared.value;
246
301
  if (isRefusal(p))
247
302
  return p;
303
+ if (nonceStale(state, input?.carrier, p.nonce))
304
+ return no('carrier-nonce-invalid');
248
305
  const peerValue = p.peer.challenge.value;
249
306
  // 5.3 single use from the scanner's side: a displayed value already in
250
307
  // one of the own records never enters a second enactment (5170)
@@ -270,7 +327,7 @@ const scanDef = {
270
327
  thread: p.threadId, bundleDigest: p.doc.digest, threads: {}, sentCard: p.sentCard, counterPending: false,
271
328
  };
272
329
  return {
273
- state: withRecord(opened.state, record),
330
+ state: withRecord({ ...opened.state, register: carrierOf(opened.state.register, ids.relId, input?.carrier) }, record),
274
331
  outbound: [{
275
332
  digest: p.doc.digest, envelope: p.doc.envelope, type: BUNDLE_TYPE, threadId: p.threadId,
276
333
  recipient: { contactId: ids.contactId, rkid: p.rkid, keyAgreement: p.peer.keyAgreement },
@@ -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;AACxE,qEAAqE;AACrE,wEAAwE;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B,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;AACtE,yEAAyE;AACzE,wEAA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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;