@interop/was-client 0.40.2 → 0.42.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 (96) hide show
  1. package/dist/Collection.d.ts.map +1 -1
  2. package/dist/Collection.js +27 -83
  3. package/dist/Collection.js.map +1 -1
  4. package/dist/Resource.d.ts +10 -7
  5. package/dist/Resource.d.ts.map +1 -1
  6. package/dist/Resource.js +32 -99
  7. package/dist/Resource.js.map +1 -1
  8. package/dist/codec.d.ts +12 -3
  9. package/dist/codec.d.ts.map +1 -1
  10. package/dist/codec.js.map +1 -1
  11. package/dist/edv/EdvCodec.d.ts +35 -4
  12. package/dist/edv/EdvCodec.d.ts.map +1 -1
  13. package/dist/edv/EdvCodec.js +296 -200
  14. package/dist/edv/EdvCodec.js.map +1 -1
  15. package/dist/edv/WasTransport.js +2 -2
  16. package/dist/edv/WasTransport.js.map +1 -1
  17. package/dist/edv/descriptorStore.d.ts +10 -6
  18. package/dist/edv/descriptorStore.d.ts.map +1 -1
  19. package/dist/edv/descriptorStore.js +5 -3
  20. package/dist/edv/descriptorStore.js.map +1 -1
  21. package/dist/edv/didKeyRecipient.d.ts.map +1 -1
  22. package/dist/edv/didKeyRecipient.js +1 -1
  23. package/dist/edv/didKeyRecipient.js.map +1 -1
  24. package/dist/edv/docCipher.d.ts.map +1 -1
  25. package/dist/edv/docCipher.js +11 -30
  26. package/dist/edv/docCipher.js.map +1 -1
  27. package/dist/edv/epochCrypto.d.ts +7 -0
  28. package/dist/edv/epochCrypto.d.ts.map +1 -1
  29. package/dist/edv/epochCrypto.js +12 -5
  30. package/dist/edv/epochCrypto.js.map +1 -1
  31. package/dist/edv/epochKeys.d.ts.map +1 -1
  32. package/dist/edv/epochKeys.js +21 -37
  33. package/dist/edv/epochKeys.js.map +1 -1
  34. package/dist/edv/epochRoster.d.ts +24 -0
  35. package/dist/edv/epochRoster.d.ts.map +1 -1
  36. package/dist/edv/epochRoster.js +26 -0
  37. package/dist/edv/epochRoster.js.map +1 -1
  38. package/dist/edv/recipients.d.ts +12 -10
  39. package/dist/edv/recipients.d.ts.map +1 -1
  40. package/dist/edv/recipients.js +254 -199
  41. package/dist/edv/recipients.js.map +1 -1
  42. package/dist/internal/codec.d.ts.map +1 -1
  43. package/dist/internal/codec.js +5 -18
  44. package/dist/internal/codec.js.map +1 -1
  45. package/dist/internal/conditional.d.ts +33 -2
  46. package/dist/internal/conditional.d.ts.map +1 -1
  47. package/dist/internal/conditional.js +52 -0
  48. package/dist/internal/conditional.js.map +1 -1
  49. package/dist/internal/content.d.ts +7 -0
  50. package/dist/internal/content.d.ts.map +1 -1
  51. package/dist/internal/content.js +7 -0
  52. package/dist/internal/content.js.map +1 -1
  53. package/dist/internal/features.d.ts.map +1 -1
  54. package/dist/internal/features.js +9 -9
  55. package/dist/internal/features.js.map +1 -1
  56. package/dist/internal/indexSchema.d.ts +0 -10
  57. package/dist/internal/indexSchema.d.ts.map +1 -1
  58. package/dist/internal/indexSchema.js +1 -1
  59. package/dist/internal/indexSchema.js.map +1 -1
  60. package/dist/internal/memo.d.ts +39 -0
  61. package/dist/internal/memo.d.ts.map +1 -0
  62. package/dist/internal/memo.js +59 -0
  63. package/dist/internal/memo.js.map +1 -0
  64. package/dist/internal/meta.d.ts +92 -0
  65. package/dist/internal/meta.d.ts.map +1 -0
  66. package/dist/internal/meta.js +126 -0
  67. package/dist/internal/meta.js.map +1 -0
  68. package/dist/internal/pagination.js +1 -1
  69. package/dist/internal/pagination.js.map +1 -1
  70. package/dist/internal/withCodec.d.ts +26 -0
  71. package/dist/internal/withCodec.d.ts.map +1 -0
  72. package/dist/internal/withCodec.js +15 -0
  73. package/dist/internal/withCodec.js.map +1 -0
  74. package/dist/internal/write.d.ts +5 -8
  75. package/dist/internal/write.d.ts.map +1 -1
  76. package/dist/internal/write.js +25 -11
  77. package/dist/internal/write.js.map +1 -1
  78. package/dist/log/logStore.d.ts +6 -3
  79. package/dist/log/logStore.d.ts.map +1 -1
  80. package/dist/log/logStore.js +6 -3
  81. package/dist/log/logStore.js.map +1 -1
  82. package/dist/sync/cid.d.ts.map +1 -1
  83. package/dist/sync/cid.js +1 -6
  84. package/dist/sync/cid.js.map +1 -1
  85. package/dist/sync/index.d.ts +2 -1
  86. package/dist/sync/index.d.ts.map +1 -1
  87. package/dist/sync/index.js +5 -1
  88. package/dist/sync/index.js.map +1 -1
  89. package/dist/sync/port.d.ts +0 -14
  90. package/dist/sync/port.d.ts.map +1 -1
  91. package/dist/sync/port.js +6 -19
  92. package/dist/sync/port.js.map +1 -1
  93. package/dist/sync/provisioning.d.ts.map +1 -1
  94. package/dist/sync/provisioning.js +23 -2
  95. package/dist/sync/provisioning.js.map +1 -1
  96. package/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ import type { ResourceCodec } from '../codec.js';
