@interop/wallet-core 0.70.0 → 0.72.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 +19 -11
- package/dist/clientAnnex/forget.d.ts.map +1 -1
- package/dist/clientAnnex/forget.js +4 -3
- package/dist/clientAnnex/forget.js.map +1 -1
- package/dist/clientAnnex/forgetLast.d.ts +55 -35
- package/dist/clientAnnex/forgetLast.d.ts.map +1 -1
- package/dist/clientAnnex/forgetLast.js +87 -35
- package/dist/clientAnnex/forgetLast.js.map +1 -1
- package/dist/clientAnnex/gc.d.ts +48 -19
- package/dist/clientAnnex/gc.d.ts.map +1 -1
- package/dist/clientAnnex/gc.js +82 -31
- package/dist/clientAnnex/gc.js.map +1 -1
- package/dist/clientAnnex/grantRevocation.d.ts +137 -0
- package/dist/clientAnnex/grantRevocation.d.ts.map +1 -0
- package/dist/clientAnnex/grantRevocation.js +135 -0
- package/dist/clientAnnex/grantRevocation.js.map +1 -0
- package/dist/clientAnnex/index.d.ts +4 -2
- package/dist/clientAnnex/index.d.ts.map +1 -1
- package/dist/clientAnnex/index.js +2 -1
- package/dist/clientAnnex/index.js.map +1 -1
- package/dist/clientAnnex/ladderAnchored.d.ts +0 -22
- package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -1
- package/dist/clientAnnex/ladderAnchored.js +8 -34
- package/dist/clientAnnex/ladderAnchored.js.map +1 -1
- package/dist/clientAnnex/log.d.ts +65 -13
- package/dist/clientAnnex/log.d.ts.map +1 -1
- package/dist/clientAnnex/log.js +160 -67
- package/dist/clientAnnex/log.js.map +1 -1
- package/dist/clientAnnex/mend.js +51 -24
- package/dist/clientAnnex/mend.js.map +1 -1
- package/dist/clientAnnex/selfEnroll.js +1 -1
- package/dist/clientAnnex/selfEnroll.js.map +1 -1
- package/dist/clientAnnex/zcap.js +1 -1
- package/dist/clientAnnex/zcap.js.map +1 -1
- package/dist/clients/grantState.d.ts +6 -3
- package/dist/clients/grantState.d.ts.map +1 -1
- package/dist/clients/grantState.js +6 -3
- package/dist/clients/grantState.js.map +1 -1
- package/dist/clients/policy.d.ts.map +1 -1
- package/dist/clients/policy.js +3 -0
- package/dist/clients/policy.js.map +1 -1
- package/dist/enrollment/enrollment.js +1 -1
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/keyring/fetch.d.ts +6 -2
- package/dist/keyring/fetch.d.ts.map +1 -1
- package/dist/keyring/fetch.js +7 -3
- package/dist/keyring/fetch.js.map +1 -1
- package/dist/keyring/index.d.ts +8 -6
- package/dist/keyring/index.d.ts.map +1 -1
- package/dist/keyring/index.js +8 -6
- package/dist/keyring/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +2 -2
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +2 -2
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keyring/unlockSpace.d.ts +45 -68
- package/dist/keyring/unlockSpace.d.ts.map +1 -1
- package/dist/keyring/unlockSpace.js +66 -88
- package/dist/keyring/unlockSpace.js.map +1 -1
- package/dist/keys/userKey.js +1 -1
- package/dist/keys/userKey.js.map +1 -1
- package/dist/menders/derive.d.ts +85 -0
- package/dist/menders/derive.d.ts.map +1 -0
- package/dist/menders/derive.js +138 -0
- package/dist/menders/derive.js.map +1 -0
- package/dist/menders/ids.d.ts +20 -0
- package/dist/menders/ids.d.ts.map +1 -0
- package/dist/menders/ids.js +85 -0
- package/dist/menders/ids.js.map +1 -0
- package/dist/menders/index.d.ts +42 -0
- package/dist/menders/index.d.ts.map +1 -0
- package/dist/menders/index.js +37 -0
- package/dist/menders/index.js.map +1 -0
- package/dist/menders/registry.d.ts +84 -0
- package/dist/menders/registry.d.ts.map +1 -0
- package/dist/menders/registry.js +62 -0
- package/dist/menders/registry.js.map +1 -0
- package/dist/menders/runner.d.ts +143 -0
- package/dist/menders/runner.d.ts.map +1 -0
- package/dist/menders/runner.js +222 -0
- package/dist/menders/runner.js.map +1 -0
- package/dist/menders/types.d.ts +146 -0
- package/dist/menders/types.d.ts.map +1 -0
- package/dist/menders/types.js +2 -0
- package/dist/menders/types.js.map +1 -0
- package/dist/menders/vocabulary.d.ts +88 -0
- package/dist/menders/vocabulary.d.ts.map +1 -0
- package/dist/menders/vocabulary.js +83 -0
- package/dist/menders/vocabulary.js.map +1 -0
- package/dist/recovery/index.d.ts +1 -1
- package/dist/recovery/index.js +1 -1
- package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
- package/dist/recovery/recoveryWebvh.js +11 -17
- package/dist/recovery/recoveryWebvh.js.map +1 -1
- package/dist/resourceLog/document.d.ts.map +1 -1
- package/dist/resourceLog/document.js +30 -6
- package/dist/resourceLog/document.js.map +1 -1
- package/dist/space/activity.d.ts +70 -0
- package/dist/space/activity.d.ts.map +1 -1
- package/dist/space/activity.js +82 -0
- package/dist/space/activity.js.map +1 -1
- package/dist/space/deleteSpace.d.ts.map +1 -1
- package/dist/space/deleteSpace.js +6 -5
- package/dist/space/deleteSpace.js.map +1 -1
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/index.js.map +1 -1
- package/dist/testing.d.ts +78 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +89 -0
- package/dist/testing.js.map +1 -0
- package/dist/unlock/index.d.ts +2 -2
- package/dist/unlock/index.d.ts.map +1 -1
- package/dist/unlock/index.js +1 -1
- package/dist/unlock/retire.d.ts +20 -5
- package/dist/unlock/retire.d.ts.map +1 -1
- package/dist/unlock/retire.js.map +1 -1
- package/dist/unlock/standingClient.d.ts +1 -1
- package/dist/unlock/standingClient.d.ts.map +1 -1
- package/dist/unlock/standingClient.js +3 -3
- package/dist/unlock/standingClient.js.map +1 -1
- package/dist/unlock/standingWebvh.d.ts +22 -2
- package/dist/unlock/standingWebvh.d.ts.map +1 -1
- package/dist/unlock/standingWebvh.js +22 -2
- package/dist/unlock/standingWebvh.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +33 -0
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +50 -11
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/enrollClient.d.ts.map +1 -1
- package/dist/webvh/enrollClient.js +4 -16
- package/dist/webvh/enrollClient.js.map +1 -1
- package/dist/webvh/index.d.ts +14 -4
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +14 -4
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/listClients.d.ts +47 -0
- package/dist/webvh/listClients.d.ts.map +1 -1
- package/dist/webvh/listClients.js +40 -1
- package/dist/webvh/listClients.js.map +1 -1
- package/dist/webvh/standingZcap.d.ts +66 -0
- package/dist/webvh/standingZcap.d.ts.map +1 -1
- package/dist/webvh/standingZcap.js +96 -0
- package/dist/webvh/standingZcap.js.map +1 -1
- package/dist/webvh/zcap.d.ts +1 -1
- package/dist/webvh/zcap.js +1 -1
- package/dist/webvh/zcap.js.map +1 -1
- package/package.json +18 -12
- package/dist/identity/agents.d.ts +0 -100
- package/dist/identity/agents.d.ts.map +0 -1
- package/dist/identity/agents.js +0 -120
- package/dist/identity/agents.js.map +0 -1
- package/dist/identity/index.d.ts +0 -24
- package/dist/identity/index.d.ts.map +0 -1
- package/dist/identity/index.js +0 -23
- package/dist/identity/index.js.map +0 -1
- package/dist/identity/keyResolver.d.ts +0 -30
- package/dist/identity/keyResolver.d.ts.map +0 -1
- package/dist/identity/keyResolver.js +0 -25
- package/dist/identity/keyResolver.js.map +0 -1
|
@@ -32,109 +32,86 @@ export declare function ensureUnlockSpace({ storageServerUrl, zcapClient, spaceI
|
|
|
32
32
|
* does not exist yet. A network / unreachable error propagates, so callers can
|
|
33
33
|
* distinguish "no keyring" from "could not check".
|
|
34
34
|
*
|
|
35
|
+
* With a `capability`, the `zcapClient` is an enrolled client's rather than
|
|
36
|
+
* the unlock identity's, and the attached management zcap (delegated by the
|
|
37
|
+
* unlock identity at bind time; it must allow GET) authorizes the read. This
|
|
38
|
+
* is what lets the revocation cascade's re-mint read a recovery code's
|
|
39
|
+
* standing record without holding the code: the record's code-authenticated
|
|
40
|
+
* binding rides the frame in the clear, so carrying it forward verbatim needs
|
|
41
|
+
* no decryption.
|
|
42
|
+
*
|
|
35
43
|
* @param options {object}
|
|
36
44
|
* @param options.storageServerUrl {string}
|
|
37
45
|
* @param options.zcapClient {ZcapClient}
|
|
38
46
|
* @param options.spaceId {string} the unlock Space id
|
|
47
|
+
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
48
|
+
* absent, the read is a root invocation
|
|
39
49
|
* @returns {Promise<unknown | null>}
|
|
40
50
|
*/
|
|
41
|
-
export declare function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId }: {
|
|
51
|
+
export declare function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId, capability }: {
|
|
42
52
|
storageServerUrl: string;
|
|
43
53
|
zcapClient: ZcapClient;
|
|
44
54
|
spaceId: string;
|
|
55
|
+
capability?: IZcap;
|
|
45
56
|
}): Promise<unknown | null>;
|
|
46
57
|
/**
|
|
47
58
|
* Writes (upserts) the keyring record into the unlock Space as a JSON document.
|
|
48
59
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*/
|
|
56
|
-
export declare function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId, record }: {
|
|
57
|
-
storageServerUrl: string;
|
|
58
|
-
zcapClient: ZcapClient;
|
|
59
|
-
spaceId: string;
|
|
60
|
-
record: object;
|
|
61
|
-
}): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Reads the keyring record with an explicitly attached management capability,
|
|
64
|
-
* rather than by root invocation, or returns `null` when it does not exist.
|
|
65
|
-
* The `zcapClient` here is an enrolled client's (not the unlock identity's);
|
|
66
|
-
* the attached `capability` -- the management zcap the unlock identity
|
|
67
|
-
* delegated at bind time, provided it allows GET -- authorizes the read
|
|
68
|
-
* against the unlock Space. This is what lets the revocation cascade's
|
|
69
|
-
* re-mint read a recovery code's standing record without holding the code:
|
|
70
|
-
* the record's code-authenticated binding rides the frame in the clear, so
|
|
71
|
-
* carrying it forward verbatim needs no decryption.
|
|
72
|
-
*
|
|
73
|
-
* @param options {object}
|
|
74
|
-
* @param options.storageServerUrl {string}
|
|
75
|
-
* @param options.zcapClient {ZcapClient} an enrolled client's zcap client
|
|
76
|
-
* @param options.spaceId {string} the unlock Space id
|
|
77
|
-
* @param options.capability {IZcap} the delegated management zcap (must
|
|
78
|
-
* allow GET)
|
|
79
|
-
* @returns {Promise<unknown | null>}
|
|
80
|
-
*/
|
|
81
|
-
export declare function getUnlockKeyringWithCapability({ storageServerUrl, zcapClient, spaceId, capability }: {
|
|
82
|
-
storageServerUrl: string;
|
|
83
|
-
zcapClient: ZcapClient;
|
|
84
|
-
spaceId: string;
|
|
85
|
-
capability: IZcap;
|
|
86
|
-
}): Promise<unknown | null>;
|
|
87
|
-
/**
|
|
88
|
-
* Writes (upserts) the keyring record with an explicitly attached management
|
|
89
|
-
* capability, rather than by root invocation. The `zcapClient` here is an
|
|
90
|
-
* enrolled client's (not the unlock identity's); the attached `capability` --
|
|
91
|
-
* the management zcap the unlock identity delegated at bind time, provided it
|
|
92
|
-
* allows PUT -- authorizes the write against the unlock Space. This is what
|
|
93
|
-
* lets the revocation cascade re-PUT a recovery code's unlock record (a fresh
|
|
94
|
-
* `did.jsonl` delegation inside a re-wrapped record) without holding the
|
|
95
|
-
* code: the record's JWE recipient is the code's unlock KAK, whose PUBLIC
|
|
60
|
+
* With a `capability`, the `zcapClient` is an enrolled client's rather than
|
|
61
|
+
* the unlock identity's, and the attached management zcap (delegated by the
|
|
62
|
+
* unlock identity at bind time; it must allow PUT) authorizes the write. This
|
|
63
|
+
* is what lets the revocation cascade re-PUT a recovery code's unlock record
|
|
64
|
+
* (a fresh `did.jsonl` delegation inside a re-wrapped record) without holding
|
|
65
|
+
* the code: the record's JWE recipient is the code's unlock KAK, whose PUBLIC
|
|
96
66
|
* half the issuing client recorded, so re-encryption needs no secret.
|
|
97
67
|
*
|
|
98
68
|
* @param options {object}
|
|
99
69
|
* @param options.storageServerUrl {string}
|
|
100
|
-
* @param options.zcapClient {ZcapClient}
|
|
70
|
+
* @param options.zcapClient {ZcapClient}
|
|
101
71
|
* @param options.spaceId {string} the unlock Space id
|
|
102
72
|
* @param options.record {object} the keyring record
|
|
103
|
-
* @param options.capability {IZcap} the delegated management zcap
|
|
104
|
-
*
|
|
73
|
+
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
74
|
+
* absent, the write is a root invocation
|
|
105
75
|
* @returns {Promise<void>}
|
|
106
76
|
*/
|
|
107
|
-
export declare function
|
|
77
|
+
export declare function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId, record, capability }: {
|
|
108
78
|
storageServerUrl: string;
|
|
109
79
|
zcapClient: ZcapClient;
|
|
110
80
|
spaceId: string;
|
|
111
81
|
record: object;
|
|
112
|
-
capability
|
|
82
|
+
capability?: IZcap;
|
|
113
83
|
}): Promise<void>;
|
|
114
84
|
/**
|
|
115
85
|
* Deletes the whole unlock Space (what retires an old passphrase on a
|
|
116
|
-
* passphrase change).
|
|
117
|
-
* Space
|
|
86
|
+
* passphrase change, or a lost unlock method). The server's answer is
|
|
87
|
+
* reported rather than decided here: an already-absent Space comes back as
|
|
88
|
+
* `not-found`, and only a non-404 error propagates, so a caller that treats
|
|
89
|
+
* the delete as idempotent ignores the outcome.
|
|
90
|
+
*
|
|
91
|
+
* With a `capability`, the `zcapClient` is an enrolled client's rather than
|
|
92
|
+
* the unlock identity's, and the attached management zcap (delegated by the
|
|
93
|
+
* unlock identity to the data identity at bind time; it must allow DELETE on
|
|
94
|
+
* the Space's own URL) authorizes the delete -- retiring a lost unlock method
|
|
95
|
+
* without re-deriving its identity from the (possibly lost) secret. The
|
|
96
|
+
* server answers 404 both for an absent Space and for a refused capability,
|
|
97
|
+
* so `not-found` is not a statement of absence on its own.
|
|
118
98
|
*
|
|
119
99
|
* @param options {object}
|
|
120
100
|
* @param options.storageServerUrl {string}
|
|
121
101
|
* @param options.zcapClient {ZcapClient}
|
|
122
102
|
* @param options.spaceId {string} the unlock Space id
|
|
123
|
-
* @
|
|
103
|
+
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
104
|
+
* absent, the delete is a root invocation
|
|
105
|
+
* @returns {Promise<{ outcome: 'deleted' | 'not-found' }>} `not-found`
|
|
106
|
+
* when the server answered 404 (absent, or unauthorized under a
|
|
107
|
+
* capability); every other error propagates unchanged
|
|
124
108
|
*/
|
|
125
|
-
export declare function deleteUnlockSpace({ storageServerUrl, zcapClient, spaceId }: {
|
|
109
|
+
export declare function deleteUnlockSpace({ storageServerUrl, zcapClient, spaceId, capability }: {
|
|
126
110
|
storageServerUrl: string;
|
|
127
111
|
zcapClient: ZcapClient;
|
|
128
112
|
spaceId: string;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* Space's deletion is the one this module's callers reach for -- retiring a
|
|
134
|
-
* lost unlock method with the management zcap the unlock identity delegated
|
|
135
|
-
* to the data identity at bind time, rather than by re-deriving the unlock
|
|
136
|
-
* identity from the (possibly lost) secret -- while the request itself is
|
|
137
|
-
* the shared one, 404 outcome and all.
|
|
138
|
-
*/
|
|
139
|
-
export { deleteSpaceWithCapability as deleteUnlockSpaceWithCapability } from '../space/deleteSpace.js';
|
|
113
|
+
capability?: IZcap;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
outcome: 'deleted' | 'not-found';
|
|
116
|
+
}>;
|
|
140
117
|
//# sourceMappingURL=unlockSpace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"
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;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,UAAU,EACX,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,CAAC,CAGhD"}
|
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
* and separate from the wallet data Space, holding the one keyring record.
|
|
7
7
|
* These are standalone functions rather than methods on a wallet's remote-store
|
|
8
8
|
* class (that store is bound to the data identity): each builds its own
|
|
9
|
-
* `WasClient` over the
|
|
10
|
-
* the unlock root key (root invocation,
|
|
11
|
-
* invocation shape the data Space uses).
|
|
9
|
+
* `WasClient` over the caller's `zcapClient`. By default that is the unlock
|
|
10
|
+
* agent's, whose invocation signer is the unlock root key (root invocation,
|
|
11
|
+
* no capability attached -- the same invocation shape the data Space uses).
|
|
12
|
+
* Each read/write/delete also takes an optional `capability`: an enrolled
|
|
13
|
+
* client's `zcapClient` then invokes the management zcap the unlock identity
|
|
14
|
+
* delegated at bind time, which is how a ceremony reaches an unlock Space
|
|
15
|
+
* without holding its secret (the revocation cascade's re-mint reading and
|
|
16
|
+
* re-PUTting a recovery code's standing record, or a lost unlock method's
|
|
17
|
+
* Space being retired).
|
|
12
18
|
*
|
|
13
19
|
* The one resource is a plaintext JSON document (its keyring payload is
|
|
14
20
|
* already ciphertext), so no encryption provider is wired in and every
|
|
@@ -16,7 +22,6 @@
|
|
|
16
22
|
* here for the absent Space a fresh unlock secret's keyring lookup meets.
|
|
17
23
|
*/
|
|
18
24
|
import { WasClient } from '@interop/was-client';
|
|
19
|
-
import { resourcePath } from '@interop/was-client/paths';
|
|
20
25
|
import { KEYRING_COLLECTION, KEYRING_RESOURCE } from '../space/collections.js';
|
|
21
26
|
import { plaintextCollection } from '../space/plaintextCollection.js';
|
|
22
27
|
/**
|
|
@@ -74,11 +79,18 @@ async function ensurePlaintextCollection({ storageServerUrl, zcapClient, spaceId
|
|
|
74
79
|
* @param options.spaceId {string}
|
|
75
80
|
* @param options.collectionId {string}
|
|
76
81
|
* @param options.resourceId {string}
|
|
82
|
+
* @param [options.capability] {IZcap} an invocation capability the GET
|
|
83
|
+
* rides; absent, the request invokes the root capability
|
|
77
84
|
* @returns {Promise<unknown | null>}
|
|
78
85
|
*/
|
|
79
|
-
async function getPlaintextRecord({ storageServerUrl, zcapClient, spaceId, collectionId, resourceId }) {
|
|
86
|
+
async function getPlaintextRecord({ storageServerUrl, zcapClient, spaceId, collectionId, resourceId, capability }) {
|
|
80
87
|
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
81
|
-
const result = await plaintextCollection({
|
|
88
|
+
const result = await plaintextCollection({
|
|
89
|
+
was,
|
|
90
|
+
spaceId,
|
|
91
|
+
collectionId,
|
|
92
|
+
capability
|
|
93
|
+
})
|
|
82
94
|
.resource(resourceId)
|
|
83
95
|
.get();
|
|
84
96
|
return result === null ? null : result;
|
|
@@ -94,12 +106,14 @@ async function getPlaintextRecord({ storageServerUrl, zcapClient, spaceId, colle
|
|
|
94
106
|
* @param options.collectionId {string}
|
|
95
107
|
* @param options.resourceId {string}
|
|
96
108
|
* @param options.record {object}
|
|
109
|
+
* @param [options.capability] {IZcap} an invocation capability the PUT
|
|
110
|
+
* rides; absent, the request invokes the root capability
|
|
97
111
|
* @returns {Promise<void>}
|
|
98
112
|
*/
|
|
99
|
-
async function putPlaintextRecord({ storageServerUrl, zcapClient, spaceId, collectionId, resourceId, record }) {
|
|
113
|
+
async function putPlaintextRecord({ storageServerUrl, zcapClient, spaceId, collectionId, resourceId, record, capability }) {
|
|
100
114
|
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
101
115
|
const body = new TextEncoder().encode(JSON.stringify(record));
|
|
102
|
-
await plaintextCollection({ was, spaceId, collectionId })
|
|
116
|
+
await plaintextCollection({ was, spaceId, collectionId, capability })
|
|
103
117
|
.resource(resourceId)
|
|
104
118
|
.put(body, { contentType: 'application/json' });
|
|
105
119
|
}
|
|
@@ -133,126 +147,90 @@ export async function ensureUnlockSpace({ storageServerUrl, zcapClient, spaceId,
|
|
|
133
147
|
* does not exist yet. A network / unreachable error propagates, so callers can
|
|
134
148
|
* distinguish "no keyring" from "could not check".
|
|
135
149
|
*
|
|
150
|
+
* With a `capability`, the `zcapClient` is an enrolled client's rather than
|
|
151
|
+
* the unlock identity's, and the attached management zcap (delegated by the
|
|
152
|
+
* unlock identity at bind time; it must allow GET) authorizes the read. This
|
|
153
|
+
* is what lets the revocation cascade's re-mint read a recovery code's
|
|
154
|
+
* standing record without holding the code: the record's code-authenticated
|
|
155
|
+
* binding rides the frame in the clear, so carrying it forward verbatim needs
|
|
156
|
+
* no decryption.
|
|
157
|
+
*
|
|
136
158
|
* @param options {object}
|
|
137
159
|
* @param options.storageServerUrl {string}
|
|
138
160
|
* @param options.zcapClient {ZcapClient}
|
|
139
161
|
* @param options.spaceId {string} the unlock Space id
|
|
162
|
+
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
163
|
+
* absent, the read is a root invocation
|
|
140
164
|
* @returns {Promise<unknown | null>}
|
|
141
165
|
*/
|
|
142
|
-
export async function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId }) {
|
|
166
|
+
export async function getUnlockKeyring({ storageServerUrl, zcapClient, spaceId, capability }) {
|
|
143
167
|
return getPlaintextRecord({
|
|
144
168
|
storageServerUrl,
|
|
145
169
|
zcapClient,
|
|
146
170
|
spaceId,
|
|
147
171
|
collectionId: KEYRING_COLLECTION.id,
|
|
148
|
-
resourceId: KEYRING_RESOURCE
|
|
172
|
+
resourceId: KEYRING_RESOURCE,
|
|
173
|
+
capability
|
|
149
174
|
});
|
|
150
175
|
}
|
|
151
176
|
/**
|
|
152
177
|
* Writes (upserts) the keyring record into the unlock Space as a JSON document.
|
|
153
178
|
*
|
|
179
|
+
* With a `capability`, the `zcapClient` is an enrolled client's rather than
|
|
180
|
+
* the unlock identity's, and the attached management zcap (delegated by the
|
|
181
|
+
* unlock identity at bind time; it must allow PUT) authorizes the write. This
|
|
182
|
+
* is what lets the revocation cascade re-PUT a recovery code's unlock record
|
|
183
|
+
* (a fresh `did.jsonl` delegation inside a re-wrapped record) without holding
|
|
184
|
+
* the code: the record's JWE recipient is the code's unlock KAK, whose PUBLIC
|
|
185
|
+
* half the issuing client recorded, so re-encryption needs no secret.
|
|
186
|
+
*
|
|
154
187
|
* @param options {object}
|
|
155
188
|
* @param options.storageServerUrl {string}
|
|
156
189
|
* @param options.zcapClient {ZcapClient}
|
|
157
190
|
* @param options.spaceId {string} the unlock Space id
|
|
158
191
|
* @param options.record {object} the keyring record
|
|
192
|
+
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
193
|
+
* absent, the write is a root invocation
|
|
159
194
|
* @returns {Promise<void>}
|
|
160
195
|
*/
|
|
161
|
-
export async function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId, record }) {
|
|
196
|
+
export async function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId, record, capability }) {
|
|
162
197
|
await putPlaintextRecord({
|
|
163
198
|
storageServerUrl,
|
|
164
199
|
zcapClient,
|
|
165
200
|
spaceId,
|
|
166
201
|
collectionId: KEYRING_COLLECTION.id,
|
|
167
202
|
resourceId: KEYRING_RESOURCE,
|
|
168
|
-
record
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Reads the keyring record with an explicitly attached management capability,
|
|
173
|
-
* rather than by root invocation, or returns `null` when it does not exist.
|
|
174
|
-
* The `zcapClient` here is an enrolled client's (not the unlock identity's);
|
|
175
|
-
* the attached `capability` -- the management zcap the unlock identity
|
|
176
|
-
* delegated at bind time, provided it allows GET -- authorizes the read
|
|
177
|
-
* against the unlock Space. This is what lets the revocation cascade's
|
|
178
|
-
* re-mint read a recovery code's standing record without holding the code:
|
|
179
|
-
* the record's code-authenticated binding rides the frame in the clear, so
|
|
180
|
-
* carrying it forward verbatim needs no decryption.
|
|
181
|
-
*
|
|
182
|
-
* @param options {object}
|
|
183
|
-
* @param options.storageServerUrl {string}
|
|
184
|
-
* @param options.zcapClient {ZcapClient} an enrolled client's zcap client
|
|
185
|
-
* @param options.spaceId {string} the unlock Space id
|
|
186
|
-
* @param options.capability {IZcap} the delegated management zcap (must
|
|
187
|
-
* allow GET)
|
|
188
|
-
* @returns {Promise<unknown | null>}
|
|
189
|
-
*/
|
|
190
|
-
export async function getUnlockKeyringWithCapability({ storageServerUrl, zcapClient, spaceId, capability }) {
|
|
191
|
-
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
192
|
-
const result = await plaintextCollection({
|
|
193
|
-
was,
|
|
194
|
-
spaceId,
|
|
195
|
-
collectionId: KEYRING_COLLECTION.id,
|
|
203
|
+
record,
|
|
196
204
|
capability
|
|
197
|
-
})
|
|
198
|
-
.resource(KEYRING_RESOURCE)
|
|
199
|
-
.get();
|
|
200
|
-
return result === null ? null : result;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Writes (upserts) the keyring record with an explicitly attached management
|
|
204
|
-
* capability, rather than by root invocation. The `zcapClient` here is an
|
|
205
|
-
* enrolled client's (not the unlock identity's); the attached `capability` --
|
|
206
|
-
* the management zcap the unlock identity delegated at bind time, provided it
|
|
207
|
-
* allows PUT -- authorizes the write against the unlock Space. This is what
|
|
208
|
-
* lets the revocation cascade re-PUT a recovery code's unlock record (a fresh
|
|
209
|
-
* `did.jsonl` delegation inside a re-wrapped record) without holding the
|
|
210
|
-
* code: the record's JWE recipient is the code's unlock KAK, whose PUBLIC
|
|
211
|
-
* half the issuing client recorded, so re-encryption needs no secret.
|
|
212
|
-
*
|
|
213
|
-
* @param options {object}
|
|
214
|
-
* @param options.storageServerUrl {string}
|
|
215
|
-
* @param options.zcapClient {ZcapClient} an enrolled client's zcap client
|
|
216
|
-
* @param options.spaceId {string} the unlock Space id
|
|
217
|
-
* @param options.record {object} the keyring record
|
|
218
|
-
* @param options.capability {IZcap} the delegated management zcap (must
|
|
219
|
-
* allow PUT)
|
|
220
|
-
* @returns {Promise<void>}
|
|
221
|
-
*/
|
|
222
|
-
export async function putUnlockKeyringWithCapability({ storageServerUrl, zcapClient, spaceId, record, capability }) {
|
|
223
|
-
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
224
|
-
const body = new TextEncoder().encode(JSON.stringify(record));
|
|
225
|
-
await was.request({
|
|
226
|
-
capability,
|
|
227
|
-
path: resourcePath(spaceId, KEYRING_COLLECTION.id, KEYRING_RESOURCE),
|
|
228
|
-
method: 'PUT',
|
|
229
|
-
headers: { 'content-type': 'application/json' },
|
|
230
|
-
body
|
|
231
205
|
});
|
|
232
206
|
}
|
|
233
207
|
/**
|
|
234
208
|
* Deletes the whole unlock Space (what retires an old passphrase on a
|
|
235
|
-
* passphrase change).
|
|
236
|
-
* Space
|
|
209
|
+
* passphrase change, or a lost unlock method). The server's answer is
|
|
210
|
+
* reported rather than decided here: an already-absent Space comes back as
|
|
211
|
+
* `not-found`, and only a non-404 error propagates, so a caller that treats
|
|
212
|
+
* the delete as idempotent ignores the outcome.
|
|
213
|
+
*
|
|
214
|
+
* With a `capability`, the `zcapClient` is an enrolled client's rather than
|
|
215
|
+
* the unlock identity's, and the attached management zcap (delegated by the
|
|
216
|
+
* unlock identity to the data identity at bind time; it must allow DELETE on
|
|
217
|
+
* the Space's own URL) authorizes the delete -- retiring a lost unlock method
|
|
218
|
+
* without re-deriving its identity from the (possibly lost) secret. The
|
|
219
|
+
* server answers 404 both for an absent Space and for a refused capability,
|
|
220
|
+
* so `not-found` is not a statement of absence on its own.
|
|
237
221
|
*
|
|
238
222
|
* @param options {object}
|
|
239
223
|
* @param options.storageServerUrl {string}
|
|
240
224
|
* @param options.zcapClient {ZcapClient}
|
|
241
225
|
* @param options.spaceId {string} the unlock Space id
|
|
242
|
-
* @
|
|
226
|
+
* @param [options.capability] {IZcap} the delegated management zcap;
|
|
227
|
+
* absent, the delete is a root invocation
|
|
228
|
+
* @returns {Promise<{ outcome: 'deleted' | 'not-found' }>} `not-found`
|
|
229
|
+
* when the server answered 404 (absent, or unauthorized under a
|
|
230
|
+
* capability); every other error propagates unchanged
|
|
243
231
|
*/
|
|
244
|
-
export async function deleteUnlockSpace({ storageServerUrl, zcapClient, spaceId }) {
|
|
232
|
+
export async function deleteUnlockSpace({ storageServerUrl, zcapClient, spaceId, capability }) {
|
|
245
233
|
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
246
|
-
|
|
234
|
+
return was.space(spaceId, { capability }).deleteWithOutcome();
|
|
247
235
|
}
|
|
248
|
-
/**
|
|
249
|
-
* The unlock Space's name for the one capability-authorized Space DELETE
|
|
250
|
-
* ({@link deleteSpaceWithCapability}). The alias stands because an unlock
|
|
251
|
-
* Space's deletion is the one this module's callers reach for -- retiring a
|
|
252
|
-
* lost unlock method with the management zcap the unlock identity delegated
|
|
253
|
-
* to the data identity at bind time, rather than by re-deriving the unlock
|
|
254
|
-
* identity from the (possibly lost) secret -- while the request itself is
|
|
255
|
-
* the shared one, 404 outcome and all.
|
|
256
|
-
*/
|
|
257
|
-
export { deleteSpaceWithCapability as deleteUnlockSpaceWithCapability } from '../space/deleteSpace.js';
|
|
258
236
|
//# sourceMappingURL=unlockSpace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.js","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"unlockSpace.js","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAG/C,OAAO,EAAE,kBAAkB,EAAE,g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U,EAAE,gBAAgB;QAC5B,UAAU;KACX,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,MAAM,EACN,UAAU,EAOX;IACC,MAAM,kBAAkB,CAAC;QACvB,gBAAgB;QAChB,UAAU;QACV,OAAO;QACP,YAAY,EAAE,kBAAkB,CAAC,EAAE;QACnC,UAAU,EAAE,gBAAgB;QAC5B,MAAM;QACN,UAAU;KACX,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,UAAU,EAMX;IACC,MAAM,GAAG,GAAG,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC,CAAA;IAC/D,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAA;AAC/D,CAAC"}
|
package/dist/keys/userKey.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { X25519KeyAgreementKey2020 } from '@interop/x25519-key-agreement-key';
|
|
21
21
|
import { epochKeyIdFor, mintEpoch } from '@interop/was-client/edv';
|
|
22
|
-
import { singleKeyResolver } from '
|
|
22
|
+
import { singleKeyResolver } from '@interop/was-client/identity';
|
|
23
23
|
/**
|
|
24
24
|
* Mints a fresh user key: the X25519 key-agreement pair via the was-client
|
|
25
25
|
* epoch construction (its did:key is the key id, its raw secret is what wraps),
|
package/dist/keys/userKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userKey.js","sourceRoot":"","sources":["../../src/keys/userKey.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GA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* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The derived sets a wallet's audit tests assert: the invariants a transient
|
|
6
|
+
* visit reaches, the gaps the registration index implies, and census
|
|
7
|
+
* completeness. Each is computed from the table and the sites alone, so a
|
|
8
|
+
* converger that quietly loses a trigger a transient visit fires, or an
|
|
9
|
+
* invariant no registration reports any more, moves a derived set and fails
|
|
10
|
+
* the wallet's pin.
|
|
11
|
+
*/
|
|
12
|
+
import { type InvariantId } from './ids.js';
|
|
13
|
+
import type { MenderRegistry } from './registry.js';
|
|
14
|
+
import type { InvariantGap, RegistrationSite } from './types.js';
|
|
15
|
+
/**
|
|
16
|
+
* One derived gap: the declared row's key and kind, without its prose.
|
|
17
|
+
*/
|
|
18
|
+
type DerivedGap = Pick<InvariantGap, 'invariant' | 'kind'>;
|
|
19
|
+
/**
|
|
20
|
+
* The invariants a transient visit on a standing credential reaches. The
|
|
21
|
+
* two chain triggers are read through `dueAt` over the ladder held set; a
|
|
22
|
+
* `login-routing` site counts unless the client-key-record probe guards it;
|
|
23
|
+
* a `ceremony-tail` entry counts, every such ceremony running on any
|
|
24
|
+
* session type; and a detector no site reports (a declaration carrying
|
|
25
|
+
* `holdsWhen`) counts when it is checked at a trigger a transient visit
|
|
26
|
+
* fires and, on the chain, under an authority the ladder held set carries.
|
|
27
|
+
* An unreported declaration with no detector is reached by nothing.
|
|
28
|
+
*
|
|
29
|
+
* @param options {object}
|
|
30
|
+
* @param options.registry {MenderRegistry}
|
|
31
|
+
* @returns {ReadonlyArray<InvariantId>} in table order
|
|
32
|
+
*/
|
|
33
|
+
export declare function transientReachableInvariants({ registry }: {
|
|
34
|
+
registry: MenderRegistry<RegistrationSite, never>;
|
|
35
|
+
}): ReadonlyArray<InvariantId>;
|
|
36
|
+
/**
|
|
37
|
+
* The gaps the index implies. An invariant no site reports derives `none`,
|
|
38
|
+
* unless it is checked at ceremony tails alone (converged by the ceremony's
|
|
39
|
+
* own sequenced code, which is never registered). A detector is not a
|
|
40
|
+
* mender: a declaration carrying `holdsWhen` and no registration derives
|
|
41
|
+
* `none` like any other unreported one, so adding a detector never retires
|
|
42
|
+
* a gap. A declaration naming a chain or routing trigger no site backs
|
|
43
|
+
* derives `none` whatever else it names. An invariant reported only at sites
|
|
44
|
+
* a transient visit cannot reach, on an account shape the violation can
|
|
45
|
+
* stand on, derives `unreachable`. Nothing else derives a gap.
|
|
46
|
+
*
|
|
47
|
+
* @param options {object}
|
|
48
|
+
* @param options.registry {MenderRegistry}
|
|
49
|
+
* @returns {ReadonlyArray<DerivedGap>}
|
|
50
|
+
*/
|
|
51
|
+
export declare function deriveGaps({ registry }: {
|
|
52
|
+
registry: MenderRegistry<RegistrationSite, never>;
|
|
53
|
+
}): ReadonlyArray<DerivedGap>;
|
|
54
|
+
/**
|
|
55
|
+
* Compares the derived gaps with a wallet's declared allowlist. The
|
|
56
|
+
* derivation admits gaps and retires none: a declared row the derivation no
|
|
57
|
+
* longer produces passes, and a derived gap with no declaration fails. A
|
|
58
|
+
* derived `none` needs a declared `none` row for its invariant; a derived
|
|
59
|
+
* `unreachable` needs any declared row for it, since a declared `none` may
|
|
60
|
+
* be scoped to a different torn state of the same predicate.
|
|
61
|
+
*
|
|
62
|
+
* @param options {object}
|
|
63
|
+
* @param options.derived {ReadonlyArray<DerivedGap>}
|
|
64
|
+
* @param options.declared {ReadonlyArray<InvariantGap>}
|
|
65
|
+
* @returns {ReadonlyArray<DerivedGap>} the
|
|
66
|
+
* derived gaps no declaration covers; empty when the allowlist is complete
|
|
67
|
+
*/
|
|
68
|
+
export declare function undeclaredGaps({ derived, declared }: {
|
|
69
|
+
derived: ReadonlyArray<DerivedGap>;
|
|
70
|
+
declared: ReadonlyArray<InvariantGap>;
|
|
71
|
+
}): ReadonlyArray<DerivedGap>;
|
|
72
|
+
/**
|
|
73
|
+
* Census completeness: the ids in {@link INVARIANT_IDS} the table does not
|
|
74
|
+
* declare. Duplicated ids and undeclared reports are refused by
|
|
75
|
+
* `menderRegistry` at construction, so a registry in hand has neither.
|
|
76
|
+
*
|
|
77
|
+
* @param options {object}
|
|
78
|
+
* @param options.registry {MenderRegistry}
|
|
79
|
+
* @returns {ReadonlyArray<InvariantId>} empty when the census is complete
|
|
80
|
+
*/
|
|
81
|
+
export declare function undeclaredInvariants({ registry }: {
|
|
82
|
+
registry: MenderRegistry<RegistrationSite, never>;
|
|
83
|
+
}): ReadonlyArray<InvariantId>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/menders/derive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEhE;;GAEG;AACH,KAAK,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,MAAM,CAAC,CAAA;AAW1D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,cAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;CAClD,GAAG,aAAa,CAAC,WAAW,CAAC,CAuC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,cAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;CAClD,GAAG,aAAa,CAAC,UAAU,CAAC,CAoB5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,QAAQ,EACT,EAAE;IACD,OAAO,EAAE,aA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