@interop/wallet-core 0.23.1 → 0.25.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 +41 -22
- package/dist/clients/index.d.ts +6 -4
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +5 -3
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/policy.d.ts +11 -3
- package/dist/clients/policy.d.ts.map +1 -1
- package/dist/clients/policy.js +12 -4
- package/dist/clients/policy.js.map +1 -1
- package/dist/clients/revocation.d.ts +24 -9
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/revocation.js +23 -10
- package/dist/clients/revocation.js.map +1 -1
- package/dist/clients/rosterPolicy.d.ts +23 -22
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/clients/rosterPolicy.js +50 -31
- package/dist/clients/rosterPolicy.js.map +1 -1
- package/dist/descriptors/acquire.d.ts +4 -1
- package/dist/descriptors/acquire.d.ts.map +1 -1
- package/dist/descriptors/acquire.js +29 -1
- package/dist/descriptors/acquire.js.map +1 -1
- package/dist/descriptors/index.d.ts +9 -1
- package/dist/descriptors/index.d.ts.map +1 -1
- package/dist/descriptors/index.js +9 -1
- package/dist/descriptors/index.js.map +1 -1
- package/dist/descriptors/logSource.d.ts +33 -0
- package/dist/descriptors/logSource.d.ts.map +1 -0
- package/dist/descriptors/logSource.js +49 -0
- package/dist/descriptors/logSource.js.map +1 -0
- package/dist/enrollment/enrollment.d.ts +2 -2
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +15 -10
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/keys/index.d.ts +15 -8
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +14 -8
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts +53 -0
- package/dist/keys/rosterLogStore.d.ts.map +1 -0
- package/dist/keys/rosterLogStore.js +134 -0
- package/dist/keys/rosterLogStore.js.map +1 -0
- package/dist/keys/rosterStore.d.ts +20 -6
- package/dist/keys/rosterStore.d.ts.map +1 -1
- package/dist/keys/rosterStore.js +36 -17
- package/dist/keys/rosterStore.js.map +1 -1
- package/dist/keys/userKeyCascade.d.ts +14 -7
- package/dist/keys/userKeyCascade.d.ts.map +1 -1
- package/dist/keys/userKeyCascade.js +12 -3
- package/dist/keys/userKeyCascade.js.map +1 -1
- package/dist/keys/userKeyRoster.d.ts +50 -97
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +44 -145
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/request/appKey.d.ts +255 -0
- package/dist/request/appKey.d.ts.map +1 -0
- package/dist/request/appKey.js +492 -0
- package/dist/request/appKey.js.map +1 -0
- package/dist/request/classify.d.ts +54 -3
- package/dist/request/classify.d.ts.map +1 -1
- package/dist/request/classify.js +106 -0
- package/dist/request/classify.js.map +1 -1
- package/dist/request/composeVp.d.ts +6 -7
- package/dist/request/composeVp.d.ts.map +1 -1
- package/dist/request/composeVp.js +44 -55
- package/dist/request/composeVp.js.map +1 -1
- package/dist/request/index.d.ts +4 -0
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +4 -0
- package/dist/request/index.js.map +1 -1
- package/dist/request/processRequest.d.ts +1 -4
- package/dist/request/processRequest.d.ts.map +1 -1
- package/dist/request/processRequest.js +17 -11
- package/dist/request/processRequest.js.map +1 -1
- package/dist/request/types.d.ts +45 -2
- package/dist/request/types.d.ts.map +1 -1
- package/dist/resourceLog/append.d.ts +103 -0
- package/dist/resourceLog/append.d.ts.map +1 -0
- package/dist/resourceLog/append.js +190 -0
- package/dist/resourceLog/append.js.map +1 -0
- package/dist/resourceLog/controller.d.ts +57 -0
- package/dist/resourceLog/controller.d.ts.map +1 -0
- package/dist/resourceLog/controller.js +81 -0
- package/dist/resourceLog/controller.js.map +1 -0
- package/dist/resourceLog/entry.d.ts +68 -0
- package/dist/resourceLog/entry.d.ts.map +1 -0
- package/dist/resourceLog/entry.js +167 -0
- package/dist/resourceLog/entry.js.map +1 -0
- package/dist/resourceLog/errors.d.ts +75 -0
- package/dist/resourceLog/errors.d.ts.map +1 -0
- package/dist/resourceLog/errors.js +76 -0
- package/dist/resourceLog/errors.js.map +1 -0
- package/dist/resourceLog/index.d.ts +26 -0
- package/dist/resourceLog/index.d.ts.map +1 -0
- package/dist/resourceLog/index.js +26 -0
- package/dist/resourceLog/index.js.map +1 -0
- package/dist/resourceLog/pin.d.ts +44 -0
- package/dist/resourceLog/pin.d.ts.map +1 -0
- package/dist/resourceLog/pin.js +32 -0
- package/dist/resourceLog/pin.js.map +1 -0
- package/dist/resourceLog/seal.d.ts +86 -0
- package/dist/resourceLog/seal.d.ts.map +1 -0
- package/dist/resourceLog/seal.js +99 -0
- package/dist/resourceLog/seal.js.map +1 -0
- package/dist/resourceLog/verify.d.ts +95 -0
- package/dist/resourceLog/verify.d.ts.map +1 -0
- package/dist/resourceLog/verify.js +435 -0
- package/dist/resourceLog/verify.js.map +1 -0
- package/dist/space/collections.d.ts +14 -11
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +14 -11
- package/dist/space/collections.js.map +1 -1
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +2 -2
- package/dist/space/index.js.map +1 -1
- package/dist/webvh/didWeb.d.ts +4 -6
- package/dist/webvh/didWeb.d.ts.map +1 -1
- package/dist/webvh/didWeb.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +1 -2
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +1 -6
- package/dist/webvh/didWebvh.js.map +1 -1
- package/package.json +11 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* The user key wrap set: the `key-map/user-key.
|
|
5
|
+
* The user key wrap set: the roster governed by `key-map/user-key.jsonl`. Its state
|
|
6
6
|
* is a `CollectionEncryption` descriptor verbatim, whose current epoch IS the
|
|
7
7
|
* current user key -- the epoch id is the user key's did:key and the wrapped
|
|
8
8
|
* secret is the user key's raw 32-byte key, wrapped to each enrolled client's
|
|
@@ -10,25 +10,34 @@
|
|
|
10
10
|
* each client keeps the user key in its own local state under the unlock layer,
|
|
11
11
|
* and the roster's epoch stamp marks a cached copy stale.
|
|
12
12
|
*
|
|
13
|
-
* Everything mutates through was-client's descriptor-store seam
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Everything mutates through was-client's descriptor-store seam -- since the
|
|
14
|
+
* roster became log-governed, the log-backed adapter
|
|
15
|
+
* (`logGovernedDescriptorStore`): reads resolve to the roster log's VERIFIED
|
|
16
|
+
* head state, writes append signed entries. No descriptor logic is
|
|
16
17
|
* reimplemented here.
|
|
17
18
|
*
|
|
18
19
|
* A resource-hosted descriptor gets NONE of the server-side epoch invariants a
|
|
19
20
|
* Collection Description enforces (append-only epochs, monotone
|
|
20
|
-
* `currentEpoch`), so
|
|
21
|
+
* `currentEpoch`), so the client-side compensations are load-bearing alone
|
|
21
22
|
* against a tampering host:
|
|
22
23
|
*
|
|
23
|
-
* -
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* - **The resource log** -- the roster is governed by a hash-linked log whose
|
|
25
|
+
* every entry is signed by an enrolled client's key, anchored in the
|
|
26
|
+
* locally verified did:webvh document, and continuity-checked against the
|
|
27
|
+
* client's chain-head pin (the `resourceLog` module). A fabricated roster
|
|
28
|
+
* fails entry-proof verification (`ResourceLogIntegrityError`); a rolled
|
|
29
|
+
* back, forked, or format-switched log fails continuity
|
|
30
|
+
* (`ResourceLogContinuityError`). This is the successor of the retired
|
|
31
|
+
* detached `epochsSig`: the entry proof covers the whole configuration, on
|
|
32
|
+
* every read instead of only the adopt path. (The `epochsMac`
|
|
33
|
+
* epoch-configuration MAC that used to sit beneath it is retired stack-wide:
|
|
34
|
+
* on a log-governed resource its coverage was a strict subset of chain
|
|
35
|
+
* verification.)
|
|
26
36
|
* - **The epoch pin** -- the latest-seen roster epoch is pinned locally by the
|
|
27
37
|
* consuming app (beside the account-pointer pin); a served
|
|
28
38
|
* roster that rolls back behind the pin is refused
|
|
29
|
-
* (`UserKeyRosterContinuityError`) rather than followed
|
|
30
|
-
*
|
|
31
|
-
* account pointer.
|
|
39
|
+
* (`UserKeyRosterContinuityError`) rather than followed, even where the
|
|
40
|
+
* chain-head pin was lost with a reinstalled client.
|
|
32
41
|
* - **The roster delivers, never sources** -- the recipient-key source of
|
|
33
42
|
* record is the locally verified did:webvh document (one `keyAgreement`
|
|
34
43
|
* verification method per enrolled client). When an epoch rotates, each
|
|
@@ -37,28 +46,18 @@
|
|
|
37
46
|
* verification method is dropped and never receives a wrap, so a
|
|
38
47
|
* server-injected entry sits ignored. Wraps are minted only by enrolled
|
|
39
48
|
* clients, against log-verified keys.
|
|
40
|
-
* - **`epochsSig`** -- the epoch configuration is additionally SIGNED by the
|
|
41
|
-
* writing client's enrolled Ed25519 key (`userKeyRosterEpochsSigner`), and a
|
|
42
|
-
* read that adopts an epoch this client has not vouched for itself (a
|
|
43
|
-
* rotated read, or a freshly enrolled client's first read) verifies that
|
|
44
|
-
* signature against the locally verified did:webvh document
|
|
45
|
-
* (`verifyUserKeyRosterEpochsSig`). This is the check the `epochsMac` alone
|
|
46
|
-
* cannot make on those paths: the MAC is keyed by a secret unwrapped from
|
|
47
|
-
* the served descriptor itself, so a host that mints its own epoch, wraps
|
|
48
|
-
* it to this client's world-readable key-agreement key, and MACs the
|
|
49
|
-
* fabricated configuration under the same minted secret passes the MAC --
|
|
50
|
-
* but it cannot produce a signature by a key the document backs.
|
|
51
49
|
*/
|
|
52
50
|
import type { IKeyAgreementKey } from '@interop/data-integrity-core';
|
|
53
51
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
54
|
-
import { type EncryptionDescriptorStore, type
|
|
52
|
+
import { type EncryptionDescriptorStore, type RecipientPublicKey } from '@interop/was-client/edv';
|
|
53
|
+
import type { ResourceLogSigner } from '../resourceLog/index.js';
|
|
55
54
|
import { type ICapabilityAgent } from '../webvh/zcap.js';
|
|
56
55
|
import type { UserKey } from './userKey.js';
|
|
57
56
|
/**
|
|
58
|
-
* Thrown when a served roster fails its client-side
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
57
|
+
* Thrown when a served roster fails its client-side consistency checks: a
|
|
58
|
+
* descriptor whose `currentEpoch` names no epoch in its own list. The server
|
|
59
|
+
* (or whoever can write to it) has produced a configuration no enrolled
|
|
60
|
+
* client authenticated.
|
|
62
61
|
*/
|
|
63
62
|
export declare class UserKeyRosterIntegrityError extends Error {
|
|
64
63
|
constructor(message: string);
|
|
@@ -67,8 +66,7 @@ export declare class UserKeyRosterIntegrityError extends Error {
|
|
|
67
66
|
* Thrown when a served roster conflicts with the locally pinned latest-seen
|
|
68
67
|
* epoch -- the epochs list no longer contains the pinned epoch, or
|
|
69
68
|
* `currentEpoch` precedes it in the (append-only) list. A rollback/replay of
|
|
70
|
-
* an older consistent configuration
|
|
71
|
-
* catch; refused rather than followed.
|
|
69
|
+
* an older consistent configuration; refused rather than followed.
|
|
72
70
|
*/
|
|
73
71
|
export declare class UserKeyRosterContinuityError extends Error {
|
|
74
72
|
pinnedEpochId: string;
|
|
@@ -101,40 +99,22 @@ export interface RosterRecipientDocument {
|
|
|
101
99
|
}>;
|
|
102
100
|
}
|
|
103
101
|
/**
|
|
104
|
-
* The roster's
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
102
|
+
* The roster's log signer: signs each roster log append with this client's
|
|
103
|
+
* own Ed25519 signing key, named by its public multibase -- exactly the
|
|
104
|
+
* string enrolled as this client's verification method in the did:webvh
|
|
105
|
+
* document, so a reader resolves the entry proof against the document rather
|
|
106
|
+
* than anything the roster (or the server) supplies. Successor of the retired
|
|
107
|
+
* `epochsSig` signer under the log design.
|
|
110
108
|
*
|
|
111
109
|
* @param options {object}
|
|
112
110
|
* @param options.keyAgent {ICapabilityAgent} this client's signing key
|
|
113
111
|
* agent (the `keyAgent` of `agentsFromSeed`)
|
|
114
|
-
* @returns {
|
|
112
|
+
* @returns {ResourceLogSigner} the signer for the log-governed store's
|
|
113
|
+
* appends
|
|
115
114
|
*/
|
|
116
|
-
export declare function
|
|
115
|
+
export declare function userKeyRosterLogSigner({ keyAgent }: {
|
|
117
116
|
keyAgent: ICapabilityAgent;
|
|
118
|
-
}):
|
|
119
|
-
/**
|
|
120
|
-
* Verifies a served roster's `epochsSig` against the locally verified
|
|
121
|
-
* did:webvh document -- the root of trust the server cannot mint. The
|
|
122
|
-
* signature must be present and supported, its `kid` must be the public
|
|
123
|
-
* multibase of one of the document's verification methods (an enrolled
|
|
124
|
-
* client's signing key), and it must verify over the canonical
|
|
125
|
-
* epoch-configuration payload. Throws {@link UserKeyRosterIntegrityError}
|
|
126
|
-
* otherwise: a configuration no enrolled client signed.
|
|
127
|
-
*
|
|
128
|
-
* @param options {object}
|
|
129
|
-
* @param options.descriptor {CollectionEncryption} the served roster
|
|
130
|
-
* @param options.document {RosterRecipientDocument} the locally verified
|
|
131
|
-
* did:webvh document (never a server-supplied roster field)
|
|
132
|
-
* @returns {Promise<void>}
|
|
133
|
-
*/
|
|
134
|
-
export declare function verifyUserKeyRosterEpochsSig({ descriptor, document }: {
|
|
135
|
-
descriptor: CollectionEncryption;
|
|
136
|
-
document: RosterRecipientDocument;
|
|
137
|
-
}): Promise<void>;
|
|
117
|
+
}): ResourceLogSigner;
|
|
138
118
|
/**
|
|
139
119
|
* A wallet client's roster kid: its key-agreement key's id exactly as
|
|
140
120
|
* `agentsFromSeed` derives it at the client's own logins
|
|
@@ -185,16 +165,12 @@ export declare function userKeyRosterRecipientResolver({ document }: {
|
|
|
185
165
|
* @param options.userKey {UserKey} the account's user key
|
|
186
166
|
* @param options.clientKeyAgreementKey {IKeyAgreementKey} this client's own
|
|
187
167
|
* (identity) key-agreement key -- the roster recipient
|
|
188
|
-
* @param options.signEpochs {EpochsSigner} this client's epoch-configuration
|
|
189
|
-
* signer ({@link userKeyRosterEpochsSigner}), so the first configuration is
|
|
190
|
-
* vouched for by an enrollable key rather than only its own MAC
|
|
191
168
|
* @returns {Promise<CollectionEncryption>} the roster descriptor
|
|
192
169
|
*/
|
|
193
|
-
export declare function ensureUserKeyRoster({ store, userKey, clientKeyAgreementKey
|
|
170
|
+
export declare function ensureUserKeyRoster({ store, userKey, clientKeyAgreementKey }: {
|
|
194
171
|
store: EncryptionDescriptorStore;
|
|
195
172
|
userKey: UserKey;
|
|
196
173
|
clientKeyAgreementKey: IKeyAgreementKey;
|
|
197
|
-
signEpochs: EpochsSigner;
|
|
198
174
|
}): Promise<CollectionEncryption>;
|
|
199
175
|
/**
|
|
200
176
|
* Wraps the user key to a client being enrolled -- the roster half of the
|
|
@@ -246,16 +222,12 @@ export declare function addUserKeyRosterRecipient({ store, recipient, ownerKeyAg
|
|
|
246
222
|
* did:webvh document, AFTER the removal edit
|
|
247
223
|
* @param options.retireRecipientId {string} the removed recipient's roster
|
|
248
224
|
* kid
|
|
249
|
-
* @param options.signEpochs {EpochsSigner} the rotating client's
|
|
250
|
-
* epoch-configuration signer ({@link userKeyRosterEpochsSigner}), vouching for
|
|
251
|
-
* the fresh epoch so other clients' rotated reads accept it
|
|
252
225
|
* @returns {Promise<CollectionEncryption>} the rotated roster descriptor
|
|
253
226
|
*/
|
|
254
|
-
export declare function rotateUserKeyRoster({ store, document, retireRecipientId
|
|
227
|
+
export declare function rotateUserKeyRoster({ store, document, retireRecipientId }: {
|
|
255
228
|
store: EncryptionDescriptorStore;
|
|
256
229
|
document: RosterRecipientDocument;
|
|
257
230
|
retireRecipientId: string;
|
|
258
|
-
signEpochs: EpochsSigner;
|
|
259
231
|
}): Promise<CollectionEncryption>;
|
|
260
232
|
/**
|
|
261
233
|
* Converges the roster onto the account document: the standing detector for a
|
|
@@ -291,18 +263,14 @@ export declare function rotateUserKeyRoster({ store, document, retireRecipientId
|
|
|
291
263
|
* @param [options.descriptor] {CollectionEncryption} a descriptor the caller
|
|
292
264
|
* has just read (a login-time roster read), to save a re-read; omitted, the
|
|
293
265
|
* roster is read fresh
|
|
294
|
-
* @param options.signEpochs {EpochsSigner} the converging client's
|
|
295
|
-
* epoch-configuration signer ({@link userKeyRosterEpochsSigner}), for the
|
|
296
|
-
* rotation this call may perform
|
|
297
266
|
* @returns {Promise<object>} whether the roster rotated on this call, the
|
|
298
267
|
* stale recipient kids found, and the roster descriptor as it now stands
|
|
299
268
|
* (`null` when the account has no roster yet)
|
|
300
269
|
*/
|
|
301
|
-
export declare function convergeUserKeyRosterToDocument({ store, document, descriptor
|
|
270
|
+
export declare function convergeUserKeyRosterToDocument({ store, document, descriptor }: {
|
|
302
271
|
store: EncryptionDescriptorStore;
|
|
303
272
|
document: RosterRecipientDocument;
|
|
304
273
|
descriptor?: CollectionEncryption;
|
|
305
|
-
signEpochs: EpochsSigner;
|
|
306
274
|
}): Promise<{
|
|
307
275
|
rotated: boolean;
|
|
308
276
|
staleRecipientIds: string[];
|
|
@@ -325,24 +293,19 @@ export interface UserKeyRosterReadResult {
|
|
|
325
293
|
* mismatch. Resolves `null` when the roster does not exist yet (an account
|
|
326
294
|
* provisioned before the roster, or provisioning still in flight); otherwise:
|
|
327
295
|
*
|
|
328
|
-
* 1. **
|
|
296
|
+
* 1. **Provenance** is the store's: a log-governed store resolves the read
|
|
297
|
+
* from the roster log's verified head -- entry proofs checked against the
|
|
298
|
+
* locally verified did:webvh document, chain-head pin enforced -- so
|
|
299
|
+
* every epoch this read can deliver was signed onto the log by an
|
|
300
|
+
* enrolled client. (The detached `epochsSig` this step used to verify on
|
|
301
|
+
* the adopt path is retired; the entry proof covers every read.)
|
|
302
|
+
* 2. **Continuity**: the served epochs must contain the pinned latest-seen
|
|
329
303
|
* epoch, and `currentEpoch` must not precede it in the append-only list
|
|
330
304
|
* (`UserKeyRosterContinuityError` -- the rollback/replay refusal).
|
|
331
|
-
*
|
|
305
|
+
* 3. **Possession**: `currentEpoch === userKey.id` confirms the cached user key
|
|
332
306
|
* current; otherwise the current epoch was rotated by another client and
|
|
333
307
|
* this client's wrap is unwrapped with its own key-agreement key
|
|
334
308
|
* (`UserKeyRosterUnwrapError` when it holds none).
|
|
335
|
-
* 3. **Provenance** (the rotated/first-read path only): the epoch
|
|
336
|
-
* configuration's `epochsSig` is verified against the locally verified
|
|
337
|
-
* did:webvh document ({@link verifyUserKeyRosterEpochsSig}) BEFORE the epoch
|
|
338
|
-
* it delivers is adopted. On this path the `epochsMac` alone proves
|
|
339
|
-
* nothing against the host -- its key is unwrapped from the served
|
|
340
|
-
* descriptor itself -- so an epoch no enrolled client signed is refused
|
|
341
|
-
* (`UserKeyRosterIntegrityError`). The cached-current path needs no signature:
|
|
342
|
-
* there the MAC is keyed by a secret this client already trusts.
|
|
343
|
-
* 4. **Authentication**: the descriptor's `epochsMac` is verified under the
|
|
344
|
-
* current epoch's secret (`UserKeyRosterIntegrityError` on any mismatch -- a
|
|
345
|
-
* fabricated configuration).
|
|
346
309
|
*
|
|
347
310
|
* A rotated read returns the fresh user key; its Ed25519 signing seed does not
|
|
348
311
|
* travel through the roster (the roster wraps the key-agreement secret
|
|
@@ -351,10 +314,7 @@ export interface UserKeyRosterReadResult {
|
|
|
351
314
|
* A caller with no cached user key at all -- a freshly enrolled client making
|
|
352
315
|
* its first post-enrollment read -- omits `userKey` and always takes the unwrap
|
|
353
316
|
* path; the result's `rotated` is then true (the user key was adopted from the
|
|
354
|
-
* roster).
|
|
355
|
-
* (or a way to resolve it): `document` when it already holds a verified copy,
|
|
356
|
-
* or `resolveDocument` to fetch-and-verify lazily, only when the read actually
|
|
357
|
-
* rotates.
|
|
317
|
+
* roster).
|
|
358
318
|
*
|
|
359
319
|
* @param options {object}
|
|
360
320
|
* @param options.store {EncryptionDescriptorStore} the roster's descriptor
|
|
@@ -364,19 +324,12 @@ export interface UserKeyRosterReadResult {
|
|
|
364
324
|
* (identity) key-agreement key, unwrapping a rotated epoch
|
|
365
325
|
* @param [options.pinnedEpochId] {string} the locally pinned latest-seen
|
|
366
326
|
* roster epoch, when this client has seen the roster before
|
|
367
|
-
* @param [options.document] {RosterRecipientDocument} the locally verified
|
|
368
|
-
* did:webvh document, when the caller already holds one
|
|
369
|
-
* @param [options.resolveDocument] {function} resolves the locally verified
|
|
370
|
-
* did:webvh document on demand; called only when the read takes the
|
|
371
|
-
* rotated/first-read path
|
|
372
327
|
* @returns {Promise<UserKeyRosterReadResult | null>}
|
|
373
328
|
*/
|
|
374
|
-
export declare function readUserKeyRoster({ store, userKey, clientKeyAgreementKey, pinnedEpochId
|
|
329
|
+
export declare function readUserKeyRoster({ store, userKey, clientKeyAgreementKey, pinnedEpochId }: {
|
|
375
330
|
store: EncryptionDescriptorStore;
|
|
376
331
|
userKey?: UserKey;
|
|
377
332
|
clientKeyAgreementKey: IKeyAgreementKey;
|
|
378
333
|
pinnedEpochId?: string | null;
|
|
379
|
-
document?: RosterRecipientDocument;
|
|
380
|
-
resolveDocument?: () => Promise<RosterRecipientDocument>;
|
|
381
334
|
}): Promise<UserKeyRosterReadResult | null>;
|
|
382
335
|
//# sourceMappingURL=userKeyRoster.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userKeyRoster.d.ts","sourceRoot":"","sources":["../../src/keys/userKeyRoster.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"userKeyRoster.d.ts","sourceRoot":"","sources":["../../src/keys/userKeyRoster.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,E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,OAAO,CAAC;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,UAAU,EAAE,oBAAoB,GAAG,IAAI,CAAA;CACxC,CAAC,CAgDD;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,oBAAoB,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,OAAO,EACP,qBAAqB,EACrB,aAAa,EACd,EAAE;IACD,KAAK,EAAE,yBAAyB,CAAA;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qBAAqB,EAAE,gBAAgB,CAAA;IACvC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CA8D1C"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { addRecipient,
|
|
2
|
-
import { Ed25519VerificationKey } from '@interop/ed25519-verification-key';
|
|
3
|
-
import { base64urlnopad } from '@scure/base';
|
|
1
|
+
import { addRecipient, initRecipients, ownerRecipient, removeRecipient, unwrapEpochSecret } from '@interop/was-client/edv';
|
|
4
2
|
import { clientSigningKeyMultibase } from '../webvh/zcap.js';
|
|
5
3
|
/**
|
|
6
|
-
* Thrown when a served roster fails its client-side
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Thrown when a served roster fails its client-side consistency checks: a
|
|
5
|
+
* descriptor whose `currentEpoch` names no epoch in its own list. The server
|
|
6
|
+
* (or whoever can write to it) has produced a configuration no enrolled
|
|
7
|
+
* client authenticated.
|
|
10
8
|
*/
|
|
11
9
|
export class UserKeyRosterIntegrityError extends Error {
|
|
12
10
|
constructor(message) {
|
|
@@ -18,8 +16,7 @@ export class UserKeyRosterIntegrityError extends Error {
|
|
|
18
16
|
* Thrown when a served roster conflicts with the locally pinned latest-seen
|
|
19
17
|
* epoch -- the epochs list no longer contains the pinned epoch, or
|
|
20
18
|
* `currentEpoch` precedes it in the (append-only) list. A rollback/replay of
|
|
21
|
-
* an older consistent configuration
|
|
22
|
-
* catch; refused rather than followed.
|
|
19
|
+
* an older consistent configuration; refused rather than followed.
|
|
23
20
|
*/
|
|
24
21
|
export class UserKeyRosterContinuityError extends Error {
|
|
25
22
|
pinnedEpochId;
|
|
@@ -43,85 +40,32 @@ export class UserKeyRosterUnwrapError extends Error {
|
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
46
|
-
* The
|
|
47
|
-
* Ed25519
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const EPOCHS_SIG_ALG = 'EdDSA';
|
|
53
|
-
/**
|
|
54
|
-
* The roster's epoch-configuration signer: signs each roster write's epoch
|
|
55
|
-
* configuration with this client's own Ed25519 signing key, under a `kid`
|
|
56
|
-
* that is the key's public multibase -- exactly the string enrolled as this
|
|
57
|
-
* client's verification method in the did:webvh document, so a reader
|
|
58
|
-
* resolves the signature against the document rather than anything the
|
|
59
|
-
* roster (or the server) supplies.
|
|
43
|
+
* The roster's log signer: signs each roster log append with this client's
|
|
44
|
+
* own Ed25519 signing key, named by its public multibase -- exactly the
|
|
45
|
+
* string enrolled as this client's verification method in the did:webvh
|
|
46
|
+
* document, so a reader resolves the entry proof against the document rather
|
|
47
|
+
* than anything the roster (or the server) supplies. Successor of the retired
|
|
48
|
+
* `epochsSig` signer under the log design.
|
|
60
49
|
*
|
|
61
50
|
* @param options {object}
|
|
62
51
|
* @param options.keyAgent {ICapabilityAgent} this client's signing key
|
|
63
52
|
* agent (the `keyAgent` of `agentsFromSeed`)
|
|
64
|
-
* @returns {
|
|
53
|
+
* @returns {ResourceLogSigner} the signer for the log-governed store's
|
|
54
|
+
* appends
|
|
65
55
|
*/
|
|
66
|
-
export function
|
|
67
|
-
const
|
|
56
|
+
export function userKeyRosterLogSigner({ keyAgent }) {
|
|
57
|
+
const keyMultibase = clientSigningKeyMultibase({ keyAgent });
|
|
68
58
|
const signer = keyAgent.getSigner();
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
59
|
+
return {
|
|
60
|
+
keyMultibase,
|
|
61
|
+
async sign({ data }) {
|
|
62
|
+
const signature = await signer.sign({ data });
|
|
63
|
+
// Re-wrap as a plain Uint8Array: a signer may return a Node Buffer (or
|
|
64
|
+
// a cross-realm view), which the kernel's strict byte check rejects.
|
|
65
|
+
return new Uint8Array(signature.buffer, signature.byteOffset, signature.byteLength);
|
|
66
|
+
}
|
|
77
67
|
};
|
|
78
68
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Verifies a served roster's `epochsSig` against the locally verified
|
|
81
|
-
* did:webvh document -- the root of trust the server cannot mint. The
|
|
82
|
-
* signature must be present and supported, its `kid` must be the public
|
|
83
|
-
* multibase of one of the document's verification methods (an enrolled
|
|
84
|
-
* client's signing key), and it must verify over the canonical
|
|
85
|
-
* epoch-configuration payload. Throws {@link UserKeyRosterIntegrityError}
|
|
86
|
-
* otherwise: a configuration no enrolled client signed.
|
|
87
|
-
*
|
|
88
|
-
* @param options {object}
|
|
89
|
-
* @param options.descriptor {CollectionEncryption} the served roster
|
|
90
|
-
* @param options.document {RosterRecipientDocument} the locally verified
|
|
91
|
-
* did:webvh document (never a server-supplied roster field)
|
|
92
|
-
* @returns {Promise<void>}
|
|
93
|
-
*/
|
|
94
|
-
export async function verifyUserKeyRosterEpochsSig({ descriptor, document }) {
|
|
95
|
-
const epochsSig = descriptor.epochsSig;
|
|
96
|
-
if (!epochsSig ||
|
|
97
|
-
epochsSig.v !== EPOCHS_SIG_V ||
|
|
98
|
-
epochsSig.alg !== EPOCHS_SIG_ALG) {
|
|
99
|
-
throw new UserKeyRosterIntegrityError('The user key roster carries no supported epoch-configuration signature.');
|
|
100
|
-
}
|
|
101
|
-
const backed = (document.verificationMethod ?? []).some(method => method.publicKeyMultibase === epochsSig.kid);
|
|
102
|
-
if (!backed) {
|
|
103
|
-
throw new UserKeyRosterIntegrityError('The user key roster epoch configuration is signed by a key the account ' +
|
|
104
|
-
'document does not back.');
|
|
105
|
-
}
|
|
106
|
-
let signature;
|
|
107
|
-
try {
|
|
108
|
-
signature = base64urlnopad.decode(epochsSig.sig);
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
throw new UserKeyRosterIntegrityError('The user key roster epoch-configuration signature is malformed.');
|
|
112
|
-
}
|
|
113
|
-
const verifier = new Ed25519VerificationKey({
|
|
114
|
-
controller: `did:key:${epochsSig.kid}`,
|
|
115
|
-
publicKeyMultibase: epochsSig.kid
|
|
116
|
-
}).verifier();
|
|
117
|
-
const verified = await verifier.verify({
|
|
118
|
-
data: epochsSigPayload(descriptor),
|
|
119
|
-
signature
|
|
120
|
-
});
|
|
121
|
-
if (!verified) {
|
|
122
|
-
throw new UserKeyRosterIntegrityError('The user key roster epoch-configuration signature failed verification.');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
69
|
/**
|
|
126
70
|
* A wallet client's roster kid: its key-agreement key's id exactly as
|
|
127
71
|
* `agentsFromSeed` derives it at the client's own logins
|
|
@@ -212,12 +156,9 @@ export function userKeyRosterRecipientResolver({ document }) {
|
|
|
212
156
|
* @param options.userKey {UserKey} the account's user key
|
|
213
157
|
* @param options.clientKeyAgreementKey {IKeyAgreementKey} this client's own
|
|
214
158
|
* (identity) key-agreement key -- the roster recipient
|
|
215
|
-
* @param options.signEpochs {EpochsSigner} this client's epoch-configuration
|
|
216
|
-
* signer ({@link userKeyRosterEpochsSigner}), so the first configuration is
|
|
217
|
-
* vouched for by an enrollable key rather than only its own MAC
|
|
218
159
|
* @returns {Promise<CollectionEncryption>} the roster descriptor
|
|
219
160
|
*/
|
|
220
|
-
export async function ensureUserKeyRoster({ store, userKey, clientKeyAgreementKey
|
|
161
|
+
export async function ensureUserKeyRoster({ store, userKey, clientKeyAgreementKey }) {
|
|
221
162
|
const current = await store.read();
|
|
222
163
|
if (current !== null) {
|
|
223
164
|
return current.descriptor;
|
|
@@ -225,8 +166,7 @@ export async function ensureUserKeyRoster({ store, userKey, clientKeyAgreementKe
|
|
|
225
166
|
return initRecipients({
|
|
226
167
|
store,
|
|
227
168
|
recipients: [ownerRecipient({ keyAgreementKey: clientKeyAgreementKey })],
|
|
228
|
-
epoch: { epochId: userKey.id, secret: userKey.secret }
|
|
229
|
-
signEpochs
|
|
169
|
+
epoch: { epochId: userKey.id, secret: userKey.secret }
|
|
230
170
|
});
|
|
231
171
|
}
|
|
232
172
|
/**
|
|
@@ -295,18 +235,14 @@ export async function addUserKeyRosterRecipient({ store, recipient, ownerKeyAgre
|
|
|
295
235
|
* did:webvh document, AFTER the removal edit
|
|
296
236
|
* @param options.retireRecipientId {string} the removed recipient's roster
|
|
297
237
|
* kid
|
|
298
|
-
* @param options.signEpochs {EpochsSigner} the rotating client's
|
|
299
|
-
* epoch-configuration signer ({@link userKeyRosterEpochsSigner}), vouching for
|
|
300
|
-
* the fresh epoch so other clients' rotated reads accept it
|
|
301
238
|
* @returns {Promise<CollectionEncryption>} the rotated roster descriptor
|
|
302
239
|
*/
|
|
303
|
-
export async function rotateUserKeyRoster({ store, document, retireRecipientId
|
|
240
|
+
export async function rotateUserKeyRoster({ store, document, retireRecipientId }) {
|
|
304
241
|
return removeRecipient({
|
|
305
242
|
store,
|
|
306
243
|
recipientId: retireRecipientId,
|
|
307
244
|
resolveRecipientKey: userKeyRosterRecipientResolver({ document }),
|
|
308
|
-
pull: async () => { }
|
|
309
|
-
signEpochs
|
|
245
|
+
pull: async () => { }
|
|
310
246
|
});
|
|
311
247
|
}
|
|
312
248
|
/**
|
|
@@ -343,14 +279,11 @@ export async function rotateUserKeyRoster({ store, document, retireRecipientId,
|
|
|
343
279
|
* @param [options.descriptor] {CollectionEncryption} a descriptor the caller
|
|
344
280
|
* has just read (a login-time roster read), to save a re-read; omitted, the
|
|
345
281
|
* roster is read fresh
|
|
346
|
-
* @param options.signEpochs {EpochsSigner} the converging client's
|
|
347
|
-
* epoch-configuration signer ({@link userKeyRosterEpochsSigner}), for the
|
|
348
|
-
* rotation this call may perform
|
|
349
282
|
* @returns {Promise<object>} whether the roster rotated on this call, the
|
|
350
283
|
* stale recipient kids found, and the roster descriptor as it now stands
|
|
351
284
|
* (`null` when the account has no roster yet)
|
|
352
285
|
*/
|
|
353
|
-
export async function convergeUserKeyRosterToDocument({ store, document, descriptor
|
|
286
|
+
export async function convergeUserKeyRosterToDocument({ store, document, descriptor }) {
|
|
354
287
|
let roster = descriptor;
|
|
355
288
|
if (!roster) {
|
|
356
289
|
const read = await store.read();
|
|
@@ -388,8 +321,7 @@ export async function convergeUserKeyRosterToDocument({ store, document, descrip
|
|
|
388
321
|
const rotated = await rotateUserKeyRoster({
|
|
389
322
|
store,
|
|
390
323
|
document,
|
|
391
|
-
retireRecipientId: staleRecipientIds[0]
|
|
392
|
-
signEpochs
|
|
324
|
+
retireRecipientId: staleRecipientIds[0]
|
|
393
325
|
});
|
|
394
326
|
return { rotated: true, staleRecipientIds, descriptor: rotated };
|
|
395
327
|
}
|
|
@@ -398,24 +330,19 @@ export async function convergeUserKeyRosterToDocument({ store, document, descrip
|
|
|
398
330
|
* mismatch. Resolves `null` when the roster does not exist yet (an account
|
|
399
331
|
* provisioned before the roster, or provisioning still in flight); otherwise:
|
|
400
332
|
*
|
|
401
|
-
* 1. **
|
|
333
|
+
* 1. **Provenance** is the store's: a log-governed store resolves the read
|
|
334
|
+
* from the roster log's verified head -- entry proofs checked against the
|
|
335
|
+
* locally verified did:webvh document, chain-head pin enforced -- so
|
|
336
|
+
* every epoch this read can deliver was signed onto the log by an
|
|
337
|
+
* enrolled client. (The detached `epochsSig` this step used to verify on
|
|
338
|
+
* the adopt path is retired; the entry proof covers every read.)
|
|
339
|
+
* 2. **Continuity**: the served epochs must contain the pinned latest-seen
|
|
402
340
|
* epoch, and `currentEpoch` must not precede it in the append-only list
|
|
403
341
|
* (`UserKeyRosterContinuityError` -- the rollback/replay refusal).
|
|
404
|
-
*
|
|
342
|
+
* 3. **Possession**: `currentEpoch === userKey.id` confirms the cached user key
|
|
405
343
|
* current; otherwise the current epoch was rotated by another client and
|
|
406
344
|
* this client's wrap is unwrapped with its own key-agreement key
|
|
407
345
|
* (`UserKeyRosterUnwrapError` when it holds none).
|
|
408
|
-
* 3. **Provenance** (the rotated/first-read path only): the epoch
|
|
409
|
-
* configuration's `epochsSig` is verified against the locally verified
|
|
410
|
-
* did:webvh document ({@link verifyUserKeyRosterEpochsSig}) BEFORE the epoch
|
|
411
|
-
* it delivers is adopted. On this path the `epochsMac` alone proves
|
|
412
|
-
* nothing against the host -- its key is unwrapped from the served
|
|
413
|
-
* descriptor itself -- so an epoch no enrolled client signed is refused
|
|
414
|
-
* (`UserKeyRosterIntegrityError`). The cached-current path needs no signature:
|
|
415
|
-
* there the MAC is keyed by a secret this client already trusts.
|
|
416
|
-
* 4. **Authentication**: the descriptor's `epochsMac` is verified under the
|
|
417
|
-
* current epoch's secret (`UserKeyRosterIntegrityError` on any mismatch -- a
|
|
418
|
-
* fabricated configuration).
|
|
419
346
|
*
|
|
420
347
|
* A rotated read returns the fresh user key; its Ed25519 signing seed does not
|
|
421
348
|
* travel through the roster (the roster wraps the key-agreement secret
|
|
@@ -424,10 +351,7 @@ export async function convergeUserKeyRosterToDocument({ store, document, descrip
|
|
|
424
351
|
* A caller with no cached user key at all -- a freshly enrolled client making
|
|
425
352
|
* its first post-enrollment read -- omits `userKey` and always takes the unwrap
|
|
426
353
|
* path; the result's `rotated` is then true (the user key was adopted from the
|
|
427
|
-
* roster).
|
|
428
|
-
* (or a way to resolve it): `document` when it already holds a verified copy,
|
|
429
|
-
* or `resolveDocument` to fetch-and-verify lazily, only when the read actually
|
|
430
|
-
* rotates.
|
|
354
|
+
* roster).
|
|
431
355
|
*
|
|
432
356
|
* @param options {object}
|
|
433
357
|
* @param options.store {EncryptionDescriptorStore} the roster's descriptor
|
|
@@ -437,14 +361,9 @@ export async function convergeUserKeyRosterToDocument({ store, document, descrip
|
|
|
437
361
|
* (identity) key-agreement key, unwrapping a rotated epoch
|
|
438
362
|
* @param [options.pinnedEpochId] {string} the locally pinned latest-seen
|
|
439
363
|
* roster epoch, when this client has seen the roster before
|
|
440
|
-
* @param [options.document] {RosterRecipientDocument} the locally verified
|
|
441
|
-
* did:webvh document, when the caller already holds one
|
|
442
|
-
* @param [options.resolveDocument] {function} resolves the locally verified
|
|
443
|
-
* did:webvh document on demand; called only when the read takes the
|
|
444
|
-
* rotated/first-read path
|
|
445
364
|
* @returns {Promise<UserKeyRosterReadResult | null>}
|
|
446
365
|
*/
|
|
447
|
-
export async function readUserKeyRoster({ store, userKey, clientKeyAgreementKey, pinnedEpochId
|
|
366
|
+
export async function readUserKeyRoster({ store, userKey, clientKeyAgreementKey, pinnedEpochId }) {
|
|
448
367
|
const current = await store.read();
|
|
449
368
|
if (current === null) {
|
|
450
369
|
return null;
|
|
@@ -463,11 +382,6 @@ export async function readUserKeyRoster({ store, userKey, clientKeyAgreementKey,
|
|
|
463
382
|
throw new UserKeyRosterContinuityError({ pinnedEpochId });
|
|
464
383
|
}
|
|
465
384
|
}
|
|
466
|
-
// The epochsMac construction's own version/alg are the caller's to check.
|
|
467
|
-
const epochsMac = descriptor.epochsMac;
|
|
468
|
-
if (!epochsMac || epochsMac.v !== 1 || epochsMac.alg !== 'HS256') {
|
|
469
|
-
throw new UserKeyRosterIntegrityError('The user key roster carries no supported epoch-configuration MAC.');
|
|
470
|
-
}
|
|
471
385
|
let currentUserKey;
|
|
472
386
|
let rotated;
|
|
473
387
|
if (userKey && descriptor.currentEpoch === userKey.id) {
|
|
@@ -475,22 +389,10 @@ export async function readUserKeyRoster({ store, userKey, clientKeyAgreementKey,
|
|
|
475
389
|
rotated = false;
|
|
476
390
|
}
|
|
477
391
|
else {
|
|
478
|
-
// Rotated by another client (or this client's first read):
|
|
479
|
-
//
|
|
480
|
-
//
|
|
481
|
-
// locally verified account document backs.
|
|
482
|
-
// carry this: on this path its key comes out of the served descriptor
|
|
483
|
-
// itself.
|
|
484
|
-
const accountDocument = document ?? (resolveDocument ? await resolveDocument() : undefined);
|
|
485
|
-
if (!accountDocument) {
|
|
486
|
-
throw new Error('A user key roster read that adopts an epoch from the roster needs the ' +
|
|
487
|
-
'account document (pass `document` or `resolveDocument`) to verify ' +
|
|
488
|
-
'the epoch configuration signature.');
|
|
489
|
-
}
|
|
490
|
-
await verifyUserKeyRosterEpochsSig({
|
|
491
|
-
descriptor,
|
|
492
|
-
document: accountDocument
|
|
493
|
-
});
|
|
392
|
+
// Rotated by another client (or this client's first read): the epoch
|
|
393
|
+
// being adopted traces to a root of trust the server cannot mint through
|
|
394
|
+
// the store itself -- a log-governed read only ever resolves to a head
|
|
395
|
+
// whose entry proofs the locally verified account document backs.
|
|
494
396
|
// Unwrap this client's entry in the current epoch with its own
|
|
495
397
|
// key-agreement key (rotation delivery).
|
|
496
398
|
const entry = descriptor.epochs[currentIndex].recipients.find(recipient => recipient.header.kid === clientKeyAgreementKey.id);
|
|
@@ -507,9 +409,6 @@ export async function readUserKeyRoster({ store, userKey, clientKeyAgreementKey,
|
|
|
507
409
|
currentUserKey = { id: descriptor.currentEpoch, secret };
|
|
508
410
|
rotated = true;
|
|
509
411
|
}
|
|
510
|
-
if (!(await verifyEpochsMac({ descriptor, epochSecret: currentUserKey.secret }))) {
|
|
511
|
-
throw new UserKeyRosterIntegrityError('The user key roster epoch configuration failed authentication.');
|
|
512
|
-
}
|
|
513
412
|
return {
|
|
514
413
|
descriptor,
|
|
515
414
|
userKey: currentUserKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userKeyRoster.js","sourceRoot":"","sources":["../../src/keys/userKeyRoster.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"userKeyRoster.js","sourceRoot":"","sources":["../../src/keys/userKeyRoster.ts"],"names":[],"mappings":"AAmDA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EAGlB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EACL,yBAAyB,EAE1B,MAAM,kBAAkB,CAAA;AAGzB;;;;;GAKG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAA;IAC3C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrD,aAAa,CAAQ;IACrB,YAAY,EAAE,aAAa,EAA6B;QACtD,KAAK,CACH,4EAA4E;YAC1E,mCAAmC,CACtC,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;QAC1C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;IACxC,CAAC;CACF;AAYD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,EAGT;IACC,MAAM,YAAY,GAAG,yBAAyB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAA;IACnC,OAAO;QACL,YAAY;QACZ,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAwB;YACvC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CA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