@interop/wallet-core 0.48.0 → 0.50.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 (163) hide show
  1. package/README.md +5 -2
  2. package/dist/clientAnnex/credentialAnchoredGenesis.d.ts +118 -0
  3. package/dist/clientAnnex/credentialAnchoredGenesis.d.ts.map +1 -0
  4. package/dist/clientAnnex/credentialAnchoredGenesis.js +174 -0
  5. package/dist/clientAnnex/credentialAnchoredGenesis.js.map +1 -0
  6. package/dist/clientAnnex/forget.d.ts +138 -0
  7. package/dist/clientAnnex/forget.d.ts.map +1 -0
  8. package/dist/clientAnnex/forget.js +133 -0
  9. package/dist/clientAnnex/forget.js.map +1 -0
  10. package/dist/clientAnnex/forgetLast.d.ts +267 -0
  11. package/dist/clientAnnex/forgetLast.d.ts.map +1 -0
  12. package/dist/clientAnnex/forgetLast.js +374 -0
  13. package/dist/clientAnnex/forgetLast.js.map +1 -0
  14. package/dist/clientAnnex/gc.d.ts +255 -0
  15. package/dist/clientAnnex/gc.d.ts.map +1 -0
  16. package/dist/clientAnnex/gc.js +445 -0
  17. package/dist/clientAnnex/gc.js.map +1 -0
  18. package/dist/clientAnnex/index.d.ts +60 -0
  19. package/dist/clientAnnex/index.d.ts.map +1 -0
  20. package/dist/clientAnnex/index.js +60 -0
  21. package/dist/clientAnnex/index.js.map +1 -0
  22. package/dist/{unlock → clientAnnex}/ladder.d.ts +99 -23
  23. package/dist/clientAnnex/ladder.d.ts.map +1 -0
  24. package/dist/clientAnnex/ladder.js +474 -0
  25. package/dist/clientAnnex/ladder.js.map +1 -0
  26. package/dist/clientAnnex/ladderAnchored.d.ts +276 -0
  27. package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -0
  28. package/dist/clientAnnex/ladderAnchored.js +631 -0
  29. package/dist/clientAnnex/ladderAnchored.js.map +1 -0
  30. package/dist/{webvh/companion.d.ts → clientAnnex/log.d.ts} +373 -152
  31. package/dist/clientAnnex/log.d.ts.map +1 -0
  32. package/dist/{webvh/companion.js → clientAnnex/log.js} +654 -261
  33. package/dist/clientAnnex/log.js.map +1 -0
  34. package/dist/clientAnnex/recoveryLadderAnchored.d.ts +103 -0
  35. package/dist/clientAnnex/recoveryLadderAnchored.d.ts.map +1 -0
  36. package/dist/clientAnnex/recoveryLadderAnchored.js +263 -0
  37. package/dist/clientAnnex/recoveryLadderAnchored.js.map +1 -0
  38. package/dist/{unlock → clientAnnex}/selfEnroll.d.ts +1 -1
  39. package/dist/clientAnnex/selfEnroll.d.ts.map +1 -0
  40. package/dist/{unlock → clientAnnex}/selfEnroll.js +1 -1
  41. package/dist/clientAnnex/selfEnroll.js.map +1 -0
  42. package/dist/clientAnnex/zcap.d.ts +49 -0
  43. package/dist/clientAnnex/zcap.d.ts.map +1 -0
  44. package/dist/clientAnnex/zcap.js +101 -0
  45. package/dist/clientAnnex/zcap.js.map +1 -0
  46. package/dist/clients/index.d.ts +9 -6
  47. package/dist/clients/index.d.ts.map +1 -1
  48. package/dist/clients/index.js +8 -5
  49. package/dist/clients/index.js.map +1 -1
  50. package/dist/clients/listing.d.ts +32 -0
  51. package/dist/clients/listing.d.ts.map +1 -1
  52. package/dist/clients/listing.js +47 -1
  53. package/dist/clients/listing.js.map +1 -1
  54. package/dist/clients/revocation.d.ts +33 -1
  55. package/dist/clients/revocation.d.ts.map +1 -1
  56. package/dist/clients/revocation.js +16 -4
  57. package/dist/clients/revocation.js.map +1 -1
  58. package/dist/enrollment/index.d.ts +6 -4
  59. package/dist/enrollment/index.d.ts.map +1 -1
  60. package/dist/enrollment/index.js +6 -4
  61. package/dist/enrollment/index.js.map +1 -1
  62. package/dist/enrollment/onboardingInvite.d.ts +5 -88
  63. package/dist/enrollment/onboardingInvite.d.ts.map +1 -1
  64. package/dist/enrollment/onboardingInvite.js +5 -168
  65. package/dist/enrollment/onboardingInvite.js.map +1 -1
  66. package/dist/genesis/index.d.ts +5 -0
  67. package/dist/genesis/index.d.ts.map +1 -1
  68. package/dist/genesis/index.js +5 -0
  69. package/dist/genesis/index.js.map +1 -1
  70. package/dist/keys/index.d.ts +1 -1
  71. package/dist/keys/index.d.ts.map +1 -1
  72. package/dist/keys/index.js +1 -1
  73. package/dist/keys/index.js.map +1 -1
  74. package/dist/keys/spaceEpochs.d.ts +7 -2
  75. package/dist/keys/spaceEpochs.d.ts.map +1 -1
  76. package/dist/keys/spaceEpochs.js +8 -2
  77. package/dist/keys/spaceEpochs.js.map +1 -1
  78. package/dist/keys/userKeyRoster.d.ts +39 -0
  79. package/dist/keys/userKeyRoster.d.ts.map +1 -1
  80. package/dist/keys/userKeyRoster.js +43 -1
  81. package/dist/keys/userKeyRoster.js.map +1 -1
  82. package/dist/recovery/index.d.ts +5 -3
  83. package/dist/recovery/index.d.ts.map +1 -1
  84. package/dist/recovery/index.js +4 -2
  85. package/dist/recovery/index.js.map +1 -1
  86. package/dist/recovery/recoveryDelegation.d.ts +35 -12
  87. package/dist/recovery/recoveryDelegation.d.ts.map +1 -1
  88. package/dist/recovery/recoveryDelegation.js +84 -86
  89. package/dist/recovery/recoveryDelegation.js.map +1 -1
  90. package/dist/recovery/recoveryWebvh.d.ts +32 -1
  91. package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
  92. package/dist/recovery/recoveryWebvh.js +2 -2
  93. package/dist/recovery/recoveryWebvh.js.map +1 -1
  94. package/dist/request/capabilityRequest.d.ts +33 -0
  95. package/dist/request/capabilityRequest.d.ts.map +1 -0
  96. package/dist/request/capabilityRequest.js +35 -0
  97. package/dist/request/capabilityRequest.js.map +1 -0
  98. package/dist/request/ephemeralExchange.d.ts +118 -0
  99. package/dist/request/ephemeralExchange.d.ts.map +1 -0
  100. package/dist/request/ephemeralExchange.js +224 -0
  101. package/dist/request/ephemeralExchange.js.map +1 -0
  102. package/dist/request/index.d.ts +6 -0
  103. package/dist/request/index.d.ts.map +1 -1
  104. package/dist/request/index.js +6 -0
  105. package/dist/request/index.js.map +1 -1
  106. package/dist/space/activity.d.ts +38 -0
  107. package/dist/space/activity.d.ts.map +1 -1
  108. package/dist/space/activity.js +41 -1
  109. package/dist/space/activity.js.map +1 -1
  110. package/dist/space/index.d.ts +1 -1
  111. package/dist/space/index.d.ts.map +1 -1
  112. package/dist/space/index.js +1 -1
  113. package/dist/space/index.js.map +1 -1
  114. package/dist/unlock/index.d.ts +11 -23
  115. package/dist/unlock/index.d.ts.map +1 -1
  116. package/dist/unlock/index.js +10 -21
  117. package/dist/unlock/index.js.map +1 -1
  118. package/dist/unlock/retire.d.ts +47 -3
  119. package/dist/unlock/retire.d.ts.map +1 -1
  120. package/dist/unlock/retire.js +21 -5
  121. package/dist/unlock/retire.js.map +1 -1
  122. package/dist/unlock/standingWebvh.d.ts +37 -82
  123. package/dist/unlock/standingWebvh.d.ts.map +1 -1
  124. package/dist/unlock/standingWebvh.js +64 -247
  125. package/dist/unlock/standingWebvh.js.map +1 -1
  126. package/dist/unlock/unlockRecord.d.ts +13 -6
  127. package/dist/unlock/unlockRecord.d.ts.map +1 -1
  128. package/dist/unlock/unlockRecord.js +14 -8
  129. package/dist/unlock/unlockRecord.js.map +1 -1
  130. package/dist/webvh/delegatedLogStore.d.ts +5 -5
  131. package/dist/webvh/delegatedLogStore.js +1 -1
  132. package/dist/webvh/didWebvh.d.ts +20 -10
  133. package/dist/webvh/didWebvh.d.ts.map +1 -1
  134. package/dist/webvh/didWebvh.js +17 -17
  135. package/dist/webvh/didWebvh.js.map +1 -1
  136. package/dist/webvh/index.d.ts +9 -23
  137. package/dist/webvh/index.d.ts.map +1 -1
  138. package/dist/webvh/index.js +9 -22
  139. package/dist/webvh/index.js.map +1 -1
  140. package/dist/webvh/revokeClient.d.ts +77 -5
  141. package/dist/webvh/revokeClient.d.ts.map +1 -1
  142. package/dist/webvh/revokeClient.js +154 -61
  143. package/dist/webvh/revokeClient.js.map +1 -1
  144. package/dist/webvh/standingZcap.d.ts +11 -1
  145. package/dist/webvh/standingZcap.d.ts.map +1 -1
  146. package/dist/webvh/standingZcap.js +13 -14
  147. package/dist/webvh/standingZcap.js.map +1 -1
  148. package/dist/webvh/wasIdStore.d.ts +13 -7
  149. package/dist/webvh/wasIdStore.d.ts.map +1 -1
  150. package/dist/webvh/wasIdStore.js +8 -4
  151. package/dist/webvh/wasIdStore.js.map +1 -1
  152. package/dist/webvh/zcap.d.ts +0 -24
  153. package/dist/webvh/zcap.d.ts.map +1 -1
  154. package/dist/webvh/zcap.js +0 -42
  155. package/dist/webvh/zcap.js.map +1 -1
  156. package/package.json +40 -34
  157. package/dist/unlock/ladder.d.ts.map +0 -1
  158. package/dist/unlock/ladder.js +0 -254
  159. package/dist/unlock/ladder.js.map +0 -1
  160. package/dist/unlock/selfEnroll.d.ts.map +0 -1
  161. package/dist/unlock/selfEnroll.js.map +0 -1
  162. package/dist/webvh/companion.d.ts.map +0 -1
  163. package/dist/webvh/companion.js.map +0 -1
