pusher-js 7.4.0 → 7.5.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v7.4.0
2
+ * Pusher JavaScript Library v7.5.0
3
3
  * https://pusher.com/
4
4
  *
5
5
  * Copyright 2020, Pusher
@@ -897,7 +897,7 @@ function safeJSONStringify(source) {
897
897
 
898
898
  // CONCATENATED MODULE: ./src/core/defaults.ts
899
899
  var Defaults = {
900
- VERSION: "7.4.0",
900
+ VERSION: "7.5.0",
901
901
  PROTOCOL: 7,
902
902
  wsPort: 80,
903
903
  wssPort: 443,
@@ -2093,10 +2093,11 @@ var presence_channel_extends = (undefined && undefined.__extends) || (function (
2093
2093
  };
2094
2094
  })();
2095
2095
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2096
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2096
2097
  return new (P || (P = Promise))(function (resolve, reject) {
2097
2098
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2098
2099
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2099
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2100
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2100
2101
  step((generator = generator.apply(thisArg, _arguments || [])).next());
2101
2102
  });
2102
2103
  };
@@ -3435,7 +3436,7 @@ function replaceHost(url, hostname) {
3435
3436
  return urlParts[1] + hostname + urlParts[3];
3436
3437
  }
3437
3438
  function randomNumber(max) {
3438
- return Math.floor(Math.random() * max);
3439
+ return worker_runtime.randomInt(max);
3439
3440
  }
3440
3441
  function randomString(length) {
3441
3442
  var result = [];
@@ -3719,6 +3720,14 @@ var Worker = {
3719
3720
  },
3720
3721
  getNetwork: function () {
3721
3722
  return net_info_Network;
3723
+ },
3724
+ randomInt: function (max) {
3725
+ var random = function () {
3726
+ var crypto = window.crypto || window['msCrypto'];
3727
+ var random = crypto.getRandomValues(new Uint32Array(1))[0];
3728
+ return random / Math.pow(2, 32);
3729
+ };
3730
+ return Math.floor(random() * max);
3722
3731
  }
3723
3732
  };
3724
3733
  /* harmony default export */ var worker_runtime = (Worker);
@@ -4105,7 +4114,7 @@ function getEnableStatsConfig(opts) {
4105
4114
  return false;
4106
4115
  }
4107
4116
  function buildUserAuthenticator(opts) {
4108
- var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);
4117
+ var userAuthentication = __assign(__assign({}, defaults.userAuthentication), opts.userAuthentication);
4109
4118
  if ('customHandler' in userAuthentication &&
4110
4119
  userAuthentication['customHandler'] != null) {
4111
4120
  return userAuthentication['customHandler'];
@@ -4115,7 +4124,7 @@ function buildUserAuthenticator(opts) {
4115
4124
  function buildChannelAuth(opts, pusher) {
4116
4125
  var channelAuthorization;
4117
4126
  if ('channelAuthorization' in opts) {
4118
- channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);
4127
+ channelAuthorization = __assign(__assign({}, defaults.channelAuthorization), opts.channelAuthorization);
4119
4128
  }
4120
4129
  else {
4121
4130
  channelAuthorization = {
@@ -4142,6 +4151,51 @@ function buildChannelAuthorizer(opts, pusher) {
4142
4151
  return channel_authorizer(channelAuthorization);
4143
4152
  }
4144
4153
 
4154
+ // CONCATENATED MODULE: ./src/core/watchlist.ts
4155
+ var watchlist_extends = (undefined && undefined.__extends) || (function () {
4156
+ var extendStatics = function (d, b) {
4157
+ extendStatics = Object.setPrototypeOf ||
4158
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4159
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4160
+ return extendStatics(d, b);
4161
+ };
4162
+ return function (d, b) {
4163
+ extendStatics(d, b);
4164
+ function __() { this.constructor = d; }
4165
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4166
+ };
4167
+ })();
4168
+
4169
+
4170
+ var watchlist_WatchlistFacade = (function (_super) {
4171
+ watchlist_extends(WatchlistFacade, _super);
4172
+ function WatchlistFacade(pusher) {
4173
+ var _this = _super.call(this, function (eventName, data) {
4174
+ logger.debug("No callbacks on watchlist events for " + eventName);
4175
+ }) || this;
4176
+ _this.pusher = pusher;
4177
+ _this.bindWatchlistInternalEvent();
4178
+ return _this;
4179
+ }
4180
+ WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
4181
+ var _this = this;
4182
+ pusherEvent.data.events.forEach(function (watchlistEvent) {
4183
+ _this.emit(watchlistEvent.name, watchlistEvent);
4184
+ });
4185
+ };
4186
+ WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
4187
+ var _this = this;
4188
+ this.pusher.connection.bind('message', function (pusherEvent) {
4189
+ var eventName = pusherEvent.event;
4190
+ if (eventName === 'pusher_internal:watchlist_events') {
4191
+ _this.handleEvent(pusherEvent);
4192
+ }
4193
+ });
4194
+ };
4195
+ return WatchlistFacade;
4196
+ }(dispatcher));
4197
+ /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
4198
+
4145
4199
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
4146
4200
  function flatPromise() {
4147
4201
  var resolve, reject;
@@ -4171,6 +4225,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
4171
4225
 
4172
4226
 
4173
4227
 
4228
+
4174
4229
  var user_UserFacade = (function (_super) {
4175
4230
  user_extends(UserFacade, _super);
4176
4231
  function UserFacade(pusher) {
@@ -4204,6 +4259,7 @@ var user_UserFacade = (function (_super) {
4204
4259
  _this._newSigninPromiseIfNeeded();
4205
4260
  }
4206
4261
  });
4262
+ _this.watchlist = new watchlist(pusher);
4207
4263
  _this.pusher.connection.bind('message', function (event) {
4208
4264
  var eventName = event.event;
4209
4265
  if (eventName === 'pusher:signin_success') {
@@ -4334,7 +4390,7 @@ var pusher_Pusher = (function () {
4334
4390
  this.config = getConfig(options, this);
4335
4391
  this.channels = factory.createChannels();
4336
4392
  this.global_emitter = new dispatcher();
4337
- this.sessionID = Math.floor(Math.random() * 1000000000);
4393
+ this.sessionID = worker_runtime.randomInt(1000000000);
4338
4394
  this.timeline = new timeline_timeline(this.key, this.sessionID, {
4339
4395
  cluster: this.config.cluster,
4340
4396
  features: Pusher.getClientFeatures(),