pusher-js 7.3.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.
- package/.github/PULL_REQUEST_TEMPLATE.md +4 -0
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/release_pr.yml +2 -3
- package/.github/workflows/run-tests.yml +2 -2
- package/.gitmodules +1 -1
- package/CHANGELOG.md +11 -1
- package/README.md +11 -31
- package/dist/node/pusher.js +159 -61
- package/dist/node/pusher.js.map +1 -1
- package/dist/react-native/pusher.js +13 -2
- package/dist/react-native/pusher.js.map +1 -1
- package/dist/web/pusher-with-encryption.js +141 -42
- package/dist/web/pusher-with-encryption.js.map +1 -1
- package/dist/web/pusher-with-encryption.min.js +2 -2
- package/dist/web/pusher-with-encryption.min.js.map +1 -1
- package/dist/web/pusher.js +141 -42
- package/dist/web/pusher.js.map +1 -1
- package/dist/web/pusher.min.js +2 -2
- package/dist/web/pusher.min.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.js +140 -41
- package/dist/worker/pusher-with-encryption.worker.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.min.js +2 -2
- package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -1
- package/dist/worker/pusher.worker.js +140 -41
- package/dist/worker/pusher.worker.js.map +1 -1
- package/dist/worker/pusher.worker.min.js +2 -2
- package/dist/worker/pusher.worker.min.js.map +1 -1
- package/package.json +5 -4
- package/spec/javascripts/helpers/timers/promises.js +9 -0
- package/spec/javascripts/unit/core/channels/presence_channel_spec.js +85 -16
- package/spec/javascripts/unit/core/user_spec.js +13 -6
- package/src/core/channels/presence_channel.ts +21 -12
- package/src/core/http/http_socket.ts +3 -1
- package/src/core/pusher.ts +1 -1
- package/src/core/user.ts +65 -27
- package/src/core/utils/flat_promise.ts +10 -0
- package/src/runtimes/interface.ts +1 -0
- package/src/runtimes/isomorphic/auth/xhr_auth.ts +1 -1
- package/src/runtimes/node/runtime.ts +5 -0
- package/src/runtimes/react-native/runtime.ts +5 -0
- package/src/runtimes/web/runtime.ts +14 -0
- package/src/runtimes/worker/runtime.ts +14 -0
- package/types/src/core/strategies/transport_strategy.d.ts +3 -0
- package/types/src/core/user.d.ts +5 -1
- package/types/src/core/utils/flat_promise.d.ts +6 -0
- package/types/src/runtimes/interface.d.ts +1 -0
|
@@ -71,7 +71,7 @@ jobs:
|
|
|
71
71
|
- uses: actions/setup-node@v2
|
|
72
72
|
if: ${{ steps.is-published.outputs.published == 'false' }}
|
|
73
73
|
with:
|
|
74
|
-
node-version: '
|
|
74
|
+
node-version: '16'
|
|
75
75
|
registry-url: https://registry.npmjs.org/
|
|
76
76
|
- run: npm install
|
|
77
77
|
if: ${{ steps.is-published.outputs.published == 'false' }}
|
|
@@ -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/
|
|
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
|
|
@@ -28,7 +27,7 @@ jobs:
|
|
|
28
27
|
current_version: ${{ env.CURRENT_VERSION }}
|
|
29
28
|
- uses: actions/setup-node@v2
|
|
30
29
|
with:
|
|
31
|
-
node-version: '
|
|
30
|
+
node-version: '16'
|
|
32
31
|
- run: npm install
|
|
33
32
|
- name: Push
|
|
34
33
|
shell: bash
|
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
- uses: actions/checkout@v2
|
|
17
17
|
- uses: actions/setup-node@v2
|
|
18
18
|
with:
|
|
19
|
-
node-version: '
|
|
19
|
+
node-version: '16'
|
|
20
20
|
- run: npm install
|
|
21
21
|
- run: npm run check-format
|
|
22
22
|
- run: make web_unit
|
|
@@ -30,7 +30,7 @@ jobs:
|
|
|
30
30
|
- uses: actions/checkout@v2
|
|
31
31
|
- uses: actions/setup-node@v2
|
|
32
32
|
with:
|
|
33
|
-
node-version: '
|
|
33
|
+
node-version: '16'
|
|
34
34
|
- run: npm install
|
|
35
35
|
- run: npm run check-format
|
|
36
36
|
- run: make node_unit
|
package/.gitmodules
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 7.4.1
|
|
4
|
+
|
|
5
|
+
- [CHANGED] Authorization error message.
|
|
6
|
+
|
|
7
|
+
## 7.4.0
|
|
8
|
+
|
|
9
|
+
* [CHANGED] Use secure random generator instead of pseudo-random generator
|
|
10
|
+
* [CHANGED] Replace git protocol with HTTPS in gitsubmodules file
|
|
11
|
+
* [ADDED] Allow presence channel authorization to depend on user authentication
|
|
12
|
+
|
|
3
13
|
## 7.3.0
|
|
4
14
|
|
|
5
|
-
* [FIXED] Restore previously exported types
|
|
15
|
+
* [FIXED] Restore previously exported types
|
|
6
16
|
|
|
7
17
|
## 7.2.0
|
|
8
18
|
|
package/README.md
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
This Pusher Channels client library supports web browsers, web workers
|
|
6
|
-
and React Native.
|
|
5
|
+
This Pusher Channels client library supports web browsers, web workers and Node.js
|
|
7
6
|
|
|
8
7
|
If you're looking for the Pusher Channels server library for Node.js, use
|
|
9
8
|
[pusher-http-node](https://github.com/pusher/pusher-http-node) instead.
|
|
@@ -145,29 +144,11 @@ var presenceChannel: PusherTypes.PresenceChannel;
|
|
|
145
144
|
|
|
146
145
|
### React Native
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
[@react-native-community/netinfo](https://github.com/react-native-community/react-native-netinfo)
|
|
154
|
-
library. Please follow the [install
|
|
155
|
-
instructions](https://github.com/react-native-community/react-native-netinfo#getting-started)
|
|
156
|
-
for the
|
|
157
|
-
[@react-native-community/netinfo](https://github.com/react-native-community/react-native-netinfo)
|
|
158
|
-
library before trying to use pusher-js in your react-native project.
|
|
159
|
-
|
|
160
|
-
Use a package manager like Yarn or NPM to install `pusher-js` and then import
|
|
161
|
-
it as follows:
|
|
162
|
-
|
|
163
|
-
```javascript
|
|
164
|
-
import Pusher from 'pusher-js/react-native';
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Notes:
|
|
168
|
-
|
|
169
|
-
* The fallbacks available for this runtime are HTTP streaming and polling.
|
|
170
|
-
* This build uses React Native's NetInfo API to detect changes on connectivity state. It will use this to automatically reconnect.
|
|
147
|
+
> **⚠️ Important notice**
|
|
148
|
+
>
|
|
149
|
+
> React Native support has been **deprecated** and soon will be removed from this repository.
|
|
150
|
+
>
|
|
151
|
+
> Please, use our official [React Native SDK](https://github.com/pusher/pusher-websocket-react-native) instead.
|
|
171
152
|
|
|
172
153
|
### Web Workers
|
|
173
154
|
(`pusher-js`'s Web Workers implementation is currently not compatible with Internet Explorer)
|
|
@@ -254,14 +235,14 @@ Object containing the configuration for user authentication. Valid keys are:
|
|
|
254
235
|
* `customHandler` (Function) - When present, this function is called instead of a request being made to the endpoint specified by `userAuthentication.endpoint`.
|
|
255
236
|
|
|
256
237
|
|
|
257
|
-
For
|
|
238
|
+
For more information see [authenticating users](https://pusher.com/docs/channels/server_api/authenticating-users/).
|
|
258
239
|
|
|
259
240
|
|
|
260
241
|
### `channelAuthorization` (Object)
|
|
261
242
|
|
|
262
243
|
Object containing the configuration for user authorization. Valid keys are:
|
|
263
244
|
|
|
264
|
-
* `endpoint` (String) - Endpoint on your server that will return the authorization signature needed for private and presence channels. Defaults to `/pusher/
|
|
245
|
+
* `endpoint` (String) - Endpoint on your server that will return the authorization signature needed for private and presence channels. Defaults to `/pusher/auth`.
|
|
265
246
|
|
|
266
247
|
* `transport` (String) - Defines how the authorization endpoint will be called. There are two options available:
|
|
267
248
|
* `ajax` - the **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
|
|
@@ -274,7 +255,7 @@ Object containing the configuration for user authorization. Valid keys are:
|
|
|
274
255
|
* `customHandler` (Function) - When present, this function is called instead of a request being made to the endpoint specified by `channelAuthorization.endpoint`.
|
|
275
256
|
|
|
276
257
|
|
|
277
|
-
For
|
|
258
|
+
For more information see [authorizing users](https://pusher.com/docs/channels/server_api/authorizing-users).
|
|
278
259
|
|
|
279
260
|
|
|
280
261
|
#### `cluster` (String)
|
|
@@ -643,7 +624,7 @@ This command will serve `pusher.js`, `sockjs.js`, `json2.js`, and their respecti
|
|
|
643
624
|
|
|
644
625
|
### Core Vs. Platform-Specific Code
|
|
645
626
|
|
|
646
|
-
New to pusher-js 3.1 is the ability for the library to produce builds for different runtimes: classic web,
|
|
627
|
+
New to pusher-js 3.1 is the ability for the library to produce builds for different runtimes: classic web, NodeJS and
|
|
647
628
|
Web Workers.
|
|
648
629
|
|
|
649
630
|
In order for this to happen, we have split the library into two directories: `core/` and `runtimes/`. In `core` we keep anything that is platform-independent. In `runtimes` we keep code that depends on certain runtimes.
|
|
@@ -682,7 +663,6 @@ In order to specify the library version, you can either update `package.json` or
|
|
|
682
663
|
Other build commands include:
|
|
683
664
|
|
|
684
665
|
```bash
|
|
685
|
-
make react-native # for the React Native build
|
|
686
666
|
make node # for the NodeJS build
|
|
687
667
|
make worker # for the worker build
|
|
688
668
|
```
|
|
@@ -696,7 +676,7 @@ Each test environment contains two types of tests:
|
|
|
696
676
|
|
|
697
677
|
Unit tests are simple, fast and don't need any external dependencies. Integration tests usually connect to production and js-integration-api servers and can use a local server for loading JS files, so they need an Internet connection to work.
|
|
698
678
|
|
|
699
|
-
There are 3 different testing environments: one for web, one for NodeJS and one for workers.
|
|
679
|
+
There are 3 different testing environments: one for web, one for NodeJS and one for workers.
|
|
700
680
|
|
|
701
681
|
The web and worker tests use [Karma](https://github.com/karma-runner/karma) to execute specs in real browsers. The NodeJS tests use [jasmine-node](https://github.com/mhevery/jasmine-node).
|
|
702
682
|
|
package/dist/node/pusher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v7.
|
|
2
|
+
* Pusher JavaScript Library v7.4.1
|
|
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("
|
|
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__(
|
|
946
|
+
var Stream = __webpack_require__(5).Stream,
|
|
947
947
|
util = __webpack_require__(0),
|
|
948
|
-
driver = __webpack_require__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
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__(
|
|
6989
|
+
var Stream = __webpack_require__(5).Stream,
|
|
6990
6990
|
util = __webpack_require__(0),
|
|
6991
|
-
driver = __webpack_require__(
|
|
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.
|
|
7490
|
+
VERSION: "7.4.1",
|
|
7491
7491
|
PROTOCOL: 7,
|
|
7492
7492
|
wsPort: 80,
|
|
7493
7493
|
wssPort: 443,
|
|
@@ -8682,6 +8682,42 @@ var presence_channel_extends = (undefined && undefined.__extends) || (function (
|
|
|
8682
8682
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8683
8683
|
};
|
|
8684
8684
|
})();
|
|
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); }); }
|
|
8687
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8688
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8689
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8690
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8691
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8692
|
+
});
|
|
8693
|
+
};
|
|
8694
|
+
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
8695
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
8696
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
8697
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
8698
|
+
function step(op) {
|
|
8699
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8700
|
+
while (_) try {
|
|
8701
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
8702
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
8703
|
+
switch (op[0]) {
|
|
8704
|
+
case 0: case 1: t = op; break;
|
|
8705
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
8706
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
8707
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
8708
|
+
default:
|
|
8709
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
8710
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
8711
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
8712
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
8713
|
+
if (t[2]) _.ops.pop();
|
|
8714
|
+
_.trys.pop(); continue;
|
|
8715
|
+
}
|
|
8716
|
+
op = body.call(thisArg, _);
|
|
8717
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
8718
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
8719
|
+
}
|
|
8720
|
+
};
|
|
8685
8721
|
|
|
8686
8722
|
|
|
8687
8723
|
|
|
@@ -8695,21 +8731,38 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
8695
8731
|
}
|
|
8696
8732
|
PresenceChannel.prototype.authorize = function (socketId, callback) {
|
|
8697
8733
|
var _this = this;
|
|
8698
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) {
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8734
|
+
_super.prototype.authorize.call(this, socketId, function (error, authData) { return __awaiter(_this, void 0, void 0, function () {
|
|
8735
|
+
var channelData, suffix;
|
|
8736
|
+
return __generator(this, function (_a) {
|
|
8737
|
+
switch (_a.label) {
|
|
8738
|
+
case 0:
|
|
8739
|
+
if (!!error) return [3, 3];
|
|
8740
|
+
authData = authData;
|
|
8741
|
+
if (!(authData.channel_data != null)) return [3, 1];
|
|
8742
|
+
channelData = JSON.parse(authData.channel_data);
|
|
8743
|
+
this.members.setMyID(channelData.user_id);
|
|
8744
|
+
return [3, 3];
|
|
8745
|
+
case 1: return [4, this.pusher.user.signinDonePromise];
|
|
8746
|
+
case 2:
|
|
8747
|
+
_a.sent();
|
|
8748
|
+
if (this.pusher.user.user_data != null) {
|
|
8749
|
+
this.members.setMyID(this.pusher.user.user_data.id);
|
|
8750
|
+
}
|
|
8751
|
+
else {
|
|
8752
|
+
suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
8753
|
+
logger.error("Invalid auth response for channel '" + this.name + "', " +
|
|
8754
|
+
("expected 'channel_data' field. " + suffix + ", ") +
|
|
8755
|
+
"or the user should be signed in.");
|
|
8756
|
+
callback('Invalid auth response');
|
|
8757
|
+
return [2];
|
|
8758
|
+
}
|
|
8759
|
+
_a.label = 3;
|
|
8760
|
+
case 3:
|
|
8761
|
+
callback(error, authData);
|
|
8762
|
+
return [2];
|
|
8707
8763
|
}
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
}
|
|
8711
|
-
callback(error, authData);
|
|
8712
|
-
});
|
|
8764
|
+
});
|
|
8765
|
+
}); });
|
|
8713
8766
|
};
|
|
8714
8767
|
PresenceChannel.prototype.handleEvent = function (event) {
|
|
8715
8768
|
var eventName = event.event;
|
|
@@ -9973,7 +10026,7 @@ function replaceHost(url, hostname) {
|
|
|
9973
10026
|
return urlParts[1] + hostname + urlParts[3];
|
|
9974
10027
|
}
|
|
9975
10028
|
function randomNumber(max) {
|
|
9976
|
-
return
|
|
10029
|
+
return node_runtime.randomInt(max);
|
|
9977
10030
|
}
|
|
9978
10031
|
function randomString(length) {
|
|
9979
10032
|
var result = [];
|
|
@@ -10203,7 +10256,7 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
|
10203
10256
|
suffix = url_store.buildLogSuffix('authenticationEndpoint');
|
|
10204
10257
|
break;
|
|
10205
10258
|
case AuthRequestType.ChannelAuthorization:
|
|
10206
|
-
suffix = "Clients must be
|
|
10259
|
+
suffix = "Clients must be authorized to join private or presence channels. " + url_store.buildLogSuffix('authorizationEndpoint');
|
|
10207
10260
|
break;
|
|
10208
10261
|
}
|
|
10209
10262
|
callback(new HTTPAuthError(xhr.status, "Unable to retrieve auth string from " + authRequestType.toString() + " endpoint - " +
|
|
@@ -10255,6 +10308,9 @@ var xhr_timeline_xhr = {
|
|
|
10255
10308
|
};
|
|
10256
10309
|
/* harmony default export */ var xhr_timeline = (xhr_timeline_xhr);
|
|
10257
10310
|
|
|
10311
|
+
// EXTERNAL MODULE: external "crypto"
|
|
10312
|
+
var external_crypto_ = __webpack_require__(3);
|
|
10313
|
+
|
|
10258
10314
|
// CONCATENATED MODULE: ./src/runtimes/node/runtime.ts
|
|
10259
10315
|
|
|
10260
10316
|
|
|
@@ -10262,6 +10318,7 @@ var xhr_timeline_xhr = {
|
|
|
10262
10318
|
|
|
10263
10319
|
|
|
10264
10320
|
|
|
10321
|
+
|
|
10265
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;
|
|
10266
10323
|
var NodeJS = {
|
|
10267
10324
|
getDefaultStrategy: runtime_getDefaultStrategy,
|
|
@@ -10289,6 +10346,9 @@ var NodeJS = {
|
|
|
10289
10346
|
},
|
|
10290
10347
|
getNetwork: function () {
|
|
10291
10348
|
return net_info_Network;
|
|
10349
|
+
},
|
|
10350
|
+
randomInt: function (max) {
|
|
10351
|
+
return Object(external_crypto_["randomInt"])(max);
|
|
10292
10352
|
}
|
|
10293
10353
|
};
|
|
10294
10354
|
/* harmony default export */ var node_runtime = (NodeJS);
|
|
@@ -10668,7 +10728,7 @@ function getEnableStatsConfig(opts) {
|
|
|
10668
10728
|
return false;
|
|
10669
10729
|
}
|
|
10670
10730
|
function buildUserAuthenticator(opts) {
|
|
10671
|
-
var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);
|
|
10731
|
+
var userAuthentication = __assign(__assign({}, defaults.userAuthentication), opts.userAuthentication);
|
|
10672
10732
|
if ('customHandler' in userAuthentication &&
|
|
10673
10733
|
userAuthentication['customHandler'] != null) {
|
|
10674
10734
|
return userAuthentication['customHandler'];
|
|
@@ -10678,7 +10738,7 @@ function buildUserAuthenticator(opts) {
|
|
|
10678
10738
|
function buildChannelAuth(opts, pusher) {
|
|
10679
10739
|
var channelAuthorization;
|
|
10680
10740
|
if ('channelAuthorization' in opts) {
|
|
10681
|
-
channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);
|
|
10741
|
+
channelAuthorization = __assign(__assign({}, defaults.channelAuthorization), opts.channelAuthorization);
|
|
10682
10742
|
}
|
|
10683
10743
|
else {
|
|
10684
10744
|
channelAuthorization = {
|
|
@@ -10705,6 +10765,17 @@ function buildChannelAuthorizer(opts, pusher) {
|
|
|
10705
10765
|
return channel_authorizer(channelAuthorization);
|
|
10706
10766
|
}
|
|
10707
10767
|
|
|
10768
|
+
// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
|
|
10769
|
+
function flatPromise() {
|
|
10770
|
+
var resolve, reject;
|
|
10771
|
+
var promise = new Promise(function (res, rej) {
|
|
10772
|
+
resolve = res;
|
|
10773
|
+
reject = rej;
|
|
10774
|
+
});
|
|
10775
|
+
return { promise: promise, resolve: resolve, reject: reject };
|
|
10776
|
+
}
|
|
10777
|
+
/* harmony default export */ var flat_promise = (flatPromise);
|
|
10778
|
+
|
|
10708
10779
|
// CONCATENATED MODULE: ./src/core/user.ts
|
|
10709
10780
|
var user_extends = (undefined && undefined.__extends) || (function () {
|
|
10710
10781
|
var extendStatics = function (d, b) {
|
|
@@ -10722,6 +10793,7 @@ var user_extends = (undefined && undefined.__extends) || (function () {
|
|
|
10722
10793
|
|
|
10723
10794
|
|
|
10724
10795
|
|
|
10796
|
+
|
|
10725
10797
|
var user_UserFacade = (function (_super) {
|
|
10726
10798
|
user_extends(UserFacade, _super);
|
|
10727
10799
|
function UserFacade(pusher) {
|
|
@@ -10731,15 +10803,29 @@ var user_UserFacade = (function (_super) {
|
|
|
10731
10803
|
_this.signin_requested = false;
|
|
10732
10804
|
_this.user_data = null;
|
|
10733
10805
|
_this.serverToUserChannel = null;
|
|
10806
|
+
_this.signinDonePromise = null;
|
|
10807
|
+
_this._signinDoneResolve = null;
|
|
10808
|
+
_this._onAuthorize = function (err, authData) {
|
|
10809
|
+
if (err) {
|
|
10810
|
+
logger.warn("Error during signin: " + err);
|
|
10811
|
+
_this._cleanup();
|
|
10812
|
+
return;
|
|
10813
|
+
}
|
|
10814
|
+
_this.pusher.send_event('pusher:signin', {
|
|
10815
|
+
auth: authData.auth,
|
|
10816
|
+
user_data: authData.user_data
|
|
10817
|
+
});
|
|
10818
|
+
};
|
|
10734
10819
|
_this.pusher = pusher;
|
|
10735
|
-
_this.pusher.connection.bind('
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10820
|
+
_this.pusher.connection.bind('state_change', function (_a) {
|
|
10821
|
+
var previous = _a.previous, current = _a.current;
|
|
10822
|
+
if (previous !== 'connected' && current === 'connected') {
|
|
10823
|
+
_this._signin();
|
|
10824
|
+
}
|
|
10825
|
+
if (previous === 'connected' && current !== 'connected') {
|
|
10826
|
+
_this._cleanup();
|
|
10827
|
+
_this._newSigninPromiseIfNeeded();
|
|
10828
|
+
}
|
|
10743
10829
|
});
|
|
10744
10830
|
_this.pusher.connection.bind('message', function (event) {
|
|
10745
10831
|
var eventName = event.event;
|
|
@@ -10761,26 +10847,16 @@ var user_UserFacade = (function (_super) {
|
|
|
10761
10847
|
this._signin();
|
|
10762
10848
|
};
|
|
10763
10849
|
UserFacade.prototype._signin = function () {
|
|
10764
|
-
var _this = this;
|
|
10765
10850
|
if (!this.signin_requested) {
|
|
10766
10851
|
return;
|
|
10767
10852
|
}
|
|
10853
|
+
this._newSigninPromiseIfNeeded();
|
|
10768
10854
|
if (this.pusher.connection.state !== 'connected') {
|
|
10769
10855
|
return;
|
|
10770
10856
|
}
|
|
10771
|
-
var onAuthorize = function (err, authData) {
|
|
10772
|
-
if (err) {
|
|
10773
|
-
logger.warn("Error during signin: " + err);
|
|
10774
|
-
return;
|
|
10775
|
-
}
|
|
10776
|
-
_this.pusher.send_event('pusher:signin', {
|
|
10777
|
-
auth: authData.auth,
|
|
10778
|
-
user_data: authData.user_data
|
|
10779
|
-
});
|
|
10780
|
-
};
|
|
10781
10857
|
this.pusher.config.userAuthenticator({
|
|
10782
10858
|
socketId: this.pusher.connection.socket_id
|
|
10783
|
-
},
|
|
10859
|
+
}, this._onAuthorize);
|
|
10784
10860
|
};
|
|
10785
10861
|
UserFacade.prototype._onSigninSuccess = function (data) {
|
|
10786
10862
|
try {
|
|
@@ -10788,12 +10864,15 @@ var user_UserFacade = (function (_super) {
|
|
|
10788
10864
|
}
|
|
10789
10865
|
catch (e) {
|
|
10790
10866
|
logger.error("Failed parsing user data after signin: " + data.user_data);
|
|
10867
|
+
this._cleanup();
|
|
10791
10868
|
return;
|
|
10792
10869
|
}
|
|
10793
10870
|
if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
|
|
10794
10871
|
logger.error("user_data doesn't contain an id. user_data: " + this.user_data);
|
|
10872
|
+
this._cleanup();
|
|
10795
10873
|
return;
|
|
10796
10874
|
}
|
|
10875
|
+
this._signinDoneResolve();
|
|
10797
10876
|
this._subscribeChannels();
|
|
10798
10877
|
};
|
|
10799
10878
|
UserFacade.prototype._subscribeChannels = function () {
|
|
@@ -10817,13 +10896,32 @@ var user_UserFacade = (function (_super) {
|
|
|
10817
10896
|
});
|
|
10818
10897
|
ensure_subscribed(this.serverToUserChannel);
|
|
10819
10898
|
};
|
|
10820
|
-
UserFacade.prototype.
|
|
10899
|
+
UserFacade.prototype._cleanup = function () {
|
|
10821
10900
|
this.user_data = null;
|
|
10822
10901
|
if (this.serverToUserChannel) {
|
|
10823
10902
|
this.serverToUserChannel.unbind_all();
|
|
10824
10903
|
this.serverToUserChannel.disconnect();
|
|
10825
10904
|
this.serverToUserChannel = null;
|
|
10826
10905
|
}
|
|
10906
|
+
if (this.signin_requested) {
|
|
10907
|
+
this._signinDoneResolve();
|
|
10908
|
+
}
|
|
10909
|
+
};
|
|
10910
|
+
UserFacade.prototype._newSigninPromiseIfNeeded = function () {
|
|
10911
|
+
if (!this.signin_requested) {
|
|
10912
|
+
return;
|
|
10913
|
+
}
|
|
10914
|
+
if (this.signinDonePromise && !this.signinDonePromise.done) {
|
|
10915
|
+
return;
|
|
10916
|
+
}
|
|
10917
|
+
var _a = flat_promise(), promise = _a.promise, resolve = _a.resolve, _ = _a.reject;
|
|
10918
|
+
promise.done = false;
|
|
10919
|
+
var setDone = function () {
|
|
10920
|
+
promise.done = true;
|
|
10921
|
+
};
|
|
10922
|
+
promise.then(setDone)["catch"](setDone);
|
|
10923
|
+
this.signinDonePromise = promise;
|
|
10924
|
+
this._signinDoneResolve = resolve;
|
|
10827
10925
|
};
|
|
10828
10926
|
return UserFacade;
|
|
10829
10927
|
}(dispatcher));
|
|
@@ -10859,7 +10957,7 @@ var pusher_Pusher = (function () {
|
|
|
10859
10957
|
this.config = getConfig(options, this);
|
|
10860
10958
|
this.channels = factory.createChannels();
|
|
10861
10959
|
this.global_emitter = new dispatcher();
|
|
10862
|
-
this.sessionID =
|
|
10960
|
+
this.sessionID = node_runtime.randomInt(1000000000);
|
|
10863
10961
|
this.timeline = new timeline_timeline(this.key, this.sessionID, {
|
|
10864
10962
|
cluster: this.config.cluster,
|
|
10865
10963
|
features: Pusher.getClientFeatures(),
|