@interop/wallet-core 0.74.0 → 0.76.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.
- package/dist/clientAnnex/heal.d.ts +5 -1
- package/dist/clientAnnex/heal.d.ts.map +1 -1
- package/dist/clientAnnex/heal.js +26 -12
- package/dist/clientAnnex/heal.js.map +1 -1
- package/dist/clientAnnex/index.d.ts +5 -1
- package/dist/clientAnnex/index.d.ts.map +1 -1
- package/dist/clientAnnex/index.js +5 -1
- package/dist/clientAnnex/index.js.map +1 -1
- package/dist/clientAnnex/log.d.ts +62 -27
- package/dist/clientAnnex/log.d.ts.map +1 -1
- package/dist/clientAnnex/log.js +61 -32
- package/dist/clientAnnex/log.js.map +1 -1
- package/dist/clientAnnex/spaceCapability.d.ts +94 -17
- package/dist/clientAnnex/spaceCapability.d.ts.map +1 -1
- package/dist/clientAnnex/spaceCapability.js +146 -8
- package/dist/clientAnnex/spaceCapability.js.map +1 -1
- package/dist/keyring/fetch.d.ts +6 -1
- package/dist/keyring/fetch.d.ts.map +1 -1
- package/dist/keyring/fetch.js +5 -1
- package/dist/keyring/fetch.js.map +1 -1
- package/dist/keyring/unlockSpace.d.ts +44 -4
- package/dist/keyring/unlockSpace.d.ts.map +1 -1
- package/dist/keyring/unlockSpace.js +51 -27
- package/dist/keyring/unlockSpace.js.map +1 -1
- package/dist/keys/collectionLogStore.d.ts +6 -2
- package/dist/keys/collectionLogStore.d.ts.map +1 -1
- package/dist/keys/collectionLogStore.js +6 -2
- package/dist/keys/collectionLogStore.js.map +1 -1
- package/dist/keys/rosterStore.d.ts +6 -2
- package/dist/keys/rosterStore.d.ts.map +1 -1
- package/dist/keys/rosterStore.js +9 -2
- package/dist/keys/rosterStore.js.map +1 -1
- package/dist/space/deleteSpace.d.ts +28 -1
- package/dist/space/deleteSpace.d.ts.map +1 -1
- package/dist/space/deleteSpace.js +9 -2
- package/dist/space/deleteSpace.js.map +1 -1
- package/dist/space/provisioning.d.ts.map +1 -1
- package/dist/unlock/unlockRecord.d.ts +2 -2
- package/dist/unlock/unlockRecord.js +2 -2
- package/dist/webvh/delegatedLogStore.d.ts +6 -1
- package/dist/webvh/delegatedLogStore.d.ts.map +1 -1
- package/dist/webvh/delegatedLogStore.js +5 -2
- package/dist/webvh/delegatedLogStore.js.map +1 -1
- package/dist/webvh/didWebProjection.d.ts +2 -2
- package/dist/webvh/didWebProjection.js +1 -1
- package/package.json +7 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { rootCapabilityId, spacePath, toUrl } from '@interop/was-client/paths';
|
|
1
|
+
import { rootCapabilityId, spaceMeta, spacePath, toUrl } from '@interop/was-client/paths';
|
|
2
|
+
import { KEYRING_COLLECTION, KEYRING_RESOURCE } from '../space/collections.js';
|
|
2
3
|
/**
|
|
3
4
|
* The single-verb Space capability's lifetime: ten minutes, long enough for
|
|
4
5
|
* the request it is minted for and twice `@interop/zcap`'s 300-second clock
|
|
@@ -81,10 +82,83 @@ function assertParentAllows({ parent, verb }) {
|
|
|
81
82
|
`${actions.join(', ')} and not ${verb}; refusing to mint a child that ` +
|
|
82
83
|
'verifies nowhere.');
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Refuses a Resource path segment that is empty or contains `/`. The server
|
|
87
|
+
* matches a Resource target as three URL-safe segments exactly, so a segment
|
|
88
|
+
* carrying a `/` would name something else and an empty one names nothing.
|
|
89
|
+
*
|
|
90
|
+
* @param options {object}
|
|
91
|
+
* @param options.label {string} `collectionId` or `resourceId`, for the
|
|
92
|
+
* message
|
|
93
|
+
* @param options.value {string}
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
function assertResourceSegment({ label, value }) {
|
|
97
|
+
if (value.length === 0 || value.includes('/')) {
|
|
98
|
+
throw new Error(`single-verb Space capability: the resource's "${label}" ` +
|
|
99
|
+
`("${value}") must be non-empty and contain no "/"; refusing to ` +
|
|
100
|
+
'mint a child that verifies nowhere.');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The stored parent's target, narrowed to what the child's verb (and, on a
|
|
105
|
+
* `GET`, an optional `resource`) addresses. A `DELETE` names the Space
|
|
106
|
+
* container, which is the parent's target unchanged; `DELETE` admits no
|
|
107
|
+
* `resource` narrowing. A bare `GET` names the Space Metadata object one
|
|
108
|
+
* segment beneath it, since that is where a Space Description is served and
|
|
109
|
+
* what a storage server's probe predicate keys on. A `GET` given `resource`
|
|
110
|
+
* names that one Resource beneath the Space instead. All three are taken
|
|
111
|
+
* from the parent's own bytes rather than rebuilt from a server URL and a
|
|
112
|
+
* Space id, because this module holds neither and a rebuilt target would
|
|
113
|
+
* miss a sub-path deployment's prefix.
|
|
114
|
+
*
|
|
115
|
+
* Every case requires the parent to target a container URL in canonical
|
|
116
|
+
* form, carrying its trailing slash, and a parent that does not is refused
|
|
117
|
+
* here rather than minted from. A storage server's admission predicate
|
|
118
|
+
* matches the canonical form by exact bytes, so a child built on any other
|
|
119
|
+
* form of the same Space verifies nowhere: appending onto a sibling path
|
|
120
|
+
* names nothing, and copying that target verbatim names one no predicate
|
|
121
|
+
* admits. That refusal comes back as a masked 404, which is indistinguishable
|
|
122
|
+
* from a Space that is simply gone -- the same failure the expiry and
|
|
123
|
+
* action-set checks above exist to keep off the wire.
|
|
124
|
+
*
|
|
125
|
+
* @param options {object}
|
|
126
|
+
* @param options.parentTarget {string}
|
|
127
|
+
* @param options.verb {SpaceCapabilityVerb}
|
|
128
|
+
* @param [options.resource] {object} a single Resource beneath the Space,
|
|
129
|
+
* admitted only for `GET`
|
|
130
|
+
* @param options.resource.collectionId {string}
|
|
131
|
+
* @param options.resource.resourceId {string}
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
function childTarget({ parentTarget, verb, resource }) {
|
|
135
|
+
if (resource !== undefined && verb === 'DELETE') {
|
|
136
|
+
throw new Error('single-verb Space capability: a DELETE child admits no `resource`; ' +
|
|
137
|
+
'a Resource is not a target the DELETE shape addresses.');
|
|
138
|
+
}
|
|
139
|
+
if (!parentTarget.endsWith('/')) {
|
|
140
|
+
throw new Error('single-verb Space capability: the parent capability targets ' +
|
|
141
|
+
`"${parentTarget}", which is not a container URL in canonical form; ` +
|
|
142
|
+
'refusing to mint a child that verifies nowhere.');
|
|
143
|
+
}
|
|
144
|
+
if (resource !== undefined) {
|
|
145
|
+
assertResourceSegment({
|
|
146
|
+
label: 'collectionId',
|
|
147
|
+
value: resource.collectionId
|
|
148
|
+
});
|
|
149
|
+
assertResourceSegment({ label: 'resourceId', value: resource.resourceId });
|
|
150
|
+
return `${parentTarget}${resource.collectionId}/${resource.resourceId}`;
|
|
151
|
+
}
|
|
152
|
+
return verb === 'GET' ? `${parentTarget}meta` : parentTarget;
|
|
153
|
+
}
|
|
84
154
|
/**
|
|
85
155
|
* Mints a single-verb child of a STORED parent capability -- the three-link
|
|
86
156
|
* shape, used on an unlock Space whose management zcap the account already
|
|
87
|
-
* holds. The child's `invocationTarget` is
|
|
157
|
+
* holds. The child's `invocationTarget` is {@link childTarget}'s: the
|
|
158
|
+
* parent's unchanged for the deletion child, the Space Metadata object
|
|
159
|
+
* beneath it for a bare `GET`, or one Resource beneath the Space for a `GET`
|
|
160
|
+
* given `resource` -- e.g. a transient session reading an unlock Space's
|
|
161
|
+
* keyring record under the stored management zcap.
|
|
88
162
|
*
|
|
89
163
|
* @param options {object}
|
|
90
164
|
* @param options.zcapClient {ZcapClient} the delegating signer (the ladder
|
|
@@ -93,13 +167,17 @@ function assertParentAllows({ parent, verb }) {
|
|
|
93
167
|
* @param options.parent {IZcap} the stored parent capability
|
|
94
168
|
* @param options.verb {SpaceCapabilityVerb} the child's one allowed action
|
|
95
169
|
* @param options.controller {string} the delegatee DID
|
|
170
|
+
* @param [options.resource] {object} a single Resource beneath the Space,
|
|
171
|
+
* admitted only for `GET`
|
|
172
|
+
* @param options.resource.collectionId {string}
|
|
173
|
+
* @param options.resource.resourceId {string}
|
|
96
174
|
* @param [options.ttlMs] {number} the child's requested lifetime
|
|
97
175
|
* @param [options.now] {number} the clock the child is minted against
|
|
98
176
|
* (epoch milliseconds); a caller holding server-relative time passes it
|
|
99
177
|
* so the proof's `created` and the child's `expires` come off one clock
|
|
100
178
|
* @returns {Promise<IZcap>}
|
|
101
179
|
*/
|
|
102
|
-
export async function mintSpaceVerbCapability({ zcapClient, parent, verb, controller, ttlMs = DELETION_ZCAP_TTL_MS, now = Date.now() }) {
|
|
180
|
+
export async function mintSpaceVerbCapability({ zcapClient, parent, verb, controller, resource, ttlMs = DELETION_ZCAP_TTL_MS, now = Date.now() }) {
|
|
103
181
|
const invocationTarget = parent
|
|
104
182
|
.invocationTarget;
|
|
105
183
|
if (invocationTarget === undefined) {
|
|
@@ -109,19 +187,43 @@ export async function mintSpaceVerbCapability({ zcapClient, parent, verb, contro
|
|
|
109
187
|
assertParentAllows({ parent, verb });
|
|
110
188
|
return (await zcapClient.delegate({
|
|
111
189
|
capability: parent,
|
|
112
|
-
invocationTarget
|
|
190
|
+
invocationTarget: childTarget({
|
|
191
|
+
parentTarget: invocationTarget,
|
|
192
|
+
verb,
|
|
193
|
+
resource
|
|
194
|
+
}),
|
|
113
195
|
controller,
|
|
114
196
|
allowedActions: [verb],
|
|
115
197
|
expires: childExpires({ ttlMs, parent, now }),
|
|
116
198
|
now
|
|
117
199
|
}));
|
|
118
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* The target a single-verb Space capability names, by verb. `DELETE`
|
|
203
|
+
* addresses the Space container itself, which in canonical form carries a
|
|
204
|
+
* trailing slash; `GET` addresses the Space Metadata object at the Space's
|
|
205
|
+
* `meta` sub-resource, where the Space Description is served.
|
|
206
|
+
*
|
|
207
|
+
* @param options {object}
|
|
208
|
+
* @param options.storageServerUrl {string}
|
|
209
|
+
* @param options.spaceId {string}
|
|
210
|
+
* @param options.verb {SpaceCapabilityVerb}
|
|
211
|
+
* @returns {string}
|
|
212
|
+
*/
|
|
213
|
+
export function spaceVerbTarget({ storageServerUrl, spaceId, verb }) {
|
|
214
|
+
const path = verb === 'GET' ? spaceMeta(spaceId) : spacePath(spaceId);
|
|
215
|
+
return toUrl({ serverUrl: storageServerUrl, path });
|
|
216
|
+
}
|
|
119
217
|
/**
|
|
120
218
|
* Mints a single-verb child of a Space's SYNTHESIZED ROOT -- the two-link
|
|
121
219
|
* shape, used on the account Space and an auxiliary annex Space, where the
|
|
122
|
-
* session holds no stored parent. The
|
|
123
|
-
*
|
|
124
|
-
*
|
|
220
|
+
* session holds no stored parent. The chain roots in the Space's own root
|
|
221
|
+
* capability, and the child's `invocationTarget` is
|
|
222
|
+
* {@link spaceVerbTarget}'s: the canonical Space URL for the deletion child,
|
|
223
|
+
* the Space Metadata object for the probe child. The probe therefore narrows
|
|
224
|
+
* its root's target rather than restating it, and neither child can be read
|
|
225
|
+
* as the broad subtree grant the Space URL would otherwise be, because its
|
|
226
|
+
* action set is one verb.
|
|
125
227
|
*
|
|
126
228
|
* @param options {object}
|
|
127
229
|
* @param options.zcapClient {ZcapClient} the delegating signer
|
|
@@ -142,11 +244,47 @@ export async function mintSpaceRootVerbCapability({ zcapClient, storageServerUrl
|
|
|
142
244
|
});
|
|
143
245
|
return (await zcapClient.delegate({
|
|
144
246
|
capability: rootCapabilityId(spaceUrl),
|
|
145
|
-
invocationTarget:
|
|
247
|
+
invocationTarget: spaceVerbTarget({ storageServerUrl, spaceId, verb }),
|
|
146
248
|
controller,
|
|
147
249
|
allowedActions: [verb],
|
|
148
250
|
expires: childExpires({ ttlMs, now }),
|
|
149
251
|
now
|
|
150
252
|
}));
|
|
151
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Mints the GET-only child that reads an unlock Space's keyring record, over
|
|
256
|
+
* the stored management zcap the account holds for that Space -- what a
|
|
257
|
+
* wallet does when it reads a SIBLING unlock credential's record, having no
|
|
258
|
+
* root invocation over the Space.
|
|
259
|
+
*
|
|
260
|
+
* It exists so the capability's target and the URL `getUnlockKeyring`
|
|
261
|
+
* addresses come from the same two constants, `KEYRING_COLLECTION.id` and
|
|
262
|
+
* `KEYRING_RESOURCE`. The child then matches the request by construction,
|
|
263
|
+
* rather than by a caller restating the record's placement beside the read
|
|
264
|
+
* and having to agree with it. Both wallets run this read.
|
|
265
|
+
*
|
|
266
|
+
* @param options {object}
|
|
267
|
+
* @param options.zcapClient {ZcapClient} the delegating signer
|
|
268
|
+
* @param options.parent {IZcap} the stored management zcap for the unlock
|
|
269
|
+
* Space
|
|
270
|
+
* @param options.controller {string} the delegatee DID
|
|
271
|
+
* @param [options.ttlMs] {number} the child's requested lifetime
|
|
272
|
+
* @param [options.now] {number} the clock the child is minted against
|
|
273
|
+
* (epoch milliseconds)
|
|
274
|
+
* @returns {Promise<IZcap>}
|
|
275
|
+
*/
|
|
276
|
+
export async function mintUnlockKeyringReadCapability({ zcapClient, parent, controller, ttlMs = DELETION_ZCAP_TTL_MS, now = Date.now() }) {
|
|
277
|
+
return mintSpaceVerbCapability({
|
|
278
|
+
zcapClient,
|
|
279
|
+
parent,
|
|
280
|
+
verb: 'GET',
|
|
281
|
+
controller,
|
|
282
|
+
resource: {
|
|
283
|
+
collectionId: KEYRING_COLLECTION.id,
|
|
284
|
+
resourceId: KEYRING_RESOURCE
|
|
285
|
+
},
|
|
286
|
+
ttlMs,
|
|
287
|
+
now
|
|
288
|
+
});
|
|
289
|
+
}
|
|
152
290
|
//# sourceMappingURL=spaceCapability.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaceCapability.js","sourceRoot":"","sources":["../../src/clientAnnex/spaceCapability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spaceCapability.js","sourceRoot":"","sources":["../../src/clientAnnex/spaceCapability.ts"],"names":[],"mappings":"AAqDA,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,KAAK,EACN,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yB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IACC,OAAO,uBAAuB,CAAC;QAC7B,UAAU;QACV,MAAM;QACN,IAAI,EAAE,KAAK;QACX,UAAU;QACV,QAAQ,EAAE;YACR,YAAY,EAAE,kBAAkB,CAAC,EAAE;YACnC,UAAU,EAAE,gBAAgB;SAC7B;QACD,KAAK;QACL,GAAG;KACJ,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/keyring/fetch.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* wrap around this rather than living inside it, because those are per-app
|
|
11
11
|
* storage concerns with per-app durability rules.
|
|
12
12
|
*/
|
|
13
|
+
import type { ServiceDescription } from '@interop/was-client';
|
|
13
14
|
import type { UnlockKdf } from './kdf.js';
|
|
14
15
|
import type { KeyringRecordContents } from './record.js';
|
|
15
16
|
/**
|
|
@@ -27,12 +28,16 @@ import type { KeyringRecordContents } from './record.js';
|
|
|
27
28
|
* (`KEYRING_KDF` for a passphrase) and a method that omits it fails to
|
|
28
29
|
* compile instead of silently reading the passphrase-salted unlock Space.
|
|
29
30
|
* @param options.storageServerUrl {string} the WAS server origin
|
|
31
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
32
|
+
* service description a client the caller already holds discovered
|
|
33
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
30
34
|
* @returns {Promise<(KeyringRecordContents & { unlockSpaceId: string }) | null>}
|
|
31
35
|
*/
|
|
32
|
-
export declare function fetchKeyringRecord({ secret, kdf, storageServerUrl }: {
|
|
36
|
+
export declare function fetchKeyringRecord({ secret, kdf, storageServerUrl, serviceDescription }: {
|
|
33
37
|
secret: string | Uint8Array;
|
|
34
38
|
kdf: UnlockKdf;
|
|
35
39
|
storageServerUrl: string;
|
|
40
|
+
serviceDescription?: ServiceDescription;
|
|
36
41
|
}): Promise<(KeyringRecordContents & {
|
|
37
42
|
unlockSpaceId: string;
|
|
38
43
|
}) | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/keyring/fetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/keyring/fetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,kBAAkB,EACnB,EAAE;IACD,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B,GAAG,EAAE,SAAS,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;CACxC,GAAG,OAAO,CAAC,CAAC,qBAAqB,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,CAqBtE"}
|
package/dist/keyring/fetch.js
CHANGED
|
@@ -16,13 +16,17 @@ import { unwrapKeyringRecord } from './record.js';
|
|
|
16
16
|
* (`KEYRING_KDF` for a passphrase) and a method that omits it fails to
|
|
17
17
|
* compile instead of silently reading the passphrase-salted unlock Space.
|
|
18
18
|
* @param options.storageServerUrl {string} the WAS server origin
|
|
19
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
20
|
+
* service description a client the caller already holds discovered
|
|
21
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
19
22
|
* @returns {Promise<(KeyringRecordContents & { unlockSpaceId: string }) | null>}
|
|
20
23
|
*/
|
|
21
|
-
export async function fetchKeyringRecord({ secret, kdf, storageServerUrl }) {
|
|
24
|
+
export async function fetchKeyringRecord({ secret, kdf, storageServerUrl, serviceDescription }) {
|
|
22
25
|
const unlock = await deriveUnlockIdentity({ secret, kdf });
|
|
23
26
|
const record = await getUnlockKeyring({
|
|
24
27
|
storageServerUrl,
|
|
25
28
|
zcapClient: unlock.zcapClient,
|
|
29
|
+
serviceDescription,
|
|
26
30
|
spaceId: unlock.spaceId
|
|
27
31
|
});
|
|
28
32
|
if (record === null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/keyring/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/keyring/fetch.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,kBAAkB,EAMnB;IACC,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IAC1D,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC;QACpC,gBAAgB;QAChB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,kBAAkB;QAClB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CAAA;IACF,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC;QACzC,MAAM;QACN,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,qEAAqE;QACrE,uEAAuE;QACvE,iEAAiE;QACjE,oBAAoB,EAAE,MAAM,CAAC,YAAY,CAAC,YAAY;KACvD,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,CAAA;AACvD,CAAC"}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The unlock Space: a minimal second Space, controlled by an unlock identity
|
|
6
|
+
* and separate from the wallet data Space, holding the one keyring record.
|
|
7
|
+
* These are standalone functions rather than methods on a wallet's remote-store
|
|
8
|
+
* class (that store is bound to the data identity): each builds its own
|
|
9
|
+
* `WasClient` over the caller's `zcapClient`. By default that is the unlock
|
|
10
|
+
* agent's, whose invocation signer is the unlock root key (root invocation,
|
|
11
|
+
* no capability attached -- the same invocation shape the data Space uses).
|
|
12
|
+
* Each read/write/delete also takes an optional `capability`: an enrolled
|
|
13
|
+
* client's `zcapClient` then invokes the management zcap the unlock identity
|
|
14
|
+
* delegated at bind time, which is how a ceremony reaches an unlock Space
|
|
15
|
+
* without holding its secret (the revocation cascade's re-mint reading and
|
|
16
|
+
* re-PUTting a recovery code's standing record, or a lost unlock method's
|
|
17
|
+
* Space being retired).
|
|
18
|
+
*
|
|
19
|
+
* The one resource is a plaintext JSON document (its keyring payload is
|
|
20
|
+
* already ciphertext), so no encryption provider is wired in and every
|
|
21
|
+
* read/write handle is built by {@link plaintextCollection} -- load-bearing
|
|
22
|
+
* here for the absent Space a fresh unlock secret's keyring lookup meets.
|
|
23
|
+
*/
|
|
24
|
+
import { type ServiceDescription } from '@interop/was-client';
|
|
1
25
|
import type { IZcap } from '@interop/data-integrity-core';
|
|
2
26
|
import type { ZcapClient } from '@interop/ezcap';
|
|
3
27
|
/**
|
|
@@ -15,14 +39,18 @@ export declare const UNLOCK_SPACE_NAME = "Freewallet Keyring";
|
|
|
15
39
|
* @param options {object}
|
|
16
40
|
* @param options.storageServerUrl {string}
|
|
17
41
|
* @param options.zcapClient {ZcapClient}
|
|
42
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
43
|
+
* service description a client the caller already holds discovered
|
|
44
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
18
45
|
* @param options.spaceId {string} the unlock Space id
|
|
19
46
|
* @param options.controller {string} the unlock did:key
|
|
20
47
|
* @param [options.name] {string} the Space Description name
|
|
21
48
|
* @returns {Promise<void>}
|
|
22
49
|
*/
|
|
23
|
-
export declare function ensureUnlockSpace({ storageServerUrl, zcapClient, spaceId, controller, name }: {
|
|
50
|
+
export declare function ensureUnlockSpace({ storageServerUrl, zcapClient, serviceDescription, spaceId, controller, name }: {
|
|
24
51
|
storageServerUrl: string;
|
|
25
52
|
zcapClient: ZcapClient;
|
|
53
|
+
serviceDescription?: ServiceDescription;
|
|
26
54
|
spaceId: string;
|
|
27
55
|
controller: string;
|
|
28
56
|
name?: string;
|
|
@@ -43,14 +71,18 @@ export declare function ensureUnlockSpace({ storageServerUrl, zcapClient, spaceI
|
|
|
43
71
|
* @param options {object}
|
|
44
72
|
* @param options.storageServerUrl {string}
|
|
45
73
|
* @param options.zcapClient {ZcapClient}
|
|
74
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
75
|
+
* service description a client the caller already holds discovered
|
|
76
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
46
77
|
* @param options.spaceId {string} the unlock Space id
|
|
47
78
|
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
48
79
|
* absent, the read is a root invocation
|
|
49
80
|
* @returns {Promise<unknown | null>}
|
|
50
81
|
*/
|
|
51
|
-
export declare function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId, capability }: {
|
|
82
|
+
export declare function getUnlockKeyring({ storageServerUrl, zcapClient, serviceDescription, spaceId, capability }: {
|
|
52
83
|
storageServerUrl: string;
|
|
53
84
|
zcapClient: ZcapClient;
|
|
85
|
+
serviceDescription?: ServiceDescription;
|
|
54
86
|
spaceId: string;
|
|
55
87
|
capability?: IZcap;
|
|
56
88
|
}): Promise<unknown | null>;
|
|
@@ -68,15 +100,19 @@ export declare function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId
|
|
|
68
100
|
* @param options {object}
|
|
69
101
|
* @param options.storageServerUrl {string}
|
|
70
102
|
* @param options.zcapClient {ZcapClient}
|
|
103
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
104
|
+
* service description a client the caller already holds discovered
|
|
105
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
71
106
|
* @param options.spaceId {string} the unlock Space id
|
|
72
107
|
* @param options.record {object} the keyring record
|
|
73
108
|
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
74
109
|
* absent, the write is a root invocation
|
|
75
110
|
* @returns {Promise<void>}
|
|
76
111
|
*/
|
|
77
|
-
export declare function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId, record, capability }: {
|
|
112
|
+
export declare function putUnlockKeyring({ storageServerUrl, zcapClient, serviceDescription, spaceId, record, capability }: {
|
|
78
113
|
storageServerUrl: string;
|
|
79
114
|
zcapClient: ZcapClient;
|
|
115
|
+
serviceDescription?: ServiceDescription;
|
|
80
116
|
spaceId: string;
|
|
81
117
|
record: object;
|
|
82
118
|
capability?: IZcap;
|
|
@@ -99,6 +135,9 @@ export declare function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId
|
|
|
99
135
|
* @param options {object}
|
|
100
136
|
* @param options.storageServerUrl {string}
|
|
101
137
|
* @param options.zcapClient {ZcapClient}
|
|
138
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
139
|
+
* service description a client the caller already holds discovered
|
|
140
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
102
141
|
* @param options.spaceId {string} the unlock Space id
|
|
103
142
|
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
104
143
|
* absent, the delete is a root invocation
|
|
@@ -106,9 +145,10 @@ export declare function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId
|
|
|
106
145
|
* when the server answered 404 (absent, or unauthorized under a
|
|
107
146
|
* capability); every other error propagates unchanged
|
|
108
147
|
*/
|
|
109
|
-
export declare function deleteUnlockSpace({ storageServerUrl, zcapClient, spaceId, capability }: {
|
|
148
|
+
export declare function deleteUnlockSpace({ storageServerUrl, zcapClient, serviceDescription, spaceId, capability }: {
|
|
110
149
|
storageServerUrl: string;
|
|
111
150
|
zcapClient: ZcapClient;
|
|
151
|
+
serviceDescription?: ServiceDescription;
|
|
112
152
|
spaceId: string;
|
|
113
153
|
capability?: IZcap;
|
|
114
154
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAIhD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAA;AAwIrD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,UAAU,EACV,IAAwB,EACzB,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,OAAO,EAA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AG,WAAW,CAAA;CAAE,CAAC,CAOhD"}
|
|
@@ -32,17 +32,22 @@ import { plaintextCollection } from '../space/plaintextCollection.js';
|
|
|
32
32
|
export const UNLOCK_SPACE_NAME = 'Freewallet Keyring';
|
|
33
33
|
/**
|
|
34
34
|
* The bare WAS client for an unlock Space (see the module doc for why it wires
|
|
35
|
-
* in no encryption provider).
|
|
35
|
+
* in no encryption provider). Each exported function builds one and hands it
|
|
36
|
+
* to the helpers it composes, so a call discovers the service at most once.
|
|
36
37
|
*
|
|
37
38
|
* @param options {object}
|
|
38
39
|
* @param options.storageServerUrl {string}
|
|
39
40
|
* @param options.zcapClient {ZcapClient} built on the unlock agent's signer
|
|
41
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
42
|
+
* service description a client the caller already holds discovered
|
|
43
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
40
44
|
* @returns {WasClient}
|
|
41
45
|
*/
|
|
42
|
-
function unlockSpaceClient({ storageServerUrl, zcapClient }) {
|
|
46
|
+
function unlockSpaceClient({ storageServerUrl, zcapClient, serviceDescription }) {
|
|
43
47
|
return new WasClient({
|
|
44
48
|
serverUrl: storageServerUrl,
|
|
45
|
-
zcapClient
|
|
49
|
+
zcapClient,
|
|
50
|
+
serviceDescription
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
53
|
/**
|
|
@@ -52,15 +57,13 @@ function unlockSpaceClient({ storageServerUrl, zcapClient }) {
|
|
|
52
57
|
* unreadable.
|
|
53
58
|
*
|
|
54
59
|
* @param options {object}
|
|
55
|
-
* @param options.
|
|
56
|
-
* @param options.zcapClient {ZcapClient}
|
|
60
|
+
* @param options.was {WasClient} the unlock Space client
|
|
57
61
|
* @param options.spaceId {string}
|
|
58
62
|
* @param options.collectionId {string}
|
|
59
63
|
* @param options.name {string}
|
|
60
64
|
* @returns {Promise<void>}
|
|
61
65
|
*/
|
|
62
|
-
async function ensurePlaintextCollection({
|
|
63
|
-
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
66
|
+
async function ensurePlaintextCollection({ was, spaceId, collectionId, name }) {
|
|
64
67
|
await was
|
|
65
68
|
.space(spaceId)
|
|
66
69
|
.collection(collectionId)
|
|
@@ -74,8 +77,7 @@ async function ensurePlaintextCollection({ storageServerUrl, zcapClient, spaceId
|
|
|
74
77
|
* The explicit `plaintext` override is load-bearing (see the module doc).
|
|
75
78
|
*
|
|
76
79
|
* @param options {object}
|
|
77
|
-
* @param options.
|
|
78
|
-
* @param options.zcapClient {ZcapClient}
|
|
80
|
+
* @param options.was {WasClient} the unlock Space client
|
|
79
81
|
* @param options.spaceId {string}
|
|
80
82
|
* @param options.collectionId {string}
|
|
81
83
|
* @param options.resourceId {string}
|
|
@@ -83,8 +85,7 @@ async function ensurePlaintextCollection({ storageServerUrl, zcapClient, spaceId
|
|
|
83
85
|
* rides; absent, the request invokes the root capability
|
|
84
86
|
* @returns {Promise<unknown | null>}
|
|
85
87
|
*/
|
|
86
|
-
async function getPlaintextRecord({
|
|
87
|
-
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
88
|
+
async function getPlaintextRecord({ was, spaceId, collectionId, resourceId, capability }) {
|
|
88
89
|
const result = await plaintextCollection({
|
|
89
90
|
was,
|
|
90
91
|
spaceId,
|
|
@@ -100,8 +101,7 @@ async function getPlaintextRecord({ storageServerUrl, zcapClient, spaceId, colle
|
|
|
100
101
|
* Serialized to bytes with an explicit `application/json` content-type.
|
|
101
102
|
*
|
|
102
103
|
* @param options {object}
|
|
103
|
-
* @param options.
|
|
104
|
-
* @param options.zcapClient {ZcapClient}
|
|
104
|
+
* @param options.was {WasClient} the unlock Space client
|
|
105
105
|
* @param options.spaceId {string}
|
|
106
106
|
* @param options.collectionId {string}
|
|
107
107
|
* @param options.resourceId {string}
|
|
@@ -110,8 +110,7 @@ async function getPlaintextRecord({ storageServerUrl, zcapClient, spaceId, colle
|
|
|
110
110
|
* rides; absent, the request invokes the root capability
|
|
111
111
|
* @returns {Promise<void>}
|
|
112
112
|
*/
|
|
113
|
-
async function putPlaintextRecord({
|
|
114
|
-
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
113
|
+
async function putPlaintextRecord({ was, spaceId, collectionId, resourceId, record, capability }) {
|
|
115
114
|
const body = new TextEncoder().encode(JSON.stringify(record));
|
|
116
115
|
await plaintextCollection({ was, spaceId, collectionId, capability })
|
|
117
116
|
.resource(resourceId)
|
|
@@ -126,17 +125,23 @@ async function putPlaintextRecord({ storageServerUrl, zcapClient, spaceId, colle
|
|
|
126
125
|
* @param options {object}
|
|
127
126
|
* @param options.storageServerUrl {string}
|
|
128
127
|
* @param options.zcapClient {ZcapClient}
|
|
128
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
129
|
+
* service description a client the caller already holds discovered
|
|
130
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
129
131
|
* @param options.spaceId {string} the unlock Space id
|
|
130
132
|
* @param options.controller {string} the unlock did:key
|
|
131
133
|
* @param [options.name] {string} the Space Description name
|
|
132
134
|
* @returns {Promise<void>}
|
|
133
135
|
*/
|
|
134
|
-
export async function ensureUnlockSpace({ storageServerUrl, zcapClient, spaceId, controller, name = UNLOCK_SPACE_NAME }) {
|
|
135
|
-
const was = unlockSpaceClient({
|
|
136
|
-
await was.space(spaceId).configure({ name, controller });
|
|
137
|
-
await ensurePlaintextCollection({
|
|
136
|
+
export async function ensureUnlockSpace({ storageServerUrl, zcapClient, serviceDescription, spaceId, controller, name = UNLOCK_SPACE_NAME }) {
|
|
137
|
+
const was = unlockSpaceClient({
|
|
138
138
|
storageServerUrl,
|
|
139
139
|
zcapClient,
|
|
140
|
+
serviceDescription
|
|
141
|
+
});
|
|
142
|
+
await was.space(spaceId).configure({ name, controller });
|
|
143
|
+
await ensurePlaintextCollection({
|
|
144
|
+
was,
|
|
140
145
|
spaceId,
|
|
141
146
|
collectionId: KEYRING_COLLECTION.id,
|
|
142
147
|
name: KEYRING_COLLECTION.name
|
|
@@ -158,15 +163,21 @@ export async function ensureUnlockSpace({ storageServerUrl, zcapClient, spaceId,
|
|
|
158
163
|
* @param options {object}
|
|
159
164
|
* @param options.storageServerUrl {string}
|
|
160
165
|
* @param options.zcapClient {ZcapClient}
|
|
166
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
167
|
+
* service description a client the caller already holds discovered
|
|
168
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
161
169
|
* @param options.spaceId {string} the unlock Space id
|
|
162
170
|
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
163
171
|
* absent, the read is a root invocation
|
|
164
172
|
* @returns {Promise<unknown | null>}
|
|
165
173
|
*/
|
|
166
|
-
export async function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId, capability }) {
|
|
174
|
+
export async function getUnlockKeyring({ storageServerUrl, zcapClient, serviceDescription, spaceId, capability }) {
|
|
167
175
|
return getPlaintextRecord({
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
was: unlockSpaceClient({
|
|
177
|
+
storageServerUrl,
|
|
178
|
+
zcapClient,
|
|
179
|
+
serviceDescription
|
|
180
|
+
}),
|
|
170
181
|
spaceId,
|
|
171
182
|
collectionId: KEYRING_COLLECTION.id,
|
|
172
183
|
resourceId: KEYRING_RESOURCE,
|
|
@@ -187,16 +198,22 @@ export async function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId,
|
|
|
187
198
|
* @param options {object}
|
|
188
199
|
* @param options.storageServerUrl {string}
|
|
189
200
|
* @param options.zcapClient {ZcapClient}
|
|
201
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
202
|
+
* service description a client the caller already holds discovered
|
|
203
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
190
204
|
* @param options.spaceId {string} the unlock Space id
|
|
191
205
|
* @param options.record {object} the keyring record
|
|
192
206
|
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
193
207
|
* absent, the write is a root invocation
|
|
194
208
|
* @returns {Promise<void>}
|
|
195
209
|
*/
|
|
196
|
-
export async function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId, record, capability }) {
|
|
210
|
+
export async function putUnlockKeyring({ storageServerUrl, zcapClient, serviceDescription, spaceId, record, capability }) {
|
|
197
211
|
await putPlaintextRecord({
|
|
198
|
-
|
|
199
|
-
|
|
212
|
+
was: unlockSpaceClient({
|
|
213
|
+
storageServerUrl,
|
|
214
|
+
zcapClient,
|
|
215
|
+
serviceDescription
|
|
216
|
+
}),
|
|
200
217
|
spaceId,
|
|
201
218
|
collectionId: KEYRING_COLLECTION.id,
|
|
202
219
|
resourceId: KEYRING_RESOURCE,
|
|
@@ -222,6 +239,9 @@ export async function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId,
|
|
|
222
239
|
* @param options {object}
|
|
223
240
|
* @param options.storageServerUrl {string}
|
|
224
241
|
* @param options.zcapClient {ZcapClient}
|
|
242
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
243
|
+
* service description a client the caller already holds discovered
|
|
244
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
225
245
|
* @param options.spaceId {string} the unlock Space id
|
|
226
246
|
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
227
247
|
* absent, the delete is a root invocation
|
|
@@ -229,8 +249,12 @@ export async function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId,
|
|
|
229
249
|
* when the server answered 404 (absent, or unauthorized under a
|
|
230
250
|
* capability); every other error propagates unchanged
|
|
231
251
|
*/
|
|
232
|
-
export async function deleteUnlockSpace({ storageServerUrl, zcapClient, spaceId, capability }) {
|
|
233
|
-
const was = unlockSpaceClient({
|
|
252
|
+
export async function deleteUnlockSpace({ storageServerUrl, zcapClient, serviceDescription, spaceId, capability }) {
|
|
253
|
+
const was = unlockSpaceClient({
|
|
254
|
+
storageServerUrl,
|
|
255
|
+
zcapClient,
|
|
256
|
+
serviceDescription
|
|
257
|
+
});
|
|
234
258
|
return was.space(spaceId, { capability }).deleteWithOutcome();
|
|
235
259
|
}
|
|
236
260
|
//# sourceMappingURL=unlockSpace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.js","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"unlockSpace.js","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,SAAS,EAA2B,MAAM,qBAAqB,CAAA;AAGxE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,SAAS,iBAAiB,CAAC,EACzB,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAKnB;IACC,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,gBAAgB;QAC3B,UAAU;QACV,kBAAkB;KACnB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,yBAAyB,CAAC,EACvC,GAAG,EACH,OAAO,EACP,YAAY,EACZ,IAAI,EAML;IACC,MAAM,GAAG;SACN,KAAK,CAAC,OAAO,CAAC;SACd,UAAU,CAAC,YAAY,CAAC;SACxB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,kBAAkB,CAAC,EAChC,GAAG,EACH,OAAO,EACP,YAAY,EACZ,UAAU,EACV,UAAU,EAOX;IACC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC;QACvC,GAAG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U,gBAAgB,CAAC,EACrC,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,UAAU,EAOX;IACC,OAAO,kBAAkB,CAAC;QACxB,GAAG,EAAE,iBAAiB,CAAC;YACrB,gBAAgB;YAChB,UAAU;YACV,kBAAkB;SACnB,CAAC;QACF,OAAO;QACP,YAAY,EAAE,kBAAkB,CAAC,EAAE;QACnC,UAAU,EAAE,gBAAgB;QAC5B,UAAU;KACX,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,UAAU,EAQX;IACC,MAAM,kBAAkB,CAAC;QACvB,GAAG,EAAE,iBAAiB,CAAC;YACrB,gBAAgB;YAChB,UAAU;YACV,kBAAkB;SACnB,CAAC;QACF,OAAO;QACP,YAAY,EAAE,kBAAkB,CAAC,EAAE;QACnC,UAAU,EAAE,gBAAgB;QAC5B,MAAM;QACN,UAAU;KACX,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,UAAU,EAOX;IACC,MAAM,GAAG,GAAG,iBAAiB,CAAC;QAC5B,gBAAgB;QAChB,UAAU;QACV,kBAAkB;KACnB,CAAC,CAAA;IACF,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAA;AAC/D,CAAC"}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import type { DIDLog } from '@interop/did-method-webvh';
|
|
29
29
|
import type { ZcapClient } from '@interop/ezcap';
|
|
30
|
-
import { type Collection, type IZcap } from '@interop/was-client';
|
|
30
|
+
import { type Collection, type IZcap, type ServiceDescription } from '@interop/was-client';
|
|
31
31
|
import type { ResourceLogPinStore, ResourceLogSigner } from '@interop/vh-resource-log';
|
|
32
32
|
import type { WebvhResourceLogController } from '../resourceLog/index.js';
|
|
33
33
|
import { type SealableEncryptionDescriptorStore } from './rosterLogStore.js';
|
|
@@ -156,9 +156,12 @@ export declare function collectionDescriptorStores({ collectionFor, resolveContr
|
|
|
156
156
|
* @param [options.capability] {IZcap} an invocation capability every
|
|
157
157
|
* request rides (a transient visit's generation delegation); absent,
|
|
158
158
|
* requests invoke the root capability
|
|
159
|
+
* @param [options.serviceDescription] {ServiceDescription} the server's
|
|
160
|
+
* service description a client the caller already holds discovered
|
|
161
|
+
* (`(await was.service()).description`), so this one skips discovery
|
|
159
162
|
* @returns {CollectionStoreFor}
|
|
160
163
|
*/
|
|
161
|
-
export declare function accountCollectionStores({ storageServerUrl, zcapClient, spaceId, did, pinStore, signer, log, capability }: {
|
|
164
|
+
export declare function accountCollectionStores({ storageServerUrl, zcapClient, spaceId, did, pinStore, signer, log, capability, serviceDescription }: {
|
|
162
165
|
storageServerUrl: string;
|
|
163
166
|
zcapClient: ZcapClient;
|
|
164
167
|
spaceId: string;
|
|
@@ -167,5 +170,6 @@ export declare function accountCollectionStores({ storageServerUrl, zcapClient,
|
|
|
167
170
|
signer: ResourceLogSigner;
|
|
168
171
|
log?: DIDLog;
|
|
169
172
|
capability?: IZcap;
|
|
173
|
+
serviceDescription?: ServiceDescription;
|
|
170
174
|
}): CollectionStoreFor;
|
|
171
175
|
//# sourceMappingURL=collectionLogStore.d.ts.map
|