@interop/was-client 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +117 -88
  2. package/dist/Collection.d.ts +17 -4
  3. package/dist/Collection.d.ts.map +1 -1
  4. package/dist/Collection.js +26 -10
  5. package/dist/Collection.js.map +1 -1
  6. package/dist/Resource.d.ts +12 -3
  7. package/dist/Resource.d.ts.map +1 -1
  8. package/dist/Resource.js +19 -3
  9. package/dist/Resource.js.map +1 -1
  10. package/dist/Space.d.ts +56 -1
  11. package/dist/Space.d.ts.map +1 -1
  12. package/dist/Space.js +91 -3
  13. package/dist/Space.js.map +1 -1
  14. package/dist/WasClient.d.ts +7 -3
  15. package/dist/WasClient.d.ts.map +1 -1
  16. package/dist/WasClient.js +7 -3
  17. package/dist/WasClient.js.map +1 -1
  18. package/dist/codec.d.ts +34 -13
  19. package/dist/codec.d.ts.map +1 -1
  20. package/dist/edv/EdvCodec.d.ts +21 -11
  21. package/dist/edv/EdvCodec.d.ts.map +1 -1
  22. package/dist/edv/EdvCodec.js +28 -13
  23. package/dist/edv/EdvCodec.js.map +1 -1
  24. package/dist/edv/index.d.ts +5 -4
  25. package/dist/edv/index.d.ts.map +1 -1
  26. package/dist/edv/index.js +4 -4
  27. package/dist/edv/index.js.map +1 -1
  28. package/dist/errors.d.ts +12 -0
  29. package/dist/errors.d.ts.map +1 -1
  30. package/dist/errors.js +16 -0
  31. package/dist/errors.js.map +1 -1
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/internal/codec.d.ts +14 -5
  37. package/dist/internal/codec.d.ts.map +1 -1
  38. package/dist/internal/codec.js +70 -9
  39. package/dist/internal/codec.js.map +1 -1
  40. package/dist/internal/describe.d.ts +27 -0
  41. package/dist/internal/describe.d.ts.map +1 -0
  42. package/dist/internal/describe.js +23 -0
  43. package/dist/internal/describe.js.map +1 -0
  44. package/dist/internal/paths.d.ts +7 -1
  45. package/dist/internal/paths.d.ts.map +1 -1
  46. package/dist/internal/paths.js +9 -1
  47. package/dist/internal/paths.js.map +1 -1
  48. package/dist/types.d.ts +26 -1
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +4 -4
package/README.md CHANGED
@@ -21,7 +21,8 @@
21
21
  - [Resource metadata](#resource-metadata)
22
22
  - [Conditional writes (optimistic concurrency)](#conditional-writes-optimistic-concurrency)
23
23
  - [Storage introspection: backends and quotas](#storage-introspection-backends-and-quotas)
24
- - [Encrypted collections (EDV-over-WAS)](#encrypted-collections-edv-over-was)
24
+ - [Registering a Bring-Your-Own-Storage backend](#registering-a-bring-your-own-storage-backend)
25
+ - [Encrypted collections (EDV-over-WAS): pass-through encryption via the WAS client (recommended)](#encrypted-collections-edv-over-was-pass-through-encryption-via-the-was-client-recommended)
25
26
  - [Export and import](#export-and-import)
26
27
  - [The manual-request escape hatch](#the-manual-request-escape-hatch)
27
28
  - [Errors and the 404/null caveat](#errors-and-the-404null-caveat)
@@ -440,38 +441,137 @@ if (backend?.features?.includes('conditional-writes')) {
440
441
  }
441
442
  ```
442
443
 
443
- ### Encrypted collections (EDV-over-WAS)
444
+ ### Registering a Bring-Your-Own-Storage backend
444
445
 
445
- Client-side end-to-end encryption is a per-collection concern, gated on whether
446
- your client holds keys for the collection -- **not** a backend feature (an
447
- encrypted document is opaque JSON any document backend stores faithfully).
448
- Construct a `WasClient` with an `encryption` provider (built from the opt-in
449
- `@interop/was-client/edv` subpath, so plaintext consumers never pull the crypto
450
- graph), and the ordinary `Collection`/`Resource` handles transparently encrypt
451
- on write and decrypt on read -- for any collection your `resolveKeys` returns
452
- keys for. Keys live in your wallet; the server only ever stores opaque JWE
453
- envelopes.
446
+ Beyond the server's built-in `default` backend, the Space controller can
447
+ register an `external` ("Bring Your Own Storage") backend -- e.g. a wallet
448
+ connecting a user's own Google Drive. Registration is a controller-authorized
449
+ write: the body carries the secret-bearing `connection` material (an OAuth
450
+ authorization code or refresh token), and the server stores it and returns the
451
+ **sanitized** descriptor (never the secrets).
452
+
453
+ ```ts
454
+ const descriptor = await space.registerBackend({
455
+ id: 'gdrive-personal', // unique within the Space
456
+ name: 'My Google Drive',
457
+ provider: 'google-drive', // selects the server-side adapter
458
+ storageMode: ['document', 'blob'],
459
+ connection: {
460
+ kind: 'oauth2-google',
461
+ authorizationCode: '4/0Ab...', // one-time PKCE code (or a refreshToken)
462
+ redirectUri: 'https://wallet.example/oauth/callback'
463
+ }
464
+ })
465
+ // descriptor.connection: { kind, status: 'registered', account?, scope?, ... }
466
+ ```
467
+
468
+ Once registered, select it on a Collection by id; reads of the backend reflect
469
+ its connection `status` (`registered` | `connected` | `expired` | `revoked` |
470
+ `unreachable`), which a storage-management UI uses to prompt re-consent:
471
+
472
+ ```ts
473
+ await space.createCollection({
474
+ id: 'photos',
475
+ backend: { id: 'gdrive-personal' }
476
+ })
477
+
478
+ const [, gdrive] = (await space.backends()) ?? []
479
+ if (gdrive?.connection?.status === 'expired') {
480
+ // re-consent: swap in fresh connection material (create-or-replace by id)
481
+ await space.updateBackend({
482
+ id: 'gdrive-personal',
483
+ provider: 'google-drive',
484
+ connection: { kind: 'oauth2-google', authorizationCode: '4/0Cd...' }
485
+ })
486
+ }
487
+
488
+ // Deregister (idempotent): forgets the record and its stored connection.
489
+ await space.deregisterBackend('gdrive-personal')
490
+ ```
491
+
492
+ `registerBackend()` throws a `ConflictError` if the `id` already exists or the
493
+ server does not permit the `provider`; `updateBackend()` returns the descriptor
494
+ when it created a record and `null` when it replaced one in place (the server
495
+ sends no body on an in-place replace).
496
+
497
+ > A registered backend's record exists immediately, but whether its connection
498
+ > can actually serve bytes depends on the server having a live provider adapter
499
+ > for it. Until then it is registered but inert (`status: 'registered'`).
500
+
501
+ ### Encrypted collections (EDV-over-WAS): pass-through encryption via the WAS client (recommended)
502
+
503
+ This is the recommended way to use encrypted collections. For the low-level
504
+ alternative -- driving an `EdvClientCore` directly via `WasTransport` -- see
505
+ [docs/edv-client-core-usage.md](docs/edv-client-core-usage.md).
506
+
507
+ Client-side end-to-end encryption is a per-collection concern -- **not** a
508
+ backend feature (an encrypted document is opaque JSON any document backend
509
+ stores faithfully). Two things drive it, kept separate:
510
+
511
+ - **Policy** (is this collection encrypted?) is declared on the collection
512
+ itself: `createCollection({ encryption: { scheme: 'edv' } })` writes a
513
+ non-secret `encryption` marker to the Collection Description. Any authorized
514
+ reader -- including a delegated consumer that did **not** create the
515
+ collection -- discovers it by reading the Description, so it knows to decrypt.
516
+ - **Keys** come from an `encryption` provider you pass to `WasClient` (built
517
+ from the opt-in `@interop/was-client/edv` subpath, so plaintext consumers
518
+ never pull the crypto graph). It is a pure **keystore**: `resolveKeys` returns
519
+ the collection's keys, which live in your wallet. The server only ever stores
520
+ opaque JWE envelopes.
521
+
522
+ The ordinary `Collection`/`Resource` handles then transparently encrypt on write
523
+ and decrypt on read for any collection the marker (or an override) declares
524
+ encrypted.
454
525
 
455
526
  ```ts
456
527
  import { WasClient } from '@interop/was-client'
457
528
  import { createEdvEncryption } from '@interop/was-client/edv'
458
529
 
459
530
  const encryption = createEdvEncryption({
460
- // Return the collection's keys to encrypt it, or null to use it in plaintext.
531
+ // The keystore: return the collection's keys (from your wallet).
461
532
  async resolveKeys({ spaceId, collectionId }) {
462
- return { keyAgreementKey, keyResolver } // from your wallet
533
+ return { keyAgreementKey, keyResolver }
463
534
  }
464
535
  })
465
536
  const was = WasClient.fromSigner({ serverUrl, signer, encryption })
466
537
 
467
- const vault = was.space(spaceId).collection('vault')
538
+ // Declare the collection encrypted (writes the marker). The returned handle is
539
+ // pre-seeded, so the first write encrypts with no extra round-trip.
540
+ const vault = await was
541
+ .space(spaceId)
542
+ .createCollection({ id: 'vault', encryption: { scheme: 'edv' } })
468
543
  const { id } = await vault.add({ secret: 'hello' }) // encrypted; id is an EDV id
469
544
  const back = await vault.get(id) // { secret: 'hello' } -- decrypted
545
+
546
+ // A consumer that did not create it discovers the marker and decrypts with its
547
+ // own keys -- no override needed; one cached read of the Description:
548
+ const same = was.space(spaceId).collection('vault')
549
+ await same.get(id) // reads the marker, then decrypts
470
550
  ```
471
551
 
472
- The switch is **keys**: a handle encrypts a collection exactly when
473
- `resolveKeys` returns keys for it (else it stays plaintext). Resolution happens
474
- once per collection handle and is cached -- no backend round-trip.
552
+ The switch is the **marker**: a handle encrypts a collection when its
553
+ Description declares `encryption` (resolution reads the Description once, then
554
+ caches -- no round-trip for plaintext-only clients or when an override is set).
555
+ Keys are then **required**: if the collection is declared encrypted but your
556
+ keystore returns no keys, reads/writes throw `EncryptionError` (fail-closed) --
557
+ they never silently fall back to plaintext.
558
+
559
+ **Per-handle override (escape hatch).** Pass `encryption` in the handle options
560
+ to force the decision and skip the Description read -- `{ scheme: 'edv' }` (keys
561
+ from the keystore), `{ scheme: 'edv', keys }` (keys inline), or `'plaintext'`:
562
+
563
+ ```ts
564
+ const vault = was.space(spaceId).collection('vault', {
565
+ encryption: { scheme: 'edv' }
566
+ })
567
+ ```
568
+
569
+ **Migrating a pre-marker vault** (created before the marker existed, keys-only):
570
+ re-declare it once with
571
+ `collection.configure({ encryption: { scheme: 'edv' } })` (the marker is
572
+ set-once: declaring it on a collection that lacks one is allowed, changing or
573
+ clearing an existing one is rejected). Until then, a per-handle override reads
574
+ it correctly.
475
575
 
476
576
  Encrypted collections are a **stricter contract**, not a drop-in (documents-only
477
577
  scope for now):
@@ -497,77 +597,6 @@ const stats = await otherSpace.import(archive)
497
597
  // policiesCreated, policiesSkipped }
498
598
  ```
499
599
 
500
- ### Encrypted collections (EDV-over-WAS)
501
-
502
- Client-side end-to-end encryption, where the server stores only opaque
503
- ciphertext and the keys never leave the client. This is the "EDV-over-WAS"
504
- layout profile (Layer 1): it maps
505
- [Encrypted Data Vault](https://digitalbazaar.github.io/encrypted-data-vaults/)
506
- documents onto ordinary WAS resources, so it works against **any** WAS server
507
- with no server changes. It is shipped on the opt-in `@interop/was-client/edv`
508
- subpath so plaintext consumers do not pull the crypto dependencies.
509
-
510
- `WasTransport` is an `@interop/edv-client` `Transport`: pair it with
511
- `EdvClientCore`, which does all encryption, decryption, and key handling
512
- client-side. The WAS Collection is the vault; each encrypted document is one WAS
513
- resource (its EDV id is used verbatim as the resource id).
514
-
515
- This example assumes a WAS server is already running and you have created (or
516
- have access to) a collection to use as the vault:
517
-
518
- ```ts
519
- import { WasClient } from '@interop/was-client'
520
- import { WasTransport } from '@interop/was-client/edv'
521
- import { EdvClientCore } from '@interop/edv-client'
522
- import { X25519KeyAgreementKey2020 } from '@interop/x25519-key-agreement-key'
523
-
524
- const was = WasClient.fromSigner({ serverUrl, signer })
525
- const space = await was.createSpace({ name: 'My Wallet' })
526
- const collection = await space.createCollection({ id: 'vault', name: 'Vault' })
527
-
528
- // Client-side key material (never sent to the server). In a real app these come
529
- // from the wallet's key store; here we generate a key-agreement key.
530
- const kak = await X25519KeyAgreementKey2020.generate({
531
- controller: was.controllerDid
532
- })
533
- const keyResolver = async ({ id }: { id: string }) => {
534
- if (id !== kak.id) throw new Error(`Unknown key id "${id}".`)
535
- return {
536
- id: kak.id,
537
- type: kak.type,
538
- publicKeyMultibase: kak.publicKeyMultibase
539
- }
540
- }
541
-
542
- const edv = new EdvClientCore({ keyAgreementKey: kak, keyResolver })
543
- const transport = new WasTransport({
544
- was,
545
- spaceId: space.id,
546
- collectionId: collection.id
547
- })
548
-
549
- // Encrypt + write: the server stores a JWE envelope, not the cleartext.
550
- const doc = await edv.insert({ doc: { content: { secret: 42 } }, transport })
551
-
552
- // Read + decrypt:
553
- const decrypted = await edv.get({ id: doc.id, transport })
554
- console.log(decrypted.content) // { secret: 42 }
555
- ```
556
-
557
- Scope and caveats (this is the first, documents-only increment):
558
-
559
- - **Documents only.** `insert` / `update` / `get` are supported. Blinded `find`
560
- / `count` / index updates and chunked blob streams throw -- they need
561
- server-side EDV affordances (a blinded `/query` endpoint, the
562
- `/{id}/chunks/{n}` sub-segment) a plaintext WAS server does not provide.
563
- - **Advisory `sequence`.** Without server-side conditional writes, a stale
564
- `update` is not rejected (last-writer-wins). Safe for single-writer use.
565
- - **Content type.** Envelopes are stored as `application/json` by default so any
566
- WAS server accepts them. The preferred marker `application/edv+json` (exported
567
- as `EDV_CONTENT_TYPE`) needs the server to register an `application/*+json`
568
- content-type parser -- the reference was-teaching-server does; pass
569
- `contentType: EDV_CONTENT_TYPE` to opt in.
570
-
571
600
  ### The manual-request escape hatch
572
601
 
573
602
  `was.request(...)` mirrors ezcap's generic `request()` for hand-built calls. As
@@ -1,11 +1,12 @@
1
1
  import type { ClientContext } from './internal/request.js';
2
2
  import { Resource } from './Resource.js';
3
- import type { AddResult, BackendDescriptor, BackendReference, BackendUsage, CollectionDescription, GrantOptions, HandleOptions, IDelegatedZcap, IZcap, Json, LinkSet, PolicyDocument, CollectionResourcesList } from './types.js';
3
+ import type { AddResult, BackendDescriptor, BackendReference, BackendUsage, CollectionDescription, CollectionEncryption, EncryptionOverride, 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;
7
7
  private readonly _context;
8
8
  private readonly _capability?;
9
+ private readonly _encryptionOverride?;
9
10
  private _codecPromise?;
10
11
  /**
11
12
  * @param options {object}
@@ -14,20 +15,27 @@ export declare class Collection {
14
15
  * @param options.spaceId {string}
15
16
  * @param options.collectionId {string}
16
17
  * @param [options.capability] {IZcap} - capability attached to every request
18
+ * @param [options.encryption] {EncryptionOverride} - per-handle encryption
19
+ * override; wins over the Collection's declared marker and skips the
20
+ * marker-discovery round-trip
17
21
  */
18
- constructor({ context, spaceId, collectionId, capability }: {
22
+ constructor({ context, spaceId, collectionId, capability, encryption }: {
19
23
  context: ClientContext;
20
24
  spaceId: string;
21
25
  collectionId: string;
22
26
  capability?: IZcap;
27
+ encryption?: EncryptionOverride;
23
28
  });
24
29
  private get _path();
25
30
  private get _itemsPath();
26
31
  /**
27
32
  * Resolves (once, then caches) the codec for this collection's reads and
28
33
  * writes: the identity codec for a plaintext collection, or the encrypting
29
- * codec when an `EncryptionProvider` is injected and supplies one for this
30
- * collection (i.e. the client holds keys for it).
34
+ * codec when this collection is declared encrypted -- by a per-handle override
35
+ * or its `encryption` marker -- and the client's keystore supplies its keys.
36
+ * An encrypted collection the client cannot key for fails closed (throws), and
37
+ * the marker read happens at most once per handle (memoized here) -- a fresh
38
+ * handle to the same collection re-reads it, so retain the handle to reuse it.
31
39
  *
32
40
  * @returns {Promise<ResourceCodec>}
33
41
  */
@@ -47,11 +55,16 @@ export declare class Collection {
47
55
  * @param desc {object}
48
56
  * @param [desc.name] {string}
49
57
  * @param [desc.backend] {BackendReference}
58
+ * @param [desc.encryption] {CollectionEncryption} declare the client-side
59
+ * encryption marker. Set-once on the server: it may be added to a Collection
60
+ * that lacks one, but changing/clearing an existing marker is rejected
61
+ * (`ConflictError`, `encryption-immutable`).
50
62
  * @returns {Promise<CollectionDescription>}
51
63
  */
52
64
  configure(desc: {
53
65
  name?: string;
54
66
  backend?: BackendReference;
67
+ encryption?: CollectionEncryption;
55
68
  }): Promise<CollectionDescription>;
56
69
  /**
57
70
  * Deletes the whole collection. Idempotent. To delete a single resource, use
@@ -1 +1 @@
1
- {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAK1D,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,CAA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,iBAAiB,GAAG,IAAI,CAAC;IAUlD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAS5C"}
@@ -11,6 +11,7 @@ import { assertNotReserved } from './internal/reserved.js';
11
11
  import { delegateGrant } from './internal/grant.js';
12
12
  import { send } from './internal/request.js';
13
13
  import { resolveCodec } from './internal/codec.js';
14
+ import { describeCollection } from './internal/describe.js';
14
15
  import { writeHeaders, readEtag } from './internal/conditional.js';
15
16
  import { Resource } from './Resource.js';
16
17
  export class Collection {
@@ -18,6 +19,7 @@ export class Collection {
18
19
  id;
19
20
  _context;
20
21
  _capability;
22
+ _encryptionOverride;
21
23
  _codecPromise;
22
24
  /**
23
25
  * @param options {object}
@@ -26,12 +28,16 @@ export class Collection {
26
28
  * @param options.spaceId {string}
27
29
  * @param options.collectionId {string}
28
30
  * @param [options.capability] {IZcap} - capability attached to every request
31
+ * @param [options.encryption] {EncryptionOverride} - per-handle encryption
32
+ * override; wins over the Collection's declared marker and skips the
33
+ * marker-discovery round-trip
29
34
  */
30
- constructor({ context, spaceId, collectionId, capability }) {
35
+ constructor({ context, spaceId, collectionId, capability, encryption }) {
31
36
  this._context = context;
32
37
  this.spaceId = spaceId;
33
38
  this.id = collectionId;
34
39
  this._capability = capability;
40
+ this._encryptionOverride = encryption;
35
41
  }
36
42
  get _path() {
37
43
  return collectionPath(this.spaceId, this.id);
@@ -42,15 +48,20 @@ export class Collection {
42
48
  /**
43
49
  * Resolves (once, then caches) the codec for this collection's reads and
44
50
  * writes: the identity codec for a plaintext collection, or the encrypting
45
- * codec when an `EncryptionProvider` is injected and supplies one for this
46
- * collection (i.e. the client holds keys for it).
51
+ * codec when this collection is declared encrypted -- by a per-handle override
52
+ * or its `encryption` marker -- and the client's keystore supplies its keys.
53
+ * An encrypted collection the client cannot key for fails closed (throws), and
54
+ * the marker read happens at most once per handle (memoized here) -- a fresh
55
+ * handle to the same collection re-reads it, so retain the handle to reuse it.
47
56
  *
48
57
  * @returns {Promise<ResourceCodec>}
49
58
  */
50
59
  _codec() {
51
60
  return (this._codecPromise ??= resolveCodec(this._context, {
52
61
  spaceId: this.spaceId,
53
- collectionId: this.id
62
+ collectionId: this.id,
63
+ override: this._encryptionOverride,
64
+ readMarker: async () => (await this.describe())?.encryption
54
65
  }));
55
66
  }
56
67
  /**
@@ -61,13 +72,11 @@ export class Collection {
61
72
  * @returns {Promise<CollectionDescription | null>}
62
73
  */
63
74
  async describe() {
64
- const response = await send(this._context, {
65
- path: this._path,
66
- method: 'GET',
67
- capability: this._capability,
68
- read: true
75
+ return describeCollection(this._context, {
76
+ spaceId: this.spaceId,
77
+ collectionId: this.id,
78
+ capability: this._capability
69
79
  });
70
- return response === null ? null : response.data;
71
80
  }
72
81
  /**
73
82
  * Creates or updates the collection by id (upsert). Merges the given fields
@@ -76,6 +85,10 @@ export class Collection {
76
85
  * @param desc {object}
77
86
  * @param [desc.name] {string}
78
87
  * @param [desc.backend] {BackendReference}
88
+ * @param [desc.encryption] {CollectionEncryption} declare the client-side
89
+ * encryption marker. Set-once on the server: it may be added to a Collection
90
+ * that lacks one, but changing/clearing an existing marker is rejected
91
+ * (`ConflictError`, `encryption-immutable`).
79
92
  * @returns {Promise<CollectionDescription>}
80
93
  */
81
94
  async configure(desc) {
@@ -86,6 +99,9 @@ export class Collection {
86
99
  if (desc.backend) {
87
100
  body.backend = desc.backend;
88
101
  }
102
+ if (desc.encryption) {
103
+ body.encryption = desc.encryption;
104
+ }
89
105
  await send(this._context, {
90
106
  path: this._path,
91
107
  method: 'PUT',
@@ -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,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,KAAK,EACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAA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AA;QACF,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,QAAQ,CAAC,IAAgB,CAAA;IAC9D,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACzC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAC9C,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;QACF,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,QAAQ,CAAC,IAA0B,CAAA;IACxE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACzC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAC5C,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;QACF,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,QAAQ,CAAC,IAAqB,CAAA;IACnE,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import type { ClientContext } from './internal/request.js';
2
2
  import type { ResourceCodec } from './codec.js';
3
- import type { IZcap, Json, PolicyDocument, ResourceMetadata, ResourceMetadataCustom } from './types.js';
3
+ import type { EncryptionOverride, IZcap, Json, PolicyDocument, ResourceMetadata, ResourceMetadataCustom } from './types.js';
4
4
  export declare class Resource {
5
5
  readonly spaceId: string;
6
6
  readonly collectionId: string;
@@ -8,6 +8,7 @@ export declare class Resource {
8
8
  private readonly _context;
9
9
  private readonly _capability?;
10
10
  private readonly _codecThunk?;
11
+ private readonly _encryptionOverride?;
11
12
  private _codecPromise?;
12
13
  /**
13
14
  * @param options {object}
@@ -20,20 +21,28 @@ export declare class Resource {
20
21
  * codec, so a resource handle obtained via `collection.resource(id)` does
21
22
  * not repeat the backend() round-trip. A standalone resource resolves its
22
23
  * own.
24
+ * @param [options.encryption] {EncryptionOverride} per-handle encryption
25
+ * override for a standalone resource (ignored when `codec` is supplied --
26
+ * the shared parent codec wins)
23
27
  */
24
- constructor({ context, spaceId, collectionId, resourceId, capability, codec }: {
28
+ constructor({ context, spaceId, collectionId, resourceId, capability, codec, encryption }: {
25
29
  context: ClientContext;
26
30
  spaceId: string;
27
31
  collectionId: string;
28
32
  resourceId: string;
29
33
  capability?: IZcap;
30
34
  codec?: () => Promise<ResourceCodec>;
35
+ encryption?: EncryptionOverride;
31
36
  });
32
37
  private get _path();
33
38
  /**
34
39
  * Resolves (once, then caches) the codec for this resource: the parent
35
40
  * collection's shared codec when this handle came from
36
- * `collection.resource(id)`, otherwise one resolved for its own collection.
41
+ * `collection.resource(id)`, otherwise one resolved for its own collection. A
42
+ * standalone resource discovers its collection's `encryption` marker (one GET
43
+ * on the collection, cached per handle) unless a per-handle override is set,
44
+ * and fails closed if it cannot key an encrypted collection. A fresh
45
+ * standalone handle re-reads the marker, so retain the handle to reuse it.
37
46
  *
38
47
  * @returns {Promise<ResourceCodec>}
39
48
  */
@@ -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;AAI1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAEnB,qBAAa,QAAQ;IACnB,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-2,6 +2,7 @@ import { resourcePath, resourcePolicy, resourceMeta } from './internal/paths.js'
2
2
  import { assertNotReserved } from './internal/reserved.js';
3
3
  import { send } from './internal/request.js';
4
4
  import { resolveCodec } from './internal/codec.js';
5
+ import { describeCollection } from './internal/describe.js';
5
6
  import { writeHeaders, readEtag } from './internal/conditional.js';
6
7
  import { ValidationError } from './errors.js';
7
8
  export class Resource {
@@ -11,6 +12,7 @@ export class Resource {
11
12
  _context;
12
13
  _capability;
13
14
  _codecThunk;
15
+ _encryptionOverride;
14
16
  _codecPromise;
15
17
  /**
16
18
  * @param options {object}
@@ -23,14 +25,18 @@ export class Resource {
23
25
  * codec, so a resource handle obtained via `collection.resource(id)` does
24
26
  * not repeat the backend() round-trip. A standalone resource resolves its
25
27
  * own.
28
+ * @param [options.encryption] {EncryptionOverride} per-handle encryption
29
+ * override for a standalone resource (ignored when `codec` is supplied --
30
+ * the shared parent codec wins)
26
31
  */
27
- constructor({ context, spaceId, collectionId, resourceId, capability, codec }) {
32
+ constructor({ context, spaceId, collectionId, resourceId, capability, codec, encryption }) {
28
33
  this._context = context;
29
34
  this.spaceId = spaceId;
30
35
  this.collectionId = collectionId;
31
36
  this.id = resourceId;
32
37
  this._capability = capability;
33
38
  this._codecThunk = codec;
39
+ this._encryptionOverride = encryption;
34
40
  }
35
41
  get _path() {
36
42
  return resourcePath(this.spaceId, this.collectionId, this.id);
@@ -38,7 +44,11 @@ export class Resource {
38
44
  /**
39
45
  * Resolves (once, then caches) the codec for this resource: the parent
40
46
  * collection's shared codec when this handle came from
41
- * `collection.resource(id)`, otherwise one resolved for its own collection.
47
+ * `collection.resource(id)`, otherwise one resolved for its own collection. A
48
+ * standalone resource discovers its collection's `encryption` marker (one GET
49
+ * on the collection, cached per handle) unless a per-handle override is set,
50
+ * and fails closed if it cannot key an encrypted collection. A fresh
51
+ * standalone handle re-reads the marker, so retain the handle to reuse it.
42
52
  *
43
53
  * @returns {Promise<ResourceCodec>}
44
54
  */
@@ -47,7 +57,13 @@ export class Resource {
47
57
  ? this._codecThunk()
48
58
  : resolveCodec(this._context, {
49
59
  spaceId: this.spaceId,
50
- collectionId: this.collectionId
60
+ collectionId: this.collectionId,
61
+ override: this._encryptionOverride,
62
+ readMarker: async () => (await describeCollection(this._context, {
63
+ spaceId: this.spaceId,
64
+ collectionId: this.collectionId,
65
+ capability: this._capability
66
+ }))?.encryption
51
67
  }));
52
68
  }
53
69
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.js","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAS7C,MAAM,OAAO,QAAQ;IACV,OAAO,CAAQ;IACf,YAAY,CAAQ;IACpB,EAAE,CAAQ;IAEF,QAAQ,CAAe;IACvB,WAAW,CAAQ;IACnB,WAAW,CAA+B;IACnD,aAAa,CAAyB;IAE9C;;;;;;;;;;;OAWG;IACH,YAAY,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,UAAU,EACV,KAAK,EAQN;QACC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC7B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;IAC1B,CAAC;IAED,IA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