@interop/was-client 0.13.2 → 0.14.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/README.md +33 -0
- package/dist/Collection.d.ts +27 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +41 -1
- package/dist/Collection.js.map +1 -1
- package/dist/Space.d.ts +27 -0
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +30 -0
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +14 -0
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +21 -0
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +67 -19
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +154 -35
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/internal/grant.d.ts +11 -1
- package/dist/internal/grant.d.ts.map +1 -1
- package/dist/internal/grant.js +32 -3
- package/dist/internal/grant.js.map +1 -1
- package/dist/internal/paths.d.ts +33 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +49 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/revoke.d.ts +34 -0
- package/dist/internal/revoke.d.ts.map +1 -0
- package/dist/internal/revoke.js +106 -0
- package/dist/internal/revoke.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/edv/WasTransport.js
CHANGED
|
@@ -26,11 +26,16 @@
|
|
|
26
26
|
* server that does not will reject it with 415). Pass `contentType:
|
|
27
27
|
* JOSE_CONTENT_TYPE` to opt into it where the server supports it.
|
|
28
28
|
*
|
|
29
|
-
* Scope: documents
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* Scope: documents (`insert` / `update` / `get`) plus blinded-index content
|
|
30
|
+
* query (`find`, the `blinded-index` profile of the reserved Collection
|
|
31
|
+
* `POST .../query` endpoint -- the server's `blinded-index-query` backend
|
|
32
|
+
* feature). `updateIndex` throws: in this profile the `indexed` array rides
|
|
33
|
+
* inside the stored document envelope, so `update()` IS the re-index
|
|
34
|
+
* operation and no separate index endpoint exists. Chunked streams
|
|
35
|
+
* (`storeChunk` / `getChunk`) still require the server's `chunked-streams`
|
|
36
|
+
* affordance (the reserved `/{id}/chunks/{n}` sub-segment), which neither
|
|
37
|
+
* reference backend provides, so they throw.
|
|
38
|
+
* `insert` uses an atomic `If-None-Match: *` create when the backend
|
|
34
39
|
* advertises the optional `conditional-writes` feature; otherwise (and for
|
|
35
40
|
* `update`) writes are advisory -- the EDV `sequence` is not enforced
|
|
36
41
|
* (last-writer-wins on `update`).
|
|
@@ -38,7 +43,7 @@
|
|
|
38
43
|
import { Transport } from '@interop/edv-client';
|
|
39
44
|
import { httpStatus } from '../errors.js';
|
|
40
45
|
import { readJsonData } from '../internal/content.js';
|
|
41
|
-
import { collectionBackend, resourcePath } from '../internal/paths.js';
|
|
46
|
+
import { collectionBackend, collectionQuery, resourcePath } from '../internal/paths.js';
|
|
42
47
|
import { DEFAULT_CONTENT_TYPE, envelopeBytes, JOSE_CONTENT_TYPE } from './constants.js';
|
|
43
48
|
export { JOSE_CONTENT_TYPE };
|
|
44
49
|
/**
|
|
@@ -65,7 +70,7 @@ export class WasTransport extends Transport {
|
|
|
65
70
|
collectionId;
|
|
66
71
|
contentType;
|
|
67
72
|
_was;
|
|
68
|
-
|
|
73
|
+
_backendFeaturesPromise;
|
|
69
74
|
/**
|
|
70
75
|
* @param options {object}
|
|
71
76
|
* @param options.was {WasClient} a WAS client holding the signer
|
|
@@ -116,30 +121,42 @@ export class WasTransport extends Transport {
|
|
|
116
121
|
});
|
|
117
122
|
}
|
|
118
123
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* memoized for the transport's
|
|
122
|
-
* (404, 501 on a server without
|
|
123
|
-
*
|
|
124
|
+
* The feature tokens the collection's backend advertises in its "Collection
|
|
125
|
+
* Backend Selected" descriptor (e.g. `conditional-writes`,
|
|
126
|
+
* `blinded-index-query`). Read once and memoized for the transport's
|
|
127
|
+
* lifetime; any failure to read the descriptor (404, 501 on a server without
|
|
128
|
+
* backend support, network error) resolves `[]`, so every affordance gate
|
|
129
|
+
* falls closed.
|
|
124
130
|
*
|
|
125
|
-
* @returns {Promise<
|
|
131
|
+
* @returns {Promise<string[]>}
|
|
126
132
|
*/
|
|
127
|
-
|
|
128
|
-
this.
|
|
133
|
+
_backendFeatures() {
|
|
134
|
+
this._backendFeaturesPromise ??= (async () => {
|
|
129
135
|
try {
|
|
130
136
|
const response = await this._was.request({
|
|
131
137
|
path: collectionBackend(this.spaceId, this.collectionId),
|
|
132
138
|
method: 'GET'
|
|
133
139
|
});
|
|
134
140
|
const descriptor = (await readJsonData(response));
|
|
135
|
-
return
|
|
136
|
-
descriptor.features.
|
|
141
|
+
return Array.isArray(descriptor?.features)
|
|
142
|
+
? descriptor.features.filter((feature) => typeof feature === 'string')
|
|
143
|
+
: [];
|
|
137
144
|
}
|
|
138
145
|
catch {
|
|
139
|
-
return
|
|
146
|
+
return [];
|
|
140
147
|
}
|
|
141
148
|
})();
|
|
142
|
-
return this.
|
|
149
|
+
return this._backendFeaturesPromise;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Whether the collection's backend advertises the optional
|
|
153
|
+
* `conditional-writes` feature, so `insert` can use an atomic
|
|
154
|
+
* `If-None-Match: *` create instead of the advisory existence-check path.
|
|
155
|
+
*
|
|
156
|
+
* @returns {Promise<boolean>}
|
|
157
|
+
*/
|
|
158
|
+
async _conditionalWrites() {
|
|
159
|
+
return (await this._backendFeatures()).includes('conditional-writes');
|
|
143
160
|
}
|
|
144
161
|
/**
|
|
145
162
|
* @inheritdoc
|
|
@@ -150,7 +167,9 @@ export class WasTransport extends Transport {
|
|
|
150
167
|
* `PUT` with `If-None-Match: *`, and the server's 412 maps to
|
|
151
168
|
* `DuplicateError`. Otherwise it degrades to a bodiless existence check
|
|
152
169
|
* (`HEAD`) before the `PUT` -- advisory and non-atomic, but no longer
|
|
153
|
-
* downloading the whole stored envelope just to discard it.
|
|
170
|
+
* downloading the whole stored envelope just to discard it. In either path a
|
|
171
|
+
* 409 (a `unique: true` blinded attribute already held by another document)
|
|
172
|
+
* likewise maps to `DuplicateError`.
|
|
154
173
|
*
|
|
155
174
|
* @param options {object}
|
|
156
175
|
* @param options.encrypted {IEncryptedDocument} the document to insert
|
|
@@ -172,6 +191,14 @@ export class WasTransport extends Transport {
|
|
|
172
191
|
cause: err
|
|
173
192
|
});
|
|
174
193
|
}
|
|
194
|
+
if (httpStatus(err) === 409) {
|
|
195
|
+
throw namedError({
|
|
196
|
+
name: 'DuplicateError',
|
|
197
|
+
message: 'A unique indexed attribute value is already held by another ' +
|
|
198
|
+
'document in this collection.',
|
|
199
|
+
cause: err
|
|
200
|
+
});
|
|
201
|
+
}
|
|
175
202
|
throw err;
|
|
176
203
|
}
|
|
177
204
|
return;
|
|
@@ -182,7 +209,20 @@ export class WasTransport extends Transport {
|
|
|
182
209
|
message: `A document with id "${encrypted.id}" already exists.`
|
|
183
210
|
});
|
|
184
211
|
}
|
|
185
|
-
|
|
212
|
+
try {
|
|
213
|
+
await this._put(encrypted.id, encrypted);
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
if (httpStatus(err) === 409) {
|
|
217
|
+
throw namedError({
|
|
218
|
+
name: 'DuplicateError',
|
|
219
|
+
message: 'A unique indexed attribute value is already held by another ' +
|
|
220
|
+
'document in this collection.',
|
|
221
|
+
cause: err
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
throw err;
|
|
225
|
+
}
|
|
186
226
|
}
|
|
187
227
|
/**
|
|
188
228
|
* @inheritdoc
|
|
@@ -191,6 +231,14 @@ export class WasTransport extends Transport {
|
|
|
191
231
|
* here -- without server-side conditional writes, a stale write is not
|
|
192
232
|
* rejected (last-writer-wins).
|
|
193
233
|
*
|
|
234
|
+
* Two write-time conflicts are mapped to the names `EdvClientCore` dispatches
|
|
235
|
+
* on. A server enforcing conditional writes rejects a stale/sequence
|
|
236
|
+
* conflict with 412 (precondition-failed), which surfaces as
|
|
237
|
+
* `InvalidStateError` -- the recoverable case, by re-fetching the current
|
|
238
|
+
* document and retrying. A 409 is the EDV unique-attribute collision (a
|
|
239
|
+
* `unique: true` blinded attribute already held by another document), which
|
|
240
|
+
* is NOT recoverable by re-fetch-and-retry; it surfaces as `DuplicateError`.
|
|
241
|
+
*
|
|
194
242
|
* @param options {object}
|
|
195
243
|
* @param options.encrypted {IEncryptedDocument} the document to update
|
|
196
244
|
* @returns {Promise<void>}
|
|
@@ -203,12 +251,19 @@ export class WasTransport extends Transport {
|
|
|
203
251
|
await this._put(encrypted.id, encrypted);
|
|
204
252
|
}
|
|
205
253
|
catch (err) {
|
|
206
|
-
|
|
207
|
-
// with 409; surface it the way `EdvClientCore` expects.
|
|
208
|
-
if (httpStatus(err) === 409) {
|
|
254
|
+
if (httpStatus(err) === 412) {
|
|
209
255
|
throw namedError({
|
|
210
256
|
name: 'InvalidStateError',
|
|
211
|
-
message: '
|
|
257
|
+
message: 'Document update conflict: the stored document changed since it ' +
|
|
258
|
+
'was read. Re-fetch the current document and retry.',
|
|
259
|
+
cause: err
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (httpStatus(err) === 409) {
|
|
263
|
+
throw namedError({
|
|
264
|
+
name: 'DuplicateError',
|
|
265
|
+
message: 'A unique indexed attribute value is already held by another ' +
|
|
266
|
+
'document in this collection.',
|
|
212
267
|
cause: err
|
|
213
268
|
});
|
|
214
269
|
}
|
|
@@ -271,19 +326,81 @@ export class WasTransport extends Transport {
|
|
|
271
326
|
/**
|
|
272
327
|
* @inheritdoc
|
|
273
328
|
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
329
|
+
* Runs a blinded-index content query: a signed `POST` of
|
|
330
|
+
* `{ profile: 'blinded-index', ...query }` to the Collection's reserved
|
|
331
|
+
* `/query` endpoint. Requires the backend's `blinded-index-query` affordance
|
|
332
|
+
* (throws `NotSupportedError` when it is absent). The server evaluates the
|
|
333
|
+
* blinded `equals` / `has` filters against the `indexed` entries of stored
|
|
334
|
+
* documents (opaque string comparison -- it does no crypto) and returns
|
|
335
|
+
* `{ documents, hasMore, cursor? }` (the encrypted envelopes verbatim, in
|
|
336
|
+
* ascending resource-id order, with `cursor` present iff `hasMore`), or a
|
|
337
|
+
* bare `{ count }` when `query.count` is `true`. The body is returned
|
|
338
|
+
* untouched: `EdvClientCore.find` decrypts `documents` and passes
|
|
339
|
+
* `hasMore` / `cursor` through.
|
|
340
|
+
*
|
|
341
|
+
* @param options {object}
|
|
342
|
+
* @param options.query {IEDVQuery} the blinded query (`index` plus one of
|
|
343
|
+
* `equals` / `has`, and optional `count` / `limit` / `cursor`), as built
|
|
344
|
+
* by `EdvClientCore`'s `IndexHelper.buildQuery`
|
|
345
|
+
* @returns {Promise<object>} the server's response body verbatim
|
|
276
346
|
*/
|
|
277
|
-
async find() {
|
|
278
|
-
|
|
347
|
+
async find({ query } = {}) {
|
|
348
|
+
if (!query) {
|
|
349
|
+
throw new TypeError('"query" is required.');
|
|
350
|
+
}
|
|
351
|
+
if (!(await this._backendFeatures()).includes('blinded-index-query')) {
|
|
352
|
+
throw namedError({
|
|
353
|
+
name: 'NotSupportedError',
|
|
354
|
+
message: "Blinded-index query is not supported: the collection's backend " +
|
|
355
|
+
'does not advertise the "blinded-index-query" affordance.'
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
// `returnDocuments` is a first-class `IEDVQuery` field, but the WAS profile
|
|
359
|
+
// has no ids-only mode, so it is dropped (whatever its value) and full
|
|
360
|
+
// documents come back -- the best-effort degradation `EdvClientCore.find`
|
|
361
|
+
// documents for this option.
|
|
362
|
+
const { returnDocuments: _returnDocuments, ...blindedQuery } = query;
|
|
363
|
+
let response;
|
|
364
|
+
try {
|
|
365
|
+
response = await this._was.request({
|
|
366
|
+
path: collectionQuery(this.spaceId, this.collectionId),
|
|
367
|
+
method: 'POST',
|
|
368
|
+
json: { profile: 'blinded-index', ...blindedQuery }
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
catch (err) {
|
|
372
|
+
if (httpStatus(err) === 404) {
|
|
373
|
+
throw namedError({
|
|
374
|
+
name: 'NotFoundError',
|
|
375
|
+
message: 'Collection not found.',
|
|
376
|
+
cause: err
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
throw err;
|
|
380
|
+
}
|
|
381
|
+
const result = await readJsonData(response);
|
|
382
|
+
if (result === null || typeof result !== 'object') {
|
|
383
|
+
throw new Error('Malformed blinded-index query response.');
|
|
384
|
+
}
|
|
385
|
+
return result;
|
|
279
386
|
}
|
|
280
387
|
/**
|
|
281
388
|
* @inheritdoc
|
|
282
389
|
*
|
|
283
|
-
*
|
|
390
|
+
* Not supported, deliberately: in the EDV-over-WAS profile, index entries
|
|
391
|
+
* are not a separate server-side resource -- the `indexed` array rides
|
|
392
|
+
* inside the stored document envelope, and every `insert` / `update`
|
|
393
|
+
* already carries it. Re-indexing a document is therefore an ordinary
|
|
394
|
+
* `update()` of the full envelope; there is no `/{id}/index` endpoint to
|
|
395
|
+
* bind this to.
|
|
284
396
|
*/
|
|
285
397
|
async updateIndex() {
|
|
286
|
-
|
|
398
|
+
throw namedError({
|
|
399
|
+
name: 'NotSupportedError',
|
|
400
|
+
message: '"updateIndex" is not supported by the EDV-over-WAS profile: index ' +
|
|
401
|
+
'entries ride inside the stored document envelope, so re-index a ' +
|
|
402
|
+
'document with an ordinary "update()" of the full document.'
|
|
403
|
+
});
|
|
287
404
|
}
|
|
288
405
|
/**
|
|
289
406
|
* @inheritdoc
|
|
@@ -302,8 +419,10 @@ export class WasTransport extends Transport {
|
|
|
302
419
|
return this._unsupported('getChunk (chunked streams)');
|
|
303
420
|
}
|
|
304
421
|
/**
|
|
305
|
-
* Throws a uniform "not supported in this profile" error for
|
|
306
|
-
*
|
|
422
|
+
* Throws a uniform "not supported in this profile" error for the chunked-
|
|
423
|
+
* stream operations, which depend on a server-side affordance (the reserved
|
|
424
|
+
* `/{id}/chunks/{n}` sub-segment, the `chunked-streams` backend feature)
|
|
425
|
+
* that neither reference backend provides yet.
|
|
307
426
|
*
|
|
308
427
|
* @param operation {string}
|
|
309
428
|
* @returns {never}
|
|
@@ -311,8 +430,8 @@ export class WasTransport extends Transport {
|
|
|
311
430
|
_unsupported(operation) {
|
|
312
431
|
throw namedError({
|
|
313
432
|
name: 'NotSupportedError',
|
|
314
|
-
message: `"${operation}" is not supported by the
|
|
315
|
-
'
|
|
433
|
+
message: `"${operation}" is not supported by the EDV-over-WAS profile ` +
|
|
434
|
+
'(requires the server\'s "chunked-streams" affordance).'
|
|
316
435
|
});
|
|
317
436
|
}
|
|
318
437
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasTransport.js","sourceRoot":"","sources":["../../src/edv/WasTransport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"WasTransport.js","sourceRoot":"","sources":["../../src/edv/WasTransport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,EACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAQ5B;;;;;;;;;;GAUG;AACH,SAAS,UAAU,CAAC,EAClB,IAAI,EACJ,OAAO,EACP,KAAK,EAKN;IACC,MAAM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D,wDAAwD;SAC3D,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/internal/grant.d.ts
CHANGED
|
@@ -6,12 +6,22 @@
|
|
|
6
6
|
* grant sugar. Maps `GrantOptions` onto `zcapClient.delegate(...)`, normalizing
|
|
7
7
|
* action verbs to uppercase so a lowercase grant (`'get'`) still validates on
|
|
8
8
|
* the server (which matches actions case-sensitively against `'GET'`).
|
|
9
|
+
*
|
|
10
|
+
* An unparented grant whose target lies in the server's Space tree is delegated
|
|
11
|
+
* from that **Space's** root capability, with the target carried as an
|
|
12
|
+
* attenuated `invocationTarget`, rather than from the target's own root
|
|
13
|
+
* capability. Both forms grant the same access (the server verifies WAS routes
|
|
14
|
+
* with target attenuation allowed), but only a Space-rooted chain can be revoked
|
|
15
|
+
* -- revocation is Space-scoped, and the endpoint requires the chain to root
|
|
16
|
+
* exactly in the Space (see `revoke.ts`).
|
|
9
17
|
*/
|
|
10
18
|
import type { ClientContext } from './request.js';
|
|
11
19
|
import type { GrantOptions, IDelegatedZcap, IZcap } from '../types.js';
|
|
12
20
|
/**
|
|
13
21
|
* Delegates a capability per `GrantOptions`, returning the signed zcap to hand
|
|
14
|
-
* off out-of-band.
|
|
22
|
+
* off out-of-band. An explicit `capability` (re-delegation of a parent zcap)
|
|
23
|
+
* always wins; otherwise a Space-tree target is rooted at its Space, so the
|
|
24
|
+
* resulting capability is revocable via `space.revoke()` / `was.revoke()`.
|
|
15
25
|
*
|
|
16
26
|
* @param context {ClientContext}
|
|
17
27
|
* @param options {GrantOptions}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAgCtE;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,YAAY,GACzD,OAAO,CAAC,cAAc,CAAC,CAazB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,EACtB,EACE,IAAI,EACJ,OAAO,EACP,UAAU,EACX,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GAC7D,OAAO,CAAC,cAAc,CAAC,CAMzB"}
|
package/dist/internal/grant.js
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
|
-
import { toUrl } from './paths.js';
|
|
1
|
+
import { parseSpaceTarget, spacePath, toUrl } from './paths.js';
|
|
2
|
+
/**
|
|
3
|
+
* The root capability id (`urn:zcap:root:<encoded target>`) of the Space
|
|
4
|
+
* containing `target`, or `undefined` when `target` is not a URL beneath this
|
|
5
|
+
* server's `/space` tree (e.g. a `/kms` target, or another origin) -- in which
|
|
6
|
+
* case the caller lets ezcap default to the target's own root capability.
|
|
7
|
+
*
|
|
8
|
+
* The id is returned as a string, which `zcapClient.delegate(...)` accepts for a
|
|
9
|
+
* root parent capability. (Its sibling `request(...)` does not, for a non-`https:`
|
|
10
|
+
* target -- hence the object form in `revoke.ts`.)
|
|
11
|
+
*
|
|
12
|
+
* @param options {object}
|
|
13
|
+
* @param options.serverUrl {string} the client's server base URL
|
|
14
|
+
* @param options.target {string} the absolute grant target URL
|
|
15
|
+
* @returns {string | undefined}
|
|
16
|
+
*/
|
|
17
|
+
function spaceRootCapabilityId({ serverUrl, target }) {
|
|
18
|
+
const parsed = parseSpaceTarget({ serverUrl, target });
|
|
19
|
+
if (parsed === null) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const spaceUrl = toUrl({ serverUrl, path: spacePath(parsed.spaceId) });
|
|
23
|
+
return `urn:zcap:root:${encodeURIComponent(spaceUrl)}`;
|
|
24
|
+
}
|
|
2
25
|
/**
|
|
3
26
|
* Delegates a capability per `GrantOptions`, returning the signed zcap to hand
|
|
4
|
-
* off out-of-band.
|
|
27
|
+
* off out-of-band. An explicit `capability` (re-delegation of a parent zcap)
|
|
28
|
+
* always wins; otherwise a Space-tree target is rooted at its Space, so the
|
|
29
|
+
* resulting capability is revocable via `space.revoke()` / `was.revoke()`.
|
|
5
30
|
*
|
|
6
31
|
* @param context {ClientContext}
|
|
7
32
|
* @param options {GrantOptions}
|
|
8
33
|
* @returns {Promise<IDelegatedZcap>}
|
|
9
34
|
*/
|
|
10
35
|
export async function delegateGrant(context, { to, actions, expires, target, capability }) {
|
|
36
|
+
const parent = capability ??
|
|
37
|
+
(target === undefined
|
|
38
|
+
? undefined
|
|
39
|
+
: spaceRootCapabilityId({ serverUrl: context.serverUrl, target }));
|
|
11
40
|
return context.zcapClient.delegate({
|
|
12
41
|
controller: to,
|
|
13
42
|
invocationTarget: target,
|
|
14
43
|
allowedActions: actions.map(action => action.toUpperCase()),
|
|
15
44
|
expires,
|
|
16
|
-
capability
|
|
45
|
+
capability: parent
|
|
17
46
|
});
|
|
18
47
|
}
|
|
19
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAG/D;;;;;;;;;;;;;;GAcG;AACH,SAAS,qBAAqB,CAAC,EAC7B,SAAS,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AAE,CAAC;QACvE,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,UAAU;KAC7C,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/internal/paths.d.ts
CHANGED
|
@@ -44,6 +44,15 @@ export declare function spacePolicy(spaceId: string): string;
|
|
|
44
44
|
* `/space/:spaceId/linkset` -- the space-level linkset (policy discovery).
|
|
45
45
|
*/
|
|
46
46
|
export declare function spaceLinkset(spaceId: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* `/space/:spaceId/zcaps/revocations/:capabilityId` -- submit a revocation of a
|
|
49
|
+
* Space-rooted capability. The capability's `id` (typically a `urn:uuid:`) is
|
|
50
|
+
* percent-encoded into the single final segment.
|
|
51
|
+
*
|
|
52
|
+
* `zcaps` is not a reserved path segment: the route sits four segments deep,
|
|
53
|
+
* deeper than any Collection or Resource route, so it shadows nothing.
|
|
54
|
+
*/
|
|
55
|
+
export declare function spaceRevocation(spaceId: string, capabilityId: string): string;
|
|
47
56
|
/**
|
|
48
57
|
* `/space/:spaceId/:collectionId` -- get / update / delete a collection
|
|
49
58
|
* (no trailing slash).
|
|
@@ -74,6 +83,11 @@ export declare function collectionBackend(spaceId: string, collectionId: string)
|
|
|
74
83
|
* report (spec "Quotas").
|
|
75
84
|
*/
|
|
76
85
|
export declare function collectionQuota(spaceId: string, collectionId: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* `/space/:spaceId/:collectionId/query` -- the collection-level query endpoint,
|
|
88
|
+
* whose body's `profile` selects the query (e.g. `changes`, `blinded-index`).
|
|
89
|
+
*/
|
|
90
|
+
export declare function collectionQuery(spaceId: string, collectionId: string): string;
|
|
77
91
|
/**
|
|
78
92
|
* `/space/:spaceId/:collectionId/:resourceId` -- get / put / delete a resource
|
|
79
93
|
* (no trailing slash).
|
|
@@ -140,6 +154,25 @@ export type ParsedSpacePath = {
|
|
|
140
154
|
spaceId: string;
|
|
141
155
|
segments: string[];
|
|
142
156
|
};
|
|
157
|
+
/**
|
|
158
|
+
* Classifies an absolute `target` URL that is expected to live on this server,
|
|
159
|
+
* relative to `serverUrl`'s base path -- so a WAS mounted under a sub-path (e.g.
|
|
160
|
+
* `https://host/was/`) resolves just as a bare-origin deployment does, which
|
|
161
|
+
* `parseSpacePath` alone cannot do (it would see a leading `was` segment).
|
|
162
|
+
*
|
|
163
|
+
* Returns `null` when `target` is not beneath `serverUrl` (another origin, or
|
|
164
|
+
* another base path) or addresses something outside the `/space` tree (e.g.
|
|
165
|
+
* `/kms`). The caller chooses whether that is an error.
|
|
166
|
+
*
|
|
167
|
+
* @param options {object}
|
|
168
|
+
* @param options.serverUrl {string} the client's server base URL
|
|
169
|
+
* @param options.target {string} an absolute URL on that server
|
|
170
|
+
* @returns {ParsedSpacePath | null}
|
|
171
|
+
*/
|
|
172
|
+
export declare function parseSpaceTarget({ serverUrl, target }: {
|
|
173
|
+
serverUrl: string;
|
|
174
|
+
target: string;
|
|
175
|
+
}): ParsedSpacePath | null;
|
|
143
176
|
/**
|
|
144
177
|
* Parses a server pathname back into the containment depth it addresses -- the
|
|
145
178
|
* inverse of the builders above, kept next to them so the grammar is owned in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAiDA;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;GAGG;A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,CAAA;CAAE,CAAA;AAEjE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,MAAM,EACP,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,eAAe,GAAG,IAAI,CAazB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAkCvE"}
|
package/dist/internal/paths.js
CHANGED
|
@@ -107,6 +107,17 @@ export function spacePolicy(spaceId) {
|
|
|
107
107
|
export function spaceLinkset(spaceId) {
|
|
108
108
|
return `/space/${encode(spaceId)}/linkset`;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* `/space/:spaceId/zcaps/revocations/:capabilityId` -- submit a revocation of a
|
|
112
|
+
* Space-rooted capability. The capability's `id` (typically a `urn:uuid:`) is
|
|
113
|
+
* percent-encoded into the single final segment.
|
|
114
|
+
*
|
|
115
|
+
* `zcaps` is not a reserved path segment: the route sits four segments deep,
|
|
116
|
+
* deeper than any Collection or Resource route, so it shadows nothing.
|
|
117
|
+
*/
|
|
118
|
+
export function spaceRevocation(spaceId, capabilityId) {
|
|
119
|
+
return `/space/${encode(spaceId)}/zcaps/revocations/${encode(capabilityId)}`;
|
|
120
|
+
}
|
|
110
121
|
/**
|
|
111
122
|
* `/space/:spaceId/:collectionId` -- get / update / delete a collection
|
|
112
123
|
* (no trailing slash).
|
|
@@ -149,6 +160,13 @@ export function collectionBackend(spaceId, collectionId) {
|
|
|
149
160
|
export function collectionQuota(spaceId, collectionId) {
|
|
150
161
|
return `/space/${encode(spaceId)}/${encode(collectionId)}/quota`;
|
|
151
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* `/space/:spaceId/:collectionId/query` -- the collection-level query endpoint,
|
|
165
|
+
* whose body's `profile` selects the query (e.g. `changes`, `blinded-index`).
|
|
166
|
+
*/
|
|
167
|
+
export function collectionQuery(spaceId, collectionId) {
|
|
168
|
+
return `/space/${encode(spaceId)}/${encode(collectionId)}/query`;
|
|
169
|
+
}
|
|
152
170
|
/**
|
|
153
171
|
* `/space/:spaceId/:collectionId/:resourceId` -- get / put / delete a resource
|
|
154
172
|
* (no trailing slash).
|
|
@@ -203,6 +221,37 @@ export function toUrl({ serverUrl, path }) {
|
|
|
203
221
|
export function collectionItemsUrl(collectionUrl) {
|
|
204
222
|
return collectionUrl.endsWith('/') ? collectionUrl : `${collectionUrl}/`;
|
|
205
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Classifies an absolute `target` URL that is expected to live on this server,
|
|
226
|
+
* relative to `serverUrl`'s base path -- so a WAS mounted under a sub-path (e.g.
|
|
227
|
+
* `https://host/was/`) resolves just as a bare-origin deployment does, which
|
|
228
|
+
* `parseSpacePath` alone cannot do (it would see a leading `was` segment).
|
|
229
|
+
*
|
|
230
|
+
* Returns `null` when `target` is not beneath `serverUrl` (another origin, or
|
|
231
|
+
* another base path) or addresses something outside the `/space` tree (e.g.
|
|
232
|
+
* `/kms`). The caller chooses whether that is an error.
|
|
233
|
+
*
|
|
234
|
+
* @param options {object}
|
|
235
|
+
* @param options.serverUrl {string} the client's server base URL
|
|
236
|
+
* @param options.target {string} an absolute URL on that server
|
|
237
|
+
* @returns {ParsedSpacePath | null}
|
|
238
|
+
*/
|
|
239
|
+
export function parseSpaceTarget({ serverUrl, target }) {
|
|
240
|
+
const base = serverUrl.endsWith('/') ? serverUrl : `${serverUrl}/`;
|
|
241
|
+
if (!target.startsWith(base)) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
let pathname;
|
|
245
|
+
try {
|
|
246
|
+
;
|
|
247
|
+
({ pathname } = new URL(target));
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
const basePathname = new URL(base).pathname;
|
|
253
|
+
return parseSpacePath(`/${pathname.slice(basePathname.length)}`);
|
|
254
|
+
}
|
|
206
255
|
/**
|
|
207
256
|
* Parses a server pathname back into the containment depth it addresses -- the
|
|
208
257
|
* inverse of the builders above, kept next to them so the grammar is owned in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC1D,MAAM,IAAI,eAAe,CACvB,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,+BAA+B;YAClE,qDAAqD,CACxD,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,OAAe;IAC7B,aAAa,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,GAAG,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,eAAe,CAAA;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,U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AI,EAAE,CAAA;AAC1D,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ClientContext } from './request.js';
|
|
2
|
+
import type { IDelegatedZcap, IZcap } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Derives the id of the Space a capability is rooted in, from its
|
|
5
|
+
* `invocationTarget`. A Space-rooted capability's target is the Space URL or a
|
|
6
|
+
* path beneath it (the server enforces this when it verifies the chain), so
|
|
7
|
+
* every depth `parseSpaceTarget` recognizes -- Space, Collection, Resource, or a
|
|
8
|
+
* reserved sub-resource such as `/space/s/c/r/meta` -- carries the Space id.
|
|
9
|
+
*
|
|
10
|
+
* @param context {ClientContext}
|
|
11
|
+
* @param zcap {IZcap} the capability to locate
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export declare function spaceIdOf(context: ClientContext, zcap: IZcap): string;
|
|
15
|
+
/**
|
|
16
|
+
* Revokes a Space-rooted delegated capability: `POST`s it to
|
|
17
|
+
* `/space/:spaceId/zcaps/revocations/:capabilityId`, invoking that URL's own
|
|
18
|
+
* root capability. Resolves on the server's 204.
|
|
19
|
+
*
|
|
20
|
+
* The `action` is deliberately left unset: `send()` defaults it to the HTTP
|
|
21
|
+
* method, and this route expects `POST` (WAS capabilities are scoped by HTTP
|
|
22
|
+
* method, unlike the webkms `/kms` revocation route's `write`).
|
|
23
|
+
*
|
|
24
|
+
* @param context {ClientContext}
|
|
25
|
+
* @param options {object}
|
|
26
|
+
* @param options.spaceId {string} the Space the capability is rooted in
|
|
27
|
+
* @param options.zcap {IDelegatedZcap} the capability to revoke
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
export declare function submitRevocation(context: ClientContext, { spaceId, zcap }: {
|
|
31
|
+
spaceId: string;
|
|
32
|
+
zcap: IDelegatedZcap;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=revoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../src/internal/revoke.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAa,KAAK,EAAE,MAAM,aAAa,CAAA;AAsCnE;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAarE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,aAAa,EACtB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GAC3D,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|