@real-life/trust-protocol 0.5.0 → 0.6.1

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 (44) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +97 -34
  3. package/dist/adapters/vti-mediator.d.ts +18 -5
  4. package/dist/adapters/vti-mediator.d.ts.map +1 -1
  5. package/dist/adapters/vti-mediator.js +143 -17
  6. package/dist/adapters/vti-mediator.js.map +1 -1
  7. package/dist/codec.d.ts +2 -9
  8. package/dist/codec.d.ts.map +1 -1
  9. package/dist/codec.js +61 -96
  10. package/dist/codec.js.map +1 -1
  11. package/dist/engine.d.ts +66 -2
  12. package/dist/engine.d.ts.map +1 -1
  13. package/dist/engine.js +393 -23
  14. package/dist/engine.js.map +1 -1
  15. package/dist/holder-api.d.ts +22 -2
  16. package/dist/holder-api.d.ts.map +1 -1
  17. package/dist/holder-api.js +43 -3
  18. package/dist/holder-api.js.map +1 -1
  19. package/dist/{holder-state-v2.d.ts → holder-state-v3.d.ts} +210 -207
  20. package/dist/holder-state-v3.d.ts.map +1 -0
  21. package/dist/holder-state-v3.js +2 -0
  22. package/dist/holder-state-v3.js.map +1 -0
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal.d.ts +1 -2
  27. package/dist/internal.d.ts.map +1 -1
  28. package/dist/internal.js.map +1 -1
  29. package/dist/results.d.ts +42 -3
  30. package/dist/results.d.ts.map +1 -1
  31. package/dist/results.js.map +1 -1
  32. package/dist/state.d.ts +22 -9
  33. package/dist/state.d.ts.map +1 -1
  34. package/dist/state.js.map +1 -1
  35. package/package.json +4 -6
  36. package/schemas/{holder-state-v2.schema.json → holder-state-v3.schema.json} +50 -5
  37. package/dist/holder-state-v1.d.ts +0 -801
  38. package/dist/holder-state-v1.d.ts.map +0 -1
  39. package/dist/holder-state-v1.js +0 -2
  40. package/dist/holder-state-v1.js.map +0 -1
  41. package/dist/holder-state-v2.d.ts.map +0 -1
  42. package/dist/holder-state-v2.js +0 -2
  43. package/dist/holder-state-v2.js.map +0 -1
  44. package/schemas/holder-state-v1.schema.json +0 -3880
