@glyphteck/veyl 0.61.12 → 0.63.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/LICENSE +1 -1
- package/dist/account.js +16301 -15686
- package/dist/auth.js +30 -9
- package/dist/cli.js +39718 -38564
- package/dist/index.js +39748 -38609
- package/dist/kdf-worker-thread.js +219 -289
- package/docs/agents.md +1 -1
- package/docs/api.md +3 -3
- package/docs/cli.md +1 -1
- package/examples/bot-fleet/policy.js +52 -3
- package/package.json +1 -1
- package/readme.md +1 -1
|
@@ -19,12 +19,14 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
}
|
|
20
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
28
30
|
if (canCache)
|
|
29
31
|
cache.set(mod, to);
|
|
30
32
|
return to;
|
|
@@ -46,7 +48,7 @@ var __export = (target, all) => {
|
|
|
46
48
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
49
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
48
50
|
|
|
49
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
51
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_u64.js
|
|
50
52
|
function fromBig(n, le = false) {
|
|
51
53
|
if (le)
|
|
52
54
|
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
@@ -62,66 +64,68 @@ function split(lst, le = false) {
|
|
|
62
64
|
}
|
|
63
65
|
return [Ah, Al];
|
|
64
66
|
}
|
|
67
|
+
function setU64FromNum(view, byteOffset, n, isLE) {
|
|
68
|
+
const h = fromNumH(n);
|
|
69
|
+
const l = fromNumL(n);
|
|
70
|
+
view.setUint32(byteOffset, isLE ? l : h, isLE);
|
|
71
|
+
view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
|
|
72
|
+
}
|
|
65
73
|
function add(Ah, Al, Bh, Bl) {
|
|
66
74
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
67
75
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
68
76
|
}
|
|
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;
|
|
77
|
+
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
78
|
var init__u64 = __esm(() => {
|
|
71
|
-
U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
79
|
+
U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
|
72
80
|
_32n = /* @__PURE__ */ BigInt(32);
|
|
73
81
|
});
|
|
74
82
|
|
|
75
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
83
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/utils.js
|
|
76
84
|
function isBytes(a) {
|
|
77
85
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
78
86
|
}
|
|
79
87
|
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
|
-
}
|
|
88
|
+
if (typeof n !== "number")
|
|
89
|
+
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
90
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
91
|
+
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
92
|
+
return n;
|
|
88
93
|
}
|
|
89
94
|
function abytes(value, length, title = "") {
|
|
95
|
+
if (isBytes(value) && (length === undefined || value.length === length))
|
|
96
|
+
return value;
|
|
97
|
+
if (length !== undefined)
|
|
98
|
+
anumber(length, "length");
|
|
90
99
|
const bytes = isBytes(value);
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
throw new RangeError(message);
|
|
101
|
-
}
|
|
102
|
-
return value;
|
|
100
|
+
const ofLen = length !== undefined ? ` of length ${length}` : "";
|
|
101
|
+
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
102
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
103
|
+
if (!bytes)
|
|
104
|
+
throw new TypeError(message);
|
|
105
|
+
throw new RangeError(message);
|
|
106
|
+
}
|
|
107
|
+
function copyBytes(bytes) {
|
|
108
|
+
return Uint8Array.from(abytes(bytes));
|
|
103
109
|
}
|
|
104
110
|
function ahash(h) {
|
|
105
111
|
if (typeof h !== "function" || typeof h.create !== "function")
|
|
106
|
-
throw new TypeError("
|
|
112
|
+
throw new TypeError("expected hash wrapped by utils.createHasher");
|
|
107
113
|
anumber(h.outputLen);
|
|
108
114
|
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');
|
|
115
|
+
if (h.outputLen < 1 || h.blockLen < 1)
|
|
116
|
+
throw new Error("hash blockLen / outputLen must be >= 1");
|
|
113
117
|
}
|
|
114
118
|
function aexists(instance, checkFinished = true) {
|
|
115
119
|
if (instance.destroyed)
|
|
116
|
-
throw new Error("
|
|
120
|
+
throw new Error("hash was destroyed");
|
|
117
121
|
if (checkFinished && instance.finished)
|
|
118
|
-
throw new Error("
|
|
122
|
+
throw new Error("digest() was already called");
|
|
119
123
|
}
|
|
120
124
|
function aoutput(out, instance) {
|
|
121
|
-
abytes(out, undefined, "
|
|
125
|
+
abytes(out, undefined, "output");
|
|
122
126
|
const min = instance.outputLen;
|
|
123
|
-
if (out.length
|
|
124
|
-
throw new RangeError('"
|
|
127
|
+
if (!(out.length >= min)) {
|
|
128
|
+
throw new RangeError('"output" expected length >= ' + min);
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
function u8(arr) {
|
|
@@ -161,13 +165,7 @@ function bytesToHex(bytes) {
|
|
|
161
165
|
return hex;
|
|
162
166
|
}
|
|
163
167
|
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;
|
|
168
|
+
return ch >= 48 && ch <= 57 ? ch - 48 : ch >= 65 && ch <= 70 ? ch - (65 - 10) : ch >= 97 && ch <= 102 ? ch - (97 - 10) : undefined;
|
|
171
169
|
}
|
|
172
170
|
function hexToBytes(hex) {
|
|
173
171
|
if (typeof hex !== "string")
|
|
@@ -222,7 +220,17 @@ function concatBytes(...arrays) {
|
|
|
222
220
|
}
|
|
223
221
|
return res;
|
|
224
222
|
}
|
|
223
|
+
function checkOpts(defaults, opts, title = "opts") {
|
|
224
|
+
aobject(defaults, "defaults");
|
|
225
|
+
if (opts !== undefined)
|
|
226
|
+
aobject(opts, title);
|
|
227
|
+
const merged = Object.assign(defaults, opts);
|
|
228
|
+
return merged;
|
|
229
|
+
}
|
|
225
230
|
function createHasher(hashCons, info = {}) {
|
|
231
|
+
if (typeof hashCons !== "function")
|
|
232
|
+
throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
|
|
233
|
+
info = checkOpts({}, info, "info");
|
|
226
234
|
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
227
235
|
const tmp = hashCons(undefined);
|
|
228
236
|
hashC.outputLen = tmp.outputLen;
|
|
@@ -241,7 +249,10 @@ function randomBytes(bytesLength = 32) {
|
|
|
241
249
|
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
242
250
|
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
243
251
|
}
|
|
244
|
-
var
|
|
252
|
+
var atitle = (title) => title ? `"${title}" ` : "", aobject = (value, label) => {
|
|
253
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
254
|
+
throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
255
|
+
}, isLE, swap8IfBE, swap32IfBE, hasHexBuiltin, hexes, oidNist = (suffix) => ({
|
|
245
256
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
246
257
|
});
|
|
247
258
|
var init_utils = __esm(() => {
|
|
@@ -250,10 +261,9 @@ var init_utils = __esm(() => {
|
|
|
250
261
|
swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
251
262
|
hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
|
252
263
|
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
264
|
});
|
|
255
265
|
|
|
256
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
266
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_md.js
|
|
257
267
|
function Chi(a, b, c) {
|
|
258
268
|
return a & b ^ ~a & c;
|
|
259
269
|
}
|
|
@@ -286,24 +296,28 @@ class HashMD {
|
|
|
286
296
|
abytes(data);
|
|
287
297
|
const { view, buffer, blockLen } = this;
|
|
288
298
|
const len = data.length;
|
|
299
|
+
let processed = false;
|
|
289
300
|
for (let pos = 0;pos < len; ) {
|
|
290
301
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
291
302
|
if (take === blockLen) {
|
|
292
303
|
const dataView = createView(data);
|
|
293
304
|
for (;blockLen <= len - pos; pos += blockLen)
|
|
294
305
|
this.process(dataView, pos);
|
|
306
|
+
processed = true;
|
|
295
307
|
continue;
|
|
296
308
|
}
|
|
297
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
309
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
298
310
|
this.pos += take;
|
|
299
311
|
pos += take;
|
|
300
312
|
if (this.pos === blockLen) {
|
|
301
313
|
this.process(view, 0);
|
|
302
314
|
this.pos = 0;
|
|
315
|
+
processed = true;
|
|
303
316
|
}
|
|
304
317
|
}
|
|
305
318
|
this.length += data.length;
|
|
306
|
-
|
|
319
|
+
if (processed)
|
|
320
|
+
this.roundClean();
|
|
307
321
|
return this;
|
|
308
322
|
}
|
|
309
323
|
digestInto(out) {
|
|
@@ -313,23 +327,20 @@ class HashMD {
|
|
|
313
327
|
const { buffer, view, blockLen, isLE: isLE2 } = this;
|
|
314
328
|
let { pos } = this;
|
|
315
329
|
buffer[pos++] = 128;
|
|
316
|
-
|
|
330
|
+
buffer.fill(0, pos);
|
|
317
331
|
if (this.padOffset > blockLen - pos) {
|
|
318
332
|
this.process(view, 0);
|
|
319
|
-
|
|
333
|
+
buffer.fill(0);
|
|
320
334
|
}
|
|
321
|
-
|
|
322
|
-
buffer[i] = 0;
|
|
323
|
-
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE2);
|
|
335
|
+
setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
|
|
324
336
|
this.process(view, 0);
|
|
325
|
-
|
|
337
|
+
this.roundClean();
|
|
338
|
+
const oview = out === buffer ? view : createView(out);
|
|
326
339
|
const len = this.outputLen;
|
|
327
|
-
if (len % 4)
|
|
328
|
-
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
329
340
|
const outLen = len / 4;
|
|
330
341
|
const state = this.get();
|
|
331
|
-
if (outLen > state.length)
|
|
332
|
-
throw new Error("
|
|
342
|
+
if (len % 4 || outLen > state.length)
|
|
343
|
+
throw new Error("invalid outputLen");
|
|
333
344
|
for (let i = 0;i < outLen; i++)
|
|
334
345
|
oview.setUint32(4 * i, state[i], isLE2);
|
|
335
346
|
}
|
|
@@ -340,15 +351,13 @@ class HashMD {
|
|
|
340
351
|
this.destroy();
|
|
341
352
|
return res;
|
|
342
353
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
to.set(...this.get());
|
|
346
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
354
|
+
_cloneIntoMeta(to) {
|
|
355
|
+
const { buffer, length, finished, destroyed, pos } = this;
|
|
347
356
|
to.destroyed = destroyed;
|
|
348
357
|
to.finished = finished;
|
|
349
358
|
to.length = length;
|
|
350
359
|
to.pos = pos;
|
|
351
|
-
if (
|
|
360
|
+
if (pos)
|
|
352
361
|
to.buffer.set(buffer);
|
|
353
362
|
return to;
|
|
354
363
|
}
|
|
@@ -356,8 +365,9 @@ class HashMD {
|
|
|
356
365
|
return this._cloneInto();
|
|
357
366
|
}
|
|
358
367
|
}
|
|
359
|
-
var SHA256_IV,
|
|
368
|
+
var SHA256_IV, SHA512_IV;
|
|
360
369
|
var init__md = __esm(() => {
|
|
370
|
+
init__u64();
|
|
361
371
|
init_utils();
|
|
362
372
|
SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
363
373
|
1779033703,
|
|
@@ -369,34 +379,6 @@ var init__md = __esm(() => {
|
|
|
369
379
|
528734635,
|
|
370
380
|
1541459225
|
|
371
381
|
]);
|
|
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
382
|
SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
401
383
|
1779033703,
|
|
402
384
|
4089235720,
|
|
@@ -420,11 +402,10 @@ var init__md = __esm(() => {
|
|
|
420
402
|
// src/runtime/kdf-worker-thread.js
|
|
421
403
|
import { parentPort } from "node:worker_threads";
|
|
422
404
|
|
|
423
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
405
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/argon2.js
|
|
424
406
|
init__u64();
|
|
425
407
|
|
|
426
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
427
|
-
init_utils();
|
|
408
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/_blake.js
|
|
428
409
|
var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
429
410
|
0,
|
|
430
411
|
1,
|
|
@@ -683,23 +664,8 @@ var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
|
683
664
|
1,
|
|
684
665
|
9
|
|
685
666
|
]);
|
|
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
667
|
|
|
701
|
-
// ../../node_modules/.bun/@noble+hashes@2.
|
|
702
|
-
init__md();
|
|
668
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/blake2.js
|
|
703
669
|
init__u64();
|
|
704
670
|
init_utils();
|
|
705
671
|
var B2B_IV = /* @__PURE__ */ Uint32Array.from([
|
|
@@ -727,18 +693,25 @@ function G1b(a, b, c, d, msg, x) {
|
|
|
727
693
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
728
694
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
729
695
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
730
|
-
|
|
696
|
+
const ll = add3L(Al, Bl, Xl);
|
|
731
697
|
Ah = add3H(ll, Ah, Bh, Xh);
|
|
732
698
|
Al = ll | 0;
|
|
733
|
-
|
|
734
|
-
|
|
699
|
+
let xh = Dh ^ Ah, xl = Dl ^ Al;
|
|
700
|
+
Dh = rotr32H(xh, xl);
|
|
701
|
+
Dl = rotr32L(xh, xl);
|
|
735
702
|
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
BBUF[2 *
|
|
741
|
-
BBUF[2 *
|
|
703
|
+
xh = Bh ^ Ch;
|
|
704
|
+
xl = Bl ^ Cl;
|
|
705
|
+
Bh = rotrSH(xh, xl, 24);
|
|
706
|
+
Bl = rotrSL(xh, xl, 24);
|
|
707
|
+
BBUF[2 * a] = Al;
|
|
708
|
+
BBUF[2 * a + 1] = Ah;
|
|
709
|
+
BBUF[2 * b] = Bl;
|
|
710
|
+
BBUF[2 * b + 1] = Bh;
|
|
711
|
+
BBUF[2 * c] = Cl;
|
|
712
|
+
BBUF[2 * c + 1] = Ch;
|
|
713
|
+
BBUF[2 * d] = Dl;
|
|
714
|
+
BBUF[2 * d + 1] = Dh;
|
|
742
715
|
}
|
|
743
716
|
function G2b(a, b, c, d, msg, x) {
|
|
744
717
|
const Xl = msg[x], Xh = msg[x + 1];
|
|
@@ -746,23 +719,30 @@ function G2b(a, b, c, d, msg, x) {
|
|
|
746
719
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
747
720
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
748
721
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
749
|
-
|
|
722
|
+
const ll = add3L(Al, Bl, Xl);
|
|
750
723
|
Ah = add3H(ll, Ah, Bh, Xh);
|
|
751
724
|
Al = ll | 0;
|
|
752
|
-
|
|
753
|
-
|
|
725
|
+
let xh = Dh ^ Ah, xl = Dl ^ Al;
|
|
726
|
+
Dh = rotrSH(xh, xl, 16);
|
|
727
|
+
Dl = rotrSL(xh, xl, 16);
|
|
754
728
|
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
BBUF[2 *
|
|
760
|
-
BBUF[2 *
|
|
729
|
+
xh = Bh ^ Ch;
|
|
730
|
+
xl = Bl ^ Cl;
|
|
731
|
+
Bh = rotrBH(xh, xl, 63);
|
|
732
|
+
Bl = rotrBL(xh, xl, 63);
|
|
733
|
+
BBUF[2 * a] = Al;
|
|
734
|
+
BBUF[2 * a + 1] = Ah;
|
|
735
|
+
BBUF[2 * b] = Bl;
|
|
736
|
+
BBUF[2 * b + 1] = Bh;
|
|
737
|
+
BBUF[2 * c] = Cl;
|
|
738
|
+
BBUF[2 * c + 1] = Ch;
|
|
739
|
+
BBUF[2 * d] = Dl;
|
|
740
|
+
BBUF[2 * d + 1] = Dh;
|
|
761
741
|
}
|
|
762
742
|
function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
763
743
|
anumber(keyLen);
|
|
764
744
|
if (outputLen <= 0 || outputLen > keyLen)
|
|
765
|
-
throw new Error("
|
|
745
|
+
throw new Error('"dkLen" must be 1..' + keyLen + ", got " + outputLen);
|
|
766
746
|
const { key, salt, personalization } = opts;
|
|
767
747
|
if (key !== undefined && (key.length < 1 || key.length > keyLen))
|
|
768
748
|
throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
|
|
@@ -816,7 +796,7 @@ class _BLAKE2 {
|
|
|
816
796
|
swap32IfBE(data32);
|
|
817
797
|
continue;
|
|
818
798
|
}
|
|
819
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
799
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
820
800
|
this.pos += take;
|
|
821
801
|
this.length += take;
|
|
822
802
|
pos += take;
|
|
@@ -826,16 +806,16 @@ class _BLAKE2 {
|
|
|
826
806
|
digestInto(out) {
|
|
827
807
|
aexists(this);
|
|
828
808
|
aoutput(out, this);
|
|
809
|
+
if (out.byteOffset & 3)
|
|
810
|
+
throw new RangeError('"output" expected 4-byte aligned byteOffset, got ' + out.byteOffset);
|
|
829
811
|
const { pos, buffer32 } = this;
|
|
830
812
|
this.finished = true;
|
|
831
|
-
|
|
813
|
+
this.buffer.fill(0, pos);
|
|
832
814
|
swap32IfBE(buffer32);
|
|
833
815
|
this.compress(buffer32, 0, true);
|
|
834
816
|
swap32IfBE(buffer32);
|
|
835
|
-
if (out.byteOffset & 3)
|
|
836
|
-
throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got ' + out.byteOffset);
|
|
837
817
|
const state = this.get();
|
|
838
|
-
const out32 = u32(out);
|
|
818
|
+
const out32 = out === this.buffer ? buffer32 : u32(out);
|
|
839
819
|
const full = Math.floor(this.outputLen / 4);
|
|
840
820
|
for (let i = 0;i < full; i++)
|
|
841
821
|
out32[i] = swap8IfBE(state[i]);
|
|
@@ -889,6 +869,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
889
869
|
v7l = B2B_IV[14] | 0;
|
|
890
870
|
v7h = B2B_IV[15] | 0;
|
|
891
871
|
constructor(opts = {}) {
|
|
872
|
+
opts = checkOpts({}, opts);
|
|
892
873
|
const olen = opts.dkLen === undefined ? 64 : opts.dkLen;
|
|
893
874
|
super(128, olen);
|
|
894
875
|
checkBlake2Opts(olen, opts, 64, 16, 16);
|
|
@@ -901,7 +882,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
901
882
|
this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
|
|
902
883
|
if (salt !== undefined) {
|
|
903
884
|
abytes(salt, undefined, "salt");
|
|
904
|
-
const slt = u32(salt);
|
|
885
|
+
const slt = u32(copyBytes(salt));
|
|
905
886
|
this.v4l ^= swap8IfBE(slt[0]);
|
|
906
887
|
this.v4h ^= swap8IfBE(slt[1]);
|
|
907
888
|
this.v5l ^= swap8IfBE(slt[2]);
|
|
@@ -909,7 +890,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
909
890
|
}
|
|
910
891
|
if (personalization !== undefined) {
|
|
911
892
|
abytes(personalization, undefined, "personalization");
|
|
912
|
-
const pers = u32(personalization);
|
|
893
|
+
const pers = u32(copyBytes(personalization));
|
|
913
894
|
this.v6l ^= swap8IfBE(pers[0]);
|
|
914
895
|
this.v6h ^= swap8IfBE(pers[1]);
|
|
915
896
|
this.v7l ^= swap8IfBE(pers[2]);
|
|
@@ -919,6 +900,7 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
919
900
|
const tmp = new Uint8Array(this.blockLen);
|
|
920
901
|
tmp.set(key);
|
|
921
902
|
this.update(tmp);
|
|
903
|
+
clean(tmp);
|
|
922
904
|
}
|
|
923
905
|
}
|
|
924
906
|
get() {
|
|
@@ -944,9 +926,28 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
944
926
|
this.v7h = v7h | 0;
|
|
945
927
|
}
|
|
946
928
|
compress(msg, offset, isLast) {
|
|
947
|
-
|
|
929
|
+
const { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
|
|
930
|
+
{
|
|
931
|
+
BBUF[0] = v0l;
|
|
932
|
+
BBUF[1] = v0h;
|
|
933
|
+
BBUF[2] = v1l;
|
|
934
|
+
BBUF[3] = v1h;
|
|
935
|
+
BBUF[4] = v2l;
|
|
936
|
+
BBUF[5] = v2h;
|
|
937
|
+
BBUF[6] = v3l;
|
|
938
|
+
BBUF[7] = v3h;
|
|
939
|
+
BBUF[8] = v4l;
|
|
940
|
+
BBUF[9] = v4h;
|
|
941
|
+
BBUF[10] = v5l;
|
|
942
|
+
BBUF[11] = v5h;
|
|
943
|
+
BBUF[12] = v6l;
|
|
944
|
+
BBUF[13] = v6h;
|
|
945
|
+
BBUF[14] = v7l;
|
|
946
|
+
BBUF[15] = v7h;
|
|
947
|
+
}
|
|
948
948
|
BBUF.set(B2B_IV, 16);
|
|
949
|
-
|
|
949
|
+
const l = fromNumL(this.length);
|
|
950
|
+
const h = fromNumH(this.length);
|
|
950
951
|
BBUF[24] = B2B_IV[8] ^ l;
|
|
951
952
|
BBUF[25] = B2B_IV[9] ^ h;
|
|
952
953
|
if (isLast) {
|
|
@@ -998,104 +999,10 @@ class _BLAKE2b extends _BLAKE2 {
|
|
|
998
999
|
}
|
|
999
1000
|
}
|
|
1000
1001
|
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
1002
|
|
|
1025
|
-
|
|
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
|
|
1003
|
+
// ../../node_modules/.bun/@noble+hashes@2.3.0/node_modules/@noble/hashes/argon2.js
|
|
1097
1004
|
init_utils();
|
|
1098
|
-
var AT = {
|
|
1005
|
+
var AT = { Argon2d: 0, Argon2i: 1, Argon2id: 2 };
|
|
1099
1006
|
var ARGON2_SYNC_POINTS = 4;
|
|
1100
1007
|
var abytesOrZero = (buf, errorTitle = "") => {
|
|
1101
1008
|
if (buf === undefined)
|
|
@@ -1116,14 +1023,10 @@ function mul(a, b) {
|
|
|
1116
1023
|
const low = carry << 16 | ll & 65535;
|
|
1117
1024
|
return { h: high, l: low };
|
|
1118
1025
|
}
|
|
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 };
|
|
1026
|
+
function mulHi(a, b) {
|
|
1027
|
+
const aL = a & 65535, aH = a >>> 16, bL = b & 65535, bH = b >>> 16;
|
|
1028
|
+
const carry = (Math.imul(aL, bL) >>> 16) + (Math.imul(aH, bL) & 65535) + Math.imul(aL, bH);
|
|
1029
|
+
return Math.imul(aH, bH) + (Math.imul(aH, bL) >>> 16) + (carry >>> 16) | 0;
|
|
1127
1030
|
}
|
|
1128
1031
|
var A2_BUF = new Uint32Array(256);
|
|
1129
1032
|
function G(a, b, c, d) {
|
|
@@ -1131,18 +1034,43 @@ function G(a, b, c, d) {
|
|
|
1131
1034
|
let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1];
|
|
1132
1035
|
let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1];
|
|
1133
1036
|
let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1];
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
(
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1037
|
+
let ml = 0, mh = 0, rl = 0, xh = 0, xl = 0;
|
|
1038
|
+
ml = Math.imul(Al, Bl);
|
|
1039
|
+
mh = mulHi(Al, Bl);
|
|
1040
|
+
rl = (Al >>> 0) + (Bl >>> 0) + (ml << 1 >>> 0);
|
|
1041
|
+
Ah = Ah + Bh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1042
|
+
Al = rl | 0;
|
|
1043
|
+
xh = Dh ^ Ah;
|
|
1044
|
+
xl = Dl ^ Al;
|
|
1045
|
+
Dh = rotr32H(xh, xl);
|
|
1046
|
+
Dl = rotr32L(xh, xl);
|
|
1047
|
+
ml = Math.imul(Cl, Dl);
|
|
1048
|
+
mh = mulHi(Cl, Dl);
|
|
1049
|
+
rl = (Cl >>> 0) + (Dl >>> 0) + (ml << 1 >>> 0);
|
|
1050
|
+
Ch = Ch + Dh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1051
|
+
Cl = rl | 0;
|
|
1052
|
+
xh = Bh ^ Ch;
|
|
1053
|
+
xl = Bl ^ Cl;
|
|
1054
|
+
Bh = rotrSH(xh, xl, 24);
|
|
1055
|
+
Bl = rotrSL(xh, xl, 24);
|
|
1056
|
+
ml = Math.imul(Al, Bl);
|
|
1057
|
+
mh = mulHi(Al, Bl);
|
|
1058
|
+
rl = (Al >>> 0) + (Bl >>> 0) + (ml << 1 >>> 0);
|
|
1059
|
+
Ah = Ah + Bh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1060
|
+
Al = rl | 0;
|
|
1061
|
+
xh = Dh ^ Ah;
|
|
1062
|
+
xl = Dl ^ Al;
|
|
1063
|
+
Dh = rotrSH(xh, xl, 16);
|
|
1064
|
+
Dl = rotrSL(xh, xl, 16);
|
|
1065
|
+
ml = Math.imul(Cl, Dl);
|
|
1066
|
+
mh = mulHi(Cl, Dl);
|
|
1067
|
+
rl = (Cl >>> 0) + (Dl >>> 0) + (ml << 1 >>> 0);
|
|
1068
|
+
Ch = Ch + Dh + (mh << 1 | ml >>> 31) + (rl / 4294967296 | 0) | 0;
|
|
1069
|
+
Cl = rl | 0;
|
|
1070
|
+
xh = Bh ^ Ch;
|
|
1071
|
+
xl = Bl ^ Cl;
|
|
1072
|
+
Bh = rotrBH(xh, xl, 63);
|
|
1073
|
+
Bl = rotrBL(xh, xl, 63);
|
|
1146
1074
|
A2_BUF[2 * a] = Al, A2_BUF[2 * a + 1] = Ah;
|
|
1147
1075
|
A2_BUF[2 * b] = Bl, A2_BUF[2 * b + 1] = Bh;
|
|
1148
1076
|
A2_BUF[2 * c] = Cl, A2_BUF[2 * c + 1] = Ch;
|
|
@@ -1219,6 +1147,7 @@ function isU32(num) {
|
|
|
1219
1147
|
return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
|
|
1220
1148
|
}
|
|
1221
1149
|
function argon2Opts(opts) {
|
|
1150
|
+
opts = checkOpts({}, opts);
|
|
1222
1151
|
const merged = {
|
|
1223
1152
|
version: 19,
|
|
1224
1153
|
dkLen: 32,
|
|
@@ -1238,7 +1167,7 @@ function argon2Opts(opts) {
|
|
|
1238
1167
|
if (!isU32(t) || t < 1)
|
|
1239
1168
|
throw new Error('"t" (iterations) must be 1..2^32');
|
|
1240
1169
|
if (onProgress !== undefined && typeof onProgress !== "function")
|
|
1241
|
-
throw new Error('"
|
|
1170
|
+
throw new Error('"onProgress" must be a function');
|
|
1242
1171
|
anumber(asyncTick, "asyncTick");
|
|
1243
1172
|
if (!isU32(m) || m < 8 * p)
|
|
1244
1173
|
throw new Error('"m" (memory) must be at least 8*p bytes');
|
|
@@ -1313,31 +1242,8 @@ function argon2Output(B, p, laneLen, dkLen) {
|
|
|
1313
1242
|
clean(B, B_final);
|
|
1314
1243
|
return res;
|
|
1315
1244
|
}
|
|
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);
|
|
1245
|
+
function* argon2Blocks(ctx) {
|
|
1246
|
+
const { type, mP, p, t, version, B, laneLen, lanes, segmentLen, perBlock } = ctx;
|
|
1341
1247
|
const address = new Uint32Array(3 * 256);
|
|
1342
1248
|
address[256 + 6] = mP;
|
|
1343
1249
|
address[256 + 8] = t;
|
|
@@ -1361,16 +1267,40 @@ function argon2(type, password, salt, opts) {
|
|
|
1361
1267
|
}
|
|
1362
1268
|
}
|
|
1363
1269
|
let offset = l * laneLen + s * segmentLen + startPos;
|
|
1364
|
-
let
|
|
1365
|
-
for (let index = startPos;index < segmentLen; index++, offset++, prev++) {
|
|
1270
|
+
for (let index = startPos;index < segmentLen; index++, offset++) {
|
|
1366
1271
|
perBlock();
|
|
1367
|
-
|
|
1272
|
+
const prev = offset % laneLen ? offset - 1 : offset + laneLen - 1;
|
|
1273
|
+
let randL, randH;
|
|
1274
|
+
if (dataIndependent) {
|
|
1275
|
+
let i128 = index % 128;
|
|
1276
|
+
if (i128 === 0) {
|
|
1277
|
+
address[256 + 12]++;
|
|
1278
|
+
block(address, 256, 2 * 256, 0, false);
|
|
1279
|
+
block(address, 0, 2 * 256, 0, false);
|
|
1280
|
+
}
|
|
1281
|
+
randL = address[2 * i128];
|
|
1282
|
+
randH = address[2 * i128 + 1];
|
|
1283
|
+
} else {
|
|
1284
|
+
const T = 256 * prev;
|
|
1285
|
+
randL = B[T];
|
|
1286
|
+
randH = B[T + 1];
|
|
1287
|
+
}
|
|
1288
|
+
const refLane = r === 0 && s === 0 ? l : randH % lanes;
|
|
1289
|
+
const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l);
|
|
1290
|
+
const refBlock = laneLen * refLane + refPos;
|
|
1291
|
+
block(B, 256 * prev, 256 * refBlock, offset * 256, needXor);
|
|
1292
|
+
yield;
|
|
1368
1293
|
}
|
|
1369
1294
|
}
|
|
1370
1295
|
}
|
|
1371
1296
|
}
|
|
1372
1297
|
clean(address);
|
|
1373
|
-
|
|
1298
|
+
}
|
|
1299
|
+
function argon2(type, password, salt, opts) {
|
|
1300
|
+
const ctx = argon2Init(password, salt, type, opts);
|
|
1301
|
+
const blocks = argon2Blocks(ctx);
|
|
1302
|
+
while (!blocks.next().done) {}
|
|
1303
|
+
return argon2Output(ctx.B, ctx.p, ctx.laneLen, ctx.dkLen);
|
|
1374
1304
|
}
|
|
1375
1305
|
var argon2id = (password, salt, opts) => argon2(AT.Argon2id, password, salt, opts);
|
|
1376
1306
|
|