@solana/web3.js 1.69.0 → 1.70.0-pr-29130

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/lib/index.esm.js CHANGED
@@ -8,11 +8,16 @@ import { serialize, deserialize, deserializeUnchecked } from 'borsh';
8
8
  import * as BufferLayout from '@solana/buffer-layout';
9
9
  import { blob } from '@solana/buffer-layout';
10
10
  import { toBigIntLE, toBufferLE } from 'bigint-buffer';
11
+ import require$$1 from 'tty';
12
+ import require$$0$1 from 'os';
13
+ import require$$0 from 'util';
14
+ import require$$0$2 from 'events';
15
+ import require$$1$1 from 'path';
16
+ import require$$0$3 from 'http';
17
+ import require$$0$4, { Agent as Agent$2 } from 'https';
11
18
  import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$1 } from 'superstruct';
12
19
  import { Client } from 'rpc-websockets';
13
20
  import RpcClient from 'jayson/lib/client/browser';
14
- import http from 'http';
15
- import https from 'https';
16
21
  import * as nodeFetch from 'node-fetch';
17
22
  import { keccak_256 } from '@noble/hashes/sha3';
18
23
  import { hmac } from '@noble/hashes/hmac';
@@ -3293,6 +3298,2596 @@ class BpfLoader {
3293
3298
 
3294
3299
  }
3295
3300
 
