@real-life/trust-protocol 0.3.1 → 0.4.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 (264) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +187 -78
  3. package/dist/ack.d.ts +84 -0
  4. package/dist/ack.d.ts.map +1 -0
  5. package/dist/ack.js +114 -0
  6. package/dist/ack.js.map +1 -0
  7. package/dist/adapters/vti-mediator.d.ts +154 -0
  8. package/dist/adapters/vti-mediator.d.ts.map +1 -0
  9. package/dist/adapters/vti-mediator.js +621 -0
  10. package/dist/adapters/vti-mediator.js.map +1 -0
  11. package/dist/anchor.d.ts +226 -0
  12. package/dist/anchor.d.ts.map +1 -0
  13. package/dist/anchor.js +347 -0
  14. package/dist/anchor.js.map +1 -0
  15. package/dist/{holder.d.ts → carrier-holder.d.ts} +1 -1
  16. package/dist/carrier-holder.d.ts.map +1 -0
  17. package/dist/{holder.js → carrier-holder.js} +5 -4
  18. package/dist/carrier-holder.js.map +1 -0
  19. package/dist/carrier-identity.js +4 -4
  20. package/dist/carrier-identity.js.map +1 -1
  21. package/dist/carrier.d.ts.map +1 -1
  22. package/dist/carrier.js +4 -3
  23. package/dist/carrier.js.map +1 -1
  24. package/dist/ceremony.d.ts +3 -2
  25. package/dist/ceremony.d.ts.map +1 -1
  26. package/dist/ceremony.js +16 -26
  27. package/dist/ceremony.js.map +1 -1
  28. package/dist/codec.d.ts +46 -0
  29. package/dist/codec.d.ts.map +1 -0
  30. package/dist/codec.js +410 -0
  31. package/dist/codec.js.map +1 -0
  32. package/dist/continuity.d.ts +67 -0
  33. package/dist/continuity.d.ts.map +1 -0
  34. package/dist/continuity.js +110 -0
  35. package/dist/continuity.js.map +1 -0
  36. package/dist/core.d.ts +4 -0
  37. package/dist/core.d.ts.map +1 -1
  38. package/dist/core.js.map +1 -1
  39. package/dist/crypto.d.ts +23 -7
  40. package/dist/crypto.d.ts.map +1 -1
  41. package/dist/crypto.js +54 -20
  42. package/dist/crypto.js.map +1 -1
  43. package/dist/delivery.d.ts +31 -3
  44. package/dist/delivery.d.ts.map +1 -1
  45. package/dist/delivery.js +75 -28
  46. package/dist/delivery.js.map +1 -1
  47. package/dist/encounter/ceremony.d.ts +37 -0
  48. package/dist/encounter/ceremony.d.ts.map +1 -0
  49. package/dist/encounter/ceremony.js +662 -0
  50. package/dist/encounter/ceremony.js.map +1 -0
  51. package/dist/encounter.d.ts +91 -1
  52. package/dist/encounter.d.ts.map +1 -1
  53. package/dist/encounter.js +191 -12
  54. package/dist/encounter.js.map +1 -1
  55. package/dist/engine.d.ts +291 -0
  56. package/dist/engine.d.ts.map +1 -0
  57. package/dist/engine.js +1395 -0
  58. package/dist/engine.js.map +1 -0
  59. package/dist/entropy.d.ts +28 -0
  60. package/dist/entropy.d.ts.map +1 -0
  61. package/dist/entropy.js +96 -0
  62. package/dist/entropy.js.map +1 -0
  63. package/dist/events.d.ts +177 -0
  64. package/dist/events.d.ts.map +1 -0
  65. package/dist/events.js +2 -0
  66. package/dist/events.js.map +1 -0
  67. package/dist/fixtures.d.ts +30 -0
  68. package/dist/fixtures.d.ts.map +1 -0
  69. package/dist/fixtures.js +155 -0
  70. package/dist/fixtures.js.map +1 -0
  71. package/dist/forge.d.ts +47 -0
  72. package/dist/forge.d.ts.map +1 -0
  73. package/dist/forge.js +20 -0
  74. package/dist/forge.js.map +1 -0
  75. package/dist/group-star.d.ts +251 -0
  76. package/dist/group-star.d.ts.map +1 -0
  77. package/dist/group-star.js +348 -0
  78. package/dist/group-star.js.map +1 -0
  79. package/dist/holder-api.d.ts +137 -0
  80. package/dist/holder-api.d.ts.map +1 -0
  81. package/dist/holder-api.js +132 -0
  82. package/dist/holder-api.js.map +1 -0
  83. package/dist/holder-state-v1.d.ts +801 -0
  84. package/dist/holder-state-v1.d.ts.map +1 -0
  85. package/dist/holder-state-v1.js +2 -0
  86. package/dist/holder-state-v1.js.map +1 -0
  87. package/dist/identity-state.d.ts +43 -0
  88. package/dist/identity-state.d.ts.map +1 -0
  89. package/dist/identity-state.js +345 -0
  90. package/dist/identity-state.js.map +1 -0
  91. package/dist/identity.d.ts +24 -2
  92. package/dist/identity.d.ts.map +1 -1
  93. package/dist/identity.js +70 -11
  94. package/dist/identity.js.map +1 -1
  95. package/dist/index.d.ts +26 -1
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +77 -29
  98. package/dist/index.js.map +1 -1
  99. package/dist/internal.d.ts +36 -0
  100. package/dist/internal.d.ts.map +1 -0
  101. package/dist/internal.js +22 -0
  102. package/dist/internal.js.map +1 -0
  103. package/dist/introduction/holder.d.ts +18 -0
  104. package/dist/introduction/holder.d.ts.map +1 -0
  105. package/dist/introduction/holder.js +757 -0
  106. package/dist/introduction/holder.js.map +1 -0
  107. package/dist/introduction.d.ts +101 -0
  108. package/dist/introduction.d.ts.map +1 -0
  109. package/dist/introduction.js +132 -0
  110. package/dist/introduction.js.map +1 -0
  111. package/dist/invariants.d.ts +43 -0
  112. package/dist/invariants.d.ts.map +1 -0
  113. package/dist/invariants.js +883 -0
  114. package/dist/invariants.js.map +1 -0
  115. package/dist/keys-seed.d.ts +7 -0
  116. package/dist/keys-seed.d.ts.map +1 -0
  117. package/dist/keys-seed.js +133 -0
  118. package/dist/keys-seed.js.map +1 -0
  119. package/dist/log-memory.d.ts +12 -0
  120. package/dist/log-memory.d.ts.map +1 -0
  121. package/dist/log-memory.js +101 -0
  122. package/dist/log-memory.js.map +1 -0
  123. package/dist/membership/holder.d.ts +35 -0
  124. package/dist/membership/holder.d.ts.map +1 -0
  125. package/dist/membership/holder.js +852 -0
  126. package/dist/membership/holder.js.map +1 -0
  127. package/dist/membership.d.ts +92 -0
  128. package/dist/membership.d.ts.map +1 -0
  129. package/dist/membership.js +157 -0
  130. package/dist/membership.js.map +1 -0
  131. package/dist/ports.d.ts +237 -0
  132. package/dist/ports.d.ts.map +1 -0
  133. package/dist/ports.js +2 -0
  134. package/dist/ports.js.map +1 -0
  135. package/dist/profile.d.ts +56 -0
  136. package/dist/profile.d.ts.map +1 -0
  137. package/dist/profile.js +193 -0
  138. package/dist/profile.js.map +1 -0
  139. package/dist/prompts.d.ts +14 -0
  140. package/dist/prompts.d.ts.map +1 -0
  141. package/dist/prompts.js +69 -0
  142. package/dist/prompts.js.map +1 -0
  143. package/dist/receive.d.ts +133 -0
  144. package/dist/receive.d.ts.map +1 -0
  145. package/dist/receive.js +298 -0
  146. package/dist/receive.js.map +1 -0
  147. package/dist/results.d.ts +158 -0
  148. package/dist/results.d.ts.map +1 -0
  149. package/dist/results.js +21 -0
  150. package/dist/results.js.map +1 -0
  151. package/dist/schemas.d.ts.map +1 -1
  152. package/dist/schemas.js +42 -38
  153. package/dist/schemas.js.map +1 -1
  154. package/dist/sha256.d.ts +3 -0
  155. package/dist/sha256.d.ts.map +1 -0
  156. package/dist/sha256.js +69 -0
  157. package/dist/sha256.js.map +1 -0
  158. package/dist/star.d.ts +31 -0
  159. package/dist/star.d.ts.map +1 -0
  160. package/dist/star.js +56 -0
  161. package/dist/star.js.map +1 -0
  162. package/dist/state-builder.d.ts +42 -0
  163. package/dist/state-builder.d.ts.map +1 -0
  164. package/dist/state-builder.js +100 -0
  165. package/dist/state-builder.js.map +1 -0
  166. package/dist/state.d.ts +853 -0
  167. package/dist/state.d.ts.map +1 -0
  168. package/dist/state.js +36 -0
  169. package/dist/state.js.map +1 -0
  170. package/dist/store-contract.d.ts +11 -0
  171. package/dist/store-contract.d.ts.map +1 -0
  172. package/dist/store-contract.js +189 -0
  173. package/dist/store-contract.js.map +1 -0
  174. package/dist/store-memory.d.ts +8 -0
  175. package/dist/store-memory.d.ts.map +1 -0
  176. package/dist/store-memory.js +17 -0
  177. package/dist/store-memory.js.map +1 -0
  178. package/dist/testing.d.ts +22 -0
  179. package/dist/testing.d.ts.map +1 -0
  180. package/dist/testing.js +21 -0
  181. package/dist/testing.js.map +1 -0
  182. package/dist/trust/continuity.d.ts +71 -0
  183. package/dist/trust/continuity.d.ts.map +1 -0
  184. package/dist/trust/continuity.js +1216 -0
  185. package/dist/trust/continuity.js.map +1 -0
  186. package/dist/trust/duties.d.ts +67 -0
  187. package/dist/trust/duties.d.ts.map +1 -0
  188. package/dist/trust/duties.js +179 -0
  189. package/dist/trust/duties.js.map +1 -0
  190. package/dist/trust/entries.d.ts +139 -0
  191. package/dist/trust/entries.d.ts.map +1 -0
  192. package/dist/trust/entries.js +694 -0
  193. package/dist/trust/entries.js.map +1 -0
  194. package/dist/trust/group-star.d.ts +43 -0
  195. package/dist/trust/group-star.d.ts.map +1 -0
  196. package/dist/trust/group-star.js +188 -0
  197. package/dist/trust/group-star.js.map +1 -0
  198. package/dist/trust/mapping.d.ts +56 -0
  199. package/dist/trust/mapping.d.ts.map +1 -0
  200. package/dist/trust/mapping.js +584 -0
  201. package/dist/trust/mapping.js.map +1 -0
  202. package/dist/trust/profile.d.ts +25 -0
  203. package/dist/trust/profile.d.ts.map +1 -0
  204. package/dist/trust/profile.js +249 -0
  205. package/dist/trust/profile.js.map +1 -0
  206. package/dist/trust/star.d.ts +208 -0
  207. package/dist/trust/star.d.ts.map +1 -0
  208. package/dist/trust/star.js +588 -0
  209. package/dist/trust/star.js.map +1 -0
  210. package/dist/trust/state.d.ts +83 -0
  211. package/dist/trust/state.d.ts.map +1 -0
  212. package/dist/trust/state.js +154 -0
  213. package/dist/trust/state.js.map +1 -0
  214. package/dist/util-freeze.d.ts +3 -0
  215. package/dist/util-freeze.d.ts.map +1 -0
  216. package/dist/util-freeze.js +11 -0
  217. package/dist/util-freeze.js.map +1 -0
  218. package/dist/views.d.ts +147 -0
  219. package/dist/views.d.ts.map +1 -0
  220. package/dist/views.js +268 -0
  221. package/dist/views.js.map +1 -0
  222. package/dist/visibility.d.ts +5 -5
  223. package/dist/visibility.d.ts.map +1 -1
  224. package/dist/visibility.js +22 -28
  225. package/dist/visibility.js.map +1 -1
  226. package/dist/wire.d.ts +178 -84
  227. package/dist/wire.d.ts.map +1 -1
  228. package/dist/wire.js.map +1 -1
  229. package/package.json +58 -11
  230. package/schemas/holder-state-v1.schema.json +3880 -0
  231. package/dist/holder.d.ts.map +0 -1
  232. package/dist/holder.js.map +0 -1
  233. package/dist/probe/acks.d.ts +0 -27
  234. package/dist/probe/acks.d.ts.map +0 -1
  235. package/dist/probe/acks.js +0 -152
  236. package/dist/probe/acks.js.map +0 -1
  237. package/dist/probe/continuity.d.ts +0 -20
  238. package/dist/probe/continuity.d.ts.map +0 -1
  239. package/dist/probe/continuity.js +0 -805
  240. package/dist/probe/continuity.js.map +0 -1
  241. package/dist/probe/deps.d.ts +0 -61
  242. package/dist/probe/deps.d.ts.map +0 -1
  243. package/dist/probe/deps.js +0 -54
  244. package/dist/probe/deps.js.map +0 -1
  245. package/dist/probe/encounter.d.ts +0 -26
  246. package/dist/probe/encounter.d.ts.map +0 -1
  247. package/dist/probe/encounter.js +0 -938
  248. package/dist/probe/encounter.js.map +0 -1
  249. package/dist/probe/introduce.d.ts +0 -70
  250. package/dist/probe/introduce.d.ts.map +0 -1
  251. package/dist/probe/introduce.js +0 -295
  252. package/dist/probe/introduce.js.map +0 -1
  253. package/dist/probe/membership.d.ts +0 -90
  254. package/dist/probe/membership.d.ts.map +0 -1
  255. package/dist/probe/membership.js +0 -450
  256. package/dist/probe/membership.js.map +0 -1
  257. package/dist/probe/trust.d.ts +0 -156
  258. package/dist/probe/trust.d.ts.map +0 -1
  259. package/dist/probe/trust.js +0 -1233
  260. package/dist/probe/trust.js.map +0 -1
  261. package/dist/probe.d.ts +0 -7
  262. package/dist/probe.d.ts.map +0 -1
  263. package/dist/probe.js +0 -42
  264. package/dist/probe.js.map +0 -1
