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
@@ -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.1",
900
+ VERSION: "7.6.0",
901
901
  PROTOCOL: 7,
902
902
  wsPort: 80,
903
903
  wssPort: 443,
@@ -3626,6 +3626,12 @@ var fetchAuth = function (context, query, authOptions, authRequestType, callback
3626
3626
  for (var headerName in authOptions.headers) {
3627
3627
  headers.set(headerName, authOptions.headers[headerName]);
3628
3628
  }
3629
+ if (authOptions.headersProvider != null) {
3630
+ var dynamicHeaders = authOptions.headersProvider();
3631
+ for (var headerName in dynamicHeaders) {
3632
+ headers.set(headerName, dynamicHeaders[headerName]);
3633
+ }
3634
+ }
3629
3635
  var body = query;
3630
3636
  var request = new Request(authOptions.endpoint, {
3631
3637
  headers: headers,
@@ -3961,12 +3967,22 @@ var AuthRequestType;
3961
3967
 
3962
3968
  var composeChannelQuery = function (params, authOptions) {
3963
3969
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
3964
- for (var i in authOptions.params) {
3970
+ for (var key in authOptions.params) {
3965
3971
  query +=
3966
3972
  '&' +
3967
- encodeURIComponent(i) +
3973
+ encodeURIComponent(key) +
3968
3974
  '=' +
3969
- encodeURIComponent(authOptions.params[i]);
3975
+ encodeURIComponent(authOptions.params[key]);
3976
+ }
3977
+ if (authOptions.paramsProvider != null) {
3978
+ var dynamicParams = authOptions.paramsProvider();
3979
+ for (var key in dynamicParams) {
3980
+ query +=
3981
+ '&' +
3982
+ encodeURIComponent(key) +
3983
+ '=' +
3984
+ encodeURIComponent(dynamicParams[key]);
3985
+ }
3970
3986
  }
3971
3987
  return query;
3972
3988
  };
@@ -3987,12 +4003,22 @@ var UserAuthenticator = function (authOptions) {
3987
4003
  var channel_authorizer_composeChannelQuery = function (params, authOptions) {
3988
4004
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
3989
4005
  query += '&channel_name=' + encodeURIComponent(params.channelName);
3990
- for (var i in authOptions.params) {
4006
+ for (var key in authOptions.params) {
3991
4007
  query +=
3992
4008
  '&' +
3993
- encodeURIComponent(i) +
4009
+ encodeURIComponent(key) +
3994
4010
  '=' +
3995
- encodeURIComponent(authOptions.params[i]);
4011
+ encodeURIComponent(authOptions.params[key]);
4012
+ }
4013
+ if (authOptions.paramsProvider != null) {
4014
+ var dynamicParams = authOptions.paramsProvider();
4015
+ for (var key in dynamicParams) {
4016
+ query +=
4017
+ '&' +
4018
+ encodeURIComponent(key) +
4019
+ '=' +
4020
+ encodeURIComponent(dynamicParams[key]);
4021
+ }
3996
4022
  }
3997
4023
  return query;
3998
4024
  };
@@ -4151,6 +4177,51 @@ function buildChannelAuthorizer(opts, pusher) {
4151
4177
  return channel_authorizer(channelAuthorization);
4152
4178
  }
4153
4179
 
4180
+ // CONCATENATED MODULE: ./src/core/watchlist.ts
4181
+ var watchlist_extends = (undefined && undefined.__extends) || (function () {
4182
+ var extendStatics = function (d, b) {
4183
+ extendStatics = Object.setPrototypeOf ||
4184
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4185
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4186
+ return extendStatics(d, b);
4187
+ };
4188
+ return function (d, b) {
4189
+ extendStatics(d, b);
4190
+ function __() { this.constructor = d; }
4191
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4192
+ };
4193
+ })();
4194
+
4195
+
4196
+ var watchlist_WatchlistFacade = (function (_super) {
4197
+ watchlist_extends(WatchlistFacade, _super);
4198
+ function WatchlistFacade(pusher) {
4199
+ var _this = _super.call(this, function (eventName, data) {
4200
+ logger.debug("No callbacks on watchlist events for " + eventName);
4201
+ }) || this;
4202
+ _this.pusher = pusher;
4203
+ _this.bindWatchlistInternalEvent();
4204
+ return _this;
4205
+ }
4206
+ WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
4207
+ var _this = this;
4208
+ pusherEvent.data.events.forEach(function (watchlistEvent) {
4209
+ _this.emit(watchlistEvent.name, watchlistEvent);
4210
+ });
4211
+ };
4212
+ WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
4213
+ var _this = this;
4214
+ this.pusher.connection.bind('message', function (pusherEvent) {
4215
+ var eventName = pusherEvent.event;
4216
+ if (eventName === 'pusher_internal:watchlist_events') {
4217
+ _this.handleEvent(pusherEvent);
4218
+ }
4219
+ });
4220
+ };
4221
+ return WatchlistFacade;
4222
+ }(dispatcher));
4223
+ /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
4224
+
4154
4225
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
4155
4226
  function flatPromise() {
4156
4227
  var resolve, reject;
@@ -4180,6 +4251,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
4180
4251
 
4181
4252
 
4182
4253
 
4254
+
4183
4255
  var user_UserFacade = (function (_super) {
4184
4256
  user_extends(UserFacade, _super);
4185
4257
  function UserFacade(pusher) {
@@ -4213,6 +4285,7 @@ var user_UserFacade = (function (_super) {
4213
4285
  _this._newSigninPromiseIfNeeded();
4214
4286
  }
4215
4287
  });
4288
+ _this.watchlist = new watchlist(pusher);
4216
4289
  _this.pusher.connection.bind('message', function (event) {
4217
4290
  var eventName = event.event;
4218
4291
  if (eventName === 'pusher:signin_success') {