3301
+ function getDefaultExportFromCjs (x) {
3302
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3303
+ }
3304
+
3305
+ var agentkeepalive = {exports: {}};
3306
+
3307
+ /**
3308
+ * Helpers.
3309
+ */
3310
+
3311
+ var s = 1000;
3312
+ var m = s * 60;
3313
+ var h = m * 60;
3314
+ var d = h * 24;
3315
+ var w = d * 7;
3316
+ var y = d * 365.25;
3317
+
3318
+ /**
3319
+ * Parse or format the given `val`.
3320
+ *
3321
+ * Options:
3322
+ *
3323
+ * - `long` verbose formatting [false]
3324
+ *
3325
+ * @param {String|Number} val
3326
+ * @param {Object} [options]
3327
+ * @throws {Error} throw an error if val is not a non-empty string or a number
3328
+ * @return {String|Number}
3329
+ * @api public
3330
+ */
3331
+
3332
+ var ms$3 = function (val, options) {
3333
+ options = options || {};
3334
+ var type = typeof val;
3335
+ if (type === 'string' && val.length > 0) {
3336
+ return parse(val);
3337
+ } else if (type === 'number' && isFinite(val)) {
3338
+ return options.long ? fmtLong(val) : fmtShort(val);
3339
+ }
3340
+ throw new Error(
3341
+ 'val is not a non-empty string or a valid number. val=' +
3342
+ JSON.stringify(val)
3343
+ );
3344
+ };
3345
+
3346
+ /**
3347
+ * Parse the given `str` and return milliseconds.
3348
+ *
3349
+ * @param {String} str
3350
+ * @return {Number}
3351
+ * @api private
3352
+ */
3353
+
3354
+ function parse(str) {
3355
+ str = String(str);
3356
+ if (str.length > 100) {
3357
+ return;
3358
+ }
3359
+ 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(
3360
+ str
3361
+ );
3362
+ if (!match) {
3363
+ return;
3364
+ }
3365
+ var n = parseFloat(match[1]);
3366
+ var type = (match[2] || 'ms').toLowerCase();
3367
+ switch (type) {
3368
+ case 'years':
3369
+ case 'year':
3370
+ case 'yrs':
3371
+ case 'yr':
3372
+ case 'y':
3373
+ return n * y;
3374
+ case 'weeks':
3375
+ case 'week':
3376
+ case 'w':
3377
+ return n * w;
3378
+ case 'days':
3379
+ case 'day':
3380
+ case 'd':
3381
+ return n * d;
3382
+ case 'hours':
3383
+ case 'hour':
3384
+ case 'hrs':
3385
+ case 'hr':
3386
+ case 'h':
3387
+ return n * h;
3388
+ case 'minutes':
3389
+ case 'minute':
3390
+ case 'mins':
3391
+ case 'min':
3392
+ case 'm':
3393
+ return n * m;
3394
+ case 'seconds':
3395
+ case 'second':
3396
+ case 'secs':
3397
+ case 'sec':
3398
+ case 's':
3399
+ return n * s;
3400
+ case 'milliseconds':
3401
+ case 'millisecond':
3402
+ case 'msecs':
3403
+ case 'msec':
3404
+ case 'ms':
3405
+ return n;
3406
+ default:
3407
+ return undefined;
3408
+ }
3409
+ }
3410
+
3411
+ /**
3412
+ * Short format for `ms`.
3413
+ *
3414
+ * @param {Number} ms
3415
+ * @return {String}
3416
+ * @api private
3417
+ */
3418
+
3419
+ function fmtShort(ms) {
3420
+ var msAbs = Math.abs(ms);
3421
+ if (msAbs >= d) {
3422
+ return Math.round(ms / d) + 'd';
3423
+ }
3424
+ if (msAbs >= h) {
3425
+ return Math.round(ms / h) + 'h';
3426
+ }
3427
+ if (msAbs >= m) {
3428
+ return Math.round(ms / m) + 'm';
3429
+ }
3430
+ if (msAbs >= s) {
3431
+ return Math.round(ms / s) + 's';
3432
+ }
3433
+ return ms + 'ms';
3434
+ }
3435
+
3436
+ /**
3437
+ * Long format for `ms`.
3438
+ *
3439
+ * @param {Number} ms
3440
+ * @return {String}
3441
+ * @api private
3442
+ */
3443
+
3444
+ function fmtLong(ms) {
3445
+ var msAbs = Math.abs(ms);
3446
+ if (msAbs >= d) {
3447
+ return plural(ms, msAbs, d, 'day');
3448
+ }
3449
+ if (msAbs >= h) {
3450
+ return plural(ms, msAbs, h, 'hour');
3451
+ }
3452
+ if (msAbs >= m) {
3453
+ return plural(ms, msAbs, m, 'minute');
3454
+ }
3455
+ if (msAbs >= s) {
3456
+ return plural(ms, msAbs, s, 'second');
3457
+ }
3458
+ return ms + ' ms';
3459
+ }
3460
+
3461
+ /**
3462
+ * Pluralization helper.
3463
+ */
3464
+
3465
+ function plural(ms, msAbs, n, name) {
3466
+ var isPlural = msAbs >= n * 1.5;
3467
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
3468
+ }
3469
+
3470
+ /*!
3471
+ * humanize-ms - index.js
3472
+ * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
3473
+ * MIT Licensed
3474
+ */
3475
+
3476
+ /**
3477
+ * Module dependencies.
3478
+ */
3479
+
3480
+ var util = require$$0;
3481
+ var ms$2 = ms$3;
3482
+
3483
+ var humanizeMs = function (t) {
3484
+ if (typeof t === 'number') return t;
3485
+ var r = ms$2(t);
3486
+ if (r === undefined) {
3487
+ var err = new Error(util.format('humanize-ms(%j) result undefined', t));
3488
+ console.warn(err.stack);
3489
+ }
3490
+ return r;
3491
+ };
3492
+
3493
+ var src = {exports: {}};
3494
+
3495
+ var browser = {exports: {}};
3496
+
3497
+ /**
3498
+ * Helpers.
3499
+ */
3500
+
3501
+ var ms$1;
3502
+ var hasRequiredMs;
3503
+
3504
+ function requireMs () {
3505
+ if (hasRequiredMs) return ms$1;
3506
+ hasRequiredMs = 1;
3507
+ var s = 1000;
3508
+ var m = s * 60;
3509
+ var h = m * 60;
3510
+ var d = h * 24;
3511
+ var w = d * 7;
3512
+ var y = d * 365.25;
3513
+
3514
+ /**
3515
+ * Parse or format the given `val`.
3516
+ *
3517
+ * Options:
3518
+ *
3519
+ * - `long` verbose formatting [false]
3520
+ *
3521
+ * @param {String|Number} val
3522
+ * @param {Object} [options]
3523
+ * @throws {Error} throw an error if val is not a non-empty string or a number
3524
+ * @return {String|Number}
3525
+ * @api public
3526
+ */
3527
+
3528
+ ms$1 = function(val, options) {
3529
+ options = options || {};
3530
+ var type = typeof val;
3531
+ if (type === 'string' && val.length > 0) {
3532
+ return parse(val);
3533
+ } else if (type === 'number' && isFinite(val)) {
3534
+ return options.long ? fmtLong(val) : fmtShort(val);
3535
+ }
3536
+ throw new Error(
3537
+ 'val is not a non-empty string or a valid number. val=' +
3538
+ JSON.stringify(val)
3539
+ );
3540
+ };
3541
+
3542
+ /**
3543
+ * Parse the given `str` and return milliseconds.
3544
+ *
3545
+ * @param {String} str
3546
+ * @return {Number}
3547
+ * @api private
3548
+ */
3549
+
3550
+ function parse(str) {
3551
+ str = String(str);
3552
+ if (str.length > 100) {
3553
+ return;
3554
+ }
3555
+ 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(
3556
+ str
3557
+ );
3558
+ if (!match) {
3559
+ return;
3560
+ }
3561
+ var n = parseFloat(match[1]);
3562
+ var type = (match[2] || 'ms').toLowerCase();
3563
+ switch (type) {
3564
+ case 'years':
3565
+ case 'year':
3566
+ case 'yrs':
3567
+ case 'yr':
3568
+ case 'y':
3569
+ return n * y;
3570
+ case 'weeks':
3571
+ case 'week':
3572
+ case 'w':
3573
+ return n * w;
3574
+ case 'days':
3575
+ case 'day':
3576
+ case 'd':
3577
+ return n * d;
3578
+ case 'hours':
3579
+ case 'hour':
3580
+ case 'hrs':
3581
+ case 'hr':
3582
+ case 'h':
3583
+ return n * h;
3584
+ case 'minutes':
3585
+ case 'minute':
3586
+ case 'mins':
3587
+ case 'min':
3588
+ case 'm':
3589
+ return n * m;
3590
+ case 'seconds':
3591
+ case 'second':
3592
+ case 'secs':
3593
+ case 'sec':
3594
+ case 's':
3595
+ return n * s;
3596
+ case 'milliseconds':
3597
+ case 'millisecond':
3598
+ case 'msecs':
3599
+ case 'msec':
3600
+ case 'ms':
3601
+ return n;
3602
+ default:
3603
+ return undefined;
3604
+ }
3605
+ }
3606
+
3607
+ /**
3608
+ * Short format for `ms`.
3609
+ *
3610
+ * @param {Number} ms
3611
+ * @return {String}
3612
+ * @api private
3613
+ */
3614
+
3615
+ function fmtShort(ms) {
3616
+ var msAbs = Math.abs(ms);
3617
+ if (msAbs >= d) {
3618
+ return Math.round(ms / d) + 'd';
3619
+ }
3620
+ if (msAbs >= h) {
3621
+ return Math.round(ms / h) + 'h';
3622
+ }
3623
+ if (msAbs >= m) {
3624
+ return Math.round(ms / m) + 'm';
3625
+ }
3626
+ if (msAbs >= s) {
3627
+ return Math.round(ms / s) + 's';
3628
+ }
3629
+ return ms + 'ms';
3630
+ }
3631
+
3632
+ /**
3633
+ * Long format for `ms`.
3634
+ *
3635
+ * @param {Number} ms
3636
+ * @return {String}
3637
+ * @api private
3638
+ */
3639
+
3640
+ function fmtLong(ms) {
3641
+ var msAbs = Math.abs(ms);
3642
+ if (msAbs >= d) {
3643
+ return plural(ms, msAbs, d, 'day');
3644
+ }
3645
+ if (msAbs >= h) {
3646
+ return plural(ms, msAbs, h, 'hour');
3647
+ }
3648
+ if (msAbs >= m) {
3649
+ return plural(ms, msAbs, m, 'minute');
3650
+ }
3651
+ if (msAbs >= s) {
3652
+ return plural(ms, msAbs, s, 'second');
3653
+ }
3654
+ return ms + ' ms';
3655
+ }
3656
+
3657
+ /**
3658
+ * Pluralization helper.
3659
+ */
3660
+
3661
+ function plural(ms, msAbs, n, name) {
3662
+ var isPlural = msAbs >= n * 1.5;
3663
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
3664
+ }
3665
+ return ms$1;
3666
+ }
3667
+
3668
+ var common;
3669
+ var hasRequiredCommon;
3670
+
3671
+ function requireCommon () {
3672
+ if (hasRequiredCommon) return common;
3673
+ hasRequiredCommon = 1;
3674
+ /**
3675
+ * This is the common logic for both the Node.js and web browser
3676
+ * implementations of `debug()`.
3677
+ */
3678
+
3679
+ function setup(env) {
3680
+ createDebug.debug = createDebug;
3681
+ createDebug.default = createDebug;
3682
+ createDebug.coerce = coerce;
3683
+ createDebug.disable = disable;
3684
+ createDebug.enable = enable;
3685
+ createDebug.enabled = enabled;
3686
+ createDebug.humanize = requireMs();
3687
+ createDebug.destroy = destroy;
3688
+
3689
+ Object.keys(env).forEach(key => {
3690
+ createDebug[key] = env[key];
3691
+ });
3692
+
3693
+ /**
3694
+ * The currently active debug mode names, and names to skip.
3695
+ */
3696
+
3697
+ createDebug.names = [];
3698
+ createDebug.skips = [];
3699
+
3700
+ /**
3701
+ * Map of special "%n" handling functions, for the debug "format" argument.
3702
+ *
3703
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3704
+ */
3705
+ createDebug.formatters = {};
3706
+
3707
+ /**
3708
+ * Selects a color for a debug namespace
3709
+ * @param {String} namespace The namespace string for the debug instance to be colored
3710
+ * @return {Number|String} An ANSI color code for the given namespace
3711
+ * @api private
3712
+ */
3713
+ function selectColor(namespace) {
3714
+ let hash = 0;
3715
+
3716
+ for (let i = 0; i < namespace.length; i++) {
3717
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
3718
+ hash |= 0; // Convert to 32bit integer
3719
+ }
3720
+
3721
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
3722
+ }
3723
+ createDebug.selectColor = selectColor;
3724
+
3725
+ /**
3726
+ * Create a debugger with the given `namespace`.
3727
+ *
3728
+ * @param {String} namespace
3729
+ * @return {Function}
3730
+ * @api public
3731
+ */
3732
+ function createDebug(namespace) {
3733
+ let prevTime;
3734
+ let enableOverride = null;
3735
+ let namespacesCache;
3736
+ let enabledCache;
3737
+
3738
+ function debug(...args) {
3739
+ // Disabled?
3740
+ if (!debug.enabled) {
3741
+ return;
3742
+ }
3743
+
3744
+ const self = debug;
3745
+
3746
+ // Set `diff` timestamp
3747
+ const curr = Number(new Date());
3748
+ const ms = curr - (prevTime || curr);
3749
+ self.diff = ms;
3750
+ self.prev = prevTime;
3751
+ self.curr = curr;
3752
+ prevTime = curr;
3753
+
3754
+ args[0] = createDebug.coerce(args[0]);
3755
+
3756
+ if (typeof args[0] !== 'string') {
3757
+ // Anything else let's inspect with %O
3758
+ args.unshift('%O');
3759
+ }
3760
+
3761
+ // Apply any `formatters` transformations
3762
+ let index = 0;
3763
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
3764
+ // If we encounter an escaped % then don't increase the array index
3765
+ if (match === '%%') {
3766
+ return '%';
3767
+ }
3768
+ index++;
3769
+ const formatter = createDebug.formatters[format];
3770
+ if (typeof formatter === 'function') {
3771
+ const val = args[index];
3772
+ match = formatter.call(self, val);
3773
+
3774
+ // Now we need to remove `args[index]` since it's inlined in the `format`
3775
+ args.splice(index, 1);
3776
+ index--;
3777
+ }
3778
+ return match;
3779
+ });
3780
+
3781
+ // Apply env-specific formatting (colors, etc.)
3782
+ createDebug.formatArgs.call(self, args);
3783
+
3784
+ const logFn = self.log || createDebug.log;
3785
+ logFn.apply(self, args);
3786
+ }
3787
+
3788
+ debug.namespace = namespace;
3789
+ debug.useColors = createDebug.useColors();
3790
+ debug.color = createDebug.selectColor(namespace);
3791
+ debug.extend = extend;
3792
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
3793
+
3794
+ Object.defineProperty(debug, 'enabled', {
3795
+ enumerable: true,
3796
+ configurable: false,
3797
+ get: () => {
3798
+ if (enableOverride !== null) {
3799
+ return enableOverride;
3800
+ }
3801
+ if (namespacesCache !== createDebug.namespaces) {
3802
+ namespacesCache = createDebug.namespaces;
3803
+ enabledCache = createDebug.enabled(namespace);
3804
+ }
3805
+
3806
+ return enabledCache;
3807
+ },
3808
+ set: v => {
3809
+ enableOverride = v;
3810
+ }
3811
+ });
3812
+
3813
+ // Env-specific initialization logic for debug instances
3814
+ if (typeof createDebug.init === 'function') {
3815
+ createDebug.init(debug);
3816
+ }
3817
+
3818
+ return debug;
3819
+ }
3820
+
3821
+ function extend(namespace, delimiter) {
3822
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
3823
+ newDebug.log = this.log;
3824
+ return newDebug;
3825
+ }
3826
+
3827
+ /**
3828
+ * Enables a debug mode by namespaces. This can include modes
3829
+ * separated by a colon and wildcards.
3830
+ *
3831
+ * @param {String} namespaces
3832
+ * @api public
3833
+ */
3834
+ function enable(namespaces) {
3835
+ createDebug.save(namespaces);
3836
+ createDebug.namespaces = namespaces;
3837
+
3838
+ createDebug.names = [];
3839
+ createDebug.skips = [];
3840
+
3841
+ let i;
3842
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
3843
+ const len = split.length;
3844
+
3845
+ for (i = 0; i < len; i++) {
3846
+ if (!split[i]) {
3847
+ // ignore empty strings
3848
+ continue;
3849
+ }
3850
+
3851
+ namespaces = split[i].replace(/\*/g, '.*?');
3852
+
3853
+ if (namespaces[0] === '-') {
3854
+ createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
3855
+ } else {
3856
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
3857
+ }
3858
+ }
3859
+ }
3860
+
3861
+ /**
3862
+ * Disable debug output.
3863
+ *
3864
+ * @return {String} namespaces
3865
+ * @api public
3866
+ */
3867
+ function disable() {
3868
+ const namespaces = [
3869
+ ...createDebug.names.map(toNamespace),
3870
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
3871
+ ].join(',');
3872
+ createDebug.enable('');
3873
+ return namespaces;
3874
+ }
3875
+
3876
+ /**
3877
+ * Returns true if the given mode name is enabled, false otherwise.
3878
+ *
3879
+ * @param {String} name
3880
+ * @return {Boolean}
3881
+ * @api public
3882
+ */
3883
+ function enabled(name) {
3884
+ if (name[name.length - 1] === '*') {
3885
+ return true;
3886
+ }
3887
+
3888
+ let i;
3889
+ let len;
3890
+
3891
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
3892
+ if (createDebug.skips[i].test(name)) {
3893
+ return false;
3894
+ }
3895
+ }
3896
+
3897
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
3898
+ if (createDebug.names[i].test(name)) {
3899
+ return true;
3900
+ }
3901
+ }
3902
+
3903
+ return false;
3904
+ }
3905
+
3906
+ /**
3907
+ * Convert regexp to namespace
3908
+ *
3909
+ * @param {RegExp} regxep
3910
+ * @return {String} namespace
3911
+ * @api private
3912
+ */
3913
+ function toNamespace(regexp) {
3914
+ return regexp.toString()
3915
+ .substring(2, regexp.toString().length - 2)
3916
+ .replace(/\.\*\?$/, '*');
3917
+ }
3918
+
3919
+ /**
3920
+ * Coerce `val`.
3921
+ *
3922
+ * @param {Mixed} val
3923
+ * @return {Mixed}
3924
+ * @api private
3925
+ */
3926
+ function coerce(val) {
3927
+ if (val instanceof Error) {
3928
+ return val.stack || val.message;
3929
+ }
3930
+ return val;
3931
+ }
3932
+
3933
+ /**
3934
+ * XXX DO NOT USE. This is a temporary stub function.
3935
+ * XXX It WILL be removed in the next major release.
3936
+ */
3937
+ function destroy() {
3938
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
3939
+ }
3940
+
3941
+ createDebug.enable(createDebug.load());
3942
+
3943
+ return createDebug;
3944
+ }
3945
+
3946
+ common = setup;
3947
+ return common;
3948
+ }
3949
+
3950
+ /* eslint-env browser */
3951
+
3952
+ var hasRequiredBrowser;
3953
+
3954
+ function requireBrowser () {
3955
+ if (hasRequiredBrowser) return browser.exports;
3956
+ hasRequiredBrowser = 1;
3957
+ (function (module, exports) {
3958
+ /**
3959
+ * This is the web browser implementation of `debug()`.
3960
+ */
3961
+
3962
+ exports.formatArgs = formatArgs;
3963
+ exports.save = save;
3964
+ exports.load = load;
3965
+ exports.useColors = useColors;
3966
+ exports.storage = localstorage();
3967
+ exports.destroy = (() => {
3968
+ let warned = false;
3969
+
3970
+ return () => {
3971
+ if (!warned) {
3972
+ warned = true;
3973
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
3974
+ }
3975
+ };
3976
+ })();
3977
+
3978
+ /**
3979
+ * Colors.
3980
+ */
3981
+
3982
+ exports.colors = [
3983
+ '#0000CC',
3984
+ '#0000FF',
3985
+ '#0033CC',
3986
+ '#0033FF',
3987
+ '#0066CC',
3988
+ '#0066FF',
3989
+ '#0099CC',
3990
+ '#0099FF',
3991
+ '#00CC00',
3992
+ '#00CC33',
3993
+ '#00CC66',
3994
+ '#00CC99',
3995
+ '#00CCCC',
3996
+ '#00CCFF',
3997
+ '#3300CC',
3998
+ '#3300FF',
3999
+ '#3333CC',
4000
+ '#3333FF',
4001
+ '#3366CC',
4002
+ '#3366FF',
4003
+ '#3399CC',
4004
+ '#3399FF',
4005
+ '#33CC00',
4006
+ '#33CC33',
4007
+ '#33CC66',
4008
+ '#33CC99',
4009
+ '#33CCCC',
4010
+ '#33CCFF',
4011
+ '#6600CC',
4012
+ '#6600FF',
4013
+ '#6633CC',
4014
+ '#6633FF',
4015
+ '#66CC00',
4016
+ '#66CC33',
4017
+ '#9900CC',
4018
+ '#9900FF',
4019
+ '#9933CC',
4020
+ '#9933FF',
4021
+ '#99CC00',
4022
+ '#99CC33',
4023
+ '#CC0000',
4024
+ '#CC0033',
4025
+ '#CC0066',
4026
+ '#CC0099',
4027
+ '#CC00CC',
4028
+ '#CC00FF',
4029
+ '#CC3300',
4030
+ '#CC3333',
4031
+ '#CC3366',
4032
+ '#CC3399',
4033
+ '#CC33CC',
4034
+ '#CC33FF',
4035
+ '#CC6600',
4036
+ '#CC6633',
4037
+ '#CC9900',
4038
+ '#CC9933',
4039
+ '#CCCC00',
4040
+ '#CCCC33',
4041
+ '#FF0000',
4042
+ '#FF0033',
4043
+ '#FF0066',
4044
+ '#FF0099',
4045
+ '#FF00CC',
4046
+ '#FF00FF',
4047
+ '#FF3300',
4048
+ '#FF3333',
4049
+ '#FF3366',
4050
+ '#FF3399',
4051
+ '#FF33CC',
4052
+ '#FF33FF',
4053
+ '#FF6600',
4054
+ '#FF6633',
4055
+ '#FF9900',
4056
+ '#FF9933',
4057
+ '#FFCC00',
4058
+ '#FFCC33'
4059
+ ];
4060
+
4061
+ /**
4062
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
4063
+ * and the Firebug extension (any Firefox version) are known
4064
+ * to support "%c" CSS customizations.
4065
+ *
4066
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
4067
+ */
4068
+
4069
+ // eslint-disable-next-line complexity
4070
+ function useColors() {
4071
+ // NB: In an Electron preload script, document will be defined but not fully
4072
+ // initialized. Since we know we're in Chrome, we'll just detect this case
4073
+ // explicitly
4074
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
4075
+ return true;
4076
+ }
4077
+
4078
+ // Internet Explorer and Edge do not support colors.
4079
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
4080
+ return false;
4081
+ }
4082
+
4083
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
4084
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
4085
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
4086
+ // Is firebug? http://stackoverflow.com/a/398120/376773
4087
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
4088
+ // Is firefox >= v31?
4089
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
4090
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
4091
+ // Double check webkit in userAgent just in case we are in a worker
4092
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
4093
+ }
4094
+
4095
+ /**
4096
+ * Colorize log arguments if enabled.
4097
+ *
4098
+ * @api public
4099
+ */
4100
+
4101
+ function formatArgs(args) {
4102
+ args[0] = (this.useColors ? '%c' : '') +
4103
+ this.namespace +
4104
+ (this.useColors ? ' %c' : ' ') +
4105
+ args[0] +
4106
+ (this.useColors ? '%c ' : ' ') +
4107
+ '+' + module.exports.humanize(this.diff);
4108
+
4109
+ if (!this.useColors) {
4110
+ return;
4111
+ }
4112
+
4113
+ const c = 'color: ' + this.color;
4114
+ args.splice(1, 0, c, 'color: inherit');
4115
+
4116
+ // The final "%c" is somewhat tricky, because there could be other
4117
+ // arguments passed either before or after the %c, so we need to
4118
+ // figure out the correct index to insert the CSS into
4119
+ let index = 0;
4120
+ let lastC = 0;
4121
+ args[0].replace(/%[a-zA-Z%]/g, match => {
4122
+ if (match === '%%') {
4123
+ return;
4124
+ }
4125
+ index++;
4126
+ if (match === '%c') {
4127
+ // We only are interested in the *last* %c
4128
+ // (the user may have provided their own)
4129
+ lastC = index;
4130
+ }
4131
+ });
4132
+
4133
+ args.splice(lastC, 0, c);
4134
+ }
4135
+
4136
+ /**
4137
+ * Invokes `console.debug()` when available.
4138
+ * No-op when `console.debug` is not a "function".
4139
+ * If `console.debug` is not available, falls back
4140
+ * to `console.log`.
4141
+ *
4142
+ * @api public
4143
+ */
4144
+ exports.log = console.debug || console.log || (() => {});
4145
+
4146
+ /**
4147
+ * Save `namespaces`.
4148
+ *
4149
+ * @param {String} namespaces
4150
+ * @api private
4151
+ */
4152
+ function save(namespaces) {
4153
+ try {
4154
+ if (namespaces) {
4155
+ exports.storage.setItem('debug', namespaces);
4156
+ } else {
4157
+ exports.storage.removeItem('debug');
4158
+ }
4159
+ } catch (error) {
4160
+ // Swallow
4161
+ // XXX (@Qix-) should we be logging these?
4162
+ }
4163
+ }
4164
+
4165
+ /**
4166
+ * Load `namespaces`.
4167
+ *
4168
+ * @return {String} returns the previously persisted debug modes
4169
+ * @api private
4170
+ */
4171
+ function load() {
4172
+ let r;
4173
+ try {
4174
+ r = exports.storage.getItem('debug');
4175
+ } catch (error) {
4176
+ // Swallow
4177
+ // XXX (@Qix-) should we be logging these?
4178
+ }
4179
+
4180
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
4181
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
4182
+ r = process.env.DEBUG;
4183
+ }
4184
+
4185
+ return r;
4186
+ }
4187
+
4188
+ /**
4189
+ * Localstorage attempts to return the localstorage.
4190
+ *
4191
+ * This is necessary because safari throws
4192
+ * when a user disables cookies/localstorage
4193
+ * and you attempt to access it.
4194
+ *
4195
+ * @return {LocalStorage}
4196
+ * @api private
4197
+ */
4198
+
4199
+ function localstorage() {
4200
+ try {
4201
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
4202
+ // The Browser also has localStorage in the global context.
4203
+ return localStorage;
4204
+ } catch (error) {
4205
+ // Swallow
4206
+ // XXX (@Qix-) should we be logging these?
4207
+ }
4208
+ }
4209
+
4210
+ module.exports = requireCommon()(exports);
4211
+
4212
+ const {formatters} = module.exports;
4213
+
4214
+ /**
4215
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
4216
+ */
4217
+
4218
+ formatters.j = function (v) {
4219
+ try {
4220
+ return JSON.stringify(v);
4221
+ } catch (error) {
4222
+ return '[UnexpectedJSONParseError]: ' + error.message;
4223
+ }
4224
+ };
4225
+ } (browser, browser.exports));
4226
+ return browser.exports;
4227
+ }
4228
+
4229
+ var node = {exports: {}};
4230
+
4231
+ var hasFlag;
4232
+ var hasRequiredHasFlag;
4233
+
4234
+ function requireHasFlag () {
4235
+ if (hasRequiredHasFlag) return hasFlag;
4236
+ hasRequiredHasFlag = 1;
4237
+
4238
+ hasFlag = (flag, argv = process.argv) => {
4239
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
4240
+ const position = argv.indexOf(prefix + flag);
4241
+ const terminatorPosition = argv.indexOf('--');
4242
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4243
+ };
4244
+ return hasFlag;
4245
+ }
4246
+
4247
+ var supportsColor_1;
4248
+ var hasRequiredSupportsColor;
4249
+
4250
+ function requireSupportsColor () {
4251
+ if (hasRequiredSupportsColor) return supportsColor_1;
4252
+ hasRequiredSupportsColor = 1;
4253
+ const os = require$$0$1;
4254
+ const tty = require$$1;
4255
+ const hasFlag = requireHasFlag();
4256
+
4257
+ const {env} = process;
4258
+
4259
+ let forceColor;
4260
+ if (hasFlag('no-color') ||
4261
+ hasFlag('no-colors') ||
4262
+ hasFlag('color=false') ||
4263
+ hasFlag('color=never')) {
4264
+ forceColor = 0;
4265
+ } else if (hasFlag('color') ||
4266
+ hasFlag('colors') ||
4267
+ hasFlag('color=true') ||
4268
+ hasFlag('color=always')) {
4269
+ forceColor = 1;
4270
+ }
4271
+
4272
+ if ('FORCE_COLOR' in env) {
4273
+ if (env.FORCE_COLOR === 'true') {
4274
+ forceColor = 1;
4275
+ } else if (env.FORCE_COLOR === 'false') {
4276
+ forceColor = 0;
4277
+ } else {
4278
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
4279
+ }
4280
+ }
4281
+
4282
+ function translateLevel(level) {
4283
+ if (level === 0) {
4284
+ return false;
4285
+ }
4286
+
4287
+ return {
4288
+ level,
4289
+ hasBasic: true,
4290
+ has256: level >= 2,
4291
+ has16m: level >= 3
4292
+ };
4293
+ }
4294
+
4295
+ function supportsColor(haveStream, streamIsTTY) {
4296
+ if (forceColor === 0) {
4297
+ return 0;
4298
+ }
4299
+
4300
+ if (hasFlag('color=16m') ||
4301
+ hasFlag('color=full') ||
4302
+ hasFlag('color=truecolor')) {
4303
+ return 3;
4304
+ }
4305
+
4306
+ if (hasFlag('color=256')) {
4307
+ return 2;
4308
+ }
4309
+
4310
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
4311
+ return 0;
4312
+ }
4313
+
4314
+ const min = forceColor || 0;
4315
+
4316
+ if (env.TERM === 'dumb') {
4317
+ return min;
4318
+ }
4319
+
4320
+ if (process.platform === 'win32') {
4321
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
4322
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
4323
+ const osRelease = os.release().split('.');
4324
+ if (
4325
+ Number(osRelease[0]) >= 10 &&
4326
+ Number(osRelease[2]) >= 10586
4327
+ ) {
4328
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
4329
+ }
4330
+
4331
+ return 1;
4332
+ }
4333
+
4334
+ if ('CI' in env) {
4335
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
4336
+ return 1;
4337
+ }
4338
+
4339
+ return min;
4340
+ }
4341
+
4342
+ if ('TEAMCITY_VERSION' in env) {
4343
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
4344
+ }
4345
+
4346
+ if (env.COLORTERM === 'truecolor') {
4347
+ return 3;
4348
+ }
4349
+
4350
+ if ('TERM_PROGRAM' in env) {
4351
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
4352
+
4353
+ switch (env.TERM_PROGRAM) {
4354
+ case 'iTerm.app':
4355
+ return version >= 3 ? 3 : 2;
4356
+ case 'Apple_Terminal':
4357
+ return 2;
4358
+ // No default
4359
+ }
4360
+ }
4361
+
4362
+ if (/-256(color)?$/i.test(env.TERM)) {
4363
+ return 2;
4364
+ }
4365
+
4366
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
4367
+ return 1;
4368
+ }
4369
+
4370
+ if ('COLORTERM' in env) {
4371
+ return 1;
4372
+ }
4373
+
4374
+ return min;
4375
+ }
4376
+
4377
+ function getSupportLevel(stream) {
4378
+ const level = supportsColor(stream, stream && stream.isTTY);
4379
+ return translateLevel(level);
4380
+ }
4381
+
4382
+ supportsColor_1 = {
4383
+ supportsColor: getSupportLevel,
4384
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
4385
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
4386
+ };
4387
+ return supportsColor_1;
4388
+ }
4389
+
4390
+ /**
4391
+ * Module dependencies.
4392
+ */
4393
+
4394
+ var hasRequiredNode;
4395
+
4396
+ function requireNode () {
4397
+ if (hasRequiredNode) return node.exports;
4398
+ hasRequiredNode = 1;
4399
+ (function (module, exports) {
4400
+ const tty = require$$1;
4401
+ const util = require$$0;
4402
+
4403
+ /**
4404
+ * This is the Node.js implementation of `debug()`.
4405
+ */
4406
+
4407
+ exports.init = init;
4408
+ exports.log = log;
4409
+ exports.formatArgs = formatArgs;
4410
+ exports.save = save;
4411
+ exports.load = load;
4412
+ exports.useColors = useColors;
4413
+ exports.destroy = util.deprecate(
4414
+ () => {},
4415
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
4416
+ );
4417
+
4418
+ /**
4419
+ * Colors.
4420
+ */
4421
+
4422
+ exports.colors = [6, 2, 3, 4, 5, 1];
4423
+
4424
+ try {
4425
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
4426
+ // eslint-disable-next-line import/no-extraneous-dependencies
4427
+ const supportsColor = requireSupportsColor();
4428
+
4429
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
4430
+ exports.colors = [
4431
+ 20,
4432
+ 21,
4433
+ 26,
4434
+ 27,
4435
+ 32,
4436
+ 33,
4437
+ 38,
4438
+ 39,
4439
+ 40,
4440
+ 41,
4441
+ 42,
4442
+ 43,
4443
+ 44,
4444
+ 45,
4445
+ 56,
4446
+ 57,
4447
+ 62,
4448
+ 63,
4449
+ 68,
4450
+ 69,
4451
+ 74,
4452
+ 75,
4453
+ 76,
4454
+ 77,
4455
+ 78,
4456
+ 79,
4457
+ 80,
4458
+ 81,
4459
+ 92,
4460
+ 93,
4461
+ 98,
4462
+ 99,
4463
+ 112,
4464
+ 113,
4465
+ 128,
4466
+ 129,
4467
+ 134,
4468
+ 135,
4469
+ 148,
4470
+ 149,
4471
+ 160,
4472
+ 161,
4473
+ 162,
4474
+ 163,
4475
+ 164,
4476
+ 165,
4477
+ 166,
4478
+ 167,
4479
+ 168,
4480
+ 169,
4481
+ 170,
4482
+ 171,
4483
+ 172,
4484
+ 173,
4485
+ 178,
4486
+ 179,
4487
+ 184,
4488
+ 185,
4489
+ 196,
4490
+ 197,
4491
+ 198,
4492
+ 199,
4493
+ 200,
4494
+ 201,
4495
+ 202,
4496
+ 203,
4497
+ 204,
4498
+ 205,
4499
+ 206,
4500
+ 207,
4501
+ 208,
4502
+ 209,
4503
+ 214,
4504
+ 215,
4505
+ 220,
4506
+ 221
4507
+ ];
4508
+ }
4509
+ } catch (error) {
4510
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
4511
+ }
4512
+
4513
+ /**
4514
+ * Build up the default `inspectOpts` object from the environment variables.
4515
+ *
4516
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
4517
+ */
4518
+
4519
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
4520
+ return /^debug_/i.test(key);
4521
+ }).reduce((obj, key) => {
4522
+ // Camel-case
4523
+ const prop = key
4524
+ .substring(6)
4525
+ .toLowerCase()
4526
+ .replace(/_([a-z])/g, (_, k) => {
4527
+ return k.toUpperCase();
4528
+ });
4529
+
4530
+ // Coerce string value into JS value
4531
+ let val = process.env[key];
4532
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
4533
+ val = true;
4534
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
4535
+ val = false;
4536
+ } else if (val === 'null') {
4537
+ val = null;
4538
+ } else {
4539
+ val = Number(val);
4540
+ }
4541
+
4542
+ obj[prop] = val;
4543
+ return obj;
4544
+ }, {});
4545
+
4546
+ /**
4547
+ * Is stdout a TTY? Colored output is enabled when `true`.
4548
+ */
4549
+
4550
+ function useColors() {
4551
+ return 'colors' in exports.inspectOpts ?
4552
+ Boolean(exports.inspectOpts.colors) :
4553
+ tty.isatty(process.stderr.fd);
4554
+ }
4555
+
4556
+ /**
4557
+ * Adds ANSI color escape codes if enabled.
4558
+ *
4559
+ * @api public
4560
+ */
4561
+
4562
+ function formatArgs(args) {
4563
+ const {namespace: name, useColors} = this;
4564
+
4565
+ if (useColors) {
4566
+ const c = this.color;
4567
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
4568
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
4569
+
4570
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
4571
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
4572
+ } else {
4573
+ args[0] = getDate() + name + ' ' + args[0];
4574
+ }
4575
+ }
4576
+
4577
+ function getDate() {
4578
+ if (exports.inspectOpts.hideDate) {
4579
+ return '';
4580
+ }
4581
+ return new Date().toISOString() + ' ';
4582
+ }
4583
+
4584
+ /**
4585
+ * Invokes `util.format()` with the specified arguments and writes to stderr.
4586
+ */
4587
+
4588
+ function log(...args) {
4589
+ return process.stderr.write(util.format(...args) + '\n');
4590
+ }
4591
+
4592
+ /**
4593
+ * Save `namespaces`.
4594
+ *
4595
+ * @param {String} namespaces
4596
+ * @api private
4597
+ */
4598
+ function save(namespaces) {
4599
+ if (namespaces) {
4600
+ process.env.DEBUG = namespaces;
4601
+ } else {
4602
+ // If you set a process.env field to null or undefined, it gets cast to the
4603
+ // string 'null' or 'undefined'. Just delete instead.
4604
+ delete process.env.DEBUG;
4605
+ }
4606
+ }
4607
+
4608
+ /**
4609
+ * Load `namespaces`.
4610
+ *
4611
+ * @return {String} returns the previously persisted debug modes
4612
+ * @api private
4613
+ */
4614
+
4615
+ function load() {
4616
+ return process.env.DEBUG;
4617
+ }
4618
+
4619
+ /**
4620
+ * Init logic for `debug` instances.
4621
+ *
4622
+ * Create a new `inspectOpts` object in case `useColors` is set
4623
+ * differently for a particular `debug` instance.
4624
+ */
4625
+
4626
+ function init(debug) {
4627
+ debug.inspectOpts = {};
4628
+
4629
+ const keys = Object.keys(exports.inspectOpts);
4630
+ for (let i = 0; i < keys.length; i++) {
4631
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
4632
+ }
4633
+ }
4634
+
4635
+ module.exports = requireCommon()(exports);
4636
+
4637
+ const {formatters} = module.exports;
4638
+
4639
+ /**
4640
+ * Map %o to `util.inspect()`, all on a single line.
4641
+ */
4642
+
4643
+ formatters.o = function (v) {
4644
+ this.inspectOpts.colors = this.useColors;
4645
+ return util.inspect(v, this.inspectOpts)
4646
+ .split('\n')
4647
+ .map(str => str.trim())
4648
+ .join(' ');
4649
+ };
4650
+
4651
+ /**
4652
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
4653
+ */
4654
+
4655
+ formatters.O = function (v) {
4656
+ this.inspectOpts.colors = this.useColors;
4657
+ return util.inspect(v, this.inspectOpts);
4658
+ };
4659
+ } (node, node.exports));
4660
+ return node.exports;
4661
+ }
4662
+
4663
+ /**
4664
+ * Detect Electron renderer / nwjs process, which is node, but we should
4665
+ * treat as a browser.
4666
+ */
4667
+
4668
+ (function (module) {
4669
+ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
4670
+ module.exports = requireBrowser();
4671
+ } else {
4672
+ module.exports = requireNode();
4673
+ }
4674
+ } (src));
4675
+
4676
+ var compat = {exports: {}};
4677
+
4678
+ /*!
4679
+ * depd
4680
+ * Copyright(c) 2014 Douglas Christopher Wilson
4681
+ * MIT Licensed
4682
+ */
4683
+
4684
+ var callsiteTostring;
4685
+ var hasRequiredCallsiteTostring;
4686
+
4687
+ function requireCallsiteTostring () {
4688
+ if (hasRequiredCallsiteTostring) return callsiteTostring;
4689
+ hasRequiredCallsiteTostring = 1;
4690
+
4691
+ /**
4692
+ * Module exports.
4693
+ */
4694
+
4695
+ callsiteTostring = callSiteToString;
4696
+
4697
+ /**
4698
+ * Format a CallSite file location to a string.
4699
+ */
4700
+
4701
+ function callSiteFileLocation (callSite) {
4702
+ var fileName;
4703
+ var fileLocation = '';
4704
+
4705
+ if (callSite.isNative()) {
4706
+ fileLocation = 'native';
4707
+ } else if (callSite.isEval()) {
4708
+ fileName = callSite.getScriptNameOrSourceURL();
4709
+ if (!fileName) {
4710
+ fileLocation = callSite.getEvalOrigin();
4711
+ }
4712
+ } else {
4713
+ fileName = callSite.getFileName();
4714
+ }
4715
+
4716
+ if (fileName) {
4717
+ fileLocation += fileName;
4718
+
4719
+ var lineNumber = callSite.getLineNumber();
4720
+ if (lineNumber != null) {
4721
+ fileLocation += ':' + lineNumber;
4722
+
4723
+ var columnNumber = callSite.getColumnNumber();
4724
+ if (columnNumber) {
4725
+ fileLocation += ':' + columnNumber;
4726
+ }
4727
+ }
4728
+ }
4729
+
4730
+ return fileLocation || 'unknown source'
4731
+ }
4732
+
4733
+ /**
4734
+ * Format a CallSite to a string.
4735
+ */
4736
+
4737
+ function callSiteToString (callSite) {
4738
+ var addSuffix = true;
4739
+ var fileLocation = callSiteFileLocation(callSite);
4740
+ var functionName = callSite.getFunctionName();
4741
+ var isConstructor = callSite.isConstructor();
4742
+ var isMethodCall = !(callSite.isToplevel() || isConstructor);
4743
+ var line = '';
4744
+
4745
+ if (isMethodCall) {
4746
+ var methodName = callSite.getMethodName();
4747
+ var typeName = getConstructorName(callSite);
4748
+
4749
+ if (functionName) {
4750
+ if (typeName && functionName.indexOf(typeName) !== 0) {
4751
+ line += typeName + '.';
4752
+ }
4753
+
4754
+ line += functionName;
4755
+
4756
+ if (methodName && functionName.lastIndexOf('.' + methodName) !== functionName.length - methodName.length - 1) {
4757
+ line += ' [as ' + methodName + ']';
4758
+ }
4759
+ } else {
4760
+ line += typeName + '.' + (methodName || '<anonymous>');
4761
+ }
4762
+ } else if (isConstructor) {
4763
+ line += 'new ' + (functionName || '<anonymous>');
4764
+ } else if (functionName) {
4765
+ line += functionName;
4766
+ } else {
4767
+ addSuffix = false;
4768
+ line += fileLocation;
4769
+ }
4770
+
4771
+ if (addSuffix) {
4772
+ line += ' (' + fileLocation + ')';
4773
+ }
4774
+
4775
+ return line
4776
+ }
4777
+
4778
+ /**
4779
+ * Get constructor name of reviver.
4780
+ */
4781
+
4782
+ function getConstructorName (obj) {
4783
+ var receiver = obj.receiver;
4784
+ return (receiver.constructor && receiver.constructor.name) || null
4785
+ }
4786
+ return callsiteTostring;
4787
+ }
4788
+
4789
+ /*!
4790
+ * depd
4791
+ * Copyright(c) 2015 Douglas Christopher Wilson
4792
+ * MIT Licensed
4793
+ */
4794
+
4795
+ var eventListenerCount_1;
4796
+ var hasRequiredEventListenerCount;
4797
+
4798
+ function requireEventListenerCount () {
4799
+ if (hasRequiredEventListenerCount) return eventListenerCount_1;
4800
+ hasRequiredEventListenerCount = 1;
4801
+
4802
+ /**
4803
+ * Module exports.
4804
+ * @public
4805
+ */
4806
+
4807
+ eventListenerCount_1 = eventListenerCount;
4808
+
4809
+ /**
4810
+ * Get the count of listeners on an event emitter of a specific type.
4811
+ */
4812
+
4813
+ function eventListenerCount (emitter, type) {
4814
+ return emitter.listeners(type).length
4815
+ }
4816
+ return eventListenerCount_1;
4817
+ }
4818
+
4819
+ /*!
4820
+ * depd
4821
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
4822
+ * MIT Licensed
4823
+ */
4824
+
4825
+ (function (module) {
4826
+
4827
+ /**
4828
+ * Module dependencies.
4829
+ * @private
4830
+ */
4831
+
4832
+ var EventEmitter = require$$0$2.EventEmitter;
4833
+
4834
+ /**
4835
+ * Module exports.
4836
+ * @public
4837
+ */
4838
+
4839
+ lazyProperty(module.exports, 'callSiteToString', function callSiteToString () {
4840
+ var limit = Error.stackTraceLimit;
4841
+ var obj = {};
4842
+ var prep = Error.prepareStackTrace;
4843
+
4844
+ function prepareObjectStackTrace (obj, stack) {
4845
+ return stack
4846
+ }
4847
+
4848
+ Error.prepareStackTrace = prepareObjectStackTrace;
4849
+ Error.stackTraceLimit = 2;
4850
+
4851
+ // capture the stack
4852
+ Error.captureStackTrace(obj);
4853
+
4854
+ // slice the stack
4855
+ var stack = obj.stack.slice();
4856
+
4857
+ Error.prepareStackTrace = prep;
4858
+ Error.stackTraceLimit = limit;
4859
+
4860
+ return stack[0].toString ? toString : requireCallsiteTostring()
4861
+ });
4862
+
4863
+ lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount () {
4864
+ return EventEmitter.listenerCount || requireEventListenerCount()
4865
+ });
4866
+
4867
+ /**
4868
+ * Define a lazy property.
4869
+ */
4870
+
4871
+ function lazyProperty (obj, prop, getter) {
4872
+ function get () {
4873
+ var val = getter();
4874
+
4875
+ Object.defineProperty(obj, prop, {
4876
+ configurable: true,
4877
+ enumerable: true,
4878
+ value: val
4879
+ });
4880
+
4881
+ return val
4882
+ }
4883
+
4884
+ Object.defineProperty(obj, prop, {
4885
+ configurable: true,
4886
+ enumerable: true,
4887
+ get: get
4888
+ });
4889
+ }
4890
+
4891
+ /**
4892
+ * Call toString() on the obj
4893
+ */
4894
+
4895
+ function toString (obj) {
4896
+ return obj.toString()
4897
+ }
4898
+ } (compat));
4899
+
4900
+ /*!
4901
+ * depd
4902
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
4903
+ * MIT Licensed
4904
+ */
4905
+
4906
+ /**
4907
+ * Module dependencies.
4908
+ */
4909
+
4910
+ var callSiteToString = compat.exports.callSiteToString;
4911
+ var eventListenerCount = compat.exports.eventListenerCount;
4912
+ var relative = require$$1$1.relative;
4913
+
4914
+ /**
4915
+ * Module exports.
4916
+ */
4917
+
4918
+ var depd_1 = depd;
4919
+
4920
+ /**
4921
+ * Get the path to base files on.
4922
+ */
4923
+
4924
+ var basePath = process.cwd();
4925
+
4926
+ /**
4927
+ * Determine if namespace is contained in the string.
4928
+ */
4929
+
4930
+ function containsNamespace (str, namespace) {
4931
+ var vals = str.split(/[ ,]+/);
4932
+ var ns = String(namespace).toLowerCase();
4933
+
4934
+ for (var i = 0; i < vals.length; i++) {
4935
+ var val = vals[i];
4936
+
4937
+ // namespace contained
4938
+ if (val && (val === '*' || val.toLowerCase() === ns)) {
4939
+ return true
4940
+ }
4941
+ }
4942
+
4943
+ return false
4944
+ }
4945
+
4946
+ /**
4947
+ * Convert a data descriptor to accessor descriptor.
4948
+ */
4949
+
4950
+ function convertDataDescriptorToAccessor (obj, prop, message) {
4951
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
4952
+ var value = descriptor.value;
4953
+
4954
+ descriptor.get = function getter () { return value };
4955
+
4956
+ if (descriptor.writable) {
4957
+ descriptor.set = function setter (val) { return (value = val) };
4958
+ }
4959
+
4960
+ delete descriptor.value;
4961
+ delete descriptor.writable;
4962
+
4963
+ Object.defineProperty(obj, prop, descriptor);
4964
+
4965
+ return descriptor
4966
+ }
4967
+
4968
+ /**
4969
+ * Create arguments string to keep arity.
4970
+ */
4971
+
4972
+ function createArgumentsString (arity) {
4973
+ var str = '';
4974
+
4975
+ for (var i = 0; i < arity; i++) {
4976
+ str += ', arg' + i;
4977
+ }
4978
+
4979
+ return str.substr(2)
4980
+ }
4981
+
4982
+ /**
4983
+ * Create stack string from stack.
4984
+ */
4985
+
4986
+ function createStackString (stack) {
4987
+ var str = this.name + ': ' + this.namespace;
4988
+
4989
+ if (this.message) {
4990
+ str += ' deprecated ' + this.message;
4991
+ }
4992
+
4993
+ for (var i = 0; i < stack.length; i++) {
4994
+ str += '\n at ' + callSiteToString(stack[i]);
4995
+ }
4996
+
4997
+ return str
4998
+ }
4999
+
5000
+ /**
5001
+ * Create deprecate for namespace in caller.
5002
+ */
5003
+
5004
+ function depd (namespace) {
5005
+ if (!namespace) {
5006
+ throw new TypeError('argument namespace is required')
5007
+ }
5008
+
5009
+ var stack = getStack();
5010
+ var site = callSiteLocation(stack[1]);
5011
+ var file = site[0];
5012
+
5013
+ function deprecate (message) {
5014
+ // call to self as log
5015
+ log.call(deprecate, message);
5016
+ }
5017
+
5018
+ deprecate._file = file;
5019
+ deprecate._ignored = isignored(namespace);
5020
+ deprecate._namespace = namespace;
5021
+ deprecate._traced = istraced(namespace);
5022
+ deprecate._warned = Object.create(null);
5023
+
5024
+ deprecate.function = wrapfunction;
5025
+ deprecate.property = wrapproperty;
5026
+
5027
+ return deprecate
5028
+ }
5029
+
5030
+ /**
5031
+ * Determine if namespace is ignored.
5032
+ */
5033
+
5034
+ function isignored (namespace) {
5035
+ /* istanbul ignore next: tested in a child processs */
5036
+ if (process.noDeprecation) {
5037
+ // --no-deprecation support
5038
+ return true
5039
+ }
5040
+
5041
+ var str = process.env.NO_DEPRECATION || '';
5042
+
5043
+ // namespace ignored
5044
+ return containsNamespace(str, namespace)
5045
+ }
5046
+
5047
+ /**
5048
+ * Determine if namespace is traced.
5049
+ */
5050
+
5051
+ function istraced (namespace) {
5052
+ /* istanbul ignore next: tested in a child processs */
5053
+ if (process.traceDeprecation) {
5054
+ // --trace-deprecation support
5055
+ return true
5056
+ }
5057
+
5058
+ var str = process.env.TRACE_DEPRECATION || '';
5059
+
5060
+ // namespace traced
5061
+ return containsNamespace(str, namespace)
5062
+ }
5063
+
5064
+ /**
5065
+ * Display deprecation message.
5066
+ */
5067
+
5068
+ function log (message, site) {
5069
+ var haslisteners = eventListenerCount(process, 'deprecation') !== 0;
5070
+
5071
+ // abort early if no destination
5072
+ if (!haslisteners && this._ignored) {
5073
+ return
5074
+ }
5075
+
5076
+ var caller;
5077
+ var callFile;
5078
+ var callSite;
5079
+ var depSite;
5080
+ var i = 0;
5081
+ var seen = false;
5082
+ var stack = getStack();
5083
+ var file = this._file;
5084
+
5085
+ if (site) {
5086
+ // provided site
5087
+ depSite = site;
5088
+ callSite = callSiteLocation(stack[1]);
5089
+ callSite.name = depSite.name;
5090
+ file = callSite[0];
5091
+ } else {
5092
+ // get call site
5093
+ i = 2;
5094
+ depSite = callSiteLocation(stack[i]);
5095
+ callSite = depSite;
5096
+ }
5097
+
5098
+ // get caller of deprecated thing in relation to file
5099
+ for (; i < stack.length; i++) {
5100
+ caller = callSiteLocation(stack[i]);
5101
+ callFile = caller[0];
5102
+
5103
+ if (callFile === file) {
5104
+ seen = true;
5105
+ } else if (callFile === this._file) {
5106
+ file = this._file;
5107
+ } else if (seen) {
5108
+ break
5109
+ }
5110
+ }
5111
+
5112
+ var key = caller
5113
+ ? depSite.join(':') + '__' + caller.join(':')
5114
+ : undefined;
5115
+
5116
+ if (key !== undefined && key in this._warned) {
5117
+ // already warned
5118
+ return
5119
+ }
5120
+
5121
+ this._warned[key] = true;
5122
+
5123
+ // generate automatic message from call site
5124
+ var msg = message;
5125
+ if (!msg) {
5126
+ msg = callSite === depSite || !callSite.name
5127
+ ? defaultMessage(depSite)
5128
+ : defaultMessage(callSite);
5129
+ }
5130
+
5131
+ // emit deprecation if listeners exist
5132
+ if (haslisteners) {
5133
+ var err = DeprecationError(this._namespace, msg, stack.slice(i));
5134
+ process.emit('deprecation', err);
5135
+ return
5136
+ }
5137
+
5138
+ // format and write message
5139
+ var format = process.stderr.isTTY
5140
+ ? formatColor
5141
+ : formatPlain;
5142
+ var output = format.call(this, msg, caller, stack.slice(i));
5143
+ process.stderr.write(output + '\n', 'utf8');
5144
+ }
5145
+
5146
+ /**
5147
+ * Get call site location as array.
5148
+ */
5149
+
5150
+ function callSiteLocation (callSite) {
5151
+ var file = callSite.getFileName() || '<anonymous>';
5152
+ var line = callSite.getLineNumber();
5153
+ var colm = callSite.getColumnNumber();
5154
+
5155
+ if (callSite.isEval()) {
5156
+ file = callSite.getEvalOrigin() + ', ' + file;
5157
+ }
5158
+
5159
+ var site = [file, line, colm];
5160
+
5161
+ site.callSite = callSite;
5162
+ site.name = callSite.getFunctionName();
5163
+
5164
+ return site
5165
+ }
5166
+
5167
+ /**
5168
+ * Generate a default message from the site.
5169
+ */
5170
+
5171
+ function defaultMessage (site) {
5172
+ var callSite = site.callSite;
5173
+ var funcName = site.name;
5174
+
5175
+ // make useful anonymous name
5176
+ if (!funcName) {
5177
+ funcName = '<anonymous@' + formatLocation(site) + '>';
5178
+ }
5179
+
5180
+ var context = callSite.getThis();
5181
+ var typeName = context && callSite.getTypeName();
5182
+
5183
+ // ignore useless type name
5184
+ if (typeName === 'Object') {
5185
+ typeName = undefined;
5186
+ }
5187
+
5188
+ // make useful type name
5189
+ if (typeName === 'Function') {
5190
+ typeName = context.name || typeName;
5191
+ }
5192
+
5193
+ return typeName && callSite.getMethodName()
5194
+ ? typeName + '.' + funcName
5195
+ : funcName
5196
+ }
5197
+
5198
+ /**
5199
+ * Format deprecation message without color.
5200
+ */
5201
+
5202
+ function formatPlain (msg, caller, stack) {
5203
+ var timestamp = new Date().toUTCString();
5204
+
5205
+ var formatted = timestamp +
5206
+ ' ' + this._namespace +
5207
+ ' deprecated ' + msg;
5208
+
5209
+ // add stack trace
5210
+ if (this._traced) {
5211
+ for (var i = 0; i < stack.length; i++) {
5212
+ formatted += '\n at ' + callSiteToString(stack[i]);
5213
+ }
5214
+
5215
+ return formatted
5216
+ }
5217
+
5218
+ if (caller) {
5219
+ formatted += ' at ' + formatLocation(caller);
5220
+ }
5221
+
5222
+ return formatted
5223
+ }
5224
+
5225
+ /**
5226
+ * Format deprecation message with color.
5227
+ */
5228
+
5229
+ function formatColor (msg, caller, stack) {
5230
+ var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' + // bold cyan
5231
+ ' \x1b[33;1mdeprecated\x1b[22;39m' + // bold yellow
5232
+ ' \x1b[0m' + msg + '\x1b[39m'; // reset
5233
+
5234
+ // add stack trace
5235
+ if (this._traced) {
5236
+ for (var i = 0; i < stack.length; i++) {
5237
+ formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m'; // cyan
5238
+ }
5239
+
5240
+ return formatted
5241
+ }
5242
+
5243
+ if (caller) {
5244
+ formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m'; // cyan
5245
+ }
5246
+
5247
+ return formatted
5248
+ }
5249
+
5250
+ /**
5251
+ * Format call site location.
5252
+ */
5253
+
5254
+ function formatLocation (callSite) {
5255
+ return relative(basePath, callSite[0]) +
5256
+ ':' + callSite[1] +
5257
+ ':' + callSite[2]
5258
+ }
5259
+
5260
+ /**
5261
+ * Get the stack as array of call sites.
5262
+ */
5263
+
5264
+ function getStack () {
5265
+ var limit = Error.stackTraceLimit;
5266
+ var obj = {};
5267
+ var prep = Error.prepareStackTrace;
5268
+
5269
+ Error.prepareStackTrace = prepareObjectStackTrace;
5270
+ Error.stackTraceLimit = Math.max(10, limit);
5271
+
5272
+ // capture the stack
5273
+ Error.captureStackTrace(obj);
5274
+
5275
+ // slice this function off the top
5276
+ var stack = obj.stack.slice(1);
5277
+
5278
+ Error.prepareStackTrace = prep;
5279
+ Error.stackTraceLimit = limit;
5280
+
5281
+ return stack
5282
+ }
5283
+
5284
+ /**
5285
+ * Capture call site stack from v8.
5286
+ */
5287
+
5288
+ function prepareObjectStackTrace (obj, stack) {
5289
+ return stack
5290
+ }
5291
+
5292
+ /**
5293
+ * Return a wrapped function in a deprecation message.
5294
+ */
5295
+
5296
+ function wrapfunction (fn, message) {
5297
+ if (typeof fn !== 'function') {
5298
+ throw new TypeError('argument fn must be a function')
5299
+ }
5300
+
5301
+ var args = createArgumentsString(fn.length);
5302
+ var stack = getStack();
5303
+ var site = callSiteLocation(stack[1]);
5304
+
5305
+ site.name = fn.name;
5306
+
5307
+ // eslint-disable-next-line no-eval
5308
+ var deprecatedfn = eval('(function (' + args + ') {\n' +
5309
+ '"use strict"\n' +
5310
+ 'log.call(deprecate, message, site)\n' +
5311
+ 'return fn.apply(this, arguments)\n' +
5312
+ '})');
5313
+
5314
+ return deprecatedfn
5315
+ }
5316
+
5317
+ /**
5318
+ * Wrap property in a deprecation message.
5319
+ */
5320
+
5321
+ function wrapproperty (obj, prop, message) {
5322
+ if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
5323
+ throw new TypeError('argument obj must be object')
5324
+ }
5325
+
5326
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
5327
+
5328
+ if (!descriptor) {
5329
+ throw new TypeError('must call property on owner object')
5330
+ }
5331
+
5332
+ if (!descriptor.configurable) {
5333
+ throw new TypeError('property must be configurable')
5334
+ }
5335
+
5336
+ var deprecate = this;
5337
+ var stack = getStack();
5338
+ var site = callSiteLocation(stack[1]);
5339
+
5340
+ // set site name
5341
+ site.name = prop;
5342
+
5343
+ // convert data descriptor
5344
+ if ('value' in descriptor) {
5345
+ descriptor = convertDataDescriptorToAccessor(obj, prop);
5346
+ }
5347
+
5348
+ var get = descriptor.get;
5349
+ var set = descriptor.set;
5350
+
5351
+ // wrap getter
5352
+ if (typeof get === 'function') {
5353
+ descriptor.get = function getter () {
5354
+ log.call(deprecate, message, site);
5355
+ return get.apply(this, arguments)
5356
+ };
5357
+ }
5358
+
5359
+ // wrap setter
5360
+ if (typeof set === 'function') {
5361
+ descriptor.set = function setter () {
5362
+ log.call(deprecate, message, site);
5363
+ return set.apply(this, arguments)
5364
+ };
5365
+ }
5366
+
5367
+ Object.defineProperty(obj, prop, descriptor);
5368
+ }
5369
+
5370
+ /**
5371
+ * Create DeprecationError for deprecation
5372
+ */
5373
+
5374
+ function DeprecationError (namespace, message, stack) {
5375
+ var error = new Error();
5376
+ var stackString;
5377
+
5378
+ Object.defineProperty(error, 'constructor', {
5379
+ value: DeprecationError
5380
+ });
5381
+
5382
+ Object.defineProperty(error, 'message', {
5383
+ configurable: true,
5384
+ enumerable: false,
5385
+ value: message,
5386
+ writable: true
5387
+ });
5388
+
5389
+ Object.defineProperty(error, 'name', {
5390
+ enumerable: false,
5391
+ configurable: true,
5392
+ value: 'DeprecationError',
5393
+ writable: true
5394
+ });
5395
+
5396
+ Object.defineProperty(error, 'namespace', {
5397
+ configurable: true,
5398
+ enumerable: false,
5399
+ value: namespace,
5400
+ writable: true
5401
+ });
5402
+
5403
+ Object.defineProperty(error, 'stack', {
5404
+ configurable: true,
5405
+ enumerable: false,
5406
+ get: function () {
5407
+ if (stackString !== undefined) {
5408
+ return stackString
5409
+ }
5410
+
5411
+ // prepare stack trace
5412
+ return (stackString = createStackString.call(this, stack))
5413
+ },
5414
+ set: function setter (val) {
5415
+ stackString = val;
5416
+ }
5417
+ });
5418
+
5419
+ return error
5420
+ }
5421
+
5422
+ var constants = {
5423
+ // agent
5424
+ CURRENT_ID: Symbol('agentkeepalive#currentId'),
5425
+ CREATE_ID: Symbol('agentkeepalive#createId'),
5426
+ INIT_SOCKET: Symbol('agentkeepalive#initSocket'),
5427
+ CREATE_HTTPS_CONNECTION: Symbol('agentkeepalive#createHttpsConnection'),
5428
+ // socket
5429
+ SOCKET_CREATED_TIME: Symbol('agentkeepalive#socketCreatedTime'),
5430
+ SOCKET_NAME: Symbol('agentkeepalive#socketName'),
5431
+ SOCKET_REQUEST_COUNT: Symbol('agentkeepalive#socketRequestCount'),
5432
+ SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'),
5433
+ };
5434
+
5435
+ const OriginalAgent = require$$0$3.Agent;
5436
+ const ms = humanizeMs;
5437
+ const debug = src.exports('agentkeepalive');
5438
+ const deprecate = depd_1('agentkeepalive');
5439
+ const {
5440
+ INIT_SOCKET: INIT_SOCKET$1,
5441
+ CURRENT_ID,
5442
+ CREATE_ID,
5443
+ SOCKET_CREATED_TIME,
5444
+ SOCKET_NAME,
5445
+ SOCKET_REQUEST_COUNT,
5446
+ SOCKET_REQUEST_FINISHED_COUNT,
5447
+ } = constants;
5448
+
5449
+ // OriginalAgent come from
5450
+ // - https://github.com/nodejs/node/blob/v8.12.0/lib/_http_agent.js
5451
+ // - https://github.com/nodejs/node/blob/v10.12.0/lib/_http_agent.js
5452
+
5453
+ // node <= 10
5454
+ let defaultTimeoutListenerCount = 1;
5455
+ const majorVersion = parseInt(process.version.split('.', 1)[0].substring(1));
5456
+ if (majorVersion >= 11 && majorVersion <= 12) {
5457
+ defaultTimeoutListenerCount = 2;
5458
+ } else if (majorVersion >= 13) {
5459
+ defaultTimeoutListenerCount = 3;
5460
+ }
5461
+
5462
+ class Agent$1 extends OriginalAgent {
5463
+ constructor(options) {
5464
+ options = options || {};
5465
+ options.keepAlive = options.keepAlive !== false;
5466
+ // default is keep-alive and 4s free socket timeout
5467
+ // see https://medium.com/ssense-tech/reduce-networking-errors-in-nodejs-23b4eb9f2d83
5468
+ if (options.freeSocketTimeout === undefined) {
5469
+ options.freeSocketTimeout = 4000;
5470
+ }
5471
+ // Legacy API: keepAliveTimeout should be rename to `freeSocketTimeout`
5472
+ if (options.keepAliveTimeout) {
5473
+ deprecate('options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead');
5474
+ options.freeSocketTimeout = options.keepAliveTimeout;
5475
+ delete options.keepAliveTimeout;
5476
+ }
5477
+ // Legacy API: freeSocketKeepAliveTimeout should be rename to `freeSocketTimeout`
5478
+ if (options.freeSocketKeepAliveTimeout) {
5479
+ deprecate('options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead');
5480
+ options.freeSocketTimeout = options.freeSocketKeepAliveTimeout;
5481
+ delete options.freeSocketKeepAliveTimeout;
5482
+ }
5483
+
5484
+ // Sets the socket to timeout after timeout milliseconds of inactivity on the socket.
5485
+ // By default is double free socket timeout.
5486
+ if (options.timeout === undefined) {
5487
+ // make sure socket default inactivity timeout >= 8s
5488
+ options.timeout = Math.max(options.freeSocketTimeout * 2, 8000);
5489
+ }
5490
+
5491
+ // support humanize format
5492
+ options.timeout = ms(options.timeout);
5493
+ options.freeSocketTimeout = ms(options.freeSocketTimeout);
5494
+ options.socketActiveTTL = options.socketActiveTTL ? ms(options.socketActiveTTL) : 0;
5495
+
5496
+ super(options);
5497
+
5498
+ this[CURRENT_ID] = 0;
5499
+
5500
+ // create socket success counter
5501
+ this.createSocketCount = 0;
5502
+ this.createSocketCountLastCheck = 0;
5503
+
5504
+ this.createSocketErrorCount = 0;
5505
+ this.createSocketErrorCountLastCheck = 0;
5506
+
5507
+ this.closeSocketCount = 0;
5508
+ this.closeSocketCountLastCheck = 0;
5509
+
5510
+ // socket error event count
5511
+ this.errorSocketCount = 0;
5512
+ this.errorSocketCountLastCheck = 0;
5513
+
5514
+ // request finished counter
5515
+ this.requestCount = 0;
5516
+ this.requestCountLastCheck = 0;
5517
+
5518
+ // including free socket timeout counter
5519
+ this.timeoutSocketCount = 0;
5520
+ this.timeoutSocketCountLastCheck = 0;
5521
+
5522
+ this.on('free', socket => {
5523
+ // https://github.com/nodejs/node/pull/32000
5524
+ // Node.js native agent will check socket timeout eqs agent.options.timeout.
5525
+ // Use the ttl or freeSocketTimeout to overwrite.
5526
+ const timeout = this.calcSocketTimeout(socket);
5527
+ if (timeout > 0 && socket.timeout !== timeout) {
5528
+ socket.setTimeout(timeout);
5529
+ }
5530
+ });
5531
+ }
5532
+
5533
+ get freeSocketKeepAliveTimeout() {
5534
+ deprecate('agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead');
5535
+ return this.options.freeSocketTimeout;
5536
+ }
5537
+
5538
+ get timeout() {
5539
+ deprecate('agent.timeout is deprecated, please use agent.options.timeout instead');
5540
+ return this.options.timeout;
5541
+ }
5542
+
5543
+ get socketActiveTTL() {
5544
+ deprecate('agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead');
5545
+ return this.options.socketActiveTTL;
5546
+ }
5547
+
5548
+ calcSocketTimeout(socket) {
5549
+ /**
5550
+ * return <= 0: should free socket
5551
+ * return > 0: should update socket timeout
5552
+ * return undefined: not find custom timeout
5553
+ */
5554
+ let freeSocketTimeout = this.options.freeSocketTimeout;
5555
+ const socketActiveTTL = this.options.socketActiveTTL;
5556
+ if (socketActiveTTL) {
5557
+ // check socketActiveTTL
5558
+ const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME];
5559
+ const diff = socketActiveTTL - aliveTime;
5560
+ if (diff <= 0) {
5561
+ return diff;
5562
+ }
5563
+ if (freeSocketTimeout && diff < freeSocketTimeout) {
5564
+ freeSocketTimeout = diff;
5565
+ }
5566
+ }
5567
+ // set freeSocketTimeout
5568
+ if (freeSocketTimeout) {
5569
+ // set free keepalive timer
5570
+ // try to use socket custom freeSocketTimeout first, support headers['keep-alive']
5571
+ // https://github.com/node-modules/urllib/blob/b76053020923f4d99a1c93cf2e16e0c5ba10bacf/lib/urllib.js#L498
5572
+ const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout;
5573
+ return customFreeSocketTimeout || freeSocketTimeout;
5574
+ }
5575
+ }
5576
+
5577
+ keepSocketAlive(socket) {
5578
+ const result = super.keepSocketAlive(socket);
5579
+ // should not keepAlive, do nothing
5580
+ if (!result) return result;
5581
+
5582
+ const customTimeout = this.calcSocketTimeout(socket);
5583
+ if (typeof customTimeout === 'undefined') {
5584
+ return true;
5585
+ }
5586
+ if (customTimeout <= 0) {
5587
+ debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s',
5588
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], customTimeout);
5589
+ return false;
5590
+ }
5591
+ if (socket.timeout !== customTimeout) {
5592
+ socket.setTimeout(customTimeout);
5593
+ }
5594
+ return true;
5595
+ }
5596
+
5597
+ // only call on addRequest
5598
+ reuseSocket(...args) {
5599
+ // reuseSocket(socket, req)
5600
+ super.reuseSocket(...args);
5601
+ const socket = args[0];
5602
+ const req = args[1];
5603
+ req.reusedSocket = true;
5604
+ const agentTimeout = this.options.timeout;
5605
+ if (getSocketTimeout(socket) !== agentTimeout) {
5606
+ // reset timeout before use
5607
+ socket.setTimeout(agentTimeout);
5608
+ debug('%s reset timeout to %sms', socket[SOCKET_NAME], agentTimeout);
5609
+ }
5610
+ socket[SOCKET_REQUEST_COUNT]++;
5611
+ debug('%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms',
5612
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
5613
+ getSocketTimeout(socket));
5614
+ }
5615
+
5616
+ [CREATE_ID]() {
5617
+ const id = this[CURRENT_ID]++;
5618
+ if (this[CURRENT_ID] === Number.MAX_SAFE_INTEGER) this[CURRENT_ID] = 0;
5619
+ return id;
5620
+ }
5621
+
5622
+ [INIT_SOCKET$1](socket, options) {
5623
+ // bugfix here.
5624
+ // https on node 8, 10 won't set agent.options.timeout by default
5625
+ // TODO: need to fix on node itself
5626
+ if (options.timeout) {
5627
+ const timeout = getSocketTimeout(socket);
5628
+ if (!timeout) {
5629
+ socket.setTimeout(options.timeout);
5630
+ }
5631
+ }
5632
+
5633
+ if (this.options.keepAlive) {
5634
+ // Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/
5635
+ // https://fengmk2.com/benchmark/nagle-algorithm-delayed-ack-mock.html
5636
+ socket.setNoDelay(true);
5637
+ }
5638
+ this.createSocketCount++;
5639
+ if (this.options.socketActiveTTL) {
5640
+ socket[SOCKET_CREATED_TIME] = Date.now();
5641
+ }
5642
+ // don't show the hole '-----BEGIN CERTIFICATE----' key string
5643
+ socket[SOCKET_NAME] = `sock[${this[CREATE_ID]()}#${options._agentKey}]`.split('-----BEGIN', 1)[0];
5644
+ socket[SOCKET_REQUEST_COUNT] = 1;
5645
+ socket[SOCKET_REQUEST_FINISHED_COUNT] = 0;
5646
+ installListeners(this, socket, options);
5647
+ }
5648
+
5649
+ createConnection(options, oncreate) {
5650
+ let called = false;
5651
+ const onNewCreate = (err, socket) => {
5652
+ if (called) return;
5653
+ called = true;
5654
+
5655
+ if (err) {
5656
+ this.createSocketErrorCount++;
5657
+ return oncreate(err);
5658
+ }
5659
+ this[INIT_SOCKET$1](socket, options);
5660
+ oncreate(err, socket);
5661
+ };
5662
+
5663
+ const newSocket = super.createConnection(options, onNewCreate);
5664
+ if (newSocket) onNewCreate(null, newSocket);
5665
+ }
5666
+
5667
+ get statusChanged() {
5668
+ const changed = this.createSocketCount !== this.createSocketCountLastCheck ||
5669
+ this.createSocketErrorCount !== this.createSocketErrorCountLastCheck ||
5670
+ this.closeSocketCount !== this.closeSocketCountLastCheck ||
5671
+ this.errorSocketCount !== this.errorSocketCountLastCheck ||
5672
+ this.timeoutSocketCount !== this.timeoutSocketCountLastCheck ||
5673
+ this.requestCount !== this.requestCountLastCheck;
5674
+ if (changed) {
5675
+ this.createSocketCountLastCheck = this.createSocketCount;
5676
+ this.createSocketErrorCountLastCheck = this.createSocketErrorCount;
5677
+ this.closeSocketCountLastCheck = this.closeSocketCount;
5678
+ this.errorSocketCountLastCheck = this.errorSocketCount;
5679
+ this.timeoutSocketCountLastCheck = this.timeoutSocketCount;
5680
+ this.requestCountLastCheck = this.requestCount;
5681
+ }
5682
+ return changed;
5683
+ }
5684
+
5685
+ getCurrentStatus() {
5686
+ return {
5687
+ createSocketCount: this.createSocketCount,
5688
+ createSocketErrorCount: this.createSocketErrorCount,
5689
+ closeSocketCount: this.closeSocketCount,
5690
+ errorSocketCount: this.errorSocketCount,
5691
+ timeoutSocketCount: this.timeoutSocketCount,
5692
+ requestCount: this.requestCount,
5693
+ freeSockets: inspect(this.freeSockets),
5694
+ sockets: inspect(this.sockets),
5695
+ requests: inspect(this.requests),
5696
+ };
5697
+ }
5698
+ }
5699
+
5700
+ // node 8 don't has timeout attribute on socket
5701
+ // https://github.com/nodejs/node/pull/21204/files#diff-e6ef024c3775d787c38487a6309e491dR408
5702
+ function getSocketTimeout(socket) {
5703
+ return socket.timeout || socket._idleTimeout;
5704
+ }
5705
+
5706
+ function installListeners(agent, socket, options) {
5707
+ debug('%s create, timeout %sms', socket[SOCKET_NAME], getSocketTimeout(socket));
5708
+
5709
+ // listener socket events: close, timeout, error, free
5710
+ function onFree() {
5711
+ // create and socket.emit('free') logic
5712
+ // https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L311
5713
+ // no req on the socket, it should be the new socket
5714
+ if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return;
5715
+
5716
+ socket[SOCKET_REQUEST_FINISHED_COUNT]++;
5717
+ agent.requestCount++;
5718
+ debug('%s(requests: %s, finished: %s) free',
5719
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]);
5720
+
5721
+ // should reuse on pedding requests?
5722
+ const name = agent.getName(options);
5723
+ if (socket.writable && agent.requests[name] && agent.requests[name].length) {
5724
+ // will be reuse on agent free listener
5725
+ socket[SOCKET_REQUEST_COUNT]++;
5726
+ debug('%s(requests: %s, finished: %s) will be reuse on agent free event',
5727
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]);
5728
+ }
5729
+ }
5730
+ socket.on('free', onFree);
5731
+
5732
+ function onClose(isError) {
5733
+ debug('%s(requests: %s, finished: %s) close, isError: %s',
5734
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], isError);
5735
+ agent.closeSocketCount++;
5736
+ }
5737
+ socket.on('close', onClose);
5738
+
5739
+ // start socket timeout handler
5740
+ function onTimeout() {
5741
+ // onTimeout and emitRequestTimeout(_http_client.js)
5742
+ // https://github.com/nodejs/node/blob/v12.x/lib/_http_client.js#L711
5743
+ const listenerCount = socket.listeners('timeout').length;
5744
+ // node <= 10, default listenerCount is 1, onTimeout
5745
+ // 11 < node <= 12, default listenerCount is 2, onTimeout and emitRequestTimeout
5746
+ // node >= 13, default listenerCount is 3, onTimeout,
5747
+ // onTimeout(https://github.com/nodejs/node/pull/32000/files#diff-5f7fb0850412c6be189faeddea6c5359R333)
5748
+ // and emitRequestTimeout
5749
+ const timeout = getSocketTimeout(socket);
5750
+ const req = socket._httpMessage;
5751
+ const reqTimeoutListenerCount = req && req.listeners('timeout').length || 0;
5752
+ debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s',
5753
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
5754
+ timeout, listenerCount, defaultTimeoutListenerCount, !!req, reqTimeoutListenerCount);
5755
+ if (debug.enabled) {
5756
+ debug('timeout listeners: %s', socket.listeners('timeout').map(f => f.name).join(', '));
5757
+ }
5758
+ agent.timeoutSocketCount++;
5759
+ const name = agent.getName(options);
5760
+ if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) {
5761
+ // free socket timeout, destroy quietly
5762
+ socket.destroy();
5763
+ // Remove it from freeSockets list immediately to prevent new requests
5764
+ // from being sent through this socket.
5765
+ agent.removeSocket(socket, options);
5766
+ debug('%s is free, destroy quietly', socket[SOCKET_NAME]);
5767
+ } else {
5768
+ // if there is no any request socket timeout handler,
5769
+ // agent need to handle socket timeout itself.
5770
+ //
5771
+ // custom request socket timeout handle logic must follow these rules:
5772
+ // 1. Destroy socket first
5773
+ // 2. Must emit socket 'agentRemove' event tell agent remove socket
5774
+ // from freeSockets list immediately.
5775
+ // Otherise you may be get 'socket hang up' error when reuse
5776
+ // free socket and timeout happen in the same time.
5777
+ if (reqTimeoutListenerCount === 0) {
5778
+ const error = new Error('Socket timeout');
5779
+ error.code = 'ERR_SOCKET_TIMEOUT';
5780
+ error.timeout = timeout;
5781
+ // must manually call socket.end() or socket.destroy() to end the connection.
5782
+ // https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback
5783
+ socket.destroy(error);
5784
+ agent.removeSocket(socket, options);
5785
+ debug('%s destroy with timeout error', socket[SOCKET_NAME]);
5786
+ }
5787
+ }
5788
+ }
5789
+ socket.on('timeout', onTimeout);
5790
+
5791
+ function onError(err) {
5792
+ const listenerCount = socket.listeners('error').length;
5793
+ debug('%s(requests: %s, finished: %s) error: %s, listenerCount: %s',
5794
+ socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
5795
+ err, listenerCount);
5796
+ agent.errorSocketCount++;
5797
+ if (listenerCount === 1) {
5798
+ // if socket don't contain error event handler, don't catch it, emit it again
5799
+ debug('%s emit uncaught error event', socket[SOCKET_NAME]);
5800
+ socket.removeListener('error', onError);
5801
+ socket.emit('error', err);
5802
+ }
5803
+ }
5804
+ socket.on('error', onError);
5805
+
5806
+ function onRemove() {
5807
+ debug('%s(requests: %s, finished: %s) agentRemove',
5808
+ socket[SOCKET_NAME],
5809
+ socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]);
5810
+ // We need this function for cases like HTTP 'upgrade'
5811
+ // (defined by WebSockets) where we need to remove a socket from the
5812
+ // pool because it'll be locked up indefinitely
5813
+ socket.removeListener('close', onClose);
5814
+ socket.removeListener('error', onError);
5815
+ socket.removeListener('free', onFree);
5816
+ socket.removeListener('timeout', onTimeout);
5817
+ socket.removeListener('agentRemove', onRemove);
5818
+ }
5819
+ socket.on('agentRemove', onRemove);
5820
+ }
5821
+
5822
+ var agent = Agent$1;
5823
+
5824
+ function inspect(obj) {
5825
+ const res = {};
5826
+ for (const key in obj) {
5827
+ res[key] = obj[key].length;
5828
+ }
5829
+ return res;
5830
+ }
5831
+
5832
+ const OriginalHttpsAgent = require$$0$4.Agent;
5833
+ const HttpAgent = agent;
5834
+ const {
5835
+ INIT_SOCKET,
5836
+ CREATE_HTTPS_CONNECTION,
5837
+ } = constants;
5838
+
5839
+ class HttpsAgent extends HttpAgent {
5840
+ constructor(options) {
5841
+ super(options);
5842
+
5843
+ this.defaultPort = 443;
5844
+ this.protocol = 'https:';
5845
+ this.maxCachedSessions = this.options.maxCachedSessions;
5846
+ /* istanbul ignore next */
5847
+ if (this.maxCachedSessions === undefined) {
5848
+ this.maxCachedSessions = 100;
5849
+ }
5850
+
5851
+ this._sessionCache = {
5852
+ map: {},
5853
+ list: [],
5854
+ };
5855
+ }
5856
+
5857
+ createConnection(options) {
5858
+ const socket = this[CREATE_HTTPS_CONNECTION](options);
5859
+ this[INIT_SOCKET](socket, options);
5860
+ return socket;
5861
+ }
5862
+ }
5863
+
5864
+ // https://github.com/nodejs/node/blob/master/lib/https.js#L89
5865
+ HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection;
5866
+
5867
+ [
5868
+ 'getName',
5869
+ '_getSession',
5870
+ '_cacheSession',
5871
+ // https://github.com/nodejs/node/pull/4982
5872
+ '_evictSession',
5873
+ ].forEach(function(method) {
5874
+ /* istanbul ignore next */
5875
+ if (typeof OriginalHttpsAgent.prototype[method] === 'function') {
5876
+ HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method];
5877
+ }
5878
+ });
5879
+
5880
+ var https_agent = HttpsAgent;
5881
+
5882
+ (function (module) {
5883
+
5884
+ module.exports = agent;
5885
+ module.exports.HttpsAgent = https_agent;
5886
+ module.exports.constants = constants;
5887
+ } (agentkeepalive));
5888
+
5889
+ var Agent = /*@__PURE__*/getDefaultExportFromCjs(agentkeepalive.exports);
5890
+
3296
5891
  var objToString = Object.prototype.toString;
