cotomy 1.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/dist/browser/cotomy.js +838 -162
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +2 -1
- package/dist/browser/cotomy.min.js.LICENSE.txt +1 -0
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.cjs.LICENSE.txt +1 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/api.js +29 -29
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/view.js +4 -4
- package/dist/esm/view.js.map +1 -1
- package/dist/types/api.d.ts +3 -3
- package/package.json +12 -12
package/dist/browser/cotomy.js
CHANGED
|
@@ -11,172 +11,849 @@
|
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
14
|
-
/***/
|
|
15
|
-
|
|
14
|
+
/***/ 318
|
|
15
|
+
(__unused_webpack_module, exports) {
|
|
16
16
|
|
|
17
|
+
"use strict";
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
20
|
+
exports.toBig = exports.shrSL = exports.shrSH = exports.rotrSL = exports.rotrSH = exports.rotrBL = exports.rotrBH = exports.rotr32L = exports.rotr32H = exports.rotlSL = exports.rotlSH = exports.rotlBL = exports.rotlBH = exports.add5L = exports.add5H = exports.add4L = exports.add4H = exports.add3L = exports.add3H = void 0;
|
|
21
|
+
exports.add = add;
|
|
22
|
+
exports.fromBig = fromBig;
|
|
23
|
+
exports.split = split;
|
|
24
|
+
/**
|
|
25
|
+
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
26
|
+
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
30
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
31
|
+
function fromBig(n, le = false) {
|
|
32
|
+
if (le)
|
|
33
|
+
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
34
|
+
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
35
|
+
}
|
|
36
|
+
function split(lst, le = false) {
|
|
37
|
+
const len = lst.length;
|
|
38
|
+
let Ah = new Uint32Array(len);
|
|
39
|
+
let Al = new Uint32Array(len);
|
|
40
|
+
for (let i = 0; i < len; i++) {
|
|
41
|
+
const { h, l } = fromBig(lst[i], le);
|
|
42
|
+
[Ah[i], Al[i]] = [h, l];
|
|
43
|
+
}
|
|
44
|
+
return [Ah, Al];
|
|
32
45
|
}
|
|
46
|
+
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
|
47
|
+
exports.toBig = toBig;
|
|
48
|
+
// for Shift in [0, 32)
|
|
49
|
+
const shrSH = (h, _l, s) => h >>> s;
|
|
50
|
+
exports.shrSH = shrSH;
|
|
51
|
+
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
52
|
+
exports.shrSL = shrSL;
|
|
53
|
+
// Right rotate for Shift in [1, 32)
|
|
54
|
+
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
|
55
|
+
exports.rotrSH = rotrSH;
|
|
56
|
+
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
|
57
|
+
exports.rotrSL = rotrSL;
|
|
58
|
+
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
59
|
+
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
|
60
|
+
exports.rotrBH = rotrBH;
|
|
61
|
+
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
|
62
|
+
exports.rotrBL = rotrBL;
|
|
63
|
+
// Right rotate for shift===32 (just swaps l&h)
|
|
64
|
+
const rotr32H = (_h, l) => l;
|
|
65
|
+
exports.rotr32H = rotr32H;
|
|
66
|
+
const rotr32L = (h, _l) => h;
|
|
67
|
+
exports.rotr32L = rotr32L;
|
|
68
|
+
// Left rotate for Shift in [1, 32)
|
|
69
|
+
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
|
70
|
+
exports.rotlSH = rotlSH;
|
|
71
|
+
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
|
72
|
+
exports.rotlSL = rotlSL;
|
|
73
|
+
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
|
74
|
+
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
|
75
|
+
exports.rotlBH = rotlBH;
|
|
76
|
+
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
|
77
|
+
exports.rotlBL = rotlBL;
|
|
78
|
+
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
|
79
|
+
// simple take carry out of low bit sum by shift, we need to use division.
|
|
80
|
+
function add(Ah, Al, Bh, Bl) {
|
|
81
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
82
|
+
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
|
83
|
+
}
|
|
84
|
+
// Addition with more than 2 elements
|
|
85
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
86
|
+
exports.add3L = add3L;
|
|
87
|
+
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
|
88
|
+
exports.add3H = add3H;
|
|
89
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
90
|
+
exports.add4L = add4L;
|
|
91
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
|
92
|
+
exports.add4H = add4H;
|
|
93
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
94
|
+
exports.add5L = add5L;
|
|
95
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
|
96
|
+
exports.add5H = add5H;
|
|
97
|
+
// prettier-ignore
|
|
98
|
+
const u64 = {
|
|
99
|
+
fromBig, split, toBig,
|
|
100
|
+
shrSH, shrSL,
|
|
101
|
+
rotrSH, rotrSL, rotrBH, rotrBL,
|
|
102
|
+
rotr32H, rotr32L,
|
|
103
|
+
rotlSH, rotlSL, rotlBH, rotlBL,
|
|
104
|
+
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
105
|
+
};
|
|
106
|
+
exports["default"] = u64;
|
|
107
|
+
//# sourceMappingURL=_u64.js.map
|
|
33
108
|
|
|
34
|
-
|
|
109
|
+
/***/ },
|
|
35
110
|
|
|
111
|
+
/***/ 145
|
|
112
|
+
(__unused_webpack_module, exports) {
|
|
36
113
|
|
|
37
|
-
|
|
114
|
+
"use strict";
|
|
38
115
|
|
|
39
|
-
|
|
40
|
-
|
|
116
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
117
|
+
exports.crypto = void 0;
|
|
118
|
+
exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
119
|
+
//# sourceMappingURL=crypto.js.map
|
|
41
120
|
|
|
42
|
-
|
|
121
|
+
/***/ },
|
|
43
122
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var mimeTypesLength = navigator.mimeTypes ? navigator.mimeTypes.length : 0;
|
|
47
|
-
var clientId = pad((mimeTypesLength +
|
|
48
|
-
navigator.userAgent.length).toString(36) +
|
|
49
|
-
globalCount.toString(36), 4);
|
|
123
|
+
/***/ 955
|
|
124
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
50
125
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
126
|
+
"use strict";
|
|
127
|
+
|
|
128
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
129
|
+
exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0;
|
|
130
|
+
exports.keccakP = keccakP;
|
|
131
|
+
/**
|
|
132
|
+
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
133
|
+
* Different from older hashes, the internal state is bigger than output size.
|
|
134
|
+
*
|
|
135
|
+
* Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
|
|
136
|
+
* [Website](https://keccak.team/keccak.html),
|
|
137
|
+
* [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
|
|
138
|
+
*
|
|
139
|
+
* Check out `sha3-addons` module for cSHAKE, k12, and others.
|
|
140
|
+
* @module
|
|
141
|
+
*/
|
|
142
|
+
const _u64_ts_1 = __webpack_require__(318);
|
|
143
|
+
// prettier-ignore
|
|
144
|
+
const utils_ts_1 = __webpack_require__(175);
|
|
145
|
+
// No __PURE__ annotations in sha3 header:
|
|
146
|
+
// EVERYTHING is in fact used on every export.
|
|
147
|
+
// Various per round constants calculations
|
|
148
|
+
const _0n = BigInt(0);
|
|
149
|
+
const _1n = BigInt(1);
|
|
150
|
+
const _2n = BigInt(2);
|
|
151
|
+
const _7n = BigInt(7);
|
|
152
|
+
const _256n = BigInt(256);
|
|
153
|
+
const _0x71n = BigInt(0x71);
|
|
154
|
+
const SHA3_PI = [];
|
|
155
|
+
const SHA3_ROTL = [];
|
|
156
|
+
const _SHA3_IOTA = [];
|
|
157
|
+
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
158
|
+
// Pi
|
|
159
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
160
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
161
|
+
// Rotational
|
|
162
|
+
SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
|
|
163
|
+
// Iota
|
|
164
|
+
let t = _0n;
|
|
165
|
+
for (let j = 0; j < 7; j++) {
|
|
166
|
+
R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
|
|
167
|
+
if (R & _2n)
|
|
168
|
+
t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
|
|
169
|
+
}
|
|
170
|
+
_SHA3_IOTA.push(t);
|
|
171
|
+
}
|
|
172
|
+
const IOTAS = (0, _u64_ts_1.split)(_SHA3_IOTA, true);
|
|
173
|
+
const SHA3_IOTA_H = IOTAS[0];
|
|
174
|
+
const SHA3_IOTA_L = IOTAS[1];
|
|
175
|
+
// Left rotation (without 0, 32, 64)
|
|
176
|
+
const rotlH = (h, l, s) => (s > 32 ? (0, _u64_ts_1.rotlBH)(h, l, s) : (0, _u64_ts_1.rotlSH)(h, l, s));
|
|
177
|
+
const rotlL = (h, l, s) => (s > 32 ? (0, _u64_ts_1.rotlBL)(h, l, s) : (0, _u64_ts_1.rotlSL)(h, l, s));
|
|
178
|
+
/** `keccakf1600` internal function, additionally allows to adjust round count. */
|
|
179
|
+
function keccakP(s, rounds = 24) {
|
|
180
|
+
const B = new Uint32Array(5 * 2);
|
|
181
|
+
// NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
|
|
182
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
183
|
+
// Theta θ
|
|
184
|
+
for (let x = 0; x < 10; x++)
|
|
185
|
+
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
186
|
+
for (let x = 0; x < 10; x += 2) {
|
|
187
|
+
const idx1 = (x + 8) % 10;
|
|
188
|
+
const idx0 = (x + 2) % 10;
|
|
189
|
+
const B0 = B[idx0];
|
|
190
|
+
const B1 = B[idx0 + 1];
|
|
191
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
192
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
193
|
+
for (let y = 0; y < 50; y += 10) {
|
|
194
|
+
s[x + y] ^= Th;
|
|
195
|
+
s[x + y + 1] ^= Tl;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Rho (ρ) and Pi (π)
|
|
199
|
+
let curH = s[2];
|
|
200
|
+
let curL = s[3];
|
|
201
|
+
for (let t = 0; t < 24; t++) {
|
|
202
|
+
const shift = SHA3_ROTL[t];
|
|
203
|
+
const Th = rotlH(curH, curL, shift);
|
|
204
|
+
const Tl = rotlL(curH, curL, shift);
|
|
205
|
+
const PI = SHA3_PI[t];
|
|
206
|
+
curH = s[PI];
|
|
207
|
+
curL = s[PI + 1];
|
|
208
|
+
s[PI] = Th;
|
|
209
|
+
s[PI + 1] = Tl;
|
|
210
|
+
}
|
|
211
|
+
// Chi (χ)
|
|
212
|
+
for (let y = 0; y < 50; y += 10) {
|
|
213
|
+
for (let x = 0; x < 10; x++)
|
|
214
|
+
B[x] = s[y + x];
|
|
215
|
+
for (let x = 0; x < 10; x++)
|
|
216
|
+
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
217
|
+
}
|
|
218
|
+
// Iota (ι)
|
|
219
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
220
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
221
|
+
}
|
|
222
|
+
(0, utils_ts_1.clean)(B);
|
|
223
|
+
}
|
|
224
|
+
/** Keccak sponge function. */
|
|
225
|
+
class Keccak extends utils_ts_1.Hash {
|
|
226
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
227
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
228
|
+
super();
|
|
229
|
+
this.pos = 0;
|
|
230
|
+
this.posOut = 0;
|
|
231
|
+
this.finished = false;
|
|
232
|
+
this.destroyed = false;
|
|
233
|
+
this.enableXOF = false;
|
|
234
|
+
this.blockLen = blockLen;
|
|
235
|
+
this.suffix = suffix;
|
|
236
|
+
this.outputLen = outputLen;
|
|
237
|
+
this.enableXOF = enableXOF;
|
|
238
|
+
this.rounds = rounds;
|
|
239
|
+
// Can be passed from user as dkLen
|
|
240
|
+
(0, utils_ts_1.anumber)(outputLen);
|
|
241
|
+
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
|
242
|
+
// 0 < blockLen < 200
|
|
243
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
244
|
+
throw new Error('only keccak-f1600 function is supported');
|
|
245
|
+
this.state = new Uint8Array(200);
|
|
246
|
+
this.state32 = (0, utils_ts_1.u32)(this.state);
|
|
247
|
+
}
|
|
248
|
+
clone() {
|
|
249
|
+
return this._cloneInto();
|
|
250
|
+
}
|
|
251
|
+
keccak() {
|
|
252
|
+
(0, utils_ts_1.swap32IfBE)(this.state32);
|
|
253
|
+
keccakP(this.state32, this.rounds);
|
|
254
|
+
(0, utils_ts_1.swap32IfBE)(this.state32);
|
|
255
|
+
this.posOut = 0;
|
|
256
|
+
this.pos = 0;
|
|
257
|
+
}
|
|
258
|
+
update(data) {
|
|
259
|
+
(0, utils_ts_1.aexists)(this);
|
|
260
|
+
data = (0, utils_ts_1.toBytes)(data);
|
|
261
|
+
(0, utils_ts_1.abytes)(data);
|
|
262
|
+
const { blockLen, state } = this;
|
|
263
|
+
const len = data.length;
|
|
264
|
+
for (let pos = 0; pos < len;) {
|
|
265
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
266
|
+
for (let i = 0; i < take; i++)
|
|
267
|
+
state[this.pos++] ^= data[pos++];
|
|
268
|
+
if (this.pos === blockLen)
|
|
269
|
+
this.keccak();
|
|
270
|
+
}
|
|
271
|
+
return this;
|
|
272
|
+
}
|
|
273
|
+
finish() {
|
|
274
|
+
if (this.finished)
|
|
275
|
+
return;
|
|
276
|
+
this.finished = true;
|
|
277
|
+
const { state, suffix, pos, blockLen } = this;
|
|
278
|
+
// Do the padding
|
|
279
|
+
state[pos] ^= suffix;
|
|
280
|
+
if ((suffix & 0x80) !== 0 && pos === blockLen - 1)
|
|
281
|
+
this.keccak();
|
|
282
|
+
state[blockLen - 1] ^= 0x80;
|
|
283
|
+
this.keccak();
|
|
284
|
+
}
|
|
285
|
+
writeInto(out) {
|
|
286
|
+
(0, utils_ts_1.aexists)(this, false);
|
|
287
|
+
(0, utils_ts_1.abytes)(out);
|
|
288
|
+
this.finish();
|
|
289
|
+
const bufferOut = this.state;
|
|
290
|
+
const { blockLen } = this;
|
|
291
|
+
for (let pos = 0, len = out.length; pos < len;) {
|
|
292
|
+
if (this.posOut >= blockLen)
|
|
293
|
+
this.keccak();
|
|
294
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
295
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
296
|
+
this.posOut += take;
|
|
297
|
+
pos += take;
|
|
298
|
+
}
|
|
299
|
+
return out;
|
|
300
|
+
}
|
|
301
|
+
xofInto(out) {
|
|
302
|
+
// Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
|
|
303
|
+
if (!this.enableXOF)
|
|
304
|
+
throw new Error('XOF is not possible for this instance');
|
|
305
|
+
return this.writeInto(out);
|
|
306
|
+
}
|
|
307
|
+
xof(bytes) {
|
|
308
|
+
(0, utils_ts_1.anumber)(bytes);
|
|
309
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
310
|
+
}
|
|
311
|
+
digestInto(out) {
|
|
312
|
+
(0, utils_ts_1.aoutput)(out, this);
|
|
313
|
+
if (this.finished)
|
|
314
|
+
throw new Error('digest() was already called');
|
|
315
|
+
this.writeInto(out);
|
|
316
|
+
this.destroy();
|
|
317
|
+
return out;
|
|
318
|
+
}
|
|
319
|
+
digest() {
|
|
320
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
321
|
+
}
|
|
322
|
+
destroy() {
|
|
323
|
+
this.destroyed = true;
|
|
324
|
+
(0, utils_ts_1.clean)(this.state);
|
|
325
|
+
}
|
|
326
|
+
_cloneInto(to) {
|
|
327
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
328
|
+
to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
329
|
+
to.state32.set(this.state32);
|
|
330
|
+
to.pos = this.pos;
|
|
331
|
+
to.posOut = this.posOut;
|
|
332
|
+
to.finished = this.finished;
|
|
333
|
+
to.rounds = rounds;
|
|
334
|
+
// Suffix can change in cSHAKE
|
|
335
|
+
to.suffix = suffix;
|
|
336
|
+
to.outputLen = outputLen;
|
|
337
|
+
to.enableXOF = enableXOF;
|
|
338
|
+
to.destroyed = this.destroyed;
|
|
339
|
+
return to;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
exports.Keccak = Keccak;
|
|
343
|
+
const gen = (suffix, blockLen, outputLen) => (0, utils_ts_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen));
|
|
344
|
+
/** SHA3-224 hash function. */
|
|
345
|
+
exports.sha3_224 = (() => gen(0x06, 144, 224 / 8))();
|
|
346
|
+
/** SHA3-256 hash function. Different from keccak-256. */
|
|
347
|
+
exports.sha3_256 = (() => gen(0x06, 136, 256 / 8))();
|
|
348
|
+
/** SHA3-384 hash function. */
|
|
349
|
+
exports.sha3_384 = (() => gen(0x06, 104, 384 / 8))();
|
|
350
|
+
/** SHA3-512 hash function. */
|
|
351
|
+
exports.sha3_512 = (() => gen(0x06, 72, 512 / 8))();
|
|
352
|
+
/** keccak-224 hash function. */
|
|
353
|
+
exports.keccak_224 = (() => gen(0x01, 144, 224 / 8))();
|
|
354
|
+
/** keccak-256 hash function. Different from SHA3-256. */
|
|
355
|
+
exports.keccak_256 = (() => gen(0x01, 136, 256 / 8))();
|
|
356
|
+
/** keccak-384 hash function. */
|
|
357
|
+
exports.keccak_384 = (() => gen(0x01, 104, 384 / 8))();
|
|
358
|
+
/** keccak-512 hash function. */
|
|
359
|
+
exports.keccak_512 = (() => gen(0x01, 72, 512 / 8))();
|
|
360
|
+
const genShake = (suffix, blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
|
361
|
+
/** SHAKE128 XOF with 128-bit security. */
|
|
362
|
+
exports.shake128 = (() => genShake(0x1f, 168, 128 / 8))();
|
|
363
|
+
/** SHAKE256 XOF with 256-bit security. */
|
|
364
|
+
exports.shake256 = (() => genShake(0x1f, 136, 256 / 8))();
|
|
365
|
+
//# sourceMappingURL=sha3.js.map
|
|
366
|
+
|
|
367
|
+
/***/ },
|
|
368
|
+
|
|
369
|
+
/***/ 175
|
|
370
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
54
371
|
|
|
372
|
+
"use strict";
|
|
55
373
|
|
|
56
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
376
|
+
* @module
|
|
377
|
+
*/
|
|
378
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
379
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
380
|
+
exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
|
|
381
|
+
exports.isBytes = isBytes;
|
|
382
|
+
exports.anumber = anumber;
|
|
383
|
+
exports.abytes = abytes;
|
|
384
|
+
exports.ahash = ahash;
|
|
385
|
+
exports.aexists = aexists;
|
|
386
|
+
exports.aoutput = aoutput;
|
|
387
|
+
exports.u8 = u8;
|
|
388
|
+
exports.u32 = u32;
|
|
389
|
+
exports.clean = clean;
|
|
390
|
+
exports.createView = createView;
|
|
391
|
+
exports.rotr = rotr;
|
|
392
|
+
exports.rotl = rotl;
|
|
393
|
+
exports.byteSwap = byteSwap;
|
|
394
|
+
exports.byteSwap32 = byteSwap32;
|
|
395
|
+
exports.bytesToHex = bytesToHex;
|
|
396
|
+
exports.hexToBytes = hexToBytes;
|
|
397
|
+
exports.asyncLoop = asyncLoop;
|
|
398
|
+
exports.utf8ToBytes = utf8ToBytes;
|
|
399
|
+
exports.bytesToUtf8 = bytesToUtf8;
|
|
400
|
+
exports.toBytes = toBytes;
|
|
401
|
+
exports.kdfInputToBytes = kdfInputToBytes;
|
|
402
|
+
exports.concatBytes = concatBytes;
|
|
403
|
+
exports.checkOpts = checkOpts;
|
|
404
|
+
exports.createHasher = createHasher;
|
|
405
|
+
exports.createOptHasher = createOptHasher;
|
|
406
|
+
exports.createXOFer = createXOFer;
|
|
407
|
+
exports.randomBytes = randomBytes;
|
|
408
|
+
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
409
|
+
// node.js versions earlier than v19 don't declare it in global scope.
|
|
410
|
+
// For node.js, package.json#exports field mapping rewrites import
|
|
411
|
+
// from `crypto` to `cryptoNode`, which imports native module.
|
|
412
|
+
// Makes the utils un-importable in browsers without a bundler.
|
|
413
|
+
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
414
|
+
const crypto_1 = __webpack_require__(145);
|
|
415
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
416
|
+
function isBytes(a) {
|
|
417
|
+
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
418
|
+
}
|
|
419
|
+
/** Asserts something is positive integer. */
|
|
420
|
+
function anumber(n) {
|
|
421
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
422
|
+
throw new Error('positive integer expected, got ' + n);
|
|
423
|
+
}
|
|
424
|
+
/** Asserts something is Uint8Array. */
|
|
425
|
+
function abytes(b, ...lengths) {
|
|
426
|
+
if (!isBytes(b))
|
|
427
|
+
throw new Error('Uint8Array expected');
|
|
428
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
429
|
+
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
|
|
430
|
+
}
|
|
431
|
+
/** Asserts something is hash */
|
|
432
|
+
function ahash(h) {
|
|
433
|
+
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
434
|
+
throw new Error('Hash should be wrapped by utils.createHasher');
|
|
435
|
+
anumber(h.outputLen);
|
|
436
|
+
anumber(h.blockLen);
|
|
437
|
+
}
|
|
438
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
439
|
+
function aexists(instance, checkFinished = true) {
|
|
440
|
+
if (instance.destroyed)
|
|
441
|
+
throw new Error('Hash instance has been destroyed');
|
|
442
|
+
if (checkFinished && instance.finished)
|
|
443
|
+
throw new Error('Hash#digest() has already been called');
|
|
444
|
+
}
|
|
445
|
+
/** Asserts output is properly-sized byte array */
|
|
446
|
+
function aoutput(out, instance) {
|
|
447
|
+
abytes(out);
|
|
448
|
+
const min = instance.outputLen;
|
|
449
|
+
if (out.length < min) {
|
|
450
|
+
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/** Cast u8 / u16 / u32 to u8. */
|
|
454
|
+
function u8(arr) {
|
|
455
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
456
|
+
}
|
|
457
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
458
|
+
function u32(arr) {
|
|
459
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
460
|
+
}
|
|
461
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
462
|
+
function clean(...arrays) {
|
|
463
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
464
|
+
arrays[i].fill(0);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
468
|
+
function createView(arr) {
|
|
469
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
470
|
+
}
|
|
471
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
472
|
+
function rotr(word, shift) {
|
|
473
|
+
return (word << (32 - shift)) | (word >>> shift);
|
|
474
|
+
}
|
|
475
|
+
/** The rotate left (circular left shift) operation for uint32 */
|
|
476
|
+
function rotl(word, shift) {
|
|
477
|
+
return (word << shift) | ((word >>> (32 - shift)) >>> 0);
|
|
478
|
+
}
|
|
479
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
480
|
+
exports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
481
|
+
/** The byte swap operation for uint32 */
|
|
482
|
+
function byteSwap(word) {
|
|
483
|
+
return (((word << 24) & 0xff000000) |
|
|
484
|
+
((word << 8) & 0xff0000) |
|
|
485
|
+
((word >>> 8) & 0xff00) |
|
|
486
|
+
((word >>> 24) & 0xff));
|
|
487
|
+
}
|
|
488
|
+
/** Conditionally byte swap if on a big-endian platform */
|
|
489
|
+
exports.swap8IfBE = exports.isLE
|
|
490
|
+
? (n) => n
|
|
491
|
+
: (n) => byteSwap(n);
|
|
492
|
+
/** @deprecated */
|
|
493
|
+
exports.byteSwapIfBE = exports.swap8IfBE;
|
|
494
|
+
/** In place byte swap for Uint32Array */
|
|
495
|
+
function byteSwap32(arr) {
|
|
496
|
+
for (let i = 0; i < arr.length; i++) {
|
|
497
|
+
arr[i] = byteSwap(arr[i]);
|
|
498
|
+
}
|
|
499
|
+
return arr;
|
|
500
|
+
}
|
|
501
|
+
exports.swap32IfBE = exports.isLE
|
|
502
|
+
? (u) => u
|
|
503
|
+
: byteSwap32;
|
|
504
|
+
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
|
|
505
|
+
const hasHexBuiltin = /* @__PURE__ */ (() =>
|
|
506
|
+
// @ts-ignore
|
|
507
|
+
typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
|
|
508
|
+
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
509
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
510
|
+
/**
|
|
511
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
512
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
513
|
+
*/
|
|
514
|
+
function bytesToHex(bytes) {
|
|
515
|
+
abytes(bytes);
|
|
516
|
+
// @ts-ignore
|
|
517
|
+
if (hasHexBuiltin)
|
|
518
|
+
return bytes.toHex();
|
|
519
|
+
// pre-caching improves the speed 6x
|
|
520
|
+
let hex = '';
|
|
521
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
522
|
+
hex += hexes[bytes[i]];
|
|
523
|
+
}
|
|
524
|
+
return hex;
|
|
525
|
+
}
|
|
526
|
+
// We use optimized technique to convert hex string to byte array
|
|
527
|
+
const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
528
|
+
function asciiToBase16(ch) {
|
|
529
|
+
if (ch >= asciis._0 && ch <= asciis._9)
|
|
530
|
+
return ch - asciis._0; // '2' => 50-48
|
|
531
|
+
if (ch >= asciis.A && ch <= asciis.F)
|
|
532
|
+
return ch - (asciis.A - 10); // 'B' => 66-(65-10)
|
|
533
|
+
if (ch >= asciis.a && ch <= asciis.f)
|
|
534
|
+
return ch - (asciis.a - 10); // 'b' => 98-(97-10)
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
539
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
540
|
+
*/
|
|
541
|
+
function hexToBytes(hex) {
|
|
542
|
+
if (typeof hex !== 'string')
|
|
543
|
+
throw new Error('hex string expected, got ' + typeof hex);
|
|
544
|
+
// @ts-ignore
|
|
545
|
+
if (hasHexBuiltin)
|
|
546
|
+
return Uint8Array.fromHex(hex);
|
|
547
|
+
const hl = hex.length;
|
|
548
|
+
const al = hl / 2;
|
|
549
|
+
if (hl % 2)
|
|
550
|
+
throw new Error('hex string expected, got unpadded hex of length ' + hl);
|
|
551
|
+
const array = new Uint8Array(al);
|
|
552
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
553
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
554
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
555
|
+
if (n1 === undefined || n2 === undefined) {
|
|
556
|
+
const char = hex[hi] + hex[hi + 1];
|
|
557
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
558
|
+
}
|
|
559
|
+
array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
|
|
560
|
+
}
|
|
561
|
+
return array;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* There is no setImmediate in browser and setTimeout is slow.
|
|
565
|
+
* Call of async fn will return Promise, which will be fullfiled only on
|
|
566
|
+
* next scheduler queue processing step and this is exactly what we need.
|
|
567
|
+
*/
|
|
568
|
+
const nextTick = async () => { };
|
|
569
|
+
exports.nextTick = nextTick;
|
|
570
|
+
/** Returns control to thread each 'tick' ms to avoid blocking. */
|
|
571
|
+
async function asyncLoop(iters, tick, cb) {
|
|
572
|
+
let ts = Date.now();
|
|
573
|
+
for (let i = 0; i < iters; i++) {
|
|
574
|
+
cb(i);
|
|
575
|
+
// Date.now() is not monotonic, so in case if clock goes backwards we return return control too
|
|
576
|
+
const diff = Date.now() - ts;
|
|
577
|
+
if (diff >= 0 && diff < tick)
|
|
578
|
+
continue;
|
|
579
|
+
await (0, exports.nextTick)();
|
|
580
|
+
ts += diff;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Converts string to bytes using UTF8 encoding.
|
|
585
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
586
|
+
*/
|
|
587
|
+
function utf8ToBytes(str) {
|
|
588
|
+
if (typeof str !== 'string')
|
|
589
|
+
throw new Error('string expected');
|
|
590
|
+
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Converts bytes to string using UTF8 encoding.
|
|
594
|
+
* @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'
|
|
595
|
+
*/
|
|
596
|
+
function bytesToUtf8(bytes) {
|
|
597
|
+
return new TextDecoder().decode(bytes);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
601
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
602
|
+
* Keep in mind for future mutable operations.
|
|
603
|
+
*/
|
|
604
|
+
function toBytes(data) {
|
|
605
|
+
if (typeof data === 'string')
|
|
606
|
+
data = utf8ToBytes(data);
|
|
607
|
+
abytes(data);
|
|
608
|
+
return data;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
612
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
613
|
+
*/
|
|
614
|
+
function kdfInputToBytes(data) {
|
|
615
|
+
if (typeof data === 'string')
|
|
616
|
+
data = utf8ToBytes(data);
|
|
617
|
+
abytes(data);
|
|
618
|
+
return data;
|
|
619
|
+
}
|
|
620
|
+
/** Copies several Uint8Arrays into one. */
|
|
621
|
+
function concatBytes(...arrays) {
|
|
622
|
+
let sum = 0;
|
|
623
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
624
|
+
const a = arrays[i];
|
|
625
|
+
abytes(a);
|
|
626
|
+
sum += a.length;
|
|
627
|
+
}
|
|
628
|
+
const res = new Uint8Array(sum);
|
|
629
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
630
|
+
const a = arrays[i];
|
|
631
|
+
res.set(a, pad);
|
|
632
|
+
pad += a.length;
|
|
633
|
+
}
|
|
634
|
+
return res;
|
|
635
|
+
}
|
|
636
|
+
function checkOpts(defaults, opts) {
|
|
637
|
+
if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
|
|
638
|
+
throw new Error('options should be object or undefined');
|
|
639
|
+
const merged = Object.assign(defaults, opts);
|
|
640
|
+
return merged;
|
|
641
|
+
}
|
|
642
|
+
/** For runtime check if class implements interface */
|
|
643
|
+
class Hash {
|
|
644
|
+
}
|
|
645
|
+
exports.Hash = Hash;
|
|
646
|
+
/** Wraps hash function, creating an interface on top of it */
|
|
647
|
+
function createHasher(hashCons) {
|
|
648
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
649
|
+
const tmp = hashCons();
|
|
650
|
+
hashC.outputLen = tmp.outputLen;
|
|
651
|
+
hashC.blockLen = tmp.blockLen;
|
|
652
|
+
hashC.create = () => hashCons();
|
|
653
|
+
return hashC;
|
|
654
|
+
}
|
|
655
|
+
function createOptHasher(hashCons) {
|
|
656
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
657
|
+
const tmp = hashCons({});
|
|
658
|
+
hashC.outputLen = tmp.outputLen;
|
|
659
|
+
hashC.blockLen = tmp.blockLen;
|
|
660
|
+
hashC.create = (opts) => hashCons(opts);
|
|
661
|
+
return hashC;
|
|
662
|
+
}
|
|
663
|
+
function createXOFer(hashCons) {
|
|
664
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
665
|
+
const tmp = hashCons({});
|
|
666
|
+
hashC.outputLen = tmp.outputLen;
|
|
667
|
+
hashC.blockLen = tmp.blockLen;
|
|
668
|
+
hashC.create = (opts) => hashCons(opts);
|
|
669
|
+
return hashC;
|
|
670
|
+
}
|
|
671
|
+
exports.wrapConstructor = createHasher;
|
|
672
|
+
exports.wrapConstructorWithOpts = createOptHasher;
|
|
673
|
+
exports.wrapXOFConstructorWithOpts = createXOFer;
|
|
674
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
675
|
+
function randomBytes(bytesLength = 32) {
|
|
676
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') {
|
|
677
|
+
return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
678
|
+
}
|
|
679
|
+
// Legacy Node.js compatibility
|
|
680
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') {
|
|
681
|
+
return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
|
|
682
|
+
}
|
|
683
|
+
throw new Error('crypto.getRandomValues must be defined');
|
|
684
|
+
}
|
|
685
|
+
//# sourceMappingURL=utils.js.map
|
|
57
686
|
|
|
58
|
-
/***/
|
|
59
|
-
/***/ (function(module) {
|
|
687
|
+
/***/ },
|
|
60
688
|
|
|
61
|
-
|
|
689
|
+
/***/ 410
|
|
690
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
62
691
|
|
|
63
|
-
|
|
692
|
+
var __webpack_unused_export__;
|
|
693
|
+
const { createId, init, getConstants, isCuid } = __webpack_require__(859);
|
|
64
694
|
|
|
65
|
-
|
|
66
|
-
|
|
695
|
+
module.exports.sX = createId;
|
|
696
|
+
__webpack_unused_export__ = init;
|
|
697
|
+
__webpack_unused_export__ = getConstants;
|
|
698
|
+
__webpack_unused_export__ = isCuid;
|
|
67
699
|
|
|
68
|
-
module.exports = function pad (num, size) {
|
|
69
|
-
var s = '000000000' + num;
|
|
70
|
-
return s.substr(s.length - size);
|
|
71
|
-
};
|
|
72
700
|
|
|
701
|
+
/***/ },
|
|
73
702
|
|
|
74
|
-
/***/
|
|
703
|
+
/***/ 859
|
|
704
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
75
705
|
|
|
76
|
-
|
|
77
|
-
|
|
706
|
+
/* global global, window, module */
|
|
707
|
+
const { sha3_512: sha3 } = __webpack_require__(955);
|
|
78
708
|
|
|
79
|
-
|
|
709
|
+
const defaultLength = 24;
|
|
710
|
+
const bigLength = 32;
|
|
80
711
|
|
|
81
|
-
|
|
712
|
+
const createEntropy = (length = 4, random = Math.random) => {
|
|
713
|
+
let entropy = "";
|
|
82
714
|
|
|
83
|
-
|
|
84
|
-
|
|
715
|
+
while (entropy.length < length) {
|
|
716
|
+
entropy = entropy + Math.floor(random() * 36).toString(36);
|
|
717
|
+
}
|
|
718
|
+
return entropy;
|
|
719
|
+
};
|
|
85
720
|
|
|
86
|
-
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* Sequential for fast db lookups and recency sorting.
|
|
90
|
-
* Safe for element IDs and server-side lookups.
|
|
91
|
-
*
|
|
92
|
-
* Extracted from CLCTR
|
|
93
|
-
*
|
|
94
|
-
* Copyright (c) Eric Elliott 2012
|
|
95
|
-
* MIT License
|
|
721
|
+
/*
|
|
722
|
+
* Adapted from https://github.com/juanelas/bigint-conversion
|
|
723
|
+
* MIT License Copyright (c) 2018 Juan Hernández Serrano
|
|
96
724
|
*/
|
|
725
|
+
function bufToBigInt(buf) {
|
|
726
|
+
let bits = 8n;
|
|
727
|
+
|
|
728
|
+
let value = 0n;
|
|
729
|
+
for (const i of buf.values()) {
|
|
730
|
+
const bi = BigInt(i);
|
|
731
|
+
value = (value << bits) + bi;
|
|
732
|
+
}
|
|
733
|
+
return value;
|
|
734
|
+
}
|
|
97
735
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
736
|
+
const hash = (input = "") => {
|
|
737
|
+
// Drop the first character because it will bias the histogram
|
|
738
|
+
// to the left.
|
|
739
|
+
return bufToBigInt(sha3(input)).toString(36).slice(1);
|
|
740
|
+
};
|
|
101
741
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
742
|
+
const alphabet = Array.from({ length: 26 }, (x, i) =>
|
|
743
|
+
String.fromCharCode(i + 97)
|
|
744
|
+
);
|
|
745
|
+
|
|
746
|
+
const randomLetter = (random) =>
|
|
747
|
+
alphabet[Math.floor(random() * alphabet.length)];
|
|
748
|
+
|
|
749
|
+
/*
|
|
750
|
+
This is a fingerprint of the host environment. It is used to help
|
|
751
|
+
prevent collisions when generating ids in a distributed system.
|
|
752
|
+
If no global object is available, you can pass in your own, or fall back
|
|
753
|
+
on a random string.
|
|
754
|
+
*/
|
|
755
|
+
const createFingerprint = ({
|
|
756
|
+
globalObj = typeof globalThis !== "undefined"
|
|
757
|
+
? globalThis
|
|
758
|
+
: typeof window !== "undefined"
|
|
759
|
+
? window
|
|
760
|
+
: {},
|
|
761
|
+
random = Math.random,
|
|
762
|
+
} = {}) => {
|
|
763
|
+
const globals = Object.keys(globalObj).toString();
|
|
764
|
+
const sourceString = globals.length
|
|
765
|
+
? globals + createEntropy(bigLength, random)
|
|
766
|
+
: createEntropy(bigLength, random);
|
|
767
|
+
|
|
768
|
+
return hash(sourceString).substring(0, bigLength);
|
|
769
|
+
};
|
|
106
770
|
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
.toString(base), blockSize);
|
|
111
|
-
}
|
|
771
|
+
const createCounter = (count) => () => {
|
|
772
|
+
return count++;
|
|
773
|
+
};
|
|
112
774
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
775
|
+
// ~22k hosts before 50% chance of initial counter collision
|
|
776
|
+
// with a remaining counter range of 9.0e+15 in JavaScript.
|
|
777
|
+
const initialCountMax = 476782367;
|
|
778
|
+
|
|
779
|
+
const init = ({
|
|
780
|
+
// Fallback if the user does not pass in a CSPRNG. This should be OK
|
|
781
|
+
// because we don't rely solely on the random number generator for entropy.
|
|
782
|
+
// We also use the host fingerprint, current time, and a session counter.
|
|
783
|
+
random = Math.random,
|
|
784
|
+
counter = createCounter(Math.floor(random() * initialCountMax)),
|
|
785
|
+
length = defaultLength,
|
|
786
|
+
fingerprint = createFingerprint({ random }),
|
|
787
|
+
} = {}) => {
|
|
788
|
+
return function cuid2() {
|
|
789
|
+
const firstLetter = randomLetter(random);
|
|
790
|
+
|
|
791
|
+
// If we're lucky, the `.toString(36)` calls may reduce hashing rounds
|
|
792
|
+
// by shortening the input to the hash function a little.
|
|
793
|
+
const time = Date.now().toString(36);
|
|
794
|
+
const count = counter().toString(36);
|
|
795
|
+
|
|
796
|
+
// The salt should be long enough to be globally unique across the full
|
|
797
|
+
// length of the hash. For simplicity, we use the same length as the
|
|
798
|
+
// intended id output.
|
|
799
|
+
const salt = createEntropy(length, random);
|
|
800
|
+
const hashInput = `${time + salt + count + fingerprint}`;
|
|
801
|
+
|
|
802
|
+
return `${firstLetter + hash(hashInput).substring(1, length)}`;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
118
805
|
|
|
119
|
-
|
|
120
|
-
// Starting with a lowercase letter makes
|
|
121
|
-
// it HTML element ID friendly.
|
|
122
|
-
var letter = 'c', // hard-coded allows for sequential access
|
|
806
|
+
const createId = init();
|
|
123
807
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
timestamp = (new Date().getTime()).toString(base),
|
|
808
|
+
const isCuid = (id, { minLength = 2, maxLength = bigLength } = {}) => {
|
|
809
|
+
const length = id.length;
|
|
810
|
+
const regex = /^[0-9a-z]+$/;
|
|
128
811
|
|
|
129
|
-
|
|
130
|
-
|
|
812
|
+
try {
|
|
813
|
+
if (
|
|
814
|
+
typeof id === "string" &&
|
|
815
|
+
length >= minLength &&
|
|
816
|
+
length <= maxLength &&
|
|
817
|
+
regex.test(id)
|
|
818
|
+
)
|
|
819
|
+
return true;
|
|
820
|
+
} finally {
|
|
821
|
+
}
|
|
131
822
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// likely to generate the same id)
|
|
135
|
-
print = fingerprint(),
|
|
823
|
+
return false;
|
|
824
|
+
};
|
|
136
825
|
|
|
137
|
-
|
|
138
|
-
|
|
826
|
+
module.exports.getConstants = () => ({ defaultLength, bigLength });
|
|
827
|
+
module.exports.init = init;
|
|
828
|
+
module.exports.createId = createId;
|
|
829
|
+
module.exports.bufToBigInt = bufToBigInt;
|
|
830
|
+
module.exports.createCounter = createCounter;
|
|
831
|
+
module.exports.createFingerprint = createFingerprint;
|
|
832
|
+
module.exports.isCuid = isCuid;
|
|
139
833
|
|
|
140
|
-
return letter + timestamp + counter + print + random;
|
|
141
|
-
}
|
|
142
834
|
|
|
143
|
-
|
|
144
|
-
var date = new Date().getTime().toString(36),
|
|
145
|
-
counter = safeCounter().toString(36).slice(-4),
|
|
146
|
-
print = fingerprint().slice(0, 1) +
|
|
147
|
-
fingerprint().slice(-1),
|
|
148
|
-
random = randomBlock().slice(-2);
|
|
835
|
+
/***/ },
|
|
149
836
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
cuid.isCuid = function isCuid (stringToCheck) {
|
|
155
|
-
if (typeof stringToCheck !== 'string') return false;
|
|
156
|
-
if (stringToCheck.startsWith('c')) return true;
|
|
157
|
-
return false;
|
|
158
|
-
};
|
|
837
|
+
/***/ 353
|
|
838
|
+
(module) {
|
|
159
839
|
|
|
160
|
-
|
|
161
|
-
if (typeof stringToCheck !== 'string') return false;
|
|
162
|
-
var stringLength = stringToCheck.length;
|
|
163
|
-
if (stringLength >= 7 && stringLength <= 10) return true;
|
|
164
|
-
return false;
|
|
165
|
-
};
|
|
840
|
+
!function(t,e){ true?module.exports=e():0}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
166
841
|
|
|
167
|
-
|
|
842
|
+
/***/ },
|
|
168
843
|
|
|
169
|
-
|
|
844
|
+
/***/ 569
|
|
845
|
+
(module) {
|
|
170
846
|
|
|
847
|
+
!function(t,e){ true?module.exports=e():0}(this,(function(){"use strict";var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,o){var r,a=function(t,n,i){void 0===i&&(i={});var o=new Date(t),r=function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",o=t+"|"+i,r=e[o];return r||(r=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),e[o]=r),r}(n,i);return r.formatToParts(o)},u=function(e,n){for(var i=a(e,n),r=[],u=0;u<i.length;u+=1){var f=i[u],s=f.type,m=f.value,c=t[s];c>=0&&(r[c]=parseInt(m,10))}var d=r[3],l=24===d?0:d,h=r[0]+"-"+r[1]+"-"+r[2]+" "+l+":"+r[4]+":"+r[5]+":000",v=+e;return(o.utc(h).valueOf()-(v-=v%1e3))/6e4},f=i.prototype;f.tz=function(t,e){void 0===t&&(t=r);var n,i=this.utcOffset(),a=this.toDate(),u=a.toLocaleString("en-US",{timeZone:t}),f=Math.round((a-new Date(u))/1e3/60),s=15*-Math.round(a.getTimezoneOffset()/15)-f;if(!Number(s))n=this.utcOffset(0,e);else if(n=o(u,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(s,!0),e){var m=n.utcOffset();n=n.add(i-m,"minute")}return n.$x.$timezone=t,n},f.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),n=a(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return n&&n.value};var s=f.startOf;f.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return s.call(this,t,e);var n=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return s.call(n,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,n){var i=n&&e,a=n||e||r,f=u(+o(),a);if("string"!=typeof t)return o(t).tz(a);var s=function(t,e,n){var i=t-60*e*1e3,o=u(i,n);if(e===o)return[i,e];var r=u(i-=60*(o-e)*1e3,n);return o===r?[i,o]:[t-60*Math.min(o,r)*1e3,Math.max(o,r)]}(o.utc(t,i).valueOf(),f,a),m=s[0],c=s[1],d=o(m).utcOffset(c);return d.$x.$timezone=a,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){r=t}}}));
|
|
171
848
|
|
|
172
|
-
/***/ }
|
|
849
|
+
/***/ },
|
|
173
850
|
|
|
174
|
-
/***/ 826
|
|
175
|
-
|
|
851
|
+
/***/ 826
|
|
852
|
+
(module) {
|
|
176
853
|
|
|
177
|
-
!function(t,i){ true?module.exports=i():0}(this,(function(){"use strict";var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var
|
|
854
|
+
!function(t,i){ true?module.exports=i():0}(this,(function(){"use strict";var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t)};var o=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else o.call(this)};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s;if(0===u)return this.utc(f);var r=this.clone();if(f)return r.$offset=u,r.$u=!1,r;var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(r=this.local().add(u+o,t)).$offset=u,r.$x.$localOffset=o,r};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)}}}));
|
|
178
855
|
|
|
179
|
-
/***/ }
|
|
856
|
+
/***/ }
|
|
180
857
|
|
|
181
858
|
/******/ });
|
|
182
859
|
/************************************************************************/
|
|
@@ -289,6 +966,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
289
966
|
// EXTERNAL MODULE: ./node_modules/dayjs/dayjs.min.js
|
|
290
967
|
var dayjs_min = __webpack_require__(353);
|
|
291
968
|
var dayjs_min_default = /*#__PURE__*/__webpack_require__.n(dayjs_min);
|
|
969
|
+
// EXTERNAL MODULE: ./node_modules/dayjs/plugin/timezone.js
|
|
970
|
+
var timezone = __webpack_require__(569);
|
|
971
|
+
var timezone_default = /*#__PURE__*/__webpack_require__.n(timezone);
|
|
972
|
+
// EXTERNAL MODULE: ./node_modules/dayjs/plugin/utc.js
|
|
973
|
+
var utc = __webpack_require__(826);
|
|
974
|
+
var utc_default = /*#__PURE__*/__webpack_require__.n(utc);
|
|
292
975
|
;// ./node_modules/http-status-codes/build/es/status-codes.js
|
|
293
976
|
// Generated file. Do not edit
|
|
294
977
|
var StatusCodes;
|
|
@@ -692,9 +1375,8 @@ class CotomyDebugSettings {
|
|
|
692
1375
|
}
|
|
693
1376
|
CotomyDebugSettings.PREFIX = "cotomy:debug";
|
|
694
1377
|
|
|
695
|
-
// EXTERNAL MODULE: ./node_modules/
|
|
696
|
-
var
|
|
697
|
-
var cuid_default = /*#__PURE__*/__webpack_require__.n(cuid);
|
|
1378
|
+
// EXTERNAL MODULE: ./node_modules/@paralleldrive/cuid2/index.js
|
|
1379
|
+
var cuid2 = __webpack_require__(410);
|
|
698
1380
|
;// ./src/view.ts
|
|
699
1381
|
|
|
700
1382
|
|
|
@@ -972,7 +1654,7 @@ class CotomyElement {
|
|
|
972
1654
|
}
|
|
973
1655
|
setInstanceId() {
|
|
974
1656
|
if (!this.hasAttribute("data-cotomy-instance")) {
|
|
975
|
-
this.attribute("data-cotomy-instance",
|
|
1657
|
+
this.attribute("data-cotomy-instance", (0,cuid2/* createId */.sX)());
|
|
976
1658
|
this.removed(() => {
|
|
977
1659
|
this._element = CotomyElement.createHTMLElement(`<div data-cotomy-invalidated style="display: none;"></div>`);
|
|
978
1660
|
EventRegistry.instance.clear(this);
|
|
@@ -992,7 +1674,7 @@ class CotomyElement {
|
|
|
992
1674
|
}
|
|
993
1675
|
get scopeId() {
|
|
994
1676
|
if (!this.hasAttribute("data-cotomy-scopeid")) {
|
|
995
|
-
this.attribute("data-cotomy-scopeid",
|
|
1677
|
+
this.attribute("data-cotomy-scopeid", (0,cuid2/* createId */.sX)());
|
|
996
1678
|
}
|
|
997
1679
|
return this.attribute("data-cotomy-scopeid");
|
|
998
1680
|
}
|
|
@@ -1043,7 +1725,7 @@ class CotomyElement {
|
|
|
1043
1725
|
}
|
|
1044
1726
|
generateId(prefix = "__cotomy_elem__") {
|
|
1045
1727
|
if (!this.id) {
|
|
1046
|
-
this.attribute("id", `${prefix}${
|
|
1728
|
+
this.attribute("id", `${prefix}${(0,cuid2/* createId */.sX)()}`);
|
|
1047
1729
|
}
|
|
1048
1730
|
return this;
|
|
1049
1731
|
}
|
|
@@ -2257,6 +2939,10 @@ CotomyWindow._instance = null;
|
|
|
2257
2939
|
|
|
2258
2940
|
|
|
2259
2941
|
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
dayjs_min_default().extend((utc_default()));
|
|
2945
|
+
dayjs_min_default().extend((timezone_default()));
|
|
2260
2946
|
class CotomyApiException extends Error {
|
|
2261
2947
|
constructor(status, message, response, bodyText = "") {
|
|
2262
2948
|
super(message);
|
|
@@ -2451,40 +3137,21 @@ class CotomyDotBindNameGenerator {
|
|
|
2451
3137
|
return parent ? `${parent}[${index}]` : `[${index}]`;
|
|
2452
3138
|
}
|
|
2453
3139
|
}
|
|
2454
|
-
class CotomyBindNameGeneratorProvider {
|
|
2455
|
-
static getDefault() {
|
|
2456
|
-
return this._default ?? (this._default = new CotomyBracketBindNameGenerator());
|
|
2457
|
-
}
|
|
2458
|
-
static setDefault(generator) {
|
|
2459
|
-
this._default = generator;
|
|
2460
|
-
}
|
|
2461
|
-
static resetDefault() {
|
|
2462
|
-
this._default = undefined;
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
3140
|
class CotomyViewRenderer {
|
|
2466
3141
|
static get defaultBindNameGenerator() {
|
|
2467
|
-
return
|
|
3142
|
+
return this._defaultBindNameGenerator ?? new CotomyBracketBindNameGenerator();
|
|
2468
3143
|
}
|
|
2469
3144
|
static set defaultBindNameGenerator(generator) {
|
|
2470
|
-
|
|
3145
|
+
this._defaultBindNameGenerator = generator;
|
|
2471
3146
|
}
|
|
2472
3147
|
static resetDefaultBindNameGenerator() {
|
|
2473
|
-
|
|
3148
|
+
this._defaultBindNameGenerator = null;
|
|
2474
3149
|
}
|
|
2475
3150
|
constructor(element, bindNameGenerator = CotomyViewRenderer.defaultBindNameGenerator) {
|
|
2476
3151
|
this.element = element;
|
|
2477
3152
|
this.bindNameGenerator = bindNameGenerator;
|
|
2478
3153
|
this._renderers = {};
|
|
2479
|
-
this.
|
|
2480
|
-
}
|
|
2481
|
-
get locale() {
|
|
2482
|
-
const languages = (navigator.languages && navigator.languages.length ? navigator.languages : [navigator.language]).filter(Boolean);
|
|
2483
|
-
let locale = this.element.attribute("data-cotomy-locale")
|
|
2484
|
-
|| this.element.closest("[data-cotomy-locale]")?.attribute("data-cotomy-locale")
|
|
2485
|
-
|| languages[0]
|
|
2486
|
-
|| 'en-US';
|
|
2487
|
-
return locale.includes("-") ? locale.split("-")[0] : locale;
|
|
3154
|
+
this._initialized = false;
|
|
2488
3155
|
}
|
|
2489
3156
|
renderer(type, callback) {
|
|
2490
3157
|
this._renderers[type] = callback;
|
|
@@ -2495,7 +3162,7 @@ class CotomyViewRenderer {
|
|
|
2495
3162
|
return this._renderers;
|
|
2496
3163
|
}
|
|
2497
3164
|
get initialized() {
|
|
2498
|
-
return this.
|
|
3165
|
+
return this._initialized;
|
|
2499
3166
|
}
|
|
2500
3167
|
initialize() {
|
|
2501
3168
|
if (!this.initialized) {
|
|
@@ -2527,16 +3194,27 @@ class CotomyViewRenderer {
|
|
|
2527
3194
|
...(currency ? { style: "currency", currency } : {}),
|
|
2528
3195
|
...(hasFractionDigits ? { minimumFractionDigits: fractionDigits, maximumFractionDigits: fractionDigits } : {}),
|
|
2529
3196
|
};
|
|
2530
|
-
|
|
3197
|
+
const languages = (navigator.languages && navigator.languages.length ? navigator.languages : [navigator.language]).filter(Boolean);
|
|
3198
|
+
const localeAttribute = element.attribute("data-cotomy-locale")
|
|
3199
|
+
|| element.closest("[data-cotomy-locale]")?.attribute("data-cotomy-locale")
|
|
3200
|
+
|| this.element.attribute("data-cotomy-locale")
|
|
3201
|
+
|| this.element.closest("[data-cotomy-locale]")?.attribute("data-cotomy-locale")
|
|
3202
|
+
|| languages[0]
|
|
3203
|
+
|| "en-US";
|
|
3204
|
+
const locale = localeAttribute.includes("-") ? localeAttribute.split("-")[0] : localeAttribute;
|
|
3205
|
+
element.text = new Intl.NumberFormat(locale, options).format(value);
|
|
2531
3206
|
}
|
|
2532
3207
|
});
|
|
2533
3208
|
this.renderer("utc", (element, value) => {
|
|
2534
3209
|
if (value) {
|
|
2535
|
-
const hasOffset = /[+-]\d{2}:\d{2}$/.test(value);
|
|
3210
|
+
const hasOffset = /([+-]\d{2}:\d{2}|Z)$/.test(value);
|
|
2536
3211
|
const date = hasOffset ? new Date(value) : new Date(`${value}Z`);
|
|
2537
3212
|
if (!isNaN(date.getTime())) {
|
|
2538
3213
|
const format = element.attribute("data-cotomy-format") ?? "YYYY/MM/DD HH:mm";
|
|
2539
|
-
|
|
3214
|
+
const timezone = element.attribute("data-cotomy-timezone")
|
|
3215
|
+
|| element.closest("[data-cotomy-timezone]")?.attribute("data-cotomy-timezone");
|
|
3216
|
+
const dt = dayjs_min_default()(date);
|
|
3217
|
+
element.text = timezone && timezone.trim() !== "" ? dt.tz(timezone).format(format) : dt.format(format);
|
|
2540
3218
|
}
|
|
2541
3219
|
}
|
|
2542
3220
|
});
|
|
@@ -2545,11 +3223,14 @@ class CotomyViewRenderer {
|
|
|
2545
3223
|
const date = new Date(value);
|
|
2546
3224
|
if (!isNaN(date.getTime())) {
|
|
2547
3225
|
const format = element.attribute("data-cotomy-format") ?? "YYYY/MM/DD";
|
|
2548
|
-
|
|
3226
|
+
const timezone = element.attribute("data-cotomy-timezone")
|
|
3227
|
+
|| element.closest("[data-cotomy-timezone]")?.attribute("data-cotomy-timezone");
|
|
3228
|
+
const dt = dayjs_min_default()(date);
|
|
3229
|
+
element.text = timezone && timezone.trim() !== "" ? dt.tz(timezone).format(format) : dt.format(format);
|
|
2549
3230
|
}
|
|
2550
3231
|
}
|
|
2551
3232
|
});
|
|
2552
|
-
this.
|
|
3233
|
+
this._initialized = true;
|
|
2553
3234
|
}
|
|
2554
3235
|
return this;
|
|
2555
3236
|
}
|
|
@@ -2607,6 +3288,7 @@ class CotomyViewRenderer {
|
|
|
2607
3288
|
return this;
|
|
2608
3289
|
}
|
|
2609
3290
|
}
|
|
3291
|
+
CotomyViewRenderer._defaultBindNameGenerator = null;
|
|
2610
3292
|
class CotomyApi {
|
|
2611
3293
|
constructor(_options = {
|
|
2612
3294
|
baseUrl: null, headers: null, credentials: null, redirect: null,
|
|
@@ -3160,12 +3842,6 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
|
|
|
3160
3842
|
}
|
|
3161
3843
|
}
|
|
3162
3844
|
|
|
3163
|
-
// EXTERNAL MODULE: ./node_modules/dayjs/plugin/timezone.js
|
|
3164
|
-
var timezone = __webpack_require__(569);
|
|
3165
|
-
var timezone_default = /*#__PURE__*/__webpack_require__.n(timezone);
|
|
3166
|
-
// EXTERNAL MODULE: ./node_modules/dayjs/plugin/utc.js
|
|
3167
|
-
var utc = __webpack_require__(826);
|
|
3168
|
-
var utc_default = /*#__PURE__*/__webpack_require__.n(utc);
|
|
3169
3845
|
;// ./src/page.ts
|
|
3170
3846
|
|
|
3171
3847
|
|