@interop/was-client 0.100.1 → 0.102.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 +44 -11
- package/dist/Collection.d.ts +21 -5
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +38 -31
- package/dist/Collection.js.map +1 -1
- package/dist/Space.d.ts +94 -22
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +162 -79
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +5 -5
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +7 -8
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +7 -4
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/docCipher.js +2 -2
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/logGovernedDescriptorStore.d.ts +6 -1
- package/dist/edv/logGovernedDescriptorStore.d.ts.map +1 -1
- package/dist/edv/logGovernedDescriptorStore.js +68 -43
- package/dist/edv/logGovernedDescriptorStore.js.map +1 -1
- package/dist/internal/codec.d.ts +11 -1
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +11 -1
- package/dist/internal/codec.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 +18 -1
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/grant.js +1 -1
- package/dist/internal/grant.js.map +1 -1
- package/dist/internal/indexSchema.d.ts +19 -4
- package/dist/internal/indexSchema.d.ts.map +1 -1
- package/dist/internal/indexSchema.js +33 -6
- package/dist/internal/indexSchema.js.map +1 -1
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +2 -2
- package/dist/internal/pagination.js.map +1 -1
- package/dist/internal/paths.d.ts +21 -8
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +36 -13
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +47 -14
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +64 -44
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/revoke.d.ts +1 -65
- package/dist/internal/revoke.d.ts.map +1 -1
- package/dist/internal/revoke.js +5 -136
- package/dist/internal/revoke.js.map +1 -1
- package/dist/internal/rootCapability.d.ts +66 -0
- package/dist/internal/rootCapability.d.ts.map +1 -0
- package/dist/internal/rootCapability.js +144 -0
- package/dist/internal/rootCapability.js.map +1 -0
- package/dist/internal/withCodec.d.ts +19 -4
- package/dist/internal/withCodec.d.ts.map +1 -1
- package/dist/internal/withCodec.js +18 -2
- package/dist/internal/withCodec.js.map +1 -1
- package/dist/internal/write.js +13 -9
- package/dist/internal/write.js.map +1 -1
- package/dist/paths.d.ts +5 -3
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +5 -3
- package/dist/paths.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,69 +1,5 @@
|
|
|
1
1
|
import type { ClientContext } from './request.js';
|
|
2
|
-
import type { IDelegatedZcap
|
|
3
|
-
/**
|
|
4
|
-
* The root capability id for an invocation target URL
|
|
5
|
-
* (`urn:zcap:root:<encoded target>`) -- the id grammar shared by revocation
|
|
6
|
-
* (which invokes the revocation URL's own root capability in object form) and
|
|
7
|
-
* grant rooting (which parents an unparented grant on its Space's root
|
|
8
|
-
* capability id).
|
|
9
|
-
*
|
|
10
|
-
* @param target {string} the absolute invocation target URL
|
|
11
|
-
* @returns {string}
|
|
12
|
-
*/
|
|
13
|
-
export declare function rootCapabilityId(target: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* The invocation target a root capability id names: the inverse of
|
|
16
|
-
* {@link rootCapabilityId}. Returns `null` for an id that is not a root
|
|
17
|
-
* capability id, or whose encoded target is malformed.
|
|
18
|
-
*
|
|
19
|
-
* @param id {string} a capability id
|
|
20
|
-
* @returns {string | null}
|
|
21
|
-
*/
|
|
22
|
-
export declare function rootCapabilityTarget(id: string): string | null;
|
|
23
|
-
/**
|
|
24
|
-
* Builds the root capability for `target` in **object** form.
|
|
25
|
-
*
|
|
26
|
-
* The object form is load-bearing: `@interop/ezcap` accepts a *string* root
|
|
27
|
-
* capability id only when its invocation target is `https:`, which would break
|
|
28
|
-
* against an `http://localhost` server. Both forms reduce to the same
|
|
29
|
-
* `zcap id="..."` invocation header.
|
|
30
|
-
*
|
|
31
|
-
* `controller` is client-side only -- the server re-derives the real controller
|
|
32
|
-
* when it synthesizes the root capability -- so the caller's own DID is fine.
|
|
33
|
-
*
|
|
34
|
-
* @param options {object}
|
|
35
|
-
* @param options.target {string} the absolute invocation target URL
|
|
36
|
-
* @param options.controller {string} the invoking client's DID
|
|
37
|
-
* @returns {IRootZcap}
|
|
38
|
-
*/
|
|
39
|
-
export declare function rootCapability({ target, controller }: {
|
|
40
|
-
target: string;
|
|
41
|
-
controller: string;
|
|
42
|
-
}): IRootZcap;
|
|
43
|
-
/**
|
|
44
|
-
* The URL of the Space a capability is rooted in, read off its delegation
|
|
45
|
-
* chain: a Space-rooted capability's chain starts at the Space's root
|
|
46
|
-
* capability, whose id encodes the Space URL. The result is in canonical
|
|
47
|
-
* form.
|
|
48
|
-
*
|
|
49
|
-
* The root's target is taken to be the Space URL. A Space URL has no shape
|
|
50
|
-
* of its own (a Collection URL is an http(s) URL ending in a slash too), so
|
|
51
|
-
* this function cannot tell a chain rooted at a Space from one rooted at a
|
|
52
|
-
* Collection, a Resource, or a Spaces Repository: only the server, which
|
|
53
|
-
* knows its hierarchy, can, and it refuses a revocation whose chain does not
|
|
54
|
-
* root exactly in the Space. What is refused here is a root whose target
|
|
55
|
-
* cannot be a Space URL at all (an origin, a URL with a query, a URN) and a
|
|
56
|
-
* chain that starts at no root capability. A capability this client minted
|
|
57
|
-
* from a handle is always Space-rooted. A bare `was.grant({ target })` with
|
|
58
|
-
* no `spaceUrl`, the mode for a server with no Space hierarchy, roots at
|
|
59
|
-
* its target and is not revocable this way by design.
|
|
60
|
-
*
|
|
61
|
-
* @param zcap {IZcap} the capability to locate
|
|
62
|
-
* @returns {string}
|
|
63
|
-
* @throws {ValidationError} when the chain does not start at a root
|
|
64
|
-
* capability id, or that id names something that cannot be a Space URL
|
|
65
|
-
*/
|
|
66
|
-
export declare function spaceUrlOf(zcap: IZcap): string;
|
|
2
|
+
import type { IDelegatedZcap } from '../types.js';
|
|
67
3
|
/**
|
|
68
4
|
* Revokes a Space-rooted delegated capability: `POST`s it to
|
|
69
5
|
* `{spaceUrl}zcaps/revocations/:capabilityId`, invoking that URL's own root
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../src/internal/revoke.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../src/internal/revoke.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,aAAa,EACtB,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GAC7D,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
package/dist/internal/revoke.js
CHANGED
|
@@ -20,145 +20,14 @@
|
|
|
20
20
|
* gone from its controller document) synthesizes an empty controller set, so
|
|
21
21
|
* the invocation is denied.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* (`spaceUrlOf`) rather than assembled from any server root.
|
|
23
|
+
* The root capability id grammar this invokes through, and `spaceUrlOf`,
|
|
24
|
+
* live in `rootCapability.ts`, which the `./paths` entry re-exports. They are
|
|
25
|
+
* kept apart from this module so that entry evaluates no transport.
|
|
27
26
|
*/
|
|
28
|
-
import {
|
|
27
|
+
import { spaceRevocationUrl } from './paths.js';
|
|
29
28
|
import { send } from './request.js';
|
|
29
|
+
import { rootCapability } from './rootCapability.js';
|
|
30
30
|
import { ValidationError } from '../errors.js';
|
|
31
|
-
/**
|
|
32
|
-
* The zcap JSON-LD context URL, the sole `@context` of a root capability.
|
|
33
|
-
*/
|
|
34
|
-
const ZCAP_CONTEXT_URL = 'https://w3id.org/zcap/v1';
|
|
35
|
-
/**
|
|
36
|
-
* The prefix of a root capability id.
|
|
37
|
-
*/
|
|
38
|
-
const ROOT_ID_PREFIX = 'urn:zcap:root:';
|
|
39
|
-
/**
|
|
40
|
-
* The root capability id for an invocation target URL
|
|
41
|
-
* (`urn:zcap:root:<encoded target>`) -- the id grammar shared by revocation
|
|
42
|
-
* (which invokes the revocation URL's own root capability in object form) and
|
|
43
|
-
* grant rooting (which parents an unparented grant on its Space's root
|
|
44
|
-
* capability id).
|
|
45
|
-
*
|
|
46
|
-
* @param target {string} the absolute invocation target URL
|
|
47
|
-
* @returns {string}
|
|
48
|
-
*/
|
|
49
|
-
export function rootCapabilityId(target) {
|
|
50
|
-
return `${ROOT_ID_PREFIX}${encodeURIComponent(target)}`;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The invocation target a root capability id names: the inverse of
|
|
54
|
-
* {@link rootCapabilityId}. Returns `null` for an id that is not a root
|
|
55
|
-
* capability id, or whose encoded target is malformed.
|
|
56
|
-
*
|
|
57
|
-
* @param id {string} a capability id
|
|
58
|
-
* @returns {string | null}
|
|
59
|
-
*/
|
|
60
|
-
export function rootCapabilityTarget(id) {
|
|
61
|
-
if (!id.startsWith(ROOT_ID_PREFIX)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
return decodeURIComponent(id.slice(ROOT_ID_PREFIX.length));
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Builds the root capability for `target` in **object** form.
|
|
73
|
-
*
|
|
74
|
-
* The object form is load-bearing: `@interop/ezcap` accepts a *string* root
|
|
75
|
-
* capability id only when its invocation target is `https:`, which would break
|
|
76
|
-
* against an `http://localhost` server. Both forms reduce to the same
|
|
77
|
-
* `zcap id="..."` invocation header.
|
|
78
|
-
*
|
|
79
|
-
* `controller` is client-side only -- the server re-derives the real controller
|
|
80
|
-
* when it synthesizes the root capability -- so the caller's own DID is fine.
|
|
81
|
-
*
|
|
82
|
-
* @param options {object}
|
|
83
|
-
* @param options.target {string} the absolute invocation target URL
|
|
84
|
-
* @param options.controller {string} the invoking client's DID
|
|
85
|
-
* @returns {IRootZcap}
|
|
86
|
-
*/
|
|
87
|
-
export function rootCapability({ target, controller }) {
|
|
88
|
-
return {
|
|
89
|
-
'@context': ZCAP_CONTEXT_URL,
|
|
90
|
-
id: rootCapabilityId(target),
|
|
91
|
-
invocationTarget: target,
|
|
92
|
-
controller
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The id of the root capability a chain starts at: the first entry of the
|
|
97
|
-
* delegation proof's `capabilityChain`, or the `parentCapability` of a
|
|
98
|
-
* capability delegated straight from a root, or the capability's own id when
|
|
99
|
-
* it is a root. `undefined` when the capability carries no proof and no
|
|
100
|
-
* parent that names a root.
|
|
101
|
-
*
|
|
102
|
-
* The delegation proof is the one carrying `capabilityChain`, wherever it
|
|
103
|
-
* sits in a proof set: a capability may also carry an assertion proof, and
|
|
104
|
-
* nothing fixes the order.
|
|
105
|
-
*
|
|
106
|
-
* @param zcap {IZcap}
|
|
107
|
-
* @returns {string | undefined}
|
|
108
|
-
*/
|
|
109
|
-
function chainRootId(zcap) {
|
|
110
|
-
if (!('parentCapability' in zcap)) {
|
|
111
|
-
return zcap.id;
|
|
112
|
-
}
|
|
113
|
-
const proofs = Array.isArray(zcap.proof) ? zcap.proof : [zcap.proof];
|
|
114
|
-
const delegation = proofs.find(proof => proof?.capabilityChain !== undefined);
|
|
115
|
-
const first = delegation?.capabilityChain?.[0];
|
|
116
|
-
if (typeof first === 'string') {
|
|
117
|
-
return first;
|
|
118
|
-
}
|
|
119
|
-
return typeof zcap.parentCapability === 'string'
|
|
120
|
-
? zcap.parentCapability
|
|
121
|
-
: undefined;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* The URL of the Space a capability is rooted in, read off its delegation
|
|
125
|
-
* chain: a Space-rooted capability's chain starts at the Space's root
|
|
126
|
-
* capability, whose id encodes the Space URL. The result is in canonical
|
|
127
|
-
* form.
|
|
128
|
-
*
|
|
129
|
-
* The root's target is taken to be the Space URL. A Space URL has no shape
|
|
130
|
-
* of its own (a Collection URL is an http(s) URL ending in a slash too), so
|
|
131
|
-
* this function cannot tell a chain rooted at a Space from one rooted at a
|
|
132
|
-
* Collection, a Resource, or a Spaces Repository: only the server, which
|
|
133
|
-
* knows its hierarchy, can, and it refuses a revocation whose chain does not
|
|
134
|
-
* root exactly in the Space. What is refused here is a root whose target
|
|
135
|
-
* cannot be a Space URL at all (an origin, a URL with a query, a URN) and a
|
|
136
|
-
* chain that starts at no root capability. A capability this client minted
|
|
137
|
-
* from a handle is always Space-rooted. A bare `was.grant({ target })` with
|
|
138
|
-
* no `spaceUrl`, the mode for a server with no Space hierarchy, roots at
|
|
139
|
-
* its target and is not revocable this way by design.
|
|
140
|
-
*
|
|
141
|
-
* @param zcap {IZcap} the capability to locate
|
|
142
|
-
* @returns {string}
|
|
143
|
-
* @throws {ValidationError} when the chain does not start at a root
|
|
144
|
-
* capability id, or that id names something that cannot be a Space URL
|
|
145
|
-
*/
|
|
146
|
-
export function spaceUrlOf(zcap) {
|
|
147
|
-
const rootId = chainRootId(zcap);
|
|
148
|
-
const target = rootId === undefined ? null : rootCapabilityTarget(rootId);
|
|
149
|
-
if (target === null) {
|
|
150
|
-
throw new ValidationError(`Cannot derive a Space from capability "${zcap.id}": its chain does ` +
|
|
151
|
-
'not start at a root capability id (`urn:zcap:root:...`), so it is ' +
|
|
152
|
-
'not rooted in a Space.');
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
|
-
return canonicalSpaceUrl(target);
|
|
156
|
-
}
|
|
157
|
-
catch (err) {
|
|
158
|
-
throw new ValidationError(`Cannot derive a Space from capability "${zcap.id}": its root ` +
|
|
159
|
-
`capability names "${target}", which is not a Space URL.`, { cause: err });
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
31
|
/**
|
|
163
32
|
* Revokes a Space-rooted delegated capability: `POST`s it to
|
|
164
33
|
* `{spaceUrl}zcaps/revocations/:capabilityId`, invoking that URL's own root
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../src/internal/revoke.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../src/internal/revoke.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAsB,EACtB,EAAE,QAAQ,EAAE,IAAI,EAA8C;IAE9D,IAAI,CAAC,CAAC,kBAAkB,IAAI,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,eAAe,CACvB,uEAAuE,CACxE,CAAA;IACH,CAAC;IACD,MAAM,GAAG,GAAG,kBAAkB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IACnE,MAAM,IAAI,CAAC,OAAO,EAAE;QAClB,GAAG;QACH,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,cAAc,CAAC;YACzB,MAAM,EAAE,GAAG;YACX,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC,CAAC;QACF,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IRootZcap, IZcap } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The root capability id for an invocation target URL
|
|
4
|
+
* (`urn:zcap:root:<encoded target>`) -- the id grammar shared by revocation
|
|
5
|
+
* (which invokes the revocation URL's own root capability in object form) and
|
|
6
|
+
* grant rooting (which parents an unparented grant on its Space's root
|
|
7
|
+
* capability id).
|
|
8
|
+
*
|
|
9
|
+
* @param target {string} the absolute invocation target URL
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export declare function rootCapabilityId(target: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The invocation target a root capability id names: the inverse of
|
|
15
|
+
* {@link rootCapabilityId}. Returns `null` for an id that is not a root
|
|
16
|
+
* capability id, or whose encoded target is malformed.
|
|
17
|
+
*
|
|
18
|
+
* @param id {string} a capability id
|
|
19
|
+
* @returns {string | null}
|
|
20
|
+
*/
|
|
21
|
+
export declare function rootCapabilityTarget(id: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Builds the root capability for `target` in **object** form.
|
|
24
|
+
*
|
|
25
|
+
* The object form is load-bearing: `@interop/ezcap` accepts a *string* root
|
|
26
|
+
* capability id only when its invocation target is `https:`, which would break
|
|
27
|
+
* against an `http://localhost` server. Both forms reduce to the same
|
|
28
|
+
* `zcap id="..."` invocation header.
|
|
29
|
+
*
|
|
30
|
+
* `controller` is client-side only -- the server re-derives the real controller
|
|
31
|
+
* when it synthesizes the root capability -- so the caller's own DID is fine.
|
|
32
|
+
*
|
|
33
|
+
* @param options {object}
|
|
34
|
+
* @param options.target {string} the absolute invocation target URL
|
|
35
|
+
* @param options.controller {string} the invoking client's DID
|
|
36
|
+
* @returns {IRootZcap}
|
|
37
|
+
*/
|
|
38
|
+
export declare function rootCapability({ target, controller }: {
|
|
39
|
+
target: string;
|
|
40
|
+
controller: string;
|
|
41
|
+
}): IRootZcap;
|
|
42
|
+
/**
|
|
43
|
+
* The URL of the Space a capability is rooted in, read off its delegation
|
|
44
|
+
* chain: a Space-rooted capability's chain starts at the Space's root
|
|
45
|
+
* capability, whose id encodes the Space URL. The result is in canonical
|
|
46
|
+
* form.
|
|
47
|
+
*
|
|
48
|
+
* The root's target is taken to be the Space URL. A Space URL has no shape
|
|
49
|
+
* of its own (a Collection URL is an http(s) URL ending in a slash too), so
|
|
50
|
+
* this function cannot tell a chain rooted at a Space from one rooted at a
|
|
51
|
+
* Collection, a Resource, or a Spaces Repository: only the server, which
|
|
52
|
+
* knows its hierarchy, can, and it refuses a revocation whose chain does not
|
|
53
|
+
* root exactly in the Space. What is refused here is a root whose target
|
|
54
|
+
* cannot be a Space URL at all (an origin, a URL with a query, a URN) and a
|
|
55
|
+
* chain that starts at no root capability. A capability this client minted
|
|
56
|
+
* from a handle is always Space-rooted. A bare `was.grant({ target })` with
|
|
57
|
+
* no `spaceUrl`, the mode for a server with no Space hierarchy, roots at
|
|
58
|
+
* its target and is not revocable this way by design.
|
|
59
|
+
*
|
|
60
|
+
* @param zcap {IZcap} the capability to locate
|
|
61
|
+
* @returns {string}
|
|
62
|
+
* @throws {ValidationError} when the chain does not start at a root
|
|
63
|
+
* capability id, or that id names something that cannot be a Space URL
|
|
64
|
+
*/
|
|
65
|
+
export declare function spaceUrlOf(zcap: IZcap): string;
|
|
66
|
+
//# sourceMappingURL=rootCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rootCapability.d.ts","sourceRoot":"","sources":["../../src/internal/rootCapability.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAInD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS9D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,UAAU,EACX,EAAE;IACD,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,SAAS,CAOZ;AA+BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAmB9C"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The root capability id grammar and its inverse, with no transport in the
|
|
6
|
+
* graph. A root capability's id encodes its invocation target
|
|
7
|
+
* (`urn:zcap:root:<encoded target>`), so a Space-rooted chain carries the
|
|
8
|
+
* Space URL in its first entry and `spaceUrlOf` reads it back off the chain
|
|
9
|
+
* rather than assembling it from any server root. `rootCapability` builds the
|
|
10
|
+
* object form a revocation invokes, and grant rooting parents an unparented
|
|
11
|
+
* grant on the id form.
|
|
12
|
+
*
|
|
13
|
+
* This module is on the `./paths` entry's graph, so it must stay offline: no
|
|
14
|
+
* import of `request.ts` or of any module that sends. The revocation
|
|
15
|
+
* submission that uses `rootCapability` lives in `revoke.ts`.
|
|
16
|
+
*/
|
|
17
|
+
import { constants } from '@interop/zcap';
|
|
18
|
+
import { canonicalSpaceUrl } from './paths.js';
|
|
19
|
+
import { ValidationError } from '../errors.js';
|
|
20
|
+
const { ZCAP_CONTEXT_URL, ZCAP_ROOT_PREFIX } = constants;
|
|
21
|
+
/**
|
|
22
|
+
* The root capability id for an invocation target URL
|
|
23
|
+
* (`urn:zcap:root:<encoded target>`) -- the id grammar shared by revocation
|
|
24
|
+
* (which invokes the revocation URL's own root capability in object form) and
|
|
25
|
+
* grant rooting (which parents an unparented grant on its Space's root
|
|
26
|
+
* capability id).
|
|
27
|
+
*
|
|
28
|
+
* @param target {string} the absolute invocation target URL
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function rootCapabilityId(target) {
|
|
32
|
+
return `${ZCAP_ROOT_PREFIX}${encodeURIComponent(target)}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The invocation target a root capability id names: the inverse of
|
|
36
|
+
* {@link rootCapabilityId}. Returns `null` for an id that is not a root
|
|
37
|
+
* capability id, or whose encoded target is malformed.
|
|
38
|
+
*
|
|
39
|
+
* @param id {string} a capability id
|
|
40
|
+
* @returns {string | null}
|
|
41
|
+
*/
|
|
42
|
+
export function rootCapabilityTarget(id) {
|
|
43
|
+
if (!id.startsWith(ZCAP_ROOT_PREFIX)) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
return decodeURIComponent(id.slice(ZCAP_ROOT_PREFIX.length));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Builds the root capability for `target` in **object** form.
|
|
55
|
+
*
|
|
56
|
+
* The object form is load-bearing: `@interop/ezcap` accepts a *string* root
|
|
57
|
+
* capability id only when its invocation target is `https:`, which would break
|
|
58
|
+
* against an `http://localhost` server. Both forms reduce to the same
|
|
59
|
+
* `zcap id="..."` invocation header.
|
|
60
|
+
*
|
|
61
|
+
* `controller` is client-side only -- the server re-derives the real controller
|
|
62
|
+
* when it synthesizes the root capability -- so the caller's own DID is fine.
|
|
63
|
+
*
|
|
64
|
+
* @param options {object}
|
|
65
|
+
* @param options.target {string} the absolute invocation target URL
|
|
66
|
+
* @param options.controller {string} the invoking client's DID
|
|
67
|
+
* @returns {IRootZcap}
|
|
68
|
+
*/
|
|
69
|
+
export function rootCapability({ target, controller }) {
|
|
70
|
+
return {
|
|
71
|
+
'@context': ZCAP_CONTEXT_URL,
|
|
72
|
+
id: rootCapabilityId(target),
|
|
73
|
+
invocationTarget: target,
|
|
74
|
+
controller
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The id of the root capability a chain starts at: the first entry of the
|
|
79
|
+
* delegation proof's `capabilityChain`, or the `parentCapability` of a
|
|
80
|
+
* capability delegated straight from a root, or the capability's own id when
|
|
81
|
+
* it is a root. `undefined` when the capability carries no proof and no
|
|
82
|
+
* parent that names a root.
|
|
83
|
+
*
|
|
84
|
+
* The delegation proof is the one carrying `capabilityChain`, wherever it
|
|
85
|
+
* sits in a proof set: a capability may also carry an assertion proof, and
|
|
86
|
+
* nothing fixes the order.
|
|
87
|
+
*
|
|
88
|
+
* @param zcap {IZcap}
|
|
89
|
+
* @returns {string | undefined}
|
|
90
|
+
*/
|
|
91
|
+
function chainRootId(zcap) {
|
|
92
|
+
if (!('parentCapability' in zcap)) {
|
|
93
|
+
return zcap.id;
|
|
94
|
+
}
|
|
95
|
+
const proofs = Array.isArray(zcap.proof) ? zcap.proof : [zcap.proof];
|
|
96
|
+
const delegation = proofs.find(proof => proof?.capabilityChain !== undefined);
|
|
97
|
+
const first = delegation?.capabilityChain?.[0];
|
|
98
|
+
if (typeof first === 'string') {
|
|
99
|
+
return first;
|
|
100
|
+
}
|
|
101
|
+
return typeof zcap.parentCapability === 'string'
|
|
102
|
+
? zcap.parentCapability
|
|
103
|
+
: undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The URL of the Space a capability is rooted in, read off its delegation
|
|
107
|
+
* chain: a Space-rooted capability's chain starts at the Space's root
|
|
108
|
+
* capability, whose id encodes the Space URL. The result is in canonical
|
|
109
|
+
* form.
|
|
110
|
+
*
|
|
111
|
+
* The root's target is taken to be the Space URL. A Space URL has no shape
|
|
112
|
+
* of its own (a Collection URL is an http(s) URL ending in a slash too), so
|
|
113
|
+
* this function cannot tell a chain rooted at a Space from one rooted at a
|
|
114
|
+
* Collection, a Resource, or a Spaces Repository: only the server, which
|
|
115
|
+
* knows its hierarchy, can, and it refuses a revocation whose chain does not
|
|
116
|
+
* root exactly in the Space. What is refused here is a root whose target
|
|
117
|
+
* cannot be a Space URL at all (an origin, a URL with a query, a URN) and a
|
|
118
|
+
* chain that starts at no root capability. A capability this client minted
|
|
119
|
+
* from a handle is always Space-rooted. A bare `was.grant({ target })` with
|
|
120
|
+
* no `spaceUrl`, the mode for a server with no Space hierarchy, roots at
|
|
121
|
+
* its target and is not revocable this way by design.
|
|
122
|
+
*
|
|
123
|
+
* @param zcap {IZcap} the capability to locate
|
|
124
|
+
* @returns {string}
|
|
125
|
+
* @throws {ValidationError} when the chain does not start at a root
|
|
126
|
+
* capability id, or that id names something that cannot be a Space URL
|
|
127
|
+
*/
|
|
128
|
+
export function spaceUrlOf(zcap) {
|
|
129
|
+
const rootId = chainRootId(zcap);
|
|
130
|
+
const target = rootId === undefined ? null : rootCapabilityTarget(rootId);
|
|
131
|
+
if (target === null) {
|
|
132
|
+
throw new ValidationError(`Cannot derive a Space from capability "${zcap.id}": its chain does ` +
|
|
133
|
+
'not start at a root capability id (`urn:zcap:root:...`), so it is ' +
|
|
134
|
+
'not rooted in a Space.');
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
return canonicalSpaceUrl(target);
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
throw new ValidationError(`Cannot derive a Space from capability "${zcap.id}": its root ` +
|
|
141
|
+
`capability names "${target}", which is not a Space URL.`, { cause: err });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=rootCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rootCapability.js","sourceRoot":"","sources":["../../src/internal/rootCapability.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-bearing part. The codec is awaited first so a
|
|
11
|
-
* codec failure takes precedence over a read failure, and the
|
|
11
|
+
* codec failure takes precedence over a read failure, and the handler
|
|
12
12
|
* attached to the request keeps an abandoned read from surfacing as an
|
|
13
13
|
* unhandled rejection when the codec throws. The request is still awaited
|
|
14
14
|
* afterwards, so its own error is never swallowed.
|
|
15
|
+
*
|
|
16
|
+
* When the codec rejects, the read is abandoned, and its response body is
|
|
17
|
+
* cancelled as soon as the response arrives. A JSON body is already drained
|
|
18
|
+
* by the request layer, so this matters for a non-JSON body (a large blob read
|
|
19
|
+
* through `Resource.getWithEtag`, say), which would otherwise hold its
|
|
20
|
+
* connection open until garbage collection.
|
|
15
21
|
*/
|
|
16
22
|
import type { ResourceCodec } from '../codec.js';
|
|
17
23
|
/**
|
|
@@ -19,8 +25,17 @@ import type { ResourceCodec } from '../codec.js';
|
|
|
19
25
|
* both once they settle.
|
|
20
26
|
*
|
|
21
27
|
* @param codecPromise {Promise<ResourceCodec>} the codec being resolved
|
|
22
|
-
* @param responsePromise {Promise<
|
|
23
|
-
* @returns {Promise<[ResourceCodec,
|
|
28
|
+
* @param responsePromise {Promise<Read>} the request to overlap with it
|
|
29
|
+
* @returns {Promise<[ResourceCodec, Read]>}
|
|
30
|
+
*/
|
|
31
|
+
export declare function withCodec<Read extends Abandonable>(codecPromise: Promise<ResourceCodec>, responsePromise: Promise<Read>): Promise<[ResourceCodec, Read]>;
|
|
32
|
+
/**
|
|
33
|
+
* What an abandoned read must look like for its body to be released: a
|
|
34
|
+
* `fetch`-shaped response, or `null` for a masked 404.
|
|
24
35
|
*/
|
|
25
|
-
|
|
36
|
+
type Abandonable = {
|
|
37
|
+
body?: ReadableStream<Uint8Array> | null;
|
|
38
|
+
bodyUsed?: boolean;
|
|
39
|
+
} | null;
|
|
40
|
+
export {};
|
|
26
41
|
//# sourceMappingURL=withCodec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withCodec.d.ts","sourceRoot":"","sources":["../../src/internal/withCodec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"withCodec.d.ts","sourceRoot":"","sources":["../../src/internal/withCodec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,IAAI,SAAS,WAAW,EACtD,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,EACpC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,GAC7B,OAAO,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAQhC;AAED;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,IAAI,CAAA"}
|
|
@@ -3,13 +3,29 @@
|
|
|
3
3
|
* both once they settle.
|
|
4
4
|
*
|
|
5
5
|
* @param codecPromise {Promise<ResourceCodec>} the codec being resolved
|
|
6
|
-
* @param responsePromise {Promise<
|
|
7
|
-
* @returns {Promise<[ResourceCodec,
|
|
6
|
+
* @param responsePromise {Promise<Read>} the request to overlap with it
|
|
7
|
+
* @returns {Promise<[ResourceCodec, Read]>}
|
|
8
8
|
*/
|
|
9
9
|
export async function withCodec(codecPromise, responsePromise) {
|
|
10
10
|
responsePromise.catch(() => { });
|
|
11
|
+
codecPromise.catch(() => {
|
|
12
|
+
responsePromise.then(cancelBody, () => { });
|
|
13
|
+
});
|
|
11
14
|
const codec = await codecPromise;
|
|
12
15
|
const response = await responsePromise;
|
|
13
16
|
return [codec, response];
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Cancels the body stream of an abandoned response, if it has one that is
|
|
20
|
+
* still unread. A cancel that itself rejects (a stream locked by another
|
|
21
|
+
* reader) is ignored: the read is abandoned either way.
|
|
22
|
+
*
|
|
23
|
+
* @param response {Abandonable} the settled read
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
function cancelBody(response) {
|
|
27
|
+
if (response?.body && !response.bodyUsed) {
|
|
28
|
+
response.body.cancel().catch(() => { });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
15
31
|
//# sourceMappingURL=withCodec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withCodec.js","sourceRoot":"","sources":["../../src/internal/withCodec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withCodec.js","sourceRoot":"","sources":["../../src/internal/withCodec.ts"],"names":[],"mappings":"AAuBA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,YAAoC,EACpC,eAA8B;IAE9B,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC/B,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE;QACtB,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,MAAM,YAAY,CAAA;IAChC,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAA;IACtC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AAC1B,CAAC;AAWD;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,QAAqB;IACvC,IAAI,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACxC,CAAC;AACH,CAAC"}
|
package/dist/internal/write.js
CHANGED
|
@@ -259,9 +259,11 @@ async function runChunkedPlan(context, { url, write, capability, current }) {
|
|
|
259
259
|
}
|
|
260
260
|
/**
|
|
261
261
|
* The error for a fresh insert by id the server rejected with 412 after the
|
|
262
|
-
* pre-read found nothing:
|
|
263
|
-
*
|
|
264
|
-
*
|
|
262
|
+
* pre-read found nothing: either a concurrent writer created the document
|
|
263
|
+
* since, or it already existed but is not readable with this capability (a
|
|
264
|
+
* masked 404). The client cannot tell the two apart, so the message names
|
|
265
|
+
* both and leads with the remedy that fits both. The server's error is kept
|
|
266
|
+
* as the cause.
|
|
265
267
|
*
|
|
266
268
|
* @param options {object}
|
|
267
269
|
* @param options.err {PreconditionFailedError} the server's 412
|
|
@@ -270,11 +272,13 @@ async function runChunkedPlan(context, { url, write, capability, current }) {
|
|
|
270
272
|
*/
|
|
271
273
|
function maskedInsertRejected({ err, url }) {
|
|
272
274
|
const { status, type, title, details, requestUrl } = err;
|
|
273
|
-
return new PreconditionFailedError(`Cannot
|
|
274
|
-
'
|
|
275
|
-
'
|
|
276
|
-
'
|
|
277
|
-
'
|
|
278
|
-
'
|
|
275
|
+
return new PreconditionFailedError(`Cannot write the document at "${url}": the pre-read found nothing, so ` +
|
|
276
|
+
'the write was sent as a fresh insert, and the server rejected it ' +
|
|
277
|
+
'because a document now exists there. Re-read and retry. Either a ' +
|
|
278
|
+
'concurrent writer created the document after the pre-read, or it ' +
|
|
279
|
+
'already existed and its current version is not readable with this ' +
|
|
280
|
+
'capability (WAS masks unauthorized reads as 404); in that case a ' +
|
|
281
|
+
'conditional codec (e.g. the EDV codec) needs read access to update ' +
|
|
282
|
+
'it.', { status, type, title, details, requestUrl, cause: err });
|
|
279
283
|
}
|
|
280
284
|
//# sourceMappingURL=write.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAGtD,OAAO,EAAE,IAAI,EA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;AACH,CAAC"}
|
package/dist/paths.d.ts
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
* re-deriving rules that must match the server's `allowedTarget` byte for
|
|
24
24
|
* byte. Exporting the builders instead is what keeps that from happening. A
|
|
25
25
|
* container's description lives at its `meta` segment (`spaceMetaUrl`,
|
|
26
|
-
* `collectionMetaUrl`) instead of at the container URL.
|
|
26
|
+
* `collectionMetaUrl`) instead of at the container URL. `spaceReplicasUrl`
|
|
27
|
+
* and `replicaRegistrationUrl` form the replicas route and one registration
|
|
28
|
+
* beneath it, for a consumer minting a grant on that route.
|
|
27
29
|
*
|
|
28
30
|
* `parseSpaceTarget` is the inverse grammar (an absolute URL back to the
|
|
29
31
|
* containment depth it addresses beneath a Space), `spaceUrlOf` reads the
|
|
@@ -40,9 +42,9 @@
|
|
|
40
42
|
* Kept off the core entry so a consumer opts in; every export here is a pure
|
|
41
43
|
* function with no I/O and no client state.
|
|
42
44
|
*/
|
|
43
|
-
export { canonicalBaseServerUrl, serviceDescriptionUrl, spacesRepositoryUrl, spaceUrlById, baseServerUrlOf, splitCollectionUrl, canonicalSpaceUrl, spaceIdOfUrl, spaceMetaUrl, collectionUrl, collectionMetaUrl, collectionLogUrl, collectionQueryUrl, resourceUrl, resourceMetaUrl, parseSpaceTarget } from './internal/paths.js';
|
|
45
|
+
export { canonicalBaseServerUrl, serviceDescriptionUrl, spacesRepositoryUrl, spaceUrlById, baseServerUrlOf, splitCollectionUrl, canonicalSpaceUrl, spaceIdOfUrl, spaceMetaUrl, collectionUrl, collectionMetaUrl, collectionLogUrl, collectionQueryUrl, resourceUrl, resourceMetaUrl, spaceReplicasUrl, replicaRegistrationUrl, parseSpaceTarget } from './internal/paths.js';
|
|
44
46
|
export { isReservedCollectionId, isReservedResourceId } from './internal/reserved.js';
|
|
45
47
|
export type { ParsedSpacePath } from './internal/paths.js';
|
|
46
|
-
export { rootCapabilityId, rootCapabilityTarget, rootCapability, spaceUrlOf } from './internal/
|
|
48
|
+
export { rootCapabilityId, rootCapabilityTarget, rootCapability, spaceUrlOf } from './internal/rootCapability.js';
|
|
47
49
|
export type { IRootZcap } from './types.js';
|
|
48
50
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACX,MAAM,8BAA8B,CAAA;AACrC,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|