@semaphore-protocol/identity 4.0.0-beta.1 → 4.0.0-beta.3

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/index.js ADDED
@@ -0,0 +1,2367 @@
1
+ /**
2
+ * @module @semaphore-protocol/identity
3
+ * @version 4.0.0-beta.3
4
+ * @file A library to create Semaphore identities.
5
+ * @copyright Ethereum Foundation 2024
6
+ * @license MIT
7
+ * @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity}
8
+ */
9
+ import { signMessage, verifySignature, EdDSAPoseidon } from '@zk-kit/eddsa-poseidon';
10
+
11
+ function getDefaultExportFromCjs (x) {
12
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13
+ }
14
+
15
+ var buffer = {};
16
+
17
+ var base64Js = {};
18
+
19
+ base64Js.byteLength = byteLength;
20
+ base64Js.toByteArray = toByteArray;
21
+ base64Js.fromByteArray = fromByteArray;
22
+ var lookup = [];
23
+ var revLookup = [];
24
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
25
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
26
+ for (var i = 0, len = code.length; i < len; ++i) {
27
+ lookup[i] = code[i];
28
+ revLookup[code.charCodeAt(i)] = i;
29
+ }
30
+ revLookup['-'.charCodeAt(0)] = 62;
31
+ revLookup['_'.charCodeAt(0)] = 63;
32
+ function getLens (b64) {
33
+ var len = b64.length;
34
+ if (len % 4 > 0) {
35
+ throw new Error('Invalid string. Length must be a multiple of 4')
36
+ }
37
+ var validLen = b64.indexOf('=');
38
+ if (validLen === -1) validLen = len;
39
+ var placeHoldersLen = validLen === len
40
+ ? 0
41
+ : 4 - (validLen % 4);
42
+ return [validLen, placeHoldersLen]
43
+ }
44
+ function byteLength (b64) {
45
+ var lens = getLens(b64);
46
+ var validLen = lens[0];
47
+ var placeHoldersLen = lens[1];
48
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
49
+ }
50
+ function _byteLength (b64, validLen, placeHoldersLen) {
51
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
52
+ }
53
+ function toByteArray (b64) {
54
+ var tmp;
55
+ var lens = getLens(b64);
56
+ var validLen = lens[0];
57
+ var placeHoldersLen = lens[1];
58
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
59
+ var curByte = 0;
60
+ var len = placeHoldersLen > 0
61
+ ? validLen - 4
62
+ : validLen;
63
+ var i;
64
+ for (i = 0; i < len; i += 4) {
65
+ tmp =
66
+ (revLookup[b64.charCodeAt(i)] << 18) |
67
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
68
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
69
+ revLookup[b64.charCodeAt(i + 3)];
70
+ arr[curByte++] = (tmp >> 16) & 0xFF;
71
+ arr[curByte++] = (tmp >> 8) & 0xFF;
72
+ arr[curByte++] = tmp & 0xFF;
73
+ }
74
+ if (placeHoldersLen === 2) {
75
+ tmp =
76
+ (revLookup[b64.charCodeAt(i)] << 2) |
77
+ (revLookup[b64.charCodeAt(i + 1)] >> 4);
78
+ arr[curByte++] = tmp & 0xFF;
79
+ }
80
+ if (placeHoldersLen === 1) {
81
+ tmp =
82
+ (revLookup[b64.charCodeAt(i)] << 10) |
83
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
84
+ (revLookup[b64.charCodeAt(i + 2)] >> 2);
85
+ arr[curByte++] = (tmp >> 8) & 0xFF;
86
+ arr[curByte++] = tmp & 0xFF;
87
+ }
88
+ return arr
89
+ }
90
+ function tripletToBase64 (num) {
91
+ return lookup[num >> 18 & 0x3F] +
92
+ lookup[num >> 12 & 0x3F] +
93
+ lookup[num >> 6 & 0x3F] +
94
+ lookup[num & 0x3F]
95
+ }
96
+ function encodeChunk (uint8, start, end) {
97
+ var tmp;
98
+ var output = [];
99
+ for (var i = start; i < end; i += 3) {
100
+ tmp =
101
+ ((uint8[i] << 16) & 0xFF0000) +
102
+ ((uint8[i + 1] << 8) & 0xFF00) +
103
+ (uint8[i + 2] & 0xFF);
104
+ output.push(tripletToBase64(tmp));
105
+ }
106
+ return output.join('')
107
+ }
108
+ function fromByteArray (uint8) {
109
+ var tmp;
110
+ var len = uint8.length;
111
+ var extraBytes = len % 3;
112
+ var parts = [];
113
+ var maxChunkLength = 16383;
114
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
115
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
116
+ }
117
+ if (extraBytes === 1) {
118
+ tmp = uint8[len - 1];
119
+ parts.push(
120
+ lookup[tmp >> 2] +
121
+ lookup[(tmp << 4) & 0x3F] +
122
+ '=='
123
+ );
124
+ } else if (extraBytes === 2) {
125
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
126
+ parts.push(
127
+ lookup[tmp >> 10] +
128
+ lookup[(tmp >> 4) & 0x3F] +
129
+ lookup[(tmp << 2) & 0x3F] +
130
+ '='
131
+ );
132
+ }
133
+ return parts.join('')
134
+ }
135
+
136
+ var ieee754 = {};
137
+
138
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
139
+ var e, m;
140
+ var eLen = (nBytes * 8) - mLen - 1;
141
+ var eMax = (1 << eLen) - 1;
142
+ var eBias = eMax >> 1;
143
+ var nBits = -7;
144
+ var i = isLE ? (nBytes - 1) : 0;
145
+ var d = isLE ? -1 : 1;
146
+ var s = buffer[offset + i];
147
+ i += d;
148
+ e = s & ((1 << (-nBits)) - 1);
149
+ s >>= (-nBits);
150
+ nBits += eLen;
151
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
152
+ m = e & ((1 << (-nBits)) - 1);
153
+ e >>= (-nBits);
154
+ nBits += mLen;
155
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
156
+ if (e === 0) {
157
+ e = 1 - eBias;
158
+ } else if (e === eMax) {
159
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
160
+ } else {
161
+ m = m + Math.pow(2, mLen);
162
+ e = e - eBias;
163
+ }
164
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
165
+ };
166
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
167
+ var e, m, c;
168
+ var eLen = (nBytes * 8) - mLen - 1;
169
+ var eMax = (1 << eLen) - 1;
170
+ var eBias = eMax >> 1;
171
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
172
+ var i = isLE ? 0 : (nBytes - 1);
173
+ var d = isLE ? 1 : -1;
174
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
175
+ value = Math.abs(value);
176
+ if (isNaN(value) || value === Infinity) {
177
+ m = isNaN(value) ? 1 : 0;
178
+ e = eMax;
179
+ } else {
180
+ e = Math.floor(Math.log(value) / Math.LN2);
181
+ if (value * (c = Math.pow(2, -e)) < 1) {
182
+ e--;
183
+ c *= 2;
184
+ }
185
+ if (e + eBias >= 1) {
186
+ value += rt / c;
187
+ } else {
188
+ value += rt * Math.pow(2, 1 - eBias);
189
+ }
190
+ if (value * c >= 2) {
191
+ e++;
192
+ c /= 2;
193
+ }
194
+ if (e + eBias >= eMax) {
195
+ m = 0;
196
+ e = eMax;
197
+ } else if (e + eBias >= 1) {
198
+ m = ((value * c) - 1) * Math.pow(2, mLen);
199
+ e = e + eBias;
200
+ } else {
201
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
202
+ e = 0;
203
+ }
204
+ }
205
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
206
+ e = (e << mLen) | m;
207
+ eLen += mLen;
208
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
209
+ buffer[offset + i - d] |= s * 128;
210
+ };
211
+
212
+ (function (exports) {
213
+ const base64 = base64Js;
214
+ const ieee754$1 = ieee754;
215
+ const customInspectSymbol =
216
+ (typeof Symbol === 'function' && typeof Symbol['for'] === 'function')
217
+ ? Symbol['for']('nodejs.util.inspect.custom')
218
+ : null;
219
+ exports.Buffer = Buffer;
220
+ exports.SlowBuffer = SlowBuffer;
221
+ exports.INSPECT_MAX_BYTES = 50;
222
+ const K_MAX_LENGTH = 0x7fffffff;
223
+ exports.kMaxLength = K_MAX_LENGTH;
224
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
225
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
226
+ typeof console.error === 'function') {
227
+ console.error(
228
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
229
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
230
+ );
231
+ }
232
+ function typedArraySupport () {
233
+ try {
234
+ const arr = new Uint8Array(1);
235
+ const proto = { foo: function () { return 42 } };
236
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
237
+ Object.setPrototypeOf(arr, proto);
238
+ return arr.foo() === 42
239
+ } catch (e) {
240
+ return false
241
+ }
242
+ }
243
+ Object.defineProperty(Buffer.prototype, 'parent', {
244
+ enumerable: true,
245
+ get: function () {
246
+ if (!Buffer.isBuffer(this)) return undefined
247
+ return this.buffer
248
+ }
249
+ });
250
+ Object.defineProperty(Buffer.prototype, 'offset', {
251
+ enumerable: true,
252
+ get: function () {
253
+ if (!Buffer.isBuffer(this)) return undefined
254
+ return this.byteOffset
255
+ }
256
+ });
257
+ function createBuffer (length) {
258
+ if (length > K_MAX_LENGTH) {
259
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
260
+ }
261
+ const buf = new Uint8Array(length);
262
+ Object.setPrototypeOf(buf, Buffer.prototype);
263
+ return buf
264
+ }
265
+ function Buffer (arg, encodingOrOffset, length) {
266
+ if (typeof arg === 'number') {
267
+ if (typeof encodingOrOffset === 'string') {
268
+ throw new TypeError(
269
+ 'The "string" argument must be of type string. Received type number'
270
+ )
271
+ }
272
+ return allocUnsafe(arg)
273
+ }
274
+ return from(arg, encodingOrOffset, length)
275
+ }
276
+ Buffer.poolSize = 8192;
277
+ function from (value, encodingOrOffset, length) {
278
+ if (typeof value === 'string') {
279
+ return fromString(value, encodingOrOffset)
280
+ }
281
+ if (ArrayBuffer.isView(value)) {
282
+ return fromArrayView(value)
283
+ }
284
+ if (value == null) {
285
+ throw new TypeError(
286
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
287
+ 'or Array-like Object. Received type ' + (typeof value)
288
+ )
289
+ }
290
+ if (isInstance(value, ArrayBuffer) ||
291
+ (value && isInstance(value.buffer, ArrayBuffer))) {
292
+ return fromArrayBuffer(value, encodingOrOffset, length)
293
+ }
294
+ if (typeof SharedArrayBuffer !== 'undefined' &&
295
+ (isInstance(value, SharedArrayBuffer) ||
296
+ (value && isInstance(value.buffer, SharedArrayBuffer)))) {
297
+ return fromArrayBuffer(value, encodingOrOffset, length)
298
+ }
299
+ if (typeof value === 'number') {
300
+ throw new TypeError(
301
+ 'The "value" argument must not be of type number. Received type number'
302
+ )
303
+ }
304
+ const valueOf = value.valueOf && value.valueOf();
305
+ if (valueOf != null && valueOf !== value) {
306
+ return Buffer.from(valueOf, encodingOrOffset, length)
307
+ }
308
+ const b = fromObject(value);
309
+ if (b) return b
310
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
311
+ typeof value[Symbol.toPrimitive] === 'function') {
312
+ return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
313
+ }
314
+ throw new TypeError(
315
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
316
+ 'or Array-like Object. Received type ' + (typeof value)
317
+ )
318
+ }
319
+ Buffer.from = function (value, encodingOrOffset, length) {
320
+ return from(value, encodingOrOffset, length)
321
+ };
322
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
323
+ Object.setPrototypeOf(Buffer, Uint8Array);
324
+ function assertSize (size) {
325
+ if (typeof size !== 'number') {
326
+ throw new TypeError('"size" argument must be of type number')
327
+ } else if (size < 0) {
328
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
329
+ }
330
+ }
331
+ function alloc (size, fill, encoding) {
332
+ assertSize(size);
333
+ if (size <= 0) {
334
+ return createBuffer(size)
335
+ }
336
+ if (fill !== undefined) {
337
+ return typeof encoding === 'string'
338
+ ? createBuffer(size).fill(fill, encoding)
339
+ : createBuffer(size).fill(fill)
340
+ }
341
+ return createBuffer(size)
342
+ }
343
+ Buffer.alloc = function (size, fill, encoding) {
344
+ return alloc(size, fill, encoding)
345
+ };
346
+ function allocUnsafe (size) {
347
+ assertSize(size);
348
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
349
+ }
350
+ Buffer.allocUnsafe = function (size) {
351
+ return allocUnsafe(size)
352
+ };
353
+ Buffer.allocUnsafeSlow = function (size) {
354
+ return allocUnsafe(size)
355
+ };
356
+ function fromString (string, encoding) {
357
+ if (typeof encoding !== 'string' || encoding === '') {
358
+ encoding = 'utf8';
359
+ }
360
+ if (!Buffer.isEncoding(encoding)) {
361
+ throw new TypeError('Unknown encoding: ' + encoding)
362
+ }
363
+ const length = byteLength(string, encoding) | 0;
364
+ let buf = createBuffer(length);
365
+ const actual = buf.write(string, encoding);
366
+ if (actual !== length) {
367
+ buf = buf.slice(0, actual);
368
+ }
369
+ return buf
370
+ }
371
+ function fromArrayLike (array) {
372
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
373
+ const buf = createBuffer(length);
374
+ for (let i = 0; i < length; i += 1) {
375
+ buf[i] = array[i] & 255;
376
+ }
377
+ return buf
378
+ }
379
+ function fromArrayView (arrayView) {
380
+ if (isInstance(arrayView, Uint8Array)) {
381
+ const copy = new Uint8Array(arrayView);
382
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
383
+ }
384
+ return fromArrayLike(arrayView)
385
+ }
386
+ function fromArrayBuffer (array, byteOffset, length) {
387
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
388
+ throw new RangeError('"offset" is outside of buffer bounds')
389
+ }
390
+ if (array.byteLength < byteOffset + (length || 0)) {
391
+ throw new RangeError('"length" is outside of buffer bounds')
392
+ }
393
+ let buf;
394
+ if (byteOffset === undefined && length === undefined) {
395
+ buf = new Uint8Array(array);
396
+ } else if (length === undefined) {
397
+ buf = new Uint8Array(array, byteOffset);
398
+ } else {
399
+ buf = new Uint8Array(array, byteOffset, length);
400
+ }
401
+ Object.setPrototypeOf(buf, Buffer.prototype);
402
+ return buf
403
+ }
404
+ function fromObject (obj) {
405
+ if (Buffer.isBuffer(obj)) {
406
+ const len = checked(obj.length) | 0;
407
+ const buf = createBuffer(len);
408
+ if (buf.length === 0) {
409
+ return buf
410
+ }
411
+ obj.copy(buf, 0, 0, len);
412
+ return buf
413
+ }
414
+ if (obj.length !== undefined) {
415
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
416
+ return createBuffer(0)
417
+ }
418
+ return fromArrayLike(obj)
419
+ }
420
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
421
+ return fromArrayLike(obj.data)
422
+ }
423
+ }
424
+ function checked (length) {
425
+ if (length >= K_MAX_LENGTH) {
426
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
427
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
428
+ }
429
+ return length | 0
430
+ }
431
+ function SlowBuffer (length) {
432
+ if (+length != length) {
433
+ length = 0;
434
+ }
435
+ return Buffer.alloc(+length)
436
+ }
437
+ Buffer.isBuffer = function isBuffer (b) {
438
+ return b != null && b._isBuffer === true &&
439
+ b !== Buffer.prototype
440
+ };
441
+ Buffer.compare = function compare (a, b) {
442
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
443
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
444
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
445
+ throw new TypeError(
446
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
447
+ )
448
+ }
449
+ if (a === b) return 0
450
+ let x = a.length;
451
+ let y = b.length;
452
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
453
+ if (a[i] !== b[i]) {
454
+ x = a[i];
455
+ y = b[i];
456
+ break
457
+ }
458
+ }
459
+ if (x < y) return -1
460
+ if (y < x) return 1
461
+ return 0
462
+ };
463
+ Buffer.isEncoding = function isEncoding (encoding) {
464
+ switch (String(encoding).toLowerCase()) {
465
+ case 'hex':
466
+ case 'utf8':
467
+ case 'utf-8':
468
+ case 'ascii':
469
+ case 'latin1':
470
+ case 'binary':
471
+ case 'base64':
472
+ case 'ucs2':
473
+ case 'ucs-2':
474
+ case 'utf16le':
475
+ case 'utf-16le':
476
+ return true
477
+ default:
478
+ return false
479
+ }
480
+ };
481
+ Buffer.concat = function concat (list, length) {
482
+ if (!Array.isArray(list)) {
483
+ throw new TypeError('"list" argument must be an Array of Buffers')
484
+ }
485
+ if (list.length === 0) {
486
+ return Buffer.alloc(0)
487
+ }
488
+ let i;
489
+ if (length === undefined) {
490
+ length = 0;
491
+ for (i = 0; i < list.length; ++i) {
492
+ length += list[i].length;
493
+ }
494
+ }
495
+ const buffer = Buffer.allocUnsafe(length);
496
+ let pos = 0;
497
+ for (i = 0; i < list.length; ++i) {
498
+ let buf = list[i];
499
+ if (isInstance(buf, Uint8Array)) {
500
+ if (pos + buf.length > buffer.length) {
501
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
502
+ buf.copy(buffer, pos);
503
+ } else {
504
+ Uint8Array.prototype.set.call(
505
+ buffer,
506
+ buf,
507
+ pos
508
+ );
509
+ }
510
+ } else if (!Buffer.isBuffer(buf)) {
511
+ throw new TypeError('"list" argument must be an Array of Buffers')
512
+ } else {
513
+ buf.copy(buffer, pos);
514
+ }
515
+ pos += buf.length;
516
+ }
517
+ return buffer
518
+ };
519
+ function byteLength (string, encoding) {
520
+ if (Buffer.isBuffer(string)) {
521
+ return string.length
522
+ }
523
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
524
+ return string.byteLength
525
+ }
526
+ if (typeof string !== 'string') {
527
+ throw new TypeError(
528
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
529
+ 'Received type ' + typeof string
530
+ )
531
+ }
532
+ const len = string.length;
533
+ const mustMatch = (arguments.length > 2 && arguments[2] === true);
534
+ if (!mustMatch && len === 0) return 0
535
+ let loweredCase = false;
536
+ for (;;) {
537
+ switch (encoding) {
538
+ case 'ascii':
539
+ case 'latin1':
540
+ case 'binary':
541
+ return len
542
+ case 'utf8':
543
+ case 'utf-8':
544
+ return utf8ToBytes(string).length
545
+ case 'ucs2':
546
+ case 'ucs-2':
547
+ case 'utf16le':
548
+ case 'utf-16le':
549
+ return len * 2
550
+ case 'hex':
551
+ return len >>> 1
552
+ case 'base64':
553
+ return base64ToBytes(string).length
554
+ default:
555
+ if (loweredCase) {
556
+ return mustMatch ? -1 : utf8ToBytes(string).length
557
+ }
558
+ encoding = ('' + encoding).toLowerCase();
559
+ loweredCase = true;
560
+ }
561
+ }
562
+ }
563
+ Buffer.byteLength = byteLength;
564
+ function slowToString (encoding, start, end) {
565
+ let loweredCase = false;
566
+ if (start === undefined || start < 0) {
567
+ start = 0;
568
+ }
569
+ if (start > this.length) {
570
+ return ''
571
+ }
572
+ if (end === undefined || end > this.length) {
573
+ end = this.length;
574
+ }
575
+ if (end <= 0) {
576
+ return ''
577
+ }
578
+ end >>>= 0;
579
+ start >>>= 0;
580
+ if (end <= start) {
581
+ return ''
582
+ }
583
+ if (!encoding) encoding = 'utf8';
584
+ while (true) {
585
+ switch (encoding) {
586
+ case 'hex':
587
+ return hexSlice(this, start, end)
588
+ case 'utf8':
589
+ case 'utf-8':
590
+ return utf8Slice(this, start, end)
591
+ case 'ascii':
592
+ return asciiSlice(this, start, end)
593
+ case 'latin1':
594
+ case 'binary':
595
+ return latin1Slice(this, start, end)
596
+ case 'base64':
597
+ return base64Slice(this, start, end)
598
+ case 'ucs2':
599
+ case 'ucs-2':
600
+ case 'utf16le':
601
+ case 'utf-16le':
602
+ return utf16leSlice(this, start, end)
603
+ default:
604
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
605
+ encoding = (encoding + '').toLowerCase();
606
+ loweredCase = true;
607
+ }
608
+ }
609
+ }
610
+ Buffer.prototype._isBuffer = true;
611
+ function swap (b, n, m) {
612
+ const i = b[n];
613
+ b[n] = b[m];
614
+ b[m] = i;
615
+ }
616
+ Buffer.prototype.swap16 = function swap16 () {
617
+ const len = this.length;
618
+ if (len % 2 !== 0) {
619
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
620
+ }
621
+ for (let i = 0; i < len; i += 2) {
622
+ swap(this, i, i + 1);
623
+ }
624
+ return this
625
+ };
626
+ Buffer.prototype.swap32 = function swap32 () {
627
+ const len = this.length;
628
+ if (len % 4 !== 0) {
629
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
630
+ }
631
+ for (let i = 0; i < len; i += 4) {
632
+ swap(this, i, i + 3);
633
+ swap(this, i + 1, i + 2);
634
+ }
635
+ return this
636
+ };
637
+ Buffer.prototype.swap64 = function swap64 () {
638
+ const len = this.length;
639
+ if (len % 8 !== 0) {
640
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
641
+ }
642
+ for (let i = 0; i < len; i += 8) {
643
+ swap(this, i, i + 7);
644
+ swap(this, i + 1, i + 6);
645
+ swap(this, i + 2, i + 5);
646
+ swap(this, i + 3, i + 4);
647
+ }
648
+ return this
649
+ };
650
+ Buffer.prototype.toString = function toString () {
651
+ const length = this.length;
652
+ if (length === 0) return ''
653
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
654
+ return slowToString.apply(this, arguments)
655
+ };
656
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
657
+ Buffer.prototype.equals = function equals (b) {
658
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
659
+ if (this === b) return true
660
+ return Buffer.compare(this, b) === 0
661
+ };
662
+ Buffer.prototype.inspect = function inspect () {
663
+ let str = '';
664
+ const max = exports.INSPECT_MAX_BYTES;
665
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
666
+ if (this.length > max) str += ' ... ';
667
+ return '<Buffer ' + str + '>'
668
+ };
669
+ if (customInspectSymbol) {
670
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
671
+ }
672
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
673
+ if (isInstance(target, Uint8Array)) {
674
+ target = Buffer.from(target, target.offset, target.byteLength);
675
+ }
676
+ if (!Buffer.isBuffer(target)) {
677
+ throw new TypeError(
678
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
679
+ 'Received type ' + (typeof target)
680
+ )
681
+ }
682
+ if (start === undefined) {
683
+ start = 0;
684
+ }
685
+ if (end === undefined) {
686
+ end = target ? target.length : 0;
687
+ }
688
+ if (thisStart === undefined) {
689
+ thisStart = 0;
690
+ }
691
+ if (thisEnd === undefined) {
692
+ thisEnd = this.length;
693
+ }
694
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
695
+ throw new RangeError('out of range index')
696
+ }
697
+ if (thisStart >= thisEnd && start >= end) {
698
+ return 0
699
+ }
700
+ if (thisStart >= thisEnd) {
701
+ return -1
702
+ }
703
+ if (start >= end) {
704
+ return 1
705
+ }
706
+ start >>>= 0;
707
+ end >>>= 0;
708
+ thisStart >>>= 0;
709
+ thisEnd >>>= 0;
710
+ if (this === target) return 0
711
+ let x = thisEnd - thisStart;
712
+ let y = end - start;
713
+ const len = Math.min(x, y);
714
+ const thisCopy = this.slice(thisStart, thisEnd);
715
+ const targetCopy = target.slice(start, end);
716
+ for (let i = 0; i < len; ++i) {
717
+ if (thisCopy[i] !== targetCopy[i]) {
718
+ x = thisCopy[i];
719
+ y = targetCopy[i];
720
+ break
721
+ }
722
+ }
723
+ if (x < y) return -1
724
+ if (y < x) return 1
725
+ return 0
726
+ };
727
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
728
+ if (buffer.length === 0) return -1
729
+ if (typeof byteOffset === 'string') {
730
+ encoding = byteOffset;
731
+ byteOffset = 0;
732
+ } else if (byteOffset > 0x7fffffff) {
733
+ byteOffset = 0x7fffffff;
734
+ } else if (byteOffset < -0x80000000) {
735
+ byteOffset = -0x80000000;
736
+ }
737
+ byteOffset = +byteOffset;
738
+ if (numberIsNaN(byteOffset)) {
739
+ byteOffset = dir ? 0 : (buffer.length - 1);
740
+ }
741
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
742
+ if (byteOffset >= buffer.length) {
743
+ if (dir) return -1
744
+ else byteOffset = buffer.length - 1;
745
+ } else if (byteOffset < 0) {
746
+ if (dir) byteOffset = 0;
747
+ else return -1
748
+ }
749
+ if (typeof val === 'string') {
750
+ val = Buffer.from(val, encoding);
751
+ }
752
+ if (Buffer.isBuffer(val)) {
753
+ if (val.length === 0) {
754
+ return -1
755
+ }
756
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
757
+ } else if (typeof val === 'number') {
758
+ val = val & 0xFF;
759
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
760
+ if (dir) {
761
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
762
+ } else {
763
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
764
+ }
765
+ }
766
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
767
+ }
768
+ throw new TypeError('val must be string, number or Buffer')
769
+ }
770
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
771
+ let indexSize = 1;
772
+ let arrLength = arr.length;
773
+ let valLength = val.length;
774
+ if (encoding !== undefined) {
775
+ encoding = String(encoding).toLowerCase();
776
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
777
+ encoding === 'utf16le' || encoding === 'utf-16le') {
778
+ if (arr.length < 2 || val.length < 2) {
779
+ return -1
780
+ }
781
+ indexSize = 2;
782
+ arrLength /= 2;
783
+ valLength /= 2;
784
+ byteOffset /= 2;
785
+ }
786
+ }
787
+ function read (buf, i) {
788
+ if (indexSize === 1) {
789
+ return buf[i]
790
+ } else {
791
+ return buf.readUInt16BE(i * indexSize)
792
+ }
793
+ }
794
+ let i;
795
+ if (dir) {
796
+ let foundIndex = -1;
797
+ for (i = byteOffset; i < arrLength; i++) {
798
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
799
+ if (foundIndex === -1) foundIndex = i;
800
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
801
+ } else {
802
+ if (foundIndex !== -1) i -= i - foundIndex;
803
+ foundIndex = -1;
804
+ }
805
+ }
806
+ } else {
807
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
808
+ for (i = byteOffset; i >= 0; i--) {
809
+ let found = true;
810
+ for (let j = 0; j < valLength; j++) {
811
+ if (read(arr, i + j) !== read(val, j)) {
812
+ found = false;
813
+ break
814
+ }
815
+ }
816
+ if (found) return i
817
+ }
818
+ }
819
+ return -1
820
+ }
821
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
822
+ return this.indexOf(val, byteOffset, encoding) !== -1
823
+ };
824
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
825
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
826
+ };
827
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
828
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
829
+ };
830
+ function hexWrite (buf, string, offset, length) {
831
+ offset = Number(offset) || 0;
832
+ const remaining = buf.length - offset;
833
+ if (!length) {
834
+ length = remaining;
835
+ } else {
836
+ length = Number(length);
837
+ if (length > remaining) {
838
+ length = remaining;
839
+ }
840
+ }
841
+ const strLen = string.length;
842
+ if (length > strLen / 2) {
843
+ length = strLen / 2;
844
+ }
845
+ let i;
846
+ for (i = 0; i < length; ++i) {
847
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
848
+ if (numberIsNaN(parsed)) return i
849
+ buf[offset + i] = parsed;
850
+ }
851
+ return i
852
+ }
853
+ function utf8Write (buf, string, offset, length) {
854
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
855
+ }
856
+ function asciiWrite (buf, string, offset, length) {
857
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
858
+ }
859
+ function base64Write (buf, string, offset, length) {
860
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
861
+ }
862
+ function ucs2Write (buf, string, offset, length) {
863
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
864
+ }
865
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
866
+ if (offset === undefined) {
867
+ encoding = 'utf8';
868
+ length = this.length;
869
+ offset = 0;
870
+ } else if (length === undefined && typeof offset === 'string') {
871
+ encoding = offset;
872
+ length = this.length;
873
+ offset = 0;
874
+ } else if (isFinite(offset)) {
875
+ offset = offset >>> 0;
876
+ if (isFinite(length)) {
877
+ length = length >>> 0;
878
+ if (encoding === undefined) encoding = 'utf8';
879
+ } else {
880
+ encoding = length;
881
+ length = undefined;
882
+ }
883
+ } else {
884
+ throw new Error(
885
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
886
+ )
887
+ }
888
+ const remaining = this.length - offset;
889
+ if (length === undefined || length > remaining) length = remaining;
890
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
891
+ throw new RangeError('Attempt to write outside buffer bounds')
892
+ }
893
+ if (!encoding) encoding = 'utf8';
894
+ let loweredCase = false;
895
+ for (;;) {
896
+ switch (encoding) {
897
+ case 'hex':
898
+ return hexWrite(this, string, offset, length)
899
+ case 'utf8':
900
+ case 'utf-8':
901
+ return utf8Write(this, string, offset, length)
902
+ case 'ascii':
903
+ case 'latin1':
904
+ case 'binary':
905
+ return asciiWrite(this, string, offset, length)
906
+ case 'base64':
907
+ return base64Write(this, string, offset, length)
908
+ case 'ucs2':
909
+ case 'ucs-2':
910
+ case 'utf16le':
911
+ case 'utf-16le':
912
+ return ucs2Write(this, string, offset, length)
913
+ default:
914
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
915
+ encoding = ('' + encoding).toLowerCase();
916
+ loweredCase = true;
917
+ }
918
+ }
919
+ };
920
+ Buffer.prototype.toJSON = function toJSON () {
921
+ return {
922
+ type: 'Buffer',
923
+ data: Array.prototype.slice.call(this._arr || this, 0)
924
+ }
925
+ };
926
+ function base64Slice (buf, start, end) {
927
+ if (start === 0 && end === buf.length) {
928
+ return base64.fromByteArray(buf)
929
+ } else {
930
+ return base64.fromByteArray(buf.slice(start, end))
931
+ }
932
+ }
933
+ function utf8Slice (buf, start, end) {
934
+ end = Math.min(buf.length, end);
935
+ const res = [];
936
+ let i = start;
937
+ while (i < end) {
938
+ const firstByte = buf[i];
939
+ let codePoint = null;
940
+ let bytesPerSequence = (firstByte > 0xEF)
941
+ ? 4
942
+ : (firstByte > 0xDF)
943
+ ? 3
944
+ : (firstByte > 0xBF)
945
+ ? 2
946
+ : 1;
947
+ if (i + bytesPerSequence <= end) {
948
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
949
+ switch (bytesPerSequence) {
950
+ case 1:
951
+ if (firstByte < 0x80) {
952
+ codePoint = firstByte;
953
+ }
954
+ break
955
+ case 2:
956
+ secondByte = buf[i + 1];
957
+ if ((secondByte & 0xC0) === 0x80) {
958
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
959
+ if (tempCodePoint > 0x7F) {
960
+ codePoint = tempCodePoint;
961
+ }
962
+ }
963
+ break
964
+ case 3:
965
+ secondByte = buf[i + 1];
966
+ thirdByte = buf[i + 2];
967
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
968
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
969
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
970
+ codePoint = tempCodePoint;
971
+ }
972
+ }
973
+ break
974
+ case 4:
975
+ secondByte = buf[i + 1];
976
+ thirdByte = buf[i + 2];
977
+ fourthByte = buf[i + 3];
978
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
979
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
980
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
981
+ codePoint = tempCodePoint;
982
+ }
983
+ }
984
+ }
985
+ }
986
+ if (codePoint === null) {
987
+ codePoint = 0xFFFD;
988
+ bytesPerSequence = 1;
989
+ } else if (codePoint > 0xFFFF) {
990
+ codePoint -= 0x10000;
991
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800);
992
+ codePoint = 0xDC00 | codePoint & 0x3FF;
993
+ }
994
+ res.push(codePoint);
995
+ i += bytesPerSequence;
996
+ }
997
+ return decodeCodePointsArray(res)
998
+ }
999
+ const MAX_ARGUMENTS_LENGTH = 0x1000;
1000
+ function decodeCodePointsArray (codePoints) {
1001
+ const len = codePoints.length;
1002
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1003
+ return String.fromCharCode.apply(String, codePoints)
1004
+ }
1005
+ let res = '';
1006
+ let i = 0;
1007
+ while (i < len) {
1008
+ res += String.fromCharCode.apply(
1009
+ String,
1010
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1011
+ );
1012
+ }
1013
+ return res
1014
+ }
1015
+ function asciiSlice (buf, start, end) {
1016
+ let ret = '';
1017
+ end = Math.min(buf.length, end);
1018
+ for (let i = start; i < end; ++i) {
1019
+ ret += String.fromCharCode(buf[i] & 0x7F);
1020
+ }
1021
+ return ret
1022
+ }
1023
+ function latin1Slice (buf, start, end) {
1024
+ let ret = '';
1025
+ end = Math.min(buf.length, end);
1026
+ for (let i = start; i < end; ++i) {
1027
+ ret += String.fromCharCode(buf[i]);
1028
+ }
1029
+ return ret
1030
+ }
1031
+ function hexSlice (buf, start, end) {
1032
+ const len = buf.length;
1033
+ if (!start || start < 0) start = 0;
1034
+ if (!end || end < 0 || end > len) end = len;
1035
+ let out = '';
1036
+ for (let i = start; i < end; ++i) {
1037
+ out += hexSliceLookupTable[buf[i]];
1038
+ }
1039
+ return out
1040
+ }
1041
+ function utf16leSlice (buf, start, end) {
1042
+ const bytes = buf.slice(start, end);
1043
+ let res = '';
1044
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1045
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
1046
+ }
1047
+ return res
1048
+ }
1049
+ Buffer.prototype.slice = function slice (start, end) {
1050
+ const len = this.length;
1051
+ start = ~~start;
1052
+ end = end === undefined ? len : ~~end;
1053
+ if (start < 0) {
1054
+ start += len;
1055
+ if (start < 0) start = 0;
1056
+ } else if (start > len) {
1057
+ start = len;
1058
+ }
1059
+ if (end < 0) {
1060
+ end += len;
1061
+ if (end < 0) end = 0;
1062
+ } else if (end > len) {
1063
+ end = len;
1064
+ }
1065
+ if (end < start) end = start;
1066
+ const newBuf = this.subarray(start, end);
1067
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
1068
+ return newBuf
1069
+ };
1070
+ function checkOffset (offset, ext, length) {
1071
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1072
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1073
+ }
1074
+ Buffer.prototype.readUintLE =
1075
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1076
+ offset = offset >>> 0;
1077
+ byteLength = byteLength >>> 0;
1078
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
1079
+ let val = this[offset];
1080
+ let mul = 1;
1081
+ let i = 0;
1082
+ while (++i < byteLength && (mul *= 0x100)) {
1083
+ val += this[offset + i] * mul;
1084
+ }
1085
+ return val
1086
+ };
1087
+ Buffer.prototype.readUintBE =
1088
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1089
+ offset = offset >>> 0;
1090
+ byteLength = byteLength >>> 0;
1091
+ if (!noAssert) {
1092
+ checkOffset(offset, byteLength, this.length);
1093
+ }
1094
+ let val = this[offset + --byteLength];
1095
+ let mul = 1;
1096
+ while (byteLength > 0 && (mul *= 0x100)) {
1097
+ val += this[offset + --byteLength] * mul;
1098
+ }
1099
+ return val
1100
+ };
1101
+ Buffer.prototype.readUint8 =
1102
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1103
+ offset = offset >>> 0;
1104
+ if (!noAssert) checkOffset(offset, 1, this.length);
1105
+ return this[offset]
1106
+ };
1107
+ Buffer.prototype.readUint16LE =
1108
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1109
+ offset = offset >>> 0;
1110
+ if (!noAssert) checkOffset(offset, 2, this.length);
1111
+ return this[offset] | (this[offset + 1] << 8)
1112
+ };
1113
+ Buffer.prototype.readUint16BE =
1114
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1115
+ offset = offset >>> 0;
1116
+ if (!noAssert) checkOffset(offset, 2, this.length);
1117
+ return (this[offset] << 8) | this[offset + 1]
1118
+ };
1119
+ Buffer.prototype.readUint32LE =
1120
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1121
+ offset = offset >>> 0;
1122
+ if (!noAssert) checkOffset(offset, 4, this.length);
1123
+ return ((this[offset]) |
1124
+ (this[offset + 1] << 8) |
1125
+ (this[offset + 2] << 16)) +
1126
+ (this[offset + 3] * 0x1000000)
1127
+ };
1128
+ Buffer.prototype.readUint32BE =
1129
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1130
+ offset = offset >>> 0;
1131
+ if (!noAssert) checkOffset(offset, 4, this.length);
1132
+ return (this[offset] * 0x1000000) +
1133
+ ((this[offset + 1] << 16) |
1134
+ (this[offset + 2] << 8) |
1135
+ this[offset + 3])
1136
+ };
1137
+ Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
1138
+ offset = offset >>> 0;
1139
+ validateNumber(offset, 'offset');
1140
+ const first = this[offset];
1141
+ const last = this[offset + 7];
1142
+ if (first === undefined || last === undefined) {
1143
+ boundsError(offset, this.length - 8);
1144
+ }
1145
+ const lo = first +
1146
+ this[++offset] * 2 ** 8 +
1147
+ this[++offset] * 2 ** 16 +
1148
+ this[++offset] * 2 ** 24;
1149
+ const hi = this[++offset] +
1150
+ this[++offset] * 2 ** 8 +
1151
+ this[++offset] * 2 ** 16 +
1152
+ last * 2 ** 24;
1153
+ return BigInt(lo) + (BigInt(hi) << BigInt(32))
1154
+ });
1155
+ Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
1156
+ offset = offset >>> 0;
1157
+ validateNumber(offset, 'offset');
1158
+ const first = this[offset];
1159
+ const last = this[offset + 7];
1160
+ if (first === undefined || last === undefined) {
1161
+ boundsError(offset, this.length - 8);
1162
+ }
1163
+ const hi = first * 2 ** 24 +
1164
+ this[++offset] * 2 ** 16 +
1165
+ this[++offset] * 2 ** 8 +
1166
+ this[++offset];
1167
+ const lo = this[++offset] * 2 ** 24 +
1168
+ this[++offset] * 2 ** 16 +
1169
+ this[++offset] * 2 ** 8 +
1170
+ last;
1171
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo)
1172
+ });
1173
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1174
+ offset = offset >>> 0;
1175
+ byteLength = byteLength >>> 0;
1176
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
1177
+ let val = this[offset];
1178
+ let mul = 1;
1179
+ let i = 0;
1180
+ while (++i < byteLength && (mul *= 0x100)) {
1181
+ val += this[offset + i] * mul;
1182
+ }
1183
+ mul *= 0x80;
1184
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1185
+ return val
1186
+ };
1187
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1188
+ offset = offset >>> 0;
1189
+ byteLength = byteLength >>> 0;
1190
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
1191
+ let i = byteLength;
1192
+ let mul = 1;
1193
+ let val = this[offset + --i];
1194
+ while (i > 0 && (mul *= 0x100)) {
1195
+ val += this[offset + --i] * mul;
1196
+ }
1197
+ mul *= 0x80;
1198
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1199
+ return val
1200
+ };
1201
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1202
+ offset = offset >>> 0;
1203
+ if (!noAssert) checkOffset(offset, 1, this.length);
1204
+ if (!(this[offset] & 0x80)) return (this[offset])
1205
+ return ((0xff - this[offset] + 1) * -1)
1206
+ };
1207
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1208
+ offset = offset >>> 0;
1209
+ if (!noAssert) checkOffset(offset, 2, this.length);
1210
+ const val = this[offset] | (this[offset + 1] << 8);
1211
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
1212
+ };
1213
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1214
+ offset = offset >>> 0;
1215
+ if (!noAssert) checkOffset(offset, 2, this.length);
1216
+ const val = this[offset + 1] | (this[offset] << 8);
1217
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
1218
+ };
1219
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1220
+ offset = offset >>> 0;
1221
+ if (!noAssert) checkOffset(offset, 4, this.length);
1222
+ return (this[offset]) |
1223
+ (this[offset + 1] << 8) |
1224
+ (this[offset + 2] << 16) |
1225
+ (this[offset + 3] << 24)
1226
+ };
1227
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1228
+ offset = offset >>> 0;
1229
+ if (!noAssert) checkOffset(offset, 4, this.length);
1230
+ return (this[offset] << 24) |
1231
+ (this[offset + 1] << 16) |
1232
+ (this[offset + 2] << 8) |
1233
+ (this[offset + 3])
1234
+ };
1235
+ Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
1236
+ offset = offset >>> 0;
1237
+ validateNumber(offset, 'offset');
1238
+ const first = this[offset];
1239
+ const last = this[offset + 7];
1240
+ if (first === undefined || last === undefined) {
1241
+ boundsError(offset, this.length - 8);
1242
+ }
1243
+ const val = this[offset + 4] +
1244
+ this[offset + 5] * 2 ** 8 +
1245
+ this[offset + 6] * 2 ** 16 +
1246
+ (last << 24);
1247
+ return (BigInt(val) << BigInt(32)) +
1248
+ BigInt(first +
1249
+ this[++offset] * 2 ** 8 +
1250
+ this[++offset] * 2 ** 16 +
1251
+ this[++offset] * 2 ** 24)
1252
+ });
1253
+ Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
1254
+ offset = offset >>> 0;
1255
+ validateNumber(offset, 'offset');
1256
+ const first = this[offset];
1257
+ const last = this[offset + 7];
1258
+ if (first === undefined || last === undefined) {
1259
+ boundsError(offset, this.length - 8);
1260
+ }
1261
+ const val = (first << 24) +
1262
+ this[++offset] * 2 ** 16 +
1263
+ this[++offset] * 2 ** 8 +
1264
+ this[++offset];
1265
+ return (BigInt(val) << BigInt(32)) +
1266
+ BigInt(this[++offset] * 2 ** 24 +
1267
+ this[++offset] * 2 ** 16 +
1268
+ this[++offset] * 2 ** 8 +
1269
+ last)
1270
+ });
1271
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1272
+ offset = offset >>> 0;
1273
+ if (!noAssert) checkOffset(offset, 4, this.length);
1274
+ return ieee754$1.read(this, offset, true, 23, 4)
1275
+ };
1276
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1277
+ offset = offset >>> 0;
1278
+ if (!noAssert) checkOffset(offset, 4, this.length);
1279
+ return ieee754$1.read(this, offset, false, 23, 4)
1280
+ };
1281
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1282
+ offset = offset >>> 0;
1283
+ if (!noAssert) checkOffset(offset, 8, this.length);
1284
+ return ieee754$1.read(this, offset, true, 52, 8)
1285
+ };
1286
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1287
+ offset = offset >>> 0;
1288
+ if (!noAssert) checkOffset(offset, 8, this.length);
1289
+ return ieee754$1.read(this, offset, false, 52, 8)
1290
+ };
1291
+ function checkInt (buf, value, offset, ext, max, min) {
1292
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1293
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1294
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
1295
+ }
1296
+ Buffer.prototype.writeUintLE =
1297
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1298
+ value = +value;
1299
+ offset = offset >>> 0;
1300
+ byteLength = byteLength >>> 0;
1301
+ if (!noAssert) {
1302
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1303
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
1304
+ }
1305
+ let mul = 1;
1306
+ let i = 0;
1307
+ this[offset] = value & 0xFF;
1308
+ while (++i < byteLength && (mul *= 0x100)) {
1309
+ this[offset + i] = (value / mul) & 0xFF;
1310
+ }
1311
+ return offset + byteLength
1312
+ };
1313
+ Buffer.prototype.writeUintBE =
1314
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1315
+ value = +value;
1316
+ offset = offset >>> 0;
1317
+ byteLength = byteLength >>> 0;
1318
+ if (!noAssert) {
1319
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1320
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
1321
+ }
1322
+ let i = byteLength - 1;
1323
+ let mul = 1;
1324
+ this[offset + i] = value & 0xFF;
1325
+ while (--i >= 0 && (mul *= 0x100)) {
1326
+ this[offset + i] = (value / mul) & 0xFF;
1327
+ }
1328
+ return offset + byteLength
1329
+ };
1330
+ Buffer.prototype.writeUint8 =
1331
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1332
+ value = +value;
1333
+ offset = offset >>> 0;
1334
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
1335
+ this[offset] = (value & 0xff);
1336
+ return offset + 1
1337
+ };
1338
+ Buffer.prototype.writeUint16LE =
1339
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1340
+ value = +value;
1341
+ offset = offset >>> 0;
1342
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1343
+ this[offset] = (value & 0xff);
1344
+ this[offset + 1] = (value >>> 8);
1345
+ return offset + 2
1346
+ };
1347
+ Buffer.prototype.writeUint16BE =
1348
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1349
+ value = +value;
1350
+ offset = offset >>> 0;
1351
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1352
+ this[offset] = (value >>> 8);
1353
+ this[offset + 1] = (value & 0xff);
1354
+ return offset + 2
1355
+ };
1356
+ Buffer.prototype.writeUint32LE =
1357
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1358
+ value = +value;
1359
+ offset = offset >>> 0;
1360
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1361
+ this[offset + 3] = (value >>> 24);
1362
+ this[offset + 2] = (value >>> 16);
1363
+ this[offset + 1] = (value >>> 8);
1364
+ this[offset] = (value & 0xff);
1365
+ return offset + 4
1366
+ };
1367
+ Buffer.prototype.writeUint32BE =
1368
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1369
+ value = +value;
1370
+ offset = offset >>> 0;
1371
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1372
+ this[offset] = (value >>> 24);
1373
+ this[offset + 1] = (value >>> 16);
1374
+ this[offset + 2] = (value >>> 8);
1375
+ this[offset + 3] = (value & 0xff);
1376
+ return offset + 4
1377
+ };
1378
+ function wrtBigUInt64LE (buf, value, offset, min, max) {
1379
+ checkIntBI(value, min, max, buf, offset, 7);
1380
+ let lo = Number(value & BigInt(0xffffffff));
1381
+ buf[offset++] = lo;
1382
+ lo = lo >> 8;
1383
+ buf[offset++] = lo;
1384
+ lo = lo >> 8;
1385
+ buf[offset++] = lo;
1386
+ lo = lo >> 8;
1387
+ buf[offset++] = lo;
1388
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1389
+ buf[offset++] = hi;
1390
+ hi = hi >> 8;
1391
+ buf[offset++] = hi;
1392
+ hi = hi >> 8;
1393
+ buf[offset++] = hi;
1394
+ hi = hi >> 8;
1395
+ buf[offset++] = hi;
1396
+ return offset
1397
+ }
1398
+ function wrtBigUInt64BE (buf, value, offset, min, max) {
1399
+ checkIntBI(value, min, max, buf, offset, 7);
1400
+ let lo = Number(value & BigInt(0xffffffff));
1401
+ buf[offset + 7] = lo;
1402
+ lo = lo >> 8;
1403
+ buf[offset + 6] = lo;
1404
+ lo = lo >> 8;
1405
+ buf[offset + 5] = lo;
1406
+ lo = lo >> 8;
1407
+ buf[offset + 4] = lo;
1408
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1409
+ buf[offset + 3] = hi;
1410
+ hi = hi >> 8;
1411
+ buf[offset + 2] = hi;
1412
+ hi = hi >> 8;
1413
+ buf[offset + 1] = hi;
1414
+ hi = hi >> 8;
1415
+ buf[offset] = hi;
1416
+ return offset + 8
1417
+ }
1418
+ Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
1419
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
1420
+ });
1421
+ Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
1422
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
1423
+ });
1424
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1425
+ value = +value;
1426
+ offset = offset >>> 0;
1427
+ if (!noAssert) {
1428
+ const limit = Math.pow(2, (8 * byteLength) - 1);
1429
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
1430
+ }
1431
+ let i = 0;
1432
+ let mul = 1;
1433
+ let sub = 0;
1434
+ this[offset] = value & 0xFF;
1435
+ while (++i < byteLength && (mul *= 0x100)) {
1436
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1437
+ sub = 1;
1438
+ }
1439
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
1440
+ }
1441
+ return offset + byteLength
1442
+ };
1443
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1444
+ value = +value;
1445
+ offset = offset >>> 0;
1446
+ if (!noAssert) {
1447
+ const limit = Math.pow(2, (8 * byteLength) - 1);
1448
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
1449
+ }
1450
+ let i = byteLength - 1;
1451
+ let mul = 1;
1452
+ let sub = 0;
1453
+ this[offset + i] = value & 0xFF;
1454
+ while (--i >= 0 && (mul *= 0x100)) {
1455
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1456
+ sub = 1;
1457
+ }
1458
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
1459
+ }
1460
+ return offset + byteLength
1461
+ };
1462
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1463
+ value = +value;
1464
+ offset = offset >>> 0;
1465
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
1466
+ if (value < 0) value = 0xff + value + 1;
1467
+ this[offset] = (value & 0xff);
1468
+ return offset + 1
1469
+ };
1470
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1471
+ value = +value;
1472
+ offset = offset >>> 0;
1473
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
1474
+ this[offset] = (value & 0xff);
1475
+ this[offset + 1] = (value >>> 8);
1476
+ return offset + 2
1477
+ };
1478
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1479
+ value = +value;
1480
+ offset = offset >>> 0;
1481
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
1482
+ this[offset] = (value >>> 8);
1483
+ this[offset + 1] = (value & 0xff);
1484
+ return offset + 2
1485
+ };
1486
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1487
+ value = +value;
1488
+ offset = offset >>> 0;
1489
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
1490
+ this[offset] = (value & 0xff);
1491
+ this[offset + 1] = (value >>> 8);
1492
+ this[offset + 2] = (value >>> 16);
1493
+ this[offset + 3] = (value >>> 24);
1494
+ return offset + 4
1495
+ };
1496
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1497
+ value = +value;
1498
+ offset = offset >>> 0;
1499
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
1500
+ if (value < 0) value = 0xffffffff + value + 1;
1501
+ this[offset] = (value >>> 24);
1502
+ this[offset + 1] = (value >>> 16);
1503
+ this[offset + 2] = (value >>> 8);
1504
+ this[offset + 3] = (value & 0xff);
1505
+ return offset + 4
1506
+ };
1507
+ Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
1508
+ return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
1509
+ });
1510
+ Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
1511
+ return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
1512
+ });
1513
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
1514
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
1515
+ if (offset < 0) throw new RangeError('Index out of range')
1516
+ }
1517
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
1518
+ value = +value;
1519
+ offset = offset >>> 0;
1520
+ if (!noAssert) {
1521
+ checkIEEE754(buf, value, offset, 4);
1522
+ }
1523
+ ieee754$1.write(buf, value, offset, littleEndian, 23, 4);
1524
+ return offset + 4
1525
+ }
1526
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1527
+ return writeFloat(this, value, offset, true, noAssert)
1528
+ };
1529
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1530
+ return writeFloat(this, value, offset, false, noAssert)
1531
+ };
1532
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
1533
+ value = +value;
1534
+ offset = offset >>> 0;
1535
+ if (!noAssert) {
1536
+ checkIEEE754(buf, value, offset, 8);
1537
+ }
1538
+ ieee754$1.write(buf, value, offset, littleEndian, 52, 8);
1539
+ return offset + 8
1540
+ }
1541
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1542
+ return writeDouble(this, value, offset, true, noAssert)
1543
+ };
1544
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1545
+ return writeDouble(this, value, offset, false, noAssert)
1546
+ };
1547
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1548
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
1549
+ if (!start) start = 0;
1550
+ if (!end && end !== 0) end = this.length;
1551
+ if (targetStart >= target.length) targetStart = target.length;
1552
+ if (!targetStart) targetStart = 0;
1553
+ if (end > 0 && end < start) end = start;
1554
+ if (end === start) return 0
1555
+ if (target.length === 0 || this.length === 0) return 0
1556
+ if (targetStart < 0) {
1557
+ throw new RangeError('targetStart out of bounds')
1558
+ }
1559
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
1560
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
1561
+ if (end > this.length) end = this.length;
1562
+ if (target.length - targetStart < end - start) {
1563
+ end = target.length - targetStart + start;
1564
+ }
1565
+ const len = end - start;
1566
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
1567
+ this.copyWithin(targetStart, start, end);
1568
+ } else {
1569
+ Uint8Array.prototype.set.call(
1570
+ target,
1571
+ this.subarray(start, end),
1572
+ targetStart
1573
+ );
1574
+ }
1575
+ return len
1576
+ };
1577
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
1578
+ if (typeof val === 'string') {
1579
+ if (typeof start === 'string') {
1580
+ encoding = start;
1581
+ start = 0;
1582
+ end = this.length;
1583
+ } else if (typeof end === 'string') {
1584
+ encoding = end;
1585
+ end = this.length;
1586
+ }
1587
+ if (encoding !== undefined && typeof encoding !== 'string') {
1588
+ throw new TypeError('encoding must be a string')
1589
+ }
1590
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1591
+ throw new TypeError('Unknown encoding: ' + encoding)
1592
+ }
1593
+ if (val.length === 1) {
1594
+ const code = val.charCodeAt(0);
1595
+ if ((encoding === 'utf8' && code < 128) ||
1596
+ encoding === 'latin1') {
1597
+ val = code;
1598
+ }
1599
+ }
1600
+ } else if (typeof val === 'number') {
1601
+ val = val & 255;
1602
+ } else if (typeof val === 'boolean') {
1603
+ val = Number(val);
1604
+ }
1605
+ if (start < 0 || this.length < start || this.length < end) {
1606
+ throw new RangeError('Out of range index')
1607
+ }
1608
+ if (end <= start) {
1609
+ return this
1610
+ }
1611
+ start = start >>> 0;
1612
+ end = end === undefined ? this.length : end >>> 0;
1613
+ if (!val) val = 0;
1614
+ let i;
1615
+ if (typeof val === 'number') {
1616
+ for (i = start; i < end; ++i) {
1617
+ this[i] = val;
1618
+ }
1619
+ } else {
1620
+ const bytes = Buffer.isBuffer(val)
1621
+ ? val
1622
+ : Buffer.from(val, encoding);
1623
+ const len = bytes.length;
1624
+ if (len === 0) {
1625
+ throw new TypeError('The value "' + val +
1626
+ '" is invalid for argument "value"')
1627
+ }
1628
+ for (i = 0; i < end - start; ++i) {
1629
+ this[i + start] = bytes[i % len];
1630
+ }
1631
+ }
1632
+ return this
1633
+ };
1634
+ const errors = {};
1635
+ function E (sym, getMessage, Base) {
1636
+ errors[sym] = class NodeError extends Base {
1637
+ constructor () {
1638
+ super();
1639
+ Object.defineProperty(this, 'message', {
1640
+ value: getMessage.apply(this, arguments),
1641
+ writable: true,
1642
+ configurable: true
1643
+ });
1644
+ this.name = `${this.name} [${sym}]`;
1645
+ this.stack;
1646
+ delete this.name;
1647
+ }
1648
+ get code () {
1649
+ return sym
1650
+ }
1651
+ set code (value) {
1652
+ Object.defineProperty(this, 'code', {
1653
+ configurable: true,
1654
+ enumerable: true,
1655
+ value,
1656
+ writable: true
1657
+ });
1658
+ }
1659
+ toString () {
1660
+ return `${this.name} [${sym}]: ${this.message}`
1661
+ }
1662
+ };
1663
+ }
1664
+ E('ERR_BUFFER_OUT_OF_BOUNDS',
1665
+ function (name) {
1666
+ if (name) {
1667
+ return `${name} is outside of buffer bounds`
1668
+ }
1669
+ return 'Attempt to access memory outside buffer bounds'
1670
+ }, RangeError);
1671
+ E('ERR_INVALID_ARG_TYPE',
1672
+ function (name, actual) {
1673
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`
1674
+ }, TypeError);
1675
+ E('ERR_OUT_OF_RANGE',
1676
+ function (str, range, input) {
1677
+ let msg = `The value of "${str}" is out of range.`;
1678
+ let received = input;
1679
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1680
+ received = addNumericalSeparator(String(input));
1681
+ } else if (typeof input === 'bigint') {
1682
+ received = String(input);
1683
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1684
+ received = addNumericalSeparator(received);
1685
+ }
1686
+ received += 'n';
1687
+ }
1688
+ msg += ` It must be ${range}. Received ${received}`;
1689
+ return msg
1690
+ }, RangeError);
1691
+ function addNumericalSeparator (val) {
1692
+ let res = '';
1693
+ let i = val.length;
1694
+ const start = val[0] === '-' ? 1 : 0;
1695
+ for (; i >= start + 4; i -= 3) {
1696
+ res = `_${val.slice(i - 3, i)}${res}`;
1697
+ }
1698
+ return `${val.slice(0, i)}${res}`
1699
+ }
1700
+ function checkBounds (buf, offset, byteLength) {
1701
+ validateNumber(offset, 'offset');
1702
+ if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
1703
+ boundsError(offset, buf.length - (byteLength + 1));
1704
+ }
1705
+ }
1706
+ function checkIntBI (value, min, max, buf, offset, byteLength) {
1707
+ if (value > max || value < min) {
1708
+ const n = typeof min === 'bigint' ? 'n' : '';
1709
+ let range;
1710
+ if (byteLength > 3) {
1711
+ if (min === 0 || min === BigInt(0)) {
1712
+ range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
1713
+ } else {
1714
+ range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
1715
+ `${(byteLength + 1) * 8 - 1}${n}`;
1716
+ }
1717
+ } else {
1718
+ range = `>= ${min}${n} and <= ${max}${n}`;
1719
+ }
1720
+ throw new errors.ERR_OUT_OF_RANGE('value', range, value)
1721
+ }
1722
+ checkBounds(buf, offset, byteLength);
1723
+ }
1724
+ function validateNumber (value, name) {
1725
+ if (typeof value !== 'number') {
1726
+ throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
1727
+ }
1728
+ }
1729
+ function boundsError (value, length, type) {
1730
+ if (Math.floor(value) !== value) {
1731
+ validateNumber(value, type);
1732
+ throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
1733
+ }
1734
+ if (length < 0) {
1735
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
1736
+ }
1737
+ throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
1738
+ `>= ${type ? 1 : 0} and <= ${length}`,
1739
+ value)
1740
+ }
1741
+ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1742
+ function base64clean (str) {
1743
+ str = str.split('=')[0];
1744
+ str = str.trim().replace(INVALID_BASE64_RE, '');
1745
+ if (str.length < 2) return ''
1746
+ while (str.length % 4 !== 0) {
1747
+ str = str + '=';
1748
+ }
1749
+ return str
1750
+ }
1751
+ function utf8ToBytes (string, units) {
1752
+ units = units || Infinity;
1753
+ let codePoint;
1754
+ const length = string.length;
1755
+ let leadSurrogate = null;
1756
+ const bytes = [];
1757
+ for (let i = 0; i < length; ++i) {
1758
+ codePoint = string.charCodeAt(i);
1759
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
1760
+ if (!leadSurrogate) {
1761
+ if (codePoint > 0xDBFF) {
1762
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
1763
+ continue
1764
+ } else if (i + 1 === length) {
1765
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
1766
+ continue
1767
+ }
1768
+ leadSurrogate = codePoint;
1769
+ continue
1770
+ }
1771
+ if (codePoint < 0xDC00) {
1772
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
1773
+ leadSurrogate = codePoint;
1774
+ continue
1775
+ }
1776
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
1777
+ } else if (leadSurrogate) {
1778
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
1779
+ }
1780
+ leadSurrogate = null;
1781
+ if (codePoint < 0x80) {
1782
+ if ((units -= 1) < 0) break
1783
+ bytes.push(codePoint);
1784
+ } else if (codePoint < 0x800) {
1785
+ if ((units -= 2) < 0) break
1786
+ bytes.push(
1787
+ codePoint >> 0x6 | 0xC0,
1788
+ codePoint & 0x3F | 0x80
1789
+ );
1790
+ } else if (codePoint < 0x10000) {
1791
+ if ((units -= 3) < 0) break
1792
+ bytes.push(
1793
+ codePoint >> 0xC | 0xE0,
1794
+ codePoint >> 0x6 & 0x3F | 0x80,
1795
+ codePoint & 0x3F | 0x80
1796
+ );
1797
+ } else if (codePoint < 0x110000) {
1798
+ if ((units -= 4) < 0) break
1799
+ bytes.push(
1800
+ codePoint >> 0x12 | 0xF0,
1801
+ codePoint >> 0xC & 0x3F | 0x80,
1802
+ codePoint >> 0x6 & 0x3F | 0x80,
1803
+ codePoint & 0x3F | 0x80
1804
+ );
1805
+ } else {
1806
+ throw new Error('Invalid code point')
1807
+ }
1808
+ }
1809
+ return bytes
1810
+ }
1811
+ function asciiToBytes (str) {
1812
+ const byteArray = [];
1813
+ for (let i = 0; i < str.length; ++i) {
1814
+ byteArray.push(str.charCodeAt(i) & 0xFF);
1815
+ }
1816
+ return byteArray
1817
+ }
1818
+ function utf16leToBytes (str, units) {
1819
+ let c, hi, lo;
1820
+ const byteArray = [];
1821
+ for (let i = 0; i < str.length; ++i) {
1822
+ if ((units -= 2) < 0) break
1823
+ c = str.charCodeAt(i);
1824
+ hi = c >> 8;
1825
+ lo = c % 256;
1826
+ byteArray.push(lo);
1827
+ byteArray.push(hi);
1828
+ }
1829
+ return byteArray
1830
+ }
1831
+ function base64ToBytes (str) {
1832
+ return base64.toByteArray(base64clean(str))
1833
+ }
1834
+ function blitBuffer (src, dst, offset, length) {
1835
+ let i;
1836
+ for (i = 0; i < length; ++i) {
1837
+ if ((i + offset >= dst.length) || (i >= src.length)) break
1838
+ dst[i + offset] = src[i];
1839
+ }
1840
+ return i
1841
+ }
1842
+ function isInstance (obj, type) {
1843
+ return obj instanceof type ||
1844
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
1845
+ obj.constructor.name === type.name)
1846
+ }
1847
+ function numberIsNaN (obj) {
1848
+ return obj !== obj
1849
+ }
1850
+ const hexSliceLookupTable = (function () {
1851
+ const alphabet = '0123456789abcdef';
1852
+ const table = new Array(256);
1853
+ for (let i = 0; i < 16; ++i) {
1854
+ const i16 = i * 16;
1855
+ for (let j = 0; j < 16; ++j) {
1856
+ table[i16 + j] = alphabet[i] + alphabet[j];
1857
+ }
1858
+ }
1859
+ return table
1860
+ })();
1861
+ function defineBigIntMethod (fn) {
1862
+ return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
1863
+ }
1864
+ function BufferBigIntNotDefined () {
1865
+ throw new Error('BigInt not supported')
1866
+ }
1867
+ } (buffer));
1868
+ getDefaultExportFromCjs(buffer);
1869
+
1870
+ /**
1871
+ * @module @zk-kit/utils
1872
+ * @version 0.8.1
1873
+ * @file Essential zero-knowledge utility library for JavaScript developers.
1874
+ * @copyright Ethereum Foundation 2024
1875
+ * @license MIT
1876
+ * @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
1877
+ */
1878
+ /**
1879
+ * @module TypeChecks
1880
+ * This module provides utility functions to check data types.
1881
+ * It defines a set of supported types and includes functions to check if
1882
+ * a value is defined and if it matches a supported type. These functions
1883
+ * are useful for type checking and validation in the other libraries,
1884
+ * enhancing code robustness and reliability.
1885
+ */
1886
+ const supportedTypes = [
1887
+ "number",
1888
+ "string",
1889
+ "function",
1890
+ "Array",
1891
+ "Uint8Array",
1892
+ "Buffer",
1893
+ "object",
1894
+ "bigint",
1895
+ "stringified-bigint",
1896
+ "hexadecimal",
1897
+ "bignumber",
1898
+ "bignumberish"
1899
+ ];
1900
+ /**
1901
+ * Returns true if the value is a number, false otherwise.
1902
+ * @param value The value to be checked.
1903
+ */
1904
+ function isNumber(value) {
1905
+ return typeof value === "number";
1906
+ }
1907
+ /**
1908
+ * Returns true if the value is a string, false otherwise.
1909
+ * @param value The value to be checked.
1910
+ */
1911
+ function isString(value) {
1912
+ return typeof value === "string";
1913
+ }
1914
+ /**
1915
+ * Returns true if the value is a function, false otherwise.
1916
+ * @param value The value to be checked.
1917
+ */
1918
+ function isFunction(value) {
1919
+ return typeof value === "function";
1920
+ }
1921
+ /**
1922
+ * Returns true if the value is an object, false otherwise.
1923
+ * Please, note that arrays are also objects in JavaScript.
1924
+ * @param value The value to be checked.
1925
+ */
1926
+ function isObject(value) {
1927
+ return typeof value === "object";
1928
+ }
1929
+ /**
1930
+ * Returns true if the value is an Array instance, false otherwise.
1931
+ * @param value The value to be checked.
1932
+ */
1933
+ function isArray(value) {
1934
+ return isObject(value) && Array.isArray(value);
1935
+ }
1936
+ /**
1937
+ * Returns true if the value is a Uint8Array instance, false otherwise.
1938
+ * @param value The value to be checked.
1939
+ */
1940
+ function isUint8Array(value) {
1941
+ return value instanceof Uint8Array;
1942
+ }
1943
+ /**
1944
+ * Returns true if the value is a Buffer instance, false otherwise.
1945
+ * @param value The value to be checked.
1946
+ */
1947
+ function isBuffer(value) {
1948
+ return buffer.Buffer.isBuffer(value);
1949
+ }
1950
+ /**
1951
+ * Returns true if the value is a bigint, false otherwise.
1952
+ * @param value The value to be checked.
1953
+ */
1954
+ function isBigInt(value) {
1955
+ return typeof value === "bigint";
1956
+ }
1957
+ /**
1958
+ * Checks if the given value is a string that represents a valid bigint.
1959
+ * @param value The value to be checked if it's a stringified bigint.
1960
+ */
1961
+ function isStringifiedBigInt(value) {
1962
+ if (!isString(value)) {
1963
+ return false;
1964
+ }
1965
+ try {
1966
+ BigInt(value);
1967
+ return true;
1968
+ }
1969
+ catch (_a) {
1970
+ return false;
1971
+ }
1972
+ }
1973
+ /**
1974
+ * Checks if a string is a valid hexadecimal string representation.
1975
+ * If 'prefix' is 'true', the string must start with '0x' or '0X' followed by one or more
1976
+ * hexadecimal digits (0-9, a-f, A-F), otherwise no prefix is expected. 'prefix' is optional and
1977
+ * if its value it is not explicitly defined it will be set to 'true' by default.
1978
+ * @param value The string to be tested.
1979
+ * @param prefix A boolean to include or not a '0x' or '0X' prefix.
1980
+ */
1981
+ function isHexadecimal(value, prefix = true) {
1982
+ if (!isString(value)) {
1983
+ return false;
1984
+ }
1985
+ if (prefix) {
1986
+ return /^(0x|0X)[0-9a-fA-F]+$/.test(value);
1987
+ }
1988
+ return /^[0-9a-fA-F]+$/.test(value);
1989
+ }
1990
+ /**
1991
+ * Checks if the given value can be considered as BigNumber.
1992
+ * A value is considered a BigNumber if it is a bigint or a string
1993
+ * that can be converted to a bigint (via `Bigint(s)`).
1994
+ * @param value The value to check.
1995
+ */
1996
+ function isBigNumber(value) {
1997
+ return isBigInt(value) || isStringifiedBigInt(value);
1998
+ }
1999
+ /**
2000
+ * Checks if the given value can be considered as BigNumberish.
2001
+ * A value is considered BigNumberish if it meets
2002
+ * any of the following conditions: it's a number, a bigint, a string
2003
+ * that can be converted to a bigint, a hexadecimal
2004
+ * string, or a Buffer object.
2005
+ * @param value The value to check.
2006
+ */
2007
+ function isBigNumberish(value) {
2008
+ return (isNumber(value) ||
2009
+ isBigInt(value) ||
2010
+ isStringifiedBigInt(value) ||
2011
+ isHexadecimal(value) ||
2012
+ isBuffer(value) ||
2013
+ isUint8Array(value));
2014
+ }
2015
+ /**
2016
+ * Returns true if the value type is the same as the type passed
2017
+ * as the second parameter, false otherwise.
2018
+ * @param type The expected type.
2019
+ */
2020
+ function isType(value, type) {
2021
+ switch (type) {
2022
+ case "number":
2023
+ return isNumber(value);
2024
+ case "string":
2025
+ return isString(value);
2026
+ case "function":
2027
+ return isFunction(value);
2028
+ case "Array":
2029
+ return isArray(value);
2030
+ case "Uint8Array":
2031
+ return isUint8Array(value);
2032
+ case "Buffer":
2033
+ return isBuffer(value);
2034
+ case "object":
2035
+ return isObject(value);
2036
+ case "bigint":
2037
+ return isBigInt(value);
2038
+ case "stringified-bigint":
2039
+ return isStringifiedBigInt(value);
2040
+ case "hexadecimal":
2041
+ return isHexadecimal(value);
2042
+ case "bignumber":
2043
+ return isBigNumber(value);
2044
+ case "bignumberish":
2045
+ return isBigNumberish(value);
2046
+ default:
2047
+ return false;
2048
+ }
2049
+ }
2050
+ /**
2051
+ * Returns true if the type is being supported by this utility
2052
+ * functions, false otherwise.
2053
+ * @param type The type to be checked.
2054
+ */
2055
+ function isSupportedType(type) {
2056
+ return supportedTypes.includes(type);
2057
+ }
2058
+
2059
+ /**
2060
+ * @module @zk-kit/utils
2061
+ * @version 0.8.1
2062
+ * @file Essential zero-knowledge utility library for JavaScript developers.
2063
+ * @copyright Ethereum Foundation 2024
2064
+ * @license MIT
2065
+ * @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
2066
+ */
2067
+ /**
2068
+ * @throws Throws a type error if the parameter value is not a string.
2069
+ * @param parameterValue The parameter value.
2070
+ * @param parameterName The parameter name.
2071
+ */
2072
+ function requireString(parameterValue, parameterName) {
2073
+ if (!isString(parameterValue)) {
2074
+ throw new TypeError(`Parameter '${parameterName}' is not a string, received type: ${typeof parameterValue}`);
2075
+ }
2076
+ }
2077
+ /**
2078
+ * @throws Throws a type error if the parameter value is not a hexadecimal string.
2079
+ * If 'prefix' is 'true', the string must start with '0x' or '0X' followed by one or more
2080
+ * hexadecimal digits (0-9, a-f, A-F), otherwise no prefix is expected. 'prefix' is optional and
2081
+ * if its value it is not explicitly defined it will be set to 'true' by default.
2082
+ * @param parameterValue The parameter value.
2083
+ * @param parameterName The parameter name.
2084
+ * @param prefix A boolean to include or not a '0x' or '0X' prefix.
2085
+ */
2086
+ function requireHexadecimal(parameterValue, parameterName, prefix = true) {
2087
+ if (!isHexadecimal(parameterValue, prefix)) {
2088
+ throw new TypeError(`Parameter '${parameterName}' is not a hexadecimal string`);
2089
+ }
2090
+ }
2091
+ /**
2092
+ * @throws Throws a type error if the parameter value type is not part of the list of types.
2093
+ * @param parameterValue The parameter value.
2094
+ * @param parameterName The parameter name.
2095
+ */
2096
+ function requireTypes(parameterValue, parameterName, types) {
2097
+ for (const type of types) {
2098
+ if (!isSupportedType(type)) {
2099
+ throw new Error(`Type '${type}' is not supported`);
2100
+ }
2101
+ }
2102
+ for (const type of types) {
2103
+ if (isType(parameterValue, type)) {
2104
+ return;
2105
+ }
2106
+ }
2107
+ throw new TypeError(`Parameter '${parameterName}' is none of the following types: ${types.join(", ")}`);
2108
+ }
2109
+
2110
+ /**
2111
+ * @module @zk-kit/utils
2112
+ * @version 0.8.1
2113
+ * @file Essential zero-knowledge utility library for JavaScript developers.
2114
+ * @copyright Ethereum Foundation 2024
2115
+ * @license MIT
2116
+ * @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
2117
+ */
2118
+ /**
2119
+ * Converts an hexadecimal string to a buffer. The hexadecimal string
2120
+ * should not start with '0x' or '0X'. It keeps the bytes in the same order.
2121
+ * @param value The hexadecimal string to convert.
2122
+ * @returns The buffer representation of the hexadecimal string.
2123
+ */
2124
+ function hexadecimalToBuffer(value) {
2125
+ requireHexadecimal(value, "value", false);
2126
+ if (value.length % 2 !== 0) {
2127
+ value = `0${value}`;
2128
+ }
2129
+ return buffer.Buffer.from(value, "hex");
2130
+ }
2131
+ /**
2132
+ * Converts a buffer to a hexadecimal string. It accepts 'Buffer' or 'Uint8Array'.
2133
+ * The hexadecimal string will not start with '0x' or '0X'. It keeps the bytes in the same order.
2134
+ * @param value The buffer to convert.
2135
+ * @returns The converted hexadecimal string.
2136
+ */
2137
+ function bufferToHexadecimal(value) {
2138
+ requireTypes(value, "value", ["Buffer", "Uint8Array"]);
2139
+ return buffer.Buffer.from(value).toString("hex");
2140
+ }
2141
+
2142
+ var poseidon2$1 = {};
2143
+
2144
+ const F = BigInt('21888242871839275222246405745257275088548364400416034343698204186575808495617');
2145
+ const N_ROUNDS_F = 8;
2146
+ const N_ROUNDS_P = [56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68];
2147
+ const pow5 = v => {
2148
+ let o = v * v;
2149
+ return v * o * o % F;
2150
+ };
2151
+ function mix(state, M) {
2152
+ const out = [];
2153
+ for (let x = 0; x < state.length; x++) {
2154
+ let o = 0n;
2155
+ for (let y = 0; y < state.length; y++) {
2156
+ o = o + M[x][y] * state[y];
2157
+ }
2158
+ out.push(o % F);
2159
+ }
2160
+ return out;
2161
+ }
2162
+ function poseidon(_inputs, opt) {
2163
+ const inputs = _inputs.map(i => BigInt(i));
2164
+ if (inputs.length <= 0) {
2165
+ throw new Error('poseidon-lite: Not enough inputs');
2166
+ }
2167
+ if (inputs.length > N_ROUNDS_P.length) {
2168
+ throw new Error('poseidon-lite: Too many inputs');
2169
+ }
2170
+ const t = inputs.length + 1;
2171
+ const nRoundsF = N_ROUNDS_F;
2172
+ const nRoundsP = N_ROUNDS_P[t - 2];
2173
+ const {
2174
+ C,
2175
+ M
2176
+ } = opt;
2177
+ if (M.length !== t) {
2178
+ throw new Error(`poseidon-lite: Incorrect M length, expected ${t} got ${M.length}`);
2179
+ }
2180
+ let state = [0n, ...inputs];
2181
+ for (let x = 0; x < nRoundsF + nRoundsP; x++) {
2182
+ for (let y = 0; y < state.length; y++) {
2183
+ state[y] = state[y] + C[x * t + y];
2184
+ if (x < nRoundsF / 2 || x >= nRoundsF / 2 + nRoundsP) state[y] = pow5(state[y]);else if (y === 0) state[y] = pow5(state[y]);
2185
+ }
2186
+ state = mix(state, M);
2187
+ }
2188
+ return state[0];
2189
+ }
2190
+ var poseidon_1 = poseidon;
2191
+ getDefaultExportFromCjs(poseidon_1);
2192
+
2193
+ var unstringify = {};
2194
+
2195
+ Object.defineProperty(unstringify, "__esModule", {
2196
+ value: true
2197
+ });
2198
+ unstringify.default = unstringifyBigInts;
2199
+ function unstringifyBigInts(o) {
2200
+ if (Array.isArray(o)) {
2201
+ return o.map(unstringifyBigInts);
2202
+ } else if (typeof o == 'object') {
2203
+ const res = {};
2204
+ for (const [key, val] of Object.entries(o)) {
2205
+ res[key] = unstringifyBigInts(val);
2206
+ }
2207
+ return res;
2208
+ }
2209
+ const byteArray = Uint8Array.from(atob(o), c => c.charCodeAt(0));
2210
+ const hex = [...byteArray].map(x => x.toString(16).padStart(2, '0')).join('');
2211
+ return BigInt(`0x${hex}`);
2212
+ }
2213
+
2214
+ var _2 = {};
2215
+
2216
+ Object.defineProperty(_2, "__esModule", {
2217
+ value: true
2218
+ });
2219
+ _2.default = void 0;
2220
+ var _default = {
2221
+ C: ['DumlkrqalRjQWYbWVvQMIRTEmTwRuym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D4vl8=', 'BU76H2Ww/OKDgIllJ12He0ONojzlsT4ZY3mMsUR9JaQ=', 'GxYvg9kX6T7bMwjCmALeudiqaQETsuFIZMz24Y5BZfE=', 'IeUkHhJWTdb9nxzdKg3jnu3+/BRmzFaOxc63RaBQbtw=', 'HPtWYujPWskiaoDuF7Nqvstzq1+H4WGSe0NJ4Q5L3wg=', 'DyEXfjAqdxu65tjR7LNztiyZrzRiIKwBKcU/Zm6yQQA=', 'FnFSI3RgaZKv+w3X9xsSvsQjau3mKQVGvO9+H1FcIyA=', 'D6PsW5SIJZwutM8kUBv62b4uyeQsXMjM1BnSppLK2HA=', 'GTwOBOC9KYNXyyZsFQYIDtNu3OhcZIzAhejFexq1S7o=', 'ECrfjvdHNaJ+kSgwbcvDyZ9vcpHNQGV4zhTqKtq6aPg=', 'D+CveFjkmFnipU1vGtlFsTFqokv73SOuQKbQy3DD6rE=', 'IW9nF7vH3tsIU2oiIIQ/Ti2l8dqp69796KXqc0R5jSI=', 'HaVcyQDw0h9KPmlDkZGKGzwjsqx3PGs++I4uQigyUWE='],
2222
+ M: [['EJt/QRug5MmytwyvXDansZS+fBGtJDeL/ttoWSuoEYs=', 'Fu1B4Tu5wMZq4RlCT928vJMU3J/b3upV1sZFQ9xJA+A=', 'K5C7oA/KBYn2F+fcv+guDfcGq2QM6yR7eRqTt042c20='], ['KWnyfu0xpIC5w2x2Q3nbyizI/dFBXD3e1ilAvN4L13E=', 'LiQZ+ewC7DlMmHHIMpY9wbiddDyMe5ZAKbIxFoex/iM=', 'EBBx8AMjebaXMVh2aQ8FPRSNThCfX7BlyKrMVaD4m/o='], ['FDAh7GhqPzMNX55lRjgGXObNeeKMWzdTMmJE7mWhsac=', 'F2zAKWla0CWCpw7/CKb9mdBX4S5Y59e2sWzfq8juKRE=', 'GaP8ClZwK/QXun/uOAJZP6ZERwMHBD93cyec1x0l1eA=']]
2223
+ };
2224
+ _2.default = _default;
2225
+
2226
+ Object.defineProperty(poseidon2$1, "__esModule", {
2227
+ value: true
2228
+ });
2229
+ var poseidon2_2 = poseidon2$1.poseidon2 = poseidon2;
2230
+ var _poseidon = _interopRequireDefault(poseidon_1);
2231
+ var _unstringify = _interopRequireDefault(unstringify);
2232
+ var _ = _interopRequireDefault(_2);
2233
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2234
+ const c = (0, _unstringify.default)(_.default);
2235
+ function poseidon2(inputs) {
2236
+ return (0, _poseidon.default)(inputs, c);
2237
+ }
2238
+
2239
+ /**
2240
+ * The Semaphore identity is essentially an {@link https://www.rfc-editor.org/rfc/rfc8032 | EdDSA}
2241
+ * public/private key pair. The {@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/eddsa-poseidon | EdDSA implementation}
2242
+ * in this library uses {@link https://eips.ethereum.org/EIPS/eip-2494 | Baby Jubjub} for public key generation
2243
+ * and {@link https://www.poseidon-hash.info | Poseidon} for signatures.
2244
+ * In addition, the commitment, i.e. the hash of the public key, is used to represent
2245
+ * Semaphore identities in groups, adding an additional layer of privacy and security.
2246
+ * The private key of the identity is stored as a hexadecimal string or text.
2247
+ * The other attributes are stored as stringified bigint.
2248
+ */
2249
+ var Identity = /** @class */ (function () {
2250
+ /**
2251
+ * Initializes the class attributes based on a given private key, which must be a hexadecimal string or a text.
2252
+ * Hexadecimal strings must not start with '0x' or '0X'.
2253
+ * If the private key is not passed as a parameter, a random hexadecimal key will be generated.
2254
+ * The EdDSAPoseidon class is used to generate the secret scalar and the public key.
2255
+ * Additionally, the constructor computes a commitment of the public key using a hash function (Poseidon).
2256
+ *
2257
+ * @example
2258
+ * // Generates an identity.
2259
+ * const { privateKey, publicKey, commitment } = new Identity("private-key")
2260
+ * @example
2261
+ * // Generates an identity with a random private key.
2262
+ * const { privateKey, publicKey, commitment } = new Identity()
2263
+ *
2264
+ * @param privateKey The private key used to derive the public key (hexadecimal or string).
2265
+ */
2266
+ function Identity(privateKey) {
2267
+ var eddsa;
2268
+ if (privateKey) {
2269
+ requireString(privateKey, "privateKey");
2270
+ this._privateKey = privateKey;
2271
+ if (isHexadecimal(privateKey, false)) {
2272
+ eddsa = new EdDSAPoseidon(hexadecimalToBuffer(privateKey));
2273
+ }
2274
+ else {
2275
+ eddsa = new EdDSAPoseidon(privateKey);
2276
+ }
2277
+ }
2278
+ else {
2279
+ eddsa = new EdDSAPoseidon();
2280
+ this._privateKey = bufferToHexadecimal(eddsa.privateKey);
2281
+ }
2282
+ this._secretScalar = eddsa.secretScalar;
2283
+ this._publicKey = eddsa.publicKey;
2284
+ this._commitment = poseidon2_2(this._publicKey);
2285
+ }
2286
+ Object.defineProperty(Identity.prototype, "privateKey", {
2287
+ /**
2288
+ * Returns the private key.
2289
+ * @returns The private key as a string (hexadecimal or text).
2290
+ */
2291
+ get: function () {
2292
+ return this._privateKey;
2293
+ },
2294
+ enumerable: false,
2295
+ configurable: true
2296
+ });
2297
+ Object.defineProperty(Identity.prototype, "secretScalar", {
2298
+ /**
2299
+ * Returns the secret scalar.
2300
+ * @returns The secret scalar as a string.
2301
+ */
2302
+ get: function () {
2303
+ return this._secretScalar;
2304
+ },
2305
+ enumerable: false,
2306
+ configurable: true
2307
+ });
2308
+ Object.defineProperty(Identity.prototype, "publicKey", {
2309
+ /**
2310
+ * Returns the public key as a Baby Jubjub {@link https://zkkit.pse.dev/types/_zk_kit_baby_jubjub.Point.html | Point}.
2311
+ * @returns The public key as a point.
2312
+ */
2313
+ get: function () {
2314
+ return this._publicKey;
2315
+ },
2316
+ enumerable: false,
2317
+ configurable: true
2318
+ });
2319
+ Object.defineProperty(Identity.prototype, "commitment", {
2320
+ /**
2321
+ * Returns the commitment hash of the public key.
2322
+ * @returns The commitment as a string.
2323
+ */
2324
+ get: function () {
2325
+ return this._commitment;
2326
+ },
2327
+ enumerable: false,
2328
+ configurable: true
2329
+ });
2330
+ /**
2331
+ * Generates a signature for a given message using the private key.
2332
+ * This method demonstrates how to sign a message and could be used
2333
+ * for authentication or data integrity.
2334
+ *
2335
+ * @example
2336
+ * const identity = new Identity()
2337
+ * const signature = identity.signMessage("message")
2338
+ *
2339
+ * @param message The message to be signed.
2340
+ * @returns A {@link https://zkkit.pse.dev/types/_zk_kit_eddsa_poseidon.Signature.html | Signature} object containing the signature components.
2341
+ */
2342
+ Identity.prototype.signMessage = function (message) {
2343
+ return signMessage(this.privateKey, message);
2344
+ };
2345
+ /**
2346
+ * Verifies a signature against a given message and public key.
2347
+ * This static method allows for the verification of signatures without needing
2348
+ * an instance of the Identity class. It's useful for cases where you only have
2349
+ * the public key, the message and a signature, and need to verify if they match.
2350
+ *
2351
+ * @example
2352
+ * const identity = new Identity()
2353
+ * const signature = identity.signMessage("message")
2354
+ * Identity.verifySignature("message", signature, identity.publicKey)
2355
+ *
2356
+ * @param message The message that was signed.
2357
+ * @param signature The signature to verify.
2358
+ * @param publicKey The public key to use for verification.
2359
+ * @returns A boolean indicating whether the signature is valid.
2360
+ */
2361
+ Identity.verifySignature = function (message, signature, publicKey) {
2362
+ return verifySignature(message, signature, publicKey);
2363
+ };
2364
+ return Identity;
2365
+ }());
2366
+
2367
+ export { Identity };