@interop/was-client 0.22.0 → 0.23.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 +8 -7
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +7 -6
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts +31 -30
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +83 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/edv/docCipher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/edv/docCipher.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGhD,8EAA8E;AAC9E,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM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qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAC5C,MAAM,KAAK,GAAG,WAAW,EAAE,CAAA;YAC3B,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ;aACsB,CAAA;YAClD,OAAO,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAS,CAAA;YAE7C,SAAS,WAAW;gBAClB,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,QAAQ,CAAC,EAAE,CAAC;oBACvC,OAAO,WAAY,CAAA;gBACrB,CAAC;gBACD,IAAI,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;oBAC5D,OAAO,UAAU,CAAA;gBACnB,CAAC;gBACD,yEAAyE;gBACzE,wEAAwE;gBACxE,kCAAkC;gBAClC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACtB,OAAO,WAAY,CAAA;gBACrB,CAAC;gBACD,MAAM,IAAI,iBAAiB,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -16,8 +16,8 @@ export interface RecipientPublicKey {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Wraps a 32-byte epoch secret to one recipient's X25519 key-agreement key,
|
|
19
|
-
* producing the JWE `recipients` entry stored on the
|
|
20
|
-
* ephemeral key per call (ECDH-ES), so each wrap carries its own `epk`.
|
|
19
|
+
* producing the JWE `recipients` entry stored on the descriptor. Generates a
|
|
20
|
+
* fresh ephemeral key per call (ECDH-ES), so each wrap carries its own `epk`.
|
|
21
21
|
*
|
|
22
22
|
* @param options {object}
|
|
23
23
|
* @param options.epochSecret {Uint8Array} the 32-byte epoch key to wrap
|
|
@@ -29,14 +29,14 @@ export declare function wrapEpochSecret({ epochSecret, recipient }: {
|
|
|
29
29
|
recipient: RecipientPublicKey;
|
|
30
30
|
}): Promise<CollectionEncryptionRecipient>;
|
|
31
31
|
/**
|
|
32
|
-
* Unwraps an epoch secret from a
|
|
33
|
-
* own key-agreement key. Returns `null` when this key does not match
|
|
34
|
-
* (the wrong recipient, or a corrupt entry) -- never treat `null` as
|
|
35
|
-
* the next candidate entry or epoch, and fail with a typed error
|
|
36
|
-
* unwraps.
|
|
32
|
+
* Unwraps an epoch secret from a descriptor `recipients` entry using the
|
|
33
|
+
* reader's own key-agreement key. Returns `null` when this key does not match
|
|
34
|
+
* the entry (the wrong recipient, or a corrupt entry) -- never treat `null` as
|
|
35
|
+
* a key; try the next candidate entry or epoch, and fail with a typed error
|
|
36
|
+
* when nothing unwraps.
|
|
37
37
|
*
|
|
38
38
|
* @param options {object}
|
|
39
|
-
* @param options.entry {CollectionEncryptionRecipient} the
|
|
39
|
+
* @param options.entry {CollectionEncryptionRecipient} the descriptor entry
|
|
40
40
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK
|
|
41
41
|
* (its `id` must equal `entry.header.kid` for the derivation to match)
|
|
42
42
|
* @returns {Promise<Uint8Array | null>}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochCrypto.d.ts","sourceRoot":"","sources":["../../src/edv/epochCrypto.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,YAAY,mBAAmB,CAAA;AAS5C;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,kBAAkB,EAAE,MAAM,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;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SAAS,EACV,EAAE;IACD,WAAW,EAAE,UAAU,CAAA;IACvB,SAAS,EAAE,kBAAkB,CAAA;CAC9B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA4BzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,eAAe,EAChB,EAAE;IACD,KAAK,EAAE,6BAA6B,CAAA;IACpC,eAAe,EAAE,gBAAgB,CAAA;CAClC,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAuC7B;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,UAAU,CAAA;CACnB,CAAC,CAQD;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,MAAM,EACP,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,gBAAgB,CASnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AA8BD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EACnC,EAAE,EACH,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BpE"}
|
package/dist/edv/epochCrypto.js
CHANGED
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
* The epoch key itself is shared with a reader by wrapping the 32-byte epoch
|
|
19
19
|
* secret to the reader's own X25519 key-agreement key, `ECDH-ES+A256KW`, and
|
|
20
20
|
* storing the result as a JWE `recipients` entry verbatim on the Collection's
|
|
21
|
-
* `encryption`
|
|
22
|
-
* ECDH against the reader's public key, the RFC 7518 Concat KDF, then
|
|
23
|
-
* `@interop/minimal-cipher`'s own `ECDH-ES+A256KW` building blocks
|
|
24
|
-
* `algorithms` subpath), so the wrapped bytes are interchangeable with
|
|
25
|
-
* `Cipher` would produce.
|
|
21
|
+
* `encryption` descriptor. The wrap is derive-then-wrap per recipient: an
|
|
22
|
+
* ephemeral ECDH against the reader's public key, the RFC 7518 Concat KDF, then
|
|
23
|
+
* A256KW -- `@interop/minimal-cipher`'s own `ECDH-ES+A256KW` building blocks
|
|
24
|
+
* (via its `algorithms` subpath), so the wrapped bytes are interchangeable with
|
|
25
|
+
* what its `Cipher` would produce.
|
|
26
26
|
*
|
|
27
27
|
* The two axes stay separate here: this module governs **read** (who can
|
|
28
28
|
* decrypt), which is prospective -- rotating the epoch only protects resources
|
|
@@ -44,8 +44,8 @@ const X25519_TYPE = 'X25519KeyAgreementKey2020';
|
|
|
44
44
|
const TEXT_ENCODER = new TextEncoder();
|
|
45
45
|
/**
|
|
46
46
|
* Wraps a 32-byte epoch secret to one recipient's X25519 key-agreement key,
|
|
47
|
-
* producing the JWE `recipients` entry stored on the
|
|
48
|
-
* ephemeral key per call (ECDH-ES), so each wrap carries its own `epk`.
|
|
47
|
+
* producing the JWE `recipients` entry stored on the descriptor. Generates a
|
|
48
|
+
* fresh ephemeral key per call (ECDH-ES), so each wrap carries its own `epk`.
|
|
49
49
|
*
|
|
50
50
|
* @param options {object}
|
|
51
51
|
* @param options.epochSecret {Uint8Array} the 32-byte epoch key to wrap
|
|
@@ -79,14 +79,14 @@ export async function wrapEpochSecret({ epochSecret, recipient }) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Unwraps an epoch secret from a
|
|
83
|
-
* own key-agreement key. Returns `null` when this key does not match
|
|
84
|
-
* (the wrong recipient, or a corrupt entry) -- never treat `null` as
|
|
85
|
-
* the next candidate entry or epoch, and fail with a typed error
|
|
86
|
-
* unwraps.
|
|
82
|
+
* Unwraps an epoch secret from a descriptor `recipients` entry using the
|
|
83
|
+
* reader's own key-agreement key. Returns `null` when this key does not match
|
|
84
|
+
* the entry (the wrong recipient, or a corrupt entry) -- never treat `null` as
|
|
85
|
+
* a key; try the next candidate entry or epoch, and fail with a typed error
|
|
86
|
+
* when nothing unwraps.
|
|
87
87
|
*
|
|
88
88
|
* @param options {object}
|
|
89
|
-
* @param options.entry {CollectionEncryptionRecipient} the
|
|
89
|
+
* @param options.entry {CollectionEncryptionRecipient} the descriptor entry
|
|
90
90
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK
|
|
91
91
|
* (its `id` must equal `entry.header.kid` for the derivation to match)
|
|
92
92
|
* @returns {Promise<Uint8Array | null>}
|
|
@@ -181,7 +181,8 @@ export function epochKeyIdFor(epochId) {
|
|
|
181
181
|
return `${epochId}#${publicKeyMultibaseFromEpochId(epochId)}`;
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
|
-
* Extracts the `publicKeyMultibase` fingerprint from an epoch id
|
|
184
|
+
* Extracts the `publicKeyMultibase` fingerprint from an epoch id
|
|
185
|
+
* (`did:key:z...`).
|
|
185
186
|
*
|
|
186
187
|
* @param epochId {string}
|
|
187
188
|
* @returns {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochCrypto.js","sourceRoot":"","sources":["../../src/edv/epochCrypto.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EACL,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,4BAA4B,EAC7B,MAAM,mCAAmC,CAAA;AAI1C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,GAAG,2BAA2B,CAAA;AAE/C,MAAM,YAAY,GAA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epoch keys from a Collection's `encryption`
|
|
6
|
-
* Given the
|
|
7
|
-
* key-agreement key, it reconstructs each epoch the reader is a
|
|
8
|
-
* an X25519 key pair the EDV `documentCipher` can use -- the
|
|
9
|
-
* for writes, and one read key per epoch the reader holds (so
|
|
10
|
-
* under an older epoch stays readable). The write epoch is
|
|
11
|
-
* the other epochs' keys unwrap lazily on first decrypt
|
|
12
|
-
* write-only handle does not pay to unwrap history it never
|
|
5
|
+
* Resolves a reader's per-epoch keys from a Collection's `encryption`
|
|
6
|
+
* descriptor. Given the descriptor (its `epochs` and `currentEpoch`) and the
|
|
7
|
+
* reader's own key-agreement key, it reconstructs each epoch the reader is a
|
|
8
|
+
* recipient of as an X25519 key pair the EDV `documentCipher` can use -- the
|
|
9
|
+
* write epoch's key for writes, and one read key per epoch the reader holds (so
|
|
10
|
+
* a resource written under an older epoch stays readable). The write epoch is
|
|
11
|
+
* unwrapped eagerly; the other epochs' keys unwrap lazily on first decrypt
|
|
12
|
+
* naming them, so a write-only handle does not pay to unwrap history it never
|
|
13
|
+
* reads.
|
|
13
14
|
*
|
|
14
15
|
* This is the read axis: holding an epoch key lets a reader decrypt resources
|
|
15
16
|
* written under it. A reader removed from a later epoch keeps the earlier epoch
|
|
@@ -23,7 +24,8 @@ import type { CollectionEncryption } from '../types.js';
|
|
|
23
24
|
*/
|
|
24
25
|
export interface ResolvedEpochKeys {
|
|
25
26
|
/**
|
|
26
|
-
* the epoch id writes encrypt under and stamp (the
|
|
27
|
+
* the epoch id writes encrypt under and stamp (the descriptor's
|
|
28
|
+
* `currentEpoch`)
|
|
27
29
|
*/
|
|
28
30
|
writeEpoch: string;
|
|
29
31
|
/**
|
|
@@ -38,14 +40,15 @@ export interface ResolvedEpochKeys {
|
|
|
38
40
|
readKeys: IKeyAgreementKey[];
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
|
-
* Resolves the reader's epoch keys from a
|
|
42
|
-
* declares no epochs (a single-key collection -- the caller keeps
|
|
43
|
-
* single-key path). Throws {@link KeyUnwrapError} when the
|
|
44
|
-
* this reader can unwrap none of them (it is not a
|
|
45
|
-
* collection is never silently read/written with
|
|
43
|
+
* Resolves the reader's epoch keys from a descriptor. Returns `null` when the
|
|
44
|
+
* descriptor declares no epochs (a single-key collection -- the caller keeps
|
|
45
|
+
* its existing single-key path). Throws {@link KeyUnwrapError} when the
|
|
46
|
+
* descriptor HAS epochs but this reader can unwrap none of them (it is not a
|
|
47
|
+
* recipient), so an encrypted collection is never silently read/written with
|
|
48
|
+
* the wrong key.
|
|
46
49
|
*
|
|
47
50
|
* @param options {object}
|
|
48
|
-
* @param options.encryption {CollectionEncryption} the Collection's
|
|
51
|
+
* @param options.encryption {CollectionEncryption} the Collection's descriptor
|
|
49
52
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK; its
|
|
50
53
|
* `id` must match a recipient `kid` in an epoch for that epoch to unwrap
|
|
51
54
|
* @returns {Promise<ResolvedEpochKeys | null>}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochKeys.d.ts","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"epochKeys.d.ts","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAEpE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,aAAa,CAAA;AAQpB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,UAAU,EACV,eAAe,EAChB,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,eAAe,EAAE,gBAAgB,CAAA;CAClC,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA+FpC"}
|
package/dist/edv/epochKeys.js
CHANGED
|
@@ -2,14 +2,15 @@ import { IntegrityError, KeyUnwrapError } from '../errors.js';
|
|
|
2
2
|
import { epochKeyIdFor, reconstructEpochKeyPair, unwrapEpochSecret } from './epochCrypto.js';
|
|
3
3
|
import { verifyEpochsMac } from './epochMac.js';
|
|
4
4
|
/**
|
|
5
|
-
* Resolves the reader's epoch keys from a
|
|
6
|
-
* declares no epochs (a single-key collection -- the caller keeps
|
|
7
|
-
* single-key path). Throws {@link KeyUnwrapError} when the
|
|
8
|
-
* this reader can unwrap none of them (it is not a
|
|
9
|
-
* collection is never silently read/written with
|
|
5
|
+
* Resolves the reader's epoch keys from a descriptor. Returns `null` when the
|
|
6
|
+
* descriptor declares no epochs (a single-key collection -- the caller keeps
|
|
7
|
+
* its existing single-key path). Throws {@link KeyUnwrapError} when the
|
|
8
|
+
* descriptor HAS epochs but this reader can unwrap none of them (it is not a
|
|
9
|
+
* recipient), so an encrypted collection is never silently read/written with
|
|
10
|
+
* the wrong key.
|
|
10
11
|
*
|
|
11
12
|
* @param options {object}
|
|
12
|
-
* @param options.encryption {CollectionEncryption} the Collection's
|
|
13
|
+
* @param options.encryption {CollectionEncryption} the Collection's descriptor
|
|
13
14
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK; its
|
|
14
15
|
* `id` must match a recipient `kid` in an epoch for that epoch to unwrap
|
|
15
16
|
* @returns {Promise<ResolvedEpochKeys | null>}
|
|
@@ -20,19 +21,19 @@ export async function resolveEpochKeys({ encryption, keyAgreementKey }) {
|
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
// The epochs this reader is named in (has a recipient entry keyed to its
|
|
23
|
-
// `kid`), in the
|
|
24
|
-
// whether a named entry actually unwraps is confirmed eagerly for
|
|
25
|
-
// epoch and lazily (on first decrypt) for the rest.
|
|
24
|
+
// `kid`), in the descriptor's canonical order. Being named IS being a
|
|
25
|
+
// recipient; whether a named entry actually unwraps is confirmed eagerly for
|
|
26
|
+
// the write epoch and lazily (on first decrypt) for the rest.
|
|
26
27
|
const namedEpochs = epochs.filter(epoch => epoch.recipients.some(recipient => recipient.header.kid === keyAgreementKey.id));
|
|
27
28
|
if (namedEpochs.length === 0) {
|
|
28
29
|
throw new KeyUnwrapError('This reader is not a recipient of any key epoch on this encrypted ' +
|
|
29
|
-
"collection (none of the
|
|
30
|
+
"collection (none of the descriptor's recipient entries name this " +
|
|
30
31
|
"reader's key-agreement key). Add this reader with addRecipient, or " +
|
|
31
32
|
'supply the correct key-agreement key.');
|
|
32
33
|
}
|
|
33
34
|
// Choose the write epoch: `currentEpoch` when this reader holds it, otherwise
|
|
34
35
|
// the newest epoch it holds -- defined deterministically as the LAST epoch in
|
|
35
|
-
// the
|
|
36
|
+
// the descriptor's canonical `epochs` order that names this reader, never the
|
|
36
37
|
// incidental order in which secrets happened to unwrap. A reader that is not a
|
|
37
38
|
// recipient of `currentEpoch` is a removed/archive reader whose writes the
|
|
38
39
|
// server rejects via its revoked zcap anyway; selecting a deterministic
|
|
@@ -56,12 +57,12 @@ export async function resolveEpochKeys({ encryption, keyAgreementKey }) {
|
|
|
56
57
|
'key.');
|
|
57
58
|
}
|
|
58
59
|
const writeKey = writeUnwrapped.key;
|
|
59
|
-
// Authenticate the epoch configuration when this reader holds the
|
|
60
|
-
// `currentEpoch` (its write epoch IS `currentEpoch`) and the
|
|
61
|
-
// MAC. A reader whose write epoch is an older held epoch
|
|
62
|
-
// (its secret is not the current epoch's), so it skips
|
|
63
|
-
// writes are rejected server-side via its revoked zcap
|
|
64
|
-
// is a legacy
|
|
60
|
+
// Authenticate the epoch configuration when this reader holds the
|
|
61
|
+
// descriptor's `currentEpoch` (its write epoch IS `currentEpoch`) and the
|
|
62
|
+
// descriptor carries a MAC. A reader whose write epoch is an older held epoch
|
|
63
|
+
// cannot key the MAC (its secret is not the current epoch's), so it skips
|
|
64
|
+
// verification -- its writes are rejected server-side via its revoked zcap
|
|
65
|
+
// anyway. An absent MAC is a legacy descriptor, accepted.
|
|
65
66
|
if (writeEpochEntry.id === encryption.currentEpoch &&
|
|
66
67
|
encryption.epochsMac !== undefined) {
|
|
67
68
|
const { v, alg } = encryption.epochsMac;
|
|
@@ -71,12 +72,12 @@ export async function resolveEpochKeys({ encryption, keyAgreementKey }) {
|
|
|
71
72
|
'server-side rollback or tamper.');
|
|
72
73
|
}
|
|
73
74
|
const authentic = await verifyEpochsMac({
|
|
74
|
-
|
|
75
|
+
descriptor: encryption,
|
|
75
76
|
epochSecret: writeUnwrapped.secret
|
|
76
77
|
});
|
|
77
78
|
if (!authentic) {
|
|
78
79
|
throw new IntegrityError('The epoch configuration failed to authenticate; a server-side ' +
|
|
79
|
-
'rollback or tamper of the encryption
|
|
80
|
+
'rollback or tamper of the encryption descriptor was detected (the ' +
|
|
80
81
|
'MAC over its epoch configuration does not verify).');
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochKeys.js","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"epochKeys.js","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAK7D,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAuB/C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,UAAU,EACV,eAAe,EAIhB;IACC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;IAChC,IAAI,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;gBACvB,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;oBACxB,OAAO,GAAG,SAAS,CAAA;gBACrB,CAAC;YACH,CAAC,CAAC,CAAA;YACF,OAAO,GAAG,OAAO,CAAA;QACnB,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;IACD,OAAO;QACL,EAAE,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,YAAY,CAAC,OAA+B;YAChD,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAA;YAC3B,OAAO,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/edv/epochMac.d.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import type { CollectionEncryption, CollectionEncryptionEpochsMac } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Computes the `epochsMac` field for a
|
|
4
|
-
* Compute this over the exact
|
|
5
|
-
* stamped), since a compare-and-swap retry re-reads the
|
|
3
|
+
* Computes the `epochsMac` field for a descriptor under the current epoch's
|
|
4
|
+
* secret. Compute this over the exact descriptor state being written (member
|
|
5
|
+
* fields already stamped), since a compare-and-swap retry re-reads the
|
|
6
|
+
* descriptor.
|
|
6
7
|
*
|
|
7
8
|
* @param options {object}
|
|
8
|
-
* @param options.
|
|
9
|
+
* @param options.descriptor {CollectionEncryption} the descriptor being written
|
|
9
10
|
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
10
11
|
* @returns {Promise<CollectionEncryptionEpochsMac>}
|
|
11
12
|
*/
|
|
12
|
-
export declare function computeEpochsMac({
|
|
13
|
-
|
|
13
|
+
export declare function computeEpochsMac({ descriptor, epochSecret }: {
|
|
14
|
+
descriptor: CollectionEncryption;
|
|
14
15
|
epochSecret: Uint8Array;
|
|
15
16
|
}): Promise<CollectionEncryptionEpochsMac>;
|
|
16
17
|
/**
|
|
17
|
-
* Verifies a
|
|
18
|
+
* Verifies a descriptor's `epochsMac` against a recomputation from the current
|
|
18
19
|
* epoch's secret. Returns `false` on any mismatch (or a malformed `mac`); the
|
|
19
20
|
* caller decides the error semantics. The MAC construction's own version/alg
|
|
20
21
|
* (`v` / `alg`) is validated by the caller before this is called.
|
|
21
22
|
*
|
|
22
23
|
* @param options {object}
|
|
23
|
-
* @param options.
|
|
24
|
+
* @param options.descriptor {CollectionEncryption} the descriptor to verify (its
|
|
24
25
|
* `epochsMac.mac` is the tag under test)
|
|
25
26
|
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
26
27
|
* @returns {Promise<boolean>}
|
|
27
28
|
*/
|
|
28
|
-
export declare function verifyEpochsMac({
|
|
29
|
-
|
|
29
|
+
export declare function verifyEpochsMac({ descriptor, epochSecret }: {
|
|
30
|
+
descriptor: CollectionEncryption;
|
|
30
31
|
epochSecret: Uint8Array;
|
|
31
32
|
}): Promise<boolean>;
|
|
32
33
|
//# sourceMappingURL=epochMac.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochMac.d.ts","sourceRoot":"","sources":["../../src/edv/epochMac.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,aAAa,CAAA;AAwEpB
|
|
1
|
+
{"version":3,"file":"epochMac.d.ts","sourceRoot":"","sources":["../../src/edv/epochMac.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,aAAa,CAAA;AAwEpB;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,UAAU,EACV,WAAW,EACZ,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,WAAW,EAAE,UAAU,CAAA;CACxB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAYzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,WAAW,EACZ,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,WAAW,EAAE,UAAU,CAAA;CACxB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBnB"}
|
package/dist/edv/epochMac.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Authenticated epoch configuration for multi-recipient encrypted Collections:
|
|
6
|
-
* a MAC over a Collection `encryption`
|
|
7
|
-
* the current epoch's secret (which the server never holds). It lets a
|
|
8
|
-
* detect a server-side rollback of `currentEpoch` or a fabricated epoch
|
|
9
|
-
* a malicious server cannot forge a valid MAC without the epoch secret.
|
|
6
|
+
* a MAC over a Collection `encryption` descriptor's epoch configuration, keyed
|
|
7
|
+
* from the current epoch's secret (which the server never holds). It lets a
|
|
8
|
+
* reader detect a server-side rollback of `currentEpoch` or a fabricated epoch
|
|
9
|
+
* list -- a malicious server cannot forge a valid MAC without the epoch secret.
|
|
10
10
|
*
|
|
11
11
|
* The MAC covers only `scheme`, `version`, `currentEpoch`, and the ordered list
|
|
12
12
|
* of epoch ids -- deliberately NOT the recipient entries, so adding a recipient
|
|
13
13
|
* (which cannot be forged without the epoch secret anyway) does not invalidate
|
|
14
|
-
* the MAC. Covering `version` makes stripping the
|
|
14
|
+
* the MAC. Covering `version` makes stripping the descriptor's scheme version
|
|
15
15
|
* MAC-detectable.
|
|
16
16
|
*
|
|
17
17
|
* Documented limitation (mirrors Cryptomator's versionMac): a server can still
|
|
@@ -48,39 +48,40 @@ async function deriveMacKey(epochSecret) {
|
|
|
48
48
|
}, ikm, { name: 'HMAC', hash: 'SHA-256', length: 256 }, false, ['sign', 'verify']);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Builds the MACed payload bytes for a
|
|
51
|
+
* Builds the MACed payload bytes for a descriptor's epoch configuration:
|
|
52
52
|
* `UTF8("was-epoch-config/v1." + JSON.stringify({ scheme, version,
|
|
53
53
|
* currentEpoch, epochs }))`, with `version` normalized to `null` when absent
|
|
54
54
|
* and `epochs` the ordered list of epoch id strings. The object member order is
|
|
55
55
|
* fixed so both sides serialize identically.
|
|
56
56
|
*
|
|
57
|
-
* @param
|
|
57
|
+
* @param descriptor {CollectionEncryption} the descriptor whose epoch configuration is
|
|
58
58
|
* being authenticated
|
|
59
59
|
* @returns {Uint8Array}
|
|
60
60
|
*/
|
|
61
|
-
function macPayload(
|
|
61
|
+
function macPayload(descriptor) {
|
|
62
62
|
const payload = {
|
|
63
|
-
scheme:
|
|
64
|
-
version:
|
|
65
|
-
currentEpoch:
|
|
66
|
-
epochs: (
|
|
63
|
+
scheme: descriptor.scheme,
|
|
64
|
+
version: descriptor.version ?? null,
|
|
65
|
+
currentEpoch: descriptor.currentEpoch,
|
|
66
|
+
epochs: (descriptor.epochs ?? []).map(epoch => epoch.id)
|
|
67
67
|
};
|
|
68
68
|
const bytes = TEXT_ENCODER.encode(MAC_PAYLOAD_PREFIX + JSON.stringify(payload));
|
|
69
69
|
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Computes the `epochsMac` field for a
|
|
73
|
-
* Compute this over the exact
|
|
74
|
-
* stamped), since a compare-and-swap retry re-reads the
|
|
72
|
+
* Computes the `epochsMac` field for a descriptor under the current epoch's
|
|
73
|
+
* secret. Compute this over the exact descriptor state being written (member
|
|
74
|
+
* fields already stamped), since a compare-and-swap retry re-reads the
|
|
75
|
+
* descriptor.
|
|
75
76
|
*
|
|
76
77
|
* @param options {object}
|
|
77
|
-
* @param options.
|
|
78
|
+
* @param options.descriptor {CollectionEncryption} the descriptor being written
|
|
78
79
|
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
79
80
|
* @returns {Promise<CollectionEncryptionEpochsMac>}
|
|
80
81
|
*/
|
|
81
|
-
export async function computeEpochsMac({
|
|
82
|
+
export async function computeEpochsMac({ descriptor, epochSecret }) {
|
|
82
83
|
const key = await deriveMacKey(epochSecret);
|
|
83
|
-
const signature = await crypto.subtle.sign('HMAC', key, macPayload(
|
|
84
|
+
const signature = await crypto.subtle.sign('HMAC', key, macPayload(descriptor));
|
|
84
85
|
return {
|
|
85
86
|
v: 1,
|
|
86
87
|
alg: 'HS256',
|
|
@@ -88,19 +89,19 @@ export async function computeEpochsMac({ marker, epochSecret }) {
|
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
|
-
* Verifies a
|
|
92
|
+
* Verifies a descriptor's `epochsMac` against a recomputation from the current
|
|
92
93
|
* epoch's secret. Returns `false` on any mismatch (or a malformed `mac`); the
|
|
93
94
|
* caller decides the error semantics. The MAC construction's own version/alg
|
|
94
95
|
* (`v` / `alg`) is validated by the caller before this is called.
|
|
95
96
|
*
|
|
96
97
|
* @param options {object}
|
|
97
|
-
* @param options.
|
|
98
|
+
* @param options.descriptor {CollectionEncryption} the descriptor to verify (its
|
|
98
99
|
* `epochsMac.mac` is the tag under test)
|
|
99
100
|
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
100
101
|
* @returns {Promise<boolean>}
|
|
101
102
|
*/
|
|
102
|
-
export async function verifyEpochsMac({
|
|
103
|
-
const epochsMac =
|
|
103
|
+
export async function verifyEpochsMac({ descriptor, epochSecret }) {
|
|
104
|
+
const epochsMac = descriptor.epochsMac;
|
|
104
105
|
if (!epochsMac) {
|
|
105
106
|
return false;
|
|
106
107
|
}
|
|
@@ -112,6 +113,6 @@ export async function verifyEpochsMac({ marker, epochSecret }) {
|
|
|
112
113
|
return false;
|
|
113
114
|
}
|
|
114
115
|
const key = await deriveMacKey(epochSecret);
|
|
115
|
-
return crypto.subtle.verify('HMAC', key, mac, macPayload(
|
|
116
|
+
return crypto.subtle.verify('HMAC', key, mac, macPayload(descriptor));
|
|
116
117
|
}
|
|
117
118
|
//# sourceMappingURL=epochMac.js.map
|
package/dist/edv/epochMac.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochMac.js","sourceRoot":"","sources":["../../src/edv/epochMac.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAM5C,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAA;AAEtC;;GAEG;AACH,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAA;AAEnE;;GAEG;AACH,MAAM,kBAAkB,GAAG,sBAAsB,CAAA;AAEjD;;;;;;;;GAQG;AACH,KAAK,UAAU,YAAY,CAAC,WAAuB;IACjD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,WAAqC,EACrC,MAAM,EACN,KAAK,EACL,CAAC,WAAW,CAAC,CACd,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAC5B;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC;QACvB,IAAI,EAAE,YAAY;KACnB,EACD,GAAG,EACH,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAC9C,KAAK,EACL,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAA;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"epochMac.js","sourceRoot":"","sources":["../../src/edv/epochMac.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAM5C,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAA;AAEtC;;GAEG;AACH,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,yBAAyB,CAA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gBAAgB,CAAC,EACrC,UAAU,EACV,WAAW,EAIZ;IACC,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,CAAA;IAC3C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CACxC,MAAM,EACN,GAAG,EACH,UAAU,CAAC,UAAU,CAAC,CACvB,CAAA;IACD,OAAO;QACL,CAAC,EAAE,CAAC;QACJ,GAAG,EAAE,OAAO;QACZ,GAAG,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;KACtD,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,UAAU,EACV,WAAW,EAIZ;IACC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;IACtC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,GAAe,CAAA;IACnB,IAAI,CAAC;QACH,GAAG,GAAG,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,CAAA;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CACzB,MAAM,EACN,GAAG,EACH,GAA6B,EAC7B,UAAU,CAAC,UAAU,CAAC,CACvB,CAAA;AACH,CAAC"}
|
package/dist/edv/index.d.ts
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* - `createEdvEncryption` -- the EDV keystore for the handle seam. Pass its
|
|
13
13
|
* result as `WasClient`'s `encryption` option; it supplies keys for the
|
|
14
|
-
* collections declared encrypted (by their `encryption`
|
|
15
|
-
* override), so `collection.put`/`get` transparently
|
|
14
|
+
* collections declared encrypted (by their `encryption` descriptor or a
|
|
15
|
+
* per-handle override), so `collection.put`/`get` transparently
|
|
16
|
+
* encrypt/decrypt.
|
|
16
17
|
* - `WasTransport` -- the standalone `@interop/edv-client`
|
|
17
18
|
* transport, for driving an `EdvClient` directly against WAS.
|
|
18
19
|
*
|
|
@@ -20,17 +21,17 @@
|
|
|
20
21
|
* `addRecipient` / `removeRecipient` manage the readers and rotate the epoch
|
|
21
22
|
* key, so the same `createEdvEncryption` provider transparently encrypts each
|
|
22
23
|
* write under the current epoch and decrypts any epoch a reader still holds.
|
|
23
|
-
* They mutate the
|
|
24
|
-
* Description by default, or any `
|
|
25
|
-
* for a
|
|
24
|
+
* They mutate the descriptor through the descriptor-store seam: the Collection
|
|
25
|
+
* Description by default, or any `EncryptionDescriptorStore` -- e.g.
|
|
26
|
+
* `resourceDescriptorStore` for a descriptor hosted as a plain JSON Resource.
|
|
26
27
|
*/
|
|
27
28
|
export { createEdvEncryption, EdvCodec } from './EdvCodec.js';
|
|
28
29
|
export type { EdvKeys } from './EdvCodec.js';
|
|
29
30
|
export { WasTransport, JOSE_CONTENT_TYPE } from './WasTransport.js';
|
|
30
31
|
export { initRecipients, addRecipient, removeRecipient } from './recipients.js';
|
|
31
32
|
export type { OwnerKey, RecipientPublicKey } from './recipients.js';
|
|
32
|
-
export {
|
|
33
|
-
export type {
|
|
33
|
+
export { collectionDescriptorStore, resourceDescriptorStore } from './descriptorStore.js';
|
|
34
|
+
export type { EncryptionDescriptorStore } from './descriptorStore.js';
|
|
34
35
|
export { mintEpoch, epochKeyIdFor, unwrapEpochSecret } from './epochCrypto.js';
|
|
35
36
|
export { verifyEpochsMac } from './epochMac.js';
|
|
36
37
|
export { createEdvDocCipher, ownerRecipient, UnknownEpochError, isEncryptedEnvelope } from './docCipher.js';
|
package/dist/edv/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7D,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC/E,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/edv/index.js
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* - `createEdvEncryption` -- the EDV keystore for the handle seam. Pass its
|
|
13
13
|
* result as `WasClient`'s `encryption` option; it supplies keys for the
|
|
14
|
-
* collections declared encrypted (by their `encryption`
|
|
15
|
-
* override), so `collection.put`/`get` transparently
|
|
14
|
+
* collections declared encrypted (by their `encryption` descriptor or a
|
|
15
|
+
* per-handle override), so `collection.put`/`get` transparently
|
|
16
|
+
* encrypt/decrypt.
|
|
16
17
|
* - `WasTransport` -- the standalone `@interop/edv-client`
|
|
17
18
|
* transport, for driving an `EdvClient` directly against WAS.
|
|
18
19
|
*
|
|
@@ -20,14 +21,14 @@
|
|
|
20
21
|
* `addRecipient` / `removeRecipient` manage the readers and rotate the epoch
|
|
21
22
|
* key, so the same `createEdvEncryption` provider transparently encrypts each
|
|
22
23
|
* write under the current epoch and decrypts any epoch a reader still holds.
|
|
23
|
-
* They mutate the
|
|
24
|
-
* Description by default, or any `
|
|
25
|
-
* for a
|
|
24
|
+
* They mutate the descriptor through the descriptor-store seam: the Collection
|
|
25
|
+
* Description by default, or any `EncryptionDescriptorStore` -- e.g.
|
|
26
|
+
* `resourceDescriptorStore` for a descriptor hosted as a plain JSON Resource.
|
|
26
27
|
*/
|
|
27
28
|
export { createEdvEncryption, EdvCodec } from './EdvCodec.js';
|
|
28
29
|
export { WasTransport, JOSE_CONTENT_TYPE } from './WasTransport.js';
|
|
29
30
|
export { initRecipients, addRecipient, removeRecipient } from './recipients.js';
|
|
30
|
-
export {
|
|
31
|
+
export { collectionDescriptorStore, resourceDescriptorStore } from './descriptorStore.js';
|
|
31
32
|
export { mintEpoch, epochKeyIdFor, unwrapEpochSecret } from './epochCrypto.js';
|
|
32
33
|
export { verifyEpochsMac } from './epochMac.js';
|
|
33
34
|
export { createEdvDocCipher, ownerRecipient, UnknownEpochError, isEncryptedEnvelope } from './docCipher.js';
|
package/dist/edv/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAE/E,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAA"}
|