@interop/was-client 0.16.0 → 0.18.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/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +6 -3
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +26 -2
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +47 -7
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +6 -0
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +26 -8
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +15 -2
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +61 -5
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +181 -11
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/epochKeys.d.ts.map +1 -1
- package/dist/edv/epochKeys.js +44 -14
- package/dist/edv/epochKeys.js.map +1 -1
- package/dist/edv/epochMac.d.ts +32 -0
- package/dist/edv/epochMac.d.ts.map +1 -0
- package/dist/edv/epochMac.js +117 -0
- package/dist/edv/epochMac.js.map +1 -0
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +26 -3
- package/dist/edv/recipients.js.map +1 -1
- package/dist/internal/pagination.d.ts +34 -19
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +9 -9
- package/dist/internal/pagination.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/edv/EdvCodec.js
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
* plaintext `name`/`tags`. A reader with the keys decrypts it back
|
|
53
53
|
* transparently via `meta()`.
|
|
54
54
|
*/
|
|
55
|
-
import { base64 } from '@scure/base';
|
|
55
|
+
import { base64, base64urlnopad } from '@scure/base';
|
|
56
56
|
import { EdvClientCore, assertDocId } from '@interop/edv-client';
|
|
57
57
|
import { EncryptionError, IntegrityError, KeyUnwrapError, ValidationError } from '../errors.js';
|
|
58
58
|
import { readEtag } from '../internal/conditional.js';
|
|
@@ -130,6 +130,18 @@ export class EdvCodec {
|
|
|
130
130
|
_contentType;
|
|
131
131
|
_maxBlobBytes;
|
|
132
132
|
_idDerivation;
|
|
133
|
+
/**
|
|
134
|
+
* The EDV-over-WAS scheme version this codec binds into every envelope's
|
|
135
|
+
* `was.v` protected-header parameter (the marker's `version`, `1` when
|
|
136
|
+
* absent). Read side rejects an envelope stamped with a greater version.
|
|
137
|
+
*/
|
|
138
|
+
_version;
|
|
139
|
+
/**
|
|
140
|
+
* Whether this codec's collection has key epochs. When it does, an envelope's
|
|
141
|
+
* `was.epoch` binding is checked on decode against the epoch of the key that
|
|
142
|
+
* actually decrypted it.
|
|
143
|
+
*/
|
|
144
|
+
_hasEpochs;
|
|
133
145
|
/**
|
|
134
146
|
* @param options {object}
|
|
135
147
|
* @param options.edv {EdvClientCore} holds the cipher + key resolver
|
|
@@ -150,8 +162,13 @@ export class EdvCodec {
|
|
|
150
162
|
* @param options.idDerivation {string} how `add()` mints a document
|
|
151
163
|
* id: `'random'` (classic `generateId()`) or `'content'` (derived from the
|
|
152
164
|
* JWE ciphertext, content-addressed)
|
|
165
|
+
* @param [options.version] {number} the EDV-over-WAS scheme version to bind
|
|
166
|
+
* into each envelope's `was.v` (defaults to `1`)
|
|
167
|
+
* @param [options.hasEpochs] {boolean} whether the collection has key
|
|
168
|
+
* epochs, so a decoded envelope's `was.epoch` binding is checked against the
|
|
169
|
+
* decrypting key's epoch (defaults to `false`)
|
|
153
170
|
*/
|
|
154
|
-
constructor({ edv, keyAgreementKey, readKeys, writeEpoch, contentType, maxBlobBytes, idDerivation }) {
|
|
171
|
+
constructor({ edv, keyAgreementKey, readKeys, writeEpoch, contentType, maxBlobBytes, idDerivation, version, hasEpochs }) {
|
|
155
172
|
this._edv = edv;
|
|
156
173
|
this._writeKey = keyAgreementKey;
|
|
157
174
|
this._recipients =
|
|
@@ -161,6 +178,8 @@ export class EdvCodec {
|
|
|
161
178
|
this._contentType = contentType;
|
|
162
179
|
this._maxBlobBytes = maxBlobBytes;
|
|
163
180
|
this._idDerivation = idDerivation;
|
|
181
|
+
this._version = version ?? 1;
|
|
182
|
+
this._hasEpochs = hasEpochs ?? false;
|
|
164
183
|
}
|
|
165
184
|
/**
|
|
166
185
|
* @inheritdoc
|
|
@@ -200,6 +219,21 @@ export class EdvCodec {
|
|
|
200
219
|
priorDoc = read;
|
|
201
220
|
}
|
|
202
221
|
const { documentCipher } = this._edv;
|
|
222
|
+
// Bind an AEAD-authenticated `was` parameter into the JWE protected header:
|
|
223
|
+
// the scheme version, the resource id when known at encrypt time (omitted
|
|
224
|
+
// for a content-derived id, which does not exist until after encryption),
|
|
225
|
+
// and the write epoch on a multi-recipient collection. A server that swaps
|
|
226
|
+
// two envelopes between ids (or replays one under a rolled-back epoch) is
|
|
227
|
+
// then detected on decrypt.
|
|
228
|
+
const was = {
|
|
229
|
+
v: this._version
|
|
230
|
+
};
|
|
231
|
+
if (docId !== undefined) {
|
|
232
|
+
was.resource = docId;
|
|
233
|
+
}
|
|
234
|
+
if (this._writeEpoch !== undefined) {
|
|
235
|
+
was.epoch = this._writeEpoch;
|
|
236
|
+
}
|
|
203
237
|
const encrypted = await documentCipher.encrypt({
|
|
204
238
|
doc: {
|
|
205
239
|
...(docId !== undefined && { id: docId }),
|
|
@@ -213,7 +247,8 @@ export class EdvCodec {
|
|
|
213
247
|
recipients: this._recipients,
|
|
214
248
|
keyResolver: this._edv.keyResolver,
|
|
215
249
|
hmac: undefined,
|
|
216
|
-
update: priorDoc !== null
|
|
250
|
+
update: priorDoc !== null,
|
|
251
|
+
additionalProtectedParams: { was }
|
|
217
252
|
});
|
|
218
253
|
if (docId === undefined) {
|
|
219
254
|
// Encrypt-then-stamp: the id lives in the cleartext envelope, outside the
|
|
@@ -251,10 +286,15 @@ export class EdvCodec {
|
|
|
251
286
|
/**
|
|
252
287
|
* @inheritdoc
|
|
253
288
|
*/
|
|
254
|
-
async decode(response) {
|
|
289
|
+
async decode(response, expectedId) {
|
|
255
290
|
const encryptedDoc = await readJsonData(response);
|
|
256
291
|
this._assertEnvelope(encryptedDoc, 'read');
|
|
257
292
|
const decrypted = await this._decrypt(encryptedDoc);
|
|
293
|
+
await this._verifyBinding({
|
|
294
|
+
jwe: encryptedDoc.jwe,
|
|
295
|
+
expectedId,
|
|
296
|
+
keyId: decrypted.keyId
|
|
297
|
+
});
|
|
258
298
|
return this._fromDocument(decrypted.content, decrypted.meta);
|
|
259
299
|
}
|
|
260
300
|
/**
|
|
@@ -269,8 +309,13 @@ export class EdvCodec {
|
|
|
269
309
|
* {@link KeyUnwrapError} -- the **read** axis only; it says nothing about
|
|
270
310
|
* whether the server will still serve (pull) the ciphertext.
|
|
271
311
|
*
|
|
312
|
+
* Also returns the `id` of the key that actually decrypted the envelope (its
|
|
313
|
+
* JWE recipient `kid`), so {@link _verifyBinding} can check a `was.epoch`
|
|
314
|
+
* binding against the epoch of the decrypting key.
|
|
315
|
+
*
|
|
272
316
|
* @param encryptedDoc {IEncryptedDocument}
|
|
273
|
-
* @returns {Promise<{ content?: unknown; meta?: Record<string, unknown
|
|
317
|
+
* @returns {Promise<{ content?: unknown; meta?: Record<string, unknown>;
|
|
318
|
+
* keyId?: string }>}
|
|
274
319
|
*/
|
|
275
320
|
async _decrypt(encryptedDoc) {
|
|
276
321
|
const recipients = encryptedDoc.jwe.recipients ?? [];
|
|
@@ -288,10 +333,11 @@ export class EdvCodec {
|
|
|
288
333
|
const rest = this._readKeys.filter(key => !kids.has(key.id));
|
|
289
334
|
for (const keyAgreementKey of [...preferred, ...rest]) {
|
|
290
335
|
try {
|
|
291
|
-
|
|
336
|
+
const decrypted = await this._edv.documentCipher.decrypt({
|
|
292
337
|
encryptedDoc,
|
|
293
338
|
keyAgreementKey
|
|
294
339
|
});
|
|
340
|
+
return { ...decrypted, keyId: keyAgreementKey.id };
|
|
295
341
|
}
|
|
296
342
|
catch (err) {
|
|
297
343
|
if (isKeyMiss(err)) {
|
|
@@ -318,6 +364,76 @@ export class EdvCodec {
|
|
|
318
364
|
'collection and the epoch was rotated). This is the read axis only -- ' +
|
|
319
365
|
'the server may still serve the ciphertext (a separate zcap decision).');
|
|
320
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Verifies the AEAD-authenticated `was` binding on a successfully-decrypted
|
|
369
|
+
* envelope (spec "Request Body Integrity"'s envelope half). Decrypt success
|
|
370
|
+
* proves the protected header authentic, so this runs only after a decrypt
|
|
371
|
+
* succeeds. Enforces, in order:
|
|
372
|
+
*
|
|
373
|
+
* - No `was` parameter at all: a legacy envelope, accepted unchanged (this
|
|
374
|
+
* client wrote it before the binding existed, or a foreign EDV writer did).
|
|
375
|
+
* - `was.v` greater than this codec's scheme version: a future-scheme envelope
|
|
376
|
+
* this client does not implement -- {@link EncryptionError}.
|
|
377
|
+
* - `was.resource` present and the expected id known: a mismatch is a server-side
|
|
378
|
+
* swap of two resources' envelopes -- {@link IntegrityError}.
|
|
379
|
+
* - `was` present but `resource` absent (a content-derived write) and the expected
|
|
380
|
+
* id known: the envelope's ciphertext must re-derive to the expected id
|
|
381
|
+
* ({@link EdvDocumentCipher.deriveId}); a mismatch means the envelope was
|
|
382
|
+
* copied under a different id -- {@link IntegrityError}. This check is NEVER
|
|
383
|
+
* applied to an envelope with no `was` at all (a legacy random-id envelope
|
|
384
|
+
* would fail it wrongly).
|
|
385
|
+
* - On a collection with epochs, `was.epoch` present: it must equal the epoch
|
|
386
|
+
* (the `did:key` before the `#`) of the key that actually decrypted -- a
|
|
387
|
+
* mismatch is a replay under a different epoch's key -- {@link IntegrityError}.
|
|
388
|
+
*
|
|
389
|
+
* @param options {object}
|
|
390
|
+
* @param options.jwe {unknown} the envelope's JWE (its `protected` header is
|
|
391
|
+
* parsed for `was`)
|
|
392
|
+
* @param [options.expectedId] {string} the resource id the read targeted
|
|
393
|
+
* @param [options.keyId] {string} the id of the key that decrypted, for the
|
|
394
|
+
* epoch check
|
|
395
|
+
* @returns {Promise<void>}
|
|
396
|
+
*/
|
|
397
|
+
async _verifyBinding({ jwe, expectedId, keyId }) {
|
|
398
|
+
const was = parseWasHeader(jwe);
|
|
399
|
+
if (was === undefined) {
|
|
400
|
+
// Legacy envelope (no `was`): accept unchanged for back-compat.
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (typeof was.v === 'number' && was.v > this._version) {
|
|
404
|
+
throw new EncryptionError(`Cannot decrypt this resource: its envelope is stamped with ` +
|
|
405
|
+
`EDV-over-WAS scheme version ${was.v}, which this client (version ` +
|
|
406
|
+
`${this._version}) does not implement. Upgrade the client.`);
|
|
407
|
+
}
|
|
408
|
+
if (typeof was.resource === 'string') {
|
|
409
|
+
if (expectedId !== undefined && was.resource !== expectedId) {
|
|
410
|
+
throw new IntegrityError(`Cannot decrypt this resource: the stored envelope is bound to a ` +
|
|
411
|
+
`different resource id ("${was.resource}") than the one requested ` +
|
|
412
|
+
`("${expectedId}"). The server swapped two resources' envelopes.`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else if (expectedId !== undefined) {
|
|
416
|
+
// Content-derived write (no `resource`): the id is a function of the
|
|
417
|
+
// ciphertext, so re-derive and compare.
|
|
418
|
+
const derived = await this._edv.documentCipher.deriveId({
|
|
419
|
+
jwe: jwe
|
|
420
|
+
});
|
|
421
|
+
if (derived !== expectedId) {
|
|
422
|
+
throw new IntegrityError(`Cannot decrypt this resource: its content-derived id ("${derived}") ` +
|
|
423
|
+
`does not match the requested id ("${expectedId}"). The server ` +
|
|
424
|
+
'served this envelope under an id it was not written for.');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (this._hasEpochs && typeof was.epoch === 'string' && keyId) {
|
|
428
|
+
const decryptedEpoch = keyId.split('#')[0];
|
|
429
|
+
if (decryptedEpoch !== was.epoch) {
|
|
430
|
+
throw new IntegrityError(`Cannot decrypt this resource: its envelope is bound to key epoch ` +
|
|
431
|
+
`"${was.epoch}" but was decrypted with a key from epoch ` +
|
|
432
|
+
`"${decryptedEpoch}". The server replayed it under a different ` +
|
|
433
|
+
'epoch.');
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
321
437
|
/**
|
|
322
438
|
* @inheritdoc
|
|
323
439
|
*
|
|
@@ -327,18 +443,28 @@ export class EdvCodec {
|
|
|
327
443
|
* inert (metadata concurrency is the server's plaintext `metaVersion`, not the
|
|
328
444
|
* envelope), so each write re-encrypts fresh with no `update`.
|
|
329
445
|
*/
|
|
330
|
-
async encodeMeta({ custom }) {
|
|
446
|
+
async encodeMeta({ custom, id: resourceId }) {
|
|
331
447
|
const { documentCipher } = this._edv;
|
|
332
448
|
// The document needs an EDV id (the cipher asserts one on decrypt). It is
|
|
333
449
|
// opaque to the server -- carried inside the un-decryptable envelope -- and
|
|
334
450
|
// minted fresh each write, since the metadata envelope is never updated in
|
|
335
451
|
// place (concurrency is the server's plaintext `metaVersion`, Decision 3).
|
|
336
452
|
const id = (await this._edv.generateId());
|
|
453
|
+
// Bind the `was` parameter to the RESOURCE id (not the metadata envelope's
|
|
454
|
+
// own random EDV id), so a server-side swap of two resources' metadata is
|
|
455
|
+
// AEAD-detected on decode. The metadata envelope always knows the resource
|
|
456
|
+
// id at encrypt time, so `resource` is always present here (never content-
|
|
457
|
+
// derived) and it carries no `epoch`.
|
|
458
|
+
const was = { v: this._version };
|
|
459
|
+
if (resourceId !== undefined) {
|
|
460
|
+
was.resource = resourceId;
|
|
461
|
+
}
|
|
337
462
|
const encrypted = await documentCipher.encrypt({
|
|
338
463
|
doc: { id, content: custom },
|
|
339
464
|
recipients: this._recipients,
|
|
340
465
|
keyResolver: this._edv.keyResolver,
|
|
341
|
-
hmac: undefined
|
|
466
|
+
hmac: undefined,
|
|
467
|
+
additionalProtectedParams: { was }
|
|
342
468
|
});
|
|
343
469
|
return { custom: encrypted };
|
|
344
470
|
}
|
|
@@ -350,12 +476,18 @@ export class EdvCodec {
|
|
|
350
476
|
* present value must be an EDV envelope (else {@link EncryptionError}, the
|
|
351
477
|
* `_assertEnvelope` guard), so a foreign plaintext `custom` fails closed.
|
|
352
478
|
*/
|
|
353
|
-
async decodeMeta({ custom }) {
|
|
479
|
+
async decodeMeta({ custom }, expectedId) {
|
|
354
480
|
if (custom === undefined || custom === null) {
|
|
355
481
|
return {};
|
|
356
482
|
}
|
|
357
483
|
this._assertEnvelope(custom, 'read');
|
|
358
|
-
const
|
|
484
|
+
const encryptedDoc = custom;
|
|
485
|
+
const decrypted = await this._decrypt(encryptedDoc);
|
|
486
|
+
await this._verifyBinding({
|
|
487
|
+
jwe: encryptedDoc.jwe,
|
|
488
|
+
expectedId,
|
|
489
|
+
keyId: decrypted.keyId
|
|
490
|
+
});
|
|
359
491
|
return (decrypted.content ?? {});
|
|
360
492
|
}
|
|
361
493
|
/**
|
|
@@ -522,6 +654,34 @@ function decodeUtf8(bytes) {
|
|
|
522
654
|
return null;
|
|
523
655
|
}
|
|
524
656
|
}
|
|
657
|
+
/**
|
|
658
|
+
* Parses the `was` binding out of a JWE's protected header. The header is
|
|
659
|
+
* base64url (no padding) JSON; a successful decrypt has already proven it
|
|
660
|
+
* authentic, so this parse is trusted. Returns the `was` object, or `undefined`
|
|
661
|
+
* when the header is absent/unparseable or carries no `was` member (a legacy
|
|
662
|
+
* envelope that predates the binding).
|
|
663
|
+
*
|
|
664
|
+
* @param jwe {unknown}
|
|
665
|
+
* @returns {Record<string, unknown> | undefined}
|
|
666
|
+
*/
|
|
667
|
+
function parseWasHeader(jwe) {
|
|
668
|
+
const protectedHeader = jwe?.protected;
|
|
669
|
+
if (typeof protectedHeader !== 'string') {
|
|
670
|
+
return undefined;
|
|
671
|
+
}
|
|
672
|
+
let parsed;
|
|
673
|
+
try {
|
|
674
|
+
parsed = JSON.parse(new TextDecoder().decode(base64urlnopad.decode(protectedHeader)));
|
|
675
|
+
}
|
|
676
|
+
catch {
|
|
677
|
+
return undefined;
|
|
678
|
+
}
|
|
679
|
+
const was = parsed?.was;
|
|
680
|
+
if (was === null || typeof was !== 'object') {
|
|
681
|
+
return undefined;
|
|
682
|
+
}
|
|
683
|
+
return was;
|
|
684
|
+
}
|
|
525
685
|
/**
|
|
526
686
|
* The EDV scheme tag this provider handles (matches the Collection marker).
|
|
527
687
|
*/
|
|
@@ -569,6 +729,14 @@ export function createEdvEncryption({ resolveKeys, contentType = DEFAULT_CONTENT
|
|
|
569
729
|
if (scheme !== EDV_SCHEME) {
|
|
570
730
|
return null;
|
|
571
731
|
}
|
|
732
|
+
// Refuse a marker from a future scheme version: this client does not
|
|
733
|
+
// implement it, and silently operating on it could mis-handle the data.
|
|
734
|
+
const markerVersion = encryption?.version;
|
|
735
|
+
if (typeof markerVersion === 'number' && markerVersion > 1) {
|
|
736
|
+
throw new EncryptionError(`Collection ${spaceId}/${collectionId} declares EDV-over-WAS scheme ` +
|
|
737
|
+
`version ${markerVersion}, which this client (version 1) does not ` +
|
|
738
|
+
'implement. Upgrade the client.');
|
|
739
|
+
}
|
|
572
740
|
// Prefer override-supplied keys; otherwise consult the keystore.
|
|
573
741
|
const resolved = keys ??
|
|
574
742
|
(await resolveKeys({ spaceId, collectionId }));
|
|
@@ -609,7 +777,9 @@ export function createEdvEncryption({ resolveKeys, contentType = DEFAULT_CONTENT
|
|
|
609
777
|
writeEpoch,
|
|
610
778
|
contentType,
|
|
611
779
|
maxBlobBytes,
|
|
612
|
-
idDerivation
|
|
780
|
+
idDerivation,
|
|
781
|
+
version: markerVersion ?? 1,
|
|
782
|
+
hasEpochs: !!(encryption?.epochs && encryption.epochs.length > 0)
|
|
613
783
|
});
|
|
614
784
|
}
|
|
615
785
|
};
|
package/dist/edv/EdvCodec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdvCodec.js","sourceRoot":"","sources":["../../src/edv/EdvCodec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;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BACZ,YAAY;gBACZ,OAAO,EAAE,aAAa,IAAI,CAAC;gBAC3B,SAAS,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;aAClE,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochKeys.d.ts","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAEpE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"epochKeys.d.ts","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;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;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B;AAED;;;;;;;;;;;;GAYG;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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { KeyUnwrapError } from '../errors.js';
|
|
1
|
+
import { IntegrityError, KeyUnwrapError } from '../errors.js';
|
|
2
2
|
import { epochKeyIdFor, reconstructEpochKeyPair, unwrapEpochSecret } from './epochCrypto.js';
|
|
3
|
+
import { verifyEpochsMac } from './epochMac.js';
|
|
3
4
|
/**
|
|
4
5
|
* Resolves the reader's epoch keys from a marker. Returns `null` when the marker
|
|
5
6
|
* declares no epochs (a single-key collection -- the caller keeps its existing
|
|
@@ -42,17 +43,43 @@ export async function resolveEpochKeys({ encryption, keyAgreementKey }) {
|
|
|
42
43
|
namedEpochs.find(epoch => epoch.id === currentEpoch)) ||
|
|
43
44
|
namedEpochs[namedEpochs.length - 1];
|
|
44
45
|
// The write epoch is unwrapped eagerly: `writeKey` must be a full key pair the
|
|
45
|
-
// EDV cipher can name recipients with and encrypt under right away.
|
|
46
|
-
|
|
46
|
+
// EDV cipher can name recipients with and encrypt under right away. Its raw
|
|
47
|
+
// secret is surfaced alongside so the epoch-configuration MAC can be verified.
|
|
48
|
+
const writeUnwrapped = await unwrapEpochKey({
|
|
47
49
|
epoch: writeEpochEntry,
|
|
48
50
|
keyAgreementKey
|
|
49
51
|
});
|
|
50
|
-
if (!
|
|
52
|
+
if (!writeUnwrapped) {
|
|
51
53
|
throw new KeyUnwrapError(`This reader's recipient entry for the write epoch ` +
|
|
52
54
|
`"${writeEpochEntry.id}" did not unwrap (a corrupt entry). Re-add ` +
|
|
53
55
|
'this reader with addRecipient, or supply the correct key-agreement ' +
|
|
54
56
|
'key.');
|
|
55
57
|
}
|
|
58
|
+
const writeKey = writeUnwrapped.key;
|
|
59
|
+
// Authenticate the epoch configuration when this reader holds the marker's
|
|
60
|
+
// `currentEpoch` (its write epoch IS `currentEpoch`) and the marker carries a
|
|
61
|
+
// MAC. A reader whose write epoch is an older held epoch cannot key the MAC
|
|
62
|
+
// (its secret is not the current epoch's), so it skips verification -- its
|
|
63
|
+
// writes are rejected server-side via its revoked zcap anyway. An absent MAC
|
|
64
|
+
// is a legacy marker, accepted.
|
|
65
|
+
if (writeEpochEntry.id === encryption.currentEpoch &&
|
|
66
|
+
encryption.epochsMac !== undefined) {
|
|
67
|
+
const { v, alg } = encryption.epochsMac;
|
|
68
|
+
if (v !== 1 || alg !== 'HS256') {
|
|
69
|
+
throw new IntegrityError('The epoch configuration failed to authenticate: its MAC declares an ' +
|
|
70
|
+
`unsupported construction (v=${v}, alg="${alg}"). This is a ` +
|
|
71
|
+
'server-side rollback or tamper.');
|
|
72
|
+
}
|
|
73
|
+
const authentic = await verifyEpochsMac({
|
|
74
|
+
marker: encryption,
|
|
75
|
+
epochSecret: writeUnwrapped.secret
|
|
76
|
+
});
|
|
77
|
+
if (!authentic) {
|
|
78
|
+
throw new IntegrityError('The epoch configuration failed to authenticate; a server-side ' +
|
|
79
|
+
'rollback or tamper of the encryption marker was detected (the ' +
|
|
80
|
+
'MAC over its epoch configuration does not verify).');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
56
83
|
// Read keys: the eagerly-unwrapped write key, plus a LAZY key per other named
|
|
57
84
|
// epoch. Each lazy key knows its `id` up front (derived from the epoch id, so
|
|
58
85
|
// the codec's kid-match filter needs no secret) and unwraps + reconstructs its
|
|
@@ -71,12 +98,15 @@ export async function resolveEpochKeys({ encryption, keyAgreementKey }) {
|
|
|
71
98
|
/**
|
|
72
99
|
* Unwraps and reconstructs a single epoch's key pair for this reader, or returns
|
|
73
100
|
* `null` when the reader is not a recipient of the epoch or its entry does not
|
|
74
|
-
* unwrap (a corrupt entry -- never treat `null` as a key).
|
|
101
|
+
* unwrap (a corrupt entry -- never treat `null` as a key). Returns the raw
|
|
102
|
+
* 32-byte epoch secret alongside the reconstructed key pair, so a caller that
|
|
103
|
+
* must authenticate the epoch configuration (the `epochsMac`) can key the MAC
|
|
104
|
+
* without re-unwrapping.
|
|
75
105
|
*
|
|
76
106
|
* @param options {object}
|
|
77
107
|
* @param options.epoch {CollectionEncryptionEpoch} the epoch to unwrap
|
|
78
108
|
* @param options.keyAgreementKey {IKeyAgreementKey} the reader's own KAK
|
|
79
|
-
* @returns {Promise<IKeyAgreementKey | null>}
|
|
109
|
+
* @returns {Promise<{ key: IKeyAgreementKey; secret: Uint8Array } | null>}
|
|
80
110
|
*/
|
|
81
111
|
async function unwrapEpochKey({ epoch, keyAgreementKey }) {
|
|
82
112
|
const entry = epoch.recipients.find(recipient => recipient.header.kid === keyAgreementKey.id);
|
|
@@ -87,7 +117,7 @@ async function unwrapEpochKey({ epoch, keyAgreementKey }) {
|
|
|
87
117
|
if (!secret) {
|
|
88
118
|
return null;
|
|
89
119
|
}
|
|
90
|
-
return reconstructEpochKeyPair({ epochId: epoch.id, secret });
|
|
120
|
+
return { key: reconstructEpochKeyPair({ epochId: epoch.id, secret }), secret };
|
|
91
121
|
}
|
|
92
122
|
/**
|
|
93
123
|
* Builds a lazily-unwrapping read key for a named epoch: an `IKeyAgreementKey`
|
|
@@ -107,16 +137,16 @@ function lazyEpochKey({ epoch, keyAgreementKey }) {
|
|
|
107
137
|
let pending;
|
|
108
138
|
const resolve = () => {
|
|
109
139
|
if (pending === undefined) {
|
|
110
|
-
const promise = unwrapEpochKey({ epoch, keyAgreementKey }).then(
|
|
111
|
-
if (!
|
|
112
|
-
// The reader was named in this epoch (else no lazy key was built)
|
|
113
|
-
// its entry did not unwrap: a corrupt entry. The codec's
|
|
114
|
-
// catches this and tries the next candidate before
|
|
115
|
-
// typed failure.
|
|
140
|
+
const promise = unwrapEpochKey({ epoch, keyAgreementKey }).then(unwrapped => {
|
|
141
|
+
if (!unwrapped) {
|
|
142
|
+
// The reader was named in this epoch (else no lazy key was built)
|
|
143
|
+
// but its entry did not unwrap: a corrupt entry. The codec's
|
|
144
|
+
// `_decrypt` catches this and tries the next candidate before
|
|
145
|
+
// surfacing its own typed failure.
|
|
116
146
|
throw new KeyUnwrapError(`This reader's recipient entry for epoch "${epoch.id}" did not ` +
|
|
117
147
|
'unwrap (a corrupt entry).');
|
|
118
148
|
}
|
|
119
|
-
return key;
|
|
149
|
+
return unwrapped.key;
|
|
120
150
|
});
|
|
121
151
|
// Cache only a successful unwrap: drop a rejected promise so the next
|
|
122
152
|
// read re-attempts (the failure may have been transient), rather than
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochKeys.js","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"epochKeys.js","sourceRoot":"","sources":["../../src/edv/epochKeys.ts"],"names":[],"mappings":"AAmBA,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;AAsB/C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,UAAU,EACV,eAAe,EAIhB;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,6EAA6E;IAC7E,4EAA4E;IAC5E,oDAAoD;IACpD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACxC,KAAK,CAAC,UAAU,CAAC,IAAI,CACnB,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,eAAe,CAAC,EAAE,CACzD,CACF,CAAA;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,cAAc,CACtB,oEAAoE;YAClE,+DAA+D;YAC/D,qEAAqE;YACrE,uCAAuC,CAC1C,CAAA;IACH,CAAC;IACD,8EAA8E;IAC9E,8EAA8E;IAC9E,0EAA0E;IA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AChF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAS,YAAY,CAAC,EACpB,KAAK,EACL,eAAe,EAIhB;IACC,IAAI,OAA8C,CAAA;IAClD,MAAM,OAAO,GAAG,GAA8B,EAAE;QAC9C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,cAAc,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC,IAAI,CAC7D,SAAS,CAAC,EAAE;gBACV,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,kEAAkE;oBAClE,6DAA6D;oBAC7D,8DAA8D;oBAC9D,mCAAmC;oBACnC,MAAM,IAAI,cAAc,CACtB,4CAA4C,KAAK,CAAC,EAAE,YAAY;wBAC9D,2BAA2B,CAC9B,CAAA;gBACH,CAAC;gBACD,OAAO,SAAS,CAAC,GAAG,CAAA;YACtB,CAAC,CACF,CAAA;YACD,sEAAsE;YACtE,sEAAsE;YACtE,sEAAsE;YACtE,8DAA8D;YAC9D,OAAO,CAAC,KAAK,CAAC,GAAS,EAAE;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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CollectionEncryption, CollectionEncryptionEpochsMac } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Computes the `epochsMac` field for a marker under the current epoch's secret.
|
|
4
|
+
* Compute this over the exact marker state being written (member fields already
|
|
5
|
+
* stamped), since a compare-and-swap retry re-reads the marker.
|
|
6
|
+
*
|
|
7
|
+
* @param options {object}
|
|
8
|
+
* @param options.marker {CollectionEncryption} the marker being written
|
|
9
|
+
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
10
|
+
* @returns {Promise<CollectionEncryptionEpochsMac>}
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeEpochsMac({ marker, epochSecret }: {
|
|
13
|
+
marker: CollectionEncryption;
|
|
14
|
+
epochSecret: Uint8Array;
|
|
15
|
+
}): Promise<CollectionEncryptionEpochsMac>;
|
|
16
|
+
/**
|
|
17
|
+
* Verifies a marker's `epochsMac` against a recomputation from the current
|
|
18
|
+
* epoch's secret. Returns `false` on any mismatch (or a malformed `mac`); the
|
|
19
|
+
* caller decides the error semantics. The MAC construction's own version/alg
|
|
20
|
+
* (`v` / `alg`) is validated by the caller before this is called.
|
|
21
|
+
*
|
|
22
|
+
* @param options {object}
|
|
23
|
+
* @param options.marker {CollectionEncryption} the marker to verify (its
|
|
24
|
+
* `epochsMac.mac` is the tag under test)
|
|
25
|
+
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
26
|
+
* @returns {Promise<boolean>}
|
|
27
|
+
*/
|
|
28
|
+
export declare function verifyEpochsMac({ marker, epochSecret }: {
|
|
29
|
+
marker: CollectionEncryption;
|
|
30
|
+
epochSecret: Uint8Array;
|
|
31
|
+
}): Promise<boolean>;
|
|
32
|
+
//# sourceMappingURL=epochMac.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,WAAW,EACZ,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,WAAW,EAAE,UAAU,CAAA;CACxB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAQzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,WAAW,EACZ,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,WAAW,EAAE,UAAU,CAAA;CACxB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBnB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Authenticated epoch configuration for multi-recipient encrypted Collections:
|
|
6
|
+
* a MAC over a Collection `encryption` marker's epoch configuration, keyed from
|
|
7
|
+
* the current epoch's secret (which the server never holds). It lets a reader
|
|
8
|
+
* detect a server-side rollback of `currentEpoch` or a fabricated epoch list --
|
|
9
|
+
* a malicious server cannot forge a valid MAC without the epoch secret.
|
|
10
|
+
*
|
|
11
|
+
* The MAC covers only `scheme`, `version`, `currentEpoch`, and the ordered list
|
|
12
|
+
* of epoch ids -- deliberately NOT the recipient entries, so adding a recipient
|
|
13
|
+
* (which cannot be forged without the epoch secret anyway) does not invalidate
|
|
14
|
+
* the MAC. Covering `version` makes stripping the marker's scheme version
|
|
15
|
+
* MAC-detectable.
|
|
16
|
+
*
|
|
17
|
+
* Documented limitation (mirrors Cryptomator's versionMac): a server can still
|
|
18
|
+
* replay an ENTIRE prior consistent configuration (an old epoch list with its
|
|
19
|
+
* matching old MAC). Detecting that needs client-side monotonic state, which is
|
|
20
|
+
* out of scope here.
|
|
21
|
+
*/
|
|
22
|
+
import { base64urlnopad } from '@scure/base';
|
|
23
|
+
const TEXT_ENCODER = new TextEncoder();
|
|
24
|
+
/**
|
|
25
|
+
* The HKDF `info` string binding the derived key to this MAC construction.
|
|
26
|
+
*/
|
|
27
|
+
const MAC_KEY_INFO = TEXT_ENCODER.encode('was-epoch-config-mac/v1');
|
|
28
|
+
/**
|
|
29
|
+
* The domain-separation prefix prepended to the JSON payload before it is MACed.
|
|
30
|
+
*/
|
|
31
|
+
const MAC_PAYLOAD_PREFIX = 'was-epoch-config/v1.';
|
|
32
|
+
/**
|
|
33
|
+
* Derives the HMAC-SHA256 key from a 32-byte epoch secret:
|
|
34
|
+
* HKDF-SHA256(ikm = the epoch secret, salt = empty, info =
|
|
35
|
+
* "was-epoch-config-mac/v1", length 32 bytes). Uses WebCrypto (`crypto.subtle`)
|
|
36
|
+
* so it works unchanged in Node 24 and browsers.
|
|
37
|
+
*
|
|
38
|
+
* @param epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
39
|
+
* @returns {Promise<CryptoKey>} the derived HMAC key (sign + verify)
|
|
40
|
+
*/
|
|
41
|
+
async function deriveMacKey(epochSecret) {
|
|
42
|
+
const ikm = await crypto.subtle.importKey('raw', epochSecret, 'HKDF', false, ['deriveKey']);
|
|
43
|
+
return crypto.subtle.deriveKey({
|
|
44
|
+
name: 'HKDF',
|
|
45
|
+
hash: 'SHA-256',
|
|
46
|
+
salt: new Uint8Array(0),
|
|
47
|
+
info: MAC_KEY_INFO
|
|
48
|
+
}, ikm, { name: 'HMAC', hash: 'SHA-256', length: 256 }, false, ['sign', 'verify']);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Builds the MACed payload bytes for a marker's epoch configuration:
|
|
52
|
+
* `UTF8("was-epoch-config/v1." + JSON.stringify({ scheme, version,
|
|
53
|
+
* currentEpoch, epochs }))`, with `version` normalized to `null` when absent
|
|
54
|
+
* and `epochs` the ordered list of epoch id strings. The object member order is
|
|
55
|
+
* fixed so both sides serialize identically.
|
|
56
|
+
*
|
|
57
|
+
* @param marker {CollectionEncryption} the marker whose epoch configuration is
|
|
58
|
+
* being authenticated
|
|
59
|
+
* @returns {Uint8Array}
|
|
60
|
+
*/
|
|
61
|
+
function macPayload(marker) {
|
|
62
|
+
const payload = {
|
|
63
|
+
scheme: marker.scheme,
|
|
64
|
+
version: marker.version ?? null,
|
|
65
|
+
currentEpoch: marker.currentEpoch,
|
|
66
|
+
epochs: (marker.epochs ?? []).map(epoch => epoch.id)
|
|
67
|
+
};
|
|
68
|
+
const bytes = TEXT_ENCODER.encode(MAC_PAYLOAD_PREFIX + JSON.stringify(payload));
|
|
69
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Computes the `epochsMac` field for a marker under the current epoch's secret.
|
|
73
|
+
* Compute this over the exact marker state being written (member fields already
|
|
74
|
+
* stamped), since a compare-and-swap retry re-reads the marker.
|
|
75
|
+
*
|
|
76
|
+
* @param options {object}
|
|
77
|
+
* @param options.marker {CollectionEncryption} the marker being written
|
|
78
|
+
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
79
|
+
* @returns {Promise<CollectionEncryptionEpochsMac>}
|
|
80
|
+
*/
|
|
81
|
+
export async function computeEpochsMac({ marker, epochSecret }) {
|
|
82
|
+
const key = await deriveMacKey(epochSecret);
|
|
83
|
+
const signature = await crypto.subtle.sign('HMAC', key, macPayload(marker));
|
|
84
|
+
return {
|
|
85
|
+
v: 1,
|
|
86
|
+
alg: 'HS256',
|
|
87
|
+
mac: base64urlnopad.encode(new Uint8Array(signature))
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Verifies a marker's `epochsMac` against a recomputation from the current
|
|
92
|
+
* epoch's secret. Returns `false` on any mismatch (or a malformed `mac`); the
|
|
93
|
+
* caller decides the error semantics. The MAC construction's own version/alg
|
|
94
|
+
* (`v` / `alg`) is validated by the caller before this is called.
|
|
95
|
+
*
|
|
96
|
+
* @param options {object}
|
|
97
|
+
* @param options.marker {CollectionEncryption} the marker to verify (its
|
|
98
|
+
* `epochsMac.mac` is the tag under test)
|
|
99
|
+
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
100
|
+
* @returns {Promise<boolean>}
|
|
101
|
+
*/
|
|
102
|
+
export async function verifyEpochsMac({ marker, epochSecret }) {
|
|
103
|
+
const epochsMac = marker.epochsMac;
|
|
104
|
+
if (!epochsMac) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
let mac;
|
|
108
|
+
try {
|
|
109
|
+
mac = base64urlnopad.decode(epochsMac.mac);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
const key = await deriveMacKey(epochSecret);
|
|
115
|
+
return crypto.subtle.verify('HMAC', key, mac, macPayload(marker));
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=epochMac.js.map
|