@real-life/trust-protocol 0.3.2 → 0.5.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.
- package/CHANGELOG.md +97 -0
- package/README.md +209 -78
- package/dist/ack.d.ts +84 -0
- package/dist/ack.d.ts.map +1 -0
- package/dist/ack.js +114 -0
- package/dist/ack.js.map +1 -0
- package/dist/adapters/vti-mediator.d.ts +169 -0
- package/dist/adapters/vti-mediator.d.ts.map +1 -0
- package/dist/adapters/vti-mediator.js +659 -0
- package/dist/adapters/vti-mediator.js.map +1 -0
- package/dist/anchor.d.ts +226 -0
- package/dist/anchor.d.ts.map +1 -0
- package/dist/anchor.js +347 -0
- package/dist/anchor.js.map +1 -0
- package/dist/{holder.d.ts → carrier-holder.d.ts} +1 -1
- package/dist/carrier-holder.d.ts.map +1 -0
- package/dist/{holder.js → carrier-holder.js} +5 -4
- package/dist/carrier-holder.js.map +1 -0
- package/dist/carrier-identity.js +4 -4
- package/dist/carrier-identity.js.map +1 -1
- package/dist/carrier.d.ts.map +1 -1
- package/dist/carrier.js +4 -3
- package/dist/carrier.js.map +1 -1
- package/dist/ceremony.d.ts +3 -2
- package/dist/ceremony.d.ts.map +1 -1
- package/dist/ceremony.js +16 -26
- package/dist/ceremony.js.map +1 -1
- package/dist/codec.d.ts +54 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +494 -0
- package/dist/codec.js.map +1 -0
- package/dist/continuity.d.ts +67 -0
- package/dist/continuity.d.ts.map +1 -0
- package/dist/continuity.js +110 -0
- package/dist/continuity.js.map +1 -0
- package/dist/core.d.ts +4 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/crypto.d.ts +23 -7
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +54 -20
- package/dist/crypto.js.map +1 -1
- package/dist/delivery.d.ts +31 -3
- package/dist/delivery.d.ts.map +1 -1
- package/dist/delivery.js +75 -28
- package/dist/delivery.js.map +1 -1
- package/dist/encounter/ceremony.d.ts +37 -0
- package/dist/encounter/ceremony.d.ts.map +1 -0
- package/dist/encounter/ceremony.js +662 -0
- package/dist/encounter/ceremony.js.map +1 -0
- package/dist/encounter.d.ts +91 -1
- package/dist/encounter.d.ts.map +1 -1
- package/dist/encounter.js +191 -12
- package/dist/encounter.js.map +1 -1
- package/dist/engine.d.ts +303 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +1509 -0
- package/dist/engine.js.map +1 -0
- package/dist/entropy.d.ts +28 -0
- package/dist/entropy.d.ts.map +1 -0
- package/dist/entropy.js +96 -0
- package/dist/entropy.js.map +1 -0
- package/dist/events.d.ts +198 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/fixtures.d.ts +30 -0
- package/dist/fixtures.d.ts.map +1 -0
- package/dist/fixtures.js +155 -0
- package/dist/fixtures.js.map +1 -0
- package/dist/forge.d.ts +47 -0
- package/dist/forge.d.ts.map +1 -0
- package/dist/forge.js +20 -0
- package/dist/forge.js.map +1 -0
- package/dist/group-star.d.ts +251 -0
- package/dist/group-star.d.ts.map +1 -0
- package/dist/group-star.js +348 -0
- package/dist/group-star.js.map +1 -0
- package/dist/holder-api.d.ts +165 -0
- package/dist/holder-api.d.ts.map +1 -0
- package/dist/holder-api.js +142 -0
- package/dist/holder-api.js.map +1 -0
- package/dist/holder-state-v1.d.ts +801 -0
- package/dist/holder-state-v1.d.ts.map +1 -0
- package/dist/holder-state-v1.js +2 -0
- package/dist/holder-state-v1.js.map +1 -0
- package/dist/holder-state-v2.d.ts +858 -0
- package/dist/holder-state-v2.d.ts.map +1 -0
- package/dist/holder-state-v2.js +2 -0
- package/dist/holder-state-v2.js.map +1 -0
- package/dist/identity-state.d.ts +43 -0
- package/dist/identity-state.d.ts.map +1 -0
- package/dist/identity-state.js +345 -0
- package/dist/identity-state.js.map +1 -0
- package/dist/identity.d.ts +24 -2
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +70 -11
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -29
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +37 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +22 -0
- package/dist/internal.js.map +1 -0
- package/dist/introduction/holder.d.ts +18 -0
- package/dist/introduction/holder.d.ts.map +1 -0
- package/dist/introduction/holder.js +764 -0
- package/dist/introduction/holder.js.map +1 -0
- package/dist/introduction.d.ts +101 -0
- package/dist/introduction.d.ts.map +1 -0
- package/dist/introduction.js +132 -0
- package/dist/introduction.js.map +1 -0
- package/dist/invariants.d.ts +43 -0
- package/dist/invariants.d.ts.map +1 -0
- package/dist/invariants.js +953 -0
- package/dist/invariants.js.map +1 -0
- package/dist/keys-seed.d.ts +7 -0
- package/dist/keys-seed.d.ts.map +1 -0
- package/dist/keys-seed.js +133 -0
- package/dist/keys-seed.js.map +1 -0
- package/dist/log-memory.d.ts +12 -0
- package/dist/log-memory.d.ts.map +1 -0
- package/dist/log-memory.js +101 -0
- package/dist/log-memory.js.map +1 -0
- package/dist/membership/holder.d.ts +33 -0
- package/dist/membership/holder.d.ts.map +1 -0
- package/dist/membership/holder.js +929 -0
- package/dist/membership/holder.js.map +1 -0
- package/dist/membership.d.ts +123 -0
- package/dist/membership.d.ts.map +1 -0
- package/dist/membership.js +180 -0
- package/dist/membership.js.map +1 -0
- package/dist/message/holder.d.ts +49 -0
- package/dist/message/holder.d.ts.map +1 -0
- package/dist/message/holder.js +290 -0
- package/dist/message/holder.js.map +1 -0
- package/dist/message.d.ts +43 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +51 -0
- package/dist/message.js.map +1 -0
- package/dist/ports.d.ts +237 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +2 -0
- package/dist/ports.js.map +1 -0
- package/dist/profile.d.ts +56 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +193 -0
- package/dist/profile.js.map +1 -0
- package/dist/prompts.d.ts +14 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +69 -0
- package/dist/prompts.js.map +1 -0
- package/dist/receive.d.ts +134 -0
- package/dist/receive.d.ts.map +1 -0
- package/dist/receive.js +317 -0
- package/dist/receive.js.map +1 -0
- package/dist/results.d.ts +173 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +21 -0
- package/dist/results.js.map +1 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +45 -38
- package/dist/schemas.js.map +1 -1
- package/dist/sha256.d.ts +3 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +69 -0
- package/dist/sha256.js.map +1 -0
- package/dist/star.d.ts +31 -0
- package/dist/star.d.ts.map +1 -0
- package/dist/star.js +56 -0
- package/dist/star.js.map +1 -0
- package/dist/state-builder.d.ts +42 -0
- package/dist/state-builder.d.ts.map +1 -0
- package/dist/state-builder.js +100 -0
- package/dist/state-builder.js.map +1 -0
- package/dist/state.d.ts +914 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +37 -0
- package/dist/state.js.map +1 -0
- package/dist/store-contract.d.ts +11 -0
- package/dist/store-contract.d.ts.map +1 -0
- package/dist/store-contract.js +189 -0
- package/dist/store-contract.js.map +1 -0
- package/dist/store-memory.d.ts +8 -0
- package/dist/store-memory.d.ts.map +1 -0
- package/dist/store-memory.js +17 -0
- package/dist/store-memory.js.map +1 -0
- package/dist/testing.d.ts +22 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +21 -0
- package/dist/testing.js.map +1 -0
- package/dist/trust/continuity.d.ts +71 -0
- package/dist/trust/continuity.d.ts.map +1 -0
- package/dist/trust/continuity.js +1222 -0
- package/dist/trust/continuity.js.map +1 -0
- package/dist/trust/duties.d.ts +67 -0
- package/dist/trust/duties.d.ts.map +1 -0
- package/dist/trust/duties.js +179 -0
- package/dist/trust/duties.js.map +1 -0
- package/dist/trust/entries.d.ts +139 -0
- package/dist/trust/entries.d.ts.map +1 -0
- package/dist/trust/entries.js +795 -0
- package/dist/trust/entries.js.map +1 -0
- package/dist/trust/group-star.d.ts +43 -0
- package/dist/trust/group-star.d.ts.map +1 -0
- package/dist/trust/group-star.js +188 -0
- package/dist/trust/group-star.js.map +1 -0
- package/dist/trust/mapping.d.ts +56 -0
- package/dist/trust/mapping.d.ts.map +1 -0
- package/dist/trust/mapping.js +584 -0
- package/dist/trust/mapping.js.map +1 -0
- package/dist/trust/profile.d.ts +25 -0
- package/dist/trust/profile.d.ts.map +1 -0
- package/dist/trust/profile.js +249 -0
- package/dist/trust/profile.js.map +1 -0
- package/dist/trust/star.d.ts +208 -0
- package/dist/trust/star.d.ts.map +1 -0
- package/dist/trust/star.js +588 -0
- package/dist/trust/star.js.map +1 -0
- package/dist/trust/state.d.ts +83 -0
- package/dist/trust/state.d.ts.map +1 -0
- package/dist/trust/state.js +154 -0
- package/dist/trust/state.js.map +1 -0
- package/dist/util-freeze.d.ts +3 -0
- package/dist/util-freeze.d.ts.map +1 -0
- package/dist/util-freeze.js +11 -0
- package/dist/util-freeze.js.map +1 -0
- package/dist/views.d.ts +179 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +286 -0
- package/dist/views.js.map +1 -0
- package/dist/visibility.d.ts +5 -5
- package/dist/visibility.d.ts.map +1 -1
- package/dist/visibility.js +22 -28
- package/dist/visibility.js.map +1 -1
- package/dist/wire.d.ts +218 -83
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js.map +1 -1
- package/package.json +60 -10
- package/schemas/holder-state-v1.schema.json +3880 -0
- package/schemas/holder-state-v2.schema.json +4123 -0
- package/dist/holder.d.ts.map +0 -1
- package/dist/holder.js.map +0 -1
- package/dist/probe/acks.d.ts +0 -27
- package/dist/probe/acks.d.ts.map +0 -1
- package/dist/probe/acks.js +0 -152
- package/dist/probe/acks.js.map +0 -1
- package/dist/probe/continuity.d.ts +0 -20
- package/dist/probe/continuity.d.ts.map +0 -1
- package/dist/probe/continuity.js +0 -805
- package/dist/probe/continuity.js.map +0 -1
- package/dist/probe/deps.d.ts +0 -61
- package/dist/probe/deps.d.ts.map +0 -1
- package/dist/probe/deps.js +0 -54
- package/dist/probe/deps.js.map +0 -1
- package/dist/probe/encounter.d.ts +0 -26
- package/dist/probe/encounter.d.ts.map +0 -1
- package/dist/probe/encounter.js +0 -938
- package/dist/probe/encounter.js.map +0 -1
- package/dist/probe/introduce.d.ts +0 -62
- package/dist/probe/introduce.d.ts.map +0 -1
- package/dist/probe/introduce.js +0 -306
- package/dist/probe/introduce.js.map +0 -1
- package/dist/probe/membership.d.ts +0 -96
- package/dist/probe/membership.d.ts.map +0 -1
- package/dist/probe/membership.js +0 -467
- package/dist/probe/membership.js.map +0 -1
- package/dist/probe/trust.d.ts +0 -156
- package/dist/probe/trust.d.ts.map +0 -1
- package/dist/probe/trust.js +0 -1233
- package/dist/probe/trust.js.map +0 -1
- package/dist/probe.d.ts +0 -7
- package/dist/probe.d.ts.map +0 -1
- package/dist/probe.js +0 -42
- package/dist/probe.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vti-mediator.js","sourceRoot":"","sources":["../../src/adapters/vti-mediator.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,4EAA4E;AAC5E,EAAE;AACF,4EAA4E;AAC5E,8DAA8D;AAC9D,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AACxE,yEAAyE;AACzE,EAAE;AACF,qEAAqE;AACrE,kDAAkD;AAClD,0DAA0D;AAC1D,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,0EAA0E;AAC1E,oEAAoE;AACpE,oEAAoE;AACpE,8BAA8B;AAC9B,EAAE;AACF,kCAAkC;AAClC,6DAA6D;AAC7D,oEAAoE;AACpE,mDAAmD;AACnD,qEAAqE;AACrE,mEAAmE;AACnE,8DAA8D;AAC9D,uDAAuD;AAC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C,OAAO,CAAA,CAAC,CAAC;CAC/C;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,KAAiB,EAAmB,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA","sourcesContent":["// RLTP transport adapter: VTI mediator — published as\n// @real-life/trust-protocol/adapters/vti-mediator (lib Stage 2, note §4.6).\n//\n// Its reports reach the holder as the ports' DeliveryReport: submitOutbound\n// files an Outbound under its document digest and returns the\n// SubmissionRef (submission id ↔ digest); report(id) maps the adapter's\n// SubmissionState onto DeliveryReport (deliveryReportOf), which the app\n// hands to holder.report(). An adapter's `delivered` is its claim about\n// transport; the holder's receive core verifies the delivery-ack itself.\n//\n// Profile: spec/adapter-vti-mediator.md v0.23 (twenty-third casting;\n// round journals under design/adapter-review*). A\n// transport adapter contract — NOT a carrier at the port.\n//\n// Beyond the profile (lib 0.5.0): conclude(collection, now, {keep}) leaves\n// the items whose disposition is transient unconcluded and offers them\n// again (Delivery 0.82 RLTP-DEL-5810, 5820: failed(rate-limited) is never\n// concluded); `concludable(result)` says which receive outcomes are\n// terminal. The profile's §4 concludes a collection whole; its next\n// casting is to take this up.\n//\n// Structural rules (reviews 3+4):\n// · No port operation ever awaits the mediator — including\n// register: keylist synchronization is a recorded intent with a\n// tracked background task, retried by advance.\n// · No report is invented, and absence is ABSENT: before the first\n// honest report exists, status() returns null (§6.1 grants the\n// window; representing it as a queryable fourth value was\n// review-4 B2). has() distinguishes an unknown id.\n// · A retired instance mutates nothing and refuses everything\n// except reading its ack state.\n\nimport { jcs } from '../core.js'\nimport { sha } from '../crypto.js'\nimport { carrierPrincipal, carrierScopedIdentity } from '../carrier-identity.js'\nimport type { CarrierPrincipal, CarrierScopedIdentity } from '../carrier-identity.js'\nimport type { DeliveryReport, Outbound, ReceiverRefusalCode, SubmissionRef } from '../ports.js'\nimport type { ReceiveResult } from '../results.js'\nexport type { ReceiverRefusalCode } from '../ports.js'\n\n// ── Declared constants (profile §2) — promises of THIS casting ──────\n// frozen: the declared promises cannot be changed at run time either\nexport const DECLARED = Object.freeze({\n giveUpHorizonMs: 72 * 3_600_000,\n statusHorizonMs: 60_000,\n queueFloorCount: 64,\n queueFloorBytes: 1_048_576,\n maxQueueBytes: 16_777_216,\n duplicateWindowMs: 30 * 86_400_000,\n} as const)\n\n// ── The injected wire ────────────────────────────────────────────────\nexport type WireErrorKind =\n | 'unreachable' | 'refused-retriable' | 'refused-admission' | 'oversize'\n\nexport class WireError extends Error {\n kind: WireErrorKind\n constructor (kind: WireErrorKind, message?: string) {\n super(message ?? kind)\n this.kind = kind\n }\n}\n\nexport interface MediatorWire {\n authChallenge (did: string): Promise<{ challenge: string, sessionId: string }>\n authenticate (answer: { did: string, challenge: string, sessionId: string }): Promise<TokenSet>\n // A transient failure MUST be a WireError 'unreachable' or\n // 'refused-retriable' (the tokens are kept); any other error means the\n // mediator refused the refresh token (the adapter re-runs the handshake).\n refresh (refreshToken: string): Promise<TokenSet>\n keylistUpdate (accessToken: string, rkids: string[]): Promise<void>\n deposit (accessToken: string, bytes: Uint8Array, egressDid: string): Promise<void>\n ackReceived (accessToken: string, queueIds: string[]): Promise<void>\n onDeliver (cb: (bytes: Uint8Array) => Promise<void>): void\n /** Optional truthful connectivity signal; absent means unknown. */\n offline? (): boolean\n}\n\nexport interface TokenSet {\n accessToken: string\n accessExpiresAt: number\n refreshToken: string\n refreshExpiresAt: number\n}\n\n// ── Sender states (§6.1 — the closed sets, nothing else) ────────────\n// ReceiverRefusalCode is the ports' (one closed set, one place)\nconst RECEIVER_REFUSAL_CODES: ReadonlySet<ReceiverRefusalCode> = new Set<ReceiverRefusalCode>([\n 'malformedRequest', 'unsupportedType', 'proofRequired',\n 'proofInvalid', 'wrongRecipient', 'identityMismatch',\n])\n\nexport type SubmissionState =\n | { state: 'awaiting-transport', reason: 'offline' | 'transport-unreachable' | 'carrier-refused-retriable' }\n | { state: 'accepted' }\n | { state: 'delivered', late: boolean }\n | { state: 'failed', reason: 'unroutable' | 'oversize' | 'expired-by-adapter-policy' }\n | { state: 'failed', reason: 'rejected-by-receiver', code: ReceiverRefusalCode }\n\n/** The ports' DeliveryReport for a document `digest` in adapter state `st`\n * (Delivery §6.1): one-to-one, `late` and the refusal code carried over. */\nexport function deliveryReportOf (digest: string, st: SubmissionState): DeliveryReport {\n switch (st.state) {\n case 'awaiting-transport': return { digest, status: 'awaiting-transport', reason: st.reason }\n case 'accepted': return { digest, status: 'accepted' }\n case 'delivered': return { digest, status: 'delivered', late: st.late }\n case 'failed': return st.reason === 'rejected-by-receiver'\n ? { digest, status: 'failed', reason: 'rejected-by-receiver', code: st.code }\n : { digest, status: 'failed', reason: st.reason }\n }\n}\n\n/** Whether a receive outcome is terminal and its item may be concluded\n * (Delivery 5a.8): every disposition but `failed(rate-limited)`, the one\n * failure that is transient (RLTP-DEL-5820). An InfraError of the\n * holder's store is transient as well (RLTP-DEL-5810): an item whose\n * receive threw is kept, too. */\nexport function concludable (r: ReceiveResult): boolean {\n return !(r.disposition === 'failed' && r.reason === 'rate-limited')\n}\n\n/** The adapter's own copy of a wire's token set: the wire keeps no handle on it. */\nconst tokenCopy = (t: TokenSet): TokenSet => ({ accessToken: t.accessToken, accessExpiresAt: t.accessExpiresAt, refreshToken: t.refreshToken, refreshExpiresAt: t.refreshExpiresAt })\n\nexport interface CollectedItem { bytes: Uint8Array, queueId: string }\nexport interface Collection { id: string, items: CollectedItem[] }\n\n/** Ack state for the host to persist (profile §4). Invariant: every\n * pending id names a concluded entry; violations are refused at\n * construction (fail-closed). */\nexport interface AckState {\n concluded: Array<{ queueId: string, concludedAt: number }>\n pending: string[]\n}\n\ninterface Submission {\n /** the document digest, for submissions filed by submitOutbound */\n digest?: string\n bytes: Uint8Array\n submittedAt: number\n attemptStartedAt: number | null\n lastKind: WireErrorKind | null\n st: SubmissionState | null // null = no honest report exists yet\n}\n\nconst hex = (b: Uint8Array): string =>\n Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('')\n\n// construction capability: only create() holds it\nconst KEY = Symbol('MediatorCarrierAdapter.create')\n\n// ── The adapter ──────────────────────────────────────────────────────\nexport class MediatorCarrierAdapter {\n // JS-hard identity fields: TS `readonly` is a compile-time promise\n // only, and §8 claims runtime unforgeability — so the values live\n // in true privates behind getters (R8-B1)\n #principal: string\n #connectionDid: string\n #egressDid: string\n get principal (): string { return this.#principal }\n get connectionDid (): string { return this.#connectionDid }\n get egressDid (): string { return this.#egressDid }\n #wire: MediatorWire\n #tokens: TokenSet | null = null\n #clock = Number.NEGATIVE_INFINITY\n #closed = false\n\n #subs = new Map<string, Submission>()\n #inflight = new Set<Promise<void>>()\n #nextId = 1\n\n #desiredRkids: string[] | null = null\n #keylistSynced = false\n #keylistSyncing = false\n\n #inbox: CollectedItem[] = []\n #inboxBytes = 0\n #inboxDigests = new Set<string>()\n #outstanding = new Map<string, Map<string, CollectedItem>>()\n #outstandingBytes = 0\n #concluded = new Map<string, number>()\n #pendingAcks = new Set<string>()\n #flightAcks = new Set<string>() // ids inside the in-flight flush snapshot\n #flushing = false\n #nextColId = 1\n\n #transitions: Array<{ id: string, to: 'delivered' }> = []\n\n /** The only way to build an adapter: the trio is DERIVED here from\n * one root, one carrier, one nonce — so principal, connection DID\n * and egress identity cannot come from different relationships\n * (R7-B2: the coupling is enforced by construction, not by\n * inspecting caller-supplied identities). */\n static async create (\n rootIkm: Uint8Array, carrier: string, nonce: Uint8Array,\n wire: MediatorWire, restored?: AckState, restoredAt?: number,\n ): Promise<MediatorCarrierAdapter> {\n // ONE tuple, snapshotted at entry: a caller mutating its buffers\n // between the three awaited derivations must not be able to mix\n // identities from two tuples (R8-B2)\n const ikm = new Uint8Array(rootIkm)\n const n = new Uint8Array(nonce)\n const principal = await carrierPrincipal(ikm, carrier, n)\n const connection = await carrierScopedIdentity(ikm, carrier, n, 'connection')\n const egress = await carrierScopedIdentity(ikm, carrier, n, 'egress')\n return new MediatorCarrierAdapter(KEY, principal, connection, egress, wire, restored, restoredAt)\n }\n\n constructor (\n key: symbol,\n principal: CarrierPrincipal,\n connection: CarrierScopedIdentity,\n egress: CarrierScopedIdentity,\n wire: MediatorWire,\n restored?: AckState,\n restoredAt?: number,\n ) {\n if (key !== KEY) {\n throw new Error('use MediatorCarrierAdapter.create — the identity trio must be derived, not supplied (5a.10)')\n }\n if (connection.scope !== 'connection' || egress.scope !== 'egress') {\n throw new Error('scoped identities passed in the wrong roles')\n }\n const three = new Set([principal.principal, connection.did, egress.did])\n if (three.size !== 3) {\n throw new Error('principal, connection DID and egress identity must be pairwise distinct (5a.10)')\n }\n this.#principal = principal.principal\n this.#connectionDid = connection.did\n this.#egressDid = egress.did\n this.#wire = wire\n if (restored) {\n // The restore instant anchors the duplicate-window: an expired,\n // debt-free entry is dropped HERE, not at the first advance —\n // otherwise a redelivery arriving before any port call would be\n // absorbed beyond the declared window (review-4 B4).\n if (typeof restoredAt !== 'number' || !Number.isFinite(restoredAt)) {\n throw new Error('restoring ack state requires a finite restoredAt instant')\n }\n this.#now(restoredAt)\n const pending = new Set(restored.pending)\n const known = new Set(restored.concluded.map((c) => c.queueId))\n for (const id of pending) {\n if (!known.has(id)) {\n throw new Error('ack snapshot violates its invariant: pending intent without a concluded entry')\n }\n }\n for (const { queueId, concludedAt } of restored.concluded) {\n if (!Number.isFinite(concludedAt) || concludedAt > restoredAt) {\n // a conclusion \"from the future\" would stretch the window\n // past its declared span (R5-B4) — fail closed\n throw new Error('ack snapshot: conclusion instant is non-finite or after restoredAt')\n }\n // the window beats everything (round-14 B): an expired entry\n // falls at the restore instant, owed or not — a phantom debt\n // from an ack that landed just before a close can never\n // outlive the window and delete a fresh copy (R14-B2)\n if (restoredAt - concludedAt >= DECLARED.duplicateWindowMs) continue\n this.#concluded.set(queueId, concludedAt)\n if (pending.has(queueId)) this.#pendingAcks.add(queueId)\n }\n }\n this.#wire.onDeliver(async (raw) => {\n if (this.#closed) return\n // a plain copy of its own: a Node Buffer's slice() would share memory\n const bytes = new Uint8Array(raw)\n const queueId = hex(await sha(bytes))\n if (this.#closed) return\n // Absorption is WINDOW-checked at the moment it happens\n // (R11-B1), and the window beats everything (round-14 B):\n // beyond it, entry AND any leftover intent fall, and the frame\n // is a new item — so no acknowledgement, owed or phantom, can\n // ever delete the only fresh copy.\n const concludedAt = this.#concluded.get(queueId)\n if (concludedAt !== undefined) {\n if (this.#flightAcks.has(queueId) ||\n this.#clock - concludedAt < DECLARED.duplicateWindowMs) {\n // inside the window — or deferred: an id inside an\n // in-flight flush keeps absorbing until that flush ends,\n // because its irrecallable ack may still land (R15-B1)\n this.#pendingAcks.add(queueId)\n return\n }\n this.#concluded.delete(queueId)\n this.#pendingAcks.delete(queueId)\n }\n if (this.#inboxDigests.has(queueId)) return\n for (const col of this.#outstanding.values()) if (col.has(queueId)) return\n const held = this.#inboxBytes + this.#outstandingBytes\n const underFloor = this.#inbox.length < DECLARED.queueFloorCount &&\n held + bytes.length <= DECLARED.queueFloorBytes\n const underCap = held + bytes.length <= DECLARED.maxQueueBytes\n if (!underFloor && !underCap) return\n this.#inbox.push({ bytes, queueId })\n this.#inboxBytes += bytes.length\n this.#inboxDigests.add(queueId)\n })\n }\n\n #now (raw: number): number {\n if (!Number.isFinite(raw)) throw new Error('non-finite time')\n if (raw > this.#clock) this.#clock = raw\n return this.#clock\n }\n\n #open (): void { if (this.#closed) throw new Error('retired (5a.10 lifecycle)') }\n\n #track (p: Promise<void>): void {\n const t = p.catch(() => {})\n this.#inflight.add(t)\n void t.finally(() => this.#inflight.delete(t))\n }\n\n // ── auth: silent carrier policy ─────────────────────────────────\n // Single-flight: concurrent callers share one handshake — the ATM\n // challenge/response is a session, and two interleaved sessions\n // under one connection DID would answer each other's challenges.\n #authing: Promise<string> | null = null\n\n #ensureAuth (now: number): Promise<string> {\n if (this.#tokens && now < this.#tokens.accessExpiresAt) return Promise.resolve(this.#tokens.accessToken)\n if (this.#authing) return this.#authing\n const run = (async (): Promise<string> => {\n if (this.#tokens && now < this.#tokens.refreshExpiresAt) {\n try {\n const refreshed = await this.#wire.refresh(this.#tokens.refreshToken)\n if (this.#closed) throw new Error('retired') // as on the handshake path (R6-B1)\n this.#tokens = tokenCopy(refreshed)\n return this.#tokens.accessToken\n } catch (e) {\n if (this.#closed) throw e\n // a transient failure (mediator unreachable, retriable refusal)\n // says nothing about the token: keep it for the next attempt (#9)\n if (e instanceof WireError && (e.kind === 'unreachable' || e.kind === 'refused-retriable')) throw e\n // a refused refresh (revoked before its expiry) is never replayed:\n // drop the tokens and take the challenge handshake below\n this.#tokens = null\n }\n }\n const { challenge, sessionId } = await this.#wire.authChallenge(this.#connectionDid)\n if (this.#closed) throw new Error('retired') // nothing new starts, not even the answer (R6-B1)\n this.#tokens = tokenCopy(await this.#wire.authenticate({ did: this.#connectionDid, challenge, sessionId }))\n return this.#tokens.accessToken\n })()\n this.#authing = run.finally(() => { this.#authing = null })\n return this.#authing\n }\n\n // ── transport registration (profile §3 — NOT §5a.3) ─────────────\n /** Records the desired keylist and returns; synchronization runs\n * as a tracked background task and advance retries it until it\n * lands (review-4 B1). */\n register (rkids: string[], rawNow: number): void {\n this.#open()\n const now = this.#now(rawNow)\n this.#desiredRkids = [...rkids]\n this.#keylistSynced = false\n this.#startKeylistSync(now)\n }\n\n get keylistSynced (): boolean {\n this.#open()\n return this.#keylistSynced\n }\n\n #startKeylistSync (now: number): void {\n if (this.#keylistSyncing || this.#keylistSynced || this.#desiredRkids === null) return\n this.#keylistSyncing = true\n const wanted = [...this.#desiredRkids]\n this.#track((async () => {\n try {\n const token = await this.#ensureAuth(now)\n if (this.#closed) return\n await this.#wire.keylistUpdate(token, [...wanted]) // the wire's own list: `wanted` is compared below\n // land only if the desire has not moved meanwhile\n if (!this.#closed && this.#desiredRkids !== null &&\n wanted.join(' ') === this.#desiredRkids.join(' ')) {\n this.#keylistSynced = true\n }\n } catch {\n // intent survives; advance retries\n } finally {\n this.#keylistSyncing = false\n }\n })())\n }\n\n // ── sender side ─────────────────────────────────────────────────\n /** Returns the submission id synchronously. Before the first\n * honest report exists, status() returns null — §6.1's own\n * pre-report window, represented as absence, not as a value. */\n submit (envelopeBytes: Uint8Array, rawNow: number): string {\n this.#open()\n const now = this.#now(rawNow)\n const id = 's' + this.#nextId++\n const knownOffline = this.#wire.offline?.() === true\n const sub: Submission = {\n // a plain copy of its own (a Node Buffer's slice() shares memory)\n bytes: new Uint8Array(envelopeBytes),\n submittedAt: now,\n attemptStartedAt: null,\n lastKind: null,\n st: null,\n }\n this.#subs.set(id, sub)\n if (!knownOffline) this.#startAttempt(sub, now)\n return id\n }\n\n /** Files an Outbound (its envelope as JCS bytes) and returns the\n * SubmissionRef the holder's reports are keyed by: submission id ↔\n * document digest (note §4.3). */\n submitOutbound (outbound: Pick<Outbound, 'digest' | 'envelope'>, rawNow: number): SubmissionRef {\n this.#open()\n if (typeof outbound?.digest !== 'string' || outbound.digest === '') throw new Error('an outbound needs its document digest')\n const submissionId = this.submit(new TextEncoder().encode(jcs(outbound.envelope)), rawNow)\n this.#subs.get(submissionId)!.digest = outbound.digest\n return { submissionId, digest: outbound.digest }\n }\n\n /** The current state as the ports' DeliveryReport for holder.report(),\n * or null while no honest report exists (and for an unknown id). A\n * submission filed without a digest (submit) has no report form. */\n report (id: string): DeliveryReport | null {\n const st = this.status(id)\n if (st === null) return null\n const digest = this.#subs.get(id)!.digest\n if (digest === undefined) throw new Error('submitted without a document digest: use submitOutbound')\n return deliveryReportOf(digest, st)\n }\n\n has (id: string): boolean {\n this.#open()\n return this.#subs.has(id)\n }\n\n #startAttempt (sub: Submission, now: number): void {\n if (sub.attemptStartedAt !== null) return\n sub.attemptStartedAt = now\n this.#track(this.#trySend(sub, now).finally(() => { sub.attemptStartedAt = null }))\n }\n\n async #trySend (sub: Submission, now: number): Promise<void> {\n if (sub.st !== null && sub.st.state !== 'awaiting-transport') return\n let next: SubmissionState\n try {\n const token = await this.#ensureAuth(now)\n if (this.#closed) return // retirement between auth and deposit: nothing new starts (R5-B2)\n // each attempt hands the wire a copy: what it does with it never reaches the next\n await this.#wire.deposit(token, new Uint8Array(sub.bytes), this.#egressDid)\n sub.lastKind = null\n next = { state: 'accepted' }\n } catch (e) {\n const kind: WireErrorKind = e instanceof WireError ? e.kind : 'unreachable'\n sub.lastKind = kind\n next = kind === 'oversize'\n ? { state: 'failed', reason: 'oversize' }\n : {\n state: 'awaiting-transport',\n reason: kind === 'unreachable' ? 'transport-unreachable' : 'carrier-refused-retriable',\n }\n }\n if (this.#closed) return\n // An interim report (including a horizon-corrected one) never\n // outranks the attempt's real outcome; only a TERMINAL state —\n // a give-up, a refusal, a delivery — stands (R5-B1). Without\n // this, an accepted deposit would stay reported unreachable and\n // be sent a second time.\n if (sub.st === null || sub.st.state === 'awaiting-transport') sub.st = next\n }\n\n /** Host teardown aid, NOT a port operation (profile §6): awaits\n * the in-flight background tasks so a host can drain before\n * persisting ackState. On a hanging wire it waits as long as the\n * wire does — a host bounds it externally (Promise.race) exactly\n * because this library holds no clock of its own. */\n async settle (): Promise<void> {\n while (this.#inflight.size > 0) await Promise.all([...this.#inflight])\n }\n\n /** The §6.1 report, or null while none exists yet (has()\n * distinguishes an unknown id). status is a PORT: after close it\n * refuses like every other port operation (R5-B3).\n *\n * The pre-transport report is an HONEST SNAPSHOT, derived at the\n * moment of observation by one precedence order (Option B of the\n * round-14 halt) — never a stored patchwork:\n * (a) the wire knows itself offline → offline\n * (b) an attempt is overdue → transport-unreachable\n * (c) the last completed attempt's kind → its report\n * (d) otherwise → no report yet (null)\n * Terminal states and `accepted` are stored and stand. */\n status (id: string): SubmissionState | null {\n this.#open()\n const sub = this.#subs.get(id)\n if (!sub) return null\n if (sub.st !== null && sub.st.state !== 'awaiting-transport') return { ...sub.st }\n if (this.#wire.offline?.() === true) {\n return { state: 'awaiting-transport', reason: 'offline' }\n }\n if (sub.attemptStartedAt !== null &&\n this.#clock - sub.attemptStartedAt >= DECLARED.statusHorizonMs) {\n return { state: 'awaiting-transport', reason: 'transport-unreachable' }\n }\n return sub.st === null ? null : { ...sub.st }\n }\n\n acknowledged (id: string): void {\n if (this.#closed) return\n const sub = this.#subs.get(id)\n if (!sub) return\n if (sub.st?.state === 'delivered') return // idempotent: a duplicate ack never rewrites `late` (R9-M4)\n const late = sub.st?.state === 'failed'\n sub.st = { state: 'delivered', late }\n if (late) this.#transitions.push({ id, to: 'delivered' })\n }\n\n /** Refusals act on live submissions only (§6.1 knows exactly one\n * late correction — the valid ack). The code set is closed and\n * TERMINAL: retryable counterpart conditions (unavailable,\n * internalError) are transport outcomes, never receiver verdicts\n * — they have no entry here, and an unknown code is refused\n * fail-closed rather than minted into a verdict (R6-B2). */\n receiverRefused (id: string, code: ReceiverRefusalCode): void {\n if (this.#closed) return\n if (!RECEIVER_REFUSAL_CODES.has(code)) {\n throw new Error('not a terminal receiver refusal code — retryable conditions are transport outcomes')\n }\n const sub = this.#subs.get(id)\n if (!sub) return\n // A VALIDATED refusal is itself the proof of receipt — the\n // mediator can have accepted and forwarded while our deposit\n // promise is still unresolved, so the report-less phase is a\n // legitimate moment for it (R9-B2, reversing the R8-B3\n // overcorrection). Only terminal states stand against it.\n if (sub.st !== null && sub.st.state !== 'awaiting-transport' && sub.st.state !== 'accepted') return\n sub.st = { state: 'failed', reason: 'rejected-by-receiver', code }\n }\n\n drainTransitions (): Array<{ id: string, to: 'delivered' }> {\n this.#open()\n return this.#transitions.splice(0)\n }\n\n // ── receiver side ───────────────────────────────────────────────\n collect (rawNow: number): Collection {\n this.#open()\n this.#now(rawNow)\n if (this.#inbox.length === 0) return { id: 'c-empty', items: [] }\n const items = this.#inbox.splice(0)\n this.#outstandingBytes += this.#inboxBytes\n this.#inboxBytes = 0\n this.#inboxDigests.clear()\n const id = 'c' + this.#nextColId++\n this.#outstanding.set(id, new Map(items.map((i) => [i.queueId, i])))\n // the caller gets its own copies: the outstanding entries stay intact,\n // whatever it does with the bytes, for a conclusion that keeps them\n return { id, items: items.map((i) => ({ ...i, bytes: new Uint8Array(i.bytes) })) }\n }\n\n /** Concludes a collection (profile §4, Delivery 5a.8): its items'\n * digests become ack intent. `keep` names the items whose disposition\n * is transient (Delivery RLTP-DEL-5810, 5820: `failed(rate-limited)`,\n * or a transaction that could not commit, see `concludable`): they are\n * not concluded and not acknowledged, they go back to the buffer and the\n * next collect offers them again, and the mediator keeps its copy. */\n conclude (collection: { id: string }, rawNow: number, opts: { keep?: readonly string[] } = {}): void {\n this.#open()\n const now = this.#now(rawNow)\n const col = this.#outstanding.get(collection.id)\n if (!col) return\n this.#outstanding.delete(collection.id)\n const keep = new Set(opts.keep ?? [])\n for (const item of col.values()) {\n this.#outstandingBytes -= item.bytes.length\n if (keep.has(item.queueId)) {\n // transient: back to the buffer, offered again, never acknowledged\n this.#inbox.push(item)\n this.#inboxBytes += item.bytes.length\n this.#inboxDigests.add(item.queueId)\n continue\n }\n this.#concluded.set(item.queueId, now)\n this.#pendingAcks.add(item.queueId)\n }\n this.#startFlush(now)\n }\n\n ackState (): AckState {\n return {\n concluded: [...this.#concluded].map(([queueId, concludedAt]) => ({ queueId, concludedAt })),\n pending: [...this.#pendingAcks],\n }\n }\n\n #startFlush (now: number): void {\n if (this.#flushing || this.#pendingAcks.size === 0) return\n this.#flushing = true\n const snapshot = new Set(this.#pendingAcks)\n this.#track(this.#flushAcks(now, [...snapshot]).finally(() => {\n this.#flushing = false\n // lost-wake-up guard (review-4 M6): intents that arrived while\n // this flush ran get their own flush now — but only newcomers,\n // so a failing wire waits for the next advance instead of\n // spinning\n if (!this.#closed) {\n for (const id of this.#pendingAcks) {\n if (!snapshot.has(id)) { this.#startFlush(this.#clock); break }\n }\n }\n }))\n }\n\n async #flushAcks (now: number, ids: string[]): Promise<void> {\n try {\n const token = await this.#ensureAuth(now)\n if (this.#closed) return\n // Only NOW does anything become irrecallable (R16-B1): the\n // stay of expiry begins at the wire call itself, never at the\n // snapshot — a hanging auth extends no window. And \"live\" is\n // WINDOW-live (R17-B1): an entry whose window already closed —\n // even if no prune has swept it yet — is never sent.\n const live = ids.filter((id) => {\n const at = this.#concluded.get(id)\n return at !== undefined && this.#clock - at < DECLARED.duplicateWindowMs\n })\n if (live.length === 0) return\n for (const id of live) this.#flightAcks.add(id)\n try {\n // the wire gets its own list: what it does with it never reaches the bookkeeping below\n await this.#wire.ackReceived(token, [...live])\n if (!this.#closed) for (const id of live) this.#pendingAcks.delete(id)\n } finally {\n for (const id of live) this.#flightAcks.delete(id)\n // deferred window sweep: entries whose window closed while\n // the ack flew fall now — intent, entry and absorption\n // together (R15-B1). Never on a retired instance: after\n // close, ackState() is the host's final-persist surface and\n // a late-returning wire mutates nothing (R17-B2).\n if (!this.#closed) {\n for (const id of live) {\n const at = this.#concluded.get(id)\n if (at !== undefined && this.#clock - at >= DECLARED.duplicateWindowMs) {\n this.#concluded.delete(id)\n this.#pendingAcks.delete(id)\n }\n }\n }\n }\n } catch {\n // intent survives; the next advance starts a fresh flush\n }\n }\n\n // ── the adapter clock — never awaits the mediator ───────────────\n advance (rawNow: number): void {\n this.#open()\n const now = this.#now(rawNow)\n for (const sub of this.#subs.values()) {\n const live = sub.st === null || sub.st.state === 'awaiting-transport' || sub.st.state === 'accepted'\n if (!live) continue\n if (now - sub.submittedAt >= DECLARED.giveUpHorizonMs) {\n // unroutable only when the LAST COMPLETED attempt was an\n // admission refusal and no attempt is in flight whose outcome\n // is unknown (review-4 B3)\n // the give-up verdict applies the SAME precedence as every\n // observation (R17-B3): a wire that knows itself offline at\n // the horizon outranks any stored refusal class — unroutable\n // needs a completed admission refusal, no unknown outcome in\n // flight, AND no offline signal standing over it\n sub.st = {\n state: 'failed',\n reason: sub.lastKind === 'refused-admission' && sub.attemptStartedAt === null &&\n this.#wire.offline?.() !== true\n ? 'unroutable'\n : 'expired-by-adapter-policy',\n }\n continue\n }\n if (sub.st !== null && sub.st.state === 'accepted') continue\n // reports are DERIVED at observation (see status()); the clock\n // only decides here whether to start an attempt — and never\n // against a wire that knows itself offline\n if (this.#wire.offline?.() === true) continue\n if (sub.attemptStartedAt === null) this.#startAttempt(sub, now)\n }\n // THE WINDOW BEATS EVERYTHING (Option B of the round-14 halt):\n // an ack intent is retried until the window closes; then intent\n // and absorption fall together. There is no ageless debt whose\n // truth the adapter would have to know — the receiver's §6.2\n // absorption owns everything beyond the window.\n for (const [digest, at] of this.#concluded) {\n if (now - at >= DECLARED.duplicateWindowMs && !this.#flightAcks.has(digest)) {\n this.#concluded.delete(digest)\n this.#pendingAcks.delete(digest)\n }\n }\n this.#startKeylistSync(now)\n this.#startFlush(now)\n }\n\n /** §5a.10 lifecycle boundary: after close, every state port is\n * inert — port operations refuse, inbound reports (acknowledged,\n * receiverRefused) are no-ops, late wire resolutions mutate\n * nothing. Only ackState() stays readable for the host's final\n * persist. */\n close (): void { this.#closed = true }\n\n get closed (): boolean { return this.#closed }\n}\n\nexport const queueIdOf = async (bytes: Uint8Array): Promise<string> => hex(await sha(bytes))\n"]}
|
package/dist/anchor.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { Context } from './identity.js';
|
|
2
|
+
/** HMAC-SHA-256 over the UTF-8 bytes of msg, in the mac encoding (`u` + base64url). */
|
|
3
|
+
export declare function macU(keyBytes: Uint8Array, msg: string, subtle?: SubtleCrypto): Promise<string>;
|
|
4
|
+
/** Raw Ed25519 over JCS(body), `z` + base58btc — the abbreviated proof form of Trust §2.1 (no DI suite). */
|
|
5
|
+
export declare function signRaw(ctx: Pick<Context, 'ed'>, body: unknown, subtle?: SubtleCrypto): Promise<string>;
|
|
6
|
+
/** The raw proofValue form of an Ed25519 signature: `z` + base58btc (Trust §2.1). */
|
|
7
|
+
export declare const rawProofValue: (sig: Uint8Array) => string;
|
|
8
|
+
/** Verifies a raw Ed25519 proofValue over JCS(body) under a did:key anchor: exactly 64 bytes, canonical base58btc. */
|
|
9
|
+
export declare function verifyRaw(did: unknown, body: unknown, proofValue: unknown, subtle?: SubtleCrypto): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* The binding of an Ed25519 anchor: `u` + base64url of the sha2-256
|
|
12
|
+
* multihash (0x12 0x20 ‖ SHA-256) over its 34 multikey bytes 0xed 0x01 ‖
|
|
13
|
+
* pk — exactly the bytes the did:key identifier encodes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function bindingOf(anchor: string, subtle?: SubtleCrypto): Promise<string>;
|
|
16
|
+
/** Whether `anchor` meets the binding `commit`. */
|
|
17
|
+
export declare const meetsBinding: (anchor: string, commit: unknown, subtle?: SubtleCrypto) => Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* self-card@2 of a community-anchor context: its anchor, key-agreement
|
|
20
|
+
* key and the binding to `nextGen`, the generation after it; signed raw
|
|
21
|
+
* under the anchor.
|
|
22
|
+
*/
|
|
23
|
+
export declare function makeSelfCard(self: Context, nextGen: Context, subtle?: SubtleCrypto): Promise<{
|
|
24
|
+
body: {
|
|
25
|
+
type: string;
|
|
26
|
+
anchor: string;
|
|
27
|
+
keyAgreement: string;
|
|
28
|
+
commit: string;
|
|
29
|
+
};
|
|
30
|
+
proof: {
|
|
31
|
+
proofValue: string;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* The link from the current community anchor (prev) to the next
|
|
36
|
+
* generation of the same digest (next), carrying the binding of next to
|
|
37
|
+
* the generation after it (after): both contexts sign the same canonical
|
|
38
|
+
* body. A rotation moves to exactly g + 1 (Trust 6330, Identity §5.4).
|
|
39
|
+
*/
|
|
40
|
+
export declare function makeAnchorRotation(prev: Context, next: Context, after: Context, subtle?: SubtleCrypto): Promise<{
|
|
41
|
+
body: {
|
|
42
|
+
type: string;
|
|
43
|
+
prev: string;
|
|
44
|
+
next: string;
|
|
45
|
+
commit: string;
|
|
46
|
+
};
|
|
47
|
+
proof: {
|
|
48
|
+
proofValue: string;
|
|
49
|
+
successorProofValue: string;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Schema, next ≠ prev, and both signatures — prev's and next's — over
|
|
54
|
+
* the canonical body; with `heldBinding` (the binding held for prev),
|
|
55
|
+
* also that next meets it (§6.3 condition 4b).
|
|
56
|
+
*/
|
|
57
|
+
export declare function verifyAnchorRotation(a: any, heldBinding?: string, subtle?: SubtleCrypto): Promise<boolean>;
|
|
58
|
+
/** A mapping carries at most this many of the most recent links (§6.1; schema maxItems). */
|
|
59
|
+
export declare const LINEAGE_MAX = 64;
|
|
60
|
+
/**
|
|
61
|
+
* Condition 4a, the chain as given: at most LINEAGE_MAX elements; every
|
|
62
|
+
* element verifies under both its signatures; each prev equals the
|
|
63
|
+
* preceding element's next; the last next equals self. An empty lineage
|
|
64
|
+
* passes: the sender presents no history. The bindings are condition 4b
|
|
65
|
+
* (verifyBindings).
|
|
66
|
+
*/
|
|
67
|
+
export declare function verifyLineage(lineage: any[], self: string, subtle?: SubtleCrypto): Promise<{
|
|
68
|
+
ok: true;
|
|
69
|
+
} | {
|
|
70
|
+
ok: false;
|
|
71
|
+
reason: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Condition 4b, pre-rotation (Trust 6115): each element after the first
|
|
75
|
+
* names a next that meets the commit of the element before it; where the
|
|
76
|
+
* lineage is not empty, card.commit equals the commit of its last
|
|
77
|
+
* element; and for every anchor for which the relationship holds a
|
|
78
|
+
* binding (`held`, 6610), an element whose prev is that anchor names a
|
|
79
|
+
* next that meets it, and a card whose anchor is that anchor carries it
|
|
80
|
+
* as commit.
|
|
81
|
+
*/
|
|
82
|
+
export declare function verifyBindings(body: {
|
|
83
|
+
lineage: any[];
|
|
84
|
+
card: any;
|
|
85
|
+
}, held?: Map<string, string>, subtle?: SubtleCrypto): Promise<{
|
|
86
|
+
ok: true;
|
|
87
|
+
} | {
|
|
88
|
+
ok: false;
|
|
89
|
+
reason: string;
|
|
90
|
+
rule: 'RLTP-TRU-6115' | 'RLTP-TRU-6117' | 'RLTP-TRU-6118';
|
|
91
|
+
}>;
|
|
92
|
+
/** Every anchor a lineage names, in chain order: the first prev, then each next. */
|
|
93
|
+
export declare const lineageAnchors: (lineage: any[]) => string[];
|
|
94
|
+
/**
|
|
95
|
+
* The verified anchor set of a mapping (§6a.1 rung 2): its self and every
|
|
96
|
+
* anchor of its carried lineage, in chain order, self last. Two
|
|
97
|
+
* relationships converge when these sets meet.
|
|
98
|
+
*/
|
|
99
|
+
export declare const mappingAnchors: (body: {
|
|
100
|
+
self: string;
|
|
101
|
+
lineage: any[];
|
|
102
|
+
}) => string[];
|
|
103
|
+
/** The links prev → next a lineage carries, in chain order. */
|
|
104
|
+
export declare const lineageLinks: (lineage: any[]) => [string, string][];
|
|
105
|
+
/**
|
|
106
|
+
* The pre-rotation bindings a verified mapping states (Trust 6610): the
|
|
107
|
+
* commit of each lineage element as the binding of its next, card.commit
|
|
108
|
+
* as the binding of self, and, for the prev of each link, the binding
|
|
109
|
+
* computed over that link's next.
|
|
110
|
+
*/
|
|
111
|
+
export declare function mappingBindings(body: {
|
|
112
|
+
self: string;
|
|
113
|
+
lineage: any[];
|
|
114
|
+
card: any;
|
|
115
|
+
}, subtle?: SubtleCrypto): Promise<Map<string, string>>;
|
|
116
|
+
/**
|
|
117
|
+
* §6.3 condition 8 against the `self` this relationship holds (6150):
|
|
118
|
+
* 'first' where it holds none, 'same' where `self` is unchanged,
|
|
119
|
+
* 'rotation' where a changed `self` comes with a carried segment that
|
|
120
|
+
* has the held self as the `prev` of one of its elements (6160), and
|
|
121
|
+
* 'rejected' otherwise (6170): a change of `self` that no carried segment
|
|
122
|
+
* links to the held one is rejected like every mapping that fails a
|
|
123
|
+
* condition, with the current state kept — also after more than 64
|
|
124
|
+
* missed rotations (6400). Condition 4b has already refused a segment
|
|
125
|
+
* that names another successor of an anchor whose binding the
|
|
126
|
+
* relationship holds.
|
|
127
|
+
*/
|
|
128
|
+
export declare function classifyMapping(heldSelf: string | undefined, body: {
|
|
129
|
+
self: string;
|
|
130
|
+
lineage: any[];
|
|
131
|
+
}): 'first' | 'same' | 'rotation' | 'rejected';
|
|
132
|
+
export interface MappingInput {
|
|
133
|
+
/** the sender's own pair context of the relationship */
|
|
134
|
+
pair: Context;
|
|
135
|
+
/** the addressee's pair anchor and key-agreement key in this relationship */
|
|
136
|
+
to: string;
|
|
137
|
+
toKeyAgreement: string;
|
|
138
|
+
/** the sender's CURRENT community anchor */
|
|
139
|
+
self: Context;
|
|
140
|
+
/** the generation after self — its binding is the card's commit */
|
|
141
|
+
nextGen: Context;
|
|
142
|
+
/** at most LINEAGE_MAX anchor-rotation@2 artifacts, in chain order, ending at self (or empty) */
|
|
143
|
+
lineage: any[];
|
|
144
|
+
revision: string;
|
|
145
|
+
issuedAt: string;
|
|
146
|
+
}
|
|
147
|
+
/** The two MACs of an anchor-mapping@4 over JCS(body) (Trust 6030), from
|
|
148
|
+
* the two shared secrets: sh1 = ECDH(pairX of the sender, pairX of the
|
|
149
|
+
* addressee), sh2 = ECDH(selfX of the sender, pairX of the addressee). */
|
|
150
|
+
export declare function assembleAnchorMapping<B extends object>(body: B, sh1: Uint8Array, sh2: Uint8Array, subtle?: SubtleCrypto): Promise<{
|
|
151
|
+
body: B;
|
|
152
|
+
proof: {
|
|
153
|
+
mac1: string;
|
|
154
|
+
mac2: string;
|
|
155
|
+
};
|
|
156
|
+
}>;
|
|
157
|
+
/** anchor-mapping@4: body { type, pair, self, to, card, lineage, revision, issuedAt }; mac1 (relationship key, map1) and mac2 (selfX × pairX of the addressee, map2) over JCS(body). */
|
|
158
|
+
export declare function buildAnchorMapping(i: MappingInput, subtle?: SubtleCrypto): Promise<{
|
|
159
|
+
body: {
|
|
160
|
+
type: string;
|
|
161
|
+
pair: string;
|
|
162
|
+
self: string;
|
|
163
|
+
to: string;
|
|
164
|
+
card: {
|
|
165
|
+
body: {
|
|
166
|
+
type: string;
|
|
167
|
+
anchor: string;
|
|
168
|
+
keyAgreement: string;
|
|
169
|
+
commit: string;
|
|
170
|
+
};
|
|
171
|
+
proof: {
|
|
172
|
+
proofValue: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
lineage: any[];
|
|
176
|
+
revision: string;
|
|
177
|
+
issuedAt: string;
|
|
178
|
+
};
|
|
179
|
+
proof: {
|
|
180
|
+
mac1: string;
|
|
181
|
+
mac2: string;
|
|
182
|
+
};
|
|
183
|
+
}>;
|
|
184
|
+
/** §6.3 conditions 1–7 as numbered by verifyAnchorMapping, with the rule
|
|
185
|
+
* each one is; for 4b the result's `rule` names the one of 6115, 6117,
|
|
186
|
+
* 6118 that failed. */
|
|
187
|
+
export declare const MAPPING_CONDITION_RULE: Readonly<Record<string, string>>;
|
|
188
|
+
/**
|
|
189
|
+
* §6.3, the closed list, evaluated in its order: 1 schema (anchor-mapping
|
|
190
|
+
* @1 to @3 are not implemented and fail here) · 2 to = own pair anchor ·
|
|
191
|
+
* 3 pair = the arrival tuple's counterpart · 4 the card verifies under
|
|
192
|
+
* its own anchor · 4a the lineage chain · 4b pre-rotation, against the
|
|
193
|
+
* bindings this relationship holds (`held`, 6610) · 5 card.anchor = self ·
|
|
194
|
+
* 6 k2 from card.keyAgreement · 7 both MACs. Revision (8) is the
|
|
195
|
+
* holder's state. The addressee's own pair key acts through `agree`: the
|
|
196
|
+
* raw X25519 shared secret with a raw public key, or null where none is
|
|
197
|
+
* usable (condition 7); a throw is a failure of condition 1, as in
|
|
198
|
+
* verifyAnchorMapping.
|
|
199
|
+
*/
|
|
200
|
+
export declare function verifyAnchorMappingWith(m: any, at: {
|
|
201
|
+
ownAnchor: string;
|
|
202
|
+
pair: string;
|
|
203
|
+
pairKeyAgreement: string;
|
|
204
|
+
held?: Map<string, string>;
|
|
205
|
+
agree: (theirX: Uint8Array) => Promise<Uint8Array | null>;
|
|
206
|
+
}, subtle?: SubtleCrypto): Promise<{
|
|
207
|
+
ok: true;
|
|
208
|
+
} | {
|
|
209
|
+
ok: false;
|
|
210
|
+
step: string;
|
|
211
|
+
rule?: string;
|
|
212
|
+
}>;
|
|
213
|
+
/** verifyAnchorMappingWith over the addressee's own pair Context; names
|
|
214
|
+
* the failed condition by its step only. */
|
|
215
|
+
export declare function verifyAnchorMapping(m: any, at: {
|
|
216
|
+
own: Context;
|
|
217
|
+
pair: string;
|
|
218
|
+
pairKeyAgreement: string;
|
|
219
|
+
held?: Map<string, string>;
|
|
220
|
+
}, subtle?: SubtleCrypto): Promise<{
|
|
221
|
+
ok: true;
|
|
222
|
+
} | {
|
|
223
|
+
ok: false;
|
|
224
|
+
step: string;
|
|
225
|
+
}>;
|
|
226
|
+
//# sourceMappingURL=anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../src/anchor.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAQ5C,uFAAuF;AACvF,wBAAsB,IAAI,CAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG1G;AACD,4GAA4G;AAC5G,wBAAsB,OAAO,CAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAE,YAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnH;AACD,qFAAqF;AACrF,eAAO,MAAM,aAAa,GAAI,KAAK,UAAU,KAAG,MAA2B,CAAA;AAC3E,sHAAsH;AACtH,wBAAsB,SAAS,CAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAU1H;AAGD;;;;GAIG;AACH,wBAAsB,SAAS,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAKvF;AACD,mDAAmD;AACnD,eAAO,MAAM,YAAY,GAAU,QAAQ,MAAM,EA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