@interop/was-client 0.13.2 → 0.14.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 +33 -0
- package/dist/Collection.d.ts +27 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +41 -1
- package/dist/Collection.js.map +1 -1
- package/dist/Space.d.ts +27 -0
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +30 -0
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +14 -0
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +21 -0
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +67 -19
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +154 -35
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/internal/grant.d.ts +11 -1
- package/dist/internal/grant.d.ts.map +1 -1
- package/dist/internal/grant.js +32 -3
- package/dist/internal/grant.js.map +1 -1
- package/dist/internal/paths.d.ts +33 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +49 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/revoke.d.ts +34 -0
- package/dist/internal/revoke.d.ts.map +1 -0
- package/dist/internal/revoke.js +106 -0
- package/dist/internal/revoke.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The revocation primitive shared by `was.revoke()` and `space.revoke()` -- the
|
|
6
|
+
* inverse of `grant.ts`. Submits a delegated capability to its Space's
|
|
7
|
+
* revocation endpoint (`POST /space/:spaceId/zcaps/revocations/:capabilityId`),
|
|
8
|
+
* where the URL names the capability's `id` and the body is that capability
|
|
9
|
+
* verbatim, proof and capability chain included.
|
|
10
|
+
*
|
|
11
|
+
* The submission invokes the revocation URL's **own** root capability, whose
|
|
12
|
+
* controller the server synthesizes as every controller in the to-be-revoked
|
|
13
|
+
* capability's delegation chain. That chain is dereferenced root-first, so it
|
|
14
|
+
* includes the root capability -- whose controller is the Space controller.
|
|
15
|
+
* A single invocation therefore authorizes both legitimate callers of the
|
|
16
|
+
* server's dual-root rule ("the delegator revokes" and "a delegee revokes its
|
|
17
|
+
* own capability"), with no need to know which one this client is.
|
|
18
|
+
*/
|
|
19
|
+
import { spaceRevocation, toUrl, parseSpaceTarget } from './paths.js';
|
|
20
|
+
import { send } from './request.js';
|
|
21
|
+
import { ValidationError } from '../errors.js';
|
|
22
|
+
/**
|
|
23
|
+
* The zcap JSON-LD context URL, the sole `@context` of a root capability.
|
|
24
|
+
*/
|
|
25
|
+
const ZCAP_CONTEXT_URL = 'https://w3id.org/zcap/v1';
|
|
26
|
+
/**
|
|
27
|
+
* Builds the root capability for `target` in **object** form.
|
|
28
|
+
*
|
|
29
|
+
* The object form is load-bearing: `@interop/ezcap` accepts a *string* root
|
|
30
|
+
* capability id only when its invocation target is `https:`, which would break
|
|
31
|
+
* against an `http://localhost` server. Both forms reduce to the same
|
|
32
|
+
* `zcap id="..."` invocation header.
|
|
33
|
+
*
|
|
34
|
+
* `controller` is client-side only -- the server re-derives the real controller
|
|
35
|
+
* when it synthesizes the root capability -- so the caller's own DID is fine.
|
|
36
|
+
*
|
|
37
|
+
* @param options {object}
|
|
38
|
+
* @param options.target {string} the absolute invocation target URL
|
|
39
|
+
* @param options.controller {string} the invoking client's DID
|
|
40
|
+
* @returns {IRootZcap}
|
|
41
|
+
*/
|
|
42
|
+
function rootCapability({ target, controller }) {
|
|
43
|
+
return {
|
|
44
|
+
'@context': ZCAP_CONTEXT_URL,
|
|
45
|
+
id: `urn:zcap:root:${encodeURIComponent(target)}`,
|
|
46
|
+
invocationTarget: target,
|
|
47
|
+
controller
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Derives the id of the Space a capability is rooted in, from its
|
|
52
|
+
* `invocationTarget`. A Space-rooted capability's target is the Space URL or a
|
|
53
|
+
* path beneath it (the server enforces this when it verifies the chain), so
|
|
54
|
+
* every depth `parseSpaceTarget` recognizes -- Space, Collection, Resource, or a
|
|
55
|
+
* reserved sub-resource such as `/space/s/c/r/meta` -- carries the Space id.
|
|
56
|
+
*
|
|
57
|
+
* @param context {ClientContext}
|
|
58
|
+
* @param zcap {IZcap} the capability to locate
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function spaceIdOf(context, zcap) {
|
|
62
|
+
const parsed = parseSpaceTarget({
|
|
63
|
+
serverUrl: context.serverUrl,
|
|
64
|
+
target: zcap.invocationTarget
|
|
65
|
+
});
|
|
66
|
+
if (parsed === null) {
|
|
67
|
+
throw new ValidationError(`Cannot derive a Space from invocationTarget ` +
|
|
68
|
+
`"${zcap.invocationTarget}": it does not address a Space on ` +
|
|
69
|
+
`"${context.serverUrl}". Revocation is scoped to one Space.`);
|
|
70
|
+
}
|
|
71
|
+
return parsed.spaceId;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Revokes a Space-rooted delegated capability: `POST`s it to
|
|
75
|
+
* `/space/:spaceId/zcaps/revocations/:capabilityId`, invoking that URL's own
|
|
76
|
+
* root capability. Resolves on the server's 204.
|
|
77
|
+
*
|
|
78
|
+
* The `action` is deliberately left unset: `send()` defaults it to the HTTP
|
|
79
|
+
* method, and this route expects `POST` (WAS capabilities are scoped by HTTP
|
|
80
|
+
* method, unlike the webkms `/kms` revocation route's `write`).
|
|
81
|
+
*
|
|
82
|
+
* @param context {ClientContext}
|
|
83
|
+
* @param options {object}
|
|
84
|
+
* @param options.spaceId {string} the Space the capability is rooted in
|
|
85
|
+
* @param options.zcap {IDelegatedZcap} the capability to revoke
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
export async function submitRevocation(context, { spaceId, zcap }) {
|
|
89
|
+
if (!('parentCapability' in zcap)) {
|
|
90
|
+
throw new ValidationError('A root capability cannot be revoked; only a delegated capability can.');
|
|
91
|
+
}
|
|
92
|
+
const url = toUrl({
|
|
93
|
+
serverUrl: context.serverUrl,
|
|
94
|
+
path: spaceRevocation(spaceId, zcap.id)
|
|
95
|
+
});
|
|
96
|
+
await send(context, {
|
|
97
|
+
url,
|
|
98
|
+
method: 'POST',
|
|
99
|
+
capability: rootCapability({
|
|
100
|
+
target: url,
|
|
101
|
+
controller: context.controllerDid
|
|
102
|
+
}),
|
|
103
|
+
json: zcap
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=revoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../src/internal/revoke.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAErE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C;;GAEG;AACH,MAAM,gBAAgB,GAAG,0BAA0B,CAAA;AAEnD;;;;;;;;;;;;;;;GAeG;AACH,SAAS,cAAc,CAAC,EACtB,MAAM,EACN,UAAU,EAIX;IACC,OAAO;QACL,UAAU,EAAE,gBAAgB;QAC5B,EAAE,EAAE,iBAAiB,kBAAkB,CAAC,MAAM,CAAC,EAAE;QACjD,gBAAgB,EAAE,MAAM;QACxB,UAAU;KACX,CAAA;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,OAAsB,EAAE,IAAW;IAC3D,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,IAAI,CAAC,gBAAgB;KAC9B,CAAC,CAAA;IACF,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,eAAe,CACvB,8CAA8C;YAC5C,IAAI,IAAI,CAAC,gBAAgB,oCAAoC;YAC7D,IAAI,OAAO,CAAC,SAAS,uCAAuC,CAC/D,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAA;AACvB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAsB,EACtB,EAAE,OAAO,EAAE,IAAI,EAA6C;IAE5D,IAAI,CAAC,CAAC,kBAAkB,IAAI,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,eAAe,CACvB,uEAAuE,CACxE,CAAA;IACH,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;KACxC,CAAC,CAAA;IACF,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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
* the handle/delegation options, and the low-level `request()` input. ZCap and
|
|
13
13
|
* signer types are re-used from `@interop/data-integrity-core`.
|
|
14
14
|
*/
|
|
15
|
-
import type { IZcap, IDelegatedZcap } from '@interop/data-integrity-core/zcap';
|
|
15
|
+
import type { IZcap, IDelegatedZcap, IRootZcap } from '@interop/data-integrity-core/zcap';
|
|
16
16
|
import type { ISigner } from '@interop/data-integrity-core';
|
|
17
17
|
import type { ActionInput } from '@interop/storage-core';
|
|
18
|
-
export type { IZcap, IDelegatedZcap, ISigner };
|
|
18
|
+
export type { IZcap, IDelegatedZcap, IRootZcap, ISigner };
|
|
19
19
|
/**
|
|
20
20
|
* Re-export the shared WAS wire model from `@interop/storage-core`. The
|
|
21
21
|
* resources-in-a-collection listing is `CollectionResourcesList` (formerly
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,SAAS,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;AAEzD;;;;;GAKG;AACH,YAAY,EACV,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAC5D,MAAM,WAAW,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C,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,UAAU,CAAA;IACxB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/was-client",
|
|
3
3
|
"description": "A developer-friendly client for Wallet Attached Storage (WAS) servers.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
"types": "dist/index.d.ts",
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@interop/data-integrity-core": "^8.
|
|
45
|
+
"@interop/data-integrity-core": "^8.2.0",
|
|
46
46
|
"@interop/ed25519-signature": "^7.1.3",
|
|
47
|
-
"@interop/edv-client": "^17.
|
|
47
|
+
"@interop/edv-client": "^17.6.0",
|
|
48
48
|
"@interop/ezcap": "^7.3.2",
|
|
49
49
|
"@interop/http-client": "^1.0.4",
|
|
50
|
-
"@interop/storage-core": "^0.3.
|
|
50
|
+
"@interop/storage-core": "^0.3.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@eslint/js": "^10.0.1",
|
|
54
54
|
"@interop/ed25519-verification-key": "^8.0.2",
|
|
55
|
-
"@interop/x25519-key-agreement-key": "^5.1.
|
|
55
|
+
"@interop/x25519-key-agreement-key": "^5.1.2",
|
|
56
56
|
"@playwright/test": "^1.60.0",
|
|
57
57
|
"@types/node": "^25.9.1",
|
|
58
58
|
"@vitest/coverage-v8": "^4.1.7",
|