@interop/was-client 0.99.0 → 0.100.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 +94 -71
- package/dist/Collection.d.ts +20 -8
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +89 -69
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +14 -3
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +38 -27
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +18 -4
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +64 -61
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +105 -58
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +216 -142
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +3 -2
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +37 -26
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +7 -4
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +39 -20
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/acquire.d.ts +3 -3
- package/dist/edv/acquire.d.ts.map +1 -1
- package/dist/edv/acquire.js +3 -3
- package/dist/edv/acquire.js.map +1 -1
- package/dist/edv/cipher.d.ts +7 -4
- package/dist/edv/cipher.d.ts.map +1 -1
- package/dist/edv/cipher.js +7 -4
- package/dist/edv/cipher.js.map +1 -1
- package/dist/edv/core.d.ts +1 -1
- package/dist/edv/core.d.ts.map +1 -1
- package/dist/edv/core.js +1 -1
- package/dist/edv/core.js.map +1 -1
- package/dist/edv/docCipher.d.ts +10 -7
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +12 -8
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/encryption.d.ts +2 -2
- package/dist/edv/encryption.d.ts.map +1 -1
- package/dist/edv/encryption.js +8 -6
- package/dist/edv/encryption.js.map +1 -1
- package/dist/edv/epochCrypto.d.ts +12 -4
- package/dist/edv/epochCrypto.d.ts.map +1 -1
- package/dist/edv/epochCrypto.js +37 -10
- package/dist/edv/epochCrypto.js.map +1 -1
- package/dist/edv/epochKeys.d.ts +6 -2
- package/dist/edv/epochKeys.d.ts.map +1 -1
- package/dist/edv/epochKeys.js +25 -14
- package/dist/edv/epochKeys.js.map +1 -1
- package/dist/edv/hmacKey.d.ts +7 -1
- package/dist/edv/hmacKey.d.ts.map +1 -1
- package/dist/edv/hmacKey.js +9 -3
- package/dist/edv/hmacKey.js.map +1 -1
- package/dist/edv/index.d.ts +1 -1
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +1 -1
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +2 -0
- package/dist/edv/recipients.js.map +1 -1
- package/dist/edv/refreshingDocCipher.d.ts +3 -3
- package/dist/edv/refreshingDocCipher.d.ts.map +1 -1
- package/dist/edv/refreshingDocCipher.js +3 -3
- package/dist/edv/refreshingDocCipher.js.map +1 -1
- package/dist/edv/transportFactory.d.ts +3 -3
- package/dist/edv/transportFactory.d.ts.map +1 -1
- package/dist/edv/transportFactory.js +3 -3
- package/dist/edv/transportFactory.js.map +1 -1
- package/dist/errors.d.ts +6 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +6 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codec.d.ts +7 -7
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +19 -18
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/conditional.d.ts +3 -3
- package/dist/internal/conditional.d.ts.map +1 -1
- package/dist/internal/conditional.js +5 -5
- package/dist/internal/conditional.js.map +1 -1
- package/dist/internal/grant.d.ts +15 -26
- package/dist/internal/grant.d.ts.map +1 -1
- package/dist/internal/grant.js +95 -29
- package/dist/internal/grant.js.map +1 -1
- package/dist/internal/memo.d.ts +13 -4
- package/dist/internal/memo.d.ts.map +1 -1
- package/dist/internal/memo.js +18 -7
- package/dist/internal/memo.js.map +1 -1
- package/dist/internal/meta.d.ts +8 -8
- package/dist/internal/meta.d.ts.map +1 -1
- package/dist/internal/meta.js +13 -10
- package/dist/internal/meta.js.map +1 -1
- package/dist/internal/pagination.d.ts +30 -15
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +31 -17
- package/dist/internal/pagination.js.map +1 -1
- package/dist/internal/paths.d.ts +332 -195
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +400 -367
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/policy.d.ts +23 -23
- package/dist/internal/policy.d.ts.map +1 -1
- package/dist/internal/policy.js +20 -20
- package/dist/internal/policy.js.map +1 -1
- package/dist/internal/request.d.ts +17 -21
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +10 -21
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/revoke.d.ts +34 -13
- package/dist/internal/revoke.d.ts.map +1 -1
- package/dist/internal/revoke.js +97 -28
- package/dist/internal/revoke.js.map +1 -1
- package/dist/internal/service.d.ts +25 -7
- package/dist/internal/service.d.ts.map +1 -1
- package/dist/internal/service.js +49 -45
- package/dist/internal/service.js.map +1 -1
- package/dist/internal/write.d.ts +18 -18
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +27 -27
- package/dist/internal/write.js.map +1 -1
- package/dist/paths.d.ts +32 -25
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +32 -25
- package/dist/paths.js.map +1 -1
- package/dist/sync/index.d.ts +4 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +4 -2
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/port.d.ts +3 -3
- package/dist/sync/port.d.ts.map +1 -1
- package/dist/sync/port.js +12 -12
- package/dist/sync/port.js.map +1 -1
- package/dist/sync/provisioning.d.ts +10 -9
- package/dist/sync/provisioning.d.ts.map +1 -1
- package/dist/sync/provisioning.js +19 -18
- package/dist/sync/provisioning.js.map +1 -1
- package/dist/sync/types.d.ts +2 -2
- package/dist/types.d.ts +13 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export { Space } from './Space.js';
|
|
|
10
10
|
export { Collection } from './Collection.js';
|
|
11
11
|
export { Resource } from './Resource.js';
|
|
12
12
|
export { zcapClientForSigner } from './zcapClient.js';
|
|
13
|
-
export { discoverService } from './internal/service.js';
|
|
13
|
+
export { discoverService, readServiceDescription } from './internal/service.js';
|
|
14
14
|
export { parseSpaceTarget } from './internal/paths.js';
|
|
15
15
|
export { allowsAction } from './internal/grant.js';
|
|
16
16
|
export { readEtag, writeHeaders } from './internal/conditional.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,gDAAgD;AAChD,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,QAAQ,EACR,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,aAAa,EACb,QAAQ,EACT,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/internal/codec.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export declare class CodecHolder {
|
|
|
93
93
|
* through unchanged.
|
|
94
94
|
*/
|
|
95
95
|
interface CodecTarget {
|
|
96
|
-
|
|
96
|
+
spaceUrl: string;
|
|
97
97
|
collectionId: string;
|
|
98
98
|
override?: EncryptionOverride;
|
|
99
99
|
capability?: IZcap;
|
|
@@ -105,7 +105,7 @@ interface CodecTarget {
|
|
|
105
105
|
*
|
|
106
106
|
* @param context {ClientContext}
|
|
107
107
|
* @param options {object}
|
|
108
|
-
* @param options.
|
|
108
|
+
* @param options.spaceUrl {string}
|
|
109
109
|
* @param options.collectionId {string}
|
|
110
110
|
* @param [options.override] {EncryptionOverride} per-handle override
|
|
111
111
|
* @param [options.capability] {IZcap} the handle's bound capability
|
|
@@ -131,7 +131,7 @@ export declare const identityCodec: ResourceCodec;
|
|
|
131
131
|
*
|
|
132
132
|
* @param context {ClientContext}
|
|
133
133
|
* @param options {object}
|
|
134
|
-
* @param options.
|
|
134
|
+
* @param options.spaceUrl {string}
|
|
135
135
|
* @param options.collectionId {string}
|
|
136
136
|
* @param [options.override] {EncryptionOverride} per-handle override; wins
|
|
137
137
|
* over the descriptor and skips the descriptor read
|
|
@@ -141,7 +141,7 @@ export declare const identityCodec: ResourceCodec;
|
|
|
141
141
|
* @returns {Promise<CodecResolution>} the codec, plus the metadata snapshot
|
|
142
142
|
* the index-schema read produced when there was one
|
|
143
143
|
*/
|
|
144
|
-
export declare function resolveCodec(context: ClientContext, {
|
|
144
|
+
export declare function resolveCodec(context: ClientContext, { spaceUrl, collectionId, override, capability }: CodecTarget): Promise<CodecResolution>;
|
|
145
145
|
/**
|
|
146
146
|
* Builds the codec a descriptor names, for a write that states the descriptor
|
|
147
147
|
* itself rather than discovering it from stored state: the identity codec when
|
|
@@ -152,14 +152,14 @@ export declare function resolveCodec(context: ClientContext, { spaceId, collecti
|
|
|
152
152
|
*
|
|
153
153
|
* @param context {ClientContext}
|
|
154
154
|
* @param options {object}
|
|
155
|
-
* @param options.
|
|
155
|
+
* @param options.spaceUrl {string}
|
|
156
156
|
* @param options.collectionId {string}
|
|
157
157
|
* @param [options.descriptor] {CollectionEncryption} the descriptor the write
|
|
158
158
|
* declares; absent means plaintext
|
|
159
159
|
* @returns {Promise<ResourceCodec | null>}
|
|
160
160
|
*/
|
|
161
|
-
export declare function codecForDescriptor(context: ClientContext, {
|
|
162
|
-
|
|
161
|
+
export declare function codecForDescriptor(context: ClientContext, { spaceUrl, collectionId, descriptor }: {
|
|
162
|
+
spaceUrl: string;
|
|
163
163
|
collectionId: string;
|
|
164
164
|
descriptor?: CollectionEncryption;
|
|
165
165
|
}): Promise<ResourceCodec | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAajD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAajD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAM7D,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,EAGL,sBAAsB,EAEvB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,aAAa,CAAA;IACpB,IAAI,CAAC,EAAE,CAAC,kBAAkB,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAA;IACtD,QAAQ,CAAC,EAAE,YAAY,CAAA;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,wBAAwB,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,kBAAkB,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED;;;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AAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC7B,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CASzC"}
|
package/dist/internal/codec.js
CHANGED
|
@@ -2,6 +2,7 @@ import { decodedStream, mediaType, prepareBody, parseResource } from './content.
|
|
|
2
2
|
import { bytesToStream } from './blob.js';
|
|
3
3
|
import { asCollectionMetadata, storedEncryption, unreadableDescriptionError } from './describe.js';
|
|
4
4
|
import { readCollectionMetadata } from './meta.js';
|
|
5
|
+
import { collectionUrl } from './paths.js';
|
|
5
6
|
import { readIndexSchema } from './indexSchema.js';
|
|
6
7
|
import { Memo } from './memo.js';
|
|
7
8
|
import { EncryptionError, NotImplementedError } from '../errors.js';
|
|
@@ -78,7 +79,7 @@ export class CodecHolder {
|
|
|
78
79
|
*
|
|
79
80
|
* @param context {ClientContext}
|
|
80
81
|
* @param options {object}
|
|
81
|
-
* @param options.
|
|
82
|
+
* @param options.spaceUrl {string}
|
|
82
83
|
* @param options.collectionId {string}
|
|
83
84
|
* @param [options.override] {EncryptionOverride} per-handle override
|
|
84
85
|
* @param [options.capability] {IZcap} the handle's bound capability
|
|
@@ -144,7 +145,7 @@ export const identityCodec = {
|
|
|
144
145
|
*
|
|
145
146
|
* @param context {ClientContext}
|
|
146
147
|
* @param options {object}
|
|
147
|
-
* @param options.
|
|
148
|
+
* @param options.spaceUrl {string}
|
|
148
149
|
* @param options.collectionId {string}
|
|
149
150
|
* @param [options.override] {EncryptionOverride} per-handle override; wins
|
|
150
151
|
* over the descriptor and skips the descriptor read
|
|
@@ -154,7 +155,7 @@ export const identityCodec = {
|
|
|
154
155
|
* @returns {Promise<CodecResolution>} the codec, plus the metadata snapshot
|
|
155
156
|
* the index-schema read produced when there was one
|
|
156
157
|
*/
|
|
157
|
-
export async function resolveCodec(context, {
|
|
158
|
+
export async function resolveCodec(context, { spaceUrl, collectionId, override, capability }) {
|
|
158
159
|
// 1. A per-handle override wins and skips the descriptor read.
|
|
159
160
|
if (override !== undefined) {
|
|
160
161
|
if (override === 'plaintext') {
|
|
@@ -166,7 +167,7 @@ export async function resolveCodec(context, { spaceId, collectionId, override, c
|
|
|
166
167
|
// fail-closed, so dropping the descriptor here would break every read and
|
|
167
168
|
// write.
|
|
168
169
|
const { codec } = await buildEncryptingCodec(context, {
|
|
169
|
-
|
|
170
|
+
spaceUrl,
|
|
170
171
|
collectionId,
|
|
171
172
|
scheme: override.scheme,
|
|
172
173
|
keys: override.keys,
|
|
@@ -175,7 +176,7 @@ export async function resolveCodec(context, { spaceId, collectionId, override, c
|
|
|
175
176
|
// The override skipped the Collection Metadata read, so a searchable
|
|
176
177
|
// collection's persisted index schema is fetched here.
|
|
177
178
|
const snapshot = await loadIndexSchema(context, {
|
|
178
|
-
|
|
179
|
+
spaceUrl,
|
|
179
180
|
collectionId,
|
|
180
181
|
capability,
|
|
181
182
|
codec
|
|
@@ -197,13 +198,13 @@ export async function resolveCodec(context, { spaceId, collectionId, override, c
|
|
|
197
198
|
// downgrading to plaintext and writing the caller's secret as server-visible
|
|
198
199
|
// plaintext into a possibly-encrypted collection.
|
|
199
200
|
const read = await readCollectionMetadata(context, {
|
|
200
|
-
|
|
201
|
+
spaceUrl,
|
|
201
202
|
collectionId,
|
|
202
203
|
capability
|
|
203
204
|
});
|
|
204
205
|
if (read === null) {
|
|
205
206
|
throw unreadableDescriptionError({
|
|
206
|
-
operation: `determine whether collection ${
|
|
207
|
+
operation: `determine whether collection ${collectionUrl({ spaceUrl, collectionId })} is ` +
|
|
207
208
|
'encrypted',
|
|
208
209
|
consequence: 'an encryption-capable client refuses to fall back to plaintext',
|
|
209
210
|
advice: 'Pass an explicit per-handle encryption override -- ' +
|
|
@@ -215,7 +216,7 @@ export async function resolveCodec(context, { spaceId, collectionId, override, c
|
|
|
215
216
|
const declared = storedEncryption(read.metadata);
|
|
216
217
|
const { codec } = declared
|
|
217
218
|
? await buildEncryptingCodec(context, {
|
|
218
|
-
|
|
219
|
+
spaceUrl,
|
|
219
220
|
collectionId,
|
|
220
221
|
scheme: declared.scheme,
|
|
221
222
|
encryption: declared
|
|
@@ -241,13 +242,13 @@ export async function resolveCodec(context, { spaceId, collectionId, override, c
|
|
|
241
242
|
*
|
|
242
243
|
* @param context {ClientContext}
|
|
243
244
|
* @param options {object}
|
|
244
|
-
* @param options.
|
|
245
|
+
* @param options.spaceUrl {string}
|
|
245
246
|
* @param options.collectionId {string}
|
|
246
247
|
* @param [options.descriptor] {CollectionEncryption} the descriptor the write
|
|
247
248
|
* declares; absent means plaintext
|
|
248
249
|
* @returns {Promise<ResourceCodec | null>}
|
|
249
250
|
*/
|
|
250
|
-
export async function codecForDescriptor(context, {
|
|
251
|
+
export async function codecForDescriptor(context, { spaceUrl, collectionId, descriptor }) {
|
|
251
252
|
if (descriptor === undefined) {
|
|
252
253
|
return identityCodec;
|
|
253
254
|
}
|
|
@@ -255,7 +256,7 @@ export async function codecForDescriptor(context, { spaceId, collectionId, descr
|
|
|
255
256
|
return null;
|
|
256
257
|
}
|
|
257
258
|
const codec = await context.encryption.codecFor({
|
|
258
|
-
|
|
259
|
+
spaceUrl,
|
|
259
260
|
collectionId,
|
|
260
261
|
scheme: descriptor.scheme,
|
|
261
262
|
encryption: descriptor
|
|
@@ -330,7 +331,7 @@ export async function openStoredCustom({ codec, stored }) {
|
|
|
330
331
|
*
|
|
331
332
|
* @param context {ClientContext}
|
|
332
333
|
* @param options {object}
|
|
333
|
-
* @param options.
|
|
334
|
+
* @param options.spaceUrl {string}
|
|
334
335
|
* @param options.collectionId {string}
|
|
335
336
|
* @param options.scheme {string}
|
|
336
337
|
* @param [options.encryption] {CollectionEncryption} the descriptor, passed
|
|
@@ -338,15 +339,15 @@ export async function openStoredCustom({ codec, stored }) {
|
|
|
338
339
|
* @param [options.keys] {unknown} override-supplied key material
|
|
339
340
|
* @returns {Promise<CodecResolution>}
|
|
340
341
|
*/
|
|
341
|
-
async function buildEncryptingCodec(context, {
|
|
342
|
-
const where =
|
|
342
|
+
async function buildEncryptingCodec(context, { spaceUrl, collectionId, scheme, encryption, keys }) {
|
|
343
|
+
const where = collectionUrl({ spaceUrl, collectionId });
|
|
343
344
|
if (!context.encryption) {
|
|
344
345
|
throw new EncryptionError(`Collection ${where} is encrypted (scheme "${scheme}") but this client ` +
|
|
345
346
|
'has no encryption provider. Construct the WasClient with an ' +
|
|
346
347
|
'`encryption` provider (see @interop/was-client/edv).');
|
|
347
348
|
}
|
|
348
349
|
const codec = await context.encryption.codecFor({
|
|
349
|
-
|
|
350
|
+
spaceUrl,
|
|
350
351
|
collectionId,
|
|
351
352
|
scheme,
|
|
352
353
|
encryption,
|
|
@@ -384,7 +385,7 @@ async function buildEncryptingCodec(context, { spaceId, collectionId, scheme, en
|
|
|
384
385
|
*
|
|
385
386
|
* @param context {ClientContext}
|
|
386
387
|
* @param options {object}
|
|
387
|
-
* @param options.
|
|
388
|
+
* @param options.spaceUrl {string}
|
|
388
389
|
* @param options.collectionId {string}
|
|
389
390
|
* @param [options.capability] {IZcap}
|
|
390
391
|
* @param options.codec {ResourceCodec} the codec to install the schema on
|
|
@@ -392,14 +393,14 @@ async function buildEncryptingCodec(context, { spaceId, collectionId, scheme, en
|
|
|
392
393
|
* the read behind it, `null` when there is none to read, and `undefined`
|
|
393
394
|
* when no read happened at all
|
|
394
395
|
*/
|
|
395
|
-
async function loadIndexSchema(context, {
|
|
396
|
+
async function loadIndexSchema(context, { spaceUrl, collectionId, capability, codec }) {
|
|
396
397
|
if (!codec.indexing) {
|
|
397
398
|
return undefined;
|
|
398
399
|
}
|
|
399
400
|
let read;
|
|
400
401
|
try {
|
|
401
402
|
read = await readCollectionMetadata(context, {
|
|
402
|
-
|
|
403
|
+
spaceUrl,
|
|
403
404
|
collectionId,
|
|
404
405
|
capability
|
|
405
406
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,aAAa,E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QAAQ,EACR,YAAY,EACZ,UAAU,EACV,KAAK,EAMN;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,IAAI,CAAA;IACR,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,sBAAsB,CAAC,OAAO,EAAE;YAC3C,QAAQ;YACR,YAAY;YACZ,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,mBAAmB,EAAE,CAAC;YACvC,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;IACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -154,13 +154,13 @@ export declare function readEtag(response: ResponseLike | null): string | undefi
|
|
|
154
154
|
* the server.
|
|
155
155
|
*
|
|
156
156
|
* @param options {object}
|
|
157
|
-
* @param options.
|
|
157
|
+
* @param options.url {string} the resource URL written
|
|
158
158
|
* @param options.current {ResponseLike | null} the pre-read document
|
|
159
159
|
* @param [options.precondition] {WritePrecondition} the caller's precondition
|
|
160
160
|
* @returns {void}
|
|
161
161
|
*/
|
|
162
|
-
export declare function assertPreconditionAgainstPreRead({
|
|
163
|
-
|
|
162
|
+
export declare function assertPreconditionAgainstPreRead({ url, current, precondition }: {
|
|
163
|
+
url: string;
|
|
164
164
|
current: ResponseLike | null;
|
|
165
165
|
precondition?: WritePrecondition;
|
|
166
166
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,YA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G,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAqBrC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACV,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,iBAAiB,CASpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gCAAgC,CAAC,EAC/C,GAAG,EACH,OAAO,EACP,YAAY,EACb,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC,GAAG,IAAI,CAkCP"}
|
|
@@ -173,17 +173,17 @@ export function readEtag(response) {
|
|
|
173
173
|
* the server.
|
|
174
174
|
*
|
|
175
175
|
* @param options {object}
|
|
176
|
-
* @param options.
|
|
176
|
+
* @param options.url {string} the resource URL written
|
|
177
177
|
* @param options.current {ResponseLike | null} the pre-read document
|
|
178
178
|
* @param [options.precondition] {WritePrecondition} the caller's precondition
|
|
179
179
|
* @returns {void}
|
|
180
180
|
*/
|
|
181
|
-
export function assertPreconditionAgainstPreRead({
|
|
181
|
+
export function assertPreconditionAgainstPreRead({ url, current, precondition }) {
|
|
182
182
|
if (precondition === undefined) {
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
if (precondition.ifNoneMatch && current !== null) {
|
|
186
|
-
throw new PreconditionFailedError(`Cannot create the document at "${
|
|
186
|
+
throw new PreconditionFailedError(`Cannot create the document at "${url}": create-if-absent was ` +
|
|
187
187
|
'requested (ifNoneMatch), but a document is already stored there. ' +
|
|
188
188
|
'Re-read it and write an update instead.', { status: 412 });
|
|
189
189
|
}
|
|
@@ -191,14 +191,14 @@ export function assertPreconditionAgainstPreRead({ path, current, precondition }
|
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
if (current === null) {
|
|
194
|
-
throw new PreconditionFailedError(`Cannot update the document at "${
|
|
194
|
+
throw new PreconditionFailedError(`Cannot update the document at "${url}": an ifMatch validator was ` +
|
|
195
195
|
'supplied, but no current document is readable there -- it was ' +
|
|
196
196
|
'deleted, or it is not readable with this capability (WAS masks ' +
|
|
197
197
|
'unauthorized reads as 404). Re-read the resource before retrying.', { status: 412 });
|
|
198
198
|
}
|
|
199
199
|
const etag = readEtag(current);
|
|
200
200
|
if (etag !== undefined && etag !== precondition.ifMatch) {
|
|
201
|
-
throw new PreconditionFailedError(`Cannot update the document at "${
|
|
201
|
+
throw new PreconditionFailedError(`Cannot update the document at "${url}": its current version ` +
|
|
202
202
|
`(${etag}) is not the one the write was pinned to ` +
|
|
203
203
|
`(${precondition.ifMatch}) -- another writer changed it. Re-read the ` +
|
|
204
204
|
'resource, rebase the change, and retry.', { status: 412 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EAChB,MAAM,cAAc,CAAA;AAErB;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAa3C;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAqB;IACvD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAA;AACvE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAC/B,YAAgC;IAEhC,OAAO,YAAY,KAAK,SAAS;QAC/B,CAAC,YAAY,CAAC,OAAO,KAAK,SAAS,IAAI,Y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AAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,uBAAuB,CAC/B,kCAAkC,GAAG,8BAA8B;YACjE,gEAAgE;YAChE,iEAAiE;YACjE,mEAAmE,EACrE,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAA;IACH,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC9B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,YAAY,CAAC,OAAO,EAAE,CAAC;QACxD,MAAM,IAAI,uBAAuB,CAC/B,kCAAkC,GAAG,yBAAyB;YAC5D,IAAI,IAAI,2CAA2C;YACnD,IAAI,YAAY,CAAC,OAAO,8CAA8C;YACtE,yCAAyC,EAC3C,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/internal/grant.d.ts
CHANGED
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The delegation primitive shared by `was.grant()` and the `space`/`collection`
|
|
6
|
-
* grant sugar. Maps `GrantOptions` onto `zcapClient.delegate(...)`, normalizing
|
|
7
|
-
* action verbs to uppercase so a lowercase grant (`'get'`) still validates on
|
|
8
|
-
* the server (which matches actions case-sensitively against `'GET'`).
|
|
9
|
-
*
|
|
10
|
-
* An unparented grant whose target lies in the server's Space tree is delegated
|
|
11
|
-
* from that **Space's** root capability, with the target carried as an
|
|
12
|
-
* attenuated `invocationTarget`, rather than from the target's own root
|
|
13
|
-
* capability. Both forms grant the same access (the server verifies WAS routes
|
|
14
|
-
* with target attenuation allowed), but only a Space-rooted chain can be revoked
|
|
15
|
-
* -- revocation is Space-scoped, and the endpoint requires the chain to root
|
|
16
|
-
* exactly in the Space (see `revoke.ts`).
|
|
17
|
-
*/
|
|
18
1
|
import type { ClientContext } from './request.js';
|
|
19
2
|
import type { GrantOptions, IDelegatedZcap, IZcap } from '../types.js';
|
|
20
3
|
/**
|
|
21
4
|
* Delegates a capability per `GrantOptions`, returning the signed zcap to hand
|
|
22
5
|
* off out-of-band. An explicit `capability` (re-delegation of a parent zcap)
|
|
23
|
-
* always wins; otherwise a
|
|
24
|
-
* resulting capability is revocable via `space.revoke()` /
|
|
6
|
+
* always wins; otherwise a grant naming its `spaceUrl` is rooted at that
|
|
7
|
+
* Space, so the resulting capability is revocable via `space.revoke()` /
|
|
8
|
+
* `was.revoke()`; otherwise ezcap roots it at the target's own root
|
|
9
|
+
* capability.
|
|
25
10
|
*
|
|
26
11
|
* @param context {ClientContext}
|
|
27
12
|
* @param options {GrantOptions}
|
|
28
13
|
* @returns {Promise<IDelegatedZcap>}
|
|
29
14
|
* @throws {ValidationError} when neither `target` nor `capability` is given,
|
|
30
|
-
* so the delegation names nothing to grant
|
|
15
|
+
* so the delegation names nothing to grant; or when `spaceUrl` is given
|
|
16
|
+
* and `target` does not lie at or beneath it
|
|
31
17
|
*/
|
|
32
|
-
export declare function delegateGrant(context: ClientContext, { to, actions, expires, target, capability }: GrantOptions): Promise<IDelegatedZcap>;
|
|
18
|
+
export declare function delegateGrant(context: ClientContext, { to, actions, expires, target, capability, spaceUrl }: GrantOptions): Promise<IDelegatedZcap>;
|
|
33
19
|
/**
|
|
34
20
|
* Whether a capability permits `action`, matched case-insensitively against
|
|
35
21
|
* its `allowedAction` (a single verb or a list). A capability that states no
|
|
@@ -49,18 +35,21 @@ export declare function allowsAction({ zcap, action }: {
|
|
|
49
35
|
/**
|
|
50
36
|
* The scoped-grant sugar shared by `Space.grant` and `Collection.grant`:
|
|
51
37
|
* delegates per `GrantOptions` with the grant `target` prefilled from the
|
|
52
|
-
* handle's `
|
|
53
|
-
*
|
|
38
|
+
* handle's `url`, the rooting `spaceUrl` from the handle's Space, and the
|
|
39
|
+
* handle's bound `capability`, if any, as the parent for re-delegation.
|
|
40
|
+
* Explicit options win over every prefill.
|
|
54
41
|
*
|
|
55
42
|
* @param context {ClientContext}
|
|
56
43
|
* @param options {object}
|
|
57
|
-
* @param options.
|
|
44
|
+
* @param options.url {string} the handle's URL (target fallback)
|
|
45
|
+
* @param options.spaceUrl {string} the handle's Space (rooting fallback)
|
|
58
46
|
* @param options.options {GrantOptions} the caller's grant options
|
|
59
47
|
* @param [options.capability] {IZcap} the handle's bound capability
|
|
60
48
|
* @returns {Promise<IDelegatedZcap>}
|
|
61
49
|
*/
|
|
62
|
-
export declare function delegateGrantAt(context: ClientContext, {
|
|
63
|
-
|
|
50
|
+
export declare function delegateGrantAt(context: ClientContext, { url, spaceUrl, options, capability }: {
|
|
51
|
+
url: string;
|
|
52
|
+
spaceUrl: string;
|
|
64
53
|
options: GrantOptions;
|
|
65
54
|
capability?: IZcap;
|
|
66
55
|
}): Promise<IDelegatedZcap>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAyEtE;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,YAAY,GACnE,OAAO,CAAC,cAAc,CAAC,CAsBzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,MAAM,EACP,EAAE;IACD,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAWV;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,EACtB,EACE,GAAG,EACH,QAAQ,EACR,OAAO,EACP,UAAU,EACX,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,YAAY,CAAA;IACrB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GACA,OAAO,CAAC,cAAc,CAAC,CAOzB"}
|
package/dist/internal/grant.js
CHANGED
|
@@ -1,42 +1,106 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The delegation primitive shared by `was.grant()` and the `space`/`collection`
|
|
6
|
+
* grant sugar. Maps `GrantOptions` onto `zcapClient.delegate(...)`, normalizing
|
|
7
|
+
* action verbs to uppercase so a lowercase grant (`'get'`) still validates on
|
|
8
|
+
* the server (which matches actions case-sensitively against `'GET'`).
|
|
9
|
+
*
|
|
10
|
+
* An unparented grant that names its Space (`spaceUrl`, which the scoped sugar
|
|
11
|
+
* fills from the handle) is delegated from that **Space's** root capability,
|
|
12
|
+
* with the target carried as an attenuated `invocationTarget`, rather than
|
|
13
|
+
* from the target's own root capability. Both forms grant the same access (the
|
|
14
|
+
* server verifies WAS routes with target attenuation allowed), but only a
|
|
15
|
+
* Space-rooted chain can be revoked -- revocation is Space-scoped, and the
|
|
16
|
+
* endpoint requires the chain to root exactly in the Space (see `revoke.ts`).
|
|
17
|
+
*
|
|
18
|
+
* A bare `was.grant({ target })` without `spaceUrl` is the other mode, kept
|
|
19
|
+
* on purpose: it delegates from the target's own root capability (ezcap's
|
|
20
|
+
* default). It is the shape for a server at the basic conformance level,
|
|
21
|
+
* which may serve fixed collections, or resources alone, with no Space
|
|
22
|
+
* container to root a chain in. Such a grant cannot be revoked through a
|
|
23
|
+
* Space's revocation endpoint; that is a limitation of that conformance
|
|
24
|
+
* level, not of the client.
|
|
25
|
+
*/
|
|
26
|
+
import { isValidTarget } from '@interop/zcap';
|
|
27
|
+
import { canonicalSpaceUrl } from './paths.js';
|
|
2
28
|
import { rootCapabilityId } from './revoke.js';
|
|
3
29
|
import { ValidationError } from '../errors.js';
|
|
4
30
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
31
|
+
* Roots a grant in its Space: the root capability id
|
|
32
|
+
* (`urn:zcap:root:<encoded Space URL>`) to parent it on, after checking that
|
|
33
|
+
* `target` lies at or beneath the Space, and the target to delegate. A chain
|
|
34
|
+
* rooted in one Space cannot delegate a target outside it, and the server
|
|
35
|
+
* would refuse the capability at invocation, so the mismatch is refused here
|
|
36
|
+
* by name.
|
|
37
|
+
*
|
|
38
|
+
* The Space itself may be named in either form. The bare (slash-less) form
|
|
39
|
+
* is accepted as the target, as `parseSpaceTarget` accepts it, and is
|
|
40
|
+
* delegated in canonical form: the server verifies a Space-rooted chain
|
|
41
|
+
* against the canonical Space URL, under which the bare form is not an
|
|
42
|
+
* attenuation of the Space but a sibling of it.
|
|
9
43
|
*
|
|
10
44
|
* The id is returned as a string, which `zcapClient.delegate(...)` accepts for a
|
|
11
45
|
* root parent capability. (Its sibling `request(...)` does not, for a non-`https:`
|
|
12
46
|
* target -- hence the object form in `revoke.ts`.)
|
|
13
47
|
*
|
|
14
48
|
* @param options {object}
|
|
15
|
-
* @param options.
|
|
16
|
-
* @param options.target {string}
|
|
17
|
-
* @returns {string
|
|
49
|
+
* @param options.spaceUrl {string} the Space to root the grant in
|
|
50
|
+
* @param options.target {string} the absolute grant target URL
|
|
51
|
+
* @returns {{ parent: string, target: string }}
|
|
52
|
+
* @throws {ValidationError} when `target` is not at or beneath `spaceUrl`,
|
|
53
|
+
* or its path is rewritten by URL normalization (a dot segment)
|
|
18
54
|
*/
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
55
|
+
function spaceRooted({ spaceUrl, target }) {
|
|
56
|
+
const canonical = canonicalSpaceUrl(spaceUrl);
|
|
57
|
+
// The check runs against the canonical Space URL, the base the server
|
|
58
|
+
// verifies the chain against, so what passes here is what the server
|
|
59
|
+
// accepts. The bare form is the one exception, matched exactly: as a base
|
|
60
|
+
// it would also admit `{space}?x`, which the server refuses.
|
|
61
|
+
const bare = canonical.slice(0, -1);
|
|
62
|
+
if (target !== bare &&
|
|
63
|
+
!isValidTarget({
|
|
64
|
+
invocationTarget: target,
|
|
65
|
+
baseInvocationTarget: canonical,
|
|
66
|
+
allowTargetAttenuation: true
|
|
67
|
+
})) {
|
|
68
|
+
throw new ValidationError(`Grant target "${target}" is not at or beneath the Space ` +
|
|
69
|
+
`"${canonical}" the grant would be rooted in.`);
|
|
70
|
+
}
|
|
71
|
+
// The prefix check reads the raw string, so a dot segment (`{space}../x`)
|
|
72
|
+
// passes it while naming a path outside the Space once a URL parser
|
|
73
|
+
// normalizes it. The server resolves the request URL that way, so such a
|
|
74
|
+
// target can never be invoked. Refuse a target whose path does not survive
|
|
75
|
+
// normalization unchanged. The query, if any, is left as given.
|
|
76
|
+
const origin = new URL(canonical).origin;
|
|
77
|
+
const rawPath = target.slice(origin.length).replace(/[?#].*$/, '');
|
|
78
|
+
if (target !== bare && new URL(target).pathname !== rawPath) {
|
|
79
|
+
throw new ValidationError(`Grant target "${target}" has a path that URL normalization rewrites ` +
|
|
80
|
+
'(a dot segment or an unencoded character); give the target in its ' +
|
|
81
|
+
'normalized form.');
|
|
23
82
|
}
|
|
24
|
-
|
|
25
|
-
|
|
83
|
+
return {
|
|
84
|
+
parent: rootCapabilityId(canonical),
|
|
85
|
+
target: target === bare ? canonical : target
|
|
86
|
+
};
|
|
26
87
|
}
|
|
27
88
|
/**
|
|
28
89
|
* Delegates a capability per `GrantOptions`, returning the signed zcap to hand
|
|
29
90
|
* off out-of-band. An explicit `capability` (re-delegation of a parent zcap)
|
|
30
|
-
* always wins; otherwise a
|
|
31
|
-
* resulting capability is revocable via `space.revoke()` /
|
|
91
|
+
* always wins; otherwise a grant naming its `spaceUrl` is rooted at that
|
|
92
|
+
* Space, so the resulting capability is revocable via `space.revoke()` /
|
|
93
|
+
* `was.revoke()`; otherwise ezcap roots it at the target's own root
|
|
94
|
+
* capability.
|
|
32
95
|
*
|
|
33
96
|
* @param context {ClientContext}
|
|
34
97
|
* @param options {GrantOptions}
|
|
35
98
|
* @returns {Promise<IDelegatedZcap>}
|
|
36
99
|
* @throws {ValidationError} when neither `target` nor `capability` is given,
|
|
37
|
-
* so the delegation names nothing to grant
|
|
100
|
+
* so the delegation names nothing to grant; or when `spaceUrl` is given
|
|
101
|
+
* and `target` does not lie at or beneath it
|
|
38
102
|
*/
|
|
39
|
-
export async function delegateGrant(context, { to, actions, expires, target, capability }) {
|
|
103
|
+
export async function delegateGrant(context, { to, actions, expires, target, capability, spaceUrl }) {
|
|
40
104
|
// The scoped sugar always prefills `target`, so this only catches a direct
|
|
41
105
|
// `was.grant()`. Without either member ezcap has no invocation target and no
|
|
42
106
|
// parent to take one from, and rejects the call with a bare `TypeError` a
|
|
@@ -45,16 +109,15 @@ export async function delegateGrant(context, { to, actions, expires, target, cap
|
|
|
45
109
|
throw new ValidationError('A grant needs a `target` (the invocationTarget URL to grant) or a ' +
|
|
46
110
|
'`capability` (the parent capability to attenuate); neither was given.');
|
|
47
111
|
}
|
|
48
|
-
const
|
|
49
|
-
(target
|
|
50
|
-
|
|
51
|
-
: spaceRootCapabilityId({ baseUrl: context.baseUrl, target }));
|
|
112
|
+
const rooted = capability === undefined && target !== undefined && spaceUrl !== undefined
|
|
113
|
+
? spaceRooted({ spaceUrl, target })
|
|
114
|
+
: { parent: capability, target };
|
|
52
115
|
return context.zcapClient.delegate({
|
|
53
116
|
controller: to,
|
|
54
|
-
invocationTarget: target,
|
|
117
|
+
invocationTarget: rooted.target,
|
|
55
118
|
allowedActions: actions.map(action => action.toUpperCase()),
|
|
56
119
|
expires,
|
|
57
|
-
capability: parent
|
|
120
|
+
capability: rooted.parent
|
|
58
121
|
});
|
|
59
122
|
}
|
|
60
123
|
/**
|
|
@@ -84,20 +147,23 @@ export function allowsAction({ zcap, action }) {
|
|
|
84
147
|
/**
|
|
85
148
|
* The scoped-grant sugar shared by `Space.grant` and `Collection.grant`:
|
|
86
149
|
* delegates per `GrantOptions` with the grant `target` prefilled from the
|
|
87
|
-
* handle's `
|
|
88
|
-
*
|
|
150
|
+
* handle's `url`, the rooting `spaceUrl` from the handle's Space, and the
|
|
151
|
+
* handle's bound `capability`, if any, as the parent for re-delegation.
|
|
152
|
+
* Explicit options win over every prefill.
|
|
89
153
|
*
|
|
90
154
|
* @param context {ClientContext}
|
|
91
155
|
* @param options {object}
|
|
92
|
-
* @param options.
|
|
156
|
+
* @param options.url {string} the handle's URL (target fallback)
|
|
157
|
+
* @param options.spaceUrl {string} the handle's Space (rooting fallback)
|
|
93
158
|
* @param options.options {GrantOptions} the caller's grant options
|
|
94
159
|
* @param [options.capability] {IZcap} the handle's bound capability
|
|
95
160
|
* @returns {Promise<IDelegatedZcap>}
|
|
96
161
|
*/
|
|
97
|
-
export async function delegateGrantAt(context, {
|
|
162
|
+
export async function delegateGrantAt(context, { url, spaceUrl, options, capability }) {
|
|
98
163
|
return delegateGrant(context, {
|
|
99
164
|
...options,
|
|
100
|
-
target: options.target ??
|
|
165
|
+
target: options.target ?? url,
|
|
166
|
+
spaceUrl: options.spaceUrl ?? spaceUrl,
|
|
101
167
|
capability: options.capability ?? capability
|
|
102
168
|
});
|
|
103
169
|
}
|