@pooflabs/web 0.0.80 → 0.0.81-rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/auth/providers/phantom-wallet-provider.d.ts +20 -0
  2. package/dist/index-Bdcc5821.js +2375 -0
  3. package/dist/index-Bdcc5821.js.map +1 -0
  4. package/dist/{index-BhfNMrC0.js → index-BjlCinic.js} +25 -883
  5. package/dist/index-BjlCinic.js.map +1 -0
  6. package/dist/{index-Db0NqU8R.esm.js → index-Bx_lLXRT.esm.js} +342 -277
  7. package/dist/index-Bx_lLXRT.esm.js.map +1 -0
  8. package/dist/{index-COIUWugk.esm.js → index-CHqM9n4K.esm.js} +24 -881
  9. package/dist/index-CHqM9n4K.esm.js.map +1 -0
  10. package/dist/{index-BVi7fTm2.js → index-CL4JIAAR.js} +24 -882
  11. package/dist/index-CL4JIAAR.js.map +1 -0
  12. package/dist/index-CrOVJFX9.esm.js +2373 -0
  13. package/dist/index-CrOVJFX9.esm.js.map +1 -0
  14. package/dist/{index-BbtYb8sE.esm.js → index-DCo85UGg.esm.js} +23 -882
  15. package/dist/index-DCo85UGg.esm.js.map +1 -0
  16. package/dist/{index-BNyxZ82q.js → index-DHm4usay.js} +342 -276
  17. package/dist/index-DHm4usay.js.map +1 -0
  18. package/dist/{index.browser-BuHl80dp.esm.js → index.browser-7dDfRU5G.esm.js} +1367 -1697
  19. package/dist/index.browser-7dDfRU5G.esm.js.map +1 -0
  20. package/dist/index.browser-Bg_-PAgT.esm.js +1250 -0
  21. package/dist/index.browser-Bg_-PAgT.esm.js.map +1 -0
  22. package/dist/index.browser-C-_FEr5M.esm.js +1134 -0
  23. package/dist/index.browser-C-_FEr5M.esm.js.map +1 -0
  24. package/dist/{index.browser-8hyi2LOX.js → index.browser-CmlqbyPr.js} +1367 -1697
  25. package/dist/index.browser-CmlqbyPr.js.map +1 -0
  26. package/dist/index.browser-CxXQ2RhF.js +122 -0
  27. package/dist/index.browser-CxXQ2RhF.js.map +1 -0
  28. package/dist/index.browser-DjEZSiqI.js +1137 -0
  29. package/dist/index.browser-DjEZSiqI.js.map +1 -0
  30. package/dist/index.browser-DuVkpEzB.js +1253 -0
  31. package/dist/index.browser-DuVkpEzB.js.map +1 -0
  32. package/dist/index.browser-xJkO73vw.esm.js +119 -0
  33. package/dist/index.browser-xJkO73vw.esm.js.map +1 -0
  34. package/dist/index.esm.js +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/{index.native-DUnE51Mx.js → index.native-DJA9_K3i.js} +186 -2669
  37. package/dist/index.native-DJA9_K3i.js.map +1 -0
  38. package/dist/{index.native-DuKhZcus.esm.js → index.native-TLhfXfe6.esm.js} +187 -2669
  39. package/dist/index.native-TLhfXfe6.esm.js.map +1 -0
  40. package/dist/index.native.esm.js +1 -1
  41. package/dist/index.native.js +1 -1
  42. package/dist/{phantom-wallet-provider-Cg-srwP4.js → phantom-wallet-provider-BegJFoWW.js} +141 -12
  43. package/dist/{phantom-wallet-provider-Cg-srwP4.js.map → phantom-wallet-provider-BegJFoWW.js.map} +1 -1
  44. package/dist/{phantom-wallet-provider--BJjVUA1.esm.js → phantom-wallet-provider-DzUAMhbm.esm.js} +141 -12
  45. package/dist/{phantom-wallet-provider--BJjVUA1.esm.js.map → phantom-wallet-provider-DzUAMhbm.esm.js.map} +1 -1
  46. package/dist/{privy-wallet-provider-BLcur3Ue.esm.js → privy-wallet-provider-BspbiyOr.esm.js} +3 -3
  47. package/dist/privy-wallet-provider-BspbiyOr.esm.js.map +1 -0
  48. package/dist/{privy-wallet-provider-DpNVyaXa.js → privy-wallet-provider-Du-QHaaG.js} +3 -3
  49. package/dist/privy-wallet-provider-Du-QHaaG.js.map +1 -0
  50. package/dist/{solana-mobile-wallet-provider-CFaubssb.esm.js → solana-mobile-wallet-provider-Bh7SBFpQ.esm.js} +53 -4
  51. package/dist/{solana-mobile-wallet-provider-CFaubssb.esm.js.map → solana-mobile-wallet-provider-Bh7SBFpQ.esm.js.map} +1 -1
  52. package/dist/{solana-mobile-wallet-provider-zXAk2tfS.js → solana-mobile-wallet-provider-DPp4SYem.js} +53 -4
  53. package/dist/{solana-mobile-wallet-provider-zXAk2tfS.js.map → solana-mobile-wallet-provider-DPp4SYem.js.map} +1 -1
  54. package/package.json +1 -1
  55. package/dist/index-BNyxZ82q.js.map +0 -1
  56. package/dist/index-BVi7fTm2.js.map +0 -1
  57. package/dist/index-BbtYb8sE.esm.js.map +0 -1
  58. package/dist/index-BhfNMrC0.js.map +0 -1
  59. package/dist/index-CKIoDkjJ.esm.js +0 -6
  60. package/dist/index-CKIoDkjJ.esm.js.map +0 -1
  61. package/dist/index-COIUWugk.esm.js.map +0 -1
  62. package/dist/index-CSraUgD6.js +0 -8
  63. package/dist/index-CSraUgD6.js.map +0 -1
  64. package/dist/index-Db0NqU8R.esm.js.map +0 -1
  65. package/dist/index.browser-8hyi2LOX.js.map +0 -1
  66. package/dist/index.browser-B4zXnffD.esm.js +0 -225
  67. package/dist/index.browser-B4zXnffD.esm.js.map +0 -1
  68. package/dist/index.browser-BJ_TdUVA.js +0 -228
  69. package/dist/index.browser-BJ_TdUVA.js.map +0 -1
  70. package/dist/index.browser-BkNaRRVe.js +0 -1222
  71. package/dist/index.browser-BkNaRRVe.js.map +0 -1
  72. package/dist/index.browser-BuHl80dp.esm.js.map +0 -1
  73. package/dist/index.browser-CnbxBj3-.esm.js +0 -1219
  74. package/dist/index.browser-CnbxBj3-.esm.js.map +0 -1
  75. package/dist/index.browser-OvGNsMPu.esm.js +0 -1002
  76. package/dist/index.browser-OvGNsMPu.esm.js.map +0 -1
  77. package/dist/index.browser-vuTr40so.js +0 -1008
  78. package/dist/index.browser-vuTr40so.js.map +0 -1
  79. package/dist/index.native-DUnE51Mx.js.map +0 -1
  80. package/dist/index.native-DuKhZcus.esm.js.map +0 -1
  81. package/dist/privy-wallet-provider-BLcur3Ue.esm.js.map +0 -1
  82. package/dist/privy-wallet-provider-DpNVyaXa.js.map +0 -1
@@ -4,21 +4,6 @@ import * as anchor from '@coral-xyz/anchor';
4
4
  import { Program } from '@coral-xyz/anchor';
5
5
  import * as React from 'react';
6
6
 
