@glyphteck/veyl 0.50.0 → 0.51.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.
@@ -0,0 +1,1402 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, {
40
+ get: all[name],
41
+ enumerable: true,
42
+ configurable: true,
43
+ set: __exportSetter.bind(all, name)
44
+ });
45
+ };
46
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
48
+
49
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/_u64.js
50
+ function fromBig(n, le = false) {
51
+ if (le)
52
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
53
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
54
+ }
55
+ function split(lst, le = false) {
56
+ const len = lst.length;
57
+ let Ah = new Uint32Array(len);
58
+ let Al = new Uint32Array(len);
59
+ for (let i = 0;i < len; i++) {
60
+ const { h, l } = fromBig(lst[i], le);
61
+ [Ah[i], Al[i]] = [h, l];
62
+ }
63
+ return [Ah, Al];
64
+ }
65
+ function add(Ah, Al, Bh, Bl) {
66
+ const l = (Al >>> 0) + (Bl >>> 0);
67
+ return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
68
+ }
69
+ var U32_MASK64, _32n, shrSH = (h, _l, s) => h >>> s, shrSL = (h, l, s) => h << 32 - s | l >>> s, rotrSH = (h, l, s) => h >>> s | l << 32 - s, rotrSL = (h, l, s) => h << 32 - s | l >>> s, rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32, rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s, rotr32H = (_h, l) => l, rotr32L = (h, _l) => h, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0, add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0), add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0, add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0), add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
70
+ var init__u64 = __esm(() => {
71
+ U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
72
+ _32n = /* @__PURE__ */ BigInt(32);
73
+ });
74
+
75
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/utils.js
76
+ function isBytes(a) {
77
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
78
+ }
79
+ function anumber(n, title = "") {
80
+ if (typeof n !== "number") {
81
+ const prefix = title && `"${title}" `;
82
+ throw new TypeError(`${prefix}expected number, got ${typeof n}`);
83
+ }
84
+ if (!Number.isSafeInteger(n) || n < 0) {
85
+ const prefix = title && `"${title}" `;
86
+ throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
87
+ }
88
+ }
89
+ function abytes(value, length, title = "") {
90
+ const bytes = isBytes(value);
91
+ const len = value?.length;
92
+ const needsLen = length !== undefined;
93
+ if (!bytes || needsLen && len !== length) {
94
+ const prefix = title && `"${title}" `;
95
+ const ofLen = needsLen ? ` of length ${length}` : "";
96
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
97
+ const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
98
+ if (!bytes)
99
+ throw new TypeError(message);
100
+ throw new RangeError(message);
101
+ }
102
+ return value;
103
+ }
104
+ function ahash(h) {
105
+ if (typeof h !== "function" || typeof h.create !== "function")
106
+ throw new TypeError("Hash must wrapped by utils.createHasher");
107
+ anumber(h.outputLen);
108
+ anumber(h.blockLen);
109
+ if (h.outputLen < 1)
110
+ throw new Error('"outputLen" must be >= 1');
111
+ if (h.blockLen < 1)
112
+ throw new Error('"blockLen" must be >= 1');
113
+ }
114
+ function aexists(instance, checkFinished = true) {
115
+ if (instance.destroyed)
116
+ throw new Error("Hash instance has been destroyed");
117
+ if (checkFinished && instance.finished)
118
+ throw new Error("Hash#digest() has already been called");
119
+ }
120
+ function aoutput(out, instance) {
121
+ abytes(out, undefined, "digestInto() output");
122
+ const min = instance.outputLen;
123
+ if (out.length < min) {
124
+ throw new RangeError('"digestInto() output" expected to be of length >=' + min);
125
+ }
126
+ }
127
+ function u8(arr) {
128
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
129
+ }
130
+ function u32(arr) {
131
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
132
+ }
133
+ function clean(...arrays) {
134
+ for (let i = 0;i < arrays.length; i++) {
135
+ arrays[i].fill(0);
136
+ }
137
+ }
138
+ function createView(arr) {
139
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
140
+ }
141
+ function rotr(word, shift) {
142
+ return word << 32 - shift | word >>> shift;
143
+ }
144
+ function byteSwap(word) {
145
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
146
+ }
147
+ function byteSwap32(arr) {
148
+ for (let i = 0;i < arr.length; i++) {
149
+ arr[i] = byteSwap(arr[i]);
150
+ }
151
+ return arr;
152
+ }
153
+ function bytesToHex(bytes) {
154
+ abytes(bytes);
155
+ if (hasHexBuiltin)
156
+ return bytes.toHex();
157
+ let hex = "";
158
+ for (let i = 0;i < bytes.length; i++) {
159
+ hex += hexes[bytes[i]];
160
+ }
161
+ return hex;
162
+ }
163
+ function asciiToBase16(ch) {
164
+ if (ch >= asciis._0 && ch <= asciis._9)
165
+ return ch - asciis._0;
166
+ if (ch >= asciis.A && ch <= asciis.F)
167
+ return ch - (asciis.A - 10);
168
+ if (ch >= asciis.a && ch <= asciis.f)
169
+ return ch - (asciis.a - 10);
170
+ return;
171
+ }
172
+ function hexToBytes(hex) {
173
+ if (typeof hex !== "string")
174
+ throw new TypeError("hex string expected, got " + typeof hex);
175
+ if (hasHexBuiltin) {
176
+ try {
177
+ return Uint8Array.fromHex(hex);
178
+ } catch (error) {
179
+ if (error instanceof SyntaxError)
180
+ throw new RangeError(error.message);
181
+ throw error;
182
+ }
183
+ }
184
+ const hl = hex.length;
185
+ const al = hl / 2;
186
+ if (hl % 2)
187
+ throw new RangeError("hex string expected, got unpadded hex of length " + hl);
188
+ const array = new Uint8Array(al);
189
+ for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
190
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
191
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
192
+ if (n1 === undefined || n2 === undefined) {
193
+ const char = hex[hi] + hex[hi + 1];
194
+ throw new RangeError('hex string expected, got non-hex character "' + char + '" at index ' + hi);
195
+ }
196
+ array[ai] = n1 * 16 + n2;
197
+ }
198
+ return array;
199
+ }
200
+ function utf8ToBytes(str) {
201
+ if (typeof str !== "string")
202
+ throw new TypeError("string expected");
203
+ return new Uint8Array(new TextEncoder().encode(str));
204
+ }
205
+ function kdfInputToBytes(data, errorTitle = "") {
206
+ if (typeof data === "string")
207
+ return utf8ToBytes(data);
208
+ return abytes(data, undefined, errorTitle);
209
+ }
210
+ function concatBytes(...arrays) {
211
+ let sum = 0;
212
+ for (let i = 0;i < arrays.length; i++) {
213
+ const a = arrays[i];
214
+ abytes(a);
215
+ sum += a.length;
216
+ }
217
+ const res = new Uint8Array(sum);
218
+ for (let i = 0, pad = 0;i < arrays.length; i++) {
219
+ const a = arrays[i];
220
+ res.set(a, pad);
221
+ pad += a.length;
222
+ }
223
+ return res;
224
+ }
225
+ function createHasher(hashCons, info = {}) {
226
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
227
+ const tmp = hashCons(undefined);
228
+ hashC.outputLen = tmp.outputLen;
229
+ hashC.blockLen = tmp.blockLen;
230
+ hashC.canXOF = tmp.canXOF;
231
+ hashC.create = (opts) => hashCons(opts);
232
+ Object.assign(hashC, info);
233
+ return Object.freeze(hashC);
234
+ }
235
+ function randomBytes(bytesLength = 32) {
236
+ anumber(bytesLength, "bytesLength");
237
+ const cr = typeof globalThis === "object" ? globalThis.crypto : null;
238
+ if (typeof cr?.getRandomValues !== "function")
239
+ throw new Error("crypto.getRandomValues must be defined");
240
+ if (bytesLength > 65536)
241
+ throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
242
+ return cr.getRandomValues(new Uint8Array(bytesLength));
243
+ }
244
+ var isLE, swap8IfBE, swap32IfBE, hasHexBuiltin, hexes, asciis, oidNist = (suffix) => ({
245
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
246
+ });
247
+ var init_utils = __esm(() => {
248
+ isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
249
+ swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n) >>> 0;
250
+ swap32IfBE = isLE ? (u) => u : byteSwap32;
251
+ hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
252
+ hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
253
+ asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
254
+ });
255
+
256
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js
257
+ function Chi(a, b, c) {
258
+ return a & b ^ ~a & c;
259
+ }
260
+ function Maj(a, b, c) {
261
+ return a & b ^ a & c ^ b & c;
262
+ }
263
+
264
+ class HashMD {
265
+ blockLen;
266
+ outputLen;
267
+ canXOF = false;
268
+ padOffset;
269
+ isLE;
270
+ buffer;
271
+ view;
272
+ finished = false;
273
+ length = 0;
274
+ pos = 0;
275
+ destroyed = false;
276
+ constructor(blockLen, outputLen, padOffset, isLE2) {
277
+ this.blockLen = blockLen;
278
+ this.outputLen = outputLen;
279
+ this.padOffset = padOffset;
280
+ this.isLE = isLE2;
281
+ this.buffer = new Uint8Array(blockLen);
282
+ this.view = createView(this.buffer);
283
+ }
284
+ update(data) {
285
+ aexists(this);
286
+ abytes(data);
287
+ const { view, buffer, blockLen } = this;
288
+ const len = data.length;
289
+ for (let pos = 0;pos < len; ) {
290
+ const take = Math.min(blockLen - this.pos, len - pos);
291
+ if (take === blockLen) {
292
+ const dataView = createView(data);
293
+ for (;blockLen <= len - pos; pos += blockLen)
294
+ this.process(dataView, pos);
295
+ continue;
296
+ }
297
+ buffer.set(data.subarray(pos, pos + take), this.pos);
298
+ this.pos += take;
299
+ pos += take;
300
+ if (this.pos === blockLen) {
301
+ this.process(view, 0);
302
+ this.pos = 0;
303
+ }
304
+ }
305
+ this.length += data.length;
306
+ this.roundClean();
307
+ return this;
308
+ }
309
+ digestInto(out) {
310
+ aexists(this);
311
+ aoutput(out, this);
312
+ this.finished = true;
313
+ const { buffer, view, blockLen, isLE: isLE2 } = this;
314
+ let { pos } = this;
315
+ buffer[pos++] = 128;
316
+ clean(this.buffer.subarray(pos));
317
+ if (this.padOffset > blockLen - pos) {
318
+ this.process(view, 0);
319
+ pos = 0;
320
+ }
321
+ for (let i = pos;i < blockLen; i++)
322
+ buffer[i] = 0;
323
+ view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE2);
324
+ this.process(view, 0);
325
+ const oview = createView(out);
326
+ const len = this.outputLen;
327
+ if (len % 4)
328
+ throw new Error("_sha2: outputLen must be aligned to 32bit");
329
+ const outLen = len / 4;
330
+ const state = this.get();
331
+ if (outLen > state.length)
332
+ throw new Error("_sha2: outputLen bigger than state");
333
+ for (let i = 0;i < outLen; i++)
334
+ oview.setUint32(4 * i, state[i], isLE2);
335
+ }
336
+ digest() {
337
+ const { buffer, outputLen } = this;
338
+ this.digestInto(buffer);
339
+ const res = buffer.slice(0, outputLen);
340
+ this.destroy();
341
+ return res;
342
+ }
343
+ _cloneInto(to) {
344
+ to ||= new this.constructor;
345
+ to.set(...this.get());
346
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
347
+ to.destroyed = destroyed;
348
+ to.finished = finished;
349
+ to.length = length;
350
+ to.pos = pos;
351
+ if (length % blockLen)
352
+ to.buffer.set(buffer);
353
+ return to;
354
+ }
355
+ clone() {
356
+ return this._cloneInto();
357
+ }
358
+ }
359
+ var SHA256_IV, SHA224_IV, SHA384_IV, SHA512_IV;
360
+ var init__md = __esm(() => {
361
+ init_utils();
362
+ SHA256_IV = /* @__PURE__ */ Uint32Array.from([
363
+ 1779033703,
364
+ 3144134277,
365
+ 1013904242,
366
+ 2773480762,
367
+ 1359893119,
368
+ 2600822924,
369
+ 528734635,
370
+ 1541459225
371
+ ]);
372
+ SHA224_IV = /* @__PURE__ */ Uint32Array.from([
373
+ 3238371032,
374
+ 914150663,
375
+ 812702999,
376
+ 4144912697,
377
+ 4290775857,
378
+ 1750603025,
379
+ 1694076839,
380
+ 3204075428
381
+ ]);
382
+ SHA384_IV = /* @__PURE__ */ Uint32Array.from([
383
+ 3418070365,
384
+ 3238371032,
385
+ 1654270250,
386
+ 914150663,
387
+ 2438529370,
388
+ 812702999,
389
+ 355462360,
390
+ 4144912697,
391
+ 1731405415,
392
+ 4290775857,
393
+ 2394180231,
394
+ 1750603025,
395
+ 3675008525,
396
+ 1694076839,
397
+ 1203062813,
398
+ 3204075428
399
+ ]);
400
+ SHA512_IV = /* @__PURE__ */ Uint32Array.from([
401
+ 1779033703,
402
+ 4089235720,
403
+ 3144134277,
404
+ 2227873595,
405
+ 1013904242,
406
+ 4271175723,
407
+ 2773480762,
408
+ 1595750129,
409
+ 1359893119,
410
+ 2917565137,
411
+ 2600822924,
412
+ 725511199,
413
+ 528734635,
414
+ 4215389547,
415
+ 1541459225,
416
+ 327033209
417
+ ]);
418
+ });
419
+
420
+ // src/runtime/kdf-worker-thread.js
421
+ import { parentPort } from "node:worker_threads";
422
+
423
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/argon2.js
424
+ init__u64();
425
+
426
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/_blake.js
427
+ init_utils();
428
+ var BSIGMA = /* @__PURE__ */ Uint8Array.from([
429
+ 0,
430
+ 1,
431
+ 2,
432
+ 3,
433
+ 4,
434
+ 5,
435
+ 6,
436
+ 7,
437
+ 8,
438
+ 9,
439
+ 10,
440
+ 11,
441
+ 12,
442
+ 13,
443
+ 14,
444
+ 15,
445
+ 14,
446
+ 10,
447
+ 4,
448
+ 8,
449
+ 9,
450
+ 15,
451
+ 13,
452
+ 6,
453
+ 1,
454
+ 12,
455
+ 0,
456
+ 2,
457
+ 11,
458
+ 7,
459
+ 5,
460
+ 3,
461
+ 11,
462
+ 8,
463
+ 12,
464
+ 0,
465
+ 5,
466
+ 2,
467
+ 15,
468
+ 13,
469
+ 10,
470
+ 14,
471
+ 3,
472
+ 6,
473
+ 7,
474
+ 1,
475
+ 9,
476
+ 4,
477
+ 7,
478
+ 9,
479
+ 3,
480
+ 1,
481
+ 13,
482
+ 12,
483
+ 11,
484
+ 14,
485
+ 2,
486
+ 6,
487
+ 5,
488
+ 10,
489
+ 4,
490
+ 0,
491
+ 15,
492
+ 8,
493
+ 9,
494
+ 0,
495
+ 5,
496
+ 7,
497
+ 2,
498
+ 4,
499
+ 10,
500
+ 15,
501
+ 14,
502
+ 1,
503
+ 11,
504
+ 12,
505
+ 6,
506
+ 8,
507
+ 3,
508
+ 13,
509
+ 2,
510
+ 12,
511
+ 6,
512
+ 10,
513
+ 0,
514
+ 11,
515
+ 8,
516
+ 3,
517
+ 4,
518
+ 13,
519
+ 7,
520
+ 5,
521
+ 15,
522
+ 14,
523
+ 1,
524
+ 9,
525
+ 12,
526
+ 5,
527
+ 1,
528
+ 15,
529
+ 14,
530
+ 13,
531
+ 4,
532
+ 10,
533
+ 0,
534
+ 7,
535
+ 6,
536
+ 3,
537
+ 9,
538
+ 2,
539
+ 8,
540
+ 11,
541
+ 13,
542
+ 11,
543
+ 7,
544
+ 14,
545
+ 12,
546
+ 1,
547
+ 3,
548
+ 9,
549
+ 5,
550
+ 0,
551
+ 15,
552
+ 4,
553
+ 8,
554
+ 6,
555
+ 2,
556
+ 10,
557
+ 6,
558
+ 15,
559
+ 14,
560
+ 9,
561
+ 11,
562
+ 3,
563
+ 0,
564
+ 8,
565
+ 12,
566
+ 2,
567
+ 13,
568
+ 7,
569
+ 1,
570
+ 4,
571
+ 10,
572
+ 5,
573
+ 10,
574
+ 2,
575
+ 8,
576
+ 4,
577
+ 7,
578
+ 6,
579
+ 1,
580
+ 5,
581
+ 15,
582
+ 11,
583
+ 9,
584
+ 14,
585
+ 3,
586
+ 12,
587
+ 13,
588
+ 0,
589
+ 0,
590
+ 1,
591
+ 2,
592
+ 3,
593
+ 4,
594
+ 5,
595
+ 6,
596
+ 7,
597
+ 8,
598
+ 9,
599
+ 10,
600
+ 11,
601
+ 12,
602
+ 13,
603
+ 14,
604
+ 15,
605
+ 14,
606
+ 10,
607
+ 4,
608
+ 8,
609
+ 9,
610
+ 15,
611
+ 13,
612
+ 6,
613
+ 1,
614
+ 12,
615
+ 0,
616
+ 2,
617
+ 11,
618
+ 7,
619
+ 5,
620
+ 3,
621
+ 11,
622
+ 8,
623
+ 12,
624
+ 0,
625
+ 5,
626
+ 2,
627
+ 15,
628
+ 13,
629
+ 10,
630
+ 14,
631
+ 3,
632
+ 6,
633
+ 7,
634
+ 1,
635
+ 9,
636
+ 4,
637
+ 7,
638
+ 9,
639
+ 3,
640
+ 1,
641
+ 13,
642
+ 12,
643
+ 11,
644
+ 14,
645
+ 2,
646
+ 6,
647
+ 5,
648
+ 10,
649
+ 4,
650
+ 0,
651
+ 15,
652
+ 8,
653
+ 9,
654
+ 0,
655
+ 5,
656
+ 7,
657
+ 2,
658
+ 4,
659
+ 10,
660
+ 15,
661
+ 14,
662
+ 1,
663
+ 11,
664
+ 12,
665
+ 6,
666
+ 8,
667
+ 3,
668
+ 13,
669
+ 2,
670
+ 12,
671
+ 6,
672
+ 10,
673
+ 0,
674
+ 11,
675
+ 8,
676
+ 3,
677
+ 4,
678
+ 13,
679
+ 7,
680
+ 5,
681
+ 15,
682
+ 14,
683
+ 1,
684
+ 9
685
+ ]);
686
+ function G1s(a, b, c, d, x) {
687
+ a = a + b + x | 0;
688
+ d = rotr(d ^ a, 16);
689
+ c = c + d | 0;
690
+ b = rotr(b ^ c, 12);
691
+ return { a, b, c, d };
692
+ }
693
+ function G2s(a, b, c, d, x) {
694
+ a = a + b + x | 0;
695
+ d = rotr(d ^ a, 8);
696
+ c = c + d | 0;
697
+ b = rotr(b ^ c, 7);
698
+ return { a, b, c, d };
699
+ }
700
+
701
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/blake2.js
702
+ init__md();
703
+ init__u64();
704
+ init_utils();
705
+ var B2B_IV = /* @__PURE__ */ Uint32Array.from([
706
+ 4089235720,
707
+ 1779033703,
708
+ 2227873595,
709
+ 3144134277,
710
+ 4271175723,
711
+ 1013904242,
712
+ 1595750129,
713
+ 2773480762,
714
+ 2917565137,
715
+ 1359893119,
716
+ 725511199,
717
+ 2600822924,
718
+ 4215389547,
719
+ 528734635,
720
+ 327033209,
721
+ 1541459225
722
+ ]);
723
+ var BBUF = /* @__PURE__ */ new Uint32Array(32);
724
+ function G1b(a, b, c, d, msg, x) {
725
+ const Xl = msg[x], Xh = msg[x + 1];
726
+ let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
727
+ let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
728
+ let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
729
+ let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
730
+ let ll = add3L(Al, Bl, Xl);
731
+ Ah = add3H(ll, Ah, Bh, Xh);
732
+ Al = ll | 0;
733
+ ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
734
+ ({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) });
735
+ ({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
736
+ ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
737
+ ({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) });
738
+ BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
739
+ BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
740
+ BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
741
+ BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
742
+ }
743
+ function G2b(a, b, c, d, msg, x) {
744
+ const Xl = msg[x], Xh = msg[x + 1];
745
+ let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
746
+ let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
747
+ let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
748
+ let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
749
+ let ll = add3L(Al, Bl, Xl);
750
+ Ah = add3H(ll, Ah, Bh, Xh);
751
+ Al = ll | 0;
752
+ ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
753
+ ({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) });
754
+ ({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
755
+ ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
756
+ ({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) });
757
+ BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
758
+ BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
759
+ BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
760
+ BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
761
+ }
762
+ function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
763
+ anumber(keyLen);
764
+ if (outputLen <= 0 || outputLen > keyLen)
765
+ throw new Error("outputLen bigger than keyLen");
766
+ const { key, salt, personalization } = opts;
767
+ if (key !== undefined && (key.length < 1 || key.length > keyLen))
768
+ throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
769
+ if (salt !== undefined)
770
+ abytes(salt, saltLen, "salt");
771
+ if (personalization !== undefined)
772
+ abytes(personalization, persLen, "personalization");
773
+ }
774
+
775
+ class _BLAKE2 {
776
+ buffer;
777
+ buffer32;
778
+ finished = false;
779
+ destroyed = false;
780
+ length = 0;
781
+ pos = 0;
782
+ blockLen;
783
+ outputLen;
784
+ canXOF = false;
785
+ constructor(blockLen, outputLen) {
786
+ anumber(blockLen);
787
+ anumber(outputLen);
788
+ this.blockLen = blockLen;
789
+ this.outputLen = outputLen;
790
+ this.buffer = new Uint8Array(blockLen);
791
+ this.buffer32 = u32(this.buffer);
792
+ }
793
+ update(data) {
794
+ aexists(this);
795
+ abytes(data);
796
+ const { blockLen, buffer, buffer32 } = this;
797
+ const len = data.length;
798
+ const offset = data.byteOffset;
799
+ const buf = data.buffer;
800
+ for (let pos = 0;pos < len; ) {
801
+ if (this.pos === blockLen) {
802
+ swap32IfBE(buffer32);
803
+ this.compress(buffer32, 0, false);
804
+ swap32IfBE(buffer32);
805
+ this.pos = 0;
806
+ }
807
+ const take = Math.min(blockLen - this.pos, len - pos);
808
+ const dataOffset = offset + pos;
809
+ if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
810
+ const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
811
+ swap32IfBE(data32);
812
+ for (let pos32 = 0;pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
813
+ this.length += blockLen;
814
+ this.compress(data32, pos32, false);
815
+ }
816
+ swap32IfBE(data32);
817
+ continue;
818
+ }
819
+ buffer.set(data.subarray(pos, pos + take), this.pos);
820
+ this.pos += take;
821
+ this.length += take;
822
+ pos += take;
823
+ }
824
+ return this;
825
+ }
826
+ digestInto(out) {
827
+ aexists(this);
828
+ aoutput(out, this);
829
+ const { pos, buffer32 } = this;
830
+ this.finished = true;
831
+ clean(this.buffer.subarray(pos));
832
+ swap32IfBE(buffer32);
833
+ this.compress(buffer32, 0, true);
834
+ swap32IfBE(buffer32);
835
+ if (out.byteOffset & 3)
836
+ throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got ' + out.byteOffset);
837
+ const state = this.get();
838
+ const out32 = u32(out);
839
+ const full = Math.floor(this.outputLen / 4);
840
+ for (let i = 0;i < full; i++)
841
+ out32[i] = swap8IfBE(state[i]);
842
+ const tail = this.outputLen % 4;
843
+ if (!tail)
844
+ return;
845
+ const off = full * 4;
846
+ const word = state[full];
847
+ for (let i = 0;i < tail; i++)
848
+ out[off + i] = word >>> 8 * i;
849
+ }
850
+ digest() {
851
+ const { buffer, outputLen } = this;
852
+ this.digestInto(buffer);
853
+ const res = buffer.slice(0, outputLen);
854
+ this.destroy();
855
+ return res;
856
+ }
857
+ _cloneInto(to) {
858
+ const { buffer, length, finished, destroyed, outputLen, pos } = this;
859
+ to ||= new this.constructor({ dkLen: outputLen });
860
+ to.set(...this.get());
861
+ to.buffer.set(buffer);
862
+ to.destroyed = destroyed;
863
+ to.finished = finished;
864
+ to.length = length;
865
+ to.pos = pos;
866
+ to.outputLen = outputLen;
867
+ return to;
868
+ }
869
+ clone() {
870
+ return this._cloneInto();
871
+ }
872
+ }
873
+
874
+ class _BLAKE2b extends _BLAKE2 {
875
+ v0l = B2B_IV[0] | 0;
876
+ v0h = B2B_IV[1] | 0;
877
+ v1l = B2B_IV[2] | 0;
878
+ v1h = B2B_IV[3] | 0;
879
+ v2l = B2B_IV[4] | 0;
880
+ v2h = B2B_IV[5] | 0;
881
+ v3l = B2B_IV[6] | 0;
882
+ v3h = B2B_IV[7] | 0;
883
+ v4l = B2B_IV[8] | 0;
884
+ v4h = B2B_IV[9] | 0;
885
+ v5l = B2B_IV[10] | 0;
886
+ v5h = B2B_IV[11] | 0;
887
+ v6l = B2B_IV[12] | 0;
888
+ v6h = B2B_IV[13] | 0;
889
+ v7l = B2B_IV[14] | 0;
890
+ v7h = B2B_IV[15] | 0;
891
+ constructor(opts = {}) {
892
+ const olen = opts.dkLen === undefined ? 64 : opts.dkLen;
893
+ super(128, olen);
894
+ checkBlake2Opts(olen, opts, 64, 16, 16);
895
+ let { key, personalization, salt } = opts;
896
+ let keyLength = 0;
897
+ if (key !== undefined) {
898
+ abytes(key, undefined, "key");
899
+ keyLength = key.length;
900
+ }
901
+ this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
902
+ if (salt !== undefined) {
903
+ abytes(salt, undefined, "salt");
904
+ const slt = u32(salt);
905
+ this.v4l ^= swap8IfBE(slt[0]);
906
+ this.v4h ^= swap8IfBE(slt[1]);
907
+ this.v5l ^= swap8IfBE(slt[2]);
908
+ this.v5h ^= swap8IfBE(slt[3]);
909
+ }
910
+ if (personalization !== undefined) {
911
+ abytes(personalization, undefined, "personalization");
912
+ const pers = u32(personalization);
913
+ this.v6l ^= swap8IfBE(pers[0]);
914
+ this.v6h ^= swap8IfBE(pers[1]);
915
+ this.v7l ^= swap8IfBE(pers[2]);
916
+ this.v7h ^= swap8IfBE(pers[3]);
917
+ }
918
+ if (key !== undefined) {
919
+ const tmp = new Uint8Array(this.blockLen);
920
+ tmp.set(key);
921
+ this.update(tmp);
922
+ }
923
+ }
924
+ get() {
925
+ let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
926
+ return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h];
927
+ }
928
+ set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) {
929
+ this.v0l = v0l | 0;
930
+ this.v0h = v0h | 0;
931
+ this.v1l = v1l | 0;
932
+ this.v1h = v1h | 0;
933
+ this.v2l = v2l | 0;
934
+ this.v2h = v2h | 0;
935
+ this.v3l = v3l | 0;
936
+ this.v3h = v3h | 0;
937
+ this.v4l = v4l | 0;
938
+ this.v4h = v4h | 0;
939
+ this.v5l = v5l | 0;
940
+ this.v5h = v5h | 0;
941
+ this.v6l = v6l | 0;
942
+ this.v6h = v6h | 0;
943
+ this.v7l = v7l | 0;
944
+ this.v7h = v7h | 0;
945
+ }
946
+ compress(msg, offset, isLast) {
947
+ this.get().forEach((v, i) => BBUF[i] = v);
948
+ BBUF.set(B2B_IV, 16);
949
+ let { h, l } = fromBig(BigInt(this.length));
950
+ BBUF[24] = B2B_IV[8] ^ l;
951
+ BBUF[25] = B2B_IV[9] ^ h;
952
+ if (isLast) {
953
+ BBUF[28] = ~BBUF[28];
954
+ BBUF[29] = ~BBUF[29];
955
+ }
956
+ let j = 0;
957
+ const s = BSIGMA;
958
+ for (let i = 0;i < 12; i++) {
959
+ G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
960
+ G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
961
+ G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
962
+ G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
963
+ G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
964
+ G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
965
+ G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
966
+ G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
967
+ G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
968
+ G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
969
+ G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
970
+ G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
971
+ G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
972
+ G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
973
+ G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
974
+ G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
975
+ }
976
+ this.v0l ^= BBUF[0] ^ BBUF[16];
977
+ this.v0h ^= BBUF[1] ^ BBUF[17];
978
+ this.v1l ^= BBUF[2] ^ BBUF[18];
979
+ this.v1h ^= BBUF[3] ^ BBUF[19];
980
+ this.v2l ^= BBUF[4] ^ BBUF[20];
981
+ this.v2h ^= BBUF[5] ^ BBUF[21];
982
+ this.v3l ^= BBUF[6] ^ BBUF[22];
983
+ this.v3h ^= BBUF[7] ^ BBUF[23];
984
+ this.v4l ^= BBUF[8] ^ BBUF[24];
985
+ this.v4h ^= BBUF[9] ^ BBUF[25];
986
+ this.v5l ^= BBUF[10] ^ BBUF[26];
987
+ this.v5h ^= BBUF[11] ^ BBUF[27];
988
+ this.v6l ^= BBUF[12] ^ BBUF[28];
989
+ this.v6h ^= BBUF[13] ^ BBUF[29];
990
+ this.v7l ^= BBUF[14] ^ BBUF[30];
991
+ this.v7h ^= BBUF[15] ^ BBUF[31];
992
+ clean(BBUF);
993
+ }
994
+ destroy() {
995
+ this.destroyed = true;
996
+ clean(this.buffer32);
997
+ this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
998
+ }
999
+ }
1000
+ var blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
1001
+ function compress(s, offset, msg, rounds, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
1002
+ let j = 0;
1003
+ for (let i = 0;i < rounds; i++) {
1004
+ ({ a: v0, b: v4, c: v8, d: v12 } = G1s(v0, v4, v8, v12, msg[offset + s[j++]]));
1005
+ ({ a: v0, b: v4, c: v8, d: v12 } = G2s(v0, v4, v8, v12, msg[offset + s[j++]]));
1006
+ ({ a: v1, b: v5, c: v9, d: v13 } = G1s(v1, v5, v9, v13, msg[offset + s[j++]]));
1007
+ ({ a: v1, b: v5, c: v9, d: v13 } = G2s(v1, v5, v9, v13, msg[offset + s[j++]]));
1008
+ ({ a: v2, b: v6, c: v10, d: v14 } = G1s(v2, v6, v10, v14, msg[offset + s[j++]]));
1009
+ ({ a: v2, b: v6, c: v10, d: v14 } = G2s(v2, v6, v10, v14, msg[offset + s[j++]]));
1010
+ ({ a: v3, b: v7, c: v11, d: v15 } = G1s(v3, v7, v11, v15, msg[offset + s[j++]]));
1011
+ ({ a: v3, b: v7, c: v11, d: v15 } = G2s(v3, v7, v11, v15, msg[offset + s[j++]]));
1012
+ ({ a: v0, b: v5, c: v10, d: v15 } = G1s(v0, v5, v10, v15, msg[offset + s[j++]]));
1013
+ ({ a: v0, b: v5, c: v10, d: v15 } = G2s(v0, v5, v10, v15, msg[offset + s[j++]]));
1014
+ ({ a: v1, b: v6, c: v11, d: v12 } = G1s(v1, v6, v11, v12, msg[offset + s[j++]]));
1015
+ ({ a: v1, b: v6, c: v11, d: v12 } = G2s(v1, v6, v11, v12, msg[offset + s[j++]]));
1016
+ ({ a: v2, b: v7, c: v8, d: v13 } = G1s(v2, v7, v8, v13, msg[offset + s[j++]]));
1017
+ ({ a: v2, b: v7, c: v8, d: v13 } = G2s(v2, v7, v8, v13, msg[offset + s[j++]]));
1018
+ ({ a: v3, b: v4, c: v9, d: v14 } = G1s(v3, v4, v9, v14, msg[offset + s[j++]]));
1019
+ ({ a: v3, b: v4, c: v9, d: v14 } = G2s(v3, v4, v9, v14, msg[offset + s[j++]]));
1020
+ }
1021
+ return { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 };
1022
+ }
1023
+ var B2S_IV = /* @__PURE__ */ SHA256_IV.slice();
1024
+
1025
+ class _BLAKE2s extends _BLAKE2 {
1026
+ v0 = B2S_IV[0] | 0;
1027
+ v1 = B2S_IV[1] | 0;
1028
+ v2 = B2S_IV[2] | 0;
1029
+ v3 = B2S_IV[3] | 0;
1030
+ v4 = B2S_IV[4] | 0;
1031
+ v5 = B2S_IV[5] | 0;
1032
+ v6 = B2S_IV[6] | 0;
1033
+ v7 = B2S_IV[7] | 0;
1034
+ constructor(opts = {}) {
1035
+ const olen = opts.dkLen === undefined ? 32 : opts.dkLen;
1036
+ super(64, olen);
1037
+ checkBlake2Opts(olen, opts, 32, 8, 8);
1038
+ let { key, personalization, salt } = opts;
1039
+ let keyLength = 0;
1040
+ if (key !== undefined) {
1041
+ abytes(key, undefined, "key");
1042
+ keyLength = key.length;
1043
+ }
1044
+ this.v0 ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
1045
+ if (salt !== undefined) {
1046
+ abytes(salt, undefined, "salt");
1047
+ const slt = u32(salt);
1048
+ this.v4 ^= swap8IfBE(slt[0]);
1049
+ this.v5 ^= swap8IfBE(slt[1]);
1050
+ }
1051
+ if (personalization !== undefined) {
1052
+ abytes(personalization, undefined, "personalization");
1053
+ const pers = u32(personalization);
1054
+ this.v6 ^= swap8IfBE(pers[0]);
1055
+ this.v7 ^= swap8IfBE(pers[1]);
1056
+ }
1057
+ if (key !== undefined) {
1058
+ const tmp = new Uint8Array(this.blockLen);
1059
+ tmp.set(key);
1060
+ this.update(tmp);
1061
+ }
1062
+ }
1063
+ get() {
1064
+ const { v0, v1, v2, v3, v4, v5, v6, v7 } = this;
1065
+ return [v0, v1, v2, v3, v4, v5, v6, v7];
1066
+ }
1067
+ set(v0, v1, v2, v3, v4, v5, v6, v7) {
1068
+ this.v0 = v0 | 0;
1069
+ this.v1 = v1 | 0;
1070
+ this.v2 = v2 | 0;
1071
+ this.v3 = v3 | 0;
1072
+ this.v4 = v4 | 0;
1073
+ this.v5 = v5 | 0;
1074
+ this.v6 = v6 | 0;
1075
+ this.v7 = v7 | 0;
1076
+ }
1077
+ compress(msg, offset, isLast) {
1078
+ const { h, l } = fromBig(BigInt(this.length));
1079
+ const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(BSIGMA, offset, msg, 10, this.v0, this.v1, this.v2, this.v3, this.v4, this.v5, this.v6, this.v7, B2S_IV[0], B2S_IV[1], B2S_IV[2], B2S_IV[3], l ^ B2S_IV[4], h ^ B2S_IV[5], isLast ? ~B2S_IV[6] : B2S_IV[6], B2S_IV[7]);
1080
+ this.v0 ^= v0 ^ v8;
1081
+ this.v1 ^= v1 ^ v9;
1082
+ this.v2 ^= v2 ^ v10;
1083
+ this.v3 ^= v3 ^ v11;
1084
+ this.v4 ^= v4 ^ v12;
1085
+ this.v5 ^= v5 ^ v13;
1086
+ this.v6 ^= v6 ^ v14;
1087
+ this.v7 ^= v7 ^ v15;
1088
+ }
1089
+ destroy() {
1090
+ this.destroyed = true;
1091
+ clean(this.buffer32);
1092
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
1093
+ }
1094
+ }
1095
+
1096
+ // ../../node_modules/.bun/@noble+hashes@2.2.0/node_modules/@noble/hashes/argon2.js
1097
+ init_utils();
1098
+ var AT = { Argond2d: 0, Argon2i: 1, Argon2id: 2 };
1099
+ var ARGON2_SYNC_POINTS = 4;
1100
+ var abytesOrZero = (buf, errorTitle = "") => {
1101
+ if (buf === undefined)
1102
+ return Uint8Array.of();
1103
+ return kdfInputToBytes(buf, errorTitle);
1104
+ };
1105
+ function mul(a, b) {
1106
+ const aL = a & 65535;
1107
+ const aH = a >>> 16;
1108
+ const bL = b & 65535;
1109
+ const bH = b >>> 16;
1110
+ const ll = Math.imul(aL, bL);
1111
+ const hl = Math.imul(aH, bL);
1112
+ const lh = Math.imul(aL, bH);
1113
+ const hh = Math.imul(aH, bH);
1114
+ const carry = (ll >>> 16) + (hl & 65535) + lh;
1115
+ const high = hh + (hl >>> 16) + (carry >>> 16) | 0;
1116
+ const low = carry << 16 | ll & 65535;
1117
+ return { h: high, l: low };
1118
+ }
1119
+ function mul2(a, b) {
1120
+ const { h, l } = mul(a, b);
1121
+ return { h: (h << 1 | l >>> 31) & 4294967295, l: l << 1 & 4294967295 };
1122
+ }
1123
+ function blamka(Ah, Al, Bh, Bl) {
1124
+ const { h: Ch, l: Cl } = mul2(Al, Bl);
1125
+ const Rll = add3L(Al, Bl, Cl);
1126
+ return { h: add3H(Rll, Ah, Bh, Ch), l: Rll | 0 };
1127
+ }
1128
+ var A2_BUF = new Uint32Array(256);
1129
+ function G(a, b, c, d) {
1130
+ let Al = A2_BUF[2 * a], Ah = A2_BUF[2 * a + 1];
1131
+ let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1];
1132
+ let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1];
1133
+ let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1];
1134
+ ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl));
1135
+ ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
1136
+ ({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) });
1137
+ ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl));
1138
+ ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
1139
+ ({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) });
1140
+ ({ h: Ah, l: Al } = blamka(Ah, Al, Bh, Bl));
1141
+ ({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
1142
+ ({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) });
1143
+ ({ h: Ch, l: Cl } = blamka(Ch, Cl, Dh, Dl));
1144
+ ({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
1145
+ ({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) });
1146
+ A2_BUF[2 * a] = Al, A2_BUF[2 * a + 1] = Ah;
1147
+ A2_BUF[2 * b] = Bl, A2_BUF[2 * b + 1] = Bh;
1148
+ A2_BUF[2 * c] = Cl, A2_BUF[2 * c + 1] = Ch;
1149
+ A2_BUF[2 * d] = Dl, A2_BUF[2 * d + 1] = Dh;
1150
+ }
1151
+ function P(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14, v15) {
1152
+ G(v00, v04, v08, v12);
1153
+ G(v01, v05, v09, v13);
1154
+ G(v02, v06, v10, v14);
1155
+ G(v03, v07, v11, v15);
1156
+ G(v00, v05, v10, v15);
1157
+ G(v01, v06, v11, v12);
1158
+ G(v02, v07, v08, v13);
1159
+ G(v03, v04, v09, v14);
1160
+ }
1161
+ function block(x, xPos, yPos, outPos, needXor) {
1162
+ for (let i = 0;i < 256; i++)
1163
+ A2_BUF[i] = x[xPos + i] ^ x[yPos + i];
1164
+ for (let i = 0;i < 128; i += 16) {
1165
+ P(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15);
1166
+ }
1167
+ for (let i = 0;i < 16; i += 2) {
1168
+ P(i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113);
1169
+ }
1170
+ if (needXor)
1171
+ for (let i = 0;i < 256; i++)
1172
+ x[outPos + i] ^= A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i];
1173
+ else
1174
+ for (let i = 0;i < 256; i++)
1175
+ x[outPos + i] = A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i];
1176
+ clean(A2_BUF);
1177
+ }
1178
+ function Hp(A, dkLen) {
1179
+ const A8 = u8(A);
1180
+ const T = new Uint32Array(1);
1181
+ const T8 = u8(T);
1182
+ T[0] = swap8IfBE(dkLen);
1183
+ if (dkLen <= 64)
1184
+ return blake2b.create({ dkLen }).update(T8).update(A8).digest();
1185
+ const out = new Uint8Array(dkLen);
1186
+ let V = blake2b.create({}).update(T8).update(A8).digest();
1187
+ let pos = 0;
1188
+ out.set(V.subarray(0, 32));
1189
+ pos += 32;
1190
+ for (;dkLen - pos > 64; pos += 32) {
1191
+ const Vh = blake2b.create({}).update(V);
1192
+ Vh.digestInto(V);
1193
+ Vh.destroy();
1194
+ out.set(V.subarray(0, 32), pos);
1195
+ }
1196
+ out.set(blake2b(V, { dkLen: dkLen - pos }), pos);
1197
+ clean(V, T);
1198
+ return out;
1199
+ }
1200
+ function indexAlpha(r, s, laneLen, segmentLen, index, randL, sameLane = false) {
1201
+ let area;
1202
+ if (r === 0) {
1203
+ if (s === 0)
1204
+ area = index - 1;
1205
+ else if (sameLane)
1206
+ area = s * segmentLen + index - 1;
1207
+ else
1208
+ area = s * segmentLen + (index == 0 ? -1 : 0);
1209
+ } else if (sameLane)
1210
+ area = laneLen - segmentLen + index - 1;
1211
+ else
1212
+ area = laneLen - segmentLen + (index == 0 ? -1 : 0);
1213
+ const startPos = r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0;
1214
+ const rel = area - 1 - mul(area, mul(randL, randL).h).h;
1215
+ return (startPos + rel) % laneLen;
1216
+ }
1217
+ var maxUint32 = Math.pow(2, 32);
1218
+ function isU32(num) {
1219
+ return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
1220
+ }
1221
+ function argon2Opts(opts) {
1222
+ const merged = {
1223
+ version: 19,
1224
+ dkLen: 32,
1225
+ maxmem: maxUint32 - 1,
1226
+ asyncTick: 10
1227
+ };
1228
+ for (let [k, v] of Object.entries(opts))
1229
+ if (v !== undefined)
1230
+ merged[k] = v;
1231
+ const { dkLen, p, m, t, version, onProgress, asyncTick } = merged;
1232
+ if (!isU32(dkLen) || dkLen < 4)
1233
+ throw new Error('"dkLen" must be 4..');
1234
+ if (!isU32(p) || p < 1 || p >= Math.pow(2, 24))
1235
+ throw new Error('"p" must be 1..2^24');
1236
+ if (!isU32(m))
1237
+ throw new Error('"m" must be 0..2^32');
1238
+ if (!isU32(t) || t < 1)
1239
+ throw new Error('"t" (iterations) must be 1..2^32');
1240
+ if (onProgress !== undefined && typeof onProgress !== "function")
1241
+ throw new Error('"progressCb" must be a function');
1242
+ anumber(asyncTick, "asyncTick");
1243
+ if (!isU32(m) || m < 8 * p)
1244
+ throw new Error('"m" (memory) must be at least 8*p bytes');
1245
+ if (version !== 16 && version !== 19)
1246
+ throw new Error('"version" must be 0x10 or 0x13, got ' + version);
1247
+ return merged;
1248
+ }
1249
+ function argon2Init(password, salt, type, opts) {
1250
+ password = kdfInputToBytes(password, "password");
1251
+ salt = kdfInputToBytes(salt, "salt");
1252
+ if (!isU32(password.length))
1253
+ throw new Error('"password" must be less of length 1..4Gb');
1254
+ if (!isU32(salt.length) || salt.length < 8)
1255
+ throw new Error('"salt" must be of length 8..4Gb');
1256
+ if (!Object.values(AT).includes(type))
1257
+ throw new Error('"type" was invalid');
1258
+ let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts);
1259
+ key = abytesOrZero(key, "key");
1260
+ personalization = abytesOrZero(personalization, "personalization");
1261
+ const h = blake2b.create();
1262
+ const BUF = new Uint32Array(1);
1263
+ const BUF8 = u8(BUF);
1264
+ for (let item of [p, dkLen, m, t, version, type]) {
1265
+ BUF[0] = swap8IfBE(item);
1266
+ h.update(BUF8);
1267
+ }
1268
+ for (let i of [password, salt, key, personalization]) {
1269
+ BUF[0] = swap8IfBE(i.length);
1270
+ h.update(BUF8).update(i);
1271
+ }
1272
+ const H0 = new Uint32Array(18);
1273
+ const H0_8 = u8(H0);
1274
+ h.digestInto(H0_8);
1275
+ const lanes = p;
1276
+ const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p));
1277
+ const laneLen = Math.floor(mP / p);
1278
+ const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS);
1279
+ const memUsed = mP * 1024;
1280
+ if (!isU32(maxmem))
1281
+ throw new Error('"maxmem" expected <2**32, got ' + maxmem);
1282
+ if (memUsed > maxmem)
1283
+ throw new Error('"maxmem" limit was hit: memUsed(mP*1024)=' + memUsed + ", maxmem=" + maxmem);
1284
+ const B = new Uint32Array(memUsed / 4);
1285
+ for (let l = 0;l < p; l++) {
1286
+ const i = 256 * laneLen * l;
1287
+ H0[17] = swap8IfBE(l);
1288
+ H0[16] = swap8IfBE(0);
1289
+ B.set(swap32IfBE(u32(Hp(H0, 1024))), i);
1290
+ H0[16] = swap8IfBE(1);
1291
+ B.set(swap32IfBE(u32(Hp(H0, 1024))), i + 256);
1292
+ }
1293
+ let perBlock = () => {};
1294
+ if (onProgress) {
1295
+ const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen - 2 * p;
1296
+ const callbackPer = Math.max(Math.floor(totalBlock / 1e4), 1);
1297
+ let blockCnt = 0;
1298
+ perBlock = () => {
1299
+ blockCnt++;
1300
+ if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock))
1301
+ onProgress(blockCnt / totalBlock);
1302
+ };
1303
+ }
1304
+ clean(BUF, H0);
1305
+ return { type, mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick };
1306
+ }
1307
+ function argon2Output(B, p, laneLen, dkLen) {
1308
+ const B_final = new Uint32Array(256);
1309
+ for (let l = 0;l < p; l++)
1310
+ for (let j = 0;j < 256; j++)
1311
+ B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j];
1312
+ const res = Hp(swap32IfBE(B_final), dkLen);
1313
+ clean(B, B_final);
1314
+ return res;
1315
+ }
1316
+ function processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor) {
1317
+ if (offset % laneLen)
1318
+ prev = offset - 1;
1319
+ let randL, randH;
1320
+ if (dataIndependent) {
1321
+ let i128 = index % 128;
1322
+ if (i128 === 0) {
1323
+ address[256 + 12]++;
1324
+ block(address, 256, 2 * 256, 0, false);
1325
+ block(address, 0, 2 * 256, 0, false);
1326
+ }
1327
+ randL = address[2 * i128];
1328
+ randH = address[2 * i128 + 1];
1329
+ } else {
1330
+ const T = 256 * prev;
1331
+ randL = B[T];
1332
+ randH = B[T + 1];
1333
+ }
1334
+ const refLane = r === 0 && s === 0 ? l : randH % lanes;
1335
+ const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l);
1336
+ const refBlock = laneLen * refLane + refPos;
1337
+ block(B, 256 * prev, 256 * refBlock, offset * 256, needXor);
1338
+ }
1339
+ function argon2(type, password, salt, opts) {
1340
+ const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock } = argon2Init(password, salt, type, opts);
1341
+ const address = new Uint32Array(3 * 256);
1342
+ address[256 + 6] = mP;
1343
+ address[256 + 8] = t;
1344
+ address[256 + 10] = type;
1345
+ for (let r = 0;r < t; r++) {
1346
+ const needXor = r !== 0 && version === 19;
1347
+ address[256 + 0] = r;
1348
+ for (let s = 0;s < ARGON2_SYNC_POINTS; s++) {
1349
+ address[256 + 4] = s;
1350
+ const dataIndependent = type == AT.Argon2i || type == AT.Argon2id && r === 0 && s < 2;
1351
+ for (let l = 0;l < p; l++) {
1352
+ address[256 + 2] = l;
1353
+ address[256 + 12] = 0;
1354
+ let startPos = 0;
1355
+ if (r === 0 && s === 0) {
1356
+ startPos = 2;
1357
+ if (dataIndependent) {
1358
+ address[256 + 12]++;
1359
+ block(address, 256, 2 * 256, 0, false);
1360
+ block(address, 0, 2 * 256, 0, false);
1361
+ }
1362
+ }
1363
+ let offset = l * laneLen + s * segmentLen + startPos;
1364
+ let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1;
1365
+ for (let index = startPos;index < segmentLen; index++, offset++, prev++) {
1366
+ perBlock();
1367
+ processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor);
1368
+ }
1369
+ }
1370
+ }
1371
+ }
1372
+ clean(address);
1373
+ return argon2Output(B, p, laneLen, dkLen);
1374
+ }
1375
+ var argon2id = (password, salt, opts) => argon2(AT.Argon2id, password, salt, opts);
1376
+
1377
+ // src/runtime/kdf-worker-thread.js
1378
+ if (!parentPort)
1379
+ throw new Error("vault KDF worker port missing");
1380
+ parentPort.on("message", ({ id, password, salt, params }) => {
1381
+ const passwordBytes = new Uint8Array(password);
1382
+ const saltBytes = new Uint8Array(salt);
1383
+ let key = null;
1384
+ try {
1385
+ key = argon2id(passwordBytes, saltBytes, params);
1386
+ parentPort.postMessage({ id, key: key.buffer }, [key.buffer]);
1387
+ key = null;
1388
+ } catch (error) {
1389
+ parentPort.postMessage({
1390
+ id,
1391
+ error: {
1392
+ name: error?.name || "Error",
1393
+ message: error?.message || String(error),
1394
+ code: error?.code || ""
1395
+ }
1396
+ });
1397
+ } finally {
1398
+ passwordBytes.fill(0);
1399
+ saltBytes.fill(0);
1400
+ key?.fill(0);
1401
+ }
1402
+ });