wallaby-cash 1.7.13 → 1.7.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
5
  const axios = require('axios');
6
+ const log = require('loglevel');
6
7
  const cryptoJs = require('crypto-js');
7
8
  const jwtDecode = require('jwt-decode');
8
9
  const uuid = require('uuid');
@@ -10,6 +11,7 @@ const uuid = require('uuid');
10
11
  const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
11
12
 
12
13
  const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
14
+ const log__default = /*#__PURE__*/_interopDefaultCompat(log);
13
15
 
14
16
  /******************************************************************************
15
17
  Copyright (c) Microsoft Corporation.
@@ -224,7 +226,7 @@ function hexToBytes$2(hex) {
224
226
  /**
225
227
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
226
228
  */
227
- function utf8ToBytes$3(str) {
229
+ function utf8ToBytes$2(str) {
228
230
  if (typeof str !== 'string')
229
231
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
230
232
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
@@ -236,7 +238,7 @@ function utf8ToBytes$3(str) {
236
238
  */
237
239
  function toBytes(data) {
238
240
  if (typeof data === 'string')
239
- data = utf8ToBytes$3(data);
241
+ data = utf8ToBytes$2(data);
240
242
  bytes$1(data);
241
243
  return data;
242
244
  }
@@ -370,7 +372,7 @@ var concatUint8Arrays = function (uint8arrays) {
370
372
  * Converts a UTF-8 string to a Uint8Array without using TextEncoder, which is not available in mobile
371
373
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
372
374
  */
373
- var utf8ToBytes$2 = function (str) {
375
+ var utf8ToBytes$1 = function (str) {
374
376
  if (typeof str !== 'string')
375
377
  throw new Error("utf8ToBytes expected string, got ".concat(typeof str));
376
378
  var bytes = [];
@@ -863,7 +865,7 @@ function equalBytes(a, b) {
863
865
  /**
864
866
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
865
867
  */
866
- function utf8ToBytes$1(str) {
868
+ function utf8ToBytes(str) {
867
869
  if (typeof str !== 'string')
868
870
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
869
871
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
@@ -1065,7 +1067,7 @@ numberToBytesBE,
1065
1067
  numberToBytesLE,
1066
1068
  numberToHexUnpadded,
1067
1069
  numberToVarBytesBE,
1068
- utf8ToBytes: utf8ToBytes$1,
1070
+ utf8ToBytes,
1069
1071
  validateObject
1070
1072
  }, Symbol.toStringTag, { value: 'Module' }));
1071
1073
 
@@ -3697,7 +3699,7 @@ var encrypt = function (publicKeyTo, msg, options) {
3697
3699
  var hash = sha512(sharedSecret);
3698
3700
  var encryptionKey = hash.subarray(0, 32);
3699
3701
  var macKey = hash.subarray(32);
3700
- var message = utf8ToBytes$2(msg);
3702
+ var message = utf8ToBytes$1(msg);
3701
3703
  var data = encrypt$1(message, encryptionKey, iv, 'aes-256-cbc');
3702
3704
  var dataToMac = concatUint8Arrays([iv, ephemPublicKey, data]);
3703
3705
  var mac = hmacSha256Sign(macKey, dataToMac);
@@ -3739,7 +3741,7 @@ var decryptWithPrivateKey = function (privateKey, encrypted) {
3739
3741
  };
3740
3742
 
3741
3743
  var solidityPackedKeccak256 = function (value) {
3742
- var bytes = utf8ToBytes$2(value);
3744
+ var bytes = utf8ToBytes$1(value);
3743
3745
  var hex = addLeading0x(bytesToHex$1(bytes));
3744
3746
  var hash = keccak256$1(hexToBytes$1(hex));
3745
3747
  return addLeading0x(bytesToHex$1(hash));
@@ -3997,13 +3999,13 @@ Item.prototype.run = function () {
3997
3999
  this.fun.apply(null, this.array);
3998
4000
  };
3999
4001
  var title = 'browser';
4000
- var platform$1 = 'browser';
4001
- var browser$1 = true;
4002
+ var platform = 'browser';
4003
+ var browser = true;
4002
4004
  var env = {};
4003
4005
  var argv = [];
4004
4006
  var version = ''; // empty string to avoid regexp issues
4005
4007
  var versions = {};
4006
- var release$1 = {};
4008
+ var release = {};
4007
4009
  var config = {};
4008
4010
 
4009
4011
  function noop() {}
@@ -4053,4148 +4055,58 @@ function hrtime(previousTimestamp){
4053
4055
  }
4054
4056
 
4055
4057
  var startTime = new Date();
4056
- function uptime$1() {
4057
- var currentTime = new Date();
4058
- var dif = currentTime - startTime;
4059
- return dif / 1000;
4060
- }
4061
-
4062
- var browser$1$1 = {
4063
- nextTick: nextTick,
4064
- title: title,
4065
- browser: browser$1,
4066
- env: env,
4067
- argv: argv,
4068
- version: version,
4069
- versions: versions,
4070
- on: on,
4071
- addListener: addListener,
4072
- once: once,
4073
- off: off,
4074
- removeListener: removeListener,
4075
- removeAllListeners: removeAllListeners,
4076
- emit: emit,
4077
- binding: binding,
4078
- cwd: cwd,
4079
- chdir: chdir,
4080
- umask: umask,
4081
- hrtime: hrtime,
4082
- platform: platform$1,
4083
- release: release$1,
4084
- config: config,
4085
- uptime: uptime$1
4086
- };
4087
-
4088
- function getDefaultExportFromCjs (x) {
4089
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
4090
- }
4091
-
4092
- function getAugmentedNamespace(n) {
4093
- if (n.__esModule) return n;
4094
- var f = n.default;
4095
- if (typeof f == "function") {
4096
- var a = function a () {
4097
- if (this instanceof a) {
4098
- return Reflect.construct(f, arguments, this.constructor);
4099
- }
4100
- return f.apply(this, arguments);
4101
- };
4102
- a.prototype = f.prototype;
4103
- } else a = {};
4104
- Object.defineProperty(a, '__esModule', {value: true});
4105
- Object.keys(n).forEach(function (k) {
4106
- var d = Object.getOwnPropertyDescriptor(n, k);
4107
- Object.defineProperty(a, k, d.get ? d : {
4108
- enumerable: true,
4109
- get: function () {
4110
- return n[k];
4111
- }
4112
- });
4113
- });
4114
- return a;
4115
- }
4116
-
4117
- var src = {exports: {}};
4118
-
4119
- var browser = {exports: {}};
4120
-
4121
- /**
4122
- * Helpers.
4123
- */
4124
-
4125
- var ms;
4126
- var hasRequiredMs;
4127
-
4128
- function requireMs () {
4129
- if (hasRequiredMs) return ms;
4130
- hasRequiredMs = 1;
4131
- var s = 1000;
4132
- var m = s * 60;
4133
- var h = m * 60;
4134
- var d = h * 24;
4135
- var w = d * 7;
4136
- var y = d * 365.25;
4137
-
4138
- /**
4139
- * Parse or format the given `val`.
4140
- *
4141
- * Options:
4142
- *
4143
- * - `long` verbose formatting [false]
4144
- *
4145
- * @param {String|Number} val
4146
- * @param {Object} [options]
4147
- * @throws {Error} throw an error if val is not a non-empty string or a number
4148
- * @return {String|Number}
4149
- * @api public
4150
- */
4151
-
4152
- ms = function (val, options) {
4153
- options = options || {};
4154
- var type = typeof val;
4155
- if (type === 'string' && val.length > 0) {
4156
- return parse(val);
4157
- } else if (type === 'number' && isFinite(val)) {
4158
- return options.long ? fmtLong(val) : fmtShort(val);
4159
- }
4160
- throw new Error(
4161
- 'val is not a non-empty string or a valid number. val=' +
4162
- JSON.stringify(val)
4163
- );
4164
- };
4165
-
4166
- /**
4167
- * Parse the given `str` and return milliseconds.
4168
- *
4169
- * @param {String} str
4170
- * @return {Number}
4171
- * @api private
4172
- */
4173
-
4174
- function parse(str) {
4175
- str = String(str);
4176
- if (str.length > 100) {
4177
- return;
4178
- }
4179
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
4180
- str
4181
- );
4182
- if (!match) {
4183
- return;
4184
- }
4185
- var n = parseFloat(match[1]);
4186
- var type = (match[2] || 'ms').toLowerCase();
4187
- switch (type) {
4188
- case 'years':
4189
- case 'year':
4190
- case 'yrs':
4191
- case 'yr':
4192
- case 'y':
4193
- return n * y;
4194
- case 'weeks':
4195
- case 'week':
4196
- case 'w':
4197
- return n * w;
4198
- case 'days':
4199
- case 'day':
4200
- case 'd':
4201
- return n * d;
4202
- case 'hours':
4203
- case 'hour':
4204
- case 'hrs':
4205
- case 'hr':
4206
- case 'h':
4207
- return n * h;
4208
- case 'minutes':
4209
- case 'minute':
4210
- case 'mins':
4211
- case 'min':
4212
- case 'm':
4213
- return n * m;
4214
- case 'seconds':
4215
- case 'second':
4216
- case 'secs':
4217
- case 'sec':
4218
- case 's':
4219
- return n * s;
4220
- case 'milliseconds':
4221
- case 'millisecond':
4222
- case 'msecs':
4223
- case 'msec':
4224
- case 'ms':
4225
- return n;
4226
- default:
4227
- return undefined;
4228
- }
4229
- }
4230
-
4231
- /**
4232
- * Short format for `ms`.
4233
- *
4234
- * @param {Number} ms
4235
- * @return {String}
4236
- * @api private
4237
- */
4238
-
4239
- function fmtShort(ms) {
4240
- var msAbs = Math.abs(ms);
4241
- if (msAbs >= d) {
4242
- return Math.round(ms / d) + 'd';
4243
- }
4244
- if (msAbs >= h) {
4245
- return Math.round(ms / h) + 'h';
4246
- }
4247
- if (msAbs >= m) {
4248
- return Math.round(ms / m) + 'm';
4249
- }
4250
- if (msAbs >= s) {
4251
- return Math.round(ms / s) + 's';
4252
- }
4253
- return ms + 'ms';
4254
- }
4255
-
4256
- /**
4257
- * Long format for `ms`.
4258
- *
4259
- * @param {Number} ms
4260
- * @return {String}
4261
- * @api private
4262
- */
4263
-
4264
- function fmtLong(ms) {
4265
- var msAbs = Math.abs(ms);
4266
- if (msAbs >= d) {
4267
- return plural(ms, msAbs, d, 'day');
4268
- }
4269
- if (msAbs >= h) {
4270
- return plural(ms, msAbs, h, 'hour');
4271
- }
4272
- if (msAbs >= m) {
4273
- return plural(ms, msAbs, m, 'minute');
4274
- }
4275
- if (msAbs >= s) {
4276
- return plural(ms, msAbs, s, 'second');
4277
- }
4278
- return ms + ' ms';
4279
- }
4280
-
4281
- /**
4282
- * Pluralization helper.
4283
- */
4284
-
4285
- function plural(ms, msAbs, n, name) {
4286
- var isPlural = msAbs >= n * 1.5;
4287
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
4288
- }
4289
- return ms;
4290
- }
4291
-
4292
- var common;
4293
- var hasRequiredCommon;
4294
-
4295
- function requireCommon () {
4296
- if (hasRequiredCommon) return common;
4297
- hasRequiredCommon = 1;
4298
- /**
4299
- * This is the common logic for both the Node.js and web browser
4300
- * implementations of `debug()`.
4301
- */
4302
-
4303
- function setup(env) {
4304
- createDebug.debug = createDebug;
4305
- createDebug.default = createDebug;
4306
- createDebug.coerce = coerce;
4307
- createDebug.disable = disable;
4308
- createDebug.enable = enable;
4309
- createDebug.enabled = enabled;
4310
- createDebug.humanize = requireMs();
4311
- createDebug.destroy = destroy;
4312
-
4313
- Object.keys(env).forEach(key => {
4314
- createDebug[key] = env[key];
4315
- });
4316
-
4317
- /**
4318
- * The currently active debug mode names, and names to skip.
4319
- */
4320
-
4321
- createDebug.names = [];
4322
- createDebug.skips = [];
4323
-
4324
- /**
4325
- * Map of special "%n" handling functions, for the debug "format" argument.
4326
- *
4327
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
4328
- */
4329
- createDebug.formatters = {};
4330
-
4331
- /**
4332
- * Selects a color for a debug namespace
4333
- * @param {String} namespace The namespace string for the debug instance to be colored
4334
- * @return {Number|String} An ANSI color code for the given namespace
4335
- * @api private
4336
- */
4337
- function selectColor(namespace) {
4338
- let hash = 0;
4339
-
4340
- for (let i = 0; i < namespace.length; i++) {
4341
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
4342
- hash |= 0; // Convert to 32bit integer
4343
- }
4344
-
4345
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
4346
- }
4347
- createDebug.selectColor = selectColor;
4348
-
4349
- /**
4350
- * Create a debugger with the given `namespace`.
4351
- *
4352
- * @param {String} namespace
4353
- * @return {Function}
4354
- * @api public
4355
- */
4356
- function createDebug(namespace) {
4357
- let prevTime;
4358
- let enableOverride = null;
4359
- let namespacesCache;
4360
- let enabledCache;
4361
-
4362
- function debug(...args) {
4363
- // Disabled?
4364
- if (!debug.enabled) {
4365
- return;
4366
- }
4367
-
4368
- const self = debug;
4369
-
4370
- // Set `diff` timestamp
4371
- const curr = Number(new Date());
4372
- const ms = curr - (prevTime || curr);
4373
- self.diff = ms;
4374
- self.prev = prevTime;
4375
- self.curr = curr;
4376
- prevTime = curr;
4377
-
4378
- args[0] = createDebug.coerce(args[0]);
4379
-
4380
- if (typeof args[0] !== 'string') {
4381
- // Anything else let's inspect with %O
4382
- args.unshift('%O');
4383
- }
4384
-
4385
- // Apply any `formatters` transformations
4386
- let index = 0;
4387
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
4388
- // If we encounter an escaped % then don't increase the array index
4389
- if (match === '%%') {
4390
- return '%';
4391
- }
4392
- index++;
4393
- const formatter = createDebug.formatters[format];
4394
- if (typeof formatter === 'function') {
4395
- const val = args[index];
4396
- match = formatter.call(self, val);
4397
-
4398
- // Now we need to remove `args[index]` since it's inlined in the `format`
4399
- args.splice(index, 1);
4400
- index--;
4401
- }
4402
- return match;
4403
- });
4404
-
4405
- // Apply env-specific formatting (colors, etc.)
4406
- createDebug.formatArgs.call(self, args);
4407
-
4408
- const logFn = self.log || createDebug.log;
4409
- logFn.apply(self, args);
4410
- }
4411
-
4412
- debug.namespace = namespace;
4413
- debug.useColors = createDebug.useColors();
4414
- debug.color = createDebug.selectColor(namespace);
4415
- debug.extend = extend;
4416
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
4417
-
4418
- Object.defineProperty(debug, 'enabled', {
4419
- enumerable: true,
4420
- configurable: false,
4421
- get: () => {
4422
- if (enableOverride !== null) {
4423
- return enableOverride;
4424
- }
4425
- if (namespacesCache !== createDebug.namespaces) {
4426
- namespacesCache = createDebug.namespaces;
4427
- enabledCache = createDebug.enabled(namespace);
4428
- }
4429
-
4430
- return enabledCache;
4431
- },
4432
- set: v => {
4433
- enableOverride = v;
4434
- }
4435
- });
4436
-
4437
- // Env-specific initialization logic for debug instances
4438
- if (typeof createDebug.init === 'function') {
4439
- createDebug.init(debug);
4440
- }
4441
-
4442
- return debug;
4443
- }
4444
-
4445
- function extend(namespace, delimiter) {
4446
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
4447
- newDebug.log = this.log;
4448
- return newDebug;
4449
- }
4450
-
4451
- /**
4452
- * Enables a debug mode by namespaces. This can include modes
4453
- * separated by a colon and wildcards.
4454
- *
4455
- * @param {String} namespaces
4456
- * @api public
4457
- */
4458
- function enable(namespaces) {
4459
- createDebug.save(namespaces);
4460
- createDebug.namespaces = namespaces;
4461
-
4462
- createDebug.names = [];
4463
- createDebug.skips = [];
4464
-
4465
- let i;
4466
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
4467
- const len = split.length;
4468
-
4469
- for (i = 0; i < len; i++) {
4470
- if (!split[i]) {
4471
- // ignore empty strings
4472
- continue;
4473
- }
4474
-
4475
- namespaces = split[i].replace(/\*/g, '.*?');
4476
-
4477
- if (namespaces[0] === '-') {
4478
- createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
4479
- } else {
4480
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
4481
- }
4482
- }
4483
- }
4484
-
4485
- /**
4486
- * Disable debug output.
4487
- *
4488
- * @return {String} namespaces
4489
- * @api public
4490
- */
4491
- function disable() {
4492
- const namespaces = [
4493
- ...createDebug.names.map(toNamespace),
4494
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
4495
- ].join(',');
4496
- createDebug.enable('');
4497
- return namespaces;
4498
- }
4499
-
4500
- /**
4501
- * Returns true if the given mode name is enabled, false otherwise.
4502
- *
4503
- * @param {String} name
4504
- * @return {Boolean}
4505
- * @api public
4506
- */
4507
- function enabled(name) {
4508
- if (name[name.length - 1] === '*') {
4509
- return true;
4510
- }
4511
-
4512
- let i;
4513
- let len;
4514
-
4515
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
4516
- if (createDebug.skips[i].test(name)) {
4517
- return false;
4518
- }
4519
- }
4520
-
4521
- for (i = 0, len = createDebug.names.length; i < len; i++) {
4522
- if (createDebug.names[i].test(name)) {
4523
- return true;
4524
- }
4525
- }
4526
-
4527
- return false;
4528
- }
4529
-
4530
- /**
4531
- * Convert regexp to namespace
4532
- *
4533
- * @param {RegExp} regxep
4534
- * @return {String} namespace
4535
- * @api private
4536
- */
4537
- function toNamespace(regexp) {
4538
- return regexp.toString()
4539
- .substring(2, regexp.toString().length - 2)
4540
- .replace(/\.\*\?$/, '*');
4541
- }
4542
-
4543
- /**
4544
- * Coerce `val`.
4545
- *
4546
- * @param {Mixed} val
4547
- * @return {Mixed}
4548
- * @api private
4549
- */
4550
- function coerce(val) {
4551
- if (val instanceof Error) {
4552
- return val.stack || val.message;
4553
- }
4554
- return val;
4555
- }
4556
-
4557
- /**
4558
- * XXX DO NOT USE. This is a temporary stub function.
4559
- * XXX It WILL be removed in the next major release.
4560
- */
4561
- function destroy() {
4562
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
4563
- }
4564
-
4565
- createDebug.enable(createDebug.load());
4566
-
4567
- return createDebug;
4568
- }
4569
-
4570
- common = setup;
4571
- return common;
4572
- }
4573
-
4574
- var hasRequiredBrowser;
4575
-
4576
- function requireBrowser () {
4577
- if (hasRequiredBrowser) return browser.exports;
4578
- hasRequiredBrowser = 1;
4579
- (function (module, exports) {
4580
- /**
4581
- * This is the web browser implementation of `debug()`.
4582
- */
4583
-
4584
- exports.formatArgs = formatArgs;
4585
- exports.save = save;
4586
- exports.load = load;
4587
- exports.useColors = useColors;
4588
- exports.storage = localstorage();
4589
- exports.destroy = (() => {
4590
- let warned = false;
4591
-
4592
- return () => {
4593
- if (!warned) {
4594
- warned = true;
4595
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
4596
- }
4597
- };
4598
- })();
4599
-
4600
- /**
4601
- * Colors.
4602
- */
4603
-
4604
- exports.colors = [
4605
- '#0000CC',
4606
- '#0000FF',
4607
- '#0033CC',
4608
- '#0033FF',
4609
- '#0066CC',
4610
- '#0066FF',
4611
- '#0099CC',
4612
- '#0099FF',
4613
- '#00CC00',
4614
- '#00CC33',
4615
- '#00CC66',
4616
- '#00CC99',
4617
- '#00CCCC',
4618
- '#00CCFF',
4619
- '#3300CC',
4620
- '#3300FF',
4621
- '#3333CC',
4622
- '#3333FF',
4623
- '#3366CC',
4624
- '#3366FF',
4625
- '#3399CC',
4626
- '#3399FF',
4627
- '#33CC00',
4628
- '#33CC33',
4629
- '#33CC66',
4630
- '#33CC99',
4631
- '#33CCCC',
4632
- '#33CCFF',
4633
- '#6600CC',
4634
- '#6600FF',
4635
- '#6633CC',
4636
- '#6633FF',
4637
- '#66CC00',
4638
- '#66CC33',
4639
- '#9900CC',
4640
- '#9900FF',
4641
- '#9933CC',
4642
- '#9933FF',
4643
- '#99CC00',
4644
- '#99CC33',
4645
- '#CC0000',
4646
- '#CC0033',
4647
- '#CC0066',
4648
- '#CC0099',
4649
- '#CC00CC',
4650
- '#CC00FF',
4651
- '#CC3300',
4652
- '#CC3333',
4653
- '#CC3366',
4654
- '#CC3399',
4655
- '#CC33CC',
4656
- '#CC33FF',
4657
- '#CC6600',
4658
- '#CC6633',
4659
- '#CC9900',
4660
- '#CC9933',
4661
- '#CCCC00',
4662
- '#CCCC33',
4663
- '#FF0000',
4664
- '#FF0033',
4665
- '#FF0066',
4666
- '#FF0099',
4667
- '#FF00CC',
4668
- '#FF00FF',
4669
- '#FF3300',
4670
- '#FF3333',
4671
- '#FF3366',
4672
- '#FF3399',
4673
- '#FF33CC',
4674
- '#FF33FF',
4675
- '#FF6600',
4676
- '#FF6633',
4677
- '#FF9900',
4678
- '#FF9933',
4679
- '#FFCC00',
4680
- '#FFCC33'
4681
- ];
4682
-
4683
- /**
4684
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
4685
- * and the Firebug extension (any Firefox version) are known
4686
- * to support "%c" CSS customizations.
4687
- *
4688
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
4689
- */
4690
-
4691
- // eslint-disable-next-line complexity
4692
- function useColors() {
4693
- // NB: In an Electron preload script, document will be defined but not fully
4694
- // initialized. Since we know we're in Chrome, we'll just detect this case
4695
- // explicitly
4696
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
4697
- return true;
4698
- }
4699
-
4700
- // Internet Explorer and Edge do not support colors.
4701
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
4702
- return false;
4703
- }
4704
-
4705
- let m;
4706
-
4707
- // Is webkit? http://stackoverflow.com/a/16459606/376773
4708
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
4709
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
4710
- // Is firebug? http://stackoverflow.com/a/398120/376773
4711
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
4712
- // Is firefox >= v31?
4713
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
4714
- (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
4715
- // Double check webkit in userAgent just in case we are in a worker
4716
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
4717
- }
4718
-
4719
- /**
4720
- * Colorize log arguments if enabled.
4721
- *
4722
- * @api public
4723
- */
4724
-
4725
- function formatArgs(args) {
4726
- args[0] = (this.useColors ? '%c' : '') +
4727
- this.namespace +
4728
- (this.useColors ? ' %c' : ' ') +
4729
- args[0] +
4730
- (this.useColors ? '%c ' : ' ') +
4731
- '+' + module.exports.humanize(this.diff);
4732
-
4733
- if (!this.useColors) {
4734
- return;
4735
- }
4736
-
4737
- const c = 'color: ' + this.color;
4738
- args.splice(1, 0, c, 'color: inherit');
4739
-
4740
- // The final "%c" is somewhat tricky, because there could be other
4741
- // arguments passed either before or after the %c, so we need to
4742
- // figure out the correct index to insert the CSS into
4743
- let index = 0;
4744
- let lastC = 0;
4745
- args[0].replace(/%[a-zA-Z%]/g, match => {
4746
- if (match === '%%') {
4747
- return;
4748
- }
4749
- index++;
4750
- if (match === '%c') {
4751
- // We only are interested in the *last* %c
4752
- // (the user may have provided their own)
4753
- lastC = index;
4754
- }
4755
- });
4756
-
4757
- args.splice(lastC, 0, c);
4758
- }
4759
-
4760
- /**
4761
- * Invokes `console.debug()` when available.
4762
- * No-op when `console.debug` is not a "function".
4763
- * If `console.debug` is not available, falls back
4764
- * to `console.log`.
4765
- *
4766
- * @api public
4767
- */
4768
- exports.log = console.debug || console.log || (() => {});
4769
-
4770
- /**
4771
- * Save `namespaces`.
4772
- *
4773
- * @param {String} namespaces
4774
- * @api private
4775
- */
4776
- function save(namespaces) {
4777
- try {
4778
- if (namespaces) {
4779
- exports.storage.setItem('debug', namespaces);
4780
- } else {
4781
- exports.storage.removeItem('debug');
4782
- }
4783
- } catch (error) {
4784
- // Swallow
4785
- // XXX (@Qix-) should we be logging these?
4786
- }
4787
- }
4788
-
4789
- /**
4790
- * Load `namespaces`.
4791
- *
4792
- * @return {String} returns the previously persisted debug modes
4793
- * @api private
4794
- */
4795
- function load() {
4796
- let r;
4797
- try {
4798
- r = exports.storage.getItem('debug');
4799
- } catch (error) {
4800
- // Swallow
4801
- // XXX (@Qix-) should we be logging these?
4802
- }
4803
-
4804
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
4805
- if (!r && typeof browser$1$1 !== 'undefined' && 'env' in browser$1$1) {
4806
- r = browser$1$1.env.DEBUG;
4807
- }
4808
-
4809
- return r;
4810
- }
4811
-
4812
- /**
4813
- * Localstorage attempts to return the localstorage.
4814
- *
4815
- * This is necessary because safari throws
4816
- * when a user disables cookies/localstorage
4817
- * and you attempt to access it.
4818
- *
4819
- * @return {LocalStorage}
4820
- * @api private
4821
- */
4822
-
4823
- function localstorage() {
4824
- try {
4825
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
4826
- // The Browser also has localStorage in the global context.
4827
- return localStorage;
4828
- } catch (error) {
4829
- // Swallow
4830
- // XXX (@Qix-) should we be logging these?
4831
- }
4832
- }
4833
-
4834
- module.exports = requireCommon()(exports);
4835
-
4836
- const {formatters} = module.exports;
4837
-
4838
- /**
4839
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
4840
- */
4841
-
4842
- formatters.j = function (v) {
4843
- try {
4844
- return JSON.stringify(v);
4845
- } catch (error) {
4846
- return '[UnexpectedJSONParseError]: ' + error.message;
4847
- }
4848
- };
4849
- } (browser, browser.exports));
4850
- return browser.exports;
4851
- }
4852
-
4853
- var node = {exports: {}};
4854
-
4855
- // MIT lisence
4856
- // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
4857
-
4858
- function isatty() {
4859
- return false;
4860
- }
4861
-
4862
- function ReadStream() {
4863
- throw new Error('tty.ReadStream is not implemented');
4864
- }
4865
-
4866
- function WriteStream() {
4867
- throw new Error('tty.ReadStream is not implemented');
4868
- }
4869
-
4870
- const _polyfillNode_tty = {
4871
- isatty: isatty,
4872
- ReadStream: ReadStream,
4873
- WriteStream: WriteStream
4874
- };
4875
-
4876
- const _polyfillNode_tty$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4877
- __proto__: null,
4878
- ReadStream,
4879
- WriteStream,
4880
- default: _polyfillNode_tty,
4881
- isatty
4882
- }, Symbol.toStringTag, { value: 'Module' }));
4883
-
4884
- const require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_tty$1);
4885
-
4886
- var lookup = [];
4887
- var revLookup = [];
4888
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
4889
- var inited = false;
4890
- function init () {
4891
- inited = true;
4892
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
4893
- for (var i = 0, len = code.length; i < len; ++i) {
4894
- lookup[i] = code[i];
4895
- revLookup[code.charCodeAt(i)] = i;
4896
- }
4897
-
4898
- revLookup['-'.charCodeAt(0)] = 62;
4899
- revLookup['_'.charCodeAt(0)] = 63;
4900
- }
4901
-
4902
- function toByteArray (b64) {
4903
- if (!inited) {
4904
- init();
4905
- }
4906
- var i, j, l, tmp, placeHolders, arr;
4907
- var len = b64.length;
4908
-
4909
- if (len % 4 > 0) {
4910
- throw new Error('Invalid string. Length must be a multiple of 4')
4911
- }
4912
-
4913
- // the number of equal signs (place holders)
4914
- // if there are two placeholders, than the two characters before it
4915
- // represent one byte
4916
- // if there is only one, then the three characters before it represent 2 bytes
4917
- // this is just a cheap hack to not do indexOf twice
4918
- placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
4919
-
4920
- // base64 is 4/3 + up to two characters of the original data
4921
- arr = new Arr(len * 3 / 4 - placeHolders);
4922
-
4923
- // if there are placeholders, only get up to the last complete 4 chars
4924
- l = placeHolders > 0 ? len - 4 : len;
4925
-
4926
- var L = 0;
4927
-
4928
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
4929
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
4930
- arr[L++] = (tmp >> 16) & 0xFF;
4931
- arr[L++] = (tmp >> 8) & 0xFF;
4932
- arr[L++] = tmp & 0xFF;
4933
- }
4934
-
4935
- if (placeHolders === 2) {
4936
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
4937
- arr[L++] = tmp & 0xFF;
4938
- } else if (placeHolders === 1) {
4939
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
4940
- arr[L++] = (tmp >> 8) & 0xFF;
4941
- arr[L++] = tmp & 0xFF;
4942
- }
4943
-
4944
- return arr
4945
- }
4946
-
4947
- function tripletToBase64 (num) {
4948
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
4949
- }
4950
-
4951
- function encodeChunk (uint8, start, end) {
4952
- var tmp;
4953
- var output = [];
4954
- for (var i = start; i < end; i += 3) {
4955
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
4956
- output.push(tripletToBase64(tmp));
4957
- }
4958
- return output.join('')
4959
- }
4960
-
4961
- function fromByteArray (uint8) {
4962
- if (!inited) {
4963
- init();
4964
- }
4965
- var tmp;
4966
- var len = uint8.length;
4967
- var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
4968
- var output = '';
4969
- var parts = [];
4970
- var maxChunkLength = 16383; // must be multiple of 3
4971
-
4972
- // go through the array every three bytes, we'll deal with trailing stuff later
4973
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
4974
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
4975
- }
4976
-
4977
- // pad the end with zeros, but make sure to not forget the extra bytes
4978
- if (extraBytes === 1) {
4979
- tmp = uint8[len - 1];
4980
- output += lookup[tmp >> 2];
4981
- output += lookup[(tmp << 4) & 0x3F];
4982
- output += '==';
4983
- } else if (extraBytes === 2) {
4984
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
4985
- output += lookup[tmp >> 10];
4986
- output += lookup[(tmp >> 4) & 0x3F];
4987
- output += lookup[(tmp << 2) & 0x3F];
4988
- output += '=';
4989
- }
4990
-
4991
- parts.push(output);
4992
-
4993
- return parts.join('')
4994
- }
4995
-
4996
- function read (buffer, offset, isLE, mLen, nBytes) {
4997
- var e, m;
4998
- var eLen = nBytes * 8 - mLen - 1;
4999
- var eMax = (1 << eLen) - 1;
5000
- var eBias = eMax >> 1;
5001
- var nBits = -7;
5002
- var i = isLE ? (nBytes - 1) : 0;
5003
- var d = isLE ? -1 : 1;
5004
- var s = buffer[offset + i];
5005
-
5006
- i += d;
5007
-
5008
- e = s & ((1 << (-nBits)) - 1);
5009
- s >>= (-nBits);
5010
- nBits += eLen;
5011
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
5012
-
5013
- m = e & ((1 << (-nBits)) - 1);
5014
- e >>= (-nBits);
5015
- nBits += mLen;
5016
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
5017
-
5018
- if (e === 0) {
5019
- e = 1 - eBias;
5020
- } else if (e === eMax) {
5021
- return m ? NaN : ((s ? -1 : 1) * Infinity)
5022
- } else {
5023
- m = m + Math.pow(2, mLen);
5024
- e = e - eBias;
5025
- }
5026
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
5027
- }
5028
-
5029
- function write (buffer, value, offset, isLE, mLen, nBytes) {
5030
- var e, m, c;
5031
- var eLen = nBytes * 8 - mLen - 1;
5032
- var eMax = (1 << eLen) - 1;
5033
- var eBias = eMax >> 1;
5034
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
5035
- var i = isLE ? 0 : (nBytes - 1);
5036
- var d = isLE ? 1 : -1;
5037
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
5038
-
5039
- value = Math.abs(value);
5040
-
5041
- if (isNaN(value) || value === Infinity) {
5042
- m = isNaN(value) ? 1 : 0;
5043
- e = eMax;
5044
- } else {
5045
- e = Math.floor(Math.log(value) / Math.LN2);
5046
- if (value * (c = Math.pow(2, -e)) < 1) {
5047
- e--;
5048
- c *= 2;
5049
- }
5050
- if (e + eBias >= 1) {
5051
- value += rt / c;
5052
- } else {
5053
- value += rt * Math.pow(2, 1 - eBias);
5054
- }
5055
- if (value * c >= 2) {
5056
- e++;
5057
- c /= 2;
5058
- }
5059
-
5060
- if (e + eBias >= eMax) {
5061
- m = 0;
5062
- e = eMax;
5063
- } else if (e + eBias >= 1) {
5064
- m = (value * c - 1) * Math.pow(2, mLen);
5065
- e = e + eBias;
5066
- } else {
5067
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
5068
- e = 0;
5069
- }
5070
- }
5071
-
5072
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
5073
-
5074
- e = (e << mLen) | m;
5075
- eLen += mLen;
5076
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
5077
-
5078
- buffer[offset + i - d] |= s * 128;
5079
- }
5080
-
5081
- var toString = {}.toString;
5082
-
5083
- var isArray$1 = Array.isArray || function (arr) {
5084
- return toString.call(arr) == '[object Array]';
5085
- };
5086
-
5087
- /*!
5088
- * The buffer module from node.js, for the browser.
5089
- *
5090
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
5091
- * @license MIT
5092
- */
5093
- /* eslint-disable no-proto */
5094
-
5095
-
5096
- var INSPECT_MAX_BYTES = 50;
5097
-
5098
- /**
5099
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
5100
- * === true Use Uint8Array implementation (fastest)
5101
- * === false Use Object implementation (most compatible, even IE6)
5102
- *
5103
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
5104
- * Opera 11.6+, iOS 4.2+.
5105
- *
5106
- * Due to various browser bugs, sometimes the Object implementation will be used even
5107
- * when the browser supports typed arrays.
5108
- *
5109
- * Note:
5110
- *
5111
- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
5112
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
5113
- *
5114
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
5115
- *
5116
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
5117
- * incorrect length in some situations.
5118
-
5119
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
5120
- * get the Object implementation, which is slower but behaves correctly.
5121
- */
5122
- Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
5123
- ? global$1.TYPED_ARRAY_SUPPORT
5124
- : true;
5125
-
5126
- /*
5127
- * Export kMaxLength after typed array support is determined.
5128
- */
5129
- kMaxLength();
5130
-
5131
- function kMaxLength () {
5132
- return Buffer.TYPED_ARRAY_SUPPORT
5133
- ? 0x7fffffff
5134
- : 0x3fffffff
5135
- }
5136
-
5137
- function createBuffer (that, length) {
5138
- if (kMaxLength() < length) {
5139
- throw new RangeError('Invalid typed array length')
5140
- }
5141
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5142
- // Return an augmented `Uint8Array` instance, for best performance
5143
- that = new Uint8Array(length);
5144
- that.__proto__ = Buffer.prototype;
5145
- } else {
5146
- // Fallback: Return an object instance of the Buffer class
5147
- if (that === null) {
5148
- that = new Buffer(length);
5149
- }
5150
- that.length = length;
5151
- }
5152
-
5153
- return that
5154
- }
5155
-
5156
- /**
5157
- * The Buffer constructor returns instances of `Uint8Array` that have their
5158
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
5159
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
5160
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
5161
- * returns a single octet.
5162
- *
5163
- * The `Uint8Array` prototype remains unmodified.
5164
- */
5165
-
5166
- function Buffer (arg, encodingOrOffset, length) {
5167
- if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
5168
- return new Buffer(arg, encodingOrOffset, length)
5169
- }
5170
-
5171
- // Common case.
5172
- if (typeof arg === 'number') {
5173
- if (typeof encodingOrOffset === 'string') {
5174
- throw new Error(
5175
- 'If encoding is specified then the first argument must be a string'
5176
- )
5177
- }
5178
- return allocUnsafe(this, arg)
5179
- }
5180
- return from(this, arg, encodingOrOffset, length)
5181
- }
5182
-
5183
- Buffer.poolSize = 8192; // not used by this implementation
5184
-
5185
- // TODO: Legacy, not needed anymore. Remove in next major version.
5186
- Buffer._augment = function (arr) {
5187
- arr.__proto__ = Buffer.prototype;
5188
- return arr
5189
- };
5190
-
5191
- function from (that, value, encodingOrOffset, length) {
5192
- if (typeof value === 'number') {
5193
- throw new TypeError('"value" argument must not be a number')
5194
- }
5195
-
5196
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
5197
- return fromArrayBuffer(that, value, encodingOrOffset, length)
5198
- }
5199
-
5200
- if (typeof value === 'string') {
5201
- return fromString(that, value, encodingOrOffset)
5202
- }
5203
-
5204
- return fromObject(that, value)
5205
- }
5206
-
5207
- /**
5208
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
5209
- * if value is a number.
5210
- * Buffer.from(str[, encoding])
5211
- * Buffer.from(array)
5212
- * Buffer.from(buffer)
5213
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
5214
- **/
5215
- Buffer.from = function (value, encodingOrOffset, length) {
5216
- return from(null, value, encodingOrOffset, length)
5217
- };
5218
-
5219
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5220
- Buffer.prototype.__proto__ = Uint8Array.prototype;
5221
- Buffer.__proto__ = Uint8Array;
5222
- if (typeof Symbol !== 'undefined' && Symbol.species &&
5223
- Buffer[Symbol.species] === Buffer) ;
5224
- }
5225
-
5226
- function assertSize (size) {
5227
- if (typeof size !== 'number') {
5228
- throw new TypeError('"size" argument must be a number')
5229
- } else if (size < 0) {
5230
- throw new RangeError('"size" argument must not be negative')
5231
- }
5232
- }
5233
-
5234
- function alloc (that, size, fill, encoding) {
5235
- assertSize(size);
5236
- if (size <= 0) {
5237
- return createBuffer(that, size)
5238
- }
5239
- if (fill !== undefined) {
5240
- // Only pay attention to encoding if it's a string. This
5241
- // prevents accidentally sending in a number that would
5242
- // be interpretted as a start offset.
5243
- return typeof encoding === 'string'
5244
- ? createBuffer(that, size).fill(fill, encoding)
5245
- : createBuffer(that, size).fill(fill)
5246
- }
5247
- return createBuffer(that, size)
5248
- }
5249
-
5250
- /**
5251
- * Creates a new filled Buffer instance.
5252
- * alloc(size[, fill[, encoding]])
5253
- **/
5254
- Buffer.alloc = function (size, fill, encoding) {
5255
- return alloc(null, size, fill, encoding)
5256
- };
5257
-
5258
- function allocUnsafe (that, size) {
5259
- assertSize(size);
5260
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
5261
- if (!Buffer.TYPED_ARRAY_SUPPORT) {
5262
- for (var i = 0; i < size; ++i) {
5263
- that[i] = 0;
5264
- }
5265
- }
5266
- return that
5267
- }
5268
-
5269
- /**
5270
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
5271
- * */
5272
- Buffer.allocUnsafe = function (size) {
5273
- return allocUnsafe(null, size)
5274
- };
5275
- /**
5276
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
5277
- */
5278
- Buffer.allocUnsafeSlow = function (size) {
5279
- return allocUnsafe(null, size)
5280
- };
5281
-
5282
- function fromString (that, string, encoding) {
5283
- if (typeof encoding !== 'string' || encoding === '') {
5284
- encoding = 'utf8';
5285
- }
5286
-
5287
- if (!Buffer.isEncoding(encoding)) {
5288
- throw new TypeError('"encoding" must be a valid string encoding')
5289
- }
5290
-
5291
- var length = byteLength(string, encoding) | 0;
5292
- that = createBuffer(that, length);
5293
-
5294
- var actual = that.write(string, encoding);
5295
-
5296
- if (actual !== length) {
5297
- // Writing a hex string, for example, that contains invalid characters will
5298
- // cause everything after the first invalid character to be ignored. (e.g.
5299
- // 'abxxcd' will be treated as 'ab')
5300
- that = that.slice(0, actual);
5301
- }
5302
-
5303
- return that
5304
- }
5305
-
5306
- function fromArrayLike (that, array) {
5307
- var length = array.length < 0 ? 0 : checked(array.length) | 0;
5308
- that = createBuffer(that, length);
5309
- for (var i = 0; i < length; i += 1) {
5310
- that[i] = array[i] & 255;
5311
- }
5312
- return that
5313
- }
5314
-
5315
- function fromArrayBuffer (that, array, byteOffset, length) {
5316
- array.byteLength; // this throws if `array` is not a valid ArrayBuffer
5317
-
5318
- if (byteOffset < 0 || array.byteLength < byteOffset) {
5319
- throw new RangeError('\'offset\' is out of bounds')
5320
- }
5321
-
5322
- if (array.byteLength < byteOffset + (length || 0)) {
5323
- throw new RangeError('\'length\' is out of bounds')
5324
- }
5325
-
5326
- if (byteOffset === undefined && length === undefined) {
5327
- array = new Uint8Array(array);
5328
- } else if (length === undefined) {
5329
- array = new Uint8Array(array, byteOffset);
5330
- } else {
5331
- array = new Uint8Array(array, byteOffset, length);
5332
- }
5333
-
5334
- if (Buffer.TYPED_ARRAY_SUPPORT) {
5335
- // Return an augmented `Uint8Array` instance, for best performance
5336
- that = array;
5337
- that.__proto__ = Buffer.prototype;
5338
- } else {
5339
- // Fallback: Return an object instance of the Buffer class
5340
- that = fromArrayLike(that, array);
5341
- }
5342
- return that
5343
- }
5344
-
5345
- function fromObject (that, obj) {
5346
- if (internalIsBuffer(obj)) {
5347
- var len = checked(obj.length) | 0;
5348
- that = createBuffer(that, len);
5349
-
5350
- if (that.length === 0) {
5351
- return that
5352
- }
5353
-
5354
- obj.copy(that, 0, 0, len);
5355
- return that
5356
- }
5357
-
5358
- if (obj) {
5359
- if ((typeof ArrayBuffer !== 'undefined' &&
5360
- obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
5361
- if (typeof obj.length !== 'number' || isnan(obj.length)) {
5362
- return createBuffer(that, 0)
5363
- }
5364
- return fromArrayLike(that, obj)
5365
- }
5366
-
5367
- if (obj.type === 'Buffer' && isArray$1(obj.data)) {
5368
- return fromArrayLike(that, obj.data)
5369
- }
5370
- }
5371
-
5372
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
5373
- }
5374
-
5375
- function checked (length) {
5376
- // Note: cannot use `length < kMaxLength()` here because that fails when
5377
- // length is NaN (which is otherwise coerced to zero.)
5378
- if (length >= kMaxLength()) {
5379
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
5380
- 'size: 0x' + kMaxLength().toString(16) + ' bytes')
5381
- }
5382
- return length | 0
5383
- }
5384
- Buffer.isBuffer = isBuffer$1;
5385
- function internalIsBuffer (b) {
5386
- return !!(b != null && b._isBuffer)
5387
- }
5388
-
5389
- Buffer.compare = function compare (a, b) {
5390
- if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
5391
- throw new TypeError('Arguments must be Buffers')
5392
- }
5393
-
5394
- if (a === b) return 0
5395
-
5396
- var x = a.length;
5397
- var y = b.length;
5398
-
5399
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
5400
- if (a[i] !== b[i]) {
5401
- x = a[i];
5402
- y = b[i];
5403
- break
5404
- }
5405
- }
5406
-
5407
- if (x < y) return -1
5408
- if (y < x) return 1
5409
- return 0
5410
- };
5411
-
5412
- Buffer.isEncoding = function isEncoding (encoding) {
5413
- switch (String(encoding).toLowerCase()) {
5414
- case 'hex':
5415
- case 'utf8':
5416
- case 'utf-8':
5417
- case 'ascii':
5418
- case 'latin1':
5419
- case 'binary':
5420
- case 'base64':
5421
- case 'ucs2':
5422
- case 'ucs-2':
5423
- case 'utf16le':
5424
- case 'utf-16le':
5425
- return true
5426
- default:
5427
- return false
5428
- }
5429
- };
5430
-
5431
- Buffer.concat = function concat (list, length) {
5432
- if (!isArray$1(list)) {
5433
- throw new TypeError('"list" argument must be an Array of Buffers')
5434
- }
5435
-
5436
- if (list.length === 0) {
5437
- return Buffer.alloc(0)
5438
- }
5439
-
5440
- var i;
5441
- if (length === undefined) {
5442
- length = 0;
5443
- for (i = 0; i < list.length; ++i) {
5444
- length += list[i].length;
5445
- }
5446
- }
5447
-
5448
- var buffer = Buffer.allocUnsafe(length);
5449
- var pos = 0;
5450
- for (i = 0; i < list.length; ++i) {
5451
- var buf = list[i];
5452
- if (!internalIsBuffer(buf)) {
5453
- throw new TypeError('"list" argument must be an Array of Buffers')
5454
- }
5455
- buf.copy(buffer, pos);
5456
- pos += buf.length;
5457
- }
5458
- return buffer
5459
- };
5460
-
5461
- function byteLength (string, encoding) {
5462
- if (internalIsBuffer(string)) {
5463
- return string.length
5464
- }
5465
- if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
5466
- (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
5467
- return string.byteLength
5468
- }
5469
- if (typeof string !== 'string') {
5470
- string = '' + string;
5471
- }
5472
-
5473
- var len = string.length;
5474
- if (len === 0) return 0
5475
-
5476
- // Use a for loop to avoid recursion
5477
- var loweredCase = false;
5478
- for (;;) {
5479
- switch (encoding) {
5480
- case 'ascii':
5481
- case 'latin1':
5482
- case 'binary':
5483
- return len
5484
- case 'utf8':
5485
- case 'utf-8':
5486
- case undefined:
5487
- return utf8ToBytes(string).length
5488
- case 'ucs2':
5489
- case 'ucs-2':
5490
- case 'utf16le':
5491
- case 'utf-16le':
5492
- return len * 2
5493
- case 'hex':
5494
- return len >>> 1
5495
- case 'base64':
5496
- return base64ToBytes(string).length
5497
- default:
5498
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
5499
- encoding = ('' + encoding).toLowerCase();
5500
- loweredCase = true;
5501
- }
5502
- }
5503
- }
5504
- Buffer.byteLength = byteLength;
5505
-
5506
- function slowToString (encoding, start, end) {
5507
- var loweredCase = false;
5508
-
5509
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
5510
- // property of a typed array.
5511
-
5512
- // This behaves neither like String nor Uint8Array in that we set start/end
5513
- // to their upper/lower bounds if the value passed is out of range.
5514
- // undefined is handled specially as per ECMA-262 6th Edition,
5515
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
5516
- if (start === undefined || start < 0) {
5517
- start = 0;
5518
- }
5519
- // Return early if start > this.length. Done here to prevent potential uint32
5520
- // coercion fail below.
5521
- if (start > this.length) {
5522
- return ''
5523
- }
5524
-
5525
- if (end === undefined || end > this.length) {
5526
- end = this.length;
5527
- }
5528
-
5529
- if (end <= 0) {
5530
- return ''
5531
- }
5532
-
5533
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
5534
- end >>>= 0;
5535
- start >>>= 0;
5536
-
5537
- if (end <= start) {
5538
- return ''
5539
- }
5540
-
5541
- if (!encoding) encoding = 'utf8';
5542
-
5543
- while (true) {
5544
- switch (encoding) {
5545
- case 'hex':
5546
- return hexSlice(this, start, end)
5547
-
5548
- case 'utf8':
5549
- case 'utf-8':
5550
- return utf8Slice(this, start, end)
5551
-
5552
- case 'ascii':
5553
- return asciiSlice(this, start, end)
5554
-
5555
- case 'latin1':
5556
- case 'binary':
5557
- return latin1Slice(this, start, end)
5558
-
5559
- case 'base64':
5560
- return base64Slice(this, start, end)
5561
-
5562
- case 'ucs2':
5563
- case 'ucs-2':
5564
- case 'utf16le':
5565
- case 'utf-16le':
5566
- return utf16leSlice(this, start, end)
5567
-
5568
- default:
5569
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
5570
- encoding = (encoding + '').toLowerCase();
5571
- loweredCase = true;
5572
- }
5573
- }
5574
- }
5575
-
5576
- // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
5577
- // Buffer instances.
5578
- Buffer.prototype._isBuffer = true;
5579
-
5580
- function swap (b, n, m) {
5581
- var i = b[n];
5582
- b[n] = b[m];
5583
- b[m] = i;
5584
- }
5585
-
5586
- Buffer.prototype.swap16 = function swap16 () {
5587
- var len = this.length;
5588
- if (len % 2 !== 0) {
5589
- throw new RangeError('Buffer size must be a multiple of 16-bits')
5590
- }
5591
- for (var i = 0; i < len; i += 2) {
5592
- swap(this, i, i + 1);
5593
- }
5594
- return this
5595
- };
5596
-
5597
- Buffer.prototype.swap32 = function swap32 () {
5598
- var len = this.length;
5599
- if (len % 4 !== 0) {
5600
- throw new RangeError('Buffer size must be a multiple of 32-bits')
5601
- }
5602
- for (var i = 0; i < len; i += 4) {
5603
- swap(this, i, i + 3);
5604
- swap(this, i + 1, i + 2);
5605
- }
5606
- return this
5607
- };
5608
-
5609
- Buffer.prototype.swap64 = function swap64 () {
5610
- var len = this.length;
5611
- if (len % 8 !== 0) {
5612
- throw new RangeError('Buffer size must be a multiple of 64-bits')
5613
- }
5614
- for (var i = 0; i < len; i += 8) {
5615
- swap(this, i, i + 7);
5616
- swap(this, i + 1, i + 6);
5617
- swap(this, i + 2, i + 5);
5618
- swap(this, i + 3, i + 4);
5619
- }
5620
- return this
5621
- };
5622
-
5623
- Buffer.prototype.toString = function toString () {
5624
- var length = this.length | 0;
5625
- if (length === 0) return ''
5626
- if (arguments.length === 0) return utf8Slice(this, 0, length)
5627
- return slowToString.apply(this, arguments)
5628
- };
5629
-
5630
- Buffer.prototype.equals = function equals (b) {
5631
- if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
5632
- if (this === b) return true
5633
- return Buffer.compare(this, b) === 0
5634
- };
5635
-
5636
- Buffer.prototype.inspect = function inspect () {
5637
- var str = '';
5638
- var max = INSPECT_MAX_BYTES;
5639
- if (this.length > 0) {
5640
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
5641
- if (this.length > max) str += ' ... ';
5642
- }
5643
- return '<Buffer ' + str + '>'
5644
- };
5645
-
5646
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
5647
- if (!internalIsBuffer(target)) {
5648
- throw new TypeError('Argument must be a Buffer')
5649
- }
5650
-
5651
- if (start === undefined) {
5652
- start = 0;
5653
- }
5654
- if (end === undefined) {
5655
- end = target ? target.length : 0;
5656
- }
5657
- if (thisStart === undefined) {
5658
- thisStart = 0;
5659
- }
5660
- if (thisEnd === undefined) {
5661
- thisEnd = this.length;
5662
- }
5663
-
5664
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
5665
- throw new RangeError('out of range index')
5666
- }
5667
-
5668
- if (thisStart >= thisEnd && start >= end) {
5669
- return 0
5670
- }
5671
- if (thisStart >= thisEnd) {
5672
- return -1
5673
- }
5674
- if (start >= end) {
5675
- return 1
5676
- }
5677
-
5678
- start >>>= 0;
5679
- end >>>= 0;
5680
- thisStart >>>= 0;
5681
- thisEnd >>>= 0;
5682
-
5683
- if (this === target) return 0
5684
-
5685
- var x = thisEnd - thisStart;
5686
- var y = end - start;
5687
- var len = Math.min(x, y);
5688
-
5689
- var thisCopy = this.slice(thisStart, thisEnd);
5690
- var targetCopy = target.slice(start, end);
5691
-
5692
- for (var i = 0; i < len; ++i) {
5693
- if (thisCopy[i] !== targetCopy[i]) {
5694
- x = thisCopy[i];
5695
- y = targetCopy[i];
5696
- break
5697
- }
5698
- }
5699
-
5700
- if (x < y) return -1
5701
- if (y < x) return 1
5702
- return 0
5703
- };
5704
-
5705
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
5706
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
5707
- //
5708
- // Arguments:
5709
- // - buffer - a Buffer to search
5710
- // - val - a string, Buffer, or number
5711
- // - byteOffset - an index into `buffer`; will be clamped to an int32
5712
- // - encoding - an optional encoding, relevant is val is a string
5713
- // - dir - true for indexOf, false for lastIndexOf
5714
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
5715
- // Empty buffer means no match
5716
- if (buffer.length === 0) return -1
5717
-
5718
- // Normalize byteOffset
5719
- if (typeof byteOffset === 'string') {
5720
- encoding = byteOffset;
5721
- byteOffset = 0;
5722
- } else if (byteOffset > 0x7fffffff) {
5723
- byteOffset = 0x7fffffff;
5724
- } else if (byteOffset < -0x80000000) {
5725
- byteOffset = -0x80000000;
5726
- }
5727
- byteOffset = +byteOffset; // Coerce to Number.
5728
- if (isNaN(byteOffset)) {
5729
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
5730
- byteOffset = dir ? 0 : (buffer.length - 1);
5731
- }
5732
-
5733
- // Normalize byteOffset: negative offsets start from the end of the buffer
5734
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
5735
- if (byteOffset >= buffer.length) {
5736
- if (dir) return -1
5737
- else byteOffset = buffer.length - 1;
5738
- } else if (byteOffset < 0) {
5739
- if (dir) byteOffset = 0;
5740
- else return -1
5741
- }
5742
-
5743
- // Normalize val
5744
- if (typeof val === 'string') {
5745
- val = Buffer.from(val, encoding);
5746
- }
5747
-
5748
- // Finally, search either indexOf (if dir is true) or lastIndexOf
5749
- if (internalIsBuffer(val)) {
5750
- // Special case: looking for empty string/buffer always fails
5751
- if (val.length === 0) {
5752
- return -1
5753
- }
5754
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
5755
- } else if (typeof val === 'number') {
5756
- val = val & 0xFF; // Search for a byte value [0-255]
5757
- if (Buffer.TYPED_ARRAY_SUPPORT &&
5758
- typeof Uint8Array.prototype.indexOf === 'function') {
5759
- if (dir) {
5760
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
5761
- } else {
5762
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
5763
- }
5764
- }
5765
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
5766
- }
5767
-
5768
- throw new TypeError('val must be string, number or Buffer')
5769
- }
5770
-
5771
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
5772
- var indexSize = 1;
5773
- var arrLength = arr.length;
5774
- var valLength = val.length;
5775
-
5776
- if (encoding !== undefined) {
5777
- encoding = String(encoding).toLowerCase();
5778
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
5779
- encoding === 'utf16le' || encoding === 'utf-16le') {
5780
- if (arr.length < 2 || val.length < 2) {
5781
- return -1
5782
- }
5783
- indexSize = 2;
5784
- arrLength /= 2;
5785
- valLength /= 2;
5786
- byteOffset /= 2;
5787
- }
5788
- }
5789
-
5790
- function read (buf, i) {
5791
- if (indexSize === 1) {
5792
- return buf[i]
5793
- } else {
5794
- return buf.readUInt16BE(i * indexSize)
5795
- }
5796
- }
5797
-
5798
- var i;
5799
- if (dir) {
5800
- var foundIndex = -1;
5801
- for (i = byteOffset; i < arrLength; i++) {
5802
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
5803
- if (foundIndex === -1) foundIndex = i;
5804
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
5805
- } else {
5806
- if (foundIndex !== -1) i -= i - foundIndex;
5807
- foundIndex = -1;
5808
- }
5809
- }
5810
- } else {
5811
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
5812
- for (i = byteOffset; i >= 0; i--) {
5813
- var found = true;
5814
- for (var j = 0; j < valLength; j++) {
5815
- if (read(arr, i + j) !== read(val, j)) {
5816
- found = false;
5817
- break
5818
- }
5819
- }
5820
- if (found) return i
5821
- }
5822
- }
5823
-
5824
- return -1
5825
- }
5826
-
5827
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
5828
- return this.indexOf(val, byteOffset, encoding) !== -1
5829
- };
5830
-
5831
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
5832
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
5833
- };
5834
-
5835
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
5836
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
5837
- };
5838
-
5839
- function hexWrite (buf, string, offset, length) {
5840
- offset = Number(offset) || 0;
5841
- var remaining = buf.length - offset;
5842
- if (!length) {
5843
- length = remaining;
5844
- } else {
5845
- length = Number(length);
5846
- if (length > remaining) {
5847
- length = remaining;
5848
- }
5849
- }
5850
-
5851
- // must be an even number of digits
5852
- var strLen = string.length;
5853
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
5854
-
5855
- if (length > strLen / 2) {
5856
- length = strLen / 2;
5857
- }
5858
- for (var i = 0; i < length; ++i) {
5859
- var parsed = parseInt(string.substr(i * 2, 2), 16);
5860
- if (isNaN(parsed)) return i
5861
- buf[offset + i] = parsed;
5862
- }
5863
- return i
5864
- }
5865
-
5866
- function utf8Write (buf, string, offset, length) {
5867
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
5868
- }
5869
-
5870
- function asciiWrite (buf, string, offset, length) {
5871
- return blitBuffer(asciiToBytes(string), buf, offset, length)
5872
- }
5873
-
5874
- function latin1Write (buf, string, offset, length) {
5875
- return asciiWrite(buf, string, offset, length)
5876
- }
5877
-
5878
- function base64Write (buf, string, offset, length) {
5879
- return blitBuffer(base64ToBytes(string), buf, offset, length)
5880
- }
5881
-
5882
- function ucs2Write (buf, string, offset, length) {
5883
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
5884
- }
5885
-
5886
- Buffer.prototype.write = function write (string, offset, length, encoding) {
5887
- // Buffer#write(string)
5888
- if (offset === undefined) {
5889
- encoding = 'utf8';
5890
- length = this.length;
5891
- offset = 0;
5892
- // Buffer#write(string, encoding)
5893
- } else if (length === undefined && typeof offset === 'string') {
5894
- encoding = offset;
5895
- length = this.length;
5896
- offset = 0;
5897
- // Buffer#write(string, offset[, length][, encoding])
5898
- } else if (isFinite(offset)) {
5899
- offset = offset | 0;
5900
- if (isFinite(length)) {
5901
- length = length | 0;
5902
- if (encoding === undefined) encoding = 'utf8';
5903
- } else {
5904
- encoding = length;
5905
- length = undefined;
5906
- }
5907
- // legacy write(string, encoding, offset, length) - remove in v0.13
5908
- } else {
5909
- throw new Error(
5910
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
5911
- )
5912
- }
5913
-
5914
- var remaining = this.length - offset;
5915
- if (length === undefined || length > remaining) length = remaining;
5916
-
5917
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
5918
- throw new RangeError('Attempt to write outside buffer bounds')
5919
- }
5920
-
5921
- if (!encoding) encoding = 'utf8';
5922
-
5923
- var loweredCase = false;
5924
- for (;;) {
5925
- switch (encoding) {
5926
- case 'hex':
5927
- return hexWrite(this, string, offset, length)
5928
-
5929
- case 'utf8':
5930
- case 'utf-8':
5931
- return utf8Write(this, string, offset, length)
5932
-
5933
- case 'ascii':
5934
- return asciiWrite(this, string, offset, length)
5935
-
5936
- case 'latin1':
5937
- case 'binary':
5938
- return latin1Write(this, string, offset, length)
5939
-
5940
- case 'base64':
5941
- // Warning: maxLength not taken into account in base64Write
5942
- return base64Write(this, string, offset, length)
5943
-
5944
- case 'ucs2':
5945
- case 'ucs-2':
5946
- case 'utf16le':
5947
- case 'utf-16le':
5948
- return ucs2Write(this, string, offset, length)
5949
-
5950
- default:
5951
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
5952
- encoding = ('' + encoding).toLowerCase();
5953
- loweredCase = true;
5954
- }
5955
- }
5956
- };
5957
-
5958
- Buffer.prototype.toJSON = function toJSON () {
5959
- return {
5960
- type: 'Buffer',
5961
- data: Array.prototype.slice.call(this._arr || this, 0)
5962
- }
5963
- };
5964
-
5965
- function base64Slice (buf, start, end) {
5966
- if (start === 0 && end === buf.length) {
5967
- return fromByteArray(buf)
5968
- } else {
5969
- return fromByteArray(buf.slice(start, end))
5970
- }
5971
- }
5972
-
5973
- function utf8Slice (buf, start, end) {
5974
- end = Math.min(buf.length, end);
5975
- var res = [];
5976
-
5977
- var i = start;
5978
- while (i < end) {
5979
- var firstByte = buf[i];
5980
- var codePoint = null;
5981
- var bytesPerSequence = (firstByte > 0xEF) ? 4
5982
- : (firstByte > 0xDF) ? 3
5983
- : (firstByte > 0xBF) ? 2
5984
- : 1;
5985
-
5986
- if (i + bytesPerSequence <= end) {
5987
- var secondByte, thirdByte, fourthByte, tempCodePoint;
5988
-
5989
- switch (bytesPerSequence) {
5990
- case 1:
5991
- if (firstByte < 0x80) {
5992
- codePoint = firstByte;
5993
- }
5994
- break
5995
- case 2:
5996
- secondByte = buf[i + 1];
5997
- if ((secondByte & 0xC0) === 0x80) {
5998
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
5999
- if (tempCodePoint > 0x7F) {
6000
- codePoint = tempCodePoint;
6001
- }
6002
- }
6003
- break
6004
- case 3:
6005
- secondByte = buf[i + 1];
6006
- thirdByte = buf[i + 2];
6007
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
6008
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
6009
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
6010
- codePoint = tempCodePoint;
6011
- }
6012
- }
6013
- break
6014
- case 4:
6015
- secondByte = buf[i + 1];
6016
- thirdByte = buf[i + 2];
6017
- fourthByte = buf[i + 3];
6018
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
6019
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
6020
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
6021
- codePoint = tempCodePoint;
6022
- }
6023
- }
6024
- }
6025
- }
6026
-
6027
- if (codePoint === null) {
6028
- // we did not generate a valid codePoint so insert a
6029
- // replacement char (U+FFFD) and advance only 1 byte
6030
- codePoint = 0xFFFD;
6031
- bytesPerSequence = 1;
6032
- } else if (codePoint > 0xFFFF) {
6033
- // encode to utf16 (surrogate pair dance)
6034
- codePoint -= 0x10000;
6035
- res.push(codePoint >>> 10 & 0x3FF | 0xD800);
6036
- codePoint = 0xDC00 | codePoint & 0x3FF;
6037
- }
6038
-
6039
- res.push(codePoint);
6040
- i += bytesPerSequence;
6041
- }
6042
-
6043
- return decodeCodePointsArray(res)
6044
- }
6045
-
6046
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
6047
- // the lowest limit is Chrome, with 0x10000 args.
6048
- // We go 1 magnitude less, for safety
6049
- var MAX_ARGUMENTS_LENGTH = 0x1000;
6050
-
6051
- function decodeCodePointsArray (codePoints) {
6052
- var len = codePoints.length;
6053
- if (len <= MAX_ARGUMENTS_LENGTH) {
6054
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
6055
- }
6056
-
6057
- // Decode in chunks to avoid "call stack size exceeded".
6058
- var res = '';
6059
- var i = 0;
6060
- while (i < len) {
6061
- res += String.fromCharCode.apply(
6062
- String,
6063
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
6064
- );
6065
- }
6066
- return res
6067
- }
6068
-
6069
- function asciiSlice (buf, start, end) {
6070
- var ret = '';
6071
- end = Math.min(buf.length, end);
6072
-
6073
- for (var i = start; i < end; ++i) {
6074
- ret += String.fromCharCode(buf[i] & 0x7F);
6075
- }
6076
- return ret
6077
- }
6078
-
6079
- function latin1Slice (buf, start, end) {
6080
- var ret = '';
6081
- end = Math.min(buf.length, end);
6082
-
6083
- for (var i = start; i < end; ++i) {
6084
- ret += String.fromCharCode(buf[i]);
6085
- }
6086
- return ret
6087
- }
6088
-
6089
- function hexSlice (buf, start, end) {
6090
- var len = buf.length;
6091
-
6092
- if (!start || start < 0) start = 0;
6093
- if (!end || end < 0 || end > len) end = len;
6094
-
6095
- var out = '';
6096
- for (var i = start; i < end; ++i) {
6097
- out += toHex(buf[i]);
6098
- }
6099
- return out
6100
- }
6101
-
6102
- function utf16leSlice (buf, start, end) {
6103
- var bytes = buf.slice(start, end);
6104
- var res = '';
6105
- for (var i = 0; i < bytes.length; i += 2) {
6106
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
6107
- }
6108
- return res
6109
- }
6110
-
6111
- Buffer.prototype.slice = function slice (start, end) {
6112
- var len = this.length;
6113
- start = ~~start;
6114
- end = end === undefined ? len : ~~end;
6115
-
6116
- if (start < 0) {
6117
- start += len;
6118
- if (start < 0) start = 0;
6119
- } else if (start > len) {
6120
- start = len;
6121
- }
6122
-
6123
- if (end < 0) {
6124
- end += len;
6125
- if (end < 0) end = 0;
6126
- } else if (end > len) {
6127
- end = len;
6128
- }
6129
-
6130
- if (end < start) end = start;
6131
-
6132
- var newBuf;
6133
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6134
- newBuf = this.subarray(start, end);
6135
- newBuf.__proto__ = Buffer.prototype;
6136
- } else {
6137
- var sliceLen = end - start;
6138
- newBuf = new Buffer(sliceLen, undefined);
6139
- for (var i = 0; i < sliceLen; ++i) {
6140
- newBuf[i] = this[i + start];
6141
- }
6142
- }
6143
-
6144
- return newBuf
6145
- };
6146
-
6147
- /*
6148
- * Need to make sure that buffer isn't trying to write out of bounds.
6149
- */
6150
- function checkOffset (offset, ext, length) {
6151
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
6152
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
6153
- }
6154
-
6155
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
6156
- offset = offset | 0;
6157
- byteLength = byteLength | 0;
6158
- if (!noAssert) checkOffset(offset, byteLength, this.length);
6159
-
6160
- var val = this[offset];
6161
- var mul = 1;
6162
- var i = 0;
6163
- while (++i < byteLength && (mul *= 0x100)) {
6164
- val += this[offset + i] * mul;
6165
- }
6166
-
6167
- return val
6168
- };
6169
-
6170
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
6171
- offset = offset | 0;
6172
- byteLength = byteLength | 0;
6173
- if (!noAssert) {
6174
- checkOffset(offset, byteLength, this.length);
6175
- }
6176
-
6177
- var val = this[offset + --byteLength];
6178
- var mul = 1;
6179
- while (byteLength > 0 && (mul *= 0x100)) {
6180
- val += this[offset + --byteLength] * mul;
6181
- }
6182
-
6183
- return val
6184
- };
6185
-
6186
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
6187
- if (!noAssert) checkOffset(offset, 1, this.length);
6188
- return this[offset]
6189
- };
6190
-
6191
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
6192
- if (!noAssert) checkOffset(offset, 2, this.length);
6193
- return this[offset] | (this[offset + 1] << 8)
6194
- };
6195
-
6196
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
6197
- if (!noAssert) checkOffset(offset, 2, this.length);
6198
- return (this[offset] << 8) | this[offset + 1]
6199
- };
6200
-
6201
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
6202
- if (!noAssert) checkOffset(offset, 4, this.length);
6203
-
6204
- return ((this[offset]) |
6205
- (this[offset + 1] << 8) |
6206
- (this[offset + 2] << 16)) +
6207
- (this[offset + 3] * 0x1000000)
6208
- };
6209
-
6210
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
6211
- if (!noAssert) checkOffset(offset, 4, this.length);
6212
-
6213
- return (this[offset] * 0x1000000) +
6214
- ((this[offset + 1] << 16) |
6215
- (this[offset + 2] << 8) |
6216
- this[offset + 3])
6217
- };
6218
-
6219
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
6220
- offset = offset | 0;
6221
- byteLength = byteLength | 0;
6222
- if (!noAssert) checkOffset(offset, byteLength, this.length);
6223
-
6224
- var val = this[offset];
6225
- var mul = 1;
6226
- var i = 0;
6227
- while (++i < byteLength && (mul *= 0x100)) {
6228
- val += this[offset + i] * mul;
6229
- }
6230
- mul *= 0x80;
6231
-
6232
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
6233
-
6234
- return val
6235
- };
6236
-
6237
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
6238
- offset = offset | 0;
6239
- byteLength = byteLength | 0;
6240
- if (!noAssert) checkOffset(offset, byteLength, this.length);
6241
-
6242
- var i = byteLength;
6243
- var mul = 1;
6244
- var val = this[offset + --i];
6245
- while (i > 0 && (mul *= 0x100)) {
6246
- val += this[offset + --i] * mul;
6247
- }
6248
- mul *= 0x80;
6249
-
6250
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
6251
-
6252
- return val
6253
- };
6254
-
6255
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
6256
- if (!noAssert) checkOffset(offset, 1, this.length);
6257
- if (!(this[offset] & 0x80)) return (this[offset])
6258
- return ((0xff - this[offset] + 1) * -1)
6259
- };
6260
-
6261
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
6262
- if (!noAssert) checkOffset(offset, 2, this.length);
6263
- var val = this[offset] | (this[offset + 1] << 8);
6264
- return (val & 0x8000) ? val | 0xFFFF0000 : val
6265
- };
6266
-
6267
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
6268
- if (!noAssert) checkOffset(offset, 2, this.length);
6269
- var val = this[offset + 1] | (this[offset] << 8);
6270
- return (val & 0x8000) ? val | 0xFFFF0000 : val
6271
- };
6272
-
6273
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
6274
- if (!noAssert) checkOffset(offset, 4, this.length);
6275
-
6276
- return (this[offset]) |
6277
- (this[offset + 1] << 8) |
6278
- (this[offset + 2] << 16) |
6279
- (this[offset + 3] << 24)
6280
- };
6281
-
6282
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
6283
- if (!noAssert) checkOffset(offset, 4, this.length);
6284
-
6285
- return (this[offset] << 24) |
6286
- (this[offset + 1] << 16) |
6287
- (this[offset + 2] << 8) |
6288
- (this[offset + 3])
6289
- };
6290
-
6291
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
6292
- if (!noAssert) checkOffset(offset, 4, this.length);
6293
- return read(this, offset, true, 23, 4)
6294
- };
6295
-
6296
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
6297
- if (!noAssert) checkOffset(offset, 4, this.length);
6298
- return read(this, offset, false, 23, 4)
6299
- };
6300
-
6301
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
6302
- if (!noAssert) checkOffset(offset, 8, this.length);
6303
- return read(this, offset, true, 52, 8)
6304
- };
6305
-
6306
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
6307
- if (!noAssert) checkOffset(offset, 8, this.length);
6308
- return read(this, offset, false, 52, 8)
6309
- };
6310
-
6311
- function checkInt (buf, value, offset, ext, max, min) {
6312
- if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
6313
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
6314
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
6315
- }
6316
-
6317
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
6318
- value = +value;
6319
- offset = offset | 0;
6320
- byteLength = byteLength | 0;
6321
- if (!noAssert) {
6322
- var maxBytes = Math.pow(2, 8 * byteLength) - 1;
6323
- checkInt(this, value, offset, byteLength, maxBytes, 0);
6324
- }
6325
-
6326
- var mul = 1;
6327
- var i = 0;
6328
- this[offset] = value & 0xFF;
6329
- while (++i < byteLength && (mul *= 0x100)) {
6330
- this[offset + i] = (value / mul) & 0xFF;
6331
- }
6332
-
6333
- return offset + byteLength
6334
- };
6335
-
6336
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
6337
- value = +value;
6338
- offset = offset | 0;
6339
- byteLength = byteLength | 0;
6340
- if (!noAssert) {
6341
- var maxBytes = Math.pow(2, 8 * byteLength) - 1;
6342
- checkInt(this, value, offset, byteLength, maxBytes, 0);
6343
- }
6344
-
6345
- var i = byteLength - 1;
6346
- var mul = 1;
6347
- this[offset + i] = value & 0xFF;
6348
- while (--i >= 0 && (mul *= 0x100)) {
6349
- this[offset + i] = (value / mul) & 0xFF;
6350
- }
6351
-
6352
- return offset + byteLength
6353
- };
6354
-
6355
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
6356
- value = +value;
6357
- offset = offset | 0;
6358
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
6359
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
6360
- this[offset] = (value & 0xff);
6361
- return offset + 1
6362
- };
6363
-
6364
- function objectWriteUInt16 (buf, value, offset, littleEndian) {
6365
- if (value < 0) value = 0xffff + value + 1;
6366
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
6367
- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
6368
- (littleEndian ? i : 1 - i) * 8;
6369
- }
6370
- }
6371
-
6372
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
6373
- value = +value;
6374
- offset = offset | 0;
6375
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
6376
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6377
- this[offset] = (value & 0xff);
6378
- this[offset + 1] = (value >>> 8);
6379
- } else {
6380
- objectWriteUInt16(this, value, offset, true);
6381
- }
6382
- return offset + 2
6383
- };
6384
-
6385
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
6386
- value = +value;
6387
- offset = offset | 0;
6388
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
6389
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6390
- this[offset] = (value >>> 8);
6391
- this[offset + 1] = (value & 0xff);
6392
- } else {
6393
- objectWriteUInt16(this, value, offset, false);
6394
- }
6395
- return offset + 2
6396
- };
6397
-
6398
- function objectWriteUInt32 (buf, value, offset, littleEndian) {
6399
- if (value < 0) value = 0xffffffff + value + 1;
6400
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
6401
- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
6402
- }
6403
- }
6404
-
6405
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
6406
- value = +value;
6407
- offset = offset | 0;
6408
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
6409
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6410
- this[offset + 3] = (value >>> 24);
6411
- this[offset + 2] = (value >>> 16);
6412
- this[offset + 1] = (value >>> 8);
6413
- this[offset] = (value & 0xff);
6414
- } else {
6415
- objectWriteUInt32(this, value, offset, true);
6416
- }
6417
- return offset + 4
6418
- };
6419
-
6420
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
6421
- value = +value;
6422
- offset = offset | 0;
6423
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
6424
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6425
- this[offset] = (value >>> 24);
6426
- this[offset + 1] = (value >>> 16);
6427
- this[offset + 2] = (value >>> 8);
6428
- this[offset + 3] = (value & 0xff);
6429
- } else {
6430
- objectWriteUInt32(this, value, offset, false);
6431
- }
6432
- return offset + 4
6433
- };
6434
-
6435
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
6436
- value = +value;
6437
- offset = offset | 0;
6438
- if (!noAssert) {
6439
- var limit = Math.pow(2, 8 * byteLength - 1);
6440
-
6441
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
6442
- }
6443
-
6444
- var i = 0;
6445
- var mul = 1;
6446
- var sub = 0;
6447
- this[offset] = value & 0xFF;
6448
- while (++i < byteLength && (mul *= 0x100)) {
6449
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
6450
- sub = 1;
6451
- }
6452
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
6453
- }
6454
-
6455
- return offset + byteLength
6456
- };
6457
-
6458
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
6459
- value = +value;
6460
- offset = offset | 0;
6461
- if (!noAssert) {
6462
- var limit = Math.pow(2, 8 * byteLength - 1);
6463
-
6464
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
6465
- }
6466
-
6467
- var i = byteLength - 1;
6468
- var mul = 1;
6469
- var sub = 0;
6470
- this[offset + i] = value & 0xFF;
6471
- while (--i >= 0 && (mul *= 0x100)) {
6472
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
6473
- sub = 1;
6474
- }
6475
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
6476
- }
6477
-
6478
- return offset + byteLength
6479
- };
6480
-
6481
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
6482
- value = +value;
6483
- offset = offset | 0;
6484
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
6485
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
6486
- if (value < 0) value = 0xff + value + 1;
6487
- this[offset] = (value & 0xff);
6488
- return offset + 1
6489
- };
6490
-
6491
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
6492
- value = +value;
6493
- offset = offset | 0;
6494
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
6495
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6496
- this[offset] = (value & 0xff);
6497
- this[offset + 1] = (value >>> 8);
6498
- } else {
6499
- objectWriteUInt16(this, value, offset, true);
6500
- }
6501
- return offset + 2
6502
- };
6503
-
6504
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
6505
- value = +value;
6506
- offset = offset | 0;
6507
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
6508
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6509
- this[offset] = (value >>> 8);
6510
- this[offset + 1] = (value & 0xff);
6511
- } else {
6512
- objectWriteUInt16(this, value, offset, false);
6513
- }
6514
- return offset + 2
6515
- };
6516
-
6517
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
6518
- value = +value;
6519
- offset = offset | 0;
6520
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
6521
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6522
- this[offset] = (value & 0xff);
6523
- this[offset + 1] = (value >>> 8);
6524
- this[offset + 2] = (value >>> 16);
6525
- this[offset + 3] = (value >>> 24);
6526
- } else {
6527
- objectWriteUInt32(this, value, offset, true);
6528
- }
6529
- return offset + 4
6530
- };
6531
-
6532
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
6533
- value = +value;
6534
- offset = offset | 0;
6535
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
6536
- if (value < 0) value = 0xffffffff + value + 1;
6537
- if (Buffer.TYPED_ARRAY_SUPPORT) {
6538
- this[offset] = (value >>> 24);
6539
- this[offset + 1] = (value >>> 16);
6540
- this[offset + 2] = (value >>> 8);
6541
- this[offset + 3] = (value & 0xff);
6542
- } else {
6543
- objectWriteUInt32(this, value, offset, false);
6544
- }
6545
- return offset + 4
6546
- };
6547
-
6548
- function checkIEEE754 (buf, value, offset, ext, max, min) {
6549
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
6550
- if (offset < 0) throw new RangeError('Index out of range')
6551
- }
6552
-
6553
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
6554
- if (!noAssert) {
6555
- checkIEEE754(buf, value, offset, 4);
6556
- }
6557
- write(buf, value, offset, littleEndian, 23, 4);
6558
- return offset + 4
6559
- }
6560
-
6561
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
6562
- return writeFloat(this, value, offset, true, noAssert)
6563
- };
6564
-
6565
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
6566
- return writeFloat(this, value, offset, false, noAssert)
6567
- };
6568
-
6569
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
6570
- if (!noAssert) {
6571
- checkIEEE754(buf, value, offset, 8);
6572
- }
6573
- write(buf, value, offset, littleEndian, 52, 8);
6574
- return offset + 8
6575
- }
6576
-
6577
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
6578
- return writeDouble(this, value, offset, true, noAssert)
6579
- };
6580
-
6581
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
6582
- return writeDouble(this, value, offset, false, noAssert)
6583
- };
6584
-
6585
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
6586
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
6587
- if (!start) start = 0;
6588
- if (!end && end !== 0) end = this.length;
6589
- if (targetStart >= target.length) targetStart = target.length;
6590
- if (!targetStart) targetStart = 0;
6591
- if (end > 0 && end < start) end = start;
6592
-
6593
- // Copy 0 bytes; we're done
6594
- if (end === start) return 0
6595
- if (target.length === 0 || this.length === 0) return 0
6596
-
6597
- // Fatal error conditions
6598
- if (targetStart < 0) {
6599
- throw new RangeError('targetStart out of bounds')
6600
- }
6601
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
6602
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
6603
-
6604
- // Are we oob?
6605
- if (end > this.length) end = this.length;
6606
- if (target.length - targetStart < end - start) {
6607
- end = target.length - targetStart + start;
6608
- }
6609
-
6610
- var len = end - start;
6611
- var i;
6612
-
6613
- if (this === target && start < targetStart && targetStart < end) {
6614
- // descending copy from end
6615
- for (i = len - 1; i >= 0; --i) {
6616
- target[i + targetStart] = this[i + start];
6617
- }
6618
- } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
6619
- // ascending copy from start
6620
- for (i = 0; i < len; ++i) {
6621
- target[i + targetStart] = this[i + start];
6622
- }
6623
- } else {
6624
- Uint8Array.prototype.set.call(
6625
- target,
6626
- this.subarray(start, start + len),
6627
- targetStart
6628
- );
6629
- }
6630
-
6631
- return len
6632
- };
6633
-
6634
- // Usage:
6635
- // buffer.fill(number[, offset[, end]])
6636
- // buffer.fill(buffer[, offset[, end]])
6637
- // buffer.fill(string[, offset[, end]][, encoding])
6638
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
6639
- // Handle string cases:
6640
- if (typeof val === 'string') {
6641
- if (typeof start === 'string') {
6642
- encoding = start;
6643
- start = 0;
6644
- end = this.length;
6645
- } else if (typeof end === 'string') {
6646
- encoding = end;
6647
- end = this.length;
6648
- }
6649
- if (val.length === 1) {
6650
- var code = val.charCodeAt(0);
6651
- if (code < 256) {
6652
- val = code;
6653
- }
6654
- }
6655
- if (encoding !== undefined && typeof encoding !== 'string') {
6656
- throw new TypeError('encoding must be a string')
6657
- }
6658
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
6659
- throw new TypeError('Unknown encoding: ' + encoding)
6660
- }
6661
- } else if (typeof val === 'number') {
6662
- val = val & 255;
6663
- }
6664
-
6665
- // Invalid ranges are not set to a default, so can range check early.
6666
- if (start < 0 || this.length < start || this.length < end) {
6667
- throw new RangeError('Out of range index')
6668
- }
6669
-
6670
- if (end <= start) {
6671
- return this
6672
- }
6673
-
6674
- start = start >>> 0;
6675
- end = end === undefined ? this.length : end >>> 0;
6676
-
6677
- if (!val) val = 0;
6678
-
6679
- var i;
6680
- if (typeof val === 'number') {
6681
- for (i = start; i < end; ++i) {
6682
- this[i] = val;
6683
- }
6684
- } else {
6685
- var bytes = internalIsBuffer(val)
6686
- ? val
6687
- : utf8ToBytes(new Buffer(val, encoding).toString());
6688
- var len = bytes.length;
6689
- for (i = 0; i < end - start; ++i) {
6690
- this[i + start] = bytes[i % len];
6691
- }
6692
- }
6693
-
6694
- return this
6695
- };
6696
-
6697
- // HELPER FUNCTIONS
6698
- // ================
6699
-
6700
- var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
6701
-
6702
- function base64clean (str) {
6703
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
6704
- str = stringtrim(str).replace(INVALID_BASE64_RE, '');
6705
- // Node converts strings with length < 2 to ''
6706
- if (str.length < 2) return ''
6707
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
6708
- while (str.length % 4 !== 0) {
6709
- str = str + '=';
6710
- }
6711
- return str
6712
- }
6713
-
6714
- function stringtrim (str) {
6715
- if (str.trim) return str.trim()
6716
- return str.replace(/^\s+|\s+$/g, '')
6717
- }
6718
-
6719
- function toHex (n) {
6720
- if (n < 16) return '0' + n.toString(16)
6721
- return n.toString(16)
6722
- }
6723
-
6724
- function utf8ToBytes (string, units) {
6725
- units = units || Infinity;
6726
- var codePoint;
6727
- var length = string.length;
6728
- var leadSurrogate = null;
6729
- var bytes = [];
6730
-
6731
- for (var i = 0; i < length; ++i) {
6732
- codePoint = string.charCodeAt(i);
6733
-
6734
- // is surrogate component
6735
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
6736
- // last char was a lead
6737
- if (!leadSurrogate) {
6738
- // no lead yet
6739
- if (codePoint > 0xDBFF) {
6740
- // unexpected trail
6741
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
6742
- continue
6743
- } else if (i + 1 === length) {
6744
- // unpaired lead
6745
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
6746
- continue
6747
- }
6748
-
6749
- // valid lead
6750
- leadSurrogate = codePoint;
6751
-
6752
- continue
6753
- }
6754
-
6755
- // 2 leads in a row
6756
- if (codePoint < 0xDC00) {
6757
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
6758
- leadSurrogate = codePoint;
6759
- continue
6760
- }
6761
-
6762
- // valid surrogate pair
6763
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
6764
- } else if (leadSurrogate) {
6765
- // valid bmp char, but last char was a lead
6766
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
6767
- }
6768
-
6769
- leadSurrogate = null;
6770
-
6771
- // encode utf8
6772
- if (codePoint < 0x80) {
6773
- if ((units -= 1) < 0) break
6774
- bytes.push(codePoint);
6775
- } else if (codePoint < 0x800) {
6776
- if ((units -= 2) < 0) break
6777
- bytes.push(
6778
- codePoint >> 0x6 | 0xC0,
6779
- codePoint & 0x3F | 0x80
6780
- );
6781
- } else if (codePoint < 0x10000) {
6782
- if ((units -= 3) < 0) break
6783
- bytes.push(
6784
- codePoint >> 0xC | 0xE0,
6785
- codePoint >> 0x6 & 0x3F | 0x80,
6786
- codePoint & 0x3F | 0x80
6787
- );
6788
- } else if (codePoint < 0x110000) {
6789
- if ((units -= 4) < 0) break
6790
- bytes.push(
6791
- codePoint >> 0x12 | 0xF0,
6792
- codePoint >> 0xC & 0x3F | 0x80,
6793
- codePoint >> 0x6 & 0x3F | 0x80,
6794
- codePoint & 0x3F | 0x80
6795
- );
6796
- } else {
6797
- throw new Error('Invalid code point')
6798
- }
6799
- }
6800
-
6801
- return bytes
6802
- }
6803
-
6804
- function asciiToBytes (str) {
6805
- var byteArray = [];
6806
- for (var i = 0; i < str.length; ++i) {
6807
- // Node's code seems to be doing this and not & 0x7F..
6808
- byteArray.push(str.charCodeAt(i) & 0xFF);
6809
- }
6810
- return byteArray
6811
- }
6812
-
6813
- function utf16leToBytes (str, units) {
6814
- var c, hi, lo;
6815
- var byteArray = [];
6816
- for (var i = 0; i < str.length; ++i) {
6817
- if ((units -= 2) < 0) break
6818
-
6819
- c = str.charCodeAt(i);
6820
- hi = c >> 8;
6821
- lo = c % 256;
6822
- byteArray.push(lo);
6823
- byteArray.push(hi);
6824
- }
6825
-
6826
- return byteArray
6827
- }
6828
-
6829
-
6830
- function base64ToBytes (str) {
6831
- return toByteArray(base64clean(str))
6832
- }
6833
-
6834
- function blitBuffer (src, dst, offset, length) {
6835
- for (var i = 0; i < length; ++i) {
6836
- if ((i + offset >= dst.length) || (i >= src.length)) break
6837
- dst[i + offset] = src[i];
6838
- }
6839
- return i
6840
- }
6841
-
6842
- function isnan (val) {
6843
- return val !== val // eslint-disable-line no-self-compare
6844
- }
6845
-
6846
-
6847
- // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
6848
- // The _isBuffer check is for Safari 5-7 support, because it's missing
6849
- // Object.prototype.constructor. Remove this eventually
6850
- function isBuffer$1(obj) {
6851
- return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
6852
- }
6853
-
6854
- function isFastBuffer (obj) {
6855
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
6856
- }
6857
-
6858
- // For Node v0.10 support. Remove this eventually.
6859
- function isSlowBuffer (obj) {
6860
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
6861
- }
6862
-
6863
- var inherits;
6864
- if (typeof Object.create === 'function'){
6865
- inherits = function inherits(ctor, superCtor) {
6866
- // implementation from standard node.js 'util' module
6867
- ctor.super_ = superCtor;
6868
- ctor.prototype = Object.create(superCtor.prototype, {
6869
- constructor: {
6870
- value: ctor,
6871
- enumerable: false,
6872
- writable: true,
6873
- configurable: true
6874
- }
6875
- });
6876
- };
6877
- } else {
6878
- inherits = function inherits(ctor, superCtor) {
6879
- ctor.super_ = superCtor;
6880
- var TempCtor = function () {};
6881
- TempCtor.prototype = superCtor.prototype;
6882
- ctor.prototype = new TempCtor();
6883
- ctor.prototype.constructor = ctor;
6884
- };
6885
- }
6886
-
6887
- var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
6888
- function getOwnPropertyDescriptors(obj) {
6889
- var keys = Object.keys(obj);
6890
- var descriptors = {};
6891
- for (var i = 0; i < keys.length; i++) {
6892
- descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
6893
- }
6894
- return descriptors;
6895
- };
6896
-
6897
- var formatRegExp = /%[sdj%]/g;
6898
- function format(f) {
6899
- if (!isString(f)) {
6900
- var objects = [];
6901
- for (var i = 0; i < arguments.length; i++) {
6902
- objects.push(inspect(arguments[i]));
6903
- }
6904
- return objects.join(' ');
6905
- }
6906
-
6907
- var i = 1;
6908
- var args = arguments;
6909
- var len = args.length;
6910
- var str = String(f).replace(formatRegExp, function(x) {
6911
- if (x === '%%') return '%';
6912
- if (i >= len) return x;
6913
- switch (x) {
6914
- case '%s': return String(args[i++]);
6915
- case '%d': return Number(args[i++]);
6916
- case '%j':
6917
- try {
6918
- return JSON.stringify(args[i++]);
6919
- } catch (_) {
6920
- return '[Circular]';
6921
- }
6922
- default:
6923
- return x;
6924
- }
6925
- });
6926
- for (var x = args[i]; i < len; x = args[++i]) {
6927
- if (isNull(x) || !isObject(x)) {
6928
- str += ' ' + x;
6929
- } else {
6930
- str += ' ' + inspect(x);
6931
- }
6932
- }
6933
- return str;
6934
- }
6935
-
6936
- // Mark that a method should not be used.
6937
- // Returns a modified function which warns once by default.
6938
- // If --no-deprecation is set, then it is a no-op.
6939
- function deprecate(fn, msg) {
6940
- // Allow for deprecating things in the process of starting up.
6941
- if (isUndefined(global$1.process)) {
6942
- return function() {
6943
- return deprecate(fn, msg).apply(this, arguments);
6944
- };
6945
- }
6946
-
6947
- if (browser$1$1.noDeprecation === true) {
6948
- return fn;
6949
- }
6950
-
6951
- var warned = false;
6952
- function deprecated() {
6953
- if (!warned) {
6954
- if (browser$1$1.throwDeprecation) {
6955
- throw new Error(msg);
6956
- } else if (browser$1$1.traceDeprecation) {
6957
- console.trace(msg);
6958
- } else {
6959
- console.error(msg);
6960
- }
6961
- warned = true;
6962
- }
6963
- return fn.apply(this, arguments);
6964
- }
6965
-
6966
- return deprecated;
6967
- }
6968
-
6969
- var debugs = {};
6970
- var debugEnviron;
6971
- function debuglog(set) {
6972
- if (isUndefined(debugEnviron))
6973
- debugEnviron = browser$1$1.env.NODE_DEBUG || '';
6974
- set = set.toUpperCase();
6975
- if (!debugs[set]) {
6976
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
6977
- var pid = 0;
6978
- debugs[set] = function() {
6979
- var msg = format.apply(null, arguments);
6980
- console.error('%s %d: %s', set, pid, msg);
6981
- };
6982
- } else {
6983
- debugs[set] = function() {};
6984
- }
6985
- }
6986
- return debugs[set];
6987
- }
6988
-
6989
- /**
6990
- * Echos the value of a value. Trys to print the value out
6991
- * in the best way possible given the different types.
6992
- *
6993
- * @param {Object} obj The object to print out.
6994
- * @param {Object} opts Optional options object that alters the output.
6995
- */
6996
- /* legacy: obj, showHidden, depth, colors*/
6997
- function inspect(obj, opts) {
6998
- // default options
6999
- var ctx = {
7000
- seen: [],
7001
- stylize: stylizeNoColor
7002
- };
7003
- // legacy...
7004
- if (arguments.length >= 3) ctx.depth = arguments[2];
7005
- if (arguments.length >= 4) ctx.colors = arguments[3];
7006
- if (isBoolean(opts)) {
7007
- // legacy...
7008
- ctx.showHidden = opts;
7009
- } else if (opts) {
7010
- // got an "options" object
7011
- _extend(ctx, opts);
7012
- }
7013
- // set default options
7014
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
7015
- if (isUndefined(ctx.depth)) ctx.depth = 2;
7016
- if (isUndefined(ctx.colors)) ctx.colors = false;
7017
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
7018
- if (ctx.colors) ctx.stylize = stylizeWithColor;
7019
- return formatValue(ctx, obj, ctx.depth);
7020
- }
7021
-
7022
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
7023
- inspect.colors = {
7024
- 'bold' : [1, 22],
7025
- 'italic' : [3, 23],
7026
- 'underline' : [4, 24],
7027
- 'inverse' : [7, 27],
7028
- 'white' : [37, 39],
7029
- 'grey' : [90, 39],
7030
- 'black' : [30, 39],
7031
- 'blue' : [34, 39],
7032
- 'cyan' : [36, 39],
7033
- 'green' : [32, 39],
7034
- 'magenta' : [35, 39],
7035
- 'red' : [31, 39],
7036
- 'yellow' : [33, 39]
7037
- };
7038
-
7039
- // Don't use 'blue' not visible on cmd.exe
7040
- inspect.styles = {
7041
- 'special': 'cyan',
7042
- 'number': 'yellow',
7043
- 'boolean': 'yellow',
7044
- 'undefined': 'grey',
7045
- 'null': 'bold',
7046
- 'string': 'green',
7047
- 'date': 'magenta',
7048
- // "name": intentionally not styling
7049
- 'regexp': 'red'
7050
- };
7051
-
7052
-
7053
- function stylizeWithColor(str, styleType) {
7054
- var style = inspect.styles[styleType];
7055
-
7056
- if (style) {
7057
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
7058
- '\u001b[' + inspect.colors[style][1] + 'm';
7059
- } else {
7060
- return str;
7061
- }
7062
- }
7063
-
7064
-
7065
- function stylizeNoColor(str, styleType) {
7066
- return str;
7067
- }
7068
-
7069
-
7070
- function arrayToHash(array) {
7071
- var hash = {};
7072
-
7073
- array.forEach(function(val, idx) {
7074
- hash[val] = true;
7075
- });
7076
-
7077
- return hash;
7078
- }
7079
-
7080
-
7081
- function formatValue(ctx, value, recurseTimes) {
7082
- // Provide a hook for user-specified inspect functions.
7083
- // Check that value is an object with an inspect function on it
7084
- if (ctx.customInspect &&
7085
- value &&
7086
- isFunction(value.inspect) &&
7087
- // Filter out the util module, it's inspect function is special
7088
- value.inspect !== inspect &&
7089
- // Also filter out any prototype objects using the circular check.
7090
- !(value.constructor && value.constructor.prototype === value)) {
7091
- var ret = value.inspect(recurseTimes, ctx);
7092
- if (!isString(ret)) {
7093
- ret = formatValue(ctx, ret, recurseTimes);
7094
- }
7095
- return ret;
7096
- }
7097
-
7098
- // Primitive types cannot have properties
7099
- var primitive = formatPrimitive(ctx, value);
7100
- if (primitive) {
7101
- return primitive;
7102
- }
7103
-
7104
- // Look up the keys of the object.
7105
- var keys = Object.keys(value);
7106
- var visibleKeys = arrayToHash(keys);
7107
-
7108
- if (ctx.showHidden) {
7109
- keys = Object.getOwnPropertyNames(value);
7110
- }
7111
-
7112
- // IE doesn't make error fields non-enumerable
7113
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
7114
- if (isError(value)
7115
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
7116
- return formatError(value);
7117
- }
7118
-
7119
- // Some type of object without properties can be shortcutted.
7120
- if (keys.length === 0) {
7121
- if (isFunction(value)) {
7122
- var name = value.name ? ': ' + value.name : '';
7123
- return ctx.stylize('[Function' + name + ']', 'special');
7124
- }
7125
- if (isRegExp(value)) {
7126
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
7127
- }
7128
- if (isDate(value)) {
7129
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
7130
- }
7131
- if (isError(value)) {
7132
- return formatError(value);
7133
- }
7134
- }
7135
-
7136
- var base = '', array = false, braces = ['{', '}'];
7137
-
7138
- // Make Array say that they are Array
7139
- if (isArray(value)) {
7140
- array = true;
7141
- braces = ['[', ']'];
7142
- }
7143
-
7144
- // Make functions say that they are functions
7145
- if (isFunction(value)) {
7146
- var n = value.name ? ': ' + value.name : '';
7147
- base = ' [Function' + n + ']';
7148
- }
7149
-
7150
- // Make RegExps say that they are RegExps
7151
- if (isRegExp(value)) {
7152
- base = ' ' + RegExp.prototype.toString.call(value);
7153
- }
7154
-
7155
- // Make dates with properties first say the date
7156
- if (isDate(value)) {
7157
- base = ' ' + Date.prototype.toUTCString.call(value);
7158
- }
7159
-
7160
- // Make error with message first say the error
7161
- if (isError(value)) {
7162
- base = ' ' + formatError(value);
7163
- }
7164
-
7165
- if (keys.length === 0 && (!array || value.length == 0)) {
7166
- return braces[0] + base + braces[1];
7167
- }
7168
-
7169
- if (recurseTimes < 0) {
7170
- if (isRegExp(value)) {
7171
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
7172
- } else {
7173
- return ctx.stylize('[Object]', 'special');
7174
- }
7175
- }
7176
-
7177
- ctx.seen.push(value);
7178
-
7179
- var output;
7180
- if (array) {
7181
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
7182
- } else {
7183
- output = keys.map(function(key) {
7184
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
7185
- });
7186
- }
7187
-
7188
- ctx.seen.pop();
7189
-
7190
- return reduceToSingleString(output, base, braces);
7191
- }
7192
-
7193
-
7194
- function formatPrimitive(ctx, value) {
7195
- if (isUndefined(value))
7196
- return ctx.stylize('undefined', 'undefined');
7197
- if (isString(value)) {
7198
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
7199
- .replace(/'/g, "\\'")
7200
- .replace(/\\"/g, '"') + '\'';
7201
- return ctx.stylize(simple, 'string');
7202
- }
7203
- if (isNumber(value))
7204
- return ctx.stylize('' + value, 'number');
7205
- if (isBoolean(value))
7206
- return ctx.stylize('' + value, 'boolean');
7207
- // For some reason typeof null is "object", so special case here.
7208
- if (isNull(value))
7209
- return ctx.stylize('null', 'null');
7210
- }
7211
-
7212
-
7213
- function formatError(value) {
7214
- return '[' + Error.prototype.toString.call(value) + ']';
7215
- }
7216
-
7217
-
7218
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
7219
- var output = [];
7220
- for (var i = 0, l = value.length; i < l; ++i) {
7221
- if (hasOwnProperty(value, String(i))) {
7222
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
7223
- String(i), true));
7224
- } else {
7225
- output.push('');
7226
- }
7227
- }
7228
- keys.forEach(function(key) {
7229
- if (!key.match(/^\d+$/)) {
7230
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
7231
- key, true));
7232
- }
7233
- });
7234
- return output;
7235
- }
7236
-
7237
-
7238
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
7239
- var name, str, desc;
7240
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
7241
- if (desc.get) {
7242
- if (desc.set) {
7243
- str = ctx.stylize('[Getter/Setter]', 'special');
7244
- } else {
7245
- str = ctx.stylize('[Getter]', 'special');
7246
- }
7247
- } else {
7248
- if (desc.set) {
7249
- str = ctx.stylize('[Setter]', 'special');
7250
- }
7251
- }
7252
- if (!hasOwnProperty(visibleKeys, key)) {
7253
- name = '[' + key + ']';
7254
- }
7255
- if (!str) {
7256
- if (ctx.seen.indexOf(desc.value) < 0) {
7257
- if (isNull(recurseTimes)) {
7258
- str = formatValue(ctx, desc.value, null);
7259
- } else {
7260
- str = formatValue(ctx, desc.value, recurseTimes - 1);
7261
- }
7262
- if (str.indexOf('\n') > -1) {
7263
- if (array) {
7264
- str = str.split('\n').map(function(line) {
7265
- return ' ' + line;
7266
- }).join('\n').substr(2);
7267
- } else {
7268
- str = '\n' + str.split('\n').map(function(line) {
7269
- return ' ' + line;
7270
- }).join('\n');
7271
- }
7272
- }
7273
- } else {
7274
- str = ctx.stylize('[Circular]', 'special');
7275
- }
7276
- }
7277
- if (isUndefined(name)) {
7278
- if (array && key.match(/^\d+$/)) {
7279
- return str;
7280
- }
7281
- name = JSON.stringify('' + key);
7282
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
7283
- name = name.substr(1, name.length - 2);
7284
- name = ctx.stylize(name, 'name');
7285
- } else {
7286
- name = name.replace(/'/g, "\\'")
7287
- .replace(/\\"/g, '"')
7288
- .replace(/(^"|"$)/g, "'");
7289
- name = ctx.stylize(name, 'string');
7290
- }
7291
- }
7292
-
7293
- return name + ': ' + str;
7294
- }
7295
-
7296
-
7297
- function reduceToSingleString(output, base, braces) {
7298
- var length = output.reduce(function(prev, cur) {
7299
- if (cur.indexOf('\n') >= 0) ;
7300
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
7301
- }, 0);
7302
-
7303
- if (length > 60) {
7304
- return braces[0] +
7305
- (base === '' ? '' : base + '\n ') +
7306
- ' ' +
7307
- output.join(',\n ') +
7308
- ' ' +
7309
- braces[1];
7310
- }
7311
-
7312
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
7313
- }
7314
-
7315
-
7316
- // NOTE: These type checking functions intentionally don't use `instanceof`
7317
- // because it is fragile and can be easily faked with `Object.create()`.
7318
- function isArray(ar) {
7319
- return Array.isArray(ar);
7320
- }
7321
-
7322
- function isBoolean(arg) {
7323
- return typeof arg === 'boolean';
7324
- }
7325
-
7326
- function isNull(arg) {
7327
- return arg === null;
7328
- }
7329
-
7330
- function isNullOrUndefined(arg) {
7331
- return arg == null;
7332
- }
7333
-
7334
- function isNumber(arg) {
7335
- return typeof arg === 'number';
7336
- }
7337
-
7338
- function isString(arg) {
7339
- return typeof arg === 'string';
7340
- }
7341
-
7342
- function isSymbol(arg) {
7343
- return typeof arg === 'symbol';
7344
- }
7345
-
7346
- function isUndefined(arg) {
7347
- return arg === void 0;
7348
- }
7349
-
7350
- function isRegExp(re) {
7351
- return isObject(re) && objectToString(re) === '[object RegExp]';
7352
- }
7353
-
7354
- function isObject(arg) {
7355
- return typeof arg === 'object' && arg !== null;
7356
- }
7357
-
7358
- function isDate(d) {
7359
- return isObject(d) && objectToString(d) === '[object Date]';
7360
- }
7361
-
7362
- function isError(e) {
7363
- return isObject(e) &&
7364
- (objectToString(e) === '[object Error]' || e instanceof Error);
7365
- }
7366
-
7367
- function isFunction(arg) {
7368
- return typeof arg === 'function';
7369
- }
7370
-
7371
- function isPrimitive(arg) {
7372
- return arg === null ||
7373
- typeof arg === 'boolean' ||
7374
- typeof arg === 'number' ||
7375
- typeof arg === 'string' ||
7376
- typeof arg === 'symbol' || // ES6 symbol
7377
- typeof arg === 'undefined';
7378
- }
7379
-
7380
- function isBuffer(maybeBuf) {
7381
- return Buffer.isBuffer(maybeBuf);
7382
- }
7383
-
7384
- function objectToString(o) {
7385
- return Object.prototype.toString.call(o);
7386
- }
7387
-
7388
-
7389
- function pad(n) {
7390
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
7391
- }
7392
-
7393
-
7394
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
7395
- 'Oct', 'Nov', 'Dec'];
7396
-
7397
- // 26 Feb 16:19:34
7398
- function timestamp() {
7399
- var d = new Date();
7400
- var time = [pad(d.getHours()),
7401
- pad(d.getMinutes()),
7402
- pad(d.getSeconds())].join(':');
7403
- return [d.getDate(), months[d.getMonth()], time].join(' ');
7404
- }
7405
-
7406
-
7407
- // log is just a thin wrapper to console.log that prepends a timestamp
7408
- function log() {
7409
- console.log('%s - %s', timestamp(), format.apply(null, arguments));
7410
- }
7411
-
7412
- function _extend(origin, add) {
7413
- // Don't do anything if add isn't an object
7414
- if (!add || !isObject(add)) return origin;
7415
-
7416
- var keys = Object.keys(add);
7417
- var i = keys.length;
7418
- while (i--) {
7419
- origin[keys[i]] = add[keys[i]];
7420
- }
7421
- return origin;
7422
- }
7423
- function hasOwnProperty(obj, prop) {
7424
- return Object.prototype.hasOwnProperty.call(obj, prop);
7425
- }
7426
-
7427
- var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
7428
-
7429
- function promisify(original) {
7430
- if (typeof original !== 'function')
7431
- throw new TypeError('The "original" argument must be of type Function');
7432
-
7433
- if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
7434
- var fn = original[kCustomPromisifiedSymbol];
7435
- if (typeof fn !== 'function') {
7436
- throw new TypeError('The "util.promisify.custom" argument must be of type Function');
7437
- }
7438
- Object.defineProperty(fn, kCustomPromisifiedSymbol, {
7439
- value: fn, enumerable: false, writable: false, configurable: true
7440
- });
7441
- return fn;
7442
- }
7443
-
7444
- function fn() {
7445
- var promiseResolve, promiseReject;
7446
- var promise = new Promise(function (resolve, reject) {
7447
- promiseResolve = resolve;
7448
- promiseReject = reject;
7449
- });
7450
-
7451
- var args = [];
7452
- for (var i = 0; i < arguments.length; i++) {
7453
- args.push(arguments[i]);
7454
- }
7455
- args.push(function (err, value) {
7456
- if (err) {
7457
- promiseReject(err);
7458
- } else {
7459
- promiseResolve(value);
7460
- }
7461
- });
7462
-
7463
- try {
7464
- original.apply(this, args);
7465
- } catch (err) {
7466
- promiseReject(err);
7467
- }
7468
-
7469
- return promise;
7470
- }
7471
-
7472
- Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
7473
-
7474
- if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
7475
- value: fn, enumerable: false, writable: false, configurable: true
7476
- });
7477
- return Object.defineProperties(
7478
- fn,
7479
- getOwnPropertyDescriptors(original)
7480
- );
7481
- }
7482
-
7483
- promisify.custom = kCustomPromisifiedSymbol;
7484
-
7485
- function callbackifyOnRejected(reason, cb) {
7486
- // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
7487
- // Because `null` is a special error value in callbacks which means "no error
7488
- // occurred", we error-wrap so the callback consumer can distinguish between
7489
- // "the promise rejected with null" or "the promise fulfilled with undefined".
7490
- if (!reason) {
7491
- var newReason = new Error('Promise was rejected with a falsy value');
7492
- newReason.reason = reason;
7493
- reason = newReason;
7494
- }
7495
- return cb(reason);
7496
- }
7497
-
7498
- function callbackify(original) {
7499
- if (typeof original !== 'function') {
7500
- throw new TypeError('The "original" argument must be of type Function');
7501
- }
7502
-
7503
- // We DO NOT return the promise as it gives the user a false sense that
7504
- // the promise is actually somehow related to the callback's execution
7505
- // and that the callback throwing will reject the promise.
7506
- function callbackified() {
7507
- var args = [];
7508
- for (var i = 0; i < arguments.length; i++) {
7509
- args.push(arguments[i]);
7510
- }
7511
-
7512
- var maybeCb = args.pop();
7513
- if (typeof maybeCb !== 'function') {
7514
- throw new TypeError('The last argument must be of type Function');
7515
- }
7516
- var self = this;
7517
- var cb = function() {
7518
- return maybeCb.apply(self, arguments);
7519
- };
7520
- // In true node style we process the callback on `nextTick` with all the
7521
- // implications (stack, `uncaughtException`, `async_hooks`)
7522
- original.apply(this, args)
7523
- .then(function(ret) { browser$1$1.nextTick(cb.bind(null, null, ret)); },
7524
- function(rej) { browser$1$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
7525
- }
7526
-
7527
- Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
7528
- Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
7529
- return callbackified;
7530
- }
7531
-
7532
- const _polyfillNode_util = {
7533
- inherits: inherits,
7534
- _extend: _extend,
7535
- log: log,
7536
- isBuffer: isBuffer,
7537
- isPrimitive: isPrimitive,
7538
- isFunction: isFunction,
7539
- isError: isError,
7540
- isDate: isDate,
7541
- isObject: isObject,
7542
- isRegExp: isRegExp,
7543
- isUndefined: isUndefined,
7544
- isSymbol: isSymbol,
7545
- isString: isString,
7546
- isNumber: isNumber,
7547
- isNullOrUndefined: isNullOrUndefined,
7548
- isNull: isNull,
7549
- isBoolean: isBoolean,
7550
- isArray: isArray,
7551
- inspect: inspect,
7552
- deprecate: deprecate,
7553
- format: format,
7554
- debuglog: debuglog,
7555
- promisify: promisify,
7556
- callbackify: callbackify,
7557
- };
7558
-
7559
- const _polyfillNode_util$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
7560
- __proto__: null,
7561
- _extend,
7562
- callbackify,
7563
- debuglog,
7564
- default: _polyfillNode_util,
7565
- deprecate,
7566
- format,
7567
- inherits,
7568
- inspect,
7569
- isArray,
7570
- isBoolean,
7571
- isBuffer,
7572
- isDate,
7573
- isError,
7574
- isFunction,
7575
- isNull,
7576
- isNullOrUndefined,
7577
- isNumber,
7578
- isObject,
7579
- isPrimitive,
7580
- isRegExp,
7581
- isString,
7582
- isSymbol,
7583
- isUndefined,
7584
- log,
7585
- promisify
7586
- }, Symbol.toStringTag, { value: 'Module' }));
7587
-
7588
- const require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
7589
-
7590
- /*
7591
- The MIT License (MIT)
7592
-
7593
- Copyright (c) 2016 CoderPuppy
7594
-
7595
- Permission is hereby granted, free of charge, to any person obtaining a copy
7596
- of this software and associated documentation files (the "Software"), to deal
7597
- in the Software without restriction, including without limitation the rights
7598
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7599
- copies of the Software, and to permit persons to whom the Software is
7600
- furnished to do so, subject to the following conditions:
7601
-
7602
- The above copyright notice and this permission notice shall be included in all
7603
- copies or substantial portions of the Software.
7604
-
7605
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7606
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7607
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7608
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7609
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7610
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7611
- SOFTWARE.
7612
-
7613
- */
7614
- var _endianness;
7615
- function endianness() {
7616
- if (typeof _endianness === 'undefined') {
7617
- var a = new ArrayBuffer(2);
7618
- var b = new Uint8Array(a);
7619
- var c = new Uint16Array(a);
7620
- b[0] = 1;
7621
- b[1] = 2;
7622
- if (c[0] === 258) {
7623
- _endianness = 'BE';
7624
- } else if (c[0] === 513){
7625
- _endianness = 'LE';
7626
- } else {
7627
- throw new Error('unable to figure out endianess');
7628
- }
7629
- }
7630
- return _endianness;
7631
- }
7632
-
7633
- function hostname() {
7634
- if (typeof global$1.location !== 'undefined') {
7635
- return global$1.location.hostname
7636
- } else return '';
7637
- }
7638
-
7639
- function loadavg() {
7640
- return [];
7641
- }
7642
-
7643
4058
  function uptime() {
7644
- return 0;
7645
- }
7646
-
7647
- function freemem() {
7648
- return Number.MAX_VALUE;
7649
- }
7650
-
7651
- function totalmem() {
7652
- return Number.MAX_VALUE;
7653
- }
7654
-
7655
- function cpus() {
7656
- return [];
7657
- }
7658
-
7659
- function type() {
7660
- return 'Browser';
7661
- }
7662
-
7663
- function release () {
7664
- if (typeof global$1.navigator !== 'undefined') {
7665
- return global$1.navigator.appVersion;
7666
- }
7667
- return '';
7668
- }
7669
-
7670
- function networkInterfaces () {
7671
- return {};
7672
- }
7673
-
7674
- function getNetworkInterfaces () {
7675
- return {};
7676
- }
7677
-
7678
- function arch() {
7679
- return 'javascript';
7680
- }
7681
-
7682
- function platform() {
7683
- return 'browser';
7684
- }
7685
-
7686
- function tmpDir() {
7687
- return '/tmp';
7688
- }
7689
- var tmpdir = tmpDir;
7690
-
7691
- var EOL = '\n';
7692
-
7693
- function homedir(){
7694
- return '$HOME'
4059
+ var currentTime = new Date();
4060
+ var dif = currentTime - startTime;
4061
+ return dif / 1000;
7695
4062
  }
