@ghostlytools/sdk 1.11.3 → 1.11.4
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/core.js +2 -2
- package/dist/{fakes-CK9Ra4X4.js → fakes-CXeeyI4Z.js} +2 -2
- package/dist/{fakes-CK9Ra4X4.js.map → fakes-CXeeyI4Z.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-CDgu84Dj.js → keet-identity-key-DLXTTFZH.js} +1754 -86
- package/dist/keet-identity-key-DLXTTFZH.js.map +1 -0
- package/dist/{src-B9HeOlsG.js → src-CqAqFhh9.js} +825 -199
- package/dist/src-CqAqFhh9.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/communityRendezvous.d.ts +5 -2
- package/dist/types/core/src/datalink.d.ts +10 -0
- package/dist/types/core/src/frames.d.ts +18 -0
- package/dist/types/core/src/ghostlink.d.ts +37 -0
- package/dist/types/core/src/groupCommunity.d.ts +13 -3
- package/dist/types/core/src/http.d.ts +26 -3
- package/dist/types/core/src/pairedAppRanges.d.ts +2 -0
- package/dist/types/core/src/videoMetadata.d.ts +7 -0
- package/dist/{verify-DZpnNeF7.js → verify-B9s82dbd.js} +2 -2
- package/dist/{verify-DZpnNeF7.js.map → verify-B9s82dbd.js.map} +1 -1
- package/package.json +1 -1
- package/dist/keet-identity-key-CDgu84Dj.js.map +0 -1
- package/dist/src-B9HeOlsG.js.map +0 -1
|
@@ -1,4 +1,638 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AE as __toCommonJS, DE as __esmMin, EE as __commonJSMin, OE as __exportAll, kE as __require } from "./src-CqAqFhh9.js";
|
|
2
|
+
//#region ../../node_modules/b4a/lib/ascii.js
|
|
3
|
+
var require_ascii = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
function byteLength(string) {
|
|
5
|
+
return string.length;
|
|
6
|
+
}
|
|
7
|
+
function toString(buffer) {
|
|
8
|
+
const len = buffer.byteLength;
|
|
9
|
+
let result = "";
|
|
10
|
+
for (let i = 0; i < len; i++) result += String.fromCharCode(buffer[i] & 127);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
function write(buffer, string) {
|
|
14
|
+
const len = buffer.byteLength;
|
|
15
|
+
for (let i = 0; i < len; i++) buffer[i] = string.charCodeAt(i);
|
|
16
|
+
return len;
|
|
17
|
+
}
|
|
18
|
+
module.exports = {
|
|
19
|
+
byteLength,
|
|
20
|
+
toString,
|
|
21
|
+
write
|
|
22
|
+
};
|
|
23
|
+
}));
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../../node_modules/b4a/lib/base64.js
|
|
26
|
+
var require_base64 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
27
|
+
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
28
|
+
var codes = /* @__PURE__ */ new Uint8Array(256);
|
|
29
|
+
for (let i = 0; i < 64; i++) codes[alphabet.charCodeAt(i)] = i;
|
|
30
|
+
codes[45] = 62;
|
|
31
|
+
codes[95] = 63;
|
|
32
|
+
function byteLength(string) {
|
|
33
|
+
let len = string.length;
|
|
34
|
+
if (string.charCodeAt(len - 1) === 61) len--;
|
|
35
|
+
if (len > 1 && string.charCodeAt(len - 1) === 61) len--;
|
|
36
|
+
return len * 3 >>> 2;
|
|
37
|
+
}
|
|
38
|
+
function toString(buffer) {
|
|
39
|
+
const len = buffer.byteLength;
|
|
40
|
+
let result = "";
|
|
41
|
+
for (let i = 0; i < len; i += 3) result += alphabet[buffer[i] >> 2] + alphabet[(buffer[i] & 3) << 4 | buffer[i + 1] >> 4] + alphabet[(buffer[i + 1] & 15) << 2 | buffer[i + 2] >> 6] + alphabet[buffer[i + 2] & 63];
|
|
42
|
+
if (len % 3 === 2) result = result.substring(0, result.length - 1) + "=";
|
|
43
|
+
else if (len % 3 === 1) result = result.substring(0, result.length - 2) + "==";
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
function write(buffer, string) {
|
|
47
|
+
const len = buffer.byteLength;
|
|
48
|
+
for (let i = 0, j = 0; j < len; i += 4) {
|
|
49
|
+
const a = codes[string.charCodeAt(i)];
|
|
50
|
+
const b = codes[string.charCodeAt(i + 1)];
|
|
51
|
+
const c = codes[string.charCodeAt(i + 2)];
|
|
52
|
+
const d = codes[string.charCodeAt(i + 3)];
|
|
53
|
+
buffer[j++] = a << 2 | b >> 4;
|
|
54
|
+
buffer[j++] = (b & 15) << 4 | c >> 2;
|
|
55
|
+
buffer[j++] = (c & 3) << 6 | d & 63;
|
|
56
|
+
}
|
|
57
|
+
return len;
|
|
58
|
+
}
|
|
59
|
+
module.exports = {
|
|
60
|
+
byteLength,
|
|
61
|
+
toString,
|
|
62
|
+
write
|
|
63
|
+
};
|
|
64
|
+
}));
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region ../../node_modules/b4a/lib/hex.js
|
|
67
|
+
var require_hex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
68
|
+
function byteLength(string) {
|
|
69
|
+
return string.length >>> 1;
|
|
70
|
+
}
|
|
71
|
+
function toString(buffer) {
|
|
72
|
+
const len = buffer.byteLength;
|
|
73
|
+
buffer = new DataView(buffer.buffer, buffer.byteOffset, len);
|
|
74
|
+
let result = "";
|
|
75
|
+
let i = 0;
|
|
76
|
+
for (let n = len - len % 4; i < n; i += 4) result += buffer.getUint32(i).toString(16).padStart(8, "0");
|
|
77
|
+
for (; i < len; i++) result += buffer.getUint8(i).toString(16).padStart(2, "0");
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function write(buffer, string) {
|
|
81
|
+
const len = buffer.byteLength;
|
|
82
|
+
for (let i = 0; i < len; i++) {
|
|
83
|
+
const a = hexValue(string.charCodeAt(i * 2));
|
|
84
|
+
const b = hexValue(string.charCodeAt(i * 2 + 1));
|
|
85
|
+
if (a === void 0 || b === void 0) return i;
|
|
86
|
+
buffer[i] = a << 4 | b;
|
|
87
|
+
}
|
|
88
|
+
return len;
|
|
89
|
+
}
|
|
90
|
+
module.exports = {
|
|
91
|
+
byteLength,
|
|
92
|
+
toString,
|
|
93
|
+
write
|
|
94
|
+
};
|
|
95
|
+
function hexValue(char) {
|
|
96
|
+
if (char >= 48 && char <= 57) return char - 48;
|
|
97
|
+
if (char >= 65 && char <= 70) return char - 65 + 10;
|
|
98
|
+
if (char >= 97 && char <= 102) return char - 97 + 10;
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../../node_modules/b4a/lib/latin1.js
|
|
103
|
+
var require_latin1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
104
|
+
function byteLength(string) {
|
|
105
|
+
return string.length;
|
|
106
|
+
}
|
|
107
|
+
function toString(buffer) {
|
|
108
|
+
const len = buffer.byteLength;
|
|
109
|
+
let result = "";
|
|
110
|
+
for (let i = 0; i < len; i++) result += String.fromCharCode(buffer[i]);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function write(buffer, string) {
|
|
114
|
+
const len = buffer.byteLength;
|
|
115
|
+
for (let i = 0; i < len; i++) buffer[i] = string.charCodeAt(i);
|
|
116
|
+
return len;
|
|
117
|
+
}
|
|
118
|
+
module.exports = {
|
|
119
|
+
byteLength,
|
|
120
|
+
toString,
|
|
121
|
+
write
|
|
122
|
+
};
|
|
123
|
+
}));
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region ../../node_modules/b4a/lib/utf8.js
|
|
126
|
+
var require_utf8 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
127
|
+
function byteLength(string) {
|
|
128
|
+
let length = 0;
|
|
129
|
+
for (let i = 0, n = string.length; i < n; i++) {
|
|
130
|
+
const code = string.charCodeAt(i);
|
|
131
|
+
if (code >= 55296 && code <= 56319 && i + 1 < n) {
|
|
132
|
+
const code = string.charCodeAt(i + 1);
|
|
133
|
+
if (code >= 56320 && code <= 57343) {
|
|
134
|
+
length += 4;
|
|
135
|
+
i++;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (code <= 127) length += 1;
|
|
140
|
+
else if (code <= 2047) length += 2;
|
|
141
|
+
else length += 3;
|
|
142
|
+
}
|
|
143
|
+
return length;
|
|
144
|
+
}
|
|
145
|
+
var toString;
|
|
146
|
+
if (typeof TextDecoder !== "undefined") {
|
|
147
|
+
const decoder = new TextDecoder();
|
|
148
|
+
toString = function toString(buffer) {
|
|
149
|
+
return decoder.decode(buffer);
|
|
150
|
+
};
|
|
151
|
+
} else toString = function toString(buffer) {
|
|
152
|
+
const len = buffer.byteLength;
|
|
153
|
+
let output = "";
|
|
154
|
+
let i = 0;
|
|
155
|
+
while (i < len) {
|
|
156
|
+
let byte = buffer[i];
|
|
157
|
+
if (byte <= 127) {
|
|
158
|
+
output += String.fromCharCode(byte);
|
|
159
|
+
i++;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let bytesNeeded = 0;
|
|
163
|
+
let codePoint = 0;
|
|
164
|
+
if (byte <= 223) {
|
|
165
|
+
bytesNeeded = 1;
|
|
166
|
+
codePoint = byte & 31;
|
|
167
|
+
} else if (byte <= 239) {
|
|
168
|
+
bytesNeeded = 2;
|
|
169
|
+
codePoint = byte & 15;
|
|
170
|
+
} else if (byte <= 244) {
|
|
171
|
+
bytesNeeded = 3;
|
|
172
|
+
codePoint = byte & 7;
|
|
173
|
+
}
|
|
174
|
+
if (len - i - bytesNeeded > 0) {
|
|
175
|
+
let k = 0;
|
|
176
|
+
while (k < bytesNeeded) {
|
|
177
|
+
byte = buffer[i + k + 1];
|
|
178
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
179
|
+
k += 1;
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
codePoint = 65533;
|
|
183
|
+
bytesNeeded = len - i;
|
|
184
|
+
}
|
|
185
|
+
output += String.fromCodePoint(codePoint);
|
|
186
|
+
i += bytesNeeded + 1;
|
|
187
|
+
}
|
|
188
|
+
return output;
|
|
189
|
+
};
|
|
190
|
+
var write;
|
|
191
|
+
if (typeof TextEncoder !== "undefined") {
|
|
192
|
+
const encoder = new TextEncoder();
|
|
193
|
+
write = function write(buffer, string) {
|
|
194
|
+
return encoder.encodeInto(string, buffer).written;
|
|
195
|
+
};
|
|
196
|
+
} else write = function write(buffer, string) {
|
|
197
|
+
const len = buffer.byteLength;
|
|
198
|
+
let i = 0;
|
|
199
|
+
let j = 0;
|
|
200
|
+
while (i < string.length) {
|
|
201
|
+
const code = string.codePointAt(i);
|
|
202
|
+
if (code <= 127) {
|
|
203
|
+
if (j + 1 > len) break;
|
|
204
|
+
buffer[j++] = code;
|
|
205
|
+
i++;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
let count = 0;
|
|
209
|
+
let bits = 0;
|
|
210
|
+
if (code <= 2047) {
|
|
211
|
+
count = 6;
|
|
212
|
+
bits = 192;
|
|
213
|
+
} else if (code <= 65535) {
|
|
214
|
+
count = 12;
|
|
215
|
+
bits = 224;
|
|
216
|
+
} else if (code <= 2097151) {
|
|
217
|
+
count = 18;
|
|
218
|
+
bits = 240;
|
|
219
|
+
}
|
|
220
|
+
if (j + count / 6 + 1 > len) break;
|
|
221
|
+
buffer[j++] = bits | code >> count;
|
|
222
|
+
count -= 6;
|
|
223
|
+
while (count >= 0) {
|
|
224
|
+
buffer[j++] = 128 | code >> count & 63;
|
|
225
|
+
count -= 6;
|
|
226
|
+
}
|
|
227
|
+
i += code >= 65536 ? 2 : 1;
|
|
228
|
+
}
|
|
229
|
+
return j;
|
|
230
|
+
};
|
|
231
|
+
module.exports = {
|
|
232
|
+
byteLength,
|
|
233
|
+
toString,
|
|
234
|
+
write
|
|
235
|
+
};
|
|
236
|
+
}));
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region ../../node_modules/b4a/lib/utf16le.js
|
|
239
|
+
var require_utf16le = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
240
|
+
function byteLength(string) {
|
|
241
|
+
return string.length * 2;
|
|
242
|
+
}
|
|
243
|
+
function toString(buffer) {
|
|
244
|
+
const len = buffer.byteLength;
|
|
245
|
+
let result = "";
|
|
246
|
+
for (let i = 0; i < len - 1; i += 2) result += String.fromCharCode(buffer[i] + buffer[i + 1] * 256);
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
function write(buffer, string) {
|
|
250
|
+
const len = buffer.byteLength;
|
|
251
|
+
let units = len;
|
|
252
|
+
for (let i = 0; i < string.length; ++i) {
|
|
253
|
+
if ((units -= 2) < 0) break;
|
|
254
|
+
const c = string.charCodeAt(i);
|
|
255
|
+
const hi = c >> 8;
|
|
256
|
+
const lo = c % 256;
|
|
257
|
+
buffer[i * 2] = lo;
|
|
258
|
+
buffer[i * 2 + 1] = hi;
|
|
259
|
+
}
|
|
260
|
+
return len;
|
|
261
|
+
}
|
|
262
|
+
module.exports = {
|
|
263
|
+
byteLength,
|
|
264
|
+
toString,
|
|
265
|
+
write
|
|
266
|
+
};
|
|
267
|
+
}));
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region ../../node_modules/b4a/browser.js
|
|
270
|
+
var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
271
|
+
var ascii = require_ascii();
|
|
272
|
+
var base64 = require_base64();
|
|
273
|
+
var hex = require_hex();
|
|
274
|
+
var latin1 = require_latin1();
|
|
275
|
+
var utf8 = require_utf8();
|
|
276
|
+
var utf16le = require_utf16le();
|
|
277
|
+
var LE = new Uint8Array(Uint16Array.of(255).buffer)[0] === 255;
|
|
278
|
+
function codecFor(encoding) {
|
|
279
|
+
switch (encoding) {
|
|
280
|
+
case "ascii": return ascii;
|
|
281
|
+
case "base64": return base64;
|
|
282
|
+
case "hex": return hex;
|
|
283
|
+
case "binary":
|
|
284
|
+
case "latin1": return latin1;
|
|
285
|
+
case "utf8":
|
|
286
|
+
case "utf-8":
|
|
287
|
+
case void 0:
|
|
288
|
+
case null: return utf8;
|
|
289
|
+
case "ucs2":
|
|
290
|
+
case "ucs-2":
|
|
291
|
+
case "utf16le":
|
|
292
|
+
case "utf-16le": return utf16le;
|
|
293
|
+
default: throw new Error(`Unknown encoding '${encoding}'`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function isBuffer(value) {
|
|
297
|
+
return value instanceof Uint8Array;
|
|
298
|
+
}
|
|
299
|
+
function isEncoding(encoding) {
|
|
300
|
+
try {
|
|
301
|
+
codecFor(encoding);
|
|
302
|
+
return true;
|
|
303
|
+
} catch {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function alloc(size, fill, encoding) {
|
|
308
|
+
const buffer = new Uint8Array(size);
|
|
309
|
+
if (fill !== void 0) exports.fill(buffer, fill, 0, buffer.byteLength, encoding);
|
|
310
|
+
return buffer;
|
|
311
|
+
}
|
|
312
|
+
function allocUnsafe(size) {
|
|
313
|
+
return new Uint8Array(size);
|
|
314
|
+
}
|
|
315
|
+
function allocUnsafeSlow(size) {
|
|
316
|
+
return new Uint8Array(size);
|
|
317
|
+
}
|
|
318
|
+
function byteLength(string, encoding) {
|
|
319
|
+
return codecFor(encoding).byteLength(string);
|
|
320
|
+
}
|
|
321
|
+
function compare(a, b) {
|
|
322
|
+
if (a === b) return 0;
|
|
323
|
+
const len = Math.min(a.byteLength, b.byteLength);
|
|
324
|
+
a = new DataView(a.buffer, a.byteOffset, a.byteLength);
|
|
325
|
+
b = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
326
|
+
let i = 0;
|
|
327
|
+
for (let n = len - len % 4; i < n; i += 4) if (a.getUint32(i, LE) !== b.getUint32(i, LE)) break;
|
|
328
|
+
for (; i < len; i++) {
|
|
329
|
+
const x = a.getUint8(i);
|
|
330
|
+
const y = b.getUint8(i);
|
|
331
|
+
if (x < y) return -1;
|
|
332
|
+
if (x > y) return 1;
|
|
333
|
+
}
|
|
334
|
+
return a.byteLength > b.byteLength ? 1 : a.byteLength < b.byteLength ? -1 : 0;
|
|
335
|
+
}
|
|
336
|
+
function concat(buffers, length) {
|
|
337
|
+
if (length === void 0) length = buffers.reduce((len, buffer) => len + buffer.byteLength, 0);
|
|
338
|
+
const result = new Uint8Array(length);
|
|
339
|
+
let offset = 0;
|
|
340
|
+
for (const buffer of buffers) {
|
|
341
|
+
if (offset + buffer.byteLength > result.byteLength) {
|
|
342
|
+
result.set(buffer.subarray(0, result.byteLength - offset), offset);
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
result.set(buffer, offset);
|
|
346
|
+
offset += buffer.byteLength;
|
|
347
|
+
}
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
function copy(source, target, targetStart = 0, sourceStart = 0, sourceEnd = source.byteLength) {
|
|
351
|
+
if (targetStart < 0) targetStart = 0;
|
|
352
|
+
if (targetStart >= target.byteLength) return 0;
|
|
353
|
+
const targetLength = target.byteLength - targetStart;
|
|
354
|
+
if (sourceStart < 0) sourceStart = 0;
|
|
355
|
+
if (sourceStart >= source.byteLength) return 0;
|
|
356
|
+
if (sourceEnd <= sourceStart) return 0;
|
|
357
|
+
if (sourceEnd > source.byteLength) sourceEnd = source.byteLength;
|
|
358
|
+
if (sourceEnd - sourceStart > targetLength) sourceEnd = sourceStart + targetLength;
|
|
359
|
+
const sourceLength = sourceEnd - sourceStart;
|
|
360
|
+
if (source === target) target.copyWithin(targetStart, sourceStart, sourceEnd);
|
|
361
|
+
else {
|
|
362
|
+
if (sourceStart !== 0 || sourceEnd !== source.byteLength) source = source.subarray(sourceStart, sourceEnd);
|
|
363
|
+
target.set(source, targetStart);
|
|
364
|
+
}
|
|
365
|
+
return sourceLength;
|
|
366
|
+
}
|
|
367
|
+
function equals(a, b) {
|
|
368
|
+
if (a === b) return true;
|
|
369
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
370
|
+
return compare(a, b) === 0;
|
|
371
|
+
}
|
|
372
|
+
function fill(buffer, value, offset = 0, end = buffer.byteLength, encoding = "utf8") {
|
|
373
|
+
if (typeof value === "string") {
|
|
374
|
+
if (typeof offset === "string") {
|
|
375
|
+
encoding = offset;
|
|
376
|
+
offset = 0;
|
|
377
|
+
end = buffer.byteLength;
|
|
378
|
+
} else if (typeof end === "string") {
|
|
379
|
+
encoding = end;
|
|
380
|
+
end = buffer.byteLength;
|
|
381
|
+
}
|
|
382
|
+
} else if (typeof value === "number") value = value & 255;
|
|
383
|
+
else if (typeof value === "boolean") value = +value;
|
|
384
|
+
if (offset < 0) offset = 0;
|
|
385
|
+
if (offset >= buffer.byteLength) return buffer;
|
|
386
|
+
if (end <= offset) return buffer;
|
|
387
|
+
if (end > buffer.byteLength) end = buffer.byteLength;
|
|
388
|
+
if (typeof value === "number") return buffer.fill(value, offset, end);
|
|
389
|
+
if (typeof value === "string") value = exports.from(value, encoding);
|
|
390
|
+
const len = value.byteLength;
|
|
391
|
+
for (let i = 0, n = end - offset; i < n; ++i) buffer[i + offset] = value[i % len];
|
|
392
|
+
return buffer;
|
|
393
|
+
}
|
|
394
|
+
function from(value, encodingOrOffset, length) {
|
|
395
|
+
if (typeof value === "string") return fromString(value, encodingOrOffset);
|
|
396
|
+
if (Array.isArray(value)) return fromArray(value);
|
|
397
|
+
if (ArrayBuffer.isView(value)) return fromBuffer(value);
|
|
398
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
399
|
+
}
|
|
400
|
+
function fromString(string, encoding) {
|
|
401
|
+
const codec = codecFor(encoding);
|
|
402
|
+
const buffer = new Uint8Array(codec.byteLength(string));
|
|
403
|
+
codec.write(buffer, string);
|
|
404
|
+
return buffer;
|
|
405
|
+
}
|
|
406
|
+
function fromArray(array) {
|
|
407
|
+
const buffer = new Uint8Array(array.length);
|
|
408
|
+
buffer.set(array);
|
|
409
|
+
return buffer;
|
|
410
|
+
}
|
|
411
|
+
function fromBuffer(buffer) {
|
|
412
|
+
const copy = new Uint8Array(buffer.byteLength);
|
|
413
|
+
copy.set(buffer);
|
|
414
|
+
return copy;
|
|
415
|
+
}
|
|
416
|
+
function fromArrayBuffer(arrayBuffer, byteOffset, length) {
|
|
417
|
+
return new Uint8Array(arrayBuffer, byteOffset, length);
|
|
418
|
+
}
|
|
419
|
+
function includes(buffer, value, byteOffset, encoding) {
|
|
420
|
+
return indexOf(buffer, value, byteOffset, encoding) !== -1;
|
|
421
|
+
}
|
|
422
|
+
function indexOf(buffer, value, byteOffset, encoding) {
|
|
423
|
+
return bidirectionalIndexOf(buffer, value, byteOffset, encoding, true);
|
|
424
|
+
}
|
|
425
|
+
function lastIndexOf(buffer, value, byteOffset, encoding) {
|
|
426
|
+
return bidirectionalIndexOf(buffer, value, byteOffset, encoding, false);
|
|
427
|
+
}
|
|
428
|
+
function bidirectionalIndexOf(buffer, value, byteOffset, encoding, first) {
|
|
429
|
+
if (buffer.byteLength === 0) return -1;
|
|
430
|
+
if (typeof byteOffset === "string") {
|
|
431
|
+
encoding = byteOffset;
|
|
432
|
+
byteOffset = 0;
|
|
433
|
+
} else if (byteOffset === void 0) byteOffset = first ? 0 : buffer.length - 1;
|
|
434
|
+
else if (byteOffset < 0) byteOffset += buffer.byteLength;
|
|
435
|
+
if (byteOffset >= buffer.byteLength) {
|
|
436
|
+
if (first) return -1;
|
|
437
|
+
else byteOffset = buffer.byteLength - 1;
|
|
438
|
+
} else if (byteOffset < 0) {
|
|
439
|
+
if (first) byteOffset = 0;
|
|
440
|
+
else return -1;
|
|
441
|
+
}
|
|
442
|
+
if (typeof value === "string") value = from(value, encoding);
|
|
443
|
+
else if (typeof value === "number") {
|
|
444
|
+
value = value & 255;
|
|
445
|
+
if (first) return buffer.indexOf(value, byteOffset);
|
|
446
|
+
else return buffer.lastIndexOf(value, byteOffset);
|
|
447
|
+
}
|
|
448
|
+
if (value.byteLength === 0) return -1;
|
|
449
|
+
if (first) {
|
|
450
|
+
let foundIndex = -1;
|
|
451
|
+
for (let i = byteOffset; i < buffer.byteLength; i++) if (buffer[i] === value[foundIndex === -1 ? 0 : i - foundIndex]) {
|
|
452
|
+
if (foundIndex === -1) foundIndex = i;
|
|
453
|
+
if (i - foundIndex + 1 === value.byteLength) return foundIndex;
|
|
454
|
+
} else {
|
|
455
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
456
|
+
foundIndex = -1;
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
if (byteOffset + value.byteLength > buffer.byteLength) byteOffset = buffer.byteLength - value.byteLength;
|
|
460
|
+
for (let i = byteOffset; i >= 0; i--) {
|
|
461
|
+
let found = true;
|
|
462
|
+
for (let j = 0; j < value.byteLength; j++) if (buffer[i + j] !== value[j]) {
|
|
463
|
+
found = false;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
if (found) return i;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return -1;
|
|
470
|
+
}
|
|
471
|
+
function swap(buffer, n, m) {
|
|
472
|
+
const i = buffer[n];
|
|
473
|
+
buffer[n] = buffer[m];
|
|
474
|
+
buffer[m] = i;
|
|
475
|
+
}
|
|
476
|
+
function swap16(buffer) {
|
|
477
|
+
const len = buffer.byteLength;
|
|
478
|
+
if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
479
|
+
for (let i = 0; i < len; i += 2) swap(buffer, i, i + 1);
|
|
480
|
+
return buffer;
|
|
481
|
+
}
|
|
482
|
+
function swap32(buffer) {
|
|
483
|
+
const len = buffer.byteLength;
|
|
484
|
+
if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
485
|
+
for (let i = 0; i < len; i += 4) {
|
|
486
|
+
swap(buffer, i, i + 3);
|
|
487
|
+
swap(buffer, i + 1, i + 2);
|
|
488
|
+
}
|
|
489
|
+
return buffer;
|
|
490
|
+
}
|
|
491
|
+
function swap64(buffer) {
|
|
492
|
+
const len = buffer.byteLength;
|
|
493
|
+
if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
494
|
+
for (let i = 0; i < len; i += 8) {
|
|
495
|
+
swap(buffer, i, i + 7);
|
|
496
|
+
swap(buffer, i + 1, i + 6);
|
|
497
|
+
swap(buffer, i + 2, i + 5);
|
|
498
|
+
swap(buffer, i + 3, i + 4);
|
|
499
|
+
}
|
|
500
|
+
return buffer;
|
|
501
|
+
}
|
|
502
|
+
function toBuffer(buffer) {
|
|
503
|
+
return buffer;
|
|
504
|
+
}
|
|
505
|
+
function toString(buffer, encoding = "utf8", start = 0, end = buffer.byteLength) {
|
|
506
|
+
if (arguments.length === 1) return utf8.toString(buffer);
|
|
507
|
+
if (arguments.length === 2) return codecFor(encoding).toString(buffer);
|
|
508
|
+
if (start < 0) start = 0;
|
|
509
|
+
if (start >= buffer.byteLength) return "";
|
|
510
|
+
if (end <= start) return "";
|
|
511
|
+
if (end > buffer.byteLength) end = buffer.byteLength;
|
|
512
|
+
if (start !== 0 || end !== buffer.byteLength) buffer = buffer.subarray(start, end);
|
|
513
|
+
return codecFor(encoding).toString(buffer);
|
|
514
|
+
}
|
|
515
|
+
function toHex(buffer, start, end) {
|
|
516
|
+
return toString(buffer, "hex", start, end);
|
|
517
|
+
}
|
|
518
|
+
function write(buffer, string, offset = 0, length = buffer.byteLength, encoding) {
|
|
519
|
+
if (arguments.length === 2) return utf8.write(buffer, string);
|
|
520
|
+
if (typeof offset === "string") {
|
|
521
|
+
encoding = offset;
|
|
522
|
+
offset = 0;
|
|
523
|
+
length = buffer.byteLength;
|
|
524
|
+
} else if (typeof length === "string") {
|
|
525
|
+
encoding = length;
|
|
526
|
+
length = buffer.byteLength - offset;
|
|
527
|
+
}
|
|
528
|
+
length = Math.min(length, exports.byteLength(string, encoding));
|
|
529
|
+
let start = offset;
|
|
530
|
+
if (start < 0) start = 0;
|
|
531
|
+
if (start >= buffer.byteLength) return 0;
|
|
532
|
+
let end = offset + length;
|
|
533
|
+
if (end <= start) return 0;
|
|
534
|
+
if (end > buffer.byteLength) end = buffer.byteLength;
|
|
535
|
+
if (start !== 0 || end !== buffer.byteLength) buffer = buffer.subarray(start, end);
|
|
536
|
+
return codecFor(encoding).write(buffer, string);
|
|
537
|
+
}
|
|
538
|
+
function readDoubleBE(buffer, offset = 0) {
|
|
539
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getFloat64(offset, false);
|
|
540
|
+
}
|
|
541
|
+
function readDoubleLE(buffer, offset = 0) {
|
|
542
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getFloat64(offset, true);
|
|
543
|
+
}
|
|
544
|
+
function readFloatBE(buffer, offset = 0) {
|
|
545
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getFloat32(offset, false);
|
|
546
|
+
}
|
|
547
|
+
function readFloatLE(buffer, offset = 0) {
|
|
548
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getFloat32(offset, true);
|
|
549
|
+
}
|
|
550
|
+
function readInt32BE(buffer, offset = 0) {
|
|
551
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getInt32(offset, false);
|
|
552
|
+
}
|
|
553
|
+
function readInt32LE(buffer, offset = 0) {
|
|
554
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getInt32(offset, true);
|
|
555
|
+
}
|
|
556
|
+
function readUInt32BE(buffer, offset = 0) {
|
|
557
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getUint32(offset, false);
|
|
558
|
+
}
|
|
559
|
+
function readUInt32LE(buffer, offset = 0) {
|
|
560
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getUint32(offset, true);
|
|
561
|
+
}
|
|
562
|
+
function writeDoubleBE(buffer, value, offset = 0) {
|
|
563
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setFloat64(offset, value, false);
|
|
564
|
+
return offset + 8;
|
|
565
|
+
}
|
|
566
|
+
function writeDoubleLE(buffer, value, offset = 0) {
|
|
567
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setFloat64(offset, value, true);
|
|
568
|
+
return offset + 8;
|
|
569
|
+
}
|
|
570
|
+
function writeFloatBE(buffer, value, offset = 0) {
|
|
571
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setFloat32(offset, value, false);
|
|
572
|
+
return offset + 4;
|
|
573
|
+
}
|
|
574
|
+
function writeFloatLE(buffer, value, offset = 0) {
|
|
575
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setFloat32(offset, value, true);
|
|
576
|
+
return offset + 4;
|
|
577
|
+
}
|
|
578
|
+
function writeInt32BE(buffer, value, offset = 0) {
|
|
579
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setInt32(offset, value, false);
|
|
580
|
+
return offset + 4;
|
|
581
|
+
}
|
|
582
|
+
function writeInt32LE(buffer, value, offset = 0) {
|
|
583
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setInt32(offset, value, true);
|
|
584
|
+
return offset + 4;
|
|
585
|
+
}
|
|
586
|
+
function writeUInt32BE(buffer, value, offset = 0) {
|
|
587
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setUint32(offset, value, false);
|
|
588
|
+
return offset + 4;
|
|
589
|
+
}
|
|
590
|
+
function writeUInt32LE(buffer, value, offset = 0) {
|
|
591
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setUint32(offset, value, true);
|
|
592
|
+
return offset + 4;
|
|
593
|
+
}
|
|
594
|
+
module.exports = exports = {
|
|
595
|
+
isBuffer,
|
|
596
|
+
isEncoding,
|
|
597
|
+
alloc,
|
|
598
|
+
allocUnsafe,
|
|
599
|
+
allocUnsafeSlow,
|
|
600
|
+
byteLength,
|
|
601
|
+
compare,
|
|
602
|
+
concat,
|
|
603
|
+
copy,
|
|
604
|
+
equals,
|
|
605
|
+
fill,
|
|
606
|
+
from,
|
|
607
|
+
includes,
|
|
608
|
+
indexOf,
|
|
609
|
+
lastIndexOf,
|
|
610
|
+
swap16,
|
|
611
|
+
swap32,
|
|
612
|
+
swap64,
|
|
613
|
+
toBuffer,
|
|
614
|
+
toString,
|
|
615
|
+
toHex,
|
|
616
|
+
write,
|
|
617
|
+
readDoubleBE,
|
|
618
|
+
readDoubleLE,
|
|
619
|
+
readFloatBE,
|
|
620
|
+
readFloatLE,
|
|
621
|
+
readInt32BE,
|
|
622
|
+
readInt32LE,
|
|
623
|
+
readUInt32BE,
|
|
624
|
+
readUInt32LE,
|
|
625
|
+
writeDoubleBE,
|
|
626
|
+
writeDoubleLE,
|
|
627
|
+
writeFloatBE,
|
|
628
|
+
writeFloatLE,
|
|
629
|
+
writeInt32BE,
|
|
630
|
+
writeInt32LE,
|
|
631
|
+
writeUInt32BE,
|
|
632
|
+
writeUInt32LE
|
|
633
|
+
};
|
|
634
|
+
}));
|
|
635
|
+
//#endregion
|
|
2
636
|
//#region ../../node_modules/compact-encoding/endian.js
|
|
3
637
|
var require_endian = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
638
|
exports.BE = !(exports.LE = new Uint8Array(new Uint16Array([255]).buffer)[0] === 255);
|
|
@@ -6,7 +640,7 @@ var require_endian = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
6
640
|
//#endregion
|
|
7
641
|
//#region ../../node_modules/compact-encoding/raw.js
|
|
8
642
|
var require_raw = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9
|
-
var b4a
|
|
643
|
+
var b4a = require_browser();
|
|
10
644
|
var { BE } = require_endian();
|
|
11
645
|
exports = module.exports = {
|
|
12
646
|
preencode(state, b) {
|
|
@@ -84,25 +718,25 @@ var require_raw = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
84
718
|
};
|
|
85
719
|
}
|
|
86
720
|
var uint8array = exports.uint8array = typedarray(Uint8Array);
|
|
87
|
-
exports.uint16array = typedarray(Uint16Array, b4a
|
|
88
|
-
exports.uint32array = typedarray(Uint32Array, b4a
|
|
721
|
+
exports.uint16array = typedarray(Uint16Array, b4a.swap16);
|
|
722
|
+
exports.uint32array = typedarray(Uint32Array, b4a.swap32);
|
|
89
723
|
exports.int8array = typedarray(Int8Array);
|
|
90
|
-
exports.int16array = typedarray(Int16Array, b4a
|
|
91
|
-
exports.int32array = typedarray(Int32Array, b4a
|
|
92
|
-
exports.biguint64array = typedarray(BigUint64Array, b4a
|
|
93
|
-
exports.bigint64array = typedarray(BigInt64Array, b4a
|
|
94
|
-
exports.float32array = typedarray(Float32Array, b4a
|
|
95
|
-
exports.float64array = typedarray(Float64Array, b4a
|
|
724
|
+
exports.int16array = typedarray(Int16Array, b4a.swap16);
|
|
725
|
+
exports.int32array = typedarray(Int32Array, b4a.swap32);
|
|
726
|
+
exports.biguint64array = typedarray(BigUint64Array, b4a.swap64);
|
|
727
|
+
exports.bigint64array = typedarray(BigInt64Array, b4a.swap64);
|
|
728
|
+
exports.float32array = typedarray(Float32Array, b4a.swap32);
|
|
729
|
+
exports.float64array = typedarray(Float64Array, b4a.swap64);
|
|
96
730
|
function string(encoding) {
|
|
97
731
|
return {
|
|
98
732
|
preencode(state, s) {
|
|
99
|
-
state.end += b4a
|
|
733
|
+
state.end += b4a.byteLength(s, encoding);
|
|
100
734
|
},
|
|
101
735
|
encode(state, s) {
|
|
102
|
-
state.start += b4a
|
|
736
|
+
state.start += b4a.write(state.buffer, s, state.start, encoding);
|
|
103
737
|
},
|
|
104
738
|
decode(state) {
|
|
105
|
-
const s = b4a
|
|
739
|
+
const s = b4a.toString(state.buffer, encoding, state.start);
|
|
106
740
|
state.start = state.end;
|
|
107
741
|
return s;
|
|
108
742
|
}
|
|
@@ -221,7 +855,7 @@ var require_lexint = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
221
855
|
//#endregion
|
|
222
856
|
//#region ../../node_modules/compact-encoding/index.js
|
|
223
857
|
var require_compact_encoding = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
224
|
-
var b4a
|
|
858
|
+
var b4a = require_browser();
|
|
225
859
|
var { BE } = require_endian();
|
|
226
860
|
var MAX_SAFE_INT = 2 ** 52 - 1;
|
|
227
861
|
var MIN_SAFE_INT = -(2 ** 52);
|
|
@@ -594,32 +1228,32 @@ var require_compact_encoding = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
594
1228
|
};
|
|
595
1229
|
}
|
|
596
1230
|
var uint8array = exports.uint8array = typedarray(Uint8Array);
|
|
597
|
-
exports.uint16array = typedarray(Uint16Array, b4a
|
|
598
|
-
exports.uint32array = typedarray(Uint32Array, b4a
|
|
1231
|
+
exports.uint16array = typedarray(Uint16Array, b4a.swap16);
|
|
1232
|
+
exports.uint32array = typedarray(Uint32Array, b4a.swap32);
|
|
599
1233
|
exports.int8array = typedarray(Int8Array);
|
|
600
|
-
exports.int16array = typedarray(Int16Array, b4a
|
|
601
|
-
exports.int32array = typedarray(Int32Array, b4a
|
|
602
|
-
exports.biguint64array = typedarray(BigUint64Array, b4a
|
|
603
|
-
exports.bigint64array = typedarray(BigInt64Array, b4a
|
|
604
|
-
exports.float32array = typedarray(Float32Array, b4a
|
|
605
|
-
exports.float64array = typedarray(Float64Array, b4a
|
|
1234
|
+
exports.int16array = typedarray(Int16Array, b4a.swap16);
|
|
1235
|
+
exports.int32array = typedarray(Int32Array, b4a.swap32);
|
|
1236
|
+
exports.biguint64array = typedarray(BigUint64Array, b4a.swap64);
|
|
1237
|
+
exports.bigint64array = typedarray(BigInt64Array, b4a.swap64);
|
|
1238
|
+
exports.float32array = typedarray(Float32Array, b4a.swap32);
|
|
1239
|
+
exports.float64array = typedarray(Float64Array, b4a.swap64);
|
|
606
1240
|
function string(encoding) {
|
|
607
1241
|
return {
|
|
608
1242
|
preencode(state, s) {
|
|
609
|
-
const len = b4a
|
|
1243
|
+
const len = b4a.byteLength(s, encoding);
|
|
610
1244
|
uint.preencode(state, len);
|
|
611
1245
|
state.end += len;
|
|
612
1246
|
},
|
|
613
1247
|
encode(state, s) {
|
|
614
|
-
const len = b4a
|
|
1248
|
+
const len = b4a.byteLength(s, encoding);
|
|
615
1249
|
uint.encode(state, len);
|
|
616
|
-
b4a
|
|
1250
|
+
b4a.write(state.buffer, s, state.start, encoding);
|
|
617
1251
|
state.start += len;
|
|
618
1252
|
},
|
|
619
1253
|
decode(state) {
|
|
620
1254
|
const len = uint.decode(state);
|
|
621
1255
|
if (state.end - state.start < len) throw new Error("Out of bounds");
|
|
622
|
-
return b4a
|
|
1256
|
+
return b4a.toString(state.buffer, encoding, state.start, state.start += len);
|
|
623
1257
|
},
|
|
624
1258
|
fixed(n) {
|
|
625
1259
|
return {
|
|
@@ -627,12 +1261,12 @@ var require_compact_encoding = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
627
1261
|
state.end += n;
|
|
628
1262
|
},
|
|
629
1263
|
encode(state, s) {
|
|
630
|
-
b4a
|
|
1264
|
+
b4a.write(state.buffer, s, state.start, n, encoding);
|
|
631
1265
|
state.start += n;
|
|
632
1266
|
},
|
|
633
1267
|
decode(state) {
|
|
634
1268
|
if (state.end - state.start < n) throw new Error("Out of bounds");
|
|
635
|
-
return b4a
|
|
1269
|
+
return b4a.toString(state.buffer, encoding, state.start, state.start += n);
|
|
636
1270
|
}
|
|
637
1271
|
};
|
|
638
1272
|
}
|
|
@@ -970,7 +1604,7 @@ var require_compact_encoding = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
970
1604
|
if (o === null || o === void 0) return 0;
|
|
971
1605
|
if (typeof o === "boolean") return 1;
|
|
972
1606
|
if (typeof o === "string") return 2;
|
|
973
|
-
if (b4a
|
|
1607
|
+
if (b4a.isBuffer(o)) return 3;
|
|
974
1608
|
if (typeof o === "number") {
|
|
975
1609
|
if (Number.isInteger(o)) return o >= 0 ? 4 : 5;
|
|
976
1610
|
return 6;
|
|
@@ -1039,7 +1673,7 @@ var require_compact_encoding = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1039
1673
|
exports.encode = function encode(enc, m) {
|
|
1040
1674
|
const state = exports.state();
|
|
1041
1675
|
enc.preencode(state, m);
|
|
1042
|
-
state.buffer = b4a
|
|
1676
|
+
state.buffer = b4a.allocUnsafe(state.end);
|
|
1043
1677
|
enc.encode(state, m);
|
|
1044
1678
|
return state.buffer;
|
|
1045
1679
|
};
|
|
@@ -1242,7 +1876,7 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1242
1876
|
//#region ../../node_modules/sha512-universal/sha512.js
|
|
1243
1877
|
var require_sha512$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1244
1878
|
var assert = require_nanoassert();
|
|
1245
|
-
var b4a
|
|
1879
|
+
var b4a = require_browser();
|
|
1246
1880
|
module.exports = Sha512;
|
|
1247
1881
|
var BLOCKSIZE = 128;
|
|
1248
1882
|
var K = [
|
|
@@ -1472,7 +2106,7 @@ var require_sha512$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1472
2106
|
}
|
|
1473
2107
|
const resultBuf = /* @__PURE__ */ new Uint8Array(64);
|
|
1474
2108
|
for (let i = 0; i < 8; i++) ts64(resultBuf, 8 * i, this.hh[i], this.hl[i]);
|
|
1475
|
-
if (typeof enc === "string") return b4a
|
|
2109
|
+
if (typeof enc === "string") return b4a.toString(resultBuf, enc);
|
|
1476
2110
|
return resultBuf;
|
|
1477
2111
|
};
|
|
1478
2112
|
function ts64(x, i, h, l) {
|
|
@@ -1486,7 +2120,7 @@ var require_sha512$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1486
2120
|
x[i + 7] = l & 255;
|
|
1487
2121
|
}
|
|
1488
2122
|
function formatInput(input, enc) {
|
|
1489
|
-
var result = b4a
|
|
2123
|
+
var result = b4a.from(input, enc);
|
|
1490
2124
|
return [result, result.byteLength];
|
|
1491
2125
|
}
|
|
1492
2126
|
function compress(hh, hl, m, n) {
|
|
@@ -1785,10 +2419,10 @@ var require_sha512$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1785
2419
|
}
|
|
1786
2420
|
function HMAC(key) {
|
|
1787
2421
|
if (!(this instanceof HMAC)) return new HMAC(key);
|
|
1788
|
-
this.pad = b4a
|
|
2422
|
+
this.pad = b4a.alloc(128);
|
|
1789
2423
|
this.inner = Sha512();
|
|
1790
2424
|
this.outer = Sha512();
|
|
1791
|
-
const keyhash = b4a
|
|
2425
|
+
const keyhash = b4a.alloc(64);
|
|
1792
2426
|
if (key.byteLength > 128) {
|
|
1793
2427
|
Sha512().update(key).digest(keyhash);
|
|
1794
2428
|
key = keyhash;
|
|
@@ -1845,7 +2479,7 @@ var require_sha512$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1845
2479
|
//#region ../../node_modules/sha512-wasm/index.js
|
|
1846
2480
|
var require_sha512_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1847
2481
|
var assert = require_nanoassert();
|
|
1848
|
-
var b4a
|
|
2482
|
+
var b4a = require_browser();
|
|
1849
2483
|
var wasm = typeof WebAssembly !== "undefined" && require_sha512$1()({ imports: { debug: {
|
|
1850
2484
|
log(...args) {
|
|
1851
2485
|
console.log(...args.map((int) => (int >>> 0).toString(16).padStart(8, "0")));
|
|
@@ -1905,7 +2539,7 @@ var require_sha512_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1905
2539
|
wasm.sha512(this.pointer, head, 0, 1);
|
|
1906
2540
|
const resultBuf = this._memory.subarray(this.pointer, this.pointer + this.digestLength);
|
|
1907
2541
|
if (!enc) return resultBuf;
|
|
1908
|
-
if (typeof enc === "string") return b4a
|
|
2542
|
+
if (typeof enc === "string") return b4a.toString(resultBuf, enc);
|
|
1909
2543
|
assert(enc instanceof Uint8Array, "output must be Uint8Array or Buffer");
|
|
1910
2544
|
assert(enc.byteLength >= this.digestLength + offset, "output must have at least 'SHA512_BYTES' bytes remaining");
|
|
1911
2545
|
for (let i = 0; i < this.digestLength; i++) enc[i + offset] = resultBuf[i];
|
|
@@ -1922,10 +2556,10 @@ var require_sha512_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1922
2556
|
Sha512.prototype.ready = Sha512.ready;
|
|
1923
2557
|
function HMAC(key) {
|
|
1924
2558
|
if (!(this instanceof HMAC)) return new HMAC(key);
|
|
1925
|
-
this.pad = b4a
|
|
2559
|
+
this.pad = b4a.alloc(128);
|
|
1926
2560
|
this.inner = Sha512();
|
|
1927
2561
|
this.outer = Sha512();
|
|
1928
|
-
const keyhash = b4a
|
|
2562
|
+
const keyhash = b4a.alloc(64);
|
|
1929
2563
|
if (key.byteLength > 128) {
|
|
1930
2564
|
Sha512().update(key).digest(keyhash);
|
|
1931
2565
|
key = keyhash;
|
|
@@ -1950,7 +2584,7 @@ var require_sha512_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1950
2584
|
Sha512.HMAC = HMAC;
|
|
1951
2585
|
function noop() {}
|
|
1952
2586
|
function formatInput(input, enc) {
|
|
1953
|
-
var result = b4a
|
|
2587
|
+
var result = b4a.from(input, enc);
|
|
1954
2588
|
return [result, result.byteLength];
|
|
1955
2589
|
}
|
|
1956
2590
|
function roundUp(n, base) {
|
|
@@ -2734,7 +3368,7 @@ var require_blake2b$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2734
3368
|
//#region ../../node_modules/blake2b-wasm/index.js
|
|
2735
3369
|
var require_blake2b_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2736
3370
|
var assert = require_nanoassert();
|
|
2737
|
-
var b4a
|
|
3371
|
+
var b4a = require_browser();
|
|
2738
3372
|
var wasm = null;
|
|
2739
3373
|
var wasmPromise = typeof WebAssembly !== "undefined" && require_blake2b$1()().then((mod) => {
|
|
2740
3374
|
wasm = mod;
|
|
@@ -2812,7 +3446,7 @@ var require_blake2b_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2812
3446
|
freeList.push(this.pointer);
|
|
2813
3447
|
wasm.blake2b_final(this.pointer);
|
|
2814
3448
|
if (!enc || enc === "binary") return this._memory.slice(this.pointer + 128, this.pointer + 128 + this.digestLength);
|
|
2815
|
-
if (typeof enc === "string") return b4a
|
|
3449
|
+
if (typeof enc === "string") return b4a.toString(this._memory, enc, this.pointer + 128, this.pointer + 128 + this.digestLength);
|
|
2816
3450
|
assert(enc instanceof Uint8Array && enc.length >= this.digestLength, "input must be Uint8Array or Buffer");
|
|
2817
3451
|
for (var i = 0; i < this.digestLength; i++) enc[i] = this._memory[this.pointer + 128 + i];
|
|
2818
3452
|
return enc;
|
|
@@ -4360,7 +4994,7 @@ var require_crypto_box = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4360
4994
|
//#region ../../node_modules/sha256-universal/sha256.js
|
|
4361
4995
|
var require_sha256$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4362
4996
|
var assert = require_nanoassert();
|
|
4363
|
-
var b4a
|
|
4997
|
+
var b4a = require_browser();
|
|
4364
4998
|
module.exports = Sha256;
|
|
4365
4999
|
var SHA256_BYTES = module.exports.SHA256_BYTES = 32;
|
|
4366
5000
|
var BLOCKSIZE = 64;
|
|
@@ -4537,7 +5171,7 @@ var require_sha256$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4537
5171
|
compress(this.state, this.words);
|
|
4538
5172
|
const resultBuf = new Uint8Array(this.state.map(bswap).buffer);
|
|
4539
5173
|
if (!enc) return new Uint8Array(resultBuf);
|
|
4540
|
-
if (typeof enc === "string") return b4a
|
|
5174
|
+
if (typeof enc === "string") return b4a.toString(resultBuf, enc);
|
|
4541
5175
|
assert(enc instanceof Uint8Array, "input must be Uint8Array or Buffer");
|
|
4542
5176
|
assert(enc.byteLength >= this.digestLength + offset, "input not large enough for digest");
|
|
4543
5177
|
for (let i = 0; i < this.digestLength; i++) enc[i + offset] = resultBuf[i];
|
|
@@ -4545,10 +5179,10 @@ var require_sha256$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4545
5179
|
};
|
|
4546
5180
|
function HMAC(key) {
|
|
4547
5181
|
if (!(this instanceof HMAC)) return new HMAC(key);
|
|
4548
|
-
this.pad = b4a
|
|
5182
|
+
this.pad = b4a.alloc(64);
|
|
4549
5183
|
this.inner = Sha256();
|
|
4550
5184
|
this.outer = Sha256();
|
|
4551
|
-
const keyhash = b4a
|
|
5185
|
+
const keyhash = b4a.alloc(32);
|
|
4552
5186
|
if (key.byteLength > 64) {
|
|
4553
5187
|
Sha256().update(key).digest(keyhash);
|
|
4554
5188
|
key = keyhash;
|
|
@@ -4572,7 +5206,7 @@ var require_sha256$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4572
5206
|
};
|
|
4573
5207
|
Sha256.HMAC = HMAC;
|
|
4574
5208
|
function formatInput(input, enc) {
|
|
4575
|
-
var result = b4a
|
|
5209
|
+
var result = b4a.from(input, enc);
|
|
4576
5210
|
return [result, result.byteLength];
|
|
4577
5211
|
}
|
|
4578
5212
|
function bswap(a) {
|
|
@@ -4612,7 +5246,7 @@ var require_sha256$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4612
5246
|
//#region ../../node_modules/sha256-wasm/index.js
|
|
4613
5247
|
var require_sha256_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4614
5248
|
var assert = require_nanoassert();
|
|
4615
|
-
var b4a
|
|
5249
|
+
var b4a = require_browser();
|
|
4616
5250
|
var wasm = typeof WebAssembly !== "undefined" && require_sha256$1()({ imports: { debug: {
|
|
4617
5251
|
log(...args) {
|
|
4618
5252
|
console.log(...args.map((int) => (int >>> 0).toString(16).padStart(8, "0")));
|
|
@@ -4671,7 +5305,7 @@ var require_sha256_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4671
5305
|
wasm.sha256(this.pointer, head, 0, 1);
|
|
4672
5306
|
const resultBuf = this._memory.subarray(this.pointer, this.pointer + this.digestLength);
|
|
4673
5307
|
if (!enc) return resultBuf;
|
|
4674
|
-
if (typeof enc === "string") return b4a
|
|
5308
|
+
if (typeof enc === "string") return b4a.toString(resultBuf, enc);
|
|
4675
5309
|
assert(enc instanceof Uint8Array, "output must be Uint8Array or Buffer");
|
|
4676
5310
|
assert(enc.byteLength >= this.digestLength + offset, "output must have at least 'SHA256_BYTES' bytes remaining");
|
|
4677
5311
|
for (let i = 0; i < this.digestLength; i++) enc[i + offset] = resultBuf[i];
|
|
@@ -4688,10 +5322,10 @@ var require_sha256_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4688
5322
|
Sha256.prototype.ready = Sha256.ready;
|
|
4689
5323
|
function HMAC(key) {
|
|
4690
5324
|
if (!(this instanceof HMAC)) return new HMAC(key);
|
|
4691
|
-
this.pad = b4a
|
|
5325
|
+
this.pad = b4a.alloc(64);
|
|
4692
5326
|
this.inner = Sha256();
|
|
4693
5327
|
this.outer = Sha256();
|
|
4694
|
-
const keyhash = b4a
|
|
5328
|
+
const keyhash = b4a.alloc(32);
|
|
4695
5329
|
if (key.byteLength > 64) {
|
|
4696
5330
|
Sha256().update(key).digest(keyhash);
|
|
4697
5331
|
key = keyhash;
|
|
@@ -4716,7 +5350,7 @@ var require_sha256_wasm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4716
5350
|
Sha256.HMAC = HMAC;
|
|
4717
5351
|
function noop() {}
|
|
4718
5352
|
function formatInput(input, enc) {
|
|
4719
|
-
var result = b4a
|
|
5353
|
+
var result = b4a.from(input, enc);
|
|
4720
5354
|
return [result, result.byteLength];
|
|
4721
5355
|
}
|
|
4722
5356
|
function roundUp(n, base) {
|
|
@@ -6293,7 +6927,7 @@ var require_sha512 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6293
6927
|
//#endregion
|
|
6294
6928
|
//#region ../../node_modules/sodium-hmac/index.js
|
|
6295
6929
|
var require_sodium_hmac = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6296
|
-
var b4a
|
|
6930
|
+
var b4a = require_browser();
|
|
6297
6931
|
var sha256 = require_sha256();
|
|
6298
6932
|
var sha512 = require_sha512();
|
|
6299
6933
|
module.exports = {
|
|
@@ -6303,8 +6937,8 @@ var require_sodium_hmac = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6303
6937
|
this.length = hash.BYTES;
|
|
6304
6938
|
this._blocksize = 2 * hash.BYTES;
|
|
6305
6939
|
this._initialised = false;
|
|
6306
|
-
this.state = b4a
|
|
6307
|
-
this.pad = b4a
|
|
6940
|
+
this.state = b4a.alloc(hash.STATEBYTES);
|
|
6941
|
+
this.pad = b4a.alloc(this._blocksize);
|
|
6308
6942
|
if (key) this.init(key);
|
|
6309
6943
|
}
|
|
6310
6944
|
init(key) {
|
|
@@ -6326,7 +6960,7 @@ var require_sodium_hmac = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6326
6960
|
this.hash.update(this.state, data);
|
|
6327
6961
|
return this;
|
|
6328
6962
|
}
|
|
6329
|
-
final(output = b4a
|
|
6963
|
+
final(output = b4a.alloc(this.length)) {
|
|
6330
6964
|
if (!this._initialised) throw new Error("First initialise with a key");
|
|
6331
6965
|
const out = output.byteLength === this.length ? output : output.subarray(0, this.hash.BYTES);
|
|
6332
6966
|
this.hash.final(this.state, out);
|
|
@@ -6355,6 +6989,1040 @@ var require_sodium_hmac = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6355
6989
|
}
|
|
6356
6990
|
}));
|
|
6357
6991
|
//#endregion
|
|
6992
|
+
//#region ../../node_modules/@noble/hashes/utils.js
|
|
6993
|
+
/**
|
|
6994
|
+
* Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
|
|
6995
|
+
* @param a - value to test
|
|
6996
|
+
* @returns `true` when the value is a Uint8Array-compatible view.
|
|
6997
|
+
* @example
|
|
6998
|
+
* Check whether a value is a Uint8Array-compatible view.
|
|
6999
|
+
* ```ts
|
|
7000
|
+
* isBytes(new Uint8Array([1, 2, 3]));
|
|
7001
|
+
* ```
|
|
7002
|
+
*/
|
|
7003
|
+
function isBytes(a) {
|
|
7004
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
7005
|
+
}
|
|
7006
|
+
/**
|
|
7007
|
+
* Asserts something is a non-negative integer.
|
|
7008
|
+
* @param n - number to validate
|
|
7009
|
+
* @param title - label included in thrown errors
|
|
7010
|
+
* @returns The validated number.
|
|
7011
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7012
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7013
|
+
* @example
|
|
7014
|
+
* Validate a non-negative integer option.
|
|
7015
|
+
* ```ts
|
|
7016
|
+
* anumber(32, 'length');
|
|
7017
|
+
* ```
|
|
7018
|
+
*/
|
|
7019
|
+
function anumber(n, title = "") {
|
|
7020
|
+
if (typeof n !== "number") throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
7021
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
7022
|
+
return n;
|
|
7023
|
+
}
|
|
7024
|
+
/**
|
|
7025
|
+
* Asserts something is Uint8Array.
|
|
7026
|
+
* @param value - value to validate
|
|
7027
|
+
* @param length - optional exact length constraint
|
|
7028
|
+
* @param title - label included in thrown errors
|
|
7029
|
+
* @returns The validated byte array.
|
|
7030
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7031
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7032
|
+
* @example
|
|
7033
|
+
* Validate that a value is a byte array.
|
|
7034
|
+
* ```ts
|
|
7035
|
+
* abytes(new Uint8Array([1, 2, 3]));
|
|
7036
|
+
* ```
|
|
7037
|
+
*/
|
|
7038
|
+
function abytes(value, length, title = "") {
|
|
7039
|
+
if (isBytes(value) && (length === void 0 || value.length === length)) return value;
|
|
7040
|
+
if (length !== void 0) anumber(length, "length");
|
|
7041
|
+
const bytes = isBytes(value);
|
|
7042
|
+
const ofLen = length !== void 0 ? ` of length ${length}` : "";
|
|
7043
|
+
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
7044
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
7045
|
+
if (!bytes) throw new TypeError(message);
|
|
7046
|
+
throw new RangeError(message);
|
|
7047
|
+
}
|
|
7048
|
+
/**
|
|
7049
|
+
* Asserts something is a wrapped hash constructor.
|
|
7050
|
+
* @param h - hash constructor to validate
|
|
7051
|
+
* @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}
|
|
7052
|
+
* @throws On invalid hash metadata ranges or values. {@link RangeError}
|
|
7053
|
+
* @throws If the hash metadata allows empty outputs or block sizes. {@link Error}
|
|
7054
|
+
* @example
|
|
7055
|
+
* Validate a callable hash wrapper.
|
|
7056
|
+
* ```ts
|
|
7057
|
+
* import { ahash } from '@noble/hashes/utils.js';
|
|
7058
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7059
|
+
* ahash(sha256);
|
|
7060
|
+
* ```
|
|
7061
|
+
*/
|
|
7062
|
+
function ahash(h) {
|
|
7063
|
+
if (typeof h !== "function" || typeof h.create !== "function") throw new TypeError("expected hash wrapped by utils.createHasher");
|
|
7064
|
+
anumber(h.outputLen);
|
|
7065
|
+
anumber(h.blockLen);
|
|
7066
|
+
if (h.outputLen < 1 || h.blockLen < 1) throw new Error("hash blockLen / outputLen must be >= 1");
|
|
7067
|
+
}
|
|
7068
|
+
/**
|
|
7069
|
+
* Asserts a hash instance has not been destroyed or finished.
|
|
7070
|
+
* @param instance - hash instance to validate
|
|
7071
|
+
* @param checkFinished - whether to reject finalized instances
|
|
7072
|
+
* @throws If the hash instance has already been destroyed or finalized. {@link Error}
|
|
7073
|
+
* @example
|
|
7074
|
+
* Validate that a hash instance is still usable.
|
|
7075
|
+
* ```ts
|
|
7076
|
+
* import { aexists } from '@noble/hashes/utils.js';
|
|
7077
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7078
|
+
* const hash = sha256.create();
|
|
7079
|
+
* aexists(hash);
|
|
7080
|
+
* ```
|
|
7081
|
+
*/
|
|
7082
|
+
function aexists(instance, checkFinished = true) {
|
|
7083
|
+
if (instance.destroyed) throw new Error("hash was destroyed");
|
|
7084
|
+
if (checkFinished && instance.finished) throw new Error("digest() was already called");
|
|
7085
|
+
}
|
|
7086
|
+
/**
|
|
7087
|
+
* Asserts output is a sufficiently-sized byte array.
|
|
7088
|
+
* @param out - destination buffer
|
|
7089
|
+
* @param instance - hash instance providing output length
|
|
7090
|
+
* Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
|
|
7091
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7092
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7093
|
+
* @example
|
|
7094
|
+
* Validate a caller-provided digest buffer.
|
|
7095
|
+
* ```ts
|
|
7096
|
+
* import { aoutput } from '@noble/hashes/utils.js';
|
|
7097
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7098
|
+
* const hash = sha256.create();
|
|
7099
|
+
* aoutput(new Uint8Array(hash.outputLen), hash);
|
|
7100
|
+
* ```
|
|
7101
|
+
*/
|
|
7102
|
+
function aoutput(out, instance) {
|
|
7103
|
+
abytes(out, void 0, "output");
|
|
7104
|
+
const min = instance.outputLen;
|
|
7105
|
+
if (!(out.length >= min)) throw new RangeError("\"output\" expected length >= " + min);
|
|
7106
|
+
}
|
|
7107
|
+
/**
|
|
7108
|
+
* Zeroizes typed arrays in place. Warning: JS provides no guarantees.
|
|
7109
|
+
* @param arrays - arrays to overwrite with zeros
|
|
7110
|
+
* @example
|
|
7111
|
+
* Zeroize sensitive buffers in place.
|
|
7112
|
+
* ```ts
|
|
7113
|
+
* clean(new Uint8Array([1, 2, 3]));
|
|
7114
|
+
* ```
|
|
7115
|
+
*/
|
|
7116
|
+
function clean$1(...arrays) {
|
|
7117
|
+
for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
|
|
7118
|
+
}
|
|
7119
|
+
/**
|
|
7120
|
+
* Creates a DataView for byte-level manipulation.
|
|
7121
|
+
* @param arr - source typed array
|
|
7122
|
+
* @returns DataView over the same buffer region.
|
|
7123
|
+
* @example
|
|
7124
|
+
* Create a DataView over an existing buffer.
|
|
7125
|
+
* ```ts
|
|
7126
|
+
* createView(new Uint8Array(4));
|
|
7127
|
+
* ```
|
|
7128
|
+
*/
|
|
7129
|
+
function createView(arr) {
|
|
7130
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
7131
|
+
}
|
|
7132
|
+
/**
|
|
7133
|
+
* Rotate-right operation for uint32 values.
|
|
7134
|
+
* @param word - source word
|
|
7135
|
+
* @param shift - shift amount in bits
|
|
7136
|
+
* @returns Rotated word.
|
|
7137
|
+
* @example
|
|
7138
|
+
* Rotate a 32-bit word to the right.
|
|
7139
|
+
* ```ts
|
|
7140
|
+
* rotr(0x12345678, 8);
|
|
7141
|
+
* ```
|
|
7142
|
+
*/
|
|
7143
|
+
function rotr(word, shift) {
|
|
7144
|
+
return word << 32 - shift | word >>> shift;
|
|
7145
|
+
}
|
|
7146
|
+
/**
|
|
7147
|
+
* Merges default options and passed options.
|
|
7148
|
+
* @param defaults - base option object
|
|
7149
|
+
* @param opts - user overrides
|
|
7150
|
+
* @param title - label included in thrown override errors
|
|
7151
|
+
* @returns Fresh merged option object with a null prototype.
|
|
7152
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7153
|
+
* @example
|
|
7154
|
+
* Merge user overrides onto default options.
|
|
7155
|
+
* ```ts
|
|
7156
|
+
* checkOpts({ dkLen: 32 }, { asyncTick: 10 });
|
|
7157
|
+
* ```
|
|
7158
|
+
*/
|
|
7159
|
+
function checkOpts(defaults, opts, title = "opts") {
|
|
7160
|
+
aopts(defaults, "defaults");
|
|
7161
|
+
if (opts !== void 0) aopts(opts, title);
|
|
7162
|
+
return Object.assign(Object.create(null), defaults, opts);
|
|
7163
|
+
}
|
|
7164
|
+
/**
|
|
7165
|
+
* Creates a callable hash function from a stateful class constructor.
|
|
7166
|
+
* @param hashCons - hash constructor or factory
|
|
7167
|
+
* @param info - optional metadata such as DER OID
|
|
7168
|
+
* @returns Frozen callable hash wrapper with `.create()`.
|
|
7169
|
+
* Wrapper construction eagerly calls `hashCons(undefined)` once to read
|
|
7170
|
+
* `outputLen` / `blockLen`, so constructor side effects happen at module
|
|
7171
|
+
* init time.
|
|
7172
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7173
|
+
* @example
|
|
7174
|
+
* Wrap a stateful hash constructor into a callable helper.
|
|
7175
|
+
* ```ts
|
|
7176
|
+
* import { createHasher } from '@noble/hashes/utils.js';
|
|
7177
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7178
|
+
* const wrapped = createHasher(sha256.create, { oid: sha256.oid });
|
|
7179
|
+
* wrapped(new Uint8Array([1]));
|
|
7180
|
+
* ```
|
|
7181
|
+
*/
|
|
7182
|
+
function createHasher(hashCons, info = {}) {
|
|
7183
|
+
if (typeof hashCons !== "function") throw new TypeError("\"hashCons\" expected function, got type=" + typeof hashCons);
|
|
7184
|
+
info = checkOpts({}, info, "info");
|
|
7185
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
7186
|
+
const tmp = hashCons(void 0);
|
|
7187
|
+
hashC.outputLen = tmp.outputLen;
|
|
7188
|
+
hashC.blockLen = tmp.blockLen;
|
|
7189
|
+
hashC.canXOF = tmp.canXOF;
|
|
7190
|
+
hashC.create = (opts) => hashCons(opts);
|
|
7191
|
+
Object.assign(hashC, info);
|
|
7192
|
+
return Object.freeze(hashC);
|
|
7193
|
+
}
|
|
7194
|
+
var atitle, aobject, aopts, oidNist;
|
|
7195
|
+
var init_utils = __esmMin((() => {
|
|
7196
|
+
atitle = (title) => title ? `"${title}" ` : "";
|
|
7197
|
+
aobject = (value, label) => {
|
|
7198
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
7199
|
+
};
|
|
7200
|
+
aopts = (value, label) => {
|
|
7201
|
+
aobject(value, label);
|
|
7202
|
+
const proto = Object.getPrototypeOf(value);
|
|
7203
|
+
if (proto !== Object.prototype && proto !== null) throw new TypeError(`"${label}" expected plain object`);
|
|
7204
|
+
if (Object.hasOwn(value, "__proto__")) throw new TypeError(`"${label}.__proto__" is not allowed`);
|
|
7205
|
+
};
|
|
7206
|
+
oidNist = (suffix) => ({ oid: Uint8Array.from([
|
|
7207
|
+
6,
|
|
7208
|
+
9,
|
|
7209
|
+
96,
|
|
7210
|
+
134,
|
|
7211
|
+
72,
|
|
7212
|
+
1,
|
|
7213
|
+
101,
|
|
7214
|
+
3,
|
|
7215
|
+
4,
|
|
7216
|
+
2,
|
|
7217
|
+
suffix
|
|
7218
|
+
]) });
|
|
7219
|
+
}));
|
|
7220
|
+
//#endregion
|
|
7221
|
+
//#region ../../node_modules/@noble/hashes/hmac.js
|
|
7222
|
+
var hmac_exports = /* @__PURE__ */ __exportAll({
|
|
7223
|
+
_HMAC: () => _HMAC,
|
|
7224
|
+
hmac: () => hmac
|
|
7225
|
+
});
|
|
7226
|
+
var _HMAC, hmac;
|
|
7227
|
+
var init_hmac = __esmMin((() => {
|
|
7228
|
+
init_utils();
|
|
7229
|
+
_HMAC = class {
|
|
7230
|
+
oHash;
|
|
7231
|
+
iHash;
|
|
7232
|
+
blockLen;
|
|
7233
|
+
outputLen;
|
|
7234
|
+
canXOF = false;
|
|
7235
|
+
finished = false;
|
|
7236
|
+
destroyed = false;
|
|
7237
|
+
constructor(hash, key) {
|
|
7238
|
+
ahash(hash);
|
|
7239
|
+
abytes(key, void 0, "key");
|
|
7240
|
+
this.iHash = hash.create();
|
|
7241
|
+
if (typeof this.iHash.update !== "function") throw new Error("expected Hash instance");
|
|
7242
|
+
this.blockLen = this.iHash.blockLen;
|
|
7243
|
+
this.outputLen = this.iHash.outputLen;
|
|
7244
|
+
const blockLen = this.blockLen;
|
|
7245
|
+
const pad = new Uint8Array(blockLen);
|
|
7246
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
7247
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 54;
|
|
7248
|
+
this.iHash.update(pad);
|
|
7249
|
+
this.oHash = hash.create();
|
|
7250
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
7251
|
+
this.oHash.update(pad);
|
|
7252
|
+
clean$1(pad);
|
|
7253
|
+
}
|
|
7254
|
+
update(buf) {
|
|
7255
|
+
aexists(this);
|
|
7256
|
+
this.iHash.update(buf);
|
|
7257
|
+
return this;
|
|
7258
|
+
}
|
|
7259
|
+
digestInto(out) {
|
|
7260
|
+
aexists(this);
|
|
7261
|
+
aoutput(out, this);
|
|
7262
|
+
this.finished = true;
|
|
7263
|
+
const buf = out.subarray(0, this.outputLen);
|
|
7264
|
+
this.iHash.digestInto(buf);
|
|
7265
|
+
this.oHash.update(buf);
|
|
7266
|
+
this.oHash.digestInto(buf);
|
|
7267
|
+
this.destroy();
|
|
7268
|
+
}
|
|
7269
|
+
digest() {
|
|
7270
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
7271
|
+
this.digestInto(out);
|
|
7272
|
+
return out;
|
|
7273
|
+
}
|
|
7274
|
+
_cloneInto(to) {
|
|
7275
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
7276
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen, canXOF } = this;
|
|
7277
|
+
to = to;
|
|
7278
|
+
to.finished = finished;
|
|
7279
|
+
to.destroyed = destroyed;
|
|
7280
|
+
to.blockLen = blockLen;
|
|
7281
|
+
to.outputLen = outputLen;
|
|
7282
|
+
to.canXOF = canXOF;
|
|
7283
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
7284
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
7285
|
+
return to;
|
|
7286
|
+
}
|
|
7287
|
+
clone() {
|
|
7288
|
+
return this._cloneInto();
|
|
7289
|
+
}
|
|
7290
|
+
destroy() {
|
|
7291
|
+
this.destroyed = true;
|
|
7292
|
+
this.oHash.destroy();
|
|
7293
|
+
this.iHash.destroy();
|
|
7294
|
+
}
|
|
7295
|
+
};
|
|
7296
|
+
hmac = /* @__PURE__ */ (() => {
|
|
7297
|
+
const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
|
|
7298
|
+
hmac_.create = (hash, key) => new _HMAC(hash, key);
|
|
7299
|
+
return hmac_;
|
|
7300
|
+
})();
|
|
7301
|
+
}));
|
|
7302
|
+
//#endregion
|
|
7303
|
+
//#region ../../node_modules/@noble/hashes/_u64.js
|
|
7304
|
+
function fromBig(n, le = false) {
|
|
7305
|
+
if (le) return {
|
|
7306
|
+
h: Number(n & U32_MASK64),
|
|
7307
|
+
l: Number(n >> _32n & U32_MASK64)
|
|
7308
|
+
};
|
|
7309
|
+
return {
|
|
7310
|
+
h: Number(n >> _32n & U32_MASK64) | 0,
|
|
7311
|
+
l: Number(n & U32_MASK64) | 0
|
|
7312
|
+
};
|
|
7313
|
+
}
|
|
7314
|
+
function split$1(lst, le = false) {
|
|
7315
|
+
const len = lst.length;
|
|
7316
|
+
let Ah = new Uint32Array(len);
|
|
7317
|
+
let Al = new Uint32Array(len);
|
|
7318
|
+
for (let i = 0; i < len; i++) {
|
|
7319
|
+
const { h, l } = fromBig(lst[i], le);
|
|
7320
|
+
[Ah[i], Al[i]] = [h, l];
|
|
7321
|
+
}
|
|
7322
|
+
return [Ah, Al];
|
|
7323
|
+
}
|
|
7324
|
+
function setU64FromNum(view, byteOffset, n, isLE) {
|
|
7325
|
+
const h = fromNumH(n);
|
|
7326
|
+
const l = fromNumL(n);
|
|
7327
|
+
view.setUint32(byteOffset, isLE ? l : h, isLE);
|
|
7328
|
+
view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
|
|
7329
|
+
}
|
|
7330
|
+
function add$1(Ah, Al, Bh, Bl) {
|
|
7331
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
7332
|
+
return {
|
|
7333
|
+
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
|
|
7334
|
+
l: l | 0
|
|
7335
|
+
};
|
|
7336
|
+
}
|
|
7337
|
+
var U32_MASK64, _32n, fromNumH, fromNumL, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, add3L, add3H, add4L, add4H, add5L, add5H;
|
|
7338
|
+
var init__u64 = __esmMin((() => {
|
|
7339
|
+
U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
|
7340
|
+
_32n = /* @__PURE__ */ BigInt(32);
|
|
7341
|
+
fromNumH = (n) => n / 2 ** 32 | 0;
|
|
7342
|
+
fromNumL = (n) => n >>> 0;
|
|
7343
|
+
shrSH = (h, _l, s) => h >>> s;
|
|
7344
|
+
shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
7345
|
+
rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
7346
|
+
rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
7347
|
+
rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
7348
|
+
rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
7349
|
+
add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
7350
|
+
add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
7351
|
+
add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
7352
|
+
add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
7353
|
+
add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
7354
|
+
add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
7355
|
+
}));
|
|
7356
|
+
//#endregion
|
|
7357
|
+
//#region ../../node_modules/@noble/hashes/_md.js
|
|
7358
|
+
/**
|
|
7359
|
+
* Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
|
|
7360
|
+
* Returns bits from `b` when `a` is set, otherwise from `c`.
|
|
7361
|
+
* The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
|
|
7362
|
+
* set the same bit.
|
|
7363
|
+
* @param a - selector word
|
|
7364
|
+
* @param b - word chosen when selector bit is set
|
|
7365
|
+
* @param c - word chosen when selector bit is clear
|
|
7366
|
+
* @returns Mixed 32-bit word.
|
|
7367
|
+
* @example
|
|
7368
|
+
* Combine three words with the shared 32-bit choice primitive.
|
|
7369
|
+
* ```ts
|
|
7370
|
+
* Chi(0xffffffff, 0x12345678, 0x87654321);
|
|
7371
|
+
* ```
|
|
7372
|
+
*/
|
|
7373
|
+
function Chi(a, b, c) {
|
|
7374
|
+
return a & b ^ ~a & c;
|
|
7375
|
+
}
|
|
7376
|
+
/**
|
|
7377
|
+
* Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
|
|
7378
|
+
* Returns bits shared by at least two inputs.
|
|
7379
|
+
* @param a - first input word
|
|
7380
|
+
* @param b - second input word
|
|
7381
|
+
* @param c - third input word
|
|
7382
|
+
* @returns Mixed 32-bit word.
|
|
7383
|
+
* @example
|
|
7384
|
+
* Combine three words with the shared 32-bit majority primitive.
|
|
7385
|
+
* ```ts
|
|
7386
|
+
* Maj(0xffffffff, 0x12345678, 0x87654321);
|
|
7387
|
+
* ```
|
|
7388
|
+
*/
|
|
7389
|
+
function Maj(a, b, c) {
|
|
7390
|
+
return a & b ^ a & c ^ b & c;
|
|
7391
|
+
}
|
|
7392
|
+
var HashMD, SHA256_IV, SHA224_IV, SHA384_IV, SHA512_IV;
|
|
7393
|
+
var init__md = __esmMin((() => {
|
|
7394
|
+
init__u64();
|
|
7395
|
+
init_utils();
|
|
7396
|
+
HashMD = class {
|
|
7397
|
+
blockLen;
|
|
7398
|
+
outputLen;
|
|
7399
|
+
canXOF = false;
|
|
7400
|
+
padOffset;
|
|
7401
|
+
isLE;
|
|
7402
|
+
buffer;
|
|
7403
|
+
view;
|
|
7404
|
+
finished = false;
|
|
7405
|
+
length = 0;
|
|
7406
|
+
pos = 0;
|
|
7407
|
+
destroyed = false;
|
|
7408
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
7409
|
+
this.blockLen = blockLen;
|
|
7410
|
+
this.outputLen = outputLen;
|
|
7411
|
+
this.padOffset = padOffset;
|
|
7412
|
+
this.isLE = isLE;
|
|
7413
|
+
this.buffer = new Uint8Array(blockLen);
|
|
7414
|
+
this.view = createView(this.buffer);
|
|
7415
|
+
}
|
|
7416
|
+
update(data) {
|
|
7417
|
+
aexists(this);
|
|
7418
|
+
abytes(data);
|
|
7419
|
+
const { view, buffer, blockLen } = this;
|
|
7420
|
+
const len = data.length;
|
|
7421
|
+
let processed = false;
|
|
7422
|
+
for (let pos = 0; pos < len;) {
|
|
7423
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
7424
|
+
if (take === blockLen) {
|
|
7425
|
+
const dataView = createView(data);
|
|
7426
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
7427
|
+
processed = true;
|
|
7428
|
+
continue;
|
|
7429
|
+
}
|
|
7430
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
7431
|
+
this.pos += take;
|
|
7432
|
+
pos += take;
|
|
7433
|
+
if (this.pos === blockLen) {
|
|
7434
|
+
this.process(view, 0);
|
|
7435
|
+
this.pos = 0;
|
|
7436
|
+
processed = true;
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
this.length += data.length;
|
|
7440
|
+
if (processed) this.roundClean();
|
|
7441
|
+
return this;
|
|
7442
|
+
}
|
|
7443
|
+
digestInto(out) {
|
|
7444
|
+
aexists(this);
|
|
7445
|
+
aoutput(out, this);
|
|
7446
|
+
this.finished = true;
|
|
7447
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
7448
|
+
let { pos } = this;
|
|
7449
|
+
buffer[pos++] = 128;
|
|
7450
|
+
buffer.fill(0, pos);
|
|
7451
|
+
if (this.padOffset > blockLen - pos) {
|
|
7452
|
+
this.process(view, 0);
|
|
7453
|
+
buffer.fill(0);
|
|
7454
|
+
}
|
|
7455
|
+
setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
|
|
7456
|
+
this.process(view, 0);
|
|
7457
|
+
this.roundClean();
|
|
7458
|
+
const oview = out === buffer ? view : createView(out);
|
|
7459
|
+
const len = this.outputLen;
|
|
7460
|
+
const outLen = len / 4;
|
|
7461
|
+
const state = this.get();
|
|
7462
|
+
if (len % 4 || outLen > state.length) throw new Error("invalid outputLen");
|
|
7463
|
+
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
7464
|
+
}
|
|
7465
|
+
digest() {
|
|
7466
|
+
const { buffer, outputLen } = this;
|
|
7467
|
+
this.digestInto(buffer);
|
|
7468
|
+
const res = buffer.slice(0, outputLen);
|
|
7469
|
+
this.destroy();
|
|
7470
|
+
return res;
|
|
7471
|
+
}
|
|
7472
|
+
_cloneIntoMeta(to) {
|
|
7473
|
+
const { buffer, length, finished, destroyed, pos } = this;
|
|
7474
|
+
to.destroyed = destroyed;
|
|
7475
|
+
to.finished = finished;
|
|
7476
|
+
to.length = length;
|
|
7477
|
+
to.pos = pos;
|
|
7478
|
+
if (pos) to.buffer.set(buffer);
|
|
7479
|
+
return to;
|
|
7480
|
+
}
|
|
7481
|
+
clone() {
|
|
7482
|
+
return this._cloneInto();
|
|
7483
|
+
}
|
|
7484
|
+
};
|
|
7485
|
+
SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
7486
|
+
1779033703,
|
|
7487
|
+
3144134277,
|
|
7488
|
+
1013904242,
|
|
7489
|
+
2773480762,
|
|
7490
|
+
1359893119,
|
|
7491
|
+
2600822924,
|
|
7492
|
+
528734635,
|
|
7493
|
+
1541459225
|
|
7494
|
+
]);
|
|
7495
|
+
SHA224_IV = /* @__PURE__ */ Uint32Array.from([
|
|
7496
|
+
3238371032,
|
|
7497
|
+
914150663,
|
|
7498
|
+
812702999,
|
|
7499
|
+
4144912697,
|
|
7500
|
+
4290775857,
|
|
7501
|
+
1750603025,
|
|
7502
|
+
1694076839,
|
|
7503
|
+
3204075428
|
|
7504
|
+
]);
|
|
7505
|
+
SHA384_IV = /* @__PURE__ */ Uint32Array.from([
|
|
7506
|
+
3418070365,
|
|
7507
|
+
3238371032,
|
|
7508
|
+
1654270250,
|
|
7509
|
+
914150663,
|
|
7510
|
+
2438529370,
|
|
7511
|
+
812702999,
|
|
7512
|
+
355462360,
|
|
7513
|
+
4144912697,
|
|
7514
|
+
1731405415,
|
|
7515
|
+
4290775857,
|
|
7516
|
+
2394180231,
|
|
7517
|
+
1750603025,
|
|
7518
|
+
3675008525,
|
|
7519
|
+
1694076839,
|
|
7520
|
+
1203062813,
|
|
7521
|
+
3204075428
|
|
7522
|
+
]);
|
|
7523
|
+
SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
7524
|
+
1779033703,
|
|
7525
|
+
4089235720,
|
|
7526
|
+
3144134277,
|
|
7527
|
+
2227873595,
|
|
7528
|
+
1013904242,
|
|
7529
|
+
4271175723,
|
|
7530
|
+
2773480762,
|
|
7531
|
+
1595750129,
|
|
7532
|
+
1359893119,
|
|
7533
|
+
2917565137,
|
|
7534
|
+
2600822924,
|
|
7535
|
+
725511199,
|
|
7536
|
+
528734635,
|
|
7537
|
+
4215389547,
|
|
7538
|
+
1541459225,
|
|
7539
|
+
327033209
|
|
7540
|
+
]);
|
|
7541
|
+
}));
|
|
7542
|
+
//#endregion
|
|
7543
|
+
//#region ../../node_modules/@noble/hashes/sha2.js
|
|
7544
|
+
var sha2_exports = /* @__PURE__ */ __exportAll({
|
|
7545
|
+
_SHA224: () => _SHA224,
|
|
7546
|
+
_SHA256: () => _SHA256,
|
|
7547
|
+
_SHA384: () => _SHA384,
|
|
7548
|
+
_SHA512: () => _SHA512,
|
|
7549
|
+
_SHA512_224: () => _SHA512_224,
|
|
7550
|
+
_SHA512_256: () => _SHA512_256,
|
|
7551
|
+
sha224: () => sha224,
|
|
7552
|
+
sha256: () => sha256,
|
|
7553
|
+
sha384: () => sha384,
|
|
7554
|
+
sha512: () => sha512,
|
|
7555
|
+
sha512_224: () => sha512_224,
|
|
7556
|
+
sha512_256: () => sha512_256
|
|
7557
|
+
});
|
|
7558
|
+
var SHA256_K, SHA256_W, SHA2_32B, _SHA256, _SHA224, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA2_64B, _SHA512, _SHA384, T224_IV, T256_IV, _SHA512_224, _SHA512_256, sha256, sha224, sha512, sha384, sha512_256, sha512_224;
|
|
7559
|
+
var init_sha2 = __esmMin((() => {
|
|
7560
|
+
init__md();
|
|
7561
|
+
init__u64();
|
|
7562
|
+
init_utils();
|
|
7563
|
+
SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
7564
|
+
1116352408,
|
|
7565
|
+
1899447441,
|
|
7566
|
+
3049323471,
|
|
7567
|
+
3921009573,
|
|
7568
|
+
961987163,
|
|
7569
|
+
1508970993,
|
|
7570
|
+
2453635748,
|
|
7571
|
+
2870763221,
|
|
7572
|
+
3624381080,
|
|
7573
|
+
310598401,
|
|
7574
|
+
607225278,
|
|
7575
|
+
1426881987,
|
|
7576
|
+
1925078388,
|
|
7577
|
+
2162078206,
|
|
7578
|
+
2614888103,
|
|
7579
|
+
3248222580,
|
|
7580
|
+
3835390401,
|
|
7581
|
+
4022224774,
|
|
7582
|
+
264347078,
|
|
7583
|
+
604807628,
|
|
7584
|
+
770255983,
|
|
7585
|
+
1249150122,
|
|
7586
|
+
1555081692,
|
|
7587
|
+
1996064986,
|
|
7588
|
+
2554220882,
|
|
7589
|
+
2821834349,
|
|
7590
|
+
2952996808,
|
|
7591
|
+
3210313671,
|
|
7592
|
+
3336571891,
|
|
7593
|
+
3584528711,
|
|
7594
|
+
113926993,
|
|
7595
|
+
338241895,
|
|
7596
|
+
666307205,
|
|
7597
|
+
773529912,
|
|
7598
|
+
1294757372,
|
|
7599
|
+
1396182291,
|
|
7600
|
+
1695183700,
|
|
7601
|
+
1986661051,
|
|
7602
|
+
2177026350,
|
|
7603
|
+
2456956037,
|
|
7604
|
+
2730485921,
|
|
7605
|
+
2820302411,
|
|
7606
|
+
3259730800,
|
|
7607
|
+
3345764771,
|
|
7608
|
+
3516065817,
|
|
7609
|
+
3600352804,
|
|
7610
|
+
4094571909,
|
|
7611
|
+
275423344,
|
|
7612
|
+
430227734,
|
|
7613
|
+
506948616,
|
|
7614
|
+
659060556,
|
|
7615
|
+
883997877,
|
|
7616
|
+
958139571,
|
|
7617
|
+
1322822218,
|
|
7618
|
+
1537002063,
|
|
7619
|
+
1747873779,
|
|
7620
|
+
1955562222,
|
|
7621
|
+
2024104815,
|
|
7622
|
+
2227730452,
|
|
7623
|
+
2361852424,
|
|
7624
|
+
2428436474,
|
|
7625
|
+
2756734187,
|
|
7626
|
+
3204031479,
|
|
7627
|
+
3329325298
|
|
7628
|
+
]);
|
|
7629
|
+
SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
7630
|
+
SHA2_32B = class extends HashMD {
|
|
7631
|
+
A = 0;
|
|
7632
|
+
B = 0;
|
|
7633
|
+
C = 0;
|
|
7634
|
+
D = 0;
|
|
7635
|
+
E = 0;
|
|
7636
|
+
F = 0;
|
|
7637
|
+
G = 0;
|
|
7638
|
+
H = 0;
|
|
7639
|
+
constructor(outputLen, IV) {
|
|
7640
|
+
super(64, outputLen, 8, false);
|
|
7641
|
+
this.A = IV[0] | 0;
|
|
7642
|
+
this.B = IV[1] | 0;
|
|
7643
|
+
this.C = IV[2] | 0;
|
|
7644
|
+
this.D = IV[3] | 0;
|
|
7645
|
+
this.E = IV[4] | 0;
|
|
7646
|
+
this.F = IV[5] | 0;
|
|
7647
|
+
this.G = IV[6] | 0;
|
|
7648
|
+
this.H = IV[7] | 0;
|
|
7649
|
+
}
|
|
7650
|
+
get() {
|
|
7651
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
7652
|
+
return [
|
|
7653
|
+
A,
|
|
7654
|
+
B,
|
|
7655
|
+
C,
|
|
7656
|
+
D,
|
|
7657
|
+
E,
|
|
7658
|
+
F,
|
|
7659
|
+
G,
|
|
7660
|
+
H
|
|
7661
|
+
];
|
|
7662
|
+
}
|
|
7663
|
+
set(A, B, C, D, E, F, G, H) {
|
|
7664
|
+
this.A = A | 0;
|
|
7665
|
+
this.B = B | 0;
|
|
7666
|
+
this.C = C | 0;
|
|
7667
|
+
this.D = D | 0;
|
|
7668
|
+
this.E = E | 0;
|
|
7669
|
+
this.F = F | 0;
|
|
7670
|
+
this.G = G | 0;
|
|
7671
|
+
this.H = H | 0;
|
|
7672
|
+
}
|
|
7673
|
+
_cloneInto(to) {
|
|
7674
|
+
(to ||= new this.constructor()).set(...this.get());
|
|
7675
|
+
return this._cloneIntoMeta(to);
|
|
7676
|
+
}
|
|
7677
|
+
process(view, offset) {
|
|
7678
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
|
|
7679
|
+
for (let i = 16; i < 64; i++) {
|
|
7680
|
+
const W15 = SHA256_W[i - 15];
|
|
7681
|
+
const W2 = SHA256_W[i - 2];
|
|
7682
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
7683
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
7684
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
7685
|
+
}
|
|
7686
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
7687
|
+
for (let i = 0; i < 64; i++) {
|
|
7688
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
7689
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
7690
|
+
const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
|
|
7691
|
+
H = G;
|
|
7692
|
+
G = F;
|
|
7693
|
+
F = E;
|
|
7694
|
+
E = D + T1 | 0;
|
|
7695
|
+
D = C;
|
|
7696
|
+
C = B;
|
|
7697
|
+
B = A;
|
|
7698
|
+
A = T1 + T2 | 0;
|
|
7699
|
+
}
|
|
7700
|
+
A = A + this.A | 0;
|
|
7701
|
+
B = B + this.B | 0;
|
|
7702
|
+
C = C + this.C | 0;
|
|
7703
|
+
D = D + this.D | 0;
|
|
7704
|
+
E = E + this.E | 0;
|
|
7705
|
+
F = F + this.F | 0;
|
|
7706
|
+
G = G + this.G | 0;
|
|
7707
|
+
H = H + this.H | 0;
|
|
7708
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
7709
|
+
}
|
|
7710
|
+
roundClean() {
|
|
7711
|
+
clean$1(SHA256_W);
|
|
7712
|
+
}
|
|
7713
|
+
destroy() {
|
|
7714
|
+
this.destroyed = true;
|
|
7715
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
7716
|
+
clean$1(this.buffer);
|
|
7717
|
+
}
|
|
7718
|
+
};
|
|
7719
|
+
_SHA256 = class extends SHA2_32B {
|
|
7720
|
+
constructor() {
|
|
7721
|
+
super(32, SHA256_IV);
|
|
7722
|
+
}
|
|
7723
|
+
};
|
|
7724
|
+
_SHA224 = class extends SHA2_32B {
|
|
7725
|
+
constructor() {
|
|
7726
|
+
super(28, SHA224_IV);
|
|
7727
|
+
}
|
|
7728
|
+
};
|
|
7729
|
+
K512 = /* @__PURE__ */ (() => split$1([
|
|
7730
|
+
"0x428a2f98d728ae22",
|
|
7731
|
+
"0x7137449123ef65cd",
|
|
7732
|
+
"0xb5c0fbcfec4d3b2f",
|
|
7733
|
+
"0xe9b5dba58189dbbc",
|
|
7734
|
+
"0x3956c25bf348b538",
|
|
7735
|
+
"0x59f111f1b605d019",
|
|
7736
|
+
"0x923f82a4af194f9b",
|
|
7737
|
+
"0xab1c5ed5da6d8118",
|
|
7738
|
+
"0xd807aa98a3030242",
|
|
7739
|
+
"0x12835b0145706fbe",
|
|
7740
|
+
"0x243185be4ee4b28c",
|
|
7741
|
+
"0x550c7dc3d5ffb4e2",
|
|
7742
|
+
"0x72be5d74f27b896f",
|
|
7743
|
+
"0x80deb1fe3b1696b1",
|
|
7744
|
+
"0x9bdc06a725c71235",
|
|
7745
|
+
"0xc19bf174cf692694",
|
|
7746
|
+
"0xe49b69c19ef14ad2",
|
|
7747
|
+
"0xefbe4786384f25e3",
|
|
7748
|
+
"0x0fc19dc68b8cd5b5",
|
|
7749
|
+
"0x240ca1cc77ac9c65",
|
|
7750
|
+
"0x2de92c6f592b0275",
|
|
7751
|
+
"0x4a7484aa6ea6e483",
|
|
7752
|
+
"0x5cb0a9dcbd41fbd4",
|
|
7753
|
+
"0x76f988da831153b5",
|
|
7754
|
+
"0x983e5152ee66dfab",
|
|
7755
|
+
"0xa831c66d2db43210",
|
|
7756
|
+
"0xb00327c898fb213f",
|
|
7757
|
+
"0xbf597fc7beef0ee4",
|
|
7758
|
+
"0xc6e00bf33da88fc2",
|
|
7759
|
+
"0xd5a79147930aa725",
|
|
7760
|
+
"0x06ca6351e003826f",
|
|
7761
|
+
"0x142929670a0e6e70",
|
|
7762
|
+
"0x27b70a8546d22ffc",
|
|
7763
|
+
"0x2e1b21385c26c926",
|
|
7764
|
+
"0x4d2c6dfc5ac42aed",
|
|
7765
|
+
"0x53380d139d95b3df",
|
|
7766
|
+
"0x650a73548baf63de",
|
|
7767
|
+
"0x766a0abb3c77b2a8",
|
|
7768
|
+
"0x81c2c92e47edaee6",
|
|
7769
|
+
"0x92722c851482353b",
|
|
7770
|
+
"0xa2bfe8a14cf10364",
|
|
7771
|
+
"0xa81a664bbc423001",
|
|
7772
|
+
"0xc24b8b70d0f89791",
|
|
7773
|
+
"0xc76c51a30654be30",
|
|
7774
|
+
"0xd192e819d6ef5218",
|
|
7775
|
+
"0xd69906245565a910",
|
|
7776
|
+
"0xf40e35855771202a",
|
|
7777
|
+
"0x106aa07032bbd1b8",
|
|
7778
|
+
"0x19a4c116b8d2d0c8",
|
|
7779
|
+
"0x1e376c085141ab53",
|
|
7780
|
+
"0x2748774cdf8eeb99",
|
|
7781
|
+
"0x34b0bcb5e19b48a8",
|
|
7782
|
+
"0x391c0cb3c5c95a63",
|
|
7783
|
+
"0x4ed8aa4ae3418acb",
|
|
7784
|
+
"0x5b9cca4f7763e373",
|
|
7785
|
+
"0x682e6ff3d6b2b8a3",
|
|
7786
|
+
"0x748f82ee5defb2fc",
|
|
7787
|
+
"0x78a5636f43172f60",
|
|
7788
|
+
"0x84c87814a1f0ab72",
|
|
7789
|
+
"0x8cc702081a6439ec",
|
|
7790
|
+
"0x90befffa23631e28",
|
|
7791
|
+
"0xa4506cebde82bde9",
|
|
7792
|
+
"0xbef9a3f7b2c67915",
|
|
7793
|
+
"0xc67178f2e372532b",
|
|
7794
|
+
"0xca273eceea26619c",
|
|
7795
|
+
"0xd186b8c721c0c207",
|
|
7796
|
+
"0xeada7dd6cde0eb1e",
|
|
7797
|
+
"0xf57d4f7fee6ed178",
|
|
7798
|
+
"0x06f067aa72176fba",
|
|
7799
|
+
"0x0a637dc5a2c898a6",
|
|
7800
|
+
"0x113f9804bef90dae",
|
|
7801
|
+
"0x1b710b35131c471b",
|
|
7802
|
+
"0x28db77f523047d84",
|
|
7803
|
+
"0x32caab7b40c72493",
|
|
7804
|
+
"0x3c9ebe0a15c9bebc",
|
|
7805
|
+
"0x431d67c49c100d4c",
|
|
7806
|
+
"0x4cc5d4becb3e42b6",
|
|
7807
|
+
"0x597f299cfc657e2a",
|
|
7808
|
+
"0x5fcb6fab3ad6faec",
|
|
7809
|
+
"0x6c44198c4a475817"
|
|
7810
|
+
].map((n) => BigInt(n))))();
|
|
7811
|
+
SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
|
|
7812
|
+
SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
7813
|
+
SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
7814
|
+
SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
7815
|
+
SHA2_64B = class extends HashMD {
|
|
7816
|
+
Ah = 0;
|
|
7817
|
+
Al = 0;
|
|
7818
|
+
Bh = 0;
|
|
7819
|
+
Bl = 0;
|
|
7820
|
+
Ch = 0;
|
|
7821
|
+
Cl = 0;
|
|
7822
|
+
Dh = 0;
|
|
7823
|
+
Dl = 0;
|
|
7824
|
+
Eh = 0;
|
|
7825
|
+
El = 0;
|
|
7826
|
+
Fh = 0;
|
|
7827
|
+
Fl = 0;
|
|
7828
|
+
Gh = 0;
|
|
7829
|
+
Gl = 0;
|
|
7830
|
+
Hh = 0;
|
|
7831
|
+
Hl = 0;
|
|
7832
|
+
constructor(outputLen, IV) {
|
|
7833
|
+
super(128, outputLen, 16, false);
|
|
7834
|
+
this.Ah = IV[0] | 0;
|
|
7835
|
+
this.Al = IV[1] | 0;
|
|
7836
|
+
this.Bh = IV[2] | 0;
|
|
7837
|
+
this.Bl = IV[3] | 0;
|
|
7838
|
+
this.Ch = IV[4] | 0;
|
|
7839
|
+
this.Cl = IV[5] | 0;
|
|
7840
|
+
this.Dh = IV[6] | 0;
|
|
7841
|
+
this.Dl = IV[7] | 0;
|
|
7842
|
+
this.Eh = IV[8] | 0;
|
|
7843
|
+
this.El = IV[9] | 0;
|
|
7844
|
+
this.Fh = IV[10] | 0;
|
|
7845
|
+
this.Fl = IV[11] | 0;
|
|
7846
|
+
this.Gh = IV[12] | 0;
|
|
7847
|
+
this.Gl = IV[13] | 0;
|
|
7848
|
+
this.Hh = IV[14] | 0;
|
|
7849
|
+
this.Hl = IV[15] | 0;
|
|
7850
|
+
}
|
|
7851
|
+
get() {
|
|
7852
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
7853
|
+
return [
|
|
7854
|
+
Ah,
|
|
7855
|
+
Al,
|
|
7856
|
+
Bh,
|
|
7857
|
+
Bl,
|
|
7858
|
+
Ch,
|
|
7859
|
+
Cl,
|
|
7860
|
+
Dh,
|
|
7861
|
+
Dl,
|
|
7862
|
+
Eh,
|
|
7863
|
+
El,
|
|
7864
|
+
Fh,
|
|
7865
|
+
Fl,
|
|
7866
|
+
Gh,
|
|
7867
|
+
Gl,
|
|
7868
|
+
Hh,
|
|
7869
|
+
Hl
|
|
7870
|
+
];
|
|
7871
|
+
}
|
|
7872
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
7873
|
+
this.Ah = Ah | 0;
|
|
7874
|
+
this.Al = Al | 0;
|
|
7875
|
+
this.Bh = Bh | 0;
|
|
7876
|
+
this.Bl = Bl | 0;
|
|
7877
|
+
this.Ch = Ch | 0;
|
|
7878
|
+
this.Cl = Cl | 0;
|
|
7879
|
+
this.Dh = Dh | 0;
|
|
7880
|
+
this.Dl = Dl | 0;
|
|
7881
|
+
this.Eh = Eh | 0;
|
|
7882
|
+
this.El = El | 0;
|
|
7883
|
+
this.Fh = Fh | 0;
|
|
7884
|
+
this.Fl = Fl | 0;
|
|
7885
|
+
this.Gh = Gh | 0;
|
|
7886
|
+
this.Gl = Gl | 0;
|
|
7887
|
+
this.Hh = Hh | 0;
|
|
7888
|
+
this.Hl = Hl | 0;
|
|
7889
|
+
}
|
|
7890
|
+
_cloneInto(to) {
|
|
7891
|
+
(to ||= new this.constructor()).set(...this.get());
|
|
7892
|
+
return this._cloneIntoMeta(to);
|
|
7893
|
+
}
|
|
7894
|
+
process(view, offset) {
|
|
7895
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
7896
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
7897
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
7898
|
+
}
|
|
7899
|
+
for (let i = 16; i < 80; i++) {
|
|
7900
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
7901
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
7902
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
7903
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
7904
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
7905
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
7906
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
7907
|
+
const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
|
|
7908
|
+
const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
7909
|
+
const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
7910
|
+
SHA512_W_H[i] = SUMh | 0;
|
|
7911
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
7912
|
+
}
|
|
7913
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
7914
|
+
for (let i = 0; i < 80; i++) {
|
|
7915
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
7916
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
7917
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
7918
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
7919
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
7920
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
7921
|
+
const T1l = T1ll | 0;
|
|
7922
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
7923
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
7924
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
7925
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
7926
|
+
Hh = Gh | 0;
|
|
7927
|
+
Hl = Gl | 0;
|
|
7928
|
+
Gh = Fh | 0;
|
|
7929
|
+
Gl = Fl | 0;
|
|
7930
|
+
Fh = Eh | 0;
|
|
7931
|
+
Fl = El | 0;
|
|
7932
|
+
({h: Eh, l: El} = add$1(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
7933
|
+
Dh = Ch | 0;
|
|
7934
|
+
Dl = Cl | 0;
|
|
7935
|
+
Ch = Bh | 0;
|
|
7936
|
+
Cl = Bl | 0;
|
|
7937
|
+
Bh = Ah | 0;
|
|
7938
|
+
Bl = Al | 0;
|
|
7939
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
7940
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
7941
|
+
Al = All | 0;
|
|
7942
|
+
}
|
|
7943
|
+
({h: Ah, l: Al} = add$1(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
7944
|
+
({h: Bh, l: Bl} = add$1(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
7945
|
+
({h: Ch, l: Cl} = add$1(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
7946
|
+
({h: Dh, l: Dl} = add$1(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
7947
|
+
({h: Eh, l: El} = add$1(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
7948
|
+
({h: Fh, l: Fl} = add$1(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
7949
|
+
({h: Gh, l: Gl} = add$1(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
7950
|
+
({h: Hh, l: Hl} = add$1(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
7951
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
7952
|
+
}
|
|
7953
|
+
roundClean() {
|
|
7954
|
+
clean$1(SHA512_W_H, SHA512_W_L);
|
|
7955
|
+
}
|
|
7956
|
+
destroy() {
|
|
7957
|
+
this.destroyed = true;
|
|
7958
|
+
clean$1(this.buffer);
|
|
7959
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
7960
|
+
}
|
|
7961
|
+
};
|
|
7962
|
+
_SHA512 = class extends SHA2_64B {
|
|
7963
|
+
constructor() {
|
|
7964
|
+
super(64, SHA512_IV);
|
|
7965
|
+
}
|
|
7966
|
+
};
|
|
7967
|
+
_SHA384 = class extends SHA2_64B {
|
|
7968
|
+
constructor() {
|
|
7969
|
+
super(48, SHA384_IV);
|
|
7970
|
+
}
|
|
7971
|
+
};
|
|
7972
|
+
T224_IV = /* @__PURE__ */ Uint32Array.from([
|
|
7973
|
+
2352822216,
|
|
7974
|
+
424955298,
|
|
7975
|
+
1944164710,
|
|
7976
|
+
2312950998,
|
|
7977
|
+
502970286,
|
|
7978
|
+
855612546,
|
|
7979
|
+
1738396948,
|
|
7980
|
+
1479516111,
|
|
7981
|
+
258812777,
|
|
7982
|
+
2077511080,
|
|
7983
|
+
2011393907,
|
|
7984
|
+
79989058,
|
|
7985
|
+
1067287976,
|
|
7986
|
+
1780299464,
|
|
7987
|
+
286451373,
|
|
7988
|
+
2446758561
|
|
7989
|
+
]);
|
|
7990
|
+
T256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
7991
|
+
573645204,
|
|
7992
|
+
4230739756,
|
|
7993
|
+
2673172387,
|
|
7994
|
+
3360449730,
|
|
7995
|
+
596883563,
|
|
7996
|
+
1867755857,
|
|
7997
|
+
2520282905,
|
|
7998
|
+
1497426621,
|
|
7999
|
+
2519219938,
|
|
8000
|
+
2827943907,
|
|
8001
|
+
3193839141,
|
|
8002
|
+
1401305490,
|
|
8003
|
+
721525244,
|
|
8004
|
+
746961066,
|
|
8005
|
+
246885852,
|
|
8006
|
+
2177182882
|
|
8007
|
+
]);
|
|
8008
|
+
_SHA512_224 = class extends SHA2_64B {
|
|
8009
|
+
constructor() {
|
|
8010
|
+
super(28, T224_IV);
|
|
8011
|
+
}
|
|
8012
|
+
};
|
|
8013
|
+
_SHA512_256 = class extends SHA2_64B {
|
|
8014
|
+
constructor() {
|
|
8015
|
+
super(32, T256_IV);
|
|
8016
|
+
}
|
|
8017
|
+
};
|
|
8018
|
+
sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), /* @__PURE__ */ oidNist(1));
|
|
8019
|
+
sha224 = /* @__PURE__ */ createHasher(() => new _SHA224(), /* @__PURE__ */ oidNist(4));
|
|
8020
|
+
sha512 = /* @__PURE__ */ createHasher(() => new _SHA512(), /* @__PURE__ */ oidNist(3));
|
|
8021
|
+
sha384 = /* @__PURE__ */ createHasher(() => new _SHA384(), /* @__PURE__ */ oidNist(2));
|
|
8022
|
+
sha512_256 = /* @__PURE__ */ createHasher(() => new _SHA512_256(), /* @__PURE__ */ oidNist(6));
|
|
8023
|
+
sha512_224 = /* @__PURE__ */ createHasher(() => new _SHA512_224(), /* @__PURE__ */ oidNist(5));
|
|
8024
|
+
}));
|
|
8025
|
+
//#endregion
|
|
6358
8026
|
//#region ../../node_modules/bip39-mnemonic/wordlist/lookup.json
|
|
6359
8027
|
var lookup_exports = /* @__PURE__ */ __exportAll({
|
|
6360
8028
|
abacate: () => abacate,
|
|
@@ -75884,7 +77552,7 @@ var require_wordlist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
75884
77552
|
//#region ../../node_modules/bip39-mnemonic/index.js
|
|
75885
77553
|
var require_bip39_mnemonic = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
75886
77554
|
var sodium = require_sodium_universal();
|
|
75887
|
-
var b4a
|
|
77555
|
+
var b4a = require_browser();
|
|
75888
77556
|
var assert = require_nanoassert();
|
|
75889
77557
|
var { detectLanguage, loadWordlist } = require_wordlist();
|
|
75890
77558
|
module.exports = {
|
|
@@ -75924,10 +77592,10 @@ var require_bip39_mnemonic = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
75924
77592
|
}
|
|
75925
77593
|
const bits = words.length * 11;
|
|
75926
77594
|
const len = bits * 32 / 33 >> 3;
|
|
75927
|
-
const extended = b4a
|
|
77595
|
+
const extended = b4a.alloc(Math.ceil(bits / 8));
|
|
75928
77596
|
const entropy = extended.subarray(0, len);
|
|
75929
77597
|
uint11Writer(extended, indexes);
|
|
75930
|
-
if (!b4a
|
|
77598
|
+
if (!b4a.equals(extended, computeCheckSum(entropy))) throw new Error("Invalid checksum");
|
|
75931
77599
|
return entropy;
|
|
75932
77600
|
}
|
|
75933
77601
|
function normalizeMnemonic(mnemonic) {
|
|
@@ -75936,9 +77604,9 @@ var require_bip39_mnemonic = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
75936
77604
|
async function mnemonicToSeed(mnemonic, passphrase = "") {
|
|
75937
77605
|
mnemonic = normalizeMnemonic(mnemonic);
|
|
75938
77606
|
if (!validateMnemonic(mnemonic)) throw new Error("Invalid mnemonic");
|
|
75939
|
-
const input = b4a
|
|
75940
|
-
const salt = b4a
|
|
75941
|
-
const output = b4a
|
|
77607
|
+
const input = b4a.from(mnemonic);
|
|
77608
|
+
const salt = b4a.from("mnemonic" + passphrase);
|
|
77609
|
+
const output = b4a.alloc(64);
|
|
75942
77610
|
if (typeof sodium.extension_pbkdf2_sha512_async !== "function") {
|
|
75943
77611
|
const key = await globalThis.crypto.subtle.importKey("raw", input, "PBKDF2", false, ["deriveBits"]);
|
|
75944
77612
|
const bits = await globalThis.crypto.subtle.deriveBits({
|
|
@@ -75963,7 +77631,7 @@ var require_bip39_mnemonic = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
75963
77631
|
}
|
|
75964
77632
|
return true;
|
|
75965
77633
|
}
|
|
75966
|
-
function sha256(data, output = b4a
|
|
77634
|
+
function sha256(data, output = b4a.alloc(32)) {
|
|
75967
77635
|
sodium.crypto_hash_sha256(output, data);
|
|
75968
77636
|
return output;
|
|
75969
77637
|
}
|
|
@@ -75972,14 +77640,14 @@ var require_bip39_mnemonic = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
75972
77640
|
const len = seed.byteLength;
|
|
75973
77641
|
const cklen = len >> 2;
|
|
75974
77642
|
const total = len + Math.ceil(cklen / 8);
|
|
75975
|
-
const output = b4a
|
|
77643
|
+
const output = b4a.alloc(len + 32);
|
|
75976
77644
|
output.set(seed);
|
|
75977
77645
|
sha256(output.subarray(0, len), output.subarray(len));
|
|
75978
77646
|
output[total - 1] &= 255 ^ 255 >> cklen;
|
|
75979
77647
|
return output.subarray(0, total);
|
|
75980
77648
|
}
|
|
75981
77649
|
function generateEntropy(length = 32) {
|
|
75982
|
-
const seed = b4a
|
|
77650
|
+
const seed = b4a.alloc(length);
|
|
75983
77651
|
sodium.randombytes_buf(seed);
|
|
75984
77652
|
return seed;
|
|
75985
77653
|
}
|
|
@@ -76034,21 +77702,21 @@ var require_bip39_mnemonic = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
76034
77702
|
//#region ../../node_modules/keet-identity-key/lib/crypto.js
|
|
76035
77703
|
var require_crypto = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
76036
77704
|
var sodium = require_sodium_universal();
|
|
76037
|
-
var b4a
|
|
77705
|
+
var b4a = require_browser();
|
|
76038
77706
|
module.exports = {
|
|
76039
77707
|
sign,
|
|
76040
77708
|
verify,
|
|
76041
77709
|
hash: blake2b
|
|
76042
77710
|
};
|
|
76043
77711
|
function sign(signable, keyPair) {
|
|
76044
|
-
const signature = b4a
|
|
77712
|
+
const signature = b4a.alloc(sodium.crypto_sign_BYTES);
|
|
76045
77713
|
sodium.crypto_sign_detached(signature, signable, keyPair.secretKey);
|
|
76046
77714
|
return signature;
|
|
76047
77715
|
}
|
|
76048
77716
|
function verify(signable, signature, publicKey) {
|
|
76049
77717
|
return sodium.crypto_sign_verify_detached(signature, signable, publicKey);
|
|
76050
77718
|
}
|
|
76051
|
-
function blake2b(data, output = b4a
|
|
77719
|
+
function blake2b(data, output = b4a.alloc(32)) {
|
|
76052
77720
|
sodium.crypto_generichash(output, data);
|
|
76053
77721
|
return output;
|
|
76054
77722
|
}
|
|
@@ -76059,10 +77727,10 @@ var require_keychain = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76059
77727
|
var sodium = require_sodium_universal();
|
|
76060
77728
|
var c = require_compact_encoding();
|
|
76061
77729
|
var assert = require_nanoassert();
|
|
76062
|
-
var b4a
|
|
77730
|
+
var b4a = require_browser();
|
|
76063
77731
|
var { HMAC: SodiumHMAC } = require_sodium_hmac();
|
|
76064
|
-
var { hmac } =
|
|
76065
|
-
var { sha512 } =
|
|
77732
|
+
var { hmac } = (init_hmac(), __toCommonJS(hmac_exports));
|
|
77733
|
+
var { sha512 } = (init_sha2(), __toCommonJS(sha2_exports));
|
|
76066
77734
|
var HMAC = typeof sodium.crypto_hash_sha512_init === "function" ? SodiumHMAC : { sha512(data, key, output) {
|
|
76067
77735
|
const digest = hmac(sha512, key, data);
|
|
76068
77736
|
output.set(digest);
|
|
@@ -76071,17 +77739,17 @@ var require_keychain = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76071
77739
|
} };
|
|
76072
77740
|
var bip39 = require_bip39_mnemonic();
|
|
76073
77741
|
var { sign } = require_crypto();
|
|
76074
|
-
var MASTER_CHAIN_CODE = b4a
|
|
76075
|
-
var MASTER_SYMMETRIC_CODE = b4a
|
|
77742
|
+
var MASTER_CHAIN_CODE = b4a.from("ed25519 seed");
|
|
77743
|
+
var MASTER_SYMMETRIC_CODE = b4a.from("Symmetric key seed");
|
|
76076
77744
|
var HARDENED_OFFSET = 2147483648;
|
|
76077
77745
|
module.exports = class KeyChain {
|
|
76078
77746
|
constructor(seed) {
|
|
76079
77747
|
this.seed = seed;
|
|
76080
|
-
this._buffer = b4a
|
|
77748
|
+
this._buffer = b4a.alloc(64);
|
|
76081
77749
|
this.chainKey = this._buffer.subarray(0, 32);
|
|
76082
77750
|
this.chainCode = this._buffer.subarray(32);
|
|
76083
|
-
this.publicKey = b4a
|
|
76084
|
-
this.secretKey = b4a
|
|
77751
|
+
this.publicKey = b4a.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
|
|
77752
|
+
this.secretKey = b4a.alloc(sodium.crypto_sign_SECRETKEYBYTES);
|
|
76085
77753
|
this._initialise();
|
|
76086
77754
|
}
|
|
76087
77755
|
static generateMnemonic() {
|
|
@@ -76098,13 +77766,13 @@ var require_keychain = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76098
77766
|
return key.get(path);
|
|
76099
77767
|
}
|
|
76100
77768
|
getSymmetricKey(path) {
|
|
76101
|
-
const buffer = b4a
|
|
77769
|
+
const buffer = b4a.alloc(64);
|
|
76102
77770
|
const chainKey = buffer.subarray(0, 32);
|
|
76103
77771
|
const key = buffer.subarray(32);
|
|
76104
77772
|
HMAC.sha512(this.seed, MASTER_SYMMETRIC_CODE, buffer);
|
|
76105
77773
|
for (const step of path) {
|
|
76106
|
-
const label = b4a
|
|
76107
|
-
b4a
|
|
77774
|
+
const label = b4a.alloc(step.length + 1);
|
|
77775
|
+
b4a.write(label, step, 1, "utf8");
|
|
76108
77776
|
HMAC.sha512(label, chainKey, buffer);
|
|
76109
77777
|
}
|
|
76110
77778
|
return key;
|
|
@@ -76128,7 +77796,7 @@ var require_keychain = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76128
77796
|
return sign(signable, this);
|
|
76129
77797
|
}
|
|
76130
77798
|
derive(path) {
|
|
76131
|
-
const buffer = b4a
|
|
77799
|
+
const buffer = b4a.from(this._buffer);
|
|
76132
77800
|
const chainKey = buffer.subarray(0, 32);
|
|
76133
77801
|
const chainCode = buffer.subarray(32);
|
|
76134
77802
|
for (const step of path) {
|
|
@@ -76140,8 +77808,8 @@ var require_keychain = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76140
77808
|
};
|
|
76141
77809
|
function createKeyPair(seed) {
|
|
76142
77810
|
if (!seed) throw new Error("No seed provided");
|
|
76143
|
-
const publicKey = b4a
|
|
76144
|
-
const secretKey = b4a
|
|
77811
|
+
const publicKey = b4a.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
|
|
77812
|
+
const secretKey = b4a.alloc(sodium.crypto_sign_SECRETKEYBYTES);
|
|
76145
77813
|
sodium.crypto_sign_seed_keypair(publicKey, secretKey, seed);
|
|
76146
77814
|
return {
|
|
76147
77815
|
publicKey,
|
|
@@ -76150,13 +77818,13 @@ var require_keychain = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76150
77818
|
}
|
|
76151
77819
|
function encodeDerivationData(key, step) {
|
|
76152
77820
|
const state = {
|
|
76153
|
-
buffer: b4a
|
|
77821
|
+
buffer: b4a.alloc(37),
|
|
76154
77822
|
start: 0,
|
|
76155
77823
|
end: 37
|
|
76156
77824
|
};
|
|
76157
77825
|
c.uint8.encode(state, 0);
|
|
76158
77826
|
c.fixed32.encode(state, key);
|
|
76159
|
-
b4a
|
|
77827
|
+
b4a.writeUInt32BE(state.buffer, step, state.start);
|
|
76160
77828
|
state.buffer[33] |= 128;
|
|
76161
77829
|
return state.buffer;
|
|
76162
77830
|
}
|
|
@@ -76304,7 +77972,7 @@ var require_encoding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76304
77972
|
//#region ../../node_modules/keet-identity-key/index.js
|
|
76305
77973
|
var require_keet_identity_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
76306
77974
|
var c = require_compact_encoding();
|
|
76307
|
-
var b4a =
|
|
77975
|
+
var b4a = require_browser();
|
|
76308
77976
|
var KeyChain = require_keychain();
|
|
76309
77977
|
var { sign, verify, hash } = require_crypto();
|
|
76310
77978
|
var { ProofEncoding, AttestedData, AttestedDevice, ReceiptEncoding } = require_encoding();
|
|
@@ -76480,4 +78148,4 @@ var require_keet_identity_key = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
76480
78148
|
//#endregion
|
|
76481
78149
|
export default require_keet_identity_key();
|
|
76482
78150
|
|
|
76483
|
-
//# sourceMappingURL=keet-identity-key-
|
|
78151
|
+
//# sourceMappingURL=keet-identity-key-DLXTTFZH.js.map
|