@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
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAG1C;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAA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U,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM1F;AAKD,wBAAsB,WAAW,CAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAG3F;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAE,aAAa,EAAE,MAAM,EAAE,UAAU,GAAE,MAAU,GAAG,MAAM,CAGrF;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,UAAU,EAAE,eAAe,MAAM,EAAE,aAAY,MAAU,KAAG,OAAO,CAAC,OAAO,CACjD,CAAA"}
package/dist/identity.js CHANGED
@@ -6,12 +6,15 @@
6
6
  // anchor per group, public personas. No two contexts link to each other
7
7
  // unless their holder deliberately discloses the link.
8
8
  //
9
- // The label registry is CLOSED (Identity §6.1, unchanged since 0.13):
10
- // exactly three label forms derive, and this API rejects every other
11
- // string before any key derivation — fail closed, no repair. `self`,
12
- // `recovery`, `carrier` and `device/…` are not labels; recovery and the
13
- // carrier-relationship identity have their own fixed derivations outside
14
- // this registry and are deliberately NOT part of this module yet.
9
+ // The label registry is CLOSED (Identity §6.1): exactly five label forms
10
+ // derive — group/<digest>, group/<digest>/<generation> (the community
11
+ // anchor's later generations, §5.4), pair/<digest>, persona/<name> and
12
+ // device/<name>/<context> (one device under one anchor context, §5.5) —
13
+ // and this API rejects every other string before any key derivation —
14
+ // fail closed, no repair. `self`, `recovery`, `carrier` and a `device/…`
15
+ // string without exactly its two components are not labels; recovery and
16
+ // the carrier-relationship identity have their own fixed derivations
17
+ // outside this registry and are deliberately NOT part of this module yet.
15
18
  //
16
19
  // Fresh-always (Encounter §4.4): a ceremony mints a pair context whose
17
20
  // label digests the NONCE BYTES, so nothing correlatable is displayed —
@@ -23,6 +26,13 @@ import { allowed15, WHITE_SPACE_15 } from './unicode15.js';
23
26
  // A digest component is the ONE canonical u rendering of a sha2-256
24
27
  // multihash: 47 characters, no padding, no non-zero trailing bits, no z.
25
28
  const digestComponent = (d) => d.length === 47 && d[0] === 'u' && toU(d) === d;
29
+ // the generation domain of the community anchor (Identity §5.4): [2,
30
+ // 2^53 − 1] — the 7a.3 domain (carrier-holder.ts GENERATION_MAX); generation 1
31
+ // is the plain group/<digest>
32
+ const GENERATION_MAX = Number.MAX_SAFE_INTEGER;
33
+ // §6.1: a decimal integer in [2, 2^53 − 1], no sign, no leading zero —
34
+ // '1', '0', '01' and anything above the domain are no label
35
+ const generationComponent = (g) => /^[1-9][0-9]{0,15}$/.test(g) && BigInt(g) >= 2n && BigInt(g) <= BigInt(GENERATION_MAX);
26
36
  // §6.2 — the ordered persona-name pipeline. NFC is the one permitted
27
37
  // normalization (applied, not rejected); every later check runs on the
28
38
  // NFC result — and every Unicode property is evaluated against the
