@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
@@ -3,9 +3,26 @@
3
3
  */
4
4
  /**
5
5
  * URL path builders for the WAS server, encoding the trailing-slash
6
- * canonicalization once. Item-create and listing endpoints use a trailing
7
- * slash; get/put/delete-by-id endpoints do not. Path segments are
8
- * percent-encoded so ids never break out of their slot.
6
+ * canonicalization once. The convention: a trailing slash marks a container in
7
+ * canonical form (`/space/{s}/`, `/space/{s}/{c}/`), everything else has
8
+ * none, and no two paths differ only by a trailing slash. Path segments are
9
+ * percent-encoded so ids never break out of their slot. The Spaces Repository
10
+ * has no builder: its URL is the `spaces` member of the service description.
11
+ *
12
+ * A container's own description is not at its URL: it lives at the reserved
13
+ * `meta` segment (`spaceMeta`, `collectionMeta`), beside the Resource-level
14
+ * `resourceMeta`. The bare (slash-less) form of a container URL only
15
+ * 308-redirects, and a signed invocation covers the target it was signed for,
16
+ * so no builder here emits the bare form -- a redirect would have to be signed
17
+ * again.
18
+ *
19
+ * The parser is deliberately laxer than the builders. `parseSpacePath` accepts
20
+ * the bare form too, because the targets it classifies are not this client's
21
+ * own URLs: they are the `invocationTarget` strings of delegated capabilities
22
+ * a third party minted, and those name containers in either form. Reading one
23
+ * as the Space or Collection it addresses is what `WasClient.fromCapability`
24
+ * and the revocation route's `spaceIdOf` do; refusing the bare form there would
25
+ * reject valid capabilities over a spelling this client does not control.
9
26
  *
10
27
  * The zcap `invocationTarget` is derived from the request URL, so these
11
28
  * trailing-slash rules must match the server's per-operation `allowedTarget`
@@ -16,9 +33,8 @@
16
33
  * resource / sub-resource), so `WasClient.fromCapability` and the builders stay
17
34
  * in lockstep.
18
35
  */
19
- import { RESERVED_COLLECTION_IDS, RESERVED_RESOURCE_IDS } from '@interop/storage-core';
20
36
  import { ValidationError } from '../errors.js';
21
- import { assertNotReserved } from './reserved.js';
37
+ import { assertNotReserved, isReservedCollectionId, isReservedResourceId } from './reserved.js';
22
38
  /**
23
39
  * Rejects an id that would escape its path slot even after percent-encoding:
24
40
  * `encodeURIComponent` leaves `.` and `..` intact, and WHATWG URL resolution
@@ -68,47 +84,59 @@ function encodeResourceId(resourceId) {
68
84
  return encode(resourceId);
69
85
  }
70
86
  /**
71
- * `/spaces/` -- the SpacesRepository (create / list spaces).
72
- */
73
- export function spacesRoot() {
74
- return '/spaces/';
75
- }
76
- /**
77
- * `/space/:spaceId` -- get / update / delete a space (no trailing slash).
87
+ * `/space/:spaceId` -- the slash-less prefix the space-level sub-endpoints hang
88
+ * off. Module-private: the bare form is not a path this client ever requests
89
+ * (the server only 308-redirects it), so it is a prefix here and never a
90
+ * builder's return value. It is still a form the parser below reads, since a
91
+ * third party's capability target may be written that way.
92
+ *
93
+ * @param spaceId {string}
94
+ * @returns {string}
78
95
  */