2
+ import type { ClientContext } from './request.js';
3
+ import type { IZcap, ResourceMetadataCustom, ResourceMetadataCustomInput } from '../types.js';
4
+ /**
5
+ * Reads a metadata document and decodes its user-writable `custom` value.
6
+ * Returns `null` when the target is missing or not visible (404 conflation
7
+ * caveat), and carries the metadata's `etag` when the backend versions it.
8
+ *
9
+ * @param context {ClientContext}
10
+ * @param options {object}
11
+ * @param options.metaPath {string} the `/meta` sub-resource path
12
+ * @param options.codec {Promise<ResourceCodec>} the resolving codec, awaited
13
+ * concurrently with the read
14
+ * @param options.subject {string} the metadata's owner as it reads in the
15
+ * malformed-response error message
16
+ * @param [options.id] {string} the resource id the metadata belongs to, for
17
+ * an encrypting codec's envelope-binding check. Omitted at Collection level.
18
+ * @param [options.capability] {IZcap}
19
+ * @returns {Promise<(Metadata & { etag?: string }) | null>}
20
+ */
21
+ export declare function readMeta<Metadata extends {
22
+ custom?: ResourceMetadataCustom;
23
+ }>(context: ClientContext, { metaPath, codec: codecPromise, subject, id, capability }: {
24
+ metaPath: string;
25
+ codec: Promise<ResourceCodec>;
26
+ subject: string;
27
+ id?: string;
28
+ capability?: IZcap;
29
+ }): Promise<(Metadata & {
30
+ etag?: string;
31
+ }) | null>;
32
+ /**
33
+ * Replaces a metadata document's user-writable `custom`, encoding it through
34
+ * the codec first (which seals it into an opaque envelope on an encrypted
35
+ * collection).
36
+ *
37
+ * @param context {ClientContext}
38
+ * @param options {object}
39
+ * @param options.metaPath {string} the `/meta` sub-resource path
40
+ * @param options.codec {Promise<ResourceCodec>} the resolving codec
41
+ * @param options.custom {ResourceMetadataCustomInput} the user-writable
42
+ * properties, as a full replacement
43
+ * @param options.sendEpoch {boolean} whether the codec's key epoch travels as
44
+ * a top-level member of this PUT body. True at Collection level, where the
45
+ * stamp describes the `custom` envelope itself; false at Resource level,
46
+ * where a Resource's epoch instead stamps its content write via the
47
+ * `Key-Epoch` header, so an epoch surfaced here is deliberately dropped.
48
+ * @param [options.id] {string} the resource id to bind the envelope to.
49
+ * Omitted at Collection level.
50
+ * @param [options.ifMatch] {string} update only if the `/meta` ETag matches
51
+ * @param [options.ifNoneMatch] {boolean} write only if no metadata is set
52
+ * @param [options.capability] {IZcap}
53
+ * @returns {Promise<{ etag?: string }>} the metadata's new ETag
54
+ */
55
+ export declare function writeMeta(context: ClientContext, { metaPath, codec: codecPromise, custom, sendEpoch, id, ifMatch, ifNoneMatch, capability }: {
56
+ metaPath: string;
57
+ codec: Promise<ResourceCodec>;
58
+ custom: ResourceMetadataCustomInput;
59
+ sendEpoch: boolean;
60
+ id?: string;
61
+ ifMatch?: string;
62
+ ifNoneMatch?: boolean;
63
+ capability?: IZcap;
64
+ }): Promise<{
65
+ etag?: string;
66
+ }>;
67
+ /**
68
+ * The shared read-then-CAS body of the handles' `setName` / `setTags`: reads
69
+ * the current metadata, merges `patch` over its `custom`, and writes it back
70
+ * pinned to the read's `etag` (when the backend supports `conditional-writes`),
71
+ * so a concurrent metadata write surfaces as `PreconditionFailedError` instead
72
+ * of being silently erased by the full-replacement write.
73
+ *
74
+ * @param handle {object} the Collection or Resource handle to patch
75
+ * @param patch {ResourceMetadataCustom} the properties to merge over the
76
+ * current `custom`
77
+ * @returns {Promise<void>}
78
+ */
79
+ export declare function patchCustom(handle: {
80
+ meta(): Promise<{
81
+ custom?: ResourceMetadataCustom;
82
+ etag?: string;
83
+ } | null>;
84
+ setMeta(meta: {
85
+ custom?: ResourceMetadataCustom;
86
+ }, options: {
87
+ ifMatch?: string;
88
+ }): Promise<{
89
+ etag?: string;
90
+ }>;
91
+ }, patch: ResourceMetadataCustom): Promise<void>;
92
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EACV,KAAK,EACL,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,SAAS;IAAE,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAAE,EAEpD,OAAO,EAAE,aAAa,EACtB,EACE,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,OAAO,EACP,EAAE,EACF,UAAU,EACX,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GACA,OAAO,CAAC,CAAC,QAAQ,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,CAuChD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,aAAa,EACtB,EACE,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,MAAM,EACN,SAAS,EACT,EAAE,EACF,OAAO,EACP,WAAW,EACX,UAAU,EACX,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7B,MAAM,EAAE,2BAA2B,CAAA;IACnC,SAAS,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GACA,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,IAAI,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,sBAAsB,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAC1E,OAAO,CACL,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,sBAAsB,CAAA;KAAE,EACzC,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9B,EACD,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -0,0 +1,126 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Shared `/meta` I/O for the Collection and Resource handles. The two read and
6
+ * write the same metadata document shape and differ only in the metadata type,
7
+ * whether the `custom` envelope is bound to a resource id, and whether the
8
+ * codec's key epoch travels in the PUT body. Each handle wraps these with its
9
+ * own JSDoc.
10
+ */
11
+ import { WasServerError } from '../errors.js';
12
+ import { send } from './request.js';
13
+ import { readEtag, writeHeaders } from './conditional.js';
14
+ import { withCodec } from './withCodec.js';
15
+ /**
16
+ * Reads a metadata document and decodes its user-writable `custom` value.
17
+ * Returns `null` when the target is missing or not visible (404 conflation
18
+ * caveat), and carries the metadata's `etag` when the backend versions it.
19
+ *
20
+ * @param context {ClientContext}
21
+ * @param options {object}
22
+ * @param options.metaPath {string} the `/meta` sub-resource path
23
+ * @param options.codec {Promise<ResourceCodec>} the resolving codec, awaited
24
+ * concurrently with the read
25
+ * @param options.subject {string} the metadata's owner as it reads in the
26
+ * malformed-response error message
27
+ * @param [options.id] {string} the resource id the metadata belongs to, for
28
+ * an encrypting codec's envelope-binding check. Omitted at Collection level.
29
+ * @param [options.capability] {IZcap}
30
+ * @returns {Promise<(Metadata & { etag?: string }) | null>}
31
+ */
32
+ export async function readMeta(context, { metaPath, codec: codecPromise, subject, id, capability }) {
33
+ // The metadata GET does not depend on the codec (only its `custom` decode
34
+ // below does), so the two overlap.
35
+ const [codec, response] = await withCodec(codecPromise, send(context, {
36
+ path: metaPath,
37
+ method: 'GET',
38
+ capability,
39
+ read: true
40
+ }));
41
+ if (response === null) {
42
+ return null;
43
+ }
44
+ if (response.data === undefined) {
45
+ // A 200 whose body `@interop/http-client` did not pre-parse into `.data`
46
+ // (a non-JSON content-type, or an empty/204 body): a metadata document
47
+ // always carries its server-managed fields as JSON, so an absent `.data`
48
+ // is a malformed response. Fail with a typed error rather than
49
+ // dereferencing `metadata.custom` off `undefined` as a raw `TypeError`.
50
+ // (Kept distinct from the `null` return, which means the target is missing
51
+ // or not visible -- not that the server answered malformed.)
52
+ throw new WasServerError(`Metadata response for ${subject} carried no JSON body ` +
53
+ `(content-type ` +
54
+ `"${response.headers.get('content-type') ?? 'unknown'}").`);
55
+ }
56
+ const metadata = response.data;
57
+ // Decode the user-writable `custom` (decrypting it on an encrypted
58
+ // collection) so callers uniformly see plaintext `{ name, tags }`. With no
59
+ // resource id -- the Collection-level read -- the slot belongs to the
60
+ // collection itself, and the encrypting codec refuses a resource-bound
61
+ // envelope served there.
62
+ const custom = await codec.decodeMeta({ custom: metadata.custom }, id);
63
+ const decoded = { ...metadata, custom };
64
+ const etag = readEtag(response);
65
+ return etag !== undefined ? { ...decoded, etag } : decoded;
66
+ }
67
+ /**
68
+ * Replaces a metadata document's user-writable `custom`, encoding it through
69
+ * the codec first (which seals it into an opaque envelope on an encrypted
70
+ * collection).
71
+ *
72
+ * @param context {ClientContext}
73
+ * @param options {object}
74
+ * @param options.metaPath {string} the `/meta` sub-resource path
75
+ * @param options.codec {Promise<ResourceCodec>} the resolving codec
76
+ * @param options.custom {ResourceMetadataCustomInput} the user-writable
77
+ * properties, as a full replacement
78
+ * @param options.sendEpoch {boolean} whether the codec's key epoch travels as
79
+ * a top-level member of this PUT body. True at Collection level, where the
80
+ * stamp describes the `custom` envelope itself; false at Resource level,
81
+ * where a Resource's epoch instead stamps its content write via the
82
+ * `Key-Epoch` header, so an epoch surfaced here is deliberately dropped.
83
+ * @param [options.id] {string} the resource id to bind the envelope to.
84
+ * Omitted at Collection level.
85
+ * @param [options.ifMatch] {string} update only if the `/meta` ETag matches
86
+ * @param [options.ifNoneMatch] {boolean} write only if no metadata is set
87
+ * @param [options.capability] {IZcap}
88
+ * @returns {Promise<{ etag?: string }>} the metadata's new ETag
89
+ */
90
+ export async function writeMeta(context, { metaPath, codec: codecPromise, custom, sendEpoch, id, ifMatch, ifNoneMatch, capability }) {
91
+ const codec = await codecPromise;
92
+ const { custom: encoded, epoch } = await codec.encodeMeta(id !== undefined ? { custom, id } : { custom });
93
+ const response = await send(context, {
94
+ path: metaPath,
95
+ method: 'PUT',
96
+ capability,
97
+ // The key epoch travels in the body here, not in the `Key-Epoch` header:
98
+ // the header channel stamps a Resource's *content* write, while the
99
+ // Collection metadata stamp describes the `custom` envelope itself and is
100
+ // a top-level member of this PUT body. The server clears the stored stamp
101
+ // when the member is omitted -- which is exactly right on a plaintext
102
+ // collection, whose codec surfaces no epoch.
103
+ json: sendEpoch && epoch !== undefined
104
+ ? { custom: encoded, epoch }
105
+ : { custom: encoded },
106
+ headers: writeHeaders({ precondition: { ifMatch, ifNoneMatch } })
107
+ });
108
+ return { etag: readEtag(response) };
109
+ }
110
+ /**
111
+ * The shared read-then-CAS body of the handles' `setName` / `setTags`: reads
112
+ * the current metadata, merges `patch` over its `custom`, and writes it back
113
+ * pinned to the read's `etag` (when the backend supports `conditional-writes`),
114
+ * so a concurrent metadata write surfaces as `PreconditionFailedError` instead
115
+ * of being silently erased by the full-replacement write.
116
+ *
117
+ * @param handle {object} the Collection or Resource handle to patch
118
+ * @param patch {ResourceMetadataCustom} the properties to merge over the
119
+ * current `custom`
120
+ * @returns {Promise<void>}
121
+ */
122
+ export async function patchCustom(handle, patch) {
123
+ const current = await handle.meta();
124
+ await handle.setMeta({ custom: { ...current?.custom, ...patch } }, { ifMatch: current?.etag });
125
+ }
126
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAG5B,OAAsB,EACtB,EACE,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,OAAO,EACP,EAAE,EACF,UAAU,EAOX;IAED,0EAA0E;IAC1E,mCAAmC;IACnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,MAAM,SAAS,CACvC,YAAY,EACZ,IAAI,CAAC,OAAO,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;QACb,UAAU;QACV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AK,EAAE,GAAG,MAAM,KAAK,CAAC,UAAU,CACvD,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAC/C,CAAA;IACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;QACb,UAAU;QACV,yEAAyE;QACzE,oEAAoE;QACpE,0EAA0E;QAC1E,0EAA0E;QAC1E,sEAAsE;QACtE,6CAA6C;QAC7C,IAAI,EACF,SAAS,IAAI,KAAK,KAAK,SAAS;YAC9B,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;YAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE;QACzB,OAAO,EAAE,YAAY,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;KAClE,CAAC,CAAA;IACF,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAMC,EACD,KAA6B;IAE7B,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;IACnC,MAAM,MAAM,CAAC,OAAO,CAClB,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,EAC5C,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAC3B,CAAA;AACH,CAAC"}
@@ -86,7 +86,7 @@ export async function collectPages(walk) {
86
86
  for await (const page of walkPages(walk)) {
87
87
  aggregate ??= page;
88
88
  // Append one by one: spreading a page's items as call arguments would hit
89
- // the engine's max-arguments ceiling on a very large page.
89
+ // the engine's max-arguments limit on a very large page.
90
90
  for (const item of page.items) {
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ACzC,SAAS,KAAK,IAAI,CAAA;QAClB,0EAA0E;QAC1E,yDAAyD;QACzD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;IACD,iEAAiE;IACjE,MAAM,MAAM,GAAM,EAAE,GAAG,SAAU,EAAE,KAAK,EAAE,CAAA;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAA;IAClB,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAE/B,IAAwB;IACxB,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,gBAAgB,CAErC,IAAwB;IACxB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,SAAS,CAC9B,KAA6C;IAE7C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Overlaps codec resolution with the signed request it decodes, which every
6
+ * read on a handle needs: the request is the same whatever the codec turns out
7
+ * to be, so the two round trips are independent and there is no reason to pay
8
+ * for them in series.
9
+ *
10
+ * The await order is the load-bearing part. The codec is awaited first so a
11
+ * codec failure takes precedence over a read failure, and the no-op handler
12
+ * attached to the request keeps an abandoned read from surfacing as an
13
+ * unhandled rejection when the codec throws. The request is still awaited
14
+ * afterwards, so its own error is never swallowed.
15
+ */
16
+ import type { ResourceCodec } from '../codec.js';
17
+ /**
18
+ * Runs a codec resolution and an independent request concurrently, returning
19
+ * both once they settle.
20
+ *
21
+ * @param codecPromise {Promise<ResourceCodec>} the codec being resolved
22
+ * @param responsePromise {Promise<Response>} the request to overlap with it
23
+ * @returns {Promise<[ResourceCodec, Response]>}
24
+ */
25
+ export declare function withCodec<Response>(codecPromise: Promise<ResourceCodec>, responsePromise: Promise<Response>): Promise<[ResourceCodec, Response]>;
26
+ //# sourceMappingURL=withCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCodec.d.ts","sourceRoot":"","sources":["../../src/internal/withCodec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EACtC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,EACpC,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAKpC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Runs a codec resolution and an independent request concurrently, returning
3
+ * both once they settle.
4
+ *
5
+ * @param codecPromise {Promise<ResourceCodec>} the codec being resolved
6
+ * @param responsePromise {Promise<Response>} the request to overlap with it
7
+ * @returns {Promise<[ResourceCodec, Response]>}
8
+ */
9
+ export async function withCodec(codecPromise, responsePromise) {
10
+ responsePromise.catch(() => { });
11
+ const codec = await codecPromise;
12
+ const response = await responsePromise;
13
+ return [codec, response];
14
+ }
15
+ //# sourceMappingURL=withCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCodec.js","sourceRoot":"","sources":["../../src/internal/withCodec.ts"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,YAAoC,EACpC,eAAkC;IAElC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC/B,MAAM,KAAK,GAAG,MAAM,YAAY,CAAA;IAChC,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAA;IACtC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AAC1B,CAAC"}
@@ -100,10 +100,10 @@ export type InsertOutcome = {
100
100
  *
101
101
  * A codec that mints its own id (e.g. the encrypting codec's EDV id) writes it
102
102
  * by `PUT` to that id's path; a codec that mints none (the identity codec)
103
- * `POST`s to the items path and lets the server mint one. As in
104
- * {@link upsertResource}, a conditional codec computes the precondition itself
105
- * (the EDV codec guards its fresh insert with `If-None-Match: *`) and a
106
- * non-conditional one defers to the caller's explicit precondition.
103
+ * `POST`s to the items path and lets the server mint one. A conditional codec
104
+ * computes the precondition itself (the EDV codec guards its fresh insert with
105
+ * `If-None-Match: *`); an insert through a non-conditional codec is
106
+ * unconditional, since `add()` names no target revision to pin against.
107
107
  *
108
108
  * Returns the codec's encoded write and the path actually written alongside the
109
109
  * response, so the caller can shape its result (the created id and URL) without
@@ -122,11 +122,9 @@ export type InsertOutcome = {
122
122
  * no extra round trip
123
123
  * @param [options.contentType] {string} caller-supplied content type
124
124
  * @param [options.capability] {IZcap}
125
- * @param [options.precondition] {WritePrecondition} the caller's explicit
126
- * precondition (used only for a non-conditional codec)
127
125
  * @returns {Promise<InsertOutcome>}
128
126
  */
129
- export declare function insertResource(context: ClientContext, { itemsPath, pathForId, codec, data, features, contentType, capability, precondition }: {
127
+ export declare function insertResource(context: ClientContext, { itemsPath, pathForId, codec, data, features, contentType, capability }: {
130
128
  itemsPath: string;
131
129
  pathForId: (id: string) => string;
132
130
  codec: ResourceCodec;
@@ -134,7 +132,6 @@ export declare function insertResource(context: ClientContext, { itemsPath, path
134
132
  features: FeatureProbe;
135
133
  contentType?: string;
136
134
  capability?: IZcap;
137
- precondition?: WritePrecondition;
138
135
  }): Promise<InsertOutcome>;
139
136
  /**
140
137
  * Creates or replaces a resource by id (upsert) through its codec, owning the
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACd,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,aAAa,EACtB,EACE,IAAI,EACJ,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EACb,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,YAAY,CAAA;IACrB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC,GACA,OAAO,CAAC,YAAY,CAAC,CAcvB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACvE,mBAAmB,CAUrB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;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,iBAAiB,CAAA;CACjC,GACA,OAAO,CAAC,YAAY,CAAC,CA2FvB"}
@@ -1,7 +1,7 @@
1
1
  import { isChunkedWrite } from '../codec.js';
2
2
  import { PreconditionFailedError, ValidationError } from '../errors.js';
3
3
  import { send } from './request.js';
4
- import { encodedPrecondition, writeHeaders } from './conditional.js';
4
+ import { assertPreconditionAgainstPreRead, encodedPrecondition, writeHeaders } from './conditional.js';
5
5
  /**
6
6
  * Sends an encoded write (`PUT`/`POST`) to a resource path, applying the
7
7
  * encoded body (`json` or `body`), its content-type, and the conditional-write
@@ -75,10 +75,10 @@ export function codecRequestContext(context, { features, capability }) {
75
75
  *
76
76
  * A codec that mints its own id (e.g. the encrypting codec's EDV id) writes it
77
77
  * by `PUT` to that id's path; a codec that mints none (the identity codec)
78
- * `POST`s to the items path and lets the server mint one. As in
79
- * {@link upsertResource}, a conditional codec computes the precondition itself
80
- * (the EDV codec guards its fresh insert with `If-None-Match: *`) and a
81
- * non-conditional one defers to the caller's explicit precondition.
78
+ * `POST`s to the items path and lets the server mint one. A conditional codec
79
+ * computes the precondition itself (the EDV codec guards its fresh insert with
80
+ * `If-None-Match: *`); an insert through a non-conditional codec is
81
+ * unconditional, since `add()` names no target revision to pin against.
82
82
  *
83
83
  * Returns the codec's encoded write and the path actually written alongside the
84
84
  * response, so the caller can shape its result (the created id and URL) without
@@ -97,11 +97,9 @@ export function codecRequestContext(context, { features, capability }) {
97
97
  * no extra round trip
98
98
  * @param [options.contentType] {string} caller-supplied content type
99
99
  * @param [options.capability] {IZcap}
100
- * @param [options.precondition] {WritePrecondition} the caller's explicit
101
- * precondition (used only for a non-conditional codec)
102
100
  * @returns {Promise<InsertOutcome>}
103
101
  */
104
- export async function insertResource(context, { itemsPath, pathForId, codec, data, features, contentType, capability, precondition }) {
102
+ export async function insertResource(context, { itemsPath, pathForId, codec, data, features, contentType, capability }) {
105
103
  const write = await codec.encode({ data, contentType });
106
104
  if (isChunkedWrite(write)) {
107
105
  const { id, etag } = await write.execute(codecRequestContext(context, { features, capability }));
@@ -116,7 +114,7 @@ export async function insertResource(context, { itemsPath, pathForId, codec, dat
116
114
  const encoded = write;
117
115
  const chosen = codec.conditionalWrites
118
116
  ? encodedPrecondition(encoded)
119
- : precondition;
117
+ : undefined;
120
118
  const path = encoded.id !== undefined ? pathForId(encoded.id) : itemsPath;
121
119
  const response = await sendEncodedWrite(context, {
122
120
  path,
@@ -173,6 +171,10 @@ export async function upsertResource(context, { path, codec, id, data, features,
173
171
  capability,
174
172
  read: true
175
173
  });
174
+ // The caller's own compare-and-swap baseline is checked against what the
175
+ // pre-read just observed, so a lost race fails here rather than being
176
+ // encoded into a sequence advance the server would then reject.
177
+ assertPreconditionAgainstPreRead({ path, current, precondition });
176
178
  if (current === null && !(await features.has('conditional-writes'))) {
177
179
  // The write would be encoded as a fresh insert guarded only by
178
180
  // `If-None-Match: *`, which this backend ignores -- so if the document in
@@ -190,7 +192,18 @@ export async function upsertResource(context, { path, codec, id, data, features,
190
192
  'descriptor, or add() to mint a fresh document id.');
191
193
  }
192
194
  }
193
- const write = await codec.encode({ id, data, contentType, current });
195
+ const write = await codec.encode({
196
+ id,
197
+ data,
198
+ contentType,
199
+ current,
200
+ // Hand a conditional codec the caller's baseline so it pins the write to
201
+ // that revision instead of to the one its own pre-read observed.
202
+ ...(codec.conditionalWrites &&
203
+ precondition !== undefined && {
204
+ precondition
205
+ })
206
+ });
194
207
  if (isChunkedWrite(write)) {
195
208
  // Auto-routing is an insert-path affordance: a write by id would have to
196
209
  // reconcile the existing stored parts (and the codec's sequence) with the
@@ -204,7 +217,8 @@ export async function upsertResource(context, { path, codec, id, data, features,
204
217
  }
205
218
  const encoded = write;
206
219
  // A conditional codec computes the precondition itself (from the sequence /
207
- // ETag); a plaintext codec defers to the caller's explicit options.
220
+ // ETag, or from the caller's baseline handed to `encode` above); a plaintext
221
+ // codec defers to the caller's explicit options.
208
222
  const chosen = codec.conditionalWrites
209
223
  ? encodedPrecondition(encoded)
210
224
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,GAAG,KAAK,CAAA;IACrB,4EAA4E;IAC5E,6EAA6E;IAC7E,iDAAiD;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,iBAAiB;QACpC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;QAC9B,CAAC,CAAC,YAAY,CAAA;IAChB,IAAI,CAAC;QACH,OAAO,MAAM,gBAAgB,CAAC,OAAO,EAAE;YACrC,IAAI;YACJ,MAAM,EAAE,KAAK;YACb,UAAU;YACV,OAAO;YACP,YAAY,EAAE,MAAM;SACrB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IACE,GAAG,YAAY,uBAAuB;YACtC,KAAK,CAAC,iBAAiB;YACvB,OAAO,KAAK,IAAI,EAChB,CAAC;YACD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YACxD,MAAM,IAAI,uBAAuB,CAC/B,kCAAkC,IAAI,gCAAgC;gBACpE,0DAA0D;gBAC1D,kEAAkE;gBAClE,gEAAgE;gBAChE,+DAA+D;gBAC/D,WAAW,EACb,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CACzD,CAAA;QACH,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
@@ -58,9 +58,12 @@ export interface ResourceLogStore {
58
58
  }
59
59
  /**
60
60
  * The WAS Resource adapter: the log is the resource's entire body, stored as
61
- * `text/jsonl`. Host the resource in a plaintext collection -- on an encrypted
62
- * collection the EDV codec computes the write preconditions itself, so this
63
- * store's `ifMatch` / create guard would not be honored.
61
+ * `text/jsonl`. The hosting collection may be plaintext or encrypted: a
62
+ * conditional codec pins the write to the `ifMatch` this store passes rather
63
+ * than to the ETag its own pre-read observed, so the append profile's
64
+ * compare-and-swap holds either way. On an encrypted host the resource id must
65
+ * be one the codec mints, since the EDV codec refuses to create a document
66
+ * under a human-readable id.
64
67
  *
65
68
  * @param options {object}
66
69
  * @param options.resource {Resource}
@@ -1 +1 @@
1
- {"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAU9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAEtE;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5E;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAA;CACnB,GAAG,gBAAgB,CAmDnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,KAAK,EACN,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAA;IACvB,KAAK,EAAE,gBAAgB,CAAA;CACxB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuB1D"}
1
+ {"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAU9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAEtE;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5E;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAA;CACnB,GAAG,gBAAgB,CAmDnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,KAAK,EACN,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAA;IACvB,KAAK,EAAE,gBAAgB,CAAA;CACxB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuB1D"}
@@ -32,9 +32,12 @@ import { parseResourceLog, serializeResourceLog, serializeResourceLogEntry } fro
32
32
  export const LOG_CONTENT_TYPE = 'text/jsonl';
33
33
  /**
34
34
  * The WAS Resource adapter: the log is the resource's entire body, stored as
35
- * `text/jsonl`. Host the resource in a plaintext collection -- on an encrypted
36
- * collection the EDV codec computes the write preconditions itself, so this
37
- * store's `ifMatch` / create guard would not be honored.
35
+ * `text/jsonl`. The hosting collection may be plaintext or encrypted: a
36
+ * conditional codec pins the write to the `ifMatch` this store passes rather
37
+ * than to the ETag its own pre-read observed, so the append profile's
38
+ * compare-and-swap holds either way. On an encrypted host the resource id must
39
+ * be one the codec mints, since the EDV codec refuses to create a document
40
+ * under a human-readable id.
38
41
  *
39
42
  * @param options {object}
40
43
  * @param options.resource {Resource}
@@ -1 +1 @@
1
- {"version":3,"file":"logStore.js","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA;AAkD5C;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EAGT;IACC,yEAAyE;IACzE,6EAA6E;IAC7E,oEAAoE;IACpE,2CAA2C;IAC3C,IAAI,YAAgC,CAAA;IACpC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAA;YAC5C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACrB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CA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,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,oBAAoB,CAC5B,oEAAoE;YAClE,YAAY,CACf,CAAA;IACH,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,CAAA;IAC3C,IAAI,MAAM,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,CAAC,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,oBAAoB,CAC5B,qEAAqE;YACnE,iCAAiC,OAAO,GAAG,CAC9C,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../src/sync/cid.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AASvC;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE3D"}
1
+ {"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../src/sync/cid.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE3D"}
package/dist/sync/cid.js CHANGED
@@ -19,12 +19,7 @@
19
19
  import { sha256 } from '@noble/hashes/sha2.js';
20
20
  import { base64urlnopad } from '@scure/base';
21
21
  import { canonicalize } from 'json-canonicalize';
22
- /**
23
- * The one UTF-8 encoder every derivation here shares: hashing runs on the
24
- * per-document hot path, so the encoder is allocated once for the module rather
25
- * than per call. `TextEncoder` is stateless, so reuse is safe.
26
- */
27
- const ENCODER = new TextEncoder();
22
+ import { ENCODER } from '../internal/content.js';
28
23
  /**
29
24
  * Derives a document's content id: `base64url(SHA-256(utf8(canonicalize(doc))))`,
30
25
  * no padding. Byte-identical across replicas for the same logical document, so a
@@ -1 +1 @@
1
- {"version":3,"file":"cid.js","sourceRoot":"","sources":["../../src/sync/cid.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD;;;;GAIG;AACH,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,GAAS;IAClC,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,GAAG,EAAmB;IAC9C,OAAO,UAAU,CAAC,GAAW,CAAC,CAAA;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC"}
1
+ {"version":3,"file":"cid.js","sourceRoot":"","sources":["../../src/sync/cid.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGhD;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,GAAS;IAClC,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,GAAG,EAAmB;IAC9C,OAAO,UAAU,CAAC,GAAW,CAAC,CAAA;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC"}
@@ -27,7 +27,8 @@
27
27
  * reader holds no key for it, so a refresh cannot help). `EncryptionError`, the
28
28
  * fail-closed umbrella `KeyUnwrapError` falls under, rides along.
29
29
  */
30
- export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag, errorStatus, errorMessage } from './port.js';
30
+ export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag } from './port.js';
31
+ export { httpStatus as errorStatus, errorMessage } from '../errors.js';
31
32
  export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
32
33
  export { isEncryptedEnvelope } from './envelope.js';
33
34
  export { createPlaintextDocCipher } from './plaintextCipher.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,IAAI,EACJ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACV,MAAM,WAAW,CAAA;AAIlB,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,IAAI,EACJ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAA"}
@@ -27,7 +27,11 @@
27
27
  * reader holds no key for it, so a refresh cannot help). `EncryptionError`, the
28
28
  * fail-closed umbrella `KeyUnwrapError` falls under, rides along.
29
29
  */
30
- export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag, errorStatus, errorMessage } from './port.js';
30
+ export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag } from './port.js';
31
+ // The sync subpath's names for the client's own error accessors, so a
32
+ // sync-only consumer reads a raw ky/ezcap failure without importing the core
33
+ // entry.
34
+ export { httpStatus as errorStatus, errorMessage } from '../errors.js';
31
35
  export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
32
36
  export { isEncryptedEnvelope } from './envelope.js';
33
37
  export { createPlaintextDocCipher } from './plaintextCipher.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACV,MAAM,WAAW,CAAA;AAClB,sEAAsE;AACtE,6EAA6E;AAC7E,SAAS;AACT,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA"}
@@ -27,7 +27,6 @@
27
27
  */
28
28
  import type { WasClient } from '../WasClient.js';
29
29
  import { KEY_EPOCH_HEADER } from '../internal/conditional.js';
30
- import { errorMessage, httpStatus } from '../errors.js';
31
30
  import type { IZcap } from '../types.js';
32
31
  import type { WasSyncPort } from './types.js';
33
32
  /**
@@ -37,19 +36,6 @@ import type { WasSyncPort } from './types.js';
37
36
  * of the sync subpath's public surface.
38
37
  */
39
38
  export { KEY_EPOCH_HEADER };
40
- /**
41
- * Extracts an HTTP status from a raw ky/ezcap error. `was.request()` rejects on
42
- * any non-2xx with `err.status` set; this reads it defensively from either the
43
- * flat `status` or the nested `response.status` shape. The sync subpath's name
44
- * for the client's own {@link httpStatus}.
45
- */
46
- export declare const errorStatus: typeof httpStatus;
47
- /**
48
- * Normalizes an unknown caught error into a display string. The sync subpath's
49
- * name for the client's own {@link errorMessage}, the companion to
50
- * {@link errorStatus}.
51
- */
52
- export { errorMessage };
53
39
  /**
54
40
  * Formats a numeric content `version` as the quoted strong `ETag` an
55
41
  * update-if-unchanged write passes as its `ifMatch` precondition (e.g. `3` to