@pooflabs/web 0.0.80 → 0.0.81-rc1

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