79
- export function spacePath(spaceId) {
96
+ function spacePrefix(spaceId) {
80
97
  return `/space/${encode(spaceId)}`;
81
98
  }
82
99
  /**
83
- * `/space/:spaceId/` -- create a collection within a space (trailing slash).
100
+ * `/space/:spaceId/` -- the Space container in canonical form: the target a
101
+ * Space root capability names, the URL whose `GET` lists the Space's
102
+ * Collections, whose `POST` creates one, and whose `DELETE` removes the Space.
103
+ * The Space is an ordinary container, so its members are listed and created at
104
+ * the container itself -- there is no second builder for that.
105
+ *
106
+ * @param spaceId {string}
107
+ * @returns {string}
84
108
  */
85
- export function spaceItems(spaceId) {
86
- return `${spacePath(spaceId)}/`;
109
+ export function spacePath(spaceId) {
110
+ return `${spacePrefix(spaceId)}/`;
87
111
  }
88
112
  /**
89
- * `/space/:spaceId/collections/` -- list collections (trailing slash).
113
+ * `/space/:spaceId/meta` -- the Space Metadata object: the Space's description
114
+ * (`name`, `controller`, `type`), read with `GET` and replaced with `PUT`.
115
+ *
116
+ * @param spaceId {string}
117
+ * @returns {string}
90
118
  */
91
- export function spaceCollections(spaceId) {
92
- return `${spacePath(spaceId)}/collections/`;
119
+ export function spaceMeta(spaceId) {
120
+ return `${spacePrefix(spaceId)}/meta`;
93
121
  }
94
122
  /**
95
123
  * `/space/:spaceId/export` -- export a space as a tar archive.
96
124
  */
97
125
  export function spaceExport(spaceId) {
98
- return `${spacePath(spaceId)}/export`;
126
+ return `${spacePrefix(spaceId)}/export`;
99
127
  }
100
128
  /**
101
129
  * `/space/:spaceId/import` -- import a tar archive into a space.
102
130
  */
103
131
  export function spaceImport(spaceId) {
104
- return `${spacePath(spaceId)}/import`;
132
+ return `${spacePrefix(spaceId)}/import`;
105
133
  }
106
134
  /**
107
135
  * `/space/:spaceId/backends` -- the backends available within a space (list, and
108
136
  * register a new `external` backend).
109
137
  */
110
138
  export function spaceBackends(spaceId) {
111
- return `${spacePath(spaceId)}/backends`;
139
+ return `${spacePrefix(spaceId)}/backends`;
112
140
  }
113
141
  /**
114
142
  * `/space/:spaceId/backends/:backendId` -- a single registered `external`
@@ -121,19 +149,19 @@ export function registeredBackend(spaceId, backendId) {
121
149
  * `/space/:spaceId/quotas` -- the space-level storage quota report.
122
150
  */
123
151
  export function spaceQuotas(spaceId) {
124
- return `${spacePath(spaceId)}/quotas`;
152
+ return `${spacePrefix(spaceId)}/quotas`;
125
153
  }
126
154
  /**
127
155
  * `/space/:spaceId/policy` -- the space-level access-control policy resource.
128
156
  */
129
157
  export function spacePolicy(spaceId) {
130
- return `${spacePath(spaceId)}/policy`;
158
+ return `${spacePrefix(spaceId)}/policy`;
131
159
  }
132
160
  /**
133
161
  * `/space/:spaceId/linkset` -- the space-level linkset (policy discovery).
134
162
  */
135
163
  export function spaceLinkset(spaceId) {
136
- return `${spacePath(spaceId)}/linkset`;
164
+ return `${spacePrefix(spaceId)}/linkset`;
137
165
  }
138
166
  /**
139
167
  * `/space/:spaceId/zcaps/revocations/:capabilityId` -- submit a revocation of a
@@ -144,57 +172,69 @@ export function spaceLinkset(spaceId) {
144
172
  * deeper than any Collection or Resource route, so it shadows nothing.
145
173
  */
146
174
  export function spaceRevocation(spaceId, capabilityId) {
147
- return `${spacePath(spaceId)}/zcaps/revocations/${encode(capabilityId)}`;
175
+ return `${spacePrefix(spaceId)}/zcaps/revocations/${encode(capabilityId)}`;
148
176
  }
149
177
  /**
150
- * `/space/:spaceId/:collectionId` -- get / update / delete a collection
151
- * (no trailing slash).
178
+ * `/space/:spaceId/:collectionId` -- the slash-less prefix the collection-level
179
+ * sub-endpoints and the Resource ids hang off. Module-private, like
180
+ * {@link spacePrefix}.
181
+ *
182
+ * @param spaceId {string}
183
+ * @param collectionId {string}
184
+ * @returns {string}
152
185
  */
153
- export function collectionPath(spaceId, collectionId) {
154
- return `${spacePath(spaceId)}/${encodeCollectionId(collectionId)}`;
186
+ function collectionPrefix(spaceId, collectionId) {
187
+ return `${spacePrefix(spaceId)}/${encodeCollectionId(collectionId)}`;
155
188
  }
156
189
  /**
157
- * `/space/:spaceId/:collectionId/` -- list items / add a resource
158
- * (trailing slash).
190
+ * `/space/:spaceId/:collectionId/` -- the Collection container in canonical
191
+ * form: the target a "share this collection" capability names, the URL whose
192
+ * `GET` lists its Resources, whose `POST` adds one, and whose `DELETE` removes
193
+ * the Collection.
194
+ *
195
+ * @param spaceId {string}
196
+ * @param collectionId {string}
197
+ * @returns {string}
159
198
  */
160
- export function collectionItems(spaceId, collectionId) {
161
- return `${collectionPath(spaceId, collectionId)}/`;
199
+ export function collectionPath(spaceId, collectionId) {
200
+ return `${collectionPrefix(spaceId, collectionId)}/`;
162
201
  }
163
202
  /**
164
203
  * `/space/:spaceId/:collectionId/policy` -- the collection-level access-control
165
204
  * policy resource.
166
205
  */
167
206
  export function collectionPolicy(spaceId, collectionId) {
168
- return `${collectionPath(spaceId, collectionId)}/policy`;
207
+ return `${collectionPrefix(spaceId, collectionId)}/policy`;
169
208
  }
170
209
  /**
171
210
  * `/space/:spaceId/:collectionId/linkset` -- the collection-level linkset
172
211
  * (policy discovery).
173
212
  */
174
213
  export function collectionLinkset(spaceId, collectionId) {
175
- return `${collectionPath(spaceId, collectionId)}/linkset`;
214
+ return `${collectionPrefix(spaceId, collectionId)}/linkset`;
176
215
  }
177
216
  /**
178
217
  * `/space/:spaceId/:collectionId/backend` -- the "Collection Backend Selected"
179
218
  * descriptor (the backend this collection is stored on).
180
219
  */
181
220
  export function collectionBackend(spaceId, collectionId) {
182
- return `${collectionPath(spaceId, collectionId)}/backend`;
221
+ return `${collectionPrefix(spaceId, collectionId)}/backend`;
183
222
  }
184
223
  /**
185
224
  * `/space/:spaceId/:collectionId/quota` -- the per-collection storage quota
186
225
  * report (spec "Quotas").
187
226
  */
188
227
  export function collectionQuota(spaceId, collectionId) {
189
- return `${collectionPath(spaceId, collectionId)}/quota`;
228
+ return `${collectionPrefix(spaceId, collectionId)}/quota`;
190
229
  }
191
230
  /**
192
- * `/space/:spaceId/:collectionId/meta` -- the Collection metadata object
193
- * (server-managed timestamps / `createdBy` / `epoch` plus the user-writable
194
- * `custom` object). Versioned independently of the Collection Description.
231
+ * `/space/:spaceId/:collectionId/meta` -- the Collection Metadata object: the
232
+ * Collection's configuration (`name`, `backend`, `encryption`, `generator`)
233
+ * together with the server-managed timestamps / `createdBy` and the
234
+ * user-writable `custom` and `epoch`, as one object under one validator.
195
235
  */
196
236
  export function collectionMeta(spaceId, collectionId) {
197
- return `${collectionPath(spaceId, collectionId)}/meta`;
237
+ return `${collectionPrefix(spaceId, collectionId)}/meta`;
198
238
  }
199
239
  /**
200
240
  * `/space/:spaceId/:collectionId/meta/log` -- the Collection's governing
@@ -209,14 +249,14 @@ export function collectionLog(spaceId, collectionId) {
209
249
  * whose body's `profile` selects the query (e.g. `changes`, `blinded-index`).
210
250
  */
211
251
  export function collectionQuery(spaceId, collectionId) {
212
- return `${collectionPath(spaceId, collectionId)}/query`;
252
+ return `${collectionPrefix(spaceId, collectionId)}/query`;
213
253
  }
214
254
  /**
215
255
  * `/space/:spaceId/:collectionId/:resourceId` -- get / put / delete a resource
216
256
  * (no trailing slash).
217
257
  */
218
258
  export function resourcePath(spaceId, collectionId, resourceId) {
219
- return `${collectionPath(spaceId, collectionId)}/${encodeResourceId(resourceId)}`;
259
+ return `${collectionPrefix(spaceId, collectionId)}/${encodeResourceId(resourceId)}`;
220
260
  }
221
261
  /**
222
262
  * `/space/:spaceId/:collectionId/:resourceId/meta` -- the resource metadata
@@ -322,6 +362,13 @@ export function parseSpaceTarget({ serverUrl, target }) {
322
362
  * or any 5-segment target like `/space/s/c/r/meta` -- is classified
323
363
  * `sub-resource`, never silently truncated to the nearest handle.
324
364
  *
365
+ * Empty segments are dropped, so a container addressed in either form
366
+ * classifies the same: `/space/s` and `/space/s/` are both the Space, and
367
+ * `/space/s/c` and `/space/s/c/` both the Collection. That is deliberate. The
368
+ * builders emit only the canonical trailing-slash form, but the targets parsed
369
+ * here come from capabilities minted elsewhere, and a client that reads only
370
+ * one spelling would refuse valid ones.
371
+ *
325
372
  * @param pathname {string} a URL pathname (e.g. from `new URL(...).pathname`)
326
373
  * @returns {ParsedSpacePath | null}
327
374
  */
@@ -346,7 +393,7 @@ export function parseSpacePath(pathname) {
346
393
  // A reserved segment directly under the space (`policy`, `backends`,
347
394
  // `export`, ...) addresses a space-level sub-endpoint, as does anything
348
395
  // nested beneath one (`/space/s/backends/:backendId`).
349
- if (RESERVED_COLLECTION_IDS.has(rest[0])) {
396
+ if (isReservedCollectionId(rest[0])) {
350
397
  return { kind: 'sub-resource', spaceId, segments: rest };
351
398
  }
352
399
  if (rest.length === 1) {
@@ -354,7 +401,7 @@ export function parseSpacePath(pathname) {
354
401
  }
355
402
  // A reserved segment under the collection (`policy`, `backend`, `quota`,
356
403
  // ...) addresses a collection-level sub-endpoint.
357
- if (RESERVED_RESOURCE_IDS.has(rest[1])) {
404
+ if (isReservedResourceId(rest[1])) {
358
405
  return { kind: 'sub-resource', spaceId, segments: rest };
359
406
  }
360
407
  if (rest.length === 2) {
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEjD;;;;;;;;;;GAU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I,CAAC,GAAG,QAAyC,CAAA;IACtE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IACnC,CAAC;IACD,qEAAqE;IACrE,wEAAwE;IACxE,uDAAuD;IACvD,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,EAAE,CAAC;QAC9C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC1D,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAW,EAAE,CAAA;IACzE,CAAC;IACD,yEAAyE;IACzE,kDAAkD;IAClD,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,EAAE,CAAC;QAC5C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC1D,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,OAAO;YACP,YAAY,EAAE,IAAI,CAAC,CAAC,CAAW;YAC/B,UAAU,EAAE,IAAI,CAAC,CAAC,CAAW;SAC9B,CAAA;IACH,CAAC;IACD,qEAAqE;IACrE,uDAAuD;IACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;AAC1D,CAAC"}
@@ -6,23 +6,27 @@
6
6
  * paths against the server URL and defaulting the capability `action` to the
7
7
  * HTTP method (never ezcap's `read`/`write`). `send()` adds the typed-error
8
8
  * mapping and the null-on-404 read translation; `rawRequest()` is the
9
- * unmapped escape hatch used by `was.request()`.
9
+ * unmapped escape hatch used by `was.request()`. Every signed request first
10
+ * awaits the context's memoized service discovery, so no request reaches a
11
+ * server whose protocol version this client does not speak.
10
12
  */
11
13
  import type { ZcapClient } from '@interop/ezcap';
12
14
  import type { HttpResponse } from '@interop/http-client';
13
15
  import type { EncryptionProvider } from '../codec.js';
14
- import type { IZcap, RequestInput } from '../types.js';
16
+ import type { IZcap, RequestInput, ServiceInfo } from '../types.js';
15
17
  /**
16
18
  * The shared context threaded through every handle: the server base URL, the
17
- * wrapped ezcap client, the cached controller DID of its signer, and the
18
- * optional encryption provider that supplies an encrypting codec for the
19
- * collections the client holds keys for.
19
+ * wrapped ezcap client, the cached controller DID of its signer, the optional
20
+ * encryption provider that supplies an encrypting codec for the collections
21
+ * the client holds keys for, and the memoized service discovery every signed
22
+ * request waits on.
20
23
  */
21
24
  export interface ClientContext {
22
25
  serverUrl: string;
23
26
  zcapClient: ZcapClient;
24
27
  controllerDid: string;
25
28
  encryption?: EncryptionProvider;
29
+ service: () => Promise<ServiceInfo>;
26
30
  }
27
31
  /**
28
32
  * A single signed request: the public `RequestInput` shape (either `path`,
@@ -43,13 +47,25 @@ export interface SendInput extends RequestInput {
43
47
  /**
44
48
  * Signs and sends a request via the wrapped ezcap client, returning the raw
45
49
  * `HttpResponse` and throwing the raw ky/ezcap error. Does not apply error
46
- * mapping or null-on-404 -- this is the escape-hatch primitive.
50
+ * mapping or null-on-404 -- this is the escape-hatch primitive. It waits on
51
+ * the context's service discovery first, and rejects with that discovery's
52
+ * error (such as `IncompatibleServerError`) before anything is signed.
47
53
  *
48
54
  * @param context {ClientContext}
49
55
  * @param input {SendInput}
50
56
  * @returns {Promise<HttpResponse>}
51
57
  */
52
58
  export declare function rawRequest(context: ClientContext, input: SendInput): Promise<HttpResponse>;
59
+ /**
60
+ * A plain unsigned `fetch` that maps a network failure to a `WasError`, the
61
+ * way the rest of the transport does. The response is returned as is,
62
+ * whatever its status.
63
+ *
64
+ * @param url {string}
65
+ * @param init {RequestInit}
66
+ * @returns {Promise<Response>}
67
+ */
68
+ export declare function fetchMapped(url: string, init: RequestInit): Promise<Response>;
53
69
  /**
54
70
  * Sends an **unsigned** request (a plain `fetch`, no capability invocation), for
55
71
  * reading public (`PublicCanRead`) resources that need no authorization. Applies
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAYD;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,YAAY,CAAC,CAavB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,GAAG,OAAO,CAAC,YAAY,GAAG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I,EAAE,UAAU,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzD,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAY5C"}
@@ -1,4 +1,4 @@
1
- import { mapError, httpStatus } from '../errors.js';
1
+ import { WasError, mapError, httpStatus } from '../errors.js';
2
2
  import { toUrl } from './paths.js';
3
3
  import { dataOrNull } from './content.js';
4
4
  import { readEtag } from './conditional.js';
@@ -14,7 +14,9 @@ function resolveRequestUrl(context, input) {
14
14
  /**
15
15
  * Signs and sends a request via the wrapped ezcap client, returning the raw
16
16
  * `HttpResponse` and throwing the raw ky/ezcap error. Does not apply error
17
- * mapping or null-on-404 -- this is the escape-hatch primitive.
17
+ * mapping or null-on-404 -- this is the escape-hatch primitive. It waits on
18
+ * the context's service discovery first, and rejects with that discovery's
19
+ * error (such as `IncompatibleServerError`) before anything is signed.
18
20
  *
19
21
  * @param context {ClientContext}
20
22
  * @param input {SendInput}
@@ -22,6 +24,7 @@ function resolveRequestUrl(context, input) {
22
24
  */
23
25
  export async function rawRequest(context, input) {
24
26
  const url = resolveRequestUrl(context, input);
27
+ await context.service();
25
28
  const method = input.method ?? 'GET';
26
29
  return context.zcapClient.request({
27
30
  url,
@@ -34,6 +37,23 @@ export async function rawRequest(context, input) {
34
37
  body: input.body
35
38
  });
36
39
  }
40
+ /**
41
+ * A plain unsigned `fetch` that maps a network failure to a `WasError`, the
42
+ * way the rest of the transport does. The response is returned as is,
43
+ * whatever its status.
44
+ *
45
+ * @param url {string}
46
+ * @param init {RequestInit}
47
+ * @returns {Promise<Response>}
48
+ */
49
+ export async function fetchMapped(url, init) {
50
+ try {
51
+ return await fetch(url, init);
52
+ }
53
+ catch (err) {
54
+ throw mapError(err);
55
+ }
56
+ }
37
57
  /**
38
58
  * Sends an **unsigned** request (a plain `fetch`, no capability invocation), for
39
59
  * reading public (`PublicCanRead`) resources that need no authorization. Applies
@@ -49,16 +69,10 @@ export async function rawRequest(context, input) {
49
69
  * @returns {Promise<HttpResponse | null>}
50
70
  */
51
71
  export async function unsignedRequest(input) {
52
- let response;
53
- try {
54
- response = await fetch(input.url, {
55
- method: input.method ?? 'GET',
56
- headers: input.headers
57
- });
58
- }
59
- catch (err) {
60
- throw mapError(err);
61
- }
72
+ const response = await fetchMapped(input.url, {
73
+ method: input.method ?? 'GET',
74
+ headers: input.headers
75
+ });
62
76
  if (response.ok) {
63
77
  return response;
64
78
  }
@@ -96,7 +110,11 @@ export async function send(context, input) {
96
110
  return await rawRequest(context, input);
97
111
  }
98
112
  catch (err) {
99
- if ((input.read || input.idempotent) && httpStatus(err) === 404) {
113
+ // Only a raw transport error translates: a `WasError` (such as a discovery
114
+ // refusal) is already an answer and passes through whatever its status.
115
+ if ((input.read || input.idempotent) &&
116
+ !(err instanceof WasError) &&
117
+ httpStatus(err) === 404) {
100
118
  return null;
101
119
  }
102
120
  throw mapError(err);
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAkC3C,SAAS,iBAAiB,CAAC,OAAsB,EAAE,KAAgB;IACjE,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,GAAG,CAAA;IAClB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,KA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AAgB,CACpC,OAAsB,EACtB,EAAE,IAAI,EAAE,UAAU,EAAwC;IAE1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI;QACJ,MAAM,EAAE,KAAK;QACb,UAAU;QACV,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,UAAU,CAAI,QAAQ,CAAC,CAAA;IACpC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC3C,CAAC"}
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Whether `id` is a reserved Collection-id path segment.
3
+ *
4
+ * @param id {string}
5
+ * @returns {boolean}
6
+ */
7
+ export declare function isReservedCollectionId(id: string): boolean;
8
+ /**
9
+ * Whether `id` is a reserved Resource-id path segment.
10
+ *
11
+ * @param id {string}
12
+ * @returns {boolean}
13
+ */
14
+ export declare function isReservedResourceId(id: string): boolean;
1
15
  /**
2
16
  * Throws a `ValidationError` if the given id collides with a reserved path
3
17
  * segment for its kind.
@@ -1 +1 @@
1
- {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,EAAE,EACF,IAAI,EACL,EAAE;IACD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,GAAG,UAAU,CAAA;CAChC,GAAG,IAAI,CAQP"}
1
+ {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,EAAE,EACF,IAAI,EACL,EAAE;IACD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,GAAG,UAAU,CAAA;CAChC,GAAG,IAAI,CAQP"}
@@ -7,11 +7,30 @@
7
7
  * than letting the server answer `409 Conflict`.
8
8
  *
9
9
  * The reserved sets themselves are single-sourced from `@interop/storage-core`
10
- * (the spec's Reserved Path Segment Registry) and re-exported here. This module
11
- * only adds the client-side `ValidationError`-throwing guard.
10
+ * (the spec's Reserved Path Segment Registry). This module adds the
11
+ * client-side `ValidationError`-throwing guard and the two membership
12
+ * predicates the path grammar asks with.
12
13
  */
13
14
  import { RESERVED_COLLECTION_IDS, RESERVED_RESOURCE_IDS } from '@interop/storage-core';
14
15
  import { ValidationError } from '../errors.js';
16
+ /**
17
+ * Whether `id` is a reserved Collection-id path segment.
18
+ *
19
+ * @param id {string}
20
+ * @returns {boolean}
21
+ */
22
+ export function isReservedCollectionId(id) {
23
+ return RESERVED_COLLECTION_IDS.has(id);
24
+ }
25
+ /**
26
+ * Whether `id` is a reserved Resource-id path segment.
27
+ *
28
+ * @param id {string}
29
+ * @returns {boolean}
30
+ */
31
+ export function isReservedResourceId(id) {
32
+ return RESERVED_RESOURCE_IDS.has(id);
33
+ }
15
34
  /**
16
35
  * Throws a `ValidationError` if the given id collides with a reserved path
17
36
  * segment for its kind.
@@ -23,8 +42,8 @@ import { ValidationError } from '../errors.js';
23
42
  * @returns {void}
24
43
  */
25
44
  export function assertNotReserved({ id, kind }) {
26
- const reserved = kind === 'collection' ? RESERVED_COLLECTION_IDS : RESERVED_RESOURCE_IDS;
27
- if (reserved.has(id)) {
45
+ const isReserved = kind === 'collection' ? isReservedCollectionId : isReservedResourceId;
46
+ if (isReserved(id)) {
28
47
  throw new ValidationError(`Cannot use reserved path segment "${id}" as a ${kind} id.`);
29
48
  }
30
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"reserved.js","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,EAAE,EACF,IAAI,EAIL;IACC,MAAM,QAAQ,GACZ,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,qBAAqB,CAAA;IACzE,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,eAAe,CACvB,qCAAqC,EAAE,UAAU,IAAI,MAAM,CAC5D,CAAA;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"reserved.js","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;GASG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAU;IAC/C,OAAO,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAU;IAC7C,OAAO,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,EAAE,EACF,IAAI,EAIL;IACC,MAAM,UAAU,GACd,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,oBAAoB,CAAA;IACvE,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,eAAe,CACvB,qCAAqC,EAAE,UAAU,IAAI,MAAM,CAC5D,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { ServiceInfo } from '../types.js';
2
+ /**
3
+ * The WAS specification's identifier, the `specs` key its version entries sit
4
+ * under. Provisional until the spec's rename registers it.
5
+ */
6
+ export declare const PWS_SPEC_ID = "https://w3id.org/pws";
7
+ /**
8
+ * The WAS specification versions this client speaks, newest first. Selection
9
+ * takes the first one the server lists.
10
+ */
11
+ export declare const SUPPORTED_PWS_VERSIONS: string[];
12
+ /**
13
+ * Reads the target of the first `service` link in a `Link` header (RFC 8288),
14
+ * resolved against the URL of the response that carried it. Relation types
15
+ * compare case-insensitively, a `rel` may list several space-separated types,
16
+ * and only the first `rel` parameter of a link-value counts.
17
+ *
18
+ * @param options {object}
19
+ * @param options.header {string | null} the `Link` header value
20
+ * @param options.baseUrl {string} the URL the response came from
21
+ * @returns {string | undefined} the absolute service description URL
22
+ */
23
+ export declare function serviceLinkTarget({ header, baseUrl }: {
24
+ header: string | null;
25
+ baseUrl: string;
26
+ }): string | undefined;
27
+ /**
28
+ * Applies the spec's version-selection rules to a service description: a
29
+ * `specs` key other than the WAS identifier is ignored, a version entry
30
+ * without a string `version` is ignored, and the newest version this client
31
+ * speaks is chosen. The members the client acts on are checked before they are
32
+ * used: `spaces` must be an absolute URL and `features` an array of strings.
33
+ *
34
+ * @param description {unknown} the parsed service description
35
+ * @returns {ServiceInfo}
36
+ * @throws {IncompatibleServerError} when the document lacks `url` or `specs`,
37
+ * when no entry names a version this client speaks, or when the chosen
38
+ * entry's `spaces` or `features` is malformed
39
+ */
40
+ export declare function selectServiceVersion(description: unknown): ServiceInfo;
41
+ /**
42
+ * Discovers the service description from a URL the client holds and selects
43
+ * the version to speak: an unsigned `HEAD` of `url` for its `service` link
44
+ * (the response status does not matter), then an unsigned `GET` of the linked
45
+ * document.
46
+ *
47
+ * A network failure, and a rate limit or temporary outage (429, 502, 503,
48
+ * 504) that comes without the link, reject with the mapped transport error,
49
+ * since they say nothing about the protocol the server speaks.
50
+ *
51
+ * @param options {object}
52
+ * @param options.url {string} any WAS URL, typically the client's `serverUrl`
53
+ * @returns {Promise<ServiceInfo>}
54
+ * @throws {IncompatibleServerError} when the response carries no `service`
55
+ * link, the linked document cannot be read or parsed, or version selection
56
+ * refuses it (see {@link selectServiceVersion})
57
+ */
58
+ export declare function discoverService({ url }: {
59
+ url: string;
60
+ }): Promise<ServiceInfo>;
61
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/internal/service.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,WAAW,yBAAyB,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,UAAU,CAAA;AA+C7C;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,OAAO,EACR,EAAE;IACD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,MAAM,GAAG,SAAS,CA2BrB;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,CAiEtE;AAqCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,eAAe,CAAC,EACpC,GAAG,EACJ,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,OAAO,CAAC,WAAW,CAAC,CAuCvB"}