pusher-js 7.1.0-beta → 7.3.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.
- package/.github/dependabot.yml +14 -0
- package/CHANGELOG.md +12 -0
- package/README.md +27 -87
- package/dist/node/pusher.js +14 -2
- package/dist/node/pusher.js.map +1 -1
- package/dist/react-native/pusher.js +2 -2
- package/dist/react-native/pusher.js.map +1 -1
- package/dist/web/pusher-with-encryption.js +14 -2
- 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 +14 -2
- 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 +14 -2
- 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 +14 -2
- 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/index.d.ts +25 -11
- package/package.json +2 -2
- package/react-native/index.d.ts +18 -4
- package/spec/javascripts/unit/core/channels/channel_spec.js +25 -0
- package/src/core/auth/options.ts +8 -1
- package/src/core/channels/channel.ts +11 -0
- package/src/core/channels/presence_channel.ts +3 -0
- package/src/core/config.ts +3 -6
- package/src/core/defaults.ts +4 -5
- package/src/core/options.ts +4 -5
- package/types/src/core/auth/options.d.ts +3 -1
- package/types/src/core/channels/channel.d.ts +2 -0
- package/types/src/core/defaults.d.ts +3 -3
- package/types/src/core/options.d.ts +3 -3
- package/with-encryption/index.d.ts +18 -4
- package/worker/index.d.ts +18 -4
- package/worker/with-encryption/index.d.ts +18 -4
- package/worker/with-encryption/index.js +1 -1
- package/types/index.d.ts +0 -15
- package/types/src/core/auth/pusher_authorizer.d.ts +0 -13
- package/types/src/core/auth/user_authorizer.d.ts +0 -3
- package/types/src/core/index.d.ts +0 -6
- package/types/src/runtimes/react-native/tweetnacl-dummy.d.ts +0 -5
- package/types/src/runtimes/react-native/tweetnacl-util-dummy.d.ts +0 -7
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm"
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
# Always increase the version requirement
|
|
13
|
+
# to match the new version.
|
|
14
|
+
versioning-strategy: increase
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 7.3.0
|
|
4
|
+
|
|
5
|
+
* [FIXED] Restore previously exported types
|
|
6
|
+
|
|
7
|
+
## 7.2.0
|
|
8
|
+
|
|
9
|
+
* [ADDED] Add support for subscription_count event
|
|
10
|
+
|
|
11
|
+
## 7.1.1-beta
|
|
12
|
+
|
|
13
|
+
[FIXED] Exported Typescript types in index.d.ts
|
|
14
|
+
|
|
3
15
|
## 7.1.0-beta
|
|
4
16
|
|
|
5
17
|
[ADDED] Support for authenticating users with the `signin` method
|
package/README.md
CHANGED
|
@@ -225,7 +225,9 @@ There are a number of configuration parameters which can be set for the client,
|
|
|
225
225
|
```js
|
|
226
226
|
const pusher = new Pusher(APP_KEY, {
|
|
227
227
|
cluster: APP_CLUSTER,
|
|
228
|
-
|
|
228
|
+
channelAuthorization: {
|
|
229
|
+
endpoint: 'http://example.com/pusher/auth'
|
|
230
|
+
},
|
|
229
231
|
});
|
|
230
232
|
```
|
|
231
233
|
|
|
@@ -235,107 +237,45 @@ For most users, there is little need to change these. See [client API guide](htt
|
|
|
235
237
|
|
|
236
238
|
Forces the connection to use TLS. When set to `false` the library will attempt non-TLS connections first. Defaults to `true`.
|
|
237
239
|
|
|
238
|
-
|
|
240
|
+
### `userAuthentication` (Object)
|
|
239
241
|
|
|
240
|
-
|
|
242
|
+
Object containing the configuration for user authentication. Valid keys are:
|
|
241
243
|
|
|
242
|
-
|
|
244
|
+
* `endpoint` (String) - Endpoint on your server that will return the authentication signature needed for signing the user in. Defaults to `/pusher/user-auth`.
|
|
243
245
|
|
|
244
|
-
|
|
246
|
+
* `transport` (String) - Defines how the authentication endpoint will be called. There are two options available:
|
|
247
|
+
* `ajax` - the **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
|
|
248
|
+
* `jsonp` - The authentication endpoint will be called by a `<script>` tag being dynamically created pointing to the endpoint defined by `userAuthentication.endpoint`. This can be used when the authentication endpoint is on a different domain to the web application. The endpoint will therefore be requested as a `GET` and parameters passed in the query string.
|
|
245
249
|
|
|
246
|
-
|
|
250
|
+
* `params` (Object) - Additional parameters to be sent when the user authentication endpoint is called. When using ajax authentication the parameters are passed as additional POST parameters. When using jsonp authentication the parameters are passed as GET parameters. This can be useful with web application frameworks that guard against CSRF (Cross-site request forgery).
|
|
247
251
|
|
|
248
|
-
* `
|
|
249
|
-
* `jsonp` - The authentication endpoint will be called by a `<script>` tag being dynamically created pointing to the endpoint defined by `authEndpoint`. This can be used when the authentication endpoint is on a different domain to the web application. The endpoint will therefore be requested as a `GET` and parameters passed in the query string.
|
|
252
|
+
* `headers` (Object) - Only applied when using `ajax` as authentication transport. Provides the ability to pass additional HTTP Headers to the user authentication endpoint. This can be useful with some web application frameworks that guard against CSRF CSRF (Cross-site request forgery).
|
|
250
253
|
|
|
251
|
-
|
|
254
|
+
* `customHandler` (Function) - When present, this function is called instead of a request being made to the endpoint specified by `userAuthentication.endpoint`.
|
|
252
255
|
|
|
253
|
-
#### `auth` (Hash)
|
|
254
256
|
|
|
255
|
-
|
|
257
|
+
For more information see [authenticating users](https://pusher.com/docs/channels/server_api/authenticating-users/).
|
|
256
258
|
|
|
257
|
-
```js
|
|
258
|
-
const pusher = new Pusher(APP_KEY, {
|
|
259
|
-
cluster: APP_CLUSTER,
|
|
260
|
-
auth: {
|
|
261
|
-
params: { foo: 'bar' },
|
|
262
|
-
headers: { baz: 'boo' }
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
```
|
|
266
259
|
|
|
267
|
-
|
|
260
|
+
### `channelAuthorization` (Object)
|
|
268
261
|
|
|
269
|
-
|
|
262
|
+
Object containing the configuration for user authorization. Valid keys are:
|
|
270
263
|
|
|
271
|
-
|
|
264
|
+
* `endpoint` (String) - Endpoint on your server that will return the authorization signature needed for private and presence channels. Defaults to `/pusher/user-auth`.
|
|
272
265
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
auth: {
|
|
277
|
-
params: { foo: 'bar' },
|
|
278
|
-
headers: { 'X-CSRF-Token': 'SOME_CSRF_TOKEN' }
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
```
|
|
266
|
+
* `transport` (String) - Defines how the authorization endpoint will be called. There are two options available:
|
|
267
|
+
* `ajax` - the **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
|
|
268
|
+
* `jsonp` - The authorization endpoint will be called by a `<script>` tag being dynamically created pointing to the endpoint defined by `channelAuthorization.endpoint`. This can be used when the authorization endpoint is on a different domain to the web application. The endpoint will therefore be requested as a `GET` and parameters passed in the query string.
|
|
282
269
|
|
|
283
|
-
|
|
270
|
+
* `params` (Object) - Additional parameters to be sent when the channel authorization endpoint is called. When using ajax authorization the parameters are passed as additional POST parameters. When using jsonp authorization the parameters are passed as GET parameters. This can be useful with web application frameworks that guard against CSRF (Cross-site request forgery).
|
|
284
271
|
|
|
285
|
-
|
|
272
|
+
* `headers` (Object) - Only applied when using `ajax` as authorizing transport. Provides the ability to pass additional HTTP Headers to the user authorization endpoint. This can be useful with some web application frameworks that guard against CSRF CSRF (Cross-site request forgery).
|
|
286
273
|
|
|
287
|
-
|
|
288
|
-
const pusher = new Pusher(APP_KEY, {
|
|
289
|
-
cluster: APP_CLUSTER,
|
|
290
|
-
authorizer: function (channel, options) {
|
|
291
|
-
return {
|
|
292
|
-
authorize: function (socketId, callback) {
|
|
293
|
-
// Do some ajax to get the auth string
|
|
294
|
-
callback(null, {auth: authString});
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
})
|
|
299
|
-
```
|
|
274
|
+
* `customHandler` (Function) - When present, this function is called instead of a request being made to the endpoint specified by `channelAuthorization.endpoint`.
|
|
300
275
|
|
|
301
|
-
Example: An authorizer which uses the [`fetch`
|
|
302
|
-
API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to make a JSON
|
|
303
|
-
request to an auth endpoint
|
|
304
276
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return {
|
|
308
|
-
authorize: (socketId, callback) => {
|
|
309
|
-
fetch(authUrl, {
|
|
310
|
-
method: "POST",
|
|
311
|
-
headers: new Headers({ "Content-Type": "application/json" }),
|
|
312
|
-
body: JSON.stringify({
|
|
313
|
-
socket_id: socketId,
|
|
314
|
-
channel_name: channel.name
|
|
315
|
-
})
|
|
316
|
-
})
|
|
317
|
-
.then(res => {
|
|
318
|
-
if (!res.ok) {
|
|
319
|
-
throw new Error(`Received ${res.statusCode} from ${authUrl}`);
|
|
320
|
-
}
|
|
321
|
-
return res.json();
|
|
322
|
-
})
|
|
323
|
-
.then(data => {
|
|
324
|
-
callback(null, data);
|
|
325
|
-
})
|
|
326
|
-
.catch(err => {
|
|
327
|
-
callback(new Error(`Error calling auth endpoint: ${err}`), {
|
|
328
|
-
auth: ""
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
};
|
|
334
|
-
const pusher = new Pusher(APP_KEY, {
|
|
335
|
-
cluster: APP_CLUSTER,
|
|
336
|
-
authorizer: authorizer,
|
|
337
|
-
})
|
|
338
|
-
```
|
|
277
|
+
For more information see [authorizing users](https://pusher.com/docs/channels/server_api/authorizing-users).
|
|
278
|
+
|
|
339
279
|
|
|
340
280
|
#### `cluster` (String)
|
|
341
281
|
|
|
@@ -525,7 +465,7 @@ It is possible to access all subscribed channels through the `allChannels` funct
|
|
|
525
465
|
pusher.allChannels().forEach(channel => console.log(channel.name));
|
|
526
466
|
```
|
|
527
467
|
|
|
528
|
-
Private, presence and encrypted channels will make a request to your `
|
|
468
|
+
Private, presence and encrypted channels will make a request to your `channelAuthorization.endpoint` (`/pusher/auth`) by default, where you will have to [authorize the subscription](https://pusher.com/docs/authorizing_users). You will have to send back the correct authorization response and a 200 status code.
|
|
529
469
|
|
|
530
470
|
## Unsubscribing from channels
|
|
531
471
|
|
|
@@ -626,9 +566,9 @@ channel.trigger('client-my-event', {message: 'Hello, world!'})
|
|
|
626
566
|
```
|
|
627
567
|
|
|
628
568
|
|
|
629
|
-
## Batching
|
|
569
|
+
## Batching authorization requests (aka multi-authorization)
|
|
630
570
|
|
|
631
|
-
Currently, pusher-js itself does not support
|
|
571
|
+
Currently, pusher-js itself does not support authorizing multiple channels in one HTTP request. However, thanks to @dirkbonhomme you can use the [pusher-js-auth](https://github.com/dirkbonhomme/pusher-js-auth) plugin that buffers subscription requests and sends authorization requests to your endpoint in batches.
|
|
632
572
|
|
|
633
573
|
## Default events
|
|
634
574
|
|
package/dist/node/pusher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v7.0
|
|
2
|
+
* Pusher JavaScript Library v7.3.0
|
|
3
3
|
* https://pusher.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020, Pusher
|
|
@@ -7487,7 +7487,7 @@ function safeJSONStringify(source) {
|
|
|
7487
7487
|
|
|
7488
7488
|
// CONCATENATED MODULE: ./src/core/defaults.ts
|
|
7489
7489
|
var Defaults = {
|
|
7490
|
-
VERSION: "7.0
|
|
7490
|
+
VERSION: "7.3.0",
|
|
7491
7491
|
PROTOCOL: 7,
|
|
7492
7492
|
wsPort: 80,
|
|
7493
7493
|
wssPort: 443,
|
|
@@ -8517,6 +8517,9 @@ var channel_Channel = (function (_super) {
|
|
|
8517
8517
|
if (eventName === 'pusher_internal:subscription_succeeded') {
|
|
8518
8518
|
this.handleSubscriptionSucceededEvent(event);
|
|
8519
8519
|
}
|
|
8520
|
+
else if (eventName === 'pusher_internal:subscription_count') {
|
|
8521
|
+
this.handleSubscriptionCountEvent(event);
|
|
8522
|
+
}
|
|
8520
8523
|
else if (eventName.indexOf('pusher_internal:') !== 0) {
|
|
8521
8524
|
var metadata = {};
|
|
8522
8525
|
this.emit(eventName, data, metadata);
|
|
@@ -8532,6 +8535,12 @@ var channel_Channel = (function (_super) {
|
|
|
8532
8535
|
this.emit('pusher:subscription_succeeded', event.data);
|
|
8533
8536
|
}
|
|
8534
8537
|
};
|
|
8538
|
+
Channel.prototype.handleSubscriptionCountEvent = function (event) {
|
|
8539
|
+
if (event.data.subscription_count) {
|
|
8540
|
+
this.subscriptionCount = event.data.subscription_count;
|
|
8541
|
+
}
|
|
8542
|
+
this.emit('pusher:subscription_count', event.data);
|
|
8543
|
+
};
|
|
8535
8544
|
Channel.prototype.subscribe = function () {
|
|
8536
8545
|
var _this = this;
|
|
8537
8546
|
if (this.subscribed) {
|
|
@@ -8723,6 +8732,9 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
8723
8732
|
case 'pusher_internal:subscription_succeeded':
|
|
8724
8733
|
this.handleSubscriptionSucceededEvent(event);
|
|
8725
8734
|
break;
|
|
8735
|
+
case 'pusher_internal:subscription_count':
|
|
8736
|
+
this.handleSubscriptionCountEvent(event);
|
|
8737
|
+
break;
|
|
8726
8738
|
case 'pusher_internal:member_added':
|
|
8727
8739
|
var addedMember = this.members.addMember(data);
|
|
8728
8740
|
this.emit('pusher:member_added', addedMember);
|