@@ -0,0 +1,177 @@
1
+ import type { JsonObject } from './core.js';
2
+ import type { Dec, OutboxStatus, PromptChoice, PromptKind } from './state.js';
3
+ /** Fields every event carries. */
4
+ export interface EventBase {
5
+ /** unique per event */
6
+ eventId: string;
7
+ /** the human act that caused it, if any (note §4.2) */
8
+ actId?: string;
9
+ /** commitSeq of the commit that caused it (state.ts), never the store token */
10
+ commitSeq: Dec;
11
+ }
12
+ export type HolderEvent = EventBase & ({
13
+ type: 'contact.added';
14
+ contactId: string;
15
+ }
16
+ /** a mapping verified on a relationship (6.3) */
17
+ | {
18
+ type: 'contact.verified';
19
+ contactId: string;
20
+ relationshipId: string;
21
+ }
22
+ /** a fresh tuple appended to a chain (6a.4, 6220): the fresh
23
+ * relationship `from` went into the chain `into`; contactId is the entry
24
+ * the chain's verifications go to after it */
25
+ | {
26
+ type: 'contact.chained';
27
+ contactId: string;
28
+ from: string;
29
+ into: string;
30
+ }
31
+ /** entries merged into one (2140): the survivor and the merged ids, now its aliases */
32
+ | {
33
+ type: 'contact.merged';
34
+ contactId: string;
35
+ merged: string[];
36
+ }
37
+ /** a relationship left a merged entry (2080): the remaining entry's id
38
+ * (renamed where 2100 says), the leaver's new entry id, the relationship */
39
+ | {
40
+ type: 'contact.split';
41
+ contactId: string;
42
+ leaver: string;
43
+ relationshipId: string;
44
+ }
45
+ /** relationships departed (2260): removed says the entry went with them */
46
+ | {
47
+ type: 'contact.departed';
48
+ contactId: string;
49
+ relationshipIds: string[];
50
+ removed: boolean;
51
+ }
52
+ /** the Trust act: anchor-mapping class on (2770) */
53
+ | {
54
+ type: 'trust.given';
55
+ contactId: string;
56
+ } | {
57
+ type: 'trust.received';
58
+ contactId: string;
59
+ }
60
+ /** the pause of 5.4: star and blinded group star off, or back */
61
+ | {
62
+ type: 'trust.paused';
63
+ contactId: string;
64
+ paused: boolean;
65
+ } | {
66
+ type: 'group.joined';
67
+ groupId: string;
68
+ } | {
69
+ type: 'prompt.opened';
70
+ promptId: string;
71
+ kind: PromptKind;
72
+ }
73
+ /** the human decided a prompt; it is closed (prompts.ts) */
74
+ | {
75
+ type: 'prompt.decided';
76
+ promptId: string;
77
+ kind: PromptKind;
78
+ choice: PromptChoice;
79
+ }
80
+ /** sender status trias (Delivery §6.1) */
81
+ | {
82
+ type: 'delivery.status';
83
+ digest: string;
84
+ threadId: string;
85
+ status: OutboxStatus;
86
+ late?: boolean;
87
+ }
88
+ /** contactId null: the holder's own profile */
89
+ | {
90
+ type: 'profile.updated';
91
+ contactId: string | null;
92
+ }
93
+ /** the community anchor's rotation completed: the head is this generation (Identity §5.4) */
94
+ | {
95
+ type: 'anchor.rotated';
96
+ generation: Dec;
97
+ }
98
+ /** a device name entered the register (Identity §5.5) */
99
+ | {
100
+ type: 'device.added';
101
+ name: string;
102
+ }
103
+ /** a device name was marked revoked (Identity §5.5) */
104
+ | {
105
+ type: 'device.revoked';
106
+ name: string;
107
+ }
108
+ /** resume found a duty of a registered kind at a version no handler
109
+ * knows: kept untouched, announced once per resume (engine.ts) */
110
+ | {
111
+ type: 'duty.unsupported';
112
+ dutyId: string;
113
+ kind: string;
114
+ v: number;
115
+ }
116
+ /** a star (5.2a) completed on a relationship: its accepted snapshot changed */
117
+ | {
118
+ type: 'star.accepted';
119
+ contactId: string;
120
+ relationshipId: string;
121
+ salt: Dec;
122
+ }
123
+ /** a group star (5.2b) completed on a relationship; sharedGroups may have changed */
124
+ | {
125
+ type: 'groupStar.accepted';
126
+ contactId: string;
127
+ relationshipId: string;
128
+ salt: Dec;
129
+ }
130
+ /** a card displayed with a fresh own challenge (Encounter 5.3): `card`
131
+ * is the optical payload to show (Encounter 6) */
132
+ | {
133
+ type: 'encounter.shown';
134
+ challenge: string;
135
+ card: JsonObject;
136
+ }
137
+ /** the scanner's step (5.8 trunk 2–3): `card` is its sent card, the
138
+ * optical leg's payload where no network carries the bundle */
139
+ | {
140
+ type: 'encounter.scanned';
141
+ contactId: string;
142
+ card: JsonObject;
143
+ }
144
+ /** an enactment record created (5.5), on either side */
145
+ | {
146
+ type: 'encounter.recorded';
147
+ contactId: string;
148
+ relationshipId: string;
149
+ role: 'scanner' | 'displayer';
150
+ }
151
+ /** the counterparty's step credential accepted (5.6): the edge now
152
+ * holds it; mutual when the own one is issued too (4.2) */
153
+ | {
154
+ type: 'encounter.accepted';
155
+ contactId: string;
156
+ relationshipId: string;
157
+ mutual: boolean;
158
+ }
159
+ /** a group founded by this holder (Access 3.4.1) */
160
+ | {
161
+ type: 'group.founded';
162
+ groupId: string;
163
+ }
164
+ /** a member admitted by this holder, by its member anchor */
165
+ | {
166
+ type: 'group.admitted';
167
+ groupId: string;
168
+ member: string;
169
+ }
170
+ /** a vouch@2 issued by this holder for a member anchor (Access 5.3) */
171
+ | {
172
+ type: 'group.vouched';
173
+ groupId: string;
174
+ member: string;
175
+ });
176
+ export type HolderEventType = HolderEvent['type'];
177
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +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,MA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,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,CAC7D,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA"}
package/dist/events.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=events.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,30 @@
1
+ import type { HolderModule } from './engine.js';
2
+ import type { HolderState, PromptKind } from './state.js';
3
+ /**
4
+ * A populated, valid HolderState, fresh on every call:
5
+ * - c-alice: met in a ceremony, trusted (anchor mapping on), mappings
6
+ * both ways, a verified profile
7
+ * - c-bob: introduced via c-alice, an alias e-bob-old, two relationships
8
+ * of which r-bob-2 lags (its anchor head is a superseded prev on
9
+ * r-bob-1), trusted and paused (star and group star off)
10
+ * - one group g-garden, the own profile (revision 3), one accepted
11
+ * outbox item to c-alice, one group-invite prompt
12
+ */
13
+ export declare function sampleState(): HolderState;
14
+ /** The command of openPromptModule. */
15
+ export declare const OPEN_PROMPT = "test.prompt.open";
16
+ /** Input of OPEN_PROMPT: the prompt without openedAt, which is `when`. */
17
+ export interface OpenPromptInput {
18
+ id: string;
19
+ kind: PromptKind;
20
+ contactId?: string;
21
+ groupId?: string;
22
+ expiresAt?: number;
23
+ }
24
+ /**
25
+ * A module for tests: its non-human command OPEN_PROMPT opens a prompt
26
+ * the way a domain module will, and announces prompt.opened. An id that
27
+ * is already open is a programming error and throws.
28
+ */
29
+ export declare const openPromptModule: HolderModule;
30
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAU,UAAU,EAAS,MAAM,YAAY,CAAA;AA6DxE;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAK,WAAW,CA8D1C;AAED,uCAAuC;AACvC,eAAO,MAAM,WAAW,qBAAqB,CAAA;AAE7C,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;AAE3H;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAoB7B,CAAA"}
@@ -0,0 +1,155 @@
1
+ // fixtures — test states and helper modules for ./testing (lib Stage 2, PR 2).
2
+ //
3
+ // sampleState() is a populated, valid HolderState for view tests: it
4
+ // passes the codec, but it is assembled by hand, not by acts, and its
5
+ // keys and anchors are placeholders, not derivations. The real test-state
6
+ // builder (stateBuilder) arrives in PR 4. openPromptModule stands in for
7
+ // the domain modules that open prompts in later PRs.
8
+ import { CODEC } from './codec.js';
9
+ import { emptyState } from './state.js';
10
+ const T = Date.parse('2026-10-14T09:00:00Z');
11
+ // placeholder key material: strings of the right family, no keys behind them
12
+ const KA_ALICE = 'z6LSaliceAliceAliceAliceAliceAliceAliceAliceAlic';
13
+ const KA_BOB = 'z6LSbobBobBobBobBobBobBobBobBobBobBobBobBobBobBob';
14
+ const OWN_ALICE = 'z6LSownAliceOwnAliceOwnAliceOwnAliceOwnAliceOwnA';
15
+ const OWN_BOB_1 = 'z6LSownBobOneOwnBobOneOwnBobOneOwnBobOneOwnBobOn';
16
+ const OWN_BOB_2 = 'z6LSownBobTwoOwnBobTwoOwnBobTwoOwnBobTwoOwnBobTw';
17
+ const ALICE_PAIR = 'did:key:z6MkalicePairAlicePairAlicePairAlicePairAli';
18
+ const BOB_PAIR_1 = 'did:key:z6MkbobPairOneBobPairOneBobPairOneBobPairOn';
19
+ const BOB_PAIR_2 = 'did:key:z6MkbobPairTwoBobPairTwoBobPairTwoBobPairTw';
20
+ const ALICE_ANCHOR = 'did:key:z6MkaliceAnchorAliceAnchorAliceAnchorAliceA';
21
+ const BOB_ANCHOR_0 = 'did:key:z6MkbobAnchorZeroBobAnchorZeroBobAnchorZero';
22
+ const BOB_ANCHOR_1 = 'did:key:z6MkbobAnchorOneBobAnchorOneBobAnchorOneBo';
23
+ const OWN_ANCHOR = 'did:key:z6MkownAnchorOwnAnchorOwnAnchorOwnAnchorOw';
24
+ const seqOut = () => ({ lastSalt: '0', exhausted: false, hwm: '0', snapshot: null, snapshotDigest: null, inflight: {} });
25
+ const seqIn = () => ({ hwm: '0', lowerBound: '0', assembly: null, accepted: null });
26
+ const tuple = (t) => ({
27
+ ownPairLabel: t.label,
28
+ counterpartAnchor: t.counterpartAnchor,
29
+ counterpartKeyAgreement: t.counterpartKeyAgreement,
30
+ rkid: t.rkid,
31
+ entryId: t.entryId,
32
+ priorCandidates: [],
33
+ starOut: seqOut(),
34
+ starIn: seqIn(),
35
+ groupStarOut: seqOut(),
36
+ groupStarIn: seqIn(),
37
+ probeOut: { seq: '0', inflight: {}, done: false },
38
+ probeIn: { hwm: '0', lowerBound: '0', assembly: null },
39
+ continuityOut: { rev: '0', body: null, proof: null, sent: [], align: false, chosen: null, reported: null, aligned: false, due: null },
40
+ continuityIn: { rev: '0', body: null, recordPrior: null },
41
+ mappingOut: t.issued
42
+ ? { rev: '1', body: { type: 'anchor-mapping@4', placeholder: true }, underAnchor: OWN_ANCHOR }
43
+ : { rev: '0', body: null, underAnchor: null },
44
+ mappingIn: t.self
45
+ ? { rev: '1', body: { type: 'anchor-mapping@4', placeholder: true }, self: t.self, card: { type: 'self-card@2', anchor: t.self } }
46
+ : { rev: '0', body: null, self: null, card: null },
47
+ profileOut: { rev: '0' },
48
+ profileIn: t.profile
49
+ ? { rev: t.profile.rev, body: { type: 'profile@1', revision: t.profile.rev, name: t.profile.name, ...(t.profile.text ? { text: t.profile.text } : {}) }, verifiedSeq: '4' }
50
+ : { rev: '0', body: null, verifiedSeq: '0' },
51
+ deactivated: false,
52
+ });
53
+ /**
54
+ * A populated, valid HolderState, fresh on every call:
55
+ * - c-alice: met in a ceremony, trusted (anchor mapping on), mappings
56
+ * both ways, a verified profile
57
+ * - c-bob: introduced via c-alice, an alias e-bob-old, two relationships
58
+ * of which r-bob-2 lags (its anchor head is a superseded prev on
59
+ * r-bob-1), trusted and paused (star and group star off)
60
+ * - one group g-garden, the own profile (revision 3), one accepted
61
+ * outbox item to c-alice, one group-invite prompt
62
+ */
63
+ export function sampleState() {
64
+ const s = emptyState(CODEC);
65
+ s.commitSeq = '12';
66
+ s.lastWhen = T + 60_000;
67
+ s.register.labels = ['pair/alice', 'pair/bob-1', 'pair/bob-2'];
68
+ s.register.pairNonces = { 'pair/alice': 'AAAA', 'pair/bob-1': 'BBBB', 'pair/bob-2': 'CCCC' };
69
+ s.register.community = { genesis: 'uCommunityGenesis', head: '1' };
70
+ s.addresses.keys = {
71
+ [OWN_ALICE]: { label: 'pair/alice', lastShown: T },
72
+ [OWN_BOB_1]: { label: 'pair/bob-1', lastShown: T },
73
+ [OWN_BOB_2]: { label: 'pair/bob-2', lastShown: T },
74
+ };
75
+ const settings = { star: 'default', groupStar: 'default', anchorMapping: 'on', sealedGroupStar: 'default', profile: 'default' };
76
+ s.contacts = {
77
+ 'c-alice': { id: 'c-alice', pos: '0', status: 'admitted', aliases: [], relIds: ['r-alice'], anchorHead: ALICE_ANCHOR, settings: { ...settings }, groupSettings: {} },
78
+ 'c-bob': {
79
+ id: 'c-bob', pos: '1', status: 'admitted', aliases: ['e-bob-old'], relIds: ['r-bob-1', 'r-bob-2'], anchorHead: BOB_ANCHOR_1,
80
+ settings: { ...settings, star: 'off', groupStar: 'off' }, groupSettings: { 'g-garden': 'off' },
81
+ },
82
+ };
83
+ const rel = (id, contactId, tuples, extra = {}) => ({
84
+ id, contactId, tuples, activeHead: tuples[tuples.length - 1].ownPairLabel, earliestAnchor: OWN_ANCHOR,
85
+ links: [], bindings: {}, heldCounterpartHead: null, memory: {}, provenance: { kind: 'ceremony', at: T }, chainedInto: null, firstVerified: null,
86
+ ...extra,
87
+ });
88
+ s.relationships = {
89
+ 'r-alice': rel('r-alice', 'c-alice', [tuple({
90
+ label: 'pair/alice', counterpartAnchor: ALICE_PAIR, counterpartKeyAgreement: KA_ALICE, rkid: OWN_ALICE, entryId: 'c-alice',
91
+ self: ALICE_ANCHOR, issued: true, profile: { rev: '2', name: 'Alice', text: 'hello' },
92
+ })], { heldCounterpartHead: ALICE_ANCHOR }),
93
+ 'r-bob-1': rel('r-bob-1', 'c-bob', [tuple({
94
+ label: 'pair/bob-1', counterpartAnchor: BOB_PAIR_1, counterpartKeyAgreement: KA_BOB, rkid: OWN_BOB_1, entryId: 'c-bob',
95
+ self: BOB_ANCHOR_1, issued: true,
96
+ })], {
97
+ heldCounterpartHead: BOB_ANCHOR_1,
98
+ links: [{ prev: BOB_ANCHOR_0, next: BOB_ANCHOR_1 }],
99
+ provenance: { kind: 'introduced', via: 'c-alice', at: T + 1000 },
100
+ }),
101
+ 'r-bob-2': rel('r-bob-2', 'c-bob', [tuple({
102
+ label: 'pair/bob-2', counterpartAnchor: BOB_PAIR_2, counterpartKeyAgreement: KA_BOB, rkid: OWN_BOB_2, entryId: 'c-bob',
103
+ self: BOB_ANCHOR_0, issued: true,
104
+ })], { heldCounterpartHead: BOB_ANCHOR_0, provenance: { kind: 'ceremony', at: T + 2000 } }),
105
+ };
106
+ s.entryOrder = { nextPos: '2', heads: ['r-alice', 'r-bob-1', 'r-bob-2'] };
107
+ s.groups = {
108
+ 'g-garden': { id: 'g-garden', memberLabel: 'group/g-garden', rules: { vouchThreshold: '2' }, listed: true, name: 'Garden', roster: {}, invitations: {}, evidence: {}, preludes: {}, memberAnchor: 'did:key:z6MkGardenMemberSampleOnly', memberOp: 'oid:garden-admission-sample' },
109
+ };
110
+ s.profile = { body: { name: 'Me', text: 'about me' }, revision: '3' };
111
+ s.outbox = {
112
+ uDocAlice1: {
113
+ type: 'https://real-life.org/trust-tasks/profile/0.1',
114
+ threadId: 'thread-alice-1',
115
+ recipient: { contactId: 'c-alice', rkid: OWN_ALICE, keyAgreement: KA_ALICE },
116
+ envelope: { rkid: KA_ALICE, epk: 'epk', nonce: 'nonce', ciphertext: 'ciphertext' },
117
+ attempt: 1,
118
+ history: [{ status: 'submitted', at: T + 10_000, attempt: 1 }, { status: 'accepted', at: T + 11_000 }],
119
+ },
120
+ };
121
+ s.prompts = {
122
+ 'p-invite': { id: 'p-invite', kind: 'group-invite', contactId: 'c-alice', groupId: 'g-garden', openedAt: T + 20_000, expiresAt: T + 86_400_000 },
123
+ };
124
+ return s;
125
+ }
126
+ /** The command of openPromptModule. */
127
+ export const OPEN_PROMPT = 'test.prompt.open';
128
+ /**
129
+ * A module for tests: its non-human command OPEN_PROMPT opens a prompt
130
+ * the way a domain module will, and announces prompt.opened. An id that
131
+ * is already open is a programming error and throws.
132
+ */
133
+ export const openPromptModule = Object.freeze({
134
+ name: 'test-prompts',
135
+ commands: Object.freeze({
136
+ [OPEN_PROMPT]: {
137
+ human: false,
138
+ apply(state, _p, input, when) {
139
+ if (Object.hasOwn(state.prompts, input.id))
140
+ throw new Error(`${OPEN_PROMPT}: prompt ${input.id} is already open`);
141
+ const p = {
142
+ id: input.id, kind: input.kind, openedAt: when,
143
+ ...(input.contactId !== undefined ? { contactId: input.contactId } : {}),
144
+ ...(input.groupId !== undefined ? { groupId: input.groupId } : {}),
145
+ ...(input.expiresAt !== undefined ? { expiresAt: input.expiresAt } : {}),
146
+ };
147
+ return {
148
+ state: { ...state, prompts: { ...state.prompts, [p.id]: p } },
149
+ events: [{ type: 'prompt.opened', promptId: p.id, kind: p.kind }],
150
+ };
151
+ },
152
+ },
153
+ }),
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).\n//\n// sampleState() is a populated, valid HolderState for view tests: it\n// passes the codec, but it is assembled by hand, not by acts, and its\n// keys and anchors are placeholders, not derivations. The real test-state\n// builder (stateBuilder) arrives in PR 4. openPromptModule stands in for\n// the domain modules that open prompts in later PRs.\nimport { CODEC } from './codec.js'\nimport type { HolderModule } from './engine.js'\nimport { emptyState } from './state.js'\nimport type { HolderState, Prompt, PromptKind, Tuple } from './state.js'\n\nconst T = Date.parse('2026-10-14T09:00:00Z')\n\n// placeholder key material: strings of the right family, no keys behind them\nconst KA_ALICE = 'z6LSaliceAliceAliceAliceAliceAliceAliceAliceAlic'\nconst KA_BOB = 'z6LSbobBobBobBobBobBobBobBobBobBobBobBobBobBobBob'\nconst OWN_ALICE = 'z6LSownAliceOwnAliceOwnAliceOwnAliceOwnAliceOwnA'\nconst OWN_BOB_1 = 'z6LSownBobOneOwnBobOneOwnBobOneOwnBobOneOwnBobOn'\nconst OWN_BOB_2 = 'z6LSownBobTwoOwnBobTwoOwnBobTwoOwnBobTwoOwnBobTw'\nconst ALICE_PAIR = 'did:key:z6MkalicePairAlicePairAlicePairAlicePairAli'\nconst BOB_PAIR_1 = 'did:key:z6MkbobPairOneBobPairOneBobPairOneBobPairOn'\nconst BOB_PAIR_2 = 'did:key:z6MkbobPairTwoBobPairTwoBobPairTwoBobPairTw'\nconst ALICE_ANCHOR = 'did:key:z6MkaliceAnchorAliceAnchorAliceAnchorAliceA'\nconst BOB_ANCHOR_0 = 'did:key:z6MkbobAnchorZeroBobAnchorZeroBobAnchorZero'\nconst BOB_ANCHOR_1 = 'did:key:z6MkbobAnchorOneBobAnchorOneBobAnchorOneBo'\nconst OWN_ANCHOR = 'did:key:z6MkownAnchorOwnAnchorOwnAnchorOwnAnchorOw'\n\nconst seqOut = () => ({ lastSalt: '0', exhausted: false, hwm: '0', snapshot: null, snapshotDigest: null, inflight: {} })\nconst seqIn = () => ({ hwm: '0', lowerBound: '0', assembly: null, accepted: null })\n\ninterface TupleSpec {\n label: string\n counterpartAnchor: string\n counterpartKeyAgreement: string\n rkid: string\n entryId: string\n /** the counterpart's community anchor its verified mapping carries */\n self?: string\n issued?: boolean\n profile?: { rev: string, name: string, text?: string }\n}\n\nconst tuple = (t: TupleSpec): Tuple => ({\n ownPairLabel: t.label,\n counterpartAnchor: t.counterpartAnchor,\n counterpartKeyAgreement: t.counterpartKeyAgreement,\n rkid: t.rkid,\n entryId: t.entryId,\n priorCandidates: [],\n starOut: seqOut(),\n starIn: seqIn(),\n groupStarOut: seqOut(),\n groupStarIn: seqIn(),\n probeOut: { seq: '0', inflight: {}, done: false },\n probeIn: { hwm: '0', lowerBound: '0', assembly: null },\n continuityOut: { rev: '0', body: null, proof: null, sent: [], align: false, chosen: null, reported: null, aligned: false, due: null },\n continuityIn: { rev: '0', body: null, recordPrior: null },\n mappingOut: t.issued\n ? { rev: '1', body: { type: 'anchor-mapping@4', placeholder: true }, underAnchor: OWN_ANCHOR }\n : { rev: '0', body: null, underAnchor: null },\n mappingIn: t.self\n ? { rev: '1', body: { type: 'anchor-mapping@4', placeholder: true }, self: t.self, card: { type: 'self-card@2', anchor: t.self } }\n : { rev: '0', body: null, self: null, card: null },\n profileOut: { rev: '0' },\n profileIn: t.profile\n ? { rev: t.profile.rev, body: { type: 'profile@1', revision: t.profile.rev, name: t.profile.name, ...(t.profile.text ? { text: t.profile.text } : {}) }, verifiedSeq: '4' }\n : { rev: '0', body: null, verifiedSeq: '0' },\n deactivated: false,\n})\n\n/**\n * A populated, valid HolderState, fresh on every call:\n * - c-alice: met in a ceremony, trusted (anchor mapping on), mappings\n * both ways, a verified profile\n * - c-bob: introduced via c-alice, an alias e-bob-old, two relationships\n * of which r-bob-2 lags (its anchor head is a superseded prev on\n * r-bob-1), trusted and paused (star and group star off)\n * - one group g-garden, the own profile (revision 3), one accepted\n * outbox item to c-alice, one group-invite prompt\n */\nexport function sampleState (): HolderState {\n const s = emptyState(CODEC)\n s.commitSeq = '12'\n s.lastWhen = T + 60_000\n s.register.labels = ['pair/alice', 'pair/bob-1', 'pair/bob-2']\n s.register.pairNonces = { 'pair/alice': 'AAAA', 'pair/bob-1': 'BBBB', 'pair/bob-2': 'CCCC' }\n s.register.community = { genesis: 'uCommunityGenesis', head: '1' }\n s.addresses.keys = {\n [OWN_ALICE]: { label: 'pair/alice', lastShown: T },\n [OWN_BOB_1]: { label: 'pair/bob-1', lastShown: T },\n [OWN_BOB_2]: { label: 'pair/bob-2', lastShown: T },\n }\n const settings = { star: 'default', groupStar: 'default', anchorMapping: 'on', sealedGroupStar: 'default', profile: 'default' } as const\n s.contacts = {\n 'c-alice': { id: 'c-alice', pos: '0', status: 'admitted', aliases: [], relIds: ['r-alice'], anchorHead: ALICE_ANCHOR, settings: { ...settings }, groupSettings: {} },\n 'c-bob': {\n id: 'c-bob', pos: '1', status: 'admitted', aliases: ['e-bob-old'], relIds: ['r-bob-1', 'r-bob-2'], anchorHead: BOB_ANCHOR_1,\n settings: { ...settings, star: 'off', groupStar: 'off' }, groupSettings: { 'g-garden': 'off' },\n },\n }\n const rel = (id: string, contactId: string, tuples: Tuple[], extra: Partial<HolderState['relationships'][string]> = {}) => ({\n id, contactId, tuples, activeHead: tuples[tuples.length - 1].ownPairLabel, earliestAnchor: OWN_ANCHOR,\n links: [], bindings: {}, heldCounterpartHead: null, memory: {}, provenance: { kind: 'ceremony' as const, at: T }, chainedInto: null, firstVerified: null,\n ...extra,\n })\n s.relationships = {\n 'r-alice': rel('r-alice', 'c-alice', [tuple({\n label: 'pair/alice', counterpartAnchor: ALICE_PAIR, counterpartKeyAgreement: KA_ALICE, rkid: OWN_ALICE, entryId: 'c-alice',\n self: ALICE_ANCHOR, issued: true, profile: { rev: '2', name: 'Alice', text: 'hello' },\n })], { heldCounterpartHead: ALICE_ANCHOR }),\n 'r-bob-1': rel('r-bob-1', 'c-bob', [tuple({\n label: 'pair/bob-1', counterpartAnchor: BOB_PAIR_1, counterpartKeyAgreement: KA_BOB, rkid: OWN_BOB_1, entryId: 'c-bob',\n self: BOB_ANCHOR_1, issued: true,\n })], {\n heldCounterpartHead: BOB_ANCHOR_1,\n links: [{ prev: BOB_ANCHOR_0, next: BOB_ANCHOR_1 }],\n provenance: { kind: 'introduced', via: 'c-alice', at: T + 1000 },\n }),\n 'r-bob-2': rel('r-bob-2', 'c-bob', [tuple({\n label: 'pair/bob-2', counterpartAnchor: BOB_PAIR_2, counterpartKeyAgreement: KA_BOB, rkid: OWN_BOB_2, entryId: 'c-bob',\n self: BOB_ANCHOR_0, issued: true,\n })], { heldCounterpartHead: BOB_ANCHOR_0, provenance: { kind: 'ceremony', at: T + 2000 } }),\n }\n s.entryOrder = { nextPos: '2', heads: ['r-alice', 'r-bob-1', 'r-bob-2'] }\n s.groups = {\n 'g-garden': { id: 'g-garden', memberLabel: 'group/g-garden', rules: { vouchThreshold: '2' }, listed: true, name: 'Garden', roster: {}, invitations: {}, evidence: {}, preludes: {}, memberAnchor: 'did:key:z6MkGardenMemberSampleOnly', memberOp: 'oid:garden-admission-sample' },\n }\n s.profile = { body: { name: 'Me', text: 'about me' }, revision: '3' }\n s.outbox = {\n uDocAlice1: {\n type: 'https://real-life.org/trust-tasks/profile/0.1',\n threadId: 'thread-alice-1',\n recipient: { contactId: 'c-alice', rkid: OWN_ALICE, keyAgreement: KA_ALICE },\n envelope: { rkid: KA_ALICE, epk: 'epk', nonce: 'nonce', ciphertext: 'ciphertext' },\n attempt: 1,\n history: [{ status: 'submitted', at: T + 10_000, attempt: 1 }, { status: 'accepted', at: T + 11_000 }],\n },\n }\n s.prompts = {\n 'p-invite': { id: 'p-invite', kind: 'group-invite', contactId: 'c-alice', groupId: 'g-garden', openedAt: T + 20_000, expiresAt: T + 86_400_000 },\n }\n return s\n}\n\n/** The command of openPromptModule. */\nexport const OPEN_PROMPT = 'test.prompt.open'\n\n/** Input of OPEN_PROMPT: the prompt without openedAt, which is `when`. */\nexport interface OpenPromptInput { id: string, kind: PromptKind, contactId?: string, groupId?: string, expiresAt?: number }\n\n/**\n * A module for tests: its non-human command OPEN_PROMPT opens a prompt\n * the way a domain module will, and announces prompt.opened. An id that\n * is already open is a programming error and throws.\n */\nexport const openPromptModule: HolderModule = Object.freeze({\n name: 'test-prompts',\n commands: Object.freeze({\n [OPEN_PROMPT]: {\n human: false,\n apply (state: Readonly<HolderState>, _p: unknown, input: OpenPromptInput, when: number) {\n if (Object.hasOwn(state.prompts, input.id)) throw new Error(`${OPEN_PROMPT}: prompt ${input.id} is already open`)\n const p: Prompt = {\n id: input.id, kind: input.kind, openedAt: when,\n ...(input.contactId !== undefined ? { contactId: input.contactId } : {}),\n ...(input.groupId !== undefined ? { groupId: input.groupId } : {}),\n ...(input.expiresAt !== undefined ? { expiresAt: input.expiresAt } : {}),\n }\n return {\n state: { ...state, prompts: { ...state.prompts, [p.id]: p } },\n events: [{ type: 'prompt.opened' as const, promptId: p.id, kind: p.kind }],\n }\n },\n },\n }),\n})\n"]}
@@ -0,0 +1,47 @@
1
+ import type { Context } from './identity.js';
2
+ export interface ForgeMappingInput {
3
+ /** the addressee's own pair context of the relationship */
4
+ own: Context;
5
+ /** the counterparty's pair anchor and key agreement on that relationship */
6
+ pair: string;
7
+ pairKeyAgreement: string;
8
+ /** a self card the addressee holds (another contact disclosed it) */
9
+ card: {
10
+ body: {
11
+ anchor: string;
12
+ keyAgreement: string;
13
+ };
14
+ };
15
+ revision?: string;
16
+ issuedAt: string;
17
+ lineage?: unknown[];
18
+ }
19
+ /**
20
+ * An anchor-mapping@4 that maps the counterparty's pair anchor to the self
21
+ * anchor of `card`, built by the addressee alone: both MACs are keyed by
22
+ * secrets the addressee shares (X25519 with the pair key and with the
23
+ * card's key), so it verifies exactly like one the counterparty issued —
24
+ * a leaked mapping proves nothing to a third party.
25
+ */
26
+ export declare function forgeMapping(i: ForgeMappingInput, subtle?: SubtleCrypto): Promise<{
27
+ body: {
28
+ type: string;
29
+ pair: string;
30
+ self: string;
31
+ to: string;
32
+ card: {
33
+ body: {
34
+ anchor: string;
35
+ keyAgreement: string;
36
+ };
37
+ };
38
+ lineage: unknown[];
39
+ revision: string;
40
+ issuedAt: string;
41
+ };
42
+ proof: {
43
+ mac1: string;
44
+ mac2: string;
45
+ };
46
+ }>;
47
+ //# sourceMappingURL=forge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge.d.ts","sourceRoot":"","sources":["../src/forge.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAG5C,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,GAAG,EAAE,OAAO,CAAA;IACZ,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,EAAE,MAAM,CAAA;IACxB,qEAAqE;IACrE,IAAI,EAAE;QAAE,IAAI,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAE,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,YAAY;;;;;;;kBAb/D;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,YAAY,EAAE,MAAM,CAAA;aAAE;;;;;;;;;;GAkBvD"}
package/dist/forge.js ADDED
@@ -0,0 +1,20 @@
1
+ // forge — test tools for the deniability of the designated-verifier forms
2
+ // (Trust 6.1): what the addressee itself can build. Exported from
3
+ // ./testing only.
4
+ import { ecdh, xRawOfMk } from './crypto.js';
5
+ import { assembleAnchorMapping } from './anchor.js';
6
+ /**
7
+ * An anchor-mapping@4 that maps the counterparty's pair anchor to the self
8
+ * anchor of `card`, built by the addressee alone: both MACs are keyed by
9
+ * secrets the addressee shares (X25519 with the pair key and with the
10
+ * card's key), so it verifies exactly like one the counterparty issued —
11
+ * a leaked mapping proves nothing to a third party.
12
+ */
13
+ export async function forgeMapping(i, subtle) {
14
+ const theirs = xRawOfMk(i.pairKeyAgreement), cards = xRawOfMk(i.card.body.keyAgreement);
15
+ if (!theirs || !cards)
16
+ throw new Error('forgeMapping: key agreement is not a multikey');
17
+ const body = { type: 'anchor-mapping@4', pair: i.pair, self: i.card.body.anchor, to: i.own.anchor, card: i.card, lineage: i.lineage ?? [], revision: i.revision ?? '1', issuedAt: i.issuedAt };
18
+ return assembleAnchorMapping(body, await ecdh(i.own.x.priv, theirs, subtle), await ecdh(i.own.x.priv, cards, subtle), subtle);
19
+ }
20
+ //# sourceMappingURL=forge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge.js","sourceRoot":"","sources":["../src/forge.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kEAAkE;AAClE,kBAAkB;AAClB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAenD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAE,CAAoB,EAAE,MAAqB;IAC7E,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IACvF,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IACvF,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC9L,OAAO,qBAAqB,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;AAC/H,CAAC","sourcesContent":["// forge — test tools for the deniability of the designated-verifier forms\n// (Trust 6.1): what the addressee itself can build. Exported from\n// ./testing only.\nimport { ecdh, xRawOfMk } from './crypto.js'\nimport type { Context } from './identity.js'\nimport { assembleAnchorMapping } from './anchor.js'\n\nexport interface ForgeMappingInput {\n /** the addressee's own pair context of the relationship */\n own: Context\n /** the counterparty's pair anchor and key agreement on that relationship */\n pair: string\n pairKeyAgreement: string\n /** a self card the addressee holds (another contact disclosed it) */\n card: { body: { anchor: string, keyAgreement: string } }\n revision?: string\n issuedAt: string\n lineage?: unknown[]\n}\n\n/**\n * An anchor-mapping@4 that maps the counterparty's pair anchor to the self\n * anchor of `card`, built by the addressee alone: both MACs are keyed by\n * secrets the addressee shares (X25519 with the pair key and with the\n * card's key), so it verifies exactly like one the counterparty issued —\n * a leaked mapping proves nothing to a third party.\n */\nexport async function forgeMapping (i: ForgeMappingInput, subtle?: SubtleCrypto) {\n const theirs = xRawOfMk(i.pairKeyAgreement), cards = xRawOfMk(i.card.body.keyAgreement)\n if (!theirs || !cards) throw new Error('forgeMapping: key agreement is not a multikey')\n const body = { type: 'anchor-mapping@4', pair: i.pair, self: i.card.body.anchor, to: i.own.anchor, card: i.card, lineage: i.lineage ?? [], revision: i.revision ?? '1', issuedAt: i.issuedAt }\n return assembleAnchorMapping(body, await ecdh(i.own.x.priv, theirs, subtle), await ecdh(i.own.x.priv, cards, subtle), subtle)\n}\n"]}