@real-life/trust-protocol 0.4.0 → 0.6.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +91 -24
  3. package/dist/adapters/vti-mediator.d.ts +36 -8
  4. package/dist/adapters/vti-mediator.d.ts.map +1 -1
  5. package/dist/adapters/vti-mediator.js +193 -29
  6. package/dist/adapters/vti-mediator.js.map +1 -1
  7. package/dist/codec.d.ts +2 -1
  8. package/dist/codec.d.ts.map +1 -1
  9. package/dist/codec.js +75 -26
  10. package/dist/codec.js.map +1 -1
  11. package/dist/engine.d.ts +77 -4
  12. package/dist/engine.d.ts.map +1 -1
  13. package/dist/engine.js +419 -31
  14. package/dist/engine.js.map +1 -1
  15. package/dist/entropy.d.ts +1 -1
  16. package/dist/entropy.d.ts.map +1 -1
  17. package/dist/entropy.js +1 -1
  18. package/dist/entropy.js.map +1 -1
  19. package/dist/events.d.ts +21 -0
  20. package/dist/events.d.ts.map +1 -1
  21. package/dist/events.js.map +1 -1
  22. package/dist/holder-api.d.ts +44 -2
  23. package/dist/holder-api.d.ts.map +1 -1
  24. package/dist/holder-api.js +40 -5
  25. package/dist/holder-api.js.map +1 -1
  26. package/dist/{holder-state-v1.d.ts → holder-state-v3.d.ts} +261 -201
  27. package/dist/holder-state-v3.d.ts.map +1 -0
  28. package/dist/holder-state-v3.js +2 -0
  29. package/dist/holder-state-v3.js.map +1 -0
  30. package/dist/index.d.ts +3 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +10 -6
  33. package/dist/index.js.map +1 -1
  34. package/dist/internal.d.ts +2 -2
  35. package/dist/internal.d.ts.map +1 -1
  36. package/dist/internal.js +1 -1
  37. package/dist/internal.js.map +1 -1
  38. package/dist/introduction/holder.d.ts.map +1 -1
  39. package/dist/introduction/holder.js +7 -0
  40. package/dist/introduction/holder.js.map +1 -1
  41. package/dist/invariants.d.ts.map +1 -1
  42. package/dist/invariants.js +70 -0
  43. package/dist/invariants.js.map +1 -1
  44. package/dist/membership/holder.d.ts +3 -5
  45. package/dist/membership/holder.d.ts.map +1 -1
  46. package/dist/membership/holder.js +165 -88
  47. package/dist/membership/holder.js.map +1 -1
  48. package/dist/membership.d.ts +31 -0
  49. package/dist/membership.d.ts.map +1 -1
  50. package/dist/membership.js +25 -2
  51. package/dist/membership.js.map +1 -1
  52. package/dist/message/holder.d.ts +49 -0
  53. package/dist/message/holder.d.ts.map +1 -0
  54. package/dist/message/holder.js +290 -0
  55. package/dist/message/holder.js.map +1 -0
  56. package/dist/message.d.ts +43 -0
  57. package/dist/message.d.ts.map +1 -0
  58. package/dist/message.js +51 -0
  59. package/dist/message.js.map +1 -0
  60. package/dist/receive.d.ts +4 -3
  61. package/dist/receive.d.ts.map +1 -1
  62. package/dist/receive.js +23 -4
  63. package/dist/receive.js.map +1 -1
  64. package/dist/results.d.ts +22 -3
  65. package/dist/results.d.ts.map +1 -1
  66. package/dist/results.js.map +1 -1
  67. package/dist/schemas.d.ts.map +1 -1
  68. package/dist/schemas.js +9 -6
  69. package/dist/schemas.js.map +1 -1
  70. package/dist/state.d.ts +88 -14
  71. package/dist/state.d.ts.map +1 -1
  72. package/dist/state.js +2 -1
  73. package/dist/state.js.map +1 -1
  74. package/dist/trust/continuity.d.ts.map +1 -1
  75. package/dist/trust/continuity.js +7 -1
  76. package/dist/trust/continuity.js.map +1 -1
  77. package/dist/trust/entries.d.ts.map +1 -1
  78. package/dist/trust/entries.js +103 -2
  79. package/dist/trust/entries.js.map +1 -1
  80. package/dist/views.d.ts +34 -2
  81. package/dist/views.d.ts.map +1 -1
  82. package/dist/views.js +19 -1
  83. package/dist/views.js.map +1 -1
  84. package/dist/wire.d.ts +47 -6
  85. package/dist/wire.d.ts.map +1 -1
  86. package/dist/wire.js.map +1 -1
  87. package/package.json +6 -4
  88. package/schemas/{holder-state-v1.schema.json → holder-state-v3.schema.json} +300 -12
  89. package/dist/holder-state-v1.d.ts.map +0 -1
  90. package/dist/holder-state-v1.js +0 -2
  91. package/dist/holder-state-v1.js.map +0 -1
package/dist/entropy.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** What a random value is for. Star salts are counters, not entropy. */
2
- export type EntropyPurpose = 'seal.eph' | 'seal.nonce' | 'doc.id' | 'thread.id' | 'ack.id' | 'challenge' | 'group.seed' | 'founding.nonce' | 'intro.act' | 'intro.target' | 'groupstar.nonce' | 'pad';
2
+ export type EntropyPurpose = 'seal.eph' | 'seal.nonce' | 'doc.id' | 'thread.id' | 'ack.id' | 'challenge' | 'group.seed' | 'founding.nonce' | 'intro.act' | 'message.mid' | 'intro.target' | 'groupstar.nonce' | 'pad';
3
3
  export declare const ENTROPY_PURPOSES: readonly EntropyPurpose[];
