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
@@ -3299,7 +3299,7 @@ function safeJSONStringify(source) {
3299
3299
 
3300
3300
  // CONCATENATED MODULE: ./src/core/defaults.ts
3301
3301
  var Defaults = {
3302
- VERSION: "7.4.0",
3302
+ VERSION: "7.5.0",
3303
3303
  PROTOCOL: 7,
3304
3304
  wsPort: 80,
3305
3305
  wssPort: 443,
@@ -4495,10 +4495,11 @@ var presence_channel_extends = (undefined && undefined.__extends) || (function (
4495
4495
  };
4496
4496
  })();
4497
4497
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4498
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4498
4499
  return new (P || (P = Promise))(function (resolve, reject) {
4499
4500
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4500
4501
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4501
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
4502
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4502
4503
  step((generator = generator.apply(thisArg, _arguments || [])).next());
4503
4504
  });
4504
4505
  };
@@ -5837,7 +5838,7 @@ function replaceHost(url, hostname) {
5837
5838
  return urlParts[1] + hostname + urlParts[3];
5838
5839
  }
5839
5840
  function randomNumber(max) {
5840
- return Math.floor(Math.random() * max);
5841
+ return worker_runtime.randomInt(max);
5841
5842
  }
5842
5843
  function randomString(length) {
5843
5844
  var result = [];
@@ -6121,6 +6122,14 @@ var Worker = {
6121
6122
  },
6122
6123
  getNetwork: function () {
6123
6124
  return net_info_Network;
6125
+ },
6126
+ randomInt: function (max) {
6127
+ var random = function () {
6128
+ var crypto = window.crypto || window['msCrypto'];
6129
+ var random = crypto.getRandomValues(new Uint32Array(1))[0];
6130
+ return random / Math.pow(2, 32);
6131
+ };
6132
+ return Math.floor(random() * max);
6124
6133
  }
6125
6134
  };
6126
6135
  /* harmony default export */ var worker_runtime = (Worker);
@@ -6507,7 +6516,7 @@ function getEnableStatsConfig(opts) {
6507
6516
  return false;
6508
6517
  }
6509
6518
  function buildUserAuthenticator(opts) {
6510
- var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);
6519
+ var userAuthentication = __assign(__assign({}, defaults.userAuthentication), opts.userAuthentication);
6511
6520
  if ('customHandler' in userAuthentication &&
6512
6521
  userAuthentication['customHandler'] != null) {
6513
6522
  return userAuthentication['customHandler'];
@@ -6517,7 +6526,7 @@ function buildUserAuthenticator(opts) {
6517
6526
  function buildChannelAuth(opts, pusher) {
6518
6527
  var channelAuthorization;
6519
6528
  if ('channelAuthorization' in opts) {
6520
- channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);
6529
+ channelAuthorization = __assign(__assign({}, defaults.channelAuthorization), opts.channelAuthorization);
6521
6530
  }
6522
6531
  else {
6523
6532
  channelAuthorization = {
@@ -6544,6 +6553,51 @@ function buildChannelAuthorizer(opts, pusher) {
6544
6553
  return channel_authorizer(channelAuthorization);
6545
6554
  }
6546
6555
 
6556
+ // CONCATENATED MODULE: ./src/core/watchlist.ts
6557
+ var watchlist_extends = (undefined && undefined.__extends) || (function () {
6558
+ var extendStatics = function (d, b) {
6559
+ extendStatics = Object.setPrototypeOf ||
6560
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6561
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6562
+ return extendStatics(d, b);
6563
+ };
6564
+ return function (d, b) {
6565
+ extendStatics(d, b);
6566
+ function __() { this.constructor = d; }
6567
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6568
+ };
6569
+ })();
6570
+
6571
+
6572
+ var watchlist_WatchlistFacade = (function (_super) {
6573
+ watchlist_extends(WatchlistFacade, _super);
6574
+ function WatchlistFacade(pusher) {
6575
+ var _this = _super.call(this, function (eventName, data) {
6576
+ logger.debug("No callbacks on watchlist events for " + eventName);
6577
+ }) || this;
6578
+ _this.pusher = pusher;
6579
+ _this.bindWatchlistInternalEvent();
6580
+ return _this;
6581
+ }
6582
+ WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
6583
+ var _this = this;
6584
+ pusherEvent.data.events.forEach(function (watchlistEvent) {
6585
+ _this.emit(watchlistEvent.name, watchlistEvent);
6586
+ });
6587
+ };
6588
+ WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
6589
+ var _this = this;
6590
+ this.pusher.connection.bind('message', function (pusherEvent) {
6591
+ var eventName = pusherEvent.event;
6592
+ if (eventName === 'pusher_internal:watchlist_events') {
6593
+ _this.handleEvent(pusherEvent);
6594
+ }
6595
+ });
6596
+ };
6597
+ return WatchlistFacade;
6598
+ }(dispatcher));
6599
+ /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
6600
+
6547
6601
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
6548
6602
  function flatPromise() {
6549
6603
  var resolve, reject;
@@ -6573,6 +6627,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
6573
6627
 
6574
6628
 
6575
6629
 
6630
+
6576
6631
  var user_UserFacade = (function (_super) {
6577
6632
  user_extends(UserFacade, _super);
6578
6633
  function UserFacade(pusher) {
@@ -6606,6 +6661,7 @@ var user_UserFacade = (function (_super) {
6606
6661
  _this._newSigninPromiseIfNeeded();
6607
6662
  }
6608
6663
  });
6664
+ _this.watchlist = new watchlist(pusher);
6609
6665
  _this.pusher.connection.bind('message', function (event) {
6610
6666
  var eventName = event.event;
6611
6667
  if (eventName === 'pusher:signin_success') {
@@ -6736,7 +6792,7 @@ var pusher_Pusher = (function () {
6736
6792
  this.config = getConfig(options, this);
6737
6793
  this.channels = factory.createChannels();
6738
6794
  this.global_emitter = new dispatcher();
6739
- this.sessionID = Math.floor(Math.random() * 1000000000);
6795
+ this.sessionID = worker_runtime.randomInt(1000000000);
6740
6796
  this.timeline = new timeline_timeline(this.key, this.sessionID, {
6741
6797
  cluster: this.config.cluster,
6742
6798
  features: Pusher.getClientFeatures(),