@interop/wallet-core 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.
Files changed (51) hide show
  1. package/dist/clients/listing.d.ts +3 -3
  2. package/dist/clients/listing.js +3 -3
  3. package/dist/descriptors/acquire.d.ts +23 -15
  4. package/dist/descriptors/acquire.d.ts.map +1 -1
  5. package/dist/descriptors/acquire.js +11 -8
  6. package/dist/descriptors/acquire.js.map +1 -1
  7. package/dist/descriptors/cipher.d.ts +5 -2
  8. package/dist/descriptors/cipher.d.ts.map +1 -1
  9. package/dist/descriptors/cipher.js +27 -4
  10. package/dist/descriptors/cipher.js.map +1 -1
  11. package/dist/descriptors/index.d.ts +6 -2
  12. package/dist/descriptors/index.d.ts.map +1 -1
  13. package/dist/descriptors/index.js +6 -2
  14. package/dist/descriptors/index.js.map +1 -1
  15. package/dist/keyring/index.d.ts +8 -3
  16. package/dist/keyring/index.d.ts.map +1 -1
  17. package/dist/keyring/index.js +8 -3
  18. package/dist/keyring/index.js.map +1 -1
  19. package/dist/keyring/record.d.ts +38 -18
  20. package/dist/keyring/record.d.ts.map +1 -1
  21. package/dist/keyring/record.js +44 -15
  22. package/dist/keyring/record.js.map +1 -1
  23. package/dist/keys/index.d.ts +1 -0
  24. package/dist/keys/index.d.ts.map +1 -1
  25. package/dist/keys/index.js.map +1 -1
  26. package/dist/keys/spaceEpochs.d.ts +50 -11
  27. package/dist/keys/spaceEpochs.d.ts.map +1 -1
  28. package/dist/keys/spaceEpochs.js +31 -15
  29. package/dist/keys/spaceEpochs.js.map +1 -1
  30. package/dist/recovery/recoveryRecord.d.ts +4 -2
  31. package/dist/recovery/recoveryRecord.d.ts.map +1 -1
  32. package/dist/recovery/recoveryRecord.js +2 -1
  33. package/dist/recovery/recoveryRecord.js.map +1 -1
  34. package/dist/sync/engine.d.ts +11 -0
  35. package/dist/sync/engine.d.ts.map +1 -1
  36. package/dist/sync/engine.js.map +1 -1
  37. package/dist/sync/remint.d.ts +23 -7
  38. package/dist/sync/remint.d.ts.map +1 -1
  39. package/dist/sync/remint.js +72 -34
  40. package/dist/sync/remint.js.map +1 -1
  41. package/dist/sync/types.d.ts +13 -1
  42. package/dist/sync/types.d.ts.map +1 -1
  43. package/dist/webvh/didWeb.d.ts +7 -1
  44. package/dist/webvh/didWeb.d.ts.map +1 -1
  45. package/dist/webvh/didWeb.js.map +1 -1
  46. package/dist/webvh/didWebvh.d.ts +5 -2
  47. package/dist/webvh/didWebvh.d.ts.map +1 -1
  48. package/dist/webvh/didWebvh.js +42 -26
  49. package/dist/webvh/didWebvh.js.map +1 -1
  50. package/dist/webvh/listClients.d.ts +3 -3
  51. package/package.json +1 -1
@@ -12,9 +12,9 @@
12
12
  * much as the display: `listEnrolledWebvhClients` keys on
13
13
  * `capabilityInvocation`, which is what structurally excludes a recovery
14
14
  * code's key (published under `keyAgreement` only, deliberately unmarked) and
15
- * the server-side conveniences (published under `authentication` /
16
- * `assertionMethod`) -- neither can appear, by construction rather than by a
17
- * filter someone must remember.
15
+ * the server-side convenience (the KMS authentication key, published under
16
+ * `authentication` only) -- neither can appear, by construction rather than
17
+ * by a filter someone must remember.
18
18
  *
19
19
  * Labels are display metadata with no authority, so a label-read failure
20
20
  * degrades to unlabeled rows; the listing itself fails only when the log
@@ -12,9 +12,9 @@
12
12
  * much as the display: `listEnrolledWebvhClients` keys on
13
13
  * `capabilityInvocation`, which is what structurally excludes a recovery
14
14
  * code's key (published under `keyAgreement` only, deliberately unmarked) and
15
- * the server-side conveniences (published under `authentication` /
16
- * `assertionMethod`) -- neither can appear, by construction rather than by a
17
- * filter someone must remember.
15
+ * the server-side convenience (the KMS authentication key, published under
16
+ * `authentication` only) -- neither can appear, by construction rather than
17
+ * by a filter someone must remember.
18
18
  *
19
19
  * Labels are display metadata with no authority, so a label-read failure
20
20
  * degrades to unlabeled rows; the listing itself fails only when the log
