@interop/was-client 0.60.0 → 0.62.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 (81) hide show
  1. package/README.md +124 -48
  2. package/dist/Collection.d.ts +135 -94
  3. package/dist/Collection.d.ts.map +1 -1
  4. package/dist/Collection.js +612 -194
  5. package/dist/Collection.js.map +1 -1
  6. package/dist/Resource.d.ts +1 -1
  7. package/dist/Resource.d.ts.map +1 -1
  8. package/dist/Resource.js +0 -3
  9. package/dist/Resource.js.map +1 -1
  10. package/dist/Space.d.ts +17 -16
  11. package/dist/Space.d.ts.map +1 -1
  12. package/dist/Space.js +41 -24
  13. package/dist/Space.js.map +1 -1
  14. package/dist/WasClient.d.ts +51 -6
  15. package/dist/WasClient.d.ts.map +1 -1
  16. package/dist/WasClient.js +84 -14
  17. package/dist/WasClient.js.map +1 -1
  18. package/dist/codec.d.ts +3 -3
  19. package/dist/edv/EdvCodec.js +1 -1
  20. package/dist/edv/descriptorStore.d.ts +16 -14
  21. package/dist/edv/descriptorStore.d.ts.map +1 -1
  22. package/dist/edv/descriptorStore.js +17 -14
  23. package/dist/edv/descriptorStore.js.map +1 -1
  24. package/dist/edv/index.d.ts +1 -1
  25. package/dist/edv/index.js +1 -1
  26. package/dist/edv/logGovernedDescriptorStore.d.ts +2 -2
  27. package/dist/edv/logGovernedDescriptorStore.d.ts.map +1 -1
  28. package/dist/edv/logGovernedDescriptorStore.js +10 -9
  29. package/dist/edv/logGovernedDescriptorStore.js.map +1 -1
  30. package/dist/edv/recipients.d.ts +1 -1
  31. package/dist/edv/recipients.js +2 -2
  32. package/dist/edv/recipients.js.map +1 -1
  33. package/dist/edv/refresh.d.ts +1 -1
  34. package/dist/edv/refresh.js +1 -1
  35. package/dist/errors.d.ts +14 -1
  36. package/dist/errors.d.ts.map +1 -1
  37. package/dist/errors.js +16 -3
  38. package/dist/errors.js.map +1 -1
  39. package/dist/index.d.ts +2 -2
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/internal/codec.d.ts +22 -1
  44. package/dist/internal/codec.d.ts.map +1 -1
  45. package/dist/internal/codec.js +117 -46
  46. package/dist/internal/codec.js.map +1 -1
  47. package/dist/internal/describe.d.ts +98 -24
  48. package/dist/internal/describe.d.ts.map +1 -1
  49. package/dist/internal/describe.js +125 -18
  50. package/dist/internal/describe.js.map +1 -1
  51. package/dist/internal/meta.d.ts +32 -17
  52. package/dist/internal/meta.d.ts.map +1 -1
  53. package/dist/internal/meta.js +64 -35
  54. package/dist/internal/meta.js.map +1 -1
  55. package/dist/internal/paths.d.ts +33 -21
  56. package/dist/internal/paths.d.ts.map +1 -1
  57. package/dist/internal/paths.js +93 -46
  58. package/dist/internal/paths.js.map +1 -1
  59. package/dist/internal/request.d.ts +22 -6
  60. package/dist/internal/request.d.ts.map +1 -1
  61. package/dist/internal/request.js +31 -13
  62. package/dist/internal/request.js.map +1 -1
  63. package/dist/internal/reserved.d.ts +14 -0
  64. package/dist/internal/reserved.d.ts.map +1 -1
  65. package/dist/internal/reserved.js +23 -4
  66. package/dist/internal/reserved.js.map +1 -1
  67. package/dist/internal/service.d.ts +61 -0
  68. package/dist/internal/service.d.ts.map +1 -0
  69. package/dist/internal/service.js +259 -0
  70. package/dist/internal/service.js.map +1 -0
  71. package/dist/paths.d.ts +8 -5
  72. package/dist/paths.d.ts.map +1 -1
  73. package/dist/paths.js +8 -5
  74. package/dist/paths.js.map +1 -1
  75. package/dist/sync/provisioning.d.ts +5 -5
  76. package/dist/sync/provisioning.d.ts.map +1 -1
  77. package/dist/sync/provisioning.js +2 -2
  78. package/dist/sync/provisioning.js.map +1 -1
  79. package/dist/types.d.ts +43 -10
  80. package/dist/types.d.ts.map +1 -1
  81. package/package.json +2 -2
@@ -6,16 +6,18 @@
6
6
  * signer) and exposes the WAS containment model
7
7
  * (`SpacesRepository > Space > Collection > Resource`) through lazy
8
8
  * navigational handles. Also hosts the general delegation primitive
