@fulmenhq/tsfulmen 0.3.3 → 0.4.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 (123) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/README.md +30 -1
  3. package/config/crucible-ts/taxonomy/metrics.yaml +1 -1
  4. package/dist/appidentity/index.js +9 -2209
  5. package/dist/appidentity/index.js.map +1 -1
  6. package/dist/assets/index.d.ts +179 -0
  7. package/dist/assets/index.js +4 -0
  8. package/dist/assets/index.js.map +1 -0
  9. package/dist/bin/prometheus-cli.js +15 -9139
  10. package/dist/bin/prometheus-cli.js.map +1 -1
  11. package/dist/bin/schema-cli.js +4 -6098
  12. package/dist/bin/schema-cli.js.map +1 -1
  13. package/dist/bin/signals-cli.js +15 -1910
  14. package/dist/bin/signals-cli.js.map +1 -1
  15. package/dist/chunk-3HISR2XI.js +36 -0
  16. package/dist/chunk-3HISR2XI.js.map +1 -0
  17. package/dist/chunk-5HZEJGZ5.js +725 -0
  18. package/dist/chunk-5HZEJGZ5.js.map +1 -0
  19. package/dist/chunk-7SVYOPJ3.js +9412 -0
  20. package/dist/chunk-7SVYOPJ3.js.map +1 -0
  21. package/dist/chunk-BCO3FUUO.js +682 -0
  22. package/dist/chunk-BCO3FUUO.js.map +1 -0
  23. package/dist/chunk-BJDL6JEX.js +208 -0
  24. package/dist/chunk-BJDL6JEX.js.map +1 -0
  25. package/dist/chunk-BTUS6PZZ.js +302 -0
  26. package/dist/chunk-BTUS6PZZ.js.map +1 -0
  27. package/dist/chunk-CW4CSNVF.js +410 -0
  28. package/dist/chunk-CW4CSNVF.js.map +1 -0
  29. package/dist/chunk-HIBZ2AY7.js +194 -0
  30. package/dist/chunk-HIBZ2AY7.js.map +1 -0
  31. package/dist/chunk-HS4F3BRR.js +985 -0
  32. package/dist/chunk-HS4F3BRR.js.map +1 -0
  33. package/dist/chunk-HY6JQOFN.js +32 -0
  34. package/dist/chunk-HY6JQOFN.js.map +1 -0
  35. package/dist/chunk-K2FYT43R.js +837 -0
  36. package/dist/chunk-K2FYT43R.js.map +1 -0
  37. package/dist/chunk-K7BMFGQP.js +43 -0
  38. package/dist/chunk-K7BMFGQP.js.map +1 -0
  39. package/dist/chunk-LWAH2UG7.js +103 -0
  40. package/dist/chunk-LWAH2UG7.js.map +1 -0
  41. package/dist/chunk-OHE2AOH4.js +273 -0
  42. package/dist/chunk-OHE2AOH4.js.map +1 -0
  43. package/dist/chunk-P3DNOZOG.js +1488 -0
  44. package/dist/chunk-P3DNOZOG.js.map +1 -0
  45. package/dist/chunk-PQ6TKPUN.js +27 -0
  46. package/dist/chunk-PQ6TKPUN.js.map +1 -0
  47. package/dist/chunk-QCCN6POA.js +211 -0
  48. package/dist/chunk-QCCN6POA.js.map +1 -0
  49. package/dist/chunk-RSLFR4TO.js +631 -0
  50. package/dist/chunk-RSLFR4TO.js.map +1 -0
  51. package/dist/chunk-UP2VWCW5.js +33 -0
  52. package/dist/chunk-UP2VWCW5.js.map +1 -0
  53. package/dist/chunk-W6TQFTTY.js +130 -0
  54. package/dist/chunk-W6TQFTTY.js.map +1 -0
  55. package/dist/chunk-WSMVLWLB.js +269 -0
  56. package/dist/chunk-WSMVLWLB.js.map +1 -0
  57. package/dist/config/index.js +6 -1220
  58. package/dist/config/index.js.map +1 -1
  59. package/dist/crucible/fulpack/index.js +2 -25
  60. package/dist/crucible/fulpack/index.js.map +1 -1
  61. package/dist/crucible/index.js +13 -1129
  62. package/dist/crucible/index.js.map +1 -1
  63. package/dist/docscribe/index.js +2 -680
  64. package/dist/docscribe/index.js.map +1 -1
  65. package/dist/errors/index.js +5 -1831
  66. package/dist/errors/index.js.map +1 -1
  67. package/dist/errors-D7KXV3QW.js +4 -0
  68. package/dist/errors-D7KXV3QW.js.map +1 -0
  69. package/dist/errors-RBJX6ETJ.js +8 -0
  70. package/dist/errors-RBJX6ETJ.js.map +1 -0
  71. package/dist/export-BWRETGYS.js +6 -0
  72. package/dist/export-BWRETGYS.js.map +1 -0
  73. package/dist/foundry/index.js +340 -3949
  74. package/dist/foundry/index.js.map +1 -1
  75. package/dist/foundry/similarity/index.js +3 -134
  76. package/dist/foundry/similarity/index.js.map +1 -1
  77. package/dist/fulencode/index.js +3 -319
  78. package/dist/fulencode/index.js.map +1 -1
  79. package/dist/fulhash/index.js +3 -611
  80. package/dist/fulhash/index.js.map +1 -1
  81. package/dist/fulpack/index.js +3 -1515
  82. package/dist/fulpack/index.js.map +1 -1
  83. package/dist/hash-YOJYVOWH.js +4 -0
  84. package/dist/hash-YOJYVOWH.js.map +1 -0
  85. package/dist/index.d.ts +1 -1
  86. package/dist/index.js +14 -4395
  87. package/dist/index.js.map +1 -1
  88. package/dist/loader-H5K7HSO5.js +9 -0
  89. package/dist/loader-H5K7HSO5.js.map +1 -0
  90. package/dist/logging/index.js +2 -723
  91. package/dist/logging/index.js.map +1 -1
  92. package/dist/pathfinder/index.js +18 -2341
  93. package/dist/pathfinder/index.js.map +1 -1
  94. package/dist/prom-client-PNEBGD3G.js +4801 -0
  95. package/dist/prom-client-PNEBGD3G.js.map +1 -0
  96. package/dist/reports/license-inventory.csv +1 -1
  97. package/dist/schema/index.d.ts +19 -6
  98. package/dist/schema/index.js +4 -6148
  99. package/dist/schema/index.js.map +1 -1
  100. package/dist/signals/index.js +8 -2767
  101. package/dist/signals/index.js.map +1 -1
  102. package/dist/similarity/index.js +3 -134
  103. package/dist/similarity/index.js.map +1 -1
  104. package/dist/telemetry/http/index.js +9 -930
  105. package/dist/telemetry/http/index.js.map +1 -1
  106. package/dist/telemetry/index.js +4 -1561
  107. package/dist/telemetry/index.js.map +1 -1
  108. package/dist/telemetry/prometheus/index.js +7 -8422
  109. package/dist/telemetry/prometheus/index.js.map +1 -1
  110. package/dist/validator-U4CKD2Y3.js +6 -0
  111. package/dist/validator-U4CKD2Y3.js.map +1 -0
  112. package/package.json +5 -1
  113. package/schemas/crucible-ts/library/module-manifest/v1.0.0/module-manifest.schema.json +1 -1
  114. package/schemas/crucible-ts/observability/logging/v1.0.0/definitions.schema.json +1 -1
  115. package/schemas/crucible-ts/observability/logging/v1.0.0/log-event.schema.json +13 -13
  116. package/schemas/crucible-ts/observability/logging/v1.0.0/logger-config.schema.json +2 -2
  117. package/schemas/crucible-ts/observability/logging/v1.0.0/logging-policy.schema.json +1 -1
  118. package/schemas/crucible-ts/observability/logging/v1.0.0/middleware-config.schema.json +2 -2
  119. package/schemas/crucible-ts/observability/logging/v1.0.0/severity-filter.schema.json +3 -3
  120. package/schemas/crucible-ts/upstream/3leaps/crucible/PROVENANCE.md +3 -3
  121. package/schemas/crucible-ts/upstream/3leaps/crucible/docs/catalog/classifiers/README.md +1 -1
  122. package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/classifiers-framework.md +1 -1
  123. package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/data-sensitivity-classification.md +1 -1