@@ -4,11 +4,16 @@
4
4
  /**
5
5
  * Collection encryption-descriptor acquisition: reading a collection's
6
6
  * `CollectionEncryption` descriptor (its key-epoch roster) from the Collection
7
- * Description, caching each success, and falling back to the cached copy when
8
- * the description cannot be fetched -- offline, a previously-shared collection
9
- * must keep encrypting under its current epoch. A successful fetch that
10
- * returns no descriptor (an unshared collection) yields `undefined`: the
11
- * single-key path.
7
+ * Description, caching each success, and falling back to the cached copy
8
+ * whenever the description yields no descriptor -- whether it could not be
9
+ * fetched at all (offline, a collection must keep encrypting under its current
10
+ * epoch) or came back empty (WAS masks an unauthorized read as an absent one,
11
+ * so an empty description is ambiguous, never an authoritative "no
12
+ * encryption"). `undefined` therefore means only this: nothing, fetched or
13
+ * cached, describes this collection's encryption -- a plaintext collection, or
14
+ * an encrypted one whose epoch[0] install has not landed. A caller that has
15
+ * declared the collection encrypted must refuse fail-closed rather than
16
+ * encrypt without a roster.
12
17
  *
13
18
  * The two seams are deliberately narrow, so a wallet app's own classes satisfy
14
19
  * them structurally -- no adapter needed. An {@link EncryptionDescriptorSource}
@@ -20,9 +25,11 @@
20
25
  import type { CollectionEncryption, WasClient } from '@interop/was-client';
21
26
  /**
22
27
  * Where descriptors come from: one signed read of the collection's
23
- * Description. Resolves `undefined` for a collection that is plaintext or has
24
- * no descriptor; network errors throw through (callers treat the fetch as
25
- * best-effort and fall back to a cached copy).
28
+ * Description. Resolves `undefined` when the description carries no encryption
29
+ * member -- which a WAS host also serves for a read this client is not
30
+ * authorized to make, so the absence is ambiguous and callers fall back to a
31
+ * cached copy just as they do for a thrown fetch. Network errors throw through
32
+ * (callers treat the fetch as best-effort).
26
33
  */
