@happyvertical/smrt-core 0.55.6 → 0.55.8

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 (205) hide show
  1. package/AGENTS.md +2 -1
  2. package/agents/browser-entry.md +44 -0
  3. package/agents/build-knowledge.md +20 -0
  4. package/agents/recipes.md +217 -0
  5. package/agents/revision-guard.md +72 -1
  6. package/dist/audit-context.d.ts.map +1 -1
  7. package/dist/audit-context.js +2 -2
  8. package/dist/audit-context.js.map +1 -1
  9. package/dist/browser.d.ts +2 -1
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +7 -7
  12. package/dist/cascade.d.ts +1 -1
  13. package/dist/cascade.d.ts.map +1 -1
  14. package/dist/cascade.js +1 -1
  15. package/dist/cascade.js.map +1 -1
  16. package/dist/change-feed.d.ts.map +1 -1
  17. package/dist/change-feed.js +1 -2
  18. package/dist/change-feed.js.map +1 -1
  19. package/dist/class.d.ts +1 -1
  20. package/dist/class.d.ts.map +1 -1
  21. package/dist/class.js +7 -3
  22. package/dist/class.js.map +1 -1
  23. package/dist/collection.d.ts.map +1 -1
  24. package/dist/collection.js +1 -1
  25. package/dist/collection.js.map +1 -1
  26. package/dist/consumer-plugin/index.js +2 -2
  27. package/dist/data-query.d.ts.map +1 -1
  28. package/dist/data-query.js +2 -13
  29. package/dist/data-query.js.map +1 -1
  30. package/dist/database.js +1 -1
  31. package/dist/database.js.map +1 -1
  32. package/dist/dispatch/bus.js +1 -1
  33. package/dist/dispatch/bus.js.map +1 -1
  34. package/dist/embedded-write-queue.d.ts +1 -1
  35. package/dist/embedded-write-queue.d.ts.map +1 -1
  36. package/dist/embedded-write-queue.js +7 -5
  37. package/dist/embedded-write-queue.js.map +1 -1
  38. package/dist/embeddings/hash.js +2 -2
  39. package/dist/embeddings/hash.js.map +1 -1
  40. package/dist/embeddings/storage.d.ts.map +1 -1
  41. package/dist/embeddings/storage.js +1 -2
  42. package/dist/embeddings/storage.js.map +1 -1
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +1 -0
  45. package/dist/errors.js.map +1 -1
  46. package/dist/generation-snapshot.js +1 -1
  47. package/dist/generators/index.js +1 -1
  48. package/dist/generators/mcp.js +3 -3
  49. package/dist/generators/preflight-route.js +1 -1
  50. package/dist/generators/rest.js +1 -1
  51. package/dist/generators.js +1 -1
  52. package/dist/host.browser.d.ts +12 -0
  53. package/dist/host.browser.d.ts.map +1 -0
  54. package/dist/host.browser.js +30 -0
  55. package/dist/host.browser.js.map +1 -0
  56. package/dist/host.d.ts +18 -0
  57. package/dist/host.d.ts.map +1 -0
  58. package/dist/host.js +15 -0
  59. package/dist/host.js.map +1 -0
  60. package/dist/index.d.ts +1 -0
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +10 -9
  63. package/dist/knowledge.d.ts.map +1 -1
  64. package/dist/knowledge.js +6 -4
  65. package/dist/knowledge.js.map +1 -1
  66. package/dist/manifest/browser-capability.generated.d.ts +14 -0
  67. package/dist/manifest/browser-capability.generated.d.ts.map +1 -0
  68. package/dist/manifest/browser-capability.generated.js +499 -0
  69. package/dist/manifest/browser-capability.generated.js.map +1 -0
  70. package/dist/manifest/discover-base-classes.js +1 -1
  71. package/dist/manifest/discover-smrt-packages.js +1 -1
  72. package/dist/manifest/generator.js +3 -3
  73. package/dist/manifest/index.js +2 -2
  74. package/dist/manifest/local-manifest-reader.d.ts +48 -0
  75. package/dist/manifest/local-manifest-reader.d.ts.map +1 -0
  76. package/dist/manifest/local-manifest-reader.js +81 -0
  77. package/dist/manifest/local-manifest-reader.js.map +1 -0
  78. package/dist/manifest/manager.d.ts +5 -28
  79. package/dist/manifest/manager.d.ts.map +1 -1
  80. package/dist/manifest/manager.js +10 -56
  81. package/dist/manifest/manager.js.map +1 -1
  82. package/dist/manifest/manifest-loader.d.ts +1 -1
  83. package/dist/manifest/manifest-loader.d.ts.map +1 -1
  84. package/dist/manifest/manifest-loader.js +43 -12
  85. package/dist/manifest/manifest-loader.js.map +1 -1
  86. package/dist/manifest/node-host.d.ts +38 -0
  87. package/dist/manifest/node-host.d.ts.map +1 -0
  88. package/dist/manifest/node-host.js +52 -0
  89. package/dist/manifest/node-host.js.map +1 -0
  90. package/dist/manifest/package-manifest-exports.js +1 -1
  91. package/dist/manifest/static-manifest.d.ts.map +1 -1
  92. package/dist/manifest/static-manifest.js +12 -2
  93. package/dist/manifest/static-manifest.js.map +1 -1
  94. package/dist/manifest/store.d.ts +2 -1
  95. package/dist/manifest/store.d.ts.map +1 -1
  96. package/dist/manifest/store.js +7 -4
  97. package/dist/manifest/store.js.map +1 -1
  98. package/dist/manifest.js +1 -1
  99. package/dist/manifest.json +14 -2
  100. package/dist/native-duckdb.d.ts +28 -0
  101. package/dist/native-duckdb.d.ts.map +1 -0
  102. package/dist/native-duckdb.js +51 -0
  103. package/dist/native-duckdb.js.map +1 -0
  104. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js +169 -0
  105. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js.map +1 -0
  106. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js +13 -0
  107. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js.map +1 -0
  108. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js +198 -0
  109. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js.map +1 -0
  110. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js +243 -0
  111. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js.map +1 -0
  112. package/dist/object.d.ts +56 -0
  113. package/dist/object.d.ts.map +1 -1
  114. package/dist/object.js +139 -16
  115. package/dist/object.js.map +1 -1
  116. package/dist/postgres-permissions.d.ts.map +1 -1
  117. package/dist/postgres-permissions.js +3 -3
  118. package/dist/postgres-permissions.js.map +1 -1
  119. package/dist/prebuild/index.js +1 -1
  120. package/dist/recipe-demo.d.ts +70 -0
  121. package/dist/recipe-demo.d.ts.map +1 -0
  122. package/dist/recipe-demo.js +130 -0
  123. package/dist/recipe-demo.js.map +1 -0
  124. package/dist/recipe.d.ts +64 -1
  125. package/dist/recipe.d.ts.map +1 -1
  126. package/dist/recipe.js +30 -0
  127. package/dist/recipe.js.map +1 -1
  128. package/dist/registry/class-registration.js +2 -2
  129. package/dist/registry/class-registration.js.map +1 -1
  130. package/dist/registry/db-cache-key.js +4 -5
  131. package/dist/registry/db-cache-key.js.map +1 -1
  132. package/dist/registry/inheritance-resolver.js +1 -1
  133. package/dist/registry/name-resolver.js +1 -1
  134. package/dist/registry/qualified-name-aliases.js +1 -1
  135. package/dist/registry/schema-builder.d.ts.map +1 -1
  136. package/dist/registry/schema-builder.js +3 -3
  137. package/dist/registry/schema-builder.js.map +1 -1
  138. package/dist/registry/types.d.ts +5 -0
  139. package/dist/registry/types.d.ts.map +1 -1
  140. package/dist/registry.d.ts.map +1 -1
  141. package/dist/registry.js +5 -8
  142. package/dist/registry.js.map +1 -1
  143. package/dist/revision-guard.js +1 -1
  144. package/dist/revision-guard.js.map +1 -1
  145. package/dist/scanner/manifest-generator.d.ts.map +1 -1
  146. package/dist/scanner/manifest-generator.js +19 -10
  147. package/dist/scanner/manifest-generator.js.map +1 -1
  148. package/dist/scanner/recipe-demo-pass.d.ts +14 -0
  149. package/dist/scanner/recipe-demo-pass.d.ts.map +1 -0
  150. package/dist/scanner/recipe-demo-pass.js +33 -0
  151. package/dist/scanner/recipe-demo-pass.js.map +1 -0
  152. package/dist/scanner/types.d.ts +9 -1
  153. package/dist/scanner/types.d.ts.map +1 -1
  154. package/dist/scanner/types.js.map +1 -1
  155. package/dist/schema/ddl/duckdb-strategy.d.ts.map +1 -1
  156. package/dist/schema/ddl/duckdb-strategy.js +1 -1
  157. package/dist/schema/ddl/duckdb-strategy.js.map +1 -1
  158. package/dist/schema/foreign-key-planner.d.ts.map +1 -1
  159. package/dist/schema/foreign-key-planner.js +1 -1
  160. package/dist/schema/foreign-key-planner.js.map +1 -1
  161. package/dist/schema/generator.d.ts.map +1 -1
  162. package/dist/schema/generator.js +10 -14
  163. package/dist/schema/generator.js.map +1 -1
  164. package/dist/schema/schema-aggregator.js +1 -1
  165. package/dist/scripts/browser-entry-evaluation.mjs +157 -0
  166. package/dist/smrt-knowledge.json +32 -12
  167. package/dist/system/browser.d.ts +16 -0
  168. package/dist/system/browser.d.ts.map +1 -0
  169. package/dist/system/browser.js +6 -0
  170. package/dist/system/index.d.ts +1 -6
  171. package/dist/system/index.d.ts.map +1 -1
  172. package/dist/system/index.js +2 -1
  173. package/dist/testing/database.js +1 -1
  174. package/dist/tools/index.js +1 -1
  175. package/dist/unchanged-indexed.d.ts +85 -0
  176. package/dist/unchanged-indexed.d.ts.map +1 -0
  177. package/dist/unchanged-indexed.js +219 -0
  178. package/dist/unchanged-indexed.js.map +1 -0
  179. package/dist/utils/async-context.d.ts +22 -0
  180. package/dist/utils/async-context.d.ts.map +1 -0
  181. package/dist/utils/async-context.js +27 -0
  182. package/dist/utils/async-context.js.map +1 -0
  183. package/dist/utils/import-project-vite.js +1 -1
  184. package/dist/utils/import-workspace-module.js +1 -1
  185. package/dist/utils/json.browser.d.ts +18 -0
  186. package/dist/utils/json.browser.d.ts.map +1 -0
  187. package/dist/utils/json.browser.js +47 -0
  188. package/dist/utils/json.browser.js.map +1 -0
  189. package/dist/utils/sha256.d.ts +15 -0
  190. package/dist/utils/sha256.d.ts.map +1 -0
  191. package/dist/utils/sha256.js +29 -0
  192. package/dist/utils/sha256.js.map +1 -0
  193. package/dist/vite-plugin/changes-route.js +1 -1
  194. package/dist/vite-plugin/dev-plane-route.js +1 -1
  195. package/dist/vite-plugin/events-route.js +1 -1
  196. package/dist/vite-plugin/import-build-aware.js +1 -1
  197. package/dist/vite-plugin/index.js +2 -2
  198. package/dist/vite-plugin/resources-route.js +1 -1
  199. package/dist/vite-plugin/sveltekit-generator.js +2 -2
  200. package/dist/vite-plugin/sveltekit-path.js +1 -1
  201. package/dist/vite-plugin/sveltekit-register-injection.js +1 -1
  202. package/dist/vite-plugin/sveltekit-route-coordinator.js +1 -1
  203. package/dist/vite-plugin/sync-apply-route.js +1 -1
  204. package/dist/vite-plugin/web-collections.js +2 -2
  205. package/package.json +21 -11