4
4
  export interface Entropy {
5
5
  /** n fresh bytes for `purpose`; a new buffer every call */
@@ -1 +1 @@
1
- {"version":3,"file":"entropy.d.ts","sourceRoot":"","sources":["../src/entropy.ts"],"names":[],"mappings":"AAYA,wEAAwE;AACxE,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,WAAW,GACX,cAAc,GACd,iBAAiB,GACjB,KAAK,CAAA;AAET,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAGpD,CAAA;AAEF,MAAM,WAAW,OAAO;IACtB,2DAA2D;IAC3D,KAAK,CAAE,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACtD,qEAAqE;IACrE,EAAE,CAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAAA;CACrC;AAED,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE9E,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,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AC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;gBACX,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMtE;AAeD,8EAA8E;AAC9E,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,CAAC,CAAA;AAE3E,wBAAgB,aAAa,CAAE,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAiBxE;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;AAE7G;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CA0B/D"}
package/dist/entropy.js CHANGED
@@ -11,7 +11,7 @@
11
11
  // (test/entropy-lint.test.mjs enforces it).
12
12
  export const ENTROPY_PURPOSES = Object.freeze([
13
13
  'seal.eph', 'seal.nonce', 'doc.id', 'thread.id', 'ack.id', 'challenge',
14
- 'group.seed', 'founding.nonce', 'intro.act', 'intro.target', 'groupstar.nonce', 'pad',
14
+ 'group.seed', 'founding.nonce', 'intro.act', 'intro.target', 'groupstar.nonce', 'pad', 'message.mid',
15
15
  ]);
16
16
  export class EntropyError extends Error {
17
17
  code;
@@ -1 +1 @@
1
- {"version":3,"file":"entropy.js","sourceRoot":"","sources":["../src/entropy.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,uDAAuD;AACvD,EAAE;AACF,uEAAuE;AACvE,4CAA4C;AAiB5C,MAAM,CAAC,MAAM,gBAAgB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACvE,UAAU,EAAE,YAAY,EAAE,QAAQ,E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§3).\n//\n// Randomness by closed purpose: every value the library draws names\n// what it is for, so a scripted run replays per purpose rather than by\n// position in one byte stream. No domain decisions travel here: group\n// rules are group state, human choices are act input. Entropy is drawn\n// fresh per preparation; after a version conflict an act is prepared\n// again, never a nonce reused under another plaintext.\n//\n// This is the ONLY file in src/ that touches the platform's generators\n// (test/entropy-lint.test.mjs enforces it).\n\n/** What a random value is for. Star salts are counters, not entropy. */\nexport type EntropyPurpose =\n | 'seal.eph' // ephemeral X25519 seed of an envelope (Delivery §5)\n | 'seal.nonce' // AES-GCM nonce of an envelope (Delivery §5), every outer seal\n | 'doc.id' // document id (uuid)\n | 'thread.id' // thread id (uuid)\n | 'ack.id' // delivery-ack document id (uuid)\n | 'challenge' // encounter challenge bytes\n | 'group.seed' // group address seed at founding\n | 'founding.nonce' // relationship / group founding nonce (Identity §6.1, §7a.3)\n | 'intro.act' // an introduction act id, 32 bytes (Trust 8070)\n | 'intro.target' // a mediator's target designator, 32 bytes (Trust 8610)\n | 'groupstar.nonce' // AEAD nonce of a group-star `c` (5.2b)\n | 'pad' // padding and filler bytes\n\nexport const ENTROPY_PURPOSES: readonly EntropyPurpose[] = Object.freeze([\n 'seal.eph', 'seal.nonce', 'doc.id', 'thread.id', 'ack.id', 'challenge',\n 'group.seed', 'founding.nonce', 'intro.act', 'intro.target', 'groupstar.nonce', 'pad',\n])\n\nexport interface Entropy {\n /** n fresh bytes for `purpose`; a new buffer every call */\n bytes (purpose: EntropyPurpose, n: number): Uint8Array\n /** a fresh identifier for `purpose` (lowercase UUIDv4 by default) */\n id (purpose: EntropyPurpose): string\n}\n\nexport type EntropyErrorCode = 'exhausted' | 'mismatch' | 'purpose' | 'length'\n\nexport class EntropyError extends Error {\n readonly code: EntropyErrorCode\n readonly purpose: string\n constructor (code: EntropyErrorCode, purpose: string, message: string) {\n super(`entropy ${code} (${purpose}): ${message}`)\n this.name = 'EntropyError'\n this.code = code\n this.purpose = purpose\n }\n}\n\nconst PURPOSES: ReadonlySet<string> = new Set(ENTROPY_PURPOSES)\nconst checkPurpose = (purpose: string): void => {\n if (!PURPOSES.has(purpose)) throw new EntropyError('purpose', purpose, 'not an entropy purpose')\n}\nconst checkLength = (purpose: string, n: number): void => {\n if (!Number.isSafeInteger(n) || n < 0) throw new EntropyError('length', purpose, `invalid length ${n}`)\n}\n\nimport { CryptoUnavailableError } from './results.js'\n\n// getRandomValues fills at most 65536 bytes per call\nconst QUOTA = 65536\n\n/** Platform randomness; the crypto handle is resolved here, not at import. */\n/** The platform generators a crypto handle offers to randomEntropy. */\nexport type PlatformRandom = Pick<Crypto, 'getRandomValues' | 'randomUUID'>\n\nexport function randomEntropy (handle?: Partial<PlatformRandom>): Entropy {\n const c = handle ?? (globalThis.crypto as Partial<Crypto> | undefined)\n const missing = (['getRandomValues', 'randomUUID'] as const).filter((m) => typeof c?.[m] !== 'function')\n if (missing.length || !c) throw new CryptoUnavailableError(missing)\n const gen = c as PlatformRandom\n return {\n bytes (purpose, n) {\n checkPurpose(purpose); checkLength(purpose, n)\n const out = new Uint8Array(n)\n for (let i = 0; i < n; i += QUOTA) gen.getRandomValues(out.subarray(i, Math.min(n, i + QUOTA)))\n return out\n },\n id (purpose) {\n checkPurpose(purpose)\n return gen.randomUUID()\n },\n }\n}\n\nexport type EntropyScript = Partial<Record<EntropyPurpose, Uint8Array | string | Array<Uint8Array | string>>>\n\n/**\n * Scripted entropy for vectors and tests: each purpose yields its values\n * in order (a single value is a list of one) and throws 'exhausted' when\n * it runs dry. bytes() needs a Uint8Array of exactly n bytes, id() a\n * string — anything else is 'mismatch'. Values are copied in and out.\n */\nexport function scriptedEntropy (script: EntropyScript): Entropy {\n const queues = new Map<string, Array<Uint8Array | string>>()\n for (const [purpose, v] of Object.entries(script)) {\n checkPurpose(purpose)\n if (v === undefined) continue\n queues.set(purpose, (Array.isArray(v) ? v : [v]).map((x) => (x instanceof Uint8Array ? new Uint8Array(x) : x)))\n }\n const next = (purpose: string): Uint8Array | string => {\n checkPurpose(purpose)\n const q = queues.get(purpose)\n if (!q || q.length === 0) throw new EntropyError('exhausted', purpose, 'script ran dry')\n return q.shift()!\n }\n return {\n bytes (purpose, n) {\n checkLength(purpose, n)\n const v = next(purpose)\n if (!(v instanceof Uint8Array) || v.length !== n) throw new EntropyError('mismatch', purpose, `expected ${n} bytes`)\n return new Uint8Array(v)\n },\n id (purpose) {\n const v = next(purpose)\n if (typeof v !== 'string') throw new EntropyError('mismatch', purpose, 'expected a string id')\n return v\n },\n }\n}\n"]}
1
+ {"version":3,"file":"entropy.js","sourceRoot":"","sources":["../src/entropy.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,uDAAuD;AACvD,EAAE;AACF,uEAAuE;AACvE,4CAA4C;AAkB5C,MAAM,CAAC,MAAM,gBAAgB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACvE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW;IACtE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa;CACrG,CAAC,CAAA;AAWF,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAkB;IACtB,OAAO,CAAQ;IACxB,YAAa,IAAsB,EAAE,OAAe,EAAE,OAAe;QACnE,KAAK,CAAC,WAAW,IAAI,KAAK,OAAO,MAAM,OAAO,EAAE,CAAC,CAAA;QACjD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAA;AAC/D,MAAM,YAAY,GAAG,CAAC,OAAe,EAAQ,EAAE;IAC7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KAAK,CAAE,OAAO,EAAE,CAAC;YACf,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YACvB,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;YACvB,IAAI,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;YACpH,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;QAC1B,CAAC;QACD,EAAE,CAAE,OAAO;YACT,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;YACvB,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAA;YAC9F,OAAO,CAAC,CAAA;QACV,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["// entropy — the Entropy port (lib Stage 2, note §3).\n//\n// Randomness by closed purpose: every value the library draws names\n// what it is for, so a scripted run replays per purpose rather than by\n// position in one byte stream. No domain decisions travel here: group\n// rules are group state, human choices are act input. Entropy is drawn\n// fresh per preparation; after a version conflict an act is prepared\n// again, never a nonce reused under another plaintext.\n//\n// This is the ONLY file in src/ that touches the platform's generators\n// (test/entropy-lint.test.mjs enforces it).\n\n/** What a random value is for. Star salts are counters, not entropy. */\nexport type EntropyPurpose =\n | 'seal.eph' // ephemeral X25519 seed of an envelope (Delivery §5)\n | 'seal.nonce' // AES-GCM nonce of an envelope (Delivery §5), every outer seal\n | 'doc.id' // document id (uuid)\n | 'thread.id' // thread id (uuid)\n | 'ack.id' // delivery-ack document id (uuid)\n | 'challenge' // encounter challenge bytes\n | 'group.seed' // group address seed at founding\n | 'founding.nonce' // relationship / group founding nonce (Identity §6.1, §7a.3)\n | 'intro.act' // an introduction act id, 32 bytes (Trust 8070)\n | 'message.mid' // a message's mid (uuid, Message Tasks 3040)\n | 'intro.target' // a mediator's target designator, 32 bytes (Trust 8610)\n | 'groupstar.nonce' // AEAD nonce of a group-star `c` (5.2b)\n | 'pad' // padding and filler bytes\n\nexport const ENTROPY_PURPOSES: readonly EntropyPurpose[] = Object.freeze([\n 'seal.eph', 'seal.nonce', 'doc.id', 'thread.id', 'ack.id', 'challenge',\n 'group.seed', 'founding.nonce', 'intro.act', 'intro.target', 'groupstar.nonce', 'pad', 'message.mid',\n])\n\nexport interface Entropy {\n /** n fresh bytes for `purpose`; a new buffer every call */\n bytes (purpose: EntropyPurpose, n: number): Uint8Array\n /** a fresh identifier for `purpose` (lowercase UUIDv4 by default) */\n id (purpose: EntropyPurpose): string\n}\n\nexport type EntropyErrorCode = 'exhausted' | 'mismatch' | 'purpose' | 'length'\n\nexport class EntropyError extends Error {\n readonly code: EntropyErrorCode\n readonly purpose: string\n constructor (code: EntropyErrorCode, purpose: string, message: string) {\n super(`entropy ${code} (${purpose}): ${message}`)\n this.name = 'EntropyError'\n this.code = code\n this.purpose = purpose\n }\n}\n\nconst PURPOSES: ReadonlySet<string> = new Set(ENTROPY_PURPOSES)\nconst checkPurpose = (purpose: string): void => {\n if (!PURPOSES.has(purpose)) throw new EntropyError('purpose', purpose, 'not an entropy purpose')\n}\nconst checkLength = (purpose: string, n: number): void => {\n if (!Number.isSafeInteger(n) || n < 0) throw new EntropyError('length', purpose, `invalid length ${n}`)\n}\n\nimport { CryptoUnavailableError } from './results.js'\n\n// getRandomValues fills at most 65536 bytes per call\nconst QUOTA = 65536\n\n/** Platform randomness; the crypto handle is resolved here, not at import. */\n/** The platform generators a crypto handle offers to randomEntropy. */\nexport type PlatformRandom = Pick<Crypto, 'getRandomValues' | 'randomUUID'>\n\nexport function randomEntropy (handle?: Partial<PlatformRandom>): Entropy {\n const c = handle ?? (globalThis.crypto as Partial<Crypto> | undefined)\n const missing = (['getRandomValues', 'randomUUID'] as const).filter((m) => typeof c?.[m] !== 'function')\n if (missing.length || !c) throw new CryptoUnavailableError(missing)\n const gen = c as PlatformRandom\n return {\n bytes (purpose, n) {\n checkPurpose(purpose); checkLength(purpose, n)\n const out = new Uint8Array(n)\n for (let i = 0; i < n; i += QUOTA) gen.getRandomValues(out.subarray(i, Math.min(n, i + QUOTA)))\n return out\n },\n id (purpose) {\n checkPurpose(purpose)\n return gen.randomUUID()\n },\n }\n}\n\nexport type EntropyScript = Partial<Record<EntropyPurpose, Uint8Array | string | Array<Uint8Array | string>>>\n\n/**\n * Scripted entropy for vectors and tests: each purpose yields its values\n * in order (a single value is a list of one) and throws 'exhausted' when\n * it runs dry. bytes() needs a Uint8Array of exactly n bytes, id() a\n * string — anything else is 'mismatch'. Values are copied in and out.\n */\nexport function scriptedEntropy (script: EntropyScript): Entropy {\n const queues = new Map<string, Array<Uint8Array | string>>()\n for (const [purpose, v] of Object.entries(script)) {\n checkPurpose(purpose)\n if (v === undefined) continue\n queues.set(purpose, (Array.isArray(v) ? v : [v]).map((x) => (x instanceof Uint8Array ? new Uint8Array(x) : x)))\n }\n const next = (purpose: string): Uint8Array | string => {\n checkPurpose(purpose)\n const q = queues.get(purpose)\n if (!q || q.length === 0) throw new EntropyError('exhausted', purpose, 'script ran dry')\n return q.shift()!\n }\n return {\n bytes (purpose, n) {\n checkLength(purpose, n)\n const v = next(purpose)\n if (!(v instanceof Uint8Array) || v.length !== n) throw new EntropyError('mismatch', purpose, `expected ${n} bytes`)\n return new Uint8Array(v)\n },\n id (purpose) {\n const v = next(purpose)\n if (typeof v !== 'string') throw new EntropyError('mismatch', purpose, 'expected a string id')\n return v\n },\n }\n}\n"]}
package/dist/events.d.ts CHANGED
@@ -172,6 +172,27 @@ export type HolderEvent = EventBase & ({
172
172
  type: 'group.vouched';
173
173
  groupId: string;
174
174
  member: string;
175
+ }
176
+ /** the block of the contact's relationships set or cleared (Message Tasks 6.1) */
177
+ | {
178
+ type: 'contact.blocked';
179
+ contactId: string;
180
+ blocked: boolean;
181
+ }
182
+ /** a message issued (Message Tasks 5): its mid and its document's digest,
183
+ * whose sender status deliveryStatus answers */
184
+ | {
185
+ type: 'message.sent';
186
+ contactId: string;
187
+ mid: string;
188
+ digest: string;
189
+ }
190
+ /** a message accepted into the inbox (4.5), by its inbox id; the contact
191
+ * of the relationship it arrived on */
192
+ | {
193
+ type: 'message.received';
194
+ contactId: string;
195
+ inboxId: string;
175
196
  });
176
197
  export type HolderEventType = HolderEvent['type'];
177
198
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7E,kCAAkC;AAClC,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+EAA+E;IAC/E,SAAS,EAAE,GAAG,CAAA;CACf;AAED,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,CAClC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC9C,iDAAiD;GAC/C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE;AACzE;;+CAE+C;GAC7C;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC5E,uFAAuF;GACrF;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE;AACjE;6EAC6E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AC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE;AAC5F,oDAAoD;GAClD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAC5C,6DAA6D;GAC3D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC7D,uEAAuE;GACrE;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC5D,kFAAkF;GAChF;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE;AAClE;iDACiD;GAC/C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC1E;wCACwC;GACtC;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CACnE,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"","sourcesContent":["// events — what a holder announces after a commit (lib Stage 2, note §4.4).\n//\n// A closed union, released only after the commit that caused it, never\n// before. Events carry ids, not text: the app renders words from the\n// type, and re-reads its views on any event. Events do not survive a\n// restart; the act journal keeps them only to answer a repeated actId.\n// Pure JSON, like the state that journals them.\nimport type { Json, JsonObject } from './core.js'\nimport type { Dec, OutboxStatus, PromptChoice, PromptKind } from './state.js'\n\n/** Fields every event carries. */\nexport interface EventBase {\n /** unique per event */\n eventId: string\n /** the human act that caused it, if any (note §4.2) */\n actId?: string\n /** commitSeq of the commit that caused it (state.ts), never the store token */\n commitSeq: Dec\n}\n\nexport type HolderEvent = EventBase & (\n | { type: 'contact.added', contactId: string }\n /** a mapping verified on a relationship (6.3) */\n | { type: 'contact.verified', contactId: string, relationshipId: string }\n /** a fresh tuple appended to a chain (6a.4, 6220): the fresh\n * relationship `from` went into the chain `into`; contactId is the entry\n * the chain's verifications go to after it */\n | { type: 'contact.chained', contactId: string, from: string, into: string }\n /** entries merged into one (2140): the survivor and the merged ids, now its aliases */\n | { type: 'contact.merged', contactId: string, merged: string[] }\n /** a relationship left a merged entry (2080): the remaining entry's id\n * (renamed where 2100 says), the leaver's new entry id, the relationship */\n | { type: 'contact.split', contactId: string, leaver: string, relationshipId: string }\n /** relationships departed (2260): removed says the entry went with them */\n | { type: 'contact.departed', contactId: string, relationshipIds: string[], removed: boolean }\n /** the Trust act: anchor-mapping class on (2770) */\n | { type: 'trust.given', contactId: string }\n | { type: 'trust.received', contactId: string }\n /** the pause of 5.4: star and blinded group star off, or back */\n | { type: 'trust.paused', contactId: string, paused: boolean }\n | { type: 'group.joined', groupId: string }\n | { type: 'prompt.opened', promptId: string, kind: PromptKind }\n /** the human decided a prompt; it is closed (prompts.ts) */\n | { type: 'prompt.decided', promptId: string, kind: PromptKind, choice: PromptChoice }\n /** sender status trias (Delivery §6.1) */\n | { type: 'delivery.status', digest: string, threadId: string, status: OutboxStatus, late?: boolean }\n /** contactId null: the holder's own profile */\n | { type: 'profile.updated', contactId: string | null }\n /** the community anchor's rotation completed: the head is this generation (Identity §5.4) */\n | { type: 'anchor.rotated', generation: Dec }\n /** a device name entered the register (Identity §5.5) */\n | { type: 'device.added', name: string }\n /** a device name was marked revoked (Identity §5.5) */\n | { type: 'device.revoked', name: string }\n /** resume found a duty of a registered kind at a version no handler\n * knows: kept untouched, announced once per resume (engine.ts) */\n | { type: 'duty.unsupported', dutyId: string, kind: string, v: number }\n /** a star (5.2a) completed on a relationship: its accepted snapshot changed */\n | { type: 'star.accepted', contactId: string, relationshipId: string, salt: Dec }\n /** a group star (5.2b) completed on a relationship; sharedGroups may have changed */\n | { type: 'groupStar.accepted', contactId: string, relationshipId: string, salt: Dec }\n /** a card displayed with a fresh own challenge (Encounter 5.3): `card`\n * is the optical payload to show (Encounter 6) */\n | { type: 'encounter.shown', challenge: string, card: JsonObject }\n /** the scanner's step (5.8 trunk 2–3): `card` is its sent card, the\n * optical leg's payload where no network carries the bundle */\n | { type: 'encounter.scanned', contactId: string, card: JsonObject }\n /** an enactment record created (5.5), on either side */\n | { type: 'encounter.recorded', contactId: string, relationshipId: string, role: 'scanner' | 'displayer' }\n /** the counterparty's step credential accepted (5.6): the edge now\n * holds it; mutual when the own one is issued too (4.2) */\n | { type: 'encounter.accepted', contactId: string, relationshipId: string, mutual: boolean }\n /** a group founded by this holder (Access 3.4.1) */\n | { type: 'group.founded', groupId: string }\n /** a member admitted by this holder, by its member anchor */\n | { type: 'group.admitted', groupId: string, member: string }\n /** a vouch@2 issued by this holder for a member anchor (Access 5.3) */\n | { type: 'group.vouched', groupId: string, member: string }\n)\n\nexport type HolderEventType = HolderEvent['type']\n"]}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"","sourcesContent":["// events — what a holder announces after a commit (lib Stage 2, note §4.4).\n//\n// A closed union, released only after the commit that caused it, never\n// before. Events carry ids, not text: the app renders words from the\n// type, and re-reads its views on any event. Events do not survive a\n// restart; the act journal keeps them only to answer a repeated actId.\n// Pure JSON, like the state that journals them.\nimport type { Json, JsonObject } from './core.js'\nimport type { Dec, OutboxStatus, PromptChoice, PromptKind } from './state.js'\n\n/** Fields every event carries. */\nexport interface EventBase {\n /** unique per event */\n eventId: string\n /** the human act that caused it, if any (note §4.2) */\n actId?: string\n /** commitSeq of the commit that caused it (state.ts), never the store token */\n commitSeq: Dec\n}\n\nexport type HolderEvent = EventBase & (\n | { type: 'contact.added', contactId: string }\n /** a mapping verified on a relationship (6.3) */\n | { type: 'contact.verified', contactId: string, relationshipId: string }\n /** a fresh tuple appended to a chain (6a.4, 6220): the fresh\n * relationship `from` went into the chain `into`; contactId is the entry\n * the chain's verifications go to after it */\n | { type: 'contact.chained', contactId: string, from: string, into: string }\n /** entries merged into one (2140): the survivor and the merged ids, now its aliases */\n | { type: 'contact.merged', contactId: string, merged: string[] }\n /** a relationship left a merged entry (2080): the remaining entry's id\n * (renamed where 2100 says), the leaver's new entry id, the relationship */\n | { type: 'contact.split', contactId: string, leaver: string, relationshipId: string }\n /** relationships departed (2260): removed says the entry went with them */\n | { type: 'contact.departed', contactId: string, relationshipIds: string[], removed: boolean }\n /** the Trust act: anchor-mapping class on (2770) */\n | { type: 'trust.given', contactId: string }\n | { type: 'trust.received', contactId: string }\n /** the pause of 5.4: star and blinded group star off, or back */\n | { type: 'trust.paused', contactId: string, paused: boolean }\n | { type: 'group.joined', groupId: string }\n | { type: 'prompt.opened', promptId: string, kind: PromptKind }\n /** the human decided a prompt; it is closed (prompts.ts) */\n | { type: 'prompt.decided', promptId: string, kind: PromptKind, choice: PromptChoice }\n /** sender status trias (Delivery §6.1) */\n | { type: 'delivery.status', digest: string, threadId: string, status: OutboxStatus, late?: boolean }\n /** contactId null: the holder's own profile */\n | { type: 'profile.updated', contactId: string | null }\n /** the community anchor's rotation completed: the head is this generation (Identity §5.4) */\n | { type: 'anchor.rotated', generation: Dec }\n /** a device name entered the register (Identity §5.5) */\n | { type: 'device.added', name: string }\n /** a device name was marked revoked (Identity §5.5) */\n | { type: 'device.revoked', name: string }\n /** resume found a duty of a registered kind at a version no handler\n * knows: kept untouched, announced once per resume (engine.ts) */\n | { type: 'duty.unsupported', dutyId: string, kind: string, v: number }\n /** a star (5.2a) completed on a relationship: its accepted snapshot changed */\n | { type: 'star.accepted', contactId: string, relationshipId: string, salt: Dec }\n /** a group star (5.2b) completed on a relationship; sharedGroups may have changed */\n | { type: 'groupStar.accepted', contactId: string, relationshipId: string, salt: Dec }\n /** a card displayed with a fresh own challenge (Encounter 5.3): `card`\n * is the optical payload to show (Encounter 6) */\n | { type: 'encounter.shown', challenge: string, card: JsonObject }\n /** the scanner's step (5.8 trunk 2–3): `card` is its sent card, the\n * optical leg's payload where no network carries the bundle */\n | { type: 'encounter.scanned', contactId: string, card: JsonObject }\n /** an enactment record created (5.5), on either side */\n | { type: 'encounter.recorded', contactId: string, relationshipId: string, role: 'scanner' | 'displayer' }\n /** the counterparty's step credential accepted (5.6): the edge now\n * holds it; mutual when the own one is issued too (4.2) */\n | { type: 'encounter.accepted', contactId: string, relationshipId: string, mutual: boolean }\n /** a group founded by this holder (Access 3.4.1) */\n | { type: 'group.founded', groupId: string }\n /** a member admitted by this holder, by its member anchor */\n | { type: 'group.admitted', groupId: string, member: string }\n /** a vouch@2 issued by this holder for a member anchor (Access 5.3) */\n | { type: 'group.vouched', groupId: string, member: string }\n /** the block of the contact's relationships set or cleared (Message Tasks 6.1) */\n | { type: 'contact.blocked', contactId: string, blocked: boolean }\n /** a message issued (Message Tasks 5): its mid and its document's digest,\n * whose sender status deliveryStatus answers */\n | { type: 'message.sent', contactId: string, mid: string, digest: string }\n /** a message accepted into the inbox (4.5), by its inbox id; the contact\n * of the relationship it arrived on */\n | { type: 'message.received', contactId: string, inboxId: string }\n)\n\nexport type HolderEventType = HolderEvent['type']\n"]}
@@ -1,11 +1,11 @@
1
- import type { CommitListener, EnginePorts, HolderModule } from './engine.js';
1
+ import type { CommitListener, EnginePorts, HolderModule, TransportEntry, TransportRefusal, TransportView } from './engine.js';
2
2
  import type { DeliveryReport } from './ports.js';
3
3
  import type { ActResult, ReceiveResult, ResumeResult } from './results.js';
4
4
  import type { DeviceKeyResult } from './identity-state.js';
5
5
  import type { ProfileContent } from './profile.js';
6
6
  import type { Dec, Millis, OpaqueHolderState, PromptChoice, Setting, TrustClass } from './state.js';
7
7
  import type { Json } from './core.js';
8
- import type { ContactView, DeliveryStatusView, GroupView, ProfileView, PromptView } from './views.js';
8
+ import type { ContactView, DeliveryStatusView, GroupView, InboxMessageView, ProfileView, PromptView } from './views.js';
9
9
  /** The committed state and its commitSeq; the state is opaque (note §4.5):
10
10
  * apps read the views, store tooling may persist it. */
11
11
  export interface HolderSnapshot {
@@ -108,6 +108,31 @@ export interface Holder {
108
108
  vouchFor(groupId: string, member: string, opts: HumanActOptions & {
109
109
  provenance?: 'met' | 'introduced';
110
110
  }): Promise<ActResult>;
111
+ /** a text message to the contact (Message Tasks 3, 5): 1 to 4096 code
112
+ * points, replyTo the mid of an earlier message of the relationship. It
113
+ * goes on a ready, unblocked relationship (canMessage); otherwise refused
114
+ * as not-ready, blocked or no-own-channel, and the app keeps it unsent.
115
+ * Event message.sent {mid, digest}; deliveryStatus(digest) is its sender
116
+ * status. Undelivered, it ends as failed(expired-by-adapter-policy) at
117
+ * the retry horizon (P7D by default, P90D at most), before its sender
118
+ * lifetime sentAt + P179D: failed(task-expired) is not reached for a
119
+ * message under any horizon the engine admits; human */
120
+ sendMessage(contactId: string, text: string, opts: HumanActOptions & {
121
+ replyTo?: string;
122
+ }): Promise<ActResult>;
123
+ /** the inbox entries the app has durably taken over leave the inbox
124
+ * (4420); their completion record stays (4350); not human */
125
+ takeMessages(ids: string[], opts: {
126
+ when: Millis;
127
+ }): Promise<ActResult>;
128
+ /** the block (Message Tasks 6): set on every relationship of the
129
+ * contact's entry. Messages, invitations and the holder's own offers on
130
+ * them stop; the protocol steps owed continue; the contact observes
131
+ * nothing it would not without the block. Event contact.blocked; human */
132
+ block(contactId: string, opts: HumanActOptions): Promise<ActResult>;
133
+ /** the block cleared on every relationship of the entry: nothing that
134
+ * was discarded under it reappears (6510); human */
135
+ unblock(contactId: string, opts: HumanActOptions): Promise<ActResult>;
111
136
  /** the device key of a held, unrevoked device name under an own anchor
112
137
  * context (Identity §5.5); reads, changes nothing */
113
138
  deviceKey(name: string, contextLabel: string): Promise<DeviceKeyResult>;
@@ -126,8 +151,25 @@ export interface Holder {
126
151
  groups(): Promise<GroupView[]>;
127
152
  profile(): Promise<ProfileView>;
128
153
  prompts(): Promise<PromptView[]>;
154
+ /** the messages accepted and not yet taken over (Message Tasks 4.5),
155
+ * by display time; event message.received announces each */
156
+ inbox(): Promise<InboxMessageView[]>;
129
157
  /** by document digest or threadId */
130
158
  deliveryStatus(digestOrThreadId: string): Promise<DeliveryStatusView>;
159
+ /** what the holder keeps for transport at `when`, after this opening's
160
+ * first completed resume (else `{ok: false, code: 'not-resumed'}`) */
161
+ pendingTransport(when: Millis): Promise<TransportView | TransportRefusal>;
162
+ /** right before a hand-over: whether this opening's `entry` may go now */
163
+ mayHandOver(entry: TransportEntry, when: Millis): Promise<boolean>;
164
+ /** the hand-over: the same check, then `start()` (which starts the
165
+ * deposit synchronously and says whether it did) inside the holder's
166
+ * queue; true when both said yes */
167
+ handOver(entry: TransportEntry, when: Millis, start: () => boolean): Promise<boolean>;
168
+ /** ends this opening (a lock, the end of a process); resolves once the
169
+ * operation running at the call has finished: after that the opening
170
+ * commits nothing more, and the next opening may start */
171
+ close(): Promise<void>;
172
+ readonly closed: boolean;
131
173
  }
132
174
  /** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.
133
175
  * The crypto handle (default globalThis.crypto) is resolved and probed
@@ -1 +1 @@
1
- {"version":3,"file":"holder-api.d.ts","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AA4DA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAQ1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,iBA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MAAM,EAAE,OAAO,CAAA;CACzB;AAED;;;wDAGwD;AACxD,wBAAsB,YAAY,CAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoEjG"}
@@ -42,7 +42,11 @@
42
42
  // invite(groupId, contactId, opts) membership.invite human
43
43
  // vouchFor(groupId, member, opts{provenance?}) membership.vouch human
44
44
  // introduce(requesterId, targetId, opts) introduction.introduce human
45
+ // sendMessage(contactId, text, opts{replyTo?}) message.send human
46
+ // block(contactId, opts) message.block {blocked: true} human
47
+ // unblock(contactId, opts) message.block {blocked: false} human
45
48
  // recover({when}) trust.recover not human
49
+ // takeMessages(ids, {when}) message.take not human
46
50
  // and the read deviceKey(name, contextLabel): the device key of a held,
47
51
  // unrevoked name under an own anchor context (identity-state.ts).
48
52
  // A missing actId is refused at runtime as actid-missing.
@@ -54,9 +58,29 @@
54
58
  //
55
59
  // Delivery: `receive(env, when)` runs Delivery §6.2 in the core and
56
60
  // dispatches through the task register (receive.ts); `report` takes the
57
- // adapter's reports (on an ack's digest it marks the ack sent); `resume`
58
- // re-emits, runs due duties and re-emits unsent acks; `tick` expires and
59
- // retains (engine.ts).
61
+ // adapter's reports (on an ack's digest: accepted or delivered marks it
62
+ // sent, failed gives it up, awaiting-transport records that the adapter
63
+ // holds it); `resume` re-emits, runs due duties and re-emits unsent acks;
64
+ // `tick` expires and retains (engine.ts).
65
+ //
66
+ // Custody (Delivery 0.83 RLTP-DEL-6120 to 6135): the holder keeps every
67
+ // outbound document until a service takes it or the holder gives it up,
68
+ // across a lock and the end of a process. One createHolder is one opening.
69
+ // After its first resume, `pendingTransport(when)` names what is to be
70
+ // handed over: the outbox items neither terminal nor accepted (held ones
71
+ // included) and the unsent acks, each with its envelope, its first
72
+ // submission and its deadline, none past it. A transport hands over only
73
+ // such entries, through `handOver(entry, when, start)`: the check of
74
+ // `mayHandOver` and the start of the deposit in one step of the holder's
75
+ // queue, true only for an entry this opening issued that is still pending,
76
+ // unchanged, before its deadline. A duplicate's stored ack past its retries
77
+ // appears once as a `resend` entry (Delivery RLTP-DEL-6330). A document missing from the
78
+ // view is no longer to be sent. `await close()` ends the opening at a lock or
79
+ // the end of a process (resolved once the running operation finished, the
80
+ // moment the next opening may start): every later call rejects with InfraError
81
+ // 'closed', mayHandOver answers false, and nothing issued before
82
+ // authorizes anything; the next opening is a new createHolder over the
83
+ // same store, resumed first.
60
84
  import { createEngine } from './engine.js';
61
85
  import { DECIDE, collectDecisions, promptsModule } from './prompts.js';
62
86
  import { InfraError } from './results.js';
@@ -70,13 +94,14 @@ import { ENTRY_COMMANDS } from './trust/entries.js';
70
94
  import { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js';
71
95
  import { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js';
72
96
  import { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js';
73
- import { contactView, contactsView, deliveryStatusView, groupsView, profileView, promptsView } from './views.js';
97
+ import { MESSAGE_COMMANDS, messageModule } from './message/holder.js';
98
+ import { contactView, contactsView, deliveryStatusView, groupsView, inboxView, profileView, promptsView } from './views.js';
74
99
  /** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.
75
100
  * The crypto handle (default globalThis.crypto) is resolved and probed
76
101
  * here and also feeds the default entropy; an app that injects one
77
102
  * passes the same handle to seedKeys(seed, crypto). */
78
103
  export async function createHolder(ports, opts = {}) {
79
- const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), ...(opts.modules ?? [])];
104
+ const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), messageModule(), ...(opts.modules ?? [])];
80
105
  const check = opts.invariants === true
81
106
  ? (before, after, op) => {
82
107
  const v = commitViolations(before, after, op);
@@ -109,6 +134,10 @@ export async function createHolder(ports, opts = {}) {
109
134
  invite: (groupId, contactId, o) => human(MEMBERSHIP_COMMANDS.invite, { groupId, contactId }, o),
110
135
  vouchFor: (groupId, member, o) => human(MEMBERSHIP_COMMANDS.vouch, o?.provenance === undefined ? { groupId, member } : { groupId, member, provenance: o.provenance }, o),
111
136
  introduce: (requesterId, targetId, o) => human(INTRODUCTION_COMMANDS.introduce, o?.label === undefined ? { requesterId, targetId } : { requesterId, targetId, label: o.label }, o),
137
+ sendMessage: (contactId, text, o) => human(MESSAGE_COMMANDS.send, o?.replyTo === undefined ? { contactId, text } : { contactId, text, replyTo: o.replyTo }, o),
138
+ takeMessages: (ids, o) => engine.act(MESSAGE_COMMANDS.take, { ids }, o?.when),
139
+ block: (contactId, o) => human(MESSAGE_COMMANDS.block, { contactId, blocked: true }, o),
140
+ unblock: (contactId, o) => human(MESSAGE_COMMANDS.block, { contactId, blocked: false }, o),
112
141
  addDevice: (name, o) => human(IDENTITY_COMMANDS.addDevice, { name }, o),
113
142
  revokeDevice: (name, o) => human(IDENTITY_COMMANDS.revokeDevice, { name }, o),
114
143
  deviceKey: async (name, contextLabel) => deviceKeyOf(await read(), ports.keys, name, contextLabel),
@@ -126,7 +155,13 @@ export async function createHolder(ports, opts = {}) {
126
155
  groups: async () => groupsView(await read()),
127
156
  profile: async () => profileView(await read()),
128
157
  prompts: async () => promptsView(await read()),
158
+ inbox: async () => inboxView(await read()),
129
159
  deliveryStatus: async (x) => deliveryStatusView(await read(), x),
160
+ pendingTransport: (when) => engine.pendingTransport(when),
161
+ mayHandOver: (entry, when) => engine.mayHandOver(entry, when),
162
+ handOver: (entry, when, start) => engine.handOver(entry, when, start),
163
+ close: () => engine.close(),
164
+ get closed() { return engine.closed; },
130
165
  });
131
166
  }
132
167
  //# sourceMappingURL=holder-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"holder-api.js","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,4EAA4E;AAC5E,wEAAwE;AACxE,sEAAsE;AACtE,uEAAuE;AACvE,u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AE,IAAI,CAAC;QAC7E,OAAO,EAAE,CAAC,GAAY,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC;QAClE,SAAS,EAAE,CAAC,QAAwB,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;QACnE,QAAQ,EAAE,KAAK,IAA6B,EAAE;YAC5C,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;YACjC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC5E,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,IAAI,EAAE,CAAC;QAChD,OAAO,EAAE,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC;QAC5D,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;QAC5C,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC;QAC9C,cAAc,EAAE,KAAK,EAAE,CAAS,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;KACzE,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// holder-api — createHolder, the facade over the engine (lib Stage 2,\n// note §4.1, §4.5). Domain modules (identity, encounter, trust, continuity,\n// membership, profile) register with the engine as they graduate; today\n// the facade carries the engine's built-ins, the prompts module, the\n// encounter module (encounter/ceremony.ts: show, scan, the optical leg, the\n// counter-step, the bundle and the credential delivery), the membership\n// module (membership/holder.ts: founding, the prelude and invite, the\n// accept on a group-invite prompt, admission and welcome, evidence and\n// vouches; and the in-library Access over the holder's groups where no\n// Access port is given), the introduction module (introduction/holder.ts:\n// the three roles of Trust §8 and the mediator's start), the identity module (identity-state.ts: device names, the rotation), the trust\n// module (trust/mapping.ts: the Trust act, the class settings, the anchor\n// mapping's issuance and reception, the entry commit; trust/star.ts and\n// trust/group-star.ts: the star and the group star, reconciled on resume\n// and received with their assemblies; trust/entries.ts: merge, split and\n// departure; trust/continuity.ts: the probe, the continuity mapping and\n// the chaining; trust/profile.ts: profile@1) and the modules given.\n//\n// The human acts (note §4.2) are typed methods with an options object\n// `{when, actId}`; actId is required, minted by the app when the human\n// acts, and journaled with the act's result (a repeat with the same actId\n// replays it, another input under it is actid-conflict). They wrap `act`\n// with the trust module's command names, which stays for modules and\n// tests:\n// trust(contactId, opts) trust.set {on: true} human\n// untrust(contactId, opts) trust.set {on: false} human\n// pauseTrust(contactId, paused, opts) trust.pause human\n// setClass(contactId, cls, setting, opts) trust.setClass human\n// setGroupClass(contactId, groupId, setting, opts) trust.setGroupClass human\n// merge(contactIds, opts) trust.merge human\n// depart(contactId, opts{relationshipId?}) trust.depart human\n// decide(promptId, choice, opts) prompt.decide human\n// addDevice(name, opts) identity.addDevice human\n// revokeDevice(name, opts) identity.revokeDevice human\n// rotateAnchor(opts) identity.rotate human\n// setProfile({name, image?, text?}, opts) profile.set human\n// show(opts{name?}) encounter.show human\n// scan(card, opts{name?}) encounter.scan human\n// captureSentCard(card, opts) encounter.capture human\n// counter(contactId, opts) encounter.counter human\n// foundGroup({name, vouchThreshold?, listed?}, opts) membership.found human\n// invite(groupId, contactId, opts) membership.invite human\n// vouchFor(groupId, member, opts{provenance?}) membership.vouch human\n// introduce(requesterId, targetId, opts) introduction.introduce human\n// recover({when}) trust.recover not human\n// and the read deviceKey(name, contextLabel): the device key of a held,\n// unrevoked name under an own anchor context (identity-state.ts).\n// A missing actId is refused at runtime as actid-missing.\n//\n// Reading: the views (views.ts) over one snapshot each, carrying its\n// commitSeq. `subscribe` announces every commit with its commitSeq and\n// events; the app re-reads the views it shows, and a view read after the\n// announcement is at that commitSeq or later.\n//\n// Delivery: `receive(env, when)` runs Delivery §6.2 in the core and\n// dispatches through the task register (receive.ts); `report` takes the\n// adapter's reports (on an ack's digest it marks the ack sent); `resume`\n// re-emits, runs due duties and re-emits unsent acks; `tick` expires and\n// retains (engine.ts).\nimport { createEngine } from './engine.js'\nimport type { CommitListener, EnginePorts, HolderModule } from './engine.js'\nimport type { DeliveryReport } from './ports.js'\nimport { DECIDE, collectDecisions, promptsModule } from './prompts.js'\nimport type { ActResult, ReceiveResult, ResumeResult } from './results.js'\nimport { InfraError } from './results.js'\nimport { commitViolations } from './invariants.js'\nimport type { CommitOp } from './invariants.js'\nimport type { HolderState } from './state.js'\nimport { toOpaque } from './state.js'\nimport { trustModule } from './trust/mapping.js'\nimport { IDENTITY_COMMANDS, deviceKeyOf, identityModule } from './identity-state.js'\nimport type { DeviceKeyResult } from './identity-state.js'\nimport { PROFILE_SET } from './trust/profile.js'\nimport type { ProfileContent } from './profile.js'\nimport type { Dec, Millis, OpaqueHolderState, PromptChoice, Setting, TrustClass } from './state.js'\nimport { TRUST_COMMANDS } from './trust/mapping.js'\nimport { ENTRY_COMMANDS } from './trust/entries.js'\nimport { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js'\nimport { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js'\nimport { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js'\nimport type { Json } from './core.js'\nimport { contactView, contactsView, deliveryStatusView, groupsView, profileView, promptsView } from './views.js'\nimport type { ContactView, DeliveryStatusView, GroupView, ProfileView, PromptView } from './views.js'\n\n/** The committed state and its commitSeq; the state is opaque (note §4.5):\n * apps read the views, store tooling may persist it. */\nexport interface HolderSnapshot { commitSeq: Dec, state: OpaqueHolderState }\n\nexport interface HolderOptions {\n /** domain modules to register beside the built-ins, the prompts and the trust module */\n modules?: readonly HolderModule[]\n /** testing mode: check the invariants of invariants.ts on every commit,\n * before the store's CAS; a violation throws InfraError\n * 'invariant-violated' (cause: the violations) and nothing commits */\n invariants?: boolean\n}\n\n/** The options of a human act (note §4.2): its time and the actId the app\n * mints when the human acts. */\nexport interface HumanActOptions { when: Millis, actId: string }\n\nexport interface Holder {\n /** any registered command by name, for modules and tests; apps use the typed acts */\n act (command: string, input: unknown, when: Millis, opts?: { actId?: string }): Promise<ActResult>\n /** the human's decision on an open prompt: a human act under the app's\n * actId (note §4.2); a missing actId is also refused at runtime */\n decide (promptId: string, choice: PromptChoice, opts: HumanActOptions): Promise<ActResult>\n /** the Trust act: the anchor mapping class on toward the contact (2770); human */\n trust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** trust withdrawn: the anchor mapping class off (2840, 2850); human */\n untrust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the pause of 5.4: star and blinded group star off, or back to default; human */\n pauseTrust (contactId: string, paused: boolean, opts: HumanActOptions): Promise<ActResult>\n /** one class's setting toward the contact (2780, 2810); human */\n setClass (contactId: string, cls: TrustClass, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the sealed group star's setting for one group toward the contact (2830); human */\n setGroupClass (contactId: string, groupId: string, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the manual merge (6640): at most one of them holds an entry; human */\n merge (contactIds: string[], opts: HumanActOptions): Promise<ActResult>\n /** departure (2260): the entry, the relationships of an alias, or one\n * relationship (relationshipId); human */\n depart (contactId: string, opts: HumanActOptions & { relationshipId?: string }): Promise<ActResult>\n /** 2240: entries re-commit from verified mappings recovered without them; not human */\n recover (opts: { when: Millis }): Promise<ActResult>\n /** a device name into the register before any key derived from it is presented (Identity §5.5); human */\n addDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the name's revocation mark: never removed, the name never given again (Identity §5.5); human */\n revokeDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the community anchor's rotation (Identity §5.4): step 1 (label,\n * closure, 6596 decided) when none runs, else step 2 of the running one\n * through the Log port; resume carries step 2 on its own (identity-state.ts) */\n rotateAnchor (opts: HumanActOptions): Promise<ActResult>\n /** the own profile (Trust 6b): validated (6430, 6435, 6475), the next\n * revision of the one counter (6450), delivered on every relationship\n * the profile class is on for (6455); human */\n setProfile (content: ProfileContent, opts: HumanActOptions): Promise<ActResult>\n /** a displayed card with a fresh own challenge under a fresh pair\n * anchor (Encounter 5.3, 4.4): the event encounter.shown carries the\n * card to display; `name` the card's display name (default: the own\n * profile's); human */\n show (opts: HumanActOptions & { name?: string }): Promise<ActResult>\n /** the scanner's step on a displayed card (Encounter 5.8): the record,\n * the fresh tuple, the bundle; encounter.scanned carries the sent card\n * for the optical leg; human */\n scan (card: Json, opts: HumanActOptions & { name?: string }): Promise<ActResult>\n /** the optical leg (Encounter 5.8, 5710): a sent card shown by the scanner; human */\n captureSentCard (card: Json, opts: HumanActOptions): Promise<ActResult>\n /** the counter-step toward a contact met as displayer (Encounter 5.8 step 4); human */\n counter (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** a group founded under a fresh pair anchor (Access 3.4.1); its rule\n * vouchThreshold (default \"1\") is group state; event group.founded; human */\n foundGroup (group: { name: string, vouchThreshold?: string, listed?: boolean }, opts: HumanActOptions): Promise<ActResult>\n /** invite a contact into a group: the prelude, then the invite on its\n * answer (Membership 1.2, 3.1); the contact decides on a group-invite\n * prompt; human */\n invite (groupId: string, contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the mediator's act (Trust §8, this library's start of it): the\n * requester gets an offer naming the target by an opaque designator and\n * at most the `label` the human types here, with the mediator's\n * ack-delay declaration; the requester decides on an\n * `introduction` prompt, the target on another; human */\n introduce (requesterId: string, targetId: string, opts: HumanActOptions & { label?: string }): Promise<ActResult>\n /** a vouch@2 for a member anchor whose consent pair this holder holds\n * (Access 5.3, Membership 3.4); human */\n vouchFor (groupId: string, member: string, opts: HumanActOptions & { provenance?: 'met' | 'introduced' }): Promise<ActResult>\n /** the device key of a held, unrevoked device name under an own anchor\n * context (Identity §5.5); reads, changes nothing */\n deviceKey (name: string, contextLabel: string): Promise<DeviceKeyResult>\n tick (when: Millis): Promise<ActResult>\n resume (when: Millis): Promise<ResumeResult>\n report (report: DeliveryReport, when: Millis): Promise<ActResult>\n /** an arriving envelope, as the app's transport delivered it (non-human,\n * no actId; idempotent over the document digest) */\n receive (env: unknown, when: Millis): Promise<ReceiveResult>\n /** after every commit: its commitSeq and events, the cue to re-read the views */\n subscribe (listener: CommitListener): () => void\n snapshot (): Promise<HolderSnapshot>\n contacts (): Promise<ContactView[]>\n /** by entry id or alias */\n contact (id: string): Promise<ContactView | undefined>\n groups (): Promise<GroupView[]>\n profile (): Promise<ProfileView>\n prompts (): Promise<PromptView[]>\n /** by document digest or threadId */\n deliveryStatus (digestOrThreadId: string): Promise<DeliveryStatusView>\n}\n\n/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.\n * The crypto handle (default globalThis.crypto) is resolved and probed\n * here and also feeds the default entropy; an app that injects one\n * passes the same handle to seedKeys(seed, crypto). */\nexport async function createHolder (ports: EnginePorts, opts: HolderOptions = {}): Promise<Holder> {\n const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), ...(opts.modules ?? [])]\n const check = opts.invariants === true\n ? (before: Readonly<HolderState>, after: Readonly<HolderState>, op: CommitOp) => {\n const v = commitViolations(before, after, op)\n if (v.length) throw new InfraError('invariant-violated', `invariants broken by ${op.kind}: ${v.map((x) => `[${x.invariant}] ${x.detail}`).join('; ')}`, { cause: v })\n }\n : undefined\n const engine = await createEngine(ports, [promptsModule(collectDecisions(modules)), ...modules], { ...(check ? { check } : {}), accessFrom: localAccess })\n const read = async () => (await engine.snapshot()).state\n /** a human act: `when` and actId from the options, a missing actId refused by the engine */\n const human = (command: string, input: unknown, o: HumanActOptions | undefined) =>\n engine.act(command, input, o?.when as Millis, o?.actId === undefined ? {} : { actId: o.actId })\n return Object.freeze({\n act: (command: string, input: unknown, when: Millis, o?: { actId?: string }) => engine.act(command, input, when, o),\n decide: (promptId: string, choice: PromptChoice, o: HumanActOptions) => human(DECIDE, { promptId, choice }, o),\n trust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: true }, o),\n untrust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: false }, o),\n pauseTrust: (contactId: string, paused: boolean, o: HumanActOptions) => human(TRUST_COMMANDS.pause, { contactId, paused }, o),\n setClass: (contactId: string, cls: TrustClass, setting: Setting, o: HumanActOptions) => human(TRUST_COMMANDS.setClass, { contactId, cls, setting }, o),\n setGroupClass: (contactId: string, groupId: string, setting: Setting, o: HumanActOptions) =>\n human(TRUST_COMMANDS.setGroupClass, { contactId, groupId, setting }, o),\n merge: (contactIds: string[], o: HumanActOptions) => human(ENTRY_COMMANDS.merge, { contactIds }, o),\n depart: (contactId: string, o: HumanActOptions & { relationshipId?: string }) =>\n human(ENTRY_COMMANDS.depart, o?.relationshipId === undefined ? { contactId } : { contactId, relationshipId: o.relationshipId }, o),\n recover: (o: { when: Millis }) => engine.act(TRUST_COMMANDS.recover, {}, o?.when as Millis),\n rotateAnchor: (o: HumanActOptions) => human(IDENTITY_COMMANDS.rotate, {}, o),\n setProfile: (content: ProfileContent, o: HumanActOptions) => human(PROFILE_SET, content, o),\n show: (o: HumanActOptions & { name?: string }) => human(ENCOUNTER_COMMANDS.show, o?.name === undefined ? {} : { name: o.name }, o),\n scan: (card: Json, o: HumanActOptions & { name?: string }) => human(ENCOUNTER_COMMANDS.scan, o?.name === undefined ? { card } : { card, name: o.name }, o),\n captureSentCard: (card: Json, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.capture, { card }, o),\n counter: (contactId: string, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.counter, { contactId }, o),\n foundGroup: (g: { name: string, vouchThreshold?: string, listed?: boolean }, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.found, g, o),\n invite: (groupId: string, contactId: string, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.invite, { groupId, contactId }, o),\n vouchFor: (groupId: string, member: string, o: HumanActOptions & { provenance?: 'met' | 'introduced' }) =>\n human(MEMBERSHIP_COMMANDS.vouch, o?.provenance === undefined ? { groupId, member } : { groupId, member, provenance: o.provenance }, o),\n introduce: (requesterId: string, targetId: string, o: HumanActOptions & { label?: string }) =>\n human(INTRODUCTION_COMMANDS.introduce, o?.label === undefined ? { requesterId, targetId } : { requesterId, targetId, label: o.label }, o),\n addDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.addDevice, { name }, o),\n revokeDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.revokeDevice, { name }, o),\n deviceKey: async (name: string, contextLabel: string) => deviceKeyOf(await read(), ports.keys, name, contextLabel),\n tick: (when: Millis) => engine.tick(when),\n resume: (when: Millis) => engine.resume(when),\n report: (report: DeliveryReport, when: Millis) => engine.report(report, when),\n receive: (env: unknown, when: Millis) => engine.receive(env, when),\n subscribe: (listener: CommitListener) => engine.subscribe(listener),\n snapshot: async (): Promise<HolderSnapshot> => {\n const s = await engine.snapshot()\n return Object.freeze({ commitSeq: s.commitSeq, state: toOpaque(s.state) })\n },\n contacts: async () => contactsView(await read()),\n contact: async (id: string) => contactView(await read(), id),\n groups: async () => groupsView(await read()),\n profile: async () => profileView(await read()),\n prompts: async () => promptsView(await read()),\n deliveryStatus: async (x: string) => deliveryStatusView(await read(), x),\n })\n}\n"]}
1
+ {"version":3,"file":"holder-api.js","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,4EAA4E;AAC5E,wEAAwE;AACxE,sEAAsE;AACtE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,wIAAwI;AACxI,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE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AAE,KAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;QAC5G,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;QAC3B,IAAI,MAAM,KAAM,OAAO,MAAM,CAAC,MAAM,CAAA,CAAC,CAAC;KACvC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// holder-api — createHolder, the facade over the engine (lib Stage 2,\n// note §4.1, §4.5). Domain modules (identity, encounter, trust, continuity,\n// membership, profile) register with the engine as they graduate; today\n// the facade carries the engine's built-ins, the prompts module, the\n// encounter module (encounter/ceremony.ts: show, scan, the optical leg, the\n// counter-step, the bundle and the credential delivery), the membership\n// module (membership/holder.ts: founding, the prelude and invite, the\n// accept on a group-invite prompt, admission and welcome, evidence and\n// vouches; and the in-library Access over the holder's groups where no\n// Access port is given), the introduction module (introduction/holder.ts:\n// the three roles of Trust §8 and the mediator's start), the identity module (identity-state.ts: device names, the rotation), the trust\n// module (trust/mapping.ts: the Trust act, the class settings, the anchor\n// mapping's issuance and reception, the entry commit; trust/star.ts and\n// trust/group-star.ts: the star and the group star, reconciled on resume\n// and received with their assemblies; trust/entries.ts: merge, split and\n// departure; trust/continuity.ts: the probe, the continuity mapping and\n// the chaining; trust/profile.ts: profile@1) and the modules given.\n//\n// The human acts (note §4.2) are typed methods with an options object\n// `{when, actId}`; actId is required, minted by the app when the human\n// acts, and journaled with the act's result (a repeat with the same actId\n// replays it, another input under it is actid-conflict). They wrap `act`\n// with the trust module's command names, which stays for modules and\n// tests:\n// trust(contactId, opts) trust.set {on: true} human\n// untrust(contactId, opts) trust.set {on: false} human\n// pauseTrust(contactId, paused, opts) trust.pause human\n// setClass(contactId, cls, setting, opts) trust.setClass human\n// setGroupClass(contactId, groupId, setting, opts) trust.setGroupClass human\n// merge(contactIds, opts) trust.merge human\n// depart(contactId, opts{relationshipId?}) trust.depart human\n// decide(promptId, choice, opts) prompt.decide human\n// addDevice(name, opts) identity.addDevice human\n// revokeDevice(name, opts) identity.revokeDevice human\n// rotateAnchor(opts) identity.rotate human\n// setProfile({name, image?, text?}, opts) profile.set human\n// show(opts{name?}) encounter.show human\n// scan(card, opts{name?}) encounter.scan human\n// captureSentCard(card, opts) encounter.capture human\n// counter(contactId, opts) encounter.counter human\n// foundGroup({name, vouchThreshold?, listed?}, opts) membership.found human\n// invite(groupId, contactId, opts) membership.invite human\n// vouchFor(groupId, member, opts{provenance?}) membership.vouch human\n// introduce(requesterId, targetId, opts) introduction.introduce human\n// sendMessage(contactId, text, opts{replyTo?}) message.send human\n// block(contactId, opts) message.block {blocked: true} human\n// unblock(contactId, opts) message.block {blocked: false} human\n// recover({when}) trust.recover not human\n// takeMessages(ids, {when}) message.take not human\n// and the read deviceKey(name, contextLabel): the device key of a held,\n// unrevoked name under an own anchor context (identity-state.ts).\n// A missing actId is refused at runtime as actid-missing.\n//\n// Reading: the views (views.ts) over one snapshot each, carrying its\n// commitSeq. `subscribe` announces every commit with its commitSeq and\n// events; the app re-reads the views it shows, and a view read after the\n// announcement is at that commitSeq or later.\n//\n// Delivery: `receive(env, when)` runs Delivery §6.2 in the core and\n// dispatches through the task register (receive.ts); `report` takes the\n// adapter's reports (on an ack's digest: accepted or delivered marks it\n// sent, failed gives it up, awaiting-transport records that the adapter\n// holds it); `resume` re-emits, runs due duties and re-emits unsent acks;\n// `tick` expires and retains (engine.ts).\n//\n// Custody (Delivery 0.83 RLTP-DEL-6120 to 6135): the holder keeps every\n// outbound document until a service takes it or the holder gives it up,\n// across a lock and the end of a process. One createHolder is one opening.\n// After its first resume, `pendingTransport(when)` names what is to be\n// handed over: the outbox items neither terminal nor accepted (held ones\n// included) and the unsent acks, each with its envelope, its first\n// submission and its deadline, none past it. A transport hands over only\n// such entries, through `handOver(entry, when, start)`: the check of\n// `mayHandOver` and the start of the deposit in one step of the holder's\n// queue, true only for an entry this opening issued that is still pending,\n// unchanged, before its deadline. A duplicate's stored ack past its retries\n// appears once as a `resend` entry (Delivery RLTP-DEL-6330). A document missing from the\n// view is no longer to be sent. `await close()` ends the opening at a lock or\n// the end of a process (resolved once the running operation finished, the\n// moment the next opening may start): every later call rejects with InfraError\n// 'closed', mayHandOver answers false, and nothing issued before\n// authorizes anything; the next opening is a new createHolder over the\n// same store, resumed first.\nimport { createEngine } from './engine.js'\nimport type { CommitListener, EnginePorts, HolderModule, TransportEntry, TransportRefusal, TransportView } from './engine.js'\nimport type { DeliveryReport } from './ports.js'\nimport { DECIDE, collectDecisions, promptsModule } from './prompts.js'\nimport type { ActResult, ReceiveResult, ResumeResult } from './results.js'\nimport { InfraError } from './results.js'\nimport { commitViolations } from './invariants.js'\nimport type { CommitOp } from './invariants.js'\nimport type { HolderState } from './state.js'\nimport { toOpaque } from './state.js'\nimport { trustModule } from './trust/mapping.js'\nimport { IDENTITY_COMMANDS, deviceKeyOf, identityModule } from './identity-state.js'\nimport type { DeviceKeyResult } from './identity-state.js'\nimport { PROFILE_SET } from './trust/profile.js'\nimport type { ProfileContent } from './profile.js'\nimport type { Dec, Millis, OpaqueHolderState, PromptChoice, Setting, TrustClass } from './state.js'\nimport { TRUST_COMMANDS } from './trust/mapping.js'\nimport { ENTRY_COMMANDS } from './trust/entries.js'\nimport { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js'\nimport { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js'\nimport { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js'\nimport { MESSAGE_COMMANDS, messageModule } from './message/holder.js'\nimport type { Json } from './core.js'\nimport { contactView, contactsView, deliveryStatusView, groupsView, inboxView, profileView, promptsView } from './views.js'\nimport type { ContactView, DeliveryStatusView, GroupView, InboxMessageView, ProfileView, PromptView } from './views.js'\n\n/** The committed state and its commitSeq; the state is opaque (note §4.5):\n * apps read the views, store tooling may persist it. */\nexport interface HolderSnapshot { commitSeq: Dec, state: OpaqueHolderState }\n\nexport interface HolderOptions {\n /** domain modules to register beside the built-ins, the prompts and the trust module */\n modules?: readonly HolderModule[]\n /** testing mode: check the invariants of invariants.ts on every commit,\n * before the store's CAS; a violation throws InfraError\n * 'invariant-violated' (cause: the violations) and nothing commits */\n invariants?: boolean\n}\n\n/** The options of a human act (note §4.2): its time and the actId the app\n * mints when the human acts. */\nexport interface HumanActOptions { when: Millis, actId: string }\n\nexport interface Holder {\n /** any registered command by name, for modules and tests; apps use the typed acts */\n act (command: string, input: unknown, when: Millis, opts?: { actId?: string }): Promise<ActResult>\n /** the human's decision on an open prompt: a human act under the app's\n * actId (note §4.2); a missing actId is also refused at runtime */\n decide (promptId: string, choice: PromptChoice, opts: HumanActOptions): Promise<ActResult>\n /** the Trust act: the anchor mapping class on toward the contact (2770); human */\n trust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** trust withdrawn: the anchor mapping class off (2840, 2850); human */\n untrust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the pause of 5.4: star and blinded group star off, or back to default; human */\n pauseTrust (contactId: string, paused: boolean, opts: HumanActOptions): Promise<ActResult>\n /** one class's setting toward the contact (2780, 2810); human */\n setClass (contactId: string, cls: TrustClass, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the sealed group star's setting for one group toward the contact (2830); human */\n setGroupClass (contactId: string, groupId: string, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the manual merge (6640): at most one of them holds an entry; human */\n merge (contactIds: string[], opts: HumanActOptions): Promise<ActResult>\n /** departure (2260): the entry, the relationships of an alias, or one\n * relationship (relationshipId); human */\n depart (contactId: string, opts: HumanActOptions & { relationshipId?: string }): Promise<ActResult>\n /** 2240: entries re-commit from verified mappings recovered without them; not human */\n recover (opts: { when: Millis }): Promise<ActResult>\n /** a device name into the register before any key derived from it is presented (Identity §5.5); human */\n addDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the name's revocation mark: never removed, the name never given again (Identity §5.5); human */\n revokeDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the community anchor's rotation (Identity §5.4): step 1 (label,\n * closure, 6596 decided) when none runs, else step 2 of the running one\n * through the Log port; resume carries step 2 on its own (identity-state.ts) */\n rotateAnchor (opts: HumanActOptions): Promise<ActResult>\n /** the own profile (Trust 6b): validated (6430, 6435, 6475), the next\n * revision of the one counter (6450), delivered on every relationship\n * the profile class is on for (6455); human */\n setProfile (content: ProfileContent, opts: HumanActOptions): Promise<ActResult>\n /** a displayed card with a fresh own challenge under a fresh pair\n * anchor (Encounter 5.3, 4.4): the event encounter.shown carries the\n * card to display; `name` the card's display name (default: the own\n * profile's); human */\n show (opts: HumanActOptions & { name?: string }): Promise<ActResult>\n /** the scanner's step on a displayed card (Encounter 5.8): the record,\n * the fresh tuple, the bundle; encounter.scanned carries the sent card\n * for the optical leg; human */\n scan (card: Json, opts: HumanActOptions & { name?: string }): Promise<ActResult>\n /** the optical leg (Encounter 5.8, 5710): a sent card shown by the scanner; human */\n captureSentCard (card: Json, opts: HumanActOptions): Promise<ActResult>\n /** the counter-step toward a contact met as displayer (Encounter 5.8 step 4); human */\n counter (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** a group founded under a fresh pair anchor (Access 3.4.1); its rule\n * vouchThreshold (default \"1\") is group state; event group.founded; human */\n foundGroup (group: { name: string, vouchThreshold?: string, listed?: boolean }, opts: HumanActOptions): Promise<ActResult>\n /** invite a contact into a group: the prelude, then the invite on its\n * answer (Membership 1.2, 3.1); the contact decides on a group-invite\n * prompt; human */\n invite (groupId: string, contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the mediator's act (Trust §8, this library's start of it): the\n * requester gets an offer naming the target by an opaque designator and\n * at most the `label` the human types here, with the mediator's\n * ack-delay declaration; the requester decides on an\n * `introduction` prompt, the target on another; human */\n introduce (requesterId: string, targetId: string, opts: HumanActOptions & { label?: string }): Promise<ActResult>\n /** a vouch@2 for a member anchor whose consent pair this holder holds\n * (Access 5.3, Membership 3.4); human */\n vouchFor (groupId: string, member: string, opts: HumanActOptions & { provenance?: 'met' | 'introduced' }): Promise<ActResult>\n /** a text message to the contact (Message Tasks 3, 5): 1 to 4096 code\n * points, replyTo the mid of an earlier message of the relationship. It\n * goes on a ready, unblocked relationship (canMessage); otherwise refused\n * as not-ready, blocked or no-own-channel, and the app keeps it unsent.\n * Event message.sent {mid, digest}; deliveryStatus(digest) is its sender\n * status. Undelivered, it ends as failed(expired-by-adapter-policy) at\n * the retry horizon (P7D by default, P90D at most), before its sender\n * lifetime sentAt + P179D: failed(task-expired) is not reached for a\n * message under any horizon the engine admits; human */\n sendMessage (contactId: string, text: string, opts: HumanActOptions & { replyTo?: string }): Promise<ActResult>\n /** the inbox entries the app has durably taken over leave the inbox\n * (4420); their completion record stays (4350); not human */\n takeMessages (ids: string[], opts: { when: Millis }): Promise<ActResult>\n /** the block (Message Tasks 6): set on every relationship of the\n * contact's entry. Messages, invitations and the holder's own offers on\n * them stop; the protocol steps owed continue; the contact observes\n * nothing it would not without the block. Event contact.blocked; human */\n block (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the block cleared on every relationship of the entry: nothing that\n * was discarded under it reappears (6510); human */\n unblock (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the device key of a held, unrevoked device name under an own anchor\n * context (Identity §5.5); reads, changes nothing */\n deviceKey (name: string, contextLabel: string): Promise<DeviceKeyResult>\n tick (when: Millis): Promise<ActResult>\n resume (when: Millis): Promise<ResumeResult>\n report (report: DeliveryReport, when: Millis): Promise<ActResult>\n /** an arriving envelope, as the app's transport delivered it (non-human,\n * no actId; idempotent over the document digest) */\n receive (env: unknown, when: Millis): Promise<ReceiveResult>\n /** after every commit: its commitSeq and events, the cue to re-read the views */\n subscribe (listener: CommitListener): () => void\n snapshot (): Promise<HolderSnapshot>\n contacts (): Promise<ContactView[]>\n /** by entry id or alias */\n contact (id: string): Promise<ContactView | undefined>\n groups (): Promise<GroupView[]>\n profile (): Promise<ProfileView>\n prompts (): Promise<PromptView[]>\n /** the messages accepted and not yet taken over (Message Tasks 4.5),\n * by display time; event message.received announces each */\n inbox (): Promise<InboxMessageView[]>\n /** by document digest or threadId */\n deliveryStatus (digestOrThreadId: string): Promise<DeliveryStatusView>\n /** what the holder keeps for transport at `when`, after this opening's\n * first completed resume (else `{ok: false, code: 'not-resumed'}`) */\n pendingTransport (when: Millis): Promise<TransportView | TransportRefusal>\n /** right before a hand-over: whether this opening's `entry` may go now */\n mayHandOver (entry: TransportEntry, when: Millis): Promise<boolean>\n /** the hand-over: the same check, then `start()` (which starts the\n * deposit synchronously and says whether it did) inside the holder's\n * queue; true when both said yes */\n handOver (entry: TransportEntry, when: Millis, start: () => boolean): Promise<boolean>\n /** ends this opening (a lock, the end of a process); resolves once the\n * operation running at the call has finished: after that the opening\n * commits nothing more, and the next opening may start */\n close (): Promise<void>\n readonly closed: boolean\n}\n\n/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.\n * The crypto handle (default globalThis.crypto) is resolved and probed\n * here and also feeds the default entropy; an app that injects one\n * passes the same handle to seedKeys(seed, crypto). */\nexport async function createHolder (ports: EnginePorts, opts: HolderOptions = {}): Promise<Holder> {\n const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), messageModule(), ...(opts.modules ?? [])]\n const check = opts.invariants === true\n ? (before: Readonly<HolderState>, after: Readonly<HolderState>, op: CommitOp) => {\n const v = commitViolations(before, after, op)\n if (v.length) throw new InfraError('invariant-violated', `invariants broken by ${op.kind}: ${v.map((x) => `[${x.invariant}] ${x.detail}`).join('; ')}`, { cause: v })\n }\n : undefined\n const engine = await createEngine(ports, [promptsModule(collectDecisions(modules)), ...modules], { ...(check ? { check } : {}), accessFrom: localAccess })\n const read = async () => (await engine.snapshot()).state\n /** a human act: `when` and actId from the options, a missing actId refused by the engine */\n const human = (command: string, input: unknown, o: HumanActOptions | undefined) =>\n engine.act(command, input, o?.when as Millis, o?.actId === undefined ? {} : { actId: o.actId })\n return Object.freeze({\n act: (command: string, input: unknown, when: Millis, o?: { actId?: string }) => engine.act(command, input, when, o),\n decide: (promptId: string, choice: PromptChoice, o: HumanActOptions) => human(DECIDE, { promptId, choice }, o),\n trust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: true }, o),\n untrust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: false }, o),\n pauseTrust: (contactId: string, paused: boolean, o: HumanActOptions) => human(TRUST_COMMANDS.pause, { contactId, paused }, o),\n setClass: (contactId: string, cls: TrustClass, setting: Setting, o: HumanActOptions) => human(TRUST_COMMANDS.setClass, { contactId, cls, setting }, o),\n setGroupClass: (contactId: string, groupId: string, setting: Setting, o: HumanActOptions) =>\n human(TRUST_COMMANDS.setGroupClass, { contactId, groupId, setting }, o),\n merge: (contactIds: string[], o: HumanActOptions) => human(ENTRY_COMMANDS.merge, { contactIds }, o),\n depart: (contactId: string, o: HumanActOptions & { relationshipId?: string }) =>\n human(ENTRY_COMMANDS.depart, o?.relationshipId === undefined ? { contactId } : { contactId, relationshipId: o.relationshipId }, o),\n recover: (o: { when: Millis }) => engine.act(TRUST_COMMANDS.recover, {}, o?.when as Millis),\n rotateAnchor: (o: HumanActOptions) => human(IDENTITY_COMMANDS.rotate, {}, o),\n setProfile: (content: ProfileContent, o: HumanActOptions) => human(PROFILE_SET, content, o),\n show: (o: HumanActOptions & { name?: string }) => human(ENCOUNTER_COMMANDS.show, o?.name === undefined ? {} : { name: o.name }, o),\n scan: (card: Json, o: HumanActOptions & { name?: string }) => human(ENCOUNTER_COMMANDS.scan, o?.name === undefined ? { card } : { card, name: o.name }, o),\n captureSentCard: (card: Json, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.capture, { card }, o),\n counter: (contactId: string, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.counter, { contactId }, o),\n foundGroup: (g: { name: string, vouchThreshold?: string, listed?: boolean }, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.found, g, o),\n invite: (groupId: string, contactId: string, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.invite, { groupId, contactId }, o),\n vouchFor: (groupId: string, member: string, o: HumanActOptions & { provenance?: 'met' | 'introduced' }) =>\n human(MEMBERSHIP_COMMANDS.vouch, o?.provenance === undefined ? { groupId, member } : { groupId, member, provenance: o.provenance }, o),\n introduce: (requesterId: string, targetId: string, o: HumanActOptions & { label?: string }) =>\n human(INTRODUCTION_COMMANDS.introduce, o?.label === undefined ? { requesterId, targetId } : { requesterId, targetId, label: o.label }, o),\n sendMessage: (contactId: string, text: string, o: HumanActOptions & { replyTo?: string }) =>\n human(MESSAGE_COMMANDS.send, o?.replyTo === undefined ? { contactId, text } : { contactId, text, replyTo: o.replyTo }, o),\n takeMessages: (ids: string[], o: { when: Millis }) => engine.act(MESSAGE_COMMANDS.take, { ids }, o?.when as Millis),\n block: (contactId: string, o: HumanActOptions) => human(MESSAGE_COMMANDS.block, { contactId, blocked: true }, o),\n unblock: (contactId: string, o: HumanActOptions) => human(MESSAGE_COMMANDS.block, { contactId, blocked: false }, o),\n addDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.addDevice, { name }, o),\n revokeDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.revokeDevice, { name }, o),\n deviceKey: async (name: string, contextLabel: string) => deviceKeyOf(await read(), ports.keys, name, contextLabel),\n tick: (when: Millis) => engine.tick(when),\n resume: (when: Millis) => engine.resume(when),\n report: (report: DeliveryReport, when: Millis) => engine.report(report, when),\n receive: (env: unknown, when: Millis) => engine.receive(env, when),\n subscribe: (listener: CommitListener) => engine.subscribe(listener),\n snapshot: async (): Promise<HolderSnapshot> => {\n const s = await engine.snapshot()\n return Object.freeze({ commitSeq: s.commitSeq, state: toOpaque(s.state) })\n },\n contacts: async () => contactsView(await read()),\n contact: async (id: string) => contactView(await read(), id),\n groups: async () => groupsView(await read()),\n profile: async () => profileView(await read()),\n prompts: async () => promptsView(await read()),\n inbox: async () => inboxView(await read()),\n deliveryStatus: async (x: string) => deliveryStatusView(await read(), x),\n pendingTransport: (when: Millis) => engine.pendingTransport(when),\n mayHandOver: (entry: TransportEntry, when: Millis) => engine.mayHandOver(entry, when),\n handOver: (entry: TransportEntry, when: Millis, start: () => boolean) => engine.handOver(entry, when, start),\n close: () => engine.close(),\n get closed () { return engine.closed },\n })\n}\n"]}