@pooflabs/core 0.0.8 → 0.0.9

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 CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  var axios = require('axios');
4
4
  var web3_js = require('@solana/web3.js');
5
- var require$$0 = require('buffer');
6
5
  var nacl = require('tweetnacl');
7
6
  var anchor = require('@coral-xyz/anchor');
8
7
  var helpers = require('@solana-developers/helpers');
@@ -210,6 +209,2377 @@ function getDefaultExportFromCjs (x) {
210
209
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
211
210
  }
212
211
 
212
+ var buffer = {};
213
+
214
+ var base64Js = {};
215
+
216
+ var hasRequiredBase64Js;
217
+
218
+ function requireBase64Js () {
219
+ if (hasRequiredBase64Js) return base64Js;
220
+ hasRequiredBase64Js = 1;
221
+
222
+ base64Js.byteLength = byteLength;
223
+ base64Js.toByteArray = toByteArray;
224
+ base64Js.fromByteArray = fromByteArray;
225
+
226
+ var lookup = [];
227
+ var revLookup = [];
228
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
229
+
230
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
231
+ for (var i = 0, len = code.length; i < len; ++i) {
232
+ lookup[i] = code[i];
233
+ revLookup[code.charCodeAt(i)] = i;
234
+ }
235
+
236
+ // Support decoding URL-safe base64 strings, as Node.js does.
237
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
238
+ revLookup['-'.charCodeAt(0)] = 62;
239
+ revLookup['_'.charCodeAt(0)] = 63;
240
+
241
+ function getLens (b64) {
242
+ var len = b64.length;
243
+
244
+ if (len % 4 > 0) {
245
+ throw new Error('Invalid string. Length must be a multiple of 4')
246
+ }
247
+
248
+ // Trim off extra bytes after placeholder bytes are found
249
+ // See: https://github.com/beatgammit/base64-js/issues/42
250
+ var validLen = b64.indexOf('=');
251
+ if (validLen === -1) validLen = len;
252
+
253
+ var placeHoldersLen = validLen === len
254
+ ? 0
255
+ : 4 - (validLen % 4);
256
+
257
+ return [validLen, placeHoldersLen]
258
+ }
259
+
260
+ // base64 is 4/3 + up to two characters of the original data
261
+ function byteLength (b64) {
262
+ var lens = getLens(b64);
263
+ var validLen = lens[0];
264
+ var placeHoldersLen = lens[1];
265
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
266
+ }
267
+
268
+ function _byteLength (b64, validLen, placeHoldersLen) {
269
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
270
+ }
271
+
272
+ function toByteArray (b64) {
273
+ var tmp;
274
+ var lens = getLens(b64);
275
+ var validLen = lens[0];
276
+ var placeHoldersLen = lens[1];
277
+
278
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
279
+
280
+ var curByte = 0;
281
+
282
+ // if there are placeholders, only get up to the last complete 4 chars
283
+ var len = placeHoldersLen > 0
284
+ ? validLen - 4
285
+ : validLen;
286
+
287
+ var i;
288
+ for (i = 0; i < len; i += 4) {
289
+ tmp =
290
+ (revLookup[b64.charCodeAt(i)] << 18) |
291
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
292
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
293
+ revLookup[b64.charCodeAt(i + 3)];
294
+ arr[curByte++] = (tmp >> 16) & 0xFF;
295
+ arr[curByte++] = (tmp >> 8) & 0xFF;
296
+ arr[curByte++] = tmp & 0xFF;
297
+ }
298
+
299
+ if (placeHoldersLen === 2) {
300
+ tmp =
301
+ (revLookup[b64.charCodeAt(i)] << 2) |
302
+ (revLookup[b64.charCodeAt(i + 1)] >> 4);
303
+ arr[curByte++] = tmp & 0xFF;
304
+ }
305
+
306
+ if (placeHoldersLen === 1) {
307
+ tmp =
308
+ (revLookup[b64.charCodeAt(i)] << 10) |
309
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
310
+ (revLookup[b64.charCodeAt(i + 2)] >> 2);
311
+ arr[curByte++] = (tmp >> 8) & 0xFF;
312
+ arr[curByte++] = tmp & 0xFF;
313
+ }
314
+
315
+ return arr
316
+ }
317
+
318
+ function tripletToBase64 (num) {
319
+ return lookup[num >> 18 & 0x3F] +
320
+ lookup[num >> 12 & 0x3F] +
321
+ lookup[num >> 6 & 0x3F] +
322
+ lookup[num & 0x3F]
323
+ }
324
+
325
+ function encodeChunk (uint8, start, end) {
326
+ var tmp;
327
+ var output = [];
328
+ for (var i = start; i < end; i += 3) {
329
+ tmp =
330
+ ((uint8[i] << 16) & 0xFF0000) +
331
+ ((uint8[i + 1] << 8) & 0xFF00) +
332
+ (uint8[i + 2] & 0xFF);
333
+ output.push(tripletToBase64(tmp));
334
+ }
335
+ return output.join('')
336
+ }
337
+
338
+ function fromByteArray (uint8) {
339
+ var tmp;
340
+ var len = uint8.length;
341
+ var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
342
+ var parts = [];
343
+ var maxChunkLength = 16383; // must be multiple of 3
344
+
345
+ // go through the array every three bytes, we'll deal with trailing stuff later
346
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
347
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
348
+ }
349
+
350
+ // pad the end with zeros, but make sure to not forget the extra bytes
351
+ if (extraBytes === 1) {
352
+ tmp = uint8[len - 1];
353
+ parts.push(
354
+ lookup[tmp >> 2] +
355
+ lookup[(tmp << 4) & 0x3F] +
356
+ '=='
357
+ );
358
+ } else if (extraBytes === 2) {
359
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
360
+ parts.push(
361
+ lookup[tmp >> 10] +
362
+ lookup[(tmp >> 4) & 0x3F] +
363
+ lookup[(tmp << 2) & 0x3F] +
364
+ '='
365
+ );
366
+ }
367
+
368
+ return parts.join('')
369
+ }
370
+ return base64Js;
371
+ }
372
+
373
+ var ieee754 = {};
374
+
375
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
376
+
377
+ var hasRequiredIeee754;
378
+
379
+ function requireIeee754 () {
380
+ if (hasRequiredIeee754) return ieee754;
381
+ hasRequiredIeee754 = 1;
382
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
383
+ var e, m;
384
+ var eLen = (nBytes * 8) - mLen - 1;
385
+ var eMax = (1 << eLen) - 1;
386
+ var eBias = eMax >> 1;
387
+ var nBits = -7;
388
+ var i = isLE ? (nBytes - 1) : 0;
389
+ var d = isLE ? -1 : 1;
390
+ var s = buffer[offset + i];
391
+
392
+ i += d;
393
+
394
+ e = s & ((1 << (-nBits)) - 1);
395
+ s >>= (-nBits);
396
+ nBits += eLen;
397
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
398
+
399
+ m = e & ((1 << (-nBits)) - 1);
400
+ e >>= (-nBits);
401
+ nBits += mLen;
402
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
403
+
404
+ if (e === 0) {
405
+ e = 1 - eBias;
406
+ } else if (e === eMax) {
407
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
408
+ } else {
409
+ m = m + Math.pow(2, mLen);
410
+ e = e - eBias;
411
+ }
412
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
413
+ };
414
+
415
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
416
+ var e, m, c;
417
+ var eLen = (nBytes * 8) - mLen - 1;
418
+ var eMax = (1 << eLen) - 1;
419
+ var eBias = eMax >> 1;
420
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
421
+ var i = isLE ? 0 : (nBytes - 1);
422
+ var d = isLE ? 1 : -1;
423
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
424
+
425
+ value = Math.abs(value);
426
+
427
+ if (isNaN(value) || value === Infinity) {
428
+ m = isNaN(value) ? 1 : 0;
429
+ e = eMax;
430
+ } else {
431
+ e = Math.floor(Math.log(value) / Math.LN2);
432
+ if (value * (c = Math.pow(2, -e)) < 1) {
433
+ e--;
434
+ c *= 2;
435
+ }
436
+ if (e + eBias >= 1) {
437
+ value += rt / c;
438
+ } else {
439
+ value += rt * Math.pow(2, 1 - eBias);
440
+ }
441
+ if (value * c >= 2) {
442
+ e++;
443
+ c /= 2;
444
+ }
445
+
446
+ if (e + eBias >= eMax) {
447
+ m = 0;
448
+ e = eMax;
449
+ } else if (e + eBias >= 1) {
450
+ m = ((value * c) - 1) * Math.pow(2, mLen);
451
+ e = e + eBias;
452
+ } else {
453
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
454
+ e = 0;
455
+ }
456
+ }
457
+
458
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
459
+
460
+ e = (e << mLen) | m;
461
+ eLen += mLen;
462
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
463
+
464
+ buffer[offset + i - d] |= s * 128;
465
+ };
466
+ return ieee754;
467
+ }
468
+
469
+ /*!
470
+ * The buffer module from node.js, for the browser.
471
+ *
472
+ * @author Feross Aboukhadijeh <https://feross.org>
473
+ * @license MIT
474
+ */
475
+
476
+ var hasRequiredBuffer;
477
+
478
+ function requireBuffer () {
479
+ if (hasRequiredBuffer) return buffer;
480
+ hasRequiredBuffer = 1;
481
+ (function (exports$1) {
482
+
483
+ const base64 = requireBase64Js();
484
+ const ieee754 = requireIeee754();
485
+ const customInspectSymbol =
486
+ (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
487
+ ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
488
+ : null;
489
+
490
+ exports$1.Buffer = Buffer;
491
+ exports$1.SlowBuffer = SlowBuffer;
492
+ exports$1.INSPECT_MAX_BYTES = 50;
493
+
494
+ const K_MAX_LENGTH = 0x7fffffff;
495
+ exports$1.kMaxLength = K_MAX_LENGTH;
496
+
497
+ /**
498
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
499
+ * === true Use Uint8Array implementation (fastest)
500
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
501
+ * implementation (most compatible, even IE6)
502
+ *
503
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
504
+ * Opera 11.6+, iOS 4.2+.
505
+ *
506
+ * We report that the browser does not support typed arrays if the are not subclassable
507
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
508
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
509
+ * for __proto__ and has a buggy typed array implementation.
510
+ */
511
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
512
+
513
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
514
+ typeof console.error === 'function') {
515
+ console.error(
516
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
517
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
518
+ );
519
+ }
520
+
521
+ function typedArraySupport () {
522
+ // Can typed array instances can be augmented?
523
+ try {
524
+ const arr = new Uint8Array(1);
525
+ const proto = { foo: function () { return 42 } };
526
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
527
+ Object.setPrototypeOf(arr, proto);
528
+ return arr.foo() === 42
529
+ } catch (e) {
530
+ return false
531
+ }
532
+ }
533
+
534
+ Object.defineProperty(Buffer.prototype, 'parent', {
535
+ enumerable: true,
536
+ get: function () {
537
+ if (!Buffer.isBuffer(this)) return undefined
538
+ return this.buffer
539
+ }
540
+ });
541
+
542
+ Object.defineProperty(Buffer.prototype, 'offset', {
543
+ enumerable: true,
544
+ get: function () {
545
+ if (!Buffer.isBuffer(this)) return undefined
546
+ return this.byteOffset
547
+ }
548
+ });
549
+
550
+ function createBuffer (length) {
551
+ if (length > K_MAX_LENGTH) {
552
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
553
+ }
554
+ // Return an augmented `Uint8Array` instance
555
+ const buf = new Uint8Array(length);
556
+ Object.setPrototypeOf(buf, Buffer.prototype);
557
+ return buf
558
+ }
559
+
560
+ /**
561
+ * The Buffer constructor returns instances of `Uint8Array` that have their
562
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
563
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
564
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
565
+ * returns a single octet.
566
+ *
567
+ * The `Uint8Array` prototype remains unmodified.
568
+ */
569
+
570
+ function Buffer (arg, encodingOrOffset, length) {
571
+ // Common case.
572
+ if (typeof arg === 'number') {
573
+ if (typeof encodingOrOffset === 'string') {
574
+ throw new TypeError(
575
+ 'The "string" argument must be of type string. Received type number'
576
+ )
577
+ }
578
+ return allocUnsafe(arg)
579
+ }
580
+ return from(arg, encodingOrOffset, length)
581
+ }
582
+
583
+ Buffer.poolSize = 8192; // not used by this implementation
584
+
585
+ function from (value, encodingOrOffset, length) {
586
+ if (typeof value === 'string') {
587
+ return fromString(value, encodingOrOffset)
588
+ }
589
+
590
+ if (ArrayBuffer.isView(value)) {
591
+ return fromArrayView(value)
592
+ }
593
+
594
+ if (value == null) {
595
+ throw new TypeError(
596
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
597
+ 'or Array-like Object. Received type ' + (typeof value)
598
+ )
599
+ }
600
+
601
+ if (isInstance(value, ArrayBuffer) ||
602
+ (value && isInstance(value.buffer, ArrayBuffer))) {
603
+ return fromArrayBuffer(value, encodingOrOffset, length)
604
+ }
605
+
606
+ if (typeof SharedArrayBuffer !== 'undefined' &&
607
+ (isInstance(value, SharedArrayBuffer) ||
608
+ (value && isInstance(value.buffer, SharedArrayBuffer)))) {
609
+ return fromArrayBuffer(value, encodingOrOffset, length)
610
+ }
611
+
612
+ if (typeof value === 'number') {
613
+ throw new TypeError(
614
+ 'The "value" argument must not be of type number. Received type number'
615
+ )
616
+ }
617
+
618
+ const valueOf = value.valueOf && value.valueOf();
619
+ if (valueOf != null && valueOf !== value) {
620
+ return Buffer.from(valueOf, encodingOrOffset, length)
621
+ }
622
+
623
+ const b = fromObject(value);
624
+ if (b) return b
625
+
626
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
627
+ typeof value[Symbol.toPrimitive] === 'function') {
628
+ return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
629
+ }
630
+
631
+ throw new TypeError(
632
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
633
+ 'or Array-like Object. Received type ' + (typeof value)
634
+ )
635
+ }
636
+
637
+ /**
638
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
639
+ * if value is a number.
640
+ * Buffer.from(str[, encoding])
641
+ * Buffer.from(array)
642
+ * Buffer.from(buffer)
643
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
644
+ **/
645
+ Buffer.from = function (value, encodingOrOffset, length) {
646
+ return from(value, encodingOrOffset, length)
647
+ };
648
+
649
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
650
+ // https://github.com/feross/buffer/pull/148
651
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
652
+ Object.setPrototypeOf(Buffer, Uint8Array);
653
+
654
+ function assertSize (size) {
655
+ if (typeof size !== 'number') {
656
+ throw new TypeError('"size" argument must be of type number')
657
+ } else if (size < 0) {
658
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
659
+ }
660
+ }
661
+
662
+ function alloc (size, fill, encoding) {
663
+ assertSize(size);
664
+ if (size <= 0) {
665
+ return createBuffer(size)
666
+ }
667
+ if (fill !== undefined) {
668
+ // Only pay attention to encoding if it's a string. This
669
+ // prevents accidentally sending in a number that would
670
+ // be interpreted as a start offset.
671
+ return typeof encoding === 'string'
672
+ ? createBuffer(size).fill(fill, encoding)
673
+ : createBuffer(size).fill(fill)
674
+ }
675
+ return createBuffer(size)
676
+ }
677
+
678
+ /**
679
+ * Creates a new filled Buffer instance.
680
+ * alloc(size[, fill[, encoding]])
681
+ **/
682
+ Buffer.alloc = function (size, fill, encoding) {
683
+ return alloc(size, fill, encoding)
684
+ };
685
+
686
+ function allocUnsafe (size) {
687
+ assertSize(size);
688
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
689
+ }
690
+
691
+ /**
692
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
693
+ * */
694
+ Buffer.allocUnsafe = function (size) {
695
+ return allocUnsafe(size)
696
+ };
697
+ /**
698
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
699
+ */
700
+ Buffer.allocUnsafeSlow = function (size) {
701
+ return allocUnsafe(size)
702
+ };
703
+
704
+ function fromString (string, encoding) {
705
+ if (typeof encoding !== 'string' || encoding === '') {
706
+ encoding = 'utf8';
707
+ }
708
+
709
+ if (!Buffer.isEncoding(encoding)) {
710
+ throw new TypeError('Unknown encoding: ' + encoding)
711
+ }
712
+
713
+ const length = byteLength(string, encoding) | 0;
714
+ let buf = createBuffer(length);
715
+
716
+ const actual = buf.write(string, encoding);
717
+
718
+ if (actual !== length) {
719
+ // Writing a hex string, for example, that contains invalid characters will
720
+ // cause everything after the first invalid character to be ignored. (e.g.
721
+ // 'abxxcd' will be treated as 'ab')
722
+ buf = buf.slice(0, actual);
723
+ }
724
+
725
+ return buf
726
+ }
727
+
728
+ function fromArrayLike (array) {
729
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
730
+ const buf = createBuffer(length);
731
+ for (let i = 0; i < length; i += 1) {
732
+ buf[i] = array[i] & 255;
733
+ }
734
+ return buf
735
+ }
736
+
737
+ function fromArrayView (arrayView) {
738
+ if (isInstance(arrayView, Uint8Array)) {
739
+ const copy = new Uint8Array(arrayView);
740
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
741
+ }
742
+ return fromArrayLike(arrayView)
743
+ }
744
+
745
+ function fromArrayBuffer (array, byteOffset, length) {
746
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
747
+ throw new RangeError('"offset" is outside of buffer bounds')
748
+ }
749
+
750
+ if (array.byteLength < byteOffset + (length || 0)) {
751
+ throw new RangeError('"length" is outside of buffer bounds')
752
+ }
753
+
754
+ let buf;
755
+ if (byteOffset === undefined && length === undefined) {
756
+ buf = new Uint8Array(array);
757
+ } else if (length === undefined) {
758
+ buf = new Uint8Array(array, byteOffset);
759
+ } else {
760
+ buf = new Uint8Array(array, byteOffset, length);
761
+ }
762
+
763
+ // Return an augmented `Uint8Array` instance
764
+ Object.setPrototypeOf(buf, Buffer.prototype);
765
+
766
+ return buf
767
+ }
768
+
769
+ function fromObject (obj) {
770
+ if (Buffer.isBuffer(obj)) {
771
+ const len = checked(obj.length) | 0;
772
+ const buf = createBuffer(len);
773
+
774
+ if (buf.length === 0) {
775
+ return buf
776
+ }
777
+
778
+ obj.copy(buf, 0, 0, len);
779
+ return buf
780
+ }
781
+
782
+ if (obj.length !== undefined) {
783
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
784
+ return createBuffer(0)
785
+ }
786
+ return fromArrayLike(obj)
787
+ }
788
+
789
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
790
+ return fromArrayLike(obj.data)
791
+ }
792
+ }
793
+
794
+ function checked (length) {
795
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
796
+ // length is NaN (which is otherwise coerced to zero.)
797
+ if (length >= K_MAX_LENGTH) {
798
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
799
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
800
+ }
801
+ return length | 0
802
+ }
803
+
804
+ function SlowBuffer (length) {
805
+ if (+length != length) { // eslint-disable-line eqeqeq
806
+ length = 0;
807
+ }
808
+ return Buffer.alloc(+length)
809
+ }
810
+
811
+ Buffer.isBuffer = function isBuffer (b) {
812
+ return b != null && b._isBuffer === true &&
813
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
814
+ };
815
+
816
+ Buffer.compare = function compare (a, b) {
817
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
818
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
819
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
820
+ throw new TypeError(
821
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
822
+ )
823
+ }
824
+
825
+ if (a === b) return 0
826
+
827
+ let x = a.length;
828
+ let y = b.length;
829
+
830
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
831
+ if (a[i] !== b[i]) {
832
+ x = a[i];
833
+ y = b[i];
834
+ break
835
+ }
836
+ }
837
+
838
+ if (x < y) return -1
839
+ if (y < x) return 1
840
+ return 0
841
+ };
842
+
843
+ Buffer.isEncoding = function isEncoding (encoding) {
844
+ switch (String(encoding).toLowerCase()) {
845
+ case 'hex':
846
+ case 'utf8':
847
+ case 'utf-8':
848
+ case 'ascii':
849
+ case 'latin1':
850
+ case 'binary':
851
+ case 'base64':
852
+ case 'ucs2':
853
+ case 'ucs-2':
854
+ case 'utf16le':
855
+ case 'utf-16le':
856
+ return true
857
+ default:
858
+ return false
859
+ }
860
+ };
861
+
862
+ Buffer.concat = function concat (list, length) {
863
+ if (!Array.isArray(list)) {
864
+ throw new TypeError('"list" argument must be an Array of Buffers')
865
+ }
866
+
867
+ if (list.length === 0) {
868
+ return Buffer.alloc(0)
869
+ }
870
+
871
+ let i;
872
+ if (length === undefined) {
873
+ length = 0;
874
+ for (i = 0; i < list.length; ++i) {
875
+ length += list[i].length;
876
+ }
877
+ }
878
+
879
+ const buffer = Buffer.allocUnsafe(length);
880
+ let pos = 0;
881
+ for (i = 0; i < list.length; ++i) {
882
+ let buf = list[i];
883
+ if (isInstance(buf, Uint8Array)) {
884
+ if (pos + buf.length > buffer.length) {
885
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
886
+ buf.copy(buffer, pos);
887
+ } else {
888
+ Uint8Array.prototype.set.call(
889
+ buffer,
890
+ buf,
891
+ pos
892
+ );
893
+ }
894
+ } else if (!Buffer.isBuffer(buf)) {
895
+ throw new TypeError('"list" argument must be an Array of Buffers')
896
+ } else {
897
+ buf.copy(buffer, pos);
898
+ }
899
+ pos += buf.length;
900
+ }
901
+ return buffer
902
+ };
903
+
904
+ function byteLength (string, encoding) {
905
+ if (Buffer.isBuffer(string)) {
906
+ return string.length
907
+ }
908
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
909
+ return string.byteLength
910
+ }
911
+ if (typeof string !== 'string') {
912
+ throw new TypeError(
913
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
914
+ 'Received type ' + typeof string
915
+ )
916
+ }
917
+
918
+ const len = string.length;
919
+ const mustMatch = (arguments.length > 2 && arguments[2] === true);
920
+ if (!mustMatch && len === 0) return 0
921
+
922
+ // Use a for loop to avoid recursion
923
+ let loweredCase = false;
924
+ for (;;) {
925
+ switch (encoding) {
926
+ case 'ascii':
927
+ case 'latin1':
928
+ case 'binary':
929
+ return len
930
+ case 'utf8':
931
+ case 'utf-8':
932
+ return utf8ToBytes(string).length
933
+ case 'ucs2':
934
+ case 'ucs-2':
935
+ case 'utf16le':
936
+ case 'utf-16le':
937
+ return len * 2
938
+ case 'hex':
939
+ return len >>> 1
940
+ case 'base64':
941
+ return base64ToBytes(string).length
942
+ default:
943
+ if (loweredCase) {
944
+ return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
945
+ }
946
+ encoding = ('' + encoding).toLowerCase();
947
+ loweredCase = true;
948
+ }
949
+ }
950
+ }
951
+ Buffer.byteLength = byteLength;
952
+
953
+ function slowToString (encoding, start, end) {
954
+ let loweredCase = false;
955
+
956
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
957
+ // property of a typed array.
958
+
959
+ // This behaves neither like String nor Uint8Array in that we set start/end
960
+ // to their upper/lower bounds if the value passed is out of range.
961
+ // undefined is handled specially as per ECMA-262 6th Edition,
962
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
963
+ if (start === undefined || start < 0) {
964
+ start = 0;
965
+ }
966
+ // Return early if start > this.length. Done here to prevent potential uint32
967
+ // coercion fail below.
968
+ if (start > this.length) {
969
+ return ''
970
+ }
971
+
972
+ if (end === undefined || end > this.length) {
973
+ end = this.length;
974
+ }
975
+
976
+ if (end <= 0) {
977
+ return ''
978
+ }
979
+
980
+ // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
981
+ end >>>= 0;
982
+ start >>>= 0;
983
+
984
+ if (end <= start) {
985
+ return ''
986
+ }
987
+
988
+ if (!encoding) encoding = 'utf8';
989
+
990
+ while (true) {
991
+ switch (encoding) {
992
+ case 'hex':
993
+ return hexSlice(this, start, end)
994
+
995
+ case 'utf8':
996
+ case 'utf-8':
997
+ return utf8Slice(this, start, end)
998
+
999
+ case 'ascii':
1000
+ return asciiSlice(this, start, end)
1001
+
1002
+ case 'latin1':
1003
+ case 'binary':
1004
+ return latin1Slice(this, start, end)
1005
+
1006
+ case 'base64':
1007
+ return base64Slice(this, start, end)
1008
+
1009
+ case 'ucs2':
1010
+ case 'ucs-2':
1011
+ case 'utf16le':
1012
+ case 'utf-16le':
1013
+ return utf16leSlice(this, start, end)
1014
+
1015
+ default:
1016
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1017
+ encoding = (encoding + '').toLowerCase();
1018
+ loweredCase = true;
1019
+ }
1020
+ }
1021
+ }
1022
+
1023
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
1024
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
1025
+ // reliably in a browserify context because there could be multiple different
1026
+ // copies of the 'buffer' package in use. This method works even for Buffer
1027
+ // instances that were created from another copy of the `buffer` package.
1028
+ // See: https://github.com/feross/buffer/issues/154
1029
+ Buffer.prototype._isBuffer = true;
1030
+
1031
+ function swap (b, n, m) {
1032
+ const i = b[n];
1033
+ b[n] = b[m];
1034
+ b[m] = i;
1035
+ }
1036
+
1037
+ Buffer.prototype.swap16 = function swap16 () {
1038
+ const len = this.length;
1039
+ if (len % 2 !== 0) {
1040
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
1041
+ }
1042
+ for (let i = 0; i < len; i += 2) {
1043
+ swap(this, i, i + 1);
1044
+ }
1045
+ return this
1046
+ };
1047
+
1048
+ Buffer.prototype.swap32 = function swap32 () {
1049
+ const len = this.length;
1050
+ if (len % 4 !== 0) {
1051
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
1052
+ }
1053
+ for (let i = 0; i < len; i += 4) {
1054
+ swap(this, i, i + 3);
1055
+ swap(this, i + 1, i + 2);
1056
+ }
1057
+ return this
1058
+ };
1059
+
1060
+ Buffer.prototype.swap64 = function swap64 () {
1061
+ const len = this.length;
1062
+ if (len % 8 !== 0) {
1063
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
1064
+ }
1065
+ for (let i = 0; i < len; i += 8) {
1066
+ swap(this, i, i + 7);
1067
+ swap(this, i + 1, i + 6);
1068
+ swap(this, i + 2, i + 5);
1069
+ swap(this, i + 3, i + 4);
1070
+ }
1071
+ return this
1072
+ };
1073
+
1074
+ Buffer.prototype.toString = function toString () {
1075
+ const length = this.length;
1076
+ if (length === 0) return ''
1077
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
1078
+ return slowToString.apply(this, arguments)
1079
+ };
1080
+
1081
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
1082
+
1083
+ Buffer.prototype.equals = function equals (b) {
1084
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1085
+ if (this === b) return true
1086
+ return Buffer.compare(this, b) === 0
1087
+ };
1088
+
1089
+ Buffer.prototype.inspect = function inspect () {
1090
+ let str = '';
1091
+ const max = exports$1.INSPECT_MAX_BYTES;
1092
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
1093
+ if (this.length > max) str += ' ... ';
1094
+ return '<Buffer ' + str + '>'
1095
+ };
1096
+ if (customInspectSymbol) {
1097
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
1098
+ }
1099
+
1100
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1101
+ if (isInstance(target, Uint8Array)) {
1102
+ target = Buffer.from(target, target.offset, target.byteLength);
1103
+ }
1104
+ if (!Buffer.isBuffer(target)) {
1105
+ throw new TypeError(
1106
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
1107
+ 'Received type ' + (typeof target)
1108
+ )
1109
+ }
1110
+
1111
+ if (start === undefined) {
1112
+ start = 0;
1113
+ }
1114
+ if (end === undefined) {
1115
+ end = target ? target.length : 0;
1116
+ }
1117
+ if (thisStart === undefined) {
1118
+ thisStart = 0;
1119
+ }
1120
+ if (thisEnd === undefined) {
1121
+ thisEnd = this.length;
1122
+ }
1123
+
1124
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1125
+ throw new RangeError('out of range index')
1126
+ }
1127
+
1128
+ if (thisStart >= thisEnd && start >= end) {
1129
+ return 0
1130
+ }
1131
+ if (thisStart >= thisEnd) {
1132
+ return -1
1133
+ }
1134
+ if (start >= end) {
1135
+ return 1
1136
+ }
1137
+
1138
+ start >>>= 0;
1139
+ end >>>= 0;
1140
+ thisStart >>>= 0;
1141
+ thisEnd >>>= 0;
1142
+
1143
+ if (this === target) return 0
1144
+
1145
+ let x = thisEnd - thisStart;
1146
+ let y = end - start;
1147
+ const len = Math.min(x, y);
1148
+
1149
+ const thisCopy = this.slice(thisStart, thisEnd);
1150
+ const targetCopy = target.slice(start, end);
1151
+
1152
+ for (let i = 0; i < len; ++i) {
1153
+ if (thisCopy[i] !== targetCopy[i]) {
1154
+ x = thisCopy[i];
1155
+ y = targetCopy[i];
1156
+ break
1157
+ }
1158
+ }
1159
+
1160
+ if (x < y) return -1
1161
+ if (y < x) return 1
1162
+ return 0
1163
+ };
1164
+
1165
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1166
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1167
+ //
1168
+ // Arguments:
1169
+ // - buffer - a Buffer to search
1170
+ // - val - a string, Buffer, or number
1171
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
1172
+ // - encoding - an optional encoding, relevant is val is a string
1173
+ // - dir - true for indexOf, false for lastIndexOf
1174
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1175
+ // Empty buffer means no match
1176
+ if (buffer.length === 0) return -1
1177
+
1178
+ // Normalize byteOffset
1179
+ if (typeof byteOffset === 'string') {
1180
+ encoding = byteOffset;
1181
+ byteOffset = 0;
1182
+ } else if (byteOffset > 0x7fffffff) {
1183
+ byteOffset = 0x7fffffff;
1184
+ } else if (byteOffset < -2147483648) {
1185
+ byteOffset = -2147483648;
1186
+ }
1187
+ byteOffset = +byteOffset; // Coerce to Number.
1188
+ if (numberIsNaN(byteOffset)) {
1189
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1190
+ byteOffset = dir ? 0 : (buffer.length - 1);
1191
+ }
1192
+
1193
+ // Normalize byteOffset: negative offsets start from the end of the buffer
1194
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
1195
+ if (byteOffset >= buffer.length) {
1196
+ if (dir) return -1
1197
+ else byteOffset = buffer.length - 1;
1198
+ } else if (byteOffset < 0) {
1199
+ if (dir) byteOffset = 0;
1200
+ else return -1
1201
+ }
1202
+
1203
+ // Normalize val
1204
+ if (typeof val === 'string') {
1205
+ val = Buffer.from(val, encoding);
1206
+ }
1207
+
1208
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
1209
+ if (Buffer.isBuffer(val)) {
1210
+ // Special case: looking for empty string/buffer always fails
1211
+ if (val.length === 0) {
1212
+ return -1
1213
+ }
1214
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1215
+ } else if (typeof val === 'number') {
1216
+ val = val & 0xFF; // Search for a byte value [0-255]
1217
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
1218
+ if (dir) {
1219
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1220
+ } else {
1221
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1222
+ }
1223
+ }
1224
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
1225
+ }
1226
+
1227
+ throw new TypeError('val must be string, number or Buffer')
1228
+ }
1229
+
1230
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1231
+ let indexSize = 1;
1232
+ let arrLength = arr.length;
1233
+ let valLength = val.length;
1234
+
1235
+ if (encoding !== undefined) {
1236
+ encoding = String(encoding).toLowerCase();
1237
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1238
+ encoding === 'utf16le' || encoding === 'utf-16le') {
1239
+ if (arr.length < 2 || val.length < 2) {
1240
+ return -1
1241
+ }
1242
+ indexSize = 2;
1243
+ arrLength /= 2;
1244
+ valLength /= 2;
1245
+ byteOffset /= 2;
1246
+ }
1247
+ }
1248
+
1249
+ function read (buf, i) {
1250
+ if (indexSize === 1) {
1251
+ return buf[i]
1252
+ } else {
1253
+ return buf.readUInt16BE(i * indexSize)
1254
+ }
1255
+ }
1256
+
1257
+ let i;
1258
+ if (dir) {
1259
+ let foundIndex = -1;
1260
+ for (i = byteOffset; i < arrLength; i++) {
1261
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1262
+ if (foundIndex === -1) foundIndex = i;
1263
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1264
+ } else {
1265
+ if (foundIndex !== -1) i -= i - foundIndex;
1266
+ foundIndex = -1;
1267
+ }
1268
+ }
1269
+ } else {
1270
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
1271
+ for (i = byteOffset; i >= 0; i--) {
1272
+ let found = true;
1273
+ for (let j = 0; j < valLength; j++) {
1274
+ if (read(arr, i + j) !== read(val, j)) {
1275
+ found = false;
1276
+ break
1277
+ }
1278
+ }
1279
+ if (found) return i
1280
+ }
1281
+ }
1282
+
1283
+ return -1
1284
+ }
1285
+
1286
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1287
+ return this.indexOf(val, byteOffset, encoding) !== -1
1288
+ };
1289
+
1290
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1291
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1292
+ };
1293
+
1294
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1295
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1296
+ };
1297
+
1298
+ function hexWrite (buf, string, offset, length) {
1299
+ offset = Number(offset) || 0;
1300
+ const remaining = buf.length - offset;
1301
+ if (!length) {
1302
+ length = remaining;
1303
+ } else {
1304
+ length = Number(length);
1305
+ if (length > remaining) {
1306
+ length = remaining;
1307
+ }
1308
+ }
1309
+
1310
+ const strLen = string.length;
1311
+
1312
+ if (length > strLen / 2) {
1313
+ length = strLen / 2;
1314
+ }
1315
+ let i;
1316
+ for (i = 0; i < length; ++i) {
1317
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
1318
+ if (numberIsNaN(parsed)) return i
1319
+ buf[offset + i] = parsed;
1320
+ }
1321
+ return i
1322
+ }
1323
+
1324
+ function utf8Write (buf, string, offset, length) {
1325
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1326
+ }
1327
+
1328
+ function asciiWrite (buf, string, offset, length) {
1329
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
1330
+ }
1331
+
1332
+ function base64Write (buf, string, offset, length) {
1333
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
1334
+ }
1335
+
1336
+ function ucs2Write (buf, string, offset, length) {
1337
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1338
+ }
1339
+
1340
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
1341
+ // Buffer#write(string)
1342
+ if (offset === undefined) {
1343
+ encoding = 'utf8';
1344
+ length = this.length;
1345
+ offset = 0;
1346
+ // Buffer#write(string, encoding)
1347
+ } else if (length === undefined && typeof offset === 'string') {
1348
+ encoding = offset;
1349
+ length = this.length;
1350
+ offset = 0;
1351
+ // Buffer#write(string, offset[, length][, encoding])
1352
+ } else if (isFinite(offset)) {
1353
+ offset = offset >>> 0;
1354
+ if (isFinite(length)) {
1355
+ length = length >>> 0;
1356
+ if (encoding === undefined) encoding = 'utf8';
1357
+ } else {
1358
+ encoding = length;
1359
+ length = undefined;
1360
+ }
1361
+ } else {
1362
+ throw new Error(
1363
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1364
+ )
1365
+ }
1366
+
1367
+ const remaining = this.length - offset;
1368
+ if (length === undefined || length > remaining) length = remaining;
1369
+
1370
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1371
+ throw new RangeError('Attempt to write outside buffer bounds')
1372
+ }
1373
+
1374
+ if (!encoding) encoding = 'utf8';
1375
+
1376
+ let loweredCase = false;
1377
+ for (;;) {
1378
+ switch (encoding) {
1379
+ case 'hex':
1380
+ return hexWrite(this, string, offset, length)
1381
+
1382
+ case 'utf8':
1383
+ case 'utf-8':
1384
+ return utf8Write(this, string, offset, length)
1385
+
1386
+ case 'ascii':
1387
+ case 'latin1':
1388
+ case 'binary':
1389
+ return asciiWrite(this, string, offset, length)
1390
+
1391
+ case 'base64':
1392
+ // Warning: maxLength not taken into account in base64Write
1393
+ return base64Write(this, string, offset, length)
1394
+
1395
+ case 'ucs2':
1396
+ case 'ucs-2':
1397
+ case 'utf16le':
1398
+ case 'utf-16le':
1399
+ return ucs2Write(this, string, offset, length)
1400
+
1401
+ default:
1402
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1403
+ encoding = ('' + encoding).toLowerCase();
1404
+ loweredCase = true;
1405
+ }
1406
+ }
1407
+ };
1408
+
1409
+ Buffer.prototype.toJSON = function toJSON () {
1410
+ return {
1411
+ type: 'Buffer',
1412
+ data: Array.prototype.slice.call(this._arr || this, 0)
1413
+ }
1414
+ };
1415
+
1416
+ function base64Slice (buf, start, end) {
1417
+ if (start === 0 && end === buf.length) {
1418
+ return base64.fromByteArray(buf)
1419
+ } else {
1420
+ return base64.fromByteArray(buf.slice(start, end))
1421
+ }
1422
+ }
1423
+
1424
+ function utf8Slice (buf, start, end) {
1425
+ end = Math.min(buf.length, end);
1426
+ const res = [];
1427
+
1428
+ let i = start;
1429
+ while (i < end) {
1430
+ const firstByte = buf[i];
1431
+ let codePoint = null;
1432
+ let bytesPerSequence = (firstByte > 0xEF)
1433
+ ? 4
1434
+ : (firstByte > 0xDF)
1435
+ ? 3
1436
+ : (firstByte > 0xBF)
1437
+ ? 2
1438
+ : 1;
1439
+
1440
+ if (i + bytesPerSequence <= end) {
1441
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
1442
+
1443
+ switch (bytesPerSequence) {
1444
+ case 1:
1445
+ if (firstByte < 0x80) {
1446
+ codePoint = firstByte;
1447
+ }
1448
+ break
1449
+ case 2:
1450
+ secondByte = buf[i + 1];
1451
+ if ((secondByte & 0xC0) === 0x80) {
1452
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
1453
+ if (tempCodePoint > 0x7F) {
1454
+ codePoint = tempCodePoint;
1455
+ }
1456
+ }
1457
+ break
1458
+ case 3:
1459
+ secondByte = buf[i + 1];
1460
+ thirdByte = buf[i + 2];
1461
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1462
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
1463
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1464
+ codePoint = tempCodePoint;
1465
+ }
1466
+ }
1467
+ break
1468
+ case 4:
1469
+ secondByte = buf[i + 1];
1470
+ thirdByte = buf[i + 2];
1471
+ fourthByte = buf[i + 3];
1472
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1473
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
1474
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1475
+ codePoint = tempCodePoint;
1476
+ }
1477
+ }
1478
+ }
1479
+ }
1480
+
1481
+ if (codePoint === null) {
1482
+ // we did not generate a valid codePoint so insert a
1483
+ // replacement char (U+FFFD) and advance only 1 byte
1484
+ codePoint = 0xFFFD;
1485
+ bytesPerSequence = 1;
1486
+ } else if (codePoint > 0xFFFF) {
1487
+ // encode to utf16 (surrogate pair dance)
1488
+ codePoint -= 0x10000;
1489
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800);
1490
+ codePoint = 0xDC00 | codePoint & 0x3FF;
1491
+ }
1492
+
1493
+ res.push(codePoint);
1494
+ i += bytesPerSequence;
1495
+ }
1496
+
1497
+ return decodeCodePointsArray(res)
1498
+ }
1499
+
1500
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1501
+ // the lowest limit is Chrome, with 0x10000 args.
1502
+ // We go 1 magnitude less, for safety
1503
+ const MAX_ARGUMENTS_LENGTH = 0x1000;
1504
+
1505
+ function decodeCodePointsArray (codePoints) {
1506
+ const len = codePoints.length;
1507
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1508
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1509
+ }
1510
+
1511
+ // Decode in chunks to avoid "call stack size exceeded".
1512
+ let res = '';
1513
+ let i = 0;
1514
+ while (i < len) {
1515
+ res += String.fromCharCode.apply(
1516
+ String,
1517
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1518
+ );
1519
+ }
1520
+ return res
1521
+ }
1522
+
1523
+ function asciiSlice (buf, start, end) {
1524
+ let ret = '';
1525
+ end = Math.min(buf.length, end);
1526
+
1527
+ for (let i = start; i < end; ++i) {
1528
+ ret += String.fromCharCode(buf[i] & 0x7F);
1529
+ }
1530
+ return ret
1531
+ }
1532
+
1533
+ function latin1Slice (buf, start, end) {
1534
+ let ret = '';
1535
+ end = Math.min(buf.length, end);
1536
+
1537
+ for (let i = start; i < end; ++i) {
1538
+ ret += String.fromCharCode(buf[i]);
1539
+ }
1540
+ return ret
1541
+ }
1542
+
1543
+ function hexSlice (buf, start, end) {
1544
+ const len = buf.length;
1545
+
1546
+ if (!start || start < 0) start = 0;
1547
+ if (!end || end < 0 || end > len) end = len;
1548
+
1549
+ let out = '';
1550
+ for (let i = start; i < end; ++i) {
1551
+ out += hexSliceLookupTable[buf[i]];
1552
+ }
1553
+ return out
1554
+ }
1555
+
1556
+ function utf16leSlice (buf, start, end) {
1557
+ const bytes = buf.slice(start, end);
1558
+ let res = '';
1559
+ // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
1560
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1561
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
1562
+ }
1563
+ return res
1564
+ }
1565
+
1566
+ Buffer.prototype.slice = function slice (start, end) {
1567
+ const len = this.length;
1568
+ start = ~~start;
1569
+ end = end === undefined ? len : ~~end;
1570
+
1571
+ if (start < 0) {
1572
+ start += len;
1573
+ if (start < 0) start = 0;
1574
+ } else if (start > len) {
1575
+ start = len;
1576
+ }
1577
+
1578
+ if (end < 0) {
1579
+ end += len;
1580
+ if (end < 0) end = 0;
1581
+ } else if (end > len) {
1582
+ end = len;
1583
+ }
1584
+
1585
+ if (end < start) end = start;
1586
+
1587
+ const newBuf = this.subarray(start, end);
1588
+ // Return an augmented `Uint8Array` instance
1589
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
1590
+
1591
+ return newBuf
1592
+ };
1593
+
1594
+ /*
1595
+ * Need to make sure that buffer isn't trying to write out of bounds.
1596
+ */
1597
+ function checkOffset (offset, ext, length) {
1598
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1599
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1600
+ }
1601
+
1602
+ Buffer.prototype.readUintLE =
1603
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1604
+ offset = offset >>> 0;
1605
+ byteLength = byteLength >>> 0;
1606
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
1607
+
1608
+ let val = this[offset];
1609
+ let mul = 1;
1610
+ let i = 0;
1611
+ while (++i < byteLength && (mul *= 0x100)) {
1612
+ val += this[offset + i] * mul;
1613
+ }
1614
+
1615
+ return val
1616
+ };
1617
+
1618
+ Buffer.prototype.readUintBE =
1619
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1620
+ offset = offset >>> 0;
1621
+ byteLength = byteLength >>> 0;
1622
+ if (!noAssert) {
1623
+ checkOffset(offset, byteLength, this.length);
1624
+ }
1625
+
1626
+ let val = this[offset + --byteLength];
1627
+ let mul = 1;
1628
+ while (byteLength > 0 && (mul *= 0x100)) {
1629
+ val += this[offset + --byteLength] * mul;
1630
+ }
1631
+
1632
+ return val
1633
+ };
1634
+
1635
+ Buffer.prototype.readUint8 =
1636
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1637
+ offset = offset >>> 0;
1638
+ if (!noAssert) checkOffset(offset, 1, this.length);
1639
+ return this[offset]
1640
+ };
1641
+
1642
+ Buffer.prototype.readUint16LE =
1643
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1644
+ offset = offset >>> 0;
1645
+ if (!noAssert) checkOffset(offset, 2, this.length);
1646
+ return this[offset] | (this[offset + 1] << 8)
1647
+ };
1648
+
1649
+ Buffer.prototype.readUint16BE =
1650
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1651
+ offset = offset >>> 0;
1652
+ if (!noAssert) checkOffset(offset, 2, this.length);
1653
+ return (this[offset] << 8) | this[offset + 1]
1654
+ };
1655
+
1656
+ Buffer.prototype.readUint32LE =
1657
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1658
+ offset = offset >>> 0;
1659
+ if (!noAssert) checkOffset(offset, 4, this.length);
1660
+
1661
+ return ((this[offset]) |
1662
+ (this[offset + 1] << 8) |
1663
+ (this[offset + 2] << 16)) +
1664
+ (this[offset + 3] * 0x1000000)
1665
+ };
1666
+
1667
+ Buffer.prototype.readUint32BE =
1668
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1669
+ offset = offset >>> 0;
1670
+ if (!noAssert) checkOffset(offset, 4, this.length);
1671
+
1672
+ return (this[offset] * 0x1000000) +
1673
+ ((this[offset + 1] << 16) |
1674
+ (this[offset + 2] << 8) |
1675
+ this[offset + 3])
1676
+ };
1677
+
1678
+ Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
1679
+ offset = offset >>> 0;
1680
+ validateNumber(offset, 'offset');
1681
+ const first = this[offset];
1682
+ const last = this[offset + 7];
1683
+ if (first === undefined || last === undefined) {
1684
+ boundsError(offset, this.length - 8);
1685
+ }
1686
+
1687
+ const lo = first +
1688
+ this[++offset] * 2 ** 8 +
1689
+ this[++offset] * 2 ** 16 +
1690
+ this[++offset] * 2 ** 24;
1691
+
1692
+ const hi = this[++offset] +
1693
+ this[++offset] * 2 ** 8 +
1694
+ this[++offset] * 2 ** 16 +
1695
+ last * 2 ** 24;
1696
+
1697
+ return BigInt(lo) + (BigInt(hi) << BigInt(32))
1698
+ });
1699
+
1700
+ Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
1701
+ offset = offset >>> 0;
1702
+ validateNumber(offset, 'offset');
1703
+ const first = this[offset];
1704
+ const last = this[offset + 7];
1705
+ if (first === undefined || last === undefined) {
1706
+ boundsError(offset, this.length - 8);
1707
+ }
1708
+
1709
+ const hi = first * 2 ** 24 +
1710
+ this[++offset] * 2 ** 16 +
1711
+ this[++offset] * 2 ** 8 +
1712
+ this[++offset];
1713
+
1714
+ const lo = this[++offset] * 2 ** 24 +
1715
+ this[++offset] * 2 ** 16 +
1716
+ this[++offset] * 2 ** 8 +
1717
+ last;
1718
+
1719
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo)
1720
+ });
1721
+
1722
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1723
+ offset = offset >>> 0;
1724
+ byteLength = byteLength >>> 0;
1725
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
1726
+
1727
+ let val = this[offset];
1728
+ let mul = 1;
1729
+ let i = 0;
1730
+ while (++i < byteLength && (mul *= 0x100)) {
1731
+ val += this[offset + i] * mul;
1732
+ }
1733
+ mul *= 0x80;
1734
+
1735
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1736
+
1737
+ return val
1738
+ };
1739
+
1740
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1741
+ offset = offset >>> 0;
1742
+ byteLength = byteLength >>> 0;
1743
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
1744
+
1745
+ let i = byteLength;
1746
+ let mul = 1;
1747
+ let val = this[offset + --i];
1748
+ while (i > 0 && (mul *= 0x100)) {
1749
+ val += this[offset + --i] * mul;
1750
+ }
1751
+ mul *= 0x80;
1752
+
1753
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1754
+
1755
+ return val
1756
+ };
1757
+
1758
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1759
+ offset = offset >>> 0;
1760
+ if (!noAssert) checkOffset(offset, 1, this.length);
1761
+ if (!(this[offset] & 0x80)) return (this[offset])
1762
+ return ((0xff - this[offset] + 1) * -1)
1763
+ };
1764
+
1765
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1766
+ offset = offset >>> 0;
1767
+ if (!noAssert) checkOffset(offset, 2, this.length);
1768
+ const val = this[offset] | (this[offset + 1] << 8);
1769
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
1770
+ };
1771
+
1772
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1773
+ offset = offset >>> 0;
1774
+ if (!noAssert) checkOffset(offset, 2, this.length);
1775
+ const val = this[offset + 1] | (this[offset] << 8);
1776
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
1777
+ };
1778
+
1779
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1780
+ offset = offset >>> 0;
1781
+ if (!noAssert) checkOffset(offset, 4, this.length);
1782
+
1783
+ return (this[offset]) |
1784
+ (this[offset + 1] << 8) |
1785
+ (this[offset + 2] << 16) |
1786
+ (this[offset + 3] << 24)
1787
+ };
1788
+
1789
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1790
+ offset = offset >>> 0;
1791
+ if (!noAssert) checkOffset(offset, 4, this.length);
1792
+
1793
+ return (this[offset] << 24) |
1794
+ (this[offset + 1] << 16) |
1795
+ (this[offset + 2] << 8) |
1796
+ (this[offset + 3])
1797
+ };
1798
+
1799
+ Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
1800
+ offset = offset >>> 0;
1801
+ validateNumber(offset, 'offset');
1802
+ const first = this[offset];
1803
+ const last = this[offset + 7];
1804
+ if (first === undefined || last === undefined) {
1805
+ boundsError(offset, this.length - 8);
1806
+ }
1807
+
1808
+ const val = this[offset + 4] +
1809
+ this[offset + 5] * 2 ** 8 +
1810
+ this[offset + 6] * 2 ** 16 +
1811
+ (last << 24); // Overflow
1812
+
1813
+ return (BigInt(val) << BigInt(32)) +
1814
+ BigInt(first +
1815
+ this[++offset] * 2 ** 8 +
1816
+ this[++offset] * 2 ** 16 +
1817
+ this[++offset] * 2 ** 24)
1818
+ });
1819
+
1820
+ Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
1821
+ offset = offset >>> 0;
1822
+ validateNumber(offset, 'offset');
1823
+ const first = this[offset];
1824
+ const last = this[offset + 7];
1825
+ if (first === undefined || last === undefined) {
1826
+ boundsError(offset, this.length - 8);
1827
+ }
1828
+
1829
+ const val = (first << 24) + // Overflow
1830
+ this[++offset] * 2 ** 16 +
1831
+ this[++offset] * 2 ** 8 +
1832
+ this[++offset];
1833
+
1834
+ return (BigInt(val) << BigInt(32)) +
1835
+ BigInt(this[++offset] * 2 ** 24 +
1836
+ this[++offset] * 2 ** 16 +
1837
+ this[++offset] * 2 ** 8 +
1838
+ last)
1839
+ });
1840
+
1841
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1842
+ offset = offset >>> 0;
1843
+ if (!noAssert) checkOffset(offset, 4, this.length);
1844
+ return ieee754.read(this, offset, true, 23, 4)
1845
+ };
1846
+
1847
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1848
+ offset = offset >>> 0;
1849
+ if (!noAssert) checkOffset(offset, 4, this.length);
1850
+ return ieee754.read(this, offset, false, 23, 4)
1851
+ };
1852
+
1853
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1854
+ offset = offset >>> 0;
1855
+ if (!noAssert) checkOffset(offset, 8, this.length);
1856
+ return ieee754.read(this, offset, true, 52, 8)
1857
+ };
1858
+
1859
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1860
+ offset = offset >>> 0;
1861
+ if (!noAssert) checkOffset(offset, 8, this.length);
1862
+ return ieee754.read(this, offset, false, 52, 8)
1863
+ };
1864
+
1865
+ function checkInt (buf, value, offset, ext, max, min) {
1866
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1867
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1868
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
1869
+ }
1870
+
1871
+ Buffer.prototype.writeUintLE =
1872
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1873
+ value = +value;
1874
+ offset = offset >>> 0;
1875
+ byteLength = byteLength >>> 0;
1876
+ if (!noAssert) {
1877
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1878
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
1879
+ }
1880
+
1881
+ let mul = 1;
1882
+ let i = 0;
1883
+ this[offset] = value & 0xFF;
1884
+ while (++i < byteLength && (mul *= 0x100)) {
1885
+ this[offset + i] = (value / mul) & 0xFF;
1886
+ }
1887
+
1888
+ return offset + byteLength
1889
+ };
1890
+
1891
+ Buffer.prototype.writeUintBE =
1892
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1893
+ value = +value;
1894
+ offset = offset >>> 0;
1895
+ byteLength = byteLength >>> 0;
1896
+ if (!noAssert) {
1897
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1898
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
1899
+ }
1900
+
1901
+ let i = byteLength - 1;
1902
+ let mul = 1;
1903
+ this[offset + i] = value & 0xFF;
1904
+ while (--i >= 0 && (mul *= 0x100)) {
1905
+ this[offset + i] = (value / mul) & 0xFF;
1906
+ }
1907
+
1908
+ return offset + byteLength
1909
+ };
1910
+
1911
+ Buffer.prototype.writeUint8 =
1912
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1913
+ value = +value;
1914
+ offset = offset >>> 0;
1915
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
1916
+ this[offset] = (value & 0xff);
1917
+ return offset + 1
1918
+ };
1919
+
1920
+ Buffer.prototype.writeUint16LE =
1921
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1922
+ value = +value;
1923
+ offset = offset >>> 0;
1924
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1925
+ this[offset] = (value & 0xff);
1926
+ this[offset + 1] = (value >>> 8);
1927
+ return offset + 2
1928
+ };
1929
+
1930
+ Buffer.prototype.writeUint16BE =
1931
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1932
+ value = +value;
1933
+ offset = offset >>> 0;
1934
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1935
+ this[offset] = (value >>> 8);
1936
+ this[offset + 1] = (value & 0xff);
1937
+ return offset + 2
1938
+ };
1939
+
1940
+ Buffer.prototype.writeUint32LE =
1941
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1942
+ value = +value;
1943
+ offset = offset >>> 0;
1944
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1945
+ this[offset + 3] = (value >>> 24);
1946
+ this[offset + 2] = (value >>> 16);
1947
+ this[offset + 1] = (value >>> 8);
1948
+ this[offset] = (value & 0xff);
1949
+ return offset + 4
1950
+ };
1951
+
1952
+ Buffer.prototype.writeUint32BE =
1953
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1954
+ value = +value;
1955
+ offset = offset >>> 0;
1956
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1957
+ this[offset] = (value >>> 24);
1958
+ this[offset + 1] = (value >>> 16);
1959
+ this[offset + 2] = (value >>> 8);
1960
+ this[offset + 3] = (value & 0xff);
1961
+ return offset + 4
1962
+ };
1963
+
1964
+ function wrtBigUInt64LE (buf, value, offset, min, max) {
1965
+ checkIntBI(value, min, max, buf, offset, 7);
1966
+
1967
+ let lo = Number(value & BigInt(0xffffffff));
1968
+ buf[offset++] = lo;
1969
+ lo = lo >> 8;
1970
+ buf[offset++] = lo;
1971
+ lo = lo >> 8;
1972
+ buf[offset++] = lo;
1973
+ lo = lo >> 8;
1974
+ buf[offset++] = lo;
1975
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1976
+ buf[offset++] = hi;
1977
+ hi = hi >> 8;
1978
+ buf[offset++] = hi;
1979
+ hi = hi >> 8;
1980
+ buf[offset++] = hi;
1981
+ hi = hi >> 8;
1982
+ buf[offset++] = hi;
1983
+ return offset
1984
+ }
1985
+
1986
+ function wrtBigUInt64BE (buf, value, offset, min, max) {
1987
+ checkIntBI(value, min, max, buf, offset, 7);
1988
+
1989
+ let lo = Number(value & BigInt(0xffffffff));
1990
+ buf[offset + 7] = lo;
1991
+ lo = lo >> 8;
1992
+ buf[offset + 6] = lo;
1993
+ lo = lo >> 8;
1994
+ buf[offset + 5] = lo;
1995
+ lo = lo >> 8;
1996
+ buf[offset + 4] = lo;
1997
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1998
+ buf[offset + 3] = hi;
1999
+ hi = hi >> 8;
2000
+ buf[offset + 2] = hi;
2001
+ hi = hi >> 8;
2002
+ buf[offset + 1] = hi;
2003
+ hi = hi >> 8;
2004
+ buf[offset] = hi;
2005
+ return offset + 8
2006
+ }
2007
+
2008
+ Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
2009
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
2010
+ });
2011
+
2012
+ Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
2013
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
2014
+ });
2015
+
2016
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
2017
+ value = +value;
2018
+ offset = offset >>> 0;
2019
+ if (!noAssert) {
2020
+ const limit = Math.pow(2, (8 * byteLength) - 1);
2021
+
2022
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
2023
+ }
2024
+
2025
+ let i = 0;
2026
+ let mul = 1;
2027
+ let sub = 0;
2028
+ this[offset] = value & 0xFF;
2029
+ while (++i < byteLength && (mul *= 0x100)) {
2030
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2031
+ sub = 1;
2032
+ }
2033
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
2034
+ }
2035
+
2036
+ return offset + byteLength
2037
+ };
2038
+
2039
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
2040
+ value = +value;
2041
+ offset = offset >>> 0;
2042
+ if (!noAssert) {
2043
+ const limit = Math.pow(2, (8 * byteLength) - 1);
2044
+
2045
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
2046
+ }
2047
+
2048
+ let i = byteLength - 1;
2049
+ let mul = 1;
2050
+ let sub = 0;
2051
+ this[offset + i] = value & 0xFF;
2052
+ while (--i >= 0 && (mul *= 0x100)) {
2053
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2054
+ sub = 1;
2055
+ }
2056
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
2057
+ }
2058
+
2059
+ return offset + byteLength
2060
+ };
2061
+
2062
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2063
+ value = +value;
2064
+ offset = offset >>> 0;
2065
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
2066
+ if (value < 0) value = 0xff + value + 1;
2067
+ this[offset] = (value & 0xff);
2068
+ return offset + 1
2069
+ };
2070
+
2071
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2072
+ value = +value;
2073
+ offset = offset >>> 0;
2074
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
2075
+ this[offset] = (value & 0xff);
2076
+ this[offset + 1] = (value >>> 8);
2077
+ return offset + 2
2078
+ };
2079
+
2080
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2081
+ value = +value;
2082
+ offset = offset >>> 0;
2083
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
2084
+ this[offset] = (value >>> 8);
2085
+ this[offset + 1] = (value & 0xff);
2086
+ return offset + 2
2087
+ };
2088
+
2089
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2090
+ value = +value;
2091
+ offset = offset >>> 0;
2092
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
2093
+ this[offset] = (value & 0xff);
2094
+ this[offset + 1] = (value >>> 8);
2095
+ this[offset + 2] = (value >>> 16);
2096
+ this[offset + 3] = (value >>> 24);
2097
+ return offset + 4
2098
+ };
2099
+
2100
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2101
+ value = +value;
2102
+ offset = offset >>> 0;
2103
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
2104
+ if (value < 0) value = 0xffffffff + value + 1;
2105
+ this[offset] = (value >>> 24);
2106
+ this[offset + 1] = (value >>> 16);
2107
+ this[offset + 2] = (value >>> 8);
2108
+ this[offset + 3] = (value & 0xff);
2109
+ return offset + 4
2110
+ };
2111
+
2112
+ Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
2113
+ return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
2114
+ });
2115
+
2116
+ Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
2117
+ return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
2118
+ });
2119
+
2120
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
2121
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
2122
+ if (offset < 0) throw new RangeError('Index out of range')
2123
+ }
2124
+
2125
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
2126
+ value = +value;
2127
+ offset = offset >>> 0;
2128
+ if (!noAssert) {
2129
+ checkIEEE754(buf, value, offset, 4);
2130
+ }
2131
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
2132
+ return offset + 4
2133
+ }
2134
+
2135
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2136
+ return writeFloat(this, value, offset, true, noAssert)
2137
+ };
2138
+
2139
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2140
+ return writeFloat(this, value, offset, false, noAssert)
2141
+ };
2142
+
2143
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
2144
+ value = +value;
2145
+ offset = offset >>> 0;
2146
+ if (!noAssert) {
2147
+ checkIEEE754(buf, value, offset, 8);
2148
+ }
2149
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
2150
+ return offset + 8
2151
+ }
2152
+
2153
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2154
+ return writeDouble(this, value, offset, true, noAssert)
2155
+ };
2156
+
2157
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2158
+ return writeDouble(this, value, offset, false, noAssert)
2159
+ };
2160
+
2161
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2162
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2163
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
2164
+ if (!start) start = 0;
2165
+ if (!end && end !== 0) end = this.length;
2166
+ if (targetStart >= target.length) targetStart = target.length;
2167
+ if (!targetStart) targetStart = 0;
2168
+ if (end > 0 && end < start) end = start;
2169
+
2170
+ // Copy 0 bytes; we're done
2171
+ if (end === start) return 0
2172
+ if (target.length === 0 || this.length === 0) return 0
2173
+
2174
+ // Fatal error conditions
2175
+ if (targetStart < 0) {
2176
+ throw new RangeError('targetStart out of bounds')
2177
+ }
2178
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
2179
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
2180
+
2181
+ // Are we oob?
2182
+ if (end > this.length) end = this.length;
2183
+ if (target.length - targetStart < end - start) {
2184
+ end = target.length - targetStart + start;
2185
+ }
2186
+
2187
+ const len = end - start;
2188
+
2189
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
2190
+ // Use built-in when available, missing from IE11
2191
+ this.copyWithin(targetStart, start, end);
2192
+ } else {
2193
+ Uint8Array.prototype.set.call(
2194
+ target,
2195
+ this.subarray(start, end),
2196
+ targetStart
2197
+ );
2198
+ }
2199
+
2200
+ return len
2201
+ };
2202
+
2203
+ // Usage:
2204
+ // buffer.fill(number[, offset[, end]])
2205
+ // buffer.fill(buffer[, offset[, end]])
2206
+ // buffer.fill(string[, offset[, end]][, encoding])
2207
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
2208
+ // Handle string cases:
2209
+ if (typeof val === 'string') {
2210
+ if (typeof start === 'string') {
2211
+ encoding = start;
2212
+ start = 0;
2213
+ end = this.length;
2214
+ } else if (typeof end === 'string') {
2215
+ encoding = end;
2216
+ end = this.length;
2217
+ }
2218
+ if (encoding !== undefined && typeof encoding !== 'string') {
2219
+ throw new TypeError('encoding must be a string')
2220
+ }
2221
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2222
+ throw new TypeError('Unknown encoding: ' + encoding)
2223
+ }
2224
+ if (val.length === 1) {
2225
+ const code = val.charCodeAt(0);
2226
+ if ((encoding === 'utf8' && code < 128) ||
2227
+ encoding === 'latin1') {
2228
+ // Fast path: If `val` fits into a single byte, use that numeric value.
2229
+ val = code;
2230
+ }
2231
+ }
2232
+ } else if (typeof val === 'number') {
2233
+ val = val & 255;
2234
+ } else if (typeof val === 'boolean') {
2235
+ val = Number(val);
2236
+ }
2237
+
2238
+ // Invalid ranges are not set to a default, so can range check early.
2239
+ if (start < 0 || this.length < start || this.length < end) {
2240
+ throw new RangeError('Out of range index')
2241
+ }
2242
+
2243
+ if (end <= start) {
2244
+ return this
2245
+ }
2246
+
2247
+ start = start >>> 0;
2248
+ end = end === undefined ? this.length : end >>> 0;
2249
+
2250
+ if (!val) val = 0;
2251
+
2252
+ let i;
2253
+ if (typeof val === 'number') {
2254
+ for (i = start; i < end; ++i) {
2255
+ this[i] = val;
2256
+ }
2257
+ } else {
2258
+ const bytes = Buffer.isBuffer(val)
2259
+ ? val
2260
+ : Buffer.from(val, encoding);
2261
+ const len = bytes.length;
2262
+ if (len === 0) {
2263
+ throw new TypeError('The value "' + val +
2264
+ '" is invalid for argument "value"')
2265
+ }
2266
+ for (i = 0; i < end - start; ++i) {
2267
+ this[i + start] = bytes[i % len];
2268
+ }
2269
+ }
2270
+
2271
+ return this
2272
+ };
2273
+
2274
+ // CUSTOM ERRORS
2275
+ // =============
2276
+
2277
+ // Simplified versions from Node, changed for Buffer-only usage
2278
+ const errors = {};
2279
+ function E (sym, getMessage, Base) {
2280
+ errors[sym] = class NodeError extends Base {
2281
+ constructor () {
2282
+ super();
2283
+
2284
+ Object.defineProperty(this, 'message', {
2285
+ value: getMessage.apply(this, arguments),
2286
+ writable: true,
2287
+ configurable: true
2288
+ });
2289
+
2290
+ // Add the error code to the name to include it in the stack trace.
2291
+ this.name = `${this.name} [${sym}]`;
2292
+ // Access the stack to generate the error message including the error code
2293
+ // from the name.
2294
+ this.stack; // eslint-disable-line no-unused-expressions
2295
+ // Reset the name to the actual name.
2296
+ delete this.name;
2297
+ }
2298
+
2299
+ get code () {
2300
+ return sym
2301
+ }
2302
+
2303
+ set code (value) {
2304
+ Object.defineProperty(this, 'code', {
2305
+ configurable: true,
2306
+ enumerable: true,
2307
+ value,
2308
+ writable: true
2309
+ });
2310
+ }
2311
+
2312
+ toString () {
2313
+ return `${this.name} [${sym}]: ${this.message}`
2314
+ }
2315
+ };
2316
+ }
2317
+
2318
+ E('ERR_BUFFER_OUT_OF_BOUNDS',
2319
+ function (name) {
2320
+ if (name) {
2321
+ return `${name} is outside of buffer bounds`
2322
+ }
2323
+
2324
+ return 'Attempt to access memory outside buffer bounds'
2325
+ }, RangeError);
2326
+ E('ERR_INVALID_ARG_TYPE',
2327
+ function (name, actual) {
2328
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`
2329
+ }, TypeError);
2330
+ E('ERR_OUT_OF_RANGE',
2331
+ function (str, range, input) {
2332
+ let msg = `The value of "${str}" is out of range.`;
2333
+ let received = input;
2334
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
2335
+ received = addNumericalSeparator(String(input));
2336
+ } else if (typeof input === 'bigint') {
2337
+ received = String(input);
2338
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
2339
+ received = addNumericalSeparator(received);
2340
+ }
2341
+ received += 'n';
2342
+ }
2343
+ msg += ` It must be ${range}. Received ${received}`;
2344
+ return msg
2345
+ }, RangeError);
2346
+
2347
+ function addNumericalSeparator (val) {
2348
+ let res = '';
2349
+ let i = val.length;
2350
+ const start = val[0] === '-' ? 1 : 0;
2351
+ for (; i >= start + 4; i -= 3) {
2352
+ res = `_${val.slice(i - 3, i)}${res}`;
2353
+ }
2354
+ return `${val.slice(0, i)}${res}`
2355
+ }
2356
+
2357
+ // CHECK FUNCTIONS
2358
+ // ===============
2359
+
2360
+ function checkBounds (buf, offset, byteLength) {
2361
+ validateNumber(offset, 'offset');
2362
+ if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
2363
+ boundsError(offset, buf.length - (byteLength + 1));
2364
+ }
2365
+ }
2366
+
2367
+ function checkIntBI (value, min, max, buf, offset, byteLength) {
2368
+ if (value > max || value < min) {
2369
+ const n = typeof min === 'bigint' ? 'n' : '';
2370
+ let range;
2371
+ {
2372
+ if (min === 0 || min === BigInt(0)) {
2373
+ range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
2374
+ } else {
2375
+ range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
2376
+ `${(byteLength + 1) * 8 - 1}${n}`;
2377
+ }
2378
+ }
2379
+ throw new errors.ERR_OUT_OF_RANGE('value', range, value)
2380
+ }
2381
+ checkBounds(buf, offset, byteLength);
2382
+ }
2383
+
2384
+ function validateNumber (value, name) {
2385
+ if (typeof value !== 'number') {
2386
+ throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
2387
+ }
2388
+ }
2389
+
2390
+ function boundsError (value, length, type) {
2391
+ if (Math.floor(value) !== value) {
2392
+ validateNumber(value, type);
2393
+ throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
2394
+ }
2395
+
2396
+ if (length < 0) {
2397
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
2398
+ }
2399
+
2400
+ throw new errors.ERR_OUT_OF_RANGE('offset',
2401
+ `>= ${0} and <= ${length}`,
2402
+ value)
2403
+ }
2404
+
2405
+ // HELPER FUNCTIONS
2406
+ // ================
2407
+
2408
+ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
2409
+
2410
+ function base64clean (str) {
2411
+ // Node takes equal signs as end of the Base64 encoding
2412
+ str = str.split('=')[0];
2413
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
2414
+ str = str.trim().replace(INVALID_BASE64_RE, '');
2415
+ // Node converts strings with length < 2 to ''
2416
+ if (str.length < 2) return ''
2417
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2418
+ while (str.length % 4 !== 0) {
2419
+ str = str + '=';
2420
+ }
2421
+ return str
2422
+ }
2423
+
2424
+ function utf8ToBytes (string, units) {
2425
+ units = units || Infinity;
2426
+ let codePoint;
2427
+ const length = string.length;
2428
+ let leadSurrogate = null;
2429
+ const bytes = [];
2430
+
2431
+ for (let i = 0; i < length; ++i) {
2432
+ codePoint = string.charCodeAt(i);
2433
+
2434
+ // is surrogate component
2435
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
2436
+ // last char was a lead
2437
+ if (!leadSurrogate) {
2438
+ // no lead yet
2439
+ if (codePoint > 0xDBFF) {
2440
+ // unexpected trail
2441
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2442
+ continue
2443
+ } else if (i + 1 === length) {
2444
+ // unpaired lead
2445
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2446
+ continue
2447
+ }
2448
+
2449
+ // valid lead
2450
+ leadSurrogate = codePoint;
2451
+
2452
+ continue
2453
+ }
2454
+
2455
+ // 2 leads in a row
2456
+ if (codePoint < 0xDC00) {
2457
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2458
+ leadSurrogate = codePoint;
2459
+ continue
2460
+ }
2461
+
2462
+ // valid surrogate pair
2463
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
2464
+ } else if (leadSurrogate) {
2465
+ // valid bmp char, but last char was a lead
2466
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2467
+ }
2468
+
2469
+ leadSurrogate = null;
2470
+
2471
+ // encode utf8
2472
+ if (codePoint < 0x80) {
2473
+ if ((units -= 1) < 0) break
2474
+ bytes.push(codePoint);
2475
+ } else if (codePoint < 0x800) {
2476
+ if ((units -= 2) < 0) break
2477
+ bytes.push(
2478
+ codePoint >> 0x6 | 0xC0,
2479
+ codePoint & 0x3F | 0x80
2480
+ );
2481
+ } else if (codePoint < 0x10000) {
2482
+ if ((units -= 3) < 0) break
2483
+ bytes.push(
2484
+ codePoint >> 0xC | 0xE0,
2485
+ codePoint >> 0x6 & 0x3F | 0x80,
2486
+ codePoint & 0x3F | 0x80
2487
+ );
2488
+ } else if (codePoint < 0x110000) {
2489
+ if ((units -= 4) < 0) break
2490
+ bytes.push(
2491
+ codePoint >> 0x12 | 0xF0,
2492
+ codePoint >> 0xC & 0x3F | 0x80,
2493
+ codePoint >> 0x6 & 0x3F | 0x80,
2494
+ codePoint & 0x3F | 0x80
2495
+ );
2496
+ } else {
2497
+ throw new Error('Invalid code point')
2498
+ }
2499
+ }
2500
+
2501
+ return bytes
2502
+ }
2503
+
2504
+ function asciiToBytes (str) {
2505
+ const byteArray = [];
2506
+ for (let i = 0; i < str.length; ++i) {
2507
+ // Node's code seems to be doing this and not & 0x7F..
2508
+ byteArray.push(str.charCodeAt(i) & 0xFF);
2509
+ }
2510
+ return byteArray
2511
+ }
2512
+
2513
+ function utf16leToBytes (str, units) {
2514
+ let c, hi, lo;
2515
+ const byteArray = [];
2516
+ for (let i = 0; i < str.length; ++i) {
2517
+ if ((units -= 2) < 0) break
2518
+
2519
+ c = str.charCodeAt(i);
2520
+ hi = c >> 8;
2521
+ lo = c % 256;
2522
+ byteArray.push(lo);
2523
+ byteArray.push(hi);
2524
+ }
2525
+
2526
+ return byteArray
2527
+ }
2528
+
2529
+ function base64ToBytes (str) {
2530
+ return base64.toByteArray(base64clean(str))
2531
+ }
2532
+
2533
+ function blitBuffer (src, dst, offset, length) {
2534
+ let i;
2535
+ for (i = 0; i < length; ++i) {
2536
+ if ((i + offset >= dst.length) || (i >= src.length)) break
2537
+ dst[i + offset] = src[i];
2538
+ }
2539
+ return i
2540
+ }
2541
+
2542
+ // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
2543
+ // the `instanceof` check but they should be treated as of that type.
2544
+ // See: https://github.com/feross/buffer/issues/166
2545
+ function isInstance (obj, type) {
2546
+ return obj instanceof type ||
2547
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
2548
+ obj.constructor.name === type.name)
2549
+ }
2550
+ function numberIsNaN (obj) {
2551
+ // For IE11 support
2552
+ return obj !== obj // eslint-disable-line no-self-compare
2553
+ }
2554
+
2555
+ // Create lookup table for `toString('hex')`
2556
+ // See: https://github.com/feross/buffer/issues/219
2557
+ const hexSliceLookupTable = (function () {
2558
+ const alphabet = '0123456789abcdef';
2559
+ const table = new Array(256);
2560
+ for (let i = 0; i < 16; ++i) {
2561
+ const i16 = i * 16;
2562
+ for (let j = 0; j < 16; ++j) {
2563
+ table[i16 + j] = alphabet[i] + alphabet[j];
2564
+ }
2565
+ }
2566
+ return table
2567
+ })();
2568
+
2569
+ // Return not function with Error if BigInt not supported
2570
+ function defineBigIntMethod (fn) {
2571
+ return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
2572
+ }
2573
+
2574
+ function BufferBigIntNotDefined () {
2575
+ throw new Error('BigInt not supported')
2576
+ }
2577
+ } (buffer));
2578
+ return buffer;
2579
+ }
2580
+
2581
+ var bufferExports = requireBuffer();
2582
+
213
2583
  var safeBuffer = {exports: {}};
214
2584
 
215
2585
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -221,7 +2591,7 @@ function requireSafeBuffer () {
221
2591
  hasRequiredSafeBuffer = 1;
222
2592
  (function (module, exports$1) {
223
2593
  /* eslint-disable node/no-deprecated-api */
224
- var buffer = require$$0;
2594
+ var buffer = requireBuffer();
225
2595
  var Buffer = buffer.Buffer;
226
2596
 
227
2597
  // alternative to using Object.keys for old browsers
@@ -442,8 +2812,8 @@ async function genSolanaMessage(address, nonce) {
442
2812
  var _a, _b;
443
2813
  /* Domain / origin aren't available server-side – fall back to envs
444
2814
  or simple placeholders. */
445
- const domain = (_a = process.env.SESSION_DOMAIN) !== null && _a !== void 0 ? _a : "server";
446
- const origin = (_b = process.env.SESSION_ORIGIN) !== null && _b !== void 0 ? _b : "server";
2815
+ const domain = (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.SESSION_DOMAIN)) || "server";
2816
+ const origin = (typeof process !== 'undefined' && ((_b = process.env) === null || _b === void 0 ? void 0 : _b.SESSION_ORIGIN)) || "server";
447
2817
  const statement = "Sign this message to authenticate with our application.";
448
2818
  const currentDate = new Date();
449
2819
  const issuedAt = currentDate.toISOString();
@@ -635,7 +3005,7 @@ async function createSession() {
635
3005
  const message = await genSolanaMessage(address);
636
3006
  /* sign the message */
637
3007
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
638
- const signature = Buffer.from(sigBytes).toString("base64");
3008
+ const signature = bufferExports.Buffer.from(sigBytes).toString("base64");
639
3009
  /* call auth API */
640
3010
  const { accessToken, idToken, refreshToken, } = await createSessionWithSignature(address, message, signature);
641
3011
  return { address, accessToken, idToken, refreshToken };
@@ -1079,7 +3449,7 @@ async function setMany(many, options) {
1079
3449
  var _a;
1080
3450
  return ({
1081
3451
  pluginFunctionKey: txData.pluginFunctionKey,
1082
- txData: Buffer.from(txData.txData),
3452
+ txData: bufferExports.Buffer.from(txData.txData),
1083
3453
  raIndices: (_a = txData.raIndices) === null || _a === void 0 ? void 0 : _a.map((raIndex) => {
1084
3454
  if (isHexString(raIndex)) {
1085
3455
  return new BN(raIndex, "hex");
@@ -1106,7 +3476,7 @@ async function setMany(many, options) {
1106
3476
  const programId = ix.programId === web3_js.SystemProgram.programId.toBase58()
1107
3477
  ? web3_js.SystemProgram.programId // prettier to use the constant
1108
3478
  : new web3_js.PublicKey(ix.programId);
1109
- const data = Buffer.from(ix.data);
3479
+ const data = bufferExports.Buffer.from(ix.data);
1110
3480
  return new web3_js.TransactionInstruction({
1111
3481
  keys,
1112
3482
  programId,
@@ -1241,6 +3611,7 @@ const WS_CONFIG = {
1241
3611
  reconnectionDelayGrowFactor: 1.3,
1242
3612
  };
1243
3613
  async function subscribe(path, subscriptionOptions) {
3614
+ var _a;
1244
3615
  const config = await getConfig();
1245
3616
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
1246
3617
  // Create unique connection key that includes prompt to support multiple subscriptions with different prompts
@@ -1284,7 +3655,7 @@ async function subscribe(path, subscriptionOptions) {
1284
3655
  return wsUrl.toString();
1285
3656
  };
1286
3657
  // Create a new WebSocket connection with urlProvider for token refresh on reconnect
1287
- const ws = new ReconnectingWebSocket(urlProvider, [], Object.assign(Object.assign({}, WS_CONFIG), { connectionTimeout: 4000, debug: process.env.NODE_ENV === 'development' }));
3658
+ const ws = new ReconnectingWebSocket(urlProvider, [], Object.assign(Object.assign({}, WS_CONFIG), { connectionTimeout: 4000, debug: typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === 'development' }));
1288
3659
  // Create connection object with connecting flag
1289
3660
  activeConnections[connectionKey] = {
1290
3661
  ws,