7
- function _mergeNamespaces(n, m) {
8
- m.forEach(function (e) {
9
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
10
- if (k !== 'default' && !(k in n)) {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- });
19
- return Object.freeze(n);
20
- }
21
-
22
7
  function getDefaultExportFromCjs$1 (x) {
23
8
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
24
9
  }
@@ -6881,19 +6866,19 @@ var webSessionManager = /*#__PURE__*/Object.freeze({
6881
6866
  WebSessionManager: WebSessionManager
6882
6867
  });
6883
6868
 
6884
- var buffer$1 = {};
6869
+ var buffer = {};
6885
6870
 
6886
- var base64Js$1 = {};
6871
+ var base64Js = {};
6887
6872
 
6888
- var hasRequiredBase64Js$1;
6873
+ var hasRequiredBase64Js;
6889
6874
 
6890
- function requireBase64Js$1 () {
6891
- if (hasRequiredBase64Js$1) return base64Js$1;
6892
- hasRequiredBase64Js$1 = 1;
6875
+ function requireBase64Js () {
6876
+ if (hasRequiredBase64Js) return base64Js;
6877
+ hasRequiredBase64Js = 1;
6893
6878
 
6894
- base64Js$1.byteLength = byteLength;
6895
- base64Js$1.toByteArray = toByteArray;
6896
- base64Js$1.fromByteArray = fromByteArray;
6879
+ base64Js.byteLength = byteLength;
6880
+ base64Js.toByteArray = toByteArray;
6881
+ base64Js.fromByteArray = fromByteArray;
6897
6882
 
6898
6883
  var lookup = [];
6899
6884
  var revLookup = [];
@@ -7039,19 +7024,19 @@ function requireBase64Js$1 () {
7039
7024
 
7040
7025
  return parts.join('')
7041
7026
  }
7042
- return base64Js$1;
7027
+ return base64Js;
7043
7028
  }
7044
7029
 
7045
- var ieee754$1 = {};
7030
+ var ieee754 = {};
7046
7031
 
7047
7032
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
7048
7033
 
7049
- var hasRequiredIeee754$1;
7034
+ var hasRequiredIeee754;
7050
7035
 
7051
- function requireIeee754$1 () {
7052
- if (hasRequiredIeee754$1) return ieee754$1;
7053
- hasRequiredIeee754$1 = 1;
7054
- ieee754$1.read = function (buffer, offset, isLE, mLen, nBytes) {
7036
+ function requireIeee754 () {
7037
+ if (hasRequiredIeee754) return ieee754;
7038
+ hasRequiredIeee754 = 1;
7039
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
7055
7040
  var e, m;
7056
7041
  var eLen = (nBytes * 8) - mLen - 1;
7057
7042
  var eMax = (1 << eLen) - 1;
@@ -7084,7 +7069,7 @@ function requireIeee754$1 () {
7084
7069
  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
7085
7070
  };
7086
7071
 
7087
- ieee754$1.write = function (buffer, value, offset, isLE, mLen, nBytes) {
7072
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
7088
7073
  var e, m, c;
7089
7074
  var eLen = (nBytes * 8) - mLen - 1;
7090
7075
  var eMax = (1 << eLen) - 1;
@@ -7135,7 +7120,7 @@ function requireIeee754$1 () {
7135
7120
 
7136
7121
  buffer[offset + i - d] |= s * 128;
7137
7122
  };
7138
- return ieee754$1;
7123
+ return ieee754;
7139
7124
  }
7140
7125
 
7141
7126
  /*!
@@ -7145,15 +7130,15 @@ function requireIeee754$1 () {
7145
7130
  * @license MIT
7146
7131
  */
7147
7132
 
7148
- var hasRequiredBuffer$1;
7133
+ var hasRequiredBuffer;
7149
7134
 
7150
- function requireBuffer$1 () {
7151
- if (hasRequiredBuffer$1) return buffer$1;
7152
- hasRequiredBuffer$1 = 1;
7135
+ function requireBuffer () {
7136
+ if (hasRequiredBuffer) return buffer;
7137
+ hasRequiredBuffer = 1;
7153
7138
  (function (exports$1) {
7154
7139
 
7155
- const base64 = requireBase64Js$1();
7156
- const ieee754 = requireIeee754$1();
7140
+ const base64 = requireBase64Js();
7141
+ const ieee754 = requireIeee754();
7157
7142
  const customInspectSymbol =
7158
7143
  (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
7159
7144
  ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
@@ -9246,24 +9231,24 @@ function requireBuffer$1 () {
9246
9231
  function BufferBigIntNotDefined () {
9247
9232
  throw new Error('BigInt not supported')
9248
9233
  }
9249
- } (buffer$1));
9250
- return buffer$1;
9234
+ } (buffer));
9235
+ return buffer;
9251
9236
  }
9252
9237
 
9253
- var bufferExports = requireBuffer$1();
9238
+ var bufferExports = requireBuffer();
9254
9239
 
9255
- var safeBuffer$1 = {exports: {}};
9240
+ var safeBuffer = {exports: {}};
9256
9241
 
9257
9242
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
9258
9243
 
9259
- var hasRequiredSafeBuffer$1;
9244
+ var hasRequiredSafeBuffer;
9260
9245
 
9261
- function requireSafeBuffer$1 () {
9262
- if (hasRequiredSafeBuffer$1) return safeBuffer$1.exports;
9263
- hasRequiredSafeBuffer$1 = 1;
9246
+ function requireSafeBuffer () {
9247
+ if (hasRequiredSafeBuffer) return safeBuffer.exports;
9248
+ hasRequiredSafeBuffer = 1;
9264
9249
  (function (module, exports$1) {
9265
9250
  /* eslint-disable node/no-deprecated-api */
9266
- var buffer = requireBuffer$1();
9251
+ var buffer = requireBuffer();
9267
9252
  var Buffer = buffer.Buffer;
9268
9253
 
9269
9254
  // alternative to using Object.keys for old browsers
@@ -9326,23 +9311,23 @@ function requireSafeBuffer$1 () {
9326
9311
  }
9327
9312
  return buffer.SlowBuffer(size)
9328
9313
  };
9329
- } (safeBuffer$1, safeBuffer$1.exports));
9330
- return safeBuffer$1.exports;
9314
+ } (safeBuffer, safeBuffer.exports));
9315
+ return safeBuffer.exports;
9331
9316
  }
9332
9317
 
9333
- var src$1;
9334
- var hasRequiredSrc$1;
9318
+ var src;
9319
+ var hasRequiredSrc;
9335
9320
 
9336
- function requireSrc$1 () {
9337
- if (hasRequiredSrc$1) return src$1;
9338
- hasRequiredSrc$1 = 1;
9321
+ function requireSrc () {
9322
+ if (hasRequiredSrc) return src;
9323
+ hasRequiredSrc = 1;
9339
9324
  // base-x encoding / decoding
9340
9325
  // Copyright (c) 2018 base-x contributors
9341
9326
  // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
9342
9327
  // Distributed under the MIT software license, see the accompanying
9343
9328
  // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
9344
9329
  // @ts-ignore
9345
- var _Buffer = requireSafeBuffer$1().Buffer;
9330
+ var _Buffer = requireSafeBuffer().Buffer;
9346
9331
  function base (ALPHABET) {
9347
9332
  if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
9348
9333
  var BASE_MAP = new Uint8Array(256);
@@ -9457,25 +9442,25 @@ function requireSrc$1 () {
9457
9442
  decode: decode
9458
9443
  }
9459
9444
  }
9460
- src$1 = base;
9461
- return src$1;
9445
+ src = base;
9446
+ return src;
9462
9447
  }
9463
9448
 
9464
- var bs58$1$1;
9465
- var hasRequiredBs58$1;
9449
+ var bs58$1;
9450
+ var hasRequiredBs58;
9466
9451
 
9467
- function requireBs58$1 () {
9468
- if (hasRequiredBs58$1) return bs58$1$1;
9469
- hasRequiredBs58$1 = 1;
9470
- var basex = requireSrc$1();
9452
+ function requireBs58 () {
9453
+ if (hasRequiredBs58) return bs58$1;
9454
+ hasRequiredBs58 = 1;
9455
+ var basex = requireSrc();
9471
9456
  var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
9472
9457
 
9473
- bs58$1$1 = basex(ALPHABET);
9474
- return bs58$1$1;
9458
+ bs58$1 = basex(ALPHABET);
9459
+ return bs58$1;
9475
9460
  }
9476
9461
 
9477
- var bs58Exports$1 = requireBs58$1();
9478
- var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports$1);
9462
+ var bs58Exports = requireBs58();
9463
+ var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
9479
9464
 
9480
9465
  // ─────────────────────────────────────────────────────────────
9481
9466
  // Local implementation of getSimulationComputeUnits
@@ -12827,15 +12812,15 @@ function clearIncompatibleSession() {
12827
12812
  // Lazy loaders for web-only providers.
12828
12813
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
12829
12814
  async function loadPrivyWalletProvider() {
12830
- const mod = await import('./privy-wallet-provider-BLcur3Ue.esm.js');
12815
+ const mod = await import('./privy-wallet-provider-BspbiyOr.esm.js');
12831
12816
  return mod.PrivyWalletProvider;
12832
12817
  }
12833
12818
  async function loadPhantomWalletProvider() {
12834
- const mod = await import('./phantom-wallet-provider--BJjVUA1.esm.js');
12819
+ const mod = await import('./phantom-wallet-provider-DzUAMhbm.esm.js');
12835
12820
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
12836
12821
  }
12837
12822
  async function loadSolanaMobileWalletProvider() {
12838
- const mod = await import('./solana-mobile-wallet-provider-CFaubssb.esm.js');
12823
+ const mod = await import('./solana-mobile-wallet-provider-Bh7SBFpQ.esm.js');
12839
12824
  return mod.SolanaMobileWalletProvider;
12840
12825
  }
12841
12826
  async function hotSwapToPrivyProvider(config) {
@@ -13245,2604 +13230,137 @@ async function confirmAndCheckTransaction(connection, signature) {
13245
13230
  throw new Error('Transaction confirmation timeout');
13246
13231
  }
13247
13232
 
13248
- var safeBuffer = {exports: {}};
13249
-
13250
- var buffer = {};
13251
-
13252
- var base64Js = {};
13253
-
13254
- var hasRequiredBase64Js;
13255
-
13256
- function requireBase64Js () {
13257
- if (hasRequiredBase64Js) return base64Js;
13258
- hasRequiredBase64Js = 1;
13259
-
13260
- base64Js.byteLength = byteLength;
13261
- base64Js.toByteArray = toByteArray;
13262
- base64Js.fromByteArray = fromByteArray;
13263
-
13264
- var lookup = [];
13265
- var revLookup = [];
13266
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
13267
-
13268
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
13269
- for (var i = 0, len = code.length; i < len; ++i) {
13270
- lookup[i] = code[i];
13271
- revLookup[code.charCodeAt(i)] = i;
13272
- }
13273
-
13274
- // Support decoding URL-safe base64 strings, as Node.js does.
13275
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
13276
- revLookup['-'.charCodeAt(0)] = 62;
13277
- revLookup['_'.charCodeAt(0)] = 63;
13278
-
13279
- function getLens (b64) {
13280
- var len = b64.length;
13281
-
13282
- if (len % 4 > 0) {
13283
- throw new Error('Invalid string. Length must be a multiple of 4')
13284
- }
13285
-
13286
- // Trim off extra bytes after placeholder bytes are found
13287
- // See: https://github.com/beatgammit/base64-js/issues/42
13288
- var validLen = b64.indexOf('=');
13289
- if (validLen === -1) validLen = len;
13290
-
13291
- var placeHoldersLen = validLen === len
13292
- ? 0
13293
- : 4 - (validLen % 4);
13294
-
13295
- return [validLen, placeHoldersLen]
13296
- }
13297
-
13298
- // base64 is 4/3 + up to two characters of the original data
13299
- function byteLength (b64) {
13300
- var lens = getLens(b64);
13301
- var validLen = lens[0];
13302
- var placeHoldersLen = lens[1];
13303
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
13304
- }
13305
-
13306
- function _byteLength (b64, validLen, placeHoldersLen) {
13307
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
13308
- }
13309
-
13310
- function toByteArray (b64) {
13311
- var tmp;
13312
- var lens = getLens(b64);
13313
- var validLen = lens[0];
13314
- var placeHoldersLen = lens[1];
13315
-
13316
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
13317
-
13318
- var curByte = 0;
13319
-
13320
- // if there are placeholders, only get up to the last complete 4 chars
13321
- var len = placeHoldersLen > 0
13322
- ? validLen - 4
13323
- : validLen;
13324
-
13325
- var i;
13326
- for (i = 0; i < len; i += 4) {
13327
- tmp =
13328
- (revLookup[b64.charCodeAt(i)] << 18) |
13329
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
13330
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
13331
- revLookup[b64.charCodeAt(i + 3)];
13332
- arr[curByte++] = (tmp >> 16) & 0xFF;
13333
- arr[curByte++] = (tmp >> 8) & 0xFF;
13334
- arr[curByte++] = tmp & 0xFF;
13335
- }
13336
-
13337
- if (placeHoldersLen === 2) {
13338
- tmp =
13339
- (revLookup[b64.charCodeAt(i)] << 2) |
13340
- (revLookup[b64.charCodeAt(i + 1)] >> 4);
13341
- arr[curByte++] = tmp & 0xFF;
13342
- }
13343
-
13344
- if (placeHoldersLen === 1) {
13345
- tmp =
13346
- (revLookup[b64.charCodeAt(i)] << 10) |
13347
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
13348
- (revLookup[b64.charCodeAt(i + 2)] >> 2);
13349
- arr[curByte++] = (tmp >> 8) & 0xFF;
13350
- arr[curByte++] = tmp & 0xFF;
13351
- }
13352
-
13353
- return arr
13354
- }
13355
-
13356
- function tripletToBase64 (num) {
13357
- return lookup[num >> 18 & 0x3F] +
13358
- lookup[num >> 12 & 0x3F] +
13359
- lookup[num >> 6 & 0x3F] +
13360
- lookup[num & 0x3F]
13361
- }
13362
-
13363
- function encodeChunk (uint8, start, end) {
13364
- var tmp;
13365
- var output = [];
13366
- for (var i = start; i < end; i += 3) {
13367
- tmp =
13368
- ((uint8[i] << 16) & 0xFF0000) +
13369
- ((uint8[i + 1] << 8) & 0xFF00) +
13370
- (uint8[i + 2] & 0xFF);
13371
- output.push(tripletToBase64(tmp));
13372
- }
13373
- return output.join('')
13374
- }
13375
-
13376
- function fromByteArray (uint8) {
13377
- var tmp;
13378
- var len = uint8.length;
13379
- var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
13380
- var parts = [];
13381
- var maxChunkLength = 16383; // must be multiple of 3
13382
-
13383
- // go through the array every three bytes, we'll deal with trailing stuff later
13384
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
13385
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
13386
- }
13387
-
13388
- // pad the end with zeros, but make sure to not forget the extra bytes
13389
- if (extraBytes === 1) {
13390
- tmp = uint8[len - 1];
13391
- parts.push(
13392
- lookup[tmp >> 2] +
13393
- lookup[(tmp << 4) & 0x3F] +
13394
- '=='
13395
- );
13396
- } else if (extraBytes === 2) {
13397
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
13398
- parts.push(
13399
- lookup[tmp >> 10] +
13400
- lookup[(tmp >> 4) & 0x3F] +
13401
- lookup[(tmp << 2) & 0x3F] +
13402
- '='
13403
- );
13404
- }
13405
-
13406
- return parts.join('')
13407
- }
13408
- return base64Js;
13409
- }
13410
-
13411
- var ieee754 = {};
13412
-
13413
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
13414
-
13415
- var hasRequiredIeee754;
13416
-
13417
- function requireIeee754 () {
13418
- if (hasRequiredIeee754) return ieee754;
13419
- hasRequiredIeee754 = 1;
13420
- ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
13421
- var e, m;
13422
- var eLen = (nBytes * 8) - mLen - 1;
13423
- var eMax = (1 << eLen) - 1;
13424
- var eBias = eMax >> 1;
13425
- var nBits = -7;
13426
- var i = isLE ? (nBytes - 1) : 0;
13427
- var d = isLE ? -1 : 1;
13428
- var s = buffer[offset + i];
13429
-
13430
- i += d;
13431
-
13432
- e = s & ((1 << (-nBits)) - 1);
13433
- s >>= (-nBits);
13434
- nBits += eLen;
13435
- for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13436
-
13437
- m = e & ((1 << (-nBits)) - 1);
13438
- e >>= (-nBits);
13439
- nBits += mLen;
13440
- for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13441
-
13442
- if (e === 0) {
13443
- e = 1 - eBias;
13444
- } else if (e === eMax) {
13445
- return m ? NaN : ((s ? -1 : 1) * Infinity)
13446
- } else {
13447
- m = m + Math.pow(2, mLen);
13448
- e = e - eBias;
13449
- }
13450
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13451
- };
13452
-
13453
- ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13454
- var e, m, c;
13455
- var eLen = (nBytes * 8) - mLen - 1;
13456
- var eMax = (1 << eLen) - 1;
13457
- var eBias = eMax >> 1;
13458
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
13459
- var i = isLE ? 0 : (nBytes - 1);
13460
- var d = isLE ? 1 : -1;
13461
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
13462
-
13463
- value = Math.abs(value);
13464
-
13465
- if (isNaN(value) || value === Infinity) {
13466
- m = isNaN(value) ? 1 : 0;
13467
- e = eMax;
13468
- } else {
13469
- e = Math.floor(Math.log(value) / Math.LN2);
13470
- if (value * (c = Math.pow(2, -e)) < 1) {
13471
- e--;
13472
- c *= 2;
13473
- }
13474
- if (e + eBias >= 1) {
13475
- value += rt / c;
13476
- } else {
13477
- value += rt * Math.pow(2, 1 - eBias);
13478
- }
13479
- if (value * c >= 2) {
13480
- e++;
13481
- c /= 2;
13482
- }
13483
-
13484
- if (e + eBias >= eMax) {
13485
- m = 0;
13486
- e = eMax;
13487
- } else if (e + eBias >= 1) {
13488
- m = ((value * c) - 1) * Math.pow(2, mLen);
13489
- e = e + eBias;
13490
- } else {
13491
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
13492
- e = 0;
13493
- }
13494
- }
13495
-
13496
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13497
-
13498
- e = (e << mLen) | m;
13499
- eLen += mLen;
13500
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13501
-
13502
- buffer[offset + i - d] |= s * 128;
13503
- };
13504
- return ieee754;
13505
- }
13506
-
13507
- /*!
13508
- * The buffer module from node.js, for the browser.
13509
- *
13510
- * @author Feross Aboukhadijeh <https://feross.org>
13511
- * @license MIT
13512
- */
13513
-
13514
- var hasRequiredBuffer;
13515
-
13516
- function requireBuffer () {
13517
- if (hasRequiredBuffer) return buffer;
13518
- hasRequiredBuffer = 1;
13519
- (function (exports$1) {
13520
-
13521
- const base64 = requireBase64Js();
13522
- const ieee754 = requireIeee754();
13523
- const customInspectSymbol =
13524
- (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
13525
- ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
13526
- : null;
13527
-
13528
- exports$1.Buffer = Buffer;
13529
- exports$1.SlowBuffer = SlowBuffer;
13530
- exports$1.INSPECT_MAX_BYTES = 50;
13531
-
13532
- const K_MAX_LENGTH = 0x7fffffff;
13533
- exports$1.kMaxLength = K_MAX_LENGTH;
13534
-
13535
- /**
13536
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
13537
- * === true Use Uint8Array implementation (fastest)
13538
- * === false Print warning and recommend using `buffer` v4.x which has an Object
13539
- * implementation (most compatible, even IE6)
13540
- *
13541
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
13542
- * Opera 11.6+, iOS 4.2+.
13543
- *
13544
- * We report that the browser does not support typed arrays if the are not subclassable
13545
- * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
13546
- * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
13547
- * for __proto__ and has a buggy typed array implementation.
13548
- */
13549
- Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
13550
-
13551
- if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
13552
- typeof console.error === 'function') {
13553
- console.error(
13554
- 'This browser lacks typed array (Uint8Array) support which is required by ' +
13555
- '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
13556
- );
13557
- }
13558
-
13559
- function typedArraySupport () {
13560
- // Can typed array instances can be augmented?
13561
- try {
13562
- const arr = new Uint8Array(1);
13563
- const proto = { foo: function () { return 42 } };
13564
- Object.setPrototypeOf(proto, Uint8Array.prototype);
13565
- Object.setPrototypeOf(arr, proto);
13566
- return arr.foo() === 42
13567
- } catch (e) {
13568
- return false
13569
- }
13570
- }
13571
-
13572
- Object.defineProperty(Buffer.prototype, 'parent', {
13573
- enumerable: true,
13574
- get: function () {
13575
- if (!Buffer.isBuffer(this)) return undefined
13576
- return this.buffer
13577
- }
13578
- });
13579
-
13580
- Object.defineProperty(Buffer.prototype, 'offset', {
13581
- enumerable: true,
13582
- get: function () {
13583
- if (!Buffer.isBuffer(this)) return undefined
13584
- return this.byteOffset
13585
- }
13586
- });
13587
-
13588
- function createBuffer (length) {
13589
- if (length > K_MAX_LENGTH) {
13590
- throw new RangeError('The value "' + length + '" is invalid for option "size"')
13591
- }
13592
- // Return an augmented `Uint8Array` instance
13593
- const buf = new Uint8Array(length);
13594
- Object.setPrototypeOf(buf, Buffer.prototype);
13595
- return buf
13596
- }
13597
-
13598
- /**
13599
- * The Buffer constructor returns instances of `Uint8Array` that have their
13600
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
13601
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
13602
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
13603
- * returns a single octet.
13604
- *
13605
- * The `Uint8Array` prototype remains unmodified.
13606
- */
13607
-
13608
- function Buffer (arg, encodingOrOffset, length) {
13609
- // Common case.
13610
- if (typeof arg === 'number') {
13611
- if (typeof encodingOrOffset === 'string') {
13612
- throw new TypeError(
13613
- 'The "string" argument must be of type string. Received type number'
13614
- )
13615
- }
13616
- return allocUnsafe(arg)
13617
- }
13618
- return from(arg, encodingOrOffset, length)
13619
- }
13620
-
13621
- Buffer.poolSize = 8192; // not used by this implementation
13622
-
13623
- function from (value, encodingOrOffset, length) {
13624
- if (typeof value === 'string') {
13625
- return fromString(value, encodingOrOffset)
13626
- }
13627
-
13628
- if (ArrayBuffer.isView(value)) {
13629
- return fromArrayView(value)
13630
- }
13631
-
13632
- if (value == null) {
13633
- throw new TypeError(
13634
- 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
13635
- 'or Array-like Object. Received type ' + (typeof value)
13636
- )
13637
- }
13638
-
13639
- if (isInstance(value, ArrayBuffer) ||
13640
- (value && isInstance(value.buffer, ArrayBuffer))) {
13641
- return fromArrayBuffer(value, encodingOrOffset, length)
13642
- }
13643
-
13644
- if (typeof SharedArrayBuffer !== 'undefined' &&
13645
- (isInstance(value, SharedArrayBuffer) ||
13646
- (value && isInstance(value.buffer, SharedArrayBuffer)))) {
13647
- return fromArrayBuffer(value, encodingOrOffset, length)
13648
- }
13649
-
13650
- if (typeof value === 'number') {
13651
- throw new TypeError(
13652
- 'The "value" argument must not be of type number. Received type number'
13653
- )
13654
- }
13655
-
13656
- const valueOf = value.valueOf && value.valueOf();
13657
- if (valueOf != null && valueOf !== value) {
13658
- return Buffer.from(valueOf, encodingOrOffset, length)
13659
- }
13660
-
13661
- const b = fromObject(value);
13662
- if (b) return b
13663
-
13664
- if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
13665
- typeof value[Symbol.toPrimitive] === 'function') {
13666
- return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
13667
- }
13668
-
13669
- throw new TypeError(
13670
- 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
13671
- 'or Array-like Object. Received type ' + (typeof value)
13672
- )
13673
- }
13674
-
13675
- /**
13676
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
13677
- * if value is a number.
13678
- * Buffer.from(str[, encoding])
13679
- * Buffer.from(array)
13680
- * Buffer.from(buffer)
13681
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
13682
- **/
13683
- Buffer.from = function (value, encodingOrOffset, length) {
13684
- return from(value, encodingOrOffset, length)
13685
- };
13686
-
13687
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
13688
- // https://github.com/feross/buffer/pull/148
13689
- Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
13690
- Object.setPrototypeOf(Buffer, Uint8Array);
13691
-
13692
- function assertSize (size) {
13693
- if (typeof size !== 'number') {
13694
- throw new TypeError('"size" argument must be of type number')
13695
- } else if (size < 0) {
13696
- throw new RangeError('The value "' + size + '" is invalid for option "size"')
13697
- }
13698
- }
13699
-
13700
- function alloc (size, fill, encoding) {
13701
- assertSize(size);
13702
- if (size <= 0) {
13703
- return createBuffer(size)
13704
- }
13705
- if (fill !== undefined) {
13706
- // Only pay attention to encoding if it's a string. This
13707
- // prevents accidentally sending in a number that would
13708
- // be interpreted as a start offset.
13709
- return typeof encoding === 'string'
13710
- ? createBuffer(size).fill(fill, encoding)
13711
- : createBuffer(size).fill(fill)
13712
- }
13713
- return createBuffer(size)
13714
- }
13715
-
13716
- /**
13717
- * Creates a new filled Buffer instance.
13718
- * alloc(size[, fill[, encoding]])
13719
- **/
13720
- Buffer.alloc = function (size, fill, encoding) {
13721
- return alloc(size, fill, encoding)
13722
- };
13723
-
13724
- function allocUnsafe (size) {
13725
- assertSize(size);
13726
- return createBuffer(size < 0 ? 0 : checked(size) | 0)
13727
- }
13728
-
13729
- /**
13730
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
13731
- * */
13732
- Buffer.allocUnsafe = function (size) {
13733
- return allocUnsafe(size)
13734
- };
13735
- /**
13736
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
13737
- */
13738
- Buffer.allocUnsafeSlow = function (size) {
13739
- return allocUnsafe(size)
13740
- };
13741
-
13742
- function fromString (string, encoding) {
13743
- if (typeof encoding !== 'string' || encoding === '') {
13744
- encoding = 'utf8';
13745
- }
13746
-
13747
- if (!Buffer.isEncoding(encoding)) {
13748
- throw new TypeError('Unknown encoding: ' + encoding)
13749
- }
13750
-
13751
- const length = byteLength(string, encoding) | 0;
13752
- let buf = createBuffer(length);
13753
-
13754
- const actual = buf.write(string, encoding);
13755
-
13756
- if (actual !== length) {
13757
- // Writing a hex string, for example, that contains invalid characters will
13758
- // cause everything after the first invalid character to be ignored. (e.g.
13759
- // 'abxxcd' will be treated as 'ab')
13760
- buf = buf.slice(0, actual);
13761
- }
13762
-
13763
- return buf
13764
- }
13765
-
13766
- function fromArrayLike (array) {
13767
- const length = array.length < 0 ? 0 : checked(array.length) | 0;
13768
- const buf = createBuffer(length);
13769
- for (let i = 0; i < length; i += 1) {
13770
- buf[i] = array[i] & 255;
13771
- }
13772
- return buf
13773
- }
13774
-
13775
- function fromArrayView (arrayView) {
13776
- if (isInstance(arrayView, Uint8Array)) {
13777
- const copy = new Uint8Array(arrayView);
13778
- return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
13779
- }
13780
- return fromArrayLike(arrayView)
13781
- }
13782
-
13783
- function fromArrayBuffer (array, byteOffset, length) {
13784
- if (byteOffset < 0 || array.byteLength < byteOffset) {
13785
- throw new RangeError('"offset" is outside of buffer bounds')
13786
- }
13787
-
13788
- if (array.byteLength < byteOffset + (length || 0)) {
13789
- throw new RangeError('"length" is outside of buffer bounds')
13790
- }
13791
-
13792
- let buf;
13793
- if (byteOffset === undefined && length === undefined) {
13794
- buf = new Uint8Array(array);
13795
- } else if (length === undefined) {
13796
- buf = new Uint8Array(array, byteOffset);
13797
- } else {
13798
- buf = new Uint8Array(array, byteOffset, length);
13799
- }
13800
-
13801
- // Return an augmented `Uint8Array` instance
13802
- Object.setPrototypeOf(buf, Buffer.prototype);
13803
-
13804
- return buf
13805
- }
13806
-
13807
- function fromObject (obj) {
13808
- if (Buffer.isBuffer(obj)) {
13809
- const len = checked(obj.length) | 0;
13810
- const buf = createBuffer(len);
13811
-
13812
- if (buf.length === 0) {
13813
- return buf
13814
- }
13815
-
13816
- obj.copy(buf, 0, 0, len);
13817
- return buf
13818
- }
13819
-
13820
- if (obj.length !== undefined) {
13821
- if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
13822
- return createBuffer(0)
13823
- }
13824
- return fromArrayLike(obj)
13825
- }
13826
-
13827
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
13828
- return fromArrayLike(obj.data)
13829
- }
13830
- }
13831
-
13832
- function checked (length) {
13833
- // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
13834
- // length is NaN (which is otherwise coerced to zero.)
13835
- if (length >= K_MAX_LENGTH) {
13836
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
13837
- 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
13838
- }
13839
- return length | 0
13840
- }
13841
-
13842
- function SlowBuffer (length) {
13843
- if (+length != length) { // eslint-disable-line eqeqeq
13844
- length = 0;
13845
- }
13846
- return Buffer.alloc(+length)
13847
- }
13848
-
13849
- Buffer.isBuffer = function isBuffer (b) {
13850
- return b != null && b._isBuffer === true &&
13851
- b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
13852
- };
13853
-
13854
- Buffer.compare = function compare (a, b) {
13855
- if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
13856
- if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
13857
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
13858
- throw new TypeError(
13859
- 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
13860
- )
13861
- }
13862
-
13863
- if (a === b) return 0
13864
-
13865
- let x = a.length;
13866
- let y = b.length;
13867
-
13868
- for (let i = 0, len = Math.min(x, y); i < len; ++i) {
13869
- if (a[i] !== b[i]) {
13870
- x = a[i];
13871
- y = b[i];
13872
- break
13873
- }
13874
- }
13875
-
13876
- if (x < y) return -1
13877
- if (y < x) return 1
13878
- return 0
13879
- };
13880
-
13881
- Buffer.isEncoding = function isEncoding (encoding) {
13882
- switch (String(encoding).toLowerCase()) {
13883
- case 'hex':
13884
- case 'utf8':
13885
- case 'utf-8':
13886
- case 'ascii':
13887
- case 'latin1':
13888
- case 'binary':
13889
- case 'base64':
13890
- case 'ucs2':
13891
- case 'ucs-2':
13892
- case 'utf16le':
13893
- case 'utf-16le':
13894
- return true
13895
- default:
13896
- return false
13897
- }
13898
- };
13899
-
13900
- Buffer.concat = function concat (list, length) {
13901
- if (!Array.isArray(list)) {
13902
- throw new TypeError('"list" argument must be an Array of Buffers')
13903
- }
13904
-
13905
- if (list.length === 0) {
13906
- return Buffer.alloc(0)
13907
- }
13908
-
13909
- let i;
13910
- if (length === undefined) {
13911
- length = 0;
13912
- for (i = 0; i < list.length; ++i) {
13913
- length += list[i].length;
13914
- }
13915
- }
13916
-
13917
- const buffer = Buffer.allocUnsafe(length);
13918
- let pos = 0;
13919
- for (i = 0; i < list.length; ++i) {
13920
- let buf = list[i];
13921
- if (isInstance(buf, Uint8Array)) {
13922
- if (pos + buf.length > buffer.length) {
13923
- if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
13924
- buf.copy(buffer, pos);
13925
- } else {
13926
- Uint8Array.prototype.set.call(
13927
- buffer,
13928
- buf,
13929
- pos
13930
- );
13931
- }
13932
- } else if (!Buffer.isBuffer(buf)) {
13933
- throw new TypeError('"list" argument must be an Array of Buffers')
13934
- } else {
13935
- buf.copy(buffer, pos);
13936
- }
13937
- pos += buf.length;
13938
- }
13939
- return buffer
13940
- };
13941
-
13942
- function byteLength (string, encoding) {
13943
- if (Buffer.isBuffer(string)) {
13944
- return string.length
13945
- }
13946
- if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
13947
- return string.byteLength
13948
- }
13949
- if (typeof string !== 'string') {
13950
- throw new TypeError(
13951
- 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
13952
- 'Received type ' + typeof string
13953
- )
13954
- }
13955
-
13956
- const len = string.length;
13957
- const mustMatch = (arguments.length > 2 && arguments[2] === true);
13958
- if (!mustMatch && len === 0) return 0
13959
-
13960
- // Use a for loop to avoid recursion
13961
- let loweredCase = false;
13962
- for (;;) {
13963
- switch (encoding) {
13964
- case 'ascii':
13965
- case 'latin1':
13966
- case 'binary':
13967
- return len
13968
- case 'utf8':
13969
- case 'utf-8':
13970
- return utf8ToBytes(string).length
13971
- case 'ucs2':
13972
- case 'ucs-2':
13973
- case 'utf16le':
13974
- case 'utf-16le':
13975
- return len * 2
13976
- case 'hex':
13977
- return len >>> 1
13978
- case 'base64':
13979
- return base64ToBytes(string).length
13980
- default:
13981
- if (loweredCase) {
13982
- return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
13983
- }
13984
- encoding = ('' + encoding).toLowerCase();
13985
- loweredCase = true;
13986
- }
13987
- }
13988
- }
13989
- Buffer.byteLength = byteLength;
13990
-
13991
- function slowToString (encoding, start, end) {
13992
- let loweredCase = false;
13993
-
13994
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
13995
- // property of a typed array.
13996
-
13997
- // This behaves neither like String nor Uint8Array in that we set start/end
13998
- // to their upper/lower bounds if the value passed is out of range.
13999
- // undefined is handled specially as per ECMA-262 6th Edition,
14000
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
14001
- if (start === undefined || start < 0) {
14002
- start = 0;
14003
- }
14004
- // Return early if start > this.length. Done here to prevent potential uint32
14005
- // coercion fail below.
14006
- if (start > this.length) {
14007
- return ''
14008
- }
14009
-
14010
- if (end === undefined || end > this.length) {
14011
- end = this.length;
14012
- }
14013
-
14014
- if (end <= 0) {
14015
- return ''
14016
- }
14017
-
14018
- // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
14019
- end >>>= 0;
14020
- start >>>= 0;
14021
-
14022
- if (end <= start) {
14023
- return ''
14024
- }
14025
-
14026
- if (!encoding) encoding = 'utf8';
14027
-
14028
- while (true) {
14029
- switch (encoding) {
14030
- case 'hex':
14031
- return hexSlice(this, start, end)
14032
-
14033
- case 'utf8':
14034
- case 'utf-8':
14035
- return utf8Slice(this, start, end)
14036
-
14037
- case 'ascii':
14038
- return asciiSlice(this, start, end)
14039
-
14040
- case 'latin1':
14041
- case 'binary':
14042
- return latin1Slice(this, start, end)
14043
-
14044
- case 'base64':
14045
- return base64Slice(this, start, end)
14046
-
14047
- case 'ucs2':
14048
- case 'ucs-2':
14049
- case 'utf16le':
14050
- case 'utf-16le':
14051
- return utf16leSlice(this, start, end)
14052
-
14053
- default:
14054
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
14055
- encoding = (encoding + '').toLowerCase();
14056
- loweredCase = true;
14057
- }
14058
- }
14059
- }
14060
-
14061
- // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
14062
- // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
14063
- // reliably in a browserify context because there could be multiple different
14064
- // copies of the 'buffer' package in use. This method works even for Buffer
14065
- // instances that were created from another copy of the `buffer` package.
14066
- // See: https://github.com/feross/buffer/issues/154
14067
- Buffer.prototype._isBuffer = true;
14068
-
14069
- function swap (b, n, m) {
14070
- const i = b[n];
14071
- b[n] = b[m];
14072
- b[m] = i;
14073
- }
14074
-
14075
- Buffer.prototype.swap16 = function swap16 () {
14076
- const len = this.length;
14077
- if (len % 2 !== 0) {
14078
- throw new RangeError('Buffer size must be a multiple of 16-bits')
14079
- }
14080
- for (let i = 0; i < len; i += 2) {
14081
- swap(this, i, i + 1);
14082
- }
14083
- return this
14084
- };
14085
-
14086
- Buffer.prototype.swap32 = function swap32 () {
14087
- const len = this.length;
14088
- if (len % 4 !== 0) {
14089
- throw new RangeError('Buffer size must be a multiple of 32-bits')
14090
- }
14091
- for (let i = 0; i < len; i += 4) {
14092
- swap(this, i, i + 3);
14093
- swap(this, i + 1, i + 2);
14094
- }
14095
- return this
14096
- };
14097
-
14098
- Buffer.prototype.swap64 = function swap64 () {
14099
- const len = this.length;
14100
- if (len % 8 !== 0) {
14101
- throw new RangeError('Buffer size must be a multiple of 64-bits')
14102
- }
14103
- for (let i = 0; i < len; i += 8) {
14104
- swap(this, i, i + 7);
14105
- swap(this, i + 1, i + 6);
14106
- swap(this, i + 2, i + 5);
14107
- swap(this, i + 3, i + 4);
14108
- }
14109
- return this
14110
- };
14111
-
14112
- Buffer.prototype.toString = function toString () {
14113
- const length = this.length;
14114
- if (length === 0) return ''
14115
- if (arguments.length === 0) return utf8Slice(this, 0, length)
14116
- return slowToString.apply(this, arguments)
14117
- };
14118
-
14119
- Buffer.prototype.toLocaleString = Buffer.prototype.toString;
14120
-
14121
- Buffer.prototype.equals = function equals (b) {
14122
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
14123
- if (this === b) return true
14124
- return Buffer.compare(this, b) === 0
14125
- };
14126
-
14127
- Buffer.prototype.inspect = function inspect () {
14128
- let str = '';
14129
- const max = exports$1.INSPECT_MAX_BYTES;
14130
- str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
14131
- if (this.length > max) str += ' ... ';
14132
- return '<Buffer ' + str + '>'
14133
- };
14134
- if (customInspectSymbol) {
14135
- Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
14136
- }
14137
-
14138
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
14139
- if (isInstance(target, Uint8Array)) {
14140
- target = Buffer.from(target, target.offset, target.byteLength);
14141
- }
14142
- if (!Buffer.isBuffer(target)) {
14143
- throw new TypeError(
14144
- 'The "target" argument must be one of type Buffer or Uint8Array. ' +
14145
- 'Received type ' + (typeof target)
14146
- )
14147
- }
14148
-
14149
- if (start === undefined) {
14150
- start = 0;
14151
- }
14152
- if (end === undefined) {
14153
- end = target ? target.length : 0;
14154
- }
14155
- if (thisStart === undefined) {
14156
- thisStart = 0;
14157
- }
14158
- if (thisEnd === undefined) {
14159
- thisEnd = this.length;
14160
- }
14161
-
14162
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
14163
- throw new RangeError('out of range index')
14164
- }
14165
-
14166
- if (thisStart >= thisEnd && start >= end) {
14167
- return 0
14168
- }
14169
- if (thisStart >= thisEnd) {
14170
- return -1
14171
- }
14172
- if (start >= end) {
14173
- return 1
14174
- }
14175
-
14176
- start >>>= 0;
14177
- end >>>= 0;
14178
- thisStart >>>= 0;
14179
- thisEnd >>>= 0;
14180
-
14181
- if (this === target) return 0
14182
-
14183
- let x = thisEnd - thisStart;
14184
- let y = end - start;
14185
- const len = Math.min(x, y);
14186
-
14187
- const thisCopy = this.slice(thisStart, thisEnd);
14188
- const targetCopy = target.slice(start, end);
14189
-
14190
- for (let i = 0; i < len; ++i) {
14191
- if (thisCopy[i] !== targetCopy[i]) {
14192
- x = thisCopy[i];
14193
- y = targetCopy[i];
14194
- break
14195
- }
14196
- }
14197
-
14198
- if (x < y) return -1
14199
- if (y < x) return 1
14200
- return 0
14201
- };
14202
-
14203
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
14204
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
14205
- //
14206
- // Arguments:
14207
- // - buffer - a Buffer to search
14208
- // - val - a string, Buffer, or number
14209
- // - byteOffset - an index into `buffer`; will be clamped to an int32
14210
- // - encoding - an optional encoding, relevant is val is a string
14211
- // - dir - true for indexOf, false for lastIndexOf
14212
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
14213
- // Empty buffer means no match
14214
- if (buffer.length === 0) return -1
14215
-
14216
- // Normalize byteOffset
14217
- if (typeof byteOffset === 'string') {
14218
- encoding = byteOffset;
14219
- byteOffset = 0;
14220
- } else if (byteOffset > 0x7fffffff) {
14221
- byteOffset = 0x7fffffff;
14222
- } else if (byteOffset < -2147483648) {
14223
- byteOffset = -2147483648;
14224
- }
14225
- byteOffset = +byteOffset; // Coerce to Number.
14226
- if (numberIsNaN(byteOffset)) {
14227
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
14228
- byteOffset = dir ? 0 : (buffer.length - 1);
14229
- }
14230
-
14231
- // Normalize byteOffset: negative offsets start from the end of the buffer
14232
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
14233
- if (byteOffset >= buffer.length) {
14234
- if (dir) return -1
14235
- else byteOffset = buffer.length - 1;
14236
- } else if (byteOffset < 0) {
14237
- if (dir) byteOffset = 0;
14238
- else return -1
14239
- }
14240
-
14241
- // Normalize val
14242
- if (typeof val === 'string') {
14243
- val = Buffer.from(val, encoding);
14244
- }
14245
-
14246
- // Finally, search either indexOf (if dir is true) or lastIndexOf
14247
- if (Buffer.isBuffer(val)) {
14248
- // Special case: looking for empty string/buffer always fails
14249
- if (val.length === 0) {
14250
- return -1
14251
- }
14252
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
14253
- } else if (typeof val === 'number') {
14254
- val = val & 0xFF; // Search for a byte value [0-255]
14255
- if (typeof Uint8Array.prototype.indexOf === 'function') {
14256
- if (dir) {
14257
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
14258
- } else {
14259
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
14260
- }
14261
- }
14262
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
14263
- }
14264
-
14265
- throw new TypeError('val must be string, number or Buffer')
14266
- }
14267
-
14268
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
14269
- let indexSize = 1;
14270
- let arrLength = arr.length;
14271
- let valLength = val.length;
14272
-
14273
- if (encoding !== undefined) {
14274
- encoding = String(encoding).toLowerCase();
14275
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
14276
- encoding === 'utf16le' || encoding === 'utf-16le') {
14277
- if (arr.length < 2 || val.length < 2) {
14278
- return -1
14279
- }
14280
- indexSize = 2;
14281
- arrLength /= 2;
14282
- valLength /= 2;
14283
- byteOffset /= 2;
14284
- }
14285
- }
14286
-
14287
- function read (buf, i) {
14288
- if (indexSize === 1) {
14289
- return buf[i]
14290
- } else {
14291
- return buf.readUInt16BE(i * indexSize)
14292
- }
14293
- }
14294
-
14295
- let i;
14296
- if (dir) {
14297
- let foundIndex = -1;
14298
- for (i = byteOffset; i < arrLength; i++) {
14299
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
14300
- if (foundIndex === -1) foundIndex = i;
14301
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
14302
- } else {
14303
- if (foundIndex !== -1) i -= i - foundIndex;
14304
- foundIndex = -1;
14305
- }
14306
- }
14307
- } else {
14308
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
14309
- for (i = byteOffset; i >= 0; i--) {
14310
- let found = true;
14311
- for (let j = 0; j < valLength; j++) {
14312
- if (read(arr, i + j) !== read(val, j)) {
14313
- found = false;
14314
- break
14315
- }
14316
- }
14317
- if (found) return i
14318
- }
14319
- }
14320
-
14321
- return -1
14322
- }
14323
-
14324
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
14325
- return this.indexOf(val, byteOffset, encoding) !== -1
14326
- };
14327
-
14328
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
14329
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
14330
- };
14331
-
14332
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
14333
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
14334
- };
14335
-
14336
- function hexWrite (buf, string, offset, length) {
14337
- offset = Number(offset) || 0;
14338
- const remaining = buf.length - offset;
14339
- if (!length) {
14340
- length = remaining;
14341
- } else {
14342
- length = Number(length);
14343
- if (length > remaining) {
14344
- length = remaining;
14345
- }
14346
- }
14347
-
14348
- const strLen = string.length;
14349
-
14350
- if (length > strLen / 2) {
14351
- length = strLen / 2;
14352
- }
14353
- let i;
14354
- for (i = 0; i < length; ++i) {
14355
- const parsed = parseInt(string.substr(i * 2, 2), 16);
14356
- if (numberIsNaN(parsed)) return i
14357
- buf[offset + i] = parsed;
14358
- }
14359
- return i
14360
- }
14361
-
14362
- function utf8Write (buf, string, offset, length) {
14363
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
14364
- }
14365
-
14366
- function asciiWrite (buf, string, offset, length) {
14367
- return blitBuffer(asciiToBytes(string), buf, offset, length)
14368
- }
14369
-
14370
- function base64Write (buf, string, offset, length) {
14371
- return blitBuffer(base64ToBytes(string), buf, offset, length)
14372
- }
14373
-
14374
- function ucs2Write (buf, string, offset, length) {
14375
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
14376
- }
14377
-
14378
- Buffer.prototype.write = function write (string, offset, length, encoding) {
14379
- // Buffer#write(string)
14380
- if (offset === undefined) {
14381
- encoding = 'utf8';
14382
- length = this.length;
14383
- offset = 0;
14384
- // Buffer#write(string, encoding)
14385
- } else if (length === undefined && typeof offset === 'string') {
14386
- encoding = offset;
14387
- length = this.length;
14388
- offset = 0;
14389
- // Buffer#write(string, offset[, length][, encoding])
14390
- } else if (isFinite(offset)) {
14391
- offset = offset >>> 0;
14392
- if (isFinite(length)) {
14393
- length = length >>> 0;
14394
- if (encoding === undefined) encoding = 'utf8';
14395
- } else {
14396
- encoding = length;
14397
- length = undefined;
14398
- }
14399
- } else {
14400
- throw new Error(
14401
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
14402
- )
14403
- }
14404
-
14405
- const remaining = this.length - offset;
14406
- if (length === undefined || length > remaining) length = remaining;
14407
-
14408
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
14409
- throw new RangeError('Attempt to write outside buffer bounds')
14410
- }
14411
-
14412
- if (!encoding) encoding = 'utf8';
14413
-
14414
- let loweredCase = false;
14415
- for (;;) {
14416
- switch (encoding) {
14417
- case 'hex':
14418
- return hexWrite(this, string, offset, length)
14419
-
14420
- case 'utf8':
14421
- case 'utf-8':
14422
- return utf8Write(this, string, offset, length)
14423
-
14424
- case 'ascii':
14425
- case 'latin1':
14426
- case 'binary':
14427
- return asciiWrite(this, string, offset, length)
14428
-
14429
- case 'base64':
14430
- // Warning: maxLength not taken into account in base64Write
14431
- return base64Write(this, string, offset, length)
14432
-
14433
- case 'ucs2':
14434
- case 'ucs-2':
14435
- case 'utf16le':
14436
- case 'utf-16le':
14437
- return ucs2Write(this, string, offset, length)
14438
-
14439
- default:
14440
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
14441
- encoding = ('' + encoding).toLowerCase();
14442
- loweredCase = true;
14443
- }
14444
- }
14445
- };
14446
-
14447
- Buffer.prototype.toJSON = function toJSON () {
14448
- return {
14449
- type: 'Buffer',
14450
- data: Array.prototype.slice.call(this._arr || this, 0)
14451
- }
14452
- };
14453
-
14454
- function base64Slice (buf, start, end) {
14455
- if (start === 0 && end === buf.length) {
14456
- return base64.fromByteArray(buf)
14457
- } else {
14458
- return base64.fromByteArray(buf.slice(start, end))
14459
- }
14460
- }
14461
-
14462
- function utf8Slice (buf, start, end) {
14463
- end = Math.min(buf.length, end);
14464
- const res = [];
14465
-
14466
- let i = start;
14467
- while (i < end) {
14468
- const firstByte = buf[i];
14469
- let codePoint = null;
14470
- let bytesPerSequence = (firstByte > 0xEF)
14471
- ? 4
14472
- : (firstByte > 0xDF)
14473
- ? 3
14474
- : (firstByte > 0xBF)
14475
- ? 2
14476
- : 1;
14477
-
14478
- if (i + bytesPerSequence <= end) {
14479
- let secondByte, thirdByte, fourthByte, tempCodePoint;
14480
-
14481
- switch (bytesPerSequence) {
14482
- case 1:
14483
- if (firstByte < 0x80) {
14484
- codePoint = firstByte;
14485
- }
14486
- break
14487
- case 2:
14488
- secondByte = buf[i + 1];
14489
- if ((secondByte & 0xC0) === 0x80) {
14490
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
14491
- if (tempCodePoint > 0x7F) {
14492
- codePoint = tempCodePoint;
14493
- }
14494
- }
14495
- break
14496
- case 3:
14497
- secondByte = buf[i + 1];
14498
- thirdByte = buf[i + 2];
14499
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
14500
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
14501
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
14502
- codePoint = tempCodePoint;
14503
- }
14504
- }
14505
- break
14506
- case 4:
14507
- secondByte = buf[i + 1];
14508
- thirdByte = buf[i + 2];
14509
- fourthByte = buf[i + 3];
14510
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
14511
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
14512
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
14513
- codePoint = tempCodePoint;
14514
- }
14515
- }
14516
- }
14517
- }
14518
-
14519
- if (codePoint === null) {
14520
- // we did not generate a valid codePoint so insert a
14521
- // replacement char (U+FFFD) and advance only 1 byte
14522
- codePoint = 0xFFFD;
14523
- bytesPerSequence = 1;
14524
- } else if (codePoint > 0xFFFF) {
14525
- // encode to utf16 (surrogate pair dance)
14526
- codePoint -= 0x10000;
14527
- res.push(codePoint >>> 10 & 0x3FF | 0xD800);
14528
- codePoint = 0xDC00 | codePoint & 0x3FF;
14529
- }
14530
-
14531
- res.push(codePoint);
14532
- i += bytesPerSequence;
14533
- }
14534
-
14535
- return decodeCodePointsArray(res)
14536
- }
14537
-
14538
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
14539
- // the lowest limit is Chrome, with 0x10000 args.
14540
- // We go 1 magnitude less, for safety
14541
- const MAX_ARGUMENTS_LENGTH = 0x1000;
14542
-
14543
- function decodeCodePointsArray (codePoints) {
14544
- const len = codePoints.length;
14545
- if (len <= MAX_ARGUMENTS_LENGTH) {
14546
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
14547
- }
14548
-
14549
- // Decode in chunks to avoid "call stack size exceeded".
14550
- let res = '';
14551
- let i = 0;
14552
- while (i < len) {
14553
- res += String.fromCharCode.apply(
14554
- String,
14555
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
14556
- );
14557
- }
14558
- return res
14559
- }
14560
-
14561
- function asciiSlice (buf, start, end) {
14562
- let ret = '';
14563
- end = Math.min(buf.length, end);
14564
-
14565
- for (let i = start; i < end; ++i) {
14566
- ret += String.fromCharCode(buf[i] & 0x7F);
14567
- }
14568
- return ret
14569
- }
14570
-
14571
- function latin1Slice (buf, start, end) {
14572
- let ret = '';
14573
- end = Math.min(buf.length, end);
14574
-
14575
- for (let i = start; i < end; ++i) {
14576
- ret += String.fromCharCode(buf[i]);
14577
- }
14578
- return ret
14579
- }
14580
-
14581
- function hexSlice (buf, start, end) {
14582
- const len = buf.length;
14583
-
14584
- if (!start || start < 0) start = 0;
14585
- if (!end || end < 0 || end > len) end = len;
14586
-
14587
- let out = '';
14588
- for (let i = start; i < end; ++i) {
14589
- out += hexSliceLookupTable[buf[i]];
14590
- }
14591
- return out
14592
- }
14593
-
14594
- function utf16leSlice (buf, start, end) {
14595
- const bytes = buf.slice(start, end);
14596
- let res = '';
14597
- // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
14598
- for (let i = 0; i < bytes.length - 1; i += 2) {
14599
- res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
14600
- }
14601
- return res
14602
- }
14603
-
14604
- Buffer.prototype.slice = function slice (start, end) {
14605
- const len = this.length;
14606
- start = ~~start;
14607
- end = end === undefined ? len : ~~end;
14608
-
14609
- if (start < 0) {
14610
- start += len;
14611
- if (start < 0) start = 0;
14612
- } else if (start > len) {
14613
- start = len;
14614
- }
14615
-
14616
- if (end < 0) {
14617
- end += len;
14618
- if (end < 0) end = 0;
14619
- } else if (end > len) {
14620
- end = len;
14621
- }
14622
-
14623
- if (end < start) end = start;
14624
-
14625
- const newBuf = this.subarray(start, end);
14626
- // Return an augmented `Uint8Array` instance
14627
- Object.setPrototypeOf(newBuf, Buffer.prototype);
14628
-
14629
- return newBuf
14630
- };
14631
-
14632
- /*
14633
- * Need to make sure that buffer isn't trying to write out of bounds.
14634
- */
14635
- function checkOffset (offset, ext, length) {
14636
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
14637
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
14638
- }
14639
-
14640
- Buffer.prototype.readUintLE =
14641
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
14642
- offset = offset >>> 0;
14643
- byteLength = byteLength >>> 0;
14644
- if (!noAssert) checkOffset(offset, byteLength, this.length);
14645
-
14646
- let val = this[offset];
14647
- let mul = 1;
14648
- let i = 0;
14649
- while (++i < byteLength && (mul *= 0x100)) {
14650
- val += this[offset + i] * mul;
14651
- }
14652
-
14653
- return val
14654
- };
14655
-
14656
- Buffer.prototype.readUintBE =
14657
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
14658
- offset = offset >>> 0;
14659
- byteLength = byteLength >>> 0;
14660
- if (!noAssert) {
14661
- checkOffset(offset, byteLength, this.length);
14662
- }
14663
-
14664
- let val = this[offset + --byteLength];
14665
- let mul = 1;
14666
- while (byteLength > 0 && (mul *= 0x100)) {
14667
- val += this[offset + --byteLength] * mul;
14668
- }
14669
-
14670
- return val
14671
- };
14672
-
14673
- Buffer.prototype.readUint8 =
14674
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
14675
- offset = offset >>> 0;
14676
- if (!noAssert) checkOffset(offset, 1, this.length);
14677
- return this[offset]
14678
- };
14679
-
14680
- Buffer.prototype.readUint16LE =
14681
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
14682
- offset = offset >>> 0;
14683
- if (!noAssert) checkOffset(offset, 2, this.length);
14684
- return this[offset] | (this[offset + 1] << 8)
14685
- };
14686
-
14687
- Buffer.prototype.readUint16BE =
14688
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
14689
- offset = offset >>> 0;
14690
- if (!noAssert) checkOffset(offset, 2, this.length);
14691
- return (this[offset] << 8) | this[offset + 1]
14692
- };
14693
-
14694
- Buffer.prototype.readUint32LE =
14695
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
14696
- offset = offset >>> 0;
14697
- if (!noAssert) checkOffset(offset, 4, this.length);
14698
-
14699
- return ((this[offset]) |
14700
- (this[offset + 1] << 8) |
14701
- (this[offset + 2] << 16)) +
14702
- (this[offset + 3] * 0x1000000)
14703
- };
14704
-
14705
- Buffer.prototype.readUint32BE =
14706
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
14707
- offset = offset >>> 0;
14708
- if (!noAssert) checkOffset(offset, 4, this.length);
14709
-
14710
- return (this[offset] * 0x1000000) +
14711
- ((this[offset + 1] << 16) |
14712
- (this[offset + 2] << 8) |
14713
- this[offset + 3])
14714
- };
14715
-
14716
- Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
14717
- offset = offset >>> 0;
14718
- validateNumber(offset, 'offset');
14719
- const first = this[offset];
14720
- const last = this[offset + 7];
14721
- if (first === undefined || last === undefined) {
14722
- boundsError(offset, this.length - 8);
14723
- }
14724
-
14725
- const lo = first +
14726
- this[++offset] * 2 ** 8 +
14727
- this[++offset] * 2 ** 16 +
14728
- this[++offset] * 2 ** 24;
14729
-
14730
- const hi = this[++offset] +
14731
- this[++offset] * 2 ** 8 +
14732
- this[++offset] * 2 ** 16 +
14733
- last * 2 ** 24;
14734
-
14735
- return BigInt(lo) + (BigInt(hi) << BigInt(32))
14736
- });
14737
-
14738
- Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
14739
- offset = offset >>> 0;
14740
- validateNumber(offset, 'offset');
14741
- const first = this[offset];
14742
- const last = this[offset + 7];
14743
- if (first === undefined || last === undefined) {
14744
- boundsError(offset, this.length - 8);
14745
- }
14746
-
14747
- const hi = first * 2 ** 24 +
14748
- this[++offset] * 2 ** 16 +
14749
- this[++offset] * 2 ** 8 +
14750
- this[++offset];
14751
-
14752
- const lo = this[++offset] * 2 ** 24 +
14753
- this[++offset] * 2 ** 16 +
14754
- this[++offset] * 2 ** 8 +
14755
- last;
14756
-
14757
- return (BigInt(hi) << BigInt(32)) + BigInt(lo)
14758
- });
14759
-
14760
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
14761
- offset = offset >>> 0;
14762
- byteLength = byteLength >>> 0;
14763
- if (!noAssert) checkOffset(offset, byteLength, this.length);
14764
-
14765
- let val = this[offset];
14766
- let mul = 1;
14767
- let i = 0;
14768
- while (++i < byteLength && (mul *= 0x100)) {
14769
- val += this[offset + i] * mul;
14770
- }
14771
- mul *= 0x80;
14772
-
14773
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
14774
-
14775
- return val
14776
- };
14777
-
14778
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
14779
- offset = offset >>> 0;
14780
- byteLength = byteLength >>> 0;
14781
- if (!noAssert) checkOffset(offset, byteLength, this.length);
14782
-
14783
- let i = byteLength;
14784
- let mul = 1;
14785
- let val = this[offset + --i];
14786
- while (i > 0 && (mul *= 0x100)) {
14787
- val += this[offset + --i] * mul;
14788
- }
14789
- mul *= 0x80;
14790
-
14791
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
14792
-
14793
- return val
14794
- };
14795
-
14796
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
14797
- offset = offset >>> 0;
14798
- if (!noAssert) checkOffset(offset, 1, this.length);
14799
- if (!(this[offset] & 0x80)) return (this[offset])
14800
- return ((0xff - this[offset] + 1) * -1)
14801
- };
14802
-
14803
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
14804
- offset = offset >>> 0;
14805
- if (!noAssert) checkOffset(offset, 2, this.length);
14806
- const val = this[offset] | (this[offset + 1] << 8);
14807
- return (val & 0x8000) ? val | 0xFFFF0000 : val
14808
- };
14809
-
14810
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
14811
- offset = offset >>> 0;
14812
- if (!noAssert) checkOffset(offset, 2, this.length);
14813
- const val = this[offset + 1] | (this[offset] << 8);
14814
- return (val & 0x8000) ? val | 0xFFFF0000 : val
14815
- };
14816
-
14817
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
14818
- offset = offset >>> 0;
14819
- if (!noAssert) checkOffset(offset, 4, this.length);
14820
-
14821
- return (this[offset]) |
14822
- (this[offset + 1] << 8) |
14823
- (this[offset + 2] << 16) |
14824
- (this[offset + 3] << 24)
14825
- };
14826
-
14827
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
14828
- offset = offset >>> 0;
14829
- if (!noAssert) checkOffset(offset, 4, this.length);
14830
-
14831
- return (this[offset] << 24) |
14832
- (this[offset + 1] << 16) |
14833
- (this[offset + 2] << 8) |
14834
- (this[offset + 3])
14835
- };
14836
-
14837
- Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
14838
- offset = offset >>> 0;
14839
- validateNumber(offset, 'offset');
14840
- const first = this[offset];
14841
- const last = this[offset + 7];
14842
- if (first === undefined || last === undefined) {
14843
- boundsError(offset, this.length - 8);
14844
- }
14845
-
14846
- const val = this[offset + 4] +
14847
- this[offset + 5] * 2 ** 8 +
14848
- this[offset + 6] * 2 ** 16 +
14849
- (last << 24); // Overflow
14850
-
14851
- return (BigInt(val) << BigInt(32)) +
14852
- BigInt(first +
14853
- this[++offset] * 2 ** 8 +
14854
- this[++offset] * 2 ** 16 +
14855
- this[++offset] * 2 ** 24)
14856
- });
14857
-
14858
- Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
14859
- offset = offset >>> 0;
14860
- validateNumber(offset, 'offset');
14861
- const first = this[offset];
14862
- const last = this[offset + 7];
14863
- if (first === undefined || last === undefined) {
14864
- boundsError(offset, this.length - 8);
14865
- }
14866
-
14867
- const val = (first << 24) + // Overflow
14868
- this[++offset] * 2 ** 16 +
14869
- this[++offset] * 2 ** 8 +
14870
- this[++offset];
14871
-
14872
- return (BigInt(val) << BigInt(32)) +
14873
- BigInt(this[++offset] * 2 ** 24 +
14874
- this[++offset] * 2 ** 16 +
14875
- this[++offset] * 2 ** 8 +
14876
- last)
14877
- });
14878
-
14879
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
14880
- offset = offset >>> 0;
14881
- if (!noAssert) checkOffset(offset, 4, this.length);
14882
- return ieee754.read(this, offset, true, 23, 4)
14883
- };
14884
-
14885
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
14886
- offset = offset >>> 0;
14887
- if (!noAssert) checkOffset(offset, 4, this.length);
14888
- return ieee754.read(this, offset, false, 23, 4)
14889
- };
14890
-
14891
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
14892
- offset = offset >>> 0;
14893
- if (!noAssert) checkOffset(offset, 8, this.length);
14894
- return ieee754.read(this, offset, true, 52, 8)
14895
- };
14896
-
14897
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
14898
- offset = offset >>> 0;
14899
- if (!noAssert) checkOffset(offset, 8, this.length);
14900
- return ieee754.read(this, offset, false, 52, 8)
14901
- };
14902
-
14903
- function checkInt (buf, value, offset, ext, max, min) {
14904
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
14905
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
14906
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
14907
- }
14908
-
14909
- Buffer.prototype.writeUintLE =
14910
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
14911
- value = +value;
14912
- offset = offset >>> 0;
14913
- byteLength = byteLength >>> 0;
14914
- if (!noAssert) {
14915
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
14916
- checkInt(this, value, offset, byteLength, maxBytes, 0);
14917
- }
14918
-
14919
- let mul = 1;
14920
- let i = 0;
14921
- this[offset] = value & 0xFF;
14922
- while (++i < byteLength && (mul *= 0x100)) {
14923
- this[offset + i] = (value / mul) & 0xFF;
14924
- }
14925
-
14926
- return offset + byteLength
14927
- };
14928
-
14929
- Buffer.prototype.writeUintBE =
14930
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
14931
- value = +value;
14932
- offset = offset >>> 0;
14933
- byteLength = byteLength >>> 0;
14934
- if (!noAssert) {
14935
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
14936
- checkInt(this, value, offset, byteLength, maxBytes, 0);
14937
- }
14938
-
14939
- let i = byteLength - 1;
14940
- let mul = 1;
14941
- this[offset + i] = value & 0xFF;
14942
- while (--i >= 0 && (mul *= 0x100)) {
14943
- this[offset + i] = (value / mul) & 0xFF;
14944
- }
14945
-
14946
- return offset + byteLength
14947
- };
14948
-
14949
- Buffer.prototype.writeUint8 =
14950
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
14951
- value = +value;
14952
- offset = offset >>> 0;
14953
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
14954
- this[offset] = (value & 0xff);
14955
- return offset + 1
14956
- };
14957
-
14958
- Buffer.prototype.writeUint16LE =
14959
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
14960
- value = +value;
14961
- offset = offset >>> 0;
14962
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
14963
- this[offset] = (value & 0xff);
14964
- this[offset + 1] = (value >>> 8);
14965
- return offset + 2
14966
- };
14967
-
14968
- Buffer.prototype.writeUint16BE =
14969
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
14970
- value = +value;
14971
- offset = offset >>> 0;
14972
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
14973
- this[offset] = (value >>> 8);
14974
- this[offset + 1] = (value & 0xff);
14975
- return offset + 2
14976
- };
14977
-
14978
- Buffer.prototype.writeUint32LE =
14979
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
14980
- value = +value;
14981
- offset = offset >>> 0;
14982
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
14983
- this[offset + 3] = (value >>> 24);
14984
- this[offset + 2] = (value >>> 16);
14985
- this[offset + 1] = (value >>> 8);
14986
- this[offset] = (value & 0xff);
14987
- return offset + 4
14988
- };
14989
-
14990
- Buffer.prototype.writeUint32BE =
14991
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
14992
- value = +value;
14993
- offset = offset >>> 0;
14994
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
14995
- this[offset] = (value >>> 24);
14996
- this[offset + 1] = (value >>> 16);
14997
- this[offset + 2] = (value >>> 8);
14998
- this[offset + 3] = (value & 0xff);
14999
- return offset + 4
15000
- };
15001
-
15002
- function wrtBigUInt64LE (buf, value, offset, min, max) {
15003
- checkIntBI(value, min, max, buf, offset, 7);
15004
-
15005
- let lo = Number(value & BigInt(0xffffffff));
15006
- buf[offset++] = lo;
15007
- lo = lo >> 8;
15008
- buf[offset++] = lo;
15009
- lo = lo >> 8;
15010
- buf[offset++] = lo;
15011
- lo = lo >> 8;
15012
- buf[offset++] = lo;
15013
- let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
15014
- buf[offset++] = hi;
15015
- hi = hi >> 8;
15016
- buf[offset++] = hi;
15017
- hi = hi >> 8;
15018
- buf[offset++] = hi;
15019
- hi = hi >> 8;
15020
- buf[offset++] = hi;
15021
- return offset
15022
- }
15023
-
15024
- function wrtBigUInt64BE (buf, value, offset, min, max) {
15025
- checkIntBI(value, min, max, buf, offset, 7);
15026
-
15027
- let lo = Number(value & BigInt(0xffffffff));
15028
- buf[offset + 7] = lo;
15029
- lo = lo >> 8;
15030
- buf[offset + 6] = lo;
15031
- lo = lo >> 8;
15032
- buf[offset + 5] = lo;
15033
- lo = lo >> 8;
15034
- buf[offset + 4] = lo;
15035
- let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
15036
- buf[offset + 3] = hi;
15037
- hi = hi >> 8;
15038
- buf[offset + 2] = hi;
15039
- hi = hi >> 8;
15040
- buf[offset + 1] = hi;
15041
- hi = hi >> 8;
15042
- buf[offset] = hi;
15043
- return offset + 8
15044
- }
15045
-
15046
- Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
15047
- return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
15048
- });
15049
-
15050
- Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
15051
- return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
15052
- });
15053
-
15054
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
15055
- value = +value;
15056
- offset = offset >>> 0;
15057
- if (!noAssert) {
15058
- const limit = Math.pow(2, (8 * byteLength) - 1);
15059
-
15060
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
15061
- }
15062
-
15063
- let i = 0;
15064
- let mul = 1;
15065
- let sub = 0;
15066
- this[offset] = value & 0xFF;
15067
- while (++i < byteLength && (mul *= 0x100)) {
15068
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
15069
- sub = 1;
15070
- }
15071
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
15072
- }
15073
-
15074
- return offset + byteLength
15075
- };
15076
-
15077
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
15078
- value = +value;
15079
- offset = offset >>> 0;
15080
- if (!noAssert) {
15081
- const limit = Math.pow(2, (8 * byteLength) - 1);
15082
-
15083
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
15084
- }
15085
-
15086
- let i = byteLength - 1;
15087
- let mul = 1;
15088
- let sub = 0;
15089
- this[offset + i] = value & 0xFF;
15090
- while (--i >= 0 && (mul *= 0x100)) {
15091
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
15092
- sub = 1;
15093
- }
15094
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
15095
- }
15096
-
15097
- return offset + byteLength
15098
- };
15099
-
15100
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
15101
- value = +value;
15102
- offset = offset >>> 0;
15103
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
15104
- if (value < 0) value = 0xff + value + 1;
15105
- this[offset] = (value & 0xff);
15106
- return offset + 1
15107
- };
15108
-
15109
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
15110
- value = +value;
15111
- offset = offset >>> 0;
15112
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
15113
- this[offset] = (value & 0xff);
15114
- this[offset + 1] = (value >>> 8);
15115
- return offset + 2
15116
- };
15117
-
15118
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
15119
- value = +value;
15120
- offset = offset >>> 0;
15121
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
15122
- this[offset] = (value >>> 8);
15123
- this[offset + 1] = (value & 0xff);
15124
- return offset + 2
15125
- };
15126
-
15127
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
15128
- value = +value;
15129
- offset = offset >>> 0;
15130
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
15131
- this[offset] = (value & 0xff);
15132
- this[offset + 1] = (value >>> 8);
15133
- this[offset + 2] = (value >>> 16);
15134
- this[offset + 3] = (value >>> 24);
15135
- return offset + 4
15136
- };
15137
-
15138
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
15139
- value = +value;
15140
- offset = offset >>> 0;
15141
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
15142
- if (value < 0) value = 0xffffffff + value + 1;
15143
- this[offset] = (value >>> 24);
15144
- this[offset + 1] = (value >>> 16);
15145
- this[offset + 2] = (value >>> 8);
15146
- this[offset + 3] = (value & 0xff);
15147
- return offset + 4
15148
- };
15149
-
15150
- Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
15151
- return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
15152
- });
15153
-
15154
- Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
15155
- return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
15156
- });
15157
-
15158
- function checkIEEE754 (buf, value, offset, ext, max, min) {
15159
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
15160
- if (offset < 0) throw new RangeError('Index out of range')
15161
- }
15162
-
15163
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
15164
- value = +value;
15165
- offset = offset >>> 0;
15166
- if (!noAssert) {
15167
- checkIEEE754(buf, value, offset, 4);
15168
- }
15169
- ieee754.write(buf, value, offset, littleEndian, 23, 4);
15170
- return offset + 4
15171
- }
15172
-
15173
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
15174
- return writeFloat(this, value, offset, true, noAssert)
15175
- };
15176
-
15177
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
15178
- return writeFloat(this, value, offset, false, noAssert)
15179
- };
15180
-
15181
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
15182
- value = +value;
15183
- offset = offset >>> 0;
15184
- if (!noAssert) {
15185
- checkIEEE754(buf, value, offset, 8);
15186
- }
15187
- ieee754.write(buf, value, offset, littleEndian, 52, 8);
15188
- return offset + 8
15189
- }
15190
-
15191
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
15192
- return writeDouble(this, value, offset, true, noAssert)
15193
- };
15194
-
15195
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
15196
- return writeDouble(this, value, offset, false, noAssert)
15197
- };
15198
-
15199
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
15200
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
15201
- if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
15202
- if (!start) start = 0;
15203
- if (!end && end !== 0) end = this.length;
15204
- if (targetStart >= target.length) targetStart = target.length;
15205
- if (!targetStart) targetStart = 0;
15206
- if (end > 0 && end < start) end = start;
15207
-
15208
- // Copy 0 bytes; we're done
15209
- if (end === start) return 0
15210
- if (target.length === 0 || this.length === 0) return 0
15211
-
15212
- // Fatal error conditions
15213
- if (targetStart < 0) {
15214
- throw new RangeError('targetStart out of bounds')
15215
- }
15216
- if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
15217
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
15218
-
15219
- // Are we oob?
15220
- if (end > this.length) end = this.length;
15221
- if (target.length - targetStart < end - start) {
15222
- end = target.length - targetStart + start;
15223
- }
15224
-
15225
- const len = end - start;
15226
-
15227
- if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
15228
- // Use built-in when available, missing from IE11
15229
- this.copyWithin(targetStart, start, end);
15230
- } else {
15231
- Uint8Array.prototype.set.call(
15232
- target,
15233
- this.subarray(start, end),
15234
- targetStart
15235
- );
15236
- }
15237
-
15238
- return len
15239
- };
15240
-
15241
- // Usage:
15242
- // buffer.fill(number[, offset[, end]])
15243
- // buffer.fill(buffer[, offset[, end]])
15244
- // buffer.fill(string[, offset[, end]][, encoding])
15245
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
15246
- // Handle string cases:
15247
- if (typeof val === 'string') {
15248
- if (typeof start === 'string') {
15249
- encoding = start;
15250
- start = 0;
15251
- end = this.length;
15252
- } else if (typeof end === 'string') {
15253
- encoding = end;
15254
- end = this.length;
15255
- }
15256
- if (encoding !== undefined && typeof encoding !== 'string') {
15257
- throw new TypeError('encoding must be a string')
15258
- }
15259
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
15260
- throw new TypeError('Unknown encoding: ' + encoding)
15261
- }
15262
- if (val.length === 1) {
15263
- const code = val.charCodeAt(0);
15264
- if ((encoding === 'utf8' && code < 128) ||
15265
- encoding === 'latin1') {
15266
- // Fast path: If `val` fits into a single byte, use that numeric value.
15267
- val = code;
15268
- }
15269
- }
15270
- } else if (typeof val === 'number') {
15271
- val = val & 255;
15272
- } else if (typeof val === 'boolean') {
15273
- val = Number(val);
15274
- }
15275
-
15276
- // Invalid ranges are not set to a default, so can range check early.
15277
- if (start < 0 || this.length < start || this.length < end) {
15278
- throw new RangeError('Out of range index')
15279
- }
15280
-
15281
- if (end <= start) {
15282
- return this
15283
- }
15284
-
15285
- start = start >>> 0;
15286
- end = end === undefined ? this.length : end >>> 0;
15287
-
15288
- if (!val) val = 0;
15289
-
15290
- let i;
15291
- if (typeof val === 'number') {
15292
- for (i = start; i < end; ++i) {
15293
- this[i] = val;
15294
- }
15295
- } else {
15296
- const bytes = Buffer.isBuffer(val)
15297
- ? val
15298
- : Buffer.from(val, encoding);
15299
- const len = bytes.length;
15300
- if (len === 0) {
15301
- throw new TypeError('The value "' + val +
15302
- '" is invalid for argument "value"')
15303
- }
15304
- for (i = 0; i < end - start; ++i) {
15305
- this[i + start] = bytes[i % len];
15306
- }
15307
- }
15308
-
15309
- return this
15310
- };
15311
-
15312
- // CUSTOM ERRORS
15313
- // =============
15314
-
15315
- // Simplified versions from Node, changed for Buffer-only usage
15316
- const errors = {};
15317
- function E (sym, getMessage, Base) {
15318
- errors[sym] = class NodeError extends Base {
15319
- constructor () {
15320
- super();
15321
-
15322
- Object.defineProperty(this, 'message', {
15323
- value: getMessage.apply(this, arguments),
15324
- writable: true,
15325
- configurable: true
15326
- });
15327
-
15328
- // Add the error code to the name to include it in the stack trace.
15329
- this.name = `${this.name} [${sym}]`;
15330
- // Access the stack to generate the error message including the error code
15331
- // from the name.
15332
- this.stack; // eslint-disable-line no-unused-expressions
15333
- // Reset the name to the actual name.
15334
- delete this.name;
15335
- }
15336
-
15337
- get code () {
15338
- return sym
15339
- }
15340
-
15341
- set code (value) {
15342
- Object.defineProperty(this, 'code', {
15343
- configurable: true,
15344
- enumerable: true,
15345
- value,
15346
- writable: true
15347
- });
15348
- }
15349
-
15350
- toString () {
15351
- return `${this.name} [${sym}]: ${this.message}`
15352
- }
15353
- };
15354
- }
15355
-
15356
- E('ERR_BUFFER_OUT_OF_BOUNDS',
15357
- function (name) {
15358
- if (name) {
15359
- return `${name} is outside of buffer bounds`
15360
- }
15361
-
15362
- return 'Attempt to access memory outside buffer bounds'
15363
- }, RangeError);
15364
- E('ERR_INVALID_ARG_TYPE',
15365
- function (name, actual) {
15366
- return `The "${name}" argument must be of type number. Received type ${typeof actual}`
15367
- }, TypeError);
15368
- E('ERR_OUT_OF_RANGE',
15369
- function (str, range, input) {
15370
- let msg = `The value of "${str}" is out of range.`;
15371
- let received = input;
15372
- if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
15373
- received = addNumericalSeparator(String(input));
15374
- } else if (typeof input === 'bigint') {
15375
- received = String(input);
15376
- if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
15377
- received = addNumericalSeparator(received);
15378
- }
15379
- received += 'n';
15380
- }
15381
- msg += ` It must be ${range}. Received ${received}`;
15382
- return msg
15383
- }, RangeError);
15384
-
15385
- function addNumericalSeparator (val) {
15386
- let res = '';
15387
- let i = val.length;
15388
- const start = val[0] === '-' ? 1 : 0;
15389
- for (; i >= start + 4; i -= 3) {
15390
- res = `_${val.slice(i - 3, i)}${res}`;
15391
- }
15392
- return `${val.slice(0, i)}${res}`
15393
- }
15394
-
15395
- // CHECK FUNCTIONS
15396
- // ===============
15397
-
15398
- function checkBounds (buf, offset, byteLength) {
15399
- validateNumber(offset, 'offset');
15400
- if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
15401
- boundsError(offset, buf.length - (byteLength + 1));
15402
- }
15403
- }
15404
-
15405
- function checkIntBI (value, min, max, buf, offset, byteLength) {
15406
- if (value > max || value < min) {
15407
- const n = typeof min === 'bigint' ? 'n' : '';
15408
- let range;
15409
- {
15410
- if (min === 0 || min === BigInt(0)) {
15411
- range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
15412
- } else {
15413
- range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
15414
- `${(byteLength + 1) * 8 - 1}${n}`;
15415
- }
15416
- }
15417
- throw new errors.ERR_OUT_OF_RANGE('value', range, value)
15418
- }
15419
- checkBounds(buf, offset, byteLength);
15420
- }
15421
-
15422
- function validateNumber (value, name) {
15423
- if (typeof value !== 'number') {
15424
- throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
15425
- }
15426
- }
15427
-
15428
- function boundsError (value, length, type) {
15429
- if (Math.floor(value) !== value) {
15430
- validateNumber(value, type);
15431
- throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
15432
- }
15433
-
15434
- if (length < 0) {
15435
- throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
15436
- }
15437
-
15438
- throw new errors.ERR_OUT_OF_RANGE('offset',
15439
- `>= ${0} and <= ${length}`,
15440
- value)
15441
- }
15442
-
15443
- // HELPER FUNCTIONS
15444
- // ================
15445
-
15446
- const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
15447
-
15448
- function base64clean (str) {
15449
- // Node takes equal signs as end of the Base64 encoding
15450
- str = str.split('=')[0];
15451
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
15452
- str = str.trim().replace(INVALID_BASE64_RE, '');
15453
- // Node converts strings with length < 2 to ''
15454
- if (str.length < 2) return ''
15455
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
15456
- while (str.length % 4 !== 0) {
15457
- str = str + '=';
15458
- }
15459
- return str
15460
- }
15461
-
15462
- function utf8ToBytes (string, units) {
15463
- units = units || Infinity;
15464
- let codePoint;
15465
- const length = string.length;
15466
- let leadSurrogate = null;
15467
- const bytes = [];
15468
-
15469
- for (let i = 0; i < length; ++i) {
15470
- codePoint = string.charCodeAt(i);
15471
-
15472
- // is surrogate component
15473
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
15474
- // last char was a lead
15475
- if (!leadSurrogate) {
15476
- // no lead yet
15477
- if (codePoint > 0xDBFF) {
15478
- // unexpected trail
15479
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15480
- continue
15481
- } else if (i + 1 === length) {
15482
- // unpaired lead
15483
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15484
- continue
15485
- }
15486
-
15487
- // valid lead
15488
- leadSurrogate = codePoint;
15489
-
15490
- continue
15491
- }
15492
-
15493
- // 2 leads in a row
15494
- if (codePoint < 0xDC00) {
15495
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15496
- leadSurrogate = codePoint;
15497
- continue
15498
- }
15499
-
15500
- // valid surrogate pair
15501
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
15502
- } else if (leadSurrogate) {
15503
- // valid bmp char, but last char was a lead
15504
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15505
- }
15506
-
15507
- leadSurrogate = null;
15508
-
15509
- // encode utf8
15510
- if (codePoint < 0x80) {
15511
- if ((units -= 1) < 0) break
15512
- bytes.push(codePoint);
15513
- } else if (codePoint < 0x800) {
15514
- if ((units -= 2) < 0) break
15515
- bytes.push(
15516
- codePoint >> 0x6 | 0xC0,
15517
- codePoint & 0x3F | 0x80
15518
- );
15519
- } else if (codePoint < 0x10000) {
15520
- if ((units -= 3) < 0) break
15521
- bytes.push(
15522
- codePoint >> 0xC | 0xE0,
15523
- codePoint >> 0x6 & 0x3F | 0x80,
15524
- codePoint & 0x3F | 0x80
15525
- );
15526
- } else if (codePoint < 0x110000) {
15527
- if ((units -= 4) < 0) break
15528
- bytes.push(
15529
- codePoint >> 0x12 | 0xF0,
15530
- codePoint >> 0xC & 0x3F | 0x80,
15531
- codePoint >> 0x6 & 0x3F | 0x80,
15532
- codePoint & 0x3F | 0x80
15533
- );
15534
- } else {
15535
- throw new Error('Invalid code point')
15536
- }
15537
- }
15538
-
15539
- return bytes
15540
- }
15541
-
15542
- function asciiToBytes (str) {
15543
- const byteArray = [];
15544
- for (let i = 0; i < str.length; ++i) {
15545
- // Node's code seems to be doing this and not & 0x7F..
15546
- byteArray.push(str.charCodeAt(i) & 0xFF);
15547
- }
15548
- return byteArray
15549
- }
15550
-
15551
- function utf16leToBytes (str, units) {
15552
- let c, hi, lo;
15553
- const byteArray = [];
15554
- for (let i = 0; i < str.length; ++i) {
15555
- if ((units -= 2) < 0) break
15556
-
15557
- c = str.charCodeAt(i);
15558
- hi = c >> 8;
15559
- lo = c % 256;
15560
- byteArray.push(lo);
15561
- byteArray.push(hi);
15562
- }
15563
-
15564
- return byteArray
15565
- }
15566
-
15567
- function base64ToBytes (str) {
15568
- return base64.toByteArray(base64clean(str))
15569
- }
15570
-
15571
- function blitBuffer (src, dst, offset, length) {
15572
- let i;
15573
- for (i = 0; i < length; ++i) {
15574
- if ((i + offset >= dst.length) || (i >= src.length)) break
15575
- dst[i + offset] = src[i];
15576
- }
15577
- return i
15578
- }
15579
-
15580
- // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
15581
- // the `instanceof` check but they should be treated as of that type.
15582
- // See: https://github.com/feross/buffer/issues/166
15583
- function isInstance (obj, type) {
15584
- return obj instanceof type ||
15585
- (obj != null && obj.constructor != null && obj.constructor.name != null &&
15586
- obj.constructor.name === type.name)
15587
- }
15588
- function numberIsNaN (obj) {
15589
- // For IE11 support
15590
- return obj !== obj // eslint-disable-line no-self-compare
15591
- }
15592
-
15593
- // Create lookup table for `toString('hex')`
15594
- // See: https://github.com/feross/buffer/issues/219
15595
- const hexSliceLookupTable = (function () {
15596
- const alphabet = '0123456789abcdef';
15597
- const table = new Array(256);
15598
- for (let i = 0; i < 16; ++i) {
15599
- const i16 = i * 16;
15600
- for (let j = 0; j < 16; ++j) {
15601
- table[i16 + j] = alphabet[i] + alphabet[j];
15602
- }
15603
- }
15604
- return table
15605
- })();
15606
-
15607
- // Return not function with Error if BigInt not supported
15608
- function defineBigIntMethod (fn) {
15609
- return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
15610
- }
15611
-
15612
- function BufferBigIntNotDefined () {
15613
- throw new Error('BigInt not supported')
15614
- }
15615
- } (buffer));
15616
- return buffer;
15617
- }
15618
-
15619
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
15620
-
15621
- var hasRequiredSafeBuffer;
15622
-
15623
- function requireSafeBuffer () {
15624
- if (hasRequiredSafeBuffer) return safeBuffer.exports;
15625
- hasRequiredSafeBuffer = 1;
15626
- (function (module, exports$1) {
15627
- /* eslint-disable node/no-deprecated-api */
15628
- var buffer = requireBuffer();
15629
- var Buffer = buffer.Buffer;
15630
-
15631
- // alternative to using Object.keys for old browsers
15632
- function copyProps (src, dst) {
15633
- for (var key in src) {
15634
- dst[key] = src[key];
15635
- }
15636
- }
15637
- if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
15638
- module.exports = buffer;
15639
- } else {
15640
- // Copy properties from require('buffer')
15641
- copyProps(buffer, exports$1);
15642
- exports$1.Buffer = SafeBuffer;
15643
- }
15644
-
15645
- function SafeBuffer (arg, encodingOrOffset, length) {
15646
- return Buffer(arg, encodingOrOffset, length)
15647
- }
15648
-
15649
- SafeBuffer.prototype = Object.create(Buffer.prototype);
15650
-
15651
- // Copy static methods from Buffer
15652
- copyProps(Buffer, SafeBuffer);
15653
-
15654
- SafeBuffer.from = function (arg, encodingOrOffset, length) {
15655
- if (typeof arg === 'number') {
15656
- throw new TypeError('Argument must not be a number')
15657
- }
15658
- return Buffer(arg, encodingOrOffset, length)
15659
- };
15660
-
15661
- SafeBuffer.alloc = function (size, fill, encoding) {
15662
- if (typeof size !== 'number') {
15663
- throw new TypeError('Argument must be a number')
15664
- }
15665
- var buf = Buffer(size);
15666
- if (fill !== undefined) {
15667
- if (typeof encoding === 'string') {
15668
- buf.fill(fill, encoding);
15669
- } else {
15670
- buf.fill(fill);
15671
- }
15672
- } else {
15673
- buf.fill(0);
15674
- }
15675
- return buf
15676
- };
15677
-
15678
- SafeBuffer.allocUnsafe = function (size) {
15679
- if (typeof size !== 'number') {
15680
- throw new TypeError('Argument must be a number')
15681
- }
15682
- return Buffer(size)
15683
- };
15684
-
15685
- SafeBuffer.allocUnsafeSlow = function (size) {
15686
- if (typeof size !== 'number') {
15687
- throw new TypeError('Argument must be a number')
15688
- }
15689
- return buffer.SlowBuffer(size)
15690
- };
15691
- } (safeBuffer, safeBuffer.exports));
15692
- return safeBuffer.exports;
15693
- }
15694
-
15695
- var src;
15696
- var hasRequiredSrc;
15697
-
15698
- function requireSrc () {
15699
- if (hasRequiredSrc) return src;
15700
- hasRequiredSrc = 1;
15701
- // base-x encoding / decoding
15702
- // Copyright (c) 2018 base-x contributors
15703
- // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
15704
- // Distributed under the MIT software license, see the accompanying
15705
- // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
15706
- // @ts-ignore
15707
- var _Buffer = requireSafeBuffer().Buffer;
15708
- function base (ALPHABET) {
15709
- if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
15710
- var BASE_MAP = new Uint8Array(256);
15711
- for (var j = 0; j < BASE_MAP.length; j++) {
15712
- BASE_MAP[j] = 255;
15713
- }
15714
- for (var i = 0; i < ALPHABET.length; i++) {
15715
- var x = ALPHABET.charAt(i);
15716
- var xc = x.charCodeAt(0);
15717
- if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
15718
- BASE_MAP[xc] = i;
15719
- }
15720
- var BASE = ALPHABET.length;
15721
- var LEADER = ALPHABET.charAt(0);
15722
- var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
15723
- var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
15724
- function encode (source) {
15725
- if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
15726
- if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
15727
- if (source.length === 0) { return '' }
15728
- // Skip & count leading zeroes.
15729
- var zeroes = 0;
15730
- var length = 0;
15731
- var pbegin = 0;
15732
- var pend = source.length;
15733
- while (pbegin !== pend && source[pbegin] === 0) {
15734
- pbegin++;
15735
- zeroes++;
15736
- }
15737
- // Allocate enough space in big-endian base58 representation.
15738
- var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
15739
- var b58 = new Uint8Array(size);
15740
- // Process the bytes.
15741
- while (pbegin !== pend) {
15742
- var carry = source[pbegin];
15743
- // Apply "b58 = b58 * 256 + ch".
15744
- var i = 0;
15745
- for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
15746
- carry += (256 * b58[it1]) >>> 0;
15747
- b58[it1] = (carry % BASE) >>> 0;
15748
- carry = (carry / BASE) >>> 0;
15749
- }
15750
- if (carry !== 0) { throw new Error('Non-zero carry') }
15751
- length = i;
15752
- pbegin++;
15753
- }
15754
- // Skip leading zeroes in base58 result.
15755
- var it2 = size - length;
15756
- while (it2 !== size && b58[it2] === 0) {
15757
- it2++;
15758
- }
15759
- // Translate the result into a string.
15760
- var str = LEADER.repeat(zeroes);
15761
- for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
15762
- return str
15763
- }
15764
- function decodeUnsafe (source) {
15765
- if (typeof source !== 'string') { throw new TypeError('Expected String') }
15766
- if (source.length === 0) { return _Buffer.alloc(0) }
15767
- var psz = 0;
15768
- // Skip and count leading '1's.
15769
- var zeroes = 0;
15770
- var length = 0;
15771
- while (source[psz] === LEADER) {
15772
- zeroes++;
15773
- psz++;
15774
- }
15775
- // Allocate enough space in big-endian base256 representation.
15776
- var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
15777
- var b256 = new Uint8Array(size);
15778
- // Process the characters.
15779
- while (psz < source.length) {
15780
- // Find code of next character
15781
- var charCode = source.charCodeAt(psz);
15782
- // Base map can not be indexed using char code
15783
- if (charCode > 255) { return }
15784
- // Decode character
15785
- var carry = BASE_MAP[charCode];
15786
- // Invalid character
15787
- if (carry === 255) { return }
15788
- var i = 0;
15789
- for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
15790
- carry += (BASE * b256[it3]) >>> 0;
15791
- b256[it3] = (carry % 256) >>> 0;
15792
- carry = (carry / 256) >>> 0;
15793
- }
15794
- if (carry !== 0) { throw new Error('Non-zero carry') }
15795
- length = i;
15796
- psz++;
15797
- }
15798
- // Skip leading zeroes in b256.
15799
- var it4 = size - length;
15800
- while (it4 !== size && b256[it4] === 0) {
15801
- it4++;
15802
- }
15803
- var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
15804
- vch.fill(0x00, 0, zeroes);
15805
- var j = zeroes;
15806
- while (it4 !== size) {
15807
- vch[j++] = b256[it4++];
15808
- }
15809
- return vch
15810
- }
15811
- function decode (string) {
15812
- var buffer = decodeUnsafe(string);
15813
- if (buffer) { return buffer }
15814
- throw new Error('Non-base' + BASE + ' character')
15815
- }
15816
- return {
15817
- encode: encode,
15818
- decodeUnsafe: decodeUnsafe,
15819
- decode: decode
15820
- }
15821
- }
15822
- src = base;
15823
- return src;
15824
- }
15825
-
15826
- var bs58$1;
15827
- var hasRequiredBs58;
15828
-
15829
- function requireBs58 () {
15830
- if (hasRequiredBs58) return bs58$1;
15831
- hasRequiredBs58 = 1;
15832
- var basex = requireSrc();
15833
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
15834
-
15835
- bs58$1 = basex(ALPHABET);
15836
- return bs58$1;
15837
- }
15838
-
15839
- var bs58Exports = requireBs58();
15840
- var bs58 = /*@__PURE__*/getDefaultExportFromCjs$1(bs58Exports);
15841
-
15842
- var index = /*#__PURE__*/_mergeNamespaces({
13233
+ // base-x encoding / decoding
13234
+ // Copyright (c) 2018 base-x contributors
13235
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
13236
+ // Distributed under the MIT software license, see the accompanying
13237
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
13238
+ function base (ALPHABET) {
13239
+ if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
13240
+ const BASE_MAP = new Uint8Array(256);
13241
+ for (let j = 0; j < BASE_MAP.length; j++) {
13242
+ BASE_MAP[j] = 255;
13243
+ }
13244
+ for (let i = 0; i < ALPHABET.length; i++) {
13245
+ const x = ALPHABET.charAt(i);
13246
+ const xc = x.charCodeAt(0);
13247
+ if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
13248
+ BASE_MAP[xc] = i;
13249
+ }
13250
+ const BASE = ALPHABET.length;
13251
+ const LEADER = ALPHABET.charAt(0);
13252
+ const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
13253
+ const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
13254
+ function encode (source) {
13255
+ // eslint-disable-next-line no-empty
13256
+ if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
13257
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
13258
+ } else if (Array.isArray(source)) {
13259
+ source = Uint8Array.from(source);
13260
+ }
13261
+ if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
13262
+ if (source.length === 0) { return '' }
13263
+ // Skip & count leading zeroes.
13264
+ let zeroes = 0;
13265
+ let length = 0;
13266
+ let pbegin = 0;
13267
+ const pend = source.length;
13268
+ while (pbegin !== pend && source[pbegin] === 0) {
13269
+ pbegin++;
13270
+ zeroes++;
13271
+ }
13272
+ // Allocate enough space in big-endian base58 representation.
13273
+ const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
13274
+ const b58 = new Uint8Array(size);
13275
+ // Process the bytes.
13276
+ while (pbegin !== pend) {
13277
+ let carry = source[pbegin];
13278
+ // Apply "b58 = b58 * 256 + ch".
13279
+ let i = 0;
13280
+ for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
13281
+ carry += (256 * b58[it1]) >>> 0;
13282
+ b58[it1] = (carry % BASE) >>> 0;
13283
+ carry = (carry / BASE) >>> 0;
13284
+ }
13285
+ if (carry !== 0) { throw new Error('Non-zero carry') }
13286
+ length = i;
13287
+ pbegin++;
13288
+ }
13289
+ // Skip leading zeroes in base58 result.
13290
+ let it2 = size - length;
13291
+ while (it2 !== size && b58[it2] === 0) {
13292
+ it2++;
13293
+ }
13294
+ // Translate the result into a string.
13295
+ let str = LEADER.repeat(zeroes);
13296
+ for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
13297
+ return str
13298
+ }
13299
+ function decodeUnsafe (source) {
13300
+ if (typeof source !== 'string') { throw new TypeError('Expected String') }
13301
+ if (source.length === 0) { return new Uint8Array() }
13302
+ let psz = 0;
13303
+ // Skip and count leading '1's.
13304
+ let zeroes = 0;
13305
+ let length = 0;
13306
+ while (source[psz] === LEADER) {
13307
+ zeroes++;
13308
+ psz++;
13309
+ }
13310
+ // Allocate enough space in big-endian base256 representation.
13311
+ const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
13312
+ const b256 = new Uint8Array(size);
13313
+ // Process the characters.
13314
+ while (psz < source.length) {
13315
+ // Find code of next character
13316
+ const charCode = source.charCodeAt(psz);
13317
+ // Base map can not be indexed using char code
13318
+ if (charCode > 255) { return }
13319
+ // Decode character
13320
+ let carry = BASE_MAP[charCode];
13321
+ // Invalid character
13322
+ if (carry === 255) { return }
13323
+ let i = 0;
13324
+ for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
13325
+ carry += (BASE * b256[it3]) >>> 0;
13326
+ b256[it3] = (carry % 256) >>> 0;
13327
+ carry = (carry / 256) >>> 0;
13328
+ }
13329
+ if (carry !== 0) { throw new Error('Non-zero carry') }
13330
+ length = i;
13331
+ psz++;
13332
+ }
13333
+ // Skip leading zeroes in b256.
13334
+ let it4 = size - length;
13335
+ while (it4 !== size && b256[it4] === 0) {
13336
+ it4++;
13337
+ }
13338
+ const vch = new Uint8Array(zeroes + (size - it4));
13339
+ let j = zeroes;
13340
+ while (it4 !== size) {
13341
+ vch[j++] = b256[it4++];
13342
+ }
13343
+ return vch
13344
+ }
13345
+ function decode (string) {
13346
+ const buffer = decodeUnsafe(string);
13347
+ if (buffer) { return buffer }
13348
+ throw new Error('Non-base' + BASE + ' character')
13349
+ }
13350
+ return {
13351
+ encode,
13352
+ decodeUnsafe,
13353
+ decode
13354
+ }
13355
+ }
13356
+
13357
+ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
13358
+ var bs58 = base(ALPHABET);
13359
+
13360
+ var index = /*#__PURE__*/Object.freeze({
15843
13361
  __proto__: null,
15844
13362
  default: bs58
15845
- }, [bs58Exports]);
13363
+ });
15846
13364
 
