pusher-js 8.0.2 → 8.2.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 +9 -0
- package/dist/node/pusher.js +968 -1391
- 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 -1434
- 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 -1410
- 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 -1390
- 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 -1366
- 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/src/runtimes/isomorphic/default_strategy.ts +0 -1
- package/src/runtimes/web/default_strategy.ts +0 -1
- 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
package/dist/node/pusher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v8.0
|
|
2
|
+
* Pusher JavaScript Library v8.2.0
|
|
3
3
|
* https://pusher.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020, Pusher
|
|
@@ -7189,6 +7189,9 @@ module.exports = require("https");
|
|
|
7189
7189
|
// ESM COMPAT FLAG
|
|
7190
7190
|
__webpack_require__.r(__webpack_exports__);
|
|
7191
7191
|
|
|
7192
|
+
// EXPORTS
|
|
7193
|
+
__webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ pusher_with_encryption_PusherWithEncryption; });
|
|
7194
|
+
|
|
7192
7195
|
// CONCATENATED MODULE: ./src/core/base64.ts
|
|
7193
7196
|
function encode(s) {
|
|
7194
7197
|
return btoa(utob(s));
|
|
@@ -7231,43 +7234,28 @@ var btoa = global.btoa ||
|
|
|
7231
7234
|
};
|
|
7232
7235
|
|
|
7233
7236
|
// CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
var _this = this;
|
|
7237
|
+
class Timer {
|
|
7238
|
+
constructor(set, clear, delay, callback) {
|
|
7237
7239
|
this.clear = clear;
|
|
7238
|
-
this.timer = set(
|
|
7239
|
-
if (
|
|
7240
|
-
|
|
7240
|
+
this.timer = set(() => {
|
|
7241
|
+
if (this.timer) {
|
|
7242
|
+
this.timer = callback(this.timer);
|
|
7241
7243
|
}
|
|
7242
7244
|
}, delay);
|
|
7243
7245
|
}
|
|
7244
|
-
|
|
7246
|
+
isRunning() {
|
|
7245
7247
|
return this.timer !== null;
|
|
7246
|
-
}
|
|
7247
|
-
|
|
7248
|
+
}
|
|
7249
|
+
ensureAborted() {
|
|
7248
7250
|
if (this.timer) {
|
|
7249
7251
|
this.clear(this.timer);
|
|
7250
7252
|
this.timer = null;
|
|
7251
7253
|
}
|
|
7252
|
-
}
|
|
7253
|
-
|
|
7254
|
-
}());
|
|
7254
|
+
}
|
|
7255
|
+
}
|
|
7255
7256
|
/* harmony default export */ var abstract_timer = (Timer);
|
|
7256
7257
|
|
|
7257
7258
|
// CONCATENATED MODULE: ./src/core/utils/timers/index.ts
|
|
7258
|
-
var __extends = (undefined && undefined.__extends) || (function () {
|
|
7259
|
-
var extendStatics = function (d, b) {
|
|
7260
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7261
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7262
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7263
|
-
return extendStatics(d, b);
|
|
7264
|
-
};
|
|
7265
|
-
return function (d, b) {
|
|
7266
|
-
extendStatics(d, b);
|
|
7267
|
-
function __() { this.constructor = d; }
|
|
7268
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7269
|
-
};
|
|
7270
|
-
})();
|
|
7271
7259
|
|
|
7272
7260
|
function timers_clearTimeout(timer) {
|
|
7273
7261
|
global.clearTimeout(timer);
|
|
@@ -7275,33 +7263,27 @@ function timers_clearTimeout(timer) {
|
|
|
7275
7263
|
function timers_clearInterval(timer) {
|
|
7276
7264
|
global.clearInterval(timer);
|
|
7277
7265
|
}
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
7266
|
+
class timers_OneOffTimer extends abstract_timer {
|
|
7267
|
+
constructor(delay, callback) {
|
|
7268
|
+
super(setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
7282
7269
|
callback();
|
|
7283
7270
|
return null;
|
|
7284
|
-
})
|
|
7271
|
+
});
|
|
7285
7272
|
}
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
__extends(PeriodicTimer, _super);
|
|
7291
|
-
function PeriodicTimer(delay, callback) {
|
|
7292
|
-
return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
|
|
7273
|
+
}
|
|
7274
|
+
class timers_PeriodicTimer extends abstract_timer {
|
|
7275
|
+
constructor(delay, callback) {
|
|
7276
|
+
super(setInterval, timers_clearInterval, delay, function (timer) {
|
|
7293
7277
|
callback();
|
|
7294
7278
|
return timer;
|
|
7295
|
-
})
|
|
7279
|
+
});
|
|
7296
7280
|
}
|
|
7297
|
-
|
|
7298
|
-
}(abstract_timer));
|
|
7299
|
-
|
|
7281
|
+
}
|
|
7300
7282
|
|
|
7301
7283
|
// CONCATENATED MODULE: ./src/core/util.ts
|
|
7302
7284
|
|
|
7303
7285
|
var Util = {
|
|
7304
|
-
now
|
|
7286
|
+
now() {
|
|
7305
7287
|
if (Date.now) {
|
|
7306
7288
|
return Date.now();
|
|
7307
7289
|
}
|
|
@@ -7309,14 +7291,10 @@ var Util = {
|
|
|
7309
7291
|
return new Date().valueOf();
|
|
7310
7292
|
}
|
|
7311
7293
|
},
|
|
7312
|
-
defer
|
|
7313
|
-
return new
|
|
7294
|
+
defer(callback) {
|
|
7295
|
+
return new timers_OneOffTimer(0, callback);
|
|
7314
7296
|
},
|
|
7315
|
-
method
|
|
7316
|
-
var args = [];
|
|
7317
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7318
|
-
args[_i - 1] = arguments[_i];
|
|
7319
|
-
}
|
|
7297
|
+
method(name, ...args) {
|
|
7320
7298
|
var boundArguments = Array.prototype.slice.call(arguments, 1);
|
|
7321
7299
|
return function (object) {
|
|
7322
7300
|
return object[name].apply(object, boundArguments.concat(arguments));
|
|
@@ -7328,11 +7306,7 @@ var Util = {
|
|
|
7328
7306
|
// CONCATENATED MODULE: ./src/core/utils/collections.ts
|
|
7329
7307
|
|
|
7330
7308
|
|
|
7331
|
-
function extend(target) {
|
|
7332
|
-
var sources = [];
|
|
7333
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7334
|
-
sources[_i - 1] = arguments[_i];
|
|
7335
|
-
}
|
|
7309
|
+
function extend(target, ...sources) {
|
|
7336
7310
|
for (var i = 0; i < sources.length; i++) {
|
|
7337
7311
|
var extensions = sources[i];
|
|
7338
7312
|
for (var property in extensions) {
|
|
@@ -7525,7 +7499,7 @@ function safeJSONStringify(source) {
|
|
|
7525
7499
|
|
|
7526
7500
|
// CONCATENATED MODULE: ./src/core/defaults.ts
|
|
7527
7501
|
var Defaults = {
|
|
7528
|
-
VERSION: "8.0
|
|
7502
|
+
VERSION: "8.2.0",
|
|
7529
7503
|
PROTOCOL: 7,
|
|
7530
7504
|
wsPort: 80,
|
|
7531
7505
|
wssPort: 443,
|
|
@@ -7594,14 +7568,14 @@ var sockjs = {
|
|
|
7594
7568
|
|
|
7595
7569
|
// CONCATENATED MODULE: ./src/core/events/callback_registry.ts
|
|
7596
7570
|
|
|
7597
|
-
|
|
7598
|
-
|
|
7571
|
+
class callback_registry_CallbackRegistry {
|
|
7572
|
+
constructor() {
|
|
7599
7573
|
this._callbacks = {};
|
|
7600
7574
|
}
|
|
7601
|
-
|
|
7575
|
+
get(name) {
|
|
7602
7576
|
return this._callbacks[prefix(name)];
|
|
7603
|
-
}
|
|
7604
|
-
|
|
7577
|
+
}
|
|
7578
|
+
add(name, callback, context) {
|
|
7605
7579
|
var prefixedEventName = prefix(name);
|
|
7606
7580
|
this._callbacks[prefixedEventName] =
|
|
7607
7581
|
this._callbacks[prefixedEventName] || [];
|
|
@@ -7609,8 +7583,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
7609
7583
|
fn: callback,
|
|
7610
7584
|
context: context
|
|
7611
7585
|
});
|
|
7612
|
-
}
|
|
7613
|
-
|
|
7586
|
+
}
|
|
7587
|
+
remove(name, callback, context) {
|
|
7614
7588
|
if (!name && !callback && !context) {
|
|
7615
7589
|
this._callbacks = {};
|
|
7616
7590
|
return;
|
|
@@ -7622,8 +7596,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
7622
7596
|
else {
|
|
7623
7597
|
this.removeAllCallbacks(names);
|
|
7624
7598
|
}
|
|
7625
|
-
}
|
|
7626
|
-
|
|
7599
|
+
}
|
|
7600
|
+
removeCallback(names, callback, context) {
|
|
7627
7601
|
apply(names, function (name) {
|
|
7628
7602
|
this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
|
|
7629
7603
|
return ((callback && callback !== binding.fn) ||
|
|
@@ -7633,15 +7607,13 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
7633
7607
|
delete this._callbacks[name];
|
|
7634
7608
|
}
|
|
7635
7609
|
}, this);
|
|
7636
|
-
}
|
|
7637
|
-
|
|
7610
|
+
}
|
|
7611
|
+
removeAllCallbacks(names) {
|
|
7638
7612
|
apply(names, function (name) {
|
|
7639
7613
|
delete this._callbacks[name];
|
|
7640
7614
|
}, this);
|
|
7641
|
-
}
|
|
7642
|
-
|
|
7643
|
-
}());
|
|
7644
|
-
/* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
|
|
7615
|
+
}
|
|
7616
|
+
}
|
|
7645
7617
|
function prefix(name) {
|
|
7646
7618
|
return '_' + name;
|
|
7647
7619
|
}
|
|
@@ -7649,38 +7621,38 @@ function prefix(name) {
|
|
|
7649
7621
|
// CONCATENATED MODULE: ./src/core/events/dispatcher.ts
|
|
7650
7622
|
|
|
7651
7623
|
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
this.callbacks = new
|
|
7624
|
+
class dispatcher_Dispatcher {
|
|
7625
|
+
constructor(failThrough) {
|
|
7626
|
+
this.callbacks = new callback_registry_CallbackRegistry();
|
|
7655
7627
|
this.global_callbacks = [];
|
|
7656
7628
|
this.failThrough = failThrough;
|
|
7657
7629
|
}
|
|
7658
|
-
|
|
7630
|
+
bind(eventName, callback, context) {
|
|
7659
7631
|
this.callbacks.add(eventName, callback, context);
|
|
7660
7632
|
return this;
|
|
7661
|
-
}
|
|
7662
|
-
|
|
7633
|
+
}
|
|
7634
|
+
bind_global(callback) {
|
|
7663
7635
|
this.global_callbacks.push(callback);
|
|
7664
7636
|
return this;
|
|
7665
|
-
}
|
|
7666
|
-
|
|
7637
|
+
}
|
|
7638
|
+
unbind(eventName, callback, context) {
|
|
7667
7639
|
this.callbacks.remove(eventName, callback, context);
|
|
7668
7640
|
return this;
|
|
7669
|
-
}
|
|
7670
|
-
|
|
7641
|
+
}
|
|
7642
|
+
unbind_global(callback) {
|
|
7671
7643
|
if (!callback) {
|
|
7672
7644
|
this.global_callbacks = [];
|
|
7673
7645
|
return this;
|
|
7674
7646
|
}
|
|
7675
|
-
this.global_callbacks = filter(this.global_callbacks || [],
|
|
7647
|
+
this.global_callbacks = filter(this.global_callbacks || [], c => c !== callback);
|
|
7676
7648
|
return this;
|
|
7677
|
-
}
|
|
7678
|
-
|
|
7649
|
+
}
|
|
7650
|
+
unbind_all() {
|
|
7679
7651
|
this.unbind();
|
|
7680
7652
|
this.unbind_global();
|
|
7681
7653
|
return this;
|
|
7682
|
-
}
|
|
7683
|
-
|
|
7654
|
+
}
|
|
7655
|
+
emit(eventName, data, metadata) {
|
|
7684
7656
|
for (var i = 0; i < this.global_callbacks.length; i++) {
|
|
7685
7657
|
this.global_callbacks[i](eventName, data);
|
|
7686
7658
|
}
|
|
@@ -7701,120 +7673,85 @@ var dispatcher_Dispatcher = (function () {
|
|
|
7701
7673
|
this.failThrough(eventName, data);
|
|
7702
7674
|
}
|
|
7703
7675
|
return this;
|
|
7704
|
-
}
|
|
7705
|
-
|
|
7706
|
-
}());
|
|
7707
|
-
/* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7708
7678
|
|
|
7709
7679
|
// CONCATENATED MODULE: ./src/core/logger.ts
|
|
7710
7680
|
|
|
7711
7681
|
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
this.globalLog =
|
|
7682
|
+
class logger_Logger {
|
|
7683
|
+
constructor() {
|
|
7684
|
+
this.globalLog = (message) => {
|
|
7715
7685
|
if (global.console && global.console.log) {
|
|
7716
7686
|
global.console.log(message);
|
|
7717
7687
|
}
|
|
7718
7688
|
};
|
|
7719
7689
|
}
|
|
7720
|
-
|
|
7721
|
-
var args = [];
|
|
7722
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7723
|
-
args[_i] = arguments[_i];
|
|
7724
|
-
}
|
|
7690
|
+
debug(...args) {
|
|
7725
7691
|
this.log(this.globalLog, args);
|
|
7726
|
-
}
|
|
7727
|
-
|
|
7728
|
-
var args = [];
|
|
7729
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7730
|
-
args[_i] = arguments[_i];
|
|
7731
|
-
}
|
|
7692
|
+
}
|
|
7693
|
+
warn(...args) {
|
|
7732
7694
|
this.log(this.globalLogWarn, args);
|
|
7733
|
-
}
|
|
7734
|
-
|
|
7735
|
-
var args = [];
|
|
7736
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7737
|
-
args[_i] = arguments[_i];
|
|
7738
|
-
}
|
|
7695
|
+
}
|
|
7696
|
+
error(...args) {
|
|
7739
7697
|
this.log(this.globalLogError, args);
|
|
7740
|
-
}
|
|
7741
|
-
|
|
7698
|
+
}
|
|
7699
|
+
globalLogWarn(message) {
|
|
7742
7700
|
if (global.console && global.console.warn) {
|
|
7743
7701
|
global.console.warn(message);
|
|
7744
7702
|
}
|
|
7745
7703
|
else {
|
|
7746
7704
|
this.globalLog(message);
|
|
7747
7705
|
}
|
|
7748
|
-
}
|
|
7749
|
-
|
|
7706
|
+
}
|
|
7707
|
+
globalLogError(message) {
|
|
7750
7708
|
if (global.console && global.console.error) {
|
|
7751
7709
|
global.console.error(message);
|
|
7752
7710
|
}
|
|
7753
7711
|
else {
|
|
7754
7712
|
this.globalLogWarn(message);
|
|
7755
7713
|
}
|
|
7756
|
-
}
|
|
7757
|
-
|
|
7758
|
-
var args = [];
|
|
7759
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7760
|
-
args[_i - 1] = arguments[_i];
|
|
7761
|
-
}
|
|
7714
|
+
}
|
|
7715
|
+
log(defaultLoggingFunction, ...args) {
|
|
7762
7716
|
var message = stringify.apply(this, arguments);
|
|
7763
7717
|
if (core_pusher.log) {
|
|
7764
7718
|
core_pusher.log(message);
|
|
7765
7719
|
}
|
|
7766
7720
|
else if (core_pusher.logToConsole) {
|
|
7767
|
-
|
|
7721
|
+
const log = defaultLoggingFunction.bind(this);
|
|
7768
7722
|
log(message);
|
|
7769
7723
|
}
|
|
7770
|
-
}
|
|
7771
|
-
|
|
7772
|
-
}());
|
|
7724
|
+
}
|
|
7725
|
+
}
|
|
7773
7726
|
/* harmony default export */ var logger = (new logger_Logger());
|
|
7774
7727
|
|
|
7775
7728
|
// CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
|
|
7776
|
-
var transport_connection_extends = (undefined && undefined.__extends) || (function () {
|
|
7777
|
-
var extendStatics = function (d, b) {
|
|
7778
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7779
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7780
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7781
|
-
return extendStatics(d, b);
|
|
7782
|
-
};
|
|
7783
|
-
return function (d, b) {
|
|
7784
|
-
extendStatics(d, b);
|
|
7785
|
-
function __() { this.constructor = d; }
|
|
7786
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7787
|
-
};
|
|
7788
|
-
})();
|
|
7789
7729
|
|
|
7790
7730
|
|
|
7791
7731
|
|
|
7792
7732
|
|
|
7793
7733
|
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
_this.id = _this.timeline.generateUniqueID();
|
|
7808
|
-
return _this;
|
|
7734
|
+
class transport_connection_TransportConnection extends dispatcher_Dispatcher {
|
|
7735
|
+
constructor(hooks, name, priority, key, options) {
|
|
7736
|
+
super();
|
|
7737
|
+
this.initialize = node_runtime.transportConnectionInitializer;
|
|
7738
|
+
this.hooks = hooks;
|
|
7739
|
+
this.name = name;
|
|
7740
|
+
this.priority = priority;
|
|
7741
|
+
this.key = key;
|
|
7742
|
+
this.options = options;
|
|
7743
|
+
this.state = 'new';
|
|
7744
|
+
this.timeline = options.timeline;
|
|
7745
|
+
this.activityTimeout = options.activityTimeout;
|
|
7746
|
+
this.id = this.timeline.generateUniqueID();
|
|
7809
7747
|
}
|
|
7810
|
-
|
|
7748
|
+
handlesActivityChecks() {
|
|
7811
7749
|
return Boolean(this.hooks.handlesActivityChecks);
|
|
7812
|
-
}
|
|
7813
|
-
|
|
7750
|
+
}
|
|
7751
|
+
supportsPing() {
|
|
7814
7752
|
return Boolean(this.hooks.supportsPing);
|
|
7815
|
-
}
|
|
7816
|
-
|
|
7817
|
-
var _this = this;
|
|
7753
|
+
}
|
|
7754
|
+
connect() {
|
|
7818
7755
|
if (this.socket || this.state !== 'initialized') {
|
|
7819
7756
|
return false;
|
|
7820
7757
|
}
|
|
@@ -7823,18 +7760,18 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
7823
7760
|
this.socket = this.hooks.getSocket(url, this.options);
|
|
7824
7761
|
}
|
|
7825
7762
|
catch (e) {
|
|
7826
|
-
util.defer(
|
|
7827
|
-
|
|
7828
|
-
|
|
7763
|
+
util.defer(() => {
|
|
7764
|
+
this.onError(e);
|
|
7765
|
+
this.changeState('closed');
|
|
7829
7766
|
});
|
|
7830
7767
|
return false;
|
|
7831
7768
|
}
|
|
7832
7769
|
this.bindListeners();
|
|
7833
|
-
logger.debug('Connecting', { transport: this.name, url
|
|
7770
|
+
logger.debug('Connecting', { transport: this.name, url });
|
|
7834
7771
|
this.changeState('connecting');
|
|
7835
7772
|
return true;
|
|
7836
|
-
}
|
|
7837
|
-
|
|
7773
|
+
}
|
|
7774
|
+
close() {
|
|
7838
7775
|
if (this.socket) {
|
|
7839
7776
|
this.socket.close();
|
|
7840
7777
|
return true;
|
|
@@ -7842,13 +7779,12 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
7842
7779
|
else {
|
|
7843
7780
|
return false;
|
|
7844
7781
|
}
|
|
7845
|
-
}
|
|
7846
|
-
|
|
7847
|
-
var _this = this;
|
|
7782
|
+
}
|
|
7783
|
+
send(data) {
|
|
7848
7784
|
if (this.state === 'open') {
|
|
7849
|
-
util.defer(
|
|
7850
|
-
if (
|
|
7851
|
-
|
|
7785
|
+
util.defer(() => {
|
|
7786
|
+
if (this.socket) {
|
|
7787
|
+
this.socket.send(data);
|
|
7852
7788
|
}
|
|
7853
7789
|
});
|
|
7854
7790
|
return true;
|
|
@@ -7856,24 +7792,24 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
7856
7792
|
else {
|
|
7857
7793
|
return false;
|
|
7858
7794
|
}
|
|
7859
|
-
}
|
|
7860
|
-
|
|
7795
|
+
}
|
|
7796
|
+
ping() {
|
|
7861
7797
|
if (this.state === 'open' && this.supportsPing()) {
|
|
7862
7798
|
this.socket.ping();
|
|
7863
7799
|
}
|
|
7864
|
-
}
|
|
7865
|
-
|
|
7800
|
+
}
|
|
7801
|
+
onOpen() {
|
|
7866
7802
|
if (this.hooks.beforeOpen) {
|
|
7867
7803
|
this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
|
|
7868
7804
|
}
|
|
7869
7805
|
this.changeState('open');
|
|
7870
7806
|
this.socket.onopen = undefined;
|
|
7871
|
-
}
|
|
7872
|
-
|
|
7807
|
+
}
|
|
7808
|
+
onError(error) {
|
|
7873
7809
|
this.emit('error', { type: 'WebSocketError', error: error });
|
|
7874
7810
|
this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
|
|
7875
|
-
}
|
|
7876
|
-
|
|
7811
|
+
}
|
|
7812
|
+
onClose(closeEvent) {
|
|
7877
7813
|
if (closeEvent) {
|
|
7878
7814
|
this.changeState('closed', {
|
|
7879
7815
|
code: closeEvent.code,
|
|
@@ -7886,34 +7822,33 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
7886
7822
|
}
|
|
7887
7823
|
this.unbindListeners();
|
|
7888
7824
|
this.socket = undefined;
|
|
7889
|
-
}
|
|
7890
|
-
|
|
7825
|
+
}
|
|
7826
|
+
onMessage(message) {
|
|
7891
7827
|
this.emit('message', message);
|
|
7892
|
-
}
|
|
7893
|
-
|
|
7828
|
+
}
|
|
7829
|
+
onActivity() {
|
|
7894
7830
|
this.emit('activity');
|
|
7895
|
-
}
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
_this.onOpen();
|
|
7831
|
+
}
|
|
7832
|
+
bindListeners() {
|
|
7833
|
+
this.socket.onopen = () => {
|
|
7834
|
+
this.onOpen();
|
|
7900
7835
|
};
|
|
7901
|
-
this.socket.onerror =
|
|
7902
|
-
|
|
7836
|
+
this.socket.onerror = error => {
|
|
7837
|
+
this.onError(error);
|
|
7903
7838
|
};
|
|
7904
|
-
this.socket.onclose =
|
|
7905
|
-
|
|
7839
|
+
this.socket.onclose = closeEvent => {
|
|
7840
|
+
this.onClose(closeEvent);
|
|
7906
7841
|
};
|
|
7907
|
-
this.socket.onmessage =
|
|
7908
|
-
|
|
7842
|
+
this.socket.onmessage = message => {
|
|
7843
|
+
this.onMessage(message);
|
|
7909
7844
|
};
|
|
7910
7845
|
if (this.supportsPing()) {
|
|
7911
|
-
this.socket.onactivity =
|
|
7912
|
-
|
|
7846
|
+
this.socket.onactivity = () => {
|
|
7847
|
+
this.onActivity();
|
|
7913
7848
|
};
|
|
7914
7849
|
}
|
|
7915
|
-
}
|
|
7916
|
-
|
|
7850
|
+
}
|
|
7851
|
+
unbindListeners() {
|
|
7917
7852
|
if (this.socket) {
|
|
7918
7853
|
this.socket.onopen = undefined;
|
|
7919
7854
|
this.socket.onerror = undefined;
|
|
@@ -7923,44 +7858,40 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
7923
7858
|
this.socket.onactivity = undefined;
|
|
7924
7859
|
}
|
|
7925
7860
|
}
|
|
7926
|
-
}
|
|
7927
|
-
|
|
7861
|
+
}
|
|
7862
|
+
changeState(state, params) {
|
|
7928
7863
|
this.state = state;
|
|
7929
7864
|
this.timeline.info(this.buildTimelineMessage({
|
|
7930
7865
|
state: state,
|
|
7931
7866
|
params: params
|
|
7932
7867
|
}));
|
|
7933
7868
|
this.emit(state, params);
|
|
7934
|
-
}
|
|
7935
|
-
|
|
7869
|
+
}
|
|
7870
|
+
buildTimelineMessage(message) {
|
|
7936
7871
|
return extend({ cid: this.id }, message);
|
|
7937
|
-
}
|
|
7938
|
-
|
|
7939
|
-
}(dispatcher));
|
|
7940
|
-
/* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
|
|
7872
|
+
}
|
|
7873
|
+
}
|
|
7941
7874
|
|
|
7942
7875
|
// CONCATENATED MODULE: ./src/core/transports/transport.ts
|
|
7943
7876
|
|
|
7944
|
-
|
|
7945
|
-
|
|
7877
|
+
class transport_Transport {
|
|
7878
|
+
constructor(hooks) {
|
|
7946
7879
|
this.hooks = hooks;
|
|
7947
7880
|
}
|
|
7948
|
-
|
|
7881
|
+
isSupported(environment) {
|
|
7949
7882
|
return this.hooks.isSupported(environment);
|
|
7950
|
-
}
|
|
7951
|
-
|
|
7952
|
-
return new
|
|
7953
|
-
}
|
|
7954
|
-
|
|
7955
|
-
}());
|
|
7956
|
-
/* harmony default export */ var transports_transport = (transport_Transport);
|
|
7883
|
+
}
|
|
7884
|
+
createConnection(name, priority, key, options) {
|
|
7885
|
+
return new transport_connection_TransportConnection(this.hooks, name, priority, key, options);
|
|
7886
|
+
}
|
|
7887
|
+
}
|
|
7957
7888
|
|
|
7958
7889
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
|
|
7959
7890
|
|
|
7960
7891
|
|
|
7961
7892
|
|
|
7962
7893
|
|
|
7963
|
-
var WSTransport = new
|
|
7894
|
+
var WSTransport = new transport_Transport({
|
|
7964
7895
|
urls: ws,
|
|
7965
7896
|
handlesActivityChecks: false,
|
|
7966
7897
|
supportsPing: false,
|
|
@@ -7997,8 +7928,8 @@ var xhrConfiguration = {
|
|
|
7997
7928
|
return node_runtime.isXHRSupported();
|
|
7998
7929
|
}
|
|
7999
7930
|
};
|
|
8000
|
-
var XHRStreamingTransport = new
|
|
8001
|
-
var XHRPollingTransport = new
|
|
7931
|
+
var XHRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xhrConfiguration)));
|
|
7932
|
+
var XHRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xhrConfiguration));
|
|
8002
7933
|
var Transports = {
|
|
8003
7934
|
ws: WSTransport,
|
|
8004
7935
|
xhr_streaming: XHRStreamingTransport,
|
|
@@ -8009,16 +7940,15 @@ var Transports = {
|
|
|
8009
7940
|
// CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
|
|
8010
7941
|
|
|
8011
7942
|
|
|
8012
|
-
|
|
8013
|
-
|
|
7943
|
+
class assistant_to_the_transport_manager_AssistantToTheTransportManager {
|
|
7944
|
+
constructor(manager, transport, options) {
|
|
8014
7945
|
this.manager = manager;
|
|
8015
7946
|
this.transport = transport;
|
|
8016
7947
|
this.minPingDelay = options.minPingDelay;
|
|
8017
7948
|
this.maxPingDelay = options.maxPingDelay;
|
|
8018
7949
|
this.pingDelay = undefined;
|
|
8019
7950
|
}
|
|
8020
|
-
|
|
8021
|
-
var _this = this;
|
|
7951
|
+
createConnection(name, priority, key, options) {
|
|
8022
7952
|
options = extend({}, options, {
|
|
8023
7953
|
activityTimeout: this.pingDelay
|
|
8024
7954
|
});
|
|
@@ -8029,31 +7959,29 @@ var assistant_to_the_transport_manager_AssistantToTheTransportManager = (functio
|
|
|
8029
7959
|
connection.bind('closed', onClosed);
|
|
8030
7960
|
openTimestamp = util.now();
|
|
8031
7961
|
};
|
|
8032
|
-
var onClosed =
|
|
7962
|
+
var onClosed = closeEvent => {
|
|
8033
7963
|
connection.unbind('closed', onClosed);
|
|
8034
7964
|
if (closeEvent.code === 1002 || closeEvent.code === 1003) {
|
|
8035
|
-
|
|
7965
|
+
this.manager.reportDeath();
|
|
8036
7966
|
}
|
|
8037
7967
|
else if (!closeEvent.wasClean && openTimestamp) {
|
|
8038
7968
|
var lifespan = util.now() - openTimestamp;
|
|
8039
|
-
if (lifespan < 2 *
|
|
8040
|
-
|
|
8041
|
-
|
|
7969
|
+
if (lifespan < 2 * this.maxPingDelay) {
|
|
7970
|
+
this.manager.reportDeath();
|
|
7971
|
+
this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);
|
|
8042
7972
|
}
|
|
8043
7973
|
}
|
|
8044
7974
|
};
|
|
8045
7975
|
connection.bind('open', onOpen);
|
|
8046
7976
|
return connection;
|
|
8047
|
-
}
|
|
8048
|
-
|
|
7977
|
+
}
|
|
7978
|
+
isSupported(environment) {
|
|
8049
7979
|
return this.manager.isAlive() && this.transport.isSupported(environment);
|
|
8050
|
-
}
|
|
8051
|
-
|
|
8052
|
-
}());
|
|
8053
|
-
/* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
|
|
7980
|
+
}
|
|
7981
|
+
}
|
|
8054
7982
|
|
|
8055
7983
|
// CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
|
|
8056
|
-
|
|
7984
|
+
const Protocol = {
|
|
8057
7985
|
decodeMessage: function (messageEvent) {
|
|
8058
7986
|
try {
|
|
8059
7987
|
var messageData = JSON.parse(messageEvent.data);
|
|
@@ -8146,68 +8074,52 @@ var Protocol = {
|
|
|
8146
8074
|
/* harmony default export */ var protocol = (Protocol);
|
|
8147
8075
|
|
|
8148
8076
|
// CONCATENATED MODULE: ./src/core/connection/connection.ts
|
|
8149
|
-
var connection_extends = (undefined && undefined.__extends) || (function () {
|
|
8150
|
-
var extendStatics = function (d, b) {
|
|
8151
|
-
extendStatics = Object.setPrototypeOf ||
|
|
8152
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8153
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
8154
|
-
return extendStatics(d, b);
|
|
8155
|
-
};
|
|
8156
|
-
return function (d, b) {
|
|
8157
|
-
extendStatics(d, b);
|
|
8158
|
-
function __() { this.constructor = d; }
|
|
8159
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8160
|
-
};
|
|
8161
|
-
})();
|
|
8162
8077
|
|
|
8163
8078
|
|
|
8164
8079
|
|
|
8165
8080
|
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
_this.bindListeners();
|
|
8174
|
-
return _this;
|
|
8081
|
+
class connection_Connection extends dispatcher_Dispatcher {
|
|
8082
|
+
constructor(id, transport) {
|
|
8083
|
+
super();
|
|
8084
|
+
this.id = id;
|
|
8085
|
+
this.transport = transport;
|
|
8086
|
+
this.activityTimeout = transport.activityTimeout;
|
|
8087
|
+
this.bindListeners();
|
|
8175
8088
|
}
|
|
8176
|
-
|
|
8089
|
+
handlesActivityChecks() {
|
|
8177
8090
|
return this.transport.handlesActivityChecks();
|
|
8178
|
-
}
|
|
8179
|
-
|
|
8091
|
+
}
|
|
8092
|
+
send(data) {
|
|
8180
8093
|
return this.transport.send(data);
|
|
8181
|
-
}
|
|
8182
|
-
|
|
8094
|
+
}
|
|
8095
|
+
send_event(name, data, channel) {
|
|
8183
8096
|
var event = { event: name, data: data };
|
|
8184
8097
|
if (channel) {
|
|
8185
8098
|
event.channel = channel;
|
|
8186
8099
|
}
|
|
8187
8100
|
logger.debug('Event sent', event);
|
|
8188
8101
|
return this.send(protocol.encodeMessage(event));
|
|
8189
|
-
}
|
|
8190
|
-
|
|
8102
|
+
}
|
|
8103
|
+
ping() {
|
|
8191
8104
|
if (this.transport.supportsPing()) {
|
|
8192
8105
|
this.transport.ping();
|
|
8193
8106
|
}
|
|
8194
8107
|
else {
|
|
8195
8108
|
this.send_event('pusher:ping', {});
|
|
8196
8109
|
}
|
|
8197
|
-
}
|
|
8198
|
-
|
|
8110
|
+
}
|
|
8111
|
+
close() {
|
|
8199
8112
|
this.transport.close();
|
|
8200
|
-
}
|
|
8201
|
-
|
|
8202
|
-
var _this = this;
|
|
8113
|
+
}
|
|
8114
|
+
bindListeners() {
|
|
8203
8115
|
var listeners = {
|
|
8204
|
-
message:
|
|
8116
|
+
message: (messageEvent) => {
|
|
8205
8117
|
var pusherEvent;
|
|
8206
8118
|
try {
|
|
8207
8119
|
pusherEvent = protocol.decodeMessage(messageEvent);
|
|
8208
8120
|
}
|
|
8209
8121
|
catch (e) {
|
|
8210
|
-
|
|
8122
|
+
this.emit('error', {
|
|
8211
8123
|
type: 'MessageParseError',
|
|
8212
8124
|
error: e,
|
|
8213
8125
|
data: messageEvent.data
|
|
@@ -8217,46 +8129,46 @@ var connection_Connection = (function (_super) {
|
|
|
8217
8129
|
logger.debug('Event recd', pusherEvent);
|
|
8218
8130
|
switch (pusherEvent.event) {
|
|
8219
8131
|
case 'pusher:error':
|
|
8220
|
-
|
|
8132
|
+
this.emit('error', {
|
|
8221
8133
|
type: 'PusherError',
|
|
8222
8134
|
data: pusherEvent.data
|
|
8223
8135
|
});
|
|
8224
8136
|
break;
|
|
8225
8137
|
case 'pusher:ping':
|
|
8226
|
-
|
|
8138
|
+
this.emit('ping');
|
|
8227
8139
|
break;
|
|
8228
8140
|
case 'pusher:pong':
|
|
8229
|
-
|
|
8141
|
+
this.emit('pong');
|
|
8230
8142
|
break;
|
|
8231
8143
|
}
|
|
8232
|
-
|
|
8144
|
+
this.emit('message', pusherEvent);
|
|
8233
8145
|
}
|
|
8234
8146
|
},
|
|
8235
|
-
activity:
|
|
8236
|
-
|
|
8147
|
+
activity: () => {
|
|
8148
|
+
this.emit('activity');
|
|
8237
8149
|
},
|
|
8238
|
-
error:
|
|
8239
|
-
|
|
8150
|
+
error: error => {
|
|
8151
|
+
this.emit('error', error);
|
|
8240
8152
|
},
|
|
8241
|
-
closed:
|
|
8153
|
+
closed: closeEvent => {
|
|
8242
8154
|
unbindListeners();
|
|
8243
8155
|
if (closeEvent && closeEvent.code) {
|
|
8244
|
-
|
|
8156
|
+
this.handleCloseEvent(closeEvent);
|
|
8245
8157
|
}
|
|
8246
|
-
|
|
8247
|
-
|
|
8158
|
+
this.transport = null;
|
|
8159
|
+
this.emit('closed');
|
|
8248
8160
|
}
|
|
8249
8161
|
};
|
|
8250
|
-
var unbindListeners =
|
|
8251
|
-
objectApply(listeners,
|
|
8252
|
-
|
|
8162
|
+
var unbindListeners = () => {
|
|
8163
|
+
objectApply(listeners, (listener, event) => {
|
|
8164
|
+
this.transport.unbind(event, listener);
|
|
8253
8165
|
});
|
|
8254
8166
|
};
|
|
8255
|
-
objectApply(listeners,
|
|
8256
|
-
|
|
8167
|
+
objectApply(listeners, (listener, event) => {
|
|
8168
|
+
this.transport.bind(event, listener);
|
|
8257
8169
|
});
|
|
8258
|
-
}
|
|
8259
|
-
|
|
8170
|
+
}
|
|
8171
|
+
handleCloseEvent(closeEvent) {
|
|
8260
8172
|
var action = protocol.getCloseAction(closeEvent);
|
|
8261
8173
|
var error = protocol.getCloseError(closeEvent);
|
|
8262
8174
|
if (error) {
|
|
@@ -8265,203 +8177,138 @@ var connection_Connection = (function (_super) {
|
|
|
8265
8177
|
if (action) {
|
|
8266
8178
|
this.emit(action, { action: action, error: error });
|
|
8267
8179
|
}
|
|
8268
|
-
}
|
|
8269
|
-
|
|
8270
|
-
}(dispatcher));
|
|
8271
|
-
/* harmony default export */ var connection_connection = (connection_Connection);
|
|
8180
|
+
}
|
|
8181
|
+
}
|
|
8272
8182
|
|
|
8273
8183
|
// CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
|
|
8274
8184
|
|
|
8275
8185
|
|
|
8276
8186
|
|
|
8277
|
-
|
|
8278
|
-
|
|
8187
|
+
class handshake_Handshake {
|
|
8188
|
+
constructor(transport, callback) {
|
|
8279
8189
|
this.transport = transport;
|
|
8280
8190
|
this.callback = callback;
|
|
8281
8191
|
this.bindListeners();
|
|
8282
8192
|
}
|
|
8283
|
-
|
|
8193
|
+
close() {
|
|
8284
8194
|
this.unbindListeners();
|
|
8285
8195
|
this.transport.close();
|
|
8286
|
-
}
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
_this.unbindListeners();
|
|
8196
|
+
}
|
|
8197
|
+
bindListeners() {
|
|
8198
|
+
this.onMessage = m => {
|
|
8199
|
+
this.unbindListeners();
|
|
8291
8200
|
var result;
|
|
8292
8201
|
try {
|
|
8293
8202
|
result = protocol.processHandshake(m);
|
|
8294
8203
|
}
|
|
8295
8204
|
catch (e) {
|
|
8296
|
-
|
|
8297
|
-
|
|
8205
|
+
this.finish('error', { error: e });
|
|
8206
|
+
this.transport.close();
|
|
8298
8207
|
return;
|
|
8299
8208
|
}
|
|
8300
8209
|
if (result.action === 'connected') {
|
|
8301
|
-
|
|
8302
|
-
connection: new
|
|
8210
|
+
this.finish('connected', {
|
|
8211
|
+
connection: new connection_Connection(result.id, this.transport),
|
|
8303
8212
|
activityTimeout: result.activityTimeout
|
|
8304
8213
|
});
|
|
8305
8214
|
}
|
|
8306
8215
|
else {
|
|
8307
|
-
|
|
8308
|
-
|
|
8216
|
+
this.finish(result.action, { error: result.error });
|
|
8217
|
+
this.transport.close();
|
|
8309
8218
|
}
|
|
8310
8219
|
};
|
|
8311
|
-
this.onClosed =
|
|
8312
|
-
|
|
8220
|
+
this.onClosed = closeEvent => {
|
|
8221
|
+
this.unbindListeners();
|
|
8313
8222
|
var action = protocol.getCloseAction(closeEvent) || 'backoff';
|
|
8314
8223
|
var error = protocol.getCloseError(closeEvent);
|
|
8315
|
-
|
|
8224
|
+
this.finish(action, { error: error });
|
|
8316
8225
|
};
|
|
8317
8226
|
this.transport.bind('message', this.onMessage);
|
|
8318
8227
|
this.transport.bind('closed', this.onClosed);
|
|
8319
|
-
}
|
|
8320
|
-
|
|
8228
|
+
}
|
|
8229
|
+
unbindListeners() {
|
|
8321
8230
|
this.transport.unbind('message', this.onMessage);
|
|
8322
8231
|
this.transport.unbind('closed', this.onClosed);
|
|
8323
|
-
}
|
|
8324
|
-
|
|
8232
|
+
}
|
|
8233
|
+
finish(action, params) {
|
|
8325
8234
|
this.callback(extend({ transport: this.transport, action: action }, params));
|
|
8326
|
-
}
|
|
8327
|
-
|
|
8328
|
-
}());
|
|
8329
|
-
/* harmony default export */ var connection_handshake = (handshake_Handshake);
|
|
8235
|
+
}
|
|
8236
|
+
}
|
|
8330
8237
|
|
|
8331
8238
|
// CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
|
|
8332
8239
|
|
|
8333
|
-
|
|
8334
|
-
|
|
8240
|
+
class timeline_sender_TimelineSender {
|
|
8241
|
+
constructor(timeline, options) {
|
|
8335
8242
|
this.timeline = timeline;
|
|
8336
8243
|
this.options = options || {};
|
|
8337
8244
|
}
|
|
8338
|
-
|
|
8245
|
+
send(useTLS, callback) {
|
|
8339
8246
|
if (this.timeline.isEmpty()) {
|
|
8340
8247
|
return;
|
|
8341
8248
|
}
|
|
8342
8249
|
this.timeline.send(node_runtime.TimelineTransport.getAgent(this, useTLS), callback);
|
|
8343
|
-
}
|
|
8344
|
-
|
|
8345
|
-
}());
|
|
8346
|
-
/* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
|
|
8250
|
+
}
|
|
8251
|
+
}
|
|
8347
8252
|
|
|
8348
8253
|
// CONCATENATED MODULE: ./src/core/errors.ts
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
}
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
}
|
|
8403
|
-
|
|
8404
|
-
}(Error));
|
|
8405
|
-
|
|
8406
|
-
var TransportClosed = (function (_super) {
|
|
8407
|
-
errors_extends(TransportClosed, _super);
|
|
8408
|
-
function TransportClosed(msg) {
|
|
8409
|
-
var _newTarget = this.constructor;
|
|
8410
|
-
var _this = _super.call(this, msg) || this;
|
|
8411
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
8412
|
-
return _this;
|
|
8413
|
-
}
|
|
8414
|
-
return TransportClosed;
|
|
8415
|
-
}(Error));
|
|
8416
|
-
|
|
8417
|
-
var UnsupportedFeature = (function (_super) {
|
|
8418
|
-
errors_extends(UnsupportedFeature, _super);
|
|
8419
|
-
function UnsupportedFeature(msg) {
|
|
8420
|
-
var _newTarget = this.constructor;
|
|
8421
|
-
var _this = _super.call(this, msg) || this;
|
|
8422
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
8423
|
-
return _this;
|
|
8424
|
-
}
|
|
8425
|
-
return UnsupportedFeature;
|
|
8426
|
-
}(Error));
|
|
8427
|
-
|
|
8428
|
-
var UnsupportedTransport = (function (_super) {
|
|
8429
|
-
errors_extends(UnsupportedTransport, _super);
|
|
8430
|
-
function UnsupportedTransport(msg) {
|
|
8431
|
-
var _newTarget = this.constructor;
|
|
8432
|
-
var _this = _super.call(this, msg) || this;
|
|
8433
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
8434
|
-
return _this;
|
|
8435
|
-
}
|
|
8436
|
-
return UnsupportedTransport;
|
|
8437
|
-
}(Error));
|
|
8438
|
-
|
|
8439
|
-
var UnsupportedStrategy = (function (_super) {
|
|
8440
|
-
errors_extends(UnsupportedStrategy, _super);
|
|
8441
|
-
function UnsupportedStrategy(msg) {
|
|
8442
|
-
var _newTarget = this.constructor;
|
|
8443
|
-
var _this = _super.call(this, msg) || this;
|
|
8444
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
8445
|
-
return _this;
|
|
8446
|
-
}
|
|
8447
|
-
return UnsupportedStrategy;
|
|
8448
|
-
}(Error));
|
|
8449
|
-
|
|
8450
|
-
var HTTPAuthError = (function (_super) {
|
|
8451
|
-
errors_extends(HTTPAuthError, _super);
|
|
8452
|
-
function HTTPAuthError(status, msg) {
|
|
8453
|
-
var _newTarget = this.constructor;
|
|
8454
|
-
var _this = _super.call(this, msg) || this;
|
|
8455
|
-
_this.status = status;
|
|
8456
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
8457
|
-
return _this;
|
|
8458
|
-
}
|
|
8459
|
-
return HTTPAuthError;
|
|
8460
|
-
}(Error));
|
|
8461
|
-
|
|
8254
|
+
class BadEventName extends Error {
|
|
8255
|
+
constructor(msg) {
|
|
8256
|
+
super(msg);
|
|
8257
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
class BadChannelName extends Error {
|
|
8261
|
+
constructor(msg) {
|
|
8262
|
+
super(msg);
|
|
8263
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
class RequestTimedOut extends Error {
|
|
8267
|
+
constructor(msg) {
|
|
8268
|
+
super(msg);
|
|
8269
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8270
|
+
}
|
|
8271
|
+
}
|
|
8272
|
+
class TransportPriorityTooLow extends Error {
|
|
8273
|
+
constructor(msg) {
|
|
8274
|
+
super(msg);
|
|
8275
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8276
|
+
}
|
|
8277
|
+
}
|
|
8278
|
+
class TransportClosed extends Error {
|
|
8279
|
+
constructor(msg) {
|
|
8280
|
+
super(msg);
|
|
8281
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8282
|
+
}
|
|
8283
|
+
}
|
|
8284
|
+
class UnsupportedFeature extends Error {
|
|
8285
|
+
constructor(msg) {
|
|
8286
|
+
super(msg);
|
|
8287
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8288
|
+
}
|
|
8289
|
+
}
|
|
8290
|
+
class UnsupportedTransport extends Error {
|
|
8291
|
+
constructor(msg) {
|
|
8292
|
+
super(msg);
|
|
8293
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8294
|
+
}
|
|
8295
|
+
}
|
|
8296
|
+
class UnsupportedStrategy extends Error {
|
|
8297
|
+
constructor(msg) {
|
|
8298
|
+
super(msg);
|
|
8299
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8302
|
+
class HTTPAuthError extends Error {
|
|
8303
|
+
constructor(status, msg) {
|
|
8304
|
+
super(msg);
|
|
8305
|
+
this.status = status;
|
|
8306
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8307
|
+
}
|
|
8308
|
+
}
|
|
8462
8309
|
|
|
8463
8310
|
// CONCATENATED MODULE: ./src/core/utils/url_store.ts
|
|
8464
|
-
|
|
8311
|
+
const urlStore = {
|
|
8465
8312
|
baseUrl: 'https://pusher.com',
|
|
8466
8313
|
urls: {
|
|
8467
8314
|
authenticationEndpoint: {
|
|
@@ -8481,12 +8328,12 @@ var urlStore = {
|
|
|
8481
8328
|
}
|
|
8482
8329
|
}
|
|
8483
8330
|
};
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8331
|
+
const buildLogSuffix = function (key) {
|
|
8332
|
+
const urlPrefix = 'See:';
|
|
8333
|
+
const urlObj = urlStore.urls[key];
|
|
8487
8334
|
if (!urlObj)
|
|
8488
8335
|
return '';
|
|
8489
|
-
|
|
8336
|
+
let url;
|
|
8490
8337
|
if (urlObj.fullUrl) {
|
|
8491
8338
|
url = urlObj.fullUrl;
|
|
8492
8339
|
}
|
|
@@ -8495,60 +8342,45 @@ var buildLogSuffix = function (key) {
|
|
|
8495
8342
|
}
|
|
8496
8343
|
if (!url)
|
|
8497
8344
|
return '';
|
|
8498
|
-
return urlPrefix
|
|
8345
|
+
return `${urlPrefix} ${url}`;
|
|
8499
8346
|
};
|
|
8500
|
-
/* harmony default export */ var url_store = ({ buildLogSuffix
|
|
8347
|
+
/* harmony default export */ var url_store = ({ buildLogSuffix });
|
|
8501
8348
|
|
|
8502
8349
|
// CONCATENATED MODULE: ./src/core/channels/channel.ts
|
|
8503
|
-
var channel_extends = (undefined && undefined.__extends) || (function () {
|
|
8504
|
-
var extendStatics = function (d, b) {
|
|
8505
|
-
extendStatics = Object.setPrototypeOf ||
|
|
8506
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8507
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
8508
|
-
return extendStatics(d, b);
|
|
8509
|
-
};
|
|
8510
|
-
return function (d, b) {
|
|
8511
|
-
extendStatics(d, b);
|
|
8512
|
-
function __() { this.constructor = d; }
|
|
8513
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8514
|
-
};
|
|
8515
|
-
})();
|
|
8516
8350
|
|
|
8517
8351
|
|
|
8518
8352
|
|
|
8519
8353
|
|
|
8520
8354
|
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
var _this = _super.call(this, function (event, data) {
|
|
8355
|
+
class channel_Channel extends dispatcher_Dispatcher {
|
|
8356
|
+
constructor(name, pusher) {
|
|
8357
|
+
super(function (event, data) {
|
|
8525
8358
|
logger.debug('No callbacks on ' + name + ' for ' + event);
|
|
8526
|
-
})
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
Channel.prototype.authorize = function (socketId, callback) {
|
|
8359
|
+
});
|
|
8360
|
+
this.name = name;
|
|
8361
|
+
this.pusher = pusher;
|
|
8362
|
+
this.subscribed = false;
|
|
8363
|
+
this.subscriptionPending = false;
|
|
8364
|
+
this.subscriptionCancelled = false;
|
|
8365
|
+
}
|
|
8366
|
+
authorize(socketId, callback) {
|
|
8535
8367
|
return callback(null, { auth: '' });
|
|
8536
|
-
}
|
|
8537
|
-
|
|
8368
|
+
}
|
|
8369
|
+
trigger(event, data) {
|
|
8538
8370
|
if (event.indexOf('client-') !== 0) {
|
|
8539
8371
|
throw new BadEventName("Event '" + event + "' does not start with 'client-'");
|
|
8540
8372
|
}
|
|
8541
8373
|
if (!this.subscribed) {
|
|
8542
8374
|
var suffix = url_store.buildLogSuffix('triggeringClientEvents');
|
|
8543
|
-
logger.warn(
|
|
8375
|
+
logger.warn(`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`);
|
|
8544
8376
|
}
|
|
8545
8377
|
return this.pusher.send_event(event, data, this.name);
|
|
8546
|
-
}
|
|
8547
|
-
|
|
8378
|
+
}
|
|
8379
|
+
disconnect() {
|
|
8548
8380
|
this.subscribed = false;
|
|
8549
8381
|
this.subscriptionPending = false;
|
|
8550
|
-
}
|
|
8551
|
-
|
|
8382
|
+
}
|
|
8383
|
+
handleEvent(event) {
|
|
8552
8384
|
var eventName = event.event;
|
|
8553
8385
|
var data = event.data;
|
|
8554
8386
|
if (eventName === 'pusher_internal:subscription_succeeded') {
|
|
@@ -8561,8 +8393,8 @@ var channel_Channel = (function (_super) {
|
|
|
8561
8393
|
var metadata = {};
|
|
8562
8394
|
this.emit(eventName, data, metadata);
|
|
8563
8395
|
}
|
|
8564
|
-
}
|
|
8565
|
-
|
|
8396
|
+
}
|
|
8397
|
+
handleSubscriptionSucceededEvent(event) {
|
|
8566
8398
|
this.subscriptionPending = false;
|
|
8567
8399
|
this.subscribed = true;
|
|
8568
8400
|
if (this.subscriptionCancelled) {
|
|
@@ -8571,91 +8403,69 @@ var channel_Channel = (function (_super) {
|
|
|
8571
8403
|
else {
|
|
8572
8404
|
this.emit('pusher:subscription_succeeded', event.data);
|
|
8573
8405
|
}
|
|
8574
|
-
}
|
|
8575
|
-
|
|
8406
|
+
}
|
|
8407
|
+
handleSubscriptionCountEvent(event) {
|
|
8576
8408
|
if (event.data.subscription_count) {
|
|
8577
8409
|
this.subscriptionCount = event.data.subscription_count;
|
|
8578
8410
|
}
|
|
8579
8411
|
this.emit('pusher:subscription_count', event.data);
|
|
8580
|
-
}
|
|
8581
|
-
|
|
8582
|
-
var _this = this;
|
|
8412
|
+
}
|
|
8413
|
+
subscribe() {
|
|
8583
8414
|
if (this.subscribed) {
|
|
8584
8415
|
return;
|
|
8585
8416
|
}
|
|
8586
8417
|
this.subscriptionPending = true;
|
|
8587
8418
|
this.subscriptionCancelled = false;
|
|
8588
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
8419
|
+
this.authorize(this.pusher.connection.socket_id, (error, data) => {
|
|
8589
8420
|
if (error) {
|
|
8590
|
-
|
|
8421
|
+
this.subscriptionPending = false;
|
|
8591
8422
|
logger.error(error.toString());
|
|
8592
|
-
|
|
8423
|
+
this.emit('pusher:subscription_error', Object.assign({}, {
|
|
8593
8424
|
type: 'AuthError',
|
|
8594
8425
|
error: error.message
|
|
8595
8426
|
}, error instanceof HTTPAuthError ? { status: error.status } : {}));
|
|
8596
8427
|
}
|
|
8597
8428
|
else {
|
|
8598
|
-
|
|
8429
|
+
this.pusher.send_event('pusher:subscribe', {
|
|
8599
8430
|
auth: data.auth,
|
|
8600
8431
|
channel_data: data.channel_data,
|
|
8601
|
-
channel:
|
|
8432
|
+
channel: this.name
|
|
8602
8433
|
});
|
|
8603
8434
|
}
|
|
8604
8435
|
});
|
|
8605
|
-
}
|
|
8606
|
-
|
|
8436
|
+
}
|
|
8437
|
+
unsubscribe() {
|
|
8607
8438
|
this.subscribed = false;
|
|
8608
8439
|
this.pusher.send_event('pusher:unsubscribe', {
|
|
8609
8440
|
channel: this.name
|
|
8610
8441
|
});
|
|
8611
|
-
}
|
|
8612
|
-
|
|
8442
|
+
}
|
|
8443
|
+
cancelSubscription() {
|
|
8613
8444
|
this.subscriptionCancelled = true;
|
|
8614
|
-
}
|
|
8615
|
-
|
|
8445
|
+
}
|
|
8446
|
+
reinstateSubscription() {
|
|
8616
8447
|
this.subscriptionCancelled = false;
|
|
8617
|
-
}
|
|
8618
|
-
|
|
8619
|
-
}(dispatcher));
|
|
8620
|
-
/* harmony default export */ var channels_channel = (channel_Channel);
|
|
8448
|
+
}
|
|
8449
|
+
}
|
|
8621
8450
|
|
|
8622
8451
|
// CONCATENATED MODULE: ./src/core/channels/private_channel.ts
|
|
8623
|
-
var private_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
8624
|
-
var extendStatics = function (d, b) {
|
|
8625
|
-
extendStatics = Object.setPrototypeOf ||
|
|
8626
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8627
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
8628
|
-
return extendStatics(d, b);
|
|
8629
|
-
};
|
|
8630
|
-
return function (d, b) {
|
|
8631
|
-
extendStatics(d, b);
|
|
8632
|
-
function __() { this.constructor = d; }
|
|
8633
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8634
|
-
};
|
|
8635
|
-
})();
|
|
8636
8452
|
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
function PrivateChannel() {
|
|
8640
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
8641
|
-
}
|
|
8642
|
-
PrivateChannel.prototype.authorize = function (socketId, callback) {
|
|
8453
|
+
class private_channel_PrivateChannel extends channel_Channel {
|
|
8454
|
+
authorize(socketId, callback) {
|
|
8643
8455
|
return this.pusher.config.channelAuthorizer({
|
|
8644
8456
|
channelName: this.name,
|
|
8645
8457
|
socketId: socketId
|
|
8646
8458
|
}, callback);
|
|
8647
|
-
}
|
|
8648
|
-
|
|
8649
|
-
}(channels_channel));
|
|
8650
|
-
/* harmony default export */ var private_channel = (PrivateChannel);
|
|
8459
|
+
}
|
|
8460
|
+
}
|
|
8651
8461
|
|
|
8652
8462
|
// CONCATENATED MODULE: ./src/core/channels/members.ts
|
|
8653
8463
|
|
|
8654
|
-
|
|
8655
|
-
|
|
8464
|
+
class members_Members {
|
|
8465
|
+
constructor() {
|
|
8656
8466
|
this.reset();
|
|
8657
8467
|
}
|
|
8658
|
-
|
|
8468
|
+
get(id) {
|
|
8659
8469
|
if (Object.prototype.hasOwnProperty.call(this.members, id)) {
|
|
8660
8470
|
return {
|
|
8661
8471
|
id: id,
|
|
@@ -8665,60 +8475,44 @@ var members_Members = (function () {
|
|
|
8665
8475
|
else {
|
|
8666
8476
|
return null;
|
|
8667
8477
|
}
|
|
8668
|
-
}
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
callback(_this.get(id));
|
|
8478
|
+
}
|
|
8479
|
+
each(callback) {
|
|
8480
|
+
objectApply(this.members, (member, id) => {
|
|
8481
|
+
callback(this.get(id));
|
|
8673
8482
|
});
|
|
8674
|
-
}
|
|
8675
|
-
|
|
8483
|
+
}
|
|
8484
|
+
setMyID(id) {
|
|
8676
8485
|
this.myID = id;
|
|
8677
|
-
}
|
|
8678
|
-
|
|
8486
|
+
}
|
|
8487
|
+
onSubscription(subscriptionData) {
|
|
8679
8488
|
this.members = subscriptionData.presence.hash;
|
|
8680
8489
|
this.count = subscriptionData.presence.count;
|
|
8681
8490
|
this.me = this.get(this.myID);
|
|
8682
|
-
}
|
|
8683
|
-
|
|
8491
|
+
}
|
|
8492
|
+
addMember(memberData) {
|
|
8684
8493
|
if (this.get(memberData.user_id) === null) {
|
|
8685
8494
|
this.count++;
|
|
8686
8495
|
}
|
|
8687
8496
|
this.members[memberData.user_id] = memberData.user_info;
|
|
8688
8497
|
return this.get(memberData.user_id);
|
|
8689
|
-
}
|
|
8690
|
-
|
|
8498
|
+
}
|
|
8499
|
+
removeMember(memberData) {
|
|
8691
8500
|
var member = this.get(memberData.user_id);
|
|
8692
8501
|
if (member) {
|
|
8693
8502
|
delete this.members[memberData.user_id];
|
|
8694
8503
|
this.count--;
|
|
8695
8504
|
}
|
|
8696
8505
|
return member;
|
|
8697
|
-
}
|
|
8698
|
-
|
|
8506
|
+
}
|
|
8507
|
+
reset() {
|
|
8699
8508
|
this.members = {};
|
|
8700
8509
|
this.count = 0;
|
|
8701
8510
|
this.myID = null;
|
|
8702
8511
|
this.me = null;
|
|
8703
|
-
}
|
|
8704
|
-
|
|
8705
|
-
}());
|
|
8706
|
-
/* harmony default export */ var members = (members_Members);
|
|
8512
|
+
}
|
|
8513
|
+
}
|
|
8707
8514
|
|
|
8708
8515
|
// CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
|
|
8709
|
-
var presence_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
8710
|
-
var extendStatics = function (d, b) {
|
|
8711
|
-
extendStatics = Object.setPrototypeOf ||
|
|
8712
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8713
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
8714
|
-
return extendStatics(d, b);
|
|
8715
|
-
};
|
|
8716
|
-
return function (d, b) {
|
|
8717
|
-
extendStatics(d, b);
|
|
8718
|
-
function __() { this.constructor = d; }
|
|
8719
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8720
|
-
};
|
|
8721
|
-
})();
|
|
8722
8516
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8723
8517
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8724
8518
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8728,80 +8522,42 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
8728
8522
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8729
8523
|
});
|
|
8730
8524
|
};
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
8748
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
8749
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
8750
|
-
if (t[2]) _.ops.pop();
|
|
8751
|
-
_.trys.pop(); continue;
|
|
8752
|
-
}
|
|
8753
|
-
op = body.call(thisArg, _);
|
|
8754
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
8755
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
8756
|
-
}
|
|
8757
|
-
};
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
var presence_channel_PresenceChannel = (function (_super) {
|
|
8763
|
-
presence_channel_extends(PresenceChannel, _super);
|
|
8764
|
-
function PresenceChannel(name, pusher) {
|
|
8765
|
-
var _this = _super.call(this, name, pusher) || this;
|
|
8766
|
-
_this.members = new members();
|
|
8767
|
-
return _this;
|
|
8768
|
-
}
|
|
8769
|
-
PresenceChannel.prototype.authorize = function (socketId, callback) {
|
|
8770
|
-
var _this = this;
|
|
8771
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) { return __awaiter(_this, void 0, void 0, function () {
|
|
8772
|
-
var channelData, suffix;
|
|
8773
|
-
return __generator(this, function (_a) {
|
|
8774
|
-
switch (_a.label) {
|
|
8775
|
-
case 0:
|
|
8776
|
-
if (!!error) return [3, 3];
|
|
8777
|
-
authData = authData;
|
|
8778
|
-
if (!(authData.channel_data != null)) return [3, 1];
|
|
8779
|
-
channelData = JSON.parse(authData.channel_data);
|
|
8780
|
-
this.members.setMyID(channelData.user_id);
|
|
8781
|
-
return [3, 3];
|
|
8782
|
-
case 1: return [4, this.pusher.user.signinDonePromise];
|
|
8783
|
-
case 2:
|
|
8784
|
-
_a.sent();
|
|
8785
|
-
if (this.pusher.user.user_data != null) {
|
|
8786
|
-
this.members.setMyID(this.pusher.user.user_data.id);
|
|
8787
|
-
}
|
|
8788
|
-
else {
|
|
8789
|
-
suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
8790
|
-
logger.error("Invalid auth response for channel '" + this.name + "', " +
|
|
8791
|
-
("expected 'channel_data' field. " + suffix + ", ") +
|
|
8792
|
-
"or the user should be signed in.");
|
|
8793
|
-
callback('Invalid auth response');
|
|
8794
|
-
return [2];
|
|
8795
|
-
}
|
|
8796
|
-
_a.label = 3;
|
|
8797
|
-
case 3:
|
|
8798
|
-
callback(error, authData);
|
|
8799
|
-
return [2];
|
|
8525
|
+
|
|
8526
|
+
|
|
8527
|
+
|
|
8528
|
+
|
|
8529
|
+
class presence_channel_PresenceChannel extends private_channel_PrivateChannel {
|
|
8530
|
+
constructor(name, pusher) {
|
|
8531
|
+
super(name, pusher);
|
|
8532
|
+
this.members = new members_Members();
|
|
8533
|
+
}
|
|
8534
|
+
authorize(socketId, callback) {
|
|
8535
|
+
super.authorize(socketId, (error, authData) => __awaiter(this, void 0, void 0, function* () {
|
|
8536
|
+
if (!error) {
|
|
8537
|
+
authData = authData;
|
|
8538
|
+
if (authData.channel_data != null) {
|
|
8539
|
+
var channelData = JSON.parse(authData.channel_data);
|
|
8540
|
+
this.members.setMyID(channelData.user_id);
|
|
8800
8541
|
}
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8542
|
+
else {
|
|
8543
|
+
yield this.pusher.user.signinDonePromise;
|
|
8544
|
+
if (this.pusher.user.user_data != null) {
|
|
8545
|
+
this.members.setMyID(this.pusher.user.user_data.id);
|
|
8546
|
+
}
|
|
8547
|
+
else {
|
|
8548
|
+
let suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
8549
|
+
logger.error(`Invalid auth response for channel '${this.name}', ` +
|
|
8550
|
+
`expected 'channel_data' field. ${suffix}, ` +
|
|
8551
|
+
`or the user should be signed in.`);
|
|
8552
|
+
callback('Invalid auth response');
|
|
8553
|
+
return;
|
|
8554
|
+
}
|
|
8555
|
+
}
|
|
8556
|
+
}
|
|
8557
|
+
callback(error, authData);
|
|
8558
|
+
}));
|
|
8559
|
+
}
|
|
8560
|
+
handleEvent(event) {
|
|
8805
8561
|
var eventName = event.event;
|
|
8806
8562
|
if (eventName.indexOf('pusher_internal:') === 0) {
|
|
8807
8563
|
this.handleInternalEvent(event);
|
|
@@ -8814,8 +8570,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
8814
8570
|
}
|
|
8815
8571
|
this.emit(eventName, data, metadata);
|
|
8816
8572
|
}
|
|
8817
|
-
}
|
|
8818
|
-
|
|
8573
|
+
}
|
|
8574
|
+
handleInternalEvent(event) {
|
|
8819
8575
|
var eventName = event.event;
|
|
8820
8576
|
var data = event.data;
|
|
8821
8577
|
switch (eventName) {
|
|
@@ -8836,8 +8592,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
8836
8592
|
}
|
|
8837
8593
|
break;
|
|
8838
8594
|
}
|
|
8839
|
-
}
|
|
8840
|
-
|
|
8595
|
+
}
|
|
8596
|
+
handleSubscriptionSucceededEvent(event) {
|
|
8841
8597
|
this.subscriptionPending = false;
|
|
8842
8598
|
this.subscribed = true;
|
|
8843
8599
|
if (this.subscriptionCancelled) {
|
|
@@ -8847,14 +8603,12 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
8847
8603
|
this.members.onSubscription(event.data);
|
|
8848
8604
|
this.emit('pusher:subscription_succeeded', this.members);
|
|
8849
8605
|
}
|
|
8850
|
-
}
|
|
8851
|
-
|
|
8606
|
+
}
|
|
8607
|
+
disconnect() {
|
|
8852
8608
|
this.members.reset();
|
|
8853
|
-
|
|
8854
|
-
}
|
|
8855
|
-
|
|
8856
|
-
}(private_channel));
|
|
8857
|
-
/* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
|
|
8609
|
+
super.disconnect();
|
|
8610
|
+
}
|
|
8611
|
+
}
|
|
8858
8612
|
|
|
8859
8613
|
// EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js
|
|
8860
8614
|
var utf8 = __webpack_require__(17);
|
|
@@ -8863,64 +8617,47 @@ var utf8 = __webpack_require__(17);
|
|
|
8863
8617
|
var base64 = __webpack_require__(8);
|
|
8864
8618
|
|
|
8865
8619
|
// CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
|
|
8866
|
-
var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
8867
|
-
var extendStatics = function (d, b) {
|
|
8868
|
-
extendStatics = Object.setPrototypeOf ||
|
|
8869
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8870
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
8871
|
-
return extendStatics(d, b);
|
|
8872
|
-
};
|
|
8873
|
-
return function (d, b) {
|
|
8874
|
-
extendStatics(d, b);
|
|
8875
|
-
function __() { this.constructor = d; }
|
|
8876
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8877
|
-
};
|
|
8878
|
-
})();
|
|
8879
8620
|
|
|
8880
8621
|
|
|
8881
8622
|
|
|
8882
8623
|
|
|
8883
8624
|
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
_this.nacl = nacl;
|
|
8890
|
-
return _this;
|
|
8625
|
+
class encrypted_channel_EncryptedChannel extends private_channel_PrivateChannel {
|
|
8626
|
+
constructor(name, pusher, nacl) {
|
|
8627
|
+
super(name, pusher);
|
|
8628
|
+
this.key = null;
|
|
8629
|
+
this.nacl = nacl;
|
|
8891
8630
|
}
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) {
|
|
8631
|
+
authorize(socketId, callback) {
|
|
8632
|
+
super.authorize(socketId, (error, authData) => {
|
|
8895
8633
|
if (error) {
|
|
8896
8634
|
callback(error, authData);
|
|
8897
8635
|
return;
|
|
8898
8636
|
}
|
|
8899
|
-
|
|
8637
|
+
let sharedSecret = authData['shared_secret'];
|
|
8900
8638
|
if (!sharedSecret) {
|
|
8901
|
-
callback(new Error(
|
|
8639
|
+
callback(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`), null);
|
|
8902
8640
|
return;
|
|
8903
8641
|
}
|
|
8904
|
-
|
|
8642
|
+
this.key = Object(base64["decode"])(sharedSecret);
|
|
8905
8643
|
delete authData['shared_secret'];
|
|
8906
8644
|
callback(null, authData);
|
|
8907
8645
|
});
|
|
8908
|
-
}
|
|
8909
|
-
|
|
8646
|
+
}
|
|
8647
|
+
trigger(event, data) {
|
|
8910
8648
|
throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
|
|
8911
|
-
}
|
|
8912
|
-
|
|
8649
|
+
}
|
|
8650
|
+
handleEvent(event) {
|
|
8913
8651
|
var eventName = event.event;
|
|
8914
8652
|
var data = event.data;
|
|
8915
8653
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
8916
8654
|
eventName.indexOf('pusher:') === 0) {
|
|
8917
|
-
|
|
8655
|
+
super.handleEvent(event);
|
|
8918
8656
|
return;
|
|
8919
8657
|
}
|
|
8920
8658
|
this.handleEncryptedEvent(eventName, data);
|
|
8921
|
-
}
|
|
8922
|
-
|
|
8923
|
-
var _this = this;
|
|
8659
|
+
}
|
|
8660
|
+
handleEncryptedEvent(event, data) {
|
|
8924
8661
|
if (!this.key) {
|
|
8925
8662
|
logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
|
|
8926
8663
|
return;
|
|
@@ -8930,98 +8667,81 @@ var encrypted_channel_EncryptedChannel = (function (_super) {
|
|
|
8930
8667
|
data);
|
|
8931
8668
|
return;
|
|
8932
8669
|
}
|
|
8933
|
-
|
|
8670
|
+
let cipherText = Object(base64["decode"])(data.ciphertext);
|
|
8934
8671
|
if (cipherText.length < this.nacl.secretbox.overheadLength) {
|
|
8935
|
-
logger.error(
|
|
8672
|
+
logger.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`);
|
|
8936
8673
|
return;
|
|
8937
8674
|
}
|
|
8938
|
-
|
|
8675
|
+
let nonce = Object(base64["decode"])(data.nonce);
|
|
8939
8676
|
if (nonce.length < this.nacl.secretbox.nonceLength) {
|
|
8940
|
-
logger.error(
|
|
8677
|
+
logger.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`);
|
|
8941
8678
|
return;
|
|
8942
8679
|
}
|
|
8943
|
-
|
|
8680
|
+
let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
8944
8681
|
if (bytes === null) {
|
|
8945
8682
|
logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
|
|
8946
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
8683
|
+
this.authorize(this.pusher.connection.socket_id, (error, authData) => {
|
|
8947
8684
|
if (error) {
|
|
8948
|
-
logger.error(
|
|
8685
|
+
logger.error(`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`);
|
|
8949
8686
|
return;
|
|
8950
8687
|
}
|
|
8951
|
-
bytes =
|
|
8688
|
+
bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
8952
8689
|
if (bytes === null) {
|
|
8953
|
-
logger.error(
|
|
8690
|
+
logger.error(`Failed to decrypt event with new key. Dropping encrypted event`);
|
|
8954
8691
|
return;
|
|
8955
8692
|
}
|
|
8956
|
-
|
|
8693
|
+
this.emit(event, this.getDataToEmit(bytes));
|
|
8957
8694
|
return;
|
|
8958
8695
|
});
|
|
8959
8696
|
return;
|
|
8960
8697
|
}
|
|
8961
8698
|
this.emit(event, this.getDataToEmit(bytes));
|
|
8962
|
-
}
|
|
8963
|
-
|
|
8964
|
-
|
|
8699
|
+
}
|
|
8700
|
+
getDataToEmit(bytes) {
|
|
8701
|
+
let raw = Object(utf8["decode"])(bytes);
|
|
8965
8702
|
try {
|
|
8966
8703
|
return JSON.parse(raw);
|
|
8967
8704
|
}
|
|
8968
8705
|
catch (_a) {
|
|
8969
8706
|
return raw;
|
|
8970
8707
|
}
|
|
8971
|
-
}
|
|
8972
|
-
|
|
8973
|
-
}(private_channel));
|
|
8974
|
-
/* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
|
|
8708
|
+
}
|
|
8709
|
+
}
|
|
8975
8710
|
|
|
8976
8711
|
// CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
|
|
8977
|
-
var connection_manager_extends = (undefined && undefined.__extends) || (function () {
|
|
8978
|
-
var extendStatics = function (d, b) {
|
|
8979
|
-
extendStatics = Object.setPrototypeOf ||
|
|
8980
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8981
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
8982
|
-
return extendStatics(d, b);
|
|
8983
|
-
};
|
|
8984
|
-
return function (d, b) {
|
|
8985
|
-
extendStatics(d, b);
|
|
8986
|
-
function __() { this.constructor = d; }
|
|
8987
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8988
|
-
};
|
|
8989
|
-
})();
|
|
8990
8712
|
|
|
8991
8713
|
|
|
8992
8714
|
|
|
8993
8715
|
|
|
8994
8716
|
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
_this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
|
|
8717
|
+
class connection_manager_ConnectionManager extends dispatcher_Dispatcher {
|
|
8718
|
+
constructor(key, options) {
|
|
8719
|
+
super();
|
|
8720
|
+
this.state = 'initialized';
|
|
8721
|
+
this.connection = null;
|
|
8722
|
+
this.key = key;
|
|
8723
|
+
this.options = options;
|
|
8724
|
+
this.timeline = this.options.timeline;
|
|
8725
|
+
this.usingTLS = this.options.useTLS;
|
|
8726
|
+
this.errorCallbacks = this.buildErrorCallbacks();
|
|
8727
|
+
this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks);
|
|
8728
|
+
this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
|
|
9008
8729
|
var Network = node_runtime.getNetwork();
|
|
9009
|
-
Network.bind('online',
|
|
9010
|
-
|
|
9011
|
-
if (
|
|
9012
|
-
|
|
8730
|
+
Network.bind('online', () => {
|
|
8731
|
+
this.timeline.info({ netinfo: 'online' });
|
|
8732
|
+
if (this.state === 'connecting' || this.state === 'unavailable') {
|
|
8733
|
+
this.retryIn(0);
|
|
9013
8734
|
}
|
|
9014
8735
|
});
|
|
9015
|
-
Network.bind('offline',
|
|
9016
|
-
|
|
9017
|
-
if (
|
|
9018
|
-
|
|
8736
|
+
Network.bind('offline', () => {
|
|
8737
|
+
this.timeline.info({ netinfo: 'offline' });
|
|
8738
|
+
if (this.connection) {
|
|
8739
|
+
this.sendActivityCheck();
|
|
9019
8740
|
}
|
|
9020
8741
|
});
|
|
9021
|
-
|
|
9022
|
-
return _this;
|
|
8742
|
+
this.updateStrategy();
|
|
9023
8743
|
}
|
|
9024
|
-
|
|
8744
|
+
connect() {
|
|
9025
8745
|
if (this.connection || this.runner) {
|
|
9026
8746
|
return;
|
|
9027
8747
|
}
|
|
@@ -9032,59 +8752,58 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
9032
8752
|
this.updateState('connecting');
|
|
9033
8753
|
this.startConnecting();
|
|
9034
8754
|
this.setUnavailableTimer();
|
|
9035
|
-
}
|
|
9036
|
-
|
|
8755
|
+
}
|
|
8756
|
+
send(data) {
|
|
9037
8757
|
if (this.connection) {
|
|
9038
8758
|
return this.connection.send(data);
|
|
9039
8759
|
}
|
|
9040
8760
|
else {
|
|
9041
8761
|
return false;
|
|
9042
8762
|
}
|
|
9043
|
-
}
|
|
9044
|
-
|
|
8763
|
+
}
|
|
8764
|
+
send_event(name, data, channel) {
|
|
9045
8765
|
if (this.connection) {
|
|
9046
8766
|
return this.connection.send_event(name, data, channel);
|
|
9047
8767
|
}
|
|
9048
8768
|
else {
|
|
9049
8769
|
return false;
|
|
9050
8770
|
}
|
|
9051
|
-
}
|
|
9052
|
-
|
|
8771
|
+
}
|
|
8772
|
+
disconnect() {
|
|
9053
8773
|
this.disconnectInternally();
|
|
9054
8774
|
this.updateState('disconnected');
|
|
9055
|
-
}
|
|
9056
|
-
|
|
8775
|
+
}
|
|
8776
|
+
isUsingTLS() {
|
|
9057
8777
|
return this.usingTLS;
|
|
9058
|
-
}
|
|
9059
|
-
|
|
9060
|
-
var
|
|
9061
|
-
var callback = function (error, handshake) {
|
|
8778
|
+
}
|
|
8779
|
+
startConnecting() {
|
|
8780
|
+
var callback = (error, handshake) => {
|
|
9062
8781
|
if (error) {
|
|
9063
|
-
|
|
8782
|
+
this.runner = this.strategy.connect(0, callback);
|
|
9064
8783
|
}
|
|
9065
8784
|
else {
|
|
9066
8785
|
if (handshake.action === 'error') {
|
|
9067
|
-
|
|
8786
|
+
this.emit('error', {
|
|
9068
8787
|
type: 'HandshakeError',
|
|
9069
8788
|
error: handshake.error
|
|
9070
8789
|
});
|
|
9071
|
-
|
|
8790
|
+
this.timeline.error({ handshakeError: handshake.error });
|
|
9072
8791
|
}
|
|
9073
8792
|
else {
|
|
9074
|
-
|
|
9075
|
-
|
|
8793
|
+
this.abortConnecting();
|
|
8794
|
+
this.handshakeCallbacks[handshake.action](handshake);
|
|
9076
8795
|
}
|
|
9077
8796
|
}
|
|
9078
8797
|
};
|
|
9079
8798
|
this.runner = this.strategy.connect(0, callback);
|
|
9080
|
-
}
|
|
9081
|
-
|
|
8799
|
+
}
|
|
8800
|
+
abortConnecting() {
|
|
9082
8801
|
if (this.runner) {
|
|
9083
8802
|
this.runner.abort();
|
|
9084
8803
|
this.runner = null;
|
|
9085
8804
|
}
|
|
9086
|
-
}
|
|
9087
|
-
|
|
8805
|
+
}
|
|
8806
|
+
disconnectInternally() {
|
|
9088
8807
|
this.abortConnecting();
|
|
9089
8808
|
this.clearRetryTimer();
|
|
9090
8809
|
this.clearUnavailableTimer();
|
|
@@ -9092,136 +8811,129 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
9092
8811
|
var connection = this.abandonConnection();
|
|
9093
8812
|
connection.close();
|
|
9094
8813
|
}
|
|
9095
|
-
}
|
|
9096
|
-
|
|
8814
|
+
}
|
|
8815
|
+
updateStrategy() {
|
|
9097
8816
|
this.strategy = this.options.getStrategy({
|
|
9098
8817
|
key: this.key,
|
|
9099
8818
|
timeline: this.timeline,
|
|
9100
8819
|
useTLS: this.usingTLS
|
|
9101
8820
|
});
|
|
9102
|
-
}
|
|
9103
|
-
|
|
9104
|
-
var _this = this;
|
|
8821
|
+
}
|
|
8822
|
+
retryIn(delay) {
|
|
9105
8823
|
this.timeline.info({ action: 'retry', delay: delay });
|
|
9106
8824
|
if (delay > 0) {
|
|
9107
8825
|
this.emit('connecting_in', Math.round(delay / 1000));
|
|
9108
8826
|
}
|
|
9109
|
-
this.retryTimer = new
|
|
9110
|
-
|
|
9111
|
-
|
|
8827
|
+
this.retryTimer = new timers_OneOffTimer(delay || 0, () => {
|
|
8828
|
+
this.disconnectInternally();
|
|
8829
|
+
this.connect();
|
|
9112
8830
|
});
|
|
9113
|
-
}
|
|
9114
|
-
|
|
8831
|
+
}
|
|
8832
|
+
clearRetryTimer() {
|
|
9115
8833
|
if (this.retryTimer) {
|
|
9116
8834
|
this.retryTimer.ensureAborted();
|
|
9117
8835
|
this.retryTimer = null;
|
|
9118
8836
|
}
|
|
9119
|
-
}
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
_this.updateState('unavailable');
|
|
8837
|
+
}
|
|
8838
|
+
setUnavailableTimer() {
|
|
8839
|
+
this.unavailableTimer = new timers_OneOffTimer(this.options.unavailableTimeout, () => {
|
|
8840
|
+
this.updateState('unavailable');
|
|
9124
8841
|
});
|
|
9125
|
-
}
|
|
9126
|
-
|
|
8842
|
+
}
|
|
8843
|
+
clearUnavailableTimer() {
|
|
9127
8844
|
if (this.unavailableTimer) {
|
|
9128
8845
|
this.unavailableTimer.ensureAborted();
|
|
9129
8846
|
}
|
|
9130
|
-
}
|
|
9131
|
-
|
|
9132
|
-
var _this = this;
|
|
8847
|
+
}
|
|
8848
|
+
sendActivityCheck() {
|
|
9133
8849
|
this.stopActivityCheck();
|
|
9134
8850
|
this.connection.ping();
|
|
9135
|
-
this.activityTimer = new
|
|
9136
|
-
|
|
9137
|
-
|
|
8851
|
+
this.activityTimer = new timers_OneOffTimer(this.options.pongTimeout, () => {
|
|
8852
|
+
this.timeline.error({ pong_timed_out: this.options.pongTimeout });
|
|
8853
|
+
this.retryIn(0);
|
|
9138
8854
|
});
|
|
9139
|
-
}
|
|
9140
|
-
|
|
9141
|
-
var _this = this;
|
|
8855
|
+
}
|
|
8856
|
+
resetActivityCheck() {
|
|
9142
8857
|
this.stopActivityCheck();
|
|
9143
8858
|
if (this.connection && !this.connection.handlesActivityChecks()) {
|
|
9144
|
-
this.activityTimer = new
|
|
9145
|
-
|
|
8859
|
+
this.activityTimer = new timers_OneOffTimer(this.activityTimeout, () => {
|
|
8860
|
+
this.sendActivityCheck();
|
|
9146
8861
|
});
|
|
9147
8862
|
}
|
|
9148
|
-
}
|
|
9149
|
-
|
|
8863
|
+
}
|
|
8864
|
+
stopActivityCheck() {
|
|
9150
8865
|
if (this.activityTimer) {
|
|
9151
8866
|
this.activityTimer.ensureAborted();
|
|
9152
8867
|
}
|
|
9153
|
-
}
|
|
9154
|
-
|
|
9155
|
-
var _this = this;
|
|
8868
|
+
}
|
|
8869
|
+
buildConnectionCallbacks(errorCallbacks) {
|
|
9156
8870
|
return extend({}, errorCallbacks, {
|
|
9157
|
-
message:
|
|
9158
|
-
|
|
9159
|
-
|
|
8871
|
+
message: message => {
|
|
8872
|
+
this.resetActivityCheck();
|
|
8873
|
+
this.emit('message', message);
|
|
9160
8874
|
},
|
|
9161
|
-
ping:
|
|
9162
|
-
|
|
8875
|
+
ping: () => {
|
|
8876
|
+
this.send_event('pusher:pong', {});
|
|
9163
8877
|
},
|
|
9164
|
-
activity:
|
|
9165
|
-
|
|
8878
|
+
activity: () => {
|
|
8879
|
+
this.resetActivityCheck();
|
|
9166
8880
|
},
|
|
9167
|
-
error:
|
|
9168
|
-
|
|
8881
|
+
error: error => {
|
|
8882
|
+
this.emit('error', error);
|
|
9169
8883
|
},
|
|
9170
|
-
closed:
|
|
9171
|
-
|
|
9172
|
-
if (
|
|
9173
|
-
|
|
8884
|
+
closed: () => {
|
|
8885
|
+
this.abandonConnection();
|
|
8886
|
+
if (this.shouldRetry()) {
|
|
8887
|
+
this.retryIn(1000);
|
|
9174
8888
|
}
|
|
9175
8889
|
}
|
|
9176
8890
|
});
|
|
9177
|
-
}
|
|
9178
|
-
|
|
9179
|
-
var _this = this;
|
|
8891
|
+
}
|
|
8892
|
+
buildHandshakeCallbacks(errorCallbacks) {
|
|
9180
8893
|
return extend({}, errorCallbacks, {
|
|
9181
|
-
connected:
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
8894
|
+
connected: (handshake) => {
|
|
8895
|
+
this.activityTimeout = Math.min(this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
|
|
8896
|
+
this.clearUnavailableTimer();
|
|
8897
|
+
this.setConnection(handshake.connection);
|
|
8898
|
+
this.socket_id = this.connection.id;
|
|
8899
|
+
this.updateState('connected', { socket_id: this.socket_id });
|
|
9187
8900
|
}
|
|
9188
8901
|
});
|
|
9189
|
-
}
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
return function (result) {
|
|
8902
|
+
}
|
|
8903
|
+
buildErrorCallbacks() {
|
|
8904
|
+
let withErrorEmitted = callback => {
|
|
8905
|
+
return (result) => {
|
|
9194
8906
|
if (result.error) {
|
|
9195
|
-
|
|
8907
|
+
this.emit('error', { type: 'WebSocketError', error: result.error });
|
|
9196
8908
|
}
|
|
9197
8909
|
callback(result);
|
|
9198
8910
|
};
|
|
9199
8911
|
};
|
|
9200
8912
|
return {
|
|
9201
|
-
tls_only: withErrorEmitted(
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
8913
|
+
tls_only: withErrorEmitted(() => {
|
|
8914
|
+
this.usingTLS = true;
|
|
8915
|
+
this.updateStrategy();
|
|
8916
|
+
this.retryIn(0);
|
|
9205
8917
|
}),
|
|
9206
|
-
refused: withErrorEmitted(
|
|
9207
|
-
|
|
8918
|
+
refused: withErrorEmitted(() => {
|
|
8919
|
+
this.disconnect();
|
|
9208
8920
|
}),
|
|
9209
|
-
backoff: withErrorEmitted(
|
|
9210
|
-
|
|
8921
|
+
backoff: withErrorEmitted(() => {
|
|
8922
|
+
this.retryIn(1000);
|
|
9211
8923
|
}),
|
|
9212
|
-
retry: withErrorEmitted(
|
|
9213
|
-
|
|
8924
|
+
retry: withErrorEmitted(() => {
|
|
8925
|
+
this.retryIn(0);
|
|
9214
8926
|
})
|
|
9215
8927
|
};
|
|
9216
|
-
}
|
|
9217
|
-
|
|
8928
|
+
}
|
|
8929
|
+
setConnection(connection) {
|
|
9218
8930
|
this.connection = connection;
|
|
9219
8931
|
for (var event in this.connectionCallbacks) {
|
|
9220
8932
|
this.connection.bind(event, this.connectionCallbacks[event]);
|
|
9221
8933
|
}
|
|
9222
8934
|
this.resetActivityCheck();
|
|
9223
|
-
}
|
|
9224
|
-
|
|
8935
|
+
}
|
|
8936
|
+
abandonConnection() {
|
|
9225
8937
|
if (!this.connection) {
|
|
9226
8938
|
return;
|
|
9227
8939
|
}
|
|
@@ -9232,8 +8944,8 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
9232
8944
|
var connection = this.connection;
|
|
9233
8945
|
this.connection = null;
|
|
9234
8946
|
return connection;
|
|
9235
|
-
}
|
|
9236
|
-
|
|
8947
|
+
}
|
|
8948
|
+
updateState(newState, data) {
|
|
9237
8949
|
var previousState = this.state;
|
|
9238
8950
|
this.state = newState;
|
|
9239
8951
|
if (previousState !== newState) {
|
|
@@ -9246,56 +8958,52 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
9246
8958
|
this.emit('state_change', { previous: previousState, current: newState });
|
|
9247
8959
|
this.emit(newState, data);
|
|
9248
8960
|
}
|
|
9249
|
-
}
|
|
9250
|
-
|
|
8961
|
+
}
|
|
8962
|
+
shouldRetry() {
|
|
9251
8963
|
return this.state === 'connecting' || this.state === 'connected';
|
|
9252
|
-
}
|
|
9253
|
-
|
|
9254
|
-
}(dispatcher));
|
|
9255
|
-
/* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
|
|
8964
|
+
}
|
|
8965
|
+
}
|
|
9256
8966
|
|
|
9257
8967
|
// CONCATENATED MODULE: ./src/core/channels/channels.ts
|
|
9258
8968
|
|
|
9259
8969
|
|
|
9260
8970
|
|
|
9261
8971
|
|
|
9262
|
-
|
|
9263
|
-
|
|
8972
|
+
class channels_Channels {
|
|
8973
|
+
constructor() {
|
|
9264
8974
|
this.channels = {};
|
|
9265
8975
|
}
|
|
9266
|
-
|
|
8976
|
+
add(name, pusher) {
|
|
9267
8977
|
if (!this.channels[name]) {
|
|
9268
8978
|
this.channels[name] = createChannel(name, pusher);
|
|
9269
8979
|
}
|
|
9270
8980
|
return this.channels[name];
|
|
9271
|
-
}
|
|
9272
|
-
|
|
8981
|
+
}
|
|
8982
|
+
all() {
|
|
9273
8983
|
return values(this.channels);
|
|
9274
|
-
}
|
|
9275
|
-
|
|
8984
|
+
}
|
|
8985
|
+
find(name) {
|
|
9276
8986
|
return this.channels[name];
|
|
9277
|
-
}
|
|
9278
|
-
|
|
8987
|
+
}
|
|
8988
|
+
remove(name) {
|
|
9279
8989
|
var channel = this.channels[name];
|
|
9280
8990
|
delete this.channels[name];
|
|
9281
8991
|
return channel;
|
|
9282
|
-
}
|
|
9283
|
-
|
|
8992
|
+
}
|
|
8993
|
+
disconnect() {
|
|
9284
8994
|
objectApply(this.channels, function (channel) {
|
|
9285
8995
|
channel.disconnect();
|
|
9286
8996
|
});
|
|
9287
|
-
}
|
|
9288
|
-
|
|
9289
|
-
}());
|
|
9290
|
-
/* harmony default export */ var channels = (channels_Channels);
|
|
8997
|
+
}
|
|
8998
|
+
}
|
|
9291
8999
|
function createChannel(name, pusher) {
|
|
9292
9000
|
if (name.indexOf('private-encrypted-') === 0) {
|
|
9293
9001
|
if (pusher.config.nacl) {
|
|
9294
9002
|
return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);
|
|
9295
9003
|
}
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
throw new UnsupportedFeature(errMsg
|
|
9004
|
+
let errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';
|
|
9005
|
+
let suffix = url_store.buildLogSuffix('encryptedChannelSupport');
|
|
9006
|
+
throw new UnsupportedFeature(`${errMsg}. ${suffix}`);
|
|
9299
9007
|
}
|
|
9300
9008
|
else if (name.indexOf('private-') === 0) {
|
|
9301
9009
|
return factory.createPrivateChannel(name, pusher);
|
|
@@ -9322,97 +9030,94 @@ function createChannel(name, pusher) {
|
|
|
9322
9030
|
|
|
9323
9031
|
|
|
9324
9032
|
var Factory = {
|
|
9325
|
-
createChannels
|
|
9326
|
-
return new
|
|
9033
|
+
createChannels() {
|
|
9034
|
+
return new channels_Channels();
|
|
9327
9035
|
},
|
|
9328
|
-
createConnectionManager
|
|
9329
|
-
return new
|
|
9036
|
+
createConnectionManager(key, options) {
|
|
9037
|
+
return new connection_manager_ConnectionManager(key, options);
|
|
9330
9038
|
},
|
|
9331
|
-
createChannel
|
|
9332
|
-
return new
|
|
9039
|
+
createChannel(name, pusher) {
|
|
9040
|
+
return new channel_Channel(name, pusher);
|
|
9333
9041
|
},
|
|
9334
|
-
createPrivateChannel
|
|
9335
|
-
return new
|
|
9042
|
+
createPrivateChannel(name, pusher) {
|
|
9043
|
+
return new private_channel_PrivateChannel(name, pusher);
|
|
9336
9044
|
},
|
|
9337
|
-
createPresenceChannel
|
|
9338
|
-
return new
|
|
9045
|
+
createPresenceChannel(name, pusher) {
|
|
9046
|
+
return new presence_channel_PresenceChannel(name, pusher);
|
|
9339
9047
|
},
|
|
9340
|
-
createEncryptedChannel
|
|
9341
|
-
return new
|
|
9048
|
+
createEncryptedChannel(name, pusher, nacl) {
|
|
9049
|
+
return new encrypted_channel_EncryptedChannel(name, pusher, nacl);
|
|
9342
9050
|
},
|
|
9343
|
-
createTimelineSender
|
|
9344
|
-
return new
|
|
9051
|
+
createTimelineSender(timeline, options) {
|
|
9052
|
+
return new timeline_sender_TimelineSender(timeline, options);
|
|
9345
9053
|
},
|
|
9346
|
-
createHandshake
|
|
9347
|
-
return new
|
|
9054
|
+
createHandshake(transport, callback) {
|
|
9055
|
+
return new handshake_Handshake(transport, callback);
|
|
9348
9056
|
},
|
|
9349
|
-
createAssistantToTheTransportManager
|
|
9350
|
-
return new
|
|
9057
|
+
createAssistantToTheTransportManager(manager, transport, options) {
|
|
9058
|
+
return new assistant_to_the_transport_manager_AssistantToTheTransportManager(manager, transport, options);
|
|
9351
9059
|
}
|
|
9352
9060
|
};
|
|
9353
9061
|
/* harmony default export */ var factory = (Factory);
|
|
9354
9062
|
|
|
9355
9063
|
// CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
|
|
9356
9064
|
|
|
9357
|
-
|
|
9358
|
-
|
|
9065
|
+
class transport_manager_TransportManager {
|
|
9066
|
+
constructor(options) {
|
|
9359
9067
|
this.options = options || {};
|
|
9360
9068
|
this.livesLeft = this.options.lives || Infinity;
|
|
9361
9069
|
}
|
|
9362
|
-
|
|
9070
|
+
getAssistant(transport) {
|
|
9363
9071
|
return factory.createAssistantToTheTransportManager(this, transport, {
|
|
9364
9072
|
minPingDelay: this.options.minPingDelay,
|
|
9365
9073
|
maxPingDelay: this.options.maxPingDelay
|
|
9366
9074
|
});
|
|
9367
|
-
}
|
|
9368
|
-
|
|
9075
|
+
}
|
|
9076
|
+
isAlive() {
|
|
9369
9077
|
return this.livesLeft > 0;
|
|
9370
|
-
}
|
|
9371
|
-
|
|
9078
|
+
}
|
|
9079
|
+
reportDeath() {
|
|
9372
9080
|
this.livesLeft -= 1;
|
|
9373
|
-
}
|
|
9374
|
-
|
|
9375
|
-
}());
|
|
9376
|
-
/* harmony default export */ var transport_manager = (transport_manager_TransportManager);
|
|
9081
|
+
}
|
|
9082
|
+
}
|
|
9377
9083
|
|
|
9378
9084
|
// CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
|
|
9379
9085
|
|
|
9380
9086
|
|
|
9381
9087
|
|
|
9382
|
-
|
|
9383
|
-
|
|
9088
|
+
class sequential_strategy_SequentialStrategy {
|
|
9089
|
+
constructor(strategies, options) {
|
|
9384
9090
|
this.strategies = strategies;
|
|
9385
9091
|
this.loop = Boolean(options.loop);
|
|
9386
9092
|
this.failFast = Boolean(options.failFast);
|
|
9387
9093
|
this.timeout = options.timeout;
|
|
9388
9094
|
this.timeoutLimit = options.timeoutLimit;
|
|
9389
9095
|
}
|
|
9390
|
-
|
|
9096
|
+
isSupported() {
|
|
9391
9097
|
return any(this.strategies, util.method('isSupported'));
|
|
9392
|
-
}
|
|
9393
|
-
|
|
9394
|
-
var _this = this;
|
|
9098
|
+
}
|
|
9099
|
+
connect(minPriority, callback) {
|
|
9395
9100
|
var strategies = this.strategies;
|
|
9396
9101
|
var current = 0;
|
|
9397
9102
|
var timeout = this.timeout;
|
|
9398
9103
|
var runner = null;
|
|
9399
|
-
var tryNextStrategy =
|
|
9104
|
+
var tryNextStrategy = (error, handshake) => {
|
|
9400
9105
|
if (handshake) {
|
|
9401
9106
|
callback(null, handshake);
|
|
9402
9107
|
}
|
|
9403
9108
|
else {
|
|
9404
9109
|
current = current + 1;
|
|
9405
|
-
if (
|
|
9110
|
+
if (this.loop) {
|
|
9406
9111
|
current = current % strategies.length;
|
|
9407
9112
|
}
|
|
9408
9113
|
if (current < strategies.length) {
|
|
9409
9114
|
if (timeout) {
|
|
9410
9115
|
timeout = timeout * 2;
|
|
9411
|
-
if (
|
|
9412
|
-
timeout = Math.min(timeout,
|
|
9116
|
+
if (this.timeoutLimit) {
|
|
9117
|
+
timeout = Math.min(timeout, this.timeoutLimit);
|
|
9413
9118
|
}
|
|
9414
9119
|
}
|
|
9415
|
-
runner =
|
|
9120
|
+
runner = this.tryStrategy(strategies[current], minPriority, { timeout, failFast: this.failFast }, tryNextStrategy);
|
|
9416
9121
|
}
|
|
9417
9122
|
else {
|
|
9418
9123
|
callback(true);
|
|
@@ -9431,12 +9136,12 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
9431
9136
|
}
|
|
9432
9137
|
}
|
|
9433
9138
|
};
|
|
9434
|
-
}
|
|
9435
|
-
|
|
9139
|
+
}
|
|
9140
|
+
tryStrategy(strategy, minPriority, options, callback) {
|
|
9436
9141
|
var timer = null;
|
|
9437
9142
|
var runner = null;
|
|
9438
9143
|
if (options.timeout > 0) {
|
|
9439
|
-
timer = new
|
|
9144
|
+
timer = new timers_OneOffTimer(options.timeout, function () {
|
|
9440
9145
|
runner.abort();
|
|
9441
9146
|
callback(true);
|
|
9442
9147
|
});
|
|
@@ -9461,22 +9166,20 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
9461
9166
|
runner.forceMinPriority(p);
|
|
9462
9167
|
}
|
|
9463
9168
|
};
|
|
9464
|
-
}
|
|
9465
|
-
|
|
9466
|
-
}());
|
|
9467
|
-
/* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
|
|
9169
|
+
}
|
|
9170
|
+
}
|
|
9468
9171
|
|
|
9469
9172
|
// CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
|
|
9470
9173
|
|
|
9471
9174
|
|
|
9472
|
-
|
|
9473
|
-
|
|
9175
|
+
class best_connected_ever_strategy_BestConnectedEverStrategy {
|
|
9176
|
+
constructor(strategies) {
|
|
9474
9177
|
this.strategies = strategies;
|
|
9475
9178
|
}
|
|
9476
|
-
|
|
9179
|
+
isSupported() {
|
|
9477
9180
|
return any(this.strategies, util.method('isSupported'));
|
|
9478
|
-
}
|
|
9479
|
-
|
|
9181
|
+
}
|
|
9182
|
+
connect(minPriority, callback) {
|
|
9480
9183
|
return connect(this.strategies, minPriority, function (i, runners) {
|
|
9481
9184
|
return function (error, handshake) {
|
|
9482
9185
|
runners[i].error = error;
|
|
@@ -9492,10 +9195,8 @@ var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
|
|
|
9492
9195
|
callback(null, handshake);
|
|
9493
9196
|
};
|
|
9494
9197
|
});
|
|
9495
|
-
}
|
|
9496
|
-
|
|
9497
|
-
}());
|
|
9498
|
-
/* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
|
|
9198
|
+
}
|
|
9199
|
+
}
|
|
9499
9200
|
function connect(strategies, minPriority, callbackBuilder) {
|
|
9500
9201
|
var runners = map(strategies, function (strategy, i, _, rs) {
|
|
9501
9202
|
return strategy.connect(minPriority, callbackBuilder(i, rs));
|
|
@@ -9528,18 +9229,18 @@ function abortRunner(runner) {
|
|
|
9528
9229
|
|
|
9529
9230
|
|
|
9530
9231
|
|
|
9531
|
-
|
|
9532
|
-
|
|
9232
|
+
class cached_strategy_CachedStrategy {
|
|
9233
|
+
constructor(strategy, transports, options) {
|
|
9533
9234
|
this.strategy = strategy;
|
|
9534
9235
|
this.transports = transports;
|
|
9535
9236
|
this.ttl = options.ttl || 1800 * 1000;
|
|
9536
9237
|
this.usingTLS = options.useTLS;
|
|
9537
9238
|
this.timeline = options.timeline;
|
|
9538
9239
|
}
|
|
9539
|
-
|
|
9240
|
+
isSupported() {
|
|
9540
9241
|
return this.strategy.isSupported();
|
|
9541
|
-
}
|
|
9542
|
-
|
|
9242
|
+
}
|
|
9243
|
+
connect(minPriority, callback) {
|
|
9543
9244
|
var usingTLS = this.usingTLS;
|
|
9544
9245
|
var info = fetchTransportCache(usingTLS);
|
|
9545
9246
|
var strategies = [this.strategy];
|
|
@@ -9551,7 +9252,7 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
9551
9252
|
transport: info.transport,
|
|
9552
9253
|
latency: info.latency
|
|
9553
9254
|
});
|
|
9554
|
-
strategies.push(new
|
|
9255
|
+
strategies.push(new sequential_strategy_SequentialStrategy([transport], {
|
|
9555
9256
|
timeout: info.latency * 2 + 1000,
|
|
9556
9257
|
failFast: true
|
|
9557
9258
|
}));
|
|
@@ -9587,10 +9288,8 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
9587
9288
|
}
|
|
9588
9289
|
}
|
|
9589
9290
|
};
|
|
9590
|
-
}
|
|
9591
|
-
|
|
9592
|
-
}());
|
|
9593
|
-
/* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
|
|
9291
|
+
}
|
|
9292
|
+
}
|
|
9594
9293
|
function getTransportCacheKey(usingTLS) {
|
|
9595
9294
|
return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');
|
|
9596
9295
|
}
|
|
@@ -9636,19 +9335,18 @@ function flushTransportCache(usingTLS) {
|
|
|
9636
9335
|
|
|
9637
9336
|
// CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
|
|
9638
9337
|
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
var number = _a.delay;
|
|
9338
|
+
class delayed_strategy_DelayedStrategy {
|
|
9339
|
+
constructor(strategy, { delay: number }) {
|
|
9642
9340
|
this.strategy = strategy;
|
|
9643
9341
|
this.options = { delay: number };
|
|
9644
9342
|
}
|
|
9645
|
-
|
|
9343
|
+
isSupported() {
|
|
9646
9344
|
return this.strategy.isSupported();
|
|
9647
|
-
}
|
|
9648
|
-
|
|
9345
|
+
}
|
|
9346
|
+
connect(minPriority, callback) {
|
|
9649
9347
|
var strategy = this.strategy;
|
|
9650
9348
|
var runner;
|
|
9651
|
-
var timer = new
|
|
9349
|
+
var timer = new timers_OneOffTimer(this.options.delay, function () {
|
|
9652
9350
|
runner = strategy.connect(minPriority, callback);
|
|
9653
9351
|
});
|
|
9654
9352
|
return {
|
|
@@ -9665,39 +9363,35 @@ var delayed_strategy_DelayedStrategy = (function () {
|
|
|
9665
9363
|
}
|
|
9666
9364
|
}
|
|
9667
9365
|
};
|
|
9668
|
-
}
|
|
9669
|
-
|
|
9670
|
-
}());
|
|
9671
|
-
/* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
|
|
9366
|
+
}
|
|
9367
|
+
}
|
|
9672
9368
|
|
|
9673
9369
|
// CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
|
|
9674
|
-
|
|
9675
|
-
|
|
9370
|
+
class IfStrategy {
|
|
9371
|
+
constructor(test, trueBranch, falseBranch) {
|
|
9676
9372
|
this.test = test;
|
|
9677
9373
|
this.trueBranch = trueBranch;
|
|
9678
9374
|
this.falseBranch = falseBranch;
|
|
9679
9375
|
}
|
|
9680
|
-
|
|
9376
|
+
isSupported() {
|
|
9681
9377
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
9682
9378
|
return branch.isSupported();
|
|
9683
|
-
}
|
|
9684
|
-
|
|
9379
|
+
}
|
|
9380
|
+
connect(minPriority, callback) {
|
|
9685
9381
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
9686
9382
|
return branch.connect(minPriority, callback);
|
|
9687
|
-
}
|
|
9688
|
-
|
|
9689
|
-
}());
|
|
9690
|
-
/* harmony default export */ var if_strategy = (IfStrategy);
|
|
9383
|
+
}
|
|
9384
|
+
}
|
|
9691
9385
|
|
|
9692
9386
|
// CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
|
|
9693
|
-
|
|
9694
|
-
|
|
9387
|
+
class FirstConnectedStrategy {
|
|
9388
|
+
constructor(strategy) {
|
|
9695
9389
|
this.strategy = strategy;
|
|
9696
9390
|
}
|
|
9697
|
-
|
|
9391
|
+
isSupported() {
|
|
9698
9392
|
return this.strategy.isSupported();
|
|
9699
|
-
}
|
|
9700
|
-
|
|
9393
|
+
}
|
|
9394
|
+
connect(minPriority, callback) {
|
|
9701
9395
|
var runner = this.strategy.connect(minPriority, function (error, handshake) {
|
|
9702
9396
|
if (handshake) {
|
|
9703
9397
|
runner.abort();
|
|
@@ -9705,10 +9399,8 @@ var FirstConnectedStrategy = (function () {
|
|
|
9705
9399
|
callback(error, handshake);
|
|
9706
9400
|
});
|
|
9707
9401
|
return runner;
|
|
9708
|
-
}
|
|
9709
|
-
|
|
9710
|
-
}());
|
|
9711
|
-
/* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
|
|
9402
|
+
}
|
|
9403
|
+
}
|
|
9712
9404
|
|
|
9713
9405
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/default_strategy.ts
|
|
9714
9406
|
|
|
@@ -9749,12 +9441,11 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
9749
9441
|
timeout: 15000,
|
|
9750
9442
|
timeoutLimit: 60000
|
|
9751
9443
|
};
|
|
9752
|
-
var ws_manager = new
|
|
9753
|
-
lives: 2,
|
|
9444
|
+
var ws_manager = new transport_manager_TransportManager({
|
|
9754
9445
|
minPingDelay: 10000,
|
|
9755
9446
|
maxPingDelay: config.activityTimeout
|
|
9756
9447
|
});
|
|
9757
|
-
var streaming_manager = new
|
|
9448
|
+
var streaming_manager = new transport_manager_TransportManager({
|
|
9758
9449
|
lives: 2,
|
|
9759
9450
|
minPingDelay: 10000,
|
|
9760
9451
|
maxPingDelay: config.activityTimeout
|
|
@@ -9763,31 +9454,31 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
9763
9454
|
var wss_transport = defineTransportStrategy('wss', 'ws', 3, wss_options, ws_manager);
|
|
9764
9455
|
var xhr_streaming_transport = defineTransportStrategy('xhr_streaming', 'xhr_streaming', 1, http_options, streaming_manager);
|
|
9765
9456
|
var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, http_options);
|
|
9766
|
-
var ws_loop = new
|
|
9767
|
-
var wss_loop = new
|
|
9768
|
-
var streaming_loop = new
|
|
9769
|
-
var polling_loop = new
|
|
9770
|
-
var http_loop = new
|
|
9771
|
-
new
|
|
9457
|
+
var ws_loop = new sequential_strategy_SequentialStrategy([ws_transport], timeouts);
|
|
9458
|
+
var wss_loop = new sequential_strategy_SequentialStrategy([wss_transport], timeouts);
|
|
9459
|
+
var streaming_loop = new sequential_strategy_SequentialStrategy([xhr_streaming_transport], timeouts);
|
|
9460
|
+
var polling_loop = new sequential_strategy_SequentialStrategy([xhr_polling_transport], timeouts);
|
|
9461
|
+
var http_loop = new sequential_strategy_SequentialStrategy([
|
|
9462
|
+
new IfStrategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
9772
9463
|
streaming_loop,
|
|
9773
|
-
new
|
|
9464
|
+
new delayed_strategy_DelayedStrategy(polling_loop, { delay: 4000 })
|
|
9774
9465
|
]), polling_loop)
|
|
9775
9466
|
], timeouts);
|
|
9776
9467
|
var wsStrategy;
|
|
9777
9468
|
if (baseOptions.useTLS) {
|
|
9778
|
-
wsStrategy = new
|
|
9469
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
9779
9470
|
ws_loop,
|
|
9780
|
-
new
|
|
9471
|
+
new delayed_strategy_DelayedStrategy(http_loop, { delay: 2000 })
|
|
9781
9472
|
]);
|
|
9782
9473
|
}
|
|
9783
9474
|
else {
|
|
9784
|
-
wsStrategy = new
|
|
9475
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
9785
9476
|
ws_loop,
|
|
9786
|
-
new
|
|
9787
|
-
new
|
|
9477
|
+
new delayed_strategy_DelayedStrategy(wss_loop, { delay: 2000 }),
|
|
9478
|
+
new delayed_strategy_DelayedStrategy(http_loop, { delay: 5000 })
|
|
9788
9479
|
]);
|
|
9789
9480
|
}
|
|
9790
|
-
return new
|
|
9481
|
+
return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)), definedTransports, {
|
|
9791
9482
|
ttl: 1800000,
|
|
9792
9483
|
timeline: baseOptions.timeline,
|
|
9793
9484
|
useTLS: baseOptions.useTLS
|
|
@@ -9810,37 +9501,21 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
9810
9501
|
});
|
|
9811
9502
|
|
|
9812
9503
|
// CONCATENATED MODULE: ./src/core/http/http_request.ts
|
|
9813
|
-
var http_request_extends = (undefined && undefined.__extends) || (function () {
|
|
9814
|
-
var extendStatics = function (d, b) {
|
|
9815
|
-
extendStatics = Object.setPrototypeOf ||
|
|
9816
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
9817
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
9818
|
-
return extendStatics(d, b);
|
|
9819
|
-
};
|
|
9820
|
-
return function (d, b) {
|
|
9821
|
-
extendStatics(d, b);
|
|
9822
|
-
function __() { this.constructor = d; }
|
|
9823
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
9824
|
-
};
|
|
9825
|
-
})();
|
|
9826
9504
|
|
|
9827
9505
|
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
_this.url = url;
|
|
9836
|
-
return _this;
|
|
9506
|
+
const MAX_BUFFER_LENGTH = 256 * 1024;
|
|
9507
|
+
class http_request_HTTPRequest extends dispatcher_Dispatcher {
|
|
9508
|
+
constructor(hooks, method, url) {
|
|
9509
|
+
super();
|
|
9510
|
+
this.hooks = hooks;
|
|
9511
|
+
this.method = method;
|
|
9512
|
+
this.url = url;
|
|
9837
9513
|
}
|
|
9838
|
-
|
|
9839
|
-
var _this = this;
|
|
9514
|
+
start(payload) {
|
|
9840
9515
|
this.position = 0;
|
|
9841
9516
|
this.xhr = this.hooks.getRequest(this);
|
|
9842
|
-
this.unloader =
|
|
9843
|
-
|
|
9517
|
+
this.unloader = () => {
|
|
9518
|
+
this.close();
|
|
9844
9519
|
};
|
|
9845
9520
|
node_runtime.addUnloadListener(this.unloader);
|
|
9846
9521
|
this.xhr.open(this.method, this.url, true);
|
|
@@ -9848,8 +9523,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
9848
9523
|
this.xhr.setRequestHeader('Content-Type', 'application/json');
|
|
9849
9524
|
}
|
|
9850
9525
|
this.xhr.send(payload);
|
|
9851
|
-
}
|
|
9852
|
-
|
|
9526
|
+
}
|
|
9527
|
+
close() {
|
|
9853
9528
|
if (this.unloader) {
|
|
9854
9529
|
node_runtime.removeUnloadListener(this.unloader);
|
|
9855
9530
|
this.unloader = null;
|
|
@@ -9858,8 +9533,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
9858
9533
|
this.hooks.abortRequest(this.xhr);
|
|
9859
9534
|
this.xhr = null;
|
|
9860
9535
|
}
|
|
9861
|
-
}
|
|
9862
|
-
|
|
9536
|
+
}
|
|
9537
|
+
onChunk(status, data) {
|
|
9863
9538
|
while (true) {
|
|
9864
9539
|
var chunk = this.advanceBuffer(data);
|
|
9865
9540
|
if (chunk) {
|
|
@@ -9872,8 +9547,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
9872
9547
|
if (this.isBufferTooLong(data)) {
|
|
9873
9548
|
this.emit('buffer_too_long');
|
|
9874
9549
|
}
|
|
9875
|
-
}
|
|
9876
|
-
|
|
9550
|
+
}
|
|
9551
|
+
advanceBuffer(buffer) {
|
|
9877
9552
|
var unreadData = buffer.slice(this.position);
|
|
9878
9553
|
var endOfLinePosition = unreadData.indexOf('\n');
|
|
9879
9554
|
if (endOfLinePosition !== -1) {
|
|
@@ -9883,13 +9558,11 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
9883
9558
|
else {
|
|
9884
9559
|
return null;
|
|
9885
9560
|
}
|
|
9886
|
-
}
|
|
9887
|
-
|
|
9561
|
+
}
|
|
9562
|
+
isBufferTooLong(buffer) {
|
|
9888
9563
|
return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
|
|
9889
|
-
}
|
|
9890
|
-
|
|
9891
|
-
}(dispatcher));
|
|
9892
|
-
/* harmony default export */ var http_request = (http_request_HTTPRequest);
|
|
9564
|
+
}
|
|
9565
|
+
}
|
|
9893
9566
|
|
|
9894
9567
|
// CONCATENATED MODULE: ./src/core/http/state.ts
|
|
9895
9568
|
var State;
|
|
@@ -9905,24 +9578,24 @@ var State;
|
|
|
9905
9578
|
|
|
9906
9579
|
|
|
9907
9580
|
var autoIncrement = 1;
|
|
9908
|
-
|
|
9909
|
-
|
|
9581
|
+
class http_socket_HTTPSocket {
|
|
9582
|
+
constructor(hooks, url) {
|
|
9910
9583
|
this.hooks = hooks;
|
|
9911
9584
|
this.session = randomNumber(1000) + '/' + randomString(8);
|
|
9912
9585
|
this.location = getLocation(url);
|
|
9913
9586
|
this.readyState = state.CONNECTING;
|
|
9914
9587
|
this.openStream();
|
|
9915
9588
|
}
|
|
9916
|
-
|
|
9589
|
+
send(payload) {
|
|
9917
9590
|
return this.sendRaw(JSON.stringify([payload]));
|
|
9918
|
-
}
|
|
9919
|
-
|
|
9591
|
+
}
|
|
9592
|
+
ping() {
|
|
9920
9593
|
this.hooks.sendHeartbeat(this);
|
|
9921
|
-
}
|
|
9922
|
-
|
|
9594
|
+
}
|
|
9595
|
+
close(code, reason) {
|
|
9923
9596
|
this.onClose(code, reason, true);
|
|
9924
|
-
}
|
|
9925
|
-
|
|
9597
|
+
}
|
|
9598
|
+
sendRaw(payload) {
|
|
9926
9599
|
if (this.readyState === state.OPEN) {
|
|
9927
9600
|
try {
|
|
9928
9601
|
node_runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);
|
|
@@ -9935,12 +9608,12 @@ var http_socket_HTTPSocket = (function () {
|
|
|
9935
9608
|
else {
|
|
9936
9609
|
return false;
|
|
9937
9610
|
}
|
|
9938
|
-
}
|
|
9939
|
-
|
|
9611
|
+
}
|
|
9612
|
+
reconnect() {
|
|
9940
9613
|
this.closeStream();
|
|
9941
9614
|
this.openStream();
|
|
9942
|
-
}
|
|
9943
|
-
|
|
9615
|
+
}
|
|
9616
|
+
onClose(code, reason, wasClean) {
|
|
9944
9617
|
this.closeStream();
|
|
9945
9618
|
this.readyState = state.CLOSED;
|
|
9946
9619
|
if (this.onclose) {
|
|
@@ -9950,8 +9623,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
9950
9623
|
wasClean: wasClean
|
|
9951
9624
|
});
|
|
9952
9625
|
}
|
|
9953
|
-
}
|
|
9954
|
-
|
|
9626
|
+
}
|
|
9627
|
+
onChunk(chunk) {
|
|
9955
9628
|
if (chunk.status !== 200) {
|
|
9956
9629
|
return;
|
|
9957
9630
|
}
|
|
@@ -9983,8 +9656,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
9983
9656
|
this.onClose(payload[0], payload[1], true);
|
|
9984
9657
|
break;
|
|
9985
9658
|
}
|
|
9986
|
-
}
|
|
9987
|
-
|
|
9659
|
+
}
|
|
9660
|
+
onOpen(options) {
|
|
9988
9661
|
if (this.readyState === state.CONNECTING) {
|
|
9989
9662
|
if (options && options.hostname) {
|
|
9990
9663
|
this.location.base = replaceHost(this.location.base, options.hostname);
|
|
@@ -9997,53 +9670,51 @@ var http_socket_HTTPSocket = (function () {
|
|
|
9997
9670
|
else {
|
|
9998
9671
|
this.onClose(1006, 'Server lost session', true);
|
|
9999
9672
|
}
|
|
10000
|
-
}
|
|
10001
|
-
|
|
9673
|
+
}
|
|
9674
|
+
onEvent(event) {
|
|
10002
9675
|
if (this.readyState === state.OPEN && this.onmessage) {
|
|
10003
9676
|
this.onmessage({ data: event });
|
|
10004
9677
|
}
|
|
10005
|
-
}
|
|
10006
|
-
|
|
9678
|
+
}
|
|
9679
|
+
onActivity() {
|
|
10007
9680
|
if (this.onactivity) {
|
|
10008
9681
|
this.onactivity();
|
|
10009
9682
|
}
|
|
10010
|
-
}
|
|
10011
|
-
|
|
9683
|
+
}
|
|
9684
|
+
onError(error) {
|
|
10012
9685
|
if (this.onerror) {
|
|
10013
9686
|
this.onerror(error);
|
|
10014
9687
|
}
|
|
10015
|
-
}
|
|
10016
|
-
|
|
10017
|
-
var _this = this;
|
|
9688
|
+
}
|
|
9689
|
+
openStream() {
|
|
10018
9690
|
this.stream = node_runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
|
|
10019
|
-
this.stream.bind('chunk',
|
|
10020
|
-
|
|
9691
|
+
this.stream.bind('chunk', chunk => {
|
|
9692
|
+
this.onChunk(chunk);
|
|
10021
9693
|
});
|
|
10022
|
-
this.stream.bind('finished',
|
|
10023
|
-
|
|
9694
|
+
this.stream.bind('finished', status => {
|
|
9695
|
+
this.hooks.onFinished(this, status);
|
|
10024
9696
|
});
|
|
10025
|
-
this.stream.bind('buffer_too_long',
|
|
10026
|
-
|
|
9697
|
+
this.stream.bind('buffer_too_long', () => {
|
|
9698
|
+
this.reconnect();
|
|
10027
9699
|
});
|
|
10028
9700
|
try {
|
|
10029
9701
|
this.stream.start();
|
|
10030
9702
|
}
|
|
10031
9703
|
catch (error) {
|
|
10032
|
-
util.defer(
|
|
10033
|
-
|
|
10034
|
-
|
|
9704
|
+
util.defer(() => {
|
|
9705
|
+
this.onError(error);
|
|
9706
|
+
this.onClose(1006, 'Could not start streaming', false);
|
|
10035
9707
|
});
|
|
10036
9708
|
}
|
|
10037
|
-
}
|
|
10038
|
-
|
|
9709
|
+
}
|
|
9710
|
+
closeStream() {
|
|
10039
9711
|
if (this.stream) {
|
|
10040
9712
|
this.stream.unbind_all();
|
|
10041
9713
|
this.stream.close();
|
|
10042
9714
|
this.stream = null;
|
|
10043
9715
|
}
|
|
10044
|
-
}
|
|
10045
|
-
|
|
10046
|
-
}());
|
|
9716
|
+
}
|
|
9717
|
+
}
|
|
10047
9718
|
function getLocation(url) {
|
|
10048
9719
|
var parts = /([^\?]*)\/*(\??.*)/.exec(url);
|
|
10049
9720
|
return {
|
|
@@ -10150,20 +9821,20 @@ var http_xhr_request_hooks = {
|
|
|
10150
9821
|
|
|
10151
9822
|
|
|
10152
9823
|
var HTTP = {
|
|
10153
|
-
createStreamingSocket
|
|
9824
|
+
createStreamingSocket(url) {
|
|
10154
9825
|
return this.createSocket(http_streaming_socket, url);
|
|
10155
9826
|
},
|
|
10156
|
-
createPollingSocket
|
|
9827
|
+
createPollingSocket(url) {
|
|
10157
9828
|
return this.createSocket(http_polling_socket, url);
|
|
10158
9829
|
},
|
|
10159
|
-
createSocket
|
|
9830
|
+
createSocket(hooks, url) {
|
|
10160
9831
|
return new http_socket(hooks, url);
|
|
10161
9832
|
},
|
|
10162
|
-
createXHR
|
|
9833
|
+
createXHR(method, url) {
|
|
10163
9834
|
return this.createRequest(http_xhr_request, method, url);
|
|
10164
9835
|
},
|
|
10165
|
-
createRequest
|
|
10166
|
-
return new
|
|
9836
|
+
createRequest(hooks, method, url) {
|
|
9837
|
+
return new http_request_HTTPRequest(hooks, method, url);
|
|
10167
9838
|
}
|
|
10168
9839
|
};
|
|
10169
9840
|
/* harmony default export */ var http_http = (HTTP);
|
|
@@ -10179,24 +9850,24 @@ var Isomorphic = {
|
|
|
10179
9850
|
Transports: transports,
|
|
10180
9851
|
transportConnectionInitializer: transport_connection_initializer,
|
|
10181
9852
|
HTTPFactory: http_http,
|
|
10182
|
-
setup
|
|
9853
|
+
setup(PusherClass) {
|
|
10183
9854
|
PusherClass.ready();
|
|
10184
9855
|
},
|
|
10185
|
-
getLocalStorage
|
|
9856
|
+
getLocalStorage() {
|
|
10186
9857
|
return undefined;
|
|
10187
9858
|
},
|
|
10188
|
-
getClientFeatures
|
|
9859
|
+
getClientFeatures() {
|
|
10189
9860
|
return keys(filterObject({ ws: transports.ws }, function (t) {
|
|
10190
9861
|
return t.isSupported({});
|
|
10191
9862
|
}));
|
|
10192
9863
|
},
|
|
10193
|
-
getProtocol
|
|
9864
|
+
getProtocol() {
|
|
10194
9865
|
return 'http:';
|
|
10195
9866
|
},
|
|
10196
|
-
isXHRSupported
|
|
9867
|
+
isXHRSupported() {
|
|
10197
9868
|
return true;
|
|
10198
9869
|
},
|
|
10199
|
-
createSocketRequest
|
|
9870
|
+
createSocketRequest(method, url) {
|
|
10200
9871
|
if (this.isXHRSupported()) {
|
|
10201
9872
|
return this.HTTPFactory.createXHR(method, url);
|
|
10202
9873
|
}
|
|
@@ -10204,16 +9875,16 @@ var Isomorphic = {
|
|
|
10204
9875
|
throw 'Cross-origin HTTP requests are not supported';
|
|
10205
9876
|
}
|
|
10206
9877
|
},
|
|
10207
|
-
createXHR
|
|
9878
|
+
createXHR() {
|
|
10208
9879
|
var Constructor = this.getXHRAPI();
|
|
10209
9880
|
return new Constructor();
|
|
10210
9881
|
},
|
|
10211
|
-
createWebSocket
|
|
9882
|
+
createWebSocket(url) {
|
|
10212
9883
|
var Constructor = this.getWebSocketAPI();
|
|
10213
9884
|
return new Constructor(url);
|
|
10214
9885
|
},
|
|
10215
|
-
addUnloadListener
|
|
10216
|
-
removeUnloadListener
|
|
9886
|
+
addUnloadListener(listener) { },
|
|
9887
|
+
removeUnloadListener(listener) { }
|
|
10217
9888
|
};
|
|
10218
9889
|
/* harmony default export */ var runtime = (Isomorphic);
|
|
10219
9890
|
|
|
@@ -10224,32 +9895,13 @@ var websocket = __webpack_require__(18);
|
|
|
10224
9895
|
var XMLHttpRequest = __webpack_require__(19);
|
|
10225
9896
|
|
|
10226
9897
|
// CONCATENATED MODULE: ./src/runtimes/node/net_info.ts
|
|
10227
|
-
var net_info_extends = (undefined && undefined.__extends) || (function () {
|
|
10228
|
-
var extendStatics = function (d, b) {
|
|
10229
|
-
extendStatics = Object.setPrototypeOf ||
|
|
10230
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10231
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
10232
|
-
return extendStatics(d, b);
|
|
10233
|
-
};
|
|
10234
|
-
return function (d, b) {
|
|
10235
|
-
extendStatics(d, b);
|
|
10236
|
-
function __() { this.constructor = d; }
|
|
10237
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
10238
|
-
};
|
|
10239
|
-
})();
|
|
10240
9898
|
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
function NetInfo() {
|
|
10244
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
10245
|
-
}
|
|
10246
|
-
NetInfo.prototype.isOnline = function () {
|
|
9899
|
+
class net_info_NetInfo extends dispatcher_Dispatcher {
|
|
9900
|
+
isOnline() {
|
|
10247
9901
|
return true;
|
|
10248
|
-
}
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
var net_info_Network = new NetInfo();
|
|
9902
|
+
}
|
|
9903
|
+
}
|
|
9904
|
+
var net_info_Network = new net_info_NetInfo();
|
|
10253
9905
|
|
|
10254
9906
|
// CONCATENATED MODULE: ./src/core/auth/options.ts
|
|
10255
9907
|
var AuthRequestType;
|
|
@@ -10263,15 +9915,15 @@ var AuthRequestType;
|
|
|
10263
9915
|
|
|
10264
9916
|
|
|
10265
9917
|
|
|
10266
|
-
|
|
10267
|
-
|
|
9918
|
+
const ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
9919
|
+
const xhr = node_runtime.createXHR();
|
|
10268
9920
|
xhr.open('POST', authOptions.endpoint, true);
|
|
10269
9921
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
10270
9922
|
for (var headerName in authOptions.headers) {
|
|
10271
9923
|
xhr.setRequestHeader(headerName, authOptions.headers[headerName]);
|
|
10272
9924
|
}
|
|
10273
9925
|
if (authOptions.headersProvider != null) {
|
|
10274
|
-
|
|
9926
|
+
let dynamicHeaders = authOptions.headersProvider();
|
|
10275
9927
|
for (var headerName in dynamicHeaders) {
|
|
10276
9928
|
xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);
|
|
10277
9929
|
}
|
|
@@ -10279,31 +9931,31 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
|
10279
9931
|
xhr.onreadystatechange = function () {
|
|
10280
9932
|
if (xhr.readyState === 4) {
|
|
10281
9933
|
if (xhr.status === 200) {
|
|
10282
|
-
|
|
10283
|
-
|
|
9934
|
+
let data;
|
|
9935
|
+
let parsed = false;
|
|
10284
9936
|
try {
|
|
10285
9937
|
data = JSON.parse(xhr.responseText);
|
|
10286
9938
|
parsed = true;
|
|
10287
9939
|
}
|
|
10288
9940
|
catch (e) {
|
|
10289
|
-
callback(new HTTPAuthError(200,
|
|
9941
|
+
callback(new HTTPAuthError(200, `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${xhr.responseText}`), null);
|
|
10290
9942
|
}
|
|
10291
9943
|
if (parsed) {
|
|
10292
9944
|
callback(null, data);
|
|
10293
9945
|
}
|
|
10294
9946
|
}
|
|
10295
9947
|
else {
|
|
10296
|
-
|
|
9948
|
+
let suffix = '';
|
|
10297
9949
|
switch (authRequestType) {
|
|
10298
9950
|
case AuthRequestType.UserAuthentication:
|
|
10299
9951
|
suffix = url_store.buildLogSuffix('authenticationEndpoint');
|
|
10300
9952
|
break;
|
|
10301
9953
|
case AuthRequestType.ChannelAuthorization:
|
|
10302
|
-
suffix =
|
|
9954
|
+
suffix = `Clients must be authorized to join private or presence channels. ${url_store.buildLogSuffix('authorizationEndpoint')}`;
|
|
10303
9955
|
break;
|
|
10304
9956
|
}
|
|
10305
|
-
callback(new HTTPAuthError(xhr.status,
|
|
10306
|
-
|
|
9957
|
+
callback(new HTTPAuthError(xhr.status, `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +
|
|
9958
|
+
`received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`), null);
|
|
10307
9959
|
}
|
|
10308
9960
|
}
|
|
10309
9961
|
};
|
|
@@ -10326,16 +9978,16 @@ var getAgent = function (sender, useTLS) {
|
|
|
10326
9978
|
xhr.open('GET', url, true);
|
|
10327
9979
|
xhr.onreadystatechange = function () {
|
|
10328
9980
|
if (xhr.readyState === 4) {
|
|
10329
|
-
|
|
10330
|
-
if (
|
|
10331
|
-
logger.debug(
|
|
9981
|
+
let { status, responseText } = xhr;
|
|
9982
|
+
if (status !== 200) {
|
|
9983
|
+
logger.debug(`TimelineSender Error: received ${status} from stats.pusher.com`);
|
|
10332
9984
|
return;
|
|
10333
9985
|
}
|
|
10334
9986
|
try {
|
|
10335
|
-
var host = JSON.parse(responseText)
|
|
9987
|
+
var { host } = JSON.parse(responseText);
|
|
10336
9988
|
}
|
|
10337
9989
|
catch (e) {
|
|
10338
|
-
logger.debug(
|
|
9990
|
+
logger.debug(`TimelineSenderError: invalid response ${responseText}`);
|
|
10339
9991
|
}
|
|
10340
9992
|
if (host) {
|
|
10341
9993
|
sender.host = host;
|
|
@@ -10347,7 +9999,7 @@ var getAgent = function (sender, useTLS) {
|
|
|
10347
9999
|
};
|
|
10348
10000
|
var xhr_timeline_xhr = {
|
|
10349
10001
|
name: 'xhr',
|
|
10350
|
-
getAgent
|
|
10002
|
+
getAgent
|
|
10351
10003
|
};
|
|
10352
10004
|
/* harmony default export */ var xhr_timeline = (xhr_timeline_xhr);
|
|
10353
10005
|
|
|
@@ -10362,35 +10014,35 @@ var external_crypto_ = __webpack_require__(3);
|
|
|
10362
10014
|
|
|
10363
10015
|
|
|
10364
10016
|
|
|
10365
|
-
|
|
10366
|
-
|
|
10017
|
+
const { getDefaultStrategy: runtime_getDefaultStrategy, Transports: runtime_Transports, setup, getProtocol, isXHRSupported, getLocalStorage, createXHR, createWebSocket, addUnloadListener, removeUnloadListener, transportConnectionInitializer, createSocketRequest, HTTPFactory } = runtime;
|
|
10018
|
+
const NodeJS = {
|
|
10367
10019
|
getDefaultStrategy: runtime_getDefaultStrategy,
|
|
10368
10020
|
Transports: runtime_Transports,
|
|
10369
|
-
setup
|
|
10370
|
-
getProtocol
|
|
10371
|
-
isXHRSupported
|
|
10372
|
-
createSocketRequest
|
|
10373
|
-
getLocalStorage
|
|
10374
|
-
createXHR
|
|
10375
|
-
createWebSocket
|
|
10376
|
-
addUnloadListener
|
|
10377
|
-
removeUnloadListener
|
|
10378
|
-
transportConnectionInitializer
|
|
10379
|
-
HTTPFactory
|
|
10021
|
+
setup,
|
|
10022
|
+
getProtocol,
|
|
10023
|
+
isXHRSupported,
|
|
10024
|
+
createSocketRequest,
|
|
10025
|
+
getLocalStorage,
|
|
10026
|
+
createXHR,
|
|
10027
|
+
createWebSocket,
|
|
10028
|
+
addUnloadListener,
|
|
10029
|
+
removeUnloadListener,
|
|
10030
|
+
transportConnectionInitializer,
|
|
10031
|
+
HTTPFactory,
|
|
10380
10032
|
TimelineTransport: xhr_timeline,
|
|
10381
|
-
getAuthorizers
|
|
10033
|
+
getAuthorizers() {
|
|
10382
10034
|
return { ajax: xhr_auth };
|
|
10383
10035
|
},
|
|
10384
|
-
getWebSocketAPI
|
|
10036
|
+
getWebSocketAPI() {
|
|
10385
10037
|
return websocket["Client"];
|
|
10386
10038
|
},
|
|
10387
|
-
getXHRAPI
|
|
10039
|
+
getXHRAPI() {
|
|
10388
10040
|
return XMLHttpRequest["XMLHttpRequest"];
|
|
10389
10041
|
},
|
|
10390
|
-
getNetwork
|
|
10042
|
+
getNetwork() {
|
|
10391
10043
|
return net_info_Network;
|
|
10392
10044
|
},
|
|
10393
|
-
randomInt
|
|
10045
|
+
randomInt(max) {
|
|
10394
10046
|
return Object(external_crypto_["randomInt"])(max);
|
|
10395
10047
|
}
|
|
10396
10048
|
};
|
|
@@ -10409,8 +10061,8 @@ var TimelineLevel;
|
|
|
10409
10061
|
|
|
10410
10062
|
|
|
10411
10063
|
|
|
10412
|
-
|
|
10413
|
-
|
|
10064
|
+
class timeline_Timeline {
|
|
10065
|
+
constructor(key, session, options) {
|
|
10414
10066
|
this.key = key;
|
|
10415
10067
|
this.session = session;
|
|
10416
10068
|
this.events = [];
|
|
@@ -10418,28 +10070,27 @@ var timeline_Timeline = (function () {
|
|
|
10418
10070
|
this.sent = 0;
|
|
10419
10071
|
this.uniqueID = 0;
|
|
10420
10072
|
}
|
|
10421
|
-
|
|
10073
|
+
log(level, event) {
|
|
10422
10074
|
if (level <= this.options.level) {
|
|
10423
10075
|
this.events.push(extend({}, event, { timestamp: util.now() }));
|
|
10424
10076
|
if (this.options.limit && this.events.length > this.options.limit) {
|
|
10425
10077
|
this.events.shift();
|
|
10426
10078
|
}
|
|
10427
10079
|
}
|
|
10428
|
-
}
|
|
10429
|
-
|
|
10080
|
+
}
|
|
10081
|
+
error(event) {
|
|
10430
10082
|
this.log(timeline_level.ERROR, event);
|
|
10431
|
-
}
|
|
10432
|
-
|
|
10083
|
+
}
|
|
10084
|
+
info(event) {
|
|
10433
10085
|
this.log(timeline_level.INFO, event);
|
|
10434
|
-
}
|
|
10435
|
-
|
|
10086
|
+
}
|
|
10087
|
+
debug(event) {
|
|
10436
10088
|
this.log(timeline_level.DEBUG, event);
|
|
10437
|
-
}
|
|
10438
|
-
|
|
10089
|
+
}
|
|
10090
|
+
isEmpty() {
|
|
10439
10091
|
return this.events.length === 0;
|
|
10440
|
-
}
|
|
10441
|
-
|
|
10442
|
-
var _this = this;
|
|
10092
|
+
}
|
|
10093
|
+
send(sendfn, callback) {
|
|
10443
10094
|
var data = extend({
|
|
10444
10095
|
session: this.session,
|
|
10445
10096
|
bundle: this.sent + 1,
|
|
@@ -10451,43 +10102,40 @@ var timeline_Timeline = (function () {
|
|
|
10451
10102
|
timeline: this.events
|
|
10452
10103
|
}, this.options.params);
|
|
10453
10104
|
this.events = [];
|
|
10454
|
-
sendfn(data,
|
|
10105
|
+
sendfn(data, (error, result) => {
|
|
10455
10106
|
if (!error) {
|
|
10456
|
-
|
|
10107
|
+
this.sent++;
|
|
10457
10108
|
}
|
|
10458
10109
|
if (callback) {
|
|
10459
10110
|
callback(error, result);
|
|
10460
10111
|
}
|
|
10461
10112
|
});
|
|
10462
10113
|
return true;
|
|
10463
|
-
}
|
|
10464
|
-
|
|
10114
|
+
}
|
|
10115
|
+
generateUniqueID() {
|
|
10465
10116
|
this.uniqueID++;
|
|
10466
10117
|
return this.uniqueID;
|
|
10467
|
-
}
|
|
10468
|
-
|
|
10469
|
-
}());
|
|
10470
|
-
/* harmony default export */ var timeline_timeline = (timeline_Timeline);
|
|
10118
|
+
}
|
|
10119
|
+
}
|
|
10471
10120
|
|
|
10472
10121
|
// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
|
|
10473
10122
|
|
|
10474
10123
|
|
|
10475
10124
|
|
|
10476
10125
|
|
|
10477
|
-
|
|
10478
|
-
|
|
10126
|
+
class transport_strategy_TransportStrategy {
|
|
10127
|
+
constructor(name, priority, transport, options) {
|
|
10479
10128
|
this.name = name;
|
|
10480
10129
|
this.priority = priority;
|
|
10481
10130
|
this.transport = transport;
|
|
10482
10131
|
this.options = options || {};
|
|
10483
10132
|
}
|
|
10484
|
-
|
|
10133
|
+
isSupported() {
|
|
10485
10134
|
return this.transport.isSupported({
|
|
10486
10135
|
useTLS: this.options.useTLS
|
|
10487
10136
|
});
|
|
10488
|
-
}
|
|
10489
|
-
|
|
10490
|
-
var _this = this;
|
|
10137
|
+
}
|
|
10138
|
+
connect(minPriority, callback) {
|
|
10491
10139
|
if (!this.isSupported()) {
|
|
10492
10140
|
return failAttempt(new UnsupportedStrategy(), callback);
|
|
10493
10141
|
}
|
|
@@ -10530,7 +10178,7 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
10530
10178
|
transport.bind('closed', onClosed);
|
|
10531
10179
|
transport.initialize();
|
|
10532
10180
|
return {
|
|
10533
|
-
abort:
|
|
10181
|
+
abort: () => {
|
|
10534
10182
|
if (connected) {
|
|
10535
10183
|
return;
|
|
10536
10184
|
}
|
|
@@ -10542,11 +10190,11 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
10542
10190
|
transport.close();
|
|
10543
10191
|
}
|
|
10544
10192
|
},
|
|
10545
|
-
forceMinPriority:
|
|
10193
|
+
forceMinPriority: p => {
|
|
10546
10194
|
if (connected) {
|
|
10547
10195
|
return;
|
|
10548
10196
|
}
|
|
10549
|
-
if (
|
|
10197
|
+
if (this.priority < p) {
|
|
10550
10198
|
if (handshake) {
|
|
10551
10199
|
handshake.close();
|
|
10552
10200
|
}
|
|
@@ -10556,10 +10204,8 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
10556
10204
|
}
|
|
10557
10205
|
}
|
|
10558
10206
|
};
|
|
10559
|
-
}
|
|
10560
|
-
|
|
10561
|
-
}());
|
|
10562
|
-
/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
|
|
10207
|
+
}
|
|
10208
|
+
}
|
|
10563
10209
|
function failAttempt(error, callback) {
|
|
10564
10210
|
util.defer(function () {
|
|
10565
10211
|
callback(error);
|
|
@@ -10576,7 +10222,7 @@ function failAttempt(error, callback) {
|
|
|
10576
10222
|
|
|
10577
10223
|
|
|
10578
10224
|
|
|
10579
|
-
|
|
10225
|
+
const { Transports: strategy_builder_Transports } = node_runtime;
|
|
10580
10226
|
var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
|
|
10581
10227
|
var transportClass = strategy_builder_Transports[type];
|
|
10582
10228
|
if (!transportClass) {
|
|
@@ -10589,7 +10235,7 @@ var strategy_builder_defineTransport = function (config, name, type, priority, o
|
|
|
10589
10235
|
var transport;
|
|
10590
10236
|
if (enabled) {
|
|
10591
10237
|
options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);
|
|
10592
|
-
transport = new
|
|
10238
|
+
transport = new transport_strategy_TransportStrategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
|
|
10593
10239
|
}
|
|
10594
10240
|
else {
|
|
10595
10241
|
transport = strategy_builder_UnsupportedStrategy;
|
|
@@ -10630,7 +10276,7 @@ function validateOptions(options) {
|
|
|
10630
10276
|
// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts
|
|
10631
10277
|
|
|
10632
10278
|
|
|
10633
|
-
|
|
10279
|
+
const composeChannelQuery = (params, authOptions) => {
|
|
10634
10280
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
10635
10281
|
for (var key in authOptions.params) {
|
|
10636
10282
|
query +=
|
|
@@ -10640,7 +10286,7 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
10640
10286
|
encodeURIComponent(authOptions.params[key]);
|
|
10641
10287
|
}
|
|
10642
10288
|
if (authOptions.paramsProvider != null) {
|
|
10643
|
-
|
|
10289
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
10644
10290
|
for (var key in dynamicParams) {
|
|
10645
10291
|
query +=
|
|
10646
10292
|
'&' +
|
|
@@ -10651,12 +10297,12 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
10651
10297
|
}
|
|
10652
10298
|
return query;
|
|
10653
10299
|
};
|
|
10654
|
-
|
|
10300
|
+
const UserAuthenticator = (authOptions) => {
|
|
10655
10301
|
if (typeof node_runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
10656
|
-
throw
|
|
10302
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
10657
10303
|
}
|
|
10658
|
-
return
|
|
10659
|
-
|
|
10304
|
+
return (params, callback) => {
|
|
10305
|
+
const query = composeChannelQuery(params, authOptions);
|
|
10660
10306
|
node_runtime.getAuthorizers()[authOptions.transport](node_runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);
|
|
10661
10307
|
};
|
|
10662
10308
|
};
|
|
@@ -10665,7 +10311,7 @@ var UserAuthenticator = function (authOptions) {
|
|
|
10665
10311
|
// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts
|
|
10666
10312
|
|
|
10667
10313
|
|
|
10668
|
-
|
|
10314
|
+
const channel_authorizer_composeChannelQuery = (params, authOptions) => {
|
|
10669
10315
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
10670
10316
|
query += '&channel_name=' + encodeURIComponent(params.channelName);
|
|
10671
10317
|
for (var key in authOptions.params) {
|
|
@@ -10676,7 +10322,7 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
10676
10322
|
encodeURIComponent(authOptions.params[key]);
|
|
10677
10323
|
}
|
|
10678
10324
|
if (authOptions.paramsProvider != null) {
|
|
10679
|
-
|
|
10325
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
10680
10326
|
for (var key in dynamicParams) {
|
|
10681
10327
|
query +=
|
|
10682
10328
|
'&' +
|
|
@@ -10687,20 +10333,20 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
10687
10333
|
}
|
|
10688
10334
|
return query;
|
|
10689
10335
|
};
|
|
10690
|
-
|
|
10336
|
+
const ChannelAuthorizer = (authOptions) => {
|
|
10691
10337
|
if (typeof node_runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
10692
|
-
throw
|
|
10338
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
10693
10339
|
}
|
|
10694
|
-
return
|
|
10695
|
-
|
|
10340
|
+
return (params, callback) => {
|
|
10341
|
+
const query = channel_authorizer_composeChannelQuery(params, authOptions);
|
|
10696
10342
|
node_runtime.getAuthorizers()[authOptions.transport](node_runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);
|
|
10697
10343
|
};
|
|
10698
10344
|
};
|
|
10699
10345
|
/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);
|
|
10700
10346
|
|
|
10701
10347
|
// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts
|
|
10702
|
-
|
|
10703
|
-
|
|
10348
|
+
const ChannelAuthorizerProxy = (pusher, authOptions, channelAuthorizerGenerator) => {
|
|
10349
|
+
const deprecatedAuthorizerOptions = {
|
|
10704
10350
|
authTransport: authOptions.transport,
|
|
10705
10351
|
authEndpoint: authOptions.endpoint,
|
|
10706
10352
|
auth: {
|
|
@@ -10708,32 +10354,21 @@ var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGen
|
|
|
10708
10354
|
headers: authOptions.headers
|
|
10709
10355
|
}
|
|
10710
10356
|
};
|
|
10711
|
-
return
|
|
10712
|
-
|
|
10713
|
-
|
|
10357
|
+
return (params, callback) => {
|
|
10358
|
+
const channel = pusher.channel(params.channelName);
|
|
10359
|
+
const channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
|
|
10714
10360
|
channelAuthorizer.authorize(params.socketId, callback);
|
|
10715
10361
|
};
|
|
10716
10362
|
};
|
|
10717
10363
|
|
|
10718
10364
|
// CONCATENATED MODULE: ./src/core/config.ts
|
|
10719
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
10720
|
-
__assign = Object.assign || function(t) {
|
|
10721
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10722
|
-
s = arguments[i];
|
|
10723
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10724
|
-
t[p] = s[p];
|
|
10725
|
-
}
|
|
10726
|
-
return t;
|
|
10727
|
-
};
|
|
10728
|
-
return __assign.apply(this, arguments);
|
|
10729
|
-
};
|
|
10730
10365
|
|
|
10731
10366
|
|
|
10732
10367
|
|
|
10733
10368
|
|
|
10734
10369
|
|
|
10735
10370
|
function getConfig(opts, pusher) {
|
|
10736
|
-
|
|
10371
|
+
let config = {
|
|
10737
10372
|
activityTimeout: opts.activityTimeout || defaults.activityTimeout,
|
|
10738
10373
|
cluster: opts.cluster,
|
|
10739
10374
|
httpPath: opts.httpPath || defaults.httpPath,
|
|
@@ -10770,7 +10405,7 @@ function getHttpHost(opts) {
|
|
|
10770
10405
|
return opts.httpHost;
|
|
10771
10406
|
}
|
|
10772
10407
|
if (opts.cluster) {
|
|
10773
|
-
return
|
|
10408
|
+
return `sockjs-${opts.cluster}.pusher.com`;
|
|
10774
10409
|
}
|
|
10775
10410
|
return defaults.httpHost;
|
|
10776
10411
|
}
|
|
@@ -10781,7 +10416,7 @@ function getWebsocketHost(opts) {
|
|
|
10781
10416
|
return getWebsocketHostFromCluster(opts.cluster);
|
|
10782
10417
|
}
|
|
10783
10418
|
function getWebsocketHostFromCluster(cluster) {
|
|
10784
|
-
return
|
|
10419
|
+
return `ws-${cluster}.pusher.com`;
|
|
10785
10420
|
}
|
|
10786
10421
|
function shouldUseTLS(opts) {
|
|
10787
10422
|
if (node_runtime.getProtocol() === 'https:') {
|
|
@@ -10802,7 +10437,7 @@ function getEnableStatsConfig(opts) {
|
|
|
10802
10437
|
return false;
|
|
10803
10438
|
}
|
|
10804
10439
|
function buildUserAuthenticator(opts) {
|
|
10805
|
-
|
|
10440
|
+
const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication);
|
|
10806
10441
|
if ('customHandler' in userAuthentication &&
|
|
10807
10442
|
userAuthentication['customHandler'] != null) {
|
|
10808
10443
|
return userAuthentication['customHandler'];
|
|
@@ -10810,9 +10445,9 @@ function buildUserAuthenticator(opts) {
|
|
|
10810
10445
|
return user_authenticator(userAuthentication);
|
|
10811
10446
|
}
|
|
10812
10447
|
function buildChannelAuth(opts, pusher) {
|
|
10813
|
-
|
|
10448
|
+
let channelAuthorization;
|
|
10814
10449
|
if ('channelAuthorization' in opts) {
|
|
10815
|
-
channelAuthorization =
|
|
10450
|
+
channelAuthorization = Object.assign(Object.assign({}, defaults.channelAuthorization), opts.channelAuthorization);
|
|
10816
10451
|
}
|
|
10817
10452
|
else {
|
|
10818
10453
|
channelAuthorization = {
|
|
@@ -10831,7 +10466,7 @@ function buildChannelAuth(opts, pusher) {
|
|
|
10831
10466
|
return channelAuthorization;
|
|
10832
10467
|
}
|
|
10833
10468
|
function buildChannelAuthorizer(opts, pusher) {
|
|
10834
|
-
|
|
10469
|
+
const channelAuthorization = buildChannelAuth(opts, pusher);
|
|
10835
10470
|
if ('customHandler' in channelAuthorization &&
|
|
10836
10471
|
channelAuthorization['customHandler'] != null) {
|
|
10837
10472
|
return channelAuthorization['customHandler'];
|
|
@@ -10840,134 +10475,99 @@ function buildChannelAuthorizer(opts, pusher) {
|
|
|
10840
10475
|
}
|
|
10841
10476
|
|
|
10842
10477
|
// CONCATENATED MODULE: ./src/core/watchlist.ts
|
|
10843
|
-
var watchlist_extends = (undefined && undefined.__extends) || (function () {
|
|
10844
|
-
var extendStatics = function (d, b) {
|
|
10845
|
-
extendStatics = Object.setPrototypeOf ||
|
|
10846
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10847
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
10848
|
-
return extendStatics(d, b);
|
|
10849
|
-
};
|
|
10850
|
-
return function (d, b) {
|
|
10851
|
-
extendStatics(d, b);
|
|
10852
|
-
function __() { this.constructor = d; }
|
|
10853
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
10854
|
-
};
|
|
10855
|
-
})();
|
|
10856
10478
|
|
|
10857
10479
|
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
logger.debug("No callbacks on watchlist events for " + eventName);
|
|
10863
|
-
}) || this;
|
|
10864
|
-
_this.pusher = pusher;
|
|
10865
|
-
_this.bindWatchlistInternalEvent();
|
|
10866
|
-
return _this;
|
|
10867
|
-
}
|
|
10868
|
-
WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
|
|
10869
|
-
var _this = this;
|
|
10870
|
-
pusherEvent.data.events.forEach(function (watchlistEvent) {
|
|
10871
|
-
_this.emit(watchlistEvent.name, watchlistEvent);
|
|
10480
|
+
class watchlist_WatchlistFacade extends dispatcher_Dispatcher {
|
|
10481
|
+
constructor(pusher) {
|
|
10482
|
+
super(function (eventName, data) {
|
|
10483
|
+
logger.debug(`No callbacks on watchlist events for ${eventName}`);
|
|
10872
10484
|
});
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10485
|
+
this.pusher = pusher;
|
|
10486
|
+
this.bindWatchlistInternalEvent();
|
|
10487
|
+
}
|
|
10488
|
+
handleEvent(pusherEvent) {
|
|
10489
|
+
pusherEvent.data.events.forEach(watchlistEvent => {
|
|
10490
|
+
this.emit(watchlistEvent.name, watchlistEvent);
|
|
10491
|
+
});
|
|
10492
|
+
}
|
|
10493
|
+
bindWatchlistInternalEvent() {
|
|
10494
|
+
this.pusher.connection.bind('message', pusherEvent => {
|
|
10877
10495
|
var eventName = pusherEvent.event;
|
|
10878
10496
|
if (eventName === 'pusher_internal:watchlist_events') {
|
|
10879
|
-
|
|
10497
|
+
this.handleEvent(pusherEvent);
|
|
10880
10498
|
}
|
|
10881
10499
|
});
|
|
10882
|
-
}
|
|
10883
|
-
|
|
10884
|
-
}(dispatcher));
|
|
10885
|
-
/* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
|
|
10500
|
+
}
|
|
10501
|
+
}
|
|
10886
10502
|
|
|
10887
10503
|
// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
|
|
10888
10504
|
function flatPromise() {
|
|
10889
|
-
|
|
10890
|
-
|
|
10505
|
+
let resolve, reject;
|
|
10506
|
+
const promise = new Promise((res, rej) => {
|
|
10891
10507
|
resolve = res;
|
|
10892
10508
|
reject = rej;
|
|
10893
10509
|
});
|
|
10894
|
-
return { promise
|
|
10510
|
+
return { promise, resolve, reject };
|
|
10895
10511
|
}
|
|
10896
10512
|
/* harmony default export */ var flat_promise = (flatPromise);
|
|
10897
10513
|
|
|
10898
10514
|
// CONCATENATED MODULE: ./src/core/user.ts
|
|
10899
|
-
var user_extends = (undefined && undefined.__extends) || (function () {
|
|
10900
|
-
var extendStatics = function (d, b) {
|
|
10901
|
-
extendStatics = Object.setPrototypeOf ||
|
|
10902
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10903
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
10904
|
-
return extendStatics(d, b);
|
|
10905
|
-
};
|
|
10906
|
-
return function (d, b) {
|
|
10907
|
-
extendStatics(d, b);
|
|
10908
|
-
function __() { this.constructor = d; }
|
|
10909
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
10910
|
-
};
|
|
10911
|
-
})();
|
|
10912
10515
|
|
|
10913
10516
|
|
|
10914
10517
|
|
|
10915
10518
|
|
|
10916
10519
|
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
var _this = _super.call(this, function (eventName, data) {
|
|
10520
|
+
class user_UserFacade extends dispatcher_Dispatcher {
|
|
10521
|
+
constructor(pusher) {
|
|
10522
|
+
super(function (eventName, data) {
|
|
10921
10523
|
logger.debug('No callbacks on user for ' + eventName);
|
|
10922
|
-
})
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10524
|
+
});
|
|
10525
|
+
this.signin_requested = false;
|
|
10526
|
+
this.user_data = null;
|
|
10527
|
+
this.serverToUserChannel = null;
|
|
10528
|
+
this.signinDonePromise = null;
|
|
10529
|
+
this._signinDoneResolve = null;
|
|
10530
|
+
this._onAuthorize = (err, authData) => {
|
|
10929
10531
|
if (err) {
|
|
10930
|
-
logger.warn(
|
|
10931
|
-
|
|
10532
|
+
logger.warn(`Error during signin: ${err}`);
|
|
10533
|
+
this._cleanup();
|
|
10932
10534
|
return;
|
|
10933
10535
|
}
|
|
10934
|
-
|
|
10536
|
+
this.pusher.send_event('pusher:signin', {
|
|
10935
10537
|
auth: authData.auth,
|
|
10936
10538
|
user_data: authData.user_data
|
|
10937
10539
|
});
|
|
10938
10540
|
};
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
var previous = _a.previous, current = _a.current;
|
|
10541
|
+
this.pusher = pusher;
|
|
10542
|
+
this.pusher.connection.bind('state_change', ({ previous, current }) => {
|
|
10942
10543
|
if (previous !== 'connected' && current === 'connected') {
|
|
10943
|
-
|
|
10544
|
+
this._signin();
|
|
10944
10545
|
}
|
|
10945
10546
|
if (previous === 'connected' && current !== 'connected') {
|
|
10946
|
-
|
|
10947
|
-
|
|
10547
|
+
this._cleanup();
|
|
10548
|
+
this._newSigninPromiseIfNeeded();
|
|
10948
10549
|
}
|
|
10949
10550
|
});
|
|
10950
|
-
|
|
10951
|
-
|
|
10551
|
+
this.watchlist = new watchlist_WatchlistFacade(pusher);
|
|
10552
|
+
this.pusher.connection.bind('message', event => {
|
|
10952
10553
|
var eventName = event.event;
|
|
10953
10554
|
if (eventName === 'pusher:signin_success') {
|
|
10954
|
-
|
|
10555
|
+
this._onSigninSuccess(event.data);
|
|
10955
10556
|
}
|
|
10956
|
-
if (
|
|
10957
|
-
|
|
10958
|
-
|
|
10557
|
+
if (this.serverToUserChannel &&
|
|
10558
|
+
this.serverToUserChannel.name === event.channel) {
|
|
10559
|
+
this.serverToUserChannel.handleEvent(event);
|
|
10959
10560
|
}
|
|
10960
10561
|
});
|
|
10961
|
-
return _this;
|
|
10962
10562
|
}
|
|
10963
|
-
|
|
10563
|
+
signin() {
|
|
10964
10564
|
if (this.signin_requested) {
|
|
10965
10565
|
return;
|
|
10966
10566
|
}
|
|
10967
10567
|
this.signin_requested = true;
|
|
10968
10568
|
this._signin();
|
|
10969
|
-
}
|
|
10970
|
-
|
|
10569
|
+
}
|
|
10570
|
+
_signin() {
|
|
10971
10571
|
if (!this.signin_requested) {
|
|
10972
10572
|
return;
|
|
10973
10573
|
}
|
|
@@ -10978,46 +10578,45 @@ var user_UserFacade = (function (_super) {
|
|
|
10978
10578
|
this.pusher.config.userAuthenticator({
|
|
10979
10579
|
socketId: this.pusher.connection.socket_id
|
|
10980
10580
|
}, this._onAuthorize);
|
|
10981
|
-
}
|
|
10982
|
-
|
|
10581
|
+
}
|
|
10582
|
+
_onSigninSuccess(data) {
|
|
10983
10583
|
try {
|
|
10984
10584
|
this.user_data = JSON.parse(data.user_data);
|
|
10985
10585
|
}
|
|
10986
10586
|
catch (e) {
|
|
10987
|
-
logger.error(
|
|
10587
|
+
logger.error(`Failed parsing user data after signin: ${data.user_data}`);
|
|
10988
10588
|
this._cleanup();
|
|
10989
10589
|
return;
|
|
10990
10590
|
}
|
|
10991
10591
|
if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
|
|
10992
|
-
logger.error(
|
|
10592
|
+
logger.error(`user_data doesn't contain an id. user_data: ${this.user_data}`);
|
|
10993
10593
|
this._cleanup();
|
|
10994
10594
|
return;
|
|
10995
10595
|
}
|
|
10996
10596
|
this._signinDoneResolve();
|
|
10997
10597
|
this._subscribeChannels();
|
|
10998
|
-
}
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
var ensure_subscribed = function (channel) {
|
|
10598
|
+
}
|
|
10599
|
+
_subscribeChannels() {
|
|
10600
|
+
const ensure_subscribed = channel => {
|
|
11002
10601
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
11003
10602
|
channel.reinstateSubscription();
|
|
11004
10603
|
}
|
|
11005
10604
|
else if (!channel.subscriptionPending &&
|
|
11006
|
-
|
|
10605
|
+
this.pusher.connection.state === 'connected') {
|
|
11007
10606
|
channel.subscribe();
|
|
11008
10607
|
}
|
|
11009
10608
|
};
|
|
11010
|
-
this.serverToUserChannel = new
|
|
11011
|
-
this.serverToUserChannel.bind_global(
|
|
10609
|
+
this.serverToUserChannel = new channel_Channel(`#server-to-user-${this.user_data.id}`, this.pusher);
|
|
10610
|
+
this.serverToUserChannel.bind_global((eventName, data) => {
|
|
11012
10611
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
11013
10612
|
eventName.indexOf('pusher:') === 0) {
|
|
11014
10613
|
return;
|
|
11015
10614
|
}
|
|
11016
|
-
|
|
10615
|
+
this.emit(eventName, data);
|
|
11017
10616
|
});
|
|
11018
10617
|
ensure_subscribed(this.serverToUserChannel);
|
|
11019
|
-
}
|
|
11020
|
-
|
|
10618
|
+
}
|
|
10619
|
+
_cleanup() {
|
|
11021
10620
|
this.user_data = null;
|
|
11022
10621
|
if (this.serverToUserChannel) {
|
|
11023
10622
|
this.serverToUserChannel.unbind_all();
|
|
@@ -11027,26 +10626,24 @@ var user_UserFacade = (function (_super) {
|
|
|
11027
10626
|
if (this.signin_requested) {
|
|
11028
10627
|
this._signinDoneResolve();
|
|
11029
10628
|
}
|
|
11030
|
-
}
|
|
11031
|
-
|
|
10629
|
+
}
|
|
10630
|
+
_newSigninPromiseIfNeeded() {
|
|
11032
10631
|
if (!this.signin_requested) {
|
|
11033
10632
|
return;
|
|
11034
10633
|
}
|
|
11035
10634
|
if (this.signinDonePromise && !this.signinDonePromise.done) {
|
|
11036
10635
|
return;
|
|
11037
10636
|
}
|
|
11038
|
-
|
|
10637
|
+
const { promise, resolve, reject: _ } = flat_promise();
|
|
11039
10638
|
promise.done = false;
|
|
11040
|
-
|
|
10639
|
+
const setDone = () => {
|
|
11041
10640
|
promise.done = true;
|
|
11042
10641
|
};
|
|
11043
|
-
promise.then(setDone)
|
|
10642
|
+
promise.then(setDone).catch(setDone);
|
|
11044
10643
|
this.signinDonePromise = promise;
|
|
11045
10644
|
this._signinDoneResolve = resolve;
|
|
11046
|
-
}
|
|
11047
|
-
|
|
11048
|
-
}(dispatcher));
|
|
11049
|
-
/* harmony default export */ var user = (user_UserFacade);
|
|
10645
|
+
}
|
|
10646
|
+
}
|
|
11050
10647
|
|
|
11051
10648
|
// CONCATENATED MODULE: ./src/core/pusher.ts
|
|
11052
10649
|
|
|
@@ -11062,19 +10659,29 @@ var user_UserFacade = (function (_super) {
|
|
|
11062
10659
|
|
|
11063
10660
|
|
|
11064
10661
|
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
10662
|
+
class pusher_Pusher {
|
|
10663
|
+
static ready() {
|
|
10664
|
+
pusher_Pusher.isReady = true;
|
|
10665
|
+
for (var i = 0, l = pusher_Pusher.instances.length; i < l; i++) {
|
|
10666
|
+
pusher_Pusher.instances[i].connect();
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
static getClientFeatures() {
|
|
10670
|
+
return keys(filterObject({ ws: node_runtime.Transports.ws }, function (t) {
|
|
10671
|
+
return t.isSupported({});
|
|
10672
|
+
}));
|
|
10673
|
+
}
|
|
10674
|
+
constructor(app_key, options) {
|
|
11068
10675
|
checkAppKey(app_key);
|
|
11069
10676
|
validateOptions(options);
|
|
11070
10677
|
this.key = app_key;
|
|
11071
10678
|
this.config = getConfig(options, this);
|
|
11072
10679
|
this.channels = factory.createChannels();
|
|
11073
|
-
this.global_emitter = new
|
|
10680
|
+
this.global_emitter = new dispatcher_Dispatcher();
|
|
11074
10681
|
this.sessionID = node_runtime.randomInt(1000000000);
|
|
11075
|
-
this.timeline = new
|
|
10682
|
+
this.timeline = new timeline_Timeline(this.key, this.sessionID, {
|
|
11076
10683
|
cluster: this.config.cluster,
|
|
11077
|
-
features:
|
|
10684
|
+
features: pusher_Pusher.getClientFeatures(),
|
|
11078
10685
|
params: this.config.timelineParams || {},
|
|
11079
10686
|
limit: 50,
|
|
11080
10687
|
level: timeline_level.INFO,
|
|
@@ -11086,8 +10693,8 @@ var pusher_Pusher = (function () {
|
|
|
11086
10693
|
path: '/timeline/v2/' + node_runtime.TimelineTransport.name
|
|
11087
10694
|
});
|
|
11088
10695
|
}
|
|
11089
|
-
var getStrategy =
|
|
11090
|
-
return node_runtime.getDefaultStrategy(
|
|
10696
|
+
var getStrategy = (options) => {
|
|
10697
|
+
return node_runtime.getDefaultStrategy(this.config, options, strategy_builder_defineTransport);
|
|
11091
10698
|
};
|
|
11092
10699
|
this.connection = factory.createConnectionManager(this.key, {
|
|
11093
10700
|
getStrategy: getStrategy,
|
|
@@ -11097,106 +10704,95 @@ var pusher_Pusher = (function () {
|
|
|
11097
10704
|
unavailableTimeout: this.config.unavailableTimeout,
|
|
11098
10705
|
useTLS: Boolean(this.config.useTLS)
|
|
11099
10706
|
});
|
|
11100
|
-
this.connection.bind('connected',
|
|
11101
|
-
|
|
11102
|
-
if (
|
|
11103
|
-
|
|
10707
|
+
this.connection.bind('connected', () => {
|
|
10708
|
+
this.subscribeAll();
|
|
10709
|
+
if (this.timelineSender) {
|
|
10710
|
+
this.timelineSender.send(this.connection.isUsingTLS());
|
|
11104
10711
|
}
|
|
11105
10712
|
});
|
|
11106
|
-
this.connection.bind('message',
|
|
10713
|
+
this.connection.bind('message', event => {
|
|
11107
10714
|
var eventName = event.event;
|
|
11108
10715
|
var internal = eventName.indexOf('pusher_internal:') === 0;
|
|
11109
10716
|
if (event.channel) {
|
|
11110
|
-
var channel =
|
|
10717
|
+
var channel = this.channel(event.channel);
|
|
11111
10718
|
if (channel) {
|
|
11112
10719
|
channel.handleEvent(event);
|
|
11113
10720
|
}
|
|
11114
10721
|
}
|
|
11115
10722
|
if (!internal) {
|
|
11116
|
-
|
|
10723
|
+
this.global_emitter.emit(event.event, event.data);
|
|
11117
10724
|
}
|
|
11118
10725
|
});
|
|
11119
|
-
this.connection.bind('connecting',
|
|
11120
|
-
|
|
10726
|
+
this.connection.bind('connecting', () => {
|
|
10727
|
+
this.channels.disconnect();
|
|
11121
10728
|
});
|
|
11122
|
-
this.connection.bind('disconnected',
|
|
11123
|
-
|
|
10729
|
+
this.connection.bind('disconnected', () => {
|
|
10730
|
+
this.channels.disconnect();
|
|
11124
10731
|
});
|
|
11125
|
-
this.connection.bind('error',
|
|
10732
|
+
this.connection.bind('error', err => {
|
|
11126
10733
|
logger.warn(err);
|
|
11127
10734
|
});
|
|
11128
|
-
|
|
11129
|
-
this.timeline.info({ instances:
|
|
11130
|
-
this.user = new
|
|
11131
|
-
if (
|
|
10735
|
+
pusher_Pusher.instances.push(this);
|
|
10736
|
+
this.timeline.info({ instances: pusher_Pusher.instances.length });
|
|
10737
|
+
this.user = new user_UserFacade(this);
|
|
10738
|
+
if (pusher_Pusher.isReady) {
|
|
11132
10739
|
this.connect();
|
|
11133
10740
|
}
|
|
11134
10741
|
}
|
|
11135
|
-
|
|
11136
|
-
Pusher.isReady = true;
|
|
11137
|
-
for (var i = 0, l = Pusher.instances.length; i < l; i++) {
|
|
11138
|
-
Pusher.instances[i].connect();
|
|
11139
|
-
}
|
|
11140
|
-
};
|
|
11141
|
-
Pusher.getClientFeatures = function () {
|
|
11142
|
-
return keys(filterObject({ ws: node_runtime.Transports.ws }, function (t) {
|
|
11143
|
-
return t.isSupported({});
|
|
11144
|
-
}));
|
|
11145
|
-
};
|
|
11146
|
-
Pusher.prototype.channel = function (name) {
|
|
10742
|
+
channel(name) {
|
|
11147
10743
|
return this.channels.find(name);
|
|
11148
|
-
}
|
|
11149
|
-
|
|
10744
|
+
}
|
|
10745
|
+
allChannels() {
|
|
11150
10746
|
return this.channels.all();
|
|
11151
|
-
}
|
|
11152
|
-
|
|
10747
|
+
}
|
|
10748
|
+
connect() {
|
|
11153
10749
|
this.connection.connect();
|
|
11154
10750
|
if (this.timelineSender) {
|
|
11155
10751
|
if (!this.timelineSenderTimer) {
|
|
11156
10752
|
var usingTLS = this.connection.isUsingTLS();
|
|
11157
10753
|
var timelineSender = this.timelineSender;
|
|
11158
|
-
this.timelineSenderTimer = new
|
|
10754
|
+
this.timelineSenderTimer = new timers_PeriodicTimer(60000, function () {
|
|
11159
10755
|
timelineSender.send(usingTLS);
|
|
11160
10756
|
});
|
|
11161
10757
|
}
|
|
11162
10758
|
}
|
|
11163
|
-
}
|
|
11164
|
-
|
|
10759
|
+
}
|
|
10760
|
+
disconnect() {
|
|
11165
10761
|
this.connection.disconnect();
|
|
11166
10762
|
if (this.timelineSenderTimer) {
|
|
11167
10763
|
this.timelineSenderTimer.ensureAborted();
|
|
11168
10764
|
this.timelineSenderTimer = null;
|
|
11169
10765
|
}
|
|
11170
|
-
}
|
|
11171
|
-
|
|
10766
|
+
}
|
|
10767
|
+
bind(event_name, callback, context) {
|
|
11172
10768
|
this.global_emitter.bind(event_name, callback, context);
|
|
11173
10769
|
return this;
|
|
11174
|
-
}
|
|
11175
|
-
|
|
10770
|
+
}
|
|
10771
|
+
unbind(event_name, callback, context) {
|
|
11176
10772
|
this.global_emitter.unbind(event_name, callback, context);
|
|
11177
10773
|
return this;
|
|
11178
|
-
}
|
|
11179
|
-
|
|
10774
|
+
}
|
|
10775
|
+
bind_global(callback) {
|
|
11180
10776
|
this.global_emitter.bind_global(callback);
|
|
11181
10777
|
return this;
|
|
11182
|
-
}
|
|
11183
|
-
|
|
10778
|
+
}
|
|
10779
|
+
unbind_global(callback) {
|
|
11184
10780
|
this.global_emitter.unbind_global(callback);
|
|
11185
10781
|
return this;
|
|
11186
|
-
}
|
|
11187
|
-
|
|
10782
|
+
}
|
|
10783
|
+
unbind_all(callback) {
|
|
11188
10784
|
this.global_emitter.unbind_all();
|
|
11189
10785
|
return this;
|
|
11190
|
-
}
|
|
11191
|
-
|
|
10786
|
+
}
|
|
10787
|
+
subscribeAll() {
|
|
11192
10788
|
var channelName;
|
|
11193
10789
|
for (channelName in this.channels.channels) {
|
|
11194
10790
|
if (this.channels.channels.hasOwnProperty(channelName)) {
|
|
11195
10791
|
this.subscribe(channelName);
|
|
11196
10792
|
}
|
|
11197
10793
|
}
|
|
11198
|
-
}
|
|
11199
|
-
|
|
10794
|
+
}
|
|
10795
|
+
subscribe(channel_name) {
|
|
11200
10796
|
var channel = this.channels.add(channel_name, this);
|
|
11201
10797
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
11202
10798
|
channel.reinstateSubscription();
|
|
@@ -11206,8 +10802,8 @@ var pusher_Pusher = (function () {
|
|
|
11206
10802
|
channel.subscribe();
|
|
11207
10803
|
}
|
|
11208
10804
|
return channel;
|
|
11209
|
-
}
|
|
11210
|
-
|
|
10805
|
+
}
|
|
10806
|
+
unsubscribe(channel_name) {
|
|
11211
10807
|
var channel = this.channels.find(channel_name);
|
|
11212
10808
|
if (channel && channel.subscriptionPending) {
|
|
11213
10809
|
channel.cancelSubscription();
|
|
@@ -11218,25 +10814,24 @@ var pusher_Pusher = (function () {
|
|
|
11218
10814
|
channel.unsubscribe();
|
|
11219
10815
|
}
|
|
11220
10816
|
}
|
|
11221
|
-
}
|
|
11222
|
-
|
|
10817
|
+
}
|
|
10818
|
+
send_event(event_name, data, channel) {
|
|
11223
10819
|
return this.connection.send_event(event_name, data, channel);
|
|
11224
|
-
}
|
|
11225
|
-
|
|
10820
|
+
}
|
|
10821
|
+
shouldUseTLS() {
|
|
11226
10822
|
return this.config.useTLS;
|
|
11227
|
-
}
|
|
11228
|
-
|
|
10823
|
+
}
|
|
10824
|
+
signin() {
|
|
11229
10825
|
this.user.signin();
|
|
11230
|
-
}
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
}());
|
|
10826
|
+
}
|
|
10827
|
+
}
|
|
10828
|
+
pusher_Pusher.instances = [];
|
|
10829
|
+
pusher_Pusher.isReady = false;
|
|
10830
|
+
pusher_Pusher.logToConsole = false;
|
|
10831
|
+
pusher_Pusher.Runtime = node_runtime;
|
|
10832
|
+
pusher_Pusher.ScriptReceivers = node_runtime.ScriptReceivers;
|
|
10833
|
+
pusher_Pusher.DependenciesReceivers = node_runtime.DependenciesReceivers;
|
|
10834
|
+
pusher_Pusher.auth_callbacks = node_runtime.auth_callbacks;
|
|
11240
10835
|
/* harmony default export */ var core_pusher = (pusher_Pusher);
|
|
11241
10836
|
function checkAppKey(key) {
|
|
11242
10837
|
if (key === null || key === undefined) {
|
|
@@ -11249,36 +10844,18 @@ node_runtime.setup(pusher_Pusher);
|
|
|
11249
10844
|
var nacl_fast = __webpack_require__(20);
|
|
11250
10845
|
|
|
11251
10846
|
// CONCATENATED MODULE: ./src/core/pusher-with-encryption.ts
|
|
11252
|
-
var pusher_with_encryption_extends = (undefined && undefined.__extends) || (function () {
|
|
11253
|
-
var extendStatics = function (d, b) {
|
|
11254
|
-
extendStatics = Object.setPrototypeOf ||
|
|
11255
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11256
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
11257
|
-
return extendStatics(d, b);
|
|
11258
|
-
};
|
|
11259
|
-
return function (d, b) {
|
|
11260
|
-
extendStatics(d, b);
|
|
11261
|
-
function __() { this.constructor = d; }
|
|
11262
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
11263
|
-
};
|
|
11264
|
-
})();
|
|
11265
10847
|
|
|
11266
10848
|
|
|
11267
10849
|
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
core_pusher.logToConsole = PusherWithEncryption.logToConsole;
|
|
11273
|
-
core_pusher.log = PusherWithEncryption.log;
|
|
10850
|
+
class pusher_with_encryption_PusherWithEncryption extends core_pusher {
|
|
10851
|
+
constructor(app_key, options) {
|
|
10852
|
+
core_pusher.logToConsole = pusher_with_encryption_PusherWithEncryption.logToConsole;
|
|
10853
|
+
core_pusher.log = pusher_with_encryption_PusherWithEncryption.log;
|
|
11274
10854
|
validateOptions(options);
|
|
11275
10855
|
options.nacl = nacl_fast;
|
|
11276
|
-
|
|
11277
|
-
return _this;
|
|
10856
|
+
super(app_key, options);
|
|
11278
10857
|
}
|
|
11279
|
-
|
|
11280
|
-
}(core_pusher));
|
|
11281
|
-
/* harmony default export */ var pusher_with_encryption = __webpack_exports__["default"] = (pusher_with_encryption_PusherWithEncryption);
|
|
10858
|
+
}
|
|
11282
10859
|
|
|
11283
10860
|
|
|
11284
10861
|
/***/ })
|