27
34
  export interface EncryptionDescriptorSource {
28
35
  collectionEncryption(options: {
@@ -59,11 +66,12 @@ export declare function wasDescriptorSource({ was, spaceId }: {
59
66
  }): EncryptionDescriptorSource;
60
67
  /**
61
68
  * Acquires one collection's descriptor: fetches it from the source, caching a
62
- * success; falls back to the cached copy when the fetch fails; and with no
63
- * source at all (a purely local code path) reads the cache alone. A successful
64
- * fetch that returns no descriptor resolves `undefined` -- an unshared
65
- * collection stays on the single-key path -- and deliberately leaves any
66
- * cached copy in place, mirroring the fetch-failure fallback.
69
+ * success; falls back to the cached copy whenever the fetch yields no
70
+ * descriptor (it threw, or it came back empty -- a masked 404 for an
71
+ * unauthorized read looks exactly like an unencrypted collection); and with no
72
+ * source at all (a purely local code path) reads the cache alone. Any cached
73
+ * copy is deliberately left in place, never cleared by an empty fetch.
74
+ * `undefined` means no descriptor exists anywhere for this collection.
67
75
  *
68
76
  * @param options {object}
69
77
  * @param [options.source] {EncryptionDescriptorSource} omit for cache-only
@@ -71,8 +79,8 @@ export declare function wasDescriptorSource({ was, spaceId }: {
71
79
  * @param options.cache {EncryptionDescriptorCache}
72
80
  * @param options.collectionId {string}
73
81
  * @param [options.onFetchError] {function} observes a swallowed fetch
74
- * failure (the cached-fallback branch); errors from the cache itself throw
75
- * through
82
+ * failure (the thrown-fetch branch only; an empty description is not an
83
+ * error). Errors from the cache itself throw through
76
84
  * @returns {Promise<CollectionEncryption | undefined>}
77
85
  */
78
86
  export declare function acquireDescriptor({ source, cache, collectionId, onFetchError }: {
@@ -1 +1 @@
1
- {"version":3,"file":"acquire.d.ts","sourceRoot":"","sources":["../../src/descriptors/acquire.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,CAAC,OAAO,EAAE;QAC5B,YAAY,EAAE,MAAM,CAAA;KACrB,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;CAC9C;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,cAAc,CAAC,OAAO,EAAE;QACtB,YAAY,EAAE,MAAM,CAAA;KACrB,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;IAC7C,eAAe,CAAC,OA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B,CAAA;IACnC,KAAK,EAAE,yBAAyB,CAAA;IAChC,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACtE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAiBhD"}
@@ -21,11 +21,12 @@ export function wasDescriptorSource({ was, spaceId }) {
21
21
  }
22
22
  /**
23
23
  * Acquires one collection's descriptor: fetches it from the source, caching a
24
- * success; falls back to the cached copy when the fetch fails; and with no
25
- * source at all (a purely local code path) reads the cache alone. A successful
26
- * fetch that returns no descriptor resolves `undefined` -- an unshared
27
- * collection stays on the single-key path -- and deliberately leaves any
28
- * cached copy in place, mirroring the fetch-failure fallback.
24
+ * success; falls back to the cached copy whenever the fetch yields no
25
+ * descriptor (it threw, or it came back empty -- a masked 404 for an
26
+ * unauthorized read looks exactly like an unencrypted collection); and with no
27
+ * source at all (a purely local code path) reads the cache alone. Any cached
28
+ * copy is deliberately left in place, never cleared by an empty fetch.
29
+ * `undefined` means no descriptor exists anywhere for this collection.
29
30
  *
30
31
  * @param options {object}
31
32
  * @param [options.source] {EncryptionDescriptorSource} omit for cache-only
@@ -33,8 +34,8 @@ export function wasDescriptorSource({ was, spaceId }) {
33
34
  * @param options.cache {EncryptionDescriptorCache}
34
35
  * @param options.collectionId {string}
35
36
  * @param [options.onFetchError] {function} observes a swallowed fetch
36
- * failure (the cached-fallback branch); errors from the cache itself throw
37
- * through
37
+ * failure (the thrown-fetch branch only; an empty description is not an
38
+ * error). Errors from the cache itself throw through
38
39
  * @returns {Promise<CollectionEncryption | undefined>}
39
40
  */
40
41
  export async function acquireDescriptor({ source, cache, collectionId, onFetchError }) {
@@ -47,7 +48,9 @@ export async function acquireDescriptor({ source, cache, collectionId, onFetchEr
47
48
  await cache.writeDescriptor({ collectionId, descriptor: fetched });
48
49
  return fetched;
49
50
  }
50
- return undefined;
51
+ // Empty description: not authoritative (an unauthorized read is masked as
52
+ // an absent one), so a warm cache still serves the collection.
53
+ return cache.readDescriptor({ collectionId });
51
54
  }
52
55
  catch (err) {
53
56
  onFetchError?.(err, { collectionId });
@@ -1 +1 @@
1
- {"version":3,"file":"acquire.js","sourceRoot":"","sources":["../../src/descriptors/acquire.ts"],"names":[],"mappings":"AAgDA;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,GAAG,EACH,OAAO,EAIR;IACC,OAAO;QACL,KAAK,CAAC,oBAAoB,CAAC,EAAE,YAAY,EAAE;YACzC,MAAM,WAAW,GAAG,MAAM,GAAG;iBAC1B,KAAK,CAAC,OAAO,CAAC;iBACd,UAAU,CAAC,YAAY,CAAC;iBACxB,QAAQ,EAAE,CAAA;YACb,OAAO,WAAW,EAAE,UAAU,IAAI,SAAS,CAAA;QAC7C,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,MAAM,EACN,KAAK,EACL,YAAY,EACZ,YAAY,EAMb;IACC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAC/C,CAAC;IACD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;QACnE,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,KAAK,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAA;YAClE,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,C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QACxC,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -8,7 +8,8 @@
8
8
  * conflict resolver) rather than a row-scanning store.
9
9
  *
10
10
  * Built, the cipher acquires the collection's descriptor (fetch, cache the
11
- * success, cached fallback on failure -- see `acquire.ts`) and constructs the
11
+ * success, cached fallback whenever the fetch yields none -- see
12
+ * `acquire.ts`) and constructs the
12
13
  * underlying EDV cipher from it; with no descriptor, or a descriptor with no
13
14
  * epochs, the build refuses fail-closed (every encrypted collection's
14
15
  * descriptor carries an epoch roster from provisioning, so the absence can
@@ -18,7 +19,9 @@
18
19
  * and retries that decrypt exactly once -- and only once per cipher instance,
19
20
  * which the host scopes to one `(profile, collection)` session by dropping
20
21
  * its cipher cache when the session ends. A second failure (or any unknown
21
- * epoch after the one refresh is spent) propagates.
22
+ * epoch after the one refresh is spent) propagates. A refresh that itself
23
+ * fails does not count as spent -- the original `UnknownEpochError` is
24
+ * rethrown and a later decrypt may try again.
22
25
  */
23
26
  import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
24
27
  import { type DocCipher } from '@interop/was-client/edv';
@@ -1 +1 @@
1
- {"version":3,"file":"cipher.d.ts","sourceRoot":"","sources":["../../src/descriptors/cipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAChC,MAAM,cAAc,CAAA;AAErB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,4BAA4B,CAAC,EACjD,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,YAAY,EACb,EAAE;IACD,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IACnC,MAAM,CAAC,EAAE,0BAA0B,CAAA;IACnC,KAAK,EAAE,yBAAyB,CAAA;IAChC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACtE,GAAG,OAAO,CAAC,SAAS,CAAC,CA8DrB"}
1
+ {"version":3,"file":"cipher.d.ts","sourceRoot":"","sources":["../../src/descriptors/cipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAChC,MAAM,cAAc,CAAA;AAErB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,4BAA4B,CAAC,EACjD,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,YAAY,EACb,EAAE;IACD,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IACnC,MAAM,CAAC,EAAE,0BAA0B,CAAA;IACnC,KAAK,EAAE,yBAAyB,CAAA;IAChC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACtE,GAAG,OAAO,CAAC,SAAS,CAAC,CAoFrB"}
@@ -64,10 +64,33 @@ export async function createRefreshingEdvDocCipher({ keyAgreementKey, keyResolve
64
64
  if (!(err instanceof UnknownEpochError) || !source) {
65
65
  throw err;
66
66
  }
67
- refreshed ??= build().then(cipher => {
68
- inner = cipher;
69
- });
70
- await refreshed;
67
+ if (!refreshed) {
68
+ const attempt = build().then(cipher => {
69
+ inner = cipher;
70
+ });
71
+ refreshed = attempt;
72
+ // Only a COMPLETED refresh is spent. A rejected one (the description
73
+ // could not be read and no cached copy answered either) un-arms the
74
+ // guard so a later unknown-epoch decrypt may try again; a successful
75
+ // refresh that still cannot route the envelope stays spent for the
76
+ // session, which is what keeps a genuinely foreign envelope from
77
+ // driving a refetch loop.
78
+ attempt.catch(() => {
79
+ if (refreshed === attempt) {
80
+ refreshed = null;
81
+ }
82
+ });
83
+ }
84
+ try {
85
+ await refreshed;
86
+ }
87
+ catch {
88
+ // The refresh failed, so nothing was learned about this envelope's
89
+ // epoch: surface the original UnknownEpochError rather than the
90
+ // build failure, so callers classifying on it (the create-loss
91
+ // re-mint) still see the row they exist to repair.
92
+ throw err;
93
+ }
71
94
  // One retry under the swapped cipher. If the refresh was already
72
95
  // spent before this decrypt began, this re-attempt is a local
73
96
  // no-network decrypt that fails the same way -- so a genuinely
@@ -1 +1 @@
1
- {"version":3,"file":"cipher.js","sourceRoot":"","sources":["../../src/descriptors/cipher.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EAGlB,MAAM,cAAc,CAAA;AAErB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,YAAY,EASb;IACC,MAAM,KAAK,GAAG,KAAK,IAAwB,EAAE;QAC3C,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC;YACzC,MAAM;YACN,KAAK;YAC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;KACF,CAAA;AACH,CAAC"}
@@ -15,8 +15,12 @@
15
15
  * - `wasDescriptorSource` -- the `EncryptionDescriptorSource` over a
16
16
  * was-client handle.
17
17
  * - `acquireDescriptor` / `acquireDescriptors` -- fetch + cache with the
18
- * cached fallback (offline, a previously-shared collection keeps encrypting
19
- * under its current epoch; no descriptor at all is the single-key path).
18
+ * cached fallback whenever the fetch yields no descriptor, thrown or empty
19
+ * (offline, a collection keeps encrypting under its current epoch; an empty
20
+ * description is ambiguous, since WAS masks an unauthorized read as an
21
+ * absent one). No descriptor anywhere means a plaintext collection, or an
22
+ * encrypted one whose epoch[0] install has not landed -- which a caller that
23
+ * has declared the collection encrypted must refuse fail-closed.
20
24
  * - `DescriptorRefreshPolicy` -- the once-per-collection-per-session
21
25
  * unknown-epoch refresh guard, plus the refresh-and-re-read-once wrapper
22
26
  * for hosts whose reads scan rows and count unknown-epoch skips.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/descriptors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/descriptors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA"}
@@ -15,8 +15,12 @@
15
15
  * - `wasDescriptorSource` -- the `EncryptionDescriptorSource` over a
16
16
  * was-client handle.
17
17
  * - `acquireDescriptor` / `acquireDescriptors` -- fetch + cache with the
18
- * cached fallback (offline, a previously-shared collection keeps encrypting
19
- * under its current epoch; no descriptor at all is the single-key path).
18
+ * cached fallback whenever the fetch yields no descriptor, thrown or empty
19
+ * (offline, a collection keeps encrypting under its current epoch; an empty
20
+ * description is ambiguous, since WAS masks an unauthorized read as an
21
+ * absent one). No descriptor anywhere means a plaintext collection, or an
22
+ * encrypted one whose epoch[0] install has not landed -- which a caller that
23
+ * has declared the collection encrypted must refuse fail-closed.
20
24
  * - `DescriptorRefreshPolicy` -- the once-per-collection-per-session
21
25
  * unknown-epoch refresh guard, plus the refresh-and-re-read-once wrapper
22
26
  * for hosts whose reads scan rows and count unknown-epoch skips.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/descriptors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AAMrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/descriptors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AAMrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA"}
@@ -10,8 +10,13 @@
10
10
  * wire-level unlock derivation (implemented over `@noble/hashes`, so it runs
11
11
  * unchanged where WebCrypto's `deriveBits` is unavailable) and the unlock
12
12
  * Space addressing convention.
13
- * - `wrapKeyringRecord` / `unwrapKeyringRecord` -- the `{ version, wrapped }`
14
- * account-pointer record codec.
13
+ * - `wrapKeyringRecord` / `unwrapKeyringRecord` -- the
14
+ * `{ version, encryption, wrapped }` account-pointer record codec.
15
+ * - `mintRecordEncryption` / `recordCipher` / `parseRecordFrame` -- the
16
+ * record-own-epoch envelope construction the codec seals with plus the frame
17
+ * validation it opens with, exported so an app's own locally stored records
18
+ * seal and unseal the same way (under their own cipher context) rather than
19
+ * re-deriving the construction.
15
20
  * - `ensureUnlockSpace` / `getUnlockKeyring` / `putUnlockKeyring` /
16
21
  * `deleteUnlockSpace` / `deleteUnlockSpaceWithCapability` -- the unlock
17
22
  * Space's lifecycle and its one resource.
@@ -23,7 +28,7 @@
23
28
  */
24
29
  export { deriveUnlockIdentity, KEYRING_KDF, UNLOCK_HANDLE, UNLOCK_KEY_NAME, unlockSpaceIdFor } from './kdf.js';
25
30
  export type { UnlockIdentity, UnlockKdf } from './kdf.js';
26
- export { KEYRING_RECORD_VERSION, parseRecordPointer, unwrapKeyringRecord, wrapKeyringRecord } from './record.js';
31
+ export { KEYRING_RECORD_VERSION, mintRecordEncryption, parseRecordFrame, parseRecordPointer, recordCipher, unwrapKeyringRecord, wrapKeyringRecord } from './record.js';
27
32
  export type { AccountPointer, KeyringRecordContents } from './record.js';
28
33
  export { deleteUnlockSpace, deleteUnlockSpaceWithCapability, ensureUnlockSpace, getUnlockKeyring, putUnlockKeyring, putUnlockKeyringWithCapability, UNLOCK_SPACE_NAME } from './unlockSpace.js';
29
34
  export { fetchKeyringRecord } from './fetch.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keyring/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzD,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExE,OAAO,EACL,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keyring/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExE,OAAO,EACL,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
@@ -10,8 +10,13 @@
10
10
  * wire-level unlock derivation (implemented over `@noble/hashes`, so it runs
11
11
  * unchanged where WebCrypto's `deriveBits` is unavailable) and the unlock
12
12
  * Space addressing convention.
13
- * - `wrapKeyringRecord` / `unwrapKeyringRecord` -- the `{ version, wrapped }`
14
- * account-pointer record codec.
13
+ * - `wrapKeyringRecord` / `unwrapKeyringRecord` -- the
14
+ * `{ version, encryption, wrapped }` account-pointer record codec.
15
+ * - `mintRecordEncryption` / `recordCipher` / `parseRecordFrame` -- the
16
+ * record-own-epoch envelope construction the codec seals with plus the frame
17
+ * validation it opens with, exported so an app's own locally stored records
18
+ * seal and unseal the same way (under their own cipher context) rather than
19
+ * re-deriving the construction.
15
20
  * - `ensureUnlockSpace` / `getUnlockKeyring` / `putUnlockKeyring` /
16
21
  * `deleteUnlockSpace` / `deleteUnlockSpaceWithCapability` -- the unlock
17
22
  * Space's lifecycle and its one resource.
@@ -22,7 +27,7 @@
22
27
  * was-client dependency graph (the same isolation pattern as `./identity`).
23
28
  */
24
29
  export { deriveUnlockIdentity, KEYRING_KDF, UNLOCK_HANDLE, UNLOCK_KEY_NAME, unlockSpaceIdFor } from './kdf.js';
25
- export { KEYRING_RECORD_VERSION, parseRecordPointer, unwrapKeyringRecord, wrapKeyringRecord } from './record.js';
30
+ export { KEYRING_RECORD_VERSION, mintRecordEncryption, parseRecordFrame, parseRecordPointer, recordCipher, unwrapKeyringRecord, wrapKeyringRecord } from './record.js';
26
31
  export { deleteUnlockSpace, deleteUnlockSpaceWithCapability, ensureUnlockSpace, getUnlockKeyring, putUnlockKeyring, putUnlockKeyringWithCapability, UNLOCK_SPACE_NAME } from './unlockSpace.js';
27
32
  export { fetchKeyringRecord } from './fetch.js';
28
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keyring/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keyring/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
@@ -8,12 +8,13 @@
8
8
  * account pointer -- and deliberately no key material of any kind, so the
9
9
  * record locates an account without authorizing anything against it.
10
10
  *
11
- * The wrap is an EDV document envelope bound to the `keyring` cipher context
12
- * (so a keyring envelope can never be mistaken for, or swapped with, any other
13
- * wrapped record), sealed under the record's own key epoch: every EDV envelope
14
- * seals to an epoch key, so the record carries its one-epoch descriptor in its
15
- * `encryption` member, epoch[0] wrapped to the unlock key-agreement key. The
16
- * record stays self-contained -- unlock KAK in, contents out.
11
+ * The wrap is an EDV document envelope sealed under the record's own key
12
+ * epoch: every EDV envelope seals to an epoch key, so the record carries its
13
+ * one-epoch descriptor in its `encryption` member, epoch[0] wrapped to the
14
+ * unlock key-agreement key. The record stays self-contained -- unlock KAK in,
15
+ * contents out. The cipher's `keyring` collection context labels errors only
16
+ * (the codec is agnostic to it); what keeps a swapped-in foreign record from
17
+ * being accepted is the contents validation on unwrap, not the cipher.
17
18
  */
18
19
  import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
19
20
  import type { CollectionEncryption } from '@interop/was-client';
@@ -27,45 +28,63 @@ import { type DocCipher } from '@interop/was-client/edv';
27
28
  export declare const KEYRING_RECORD_VERSION = 1;
28
29
  /**
29
30
  * Mints the one-epoch descriptor a fresh record is sealed under: epoch[0]
30
- * wrapped to the unlock KAK alone, built through `initRecipients` against a
31
+ * wrapped to the given KAK alone, built through `initRecipients` against a
31
32
  * throwaway in-memory store (the descriptor's home is the record itself).
33
+ * Exported for any consumer sealing a self-contained
34
+ * `{ version, encryption, wrapped }` record -- the keyring and recovery
35
+ * records here, and a wallet app's own locally stored records (e.g.
36
+ * freewallet's client-key record and unlock-methods registry).
32
37
  *
33
38
  * @param options {object}
34
- * @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
39
+ * @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
40
+ * the keyring record, the unlock KAK)
35
41
  * @returns {Promise<CollectionEncryption>}
36
42
  */
37
43
  export declare function mintRecordEncryption({ keyAgreementKey }: {
38
44
  keyAgreementKey: IKeyAgreementKey;
39
45
  }): Promise<CollectionEncryption>;
40
46
  /**
41
- * Builds the record cipher: the keyring-context EDV cipher over the record's
42
- * own descriptor. Shared by the wrap and unwrap paths (and by the recovery
43
- * record, which reuses the keyring cipher context verbatim).
47
+ * Builds the record cipher: an EDV cipher over the record's own descriptor.
48
+ * Shared by the wrap and unwrap paths (and by the recovery record, which
49
+ * reuses the keyring cipher context verbatim); an app's own record kind
50
+ * passes its own `collectionId` so its failures name the record kind. The
51
+ * context labels errors only -- the codec is agnostic to it, so a record
52
+ * kind's real swap protection is its contents validation on unwrap.
44
53
  *
45
54
  * @param options {object}
46
- * @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
55
+ * @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
56
+ * the keyring record, the unlock KAK)
47
57
  * @param options.keyResolver {IKeyResolver}
48
58
  * @param options.encryption {CollectionEncryption} the record's descriptor
59
+ * @param [options.collectionId] {string} the cipher context failures are
60
+ * labeled with; defaults to the keyring context
49
61
  * @returns {Promise<DocCipher>}
50
62
  */
51
- export declare function recordCipher({ keyAgreementKey, keyResolver, encryption }: {
63
+ export declare function recordCipher({ keyAgreementKey, keyResolver, encryption, collectionId }: {
52
64
  keyAgreementKey: IKeyAgreementKey;
53
65
  keyResolver: IKeyResolver;
54
66
  encryption: CollectionEncryption;
67
+ collectionId?: string;
55
68
  }): Promise<DocCipher>;
56
69
  /**
57
70
  * Validates the common `{ version, encryption, wrapped }` frame of a stored
58
71
  * record (keyring or recovery -- `label` names the refusals) and returns its
59
- * members.
72
+ * members. Exported so an app's own record kinds open their records through
73
+ * the same frame validation the codec here seals with, rather than re-deriving
74
+ * the version and shape checks.
60
75
  *
61
76
  * @param options {object}
62
77
  * @param options.record {unknown}
63
- * @param options.label {string} `'keyring'` or `'recovery'`
78
+ * @param options.label {string} `'keyring'`, `'recovery'`, or an app record
79
+ * kind's own label
80
+ * @param [options.version] {number} the version the frame must carry;
81
+ * defaults to the keyring record version
64
82
  * @returns {{ encryption: CollectionEncryption, wrapped: unknown }}
65
83
  */
66
- export declare function parseRecordFrame({ record, label }: {
84
+ export declare function parseRecordFrame({ record, label, version }: {
67
85
  record: unknown;
68
86
  label: string;
87
+ version?: number;
69
88
  }): {
70
89
  encryption: CollectionEncryption;
71
90
  wrapped: unknown;
@@ -106,7 +125,8 @@ export interface KeyringRecordContents {
106
125
  * no-WAS deployments)
107
126
  * @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
108
127
  * @param options.keyResolver {IKeyResolver}
109
- * @returns {Promise<{ version: number, encryption: unknown, wrapped: unknown }>}
128
+ * @returns {Promise<{ version: number, encryption: CollectionEncryption,
129
+ * wrapped: unknown }>}
110
130
  */
111
131
  export declare function wrapKeyringRecord({ controller, email, pointer, keyAgreementKey, keyResolver }: {
112
132
  controller: string;
@@ -116,7 +136,7 @@ export declare function wrapKeyringRecord({ controller, email, pointer, keyAgree
116
136
  keyResolver: IKeyResolver;
117
137
  }): Promise<{
118
138
  version: number;
119
- encryption: unknown;
139
+ encryption: CollectionEncryption;
120
140
  wrapped: unknown;
121
141
  }>;
122
142
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/keyring/record.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,yBAAyB,CAAA;AAGhC;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,eAAe,EAChB,EAAE;IACD,eAAe,EAAE,gBAAgB,CAAA;CAClC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiBhC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,EACjC,eAAe,EACf,WAAW,EACX,UAAU,EACX,EAAE;IACD,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,UAAU,EAAE,oBAAoB,CAAA;CACjC,GAAG,OAAO,CAAC,SAAS,CAAC,CAOrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,KAAK,EACN,EAAE;IACD,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AM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,UAAU,EACV,KAAK,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACZ,EAAE;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;CAC1B,GAAG,OAAO,CAAC;IACV,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,oBAAoB,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAC,CAwBD;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EACN,eAAe,EACf,WAAW,EACZ,EAAE;IACD,MAAM,EAAE,OAAO,CAAA;IACf,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;CAC1B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAgCjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAsB7E"}
@@ -9,11 +9,16 @@ import { KEYRING_COLLECTION } from '../space/collections.js';
9
9
  export const KEYRING_RECORD_VERSION = 1;
10
10
  /**
11
11
  * Mints the one-epoch descriptor a fresh record is sealed under: epoch[0]
12
- * wrapped to the unlock KAK alone, built through `initRecipients` against a
12
+ * wrapped to the given KAK alone, built through `initRecipients` against a
13
13
  * throwaway in-memory store (the descriptor's home is the record itself).
14
+ * Exported for any consumer sealing a self-contained
15
+ * `{ version, encryption, wrapped }` record -- the keyring and recovery
16
+ * records here, and a wallet app's own locally stored records (e.g.
17
+ * freewallet's client-key record and unlock-methods registry).
14
18
  *
15
19
  * @param options {object}
16
- * @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
20
+ * @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
21
+ * the keyring record, the unlock KAK)
17
22
  * @returns {Promise<CollectionEncryption>}
18
23
  */
19
24
  export async function mintRecordEncryption({ keyAgreementKey }) {
@@ -35,41 +40,64 @@ export async function mintRecordEncryption({ keyAgreementKey }) {
35
40
  });
36
41
  }
37
42
  /**
38
- * Builds the record cipher: the keyring-context EDV cipher over the record's
39
- * own descriptor. Shared by the wrap and unwrap paths (and by the recovery
40
- * record, which reuses the keyring cipher context verbatim).
43
+ * Builds the record cipher: an EDV cipher over the record's own descriptor.
44
+ * Shared by the wrap and unwrap paths (and by the recovery record, which
45
+ * reuses the keyring cipher context verbatim); an app's own record kind
46
+ * passes its own `collectionId` so its failures name the record kind. The
47
+ * context labels errors only -- the codec is agnostic to it, so a record
48
+ * kind's real swap protection is its contents validation on unwrap.
41
49
  *
42
50
  * @param options {object}
43
- * @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
51
+ * @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
52
+ * the keyring record, the unlock KAK)
44
53
  * @param options.keyResolver {IKeyResolver}
45
54
  * @param options.encryption {CollectionEncryption} the record's descriptor
55
+ * @param [options.collectionId] {string} the cipher context failures are
56
+ * labeled with; defaults to the keyring context
46
57
  * @returns {Promise<DocCipher>}
47
58
  */
48
- export async function recordCipher({ keyAgreementKey, keyResolver, encryption }) {
59
+ export async function recordCipher({ keyAgreementKey, keyResolver, encryption, collectionId = KEYRING_COLLECTION.id }) {
49
60
  return createEdvDocCipher({
50
61
  keyAgreementKey,
51
62
  keyResolver,
52
- collectionId: KEYRING_COLLECTION.id,
63
+ collectionId,
53
64
  encryption
54
65
  });
55
66
  }
56
67
  /**
57
68
  * Validates the common `{ version, encryption, wrapped }` frame of a stored
58
69
  * record (keyring or recovery -- `label` names the refusals) and returns its
59
- * members.
70
+ * members. Exported so an app's own record kinds open their records through
71
+ * the same frame validation the codec here seals with, rather than re-deriving
72
+ * the version and shape checks.
60
73
  *
61
74
  * @param options {object}
62
75
  * @param options.record {unknown}
63
- * @param options.label {string} `'keyring'` or `'recovery'`
76
+ * @param options.label {string} `'keyring'`, `'recovery'`, or an app record
77
+ * kind's own label
78
+ * @param [options.version] {number} the version the frame must carry;
79
+ * defaults to the keyring record version
64
80
  * @returns {{ encryption: CollectionEncryption, wrapped: unknown }}
65
81
  */
66
- export function parseRecordFrame({ record, label }) {
82
+ export function parseRecordFrame({ record, label, version = KEYRING_RECORD_VERSION }) {
67
83
  if (record === null || typeof record !== 'object') {
68
84
  throw new Error(`Malformed ${label} record.`);
69
85
  }
70
- const { version, encryption, wrapped } = record;
71
- if (version !== KEYRING_RECORD_VERSION) {
72
- throw new Error(`Unsupported ${label} record version "${String(version)}".`);
86
+ const { version: recordVersion, encryption, wrapped } = record;
87
+ if (recordVersion !== version) {
88
+ throw new Error(`Unsupported ${label} record version "${String(recordVersion)}".`);
89
+ }
90
+ if (wrapped === undefined || wrapped === null) {
91
+ throw new Error(`Malformed ${label} record.`);
92
+ }
93
+ // A version-1 frame carrying a wrap but no descriptor is the retired
94
+ // pre-extraction record shape, which shipped under this same version number
95
+ // and wrapped a data seed. It is unusable, not merely damaged -- name the
96
+ // shape so the refusal is not read as corruption.
97
+ if (encryption === undefined && version === KEYRING_RECORD_VERSION) {
98
+ throw new Error(`The ${label} record uses the retired pre-extraction version 1 shape ` +
99
+ '(a data-seed wrap with no encryption descriptor); such accounts are ' +
100
+ 're-provisioned, not migrated.');
73
101
  }
74
102
  if (encryption === null || typeof encryption !== 'object') {
75
103
  throw new Error(`The ${label} record is missing its encryption descriptor.`);
@@ -89,7 +117,8 @@ export function parseRecordFrame({ record, label }) {
89
117
  * no-WAS deployments)
90
118
  * @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
91
119
  * @param options.keyResolver {IKeyResolver}
92
- * @returns {Promise<{ version: number, encryption: unknown, wrapped: unknown }>}
120
+ * @returns {Promise<{ version: number, encryption: CollectionEncryption,
121
+ * wrapped: unknown }>}
93
122
  */
94
123
  export async function wrapKeyringRecord({ controller, email, pointer, keyAgreementKey, keyResolver }) {
95
124
  const encryption = await mintRecordEncryption({ keyAgreementKey });
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/keyring/record.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EAGf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,eAAe,EAGhB;IACC,IAAI,MAAM,GAAgC,IAAI,CAAA;IAC9C,MAAM,KAAK,GAA8B;QACvC,KAAK,CAAC,IAAI;YACR,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;QAC/C,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,IAAI;YAChB,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,IAAI;YACf,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;KACF,CAAA;IACD,OAAO,cAAc,CAAC;QACpB,KAAK;QACL,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;KAClD,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,eAAe,EACf,WAAW,EACX,UAAU,EAKX;IACC,OAAO,kBAAkB,CAAC;QACxB,eAAe;QACf,WAAW;QACX,YAAY,EAAE,kBAAkB,CAAC,EAAE;QACnC,UAAU;KACX,CAAC,C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nD,CAAC"}
@@ -50,6 +50,7 @@ export type { CollectionUserKeyRotationOutcome, UserKeyCascadeResult } from './u
50
50
  export type { UserKeyRosterReadResult, RosterRecipientDocument } from './userKeyRoster.js';
51
51
  export { userKeyRosterDescriptorStore } from './rosterStore.js';
52
52
  export { ensureWalletSpaceEpochs } from './spaceEpochs.js';
53
+ export type { WalletSpaceEpochsResult } from './spaceEpochs.js';
53
54
  export { readClientLabels, removeClientLabel, setClientLabel } from './clientLabels.js';
54
55
  export type { ClientLabelsRecord, ClientLabelsStore } from './clientLabels.js';
55
56
  export { wasClientLabelsStore } from './wasLabelsStore.js';