@interop/wallet-core 0.44.0 → 0.46.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 (103) hide show
  1. package/dist/clients/revocation.d.ts +2 -25
  2. package/dist/clients/revocation.d.ts.map +1 -1
  3. package/dist/clients/revocation.js +25 -96
  4. package/dist/clients/revocation.js.map +1 -1
  5. package/dist/keyring/record.d.ts +4 -3
  6. package/dist/keyring/record.d.ts.map +1 -1
  7. package/dist/keyring/record.js.map +1 -1
  8. package/dist/keys/index.d.ts +7 -0
  9. package/dist/keys/index.d.ts.map +1 -1
  10. package/dist/keys/index.js +6 -0
  11. package/dist/keys/index.js.map +1 -1
  12. package/dist/keys/rosterLogStore.d.ts.map +1 -1
  13. package/dist/keys/rosterLogStore.js +18 -1
  14. package/dist/keys/rosterLogStore.js.map +1 -1
  15. package/dist/keys/userKeyRosterCascade.d.ts +121 -0
  16. package/dist/keys/userKeyRosterCascade.d.ts.map +1 -0
  17. package/dist/keys/userKeyRosterCascade.js +125 -0
  18. package/dist/keys/userKeyRosterCascade.js.map +1 -0
  19. package/dist/recovery/index.d.ts +1 -1
  20. package/dist/recovery/index.d.ts.map +1 -1
  21. package/dist/recovery/index.js +1 -1
  22. package/dist/recovery/index.js.map +1 -1
  23. package/dist/recovery/recoveryDelegation.d.ts +27 -40
  24. package/dist/recovery/recoveryDelegation.d.ts.map +1 -1
  25. package/dist/recovery/recoveryDelegation.js +119 -53
  26. package/dist/recovery/recoveryDelegation.js.map +1 -1
  27. package/dist/recovery/recoveryWebvh.d.ts +9 -2
  28. package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
  29. package/dist/recovery/recoveryWebvh.js +4 -2
  30. package/dist/recovery/recoveryWebvh.js.map +1 -1
  31. package/dist/resourceLog/controller.d.ts +38 -3
  32. package/dist/resourceLog/controller.d.ts.map +1 -1
  33. package/dist/resourceLog/controller.js +106 -10
  34. package/dist/resourceLog/controller.js.map +1 -1
  35. package/dist/resourceLog/errors.d.ts +22 -1
  36. package/dist/resourceLog/errors.d.ts.map +1 -1
  37. package/dist/resourceLog/errors.js +23 -1
  38. package/dist/resourceLog/errors.js.map +1 -1
  39. package/dist/resourceLog/index.d.ts +8 -6
  40. package/dist/resourceLog/index.d.ts.map +1 -1
  41. package/dist/resourceLog/index.js +7 -5
  42. package/dist/resourceLog/index.js.map +1 -1
  43. package/dist/resourceLog/license.d.ts +44 -0
  44. package/dist/resourceLog/license.d.ts.map +1 -0
  45. package/dist/resourceLog/license.js +63 -0
  46. package/dist/resourceLog/license.js.map +1 -0
  47. package/dist/resourceLog/verify.d.ts +3 -2
  48. package/dist/resourceLog/verify.d.ts.map +1 -1
  49. package/dist/resourceLog/verify.js +30 -8
  50. package/dist/resourceLog/verify.js.map +1 -1
  51. package/dist/unlock/index.d.ts +22 -8
  52. package/dist/unlock/index.d.ts.map +1 -1
  53. package/dist/unlock/index.js +21 -8
  54. package/dist/unlock/index.js.map +1 -1
  55. package/dist/unlock/ladder.d.ts +76 -0
  56. package/dist/unlock/ladder.d.ts.map +1 -1
  57. package/dist/unlock/ladder.js +111 -1
  58. package/dist/unlock/ladder.js.map +1 -1
  59. package/dist/unlock/retire.d.ts +126 -0
  60. package/dist/unlock/retire.d.ts.map +1 -0
  61. package/dist/unlock/retire.js +83 -0
  62. package/dist/unlock/retire.js.map +1 -0
  63. package/dist/unlock/standingWebvh.d.ts +50 -3
  64. package/dist/unlock/standingWebvh.d.ts.map +1 -1
  65. package/dist/unlock/standingWebvh.js +78 -9
  66. package/dist/unlock/standingWebvh.js.map +1 -1
  67. package/dist/unlock/unlockRecord.d.ts +28 -8
  68. package/dist/unlock/unlockRecord.d.ts.map +1 -1
  69. package/dist/unlock/unlockRecord.js +93 -13
  70. package/dist/unlock/unlockRecord.js.map +1 -1
  71. package/dist/webvh/companion.d.ts +681 -0
  72. package/dist/webvh/companion.d.ts.map +1 -0
  73. package/dist/webvh/companion.js +1151 -0
  74. package/dist/webvh/companion.js.map +1 -0
  75. package/dist/webvh/delegatedLogStore.d.ts +67 -0
  76. package/dist/webvh/delegatedLogStore.d.ts.map +1 -0
  77. package/dist/webvh/delegatedLogStore.js +104 -0
  78. package/dist/webvh/delegatedLogStore.js.map +1 -0
  79. package/dist/webvh/didWebvh.d.ts +109 -5
  80. package/dist/webvh/didWebvh.d.ts.map +1 -1
  81. package/dist/webvh/didWebvh.js +186 -21
  82. package/dist/webvh/didWebvh.js.map +1 -1
  83. package/dist/webvh/index.d.ts +34 -5
  84. package/dist/webvh/index.d.ts.map +1 -1
  85. package/dist/webvh/index.js +31 -5
  86. package/dist/webvh/index.js.map +1 -1
  87. package/dist/webvh/listClients.d.ts +33 -0
  88. package/dist/webvh/listClients.d.ts.map +1 -1
  89. package/dist/webvh/listClients.js +27 -0
  90. package/dist/webvh/listClients.js.map +1 -1
  91. package/dist/webvh/standingZcap.d.ts +48 -0
  92. package/dist/webvh/standingZcap.d.ts.map +1 -0
  93. package/dist/webvh/standingZcap.js +54 -0
  94. package/dist/webvh/standingZcap.js.map +1 -0
  95. package/dist/webvh/wasIdStore.d.ts +36 -6
  96. package/dist/webvh/wasIdStore.d.ts.map +1 -1
  97. package/dist/webvh/wasIdStore.js +32 -13
  98. package/dist/webvh/wasIdStore.js.map +1 -1
  99. package/dist/webvh/zcap.d.ts +24 -0
  100. package/dist/webvh/zcap.d.ts.map +1 -1
  101. package/dist/webvh/zcap.js +42 -0
  102. package/dist/webvh/zcap.js.map +1 -1
  103. package/package.json +9 -9
