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.
@@ -8,3 +8,7 @@
8
8
  - [ ] All tests are passing.
9
9
  - [ ] New or changed API methods have been documented.
10
10
  - [ ] `npm run format` has been run
11
+
12
+ ## CHANGELOG
13
+
14
+ - [CHANGED] Describe your change here. Look at CHANGELOG.md to see the format.
@@ -19,8 +19,7 @@ jobs:
19
19
  echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20
20
  - uses: actions/checkout@v2
21
21
  with:
22
- repository: pusher/actions
23
- token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
22
+ repository: pusher/public_actions
24
23
  path: .github/actions
25
24
  - uses: ./.github/actions/prepare-version-bump
26
25
  id: bump
@@ -37,6 +36,8 @@ jobs:
37
36
 
38
37
  make build_all
39
38
 
40
- git add package.json CHANGELOG.md dist/
39
+ git status
40
+
41
+ git add package.json package-lock.json CHANGELOG.md dist/ types/
41
42
  git commit -m "Bump to version ${{ steps.bump.outputs.new_version }}"
42
43
  git push
package/CHANGELOG.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.5.0
4
+
5
+ - [ADDED] Watchlist Online Status
6
+
7
+ ## 7.4.1
8
+
9
+ - [CHANGED] Authorization error message.
10
+
3
11
  ## 7.4.0
4
12
 
5
- * [FIXED] Allow presence channel authorization to depend on user authentication
13
+ * [CHANGED] Use secure random generator instead of pseudo-random generator
14
+ * [CHANGED] Replace git protocol with HTTPS in gitsubmodules file
15
+ * [ADDED] Allow presence channel authorization to depend on user authentication
6
16
 
7
17
  ## 7.3.0
8
18
 
9
- * [FIXED] Restore previously exported types
19
+ * [FIXED] Restore previously exported types
10
20
 
11
21
  ## 7.2.0
12
22
 
package/README.md CHANGED
@@ -242,7 +242,7 @@ For more information see [authenticating users](https://pusher.com/docs/channels
242
242
 
243
243
  Object containing the configuration for user authorization. Valid keys are:
244
244
 
245
- * `endpoint` (String) - Endpoint on your server that will return the authorization signature needed for private and presence channels. Defaults to `/pusher/user-auth`.
245
+ * `endpoint` (String) - Endpoint on your server that will return the authorization signature needed for private and presence channels. Defaults to `/pusher/auth`.
246
246
 
247
247
  * `transport` (String) - Defines how the authorization endpoint will be called. There are two options available:
248
248
  * `ajax` - the **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
@@ -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
@@ -369,6 +369,12 @@ module.exports = Base;
369
369
 
370
370
  /***/ }),
371
371
  /* 3 */
