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
@@ -2995,7 +2995,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip
2995
2995
 
2996
2996
  // CONCATENATED MODULE: ./src/core/defaults.ts
2997
2997
  var Defaults = {
2998
- VERSION: "7.4.1",
2998
+ VERSION: "7.6.0",
2999
2999
  PROTOCOL: 7,
3000
3000
  wsPort: 80,
3001
3001
  wssPort: 443,
@@ -3264,6 +3264,12 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
3264
3264
  for (var headerName in authOptions.headers) {
3265
3265
  xhr.setRequestHeader(headerName, authOptions.headers[headerName]);
3266
3266
  }
3267
+ if (authOptions.headersProvider != null) {
3268
+ var dynamicHeaders = authOptions.headersProvider();
3269
+ for (var headerName in dynamicHeaders) {
3270
+ xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);
3271
+ }
3272
+ }
3267
3273
  xhr.onreadystatechange = function () {
3268
3274
  if (xhr.readyState === 4) {
3269
3275
  if (xhr.status === 200) {
@@ -3703,7 +3709,8 @@ var logger_Logger = (function () {
3703
3709
  // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
3704
3710
 
3705
3711
  var jsonp = function (context, query, authOptions, authRequestType, callback) {
3706
- if (authOptions.headers !== undefined) {
3712
+ if (authOptions.headers !== undefined ||
3713
+ authOptions.headersProvider != null) {
3707
3714
  logger.warn("To send headers with the " + authRequestType.toString() + " request, you must use AJAX, rather than JSONP.");
3708
3715
  }
3709
3716
  var callbackName = context.nextAuthCallbackID.toString();
@@ -6758,12 +6765,22 @@ var strategy_builder_UnsupportedStrategy = {
6758
6765
 
6759
6766
  var composeChannelQuery = function (params, authOptions) {
6760
6767
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
6761
- for (var i in authOptions.params) {
6768
+ for (var key in authOptions.params) {
6762
6769
  query +=
6763
6770
  '&' +
6764
- encodeURIComponent(i) +
6771
+ encodeURIComponent(key) +
6765
6772
  '=' +
6766
- encodeURIComponent(authOptions.params[i]);
6773
+ encodeURIComponent(authOptions.params[key]);
6774
+ }
6775
+ if (authOptions.paramsProvider != null) {
6776
+ var dynamicParams = authOptions.paramsProvider();
6777
+ for (var key in dynamicParams) {
6778
+ query +=
6779
+ '&' +
6780
+ encodeURIComponent(key) +
6781
+ '=' +
6782
+ encodeURIComponent(dynamicParams[key]);
6783
+ }
6767
6784
  }
6768
6785
  return query;
6769
6786
  };
@@ -6784,12 +6801,22 @@ var UserAuthenticator = function (authOptions) {
6784
6801
  var channel_authorizer_composeChannelQuery = function (params, authOptions) {
6785
6802
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
6786
6803
  query += '&channel_name=' + encodeURIComponent(params.channelName);
6787
- for (var i in authOptions.params) {
6804
+ for (var key in authOptions.params) {
6788
6805
  query +=
6789
6806
  '&' +
6790
- encodeURIComponent(i) +
6807
+ encodeURIComponent(key) +
6791
6808
  '=' +
6792
- encodeURIComponent(authOptions.params[i]);
6809
+ encodeURIComponent(authOptions.params[key]);
6810
+ }
6811
+ if (authOptions.paramsProvider != null) {
6812
+ var dynamicParams = authOptions.paramsProvider();
6813
+ for (var key in dynamicParams) {
6814
+ query +=
6815
+ '&' +
6816
+ encodeURIComponent(key) +
6817
+ '=' +
6818
+ encodeURIComponent(dynamicParams[key]);
6819
+ }
6793
6820
  }
6794
6821
  return query;
6795
6822
  };
@@ -6948,6 +6975,51 @@ function buildChannelAuthorizer(opts, pusher) {
6948
6975
  return channel_authorizer(channelAuthorization);
6949
6976
  }
6950
6977
 
6978
+ // CONCATENATED MODULE: ./src/core/watchlist.ts
6979
+ var watchlist_extends = (undefined && undefined.__extends) || (function () {
6980
+ var extendStatics = function (d, b) {
6981
+ extendStatics = Object.setPrototypeOf ||
6982
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6983
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6984
+ return extendStatics(d, b);
6985
+ };
6986
+ return function (d, b) {
6987
+ extendStatics(d, b);
6988
+ function __() { this.constructor = d; }
6989
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6990
+ };
6991
+ })();
6992
+
6993
+
6994
+ var watchlist_WatchlistFacade = (function (_super) {
6995
+ watchlist_extends(WatchlistFacade, _super);
6996
+ function WatchlistFacade(pusher) {
6997
+ var _this = _super.call(this, function (eventName, data) {
6998
+ logger.debug("No callbacks on watchlist events for " + eventName);
6999
+ }) || this;
7000
+ _this.pusher = pusher;
7001
+ _this.bindWatchlistInternalEvent();
7002
+ return _this;
7003
+ }
7004
+ WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
7005
+ var _this = this;
7006
+ pusherEvent.data.events.forEach(function (watchlistEvent) {
7007
+ _this.emit(watchlistEvent.name, watchlistEvent);
7008
+ });
7009
+ };
7010
+ WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
7011
+ var _this = this;
7012
+ this.pusher.connection.bind('message', function (pusherEvent) {
7013
+ var eventName = pusherEvent.event;
7014
+ if (eventName === 'pusher_internal:watchlist_events') {
7015
+ _this.handleEvent(pusherEvent);
7016
+ }
7017
+ });
7018
+ };
7019
+ return WatchlistFacade;
7020
+ }(dispatcher));
7021
+ /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
7022
+
6951
7023
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
6952
7024
  function flatPromise() {
6953
7025
  var resolve, reject;
@@ -6977,6 +7049,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
6977
7049
 
6978
7050
 
6979
7051
 
7052
+
6980
7053
  var user_UserFacade = (function (_super) {
6981
7054
  user_extends(UserFacade, _super);
6982
7055
  function UserFacade(pusher) {
@@ -7010,6 +7083,7 @@ var user_UserFacade = (function (_super) {
7010
7083
  _this._newSigninPromiseIfNeeded();
7011
7084
  }
7012
7085
  });
7086
+ _this.watchlist = new watchlist(pusher);
7013
7087
  _this.pusher.connection.bind('message', function (event) {
7014
7088
  var eventName = event.event;
7015
7089
  if (eventName === 'pusher:signin_success') {