@interop/was-client 0.61.0 → 0.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -3
- package/dist/WasClient.d.ts +51 -6
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +84 -14
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts +4 -5
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +14 -11
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/epochRoster.d.ts +7 -32
- package/dist/edv/epochRoster.d.ts.map +1 -1
- package/dist/edv/epochRoster.js +10 -35
- package/dist/edv/epochRoster.js.map +1 -1
- package/dist/edv/recipients.d.ts +5 -0
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +15 -2
- package/dist/edv/recipients.js.map +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cas.d.ts +10 -7
- package/dist/internal/cas.d.ts.map +1 -1
- package/dist/internal/cas.js +18 -7
- package/dist/internal/cas.js.map +1 -1
- package/dist/internal/describe.d.ts +6 -0
- package/dist/internal/describe.d.ts.map +1 -1
- package/dist/internal/describe.js +27 -1
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/pagination.d.ts +24 -1
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +77 -9
- package/dist/internal/pagination.js.map +1 -1
- package/dist/internal/paths.d.ts +0 -4
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +4 -9
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +22 -6
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +31 -13
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/service.d.ts +61 -0
- package/dist/internal/service.d.ts.map +1 -0
- package/dist/internal/service.js +259 -0
- package/dist/internal/service.js.map +1 -0
- package/dist/paths.d.ts +5 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +5 -1
- package/dist/paths.js.map +1 -1
- package/dist/types.d.ts +28 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/internal/cas.js
CHANGED
|
@@ -35,12 +35,12 @@ export function isPreconditionFailed(err) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Reads the store's value, applies `mutate`, and writes the result back with a
|
|
38
|
-
* compare-and-swap (`If-Match`). Retries on a stale (`412`) validator,
|
|
39
|
-
* re-reading the fresh value each time, up to
|
|
40
|
-
* `PreconditionFailedError` naming `operation` if it
|
|
41
|
-
* `mutate` that resolves `null` signals "no change
|
|
42
|
-
* reflects the desired state, e.g. an idempotent
|
|
43
|
-
* and the current value is returned as-is. Any other error `mutate` throws
|
|
38
|
+
* compare-and-swap (`If-Match`). Retries on a stale (`412`) validator, or a
|
|
39
|
+
* `412` raised by the read itself, re-reading the fresh value each time, up to
|
|
40
|
+
* `maxAttempts`; surfaces a `PreconditionFailedError` naming `operation` if it
|
|
41
|
+
* keeps losing the race. A `mutate` that resolves `null` signals "no change
|
|
42
|
+
* needed" (the value already reflects the desired state, e.g. an idempotent
|
|
43
|
+
* retry): nothing is written and the current value is returned as-is. Any other error `mutate` throws
|
|
44
44
|
* propagates unchanged.
|
|
45
45
|
*
|
|
46
46
|
* When the store reports no value yet (`read()` resolves `null`), the optional
|
|
@@ -64,7 +64,18 @@ export function isPreconditionFailed(err) {
|
|
|
64
64
|
export async function compareAndSwap({ store, mutate, operation, onAbsent, maxAttempts = DEFAULT_CAS_ATTEMPTS }) {
|
|
65
65
|
let lastError;
|
|
66
66
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
67
|
-
|
|
67
|
+
let current;
|
|
68
|
+
try {
|
|
69
|
+
current = await store.read();
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (isPreconditionFailed(err)) {
|
|
73
|
+
// The read observed a concurrent write: re-read.
|
|
74
|
+
lastError = err;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
68
79
|
if (current === null) {
|
|
69
80
|
if (onAbsent === undefined) {
|
|
70
81
|
throw new ValidationError(`Cannot ${operation.toLowerCase()}: this store holds no value yet.`);
|
package/dist/internal/cas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cas.js","sourceRoot":"","sources":["../../src/internal/cas.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"cas.js","sourceRoot":"","sources":["../../src/internal/cas.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAA;AA0CrC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,OAAO,CACL,GAAG,YAAY,uBAAuB;QACtC,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,yBAAyB,CAAC,CACjE,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,EACtC,KAAK,EACL,MAAM,EACN,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,oBAAoB,EAOnC;IACC,IAAI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G,CAAA;YACX,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACxC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,kEAAkE;YAClE,OAAO,OAAO,CAAC,KAAK,CAAA;QACtB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;YACpD,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,yDAAyD;gBACzD,SAAS,GAAG,GAAG,CAAA;gBACf,SAAQ;YACV,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IACD,MAAM,IAAI,uBAAuB,CAC/B,GAAG,SAAS,yCAAyC,WAAW,GAAG;QACjE,sEAAsE;QACtE,YAAY,EACd,EAAE,KAAK,EAAE,SAAkB,EAAE,CAC9B,CAAA;AACH,CAAC"}
|
|
@@ -36,6 +36,12 @@ export type StoredCollectionMetadata = Record<string, unknown>;
|
|
|
36
36
|
* server guarantees the object's shape, so the assertion lives here once
|
|
37
37
|
* instead of at each reader.
|
|
38
38
|
*
|
|
39
|
+
* `custom` is normalized on the way out: a stored `null` or an empty plain
|
|
40
|
+
* object both mean "cleared" on the wire, so the returned object carries no
|
|
41
|
+
* `custom` member at all and a reader has one answer to check for rather than
|
|
42
|
+
* three. Every other member is returned as served, and the stored object itself
|
|
43
|
+
* is not modified (a write composes from it verbatim).
|
|
44
|
+
*
|
|
39
45
|
* @param stored {StoredCollectionMetadata}
|
|
40
46
|
* @returns {CollectionMetadata}
|
|
41
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings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EAMlD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAwB,CAAA;AAExE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,wBAAwB,GAC/B,oBAAoB,GAAG,SAAS,CAElC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,wBAAwB,EAChC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC9C,wBAAwB,CAgB1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACrE,OAAO,CAAC;IAAE,QAAQ,EAAE,wBAAwB,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAYvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,SAAS,EACT,WAAW,EACX,MAAM,EACN,UAA4B,EAC7B,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,QAAQ,CAAA;CAC/C,GAAG,QAAQ,CAQX"}
|
|
@@ -8,11 +8,37 @@ import { ValidationError } from '../errors.js';
|
|
|
8
8
|
* server guarantees the object's shape, so the assertion lives here once
|
|
9
9
|
* instead of at each reader.
|
|
10
10
|
*
|
|
11
|
+
* `custom` is normalized on the way out: a stored `null` or an empty plain
|
|
12
|
+
* object both mean "cleared" on the wire, so the returned object carries no
|
|
13
|
+
* `custom` member at all and a reader has one answer to check for rather than
|
|
14
|
+
* three. Every other member is returned as served, and the stored object itself
|
|
15
|
+
* is not modified (a write composes from it verbatim).
|
|
16
|
+
*
|
|
11
17
|
* @param stored {StoredCollectionMetadata}
|
|
12
18
|
* @returns {CollectionMetadata}
|
|
13
19
|
*/
|
|
14
20
|
export function asCollectionMetadata(stored) {
|
|
15
|
-
|
|
21
|
+
if (!isClearedCustom(stored.custom)) {
|
|
22
|
+
return stored;
|
|
23
|
+
}
|
|
24
|
+
const { custom: _cleared, ...rest } = stored;
|
|
25
|
+
return rest;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a stored `custom` value means "cleared": `null`, or a plain object
|
|
29
|
+
* with no own members. An opaque envelope on an encrypted Collection carries
|
|
30
|
+
* members, so it is never read as cleared.
|
|
31
|
+
*
|
|
32
|
+
* @param custom {unknown}
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
function isClearedCustom(custom) {
|
|
36
|
+
if (custom === null) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return (typeof custom === 'object' &&
|
|
40
|
+
!Array.isArray(custom) &&
|
|
41
|
+
Object.keys(custom).length === 0);
|
|
16
42
|
}
|
|
17
43
|
/**
|
|
18
44
|
* Whether a served encryption descriptor is the server-derived projection of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAkB9C
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,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IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,OAAO,OAAO,CAAC,UAAU,CAAA;IAC3B,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAsB,EACtB,OAAsE;IAEtE,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAA2B,OAAO,EAAE;QACrE,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC;QAC3D,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC,CAAA;IACF,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,IAAI;QACnB,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;KACpD,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,0BAA0B,CAAC,EACzC,SAAS,EACT,WAAW,EACX,MAAM,EACN,UAAU,GAAG,eAAe,EAM7B;IACC,OAAO,IAAI,UAAU,CACnB,UAAU,SAAS,sDAAsD;QACvE,kEAAkE;QAClE,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG;QACH,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC7C,CAAA;AACH,CAAC"}
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
* request, and yields one page at a time (constant memory, early-exit-friendly).
|
|
11
11
|
* `collectPages` builds on it to eagerly aggregate every page into one envelope.
|
|
12
12
|
*
|
|
13
|
+
* The server's `next` is untrusted input. Following it attaches a signed
|
|
14
|
+
* invocation (and, with no bound capability, a root zcap synthesized for
|
|
15
|
+
* whatever URL is requested), so `walkPages` only follows a `next` that stays
|
|
16
|
+
* within the first page's origin and base path, and stops after a bounded
|
|
17
|
+
* number of pages. Either violation fails the walk with a `WasServerError`.
|
|
18
|
+
*
|
|
13
19
|
* The helpers are generic over the listing envelope, so they serve all three
|
|
14
20
|
* paginated WAS listings: List Collection items (`CollectionResourcesList`),
|
|
15
21
|
* List Collections (`CollectionsList`), and List Spaces (`SpaceListing`). Each
|
|
@@ -17,6 +23,12 @@
|
|
|
17
23
|
*/
|
|
18
24
|
import type { CollectionResourcesList, IZcap, ResourceSummary } from '../types.js';
|
|
19
25
|
import type { ClientContext } from './request.js';
|
|
26
|
+
/**
|
|
27
|
+
* The default page-count bound on one listing walk. Generous enough for any
|
|
28
|
+
* real listing, but it stops a server whose every page returns a fresh cursor
|
|
29
|
+
* from driving an unbounded number of requests.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_MAX_PAGES = 10000;
|
|
20
32
|
/**
|
|
21
33
|
* The shared shape of every paginated listing envelope: an `items` array and an
|
|
22
34
|
* optional `next` continuation URL. The traversal core only ever touches these
|
|
@@ -77,10 +89,21 @@ export declare function signedPageWalk<T extends PageEnvelope = CollectionResour
|
|
|
77
89
|
* `next` ends the traversal defensively rather than looping forever. Yields one
|
|
78
90
|
* page at a time, so a consumer can stop early without fetching the rest.
|
|
79
91
|
*
|
|
92
|
+
* A `next` outside the first page's origin or base path, a `next` carrying a
|
|
93
|
+
* username or password, or a walk that would
|
|
94
|
+
* exceed `maxPages` pages, fails with a `WasServerError` naming the listing URL
|
|
95
|
+
* instead of fetching.
|
|
96
|
+
*
|
|
80
97
|
* @param walk {PageWalk<T>}
|
|
98
|
+
* @param [options] {object}
|
|
99
|
+
* @param [options.maxPages] {number} the most pages to yield, counting the
|
|
100
|
+
* first (defaults to {@link DEFAULT_MAX_PAGES})
|
|
81
101
|
* @returns {AsyncGenerator<T>}
|
|
102
|
+
* @throws {WasServerError} when `next` leaves the listing or the bound is hit
|
|
82
103
|
*/
|
|
83
|
-
export declare function walkPages<T extends PageEnvelope = CollectionResourcesList>(walk: PageWalk<T
|
|
104
|
+
export declare function walkPages<T extends PageEnvelope = CollectionResourcesList>(walk: PageWalk<T>, { maxPages }?: {
|
|
105
|
+
maxPages?: number;
|
|
106
|
+
}): AsyncGenerator<T>;
|
|
84
107
|
/**
|
|
85
108
|
* Eagerly follows every `next` link, aggregating all pages' items into a single
|
|
86
109
|
* envelope shaped like the first page (with `next` dropped, since the whole list
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/internal/pagination.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/internal/pagination.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EACV,uBAAuB,EACvB,KAAK,EACL,eAAe,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAKjD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAS,CAAA;AAEvC;;;;GAIG;AACH,KAAK,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvD;;;;GAIG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,YAAY,GAAG,uBAAuB;IACxE,KAAK,EAAE,CAAC,CAAA;IACR,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;CAC9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,CAAC,SAAS,Y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AC,CAAC,GAAG,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,CAI7C;AAED;;;;;;;GAOG;AACH,wBAAuB,SAAS,CAC9B,KAAK,EAAE,aAAa,CAAC,uBAAuB,CAAC,GAC5C,cAAc,CAAC,eAAe,CAAC,CAIjC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { send } from './request.js';
|
|
2
2
|
import { dataOrNull } from './content.js';
|
|
3
|
+
import { WasServerError } from '../errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* The default page-count bound on one listing walk. Generous enough for any
|
|
6
|
+
* real listing, but it stops a server whose every page returns a fresh cursor
|
|
7
|
+
* from driving an unbounded number of requests.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_MAX_PAGES = 10_000;
|
|
3
10
|
/**
|
|
4
11
|
* Builds a {@link PageWalk} by fetching the first page with the same
|
|
5
12
|
* `fetchPage` used for every following page -- the shared shape of the signed
|
|
@@ -36,6 +43,50 @@ export async function signedPageWalk(context, { firstUrl, capability }) {
|
|
|
36
43
|
fetchPage: async (url) => dataOrNull(await send(context, { url, method: 'GET', capability, read: true }))
|
|
37
44
|
});
|
|
38
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolves a server-supplied `next` against the URL of the page that produced
|
|
48
|
+
* it, and checks that the result stays within the listing: the same origin as
|
|
49
|
+
* the first page, a path equal to or under the first page's path, and no
|
|
50
|
+
* username or password. A `next` that fails any check is never fetched, because
|
|
51
|
+
* the fetch would carry the caller's signed invocation to wherever the server
|
|
52
|
+
* pointed it.
|
|
53
|
+
*
|
|
54
|
+
* @param options {object}
|
|
55
|
+
* @param options.next {unknown} the `next` value from the page
|
|
56
|
+
* @param options.baseUrl {string} the URL of the page that produced it
|
|
57
|
+
* @param options.firstUrl {URL} the canonicalized first page URL
|
|
58
|
+
* @returns {string} the absolute, canonicalized page URL
|
|
59
|
+
* @throws {WasServerError} when `next` is not a URL or leaves the listing
|
|
60
|
+
*/
|
|
61
|
+
function resolveNext({ next, baseUrl, firstUrl }) {
|
|
62
|
+
const listingUrl = firstUrl.toString();
|
|
63
|
+
let pageUrl;
|
|
64
|
+
try {
|
|
65
|
+
// A parsed body is untrusted: a non-string `next` would otherwise be
|
|
66
|
+
// coerced into a relative path and followed.
|
|
67
|
+
if (typeof next !== 'string') {
|
|
68
|
+
throw new TypeError(`\`next\` is a ${typeof next}, not a string.`);
|
|
69
|
+
}
|
|
70
|
+
pageUrl = new URL(next, baseUrl);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
throw new WasServerError(`The listing at "${listingUrl}" served a \`next\` link that is not a ` +
|
|
74
|
+
`URL: ${JSON.stringify(next)}.`, { requestUrl: listingUrl, cause: err });
|
|
75
|
+
}
|
|
76
|
+
const basePath = firstUrl.pathname.endsWith('/')
|
|
77
|
+
? firstUrl.pathname
|
|
78
|
+
: `${firstUrl.pathname}/`;
|
|
79
|
+
const sameOrigin = pageUrl.origin !== 'null' && pageUrl.origin === firstUrl.origin;
|
|
80
|
+
const underBasePath = pageUrl.pathname === firstUrl.pathname ||
|
|
81
|
+
pageUrl.pathname.startsWith(basePath);
|
|
82
|
+
const hasCredentials = pageUrl.username !== '' || pageUrl.password !== '';
|
|
83
|
+
if (!sameOrigin || !underBasePath || hasCredentials) {
|
|
84
|
+
throw new WasServerError(`The listing at "${listingUrl}" served a \`next\` link ` +
|
|
85
|
+
`("${pageUrl.toString()}") outside its origin or base path, or ` +
|
|
86
|
+
'with credentials in it. It was not followed.', { requestUrl: listingUrl });
|
|
87
|
+
}
|
|
88
|
+
return pageUrl.toString();
|
|
89
|
+
}
|
|
39
90
|
/**
|
|
40
91
|
* Lazily walks a list response page by page, yielding the first page and then
|
|
41
92
|
* each page reached by following `next`. Each `next` is resolved relative to the
|
|
@@ -43,29 +94,46 @@ export async function signedPageWalk(context, { firstUrl, capability }) {
|
|
|
43
94
|
* `next` ends the traversal defensively rather than looping forever. Yields one
|
|
44
95
|
* page at a time, so a consumer can stop early without fetching the rest.
|
|
45
96
|
*
|
|
97
|
+
* A `next` outside the first page's origin or base path, a `next` carrying a
|
|
98
|
+
* username or password, or a walk that would
|
|
99
|
+
* exceed `maxPages` pages, fails with a `WasServerError` naming the listing URL
|
|
100
|
+
* instead of fetching.
|
|
101
|
+
*
|
|
46
102
|
* @param walk {PageWalk<T>}
|
|
103
|
+
* @param [options] {object}
|
|
104
|
+
* @param [options.maxPages] {number} the most pages to yield, counting the
|
|
105
|
+
* first (defaults to {@link DEFAULT_MAX_PAGES})
|
|
47
106
|
* @returns {AsyncGenerator<T>}
|
|
107
|
+
* @throws {WasServerError} when `next` leaves the listing or the bound is hit
|
|
48
108
|
*/
|
|
49
|
-
export async function* walkPages(walk) {
|
|
50
|
-
const { first,
|
|
109
|
+
export async function* walkPages(walk, { maxPages = DEFAULT_MAX_PAGES } = {}) {
|
|
110
|
+
const { first, fetchPage } = walk;
|
|
111
|
+
// Canonicalize the first URL once: it is both the scope every `next` is
|
|
112
|
+
// checked against and the seed of the cycle guard. Every followed `next` is
|
|
113
|
+
// canonicalized via `new URL(...)`, so an equivalent-but-unequal seed (e.g.
|
|
114
|
+
// an explicit default port) would let a next-link back to page 1 defeat the
|
|
115
|
+
// guard and yield its items twice.
|
|
116
|
+
const firstUrl = new URL(walk.firstUrl);
|
|
51
117
|
yield first;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// defeat the guard and yield its items twice.
|
|
56
|
-
const seen = new Set([new URL(firstUrl).toString()]);
|
|
57
|
-
let baseUrl = firstUrl;
|
|
118
|
+
const seen = new Set([firstUrl.toString()]);
|
|
119
|
+
let pageCount = 1;
|
|
120
|
+
let baseUrl = firstUrl.toString();
|
|
58
121
|
let next = first.next;
|
|
59
122
|
while (next) {
|
|
60
|
-
const pageUrl =
|
|
123
|
+
const pageUrl = resolveNext({ next, baseUrl, firstUrl });
|
|
61
124
|
if (seen.has(pageUrl)) {
|
|
62
125
|
break;
|
|
63
126
|
}
|
|
127
|
+
if (pageCount >= maxPages) {
|
|
128
|
+
throw new WasServerError(`The listing at "${firstUrl.toString()}" did not end within ` +
|
|
129
|
+
`${maxPages} pages.`, { requestUrl: firstUrl.toString() });
|
|
130
|
+
}
|
|
64
131
|
seen.add(pageUrl);
|
|
65
132
|
const page = await fetchPage(pageUrl);
|
|
66
133
|
if (page === null) {
|
|
67
134
|
break;
|
|
68
135
|
}
|
|
136
|
+
pageCount += 1;
|
|
69
137
|
yield page;
|
|
70
138
|
baseUrl = pageUrl;
|
|
71
139
|
next = page.next;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/internal/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/internal/pagination.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAoBvC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAEjC,EACA,QAAQ,EACR,SAAS,EAIV;IACC,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAA;IACvC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA;AAC/D,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC,OAAsB,EACtB,EAAE,QAAQ,EAAE,UAAU,EAA4C;IAElE,OAAO,aAAa,CAAI;QACtB,QAAQ;QACR,SAAS,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE,CACrB,UAAU,C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CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,gBAAgB,CAErC,IAAwB;IACxB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,SAAS,CAC9B,KAA6C;IAE7C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;AACH,CAAC"}
|
package/dist/internal/paths.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `/spaces/` -- the SpacesRepository (create / list spaces).
|
|
3
|
-
*/
|
|
4
|
-
export declare function spacesRoot(): string;
|
|
5
1
|
/**
|
|
6
2
|
* `/space/:spaceId/` -- the Space container in canonical form: the target a
|
|
7
3
|
* Space root capability names, the URL whose `GET` lists the Space's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AA8GA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAA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AAM,EAAE,CAAA;CAAE,CAAA;AAEjE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,MAAM,EACP,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,eAAe,GAAG,IAAI,CAazB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA0CvE"}
|
package/dist/internal/paths.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* URL path builders for the WAS server, encoding the trailing-slash
|
|
6
6
|
* canonicalization once. The convention: a trailing slash marks a container in
|
|
7
|
-
* canonical form (`/
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
10
11
|
*
|
|
11
12
|
* A container's own description is not at its URL: it lives at the reserved
|
|
12
13
|
* `meta` segment (`spaceMeta`, `collectionMeta`), beside the Resource-level
|
|
@@ -82,12 +83,6 @@ function encodeResourceId(resourceId) {
|
|
|
82
83
|
assertNotReserved({ id: resourceId, kind: 'resource' });
|
|
83
84
|
return encode(resourceId);
|
|
84
85
|
}
|
|
85
|
-
/**
|
|
86
|
-
* `/spaces/` -- the SpacesRepository (create / list spaces).
|
|
87
|
-
*/
|
|
88
|
-
export function spacesRoot() {
|
|
89
|
-
return '/spaces/';
|
|
90
|
-
}
|
|
91
86
|
/**
|
|
92
87
|
* `/space/:spaceId` -- the slash-less prefix the space-level sub-endpoints hang
|
|
93
88
|
* off. Module-private: the bare form is not a path this client ever requests
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,eAAe,CAAA;AAEtB;;;;;;;;;;GAUG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC1D,MAAM,IAAI,eAAe,CACvB,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,+BAA+B;YAClE,qDAAqD,CACxD,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,OAAe;IAC7B,aAAa,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,iBAAiB,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;IAC3D,OAAO,MAAM,CAAC,YAAY,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,UAAkB;IAC1C,iBAAiB,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;IACvD,OAAO,MAAM,CAAC,UAAU,CAAC,CAAA;AAC3B,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;AACpC,C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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,
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;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,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AAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAQnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,OAAO,EAAE,aAAa,EACtB,EAAE,IAAI,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"}
|
package/dist/internal/request.js
CHANGED
|
@@ -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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAoC3C,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,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;AAClE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAsB,EACtB,KAAgB;IAEhB,MAAM,GAAG,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7C,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IACvB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAA;IACpC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