@@ -0,0 +1,198 @@
1
+ import { clean, createHasher, oidNist, rotr } from "./utils.js";
2
+ import { Chi, HashMD, Maj, SHA256_IV } from "./_md.js";
3
+ //#region ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha2.js
4
+ /**
5
+ * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
6
+ * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
7
+ * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and
8
+ * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.
9
+ * @module
10
+ */
11
+ /**
12
+ * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits
13
+ * of the cube roots of the first 64 primes (2..311).
14
+ */
15
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
16
+ 1116352408,
17
+ 1899447441,
18
+ 3049323471,
19
+ 3921009573,
20
+ 961987163,
21
+ 1508970993,
22
+ 2453635748,
23
+ 2870763221,
24
+ 3624381080,
25
+ 310598401,
26
+ 607225278,
27
+ 1426881987,
28
+ 1925078388,
29
+ 2162078206,
30
+ 2614888103,
31
+ 3248222580,
32
+ 3835390401,
33
+ 4022224774,
34
+ 264347078,
35
+ 604807628,
36
+ 770255983,
37
+ 1249150122,
38
+ 1555081692,
39
+ 1996064986,
40
+ 2554220882,
41
+ 2821834349,
42
+ 2952996808,
43
+ 3210313671,
44
+ 3336571891,
45
+ 3584528711,
46
+ 113926993,
47
+ 338241895,
48
+ 666307205,
49
+ 773529912,
50
+ 1294757372,
51
+ 1396182291,
52
+ 1695183700,
53
+ 1986661051,
54
+ 2177026350,
55
+ 2456956037,
56
+ 2730485921,
57
+ 2820302411,
58
+ 3259730800,
59
+ 3345764771,
60
+ 3516065817,
61
+ 3600352804,
62
+ 4094571909,
63
+ 275423344,
64
+ 430227734,
65
+ 506948616,
66
+ 659060556,
67
+ 883997877,
68
+ 958139571,
69
+ 1322822218,
70
+ 1537002063,
71
+ 1747873779,
72
+ 1955562222,
73
+ 2024104815,
74
+ 2227730452,
75
+ 2361852424,
76
+ 2428436474,
77
+ 2756734187,
78
+ 3204031479,
79
+ 3329325298
80
+ ]);
81
+ /** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */
82
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
83
+ /** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */
84
+ var SHA2_32B = class extends HashMD {
85
+ A = 0;
86
+ B = 0;
87
+ C = 0;
88
+ D = 0;
89
+ E = 0;
90
+ F = 0;
91
+ G = 0;
92
+ H = 0;
93
+ constructor(outputLen, IV) {
94
+ super(64, outputLen, 8, false);
95
+ this.A = IV[0] | 0;
96
+ this.B = IV[1] | 0;
97
+ this.C = IV[2] | 0;
98
+ this.D = IV[3] | 0;
99
+ this.E = IV[4] | 0;
100
+ this.F = IV[5] | 0;
101
+ this.G = IV[6] | 0;
102
+ this.H = IV[7] | 0;
103
+ }
104
+ get() {
105
+ const { A, B, C, D, E, F, G, H } = this;
106
+ return [
107
+ A,
108
+ B,
109
+ C,
110
+ D,
111
+ E,
112
+ F,
113
+ G,
114
+ H
115
+ ];
116
+ }
117
+ set(A, B, C, D, E, F, G, H) {
118
+ this.A = A | 0;
119
+ this.B = B | 0;
120
+ this.C = C | 0;
121
+ this.D = D | 0;
122
+ this.E = E | 0;
123
+ this.F = F | 0;
124
+ this.G = G | 0;
125
+ this.H = H | 0;
126
+ }
127
+ _cloneInto(to) {
128
+ (to ||= new this.constructor()).set(...this.get());
129
+ return this._cloneIntoMeta(to);
130
+ }
131
+ process(view, offset) {
132
+ for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
133
+ for (let i = 16; i < 64; i++) {
134
+ const W15 = SHA256_W[i - 15];
135
+ const W2 = SHA256_W[i - 2];
136
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
137
+ SHA256_W[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
138
+ }
139
+ let { A, B, C, D, E, F, G, H } = this;
140
+ for (let i = 0; i < 64; i++) {
141
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
142
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
143
+ const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
144
+ H = G;
145
+ G = F;
146
+ F = E;
147
+ E = D + T1 | 0;
148
+ D = C;
149
+ C = B;
150
+ B = A;
151
+ A = T1 + T2 | 0;
152
+ }
153
+ A = A + this.A | 0;
154
+ B = B + this.B | 0;
155
+ C = C + this.C | 0;
156
+ D = D + this.D | 0;
157
+ E = E + this.E | 0;
158
+ F = F + this.F | 0;
159
+ G = G + this.G | 0;
160
+ H = H + this.H | 0;
161
+ this.set(A, B, C, D, E, F, G, H);
162
+ }
163
+ roundClean() {
164
+ clean(SHA256_W);
165
+ }
166
+ destroy() {
167
+ this.destroyed = true;
168
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
169
+ clean(this.buffer);
170
+ }
171
+ };
172
+ /** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */
173
+ var _SHA256 = class extends SHA2_32B {
174
+ constructor() {
175
+ super(32, SHA256_IV);
176
+ }
177
+ };
178
+ /**
179
+ * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:
180
+ *
181
+ * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.
182
+ * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
183
+ * - Each sha256 hash is executing 2^18 bit operations.
184
+ * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.
185
+ * @param msg - message bytes to hash
186
+ * @param opts - Reserved hash options.
187
+ * @returns Digest bytes.
188
+ * @example
189
+ * Hash a message with SHA2-256.
190
+ * ```ts
191
+ * sha256(new Uint8Array([97, 98, 99]));
192
+ * ```
193
+ */
194
+ var sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), /* @__PURE__ */ oidNist(1));
195
+ //#endregion
196
+ export { _SHA256, sha256 };
197
+
198
+ //# sourceMappingURL=sha2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha2.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha2.js"],"sourcesContent":["/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.\n * @module\n */\nimport { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from \"./_md.js\";\nimport * as u64 from \"./_u64.js\";\nimport { clean, createHasher, oidNist, rotr } from \"./utils.js\";\n/**\n * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits\n * of the cube roots of the first 64 primes (2..311).\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\n/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */\nclass SHA2_32B extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // Numeric initializers matter: starting the fields as `undefined` changes\n // V8's field representation and makes sha256 3x slower (measured).\n A = 0;\n B = 0;\n C = 0;\n D = 0;\n E = 0;\n F = 0;\n G = 0;\n H = 0;\n constructor(outputLen, IV) {\n super(64, outputLen, 8, false);\n this.A = IV[0] | 0;\n this.B = IV[1] | 0;\n this.C = IV[2] | 0;\n this.D = IV[3] | 0;\n this.E = IV[4] | 0;\n this.F = IV[5] | 0;\n this.G = IV[6] | 0;\n this.H = IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n _cloneInto(to) {\n (to ||= new this.constructor()).set(...this.get());\n return this._cloneIntoMeta(to);\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean(SHA256_W);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */\nexport class _SHA256 extends SHA2_32B {\n constructor() {\n super(32, SHA256_IV);\n }\n}\n/** Internal SHA-224 hash class grounded in RFC 6234 §6.2 and §8.5. */\nexport class _SHA224 extends SHA2_32B {\n constructor() {\n super(28, SHA224_IV);\n }\n}\n// SHA2-512 is slower than sha256 in js because u64 operations are slow.\n// SHA-384 / SHA-512 round constants from RFC 6234 §5.2:\n// 80 full 64-bit words split into high/low halves.\n// prettier-ignore\nconst K512 = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\nconst SHA512_Kh = /* @__PURE__ */ (() => K512[0])();\nconst SHA512_Kl = /* @__PURE__ */ (() => K512[1])();\n// Reusable high-half schedule buffer for the RFC 6234 §6.4 64-bit `W_t` words.\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\n// Reusable low-half schedule buffer for the RFC 6234 §6.4 64-bit `W_t` words.\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\n/** Internal SHA-384 / SHA-512 compression engine from RFC 6234 §6.4. */\nclass SHA2_64B extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // h -- high 32 bits, l -- low 32 bits\n // Numeric initializers matter: starting the fields as `undefined` changes\n // V8's field representation and slows hashing down (measured on sha256).\n Ah = 0;\n Al = 0;\n Bh = 0;\n Bl = 0;\n Ch = 0;\n Cl = 0;\n Dh = 0;\n Dl = 0;\n Eh = 0;\n El = 0;\n Fh = 0;\n Fl = 0;\n Gh = 0;\n Gl = 0;\n Hh = 0;\n Hl = 0;\n constructor(outputLen, IV) {\n super(128, outputLen, 16, false);\n this.Ah = IV[0] | 0;\n this.Al = IV[1] | 0;\n this.Bh = IV[2] | 0;\n this.Bl = IV[3] | 0;\n this.Ch = IV[4] | 0;\n this.Cl = IV[5] | 0;\n this.Dh = IV[6] | 0;\n this.Dl = IV[7] | 0;\n this.Eh = IV[8] | 0;\n this.El = IV[9] | 0;\n this.Fh = IV[10] | 0;\n this.Fl = IV[11] | 0;\n this.Gh = IV[12] | 0;\n this.Gl = IV[13] | 0;\n this.Hh = IV[14] | 0;\n this.Hl = IV[15] | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n _cloneInto(to) {\n (to ||= new this.constructor()).set(...this.get());\n return this._cloneIntoMeta(to);\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA512_W[i] = s0 + s1 + SHA512_W[i - 7] + SHA512_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n clean(SHA512_W_H, SHA512_W_L);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\n/** Internal SHA-512 hash class grounded in RFC 6234 §6.3 and §6.4. */\nexport class _SHA512 extends SHA2_64B {\n constructor() {\n super(64, SHA512_IV);\n }\n}\n/** Internal SHA-384 hash class grounded in RFC 6234 §6.3 and §6.4. */\nexport class _SHA384 extends SHA2_64B {\n constructor() {\n super(48, SHA384_IV);\n }\n}\n/**\n * Truncated SHA512/256 and SHA512/224.\n * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as \"intermediary\" IV of SHA512/t.\n * Then t hashes string to produce result IV.\n * See the repo-side derivation recipe in `test/misc/sha2-gen-iv.js`.\n * These IV literals are checked against that script rather than a dedicated\n * local RFC section.\n */\n/** SHA-512/224 IV derived by the SHA-512/t recipe in `test/misc/sha2-gen-iv.js` and\n * stored as sixteen big-endian 32-bit halves. */\nconst T224_IV = /* @__PURE__ */ Uint32Array.from([\n 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf,\n 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1,\n]);\n/** SHA-512/256 IV derived by the SHA-512/t recipe in `test/misc/sha2-gen-iv.js` and\n * stored as sixteen big-endian 32-bit halves. */\nconst T256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd,\n 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2,\n]);\n/** Internal SHA-512/224 hash class using the derived `T224_IV` and the shared\n * RFC 6234 §6.4 compression engine. */\nexport class _SHA512_224 extends SHA2_64B {\n constructor() {\n super(28, T224_IV);\n }\n}\n/** Internal SHA-512/256 hash class using the derived `T256_IV` and the shared\n * RFC 6234 §6.4 compression engine. */\nexport class _SHA512_256 extends SHA2_64B {\n constructor() {\n super(32, T256_IV);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:\n *\n * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.\n * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n * - Each sha256 hash is executing 2^18 bit operations.\n * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-256.\n * ```ts\n * sha256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), \n/* @__PURE__ */ oidNist(0x01));\n/**\n * SHA2-224 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-224.\n * ```ts\n * sha224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha224 = /* @__PURE__ */ createHasher(() => new _SHA224(), \n/* @__PURE__ */ oidNist(0x04));\n/**\n * SHA2-512 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512.\n * ```ts\n * sha512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512 = /* @__PURE__ */ createHasher(() => new _SHA512(), \n/* @__PURE__ */ oidNist(0x03));\n/**\n * SHA2-384 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-384.\n * ```ts\n * sha384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha384 = /* @__PURE__ */ createHasher(() => new _SHA384(), \n/* @__PURE__ */ oidNist(0x02));\n/**\n * SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on {@link https://eprint.iacr.org/2010/548.pdf | truncated SHA512}.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512/256.\n * ```ts\n * sha512_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512_256 = /* @__PURE__ */ createHasher(() => new _SHA512_256(), \n/* @__PURE__ */ oidNist(0x06));\n/**\n * SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on {@link https://eprint.iacr.org/2010/548.pdf | truncated SHA512}.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512/224.\n * ```ts\n * sha512_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512_224 = /* @__PURE__ */ createHasher(() => new _SHA512_224(), \n/* @__PURE__ */ oidNist(0x05));\n"],"x_google_ignoreList":[0],"mappings":"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"}
@@ -0,0 +1,243 @@
1
+ //#region ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js
2
+ /**
3
+ * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
4
+ * @param a - value to test
5
+ * @returns `true` when the value is a Uint8Array-compatible view.
6
+ * @example
7
+ * Check whether a value is a Uint8Array-compatible view.
8
+ * ```ts
9
+ * isBytes(new Uint8Array([1, 2, 3]));
10
+ * ```
11
+ */
12
+ function isBytes(a) {
13
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
14
+ }
15
+ var atitle = (title) => title ? `"${title}" ` : "";
16
+ /**
17
+ * Asserts something is a non-negative integer.
18
+ * @param n - number to validate
19
+ * @param title - label included in thrown errors
20
+ * @returns The validated number.
21
+ * @throws On wrong argument types. {@link TypeError}
22
+ * @throws On wrong argument ranges or values. {@link RangeError}
23
+ * @example
24
+ * Validate a non-negative integer option.
25
+ * ```ts
26
+ * anumber(32, 'length');
27
+ * ```
28
+ */
29
+ function anumber(n, title = "") {
30
+ if (typeof n !== "number") throw new TypeError(atitle(title) + "expected number, got " + typeof n);
31
+ if (!Number.isSafeInteger(n) || n < 0) throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
32
+ return n;
33
+ }
34
+ /**
35
+ * Asserts something is Uint8Array.
36
+ * @param value - value to validate
37
+ * @param length - optional exact length constraint
38
+ * @param title - label included in thrown errors
39
+ * @returns The validated byte array.
40
+ * @throws On wrong argument types. {@link TypeError}
41
+ * @throws On wrong argument ranges or values. {@link RangeError}
42
+ * @example
43
+ * Validate that a value is a byte array.
44
+ * ```ts
45
+ * abytes(new Uint8Array([1, 2, 3]));
46
+ * ```
47
+ */
48
+ function abytes(value, length, title = "") {
49
+ if (isBytes(value) && (length === void 0 || value.length === length)) return value;
50
+ if (length !== void 0) anumber(length, "length");
51
+ const bytes = isBytes(value);
52
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
53
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
54
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
55
+ if (!bytes) throw new TypeError(message);
56
+ throw new RangeError(message);
57
+ }
58
+ var aobject = (value, label) => {
59
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
60
+ };
61
+ var aopts = (value, label) => {
62
+ aobject(value, label);
63
+ const proto = Object.getPrototypeOf(value);
64
+ if (proto !== Object.prototype && proto !== null) throw new TypeError(`"${label}" expected plain object`);
65
+ if (Object.hasOwn(value, "__proto__")) throw new TypeError(`"${label}.__proto__" is not allowed`);
66
+ };
67
+ /**
68
+ * Asserts a hash instance has not been destroyed or finished.
69
+ * @param instance - hash instance to validate
70
+ * @param checkFinished - whether to reject finalized instances
71
+ * @throws If the hash instance has already been destroyed or finalized. {@link Error}
72
+ * @example
73
+ * Validate that a hash instance is still usable.
74
+ * ```ts
75
+ * import { aexists } from '@noble/hashes/utils.js';
76
+ * import { sha256 } from '@noble/hashes/sha2.js';
77
+ * const hash = sha256.create();
78
+ * aexists(hash);
79
+ * ```
80
+ */
81
+ function aexists(instance, checkFinished = true) {
82
+ if (instance.destroyed) throw new Error("hash was destroyed");
83
+ if (checkFinished && instance.finished) throw new Error("digest() was already called");
84
+ }
85
+ /**
86
+ * Asserts output is a sufficiently-sized byte array.
87
+ * @param out - destination buffer
88
+ * @param instance - hash instance providing output length
89
+ * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
90
+ * @throws On wrong argument types. {@link TypeError}
91
+ * @throws On wrong argument ranges or values. {@link RangeError}
92
+ * @example
93
+ * Validate a caller-provided digest buffer.
94
+ * ```ts
95
+ * import { aoutput } from '@noble/hashes/utils.js';
96
+ * import { sha256 } from '@noble/hashes/sha2.js';
97
+ * const hash = sha256.create();
98
+ * aoutput(new Uint8Array(hash.outputLen), hash);
99
+ * ```
100
+ */
101
+ function aoutput(out, instance) {
102
+ abytes(out, void 0, "output");
103
+ const min = instance.outputLen;
104
+ if (!(out.length >= min)) throw new RangeError("\"output\" expected length >= " + min);
105
+ }
106
+ /**
107
+ * Zeroizes typed arrays in place. Warning: JS provides no guarantees.
108
+ * @param arrays - arrays to overwrite with zeros
109
+ * @example
110
+ * Zeroize sensitive buffers in place.
111
+ * ```ts
112
+ * clean(new Uint8Array([1, 2, 3]));
113
+ * ```
114
+ */
115
+ function clean(...arrays) {
116
+ for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
117
+ }
118
+ /**
119
+ * Creates a DataView for byte-level manipulation.
120
+ * @param arr - source typed array
121
+ * @returns DataView over the same buffer region.
122
+ * @example
123
+ * Create a DataView over an existing buffer.
124
+ * ```ts
125
+ * createView(new Uint8Array(4));
126
+ * ```
127
+ */
128
+ function createView(arr) {
129
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
130
+ }
131
+ /**
132
+ * Rotate-right operation for uint32 values.
133
+ * @param word - source word
134
+ * @param shift - shift amount in bits
135
+ * @returns Rotated word.
136
+ * @example
137
+ * Rotate a 32-bit word to the right.
138
+ * ```ts
139
+ * rotr(0x12345678, 8);
140
+ * ```
141
+ */
142
+ function rotr(word, shift) {
143
+ return word << 32 - shift | word >>> shift;
144
+ }
145
+ var hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
146
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
147
+ /**
148
+ * Convert byte array to hex string.
149
+ * Uses the built-in function when available and assumes it matches the tested
150
+ * fallback semantics.
151
+ * @param bytes - bytes to encode
152
+ * @returns Lowercase hexadecimal string.
153
+ * @throws On wrong argument types. {@link TypeError}
154
+ * @example
155
+ * Convert bytes to lowercase hexadecimal.
156
+ * ```ts
157
+ * bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'
158
+ * ```
159
+ */
160
+ function bytesToHex(bytes) {
161
+ abytes(bytes);
162
+ if (hasHexBuiltin) return bytes.toHex();
163
+ let hex = "";
164
+ for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
165
+ return hex;
166
+ }
167
+ /**
168
+ * Merges default options and passed options.
169
+ * @param defaults - base option object
170
+ * @param opts - user overrides
171
+ * @param title - label included in thrown override errors
172
+ * @returns Fresh merged option object with a null prototype.
173
+ * @throws On wrong argument types. {@link TypeError}
174
+ * @example
175
+ * Merge user overrides onto default options.
176
+ * ```ts
177
+ * checkOpts({ dkLen: 32 }, { asyncTick: 10 });
178
+ * ```
179
+ */
180
+ function checkOpts(defaults, opts, title = "opts") {
181
+ aopts(defaults, "defaults");
182
+ if (opts !== void 0) aopts(opts, title);
183
+ return Object.assign(Object.create(null), defaults, opts);
184
+ }
185
+ /**
186
+ * Creates a callable hash function from a stateful class constructor.
187
+ * @param hashCons - hash constructor or factory
188
+ * @param info - optional metadata such as DER OID
189
+ * @returns Frozen callable hash wrapper with `.create()`.
190
+ * Wrapper construction eagerly calls `hashCons(undefined)` once to read
191
+ * `outputLen` / `blockLen`, so constructor side effects happen at module
192
+ * init time.
193
+ * @throws On wrong argument types. {@link TypeError}
194
+ * @example
195
+ * Wrap a stateful hash constructor into a callable helper.
196
+ * ```ts
197
+ * import { createHasher } from '@noble/hashes/utils.js';
198
+ * import { sha256 } from '@noble/hashes/sha2.js';
199
+ * const wrapped = createHasher(sha256.create, { oid: sha256.oid });
200
+ * wrapped(new Uint8Array([1]));
201
+ * ```
202
+ */
203
+ function createHasher(hashCons, info = {}) {
204
+ if (typeof hashCons !== "function") throw new TypeError("\"hashCons\" expected function, got type=" + typeof hashCons);
205
+ info = checkOpts({}, info, "info");
206
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
207
+ const tmp = hashCons(void 0);
208
+ hashC.outputLen = tmp.outputLen;
209
+ hashC.blockLen = tmp.blockLen;
210
+ hashC.canXOF = tmp.canXOF;
211
+ hashC.create = (opts) => hashCons(opts);
212
+ Object.assign(hashC, info);
213
+ return Object.freeze(hashC);
214
+ }
215
+ /**
216
+ * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.
217
+ * @param suffix - final OID byte for the selected hash.
218
+ * The helper accepts any byte even though only the documented NIST hash
219
+ * suffixes are meaningful downstream.
220
+ * @returns Object containing the DER-encoded OID.
221
+ * @example
222
+ * Build OID metadata for a NIST hash.
223
+ * ```ts
224
+ * oidNist(0x01);
225
+ * ```
226
+ */
227
+ var oidNist = (suffix) => ({ oid: Uint8Array.from([
228
+ 6,
229
+ 9,
230
+ 96,
231
+ 134,
232
+ 72,
233
+ 1,
234
+ 101,
235
+ 3,
236
+ 4,
237
+ 2,
238
+ suffix
239
+ ]) });
240
+ //#endregion
241
+ export { abytes, aexists, anumber, aoutput, bytesToHex, checkOpts, clean, createHasher, createView, isBytes, oidNist, rotr };
242
+
243
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js"],"sourcesContent":["/**\n * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.\n * @param a - value to test\n * @returns `true` when the value is a Uint8Array-compatible view.\n * @example\n * Check whether a value is a Uint8Array-compatible view.\n * ```ts\n * isBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.\n // The fallback still requires a real ArrayBuffer view, so plain\n // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and\n // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return (a instanceof Uint8Array ||\n (ArrayBuffer.isView(a) &&\n a.constructor.name === 'Uint8Array' &&\n 'BYTES_PER_ELEMENT' in a &&\n a.BYTES_PER_ELEMENT === 1));\n}\n// Shared error-message prefix builder. Only called on throw paths, so assert\n// success paths never pay for the string concatenation.\nconst atitle = (title) => (title ? `\"${title}\" ` : '');\n/**\n * Asserts something is a non-negative integer.\n * @param n - number to validate\n * @param title - label included in thrown errors\n * @returns The validated number.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a non-negative integer option.\n * ```ts\n * anumber(32, 'length');\n * ```\n */\nexport function anumber(n, title = '') {\n if (typeof n !== 'number')\n throw new TypeError(atitle(title) + 'expected number, got ' + typeof n);\n if (!Number.isSafeInteger(n) || n < 0)\n throw new RangeError(atitle(title) + 'expected integer >= 0, got ' + n);\n return n;\n}\n/**\n * Asserts something is a boolean.\n * @param value - value to validate\n * @param title - label included in thrown errors\n * @returns The validated boolean.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Validate a boolean option.\n * ```ts\n * abool(true, 'enableXOF');\n * ```\n */\nexport function abool(value, title = '') {\n if (typeof value !== 'boolean')\n throw new TypeError(atitle(title) + 'expected boolean, got type=' + typeof value);\n return value;\n}\n/**\n * Asserts something is Uint8Array.\n * @param value - value to validate\n * @param length - optional exact length constraint\n * @param title - label included in thrown errors\n * @returns The validated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate that a value is a byte array.\n * ```ts\n * abytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function abytes(value, length, title = '') {\n // Success path first: this runs at the start of every update() / digestInto(), and the\n // common `abytes(data)` form must not pay for length handling it does not use.\n if (isBytes(value) && (length === undefined || value.length === length))\n return value;\n // Error path: recompute freely to build the exact message.\n if (length !== undefined)\n anumber(length, 'length');\n const bytes = isBytes(value);\n const ofLen = length !== undefined ? ` of length ${length}` : '';\n const got = bytes ? `length=${value.length}` : `type=${typeof value}`;\n const message = atitle(title) + 'expected Uint8Array' + ofLen + ', got ' + got;\n if (!bytes)\n throw new TypeError(message);\n throw new RangeError(message);\n}\n/**\n * Copies bytes into a fresh Uint8Array.\n * Buffer-style slices can alias the same backing store, so callers that need ownership should copy.\n * @param bytes - source bytes to clone\n * @returns Freshly allocated copy of `bytes`.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Clone a byte array before mutating it.\n * ```ts\n * const copy = copyBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function copyBytes(bytes) {\n // `Uint8Array.from(...)` would also accept arrays / other typed arrays. Keep this helper strict\n // because callers use it at byte-validation boundaries before mutating the detached copy.\n return Uint8Array.from(abytes(bytes));\n}\n/**\n * Asserts something is a wrapped hash constructor.\n * @param h - hash constructor to validate\n * @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}\n * @throws On invalid hash metadata ranges or values. {@link RangeError}\n * @throws If the hash metadata allows empty outputs or block sizes. {@link Error}\n * @example\n * Validate a callable hash wrapper.\n * ```ts\n * import { ahash } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * ahash(sha256);\n * ```\n */\nexport function ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new TypeError('expected hash wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n // HMAC and KDF callers treat these as real byte lengths; allowing zero lets fake wrappers pass\n // validation and can produce empty outputs instead of failing fast.\n if (h.outputLen < 1 || h.blockLen < 1)\n throw new Error('hash blockLen / outputLen must be >= 1');\n}\nconst aobject = (value, label) => {\n if (value === null || typeof value !== 'object' || Array.isArray(value))\n throw new TypeError((label === 'object' ? '' : `\"${label}\" `) + 'expected object, got type=' + typeof value);\n};\nconst aopts = (value, label) => {\n aobject(value, label);\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null)\n throw new TypeError(`\"${label}\" expected plain object`);\n // Object.assign() treats an own \"__proto__\" source key as a write to the target's legacy\n // prototype setter. Reject it before merging so inherited option values cannot be injected.\n if (Object.hasOwn(value, '__proto__'))\n throw new TypeError(`\"${label}.__proto__\" is not allowed`);\n};\n/**\n * Asserts a hash instance has not been destroyed or finished.\n * @param instance - hash instance to validate\n * @param checkFinished - whether to reject finalized instances\n * @throws If the hash instance has already been destroyed or finalized. {@link Error}\n * @example\n * Validate that a hash instance is still usable.\n * ```ts\n * import { aexists } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aexists(hash);\n * ```\n */\nexport function aexists(instance, checkFinished = true) {\n // Runs on every update()/digestInto(); the flags are library-owned booleans, so only their\n // truthiness is checked - re-validating their type per call was pure hot-path overhead.\n if (instance.destroyed)\n throw new Error('hash was destroyed');\n if (checkFinished && instance.finished)\n throw new Error('digest() was already called');\n}\n/**\n * Asserts output is a sufficiently-sized byte array.\n * @param out - destination buffer\n * @param instance - hash instance providing output length\n * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a caller-provided digest buffer.\n * ```ts\n * import { aoutput } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aoutput(new Uint8Array(hash.outputLen), hash);\n * ```\n */\nexport function aoutput(out, instance) {\n abytes(out, undefined, 'output');\n // `outputLen` is a library-owned readonly number; the negated comparison keeps failing fast\n // when it is missing/NaN (comparisons with undefined/NaN are false) without an anumber() call.\n const min = instance.outputLen;\n if (!(out.length >= min)) {\n throw new RangeError('\"output\" expected length >= ' + min);\n }\n}\n/**\n * Casts a typed array view to Uint8Array.\n * @param arr - source typed array\n * @returns Uint8Array view over the same buffer.\n * @example\n * Reinterpret a typed array as bytes.\n * ```ts\n * u8(new Uint32Array([1, 2]));\n * ```\n */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Casts a typed array view to Uint32Array.\n * `arr.byteOffset` must already be 4-byte aligned or the platform\n * Uint32Array constructor will throw.\n * @param arr - source typed array\n * @returns Uint32Array view over the same buffer.\n * @example\n * Reinterpret a byte array as 32-bit words.\n * ```ts\n * u32(new Uint8Array(8));\n * ```\n */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/**\n * Zeroizes typed arrays in place. Warning: JS provides no guarantees.\n * @param arrays - arrays to overwrite with zeros\n * @example\n * Zeroize sensitive buffers in place.\n * ```ts\n * clean(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/**\n * Creates a DataView for byte-level manipulation.\n * @param arr - source typed array\n * @returns DataView over the same buffer region.\n * @example\n * Create a DataView over an existing buffer.\n * ```ts\n * createView(new Uint8Array(4));\n * ```\n */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Rotate-right operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the right.\n * ```ts\n * rotr(0x12345678, 8);\n * ```\n */\nexport function rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Rotate-left operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the left.\n * ```ts\n * rotl(0x12345678, 8);\n * ```\n */\nexport function rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Whether the current platform is little-endian. */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n/**\n * Byte-swap operation for uint32 values.\n * @param word - source word\n * @returns Word with reversed byte order.\n * @example\n * Reverse the byte order of a 32-bit word.\n * ```ts\n * byteSwap(0x11223344);\n * ```\n */\nexport function byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/**\n * Conditionally byte-swaps one 32-bit word on big-endian platforms.\n * @param n - source word\n * @returns Original or byte-swapped word depending on platform endianness.\n * @example\n * Normalize a 32-bit word for host endianness.\n * ```ts\n * swap8IfBE(0x11223344);\n * ```\n */\nexport const swap8IfBE = isLE\n ? (n) => n\n : (n) => byteSwap(n) >>> 0;\n/**\n * Byte-swaps every word of a Uint32Array in place.\n * @param arr - array to mutate\n * @returns The same array after mutation; callers pass live state arrays here.\n * @example\n * Reverse the byte order of every word in place.\n * ```ts\n * byteSwap32(new Uint32Array([0x11223344]));\n * ```\n */\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n/**\n * Conditionally byte-swaps a Uint32Array on big-endian platforms.\n * @param u - array to normalize for host endianness\n * @returns Original or byte-swapped array depending on platform endianness.\n * On big-endian runtimes this mutates `u` in place via `byteSwap32(...)`.\n * @example\n * Normalize a word array for host endianness.\n * ```ts\n * swap32IfBE(new Uint32Array([0x11223344]));\n * ```\n */\nexport const swap32IfBE = isLE\n ? (u) => u\n : byteSwap32;\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string.\n * Uses the built-in function when available and assumes it matches the tested\n * fallback semantics.\n * @param bytes - bytes to encode\n * @returns Lowercase hexadecimal string.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Convert bytes to lowercase hexadecimal.\n * ```ts\n * bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'\n * ```\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// Strict ASCII nibble parser: non-ASCII hex lookalikes are rejected as undefined.\n// ASCII codes: '0'..'9' = 48..57, 'A'..'F' = 65..70, 'a'..'f' = 97..102.\n// prettier-ignore\nfunction asciiToBase16(ch) {\n return ch >= 48 && ch <= 57 ? ch - 48 // '2' => 50-48\n : ch >= 65 && ch <= 70 ? ch - (65 - 10) // 'B' => 66-(65-10)\n : ch >= 97 && ch <= 102 ? ch - (97 - 10) // 'b' => 98-(97-10)\n : undefined;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @param hex - hexadecimal string to decode\n * @returns Decoded bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Decode lowercase hexadecimal into bytes.\n * ```ts\n * hexToBytes('cafe0123'); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n * ```\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new TypeError('hex string expected, got ' + typeof hex);\n if (hasHexBuiltin) {\n try {\n return Uint8Array.fromHex(hex);\n }\n catch (error) {\n if (error instanceof SyntaxError)\n throw new RangeError(error.message);\n throw error;\n }\n }\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new RangeError('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi)); // parse first char, multiply it by 16\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); // parse second char\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new RangeError('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // example: 'A9' => 10*16 + 9\n }\n return array;\n}\n/**\n * Yields to the host task scheduler so timers, I/O, and rendering can make progress.\n * Uses the Web Scheduling API when available or `setTimeout` as a cross-platform fallback.\n * Host-task yields are much slower than microtasks (roughly 1ms with the timer fallback), so\n * async loops should use `asyncTick >= 10` to amortize scheduling overhead to about 10% while\n * still allowing other event-loop work to proceed.\n * @param onReject - optional cleanup invoked only if the host yield fails\n * @example\n * Yield to the next scheduler tick.\n * ```ts\n * await nextTick();\n * ```\n */\nexport function nextTick(onReject) {\n const host = globalThis;\n if (typeof host.scheduler?.yield === 'function') {\n const promise = host.scheduler.yield();\n // Keep the original scheduler rejection; this handler exists only for cleanup.\n if (onReject)\n promise.catch(onReject);\n return promise;\n }\n return new Promise((resolve) => host.setTimeout(resolve, 0));\n}\n/**\n * Returns control to the host event loop every `tick` milliseconds to avoid blocking long loops.\n * @param iters - number of loop iterations to run\n * @param tick - maximum time slice in milliseconds\n * @param cb - callback executed on each iteration\n * @param onReject - optional cleanup invoked only if a host yield fails\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Run a loop that periodically yields back to the event loop.\n * ```ts\n * await asyncLoop(2, 0, () => {});\n * ```\n */\nexport async function asyncLoop(iters, tick, cb, onReject) {\n anumber(iters, 'iters');\n anumber(tick, 'tick');\n if (typeof cb !== 'function')\n throw new TypeError('callback must be a function');\n // Callback is synchronous by contract; asyncLoop only yields between sync work windows.\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick(onReject);\n // Track only synchronous work time; scheduler delay after yielding is outside our budget.\n ts = Date.now();\n }\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * Built-in doesn't validate input to be string: we do the check.\n * Non-ASCII details are delegated to the platform `TextEncoder`.\n * @param str - string to encode\n * @returns UTF-8 encoded bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Encode a string as UTF-8 bytes.\n * ```ts\n * utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])\n * ```\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new TypeError('string expected');\n const encoded = new TextEncoder().encode(str);\n try {\n // Copy into the current realm for Firefox extension contexts. Callers that own the returned\n // buffer can then wipe it independently of TextEncoder's temporary result.\n return new Uint8Array(encoded); // https://bugzil.la/1681809\n }\n finally {\n clean(encoded);\n }\n}\n/**\n * Helper for KDFs: consumes Uint8Array or string.\n * String inputs are UTF-8 encoded; byte-array inputs stay aliased to the caller buffer.\n * @param data - user-provided KDF input\n * @param errorTitle - label included in thrown errors\n * @returns Byte representation of the input.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Normalize KDF input to bytes.\n * ```ts\n * kdfInputToBytes('password');\n * ```\n */\nexport function kdfInputToBytes(data, errorTitle = '') {\n if (typeof data === 'string')\n return utf8ToBytes(data);\n return abytes(data, undefined, errorTitle);\n}\n/**\n * Copies several Uint8Arrays into one.\n * @param arrays - arrays to concatenate\n * @returns Concatenated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Concatenate multiple byte arrays.\n * ```ts\n * concatBytes(new Uint8Array([1]), new Uint8Array([2]));\n * ```\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n/**\n * Validates declared required and optional field types on a plain object.\n * This walks field schemas and formats detailed errors, so avoid it on hot paths; use direct\n * one-line guards such as `abytes()`, `abool()`, or `anumber()` instead.\n * @param object - object to validate\n * @param fields - map of required field names to expected types\n * @param optFields - map of optional field names to expected types\n * @param title - label included in thrown errors\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Validate required and optional option fields.\n * ```ts\n * validateObject({ N: 1024, dkLen: 32 }, { N: 'number' }, { dkLen: 'number' });\n * ```\n */\nexport const validateObject = (object, fields = {}, optFields = {}, title = 'object') => {\n aobject(object, title);\n aobject(fields, 'fields');\n aobject(optFields, 'optFields');\n function checkField(fieldName, expectedType, isOpt) {\n const label = title === 'object' ? `param \"${String(fieldName)}\"` : `\"${title}.${String(fieldName)}\"`;\n // Config fields must be explicit own properties. Optional inherited values are rejected too\n // because callers keep reading the same options object after validation.\n const val = object[fieldName];\n // Runtime objects such as Field instances intentionally satisfy required method slots\n // via their shared prototype.\n if (!Object.hasOwn(object, fieldName) &&\n (isOpt ? val !== undefined : expectedType !== 'function')) {\n throw new TypeError(`${label} is invalid: expected own property`);\n }\n if (isOpt && val === undefined)\n return;\n const current = typeof val;\n if (current !== expectedType || val === null)\n throw new TypeError(`${label} is invalid: expected ${expectedType}, got ${current}`);\n }\n const iter = (f, isOpt) => Object.entries(f).forEach(([k, v]) => checkField(k, v, isOpt));\n iter(fields, false);\n iter(optFields, true);\n};\n/**\n * Merges default options and passed options.\n * @param defaults - base option object\n * @param opts - user overrides\n * @param title - label included in thrown override errors\n * @returns Fresh merged option object with a null prototype.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Merge user overrides onto default options.\n * ```ts\n * checkOpts({ dkLen: 32 }, { asyncTick: 10 });\n * ```\n */\nexport function checkOpts(defaults, opts, title = 'opts') {\n aopts(defaults, 'defaults');\n if (opts !== undefined)\n aopts(opts, title);\n // Callers read optional fields directly, so omitted values must not fall through to ambient\n // Object.prototype pollution (for example a forged `dkLen` changing SHAKE's default output).\n const merged = Object.assign(Object.create(null), defaults, opts);\n return merged;\n}\n/**\n * Creates a callable hash function from a stateful class constructor.\n * @param hashCons - hash constructor or factory\n * @param info - optional metadata such as DER OID\n * @returns Frozen callable hash wrapper with `.create()`.\n * Wrapper construction eagerly calls `hashCons(undefined)` once to read\n * `outputLen` / `blockLen`, so constructor side effects happen at module\n * init time.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Wrap a stateful hash constructor into a callable helper.\n * ```ts\n * import { createHasher } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const wrapped = createHasher(sha256.create, { oid: sha256.oid });\n * wrapped(new Uint8Array([1]));\n * ```\n */\nexport function createHasher(hashCons, info = {}) {\n if (typeof hashCons !== 'function')\n throw new TypeError('\"hashCons\" expected function, got type=' + typeof hashCons);\n info = checkOpts({}, info, 'info');\n const hashC = (msg, opts) => hashCons(opts)\n .update(msg)\n .digest();\n const tmp = hashCons(undefined);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.canXOF = tmp.canXOF;\n hashC.create = (opts) => hashCons(opts);\n Object.assign(hashC, info);\n return Object.freeze(hashC);\n}\n/**\n * Cryptographically secure PRNG backed by `crypto.getRandomValues`.\n * @param bytesLength - number of random bytes to generate\n * @returns Random bytes.\n * The platform `getRandomValues()` implementation still defines any\n * single-call length cap, and this helper rejects oversize requests\n * with a stable library `RangeError` instead of host-specific errors.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}\n * @example\n * Generate a fresh random key or nonce.\n * ```ts\n * const key = randomBytes(16);\n * ```\n */\nexport function randomBytes(bytesLength = 32) {\n // Match the repo's other length-taking helpers instead of relying on Uint8Array coercion.\n anumber(bytesLength, 'bytesLength');\n const cr = typeof globalThis === 'object' ? globalThis.crypto : null;\n if (typeof cr?.getRandomValues !== 'function')\n throw new Error('crypto.getRandomValues must be defined');\n // Web Cryptography API Level 2 §10.1.1:\n // if `byteLength > 65536`, throw `QuotaExceededError`.\n // Keep the guard explicit so callers can see the quota in code\n // instead of discovering it by reading the spec or host errors.\n // This wrapper surfaces the same quota as a stable library RangeError.\n if (bytesLength > 65536)\n throw new RangeError(`\"bytesLength\" expected <= 65536, got ${bytesLength}`);\n return cr.getRandomValues(new Uint8Array(bytesLength));\n}\n/**\n * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.\n * @param suffix - final OID byte for the selected hash.\n * The helper accepts any byte even though only the documented NIST hash\n * suffixes are meaningful downstream.\n * @returns Object containing the DER-encoded OID.\n * @example\n * Build OID metadata for a NIST hash.\n * ```ts\n * oidNist(0x01);\n * ```\n */\nexport const oidNist = (suffix) => ({\n // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.\n // Larger suffix values would need base-128 OID encoding and a different length byte.\n oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]),\n});\n"],"x_google_ignoreList":[0],"mappings":"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"}
package/dist/object.d.ts CHANGED
@@ -398,6 +398,22 @@ export declare class SmrtObject extends SmrtClass {
398
398
  protected canonicalizePersistedUuidRow(row: Record<string, unknown>): Promise<Record<string, unknown>>;
399
399
  /** Fetch one exact row while casting native DuckDB UUIDs in that same read. */
400
400
  protected getCanonicalPersistedRow(filter: Record<string, unknown>): Promise<Record<string, unknown> | null>;
401
+ /**
402
+ * Whether this database is POSITIVELY the native DuckDB adapter, never the
403
+ * JSON adapter that shares its client class.
404
+ *
405
+ * {@link isNativeDuckDb} answers "DuckDB dialect": the JSON adapter wraps the
406
+ * same `DuckDBConnection`, and even a `json` type hint maps to `duckdb`. The
407
+ * JSON adapter only persists a table to its `<table>.json` file from its own
408
+ * `insert`/`update`/`upsert`/`delete`; a raw `query()` never does, so a raw
409
+ * write there is visible in-process and lost on the next one. Writers that
410
+ * bypass those methods must therefore gate on this.
411
+ *
412
+ * Identification is deterministic, see `native-duckdb.ts`: a root handle is
413
+ * recognized structurally, and a transaction handle through the root core
414
+ * noted before binding to it (initialize, withDatabase, transactions).
415
+ */
416
+ private isPositivelyNativeDuckDb;
401
417
  private isNativeDuckDb;
402
418
  /**
403
419
  * Gets the database table name for this object
@@ -734,6 +750,46 @@ export declare class SmrtObject extends SmrtClass {
734
750
  * and other after-save consumers all see authoritative state.
735
751
  */
736
752
  protected completePersistedUpdate(durableRow: Record<string, unknown>): Promise<void>;
753
+ /**
754
+ * Indexed columns of `data` that provably keep the stored row's value, so the
755
+ * write can leave them out (#3737). Native DuckDB only: it rewrites a row
756
+ * when an indexed column is assigned, even to its existing value, which a
757
+ * foreign key still referencing the row then rejects. Other engines assign
758
+ * unchanged columns harmlessly and keep writing exactly what they did.
759
+ *
760
+ * `stored` is the row just read under the embedded write queue, after its
761
+ * revision matched the loaded one, so it is the state this save was loaded
762
+ * from. Anything not provably equal stays assigned.
763
+ */
764
+ private unchangedIndexedColumnsOf;
765
+ /**
766
+ * Write an existing row on an embedded engine, after the caller verified its
767
+ * revision under the write queue.
768
+ *
769
+ * Ordinarily one `upsert` by primary key that assigns every column. When
770
+ * {@link unchangedIndexedColumnsOf} proves indexed columns unchanged, those
771
+ * are left out of an id-targeted `UPDATE` instead (the adapter's `upsert`
772
+ * cannot restrict its `DO UPDATE SET`), so a referenced DuckDB parent is not
773
+ * rewritten. Every changed column, including a changed indexed one that
774
+ * DuckDB may still rightly refuse, is assigned as before.
775
+ */
776
+ private writeEmbeddedRevisionRow;
777
+ /**
778
+ * The natural-key upsert of a new object. When it adopts an existing row on
779
+ * native DuckDB, the columns the row already holds (its key, ownership and
780
+ * creation time among them) are left out of an id-targeted `UPDATE` rather
781
+ * than reassigned by `DO UPDATE SET`, for the reason given at
782
+ * {@link unchangedIndexedColumnsOf} (#3737). The adopted row was read, and
783
+ * its owner checked, under the same embedded write queue; the conflict
784
+ * columns it matched are never assigned, exactly as in the upsert.
785
+ */
786
+ private writeNaturalKeyUpsert;
787
+ /**
788
+ * One id-targeted `UPDATE` on native DuckDB (see {@link buildDuckDbIdUpdate}
789
+ * for the quoting and binding). The caller holds the embedded write queue
790
+ * and has already matched the row; `affected` is the driver's own count.
791
+ */
792
+ private updateDuckDbRowById;
737
793
  /**
738
794
  * Build the compare-and-swap condition that pins a guarded UPDATE or DELETE
739
795
  * to the revision this writer loaded.