@interop/was-client 0.96.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -10
- package/dist/Collection.d.ts +1 -1
- package/dist/Collection.js +7 -7
- package/dist/Collection.js.map +1 -1
- package/dist/Space.js +1 -1
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +32 -11
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +81 -32
- package/dist/WasClient.js.map +1 -1
- package/dist/internal/grant.js +6 -6
- package/dist/internal/grant.js.map +1 -1
- package/dist/internal/paths.d.ts +52 -18
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +137 -42
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +3 -3
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/revoke.js +3 -3
- package/dist/internal/revoke.js.map +1 -1
- package/dist/internal/service.d.ts +1 -0
- package/dist/internal/service.d.ts.map +1 -1
- package/dist/internal/service.js +1 -0
- package/dist/internal/service.js.map +1 -1
- package/dist/paths.d.ts +4 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -2
- package/dist/paths.js.map +1 -1
- package/package.json +1 -1
package/dist/WasClient.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { collectionItemsUrl, parseSpaceTarget } from './internal/paths.js';
|
|
1
|
+
import { baseUrlOfSpacesUrl, collectionItemsUrl, parseSpaceTarget, spacesUrl } 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';
|
|
@@ -6,19 +6,36 @@ import { delegateGrant } from './internal/grant.js';
|
|
|
6
6
|
import { spaceIdOf, submitRevocation } from './internal/revoke.js';
|
|
7
7
|
import { Memo } from './internal/memo.js';
|
|
8
8
|
import { discoverService, selectServiceVersion } from './internal/service.js';
|
|
9
|
-
import { NotSupportedError, ValidationError, WasServerError } from './errors.js';
|
|
9
|
+
import { IncompatibleServerError, NotSupportedError, ValidationError, WasServerError } from './errors.js';
|
|
10
10
|
import { zcapClientForSigner } from './zcapClient.js';
|
|
11
11
|
import { Space } from './Space.js';
|
|
12
12
|
import { Collection } from './Collection.js';
|
|
13
13
|
import { Resource } from './Resource.js';
|
|
14
14
|
export class WasClient {
|
|
15
|
+
/**
|
|
16
|
+
* The server's Spaces Repository URL, in canonical trailing-slash form
|
|
17
|
+
* (`https://host/spaces/`). Service discovery starts here.
|
|
18
|
+
*/
|
|
15
19
|
serverUrl;
|
|
20
|
+
/**
|
|
21
|
+
* The server base URL every Space path hangs off, without a trailing slash:
|
|
22
|
+
* the parent of {@link serverUrl} (`https://host`, or `https://host/was` on
|
|
23
|
+
* a sub-path mount). Zcap `invocationTarget`s are built beneath it.
|
|
24
|
+
*/
|
|
25
|
+
baseUrl;
|
|
16
26
|
zcapClient;
|
|
17
27
|
encryption;
|
|
18
28
|
/**
|
|
19
29
|
* @param options {object}
|
|
20
|
-
* @param options.serverUrl {string}
|
|
21
|
-
*
|
|
30
|
+
* @param options.serverUrl {string} the server's Spaces Repository URL
|
|
31
|
+
* (`https://host/spaces/`, or `https://host/was/spaces/` on a sub-path
|
|
32
|
+
* mount). The base URL for Space paths and zcap `invocationTarget`s is
|
|
33
|
+
* its parent. Service discovery starts from this URL rather than from the
|
|
34
|
+
* base, which is often a landing page with no `service` link. The value
|
|
35
|
+
* is normalized to canonical form; `baseUrlOfSpacesUrl` in `./paths`
|
|
36
|
+
* states what is accepted. The client is built from this URL only: a
|
|
37
|
+
* server with no Spaces Repository (the spec leaves the endpoint
|
|
38
|
+
* optional) has no URL this constructor accepts and is not supported.
|
|
22
39
|
* @param options.zcapClient {ZcapClient} an ezcap client holding the signer
|
|
23
40
|
* @param [options.encryption] {EncryptionProvider} the keystore that
|
|
24
41
|
* supplies keys for collections declared encrypted (by their `encryption`
|
|
@@ -31,11 +48,20 @@ export class WasClient {
|
|
|
31
48
|
* description the caller already holds (from a cache, say). The client
|
|
32
49
|
* selects its version from this copy instead of discovering the document
|
|
33
50
|
* from `serverUrl`, and still refuses it with `IncompatibleServerError` if
|
|
34
|
-
* it names no version this client speaks
|
|
35
|
-
* discards it and
|
|
51
|
+
* it names no version this client speaks or advertises a Spaces Repository
|
|
52
|
+
* other than `serverUrl`. `service({ refresh: true })` discards it and
|
|
53
|
+
* discovers afresh.
|
|
54
|
+
* @throws {ValidationError} when `serverUrl` is not a Spaces Repository URL
|
|
36
55
|
*/
|
|
37
56
|
constructor({ serverUrl, zcapClient, encryption, serviceDescription }) {
|
|
38
|
-
|
|
57
|
+
const baseUrl = baseUrlOfSpacesUrl(serverUrl);
|
|
58
|
+
if (baseUrl === null) {
|
|
59
|
+
throw new ValidationError(`serverUrl "${serverUrl}" is not a Spaces Repository URL. Pass the ` +
|
|
60
|
+
"server's `/spaces/` URL as an absolute URL, for example " +
|
|
61
|
+
'"https://host/spaces/".');
|
|
62
|
+
}
|
|
63
|
+
this.serverUrl = spacesUrl({ baseUrl });
|
|
64
|
+
this.baseUrl = baseUrl;
|
|
39
65
|
this.zcapClient = zcapClient;
|
|
40
66
|
this.encryption = encryption;
|
|
41
67
|
this.#serviceDescription = serviceDescription;
|
|
@@ -79,16 +105,36 @@ export class WasClient {
|
|
|
79
105
|
return signer.id.split('#')[0];
|
|
80
106
|
}
|
|
81
107
|
#serviceDescription;
|
|
82
|
-
#service = new Memo(async () =>
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
#service = new Memo(async () => {
|
|
109
|
+
const info = this.#serviceDescription === undefined
|
|
110
|
+
? await discoverService({ url: this.serverUrl })
|
|
111
|
+
: selectServiceVersion(this.#serviceDescription);
|
|
112
|
+
// Every Space path is built beneath the parent of `serverUrl`, so a server
|
|
113
|
+
// that advertises its Spaces Repository elsewhere would be addressed at
|
|
114
|
+
// the wrong mount. Refuse it by name rather than misroute. Both sides are
|
|
115
|
+
// compared in canonical base-URL form, so an advertised value that differs
|
|
116
|
+
// only in serialization (host case, default port, trailing slash) passes.
|
|
117
|
+
if (info.spacesUrl !== undefined) {
|
|
118
|
+
const advertisedBase = baseUrlOfSpacesUrl(info.spacesUrl);
|
|
119
|
+
if (advertisedBase !== this.baseUrl) {
|
|
120
|
+
const why = advertisedBase === null
|
|
121
|
+
? `which is not a Spaces Repository URL (an absolute http(s) ` +
|
|
122
|
+
`URL ending in a "spaces" segment, with no query or fragment).`
|
|
123
|
+
: `but this client was given "${this.serverUrl}".`;
|
|
124
|
+
throw new IncompatibleServerError(`The server advertises its Spaces Repository at ` +
|
|
125
|
+
`"${info.spacesUrl}", ${why}`, { requestUrl: this.serverUrl });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return info;
|
|
129
|
+
});
|
|
85
130
|
/**
|
|
86
131
|
* Discovers the server's service description and the WAS version this
|
|
87
132
|
* client speaks with it. Follows the `rel="service"` link on the response to
|
|
88
|
-
* an unsigned `HEAD` of `serverUrl
|
|
89
|
-
* unsigned `GET`. No capability is invoked. The
|
|
90
|
-
* life of the client and shared by every handle;
|
|
91
|
-
* one discovery, and a failure is not memoized, so
|
|
133
|
+
* an unsigned `HEAD` of `serverUrl` (the Spaces Repository URL), then reads
|
|
134
|
+
* the linked document with an unsigned `GET`. No capability is invoked. The
|
|
135
|
+
* result is memoized for the life of the client and shared by every handle;
|
|
136
|
+
* concurrent callers share one discovery, and a failure is not memoized, so
|
|
137
|
+
* the next call retries.
|
|
92
138
|
*
|
|
93
139
|
* Every signed request waits on this discovery, so a caller rarely needs to
|
|
94
140
|
* call it first. It is the way to read the server-wide affordances:
|
|
@@ -105,8 +151,9 @@ export class WasClient {
|
|
|
105
151
|
* advertising
|
|
106
152
|
* @returns {Promise<ServiceInfo>}
|
|
107
153
|
* @throws {IncompatibleServerError} when the server's responses carry no
|
|
108
|
-
* `service` link (it predates v0.5), the document is malformed,
|
|
109
|
-
*
|
|
154
|
+
* `service` link (it predates v0.5), the document is malformed, it lists
|
|
155
|
+
* no version this client speaks, or it advertises a Spaces Repository URL
|
|
156
|
+
* other than `serverUrl`
|
|
110
157
|
*/
|
|
111
158
|
async service(options = {}) {
|
|
112
159
|
if (options.refresh) {
|
|
@@ -116,30 +163,31 @@ export class WasClient {
|
|
|
116
163
|
return this.#service.get();
|
|
117
164
|
}
|
|
118
165
|
/**
|
|
119
|
-
*
|
|
166
|
+
* Waits for discovery and refuses a server whose service description has no
|
|
167
|
+
* Spaces Repository. Discovery has already checked that an advertised
|
|
168
|
+
* `spaces` URL names `serverUrl`, so callers address `serverUrl` directly.
|
|
120
169
|
*
|
|
121
|
-
* @returns {Promise<
|
|
170
|
+
* @returns {Promise<void>}
|
|
122
171
|
* @throws {NotSupportedError} when the server does not implement the
|
|
123
172
|
* Spaces Repository
|
|
124
173
|
*/
|
|
125
|
-
async #
|
|
174
|
+
async #assertSpacesRepository() {
|
|
126
175
|
const { spacesUrl, version } = await this.service();
|
|
127
176
|
if (spacesUrl === undefined) {
|
|
128
|
-
throw new NotSupportedError(`The server at "${this.
|
|
177
|
+
throw new NotSupportedError(`The server at "${this.baseUrl}" does not implement the Spaces ` +
|
|
129
178
|
`Repository: its WAS ${version} service description entry has no ` +
|
|
130
179
|
'`spaces` URL.');
|
|
131
180
|
}
|
|
132
|
-
return spacesUrl;
|
|
133
181
|
}
|
|
134
182
|
#cachedContext;
|
|
135
183
|
get #context() {
|
|
136
|
-
// `
|
|
184
|
+
// `baseUrl`, `zcapClient` and `encryption` are all constructor-fixed, so
|
|
137
185
|
// the context is derived once and reused rather than reallocating the
|
|
138
186
|
// object on every handle access.
|
|
139
187
|
if (this.#cachedContext === undefined) {
|
|
140
188
|
const readControllerDid = () => this.controllerDid;
|
|
141
189
|
this.#cachedContext = {
|
|
142
|
-
|
|
190
|
+
baseUrl: this.baseUrl,
|
|
143
191
|
zcapClient: this.zcapClient,
|
|
144
192
|
// Read lazily, so building a handle costs nothing and a
|
|
145
193
|
// delegation-only client (a `ZcapClient` with a delegation signer and
|
|
@@ -200,8 +248,9 @@ export class WasClient {
|
|
|
200
248
|
...(desc.name !== undefined && { name: desc.name }),
|
|
201
249
|
...(desc.type !== undefined && { type: desc.type })
|
|
202
250
|
};
|
|
251
|
+
await this.#assertSpacesRepository();
|
|
203
252
|
const response = await send(this.#context, {
|
|
204
|
-
url:
|
|
253
|
+
url: this.serverUrl,
|
|
205
254
|
method: 'POST',
|
|
206
255
|
json: body
|
|
207
256
|
});
|
|
@@ -229,9 +278,9 @@ export class WasClient {
|
|
|
229
278
|
* @throws {NotSupportedError} when the server has no Spaces Repository
|
|
230
279
|
*/
|
|
231
280
|
async listSpaces() {
|
|
232
|
-
|
|
281
|
+
await this.#assertSpacesRepository();
|
|
233
282
|
const walk = await signedPageWalk(this.#context, {
|
|
234
|
-
firstUrl:
|
|
283
|
+
firstUrl: this.serverUrl
|
|
235
284
|
});
|
|
236
285
|
// The first page always carries the listing body (an unauthorized caller
|
|
237
286
|
// still gets an empty `items` list, not an error), so a `null` walk is a
|
|
@@ -239,7 +288,7 @@ export class WasClient {
|
|
|
239
288
|
// body did not parse as JSON. Report it as one, rather than as a
|
|
240
289
|
// `TypeError` from destructuring `null`.
|
|
241
290
|
if (walk === null) {
|
|
242
|
-
throw new WasServerError(`The space listing at "${
|
|
291
|
+
throw new WasServerError(`The space listing at "${this.serverUrl}" answered with no JSON body.`);
|
|
243
292
|
}
|
|
244
293
|
const listing = await collectPages(walk);
|
|
245
294
|
// A paginating server omits `totalItems` on truncated pages; the walk has
|
|
@@ -353,8 +402,8 @@ export class WasClient {
|
|
|
353
402
|
catch (err) {
|
|
354
403
|
throw new ValidationError(`invocationTarget "${target}" is not a valid absolute URL.`, { cause: err });
|
|
355
404
|
}
|
|
356
|
-
// `parseSpaceTarget` owns the path grammar: it strips `
|
|
357
|
-
//
|
|
405
|
+
// `parseSpaceTarget` owns the path grammar: it strips `baseUrl`'s path
|
|
406
|
+
// first (so a WAS mounted under a sub-path -- `https://host/was/` --
|
|
358
407
|
// classifies just as a bare-origin deployment does, which `parseSpacePath`
|
|
359
408
|
// alone cannot) and percent-decodes each segment, since the path builders
|
|
360
409
|
// re-encode every id. Classifying the full segment list -- rather than
|
|
@@ -362,10 +411,10 @@ export class WasClient {
|
|
|
362
411
|
// (`/space/s/policy`, `/space/s/c/r/meta`, ...) from being silently
|
|
363
412
|
// truncated to the nearest containment handle, whose derived URLs would
|
|
364
413
|
// mismatch the capability's invocation target.
|
|
365
|
-
const parsed = parseSpaceTarget({
|
|
414
|
+
const parsed = parseSpaceTarget({ baseUrl: this.baseUrl, target });
|
|
366
415
|
if (parsed === null) {
|
|
367
416
|
throw new ValidationError(`Cannot derive a handle from invocationTarget "${target}": it does ` +
|
|
368
|
-
`not address a resource on "${this.
|
|
417
|
+
`not address a resource on "${this.baseUrl}".`);
|
|
369
418
|
}
|
|
370
419
|
if (parsed.kind === 'sub-resource') {
|
|
371
420
|
throw new ValidationError(`invocationTarget "${target}" addresses a reserved ` +
|
|
@@ -428,7 +477,7 @@ export class WasClient {
|
|
|
428
477
|
}
|
|
429
478
|
/**
|
|
430
479
|
* The signed escape hatch, mirroring ezcap's generic `request()`. Resolves
|
|
431
|
-
* `path` against `
|
|
480
|
+
* `path` against `baseUrl`, defaults `action` to `method`, and signs via the
|
|
432
481
|
* wrapped client. Returns the raw `HttpResponse` and throws raw ky/ezcap
|
|
433
482
|
* errors -- it does not apply the null-on-404 or typed-error conveniences.
|
|
434
483
|
* Like every signed request it waits on {@link service} first, and rejects
|
package/dist/WasClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasClient.js","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAeA,OAAO,
|
|
1
|
+
{"version":3,"file":"WasClient.js","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AAY,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/internal/grant.js
CHANGED
|
@@ -12,16 +12,16 @@ import { ValidationError } from '../errors.js';
|
|
|
12
12
|
* target -- hence the object form in `revoke.ts`.)
|
|
13
13
|
*
|
|
14
14
|
* @param options {object}
|
|
15
|
-
* @param options.
|
|
15
|
+
* @param options.baseUrl {string} the client's server base URL
|
|
16
16
|
* @param options.target {string} the absolute grant target URL
|
|
17
17
|
* @returns {string | undefined}
|
|
18
18
|
*/
|
|
19
|
-
function spaceRootCapabilityId({
|
|
20
|
-
const parsed = parseSpaceTarget({
|
|
19
|
+
function spaceRootCapabilityId({ baseUrl, target }) {
|
|
20
|
+
const parsed = parseSpaceTarget({ baseUrl, target });
|
|
21
21
|
if (parsed === null) {
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
const spaceUrl = toUrl({
|
|
24
|
+
const spaceUrl = toUrl({ baseUrl, path: spacePath(parsed.spaceId) });
|
|
25
25
|
return rootCapabilityId(spaceUrl);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -48,7 +48,7 @@ export async function delegateGrant(context, { to, actions, expires, target, cap
|
|
|
48
48
|
const parent = capability ??
|
|
49
49
|
(target === undefined
|
|
50
50
|
? undefined
|
|
51
|
-
: spaceRootCapabilityId({
|
|
51
|
+
: spaceRootCapabilityId({ baseUrl: context.baseUrl, target }));
|
|
52
52
|
return context.zcapClient.delegate({
|
|
53
53
|
controller: to,
|
|
54
54
|
invocationTarget: target,
|
|
@@ -97,7 +97,7 @@ export function allowsAction({ zcap, action }) {
|
|
|
97
97
|
export async function delegateGrantAt(context, { path, options, capability }) {
|
|
98
98
|
return delegateGrant(context, {
|
|
99
99
|
...options,
|
|
100
|
-
target: options.target ?? toUrl({
|
|
100
|
+
target: options.target ?? toUrl({ baseUrl: context.baseUrl, path }),
|
|
101
101
|
capability: options.capability ?? capability
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;;;;;;;;;;;;GAcG;AACH,SAAS,qBAAqB,CAAC,EAC7B,
|
|
1
|
+
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,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B,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,IAAI,EACJ,MAAM,EAIP;IACC,MAAM,OAAO,GAAG,IAAI,EAAE,aAAa,CAAA;IACnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAC5D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IACnC,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAsB,EACtB,EACE,IAAI,EACJ,OAAO,EACP,UAAU,EACkD;IAE9D,OAAO,aAAa,CAAC,OAAO,EAAE;QAC5B,GAAG,OAAO;QACV,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;QACnE,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,UAAU;KAC7C,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/internal/paths.d.ts
CHANGED
|
@@ -147,21 +147,52 @@ export declare function resourcePolicy(spaceId: string, collectionId: string, re
|
|
|
147
147
|
* @returns {string}
|
|
148
148
|
*/
|
|
149
149
|
export declare function resourceChunkPath(spaceId: string, collectionId: string, resourceId: string, chunkIndex: number): string;
|
|
150
|
+
/**
|
|
151
|
+
* The Spaces Repository URL beneath a server base URL: the reserved `spaces`
|
|
152
|
+
* segment at the server root, in canonical trailing-slash form. This is the
|
|
153
|
+
* URL a `WasClient` is constructed with (its `serverUrl`), so a consumer that
|
|
154
|
+
* holds only a Space or Collection URL forms the client's `serverUrl` from the
|
|
155
|
+
* base `parseAbsoluteSpaceTarget` reads off it.
|
|
156
|
+
*
|
|
157
|
+
* @param options {object}
|
|
158
|
+
* @param options.baseUrl {string} the server base URL
|
|
159
|
+
* @returns {string}
|
|
160
|
+
*/
|
|
161
|
+
export declare function spacesUrl({ baseUrl }: {
|
|
162
|
+
baseUrl: string;
|
|
163
|
+
}): string;
|
|
164
|
+
/**
|
|
165
|
+
* The server base URL a Spaces Repository URL sits beneath: everything before
|
|
166
|
+
* its final `spaces` segment, without a trailing slash, so
|
|
167
|
+
* `https://host/was/spaces/` yields `https://host/was` and
|
|
168
|
+
* `https://host/spaces/` yields `https://host`. A trailing run of slashes is
|
|
169
|
+
* collapsed first, so `https://host/spaces` and `https://host/spaces//` read
|
|
170
|
+
* the same. The result is in `URL` canonical form (lower-case host, default
|
|
171
|
+
* port dropped), so two serializations of one URL compare equal.
|
|
172
|
+
*
|
|
173
|
+
* Returns `null` when `url` is not an absolute `http(s)` URL, its last path
|
|
174
|
+
* segment is not `spaces`, it has an empty path segment (`https://host//spaces`),
|
|
175
|
+
* or it carries a query or fragment; the caller chooses the error.
|
|
176
|
+
*
|
|
177
|
+
* @param url {string} a Spaces Repository URL
|
|
178
|
+
* @returns {string | null}
|
|
179
|
+
*/
|
|
180
|
+
export declare function baseUrlOfSpacesUrl(url: string): string | null;
|
|
150
181
|
/**
|
|
151
182
|
* Resolves a path against the server base URL, producing an absolute URL
|
|
152
183
|
* string suitable for zcap `invocationTarget`s.
|
|
153
184
|
*
|
|
154
|
-
* The path is joined onto `
|
|
155
|
-
*
|
|
156
|
-
* prefix. A bare-origin `
|
|
185
|
+
* The path is joined onto `baseUrl`'s path rather than its origin, so a WAS
|
|
186
|
+
* deployment mounted under a sub-path (e.g. `https://host/was`) keeps that
|
|
187
|
+
* prefix. A bare-origin `baseUrl` behaves as before.
|
|
157
188
|
*
|
|
158
189
|
* @param options {object}
|
|
159
|
-
* @param options.
|
|
190
|
+
* @param options.baseUrl {string} the server base URL
|
|
160
191
|
* @param options.path {string} a leading-slash path (e.g. `/space/x`)
|
|
161
192
|
* @returns {string}
|
|
162
193
|
*/
|
|
163
|
-
export declare function toUrl({
|
|
164
|
-
|
|
194
|
+
export declare function toUrl({ baseUrl, path }: {
|
|
195
|
+
baseUrl: string;
|
|
165
196
|
path: string;
|
|
166
197
|
}): string;
|
|
167
198
|
/**
|
|
@@ -200,21 +231,22 @@ export type ParsedSpacePath = {
|
|
|
200
231
|
};
|
|
201
232
|
/**
|
|
202
233
|
* Classifies an absolute `target` URL that is expected to live on this server,
|
|
203
|
-
* relative to `
|
|
234
|
+
* relative to `baseUrl`'s base path -- so a WAS mounted under a sub-path (e.g.
|
|
204
235
|
* `https://host/was/`) resolves just as a bare-origin deployment does, which
|
|
205
236
|
* `parseSpacePath` alone cannot do (it would see a leading `was` segment).
|
|
206
237
|
*
|
|
207
|
-
* Returns `null` when `target` is not beneath `
|
|
208
|
-
* another base path)
|
|
209
|
-
* `/kms`). The caller chooses whether that is
|
|
238
|
+
* Returns `null` when `target` is not beneath `baseUrl` (another origin, or
|
|
239
|
+
* another base path), carries a query or fragment, or addresses something
|
|
240
|
+
* outside the `/space` tree (e.g. `/kms`). The caller chooses whether that is
|
|
241
|
+
* an error.
|
|
210
242
|
*
|
|
211
243
|
* @param options {object}
|
|
212
|
-
* @param options.
|
|
244
|
+
* @param options.baseUrl {string} the client's server base URL
|
|
213
245
|
* @param options.target {string} an absolute URL on that server
|
|
214
246
|
* @returns {ParsedSpacePath | null}
|
|
215
247
|
*/
|
|
216
|
-
export declare function parseSpaceTarget({
|
|
217
|
-
|
|
248
|
+
export declare function parseSpaceTarget({ baseUrl, target }: {
|
|
249
|
+
baseUrl: string;
|
|
218
250
|
target: string;
|
|
219
251
|
}): ParsedSpacePath | null;
|
|
220
252
|
/**
|
|
@@ -226,16 +258,18 @@ export declare function parseSpaceTarget({ serverUrl, target }: {
|
|
|
226
258
|
* beneath any other base). This is the one for a capability received from
|
|
227
259
|
* another party, whose `invocationTarget` may name any host.
|
|
228
260
|
*
|
|
229
|
-
* Returns `null` when `target` is not an absolute URL
|
|
230
|
-
* segment,
|
|
231
|
-
*
|
|
261
|
+
* Returns `null` when `target` is not an absolute `http(s)` URL, has no
|
|
262
|
+
* `space` segment, carries a query or fragment, or has an empty segment in
|
|
263
|
+
* the base before it (`https://host//was/space/x`); these are the rules
|
|
264
|
+
* `baseUrlOfSpacesUrl` applies too. Also `null` from the path grammar for a
|
|
265
|
+
* path it cannot classify. The caller chooses whether that is an error.
|
|
232
266
|
*
|
|
233
267
|
* @param target {string} an absolute WAS URL
|
|
234
|
-
* @returns {{
|
|
268
|
+
* @returns {{ baseUrl: string; path: ParsedSpacePath } | null} the server
|
|
235
269
|
* base URL (no trailing slash) and the parsed target beneath it
|
|
236
270
|
*/
|
|
237
271
|
export declare function parseAbsoluteSpaceTarget(target: string): {
|
|
238
|
-
|
|
272
|
+
baseUrl: string;
|
|
239
273
|
path: ParsedSpacePath;
|
|
240
274
|
} | null;
|
|
241
275
|
/**
|
|
@@ -1 +1 @@
|
|
|
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,aAA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