7696
4063
 
7697
- const _polyfillNode_os = {
7698
- homedir: homedir,
7699
- EOL: EOL,
7700
- arch: arch,
4064
+ var browser$1 = {
4065
+ nextTick: nextTick,
4066
+ title: title,
4067
+ browser: browser,
4068
+ env: env,
4069
+ argv: argv,
4070
+ version: version,
4071
+ versions: versions,
4072
+ on: on,
4073
+ addListener: addListener,
4074
+ once: once,
4075
+ off: off,
4076
+ removeListener: removeListener,
4077
+ removeAllListeners: removeAllListeners,
4078
+ emit: emit,
4079
+ binding: binding,
4080
+ cwd: cwd,
4081
+ chdir: chdir,
4082
+ umask: umask,
4083
+ hrtime: hrtime,
7701
4084
  platform: platform,
7702
- tmpdir: tmpdir,
7703
- tmpDir: tmpDir,
7704
- networkInterfaces:networkInterfaces,
7705
- getNetworkInterfaces: getNetworkInterfaces,
7706
4085
  release: release,
7707
- type: type,
7708
- cpus: cpus,
7709
- totalmem: totalmem,
7710
- freemem: freemem,
7711
- uptime: uptime,
7712
- loadavg: loadavg,
7713
- hostname: hostname,
7714
- endianness: endianness,
4086
+ config: config,
4087
+ uptime: uptime
7715
4088
  };
7716
4089
 
7717
- const _polyfillNode_os$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
7718
- __proto__: null,
7719
- EOL,
7720
- arch,
7721
- cpus,
7722
- default: _polyfillNode_os,
7723
- endianness,
7724
- freemem,
7725
- getNetworkInterfaces,
7726
- homedir,
7727
- hostname,
7728
- loadavg,
7729
- networkInterfaces,
7730
- platform,
7731
- release,
7732
- tmpDir,
7733
- tmpdir,
7734
- totalmem,
7735
- type,
7736
- uptime
7737
- }, Symbol.toStringTag, { value: 'Module' }));
7738
-
7739
- const require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_os$1);
7740
-
7741
- var hasFlag;
7742
- var hasRequiredHasFlag;
7743
-
7744
- function requireHasFlag () {
7745
- if (hasRequiredHasFlag) return hasFlag;
7746
- hasRequiredHasFlag = 1;
7747
-
7748
- hasFlag = (flag, argv = browser$1$1.argv) => {
7749
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
7750
- const position = argv.indexOf(prefix + flag);
7751
- const terminatorPosition = argv.indexOf('--');
7752
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
7753
- };
7754
- return hasFlag;
7755
- }
7756
-
7757
- var supportsColor_1;
7758
- var hasRequiredSupportsColor;
7759
-
7760
- function requireSupportsColor () {
7761
- if (hasRequiredSupportsColor) return supportsColor_1;
7762
- hasRequiredSupportsColor = 1;
7763
- const os = require$$0;
7764
- const tty = require$$0$1;
7765
- const hasFlag = requireHasFlag();
7766
-
7767
- const {env} = browser$1$1;
7768
-
7769
- let forceColor;
7770
- if (hasFlag('no-color') ||
7771
- hasFlag('no-colors') ||
7772
- hasFlag('color=false') ||
7773
- hasFlag('color=never')) {
7774
- forceColor = 0;
7775
- } else if (hasFlag('color') ||
7776
- hasFlag('colors') ||
7777
- hasFlag('color=true') ||
7778
- hasFlag('color=always')) {
7779
- forceColor = 1;
7780
- }
7781
-
7782
- if ('FORCE_COLOR' in env) {
7783
- if (env.FORCE_COLOR === 'true') {
7784
- forceColor = 1;
7785
- } else if (env.FORCE_COLOR === 'false') {
7786
- forceColor = 0;
7787
- } else {
7788
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
7789
- }
7790
- }
7791
-
7792
- function translateLevel(level) {
7793
- if (level === 0) {
7794
- return false;
7795
- }
7796
-
7797
- return {
7798
- level,
7799
- hasBasic: true,
7800
- has256: level >= 2,
7801
- has16m: level >= 3
7802
- };
7803
- }
7804
-
7805
- function supportsColor(haveStream, streamIsTTY) {
7806
- if (forceColor === 0) {
7807
- return 0;
7808
- }
7809
-
7810
- if (hasFlag('color=16m') ||
7811
- hasFlag('color=full') ||
7812
- hasFlag('color=truecolor')) {
7813
- return 3;
7814
- }
7815
-
7816
- if (hasFlag('color=256')) {
7817
- return 2;
7818
- }
7819
-
7820
- if (haveStream && !streamIsTTY && forceColor === undefined) {
7821
- return 0;
7822
- }
7823
-
7824
- const min = forceColor || 0;
7825
-
7826
- if (env.TERM === 'dumb') {
7827
- return min;
7828
- }
7829
-
7830
- if (browser$1$1.platform === 'win32') {
7831
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
7832
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
7833
- const osRelease = os.release().split('.');
7834
- if (
7835
- Number(osRelease[0]) >= 10 &&
7836
- Number(osRelease[2]) >= 10586
7837
- ) {
7838
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
7839
- }
7840
-
7841
- return 1;
7842
- }
7843
-
7844
- if ('CI' in env) {
7845
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
7846
- return 1;
7847
- }
7848
-
7849
- return min;
7850
- }
7851
-
7852
- if ('TEAMCITY_VERSION' in env) {
7853
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
7854
- }
7855
-
7856
- if (env.COLORTERM === 'truecolor') {
7857
- return 3;
7858
- }
7859
-
7860
- if ('TERM_PROGRAM' in env) {
7861
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
7862
-
7863
- switch (env.TERM_PROGRAM) {
7864
- case 'iTerm.app':
7865
- return version >= 3 ? 3 : 2;
7866
- case 'Apple_Terminal':
7867
- return 2;
7868
- // No default
7869
- }
7870
- }
7871
-
7872
- if (/-256(color)?$/i.test(env.TERM)) {
7873
- return 2;
7874
- }
7875
-
7876
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
7877
- return 1;
7878
- }
7879
-
7880
- if ('COLORTERM' in env) {
7881
- return 1;
7882
- }
7883
-
7884
- return min;
7885
- }
7886
-
7887
- function getSupportLevel(stream) {
7888
- const level = supportsColor(stream, stream && stream.isTTY);
7889
- return translateLevel(level);
7890
- }
7891
-
7892
- supportsColor_1 = {
7893
- supportsColor: getSupportLevel,
7894
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
7895
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
7896
- };
7897
- return supportsColor_1;
7898
- }
7899
-
7900
- var hasRequiredNode;
7901
-
7902
- function requireNode () {
7903
- if (hasRequiredNode) return node.exports;
7904
- hasRequiredNode = 1;
7905
- (function (module, exports) {
7906
- const tty = require$$0$1;
7907
- const util = require$$1;
7908
-
7909
- /**
7910
- * This is the Node.js implementation of `debug()`.
7911
- */
7912
-
7913
- exports.init = init;
7914
- exports.log = log;
7915
- exports.formatArgs = formatArgs;
7916
- exports.save = save;
7917
- exports.load = load;
7918
- exports.useColors = useColors;
7919
- exports.destroy = util.deprecate(
7920
- () => {},
7921
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
7922
- );
7923
-
7924
- /**
7925
- * Colors.
7926
- */
7927
-
7928
- exports.colors = [6, 2, 3, 4, 5, 1];
7929
-
7930
- try {
7931
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
7932
- // eslint-disable-next-line import/no-extraneous-dependencies
7933
- const supportsColor = requireSupportsColor();
7934
-
7935
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
7936
- exports.colors = [
7937
- 20,
7938
- 21,
7939
- 26,
7940
- 27,
7941
- 32,
7942
- 33,
7943
- 38,
7944
- 39,
7945
- 40,
7946
- 41,
7947
- 42,
7948
- 43,
7949
- 44,
7950
- 45,
7951
- 56,
7952
- 57,
7953
- 62,
7954
- 63,
7955
- 68,
7956
- 69,
7957
- 74,
7958
- 75,
7959
- 76,
7960
- 77,
7961
- 78,
7962
- 79,
7963
- 80,
7964
- 81,
7965
- 92,
7966
- 93,
7967
- 98,
7968
- 99,
7969
- 112,
7970
- 113,
7971
- 128,
7972
- 129,
7973
- 134,
7974
- 135,
7975
- 148,
7976
- 149,
7977
- 160,
7978
- 161,
7979
- 162,
7980
- 163,
7981
- 164,
7982
- 165,
7983
- 166,
7984
- 167,
7985
- 168,
7986
- 169,
7987
- 170,
7988
- 171,
7989
- 172,
7990
- 173,
7991
- 178,
7992
- 179,
7993
- 184,
7994
- 185,
7995
- 196,
7996
- 197,
7997
- 198,
7998
- 199,
7999
- 200,
8000
- 201,
8001
- 202,
8002
- 203,
8003
- 204,
8004
- 205,
8005
- 206,
8006
- 207,
8007
- 208,
8008
- 209,
8009
- 214,
8010
- 215,
8011
- 220,
8012
- 221
8013
- ];
8014
- }
8015
- } catch (error) {
8016
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
8017
- }
8018
-
8019
- /**
8020
- * Build up the default `inspectOpts` object from the environment variables.
8021
- *
8022
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
8023
- */
8024
-
8025
- exports.inspectOpts = Object.keys(browser$1$1.env).filter(key => {
8026
- return /^debug_/i.test(key);
8027
- }).reduce((obj, key) => {
8028
- // Camel-case
8029
- const prop = key
8030
- .substring(6)
8031
- .toLowerCase()
8032
- .replace(/_([a-z])/g, (_, k) => {
8033
- return k.toUpperCase();
8034
- });
8035
-
8036
- // Coerce string value into JS value
8037
- let val = browser$1$1.env[key];
8038
- if (/^(yes|on|true|enabled)$/i.test(val)) {
8039
- val = true;
8040
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
8041
- val = false;
8042
- } else if (val === 'null') {
8043
- val = null;
8044
- } else {
8045
- val = Number(val);
8046
- }
8047
-
8048
- obj[prop] = val;
8049
- return obj;
8050
- }, {});
8051
-
8052
- /**
8053
- * Is stdout a TTY? Colored output is enabled when `true`.
8054
- */
8055
-
8056
- function useColors() {
8057
- return 'colors' in exports.inspectOpts ?
8058
- Boolean(exports.inspectOpts.colors) :
8059
- tty.isatty(browser$1$1.stderr.fd);
8060
- }
8061
-
8062
- /**
8063
- * Adds ANSI color escape codes if enabled.
8064
- *
8065
- * @api public
8066
- */
8067
-
8068
- function formatArgs(args) {
8069
- const {namespace: name, useColors} = this;
8070
-
8071
- if (useColors) {
8072
- const c = this.color;
8073
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
8074
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
8075
-
8076
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
8077
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
8078
- } else {
8079
- args[0] = getDate() + name + ' ' + args[0];
8080
- }
8081
- }
8082
-
8083
- function getDate() {
8084
- if (exports.inspectOpts.hideDate) {
8085
- return '';
8086
- }
8087
- return new Date().toISOString() + ' ';
8088
- }
8089
-
8090
- /**
8091
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
8092
- */
8093
-
8094
- function log(...args) {
8095
- return browser$1$1.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
8096
- }
8097
-
8098
- /**
8099
- * Save `namespaces`.
8100
- *
8101
- * @param {String} namespaces
8102
- * @api private
8103
- */
8104
- function save(namespaces) {
8105
- if (namespaces) {
8106
- browser$1$1.env.DEBUG = namespaces;
8107
- } else {
8108
- // If you set a process.env field to null or undefined, it gets cast to the
8109
- // string 'null' or 'undefined'. Just delete instead.
8110
- delete browser$1$1.env.DEBUG;
8111
- }
8112
- }
8113
-
8114
- /**
8115
- * Load `namespaces`.
8116
- *
8117
- * @return {String} returns the previously persisted debug modes
8118
- * @api private
8119
- */
8120
-
8121
- function load() {
8122
- return browser$1$1.env.DEBUG;
8123
- }
8124
-
8125
- /**
8126
- * Init logic for `debug` instances.
8127
- *
8128
- * Create a new `inspectOpts` object in case `useColors` is set
8129
- * differently for a particular `debug` instance.
8130
- */
8131
-
8132
- function init(debug) {
8133
- debug.inspectOpts = {};
8134
-
8135
- const keys = Object.keys(exports.inspectOpts);
8136
- for (let i = 0; i < keys.length; i++) {
8137
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
8138
- }
8139
- }
8140
-
8141
- module.exports = requireCommon()(exports);
8142
-
8143
- const {formatters} = module.exports;
8144
-
8145
- /**
8146
- * Map %o to `util.inspect()`, all on a single line.
8147
- */
8148
-
8149
- formatters.o = function (v) {
8150
- this.inspectOpts.colors = this.useColors;
8151
- return util.inspect(v, this.inspectOpts)
8152
- .split('\n')
8153
- .map(str => str.trim())
8154
- .join(' ');
8155
- };
8156
-
8157
- /**
8158
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
8159
- */
8160
-
8161
- formatters.O = function (v) {
8162
- this.inspectOpts.colors = this.useColors;
8163
- return util.inspect(v, this.inspectOpts);
8164
- };
8165
- } (node, node.exports));
8166
- return node.exports;
4090
+ if (browser$1.env.NODE_ENV === 'production') {
4091
+ log__default.default.setLevel('silent');
8167
4092
  }