@@ -0,0 +1,445 @@
1
+ import { clientAnnexDidParts, clientAnnexLogPinId, clientAnnexLogStore, delegatedClientsPointer, embeddedGenerationDelegation, ensureGenerationDelegationCurrent, GENERATION_ID_PREFIX, mintCredentialClientAnnexGeneration, mintGenerationDelegation, revokeTreatingAlreadyRevokedAsSuccess, setDelegatedClientsPointer } from './log.js';
2
+ import { readPublishedLog } from '../webvh/didWebvh.js';
3
+ import { accountLogPinId } from '../webvh/verifyLog.js';
4
+ /**
5
+ * The fixed GC cadence: a generation is replaced at the first durable login
6
+ * 90 days after the current pointer value was established. Wallet GC policy
7
+ * over the account log's own timestamps, never a stored or wire value.
8
+ */
9
+ export const GENERATION_GC_PERIOD_MS = 90 * 24 * 60 * 60 * 1000;
10
+ /**
11
+ * The quiet bound: a generation is GC-quiet when its newest entry's
12
+ * `versionTime` is over 24 hours old. The bound defers the swap only; it
13
+ * never expires a session. A visit outliving it merely loses guaranteed
14
+ * guard protection, and in the rare case a quarterly pass lands on one, the
15
+ * session's next authorization failure maps to the generation-lapse retry
16
+ * state.
17
+ */
18
+ export const GENERATION_QUIET_BOUND_MS = 24 * 60 * 60 * 1000;
19
+ /**
20
+ * The skew-margin grace floor on the quiet bound: three clocks meet at the
21
+ * guard check (the enrolling writer's, any prior entry writer's, and the
22
+ * GC-running client's), and `versionTime` is asserted by the writer's clock,
23
+ * so the guard compares against the bound plus this margin. An hour is
24
+ * generous against real-world skew and defers the swap by at most an hour
25
+ * against a quarterly cadence.
26
+ */
27
+ export const GENERATION_QUIET_GRACE_MS = 60 * 60 * 1000;
28
+ /**
29
+ * The `versionTime` of the account-log entry that established the CURRENT
30
+ * `#DelegatedClients` pointer value: the newest entry whose state names a
31
+ * different annex DID than the entry before it (or the first entry, when
32
+ * the pointer has been there since genesis). This is the cadence's clock --
33
+ * "the pointer-update entry is the record" -- and it is read off the log a
34
+ * durable login has already verified, so the cadence costs no extra fetch
35
+ * and every enrolled client agrees on it.
36
+ *
37
+ * @param options {object}
38
+ * @param options.log {DIDLog} the VERIFIED account log
39
+ * @returns {string | undefined} the establishing entry's `versionTime`,
40
+ * or undefined when no entry carries a pointer
41
+ */
42
+ export function delegatedClientsPointerEstablishedAt({ log }) {
43
+ let establishedAt;
44
+ let previous;
45
+ for (const entry of log) {
46
+ const pointed = delegatedClientsPointer({ doc: entry.state });
47
+ if (pointed !== undefined && pointed !== previous) {
48
+ establishedAt = entry.versionTime;
49
+ }
50
+ if (pointed === undefined) {
51
+ // A document with no pointer has no annex posture; a later entry
52
+ // restoring one establishes afresh.
53
+ establishedAt = undefined;
54
+ }
55
+ previous = pointed;
56
+ }
57
+ return establishedAt;
58
+ }
59
+ /**
60
+ * Whether the quarterly swap is due: the current pointer value was
61
+ * established {@link GENERATION_GC_PERIOD_MS} or more ago. A log with no
62
+ * pointer is never due (there is no generation to replace).
63
+ *
64
+ * @param options {object}
65
+ * @param options.log {DIDLog} the VERIFIED account log
66
+ * @param [options.now] {number} epoch milliseconds, for tests
67
+ * @returns {boolean}
68
+ */
69
+ export function clientAnnexGcDue({ log, now = Date.now() }) {
70
+ const establishedAt = delegatedClientsPointerEstablishedAt({ log });
71
+ if (establishedAt === undefined) {
72
+ return false;
73
+ }
74
+ const establishedMs = Date.parse(establishedAt);
75
+ return (Number.isFinite(establishedMs) &&
76
+ now - establishedMs >= GENERATION_GC_PERIOD_MS);
77
+ }
78
+ /**
79
+ * The live-entry guard: whether a generation is GC-quiet -- its newest
80
+ * entry's `versionTime` is older than the quiet bound plus the skew grace
81
+ * margin. Applies to the POINTED generation only (an unpointed generation
82
+ * authorizes nothing under pointer equality, so nothing inside it ever
83
+ * defers deletion). An unparseable `versionTime` reads as not quiet: the
84
+ * swap defers rather than abandoning a possibly-live visit.
85
+ *
86
+ * @param options {object}
87
+ * @param options.log {DIDLog} the pointed generation's VERIFIED annex
88
+ * log
89
+ * @param [options.now] {number} epoch milliseconds, for tests
90
+ * @returns {boolean}
91
+ */
92
+ export function generationQuiet({ log, now = Date.now() }) {
93
+ const newest = log[log.length - 1]?.versionTime;
94
+ if (newest === undefined) {
95
+ return false;
96
+ }
97
+ const newestMs = Date.parse(newest);
98
+ return (Number.isFinite(newestMs) &&
99
+ now - newestMs >= GENERATION_QUIET_BOUND_MS + GENERATION_QUIET_GRACE_MS);
100
+ }
101
+ /**
102
+ * One annex GC pass: the quarterly swap when due and quiet, then the
103
+ * predicate-driven collect fan-out over every non-pointed `gen-` collection.
104
+ * See the module header for the stage order and its load-bearing constraints.
105
+ *
106
+ * Convergence: every stage detects completion from durable state. A re-run
107
+ * after a tear re-POSTs the revocation blind (400 already-revoked reads as
108
+ * success), re-writes the digest (the deterministic payload id collapses the
109
+ * second row at read time), and re-runs the idempotent delete; a swap torn
110
+ * before its re-point leaves an unpointed fresh generation the same fan-out
111
+ * collects.
112
+ *
113
+ * @param options {object}
114
+ * @param options.was {WasClient} the storage client, signing as an
115
+ * enrolled client (root tier on both the account and auxiliary Spaces)
116
+ * @param options.wasServerUrl {string} the account pointer's host
117
+ * @param options.accountSpaceId {string} the ACCOUNT Space's id (the
118
+ * generation delegation's target subtree)
119
+ * @param options.account {object} the VERIFIED account log
120
+ * (`{ did, doc, log }` -- `verifyAccountLog`'s shape)
121
+ * @param options.idStore {WebvhIdStore} the account log's id store, for
122
+ * the re-point
123
+ * @param options.updateKeys {ClientWebvhUpdateKeys} this enrolled client's
124
+ * update keys, signing the re-point entry
125
+ * @param options.zcapClient {ZcapClient} signs the fresh generation
126
+ * delegation (the promoted account keyId)
127
+ * @param [options.ladderSeed] {Uint8Array} the login credential's ladder
128
+ * seed; absent, a due swap reports `no-ladder-seed` and only the collect
129
+ * fan-out runs
130
+ * @param options.recordDigest {Function}
131
+ * `({ generationId, firstEntry, lastEntry, entryCount }) => Promise<void>`
132
+ * -- writes the GenerationCollect wallet-activity row; called before the
133
+ * delete, and a throw keeps the generation for the next pass
134
+ * @param [options.onCollected] {Function}
135
+ * `({ generationId }) => Promise<void>` -- local cleanup after a
136
+ * generation's delete (the caller's annex pin-slot drop); a throw is
137
+ * reported but cannot be retried (the collection is already gone)
138
+ * @param [options.pinStore] {ResourceLogPinStore} chain-head pins for the
139
+ * account-log re-point and the pointed generation's read
140
+ * @param [options.now] {number} epoch milliseconds, for tests
141
+ * @returns {Promise<ClientAnnexGcReport>}
142
+ */
143
+ export async function runClientAnnexGc({ was, wasServerUrl, accountSpaceId, account, idStore, updateKeys, zcapClient, ladderSeed, recordDigest, onCollected, pinStore, now = Date.now() }) {
144
+ const pointedDid = delegatedClientsPointer({ doc: account.doc });
145
+ if (pointedDid === undefined) {
146
+ return { swap: 'no-pointer', collected: [], failed: [] };
147
+ }
148
+ const { spaceId } = clientAnnexDidParts({ did: pointedDid });
149
+ const failed = [];
150
+ // 1. The swap, when the quarterly cadence is due. Its own failure is
151
+ // collected under the pointed generation's id rather than aborting the
152
+ // pass: the collect fan-out below still cleans what it can, and the next
153
+ // durable login re-attempts the swap from durable state.
154
+ let swap = 'not-due';
155
+ let currentDid = pointedDid;
156
+ if (clientAnnexGcDue({ log: account.log, now })) {
157
+ swap =
158
+ ladderSeed === undefined
159
+ ? 'no-ladder-seed'
160
+ : await (async () => {
161
+ const oldParts = clientAnnexDidParts({ did: pointedDid });
162
+ try {
163
+ const old = await readClientAnnexGeneration({
164
+ was,
165
+ spaceId,
166
+ generationId: oldParts.generationId,
167
+ expectedDid: pointedDid,
168
+ pinStore
169
+ });
170
+ if (old === undefined ||
171
+ !generationQuiet({ log: old.log, now })) {
172
+ // A missing pointed log is a broken state the collect
173
+ // fan-out cannot touch (the pointer still names it); defer
174
+ // rather than swap onto a generation this pass could not
175
+ // read as quiet.
176
+ return old === undefined ? 'failed' : 'deferred-live';
177
+ }
178
+ currentDid = await replaceClientAnnexGeneration({
179
+ was,
180
+ wasServerUrl,
181
+ accountSpaceId,
182
+ account,
183
+ idStore,
184
+ updateKeys,
185
+ zcapClient,
186
+ ladderSeed,
187
+ clientAnnexSpaceId: spaceId,
188
+ oldGeneration: old,
189
+ pinStore
190
+ });
191
+ return 'replaced';
192
+ }
193
+ catch (err) {
194
+ failed.push({ generationId: oldParts.generationId, error: err });
195
+ return 'failed';
196
+ }
197
+ })();
198
+ }
199
+ // 2. The collect fan-out: every `gen-` collection the (possibly fresh)
200
+ // pointer does not name. Orphan discovery is a plain prefix match over the
201
+ // auxiliary Space's collection listing -- no registry of generations
202
+ // exists anywhere -- and a torn GC's old generation, a torn signup's
203
+ // orphan, and a double-genesis loser get identical treatment.
204
+ const currentGenerationId = clientAnnexDidParts({
205
+ did: currentDid
206
+ }).generationId;
207
+ const space = was.space(spaceId);
208
+ const stale = [];
209
+ for await (const page of space.collectionsPages()) {
210
+ for (const item of page.items) {
211
+ if (item.id.startsWith(GENERATION_ID_PREFIX) &&
212
+ item.id !== currentGenerationId) {
213
+ stale.push(item.id);
214
+ }
215
+ }
216
+ }
217
+ const collected = [];
218
+ await Promise.all(stale.map(async (generationId) => {
219
+ try {
220
+ await collectOneGeneration({
221
+ was,
222
+ spaceId,
223
+ generationId,
224
+ recordDigest,
225
+ onCollected
226
+ });
227
+ collected.push(generationId);
228
+ }
229
+ catch (err) {
230
+ failed.push({ generationId, error: err });
231
+ }
232
+ }));
233
+ return { swap, pointedDid: currentDid, collected, failed };
234
+ }
235
+ /**
236
+ * Reads and verifies one generation's published annex log, or resolves
237
+ * undefined when its `did.jsonl` does not exist (a generation that never
238
+ * finished minting, or whose collection outlived a torn delete).
239
+ *
240
+ * @param options {object}
241
+ * @param options.was {WasClient}
242
+ * @param options.spaceId {string} the auxiliary annex Space's id
243
+ * @param options.generationId {string}
244
+ * @param [options.expectedDid] {string}
245
+ * @param [options.pinStore] {ResourceLogPinStore}
246
+ * @returns {Promise<PublishedWebvhLog | undefined>}
247
+ */
248
+ async function readClientAnnexGeneration({ was, spaceId, generationId, expectedDid, pinStore }) {
249
+ const store = clientAnnexLogStore({ was, spaceId, generationId });
250
+ return readPublishedLog({
251
+ idStore: store,
252
+ ...(expectedDid !== undefined ? { expectedDid } : {}),
253
+ ...(pinStore !== undefined
254
+ ? { pinStore, logId: clientAnnexLogPinId({ spaceId, generationId }) }
255
+ : {})
256
+ });
257
+ }
258
+ /**
259
+ * The swap's four stages, in the fixed order: mint + genesis; install the
260
+ * fresh generation's delegation service entry; revoke the old generation's
261
+ * delegation; re-point the account document. Returns the fresh annex
262
+ * DID. The digest and the delete are deliberately NOT here -- once the
263
+ * re-point lands, the old generation is an ordinary non-pointed `gen-`
264
+ * collection and the standing collect fan-out handles it, which is also
265
+ * what makes a swap torn after its re-point resume for free.
266
+ *
267
+ * @param options {object} see {@link runClientAnnexGc}, plus:
268
+ * @param options.clientAnnexSpaceId {string} the auxiliary Space's id
269
+ * @param [options.oldGeneration] {PublishedWebvhLog} the pointed
270
+ * generation's verified log, read by the quiet check; absent (an
271
+ * off-cadence swap whose pointed log is unreadable), the revoke stage is
272
+ * skipped and the old generation's delegation dies with the re-point on a
273
+ * conforming server
274
+ * @returns {Promise<string>} the fresh annex DID
275
+ */
276
+ async function replaceClientAnnexGeneration({ was, wasServerUrl, accountSpaceId, account, idStore, updateKeys, zcapClient, ladderSeed, clientAnnexSpaceId, oldGeneration, pinStore }) {
277
+ // 1. Mint + genesis: a fresh generation in the existing auxiliary Space
278
+ // (the typed-Space ensure no-ops on it; the controller argument is only
279
+ // read when the Space does not exist). The genesis commits the minting
280
+ // credential's rung-0 hash for the fresh generation id.
281
+ const minted = await mintCredentialClientAnnexGeneration({
282
+ was,
283
+ wasServerUrl,
284
+ spaceId: clientAnnexSpaceId,
285
+ controller: account.did,
286
+ ladderSeed
287
+ });
288
+ // 2. Install the fresh generation's delegation service entry (the
289
+ // install-when-absent half of the renew-precedes-mint helper), the
290
+ // delegation signed by this enrolled client's promoted account key and the
291
+ // installing annex entry by the credential's rung 0.
292
+ await ensureGenerationDelegationCurrent({
293
+ store: clientAnnexLogStore({
294
+ was,
295
+ spaceId: clientAnnexSpaceId,
296
+ generationId: minted.generationId
297
+ }),
298
+ ladderSeed,
299
+ generationId: minted.generationId,
300
+ mintGenerationDelegation: async ({ clientAnnexDid }) => mintGenerationDelegation({
301
+ zcapClient,
302
+ wasServerUrl,
303
+ spaceId: accountSpaceId,
304
+ clientAnnexDid
305
+ }),
306
+ expectedDid: minted.did,
307
+ ...(pinStore !== undefined
308
+ ? {
309
+ pinStore,
310
+ logId: clientAnnexLogPinId({
311
+ spaceId: clientAnnexSpaceId,
312
+ generationId: minted.generationId
313
+ })
314
+ }
315
+ : {})
316
+ });
317
+ // 3. Revoke the old generation's delegation, before the re-point (the
318
+ // revocation POST verifies against the currently resolved document, so it
319
+ // only chains while the pointer still names the old generation) and
320
+ // before the delete (the POST needs bytes the delete destroys).
321
+ const oldDelegation = oldGeneration === undefined
322
+ ? undefined
323
+ : embeddedGenerationDelegation({ doc: oldGeneration.doc });
324
+ if (oldDelegation !== undefined) {
325
+ await revokeTreatingAlreadyRevokedAsSuccess({
326
+ revoke: zcap => was.revoke(zcap),
327
+ delegation: oldDelegation
328
+ });
329
+ }
330
+ // 4. Re-point the account document at the fresh generation. On a
331
+ // conforming server the pointer equality itself kills the old
332
+ // generation's delegations; the explicit revoke above covered the
333
+ // fail-open case.
334
+ await setDelegatedClientsPointer({
335
+ idStore,
336
+ updateKeys,
337
+ clientAnnexDid: minted.did,
338
+ expectedDid: account.did,
339
+ ...(pinStore !== undefined
340
+ ? { pinStore, logId: accountLogPinId({ spaceId: accountSpaceId }) }
341
+ : {})
342
+ });
343
+ return minted.did;
344
+ }
345
+ /**
346
+ * AN OFF-CADENCE GENERATION SWAP: replaces the pointed annex generation
347
+ * outside the quarterly rhythm -- the credential-rotation ceremony's
348
+ * fallback when no distinct committed rung can sign a strike entry
349
+ * (`retireClientAnnexRung`): a fresh generation minted from a SURVIVING
350
+ * credential's seed commits only that credential's rung-0 hash, so the
351
+ * retired credential's annex posture dies with the whole generation the
352
+ * moment the re-point lands. The abandoned generation is an ordinary
353
+ * non-pointed `gen-` collection the standing collect fan-out picks up at the
354
+ * next durable login.
355
+ *
356
+ * Same four swap stages and ordering as the quarterly GC swap, minus the
357
+ * cadence and quiet gates (the caller's reason for swapping is authority
358
+ * removal, not hygiene). The pointed generation's log is read for the revoke
359
+ * stage's delegation bytes; unreadable, the revoke is skipped and pointer
360
+ * equality retires the old delegation on a conforming server.
361
+ *
362
+ * @param options {object} see {@link runClientAnnexGc} for the shared
363
+ * members ({ was, wasServerUrl, accountSpaceId, account, idStore,
364
+ * updateKeys, zcapClient, pinStore }); `ladderSeed` here is the SURVIVING
365
+ * credential's seed the fresh generation is minted from
366
+ * @returns {Promise<string>} the fresh annex DID
367
+ */
368
+ export async function swapClientAnnexGeneration({ was, wasServerUrl, accountSpaceId, account, idStore, updateKeys, zcapClient, ladderSeed, pinStore }) {
369
+ const pointedDid = delegatedClientsPointer({ doc: account.doc });
370
+ if (pointedDid === undefined) {
371
+ throw new Error('clientAnnex: the account document carries no delegated-clients ' +
372
+ 'service entry; no generation exists to swap.');
373
+ }
374
+ const { spaceId } = clientAnnexDidParts({ did: pointedDid });
375
+ const oldGeneration = await readClientAnnexGeneration({
376
+ was,
377
+ spaceId,
378
+ generationId: clientAnnexDidParts({ did: pointedDid }).generationId,
379
+ expectedDid: pointedDid,
380
+ ...(pinStore !== undefined ? { pinStore } : {})
381
+ });
382
+ return replaceClientAnnexGeneration({
383
+ was,
384
+ wasServerUrl,
385
+ accountSpaceId,
386
+ account,
387
+ idStore,
388
+ updateKeys,
389
+ zcapClient,
390
+ ladderSeed,
391
+ clientAnnexSpaceId: spaceId,
392
+ ...(oldGeneration !== undefined ? { oldGeneration } : {}),
393
+ ...(pinStore !== undefined ? { pinStore } : {})
394
+ });
395
+ }
396
+ /**
397
+ * Collects one non-pointed generation: revoke its embedded delegation
398
+ * (blind; the server's 400 already-revoked answer reads as success), write
399
+ * the digest from its verified log, delete the collection, then the
400
+ * caller's local cleanup. A generation whose `did.jsonl` does not exist
401
+ * held no visits and is deleted without a digest row; one whose log exists
402
+ * but fails verification is kept and reported (deleting it would destroy
403
+ * the evidence of tampering).
404
+ *
405
+ * @param options {object}
406
+ * @param options.was {WasClient}
407
+ * @param options.spaceId {string}
408
+ * @param options.generationId {string}
409
+ * @param options.recordDigest {Function} see {@link runClientAnnexGc}
410
+ * @param [options.onCollected] {Function} see {@link runClientAnnexGc}
411
+ * @returns {Promise<void>}
412
+ */
413
+ async function collectOneGeneration({ was, spaceId, generationId, recordDigest, onCollected }) {
414
+ // No pin, no expectedDid: an orphan was possibly never pointed from this
415
+ // client, and its chain-head slot is about to be dropped either way. The
416
+ // log still fully verifies (hash chain, prerotation, rung signatures) --
417
+ // the digest quotes only a log that resolves.
418
+ const published = await readClientAnnexGeneration({
419
+ was,
420
+ spaceId,
421
+ generationId
422
+ });
423
+ if (published !== undefined) {
424
+ const oldDelegation = embeddedGenerationDelegation({ doc: published.doc });
425
+ if (oldDelegation !== undefined) {
426
+ await revokeTreatingAlreadyRevokedAsSuccess({
427
+ revoke: zcap => was.revoke(zcap),
428
+ delegation: oldDelegation
429
+ });
430
+ }
431
+ // The digest, strictly before the delete: the delete destroys the
432
+ // owner's only per-entry record of the window's visits, so a digest
433
+ // that cannot be written keeps the generation for the next pass.
434
+ await recordDigest({
435
+ generationId,
436
+ firstEntry: published.log[0]?.versionTime,
437
+ lastEntry: published.log[published.log.length - 1]?.versionTime,
438
+ entryCount: published.log.length
439
+ });
440
+ }
441
+ // Idempotent: a re-run's delete of an already-deleted collection resolves.
442
+ await was.space(spaceId).collection(generationId).delete();
443
+ await onCollected?.({ generationId });
444
+ }
445
+ //# sourceMappingURL=gc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gc.js","sourceRoot":"","sources":["../../src/clientAnnex/gc.ts"],"names":[],"mappings":"AAwDA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,4BAA4B,EAC5B,iCAAiC,EACjC,oBAAoB,EACpB,mCAAmC,EACnC,wBAAwB,EACxB,qCAAqC,EACrC,0BAA0B,EAC3B,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAMvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAE/D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oCAAoC,CAAC,EACnD,GAAG,EAGJ;IACC,IAAI,aAAiC,CAAA;IACrC,IAAI,QAA4B,CAAA;IAChC,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,uBAAuB,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,E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E,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;gBAChC,UAAU,EAAE,aAAa;aAC1B,CAAC,CAAA;QACJ,CAAC;QACD,kEAAkE;QAClE,oEAAoE;QACpE,iEAAiE;QACjE,MAAM,YAAY,CAAC;YACjB,YAAY;YACZ,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW;YACzC,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,WAAW;YAC/D,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM;SACjC,CAAC,CAAA;IACJ,CAAC;IAED,2EAA2E;IAC3E,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAA;IAC1D,MAAM,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;AACvC,CAAC"}
@@ -0,0 +1,60 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * The `@interop/wallet-core/clientAnnex` subpath: the client annex -- the
6
+ * authoring and maintenance surface of everything anchored on a standing
7
+ * credential's ladder rather than on an enrolled durable client. One boundary
8
+ * rule holds throughout: this subpath imports from the base subpaths;
9
+ * nothing in the base imports from it (enforced in the lint pass, with one
10
+ * pinned exception -- `unlock/standingWebvh.ts` uses the shared ladder
11
+ * attribution helpers here, never the annex log machinery). The verify-side
12
+ * halves every wallet needs regardless of posture stay in the base: the
13
+ * resource-log ladder-append license and `ControllerPosture` ladder-key
14
+ * computation (`resourceLog`), `ladderVmIds` recognition (`webvh`), the
15
+ * unlock-record codec with its `ladder` and `delegatedClients` members
16
+ * (`unlock`), the standing-zcap staleness policy and the generalized log
17
+ * store seams (`webvh`), and the `GenerationCollect` activity builder
18
+ * (`space`).
19
+ *
20
+ * - The ladder (`ladder.ts`): rung and ladder-VM derivation from the record's
21
+ * random seed, and the shared attribution walks (`attributeLadderRung`,
22
+ * `attributeLadderPosture`) that recover the ladder's state from the
23
+ * published log itself.
24
+ * - The annex log (`log.ts`) and its GC (`gc.ts`): the disposable sidecar
25
+ * did:webvh of GC'd generations holding transient per-visit verification
26
+ * methods, the generation delegation, the account document's
27
+ * `#DelegatedClients` pointer, and the quarterly swap-and-collect.
28
+ * - ZCap signing as the ladder VM (`zcap.ts`): `ladderVmZcapClient` and the
29
+ * bootstrap `ladderVmAgent`.
30
+ * - The ladder-anchored account-log ceremonies (`ladderAnchored.ts`):
31
+ * ladder-anchored genesis, the self-enrolling continuation, the one-entry
32
+ * forget -- plus the composed flows around them (`selfEnroll.ts`,
33
+ * `forget.ts`), the credential-anchored account genesis
34
+ * (`credentialAnchoredGenesis.ts`), and the transient-recovery
35
+ * continuation (`recoveryLadderAnchored.ts`).
36
+ *
37
+ * The subsystem's decision records are the subpath's reading list:
38
+ * `decisions/0002` (annex log update authority is static rung 0),
39
+ * `decisions/0003` (generation identity and the ladder HKDF label family),
40
+ * `decisions/0005` (the `delegatedClients` sealed record member),
41
+ * `decisions/0006` (generation GC observables and the `GenerationCollect`
42
+ * digest), and `decisions/0007` (the reveal entry's hash order).
43
+ */
44
+ export { attributeLadderPosture, attributeLadderRung, clientAnnexRung, clientAnnexRungSeed, generateLadderSeed, LADDER_MAX_SCAN, LadderAttributionError, ladderRung, ladderRungSeed, ladderVmKeyMultibase, ladderVmSeed } from './ladder.js';
45
+ export type { LadderRung, LadderRungState, LadderStandingPosture } from './ladder.js';
46
+ export { assertGenerationId, clampGrantExpires, CLIENT_ANNEX_SPACE_TYPE, clientAnnexDidParts, clientAnnexLogPinId, clientAnnexLogStore, ClientAnnexRungUncommittedError, commitClientAnnexRung, createClientAnnexLog, DELEGATED_CLIENTS_DELEGATION_ACTIONS, DELEGATED_CLIENTS_DELEGATION_TTL_MS, DELEGATED_CLIENTS_SERVICE_TYPE, delegatedClientsDelegationMinter, delegatedClientsDelegationSpaceId, delegatedClientsPointer, delegatedClientsServiceEntry, embeddedGenerationDelegation, enrollClientAnnexTransientClient, enrollTransientClient, ensureClientAnnexSpace, ensureGenerationDelegationCurrent, GENERATION_DELEGATION_ACTIONS, GENERATION_DELEGATION_SERVICE_TYPE, GENERATION_DELEGATION_TTL_MS, GENERATION_ID_PREFIX, generationDelegationHistory, generationDelegationServiceEntry, mintClientAnnexGeneration, mintCredentialClientAnnexGeneration, mintDelegatedClientsDelegation, mintGenerationDelegation, mintGenerationId, retireClientAnnexRung, revokeTreatingAlreadyRevokedAsSuccess, servicesPointedAtClientAnnex, setDelegatedClientsPointer } from './log.js';
47
+ export type { ClientAnnexWriteStore } from './log.js';
48
+ export { clientAnnexGcDue, delegatedClientsPointerEstablishedAt, GENERATION_GC_PERIOD_MS, GENERATION_QUIET_BOUND_MS, GENERATION_QUIET_GRACE_MS, generationQuiet, runClientAnnexGc, swapClientAnnexGeneration } from './gc.js';
49
+ export type { ClientAnnexGcReport, ClientAnnexGcSwapOutcome } from './gc.js';
50
+ export { ladderVmAgent, ladderVmZcapClient } from './zcap.js';
51
+ export { createLadderAnchoredAccountLog, ensureLadderAnchoredDidWebvh, forgetLastWebvhClient, forgetWebvhClient, installLadderVmWebvh, LastDurableClientForgetError, selfEnrollWebvhClient } from './ladderAnchored.js';
52
+ export { selfEnrollClientCore } from './selfEnroll.js';
53
+ export { forgetDurableClient } from './forget.js';
54
+ export type { DurableClientForgetResult } from './forget.js';
55
+ export { forgetLastDurableClient } from './forgetLast.js';
56
+ export type { GenerationDelegationRetirement, LastDurableClientForgetResult, UnlockMethodsRemintReach } from './forgetLast.js';
57
+ export { ensureCredentialAnchoredAccountGenesis, mintCredentialAnchoredAccountKeySet } from './credentialAnchoredGenesis.js';
58
+ export { recoverWebvhLadderAnchored } from './recoveryLadderAnchored.js';
59
+ export { createLadderAnchoredWebvhLog, ladderVerificationMethod } from '../webvh/didWebvh.js';
60
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clientAnnex/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,YAAY,EACb,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,UAAU,EACV,eAAe,EACf,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,+BAA+B,EAC/B,qBAAqB,EACrB,oBAAoB,EACpB,oCAAoC,EACpC,mCAAmC,EACnC,8BAA8B,EAC9B,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,EACjC,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,EAC3B,gCAAgC,EAChC,yBAAyB,EACzB,mCAAmC,EACnC,8BAA8B,EAC9B,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,qCAAqC,EACrC,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,OAAO,EACL,gBAAgB,EAChB,oCAAoC,EACpC,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE5E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE7D,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACzD,YAAY,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,sCAAsC,EACtC,mCAAmC,EACpC,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AAOxE,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACzB,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,60 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * The `@interop/wallet-core/clientAnnex` subpath: the client annex -- the
6
+ * authoring and maintenance surface of everything anchored on a standing
7
+ * credential's ladder rather than on an enrolled durable client. One boundary
8
+ * rule holds throughout: this subpath imports from the base subpaths;
9
+ * nothing in the base imports from it (enforced in the lint pass, with one
10
+ * pinned exception -- `unlock/standingWebvh.ts` uses the shared ladder
11
+ * attribution helpers here, never the annex log machinery). The verify-side
12
+ * halves every wallet needs regardless of posture stay in the base: the
13
+ * resource-log ladder-append license and `ControllerPosture` ladder-key
14
+ * computation (`resourceLog`), `ladderVmIds` recognition (`webvh`), the
15
+ * unlock-record codec with its `ladder` and `delegatedClients` members
16
+ * (`unlock`), the standing-zcap staleness policy and the generalized log
17
+ * store seams (`webvh`), and the `GenerationCollect` activity builder
18
+ * (`space`).
19
+ *
20
+ * - The ladder (`ladder.ts`): rung and ladder-VM derivation from the record's
21
+ * random seed, and the shared attribution walks (`attributeLadderRung`,
22
+ * `attributeLadderPosture`) that recover the ladder's state from the
23
+ * published log itself.
24
+ * - The annex log (`log.ts`) and its GC (`gc.ts`): the disposable sidecar
25
+ * did:webvh of GC'd generations holding transient per-visit verification
26
+ * methods, the generation delegation, the account document's
27
+ * `#DelegatedClients` pointer, and the quarterly swap-and-collect.
28
+ * - ZCap signing as the ladder VM (`zcap.ts`): `ladderVmZcapClient` and the
29
+ * bootstrap `ladderVmAgent`.
30
+ * - The ladder-anchored account-log ceremonies (`ladderAnchored.ts`):
31
+ * ladder-anchored genesis, the self-enrolling continuation, the one-entry
32
+ * forget -- plus the composed flows around them (`selfEnroll.ts`,
33
+ * `forget.ts`), the credential-anchored account genesis
34
+ * (`credentialAnchoredGenesis.ts`), and the transient-recovery
35
+ * continuation (`recoveryLadderAnchored.ts`).
36
+ *
37
+ * The subsystem's decision records are the subpath's reading list:
38
+ * `decisions/0002` (annex log update authority is static rung 0),
39
+ * `decisions/0003` (generation identity and the ladder HKDF label family),
40
+ * `decisions/0005` (the `delegatedClients` sealed record member),
41
+ * `decisions/0006` (generation GC observables and the `GenerationCollect`
42
+ * digest), and `decisions/0007` (the reveal entry's hash order).
43
+ */
44
+ export { attributeLadderPosture, attributeLadderRung, clientAnnexRung, clientAnnexRungSeed, generateLadderSeed, LADDER_MAX_SCAN, LadderAttributionError, ladderRung, ladderRungSeed, ladderVmKeyMultibase, ladderVmSeed } from './ladder.js';
45
+ export { assertGenerationId, clampGrantExpires, CLIENT_ANNEX_SPACE_TYPE, clientAnnexDidParts, clientAnnexLogPinId, clientAnnexLogStore, ClientAnnexRungUncommittedError, commitClientAnnexRung, createClientAnnexLog, DELEGATED_CLIENTS_DELEGATION_ACTIONS, DELEGATED_CLIENTS_DELEGATION_TTL_MS, DELEGATED_CLIENTS_SERVICE_TYPE, delegatedClientsDelegationMinter, delegatedClientsDelegationSpaceId, delegatedClientsPointer, delegatedClientsServiceEntry, embeddedGenerationDelegation, enrollClientAnnexTransientClient, enrollTransientClient, ensureClientAnnexSpace, ensureGenerationDelegationCurrent, GENERATION_DELEGATION_ACTIONS, GENERATION_DELEGATION_SERVICE_TYPE, GENERATION_DELEGATION_TTL_MS, GENERATION_ID_PREFIX, generationDelegationHistory, generationDelegationServiceEntry, mintClientAnnexGeneration, mintCredentialClientAnnexGeneration, mintDelegatedClientsDelegation, mintGenerationDelegation, mintGenerationId, retireClientAnnexRung, revokeTreatingAlreadyRevokedAsSuccess, servicesPointedAtClientAnnex, setDelegatedClientsPointer } from './log.js';
46
+ export { clientAnnexGcDue, delegatedClientsPointerEstablishedAt, GENERATION_GC_PERIOD_MS, GENERATION_QUIET_BOUND_MS, GENERATION_QUIET_GRACE_MS, generationQuiet, runClientAnnexGc, swapClientAnnexGeneration } from './gc.js';
47
+ export { ladderVmAgent, ladderVmZcapClient } from './zcap.js';
48
+ export { createLadderAnchoredAccountLog, ensureLadderAnchoredDidWebvh, forgetLastWebvhClient, forgetWebvhClient, installLadderVmWebvh, LastDurableClientForgetError, selfEnrollWebvhClient } from './ladderAnchored.js';
49
+ export { selfEnrollClientCore } from './selfEnroll.js';
50
+ export { forgetDurableClient } from './forget.js';
51
+ export { forgetLastDurableClient } from './forgetLast.js';
52
+ export { ensureCredentialAnchoredAccountGenesis, mintCredentialAnchoredAccountKeySet } from './credentialAnchoredGenesis.js';
53
+ export { recoverWebvhLadderAnchored } from './recoveryLadderAnchored.js';
54
+ // The ladder VM's pure document builder and the ladder-anchored genesis log
55
+ // assembly stay defined in `webvh/didWebvh.ts` (the genesis document
56
+ // builder's two-armed clientKeys XOR ladderVm signature is base API, and the
57
+ // ladder arm calls `ladderVerificationMethod` internally), but this subpath
58
+ // is their public home.
59
+ export { createLadderAnchoredWebvhLog, ladderVerificationMethod } from '../webvh/didWebvh.js';
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/clientAnnex/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,YAAY,EACb,MAAM,aAAa,CAAA;AAOpB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,+BAA+B,EAC/B,qBAAqB,EACrB,oBAAoB,EACpB,oCAAoC,EACpC,mCAAmC,EACnC,8BAA8B,EAC9B,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,EACjC,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,EAC3B,gCAAgC,EAChC,yBAAyB,EACzB,mCAAmC,EACnC,8BAA8B,EAC9B,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,qCAAqC,EACrC,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,gBAAgB,EAChB,oCAAoC,EACpC,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE7D,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB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