@interop/was-client 0.4.0 → 0.6.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 +93 -6
- package/dist/Collection.d.ts +19 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +35 -1
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +6 -0
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +7 -1
- package/dist/Resource.js.map +1 -1
- package/dist/WasClient.d.ts +6 -3
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +8 -5
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +178 -0
- package/dist/edv/WasTransport.d.ts.map +1 -0
- package/dist/edv/WasTransport.js +284 -0
- package/dist/edv/WasTransport.js.map +1 -0
- package/dist/edv/index.d.ts +11 -0
- package/dist/edv/index.d.ts.map +1 -0
- package/dist/edv/index.js +11 -0
- package/dist/edv/index.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -1
- package/dist/errors.js.map +1 -1
- package/dist/internal/content.d.ts +30 -1
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +68 -3
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/paths.d.ts +10 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +14 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +2 -7
- package/dist/internal/request.js.map +1 -1
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
- [Resource metadata](#resource-metadata)
|
|
22
22
|
- [Storage introspection: backends and quotas](#storage-introspection-backends-and-quotas)
|
|
23
23
|
- [Export and import](#export-and-import)
|
|
24
|
+
- [Encrypted collections (EDV-over-WAS)](#encrypted-collections-edv-over-was)
|
|
24
25
|
- [The manual-request escape hatch](#the-manual-request-escape-hatch)
|
|
25
26
|
- [Errors and the 404/null caveat](#errors-and-the-404null-caveat)
|
|
26
27
|
- [Contribute](#contribute)
|
|
@@ -177,10 +178,16 @@ await space.configure({ name: 'Home (renamed)' })
|
|
|
177
178
|
await space.delete() // idempotent
|
|
178
179
|
```
|
|
179
180
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
List the spaces in the repository visible to your signer with
|
|
182
|
+
`was.listSpaces()`. It returns a `{ url, totalItems, items }` listing holding
|
|
183
|
+
only the spaces whose controller your invocation is authorized for; an
|
|
184
|
+
unauthorized caller gets an empty list rather than an error. To enumerate what
|
|
185
|
+
is _inside_ a space, use `space.collections()` (below).
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
const { totalItems, items } = await was.listSpaces()
|
|
189
|
+
// items: [{ id, url, name? }, ...]
|
|
190
|
+
```
|
|
184
191
|
|
|
185
192
|
### Collections
|
|
186
193
|
|
|
@@ -378,6 +385,15 @@ const report = await space.quotas() // SpaceQuotaReport | null
|
|
|
378
385
|
// report.backends[i]: { id, state, usageBytes, limit, restrictedActions, ... }
|
|
379
386
|
```
|
|
380
387
|
|
|
388
|
+
A Collection can likewise report the backend it is stored on and its own usage,
|
|
389
|
+
scoped to that backend (same optional-feature and 404/null caveats).
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
const backend = await collection.backend() // BackendDescriptor | null
|
|
393
|
+
const usage = await collection.quota() // BackendUsage | null
|
|
394
|
+
// usage: { id, state, usageBytes, limit, restrictedActions, measuredAt, ... }
|
|
395
|
+
```
|
|
396
|
+
|
|
381
397
|
### Export and import
|
|
382
398
|
|
|
383
399
|
```ts
|
|
@@ -387,6 +403,77 @@ const stats = await otherSpace.import(archive)
|
|
|
387
403
|
// policiesCreated, policiesSkipped }
|
|
388
404
|
```
|
|
389
405
|
|
|
406
|
+
### Encrypted collections (EDV-over-WAS)
|
|
407
|
+
|
|
408
|
+
Client-side end-to-end encryption, where the server stores only opaque
|
|
409
|
+
ciphertext and the keys never leave the client. This is the "EDV-over-WAS"
|
|
410
|
+
layout profile (Layer 1): it maps
|
|
411
|
+
[Encrypted Data Vault](https://digitalbazaar.github.io/encrypted-data-vaults/)
|
|
412
|
+
documents onto ordinary WAS resources, so it works against **any** WAS server
|
|
413
|
+
with no server changes. It is shipped on the opt-in `@interop/was-client/edv`
|
|
414
|
+
subpath so plaintext consumers do not pull the crypto dependencies.
|
|
415
|
+
|
|
416
|
+
`WasTransport` is an `@interop/edv-client` `Transport`: pair it with
|
|
417
|
+
`EdvClientCore`, which does all encryption, decryption, and key handling
|
|
418
|
+
client-side. The WAS Collection is the vault; each encrypted document is one WAS
|
|
419
|
+
resource (its EDV id is used verbatim as the resource id).
|
|
420
|
+
|
|
421
|
+
This example assumes a WAS server is already running and you have created (or
|
|
422
|
+
have access to) a collection to use as the vault:
|
|
423
|
+
|
|
424
|
+
```ts
|
|
425
|
+
import { WasClient } from '@interop/was-client'
|
|
426
|
+
import { WasTransport } from '@interop/was-client/edv'
|
|
427
|
+
import { EdvClientCore } from '@interop/edv-client'
|
|
428
|
+
import { X25519KeyAgreementKey2020 } from '@interop/x25519-key-agreement-key'
|
|
429
|
+
|
|
430
|
+
const was = WasClient.fromSigner({ serverUrl, signer })
|
|
431
|
+
const space = await was.createSpace({ name: 'My Wallet' })
|
|
432
|
+
const collection = await space.createCollection({ id: 'vault', name: 'Vault' })
|
|
433
|
+
|
|
434
|
+
// Client-side key material (never sent to the server). In a real app these come
|
|
435
|
+
// from the wallet's key store; here we generate a key-agreement key.
|
|
436
|
+
const kak = await X25519KeyAgreementKey2020.generate({
|
|
437
|
+
controller: was.controllerDid
|
|
438
|
+
})
|
|
439
|
+
const keyResolver = async ({ id }: { id: string }) => {
|
|
440
|
+
if (id !== kak.id) throw new Error(`Unknown key id "${id}".`)
|
|
441
|
+
return {
|
|
442
|
+
id: kak.id,
|
|
443
|
+
type: kak.type,
|
|
444
|
+
publicKeyMultibase: kak.publicKeyMultibase
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const edv = new EdvClientCore({ keyAgreementKey: kak, keyResolver })
|
|
449
|
+
const transport = new WasTransport({
|
|
450
|
+
was,
|
|
451
|
+
spaceId: space.id,
|
|
452
|
+
collectionId: collection.id
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
// Encrypt + write: the server stores a JWE envelope, not the cleartext.
|
|
456
|
+
const doc = await edv.insert({ doc: { content: { secret: 42 } }, transport })
|
|
457
|
+
|
|
458
|
+
// Read + decrypt:
|
|
459
|
+
const decrypted = await edv.get({ id: doc.id, transport })
|
|
460
|
+
console.log(decrypted.content) // { secret: 42 }
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Scope and caveats (this is the first, documents-only increment):
|
|
464
|
+
|
|
465
|
+
- **Documents only.** `insert` / `update` / `get` are supported. Blinded `find`
|
|
466
|
+
/ `count` / index updates and chunked blob streams throw -- they need
|
|
467
|
+
server-side EDV affordances (a blinded `/query` endpoint, the
|
|
468
|
+
`/{id}/chunks/{n}` sub-segment) a plaintext WAS server does not provide.
|
|
469
|
+
- **Advisory `sequence`.** Without server-side conditional writes, a stale
|
|
470
|
+
`update` is not rejected (last-writer-wins). Safe for single-writer use.
|
|
471
|
+
- **Content type.** Envelopes are stored as `application/json` by default so any
|
|
472
|
+
WAS server accepts them. The preferred marker `application/edv+json` (exported
|
|
473
|
+
as `EDV_CONTENT_TYPE`) needs the server to register an `application/*+json`
|
|
474
|
+
content-type parser -- the reference was-teaching-server does; pass
|
|
475
|
+
`contentType: EDV_CONTENT_TYPE` to opt in.
|
|
476
|
+
|
|
390
477
|
### The manual-request escape hatch
|
|
391
478
|
|
|
392
479
|
`was.request(...)` mirrors ezcap's generic `request()` for hand-built calls. As
|
|
@@ -425,8 +512,8 @@ a 507 `quota-exceeded` (a client-actionable storage-full condition, not a server
|
|
|
425
512
|
fault) as a `QuotaExceededError`. `delete()` additionally treats a 404 as
|
|
426
513
|
success, so it is idempotent.
|
|
427
514
|
|
|
428
|
-
|
|
429
|
-
|
|
515
|
+
Spec endpoints a given server has not yet implemented surface as
|
|
516
|
+
`NotImplementedError` (the server's 501).
|
|
430
517
|
|
|
431
518
|
## Contribute
|
|
432
519
|
|
package/dist/Collection.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ClientContext } from './internal/request.js';
|
|
2
2
|
import { Resource } from './Resource.js';
|
|
3
|
-
import type { AddResult, BackendReference, CollectionDescription, GrantOptions, HandleOptions, IDelegatedZcap, IZcap, Json, LinkSet, PolicyDocument, CollectionResourcesList } from './types.js';
|
|
3
|
+
import type { AddResult, BackendDescriptor, BackendReference, BackendUsage, CollectionDescription, GrantOptions, HandleOptions, IDelegatedZcap, IZcap, Json, LinkSet, PolicyDocument, CollectionResourcesList } from './types.js';
|
|
4
4
|
export declare class Collection {
|
|
5
5
|
readonly spaceId: string;
|
|
6
6
|
readonly id: string;
|
|
@@ -152,5 +152,23 @@ export declare class Collection {
|
|
|
152
152
|
* @returns {Promise<LinkSet | null>}
|
|
153
153
|
*/
|
|
154
154
|
linkset(): Promise<LinkSet | null>;
|
|
155
|
+
/**
|
|
156
|
+
* Reads the storage backend this collection is stored on ("Collection Backend
|
|
157
|
+
* Selected"). Returns `null` if the collection is missing or not visible to
|
|
158
|
+
* you (404 conflation caveat). A server without backend support surfaces its
|
|
159
|
+
* 501 as `NotImplementedError`.
|
|
160
|
+
*
|
|
161
|
+
* @returns {Promise<BackendDescriptor | null>}
|
|
162
|
+
*/
|
|
163
|
+
backend(): Promise<BackendDescriptor | null>;
|
|
164
|
+
/**
|
|
165
|
+
* Reads the collection's storage usage report, scoped to its backend (spec
|
|
166
|
+
* "Quotas"). Returns `null` if the collection is missing or not visible to you
|
|
167
|
+
* (404 conflation caveat). A backend that cannot account per-collection
|
|
168
|
+
* surfaces its 501 as `NotImplementedError`.
|
|
169
|
+
*
|
|
170
|
+
* @returns {Promise<BackendUsage | null>}
|
|
171
|
+
*/
|
|
172
|
+
quota(): Promise<BackendUsage | null>;
|
|
155
173
|
}
|
|
156
174
|
//# sourceMappingURL=Collection.d.ts.map
|
package/dist/Collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,KAAK,EACL,IAAI,EACJ,OAAO,EACP,cAAc,EACd,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAEnB,qBAAa,UAAU;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAO;IAEpC;;;;;;;OAOG;gBACS,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACX,EAAE;QACD,OAAO,EAAE,aAAa,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;QACpB,UAAU,CAAC,EAAE,KAAK,CAAA;KACnB;IAOD,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,UAAU,GAErB;IAED;;;;;;OAMG;IACG,QAAQ,IAAI,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAUvD;;;;;;;;OAQG;IACG,SAAS,CAAC,IAAI,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AI,CAAC;IASlC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAUxC;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAUlD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAS5C"}
|
package/dist/Collection.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* lifecycle (`describe`/`configure`/`delete`) and contained-resource operations
|
|
7
7
|
* (`add`/`get`/`put`/`list`, plus `resource(id)` for delete-by-id).
|
|
8
8
|
*/
|
|
9
|
-
import { collectionPath, collectionItems, collectionPolicy, collectionLinkset, resourcePath, toUrl } from './internal/paths.js';
|
|
9
|
+
import { collectionPath, collectionItems, collectionPolicy, collectionLinkset, collectionBackend, collectionQuota, resourcePath, toUrl } from './internal/paths.js';
|
|
10
10
|
import { prepareBody, parseResource } from './internal/content.js';
|
|
11
11
|
import { assertNotReserved } from './internal/reserved.js';
|
|
12
12
|
import { delegateGrant } from './internal/grant.js';
|
|
@@ -286,5 +286,39 @@ export class Collection {
|
|
|
286
286
|
});
|
|
287
287
|
return response === null ? null : response.data;
|
|
288
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Reads the storage backend this collection is stored on ("Collection Backend
|
|
291
|
+
* Selected"). Returns `null` if the collection is missing or not visible to
|
|
292
|
+
* you (404 conflation caveat). A server without backend support surfaces its
|
|
293
|
+
* 501 as `NotImplementedError`.
|
|
294
|
+
*
|
|
295
|
+
* @returns {Promise<BackendDescriptor | null>}
|
|
296
|
+
*/
|
|
297
|
+
async backend() {
|
|
298
|
+
const response = await send(this._context, {
|
|
299
|
+
path: collectionBackend(this.spaceId, this.id),
|
|
300
|
+
method: 'GET',
|
|
301
|
+
capability: this._capability,
|
|
302
|
+
read: true
|
|
303
|
+
});
|
|
304
|
+
return response === null ? null : response.data;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Reads the collection's storage usage report, scoped to its backend (spec
|
|
308
|
+
* "Quotas"). Returns `null` if the collection is missing or not visible to you
|
|
309
|
+
* (404 conflation caveat). A backend that cannot account per-collection
|
|
310
|
+
* surfaces its 501 as `NotImplementedError`.
|
|
311
|
+
*
|
|
312
|
+
* @returns {Promise<BackendUsage | null>}
|
|
313
|
+
*/
|
|
314
|
+
async quota() {
|
|
315
|
+
const response = await send(this._context, {
|
|
316
|
+
path: collectionQuota(this.spaceId, this.id),
|
|
317
|
+
method: 'GET',
|
|
318
|
+
capability: this._capability,
|
|
319
|
+
read: true
|
|
320
|
+
});
|
|
321
|
+
return response === null ? null : response.data;
|
|
322
|
+
}
|
|
289
323
|
}
|
|
290
324
|
//# sourceMappingURL=Collection.js.map
|
package/dist/Collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,KAAK,EACN,MAAM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F"}
|
package/dist/Resource.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ export declare class Resource {
|
|
|
49
49
|
* objects/arrays, binary for `Blob`/`Uint8Array`. Throws `NotFoundError` if
|
|
50
50
|
* the parent collection does not exist (WAS does not auto-create parents).
|
|
51
51
|
*
|
|
52
|
+
* For binary data with no explicit `contentType` (and no `Blob.type`), the
|
|
53
|
+
* content-type is guessed from the resource id's file extension for common
|
|
54
|
+
* static-web types -- so `resource('index.html').put(bytes)` is sent as
|
|
55
|
+
* `text/html`. An unrecognized/absent extension sends no content-type, and the
|
|
56
|
+
* server applies its own required-`Content-Type` rule.
|
|
57
|
+
*
|
|
52
58
|
* @param data {Json | Blob | Uint8Array}
|
|
53
59
|
* @param options {object}
|
|
54
60
|
* @param [options.contentType] {string} content-type for binary data
|
package/dist/Resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAEnB,qBAAa,QAAQ;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAO;IAEpC;;;;;;;OAOG;gBACS,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,UAAU,EACX,EAAE;QACD,OAAO,EAAE,aAAa,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;QACpB,UAAU,EAAE,M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|
|
89
89
|
* the parent collection does not exist (WAS does not auto-create parents).
|
|
90
90
|
*
|
|
91
|
+
* For binary data with no explicit `contentType` (and no `Blob.type`), the
|
|
92
|
+
* content-type is guessed from the resource id's file extension for common
|
|
93
|
+
* static-web types -- so `resource('index.html').put(bytes)` is sent as
|
|
94
|
+
* `text/html`. An unrecognized/absent extension sends no content-type, and the
|
|
95
|
+
* server applies its own required-`Content-Type` rule.
|
|
96
|
+
*
|
|
91
97
|
* @param data {Json | Blob | Uint8Array}
|
|
92
98
|
* @param options {object}
|
|
93
99
|
* @param [options.contentType] {string} content-type for binary data
|
|
@@ -95,7 +101,7 @@ export class Resource {
|
|
|
95
101
|
*/
|
|
96
102
|
async put(data, options = {}) {
|
|
97
103
|
assertNotReserved(this.id, 'resource');
|
|
98
|
-
const prepared = prepareBody(data, options);
|
|
104
|
+
const prepared = prepareBody(data, { ...options, filename: this.id });
|
|
99
105
|
await send(this._context, {
|
|
100
106
|
path: this._path,
|
|
101
107
|
method: 'PUT',
|
package/dist/Resource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAS5C,MAAM,OAAO,QAAQ;IACV,OAAO,CAAQ;IACf,YAAY,CAAQ;IACpB,EAAE,CAAQ;IAEF,QAAQ,CAAe;IACvB,WAAW,CAAQ;IAEpC;;;;;;;OAOG;IACH,YAAY,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,UAAU,EAOX;QACC,IAA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AAI,EAAE,IAAI,CAAC,WAAW;YACtB,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,IAAI,EAAE,MAAM;SACb,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;QACrC,OAAO,MAAM,EAAE,IAAI,KAAK,eAAe,CAAA;IACzC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACxB,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/WasClient.d.ts
CHANGED
|
@@ -75,9 +75,12 @@ export declare class WasClient {
|
|
|
75
75
|
controller?: string;
|
|
76
76
|
}): Promise<Space>;
|
|
77
77
|
/**
|
|
78
|
-
* Lists the spaces in the repository
|
|
79
|
-
*
|
|
80
|
-
*
|
|
78
|
+
* Lists the spaces in the repository visible to the wrapped signer, as a
|
|
79
|
+
* `{ url, totalItems, items }` listing. Visibility is per-controller: the
|
|
80
|
+
* result holds only the spaces whose controller the signed invocation is
|
|
81
|
+
* authorized for. An unauthorized caller is not an error -- the server
|
|
82
|
+
* returns an empty `items` list (the spec's explicit exception to 404
|
|
83
|
+
* masking), so nothing is revealed about which spaces exist.
|
|
81
84
|
*
|
|
82
85
|
* @returns {Promise<SpaceListing>}
|
|
83
86
|
*/
|
package/dist/WasClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAC7D,OAAO,CAAC,KAAK,CAAC;IAkBjB;;;;;;;;;OASG;IACG,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC;IAQzC;;;;;;;;;OASG;IACG,UAAU,CAAC,EACf,WAAW,EACZ,EAAE;QACD,WAAW,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAS/B;;;;;;;;;OASG;IACG,oBAAoB,CAAC,EACzB,aAAa,EACd,EAAE;QACD,aAAa,EAAE,MAAM,CAAA;KACtB,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAY3C;;;;;;;OAOG;IACH,cAAc,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ;IAmC1D;;;;;;;;OAQG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAI3D;;;;;;;;OAQG;IACG,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;CAG5D"}
|
package/dist/WasClient.js
CHANGED
|
@@ -13,7 +13,7 @@ import { ZcapClient } from '@interop/ezcap';
|
|
|
13
13
|
import { Ed25519Signature2020 } from '@interop/ed25519-signature';
|
|
14
14
|
import { spacesRoot } from './internal/paths.js';
|
|
15
15
|
import { send, rawRequest, unsignedRequest } from './internal/request.js';
|
|
16
|
-
import { parseResource } from './internal/content.js';
|
|
16
|
+
import { parseResource, readJsonData } from './internal/content.js';
|
|
17
17
|
import { delegateGrant } from './internal/grant.js';
|
|
18
18
|
import { ValidationError } from './errors.js';
|
|
19
19
|
import { Space } from './Space.js';
|
|
@@ -113,9 +113,12 @@ export class WasClient {
|
|
|
113
113
|
return this.space(created.id);
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
-
* Lists the spaces in the repository
|
|
117
|
-
*
|
|
118
|
-
*
|
|
116
|
+
* Lists the spaces in the repository visible to the wrapped signer, as a
|
|
117
|
+
* `{ url, totalItems, items }` listing. Visibility is per-controller: the
|
|
118
|
+
* result holds only the spaces whose controller the signed invocation is
|
|
119
|
+
* authorized for. An unauthorized caller is not an error -- the server
|
|
120
|
+
* returns an empty `items` list (the spec's explicit exception to 404
|
|
121
|
+
* masking), so nothing is revealed about which spaces exist.
|
|
119
122
|
*
|
|
120
123
|
* @returns {Promise<SpaceListing>}
|
|
121
124
|
*/
|
|
@@ -163,7 +166,7 @@ export class WasClient {
|
|
|
163
166
|
if (response === null) {
|
|
164
167
|
return null;
|
|
165
168
|
}
|
|
166
|
-
return (
|
|
169
|
+
return (await readJsonData(response));
|
|
167
170
|
}
|
|
168
171
|
/**
|
|
169
172
|
* Rebuilds an access handle from a received capability, returning a handle at
|
package/dist/WasClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasClient.js","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"WasClient.js","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,IAAI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AAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,eAAe,CACvB,qBAAqB,IAAI,CAAC,gBAAgB,oBAAoB,CAC/D,CAAA;QACH,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,IAAI,QAAQ,CAAC;gBAClB,OAAO;gBACP,OAAO;gBACP,YAAY,EAAE,YAAsB;gBACpC,UAAU;gBACV,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,IAAI,UAAU,CAAC;gBACpB,OAAO;gBACP,OAAO;gBACP,YAAY;gBACZ,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,CAAC,OAAqB;QACjC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* An `@interop/edv-client` `Transport` that maps Encrypted Data Vault (EDV)
|
|
6
|
+
* document operations onto ordinary WAS Resource CRUD -- the "EDV-over-WAS"
|
|
7
|
+
* layout profile (Layer 1). It is paired with `EdvClientCore`, which does all
|
|
8
|
+
* encryption, decryption, and index blinding client-side; this transport only
|
|
9
|
+
* moves opaque JWE documents to and from a WAS server, reusing the client's
|
|
10
|
+
* zcap-signed request layer (`WasClient.request()`). Keys never reach the
|
|
11
|
+
* server.
|
|
12
|
+
*
|
|
13
|
+
* Profile decisions encoded here:
|
|
14
|
+
*
|
|
15
|
+
* - **Vault per Collection.** The WAS Collection is the EDV vault; each
|
|
16
|
+
* encrypted document is one WAS Resource.
|
|
17
|
+
* - **Restrict-mode ids.** The WAS resource id IS the EDV document id (the
|
|
18
|
+
* 128-bit multibase value `EdvClientCore.generateId()` produces), which is
|
|
19
|
+
* URL-safe and never a reserved segment.
|
|
20
|
+
* - **Encrypted content type.** Documents are stored as `application/json` by
|
|
21
|
+
* default, so the profile works against an unmodified WAS server. The
|
|
22
|
+
* preferred marker is `application/edv+json` (exported as `EDV_CONTENT_TYPE`),
|
|
23
|
+
* which distinguishes EDV envelopes from plaintext application JSON in
|
|
24
|
+
* listings and metadata -- but the server must register an `application/*+json`
|
|
25
|
+
* content-type parser to accept it (the reference was-teaching-server does; a
|
|
26
|
+
* server that does not will reject it with 415). Pass `contentType:
|
|
27
|
+
* EDV_CONTENT_TYPE` to opt into it where the server supports it.
|
|
28
|
+
*
|
|
29
|
+
* Scope: documents only (`insert` / `update` / `get`). Blinded `find` / `count`
|
|
30
|
+
* / `updateIndex` and chunked streams (`storeChunk` / `getChunk`) require
|
|
31
|
+
* server-side EDV affordances (blinded `/query`, the `/{id}/chunks/{n}`
|
|
32
|
+
* sub-segment, conditional writes) that a plaintext WAS server does not yet
|
|
33
|
+
* provide, so they throw here. Because there are no conditional writes, the EDV
|
|
34
|
+
* `sequence` is advisory (last-writer-wins on `update`).
|
|
35
|
+
*/
|
|
36
|
+
import { Transport } from '@interop/edv-client';
|
|
37
|
+
import type { IEncryptedDocument } from '@interop/data-integrity-core';
|
|
38
|
+
import type { WasClient } from '../WasClient.js';
|
|
39
|
+
/**
|
|
40
|
+
* The preferred content type marking a stored EDV-encrypted document (a JSON
|
|
41
|
+
* envelope whose `jwe` property carries the ciphertext). Requires the server to
|
|
42
|
+
* register an `application/*+json` content-type parser; otherwise use the
|
|
43
|
+
* default `application/json` (see `WasTransport`'s `contentType` option).
|
|
44
|
+
*/
|
|
45
|
+
export declare const EDV_CONTENT_TYPE = "application/edv+json";
|
|
46
|
+
/**
|
|
47
|
+
* The subset of `WasClient` this transport depends on: the signed-request
|
|
48
|
+
* escape hatch. Declared structurally so tests can supply a lightweight stub.
|
|
49
|
+
*/
|
|
50
|
+
type WasRequester = Pick<WasClient, 'request'>;
|
|
51
|
+
export declare class WasTransport extends Transport {
|
|
52
|
+
readonly spaceId: string;
|
|
53
|
+
readonly collectionId: string;
|
|
54
|
+
readonly contentType: string;
|
|
55
|
+
private readonly _was;
|
|
56
|
+
/**
|
|
57
|
+
* @param options {object}
|
|
58
|
+
* @param options.was {WasClient} a WAS client holding the signer
|
|
59
|
+
* @param options.spaceId {string} the vault's Space id
|
|
60
|
+
* @param options.collectionId {string} the vault Collection id
|
|
61
|
+
* @param [options.contentType] {string} content type for stored envelopes;
|
|
62
|
+
* defaults to `application/json` (accepted by an unmodified server). Pass
|
|
63
|
+
* `EDV_CONTENT_TYPE` against a server that registers an `application/*+json`
|
|
64
|
+
* parser.
|
|
65
|
+
*/
|
|
66
|
+
constructor({ was, spaceId, collectionId, contentType }: {
|
|
67
|
+
was: WasRequester;
|
|
68
|
+
spaceId: string;
|
|
69
|
+
collectionId: string;
|
|
70
|
+
contentType?: string;
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* The WAS resource path for a document id, delegating to was-client's
|
|
74
|
+
* internal `resourcePath` builder so the percent-encoding and trailing-slash
|
|
75
|
+
* rules stay defined in one place (no trailing slash -- get/put/delete by
|
|
76
|
+
* id).
|
|
77
|
+
*
|
|
78
|
+
* @param id {string} the EDV document id (= WAS resource id)
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
private _resourcePath;
|
|
82
|
+
/**
|
|
83
|
+
* Writes an encrypted document to its WAS resource path as
|
|
84
|
+
* `application/edv+json` (the envelope serialized to bytes so the stored
|
|
85
|
+
* content type is exact).
|
|
86
|
+
*
|
|
87
|
+
* @param id {string}
|
|
88
|
+
* @param encrypted {IEncryptedDocument}
|
|
89
|
+
* @returns {Promise<HttpResponse>}
|
|
90
|
+
*/
|
|
91
|
+
private _put;
|
|
92
|
+
/**
|
|
93
|
+
* @inheritdoc
|
|
94
|
+
*
|
|
95
|
+
* Inserts a new encrypted document. WAS `PUT` is an upsert, so to preserve
|
|
96
|
+
* EDV insert semantics (`DuplicateError` if the id already exists) this first
|
|
97
|
+
* checks for an existing resource. The check + write is not atomic -- with no
|
|
98
|
+
* server-side conditional writes yet, this is an advisory, single-writer
|
|
99
|
+
* guard.
|
|
100
|
+
*
|
|
101
|
+
* @param options {object}
|
|
102
|
+
* @param options.encrypted {IEncryptedDocument} the document to insert
|
|
103
|
+
* @returns {Promise<void>}
|
|
104
|
+
*/
|
|
105
|
+
insert({ encrypted }?: {
|
|
106
|
+
encrypted?: IEncryptedDocument;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* @inheritdoc
|
|
110
|
+
*
|
|
111
|
+
* Updates (upserts) an encrypted document. The EDV `sequence` is advisory
|
|
112
|
+
* here -- without server-side conditional writes, a stale write is not
|
|
113
|
+
* rejected (last-writer-wins).
|
|
114
|
+
*
|
|
115
|
+
* @param options {object}
|
|
116
|
+
* @param options.encrypted {IEncryptedDocument} the document to update
|
|
117
|
+
* @returns {Promise<void>}
|
|
118
|
+
*/
|
|
119
|
+
update({ encrypted }?: {
|
|
120
|
+
encrypted?: IEncryptedDocument;
|
|
121
|
+
}): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* @inheritdoc
|
|
124
|
+
*
|
|
125
|
+
* Reads an encrypted document by id. Throws a `NotFoundError` (the name
|
|
126
|
+
* `EdvClientCore` expects) when the resource is missing or not visible.
|
|
127
|
+
*
|
|
128
|
+
* @param options {object}
|
|
129
|
+
* @param options.id {string} the document id to read
|
|
130
|
+
* @returns {Promise<IEncryptedDocument>}
|
|
131
|
+
*/
|
|
132
|
+
get({ id }?: {
|
|
133
|
+
id?: string;
|
|
134
|
+
}): Promise<IEncryptedDocument>;
|
|
135
|
+
/**
|
|
136
|
+
* Resolves to `true` if a resource exists at the document's path. A 404
|
|
137
|
+
* resolves to `false`; any other error propagates.
|
|
138
|
+
*
|
|
139
|
+
* @param id {string}
|
|
140
|
+
* @returns {Promise<boolean>}
|
|
141
|
+
*/
|
|
142
|
+
private _exists;
|
|
143
|
+
/**
|
|
144
|
+
* @inheritdoc
|
|
145
|
+
*
|
|
146
|
+
* Blinded-index query is not part of the documents-only EDV-over-WAS profile;
|
|
147
|
+
* it needs the server's `/query` affordance.
|
|
148
|
+
*/
|
|
149
|
+
find(): Promise<never>;
|
|
150
|
+
/**
|
|
151
|
+
* @inheritdoc
|
|
152
|
+
*
|
|
153
|
+
* Index updates need the server's `/{id}/index` affordance.
|
|
154
|
+
*/
|
|
155
|
+
updateIndex(): Promise<never>;
|
|
156
|
+
/**
|
|
157
|
+
* @inheritdoc
|
|
158
|
+
*
|
|
159
|
+
* Chunked streams need the reserved `/{id}/chunks/{n}` sub-segment.
|
|
160
|
+
*/
|
|
161
|
+
storeChunk(): Promise<never>;
|
|
162
|
+
/**
|
|
163
|
+
* @inheritdoc
|
|
164
|
+
*
|
|
165
|
+
* Chunked streams need the reserved `/{id}/chunks/{n}` sub-segment.
|
|
166
|
+
*/
|
|
167
|
+
getChunk(): Promise<never>;
|
|
168
|
+
/**
|
|
169
|
+
* Throws a uniform "not supported in this profile" error for EDV operations
|
|
170
|
+
* that depend on server-side affordances absent from a plaintext WAS server.
|
|
171
|
+
*
|
|
172
|
+
* @param operation {string}
|
|
173
|
+
* @returns {never}
|
|
174
|
+
*/
|
|
175
|
+
private _unsupported;
|
|
176
|
+
}
|
|
177
|
+
export {};
|
|
178
|
+
//# sourceMappingURL=WasTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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