15847
13365
  /**
15848
13366
  * Privy Expo Auth Provider — React Native implementation of AuthProvider.
@@ -16183,5 +13701,5 @@ class PrivyExpoProvider {
16183
13701
  }
16184
13702
  }
16185
13703
 
16186
- export { ReactNativeSessionManager as $, getAuthProvider as A, get as B, set as C, setMany as D, setFile as E, getFiles as F, runQuery as G, runQueryMany as H, runExpression as I, runExpressionMany as J, signMessage as K, signTransaction as L, signAndSubmitTransaction as M, count as N, aggregate as O, subscribe as P, useAuth as Q, deserializeTransaction as R, SOLANA_MAINNET_RPC_URL as S, getIdToken as T, setPlatform as U, MockAuthProvider as V, WebSessionManager as W, DEFAULT_TEST_ADDRESS as X, OffchainAuthProvider as Y, PrivyExpoProvider as Z, InsufficientBalanceError as _, SOLANA_DEVNET_RPC_URL as a, ServerSessionManager as a0, clearCache as a1, closeAllSubscriptions as a2, getCachedData as a3, getMany as a4, reconnectWithNewAuth as a5, refreshSession as a6, signSessionCreateMessage as a7, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, bs58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, SURFNET_RPC_URL$1 as h, index as i, detectMobile as j, detectAndroid as k, setAuthLoading as l, genAuthNonce as m, genSolanaMessage as n, createSessionWithSignature as o, getDefaultExportFromCjs$1 as p, init as q, requireBuffer as r, setCurrentUser as s, getCurrentUser as t, onAuthStateChanged as u, onAuthLoadingChanged as v, getAuthLoading as w, login as x, logout as y, getConfig as z };
16187
- //# sourceMappingURL=index.native-DuKhZcus.esm.js.map
13704
+ export { clearCache as $, set as A, setMany as B, setFile as C, getFiles as D, runQuery as E, runQueryMany as F, runExpression as G, runExpressionMany as H, signMessage as I, signTransaction as J, signAndSubmitTransaction as K, count as L, aggregate as M, subscribe as N, useAuth as O, deserializeTransaction as P, getIdToken as Q, setPlatform as R, SOLANA_MAINNET_RPC_URL as S, MockAuthProvider as T, DEFAULT_TEST_ADDRESS as U, OffchainAuthProvider as V, WebSessionManager as W, PrivyExpoProvider as X, InsufficientBalanceError as Y, ReactNativeSessionManager as Z, ServerSessionManager as _, SOLANA_DEVNET_RPC_URL as a, closeAllSubscriptions as a0, getCachedData as a1, getMany as a2, reconnectWithNewAuth as a3, refreshSession as a4, signSessionCreateMessage as a5, index as a6, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, bs58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, detectAndroid as h, SURFNET_RPC_URL$1 as i, detectMobile as j, setAuthLoading as k, genAuthNonce as l, genSolanaMessage as m, createSessionWithSignature as n, getDefaultExportFromCjs$1 as o, init as p, getCurrentUser as q, onAuthStateChanged as r, setCurrentUser as s, onAuthLoadingChanged as t, getAuthLoading as u, login as v, logout as w, getConfig as x, getAuthProvider as y, get as z };
13705
+ //# sourceMappingURL=index.native-TLhfXfe6.esm.js.map