@@ -56,15 +66,48 @@ const personaName = (raw) => {
56
66
  export function canonicalLabel(label) {
57
67
  if (typeof label !== 'string')
58
68
  return null;
59
- if (label.startsWith('group/'))
60
- return digestComponent(label.slice(6)) ? label : null;
69
+ if (label.startsWith('group/')) {
70
+ const rest = label.slice(6);
71
+ const cut = rest.indexOf('/');
72
+ if (cut < 0)
73
+ return digestComponent(rest) ? label : null;
74
+ return digestComponent(rest.slice(0, cut)) && generationComponent(rest.slice(cut + 1)) ? label : null;
75
+ }
61
76
  if (label.startsWith('pair/'))
62
77
  return digestComponent(label.slice(5)) ? label : null;
63
78
  if (label.startsWith('persona/')) {
64
79
  const name = personaName(label.slice(8));
65
80
  return name === null ? null : 'persona/' + name;
66
81
  }
67
- return null; // self, recovery, carrier, device/…, and every unknown form: fail closed
82
+ if (label.startsWith('device/')) {
83
+ // §5.5: device/<n>/<c> — c is 47 characters and n holds no '/', so
84
+ // the label parses into exactly one (n, c); n follows 6.2 (NFC applied)
85
+ const rest = label.slice(7);
86
+ const cut = rest.length - 48;
87
+ if (cut < 1 || rest[cut] !== '/' || !digestComponent(rest.slice(cut + 1)))
88
+ return null;
89
+ const name = personaName(rest.slice(0, cut));
90
+ return name === null ? null : `device/${name}/${rest.slice(cut + 1)}`;
91
+ }
92
+ return null; // self, recovery, carrier, device/… without both components, and every unknown form: fail closed
93
+ }
94
+ /** A device name per 6.2 (Identity §5.5), NFC-normalized, or null. */
95
+ export const deviceName = (raw) => (typeof raw === 'string' ? personaName(raw) : null);
96
+ /**
97
+ * The device label of one device under one anchor context (Identity
98
+ * §5.5): device/<n>/<c>, c the 6.1 encoding of sha2-256 over the UTF-8
99
+ * bytes of the context's canonical label — a group/…, persona/… or pair/…
100
+ * label, never a device/… one. One device key per anchor context: the
101
+ * context is part of the label.
102
+ */
103
+ export async function deviceLabel(name, contextLabel, subtle) {
104
+ const n = deviceName(name);
105
+ if (n === null)
106
+ throw new Error(`not a device name (Identity §5.5, §6.2): ${JSON.stringify(name)}`);
107
+ const a = canonicalLabel(contextLabel);
108
+ if (a === null || a.startsWith('device/'))
109
+ throw new Error(`not an anchor context label (Identity §5.5): ${JSON.stringify(contextLabel)}`);
110
+ return `device/${n}/${await digestBytes(new TextEncoder().encode(a), subtle)}`;
68
111
  }
69
112
  export async function labeledContext(rootIkm, label) {
70
113
  const canonical = canonicalLabel(label);
@@ -82,6 +125,22 @@ export async function pairContext(rootIkm, nonce) {
82
125
  throw new Error('pair nonce must be exactly 32 bytes (Identity §6.1)');
83
126
  return labeledContext(rootIkm, 'pair/' + await digestBytes(nonce));
84
127
  }
85
- /** The community anchor: an ordinary group context over the community's genesis digest. */
86
- export const communityContext = (rootIkm, genesisDigest) => labeledContext(rootIkm, 'group/' + genesisDigest);
128
+ /**
129
+ * The label of the community anchor at a generation (Identity §5.4,
130
+ * §6.1): generation 1 is the ordinary group/<digest> context, a later
131
+ * one group/<digest>/<generation>. The label string is the whole
132
+ * derivation context — the generation enters nowhere else.
133
+ */
134
+ export function communityLabel(genesisDigest, generation = 1) {
135
+ if (!Number.isSafeInteger(generation) || generation < 1)
136
+ throw new Error(`generation outside [1, 2^53 − 1] (Identity §5.4): ${generation}`);
137
+ return generation === 1 ? 'group/' + genesisDigest : `group/${genesisDigest}/${generation}`;
138
+ }
139
+ /**
140
+ * The community anchor: the group context over the personal community's
141
+ * genesis digest at the holder's current generation (Identity §2, §5.4).
142
+ * It is not a member of the personal community — that group is founded,
143
+ * like every group, under a fresh pair anchor (Access §3.4.1).
144
+ */
145
+ export const communityContext = (rootIkm, genesisDigest, generation = 1) => labeledContext(rootIkm, communityLabel(genesisDigest, generation));
87
146
  //# sourceMappingURL=identity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,mEAAmE;AACnE,wEAAwE;AACxE,uDAAuD;AACvD,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,qEAAqE;AACrE,wEAAwE;AACxE,yEAAyE;AACzE,kEAAkE;AAClE,EAAE;AACF,uEAAuE;AACvE,wEAAwE;AACxE,6DAA6D;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAe1D,2EAA2E;AAC3E,oEAAoE;AACpE,yEAAyE;AACzE,MAAM,eAAe,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAE/F,qEAAqE;AACrE,uEAAuE;AACvE,mEAAmE;AACnE,wEAAwE;AACxE,qEAAqE;AACrE,+DAA+D;AAC/D,MAAM,WAAW,GAAG,CAAC,GAAW,EAAiB,EAAE;IACjD,IAAI,CAAE,GAA8C,CAAC,YA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AAC,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACjI,OAAO,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;AACpE,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAmB,EAAE,aAAqB,EAAoB,EAAE,CAC/F,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,aAAa,CAAC,CAAA","sourcesContent":["// identity — the Identity Layer: one root seed, every context derived.\n//\n// A person holds ONE secret. Everything else is derived from it through\n// the ordinary rltp/anchor family: the community anchor that carries the\n// stable social identity, a pair anchor per relationship, a member\n// anchor per group, public personas. No two contexts link to each other\n// unless their holder deliberately discloses the link.\n//\n// The label registry is CLOSED (Identity §6.1, unchanged since 0.13):\n// exactly three label forms derive, and this API rejects every other\n// string before any key derivation — fail closed, no repair. `self`,\n// `recovery`, `carrier` and `device/…` are not labels; recovery and the\n// carrier-relationship identity have their own fixed derivations outside\n// this registry and are deliberately NOT part of this module yet.\n//\n// Fresh-always (Encounter §4.4): a ceremony mints a pair context whose\n// label digests the NONCE BYTES, so nothing correlatable is displayed —\n// not even to someone who scanned the same person yesterday.\nimport { toU } from './core.js'\nimport { hkdf, edFromSeed, xFromSeed, anchorOfEd, mkOfX, digestBytes } from './crypto.js'\nimport type { KeyPair } from './crypto.js'\nimport { allowed15, WHITE_SPACE_15 } from './unicode15.js'\n\n/**\n * One derived identity context: its label, both key pairs, and the two\n * public forms others see — the did:key anchor and the multikey for key\n * agreement. Contexts never link to each other without a deliberate act.\n */\nexport interface Context {\n label: string\n ed: KeyPair\n x: KeyPair\n anchor: string\n keyAgreement: string\n}\n\n// ── the closed registry (Identity §6.1) ─────────────────────────────────\n// A digest component is the ONE canonical u rendering of a sha2-256\n// multihash: 47 characters, no padding, no non-zero trailing bits, no z.\nconst digestComponent = (d: string): boolean => d.length === 47 && d[0] === 'u' && toU(d) === d\n\n// §6.2 — the ordered persona-name pipeline. NFC is the one permitted\n// normalization (applied, not rejected); every later check runs on the\n// NFC result — and every Unicode property is evaluated against the\n// PINNED 15.0 data in unicode15.ts, never the platform's tables (review\n// 2, B-1: Node 22 ships Unicode 16 — a post-15.0 code point must not\n// derive an anchor on one runtime and be rejected on another).\nconst personaName = (raw: string): string | null => {\n if (!(raw as unknown as { isWellFormed(): boolean }).isWellFormed()) return null // no lone surrogates\n const name = raw.normalize('NFC') // NFC of 15.0-assigned code points is version-stable by Unicode's guarantee\n const cps = [...name]\n if (cps.length < 1 || cps.length > 64) return null\n if (new TextEncoder().encode(name).length > 256) return null\n if (name.includes('/')) return null // labels have exactly the components the registry shows\n for (const c of cps) if (!allowed15(c.codePointAt(0)!)) return null // assigned in 15.0, no Cc/Cf\n if (WHITE_SPACE_15.has(cps[0]!.codePointAt(0)!) || WHITE_SPACE_15.has(cps[cps.length - 1]!.codePointAt(0)!)) return null\n return name\n}\n\n/**\n * The canonical form of a registry label, or null for everything the\n * closed registry rejects. Personas come back NFC-normalized — for them\n * the canonical label may differ from the input; label equality IS\n * anchor identity, so derivation always uses the canonical form.\n */\nexport function canonicalLabel (label: string): string | null {\n if (typeof label !== 'string') return null\n if (label.startsWith('group/')) return digestComponent(label.slice(6)) ? label : null\n if (label.startsWith('pair/')) return digestComponent(label.slice(5)) ? label : null\n if (label.startsWith('persona/')) {\n const name = personaName(label.slice(8))\n return name === null ? null : 'persona/' + name\n }\n return null // self, recovery, carrier, device/…, and every unknown form: fail closed\n}\n\nexport async function labeledContext (rootIkm: Uint8Array, label: string): Promise<Context> {\n const canonical = canonicalLabel(label)\n if (canonical === null) throw new Error(`not a label of the closed registry (Identity §6.1): ${JSON.stringify(label)}`)\n const ed = await edFromSeed(await hkdf(rootIkm, 'rltp/anchor/ed/' + canonical))\n const x = await xFromSeed(await hkdf(rootIkm, 'rltp/anchor/x/' + canonical))\n return { label: canonical, ed, x, anchor: anchorOfEd(ed.pubRaw), keyAgreement: mkOfX(x.pubRaw) }\n}\n\n// fresh-always (Encounter §4.4): label = pair/<multihash over the NONCE\n// BYTES>. The nonce is the holder's own, fresh, and exactly 32 bytes —\n// a shorter one weakens the label to below its specified entropy (B-2).\nexport async function pairContext (rootIkm: Uint8Array, nonce: Uint8Array): Promise<Context> {\n if (!(nonce instanceof Uint8Array) || nonce.length !== 32) throw new Error('pair nonce must be exactly 32 bytes (Identity §6.1)')\n return labeledContext(rootIkm, 'pair/' + await digestBytes(nonce))\n}\n\n/** The community anchor: an ordinary group context over the community's genesis digest. */\nexport const communityContext = (rootIkm: Uint8Array, genesisDigest: string): Promise<Context> =>\n labeledContext(rootIkm, 'group/' + genesisDigest)\n"]}
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,mEAAmE;AACnE,wEAAwE;AACxE,uDAAuD;AACvD,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,uEAAuE;AACvE,wEAAwE;AACxE,sEAAsE;AACtE,yEAAyE;AACzE,yEAAyE;AACzE,qEAAqE;AACrE,0EAA0E;AAC1E,EAAE;AACF,uEAAuE;AACvE,wEAAwE;AACxE,6DAA6D;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAe1D,2EAA2E;AAC3E,oEAAoE;AACpE,yEAAyE;AACzE,MAAM,eAAe,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAA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,CAAA;IACjI,OAAO,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAE,aAAqB,EAAE,aAAqB,CAAC;IAC3E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,EAAE,CAAC,CAAA;IAC3I,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,aAAa,IAAI,UAAU,EAAE,CAAA;AAC7F,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAmB,EAAE,aAAqB,EAAE,aAAqB,CAAC,EAAoB,EAAE,CACvH,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAA","sourcesContent":["// identity — the Identity Layer: one root seed, every context derived.\n//\n// A person holds ONE secret. Everything else is derived from it through\n// the ordinary rltp/anchor family: the community anchor that carries the\n// stable social identity, a pair anchor per relationship, a member\n// anchor per group, public personas. No two contexts link to each other\n// unless their holder deliberately discloses the link.\n//\n// The label registry is CLOSED (Identity §6.1): exactly five label forms\n// derive — group/<digest>, group/<digest>/<generation> (the community\n// anchor's later generations, §5.4), pair/<digest>, persona/<name> and\n// device/<name>/<context> (one device under one anchor context, §5.5) —\n// and this API rejects every other string before any key derivation —\n// fail closed, no repair. `self`, `recovery`, `carrier` and a `device/…`\n// string without exactly its two components are not labels; recovery and\n// the carrier-relationship identity have their own fixed derivations\n// outside this registry and are deliberately NOT part of this module yet.\n//\n// Fresh-always (Encounter §4.4): a ceremony mints a pair context whose\n// label digests the NONCE BYTES, so nothing correlatable is displayed —\n// not even to someone who scanned the same person yesterday.\nimport { toU } from './core.js'\nimport { hkdf, edFromSeed, xFromSeed, anchorOfEd, mkOfX, digestBytes } from './crypto.js'\nimport type { KeyPair } from './crypto.js'\nimport { allowed15, WHITE_SPACE_15 } from './unicode15.js'\n\n/**\n * One derived identity context: its label, both key pairs, and the two\n * public forms others see — the did:key anchor and the multikey for key\n * agreement. Contexts never link to each other without a deliberate act.\n */\nexport interface Context {\n label: string\n ed: KeyPair\n x: KeyPair\n anchor: string\n keyAgreement: string\n}\n\n// ── the closed registry (Identity §6.1) ─────────────────────────────────\n// A digest component is the ONE canonical u rendering of a sha2-256\n// multihash: 47 characters, no padding, no non-zero trailing bits, no z.\nconst digestComponent = (d: string): boolean => d.length === 47 && d[0] === 'u' && toU(d) === d\n\n// the generation domain of the community anchor (Identity §5.4): [2,\n// 2^53 − 1] — the 7a.3 domain (carrier-holder.ts GENERATION_MAX); generation 1\n// is the plain group/<digest>\nconst GENERATION_MAX = Number.MAX_SAFE_INTEGER\n// §6.1: a decimal integer in [2, 2^53 − 1], no sign, no leading zero —\n// '1', '0', '01' and anything above the domain are no label\nconst generationComponent = (g: string): boolean =>\n /^[1-9][0-9]{0,15}$/.test(g) && BigInt(g) >= 2n && BigInt(g) <= BigInt(GENERATION_MAX)\n\n// §6.2 — the ordered persona-name pipeline. NFC is the one permitted\n// normalization (applied, not rejected); every later check runs on the\n// NFC result — and every Unicode property is evaluated against the\n// PINNED 15.0 data in unicode15.ts, never the platform's tables (review\n// 2, B-1: Node 22 ships Unicode 16 — a post-15.0 code point must not\n// derive an anchor on one runtime and be rejected on another).\nconst personaName = (raw: string): string | null => {\n if (!(raw as unknown as { isWellFormed(): boolean }).isWellFormed()) return null // no lone surrogates\n const name = raw.normalize('NFC') // NFC of 15.0-assigned code points is version-stable by Unicode's guarantee\n const cps = [...name]\n if (cps.length < 1 || cps.length > 64) return null\n if (new TextEncoder().encode(name).length > 256) return null\n if (name.includes('/')) return null // labels have exactly the components the registry shows\n for (const c of cps) if (!allowed15(c.codePointAt(0)!)) return null // assigned in 15.0, no Cc/Cf\n if (WHITE_SPACE_15.has(cps[0]!.codePointAt(0)!) || WHITE_SPACE_15.has(cps[cps.length - 1]!.codePointAt(0)!)) return null\n return name\n}\n\n/**\n * The canonical form of a registry label, or null for everything the\n * closed registry rejects. Personas come back NFC-normalized — for them\n * the canonical label may differ from the input; label equality IS\n * anchor identity, so derivation always uses the canonical form.\n */\nexport function canonicalLabel (label: string): string | null {\n if (typeof label !== 'string') return null\n if (label.startsWith('group/')) {\n const rest = label.slice(6)\n const cut = rest.indexOf('/')\n if (cut < 0) return digestComponent(rest) ? label : null\n return digestComponent(rest.slice(0, cut)) && generationComponent(rest.slice(cut + 1)) ? label : null\n }\n if (label.startsWith('pair/')) return digestComponent(label.slice(5)) ? label : null\n if (label.startsWith('persona/')) {\n const name = personaName(label.slice(8))\n return name === null ? null : 'persona/' + name\n }\n if (label.startsWith('device/')) {\n // §5.5: device/<n>/<c> — c is 47 characters and n holds no '/', so\n // the label parses into exactly one (n, c); n follows 6.2 (NFC applied)\n const rest = label.slice(7)\n const cut = rest.length - 48\n if (cut < 1 || rest[cut] !== '/' || !digestComponent(rest.slice(cut + 1))) return null\n const name = personaName(rest.slice(0, cut))\n return name === null ? null : `device/${name}/${rest.slice(cut + 1)}`\n }\n return null // self, recovery, carrier, device/… without both components, and every unknown form: fail closed\n}\n\n/** A device name per 6.2 (Identity §5.5), NFC-normalized, or null. */\nexport const deviceName = (raw: string): string | null => (typeof raw === 'string' ? personaName(raw) : null)\n\n/**\n * The device label of one device under one anchor context (Identity\n * §5.5): device/<n>/<c>, c the 6.1 encoding of sha2-256 over the UTF-8\n * bytes of the context's canonical label — a group/…, persona/… or pair/…\n * label, never a device/… one. One device key per anchor context: the\n * context is part of the label.\n */\nexport async function deviceLabel (name: string, contextLabel: string, subtle?: SubtleCrypto): Promise<string> {\n const n = deviceName(name)\n if (n === null) throw new Error(`not a device name (Identity §5.5, §6.2): ${JSON.stringify(name)}`)\n const a = canonicalLabel(contextLabel)\n if (a === null || a.startsWith('device/')) throw new Error(`not an anchor context label (Identity §5.5): ${JSON.stringify(contextLabel)}`)\n return `device/${n}/${await digestBytes(new TextEncoder().encode(a), subtle)}`\n}\n\nexport async function labeledContext (rootIkm: Uint8Array, label: string): Promise<Context> {\n const canonical = canonicalLabel(label)\n if (canonical === null) throw new Error(`not a label of the closed registry (Identity §6.1): ${JSON.stringify(label)}`)\n const ed = await edFromSeed(await hkdf(rootIkm, 'rltp/anchor/ed/' + canonical))\n const x = await xFromSeed(await hkdf(rootIkm, 'rltp/anchor/x/' + canonical))\n return { label: canonical, ed, x, anchor: anchorOfEd(ed.pubRaw), keyAgreement: mkOfX(x.pubRaw) }\n}\n\n// fresh-always (Encounter §4.4): label = pair/<multihash over the NONCE\n// BYTES>. The nonce is the holder's own, fresh, and exactly 32 bytes —\n// a shorter one weakens the label to below its specified entropy (B-2).\nexport async function pairContext (rootIkm: Uint8Array, nonce: Uint8Array): Promise<Context> {\n if (!(nonce instanceof Uint8Array) || nonce.length !== 32) throw new Error('pair nonce must be exactly 32 bytes (Identity §6.1)')\n return labeledContext(rootIkm, 'pair/' + await digestBytes(nonce))\n}\n\n/**\n * The label of the community anchor at a generation (Identity §5.4,\n * §6.1): generation 1 is the ordinary group/<digest> context, a later\n * one group/<digest>/<generation>. The label string is the whole\n * derivation context — the generation enters nowhere else.\n */\nexport function communityLabel (genesisDigest: string, generation: number = 1): string {\n if (!Number.isSafeInteger(generation) || generation < 1) throw new Error(`generation outside [1, 2^53 − 1] (Identity §5.4): ${generation}`)\n return generation === 1 ? 'group/' + genesisDigest : `group/${genesisDigest}/${generation}`\n}\n\n/**\n * The community anchor: the group context over the personal community's\n * genesis digest at the holder's current generation (Identity §2, §5.4).\n * It is not a member of the personal community — that group is founded,\n * like every group, under a fresh pair anchor (Access §3.4.1).\n */\nexport const communityContext = (rootIkm: Uint8Array, genesisDigest: string, generation: number = 1): Promise<Context> =>\n labeledContext(rootIkm, communityLabel(genesisDigest, generation))\n"]}
package/dist/index.d.ts CHANGED
@@ -2,10 +2,35 @@ export * from './core.js';
2
2
  export * from './crypto.js';
3
3
  export * from './identity.js';
4
4
  export * from './encounter.js';
5
+ export * from './membership.js';
6
+ export * from './introduction.js';
5
7
  export * from './delivery.js';
6
8
  export * from './carrier-identity.js';
7
9
  export * from './carrier.js';
8
- export * from './holder.js';
10
+ export * from './carrier-holder.js';
11
+ export { PROFILE_TYPE, PROFILE_LIMITS, profileSchemaOk, imageDimensions, imageWithinBounds, profileProblem, profileInfo, profileKey, assembleProfile, profileMacOk, } from './profile.js';
12
+ export type { ProfileContent, ProfileBody, ProfileArtifact, Dimensions, ImageDimensions } from './profile.js';
9
13
  export * as visibility from './visibility.js';
10
14
  export * as ceremony from './ceremony.js';
15
+ import type { OpaqueHolderState } from './state.js';
16
+ export type { OpaqueHolderState as HolderState, Dec, Millis, B64u, TrustClass, Setting, PromptKind, PromptChoice, OutboxStatus } from './state.js';
17
+ export { CODEC, StateCodecError } from './codec.js';
18
+ export type { StateCodecErrorCode } from './codec.js';
19
+ /** Load a stored state (a JSON string or a parsed value): an independent,
20
+ * opaque copy at the current codec, or StateCodecError. */
21
+ export declare function decodeState(raw: unknown): OpaqueHolderState;
22
+ export type * from './ports.js';
23
+ export type * from './events.js';
24
+ export { InfraError, CryptoUnavailableError } from './results.js';
25
+ export type { ActError, ActResult, ReceiveFailure, ReceiveStageNo, ReceiveResult, ResumeResult, InfraErrorCode } from './results.js';
26
+ export { ENTROPY_PURPOSES, EntropyError, randomEntropy } from './entropy.js';
27
+ export type { Entropy, EntropyPurpose, EntropyErrorCode, PlatformRandom } from './entropy.js';
28
+ export { storeContract } from './store-contract.js';
29
+ export { seedKeys } from './keys-seed.js';
30
+ export { createHolder } from './holder-api.js';
31
+ export type { Holder, HolderOptions, HolderSnapshot, HumanActOptions } from './holder-api.js';
32
+ export type { DeviceKeyResult } from './identity-state.js';
33
+ export type { ContactView, RelationshipView, ClassView, SealedClassView, ClassesView, ContactProfileView, GroupView, ProfileView, PromptView, DeliveryItemView, DeliveryStatusView } from './views.js';
34
+ export type { EnginePorts, CommitListener, CryptoHandle } from './engine.js';
35
+ export type { ContractHarness } from './store-contract.js';
11
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqEA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACL,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAC1H,eAAe,EAAE,YAAY,GAC9B,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC7G,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YA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A;AACtM,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5E,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -1,46 +1,94 @@
1
- // @real-life/trust-protocol — the cryptographic core of RLTP.
1
+ // @real-life/trust-protocol — the reference library of RLTP.
2
2
  //
3
- // What this entry point IS: the wire-level primitives of the converged
4
- // layers, reproducing the shipped test vectors byte for byte — the
5
- // canonical form, the derivation of identity contexts under the closed
6
- // label registry, the encounter wire builders, the sealed envelope and
7
- // the generic receive chain.
3
+ // The holder: createHolder({store, keys, entropy?, log?, access?, retry?,
4
+ // crypto?}) — one person's device state behind the human acts, receive,
5
+ // report, resume and tick, and the views an app reads. The ports (Store,
6
+ // KeyProvider, Entropy, Log, Access, DeliveryReport, Outbound) are the
7
+ // app's; seedKeys is the default KeyProvider. Beside it, the pure wire
8
+ // builders and verifiers of every layer, byte-compatible with the shipped
9
+ // vectors.
8
10
  //
9
- // What it is NOT (yet): the layers' full state machines. Identity's
10
- // recovery derivation, Encounter's ceremony record and acceptance
11
- // machinery, Delivery's type-specific stages and residual bookkeeping
12
- // live in the specification and its conformance fixtures, not here. A
13
- // conformant implementation builds ON this module; importing it is not
14
- // yet conformance. The README states per module which casting's wire
15
- // forms it implements.
16
- //
17
- // core the form every artifact obeys
11
+ // core the form every artifact obeys (JCS, digests, schemas)
18
12
  // crypto the primitives, and the Data Integrity proof
19
- // identity context derivation under the closed registry (§6.1/§6.2)
20
- // encounter the ceremony's wire forms: challenges, cards, credentials
13
+ // identity context derivation under the closed registry (§6.1/§6.2),
14
+ // device labels device/<n>/<c> (§5.5)
15
+ // profile profile@1 (Trust §6b): k_pr, the MAC, the bounds and
16
+ // the picture's header read before any decoding
17
+ // encounter the ceremony's wire forms: challenges, cards, credentials,
18
+ // and its pure checks (5.6 acceptance, the bundle's forms)
19
+ // membership Membership 0.19's forms and checks: invite, accept,
20
+ // evidence, vouch@2, the member label, oids
21
+ // introduction Trust §8's artifacts and checks, the act window, the
22
+ // registry declaration's ack-delay
21
23
  // delivery the sealed envelope and the generic receive stages 1–4
22
24
  // carrier-identity the carrier-relationship principal (Identity §7a)
23
25
  // carrier the carrier side of the port (Delivery §4.4 + §5a)
24
- // holder the holder side: proofs, verdicts, recovery (§5a, §9.3)
25
- // visibility Network Visibility 0.29 on Delivery 0.79 — the trust
26
- // act, the blinded star, §6a continuity, the deniable
27
- // ack (namespaced: `visibility.trust`, `.continuity`,
28
- // `.acks`; graduated from /probe on 04.09.2026)
29
- // ceremony Encounter 0.29's registered ceremony on Delivery
30
- // 0.79 — encounter-bundle, encounter-credential-
31
- // delivery, the signed ack; own-challenge state
32
- // model, enactment record, 5.6 acceptance, both
33
- // paths of 5.8 (graduated from /probe on 05.09.2026)
26
+ // carrier-holder the holder side of the carrier port: proofs, verdicts,
27
+ // recovery (§5a, §9.3)
28
+ // visibility the Trust Layer's wire forms, pure: anchor (self-card@2,
29
+ // anchor-rotation@2, anchor-mapping@4), star@2,
30
+ // group-star@1, continuity-probe@1 and
31
+ // continuity-mapping@1, delivery-ack/0.1
32
+ // ceremony the encounter's, the group's and the introduction's
33
+ // wire forms, pure (the same as the root's encounter,
34
+ // membership and introduction modules, under one name)
35
+ //
36
+ // The holder (holder-api.ts): the typed human acts (trust, untrust,
37
+ // pauseTrust, setClass, setGroupClass, merge, depart, decide, rotateAnchor,
38
+ // setProfile, addDevice, revokeDevice, show, scan, captureSentCard,
39
+ // counter, foundGroup, invite, vouchFor, introduce; {when, actId}), recover,
40
+ // act, receive, tick, resume, report, subscribe, snapshot, deviceKey and the
41
+ // views contacts, contact, groups, profile, prompts, deliveryStatus;
42
+ // `invariants: true` checks invariants.ts on every commit (testing mode).
43
+ // Its modules: identity (Identity §2, §5.4, §5.5), trust (Trust 2, 2a,
44
+ // 5.2–5.4, 6.1–6.5, 6a, 6b), encounter (Encounter 0.31 §5–§7), membership
45
+ // (Membership 0.19 with an in-library Access) and introduction (Trust §8).
46
+ //
47
+ // views the view types (ContactView, …)
48
+ // keys-seed seedKeys — the default KeyProvider over a root seed
49
+ // state HolderState — opaque here (note §4.5): store adapters
50
+ // persist it, apps read the views
51
+ // codec decodeState (to the opaque state), CODEC, StateCodecError
52
+ // ports Store, KeyProvider, Log, Access, DeliveryReport, Outbound
53
+ // results, events ActResult, ReceiveResult, InfraError, HolderEvent
54
+ // entropy the Entropy port by closed purpose
55
+ // store-contract storeContract — the test suite a Store adapter passes
56
+ //
57
+ // Other entry points:
58
+ // ./testing InMemoryStore, memoryLog, scriptedEntropy, storeContract,
59
+ // emptyState, stateBuilder, freezeDeep, sampleState,
60
+ // openPromptModule, the invariants, forgeMapping, SCHEMAS
61
+ // and the generated wire types
62
+ // ./internal the structural state, encodeState and the codec chain,
63
+ // the engine's module types, the pure view functions, the
64
+ // modules' factories and pure reads — for the library's
65
+ // modules and tests, not an app contract
66
+ // ./adapters/vti-mediator the VTI mediator's reports as DeliveryReport
34
67
  //
35
- // Specification, schemas and vectors: https://rltp.real-life.org
68
+ // Specification, schemas and vectors: https://trust-protocol.real-life.org
36
69
  export * from './core.js';
37
70
  export * from './crypto.js';
38
71
  export * from './identity.js';
39
72
  export * from './encounter.js';
73
+ export * from './membership.js';
74
+ export * from './introduction.js';
40
75
  export * from './delivery.js';
41
76
  export * from './carrier-identity.js';
42
77
  export * from './carrier.js';
43
- export * from './holder.js';
78
+ export * from './carrier-holder.js';
79
+ export { PROFILE_TYPE, PROFILE_LIMITS, profileSchemaOk, imageDimensions, imageWithinBounds, profileProblem, profileInfo, profileKey, assembleProfile, profileMacOk, } from './profile.js';
44
80
  export * as visibility from './visibility.js';
45
81
  export * as ceremony from './ceremony.js';
82
+ import { decodeState as decodeStructural } from './codec.js';
83
+ export { CODEC, StateCodecError } from './codec.js';
84
+ /** Load a stored state (a JSON string or a parsed value): an independent,
85
+ * opaque copy at the current codec, or StateCodecError. */
86
+ export function decodeState(raw) {
87
+ return decodeStructural(raw);
88
+ }
89
+ export { InfraError, CryptoUnavailableError } from './results.js';
90
+ export { ENTROPY_PURPOSES, EntropyError, randomEntropy } from './entropy.js';
91
+ export { storeContract } from './store-contract.js';
92
+ export { seedKeys } from './keys-seed.js';
93
+ export { createHolder } from './holder-api.js';
46
94
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,uEAAuE;AACvE,uEAAuE;AACvE,6BAA6B;AAC7B,EAAE;AACF,oEAAoE;AACpE,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,uBAAuB;AACvB,EAAE;AACF,oDAAoD;AACpD,mEAAmE;AACnE,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,oEAAoE;AACpE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,oEAAoE;AACpE,yEAAyE;AACzE,EAAE;AACF,iEAAiE;AAEjE,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA","sourcesContent":["// @real-life/trust-protocol — the cryptographic core of RLTP.\n//\n// What this entry point IS: the wire-level primitives of the converged\n// layers, reproducing the shipped test vectors byte for byte — the\n// canonical form, the derivation of identity contexts under the closed\n// label registry, the encounter wire builders, the sealed envelope and\n// the generic receive chain.\n//\n// What it is NOT (yet): the layers' full state machines. Identity's\n// recovery derivation, Encounter's ceremony record and acceptance\n// machinery, Delivery's type-specific stages and residual bookkeeping\n// live in the specification and its conformance fixtures, not here. A\n// conformant implementation builds ON this module; importing it is not\n// yet conformance. The README states per module which casting's wire\n// forms it implements.\n//\n// core the form every artifact obeys\n// crypto the primitives, and the Data Integrity proof\n// identity context derivation under the closed registry (§6.1/§6.2)\n// encounter the ceremony's wire forms: challenges, cards, credentials\n// delivery the sealed envelope and the generic receive stages 1–4\n// carrier-identity the carrier-relationship principal (Identity §7a)\n// carrier the carrier side of the port (Delivery §4.4 + §5a)\n// holder the holder side: proofs, verdicts, recovery (§5a, §9.3)\n// visibility Network Visibility 0.29 on Delivery 0.79 — the trust\n// act, the blinded star, §6a continuity, the deniable\n// ack (namespaced: `visibility.trust`, `.continuity`,\n// `.acks`; graduated from /probe on 04.09.2026)\n// ceremony Encounter 0.29's registered ceremony on Delivery\n// 0.79 — encounter-bundle, encounter-credential-\n// delivery, the signed ack; own-challenge state\n// model, enactment record, 5.6 acceptance, both\n// paths of 5.8 (graduated from /probe on 05.09.2026)\n//\n// Specification, schemas and vectors: https://rltp.real-life.org\n\nexport * from './core.js'\nexport * from './crypto.js'\nexport * from './identity.js'\nexport * from './encounter.js'\nexport * from './delivery.js'\nexport * from './carrier-identity.js'\nexport * from './carrier.js'\nexport * from './holder.js'\nexport * as visibility from './visibility.js'\nexport * as ceremony from './ceremony.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,4EAA4E;AAC5E,mEAAmE;AACnE,gFAAgF;AAChF,0DAA0D;AAC1D,2EAA2E;AAC3E,oEAAoE;AAC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AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG5D,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEnD;4DAC4D;AAC5D,MAAM,UAAU,WAAW,CAAE,GAAY;IACvC,OAAO,gBAAgB,CAAC,GAAG,CAAiC,CAAA;AAC9D,CAAC;AAGD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA","sourcesContent":["// @real-life/trust-protocol — the reference library of RLTP.\n//\n// The holder: createHolder({store, keys, entropy?, log?, access?, retry?,\n// crypto?}) — one person's device state behind the human acts, receive,\n// report, resume and tick, and the views an app reads. The ports (Store,\n// KeyProvider, Entropy, Log, Access, DeliveryReport, Outbound) are the\n// app's; seedKeys is the default KeyProvider. Beside it, the pure wire\n// builders and verifiers of every layer, byte-compatible with the shipped\n// vectors.\n//\n// core the form every artifact obeys (JCS, digests, schemas)\n// crypto the primitives, and the Data Integrity proof\n// identity context derivation under the closed registry (§6.1/§6.2),\n// device labels device/<n>/<c> (§5.5)\n// profile profile@1 (Trust §6b): k_pr, the MAC, the bounds and\n// the picture's header read before any decoding\n// encounter the ceremony's wire forms: challenges, cards, credentials,\n// and its pure checks (5.6 acceptance, the bundle's forms)\n// membership Membership 0.19's forms and checks: invite, accept,\n// evidence, vouch@2, the member label, oids\n// introduction Trust §8's artifacts and checks, the act window, the\n// registry declaration's ack-delay\n// delivery the sealed envelope and the generic receive stages 1–4\n// carrier-identity the carrier-relationship principal (Identity §7a)\n// carrier the carrier side of the port (Delivery §4.4 + §5a)\n// carrier-holder the holder side of the carrier port: proofs, verdicts,\n// recovery (§5a, §9.3)\n// visibility the Trust Layer's wire forms, pure: anchor (self-card@2,\n// anchor-rotation@2, anchor-mapping@4), star@2,\n// group-star@1, continuity-probe@1 and\n// continuity-mapping@1, delivery-ack/0.1\n// ceremony the encounter's, the group's and the introduction's\n// wire forms, pure (the same as the root's encounter,\n// membership and introduction modules, under one name)\n//\n// The holder (holder-api.ts): the typed human acts (trust, untrust,\n// pauseTrust, setClass, setGroupClass, merge, depart, decide, rotateAnchor,\n// setProfile, addDevice, revokeDevice, show, scan, captureSentCard,\n// counter, foundGroup, invite, vouchFor, introduce; {when, actId}), recover,\n// act, receive, tick, resume, report, subscribe, snapshot, deviceKey and the\n// views contacts, contact, groups, profile, prompts, deliveryStatus;\n// `invariants: true` checks invariants.ts on every commit (testing mode).\n// Its modules: identity (Identity §2, §5.4, §5.5), trust (Trust 2, 2a,\n// 5.2–5.4, 6.1–6.5, 6a, 6b), encounter (Encounter 0.31 §5–§7), membership\n// (Membership 0.19 with an in-library Access) and introduction (Trust §8).\n//\n// views the view types (ContactView, …)\n// keys-seed seedKeys — the default KeyProvider over a root seed\n// state HolderState — opaque here (note §4.5): store adapters\n// persist it, apps read the views\n// codec decodeState (to the opaque state), CODEC, StateCodecError\n// ports Store, KeyProvider, Log, Access, DeliveryReport, Outbound\n// results, events ActResult, ReceiveResult, InfraError, HolderEvent\n// entropy the Entropy port by closed purpose\n// store-contract storeContract — the test suite a Store adapter passes\n//\n// Other entry points:\n// ./testing InMemoryStore, memoryLog, scriptedEntropy, storeContract,\n// emptyState, stateBuilder, freezeDeep, sampleState,\n// openPromptModule, the invariants, forgeMapping, SCHEMAS\n// and the generated wire types\n// ./internal the structural state, encodeState and the codec chain,\n// the engine's module types, the pure view functions, the\n// modules' factories and pure reads — for the library's\n// modules and tests, not an app contract\n// ./adapters/vti-mediator the VTI mediator's reports as DeliveryReport\n//\n// Specification, schemas and vectors: https://trust-protocol.real-life.org\n\nexport * from './core.js'\nexport * from './crypto.js'\nexport * from './identity.js'\nexport * from './encounter.js'\nexport * from './membership.js'\nexport * from './introduction.js'\nexport * from './delivery.js'\nexport * from './carrier-identity.js'\nexport * from './carrier.js'\nexport * from './carrier-holder.js'\nexport {\n PROFILE_TYPE, PROFILE_LIMITS, profileSchemaOk, imageDimensions, imageWithinBounds, profileProblem, profileInfo, profileKey,\n assembleProfile, profileMacOk,\n} from './profile.js'\nexport type { ProfileContent, ProfileBody, ProfileArtifact, Dimensions, ImageDimensions } from './profile.js'\nexport * as visibility from './visibility.js'\nexport * as ceremony from './ceremony.js'\nimport { decodeState as decodeStructural } from './codec.js'\nimport type { OpaqueHolderState } from './state.js'\nexport type { OpaqueHolderState as HolderState, Dec, Millis, B64u, TrustClass, Setting, PromptKind, PromptChoice, OutboxStatus } from './state.js'\nexport { CODEC, StateCodecError } from './codec.js'\nexport type { StateCodecErrorCode } from './codec.js'\n/** Load a stored state (a JSON string or a parsed value): an independent,\n * opaque copy at the current codec, or StateCodecError. */\nexport function decodeState (raw: unknown): OpaqueHolderState {\n return decodeStructural(raw) as unknown as OpaqueHolderState\n}\nexport type * from './ports.js'\nexport type * from './events.js'\nexport { InfraError, CryptoUnavailableError } from './results.js'\nexport type { ActError, ActResult, ReceiveFailure, ReceiveStageNo, ReceiveResult, ResumeResult, InfraErrorCode } from './results.js'\nexport { ENTROPY_PURPOSES, EntropyError, randomEntropy } from './entropy.js'\nexport type { Entropy, EntropyPurpose, EntropyErrorCode, PlatformRandom } from './entropy.js'\nexport { storeContract } from './store-contract.js'\nexport { seedKeys } from './keys-seed.js'\nexport { createHolder } from './holder-api.js'\nexport type { Holder, HolderOptions, HolderSnapshot, HumanActOptions } from './holder-api.js'\nexport type { DeviceKeyResult } from './identity-state.js'\nexport type { ContactView, RelationshipView, ClassView, SealedClassView, ClassesView, ContactProfileView, GroupView, ProfileView, PromptView, DeliveryItemView, DeliveryStatusView } from './views.js'\nexport type { EnginePorts, CommitListener, CryptoHandle } from './engine.js'\nexport type { ContractHarness } from './store-contract.js'\n"]}
@@ -0,0 +1,36 @@
1
+ export type * from './state.js';
2
+ export type { HolderStateV1 } from './holder-state-v1.js';
3
+ export { emptyState, triasOf, toOpaque } from './state.js';
4
+ export { CODEC, MIGRATIONS, VALIDATORS, decodeState, encodeState, sameState, isKnownDuty, StateCodecError } from './codec.js';
5
+ export type { StateCodecErrorCode, StateValidator } from './codec.js';
6
+ export type { HolderModule, CommandDef, PrepareCtx, Prepared, Applied, Refusal, TaskHandler, DutyHandler, DutyCtx, SweepHandler, AckHandler, DecisionHandler, DecisionDef, DecisionFn, EventDraft, OutboundDraft, EngineSnapshot } from './engine.js';
7
+ export type { Arrival, Channel, ReceivedDocument, TaskDiscarded, DiscardReason, TaskFailure, TaskRefusal } from './receive.js';
8
+ export { SIGNATURE_CLASS } from './receive.js';
9
+ export { contactsView, contactView, groupsView, profileView, promptsView, deliveryStatusView } from './views.js';
10
+ export { DECIDE } from './prompts.js';
11
+ export type { DecideInput } from './prompts.js';
12
+ export { freezeDeep } from './util-freeze.js';
13
+ export { trustModule, ANCHOR_MAPPING_TYPE, TRUST_COMMANDS, lineageSegment, recommitEntries } from './trust/mapping.js';
14
+ export type { TrustModuleOptions, TrustSetInput, TrustSetClassInput, TrustSetGroupClassInput, TrustPauseInput } from './trust/mapping.js';
15
+ export { ADMISSION_BOUND, CLASSES, classOn, classOnToward, trusted, lags, newestHeads, newestOf, entryRelationships, activeTuple, findContact, entryOf, feeding, conflicts, joins, supersededIn, anchorSet, tupleByLabel, liveRel, } from './trust/state.js';
16
+ export { STAR_TYPE, ASSEMBLY_LIMIT, starView, viewDigest, heldAnchors, discardAssemblies, rematchStars, retainInflight } from './trust/star.js';
17
+ export { GROUP_STAR_TYPE, groupStarView, sealedOn } from './trust/group-star.js';
18
+ export { CONTINUITY_PROBE_TYPE, CONTINUITY_MAPPING_TYPE, NEW_TUPLE, openTuple, chainTuple, substitutePrior } from './trust/continuity.js';
19
+ export type { NewTupleInput } from './trust/continuity.js';
20
+ export { ENTRY_COMMANDS, mergeEntries, mergeDutiesAfter, mergeable, mergeSettings, rewriteIdentity, splitOff, depart, chainAliases, settleHead, admitPending, } from './trust/entries.js';
21
+ export type { TrustMergeInput, TrustDepartInput } from './trust/entries.js';
22
+ export { DUTY_CLASSES, RECONCILED, classOnId, profileDutyId, classOfDuty, owedOn, onFor, onRelationships, classOnDuty, dropOff, followClasses, moveDuties, afterChain, classOnHandler, } from './trust/duties.js';
23
+ export { promptsModule, collectDecisions } from './prompts.js';
24
+ export { PROFILE_SET, profileIssueDuty, profileTask, profileParts } from './trust/profile.js';
25
+ export { identityModule, IDENTITY_COMMANDS, GENERATION_LAST, withLabel, withPairNonce, deviceKeyOf, rotationDutyId, reissueId } from './identity-state.js';
26
+ export type { DeviceInput, DeviceKeyResult } from './identity-state.js';
27
+ export { stateViolations, transitionViolations, commitViolations, dutyDrops } from './invariants.js';
28
+ export type { CommitOp, Violation } from './invariants.js';
29
+ export { createEngine } from './engine.js';
30
+ export { encounterModule, ENCOUNTER_COMMANDS, resolve as resolveChallenge, idsOf as encounterIdsOf, confirmPromptId } from './encounter/ceremony.js';
31
+ export type { ShowInput, ScanInput, CaptureInput, CounterInput } from './encounter/ceremony.js';
32
+ export { membershipModule, localAccess, MEMBERSHIP_COMMANDS, PRELUDE_REQUEST_TYPE, PRELUDE_REPLY_TYPE, WELCOME_TYPE } from './membership/holder.js';
33
+ export type { FoundInput, InviteInput, VouchInput } from './membership/holder.js';
34
+ export { introductionModule, INTRODUCTION_COMMANDS, OFFER_TYPE, ACK_DELAY } from './introduction/holder.js';
35
+ export type { IntroduceInput } from './introduction/holder.js';
36
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AA8BA,mBAAmB,YAAY,CAAA;AAE/B,YAAY,EAAE,aA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AE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC1J,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACpG,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,OAAO,IAAI,gBAAgB,EAAE,KAAK,IAAI,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACpJ,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACnJ,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC3G,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,22 @@
1
+ export { emptyState, triasOf, toOpaque } from './state.js';
2
+ export { CODEC, MIGRATIONS, VALIDATORS, decodeState, encodeState, sameState, isKnownDuty, StateCodecError } from './codec.js';
3
+ export { SIGNATURE_CLASS } from './receive.js';
4
+ export { contactsView, contactView, groupsView, profileView, promptsView, deliveryStatusView } from './views.js';
5
+ export { DECIDE } from './prompts.js';
6
+ export { freezeDeep } from './util-freeze.js';
7
+ export { trustModule, ANCHOR_MAPPING_TYPE, TRUST_COMMANDS, lineageSegment, recommitEntries } from './trust/mapping.js';
8
+ export { ADMISSION_BOUND, CLASSES, classOn, classOnToward, trusted, lags, newestHeads, newestOf, entryRelationships, activeTuple, findContact, entryOf, feeding, conflicts, joins, supersededIn, anchorSet, tupleByLabel, liveRel, } from './trust/state.js';
9
+ export { STAR_TYPE, ASSEMBLY_LIMIT, starView, viewDigest, heldAnchors, discardAssemblies, rematchStars, retainInflight } from './trust/star.js';
10
+ export { GROUP_STAR_TYPE, groupStarView, sealedOn } from './trust/group-star.js';
11
+ export { CONTINUITY_PROBE_TYPE, CONTINUITY_MAPPING_TYPE, NEW_TUPLE, openTuple, chainTuple, substitutePrior } from './trust/continuity.js';
12
+ export { ENTRY_COMMANDS, mergeEntries, mergeDutiesAfter, mergeable, mergeSettings, rewriteIdentity, splitOff, depart, chainAliases, settleHead, admitPending, } from './trust/entries.js';
13
+ export { DUTY_CLASSES, RECONCILED, classOnId, profileDutyId, classOfDuty, owedOn, onFor, onRelationships, classOnDuty, dropOff, followClasses, moveDuties, afterChain, classOnHandler, } from './trust/duties.js';
14
+ export { promptsModule, collectDecisions } from './prompts.js';
15
+ export { PROFILE_SET, profileIssueDuty, profileTask, profileParts } from './trust/profile.js';
16
+ export { identityModule, IDENTITY_COMMANDS, GENERATION_LAST, withLabel, withPairNonce, deviceKeyOf, rotationDutyId, reissueId } from './identity-state.js';
17
+ export { stateViolations, transitionViolations, commitViolations, dutyDrops } from './invariants.js';
18
+ export { createEngine } from './engine.js';
19
+ export { encounterModule, ENCOUNTER_COMMANDS, resolve as resolveChallenge, idsOf as encounterIdsOf, confirmPromptId } from './encounter/ceremony.js';
20
+ export { membershipModule, localAccess, MEMBERSHIP_COMMANDS, PRELUDE_REQUEST_TYPE, PRELUDE_REPLY_TYPE, WELCOME_TYPE } from './membership/holder.js';
21
+ export { introductionModule, INTRODUCTION_COMMANDS, OFFER_TYPE, ACK_DELAY } from './introduction/holder.js';
22
+ //# sourceMapping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and\n// its tests build on, not an app contract (lib Stage 2, note §4.5, §4.6).\n//\n// The structural HolderState and its parts change with every codec until\n// 0.4.0 and beyond; apps read the views through createHolder, and store\n// adapters see the state only as the opaque root type. Here:\n//\n// state the structural HolderState and its parts, emptyState, triasOf\n// codec decodeState (structural), encodeState, sameState, the chain\n// (CODEC, MIGRATIONS, VALIDATORS), isKnownDuty\n// engine the module surface: HolderModule, CommandDef, PrepareCtx,\n// Prepared, Applied, Refusal, TaskHandler, DutyHandler, DutyCtx,\n// SweepHandler, AckHandler, FailureHandler, IdentityRename, DecisionHandler, EventDraft,\n// OutboundDraft, EngineSnapshot; receive's Arrival,\n// ReceivedDocument, TaskRefusal, TaskDiscarded, TaskFailure\n// views the pure projections state → view\n// prompts DECIDE, DecideInput\n// trust the trust module's factory (trustModule, for tests with another\n// admission bound or assembly limit), its task types and command\n// names, the pure reads of trust/state.ts (trusted, lags,\n// classOn, …), the 2240 re-commit (recommitEntries), the views\n// of 5.4 (starView, groupStarView, sealedOn), heldAnchors,\n// ASSEMBLY_LIMIT and discardAssemblies (5360); the entries\n// (trust/entries.ts: merge, split, departure, the identity\n// rewrite) and continuity (trust/continuity.ts: openTuple,\n// chainTuple, substitutePrior, the task types); the class\n// duties (trust/duties.ts: onFor, the follow rule, the move at\n// a chaining, the handlers)\n// freeze freezeDeep\n// invariants the predicates of invariants.ts over a state and a commit\nexport type * from './state.js'\n// the projection of the non-normative lib/schemas/holder-state-v1.schema.json\nexport type { HolderStateV1 } from './holder-state-v1.js'\nexport { emptyState, triasOf, toOpaque } from './state.js'\nexport { CODEC, MIGRATIONS, VALIDATORS, decodeState, encodeState, sameState, isKnownDuty, StateCodecError } from './codec.js'\nexport type { StateCodecErrorCode, StateValidator } from './codec.js'\nexport type { HolderModule, CommandDef, PrepareCtx, Prepared, Applied, Refusal, TaskHandler, DutyHandler, DutyCtx, SweepHandler, AckHandler, DecisionHandler, DecisionDef, DecisionFn, EventDraft, OutboundDraft, EngineSnapshot } from './engine.js'\nexport type { Arrival, Channel, ReceivedDocument, TaskDiscarded, DiscardReason, TaskFailure, TaskRefusal } from './receive.js'\nexport { SIGNATURE_CLASS } from './receive.js'\nexport { contactsView, contactView, groupsView, profileView, promptsView, deliveryStatusView } from './views.js'\nexport { DECIDE } from './prompts.js'\nexport type { DecideInput } from './prompts.js'\nexport { freezeDeep } from './util-freeze.js'\nexport { trustModule, ANCHOR_MAPPING_TYPE, TRUST_COMMANDS, lineageSegment, recommitEntries } from './trust/mapping.js'\nexport type { TrustModuleOptions, TrustSetInput, TrustSetClassInput, TrustSetGroupClassInput, TrustPauseInput } from './trust/mapping.js'\nexport {\n ADMISSION_BOUND, CLASSES, classOn, classOnToward, trusted, lags, newestHeads, newestOf, entryRelationships, activeTuple, findContact,\n entryOf, feeding, conflicts, joins, supersededIn, anchorSet, tupleByLabel, liveRel,\n} from './trust/state.js'\nexport { STAR_TYPE, ASSEMBLY_LIMIT, starView, viewDigest, heldAnchors, discardAssemblies, rematchStars, retainInflight } from './trust/star.js'\nexport { GROUP_STAR_TYPE, groupStarView, sealedOn } from './trust/group-star.js'\nexport { CONTINUITY_PROBE_TYPE, CONTINUITY_MAPPING_TYPE, NEW_TUPLE, openTuple, chainTuple, substitutePrior } from './trust/continuity.js'\nexport type { NewTupleInput } from './trust/continuity.js'\nexport {\n ENTRY_COMMANDS, mergeEntries, mergeDutiesAfter, mergeable, mergeSettings, rewriteIdentity, splitOff, depart, chainAliases, settleHead, admitPending,\n} from './trust/entries.js'\nexport type { TrustMergeInput, TrustDepartInput } from './trust/entries.js'\nexport {\n DUTY_CLASSES, RECONCILED, classOnId, profileDutyId, classOfDuty, owedOn, onFor, onRelationships, classOnDuty, dropOff, followClasses, moveDuties, afterChain,\n classOnHandler,\n} from './trust/duties.js'\nexport { promptsModule, collectDecisions } from './prompts.js'\nexport { PROFILE_SET, profileIssueDuty, profileTask, profileParts } from './trust/profile.js'\nexport { identityModule, IDENTITY_COMMANDS, GENERATION_LAST, withLabel, withPairNonce, deviceKeyOf, rotationDutyId, reissueId } from './identity-state.js'\nexport type { DeviceInput, DeviceKeyResult } from './identity-state.js'\nexport { stateViolations, transitionViolations, commitViolations, dutyDrops } from './invariants.js'\nexport type { CommitOp, Violation } from './invariants.js'\nexport { createEngine } from './engine.js'\nexport { encounterModule, ENCOUNTER_COMMANDS, resolve as resolveChallenge, idsOf as encounterIdsOf, confirmPromptId } from './encounter/ceremony.js'\nexport type { ShowInput, ScanInput, CaptureInput, CounterInput } from './encounter/ceremony.js'\nexport { membershipModule, localAccess, MEMBERSHIP_COMMANDS, PRELUDE_REQUEST_TYPE, PRELUDE_REPLY_TYPE, WELCOME_TYPE } from './membership/holder.js'\nexport type { FoundInput, InviteInput, VouchInput } from './membership/holder.js'\nexport { introductionModule, INTRODUCTION_COMMANDS, OFFER_TYPE, ACK_DELAY } from './introduction/holder.js'\nexport type { IntroduceInput } from './introduction/holder.js'\n"]}
@@ -0,0 +1,18 @@
1
+ import { DECLARATION_TYPE, INTRODUCTION_TYPES } from '../introduction.js';
2
+ import type { HolderModule } from '../engine.js';
3
+ export declare const OFFER_TYPE: string;
4
+ export { DECLARATION_TYPE, INTRODUCTION_TYPES };
5
+ /** The mediator's declared ack-delay (Delivery §4.4, Trust 8.4). */
6
+ export declare const ACK_DELAY = "PT30S";
7
+ export declare const ACK_DELAY_MS = 30000;
8
+ export declare const INTRODUCTION_COMMANDS: Readonly<{
9
+ introduce: "introduction.introduce";
10
+ }>;
11
+ export interface IntroduceInput {
12
+ requesterId: string;
13
+ targetId: string;
14
+ label?: string;
15
+ }
16
+ /** The introduction module createHolder registers. */
17
+ export declare function introductionModule(): HolderModule;
18
+ //# sourceMappingURL=holder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holder.d.ts","sourceRoot":"","sources":["../../src/introduction/holder.ts"],"names":[],"mappings":"AAgGA,OAAO,EACiB,gBAAgB,EAAE,kBAAkB,EAG3D,MAAM,oBAAoB,CAAA;AAK3B,OAAO,KAAK,EAA6D,YAAY,EAAmD,MAAM,cAAc,CAAA;AAU5J,eAAO,MAAM,UAAU,QAAkC,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAA;AAE/C,oEAAoE;AACpE,eAAO,MAAM,SAAS,UAAU,CAAA;AAChC,eAAO,MAAM,YAAY,QAAS,CAAA;AAElC,eAAO,MAAM,qBAAqB;;EAAyD,CAAA;AAC3F,MAAM,WAAW,cAAc;IAAG,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AA2mBzF,sDAAsD;AACtD,wBAAgB,kBAAkB,IAAK,YAAY,CAmBlD"}