@@ -0,0 +1,681 @@
1
+ import type { DIDDoc, DIDLog, ServiceEndpoint, Signer } from '@interop/did-method-webvh';
2
+ import type { IZcap } from '@interop/data-integrity-core';
3
+ import type { ZcapClient } from '@interop/ezcap';
4
+ import type { WasClient } from '@interop/was-client';
5
+ import type { ResourceLogPinStore } from '../resourceLog/pin.js';
6
+ import type { ClientWebvhUpdateKeys, WebvhIdStore } from './didWebvh.js';
7
+ import type { WebvhLogResourceStore } from './wasIdStore.js';
8
+ /**
9
+ * The Space Description `type` array of the auxiliary companion Space, set at
10
+ * creation (the server treats a Space's `type` as immutable afterwards).
11
+ * Wire-level and permanent: the server's inspector clause recognizes the
12
+ * `DelegatedClientsSpace` member, and user-data surfaces exclude auxiliary
13
+ * Spaces by it.
14
+ */
15
+ export declare const COMPANION_SPACE_TYPE: string[];
16
+ /**
17
+ * The literal prefix of every generation collection's name. Wire-level and
18
+ * permanent: orphan discovery is a plain prefix match over the auxiliary
19
+ * Space's collection listing, and the segment embeds in every companion DID
20
+ * string ever published.
21
+ */
22
+ export declare const GENERATION_SEGMENT_PREFIX = "gen-";
23
+ /**
24
+ * Mints a fresh generation segment -- the generation collection's name, e.g.
25
+ * `gen-Ux3v0kQf9aPmB2hZ`. Random rather than a counter on purpose: never-reuse
26
+ * is structural (nothing durable survives GC to carry a counter), at the same
27
+ * probabilistic order as every other random-id convention in the system.
28
+ *
29
+ * @returns {string}
30
+ */
31
+ export declare function mintGenerationSegment(): string;
32
+ /**
33
+ * Refuses anything that is not a well-formed generation segment. Run by every
34
+ * companion builder that takes a segment, so a malformed one is refused
35
+ * before it can reach a DID string, an HKDF label, or a collection id.
36
+ *
37
+ * @param segment {string}
38
+ */
39
+ export declare function assertGenerationSegment(segment: string): void;
40
+ /**
41
+ * The pin-slot key for one companion generation's log -- host-free like every
42
+ * pin-slot key, keyed by the auxiliary Space id and the generation segment.
43
+ * A transient session keeps this slot in an in-memory pin store (a durable
44
+ * pin is the wrong lifetime for a disposable log, and a transient session
45
+ * must not durably create the pin store on a read); a durable client's store
46
+ * clears companion slots when the generation is collected.
47
+ *
48
+ * @param options {object}
49
+ * @param options.spaceId {string} the auxiliary companion Space's id
50
+ * @param options.segment {string} the generation collection's name
51
+ * @returns {string}
52
+ */
53
+ export declare function companionLogPinId({ spaceId, segment }: {
54
+ spaceId: string;
55
+ segment: string;
56
+ }): string;
57
+ /**
58
+ * The WAS-backed store a companion generation's ceremonies read and publish
59
+ * through with controller-tier signing (an enrolled client). A transient
60
+ * session writes through the delegated store instead
61
+ * (`delegatedWebvhLogStore`, invoking the credential's sibling delegation);
62
+ * both carry the same CAS/ETag conditional-publish discipline.
63
+ *
64
+ * @param options {object}
65
+ * @param options.was {WasClient}
66
+ * @param options.spaceId {string} the auxiliary companion Space's id
67
+ * @param options.segment {string} the generation collection's name
68
+ * @returns {WebvhLogResourceStore}
69
+ */
70
+ export declare function companionLogStore({ was, spaceId, segment }: {
71
+ was: WasClient;
72
+ spaceId: string;
73
+ segment: string;
74
+ }): WebvhLogResourceStore;
75
+ /**
76
+ * Creates the one-entry companion generation log. The genesis parameters are
77
+ * the companion posture (see the module doc): prerotation on via the rung-0
78
+ * hash commitments, no witnesses, portability off (the library's default,
79
+ * stated explicitly in the emitted entry), and a bare document -- id and the
80
+ * DID core context, nothing else.
81
+ *
82
+ * The caller supplies the update authority: the minting credential's
83
+ * companion rung-0 key as the sole `updateKeys` member, `nextKeyHashes` as
84
+ * every standing credential's rung-0 hash (restated explicitly on every later
85
+ * entry, never inherited), and rung 0's signer. The minting key's own
86
+ * carry-over hash MUST be among the commitments -- every companion entry
87
+ * re-states `updateKeys` containing the revealed rung-0 keys, and the
88
+ * resolver checks the re-statement against the previous entry's commitments
89
+ * -- so a `nextKeyHashes` that omits it is refused here rather than
90
+ * publishing a generation no one can ever extend.
91
+ *
92
+ * @param options {object}
93
+ * @param options.wasServerUrl {string}
94
+ * @param options.spaceId {string} the auxiliary companion Space's id
95
+ * @param options.segment {string} the generation collection's name
96
+ * @param options.updateKeyPublicKeyMultibase {string} the minting
97
+ * credential's companion rung-0 key
98
+ * @param options.nextKeyHashes {string[]} every standing credential's
99
+ * rung-0 hash, the minting credential's included
100
+ * @param options.signer {Signer} the minting credential's rung-0 signer
101
+ * @returns {Promise<{ log: DIDLog; did: string; doc: DIDDoc }>}
102
+ */
103
+ export declare function createCompanionLog({ wasServerUrl, spaceId, segment, updateKeyPublicKeyMultibase, nextKeyHashes, signer }: {
104
+ wasServerUrl: string;
105
+ spaceId: string;
106
+ segment: string;
107
+ updateKeyPublicKeyMultibase: string;
108
+ nextKeyHashes: string[];
109
+ signer: Signer;
110
+ }): Promise<{
111
+ log: DIDLog;
112
+ did: string;
113
+ doc: DIDDoc;
114
+ }>;
115
+ /**
116
+ * Ensures the auxiliary companion Space exists: created with the typed
117
+ * Description ({@link COMPANION_SPACE_TYPE}) under the given controller when
118
+ * absent, verified when present. The `type` array must ride the create -- the
119
+ * server accepts it at creation only and treats it as immutable afterwards --
120
+ * which is also why an existing Space at this id that is NOT typed as the
121
+ * delegated-clients Space is refused loudly: it can never become one.
122
+ *
123
+ * The Space id is minted by the caller at credential bind time with the
124
+ * account Space's `mintSpaceId` convention (32 random bytes, base64url
125
+ * no-pad): the sibling delegation's `invocationTarget` embeds the id and is
126
+ * sealed into the unlock record before the account DID exists, so no
127
+ * derivation over the account identity is possible -- and hash-derived
128
+ * addressing would import the unlock Spaces' existence-oracle posture,
129
+ * unwanted here.
130
+ *
131
+ * @param options {object}
132
+ * @param options.was {WasClient}
133
+ * @param options.spaceId {string} the auxiliary companion Space's id
134
+ * @param options.controller {string} the Space controller (the account
135
+ * did:webvh where it exists; a bootstrap did:key on a client-less signup,
136
+ * promoted the same way the account Space's controller is)
137
+ * @returns {Promise<void>}
138
+ */
139
+ export declare function ensureCompanionSpace({ was, spaceId, controller }: {
140
+ was: WasClient;
141
+ spaceId: string;
142
+ controller: string;
143
+ }): Promise<void>;
144
+ /**
145
+ * Mints a fresh companion generation with controller-tier signing: ensures
146
+ * the typed auxiliary Space, mints a fresh random segment, creates the
147
+ * generation collection, and publishes the genesis `did.jsonl` as a
148
+ * create-if-absent -- the same conditional-publish discipline as every log
149
+ * write, though a fresh random segment makes a create collision negligible.
150
+ *
151
+ * The account document's `#DelegatedClients` service entry is deliberately
152
+ * NOT written here: the companion log publishes first, and the caller
153
+ * re-points the account document at the returned DID afterwards. A run torn
154
+ * between the two leaves an unpointed generation -- authorization-inert (no
155
+ * delegation names it), collected by the standing `gen-` prefix orphan
156
+ * discovery at the next durable login.
157
+ *
158
+ * A re-run after a tear mints a FRESH generation rather than resuming: the
159
+ * genesis entry is timestamped, so a re-created log has a different SCID and
160
+ * a resume could never land its create-if-absent PUT; the torn generation is
161
+ * an inert orphan like any other.
162
+ *
163
+ * @param options {object}
164
+ * @param options.was {WasClient} the storage client, signing as an enrolled
165
+ * client (or the bootstrap controller on a client-less signup)
166
+ * @param options.wasServerUrl {string}
167
+ * @param options.spaceId {string} the auxiliary companion Space's id
168
+ * @param options.controller {string} the auxiliary Space's controller, used
169
+ * only when the Space does not exist yet
170
+ * @param options.updateKeyPublicKeyMultibase {string} the minting
171
+ * credential's companion rung-0 key
172
+ * @param options.nextKeyHashes {string[]} every standing credential's
173
+ * rung-0 hash, the minting credential's included
174
+ * @param options.signer {Signer} the minting credential's rung-0 signer
175
+ * @returns {Promise<{ did: string; segment: string; log: DIDLog;
176
+ * doc: DIDDoc }>}
177
+ */
178
+ export declare function mintCompanionGeneration({ was, wasServerUrl, spaceId, controller, updateKeyPublicKeyMultibase, nextKeyHashes, signer }: {
179
+ was: WasClient;
180
+ wasServerUrl: string;
181
+ spaceId: string;
182
+ controller: string;
183
+ updateKeyPublicKeyMultibase: string;
184
+ nextKeyHashes: string[];
185
+ signer: Signer;
186
+ }): Promise<{
187
+ did: string;
188
+ segment: string;
189
+ log: DIDLog;
190
+ doc: DIDDoc;
191
+ }>;
192
+ /**
193
+ * The type IRI of the account document's delegated-clients service entry --
194
+ * the pointer at the current companion generation's DID. Wire-level and
195
+ * permanent: readers (this module's {@link delegatedClientsPointer}, the
196
+ * server's companion-chain inspector clause) dispatch on this IRI, never on
197
+ * the entry's fragment id, which is non-semantic by convention.
198
+ */
199
+ export declare const DELEGATED_CLIENTS_SERVICE_TYPE = "https://w3id.org/byoe#DelegatedClients";
200
+ /**
201
+ * Builds a fresh delegated-clients service entry for the account document.
202
+ * The `serviceEndpoint` is the companion DID STRING, deliberately not a URL:
203
+ * the DID is self-certifying and host-independent, and the account pointer
204
+ * already carries the host.
205
+ *
206
+ * @param options {object}
207
+ * @param options.accountDid {string} the account did:webvh
208
+ * @param options.companionDid {string} the current generation's companion
209
+ * DID
210
+ * @returns {ServiceEndpoint}
211
+ */
212
+ export declare function delegatedClientsServiceEntry({ accountDid, companionDid }: {
213
+ accountDid: string;
214
+ companionDid: string;
215
+ }): ServiceEndpoint;
216
+ /**
217
+ * The companion DID the account document currently points at: the
218
+ * `serviceEndpoint` of the service entry whose `type` names (or includes)
219
+ * {@link DELEGATED_CLIENTS_SERVICE_TYPE}. Only a bare DID-string endpoint
220
+ * counts -- the same predicate the server's inspector clause evaluates, so
221
+ * wallet and server can never disagree on which generation is pointed.
222
+ *
223
+ * @param options {object}
224
+ * @param options.doc {DIDDoc} the resolved (and verified) account document
225
+ * @returns {string | undefined}
226
+ */
227
+ export declare function delegatedClientsPointer({ doc }: {
228
+ doc: DIDDoc;
229
+ }): string | undefined;
230
+ /**
231
+ * The unlock-record sibling delegation's `allowedAction` set: GET beside PUT,
232
+ * so an enrolling transient client can read the companion head it appends to.
233
+ * Wire-level and permanent (wallet-core decision 0005): the server's
234
+ * inspector clause admits a delegated-clients delegation with `allowedAction`
235
+ * a subset of exactly this pair.
236
+ */
237
+ export declare const DELEGATED_CLIENTS_DELEGATION_ACTIONS: string[];
238
+ /**
239
+ * The sibling delegation's lifetime: the house standing-zcap value (one
240
+ * year; see `standingZcap.ts`). It rots on exactly the account bridge's axis
241
+ * -- same signer, same current-key-set rule, same renewal window -- so the
242
+ * re-mint pass that refreshes the bridge refreshes it too.
243
+ */
244
+ export declare const DELEGATED_CLIENTS_DELEGATION_TTL_MS: number;
245
+ /**
246
+ * Mints one delegated-clients (companion-Space) delegation: the pre-minted
247
+ * zcap sealed into a standing credential's unlock record beside the account
248
+ * bridge, which is what lets a transient login reach the companion log with
249
+ * nothing but the credential. The shape is a permanent wire artifact
250
+ * (wallet-core decision 0005):
251
+ *
252
+ * - `invocationTarget` is the AUXILIARY companion Space's items subtree --
253
+ * the Space URL with a trailing slash, built with was-client's paths
254
+ * helpers so the bytes match the server's target check on a sub-path
255
+ * deployment. Generation coverage comes from segment-bounded attenuation
256
+ * over the flat `gen-` collection names, so no GC cycle rewrites the
257
+ * record or the registry.
258
+ * - `controller` is the credential-derived signing DID (the same grantee
259
+ * the account bridge names).
260
+ * - `allowedActions` is {@link DELEGATED_CLIENTS_DELEGATION_ACTIONS}.
261
+ * - The chain is rooted directly in the auxiliary Space's root zcap.
262
+ * - `expires` is {@link DELEGATED_CLIENTS_DELEGATION_TTL_MS} out.
263
+ *
264
+ * @param options {object}
265
+ * @param options.zcapClient {ZcapClient} the delegating signer (an
266
+ * enrolled client's promoted signer, or the account ladder VM)
267
+ * @param options.wasServerUrl {string} the auxiliary Space's storage
268
+ * server (the account pointer's host)
269
+ * @param options.companionSpaceId {string} the auxiliary companion
270
+ * Space's id
271
+ * @param options.controller {string} the credential-derived signing DID
272
+ * @param [options.now] {number} epoch milliseconds, for tests
273
+ * @returns {Promise<IZcap>}
274
+ */
275
+ export declare function mintDelegatedClientsDelegation({ zcapClient, wasServerUrl, companionSpaceId, controller, now }: {
276
+ zcapClient: ZcapClient;
277
+ wasServerUrl: string;
278
+ companionSpaceId: string;
279
+ controller: string;
280
+ now?: number;
281
+ }): Promise<IZcap>;
282
+ /**
283
+ * The auxiliary companion Space id a delegated-clients delegation targets,
284
+ * read out of its `invocationTarget` (the items-subtree URL,
285
+ * `.../space/<companionSpaceId>/`). The id has no other home -- a transient
286
+ * login learns the Space from the delegation it unwraps, and a refresh pass
287
+ * that holds the old delegation rebuilds the target from it -- so this parse
288
+ * is the one reader. Returns `undefined` on anything that is not an
289
+ * items-subtree Space URL.
290
+ *
291
+ * @param options {object}
292
+ * @param options.delegation {IZcap} a delegated-clients delegation
293
+ * @returns {string | undefined}
294
+ */
295
+ export declare function delegatedClientsDelegationSpaceId({ delegation }: {
296
+ delegation: IZcap;
297
+ }): string | undefined;
298
+ /**
299
+ * The type IRI of the companion document's generation-delegation service
300
+ * entry -- the generation's standing Space-scoped zcap, embedded where an
301
+ * enrolling transient client can reach it before it holds any other
302
+ * authority. Wire-level and permanent: readers (this module's
303
+ * {@link embeddedGenerationDelegation}, the app-side loader) dispatch on this
304
+ * IRI, never on the entry's fragment id, which is non-semantic by the byoe
305
+ * service-entry convention.
306
+ */
307
+ export declare const GENERATION_DELEGATION_SERVICE_TYPE = "https://w3id.org/byoe#GenerationDelegation";
308
+ /**
309
+ * The generation delegation's `allowedAction` set: the full closed WAS
310
+ * action vocabulary. Wire-level and permanent (the app-connect-spec
311
+ * generation-delegation record): attenuation is structural, not enumerated
312
+ * -- child-within-parent is enforced on both actions and targets, so any
313
+ * verb missing here would cap every transient-visit App Connect grant below
314
+ * its durable-client shape. What stays outside the delegation is carried by
315
+ * the TARGET instead: the items subtree excludes the bare Space URL, and
316
+ * with it the Space Description PUT (a controller rewrite) and the Space
317
+ * DELETE.
318
+ */
319
+ export declare const GENERATION_DELEGATION_ACTIONS: string[];
320
+ /**
321
+ * The generation delegation's lifetime: the house standing-zcap value (one
322
+ * year; see `standingZcap.ts`). GC's explicit revoke is the intended
323
+ * end-of-life; expiry is the backstop, deliberately not matched to the
324
+ * quarterly GC cadence -- a 90-day-class TTL would begin renewal churn
325
+ * exactly when GC is merely due.
326
+ */
327
+ export declare const GENERATION_DELEGATION_TTL_MS: number;
328
+ /**
329
+ * Mints one generation delegation: the standing Space-scoped zcap a
330
+ * generation's transient clients invoke under. The shape is a permanent wire
331
+ * artifact (the app-connect-spec generation-delegation record):
332
+ *
333
+ * - `invocationTarget` is the ACCOUNT Space's items subtree -- the Space URL
334
+ * with a trailing slash, built with was-client's paths helpers so the
335
+ * bytes match the server's target check on a sub-path deployment. The
336
+ * bare Space URL sits outside the capability bytes (see
337
+ * {@link GENERATION_DELEGATION_ACTIONS} for what that excludes).
338
+ * - `controller` is the bare companion DID string. Transient keys invoke as
339
+ * `<companionDid>#<vm>`, and the server's inspector clause compares this
340
+ * string against the account document's delegated-clients pointer.
341
+ * - The chain is rooted directly in the account Space's root zcap, so an
342
+ * App Connect grant delegated under it forms the depth-3 chain
343
+ * `[root id string, this delegation embedded]`.
344
+ * - `expires` is {@link GENERATION_DELEGATION_TTL_MS} out.
345
+ *
346
+ * The delegation signer is the caller's choice of licensed authority: the
347
+ * account ladder VM (`ladderVmZcapClient`) or an enrolled durable client's
348
+ * promoted signer (`webvhZcapClient`).
349
+ *
350
+ * @param options {object}
351
+ * @param options.zcapClient {ZcapClient} the delegating signer (ladder VM
352
+ * or a durable client's promoted signer)
353
+ * @param options.wasServerUrl {string} the ACCOUNT Space's storage server
354
+ * @param options.spaceId {string} the ACCOUNT Space's id
355
+ * @param options.companionDid {string} the generation's companion DID
356
+ * @param [options.now] {number} epoch milliseconds, for tests
357
+ * @returns {Promise<IZcap>}
358
+ */
359
+ export declare function mintGenerationDelegation({ zcapClient, wasServerUrl, spaceId, companionDid, now }: {
360
+ zcapClient: ZcapClient;
361
+ wasServerUrl: string;
362
+ spaceId: string;
363
+ companionDid: string;
364
+ now?: number;
365
+ }): Promise<IZcap>;
366
+ /**
367
+ * A child grant's `expires` under the generation delegation: the requested
368
+ * TTL, clamped to the delegation's own expiry -- the library's per-hop
369
+ * monotonicity rule IS the TTL clamp, so a grant minted past the parent's
370
+ * `expires` would verify nowhere. By construction the bounded grants (30-day
371
+ * read, 7-day write) always receive their full TTL; only 365-day-class
372
+ * grants ever meet the clamp, at 30 or more days remaining (the
373
+ * renew-precedes-mint stage keeps the delegation outside its renewal window
374
+ * whenever a grant is minted).
375
+ *
376
+ * @param options {object}
377
+ * @param options.ttlMs {number} the grant's requested TTL
378
+ * @param options.delegation {IZcap} the generation delegation
379
+ * @param [options.now] {number} epoch milliseconds, for tests
380
+ * @returns {Date}
381
+ */
382
+ export declare function clampGrantExpires({ ttlMs, delegation, now }: {
383
+ ttlMs: number;
384
+ delegation: IZcap;
385
+ now?: number;
386
+ }): Date;
387
+ /**
388
+ * Builds a fresh generation-delegation service entry for a companion
389
+ * document. The `serviceEndpoint` is the full delegated-zcap JSON as a
390
+ * single map, byte-identical to what `zcapClient.delegate` produced -- the
391
+ * companion entry proof (JCS canonicalization) then covers it byte for byte,
392
+ * so host tampering with the stored delegation is client-visible.
393
+ *
394
+ * @param options {object}
395
+ * @param options.companionDid {string} the generation's companion DID
396
+ * @param options.delegation {IZcap} the minted generation delegation
397
+ * @returns {ServiceEndpoint}
398
+ */
399
+ export declare function generationDelegationServiceEntry({ companionDid, delegation }: {
400
+ companionDid: string;
401
+ delegation: IZcap;
402
+ }): ServiceEndpoint;
403
+ /**
404
+ * The generation delegation a companion document carries: the
405
+ * `serviceEndpoint` map of the service entry whose `type` names (or
406
+ * includes) {@link GENERATION_DELEGATION_SERVICE_TYPE}. Only a map-form
407
+ * endpoint counts (the delegation is embedded as the zcap JSON itself,
408
+ * never as a URL or an encoded string).
409
+ *
410
+ * @param options {object}
411
+ * @param options.doc {DIDDoc} the resolved (and verified) companion
412
+ * document
413
+ * @returns {IZcap | undefined}
414
+ */
415
+ export declare function embeddedGenerationDelegation({ doc }: {
416
+ doc: DIDDoc;
417
+ }): IZcap | undefined;
418
+ /**
419
+ * Parses the auxiliary Space id and generation segment out of a companion DID
420
+ * string. Both are permanent substrings of every companion DID by
421
+ * construction (`did:webvh:<scid>:<host>:...:space:<spaceId>:<segment>`), and
422
+ * the segment is the generation-identifying half of the companion rung HKDF
423
+ * labels, so this parse is what lets an enrollee derive its writing key from
424
+ * the pointer alone -- no log read, no registry.
425
+ *
426
+ * @param options {object}
427
+ * @param options.did {string} a companion did:webvh string
428
+ * @returns {{ spaceId: string, segment: string }}
429
+ */
430
+ export declare function companionDidParts({ did }: {
431
+ did: string;
432
+ }): {
433
+ spaceId: string;
434
+ segment: string;
435
+ };
436
+ /**
437
+ * Thrown when the published companion log commits neither the writing
438
+ * credential's rung-0 key nor its hash -- the mid-generation lockout: a
439
+ * credential bound after the generation's genesis cannot write the companion
440
+ * until an existing writer commits its rung-0 hash or the next GC swap's
441
+ * genesis does. Typed so callers can map it to the fresh-generation path
442
+ * where one is licensed (the transient-recovery continuation) or to honest
443
+ * copy where none is.
444
+ */
445
+ export declare class CompanionRungUncommittedError extends Error {
446
+ constructor(message: string);
447
+ }
448
+ /**
449
+ * The narrow store seam a companion entry is read and published through: the
450
+ * log read and the conditional `did.jsonl` PUT, nothing else (a companion has
451
+ * no `did.json` projection and no key map). Satisfied by
452
+ * {@link companionLogStore} (controller-tier signing) and by the delegated
453
+ * store a transient session writes through (`delegatedWebvhLogStore`,
454
+ * invoking the credential's sibling delegation).
455
+ */
456
+ export type CompanionWriteStore = Pick<WebvhIdStore, 'getIdResourceRaw' | 'putIdResource'>;
457
+ /**
458
+ * TRANSIENT ENROLLMENT: publishes one per-visit verification method into a
459
+ * companion generation's log -- one atomic entry, signed by the writing
460
+ * credential's static rung 0 (derived from the ladder seed and the segment;
461
+ * see `companionRung`). The entry:
462
+ *
463
+ * - reveals the writer's rung-0 key into `updateKeys` at its first companion
464
+ * write (later writes re-state it unchanged);
465
+ * - re-states `nextKeyHashes` verbatim -- every standing credential's rung-0
466
+ * hash, the writer's own carry-over hash included -- explicitly on the
467
+ * entry, never inherited from the prior entry's parameters;
468
+ * - adds the transient VM under `capabilityInvocation` ONLY, with all five
469
+ * relationship arrays stated explicitly (no `authentication`, no
470
+ * `assertionMethod`, no `keyAgreement` twin -- the DIDAuth path signs as
471
+ * the bare did:key, and the controller-marker convention does not arise in
472
+ * the companion at all).
473
+ *
474
+ * The transient key set carries no update key, and nothing here touches the
475
+ * ACCOUNT log's `updateKeys` or `nextKeyHashes`. There is no two-entry
476
+ * reveal/add split and no attribution scan: a CAS loser re-signs with the
477
+ * SAME key via the ordinary conflict retry, and resumability reduces to the
478
+ * published document's own state -- a VM already present is a no-op.
479
+ *
480
+ * A writer whose rung-0 key is neither revealed nor committed is refused
481
+ * ({@link CompanionRungUncommittedError}): companion entries verify against
482
+ * the log's own hash-commitment chain, so no admission rule can make an
483
+ * uncommitted key verify mid-log.
484
+ *
485
+ * @param options {object}
486
+ * @param options.store {CompanionWriteStore} the generation's log store
487
+ * (delegated through the credential's sibling delegation, or
488
+ * controller-tier)
489
+ * @param options.ladderSeed {Uint8Array} the credential's ladder seed, from
490
+ * its unlock record
491
+ * @param options.segment {string} the generation collection's name
492
+ * @param options.transientKeyMultibase {string} the visit's in-memory
493
+ * Ed25519 signing key, public multibase
494
+ * @param [options.services] {ServiceEndpoint[]} the companion document's
495
+ * full service-entry list, replacing the published one wholesale; omitted,
496
+ * the prior entries are preserved verbatim (or extended by
497
+ * `mintGenerationDelegation` below). Supplying both is refused in favor of
498
+ * the explicit list
499
+ * @param [options.mintGenerationDelegation] {Function}
500
+ * `({ companionDid }) => Promise<IZcap>` -- mints the generation
501
+ * delegation this entry installs when it publishes the generation's FIRST
502
+ * transient verification method (and the document carries no delegation
503
+ * entry yet). Never invoked otherwise: the delegation is installed with
504
+ * the first transient VM or by the GC ceremony's own install stage, never
505
+ * by genesis (a genesis-embedded signed zcap can never verify -- its
506
+ * `controller` embeds the SCID the genesis hash derives from)
507
+ * @param [options.expectedDid] {string} the companion DID the log must
508
+ * resolve to, from the account document's pointer
509
+ * @param [options.pinStore] {ResourceLogPinStore} chain-head pins (a
510
+ * transient session passes an in-memory store)
511
+ * @param [options.logId] {string} the generation's pin-slot key, from
512
+ * {@link companionLogPinId}; required whenever a `pinStore` is supplied
513
+ * @returns {Promise<{ did: string, doc: DIDDoc, log: DIDLog }>}
514
+ */
515
+ export declare function enrollCompanionTransientClient(options: {
516
+ store: CompanionWriteStore;
517
+ ladderSeed: Uint8Array;
518
+ segment: string;
519
+ transientKeyMultibase: string;
520
+ services?: ServiceEndpoint[];
521
+ mintGenerationDelegation?: (options: {
522
+ companionDid: string;
523
+ }) => Promise<IZcap>;
524
+ expectedDid?: string;
525
+ pinStore?: ResourceLogPinStore;
526
+ logId?: string;
527
+ }): Promise<{
528
+ did: string;
529
+ doc: DIDDoc;
530
+ log: DIDLog;
531
+ }>;
532
+ /**
533
+ * Points the account document's delegated-clients service entry at a
534
+ * companion DID -- the first install after a generation's genesis, and the GC
535
+ * swap's re-point alike. One ordinary document-update entry, signed by an
536
+ * enrolled durable client's active update key; the companion log always
537
+ * publishes FIRST (see {@link mintCompanionGeneration}), so a tear leaves an
538
+ * unpointed, authorization-inert generation, never a dangling pointer.
539
+ *
540
+ * An existing delegated-clients entry is re-pointed in place, its fragment id
541
+ * preserved verbatim (the id is non-semantic and stable); absent one, a fresh
542
+ * entry is appended ({@link delegatedClientsServiceEntry}). Every other
543
+ * service entry, the verification methods, and the relationship arrays are
544
+ * preserved untouched. Idempotent: a document already pointing at the DID is
545
+ * a no-op on the log (it still heals a lagging `did.json`).
546
+ *
547
+ * @param options {object}
548
+ * @param options.idStore {WebvhIdStore} the ACCOUNT log's store
549
+ * @param options.updateKeys {ClientWebvhUpdateKeys} this durable client's
550
+ * update-key seeds
551
+ * @param options.companionDid {string} the generation to point at
552
+ * @param [options.expectedDid] {string} the account DID the log must
553
+ * resolve to, from the account pointer
554
+ * @param [options.pinStore] {ResourceLogPinStore} this client's chain-head
555
+ * pins for the account log
556
+ * @param [options.logId] {string} the account log's pin-slot key, from
557
+ * `accountLogPinId({ spaceId })`; required whenever a `pinStore` is
558
+ * supplied
559
+ * @returns {Promise<{ did: string, doc: DIDDoc }>}
560
+ */
561
+ export declare function setDelegatedClientsPointer(options: {
562
+ idStore: WebvhIdStore;
563
+ updateKeys: ClientWebvhUpdateKeys;
564
+ companionDid: string;
565
+ expectedDid?: string;
566
+ pinStore?: ResourceLogPinStore;
567
+ logId?: string;
568
+ }): Promise<{
569
+ did: string;
570
+ doc: DIDDoc;
571
+ }>;
572
+ /**
573
+ * The whole transient-enrollment ceremony as the enrollee runs it: resolve
574
+ * the account document's delegated-clients pointer, enroll the visit's key
575
+ * into the pointed generation, then RE-READ the pointer -- the GC-race
576
+ * closure. An enrollment landing between a GC pass's guard check and its
577
+ * re-point would otherwise yield a session whose generation the pointer then
578
+ * abandons and whose delegation is already revoked; the enrollee closes the
579
+ * race with one extra read, re-enrolling into the fresh generation on a
580
+ * mismatch. Convergent under retry (each round enrolls into whatever the
581
+ * pointer names NOW), and idempotent per generation like the entry itself.
582
+ *
583
+ * @param options {object}
584
+ * @param options.readAccountDocument {Function} reads the VERIFIED account
585
+ * document (the caller's `verifyAccountLog` read, pins and `expectedDid`
586
+ * applied there); called once per round
587
+ * @param options.storeForSegment {Function} builds the generation's log
588
+ * store for a segment (the delegated store over the credential's sibling
589
+ * delegation, or a controller-tier store)
590
+ * @param options.ladderSeed {Uint8Array} the credential's ladder seed
591
+ * @param options.transientKeyMultibase {string} the visit's in-memory
592
+ * signing key, public multibase
593
+ * @param [options.mintGenerationDelegation] {Function}
594
+ * `({ companionDid }) => Promise<IZcap>` -- forwarded to the enrollment
595
+ * entry, which installs the minted delegation when it publishes the
596
+ * generation's first transient VM (see
597
+ * {@link enrollCompanionTransientClient}). The closure receives whichever
598
+ * companion DID the round enrolls into, so a GC-race re-enroll mints for
599
+ * the fresh generation
600
+ * @param [options.pinStore] {ResourceLogPinStore} chain-head pins for the
601
+ * generation logs (a transient session passes an in-memory store); slot
602
+ * keys are derived per generation with {@link companionLogPinId}
603
+ * @param [options.maxRounds] {number} how many pointer moves to chase
604
+ * before giving up (a GC pass is quarterly, so more than one mid-ceremony
605
+ * move means something else is wrong)
606
+ * @returns {Promise<{ companionDid: string, doc: DIDDoc, log: DIDLog }>}
607
+ */
608
+ export declare function enrollTransientClient({ readAccountDocument, storeForSegment, ladderSeed, transientKeyMultibase, mintGenerationDelegation: mintDelegation, pinStore, maxRounds }: {
609
+ readAccountDocument: () => Promise<DIDDoc>;
610
+ storeForSegment: (segment: string) => CompanionWriteStore;
611
+ ladderSeed: Uint8Array;
612
+ transientKeyMultibase: string;
613
+ mintGenerationDelegation?: (options: {
614
+ companionDid: string;
615
+ }) => Promise<IZcap>;
616
+ pinStore?: ResourceLogPinStore;
617
+ maxRounds?: number;
618
+ }): Promise<{
619
+ companionDid: string;
620
+ doc: DIDDoc;
621
+ log: DIDLog;
622
+ }>;
623
+ /**
624
+ * RENEW PRECEDES MINT: the blocking pre-mint stage a transient App Connect
625
+ * approval runs before delegating any grant. Reads the companion document
626
+ * and hands back its embedded generation delegation -- renewing it first
627
+ * when it is expired or inside the 30-day renewal window ({@link
628
+ * zcapExpiring}): a fresh delegation is minted through the caller's closure
629
+ * (ladder-signed -- the renewal must not depend on the very delegation it
630
+ * replaces; published through the store, which in a transient session is
631
+ * the credential's sibling delegation, so even a hard-expired delegation is
632
+ * recoverable), and one companion entry replaces the service entry's
633
+ * endpoint in place, signed by the writing credential's static rung 0.
634
+ *
635
+ * A companion document carrying no delegation entry at all installs one the
636
+ * same way (the GC ceremony's own install stage and the first-VM install
637
+ * make this rare; a heal, not a policy).
638
+ *
639
+ * Failure is the caller's failure: a renewal that cannot complete throws,
640
+ * and the App Connect approval fails with the standard retryable-ceremony
641
+ * posture -- deliberately no clamp-on-failure fallback, which would deliver
642
+ * exactly the silently short grant this stage exists to prevent. By
643
+ * construction a grant minted behind a completed renewal never meets the
644
+ * monotonicity clamp below its full TTL except for 365-day-class grants at
645
+ * 30 or more days remaining ({@link clampGrantExpires}).
646
+ *
647
+ * @param options {object}
648
+ * @param options.store {CompanionWriteStore} the generation's log store
649
+ * (delegated through the credential's sibling delegation, or
650
+ * controller-tier)
651
+ * @param options.ladderSeed {Uint8Array} the credential's ladder seed, from
652
+ * its unlock record
653
+ * @param options.segment {string} the generation collection's name
654
+ * @param options.mintGenerationDelegation {Function}
655
+ * `({ companionDid }) => Promise<IZcap>` -- mints the replacement
656
+ * delegation (ladder-signed in a transient session)
657
+ * @param [options.expectedDid] {string} the companion DID the log must
658
+ * resolve to, from the account document's pointer
659
+ * @param [options.pinStore] {ResourceLogPinStore} chain-head pins (a
660
+ * transient session passes an in-memory store)
661
+ * @param [options.logId] {string} the generation's pin-slot key, from
662
+ * {@link companionLogPinId}; required whenever a `pinStore` is supplied
663
+ * @param [options.now] {number} epoch milliseconds, for tests
664
+ * @returns {Promise<{ delegation: IZcap, renewed: boolean }>}
665
+ */
666
+ export declare function ensureGenerationDelegationCurrent(options: {
667
+ store: CompanionWriteStore;
668
+ ladderSeed: Uint8Array;
669
+ segment: string;
670
+ mintGenerationDelegation: (options: {
671
+ companionDid: string;
672
+ }) => Promise<IZcap>;
673
+ expectedDid?: string;
674
+ pinStore?: ResourceLogPinStore;
675
+ logId?: string;
676
+ now?: number;
677
+ }): Promise<{
678
+ delegation: IZcap;
679
+ renewed: boolean;
680
+ }>;
681
+ //# sourceMappingURL=companion.d.ts.map