pusher-js 7.4.0 → 7.4.1

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.4.1
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.4.1",
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 = {
@@ -4334,7 +4343,7 @@ var pusher_Pusher = (function () {
4334
4343
  this.config = getConfig(options, this);
4335
4344
  this.channels = factory.createChannels();
4336
4345
  this.global_emitter = new dispatcher();
4337
- this.sessionID = Math.floor(Math.random() * 1000000000);
4346
+ this.sessionID = worker_runtime.randomInt(1000000000);
4338
4347
  this.timeline = new timeline_timeline(this.key, this.sessionID, {
4339
4348
  cluster: this.config.cluster,
4340
4349
  features: Pusher.getClientFeatures(),