pusher-js 8.0.2 → 8.1.0
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/CHANGELOG.md +5 -0
- package/dist/node/pusher.js +968 -1390
- package/dist/node/pusher.js.map +1 -1
- package/dist/react-native/pusher.js +2 -2
- package/dist/react-native/pusher.js.map +1 -1
- package/dist/web/pusher-with-encryption.js +1003 -1433
- package/dist/web/pusher-with-encryption.js.map +1 -1
- package/dist/web/pusher-with-encryption.min.js +2 -2
- package/dist/web/pusher-with-encryption.min.js.map +1 -1
- package/dist/web/pusher.js +994 -1409
- package/dist/web/pusher.js.map +1 -1
- package/dist/web/pusher.min.js +2 -2
- package/dist/web/pusher.min.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.js +968 -1389
- package/dist/worker/pusher-with-encryption.worker.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.min.js +2 -2
- package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -1
- package/dist/worker/pusher.worker.js +959 -1365
- package/dist/worker/pusher.worker.js.map +1 -1
- package/dist/worker/pusher.worker.min.js +2 -2
- package/dist/worker/pusher.worker.min.js.map +1 -1
- package/package.json +6 -6
- package/tsconfig.json +1 -1
- package/types/src/core/auth/options.d.ts +3 -3
- package/types/src/core/config.d.ts +2 -2
- package/types/src/core/strategies/transport_strategy.d.ts +0 -3
- package/types/src/core/utils/timers/scheduling.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v8.0
|
|
2
|
+
* Pusher JavaScript Library v8.1.0
|
|
3
3
|
* https://pusher.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020, Pusher
|
|
@@ -2963,6 +2963,9 @@ module.exports = __webpack_require__(5).default;
|
|
|
2963
2963
|
// ESM COMPAT FLAG
|
|
2964
2964
|
__webpack_require__.r(__webpack_exports__);
|
|
2965
2965
|
|
|
2966
|
+
// EXPORTS
|
|
2967
|
+
__webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ pusher_with_encryption_PusherWithEncryption; });
|
|
2968
|
+
|
|
2966
2969
|
// CONCATENATED MODULE: ./src/core/base64.ts
|
|
2967
2970
|
function encode(s) {
|
|
2968
2971
|
return btoa(utob(s));
|
|
@@ -3005,43 +3008,28 @@ var btoa = self.btoa ||
|
|
|
3005
3008
|
};
|
|
3006
3009
|
|
|
3007
3010
|
// CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
var _this = this;
|
|
3011
|
+
class Timer {
|
|
3012
|
+
constructor(set, clear, delay, callback) {
|
|
3011
3013
|
this.clear = clear;
|
|
3012
|
-
this.timer = set(
|
|
3013
|
-
if (
|
|
3014
|
-
|
|
3014
|
+
this.timer = set(() => {
|
|
3015
|
+
if (this.timer) {
|
|
3016
|
+
this.timer = callback(this.timer);
|
|
3015
3017
|
}
|
|
3016
3018
|
}, delay);
|
|
3017
3019
|
}
|
|
3018
|
-
|
|
3020
|
+
isRunning() {
|
|
3019
3021
|
return this.timer !== null;
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
+
}
|
|
3023
|
+
ensureAborted() {
|
|
3022
3024
|
if (this.timer) {
|
|
3023
3025
|
this.clear(this.timer);
|
|
3024
3026
|
this.timer = null;
|
|
3025
3027
|
}
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
}());
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3029
3030
|
/* harmony default export */ var abstract_timer = (Timer);
|
|
3030
3031
|
|
|
3031
3032
|
// CONCATENATED MODULE: ./src/core/utils/timers/index.ts
|
|
3032
|
-
var __extends = (undefined && undefined.__extends) || (function () {
|
|
3033
|
-
var extendStatics = function (d, b) {
|
|
3034
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3035
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3036
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
3037
|
-
return extendStatics(d, b);
|
|
3038
|
-
};
|
|
3039
|
-
return function (d, b) {
|
|
3040
|
-
extendStatics(d, b);
|
|
3041
|
-
function __() { this.constructor = d; }
|
|
3042
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3043
|
-
};
|
|
3044
|
-
})();
|
|
3045
3033
|
|
|
3046
3034
|
function timers_clearTimeout(timer) {
|
|
3047
3035
|
self.clearTimeout(timer);
|
|
@@ -3049,33 +3037,27 @@ function timers_clearTimeout(timer) {
|
|
|
3049
3037
|
function timers_clearInterval(timer) {
|
|
3050
3038
|
self.clearInterval(timer);
|
|
3051
3039
|
}
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
3040
|
+
class timers_OneOffTimer extends abstract_timer {
|
|
3041
|
+
constructor(delay, callback) {
|
|
3042
|
+
super(setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
3056
3043
|
callback();
|
|
3057
3044
|
return null;
|
|
3058
|
-
})
|
|
3045
|
+
});
|
|
3059
3046
|
}
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
__extends(PeriodicTimer, _super);
|
|
3065
|
-
function PeriodicTimer(delay, callback) {
|
|
3066
|
-
return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
|
|
3047
|
+
}
|
|
3048
|
+
class timers_PeriodicTimer extends abstract_timer {
|
|
3049
|
+
constructor(delay, callback) {
|
|
3050
|
+
super(setInterval, timers_clearInterval, delay, function (timer) {
|
|
3067
3051
|
callback();
|
|
3068
3052
|
return timer;
|
|
3069
|
-
})
|
|
3053
|
+
});
|
|
3070
3054
|
}
|
|
3071
|
-
|
|
3072
|
-
}(abstract_timer));
|
|
3073
|
-
|
|
3055
|
+
}
|
|
3074
3056
|
|
|
3075
3057
|
// CONCATENATED MODULE: ./src/core/util.ts
|
|
3076
3058
|
|
|
3077
3059
|
var Util = {
|
|
3078
|
-
now
|
|
3060
|
+
now() {
|
|
3079
3061
|
if (Date.now) {
|
|
3080
3062
|
return Date.now();
|
|
3081
3063
|
}
|
|
@@ -3083,14 +3065,10 @@ var Util = {
|
|
|
3083
3065
|
return new Date().valueOf();
|
|
3084
3066
|
}
|
|
3085
3067
|
},
|
|
3086
|
-
defer
|
|
3087
|
-
return new
|
|
3068
|
+
defer(callback) {
|
|
3069
|
+
return new timers_OneOffTimer(0, callback);
|
|
3088
3070
|
},
|
|
3089
|
-
method
|
|
3090
|
-
var args = [];
|
|
3091
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3092
|
-
args[_i - 1] = arguments[_i];
|
|
3093
|
-
}
|
|
3071
|
+
method(name, ...args) {
|
|
3094
3072
|
var boundArguments = Array.prototype.slice.call(arguments, 1);
|
|
3095
3073
|
return function (object) {
|
|
3096
3074
|
return object[name].apply(object, boundArguments.concat(arguments));
|
|
@@ -3102,11 +3080,7 @@ var Util = {
|
|
|
3102
3080
|
// CONCATENATED MODULE: ./src/core/utils/collections.ts
|
|
3103
3081
|
|
|
3104
3082
|
|
|
3105
|
-
function extend(target) {
|
|
3106
|
-
var sources = [];
|
|
3107
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3108
|
-
sources[_i - 1] = arguments[_i];
|
|
3109
|
-
}
|
|
3083
|
+
function extend(target, ...sources) {
|
|
3110
3084
|
for (var i = 0; i < sources.length; i++) {
|
|
3111
3085
|
var extensions = sources[i];
|
|
3112
3086
|
for (var property in extensions) {
|
|
@@ -3299,7 +3273,7 @@ function safeJSONStringify(source) {
|
|
|
3299
3273
|
|
|
3300
3274
|
// CONCATENATED MODULE: ./src/core/defaults.ts
|
|
3301
3275
|
var Defaults = {
|
|
3302
|
-
VERSION: "8.0
|
|
3276
|
+
VERSION: "8.1.0",
|
|
3303
3277
|
PROTOCOL: 7,
|
|
3304
3278
|
wsPort: 80,
|
|
3305
3279
|
wssPort: 443,
|
|
@@ -3368,14 +3342,14 @@ var sockjs = {
|
|
|
3368
3342
|
|
|
3369
3343
|
// CONCATENATED MODULE: ./src/core/events/callback_registry.ts
|
|
3370
3344
|
|
|
3371
|
-
|
|
3372
|
-
|
|
3345
|
+
class callback_registry_CallbackRegistry {
|
|
3346
|
+
constructor() {
|
|
3373
3347
|
this._callbacks = {};
|
|
3374
3348
|
}
|
|
3375
|
-
|
|
3349
|
+
get(name) {
|
|
3376
3350
|
return this._callbacks[prefix(name)];
|
|
3377
|
-
}
|
|
3378
|
-
|
|
3351
|
+
}
|
|
3352
|
+
add(name, callback, context) {
|
|
3379
3353
|
var prefixedEventName = prefix(name);
|
|
3380
3354
|
this._callbacks[prefixedEventName] =
|
|
3381
3355
|
this._callbacks[prefixedEventName] || [];
|
|
@@ -3383,8 +3357,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
3383
3357
|
fn: callback,
|
|
3384
3358
|
context: context
|
|
3385
3359
|
});
|
|
3386
|
-
}
|
|
3387
|
-
|
|
3360
|
+
}
|
|
3361
|
+
remove(name, callback, context) {
|
|
3388
3362
|
if (!name && !callback && !context) {
|
|
3389
3363
|
this._callbacks = {};
|
|
3390
3364
|
return;
|
|
@@ -3396,8 +3370,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
3396
3370
|
else {
|
|
3397
3371
|
this.removeAllCallbacks(names);
|
|
3398
3372
|
}
|
|
3399
|
-
}
|
|
3400
|
-
|
|
3373
|
+
}
|
|
3374
|
+
removeCallback(names, callback, context) {
|
|
3401
3375
|
apply(names, function (name) {
|
|
3402
3376
|
this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
|
|
3403
3377
|
return ((callback && callback !== binding.fn) ||
|
|
@@ -3407,15 +3381,13 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
3407
3381
|
delete this._callbacks[name];
|
|
3408
3382
|
}
|
|
3409
3383
|
}, this);
|
|
3410
|
-
}
|
|
3411
|
-
|
|
3384
|
+
}
|
|
3385
|
+
removeAllCallbacks(names) {
|
|
3412
3386
|
apply(names, function (name) {
|
|
3413
3387
|
delete this._callbacks[name];
|
|
3414
3388
|
}, this);
|
|
3415
|
-
}
|
|
3416
|
-
|
|
3417
|
-
}());
|
|
3418
|
-
/* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3419
3391
|
function prefix(name) {
|
|
3420
3392
|
return '_' + name;
|
|
3421
3393
|
}
|
|
@@ -3423,38 +3395,38 @@ function prefix(name) {
|
|
|
3423
3395
|
// CONCATENATED MODULE: ./src/core/events/dispatcher.ts
|
|
3424
3396
|
|
|
3425
3397
|
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
this.callbacks = new
|
|
3398
|
+
class dispatcher_Dispatcher {
|
|
3399
|
+
constructor(failThrough) {
|
|
3400
|
+
this.callbacks = new callback_registry_CallbackRegistry();
|
|
3429
3401
|
this.global_callbacks = [];
|
|
3430
3402
|
this.failThrough = failThrough;
|
|
3431
3403
|
}
|
|
3432
|
-
|
|
3404
|
+
bind(eventName, callback, context) {
|
|
3433
3405
|
this.callbacks.add(eventName, callback, context);
|
|
3434
3406
|
return this;
|
|
3435
|
-
}
|
|
3436
|
-
|
|
3407
|
+
}
|
|
3408
|
+
bind_global(callback) {
|
|
3437
3409
|
this.global_callbacks.push(callback);
|
|
3438
3410
|
return this;
|
|
3439
|
-
}
|
|
3440
|
-
|
|
3411
|
+
}
|
|
3412
|
+
unbind(eventName, callback, context) {
|
|
3441
3413
|
this.callbacks.remove(eventName, callback, context);
|
|
3442
3414
|
return this;
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3415
|
+
}
|
|
3416
|
+
unbind_global(callback) {
|
|
3445
3417
|
if (!callback) {
|
|
3446
3418
|
this.global_callbacks = [];
|
|
3447
3419
|
return this;
|
|
3448
3420
|
}
|
|
3449
|
-
this.global_callbacks = filter(this.global_callbacks || [],
|
|
3421
|
+
this.global_callbacks = filter(this.global_callbacks || [], c => c !== callback);
|
|
3450
3422
|
return this;
|
|
3451
|
-
}
|
|
3452
|
-
|
|
3423
|
+
}
|
|
3424
|
+
unbind_all() {
|
|
3453
3425
|
this.unbind();
|
|
3454
3426
|
this.unbind_global();
|
|
3455
3427
|
return this;
|
|
3456
|
-
}
|
|
3457
|
-
|
|
3428
|
+
}
|
|
3429
|
+
emit(eventName, data, metadata) {
|
|
3458
3430
|
for (var i = 0; i < this.global_callbacks.length; i++) {
|
|
3459
3431
|
this.global_callbacks[i](eventName, data);
|
|
3460
3432
|
}
|
|
@@ -3475,120 +3447,85 @@ var dispatcher_Dispatcher = (function () {
|
|
|
3475
3447
|
this.failThrough(eventName, data);
|
|
3476
3448
|
}
|
|
3477
3449
|
return this;
|
|
3478
|
-
}
|
|
3479
|
-
|
|
3480
|
-
}());
|
|
3481
|
-
/* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3482
3452
|
|
|
3483
3453
|
// CONCATENATED MODULE: ./src/core/logger.ts
|
|
3484
3454
|
|
|
3485
3455
|
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
this.globalLog =
|
|
3456
|
+
class logger_Logger {
|
|
3457
|
+
constructor() {
|
|
3458
|
+
this.globalLog = (message) => {
|
|
3489
3459
|
if (self.console && self.console.log) {
|
|
3490
3460
|
self.console.log(message);
|
|
3491
3461
|
}
|
|
3492
3462
|
};
|
|
3493
3463
|
}
|
|
3494
|
-
|
|
3495
|
-
var args = [];
|
|
3496
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3497
|
-
args[_i] = arguments[_i];
|
|
3498
|
-
}
|
|
3464
|
+
debug(...args) {
|
|
3499
3465
|
this.log(this.globalLog, args);
|
|
3500
|
-
}
|
|
3501
|
-
|
|
3502
|
-
var args = [];
|
|
3503
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3504
|
-
args[_i] = arguments[_i];
|
|
3505
|
-
}
|
|
3466
|
+
}
|
|
3467
|
+
warn(...args) {
|
|
3506
3468
|
this.log(this.globalLogWarn, args);
|
|
3507
|
-
}
|
|
3508
|
-
|
|
3509
|
-
var args = [];
|
|
3510
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3511
|
-
args[_i] = arguments[_i];
|
|
3512
|
-
}
|
|
3469
|
+
}
|
|
3470
|
+
error(...args) {
|
|
3513
3471
|
this.log(this.globalLogError, args);
|
|
3514
|
-
}
|
|
3515
|
-
|
|
3472
|
+
}
|
|
3473
|
+
globalLogWarn(message) {
|
|
3516
3474
|
if (self.console && self.console.warn) {
|
|
3517
3475
|
self.console.warn(message);
|
|
3518
3476
|
}
|
|
3519
3477
|
else {
|
|
3520
3478
|
this.globalLog(message);
|
|
3521
3479
|
}
|
|
3522
|
-
}
|
|
3523
|
-
|
|
3480
|
+
}
|
|
3481
|
+
globalLogError(message) {
|
|
3524
3482
|
if (self.console && self.console.error) {
|
|
3525
3483
|
self.console.error(message);
|
|
3526
3484
|
}
|
|
3527
3485
|
else {
|
|
3528
3486
|
this.globalLogWarn(message);
|
|
3529
3487
|
}
|
|
3530
|
-
}
|
|
3531
|
-
|
|
3532
|
-
var args = [];
|
|
3533
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3534
|
-
args[_i - 1] = arguments[_i];
|
|
3535
|
-
}
|
|
3488
|
+
}
|
|
3489
|
+
log(defaultLoggingFunction, ...args) {
|
|
3536
3490
|
var message = stringify.apply(this, arguments);
|
|
3537
3491
|
if (core_pusher.log) {
|
|
3538
3492
|
core_pusher.log(message);
|
|
3539
3493
|
}
|
|
3540
3494
|
else if (core_pusher.logToConsole) {
|
|
3541
|
-
|
|
3495
|
+
const log = defaultLoggingFunction.bind(this);
|
|
3542
3496
|
log(message);
|
|
3543
3497
|
}
|
|
3544
|
-
}
|
|
3545
|
-
|
|
3546
|
-
}());
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3547
3500
|
/* harmony default export */ var logger = (new logger_Logger());
|
|
3548
3501
|
|
|
3549
3502
|
// CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
|
|
3550
|
-
var transport_connection_extends = (undefined && undefined.__extends) || (function () {
|
|
3551
|
-
var extendStatics = function (d, b) {
|
|
3552
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3553
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3554
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
3555
|
-
return extendStatics(d, b);
|
|
3556
|
-
};
|
|
3557
|
-
return function (d, b) {
|
|
3558
|
-
extendStatics(d, b);
|
|
3559
|
-
function __() { this.constructor = d; }
|
|
3560
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3561
|
-
};
|
|
3562
|
-
})();
|
|
3563
3503
|
|
|
3564
3504
|
|
|
3565
3505
|
|
|
3566
3506
|
|
|
3567
3507
|
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
_this.id = _this.timeline.generateUniqueID();
|
|
3582
|
-
return _this;
|
|
3508
|
+
class transport_connection_TransportConnection extends dispatcher_Dispatcher {
|
|
3509
|
+
constructor(hooks, name, priority, key, options) {
|
|
3510
|
+
super();
|
|
3511
|
+
this.initialize = worker_runtime.transportConnectionInitializer;
|
|
3512
|
+
this.hooks = hooks;
|
|
3513
|
+
this.name = name;
|
|
3514
|
+
this.priority = priority;
|
|
3515
|
+
this.key = key;
|
|
3516
|
+
this.options = options;
|
|
3517
|
+
this.state = 'new';
|
|
3518
|
+
this.timeline = options.timeline;
|
|
3519
|
+
this.activityTimeout = options.activityTimeout;
|
|
3520
|
+
this.id = this.timeline.generateUniqueID();
|
|
3583
3521
|
}
|
|
3584
|
-
|
|
3522
|
+
handlesActivityChecks() {
|
|
3585
3523
|
return Boolean(this.hooks.handlesActivityChecks);
|
|
3586
|
-
}
|
|
3587
|
-
|
|
3524
|
+
}
|
|
3525
|
+
supportsPing() {
|
|
3588
3526
|
return Boolean(this.hooks.supportsPing);
|
|
3589
|
-
}
|
|
3590
|
-
|
|
3591
|
-
var _this = this;
|
|
3527
|
+
}
|
|
3528
|
+
connect() {
|
|
3592
3529
|
if (this.socket || this.state !== 'initialized') {
|
|
3593
3530
|
return false;
|
|
3594
3531
|
}
|
|
@@ -3597,18 +3534,18 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
3597
3534
|
this.socket = this.hooks.getSocket(url, this.options);
|
|
3598
3535
|
}
|
|
3599
3536
|
catch (e) {
|
|
3600
|
-
util.defer(
|
|
3601
|
-
|
|
3602
|
-
|
|
3537
|
+
util.defer(() => {
|
|
3538
|
+
this.onError(e);
|
|
3539
|
+
this.changeState('closed');
|
|
3603
3540
|
});
|
|
3604
3541
|
return false;
|
|
3605
3542
|
}
|
|
3606
3543
|
this.bindListeners();
|
|
3607
|
-
logger.debug('Connecting', { transport: this.name, url
|
|
3544
|
+
logger.debug('Connecting', { transport: this.name, url });
|
|
3608
3545
|
this.changeState('connecting');
|
|
3609
3546
|
return true;
|
|
3610
|
-
}
|
|
3611
|
-
|
|
3547
|
+
}
|
|
3548
|
+
close() {
|
|
3612
3549
|
if (this.socket) {
|
|
3613
3550
|
this.socket.close();
|
|
3614
3551
|
return true;
|
|
@@ -3616,13 +3553,12 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
3616
3553
|
else {
|
|
3617
3554
|
return false;
|
|
3618
3555
|
}
|
|
3619
|
-
}
|
|
3620
|
-
|
|
3621
|
-
var _this = this;
|
|
3556
|
+
}
|
|
3557
|
+
send(data) {
|
|
3622
3558
|
if (this.state === 'open') {
|
|
3623
|
-
util.defer(
|
|
3624
|
-
if (
|
|
3625
|
-
|
|
3559
|
+
util.defer(() => {
|
|
3560
|
+
if (this.socket) {
|
|
3561
|
+
this.socket.send(data);
|
|
3626
3562
|
}
|
|
3627
3563
|
});
|
|
3628
3564
|
return true;
|
|
@@ -3630,24 +3566,24 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
3630
3566
|
else {
|
|
3631
3567
|
return false;
|
|
3632
3568
|
}
|
|
3633
|
-
}
|
|
3634
|
-
|
|
3569
|
+
}
|
|
3570
|
+
ping() {
|
|
3635
3571
|
if (this.state === 'open' && this.supportsPing()) {
|
|
3636
3572
|
this.socket.ping();
|
|
3637
3573
|
}
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3574
|
+
}
|
|
3575
|
+
onOpen() {
|
|
3640
3576
|
if (this.hooks.beforeOpen) {
|
|
3641
3577
|
this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
|
|
3642
3578
|
}
|
|
3643
3579
|
this.changeState('open');
|
|
3644
3580
|
this.socket.onopen = undefined;
|
|
3645
|
-
}
|
|
3646
|
-
|
|
3581
|
+
}
|
|
3582
|
+
onError(error) {
|
|
3647
3583
|
this.emit('error', { type: 'WebSocketError', error: error });
|
|
3648
3584
|
this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
|
|
3649
|
-
}
|
|
3650
|
-
|
|
3585
|
+
}
|
|
3586
|
+
onClose(closeEvent) {
|
|
3651
3587
|
if (closeEvent) {
|
|
3652
3588
|
this.changeState('closed', {
|
|
3653
3589
|
code: closeEvent.code,
|
|
@@ -3660,34 +3596,33 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
3660
3596
|
}
|
|
3661
3597
|
this.unbindListeners();
|
|
3662
3598
|
this.socket = undefined;
|
|
3663
|
-
}
|
|
3664
|
-
|
|
3599
|
+
}
|
|
3600
|
+
onMessage(message) {
|
|
3665
3601
|
this.emit('message', message);
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3602
|
+
}
|
|
3603
|
+
onActivity() {
|
|
3668
3604
|
this.emit('activity');
|
|
3669
|
-
}
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
_this.onOpen();
|
|
3605
|
+
}
|
|
3606
|
+
bindListeners() {
|
|
3607
|
+
this.socket.onopen = () => {
|
|
3608
|
+
this.onOpen();
|
|
3674
3609
|
};
|
|
3675
|
-
this.socket.onerror =
|
|
3676
|
-
|
|
3610
|
+
this.socket.onerror = error => {
|
|
3611
|
+
this.onError(error);
|
|
3677
3612
|
};
|
|
3678
|
-
this.socket.onclose =
|
|
3679
|
-
|
|
3613
|
+
this.socket.onclose = closeEvent => {
|
|
3614
|
+
this.onClose(closeEvent);
|
|
3680
3615
|
};
|
|
3681
|
-
this.socket.onmessage =
|
|
3682
|
-
|
|
3616
|
+
this.socket.onmessage = message => {
|
|
3617
|
+
this.onMessage(message);
|
|
3683
3618
|
};
|
|
3684
3619
|
if (this.supportsPing()) {
|
|
3685
|
-
this.socket.onactivity =
|
|
3686
|
-
|
|
3620
|
+
this.socket.onactivity = () => {
|
|
3621
|
+
this.onActivity();
|
|
3687
3622
|
};
|
|
3688
3623
|
}
|
|
3689
|
-
}
|
|
3690
|
-
|
|
3624
|
+
}
|
|
3625
|
+
unbindListeners() {
|
|
3691
3626
|
if (this.socket) {
|
|
3692
3627
|
this.socket.onopen = undefined;
|
|
3693
3628
|
this.socket.onerror = undefined;
|
|
@@ -3697,44 +3632,40 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
3697
3632
|
this.socket.onactivity = undefined;
|
|
3698
3633
|
}
|
|
3699
3634
|
}
|
|
3700
|
-
}
|
|
3701
|
-
|
|
3635
|
+
}
|
|
3636
|
+
changeState(state, params) {
|
|
3702
3637
|
this.state = state;
|
|
3703
3638
|
this.timeline.info(this.buildTimelineMessage({
|
|
3704
3639
|
state: state,
|
|
3705
3640
|
params: params
|
|
3706
3641
|
}));
|
|
3707
3642
|
this.emit(state, params);
|
|
3708
|
-
}
|
|
3709
|
-
|
|
3643
|
+
}
|
|
3644
|
+
buildTimelineMessage(message) {
|
|
3710
3645
|
return extend({ cid: this.id }, message);
|
|
3711
|
-
}
|
|
3712
|
-
|
|
3713
|
-
}(dispatcher));
|
|
3714
|
-
/* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3715
3648
|
|
|
3716
3649
|
// CONCATENATED MODULE: ./src/core/transports/transport.ts
|
|
3717
3650
|
|
|
3718
|
-
|
|
3719
|
-
|
|
3651
|
+
class transport_Transport {
|
|
3652
|
+
constructor(hooks) {
|
|
3720
3653
|
this.hooks = hooks;
|
|
3721
3654
|
}
|
|
3722
|
-
|
|
3655
|
+
isSupported(environment) {
|
|
3723
3656
|
return this.hooks.isSupported(environment);
|
|
3724
|
-
}
|
|
3725
|
-
|
|
3726
|
-
return new
|
|
3727
|
-
}
|
|
3728
|
-
|
|
3729
|
-
}());
|
|
3730
|
-
/* harmony default export */ var transports_transport = (transport_Transport);
|
|
3657
|
+
}
|
|
3658
|
+
createConnection(name, priority, key, options) {
|
|
3659
|
+
return new transport_connection_TransportConnection(this.hooks, name, priority, key, options);
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3731
3662
|
|
|
3732
3663
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
|
|
3733
3664
|
|
|
3734
3665
|
|
|
3735
3666
|
|
|
3736
3667
|
|
|
3737
|
-
var WSTransport = new
|
|
3668
|
+
var WSTransport = new transport_Transport({
|
|
3738
3669
|
urls: ws,
|
|
3739
3670
|
handlesActivityChecks: false,
|
|
3740
3671
|
supportsPing: false,
|
|
@@ -3771,8 +3702,8 @@ var xhrConfiguration = {
|
|
|
3771
3702
|
return worker_runtime.isXHRSupported();
|
|
3772
3703
|
}
|
|
3773
3704
|
};
|
|
3774
|
-
var XHRStreamingTransport = new
|
|
3775
|
-
var XHRPollingTransport = new
|
|
3705
|
+
var XHRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xhrConfiguration)));
|
|
3706
|
+
var XHRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xhrConfiguration));
|
|
3776
3707
|
var Transports = {
|
|
3777
3708
|
ws: WSTransport,
|
|
3778
3709
|
xhr_streaming: XHRStreamingTransport,
|
|
@@ -3783,16 +3714,15 @@ var Transports = {
|
|
|
3783
3714
|
// CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
|
|
3784
3715
|
|
|
3785
3716
|
|
|
3786
|
-
|
|
3787
|
-
|
|
3717
|
+
class assistant_to_the_transport_manager_AssistantToTheTransportManager {
|
|
3718
|
+
constructor(manager, transport, options) {
|
|
3788
3719
|
this.manager = manager;
|
|
3789
3720
|
this.transport = transport;
|
|
3790
3721
|
this.minPingDelay = options.minPingDelay;
|
|
3791
3722
|
this.maxPingDelay = options.maxPingDelay;
|
|
3792
3723
|
this.pingDelay = undefined;
|
|
3793
3724
|
}
|
|
3794
|
-
|
|
3795
|
-
var _this = this;
|
|
3725
|
+
createConnection(name, priority, key, options) {
|
|
3796
3726
|
options = extend({}, options, {
|
|
3797
3727
|
activityTimeout: this.pingDelay
|
|
3798
3728
|
});
|
|
@@ -3803,31 +3733,29 @@ var assistant_to_the_transport_manager_AssistantToTheTransportManager = (functio
|
|
|
3803
3733
|
connection.bind('closed', onClosed);
|
|
3804
3734
|
openTimestamp = util.now();
|
|
3805
3735
|
};
|
|
3806
|
-
var onClosed =
|
|
3736
|
+
var onClosed = closeEvent => {
|
|
3807
3737
|
connection.unbind('closed', onClosed);
|
|
3808
3738
|
if (closeEvent.code === 1002 || closeEvent.code === 1003) {
|
|
3809
|
-
|
|
3739
|
+
this.manager.reportDeath();
|
|
3810
3740
|
}
|
|
3811
3741
|
else if (!closeEvent.wasClean && openTimestamp) {
|
|
3812
3742
|
var lifespan = util.now() - openTimestamp;
|
|
3813
|
-
if (lifespan < 2 *
|
|
3814
|
-
|
|
3815
|
-
|
|
3743
|
+
if (lifespan < 2 * this.maxPingDelay) {
|
|
3744
|
+
this.manager.reportDeath();
|
|
3745
|
+
this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);
|
|
3816
3746
|
}
|
|
3817
3747
|
}
|
|
3818
3748
|
};
|
|
3819
3749
|
connection.bind('open', onOpen);
|
|
3820
3750
|
return connection;
|
|
3821
|
-
}
|
|
3822
|
-
|
|
3751
|
+
}
|
|
3752
|
+
isSupported(environment) {
|
|
3823
3753
|
return this.manager.isAlive() && this.transport.isSupported(environment);
|
|
3824
|
-
}
|
|
3825
|
-
|
|
3826
|
-
}());
|
|
3827
|
-
/* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3828
3756
|
|
|
3829
3757
|
// CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
|
|
3830
|
-
|
|
3758
|
+
const Protocol = {
|
|
3831
3759
|
decodeMessage: function (messageEvent) {
|
|
3832
3760
|
try {
|
|
3833
3761
|
var messageData = JSON.parse(messageEvent.data);
|
|
@@ -3920,68 +3848,52 @@ var Protocol = {
|
|
|
3920
3848
|
/* harmony default export */ var protocol = (Protocol);
|
|
3921
3849
|
|
|
3922
3850
|
// CONCATENATED MODULE: ./src/core/connection/connection.ts
|
|
3923
|
-
var connection_extends = (undefined && undefined.__extends) || (function () {
|
|
3924
|
-
var extendStatics = function (d, b) {
|
|
3925
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3926
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3927
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
3928
|
-
return extendStatics(d, b);
|
|
3929
|
-
};
|
|
3930
|
-
return function (d, b) {
|
|
3931
|
-
extendStatics(d, b);
|
|
3932
|
-
function __() { this.constructor = d; }
|
|
3933
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3934
|
-
};
|
|
3935
|
-
})();
|
|
3936
3851
|
|
|
3937
3852
|
|
|
3938
3853
|
|
|
3939
3854
|
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
_this.bindListeners();
|
|
3948
|
-
return _this;
|
|
3855
|
+
class connection_Connection extends dispatcher_Dispatcher {
|
|
3856
|
+
constructor(id, transport) {
|
|
3857
|
+
super();
|
|
3858
|
+
this.id = id;
|
|
3859
|
+
this.transport = transport;
|
|
3860
|
+
this.activityTimeout = transport.activityTimeout;
|
|
3861
|
+
this.bindListeners();
|
|
3949
3862
|
}
|
|
3950
|
-
|
|
3863
|
+
handlesActivityChecks() {
|
|
3951
3864
|
return this.transport.handlesActivityChecks();
|
|
3952
|
-
}
|
|
3953
|
-
|
|
3865
|
+
}
|
|
3866
|
+
send(data) {
|
|
3954
3867
|
return this.transport.send(data);
|
|
3955
|
-
}
|
|
3956
|
-
|
|
3868
|
+
}
|
|
3869
|
+
send_event(name, data, channel) {
|
|
3957
3870
|
var event = { event: name, data: data };
|
|
3958
3871
|
if (channel) {
|
|
3959
3872
|
event.channel = channel;
|
|
3960
3873
|
}
|
|
3961
3874
|
logger.debug('Event sent', event);
|
|
3962
3875
|
return this.send(protocol.encodeMessage(event));
|
|
3963
|
-
}
|
|
3964
|
-
|
|
3876
|
+
}
|
|
3877
|
+
ping() {
|
|
3965
3878
|
if (this.transport.supportsPing()) {
|
|
3966
3879
|
this.transport.ping();
|
|
3967
3880
|
}
|
|
3968
3881
|
else {
|
|
3969
3882
|
this.send_event('pusher:ping', {});
|
|
3970
3883
|
}
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3884
|
+
}
|
|
3885
|
+
close() {
|
|
3973
3886
|
this.transport.close();
|
|
3974
|
-
}
|
|
3975
|
-
|
|
3976
|
-
var _this = this;
|
|
3887
|
+
}
|
|
3888
|
+
bindListeners() {
|
|
3977
3889
|
var listeners = {
|
|
3978
|
-
message:
|
|
3890
|
+
message: (messageEvent) => {
|
|
3979
3891
|
var pusherEvent;
|
|
3980
3892
|
try {
|
|
3981
3893
|
pusherEvent = protocol.decodeMessage(messageEvent);
|
|
3982
3894
|
}
|
|
3983
3895
|
catch (e) {
|
|
3984
|
-
|
|
3896
|
+
this.emit('error', {
|
|
3985
3897
|
type: 'MessageParseError',
|
|
3986
3898
|
error: e,
|
|
3987
3899
|
data: messageEvent.data
|
|
@@ -3991,46 +3903,46 @@ var connection_Connection = (function (_super) {
|
|
|
3991
3903
|
logger.debug('Event recd', pusherEvent);
|
|
3992
3904
|
switch (pusherEvent.event) {
|
|
3993
3905
|
case 'pusher:error':
|
|
3994
|
-
|
|
3906
|
+
this.emit('error', {
|
|
3995
3907
|
type: 'PusherError',
|
|
3996
3908
|
data: pusherEvent.data
|
|
3997
3909
|
});
|
|
3998
3910
|
break;
|
|
3999
3911
|
case 'pusher:ping':
|
|
4000
|
-
|
|
3912
|
+
this.emit('ping');
|
|
4001
3913
|
break;
|
|
4002
3914
|
case 'pusher:pong':
|
|
4003
|
-
|
|
3915
|
+
this.emit('pong');
|
|
4004
3916
|
break;
|
|
4005
3917
|
}
|
|
4006
|
-
|
|
3918
|
+
this.emit('message', pusherEvent);
|
|
4007
3919
|
}
|
|
4008
3920
|
},
|
|
4009
|
-
activity:
|
|
4010
|
-
|
|
3921
|
+
activity: () => {
|
|
3922
|
+
this.emit('activity');
|
|
4011
3923
|
},
|
|
4012
|
-
error:
|
|
4013
|
-
|
|
3924
|
+
error: error => {
|
|
3925
|
+
this.emit('error', error);
|
|
4014
3926
|
},
|
|
4015
|
-
closed:
|
|
3927
|
+
closed: closeEvent => {
|
|
4016
3928
|
unbindListeners();
|
|
4017
3929
|
if (closeEvent && closeEvent.code) {
|
|
4018
|
-
|
|
3930
|
+
this.handleCloseEvent(closeEvent);
|
|
4019
3931
|
}
|
|
4020
|
-
|
|
4021
|
-
|
|
3932
|
+
this.transport = null;
|
|
3933
|
+
this.emit('closed');
|
|
4022
3934
|
}
|
|
4023
3935
|
};
|
|
4024
|
-
var unbindListeners =
|
|
4025
|
-
objectApply(listeners,
|
|
4026
|
-
|
|
3936
|
+
var unbindListeners = () => {
|
|
3937
|
+
objectApply(listeners, (listener, event) => {
|
|
3938
|
+
this.transport.unbind(event, listener);
|
|
4027
3939
|
});
|
|
4028
3940
|
};
|
|
4029
|
-
objectApply(listeners,
|
|
4030
|
-
|
|
3941
|
+
objectApply(listeners, (listener, event) => {
|
|
3942
|
+
this.transport.bind(event, listener);
|
|
4031
3943
|
});
|
|
4032
|
-
}
|
|
4033
|
-
|
|
3944
|
+
}
|
|
3945
|
+
handleCloseEvent(closeEvent) {
|
|
4034
3946
|
var action = protocol.getCloseAction(closeEvent);
|
|
4035
3947
|
var error = protocol.getCloseError(closeEvent);
|
|
4036
3948
|
if (error) {
|
|
@@ -4039,203 +3951,138 @@ var connection_Connection = (function (_super) {
|
|
|
4039
3951
|
if (action) {
|
|
4040
3952
|
this.emit(action, { action: action, error: error });
|
|
4041
3953
|
}
|
|
4042
|
-
}
|
|
4043
|
-
|
|
4044
|
-
}(dispatcher));
|
|
4045
|
-
/* harmony default export */ var connection_connection = (connection_Connection);
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
4046
3956
|
|
|
4047
3957
|
// CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
|
|
4048
3958
|
|
|
4049
3959
|
|
|
4050
3960
|
|
|
4051
|
-
|
|
4052
|
-
|
|
3961
|
+
class handshake_Handshake {
|
|
3962
|
+
constructor(transport, callback) {
|
|
4053
3963
|
this.transport = transport;
|
|
4054
3964
|
this.callback = callback;
|
|
4055
3965
|
this.bindListeners();
|
|
4056
3966
|
}
|
|
4057
|
-
|
|
3967
|
+
close() {
|
|
4058
3968
|
this.unbindListeners();
|
|
4059
3969
|
this.transport.close();
|
|
4060
|
-
}
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
_this.unbindListeners();
|
|
3970
|
+
}
|
|
3971
|
+
bindListeners() {
|
|
3972
|
+
this.onMessage = m => {
|
|
3973
|
+
this.unbindListeners();
|
|
4065
3974
|
var result;
|
|
4066
3975
|
try {
|
|
4067
3976
|
result = protocol.processHandshake(m);
|
|
4068
3977
|
}
|
|
4069
3978
|
catch (e) {
|
|
4070
|
-
|
|
4071
|
-
|
|
3979
|
+
this.finish('error', { error: e });
|
|
3980
|
+
this.transport.close();
|
|
4072
3981
|
return;
|
|
4073
3982
|
}
|
|
4074
3983
|
if (result.action === 'connected') {
|
|
4075
|
-
|
|
4076
|
-
connection: new
|
|
3984
|
+
this.finish('connected', {
|
|
3985
|
+
connection: new connection_Connection(result.id, this.transport),
|
|
4077
3986
|
activityTimeout: result.activityTimeout
|
|
4078
3987
|
});
|
|
4079
3988
|
}
|
|
4080
3989
|
else {
|
|
4081
|
-
|
|
4082
|
-
|
|
3990
|
+
this.finish(result.action, { error: result.error });
|
|
3991
|
+
this.transport.close();
|
|
4083
3992
|
}
|
|
4084
3993
|
};
|
|
4085
|
-
this.onClosed =
|
|
4086
|
-
|
|
3994
|
+
this.onClosed = closeEvent => {
|
|
3995
|
+
this.unbindListeners();
|
|
4087
3996
|
var action = protocol.getCloseAction(closeEvent) || 'backoff';
|
|
4088
3997
|
var error = protocol.getCloseError(closeEvent);
|
|
4089
|
-
|
|
3998
|
+
this.finish(action, { error: error });
|
|
4090
3999
|
};
|
|
4091
4000
|
this.transport.bind('message', this.onMessage);
|
|
4092
4001
|
this.transport.bind('closed', this.onClosed);
|
|
4093
|
-
}
|
|
4094
|
-
|
|
4002
|
+
}
|
|
4003
|
+
unbindListeners() {
|
|
4095
4004
|
this.transport.unbind('message', this.onMessage);
|
|
4096
4005
|
this.transport.unbind('closed', this.onClosed);
|
|
4097
|
-
}
|
|
4098
|
-
|
|
4006
|
+
}
|
|
4007
|
+
finish(action, params) {
|
|
4099
4008
|
this.callback(extend({ transport: this.transport, action: action }, params));
|
|
4100
|
-
}
|
|
4101
|
-
|
|
4102
|
-
}());
|
|
4103
|
-
/* harmony default export */ var connection_handshake = (handshake_Handshake);
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4104
4011
|
|
|
4105
4012
|
// CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
|
|
4106
4013
|
|
|
4107
|
-
|
|
4108
|
-
|
|
4014
|
+
class timeline_sender_TimelineSender {
|
|
4015
|
+
constructor(timeline, options) {
|
|
4109
4016
|
this.timeline = timeline;
|
|
4110
4017
|
this.options = options || {};
|
|
4111
4018
|
}
|
|
4112
|
-
|
|
4019
|
+
send(useTLS, callback) {
|
|
4113
4020
|
if (this.timeline.isEmpty()) {
|
|
4114
4021
|
return;
|
|
4115
4022
|
}
|
|
4116
4023
|
this.timeline.send(worker_runtime.TimelineTransport.getAgent(this, useTLS), callback);
|
|
4117
|
-
}
|
|
4118
|
-
|
|
4119
|
-
}());
|
|
4120
|
-
/* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4121
4026
|
|
|
4122
4027
|
// CONCATENATED MODULE: ./src/core/errors.ts
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
}
|
|
4177
|
-
|
|
4178
|
-
}(Error));
|
|
4179
|
-
|
|
4180
|
-
var TransportClosed = (function (_super) {
|
|
4181
|
-
errors_extends(TransportClosed, _super);
|
|
4182
|
-
function TransportClosed(msg) {
|
|
4183
|
-
var _newTarget = this.constructor;
|
|
4184
|
-
var _this = _super.call(this, msg) || this;
|
|
4185
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
4186
|
-
return _this;
|
|
4187
|
-
}
|
|
4188
|
-
return TransportClosed;
|
|
4189
|
-
}(Error));
|
|
4190
|
-
|
|
4191
|
-
var UnsupportedFeature = (function (_super) {
|
|
4192
|
-
errors_extends(UnsupportedFeature, _super);
|
|
4193
|
-
function UnsupportedFeature(msg) {
|
|
4194
|
-
var _newTarget = this.constructor;
|
|
4195
|
-
var _this = _super.call(this, msg) || this;
|
|
4196
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
4197
|
-
return _this;
|
|
4198
|
-
}
|
|
4199
|
-
return UnsupportedFeature;
|
|
4200
|
-
}(Error));
|
|
4201
|
-
|
|
4202
|
-
var UnsupportedTransport = (function (_super) {
|
|
4203
|
-
errors_extends(UnsupportedTransport, _super);
|
|
4204
|
-
function UnsupportedTransport(msg) {
|
|
4205
|
-
var _newTarget = this.constructor;
|
|
4206
|
-
var _this = _super.call(this, msg) || this;
|
|
4207
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
4208
|
-
return _this;
|
|
4209
|
-
}
|
|
4210
|
-
return UnsupportedTransport;
|
|
4211
|
-
}(Error));
|
|
4212
|
-
|
|
4213
|
-
var UnsupportedStrategy = (function (_super) {
|
|
4214
|
-
errors_extends(UnsupportedStrategy, _super);
|
|
4215
|
-
function UnsupportedStrategy(msg) {
|
|
4216
|
-
var _newTarget = this.constructor;
|
|
4217
|
-
var _this = _super.call(this, msg) || this;
|
|
4218
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
4219
|
-
return _this;
|
|
4220
|
-
}
|
|
4221
|
-
return UnsupportedStrategy;
|
|
4222
|
-
}(Error));
|
|
4223
|
-
|
|
4224
|
-
var HTTPAuthError = (function (_super) {
|
|
4225
|
-
errors_extends(HTTPAuthError, _super);
|
|
4226
|
-
function HTTPAuthError(status, msg) {
|
|
4227
|
-
var _newTarget = this.constructor;
|
|
4228
|
-
var _this = _super.call(this, msg) || this;
|
|
4229
|
-
_this.status = status;
|
|
4230
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
4231
|
-
return _this;
|
|
4232
|
-
}
|
|
4233
|
-
return HTTPAuthError;
|
|
4234
|
-
}(Error));
|
|
4235
|
-
|
|
4028
|
+
class BadEventName extends Error {
|
|
4029
|
+
constructor(msg) {
|
|
4030
|
+
super(msg);
|
|
4031
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
class BadChannelName extends Error {
|
|
4035
|
+
constructor(msg) {
|
|
4036
|
+
super(msg);
|
|
4037
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
class RequestTimedOut extends Error {
|
|
4041
|
+
constructor(msg) {
|
|
4042
|
+
super(msg);
|
|
4043
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
class TransportPriorityTooLow extends Error {
|
|
4047
|
+
constructor(msg) {
|
|
4048
|
+
super(msg);
|
|
4049
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
class TransportClosed extends Error {
|
|
4053
|
+
constructor(msg) {
|
|
4054
|
+
super(msg);
|
|
4055
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
class UnsupportedFeature extends Error {
|
|
4059
|
+
constructor(msg) {
|
|
4060
|
+
super(msg);
|
|
4061
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
class UnsupportedTransport extends Error {
|
|
4065
|
+
constructor(msg) {
|
|
4066
|
+
super(msg);
|
|
4067
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
class UnsupportedStrategy extends Error {
|
|
4071
|
+
constructor(msg) {
|
|
4072
|
+
super(msg);
|
|
4073
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
class HTTPAuthError extends Error {
|
|
4077
|
+
constructor(status, msg) {
|
|
4078
|
+
super(msg);
|
|
4079
|
+
this.status = status;
|
|
4080
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4236
4083
|
|
|
4237
4084
|
// CONCATENATED MODULE: ./src/core/utils/url_store.ts
|
|
4238
|
-
|
|
4085
|
+
const urlStore = {
|
|
4239
4086
|
baseUrl: 'https://pusher.com',
|
|
4240
4087
|
urls: {
|
|
4241
4088
|
authenticationEndpoint: {
|
|
@@ -4255,12 +4102,12 @@ var urlStore = {
|
|
|
4255
4102
|
}
|
|
4256
4103
|
}
|
|
4257
4104
|
};
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4105
|
+
const buildLogSuffix = function (key) {
|
|
4106
|
+
const urlPrefix = 'See:';
|
|
4107
|
+
const urlObj = urlStore.urls[key];
|
|
4261
4108
|
if (!urlObj)
|
|
4262
4109
|
return '';
|
|
4263
|
-
|
|
4110
|
+
let url;
|
|
4264
4111
|
if (urlObj.fullUrl) {
|
|
4265
4112
|
url = urlObj.fullUrl;
|
|
4266
4113
|
}
|
|
@@ -4269,60 +4116,45 @@ var buildLogSuffix = function (key) {
|
|
|
4269
4116
|
}
|
|
4270
4117
|
if (!url)
|
|
4271
4118
|
return '';
|
|
4272
|
-
return urlPrefix
|
|
4119
|
+
return `${urlPrefix} ${url}`;
|
|
4273
4120
|
};
|
|
4274
|
-
/* harmony default export */ var url_store = ({ buildLogSuffix
|
|
4121
|
+
/* harmony default export */ var url_store = ({ buildLogSuffix });
|
|
4275
4122
|
|
|
4276
4123
|
// CONCATENATED MODULE: ./src/core/channels/channel.ts
|
|
4277
|
-
var channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4278
|
-
var extendStatics = function (d, b) {
|
|
4279
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4280
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4281
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4282
|
-
return extendStatics(d, b);
|
|
4283
|
-
};
|
|
4284
|
-
return function (d, b) {
|
|
4285
|
-
extendStatics(d, b);
|
|
4286
|
-
function __() { this.constructor = d; }
|
|
4287
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4288
|
-
};
|
|
4289
|
-
})();
|
|
4290
4124
|
|
|
4291
4125
|
|
|
4292
4126
|
|
|
4293
4127
|
|
|
4294
4128
|
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
var _this = _super.call(this, function (event, data) {
|
|
4129
|
+
class channel_Channel extends dispatcher_Dispatcher {
|
|
4130
|
+
constructor(name, pusher) {
|
|
4131
|
+
super(function (event, data) {
|
|
4299
4132
|
logger.debug('No callbacks on ' + name + ' for ' + event);
|
|
4300
|
-
})
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
Channel.prototype.authorize = function (socketId, callback) {
|
|
4133
|
+
});
|
|
4134
|
+
this.name = name;
|
|
4135
|
+
this.pusher = pusher;
|
|
4136
|
+
this.subscribed = false;
|
|
4137
|
+
this.subscriptionPending = false;
|
|
4138
|
+
this.subscriptionCancelled = false;
|
|
4139
|
+
}
|
|
4140
|
+
authorize(socketId, callback) {
|
|
4309
4141
|
return callback(null, { auth: '' });
|
|
4310
|
-
}
|
|
4311
|
-
|
|
4142
|
+
}
|
|
4143
|
+
trigger(event, data) {
|
|
4312
4144
|
if (event.indexOf('client-') !== 0) {
|
|
4313
4145
|
throw new BadEventName("Event '" + event + "' does not start with 'client-'");
|
|
4314
4146
|
}
|
|
4315
4147
|
if (!this.subscribed) {
|
|
4316
4148
|
var suffix = url_store.buildLogSuffix('triggeringClientEvents');
|
|
4317
|
-
logger.warn(
|
|
4149
|
+
logger.warn(`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`);
|
|
4318
4150
|
}
|
|
4319
4151
|
return this.pusher.send_event(event, data, this.name);
|
|
4320
|
-
}
|
|
4321
|
-
|
|
4152
|
+
}
|
|
4153
|
+
disconnect() {
|
|
4322
4154
|
this.subscribed = false;
|
|
4323
4155
|
this.subscriptionPending = false;
|
|
4324
|
-
}
|
|
4325
|
-
|
|
4156
|
+
}
|
|
4157
|
+
handleEvent(event) {
|
|
4326
4158
|
var eventName = event.event;
|
|
4327
4159
|
var data = event.data;
|
|
4328
4160
|
if (eventName === 'pusher_internal:subscription_succeeded') {
|
|
@@ -4335,8 +4167,8 @@ var channel_Channel = (function (_super) {
|
|
|
4335
4167
|
var metadata = {};
|
|
4336
4168
|
this.emit(eventName, data, metadata);
|
|
4337
4169
|
}
|
|
4338
|
-
}
|
|
4339
|
-
|
|
4170
|
+
}
|
|
4171
|
+
handleSubscriptionSucceededEvent(event) {
|
|
4340
4172
|
this.subscriptionPending = false;
|
|
4341
4173
|
this.subscribed = true;
|
|
4342
4174
|
if (this.subscriptionCancelled) {
|
|
@@ -4345,91 +4177,69 @@ var channel_Channel = (function (_super) {
|
|
|
4345
4177
|
else {
|
|
4346
4178
|
this.emit('pusher:subscription_succeeded', event.data);
|
|
4347
4179
|
}
|
|
4348
|
-
}
|
|
4349
|
-
|
|
4180
|
+
}
|
|
4181
|
+
handleSubscriptionCountEvent(event) {
|
|
4350
4182
|
if (event.data.subscription_count) {
|
|
4351
4183
|
this.subscriptionCount = event.data.subscription_count;
|
|
4352
4184
|
}
|
|
4353
4185
|
this.emit('pusher:subscription_count', event.data);
|
|
4354
|
-
}
|
|
4355
|
-
|
|
4356
|
-
var _this = this;
|
|
4186
|
+
}
|
|
4187
|
+
subscribe() {
|
|
4357
4188
|
if (this.subscribed) {
|
|
4358
4189
|
return;
|
|
4359
4190
|
}
|
|
4360
4191
|
this.subscriptionPending = true;
|
|
4361
4192
|
this.subscriptionCancelled = false;
|
|
4362
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
4193
|
+
this.authorize(this.pusher.connection.socket_id, (error, data) => {
|
|
4363
4194
|
if (error) {
|
|
4364
|
-
|
|
4195
|
+
this.subscriptionPending = false;
|
|
4365
4196
|
logger.error(error.toString());
|
|
4366
|
-
|
|
4197
|
+
this.emit('pusher:subscription_error', Object.assign({}, {
|
|
4367
4198
|
type: 'AuthError',
|
|
4368
4199
|
error: error.message
|
|
4369
4200
|
}, error instanceof HTTPAuthError ? { status: error.status } : {}));
|
|
4370
4201
|
}
|
|
4371
4202
|
else {
|
|
4372
|
-
|
|
4203
|
+
this.pusher.send_event('pusher:subscribe', {
|
|
4373
4204
|
auth: data.auth,
|
|
4374
4205
|
channel_data: data.channel_data,
|
|
4375
|
-
channel:
|
|
4206
|
+
channel: this.name
|
|
4376
4207
|
});
|
|
4377
4208
|
}
|
|
4378
4209
|
});
|
|
4379
|
-
}
|
|
4380
|
-
|
|
4210
|
+
}
|
|
4211
|
+
unsubscribe() {
|
|
4381
4212
|
this.subscribed = false;
|
|
4382
4213
|
this.pusher.send_event('pusher:unsubscribe', {
|
|
4383
4214
|
channel: this.name
|
|
4384
4215
|
});
|
|
4385
|
-
}
|
|
4386
|
-
|
|
4216
|
+
}
|
|
4217
|
+
cancelSubscription() {
|
|
4387
4218
|
this.subscriptionCancelled = true;
|
|
4388
|
-
}
|
|
4389
|
-
|
|
4219
|
+
}
|
|
4220
|
+
reinstateSubscription() {
|
|
4390
4221
|
this.subscriptionCancelled = false;
|
|
4391
|
-
}
|
|
4392
|
-
|
|
4393
|
-
}(dispatcher));
|
|
4394
|
-
/* harmony default export */ var channels_channel = (channel_Channel);
|
|
4222
|
+
}
|
|
4223
|
+
}
|
|
4395
4224
|
|
|
4396
4225
|
// CONCATENATED MODULE: ./src/core/channels/private_channel.ts
|
|
4397
|
-
var private_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4398
|
-
var extendStatics = function (d, b) {
|
|
4399
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4400
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4401
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4402
|
-
return extendStatics(d, b);
|
|
4403
|
-
};
|
|
4404
|
-
return function (d, b) {
|
|
4405
|
-
extendStatics(d, b);
|
|
4406
|
-
function __() { this.constructor = d; }
|
|
4407
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4408
|
-
};
|
|
4409
|
-
})();
|
|
4410
4226
|
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
function PrivateChannel() {
|
|
4414
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4415
|
-
}
|
|
4416
|
-
PrivateChannel.prototype.authorize = function (socketId, callback) {
|
|
4227
|
+
class private_channel_PrivateChannel extends channel_Channel {
|
|
4228
|
+
authorize(socketId, callback) {
|
|
4417
4229
|
return this.pusher.config.channelAuthorizer({
|
|
4418
4230
|
channelName: this.name,
|
|
4419
4231
|
socketId: socketId
|
|
4420
4232
|
}, callback);
|
|
4421
|
-
}
|
|
4422
|
-
|
|
4423
|
-
}(channels_channel));
|
|
4424
|
-
/* harmony default export */ var private_channel = (PrivateChannel);
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4425
4235
|
|
|
4426
4236
|
// CONCATENATED MODULE: ./src/core/channels/members.ts
|
|
4427
4237
|
|
|
4428
|
-
|
|
4429
|
-
|
|
4238
|
+
class members_Members {
|
|
4239
|
+
constructor() {
|
|
4430
4240
|
this.reset();
|
|
4431
4241
|
}
|
|
4432
|
-
|
|
4242
|
+
get(id) {
|
|
4433
4243
|
if (Object.prototype.hasOwnProperty.call(this.members, id)) {
|
|
4434
4244
|
return {
|
|
4435
4245
|
id: id,
|
|
@@ -4439,60 +4249,44 @@ var members_Members = (function () {
|
|
|
4439
4249
|
else {
|
|
4440
4250
|
return null;
|
|
4441
4251
|
}
|
|
4442
|
-
}
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
callback(_this.get(id));
|
|
4252
|
+
}
|
|
4253
|
+
each(callback) {
|
|
4254
|
+
objectApply(this.members, (member, id) => {
|
|
4255
|
+
callback(this.get(id));
|
|
4447
4256
|
});
|
|
4448
|
-
}
|
|
4449
|
-
|
|
4257
|
+
}
|
|
4258
|
+
setMyID(id) {
|
|
4450
4259
|
this.myID = id;
|
|
4451
|
-
}
|
|
4452
|
-
|
|
4260
|
+
}
|
|
4261
|
+
onSubscription(subscriptionData) {
|
|
4453
4262
|
this.members = subscriptionData.presence.hash;
|
|
4454
4263
|
this.count = subscriptionData.presence.count;
|
|
4455
4264
|
this.me = this.get(this.myID);
|
|
4456
|
-
}
|
|
4457
|
-
|
|
4265
|
+
}
|
|
4266
|
+
addMember(memberData) {
|
|
4458
4267
|
if (this.get(memberData.user_id) === null) {
|
|
4459
4268
|
this.count++;
|
|
4460
4269
|
}
|
|
4461
4270
|
this.members[memberData.user_id] = memberData.user_info;
|
|
4462
4271
|
return this.get(memberData.user_id);
|
|
4463
|
-
}
|
|
4464
|
-
|
|
4272
|
+
}
|
|
4273
|
+
removeMember(memberData) {
|
|
4465
4274
|
var member = this.get(memberData.user_id);
|
|
4466
4275
|
if (member) {
|
|
4467
4276
|
delete this.members[memberData.user_id];
|
|
4468
4277
|
this.count--;
|
|
4469
4278
|
}
|
|
4470
4279
|
return member;
|
|
4471
|
-
}
|
|
4472
|
-
|
|
4280
|
+
}
|
|
4281
|
+
reset() {
|
|
4473
4282
|
this.members = {};
|
|
4474
4283
|
this.count = 0;
|
|
4475
4284
|
this.myID = null;
|
|
4476
4285
|
this.me = null;
|
|
4477
|
-
}
|
|
4478
|
-
|
|
4479
|
-
}());
|
|
4480
|
-
/* harmony default export */ var members = (members_Members);
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
4481
4288
|
|
|
4482
4289
|
// CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
|
|
4483
|
-
var presence_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4484
|
-
var extendStatics = function (d, b) {
|
|
4485
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4486
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4487
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4488
|
-
return extendStatics(d, b);
|
|
4489
|
-
};
|
|
4490
|
-
return function (d, b) {
|
|
4491
|
-
extendStatics(d, b);
|
|
4492
|
-
function __() { this.constructor = d; }
|
|
4493
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4494
|
-
};
|
|
4495
|
-
})();
|
|
4496
4290
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4497
4291
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4498
4292
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -4502,80 +4296,42 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
4502
4296
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
4503
4297
|
});
|
|
4504
4298
|
};
|
|
4505
|
-
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
4506
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4507
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
4508
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
4509
|
-
function step(op) {
|
|
4510
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
4511
|
-
while (_) try {
|
|
4512
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
4513
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
4514
|
-
switch (op[0]) {
|
|
4515
|
-
case 0: case 1: t = op; break;
|
|
4516
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
4517
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
4518
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
4519
|
-
default:
|
|
4520
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
4521
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
4522
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
4523
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
4524
|
-
if (t[2]) _.ops.pop();
|
|
4525
|
-
_.trys.pop(); continue;
|
|
4526
|
-
}
|
|
4527
|
-
op = body.call(thisArg, _);
|
|
4528
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
4529
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
4530
|
-
}
|
|
4531
|
-
};
|
|
4532
4299
|
|
|
4533
4300
|
|
|
4534
4301
|
|
|
4535
4302
|
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
switch (_a.label) {
|
|
4549
|
-
case 0:
|
|
4550
|
-
if (!!error) return [3, 3];
|
|
4551
|
-
authData = authData;
|
|
4552
|
-
if (!(authData.channel_data != null)) return [3, 1];
|
|
4553
|
-
channelData = JSON.parse(authData.channel_data);
|
|
4554
|
-
this.members.setMyID(channelData.user_id);
|
|
4555
|
-
return [3, 3];
|
|
4556
|
-
case 1: return [4, this.pusher.user.signinDonePromise];
|
|
4557
|
-
case 2:
|
|
4558
|
-
_a.sent();
|
|
4559
|
-
if (this.pusher.user.user_data != null) {
|
|
4560
|
-
this.members.setMyID(this.pusher.user.user_data.id);
|
|
4561
|
-
}
|
|
4562
|
-
else {
|
|
4563
|
-
suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
4564
|
-
logger.error("Invalid auth response for channel '" + this.name + "', " +
|
|
4565
|
-
("expected 'channel_data' field. " + suffix + ", ") +
|
|
4566
|
-
"or the user should be signed in.");
|
|
4567
|
-
callback('Invalid auth response');
|
|
4568
|
-
return [2];
|
|
4569
|
-
}
|
|
4570
|
-
_a.label = 3;
|
|
4571
|
-
case 3:
|
|
4572
|
-
callback(error, authData);
|
|
4573
|
-
return [2];
|
|
4303
|
+
class presence_channel_PresenceChannel extends private_channel_PrivateChannel {
|
|
4304
|
+
constructor(name, pusher) {
|
|
4305
|
+
super(name, pusher);
|
|
4306
|
+
this.members = new members_Members();
|
|
4307
|
+
}
|
|
4308
|
+
authorize(socketId, callback) {
|
|
4309
|
+
super.authorize(socketId, (error, authData) => __awaiter(this, void 0, void 0, function* () {
|
|
4310
|
+
if (!error) {
|
|
4311
|
+
authData = authData;
|
|
4312
|
+
if (authData.channel_data != null) {
|
|
4313
|
+
var channelData = JSON.parse(authData.channel_data);
|
|
4314
|
+
this.members.setMyID(channelData.user_id);
|
|
4574
4315
|
}
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4316
|
+
else {
|
|
4317
|
+
yield this.pusher.user.signinDonePromise;
|
|
4318
|
+
if (this.pusher.user.user_data != null) {
|
|
4319
|
+
this.members.setMyID(this.pusher.user.user_data.id);
|
|
4320
|
+
}
|
|
4321
|
+
else {
|
|
4322
|
+
let suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
4323
|
+
logger.error(`Invalid auth response for channel '${this.name}', ` +
|
|
4324
|
+
`expected 'channel_data' field. ${suffix}, ` +
|
|
4325
|
+
`or the user should be signed in.`);
|
|
4326
|
+
callback('Invalid auth response');
|
|
4327
|
+
return;
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
callback(error, authData);
|
|
4332
|
+
}));
|
|
4333
|
+
}
|
|
4334
|
+
handleEvent(event) {
|
|
4579
4335
|
var eventName = event.event;
|
|
4580
4336
|
if (eventName.indexOf('pusher_internal:') === 0) {
|
|
4581
4337
|
this.handleInternalEvent(event);
|
|
@@ -4588,8 +4344,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
4588
4344
|
}
|
|
4589
4345
|
this.emit(eventName, data, metadata);
|
|
4590
4346
|
}
|
|
4591
|
-
}
|
|
4592
|
-
|
|
4347
|
+
}
|
|
4348
|
+
handleInternalEvent(event) {
|
|
4593
4349
|
var eventName = event.event;
|
|
4594
4350
|
var data = event.data;
|
|
4595
4351
|
switch (eventName) {
|
|
@@ -4610,8 +4366,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
4610
4366
|
}
|
|
4611
4367
|
break;
|
|
4612
4368
|
}
|
|
4613
|
-
}
|
|
4614
|
-
|
|
4369
|
+
}
|
|
4370
|
+
handleSubscriptionSucceededEvent(event) {
|
|
4615
4371
|
this.subscriptionPending = false;
|
|
4616
4372
|
this.subscribed = true;
|
|
4617
4373
|
if (this.subscriptionCancelled) {
|
|
@@ -4621,14 +4377,12 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
4621
4377
|
this.members.onSubscription(event.data);
|
|
4622
4378
|
this.emit('pusher:subscription_succeeded', this.members);
|
|
4623
4379
|
}
|
|
4624
|
-
}
|
|
4625
|
-
|
|
4380
|
+
}
|
|
4381
|
+
disconnect() {
|
|
4626
4382
|
this.members.reset();
|
|
4627
|
-
|
|
4628
|
-
}
|
|
4629
|
-
|
|
4630
|
-
}(private_channel));
|
|
4631
|
-
/* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
|
|
4383
|
+
super.disconnect();
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4632
4386
|
|
|
4633
4387
|
// EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js
|
|
4634
4388
|
var utf8 = __webpack_require__(1);
|
|
@@ -4637,64 +4391,47 @@ var utf8 = __webpack_require__(1);
|
|
|
4637
4391
|
var base64 = __webpack_require__(0);
|
|
4638
4392
|
|
|
4639
4393
|
// CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
|
|
4640
|
-
var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4641
|
-
var extendStatics = function (d, b) {
|
|
4642
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4643
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4644
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4645
|
-
return extendStatics(d, b);
|
|
4646
|
-
};
|
|
4647
|
-
return function (d, b) {
|
|
4648
|
-
extendStatics(d, b);
|
|
4649
|
-
function __() { this.constructor = d; }
|
|
4650
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4651
|
-
};
|
|
4652
|
-
})();
|
|
4653
4394
|
|
|
4654
4395
|
|
|
4655
4396
|
|
|
4656
4397
|
|
|
4657
4398
|
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
_this.nacl = nacl;
|
|
4664
|
-
return _this;
|
|
4399
|
+
class encrypted_channel_EncryptedChannel extends private_channel_PrivateChannel {
|
|
4400
|
+
constructor(name, pusher, nacl) {
|
|
4401
|
+
super(name, pusher);
|
|
4402
|
+
this.key = null;
|
|
4403
|
+
this.nacl = nacl;
|
|
4665
4404
|
}
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) {
|
|
4405
|
+
authorize(socketId, callback) {
|
|
4406
|
+
super.authorize(socketId, (error, authData) => {
|
|
4669
4407
|
if (error) {
|
|
4670
4408
|
callback(error, authData);
|
|
4671
4409
|
return;
|
|
4672
4410
|
}
|
|
4673
|
-
|
|
4411
|
+
let sharedSecret = authData['shared_secret'];
|
|
4674
4412
|
if (!sharedSecret) {
|
|
4675
|
-
callback(new Error(
|
|
4413
|
+
callback(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`), null);
|
|
4676
4414
|
return;
|
|
4677
4415
|
}
|
|
4678
|
-
|
|
4416
|
+
this.key = Object(base64["decode"])(sharedSecret);
|
|
4679
4417
|
delete authData['shared_secret'];
|
|
4680
4418
|
callback(null, authData);
|
|
4681
4419
|
});
|
|
4682
|
-
}
|
|
4683
|
-
|
|
4420
|
+
}
|
|
4421
|
+
trigger(event, data) {
|
|
4684
4422
|
throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
|
|
4685
|
-
}
|
|
4686
|
-
|
|
4423
|
+
}
|
|
4424
|
+
handleEvent(event) {
|
|
4687
4425
|
var eventName = event.event;
|
|
4688
4426
|
var data = event.data;
|
|
4689
4427
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
4690
4428
|
eventName.indexOf('pusher:') === 0) {
|
|
4691
|
-
|
|
4429
|
+
super.handleEvent(event);
|
|
4692
4430
|
return;
|
|
4693
4431
|
}
|
|
4694
4432
|
this.handleEncryptedEvent(eventName, data);
|
|
4695
|
-
}
|
|
4696
|
-
|
|
4697
|
-
var _this = this;
|
|
4433
|
+
}
|
|
4434
|
+
handleEncryptedEvent(event, data) {
|
|
4698
4435
|
if (!this.key) {
|
|
4699
4436
|
logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
|
|
4700
4437
|
return;
|
|
@@ -4704,98 +4441,81 @@ var encrypted_channel_EncryptedChannel = (function (_super) {
|
|
|
4704
4441
|
data);
|
|
4705
4442
|
return;
|
|
4706
4443
|
}
|
|
4707
|
-
|
|
4444
|
+
let cipherText = Object(base64["decode"])(data.ciphertext);
|
|
4708
4445
|
if (cipherText.length < this.nacl.secretbox.overheadLength) {
|
|
4709
|
-
logger.error(
|
|
4446
|
+
logger.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`);
|
|
4710
4447
|
return;
|
|
4711
4448
|
}
|
|
4712
|
-
|
|
4449
|
+
let nonce = Object(base64["decode"])(data.nonce);
|
|
4713
4450
|
if (nonce.length < this.nacl.secretbox.nonceLength) {
|
|
4714
|
-
logger.error(
|
|
4451
|
+
logger.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`);
|
|
4715
4452
|
return;
|
|
4716
4453
|
}
|
|
4717
|
-
|
|
4454
|
+
let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
4718
4455
|
if (bytes === null) {
|
|
4719
4456
|
logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
|
|
4720
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
4457
|
+
this.authorize(this.pusher.connection.socket_id, (error, authData) => {
|
|
4721
4458
|
if (error) {
|
|
4722
|
-
logger.error(
|
|
4459
|
+
logger.error(`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`);
|
|
4723
4460
|
return;
|
|
4724
4461
|
}
|
|
4725
|
-
bytes =
|
|
4462
|
+
bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
4726
4463
|
if (bytes === null) {
|
|
4727
|
-
logger.error(
|
|
4464
|
+
logger.error(`Failed to decrypt event with new key. Dropping encrypted event`);
|
|
4728
4465
|
return;
|
|
4729
4466
|
}
|
|
4730
|
-
|
|
4467
|
+
this.emit(event, this.getDataToEmit(bytes));
|
|
4731
4468
|
return;
|
|
4732
4469
|
});
|
|
4733
4470
|
return;
|
|
4734
4471
|
}
|
|
4735
4472
|
this.emit(event, this.getDataToEmit(bytes));
|
|
4736
|
-
}
|
|
4737
|
-
|
|
4738
|
-
|
|
4473
|
+
}
|
|
4474
|
+
getDataToEmit(bytes) {
|
|
4475
|
+
let raw = Object(utf8["decode"])(bytes);
|
|
4739
4476
|
try {
|
|
4740
4477
|
return JSON.parse(raw);
|
|
4741
4478
|
}
|
|
4742
4479
|
catch (_a) {
|
|
4743
4480
|
return raw;
|
|
4744
4481
|
}
|
|
4745
|
-
}
|
|
4746
|
-
|
|
4747
|
-
}(private_channel));
|
|
4748
|
-
/* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4749
4484
|
|
|
4750
4485
|
// CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
|
|
4751
|
-
var connection_manager_extends = (undefined && undefined.__extends) || (function () {
|
|
4752
|
-
var extendStatics = function (d, b) {
|
|
4753
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4754
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4755
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4756
|
-
return extendStatics(d, b);
|
|
4757
|
-
};
|
|
4758
|
-
return function (d, b) {
|
|
4759
|
-
extendStatics(d, b);
|
|
4760
|
-
function __() { this.constructor = d; }
|
|
4761
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4762
|
-
};
|
|
4763
|
-
})();
|
|
4764
4486
|
|
|
4765
4487
|
|
|
4766
4488
|
|
|
4767
4489
|
|
|
4768
4490
|
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
_this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
|
|
4491
|
+
class connection_manager_ConnectionManager extends dispatcher_Dispatcher {
|
|
4492
|
+
constructor(key, options) {
|
|
4493
|
+
super();
|
|
4494
|
+
this.state = 'initialized';
|
|
4495
|
+
this.connection = null;
|
|
4496
|
+
this.key = key;
|
|
4497
|
+
this.options = options;
|
|
4498
|
+
this.timeline = this.options.timeline;
|
|
4499
|
+
this.usingTLS = this.options.useTLS;
|
|
4500
|
+
this.errorCallbacks = this.buildErrorCallbacks();
|
|
4501
|
+
this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks);
|
|
4502
|
+
this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
|
|
4782
4503
|
var Network = worker_runtime.getNetwork();
|
|
4783
|
-
Network.bind('online',
|
|
4784
|
-
|
|
4785
|
-
if (
|
|
4786
|
-
|
|
4504
|
+
Network.bind('online', () => {
|
|
4505
|
+
this.timeline.info({ netinfo: 'online' });
|
|
4506
|
+
if (this.state === 'connecting' || this.state === 'unavailable') {
|
|
4507
|
+
this.retryIn(0);
|
|
4787
4508
|
}
|
|
4788
4509
|
});
|
|
4789
|
-
Network.bind('offline',
|
|
4790
|
-
|
|
4791
|
-
if (
|
|
4792
|
-
|
|
4510
|
+
Network.bind('offline', () => {
|
|
4511
|
+
this.timeline.info({ netinfo: 'offline' });
|
|
4512
|
+
if (this.connection) {
|
|
4513
|
+
this.sendActivityCheck();
|
|
4793
4514
|
}
|
|
4794
4515
|
});
|
|
4795
|
-
|
|
4796
|
-
return _this;
|
|
4516
|
+
this.updateStrategy();
|
|
4797
4517
|
}
|
|
4798
|
-
|
|
4518
|
+
connect() {
|
|
4799
4519
|
if (this.connection || this.runner) {
|
|
4800
4520
|
return;
|
|
4801
4521
|
}
|
|
@@ -4806,59 +4526,58 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
4806
4526
|
this.updateState('connecting');
|
|
4807
4527
|
this.startConnecting();
|
|
4808
4528
|
this.setUnavailableTimer();
|
|
4809
|
-
}
|
|
4810
|
-
|
|
4529
|
+
}
|
|
4530
|
+
send(data) {
|
|
4811
4531
|
if (this.connection) {
|
|
4812
4532
|
return this.connection.send(data);
|
|
4813
4533
|
}
|
|
4814
4534
|
else {
|
|
4815
4535
|
return false;
|
|
4816
4536
|
}
|
|
4817
|
-
}
|
|
4818
|
-
|
|
4537
|
+
}
|
|
4538
|
+
send_event(name, data, channel) {
|
|
4819
4539
|
if (this.connection) {
|
|
4820
4540
|
return this.connection.send_event(name, data, channel);
|
|
4821
4541
|
}
|
|
4822
4542
|
else {
|
|
4823
4543
|
return false;
|
|
4824
4544
|
}
|
|
4825
|
-
}
|
|
4826
|
-
|
|
4545
|
+
}
|
|
4546
|
+
disconnect() {
|
|
4827
4547
|
this.disconnectInternally();
|
|
4828
4548
|
this.updateState('disconnected');
|
|
4829
|
-
}
|
|
4830
|
-
|
|
4549
|
+
}
|
|
4550
|
+
isUsingTLS() {
|
|
4831
4551
|
return this.usingTLS;
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
var
|
|
4835
|
-
var callback = function (error, handshake) {
|
|
4552
|
+
}
|
|
4553
|
+
startConnecting() {
|
|
4554
|
+
var callback = (error, handshake) => {
|
|
4836
4555
|
if (error) {
|
|
4837
|
-
|
|
4556
|
+
this.runner = this.strategy.connect(0, callback);
|
|
4838
4557
|
}
|
|
4839
4558
|
else {
|
|
4840
4559
|
if (handshake.action === 'error') {
|
|
4841
|
-
|
|
4560
|
+
this.emit('error', {
|
|
4842
4561
|
type: 'HandshakeError',
|
|
4843
4562
|
error: handshake.error
|
|
4844
4563
|
});
|
|
4845
|
-
|
|
4564
|
+
this.timeline.error({ handshakeError: handshake.error });
|
|
4846
4565
|
}
|
|
4847
4566
|
else {
|
|
4848
|
-
|
|
4849
|
-
|
|
4567
|
+
this.abortConnecting();
|
|
4568
|
+
this.handshakeCallbacks[handshake.action](handshake);
|
|
4850
4569
|
}
|
|
4851
4570
|
}
|
|
4852
4571
|
};
|
|
4853
4572
|
this.runner = this.strategy.connect(0, callback);
|
|
4854
|
-
}
|
|
4855
|
-
|
|
4573
|
+
}
|
|
4574
|
+
abortConnecting() {
|
|
4856
4575
|
if (this.runner) {
|
|
4857
4576
|
this.runner.abort();
|
|
4858
4577
|
this.runner = null;
|
|
4859
4578
|
}
|
|
4860
|
-
}
|
|
4861
|
-
|
|
4579
|
+
}
|
|
4580
|
+
disconnectInternally() {
|
|
4862
4581
|
this.abortConnecting();
|
|
4863
4582
|
this.clearRetryTimer();
|
|
4864
4583
|
this.clearUnavailableTimer();
|
|
@@ -4866,136 +4585,129 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
4866
4585
|
var connection = this.abandonConnection();
|
|
4867
4586
|
connection.close();
|
|
4868
4587
|
}
|
|
4869
|
-
}
|
|
4870
|
-
|
|
4588
|
+
}
|
|
4589
|
+
updateStrategy() {
|
|
4871
4590
|
this.strategy = this.options.getStrategy({
|
|
4872
4591
|
key: this.key,
|
|
4873
4592
|
timeline: this.timeline,
|
|
4874
4593
|
useTLS: this.usingTLS
|
|
4875
4594
|
});
|
|
4876
|
-
}
|
|
4877
|
-
|
|
4878
|
-
var _this = this;
|
|
4595
|
+
}
|
|
4596
|
+
retryIn(delay) {
|
|
4879
4597
|
this.timeline.info({ action: 'retry', delay: delay });
|
|
4880
4598
|
if (delay > 0) {
|
|
4881
4599
|
this.emit('connecting_in', Math.round(delay / 1000));
|
|
4882
4600
|
}
|
|
4883
|
-
this.retryTimer = new
|
|
4884
|
-
|
|
4885
|
-
|
|
4601
|
+
this.retryTimer = new timers_OneOffTimer(delay || 0, () => {
|
|
4602
|
+
this.disconnectInternally();
|
|
4603
|
+
this.connect();
|
|
4886
4604
|
});
|
|
4887
|
-
}
|
|
4888
|
-
|
|
4605
|
+
}
|
|
4606
|
+
clearRetryTimer() {
|
|
4889
4607
|
if (this.retryTimer) {
|
|
4890
4608
|
this.retryTimer.ensureAborted();
|
|
4891
4609
|
this.retryTimer = null;
|
|
4892
4610
|
}
|
|
4893
|
-
}
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
_this.updateState('unavailable');
|
|
4611
|
+
}
|
|
4612
|
+
setUnavailableTimer() {
|
|
4613
|
+
this.unavailableTimer = new timers_OneOffTimer(this.options.unavailableTimeout, () => {
|
|
4614
|
+
this.updateState('unavailable');
|
|
4898
4615
|
});
|
|
4899
|
-
}
|
|
4900
|
-
|
|
4616
|
+
}
|
|
4617
|
+
clearUnavailableTimer() {
|
|
4901
4618
|
if (this.unavailableTimer) {
|
|
4902
4619
|
this.unavailableTimer.ensureAborted();
|
|
4903
4620
|
}
|
|
4904
|
-
}
|
|
4905
|
-
|
|
4906
|
-
var _this = this;
|
|
4621
|
+
}
|
|
4622
|
+
sendActivityCheck() {
|
|
4907
4623
|
this.stopActivityCheck();
|
|
4908
4624
|
this.connection.ping();
|
|
4909
|
-
this.activityTimer = new
|
|
4910
|
-
|
|
4911
|
-
|
|
4625
|
+
this.activityTimer = new timers_OneOffTimer(this.options.pongTimeout, () => {
|
|
4626
|
+
this.timeline.error({ pong_timed_out: this.options.pongTimeout });
|
|
4627
|
+
this.retryIn(0);
|
|
4912
4628
|
});
|
|
4913
|
-
}
|
|
4914
|
-
|
|
4915
|
-
var _this = this;
|
|
4629
|
+
}
|
|
4630
|
+
resetActivityCheck() {
|
|
4916
4631
|
this.stopActivityCheck();
|
|
4917
4632
|
if (this.connection && !this.connection.handlesActivityChecks()) {
|
|
4918
|
-
this.activityTimer = new
|
|
4919
|
-
|
|
4633
|
+
this.activityTimer = new timers_OneOffTimer(this.activityTimeout, () => {
|
|
4634
|
+
this.sendActivityCheck();
|
|
4920
4635
|
});
|
|
4921
4636
|
}
|
|
4922
|
-
}
|
|
4923
|
-
|
|
4637
|
+
}
|
|
4638
|
+
stopActivityCheck() {
|
|
4924
4639
|
if (this.activityTimer) {
|
|
4925
4640
|
this.activityTimer.ensureAborted();
|
|
4926
4641
|
}
|
|
4927
|
-
}
|
|
4928
|
-
|
|
4929
|
-
var _this = this;
|
|
4642
|
+
}
|
|
4643
|
+
buildConnectionCallbacks(errorCallbacks) {
|
|
4930
4644
|
return extend({}, errorCallbacks, {
|
|
4931
|
-
message:
|
|
4932
|
-
|
|
4933
|
-
|
|
4645
|
+
message: message => {
|
|
4646
|
+
this.resetActivityCheck();
|
|
4647
|
+
this.emit('message', message);
|
|
4934
4648
|
},
|
|
4935
|
-
ping:
|
|
4936
|
-
|
|
4649
|
+
ping: () => {
|
|
4650
|
+
this.send_event('pusher:pong', {});
|
|
4937
4651
|
},
|
|
4938
|
-
activity:
|
|
4939
|
-
|
|
4652
|
+
activity: () => {
|
|
4653
|
+
this.resetActivityCheck();
|
|
4940
4654
|
},
|
|
4941
|
-
error:
|
|
4942
|
-
|
|
4655
|
+
error: error => {
|
|
4656
|
+
this.emit('error', error);
|
|
4943
4657
|
},
|
|
4944
|
-
closed:
|
|
4945
|
-
|
|
4946
|
-
if (
|
|
4947
|
-
|
|
4658
|
+
closed: () => {
|
|
4659
|
+
this.abandonConnection();
|
|
4660
|
+
if (this.shouldRetry()) {
|
|
4661
|
+
this.retryIn(1000);
|
|
4948
4662
|
}
|
|
4949
4663
|
}
|
|
4950
4664
|
});
|
|
4951
|
-
}
|
|
4952
|
-
|
|
4953
|
-
var _this = this;
|
|
4665
|
+
}
|
|
4666
|
+
buildHandshakeCallbacks(errorCallbacks) {
|
|
4954
4667
|
return extend({}, errorCallbacks, {
|
|
4955
|
-
connected:
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4668
|
+
connected: (handshake) => {
|
|
4669
|
+
this.activityTimeout = Math.min(this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
|
|
4670
|
+
this.clearUnavailableTimer();
|
|
4671
|
+
this.setConnection(handshake.connection);
|
|
4672
|
+
this.socket_id = this.connection.id;
|
|
4673
|
+
this.updateState('connected', { socket_id: this.socket_id });
|
|
4961
4674
|
}
|
|
4962
4675
|
});
|
|
4963
|
-
}
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
return function (result) {
|
|
4676
|
+
}
|
|
4677
|
+
buildErrorCallbacks() {
|
|
4678
|
+
let withErrorEmitted = callback => {
|
|
4679
|
+
return (result) => {
|
|
4968
4680
|
if (result.error) {
|
|
4969
|
-
|
|
4681
|
+
this.emit('error', { type: 'WebSocketError', error: result.error });
|
|
4970
4682
|
}
|
|
4971
4683
|
callback(result);
|
|
4972
4684
|
};
|
|
4973
4685
|
};
|
|
4974
4686
|
return {
|
|
4975
|
-
tls_only: withErrorEmitted(
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4687
|
+
tls_only: withErrorEmitted(() => {
|
|
4688
|
+
this.usingTLS = true;
|
|
4689
|
+
this.updateStrategy();
|
|
4690
|
+
this.retryIn(0);
|
|
4979
4691
|
}),
|
|
4980
|
-
refused: withErrorEmitted(
|
|
4981
|
-
|
|
4692
|
+
refused: withErrorEmitted(() => {
|
|
4693
|
+
this.disconnect();
|
|
4982
4694
|
}),
|
|
4983
|
-
backoff: withErrorEmitted(
|
|
4984
|
-
|
|
4695
|
+
backoff: withErrorEmitted(() => {
|
|
4696
|
+
this.retryIn(1000);
|
|
4985
4697
|
}),
|
|
4986
|
-
retry: withErrorEmitted(
|
|
4987
|
-
|
|
4698
|
+
retry: withErrorEmitted(() => {
|
|
4699
|
+
this.retryIn(0);
|
|
4988
4700
|
})
|
|
4989
4701
|
};
|
|
4990
|
-
}
|
|
4991
|
-
|
|
4702
|
+
}
|
|
4703
|
+
setConnection(connection) {
|
|
4992
4704
|
this.connection = connection;
|
|
4993
4705
|
for (var event in this.connectionCallbacks) {
|
|
4994
4706
|
this.connection.bind(event, this.connectionCallbacks[event]);
|
|
4995
4707
|
}
|
|
4996
4708
|
this.resetActivityCheck();
|
|
4997
|
-
}
|
|
4998
|
-
|
|
4709
|
+
}
|
|
4710
|
+
abandonConnection() {
|
|
4999
4711
|
if (!this.connection) {
|
|
5000
4712
|
return;
|
|
5001
4713
|
}
|
|
@@ -5006,8 +4718,8 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
5006
4718
|
var connection = this.connection;
|
|
5007
4719
|
this.connection = null;
|
|
5008
4720
|
return connection;
|
|
5009
|
-
}
|
|
5010
|
-
|
|
4721
|
+
}
|
|
4722
|
+
updateState(newState, data) {
|
|
5011
4723
|
var previousState = this.state;
|
|
5012
4724
|
this.state = newState;
|
|
5013
4725
|
if (previousState !== newState) {
|
|
@@ -5020,56 +4732,52 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
5020
4732
|
this.emit('state_change', { previous: previousState, current: newState });
|
|
5021
4733
|
this.emit(newState, data);
|
|
5022
4734
|
}
|
|
5023
|
-
}
|
|
5024
|
-
|
|
4735
|
+
}
|
|
4736
|
+
shouldRetry() {
|
|
5025
4737
|
return this.state === 'connecting' || this.state === 'connected';
|
|
5026
|
-
}
|
|
5027
|
-
|
|
5028
|
-
}(dispatcher));
|
|
5029
|
-
/* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
|
|
4738
|
+
}
|
|
4739
|
+
}
|
|
5030
4740
|
|
|
5031
4741
|
// CONCATENATED MODULE: ./src/core/channels/channels.ts
|
|
5032
4742
|
|
|
5033
4743
|
|
|
5034
4744
|
|
|
5035
4745
|
|
|
5036
|
-
|
|
5037
|
-
|
|
4746
|
+
class channels_Channels {
|
|
4747
|
+
constructor() {
|
|
5038
4748
|
this.channels = {};
|
|
5039
4749
|
}
|
|
5040
|
-
|
|
4750
|
+
add(name, pusher) {
|
|
5041
4751
|
if (!this.channels[name]) {
|
|
5042
4752
|
this.channels[name] = createChannel(name, pusher);
|
|
5043
4753
|
}
|
|
5044
4754
|
return this.channels[name];
|
|
5045
|
-
}
|
|
5046
|
-
|
|
4755
|
+
}
|
|
4756
|
+
all() {
|
|
5047
4757
|
return values(this.channels);
|
|
5048
|
-
}
|
|
5049
|
-
|
|
4758
|
+
}
|
|
4759
|
+
find(name) {
|
|
5050
4760
|
return this.channels[name];
|
|
5051
|
-
}
|
|
5052
|
-
|
|
4761
|
+
}
|
|
4762
|
+
remove(name) {
|
|
5053
4763
|
var channel = this.channels[name];
|
|
5054
4764
|
delete this.channels[name];
|
|
5055
4765
|
return channel;
|
|
5056
|
-
}
|
|
5057
|
-
|
|
4766
|
+
}
|
|
4767
|
+
disconnect() {
|
|
5058
4768
|
objectApply(this.channels, function (channel) {
|
|
5059
4769
|
channel.disconnect();
|
|
5060
4770
|
});
|
|
5061
|
-
}
|
|
5062
|
-
|
|
5063
|
-
}());
|
|
5064
|
-
/* harmony default export */ var channels = (channels_Channels);
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
5065
4773
|
function createChannel(name, pusher) {
|
|
5066
4774
|
if (name.indexOf('private-encrypted-') === 0) {
|
|
5067
4775
|
if (pusher.config.nacl) {
|
|
5068
4776
|
return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);
|
|
5069
4777
|
}
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
throw new UnsupportedFeature(errMsg
|
|
4778
|
+
let errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';
|
|
4779
|
+
let suffix = url_store.buildLogSuffix('encryptedChannelSupport');
|
|
4780
|
+
throw new UnsupportedFeature(`${errMsg}. ${suffix}`);
|
|
5073
4781
|
}
|
|
5074
4782
|
else if (name.indexOf('private-') === 0) {
|
|
5075
4783
|
return factory.createPrivateChannel(name, pusher);
|
|
@@ -5096,97 +4804,94 @@ function createChannel(name, pusher) {
|
|
|
5096
4804
|
|
|
5097
4805
|
|
|
5098
4806
|
var Factory = {
|
|
5099
|
-
createChannels
|
|
5100
|
-
return new
|
|
4807
|
+
createChannels() {
|
|
4808
|
+
return new channels_Channels();
|
|
5101
4809
|
},
|
|
5102
|
-
createConnectionManager
|
|
5103
|
-
return new
|
|
4810
|
+
createConnectionManager(key, options) {
|
|
4811
|
+
return new connection_manager_ConnectionManager(key, options);
|
|
5104
4812
|
},
|
|
5105
|
-
createChannel
|
|
5106
|
-
return new
|
|
4813
|
+
createChannel(name, pusher) {
|
|
4814
|
+
return new channel_Channel(name, pusher);
|
|
5107
4815
|
},
|
|
5108
|
-
createPrivateChannel
|
|
5109
|
-
return new
|
|
4816
|
+
createPrivateChannel(name, pusher) {
|
|
4817
|
+
return new private_channel_PrivateChannel(name, pusher);
|
|
5110
4818
|
},
|
|
5111
|
-
createPresenceChannel
|
|
5112
|
-
return new
|
|
4819
|
+
createPresenceChannel(name, pusher) {
|
|
4820
|
+
return new presence_channel_PresenceChannel(name, pusher);
|
|
5113
4821
|
},
|
|
5114
|
-
createEncryptedChannel
|
|
5115
|
-
return new
|
|
4822
|
+
createEncryptedChannel(name, pusher, nacl) {
|
|
4823
|
+
return new encrypted_channel_EncryptedChannel(name, pusher, nacl);
|
|
5116
4824
|
},
|
|
5117
|
-
createTimelineSender
|
|
5118
|
-
return new
|
|
4825
|
+
createTimelineSender(timeline, options) {
|
|
4826
|
+
return new timeline_sender_TimelineSender(timeline, options);
|
|
5119
4827
|
},
|
|
5120
|
-
createHandshake
|
|
5121
|
-
return new
|
|
4828
|
+
createHandshake(transport, callback) {
|
|
4829
|
+
return new handshake_Handshake(transport, callback);
|
|
5122
4830
|
},
|
|
5123
|
-
createAssistantToTheTransportManager
|
|
5124
|
-
return new
|
|
4831
|
+
createAssistantToTheTransportManager(manager, transport, options) {
|
|
4832
|
+
return new assistant_to_the_transport_manager_AssistantToTheTransportManager(manager, transport, options);
|
|
5125
4833
|
}
|
|
5126
4834
|
};
|
|
5127
4835
|
/* harmony default export */ var factory = (Factory);
|
|
5128
4836
|
|
|
5129
4837
|
// CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
|
|
5130
4838
|
|
|
5131
|
-
|
|
5132
|
-
|
|
4839
|
+
class transport_manager_TransportManager {
|
|
4840
|
+
constructor(options) {
|
|
5133
4841
|
this.options = options || {};
|
|
5134
4842
|
this.livesLeft = this.options.lives || Infinity;
|
|
5135
4843
|
}
|
|
5136
|
-
|
|
4844
|
+
getAssistant(transport) {
|
|
5137
4845
|
return factory.createAssistantToTheTransportManager(this, transport, {
|
|
5138
4846
|
minPingDelay: this.options.minPingDelay,
|
|
5139
4847
|
maxPingDelay: this.options.maxPingDelay
|
|
5140
4848
|
});
|
|
5141
|
-
}
|
|
5142
|
-
|
|
4849
|
+
}
|
|
4850
|
+
isAlive() {
|
|
5143
4851
|
return this.livesLeft > 0;
|
|
5144
|
-
}
|
|
5145
|
-
|
|
4852
|
+
}
|
|
4853
|
+
reportDeath() {
|
|
5146
4854
|
this.livesLeft -= 1;
|
|
5147
|
-
}
|
|
5148
|
-
|
|
5149
|
-
}());
|
|
5150
|
-
/* harmony default export */ var transport_manager = (transport_manager_TransportManager);
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
5151
4857
|
|
|
5152
4858
|
// CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
|
|
5153
4859
|
|
|
5154
4860
|
|
|
5155
4861
|
|
|
5156
|
-
|
|
5157
|
-
|
|
4862
|
+
class sequential_strategy_SequentialStrategy {
|
|
4863
|
+
constructor(strategies, options) {
|
|
5158
4864
|
this.strategies = strategies;
|
|
5159
4865
|
this.loop = Boolean(options.loop);
|
|
5160
4866
|
this.failFast = Boolean(options.failFast);
|
|
5161
4867
|
this.timeout = options.timeout;
|
|
5162
4868
|
this.timeoutLimit = options.timeoutLimit;
|
|
5163
4869
|
}
|
|
5164
|
-
|
|
4870
|
+
isSupported() {
|
|
5165
4871
|
return any(this.strategies, util.method('isSupported'));
|
|
5166
|
-
}
|
|
5167
|
-
|
|
5168
|
-
var _this = this;
|
|
4872
|
+
}
|
|
4873
|
+
connect(minPriority, callback) {
|
|
5169
4874
|
var strategies = this.strategies;
|
|
5170
4875
|
var current = 0;
|
|
5171
4876
|
var timeout = this.timeout;
|
|
5172
4877
|
var runner = null;
|
|
5173
|
-
var tryNextStrategy =
|
|
4878
|
+
var tryNextStrategy = (error, handshake) => {
|
|
5174
4879
|
if (handshake) {
|
|
5175
4880
|
callback(null, handshake);
|
|
5176
4881
|
}
|
|
5177
4882
|
else {
|
|
5178
4883
|
current = current + 1;
|
|
5179
|
-
if (
|
|
4884
|
+
if (this.loop) {
|
|
5180
4885
|
current = current % strategies.length;
|
|
5181
4886
|
}
|
|
5182
4887
|
if (current < strategies.length) {
|
|
5183
4888
|
if (timeout) {
|
|
5184
4889
|
timeout = timeout * 2;
|
|
5185
|
-
if (
|
|
5186
|
-
timeout = Math.min(timeout,
|
|
4890
|
+
if (this.timeoutLimit) {
|
|
4891
|
+
timeout = Math.min(timeout, this.timeoutLimit);
|
|
5187
4892
|
}
|
|
5188
4893
|
}
|
|
5189
|
-
runner =
|
|
4894
|
+
runner = this.tryStrategy(strategies[current], minPriority, { timeout, failFast: this.failFast }, tryNextStrategy);
|
|
5190
4895
|
}
|
|
5191
4896
|
else {
|
|
5192
4897
|
callback(true);
|
|
@@ -5205,12 +4910,12 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
5205
4910
|
}
|
|
5206
4911
|
}
|
|
5207
4912
|
};
|
|
5208
|
-
}
|
|
5209
|
-
|
|
4913
|
+
}
|
|
4914
|
+
tryStrategy(strategy, minPriority, options, callback) {
|
|
5210
4915
|
var timer = null;
|
|
5211
4916
|
var runner = null;
|
|
5212
4917
|
if (options.timeout > 0) {
|
|
5213
|
-
timer = new
|
|
4918
|
+
timer = new timers_OneOffTimer(options.timeout, function () {
|
|
5214
4919
|
runner.abort();
|
|
5215
4920
|
callback(true);
|
|
5216
4921
|
});
|
|
@@ -5235,22 +4940,20 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
5235
4940
|
runner.forceMinPriority(p);
|
|
5236
4941
|
}
|
|
5237
4942
|
};
|
|
5238
|
-
}
|
|
5239
|
-
|
|
5240
|
-
}());
|
|
5241
|
-
/* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
5242
4945
|
|
|
5243
4946
|
// CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
|
|
5244
4947
|
|
|
5245
4948
|
|
|
5246
|
-
|
|
5247
|
-
|
|
4949
|
+
class best_connected_ever_strategy_BestConnectedEverStrategy {
|
|
4950
|
+
constructor(strategies) {
|
|
5248
4951
|
this.strategies = strategies;
|
|
5249
4952
|
}
|
|
5250
|
-
|
|
4953
|
+
isSupported() {
|
|
5251
4954
|
return any(this.strategies, util.method('isSupported'));
|
|
5252
|
-
}
|
|
5253
|
-
|
|
4955
|
+
}
|
|
4956
|
+
connect(minPriority, callback) {
|
|
5254
4957
|
return connect(this.strategies, minPriority, function (i, runners) {
|
|
5255
4958
|
return function (error, handshake) {
|
|
5256
4959
|
runners[i].error = error;
|
|
@@ -5266,10 +4969,8 @@ var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
|
|
|
5266
4969
|
callback(null, handshake);
|
|
5267
4970
|
};
|
|
5268
4971
|
});
|
|
5269
|
-
}
|
|
5270
|
-
|
|
5271
|
-
}());
|
|
5272
|
-
/* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
5273
4974
|
function connect(strategies, minPriority, callbackBuilder) {
|
|
5274
4975
|
var runners = map(strategies, function (strategy, i, _, rs) {
|
|
5275
4976
|
return strategy.connect(minPriority, callbackBuilder(i, rs));
|
|
@@ -5302,18 +5003,18 @@ function abortRunner(runner) {
|
|
|
5302
5003
|
|
|
5303
5004
|
|
|
5304
5005
|
|
|
5305
|
-
|
|
5306
|
-
|
|
5006
|
+
class cached_strategy_CachedStrategy {
|
|
5007
|
+
constructor(strategy, transports, options) {
|
|
5307
5008
|
this.strategy = strategy;
|
|
5308
5009
|
this.transports = transports;
|
|
5309
5010
|
this.ttl = options.ttl || 1800 * 1000;
|
|
5310
5011
|
this.usingTLS = options.useTLS;
|
|
5311
5012
|
this.timeline = options.timeline;
|
|
5312
5013
|
}
|
|
5313
|
-
|
|
5014
|
+
isSupported() {
|
|
5314
5015
|
return this.strategy.isSupported();
|
|
5315
|
-
}
|
|
5316
|
-
|
|
5016
|
+
}
|
|
5017
|
+
connect(minPriority, callback) {
|
|
5317
5018
|
var usingTLS = this.usingTLS;
|
|
5318
5019
|
var info = fetchTransportCache(usingTLS);
|
|
5319
5020
|
var strategies = [this.strategy];
|
|
@@ -5325,7 +5026,7 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
5325
5026
|
transport: info.transport,
|
|
5326
5027
|
latency: info.latency
|
|
5327
5028
|
});
|
|
5328
|
-
strategies.push(new
|
|
5029
|
+
strategies.push(new sequential_strategy_SequentialStrategy([transport], {
|
|
5329
5030
|
timeout: info.latency * 2 + 1000,
|
|
5330
5031
|
failFast: true
|
|
5331
5032
|
}));
|
|
@@ -5361,10 +5062,8 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
5361
5062
|
}
|
|
5362
5063
|
}
|
|
5363
5064
|
};
|
|
5364
|
-
}
|
|
5365
|
-
|
|
5366
|
-
}());
|
|
5367
|
-
/* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5368
5067
|
function getTransportCacheKey(usingTLS) {
|
|
5369
5068
|
return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');
|
|
5370
5069
|
}
|
|
@@ -5410,19 +5109,18 @@ function flushTransportCache(usingTLS) {
|
|
|
5410
5109
|
|
|
5411
5110
|
// CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
|
|
5412
5111
|
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
var number = _a.delay;
|
|
5112
|
+
class delayed_strategy_DelayedStrategy {
|
|
5113
|
+
constructor(strategy, { delay: number }) {
|
|
5416
5114
|
this.strategy = strategy;
|
|
5417
5115
|
this.options = { delay: number };
|
|
5418
5116
|
}
|
|
5419
|
-
|
|
5117
|
+
isSupported() {
|
|
5420
5118
|
return this.strategy.isSupported();
|
|
5421
|
-
}
|
|
5422
|
-
|
|
5119
|
+
}
|
|
5120
|
+
connect(minPriority, callback) {
|
|
5423
5121
|
var strategy = this.strategy;
|
|
5424
5122
|
var runner;
|
|
5425
|
-
var timer = new
|
|
5123
|
+
var timer = new timers_OneOffTimer(this.options.delay, function () {
|
|
5426
5124
|
runner = strategy.connect(minPriority, callback);
|
|
5427
5125
|
});
|
|
5428
5126
|
return {
|
|
@@ -5439,39 +5137,35 @@ var delayed_strategy_DelayedStrategy = (function () {
|
|
|
5439
5137
|
}
|
|
5440
5138
|
}
|
|
5441
5139
|
};
|
|
5442
|
-
}
|
|
5443
|
-
|
|
5444
|
-
}());
|
|
5445
|
-
/* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
|
|
5140
|
+
}
|
|
5141
|
+
}
|
|
5446
5142
|
|
|
5447
5143
|
// CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
|
|
5448
|
-
|
|
5449
|
-
|
|
5144
|
+
class IfStrategy {
|
|
5145
|
+
constructor(test, trueBranch, falseBranch) {
|
|
5450
5146
|
this.test = test;
|
|
5451
5147
|
this.trueBranch = trueBranch;
|
|
5452
5148
|
this.falseBranch = falseBranch;
|
|
5453
5149
|
}
|
|
5454
|
-
|
|
5150
|
+
isSupported() {
|
|
5455
5151
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
5456
5152
|
return branch.isSupported();
|
|
5457
|
-
}
|
|
5458
|
-
|
|
5153
|
+
}
|
|
5154
|
+
connect(minPriority, callback) {
|
|
5459
5155
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
5460
5156
|
return branch.connect(minPriority, callback);
|
|
5461
|
-
}
|
|
5462
|
-
|
|
5463
|
-
}());
|
|
5464
|
-
/* harmony default export */ var if_strategy = (IfStrategy);
|
|
5157
|
+
}
|
|
5158
|
+
}
|
|
5465
5159
|
|
|
5466
5160
|
// CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
|
|
5467
|
-
|
|
5468
|
-
|
|
5161
|
+
class FirstConnectedStrategy {
|
|
5162
|
+
constructor(strategy) {
|
|
5469
5163
|
this.strategy = strategy;
|
|
5470
5164
|
}
|
|
5471
|
-
|
|
5165
|
+
isSupported() {
|
|
5472
5166
|
return this.strategy.isSupported();
|
|
5473
|
-
}
|
|
5474
|
-
|
|
5167
|
+
}
|
|
5168
|
+
connect(minPriority, callback) {
|
|
5475
5169
|
var runner = this.strategy.connect(minPriority, function (error, handshake) {
|
|
5476
5170
|
if (handshake) {
|
|
5477
5171
|
runner.abort();
|
|
@@ -5479,10 +5173,8 @@ var FirstConnectedStrategy = (function () {
|
|
|
5479
5173
|
callback(error, handshake);
|
|
5480
5174
|
});
|
|
5481
5175
|
return runner;
|
|
5482
|
-
}
|
|
5483
|
-
|
|
5484
|
-
}());
|
|
5485
|
-
/* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
|
|
5176
|
+
}
|
|
5177
|
+
}
|
|
5486
5178
|
|
|
5487
5179
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/default_strategy.ts
|
|
5488
5180
|
|
|
@@ -5523,12 +5215,12 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5523
5215
|
timeout: 15000,
|
|
5524
5216
|
timeoutLimit: 60000
|
|
5525
5217
|
};
|
|
5526
|
-
var ws_manager = new
|
|
5218
|
+
var ws_manager = new transport_manager_TransportManager({
|
|
5527
5219
|
lives: 2,
|
|
5528
5220
|
minPingDelay: 10000,
|
|
5529
5221
|
maxPingDelay: config.activityTimeout
|
|
5530
5222
|
});
|
|
5531
|
-
var streaming_manager = new
|
|
5223
|
+
var streaming_manager = new transport_manager_TransportManager({
|
|
5532
5224
|
lives: 2,
|
|
5533
5225
|
minPingDelay: 10000,
|
|
5534
5226
|
maxPingDelay: config.activityTimeout
|
|
@@ -5537,31 +5229,31 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5537
5229
|
var wss_transport = defineTransportStrategy('wss', 'ws', 3, wss_options, ws_manager);
|
|
5538
5230
|
var xhr_streaming_transport = defineTransportStrategy('xhr_streaming', 'xhr_streaming', 1, http_options, streaming_manager);
|
|
5539
5231
|
var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, http_options);
|
|
5540
|
-
var ws_loop = new
|
|
5541
|
-
var wss_loop = new
|
|
5542
|
-
var streaming_loop = new
|
|
5543
|
-
var polling_loop = new
|
|
5544
|
-
var http_loop = new
|
|
5545
|
-
new
|
|
5232
|
+
var ws_loop = new sequential_strategy_SequentialStrategy([ws_transport], timeouts);
|
|
5233
|
+
var wss_loop = new sequential_strategy_SequentialStrategy([wss_transport], timeouts);
|
|
5234
|
+
var streaming_loop = new sequential_strategy_SequentialStrategy([xhr_streaming_transport], timeouts);
|
|
5235
|
+
var polling_loop = new sequential_strategy_SequentialStrategy([xhr_polling_transport], timeouts);
|
|
5236
|
+
var http_loop = new sequential_strategy_SequentialStrategy([
|
|
5237
|
+
new IfStrategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5546
5238
|
streaming_loop,
|
|
5547
|
-
new
|
|
5239
|
+
new delayed_strategy_DelayedStrategy(polling_loop, { delay: 4000 })
|
|
5548
5240
|
]), polling_loop)
|
|
5549
5241
|
], timeouts);
|
|
5550
5242
|
var wsStrategy;
|
|
5551
5243
|
if (baseOptions.useTLS) {
|
|
5552
|
-
wsStrategy = new
|
|
5244
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5553
5245
|
ws_loop,
|
|
5554
|
-
new
|
|
5246
|
+
new delayed_strategy_DelayedStrategy(http_loop, { delay: 2000 })
|
|
5555
5247
|
]);
|
|
5556
5248
|
}
|
|
5557
5249
|
else {
|
|
5558
|
-
wsStrategy = new
|
|
5250
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5559
5251
|
ws_loop,
|
|
5560
|
-
new
|
|
5561
|
-
new
|
|
5252
|
+
new delayed_strategy_DelayedStrategy(wss_loop, { delay: 2000 }),
|
|
5253
|
+
new delayed_strategy_DelayedStrategy(http_loop, { delay: 5000 })
|
|
5562
5254
|
]);
|
|
5563
5255
|
}
|
|
5564
|
-
return new
|
|
5256
|
+
return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)), definedTransports, {
|
|
5565
5257
|
ttl: 1800000,
|
|
5566
5258
|
timeline: baseOptions.timeline,
|
|
5567
5259
|
useTLS: baseOptions.useTLS
|
|
@@ -5584,37 +5276,21 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5584
5276
|
});
|
|
5585
5277
|
|
|
5586
5278
|
// CONCATENATED MODULE: ./src/core/http/http_request.ts
|
|
5587
|
-
var http_request_extends = (undefined && undefined.__extends) || (function () {
|
|
5588
|
-
var extendStatics = function (d, b) {
|
|
5589
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5590
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5591
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
5592
|
-
return extendStatics(d, b);
|
|
5593
|
-
};
|
|
5594
|
-
return function (d, b) {
|
|
5595
|
-
extendStatics(d, b);
|
|
5596
|
-
function __() { this.constructor = d; }
|
|
5597
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
5598
|
-
};
|
|
5599
|
-
})();
|
|
5600
5279
|
|
|
5601
5280
|
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
_this.url = url;
|
|
5610
|
-
return _this;
|
|
5281
|
+
const MAX_BUFFER_LENGTH = 256 * 1024;
|
|
5282
|
+
class http_request_HTTPRequest extends dispatcher_Dispatcher {
|
|
5283
|
+
constructor(hooks, method, url) {
|
|
5284
|
+
super();
|
|
5285
|
+
this.hooks = hooks;
|
|
5286
|
+
this.method = method;
|
|
5287
|
+
this.url = url;
|
|
5611
5288
|
}
|
|
5612
|
-
|
|
5613
|
-
var _this = this;
|
|
5289
|
+
start(payload) {
|
|
5614
5290
|
this.position = 0;
|
|
5615
5291
|
this.xhr = this.hooks.getRequest(this);
|
|
5616
|
-
this.unloader =
|
|
5617
|
-
|
|
5292
|
+
this.unloader = () => {
|
|
5293
|
+
this.close();
|
|
5618
5294
|
};
|
|
5619
5295
|
worker_runtime.addUnloadListener(this.unloader);
|
|
5620
5296
|
this.xhr.open(this.method, this.url, true);
|
|
@@ -5622,8 +5298,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
5622
5298
|
this.xhr.setRequestHeader('Content-Type', 'application/json');
|
|
5623
5299
|
}
|
|
5624
5300
|
this.xhr.send(payload);
|
|
5625
|
-
}
|
|
5626
|
-
|
|
5301
|
+
}
|
|
5302
|
+
close() {
|
|
5627
5303
|
if (this.unloader) {
|
|
5628
5304
|
worker_runtime.removeUnloadListener(this.unloader);
|
|
5629
5305
|
this.unloader = null;
|
|
@@ -5632,8 +5308,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
5632
5308
|
this.hooks.abortRequest(this.xhr);
|
|
5633
5309
|
this.xhr = null;
|
|
5634
5310
|
}
|
|
5635
|
-
}
|
|
5636
|
-
|
|
5311
|
+
}
|
|
5312
|
+
onChunk(status, data) {
|
|
5637
5313
|
while (true) {
|
|
5638
5314
|
var chunk = this.advanceBuffer(data);
|
|
5639
5315
|
if (chunk) {
|
|
@@ -5646,8 +5322,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
5646
5322
|
if (this.isBufferTooLong(data)) {
|
|
5647
5323
|
this.emit('buffer_too_long');
|
|
5648
5324
|
}
|
|
5649
|
-
}
|
|
5650
|
-
|
|
5325
|
+
}
|
|
5326
|
+
advanceBuffer(buffer) {
|
|
5651
5327
|
var unreadData = buffer.slice(this.position);
|
|
5652
5328
|
var endOfLinePosition = unreadData.indexOf('\n');
|
|
5653
5329
|
if (endOfLinePosition !== -1) {
|
|
@@ -5657,13 +5333,11 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
5657
5333
|
else {
|
|
5658
5334
|
return null;
|
|
5659
5335
|
}
|
|
5660
|
-
}
|
|
5661
|
-
|
|
5336
|
+
}
|
|
5337
|
+
isBufferTooLong(buffer) {
|
|
5662
5338
|
return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
|
|
5663
|
-
}
|
|
5664
|
-
|
|
5665
|
-
}(dispatcher));
|
|
5666
|
-
/* harmony default export */ var http_request = (http_request_HTTPRequest);
|
|
5339
|
+
}
|
|
5340
|
+
}
|
|
5667
5341
|
|
|
5668
5342
|
// CONCATENATED MODULE: ./src/core/http/state.ts
|
|
5669
5343
|
var State;
|
|
@@ -5679,24 +5353,24 @@ var State;
|
|
|
5679
5353
|
|
|
5680
5354
|
|
|
5681
5355
|
var autoIncrement = 1;
|
|
5682
|
-
|
|
5683
|
-
|
|
5356
|
+
class http_socket_HTTPSocket {
|
|
5357
|
+
constructor(hooks, url) {
|
|
5684
5358
|
this.hooks = hooks;
|
|
5685
5359
|
this.session = randomNumber(1000) + '/' + randomString(8);
|
|
5686
5360
|
this.location = getLocation(url);
|
|
5687
5361
|
this.readyState = state.CONNECTING;
|
|
5688
5362
|
this.openStream();
|
|
5689
5363
|
}
|
|
5690
|
-
|
|
5364
|
+
send(payload) {
|
|
5691
5365
|
return this.sendRaw(JSON.stringify([payload]));
|
|
5692
|
-
}
|
|
5693
|
-
|
|
5366
|
+
}
|
|
5367
|
+
ping() {
|
|
5694
5368
|
this.hooks.sendHeartbeat(this);
|
|
5695
|
-
}
|
|
5696
|
-
|
|
5369
|
+
}
|
|
5370
|
+
close(code, reason) {
|
|
5697
5371
|
this.onClose(code, reason, true);
|
|
5698
|
-
}
|
|
5699
|
-
|
|
5372
|
+
}
|
|
5373
|
+
sendRaw(payload) {
|
|
5700
5374
|
if (this.readyState === state.OPEN) {
|
|
5701
5375
|
try {
|
|
5702
5376
|
worker_runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);
|
|
@@ -5709,12 +5383,12 @@ var http_socket_HTTPSocket = (function () {
|
|
|
5709
5383
|
else {
|
|
5710
5384
|
return false;
|
|
5711
5385
|
}
|
|
5712
|
-
}
|
|
5713
|
-
|
|
5386
|
+
}
|
|
5387
|
+
reconnect() {
|
|
5714
5388
|
this.closeStream();
|
|
5715
5389
|
this.openStream();
|
|
5716
|
-
}
|
|
5717
|
-
|
|
5390
|
+
}
|
|
5391
|
+
onClose(code, reason, wasClean) {
|
|
5718
5392
|
this.closeStream();
|
|
5719
5393
|
this.readyState = state.CLOSED;
|
|
5720
5394
|
if (this.onclose) {
|
|
@@ -5724,8 +5398,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
5724
5398
|
wasClean: wasClean
|
|
5725
5399
|
});
|
|
5726
5400
|
}
|
|
5727
|
-
}
|
|
5728
|
-
|
|
5401
|
+
}
|
|
5402
|
+
onChunk(chunk) {
|
|
5729
5403
|
if (chunk.status !== 200) {
|
|
5730
5404
|
return;
|
|
5731
5405
|
}
|
|
@@ -5757,8 +5431,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
5757
5431
|
this.onClose(payload[0], payload[1], true);
|
|
5758
5432
|
break;
|
|
5759
5433
|
}
|
|
5760
|
-
}
|
|
5761
|
-
|
|
5434
|
+
}
|
|
5435
|
+
onOpen(options) {
|
|
5762
5436
|
if (this.readyState === state.CONNECTING) {
|
|
5763
5437
|
if (options && options.hostname) {
|
|
5764
5438
|
this.location.base = replaceHost(this.location.base, options.hostname);
|
|
@@ -5771,53 +5445,51 @@ var http_socket_HTTPSocket = (function () {
|
|
|
5771
5445
|
else {
|
|
5772
5446
|
this.onClose(1006, 'Server lost session', true);
|
|
5773
5447
|
}
|
|
5774
|
-
}
|
|
5775
|
-
|
|
5448
|
+
}
|
|
5449
|
+
onEvent(event) {
|
|
5776
5450
|
if (this.readyState === state.OPEN && this.onmessage) {
|
|
5777
5451
|
this.onmessage({ data: event });
|
|
5778
5452
|
}
|
|
5779
|
-
}
|
|
5780
|
-
|
|
5453
|
+
}
|
|
5454
|
+
onActivity() {
|
|
5781
5455
|
if (this.onactivity) {
|
|
5782
5456
|
this.onactivity();
|
|
5783
5457
|
}
|
|
5784
|
-
}
|
|
5785
|
-
|
|
5458
|
+
}
|
|
5459
|
+
onError(error) {
|
|
5786
5460
|
if (this.onerror) {
|
|
5787
5461
|
this.onerror(error);
|
|
5788
5462
|
}
|
|
5789
|
-
}
|
|
5790
|
-
|
|
5791
|
-
var _this = this;
|
|
5463
|
+
}
|
|
5464
|
+
openStream() {
|
|
5792
5465
|
this.stream = worker_runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
|
|
5793
|
-
this.stream.bind('chunk',
|
|
5794
|
-
|
|
5466
|
+
this.stream.bind('chunk', chunk => {
|
|
5467
|
+
this.onChunk(chunk);
|
|
5795
5468
|
});
|
|
5796
|
-
this.stream.bind('finished',
|
|
5797
|
-
|
|
5469
|
+
this.stream.bind('finished', status => {
|
|
5470
|
+
this.hooks.onFinished(this, status);
|
|
5798
5471
|
});
|
|
5799
|
-
this.stream.bind('buffer_too_long',
|
|
5800
|
-
|
|
5472
|
+
this.stream.bind('buffer_too_long', () => {
|
|
5473
|
+
this.reconnect();
|
|
5801
5474
|
});
|
|
5802
5475
|
try {
|
|
5803
5476
|
this.stream.start();
|
|
5804
5477
|
}
|
|
5805
5478
|
catch (error) {
|
|
5806
|
-
util.defer(
|
|
5807
|
-
|
|
5808
|
-
|
|
5479
|
+
util.defer(() => {
|
|
5480
|
+
this.onError(error);
|
|
5481
|
+
this.onClose(1006, 'Could not start streaming', false);
|
|
5809
5482
|
});
|
|
5810
5483
|
}
|
|
5811
|
-
}
|
|
5812
|
-
|
|
5484
|
+
}
|
|
5485
|
+
closeStream() {
|
|
5813
5486
|
if (this.stream) {
|
|
5814
5487
|
this.stream.unbind_all();
|
|
5815
5488
|
this.stream.close();
|
|
5816
5489
|
this.stream = null;
|
|
5817
5490
|
}
|
|
5818
|
-
}
|
|
5819
|
-
|
|
5820
|
-
}());
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5821
5493
|
function getLocation(url) {
|
|
5822
5494
|
var parts = /([^\?]*)\/*(\??.*)/.exec(url);
|
|
5823
5495
|
return {
|
|
@@ -5924,20 +5596,20 @@ var http_xhr_request_hooks = {
|
|
|
5924
5596
|
|
|
5925
5597
|
|
|
5926
5598
|
var HTTP = {
|
|
5927
|
-
createStreamingSocket
|
|
5599
|
+
createStreamingSocket(url) {
|
|
5928
5600
|
return this.createSocket(http_streaming_socket, url);
|
|
5929
5601
|
},
|
|
5930
|
-
createPollingSocket
|
|
5602
|
+
createPollingSocket(url) {
|
|
5931
5603
|
return this.createSocket(http_polling_socket, url);
|
|
5932
5604
|
},
|
|
5933
|
-
createSocket
|
|
5605
|
+
createSocket(hooks, url) {
|
|
5934
5606
|
return new http_socket(hooks, url);
|
|
5935
5607
|
},
|
|
5936
|
-
createXHR
|
|
5608
|
+
createXHR(method, url) {
|
|
5937
5609
|
return this.createRequest(http_xhr_request, method, url);
|
|
5938
5610
|
},
|
|
5939
|
-
createRequest
|
|
5940
|
-
return new
|
|
5611
|
+
createRequest(hooks, method, url) {
|
|
5612
|
+
return new http_request_HTTPRequest(hooks, method, url);
|
|
5941
5613
|
}
|
|
5942
5614
|
};
|
|
5943
5615
|
/* harmony default export */ var http_http = (HTTP);
|
|
@@ -5953,24 +5625,24 @@ var Isomorphic = {
|
|
|
5953
5625
|
Transports: transports,
|
|
5954
5626
|
transportConnectionInitializer: transport_connection_initializer,
|
|
5955
5627
|
HTTPFactory: http_http,
|
|
5956
|
-
setup
|
|
5628
|
+
setup(PusherClass) {
|
|
5957
5629
|
PusherClass.ready();
|
|
5958
5630
|
},
|
|
5959
|
-
getLocalStorage
|
|
5631
|
+
getLocalStorage() {
|
|
5960
5632
|
return undefined;
|
|
5961
5633
|
},
|
|
5962
|
-
getClientFeatures
|
|
5634
|
+
getClientFeatures() {
|
|
5963
5635
|
return keys(filterObject({ ws: transports.ws }, function (t) {
|
|
5964
5636
|
return t.isSupported({});
|
|
5965
5637
|
}));
|
|
5966
5638
|
},
|
|
5967
|
-
getProtocol
|
|
5639
|
+
getProtocol() {
|
|
5968
5640
|
return 'http:';
|
|
5969
5641
|
},
|
|
5970
|
-
isXHRSupported
|
|
5642
|
+
isXHRSupported() {
|
|
5971
5643
|
return true;
|
|
5972
5644
|
},
|
|
5973
|
-
createSocketRequest
|
|
5645
|
+
createSocketRequest(method, url) {
|
|
5974
5646
|
if (this.isXHRSupported()) {
|
|
5975
5647
|
return this.HTTPFactory.createXHR(method, url);
|
|
5976
5648
|
}
|
|
@@ -5978,46 +5650,27 @@ var Isomorphic = {
|
|
|
5978
5650
|
throw 'Cross-origin HTTP requests are not supported';
|
|
5979
5651
|
}
|
|
5980
5652
|
},
|
|
5981
|
-
createXHR
|
|
5653
|
+
createXHR() {
|
|
5982
5654
|
var Constructor = this.getXHRAPI();
|
|
5983
5655
|
return new Constructor();
|
|
5984
5656
|
},
|
|
5985
|
-
createWebSocket
|
|
5657
|
+
createWebSocket(url) {
|
|
5986
5658
|
var Constructor = this.getWebSocketAPI();
|
|
5987
5659
|
return new Constructor(url);
|
|
5988
5660
|
},
|
|
5989
|
-
addUnloadListener
|
|
5990
|
-
removeUnloadListener
|
|
5661
|
+
addUnloadListener(listener) { },
|
|
5662
|
+
removeUnloadListener(listener) { }
|
|
5991
5663
|
};
|
|
5992
5664
|
/* harmony default export */ var runtime = (Isomorphic);
|
|
5993
5665
|
|
|
5994
5666
|
// CONCATENATED MODULE: ./src/runtimes/worker/net_info.ts
|
|
5995
|
-
var net_info_extends = (undefined && undefined.__extends) || (function () {
|
|
5996
|
-
var extendStatics = function (d, b) {
|
|
5997
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5998
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5999
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6000
|
-
return extendStatics(d, b);
|
|
6001
|
-
};
|
|
6002
|
-
return function (d, b) {
|
|
6003
|
-
extendStatics(d, b);
|
|
6004
|
-
function __() { this.constructor = d; }
|
|
6005
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6006
|
-
};
|
|
6007
|
-
})();
|
|
6008
5667
|
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
function NetInfo() {
|
|
6012
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
6013
|
-
}
|
|
6014
|
-
NetInfo.prototype.isOnline = function () {
|
|
5668
|
+
class net_info_NetInfo extends dispatcher_Dispatcher {
|
|
5669
|
+
isOnline() {
|
|
6015
5670
|
return true;
|
|
6016
|
-
}
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
var net_info_Network = new NetInfo();
|
|
5671
|
+
}
|
|
5672
|
+
}
|
|
5673
|
+
var net_info_Network = new net_info_NetInfo();
|
|
6021
5674
|
|
|
6022
5675
|
// CONCATENATED MODULE: ./src/runtimes/worker/auth/fetch_auth.ts
|
|
6023
5676
|
|
|
@@ -6028,36 +5681,37 @@ var fetchAuth = function (context, query, authOptions, authRequestType, callback
|
|
|
6028
5681
|
headers.set(headerName, authOptions.headers[headerName]);
|
|
6029
5682
|
}
|
|
6030
5683
|
if (authOptions.headersProvider != null) {
|
|
6031
|
-
|
|
5684
|
+
const dynamicHeaders = authOptions.headersProvider();
|
|
6032
5685
|
for (var headerName in dynamicHeaders) {
|
|
6033
5686
|
headers.set(headerName, dynamicHeaders[headerName]);
|
|
6034
5687
|
}
|
|
6035
5688
|
}
|
|
6036
5689
|
var body = query;
|
|
6037
5690
|
var request = new Request(authOptions.endpoint, {
|
|
6038
|
-
headers
|
|
6039
|
-
body
|
|
5691
|
+
headers,
|
|
5692
|
+
body,
|
|
6040
5693
|
credentials: 'same-origin',
|
|
6041
5694
|
method: 'POST'
|
|
6042
5695
|
});
|
|
6043
5696
|
return fetch(request)
|
|
6044
|
-
.then(
|
|
6045
|
-
|
|
5697
|
+
.then(response => {
|
|
5698
|
+
let { status } = response;
|
|
6046
5699
|
if (status === 200) {
|
|
6047
5700
|
return response.text();
|
|
6048
5701
|
}
|
|
6049
|
-
throw new HTTPAuthError(status,
|
|
5702
|
+
throw new HTTPAuthError(status, `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`);
|
|
6050
5703
|
})
|
|
6051
|
-
.then(
|
|
6052
|
-
|
|
5704
|
+
.then(data => {
|
|
5705
|
+
let parsedData;
|
|
6053
5706
|
try {
|
|
6054
5707
|
parsedData = JSON.parse(data);
|
|
6055
5708
|
}
|
|
6056
5709
|
catch (e) {
|
|
6057
|
-
throw new HTTPAuthError(200,
|
|
5710
|
+
throw new HTTPAuthError(200, `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`);
|
|
6058
5711
|
}
|
|
6059
5712
|
callback(null, parsedData);
|
|
6060
|
-
})
|
|
5713
|
+
})
|
|
5714
|
+
.catch(err => {
|
|
6061
5715
|
callback(err, null);
|
|
6062
5716
|
});
|
|
6063
5717
|
};
|
|
@@ -6073,25 +5727,25 @@ var getAgent = function (sender, useTLS) {
|
|
|
6073
5727
|
var query = buildQueryString(data);
|
|
6074
5728
|
url += '/' + 2 + '?' + query;
|
|
6075
5729
|
fetch(url)
|
|
6076
|
-
.then(
|
|
5730
|
+
.then(response => {
|
|
6077
5731
|
if (response.status !== 200) {
|
|
6078
|
-
throw
|
|
5732
|
+
throw `received ${response.status} from stats.pusher.com`;
|
|
6079
5733
|
}
|
|
6080
5734
|
return response.json();
|
|
6081
5735
|
})
|
|
6082
|
-
.then(
|
|
6083
|
-
var host = _a.host;
|
|
5736
|
+
.then(({ host }) => {
|
|
6084
5737
|
if (host) {
|
|
6085
5738
|
sender.host = host;
|
|
6086
5739
|
}
|
|
6087
|
-
})
|
|
5740
|
+
})
|
|
5741
|
+
.catch(err => {
|
|
6088
5742
|
logger.debug('TimelineSender Error: ', err);
|
|
6089
5743
|
});
|
|
6090
5744
|
};
|
|
6091
5745
|
};
|
|
6092
5746
|
var fetchTimeline = {
|
|
6093
5747
|
name: 'xhr',
|
|
6094
|
-
getAgent
|
|
5748
|
+
getAgent
|
|
6095
5749
|
};
|
|
6096
5750
|
/* harmony default export */ var fetch_timeline = (fetchTimeline);
|
|
6097
5751
|
|
|
@@ -6100,38 +5754,38 @@ var fetchTimeline = {
|
|
|
6100
5754
|
|
|
6101
5755
|
|
|
6102
5756
|
|
|
6103
|
-
|
|
6104
|
-
|
|
5757
|
+
const { getDefaultStrategy: runtime_getDefaultStrategy, Transports: runtime_Transports, setup, getProtocol, isXHRSupported, getLocalStorage, createXHR, createWebSocket, addUnloadListener, removeUnloadListener, transportConnectionInitializer, createSocketRequest, HTTPFactory } = runtime;
|
|
5758
|
+
const Worker = {
|
|
6105
5759
|
getDefaultStrategy: runtime_getDefaultStrategy,
|
|
6106
5760
|
Transports: runtime_Transports,
|
|
6107
|
-
setup
|
|
6108
|
-
getProtocol
|
|
6109
|
-
isXHRSupported
|
|
6110
|
-
getLocalStorage
|
|
6111
|
-
createXHR
|
|
6112
|
-
createWebSocket
|
|
6113
|
-
addUnloadListener
|
|
6114
|
-
removeUnloadListener
|
|
6115
|
-
transportConnectionInitializer
|
|
6116
|
-
createSocketRequest
|
|
6117
|
-
HTTPFactory
|
|
5761
|
+
setup,
|
|
5762
|
+
getProtocol,
|
|
5763
|
+
isXHRSupported,
|
|
5764
|
+
getLocalStorage,
|
|
5765
|
+
createXHR,
|
|
5766
|
+
createWebSocket,
|
|
5767
|
+
addUnloadListener,
|
|
5768
|
+
removeUnloadListener,
|
|
5769
|
+
transportConnectionInitializer,
|
|
5770
|
+
createSocketRequest,
|
|
5771
|
+
HTTPFactory,
|
|
6118
5772
|
TimelineTransport: fetch_timeline,
|
|
6119
|
-
getAuthorizers
|
|
5773
|
+
getAuthorizers() {
|
|
6120
5774
|
return { ajax: fetch_auth };
|
|
6121
5775
|
},
|
|
6122
|
-
getWebSocketAPI
|
|
5776
|
+
getWebSocketAPI() {
|
|
6123
5777
|
return WebSocket;
|
|
6124
5778
|
},
|
|
6125
|
-
getXHRAPI
|
|
5779
|
+
getXHRAPI() {
|
|
6126
5780
|
return XMLHttpRequest;
|
|
6127
5781
|
},
|
|
6128
|
-
getNetwork
|
|
5782
|
+
getNetwork() {
|
|
6129
5783
|
return net_info_Network;
|
|
6130
5784
|
},
|
|
6131
|
-
randomInt
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
5785
|
+
randomInt(max) {
|
|
5786
|
+
const random = function () {
|
|
5787
|
+
const crypto = globalThis.crypto || globalThis['msCrypto'];
|
|
5788
|
+
const random = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
6135
5789
|
return random / Math.pow(2, 32);
|
|
6136
5790
|
};
|
|
6137
5791
|
return Math.floor(random() * max);
|
|
@@ -6152,8 +5806,8 @@ var TimelineLevel;
|
|
|
6152
5806
|
|
|
6153
5807
|
|
|
6154
5808
|
|
|
6155
|
-
|
|
6156
|
-
|
|
5809
|
+
class timeline_Timeline {
|
|
5810
|
+
constructor(key, session, options) {
|
|
6157
5811
|
this.key = key;
|
|
6158
5812
|
this.session = session;
|
|
6159
5813
|
this.events = [];
|
|
@@ -6161,28 +5815,27 @@ var timeline_Timeline = (function () {
|
|
|
6161
5815
|
this.sent = 0;
|
|
6162
5816
|
this.uniqueID = 0;
|
|
6163
5817
|
}
|
|
6164
|
-
|
|
5818
|
+
log(level, event) {
|
|
6165
5819
|
if (level <= this.options.level) {
|
|
6166
5820
|
this.events.push(extend({}, event, { timestamp: util.now() }));
|
|
6167
5821
|
if (this.options.limit && this.events.length > this.options.limit) {
|
|
6168
5822
|
this.events.shift();
|
|
6169
5823
|
}
|
|
6170
5824
|
}
|
|
6171
|
-
}
|
|
6172
|
-
|
|
5825
|
+
}
|
|
5826
|
+
error(event) {
|
|
6173
5827
|
this.log(timeline_level.ERROR, event);
|
|
6174
|
-
}
|
|
6175
|
-
|
|
5828
|
+
}
|
|
5829
|
+
info(event) {
|
|
6176
5830
|
this.log(timeline_level.INFO, event);
|
|
6177
|
-
}
|
|
6178
|
-
|
|
5831
|
+
}
|
|
5832
|
+
debug(event) {
|
|
6179
5833
|
this.log(timeline_level.DEBUG, event);
|
|
6180
|
-
}
|
|
6181
|
-
|
|
5834
|
+
}
|
|
5835
|
+
isEmpty() {
|
|
6182
5836
|
return this.events.length === 0;
|
|
6183
|
-
}
|
|
6184
|
-
|
|
6185
|
-
var _this = this;
|
|
5837
|
+
}
|
|
5838
|
+
send(sendfn, callback) {
|
|
6186
5839
|
var data = extend({
|
|
6187
5840
|
session: this.session,
|
|
6188
5841
|
bundle: this.sent + 1,
|
|
@@ -6194,43 +5847,40 @@ var timeline_Timeline = (function () {
|
|
|
6194
5847
|
timeline: this.events
|
|
6195
5848
|
}, this.options.params);
|
|
6196
5849
|
this.events = [];
|
|
6197
|
-
sendfn(data,
|
|
5850
|
+
sendfn(data, (error, result) => {
|
|
6198
5851
|
if (!error) {
|
|
6199
|
-
|
|
5852
|
+
this.sent++;
|
|
6200
5853
|
}
|
|
6201
5854
|
if (callback) {
|
|
6202
5855
|
callback(error, result);
|
|
6203
5856
|
}
|
|
6204
5857
|
});
|
|
6205
5858
|
return true;
|
|
6206
|
-
}
|
|
6207
|
-
|
|
5859
|
+
}
|
|
5860
|
+
generateUniqueID() {
|
|
6208
5861
|
this.uniqueID++;
|
|
6209
5862
|
return this.uniqueID;
|
|
6210
|
-
}
|
|
6211
|
-
|
|
6212
|
-
}());
|
|
6213
|
-
/* harmony default export */ var timeline_timeline = (timeline_Timeline);
|
|
5863
|
+
}
|
|
5864
|
+
}
|
|
6214
5865
|
|
|
6215
5866
|
// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
|
|
6216
5867
|
|
|
6217
5868
|
|
|
6218
5869
|
|
|
6219
5870
|
|
|
6220
|
-
|
|
6221
|
-
|
|
5871
|
+
class transport_strategy_TransportStrategy {
|
|
5872
|
+
constructor(name, priority, transport, options) {
|
|
6222
5873
|
this.name = name;
|
|
6223
5874
|
this.priority = priority;
|
|
6224
5875
|
this.transport = transport;
|
|
6225
5876
|
this.options = options || {};
|
|
6226
5877
|
}
|
|
6227
|
-
|
|
5878
|
+
isSupported() {
|
|
6228
5879
|
return this.transport.isSupported({
|
|
6229
5880
|
useTLS: this.options.useTLS
|
|
6230
5881
|
});
|
|
6231
|
-
}
|
|
6232
|
-
|
|
6233
|
-
var _this = this;
|
|
5882
|
+
}
|
|
5883
|
+
connect(minPriority, callback) {
|
|
6234
5884
|
if (!this.isSupported()) {
|
|
6235
5885
|
return failAttempt(new UnsupportedStrategy(), callback);
|
|
6236
5886
|
}
|
|
@@ -6273,7 +5923,7 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6273
5923
|
transport.bind('closed', onClosed);
|
|
6274
5924
|
transport.initialize();
|
|
6275
5925
|
return {
|
|
6276
|
-
abort:
|
|
5926
|
+
abort: () => {
|
|
6277
5927
|
if (connected) {
|
|
6278
5928
|
return;
|
|
6279
5929
|
}
|
|
@@ -6285,11 +5935,11 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6285
5935
|
transport.close();
|
|
6286
5936
|
}
|
|
6287
5937
|
},
|
|
6288
|
-
forceMinPriority:
|
|
5938
|
+
forceMinPriority: p => {
|
|
6289
5939
|
if (connected) {
|
|
6290
5940
|
return;
|
|
6291
5941
|
}
|
|
6292
|
-
if (
|
|
5942
|
+
if (this.priority < p) {
|
|
6293
5943
|
if (handshake) {
|
|
6294
5944
|
handshake.close();
|
|
6295
5945
|
}
|
|
@@ -6299,10 +5949,8 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6299
5949
|
}
|
|
6300
5950
|
}
|
|
6301
5951
|
};
|
|
6302
|
-
}
|
|
6303
|
-
|
|
6304
|
-
}());
|
|
6305
|
-
/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
|
|
5952
|
+
}
|
|
5953
|
+
}
|
|
6306
5954
|
function failAttempt(error, callback) {
|
|
6307
5955
|
util.defer(function () {
|
|
6308
5956
|
callback(error);
|
|
@@ -6319,7 +5967,7 @@ function failAttempt(error, callback) {
|
|
|
6319
5967
|
|
|
6320
5968
|
|
|
6321
5969
|
|
|
6322
|
-
|
|
5970
|
+
const { Transports: strategy_builder_Transports } = worker_runtime;
|
|
6323
5971
|
var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
|
|
6324
5972
|
var transportClass = strategy_builder_Transports[type];
|
|
6325
5973
|
if (!transportClass) {
|
|
@@ -6332,7 +5980,7 @@ var strategy_builder_defineTransport = function (config, name, type, priority, o
|
|
|
6332
5980
|
var transport;
|
|
6333
5981
|
if (enabled) {
|
|
6334
5982
|
options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);
|
|
6335
|
-
transport = new
|
|
5983
|
+
transport = new transport_strategy_TransportStrategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
|
|
6336
5984
|
}
|
|
6337
5985
|
else {
|
|
6338
5986
|
transport = strategy_builder_UnsupportedStrategy;
|
|
@@ -6380,7 +6028,7 @@ var AuthRequestType;
|
|
|
6380
6028
|
// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts
|
|
6381
6029
|
|
|
6382
6030
|
|
|
6383
|
-
|
|
6031
|
+
const composeChannelQuery = (params, authOptions) => {
|
|
6384
6032
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
6385
6033
|
for (var key in authOptions.params) {
|
|
6386
6034
|
query +=
|
|
@@ -6390,7 +6038,7 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
6390
6038
|
encodeURIComponent(authOptions.params[key]);
|
|
6391
6039
|
}
|
|
6392
6040
|
if (authOptions.paramsProvider != null) {
|
|
6393
|
-
|
|
6041
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
6394
6042
|
for (var key in dynamicParams) {
|
|
6395
6043
|
query +=
|
|
6396
6044
|
'&' +
|
|
@@ -6401,12 +6049,12 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
6401
6049
|
}
|
|
6402
6050
|
return query;
|
|
6403
6051
|
};
|
|
6404
|
-
|
|
6052
|
+
const UserAuthenticator = (authOptions) => {
|
|
6405
6053
|
if (typeof worker_runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
6406
|
-
throw
|
|
6054
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
6407
6055
|
}
|
|
6408
|
-
return
|
|
6409
|
-
|
|
6056
|
+
return (params, callback) => {
|
|
6057
|
+
const query = composeChannelQuery(params, authOptions);
|
|
6410
6058
|
worker_runtime.getAuthorizers()[authOptions.transport](worker_runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);
|
|
6411
6059
|
};
|
|
6412
6060
|
};
|
|
@@ -6415,7 +6063,7 @@ var UserAuthenticator = function (authOptions) {
|
|
|
6415
6063
|
// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts
|
|
6416
6064
|
|
|
6417
6065
|
|
|
6418
|
-
|
|
6066
|
+
const channel_authorizer_composeChannelQuery = (params, authOptions) => {
|
|
6419
6067
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
6420
6068
|
query += '&channel_name=' + encodeURIComponent(params.channelName);
|
|
6421
6069
|
for (var key in authOptions.params) {
|
|
@@ -6426,7 +6074,7 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
6426
6074
|
encodeURIComponent(authOptions.params[key]);
|
|
6427
6075
|
}
|
|
6428
6076
|
if (authOptions.paramsProvider != null) {
|
|
6429
|
-
|
|
6077
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
6430
6078
|
for (var key in dynamicParams) {
|
|
6431
6079
|
query +=
|
|
6432
6080
|
'&' +
|
|
@@ -6437,20 +6085,20 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
6437
6085
|
}
|
|
6438
6086
|
return query;
|
|
6439
6087
|
};
|
|
6440
|
-
|
|
6088
|
+
const ChannelAuthorizer = (authOptions) => {
|
|
6441
6089
|
if (typeof worker_runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
6442
|
-
throw
|
|
6090
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
6443
6091
|
}
|
|
6444
|
-
return
|
|
6445
|
-
|
|
6092
|
+
return (params, callback) => {
|
|
6093
|
+
const query = channel_authorizer_composeChannelQuery(params, authOptions);
|
|
6446
6094
|
worker_runtime.getAuthorizers()[authOptions.transport](worker_runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);
|
|
6447
6095
|
};
|
|
6448
6096
|
};
|
|
6449
6097
|
/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);
|
|
6450
6098
|
|
|
6451
6099
|
// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts
|
|
6452
|
-
|
|
6453
|
-
|
|
6100
|
+
const ChannelAuthorizerProxy = (pusher, authOptions, channelAuthorizerGenerator) => {
|
|
6101
|
+
const deprecatedAuthorizerOptions = {
|
|
6454
6102
|
authTransport: authOptions.transport,
|
|
6455
6103
|
authEndpoint: authOptions.endpoint,
|
|
6456
6104
|
auth: {
|
|
@@ -6458,32 +6106,21 @@ var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGen
|
|
|
6458
6106
|
headers: authOptions.headers
|
|
6459
6107
|
}
|
|
6460
6108
|
};
|
|
6461
|
-
return
|
|
6462
|
-
|
|
6463
|
-
|
|
6109
|
+
return (params, callback) => {
|
|
6110
|
+
const channel = pusher.channel(params.channelName);
|
|
6111
|
+
const channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
|
|
6464
6112
|
channelAuthorizer.authorize(params.socketId, callback);
|
|
6465
6113
|
};
|
|
6466
6114
|
};
|
|
6467
6115
|
|
|
6468
6116
|
// CONCATENATED MODULE: ./src/core/config.ts
|
|
6469
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
6470
|
-
__assign = Object.assign || function(t) {
|
|
6471
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6472
|
-
s = arguments[i];
|
|
6473
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6474
|
-
t[p] = s[p];
|
|
6475
|
-
}
|
|
6476
|
-
return t;
|
|
6477
|
-
};
|
|
6478
|
-
return __assign.apply(this, arguments);
|
|
6479
|
-
};
|
|
6480
6117
|
|
|
6481
6118
|
|
|
6482
6119
|
|
|
6483
6120
|
|
|
6484
6121
|
|
|
6485
6122
|
function getConfig(opts, pusher) {
|
|
6486
|
-
|
|
6123
|
+
let config = {
|
|
6487
6124
|
activityTimeout: opts.activityTimeout || defaults.activityTimeout,
|
|
6488
6125
|
cluster: opts.cluster,
|
|
6489
6126
|
httpPath: opts.httpPath || defaults.httpPath,
|
|
@@ -6520,7 +6157,7 @@ function getHttpHost(opts) {
|
|
|
6520
6157
|
return opts.httpHost;
|
|
6521
6158
|
}
|
|
6522
6159
|
if (opts.cluster) {
|
|
6523
|
-
return
|
|
6160
|
+
return `sockjs-${opts.cluster}.pusher.com`;
|
|
6524
6161
|
}
|
|
6525
6162
|
return defaults.httpHost;
|
|
6526
6163
|
}
|
|
@@ -6531,7 +6168,7 @@ function getWebsocketHost(opts) {
|
|
|
6531
6168
|
return getWebsocketHostFromCluster(opts.cluster);
|
|
6532
6169
|
}
|
|
6533
6170
|
function getWebsocketHostFromCluster(cluster) {
|
|
6534
|
-
return
|
|
6171
|
+
return `ws-${cluster}.pusher.com`;
|
|
6535
6172
|
}
|
|
6536
6173
|
function shouldUseTLS(opts) {
|
|
6537
6174
|
if (worker_runtime.getProtocol() === 'https:') {
|
|
@@ -6552,7 +6189,7 @@ function getEnableStatsConfig(opts) {
|
|
|
6552
6189
|
return false;
|
|
6553
6190
|
}
|
|
6554
6191
|
function buildUserAuthenticator(opts) {
|
|
6555
|
-
|
|
6192
|
+
const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication);
|
|
6556
6193
|
if ('customHandler' in userAuthentication &&
|
|
6557
6194
|
userAuthentication['customHandler'] != null) {
|
|
6558
6195
|
return userAuthentication['customHandler'];
|
|
@@ -6560,9 +6197,9 @@ function buildUserAuthenticator(opts) {
|
|
|
6560
6197
|
return user_authenticator(userAuthentication);
|
|
6561
6198
|
}
|
|
6562
6199
|
function buildChannelAuth(opts, pusher) {
|
|
6563
|
-
|
|
6200
|
+
let channelAuthorization;
|
|
6564
6201
|
if ('channelAuthorization' in opts) {
|
|
6565
|
-
channelAuthorization =
|
|
6202
|
+
channelAuthorization = Object.assign(Object.assign({}, defaults.channelAuthorization), opts.channelAuthorization);
|
|
6566
6203
|
}
|
|
6567
6204
|
else {
|
|
6568
6205
|
channelAuthorization = {
|
|
@@ -6581,7 +6218,7 @@ function buildChannelAuth(opts, pusher) {
|
|
|
6581
6218
|
return channelAuthorization;
|
|
6582
6219
|
}
|
|
6583
6220
|
function buildChannelAuthorizer(opts, pusher) {
|
|
6584
|
-
|
|
6221
|
+
const channelAuthorization = buildChannelAuth(opts, pusher);
|
|
6585
6222
|
if ('customHandler' in channelAuthorization &&
|
|
6586
6223
|
channelAuthorization['customHandler'] != null) {
|
|
6587
6224
|
return channelAuthorization['customHandler'];
|
|
@@ -6590,134 +6227,99 @@ function buildChannelAuthorizer(opts, pusher) {
|
|
|
6590
6227
|
}
|
|
6591
6228
|
|
|
6592
6229
|
// CONCATENATED MODULE: ./src/core/watchlist.ts
|
|
6593
|
-
var watchlist_extends = (undefined && undefined.__extends) || (function () {
|
|
6594
|
-
var extendStatics = function (d, b) {
|
|
6595
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6596
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6597
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6598
|
-
return extendStatics(d, b);
|
|
6599
|
-
};
|
|
6600
|
-
return function (d, b) {
|
|
6601
|
-
extendStatics(d, b);
|
|
6602
|
-
function __() { this.constructor = d; }
|
|
6603
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6604
|
-
};
|
|
6605
|
-
})();
|
|
6606
6230
|
|
|
6607
6231
|
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
logger.debug("No callbacks on watchlist events for " + eventName);
|
|
6613
|
-
}) || this;
|
|
6614
|
-
_this.pusher = pusher;
|
|
6615
|
-
_this.bindWatchlistInternalEvent();
|
|
6616
|
-
return _this;
|
|
6617
|
-
}
|
|
6618
|
-
WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
|
|
6619
|
-
var _this = this;
|
|
6620
|
-
pusherEvent.data.events.forEach(function (watchlistEvent) {
|
|
6621
|
-
_this.emit(watchlistEvent.name, watchlistEvent);
|
|
6232
|
+
class watchlist_WatchlistFacade extends dispatcher_Dispatcher {
|
|
6233
|
+
constructor(pusher) {
|
|
6234
|
+
super(function (eventName, data) {
|
|
6235
|
+
logger.debug(`No callbacks on watchlist events for ${eventName}`);
|
|
6622
6236
|
});
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6237
|
+
this.pusher = pusher;
|
|
6238
|
+
this.bindWatchlistInternalEvent();
|
|
6239
|
+
}
|
|
6240
|
+
handleEvent(pusherEvent) {
|
|
6241
|
+
pusherEvent.data.events.forEach(watchlistEvent => {
|
|
6242
|
+
this.emit(watchlistEvent.name, watchlistEvent);
|
|
6243
|
+
});
|
|
6244
|
+
}
|
|
6245
|
+
bindWatchlistInternalEvent() {
|
|
6246
|
+
this.pusher.connection.bind('message', pusherEvent => {
|
|
6627
6247
|
var eventName = pusherEvent.event;
|
|
6628
6248
|
if (eventName === 'pusher_internal:watchlist_events') {
|
|
6629
|
-
|
|
6249
|
+
this.handleEvent(pusherEvent);
|
|
6630
6250
|
}
|
|
6631
6251
|
});
|
|
6632
|
-
}
|
|
6633
|
-
|
|
6634
|
-
}(dispatcher));
|
|
6635
|
-
/* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6636
6254
|
|
|
6637
6255
|
// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
|
|
6638
6256
|
function flatPromise() {
|
|
6639
|
-
|
|
6640
|
-
|
|
6257
|
+
let resolve, reject;
|
|
6258
|
+
const promise = new Promise((res, rej) => {
|
|
6641
6259
|
resolve = res;
|
|
6642
6260
|
reject = rej;
|
|
6643
6261
|
});
|
|
6644
|
-
return { promise
|
|
6262
|
+
return { promise, resolve, reject };
|
|
6645
6263
|
}
|
|
6646
6264
|
/* harmony default export */ var flat_promise = (flatPromise);
|
|
6647
6265
|
|
|
6648
6266
|
// CONCATENATED MODULE: ./src/core/user.ts
|
|
6649
|
-
var user_extends = (undefined && undefined.__extends) || (function () {
|
|
6650
|
-
var extendStatics = function (d, b) {
|
|
6651
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6652
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6653
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6654
|
-
return extendStatics(d, b);
|
|
6655
|
-
};
|
|
6656
|
-
return function (d, b) {
|
|
6657
|
-
extendStatics(d, b);
|
|
6658
|
-
function __() { this.constructor = d; }
|
|
6659
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6660
|
-
};
|
|
6661
|
-
})();
|
|
6662
6267
|
|
|
6663
6268
|
|
|
6664
6269
|
|
|
6665
6270
|
|
|
6666
6271
|
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
var _this = _super.call(this, function (eventName, data) {
|
|
6272
|
+
class user_UserFacade extends dispatcher_Dispatcher {
|
|
6273
|
+
constructor(pusher) {
|
|
6274
|
+
super(function (eventName, data) {
|
|
6671
6275
|
logger.debug('No callbacks on user for ' + eventName);
|
|
6672
|
-
})
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6276
|
+
});
|
|
6277
|
+
this.signin_requested = false;
|
|
6278
|
+
this.user_data = null;
|
|
6279
|
+
this.serverToUserChannel = null;
|
|
6280
|
+
this.signinDonePromise = null;
|
|
6281
|
+
this._signinDoneResolve = null;
|
|
6282
|
+
this._onAuthorize = (err, authData) => {
|
|
6679
6283
|
if (err) {
|
|
6680
|
-
logger.warn(
|
|
6681
|
-
|
|
6284
|
+
logger.warn(`Error during signin: ${err}`);
|
|
6285
|
+
this._cleanup();
|
|
6682
6286
|
return;
|
|
6683
6287
|
}
|
|
6684
|
-
|
|
6288
|
+
this.pusher.send_event('pusher:signin', {
|
|
6685
6289
|
auth: authData.auth,
|
|
6686
6290
|
user_data: authData.user_data
|
|
6687
6291
|
});
|
|
6688
6292
|
};
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
var previous = _a.previous, current = _a.current;
|
|
6293
|
+
this.pusher = pusher;
|
|
6294
|
+
this.pusher.connection.bind('state_change', ({ previous, current }) => {
|
|
6692
6295
|
if (previous !== 'connected' && current === 'connected') {
|
|
6693
|
-
|
|
6296
|
+
this._signin();
|
|
6694
6297
|
}
|
|
6695
6298
|
if (previous === 'connected' && current !== 'connected') {
|
|
6696
|
-
|
|
6697
|
-
|
|
6299
|
+
this._cleanup();
|
|
6300
|
+
this._newSigninPromiseIfNeeded();
|
|
6698
6301
|
}
|
|
6699
6302
|
});
|
|
6700
|
-
|
|
6701
|
-
|
|
6303
|
+
this.watchlist = new watchlist_WatchlistFacade(pusher);
|
|
6304
|
+
this.pusher.connection.bind('message', event => {
|
|
6702
6305
|
var eventName = event.event;
|
|
6703
6306
|
if (eventName === 'pusher:signin_success') {
|
|
6704
|
-
|
|
6307
|
+
this._onSigninSuccess(event.data);
|
|
6705
6308
|
}
|
|
6706
|
-
if (
|
|
6707
|
-
|
|
6708
|
-
|
|
6309
|
+
if (this.serverToUserChannel &&
|
|
6310
|
+
this.serverToUserChannel.name === event.channel) {
|
|
6311
|
+
this.serverToUserChannel.handleEvent(event);
|
|
6709
6312
|
}
|
|
6710
6313
|
});
|
|
6711
|
-
return _this;
|
|
6712
6314
|
}
|
|
6713
|
-
|
|
6315
|
+
signin() {
|
|
6714
6316
|
if (this.signin_requested) {
|
|
6715
6317
|
return;
|
|
6716
6318
|
}
|
|
6717
6319
|
this.signin_requested = true;
|
|
6718
6320
|
this._signin();
|
|
6719
|
-
}
|
|
6720
|
-
|
|
6321
|
+
}
|
|
6322
|
+
_signin() {
|
|
6721
6323
|
if (!this.signin_requested) {
|
|
6722
6324
|
return;
|
|
6723
6325
|
}
|
|
@@ -6728,46 +6330,45 @@ var user_UserFacade = (function (_super) {
|
|
|
6728
6330
|
this.pusher.config.userAuthenticator({
|
|
6729
6331
|
socketId: this.pusher.connection.socket_id
|
|
6730
6332
|
}, this._onAuthorize);
|
|
6731
|
-
}
|
|
6732
|
-
|
|
6333
|
+
}
|
|
6334
|
+
_onSigninSuccess(data) {
|
|
6733
6335
|
try {
|
|
6734
6336
|
this.user_data = JSON.parse(data.user_data);
|
|
6735
6337
|
}
|
|
6736
6338
|
catch (e) {
|
|
6737
|
-
logger.error(
|
|
6339
|
+
logger.error(`Failed parsing user data after signin: ${data.user_data}`);
|
|
6738
6340
|
this._cleanup();
|
|
6739
6341
|
return;
|
|
6740
6342
|
}
|
|
6741
6343
|
if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
|
|
6742
|
-
logger.error(
|
|
6344
|
+
logger.error(`user_data doesn't contain an id. user_data: ${this.user_data}`);
|
|
6743
6345
|
this._cleanup();
|
|
6744
6346
|
return;
|
|
6745
6347
|
}
|
|
6746
6348
|
this._signinDoneResolve();
|
|
6747
6349
|
this._subscribeChannels();
|
|
6748
|
-
}
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
var ensure_subscribed = function (channel) {
|
|
6350
|
+
}
|
|
6351
|
+
_subscribeChannels() {
|
|
6352
|
+
const ensure_subscribed = channel => {
|
|
6752
6353
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
6753
6354
|
channel.reinstateSubscription();
|
|
6754
6355
|
}
|
|
6755
6356
|
else if (!channel.subscriptionPending &&
|
|
6756
|
-
|
|
6357
|
+
this.pusher.connection.state === 'connected') {
|
|
6757
6358
|
channel.subscribe();
|
|
6758
6359
|
}
|
|
6759
6360
|
};
|
|
6760
|
-
this.serverToUserChannel = new
|
|
6761
|
-
this.serverToUserChannel.bind_global(
|
|
6361
|
+
this.serverToUserChannel = new channel_Channel(`#server-to-user-${this.user_data.id}`, this.pusher);
|
|
6362
|
+
this.serverToUserChannel.bind_global((eventName, data) => {
|
|
6762
6363
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
6763
6364
|
eventName.indexOf('pusher:') === 0) {
|
|
6764
6365
|
return;
|
|
6765
6366
|
}
|
|
6766
|
-
|
|
6367
|
+
this.emit(eventName, data);
|
|
6767
6368
|
});
|
|
6768
6369
|
ensure_subscribed(this.serverToUserChannel);
|
|
6769
|
-
}
|
|
6770
|
-
|
|
6370
|
+
}
|
|
6371
|
+
_cleanup() {
|
|
6771
6372
|
this.user_data = null;
|
|
6772
6373
|
if (this.serverToUserChannel) {
|
|
6773
6374
|
this.serverToUserChannel.unbind_all();
|
|
@@ -6777,26 +6378,24 @@ var user_UserFacade = (function (_super) {
|
|
|
6777
6378
|
if (this.signin_requested) {
|
|
6778
6379
|
this._signinDoneResolve();
|
|
6779
6380
|
}
|
|
6780
|
-
}
|
|
6781
|
-
|
|
6381
|
+
}
|
|
6382
|
+
_newSigninPromiseIfNeeded() {
|
|
6782
6383
|
if (!this.signin_requested) {
|
|
6783
6384
|
return;
|
|
6784
6385
|
}
|
|
6785
6386
|
if (this.signinDonePromise && !this.signinDonePromise.done) {
|
|
6786
6387
|
return;
|
|
6787
6388
|
}
|
|
6788
|
-
|
|
6389
|
+
const { promise, resolve, reject: _ } = flat_promise();
|
|
6789
6390
|
promise.done = false;
|
|
6790
|
-
|
|
6391
|
+
const setDone = () => {
|
|
6791
6392
|
promise.done = true;
|
|
6792
6393
|
};
|
|
6793
|
-
promise.then(setDone)
|
|
6394
|
+
promise.then(setDone).catch(setDone);
|
|
6794
6395
|
this.signinDonePromise = promise;
|
|
6795
6396
|
this._signinDoneResolve = resolve;
|
|
6796
|
-
}
|
|
6797
|
-
|
|
6798
|
-
}(dispatcher));
|
|
6799
|
-
/* harmony default export */ var user = (user_UserFacade);
|
|
6397
|
+
}
|
|
6398
|
+
}
|
|
6800
6399
|
|
|
6801
6400
|
// CONCATENATED MODULE: ./src/core/pusher.ts
|
|
6802
6401
|
|
|
@@ -6812,19 +6411,29 @@ var user_UserFacade = (function (_super) {
|
|
|
6812
6411
|
|
|
6813
6412
|
|
|
6814
6413
|
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6414
|
+
class pusher_Pusher {
|
|
6415
|
+
static ready() {
|
|
6416
|
+
pusher_Pusher.isReady = true;
|
|
6417
|
+
for (var i = 0, l = pusher_Pusher.instances.length; i < l; i++) {
|
|
6418
|
+
pusher_Pusher.instances[i].connect();
|
|
6419
|
+
}
|
|
6420
|
+
}
|
|
6421
|
+
static getClientFeatures() {
|
|
6422
|
+
return keys(filterObject({ ws: worker_runtime.Transports.ws }, function (t) {
|
|
6423
|
+
return t.isSupported({});
|
|
6424
|
+
}));
|
|
6425
|
+
}
|
|
6426
|
+
constructor(app_key, options) {
|
|
6818
6427
|
checkAppKey(app_key);
|
|
6819
6428
|
validateOptions(options);
|
|
6820
6429
|
this.key = app_key;
|
|
6821
6430
|
this.config = getConfig(options, this);
|
|
6822
6431
|
this.channels = factory.createChannels();
|
|
6823
|
-
this.global_emitter = new
|
|
6432
|
+
this.global_emitter = new dispatcher_Dispatcher();
|
|
6824
6433
|
this.sessionID = worker_runtime.randomInt(1000000000);
|
|
6825
|
-
this.timeline = new
|
|
6434
|
+
this.timeline = new timeline_Timeline(this.key, this.sessionID, {
|
|
6826
6435
|
cluster: this.config.cluster,
|
|
6827
|
-
features:
|
|
6436
|
+
features: pusher_Pusher.getClientFeatures(),
|
|
6828
6437
|
params: this.config.timelineParams || {},
|
|
6829
6438
|
limit: 50,
|
|
6830
6439
|
level: timeline_level.INFO,
|
|
@@ -6836,8 +6445,8 @@ var pusher_Pusher = (function () {
|
|
|
6836
6445
|
path: '/timeline/v2/' + worker_runtime.TimelineTransport.name
|
|
6837
6446
|
});
|
|
6838
6447
|
}
|
|
6839
|
-
var getStrategy =
|
|
6840
|
-
return worker_runtime.getDefaultStrategy(
|
|
6448
|
+
var getStrategy = (options) => {
|
|
6449
|
+
return worker_runtime.getDefaultStrategy(this.config, options, strategy_builder_defineTransport);
|
|
6841
6450
|
};
|
|
6842
6451
|
this.connection = factory.createConnectionManager(this.key, {
|
|
6843
6452
|
getStrategy: getStrategy,
|
|
@@ -6847,106 +6456,95 @@ var pusher_Pusher = (function () {
|
|
|
6847
6456
|
unavailableTimeout: this.config.unavailableTimeout,
|
|
6848
6457
|
useTLS: Boolean(this.config.useTLS)
|
|
6849
6458
|
});
|
|
6850
|
-
this.connection.bind('connected',
|
|
6851
|
-
|
|
6852
|
-
if (
|
|
6853
|
-
|
|
6459
|
+
this.connection.bind('connected', () => {
|
|
6460
|
+
this.subscribeAll();
|
|
6461
|
+
if (this.timelineSender) {
|
|
6462
|
+
this.timelineSender.send(this.connection.isUsingTLS());
|
|
6854
6463
|
}
|
|
6855
6464
|
});
|
|
6856
|
-
this.connection.bind('message',
|
|
6465
|
+
this.connection.bind('message', event => {
|
|
6857
6466
|
var eventName = event.event;
|
|
6858
6467
|
var internal = eventName.indexOf('pusher_internal:') === 0;
|
|
6859
6468
|
if (event.channel) {
|
|
6860
|
-
var channel =
|
|
6469
|
+
var channel = this.channel(event.channel);
|
|
6861
6470
|
if (channel) {
|
|
6862
6471
|
channel.handleEvent(event);
|
|
6863
6472
|
}
|
|
6864
6473
|
}
|
|
6865
6474
|
if (!internal) {
|
|
6866
|
-
|
|
6475
|
+
this.global_emitter.emit(event.event, event.data);
|
|
6867
6476
|
}
|
|
6868
6477
|
});
|
|
6869
|
-
this.connection.bind('connecting',
|
|
6870
|
-
|
|
6478
|
+
this.connection.bind('connecting', () => {
|
|
6479
|
+
this.channels.disconnect();
|
|
6871
6480
|
});
|
|
6872
|
-
this.connection.bind('disconnected',
|
|
6873
|
-
|
|
6481
|
+
this.connection.bind('disconnected', () => {
|
|
6482
|
+
this.channels.disconnect();
|
|
6874
6483
|
});
|
|
6875
|
-
this.connection.bind('error',
|
|
6484
|
+
this.connection.bind('error', err => {
|
|
6876
6485
|
logger.warn(err);
|
|
6877
6486
|
});
|
|
6878
|
-
|
|
6879
|
-
this.timeline.info({ instances:
|
|
6880
|
-
this.user = new
|
|
6881
|
-
if (
|
|
6487
|
+
pusher_Pusher.instances.push(this);
|
|
6488
|
+
this.timeline.info({ instances: pusher_Pusher.instances.length });
|
|
6489
|
+
this.user = new user_UserFacade(this);
|
|
6490
|
+
if (pusher_Pusher.isReady) {
|
|
6882
6491
|
this.connect();
|
|
6883
6492
|
}
|
|
6884
6493
|
}
|
|
6885
|
-
|
|
6886
|
-
Pusher.isReady = true;
|
|
6887
|
-
for (var i = 0, l = Pusher.instances.length; i < l; i++) {
|
|
6888
|
-
Pusher.instances[i].connect();
|
|
6889
|
-
}
|
|
6890
|
-
};
|
|
6891
|
-
Pusher.getClientFeatures = function () {
|
|
6892
|
-
return keys(filterObject({ ws: worker_runtime.Transports.ws }, function (t) {
|
|
6893
|
-
return t.isSupported({});
|
|
6894
|
-
}));
|
|
6895
|
-
};
|
|
6896
|
-
Pusher.prototype.channel = function (name) {
|
|
6494
|
+
channel(name) {
|
|
6897
6495
|
return this.channels.find(name);
|
|
6898
|
-
}
|
|
6899
|
-
|
|
6496
|
+
}
|
|
6497
|
+
allChannels() {
|
|
6900
6498
|
return this.channels.all();
|
|
6901
|
-
}
|
|
6902
|
-
|
|
6499
|
+
}
|
|
6500
|
+
connect() {
|
|
6903
6501
|
this.connection.connect();
|
|
6904
6502
|
if (this.timelineSender) {
|
|
6905
6503
|
if (!this.timelineSenderTimer) {
|
|
6906
6504
|
var usingTLS = this.connection.isUsingTLS();
|
|
6907
6505
|
var timelineSender = this.timelineSender;
|
|
6908
|
-
this.timelineSenderTimer = new
|
|
6506
|
+
this.timelineSenderTimer = new timers_PeriodicTimer(60000, function () {
|
|
6909
6507
|
timelineSender.send(usingTLS);
|
|
6910
6508
|
});
|
|
6911
6509
|
}
|
|
6912
6510
|
}
|
|
6913
|
-
}
|
|
6914
|
-
|
|
6511
|
+
}
|
|
6512
|
+
disconnect() {
|
|
6915
6513
|
this.connection.disconnect();
|
|
6916
6514
|
if (this.timelineSenderTimer) {
|
|
6917
6515
|
this.timelineSenderTimer.ensureAborted();
|
|
6918
6516
|
this.timelineSenderTimer = null;
|
|
6919
6517
|
}
|
|
6920
|
-
}
|
|
6921
|
-
|
|
6518
|
+
}
|
|
6519
|
+
bind(event_name, callback, context) {
|
|
6922
6520
|
this.global_emitter.bind(event_name, callback, context);
|
|
6923
6521
|
return this;
|
|
6924
|
-
}
|
|
6925
|
-
|
|
6522
|
+
}
|
|
6523
|
+
unbind(event_name, callback, context) {
|
|
6926
6524
|
this.global_emitter.unbind(event_name, callback, context);
|
|
6927
6525
|
return this;
|
|
6928
|
-
}
|
|
6929
|
-
|
|
6526
|
+
}
|
|
6527
|
+
bind_global(callback) {
|
|
6930
6528
|
this.global_emitter.bind_global(callback);
|
|
6931
6529
|
return this;
|
|
6932
|
-
}
|
|
6933
|
-
|
|
6530
|
+
}
|
|
6531
|
+
unbind_global(callback) {
|
|
6934
6532
|
this.global_emitter.unbind_global(callback);
|
|
6935
6533
|
return this;
|
|
6936
|
-
}
|
|
6937
|
-
|
|
6534
|
+
}
|
|
6535
|
+
unbind_all(callback) {
|
|
6938
6536
|
this.global_emitter.unbind_all();
|
|
6939
6537
|
return this;
|
|
6940
|
-
}
|
|
6941
|
-
|
|
6538
|
+
}
|
|
6539
|
+
subscribeAll() {
|
|
6942
6540
|
var channelName;
|
|
6943
6541
|
for (channelName in this.channels.channels) {
|
|
6944
6542
|
if (this.channels.channels.hasOwnProperty(channelName)) {
|
|
6945
6543
|
this.subscribe(channelName);
|
|
6946
6544
|
}
|
|
6947
6545
|
}
|
|
6948
|
-
}
|
|
6949
|
-
|
|
6546
|
+
}
|
|
6547
|
+
subscribe(channel_name) {
|
|
6950
6548
|
var channel = this.channels.add(channel_name, this);
|
|
6951
6549
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
6952
6550
|
channel.reinstateSubscription();
|
|
@@ -6956,8 +6554,8 @@ var pusher_Pusher = (function () {
|
|
|
6956
6554
|
channel.subscribe();
|
|
6957
6555
|
}
|
|
6958
6556
|
return channel;
|
|
6959
|
-
}
|
|
6960
|
-
|
|
6557
|
+
}
|
|
6558
|
+
unsubscribe(channel_name) {
|
|
6961
6559
|
var channel = this.channels.find(channel_name);
|
|
6962
6560
|
if (channel && channel.subscriptionPending) {
|
|
6963
6561
|
channel.cancelSubscription();
|
|
@@ -6968,25 +6566,24 @@ var pusher_Pusher = (function () {
|
|
|
6968
6566
|
channel.unsubscribe();
|
|
6969
6567
|
}
|
|
6970
6568
|
}
|
|
6971
|
-
}
|
|
6972
|
-
|
|
6569
|
+
}
|
|
6570
|
+
send_event(event_name, data, channel) {
|
|
6973
6571
|
return this.connection.send_event(event_name, data, channel);
|
|
6974
|
-
}
|
|
6975
|
-
|
|
6572
|
+
}
|
|
6573
|
+
shouldUseTLS() {
|
|
6976
6574
|
return this.config.useTLS;
|
|
6977
|
-
}
|
|
6978
|
-
|
|
6575
|
+
}
|
|
6576
|
+
signin() {
|
|
6979
6577
|
this.user.signin();
|
|
6980
|
-
}
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
}());
|
|
6578
|
+
}
|
|
6579
|
+
}
|
|
6580
|
+
pusher_Pusher.instances = [];
|
|
6581
|
+
pusher_Pusher.isReady = false;
|
|
6582
|
+
pusher_Pusher.logToConsole = false;
|
|
6583
|
+
pusher_Pusher.Runtime = worker_runtime;
|
|
6584
|
+
pusher_Pusher.ScriptReceivers = worker_runtime.ScriptReceivers;
|
|
6585
|
+
pusher_Pusher.DependenciesReceivers = worker_runtime.DependenciesReceivers;
|
|
6586
|
+
pusher_Pusher.auth_callbacks = worker_runtime.auth_callbacks;
|
|
6990
6587
|
/* harmony default export */ var core_pusher = (pusher_Pusher);
|
|
6991
6588
|
function checkAppKey(key) {
|
|
6992
6589
|
if (key === null || key === undefined) {
|
|
@@ -6999,36 +6596,18 @@ worker_runtime.setup(pusher_Pusher);
|
|
|
6999
6596
|
var nacl_fast = __webpack_require__(2);
|
|
7000
6597
|
|
|
7001
6598
|
// CONCATENATED MODULE: ./src/core/pusher-with-encryption.ts
|
|
7002
|
-
var pusher_with_encryption_extends = (undefined && undefined.__extends) || (function () {
|
|
7003
|
-
var extendStatics = function (d, b) {
|
|
7004
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7005
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7006
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7007
|
-
return extendStatics(d, b);
|
|
7008
|
-
};
|
|
7009
|
-
return function (d, b) {
|
|
7010
|
-
extendStatics(d, b);
|
|
7011
|
-
function __() { this.constructor = d; }
|
|
7012
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7013
|
-
};
|
|
7014
|
-
})();
|
|
7015
6599
|
|
|
7016
6600
|
|
|
7017
6601
|
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
core_pusher.logToConsole = PusherWithEncryption.logToConsole;
|
|
7023
|
-
core_pusher.log = PusherWithEncryption.log;
|
|
6602
|
+
class pusher_with_encryption_PusherWithEncryption extends core_pusher {
|
|
6603
|
+
constructor(app_key, options) {
|
|
6604
|
+
core_pusher.logToConsole = pusher_with_encryption_PusherWithEncryption.logToConsole;
|
|
6605
|
+
core_pusher.log = pusher_with_encryption_PusherWithEncryption.log;
|
|
7024
6606
|
validateOptions(options);
|
|
7025
6607
|
options.nacl = nacl_fast;
|
|
7026
|
-
|
|
7027
|
-
return _this;
|
|
6608
|
+
super(app_key, options);
|
|
7028
6609
|
}
|
|
7029
|
-
|
|
7030
|
-
}(core_pusher));
|
|
7031
|
-
/* harmony default export */ var pusher_with_encryption = __webpack_exports__["default"] = (pusher_with_encryption_PusherWithEncryption);
|
|
6610
|
+
}
|
|
7032
6611
|
|
|
7033
6612
|
|
|
7034
6613
|
/***/ })
|