@@ -1,6 +1,6 @@
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
- import type { ActResult, ReceiveResult, ResumeResult } from './results.js';
3
+ import type { ActResult, ReceiveResult, ReplayResult, 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';
@@ -156,6 +156,26 @@ export interface Holder {
156
156
  inbox(): Promise<InboxMessageView[]>;
157
157
  /** by document digest or threadId */
158
158
  deliveryStatus(digestOrThreadId: string): Promise<DeliveryStatusView>;
159
+ /** the journaled result of the human act `actId` (any of the acts above:
160
+ * for sendMessage its `message.sent` event with `mid` and `digest`), or
161
+ * `{ok: false, code: 'unknown-act'}`; a pure read that never runs the
162
+ * act, never mints a mid, commits nothing. The question an app asks
163
+ * after a crash or a lock instead of repeating the act blind */
164
+ replay(actId: string, when: Millis): Promise<ReplayResult>;
165
+ /** what the holder keeps for transport at `when`, after this opening's
166
+ * first completed resume (else `{ok: false, code: 'not-resumed'}`) */
167
+ pendingTransport(when: Millis): Promise<TransportView | TransportRefusal>;
168
+ /** right before a hand-over: whether this opening's `entry` may go now */
169
+ mayHandOver(entry: TransportEntry, when: Millis): Promise<boolean>;
170
+ /** the hand-over: the same check, then `start()` (which starts the
171
+ * deposit synchronously and says whether it did) inside the holder's
172
+ * queue; true when both said yes */
173
+ handOver(entry: TransportEntry, when: Millis, start: () => boolean): Promise<boolean>;
174
+ /** ends this opening (a lock, the end of a process); resolves once the
175
+ * operation running at the call has finished: after that the opening
176
+ * commits nothing more, and the next opening may start */
177
+ close(): Promise<void>;
178
+ readonly closed: boolean;
159
179
  }
160
180
  /** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.
161
181
  * 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":"AAgEA,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,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAOnG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvH;yDACyD;AACzD,MAAM,WAAW,cAAc;IAAG,SAAS,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE;AAE5E,MAAM,WAAW,aAAa;IAC5B,wFAAwF;IACxF,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IACjC;;2EAEuE;IACvE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;iCACiC;AACjC,MAAM,WAAW,eAAe;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAEhE,MAAM,W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IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACtF;;+DAE2D;IAC3D,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED;;;wDAGwD;AACxD,wBAAsB,YAAY,CAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqEjG"}
@@ -51,6 +51,20 @@
51
51
  // unrevoked name under an own anchor context (identity-state.ts).
52
52
  // A missing actId is refused at runtime as actid-missing.
53
53
  //
54
+ // One actId, one result: replay(actId, when) reads the journaled result of
55
+ // any of the human acts above (its events: for sendMessage `message.sent`
56
+ // with mid and digest; its commit time; its documents and whether a repeat
57
+ // would hand them out at `when`), or answers unknown-act. It runs nothing
58
+ // and commits nothing, needs no keys, and works on every opening over the
59
+ // store. A repeat of the act under the same actId answers the same events
60
+ // at any clock, across a lock and a new opening; the journal holds an act
61
+ // for the retention max(P90D, retry.horizonMs) after its commit and after
62
+ // the last step of each of its documents, in holder time (engine.ts),
63
+ // after which the actId is unknown. An app that does not
64
+ // know whether an act committed (a crash, an unknown-commit-outcome, a
65
+ // lock) asks replay; on unknown-act the act did not commit or has left
66
+ // the journal, and only the human decides to act anew.
67
+ //
54
68
  // Reading: the views (views.ts) over one snapshot each, carrying its
55
69
  // commitSeq. `subscribe` announces every commit with its commitSeq and
56
70
  // events; the app re-reads the views it shows, and a view read after the
@@ -58,9 +72,29 @@
58
72
  //
59
73
  // Delivery: `receive(env, when)` runs Delivery §6.2 in the core and
60
74
  // dispatches through the task register (receive.ts); `report` takes the
61
- // adapter's reports (on an ack's digest it marks the ack sent); `resume`
62
- // re-emits, runs due duties and re-emits unsent acks; `tick` expires and
63
- // retains (engine.ts).
75
+ // adapter's reports (on an ack's digest: accepted or delivered marks it
76
+ // sent, failed gives it up, awaiting-transport records that the adapter
77
+ // holds it); `resume` re-emits, runs due duties and re-emits unsent acks;
78
+ // `tick` expires and retains (engine.ts).
79
+ //
80
+ // Custody (Delivery 0.83 RLTP-DEL-6120 to 6135): the holder keeps every
81
+ // outbound document until a service takes it or the holder gives it up,
82
+ // across a lock and the end of a process. One createHolder is one opening.
83
+ // After its first resume, `pendingTransport(when)` names what is to be
84
+ // handed over: the outbox items neither terminal nor accepted (held ones
85
+ // included) and the unsent acks, each with its envelope, its first
86
+ // submission and its deadline, none past it. A transport hands over only
87
+ // such entries, through `handOver(entry, when, start)`: the check of
88
+ // `mayHandOver` and the start of the deposit in one step of the holder's
89
+ // queue, true only for an entry this opening issued that is still pending,
90
+ // unchanged, before its deadline. A duplicate's stored ack past its retries
91
+ // appears once as a `resend` entry (Delivery RLTP-DEL-6330). A document missing from the
92
+ // view is no longer to be sent. `await close()` ends the opening at a lock or
93
+ // the end of a process (resolved once the running operation finished, the
94
+ // moment the next opening may start): every later call rejects with InfraError
95
+ // 'closed', mayHandOver answers false, and nothing issued before
96
+ // authorizes anything; the next opening is a new createHolder over the
97
+ // same store, resumed first.
64
98
  import { createEngine } from './engine.js';
65
99
  import { DECIDE, collectDecisions, promptsModule } from './prompts.js';
66
100
  import { InfraError } from './results.js';
@@ -137,6 +171,12 @@ export async function createHolder(ports, opts = {}) {
137
171
  prompts: async () => promptsView(await read()),
138
172
  inbox: async () => inboxView(await read()),
139
173
  deliveryStatus: async (x) => deliveryStatusView(await read(), x),
174
+ replay: (actId, when) => engine.replay(actId, when),
175
+ pendingTransport: (when) => engine.pendingTransport(when),
176
+ mayHandOver: (entry, when) => engine.mayHandOver(entry, when),
177
+ handOver: (entry, when, start) => engine.handOver(entry, when, start),
178
+ close: () => engine.close(),
179
+ get closed() { return engine.closed; },
140
180
  });
141
181
  }
142
182
  //# sourceMappingURL=holder-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"holder-api.js","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAAA,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,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,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;QAC1C,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// 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 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 { 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}\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 })\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,yEAAyE;AACzE,wEAAwE;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MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;QACnE,gBAAgB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACjE,WAAW,EAAE,CAAC,KAAqB,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC;QACrF,QAAQ,EAAE,CAAC,KAAqB,EAAE,IAAY,EAAE,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// One actId, one result: replay(actId, when) reads the journaled result of\n// any of the human acts above (its events: for sendMessage `message.sent`\n// with mid and digest; its commit time; its documents and whether a repeat\n// would hand them out at `when`), or answers unknown-act. It runs nothing\n// and commits nothing, needs no keys, and works on every opening over the\n// store. A repeat of the act under the same actId answers the same events\n// at any clock, across a lock and a new opening; the journal holds an act\n// for the retention max(P90D, retry.horizonMs) after its commit and after\n// the last step of each of its documents, in holder time (engine.ts),\n// after which the actId is unknown. An app that does not\n// know whether an act committed (a crash, an unknown-commit-outcome, a\n// lock) asks replay; on unknown-act the act did not commit or has left\n// the journal, and only the human decides to act anew.\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, ReplayResult, 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 /** the journaled result of the human act `actId` (any of the acts above:\n * for sendMessage its `message.sent` event with `mid` and `digest`), or\n * `{ok: false, code: 'unknown-act'}`; a pure read that never runs the\n * act, never mints a mid, commits nothing. The question an app asks\n * after a crash or a lock instead of repeating the act blind */\n replay (actId: string, when: Millis): Promise<ReplayResult>\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 replay: (actId: string, when: Millis) => engine.replay(actId, when),\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"]}