pusher-js 7.4.1 → 7.6.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.
Files changed (57) hide show
  1. package/.github/workflows/release_pr.yml +3 -1
  2. package/.github/workflows/run-tests.yml +27 -3
  3. package/CHANGELOG.md +8 -0
  4. package/Makefile +1 -0
  5. package/README.md +11 -3
  6. package/dist/node/pusher.js +139 -28
  7. package/dist/node/pusher.js.map +1 -1
  8. package/dist/react-native/pusher.js +5 -5
  9. package/dist/react-native/pusher.js.map +1 -1
  10. package/dist/web/pusher-with-encryption.js +83 -9
  11. package/dist/web/pusher-with-encryption.js.map +1 -1
  12. package/dist/web/pusher-with-encryption.min.js +2 -2
  13. package/dist/web/pusher-with-encryption.min.js.map +1 -1
  14. package/dist/web/pusher.js +83 -9
  15. package/dist/web/pusher.js.map +1 -1
  16. package/dist/web/pusher.min.js +2 -2
  17. package/dist/web/pusher.min.js.map +1 -1
  18. package/dist/worker/pusher-with-encryption.worker.js +81 -8
  19. package/dist/worker/pusher-with-encryption.worker.js.map +1 -1
  20. package/dist/worker/pusher-with-encryption.worker.min.js +2 -2
  21. package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -1
  22. package/dist/worker/pusher.worker.js +81 -8
  23. package/dist/worker/pusher.worker.js.map +1 -1
  24. package/dist/worker/pusher.worker.min.js +2 -2
  25. package/dist/worker/pusher.worker.min.js.map +1 -1
  26. package/integration_tests_server/index.js +176 -0
  27. package/integration_tests_server/package-lock.json +1177 -0
  28. package/integration_tests_server/package.json +15 -0
  29. package/package.json +6 -5
  30. package/spec/config/karma/config.common.js +1 -2
  31. package/spec/javascripts/helpers/node/integration.js +2 -2
  32. package/spec/javascripts/helpers/web/integration.js +2 -2
  33. package/spec/javascripts/integration/core/cluster_config_spec.js +1 -1
  34. package/spec/javascripts/integration/core/pusher_spec/test_builder.js +13 -43
  35. package/spec/javascripts/integration/web/dom/jsonp_spec.js +2 -2
  36. package/spec/javascripts/unit/core/config_spec.js +91 -3
  37. package/spec/javascripts/unit/core/connection/connection_manager_spec.js +11 -1
  38. package/spec/javascripts/unit/core/http/http_request_spec.js +0 -6
  39. package/spec/javascripts/unit/core/transports/transport_connection_spec.js +5 -0
  40. package/spec/javascripts/unit/core/utils/timers_spec.js +0 -4
  41. package/spec/javascripts/unit/core/watchlist_spec.js +48 -0
  42. package/spec/javascripts/unit/core_with_runtime/auth/channel_authorizer_spec.js +82 -0
  43. package/spec/javascripts/unit/core_with_runtime/auth/user_authorizer_spec.js +76 -0
  44. package/spec/javascripts/unit/web/pusher_authorizer_spec.js +28 -0
  45. package/spec/javascripts/unit/worker/channel_authorizer_spec.js +46 -0
  46. package/src/core/auth/channel_authorizer.ts +14 -3
  47. package/src/core/auth/options.ts +4 -0
  48. package/src/core/auth/user_authenticator.ts +14 -3
  49. package/src/core/pusher.ts +0 -1
  50. package/src/core/user.ts +5 -0
  51. package/src/core/watchlist.ts +31 -0
  52. package/src/runtimes/isomorphic/auth/xhr_auth.ts +6 -0
  53. package/src/runtimes/web/auth/jsonp_auth.ts +4 -1
  54. package/src/runtimes/worker/auth/fetch_auth.ts +7 -0
  55. package/types/src/core/auth/options.d.ts +4 -0
  56. package/types/src/core/user.d.ts +2 -0
  57. package/types/src/core/watchlist.d.ts +8 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v7.4.1
2
+ * Pusher JavaScript Library v7.6.0
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.1",
596
+ VERSION: "7.6.0",
597
597
  PROTOCOL: 7,
598
598
  wsPort: 80,
599
599
  wssPort: 443,
@@ -862,6 +862,12 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
862
862
  for (var headerName in authOptions.headers) {
863
863
  xhr.setRequestHeader(headerName, authOptions.headers[headerName]);
864
864
  }
