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
|
@@ -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
|
|
@@ -2963,14 +2963,17 @@ module.exports = __webpack_require__(5).default;
|
|
|
2963
2963
|
// ESM COMPAT FLAG
|
|
2964
2964
|
__webpack_require__.r(__webpack_exports__);
|
|
2965
2965
|
|
|
2966
|
+
// EXPORTS
|
|
2967
|
+
__webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ pusher_with_encryption_PusherWithEncryption; });
|
|
2968
|
+
|
|
2966
2969
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
|
|
2967
|
-
|
|
2968
|
-
|
|
2970
|
+
class ScriptReceiverFactory {
|
|
2971
|
+
constructor(prefix, name) {
|
|
2969
2972
|
this.lastId = 0;
|
|
2970
2973
|
this.prefix = prefix;
|
|
2971
2974
|
this.name = name;
|
|
2972
2975
|
}
|
|
2973
|
-
|
|
2976
|
+
create(callback) {
|
|
2974
2977
|
this.lastId++;
|
|
2975
2978
|
var number = this.lastId;
|
|
2976
2979
|
var id = this.prefix + number;
|
|
@@ -2984,18 +2987,16 @@ var ScriptReceiverFactory = (function () {
|
|
|
2984
2987
|
};
|
|
2985
2988
|
this[number] = callbackWrapper;
|
|
2986
2989
|
return { number: number, id: id, name: name, callback: callbackWrapper };
|
|
2987
|
-
}
|
|
2988
|
-
|
|
2990
|
+
}
|
|
2991
|
+
remove(receiver) {
|
|
2989
2992
|
delete this[receiver.number];
|
|
2990
|
-
}
|
|
2991
|
-
|
|
2992
|
-
}());
|
|
2993
|
-
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2994
2995
|
var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.ScriptReceivers');
|
|
2995
2996
|
|
|
2996
2997
|
// CONCATENATED MODULE: ./src/core/defaults.ts
|
|
2997
2998
|
var Defaults = {
|
|
2998
|
-
VERSION: "8.0
|
|
2999
|
+
VERSION: "8.2.0",
|
|
2999
3000
|
PROTOCOL: 7,
|
|
3000
3001
|
wsPort: 80,
|
|
3001
3002
|
wssPort: 443,
|
|
@@ -3027,13 +3028,13 @@ var Defaults = {
|
|
|
3027
3028
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
|
|
3028
3029
|
|
|
3029
3030
|
|
|
3030
|
-
|
|
3031
|
-
|
|
3031
|
+
class dependency_loader_DependencyLoader {
|
|
3032
|
+
constructor(options) {
|
|
3032
3033
|
this.options = options;
|
|
3033
3034
|
this.receivers = options.receivers || ScriptReceivers;
|
|
3034
3035
|
this.loading = {};
|
|
3035
3036
|
}
|
|
3036
|
-
|
|
3037
|
+
load(name, options, callback) {
|
|
3037
3038
|
var self = this;
|
|
3038
3039
|
if (self.loading[name] && self.loading[name].length > 0) {
|
|
3039
3040
|
self.loading[name].push(callback);
|
|
@@ -3058,8 +3059,8 @@ var dependency_loader_DependencyLoader = (function () {
|
|
|
3058
3059
|
});
|
|
3059
3060
|
request.send(receiver);
|
|
3060
3061
|
}
|
|
3061
|
-
}
|
|
3062
|
-
|
|
3062
|
+
}
|
|
3063
|
+
getRoot(options) {
|
|
3063
3064
|
var cdn;
|
|
3064
3065
|
var protocol = runtime.getDocument().location.protocol;
|
|
3065
3066
|
if ((options && options.useTLS) || protocol === 'https:') {
|
|
@@ -3069,20 +3070,18 @@ var dependency_loader_DependencyLoader = (function () {
|
|
|
3069
3070
|
cdn = this.options.cdn_http;
|
|
3070
3071
|
}
|
|
3071
3072
|
return cdn.replace(/\/*$/, '') + '/' + this.options.version;
|
|
3072
|
-
}
|
|
3073
|
-
|
|
3073
|
+
}
|
|
3074
|
+
getPath(name, options) {
|
|
3074
3075
|
return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
|
|
3075
|
-
}
|
|
3076
|
-
|
|
3077
|
-
}());
|
|
3078
|
-
/* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3079
3078
|
|
|
3080
3079
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
|
|
3081
3080
|
|
|
3082
3081
|
|
|
3083
3082
|
|
|
3084
3083
|
var DependenciesReceivers = new ScriptReceiverFactory('_pusher_dependencies', 'Pusher.DependenciesReceivers');
|
|
3085
|
-
var Dependencies = new
|
|
3084
|
+
var Dependencies = new dependency_loader_DependencyLoader({
|
|
3086
3085
|
cdn_http: defaults.cdn_http,
|
|
3087
3086
|
cdn_https: defaults.cdn_https,
|
|
3088
3087
|
version: defaults.VERSION,
|
|
@@ -3091,7 +3090,7 @@ var Dependencies = new dependency_loader({
|
|
|
3091
3090
|
});
|
|
3092
3091
|
|
|
3093
3092
|
// CONCATENATED MODULE: ./src/core/utils/url_store.ts
|
|
3094
|
-
|
|
3093
|
+
const urlStore = {
|
|
3095
3094
|
baseUrl: 'https://pusher.com',
|
|
3096
3095
|
urls: {
|
|
3097
3096
|
authenticationEndpoint: {
|
|
@@ -3111,12 +3110,12 @@ var urlStore = {
|
|
|
3111
3110
|
}
|
|
3112
3111
|
}
|
|
3113
3112
|
};
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3113
|
+
const buildLogSuffix = function (key) {
|
|
3114
|
+
const urlPrefix = 'See:';
|
|
3115
|
+
const urlObj = urlStore.urls[key];
|
|
3117
3116
|
if (!urlObj)
|
|
3118
3117
|
return '';
|
|
3119
|
-
|
|
3118
|
+
let url;
|
|
3120
3119
|
if (urlObj.fullUrl) {
|
|
3121
3120
|
url = urlObj.fullUrl;
|
|
3122
3121
|
}
|
|
@@ -3125,9 +3124,9 @@ var buildLogSuffix = function (key) {
|
|
|
3125
3124
|
}
|
|
3126
3125
|
if (!url)
|
|
3127
3126
|
return '';
|
|
3128
|
-
return urlPrefix
|
|
3127
|
+
return `${urlPrefix} ${url}`;
|
|
3129
3128
|
};
|
|
3130
|
-
/* harmony default export */ var url_store = ({ buildLogSuffix
|
|
3129
|
+
/* harmony default export */ var url_store = ({ buildLogSuffix });
|
|
3131
3130
|
|
|
3132
3131
|
// CONCATENATED MODULE: ./src/core/auth/options.ts
|
|
3133
3132
|
var AuthRequestType;
|
|
@@ -3137,134 +3136,76 @@ var AuthRequestType;
|
|
|
3137
3136
|
})(AuthRequestType || (AuthRequestType = {}));
|
|
3138
3137
|
|
|
3139
3138
|
// CONCATENATED MODULE: ./src/core/errors.ts
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
}
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
}
|
|
3194
|
-
|
|
3195
|
-
}(Error));
|
|
3196
|
-
|
|
3197
|
-
var TransportClosed = (function (_super) {
|
|
3198
|
-
__extends(TransportClosed, _super);
|
|
3199
|
-
function TransportClosed(msg) {
|
|
3200
|
-
var _newTarget = this.constructor;
|
|
3201
|
-
var _this = _super.call(this, msg) || this;
|
|
3202
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
3203
|
-
return _this;
|
|
3204
|
-
}
|
|
3205
|
-
return TransportClosed;
|
|
3206
|
-
}(Error));
|
|
3207
|
-
|
|
3208
|
-
var UnsupportedFeature = (function (_super) {
|
|
3209
|
-
__extends(UnsupportedFeature, _super);
|
|
3210
|
-
function UnsupportedFeature(msg) {
|
|
3211
|
-
var _newTarget = this.constructor;
|
|
3212
|
-
var _this = _super.call(this, msg) || this;
|
|
3213
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
3214
|
-
return _this;
|
|
3215
|
-
}
|
|
3216
|
-
return UnsupportedFeature;
|
|
3217
|
-
}(Error));
|
|
3218
|
-
|
|
3219
|
-
var UnsupportedTransport = (function (_super) {
|
|
3220
|
-
__extends(UnsupportedTransport, _super);
|
|
3221
|
-
function UnsupportedTransport(msg) {
|
|
3222
|
-
var _newTarget = this.constructor;
|
|
3223
|
-
var _this = _super.call(this, msg) || this;
|
|
3224
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
3225
|
-
return _this;
|
|
3226
|
-
}
|
|
3227
|
-
return UnsupportedTransport;
|
|
3228
|
-
}(Error));
|
|
3229
|
-
|
|
3230
|
-
var UnsupportedStrategy = (function (_super) {
|
|
3231
|
-
__extends(UnsupportedStrategy, _super);
|
|
3232
|
-
function UnsupportedStrategy(msg) {
|
|
3233
|
-
var _newTarget = this.constructor;
|
|
3234
|
-
var _this = _super.call(this, msg) || this;
|
|
3235
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
3236
|
-
return _this;
|
|
3237
|
-
}
|
|
3238
|
-
return UnsupportedStrategy;
|
|
3239
|
-
}(Error));
|
|
3240
|
-
|
|
3241
|
-
var HTTPAuthError = (function (_super) {
|
|
3242
|
-
__extends(HTTPAuthError, _super);
|
|
3243
|
-
function HTTPAuthError(status, msg) {
|
|
3244
|
-
var _newTarget = this.constructor;
|
|
3245
|
-
var _this = _super.call(this, msg) || this;
|
|
3246
|
-
_this.status = status;
|
|
3247
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
3248
|
-
return _this;
|
|
3249
|
-
}
|
|
3250
|
-
return HTTPAuthError;
|
|
3251
|
-
}(Error));
|
|
3252
|
-
|
|
3139
|
+
class BadEventName extends Error {
|
|
3140
|
+
constructor(msg) {
|
|
3141
|
+
super(msg);
|
|
3142
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
class BadChannelName extends Error {
|
|
3146
|
+
constructor(msg) {
|
|
3147
|
+
super(msg);
|
|
3148
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
class RequestTimedOut extends Error {
|
|
3152
|
+
constructor(msg) {
|
|
3153
|
+
super(msg);
|
|
3154
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
class TransportPriorityTooLow extends Error {
|
|
3158
|
+
constructor(msg) {
|
|
3159
|
+
super(msg);
|
|
3160
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
class TransportClosed extends Error {
|
|
3164
|
+
constructor(msg) {
|
|
3165
|
+
super(msg);
|
|
3166
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
class UnsupportedFeature extends Error {
|
|
3170
|
+
constructor(msg) {
|
|
3171
|
+
super(msg);
|
|
3172
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
class UnsupportedTransport extends Error {
|
|
3176
|
+
constructor(msg) {
|
|
3177
|
+
super(msg);
|
|
3178
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
class UnsupportedStrategy extends Error {
|
|
3182
|
+
constructor(msg) {
|
|
3183
|
+
super(msg);
|
|
3184
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
class HTTPAuthError extends Error {
|
|
3188
|
+
constructor(status, msg) {
|
|
3189
|
+
super(msg);
|
|
3190
|
+
this.status = status;
|
|
3191
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3253
3194
|
|
|
3254
3195
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
|
|
3255
3196
|
|
|
3256
3197
|
|
|
3257
3198
|
|
|
3258
3199
|
|
|
3259
|
-
|
|
3260
|
-
|
|
3200
|
+
const ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
3201
|
+
const xhr = runtime.createXHR();
|
|
3261
3202
|
xhr.open('POST', authOptions.endpoint, true);
|
|
3262
3203
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
3263
3204
|
for (var headerName in authOptions.headers) {
|
|
3264
3205
|
xhr.setRequestHeader(headerName, authOptions.headers[headerName]);
|
|
3265
3206
|
}
|
|
3266
3207
|
if (authOptions.headersProvider != null) {
|
|
3267
|
-
|
|
3208
|
+
let dynamicHeaders = authOptions.headersProvider();
|
|
3268
3209
|
for (var headerName in dynamicHeaders) {
|
|
3269
3210
|
xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);
|
|
3270
3211
|
}
|
|
@@ -3272,31 +3213,31 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
|
3272
3213
|
xhr.onreadystatechange = function () {
|
|
3273
3214
|
if (xhr.readyState === 4) {
|
|
3274
3215
|
if (xhr.status === 200) {
|
|
3275
|
-
|
|
3276
|
-
|
|
3216
|
+
let data;
|
|
3217
|
+
let parsed = false;
|
|
3277
3218
|
try {
|
|
3278
3219
|
data = JSON.parse(xhr.responseText);
|
|
3279
3220
|
parsed = true;
|
|
3280
3221
|
}
|
|
3281
3222
|
catch (e) {
|
|
3282
|
-
callback(new HTTPAuthError(200,
|
|
3223
|
+
callback(new HTTPAuthError(200, `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${xhr.responseText}`), null);
|
|
3283
3224
|
}
|
|
3284
3225
|
if (parsed) {
|
|
3285
3226
|
callback(null, data);
|
|
3286
3227
|
}
|
|
3287
3228
|
}
|
|
3288
3229
|
else {
|
|
3289
|
-
|
|
3230
|
+
let suffix = '';
|
|
3290
3231
|
switch (authRequestType) {
|
|
3291
3232
|
case AuthRequestType.UserAuthentication:
|
|
3292
3233
|
suffix = url_store.buildLogSuffix('authenticationEndpoint');
|
|
3293
3234
|
break;
|
|
3294
3235
|
case AuthRequestType.ChannelAuthorization:
|
|
3295
|
-
suffix =
|
|
3236
|
+
suffix = `Clients must be authorized to join private or presence channels. ${url_store.buildLogSuffix('authorizationEndpoint')}`;
|
|
3296
3237
|
break;
|
|
3297
3238
|
}
|
|
3298
|
-
callback(new HTTPAuthError(xhr.status,
|
|
3299
|
-
|
|
3239
|
+
callback(new HTTPAuthError(xhr.status, `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +
|
|
3240
|
+
`received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`), null);
|
|
3300
3241
|
}
|
|
3301
3242
|
}
|
|
3302
3243
|
};
|
|
@@ -3347,43 +3288,28 @@ var btoa = window.btoa ||
|
|
|
3347
3288
|
};
|
|
3348
3289
|
|
|
3349
3290
|
// CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
var _this = this;
|
|
3291
|
+
class Timer {
|
|
3292
|
+
constructor(set, clear, delay, callback) {
|
|
3353
3293
|
this.clear = clear;
|
|
3354
|
-
this.timer = set(
|
|
3355
|
-
if (
|
|
3356
|
-
|
|
3294
|
+
this.timer = set(() => {
|
|
3295
|
+
if (this.timer) {
|
|
3296
|
+
this.timer = callback(this.timer);
|
|
3357
3297
|
}
|
|
3358
3298
|
}, delay);
|
|
3359
3299
|
}
|
|
3360
|
-
|
|
3300
|
+
isRunning() {
|
|
3361
3301
|
return this.timer !== null;
|
|
3362
|
-
}
|
|
3363
|
-
|
|
3302
|
+
}
|
|
3303
|
+
ensureAborted() {
|
|
3364
3304
|
if (this.timer) {
|
|
3365
3305
|
this.clear(this.timer);
|
|
3366
3306
|
this.timer = null;
|
|
3367
3307
|
}
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
}());
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3371
3310
|
/* harmony default export */ var abstract_timer = (Timer);
|
|
3372
3311
|
|
|
3373
3312
|
// CONCATENATED MODULE: ./src/core/utils/timers/index.ts
|
|
3374
|
-
var timers_extends = (undefined && undefined.__extends) || (function () {
|
|
3375
|
-
var extendStatics = function (d, b) {
|
|
3376
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3377
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3378
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
3379
|
-
return extendStatics(d, b);
|
|
3380
|
-
};
|
|
3381
|
-
return function (d, b) {
|
|
3382
|
-
extendStatics(d, b);
|
|
3383
|
-
function __() { this.constructor = d; }
|
|
3384
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3385
|
-
};
|
|
3386
|
-
})();
|
|
3387
3313
|
|
|
3388
3314
|
function timers_clearTimeout(timer) {
|
|
3389
3315
|
window.clearTimeout(timer);
|
|
@@ -3391,33 +3317,27 @@ function timers_clearTimeout(timer) {
|
|
|
3391
3317
|
function timers_clearInterval(timer) {
|
|
3392
3318
|
window.clearInterval(timer);
|
|
3393
3319
|
}
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
3320
|
+
class timers_OneOffTimer extends abstract_timer {
|
|
3321
|
+
constructor(delay, callback) {
|
|
3322
|
+
super(setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
3398
3323
|
callback();
|
|
3399
3324
|
return null;
|
|
3400
|
-
})
|
|
3325
|
+
});
|
|
3401
3326
|
}
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
timers_extends(PeriodicTimer, _super);
|
|
3407
|
-
function PeriodicTimer(delay, callback) {
|
|
3408
|
-
return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
|
|
3327
|
+
}
|
|
3328
|
+
class timers_PeriodicTimer extends abstract_timer {
|
|
3329
|
+
constructor(delay, callback) {
|
|
3330
|
+
super(setInterval, timers_clearInterval, delay, function (timer) {
|
|
3409
3331
|
callback();
|
|
3410
3332
|
return timer;
|
|
3411
|
-
})
|
|
3333
|
+
});
|
|
3412
3334
|
}
|
|
3413
|
-
|
|
3414
|
-
}(abstract_timer));
|
|
3415
|
-
|
|
3335
|
+
}
|
|
3416
3336
|
|
|
3417
3337
|
// CONCATENATED MODULE: ./src/core/util.ts
|
|
3418
3338
|
|
|
3419
3339
|
var Util = {
|
|
3420
|
-
now
|
|
3340
|
+
now() {
|
|
3421
3341
|
if (Date.now) {
|
|
3422
3342
|
return Date.now();
|
|
3423
3343
|
}
|
|
@@ -3425,14 +3345,10 @@ var Util = {
|
|
|
3425
3345
|
return new Date().valueOf();
|
|
3426
3346
|
}
|
|
3427
3347
|
},
|
|
3428
|
-
defer
|
|
3429
|
-
return new
|
|
3348
|
+
defer(callback) {
|
|
3349
|
+
return new timers_OneOffTimer(0, callback);
|
|
3430
3350
|
},
|
|
3431
|
-
method
|
|
3432
|
-
var args = [];
|
|
3433
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3434
|
-
args[_i - 1] = arguments[_i];
|
|
3435
|
-
}
|
|
3351
|
+
method(name, ...args) {
|
|
3436
3352
|
var boundArguments = Array.prototype.slice.call(arguments, 1);
|
|
3437
3353
|
return function (object) {
|
|
3438
3354
|
return object[name].apply(object, boundArguments.concat(arguments));
|
|
@@ -3444,11 +3360,7 @@ var Util = {
|
|
|
3444
3360
|
// CONCATENATED MODULE: ./src/core/utils/collections.ts
|
|
3445
3361
|
|
|
3446
3362
|
|
|
3447
|
-
function extend(target) {
|
|
3448
|
-
var sources = [];
|
|
3449
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3450
|
-
sources[_i - 1] = arguments[_i];
|
|
3451
|
-
}
|
|
3363
|
+
function extend(target, ...sources) {
|
|
3452
3364
|
for (var i = 0; i < sources.length; i++) {
|
|
3453
3365
|
var extensions = sources[i];
|
|
3454
3366
|
for (var property in extensions) {
|
|
@@ -3642,67 +3554,50 @@ function safeJSONStringify(source) {
|
|
|
3642
3554
|
// CONCATENATED MODULE: ./src/core/logger.ts
|
|
3643
3555
|
|
|
3644
3556
|
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
this.globalLog =
|
|
3557
|
+
class logger_Logger {
|
|
3558
|
+
constructor() {
|
|
3559
|
+
this.globalLog = (message) => {
|
|
3648
3560
|
if (window.console && window.console.log) {
|
|
3649
3561
|
window.console.log(message);
|
|
3650
3562
|
}
|
|
3651
3563
|
};
|
|
3652
3564
|
}
|
|
3653
|
-
|
|
3654
|
-
var args = [];
|
|
3655
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3656
|
-
args[_i] = arguments[_i];
|
|
3657
|
-
}
|
|
3565
|
+
debug(...args) {
|
|
3658
3566
|
this.log(this.globalLog, args);
|
|
3659
|
-
}
|
|
3660
|
-
|
|
3661
|
-
var args = [];
|
|
3662
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3663
|
-
args[_i] = arguments[_i];
|
|
3664
|
-
}
|
|
3567
|
+
}
|
|
3568
|
+
warn(...args) {
|
|
3665
3569
|
this.log(this.globalLogWarn, args);
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3668
|
-
var args = [];
|
|
3669
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3670
|
-
args[_i] = arguments[_i];
|
|
3671
|
-
}
|
|
3570
|
+
}
|
|
3571
|
+
error(...args) {
|
|
3672
3572
|
this.log(this.globalLogError, args);
|
|
3673
|
-
}
|
|
3674
|
-
|
|
3573
|
+
}
|
|
3574
|
+
globalLogWarn(message) {
|
|
3675
3575
|
if (window.console && window.console.warn) {
|
|
3676
3576
|
window.console.warn(message);
|
|
3677
3577
|
}
|
|
3678
3578
|
else {
|
|
3679
3579
|
this.globalLog(message);
|
|
3680
3580
|
}
|
|
3681
|
-
}
|
|
3682
|
-
|
|
3581
|
+
}
|
|
3582
|
+
globalLogError(message) {
|
|
3683
3583
|
if (window.console && window.console.error) {
|
|
3684
3584
|
window.console.error(message);
|
|
3685
3585
|
}
|
|
3686
3586
|
else {
|
|
3687
3587
|
this.globalLogWarn(message);
|
|
3688
3588
|
}
|
|
3689
|
-
}
|
|
3690
|
-
|
|
3691
|
-
var args = [];
|
|
3692
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3693
|
-
args[_i - 1] = arguments[_i];
|
|
3694
|
-
}
|
|
3589
|
+
}
|
|
3590
|
+
log(defaultLoggingFunction, ...args) {
|
|
3695
3591
|
var message = stringify.apply(this, arguments);
|
|
3696
3592
|
if (core_pusher.log) {
|
|
3697
3593
|
core_pusher.log(message);
|
|
3698
3594
|
}
|
|
3699
3595
|
else if (core_pusher.logToConsole) {
|
|
3700
|
-
|
|
3596
|
+
const log = defaultLoggingFunction.bind(this);
|
|
3701
3597
|
log(message);
|
|
3702
3598
|
}
|
|
3703
|
-
}
|
|
3704
|
-
|
|
3705
|
-
}());
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3706
3601
|
/* harmony default export */ var logger = (new logger_Logger());
|
|
3707
3602
|
|
|
3708
3603
|
// CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
|
|
@@ -3710,7 +3605,7 @@ var logger_Logger = (function () {
|
|
|
3710
3605
|
var jsonp = function (context, query, authOptions, authRequestType, callback) {
|
|
3711
3606
|
if (authOptions.headers !== undefined ||
|
|
3712
3607
|
authOptions.headersProvider != null) {
|
|
3713
|
-
logger.warn(
|
|
3608
|
+
logger.warn(`To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`);
|
|
3714
3609
|
}
|
|
3715
3610
|
var callbackName = context.nextAuthCallbackID.toString();
|
|
3716
3611
|
context.nextAuthCallbackID++;
|
|
@@ -3732,11 +3627,11 @@ var jsonp = function (context, query, authOptions, authRequestType, callback) {
|
|
|
3732
3627
|
/* harmony default export */ var jsonp_auth = (jsonp);
|
|
3733
3628
|
|
|
3734
3629
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
|
|
3735
|
-
|
|
3736
|
-
|
|
3630
|
+
class ScriptRequest {
|
|
3631
|
+
constructor(src) {
|
|
3737
3632
|
this.src = src;
|
|
3738
3633
|
}
|
|
3739
|
-
|
|
3634
|
+
send(receiver) {
|
|
3740
3635
|
var self = this;
|
|
3741
3636
|
var errorString = 'Error loading ' + self.src;
|
|
3742
3637
|
self.script = document.createElement('script');
|
|
@@ -3776,8 +3671,8 @@ var ScriptRequest = (function () {
|
|
|
3776
3671
|
if (self.errorScript) {
|
|
3777
3672
|
head.insertBefore(self.errorScript, self.script.nextSibling);
|
|
3778
3673
|
}
|
|
3779
|
-
}
|
|
3780
|
-
|
|
3674
|
+
}
|
|
3675
|
+
cleanup() {
|
|
3781
3676
|
if (this.script) {
|
|
3782
3677
|
this.script.onload = this.script.onerror = null;
|
|
3783
3678
|
this.script.onreadystatechange = null;
|
|
@@ -3790,20 +3685,18 @@ var ScriptRequest = (function () {
|
|
|
3790
3685
|
}
|
|
3791
3686
|
this.script = null;
|
|
3792
3687
|
this.errorScript = null;
|
|
3793
|
-
}
|
|
3794
|
-
|
|
3795
|
-
}());
|
|
3796
|
-
/* harmony default export */ var script_request = (ScriptRequest);
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3797
3690
|
|
|
3798
3691
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
|
|
3799
3692
|
|
|
3800
3693
|
|
|
3801
|
-
|
|
3802
|
-
|
|
3694
|
+
class jsonp_request_JSONPRequest {
|
|
3695
|
+
constructor(url, data) {
|
|
3803
3696
|
this.url = url;
|
|
3804
3697
|
this.data = data;
|
|
3805
3698
|
}
|
|
3806
|
-
|
|
3699
|
+
send(receiver) {
|
|
3807
3700
|
if (this.request) {
|
|
3808
3701
|
return;
|
|
3809
3702
|
}
|
|
@@ -3811,15 +3704,13 @@ var jsonp_request_JSONPRequest = (function () {
|
|
|
3811
3704
|
var url = this.url + '/' + receiver.number + '?' + query;
|
|
3812
3705
|
this.request = runtime.createScriptRequest(url);
|
|
3813
3706
|
this.request.send(receiver);
|
|
3814
|
-
}
|
|
3815
|
-
|
|
3707
|
+
}
|
|
3708
|
+
cleanup() {
|
|
3816
3709
|
if (this.request) {
|
|
3817
3710
|
this.request.cleanup();
|
|
3818
3711
|
}
|
|
3819
|
-
}
|
|
3820
|
-
|
|
3821
|
-
}());
|
|
3822
|
-
/* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3823
3714
|
|
|
3824
3715
|
// CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
|
|
3825
3716
|
|
|
@@ -3844,7 +3735,7 @@ var getAgent = function (sender, useTLS) {
|
|
|
3844
3735
|
};
|
|
3845
3736
|
var jsonp_timeline_jsonp = {
|
|
3846
3737
|
name: 'jsonp',
|
|
3847
|
-
getAgent
|
|
3738
|
+
getAgent
|
|
3848
3739
|
};
|
|
3849
3740
|
/* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
|
|
3850
3741
|
|
|
@@ -3888,14 +3779,14 @@ var sockjs = {
|
|
|
3888
3779
|
|
|
3889
3780
|
// CONCATENATED MODULE: ./src/core/events/callback_registry.ts
|
|
3890
3781
|
|
|
3891
|
-
|
|
3892
|
-
|
|
3782
|
+
class callback_registry_CallbackRegistry {
|
|
3783
|
+
constructor() {
|
|
3893
3784
|
this._callbacks = {};
|
|
3894
3785
|
}
|
|
3895
|
-
|
|
3786
|
+
get(name) {
|
|
3896
3787
|
return this._callbacks[prefix(name)];
|
|
3897
|
-
}
|
|
3898
|
-
|
|
3788
|
+
}
|
|
3789
|
+
add(name, callback, context) {
|
|
3899
3790
|
var prefixedEventName = prefix(name);
|
|
3900
3791
|
this._callbacks[prefixedEventName] =
|
|
3901
3792
|
this._callbacks[prefixedEventName] || [];
|
|
@@ -3903,8 +3794,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
3903
3794
|
fn: callback,
|
|
3904
3795
|
context: context
|
|
3905
3796
|
});
|
|
3906
|
-
}
|
|
3907
|
-
|
|
3797
|
+
}
|
|
3798
|
+
remove(name, callback, context) {
|
|
3908
3799
|
if (!name && !callback && !context) {
|
|
3909
3800
|
this._callbacks = {};
|
|
3910
3801
|
return;
|
|
@@ -3916,8 +3807,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
3916
3807
|
else {
|
|
3917
3808
|
this.removeAllCallbacks(names);
|
|
3918
3809
|
}
|
|
3919
|
-
}
|
|
3920
|
-
|
|
3810
|
+
}
|
|
3811
|
+
removeCallback(names, callback, context) {
|
|
3921
3812
|
apply(names, function (name) {
|
|
3922
3813
|
this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
|
|
3923
3814
|
return ((callback && callback !== binding.fn) ||
|
|
@@ -3927,15 +3818,13 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
3927
3818
|
delete this._callbacks[name];
|
|
3928
3819
|
}
|
|
3929
3820
|
}, this);
|
|
3930
|
-
}
|
|
3931
|
-
|
|
3821
|
+
}
|
|
3822
|
+
removeAllCallbacks(names) {
|
|
3932
3823
|
apply(names, function (name) {
|
|
3933
3824
|
delete this._callbacks[name];
|
|
3934
3825
|
}, this);
|
|
3935
|
-
}
|
|
3936
|
-
|
|
3937
|
-
}());
|
|
3938
|
-
/* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3939
3828
|
function prefix(name) {
|
|
3940
3829
|
return '_' + name;
|
|
3941
3830
|
}
|
|
@@ -3943,38 +3832,38 @@ function prefix(name) {
|
|
|
3943
3832
|
// CONCATENATED MODULE: ./src/core/events/dispatcher.ts
|
|
3944
3833
|
|
|
3945
3834
|
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
this.callbacks = new
|
|
3835
|
+
class dispatcher_Dispatcher {
|
|
3836
|
+
constructor(failThrough) {
|
|
3837
|
+
this.callbacks = new callback_registry_CallbackRegistry();
|
|
3949
3838
|
this.global_callbacks = [];
|
|
3950
3839
|
this.failThrough = failThrough;
|
|
3951
3840
|
}
|
|
3952
|
-
|
|
3841
|
+
bind(eventName, callback, context) {
|
|
3953
3842
|
this.callbacks.add(eventName, callback, context);
|
|
3954
3843
|
return this;
|
|
3955
|
-
}
|
|
3956
|
-
|
|
3844
|
+
}
|
|
3845
|
+
bind_global(callback) {
|
|
3957
3846
|
this.global_callbacks.push(callback);
|
|
3958
3847
|
return this;
|
|
3959
|
-
}
|
|
3960
|
-
|
|
3848
|
+
}
|
|
3849
|
+
unbind(eventName, callback, context) {
|
|
3961
3850
|
this.callbacks.remove(eventName, callback, context);
|
|
3962
3851
|
return this;
|
|
3963
|
-
}
|
|
3964
|
-
|
|
3852
|
+
}
|
|
3853
|
+
unbind_global(callback) {
|
|
3965
3854
|
if (!callback) {
|
|
3966
3855
|
this.global_callbacks = [];
|
|
3967
3856
|
return this;
|
|
3968
3857
|
}
|
|
3969
|
-
this.global_callbacks = filter(this.global_callbacks || [],
|
|
3858
|
+
this.global_callbacks = filter(this.global_callbacks || [], c => c !== callback);
|
|
3970
3859
|
return this;
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3860
|
+
}
|
|
3861
|
+
unbind_all() {
|
|
3973
3862
|
this.unbind();
|
|
3974
3863
|
this.unbind_global();
|
|
3975
3864
|
return this;
|
|
3976
|
-
}
|
|
3977
|
-
|
|
3865
|
+
}
|
|
3866
|
+
emit(eventName, data, metadata) {
|
|
3978
3867
|
for (var i = 0; i < this.global_callbacks.length; i++) {
|
|
3979
3868
|
this.global_callbacks[i](eventName, data);
|
|
3980
3869
|
}
|
|
@@ -3995,54 +3884,36 @@ var dispatcher_Dispatcher = (function () {
|
|
|
3995
3884
|
this.failThrough(eventName, data);
|
|
3996
3885
|
}
|
|
3997
3886
|
return this;
|
|
3998
|
-
}
|
|
3999
|
-
|
|
4000
|
-
}());
|
|
4001
|
-
/* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
4002
3889
|
|
|
4003
3890
|
// CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
|
|
4004
|
-
var transport_connection_extends = (undefined && undefined.__extends) || (function () {
|
|
4005
|
-
var extendStatics = function (d, b) {
|
|
4006
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4007
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4008
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4009
|
-
return extendStatics(d, b);
|
|
4010
|
-
};
|
|
4011
|
-
return function (d, b) {
|
|
4012
|
-
extendStatics(d, b);
|
|
4013
|
-
function __() { this.constructor = d; }
|
|
4014
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4015
|
-
};
|
|
4016
|
-
})();
|
|
4017
3891
|
|
|
4018
3892
|
|
|
4019
3893
|
|
|
4020
3894
|
|
|
4021
3895
|
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
_this.id = _this.timeline.generateUniqueID();
|
|
4036
|
-
return _this;
|
|
3896
|
+
class transport_connection_TransportConnection extends dispatcher_Dispatcher {
|
|
3897
|
+
constructor(hooks, name, priority, key, options) {
|
|
3898
|
+
super();
|
|
3899
|
+
this.initialize = runtime.transportConnectionInitializer;
|
|
3900
|
+
this.hooks = hooks;
|
|
3901
|
+
this.name = name;
|
|
3902
|
+
this.priority = priority;
|
|
3903
|
+
this.key = key;
|
|
3904
|
+
this.options = options;
|
|
3905
|
+
this.state = 'new';
|
|
3906
|
+
this.timeline = options.timeline;
|
|
3907
|
+
this.activityTimeout = options.activityTimeout;
|
|
3908
|
+
this.id = this.timeline.generateUniqueID();
|
|
4037
3909
|
}
|
|
4038
|
-
|
|
3910
|
+
handlesActivityChecks() {
|
|
4039
3911
|
return Boolean(this.hooks.handlesActivityChecks);
|
|
4040
|
-
}
|
|
4041
|
-
|
|
3912
|
+
}
|
|
3913
|
+
supportsPing() {
|
|
4042
3914
|
return Boolean(this.hooks.supportsPing);
|
|
4043
|
-
}
|
|
4044
|
-
|
|
4045
|
-
var _this = this;
|
|
3915
|
+
}
|
|
3916
|
+
connect() {
|
|
4046
3917
|
if (this.socket || this.state !== 'initialized') {
|
|
4047
3918
|
return false;
|
|
4048
3919
|
}
|
|
@@ -4051,18 +3922,18 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
4051
3922
|
this.socket = this.hooks.getSocket(url, this.options);
|
|
4052
3923
|
}
|
|
4053
3924
|
catch (e) {
|
|
4054
|
-
util.defer(
|
|
4055
|
-
|
|
4056
|
-
|
|
3925
|
+
util.defer(() => {
|
|
3926
|
+
this.onError(e);
|
|
3927
|
+
this.changeState('closed');
|
|
4057
3928
|
});
|
|
4058
3929
|
return false;
|
|
4059
3930
|
}
|
|
4060
3931
|
this.bindListeners();
|
|
4061
|
-
logger.debug('Connecting', { transport: this.name, url
|
|
3932
|
+
logger.debug('Connecting', { transport: this.name, url });
|
|
4062
3933
|
this.changeState('connecting');
|
|
4063
3934
|
return true;
|
|
4064
|
-
}
|
|
4065
|
-
|
|
3935
|
+
}
|
|
3936
|
+
close() {
|
|
4066
3937
|
if (this.socket) {
|
|
4067
3938
|
this.socket.close();
|
|
4068
3939
|
return true;
|
|
@@ -4070,13 +3941,12 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
4070
3941
|
else {
|
|
4071
3942
|
return false;
|
|
4072
3943
|
}
|
|
4073
|
-
}
|
|
4074
|
-
|
|
4075
|
-
var _this = this;
|
|
3944
|
+
}
|
|
3945
|
+
send(data) {
|
|
4076
3946
|
if (this.state === 'open') {
|
|
4077
|
-
util.defer(
|
|
4078
|
-
if (
|
|
4079
|
-
|
|
3947
|
+
util.defer(() => {
|
|
3948
|
+
if (this.socket) {
|
|
3949
|
+
this.socket.send(data);
|
|
4080
3950
|
}
|
|
4081
3951
|
});
|
|
4082
3952
|
return true;
|
|
@@ -4084,24 +3954,24 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
4084
3954
|
else {
|
|
4085
3955
|
return false;
|
|
4086
3956
|
}
|
|
4087
|
-
}
|
|
4088
|
-
|
|
3957
|
+
}
|
|
3958
|
+
ping() {
|
|
4089
3959
|
if (this.state === 'open' && this.supportsPing()) {
|
|
4090
3960
|
this.socket.ping();
|
|
4091
3961
|
}
|
|
4092
|
-
}
|
|
4093
|
-
|
|
3962
|
+
}
|
|
3963
|
+
onOpen() {
|
|
4094
3964
|
if (this.hooks.beforeOpen) {
|
|
4095
3965
|
this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
|
|
4096
3966
|
}
|
|
4097
3967
|
this.changeState('open');
|
|
4098
3968
|
this.socket.onopen = undefined;
|
|
4099
|
-
}
|
|
4100
|
-
|
|
3969
|
+
}
|
|
3970
|
+
onError(error) {
|
|
4101
3971
|
this.emit('error', { type: 'WebSocketError', error: error });
|
|
4102
3972
|
this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
|
|
4103
|
-
}
|
|
4104
|
-
|
|
3973
|
+
}
|
|
3974
|
+
onClose(closeEvent) {
|
|
4105
3975
|
if (closeEvent) {
|
|
4106
3976
|
this.changeState('closed', {
|
|
4107
3977
|
code: closeEvent.code,
|
|
@@ -4114,34 +3984,33 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
4114
3984
|
}
|
|
4115
3985
|
this.unbindListeners();
|
|
4116
3986
|
this.socket = undefined;
|
|
4117
|
-
}
|
|
4118
|
-
|
|
3987
|
+
}
|
|
3988
|
+
onMessage(message) {
|
|
4119
3989
|
this.emit('message', message);
|
|
4120
|
-
}
|
|
4121
|
-
|
|
3990
|
+
}
|
|
3991
|
+
onActivity() {
|
|
4122
3992
|
this.emit('activity');
|
|
4123
|
-
}
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
_this.onOpen();
|
|
3993
|
+
}
|
|
3994
|
+
bindListeners() {
|
|
3995
|
+
this.socket.onopen = () => {
|
|
3996
|
+
this.onOpen();
|
|
4128
3997
|
};
|
|
4129
|
-
this.socket.onerror =
|
|
4130
|
-
|
|
3998
|
+
this.socket.onerror = error => {
|
|
3999
|
+
this.onError(error);
|
|
4131
4000
|
};
|
|
4132
|
-
this.socket.onclose =
|
|
4133
|
-
|
|
4001
|
+
this.socket.onclose = closeEvent => {
|
|
4002
|
+
this.onClose(closeEvent);
|
|
4134
4003
|
};
|
|
4135
|
-
this.socket.onmessage =
|
|
4136
|
-
|
|
4004
|
+
this.socket.onmessage = message => {
|
|
4005
|
+
this.onMessage(message);
|
|
4137
4006
|
};
|
|
4138
4007
|
if (this.supportsPing()) {
|
|
4139
|
-
this.socket.onactivity =
|
|
4140
|
-
|
|
4008
|
+
this.socket.onactivity = () => {
|
|
4009
|
+
this.onActivity();
|
|
4141
4010
|
};
|
|
4142
4011
|
}
|
|
4143
|
-
}
|
|
4144
|
-
|
|
4012
|
+
}
|
|
4013
|
+
unbindListeners() {
|
|
4145
4014
|
if (this.socket) {
|
|
4146
4015
|
this.socket.onopen = undefined;
|
|
4147
4016
|
this.socket.onerror = undefined;
|
|
@@ -4151,44 +4020,40 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
4151
4020
|
this.socket.onactivity = undefined;
|
|
4152
4021
|
}
|
|
4153
4022
|
}
|
|
4154
|
-
}
|
|
4155
|
-
|
|
4023
|
+
}
|
|
4024
|
+
changeState(state, params) {
|
|
4156
4025
|
this.state = state;
|
|
4157
4026
|
this.timeline.info(this.buildTimelineMessage({
|
|
4158
4027
|
state: state,
|
|
4159
4028
|
params: params
|
|
4160
4029
|
}));
|
|
4161
4030
|
this.emit(state, params);
|
|
4162
|
-
}
|
|
4163
|
-
|
|
4031
|
+
}
|
|
4032
|
+
buildTimelineMessage(message) {
|
|
4164
4033
|
return extend({ cid: this.id }, message);
|
|
4165
|
-
}
|
|
4166
|
-
|
|
4167
|
-
}(dispatcher));
|
|
4168
|
-
/* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4169
4036
|
|
|
4170
4037
|
// CONCATENATED MODULE: ./src/core/transports/transport.ts
|
|
4171
4038
|
|
|
4172
|
-
|
|
4173
|
-
|
|
4039
|
+
class transport_Transport {
|
|
4040
|
+
constructor(hooks) {
|
|
4174
4041
|
this.hooks = hooks;
|
|
4175
4042
|
}
|
|
4176
|
-
|
|
4043
|
+
isSupported(environment) {
|
|
4177
4044
|
return this.hooks.isSupported(environment);
|
|
4178
|
-
}
|
|
4179
|
-
|
|
4180
|
-
return new
|
|
4181
|
-
}
|
|
4182
|
-
|
|
4183
|
-
}());
|
|
4184
|
-
/* harmony default export */ var transports_transport = (transport_Transport);
|
|
4045
|
+
}
|
|
4046
|
+
createConnection(name, priority, key, options) {
|
|
4047
|
+
return new transport_connection_TransportConnection(this.hooks, name, priority, key, options);
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4185
4050
|
|
|
4186
4051
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
|
|
4187
4052
|
|
|
4188
4053
|
|
|
4189
4054
|
|
|
4190
4055
|
|
|
4191
|
-
var WSTransport = new
|
|
4056
|
+
var WSTransport = new transport_Transport({
|
|
4192
4057
|
urls: ws,
|
|
4193
4058
|
handlesActivityChecks: false,
|
|
4194
4059
|
supportsPing: false,
|
|
@@ -4225,8 +4090,8 @@ var xhrConfiguration = {
|
|
|
4225
4090
|
return runtime.isXHRSupported();
|
|
4226
4091
|
}
|
|
4227
4092
|
};
|
|
4228
|
-
var XHRStreamingTransport = new
|
|
4229
|
-
var XHRPollingTransport = new
|
|
4093
|
+
var XHRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xhrConfiguration)));
|
|
4094
|
+
var XHRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xhrConfiguration));
|
|
4230
4095
|
var Transports = {
|
|
4231
4096
|
ws: WSTransport,
|
|
4232
4097
|
xhr_streaming: XHRStreamingTransport,
|
|
@@ -4241,7 +4106,7 @@ var Transports = {
|
|
|
4241
4106
|
|
|
4242
4107
|
|
|
4243
4108
|
|
|
4244
|
-
var SockJSTransport = new
|
|
4109
|
+
var SockJSTransport = new transport_Transport({
|
|
4245
4110
|
file: 'sockjs',
|
|
4246
4111
|
urls: sockjs,
|
|
4247
4112
|
handlesActivityChecks: true,
|
|
@@ -4272,33 +4137,19 @@ var xdrConfiguration = {
|
|
|
4272
4137
|
return yes;
|
|
4273
4138
|
}
|
|
4274
4139
|
};
|
|
4275
|
-
var XDRStreamingTransport = new
|
|
4276
|
-
var XDRPollingTransport = new
|
|
4140
|
+
var XDRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xdrConfiguration)));
|
|
4141
|
+
var XDRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xdrConfiguration));
|
|
4277
4142
|
transports.xdr_streaming = XDRStreamingTransport;
|
|
4278
4143
|
transports.xdr_polling = XDRPollingTransport;
|
|
4279
4144
|
transports.sockjs = SockJSTransport;
|
|
4280
4145
|
/* harmony default export */ var transports_transports = (transports);
|
|
4281
4146
|
|
|
4282
4147
|
// CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
|
|
4283
|
-
var net_info_extends = (undefined && undefined.__extends) || (function () {
|
|
4284
|
-
var extendStatics = function (d, b) {
|
|
4285
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4286
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4287
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4288
|
-
return extendStatics(d, b);
|
|
4289
|
-
};
|
|
4290
|
-
return function (d, b) {
|
|
4291
|
-
extendStatics(d, b);
|
|
4292
|
-
function __() { this.constructor = d; }
|
|
4293
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4294
|
-
};
|
|
4295
|
-
})();
|
|
4296
4148
|
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
var
|
|
4301
|
-
var self = _this;
|
|
4149
|
+
class net_info_NetInfo extends dispatcher_Dispatcher {
|
|
4150
|
+
constructor() {
|
|
4151
|
+
super();
|
|
4152
|
+
var self = this;
|
|
4302
4153
|
if (window.addEventListener !== undefined) {
|
|
4303
4154
|
window.addEventListener('online', function () {
|
|
4304
4155
|
self.emit('online');
|
|
@@ -4307,34 +4158,30 @@ var NetInfo = (function (_super) {
|
|
|
4307
4158
|
self.emit('offline');
|
|
4308
4159
|
}, false);
|
|
4309
4160
|
}
|
|
4310
|
-
return _this;
|
|
4311
4161
|
}
|
|
4312
|
-
|
|
4162
|
+
isOnline() {
|
|
4313
4163
|
if (window.navigator.onLine === undefined) {
|
|
4314
4164
|
return true;
|
|
4315
4165
|
}
|
|
4316
4166
|
else {
|
|
4317
4167
|
return window.navigator.onLine;
|
|
4318
4168
|
}
|
|
4319
|
-
}
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
var net_info_Network = new NetInfo();
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
var net_info_Network = new net_info_NetInfo();
|
|
4324
4172
|
|
|
4325
4173
|
// CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
|
|
4326
4174
|
|
|
4327
4175
|
|
|
4328
|
-
|
|
4329
|
-
|
|
4176
|
+
class assistant_to_the_transport_manager_AssistantToTheTransportManager {
|
|
4177
|
+
constructor(manager, transport, options) {
|
|
4330
4178
|
this.manager = manager;
|
|
4331
4179
|
this.transport = transport;
|
|
4332
4180
|
this.minPingDelay = options.minPingDelay;
|
|
4333
4181
|
this.maxPingDelay = options.maxPingDelay;
|
|
4334
4182
|
this.pingDelay = undefined;
|
|
4335
4183
|
}
|
|
4336
|
-
|
|
4337
|
-
var _this = this;
|
|
4184
|
+
createConnection(name, priority, key, options) {
|
|
4338
4185
|
options = extend({}, options, {
|
|
4339
4186
|
activityTimeout: this.pingDelay
|
|
4340
4187
|
});
|
|
@@ -4345,31 +4192,29 @@ var assistant_to_the_transport_manager_AssistantToTheTransportManager = (functio
|
|
|
4345
4192
|
connection.bind('closed', onClosed);
|
|
4346
4193
|
openTimestamp = util.now();
|
|
4347
4194
|
};
|
|
4348
|
-
var onClosed =
|
|
4195
|
+
var onClosed = closeEvent => {
|
|
4349
4196
|
connection.unbind('closed', onClosed);
|
|
4350
4197
|
if (closeEvent.code === 1002 || closeEvent.code === 1003) {
|
|
4351
|
-
|
|
4198
|
+
this.manager.reportDeath();
|
|
4352
4199
|
}
|
|
4353
4200
|
else if (!closeEvent.wasClean && openTimestamp) {
|
|
4354
4201
|
var lifespan = util.now() - openTimestamp;
|
|
4355
|
-
if (lifespan < 2 *
|
|
4356
|
-
|
|
4357
|
-
|
|
4202
|
+
if (lifespan < 2 * this.maxPingDelay) {
|
|
4203
|
+
this.manager.reportDeath();
|
|
4204
|
+
this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);
|
|
4358
4205
|
}
|
|
4359
4206
|
}
|
|
4360
4207
|
};
|
|
4361
4208
|
connection.bind('open', onOpen);
|
|
4362
4209
|
return connection;
|
|
4363
|
-
}
|
|
4364
|
-
|
|
4210
|
+
}
|
|
4211
|
+
isSupported(environment) {
|
|
4365
4212
|
return this.manager.isAlive() && this.transport.isSupported(environment);
|
|
4366
|
-
}
|
|
4367
|
-
|
|
4368
|
-
}());
|
|
4369
|
-
/* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4370
4215
|
|
|
4371
4216
|
// CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
|
|
4372
|
-
|
|
4217
|
+
const Protocol = {
|
|
4373
4218
|
decodeMessage: function (messageEvent) {
|
|
4374
4219
|
try {
|
|
4375
4220
|
var messageData = JSON.parse(messageEvent.data);
|
|
@@ -4462,68 +4307,52 @@ var Protocol = {
|
|
|
4462
4307
|
/* harmony default export */ var protocol_protocol = (Protocol);
|
|
4463
4308
|
|
|
4464
4309
|
// CONCATENATED MODULE: ./src/core/connection/connection.ts
|
|
4465
|
-
var connection_extends = (undefined && undefined.__extends) || (function () {
|
|
4466
|
-
var extendStatics = function (d, b) {
|
|
4467
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4468
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4469
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4470
|
-
return extendStatics(d, b);
|
|
4471
|
-
};
|
|
4472
|
-
return function (d, b) {
|
|
4473
|
-
extendStatics(d, b);
|
|
4474
|
-
function __() { this.constructor = d; }
|
|
4475
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4476
|
-
};
|
|
4477
|
-
})();
|
|
4478
4310
|
|
|
4479
4311
|
|
|
4480
4312
|
|
|
4481
4313
|
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
_this.bindListeners();
|
|
4490
|
-
return _this;
|
|
4314
|
+
class connection_Connection extends dispatcher_Dispatcher {
|
|
4315
|
+
constructor(id, transport) {
|
|
4316
|
+
super();
|
|
4317
|
+
this.id = id;
|
|
4318
|
+
this.transport = transport;
|
|
4319
|
+
this.activityTimeout = transport.activityTimeout;
|
|
4320
|
+
this.bindListeners();
|
|
4491
4321
|
}
|
|
4492
|
-
|
|
4322
|
+
handlesActivityChecks() {
|
|
4493
4323
|
return this.transport.handlesActivityChecks();
|
|
4494
|
-
}
|
|
4495
|
-
|
|
4324
|
+
}
|
|
4325
|
+
send(data) {
|
|
4496
4326
|
return this.transport.send(data);
|
|
4497
|
-
}
|
|
4498
|
-
|
|
4327
|
+
}
|
|
4328
|
+
send_event(name, data, channel) {
|
|
4499
4329
|
var event = { event: name, data: data };
|
|
4500
4330
|
if (channel) {
|
|
4501
4331
|
event.channel = channel;
|
|
4502
4332
|
}
|
|
4503
4333
|
logger.debug('Event sent', event);
|
|
4504
4334
|
return this.send(protocol_protocol.encodeMessage(event));
|
|
4505
|
-
}
|
|
4506
|
-
|
|
4335
|
+
}
|
|
4336
|
+
ping() {
|
|
4507
4337
|
if (this.transport.supportsPing()) {
|
|
4508
4338
|
this.transport.ping();
|
|
4509
4339
|
}
|
|
4510
4340
|
else {
|
|
4511
4341
|
this.send_event('pusher:ping', {});
|
|
4512
4342
|
}
|
|
4513
|
-
}
|
|
4514
|
-
|
|
4343
|
+
}
|
|
4344
|
+
close() {
|
|
4515
4345
|
this.transport.close();
|
|
4516
|
-
}
|
|
4517
|
-
|
|
4518
|
-
var _this = this;
|
|
4346
|
+
}
|
|
4347
|
+
bindListeners() {
|
|
4519
4348
|
var listeners = {
|
|
4520
|
-
message:
|
|
4349
|
+
message: (messageEvent) => {
|
|
4521
4350
|
var pusherEvent;
|
|
4522
4351
|
try {
|
|
4523
4352
|
pusherEvent = protocol_protocol.decodeMessage(messageEvent);
|
|
4524
4353
|
}
|
|
4525
4354
|
catch (e) {
|
|
4526
|
-
|
|
4355
|
+
this.emit('error', {
|
|
4527
4356
|
type: 'MessageParseError',
|
|
4528
4357
|
error: e,
|
|
4529
4358
|
data: messageEvent.data
|
|
@@ -4533,46 +4362,46 @@ var connection_Connection = (function (_super) {
|
|
|
4533
4362
|
logger.debug('Event recd', pusherEvent);
|
|
4534
4363
|
switch (pusherEvent.event) {
|
|
4535
4364
|
case 'pusher:error':
|
|
4536
|
-
|
|
4365
|
+
this.emit('error', {
|
|
4537
4366
|
type: 'PusherError',
|
|
4538
4367
|
data: pusherEvent.data
|
|
4539
4368
|
});
|
|
4540
4369
|
break;
|
|
4541
4370
|
case 'pusher:ping':
|
|
4542
|
-
|
|
4371
|
+
this.emit('ping');
|
|
4543
4372
|
break;
|
|
4544
4373
|
case 'pusher:pong':
|
|
4545
|
-
|
|
4374
|
+
this.emit('pong');
|
|
4546
4375
|
break;
|
|
4547
4376
|
}
|
|
4548
|
-
|
|
4377
|
+
this.emit('message', pusherEvent);
|
|
4549
4378
|
}
|
|
4550
4379
|
},
|
|
4551
|
-
activity:
|
|
4552
|
-
|
|
4380
|
+
activity: () => {
|
|
4381
|
+
this.emit('activity');
|
|
4553
4382
|
},
|
|
4554
|
-
error:
|
|
4555
|
-
|
|
4383
|
+
error: error => {
|
|
4384
|
+
this.emit('error', error);
|
|
4556
4385
|
},
|
|
4557
|
-
closed:
|
|
4386
|
+
closed: closeEvent => {
|
|
4558
4387
|
unbindListeners();
|
|
4559
4388
|
if (closeEvent && closeEvent.code) {
|
|
4560
|
-
|
|
4389
|
+
this.handleCloseEvent(closeEvent);
|
|
4561
4390
|
}
|
|
4562
|
-
|
|
4563
|
-
|
|
4391
|
+
this.transport = null;
|
|
4392
|
+
this.emit('closed');
|
|
4564
4393
|
}
|
|
4565
4394
|
};
|
|
4566
|
-
var unbindListeners =
|
|
4567
|
-
objectApply(listeners,
|
|
4568
|
-
|
|
4395
|
+
var unbindListeners = () => {
|
|
4396
|
+
objectApply(listeners, (listener, event) => {
|
|
4397
|
+
this.transport.unbind(event, listener);
|
|
4569
4398
|
});
|
|
4570
4399
|
};
|
|
4571
|
-
objectApply(listeners,
|
|
4572
|
-
|
|
4400
|
+
objectApply(listeners, (listener, event) => {
|
|
4401
|
+
this.transport.bind(event, listener);
|
|
4573
4402
|
});
|
|
4574
|
-
}
|
|
4575
|
-
|
|
4403
|
+
}
|
|
4404
|
+
handleCloseEvent(closeEvent) {
|
|
4576
4405
|
var action = protocol_protocol.getCloseAction(closeEvent);
|
|
4577
4406
|
var error = protocol_protocol.getCloseError(closeEvent);
|
|
4578
4407
|
if (error) {
|
|
@@ -4581,136 +4410,114 @@ var connection_Connection = (function (_super) {
|
|
|
4581
4410
|
if (action) {
|
|
4582
4411
|
this.emit(action, { action: action, error: error });
|
|
4583
4412
|
}
|
|
4584
|
-
}
|
|
4585
|
-
|
|
4586
|
-
}(dispatcher));
|
|
4587
|
-
/* harmony default export */ var connection_connection = (connection_Connection);
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4588
4415
|
|
|
4589
4416
|
// CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
|
|
4590
4417
|
|
|
4591
4418
|
|
|
4592
4419
|
|
|
4593
|
-
|
|
4594
|
-
|
|
4420
|
+
class handshake_Handshake {
|
|
4421
|
+
constructor(transport, callback) {
|
|
4595
4422
|
this.transport = transport;
|
|
4596
4423
|
this.callback = callback;
|
|
4597
4424
|
this.bindListeners();
|
|
4598
4425
|
}
|
|
4599
|
-
|
|
4426
|
+
close() {
|
|
4600
4427
|
this.unbindListeners();
|
|
4601
4428
|
this.transport.close();
|
|
4602
|
-
}
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
_this.unbindListeners();
|
|
4429
|
+
}
|
|
4430
|
+
bindListeners() {
|
|
4431
|
+
this.onMessage = m => {
|
|
4432
|
+
this.unbindListeners();
|
|
4607
4433
|
var result;
|
|
4608
4434
|
try {
|
|
4609
4435
|
result = protocol_protocol.processHandshake(m);
|
|
4610
4436
|
}
|
|
4611
4437
|
catch (e) {
|
|
4612
|
-
|
|
4613
|
-
|
|
4438
|
+
this.finish('error', { error: e });
|
|
4439
|
+
this.transport.close();
|
|
4614
4440
|
return;
|
|
4615
4441
|
}
|
|
4616
4442
|
if (result.action === 'connected') {
|
|
4617
|
-
|
|
4618
|
-
connection: new
|
|
4443
|
+
this.finish('connected', {
|
|
4444
|
+
connection: new connection_Connection(result.id, this.transport),
|
|
4619
4445
|
activityTimeout: result.activityTimeout
|
|
4620
4446
|
});
|
|
4621
4447
|
}
|
|
4622
4448
|
else {
|
|
4623
|
-
|
|
4624
|
-
|
|
4449
|
+
this.finish(result.action, { error: result.error });
|
|
4450
|
+
this.transport.close();
|
|
4625
4451
|
}
|
|
4626
4452
|
};
|
|
4627
|
-
this.onClosed =
|
|
4628
|
-
|
|
4453
|
+
this.onClosed = closeEvent => {
|
|
4454
|
+
this.unbindListeners();
|
|
4629
4455
|
var action = protocol_protocol.getCloseAction(closeEvent) || 'backoff';
|
|
4630
4456
|
var error = protocol_protocol.getCloseError(closeEvent);
|
|
4631
|
-
|
|
4457
|
+
this.finish(action, { error: error });
|
|
4632
4458
|
};
|
|
4633
4459
|
this.transport.bind('message', this.onMessage);
|
|
4634
4460
|
this.transport.bind('closed', this.onClosed);
|
|
4635
|
-
}
|
|
4636
|
-
|
|
4461
|
+
}
|
|
4462
|
+
unbindListeners() {
|
|
4637
4463
|
this.transport.unbind('message', this.onMessage);
|
|
4638
4464
|
this.transport.unbind('closed', this.onClosed);
|
|
4639
|
-
}
|
|
4640
|
-
|
|
4465
|
+
}
|
|
4466
|
+
finish(action, params) {
|
|
4641
4467
|
this.callback(extend({ transport: this.transport, action: action }, params));
|
|
4642
|
-
}
|
|
4643
|
-
|
|
4644
|
-
}());
|
|
4645
|
-
/* harmony default export */ var connection_handshake = (handshake_Handshake);
|
|
4468
|
+
}
|
|
4469
|
+
}
|
|
4646
4470
|
|
|
4647
4471
|
// CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
|
|
4648
4472
|
|
|
4649
|
-
|
|
4650
|
-
|
|
4473
|
+
class timeline_sender_TimelineSender {
|
|
4474
|
+
constructor(timeline, options) {
|
|
4651
4475
|
this.timeline = timeline;
|
|
4652
4476
|
this.options = options || {};
|
|
4653
4477
|
}
|
|
4654
|
-
|
|
4478
|
+
send(useTLS, callback) {
|
|
4655
4479
|
if (this.timeline.isEmpty()) {
|
|
4656
4480
|
return;
|
|
4657
4481
|
}
|
|
4658
4482
|
this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
|
-
}());
|
|
4662
|
-
/* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4663
4485
|
|
|
4664
4486
|
// CONCATENATED MODULE: ./src/core/channels/channel.ts
|
|
4665
|
-
var channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4666
|
-
var extendStatics = function (d, b) {
|
|
4667
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4668
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4669
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4670
|
-
return extendStatics(d, b);
|
|
4671
|
-
};
|
|
4672
|
-
return function (d, b) {
|
|
4673
|
-
extendStatics(d, b);
|
|
4674
|
-
function __() { this.constructor = d; }
|
|
4675
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4676
|
-
};
|
|
4677
|
-
})();
|
|
4678
4487
|
|
|
4679
4488
|
|
|
4680
4489
|
|
|
4681
4490
|
|
|
4682
4491
|
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
var _this = _super.call(this, function (event, data) {
|
|
4492
|
+
class channel_Channel extends dispatcher_Dispatcher {
|
|
4493
|
+
constructor(name, pusher) {
|
|
4494
|
+
super(function (event, data) {
|
|
4687
4495
|
logger.debug('No callbacks on ' + name + ' for ' + event);
|
|
4688
|
-
})
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
Channel.prototype.authorize = function (socketId, callback) {
|
|
4496
|
+
});
|
|
4497
|
+
this.name = name;
|
|
4498
|
+
this.pusher = pusher;
|
|
4499
|
+
this.subscribed = false;
|
|
4500
|
+
this.subscriptionPending = false;
|
|
4501
|
+
this.subscriptionCancelled = false;
|
|
4502
|
+
}
|
|
4503
|
+
authorize(socketId, callback) {
|
|
4697
4504
|
return callback(null, { auth: '' });
|
|
4698
|
-
}
|
|
4699
|
-
|
|
4505
|
+
}
|
|
4506
|
+
trigger(event, data) {
|
|
4700
4507
|
if (event.indexOf('client-') !== 0) {
|
|
4701
4508
|
throw new BadEventName("Event '" + event + "' does not start with 'client-'");
|
|
4702
4509
|
}
|
|
4703
4510
|
if (!this.subscribed) {
|
|
4704
4511
|
var suffix = url_store.buildLogSuffix('triggeringClientEvents');
|
|
4705
|
-
logger.warn(
|
|
4512
|
+
logger.warn(`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`);
|
|
4706
4513
|
}
|
|
4707
4514
|
return this.pusher.send_event(event, data, this.name);
|
|
4708
|
-
}
|
|
4709
|
-
|
|
4515
|
+
}
|
|
4516
|
+
disconnect() {
|
|
4710
4517
|
this.subscribed = false;
|
|
4711
4518
|
this.subscriptionPending = false;
|
|
4712
|
-
}
|
|
4713
|
-
|
|
4519
|
+
}
|
|
4520
|
+
handleEvent(event) {
|
|
4714
4521
|
var eventName = event.event;
|
|
4715
4522
|
var data = event.data;
|
|
4716
4523
|
if (eventName === 'pusher_internal:subscription_succeeded') {
|
|
@@ -4723,8 +4530,8 @@ var channel_Channel = (function (_super) {
|
|
|
4723
4530
|
var metadata = {};
|
|
4724
4531
|
this.emit(eventName, data, metadata);
|
|
4725
4532
|
}
|
|
4726
|
-
}
|
|
4727
|
-
|
|
4533
|
+
}
|
|
4534
|
+
handleSubscriptionSucceededEvent(event) {
|
|
4728
4535
|
this.subscriptionPending = false;
|
|
4729
4536
|
this.subscribed = true;
|
|
4730
4537
|
if (this.subscriptionCancelled) {
|
|
@@ -4733,91 +4540,69 @@ var channel_Channel = (function (_super) {
|
|
|
4733
4540
|
else {
|
|
4734
4541
|
this.emit('pusher:subscription_succeeded', event.data);
|
|
4735
4542
|
}
|
|
4736
|
-
}
|
|
4737
|
-
|
|
4543
|
+
}
|
|
4544
|
+
handleSubscriptionCountEvent(event) {
|
|
4738
4545
|
if (event.data.subscription_count) {
|
|
4739
4546
|
this.subscriptionCount = event.data.subscription_count;
|
|
4740
4547
|
}
|
|
4741
4548
|
this.emit('pusher:subscription_count', event.data);
|
|
4742
|
-
}
|
|
4743
|
-
|
|
4744
|
-
var _this = this;
|
|
4549
|
+
}
|
|
4550
|
+
subscribe() {
|
|
4745
4551
|
if (this.subscribed) {
|
|
4746
4552
|
return;
|
|
4747
4553
|
}
|
|
4748
4554
|
this.subscriptionPending = true;
|
|
4749
4555
|
this.subscriptionCancelled = false;
|
|
4750
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
4556
|
+
this.authorize(this.pusher.connection.socket_id, (error, data) => {
|
|
4751
4557
|
if (error) {
|
|
4752
|
-
|
|
4558
|
+
this.subscriptionPending = false;
|
|
4753
4559
|
logger.error(error.toString());
|
|
4754
|
-
|
|
4560
|
+
this.emit('pusher:subscription_error', Object.assign({}, {
|
|
4755
4561
|
type: 'AuthError',
|
|
4756
4562
|
error: error.message
|
|
4757
4563
|
}, error instanceof HTTPAuthError ? { status: error.status } : {}));
|
|
4758
4564
|
}
|
|
4759
4565
|
else {
|
|
4760
|
-
|
|
4566
|
+
this.pusher.send_event('pusher:subscribe', {
|
|
4761
4567
|
auth: data.auth,
|
|
4762
4568
|
channel_data: data.channel_data,
|
|
4763
|
-
channel:
|
|
4569
|
+
channel: this.name
|
|
4764
4570
|
});
|
|
4765
4571
|
}
|
|
4766
4572
|
});
|
|
4767
|
-
}
|
|
4768
|
-
|
|
4573
|
+
}
|
|
4574
|
+
unsubscribe() {
|
|
4769
4575
|
this.subscribed = false;
|
|
4770
4576
|
this.pusher.send_event('pusher:unsubscribe', {
|
|
4771
4577
|
channel: this.name
|
|
4772
4578
|
});
|
|
4773
|
-
}
|
|
4774
|
-
|
|
4579
|
+
}
|
|
4580
|
+
cancelSubscription() {
|
|
4775
4581
|
this.subscriptionCancelled = true;
|
|
4776
|
-
}
|
|
4777
|
-
|
|
4582
|
+
}
|
|
4583
|
+
reinstateSubscription() {
|
|
4778
4584
|
this.subscriptionCancelled = false;
|
|
4779
|
-
}
|
|
4780
|
-
|
|
4781
|
-
}(dispatcher));
|
|
4782
|
-
/* harmony default export */ var channels_channel = (channel_Channel);
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4783
4587
|
|
|
4784
4588
|
// CONCATENATED MODULE: ./src/core/channels/private_channel.ts
|
|
4785
|
-
var private_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4786
|
-
var extendStatics = function (d, b) {
|
|
4787
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4788
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4789
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4790
|
-
return extendStatics(d, b);
|
|
4791
|
-
};
|
|
4792
|
-
return function (d, b) {
|
|
4793
|
-
extendStatics(d, b);
|
|
4794
|
-
function __() { this.constructor = d; }
|
|
4795
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4796
|
-
};
|
|
4797
|
-
})();
|
|
4798
4589
|
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
function PrivateChannel() {
|
|
4802
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4803
|
-
}
|
|
4804
|
-
PrivateChannel.prototype.authorize = function (socketId, callback) {
|
|
4590
|
+
class private_channel_PrivateChannel extends channel_Channel {
|
|
4591
|
+
authorize(socketId, callback) {
|
|
4805
4592
|
return this.pusher.config.channelAuthorizer({
|
|
4806
4593
|
channelName: this.name,
|
|
4807
4594
|
socketId: socketId
|
|
4808
4595
|
}, callback);
|
|
4809
|
-
}
|
|
4810
|
-
|
|
4811
|
-
}(channels_channel));
|
|
4812
|
-
/* harmony default export */ var private_channel = (PrivateChannel);
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4813
4598
|
|
|
4814
4599
|
// CONCATENATED MODULE: ./src/core/channels/members.ts
|
|
4815
4600
|
|
|
4816
|
-
|
|
4817
|
-
|
|
4601
|
+
class members_Members {
|
|
4602
|
+
constructor() {
|
|
4818
4603
|
this.reset();
|
|
4819
4604
|
}
|
|
4820
|
-
|
|
4605
|
+
get(id) {
|
|
4821
4606
|
if (Object.prototype.hasOwnProperty.call(this.members, id)) {
|
|
4822
4607
|
return {
|
|
4823
4608
|
id: id,
|
|
@@ -4827,60 +4612,44 @@ var members_Members = (function () {
|
|
|
4827
4612
|
else {
|
|
4828
4613
|
return null;
|
|
4829
4614
|
}
|
|
4830
|
-
}
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
callback(_this.get(id));
|
|
4615
|
+
}
|
|
4616
|
+
each(callback) {
|
|
4617
|
+
objectApply(this.members, (member, id) => {
|
|
4618
|
+
callback(this.get(id));
|
|
4835
4619
|
});
|
|
4836
|
-
}
|
|
4837
|
-
|
|
4620
|
+
}
|
|
4621
|
+
setMyID(id) {
|
|
4838
4622
|
this.myID = id;
|
|
4839
|
-
}
|
|
4840
|
-
|
|
4623
|
+
}
|
|
4624
|
+
onSubscription(subscriptionData) {
|
|
4841
4625
|
this.members = subscriptionData.presence.hash;
|
|
4842
4626
|
this.count = subscriptionData.presence.count;
|
|
4843
4627
|
this.me = this.get(this.myID);
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4628
|
+
}
|
|
4629
|
+
addMember(memberData) {
|
|
4846
4630
|
if (this.get(memberData.user_id) === null) {
|
|
4847
4631
|
this.count++;
|
|
4848
4632
|
}
|
|
4849
4633
|
this.members[memberData.user_id] = memberData.user_info;
|
|
4850
4634
|
return this.get(memberData.user_id);
|
|
4851
|
-
}
|
|
4852
|
-
|
|
4635
|
+
}
|
|
4636
|
+
removeMember(memberData) {
|
|
4853
4637
|
var member = this.get(memberData.user_id);
|
|
4854
4638
|
if (member) {
|
|
4855
4639
|
delete this.members[memberData.user_id];
|
|
4856
4640
|
this.count--;
|
|
4857
4641
|
}
|
|
4858
4642
|
return member;
|
|
4859
|
-
}
|
|
4860
|
-
|
|
4643
|
+
}
|
|
4644
|
+
reset() {
|
|
4861
4645
|
this.members = {};
|
|
4862
4646
|
this.count = 0;
|
|
4863
4647
|
this.myID = null;
|
|
4864
4648
|
this.me = null;
|
|
4865
|
-
}
|
|
4866
|
-
|
|
4867
|
-
}());
|
|
4868
|
-
/* harmony default export */ var members = (members_Members);
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4869
4651
|
|
|
4870
4652
|
// CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
|
|
4871
|
-
var presence_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
4872
|
-
var extendStatics = function (d, b) {
|
|
4873
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4874
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4875
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4876
|
-
return extendStatics(d, b);
|
|
4877
|
-
};
|
|
4878
|
-
return function (d, b) {
|
|
4879
|
-
extendStatics(d, b);
|
|
4880
|
-
function __() { this.constructor = d; }
|
|
4881
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4882
|
-
};
|
|
4883
|
-
})();
|
|
4884
4653
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4885
4654
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4886
4655
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -4890,80 +4659,42 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
4890
4659
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
4891
4660
|
});
|
|
4892
4661
|
};
|
|
4893
|
-
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
4894
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4895
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
4896
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
4897
|
-
function step(op) {
|
|
4898
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
4899
|
-
while (_) try {
|
|
4900
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
4901
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
4902
|
-
switch (op[0]) {
|
|
4903
|
-
case 0: case 1: t = op; break;
|
|
4904
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
4905
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
4906
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
4907
|
-
default:
|
|
4908
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
4909
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
4910
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
4911
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
4912
|
-
if (t[2]) _.ops.pop();
|
|
4913
|
-
_.trys.pop(); continue;
|
|
4914
|
-
}
|
|
4915
|
-
op = body.call(thisArg, _);
|
|
4916
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
4917
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
4918
|
-
}
|
|
4919
|
-
};
|
|
4920
4662
|
|
|
4921
4663
|
|
|
4922
4664
|
|
|
4923
4665
|
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
switch (_a.label) {
|
|
4937
|
-
case 0:
|
|
4938
|
-
if (!!error) return [3, 3];
|
|
4939
|
-
authData = authData;
|
|
4940
|
-
if (!(authData.channel_data != null)) return [3, 1];
|
|
4941
|
-
channelData = JSON.parse(authData.channel_data);
|
|
4942
|
-
this.members.setMyID(channelData.user_id);
|
|
4943
|
-
return [3, 3];
|
|
4944
|
-
case 1: return [4, this.pusher.user.signinDonePromise];
|
|
4945
|
-
case 2:
|
|
4946
|
-
_a.sent();
|
|
4947
|
-
if (this.pusher.user.user_data != null) {
|
|
4948
|
-
this.members.setMyID(this.pusher.user.user_data.id);
|
|
4949
|
-
}
|
|
4950
|
-
else {
|
|
4951
|
-
suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
4952
|
-
logger.error("Invalid auth response for channel '" + this.name + "', " +
|
|
4953
|
-
("expected 'channel_data' field. " + suffix + ", ") +
|
|
4954
|
-
"or the user should be signed in.");
|
|
4955
|
-
callback('Invalid auth response');
|
|
4956
|
-
return [2];
|
|
4957
|
-
}
|
|
4958
|
-
_a.label = 3;
|
|
4959
|
-
case 3:
|
|
4960
|
-
callback(error, authData);
|
|
4961
|
-
return [2];
|
|
4666
|
+
class presence_channel_PresenceChannel extends private_channel_PrivateChannel {
|
|
4667
|
+
constructor(name, pusher) {
|
|
4668
|
+
super(name, pusher);
|
|
4669
|
+
this.members = new members_Members();
|
|
4670
|
+
}
|
|
4671
|
+
authorize(socketId, callback) {
|
|
4672
|
+
super.authorize(socketId, (error, authData) => __awaiter(this, void 0, void 0, function* () {
|
|
4673
|
+
if (!error) {
|
|
4674
|
+
authData = authData;
|
|
4675
|
+
if (authData.channel_data != null) {
|
|
4676
|
+
var channelData = JSON.parse(authData.channel_data);
|
|
4677
|
+
this.members.setMyID(channelData.user_id);
|
|
4962
4678
|
}
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4679
|
+
else {
|
|
4680
|
+
yield this.pusher.user.signinDonePromise;
|
|
4681
|
+
if (this.pusher.user.user_data != null) {
|
|
4682
|
+
this.members.setMyID(this.pusher.user.user_data.id);
|
|
4683
|
+
}
|
|
4684
|
+
else {
|
|
4685
|
+
let suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
4686
|
+
logger.error(`Invalid auth response for channel '${this.name}', ` +
|
|
4687
|
+
`expected 'channel_data' field. ${suffix}, ` +
|
|
4688
|
+
`or the user should be signed in.`);
|
|
4689
|
+
callback('Invalid auth response');
|
|
4690
|
+
return;
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
callback(error, authData);
|
|
4695
|
+
}));
|
|
4696
|
+
}
|
|
4697
|
+
handleEvent(event) {
|
|
4967
4698
|
var eventName = event.event;
|
|
4968
4699
|
if (eventName.indexOf('pusher_internal:') === 0) {
|
|
4969
4700
|
this.handleInternalEvent(event);
|
|
@@ -4976,8 +4707,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
4976
4707
|
}
|
|
4977
4708
|
this.emit(eventName, data, metadata);
|
|
4978
4709
|
}
|
|
4979
|
-
}
|
|
4980
|
-
|
|
4710
|
+
}
|
|
4711
|
+
handleInternalEvent(event) {
|
|
4981
4712
|
var eventName = event.event;
|
|
4982
4713
|
var data = event.data;
|
|
4983
4714
|
switch (eventName) {
|
|
@@ -4998,8 +4729,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
4998
4729
|
}
|
|
4999
4730
|
break;
|
|
5000
4731
|
}
|
|
5001
|
-
}
|
|
5002
|
-
|
|
4732
|
+
}
|
|
4733
|
+
handleSubscriptionSucceededEvent(event) {
|
|
5003
4734
|
this.subscriptionPending = false;
|
|
5004
4735
|
this.subscribed = true;
|
|
5005
4736
|
if (this.subscriptionCancelled) {
|
|
@@ -5009,14 +4740,12 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
5009
4740
|
this.members.onSubscription(event.data);
|
|
5010
4741
|
this.emit('pusher:subscription_succeeded', this.members);
|
|
5011
4742
|
}
|
|
5012
|
-
}
|
|
5013
|
-
|
|
4743
|
+
}
|
|
4744
|
+
disconnect() {
|
|
5014
4745
|
this.members.reset();
|
|
5015
|
-
|
|
5016
|
-
}
|
|
5017
|
-
|
|
5018
|
-
}(private_channel));
|
|
5019
|
-
/* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
|
|
4746
|
+
super.disconnect();
|
|
4747
|
+
}
|
|
4748
|
+
}
|
|
5020
4749
|
|
|
5021
4750
|
// EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js
|
|
5022
4751
|
var utf8 = __webpack_require__(1);
|
|
@@ -5025,64 +4754,47 @@ var utf8 = __webpack_require__(1);
|
|
|
5025
4754
|
var base64 = __webpack_require__(0);
|
|
5026
4755
|
|
|
5027
4756
|
// CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
|
|
5028
|
-
var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
5029
|
-
var extendStatics = function (d, b) {
|
|
5030
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5031
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5032
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
5033
|
-
return extendStatics(d, b);
|
|
5034
|
-
};
|
|
5035
|
-
return function (d, b) {
|
|
5036
|
-
extendStatics(d, b);
|
|
5037
|
-
function __() { this.constructor = d; }
|
|
5038
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
5039
|
-
};
|
|
5040
|
-
})();
|
|
5041
4757
|
|
|
5042
4758
|
|
|
5043
4759
|
|
|
5044
4760
|
|
|
5045
4761
|
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
_this.nacl = nacl;
|
|
5052
|
-
return _this;
|
|
4762
|
+
class encrypted_channel_EncryptedChannel extends private_channel_PrivateChannel {
|
|
4763
|
+
constructor(name, pusher, nacl) {
|
|
4764
|
+
super(name, pusher);
|
|
4765
|
+
this.key = null;
|
|
4766
|
+
this.nacl = nacl;
|
|
5053
4767
|
}
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) {
|
|
4768
|
+
authorize(socketId, callback) {
|
|
4769
|
+
super.authorize(socketId, (error, authData) => {
|
|
5057
4770
|
if (error) {
|
|
5058
4771
|
callback(error, authData);
|
|
5059
4772
|
return;
|
|
5060
4773
|
}
|
|
5061
|
-
|
|
4774
|
+
let sharedSecret = authData['shared_secret'];
|
|
5062
4775
|
if (!sharedSecret) {
|
|
5063
|
-
callback(new Error(
|
|
4776
|
+
callback(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`), null);
|
|
5064
4777
|
return;
|
|
5065
4778
|
}
|
|
5066
|
-
|
|
4779
|
+
this.key = Object(base64["decode"])(sharedSecret);
|
|
5067
4780
|
delete authData['shared_secret'];
|
|
5068
4781
|
callback(null, authData);
|
|
5069
4782
|
});
|
|
5070
|
-
}
|
|
5071
|
-
|
|
4783
|
+
}
|
|
4784
|
+
trigger(event, data) {
|
|
5072
4785
|
throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
|
|
5073
|
-
}
|
|
5074
|
-
|
|
4786
|
+
}
|
|
4787
|
+
handleEvent(event) {
|
|
5075
4788
|
var eventName = event.event;
|
|
5076
4789
|
var data = event.data;
|
|
5077
4790
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
5078
4791
|
eventName.indexOf('pusher:') === 0) {
|
|
5079
|
-
|
|
4792
|
+
super.handleEvent(event);
|
|
5080
4793
|
return;
|
|
5081
4794
|
}
|
|
5082
4795
|
this.handleEncryptedEvent(eventName, data);
|
|
5083
|
-
}
|
|
5084
|
-
|
|
5085
|
-
var _this = this;
|
|
4796
|
+
}
|
|
4797
|
+
handleEncryptedEvent(event, data) {
|
|
5086
4798
|
if (!this.key) {
|
|
5087
4799
|
logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
|
|
5088
4800
|
return;
|
|
@@ -5092,98 +4804,81 @@ var encrypted_channel_EncryptedChannel = (function (_super) {
|
|
|
5092
4804
|
data);
|
|
5093
4805
|
return;
|
|
5094
4806
|
}
|
|
5095
|
-
|
|
4807
|
+
let cipherText = Object(base64["decode"])(data.ciphertext);
|
|
5096
4808
|
if (cipherText.length < this.nacl.secretbox.overheadLength) {
|
|
5097
|
-
logger.error(
|
|
4809
|
+
logger.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`);
|
|
5098
4810
|
return;
|
|
5099
4811
|
}
|
|
5100
|
-
|
|
4812
|
+
let nonce = Object(base64["decode"])(data.nonce);
|
|
5101
4813
|
if (nonce.length < this.nacl.secretbox.nonceLength) {
|
|
5102
|
-
logger.error(
|
|
4814
|
+
logger.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`);
|
|
5103
4815
|
return;
|
|
5104
4816
|
}
|
|
5105
|
-
|
|
4817
|
+
let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
5106
4818
|
if (bytes === null) {
|
|
5107
4819
|
logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
|
|
5108
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
4820
|
+
this.authorize(this.pusher.connection.socket_id, (error, authData) => {
|
|
5109
4821
|
if (error) {
|
|
5110
|
-
logger.error(
|
|
4822
|
+
logger.error(`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`);
|
|
5111
4823
|
return;
|
|
5112
4824
|
}
|
|
5113
|
-
bytes =
|
|
4825
|
+
bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
5114
4826
|
if (bytes === null) {
|
|
5115
|
-
logger.error(
|
|
4827
|
+
logger.error(`Failed to decrypt event with new key. Dropping encrypted event`);
|
|
5116
4828
|
return;
|
|
5117
4829
|
}
|
|
5118
|
-
|
|
4830
|
+
this.emit(event, this.getDataToEmit(bytes));
|
|
5119
4831
|
return;
|
|
5120
4832
|
});
|
|
5121
4833
|
return;
|
|
5122
4834
|
}
|
|
5123
4835
|
this.emit(event, this.getDataToEmit(bytes));
|
|
5124
|
-
}
|
|
5125
|
-
|
|
5126
|
-
|
|
4836
|
+
}
|
|
4837
|
+
getDataToEmit(bytes) {
|
|
4838
|
+
let raw = Object(utf8["decode"])(bytes);
|
|
5127
4839
|
try {
|
|
5128
4840
|
return JSON.parse(raw);
|
|
5129
4841
|
}
|
|
5130
4842
|
catch (_a) {
|
|
5131
4843
|
return raw;
|
|
5132
4844
|
}
|
|
5133
|
-
}
|
|
5134
|
-
|
|
5135
|
-
}(private_channel));
|
|
5136
|
-
/* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
5137
4847
|
|
|
5138
4848
|
// CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
|
|
5139
|
-
var connection_manager_extends = (undefined && undefined.__extends) || (function () {
|
|
5140
|
-
var extendStatics = function (d, b) {
|
|
5141
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5142
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5143
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
5144
|
-
return extendStatics(d, b);
|
|
5145
|
-
};
|
|
5146
|
-
return function (d, b) {
|
|
5147
|
-
extendStatics(d, b);
|
|
5148
|
-
function __() { this.constructor = d; }
|
|
5149
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
5150
|
-
};
|
|
5151
|
-
})();
|
|
5152
4849
|
|
|
5153
4850
|
|
|
5154
4851
|
|
|
5155
4852
|
|
|
5156
4853
|
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
_this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
|
|
4854
|
+
class connection_manager_ConnectionManager extends dispatcher_Dispatcher {
|
|
4855
|
+
constructor(key, options) {
|
|
4856
|
+
super();
|
|
4857
|
+
this.state = 'initialized';
|
|
4858
|
+
this.connection = null;
|
|
4859
|
+
this.key = key;
|
|
4860
|
+
this.options = options;
|
|
4861
|
+
this.timeline = this.options.timeline;
|
|
4862
|
+
this.usingTLS = this.options.useTLS;
|
|
4863
|
+
this.errorCallbacks = this.buildErrorCallbacks();
|
|
4864
|
+
this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks);
|
|
4865
|
+
this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
|
|
5170
4866
|
var Network = runtime.getNetwork();
|
|
5171
|
-
Network.bind('online',
|
|
5172
|
-
|
|
5173
|
-
if (
|
|
5174
|
-
|
|
4867
|
+
Network.bind('online', () => {
|
|
4868
|
+
this.timeline.info({ netinfo: 'online' });
|
|
4869
|
+
if (this.state === 'connecting' || this.state === 'unavailable') {
|
|
4870
|
+
this.retryIn(0);
|
|
5175
4871
|
}
|
|
5176
4872
|
});
|
|
5177
|
-
Network.bind('offline',
|
|
5178
|
-
|
|
5179
|
-
if (
|
|
5180
|
-
|
|
4873
|
+
Network.bind('offline', () => {
|
|
4874
|
+
this.timeline.info({ netinfo: 'offline' });
|
|
4875
|
+
if (this.connection) {
|
|
4876
|
+
this.sendActivityCheck();
|
|
5181
4877
|
}
|
|
5182
4878
|
});
|
|
5183
|
-
|
|
5184
|
-
return _this;
|
|
4879
|
+
this.updateStrategy();
|
|
5185
4880
|
}
|
|
5186
|
-
|
|
4881
|
+
connect() {
|
|
5187
4882
|
if (this.connection || this.runner) {
|
|
5188
4883
|
return;
|
|
5189
4884
|
}
|
|
@@ -5194,59 +4889,58 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
5194
4889
|
this.updateState('connecting');
|
|
5195
4890
|
this.startConnecting();
|
|
5196
4891
|
this.setUnavailableTimer();
|
|
5197
|
-
}
|
|
5198
|
-
|
|
4892
|
+
}
|
|
4893
|
+
send(data) {
|
|
5199
4894
|
if (this.connection) {
|
|
5200
4895
|
return this.connection.send(data);
|
|
5201
4896
|
}
|
|
5202
4897
|
else {
|
|
5203
4898
|
return false;
|
|
5204
4899
|
}
|
|
5205
|
-
}
|
|
5206
|
-
|
|
4900
|
+
}
|
|
4901
|
+
send_event(name, data, channel) {
|
|
5207
4902
|
if (this.connection) {
|
|
5208
4903
|
return this.connection.send_event(name, data, channel);
|
|
5209
4904
|
}
|
|
5210
4905
|
else {
|
|
5211
4906
|
return false;
|
|
5212
4907
|
}
|
|
5213
|
-
}
|
|
5214
|
-
|
|
4908
|
+
}
|
|
4909
|
+
disconnect() {
|
|
5215
4910
|
this.disconnectInternally();
|
|
5216
4911
|
this.updateState('disconnected');
|
|
5217
|
-
}
|
|
5218
|
-
|
|
4912
|
+
}
|
|
4913
|
+
isUsingTLS() {
|
|
5219
4914
|
return this.usingTLS;
|
|
5220
|
-
}
|
|
5221
|
-
|
|
5222
|
-
var
|
|
5223
|
-
var callback = function (error, handshake) {
|
|
4915
|
+
}
|
|
4916
|
+
startConnecting() {
|
|
4917
|
+
var callback = (error, handshake) => {
|
|
5224
4918
|
if (error) {
|
|
5225
|
-
|
|
4919
|
+
this.runner = this.strategy.connect(0, callback);
|
|
5226
4920
|
}
|
|
5227
4921
|
else {
|
|
5228
4922
|
if (handshake.action === 'error') {
|
|
5229
|
-
|
|
4923
|
+
this.emit('error', {
|
|
5230
4924
|
type: 'HandshakeError',
|
|
5231
4925
|
error: handshake.error
|
|
5232
4926
|
});
|
|
5233
|
-
|
|
4927
|
+
this.timeline.error({ handshakeError: handshake.error });
|
|
5234
4928
|
}
|
|
5235
4929
|
else {
|
|
5236
|
-
|
|
5237
|
-
|
|
4930
|
+
this.abortConnecting();
|
|
4931
|
+
this.handshakeCallbacks[handshake.action](handshake);
|
|
5238
4932
|
}
|
|
5239
4933
|
}
|
|
5240
4934
|
};
|
|
5241
4935
|
this.runner = this.strategy.connect(0, callback);
|
|
5242
|
-
}
|
|
5243
|
-
|
|
4936
|
+
}
|
|
4937
|
+
abortConnecting() {
|
|
5244
4938
|
if (this.runner) {
|
|
5245
4939
|
this.runner.abort();
|
|
5246
4940
|
this.runner = null;
|
|
5247
4941
|
}
|
|
5248
|
-
}
|
|
5249
|
-
|
|
4942
|
+
}
|
|
4943
|
+
disconnectInternally() {
|
|
5250
4944
|
this.abortConnecting();
|
|
5251
4945
|
this.clearRetryTimer();
|
|
5252
4946
|
this.clearUnavailableTimer();
|
|
@@ -5254,136 +4948,129 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
5254
4948
|
var connection = this.abandonConnection();
|
|
5255
4949
|
connection.close();
|
|
5256
4950
|
}
|
|
5257
|
-
}
|
|
5258
|
-
|
|
4951
|
+
}
|
|
4952
|
+
updateStrategy() {
|
|
5259
4953
|
this.strategy = this.options.getStrategy({
|
|
5260
4954
|
key: this.key,
|
|
5261
4955
|
timeline: this.timeline,
|
|
5262
4956
|
useTLS: this.usingTLS
|
|
5263
4957
|
});
|
|
5264
|
-
}
|
|
5265
|
-
|
|
5266
|
-
var _this = this;
|
|
4958
|
+
}
|
|
4959
|
+
retryIn(delay) {
|
|
5267
4960
|
this.timeline.info({ action: 'retry', delay: delay });
|
|
5268
4961
|
if (delay > 0) {
|
|
5269
4962
|
this.emit('connecting_in', Math.round(delay / 1000));
|
|
5270
4963
|
}
|
|
5271
|
-
this.retryTimer = new
|
|
5272
|
-
|
|
5273
|
-
|
|
4964
|
+
this.retryTimer = new timers_OneOffTimer(delay || 0, () => {
|
|
4965
|
+
this.disconnectInternally();
|
|
4966
|
+
this.connect();
|
|
5274
4967
|
});
|
|
5275
|
-
}
|
|
5276
|
-
|
|
4968
|
+
}
|
|
4969
|
+
clearRetryTimer() {
|
|
5277
4970
|
if (this.retryTimer) {
|
|
5278
4971
|
this.retryTimer.ensureAborted();
|
|
5279
4972
|
this.retryTimer = null;
|
|
5280
4973
|
}
|
|
5281
|
-
}
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
_this.updateState('unavailable');
|
|
4974
|
+
}
|
|
4975
|
+
setUnavailableTimer() {
|
|
4976
|
+
this.unavailableTimer = new timers_OneOffTimer(this.options.unavailableTimeout, () => {
|
|
4977
|
+
this.updateState('unavailable');
|
|
5286
4978
|
});
|
|
5287
|
-
}
|
|
5288
|
-
|
|
4979
|
+
}
|
|
4980
|
+
clearUnavailableTimer() {
|
|
5289
4981
|
if (this.unavailableTimer) {
|
|
5290
4982
|
this.unavailableTimer.ensureAborted();
|
|
5291
4983
|
}
|
|
5292
|
-
}
|
|
5293
|
-
|
|
5294
|
-
var _this = this;
|
|
4984
|
+
}
|
|
4985
|
+
sendActivityCheck() {
|
|
5295
4986
|
this.stopActivityCheck();
|
|
5296
4987
|
this.connection.ping();
|
|
5297
|
-
this.activityTimer = new
|
|
5298
|
-
|
|
5299
|
-
|
|
4988
|
+
this.activityTimer = new timers_OneOffTimer(this.options.pongTimeout, () => {
|
|
4989
|
+
this.timeline.error({ pong_timed_out: this.options.pongTimeout });
|
|
4990
|
+
this.retryIn(0);
|
|
5300
4991
|
});
|
|
5301
|
-
}
|
|
5302
|
-
|
|
5303
|
-
var _this = this;
|
|
4992
|
+
}
|
|
4993
|
+
resetActivityCheck() {
|
|
5304
4994
|
this.stopActivityCheck();
|
|
5305
4995
|
if (this.connection && !this.connection.handlesActivityChecks()) {
|
|
5306
|
-
this.activityTimer = new
|
|
5307
|
-
|
|
4996
|
+
this.activityTimer = new timers_OneOffTimer(this.activityTimeout, () => {
|
|
4997
|
+
this.sendActivityCheck();
|
|
5308
4998
|
});
|
|
5309
4999
|
}
|
|
5310
|
-
}
|
|
5311
|
-
|
|
5000
|
+
}
|
|
5001
|
+
stopActivityCheck() {
|
|
5312
5002
|
if (this.activityTimer) {
|
|
5313
5003
|
this.activityTimer.ensureAborted();
|
|
5314
5004
|
}
|
|
5315
|
-
}
|
|
5316
|
-
|
|
5317
|
-
var _this = this;
|
|
5005
|
+
}
|
|
5006
|
+
buildConnectionCallbacks(errorCallbacks) {
|
|
5318
5007
|
return extend({}, errorCallbacks, {
|
|
5319
|
-
message:
|
|
5320
|
-
|
|
5321
|
-
|
|
5008
|
+
message: message => {
|
|
5009
|
+
this.resetActivityCheck();
|
|
5010
|
+
this.emit('message', message);
|
|
5322
5011
|
},
|
|
5323
|
-
ping:
|
|
5324
|
-
|
|
5012
|
+
ping: () => {
|
|
5013
|
+
this.send_event('pusher:pong', {});
|
|
5325
5014
|
},
|
|
5326
|
-
activity:
|
|
5327
|
-
|
|
5015
|
+
activity: () => {
|
|
5016
|
+
this.resetActivityCheck();
|
|
5328
5017
|
},
|
|
5329
|
-
error:
|
|
5330
|
-
|
|
5018
|
+
error: error => {
|
|
5019
|
+
this.emit('error', error);
|
|
5331
5020
|
},
|
|
5332
|
-
closed:
|
|
5333
|
-
|
|
5334
|
-
if (
|
|
5335
|
-
|
|
5021
|
+
closed: () => {
|
|
5022
|
+
this.abandonConnection();
|
|
5023
|
+
if (this.shouldRetry()) {
|
|
5024
|
+
this.retryIn(1000);
|
|
5336
5025
|
}
|
|
5337
5026
|
}
|
|
5338
5027
|
});
|
|
5339
|
-
}
|
|
5340
|
-
|
|
5341
|
-
var _this = this;
|
|
5028
|
+
}
|
|
5029
|
+
buildHandshakeCallbacks(errorCallbacks) {
|
|
5342
5030
|
return extend({}, errorCallbacks, {
|
|
5343
|
-
connected:
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5031
|
+
connected: (handshake) => {
|
|
5032
|
+
this.activityTimeout = Math.min(this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
|
|
5033
|
+
this.clearUnavailableTimer();
|
|
5034
|
+
this.setConnection(handshake.connection);
|
|
5035
|
+
this.socket_id = this.connection.id;
|
|
5036
|
+
this.updateState('connected', { socket_id: this.socket_id });
|
|
5349
5037
|
}
|
|
5350
5038
|
});
|
|
5351
|
-
}
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
return function (result) {
|
|
5039
|
+
}
|
|
5040
|
+
buildErrorCallbacks() {
|
|
5041
|
+
let withErrorEmitted = callback => {
|
|
5042
|
+
return (result) => {
|
|
5356
5043
|
if (result.error) {
|
|
5357
|
-
|
|
5044
|
+
this.emit('error', { type: 'WebSocketError', error: result.error });
|
|
5358
5045
|
}
|
|
5359
5046
|
callback(result);
|
|
5360
5047
|
};
|
|
5361
5048
|
};
|
|
5362
5049
|
return {
|
|
5363
|
-
tls_only: withErrorEmitted(
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5050
|
+
tls_only: withErrorEmitted(() => {
|
|
5051
|
+
this.usingTLS = true;
|
|
5052
|
+
this.updateStrategy();
|
|
5053
|
+
this.retryIn(0);
|
|
5367
5054
|
}),
|
|
5368
|
-
refused: withErrorEmitted(
|
|
5369
|
-
|
|
5055
|
+
refused: withErrorEmitted(() => {
|
|
5056
|
+
this.disconnect();
|
|
5370
5057
|
}),
|
|
5371
|
-
backoff: withErrorEmitted(
|
|
5372
|
-
|
|
5058
|
+
backoff: withErrorEmitted(() => {
|
|
5059
|
+
this.retryIn(1000);
|
|
5373
5060
|
}),
|
|
5374
|
-
retry: withErrorEmitted(
|
|
5375
|
-
|
|
5061
|
+
retry: withErrorEmitted(() => {
|
|
5062
|
+
this.retryIn(0);
|
|
5376
5063
|
})
|
|
5377
5064
|
};
|
|
5378
|
-
}
|
|
5379
|
-
|
|
5065
|
+
}
|
|
5066
|
+
setConnection(connection) {
|
|
5380
5067
|
this.connection = connection;
|
|
5381
5068
|
for (var event in this.connectionCallbacks) {
|
|
5382
5069
|
this.connection.bind(event, this.connectionCallbacks[event]);
|
|
5383
5070
|
}
|
|
5384
5071
|
this.resetActivityCheck();
|
|
5385
|
-
}
|
|
5386
|
-
|
|
5072
|
+
}
|
|
5073
|
+
abandonConnection() {
|
|
5387
5074
|
if (!this.connection) {
|
|
5388
5075
|
return;
|
|
5389
5076
|
}
|
|
@@ -5394,8 +5081,8 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
5394
5081
|
var connection = this.connection;
|
|
5395
5082
|
this.connection = null;
|
|
5396
5083
|
return connection;
|
|
5397
|
-
}
|
|
5398
|
-
|
|
5084
|
+
}
|
|
5085
|
+
updateState(newState, data) {
|
|
5399
5086
|
var previousState = this.state;
|
|
5400
5087
|
this.state = newState;
|
|
5401
5088
|
if (previousState !== newState) {
|
|
@@ -5408,56 +5095,52 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
5408
5095
|
this.emit('state_change', { previous: previousState, current: newState });
|
|
5409
5096
|
this.emit(newState, data);
|
|
5410
5097
|
}
|
|
5411
|
-
}
|
|
5412
|
-
|
|
5098
|
+
}
|
|
5099
|
+
shouldRetry() {
|
|
5413
5100
|
return this.state === 'connecting' || this.state === 'connected';
|
|
5414
|
-
}
|
|
5415
|
-
|
|
5416
|
-
}(dispatcher));
|
|
5417
|
-
/* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5418
5103
|
|
|
5419
5104
|
// CONCATENATED MODULE: ./src/core/channels/channels.ts
|
|
5420
5105
|
|
|
5421
5106
|
|
|
5422
5107
|
|
|
5423
5108
|
|
|
5424
|
-
|
|
5425
|
-
|
|
5109
|
+
class channels_Channels {
|
|
5110
|
+
constructor() {
|
|
5426
5111
|
this.channels = {};
|
|
5427
5112
|
}
|
|
5428
|
-
|
|
5113
|
+
add(name, pusher) {
|
|
5429
5114
|
if (!this.channels[name]) {
|
|
5430
5115
|
this.channels[name] = createChannel(name, pusher);
|
|
5431
5116
|
}
|
|
5432
5117
|
return this.channels[name];
|
|
5433
|
-
}
|
|
5434
|
-
|
|
5118
|
+
}
|
|
5119
|
+
all() {
|
|
5435
5120
|
return values(this.channels);
|
|
5436
|
-
}
|
|
5437
|
-
|
|
5121
|
+
}
|
|
5122
|
+
find(name) {
|
|
5438
5123
|
return this.channels[name];
|
|
5439
|
-
}
|
|
5440
|
-
|
|
5124
|
+
}
|
|
5125
|
+
remove(name) {
|
|
5441
5126
|
var channel = this.channels[name];
|
|
5442
5127
|
delete this.channels[name];
|
|
5443
5128
|
return channel;
|
|
5444
|
-
}
|
|
5445
|
-
|
|
5129
|
+
}
|
|
5130
|
+
disconnect() {
|
|
5446
5131
|
objectApply(this.channels, function (channel) {
|
|
5447
5132
|
channel.disconnect();
|
|
5448
5133
|
});
|
|
5449
|
-
}
|
|
5450
|
-
|
|
5451
|
-
}());
|
|
5452
|
-
/* harmony default export */ var channels = (channels_Channels);
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5453
5136
|
function createChannel(name, pusher) {
|
|
5454
5137
|
if (name.indexOf('private-encrypted-') === 0) {
|
|
5455
5138
|
if (pusher.config.nacl) {
|
|
5456
5139
|
return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);
|
|
5457
5140
|
}
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
throw new UnsupportedFeature(errMsg
|
|
5141
|
+
let errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';
|
|
5142
|
+
let suffix = url_store.buildLogSuffix('encryptedChannelSupport');
|
|
5143
|
+
throw new UnsupportedFeature(`${errMsg}. ${suffix}`);
|
|
5461
5144
|
}
|
|
5462
5145
|
else if (name.indexOf('private-') === 0) {
|
|
5463
5146
|
return factory.createPrivateChannel(name, pusher);
|
|
@@ -5484,97 +5167,94 @@ function createChannel(name, pusher) {
|
|
|
5484
5167
|
|
|
5485
5168
|
|
|
5486
5169
|
var Factory = {
|
|
5487
|
-
createChannels
|
|
5488
|
-
return new
|
|
5170
|
+
createChannels() {
|
|
5171
|
+
return new channels_Channels();
|
|
5489
5172
|
},
|
|
5490
|
-
createConnectionManager
|
|
5491
|
-
return new
|
|
5173
|
+
createConnectionManager(key, options) {
|
|
5174
|
+
return new connection_manager_ConnectionManager(key, options);
|
|
5492
5175
|
},
|
|
5493
|
-
createChannel
|
|
5494
|
-
return new
|
|
5176
|
+
createChannel(name, pusher) {
|
|
5177
|
+
return new channel_Channel(name, pusher);
|
|
5495
5178
|
},
|
|
5496
|
-
createPrivateChannel
|
|
5497
|
-
return new
|
|
5179
|
+
createPrivateChannel(name, pusher) {
|
|
5180
|
+
return new private_channel_PrivateChannel(name, pusher);
|
|
5498
5181
|
},
|
|
5499
|
-
createPresenceChannel
|
|
5500
|
-
return new
|
|
5182
|
+
createPresenceChannel(name, pusher) {
|
|
5183
|
+
return new presence_channel_PresenceChannel(name, pusher);
|
|
5501
5184
|
},
|
|
5502
|
-
createEncryptedChannel
|
|
5503
|
-
return new
|
|
5185
|
+
createEncryptedChannel(name, pusher, nacl) {
|
|
5186
|
+
return new encrypted_channel_EncryptedChannel(name, pusher, nacl);
|
|
5504
5187
|
},
|
|
5505
|
-
createTimelineSender
|
|
5506
|
-
return new
|
|
5188
|
+
createTimelineSender(timeline, options) {
|
|
5189
|
+
return new timeline_sender_TimelineSender(timeline, options);
|
|
5507
5190
|
},
|
|
5508
|
-
createHandshake
|
|
5509
|
-
return new
|
|
5191
|
+
createHandshake(transport, callback) {
|
|
5192
|
+
return new handshake_Handshake(transport, callback);
|
|
5510
5193
|
},
|
|
5511
|
-
createAssistantToTheTransportManager
|
|
5512
|
-
return new
|
|
5194
|
+
createAssistantToTheTransportManager(manager, transport, options) {
|
|
5195
|
+
return new assistant_to_the_transport_manager_AssistantToTheTransportManager(manager, transport, options);
|
|
5513
5196
|
}
|
|
5514
5197
|
};
|
|
5515
5198
|
/* harmony default export */ var factory = (Factory);
|
|
5516
5199
|
|
|
5517
5200
|
// CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
|
|
5518
5201
|
|
|
5519
|
-
|
|
5520
|
-
|
|
5202
|
+
class transport_manager_TransportManager {
|
|
5203
|
+
constructor(options) {
|
|
5521
5204
|
this.options = options || {};
|
|
5522
5205
|
this.livesLeft = this.options.lives || Infinity;
|
|
5523
5206
|
}
|
|
5524
|
-
|
|
5207
|
+
getAssistant(transport) {
|
|
5525
5208
|
return factory.createAssistantToTheTransportManager(this, transport, {
|
|
5526
5209
|
minPingDelay: this.options.minPingDelay,
|
|
5527
5210
|
maxPingDelay: this.options.maxPingDelay
|
|
5528
5211
|
});
|
|
5529
|
-
}
|
|
5530
|
-
|
|
5212
|
+
}
|
|
5213
|
+
isAlive() {
|
|
5531
5214
|
return this.livesLeft > 0;
|
|
5532
|
-
}
|
|
5533
|
-
|
|
5215
|
+
}
|
|
5216
|
+
reportDeath() {
|
|
5534
5217
|
this.livesLeft -= 1;
|
|
5535
|
-
}
|
|
5536
|
-
|
|
5537
|
-
}());
|
|
5538
|
-
/* harmony default export */ var transport_manager = (transport_manager_TransportManager);
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5539
5220
|
|
|
5540
5221
|
// CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
|
|
5541
5222
|
|
|
5542
5223
|
|
|
5543
5224
|
|
|
5544
|
-
|
|
5545
|
-
|
|
5225
|
+
class sequential_strategy_SequentialStrategy {
|
|
5226
|
+
constructor(strategies, options) {
|
|
5546
5227
|
this.strategies = strategies;
|
|
5547
5228
|
this.loop = Boolean(options.loop);
|
|
5548
5229
|
this.failFast = Boolean(options.failFast);
|
|
5549
5230
|
this.timeout = options.timeout;
|
|
5550
5231
|
this.timeoutLimit = options.timeoutLimit;
|
|
5551
5232
|
}
|
|
5552
|
-
|
|
5233
|
+
isSupported() {
|
|
5553
5234
|
return any(this.strategies, util.method('isSupported'));
|
|
5554
|
-
}
|
|
5555
|
-
|
|
5556
|
-
var _this = this;
|
|
5235
|
+
}
|
|
5236
|
+
connect(minPriority, callback) {
|
|
5557
5237
|
var strategies = this.strategies;
|
|
5558
5238
|
var current = 0;
|
|
5559
5239
|
var timeout = this.timeout;
|
|
5560
5240
|
var runner = null;
|
|
5561
|
-
var tryNextStrategy =
|
|
5241
|
+
var tryNextStrategy = (error, handshake) => {
|
|
5562
5242
|
if (handshake) {
|
|
5563
5243
|
callback(null, handshake);
|
|
5564
5244
|
}
|
|
5565
5245
|
else {
|
|
5566
5246
|
current = current + 1;
|
|
5567
|
-
if (
|
|
5247
|
+
if (this.loop) {
|
|
5568
5248
|
current = current % strategies.length;
|
|
5569
5249
|
}
|
|
5570
5250
|
if (current < strategies.length) {
|
|
5571
5251
|
if (timeout) {
|
|
5572
5252
|
timeout = timeout * 2;
|
|
5573
|
-
if (
|
|
5574
|
-
timeout = Math.min(timeout,
|
|
5253
|
+
if (this.timeoutLimit) {
|
|
5254
|
+
timeout = Math.min(timeout, this.timeoutLimit);
|
|
5575
5255
|
}
|
|
5576
5256
|
}
|
|
5577
|
-
runner =
|
|
5257
|
+
runner = this.tryStrategy(strategies[current], minPriority, { timeout, failFast: this.failFast }, tryNextStrategy);
|
|
5578
5258
|
}
|
|
5579
5259
|
else {
|
|
5580
5260
|
callback(true);
|
|
@@ -5593,12 +5273,12 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
5593
5273
|
}
|
|
5594
5274
|
}
|
|
5595
5275
|
};
|
|
5596
|
-
}
|
|
5597
|
-
|
|
5276
|
+
}
|
|
5277
|
+
tryStrategy(strategy, minPriority, options, callback) {
|
|
5598
5278
|
var timer = null;
|
|
5599
5279
|
var runner = null;
|
|
5600
5280
|
if (options.timeout > 0) {
|
|
5601
|
-
timer = new
|
|
5281
|
+
timer = new timers_OneOffTimer(options.timeout, function () {
|
|
5602
5282
|
runner.abort();
|
|
5603
5283
|
callback(true);
|
|
5604
5284
|
});
|
|
@@ -5623,22 +5303,20 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
5623
5303
|
runner.forceMinPriority(p);
|
|
5624
5304
|
}
|
|
5625
5305
|
};
|
|
5626
|
-
}
|
|
5627
|
-
|
|
5628
|
-
}());
|
|
5629
|
-
/* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5630
5308
|
|
|
5631
5309
|
// CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
|
|
5632
5310
|
|
|
5633
5311
|
|
|
5634
|
-
|
|
5635
|
-
|
|
5312
|
+
class best_connected_ever_strategy_BestConnectedEverStrategy {
|
|
5313
|
+
constructor(strategies) {
|
|
5636
5314
|
this.strategies = strategies;
|
|
5637
5315
|
}
|
|
5638
|
-
|
|
5316
|
+
isSupported() {
|
|
5639
5317
|
return any(this.strategies, util.method('isSupported'));
|
|
5640
|
-
}
|
|
5641
|
-
|
|
5318
|
+
}
|
|
5319
|
+
connect(minPriority, callback) {
|
|
5642
5320
|
return connect(this.strategies, minPriority, function (i, runners) {
|
|
5643
5321
|
return function (error, handshake) {
|
|
5644
5322
|
runners[i].error = error;
|
|
@@ -5654,10 +5332,8 @@ var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
|
|
|
5654
5332
|
callback(null, handshake);
|
|
5655
5333
|
};
|
|
5656
5334
|
});
|
|
5657
|
-
}
|
|
5658
|
-
|
|
5659
|
-
}());
|
|
5660
|
-
/* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
|
|
5335
|
+
}
|
|
5336
|
+
}
|
|
5661
5337
|
function connect(strategies, minPriority, callbackBuilder) {
|
|
5662
5338
|
var runners = map(strategies, function (strategy, i, _, rs) {
|
|
5663
5339
|
return strategy.connect(minPriority, callbackBuilder(i, rs));
|
|
@@ -5690,18 +5366,18 @@ function abortRunner(runner) {
|
|
|
5690
5366
|
|
|
5691
5367
|
|
|
5692
5368
|
|
|
5693
|
-
|
|
5694
|
-
|
|
5369
|
+
class cached_strategy_CachedStrategy {
|
|
5370
|
+
constructor(strategy, transports, options) {
|
|
5695
5371
|
this.strategy = strategy;
|
|
5696
5372
|
this.transports = transports;
|
|
5697
5373
|
this.ttl = options.ttl || 1800 * 1000;
|
|
5698
5374
|
this.usingTLS = options.useTLS;
|
|
5699
5375
|
this.timeline = options.timeline;
|
|
5700
5376
|
}
|
|
5701
|
-
|
|
5377
|
+
isSupported() {
|
|
5702
5378
|
return this.strategy.isSupported();
|
|
5703
|
-
}
|
|
5704
|
-
|
|
5379
|
+
}
|
|
5380
|
+
connect(minPriority, callback) {
|
|
5705
5381
|
var usingTLS = this.usingTLS;
|
|
5706
5382
|
var info = fetchTransportCache(usingTLS);
|
|
5707
5383
|
var strategies = [this.strategy];
|
|
@@ -5713,7 +5389,7 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
5713
5389
|
transport: info.transport,
|
|
5714
5390
|
latency: info.latency
|
|
5715
5391
|
});
|
|
5716
|
-
strategies.push(new
|
|
5392
|
+
strategies.push(new sequential_strategy_SequentialStrategy([transport], {
|
|
5717
5393
|
timeout: info.latency * 2 + 1000,
|
|
5718
5394
|
failFast: true
|
|
5719
5395
|
}));
|
|
@@ -5749,10 +5425,8 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
5749
5425
|
}
|
|
5750
5426
|
}
|
|
5751
5427
|
};
|
|
5752
|
-
}
|
|
5753
|
-
|
|
5754
|
-
}());
|
|
5755
|
-
/* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
|
|
5428
|
+
}
|
|
5429
|
+
}
|
|
5756
5430
|
function getTransportCacheKey(usingTLS) {
|
|
5757
5431
|
return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');
|
|
5758
5432
|
}
|
|
@@ -5798,19 +5472,18 @@ function flushTransportCache(usingTLS) {
|
|
|
5798
5472
|
|
|
5799
5473
|
// CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
|
|
5800
5474
|
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
var number = _a.delay;
|
|
5475
|
+
class delayed_strategy_DelayedStrategy {
|
|
5476
|
+
constructor(strategy, { delay: number }) {
|
|
5804
5477
|
this.strategy = strategy;
|
|
5805
5478
|
this.options = { delay: number };
|
|
5806
5479
|
}
|
|
5807
|
-
|
|
5480
|
+
isSupported() {
|
|
5808
5481
|
return this.strategy.isSupported();
|
|
5809
|
-
}
|
|
5810
|
-
|
|
5482
|
+
}
|
|
5483
|
+
connect(minPriority, callback) {
|
|
5811
5484
|
var strategy = this.strategy;
|
|
5812
5485
|
var runner;
|
|
5813
|
-
var timer = new
|
|
5486
|
+
var timer = new timers_OneOffTimer(this.options.delay, function () {
|
|
5814
5487
|
runner = strategy.connect(minPriority, callback);
|
|
5815
5488
|
});
|
|
5816
5489
|
return {
|
|
@@ -5827,39 +5500,35 @@ var delayed_strategy_DelayedStrategy = (function () {
|
|
|
5827
5500
|
}
|
|
5828
5501
|
}
|
|
5829
5502
|
};
|
|
5830
|
-
}
|
|
5831
|
-
|
|
5832
|
-
}());
|
|
5833
|
-
/* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
|
|
5503
|
+
}
|
|
5504
|
+
}
|
|
5834
5505
|
|
|
5835
5506
|
// CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
|
|
5836
|
-
|
|
5837
|
-
|
|
5507
|
+
class IfStrategy {
|
|
5508
|
+
constructor(test, trueBranch, falseBranch) {
|
|
5838
5509
|
this.test = test;
|
|
5839
5510
|
this.trueBranch = trueBranch;
|
|
5840
5511
|
this.falseBranch = falseBranch;
|
|
5841
5512
|
}
|
|
5842
|
-
|
|
5513
|
+
isSupported() {
|
|
5843
5514
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
5844
5515
|
return branch.isSupported();
|
|
5845
|
-
}
|
|
5846
|
-
|
|
5516
|
+
}
|
|
5517
|
+
connect(minPriority, callback) {
|
|
5847
5518
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
5848
5519
|
return branch.connect(minPriority, callback);
|
|
5849
|
-
}
|
|
5850
|
-
|
|
5851
|
-
}());
|
|
5852
|
-
/* harmony default export */ var if_strategy = (IfStrategy);
|
|
5520
|
+
}
|
|
5521
|
+
}
|
|
5853
5522
|
|
|
5854
5523
|
// CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
|
|
5855
|
-
|
|
5856
|
-
|
|
5524
|
+
class FirstConnectedStrategy {
|
|
5525
|
+
constructor(strategy) {
|
|
5857
5526
|
this.strategy = strategy;
|
|
5858
5527
|
}
|
|
5859
|
-
|
|
5528
|
+
isSupported() {
|
|
5860
5529
|
return this.strategy.isSupported();
|
|
5861
|
-
}
|
|
5862
|
-
|
|
5530
|
+
}
|
|
5531
|
+
connect(minPriority, callback) {
|
|
5863
5532
|
var runner = this.strategy.connect(minPriority, function (error, handshake) {
|
|
5864
5533
|
if (handshake) {
|
|
5865
5534
|
runner.abort();
|
|
@@ -5867,10 +5536,8 @@ var FirstConnectedStrategy = (function () {
|
|
|
5867
5536
|
callback(error, handshake);
|
|
5868
5537
|
});
|
|
5869
5538
|
return runner;
|
|
5870
|
-
}
|
|
5871
|
-
|
|
5872
|
-
}());
|
|
5873
|
-
/* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
|
|
5539
|
+
}
|
|
5540
|
+
}
|
|
5874
5541
|
|
|
5875
5542
|
// CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
|
|
5876
5543
|
|
|
@@ -5910,12 +5577,11 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5910
5577
|
timeout: 15000,
|
|
5911
5578
|
timeoutLimit: 60000
|
|
5912
5579
|
};
|
|
5913
|
-
var ws_manager = new
|
|
5914
|
-
lives: 2,
|
|
5580
|
+
var ws_manager = new transport_manager_TransportManager({
|
|
5915
5581
|
minPingDelay: 10000,
|
|
5916
5582
|
maxPingDelay: config.activityTimeout
|
|
5917
5583
|
});
|
|
5918
|
-
var streaming_manager = new
|
|
5584
|
+
var streaming_manager = new transport_manager_TransportManager({
|
|
5919
5585
|
lives: 2,
|
|
5920
5586
|
minPingDelay: 10000,
|
|
5921
5587
|
maxPingDelay: config.activityTimeout
|
|
@@ -5927,37 +5593,37 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5927
5593
|
var xdr_streaming_transport = defineTransportStrategy('xdr_streaming', 'xdr_streaming', 1, sockjs_options, streaming_manager);
|
|
5928
5594
|
var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, sockjs_options);
|
|
5929
5595
|
var xdr_polling_transport = defineTransportStrategy('xdr_polling', 'xdr_polling', 1, sockjs_options);
|
|
5930
|
-
var ws_loop = new
|
|
5931
|
-
var wss_loop = new
|
|
5932
|
-
var sockjs_loop = new
|
|
5933
|
-
var streaming_loop = new
|
|
5934
|
-
new
|
|
5596
|
+
var ws_loop = new sequential_strategy_SequentialStrategy([ws_transport], timeouts);
|
|
5597
|
+
var wss_loop = new sequential_strategy_SequentialStrategy([wss_transport], timeouts);
|
|
5598
|
+
var sockjs_loop = new sequential_strategy_SequentialStrategy([sockjs_transport], timeouts);
|
|
5599
|
+
var streaming_loop = new sequential_strategy_SequentialStrategy([
|
|
5600
|
+
new IfStrategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)
|
|
5935
5601
|
], timeouts);
|
|
5936
|
-
var polling_loop = new
|
|
5937
|
-
new
|
|
5602
|
+
var polling_loop = new sequential_strategy_SequentialStrategy([
|
|
5603
|
+
new IfStrategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)
|
|
5938
5604
|
], timeouts);
|
|
5939
|
-
var http_loop = new
|
|
5940
|
-
new
|
|
5605
|
+
var http_loop = new sequential_strategy_SequentialStrategy([
|
|
5606
|
+
new IfStrategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5941
5607
|
streaming_loop,
|
|
5942
|
-
new
|
|
5608
|
+
new delayed_strategy_DelayedStrategy(polling_loop, { delay: 4000 })
|
|
5943
5609
|
]), polling_loop)
|
|
5944
5610
|
], timeouts);
|
|
5945
|
-
var http_fallback_loop = new
|
|
5611
|
+
var http_fallback_loop = new IfStrategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
|
|
5946
5612
|
var wsStrategy;
|
|
5947
5613
|
if (baseOptions.useTLS) {
|
|
5948
|
-
wsStrategy = new
|
|
5614
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5949
5615
|
ws_loop,
|
|
5950
|
-
new
|
|
5616
|
+
new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 2000 })
|
|
5951
5617
|
]);
|
|
5952
5618
|
}
|
|
5953
5619
|
else {
|
|
5954
|
-
wsStrategy = new
|
|
5620
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5955
5621
|
ws_loop,
|
|
5956
|
-
new
|
|
5957
|
-
new
|
|
5622
|
+
new delayed_strategy_DelayedStrategy(wss_loop, { delay: 2000 }),
|
|
5623
|
+
new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 5000 })
|
|
5958
5624
|
]);
|
|
5959
5625
|
}
|
|
5960
|
-
return new
|
|
5626
|
+
return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
|
|
5961
5627
|
ttl: 1800000,
|
|
5962
5628
|
timeline: baseOptions.timeline,
|
|
5963
5629
|
useTLS: baseOptions.useTLS
|
|
@@ -6031,37 +5697,21 @@ var http_xdomain_request_hooks = {
|
|
|
6031
5697
|
/* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
|
|
6032
5698
|
|
|
6033
5699
|
// CONCATENATED MODULE: ./src/core/http/http_request.ts
|
|
6034
|
-
var http_request_extends = (undefined && undefined.__extends) || (function () {
|
|
6035
|
-
var extendStatics = function (d, b) {
|
|
6036
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6037
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6038
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6039
|
-
return extendStatics(d, b);
|
|
6040
|
-
};
|
|
6041
|
-
return function (d, b) {
|
|
6042
|
-
extendStatics(d, b);
|
|
6043
|
-
function __() { this.constructor = d; }
|
|
6044
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6045
|
-
};
|
|
6046
|
-
})();
|
|
6047
5700
|
|
|
6048
5701
|
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
_this.url = url;
|
|
6057
|
-
return _this;
|
|
5702
|
+
const MAX_BUFFER_LENGTH = 256 * 1024;
|
|
5703
|
+
class http_request_HTTPRequest extends dispatcher_Dispatcher {
|
|
5704
|
+
constructor(hooks, method, url) {
|
|
5705
|
+
super();
|
|
5706
|
+
this.hooks = hooks;
|
|
5707
|
+
this.method = method;
|
|
5708
|
+
this.url = url;
|
|
6058
5709
|
}
|
|
6059
|
-
|
|
6060
|
-
var _this = this;
|
|
5710
|
+
start(payload) {
|
|
6061
5711
|
this.position = 0;
|
|
6062
5712
|
this.xhr = this.hooks.getRequest(this);
|
|
6063
|
-
this.unloader =
|
|
6064
|
-
|
|
5713
|
+
this.unloader = () => {
|
|
5714
|
+
this.close();
|
|
6065
5715
|
};
|
|
6066
5716
|
runtime.addUnloadListener(this.unloader);
|
|
6067
5717
|
this.xhr.open(this.method, this.url, true);
|
|
@@ -6069,8 +5719,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6069
5719
|
this.xhr.setRequestHeader('Content-Type', 'application/json');
|
|
6070
5720
|
}
|
|
6071
5721
|
this.xhr.send(payload);
|
|
6072
|
-
}
|
|
6073
|
-
|
|
5722
|
+
}
|
|
5723
|
+
close() {
|
|
6074
5724
|
if (this.unloader) {
|
|
6075
5725
|
runtime.removeUnloadListener(this.unloader);
|
|
6076
5726
|
this.unloader = null;
|
|
@@ -6079,8 +5729,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6079
5729
|
this.hooks.abortRequest(this.xhr);
|
|
6080
5730
|
this.xhr = null;
|
|
6081
5731
|
}
|
|
6082
|
-
}
|
|
6083
|
-
|
|
5732
|
+
}
|
|
5733
|
+
onChunk(status, data) {
|
|
6084
5734
|
while (true) {
|
|
6085
5735
|
var chunk = this.advanceBuffer(data);
|
|
6086
5736
|
if (chunk) {
|
|
@@ -6093,8 +5743,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6093
5743
|
if (this.isBufferTooLong(data)) {
|
|
6094
5744
|
this.emit('buffer_too_long');
|
|
6095
5745
|
}
|
|
6096
|
-
}
|
|
6097
|
-
|
|
5746
|
+
}
|
|
5747
|
+
advanceBuffer(buffer) {
|
|
6098
5748
|
var unreadData = buffer.slice(this.position);
|
|
6099
5749
|
var endOfLinePosition = unreadData.indexOf('\n');
|
|
6100
5750
|
if (endOfLinePosition !== -1) {
|
|
@@ -6104,13 +5754,11 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6104
5754
|
else {
|
|
6105
5755
|
return null;
|
|
6106
5756
|
}
|
|
6107
|
-
}
|
|
6108
|
-
|
|
5757
|
+
}
|
|
5758
|
+
isBufferTooLong(buffer) {
|
|
6109
5759
|
return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
|
|
6110
|
-
}
|
|
6111
|
-
|
|
6112
|
-
}(dispatcher));
|
|
6113
|
-
/* harmony default export */ var http_request = (http_request_HTTPRequest);
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
6114
5762
|
|
|
6115
5763
|
// CONCATENATED MODULE: ./src/core/http/state.ts
|
|
6116
5764
|
var State;
|
|
@@ -6126,24 +5774,24 @@ var State;
|
|
|
6126
5774
|
|
|
6127
5775
|
|
|
6128
5776
|
var autoIncrement = 1;
|
|
6129
|
-
|
|
6130
|
-
|
|
5777
|
+
class http_socket_HTTPSocket {
|
|
5778
|
+
constructor(hooks, url) {
|
|
6131
5779
|
this.hooks = hooks;
|
|
6132
5780
|
this.session = randomNumber(1000) + '/' + randomString(8);
|
|
6133
5781
|
this.location = getLocation(url);
|
|
6134
5782
|
this.readyState = state.CONNECTING;
|
|
6135
5783
|
this.openStream();
|
|
6136
5784
|
}
|
|
6137
|
-
|
|
5785
|
+
send(payload) {
|
|
6138
5786
|
return this.sendRaw(JSON.stringify([payload]));
|
|
6139
|
-
}
|
|
6140
|
-
|
|
5787
|
+
}
|
|
5788
|
+
ping() {
|
|
6141
5789
|
this.hooks.sendHeartbeat(this);
|
|
6142
|
-
}
|
|
6143
|
-
|
|
5790
|
+
}
|
|
5791
|
+
close(code, reason) {
|
|
6144
5792
|
this.onClose(code, reason, true);
|
|
6145
|
-
}
|
|
6146
|
-
|
|
5793
|
+
}
|
|
5794
|
+
sendRaw(payload) {
|
|
6147
5795
|
if (this.readyState === state.OPEN) {
|
|
6148
5796
|
try {
|
|
6149
5797
|
runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);
|
|
@@ -6156,12 +5804,12 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6156
5804
|
else {
|
|
6157
5805
|
return false;
|
|
6158
5806
|
}
|
|
6159
|
-
}
|
|
6160
|
-
|
|
5807
|
+
}
|
|
5808
|
+
reconnect() {
|
|
6161
5809
|
this.closeStream();
|
|
6162
5810
|
this.openStream();
|
|
6163
|
-
}
|
|
6164
|
-
|
|
5811
|
+
}
|
|
5812
|
+
onClose(code, reason, wasClean) {
|
|
6165
5813
|
this.closeStream();
|
|
6166
5814
|
this.readyState = state.CLOSED;
|
|
6167
5815
|
if (this.onclose) {
|
|
@@ -6171,8 +5819,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6171
5819
|
wasClean: wasClean
|
|
6172
5820
|
});
|
|
6173
5821
|
}
|
|
6174
|
-
}
|
|
6175
|
-
|
|
5822
|
+
}
|
|
5823
|
+
onChunk(chunk) {
|
|
6176
5824
|
if (chunk.status !== 200) {
|
|
6177
5825
|
return;
|
|
6178
5826
|
}
|
|
@@ -6204,8 +5852,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6204
5852
|
this.onClose(payload[0], payload[1], true);
|
|
6205
5853
|
break;
|
|
6206
5854
|
}
|
|
6207
|
-
}
|
|
6208
|
-
|
|
5855
|
+
}
|
|
5856
|
+
onOpen(options) {
|
|
6209
5857
|
if (this.readyState === state.CONNECTING) {
|
|
6210
5858
|
if (options && options.hostname) {
|
|
6211
5859
|
this.location.base = replaceHost(this.location.base, options.hostname);
|
|
@@ -6218,53 +5866,51 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6218
5866
|
else {
|
|
6219
5867
|
this.onClose(1006, 'Server lost session', true);
|
|
6220
5868
|
}
|
|
6221
|
-
}
|
|
6222
|
-
|
|
5869
|
+
}
|
|
5870
|
+
onEvent(event) {
|
|
6223
5871
|
if (this.readyState === state.OPEN && this.onmessage) {
|
|
6224
5872
|
this.onmessage({ data: event });
|
|
6225
5873
|
}
|
|
6226
|
-
}
|
|
6227
|
-
|
|
5874
|
+
}
|
|
5875
|
+
onActivity() {
|
|
6228
5876
|
if (this.onactivity) {
|
|
6229
5877
|
this.onactivity();
|
|
6230
5878
|
}
|
|
6231
|
-
}
|
|
6232
|
-
|
|
5879
|
+
}
|
|
5880
|
+
onError(error) {
|
|
6233
5881
|
if (this.onerror) {
|
|
6234
5882
|
this.onerror(error);
|
|
6235
5883
|
}
|
|
6236
|
-
}
|
|
6237
|
-
|
|
6238
|
-
var _this = this;
|
|
5884
|
+
}
|
|
5885
|
+
openStream() {
|
|
6239
5886
|
this.stream = runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
|
|
6240
|
-
this.stream.bind('chunk',
|
|
6241
|
-
|
|
5887
|
+
this.stream.bind('chunk', chunk => {
|
|
5888
|
+
this.onChunk(chunk);
|
|
6242
5889
|
});
|
|
6243
|
-
this.stream.bind('finished',
|
|
6244
|
-
|
|
5890
|
+
this.stream.bind('finished', status => {
|
|
5891
|
+
this.hooks.onFinished(this, status);
|
|
6245
5892
|
});
|
|
6246
|
-
this.stream.bind('buffer_too_long',
|
|
6247
|
-
|
|
5893
|
+
this.stream.bind('buffer_too_long', () => {
|
|
5894
|
+
this.reconnect();
|
|
6248
5895
|
});
|
|
6249
5896
|
try {
|
|
6250
5897
|
this.stream.start();
|
|
6251
5898
|
}
|
|
6252
5899
|
catch (error) {
|
|
6253
|
-
util.defer(
|
|
6254
|
-
|
|
6255
|
-
|
|
5900
|
+
util.defer(() => {
|
|
5901
|
+
this.onError(error);
|
|
5902
|
+
this.onClose(1006, 'Could not start streaming', false);
|
|
6256
5903
|
});
|
|
6257
5904
|
}
|
|
6258
|
-
}
|
|
6259
|
-
|
|
5905
|
+
}
|
|
5906
|
+
closeStream() {
|
|
6260
5907
|
if (this.stream) {
|
|
6261
5908
|
this.stream.unbind_all();
|
|
6262
5909
|
this.stream.close();
|
|
6263
5910
|
this.stream = null;
|
|
6264
5911
|
}
|
|
6265
|
-
}
|
|
6266
|
-
|
|
6267
|
-
}());
|
|
5912
|
+
}
|
|
5913
|
+
}
|
|
6268
5914
|
function getLocation(url) {
|
|
6269
5915
|
var parts = /([^\?]*)\/*(\??.*)/.exec(url);
|
|
6270
5916
|
return {
|
|
@@ -6371,20 +6017,20 @@ var http_xhr_request_hooks = {
|
|
|
6371
6017
|
|
|
6372
6018
|
|
|
6373
6019
|
var HTTP = {
|
|
6374
|
-
createStreamingSocket
|
|
6020
|
+
createStreamingSocket(url) {
|
|
6375
6021
|
return this.createSocket(http_streaming_socket, url);
|
|
6376
6022
|
},
|
|
6377
|
-
createPollingSocket
|
|
6023
|
+
createPollingSocket(url) {
|
|
6378
6024
|
return this.createSocket(http_polling_socket, url);
|
|
6379
6025
|
},
|
|
6380
|
-
createSocket
|
|
6026
|
+
createSocket(hooks, url) {
|
|
6381
6027
|
return new http_socket(hooks, url);
|
|
6382
6028
|
},
|
|
6383
|
-
createXHR
|
|
6029
|
+
createXHR(method, url) {
|
|
6384
6030
|
return this.createRequest(http_xhr_request, method, url);
|
|
6385
6031
|
},
|
|
6386
|
-
createRequest
|
|
6387
|
-
return new
|
|
6032
|
+
createRequest(hooks, method, url) {
|
|
6033
|
+
return new http_request_HTTPRequest(hooks, method, url);
|
|
6388
6034
|
}
|
|
6389
6035
|
};
|
|
6390
6036
|
/* harmony default export */ var http_http = (HTTP);
|
|
@@ -6420,17 +6066,16 @@ var Runtime = {
|
|
|
6420
6066
|
transportConnectionInitializer: transport_connection_initializer,
|
|
6421
6067
|
HTTPFactory: web_http_http,
|
|
6422
6068
|
TimelineTransport: jsonp_timeline,
|
|
6423
|
-
getXHRAPI
|
|
6069
|
+
getXHRAPI() {
|
|
6424
6070
|
return window.XMLHttpRequest;
|
|
6425
6071
|
},
|
|
6426
|
-
getWebSocketAPI
|
|
6072
|
+
getWebSocketAPI() {
|
|
6427
6073
|
return window.WebSocket || window.MozWebSocket;
|
|
6428
6074
|
},
|
|
6429
|
-
setup
|
|
6430
|
-
var _this = this;
|
|
6075
|
+
setup(PusherClass) {
|
|
6431
6076
|
window.Pusher = PusherClass;
|
|
6432
|
-
var initializeOnDocumentBody =
|
|
6433
|
-
|
|
6077
|
+
var initializeOnDocumentBody = () => {
|
|
6078
|
+
this.onDocumentBody(PusherClass.ready);
|
|
6434
6079
|
};
|
|
6435
6080
|
if (!window.JSON) {
|
|
6436
6081
|
Dependencies.load('json2', {}, initializeOnDocumentBody);
|
|
@@ -6439,33 +6084,32 @@ var Runtime = {
|
|
|
6439
6084
|
initializeOnDocumentBody();
|
|
6440
6085
|
}
|
|
6441
6086
|
},
|
|
6442
|
-
getDocument
|
|
6087
|
+
getDocument() {
|
|
6443
6088
|
return document;
|
|
6444
6089
|
},
|
|
6445
|
-
getProtocol
|
|
6090
|
+
getProtocol() {
|
|
6446
6091
|
return this.getDocument().location.protocol;
|
|
6447
6092
|
},
|
|
6448
|
-
getAuthorizers
|
|
6093
|
+
getAuthorizers() {
|
|
6449
6094
|
return { ajax: xhr_auth, jsonp: jsonp_auth };
|
|
6450
6095
|
},
|
|
6451
|
-
onDocumentBody
|
|
6452
|
-
var _this = this;
|
|
6096
|
+
onDocumentBody(callback) {
|
|
6453
6097
|
if (document.body) {
|
|
6454
6098
|
callback();
|
|
6455
6099
|
}
|
|
6456
6100
|
else {
|
|
6457
|
-
setTimeout(
|
|
6458
|
-
|
|
6101
|
+
setTimeout(() => {
|
|
6102
|
+
this.onDocumentBody(callback);
|
|
6459
6103
|
}, 0);
|
|
6460
6104
|
}
|
|
6461
6105
|
},
|
|
6462
|
-
createJSONPRequest
|
|
6463
|
-
return new
|
|
6106
|
+
createJSONPRequest(url, data) {
|
|
6107
|
+
return new jsonp_request_JSONPRequest(url, data);
|
|
6464
6108
|
},
|
|
6465
|
-
createScriptRequest
|
|
6466
|
-
return new
|
|
6109
|
+
createScriptRequest(src) {
|
|
6110
|
+
return new ScriptRequest(src);
|
|
6467
6111
|
},
|
|
6468
|
-
getLocalStorage
|
|
6112
|
+
getLocalStorage() {
|
|
6469
6113
|
try {
|
|
6470
6114
|
return window.localStorage;
|
|
6471
6115
|
}
|
|
@@ -6473,7 +6117,7 @@ var Runtime = {
|
|
|
6473
6117
|
return undefined;
|
|
6474
6118
|
}
|
|
6475
6119
|
},
|
|
6476
|
-
createXHR
|
|
6120
|
+
createXHR() {
|
|
6477
6121
|
if (this.getXHRAPI()) {
|
|
6478
6122
|
return this.createXMLHttpRequest();
|
|
6479
6123
|
}
|
|
@@ -6481,21 +6125,21 @@ var Runtime = {
|
|
|
6481
6125
|
return this.createMicrosoftXHR();
|
|
6482
6126
|
}
|
|
6483
6127
|
},
|
|
6484
|
-
createXMLHttpRequest
|
|
6128
|
+
createXMLHttpRequest() {
|
|
6485
6129
|
var Constructor = this.getXHRAPI();
|
|
6486
6130
|
return new Constructor();
|
|
6487
6131
|
},
|
|
6488
|
-
createMicrosoftXHR
|
|
6132
|
+
createMicrosoftXHR() {
|
|
6489
6133
|
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
6490
6134
|
},
|
|
6491
|
-
getNetwork
|
|
6135
|
+
getNetwork() {
|
|
6492
6136
|
return net_info_Network;
|
|
6493
6137
|
},
|
|
6494
|
-
createWebSocket
|
|
6138
|
+
createWebSocket(url) {
|
|
6495
6139
|
var Constructor = this.getWebSocketAPI();
|
|
6496
6140
|
return new Constructor(url);
|
|
6497
6141
|
},
|
|
6498
|
-
createSocketRequest
|
|
6142
|
+
createSocketRequest(method, url) {
|
|
6499
6143
|
if (this.isXHRSupported()) {
|
|
6500
6144
|
return this.HTTPFactory.createXHR(method, url);
|
|
6501
6145
|
}
|
|
@@ -6506,16 +6150,16 @@ var Runtime = {
|
|
|
6506
6150
|
throw 'Cross-origin HTTP requests are not supported';
|
|
6507
6151
|
}
|
|
6508
6152
|
},
|
|
6509
|
-
isXHRSupported
|
|
6153
|
+
isXHRSupported() {
|
|
6510
6154
|
var Constructor = this.getXHRAPI();
|
|
6511
6155
|
return (Boolean(Constructor) && new Constructor().withCredentials !== undefined);
|
|
6512
6156
|
},
|
|
6513
|
-
isXDRSupported
|
|
6157
|
+
isXDRSupported(useTLS) {
|
|
6514
6158
|
var protocol = useTLS ? 'https:' : 'http:';
|
|
6515
6159
|
var documentProtocol = this.getProtocol();
|
|
6516
6160
|
return (Boolean(window['XDomainRequest']) && documentProtocol === protocol);
|
|
6517
6161
|
},
|
|
6518
|
-
addUnloadListener
|
|
6162
|
+
addUnloadListener(listener) {
|
|
6519
6163
|
if (window.addEventListener !== undefined) {
|
|
6520
6164
|
window.addEventListener('unload', listener, false);
|
|
6521
6165
|
}
|
|
@@ -6523,7 +6167,7 @@ var Runtime = {
|
|
|
6523
6167
|
window.attachEvent('onunload', listener);
|
|
6524
6168
|
}
|
|
6525
6169
|
},
|
|
6526
|
-
removeUnloadListener
|
|
6170
|
+
removeUnloadListener(listener) {
|
|
6527
6171
|
if (window.addEventListener !== undefined) {
|
|
6528
6172
|
window.removeEventListener('unload', listener, false);
|
|
6529
6173
|
}
|
|
@@ -6531,10 +6175,10 @@ var Runtime = {
|
|
|
6531
6175
|
window.detachEvent('onunload', listener);
|
|
6532
6176
|
}
|
|
6533
6177
|
},
|
|
6534
|
-
randomInt
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6178
|
+
randomInt(max) {
|
|
6179
|
+
const random = function () {
|
|
6180
|
+
const crypto = window.crypto || window['msCrypto'];
|
|
6181
|
+
const random = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
6538
6182
|
return random / Math.pow(2, 32);
|
|
6539
6183
|
};
|
|
6540
6184
|
return Math.floor(random() * max);
|
|
@@ -6555,8 +6199,8 @@ var TimelineLevel;
|
|
|
6555
6199
|
|
|
6556
6200
|
|
|
6557
6201
|
|
|
6558
|
-
|
|
6559
|
-
|
|
6202
|
+
class timeline_Timeline {
|
|
6203
|
+
constructor(key, session, options) {
|
|
6560
6204
|
this.key = key;
|
|
6561
6205
|
this.session = session;
|
|
6562
6206
|
this.events = [];
|
|
@@ -6564,28 +6208,27 @@ var timeline_Timeline = (function () {
|
|
|
6564
6208
|
this.sent = 0;
|
|
6565
6209
|
this.uniqueID = 0;
|
|
6566
6210
|
}
|
|
6567
|
-
|
|
6211
|
+
log(level, event) {
|
|
6568
6212
|
if (level <= this.options.level) {
|
|
6569
6213
|
this.events.push(extend({}, event, { timestamp: util.now() }));
|
|
6570
6214
|
if (this.options.limit && this.events.length > this.options.limit) {
|
|
6571
6215
|
this.events.shift();
|
|
6572
6216
|
}
|
|
6573
6217
|
}
|
|
6574
|
-
}
|
|
6575
|
-
|
|
6218
|
+
}
|
|
6219
|
+
error(event) {
|
|
6576
6220
|
this.log(timeline_level.ERROR, event);
|
|
6577
|
-
}
|
|
6578
|
-
|
|
6221
|
+
}
|
|
6222
|
+
info(event) {
|
|
6579
6223
|
this.log(timeline_level.INFO, event);
|
|
6580
|
-
}
|
|
6581
|
-
|
|
6224
|
+
}
|
|
6225
|
+
debug(event) {
|
|
6582
6226
|
this.log(timeline_level.DEBUG, event);
|
|
6583
|
-
}
|
|
6584
|
-
|
|
6227
|
+
}
|
|
6228
|
+
isEmpty() {
|
|
6585
6229
|
return this.events.length === 0;
|
|
6586
|
-
}
|
|
6587
|
-
|
|
6588
|
-
var _this = this;
|
|
6230
|
+
}
|
|
6231
|
+
send(sendfn, callback) {
|
|
6589
6232
|
var data = extend({
|
|
6590
6233
|
session: this.session,
|
|
6591
6234
|
bundle: this.sent + 1,
|
|
@@ -6597,43 +6240,40 @@ var timeline_Timeline = (function () {
|
|
|
6597
6240
|
timeline: this.events
|
|
6598
6241
|
}, this.options.params);
|
|
6599
6242
|
this.events = [];
|
|
6600
|
-
sendfn(data,
|
|
6243
|
+
sendfn(data, (error, result) => {
|
|
6601
6244
|
if (!error) {
|
|
6602
|
-
|
|
6245
|
+
this.sent++;
|
|
6603
6246
|
}
|
|
6604
6247
|
if (callback) {
|
|
6605
6248
|
callback(error, result);
|
|
6606
6249
|
}
|
|
6607
6250
|
});
|
|
6608
6251
|
return true;
|
|
6609
|
-
}
|
|
6610
|
-
|
|
6252
|
+
}
|
|
6253
|
+
generateUniqueID() {
|
|
6611
6254
|
this.uniqueID++;
|
|
6612
6255
|
return this.uniqueID;
|
|
6613
|
-
}
|
|
6614
|
-
|
|
6615
|
-
}());
|
|
6616
|
-
/* harmony default export */ var timeline_timeline = (timeline_Timeline);
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6617
6258
|
|
|
6618
6259
|
// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
|
|
6619
6260
|
|
|
6620
6261
|
|
|
6621
6262
|
|
|
6622
6263
|
|
|
6623
|
-
|
|
6624
|
-
|
|
6264
|
+
class transport_strategy_TransportStrategy {
|
|
6265
|
+
constructor(name, priority, transport, options) {
|
|
6625
6266
|
this.name = name;
|
|
6626
6267
|
this.priority = priority;
|
|
6627
6268
|
this.transport = transport;
|
|
6628
6269
|
this.options = options || {};
|
|
6629
6270
|
}
|
|
6630
|
-
|
|
6271
|
+
isSupported() {
|
|
6631
6272
|
return this.transport.isSupported({
|
|
6632
6273
|
useTLS: this.options.useTLS
|
|
6633
6274
|
});
|
|
6634
|
-
}
|
|
6635
|
-
|
|
6636
|
-
var _this = this;
|
|
6275
|
+
}
|
|
6276
|
+
connect(minPriority, callback) {
|
|
6637
6277
|
if (!this.isSupported()) {
|
|
6638
6278
|
return failAttempt(new UnsupportedStrategy(), callback);
|
|
6639
6279
|
}
|
|
@@ -6676,7 +6316,7 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6676
6316
|
transport.bind('closed', onClosed);
|
|
6677
6317
|
transport.initialize();
|
|
6678
6318
|
return {
|
|
6679
|
-
abort:
|
|
6319
|
+
abort: () => {
|
|
6680
6320
|
if (connected) {
|
|
6681
6321
|
return;
|
|
6682
6322
|
}
|
|
@@ -6688,11 +6328,11 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6688
6328
|
transport.close();
|
|
6689
6329
|
}
|
|
6690
6330
|
},
|
|
6691
|
-
forceMinPriority:
|
|
6331
|
+
forceMinPriority: p => {
|
|
6692
6332
|
if (connected) {
|
|
6693
6333
|
return;
|
|
6694
6334
|
}
|
|
6695
|
-
if (
|
|
6335
|
+
if (this.priority < p) {
|
|
6696
6336
|
if (handshake) {
|
|
6697
6337
|
handshake.close();
|
|
6698
6338
|
}
|
|
@@ -6702,10 +6342,8 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6702
6342
|
}
|
|
6703
6343
|
}
|
|
6704
6344
|
};
|
|
6705
|
-
}
|
|
6706
|
-
|
|
6707
|
-
}());
|
|
6708
|
-
/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6709
6347
|
function failAttempt(error, callback) {
|
|
6710
6348
|
util.defer(function () {
|
|
6711
6349
|
callback(error);
|
|
@@ -6722,7 +6360,7 @@ function failAttempt(error, callback) {
|
|
|
6722
6360
|
|
|
6723
6361
|
|
|
6724
6362
|
|
|
6725
|
-
|
|
6363
|
+
const { Transports: strategy_builder_Transports } = runtime;
|
|
6726
6364
|
var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
|
|
6727
6365
|
var transportClass = strategy_builder_Transports[type];
|
|
6728
6366
|
if (!transportClass) {
|
|
@@ -6735,7 +6373,7 @@ var strategy_builder_defineTransport = function (config, name, type, priority, o
|
|
|
6735
6373
|
var transport;
|
|
6736
6374
|
if (enabled) {
|
|
6737
6375
|
options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);
|
|
6738
|
-
transport = new
|
|
6376
|
+
transport = new transport_strategy_TransportStrategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
|
|
6739
6377
|
}
|
|
6740
6378
|
else {
|
|
6741
6379
|
transport = strategy_builder_UnsupportedStrategy;
|
|
@@ -6776,7 +6414,7 @@ function validateOptions(options) {
|
|
|
6776
6414
|
// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts
|
|
6777
6415
|
|
|
6778
6416
|
|
|
6779
|
-
|
|
6417
|
+
const composeChannelQuery = (params, authOptions) => {
|
|
6780
6418
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
6781
6419
|
for (var key in authOptions.params) {
|
|
6782
6420
|
query +=
|
|
@@ -6786,7 +6424,7 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
6786
6424
|
encodeURIComponent(authOptions.params[key]);
|
|
6787
6425
|
}
|
|
6788
6426
|
if (authOptions.paramsProvider != null) {
|
|
6789
|
-
|
|
6427
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
6790
6428
|
for (var key in dynamicParams) {
|
|
6791
6429
|
query +=
|
|
6792
6430
|
'&' +
|
|
@@ -6797,12 +6435,12 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
6797
6435
|
}
|
|
6798
6436
|
return query;
|
|
6799
6437
|
};
|
|
6800
|
-
|
|
6438
|
+
const UserAuthenticator = (authOptions) => {
|
|
6801
6439
|
if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
6802
|
-
throw
|
|
6440
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
6803
6441
|
}
|
|
6804
|
-
return
|
|
6805
|
-
|
|
6442
|
+
return (params, callback) => {
|
|
6443
|
+
const query = composeChannelQuery(params, authOptions);
|
|
6806
6444
|
runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);
|
|
6807
6445
|
};
|
|
6808
6446
|
};
|
|
@@ -6811,7 +6449,7 @@ var UserAuthenticator = function (authOptions) {
|
|
|
6811
6449
|
// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts
|
|
6812
6450
|
|
|
6813
6451
|
|
|
6814
|
-
|
|
6452
|
+
const channel_authorizer_composeChannelQuery = (params, authOptions) => {
|
|
6815
6453
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
6816
6454
|
query += '&channel_name=' + encodeURIComponent(params.channelName);
|
|
6817
6455
|
for (var key in authOptions.params) {
|
|
@@ -6822,7 +6460,7 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
6822
6460
|
encodeURIComponent(authOptions.params[key]);
|
|
6823
6461
|
}
|
|
6824
6462
|
if (authOptions.paramsProvider != null) {
|
|
6825
|
-
|
|
6463
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
6826
6464
|
for (var key in dynamicParams) {
|
|
6827
6465
|
query +=
|
|
6828
6466
|
'&' +
|
|
@@ -6833,20 +6471,20 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
6833
6471
|
}
|
|
6834
6472
|
return query;
|
|
6835
6473
|
};
|
|
6836
|
-
|
|
6474
|
+
const ChannelAuthorizer = (authOptions) => {
|
|
6837
6475
|
if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
6838
|
-
throw
|
|
6476
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
6839
6477
|
}
|
|
6840
|
-
return
|
|
6841
|
-
|
|
6478
|
+
return (params, callback) => {
|
|
6479
|
+
const query = channel_authorizer_composeChannelQuery(params, authOptions);
|
|
6842
6480
|
runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);
|
|
6843
6481
|
};
|
|
6844
6482
|
};
|
|
6845
6483
|
/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);
|
|
6846
6484
|
|
|
6847
6485
|
// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts
|
|
6848
|
-
|
|
6849
|
-
|
|
6486
|
+
const ChannelAuthorizerProxy = (pusher, authOptions, channelAuthorizerGenerator) => {
|
|
6487
|
+
const deprecatedAuthorizerOptions = {
|
|
6850
6488
|
authTransport: authOptions.transport,
|
|
6851
6489
|
authEndpoint: authOptions.endpoint,
|
|
6852
6490
|
auth: {
|
|
@@ -6854,32 +6492,21 @@ var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGen
|
|
|
6854
6492
|
headers: authOptions.headers
|
|
6855
6493
|
}
|
|
6856
6494
|
};
|
|
6857
|
-
return
|
|
6858
|
-
|
|
6859
|
-
|
|
6495
|
+
return (params, callback) => {
|
|
6496
|
+
const channel = pusher.channel(params.channelName);
|
|
6497
|
+
const channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
|
|
6860
6498
|
channelAuthorizer.authorize(params.socketId, callback);
|
|
6861
6499
|
};
|
|
6862
6500
|
};
|
|
6863
6501
|
|
|
6864
6502
|
// CONCATENATED MODULE: ./src/core/config.ts
|
|
6865
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
6866
|
-
__assign = Object.assign || function(t) {
|
|
6867
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6868
|
-
s = arguments[i];
|
|
6869
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6870
|
-
t[p] = s[p];
|
|
6871
|
-
}
|
|
6872
|
-
return t;
|
|
6873
|
-
};
|
|
6874
|
-
return __assign.apply(this, arguments);
|
|
6875
|
-
};
|
|
6876
6503
|
|
|
6877
6504
|
|
|
6878
6505
|
|
|
6879
6506
|
|
|
6880
6507
|
|
|
6881
6508
|
function getConfig(opts, pusher) {
|
|
6882
|
-
|
|
6509
|
+
let config = {
|
|
6883
6510
|
activityTimeout: opts.activityTimeout || defaults.activityTimeout,
|
|
6884
6511
|
cluster: opts.cluster,
|
|
6885
6512
|
httpPath: opts.httpPath || defaults.httpPath,
|
|
@@ -6916,7 +6543,7 @@ function getHttpHost(opts) {
|
|
|
6916
6543
|
return opts.httpHost;
|
|
6917
6544
|
}
|
|
6918
6545
|
if (opts.cluster) {
|
|
6919
|
-
return
|
|
6546
|
+
return `sockjs-${opts.cluster}.pusher.com`;
|
|
6920
6547
|
}
|
|
6921
6548
|
return defaults.httpHost;
|
|
6922
6549
|
}
|
|
@@ -6927,7 +6554,7 @@ function getWebsocketHost(opts) {
|
|
|
6927
6554
|
return getWebsocketHostFromCluster(opts.cluster);
|
|
6928
6555
|
}
|
|
6929
6556
|
function getWebsocketHostFromCluster(cluster) {
|
|
6930
|
-
return
|
|
6557
|
+
return `ws-${cluster}.pusher.com`;
|
|
6931
6558
|
}
|
|
6932
6559
|
function shouldUseTLS(opts) {
|
|
6933
6560
|
if (runtime.getProtocol() === 'https:') {
|
|
@@ -6948,7 +6575,7 @@ function getEnableStatsConfig(opts) {
|
|
|
6948
6575
|
return false;
|
|
6949
6576
|
}
|
|
6950
6577
|
function buildUserAuthenticator(opts) {
|
|
6951
|
-
|
|
6578
|
+
const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication);
|
|
6952
6579
|
if ('customHandler' in userAuthentication &&
|
|
6953
6580
|
userAuthentication['customHandler'] != null) {
|
|
6954
6581
|
return userAuthentication['customHandler'];
|
|
@@ -6956,9 +6583,9 @@ function buildUserAuthenticator(opts) {
|
|
|
6956
6583
|
return user_authenticator(userAuthentication);
|
|
6957
6584
|
}
|
|
6958
6585
|
function buildChannelAuth(opts, pusher) {
|
|
6959
|
-
|
|
6586
|
+
let channelAuthorization;
|
|
6960
6587
|
if ('channelAuthorization' in opts) {
|
|
6961
|
-
channelAuthorization =
|
|
6588
|
+
channelAuthorization = Object.assign(Object.assign({}, defaults.channelAuthorization), opts.channelAuthorization);
|
|
6962
6589
|
}
|
|
6963
6590
|
else {
|
|
6964
6591
|
channelAuthorization = {
|
|
@@ -6977,7 +6604,7 @@ function buildChannelAuth(opts, pusher) {
|
|
|
6977
6604
|
return channelAuthorization;
|
|
6978
6605
|
}
|
|
6979
6606
|
function buildChannelAuthorizer(opts, pusher) {
|
|
6980
|
-
|
|
6607
|
+
const channelAuthorization = buildChannelAuth(opts, pusher);
|
|
6981
6608
|
if ('customHandler' in channelAuthorization &&
|
|
6982
6609
|
channelAuthorization['customHandler'] != null) {
|
|
6983
6610
|
return channelAuthorization['customHandler'];
|
|
@@ -6986,134 +6613,99 @@ function buildChannelAuthorizer(opts, pusher) {
|
|
|
6986
6613
|
}
|
|
6987
6614
|
|
|
6988
6615
|
// CONCATENATED MODULE: ./src/core/watchlist.ts
|
|
6989
|
-
var watchlist_extends = (undefined && undefined.__extends) || (function () {
|
|
6990
|
-
var extendStatics = function (d, b) {
|
|
6991
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6992
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6993
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6994
|
-
return extendStatics(d, b);
|
|
6995
|
-
};
|
|
6996
|
-
return function (d, b) {
|
|
6997
|
-
extendStatics(d, b);
|
|
6998
|
-
function __() { this.constructor = d; }
|
|
6999
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7000
|
-
};
|
|
7001
|
-
})();
|
|
7002
6616
|
|
|
7003
6617
|
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
logger.debug("No callbacks on watchlist events for " + eventName);
|
|
7009
|
-
}) || this;
|
|
7010
|
-
_this.pusher = pusher;
|
|
7011
|
-
_this.bindWatchlistInternalEvent();
|
|
7012
|
-
return _this;
|
|
7013
|
-
}
|
|
7014
|
-
WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
|
|
7015
|
-
var _this = this;
|
|
7016
|
-
pusherEvent.data.events.forEach(function (watchlistEvent) {
|
|
7017
|
-
_this.emit(watchlistEvent.name, watchlistEvent);
|
|
6618
|
+
class watchlist_WatchlistFacade extends dispatcher_Dispatcher {
|
|
6619
|
+
constructor(pusher) {
|
|
6620
|
+
super(function (eventName, data) {
|
|
6621
|
+
logger.debug(`No callbacks on watchlist events for ${eventName}`);
|
|
7018
6622
|
});
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
6623
|
+
this.pusher = pusher;
|
|
6624
|
+
this.bindWatchlistInternalEvent();
|
|
6625
|
+
}
|
|
6626
|
+
handleEvent(pusherEvent) {
|
|
6627
|
+
pusherEvent.data.events.forEach(watchlistEvent => {
|
|
6628
|
+
this.emit(watchlistEvent.name, watchlistEvent);
|
|
6629
|
+
});
|
|
6630
|
+
}
|
|
6631
|
+
bindWatchlistInternalEvent() {
|
|
6632
|
+
this.pusher.connection.bind('message', pusherEvent => {
|
|
7023
6633
|
var eventName = pusherEvent.event;
|
|
7024
6634
|
if (eventName === 'pusher_internal:watchlist_events') {
|
|
7025
|
-
|
|
6635
|
+
this.handleEvent(pusherEvent);
|
|
7026
6636
|
}
|
|
7027
6637
|
});
|
|
7028
|
-
}
|
|
7029
|
-
|
|
7030
|
-
}(dispatcher));
|
|
7031
|
-
/* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
7032
6640
|
|
|
7033
6641
|
// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
|
|
7034
6642
|
function flatPromise() {
|
|
7035
|
-
|
|
7036
|
-
|
|
6643
|
+
let resolve, reject;
|
|
6644
|
+
const promise = new Promise((res, rej) => {
|
|
7037
6645
|
resolve = res;
|
|
7038
6646
|
reject = rej;
|
|
7039
6647
|
});
|
|
7040
|
-
return { promise
|
|
6648
|
+
return { promise, resolve, reject };
|
|
7041
6649
|
}
|
|
7042
6650
|
/* harmony default export */ var flat_promise = (flatPromise);
|
|
7043
6651
|
|
|
7044
6652
|
// CONCATENATED MODULE: ./src/core/user.ts
|
|
7045
|
-
var user_extends = (undefined && undefined.__extends) || (function () {
|
|
7046
|
-
var extendStatics = function (d, b) {
|
|
7047
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7048
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7049
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7050
|
-
return extendStatics(d, b);
|
|
7051
|
-
};
|
|
7052
|
-
return function (d, b) {
|
|
7053
|
-
extendStatics(d, b);
|
|
7054
|
-
function __() { this.constructor = d; }
|
|
7055
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7056
|
-
};
|
|
7057
|
-
})();
|
|
7058
6653
|
|
|
7059
6654
|
|
|
7060
6655
|
|
|
7061
6656
|
|
|
7062
6657
|
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
var _this = _super.call(this, function (eventName, data) {
|
|
6658
|
+
class user_UserFacade extends dispatcher_Dispatcher {
|
|
6659
|
+
constructor(pusher) {
|
|
6660
|
+
super(function (eventName, data) {
|
|
7067
6661
|
logger.debug('No callbacks on user for ' + eventName);
|
|
7068
|
-
})
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
6662
|
+
});
|
|
6663
|
+
this.signin_requested = false;
|
|
6664
|
+
this.user_data = null;
|
|
6665
|
+
this.serverToUserChannel = null;
|
|
6666
|
+
this.signinDonePromise = null;
|
|
6667
|
+
this._signinDoneResolve = null;
|
|
6668
|
+
this._onAuthorize = (err, authData) => {
|
|
7075
6669
|
if (err) {
|
|
7076
|
-
logger.warn(
|
|
7077
|
-
|
|
6670
|
+
logger.warn(`Error during signin: ${err}`);
|
|
6671
|
+
this._cleanup();
|
|
7078
6672
|
return;
|
|
7079
6673
|
}
|
|
7080
|
-
|
|
6674
|
+
this.pusher.send_event('pusher:signin', {
|
|
7081
6675
|
auth: authData.auth,
|
|
7082
6676
|
user_data: authData.user_data
|
|
7083
6677
|
});
|
|
7084
6678
|
};
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
var previous = _a.previous, current = _a.current;
|
|
6679
|
+
this.pusher = pusher;
|
|
6680
|
+
this.pusher.connection.bind('state_change', ({ previous, current }) => {
|
|
7088
6681
|
if (previous !== 'connected' && current === 'connected') {
|
|
7089
|
-
|
|
6682
|
+
this._signin();
|
|
7090
6683
|
}
|
|
7091
6684
|
if (previous === 'connected' && current !== 'connected') {
|
|
7092
|
-
|
|
7093
|
-
|
|
6685
|
+
this._cleanup();
|
|
6686
|
+
this._newSigninPromiseIfNeeded();
|
|
7094
6687
|
}
|
|
7095
6688
|
});
|
|
7096
|
-
|
|
7097
|
-
|
|
6689
|
+
this.watchlist = new watchlist_WatchlistFacade(pusher);
|
|
6690
|
+
this.pusher.connection.bind('message', event => {
|
|
7098
6691
|
var eventName = event.event;
|
|
7099
6692
|
if (eventName === 'pusher:signin_success') {
|
|
7100
|
-
|
|
6693
|
+
this._onSigninSuccess(event.data);
|
|
7101
6694
|
}
|
|
7102
|
-
if (
|
|
7103
|
-
|
|
7104
|
-
|
|
6695
|
+
if (this.serverToUserChannel &&
|
|
6696
|
+
this.serverToUserChannel.name === event.channel) {
|
|
6697
|
+
this.serverToUserChannel.handleEvent(event);
|
|
7105
6698
|
}
|
|
7106
6699
|
});
|
|
7107
|
-
return _this;
|
|
7108
6700
|
}
|
|
7109
|
-
|
|
6701
|
+
signin() {
|
|
7110
6702
|
if (this.signin_requested) {
|
|
7111
6703
|
return;
|
|
7112
6704
|
}
|
|
7113
6705
|
this.signin_requested = true;
|
|
7114
6706
|
this._signin();
|
|
7115
|
-
}
|
|
7116
|
-
|
|
6707
|
+
}
|
|
6708
|
+
_signin() {
|
|
7117
6709
|
if (!this.signin_requested) {
|
|
7118
6710
|
return;
|
|
7119
6711
|
}
|
|
@@ -7124,46 +6716,45 @@ var user_UserFacade = (function (_super) {
|
|
|
7124
6716
|
this.pusher.config.userAuthenticator({
|
|
7125
6717
|
socketId: this.pusher.connection.socket_id
|
|
7126
6718
|
}, this._onAuthorize);
|
|
7127
|
-
}
|
|
7128
|
-
|
|
6719
|
+
}
|
|
6720
|
+
_onSigninSuccess(data) {
|
|
7129
6721
|
try {
|
|
7130
6722
|
this.user_data = JSON.parse(data.user_data);
|
|
7131
6723
|
}
|
|
7132
6724
|
catch (e) {
|
|
7133
|
-
logger.error(
|
|
6725
|
+
logger.error(`Failed parsing user data after signin: ${data.user_data}`);
|
|
7134
6726
|
this._cleanup();
|
|
7135
6727
|
return;
|
|
7136
6728
|
}
|
|
7137
6729
|
if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
|
|
7138
|
-
logger.error(
|
|
6730
|
+
logger.error(`user_data doesn't contain an id. user_data: ${this.user_data}`);
|
|
7139
6731
|
this._cleanup();
|
|
7140
6732
|
return;
|
|
7141
6733
|
}
|
|
7142
6734
|
this._signinDoneResolve();
|
|
7143
6735
|
this._subscribeChannels();
|
|
7144
|
-
}
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
var ensure_subscribed = function (channel) {
|
|
6736
|
+
}
|
|
6737
|
+
_subscribeChannels() {
|
|
6738
|
+
const ensure_subscribed = channel => {
|
|
7148
6739
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
7149
6740
|
channel.reinstateSubscription();
|
|
7150
6741
|
}
|
|
7151
6742
|
else if (!channel.subscriptionPending &&
|
|
7152
|
-
|
|
6743
|
+
this.pusher.connection.state === 'connected') {
|
|
7153
6744
|
channel.subscribe();
|
|
7154
6745
|
}
|
|
7155
6746
|
};
|
|
7156
|
-
this.serverToUserChannel = new
|
|
7157
|
-
this.serverToUserChannel.bind_global(
|
|
6747
|
+
this.serverToUserChannel = new channel_Channel(`#server-to-user-${this.user_data.id}`, this.pusher);
|
|
6748
|
+
this.serverToUserChannel.bind_global((eventName, data) => {
|
|
7158
6749
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
7159
6750
|
eventName.indexOf('pusher:') === 0) {
|
|
7160
6751
|
return;
|
|
7161
6752
|
}
|
|
7162
|
-
|
|
6753
|
+
this.emit(eventName, data);
|
|
7163
6754
|
});
|
|
7164
6755
|
ensure_subscribed(this.serverToUserChannel);
|
|
7165
|
-
}
|
|
7166
|
-
|
|
6756
|
+
}
|
|
6757
|
+
_cleanup() {
|
|
7167
6758
|
this.user_data = null;
|
|
7168
6759
|
if (this.serverToUserChannel) {
|
|
7169
6760
|
this.serverToUserChannel.unbind_all();
|
|
@@ -7173,26 +6764,24 @@ var user_UserFacade = (function (_super) {
|
|
|
7173
6764
|
if (this.signin_requested) {
|
|
7174
6765
|
this._signinDoneResolve();
|
|
7175
6766
|
}
|
|
7176
|
-
}
|
|
7177
|
-
|
|
6767
|
+
}
|
|
6768
|
+
_newSigninPromiseIfNeeded() {
|
|
7178
6769
|
if (!this.signin_requested) {
|
|
7179
6770
|
return;
|
|
7180
6771
|
}
|
|
7181
6772
|
if (this.signinDonePromise && !this.signinDonePromise.done) {
|
|
7182
6773
|
return;
|
|
7183
6774
|
}
|
|
7184
|
-
|
|
6775
|
+
const { promise, resolve, reject: _ } = flat_promise();
|
|
7185
6776
|
promise.done = false;
|
|
7186
|
-
|
|
6777
|
+
const setDone = () => {
|
|
7187
6778
|
promise.done = true;
|
|
7188
6779
|
};
|
|
7189
|
-
promise.then(setDone)
|
|
6780
|
+
promise.then(setDone).catch(setDone);
|
|
7190
6781
|
this.signinDonePromise = promise;
|
|
7191
6782
|
this._signinDoneResolve = resolve;
|
|
7192
|
-
}
|
|
7193
|
-
|
|
7194
|
-
}(dispatcher));
|
|
7195
|
-
/* harmony default export */ var user = (user_UserFacade);
|
|
6783
|
+
}
|
|
6784
|
+
}
|
|
7196
6785
|
|
|
7197
6786
|
// CONCATENATED MODULE: ./src/core/pusher.ts
|
|
7198
6787
|
|
|
@@ -7208,19 +6797,29 @@ var user_UserFacade = (function (_super) {
|
|
|
7208
6797
|
|
|
7209
6798
|
|
|
7210
6799
|
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
6800
|
+
class pusher_Pusher {
|
|
6801
|
+
static ready() {
|
|
6802
|
+
pusher_Pusher.isReady = true;
|
|
6803
|
+
for (var i = 0, l = pusher_Pusher.instances.length; i < l; i++) {
|
|
6804
|
+
pusher_Pusher.instances[i].connect();
|
|
6805
|
+
}
|
|
6806
|
+
}
|
|
6807
|
+
static getClientFeatures() {
|
|
6808
|
+
return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
|
|
6809
|
+
return t.isSupported({});
|
|
6810
|
+
}));
|
|
6811
|
+
}
|
|
6812
|
+
constructor(app_key, options) {
|
|
7214
6813
|
checkAppKey(app_key);
|
|
7215
6814
|
validateOptions(options);
|
|
7216
6815
|
this.key = app_key;
|
|
7217
6816
|
this.config = getConfig(options, this);
|
|
7218
6817
|
this.channels = factory.createChannels();
|
|
7219
|
-
this.global_emitter = new
|
|
6818
|
+
this.global_emitter = new dispatcher_Dispatcher();
|
|
7220
6819
|
this.sessionID = runtime.randomInt(1000000000);
|
|
7221
|
-
this.timeline = new
|
|
6820
|
+
this.timeline = new timeline_Timeline(this.key, this.sessionID, {
|
|
7222
6821
|
cluster: this.config.cluster,
|
|
7223
|
-
features:
|
|
6822
|
+
features: pusher_Pusher.getClientFeatures(),
|
|
7224
6823
|
params: this.config.timelineParams || {},
|
|
7225
6824
|
limit: 50,
|
|
7226
6825
|
level: timeline_level.INFO,
|
|
@@ -7232,8 +6831,8 @@ var pusher_Pusher = (function () {
|
|
|
7232
6831
|
path: '/timeline/v2/' + runtime.TimelineTransport.name
|
|
7233
6832
|
});
|
|
7234
6833
|
}
|
|
7235
|
-
var getStrategy =
|
|
7236
|
-
return runtime.getDefaultStrategy(
|
|
6834
|
+
var getStrategy = (options) => {
|
|
6835
|
+
return runtime.getDefaultStrategy(this.config, options, strategy_builder_defineTransport);
|
|
7237
6836
|
};
|
|
7238
6837
|
this.connection = factory.createConnectionManager(this.key, {
|
|
7239
6838
|
getStrategy: getStrategy,
|
|
@@ -7243,106 +6842,95 @@ var pusher_Pusher = (function () {
|
|
|
7243
6842
|
unavailableTimeout: this.config.unavailableTimeout,
|
|
7244
6843
|
useTLS: Boolean(this.config.useTLS)
|
|
7245
6844
|
});
|
|
7246
|
-
this.connection.bind('connected',
|
|
7247
|
-
|
|
7248
|
-
if (
|
|
7249
|
-
|
|
6845
|
+
this.connection.bind('connected', () => {
|
|
6846
|
+
this.subscribeAll();
|
|
6847
|
+
if (this.timelineSender) {
|
|
6848
|
+
this.timelineSender.send(this.connection.isUsingTLS());
|
|
7250
6849
|
}
|
|
7251
6850
|
});
|
|
7252
|
-
this.connection.bind('message',
|
|
6851
|
+
this.connection.bind('message', event => {
|
|
7253
6852
|
var eventName = event.event;
|
|
7254
6853
|
var internal = eventName.indexOf('pusher_internal:') === 0;
|
|
7255
6854
|
if (event.channel) {
|
|
7256
|
-
var channel =
|
|
6855
|
+
var channel = this.channel(event.channel);
|
|
7257
6856
|
if (channel) {
|
|
7258
6857
|
channel.handleEvent(event);
|
|
7259
6858
|
}
|
|
7260
6859
|
}
|
|
7261
6860
|
if (!internal) {
|
|
7262
|
-
|
|
6861
|
+
this.global_emitter.emit(event.event, event.data);
|
|
7263
6862
|
}
|
|
7264
6863
|
});
|
|
7265
|
-
this.connection.bind('connecting',
|
|
7266
|
-
|
|
6864
|
+
this.connection.bind('connecting', () => {
|
|
6865
|
+
this.channels.disconnect();
|
|
7267
6866
|
});
|
|
7268
|
-
this.connection.bind('disconnected',
|
|
7269
|
-
|
|
6867
|
+
this.connection.bind('disconnected', () => {
|
|
6868
|
+
this.channels.disconnect();
|
|
7270
6869
|
});
|
|
7271
|
-
this.connection.bind('error',
|
|
6870
|
+
this.connection.bind('error', err => {
|
|
7272
6871
|
logger.warn(err);
|
|
7273
6872
|
});
|
|
7274
|
-
|
|
7275
|
-
this.timeline.info({ instances:
|
|
7276
|
-
this.user = new
|
|
7277
|
-
if (
|
|
6873
|
+
pusher_Pusher.instances.push(this);
|
|
6874
|
+
this.timeline.info({ instances: pusher_Pusher.instances.length });
|
|
6875
|
+
this.user = new user_UserFacade(this);
|
|
6876
|
+
if (pusher_Pusher.isReady) {
|
|
7278
6877
|
this.connect();
|
|
7279
6878
|
}
|
|
7280
6879
|
}
|
|
7281
|
-
|
|
7282
|
-
Pusher.isReady = true;
|
|
7283
|
-
for (var i = 0, l = Pusher.instances.length; i < l; i++) {
|
|
7284
|
-
Pusher.instances[i].connect();
|
|
7285
|
-
}
|
|
7286
|
-
};
|
|
7287
|
-
Pusher.getClientFeatures = function () {
|
|
7288
|
-
return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
|
|
7289
|
-
return t.isSupported({});
|
|
7290
|
-
}));
|
|
7291
|
-
};
|
|
7292
|
-
Pusher.prototype.channel = function (name) {
|
|
6880
|
+
channel(name) {
|
|
7293
6881
|
return this.channels.find(name);
|
|
7294
|
-
}
|
|
7295
|
-
|
|
6882
|
+
}
|
|
6883
|
+
allChannels() {
|
|
7296
6884
|
return this.channels.all();
|
|
7297
|
-
}
|
|
7298
|
-
|
|
6885
|
+
}
|
|
6886
|
+
connect() {
|
|
7299
6887
|
this.connection.connect();
|
|
7300
6888
|
if (this.timelineSender) {
|
|
7301
6889
|
if (!this.timelineSenderTimer) {
|
|
7302
6890
|
var usingTLS = this.connection.isUsingTLS();
|
|
7303
6891
|
var timelineSender = this.timelineSender;
|
|
7304
|
-
this.timelineSenderTimer = new
|
|
6892
|
+
this.timelineSenderTimer = new timers_PeriodicTimer(60000, function () {
|
|
7305
6893
|
timelineSender.send(usingTLS);
|
|
7306
6894
|
});
|
|
7307
6895
|
}
|
|
7308
6896
|
}
|
|
7309
|
-
}
|
|
7310
|
-
|
|
6897
|
+
}
|
|
6898
|
+
disconnect() {
|
|
7311
6899
|
this.connection.disconnect();
|
|
7312
6900
|
if (this.timelineSenderTimer) {
|
|
7313
6901
|
this.timelineSenderTimer.ensureAborted();
|
|
7314
6902
|
this.timelineSenderTimer = null;
|
|
7315
6903
|
}
|
|
7316
|
-
}
|
|
7317
|
-
|
|
6904
|
+
}
|
|
6905
|
+
bind(event_name, callback, context) {
|
|
7318
6906
|
this.global_emitter.bind(event_name, callback, context);
|
|
7319
6907
|
return this;
|
|
7320
|
-
}
|
|
7321
|
-
|
|
6908
|
+
}
|
|
6909
|
+
unbind(event_name, callback, context) {
|
|
7322
6910
|
this.global_emitter.unbind(event_name, callback, context);
|
|
7323
6911
|
return this;
|
|
7324
|
-
}
|
|
7325
|
-
|
|
6912
|
+
}
|
|
6913
|
+
bind_global(callback) {
|
|
7326
6914
|
this.global_emitter.bind_global(callback);
|
|
7327
6915
|
return this;
|
|
7328
|
-
}
|
|
7329
|
-
|
|
6916
|
+
}
|
|
6917
|
+
unbind_global(callback) {
|
|
7330
6918
|
this.global_emitter.unbind_global(callback);
|
|
7331
6919
|
return this;
|
|
7332
|
-
}
|
|
7333
|
-
|
|
6920
|
+
}
|
|
6921
|
+
unbind_all(callback) {
|
|
7334
6922
|
this.global_emitter.unbind_all();
|
|
7335
6923
|
return this;
|
|
7336
|
-
}
|
|
7337
|
-
|
|
6924
|
+
}
|
|
6925
|
+
subscribeAll() {
|
|
7338
6926
|
var channelName;
|
|
7339
6927
|
for (channelName in this.channels.channels) {
|
|
7340
6928
|
if (this.channels.channels.hasOwnProperty(channelName)) {
|
|
7341
6929
|
this.subscribe(channelName);
|
|
7342
6930
|
}
|
|
7343
6931
|
}
|
|
7344
|
-
}
|
|
7345
|
-
|
|
6932
|
+
}
|
|
6933
|
+
subscribe(channel_name) {
|
|
7346
6934
|
var channel = this.channels.add(channel_name, this);
|
|
7347
6935
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
7348
6936
|
channel.reinstateSubscription();
|
|
@@ -7352,8 +6940,8 @@ var pusher_Pusher = (function () {
|
|
|
7352
6940
|
channel.subscribe();
|
|
7353
6941
|
}
|
|
7354
6942
|
return channel;
|
|
7355
|
-
}
|
|
7356
|
-
|
|
6943
|
+
}
|
|
6944
|
+
unsubscribe(channel_name) {
|
|
7357
6945
|
var channel = this.channels.find(channel_name);
|
|
7358
6946
|
if (channel && channel.subscriptionPending) {
|
|
7359
6947
|
channel.cancelSubscription();
|
|
@@ -7364,25 +6952,24 @@ var pusher_Pusher = (function () {
|
|
|
7364
6952
|
channel.unsubscribe();
|
|
7365
6953
|
}
|
|
7366
6954
|
}
|
|
7367
|
-
}
|
|
7368
|
-
|
|
6955
|
+
}
|
|
6956
|
+
send_event(event_name, data, channel) {
|
|
7369
6957
|
return this.connection.send_event(event_name, data, channel);
|
|
7370
|
-
}
|
|
7371
|
-
|
|
6958
|
+
}
|
|
6959
|
+
shouldUseTLS() {
|
|
7372
6960
|
return this.config.useTLS;
|
|
7373
|
-
}
|
|
7374
|
-
|
|
6961
|
+
}
|
|
6962
|
+
signin() {
|
|
7375
6963
|
this.user.signin();
|
|
7376
|
-
}
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
}());
|
|
6964
|
+
}
|
|
6965
|
+
}
|
|
6966
|
+
pusher_Pusher.instances = [];
|
|
6967
|
+
pusher_Pusher.isReady = false;
|
|
6968
|
+
pusher_Pusher.logToConsole = false;
|
|
6969
|
+
pusher_Pusher.Runtime = runtime;
|
|
6970
|
+
pusher_Pusher.ScriptReceivers = runtime.ScriptReceivers;
|
|
6971
|
+
pusher_Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
|
|
6972
|
+
pusher_Pusher.auth_callbacks = runtime.auth_callbacks;
|
|
7386
6973
|
/* harmony default export */ var core_pusher = (pusher_Pusher);
|
|
7387
6974
|
function checkAppKey(key) {
|
|
7388
6975
|
if (key === null || key === undefined) {
|
|
@@ -7395,36 +6982,18 @@ runtime.setup(pusher_Pusher);
|
|
|
7395
6982
|
var nacl_fast = __webpack_require__(2);
|
|
7396
6983
|
|
|
7397
6984
|
// CONCATENATED MODULE: ./src/core/pusher-with-encryption.ts
|
|
7398
|
-
var pusher_with_encryption_extends = (undefined && undefined.__extends) || (function () {
|
|
7399
|
-
var extendStatics = function (d, b) {
|
|
7400
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7401
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7402
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7403
|
-
return extendStatics(d, b);
|
|
7404
|
-
};
|
|
7405
|
-
return function (d, b) {
|
|
7406
|
-
extendStatics(d, b);
|
|
7407
|
-
function __() { this.constructor = d; }
|
|
7408
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7409
|
-
};
|
|
7410
|
-
})();
|
|
7411
6985
|
|
|
7412
6986
|
|
|
7413
6987
|
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
core_pusher.logToConsole = PusherWithEncryption.logToConsole;
|
|
7419
|
-
core_pusher.log = PusherWithEncryption.log;
|
|
6988
|
+
class pusher_with_encryption_PusherWithEncryption extends core_pusher {
|
|
6989
|
+
constructor(app_key, options) {
|
|
6990
|
+
core_pusher.logToConsole = pusher_with_encryption_PusherWithEncryption.logToConsole;
|
|
6991
|
+
core_pusher.log = pusher_with_encryption_PusherWithEncryption.log;
|
|
7420
6992
|
validateOptions(options);
|
|
7421
6993
|
options.nacl = nacl_fast;
|
|
7422
|
-
|
|
7423
|
-
return _this;
|
|
6994
|
+
super(app_key, options);
|
|
7424
6995
|
}
|
|
7425
|
-
|
|
7426
|
-
}(core_pusher));
|
|
7427
|
-
/* harmony default export */ var pusher_with_encryption = __webpack_exports__["default"] = (pusher_with_encryption_PusherWithEncryption);
|
|
6996
|
+
}
|
|
7428
6997
|
|
|
7429
6998
|
|
|
7430
6999
|
/***/ })
|