@@ -1,613 +1,5 @@
1
- import { crc32, xxhash128, createXXHash128, createCRC32 } from 'hash-wasm';
2
- import { createHash } from 'crypto';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __esm = (fn, res) => function __init() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
- };
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
-
14
- // src/crucible/fulhash/types.ts
15
- var Algorithm;
16
- var init_types = __esm({
17
- "src/crucible/fulhash/types.ts"() {
18
- Algorithm = /* @__PURE__ */ ((Algorithm2) => {
19
- Algorithm2["XXH3_128"] = "xxh3-128";
20
- Algorithm2["SHA256"] = "sha256";
21
- Algorithm2["CRC32"] = "crc32";
22
- Algorithm2["CRC32C"] = "crc32c";
23
- return Algorithm2;
24
- })(Algorithm || {});
25
- }
26
- });
27
-
28
- // src/fulhash/errors.ts
29
- var FulHashError, UnsupportedAlgorithmError, InvalidChecksumError, InvalidChecksumFormatError, DigestStateError;
30
- var init_errors = __esm({
31
- "src/fulhash/errors.ts"() {
32
- FulHashError = class _FulHashError extends Error {
33
- constructor(message) {
34
- super(message);
35
- this.name = "FulHashError";
36
- Object.setPrototypeOf(this, _FulHashError.prototype);
37
- }
38
- };
39
- UnsupportedAlgorithmError = class _UnsupportedAlgorithmError extends FulHashError {
40
- constructor(algorithm, supportedAlgorithms) {
41
- super(
42
- `Unsupported algorithm "${algorithm}". Supported algorithms: ${supportedAlgorithms.join(", ")}`
43
- );
44
- this.name = "UnsupportedAlgorithmError";
45
- Object.setPrototypeOf(this, _UnsupportedAlgorithmError.prototype);
46
- }
47
- };
48
- InvalidChecksumError = class _InvalidChecksumError extends FulHashError {
49
- constructor(checksum, reason) {
50
- super(`Invalid checksum "${checksum}": ${reason}. Expected format: algorithm:hex`);
51
- this.name = "InvalidChecksumError";
52
- Object.setPrototypeOf(this, _InvalidChecksumError.prototype);
53
- }
54
- };
55
- InvalidChecksumFormatError = class _InvalidChecksumFormatError extends InvalidChecksumError {
56
- constructor(checksum, reason) {
57
- super(checksum, reason);
58
- this.name = "InvalidChecksumFormatError";
59
- Object.setPrototypeOf(this, _InvalidChecksumFormatError.prototype);
60
- }
61
- };
62
- DigestStateError = class _DigestStateError extends FulHashError {
63
- constructor(operation) {
64
- super(`Cannot ${operation}: digest already finalized. Call reset() to reuse hasher.`);
65
- this.name = "DigestStateError";
66
- Object.setPrototypeOf(this, _DigestStateError.prototype);
67
- }
68
- };
69
- }
70
- });
71
- function hexToBytes(hex) {
72
- const bytes = new Uint8Array(4);
73
- for (let i = 0; i < 4; i++) {
74
- bytes[i] = Number.parseInt(hex.substr(i * 2, 2), 16);
75
- }
76
- return bytes;
77
- }
78
- async function hashBytes(data) {
79
- const hex = await crc32(data);
80
- return hexToBytes(hex);
81
- }
82
- async function hashString(str, encoding = "utf8") {
83
- if (encoding !== "utf8") {
84
- const buf = Buffer.from(str, encoding);
85
- const hex2 = await crc32(buf);
86
- return hexToBytes(hex2);
87
- }
88
- const hex = await crc32(str);
89
- return hexToBytes(hex);
90
- }
91
- async function createHasher() {
92
- const hasher = await createCRC32();
93
- return hasher;
94
- }
95
- var init_crc32 = __esm({
96
- "src/fulhash/algorithms/crc32.ts"() {
97
- }
98
- });
99
- function hexToBytes2(hex) {
100
- const bytes = new Uint8Array(4);
101
- for (let i = 0; i < 4; i++) {
102
- bytes[i] = Number.parseInt(hex.substr(i * 2, 2), 16);
103
- }
104
- return bytes;
105
- }
106
- async function hashBytes2(data) {
107
- const hex = await crc32(data, CRC32C_POLYNOMIAL);
108
- return hexToBytes2(hex);
109
- }
110
- async function hashString2(str, encoding = "utf8") {
111
- if (encoding !== "utf8") {
112
- const buf = Buffer.from(str, encoding);
113
- const hex2 = await crc32(buf, CRC32C_POLYNOMIAL);
114
- return hexToBytes2(hex2);
115
- }
116
- const hex = await crc32(str, CRC32C_POLYNOMIAL);
117
- return hexToBytes2(hex);
118
- }
119
- async function createHasher2() {
120
- const hasher = await createCRC32(CRC32C_POLYNOMIAL);
121
- return hasher;
122
- }
123
- var CRC32C_POLYNOMIAL;
124
- var init_crc32c = __esm({
125
- "src/fulhash/algorithms/crc32c.ts"() {
126
- CRC32C_POLYNOMIAL = 2197175160;
127
- }
128
- });
129
- function hashBytes3(data) {
130
- const hash2 = createHash("sha256");
131
- hash2.update(data);
132
- return new Uint8Array(hash2.digest());
133
- }
134
- function hashString3(str, encoding = "utf8") {
135
- const hash2 = createHash("sha256");
136
- hash2.update(str, encoding);
137
- return new Uint8Array(hash2.digest());
138
- }
139
- var init_sha256 = __esm({
140
- "src/fulhash/algorithms/sha256.ts"() {
141
- }
142
- });
143
- function hexToBytes3(hex) {
144
- const bytes = new Uint8Array(16);
145
- for (let i = 0; i < 16; i++) {
146
- bytes[i] = Number.parseInt(hex.substr(i * 2, 2), 16);
147
- }
148
- return bytes;
149
- }
150
- async function hashBytes4(data) {
151
- const hex = await xxhash128(data);
152
- return hexToBytes3(hex);
153
- }
154
- async function hashString4(str, encoding = "utf8") {
155
- if (encoding !== "utf8") {
156
- throw new FulHashError(
157
- "XXH3-128 only supports UTF-8 encoding. Use utf8 encoding or convert data to Uint8Array."
158
- );
159
- }
160
- const hex = await xxhash128(str);
161
- return hexToBytes3(hex);
162
- }
163
- var init_xxh3 = __esm({
164
- "src/fulhash/algorithms/xxh3.ts"() {
165
- init_errors();
166
- }
167
- });
168
-
169
- // src/fulhash/hash.ts
170
- var hash_exports = {};
171
- __export(hash_exports, {
172
- hash: () => hash,
173
- hashBytes: () => hashBytes5,
174
- hashString: () => hashString5
175
- });
176
- async function hash(input, options) {
177
- const algorithm = options?.algorithm ?? "xxh3-128" /* XXH3_128 */;
178
- const encoding = options?.encoding ?? "utf8";
179
- let bytes;
180
- switch (algorithm) {
181
- case "sha256" /* SHA256 */:
182
- if (typeof input === "string") {
183
- bytes = hashString3(input, encoding);
184
- } else {
185
- bytes = hashBytes3(input);
186
- }
187
- break;
188
- case "xxh3-128" /* XXH3_128 */:
189
- if (typeof input === "string") {
190
- if (encoding !== "utf8") {
191
- bytes = await hashBytes4(Buffer.from(input, encoding));
192
- } else {
193
- bytes = await hashString4(input, "utf8");
194
- }
195
- } else {
196
- bytes = await hashBytes4(input);
197
- }
198
- break;
199
- case "crc32" /* CRC32 */:
200
- if (typeof input === "string") {
201
- bytes = await hashString(input, encoding);
202
- } else {
203
- bytes = await hashBytes(input);
204
- }
205
- break;
206
- case "crc32c" /* CRC32C */:
207
- if (typeof input === "string") {
208
- bytes = await hashString2(input, encoding);
209
- } else {
210
- bytes = await hashBytes2(input);
211
- }
212
- break;
213
- default:
214
- throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
215
- }
216
- return new Digest(algorithm, bytes);
217
- }
218
- async function hashString5(str, options) {
219
- return hash(str, options);
220
- }
221
- async function hashBytes5(data, options) {
222
- return hash(data, options);
223
- }
224
- var init_hash = __esm({
225
- "src/fulhash/hash.ts"() {
226
- init_types();
227
- init_crc32();
228
- init_crc32c();
229
- init_sha256();
230
- init_xxh3();
231
- init_digest();
232
- init_errors();
233
- }
234
- });
235
-
236
- // src/fulhash/digest.ts
237
- var Digest;
238
- var init_digest = __esm({
239
- "src/fulhash/digest.ts"() {
240
- init_types();
241
- init_errors();
242
- Digest = class _Digest {
243
- algorithm;
244
- _bytes;
245
- hex;
246
- formatted;
247
- constructor(algorithm, bytes) {
248
- this.algorithm = algorithm;
249
- this._bytes = new Uint8Array(bytes);
250
- this.hex = Array.from(this._bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
251
- this.formatted = `${this.algorithm}:${this.hex}`;
252
- Object.freeze(this);
253
- }
254
- get bytes() {
255
- return Array.from(this._bytes);
256
- }
257
- toJSON() {
258
- return {
259
- algorithm: this.algorithm,
260
- hex: this.hex,
261
- formatted: this.formatted
262
- };
263
- }
264
- toString() {
265
- return this.formatted;
266
- }
267
- static parse(formatted) {
268
- if (!formatted.includes(":")) {
269
- throw new InvalidChecksumFormatError(formatted, "missing separator");
270
- }
271
- const [algorithmStr, hex] = formatted.split(":", 2);
272
- if (!algorithmStr || !hex) {
273
- throw new InvalidChecksumFormatError(formatted, "invalid format");
274
- }
275
- const algorithm = algorithmStr;
276
- if (!Object.values(Algorithm).includes(algorithm)) {
277
- throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
278
- }
279
- if (!/^[0-9a-f]+$/.test(hex)) {
280
- throw new InvalidChecksumError(
281
- formatted,
282
- "hex must contain only lowercase hexadecimal characters"
283
- );
284
- }
285
- let expectedLength;
286
- switch (algorithm) {
287
- case "xxh3-128" /* XXH3_128 */:
288
- expectedLength = 32;
289
- break;
290
- case "sha256" /* SHA256 */:
291
- expectedLength = 64;
292
- break;
293
- case "crc32" /* CRC32 */:
294
- case "crc32c" /* CRC32C */:
295
- expectedLength = 8;
296
- break;
297
- default:
298
- throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
299
- }
300
- if (hex.length !== expectedLength) {
301
- throw new InvalidChecksumError(
302
- formatted,
303
- `invalid hex length for ${algorithm}: expected ${expectedLength}, got ${hex.length}`
304
- );
305
- }
306
- const bytes = new Uint8Array(hex.length / 2);
307
- for (let i = 0; i < hex.length; i += 2) {
308
- bytes[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
309
- }
310
- return new _Digest(algorithm, bytes);
311
- }
312
- equals(other) {
313
- if (this.algorithm !== other.algorithm) {
314
- return false;
315
- }
316
- if (this.hex !== other.hex) {
317
- return false;
318
- }
319
- return true;
320
- }
321
- static async verify(data, checksum) {
322
- const expected = _Digest.parse(checksum);
323
- const { hash: hash2 } = await Promise.resolve().then(() => (init_hash(), hash_exports));
324
- const actual = await hash2(data, { algorithm: expected.algorithm });
325
- return actual.equals(expected);
326
- }
327
- };
328
- }
329
- });
330
-
331
- // src/fulhash/index.ts
332
- init_types();
333
-
334
- // src/fulhash/convenience.ts
335
- init_digest();
336
-
337
- // src/fulhash/stream.ts
338
- init_types();
339
- init_crc32();
340
- init_crc32c();
341
- init_digest();
342
- init_errors();
343
-
344
- // src/fulhash/wasm-loader.ts
345
- init_errors();
346
- var isWasmReady = false;
347
- var initPromise = null;
348
- async function initializeWasm() {
349
- if (isWasmReady) {
350
- return;
351
- }
352
- if (initPromise) {
353
- return initPromise;
354
- }
355
- initPromise = createXXHash128().then(() => {
356
- isWasmReady = true;
357
- }).catch((error) => {
358
- initPromise = null;
359
- throw new FulHashError(`Failed to initialize hash-wasm XXH3-128 module: ${error.message}`);
360
- });
361
- return initPromise;
362
- }
363
- async function createHasher3() {
364
- if (!isWasmReady) {
365
- throw new FulHashError("WASM not initialized. Call initializeWasm() first.");
366
- }
367
- return createXXHash128();
368
- }
369
-
370
- // src/fulhash/stream.ts
371
- function intToBytes(crc) {
372
- const bytes = new Uint8Array(4);
373
- const unsigned = crc >>> 0;
374
- bytes[0] = unsigned >>> 24 & 255;
375
- bytes[1] = unsigned >>> 16 & 255;
376
- bytes[2] = unsigned >>> 8 & 255;
377
- bytes[3] = unsigned & 255;
378
- return bytes;
379
- }
380
- var BaseStreamHasher = class {
381
- state = "initial" /* INITIAL */;
382
- algorithm;
383
- constructor(algorithm) {
384
- this.algorithm = algorithm;
385
- }
386
- ensureNotFinalized() {
387
- if (this.state === "finalized" /* FINALIZED */) {
388
- throw new DigestStateError("Cannot update after digest(). Call reset() to reuse hasher.");
389
- }
390
- }
391
- ensureUpdating() {
392
- if (this.state !== "updating" /* UPDATING */ && this.state !== "initial" /* INITIAL */) {
393
- throw new DigestStateError("Invalid state for digest(). Hasher may have been finalized.");
394
- }
395
- }
396
- markUpdating() {
397
- this.state = "updating" /* UPDATING */;
398
- }
399
- markFinalized() {
400
- this.state = "finalized" /* FINALIZED */;
401
- }
402
- markInitial() {
403
- this.state = "initial" /* INITIAL */;
404
- }
405
- };
406
- var SHA256StreamHasher = class extends BaseStreamHasher {
407
- hasher;
408
- constructor() {
409
- super("sha256" /* SHA256 */);
410
- this.hasher = createHash("sha256");
411
- }
412
- update(data) {
413
- this.ensureNotFinalized();
414
- this.markUpdating();
415
- if (typeof data === "string") {
416
- this.hasher.update(data, "utf8");
417
- } else {
418
- this.hasher.update(data);
419
- }
420
- return this;
421
- }
422
- digest() {
423
- this.ensureUpdating();
424
- this.markFinalized();
425
- const bytes = new Uint8Array(this.hasher.digest());
426
- return new Digest(this.algorithm, bytes);
427
- }
428
- reset() {
429
- this.hasher = createHash("sha256");
430
- this.markInitial();
431
- return this;
432
- }
433
- };
434
- var XXH3StreamHasher = class extends BaseStreamHasher {
435
- hasher;
436
- constructor(hasher) {
437
- super("xxh3-128" /* XXH3_128 */);
438
- this.hasher = hasher;
439
- this.hasher.init();
440
- }
441
- update(data) {
442
- this.ensureNotFinalized();
443
- this.markUpdating();
444
- if (typeof data === "string") {
445
- const encoder = new TextEncoder();
446
- this.hasher.update(encoder.encode(data));
447
- } else {
448
- this.hasher.update(data);
449
- }
450
- return this;
451
- }
452
- digest() {
453
- this.ensureUpdating();
454
- this.markFinalized();
455
- const bytes = this.hasher.digest("binary");
456
- return new Digest(this.algorithm, bytes);
457
- }
458
- reset() {
459
- this.hasher.init();
460
- this.markInitial();
461
- return this;
462
- }
463
- };
464
- var CRC32StreamHasher = class extends BaseStreamHasher {
465
- hasher = null;
466
- constructor() {
467
- super("crc32" /* CRC32 */);
468
- }
469
- async init() {
470
- this.hasher = await createHasher();
471
- this.hasher.init();
472
- }
473
- update(data) {
474
- this.ensureNotFinalized();
475
- this.markUpdating();
476
- if (!this.hasher) {
477
- throw new Error("Hasher not initialized");
478
- }
479
- if (typeof data === "string") {
480
- const encoder = new TextEncoder();
481
- this.hasher.update(encoder.encode(data));
482
- } else {
483
- this.hasher.update(data);
484
- }
485
- return this;
486
- }
487
- digest() {
488
- this.ensureUpdating();
489
- this.markFinalized();
490
- if (!this.hasher) throw new Error("Hasher not initialized");
491
- const hex = this.hasher.digest();
492
- const bytes = intToBytes(parseInt(hex, 16));
493
- return new Digest(this.algorithm, bytes);
494
- }
495
- reset() {
496
- if (!this.hasher) throw new Error("Hasher not initialized");
497
- this.hasher.init();
498
- this.markInitial();
499
- return this;
500
- }
501
- };
502
- var CRC32CStreamHasher = class extends BaseStreamHasher {
503
- hasher = null;
504
- constructor() {
505
- super("crc32c" /* CRC32C */);
506
- }
507
- async init() {
508
- this.hasher = await createHasher2();
509
- this.hasher.init();
510
- }
511
- update(data) {
512
- this.ensureNotFinalized();
513
- this.markUpdating();
514
- if (!this.hasher) throw new Error("Hasher not initialized");
515
- if (typeof data === "string") {
516
- const encoder = new TextEncoder();
517
- this.hasher.update(encoder.encode(data));
518
- } else {
519
- this.hasher.update(data);
520
- }
521
- return this;
522
- }
523
- digest() {
524
- this.ensureUpdating();
525
- this.markFinalized();
526
- if (!this.hasher) throw new Error("Hasher not initialized");
527
- const hex = this.hasher.digest();
528
- const bytes = intToBytes(parseInt(hex, 16));
529
- return new Digest(this.algorithm, bytes);
530
- }
531
- reset() {
532
- if (!this.hasher) throw new Error("Hasher not initialized");
533
- this.hasher.init();
534
- this.markInitial();
535
- return this;
536
- }
537
- };
538
- async function createStreamHasher(options = {}) {
539
- const algorithm = options.algorithm ?? "xxh3-128" /* XXH3_128 */;
540
- switch (algorithm) {
541
- case "sha256" /* SHA256 */:
542
- return new SHA256StreamHasher();
543
- case "xxh3-128" /* XXH3_128 */: {
544
- await initializeWasm();
545
- const wasmHasher = await createHasher3();
546
- return new XXH3StreamHasher(wasmHasher);
547
- }
548
- case "crc32" /* CRC32 */: {
549
- const hasher = new CRC32StreamHasher();
550
- await hasher.init();
551
- return hasher;
552
- }
553
- case "crc32c" /* CRC32C */: {
554
- const hasher = new CRC32CStreamHasher();
555
- await hasher.init();
556
- return hasher;
557
- }
558
- default:
559
- throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
560
- }
561
- }
562
-
563
- // src/fulhash/convenience.ts
564
- async function multiHash(input, algorithms, encoding = "utf8") {
565
- const uniqueAlgorithms = [...new Set(algorithms)];
566
- const hashers = await Promise.all(
567
- uniqueAlgorithms.map((algo) => createStreamHasher({ algorithm: algo }))
568
- );
569
- if (typeof input === "string") {
570
- if (encoding !== "utf8") {
571
- const buf = Buffer.from(input, encoding);
572
- for (const hasher of hashers) {
573
- hasher.update(buf);
574
- }
575
- } else {
576
- for (const hasher of hashers) {
577
- hasher.update(input);
578
- }
579
- }
580
- } else if (input instanceof Uint8Array) {
581
- for (const hasher of hashers) {
582
- hasher.update(input);
583
- }
584
- } else {
585
- for await (const chunk of input) {
586
- for (const hasher of hashers) {
587
- hasher.update(chunk);
588
- }
589
- }
590
- }
591
- const result = {};
592
- for (let i = 0; i < uniqueAlgorithms.length; i++) {
593
- result[uniqueAlgorithms[i]] = hashers[i].digest();
594
- }
595
- return result;
596
- }
597
- async function verify(input, checksum, encoding = "utf8") {
598
- const expected = Digest.parse(checksum);
599
- const result = await multiHash(input, [expected.algorithm], encoding);
600
- const actual = result[expected.algorithm];
601
- if (!actual) return false;
602
- return actual.algorithm === expected.algorithm && actual.hex === expected.hex;
603
- }
604
-
605
- // src/fulhash/index.ts
606
- init_digest();
607
- init_errors();
608
- init_hash();
609
- var VERSION = "1.0.0";
610
-
611
- export { Algorithm, Digest, DigestStateError, FulHashError, InvalidChecksumError, InvalidChecksumFormatError, UnsupportedAlgorithmError, VERSION, createStreamHasher, hash, hashBytes5 as hashBytes, hashString5 as hashString, multiHash, verify };
1
+ export { VERSION, createStreamHasher, multiHash, verify } from '../chunk-WSMVLWLB.js';
2
+ export { Algorithm, Digest, DigestStateError, FulHashError, InvalidChecksumError, InvalidChecksumFormatError, UnsupportedAlgorithmError, hash, hashBytes, hashString } from '../chunk-OHE2AOH4.js';
3
+ import '../chunk-UP2VWCW5.js';
612
4
  //# sourceMappingURL=index.js.map
613
5
  //# sourceMappingURL=index.js.map