@interop/was-client 0.22.0 → 0.24.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 +12 -11
- package/dist/Collection.d.ts +28 -25
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +55 -51
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +7 -7
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +19 -18
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +3 -2
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +5 -4
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +19 -17
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +23 -21
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +16 -15
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +2 -2
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +29 -28
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +9 -8
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +9 -8
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/constants.js +1 -1
- package/dist/edv/descriptorStore.d.ts +119 -0
- package/dist/edv/descriptorStore.d.ts.map +1 -0
- package/dist/edv/{markerStore.js → descriptorStore.js} +41 -40
- package/dist/edv/descriptorStore.js.map +1 -0
- package/dist/edv/docCipher.d.ts +31 -29
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +26 -24
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/epochCrypto.d.ts +8 -8
- package/dist/edv/epochCrypto.d.ts.map +1 -1
- package/dist/edv/epochCrypto.js +15 -14
- package/dist/edv/epochCrypto.js.map +1 -1
- package/dist/edv/epochKeys.d.ts +18 -15
- package/dist/edv/epochKeys.d.ts.map +1 -1
- package/dist/edv/epochKeys.js +20 -19
- package/dist/edv/epochKeys.js.map +1 -1
- package/dist/edv/epochMac.d.ts +11 -10
- package/dist/edv/epochMac.d.ts.map +1 -1
- package/dist/edv/epochMac.js +24 -23
- package/dist/edv/epochMac.js.map +1 -1
- package/dist/edv/index.d.ts +11 -8
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +9 -7
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts +92 -30
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +228 -80
- package/dist/edv/recipients.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +2 -2
- package/dist/internal/codec.d.ts +8 -8
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +12 -12
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/describe.d.ts +3 -3
- package/dist/sync/envelope.d.ts +2 -2
- package/dist/sync/envelope.js +2 -2
- package/dist/sync/provisioning.d.ts +10 -10
- package/dist/sync/provisioning.js +9 -9
- package/dist/sync/types.d.ts +4 -4
- package/dist/types.d.ts +5 -5
- package/package.json +2 -2
- package/dist/edv/markerStore.d.ts +0 -118
- package/dist/edv/markerStore.d.ts.map +0 -1
- package/dist/edv/markerStore.js.map +0 -1
package/dist/edv/recipients.d.ts
CHANGED
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
* Recipient and key-epoch management for multi-recipient encrypted Collections:
|
|
6
6
|
* initializing the first epoch, adding a reader (escrow -- history included),
|
|
7
7
|
* and removing a reader (the full revoke-and-rotate procedure). Each operation
|
|
8
|
-
* mutates a `CollectionEncryption`
|
|
9
|
-
* `
|
|
10
|
-
* `collection` sugar, or any explicit `store`, such as a
|
|
11
|
-
* plain JSON Resource -- and writes it back with a
|
|
12
|
-
* (`If-Match`), retrying on a concurrent change so two racing
|
|
13
|
-
* cannot clobber one another.
|
|
8
|
+
* mutates a `CollectionEncryption` descriptor through the descriptor-store seam
|
|
9
|
+
* (see `descriptorStore.ts`) -- the Collection Description's `encryption`
|
|
10
|
+
* member for the `collection` sugar, or any explicit `store`, such as a
|
|
11
|
+
* descriptor hosted as a plain JSON Resource -- and writes it back with a
|
|
12
|
+
* compare-and-swap (`If-Match`), retrying on a concurrent change so two racing
|
|
13
|
+
* recipient edits cannot clobber one another.
|
|
14
14
|
*
|
|
15
15
|
* The two axes stay separate and are both required to actually remove a reader:
|
|
16
16
|
*
|
|
17
17
|
* - **pull** -- the reader's server-side access. For a Collection this is the
|
|
18
18
|
* zcap the server checks at request time: revoking it stops the server
|
|
19
|
-
* serving that reader ciphertext. Immediate and total. A
|
|
19
|
+
* serving that reader ciphertext. Immediate and total. A descriptor whose pull
|
|
20
20
|
* axis lives elsewhere (e.g. a DID document naming the readers) supplies a
|
|
21
21
|
* `pull` action instead of the default zcap revocation.
|
|
22
22
|
* - **read** -- possession of an epoch key. Rotating the epoch means resources
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import type { IKeyAgreementKey } from '@interop/data-integrity-core';
|
|
34
34
|
import type { Collection } from '../Collection.js';
|
|
35
35
|
import type { Space } from '../Space.js';
|
|
36
|
-
import type {
|
|
36
|
+
import type { EncryptionDescriptorStore } from './descriptorStore.js';
|
|
37
37
|
import type { CollectionEncryption, IDelegatedZcap } from '../types.js';
|
|
38
38
|
import type { RecipientPublicKey } from './epochCrypto.js';
|
|
39
39
|
export type { RecipientPublicKey } from './epochCrypto.js';
|
|
@@ -45,23 +45,24 @@ export interface OwnerKey {
|
|
|
45
45
|
keyAgreementKey: IKeyAgreementKey;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Initializes the first key epoch on a
|
|
49
|
-
* fresh epoch key, wraps it to each initial recipient, and writes
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
48
|
+
* Initializes the first key epoch on a descriptor that has no epochs yet: mints
|
|
49
|
+
* a fresh epoch key, wraps it to each initial recipient, and writes `epochs:
|
|
50
|
+
* [epoch]` / `currentEpoch` back with a compare-and-swap. After this, resources
|
|
51
|
+
* written by any recipient are encrypted under the epoch, and readers unwrap it
|
|
52
|
+
* with their own key-agreement key.
|
|
53
53
|
*
|
|
54
54
|
* On the `collection` host the collection must already be declared encrypted
|
|
55
|
-
* (its
|
|
56
|
-
* host starts absent (e.g. `
|
|
57
|
-
* not exist before the first init), the
|
|
58
|
-
* with a create-if-absent guard (`If-None-Match: *`), so
|
|
59
|
-
* inits cannot clobber one another.
|
|
55
|
+
* (its descriptor exists; this fills in the first epochs). On a store whose
|
|
56
|
+
* descriptor host starts absent (e.g. `resourceDescriptorStore`, whose roster
|
|
57
|
+
* resource does not exist before the first init), the descriptor itself is
|
|
58
|
+
* created from scratch with a create-if-absent guard (`If-None-Match: *`), so
|
|
59
|
+
* two racing first inits cannot clobber one another.
|
|
60
60
|
*
|
|
61
61
|
* @param options {object}
|
|
62
62
|
* @param [options.collection] {Collection} the (already encrypted) collection
|
|
63
|
-
* whose Description hosts the
|
|
64
|
-
*
|
|
63
|
+
* whose Description hosts the descriptor; exactly one of `collection` /
|
|
64
|
+
* `store`
|
|
65
|
+
* @param [options.store] {EncryptionDescriptorStore} an explicit descriptor store
|
|
65
66
|
* @param options.recipients {RecipientPublicKey[]} the initial readers' public
|
|
66
67
|
* key-agreement keys (each `id` is the reader's `kid`)
|
|
67
68
|
* @param [options.epoch] {{ epochId: string, secret: Uint8Array }} a
|
|
@@ -69,11 +70,11 @@ export interface OwnerKey {
|
|
|
69
70
|
* whose epoch key already exists (e.g. a per-user key being enrolled into
|
|
70
71
|
* its wrap-set roster). The `epochId` must be the key's did:key and `secret`
|
|
71
72
|
* its raw 32-byte private key, exactly what {@link mintEpoch} returns.
|
|
72
|
-
* @returns {Promise<CollectionEncryption>} the new
|
|
73
|
+
* @returns {Promise<CollectionEncryption>} the new descriptor
|
|
73
74
|
*/
|
|
74
75
|
export declare function initRecipients({ collection, store, recipients, epoch: premintedEpoch }: {
|
|
75
76
|
collection?: Collection;
|
|
76
|
-
store?:
|
|
77
|
+
store?: EncryptionDescriptorStore;
|
|
77
78
|
recipients: RecipientPublicKey[];
|
|
78
79
|
epoch?: {
|
|
79
80
|
epochId: string;
|
|
@@ -92,16 +93,16 @@ export declare function initRecipients({ collection, store, recipients, epoch: p
|
|
|
92
93
|
*
|
|
93
94
|
* @param options {object}
|
|
94
95
|
* @param [options.collection] {Collection} the collection whose Description
|
|
95
|
-
* hosts the
|
|
96
|
-
* @param [options.store] {
|
|
96
|
+
* hosts the descriptor; exactly one of `collection` / `store`
|
|
97
|
+
* @param [options.store] {EncryptionDescriptorStore} an explicit descriptor store
|
|
97
98
|
* @param options.recipient {RecipientPublicKey} the new reader's public KAK
|
|
98
99
|
* @param options.owner {OwnerKey} the caller's own key-agreement key, to
|
|
99
100
|
* unwrap each epoch key for re-wrapping to the new reader
|
|
100
|
-
* @returns {Promise<CollectionEncryption>} the new
|
|
101
|
+
* @returns {Promise<CollectionEncryption>} the new descriptor
|
|
101
102
|
*/
|
|
102
103
|
export declare function addRecipient({ collection, store, recipient, owner }: {
|
|
103
104
|
collection?: Collection;
|
|
104
|
-
store?:
|
|
105
|
+
store?: EncryptionDescriptorStore;
|
|
105
106
|
recipient: RecipientPublicKey;
|
|
106
107
|
owner: OwnerKey;
|
|
107
108
|
}): Promise<CollectionEncryption>;
|
|
@@ -137,8 +138,8 @@ export declare function addRecipient({ collection, store, recipient, owner }: {
|
|
|
137
138
|
*
|
|
138
139
|
* @param options {object}
|
|
139
140
|
* @param [options.collection] {Collection} the collection whose Description
|
|
140
|
-
* hosts the
|
|
141
|
-
* @param [options.store] {
|
|
141
|
+
* hosts the descriptor; exactly one of `collection` / `store`
|
|
142
|
+
* @param [options.store] {EncryptionDescriptorStore} an explicit descriptor store
|
|
142
143
|
* @param [options.space] {Space} the collection's Space, for the default
|
|
143
144
|
* pull axis (zcap revocation); required together with `revoke` unless a
|
|
144
145
|
* custom `pull` is supplied
|
|
@@ -158,15 +159,76 @@ export declare function addRecipient({ collection, store, recipient, owner }: {
|
|
|
158
159
|
* self-describing `did:key`. May resolve `null` to signal drop-this-kid:
|
|
159
160
|
* the rotation then excludes that entry from the fresh epoch instead of
|
|
160
161
|
* throwing (subject to the no-recipients-remaining guard).
|
|
161
|
-
* @returns {Promise<CollectionEncryption>} the new
|
|
162
|
+
* @returns {Promise<CollectionEncryption>} the new descriptor
|
|
162
163
|
*/
|
|
163
164
|
export declare function removeRecipient({ collection, store, space, recipientId, revoke, pull, resolveRecipientKey }: {
|
|
164
165
|
collection?: Collection;
|
|
165
|
-
store?:
|
|
166
|
+
store?: EncryptionDescriptorStore;
|
|
166
167
|
space?: Space;
|
|
167
168
|
recipientId: string;
|
|
168
169
|
revoke?: IDelegatedZcap | IDelegatedZcap[];
|
|
169
170
|
pull?: () => Promise<void>;
|
|
170
171
|
resolveRecipientKey?: (kid: string) => Promise<RecipientPublicKey | null>;
|
|
171
172
|
}): Promise<CollectionEncryption>;
|
|
173
|
+
/**
|
|
174
|
+
* Replaces one reader (or several) with another in ONE descriptor write -- the
|
|
175
|
+
* shape of a key rotation cascading over a collection (e.g. a per-user key
|
|
176
|
+
* replaced by its successor): the incoming recipient is escrowed into EVERY
|
|
177
|
+
* epoch (history included, {@link addRecipient}'s semantics) and the current
|
|
178
|
+
* epoch is rotated off the retiring recipient(s) ({@link removeRecipient}'s
|
|
179
|
+
* semantics), in a single compare-and-swap. Two requests total (the read and
|
|
180
|
+
* the CAS write) against the four a compose of addRecipient + removeRecipient
|
|
181
|
+
* would cost, and no intermediate state in which both keys are current.
|
|
182
|
+
*
|
|
183
|
+
* Idempotent to convergence like its two halves: an epoch already carrying the
|
|
184
|
+
* incoming recipient is left untouched; when additionally no retiring
|
|
185
|
+
* recipient remains in the current epoch, nothing is written at all -- a naive
|
|
186
|
+
* re-run after a crash appends zero redundant epochs. An escrow-only state
|
|
187
|
+
* (the incoming recipient missing from some epoch but no retiring recipient
|
|
188
|
+
* current) writes the escrow wraps without minting an epoch; the `epochsMac`
|
|
189
|
+
* is untouched then, since it binds the epoch configuration, not the
|
|
190
|
+
* recipient wraps.
|
|
191
|
+
*
|
|
192
|
+
* The pull-axis contract is {@link removeRecipient}'s verbatim: the default
|
|
193
|
+
* zcap revocation (`space` + `revoke`) or a caller-supplied `pull` action,
|
|
194
|
+
* run only after the rotation is durable. A caller whose pull axis has
|
|
195
|
+
* already run elsewhere (e.g. a DID-document edit under a current-key-set
|
|
196
|
+
* rule) passes a no-op `pull`.
|
|
197
|
+
*
|
|
198
|
+
* The rotation ceiling is unchanged: nothing is re-encrypted, so a retired
|
|
199
|
+
* key still opens every pre-rotation epoch it was a recipient of.
|
|
200
|
+
*
|
|
201
|
+
* @param options {object}
|
|
202
|
+
* @param [options.collection] {Collection} the collection whose Description
|
|
203
|
+
* hosts the descriptor; exactly one of `collection` / `store`
|
|
204
|
+
* @param [options.store] {EncryptionDescriptorStore} an explicit descriptor store
|
|
205
|
+
* @param [options.space] {Space} the default pull axis, with `revoke`
|
|
206
|
+
* @param options.retire {string | string[]} the retiring recipient kid(s),
|
|
207
|
+
* dropped from the fresh epoch's roster
|
|
208
|
+
* @param options.recipient {RecipientPublicKey} the incoming reader's public
|
|
209
|
+
* key-agreement key, escrowed into every epoch and wrapped into the fresh one
|
|
210
|
+
* @param options.owner {OwnerKey} the caller's own key-agreement key,
|
|
211
|
+
* unwrapping each epoch key for the escrow -- it must be a recipient of
|
|
212
|
+
* every epoch (a retiring key that was escrowed everywhere qualifies)
|
|
213
|
+
* @param [options.revoke] {IDelegatedZcap | IDelegatedZcap[]} the default
|
|
214
|
+
* pull axis, with `space`
|
|
215
|
+
* @param [options.pull] {function} a caller-supplied pull action; mutually
|
|
216
|
+
* exclusive with `space` / `revoke`
|
|
217
|
+
* @param [options.resolveRecipientKey] {function} resolves a remaining
|
|
218
|
+
* recipient's kid for the fresh epoch, `null` to drop it -- the
|
|
219
|
+
* {@link removeRecipient} contract (the incoming recipient never routes
|
|
220
|
+
* through it)
|
|
221
|
+
* @returns {Promise<CollectionEncryption>} the new descriptor
|
|
222
|
+
*/
|
|
223
|
+
export declare function replaceRecipient({ collection, store, space, retire, recipient, owner, revoke, pull, resolveRecipientKey }: {
|
|
224
|
+
collection?: Collection;
|
|
225
|
+
store?: EncryptionDescriptorStore;
|
|
226
|
+
space?: Space;
|
|
227
|
+
retire: string | string[];
|
|
228
|
+
recipient: RecipientPublicKey;
|
|
229
|
+
owner: OwnerKey;
|
|
230
|
+
revoke?: IDelegatedZcap | IDelegatedZcap[];
|
|
231
|
+
pull?: () => Promise<void>;
|
|
232
|
+
resolveRecipientKey?: (kid: string) => Promise<RecipientPublicKey | null>;
|
|
233
|
+
}): Promise<CollectionEncryption>;
|
|
172
234
|
//# sourceMappingURL=recipients.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipients.d.ts","sourceRoot":"","sources":["../../src/edv/recipients.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"recipients.d.ts","sourceRoot":"","sources":["../../src/edv/recipients.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,KAAK,EACV,oBA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