8168
-
8169
- if (typeof browser$1$1 === 'undefined' || browser$1$1.type === 'renderer' || browser$1$1.browser === true || browser$1$1.__nwjs) {
8170
- src.exports = requireBrowser();
8171
- } else {
8172
- src.exports = requireNode();
4093
+ else {
4094
+ log__default.default.setLevel('trace');
8173
4095
  }
8174
-
8175
- var srcExports = src.exports;
8176
- const debug = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
8177
-
8178
- var logger = function (message, data) {
8179
- if (browser$1$1.env.NODE_ENV === 'production') {
8180
- return;
8181
- }
8182
- var log = debug('NCW-SDK-JS');
8183
- return log(message, data);
8184
- };
4096
+ var logger = log__default.default;
8185
4097
 
8186
4098
  var _a;
8187
4099
  /**
8188
4100
  * The default environment will be set to NODE_ENV if environment is not set in config.
8189
4101
  * For production builds, it is recommended to set NODE_ENV to 'production'.
8190
4102
  */
8191
- var defaultEnvironment = (_a = browser$1$1.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'production';
4103
+ var defaultEnvironment = (_a = browser$1.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'production';
8192
4104
  /**
8193
4105
  * The default network is set to 'testnet' for protection during development.
8194
4106
  * Please pass the network value in the WallabyConfigOptions object to override it for production-mainnet.
8195
4107
  */
8196
4108
  var defaultNetwork = 'testnet';
8197
- var isTest = browser$1$1.env.NODE_ENV === 'test';
4109
+ var isTest = browser$1.env.NODE_ENV === 'test';
8198
4110
 
8199
4111
  var StorageService = /** @class */ (function () {
8200
4112
  function StorageService(_a) {
@@ -8254,7 +4166,7 @@ var StorageService = /** @class */ (function () {
8254
4166
  return [2 /*return*/, true];
8255
4167
  case 2:
8256
4168
  error_1 = _a.sent();
8257
- logger('SDK::StorageService::setWallabyAuthPubKey:error', error_1);
4169
+ logger.error('SDK::StorageService::setWallabyAuthPubKey:error', error_1);
8258
4170
  return [2 /*return*/, false];
8259
4171
  case 3: return [2 /*return*/];
8260
4172
  }
@@ -8295,7 +4207,7 @@ var StorageService = /** @class */ (function () {
8295
4207
  case 6: return [3 /*break*/, 8];
8296
4208
  case 7:
8297
4209
  error_2 = _a.sent();
8298
- logger('SDK::UtilsHelpers::getWallabyAuthPubKey::error', error_2);
4210
+ logger.error('SDK::UtilsHelpers::getWallabyAuthPubKey::error', error_2);
8299
4211
  return [2 /*return*/, undefined];
8300
4212
  case 8: return [2 /*return*/];
8301
4213
  }
@@ -8322,7 +4234,7 @@ var StorageService = /** @class */ (function () {
8322
4234
  return [2 /*return*/, true];
8323
4235
  case 2:
8324
4236
  error_3 = _a.sent();
8325
- logger('SDK::StorageService::setEncryptedPrivateKey', error_3);
4237
+ logger.error('SDK::StorageService::setEncryptedPrivateKey', error_3);
8326
4238
  return [2 /*return*/, false];
8327
4239
  case 3: return [2 /*return*/];
8328
4240
  }
@@ -8358,12 +4270,12 @@ var StorageService = /** @class */ (function () {
8358
4270
  _a.sent();
8359
4271
  return [2 /*return*/, encryptedPrivateKey];
8360
4272
  case 5:
8361
- logger('SDK::StorageService::getEncryptedPrivateKey: private key not found');
4273
+ logger.error('SDK::StorageService::getEncryptedPrivateKey: private key not found');
8362
4274
  return [2 /*return*/, undefined];
8363
4275
  case 6: return [3 /*break*/, 8];
8364
4276
  case 7:
8365
4277
  error_4 = _a.sent();
8366
- logger('SDK::StorageService::getEncryptedPrivateKey::error', error_4);
4278
+ logger.error('SDK::StorageService::getEncryptedPrivateKey::error', error_4);
8367
4279
  return [2 /*return*/, undefined];
8368
4280
  case 8: return [2 /*return*/];
8369
4281
  }
@@ -8398,7 +4310,7 @@ var StorageService = /** @class */ (function () {
8398
4310
  }
8399
4311
  case 2:
8400
4312
  error_5 = _a.sent();
8401
- logger('SDK::StorageService::getDecryptedPrivateKey::error', error_5);
4313
+ logger.error('SDK::StorageService::getDecryptedPrivateKey::error', error_5);
8402
4314
  return [2 /*return*/, undefined];
8403
4315
  case 3: return [2 /*return*/];
8404
4316
  }
@@ -8522,7 +4434,7 @@ var StorageService = /** @class */ (function () {
8522
4434
  return [2 /*return*/, true];
8523
4435
  case 2:
8524
4436
  error_6 = _a.sent();
8525
- logger('SDK::StorageService::setAccessToken::error', error_6);
4437
+ logger.error('SDK::StorageService::setAccessToken::error', error_6);
8526
4438
  return [2 /*return*/, false];
8527
4439
  case 3: return [2 /*return*/];
8528
4440
  }
@@ -8554,7 +4466,7 @@ var StorageService = /** @class */ (function () {
8554
4466
  }
8555
4467
  case 4:
8556
4468
  error_7 = _a.sent();
8557
- logger('SDK::StorageService::getAccessToken::error', error_7);
4469
+ logger.error('SDK::StorageService::getAccessToken::error', error_7);
8558
4470
  return [2 /*return*/, undefined];
8559
4471
  case 5: return [2 /*return*/];
8560
4472
  }
@@ -8785,10 +4697,10 @@ var Base = /** @class */ (function () {
8785
4697
  http.interceptors.response.use(function (response) { return response; }, function (error) {
8786
4698
  var _a, _b, _c;
8787
4699
  if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
8788
- logger('SDK::Base::Interceptor::error.response.data', (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data);
4700
+ logger.info('SDK::Base::Interceptor::error.response.data', (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data);
8789
4701
  return Promise.reject((_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data);
8790
4702
  }
8791
- logger('SDK::Base::Interceptor::error', error);
4703
+ logger.error('SDK::Base::Interceptor::error', error);
8792
4704
  return Promise.reject(error);
8793
4705
  });
8794
4706
  _a = route.method;
@@ -8803,12 +4715,12 @@ var Base = /** @class */ (function () {
8803
4715
  return [4 /*yield*/, http.get(url)];
8804
4716
  case 3:
8805
4717
  result = _k.sent();
8806
- logger('SDK::Base::RequestMethod.Get::result', result);
4718
+ logger.info('SDK::Base::RequestMethod.Get::result', result);
8807
4719
  return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
8808
4720
  case 4:
8809
4721
  error_1 = _k.sent();
8810
4722
  if (error_1 instanceof axios.AxiosError) {
8811
- logger('SDK::Base::RequestMethod.Get::error', (_c = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _c === void 0 ? void 0 : _c.data);
4723
+ logger.error('SDK::Base::RequestMethod.Get::error', (_c = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _c === void 0 ? void 0 : _c.data);
8812
4724
  return [2 /*return*/, Promise.reject((_d = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _d === void 0 ? void 0 : _d.data)];
8813
4725
  }
8814
4726
  return [2 /*return*/, Promise.reject(error_1 === null || error_1 === void 0 ? void 0 : error_1.message)];
@@ -8817,12 +4729,12 @@ var Base = /** @class */ (function () {
8817
4729
  return [4 /*yield*/, http.post(url, JSON.stringify(options === null || options === void 0 ? void 0 : options.payload))];
8818
4730
  case 6:
8819
4731
  result = _k.sent();
8820
- logger('SDK::Base::RequestMethod.Post::result', result);
4732
+ logger.info('SDK::Base::RequestMethod.Post::result', result);
8821
4733
  return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
8822
4734
  case 7:
8823
4735
  error_2 = _k.sent();
8824
4736
  if (error_2 instanceof axios.AxiosError) {
8825
- logger('SDK::Base::RequestMethod.Post::error', (_e = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _e === void 0 ? void 0 : _e.data);
4737
+ logger.error('SDK::Base::RequestMethod.Post::error', (_e = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _e === void 0 ? void 0 : _e.data);
8826
4738
  return [2 /*return*/, Promise.reject((_f = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _f === void 0 ? void 0 : _f.data)];
8827
4739
  }
8828
4740
  return [2 /*return*/, Promise.reject(error_2 === null || error_2 === void 0 ? void 0 : error_2.message)];
@@ -8835,14 +4747,14 @@ var Base = /** @class */ (function () {
8835
4747
  case 10:
8836
4748
  error_3 = _k.sent();
8837
4749
  if (error_3 instanceof axios.AxiosError) {
8838
- logger('SDK::Base::RequestMethod.Put::error', (_h = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _h === void 0 ? void 0 : _h.data);
4750
+ logger.error('SDK::Base::RequestMethod.Put::error', (_h = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _h === void 0 ? void 0 : _h.data);
8839
4751
  return [2 /*return*/, Promise.reject((_j = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _j === void 0 ? void 0 : _j.data)];
8840
4752
  }
8841
4753
  return [2 /*return*/, Promise.reject(error_3 === null || error_3 === void 0 ? void 0 : error_3.message)];
8842
4754
  case 11: return [3 /*break*/, 13];
8843
4755
  case 12:
8844
4756
  error_4 = _k.sent();
8845
- logger('SDK::Base::request::error', error_4);
4757
+ logger.error('SDK::Base::request::error', error_4);
8846
4758
  return [2 /*return*/, Promise.reject(error_4)];
8847
4759
  case 13: return [2 /*return*/];
8848
4760
  }
@@ -9139,7 +5051,7 @@ var Auth = /** @class */ (function (_super) {
9139
5051
  return [2 /*return*/, { message: message, hashedMessage: hashedMessage, signature: signature, decryptedClientAuthPrivKey: decryptedClientAuthPrivKey, clientAuthPubKey: clientAuthPubKey }];
9140
5052
  case 3:
9141
5053
  error_1 = _d.sent();
9142
- logger('SDK::Auth::signatureMessage::error', error_1);
5054
+ logger.error('SDK::Auth::signatureMessage::error', error_1);
9143
5055
  return [2 /*return*/, Promise.reject(error_1)];
9144
5056
  case 4: return [2 /*return*/];
9145
5057
  }
@@ -9159,12 +5071,11 @@ var Auth = /** @class */ (function (_super) {
9159
5071
  Auth.prototype.signUp = function (_a) {
9160
5072
  return __awaiter(this, arguments, void 0, function (_b) {
9161
5073
  var signatureMessage, message, signature, decryptedClientAuthPrivKey, clientAuthPubKey, response, accessToken, user, _c, _d, error_2;
9162
- var password = _b.password, firstName = _b.firstName, lastName = _b.lastName, email = _b.email;
5074
+ var password = _b.password;
9163
5075
  return __generator(this, function (_e) {
9164
5076
  switch (_e.label) {
9165
5077
  case 0:
9166
5078
  _e.trys.push([0, 7, , 8]);
9167
- logger('SDK::Auth::signUp::info', { firstName: firstName, lastName: lastName, email: email });
9168
5079
  return [4 /*yield*/, this.signatureMessage({ password: password })];
9169
5080
  case 1:
9170
5081
  signatureMessage = _e.sent();
@@ -9198,7 +5109,7 @@ var Auth = /** @class */ (function (_super) {
9198
5109
  return [2 /*return*/, response];
9199
5110
  case 7:
9200
5111
  error_2 = _e.sent();
9201
- logger('SDK::Auth::singUp::error', error_2);
5112
+ logger.error('SDK::Auth::singUp::error', error_2);
9202
5113
  return [2 /*return*/, Promise.reject(error_2)];
9203
5114
  case 8: return [2 /*return*/];
9204
5115
  }
@@ -9240,7 +5151,7 @@ var Auth = /** @class */ (function (_super) {
9240
5151
  return [2 /*return*/, response];
9241
5152
  case 3:
9242
5153
  error_3 = _c.sent();
9243
- logger('SDK::Auth::signIn::error', error_3);
5154
+ logger.error('SDK::Auth::signIn::error', error_3);
9244
5155
  return [2 /*return*/, Promise.reject(error_3)];
9245
5156
  case 4: return [2 /*return*/];
9246
5157
  }
@@ -9271,7 +5182,7 @@ var Auth = /** @class */ (function (_super) {
9271
5182
  return [2 /*return*/, response];
9272
5183
  case 2:
9273
5184
  error_4 = _a.sent();
9274
- logger('SDK::Auth::RefreshAccessToken::error', error_4);
5185
+ logger.error('SDK::Auth::RefreshAccessToken::error', error_4);
9275
5186
  return [2 /*return*/, Promise.reject(error_4)];
9276
5187
  case 3: return [2 /*return*/];
9277
5188
  }
@@ -9316,7 +5227,7 @@ var Auth = /** @class */ (function (_super) {
9316
5227
  return [2 /*return*/, response];
9317
5228
  case 3:
9318
5229
  error_5 = _d.sent();
9319
- logger('SDK::Auth::clientAuthPubKey::error', error_5);
5230
+ logger.error('SDK::Auth::clientAuthPubKey::error', error_5);
9320
5231
  return [2 /*return*/, Promise.reject(error_5)];
9321
5232
  case 4: return [2 /*return*/];
9322
5233
  }
@@ -9348,7 +5259,7 @@ var Auth = /** @class */ (function (_super) {
9348
5259
  return [2 /*return*/, (_a = response.clientSalt) !== null && _a !== void 0 ? _a : response.salt];
9349
5260
  case 2:
9350
5261
  error_6 = _b.sent();
9351
- logger('SDK::Auth::getUserSalt::error', error_6);
5262
+ logger.error('SDK::Auth::getUserSalt::error', error_6);
9352
5263
  return [2 /*return*/, Promise.reject(error_6)];
9353
5264
  case 3: return [2 /*return*/];
9354
5265
  }
@@ -9422,7 +5333,7 @@ var Wallet = /** @class */ (function (_super) {
9422
5333
  return [2 /*return*/, { standardSeedPhrase: standardSeedPhrase, algorandSeedPhrase: algorandSeedPhrase }];
9423
5334
  case 3:
9424
5335
  error_1 = _c.sent();
9425
- logger('SDK::Wallet::mnemonicSeedPhrase::error', error_1);
5336
+ logger.error('SDK::Wallet::mnemonicSeedPhrase::error', error_1);
9426
5337
  return [2 /*return*/, Promise.reject(error_1)];
9427
5338
  case 4: return [2 /*return*/];
9428
5339
  }
@@ -9458,7 +5369,7 @@ var Wallet = /** @class */ (function (_super) {
9458
5369
  return [2 /*return*/, response];
9459
5370
  case 2:
9460
5371
  error_2 = _c.sent();
9461
- logger('SDK::Wallet::getTokenBalance::error', error_2);
5372
+ logger.error('SDK::Wallet::getTokenBalance::error', error_2);
9462
5373
  return [2 /*return*/, Promise.reject(error_2)];
9463
5374
  case 3: return [2 /*return*/];
9464
5375
  }
@@ -9494,7 +5405,7 @@ var Wallet = /** @class */ (function (_super) {
9494
5405
  return [2 /*return*/, response];
9495
5406
  case 2:
9496
5407
  error_3 = _a.sent();
9497
- logger('SDK::Wallet::getTokenBalance::error', error_3);
5408
+ logger.error('SDK::Wallet::getTokenBalance::error', error_3);
9498
5409
  return [2 /*return*/, Promise.reject(error_3)];
9499
5410
  case 3: return [2 /*return*/];
9500
5411
  }
@@ -9528,7 +5439,7 @@ var Wallet = /** @class */ (function (_super) {
9528
5439
  return [2 /*return*/, response];
9529
5440
  case 2:
9530
5441
  error_4 = _c.sent();
9531
- logger('SDK::Wallet::getTokenBalance::error', error_4);
5442
+ logger.error('SDK::Wallet::getTokenBalance::error', error_4);
9532
5443
  return [2 /*return*/, Promise.reject(error_4)];
9533
5444
  case 3: return [2 /*return*/];
9534
5445
  }
@@ -9614,7 +5525,7 @@ var Wallet = /** @class */ (function (_super) {
9614
5525
  return [2 /*return*/, __assign(__assign({}, response), { decryptedSeedPhrase: decryptedSeedPhrase, decryptedMnemonicSeedPhrase: decryptedMnemonicSeedPhrase })];
9615
5526
  case 10:
9616
5527
  error_5 = _c.sent();
9617
- logger('SDK::Wallet::create::error', error_5);
5528
+ logger.error('SDK::Wallet::create::error', error_5);
9618
5529
  return [2 /*return*/, Promise.reject(error_5)];
9619
5530
  case 11: return [2 /*return*/];
9620
5531
  }
@@ -9709,7 +5620,7 @@ var Wallet = /** @class */ (function (_super) {
9709
5620
  return [2 /*return*/, __assign(__assign({}, response), { decryptedSeedPhrase: decryptedSeedPhrase, decryptedMnemonicSeedPhrase: decryptedMnemonicSeedPhrase })];
9710
5621
  case 11:
9711
5622
  error_6 = _c.sent();
9712
- logger('SDK::Wallet::create::error', error_6);
5623
+ logger.error('SDK::Wallet::create::error', error_6);
9713
5624
  return [2 /*return*/, Promise.reject(error_6)];
9714
5625
  case 12: return [2 /*return*/];
9715
5626
  }
@@ -9771,7 +5682,7 @@ var Wallet = /** @class */ (function (_super) {
9771
5682
  return [2 /*return*/, response];
9772
5683
  case 6:
9773
5684
  error_7 = _c.sent();
9774
- logger('SDK::Wallet::create::error', error_7);
5685
+ logger.error('SDK::Wallet::create::error', error_7);
9775
5686
  return [2 /*return*/, Promise.reject(error_7)];
9776
5687
  case 7: return [2 /*return*/];
9777
5688
  }
@@ -9820,7 +5731,7 @@ var Wallet = /** @class */ (function (_super) {
9820
5731
  return [2 /*return*/, { standardSeedPhrase: standardSeedPhrase, algorandSeedPhrase: algorandSeedPhrase }];
9821
5732
  case 4:
9822
5733
  error_8 = _c.sent();
9823
- logger('SDK::Wallet::mnemonicSeedPhrase::error', error_8);
5734
+ logger.error('SDK::Wallet::mnemonicSeedPhrase::error', error_8);
9824
5735
  return [2 /*return*/, Promise.reject(error_8)];
9825
5736
  case 5: return [2 /*return*/];
9826
5737
  }
@@ -9846,7 +5757,7 @@ var Wallet = /** @class */ (function (_super) {
9846
5757
  return [2 /*return*/, true];
9847
5758
  case 2:
9848
5759
  error_9 = _a.sent();
9849
- logger('SDK::Wallet::clearDevice::error', error_9);
5760
+ logger.error('SDK::Wallet::clearDevice::error', error_9);
9850
5761
  return [2 /*return*/, false];
9851
5762
  case 3: return [2 /*return*/];
9852
5763
  }
@@ -9892,7 +5803,7 @@ var Wallet = /** @class */ (function (_super) {
9892
5803
  return [2 /*return*/, response];
9893
5804
  case 3:
9894
5805
  error_10 = _c.sent();
9895
- logger('SDK::Wallet::convertMnemonicSeedphrase::error', error_10);
5806
+ logger.error('SDK::Wallet::convertMnemonicSeedphrase::error', error_10);
9896
5807
  return [2 /*return*/, Promise.reject(error_10)];
9897
5808
  case 4: return [2 /*return*/];
9898
5809
  }
@@ -9987,7 +5898,7 @@ var Wallet = /** @class */ (function (_super) {
9987
5898
  return [2 /*return*/, __assign(__assign({}, response), { seedPhrase: seedPhrase, decryptedAlgorandSeedphrase: decryptedAlgorandSeedphrase })];
9988
5899
  case 9:
9989
5900
  error_11 = _d.sent();
9990
- logger('SDK::Wallet::recover::error', error_11);
5901
+ logger.error('SDK::Wallet::recover::error', error_11);
9991
5902
  return [2 /*return*/, Promise.reject(error_11)];
9992
5903
  case 10: return [2 /*return*/];
9993
5904
  }
@@ -10024,7 +5935,7 @@ var Wallet = /** @class */ (function (_super) {
10024
5935
  return [2 /*return*/, response];
10025
5936
  case 2:
10026
5937
  error_12 = _c.sent();
10027
- logger('SDK::Wallet::getUserAssets::error', error_12);
5938
+ logger.error('SDK::Wallet::getUserAssets::error', error_12);
10028
5939
  return [2 /*return*/, Promise.reject(error_12)];
10029
5940
  case 3: return [2 /*return*/];
10030
5941
  }
@@ -10060,7 +5971,7 @@ var Wallet = /** @class */ (function (_super) {
10060
5971
  return [2 /*return*/, response];
10061
5972
  case 2:
10062
5973
  error_13 = _c.sent();
10063
- logger('SDK::Wallet::getUserWallets::error', error_13);
5974
+ logger.error('SDK::Wallet::getUserWallets::error', error_13);
10064
5975
  return [2 /*return*/, Promise.reject(error_13)];
10065
5976
  case 3: return [2 /*return*/];
10066
5977
  }
@@ -10097,7 +6008,7 @@ var Wallet = /** @class */ (function (_super) {
10097
6008
  return [2 /*return*/, response];
10098
6009
  case 2:
10099
6010
  error_14 = _c.sent();
10100
- logger('SDK::Wallet::getWalletAssets::error', error_14);
6011
+ logger.error('SDK::Wallet::getWalletAssets::error', error_14);
10101
6012
  return [2 /*return*/, Promise.reject(error_14)];
10102
6013
  case 3: return [2 /*return*/];
10103
6014
  }
@@ -10144,7 +6055,7 @@ var Wallet = /** @class */ (function (_super) {
10144
6055
  return [2 /*return*/, response];
10145
6056
  case 2:
10146
6057
  error_15 = _c.sent();
10147
- logger('SDK::Wallet::createMultisigAsset::error', error_15);
6058
+ logger.error('SDK::Wallet::createMultisigAsset::error', error_15);
10148
6059
  return [2 /*return*/, Promise.reject(error_15)];
10149
6060
  case 3: return [2 /*return*/];
10150
6061
  }
@@ -10203,7 +6114,7 @@ var Wallet = /** @class */ (function (_super) {
10203
6114
  return [2 /*return*/, response];
10204
6115
  case 2:
10205
6116
  error_16 = _c.sent();
10206
- logger('SDK::Wallet::addTokenToWallet::error', error_16);
6117
+ logger.error('SDK::Wallet::addTokenToWallet::error', error_16);
10207
6118
  return [2 /*return*/, Promise.reject(error_16)];
10208
6119
  case 3: return [2 /*return*/];
10209
6120
  }
@@ -10246,7 +6157,7 @@ var Wallet = /** @class */ (function (_super) {
10246
6157
  return [2 /*return*/, response];
10247
6158
  case 2:
10248
6159
  error_17 = _b.sent();
10249
- logger('SDK::Wallet::updateAsset::error', error_17);
6160
+ logger.error('SDK::Wallet::updateAsset::error', error_17);
10250
6161
  return [2 /*return*/, Promise.reject(error_17)];
10251
6162
  case 3: return [2 /*return*/];
10252
6163
  }
@@ -10276,7 +6187,7 @@ var Wallet = /** @class */ (function (_super) {
10276
6187
  return [2 /*return*/, { signatureMessage: initRecovery.signatureMessage, wallabyAuthPubKey: initRecovery.wallabyAuthPubKey }];
10277
6188
  case 2:
10278
6189
  error_18 = _c.sent();
10279
- logger('SDK::Wallet::initRecoveryFlow::error', error_18);
6190
+ logger.error('SDK::Wallet::initRecoveryFlow::error', error_18);
10280
6191
  return [2 /*return*/, Promise.reject(error_18)];
10281
6192
  case 3: return [2 /*return*/];
10282
6193
  }
@@ -10305,7 +6216,7 @@ var Utils = /** @class */ (function (_super) {
10305
6216
  case 1:
10306
6217
  privateKey = _a.sent();
10307
6218
  if (!privateKey) {
10308
- logger('SDK::Utils::getDecryptedPrivateKey::undefined?', !privateKey);
6219
+ logger.error('SDK::Utils::getDecryptedPrivateKey::undefined?', !privateKey);
10309
6220
  return [2 /*return*/, undefined];
10310
6221
  }
10311
6222
  decryptedPrivateKey = cryptoJs.AES.decrypt(privateKey, password).toString(cryptoJs.enc.Utf8);
@@ -10368,7 +6279,7 @@ var Utils = /** @class */ (function (_super) {
10368
6279
  _d.password = password,
10369
6280
  _d)]);
10370
6281
  if (!devicePrivateKey) {
10371
- logger('SDK::Utils::decryptSeedPhrase::devicePrivateKey: Device private key could not be decrypted');
6282
+ logger.error('SDK::Utils::decryptSeedPhrase::devicePrivateKey: Device private key could not be decrypted');
10372
6283
  throw new Error('Device private key could not be decrypted');
10373
6284
  }
10374
6285
  return [4 /*yield*/, decryptWithPrivateKey(devicePrivateKey, parsedSeed)];
@@ -10440,7 +6351,7 @@ var Utils = /** @class */ (function (_super) {
10440
6351
  return [2 /*return*/, response];
10441
6352
  case 2:
10442
6353
  error_1 = _c.sent();
10443
- logger('SDK::Utils::fetchFromEndpoint::error', error_1);
6354
+ logger.error('SDK::Utils::fetchFromEndpoint::error', error_1);
10444
6355
  return [2 /*return*/, Promise.reject(error_1)];
10445
6356
  case 3: return [2 /*return*/];
10446
6357
  }
@@ -10535,6 +6446,13 @@ var Merchants = /** @class */ (function (_super) {
10535
6446
  function Merchants(config) {
10536
6447
  return _super.call(this, config) || this;
10537
6448
  }
6449
+ Object.defineProperty(Merchants.prototype, "merchantId", {
6450
+ get: function () {
6451
+ return this.getMerchantId();
6452
+ },
6453
+ enumerable: false,
6454
+ configurable: true
6455
+ });
10538
6456
  /**
10539
6457
  *
10540
6458
  * @public
@@ -10560,7 +6478,7 @@ var Merchants = /** @class */ (function (_super) {
10560
6478
  return [2 /*return*/, response];
10561
6479
  case 2:
10562
6480
  error_1 = _a.sent();
10563
- logger('SDK::Merchants::list::error', error_1);
6481
+ logger.error('SDK::Merchants::list::error', error_1);
10564
6482
  return [2 /*return*/, Promise.reject(error_1)];
10565
6483
  case 3: return [2 /*return*/];
10566
6484
  }
@@ -10593,7 +6511,7 @@ var Merchants = /** @class */ (function (_super) {
10593
6511
  return [2 /*return*/, response];
10594
6512
  case 2:
10595
6513
  error_2 = _c.sent();
10596
- logger('SDK::Merchants::list::error', error_2);
6514
+ logger.error('SDK::Merchants::list::error', error_2);
10597
6515
  return [2 /*return*/, Promise.reject(error_2)];
10598
6516
  case 3: return [2 /*return*/];
10599
6517
  }
@@ -10609,14 +6527,14 @@ var Merchants = /** @class */ (function (_super) {
10609
6527
  Merchants.prototype.update = function (_a) {
10610
6528
  return __awaiter(this, arguments, void 0, function (_b) {
10611
6529
  var response, error_3;
10612
- var merchantId = _b.merchantId, name = _b.name, status = _b.status;
6530
+ var name = _b.name, status = _b.status;
10613
6531
  return __generator(this, function (_c) {
10614
6532
  switch (_c.label) {
10615
6533
  case 0:
10616
6534
  _c.trys.push([0, 2, , 3]);
10617
6535
  return [4 /*yield*/, this.request(MerchantsRoutes.update, {
10618
6536
  method: MerchantsRoutes.update.method,
10619
- payload: { merchantId: merchantId, name: name, status: status },
6537
+ payload: { merchantId: this.merchantId, name: name, status: status },
10620
6538
  })];
10621
6539
  case 1:
10622
6540
  response = _c.sent();
@@ -10626,7 +6544,7 @@ var Merchants = /** @class */ (function (_super) {
10626
6544
  return [2 /*return*/, response];
10627
6545
  case 2:
10628
6546
  error_3 = _c.sent();
10629
- logger('SDK::Merchants::list::error', error_3);
6547
+ logger.error('SDK::Merchants::list::error', error_3);
10630
6548
  return [2 /*return*/, Promise.reject(error_3)];
10631
6549
  case 3: return [2 /*return*/];
10632
6550
  }
@@ -10636,30 +6554,28 @@ var Merchants = /** @class */ (function (_super) {
10636
6554
  /**
10637
6555
  *
10638
6556
  * @public
10639
- * @param merchantId Merchant ID
10640
6557
  * @returns { Merchant } Merchant data
10641
6558
  */
10642
- Merchants.prototype.getMerchantData = function (_a) {
10643
- return __awaiter(this, arguments, void 0, function (_b) {
6559
+ Merchants.prototype.getMerchantData = function () {
6560
+ return __awaiter(this, void 0, void 0, function () {
10644
6561
  var response, error_4;
10645
- var merchantId = _b.merchantId;
10646
- return __generator(this, function (_c) {
10647
- switch (_c.label) {
6562
+ return __generator(this, function (_a) {
6563
+ switch (_a.label) {
10648
6564
  case 0:
10649
- _c.trys.push([0, 2, , 3]);
6565
+ _a.trys.push([0, 2, , 3]);
10650
6566
  return [4 /*yield*/, this.request(MerchantsRoutes.getMerchantData, {
10651
6567
  method: MerchantsRoutes.getMerchantData.method,
10652
- payload: { merchantId: merchantId },
6568
+ payload: { merchantId: this.merchantId },
10653
6569
  })];
10654
6570
  case 1:
10655
- response = _c.sent();
6571
+ response = _a.sent();
10656
6572
  if (!response || response.error) {
10657
6573
  throw new Error(response.error);
10658
6574
  }
10659
6575
  return [2 /*return*/, response];
10660
6576
  case 2:
10661
- error_4 = _c.sent();
10662
- logger('SDK::Merchants::list::error', error_4);
6577
+ error_4 = _a.sent();
6578
+ logger.error('SDK::Merchants::list::error', error_4);
10663
6579
  return [2 /*return*/, Promise.reject(error_4)];
10664
6580
  case 3: return [2 /*return*/];
10665
6581
  }
@@ -10672,27 +6588,26 @@ var Merchants = /** @class */ (function (_super) {
10672
6588
  * @param merchantId Merchant ID
10673
6589
  * @returns { MerchantAsset[] } List of merchant assets
10674
6590
  */
10675
- Merchants.prototype.getAssets = function (_a) {
10676
- return __awaiter(this, arguments, void 0, function (_b) {
6591
+ Merchants.prototype.getAssets = function () {
6592
+ return __awaiter(this, void 0, void 0, function () {
10677
6593
  var response, error_5;
10678
- var merchantId = _b.merchantId;
10679
- return __generator(this, function (_c) {
10680
- switch (_c.label) {
6594
+ return __generator(this, function (_a) {
6595
+ switch (_a.label) {
10681
6596
  case 0:
10682
- _c.trys.push([0, 2, , 3]);
6597
+ _a.trys.push([0, 2, , 3]);
10683
6598
  return [4 /*yield*/, this.request(MerchantsRoutes.getAssets, {
10684
6599
  method: MerchantsRoutes.getAssets.method,
10685
- payload: { merchantId: merchantId },
6600
+ payload: { merchantId: this.merchantId },
10686
6601
  })];
10687
6602
  case 1:
10688
- response = _c.sent();
6603
+ response = _a.sent();
10689
6604
  if (!response || response.error) {
10690
6605
  throw new Error(response.error);
10691
6606
  }
10692
6607
  return [2 /*return*/, response];
10693
6608
  case 2:
10694
- error_5 = _c.sent();
10695
- logger('SDK::Merchants::list::error', error_5);
6609
+ error_5 = _a.sent();
6610
+ logger.error('SDK::Merchants::list::error', error_5);
10696
6611
  return [2 /*return*/, Promise.reject(error_5)];
10697
6612
  case 3: return [2 /*return*/];
10698
6613
  }
@@ -10702,14 +6617,14 @@ var Merchants = /** @class */ (function (_super) {
10702
6617
  Merchants.prototype.addAsset = function (_a) {
10703
6618
  return __awaiter(this, arguments, void 0, function (_b) {
10704
6619
  var response, error_6;
10705
- var merchantId = _b.merchantId, configId = _b.configId;
6620
+ var configId = _b.configId;
10706
6621
  return __generator(this, function (_c) {
10707
6622
  switch (_c.label) {
10708
6623
  case 0:
10709
6624
  _c.trys.push([0, 2, , 3]);
10710
6625
  return [4 /*yield*/, this.request(MerchantsRoutes.addAsset, {
10711
6626
  method: MerchantsRoutes.addAsset.method,
10712
- payload: { merchantId: merchantId, configId: configId },
6627
+ payload: { merchantId: this.merchantId, configId: configId },
10713
6628
  })];
10714
6629
  case 1:
10715
6630
  response = _c.sent();
@@ -10719,7 +6634,7 @@ var Merchants = /** @class */ (function (_super) {
10719
6634
  return [2 /*return*/, response];
10720
6635
  case 2:
10721
6636
  error_6 = _c.sent();
10722
- logger('SDK::Merchants::list::error', error_6);
6637
+ logger.error('SDK::Merchants::list::error', error_6);
10723
6638
  return [2 /*return*/, Promise.reject(error_6)];
10724
6639
  case 3: return [2 /*return*/];
10725
6640
  }
@@ -10729,14 +6644,14 @@ var Merchants = /** @class */ (function (_super) {
10729
6644
  Merchants.prototype.deleteAsset = function (_a) {
10730
6645
  return __awaiter(this, arguments, void 0, function (_b) {
10731
6646
  var response, error_7;
10732
- var merchantId = _b.merchantId, configId = _b.configId;
6647
+ var configId = _b.configId;
10733
6648
  return __generator(this, function (_c) {
10734
6649
  switch (_c.label) {
10735
6650
  case 0:
10736
6651
  _c.trys.push([0, 2, , 3]);
10737
6652
  return [4 /*yield*/, this.request(MerchantsRoutes.deleteAsset, {
10738
6653
  method: MerchantsRoutes.deleteAsset.method,
10739
- payload: { merchantId: merchantId, configId: configId },
6654
+ payload: { merchantId: this.merchantId, configId: configId },
10740
6655
  })];
10741
6656
  case 1:
10742
6657
  response = _c.sent();
@@ -10746,13 +6661,30 @@ var Merchants = /** @class */ (function (_super) {
10746
6661
  return [2 /*return*/, response];
10747
6662
  case 2:
10748
6663
  error_7 = _c.sent();
10749
- logger('SDK::Merchants::list::error', error_7);
6664
+ logger.error('SDK::Merchants::list::error', error_7);
10750
6665
  return [2 /*return*/, Promise.reject(error_7)];
10751
6666
  case 3: return [2 /*return*/];
10752
6667
  }
10753
6668
  });
10754
6669
  });
10755
6670
  };
6671
+ Merchants.prototype.getMerchantId = function () {
6672
+ return __awaiter(this, void 0, void 0, function () {
6673
+ var accessToken, decodedToken;
6674
+ return __generator(this, function (_a) {
6675
+ switch (_a.label) {
6676
+ case 0: return [4 /*yield*/, this.storageService.getAccessToken()];
6677
+ case 1:
6678
+ accessToken = _a.sent();
6679
+ if (!accessToken) {
6680
+ throw new Error('You are not authorized to perform this action, please sign in to continue');
6681
+ }
6682
+ decodedToken = jwtDecode.jwtDecode(accessToken);
6683
+ return [2 /*return*/, decodedToken.aud];
6684
+ }
6685
+ });
6686
+ });
6687
+ };
10756
6688
  return Merchants;
10757
6689
  }(Base));
10758
6690
 
@@ -10774,23 +6706,19 @@ var System = /** @class */ (function (_super) {
10774
6706
  switch (_a.label) {
10775
6707
  case 0:
10776
6708
  _a.trys.push([0, 2, , 3]);
10777
- logger('SDK::System::getSupportedBlockchains:: before response');
10778
6709
  return [4 /*yield*/, this.request(SystemRoutes.getSupportedBlockchains, {
10779
6710
  method: SystemRoutes.getSupportedBlockchains.method,
10780
6711
  payload: {},
10781
6712
  })];
10782
6713
  case 1:
10783
6714
  response = _a.sent();
10784
- logger('SDK::System::getSupportedBlockchains::response', response);
10785
6715
  if (!response || response.error) {
10786
- logger('SDK::System::getSupportedBlockchains::no response');
10787
- // logger('SDK::System::getSupportedBlockchains::response.error', response.error);
10788
6716
  throw new Error('There is no response');
10789
6717
  }
10790
6718
  return [2 /*return*/, response.chains];
10791
6719
  case 2:
10792
6720
  error_1 = _a.sent();
10793
- logger('SDK::System::getSupportedBlockchains::error', error_1);
6721
+ logger.error('SDK::System::getSupportedBlockchains::error', error_1);
10794
6722
  return [2 /*return*/, Promise.reject(error_1)];
10795
6723
  case 3: return [2 /*return*/];
10796
6724
  }
@@ -10879,7 +6807,7 @@ var System = /** @class */ (function (_super) {
10879
6807
  return [2 /*return*/, response];
10880
6808
  case 2:
10881
6809
  error_2 = _c.sent();
10882
- logger('SDK::Wallet::fetchTokenInfo::error', error_2);
6810
+ logger.error('SDK::Wallet::fetchTokenInfo::error', error_2);
10883
6811
  return [2 /*return*/, Promise.reject(error_2)];
10884
6812
  case 3: return [2 /*return*/];
10885
6813
  }
@@ -10911,7 +6839,7 @@ var System = /** @class */ (function (_super) {
10911
6839
  return [2 /*return*/, response.assets];
10912
6840
  case 2:
10913
6841
  error_3 = _a.sent();
10914
- logger('SDK::System::getSupportedTokens::error', error_3);
6842
+ logger.error('SDK::System::getSupportedTokens::error', error_3);
10915
6843
  return [2 /*return*/, Promise.reject(error_3)];
10916
6844
  case 3: return [2 /*return*/];
10917
6845
  }
@@ -10942,7 +6870,7 @@ var System = /** @class */ (function (_super) {
10942
6870
  return [2 /*return*/, response.user];
10943
6871
  case 2:
10944
6872
  error_4 = _a.sent();
10945
- logger('SDK::System::getUserData::error', error_4);
6873
+ logger.error('SDK::System::getUserData::error', error_4);
10946
6874
  return [2 /*return*/, Promise.reject(error_4)];
10947
6875
  case 3: return [2 /*return*/];
10948
6876
  }
@@ -10974,7 +6902,7 @@ var System = /** @class */ (function (_super) {
10974
6902
  return [2 /*return*/, response.user];
10975
6903
  case 2:
10976
6904
  error_5 = _a.sent();
10977
- logger('SDK::System::getUserByExternalUserId::error', error_5);
6905
+ logger.error('SDK::System::getUserByExternalUserId::error', error_5);
10978
6906
  return [2 /*return*/, Promise.reject(error_5)];
10979
6907
  case 3: return [2 /*return*/];
10980
6908
  }
@@ -11061,7 +6989,7 @@ var Transactions = /** @class */ (function (_super) {
11061
6989
  return [2 /*return*/, response];
11062
6990
  case 2:
11063
6991
  error_1 = _c.sent();
11064
- logger('SDK::Transactions::estimateFee::error', error_1);
6992
+ logger.error('SDK::Transactions::estimateFee::error', error_1);
11065
6993
  return [2 /*return*/, Promise.reject(error_1)];
11066
6994
  case 3: return [2 /*return*/];
11067
6995
  }
@@ -11118,7 +7046,7 @@ var Transactions = /** @class */ (function (_super) {
11118
7046
  return [2 /*return*/, response];
11119
7047
  case 4:
11120
7048
  error_2 = _c.sent();
11121
- logger('SDK::Transactions::transfer::error', error_2);
7049
+ logger.error('SDK::Transactions::transfer::error', error_2);
11122
7050
  return [2 /*return*/, Promise.reject(error_2)];
11123
7051
  case 5: return [2 /*return*/];
11124
7052
  }
@@ -11157,7 +7085,7 @@ var Transactions = /** @class */ (function (_super) {
11157
7085
  return [2 /*return*/, response];
11158
7086
  case 2:
11159
7087
  error_3 = _c.sent();
11160
- logger('SDK::Transactions::getTransactionStatus::error', error_3);
7088
+ logger.error('SDK::Transactions::getTransactionStatus::error', error_3);
11161
7089
  return [2 /*return*/, Promise.reject(error_3)];
11162
7090
  case 3: return [2 /*return*/];
11163
7091
  }
@@ -11196,7 +7124,7 @@ var Transactions = /** @class */ (function (_super) {
11196
7124
  return [2 /*return*/, response];
11197
7125
  case 2:
11198
7126
  error_4 = _c.sent();
11199
- logger('SDK::Transactions::getTransactions::error', error_4);
7127
+ logger.error('SDK::Transactions::getTransactions::error', error_4);
11200
7128
  return [2 /*return*/, Promise.reject(error_4)];
11201
7129
  case 3: return [2 /*return*/];
11202
7130
  }
@@ -11260,7 +7188,7 @@ var Transactions = /** @class */ (function (_super) {
11260
7188
  return [2 /*return*/, response];
11261
7189
  case 4:
11262
7190
  error_5 = _c.sent();
11263
- logger('SDK::Transactions::createAllowance::error', error_5);
7191
+ logger.error('SDK::Transactions::createAllowance::error', error_5);
11264
7192
  return [2 /*return*/, Promise.reject(error_5)];
11265
7193
  case 5: return [2 /*return*/];
11266
7194
  }