865
+ if (authOptions.headersProvider != null) {
866
+ var dynamicHeaders = authOptions.headersProvider();
867
+ for (var headerName in dynamicHeaders) {
868
+ xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);
869
+ }
870
+ }
865
871
  xhr.onreadystatechange = function () {
866
872
  if (xhr.readyState === 4) {
867
873
  if (xhr.status === 200) {
@@ -1301,7 +1307,8 @@ var logger_Logger = (function () {
1301
1307
  // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
1302
1308
 
1303
1309
  var jsonp = function (context, query, authOptions, authRequestType, callback) {
1304
- if (authOptions.headers !== undefined) {
1310
+ if (authOptions.headers !== undefined ||
1311
+ authOptions.headersProvider != null) {
1305
1312
  logger.warn("To send headers with the " + authRequestType.toString() + " request, you must use AJAX, rather than JSONP.");
1306
1313
  }
1307
1314
  var callbackName = context.nextAuthCallbackID.toString();
@@ -4356,12 +4363,22 @@ var strategy_builder_UnsupportedStrategy = {
4356
4363
 
4357
4364
  var composeChannelQuery = function (params, authOptions) {
4358
4365
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
4359
- for (var i in authOptions.params) {
4366
+ for (var key in authOptions.params) {
4360
4367
  query +=
4361
4368
  '&' +
4362
- encodeURIComponent(i) +
4369
+ encodeURIComponent(key) +
4363
4370
  '=' +
4364
- encodeURIComponent(authOptions.params[i]);
4371
+ encodeURIComponent(authOptions.params[key]);
4372
+ }
4373
+ if (authOptions.paramsProvider != null) {
4374
+ var dynamicParams = authOptions.paramsProvider();
4375
+ for (var key in dynamicParams) {
4376
+ query +=
4377
+ '&' +
4378
+ encodeURIComponent(key) +
4379
+ '=' +
4380
+ encodeURIComponent(dynamicParams[key]);
4381
+ }
4365
4382
  }
4366
4383
  return query;
4367
4384
  };
@@ -4382,12 +4399,22 @@ var UserAuthenticator = function (authOptions) {
4382
4399
  var channel_authorizer_composeChannelQuery = function (params, authOptions) {
4383
4400
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
4384
4401
  query += '&channel_name=' + encodeURIComponent(params.channelName);
4385
- for (var i in authOptions.params) {
4402
+ for (var key in authOptions.params) {
4386
4403
  query +=
4387
4404
  '&' +
4388
- encodeURIComponent(i) +
4405
+ encodeURIComponent(key) +
4389
4406
  '=' +
4390
- encodeURIComponent(authOptions.params[i]);
4407
+ encodeURIComponent(authOptions.params[key]);
4408
+ }
4409
+ if (authOptions.paramsProvider != null) {
4410
+ var dynamicParams = authOptions.paramsProvider();
4411
+ for (var key in dynamicParams) {
4412
+ query +=
4413
+ '&' +
4414
+ encodeURIComponent(key) +
4415
+ '=' +
4416
+ encodeURIComponent(dynamicParams[key]);
4417
+ }
4391
4418
  }
4392
4419
  return query;
4393
4420
  };
@@ -4546,6 +4573,51 @@ function buildChannelAuthorizer(opts, pusher) {
4546
4573
  return channel_authorizer(channelAuthorization);
4547
4574
  }
4548
4575
 
4576
+ // CONCATENATED MODULE: ./src/core/watchlist.ts
4577
+ var watchlist_extends = (undefined && undefined.__extends) || (function () {
4578
+ var extendStatics = function (d, b) {
4579
+ extendStatics = Object.setPrototypeOf ||
4580
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4581
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4582
+ return extendStatics(d, b);
4583
+ };
4584
+ return function (d, b) {
4585
+ extendStatics(d, b);
4586
+ function __() { this.constructor = d; }
4587
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4588
+ };
4589
+ })();
4590
+
4591
+
4592
+ var watchlist_WatchlistFacade = (function (_super) {
4593
+ watchlist_extends(WatchlistFacade, _super);
4594
+ function WatchlistFacade(pusher) {
4595
+ var _this = _super.call(this, function (eventName, data) {
4596
+ logger.debug("No callbacks on watchlist events for " + eventName);
4597
+ }) || this;
4598
+ _this.pusher = pusher;
4599
+ _this.bindWatchlistInternalEvent();
4600
+ return _this;
4601
+ }
4602
+ WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
4603
+ var _this = this;
4604
+ pusherEvent.data.events.forEach(function (watchlistEvent) {
4605
+ _this.emit(watchlistEvent.name, watchlistEvent);
4606
+ });
4607
+ };
4608
+ WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
4609
+ var _this = this;
4610
+ this.pusher.connection.bind('message', function (pusherEvent) {
4611
+ var eventName = pusherEvent.event;
4612
+ if (eventName === 'pusher_internal:watchlist_events') {
4613
+ _this.handleEvent(pusherEvent);
4614
+ }
4615
+ });
4616
+ };
4617
+ return WatchlistFacade;
4618
+ }(dispatcher));
4619
+ /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
4620
+
4549
4621
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
4550
4622
  function flatPromise() {
4551
4623
  var resolve, reject;
@@ -4575,6 +4647,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
4575
4647
 
4576
4648
 
4577
4649
 
4650
+
4578
4651
  var user_UserFacade = (function (_super) {
4579
4652
  user_extends(UserFacade, _super);
4580
4653
  function UserFacade(pusher) {
@@ -4608,6 +4681,7 @@ var user_UserFacade = (function (_super) {
4608
4681
  _this._newSigninPromiseIfNeeded();
4609
4682
  }
4610
4683
  });
4684
+ _this.watchlist = new watchlist(pusher);
4611
4685
  _this.pusher.connection.bind('message', function (event) {
4612
4686
  var eventName = event.event;
4613
4687
  if (eventName === 'pusher:signin_success') {