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
@@ -593,7 +593,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip
593
593
 
594
594
  // CONCATENATED MODULE: ./src/core/defaults.ts
595
595
  var Defaults = {
596
- VERSION: "7.4.0",
596
+ VERSION: "7.4.1",
597
597
  PROTOCOL: 7,
598
598
  wsPort: 80,
599
599
  wssPort: 443,
@@ -885,7 +885,7 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
885
885
  suffix = url_store.buildLogSuffix('authenticationEndpoint');
886
886
  break;
887
887
  case AuthRequestType.ChannelAuthorization:
888
- suffix = "Clients must be authenticated to join private or presence channels. " + url_store.buildLogSuffix('authorizationEndpoint');
888
+ suffix = "Clients must be authorized to join private or presence channels. " + url_store.buildLogSuffix('authorizationEndpoint');
889
889
  break;
890
890
  }
891
891
  callback(new HTTPAuthError(xhr.status, "Unable to retrieve auth string from " + authRequestType.toString() + " endpoint - " +
@@ -2474,10 +2474,11 @@ var presence_channel_extends = (undefined && undefined.__extends) || (function (
2474
2474
  };
2475
2475
  })();
2476
2476
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2477
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2477
2478
  return new (P || (P = Promise))(function (resolve, reject) {
2478
2479
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2479
2480
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2480
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2481
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2481
2482
  step((generator = generator.apply(thisArg, _arguments || [])).next());
2482
2483
  });
2483
2484
  };
@@ -3875,7 +3876,7 @@ function replaceHost(url, hostname) {
3875
3876
  return urlParts[1] + hostname + urlParts[3];
3876
3877
  }
3877
3878
  function randomNumber(max) {
3878
- return Math.floor(Math.random() * max);
3879
+ return runtime.randomInt(max);
3879
3880
  }
3880
3881
  function randomString(length) {
3881
3882
  var result = [];
@@ -4121,6 +4122,14 @@ var Runtime = {
4121
4122
  else if (window.detachEvent !== undefined) {
4122
4123
  window.detachEvent('onunload', listener);
4123
4124
  }
4125
+ },
4126
+ randomInt: function (max) {
4127
+ var random = function () {
4128
+ var crypto = window.crypto || window['msCrypto'];
4129
+ var random = crypto.getRandomValues(new Uint32Array(1))[0];
4130
+ return random / Math.pow(2, 32);
4131
+ };
4132
+ return Math.floor(random() * max);
4124
4133
  }
4125
4134
  };
4126
4135
  /* harmony default export */ var runtime = (Runtime);
@@ -4500,7 +4509,7 @@ function getEnableStatsConfig(opts) {
4500
4509
  return false;
4501
4510
  }
4502
4511
  function buildUserAuthenticator(opts) {
4503
- var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);
4512
+ var userAuthentication = __assign(__assign({}, defaults.userAuthentication), opts.userAuthentication);
4504
4513
  if ('customHandler' in userAuthentication &&
4505
4514
  userAuthentication['customHandler'] != null) {
4506
4515
  return userAuthentication['customHandler'];
@@ -4510,7 +4519,7 @@ function buildUserAuthenticator(opts) {
4510
4519
  function buildChannelAuth(opts, pusher) {
4511
4520
  var channelAuthorization;
4512
4521
  if ('channelAuthorization' in opts) {
4513
- channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);
4522
+ channelAuthorization = __assign(__assign({}, defaults.channelAuthorization), opts.channelAuthorization);
4514
4523
  }
4515
4524
  else {
4516
4525
  channelAuthorization = {
@@ -4729,7 +4738,7 @@ var pusher_Pusher = (function () {
4729
4738
  this.config = getConfig(options, this);
4730
4739
  this.channels = factory.createChannels();
4731
4740
  this.global_emitter = new dispatcher();
4732
- this.sessionID = Math.floor(Math.random() * 1000000000);
4741
+ this.sessionID = runtime.randomInt(1000000000);
4733
4742
  this.timeline = new timeline_timeline(this.key, this.sessionID, {
4734
4743
  cluster: this.config.cluster,
4735
4744
  features: Pusher.getClientFeatures(),