@pooflabs/core 0.0.8 → 0.0.10

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