@glyphteck/veyl 0.61.12 → 0.62.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.
- package/dist/account.js +15932 -15425
- package/dist/cli.js +18698 -17860
- package/dist/index.js +18663 -17840
- package/dist/kdf-worker-thread.js +219 -178
- package/docs/api.md +1 -1
- package/examples/bot-fleet/policy.js +52 -3
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ var __export = (target, all) => {
|
|
|
46
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
47
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
48
48
|
|
|
49
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
49
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_u64.js
|
|
50
50
|
function fromBig(n, le = false) {
|
|
51
51
|
if (le)
|
|
52
52
|
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
@@ -62,66 +62,68 @@ function split(lst, le = false) {
|
|
|
62
62
|
}
|
|
63
63
|
return [Ah, Al];
|
|
64
64
|
}
|
|
65
|
+
function setU64FromNum(view, byteOffset, n, isLE) {
|
|
66
|
+
const h = fromNumH(n);
|
|
67
|
+
const l = fromNumL(n);
|
|
68
|
+
view.setUint32(byteOffset, isLE ? l : h, isLE);
|
|
69
|
+
view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
|
|
70
|
+
}
|
|
65
71
|
function add(Ah, Al, Bh, Bl) {
|
|
66
72
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
67
73
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
68
74
|
}
|
|
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;
|
|
75
|
+
var U32_MASK64, _32n, fromNumH = (n) => n / 2 ** 32 | 0, fromNumL = (n) => n >>> 0, 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
76
|
var init__u64 = __esm(() => {
|
|
71
|
-
U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
77
|
+
U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
|
72
78
|
_32n = /* @__PURE__ */ BigInt(32);
|
|
73
79
|
});
|
|
74
80
|
|
|
75
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
81
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/utils.js
|
|
76
82
|
function isBytes(a) {
|
|
77
83
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
78
84
|
}
|
|
79
85
|
function anumber(n, title = "") {
|
|
80
|
-
if (typeof n !== "number")
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const prefix = title && `"${title}" `;
|
|
86
|
-
throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
|
|
87
|
-
}
|
|
86
|
+
if (typeof n !== "number")
|
|
87
|
+
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
88
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
89
|
+
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
90
|
+
return n;
|
|
88
91
|
}
|
|
89
92
|
function abytes(value, length, title = "") {
|
|
93
|
+
if (isBytes(value) && (length === undefined || value.length === length))
|
|
94
|
+
return value;
|
|
95
|
+
if (length !== undefined)
|
|
96
|
+
anumber(length, "length");
|
|
90
97
|
const bytes = isBytes(value);
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
throw new RangeError(message);
|
|
101
|
-
}
|
|
102
|
-
return value;
|
|
98
|
+
const ofLen = length !== undefined ? ` of length ${length}` : "";
|
|
99
|
+
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
100
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
101
|
+
if (!bytes)
|
|
102
|
+
throw new TypeError(message);
|
|
103
|
+
throw new RangeError(message);
|
|
104
|
+
}
|
|
105
|
+
function copyBytes(bytes) {
|
|
106
|
+
return Uint8Array.from(abytes(bytes));
|
|
103
107
|
}
|
|
104
108
|
function ahash(h) {
|
|
105
109
|
if (typeof h !== "function" || typeof h.create !== "function")
|
|
106
|
-
throw new TypeError("
|
|
110
|
+
throw new TypeError("expected hash wrapped by utils.createHasher");
|
|
107
111
|
anumber(h.outputLen);
|
|
108
112
|
anumber(h.blockLen);
|
|
109
|
-
if (h.outputLen < 1)
|
|
110
|
-
throw new Error(
|
|
111
|
-
if (h.blockLen < 1)
|
|
112
|
-
throw new Error('"blockLen" must be >= 1');
|
|
113
|
+
if (h.outputLen < 1 || h.blockLen < 1)
|
|
114
|
+
throw new Error("hash blockLen / outputLen must be >= 1");
|
|
113
115
|
}
|
|
114
116
|
function aexists(instance, checkFinished = true) {
|
|
115
117
|
if (instance.destroyed)
|
|
116
|
-
throw new Error("
|
|
118
|
+
throw new Error("hash was destroyed");
|
|
117
119
|
if (checkFinished && instance.finished)
|
|
118
|
-
throw new Error("
|
|
120
|
+
throw new Error("digest() was already called");
|
|
119
121
|
}
|
|
120
122
|
function aoutput(out, instance) {
|
|
121
|
-
abytes(out, undefined, "
|
|
123
|
+
abytes(out, undefined, "output");
|
|
122
124
|
const min = instance.outputLen;
|
|
123
|
-
if (out.length
|
|
124
|
-
throw new RangeError('"
|
|
125
|
+
if (!(out.length >= min)) {
|
|
126
|
+
throw new RangeError('"output" expected length >= ' + min);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
function u8(arr) {
|
|
@@ -161,13 +163,7 @@ function bytesToHex(bytes) {
|
|
|
161
163
|
return hex;
|
|
162
164
|
}
|
|
163
165
|
function asciiToBase16(ch) {
|
|
164
|
-
|
|
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;
|
|
166
|
+
return ch >= 48 && ch <= 57 ? ch - 48 : ch >= 65 && ch <= 70 ? ch - (65 - 10) : ch >= 97 && ch <= 102 ? ch - (97 - 10) : undefined;
|
|
171
167
|
}
|
|
172
168
|
function hexToBytes(hex) {
|
|
173
169
|
if (typeof hex !== "string")
|
|
@@ -222,7 +218,17 @@ function concatBytes(...arrays) {
|
|
|
222
218
|
}
|
|
223
219
|
return res;
|
|
224
220
|
}
|
|
221
|
+
function checkOpts(defaults, opts, title = "opts") {
|
|
222
|
+
aobject(defaults, "defaults");
|
|
223
|
+
if (opts !== undefined)
|
|
224
|
+
aobject(opts, title);
|
|
225
|
+
const merged = Object.assign(defaults, opts);
|
|
226
|
+
return merged;
|
|
227
|
+
}
|
|
225
228
|
function createHasher(hashCons, info = {}) {
|
|
229
|
+
if (typeof hashCons !== "function")
|
|
230
|
+
throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
|
|
231
|
+
info = checkOpts({}, info, "info");
|
|
226
232
|
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
227
233
|
const tmp = hashCons(undefined);
|
|
228
234
|
hashC.outputLen = tmp.outputLen;
|
|
@@ -241,7 +247,10 @@ function randomBytes(bytesLength = 32) {
|
|
|
241
247
|
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
242
248
|
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
243
249
|
}
|
|
244
|
-
var
|
|
250
|
+
var atitle = (title) => title ? `"${title}" ` : "", aobject = (value, label) => {
|
|
251
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
252
|
+
throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
253
|
+
}, isLE, swap8IfBE, swap32IfBE, hasHexBuiltin, hexes, oidNist = (suffix) => ({
|
|
245
254
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
246
255
|
});
|
|
247
256
|
var init_utils = __esm(() => {
|
|
@@ -250,10 +259,9 @@ var init_utils = __esm(() => {
|
|
|
250
259
|
swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
251
260
|
hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
|
252
261
|
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
262
|
});
|
|
255
263
|
|
|
256
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
264
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_md.js
|
|
257
265
|
function Chi(a, b, c) {
|
|
258
266
|
return a & b ^ ~a & c;
|
|
259
267
|
}
|
|
@@ -286,24 +294,28 @@ class HashMD {
|
|
|
286
294
|
abytes(data);
|
|
287
295
|
const { view, buffer, blockLen } = this;
|
|
288
296
|
const len = data.length;
|
|
297
|
+
let processed = false;
|
|
289
298
|
for (let pos = 0;pos < len; ) {
|
|
290
299
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
291
300
|
if (take === blockLen) {
|
|
292
301
|
const dataView = createView(data);
|
|
293
302
|
for (;blockLen <= len - pos; pos += blockLen)
|
|
294
303
|
this.process(dataView, pos);
|
|
304
|
+
processed = true;
|
|
295
305
|
continue;
|
|
296
306
|
}
|
|
297
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
307
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
298
308
|
this.pos += take;
|
|
299
309
|
pos += take;
|
|
300
310
|
if (this.pos === blockLen) {
|
|
301
311
|
this.process(view, 0);
|
|
302
312
|
this.pos = 0;
|
|
313
|
+
processed = true;
|
|
303
314
|
}
|
|
304
315
|
}
|
|
305
316
|
this.length += data.length;
|
|
306
|
-
|
|
317
|
+
if (processed)
|
|
318
|
+
this.roundClean();
|
|
307
319
|
return this;
|
|
308
320
|
}
|
|
309
321
|
digestInto(out) {
|
|
@@ -313,23 +325,20 @@ class HashMD {
|
|
|
313
325
|
const { buffer, view, blockLen, isLE: isLE2 } = this;
|
|
314
326
|
let { pos } = this;
|
|
315
327
|
buffer[pos++] = 128;
|
|
316
|
-
|
|
328
|
+
buffer.fill(0, pos);
|
|
317
329
|
if (this.padOffset > blockLen - pos) {
|
|
318
330
|
this.process(view, 0);
|
|
319
|
-
|
|
331
|
+
buffer.fill(0);
|
|
320
332
|
}
|
|
321
|
-
|
|
322
|
-
buffer[i] = 0;
|
|
323
|
-
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE2);
|
|
333
|
+
setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
|
|
324
334
|
this.process(view, 0);
|
|
325
|
-
|
|
335
|
+
this.roundClean();
|
|
336
|
+
const oview = out === buffer ? view : createView(out);
|
|
326
337
|
const len = this.outputLen;
|
|
327
|
-
if (len % 4)
|
|
328
|
-
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
329
338
|
const outLen = len / 4;
|
|
330
339
|
const state = this.get();
|
|
331
|
-
if (outLen > state.length)
|
|
332
|
-
throw new Error("
|
|
340
|
+
if (len % 4 || outLen > state.length)
|
|
341
|
+
throw new Error("invalid outputLen");
|
|
333
342
|
for (let i = 0;i < outLen; i++)
|
|
334
343
|
oview.setUint32(4 * i, state[i], isLE2);
|
|
335
344
|
}
|
|
@@ -340,15 +349,13 @@ class HashMD {
|
|
|
340
349
|
this.destroy();
|
|
341
350
|
return res;
|
|
342
351
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
to.set(...this.get());
|
|
346
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
352
|
+
_cloneIntoMeta(to) {
|
|
353
|
+
const { buffer, length, finished, destroyed, pos } = this;
|
|
347
354
|
to.destroyed = destroyed;
|
|
348
355
|
to.finished = finished;
|
|
349
356
|
to.length = length;
|
|
350
357
|
to.pos = pos;
|
|
351
|
-
if (
|
|
358
|
+
if (pos)
|
|
352
359
|
to.buffer.set(buffer);
|
|
353
360
|
return to;
|
|
354
361
|
}
|
|
@@ -356,8 +363,9 @@ class HashMD {
|
|
|
356
363
|
return this._cloneInto();
|
|
357
364
|
}
|
|
358
365
|
}
|
|
359
|
-
var SHA256_IV,
|
|
366
|
+
var SHA256_IV, SHA512_IV;
|
|
360
367
|
var init__md = __esm(() => {
|
|
368
|
+
init__u64();
|
|
361
369
|
init_utils();
|
|
362
370
|
SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
363
371
|
1779033703,
|
|
@@ -369,34 +377,6 @@ var init__md = __esm(() => {
|
|
|
369
377
|
528734635,
|
|
370
378
|
1541459225
|
|
371
379
|
]);
|
|
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
380
|
SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
401
381
|
1779033703,
|
|
402
382
|
4089235720,
|
|
@@ -420,10 +400,10 @@ var init__md = __esm(() => {
|
|
|
420
400
|
// src/runtime/kdf-worker-thread.js
|
|
421
401
|
import { parentPort } from "node:worker_threads";
|
|
422
402
|
|
|
423
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
403
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/argon2.js
|
|
424
404
|
init__u64();
|
|
425
405
|
|
|
426
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
406
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_blake.js
|
|
427
407
|
init_utils();
|
|
428
408
|
var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
429
409
|
0,
|
|
@@ -698,7 +678,7 @@ function G2s(a, b, c, d, x) {
|
|
|
698
678
|
return { a, b, c, d };
|
|
699
679
|
}
|
|
700
680
|
|
|
701
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
681
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/blake2.js
|
|
702
682
|
init__md();
|
|
703
683
|
init__u64();
|
|
704
684
|
init_utils();
|
|
@@ -727,18 +707,25 @@ function G1b(a, b, c, d, msg, x) {
|
|
|
727
707
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
728
708
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
729
709
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
730
|
-
|
|
710
|
+
const ll = add3L(Al, Bl, Xl);
|
|
731
711
|
Ah = add3H(ll, Ah, Bh, Xh);
|
|
732
712
|
Al = ll | 0;
|
|
733
|
-
|
|
734
|
-
|
|
713
|
+
let xh = Dh ^ Ah, xl = Dl ^ Al;
|
|
714
|
+
Dh = rotr32H(xh, xl);
|
|
715
|
+
Dl = rotr32L(xh, xl);
|
|
735
716
|
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
BBUF[2 *
|
|
741
|
-
BBUF[2 *
|
|
717
|
+
xh = Bh ^ Ch;
|
|
718
|
+
xl = Bl ^ Cl;
|
|
719
|
+
Bh = rotrSH(xh, xl, 24);
|
|
720
|
+
Bl = rotrSL(xh, xl, 24);
|
|
721
|
+
BBUF[2 * a] = Al;
|
|
722
|
+
BBUF[2 * a + 1] = Ah;
|
|
723
|
+
BBUF[2 * b] = Bl;
|
|
724
|
+
BBUF[2 * b + 1] = Bh;
|
|
725
|
+
BBUF[2 * c] = Cl;
|
|
726
|
+
BBUF[2 * c + 1] = Ch;
|
|
727
|
+
BBUF[2 * d] = Dl;
|
|
728
|
+
BBUF[2 * d + 1] = Dh;
|
|
742
729
|
}
|
|
743
730
|
function G2b(a, b, c, d, msg, x) {
|
|
744
731
|
const Xl = msg[x], Xh = msg[x + 1];
|
|
@@ -746,23 +733,30 @@ function G2b(a, b, c, d, msg, x) {
|
|
|
746
733
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
747
734
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
748
735
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
749
|
-
|
|
736
|
+
const ll = add3L(Al, Bl, Xl);
|
|
750
737
|
Ah = add3H(ll, Ah, Bh, Xh);
|
|
751
738
|
Al = ll | 0;
|
|
752
|
-
|
|
753
|
-
|
|
739
|
+
let xh = Dh ^ Ah, xl = Dl ^ Al;
|
|
740
|
+
Dh = rotrSH(xh, xl, 16);
|
|
741
|
+
Dl = rotrSL(xh, xl, 16);
|
|
754
742
|
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
BBUF[2 *
|
|
760
|
-
BBUF[2 *
|
|
743
|
+
xh = Bh ^ Ch;
|
|
744
|
+
xl = Bl ^ Cl;
|
|
745
|
+
Bh = rotrBH(xh, xl, 63);
|
|
746
|
+
Bl = rotrBL(xh, xl, 63);
|
|
747
|
+
BBUF[2 * a] = Al;
|
|
748
|
+
BBUF[2 * a + 1] = Ah;
|
|
749
|
+
BBUF[2 * b] = Bl;
|
|
750
|
+
BBUF[2 * b + 1] = Bh;
|
|
751
|
+
BBUF[2 * c] = Cl;
|
|
752
|
+
BBUF[2 * c + 1] = Ch;
|
|
753
|
+
BBUF[2 * d] = Dl;
|
|
754
|
+
BBUF[2 * d + 1] = Dh;
|
|
761
755
|
}
|
|
762
756
|
function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
763
757
|
anumber(keyLen);
|
|
764
758
|
if (outputLen <= 0 || outputLen > keyLen)
|
|
765
|
-
throw new Error("
|
|
759
|
+
throw new Error('"dkLen" must be 1..' + keyLen + ", got " + outputLen);
|
|
766
760
|
const { key, salt, personalization } = opts;
|
|
767
761
|
if (key !== undefined && (key.length < 1 || key.length > keyLen))
|
|
768
762
|
throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
|
|
@@ -816,7 +810,7 @@ class _BLAKE2 {
|
|
|
816
810
|
swap32IfBE(data32);
|
|
817
811
|
continue;
|
|
818
812
|
}
|
|
819
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
813
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
820
814
|
this.pos += take;
|
|
821
815
|
this.length += take;
|
|
822
816
|
pos += take;
|
|
@@ -826,16 +820,16 @@ class _BLAKE2 {
|
|
|
826
820
|
digestInto(out) {
|
|
827
821
|
aexists(this);
|
|
828
822
|
aoutput(out, this);
|
|
823
|
+
if (out.byteOffset & 3)
|
|
824
|
+
throw new RangeError('"output" expected 4-byte aligned byteOffset, got ' + out.byteOffset);
|
|
829
825
|
const { pos, buffer32 } = this;
|
|
830
826
|
this.finished = true;
|
|
831
|
-
|
|
827
|
+
this.buffer.fill(0, pos);
|
|
832
828
|
swap32IfBE(buffer32);
|
|
833
829
|
this.compress(buffer32, 0, true);
|
|
834
830
|
swap32IfBE(buffer32);
|
|
835
|
-
if (out.byteOffset & 3)
|
|
836
|
-
throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got ' + out.byteOffset);
|
|
837
831
|
const state = this.get();
|
|
838
|
-
const out32 = u32(out);
|
|
832
|
+
const out32 = out === this.buffer ? buffer32 : u32(out);
|
|
839
833
|
const full = Math.floor(this.outputLen / 4);
|
|
840
834
|
for (let i = 0;i < full; i++)
|
|
841
835
|
out32[i] = swap8IfBE(state[i]);
|
|
@@ -889,6 +883,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
889
883
|
v7l = B2B_IV[14] | 0;
|
|
890
884
|
v7h = B2B_IV[15] | 0;
|
|
891
885
|
constructor(opts = {}) {
|
|
886
|
+
opts = checkOpts({}, opts);
|
|
892
887
|
const olen = opts.dkLen === undefined ? 64 : opts.dkLen;
|
|
893
888
|
super(128, olen);
|
|
894
889
|
checkBlake2Opts(olen, opts, 64, 16, 16);
|
|
@@ -901,7 +896,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
901
896
|
this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
|
|
902
897
|
if (salt !== undefined) {
|
|
903
898
|
abytes(salt, undefined, "salt");
|
|
904
|
-
const slt = u32(salt);
|
|
899
|
+
const slt = u32(copyBytes(salt));
|
|
905
900
|
this.v4l ^= swap8IfBE(slt[0]);
|
|
906
901
|
this.v4h ^= swap8IfBE(slt[1]);
|
|
907
902
|
this.v5l ^= swap8IfBE(slt[2]);
|
|
@@ -909,7 +904,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
909
904
|
}
|
|
910
905
|
if (personalization !== undefined) {
|
|
911
906
|
abytes(personalization, undefined, "personalization");
|
|
912
|
-
const pers = u32(personalization);
|
|
907
|
+
const pers = u32(copyBytes(personalization));
|
|
913
908
|
this.v6l ^= swap8IfBE(pers[0]);
|
|
914
909
|
this.v6h ^= swap8IfBE(pers[1]);
|
|
915
910
|
this.v7l ^= swap8IfBE(pers[2]);
|
|
@@ -919,6 +914,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
919
914
|
const tmp = new Uint8Array(this.blockLen);
|
|
920
915
|
tmp.set(key);
|
|
921
916
|
this.update(tmp);
|
|
917
|
+
clean(tmp);
|
|
922
918
|
}
|
|
923
919
|
}
|
|
924
920
|
get() {
|
|
@@ -944,9 +940,28 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
944
940
|
this.v7h = v7h | 0;
|
|
945
941
|
}
|
|
946
942
|
compress(msg, offset, isLast) {
|
|
947
|
-
|
|
943
|
+
const { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
|
|
944
|
+
{
|
|
945
|
+
BBUF[0] = v0l;
|
|
946
|
+
BBUF[1] = v0h;
|
|
947
|
+
BBUF[2] = v1l;
|
|
948
|
+
BBUF[3] = v1h;
|
|
949
|
+
BBUF[4] = v2l;
|
|
950
|
+
BBUF[5] = v2h;
|
|
951
|
+
BBUF[6] = v3l;
|
|
952
|
+
BBUF[7] = v3h;
|
|
953
|
+
BBUF[8] = v4l;
|
|
954
|
+
BBUF[9] = v4h;
|
|
955
|
+
BBUF[10] = v5l;
|
|
956
|
+
BBUF[11] = v5h;
|
|
957
|
+
BBUF[12] = v6l;
|
|
958
|
+
BBUF[13] = v6h;
|
|
959
|
+
BBUF[14] = v7l;
|
|
960
|
+
BBUF[15] = v7h;
|
|
961
|
+
}
|
|
948
962
|
BBUF.set(B2B_IV, 16);
|
|
949
|
-
|
|
963
|
+
const l = fromNumL(this.length);
|
|
964
|
+
const h = fromNumH(this.length);
|
|
950
965
|
BBUF[24] = B2B_IV[8] ^ l;
|
|
951
966
|
BBUF[25] = B2B_IV[9] ^ h;
|
|
952
967
|
if (isLast) {
|
|
@@ -998,7 +1013,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
998
1013
|
}
|
|
999
1014
|
}
|
|
1000
1015
|
var blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
|
|
1001
|
-
function
|
|
1016
|
+
function _compress(s, offset, msg, rounds, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
|
|
1002
1017
|
let j = 0;
|
|
1003
1018
|
for (let i = 0;i < rounds; i++) {
|
|
1004
1019
|
({ a: v0, b: v4, c: v8, d: v12 } = G1s(v0, v4, v8, v12, msg[offset + s[j++]]));
|
|
@@ -1032,6 +1047,7 @@ class _BLAKE2s extends _BLAKE2 {
|
|
|
1032
1047
|
v6 = B2S_IV[6] | 0;
|
|
1033
1048
|
v7 = B2S_IV[7] | 0;
|
|
1034
1049
|
constructor(opts = {}) {
|
|
1050
|
+
opts = checkOpts({}, opts);
|
|
1035
1051
|
const olen = opts.dkLen === undefined ? 32 : opts.dkLen;
|
|
1036
1052
|
super(64, olen);
|
|
1037
1053
|
checkBlake2Opts(olen, opts, 32, 8, 8);
|
|
@@ -1044,13 +1060,13 @@ class _BLAKE2s extends _BLAKE2 {
|
|
|
1044
1060
|
this.v0 ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
|
|
1045
1061
|
if (salt !== undefined) {
|
|
1046
1062
|
abytes(salt, undefined, "salt");
|
|
1047
|
-
const slt = u32(salt);
|
|
1063
|
+
const slt = u32(copyBytes(salt));
|
|
1048
1064
|
this.v4 ^= swap8IfBE(slt[0]);
|
|
1049
1065
|
this.v5 ^= swap8IfBE(slt[1]);
|
|
1050
1066
|
}
|
|
1051
1067
|
if (personalization !== undefined) {
|
|
1052
1068
|
abytes(personalization, undefined, "personalization");
|
|
1053
|
-
const pers = u32(personalization);
|
|
1069
|
+
const pers = u32(copyBytes(personalization));
|
|
1054
1070
|
this.v6 ^= swap8IfBE(pers[0]);
|
|
1055
1071
|
this.v7 ^= swap8IfBE(pers[1]);
|
|
1056
1072
|
}
|
|
@@ -1058,6 +1074,7 @@ class _BLAKE2s extends _BLAKE2 {
|
|
|
1058
1074
|
const tmp = new Uint8Array(this.blockLen);
|
|
1059
1075
|
tmp.set(key);
|
|
1060
1076
|
this.update(tmp);
|
|
1077
|
+
clean(tmp);
|
|
1061
1078
|
}
|
|
1062
1079
|
}
|
|
1063
1080
|
get() {
|
|
@@ -1075,8 +1092,9 @@ class _BLAKE2s extends _BLAKE2 {
|
|
|
1075
1092
|
this.v7 = v7 | 0;
|
|
1076
1093
|
}
|
|
1077
1094
|
compress(msg, offset, isLast) {
|
|
1078
|
-
const
|
|
1079
|
-
const
|
|
1095
|
+
const l = fromNumL(this.length);
|
|
1096
|
+
const h = fromNumH(this.length);
|
|
1097
|
+
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
1098
|
this.v0 ^= v0 ^ v8;
|
|
1081
1099
|
this.v1 ^= v1 ^ v9;
|
|
1082
1100
|
this.v2 ^= v2 ^ v10;
|
|
@@ -1093,9 +1111,9 @@ class _BLAKE2s extends _BLAKE2 {
|
|
|
1093
1111
|
}
|
|
1094
1112
|
}
|
|
1095
1113
|
|
|
1096
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
1114
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/argon2.js
|
|
1097
1115
|
init_utils();
|
|
1098
|
-
var AT = {
|
|
1116
|
+
var AT = { Argon2d: 0, Argon2i: 1, Argon2id: 2 };
|
|
1099
1117
|
var ARGON2_SYNC_POINTS = 4;
|
|
1100
1118
|
var abytesOrZero = (buf, errorTitle = "") => {
|
|
1101
1119
|
if (buf === undefined)
|
|
@@ -1116,14 +1134,10 @@ function mul(a, b) {
|
|
|
1116
1134
|
const low = carry << 16 | ll & 65535;
|
|
1117
1135
|
return { h: high, l: low };
|
|
1118
1136
|
}
|
|
1119
|
-
function
|
|
1120
|
-
const
|
|
1121
|
-
|
|
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 };
|
|
1137
|
+
function mulHi(a, b) {
|
|
1138
|
+
const aL = a & 65535, aH = a >>> 16, bL = b & 65535, bH = b >>> 16;
|
|
1139
|
+
const carry = (Math.imul(aL, bL) >>> 16) + (Math.imul(aH, bL) & 65535) + Math.imul(aL, bH);
|
|
1140
|
+
return Math.imul(aH, bH) + (Math.imul(aH, bL) >>> 16) + (carry >>> 16) | 0;
|
|
1127
1141
|
}
|
|
1128
1142
|
var A2_BUF = new Uint32Array(256);
|
|
1129
1143
|
function G(a, b, c, d) {
|
|
@@ -1131,18 +1145,43 @@ function G(a, b, c, d) {
|
|
|
1131
1145
|
let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1];
|
|
1132
1146
|
let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1];
|
|
1133
1147
|
let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1];
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
(
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1148
|
+
let ml = 0, mh = 0, rl = 0, xh = 0, xl = 0;
|
|
1149
|
+
ml = Math.imul(Al, Bl);
|
|
1150
|
+
mh = mulHi(Al, Bl);
|
|
1151
|
+
rl = (Al >>> 0) + (Bl >>> 0) + (ml << 1 >>> 0);
|
|
1152
|
+
Ah = Ah + Bh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1153
|
+
Al = rl | 0;
|
|
1154
|
+
xh = Dh ^ Ah;
|
|
1155
|
+
xl = Dl ^ Al;
|
|
1156
|
+
Dh = rotr32H(xh, xl);
|
|
1157
|
+
Dl = rotr32L(xh, xl);
|
|
1158
|
+
ml = Math.imul(Cl, Dl);
|
|
1159
|
+
mh = mulHi(Cl, Dl);
|
|
1160
|
+
rl = (Cl >>> 0) + (Dl >>> 0) + (ml << 1 >>> 0);
|
|
1161
|
+
Ch = Ch + Dh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1162
|
+
Cl = rl | 0;
|
|
1163
|
+
xh = Bh ^ Ch;
|
|
1164
|
+
xl = Bl ^ Cl;
|
|
1165
|
+
Bh = rotrSH(xh, xl, 24);
|
|
1166
|
+
Bl = rotrSL(xh, xl, 24);
|
|
1167
|
+
ml = Math.imul(Al, Bl);
|
|
1168
|
+
mh = mulHi(Al, Bl);
|
|
1169
|
+
rl = (Al >>> 0) + (Bl >>> 0) + (ml << 1 >>> 0);
|
|
1170
|
+
Ah = Ah + Bh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1171
|
+
Al = rl | 0;
|
|
1172
|
+
xh = Dh ^ Ah;
|
|
1173
|
+
xl = Dl ^ Al;
|
|
1174
|
+
Dh = rotrSH(xh, xl, 16);
|
|
1175
|
+
Dl = rotrSL(xh, xl, 16);
|
|
1176
|
+
ml = Math.imul(Cl, Dl);
|
|
1177
|
+
mh = mulHi(Cl, Dl);
|
|
1178
|
+
rl = (Cl >>> 0) + (Dl >>> 0) + (ml << 1 >>> 0);
|
|
1179
|
+
Ch = Ch + Dh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1180
|
+
Cl = rl | 0;
|
|
1181
|
+
xh = Bh ^ Ch;
|
|
1182
|
+
xl = Bl ^ Cl;
|
|
1183
|
+
Bh = rotrBH(xh, xl, 63);
|
|
1184
|
+
Bl = rotrBL(xh, xl, 63);
|
|
1146
1185
|
A2_BUF[2 * a] = Al, A2_BUF[2 * a + 1] = Ah;
|
|
1147
1186
|
A2_BUF[2 * b] = Bl, A2_BUF[2 * b + 1] = Bh;
|
|
1148
1187
|
A2_BUF[2 * c] = Cl, A2_BUF[2 * c + 1] = Ch;
|
|
@@ -1219,6 +1258,7 @@ function isU32(num) {
|
|
|
1219
1258
|
return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
|
|
1220
1259
|
}
|
|
1221
1260
|
function argon2Opts(opts) {
|
|
1261
|
+
opts = checkOpts({}, opts);
|
|
1222
1262
|
const merged = {
|
|
1223
1263
|
version: 19,
|
|
1224
1264
|
dkLen: 32,
|
|
@@ -1238,7 +1278,7 @@ function argon2Opts(opts) {
|
|
|
1238
1278
|
if (!isU32(t) || t < 1)
|
|
1239
1279
|
throw new Error('"t" (iterations) must be 1..2^32');
|
|
1240
1280
|
if (onProgress !== undefined && typeof onProgress !== "function")
|
|
1241
|
-
throw new Error('"
|
|
1281
|
+
throw new Error('"onProgress" must be a function');
|
|
1242
1282
|
anumber(asyncTick, "asyncTick");
|
|
1243
1283
|
if (!isU32(m) || m < 8 * p)
|
|
1244
1284
|
throw new Error('"m" (memory) must be at least 8*p bytes');
|
|
@@ -1313,31 +1353,8 @@ function argon2Output(B, p, laneLen, dkLen) {
|
|
|
1313
1353
|
clean(B, B_final);
|
|
1314
1354
|
return res;
|
|
1315
1355
|
}
|
|
1316
|
-
function
|
|
1317
|
-
|
|
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);
|
|
1356
|
+
function* argon2Blocks(ctx) {
|
|
1357
|
+
const { type, mP, p, t, version, B, laneLen, lanes, segmentLen, perBlock } = ctx;
|
|
1341
1358
|
const address = new Uint32Array(3 * 256);
|
|
1342
1359
|
address[256 + 6] = mP;
|
|
1343
1360
|
address[256 + 8] = t;
|
|
@@ -1361,16 +1378,40 @@ function argon2(type, password, salt, opts) {
|
|
|
1361
1378
|
}
|
|
1362
1379
|
}
|
|
1363
1380
|
let offset = l * laneLen + s * segmentLen + startPos;
|
|
1364
|
-
let
|
|
1365
|
-
for (let index = startPos;index < segmentLen; index++, offset++, prev++) {
|
|
1381
|
+
for (let index = startPos;index < segmentLen; index++, offset++) {
|
|
1366
1382
|
perBlock();
|
|
1367
|
-
|
|
1383
|
+
const prev = offset % laneLen ? offset - 1 : offset + laneLen - 1;
|
|
1384
|
+
let randL, randH;
|
|
1385
|
+
if (dataIndependent) {
|
|
1386
|
+
let i128 = index % 128;
|
|
1387
|
+
if (i128 === 0) {
|
|
1388
|
+
address[256 + 12]++;
|
|
1389
|
+
block(address, 256, 2 * 256, 0, false);
|
|
1390
|
+
block(address, 0, 2 * 256, 0, false);
|
|
1391
|
+
}
|
|
1392
|
+
randL = address[2 * i128];
|
|
1393
|
+
randH = address[2 * i128 + 1];
|
|
1394
|
+
} else {
|
|
1395
|
+
const T = 256 * prev;
|
|
1396
|
+
randL = B[T];
|
|
1397
|
+
randH = B[T + 1];
|
|
1398
|
+
}
|
|
1399
|
+
const refLane = r === 0 && s === 0 ? l : randH % lanes;
|
|
1400
|
+
const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l);
|
|
1401
|
+
const refBlock = laneLen * refLane + refPos;
|
|
1402
|
+
block(B, 256 * prev, 256 * refBlock, offset * 256, needXor);
|
|
1403
|
+
yield;
|
|
1368
1404
|
}
|
|
1369
1405
|
}
|
|
1370
1406
|
}
|
|
1371
1407
|
}
|
|
1372
1408
|
clean(address);
|
|
1373
|
-
|
|
1409
|
+
}
|
|
1410
|
+
function argon2(type, password, salt, opts) {
|
|
1411
|
+
const ctx = argon2Init(password, salt, type, opts);
|
|
1412
|
+
const blocks = argon2Blocks(ctx);
|
|
1413
|
+
while (!blocks.next().done) {}
|
|
1414
|
+
return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
|
|
1374
1415
|
}
|
|
1375
1416
|
var argon2id = (password, salt, opts) => argon2(AT.Argon2id, password, salt, opts);
|
|
1376
1417
|
|