@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.
@@ -1 +1 @@
1
- {"version":3,"file":"identity-state.js","sourceRoot":"","sources":["../src/identity-state.ts"],"names":[],"mappings":"AA8FA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEvF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE5F,2CAA2C;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,EAAE,iBAAiB;CACzF,CAAC,CAAA;AAEX,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAA;AAI1D,sEAAsE;AACtE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAqB,EAAE,KAAa,EAAY,EAAE,CAC1E,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAa,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;AAEnF;0EAC0E;AAC1E,MAAM,UAAU,aAAa,CAAE,CAAqB,EAAE,KAAa,EAAE,KAAa;IAChF,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,CAAC,U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AE,CAAC,CAAC,CAAA;IACrC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,CAAA;AAC5E,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;QACnF,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;KAClD,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// identity-state — the Identity Layer on the holder (lib Stage 2, PR 6):\n// the label register (Identity §2, §6.3) with its device names and\n// revocation marks (§5.5), and the community anchor's rotation as a\n// resumable procedure over the Log port (§5.4; Trust 6360–6420, 6596;\n// Access §5.6). Module `identity`, built into createHolder.\n//\n// Labels and addresses: a pair label's key is a delivery address (Delivery\n// §5): retired, it becomes a tombstone for ever. A member label\n// group/<digest> is an identity context (§6.1): one derivation per group,\n// reused whenever the holder is invited to that group again, so its key\n// leaves `addresses` without a tombstone (engine.ts tick). The register\n// keeps every label either way.\n//\n// What the module registers:\n// commands identity.addDevice {name} a device name into the\n// register (§5.5), before any key derived from it is\n// presented; human\n// identity.revokeDevice {name} the name's revocation mark\n// (§5.5): never removed, the name never given again; human\n// identity.rotate {} the community anchor's rotation\n// (§5.4): step 1 when none runs, else step 2 of the running\n// one; human (holder.rotateAnchor)\n// duty rotation/1 {rotationId} step 2 on resume, until the log\n// holds the entry\n//\n// The rotation, a procedure in state.rotations (note §2.1, §3 Log: head,\n// at, append):\n// where the log stands (standing), for a rotation g → g+1 (§5.4, RLTP-\n// ACC-5980): the genesis must match; a log whose generation g+1 is\n// held (head.gen ≥ g+1) holds this rotation where at(g+1) names its\n// next and commit (present: this device's append whose answer was\n// lost, or another device of the seed, the log since moved on or not),\n// else a fork (diverged); otherwise the device may append over the\n// head that holds the lineage through g (empty for g = 1, else gen g,\n// next = prev, commit = the binding of next); an earlier head is\n// behind, any other diverged\n// step 1 (identity.rotate, one commit) anchor-rotation@2 built (prev g,\n// next g+1, commit = the binding of g+2) and signed by prev and next\n// through the KeyProvider; the head read and the log's standing checked\n// BEFORE anything commits: behind and diverged are refused (log-behind,\n// log-diverged), so the label and the 6596 decision persist only when\n// the device may rotate. Then in one commit the label of g+1 (§5.4:\n// persisted before any presentation; 6360: before the log entry), per\n// relationship the withholding of 6596 decided against the entry state\n// now (awaitHead: H, the entry's anchor head, where it lags; null where\n// it does not; only where the anchor mapping class is on), the closure\n// {entry: {rotation}, overHead: the head read}, the rotation duty. The\n// register's head stays g: nothing is issued under g+1 before the log\n// holds it, and no device key derives under g+1 (deviceKey)\n// step 2 (the rotation duty on resume, or identity.rotate again) the\n// standing again: present completes without an append; behind and\n// diverged keep the rotation pending (the duty refused, no timer: the\n// log's sync is the cue; the act answers log-behind, log-diverged). An\n// append goes only ever over the head the rotation record names, so the\n// port's idempotence over exactly (entry, overHead) holds across a lost\n// answer: where the head the device may append over is another, it is\n// persisted first (the record's overHead, the duty due at once) and the\n// append follows on the next run. append on appended/exists completes the\n// rotation in one commit: the register's head g+1, the rotation in\n// register.lineage, the rotation and its duty gone, anchor.rotated, and\n// the re-issue duties of 6370 opened from the awaitHead decided at step\n// 1 (reissue-mapping/1, id reissue:<g+1>:<relId>) — and for a live\n// relationship the class is on for now that was not in it (new since\n// step 1), decided at completion. A chaining in between unions the\n// decisions onto the chain (null wins). head-conflict re-reads (four\n// reads); failure, or a port that throws, keeps the rotation pending:\n// the duty is due again after the retry backoff (attempt, lastAt), the\n// act answers log-failure\n// 6380 (the self card under the new anchor wherever it is carried): the\n// card travels only inside anchor-mapping@4 here (6.1 card), so the\n// re-issue of 6370 carries it; no duty of its own until the encounter\n// (PR 7) carries a card elsewhere\n// A throw of the Log port at step 1 is InfraError('log'): nothing\n// commits. Without a Log port the rotation is refused (log-missing); at the last\n// generation 2^53 − 2 it is refused (scope-exhausted, Identity §5.4)\n//\n// Pure register helpers for the modules that open contexts (the encounter\n// in PR 7, continuity.newTuple until then): withLabel, withPairNonce.\n//\n// Choices this file makes where note and spec leave them open:\n// - a device name is stored in its 6.2 canonical form (NFC applied), so\n// the register compares what the derivation uses\n// - a name the register already holds is refused (device-name-held: the\n// SHOULD of §5.5 is followed); a revoked name is refused as\n// device-name-revoked (the MUST)\n// - revoking a name already revoked is ok and changes nothing; revoking\n// a name the register does not hold is unknown-device\n// - deviceKey (holder) derives only for a held, unrevoked name and an\n// own anchor context: a label of the register or a generation of the\n// community anchor up to its head (§5.5: names recorded before any\n// derived key is presented; a revoked name offers no key for a new\n// binding). Reading it changes nothing\nimport type { Applied, CommandDef, DutyHandler, HolderModule, PrepareCtx, Refusal } from './engine.js'\nimport type { Dec, Duty, HolderState, Millis, Register, ReissueMappingDuty, Rotation, RotationDuty } from './state.js'\nimport { canonicalLabel, communityLabel, deviceLabel, deviceName } from './identity.js'\nimport type { KeyProvider, LogHead } from './ports.js'\nimport { jcs } from './core.js'\nimport type { Json } from './core.js'\nimport { bindingOf, rawProofValue } from './anchor.js'\nimport { classOnToward, entryOf, entryRelationships, lags, liveRel } from './trust/state.js'\n\n/** The identity module's command names. */\nexport const IDENTITY_COMMANDS = Object.freeze({\n addDevice: 'identity.addDevice', revokeDevice: 'identity.revokeDevice', rotate: 'identity.rotate',\n} as const)\n\n/** The last generation a rotation moves to (Identity §5.4): 2^53 − 2. */\nexport const GENERATION_LAST = Number.MAX_SAFE_INTEGER - 1\n\nexport interface DeviceInput { name: string }\n\n/** The register with `label` among its labels (a set: added once). */\nexport const withLabel = (r: Readonly<Register>, label: string): Register =>\n r.labels.includes(label) ? r as Register : { ...r, labels: [...r.labels, label] }\n\n/** The register with a pair label and its relationship nonce (Identity\n * §6.1): the nonce is recorded alongside the label and never changes. */\nexport function withPairNonce (r: Readonly<Register>, label: string, nonce: string): Register {\n if (Object.hasOwn(r.pairNonces, label)) {\n if (r.pairNonces[label] !== nonce) throw new Error(`identity: ${label} already holds another relationship nonce (§6.1)`)\n return withLabel(r, label)\n }\n return { ...withLabel(r, label), pairNonces: { ...r.pairNonces, [label]: nonce } }\n}\n\nconst needName = (x: unknown, cmd: string): string => {\n if (x === null || typeof x !== 'object' || Array.isArray(x)) throw new TypeError(`${cmd} needs an input object`)\n const n = (x as { name?: unknown }).name\n if (typeof n !== 'string') throw new TypeError(`${cmd}: name must be a string`)\n return n\n}\n\nconst refuse = (code: Refusal['code'], ref?: string): Refusal => ({ ok: false, code, ...(ref ? { ref } : {}) })\n\nconst commands: Record<string, CommandDef> = {\n // §5.5: the name is persisted before any key derived from it is presented\n [IDENTITY_COMMANDS.addDevice]: {\n human: true,\n apply (state, _p, input: DeviceInput) {\n const n = deviceName(needName(input, IDENTITY_COMMANDS.addDevice))\n if (n === null) return refuse('device-name-invalid', 'Identity §6.2')\n const d = state.register.devices\n if (d.revoked.includes(n)) return refuse('device-name-revoked', 'Identity §5.5')\n if (d.names.includes(n)) return refuse('device-name-held', 'Identity §5.5')\n return {\n state: { ...state, register: { ...state.register, devices: { ...d, names: [...d.names, n] } } },\n events: [{ type: 'device.added', name: n }],\n }\n },\n } satisfies CommandDef<DeviceInput>,\n // §5.5: revocation consumes the name; the mark is never removed\n [IDENTITY_COMMANDS.revokeDevice]: {\n human: true,\n apply (state, _p, input: DeviceInput) {\n const n = deviceName(needName(input, IDENTITY_COMMANDS.revokeDevice))\n const d = state.register.devices\n if (n === null || !d.names.includes(n)) return refuse('unknown-device', 'Identity §5.5')\n if (d.revoked.includes(n)) return { state: state as HolderState }\n return {\n state: { ...state, register: { ...state.register, devices: { ...d, revoked: [...d.revoked, n] } } },\n events: [{ type: 'device.revoked', name: n }],\n }\n },\n } satisfies CommandDef<DeviceInput>,\n}\n\n\n// ── the rotation (Identity §5.4, Trust 6360–6420, 6596, Access §5.6) ──\n\n/** The rotation duty's id for a rotation. */\nexport const rotationDutyId = (rotationId: string): string => `rotation:${rotationId}`\n/** A re-issue duty's id after the rotation to generation `to` (6370). */\nexport const reissueId = (to: Dec, relId: string): string => `reissue:${to}:${relId}`\n\ntype RotationArtifact = { body: { type: 'anchor-rotation@2', prev: string, next: string, commit: string }, proof: { proofValue: string, successorProofValue: string } }\n\n/** What step 2 found at the log. */\ntype LogOutcome =\n | { status: 'done', head: LogHead }\n /** the log stands where this device may rotate, over a head other than\n * the persisted closure's: persist it before appending over it */\n | { status: 'moved', head: LogHead }\n | { status: 'behind' | 'diverged', head: LogHead }\n | { status: 'failure', reason: string }\n | { status: 'log-missing' }\n\ntype Rot = RotationArtifact['body']\n\n/**\n * Where the log stands for the rotation g → g+1 (Identity §5.4, RLTP-ACC-\n * 5980): `present`, its generation g+1 holds this rotation (at(g+1) names\n * this next and commit — appended by this device with its answer lost, or\n * by another device of the same seed, the log since moved on or not);\n * `{over}`, the device may append over that head (empty for g = 1, else\n * the entry that introduced g: gen g, next = prev, commit = the binding of\n * next); `behind`, the log has not reached g; `diverged`, another genesis,\n * another entry at g+1 (a fork), or a head the rotation does not continue.\n */\nasync function standing (ctx: PrepareCtx, head: LogHead, genesis: string, from: number, rot: Rot): Promise<'present' | 'behind' | 'diverged' | { over: string | null }> {\n if (head.genesis !== genesis) return 'diverged'\n if ('empty' in head) return from === 1 ? { over: null } : 'behind'\n if (head.gen >= from + 1) {\n const e = await ctx.log!.at(from + 1)\n return e && e.next === rot.next && e.commit === rot.commit ? 'present' : 'diverged'\n }\n if (head.gen === from && head.next === rot.prev && head.commit === await bindingOf(rot.next, ctx.crypto.subtle)) return { over: head.entryId }\n return head.gen < from ? 'behind' : 'diverged'\n}\n\nconst headId = (h: LogHead): string | null => ('empty' in h ? null : h.entryId)\n\n/**\n * Step 2 through the Log port (see the header): where the log stands, then\n * append(entry, the persisted overHead) — only ever over the head the\n * rotation record names, so the port's idempotence over exactly (entry,\n * overHead) holds across a lost answer; a head that moved is persisted\n * first ('moved'). head-conflict re-reads. A port that throws is a\n * failure: the rotation stays pending.\n */\nasync function logStep (ctx: PrepareCtx, r: Readonly<Rotation>, genesis: string): Promise<LogOutcome> {\n const log = ctx.log\n if (!log) return { status: 'log-missing' }\n const rot = (r.entry as { rotation: RotationArtifact }).rotation\n try {\n for (let i = 0; i < 4; i++) {\n const head = await log.head()\n const at = await standing(ctx, head, genesis, Number(r.from), rot.body)\n if (at === 'present') return { status: 'done', head }\n if (at === 'behind' || at === 'diverged') return { status: at, head }\n if (at.over !== headId(r.overHead) || head.genesis !== r.overHead.genesis) return { status: 'moved', head }\n const a = await log.append({ rotation: rot } as unknown as Json, at.over)\n if (a.status === 'appended' || a.status === 'exists') return { status: 'done', head: a.head }\n if (a.status === 'failure') return { status: 'failure', reason: a.reason }\n // head-conflict: re-read\n }\n return { status: 'failure', reason: 'head-conflict persisted' }\n } catch (e) {\n return { status: 'failure', reason: (e as Error)?.message ?? String(e) }\n }\n}\n\n/** 6596, per relationship: the anchor mapping class on for it (live, under\n * its entry), and whether it lags there — then H, else null. */\nfunction withholding (state: Readonly<HolderState>, relId: string): { contactId: string, awaitHead: string | null } | null {\n const r = state.relationships[relId]\n if (!r || !liveRel(r)) return null\n const e = entryOf(state, r)\n if (!e || !e.relIds.includes(r.id) || !classOnToward(e, 'anchorMapping')) return null\n return { contactId: e.id, awaitHead: lags(r, entryRelationships(state, e)) && e.anchorHead !== null ? e.anchorHead : null }\n}\n\n/** Step 1's commit (see the header). */\nfunction startRotation (state: Readonly<HolderState>, p: { id: string, from: Dec, to: Dec, entry: Json, overHead: LogHead, label: string }, when: Millis): Applied | Refusal {\n const com = state.register.community\n if (com === null || com.head !== p.from || Object.keys(state.rotations).length) return refuse('in-flight')\n const awaitHead: Record<string, string | null> = {}\n for (const id of Object.keys(state.relationships).sort()) {\n const w = withholding(state, id)\n if (w) awaitHead[id] = w.awaitHead\n }\n const rotation: Rotation = { id: p.id, from: p.from, to: p.to, step: 'log', startedAt: when, entry: p.entry, overHead: p.overHead, awaitHead }\n const duty: RotationDuty = { kind: 'rotation', v: 1, id: rotationDutyId(p.id), rotationId: p.id }\n return {\n state: { ...state, register: withLabel(state.register, p.label), rotations: { ...state.rotations, [p.id]: rotation } },\n duties: [duty],\n }\n}\n\n/** The completion's commit: head, lineage, the re-issues of 6370 (6596). */\nfunction completeRotation (state: Readonly<HolderState>, r: Readonly<Rotation>): Applied | Refusal {\n const com = state.register.community\n if (com === null || com.head !== r.from) return refuse('in-flight')\n const rot = (r.entry as { rotation: RotationArtifact }).rotation\n const duties: ReissueMappingDuty[] = []\n const reissue = (relId: string, contactId: string, awaitHead: string | null): void => {\n duties.push({ kind: 'reissue-mapping', v: 1, id: reissueId(r.to, relId), contactId, relId, awaitHead })\n }\n // decided at step 1 (6596), where the class is still on for it now\n for (const [relId, awaitHead] of Object.entries(r.awaitHead).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {\n const w = withholding(state, relId)\n if (w) reissue(relId, w.contactId, awaitHead)\n }\n // on for it now, unknown to step 1: decided now\n for (const relId of Object.keys(state.relationships).sort()) {\n if (Object.hasOwn(r.awaitHead, relId)) continue\n const w = withholding(state, relId)\n if (w) reissue(relId, w.contactId, w.awaitHead)\n }\n const rotations = { ...state.rotations }\n delete rotations[r.id]\n const left = { ...state.duties }\n delete left[rotationDutyId(r.id)]\n return {\n state: {\n ...state,\n register: { ...withLabel(state.register, communityLabel(com.genesis, Number(r.to))), community: { ...com, head: r.to }, lineage: [...state.register.lineage, rot as unknown as Json as Register['lineage'][number]] },\n rotations,\n duties: left,\n },\n events: [{ type: 'anchor.rotated', generation: r.to }],\n duties,\n }\n}\n\n/** What step 2's outcome means for the rotation: completion, or why not. */\nfunction afterLog (state: Readonly<HolderState>, rotationId: string, o: LogOutcome, when: Millis): Applied | Refusal {\n const r = Object.hasOwn(state.rotations, rotationId) ? state.rotations[rotationId] : undefined\n if (!r) return refuse('in-flight')\n switch (o.status) {\n case 'done': return completeRotation(state, r)\n case 'moved': {\n // the closure's head, persisted before any append over it; the duty\n // runs again at once (lastAt marks the change, no dueAt)\n const id = rotationDutyId(r.id)\n const held = Object.hasOwn(state.duties, id) ? state.duties[id] as RotationDuty : { kind: 'rotation' as const, v: 1 as const, id, rotationId: r.id }\n const { dueAt: _, ...rest } = held\n const duty: RotationDuty = { ...rest, lastAt: when }\n // single path: the duty leaves the state and comes back as Applied.duties,\n // on the act path and in resume alike\n const left = { ...state.duties }\n delete left[id]\n return {\n state: { ...state, rotations: { ...state.rotations, [r.id]: { ...r, overHead: o.head } }, duties: left },\n duties: [duty],\n }\n }\n case 'behind': return refuse('log-behind', 'RLTP-ACC-5980')\n case 'diverged': return refuse('log-diverged', 'RLTP-ACC-5980')\n case 'log-missing': return refuse('log-missing')\n case 'failure': return refuse('log-failure')\n }\n}\n\ntype RotatePrepared =\n | { kind: 'refuse', code: Refusal['code'], ref?: string }\n | { kind: 'start', id: string, from: Dec, to: Dec, entry: Json, overHead: LogHead, label: string }\n | { kind: 'resume', rotationId: string, outcome: LogOutcome }\n\nconst rotateCommand: CommandDef<Record<string, never>, RotatePrepared> = {\n human: true,\n async prepare (ctx) {\n const st = ctx.snapshot\n const com = st.register.community\n if (com === null) return { kind: 'refuse', code: 'no-community' }\n if (!ctx.log) return { kind: 'refuse', code: 'log-missing' }\n const running = Object.values(st.rotations)[0]\n if (running) return { kind: 'resume', rotationId: running.id, outcome: await logStep(ctx, running, com.genesis) }\n const g = Number(com.head)\n if (!Number.isSafeInteger(g) || g < 1 || g + 1 > GENERATION_LAST) return { kind: 'refuse', code: 'scope-exhausted', ref: 'Identity §5.4' }\n const [prevL, nextL, afterL] = [g, g + 1, g + 2].map((k) => communityLabel(com.genesis, k))\n const [prev, next, after] = await Promise.all([prevL, nextL, afterL].map((l) => ctx.keys.anchorOf(l)))\n const body = { type: 'anchor-rotation@2' as const, prev: prev.anchor, next: next.anchor, commit: await bindingOf(after.anchor, ctx.crypto.subtle) }\n const bytes = new TextEncoder().encode(jcs(body))\n const rotation: RotationArtifact = {\n body,\n proof: { proofValue: rawProofValue(await ctx.keys.sign(prevL, bytes)), successorProofValue: rawProofValue(await ctx.keys.sign(nextL, bytes)) },\n }\n // §5.4: the device rotates only over the log it holds — checked before\n // anything commits, so label and 6596 decision persist only when it may\n const overHead = await ctx.log.head()\n const at = await standing(ctx, overHead, com.genesis, g, body)\n if (at === 'behind') return { kind: 'refuse', code: 'log-behind', ref: 'RLTP-ACC-5980' }\n if (at === 'diverged') return { kind: 'refuse', code: 'log-diverged', ref: 'RLTP-ACC-5980' }\n const to = String(g + 1)\n return { kind: 'start', id: to, from: com.head, to, entry: { rotation } as unknown as Json, overHead, label: nextL }\n },\n apply (state, prepared, _input, when) {\n const p = prepared.value\n if (p.kind === 'refuse') return refuse(p.code, p.ref)\n if (p.kind === 'start') return startRotation(state, p, when)\n return afterLog(state, p.rotationId, p.outcome, when)\n },\n}\n\n/** The rotation duty (rotation/1): step 2 on resume. */\nconst rotationDuty: DutyHandler<LogOutcome | null> = {\n v: 1,\n async prepare (ctx, duty) {\n const r = ctx.snapshot.rotations[(duty as RotationDuty).rotationId]\n const com = ctx.snapshot.register.community\n return r && com ? logStep(ctx, r, com.genesis) : null\n },\n apply (state, duty, ctx, when) {\n const d = duty as RotationDuty\n // a rotation completed (by the act) or gone: nothing left to do\n if (!Object.hasOwn(state.rotations, d.rotationId)) return { state: state as HolderState }\n const o = ctx.prepared.value\n if (o === null) return 'not-due'\n if (o.status === 'failure') {\n // pending, due again after the retry backoff (the duty's own attempt)\n const attempt = (d.attempt ?? 0) + 1\n const again: RotationDuty = { ...d, attempt, lastAt: when, dueAt: Math.min(when + Math.max(0, Math.ceil(ctx.backoff(attempt))), Number.MAX_SAFE_INTEGER) }\n return { state: state as HolderState, duties: [again] }\n }\n return afterLog(state, d.rotationId, o, when)\n },\n}\n\n/** A device key as deviceKey derives it: the device label, the device's\n * did:key and its key-agreement multikey (Identity §5.5). */\nexport type DeviceKeyResult =\n | { ok: true, label: string, device: string, keyAgreement: string }\n | { ok: false, code: 'unknown-device' | 'device-revoked' | 'unknown-context' }\n\n/** Whether `label` names an own anchor context: a label of the register,\n * or a generation of the community anchor up to its head (§5.4). */\nfunction ownContext (state: Readonly<HolderState>, label: string): boolean {\n if (label.startsWith('device/')) return false\n // the community's generations first, bounded by the head: the label of\n // a pending g+1 is recorded, but no key is presented under it before the\n // rotation completes (§5.4)\n const c = state.register.community\n if (c !== null) {\n const base = communityLabel(c.genesis, 1)\n if (label === base) return true\n if (label.startsWith(base + '/')) {\n const g = BigInt(label.slice(base.length + 1))\n return g >= 2n && g <= BigInt(c.head)\n }\n }\n return state.register.labels.includes(label)\n}\n\n/**\n * The device key of a held, unrevoked device name under an own anchor\n * context (Identity §5.5): derived through the KeyProvider, never stored\n * (keys are not state, 9.3).\n */\nexport async function deviceKeyOf (state: Readonly<HolderState>, keys: KeyProvider, name: string, contextLabel: string): Promise<DeviceKeyResult> {\n const n = deviceName(name)\n const d = state.register.devices\n if (n === null || !d.names.includes(n)) return { ok: false, code: 'unknown-device' }\n if (d.revoked.includes(n)) return { ok: false, code: 'device-revoked' }\n const a = canonicalLabel(contextLabel)\n if (a === null || !ownContext(state, a)) return { ok: false, code: 'unknown-context' }\n const label = await deviceLabel(n, a)\n const k = await keys.anchorOf(label)\n return { ok: true, label, device: k.anchor, keyAgreement: k.keyAgreement }\n}\n\n/** The identity module createHolder builds in (see the header). */\nexport function identityModule (): HolderModule {\n return Object.freeze({\n name: 'identity',\n commands: Object.freeze({ ...commands, [IDENTITY_COMMANDS.rotate]: rotateCommand }),\n duties: Object.freeze({ rotation: rotationDuty }),\n })\n}\n"]}
1
+ {"version":3,"file":"identity-state.js","sourceRoot":"","sources":["../src/identity-state.ts"],"names":[],"mappings":"AAgGA,OAAO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,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAA;IACpF,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAA;IACvE,MAAM,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,CAAA;IACtC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAA;IACtF,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACrC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,CAAA;AAC5E,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;QACnF,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;KAClD,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// identity-state — the Identity Layer on the holder (lib Stage 2, PR 6):\n// the label register (Identity §2, §6.3) with its device names and\n// revocation marks (§5.5), and the community anchor's rotation as a\n// resumable procedure over the Log port (§5.4; Trust 6360–6420, 6596;\n// Access §5.6). Module `identity`, built into createHolder.\n//\n// Labels and addresses: a pair label's key is a delivery address (Delivery\n// §5): retired, it becomes a tombstone for ever. A member label\n// group/<digest> is an identity context (§6.1): one derivation per group,\n// reused whenever the holder is invited to that group again, so its key\n// leaves `addresses` without a tombstone (engine.ts tick). The register\n// keeps every label either way.\n//\n// What the module registers:\n// commands identity.addDevice {name} a device name into the\n// register (§5.5), before any key derived from it is\n// presented; human\n// identity.revokeDevice {name} the name's revocation mark\n// (§5.5): never removed, the name never given again; human\n// identity.rotate {} the community anchor's rotation\n// (§5.4): step 1 when none runs, else step 2 of the running\n// one; human (holder.rotateAnchor)\n// duty rotation/1 {rotationId} step 2 on resume, until the log\n// holds the entry\n//\n// The rotation, a procedure in state.rotations (note §2.1, §3 Log: head,\n// at, append):\n// where the log stands (standing), for a rotation g → g+1 (§5.4, RLTP-\n// ACC-5980): the genesis must match; a log whose generation g+1 is\n// held (head.gen ≥ g+1) holds this rotation where at(g+1) names its\n// next and commit (present: this device's append whose answer was\n// lost, or another device of the seed, the log since moved on or not),\n// else a fork (diverged); otherwise the device may append over the\n// head that holds the lineage through g (empty for g = 1, else gen g,\n// next = prev, commit = the binding of next); an earlier head is\n// behind, any other diverged\n// step 1 (identity.rotate, one commit) anchor-rotation@2 built (prev g,\n// next g+1, commit = the binding of g+2) and signed by prev and next\n// through the KeyProvider; the head read and the log's standing checked\n// BEFORE anything commits: behind and diverged are refused (log-behind,\n// log-diverged), so the label and the 6596 decision persist only when\n// the device may rotate. Then in one commit the label of g+1 (§5.4:\n// persisted before any presentation; 6360: before the log entry), per\n// relationship the withholding of 6596 decided against the entry state\n// now (awaitHead: H, the entry's anchor head, where it lags; null where\n// it does not; only where the anchor mapping class is on), the closure\n// {entry: {rotation}, overHead: the head read}, the rotation duty. The\n// register's head stays g: nothing is issued under g+1 before the log\n// holds it, and no device key derives under g+1 (deviceKey)\n// step 2 (the rotation duty on resume, or identity.rotate again) the\n// standing again: present completes without an append; behind and\n// diverged keep the rotation pending (the duty refused, no timer: the\n// log's sync is the cue; the act answers log-behind, log-diverged). An\n// append goes only ever over the head the rotation record names, so the\n// port's idempotence over exactly (entry, overHead) holds across a lost\n// answer: where the head the device may append over is another, it is\n// persisted first (the record's overHead, the duty due at once) and the\n// append follows on the next run. append on appended/exists completes the\n// rotation in one commit: the register's head g+1, the rotation in\n// register.lineage, the rotation and its duty gone, anchor.rotated, and\n// the re-issue duties of 6370 opened from the awaitHead decided at step\n// 1 (reissue-mapping/1, id reissue:<g+1>:<relId>) — and for a live\n// relationship the class is on for now that was not in it (new since\n// step 1), decided at completion. A chaining in between unions the\n// decisions onto the chain (null wins). head-conflict re-reads (four\n// reads); failure, or a port that throws, keeps the rotation pending:\n// the duty is due again after the retry backoff (attempt, lastAt), the\n// act answers log-failure\n// 6380 (the self card under the new anchor wherever it is carried): the\n// card travels only inside anchor-mapping@4 here (6.1 card), so the\n// re-issue of 6370 carries it; no duty of its own until the encounter\n// (PR 7) carries a card elsewhere\n// A throw of the Log port at step 1 is InfraError('log'): nothing\n// commits. Without a Log port the rotation is refused (log-missing); at the last\n// generation 2^53 − 2 it is refused (scope-exhausted, Identity §5.4)\n//\n// Pure register helpers for the modules that open contexts (the encounter\n// in PR 7, continuity.newTuple until then): withLabel, withPairNonce; and\n// for the carrier nonce of a relationship (Identity §7a.3): carrierNonceHeld,\n// withCarrierNonce, canonicalCarrierNonce.\n//\n// Choices this file makes where note and spec leave them open:\n// - a device name is stored in its 6.2 canonical form (NFC applied), so\n// the register compares what the derivation uses\n// - a name the register already holds is refused (device-name-held: the\n// SHOULD of §5.5 is followed); a revoked name is refused as\n// device-name-revoked (the MUST)\n// - revoking a name already revoked is ok and changes nothing; revoking\n// a name the register does not hold is unknown-device\n// - deviceKey (holder) derives only for a held, unrevoked name and an\n// own anchor context: a label of the register or a generation of the\n// community anchor up to its head (§5.5: names recorded before any\n// derived key is presented; a revoked name offers no key for a new\n// binding). Reading it changes nothing\nimport type { Applied, CommandDef, DutyHandler, HolderModule, PrepareCtx, Refusal } from './engine.js'\nimport type { CarrierNonce, Dec, Duty, HolderState, Millis, Register, ReissueMappingDuty, Rotation, RotationDuty } from './state.js'\nimport { canonicalLabel, communityLabel, deviceLabel, deviceName } from './identity.js'\nimport type { KeyProvider, LogHead } from './ports.js'\nimport { fromB64u, jcs } from './core.js'\nimport type { Json } from './core.js'\nimport { bindingOf, rawProofValue } from './anchor.js'\nimport { classOnToward, entryOf, entryRelationships, lags, liveRel } from './trust/state.js'\n\n/** The identity module's command names. */\nexport const IDENTITY_COMMANDS = Object.freeze({\n addDevice: 'identity.addDevice', revokeDevice: 'identity.revokeDevice', rotate: 'identity.rotate',\n} as const)\n\n/** The last generation a rotation moves to (Identity §5.4): 2^53 − 2. */\nexport const GENERATION_LAST = Number.MAX_SAFE_INTEGER - 1\n\nexport interface DeviceInput { name: string }\n\n/** The register with `label` among its labels (a set: added once). */\nexport const withLabel = (r: Readonly<Register>, label: string): Register =>\n r.labels.includes(label) ? r as Register : { ...r, labels: [...r.labels, label] }\n\n/** The register with a pair label and its relationship nonce (Identity\n * §6.1): the nonce is recorded alongside the label and never changes. */\nexport function withPairNonce (r: Readonly<Register>, label: string, nonce: string): Register {\n if (Object.hasOwn(r.pairNonces, label)) {\n if (r.pairNonces[label] !== nonce) throw new Error(`identity: ${label} already holds another relationship nonce (§6.1)`)\n return withLabel(r, label)\n }\n return { ...withLabel(r, label), pairNonces: { ...r.pairNonces, [label]: nonce } }\n}\n\n/** Does the register hold `nonce` (canonical base64url) as a carrier\n * nonce of any relationship, or as a pair nonce (Identity §7a.3: N is\n * fresh and never a pair nonce)? */\nexport const carrierNonceHeld = (r: Readonly<Register>, nonce: string): boolean =>\n Object.values(r.carriers).some((list) => list.some((e) => e.nonce === nonce)) || Object.values(r.pairNonces).includes(nonce)\n\n/** The register with the first carrier-nonce entry of relationship\n * `relId`, generation 1 (Identity §7a.3). A relationship that already\n * holds an entry is not given a second one here: rotation is not this. */\nexport function withCarrierNonce (r: Readonly<Register>, relId: string, nonce: string): Register {\n if (Object.hasOwn(r.carriers, relId)) throw new Error(`identity: ${relId} already holds a carrier nonce (§7a.3)`)\n return { ...r, carriers: { ...r.carriers, [relId]: [{ nonce, generation: '1' }] } }\n}\n\n/** The canonical carrier-nonce entry of a relationship (Identity §7a.3):\n * the highest generation, among equal ones the nonce whose bytes are\n * smallest in unsigned bytewise order; undefined where none is held. */\nexport function canonicalCarrierNonce (r: Readonly<Register>, relId: string): CarrierNonce | undefined {\n const list = Object.hasOwn(r.carriers, relId) ? r.carriers[relId] : []\n let best: CarrierNonce | undefined\n for (const e of list) {\n if (!best) { best = e; continue }\n const g = BigInt(e.generation) - BigInt(best.generation)\n if (g > 0n || (g === 0n && bytewiseLess(fromB64u(e.nonce), fromB64u(best.nonce)))) best = e\n }\n return best\n}\n\nconst bytewiseLess = (a: Uint8Array, b: Uint8Array): boolean => {\n for (let i = 0; i < Math.min(a.length, b.length); i++) if (a[i] !== b[i]) return a[i] < b[i]\n return a.length < b.length\n}\n\nconst needName = (x: unknown, cmd: string): string => {\n if (x === null || typeof x !== 'object' || Array.isArray(x)) throw new TypeError(`${cmd} needs an input object`)\n const n = (x as { name?: unknown }).name\n if (typeof n !== 'string') throw new TypeError(`${cmd}: name must be a string`)\n return n\n}\n\nconst refuse = (code: Refusal['code'], ref?: string): Refusal => ({ ok: false, code, ...(ref ? { ref } : {}) })\n\nconst commands: Record<string, CommandDef> = {\n // §5.5: the name is persisted before any key derived from it is presented\n [IDENTITY_COMMANDS.addDevice]: {\n human: true,\n apply (state, _p, input: DeviceInput) {\n const n = deviceName(needName(input, IDENTITY_COMMANDS.addDevice))\n if (n === null) return refuse('device-name-invalid', 'Identity §6.2')\n const d = state.register.devices\n if (d.revoked.includes(n)) return refuse('device-name-revoked', 'Identity §5.5')\n if (d.names.includes(n)) return refuse('device-name-held', 'Identity §5.5')\n return {\n state: { ...state, register: { ...state.register, devices: { ...d, names: [...d.names, n] } } },\n events: [{ type: 'device.added', name: n }],\n }\n },\n } satisfies CommandDef<DeviceInput>,\n // §5.5: revocation consumes the name; the mark is never removed\n [IDENTITY_COMMANDS.revokeDevice]: {\n human: true,\n apply (state, _p, input: DeviceInput) {\n const n = deviceName(needName(input, IDENTITY_COMMANDS.revokeDevice))\n const d = state.register.devices\n if (n === null || !d.names.includes(n)) return refuse('unknown-device', 'Identity §5.5')\n if (d.revoked.includes(n)) return { state: state as HolderState }\n return {\n state: { ...state, register: { ...state.register, devices: { ...d, revoked: [...d.revoked, n] } } },\n events: [{ type: 'device.revoked', name: n }],\n }\n },\n } satisfies CommandDef<DeviceInput>,\n}\n\n\n// ── the rotation (Identity §5.4, Trust 6360–6420, 6596, Access §5.6) ──\n\n/** The rotation duty's id for a rotation. */\nexport const rotationDutyId = (rotationId: string): string => `rotation:${rotationId}`\n/** A re-issue duty's id after the rotation to generation `to` (6370). */\nexport const reissueId = (to: Dec, relId: string): string => `reissue:${to}:${relId}`\n\ntype RotationArtifact = { body: { type: 'anchor-rotation@2', prev: string, next: string, commit: string }, proof: { proofValue: string, successorProofValue: string } }\n\n/** What step 2 found at the log. */\ntype LogOutcome =\n | { status: 'done', head: LogHead }\n /** the log stands where this device may rotate, over a head other than\n * the persisted closure's: persist it before appending over it */\n | { status: 'moved', head: LogHead }\n | { status: 'behind' | 'diverged', head: LogHead }\n | { status: 'failure', reason: string }\n | { status: 'log-missing' }\n\ntype Rot = RotationArtifact['body']\n\n/**\n * Where the log stands for the rotation g → g+1 (Identity §5.4, RLTP-ACC-\n * 5980): `present`, its generation g+1 holds this rotation (at(g+1) names\n * this next and commit — appended by this device with its answer lost, or\n * by another device of the same seed, the log since moved on or not);\n * `{over}`, the device may append over that head (empty for g = 1, else\n * the entry that introduced g: gen g, next = prev, commit = the binding of\n * next); `behind`, the log has not reached g; `diverged`, another genesis,\n * another entry at g+1 (a fork), or a head the rotation does not continue.\n */\nasync function standing (ctx: PrepareCtx, head: LogHead, genesis: string, from: number, rot: Rot): Promise<'present' | 'behind' | 'diverged' | { over: string | null }> {\n if (head.genesis !== genesis) return 'diverged'\n if ('empty' in head) return from === 1 ? { over: null } : 'behind'\n if (head.gen >= from + 1) {\n const e = await ctx.log!.at(from + 1)\n return e && e.next === rot.next && e.commit === rot.commit ? 'present' : 'diverged'\n }\n if (head.gen === from && head.next === rot.prev && head.commit === await bindingOf(rot.next, ctx.crypto.subtle)) return { over: head.entryId }\n return head.gen < from ? 'behind' : 'diverged'\n}\n\nconst headId = (h: LogHead): string | null => ('empty' in h ? null : h.entryId)\n\n/**\n * Step 2 through the Log port (see the header): where the log stands, then\n * append(entry, the persisted overHead) — only ever over the head the\n * rotation record names, so the port's idempotence over exactly (entry,\n * overHead) holds across a lost answer; a head that moved is persisted\n * first ('moved'). head-conflict re-reads. A port that throws is a\n * failure: the rotation stays pending.\n */\nasync function logStep (ctx: PrepareCtx, r: Readonly<Rotation>, genesis: string): Promise<LogOutcome> {\n const log = ctx.log\n if (!log) return { status: 'log-missing' }\n const rot = (r.entry as { rotation: RotationArtifact }).rotation\n try {\n for (let i = 0; i < 4; i++) {\n const head = await log.head()\n const at = await standing(ctx, head, genesis, Number(r.from), rot.body)\n if (at === 'present') return { status: 'done', head }\n if (at === 'behind' || at === 'diverged') return { status: at, head }\n if (at.over !== headId(r.overHead) || head.genesis !== r.overHead.genesis) return { status: 'moved', head }\n const a = await log.append({ rotation: rot } as unknown as Json, at.over)\n if (a.status === 'appended' || a.status === 'exists') return { status: 'done', head: a.head }\n if (a.status === 'failure') return { status: 'failure', reason: a.reason }\n // head-conflict: re-read\n }\n return { status: 'failure', reason: 'head-conflict persisted' }\n } catch (e) {\n return { status: 'failure', reason: (e as Error)?.message ?? String(e) }\n }\n}\n\n/** 6596, per relationship: the anchor mapping class on for it (live, under\n * its entry), and whether it lags there — then H, else null. */\nfunction withholding (state: Readonly<HolderState>, relId: string): { contactId: string, awaitHead: string | null } | null {\n const r = state.relationships[relId]\n if (!r || !liveRel(r)) return null\n const e = entryOf(state, r)\n if (!e || !e.relIds.includes(r.id) || !classOnToward(e, 'anchorMapping')) return null\n return { contactId: e.id, awaitHead: lags(r, entryRelationships(state, e)) && e.anchorHead !== null ? e.anchorHead : null }\n}\n\n/** Step 1's commit (see the header). */\nfunction startRotation (state: Readonly<HolderState>, p: { id: string, from: Dec, to: Dec, entry: Json, overHead: LogHead, label: string }, when: Millis): Applied | Refusal {\n const com = state.register.community\n if (com === null || com.head !== p.from || Object.keys(state.rotations).length) return refuse('in-flight')\n const awaitHead: Record<string, string | null> = {}\n for (const id of Object.keys(state.relationships).sort()) {\n const w = withholding(state, id)\n if (w) awaitHead[id] = w.awaitHead\n }\n const rotation: Rotation = { id: p.id, from: p.from, to: p.to, step: 'log', startedAt: when, entry: p.entry, overHead: p.overHead, awaitHead }\n const duty: RotationDuty = { kind: 'rotation', v: 1, id: rotationDutyId(p.id), rotationId: p.id }\n return {\n state: { ...state, register: withLabel(state.register, p.label), rotations: { ...state.rotations, [p.id]: rotation } },\n duties: [duty],\n }\n}\n\n/** The completion's commit: head, lineage, the re-issues of 6370 (6596). */\nfunction completeRotation (state: Readonly<HolderState>, r: Readonly<Rotation>): Applied | Refusal {\n const com = state.register.community\n if (com === null || com.head !== r.from) return refuse('in-flight')\n const rot = (r.entry as { rotation: RotationArtifact }).rotation\n const duties: ReissueMappingDuty[] = []\n const reissue = (relId: string, contactId: string, awaitHead: string | null): void => {\n duties.push({ kind: 'reissue-mapping', v: 1, id: reissueId(r.to, relId), contactId, relId, awaitHead })\n }\n // decided at step 1 (6596), where the class is still on for it now\n for (const [relId, awaitHead] of Object.entries(r.awaitHead).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {\n const w = withholding(state, relId)\n if (w) reissue(relId, w.contactId, awaitHead)\n }\n // on for it now, unknown to step 1: decided now\n for (const relId of Object.keys(state.relationships).sort()) {\n if (Object.hasOwn(r.awaitHead, relId)) continue\n const w = withholding(state, relId)\n if (w) reissue(relId, w.contactId, w.awaitHead)\n }\n const rotations = { ...state.rotations }\n delete rotations[r.id]\n const left = { ...state.duties }\n delete left[rotationDutyId(r.id)]\n return {\n state: {\n ...state,\n register: { ...withLabel(state.register, communityLabel(com.genesis, Number(r.to))), community: { ...com, head: r.to }, lineage: [...state.register.lineage, rot as unknown as Json as Register['lineage'][number]] },\n rotations,\n duties: left,\n },\n events: [{ type: 'anchor.rotated', generation: r.to }],\n duties,\n }\n}\n\n/** What step 2's outcome means for the rotation: completion, or why not. */\nfunction afterLog (state: Readonly<HolderState>, rotationId: string, o: LogOutcome, when: Millis): Applied | Refusal {\n const r = Object.hasOwn(state.rotations, rotationId) ? state.rotations[rotationId] : undefined\n if (!r) return refuse('in-flight')\n switch (o.status) {\n case 'done': return completeRotation(state, r)\n case 'moved': {\n // the closure's head, persisted before any append over it; the duty\n // runs again at once (lastAt marks the change, no dueAt)\n const id = rotationDutyId(r.id)\n const held = Object.hasOwn(state.duties, id) ? state.duties[id] as RotationDuty : { kind: 'rotation' as const, v: 1 as const, id, rotationId: r.id }\n const { dueAt: _, ...rest } = held\n const duty: RotationDuty = { ...rest, lastAt: when }\n // single path: the duty leaves the state and comes back as Applied.duties,\n // on the act path and in resume alike\n const left = { ...state.duties }\n delete left[id]\n return {\n state: { ...state, rotations: { ...state.rotations, [r.id]: { ...r, overHead: o.head } }, duties: left },\n duties: [duty],\n }\n }\n case 'behind': return refuse('log-behind', 'RLTP-ACC-5980')\n case 'diverged': return refuse('log-diverged', 'RLTP-ACC-5980')\n case 'log-missing': return refuse('log-missing')\n case 'failure': return refuse('log-failure')\n }\n}\n\ntype RotatePrepared =\n | { kind: 'refuse', code: Refusal['code'], ref?: string }\n | { kind: 'start', id: string, from: Dec, to: Dec, entry: Json, overHead: LogHead, label: string }\n | { kind: 'resume', rotationId: string, outcome: LogOutcome }\n\nconst rotateCommand: CommandDef<Record<string, never>, RotatePrepared> = {\n human: true,\n async prepare (ctx) {\n const st = ctx.snapshot\n const com = st.register.community\n if (com === null) return { kind: 'refuse', code: 'no-community' }\n if (!ctx.log) return { kind: 'refuse', code: 'log-missing' }\n const running = Object.values(st.rotations)[0]\n if (running) return { kind: 'resume', rotationId: running.id, outcome: await logStep(ctx, running, com.genesis) }\n const g = Number(com.head)\n if (!Number.isSafeInteger(g) || g < 1 || g + 1 > GENERATION_LAST) return { kind: 'refuse', code: 'scope-exhausted', ref: 'Identity §5.4' }\n const [prevL, nextL, afterL] = [g, g + 1, g + 2].map((k) => communityLabel(com.genesis, k))\n const [prev, next, after] = await Promise.all([prevL, nextL, afterL].map((l) => ctx.keys.anchorOf(l)))\n const body = { type: 'anchor-rotation@2' as const, prev: prev.anchor, next: next.anchor, commit: await bindingOf(after.anchor, ctx.crypto.subtle) }\n const bytes = new TextEncoder().encode(jcs(body))\n const rotation: RotationArtifact = {\n body,\n proof: { proofValue: rawProofValue(await ctx.keys.sign(prevL, bytes)), successorProofValue: rawProofValue(await ctx.keys.sign(nextL, bytes)) },\n }\n // §5.4: the device rotates only over the log it holds — checked before\n // anything commits, so label and 6596 decision persist only when it may\n const overHead = await ctx.log.head()\n const at = await standing(ctx, overHead, com.genesis, g, body)\n if (at === 'behind') return { kind: 'refuse', code: 'log-behind', ref: 'RLTP-ACC-5980' }\n if (at === 'diverged') return { kind: 'refuse', code: 'log-diverged', ref: 'RLTP-ACC-5980' }\n const to = String(g + 1)\n return { kind: 'start', id: to, from: com.head, to, entry: { rotation } as unknown as Json, overHead, label: nextL }\n },\n apply (state, prepared, _input, when) {\n const p = prepared.value\n if (p.kind === 'refuse') return refuse(p.code, p.ref)\n if (p.kind === 'start') return startRotation(state, p, when)\n return afterLog(state, p.rotationId, p.outcome, when)\n },\n}\n\n/** The rotation duty (rotation/1): step 2 on resume. */\nconst rotationDuty: DutyHandler<LogOutcome | null> = {\n v: 1,\n async prepare (ctx, duty) {\n const r = ctx.snapshot.rotations[(duty as RotationDuty).rotationId]\n const com = ctx.snapshot.register.community\n return r && com ? logStep(ctx, r, com.genesis) : null\n },\n apply (state, duty, ctx, when) {\n const d = duty as RotationDuty\n // a rotation completed (by the act) or gone: nothing left to do\n if (!Object.hasOwn(state.rotations, d.rotationId)) return { state: state as HolderState }\n const o = ctx.prepared.value\n if (o === null) return 'not-due'\n if (o.status === 'failure') {\n // pending, due again after the retry backoff (the duty's own attempt)\n const attempt = (d.attempt ?? 0) + 1\n const again: RotationDuty = { ...d, attempt, lastAt: when, dueAt: Math.min(when + Math.max(0, Math.ceil(ctx.backoff(attempt))), Number.MAX_SAFE_INTEGER) }\n return { state: state as HolderState, duties: [again] }\n }\n return afterLog(state, d.rotationId, o, when)\n },\n}\n\n/** A device key as deviceKey derives it: the device label, the device's\n * did:key and its key-agreement multikey (Identity §5.5). */\nexport type DeviceKeyResult =\n | { ok: true, label: string, device: string, keyAgreement: string }\n | { ok: false, code: 'unknown-device' | 'device-revoked' | 'unknown-context' }\n\n/** Whether `label` names an own anchor context: a label of the register,\n * or a generation of the community anchor up to its head (§5.4). */\nfunction ownContext (state: Readonly<HolderState>, label: string): boolean {\n if (label.startsWith('device/')) return false\n // the community's generations first, bounded by the head: the label of\n // a pending g+1 is recorded, but no key is presented under it before the\n // rotation completes (§5.4)\n const c = state.register.community\n if (c !== null) {\n const base = communityLabel(c.genesis, 1)\n if (label === base) return true\n if (label.startsWith(base + '/')) {\n const g = BigInt(label.slice(base.length + 1))\n return g >= 2n && g <= BigInt(c.head)\n }\n }\n return state.register.labels.includes(label)\n}\n\n/**\n * The device key of a held, unrevoked device name under an own anchor\n * context (Identity §5.5): derived through the KeyProvider, never stored\n * (keys are not state, 9.3).\n */\nexport async function deviceKeyOf (state: Readonly<HolderState>, keys: KeyProvider, name: string, contextLabel: string): Promise<DeviceKeyResult> {\n const n = deviceName(name)\n const d = state.register.devices\n if (n === null || !d.names.includes(n)) return { ok: false, code: 'unknown-device' }\n if (d.revoked.includes(n)) return { ok: false, code: 'device-revoked' }\n const a = canonicalLabel(contextLabel)\n if (a === null || !ownContext(state, a)) return { ok: false, code: 'unknown-context' }\n const label = await deviceLabel(n, a)\n const k = await keys.anchorOf(label)\n return { ok: true, label, device: k.anchor, keyAgreement: k.keyAgreement }\n}\n\n/** The identity module createHolder builds in (see the header). */\nexport function identityModule (): HolderModule {\n return Object.freeze({\n name: 'identity',\n commands: Object.freeze({ ...commands, [IDENTITY_COMMANDS.rotate]: rotateCommand }),\n duties: Object.freeze({ rotation: rotationDuty }),\n })\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ export type { Entropy, EntropyPurpose, EntropyErrorCode, PlatformRandom } from '
29
29
  export { storeContract } from './store-contract.js';
30
30
  export { seedKeys } from './keys-seed.js';
31
31
  export { createHolder } from './holder-api.js';
32
- export type { Holder, HolderOptions, HolderSnapshot, HumanActOptions } from './holder-api.js';
32
+ export type { CarrierOffer, Holder, HolderOptions, HolderSnapshot, HumanActOptions } from './holder-api.js';
33
33
  export type { DeviceKeyResult } from './identity-state.js';
34
34
  export type { ContactView, RelationshipView, ClassView, SealedClassView, ClassesView, ContactProfileView, GroupView, ProfileView, PromptView, InboxMessageView, DeliveryItemView, DeliveryStatusView } from './views.js';
35
35
  export type { EnginePorts, CommitListener, CryptoHandle, TransportEntry, TransportView, TransportRefusal } from './engine.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwEA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACL,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EA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B,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACxN,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC7H,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,4EAA4E;AAC5E,mEAAmE;AACnE,gFAAgF;AAChF,0DAA0D;AAC1D,2EAA2E;AAC3E,oEAAoE;AACpE,iFAAiF;AACjF,+EAA+E;AAC/E,uEAAuE;AACvE,gFAAgF;AAChF,2EAA2E;AAC3E,2EAA2E;AAC3E,uDAAuD;AACvD,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,6EAA6E;AAC7E,2CAA2C;AAC3C,+EAA+E;AAC/E,oEAAoE;AACpE,2DAA2D;AAC3D,6DAA6D;AAC7D,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,oEAAoE;AACpE,wEAAwE;AACxE,sEAAsE;AACtE,yEAAyE;AACzE,4DAA4D;AAC5D,0EAA0E;AAC1E,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,+DAA+D;AAC/D,EAAE;AACF,sDAAsD;AACtD,0EAA0E;AAC1E,4EAA4E;AAC5E,sDAAsD;AACtD,gFAAgF;AAChF,gFAAgF;AAChF,wEAAwE;AACxE,yDAAyD;AACzD,4EAA4E;AAC5E,EAAE;AACF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AA","sourcesContent":["// @real-life/trust-protocol — the reference library of RLTP.\n//\n// The holder: createHolder({store, keys, entropy?, log?, access?, retry?,\n// crypto?}) — one person's device state behind the human acts, receive,\n// report, resume and tick, and the views an app reads. The ports (Store,\n// KeyProvider, Entropy, Log, Access, DeliveryReport, Outbound) are the\n// app's; seedKeys is the default KeyProvider. Beside it, the pure wire\n// builders and verifiers of every layer, byte-compatible with the shipped\n// vectors.\n//\n// core the form every artifact obeys (JCS, digests, schemas)\n// crypto the primitives, and the Data Integrity proof\n// identity context derivation under the closed registry (§6.1/§6.2),\n// device labels device/<n>/<c> (§5.5)\n// profile profile@1 (Trust §6b): k_pr, the MAC, the bounds and\n// the picture's header read before any decoding\n// encounter the ceremony's wire forms: challenges, cards, credentials,\n// and its pure checks (5.6 acceptance, the bundle's forms)\n// membership Membership 0.20's forms and checks: the prelude,\n// invite, accept, evidence, vouch@2, the member label, oids\n// message Message Tasks 0.1's forms: message@1, k_msg, the MAC\n// introduction Trust §8's artifacts and checks, the act window, the\n// registry declaration's ack-delay\n// delivery the sealed envelope and the generic receive stages 1–4\n// carrier-identity the carrier-relationship principal (Identity §7a)\n// carrier the carrier side of the port (Delivery §4.4 + §5a)\n// carrier-holder the holder side of the carrier port: proofs, verdicts,\n// recovery (§5a, §9.3)\n// visibility the Trust Layer's wire forms, pure: anchor (self-card@2,\n// anchor-rotation@2, anchor-mapping@4), star@2,\n// group-star@1, continuity-probe@1 and\n// continuity-mapping@1, delivery-ack/0.1\n// ceremony the encounter's, the group's and the introduction's\n// wire forms, pure (the same as the root's encounter,\n// membership and introduction modules, under one name)\n//\n// The holder (holder-api.ts): the typed human acts (trust, untrust,\n// pauseTrust, setClass, setGroupClass, merge, depart, decide, rotateAnchor,\n// setProfile, addDevice, revokeDevice, show, scan, captureSentCard,\n// counter, foundGroup, invite, vouchFor, introduce, sendMessage, block,\n// unblock; {when, actId}), recover, takeMessages, act, receive, tick,\n// resume, report, subscribe, snapshot, deviceKey and the views contacts,\n// contact, groups, profile, prompts, inbox, deliveryStatus;\n// `invariants: true` checks invariants.ts on every commit (testing mode).\n// Its modules: identity (Identity §2, §5.4, §5.5), trust (Trust 2, 2a,\n// 5.2–5.4, 6.1–6.5, 6a, 6b), encounter (Encounter 0.31 §5–§7), membership\n// (Membership 0.20 with an in-library Access), introduction (Trust §8) and\n// message (Message Tasks 0.1: messages, the inbox, the block).\n//\n// views the view types (ContactView, …)\n// keys-seed seedKeys — the default KeyProvider over a root seed\n// state HolderState — opaque here (note §4.5): store adapters\n// persist it, apps read the views\n// codec decodeState (to the opaque state), CODEC, StateCodecError\n// ports Store, KeyProvider, Log, Access, DeliveryReport, Outbound\n// results, events ActResult, ReceiveResult, InfraError, HolderEvent\n// entropy the Entropy port by closed purpose\n// store-contract storeContract — the test suite a Store adapter passes\n//\n// Other entry points:\n// ./testing InMemoryStore, memoryLog, scriptedEntropy, storeContract,\n// emptyState, stateBuilder, freezeDeep, sampleState,\n// openPromptModule, the invariants, forgeMapping, SCHEMAS\n// and the generated wire types\n// ./internal the structural state, encodeState and the codec chain,\n// the engine's module types, the pure view functions, the\n// modules' factories and pure reads — for the library's\n// modules and tests, not an app contract\n// ./adapters/vti-mediator the VTI mediator's reports as DeliveryReport\n//\n// Specification, schemas and vectors: https://trust-protocol.real-life.org\n\nexport * from './core.js'\nexport * from './crypto.js'\nexport * from './identity.js'\nexport * from './encounter.js'\nexport * from './membership.js'\nexport * from './message.js'\nexport * from './introduction.js'\nexport * from './delivery.js'\nexport * from './carrier-identity.js'\nexport * from './carrier.js'\nexport * from './carrier-holder.js'\nexport {\n PROFILE_TYPE, PROFILE_LIMITS, profileSchemaOk, imageDimensions, imageWithinBounds, profileProblem, profileInfo, profileKey,\n assembleProfile, profileMacOk,\n} from './profile.js'\nexport type { ProfileContent, ProfileBody, ProfileArtifact, Dimensions, ImageDimensions } from './profile.js'\nexport * as visibility from './visibility.js'\nexport * as ceremony from './ceremony.js'\nimport { decodeState as decodeStructural } from './codec.js'\nimport type { OpaqueHolderState } from './state.js'\nexport type { OpaqueHolderState as HolderState, Dec, Millis, B64u, TrustClass, Setting, PromptKind, PromptChoice, OutboxStatus } from './state.js'\nexport { CODEC, StateCodecError } from './codec.js'\nexport type { StateCodecErrorCode } from './codec.js'\n/** Load a stored state (a JSON string or a parsed value): an independent,\n * opaque copy at the current codec, or StateCodecError. */\nexport function decodeState (raw: unknown): OpaqueHolderState {\n return decodeStructural(raw) as unknown as OpaqueHolderState\n}\nexport type * from './ports.js'\nexport type * from './events.js'\nexport { InfraError, CryptoUnavailableError } from './results.js'\nexport type { ActError, ActResult, ActReplay, ReceiveFailure, ReceiveStageNo, ReceiveResult, ReplayOutbound, ReplayResult, ResumeResult, InfraErrorCode } from './results.js'\nexport { ENTROPY_PURPOSES, EntropyError, randomEntropy } from './entropy.js'\nexport type { Entropy, EntropyPurpose, EntropyErrorCode, PlatformRandom } from './entropy.js'\nexport { storeContract } from './store-contract.js'\nexport { seedKeys } from './keys-seed.js'\nexport { createHolder } from './holder-api.js'\nexport type { Holder, HolderOptions, HolderSnapshot, HumanActOptions } from './holder-api.js'\nexport type { DeviceKeyResult } from './identity-state.js'\nexport type { ContactView, RelationshipView, ClassView, SealedClassView, ClassesView, ContactProfileView, GroupView, ProfileView, PromptView, InboxMessageView, DeliveryItemView, DeliveryStatusView } from './views.js'\nexport type { EnginePorts, CommitListener, CryptoHandle, TransportEntry, TransportView, TransportRefusal } from './engine.js'\nexport type { ContractHarness } from './store-contract.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,4EAA4E;AAC5E,mEAAmE;AACnE,gFAAgF;AAChF,0DAA0D;AAC1D,2EAA2E;AAC3E,oEAAoE;AACpE,iFAAiF;AACjF,+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AAA;AAErB,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG5D,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEnD;4DAC4D;AAC5D,MAAM,UAAU,WAAW,CAAE,GAAY;IACvC,OAAO,gBAAgB,CAAC,GAAG,CAAiC,CAAA;AAC9D,CAAC;AAGD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA","sourcesContent":["// @real-life/trust-protocol — the reference library of RLTP.\n//\n// The holder: createHolder({store, keys, entropy?, log?, access?, retry?,\n// crypto?}) — one person's device state behind the human acts, receive,\n// report, resume and tick, and the views an app reads. The ports (Store,\n// KeyProvider, Entropy, Log, Access, DeliveryReport, Outbound) are the\n// app's; seedKeys is the default KeyProvider. Beside it, the pure wire\n// builders and verifiers of every layer, byte-compatible with the shipped\n// vectors.\n//\n// core the form every artifact obeys (JCS, digests, schemas)\n// crypto the primitives, and the Data Integrity proof\n// identity context derivation under the closed registry (§6.1/§6.2),\n// device labels device/<n>/<c> (§5.5)\n// profile profile@1 (Trust §6b): k_pr, the MAC, the bounds and\n// the picture's header read before any decoding\n// encounter the ceremony's wire forms: challenges, cards, credentials,\n// and its pure checks (5.6 acceptance, the bundle's forms)\n// membership Membership 0.20's forms and checks: the prelude,\n// invite, accept, evidence, vouch@2, the member label, oids\n// message Message Tasks 0.1's forms: message@1, k_msg, the MAC\n// introduction Trust §8's artifacts and checks, the act window, the\n// registry declaration's ack-delay\n// delivery the sealed envelope and the generic receive stages 1–4\n// carrier-identity the carrier-relationship principal (Identity §7a)\n// carrier the carrier side of the port (Delivery §4.4 + §5a)\n// carrier-holder the holder side of the carrier port: proofs, verdicts,\n// recovery (§5a, §9.3)\n// visibility the Trust Layer's wire forms, pure: anchor (self-card@2,\n// anchor-rotation@2, anchor-mapping@4), star@2,\n// group-star@1, continuity-probe@1 and\n// continuity-mapping@1, delivery-ack/0.1\n// ceremony the encounter's, the group's and the introduction's\n// wire forms, pure (the same as the root's encounter,\n// membership and introduction modules, under one name)\n//\n// The holder (holder-api.ts): the typed human acts (trust, untrust,\n// pauseTrust, setClass, setGroupClass, merge, depart, decide, rotateAnchor,\n// setProfile, addDevice, revokeDevice, show, scan, captureSentCard,\n// counter, foundGroup, invite, vouchFor, introduce, sendMessage, block,\n// unblock; {when, actId}), recover, takeMessages, act, receive, tick,\n// resume, report, subscribe, snapshot, deviceKey and the views contacts,\n// contact, groups, profile, prompts, inbox, deliveryStatus;\n// `invariants: true` checks invariants.ts on every commit (testing mode).\n// Its modules: identity (Identity §2, §5.4, §5.5), trust (Trust 2, 2a,\n// 5.2–5.4, 6.1–6.5, 6a, 6b), encounter (Encounter 0.31 §5–§7), membership\n// (Membership 0.20 with an in-library Access), introduction (Trust §8) and\n// message (Message Tasks 0.1: messages, the inbox, the block).\n//\n// views the view types (ContactView, …)\n// keys-seed seedKeys — the default KeyProvider over a root seed\n// state HolderState — opaque here (note §4.5): store adapters\n// persist it, apps read the views\n// codec decodeState (to the opaque state), CODEC, StateCodecError\n// ports Store, KeyProvider, Log, Access, DeliveryReport, Outbound\n// results, events ActResult, ReceiveResult, InfraError, HolderEvent\n// entropy the Entropy port by closed purpose\n// store-contract storeContract — the test suite a Store adapter passes\n//\n// Other entry points:\n// ./testing InMemoryStore, memoryLog, scriptedEntropy, storeContract,\n// emptyState, stateBuilder, freezeDeep, sampleState,\n// openPromptModule, the invariants, forgeMapping, SCHEMAS\n// and the generated wire types\n// ./internal the structural state, encodeState and the codec chain,\n// the engine's module types, the pure view functions, the\n// modules' factories and pure reads — for the library's\n// modules and tests, not an app contract\n// ./adapters/vti-mediator the VTI mediator's reports as DeliveryReport\n//\n// Specification, schemas and vectors: https://trust-protocol.real-life.org\n\nexport * from './core.js'\nexport * from './crypto.js'\nexport * from './identity.js'\nexport * from './encounter.js'\nexport * from './membership.js'\nexport * from './message.js'\nexport * from './introduction.js'\nexport * from './delivery.js'\nexport * from './carrier-identity.js'\nexport * from './carrier.js'\nexport * from './carrier-holder.js'\nexport {\n PROFILE_TYPE, PROFILE_LIMITS, profileSchemaOk, imageDimensions, imageWithinBounds, profileProblem, profileInfo, profileKey,\n assembleProfile, profileMacOk,\n} from './profile.js'\nexport type { ProfileContent, ProfileBody, ProfileArtifact, Dimensions, ImageDimensions } from './profile.js'\nexport * as visibility from './visibility.js'\nexport * as ceremony from './ceremony.js'\nimport { decodeState as decodeStructural } from './codec.js'\nimport type { OpaqueHolderState } from './state.js'\nexport type { OpaqueHolderState as HolderState, Dec, Millis, B64u, TrustClass, Setting, PromptKind, PromptChoice, OutboxStatus } from './state.js'\nexport { CODEC, StateCodecError } from './codec.js'\nexport type { StateCodecErrorCode } from './codec.js'\n/** Load a stored state (a JSON string or a parsed value): an independent,\n * opaque copy at the current codec, or StateCodecError. */\nexport function decodeState (raw: unknown): OpaqueHolderState {\n return decodeStructural(raw) as unknown as OpaqueHolderState\n}\nexport type * from './ports.js'\nexport type * from './events.js'\nexport { InfraError, CryptoUnavailableError } from './results.js'\nexport type { ActError, ActResult, ActReplay, ReceiveFailure, ReceiveStageNo, ReceiveResult, ReplayOutbound, ReplayResult, ResumeResult, InfraErrorCode } from './results.js'\nexport { ENTROPY_PURPOSES, EntropyError, randomEntropy } from './entropy.js'\nexport type { Entropy, EntropyPurpose, EntropyErrorCode, PlatformRandom } from './entropy.js'\nexport { storeContract } from './store-contract.js'\nexport { seedKeys } from './keys-seed.js'\nexport { createHolder } from './holder-api.js'\nexport type { CarrierOffer, Holder, HolderOptions, HolderSnapshot, HumanActOptions } from './holder-api.js'\nexport type { DeviceKeyResult } from './identity-state.js'\nexport type { ContactView, RelationshipView, ClassView, SealedClassView, ClassesView, ContactProfileView, GroupView, ProfileView, PromptView, InboxMessageView, DeliveryItemView, DeliveryStatusView } from './views.js'\nexport type { EnginePorts, CommitListener, CryptoHandle, TransportEntry, TransportView, TransportRefusal } from './engine.js'\nexport type { ContractHarness } from './store-contract.js'\n"]}
package/dist/results.d.ts CHANGED
@@ -43,6 +43,10 @@ export type ActError = 'unknown-contact' | 'no-own-channel' | 'tuple-deactivated
43
43
  * keys, proof) or is not of the profile the act needs (displayed for a
44
44
  * scan, sent and addressed to an own challenge's anchor for a capture) */
45
45
  | 'card-invalid'
46
+ /** encounter.show, encounter.scan: the carrier nonce of the offer is not
47
+ * 32 bytes in canonical base64url, or the register already holds it as
48
+ * a carrier or pair nonce (Identity §7a.3: fresh) */
49
+ | 'carrier-nonce-invalid'
46
50
  /** encounter.scan: this displayed code was scanned already: its
47
51
  * challenge is in a record (5.3, 5170) */
48
52
  | 'already-scanned'
@@ -1 +1 @@
1
- {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C;oEACoE;AACpE,MAAM,WAAW,YAAY;IAAG,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;AAEjG,qEAAqE;AACrE,MAAM,MAAM,QAAQ,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB;AAClB,uEAAuE;GACrE,eAAe,GACf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E+B;GAC7B,oBAAoB;AACtB;;2BAE2B;GACzB,QAAQ,CAAA;AAEZ,oEAAoE;AACpE,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;gBAChB,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAKnF;AAED;yDACyD;AACzD,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;gBACtB,OAAO,EAAE,SAAS,MAAM,EAAE;CAKxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"results.js","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AA4MA,oEAAoE;AACpE,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,CAAgB;IAC7B,YAAa,IAAoB,EAAE,OAAgB,EAAE,OAA6B;QAChF,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,OAAO,CAAC,CAAA;QAC/B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED;yDACyD;AACzD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,6EAA6E;IACpE,OAAO,CAAmB;IACnC,YAAa,OAA0B;QACrC,KAAK,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAA;QACrG,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF","sourcesContent":["// results — one closed result type for acts, one for reception, one error\n// class for infrastructure (lib Stage 2, note §4.4).\n//\n// \"Nothing to do\" is ok with empty outbound. A committed act with open\n// follow-up work is success plus a duty. Store and provider failures are\n// InfraError; programming errors and broken invariants throw. Human text\n// is the app's, made from the code.\nimport type { HolderEvent } from './events.js'\nimport type { Outbound } from './ports.js'\n\n/** What resume(when) hands out: retries and due duties, in the engine's\n * fixed order, and when to call again (absent: nothing is due). */\nexport interface ResumeResult { outbound: Outbound[], events: HolderEvent[], nextDueAt?: number }\n\n/** Why an act was refused; `ref` on the result may name the rule. */\nexport type ActError =\n | 'unknown-contact'\n | 'no-own-channel'\n | 'tuple-deactivated'\n | 'already-given'\n | 'in-flight'\n | 'scope-exhausted'\n | 'stale-issuance'\n | 'actid-conflict'\n /** a human act came without the actId the app must mint (note §4.2) */\n | 'actid-missing'\n | 'log-missing'\n /** the anchor mapping needs the holder's community anchor (register.community, Identity §5.4) */\n | 'no-community'\n | 'unknown-digest'\n /** prompt.decide: no open prompt has this id */\n | 'unknown-prompt'\n /** prompt.decide: the prompt's expiresAt is not after when; tick removes it */\n | 'prompt-expired'\n /** trust.merge: the manual merge joins at most one entry (6640), and\n * never relationships the binding rule keeps apart (6605) */\n | 'not-mergeable'\n /** identity.addDevice: not a device name of 6.2 (Identity §5.5) */\n | 'device-name-invalid'\n /** identity.addDevice: the register already holds the name (Identity §5.5, SHOULD) */\n | 'device-name-held'\n /** identity.addDevice: a revoked name is never given again (Identity §5.5) */\n | 'device-name-revoked'\n /** identity.revokeDevice: the register holds no such device name */\n | 'unknown-device'\n /** identity.rotate: the log replica does not hold the lineage through the\n * current generation (Identity §5.4, Access RLTP-ACC-5980); the rotation\n * stays pending until it does */\n | 'log-behind'\n /** identity.rotate: the log's head is no generation of this register's\n * lineage (another genesis, or a head the register does not follow) */\n | 'log-diverged'\n /** identity.rotate: the log answered failure; the rotation stays pending */\n | 'log-failure'\n /** setProfile: the body breaks 6430/6435 or its image 6475 */\n | 'profile-invalid'\n /** encounter: a card that fails Encounter 6 (schema, version, challenge,\n * keys, proof) or is not of the profile the act needs (displayed for a\n * scan, sent and addressed to an own challenge's anchor for a capture) */\n | 'card-invalid'\n /** encounter.scan: this displayed code was scanned already: its\n * challenge is in a record (5.3, 5170) */\n | 'already-scanned'\n /** encounter.capture: the bound challenge resolves unknown (5460) */\n | 'gate-expired'\n /** encounter: the own challenge is future-dated beyond the skew (5390) */\n | 'gate-future'\n /** encounter.capture: the challenge was consumed by another enactment (5440) */\n | 'consumed-challenge'\n /** encounter.capture: the same counterparty with other material (5450) */\n | 'card-mismatch'\n /** encounter.counter: no enactment record of the contact to issue on */\n | 'no-record'\n /** encounter.counter: the own step credential is issued already */\n | 'already-issued'\n /** membership: no such group, or the holder holds no role in it the act needs */\n | 'unknown-group'\n /** membership.vouch: no consent pair held for this member (Access 5.3) */\n | 'no-evidence'\n /** membership.vouch: the admitting member's own vouch never counts beside its admission */\n | 'own-admission'\n /** membership.found: a genesis admits under the rule of one; a stricter rule needs policy.change */\n | 'threshold-unsupported'\n /** introduction: no such act, or not in a state that allows the step */\n | 'unknown-act'\n /** introduction.request: the mediator's ack-delay declaration is not held (Delivery 4.4) */\n | 'no-declaration'\n /** a message, an invitation or the start of an introduction act toward\n * a relationship the holder has blocked (Message Tasks RLTP-MSG-6410) */\n | 'blocked'\n /** message.send: the tuple is not ready — no document of the\n * counterpart was accepted on it yet (Message Tasks RLTP-MSG-5020); the\n * app keeps the message unsent and sends it once the contact view says\n * `canMessage` */\n | 'not-ready'\n /** message.send: the text is not 1 to 4096 code points, or replyTo is no\n * lowercase UUID v4 (Message Tasks 3.2) */\n | 'message-invalid'\n\nexport type ActResult =\n /** nextDueAt: duty work this act opened or unblocked, or the first retry\n * or send deadline of a document it issued (a repeat: of its live\n * documents), is due then (`when`: now) — call resume at that time\n * (engine.ts) */\n | { ok: true, outbound: Outbound[], events: HolderEvent[], nextDueAt?: number }\n | { ok: false, code: ActError, ref?: string }\n\n/** One document of a journaled act, as replay(actId, when) sees it:\n * `live` is whether a repeat of the act at `when` would hand it out again\n * (neither delivered nor failed, and not past its sender lifetime or the\n * horizon at max(when, lastWhen)); deliveryStatus(digest) has the rest. */\nexport interface ReplayOutbound { readonly digest: string, readonly live: boolean }\n\n/** The journaled result of one human act (note §4.2): what the act's\n * commit answered. For sendMessage, the `message.sent` event carries\n * `mid` and `digest`; `at` is the commit time the message's `sentAt` was\n * taken from (whole seconds below it). */\nexport interface ActReplay {\n readonly actId: string\n /** the act's commit */\n readonly commitSeq: string\n /** the holder time of the act's commit (max(when, lastWhen) then) */\n readonly at: number\n /** the act's events as the commit announced them */\n readonly events: readonly HolderEvent[]\n /** the act's documents, in the act's order */\n readonly outbound: readonly ReplayOutbound[]\n}\n\n/** replay(actId, when): the journaled result, or `unknown-act` when the\n * journal holds no act under the id — never committed, or past the\n * journal's retention. A pure read: nothing runs, nothing commits. */\nexport type ReplayResult =\n | { readonly ok: true, readonly result: ActReplay }\n | { readonly ok: false, readonly code: 'unknown-act' | 'actid-missing' }\n\n/** Receiver failure dispositions (Delivery §6.2), by the stage that names them. */\nexport type ReceiveFailure =\n | 'oversize' // stage 1\n | 'malformed' // stages 2, 4, 5, 7\n | 'decryption-failed' // stage 3\n | 'wrong-recipient' // stage 5\n | 'unknown-type' // stage 6\n | 'validation-failed' // stages 6 (the entry's proof declaration), 8, 9\n | 'stale-issuance' // stages 8, 9\n /** transient (Delivery RLTP-DEL-5820, 6270, 6280): nothing committed, no\n * ack, no cache entry; the carrier keeps the document and the receiver\n * evaluates it afresh when it is delivered again — never concluded */\n | 'rate-limited' // stage 8\n | 'gate-future' // stage 9\n | 'consumed-challenge' // stage 9\n\nexport type ReceiveStageNo = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\n/**\n * The outcome of receive(env, when). `unique`: the effect committed,\n * with its ack first among `outbound` where the type acknowledges (a\n * delivery-ack itself is terminal and earns none), then the documents\n * the effect issued. `duplicate-known`: the stored ack is re-sent\n * byte-identical (none for a terminal document); nothing commits beyond\n * a raised lastWhen. `failed`: nothing took effect and nothing commits.\n * `discarded`: the document's chunk met a receiver resource limit (Trust\n * 5365, reason `resource-limit`) or, authenticated, violated the assembly\n * rules so that its whole delivery is rejected (5260–5310, 5500, 5510,\n * reason `rejected`): the open assembly is dropped and its salt held as\n * the lower bound (5366), committed; no cache entry, no ack, no event.\n * Delivery §6.2 has no disposition for it yet (receive.ts: a gap for\n * Delivery 0.82).\n */\nexport type ReceiveResult =\n | { disposition: 'unique', digest: string, type: string, outbound: Outbound[], events: HolderEvent[], /** as on ActResult */ nextDueAt?: number }\n | { disposition: 'duplicate-known', digest: string, outbound: Outbound[] }\n | { disposition: 'discarded', digest: string, type: string, reason: 'resource-limit' | 'rejected', ref?: string }\n | {\n disposition: 'failed', reason: ReceiveFailure, stage: ReceiveStageNo, digest?: string,\n /** local diagnosis of a key failure, never a disposition of its own\n * (Delivery §5, §6.2): 'unknown' — an rkid this holder never issued,\n * failed(malformed) at stage 2; 'retired' — a tombstone (or a key\n * marked retired), failed(decryption-failed) at stage 3 */\n key?: 'unknown' | 'retired'\n /** the rule the document failed, where its task handler names one\n * (TaskRefusal.ref), e.g. RLTP-TRU-6118 */\n ref?: string\n }\n\nexport type InfraErrorCode =\n | 'store-read'\n | 'store-commit'\n /** the commit may or may not have landed; re-read and consult the act journal */\n | 'unknown-commit-outcome'\n /** the store kept answering `conflict` past the retry bound (RetryPolicy.commitAttempts) */\n | 'commit-conflict'\n | 'key-provider'\n | 'log'\n | 'access'\n /** testing mode only (createHolder's `invariants: true`): a commit would\n * break an invariant of invariants.ts; nothing committed, the\n * violations are the cause */\n | 'invariant-violated'\n /** the holder was closed (a lock, the end of a process): it runs nothing\n * more, and nothing it issued authorizes a hand-over (Delivery\n * RLTP-DEL-6125, 6130) */\n | 'closed'\n\n/** A failure of a port the host provides, never of the protocol. */\nexport class InfraError extends Error {\n readonly code: InfraErrorCode\n constructor (code: InfraErrorCode, message?: string, options?: { cause?: unknown }) {\n super(message ?? code, options)\n this.name = 'InfraError'\n this.code = code\n }\n}\n\n/** The WebCrypto handle lacks what the library needs; raised when a\n * holder is built, never at import (note §3 Crypto). */\nexport class CryptoUnavailableError extends Error {\n /** the algorithms (or 'subtle' itself) that are missing, in a fixed order */\n readonly missing: readonly string[]\n constructor (missing: readonly string[]) {\n super(`WebCrypto lacks: ${missing.join(', ')} (needs Ed25519, X25519, HKDF, HMAC, AES-GCM, SHA-256)`)\n this.name = 'CryptoUnavailableError'\n this.missing = Object.freeze([...missing])\n }\n}\n"]}
1
+ {"version":3,"file":"results.js","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAgNA,oEAAoE;AACpE,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,CAAgB;IAC7B,YAAa,IAAoB,EAAE,OAAgB,EAAE,OAA6B;QAChF,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,OAAO,CAAC,CAAA;QAC/B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED;yDACyD;AACzD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,6EAA6E;IACpE,OAAO,CAAmB;IACnC,YAAa,OAA0B;QACrC,KAAK,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAA;QACrG,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF","sourcesContent":["// results — one closed result type for acts, one for reception, one error\n// class for infrastructure (lib Stage 2, note §4.4).\n//\n// \"Nothing to do\" is ok with empty outbound. A committed act with open\n// follow-up work is success plus a duty. Store and provider failures are\n// InfraError; programming errors and broken invariants throw. Human text\n// is the app's, made from the code.\nimport type { HolderEvent } from './events.js'\nimport type { Outbound } from './ports.js'\n\n/** What resume(when) hands out: retries and due duties, in the engine's\n * fixed order, and when to call again (absent: nothing is due). */\nexport interface ResumeResult { outbound: Outbound[], events: HolderEvent[], nextDueAt?: number }\n\n/** Why an act was refused; `ref` on the result may name the rule. */\nexport type ActError =\n | 'unknown-contact'\n | 'no-own-channel'\n | 'tuple-deactivated'\n | 'already-given'\n | 'in-flight'\n | 'scope-exhausted'\n | 'stale-issuance'\n | 'actid-conflict'\n /** a human act came without the actId the app must mint (note §4.2) */\n | 'actid-missing'\n | 'log-missing'\n /** the anchor mapping needs the holder's community anchor (register.community, Identity §5.4) */\n | 'no-community'\n | 'unknown-digest'\n /** prompt.decide: no open prompt has this id */\n | 'unknown-prompt'\n /** prompt.decide: the prompt's expiresAt is not after when; tick removes it */\n | 'prompt-expired'\n /** trust.merge: the manual merge joins at most one entry (6640), and\n * never relationships the binding rule keeps apart (6605) */\n | 'not-mergeable'\n /** identity.addDevice: not a device name of 6.2 (Identity §5.5) */\n | 'device-name-invalid'\n /** identity.addDevice: the register already holds the name (Identity §5.5, SHOULD) */\n | 'device-name-held'\n /** identity.addDevice: a revoked name is never given again (Identity §5.5) */\n | 'device-name-revoked'\n /** identity.revokeDevice: the register holds no such device name */\n | 'unknown-device'\n /** identity.rotate: the log replica does not hold the lineage through the\n * current generation (Identity §5.4, Access RLTP-ACC-5980); the rotation\n * stays pending until it does */\n | 'log-behind'\n /** identity.rotate: the log's head is no generation of this register's\n * lineage (another genesis, or a head the register does not follow) */\n | 'log-diverged'\n /** identity.rotate: the log answered failure; the rotation stays pending */\n | 'log-failure'\n /** setProfile: the body breaks 6430/6435 or its image 6475 */\n | 'profile-invalid'\n /** encounter: a card that fails Encounter 6 (schema, version, challenge,\n * keys, proof) or is not of the profile the act needs (displayed for a\n * scan, sent and addressed to an own challenge's anchor for a capture) */\n | 'card-invalid'\n /** encounter.show, encounter.scan: the carrier nonce of the offer is not\n * 32 bytes in canonical base64url, or the register already holds it as\n * a carrier or pair nonce (Identity §7a.3: fresh) */\n | 'carrier-nonce-invalid'\n /** encounter.scan: this displayed code was scanned already: its\n * challenge is in a record (5.3, 5170) */\n | 'already-scanned'\n /** encounter.capture: the bound challenge resolves unknown (5460) */\n | 'gate-expired'\n /** encounter: the own challenge is future-dated beyond the skew (5390) */\n | 'gate-future'\n /** encounter.capture: the challenge was consumed by another enactment (5440) */\n | 'consumed-challenge'\n /** encounter.capture: the same counterparty with other material (5450) */\n | 'card-mismatch'\n /** encounter.counter: no enactment record of the contact to issue on */\n | 'no-record'\n /** encounter.counter: the own step credential is issued already */\n | 'already-issued'\n /** membership: no such group, or the holder holds no role in it the act needs */\n | 'unknown-group'\n /** membership.vouch: no consent pair held for this member (Access 5.3) */\n | 'no-evidence'\n /** membership.vouch: the admitting member's own vouch never counts beside its admission */\n | 'own-admission'\n /** membership.found: a genesis admits under the rule of one; a stricter rule needs policy.change */\n | 'threshold-unsupported'\n /** introduction: no such act, or not in a state that allows the step */\n | 'unknown-act'\n /** introduction.request: the mediator's ack-delay declaration is not held (Delivery 4.4) */\n | 'no-declaration'\n /** a message, an invitation or the start of an introduction act toward\n * a relationship the holder has blocked (Message Tasks RLTP-MSG-6410) */\n | 'blocked'\n /** message.send: the tuple is not ready — no document of the\n * counterpart was accepted on it yet (Message Tasks RLTP-MSG-5020); the\n * app keeps the message unsent and sends it once the contact view says\n * `canMessage` */\n | 'not-ready'\n /** message.send: the text is not 1 to 4096 code points, or replyTo is no\n * lowercase UUID v4 (Message Tasks 3.2) */\n | 'message-invalid'\n\nexport type ActResult =\n /** nextDueAt: duty work this act opened or unblocked, or the first retry\n * or send deadline of a document it issued (a repeat: of its live\n * documents), is due then (`when`: now) — call resume at that time\n * (engine.ts) */\n | { ok: true, outbound: Outbound[], events: HolderEvent[], nextDueAt?: number }\n | { ok: false, code: ActError, ref?: string }\n\n/** One document of a journaled act, as replay(actId, when) sees it:\n * `live` is whether a repeat of the act at `when` would hand it out again\n * (neither delivered nor failed, and not past its sender lifetime or the\n * horizon at max(when, lastWhen)); deliveryStatus(digest) has the rest. */\nexport interface ReplayOutbound { readonly digest: string, readonly live: boolean }\n\n/** The journaled result of one human act (note §4.2): what the act's\n * commit answered. For sendMessage, the `message.sent` event carries\n * `mid` and `digest`; `at` is the commit time the message's `sentAt` was\n * taken from (whole seconds below it). */\nexport interface ActReplay {\n readonly actId: string\n /** the act's commit */\n readonly commitSeq: string\n /** the holder time of the act's commit (max(when, lastWhen) then) */\n readonly at: number\n /** the act's events as the commit announced them */\n readonly events: readonly HolderEvent[]\n /** the act's documents, in the act's order */\n readonly outbound: readonly ReplayOutbound[]\n}\n\n/** replay(actId, when): the journaled result, or `unknown-act` when the\n * journal holds no act under the id — never committed, or past the\n * journal's retention. A pure read: nothing runs, nothing commits. */\nexport type ReplayResult =\n | { readonly ok: true, readonly result: ActReplay }\n | { readonly ok: false, readonly code: 'unknown-act' | 'actid-missing' }\n\n/** Receiver failure dispositions (Delivery §6.2), by the stage that names them. */\nexport type ReceiveFailure =\n | 'oversize' // stage 1\n | 'malformed' // stages 2, 4, 5, 7\n | 'decryption-failed' // stage 3\n | 'wrong-recipient' // stage 5\n | 'unknown-type' // stage 6\n | 'validation-failed' // stages 6 (the entry's proof declaration), 8, 9\n | 'stale-issuance' // stages 8, 9\n /** transient (Delivery RLTP-DEL-5820, 6270, 6280): nothing committed, no\n * ack, no cache entry; the carrier keeps the document and the receiver\n * evaluates it afresh when it is delivered again — never concluded */\n | 'rate-limited' // stage 8\n | 'gate-future' // stage 9\n | 'consumed-challenge' // stage 9\n\nexport type ReceiveStageNo = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\n/**\n * The outcome of receive(env, when). `unique`: the effect committed,\n * with its ack first among `outbound` where the type acknowledges (a\n * delivery-ack itself is terminal and earns none), then the documents\n * the effect issued. `duplicate-known`: the stored ack is re-sent\n * byte-identical (none for a terminal document); nothing commits beyond\n * a raised lastWhen. `failed`: nothing took effect and nothing commits.\n * `discarded`: the document's chunk met a receiver resource limit (Trust\n * 5365, reason `resource-limit`) or, authenticated, violated the assembly\n * rules so that its whole delivery is rejected (5260–5310, 5500, 5510,\n * reason `rejected`): the open assembly is dropped and its salt held as\n * the lower bound (5366), committed; no cache entry, no ack, no event.\n * Delivery §6.2 has no disposition for it yet (receive.ts: a gap for\n * Delivery 0.82).\n */\nexport type ReceiveResult =\n | { disposition: 'unique', digest: string, type: string, outbound: Outbound[], events: HolderEvent[], /** as on ActResult */ nextDueAt?: number }\n | { disposition: 'duplicate-known', digest: string, outbound: Outbound[] }\n | { disposition: 'discarded', digest: string, type: string, reason: 'resource-limit' | 'rejected', ref?: string }\n | {\n disposition: 'failed', reason: ReceiveFailure, stage: ReceiveStageNo, digest?: string,\n /** local diagnosis of a key failure, never a disposition of its own\n * (Delivery §5, §6.2): 'unknown' — an rkid this holder never issued,\n * failed(malformed) at stage 2; 'retired' — a tombstone (or a key\n * marked retired), failed(decryption-failed) at stage 3 */\n key?: 'unknown' | 'retired'\n /** the rule the document failed, where its task handler names one\n * (TaskRefusal.ref), e.g. RLTP-TRU-6118 */\n ref?: string\n }\n\nexport type InfraErrorCode =\n | 'store-read'\n | 'store-commit'\n /** the commit may or may not have landed; re-read and consult the act journal */\n | 'unknown-commit-outcome'\n /** the store kept answering `conflict` past the retry bound (RetryPolicy.commitAttempts) */\n | 'commit-conflict'\n | 'key-provider'\n | 'log'\n | 'access'\n /** testing mode only (createHolder's `invariants: true`): a commit would\n * break an invariant of invariants.ts; nothing committed, the\n * violations are the cause */\n | 'invariant-violated'\n /** the holder was closed (a lock, the end of a process): it runs nothing\n * more, and nothing it issued authorizes a hand-over (Delivery\n * RLTP-DEL-6125, 6130) */\n | 'closed'\n\n/** A failure of a port the host provides, never of the protocol. */\nexport class InfraError extends Error {\n readonly code: InfraErrorCode\n constructor (code: InfraErrorCode, message?: string, options?: { cause?: unknown }) {\n super(message ?? code, options)\n this.name = 'InfraError'\n this.code = code\n }\n}\n\n/** The WebCrypto handle lacks what the library needs; raised when a\n * holder is built, never at import (note §3 Crypto). */\nexport class CryptoUnavailableError extends Error {\n /** the algorithms (or 'subtle' itself) that are missing, in a fixed order */\n readonly missing: readonly string[]\n constructor (missing: readonly string[]) {\n super(`WebCrypto lacks: ${missing.join(', ')} (needs Ed25519, X25519, HKDF, HMAC, AES-GCM, SHA-256)`)\n this.name = 'CryptoUnavailableError'\n this.missing = Object.freeze([...missing])\n }\n}\n"]}
package/dist/views.d.ts CHANGED
@@ -93,6 +93,20 @@ export interface RelationshipView {
93
93
  id: string;
94
94
  tuples: number;
95
95
  chainedFrom: string[];
96
+ /** the relationship's canonical carrier-nonce entry (Identity §7a.3):
97
+ * N in base64url and its generation, from which an adapter derives this
98
+ * side's wire identities; absent where none is held. A relationship
99
+ * chained into this one is listed only in chainedFrom and shows none:
100
+ * the chain is carried under this N (profile RLTP-VTI-1230) */
101
+ carrierNonce?: {
102
+ nonce: string;
103
+ generation: Dec;
104
+ };
105
+ /** the counterpart's delivery hints from the card of the enactment that
106
+ * opened this relationship (its first contact; Encounter 6080), as
107
+ * signed, uninterpreted; absent where that card carried none. A card of
108
+ * a later enactment chained into the relationship changes nothing */
109
+ counterpartDeliveryHints?: string[];
96
110
  }
97
111
  /** One group the holder is a member of. */
98
112
  export interface GroupView {
@@ -1 +1 @@
1
- {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../src/views.ts"],"names":[],"mappings":"AAyEA,OAAO,KAAK,EAED,GAAG,EAAE,WAAW,EAAE,MAAM,EAAc,YAAY,EAAE,UAAU,EAAgB,OAAO,EAAE,UAAU,EAC3G,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAE1F,0FAA0F;AAC1F,MAAM,WAAW,SAAS;IAAG,OAAO,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE;AAE5D;8EAC8E;AAC9E,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAAG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAAE;AAExF,kFA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AE,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAG9F;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,EAAE,CAWrE;AAED,gCAAgC;AAChC,wBAAgB,WAAW,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,WAAW,CAEtE;AAED;+DAC+D;AAC/D,wBAAgB,WAAW,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,UAAU,EAAE,CAQvE;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAM/F;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,gBAAgB,EAAE,CAa3E"}
package/dist/views.js CHANGED
@@ -62,7 +62,16 @@
62
62
  // - deliveryStatus(x) lists the outbox items whose digest or threadId is
63
63
  // x, by first submission, then digest; an unknown x lists none
64
64
  // - relationships: the entry's own (relIds), in that order; chainedFrom
65
- // the husks chained into each (chainedInto), by id
65
+ // the husks chained into each (chainedInto), by id; carrierNonce the
66
+ // canonical register entry under the relationship's id;
67
+ // counterpartDeliveryHints the deliveryHints of the counterparty card
68
+ // on the record of the relationship's first tuple, whose relId is the
69
+ // relationship's id (the enactment that opened it): a re-encounter's
70
+ // record names the husk it opened, so its card never replaces the
71
+ // first contact's hints. A chained relationship (a husk) is no
72
+ // RelationshipView of its own, only an id in chainedFrom: it shows no
73
+ // carrierNonce, because no adapter instance runs for it (profile
74
+ // RLTP-VTI-1230)
66
75
  // - a contact without a relationship breaks an invariant and throws
67
76
  import { freezeDeep } from './util-freeze.js';
68
77
  import { triasOf } from './state.js';
@@ -70,6 +79,7 @@ import { CLASSES, activeTuple, classOn, findContact, lags, trusted as isTrusted,
70
79
  import { sealedOn } from './trust/group-star.js';
71
80
  import { classOfDuty } from './trust/duties.js';
72
81
  import { messageChannel } from './message/holder.js';
82
+ import { canonicalCarrierNonce } from './identity-state.js';
73
83
  // ── helpers ────────────────────────────────────────────────────────────
74
84
  const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
75
85
  const cmpDec = (a, b) => { const x = BigInt(a), y = BigInt(b); return x < y ? -1 : x > y ? 1 : 0; };
@@ -119,6 +129,28 @@ const relationshipsOf = (state, c, ids, ix) => {
119
129
  }
120
130
  return { own, all };
121
131
  };
132
+ /** The counterparty card's delivery hints on the record that opened
133
+ * relationship `r`: the record of its first tuple's label (a chaining
134
+ * appends, so the first tuple stays the one the relationship opened with),
135
+ * found in the per-read label index. */
136
+ const firstHints = (r, rix) => {
137
+ const first = r.tuples[0];
138
+ const rec = first ? rix.get(first.ownPairLabel) : undefined;
139
+ if (!rec || rec.relId !== r.id)
140
+ return undefined;
141
+ const h = rec.card?.deliveryHints;
142
+ return Array.isArray(h) && h.length ? h.filter((x) => typeof x === 'string') : undefined;
143
+ };
144
+ const relationshipView = (state, r, rix) => {
145
+ const n = canonicalCarrierNonce(state.register, r.id);
146
+ const hints = firstHints(r, rix);
147
+ return {
148
+ id: r.id, tuples: r.tuples.length,
149
+ chainedFrom: Object.values(state.relationships).filter((x) => x.chainedInto === r.id).map((x) => x.id).sort(cmp),
150
+ ...(n ? { carrierNonce: { nonce: n.nonce, generation: n.generation } } : {}),
151
+ ...(hints ? { counterpartDeliveryHints: hints } : {}),
152
+ };
153
+ };
122
154
  const project = (state, c, ix, rix) => {
123
155
  const ids = new Set([c.id, ...c.aliases]);
124
156
  const { own, all: rels } = relationshipsOf(state, c, ids, ix);
@@ -166,10 +198,7 @@ const project = (state, c, ix, rix) => {
166
198
  commitSeq: state.commitSeq,
167
199
  id: c.id,
168
200
  aliases: [...c.aliases],
169
- relationships: own.map((r) => ({
170
- id: r.id, tuples: r.tuples.length,
171
- chainedFrom: Object.values(state.relationships).filter((x) => x.chainedInto === r.id).map((x) => x.id).sort(cmp),
172
- })),
201
+ relationships: own.map((r) => relationshipView(state, r, rix)),
173
202
  ...(profile?.name !== undefined ? { displayName: profile.name } : cardName !== undefined ? { displayName: cardName } : {}),
174
203
  provenance: origin.provenance.kind,
175
204
  ...(origin.provenance.kind === 'introduced' && origin.provenance.via !== undefined ? { via: origin.provenance.via } : {}),