372
+ /***/ (function(module, exports) {
373
+
374
+ module.exports = require("crypto");
375
+
376
+ /***/ }),
377
+ /* 4 */
372
378
  /***/ (function(module, exports, __webpack_require__) {
373
379
 
374
380
  "use strict";
@@ -417,17 +423,11 @@ var Driver = {
417
423
  module.exports = Driver;
418
424
 
419
425
 
420
- /***/ }),
421
- /* 4 */
422
- /***/ (function(module, exports) {
423
-
424
- module.exports = require("stream");
425
-
426
426
  /***/ }),
427
427
  /* 5 */
428
428
  /***/ (function(module, exports) {
429
429
 
430
- module.exports = require("crypto");
430
+ module.exports = require("stream");
431
431
 
432
432
  /***/ }),
433
433
  /* 6 */
@@ -943,9 +943,9 @@ module.exports = HttpParser;
943
943
  "use strict";
944
944
 
945
945
 
946
- var Stream = __webpack_require__(4).Stream,
946
+ var Stream = __webpack_require__(5).Stream,
947
947
  util = __webpack_require__(0),
948
- driver = __webpack_require__(3),
948
+ driver = __webpack_require__(4),
949
949
  EventTarget = __webpack_require__(16),
950
950
  Event = __webpack_require__(7);
951
951
 
@@ -1148,7 +1148,7 @@ module.exports = API;
1148
1148
 
1149
1149
 
1150
1150
  var Buffer = __webpack_require__(1).Buffer,
1151
- crypto = __webpack_require__(5),
1151
+ crypto = __webpack_require__(3),
1152
1152
  util = __webpack_require__(0),
1153
1153
  Extensions = __webpack_require__(29),
1154
1154
  Base = __webpack_require__(2),
@@ -2083,7 +2083,7 @@ exports.decode = decode;
2083
2083
 
2084
2084
 
2085
2085
  var util = __webpack_require__(0),
2086
- driver = __webpack_require__(3),
2086
+ driver = __webpack_require__(4),
2087
2087
  API = __webpack_require__(11);
2088
2088
 
2089
2089
  var WebSocket = function(request, socket, body, protocols, options) {
@@ -5132,7 +5132,7 @@ nacl.setPRNG = function(fn) {
5132
5132
  });
5133
5133
  } else if (true) {
5134
5134
  // Node.js.
5135
- crypto = __webpack_require__(5);
5135
+ crypto = __webpack_require__(3);
5136
5136
  if (crypto && crypto.randomBytes) {
5137
5137
  nacl.setPRNG(function(x, n) {
5138
5138
  var i, v = crypto.randomBytes(n);
@@ -5215,7 +5215,7 @@ driver having these two methods.
5215
5215
  **/
5216
5216
 
5217
5217
 
5218
- var Stream = __webpack_require__(4).Stream,
5218
+ var Stream = __webpack_require__(5).Stream,
5219
5219
  util = __webpack_require__(0);
5220
5220
 
5221
5221
 
@@ -5402,7 +5402,7 @@ module.exports = StreamReader;
5402
5402
 
5403
5403
 
5404
5404
  var Buffer = __webpack_require__(1).Buffer,
5405
- crypto = __webpack_require__(5),
5405
+ crypto = __webpack_require__(3),
5406
5406
  url = __webpack_require__(6),
5407
5407
  util = __webpack_require__(0),
5408
5408
  HttpParser = __webpack_require__(10),
@@ -6529,7 +6529,7 @@ module.exports = Message;
6529
6529
 
6530
6530
 
6531
6531
  var Buffer = __webpack_require__(1).Buffer,
6532
- Stream = __webpack_require__(4).Stream,
6532
+ Stream = __webpack_require__(5).Stream,
6533
6533
  url = __webpack_require__(6),
6534
6534
  util = __webpack_require__(0),
6535
6535
  Base = __webpack_require__(2),
@@ -6756,7 +6756,7 @@ module.exports = Server;
6756
6756
  var Buffer = __webpack_require__(1).Buffer,
6757
6757
  Base = __webpack_require__(2),
6758
6758
  Draft75 = __webpack_require__(15),
6759
- crypto = __webpack_require__(5),
6759
+ crypto = __webpack_require__(3),
6760
6760
  util = __webpack_require__(0);
6761
6761
 
6762
6762
 
@@ -6881,7 +6881,7 @@ var util = __webpack_require__(0),
6881
6881
  net = __webpack_require__(40),
6882
6882
  tls = __webpack_require__(41),
6883
6883
  url = __webpack_require__(6),
6884
- driver = __webpack_require__(3),
6884
+ driver = __webpack_require__(4),
6885
6885
  API = __webpack_require__(11),
6886
6886
  Event = __webpack_require__(7);
6887
6887
 
@@ -6986,9 +6986,9 @@ module.exports = require("tls");
6986
6986
  "use strict";
6987
6987
 
6988
6988
 
6989
- var Stream = __webpack_require__(4).Stream,
6989
+ var Stream = __webpack_require__(5).Stream,
6990
6990
  util = __webpack_require__(0),
6991
- driver = __webpack_require__(3),
6991
+ driver = __webpack_require__(4),
6992
6992
  Headers = __webpack_require__(9),
6993
6993
  API = __webpack_require__(11),
6994
6994
  EventTarget = __webpack_require__(16),
@@ -7487,7 +7487,7 @@ function safeJSONStringify(source) {
7487
7487
 
7488
7488
  // CONCATENATED MODULE: ./src/core/defaults.ts
7489
7489
  var Defaults = {
7490
- VERSION: "7.4.0",
7490
+ VERSION: "7.5.0",
7491
7491
  PROTOCOL: 7,
7492
7492
  wsPort: 80,
7493
7493
  wssPort: 443,
@@ -8683,10 +8683,11 @@ var presence_channel_extends = (undefined && undefined.__extends) || (function (
8683
8683
  };
8684
8684
  })();
8685
8685
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
8686
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8686
8687
  return new (P || (P = Promise))(function (resolve, reject) {
8687
8688
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8688
8689
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8689
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
8690
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8690
8691
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8691
8692
  });
8692
8693
  };
@@ -10025,7 +10026,7 @@ function replaceHost(url, hostname) {
10025
10026
  return urlParts[1] + hostname + urlParts[3];
10026
10027
  }
10027
10028
  function randomNumber(max) {
10028
- return Math.floor(Math.random() * max);
10029
+ return node_runtime.randomInt(max);
10029
10030
  }
10030
10031
  function randomString(length) {
10031
10032
  var result = [];
@@ -10255,7 +10256,7 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
10255
10256
  suffix = url_store.buildLogSuffix('authenticationEndpoint');
10256
10257
  break;
10257
10258
  case AuthRequestType.ChannelAuthorization:
10258
- suffix = "Clients must be authenticated to join private or presence channels. " + url_store.buildLogSuffix('authorizationEndpoint');
10259
+ suffix = "Clients must be authorized to join private or presence channels. " + url_store.buildLogSuffix('authorizationEndpoint');
10259
10260
  break;
10260
10261
  }
10261
10262
  callback(new HTTPAuthError(xhr.status, "Unable to retrieve auth string from " + authRequestType.toString() + " endpoint - " +
@@ -10307,6 +10308,9 @@ var xhr_timeline_xhr = {
10307
10308
  };
10308
10309
  /* harmony default export */ var xhr_timeline = (xhr_timeline_xhr);
10309
10310
 
10311
+ // EXTERNAL MODULE: external "crypto"
10312
+ var external_crypto_ = __webpack_require__(3);
10313
+
10310
10314
  // CONCATENATED MODULE: ./src/runtimes/node/runtime.ts
10311
10315
 
10312
10316
 
@@ -10314,6 +10318,7 @@ var xhr_timeline_xhr = {
10314
10318
 
10315
10319
 
10316
10320
 
10321
+
10317
10322
  var runtime_getDefaultStrategy = runtime.getDefaultStrategy, runtime_Transports = runtime.Transports, setup = runtime.setup, getProtocol = runtime.getProtocol, isXHRSupported = runtime.isXHRSupported, getLocalStorage = runtime.getLocalStorage, createXHR = runtime.createXHR, createWebSocket = runtime.createWebSocket, addUnloadListener = runtime.addUnloadListener, removeUnloadListener = runtime.removeUnloadListener, transportConnectionInitializer = runtime.transportConnectionInitializer, createSocketRequest = runtime.createSocketRequest, HTTPFactory = runtime.HTTPFactory;
10318
10323
  var NodeJS = {
10319
10324
  getDefaultStrategy: runtime_getDefaultStrategy,
@@ -10341,6 +10346,9 @@ var NodeJS = {
10341
10346
  },
10342
10347
  getNetwork: function () {
10343
10348
  return net_info_Network;
10349
+ },
10350
+ randomInt: function (max) {
10351
+ return Object(external_crypto_["randomInt"])(max);
10344
10352
  }
10345
10353
  };
10346
10354
  /* harmony default export */ var node_runtime = (NodeJS);
@@ -10720,7 +10728,7 @@ function getEnableStatsConfig(opts) {
10720
10728
  return false;
10721
10729
  }
10722
10730
  function buildUserAuthenticator(opts) {
10723
- var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);
10731
+ var userAuthentication = __assign(__assign({}, defaults.userAuthentication), opts.userAuthentication);
10724
10732
  if ('customHandler' in userAuthentication &&
10725
10733
  userAuthentication['customHandler'] != null) {
10726
10734
  return userAuthentication['customHandler'];
@@ -10730,7 +10738,7 @@ function buildUserAuthenticator(opts) {
10730
10738
  function buildChannelAuth(opts, pusher) {
10731
10739
  var channelAuthorization;
10732
10740
  if ('channelAuthorization' in opts) {
10733
- channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);
10741
+ channelAuthorization = __assign(__assign({}, defaults.channelAuthorization), opts.channelAuthorization);
10734
10742
  }
10735
10743
  else {
10736
10744
  channelAuthorization = {
@@ -10757,6 +10765,51 @@ function buildChannelAuthorizer(opts, pusher) {
10757
10765
  return channel_authorizer(channelAuthorization);
10758
10766
  }
10759
10767
 
10768
+ // CONCATENATED MODULE: ./src/core/watchlist.ts
10769
+ var watchlist_extends = (undefined && undefined.__extends) || (function () {
10770
+ var extendStatics = function (d, b) {
10771
+ extendStatics = Object.setPrototypeOf ||
10772
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10773
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10774
+ return extendStatics(d, b);
10775
+ };
10776
+ return function (d, b) {
10777
+ extendStatics(d, b);
10778
+ function __() { this.constructor = d; }
10779
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10780
+ };
10781
+ })();
10782
+
10783
+
10784
+ var watchlist_WatchlistFacade = (function (_super) {
10785
+ watchlist_extends(WatchlistFacade, _super);
10786
+ function WatchlistFacade(pusher) {
10787
+ var _this = _super.call(this, function (eventName, data) {
10788
+ logger.debug("No callbacks on watchlist events for " + eventName);
10789
+ }) || this;
10790
+ _this.pusher = pusher;
10791
+ _this.bindWatchlistInternalEvent();
10792
+ return _this;
10793
+ }
10794
+ WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
10795
+ var _this = this;
10796
+ pusherEvent.data.events.forEach(function (watchlistEvent) {
10797
+ _this.emit(watchlistEvent.name, watchlistEvent);
10798
+ });
10799
+ };
10800
+ WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
10801
+ var _this = this;
10802
+ this.pusher.connection.bind('message', function (pusherEvent) {
10803
+ var eventName = pusherEvent.event;
10804
+ if (eventName === 'pusher_internal:watchlist_events') {
10805
+ _this.handleEvent(pusherEvent);
10806
+ }
10807
+ });
10808
+ };
10809
+ return WatchlistFacade;
10810
+ }(dispatcher));
10811
+ /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
10812
+
10760
10813
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
10761
10814
  function flatPromise() {
10762
10815
  var resolve, reject;
@@ -10786,6 +10839,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
10786
10839
 
10787
10840
 
10788
10841
 
10842
+
10789
10843
  var user_UserFacade = (function (_super) {
10790
10844
  user_extends(UserFacade, _super);
10791
10845
  function UserFacade(pusher) {
@@ -10819,6 +10873,7 @@ var user_UserFacade = (function (_super) {
10819
10873
  _this._newSigninPromiseIfNeeded();
10820
10874
  }
10821
10875
  });
10876
+ _this.watchlist = new watchlist(pusher);
10822
10877
  _this.pusher.connection.bind('message', function (event) {
10823
10878
  var eventName = event.event;
10824
10879
  if (eventName === 'pusher:signin_success') {
@@ -10949,7 +11004,7 @@ var pusher_Pusher = (function () {
10949
11004
  this.config = getConfig(options, this);
10950
11005
  this.channels = factory.createChannels();
10951
11006
  this.global_emitter = new dispatcher();
10952
- this.sessionID = Math.floor(Math.random() * 1000000000);
11007
+ this.sessionID = node_runtime.randomInt(1000000000);
10953
11008
  this.timeline = new timeline_timeline(this.key, this.sessionID, {
10954
11009
  cluster: this.config.cluster,
10955
11010
  features: Pusher.getClientFeatures(),