3297
5892
  var objKeys = Object.keys || function(obj) {
3298
5893
  var keys = [];
@@ -3369,55 +5964,6 @@ var fastStableStringify = function(val) {
3369
5964
 
3370
5965
  var fastStableStringify$1 = fastStableStringify;
3371
5966
 
3372
- const DESTROY_TIMEOUT_MS = 5000;
3373
- class AgentManager {
3374
- static _newAgent(useHttps) {
3375
- const options = {
3376
- keepAlive: true,
3377
- maxSockets: 25
3378
- };
3379
-
3380
- if (useHttps) {
3381
- return new https.Agent(options);
3382
- } else {
3383
- return new http.Agent(options);
3384
- }
3385
- }
3386
-
3387
- constructor(useHttps) {
3388
- this._agent = void 0;
3389
- this._activeRequests = 0;
3390
- this._destroyTimeout = null;
3391
- this._useHttps = void 0;
3392
- this._useHttps = useHttps === true;
3393
- this._agent = AgentManager._newAgent(this._useHttps);
3394
- }
3395
-
3396
- requestStart() {
3397
- this._activeRequests++;
3398
-
3399
- if (this._destroyTimeout !== null) {
3400
- clearTimeout(this._destroyTimeout);
3401
- this._destroyTimeout = null;
3402
- }
3403
-
3404
- return this._agent;
3405
- }
3406
-
3407
- requestEnd() {
3408
- this._activeRequests--;
3409
-
3410
- if (this._activeRequests === 0 && this._destroyTimeout === null) {
3411
- this._destroyTimeout = setTimeout(() => {
3412
- this._agent.destroy();
3413
-
3414
- this._agent = AgentManager._newAgent(this._useHttps);
3415
- }, DESTROY_TIMEOUT_MS);
3416
- }
3417
- }
3418
-
3419
- }
3420
-
3421
5967
  const MINIMUM_SLOT_PER_EPOCH = 32; // Returns the number of trailing zeros in the binary representation of self.
3422
5968
 
3423
5969
  function trailingZeros(n) {
@@ -3916,14 +6462,34 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
3916
6462
  * A performance sample
3917
6463
  */
3918
6464
 
3919
- function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
6465
+ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
3920
6466
  const fetch = customFetch ? customFetch : fetchImpl;
3921
- let agentManager;
6467
+ let agent;
3922
6468
 
3923
6469
  {
3924
- agentManager = new AgentManager(url.startsWith('https:')
3925
- /* useHttps */
3926
- );
6470
+ if (httpAgent == null) {
6471
+ {
6472
+ agent = new Agent({
6473
+ // One second fewer than the Solana RPC's keepalive timeout.
6474
+ // Read more: https://github.com/solana-labs/solana/issues/27859#issuecomment-1340097889
6475
+ freeSocketTimeout: 19000,
6476
+ keepAlive: true,
6477
+ maxSockets: 25
6478
+ });
6479
+ }
6480
+ } else {
6481
+ if (httpAgent !== false) {
6482
+ const isHttps = url.startsWith('https:');
6483
+
6484
+ if (isHttps && !(httpAgent instanceof Agent$2)) {
6485
+ throw new Error('The endpoint `' + url + '` can only be paired with an `https.Agent`. You have, instead, supplied an ' + '`http.Agent` through `httpAgent`.');
6486
+ } else if (!isHttps && httpAgent instanceof Agent$2) {
6487
+ throw new Error('The endpoint `' + url + '` can only be paired with an `http.Agent`. You have, instead, supplied an ' + '`https.Agent` through `httpAgent`.');
6488
+ }
6489
+
6490
+ agent = httpAgent;
6491
+ }
6492
+ }
3927
6493
  }
3928
6494
 
3929
6495
  let fetchWithMiddleware;
@@ -3942,7 +6508,6 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
3942
6508
  }
3943
6509
 
3944
6510
  const clientBrowser = new RpcClient(async (request, callback) => {
3945
- const agent = agentManager ? agentManager.requestStart() : undefined;
3946
6511
  const options = {
3947
6512
  method: 'POST',
3948
6513
  body: request,
@@ -3994,8 +6559,6 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
3994
6559
  }
3995
6560
  } catch (err) {
3996
6561
  if (err instanceof Error) callback(err);
3997
- } finally {
3998
- agentManager && agentManager.requestEnd();
3999
6562
  }
4000
6563
  }, {});
4001
6564
  return clientBrowser;
@@ -4833,6 +7396,7 @@ class Connection {
4833
7396
  let fetch;
4834
7397
  let fetchMiddleware;
4835
7398
  let disableRetryOnRateLimit;
7399
+ let httpAgent;
4836
7400
 
4837
7401
  if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
4838
7402
  this._commitment = commitmentOrConfig;
@@ -4844,11 +7408,12 @@ class Connection {
4844
7408
  fetch = commitmentOrConfig.fetch;
4845
7409
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
4846
7410
  disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
7411
+ httpAgent = commitmentOrConfig.httpAgent;
4847
7412
  }
4848
7413
 
4849
7414
  this._rpcEndpoint = assertEndpointUrl(endpoint);
4850
7415
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
4851
- this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
7416
+ this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
4852
7417
  this._rpcRequest = createRpcRequest(this._rpcClient);
4853
7418
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
4854
7419
  this._rpcWebSocket = new Client(this._rpcWsEndpoint, {