@prosopo/account 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/extension/ExtensionWeb2.cjs +7 -10
  2. package/dist/cjs/extension/ExtensionWeb3.cjs +4 -5
  3. package/dist/extension/ExtensionWeb2.d.ts.map +1 -1
  4. package/dist/extension/ExtensionWeb2.js.map +1 -1
  5. package/dist/extension/ExtensionWeb3.js.map +1 -1
  6. package/package.json +57 -53
  7. package/dist/cjs/common/dist/array.cjs +0 -8
  8. package/dist/cjs/common/dist/asyncFactory.cjs +0 -13
  9. package/dist/cjs/common/dist/custom.cjs +0 -1
  10. package/dist/cjs/common/dist/error.cjs +0 -104
  11. package/dist/cjs/common/dist/hash.cjs +0 -14
  12. package/dist/cjs/common/dist/i18n.cjs +0 -29
  13. package/dist/cjs/common/dist/index.cjs +0 -39
  14. package/dist/cjs/common/dist/locales/en.json.cjs +0 -205
  15. package/dist/cjs/common/dist/logger.cjs +0 -103
  16. package/dist/cjs/common/dist/node/UrlConverter.cjs +0 -223
  17. package/dist/cjs/common/dist/node/i18nMiddleware.cjs +0 -8
  18. package/dist/cjs/common/dist/node/index.cjs +0 -4
  19. package/dist/cjs/common/dist/react/index.cjs +0 -4
  20. package/dist/cjs/common/dist/react/useTranslation.cjs +0 -8
  21. package/dist/cjs/common/dist/string.cjs +0 -6
  22. package/dist/cjs/common/dist/utils.cjs +0 -33
  23. package/dist/cjs/detector/src/index.cjs +0 -4586
  24. package/dist/cjs/util/dist/at.cjs +0 -25
  25. package/dist/cjs/util/dist/canvas.cjs +0 -332
  26. package/dist/cjs/util/dist/checks.cjs +0 -10
  27. package/dist/cjs/util/dist/choice.cjs +0 -19
  28. package/dist/cjs/util/dist/get.cjs +0 -10
  29. package/dist/cjs/util/dist/hex.cjs +0 -46
  30. package/dist/cjs/util/dist/index.cjs +0 -44
  31. package/dist/cjs/util/dist/isMain.cjs +0 -13
  32. package/dist/cjs/util/dist/lodash.cjs +0 -35
  33. package/dist/cjs/util/dist/merge.cjs +0 -58
  34. package/dist/cjs/util/dist/ofLen.cjs +0 -526
  35. package/dist/cjs/util/dist/permutations.cjs +0 -26
  36. package/dist/cjs/util/dist/solverService.cjs +0 -17
  37. package/dist/cjs/util/dist/table.cjs +0 -24
  38. package/dist/cjs/util/dist/url.cjs +0 -9
  39. package/dist/cjs/util/dist/util.cjs +0 -22
  40. package/dist/cjs/util/dist/verifyRecency.cjs +0 -12
  41. package/dist/cjs/util/dist/version.cjs +0 -4
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function at(items, index, options) {
4
- if (items.length === 0) {
5
- throw new Error("Array is empty");
6
- }
7
- if (!Number.isFinite(index)) {
8
- throw new Error(`Index ${index} is not a finite number`);
9
- }
10
- if (!options?.noWrap) {
11
- if (index > 0) {
12
- index = index % items.length;
13
- } else {
14
- index = Math.ceil(Math.abs(index) / items.length) * items.length + index;
15
- }
16
- }
17
- if (index >= items.length) {
18
- throw new Error(`Index ${index} larger than array length ${items.length}`);
19
- }
20
- if (index < 0) {
21
- throw new Error(`Index ${index} smaller than 0`);
22
- }
23
- return items[index];
24
- }
25
- exports.at = at;
@@ -1,332 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("./index.cjs");
4
- const at = require("./at.cjs");
5
- function x64Add(m, n) {
6
- m = [at.at(m, 0) >>> 16, at.at(m, 0) & 65535, at.at(m, 1) >>> 16, at.at(m, 1) & 65535];
7
- n = [at.at(n, 0) >>> 16, at.at(n, 0) & 65535, at.at(n, 1) >>> 16, at.at(n, 1) & 65535];
8
- const o = [0, 0, 0, 0];
9
- o[3] += at.at(m, 3) + at.at(n, 3);
10
- o[2] += at.at(o, 3) >>> 16;
11
- o[3] &= 65535;
12
- o[2] += at.at(m, 2) + at.at(n, 2);
13
- o[1] += at.at(o, 2) >>> 16;
14
- o[2] &= 65535;
15
- o[1] += at.at(m, 1) + at.at(n, 1);
16
- o[0] += at.at(o, 1) >>> 16;
17
- o[1] &= 65535;
18
- o[0] += at.at(m, 0) + at.at(n, 0);
19
- o[0] &= 65535;
20
- return [at.at(o, 0) << 16 | at.at(o, 1), at.at(o, 2) << 16 | at.at(o, 3)];
21
- }
22
- function x64Multiply(m, n) {
23
- m = [at.at(m, 0) >>> 16, at.at(m, 0) & 65535, at.at(m, 1) >>> 16, at.at(m, 1) & 65535];
24
- n = [at.at(n, 0) >>> 16, at.at(n, 0) & 65535, at.at(n, 1) >>> 16, at.at(n, 1) & 65535];
25
- const o = [0, 0, 0, 0];
26
- o[3] += at.at(m, 3) * at.at(n, 3);
27
- o[2] += at.at(o, 3) >>> 16;
28
- o[3] &= 65535;
29
- o[2] += at.at(m, 2) * at.at(n, 3);
30
- o[1] += at.at(o, 2) >>> 16;
31
- o[2] &= 65535;
32
- o[2] += at.at(m, 3) * at.at(n, 2);
33
- o[1] += at.at(o, 2) >>> 16;
34
- o[2] &= 65535;
35
- o[1] += at.at(m, 1) * at.at(n, 3);
36
- o[0] += at.at(o, 1) >>> 16;
37
- o[1] &= 65535;
38
- o[1] += at.at(m, 2) * at.at(n, 2);
39
- o[0] += at.at(o, 1) >>> 16;
40
- o[1] &= 65535;
41
- o[1] += at.at(m, 3) * at.at(n, 1);
42
- o[0] += at.at(o, 1) >>> 16;
43
- o[1] &= 65535;
44
- o[0] += at.at(m, 0) * at.at(n, 3) + at.at(m, 1) * at.at(n, 2) + at.at(m, 2) * at.at(n, 1) + at.at(m, 3) * at.at(n, 0);
45
- o[0] &= 65535;
46
- return [at.at(o, 0) << 16 | at.at(o, 1), at.at(o, 2) << 16 | at.at(o, 3)];
47
- }
48
- function x64Rotl(m, n) {
49
- n %= 64;
50
- if (n === 32) {
51
- return [at.at(m, 1), at.at(m, 0)];
52
- }
53
- if (n < 32) {
54
- return [
55
- at.at(m, 0) << n | at.at(m, 1) >>> 32 - n,
56
- at.at(m, 1) << n | at.at(m, 0) >>> 32 - n
57
- ];
58
- }
59
- n -= 32;
60
- return [
61
- at.at(m, 1) << n | at.at(m, 0) >>> 32 - n,
62
- at.at(m, 0) << n | at.at(m, 1) >>> 32 - n
63
- ];
64
- }
65
- function x64LeftShift(m, n) {
66
- n %= 64;
67
- if (n === 0) {
68
- return m;
69
- }
70
- if (n < 32) {
71
- return [at.at(m, 0) << n | at.at(m, 1) >>> 32 - n, at.at(m, 1) << n];
72
- }
73
- return [at.at(m, 1) << n - 32, 0];
74
- }
75
- function x64Xor(m, n) {
76
- return [at.at(m, 0) ^ at.at(n, 0), at.at(m, 1) ^ at.at(n, 1)];
77
- }
78
- function x64Fmix(h) {
79
- h = x64Xor(h, [0, at.at(h, 0) >>> 1]);
80
- h = x64Multiply(h, [4283543511, 3981806797]);
81
- h = x64Xor(h, [0, at.at(h, 0) >>> 1]);
82
- h = x64Multiply(h, [3301882366, 444984403]);
83
- h = x64Xor(h, [0, at.at(h, 0) >>> 1]);
84
- return h;
85
- }
86
- function x64hash128(key, seed) {
87
- key = key || "";
88
- seed = seed || 0;
89
- const remainder = key.length % 16;
90
- const bytes = key.length - remainder;
91
- let h1 = [0, seed];
92
- let h2 = [0, seed];
93
- let k1 = [0, 0];
94
- let k2 = [0, 0];
95
- const c1 = [2277735313, 289559509];
96
- const c2 = [1291169091, 658871167];
97
- let i = 0;
98
- for (i = 0; i < bytes; i = i + 16) {
99
- k1 = [
100
- key.charCodeAt(i + 4) & 255 | (key.charCodeAt(i + 5) & 255) << 8 | (key.charCodeAt(i + 6) & 255) << 16 | (key.charCodeAt(i + 7) & 255) << 24,
101
- key.charCodeAt(i) & 255 | (key.charCodeAt(i + 1) & 255) << 8 | (key.charCodeAt(i + 2) & 255) << 16 | (key.charCodeAt(i + 3) & 255) << 24
102
- ];
103
- k2 = [
104
- key.charCodeAt(i + 12) & 255 | (key.charCodeAt(i + 13) & 255) << 8 | (key.charCodeAt(i + 14) & 255) << 16 | (key.charCodeAt(i + 15) & 255) << 24,
105
- key.charCodeAt(i + 8) & 255 | (key.charCodeAt(i + 9) & 255) << 8 | (key.charCodeAt(i + 10) & 255) << 16 | (key.charCodeAt(i + 11) & 255) << 24
106
- ];
107
- k1 = x64Multiply(k1, c1);
108
- k1 = x64Rotl(k1, 31);
109
- k1 = x64Multiply(k1, c2);
110
- h1 = x64Xor(h1, k1);
111
- h1 = x64Rotl(h1, 27);
112
- h1 = x64Add(h1, h2);
113
- h1 = x64Add(x64Multiply(h1, [0, 5]), [0, 1390208809]);
114
- k2 = x64Multiply(k2, c2);
115
- k2 = x64Rotl(k2, 33);
116
- k2 = x64Multiply(k2, c1);
117
- h2 = x64Xor(h2, k2);
118
- h2 = x64Rotl(h2, 31);
119
- h2 = x64Add(h2, h1);
120
- h2 = x64Add(x64Multiply(h2, [0, 5]), [0, 944331445]);
121
- }
122
- k1 = [0, 0];
123
- k2 = [0, 0];
124
- switch (remainder) {
125
- case 15:
126
- k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 14)], 48));
127
- break;
128
- case 14:
129
- k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 13)], 40));
130
- break;
131
- case 13:
132
- k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 12)], 32));
133
- break;
134
- case 12:
135
- k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 11)], 24));
136
- break;
137
- case 11:
138
- k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 10)], 16));
139
- break;
140
- case 10:
141
- k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 9)], 8));
142
- break;
143
- case 9:
144
- k2 = x64Xor(k2, [0, key.charCodeAt(i + 8)]);
145
- k2 = x64Multiply(k2, c2);
146
- k2 = x64Rotl(k2, 33);
147
- k2 = x64Multiply(k2, c1);
148
- h2 = x64Xor(h2, k2);
149
- break;
150
- case 8:
151
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 7)], 56));
152
- break;
153
- case 7:
154
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 6)], 48));
155
- break;
156
- case 6:
157
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 5)], 40));
158
- break;
159
- case 5:
160
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 4)], 32));
161
- break;
162
- case 4:
163
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 3)], 24));
164
- break;
165
- case 3:
166
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 2)], 16));
167
- break;
168
- case 2:
169
- k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 1)], 8));
170
- break;
171
- case 1:
172
- k1 = x64Xor(k1, [0, key.charCodeAt(i)]);
173
- k1 = x64Multiply(k1, c1);
174
- k1 = x64Rotl(k1, 31);
175
- k1 = x64Multiply(k1, c2);
176
- h1 = x64Xor(h1, k1);
177
- }
178
- h1 = x64Xor(h1, [0, key.length]);
179
- h2 = x64Xor(h2, [0, key.length]);
180
- h1 = x64Add(h1, h2);
181
- h2 = x64Add(h2, h1);
182
- h1 = x64Fmix(h1);
183
- h2 = x64Fmix(h2);
184
- h1 = x64Add(h1, h2);
185
- h2 = x64Add(h2, h1);
186
- return `00000000${(at.at(h1, 0) >>> 0).toString(16)}`.slice(-8) + `00000000${(at.at(h1, 1) >>> 0).toString(16)}`.slice(-8) + `00000000${(at.at(h2, 0) >>> 0).toString(16)}`.slice(-8) + `00000000${(at.at(h2, 1) >>> 0).toString(16)}`.slice(-8);
187
- }
188
- function picassoCanvas(roundNumber, seed, params) {
189
- const { area, offsetParameter, multiplier, fontSizeFactor, maxShadowBlur } = params;
190
- class Prng {
191
- constructor(seed2) {
192
- this.currentNumber = seed2 % offsetParameter;
193
- if (this.currentNumber <= 0) {
194
- this.currentNumber += offsetParameter;
195
- }
196
- }
197
- getNext() {
198
- this.currentNumber = multiplier * this.currentNumber % offsetParameter;
199
- return this.currentNumber;
200
- }
201
- }
202
- function adaptRandomNumberToContext(randomNumber, maxBound, floatAllowed) {
203
- randomNumber = (randomNumber - 1) / offsetParameter;
204
- if (floatAllowed) {
205
- return randomNumber * maxBound;
206
- }
207
- return Math.floor(randomNumber * maxBound);
208
- }
209
- function addRandomCanvasGradient(prng, context, area2) {
210
- const canvasGradient = context.createRadialGradient(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0));
211
- canvasGradient.addColorStop(0, at.at(colors, adaptRandomNumberToContext(prng.getNext(), colors.length, void 0)));
212
- canvasGradient.addColorStop(1, at.at(colors, adaptRandomNumberToContext(prng.getNext(), colors.length, void 0)));
213
- context.fillStyle = canvasGradient;
214
- }
215
- function generateRandomWord(prng, wordLength) {
216
- const minAscii = 65;
217
- const maxAscii = 126;
218
- const wordGenerated = [];
219
- for (let i = 0; i < wordLength; i++) {
220
- const asciiCode = minAscii + prng.getNext() % (maxAscii - minAscii);
221
- wordGenerated.push(String.fromCharCode(asciiCode));
222
- }
223
- return wordGenerated.join("");
224
- }
225
- if (window.CanvasRenderingContext2D) {
226
- return "unknown";
227
- }
228
- const colors = [
229
- "#FF6633",
230
- "#FFB399",
231
- "#FF33FF",
232
- "#FFFF99",
233
- "#00B3E6",
234
- "#E6B333",
235
- "#3366E6",
236
- "#999966",
237
- "#99FF99",
238
- "#B34D4D",
239
- "#80B300",
240
- "#809900",
241
- "#E6B3B3",
242
- "#6680B3",
243
- "#66991A",
244
- "#FF99E6",
245
- "#CCFF1A",
246
- "#FF1A66",
247
- "#E6331A",
248
- "#33FFCC",
249
- "#66994D",
250
- "#B366CC",
251
- "#4D8000",
252
- "#B33300",
253
- "#CC80CC",
254
- "#66664D",
255
- "#991AFF",
256
- "#E666FF",
257
- "#4DB3FF",
258
- "#1AB399",
259
- "#E666B3",
260
- "#33991A",
261
- "#CC9999",
262
- "#B3B31A",
263
- "#00E680",
264
- "#4D8066",
265
- "#809980",
266
- "#E6FF80",
267
- "#1AFF33",
268
- "#999933",
269
- "#FF3380",
270
- "#CCCC00",
271
- "#66E64D",
272
- "#4D80CC",
273
- "#9900B3",
274
- "#E64D66",
275
- "#4DB380",
276
- "#FF4D4D",
277
- "#99E6E6",
278
- "#6666FF"
279
- ];
280
- const primitives = [
281
- function arc(prng, context, area2) {
282
- context.beginPath();
283
- context.arc(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), Math.min(area2.width, area2.height), void 0), adaptRandomNumberToContext(prng.getNext(), 2 * Math.PI, true), adaptRandomNumberToContext(prng.getNext(), 2 * Math.PI, true));
284
- context.stroke();
285
- },
286
- function text(prng, context, area2) {
287
- const wordLength = Math.max(1, adaptRandomNumberToContext(prng.getNext(), 5, void 0));
288
- const textToStroke = generateRandomWord(prng, wordLength);
289
- context.font = `${area2.height / fontSizeFactor}px aafakefontaa`;
290
- context.strokeText(textToStroke, adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0));
291
- },
292
- function bezierCurve(prng, context, area2) {
293
- context.beginPath();
294
- context.moveTo(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0));
295
- context.bezierCurveTo(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0));
296
- context.stroke();
297
- },
298
- function quadraticCurve(prng, context, area2) {
299
- context.beginPath();
300
- context.moveTo(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0));
301
- context.quadraticCurveTo(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0));
302
- context.stroke();
303
- },
304
- function ellipse(prng, context, area2) {
305
- context.beginPath();
306
- context.ellipse(adaptRandomNumberToContext(prng.getNext(), area2.width, void 0), adaptRandomNumberToContext(prng.getNext(), area2.height, void 0), adaptRandomNumberToContext(prng.getNext(), Math.floor(area2.width / 2), void 0), adaptRandomNumberToContext(prng.getNext(), Math.floor(area2.height / 2), void 0), adaptRandomNumberToContext(prng.getNext(), 2 * Math.PI, true), adaptRandomNumberToContext(prng.getNext(), 2 * Math.PI, true), adaptRandomNumberToContext(prng.getNext(), 2 * Math.PI, true));
307
- context.stroke();
308
- }
309
- ];
310
- try {
311
- const prng = new Prng(seed);
312
- const canvasElt = document.createElement("canvas");
313
- canvasElt.width = area.width;
314
- canvasElt.height = area.height;
315
- canvasElt.style.display = "none";
316
- const context = canvasElt.getContext("2d");
317
- if (context !== null) {
318
- for (let i = 0; i < roundNumber; i++) {
319
- addRandomCanvasGradient(prng, context, area);
320
- context.shadowBlur = adaptRandomNumberToContext(prng.getNext(), maxShadowBlur, void 0);
321
- context.shadowColor = at.at(colors, adaptRandomNumberToContext(prng.getNext(), colors.length, void 0));
322
- const randomPrimitive = at.at(primitives, adaptRandomNumberToContext(prng.getNext(), primitives.length, void 0));
323
- randomPrimitive(prng, context, area);
324
- context.fill();
325
- }
326
- }
327
- return x64hash128(canvasElt.toDataURL(), seed);
328
- } catch (error) {
329
- throw new Error(`Error with Captcha canvas. context: ${JSON.stringify(error)}`);
330
- }
331
- }
332
- exports.picassoCanvas = picassoCanvas;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const isArray = (value) => {
4
- return Array.isArray(value) && value !== null;
5
- };
6
- const isObject = (value) => {
7
- return value instanceof Object && !isArray(value);
8
- };
9
- exports.isArray = isArray;
10
- exports.isObject = isObject;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function choice(items, n, random, options) {
4
- if (n > items.length) {
5
- throw new Error(`Cannot choose ${n} items from array of length ${items.length}`);
6
- }
7
- const result = [];
8
- const indices = [];
9
- for (let i = 0; i < n; i++) {
10
- let index;
11
- do {
12
- index = Math.floor(Math.abs(random()) * items.length) % items.length;
13
- } while (options?.withReplacement === false && indices.includes(index));
14
- indices.push(index);
15
- result.push(items[index]);
16
- }
17
- return result;
18
- }
19
- exports.choice = choice;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function get(obj, key, required = true) {
4
- const value = obj[key];
5
- if (required && value === void 0) {
6
- throw new Error(`Object has no property '${String(key)}': ${JSON.stringify(obj, null, 2)}`);
7
- }
8
- return value;
9
- }
10
- exports.get = get;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const checks = require("./checks.cjs");
4
- const U8 = new Array(256);
5
- const U16 = new Array(256 * 256);
6
- for (let n = 0; n < 256; n++) {
7
- U8[n] = n.toString(16).padStart(2, "0");
8
- }
9
- for (let i = 0; i < 256; i++) {
10
- const s = i << 8;
11
- for (let j = 0; j < 256; j++) {
12
- U16[s | j] = U8[i] + U8[j];
13
- }
14
- }
15
- function hex(value, result) {
16
- const mod = value.length % 2 | 0;
17
- const length = value.length - mod | 0;
18
- for (let i = 0; i < length; i += 2) {
19
- result += U16[value[i] << 8 | value[i + 1]];
20
- }
21
- if (mod) {
22
- result += U8[value[length] | 0];
23
- }
24
- return result;
25
- }
26
- function u8aToHex(value, bitLength = -1, isPrefixed = true) {
27
- const empty = isPrefixed ? "0x" : "";
28
- if (!value?.length) {
29
- return empty;
30
- }
31
- if (bitLength > 0) {
32
- const length = Math.ceil(bitLength / 8);
33
- if (value.length > length) {
34
- return `${hex(value.subarray(0, length / 2), empty)}…${hex(value.subarray(value.length - length / 2), "")}`;
35
- }
36
- }
37
- return hex(value, empty);
38
- }
39
- const hashToHex = (hash) => {
40
- if (checks.isArray(hash)) {
41
- return u8aToHex(new Uint8Array(hash));
42
- }
43
- return hash.toString();
44
- };
45
- exports.hashToHex = hashToHex;
46
- exports.u8aToHex = u8aToHex;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const util = require("./util.cjs");
4
- const ofLen = require("./ofLen.cjs");
5
- const lodash = require("./lodash.cjs");
6
- const isMain = require("./isMain.cjs");
7
- const canvas = require("./canvas.cjs");
8
- const solverService = require("./solverService.cjs");
9
- const table = require("./table.cjs");
10
- const url = require("./url.cjs");
11
- const at = require("./at.cjs");
12
- const get = require("./get.cjs");
13
- const merge = require("./merge.cjs");
14
- const choice = require("./choice.cjs");
15
- const permutations = require("./permutations.cjs");
16
- const version = require("./version.cjs");
17
- const hex = require("./hex.cjs");
18
- const checks = require("./checks.cjs");
19
- const verifyRecency = require("./verifyRecency.cjs");
20
- exports.flatten = util.flatten;
21
- exports.getCurrentFileDirectory = util.getCurrentFileDirectory;
22
- exports.kebabCase = util.kebabCase;
23
- exports.sleep = util.sleep;
24
- exports.ofLen = ofLen.ofLen;
25
- exports.lodash = lodash.lodash;
26
- exports.rng = lodash.rng;
27
- exports.seedLodash = lodash.seedLodash;
28
- exports.setSeedGlobal = lodash.setSeedGlobal;
29
- exports.isMain = isMain.isMain;
30
- exports.picassoCanvas = canvas.picassoCanvas;
31
- exports.solvePoW = solverService.solvePoW;
32
- exports.consoleTableWithWrapping = table.consoleTableWithWrapping;
33
- exports.getURLProtocol = url.getURLProtocol;
34
- exports.at = at.at;
35
- exports.get = get.get;
36
- exports.merge = merge.merge;
37
- exports.choice = choice.choice;
38
- exports.permutations = permutations.permutations;
39
- exports.version = version.version;
40
- exports.hashToHex = hex.hashToHex;
41
- exports.u8aToHex = hex.u8aToHex;
42
- exports.isArray = checks.isArray;
43
- exports.isObject = checks.isObject;
44
- exports.verifyRecency = verifyRecency.verifyRecency;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const url = require("url");
4
- const isMain = (moduleOrImportMetaUrl, binName) => {
5
- if (typeof moduleOrImportMetaUrl === "string") {
6
- return process.argv[1] === url.fileURLToPath(moduleOrImportMetaUrl) || binName && process.argv[1] && process.argv[1].indexOf(`node_modules/.bin/${binName}`) > -1;
7
- }
8
- if (typeof require !== "undefined" && "exports" in moduleOrImportMetaUrl) {
9
- return require.main === moduleOrImportMetaUrl;
10
- }
11
- return false;
12
- };
13
- exports.isMain = isMain;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const _lodash = require("lodash");
4
- const seedrandom = require("seedrandom");
5
- const rng = (seed) => {
6
- const rng2 = seedrandom(seed.toString());
7
- return {
8
- double: () => rng2.double(),
9
- float: () => rng2.quick(),
10
- int: () => {
11
- const a = rng2.int32();
12
- const b = rng2.int32();
13
- return (a << 21) + b;
14
- },
15
- int32: () => rng2.int32(),
16
- bool: () => rng2.int32() % 2 === 0
17
- };
18
- };
19
- const setSeedGlobal = (seed) => {
20
- seedrandom(seed.toString(), { global: true });
21
- };
22
- const lodash = () => {
23
- return _lodash.runInContext();
24
- };
25
- const seedLodash = (seed) => {
26
- const orig = Math.random;
27
- seedrandom(seed.toString(), { global: true });
28
- const lodash2 = _lodash.runInContext();
29
- Math.random = orig;
30
- return lodash2;
31
- };
32
- exports.lodash = lodash;
33
- exports.rng = rng;
34
- exports.seedLodash = seedLodash;
35
- exports.setSeedGlobal = setSeedGlobal;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const checks = require("./checks.cjs");
4
- function merge(dest, src, options) {
5
- const atomicArrays = options?.atomicArrays;
6
- const queue = [
7
- {
8
- src,
9
- dest
10
- }
11
- ];
12
- while (queue.length > 0) {
13
- const task = queue.pop();
14
- if (task === void 0) {
15
- throw new Error("queue is empty");
16
- }
17
- if (checks.isArray(task.dest)) {
18
- const src2 = task.src;
19
- const dest2 = task.dest;
20
- if (atomicArrays) {
21
- while (dest2.length > src2.length) {
22
- dest2.pop();
23
- }
24
- for (let i = 0; i < src2.length; i++) {
25
- dest2[i] = src2[i];
26
- }
27
- } else {
28
- for (let i = 0; i < src2.length; i++) {
29
- if (checks.isArray(dest2[i]) && checks.isArray(src2[i]) || checks.isObject(dest2[i]) && checks.isObject(src2[i])) {
30
- queue.push({
31
- src: src2[i],
32
- dest: dest2[i]
33
- });
34
- } else {
35
- dest2[i] = src2[i];
36
- }
37
- }
38
- }
39
- } else if (checks.isObject(task.dest)) {
40
- const src2 = task.src;
41
- const destAny = task.dest;
42
- for (const [key, value] of Object.entries(src2)) {
43
- if (checks.isArray(value) && checks.isArray(destAny[key]) || checks.isObject(value) && checks.isObject(destAny[key])) {
44
- queue.push({
45
- src: value,
46
- dest: destAny[key]
47
- });
48
- } else {
49
- destAny[key] = value;
50
- }
51
- }
52
- } else {
53
- throw new Error(`cannot handle type in queue: ${typeof task.dest}`);
54
- }
55
- }
56
- return dest;
57
- }
58
- exports.merge = merge;