@interop/was-client 0.98.0 → 0.99.1
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 +63 -42
- package/dist/Collection.d.ts +43 -15
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +127 -54
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +26 -11
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +26 -11
- package/dist/Resource.js.map +1 -1
- package/dist/WasClient.d.ts +23 -8
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +31 -15
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +6 -14
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts +2 -1
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +348 -105
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +76 -12
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +76 -11
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/cipher.d.ts +6 -3
- package/dist/edv/cipher.d.ts.map +1 -1
- package/dist/edv/cipher.js +6 -3
- package/dist/edv/cipher.js.map +1 -1
- package/dist/edv/core.d.ts +1 -1
- package/dist/edv/core.d.ts.map +1 -1
- package/dist/edv/core.js +1 -1
- package/dist/edv/core.js.map +1 -1
- package/dist/edv/docCipher.d.ts +4 -2
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +17 -12
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/epochCrypto.d.ts +12 -4
- package/dist/edv/epochCrypto.d.ts.map +1 -1
- package/dist/edv/epochCrypto.js +37 -10
- package/dist/edv/epochCrypto.js.map +1 -1
- package/dist/edv/epochKeys.d.ts +6 -2
- package/dist/edv/epochKeys.d.ts.map +1 -1
- package/dist/edv/epochKeys.js +25 -14
- package/dist/edv/epochKeys.js.map +1 -1
- package/dist/edv/hmacKey.d.ts +7 -1
- package/dist/edv/hmacKey.d.ts.map +1 -1
- package/dist/edv/hmacKey.js +9 -3
- package/dist/edv/hmacKey.js.map +1 -1
- package/dist/edv/index.d.ts +2 -1
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +1 -1
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +2 -0
- package/dist/edv/recipients.js.map +1 -1
- package/dist/edv/transportFactory.d.ts.map +1 -1
- package/dist/edv/transportFactory.js +3 -2
- package/dist/edv/transportFactory.js.map +1 -1
- package/dist/errors.d.ts +19 -10
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +22 -11
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codec.d.ts +51 -2
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +53 -21
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/indexSchema.d.ts +30 -0
- package/dist/internal/indexSchema.d.ts.map +1 -1
- package/dist/internal/indexSchema.js +40 -0
- package/dist/internal/indexSchema.js.map +1 -1
- package/dist/internal/memo.d.ts +13 -4
- package/dist/internal/memo.d.ts.map +1 -1
- package/dist/internal/memo.js +18 -7
- package/dist/internal/memo.js.map +1 -1
- package/dist/internal/meta.d.ts +9 -3
- package/dist/internal/meta.d.ts.map +1 -1
- package/dist/internal/meta.js +13 -7
- package/dist/internal/meta.js.map +1 -1
- package/dist/internal/pagination.d.ts +30 -15
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +31 -17
- package/dist/internal/pagination.js.map +1 -1
- package/dist/internal/paths.d.ts +11 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +13 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +9 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +31 -3
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/write.d.ts +10 -10
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +23 -30
- package/dist/internal/write.js.map +1 -1
- package/dist/sync/index.d.ts +4 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +4 -2
- package/dist/sync/index.js.map +1 -1
- package/package.json +7 -7
package/dist/edv/docCipher.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ import type { ChunkSource } from './EdvCodec.js';
|
|
|
58
58
|
import type { RecipientPublicKey } from './recipients.js';
|
|
59
59
|
export { isEncryptedEnvelope } from '../sync/envelope.js';
|
|
60
60
|
export type { DocCipher } from '../sync/types.js';
|
|
61
|
-
export { EncryptOnlyCipherError, KeyUnwrapError, UnknownEpochError } from '../errors.js';
|
|
61
|
+
export { EncryptOnlyCipherError, IntegrityError, KeyUnwrapError, UnknownEpochError } from '../errors.js';
|
|
62
62
|
/**
|
|
63
63
|
* A wallet's own key-agreement key as a `RecipientPublicKey` -- the "recipient
|
|
64
64
|
* zero" entry a caller passes to `initRecipients` when it first makes a
|
|
@@ -194,7 +194,9 @@ export interface EdvDocCipher extends DocCipher {
|
|
|
194
194
|
* The reader must be a recipient of every epoch on the descriptor (the owner is
|
|
195
195
|
* "recipient zero"). If it is a recipient of none, building the cipher
|
|
196
196
|
* throws {@link KeyUnwrapError}; this surfaces it with a clearer error rather
|
|
197
|
-
* than silently writing envelopes other recipients cannot read.
|
|
197
|
+
* than silently writing envelopes other recipients cannot read. An entry that
|
|
198
|
+
* names this reader but fails its key-wrap integrity check throws
|
|
199
|
+
* {@link IntegrityError} instead, and that propagates untouched.
|
|
198
200
|
*
|
|
199
201
|
* @param options {object}
|
|
200
202
|
* @param options.keyAgreementKey {IKeyAgreementKey}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.d.ts","sourceRoot":"","sources":["../../src/edv/docCipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAc,WAAW,EAAE,MAAM,aAAa,CAAA;AAU/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvD,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"docCipher.d.ts","sourceRoot":"","sources":["../../src/edv/docCipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAc,WAAW,EAAE,MAAM,aAAa,CAAA;AAU/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvD,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AASzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,iBAA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,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IACnC,UAAU,EAAE,oBAAoB,CAAA;IAChC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC5B,GAAG,OAAO,CAAC,YAAY,CAAC,CAuExB;AAkID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,YAAwB,EACxB,UAAU,EACX,EAAE;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IACnC,UAAU,EAAE,oBAAoB,CAAA;CACjC,GAAG,OAAO,CAAC,SAAS,CAAC,CAsBrB"}
|
package/dist/edv/docCipher.js
CHANGED
|
@@ -7,11 +7,12 @@ import { buildEdvCodec, encryptOnlyEdvCodec } from './EdvCodec.js';
|
|
|
7
7
|
// `isEncryptedEnvelope` and the `DocCipher` interface live in the crypto-free
|
|
8
8
|
// `../sync` module, and the decrypt-routing signals (`UnknownEpochError` for a
|
|
9
9
|
// stale descriptor, `KeyUnwrapError` for a reader that is not a recipient of
|
|
10
|
-
// the envelope's epoch
|
|
10
|
+
// the envelope's epoch, `IntegrityError` for a kid-matched entry or envelope
|
|
11
|
+
// that fails its integrity check) in the errors module; re-exported here so an
|
|
11
12
|
// encrypted-collection consumer that imports this subpath gets them without a
|
|
12
13
|
// second import.
|
|
13
14
|
export { isEncryptedEnvelope } from '../sync/envelope.js';
|
|
14
|
-
export { EncryptOnlyCipherError, KeyUnwrapError, UnknownEpochError } from '../errors.js';
|
|
15
|
+
export { EncryptOnlyCipherError, IntegrityError, KeyUnwrapError, UnknownEpochError } from '../errors.js';
|
|
15
16
|
/**
|
|
16
17
|
* A wallet's own key-agreement key as a `RecipientPublicKey` -- the "recipient
|
|
17
18
|
* zero" entry a caller passes to `initRecipients` when it first makes a
|
|
@@ -58,7 +59,9 @@ export function ownerRecipient({ keyAgreementKey }) {
|
|
|
58
59
|
* The reader must be a recipient of every epoch on the descriptor (the owner is
|
|
59
60
|
* "recipient zero"). If it is a recipient of none, building the cipher
|
|
60
61
|
* throws {@link KeyUnwrapError}; this surfaces it with a clearer error rather
|
|
61
|
-
* than silently writing envelopes other recipients cannot read.
|
|
62
|
+
* than silently writing envelopes other recipients cannot read. An entry that
|
|
63
|
+
* names this reader but fails its key-wrap integrity check throws
|
|
64
|
+
* {@link IntegrityError} instead, and that propagates untouched.
|
|
62
65
|
*
|
|
63
66
|
* @param options {object}
|
|
64
67
|
* @param options.keyAgreementKey {IKeyAgreementKey}
|
|
@@ -167,17 +170,19 @@ function docCipherOverCodec({ codec, collectionId }) {
|
|
|
167
170
|
// Parses the codec's `EncodedWrite` (id + envelope body bytes) to the stored
|
|
168
171
|
// `{ id, envelope, epoch? }` shape. Shared by the create and update paths.
|
|
169
172
|
const readEncoded = (write) => {
|
|
170
|
-
// A payload over the codec's single-document threshold
|
|
171
|
-
// multi-request plan (a document
|
|
172
|
-
//
|
|
173
|
-
//
|
|
173
|
+
// A payload over the codec's single-document threshold, or a write over
|
|
174
|
+
// a chunked prior envelope, answers with a multi-request plan (a document
|
|
175
|
+
// plus chunk resources on a live server, or the reaping of a prior
|
|
176
|
+
// document's chunks), which has no one envelope to hand a replica. This
|
|
177
|
+
// seam is envelope-in/envelope-out, so it refuses the write instead.
|
|
174
178
|
if (isChunkedWrite(write)) {
|
|
175
179
|
throw new ValidationError(`Cannot encrypt this value for collection "${collectionId}": the ` +
|
|
176
|
-
'
|
|
177
|
-
'
|
|
178
|
-
'
|
|
179
|
-
'
|
|
180
|
-
'a Collection handle, or
|
|
180
|
+
'write needs several server requests (a binary payload over the ' +
|
|
181
|
+
'single-document threshold is stored as a document plus chunk ' +
|
|
182
|
+
'resources, and a write over such a document reaps its chunks), ' +
|
|
183
|
+
'so it has no single envelope, which this local-replica cipher ' +
|
|
184
|
+
'does not support. Write it through a Collection handle, or keep ' +
|
|
185
|
+
'the value under the threshold.');
|
|
181
186
|
}
|
|
182
187
|
const encoded = write;
|
|
183
188
|
// Read `envelope` first and never touch `body` when it is there: the EDV
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/edv/docCipher.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAQlE,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/edv/docCipher.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAQlE,8E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AAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,EAClD,YAAY,EACZ,YAAY,GAAG,SAAS,EACxB,UAAU,EAKX;IACC,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC;QACtC,YAAY;QACZ,YAAY;QACZ,UAAU;KACX,CAAC,CAAA;IACF,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,kBAAkB,CAAC;QACpD,KAAK;QACL,YAAY;KACb,CAAC,CAAA;IACF,OAAO;QACL,OAAO;QACP,aAAa;QACb,KAAK,CAAC,OAAO;YACX,MAAM,IAAI,sBAAsB,CAC9B,4CAA4C,YAAY,YAAY;gBAClE,kEAAkE;gBAClE,mDAAmD;gBACnD,wDAAwD,CAC3D,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -48,10 +48,18 @@ export declare function wrapEpochSecretTo({ epochSecret, recipients }: {
|
|
|
48
48
|
}): Promise<CollectionEncryptionRecipient[]>;
|
|
49
49
|
/**
|
|
50
50
|
* Unwraps an epoch secret from a descriptor `recipients` entry using the
|
|
51
|
-
* reader's own key-agreement key. Returns `null` when
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
51
|
+
* reader's own key-agreement key. Returns `null` when the entry is not
|
|
52
|
+
* addressed to this key (its `kid` is another reader's id) or is malformed (no
|
|
53
|
+
* usable `epk`, a non-base64url `encrypted_key`, a failed ECDH) -- never treat
|
|
54
|
+
* `null` as a key; try the next candidate entry or epoch, and fail with a
|
|
55
|
+
* typed error when nothing unwraps.
|
|
56
|
+
*
|
|
57
|
+
* Throws {@link IntegrityError} when the entry names this reader and is
|
|
58
|
+
* well-formed but its AES-KW integrity check fails. That cannot mean "not my
|
|
59
|
+
* entry": the entry is addressed to this reader and its wrapped bytes do not
|
|
60
|
+
* authenticate under the key they were wrapped to. It is the key-wrap
|
|
61
|
+
* counterpart of a content envelope whose AEAD tag fails for a kid-matched
|
|
62
|
+
* key, and it is reported the same way rather than as a membership decision.
|
|
55
63
|
*
|
|
56
64
|
* @param options {object}
|
|
57
65
|
* @param options.entry {CollectionEncryptionRecipient} the descriptor entry
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"epochCrypto.d.ts","sourceRoot":"","sources":["../../src/edv/epochCrypto.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAGpE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAYhE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aAAa,CAAA;AAExC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,kBAAkB,EAAE,MAAM,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,EACpC,WAAW,EACX,SAAS,EACV,EAAE;IACD,WAAW,EAAE,UAAU,CAAA;IACvB,SAAS,EAAE,kBAAkB,CAAA;CAC9B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA4BzC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,WAAW,EACX,UAAU,EACX,EAAE;IACD,WAAW,EAAE,UAAU,CAAA;IACvB,UAAU,EAAE,kBAAkB,EAAE,CAAA;CACjC,GAAG,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAI3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;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,CA2D7B;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
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
import { base64urlnopad } from '@scure/base';
|
|
34
34
|
import { createKek, deriveKey } from '@interop/minimal-cipher/algorithms';
|
|
35
35
|
import { X25519KeyAgreementKey2020, multibaseDecode, multibaseEncode, MULTICODEC_X25519_PUB_HEADER } from '@interop/x25519-key-agreement-key';
|
|
36
|
+
import { IntegrityError } from '../errors.js';
|
|
36
37
|
import { ENCODER } from '../internal/content.js';
|
|
37
38
|
/**
|
|
38
39
|
* The JOSE key-management algorithm for every epoch/recipient wrap.
|
|
@@ -101,10 +102,18 @@ export async function wrapEpochSecretTo({ epochSecret, recipients }) {
|
|
|
101
102
|
}
|
|
102
103
|
/**
|
|
103
104
|
* Unwraps an epoch secret from a descriptor `recipients` entry using the
|
|
104
|
-
* reader's own key-agreement key. Returns `null` when
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* reader's own key-agreement key. Returns `null` when the entry is not
|
|
106
|
+
* addressed to this key (its `kid` is another reader's id) or is malformed (no
|
|
107
|
+
* usable `epk`, a non-base64url `encrypted_key`, a failed ECDH) -- never treat
|
|
108
|
+
* `null` as a key; try the next candidate entry or epoch, and fail with a
|
|
109
|
+
* typed error when nothing unwraps.
|
|
110
|
+
*
|
|
111
|
+
* Throws {@link IntegrityError} when the entry names this reader and is
|
|
112
|
+
* well-formed but its AES-KW integrity check fails. That cannot mean "not my
|
|
113
|
+
* entry": the entry is addressed to this reader and its wrapped bytes do not
|
|
114
|
+
* authenticate under the key they were wrapped to. It is the key-wrap
|
|
115
|
+
* counterpart of a content envelope whose AEAD tag fails for a kid-matched
|
|
116
|
+
* key, and it is reported the same way rather than as a membership decision.
|
|
108
117
|
*
|
|
109
118
|
* @param options {object}
|
|
110
119
|
* @param options.entry {CollectionEncryptionRecipient} the descriptor entry
|
|
@@ -113,6 +122,12 @@ export async function wrapEpochSecretTo({ epochSecret, recipients }) {
|
|
|
113
122
|
* @returns {Promise<Uint8Array | null>}
|
|
114
123
|
*/
|
|
115
124
|
export async function unwrapEpochSecret({ entry, keyAgreementKey }) {
|
|
125
|
+
if (entry.header.kid !== keyAgreementKey.id) {
|
|
126
|
+
// Another reader's entry: the KDF binds the wrap to the recipient's key
|
|
127
|
+
// id, so this key could never unwrap it, and a failure below would say
|
|
128
|
+
// nothing about the entry's integrity.
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
116
131
|
const epk = entry.header.epk;
|
|
117
132
|
if (!epk || typeof epk.x !== 'string') {
|
|
118
133
|
return null;
|
|
@@ -122,8 +137,8 @@ export async function unwrapEpochSecret({ entry, keyAgreementKey }) {
|
|
|
122
137
|
ephemeralPublicKey = base64urlnopad.decode(epk.x);
|
|
123
138
|
}
|
|
124
139
|
catch {
|
|
125
|
-
// A malformed (non-base64url) `epk.x` is the
|
|
126
|
-
//
|
|
140
|
+
// A malformed (non-base64url) `epk.x` is the malformed-entry class:
|
|
141
|
+
// honor the documented null contract.
|
|
127
142
|
return null;
|
|
128
143
|
}
|
|
129
144
|
let secret;
|
|
@@ -142,15 +157,27 @@ export async function unwrapEpochSecret({ entry, keyAgreementKey }) {
|
|
|
142
157
|
const consumerInfo = ENCODER.encode(keyAgreementKey.id);
|
|
143
158
|
const keyData = await deriveKey({ secret, producerInfo, consumerInfo });
|
|
144
159
|
const kek = await createKek({ keyData });
|
|
160
|
+
let unwrapped;
|
|
145
161
|
try {
|
|
146
|
-
|
|
162
|
+
unwrapped = await kek.unwrapKey({ wrappedKey: entry.encrypted_key });
|
|
147
163
|
}
|
|
148
164
|
catch {
|
|
149
|
-
// `unwrapKey`
|
|
150
|
-
// malformed
|
|
151
|
-
//
|
|
165
|
+
// `unwrapKey` throws on a malformed (non-base64url or wrong-length)
|
|
166
|
+
// `encrypted_key`: the malformed-entry class, so honor the documented
|
|
167
|
+
// null contract.
|
|
152
168
|
return null;
|
|
153
169
|
}
|
|
170
|
+
if (unwrapped === null) {
|
|
171
|
+
// `unwrapKey` returns null only when the bytes decoded and had a valid
|
|
172
|
+
// length but the AES-KW integrity check failed: the entry is addressed to
|
|
173
|
+
// this reader and does not authenticate under its key.
|
|
174
|
+
throw new IntegrityError(`This reader's recipient entry (kid "${entry.header.kid}") failed to ` +
|
|
175
|
+
'authenticate: its wrapped epoch key did not pass the AES-KW ' +
|
|
176
|
+
'integrity check. The entry names this reader, so this is not a ' +
|
|
177
|
+
'membership problem -- the stored entry is corrupt or has been ' +
|
|
178
|
+
'tampered with.');
|
|
179
|
+
}
|
|
180
|
+
return unwrapped;
|
|
154
181
|
}
|
|
155
182
|
/**
|
|
156
183
|
* Mints a fresh key epoch: a new random X25519 key pair whose `did:key` is the
|
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AAC,IAAI,GAAG,CAAC,CAAC,CAAA;IACtD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAA;IAC/D,CAAC;IACD,4EAA4E;IAC5E,wCAAwC;IACxC,MAAM,OAAO,GAAG,yBAAyB,CAAC,eAAe,CAAC;QACxD,WAAW,EAAE,QAAQ;KACtB,CAAC,CAAA;IACF,OAAO,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAA;IACpD,MAAM,QAAQ,GAAG;QACf,EAAE;QACF,IAAI,EAAE,WAAW;QACjB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;KAC/C,CAAA;IACD,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IAC/B,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/edv/epochKeys.d.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* a resource written under an older epoch stays readable). The write epoch is
|
|
11
11
|
* unwrapped eagerly; the other epochs' keys unwrap lazily on first decrypt
|
|
12
12
|
* naming them, so a write-only handle does not pay to unwrap history it never
|
|
13
|
-
* reads.
|
|
13
|
+
* reads. A lazy unwrap that fails its key-wrap check is remembered, so a run of
|
|
14
|
+
* resources under a damaged epoch pays for one unwrap, not one per resource.
|
|
14
15
|
*
|
|
15
16
|
* This is the read axis: holding an epoch key lets a reader decrypt resources
|
|
16
17
|
* written under it. A reader removed from a later epoch keeps the earlier epoch
|
|
@@ -55,7 +56,10 @@ export interface ResolvedEpochKeys {
|
|
|
55
56
|
* fail-closed before calling this). Throws {@link KeyUnwrapError} when the
|
|
56
57
|
* descriptor HAS epochs but this reader can unwrap none of them (it is not a
|
|
57
58
|
* recipient), so an encrypted collection is never silently read/written with
|
|
58
|
-
* the wrong key.
|
|
59
|
+
* the wrong key. Throws {@link IntegrityError} when the entry addressed to
|
|
60
|
+
* this reader fails its key-wrap integrity check: that is a tamper signal, not
|
|
61
|
+
* a membership decision, and it propagates untouched (eagerly for the write
|
|
62
|
+
* epoch, on first decrypt for a lazily-unwrapped read epoch).
|
|
59
63
|
*
|
|
60
64
|
* The write epoch is always the descriptor's current epoch, whether or not
|
|
61
65
|
* this reader is a recipient of it: a reader rotated off the current epoch
|
|
@@ -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;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAQpE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,aAAa,CAAA;AASpB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,EAAE,gBAAgB,CAAA;IAC1B;;;;;OAKG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAA;IAC5B;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,UAAU,EACV,eAAe,EACf,KAAmB,EACpB,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,eAAe,EAAE,gBAAgB,CAAA;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA0FpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,KAAK,EACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2B5B"}
|
package/dist/edv/epochKeys.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EncryptionError, EncryptOnlyCipherError, KeyUnwrapError } from '../errors.js';
|
|
1
|
+
import { EncryptionError, EncryptOnlyCipherError, IntegrityError, KeyUnwrapError } from '../errors.js';
|
|
2
2
|
import { Memo } from '../internal/memo.js';
|
|
3
3
|
import { didKeyResolver, epochKeyIdFor, reconstructEpochKeyPair, unwrapEpochSecret } from './epochCrypto.js';
|
|
4
4
|
import { currentEpochOf } from './epochRoster.js';
|
|
@@ -8,7 +8,10 @@ import { currentEpochOf } from './epochRoster.js';
|
|
|
8
8
|
* fail-closed before calling this). Throws {@link KeyUnwrapError} when the
|
|
9
9
|
* descriptor HAS epochs but this reader can unwrap none of them (it is not a
|
|
10
10
|
* recipient), so an encrypted collection is never silently read/written with
|
|
11
|
-
* the wrong key.
|
|
11
|
+
* the wrong key. Throws {@link IntegrityError} when the entry addressed to
|
|
12
|
+
* this reader fails its key-wrap integrity check: that is a tamper signal, not
|
|
13
|
+
* a membership decision, and it propagates untouched (eagerly for the write
|
|
14
|
+
* epoch, on first decrypt for a lazily-unwrapped read epoch).
|
|
12
15
|
*
|
|
13
16
|
* The write epoch is always the descriptor's current epoch, whether or not
|
|
14
17
|
* this reader is a recipient of it: a reader rotated off the current epoch
|
|
@@ -79,7 +82,7 @@ export async function resolveEpochKeys({ encryption, keyAgreementKey, label = '(
|
|
|
79
82
|
});
|
|
80
83
|
if (!writeKey) {
|
|
81
84
|
throw new KeyUnwrapError(`This reader's recipient entry for the write epoch ` +
|
|
82
|
-
`"${writeEpochEntry.id}" did not unwrap (a
|
|
85
|
+
`"${writeEpochEntry.id}" did not unwrap (a malformed entry). Re-add ` +
|
|
83
86
|
'this reader with addRecipient, or supply the correct key-agreement ' +
|
|
84
87
|
'key.');
|
|
85
88
|
}
|
|
@@ -146,8 +149,10 @@ export async function epochWriteStandIn({ epochId, label }) {
|
|
|
146
149
|
}
|
|
147
150
|
/**
|
|
148
151
|
* Unwraps and reconstructs a single epoch's key pair for this reader, or returns
|
|
149
|
-
* `null` when the reader is not a recipient of the epoch or its entry
|
|
150
|
-
*
|
|
152
|
+
* `null` when the reader is not a recipient of the epoch or its entry is
|
|
153
|
+
* malformed (never treat `null` as a key). An entry addressed to this reader
|
|
154
|
+
* that fails its key-wrap integrity check throws {@link IntegrityError} from
|
|
155
|
+
* `unwrapEpochSecret`, and that propagates.
|
|
151
156
|
*
|
|
152
157
|
* @param options {object}
|
|
153
158
|
* @param options.epoch {CollectionEncryptionEpoch} the epoch to unwrap
|
|
@@ -180,21 +185,27 @@ async function unwrapEpochKey({ epoch, keyAgreementKey }) {
|
|
|
180
185
|
* @returns {IKeyAgreementKey}
|
|
181
186
|
*/
|
|
182
187
|
function lazyEpochKey({ epoch, keyAgreementKey }) {
|
|
183
|
-
// The memo caches
|
|
184
|
-
// the next read re-attempts (the failure may
|
|
185
|
-
// than replaying the same cached rejection for
|
|
188
|
+
// The memo caches a successful unwrap, and one failure class. A rejected
|
|
189
|
+
// attempt is normally dropped so the next read re-attempts (the failure may
|
|
190
|
+
// have been transient) rather than replaying the same cached rejection for
|
|
191
|
+
// the life of the handle. A failed key-wrap check is the exception: the
|
|
192
|
+
// entry's bytes are part of the descriptor this handle was built from and do
|
|
193
|
+
// not change under it, so a second attempt could only fail the same way. The
|
|
194
|
+
// handle's codec memo deliberately does NOT retain the same failure when the
|
|
195
|
+
// eager write-epoch unwrap raises it at build time: a rebuild re-reads the
|
|
196
|
+
// descriptor, so a repaired entry (the owner re-added this reader) is
|
|
197
|
+
// observable there, where it never is here.
|
|
186
198
|
const memo = new Memo(async () => {
|
|
187
199
|
const key = await unwrapEpochKey({ epoch, keyAgreementKey });
|
|
188
200
|
if (!key) {
|
|
189
|
-
// The reader was named in this epoch (else no lazy key was built) but
|
|
190
|
-
// entry
|
|
191
|
-
//
|
|
192
|
-
// failure.
|
|
201
|
+
// The reader was named in this epoch (else no lazy key was built) but
|
|
202
|
+
// its entry is malformed. The codec's decrypt loop catches this and
|
|
203
|
+
// tries the next candidate before surfacing its own typed failure.
|
|
193
204
|
throw new KeyUnwrapError(`This reader's recipient entry for epoch "${epoch.id}" did not ` +
|
|
194
|
-
'unwrap (a
|
|
205
|
+
'unwrap (a malformed entry).');
|
|
195
206
|
}
|
|
196
207
|
return key;
|
|
197
|
-
});
|
|
208
|
+
}, { retain: err => err instanceof IntegrityError });
|
|
198
209
|
return {
|
|
199
210
|
id: epochKeyIdFor(epoch.id),
|
|
200
211
|
async deriveSecret(options) {
|
|
@@ -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":"AAqBA,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,cAAc,EACf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAK1C,OAAO,EACL,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAiCjD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,UAAU,EACV,eAAe,EACf,KAAK,GAAG,WAAW,EAKpB;IACC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;IAChC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,yEAAyE;IACzE,sEAAsE;IACtE,6EAA6E;I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AI,cAAc,CACtB,4CAA4C,KAAK,CAAC,EAAE,YAAY;gBAC9D,6BAA6B,CAChC,CAAA;QACH,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,EACD,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,cAAc,EAAE,CACjD,CAAA;IACD,OAAO;QACL,EAAE,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,YAAY,CAAC,OAA+B;YAChD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;YAC5B,OAAO,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/edv/hmacKey.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export declare function hmacKeyFromSecret({ id, secret }: {
|
|
|
90
90
|
*
|
|
91
91
|
* Fails closed when the descriptor DOES declare one, this key-agreement key
|
|
92
92
|
* unwraps no entry, and `required` is set: a current recipient must be able to
|
|
93
|
-
* blind, so a missing or
|
|
93
|
+
* blind, so a missing or malformed entry is an {@link EncryptionError} rather
|
|
94
94
|
* than a silent "unindexable" downgrade that would write envelopes nobody can
|
|
95
95
|
* find.
|
|
96
96
|
*
|
|
@@ -101,6 +101,12 @@ export declare function hmacKeyFromSecret({ id, secret }: {
|
|
|
101
101
|
* gets `null`, i.e. a cipher with no blinded index: it reads documents by id
|
|
102
102
|
* and cannot search.
|
|
103
103
|
*
|
|
104
|
+
* An entry that names this reader but fails its key-wrap integrity check is
|
|
105
|
+
* neither case. It throws `IntegrityError` from the unwrap whether or not
|
|
106
|
+
* `required` is set: a removal drops the entry outright, so a surviving entry
|
|
107
|
+
* addressed to this reader that does not authenticate is a tamper signal, and
|
|
108
|
+
* that outranks the rotated-off reader's history reads.
|
|
109
|
+
*
|
|
104
110
|
* @param options {object}
|
|
105
111
|
* @param options.encryption {EncryptionWithHmac} the Collection's descriptor
|
|
106
112
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK; its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmacKey.d.ts","sourceRoot":"","sources":["../../src/edv/hmacKey.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGrD;;GAEG;AACH,eAAO,MAAM,aAAa,sBAAsB,CAAA;AAEhD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACxD,MAAM,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,SAAS,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC/E;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC;IAC3C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,UAAU,CAAA;CACnB,CAAC,CAGD;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,EAAE,EACF,MAAM,EACP,EAAE;IACD,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,OAAO,CAAC,aAAa,CAAC,CAEzB;AAED
|
|
1
|
+
{"version":3,"file":"hmacKey.d.ts","sourceRoot":"","sources":["../../src/edv/hmacKey.ts"],"names":[],"mappings":"AAAA;;GAEG;AAC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/dist/edv/hmacKey.js
CHANGED
|
@@ -68,7 +68,7 @@ export async function hmacKeyFromSecret({ id, secret }) {
|
|
|
68
68
|
*
|
|
69
69
|
* Fails closed when the descriptor DOES declare one, this key-agreement key
|
|
70
70
|
* unwraps no entry, and `required` is set: a current recipient must be able to
|
|
71
|
-
* blind, so a missing or
|
|
71
|
+
* blind, so a missing or malformed entry is an {@link EncryptionError} rather
|
|
72
72
|
* than a silent "unindexable" downgrade that would write envelopes nobody can
|
|
73
73
|
* find.
|
|
74
74
|
*
|
|
@@ -79,6 +79,12 @@ export async function hmacKeyFromSecret({ id, secret }) {
|
|
|
79
79
|
* gets `null`, i.e. a cipher with no blinded index: it reads documents by id
|
|
80
80
|
* and cannot search.
|
|
81
81
|
*
|
|
82
|
+
* An entry that names this reader but fails its key-wrap integrity check is
|
|
83
|
+
* neither case. It throws `IntegrityError` from the unwrap whether or not
|
|
84
|
+
* `required` is set: a removal drops the entry outright, so a surviving entry
|
|
85
|
+
* addressed to this reader that does not authenticate is a tamper signal, and
|
|
86
|
+
* that outranks the rotated-off reader's history reads.
|
|
87
|
+
*
|
|
82
88
|
* @param options {object}
|
|
83
89
|
* @param options.encryption {EncryptionWithHmac} the Collection's descriptor
|
|
84
90
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK; its
|
|
@@ -104,8 +110,8 @@ export async function resolveHmacKey({ encryption, keyAgreementKey, required })
|
|
|
104
110
|
throw new EncryptionError('This collection declares a blinded-index key ' +
|
|
105
111
|
`("${hmac.id}") that this client's key-agreement key ` +
|
|
106
112
|
`("${keyAgreementKey.id}") cannot unwrap (no recipient entry names ` +
|
|
107
|
-
'it, or its entry is
|
|
108
|
-
'or supply the correct key-agreement key.');
|
|
113
|
+
'it, or its entry is malformed). Re-add this reader with ' +
|
|
114
|
+
'addRecipient, or supply the correct key-agreement key.');
|
|
109
115
|
}
|
|
110
116
|
return hmacKeyFromSecret({ id: hmac.id, secret });
|
|
111
117
|
}
|
package/dist/edv/hmacKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmacKey.js","sourceRoot":"","sources":["../../src/edv/hmacKey.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAA;AAkBhD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAK/B,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAA;IACzD,OAAO,EAAE,EAAE,EAAE,YAAY,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AAC/E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,EAAE,EACF,MAAM,EAIP;IACC,OAAO,aAAa,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;AACjD,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"hmacKey.js","sourceRoot":"","sources":["../../src/edv/hmacKey.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAA;AAkBhD;;;;;;;GAOG;AACH,M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H,CAAC;IACD,OAAO,iBAAiB,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/edv/index.d.ts
CHANGED
|
@@ -58,11 +58,12 @@
|
|
|
58
58
|
* re-reads the description, swaps itself, and retries exactly once per
|
|
59
59
|
* instance.
|
|
60
60
|
*/
|
|
61
|
-
export { EdvCodec, EDV_SCHEME_VERSION, JOSE_CONTENT_TYPE, ensureFirstEpoch, initRecipients, addRecipient, removeRecipient, replaceRecipient, trustRosterDidKeys, isEd25519DidKey, x25519RecipientFromDidKey, resourceDescriptorStore, EPOCH_CONFIGURATION_STATE_TYPE, logGovernedCollectionDescriptorStore, logGovernedDescriptorStore, readGovernedEpochConfiguration, toEpochConfigurationState, didKeyResolver, mintEpoch, epochKeyIdFor, unwrapEpochSecret, wrapEpochSecret, hasKeyEpochs, epochRostersEqual, currentEpochOf, resolveEpochKeys, HMAC_KEY_TYPE, mintHmacKey, hmacKeyFromSecret, resolveHmacKey, createEdvDocCipher, createEdvEncryptOnlyDocCipher, ownerRecipient, EncryptOnlyCipherError, KeyUnwrapError, UnknownEpochError, isEncryptedEnvelope, isKeyUnwrapError, edvIdFromBytes, blobBytes } from './core.js';
|
|
61
|
+
export { EdvCodec, EDV_SCHEME_VERSION, JOSE_CONTENT_TYPE, ensureFirstEpoch, initRecipients, addRecipient, removeRecipient, replaceRecipient, trustRosterDidKeys, isEd25519DidKey, x25519RecipientFromDidKey, resourceDescriptorStore, EPOCH_CONFIGURATION_STATE_TYPE, logGovernedCollectionDescriptorStore, logGovernedDescriptorStore, readGovernedEpochConfiguration, toEpochConfigurationState, didKeyResolver, mintEpoch, epochKeyIdFor, unwrapEpochSecret, wrapEpochSecret, hasKeyEpochs, epochRostersEqual, currentEpochOf, resolveEpochKeys, HMAC_KEY_TYPE, mintHmacKey, hmacKeyFromSecret, resolveHmacKey, createEdvDocCipher, createEdvEncryptOnlyDocCipher, ownerRecipient, EncryptOnlyCipherError, IntegrityError, KeyUnwrapError, UnknownEpochError, isEncryptedEnvelope, isIntegrityError, isKeyUnwrapError, edvIdFromBytes, blobBytes } from './core.js';
|
|
62
62
|
export type { ChunkSource, CodecTransportFactory, EdvKeys, RecipientPublicKey, EncryptionDescriptorStore, LogGovernedDescriptorStore, ResolvedEpochKeys, BlindingKey, DocCipher, EdvDocCipher } from './core.js';
|
|
63
63
|
export { createEdvEncryption } from './encryption.js';
|
|
64
64
|
export { wasTransportFactory } from './transportFactory.js';
|
|
65
65
|
export { WasTransport } from './WasTransport.js';
|
|
66
|
+
export type { ChunkListEntry, StoredDocument } from './WasTransport.js';
|
|
66
67
|
export { collectionDescriptorStore } from './descriptorStore.js';
|
|
67
68
|
export { acquireDescriptor, acquireDescriptors, wasDescriptorSource } from './acquire.js';
|
|
68
69
|
export { UnverifiedDescriptorError } from '../errors.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAKH,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAC9B,oCAAoC,EACpC,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,6BAA6B,EAC7B,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,WAAW,CAAA;AAClB,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,OAAO,EACP,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,YAAY,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAKH,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAC9B,oCAAoC,EACpC,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,6BAA6B,EAC7B,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,WAAW,CAAA;AAClB,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,OAAO,EACP,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,YAAY,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA"}
|
package/dist/edv/index.js
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
// This entry is the one every online consumer imports, so its surface is
|
|
63
63
|
// stated here: an export added to `core.ts` widens `./edv/core` only, and
|
|
64
64
|
// widening `./edv` takes an edit to this list.
|
|
65
|
-
export { EdvCodec, EDV_SCHEME_VERSION, JOSE_CONTENT_TYPE, ensureFirstEpoch, initRecipients, addRecipient, removeRecipient, replaceRecipient, trustRosterDidKeys, isEd25519DidKey, x25519RecipientFromDidKey, resourceDescriptorStore, EPOCH_CONFIGURATION_STATE_TYPE, logGovernedCollectionDescriptorStore, logGovernedDescriptorStore, readGovernedEpochConfiguration, toEpochConfigurationState, didKeyResolver, mintEpoch, epochKeyIdFor, unwrapEpochSecret, wrapEpochSecret, hasKeyEpochs, epochRostersEqual, currentEpochOf, resolveEpochKeys, HMAC_KEY_TYPE, mintHmacKey, hmacKeyFromSecret, resolveHmacKey, createEdvDocCipher, createEdvEncryptOnlyDocCipher, ownerRecipient, EncryptOnlyCipherError, KeyUnwrapError, UnknownEpochError, isEncryptedEnvelope, isKeyUnwrapError, edvIdFromBytes, blobBytes } from './core.js';
|
|
65
|
+
export { EdvCodec, EDV_SCHEME_VERSION, JOSE_CONTENT_TYPE, ensureFirstEpoch, initRecipients, addRecipient, removeRecipient, replaceRecipient, trustRosterDidKeys, isEd25519DidKey, x25519RecipientFromDidKey, resourceDescriptorStore, EPOCH_CONFIGURATION_STATE_TYPE, logGovernedCollectionDescriptorStore, logGovernedDescriptorStore, readGovernedEpochConfiguration, toEpochConfigurationState, didKeyResolver, mintEpoch, epochKeyIdFor, unwrapEpochSecret, wrapEpochSecret, hasKeyEpochs, epochRostersEqual, currentEpochOf, resolveEpochKeys, HMAC_KEY_TYPE, mintHmacKey, hmacKeyFromSecret, resolveHmacKey, createEdvDocCipher, createEdvEncryptOnlyDocCipher, ownerRecipient, EncryptOnlyCipherError, IntegrityError, KeyUnwrapError, UnknownEpochError, isEncryptedEnvelope, isIntegrityError, isKeyUnwrapError, edvIdFromBytes, blobBytes } from './core.js';
|
|
66
66
|
export { createEdvEncryption } from './encryption.js';
|
|
67
67
|
export { wasTransportFactory } from './transportFactory.js';
|
|
68
68
|
export { WasTransport } from './WasTransport.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,+CAA+C;AAC/C,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAC9B,oCAAoC,EACpC,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,6BAA6B,EAC7B,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,WAAW,CAAA;AAalB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,+CAA+C;AAC/C,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAC9B,oCAAoC,EACpC,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,6BAA6B,EAC7B,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,WAAW,CAAA;AAalB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAKxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipients.d.ts","sourceRoot":"","sources":["../../src/edv/recipients.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAA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AAmB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;CACzE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoBhC;AAgMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,UAAU,EACV,KAAK,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,IAAI,EACJ,mBAAmB,EACpB,EAAE;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,KAAK,CAAC,EAAE,yBAAyB,CAAA;IACjC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,SAAS,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAA;IACpD,KAAK,EAAE;QAAE,eAAe,EAAE,gBAAgB,CAAA;KAAE,CAAA;IAC5C,MAAM,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,CAAA;IAC1C,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,mBAAmB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;CACzE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA8BhC;AAkED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
|
package/dist/edv/recipients.js
CHANGED
|
@@ -60,6 +60,8 @@ async function escrowInto({ roster, recipients, owner, operation, subject }) {
|
|
|
60
60
|
throw new ValidationError(`Cannot ${operation}: the caller is not a recipient of ` +
|
|
61
61
|
`${subject.notRecipient} to the ${reader} reader.`);
|
|
62
62
|
}
|
|
63
|
+
// An `IntegrityError` here (the caller's own entry fails its key-wrap
|
|
64
|
+
// check) propagates: it is a tamper signal, not an authorization problem.
|
|
63
65
|
const epochSecret = await unwrapEpochSecret({
|
|
64
66
|
entry: ownEntry,
|
|
65
67
|
keyAgreementKey: owner.keyAgreementKey
|