9
- * (`grant`), capability-rebuilding (`fromCapability`), and the signed
10
- * escape-hatch (`request`).
9
+ * (`grant`), capability-rebuilding (`fromCapability`), the signed
10
+ * escape-hatch (`request`), and service discovery (`service`), which every
11
+ * signed request waits on.
11
12
  */
12
13
  import type { ZcapClient } from '@interop/ezcap';
13
14
  import type { HttpResponse } from '@interop/http-client';
15
+ import type { ServiceDescription } from '@interop/storage-core';
14
16
  import type { EncryptionProvider } from './codec.js';
15
17
  import { Space } from './Space.js';
16
18
  import { Collection } from './Collection.js';
17
19
  import { Resource } from './Resource.js';
18
- import type { GrantOptions, HandleOptions, IDelegatedZcap, ISigner, IZcap, Json, RequestInput, CollectionResourcesList, ResourceSummary, SpaceListing } from './types.js';
20
+ import type { GrantOptions, HandleOptions, IDelegatedZcap, ISigner, IZcap, Json, RequestInput, CollectionResourcesList, ResourceSummary, ServiceInfo, SpaceListing } from './types.js';
19
21
  export declare class WasClient {
20
22
  #private;
21
23
  readonly serverUrl: string;
@@ -33,11 +35,18 @@ export declare class WasClient {
33
35
  * does not decide *which* collections are encrypted -- that is the
34
36
  * descriptor/override -- so a missing key for an encrypted collection fails
35
37
  * closed rather than silently downgrading to plaintext.
38
+ * @param [options.serviceDescription] {ServiceDescription} a service
39
+ * description the caller already holds (from a cache, say). The client
40
+ * selects its version from this copy instead of discovering the document
41
+ * from `serverUrl`, and still refuses it with `IncompatibleServerError` if
42
+ * it names no version this client speaks. `service({ refresh: true })`
43
+ * discards it and discovers afresh.
36
44
  */
37
- constructor({ serverUrl, zcapClient, encryption }: {
45
+ constructor({ serverUrl, zcapClient, encryption, serviceDescription }: {
38
46
  serverUrl: string;
39
47
  zcapClient: ZcapClient;
40
48
  encryption?: EncryptionProvider;
49
+ serviceDescription?: ServiceDescription;
41
50
  });
42
51
  /**
43
52
  * Convenience constructor that builds the ezcap `ZcapClient` internally from
@@ -52,12 +61,15 @@ export declare class WasClient {
52
61
  * @param options.serverUrl {string}
53
62
  * @param options.signer {ISigner}
54
63
  * @param [options.encryption] {EncryptionProvider} see the constructor
64
+ * @param [options.serviceDescription] {ServiceDescription} see the
65
+ * constructor
55
66
  * @returns {WasClient}
56
67
  */
57
- static fromSigner({ serverUrl, signer, encryption }: {
68
+ static fromSigner({ serverUrl, signer, encryption, serviceDescription }: {
58
69
  serverUrl: string;
59
70
  signer: ISigner;
60
71
  encryption?: EncryptionProvider;
72
+ serviceDescription?: ServiceDescription;
61
73
  }): WasClient;
62
74
  /**
63
75
  * The DID controlling the wrapped signer (`signer.id` without the key
@@ -66,6 +78,34 @@ export declare class WasClient {
66
78
  * @returns {string}
67
79
  */
68
80
  get controllerDid(): string;
81
+ /**
82
+ * Discovers the server's service description and the WAS version this
83
+ * client speaks with it. Follows the `rel="service"` link on the response to
84
+ * an unsigned `HEAD` of `serverUrl`, then reads the linked document with an
85
+ * unsigned `GET`. No capability is invoked. The result is memoized for the
86
+ * life of the client and shared by every handle; concurrent callers share
87
+ * one discovery, and a failure is not memoized, so the next call retries.
88
+ *
89
+ * Every signed request waits on this discovery, so a caller rarely needs to
90
+ * call it first. It is the way to read the server-wide affordances:
91
+ * `features` (an open token list, where an absent token means unsupported)
92
+ * and `spacesUrl` (absent when the server has no Spaces Repository).
93
+ * Unsigned public reads (`publicRead`, `publicListCollection`, ...) address
94
+ * an absolute URL that may be on another server, and do not wait on it.
95
+ *
96
+ * @param [options] {object}
97
+ * @param [options.refresh] {boolean} discard the memoized result (and any
98
+ * constructor-supplied `serviceDescription`) and discover again, for a
99
+ * caller about to rely on an affordance the server may have stopped
100
+ * advertising
101
+ * @returns {Promise<ServiceInfo>}
102
+ * @throws {IncompatibleServerError} when the server's responses carry no
103
+ * `service` link (it predates v0.5), the document is malformed, or it
104
+ * lists no version this client speaks
105
+ */
106
+ service(options?: {
107
+ refresh?: boolean;
108
+ }): Promise<ServiceInfo>;
69
109
  /**
70
110
  * Returns a lazy handle to a space by id. No I/O.
71
111
  *
@@ -78,13 +118,15 @@ export declare class WasClient {
78
118
  /**
79
119
  * Creates a space (server-generated id unless `id` is given). `name` is
80
120
  * optional (both in the spec and on the reference server); `controller` must
81
- * match the wrapped signer's DID (which is the default).
121
+ * match the wrapped signer's DID (which is the default). The request goes
122
+ * to the Spaces Repository URL the service description names.
82
123
  *
83
124
  * @param desc {object}
84
125
  * @param [desc.id] {string}
85
126
  * @param [desc.name] {string}
86
127
  * @param [desc.controller] {string}
87
128
  * @returns {Promise<Space>}
129
+ * @throws {NotSupportedError} when the server has no Spaces Repository
88
130
  */
89
131
  createSpace(desc?: {
90
132
  id?: string;
@@ -106,6 +148,7 @@ export declare class WasClient {
106
148
  * the walk has gathered the complete listing.
107
149
  *
108
150
  * @returns {Promise<SpaceListing>}
151
+ * @throws {NotSupportedError} when the server has no Spaces Repository
109
152
  */
110
153
  listSpaces(): Promise<SpaceListing>;
111
154
  /**
@@ -205,6 +248,8 @@ export declare class WasClient {
205
248
  * `path` against `serverUrl`, defaults `action` to `method`, and signs via the
206
249
  * wrapped client. Returns the raw `HttpResponse` and throws raw ky/ezcap
207
250
  * errors -- it does not apply the null-on-404 or typed-error conveniences.
251
+ * Like every signed request it waits on {@link service} first, and rejects
252
+ * with its `IncompatibleServerError` before signing anything.
208
253
  *
209
254
  * @param options {RequestInput}
210
255
  * @returns {Promise<HttpResponse>}
@@ -1 +1 @@
1
- {"version":3,"file":"WasClient.d.ts","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAuBxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAA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ANGED
@@ -1,10 +1,12 @@
1
- import { collectionItemsUrl, parseSpaceTarget, spacesRoot, toUrl } from './internal/paths.js';
1
+ import { collectionItemsUrl, parseSpaceTarget } from './internal/paths.js';
2
2
  import { send, rawRequest, unsignedRequest } from './internal/request.js';
3
3
  import { createdId, parseResource, readJsonData } from './internal/content.js';
4
4
  import { buildPageWalk, collectPages, collectWalk, signedPageWalk, walkItems, walkPagesOrEmpty } from './internal/pagination.js';
5
5
  import { delegateGrant } from './internal/grant.js';
6
6
  import { spaceIdOf, submitRevocation } from './internal/revoke.js';
7
- import { ValidationError, WasServerError } from './errors.js';
7
+ import { Memo } from './internal/memo.js';
8
+ import { discoverService, selectServiceVersion } from './internal/service.js';
9
+ import { NotSupportedError, ValidationError, WasServerError } from './errors.js';
8
10
  import { zcapClientForSigner } from './zcapClient.js';
9
11
  import { Space } from './Space.js';
10
12
  import { Collection } from './Collection.js';
@@ -25,11 +27,18 @@ export class WasClient {
25
27
  * does not decide *which* collections are encrypted -- that is the
26
28
  * descriptor/override -- so a missing key for an encrypted collection fails
27
29
  * closed rather than silently downgrading to plaintext.
30
+ * @param [options.serviceDescription] {ServiceDescription} a service
31
+ * description the caller already holds (from a cache, say). The client
32
+ * selects its version from this copy instead of discovering the document
33
+ * from `serverUrl`, and still refuses it with `IncompatibleServerError` if
34
+ * it names no version this client speaks. `service({ refresh: true })`
35
+ * discards it and discovers afresh.
28
36
  */
29
- constructor({ serverUrl, zcapClient, encryption }) {
37
+ constructor({ serverUrl, zcapClient, encryption, serviceDescription }) {
30
38
  this.serverUrl = serverUrl;
31
39
  this.zcapClient = zcapClient;
32
40
  this.encryption = encryption;
41
+ this.#serviceDescription = serviceDescription;
33
42
  }
34
43
  /**
35
44
  * Convenience constructor that builds the ezcap `ZcapClient` internally from
@@ -44,13 +53,16 @@ export class WasClient {
44
53
  * @param options.serverUrl {string}
45
54
  * @param options.signer {ISigner}
46
55
  * @param [options.encryption] {EncryptionProvider} see the constructor
56
+ * @param [options.serviceDescription] {ServiceDescription} see the
57
+ * constructor
47
58
  * @returns {WasClient}
48
59
  */
49
- static fromSigner({ serverUrl, signer, encryption }) {
60
+ static fromSigner({ serverUrl, signer, encryption, serviceDescription }) {
50
61
  return new WasClient({
51
62
  serverUrl,
52
63
  zcapClient: zcapClientForSigner({ signer }),
53
- encryption
64
+ encryption,
65
+ serviceDescription
54
66
  });
55
67
  }
56
68
  /**
@@ -66,6 +78,58 @@ export class WasClient {
66
78
  }
67
79
  return signer.id.split('#')[0];
68
80
  }
81
+ #serviceDescription;
82
+ #service = new Memo(async () => this.#serviceDescription === undefined
83
+ ? discoverService({ url: this.serverUrl })
84
+ : selectServiceVersion(this.#serviceDescription));
85
+ /**
86
+ * Discovers the server's service description and the WAS version this
87
+ * client speaks with it. Follows the `rel="service"` link on the response to
88
+ * an unsigned `HEAD` of `serverUrl`, then reads the linked document with an
89
+ * unsigned `GET`. No capability is invoked. The result is memoized for the
90
+ * life of the client and shared by every handle; concurrent callers share
91
+ * one discovery, and a failure is not memoized, so the next call retries.
92
+ *
93
+ * Every signed request waits on this discovery, so a caller rarely needs to
94
+ * call it first. It is the way to read the server-wide affordances:
95
+ * `features` (an open token list, where an absent token means unsupported)
96
+ * and `spacesUrl` (absent when the server has no Spaces Repository).
97
+ * Unsigned public reads (`publicRead`, `publicListCollection`, ...) address
98
+ * an absolute URL that may be on another server, and do not wait on it.
99
+ *
100
+ * @param [options] {object}
101
+ * @param [options.refresh] {boolean} discard the memoized result (and any
102
+ * constructor-supplied `serviceDescription`) and discover again, for a
103
+ * caller about to rely on an affordance the server may have stopped
104
+ * advertising
105
+ * @returns {Promise<ServiceInfo>}
106
+ * @throws {IncompatibleServerError} when the server's responses carry no
107
+ * `service` link (it predates v0.5), the document is malformed, or it
108
+ * lists no version this client speaks
109
+ */
110
+ async service(options = {}) {
111
+ if (options.refresh) {
112
+ this.#serviceDescription = undefined;
113
+ this.#service.reset();
114
+ }
115
+ return this.#service.get();
116
+ }
117
+ /**
118
+ * The Spaces Repository URL from the service description.
119
+ *
120
+ * @returns {Promise<string>}
121
+ * @throws {NotSupportedError} when the server does not implement the
122
+ * Spaces Repository
123
+ */
124
+ async #spacesUrl() {
125
+ const { spacesUrl, version } = await this.service();
126
+ if (spacesUrl === undefined) {
127
+ throw new NotSupportedError(`The server at "${this.serverUrl}" does not implement the Spaces ` +
128
+ `Repository: its WAS ${version} service description entry has no ` +
129
+ '`spaces` URL.');
130
+ }
131
+ return spacesUrl;
132
+ }
69
133
  #cachedContext;
70
134
  get #context() {
71
135
  // `serverUrl`, `zcapClient` (and thus `controllerDid`), and `encryption`
@@ -77,7 +141,8 @@ export class WasClient {
77
141
  serverUrl: this.serverUrl,
78
142
  zcapClient: this.zcapClient,
79
143
  controllerDid: this.controllerDid,
80
- encryption: this.encryption
144
+ encryption: this.encryption,
145
+ service: () => this.service()
81
146
  };
82
147
  }
83
148
  return this.#cachedContext;
@@ -100,13 +165,15 @@ export class WasClient {
100
165
  /**
101
166
  * Creates a space (server-generated id unless `id` is given). `name` is
102
167
  * optional (both in the spec and on the reference server); `controller` must
103
- * match the wrapped signer's DID (which is the default).
168
+ * match the wrapped signer's DID (which is the default). The request goes
169
+ * to the Spaces Repository URL the service description names.
104
170
  *
105
171
  * @param desc {object}
106
172
  * @param [desc.id] {string}
107
173
  * @param [desc.name] {string}
108
174
  * @param [desc.controller] {string}
109
175
  * @returns {Promise<Space>}
176
+ * @throws {NotSupportedError} when the server has no Spaces Repository
110
177
  */
111
178
  async createSpace(desc = {}) {
112
179
  const controller = desc.controller ?? this.controllerDid;
@@ -116,7 +183,7 @@ export class WasClient {
116
183
  ...(desc.name !== undefined && { name: desc.name })
117
184
  };
118
185
  const response = await send(this.#context, {
119
- path: spacesRoot(),
186
+ url: await this.#spacesUrl(),
120
187
  method: 'POST',
121
188
  json: body
122
189
  });
@@ -137,19 +204,20 @@ export class WasClient {
137
204
  * the walk has gathered the complete listing.
138
205
  *
139
206
  * @returns {Promise<SpaceListing>}
207
+ * @throws {NotSupportedError} when the server has no Spaces Repository
140
208
  */
141
209
  async listSpaces() {
210
+ const spacesUrl = await this.#spacesUrl();
142
211
  const walk = await signedPageWalk(this.#context, {
143
- firstUrl: toUrl({ serverUrl: this.serverUrl, path: spacesRoot() })
212
+ firstUrl: spacesUrl
144
213
  });
145
214
  // The first page always carries the listing body (an unauthorized caller
146
215
  // still gets an empty `items` list, not an error), so a `null` walk is a
147
- // server fault -- a 404 from a `serverUrl` whose base path does not reach
148
- // the repository, or a 2xx whose body did not parse as JSON. Report it as
149
- // one, rather than as a `TypeError` from destructuring `null`.
216
+ // server fault -- a 404 at the advertised repository URL, or a 2xx whose
217
+ // body did not parse as JSON. Report it as one, rather than as a
218
+ // `TypeError` from destructuring `null`.
150
219
  if (walk === null) {
151
- throw new WasServerError(`The space listing at "${this.serverUrl}" answered with no JSON ` +
152
- 'body. Check that `serverUrl` names the WAS repository root.');
220
+ throw new WasServerError(`The space listing at "${spacesUrl}" answered with no JSON body.`);
153
221
  }
154
222
  const listing = await collectPages(walk);
155
223
  // A paginating server omits `totalItems` on truncated pages; the walk has
@@ -341,6 +409,8 @@ export class WasClient {
341
409
  * `path` against `serverUrl`, defaults `action` to `method`, and signs via the
342
410
  * wrapped client. Returns the raw `HttpResponse` and throws raw ky/ezcap
343
411
  * errors -- it does not apply the null-on-404 or typed-error conveniences.
412
+ * Like every signed request it waits on {@link service} first, and rejects
413
+ * with its `IncompatibleServerError` before signing anything.
344
414
  *
345
415
  * @param options {RequestInput}
346
416
  * @returns {Promise<HttpResponse>}
@@ -1 +1 @@
1
- {"version":3,"file":"WasClient.js","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,KAAK,EACN,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE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AC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,OAAO,IAAI,QAAQ,CAAC;gBAClB,OAAO;gBACP,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACjC,OAAO,IAAI,UAAU,CAAC;gBACpB,OAAO;gBACP,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1E,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,CAAC,IAAoB;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,OAAO,gBAAgB,CAAC,OAAO,EAAE;YAC/B,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC;YACjC,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,CAAC,OAAqB;QACjC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;CACF"}
package/dist/codec.d.ts CHANGED
@@ -434,9 +434,9 @@ export interface EncryptionProvider {
434
434
  * @param input.collectionId {string}
435
435
  * @param input.scheme {string} the declared encryption scheme (e.g. `edv`)
436
436
  * @param [input.encryption] {CollectionEncryption} the full encryption
437
- * descriptor read from the Collection Description (when core discovered it
438
- * via the descriptor rather than an override). Carries the key-epoch public
439
- * references (`epochs` / `currentEpoch`) a multi-recipient provider needs
437
+ * descriptor read from the Collection Metadata object (when core
438
+ * discovered it via the descriptor rather than an override). Carries the
439
+ * key-epoch public references (`epochs` / `currentEpoch`) a provider needs
440
440
  * to resolve per-epoch keys; absent on an override-driven resolution, where
441
441
  * the provider falls back to its single-key path.
442
442
  * @param [input.keys] {unknown} override-supplied key material (a per-handle
@@ -916,7 +916,7 @@ export class EdvCodec {
916
916
  * read axis only; it says nothing about whether the server will still
917
917
  * serve (pull) the ciphertext. An epoch the descriptor does not list at
918
918
  * all raises {@link UnknownEpochError} -- the signal that the cached
919
- * Collection Description may be stale (an epoch rotation emits no
919
+ * Collection Metadata object may be stale (an epoch rotation emits no
920
920
  * change-feed entry) and the codec must be rebuilt from a re-read
921
921
  * descriptor. A candidate whose entry then fails to unwrap also surfaces
922
922
  * {@link KeyUnwrapError}.
@@ -11,8 +11,8 @@
11
11
  *
12
12
  * Two adapters:
13
13
  *
14
- * - {@link collectionDescriptorStore} -- the Collection Description's `encryption`
15
- * member, read with `describeWithEtag` and written back with
14
+ * - {@link collectionDescriptorStore} -- the Collection Metadata object's
15
+ * `encryption` member, read with `describeWithEtag` and written back with
16
16
  * `replaceDescription` + `If-Match`. The server enforces the descriptor
17
17
  * invariants (append-only epochs, monotone `currentEpoch`, non-decreasing
18
18
  * `version`) on this path.
@@ -45,7 +45,7 @@ export interface EncryptionDescriptorStore {
45
45
  * next {@link replace} must be compare-and-swapped against. Resolves `null`
46
46
  * when no descriptor exists yet AND this store can create one (the resource
47
47
  * adapter before the first `initRecipients`); a store whose host must
48
- * already exist (the description adapter) throws instead of resolving
48
+ * already exist (the Collection Metadata adapter) throws instead of resolving
49
49
  * `null`. Throws when the hosted value is not an `edv`-scheme descriptor.
50
50
  *
51
51
  * @returns {Promise<{ descriptor: CollectionEncryption; etag?: string } | null>}
@@ -59,8 +59,8 @@ export interface EncryptionDescriptorStore {
59
59
  * validator from {@link read}); a stale validator throws
60
60
  * `PreconditionFailedError` (412). Must follow a {@link read} on the same
61
61
  * store instance -- an adapter may forward sibling state observed by its most
62
- * recent read (the description adapter forwards the description's `name` /
63
- * `backend`).
62
+ * recent read (the Collection Metadata adapter forwards the object's `name`
63
+ * / `backend`).
64
64
  *
65
65
  * @param descriptor {CollectionEncryption}
66
66
  * @param options {object}
@@ -75,7 +75,7 @@ export interface EncryptionDescriptorStore {
75
75
  * Creates the FIRST descriptor where {@link read} resolved `null`, guarded
76
76
  * create-if-absent (`If-None-Match: *`); throws `PreconditionFailedError`
77
77
  * (412) when a concurrent writer created one first. Absent on stores whose
78
- * host always exists (the description adapter).
78
+ * host always exists (the Collection Metadata adapter).
79
79
  *
80
80
  * @param descriptor {CollectionEncryption}
81
81
  * @returns {Promise<void>}
@@ -83,14 +83,16 @@ export interface EncryptionDescriptorStore {
83
83
  create?(descriptor: CollectionEncryption): Promise<void>;
84
84
  }
85
85
  /**
86
- * The Collection Description adapter: the descriptor is the Description's
87
- * `encryption` member. Read fails closed when the Description is unreadable
86
+ * The Collection Metadata adapter: the descriptor is the Collection Metadata
87
+ * object's `encryption` member. Read fails closed when the object is unreadable
88
88
  * (WAS masks unauthorized reads as 404) or the collection is not declared
89
- * encrypted with the `edv` scheme; the CAS write forwards the description's
90
- * sibling fields (`name` / `backend`) observed by the most recent read, so
91
- * the replace-semantics PUT does not drop them. No `create`: a Collection
92
- * Description always exists, so a first descriptor is declared via
93
- * `collection.configure({ encryption })`, never through this store.
89
+ * encrypted with the `edv` scheme; the CAS write forwards the configuration
90
+ * members (`name` / `backend` / the app attribution) observed by the most
91
+ * recent read, so the full-replacement PUT does not drop them. The
92
+ * annotations (`custom` and its `epoch` stamp) are carried forward by
93
+ * `replaceDescription` itself. No `create`: a Collection Metadata object
94
+ * always exists alongside its Collection, so a first descriptor is declared
95
+ * via `collection.configure({ encryption })` instead of through this store.
94
96
  *
95
97
  * @param options {object}
96
98
  * @param options.collection {Collection}
@@ -107,7 +109,7 @@ export declare function collectionDescriptorStore({ collection }: {
107
109
  * than an `edv`-scheme descriptor object.
108
110
  *
109
111
  * The server enforces no descriptor invariants on a resource (unlike a
110
- * Collection Description): rollback/tamper detection rests on client-side
112
+ * Collection Metadata object): rollback/tamper detection rests on client-side
111
113
  * epoch pinning plus whatever governance the hosting profile adds (for a
112
114
  * log-governed descriptor, the Resource Log Profile's verified entry proofs
113
115
  * and chain-head pin), and the CAS/create guards ride the backend's
@@ -1 +1 @@
1
- {"version":3,"file":"descriptorStore.d.ts","sourceRoot":"","sources":["../../src/edv/descriptorStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9C,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;;;;OASG;IACH,IAAI,IAAI,OAAO,CAAC;QAAE,UAAU,EAAE,oBAAoB,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAE3E;;;;;;;;;;;;;OAaG;IACH,OAAO,CACL,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhB;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,UAAU,EAC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Q,CAAA;CACnB,GAAG,yBAAyB,CAgC5B"}
@@ -1,24 +1,26 @@
1
1
  import { unreadableDescriptionError } from '../internal/describe.js';
2
2
  import { ValidationError } from '../errors.js';
3
3
  /**
4
- * The Collection Description adapter: the descriptor is the Description's
5
- * `encryption` member. Read fails closed when the Description is unreadable
4
+ * The Collection Metadata adapter: the descriptor is the Collection Metadata
5
+ * object's `encryption` member. Read fails closed when the object is unreadable
6
6
  * (WAS masks unauthorized reads as 404) or the collection is not declared
7
- * encrypted with the `edv` scheme; the CAS write forwards the description's
8
- * sibling fields (`name` / `backend`) observed by the most recent read, so
9
- * the replace-semantics PUT does not drop them. No `create`: a Collection
10
- * Description always exists, so a first descriptor is declared via
11
- * `collection.configure({ encryption })`, never through this store.
7
+ * encrypted with the `edv` scheme; the CAS write forwards the configuration
8
+ * members (`name` / `backend` / the app attribution) observed by the most
9
+ * recent read, so the full-replacement PUT does not drop them. The
10
+ * annotations (`custom` and its `epoch` stamp) are carried forward by
11
+ * `replaceDescription` itself. No `create`: a Collection Metadata object
12
+ * always exists alongside its Collection, so a first descriptor is declared
13
+ * via `collection.configure({ encryption })` instead of through this store.
12
14
  *
13
15
  * @param options {object}
14
16
  * @param options.collection {Collection}
15
17
  * @returns {EncryptionDescriptorStore}
16
18
  */
17
19
  export function collectionDescriptorStore({ collection }) {
18
- // The sibling description fields observed by the most recent read, forwarded
19
- // verbatim by the CAS write (the server's replace semantics would otherwise
20
- // drop them). Safe to forward even if stale: the write is pinned to the same
21
- // read's ETag, so a concurrent description change fails the CAS instead.
20
+ // The configuration members observed by the most recent read, forwarded
21
+ // verbatim by the CAS write (the full-replacement PUT would otherwise drop
22
+ // them). Safe to forward even if stale: the write is pinned to the same
23
+ // read's ETag, so a concurrent configuration change fails the CAS instead.
22
24
  let described;
23
25
  return {
24
26
  async read() {
@@ -26,7 +28,7 @@ export function collectionDescriptorStore({ collection }) {
26
28
  if (current === null) {
27
29
  throw unreadableDescriptionError({
28
30
  operation: 'manage recipients',
29
- advice: 'Use a capability that can read the Collection Description.'
31
+ advice: 'Use a capability that can read the Collection Metadata object.'
30
32
  });
31
33
  }
32
34
  const descriptor = current.description.encryption;
@@ -56,7 +58,7 @@ export function collectionDescriptorStore({ collection }) {
56
58
  * than an `edv`-scheme descriptor object.
57
59
  *
58
60
  * The server enforces no descriptor invariants on a resource (unlike a
59
- * Collection Description): rollback/tamper detection rests on client-side
61
+ * Collection Metadata object): rollback/tamper detection rests on client-side
60
62
  * epoch pinning plus whatever governance the hosting profile adds (for a
61
63
  * log-governed descriptor, the Resource Log Profile's verified entry proofs
62
64
  * and chain-head pin), and the CAS/create guards ride the backend's
@@ -103,7 +105,8 @@ export function resourceDescriptorStore({ resource }) {
103
105
  * Casts a descriptor to the `JsonObject` a resource write takes. The descriptor
104
106
  * types are interfaces without index signatures, so they do not structurally
105
107
  * satisfy `JsonObject` -- but a descriptor is plain JSON by construction (it
106
- * round-trips through the Collection Description on the classic host), so this
108
+ * round-trips through the Collection Metadata object on the classic host), so
109
+ * this
107
110
  * is sound.
108
111
  *
109
112
  * @param descriptor {CollectionEncryption}
@@ -1 +1 @@
1
- {"version":3,"file":"descriptorStore.js","sourceRoot":"","sources":["../../src/edv/descriptorStore.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AA0D9C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CAAC,EACxC,UAAU,EAGX;IACC,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,yEAAyE;IACzE,IAAI,SAA4C,CAAA;IAChD,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,gBAAgB,EAAE,CAAA;YACnD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACrB,MAAM,0BAA0B,CAAC;oBAC/B,SAAS,EAAE,mB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CAA2C,QAAQ,CAAC,EAAE,aAAa;oBACjE,+DAA+D,CAClE,CAAA;YACH,CAAC;YACD,OAAO;gBACL,UAAU,EAAE,UAA6C;gBACzD,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAA;QACH,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE;YACnC,MAAM,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/D,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,UAAU;YACrB,MAAM,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QACzE,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CAAC,UAAgC;IACxD,OAAO,UAAmC,CAAA;AAC5C,CAAC"}
@@ -61,7 +61,7 @@
61
61
  * loudly; it fails as a resource one of them cannot decrypt):
62
62
  *
63
63
  * - `EncryptionDescriptorSource` / `EncryptionDescriptorCache` -- the narrow
64
- * seams a host implements: one signed Collection Description read, and a
64
+ * seams a host implements: one signed Collection Metadata read, and a
65
65
  * client-local get/put pre-scoped to one Space. `wasDescriptorSource` is the
66
66
  * source over a `WasClient` handle.
67
67
  * - `acquireDescriptor` / `acquireDescriptors` -- fetch + cache with the
package/dist/edv/index.js CHANGED
@@ -61,7 +61,7 @@
61
61
  * loudly; it fails as a resource one of them cannot decrypt):
62
62
  *
63
63
  * - `EncryptionDescriptorSource` / `EncryptionDescriptorCache` -- the narrow
64
- * seams a host implements: one signed Collection Description read, and a
64
+ * seams a host implements: one signed Collection Metadata read, and a
65
65
  * client-local get/put pre-scoped to one Space. `wasDescriptorSource` is the
66
66
  * source over a `WasClient` handle.
67
67
  * - `acquireDescriptor` / `acquireDescriptors` -- fetch + cache with the
@@ -118,8 +118,8 @@ export declare function logGovernedDescriptorStore({ log, resolveController, pin
118
118
  }): LogGovernedDescriptorStore;
119
119
  /**
120
120
  * Builds the `EncryptionDescriptorStore` over a Collection that may be
121
- * log-governed. `read()` fetches the Collection Description and dispatches on
122
- * its `encryption` member: absent, the store resolves `null` (a fresh
121
+ * log-governed. `read()` fetches the Collection Metadata object and dispatches
122
+ * on its `encryption` member: absent, the store resolves `null` (a fresh
123
123
  * Collection that `create` makes log-governed with a genesis entry); present
124
124
  * without `history`, it is the plain point-state descriptor and the store
125
125
  * behaves exactly like `collectionDescriptorStore`; present with `history`,
@@ -1 +1 @@
1
- {"version":3,"file":"logGovernedDescriptorStore.d.ts","sourceRoot":"","sources":["../../src/edv/logGovernedDescriptorStore.ts"],"names":[],"mappings":"AA+BA,OAAO,EAWL,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOlD,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,8BAA8B,0BAA0B,CAAA;AAErE;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,oBAAoB,GAC/B,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAGzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,8BAA8B,CAAC,EACnD,KAAK,EACL,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACN,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAA;IACvB,iBAAiB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACvD,QAAQ,EAAE,mBAAmB,CAAA;I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U,EAAE,oBAAoB,CAAA;QAChC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,GAAG,IAAI,CAAC,CAAA;IACT,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAA;CACnC;AAuBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,GAAG,EACH,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,MAAM,EACP,EAAE;IACD,GAAG,EAAE,gBAAgB,CAAA;IACrB,iBAAiB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACvD,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC3B,GAAG,0BAA0B,CA8L7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,oCAAoC,CAAC,EACnD,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,MAAM,EACP,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,iBAAiB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACvD,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC3B,GAAG,0BAA0B,CAwI7B"}
@@ -315,8 +315,8 @@ export function logGovernedDescriptorStore({ log, resolveController, pinStore, l
315
315
  }
316
316
  /**
317
317
  * Builds the `EncryptionDescriptorStore` over a Collection that may be
318
- * log-governed. `read()` fetches the Collection Description and dispatches on
319
- * its `encryption` member: absent, the store resolves `null` (a fresh
318
+ * log-governed. `read()` fetches the Collection Metadata object and dispatches
319
+ * on its `encryption` member: absent, the store resolves `null` (a fresh
320
320
  * Collection that `create` makes log-governed with a genesis entry); present
321
321
  * without `history`, it is the plain point-state descriptor and the store
322
322
  * behaves exactly like `collectionDescriptorStore`; present with `history`,
@@ -360,12 +360,13 @@ export function logGovernedCollectionDescriptorStore({ collection, resolveContro
360
360
  signer
361
361
  });
362
362
  /**
363
- * The description observed by the most recent read: its sibling fields are
364
- * forwarded by a point-state replace (the server's replace semantics would
365
- * otherwise drop them), and its `encryption` member decides which write path
366
- * a replace takes. Safe to carry even if stale: every write is pinned to the
367
- * same read's validator, so a concurrent change fails the CAS instead. A
368
- * create clears it, since the Collection it described is now log-governed.
363
+ * The Collection Metadata object observed by the most recent read: its
364
+ * configuration members are forwarded by a point-state replace (the
365
+ * full-replacement PUT would otherwise drop them), and its `encryption`
366
+ * member decides which write path a replace takes. Safe to carry even if
367
+ * stale: every write is pinned to the same read's validator, so a concurrent
368
+ * change fails the CAS instead. A create clears it, since the Collection it
369
+ * described is now log-governed.
369
370
  */
370
371
  let described;
371
372
  async function readGoverned(projection) {
@@ -413,7 +414,7 @@ export function logGovernedCollectionDescriptorStore({ collection, resolveContro
413
414
  if (current === null) {
414
415
  throw unreadableDescriptionError({
415
416
  operation: 'manage recipients',
416
- advice: 'Use a capability that can read the Collection Description.'
417
+ advice: 'Use a capability that can read the Collection Metadata object.'
417
418
  });
418
419
  }
419
420
  described = current.description;