pusher-js 8.0.2 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/node/pusher.js +968 -1390
- package/dist/node/pusher.js.map +1 -1
- package/dist/react-native/pusher.js +2 -2
- package/dist/react-native/pusher.js.map +1 -1
- package/dist/web/pusher-with-encryption.js +1003 -1433
- package/dist/web/pusher-with-encryption.js.map +1 -1
- package/dist/web/pusher-with-encryption.min.js +2 -2
- package/dist/web/pusher-with-encryption.min.js.map +1 -1
- package/dist/web/pusher.js +994 -1409
- package/dist/web/pusher.js.map +1 -1
- package/dist/web/pusher.min.js +2 -2
- package/dist/web/pusher.min.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.js +968 -1389
- package/dist/worker/pusher-with-encryption.worker.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.min.js +2 -2
- package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -1
- package/dist/worker/pusher.worker.js +959 -1365
- package/dist/worker/pusher.worker.js.map +1 -1
- package/dist/worker/pusher.worker.min.js +2 -2
- package/dist/worker/pusher.worker.min.js.map +1 -1
- package/package.json +6 -6
- package/tsconfig.json +1 -1
- package/types/src/core/auth/options.d.ts +3 -3
- package/types/src/core/config.d.ts +2 -2
- package/types/src/core/strategies/transport_strategy.d.ts +0 -3
- package/types/src/core/utils/timers/scheduling.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v8.0
|
|
2
|
+
* Pusher JavaScript Library v8.1.0
|
|
3
3
|
* https://pusher.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020, Pusher
|
|
@@ -2963,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.1.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,12 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5910
5577
|
timeout: 15000,
|
|
5911
5578
|
timeoutLimit: 60000
|
|
5912
5579
|
};
|
|
5913
|
-
var ws_manager = new
|
|
5580
|
+
var ws_manager = new transport_manager_TransportManager({
|
|
5914
5581
|
lives: 2,
|
|
5915
5582
|
minPingDelay: 10000,
|
|
5916
5583
|
maxPingDelay: config.activityTimeout
|
|
5917
5584
|
});
|
|
5918
|
-
var streaming_manager = new
|
|
5585
|
+
var streaming_manager = new transport_manager_TransportManager({
|
|
5919
5586
|
lives: 2,
|
|
5920
5587
|
minPingDelay: 10000,
|
|
5921
5588
|
maxPingDelay: config.activityTimeout
|
|
@@ -5927,37 +5594,37 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
5927
5594
|
var xdr_streaming_transport = defineTransportStrategy('xdr_streaming', 'xdr_streaming', 1, sockjs_options, streaming_manager);
|
|
5928
5595
|
var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, sockjs_options);
|
|
5929
5596
|
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
|
|
5597
|
+
var ws_loop = new sequential_strategy_SequentialStrategy([ws_transport], timeouts);
|
|
5598
|
+
var wss_loop = new sequential_strategy_SequentialStrategy([wss_transport], timeouts);
|
|
5599
|
+
var sockjs_loop = new sequential_strategy_SequentialStrategy([sockjs_transport], timeouts);
|
|
5600
|
+
var streaming_loop = new sequential_strategy_SequentialStrategy([
|
|
5601
|
+
new IfStrategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)
|
|
5935
5602
|
], timeouts);
|
|
5936
|
-
var polling_loop = new
|
|
5937
|
-
new
|
|
5603
|
+
var polling_loop = new sequential_strategy_SequentialStrategy([
|
|
5604
|
+
new IfStrategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)
|
|
5938
5605
|
], timeouts);
|
|
5939
|
-
var http_loop = new
|
|
5940
|
-
new
|
|
5606
|
+
var http_loop = new sequential_strategy_SequentialStrategy([
|
|
5607
|
+
new IfStrategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5941
5608
|
streaming_loop,
|
|
5942
|
-
new
|
|
5609
|
+
new delayed_strategy_DelayedStrategy(polling_loop, { delay: 4000 })
|
|
5943
5610
|
]), polling_loop)
|
|
5944
5611
|
], timeouts);
|
|
5945
|
-
var http_fallback_loop = new
|
|
5612
|
+
var http_fallback_loop = new IfStrategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
|
|
5946
5613
|
var wsStrategy;
|
|
5947
5614
|
if (baseOptions.useTLS) {
|
|
5948
|
-
wsStrategy = new
|
|
5615
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5949
5616
|
ws_loop,
|
|
5950
|
-
new
|
|
5617
|
+
new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 2000 })
|
|
5951
5618
|
]);
|
|
5952
5619
|
}
|
|
5953
5620
|
else {
|
|
5954
|
-
wsStrategy = new
|
|
5621
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
5955
5622
|
ws_loop,
|
|
5956
|
-
new
|
|
5957
|
-
new
|
|
5623
|
+
new delayed_strategy_DelayedStrategy(wss_loop, { delay: 2000 }),
|
|
5624
|
+
new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 5000 })
|
|
5958
5625
|
]);
|
|
5959
5626
|
}
|
|
5960
|
-
return new
|
|
5627
|
+
return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
|
|
5961
5628
|
ttl: 1800000,
|
|
5962
5629
|
timeline: baseOptions.timeline,
|
|
5963
5630
|
useTLS: baseOptions.useTLS
|
|
@@ -6031,37 +5698,21 @@ var http_xdomain_request_hooks = {
|
|
|
6031
5698
|
/* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
|
|
6032
5699
|
|
|
6033
5700
|
// 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
5701
|
|
|
6048
5702
|
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
_this.url = url;
|
|
6057
|
-
return _this;
|
|
5703
|
+
const MAX_BUFFER_LENGTH = 256 * 1024;
|
|
5704
|
+
class http_request_HTTPRequest extends dispatcher_Dispatcher {
|
|
5705
|
+
constructor(hooks, method, url) {
|
|
5706
|
+
super();
|
|
5707
|
+
this.hooks = hooks;
|
|
5708
|
+
this.method = method;
|
|
5709
|
+
this.url = url;
|
|
6058
5710
|
}
|
|
6059
|
-
|
|
6060
|
-
var _this = this;
|
|
5711
|
+
start(payload) {
|
|
6061
5712
|
this.position = 0;
|
|
6062
5713
|
this.xhr = this.hooks.getRequest(this);
|
|
6063
|
-
this.unloader =
|
|
6064
|
-
|
|
5714
|
+
this.unloader = () => {
|
|
5715
|
+
this.close();
|
|
6065
5716
|
};
|
|
6066
5717
|
runtime.addUnloadListener(this.unloader);
|
|
6067
5718
|
this.xhr.open(this.method, this.url, true);
|
|
@@ -6069,8 +5720,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6069
5720
|
this.xhr.setRequestHeader('Content-Type', 'application/json');
|
|
6070
5721
|
}
|
|
6071
5722
|
this.xhr.send(payload);
|
|
6072
|
-
}
|
|
6073
|
-
|
|
5723
|
+
}
|
|
5724
|
+
close() {
|
|
6074
5725
|
if (this.unloader) {
|
|
6075
5726
|
runtime.removeUnloadListener(this.unloader);
|
|
6076
5727
|
this.unloader = null;
|
|
@@ -6079,8 +5730,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6079
5730
|
this.hooks.abortRequest(this.xhr);
|
|
6080
5731
|
this.xhr = null;
|
|
6081
5732
|
}
|
|
6082
|
-
}
|
|
6083
|
-
|
|
5733
|
+
}
|
|
5734
|
+
onChunk(status, data) {
|
|
6084
5735
|
while (true) {
|
|
6085
5736
|
var chunk = this.advanceBuffer(data);
|
|
6086
5737
|
if (chunk) {
|
|
@@ -6093,8 +5744,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6093
5744
|
if (this.isBufferTooLong(data)) {
|
|
6094
5745
|
this.emit('buffer_too_long');
|
|
6095
5746
|
}
|
|
6096
|
-
}
|
|
6097
|
-
|
|
5747
|
+
}
|
|
5748
|
+
advanceBuffer(buffer) {
|
|
6098
5749
|
var unreadData = buffer.slice(this.position);
|
|
6099
5750
|
var endOfLinePosition = unreadData.indexOf('\n');
|
|
6100
5751
|
if (endOfLinePosition !== -1) {
|
|
@@ -6104,13 +5755,11 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
6104
5755
|
else {
|
|
6105
5756
|
return null;
|
|
6106
5757
|
}
|
|
6107
|
-
}
|
|
6108
|
-
|
|
5758
|
+
}
|
|
5759
|
+
isBufferTooLong(buffer) {
|
|
6109
5760
|
return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
|
|
6110
|
-
}
|
|
6111
|
-
|
|
6112
|
-
}(dispatcher));
|
|
6113
|
-
/* harmony default export */ var http_request = (http_request_HTTPRequest);
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
6114
5763
|
|
|
6115
5764
|
// CONCATENATED MODULE: ./src/core/http/state.ts
|
|
6116
5765
|
var State;
|
|
@@ -6126,24 +5775,24 @@ var State;
|
|
|
6126
5775
|
|
|
6127
5776
|
|
|
6128
5777
|
var autoIncrement = 1;
|
|
6129
|
-
|
|
6130
|
-
|
|
5778
|
+
class http_socket_HTTPSocket {
|
|
5779
|
+
constructor(hooks, url) {
|
|
6131
5780
|
this.hooks = hooks;
|
|
6132
5781
|
this.session = randomNumber(1000) + '/' + randomString(8);
|
|
6133
5782
|
this.location = getLocation(url);
|
|
6134
5783
|
this.readyState = state.CONNECTING;
|
|
6135
5784
|
this.openStream();
|
|
6136
5785
|
}
|
|
6137
|
-
|
|
5786
|
+
send(payload) {
|
|
6138
5787
|
return this.sendRaw(JSON.stringify([payload]));
|
|
6139
|
-
}
|
|
6140
|
-
|
|
5788
|
+
}
|
|
5789
|
+
ping() {
|
|
6141
5790
|
this.hooks.sendHeartbeat(this);
|
|
6142
|
-
}
|
|
6143
|
-
|
|
5791
|
+
}
|
|
5792
|
+
close(code, reason) {
|
|
6144
5793
|
this.onClose(code, reason, true);
|
|
6145
|
-
}
|
|
6146
|
-
|
|
5794
|
+
}
|
|
5795
|
+
sendRaw(payload) {
|
|
6147
5796
|
if (this.readyState === state.OPEN) {
|
|
6148
5797
|
try {
|
|
6149
5798
|
runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);
|
|
@@ -6156,12 +5805,12 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6156
5805
|
else {
|
|
6157
5806
|
return false;
|
|
6158
5807
|
}
|
|
6159
|
-
}
|
|
6160
|
-
|
|
5808
|
+
}
|
|
5809
|
+
reconnect() {
|
|
6161
5810
|
this.closeStream();
|
|
6162
5811
|
this.openStream();
|
|
6163
|
-
}
|
|
6164
|
-
|
|
5812
|
+
}
|
|
5813
|
+
onClose(code, reason, wasClean) {
|
|
6165
5814
|
this.closeStream();
|
|
6166
5815
|
this.readyState = state.CLOSED;
|
|
6167
5816
|
if (this.onclose) {
|
|
@@ -6171,8 +5820,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6171
5820
|
wasClean: wasClean
|
|
6172
5821
|
});
|
|
6173
5822
|
}
|
|
6174
|
-
}
|
|
6175
|
-
|
|
5823
|
+
}
|
|
5824
|
+
onChunk(chunk) {
|
|
6176
5825
|
if (chunk.status !== 200) {
|
|
6177
5826
|
return;
|
|
6178
5827
|
}
|
|
@@ -6204,8 +5853,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6204
5853
|
this.onClose(payload[0], payload[1], true);
|
|
6205
5854
|
break;
|
|
6206
5855
|
}
|
|
6207
|
-
}
|
|
6208
|
-
|
|
5856
|
+
}
|
|
5857
|
+
onOpen(options) {
|
|
6209
5858
|
if (this.readyState === state.CONNECTING) {
|
|
6210
5859
|
if (options && options.hostname) {
|
|
6211
5860
|
this.location.base = replaceHost(this.location.base, options.hostname);
|
|
@@ -6218,53 +5867,51 @@ var http_socket_HTTPSocket = (function () {
|
|
|
6218
5867
|
else {
|
|
6219
5868
|
this.onClose(1006, 'Server lost session', true);
|
|
6220
5869
|
}
|
|
6221
|
-
}
|
|
6222
|
-
|
|
5870
|
+
}
|
|
5871
|
+
onEvent(event) {
|
|
6223
5872
|
if (this.readyState === state.OPEN && this.onmessage) {
|
|
6224
5873
|
this.onmessage({ data: event });
|
|
6225
5874
|
}
|
|
6226
|
-
}
|
|
6227
|
-
|
|
5875
|
+
}
|
|
5876
|
+
onActivity() {
|
|
6228
5877
|
if (this.onactivity) {
|
|
6229
5878
|
this.onactivity();
|
|
6230
5879
|
}
|
|
6231
|
-
}
|
|
6232
|
-
|
|
5880
|
+
}
|
|
5881
|
+
onError(error) {
|
|
6233
5882
|
if (this.onerror) {
|
|
6234
5883
|
this.onerror(error);
|
|
6235
5884
|
}
|
|
6236
|
-
}
|
|
6237
|
-
|
|
6238
|
-
var _this = this;
|
|
5885
|
+
}
|
|
5886
|
+
openStream() {
|
|
6239
5887
|
this.stream = runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
|
|
6240
|
-
this.stream.bind('chunk',
|
|
6241
|
-
|
|
5888
|
+
this.stream.bind('chunk', chunk => {
|
|
5889
|
+
this.onChunk(chunk);
|
|
6242
5890
|
});
|
|
6243
|
-
this.stream.bind('finished',
|
|
6244
|
-
|
|
5891
|
+
this.stream.bind('finished', status => {
|
|
5892
|
+
this.hooks.onFinished(this, status);
|
|
6245
5893
|
});
|
|
6246
|
-
this.stream.bind('buffer_too_long',
|
|
6247
|
-
|
|
5894
|
+
this.stream.bind('buffer_too_long', () => {
|
|
5895
|
+
this.reconnect();
|
|
6248
5896
|
});
|
|
6249
5897
|
try {
|
|
6250
5898
|
this.stream.start();
|
|
6251
5899
|
}
|
|
6252
5900
|
catch (error) {
|
|
6253
|
-
util.defer(
|
|
6254
|
-
|
|
6255
|
-
|
|
5901
|
+
util.defer(() => {
|
|
5902
|
+
this.onError(error);
|
|
5903
|
+
this.onClose(1006, 'Could not start streaming', false);
|
|
6256
5904
|
});
|
|
6257
5905
|
}
|
|
6258
|
-
}
|
|
6259
|
-
|
|
5906
|
+
}
|
|
5907
|
+
closeStream() {
|
|
6260
5908
|
if (this.stream) {
|
|
6261
5909
|
this.stream.unbind_all();
|
|
6262
5910
|
this.stream.close();
|
|
6263
5911
|
this.stream = null;
|
|
6264
5912
|
}
|
|
6265
|
-
}
|
|
6266
|
-
|
|
6267
|
-
}());
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
6268
5915
|
function getLocation(url) {
|
|
6269
5916
|
var parts = /([^\?]*)\/*(\??.*)/.exec(url);
|
|
6270
5917
|
return {
|
|
@@ -6371,20 +6018,20 @@ var http_xhr_request_hooks = {
|
|
|
6371
6018
|
|
|
6372
6019
|
|
|
6373
6020
|
var HTTP = {
|
|
6374
|
-
createStreamingSocket
|
|
6021
|
+
createStreamingSocket(url) {
|
|
6375
6022
|
return this.createSocket(http_streaming_socket, url);
|
|
6376
6023
|
},
|
|
6377
|
-
createPollingSocket
|
|
6024
|
+
createPollingSocket(url) {
|
|
6378
6025
|
return this.createSocket(http_polling_socket, url);
|
|
6379
6026
|
},
|
|
6380
|
-
createSocket
|
|
6027
|
+
createSocket(hooks, url) {
|
|
6381
6028
|
return new http_socket(hooks, url);
|
|
6382
6029
|
},
|
|
6383
|
-
createXHR
|
|
6030
|
+
createXHR(method, url) {
|
|
6384
6031
|
return this.createRequest(http_xhr_request, method, url);
|
|
6385
6032
|
},
|
|
6386
|
-
createRequest
|
|
6387
|
-
return new
|
|
6033
|
+
createRequest(hooks, method, url) {
|
|
6034
|
+
return new http_request_HTTPRequest(hooks, method, url);
|
|
6388
6035
|
}
|
|
6389
6036
|
};
|
|
6390
6037
|
/* harmony default export */ var http_http = (HTTP);
|
|
@@ -6420,17 +6067,16 @@ var Runtime = {
|
|
|
6420
6067
|
transportConnectionInitializer: transport_connection_initializer,
|
|
6421
6068
|
HTTPFactory: web_http_http,
|
|
6422
6069
|
TimelineTransport: jsonp_timeline,
|
|
6423
|
-
getXHRAPI
|
|
6070
|
+
getXHRAPI() {
|
|
6424
6071
|
return window.XMLHttpRequest;
|
|
6425
6072
|
},
|
|
6426
|
-
getWebSocketAPI
|
|
6073
|
+
getWebSocketAPI() {
|
|
6427
6074
|
return window.WebSocket || window.MozWebSocket;
|
|
6428
6075
|
},
|
|
6429
|
-
setup
|
|
6430
|
-
var _this = this;
|
|
6076
|
+
setup(PusherClass) {
|
|
6431
6077
|
window.Pusher = PusherClass;
|
|
6432
|
-
var initializeOnDocumentBody =
|
|
6433
|
-
|
|
6078
|
+
var initializeOnDocumentBody = () => {
|
|
6079
|
+
this.onDocumentBody(PusherClass.ready);
|
|
6434
6080
|
};
|
|
6435
6081
|
if (!window.JSON) {
|
|
6436
6082
|
Dependencies.load('json2', {}, initializeOnDocumentBody);
|
|
@@ -6439,33 +6085,32 @@ var Runtime = {
|
|
|
6439
6085
|
initializeOnDocumentBody();
|
|
6440
6086
|
}
|
|
6441
6087
|
},
|
|
6442
|
-
getDocument
|
|
6088
|
+
getDocument() {
|
|
6443
6089
|
return document;
|
|
6444
6090
|
},
|
|
6445
|
-
getProtocol
|
|
6091
|
+
getProtocol() {
|
|
6446
6092
|
return this.getDocument().location.protocol;
|
|
6447
6093
|
},
|
|
6448
|
-
getAuthorizers
|
|
6094
|
+
getAuthorizers() {
|
|
6449
6095
|
return { ajax: xhr_auth, jsonp: jsonp_auth };
|
|
6450
6096
|
},
|
|
6451
|
-
onDocumentBody
|
|
6452
|
-
var _this = this;
|
|
6097
|
+
onDocumentBody(callback) {
|
|
6453
6098
|
if (document.body) {
|
|
6454
6099
|
callback();
|
|
6455
6100
|
}
|
|
6456
6101
|
else {
|
|
6457
|
-
setTimeout(
|
|
6458
|
-
|
|
6102
|
+
setTimeout(() => {
|
|
6103
|
+
this.onDocumentBody(callback);
|
|
6459
6104
|
}, 0);
|
|
6460
6105
|
}
|
|
6461
6106
|
},
|
|
6462
|
-
createJSONPRequest
|
|
6463
|
-
return new
|
|
6107
|
+
createJSONPRequest(url, data) {
|
|
6108
|
+
return new jsonp_request_JSONPRequest(url, data);
|
|
6464
6109
|
},
|
|
6465
|
-
createScriptRequest
|
|
6466
|
-
return new
|
|
6110
|
+
createScriptRequest(src) {
|
|
6111
|
+
return new ScriptRequest(src);
|
|
6467
6112
|
},
|
|
6468
|
-
getLocalStorage
|
|
6113
|
+
getLocalStorage() {
|
|
6469
6114
|
try {
|
|
6470
6115
|
return window.localStorage;
|
|
6471
6116
|
}
|
|
@@ -6473,7 +6118,7 @@ var Runtime = {
|
|
|
6473
6118
|
return undefined;
|
|
6474
6119
|
}
|
|
6475
6120
|
},
|
|
6476
|
-
createXHR
|
|
6121
|
+
createXHR() {
|
|
6477
6122
|
if (this.getXHRAPI()) {
|
|
6478
6123
|
return this.createXMLHttpRequest();
|
|
6479
6124
|
}
|
|
@@ -6481,21 +6126,21 @@ var Runtime = {
|
|
|
6481
6126
|
return this.createMicrosoftXHR();
|
|
6482
6127
|
}
|
|
6483
6128
|
},
|
|
6484
|
-
createXMLHttpRequest
|
|
6129
|
+
createXMLHttpRequest() {
|
|
6485
6130
|
var Constructor = this.getXHRAPI();
|
|
6486
6131
|
return new Constructor();
|
|
6487
6132
|
},
|
|
6488
|
-
createMicrosoftXHR
|
|
6133
|
+
createMicrosoftXHR() {
|
|
6489
6134
|
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
6490
6135
|
},
|
|
6491
|
-
getNetwork
|
|
6136
|
+
getNetwork() {
|
|
6492
6137
|
return net_info_Network;
|
|
6493
6138
|
},
|
|
6494
|
-
createWebSocket
|
|
6139
|
+
createWebSocket(url) {
|
|
6495
6140
|
var Constructor = this.getWebSocketAPI();
|
|
6496
6141
|
return new Constructor(url);
|
|
6497
6142
|
},
|
|
6498
|
-
createSocketRequest
|
|
6143
|
+
createSocketRequest(method, url) {
|
|
6499
6144
|
if (this.isXHRSupported()) {
|
|
6500
6145
|
return this.HTTPFactory.createXHR(method, url);
|
|
6501
6146
|
}
|
|
@@ -6506,16 +6151,16 @@ var Runtime = {
|
|
|
6506
6151
|
throw 'Cross-origin HTTP requests are not supported';
|
|
6507
6152
|
}
|
|
6508
6153
|
},
|
|
6509
|
-
isXHRSupported
|
|
6154
|
+
isXHRSupported() {
|
|
6510
6155
|
var Constructor = this.getXHRAPI();
|
|
6511
6156
|
return (Boolean(Constructor) && new Constructor().withCredentials !== undefined);
|
|
6512
6157
|
},
|
|
6513
|
-
isXDRSupported
|
|
6158
|
+
isXDRSupported(useTLS) {
|
|
6514
6159
|
var protocol = useTLS ? 'https:' : 'http:';
|
|
6515
6160
|
var documentProtocol = this.getProtocol();
|
|
6516
6161
|
return (Boolean(window['XDomainRequest']) && documentProtocol === protocol);
|
|
6517
6162
|
},
|
|
6518
|
-
addUnloadListener
|
|
6163
|
+
addUnloadListener(listener) {
|
|
6519
6164
|
if (window.addEventListener !== undefined) {
|
|
6520
6165
|
window.addEventListener('unload', listener, false);
|
|
6521
6166
|
}
|
|
@@ -6523,7 +6168,7 @@ var Runtime = {
|
|
|
6523
6168
|
window.attachEvent('onunload', listener);
|
|
6524
6169
|
}
|
|
6525
6170
|
},
|
|
6526
|
-
removeUnloadListener
|
|
6171
|
+
removeUnloadListener(listener) {
|
|
6527
6172
|
if (window.addEventListener !== undefined) {
|
|
6528
6173
|
window.removeEventListener('unload', listener, false);
|
|
6529
6174
|
}
|
|
@@ -6531,10 +6176,10 @@ var Runtime = {
|
|
|
6531
6176
|
window.detachEvent('onunload', listener);
|
|
6532
6177
|
}
|
|
6533
6178
|
},
|
|
6534
|
-
randomInt
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6179
|
+
randomInt(max) {
|
|
6180
|
+
const random = function () {
|
|
6181
|
+
const crypto = window.crypto || window['msCrypto'];
|
|
6182
|
+
const random = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
6538
6183
|
return random / Math.pow(2, 32);
|
|
6539
6184
|
};
|
|
6540
6185
|
return Math.floor(random() * max);
|
|
@@ -6555,8 +6200,8 @@ var TimelineLevel;
|
|
|
6555
6200
|
|
|
6556
6201
|
|
|
6557
6202
|
|
|
6558
|
-
|
|
6559
|
-
|
|
6203
|
+
class timeline_Timeline {
|
|
6204
|
+
constructor(key, session, options) {
|
|
6560
6205
|
this.key = key;
|
|
6561
6206
|
this.session = session;
|
|
6562
6207
|
this.events = [];
|
|
@@ -6564,28 +6209,27 @@ var timeline_Timeline = (function () {
|
|
|
6564
6209
|
this.sent = 0;
|
|
6565
6210
|
this.uniqueID = 0;
|
|
6566
6211
|
}
|
|
6567
|
-
|
|
6212
|
+
log(level, event) {
|
|
6568
6213
|
if (level <= this.options.level) {
|
|
6569
6214
|
this.events.push(extend({}, event, { timestamp: util.now() }));
|
|
6570
6215
|
if (this.options.limit && this.events.length > this.options.limit) {
|
|
6571
6216
|
this.events.shift();
|
|
6572
6217
|
}
|
|
6573
6218
|
}
|
|
6574
|
-
}
|
|
6575
|
-
|
|
6219
|
+
}
|
|
6220
|
+
error(event) {
|
|
6576
6221
|
this.log(timeline_level.ERROR, event);
|
|
6577
|
-
}
|
|
6578
|
-
|
|
6222
|
+
}
|
|
6223
|
+
info(event) {
|
|
6579
6224
|
this.log(timeline_level.INFO, event);
|
|
6580
|
-
}
|
|
6581
|
-
|
|
6225
|
+
}
|
|
6226
|
+
debug(event) {
|
|
6582
6227
|
this.log(timeline_level.DEBUG, event);
|
|
6583
|
-
}
|
|
6584
|
-
|
|
6228
|
+
}
|
|
6229
|
+
isEmpty() {
|
|
6585
6230
|
return this.events.length === 0;
|
|
6586
|
-
}
|
|
6587
|
-
|
|
6588
|
-
var _this = this;
|
|
6231
|
+
}
|
|
6232
|
+
send(sendfn, callback) {
|
|
6589
6233
|
var data = extend({
|
|
6590
6234
|
session: this.session,
|
|
6591
6235
|
bundle: this.sent + 1,
|
|
@@ -6597,43 +6241,40 @@ var timeline_Timeline = (function () {
|
|
|
6597
6241
|
timeline: this.events
|
|
6598
6242
|
}, this.options.params);
|
|
6599
6243
|
this.events = [];
|
|
6600
|
-
sendfn(data,
|
|
6244
|
+
sendfn(data, (error, result) => {
|
|
6601
6245
|
if (!error) {
|
|
6602
|
-
|
|
6246
|
+
this.sent++;
|
|
6603
6247
|
}
|
|
6604
6248
|
if (callback) {
|
|
6605
6249
|
callback(error, result);
|
|
6606
6250
|
}
|
|
6607
6251
|
});
|
|
6608
6252
|
return true;
|
|
6609
|
-
}
|
|
6610
|
-
|
|
6253
|
+
}
|
|
6254
|
+
generateUniqueID() {
|
|
6611
6255
|
this.uniqueID++;
|
|
6612
6256
|
return this.uniqueID;
|
|
6613
|
-
}
|
|
6614
|
-
|
|
6615
|
-
}());
|
|
6616
|
-
/* harmony default export */ var timeline_timeline = (timeline_Timeline);
|
|
6257
|
+
}
|
|
6258
|
+
}
|
|
6617
6259
|
|
|
6618
6260
|
// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
|
|
6619
6261
|
|
|
6620
6262
|
|
|
6621
6263
|
|
|
6622
6264
|
|
|
6623
|
-
|
|
6624
|
-
|
|
6265
|
+
class transport_strategy_TransportStrategy {
|
|
6266
|
+
constructor(name, priority, transport, options) {
|
|
6625
6267
|
this.name = name;
|
|
6626
6268
|
this.priority = priority;
|
|
6627
6269
|
this.transport = transport;
|
|
6628
6270
|
this.options = options || {};
|
|
6629
6271
|
}
|
|
6630
|
-
|
|
6272
|
+
isSupported() {
|
|
6631
6273
|
return this.transport.isSupported({
|
|
6632
6274
|
useTLS: this.options.useTLS
|
|
6633
6275
|
});
|
|
6634
|
-
}
|
|
6635
|
-
|
|
6636
|
-
var _this = this;
|
|
6276
|
+
}
|
|
6277
|
+
connect(minPriority, callback) {
|
|
6637
6278
|
if (!this.isSupported()) {
|
|
6638
6279
|
return failAttempt(new UnsupportedStrategy(), callback);
|
|
6639
6280
|
}
|
|
@@ -6676,7 +6317,7 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6676
6317
|
transport.bind('closed', onClosed);
|
|
6677
6318
|
transport.initialize();
|
|
6678
6319
|
return {
|
|
6679
|
-
abort:
|
|
6320
|
+
abort: () => {
|
|
6680
6321
|
if (connected) {
|
|
6681
6322
|
return;
|
|
6682
6323
|
}
|
|
@@ -6688,11 +6329,11 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6688
6329
|
transport.close();
|
|
6689
6330
|
}
|
|
6690
6331
|
},
|
|
6691
|
-
forceMinPriority:
|
|
6332
|
+
forceMinPriority: p => {
|
|
6692
6333
|
if (connected) {
|
|
6693
6334
|
return;
|
|
6694
6335
|
}
|
|
6695
|
-
if (
|
|
6336
|
+
if (this.priority < p) {
|
|
6696
6337
|
if (handshake) {
|
|
6697
6338
|
handshake.close();
|
|
6698
6339
|
}
|
|
@@ -6702,10 +6343,8 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
6702
6343
|
}
|
|
6703
6344
|
}
|
|
6704
6345
|
};
|
|
6705
|
-
}
|
|
6706
|
-
|
|
6707
|
-
}());
|
|
6708
|
-
/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
|
|
6346
|
+
}
|
|
6347
|
+
}
|
|
6709
6348
|
function failAttempt(error, callback) {
|
|
6710
6349
|
util.defer(function () {
|
|
6711
6350
|
callback(error);
|
|
@@ -6722,7 +6361,7 @@ function failAttempt(error, callback) {
|
|
|
6722
6361
|
|
|
6723
6362
|
|
|
6724
6363
|
|
|
6725
|
-
|
|
6364
|
+
const { Transports: strategy_builder_Transports } = runtime;
|
|
6726
6365
|
var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
|
|
6727
6366
|
var transportClass = strategy_builder_Transports[type];
|
|
6728
6367
|
if (!transportClass) {
|
|
@@ -6735,7 +6374,7 @@ var strategy_builder_defineTransport = function (config, name, type, priority, o
|
|
|
6735
6374
|
var transport;
|
|
6736
6375
|
if (enabled) {
|
|
6737
6376
|
options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);
|
|
6738
|
-
transport = new
|
|
6377
|
+
transport = new transport_strategy_TransportStrategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
|
|
6739
6378
|
}
|
|
6740
6379
|
else {
|
|
6741
6380
|
transport = strategy_builder_UnsupportedStrategy;
|
|
@@ -6776,7 +6415,7 @@ function validateOptions(options) {
|
|
|
6776
6415
|
// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts
|
|
6777
6416
|
|
|
6778
6417
|
|
|
6779
|
-
|
|
6418
|
+
const composeChannelQuery = (params, authOptions) => {
|
|
6780
6419
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
6781
6420
|
for (var key in authOptions.params) {
|
|
6782
6421
|
query +=
|
|
@@ -6786,7 +6425,7 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
6786
6425
|
encodeURIComponent(authOptions.params[key]);
|
|
6787
6426
|
}
|
|
6788
6427
|
if (authOptions.paramsProvider != null) {
|
|
6789
|
-
|
|
6428
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
6790
6429
|
for (var key in dynamicParams) {
|
|
6791
6430
|
query +=
|
|
6792
6431
|
'&' +
|
|
@@ -6797,12 +6436,12 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
6797
6436
|
}
|
|
6798
6437
|
return query;
|
|
6799
6438
|
};
|
|
6800
|
-
|
|
6439
|
+
const UserAuthenticator = (authOptions) => {
|
|
6801
6440
|
if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
6802
|
-
throw
|
|
6441
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
6803
6442
|
}
|
|
6804
|
-
return
|
|
6805
|
-
|
|
6443
|
+
return (params, callback) => {
|
|
6444
|
+
const query = composeChannelQuery(params, authOptions);
|
|
6806
6445
|
runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);
|
|
6807
6446
|
};
|
|
6808
6447
|
};
|
|
@@ -6811,7 +6450,7 @@ var UserAuthenticator = function (authOptions) {
|
|
|
6811
6450
|
// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts
|
|
6812
6451
|
|
|
6813
6452
|
|
|
6814
|
-
|
|
6453
|
+
const channel_authorizer_composeChannelQuery = (params, authOptions) => {
|
|
6815
6454
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
6816
6455
|
query += '&channel_name=' + encodeURIComponent(params.channelName);
|
|
6817
6456
|
for (var key in authOptions.params) {
|
|
@@ -6822,7 +6461,7 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
6822
6461
|
encodeURIComponent(authOptions.params[key]);
|
|
6823
6462
|
}
|
|
6824
6463
|
if (authOptions.paramsProvider != null) {
|
|
6825
|
-
|
|
6464
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
6826
6465
|
for (var key in dynamicParams) {
|
|
6827
6466
|
query +=
|
|
6828
6467
|
'&' +
|
|
@@ -6833,20 +6472,20 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
6833
6472
|
}
|
|
6834
6473
|
return query;
|
|
6835
6474
|
};
|
|
6836
|
-
|
|
6475
|
+
const ChannelAuthorizer = (authOptions) => {
|
|
6837
6476
|
if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
6838
|
-
throw
|
|
6477
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
6839
6478
|
}
|
|
6840
|
-
return
|
|
6841
|
-
|
|
6479
|
+
return (params, callback) => {
|
|
6480
|
+
const query = channel_authorizer_composeChannelQuery(params, authOptions);
|
|
6842
6481
|
runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);
|
|
6843
6482
|
};
|
|
6844
6483
|
};
|
|
6845
6484
|
/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);
|
|
6846
6485
|
|
|
6847
6486
|
// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts
|
|
6848
|
-
|
|
6849
|
-
|
|
6487
|
+
const ChannelAuthorizerProxy = (pusher, authOptions, channelAuthorizerGenerator) => {
|
|
6488
|
+
const deprecatedAuthorizerOptions = {
|
|
6850
6489
|
authTransport: authOptions.transport,
|
|
6851
6490
|
authEndpoint: authOptions.endpoint,
|
|
6852
6491
|
auth: {
|
|
@@ -6854,32 +6493,21 @@ var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGen
|
|
|
6854
6493
|
headers: authOptions.headers
|
|
6855
6494
|
}
|
|
6856
6495
|
};
|
|
6857
|
-
return
|
|
6858
|
-
|
|
6859
|
-
|
|
6496
|
+
return (params, callback) => {
|
|
6497
|
+
const channel = pusher.channel(params.channelName);
|
|
6498
|
+
const channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
|
|
6860
6499
|
channelAuthorizer.authorize(params.socketId, callback);
|
|
6861
6500
|
};
|
|
6862
6501
|
};
|
|
6863
6502
|
|
|
6864
6503
|
// 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
6504
|
|
|
6877
6505
|
|
|
6878
6506
|
|
|
6879
6507
|
|
|
6880
6508
|
|
|
6881
6509
|
function getConfig(opts, pusher) {
|
|
6882
|
-
|
|
6510
|
+
let config = {
|
|
6883
6511
|
activityTimeout: opts.activityTimeout || defaults.activityTimeout,
|
|
6884
6512
|
cluster: opts.cluster,
|
|
6885
6513
|
httpPath: opts.httpPath || defaults.httpPath,
|
|
@@ -6916,7 +6544,7 @@ function getHttpHost(opts) {
|
|
|
6916
6544
|
return opts.httpHost;
|
|
6917
6545
|
}
|
|
6918
6546
|
if (opts.cluster) {
|
|
6919
|
-
return
|
|
6547
|
+
return `sockjs-${opts.cluster}.pusher.com`;
|
|
6920
6548
|
}
|
|
6921
6549
|
return defaults.httpHost;
|
|
6922
6550
|
}
|
|
@@ -6927,7 +6555,7 @@ function getWebsocketHost(opts) {
|
|
|
6927
6555
|
return getWebsocketHostFromCluster(opts.cluster);
|
|
6928
6556
|
}
|
|
6929
6557
|
function getWebsocketHostFromCluster(cluster) {
|
|
6930
|
-
return
|
|
6558
|
+
return `ws-${cluster}.pusher.com`;
|
|
6931
6559
|
}
|
|
6932
6560
|
function shouldUseTLS(opts) {
|
|
6933
6561
|
if (runtime.getProtocol() === 'https:') {
|
|
@@ -6948,7 +6576,7 @@ function getEnableStatsConfig(opts) {
|
|
|
6948
6576
|
return false;
|
|
6949
6577
|
}
|
|
6950
6578
|
function buildUserAuthenticator(opts) {
|
|
6951
|
-
|
|
6579
|
+
const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication);
|
|
6952
6580
|
if ('customHandler' in userAuthentication &&
|
|
6953
6581
|
userAuthentication['customHandler'] != null) {
|
|
6954
6582
|
return userAuthentication['customHandler'];
|
|
@@ -6956,9 +6584,9 @@ function buildUserAuthenticator(opts) {
|
|
|
6956
6584
|
return user_authenticator(userAuthentication);
|
|
6957
6585
|
}
|
|
6958
6586
|
function buildChannelAuth(opts, pusher) {
|
|
6959
|
-
|
|
6587
|
+
let channelAuthorization;
|
|
6960
6588
|
if ('channelAuthorization' in opts) {
|
|
6961
|
-
channelAuthorization =
|
|
6589
|
+
channelAuthorization = Object.assign(Object.assign({}, defaults.channelAuthorization), opts.channelAuthorization);
|
|
6962
6590
|
}
|
|
6963
6591
|
else {
|
|
6964
6592
|
channelAuthorization = {
|
|
@@ -6977,7 +6605,7 @@ function buildChannelAuth(opts, pusher) {
|
|
|
6977
6605
|
return channelAuthorization;
|
|
6978
6606
|
}
|
|
6979
6607
|
function buildChannelAuthorizer(opts, pusher) {
|
|
6980
|
-
|
|
6608
|
+
const channelAuthorization = buildChannelAuth(opts, pusher);
|
|
6981
6609
|
if ('customHandler' in channelAuthorization &&
|
|
6982
6610
|
channelAuthorization['customHandler'] != null) {
|
|
6983
6611
|
return channelAuthorization['customHandler'];
|
|
@@ -6986,134 +6614,99 @@ function buildChannelAuthorizer(opts, pusher) {
|
|
|
6986
6614
|
}
|
|
6987
6615
|
|
|
6988
6616
|
// 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
6617
|
|
|
7003
6618
|
|
|
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);
|
|
6619
|
+
class watchlist_WatchlistFacade extends dispatcher_Dispatcher {
|
|
6620
|
+
constructor(pusher) {
|
|
6621
|
+
super(function (eventName, data) {
|
|
6622
|
+
logger.debug(`No callbacks on watchlist events for ${eventName}`);
|
|
7018
6623
|
});
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
6624
|
+
this.pusher = pusher;
|
|
6625
|
+
this.bindWatchlistInternalEvent();
|
|
6626
|
+
}
|
|
6627
|
+
handleEvent(pusherEvent) {
|
|
6628
|
+
pusherEvent.data.events.forEach(watchlistEvent => {
|
|
6629
|
+
this.emit(watchlistEvent.name, watchlistEvent);
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6632
|
+
bindWatchlistInternalEvent() {
|
|
6633
|
+
this.pusher.connection.bind('message', pusherEvent => {
|
|
7023
6634
|
var eventName = pusherEvent.event;
|
|
7024
6635
|
if (eventName === 'pusher_internal:watchlist_events') {
|
|
7025
|
-
|
|
6636
|
+
this.handleEvent(pusherEvent);
|
|
7026
6637
|
}
|
|
7027
6638
|
});
|
|
7028
|
-
}
|
|
7029
|
-
|
|
7030
|
-
}(dispatcher));
|
|
7031
|
-
/* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
7032
6641
|
|
|
7033
6642
|
// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
|
|
7034
6643
|
function flatPromise() {
|
|
7035
|
-
|
|
7036
|
-
|
|
6644
|
+
let resolve, reject;
|
|
6645
|
+
const promise = new Promise((res, rej) => {
|
|
7037
6646
|
resolve = res;
|
|
7038
6647
|
reject = rej;
|
|
7039
6648
|
});
|
|
7040
|
-
return { promise
|
|
6649
|
+
return { promise, resolve, reject };
|
|
7041
6650
|
}
|
|
7042
6651
|
/* harmony default export */ var flat_promise = (flatPromise);
|
|
7043
6652
|
|
|
7044
6653
|
// 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
6654
|
|
|
7059
6655
|
|
|
7060
6656
|
|
|
7061
6657
|
|
|
7062
6658
|
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
var _this = _super.call(this, function (eventName, data) {
|
|
6659
|
+
class user_UserFacade extends dispatcher_Dispatcher {
|
|
6660
|
+
constructor(pusher) {
|
|
6661
|
+
super(function (eventName, data) {
|
|
7067
6662
|
logger.debug('No callbacks on user for ' + eventName);
|
|
7068
|
-
})
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
6663
|
+
});
|
|
6664
|
+
this.signin_requested = false;
|
|
6665
|
+
this.user_data = null;
|
|
6666
|
+
this.serverToUserChannel = null;
|
|
6667
|
+
this.signinDonePromise = null;
|
|
6668
|
+
this._signinDoneResolve = null;
|
|
6669
|
+
this._onAuthorize = (err, authData) => {
|
|
7075
6670
|
if (err) {
|
|
7076
|
-
logger.warn(
|
|
7077
|
-
|
|
6671
|
+
logger.warn(`Error during signin: ${err}`);
|
|
6672
|
+
this._cleanup();
|
|
7078
6673
|
return;
|
|
7079
6674
|
}
|
|
7080
|
-
|
|
6675
|
+
this.pusher.send_event('pusher:signin', {
|
|
7081
6676
|
auth: authData.auth,
|
|
7082
6677
|
user_data: authData.user_data
|
|
7083
6678
|
});
|
|
7084
6679
|
};
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
var previous = _a.previous, current = _a.current;
|
|
6680
|
+
this.pusher = pusher;
|
|
6681
|
+
this.pusher.connection.bind('state_change', ({ previous, current }) => {
|
|
7088
6682
|
if (previous !== 'connected' && current === 'connected') {
|
|
7089
|
-
|
|
6683
|
+
this._signin();
|
|
7090
6684
|
}
|
|
7091
6685
|
if (previous === 'connected' && current !== 'connected') {
|
|
7092
|
-
|
|
7093
|
-
|
|
6686
|
+
this._cleanup();
|
|
6687
|
+
this._newSigninPromiseIfNeeded();
|
|
7094
6688
|
}
|
|
7095
6689
|
});
|
|
7096
|
-
|
|
7097
|
-
|
|
6690
|
+
this.watchlist = new watchlist_WatchlistFacade(pusher);
|
|
6691
|
+
this.pusher.connection.bind('message', event => {
|
|
7098
6692
|
var eventName = event.event;
|
|
7099
6693
|
if (eventName === 'pusher:signin_success') {
|
|
7100
|
-
|
|
6694
|
+
this._onSigninSuccess(event.data);
|
|
7101
6695
|
}
|
|
7102
|
-
if (
|
|
7103
|
-
|
|
7104
|
-
|
|
6696
|
+
if (this.serverToUserChannel &&
|
|
6697
|
+
this.serverToUserChannel.name === event.channel) {
|
|
6698
|
+
this.serverToUserChannel.handleEvent(event);
|
|
7105
6699
|
}
|
|
7106
6700
|
});
|
|
7107
|
-
return _this;
|
|
7108
6701
|
}
|
|
7109
|
-
|
|
6702
|
+
signin() {
|
|
7110
6703
|
if (this.signin_requested) {
|
|
7111
6704
|
return;
|
|
7112
6705
|
}
|
|
7113
6706
|
this.signin_requested = true;
|
|
7114
6707
|
this._signin();
|
|
7115
|
-
}
|
|
7116
|
-
|
|
6708
|
+
}
|
|
6709
|
+
_signin() {
|
|
7117
6710
|
if (!this.signin_requested) {
|
|
7118
6711
|
return;
|
|
7119
6712
|
}
|
|
@@ -7124,46 +6717,45 @@ var user_UserFacade = (function (_super) {
|
|
|
7124
6717
|
this.pusher.config.userAuthenticator({
|
|
7125
6718
|
socketId: this.pusher.connection.socket_id
|
|
7126
6719
|
}, this._onAuthorize);
|
|
7127
|
-
}
|
|
7128
|
-
|
|
6720
|
+
}
|
|
6721
|
+
_onSigninSuccess(data) {
|
|
7129
6722
|
try {
|
|
7130
6723
|
this.user_data = JSON.parse(data.user_data);
|
|
7131
6724
|
}
|
|
7132
6725
|
catch (e) {
|
|
7133
|
-
logger.error(
|
|
6726
|
+
logger.error(`Failed parsing user data after signin: ${data.user_data}`);
|
|
7134
6727
|
this._cleanup();
|
|
7135
6728
|
return;
|
|
7136
6729
|
}
|
|
7137
6730
|
if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
|
|
7138
|
-
logger.error(
|
|
6731
|
+
logger.error(`user_data doesn't contain an id. user_data: ${this.user_data}`);
|
|
7139
6732
|
this._cleanup();
|
|
7140
6733
|
return;
|
|
7141
6734
|
}
|
|
7142
6735
|
this._signinDoneResolve();
|
|
7143
6736
|
this._subscribeChannels();
|
|
7144
|
-
}
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
var ensure_subscribed = function (channel) {
|
|
6737
|
+
}
|
|
6738
|
+
_subscribeChannels() {
|
|
6739
|
+
const ensure_subscribed = channel => {
|
|
7148
6740
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
7149
6741
|
channel.reinstateSubscription();
|
|
7150
6742
|
}
|
|
7151
6743
|
else if (!channel.subscriptionPending &&
|
|
7152
|
-
|
|
6744
|
+
this.pusher.connection.state === 'connected') {
|
|
7153
6745
|
channel.subscribe();
|
|
7154
6746
|
}
|
|
7155
6747
|
};
|
|
7156
|
-
this.serverToUserChannel = new
|
|
7157
|
-
this.serverToUserChannel.bind_global(
|
|
6748
|
+
this.serverToUserChannel = new channel_Channel(`#server-to-user-${this.user_data.id}`, this.pusher);
|
|
6749
|
+
this.serverToUserChannel.bind_global((eventName, data) => {
|
|
7158
6750
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
7159
6751
|
eventName.indexOf('pusher:') === 0) {
|
|
7160
6752
|
return;
|
|
7161
6753
|
}
|
|
7162
|
-
|
|
6754
|
+
this.emit(eventName, data);
|
|
7163
6755
|
});
|
|
7164
6756
|
ensure_subscribed(this.serverToUserChannel);
|
|
7165
|
-
}
|
|
7166
|
-
|
|
6757
|
+
}
|
|
6758
|
+
_cleanup() {
|
|
7167
6759
|
this.user_data = null;
|
|
7168
6760
|
if (this.serverToUserChannel) {
|
|
7169
6761
|
this.serverToUserChannel.unbind_all();
|
|
@@ -7173,26 +6765,24 @@ var user_UserFacade = (function (_super) {
|
|
|
7173
6765
|
if (this.signin_requested) {
|
|
7174
6766
|
this._signinDoneResolve();
|
|
7175
6767
|
}
|
|
7176
|
-
}
|
|
7177
|
-
|
|
6768
|
+
}
|
|
6769
|
+
_newSigninPromiseIfNeeded() {
|
|
7178
6770
|
if (!this.signin_requested) {
|
|
7179
6771
|
return;
|
|
7180
6772
|
}
|
|
7181
6773
|
if (this.signinDonePromise && !this.signinDonePromise.done) {
|
|
7182
6774
|
return;
|
|
7183
6775
|
}
|
|
7184
|
-
|
|
6776
|
+
const { promise, resolve, reject: _ } = flat_promise();
|
|
7185
6777
|
promise.done = false;
|
|
7186
|
-
|
|
6778
|
+
const setDone = () => {
|
|
7187
6779
|
promise.done = true;
|
|
7188
6780
|
};
|
|
7189
|
-
promise.then(setDone)
|
|
6781
|
+
promise.then(setDone).catch(setDone);
|
|
7190
6782
|
this.signinDonePromise = promise;
|
|
7191
6783
|
this._signinDoneResolve = resolve;
|
|
7192
|
-
}
|
|
7193
|
-
|
|
7194
|
-
}(dispatcher));
|
|
7195
|
-
/* harmony default export */ var user = (user_UserFacade);
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
7196
6786
|
|
|
7197
6787
|
// CONCATENATED MODULE: ./src/core/pusher.ts
|
|
7198
6788
|
|
|
@@ -7208,19 +6798,29 @@ var user_UserFacade = (function (_super) {
|
|
|
7208
6798
|
|
|
7209
6799
|
|
|
7210
6800
|
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
6801
|
+
class pusher_Pusher {
|
|
6802
|
+
static ready() {
|
|
6803
|
+
pusher_Pusher.isReady = true;
|
|
6804
|
+
for (var i = 0, l = pusher_Pusher.instances.length; i < l; i++) {
|
|
6805
|
+
pusher_Pusher.instances[i].connect();
|
|
6806
|
+
}
|
|
6807
|
+
}
|
|
6808
|
+
static getClientFeatures() {
|
|
6809
|
+
return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
|
|
6810
|
+
return t.isSupported({});
|
|
6811
|
+
}));
|
|
6812
|
+
}
|
|
6813
|
+
constructor(app_key, options) {
|
|
7214
6814
|
checkAppKey(app_key);
|
|
7215
6815
|
validateOptions(options);
|
|
7216
6816
|
this.key = app_key;
|
|
7217
6817
|
this.config = getConfig(options, this);
|
|
7218
6818
|
this.channels = factory.createChannels();
|
|
7219
|
-
this.global_emitter = new
|
|
6819
|
+
this.global_emitter = new dispatcher_Dispatcher();
|
|
7220
6820
|
this.sessionID = runtime.randomInt(1000000000);
|
|
7221
|
-
this.timeline = new
|
|
6821
|
+
this.timeline = new timeline_Timeline(this.key, this.sessionID, {
|
|
7222
6822
|
cluster: this.config.cluster,
|
|
7223
|
-
features:
|
|
6823
|
+
features: pusher_Pusher.getClientFeatures(),
|
|
7224
6824
|
params: this.config.timelineParams || {},
|
|
7225
6825
|
limit: 50,
|
|
7226
6826
|
level: timeline_level.INFO,
|
|
@@ -7232,8 +6832,8 @@ var pusher_Pusher = (function () {
|
|
|
7232
6832
|
path: '/timeline/v2/' + runtime.TimelineTransport.name
|
|
7233
6833
|
});
|
|
7234
6834
|
}
|
|
7235
|
-
var getStrategy =
|
|
7236
|
-
return runtime.getDefaultStrategy(
|
|
6835
|
+
var getStrategy = (options) => {
|
|
6836
|
+
return runtime.getDefaultStrategy(this.config, options, strategy_builder_defineTransport);
|
|
7237
6837
|
};
|
|
7238
6838
|
this.connection = factory.createConnectionManager(this.key, {
|
|
7239
6839
|
getStrategy: getStrategy,
|
|
@@ -7243,106 +6843,95 @@ var pusher_Pusher = (function () {
|
|
|
7243
6843
|
unavailableTimeout: this.config.unavailableTimeout,
|
|
7244
6844
|
useTLS: Boolean(this.config.useTLS)
|
|
7245
6845
|
});
|
|
7246
|
-
this.connection.bind('connected',
|
|
7247
|
-
|
|
7248
|
-
if (
|
|
7249
|
-
|
|
6846
|
+
this.connection.bind('connected', () => {
|
|
6847
|
+
this.subscribeAll();
|
|
6848
|
+
if (this.timelineSender) {
|
|
6849
|
+
this.timelineSender.send(this.connection.isUsingTLS());
|
|
7250
6850
|
}
|
|
7251
6851
|
});
|
|
7252
|
-
this.connection.bind('message',
|
|
6852
|
+
this.connection.bind('message', event => {
|
|
7253
6853
|
var eventName = event.event;
|
|
7254
6854
|
var internal = eventName.indexOf('pusher_internal:') === 0;
|
|
7255
6855
|
if (event.channel) {
|
|
7256
|
-
var channel =
|
|
6856
|
+
var channel = this.channel(event.channel);
|
|
7257
6857
|
if (channel) {
|
|
7258
6858
|
channel.handleEvent(event);
|
|
7259
6859
|
}
|
|
7260
6860
|
}
|
|
7261
6861
|
if (!internal) {
|
|
7262
|
-
|
|
6862
|
+
this.global_emitter.emit(event.event, event.data);
|
|
7263
6863
|
}
|
|
7264
6864
|
});
|
|
7265
|
-
this.connection.bind('connecting',
|
|
7266
|
-
|
|
6865
|
+
this.connection.bind('connecting', () => {
|
|
6866
|
+
this.channels.disconnect();
|
|
7267
6867
|
});
|
|
7268
|
-
this.connection.bind('disconnected',
|
|
7269
|
-
|
|
6868
|
+
this.connection.bind('disconnected', () => {
|
|
6869
|
+
this.channels.disconnect();
|
|
7270
6870
|
});
|
|
7271
|
-
this.connection.bind('error',
|
|
6871
|
+
this.connection.bind('error', err => {
|
|
7272
6872
|
logger.warn(err);
|
|
7273
6873
|
});
|
|
7274
|
-
|
|
7275
|
-
this.timeline.info({ instances:
|
|
7276
|
-
this.user = new
|
|
7277
|
-
if (
|
|
6874
|
+
pusher_Pusher.instances.push(this);
|
|
6875
|
+
this.timeline.info({ instances: pusher_Pusher.instances.length });
|
|
6876
|
+
this.user = new user_UserFacade(this);
|
|
6877
|
+
if (pusher_Pusher.isReady) {
|
|
7278
6878
|
this.connect();
|
|
7279
6879
|
}
|
|
7280
6880
|
}
|
|
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) {
|
|
6881
|
+
channel(name) {
|
|
7293
6882
|
return this.channels.find(name);
|
|
7294
|
-
}
|
|
7295
|
-
|
|
6883
|
+
}
|
|
6884
|
+
allChannels() {
|
|
7296
6885
|
return this.channels.all();
|
|
7297
|
-
}
|
|
7298
|
-
|
|
6886
|
+
}
|
|
6887
|
+
connect() {
|
|
7299
6888
|
this.connection.connect();
|
|
7300
6889
|
if (this.timelineSender) {
|
|
7301
6890
|
if (!this.timelineSenderTimer) {
|
|
7302
6891
|
var usingTLS = this.connection.isUsingTLS();
|
|
7303
6892
|
var timelineSender = this.timelineSender;
|
|
7304
|
-
this.timelineSenderTimer = new
|
|
6893
|
+
this.timelineSenderTimer = new timers_PeriodicTimer(60000, function () {
|
|
7305
6894
|
timelineSender.send(usingTLS);
|
|
7306
6895
|
});
|
|
7307
6896
|
}
|
|
7308
6897
|
}
|
|
7309
|
-
}
|
|
7310
|
-
|
|
6898
|
+
}
|
|
6899
|
+
disconnect() {
|
|
7311
6900
|
this.connection.disconnect();
|
|
7312
6901
|
if (this.timelineSenderTimer) {
|
|
7313
6902
|
this.timelineSenderTimer.ensureAborted();
|
|
7314
6903
|
this.timelineSenderTimer = null;
|
|
7315
6904
|
}
|
|
7316
|
-
}
|
|
7317
|
-
|
|
6905
|
+
}
|
|
6906
|
+
bind(event_name, callback, context) {
|
|
7318
6907
|
this.global_emitter.bind(event_name, callback, context);
|
|
7319
6908
|
return this;
|
|
7320
|
-
}
|
|
7321
|
-
|
|
6909
|
+
}
|
|
6910
|
+
unbind(event_name, callback, context) {
|
|
7322
6911
|
this.global_emitter.unbind(event_name, callback, context);
|
|
7323
6912
|
return this;
|
|
7324
|
-
}
|
|
7325
|
-
|
|
6913
|
+
}
|
|
6914
|
+
bind_global(callback) {
|
|
7326
6915
|
this.global_emitter.bind_global(callback);
|
|
7327
6916
|
return this;
|
|
7328
|
-
}
|
|
7329
|
-
|
|
6917
|
+
}
|
|
6918
|
+
unbind_global(callback) {
|
|
7330
6919
|
this.global_emitter.unbind_global(callback);
|
|
7331
6920
|
return this;
|
|
7332
|
-
}
|
|
7333
|
-
|
|
6921
|
+
}
|
|
6922
|
+
unbind_all(callback) {
|
|
7334
6923
|
this.global_emitter.unbind_all();
|
|
7335
6924
|
return this;
|
|
7336
|
-
}
|
|
7337
|
-
|
|
6925
|
+
}
|
|
6926
|
+
subscribeAll() {
|
|
7338
6927
|
var channelName;
|
|
7339
6928
|
for (channelName in this.channels.channels) {
|
|
7340
6929
|
if (this.channels.channels.hasOwnProperty(channelName)) {
|
|
7341
6930
|
this.subscribe(channelName);
|
|
7342
6931
|
}
|
|
7343
6932
|
}
|
|
7344
|
-
}
|
|
7345
|
-
|
|
6933
|
+
}
|
|
6934
|
+
subscribe(channel_name) {
|
|
7346
6935
|
var channel = this.channels.add(channel_name, this);
|
|
7347
6936
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
7348
6937
|
channel.reinstateSubscription();
|
|
@@ -7352,8 +6941,8 @@ var pusher_Pusher = (function () {
|
|
|
7352
6941
|
channel.subscribe();
|
|
7353
6942
|
}
|
|
7354
6943
|
return channel;
|
|
7355
|
-
}
|
|
7356
|
-
|
|
6944
|
+
}
|
|
6945
|
+
unsubscribe(channel_name) {
|
|
7357
6946
|
var channel = this.channels.find(channel_name);
|
|
7358
6947
|
if (channel && channel.subscriptionPending) {
|
|
7359
6948
|
channel.cancelSubscription();
|
|
@@ -7364,25 +6953,24 @@ var pusher_Pusher = (function () {
|
|
|
7364
6953
|
channel.unsubscribe();
|
|
7365
6954
|
}
|
|
7366
6955
|
}
|
|
7367
|
-
}
|
|
7368
|
-
|
|
6956
|
+
}
|
|
6957
|
+
send_event(event_name, data, channel) {
|
|
7369
6958
|
return this.connection.send_event(event_name, data, channel);
|
|
7370
|
-
}
|
|
7371
|
-
|
|
6959
|
+
}
|
|
6960
|
+
shouldUseTLS() {
|
|
7372
6961
|
return this.config.useTLS;
|
|
7373
|
-
}
|
|
7374
|
-
|
|
6962
|
+
}
|
|
6963
|
+
signin() {
|
|
7375
6964
|
this.user.signin();
|
|
7376
|
-
}
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
}());
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
pusher_Pusher.instances = [];
|
|
6968
|
+
pusher_Pusher.isReady = false;
|
|
6969
|
+
pusher_Pusher.logToConsole = false;
|
|
6970
|
+
pusher_Pusher.Runtime = runtime;
|
|
6971
|
+
pusher_Pusher.ScriptReceivers = runtime.ScriptReceivers;
|
|
6972
|
+
pusher_Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
|
|
6973
|
+
pusher_Pusher.auth_callbacks = runtime.auth_callbacks;
|
|
7386
6974
|
/* harmony default export */ var core_pusher = (pusher_Pusher);
|
|
7387
6975
|
function checkAppKey(key) {
|
|
7388
6976
|
if (key === null || key === undefined) {
|
|
@@ -7395,36 +6983,18 @@ runtime.setup(pusher_Pusher);
|
|
|
7395
6983
|
var nacl_fast = __webpack_require__(2);
|
|
7396
6984
|
|
|
7397
6985
|
// 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
6986
|
|
|
7412
6987
|
|
|
7413
6988
|
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
core_pusher.logToConsole = PusherWithEncryption.logToConsole;
|
|
7419
|
-
core_pusher.log = PusherWithEncryption.log;
|
|
6989
|
+
class pusher_with_encryption_PusherWithEncryption extends core_pusher {
|
|
6990
|
+
constructor(app_key, options) {
|
|
6991
|
+
core_pusher.logToConsole = pusher_with_encryption_PusherWithEncryption.logToConsole;
|
|
6992
|
+
core_pusher.log = pusher_with_encryption_PusherWithEncryption.log;
|
|
7420
6993
|
validateOptions(options);
|
|
7421
6994
|
options.nacl = nacl_fast;
|
|
7422
|
-
|
|
7423
|
-
return _this;
|
|
6995
|
+
super(app_key, options);
|
|
7424
6996
|
}
|
|
7425
|
-
|
|
7426
|
-
}(core_pusher));
|
|
7427
|
-
/* harmony default export */ var pusher_with_encryption = __webpack_exports__["default"] = (pusher_with_encryption_PusherWithEncryption);
|
|
6997
|
+
}
|
|
7428
6998
|
|
|
7429
6999
|
|
|
7430
7000
|
/***/ })
|