pusher-js 7.1.0-beta → 7.1.1-beta
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/CHANGELOG.md +4 -0
- package/README.md +21 -83
- package/dist/node/pusher.js +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +8 -3
- package/package.json +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
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -235,107 +235,45 @@ For most users, there is little need to change these. See [client API guide](htt
|
|
|
235
235
|
|
|
236
236
|
Forces the connection to use TLS. When set to `false` the library will attempt non-TLS connections first. Defaults to `true`.
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
### `userAuthentication` (Object)
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
Object containing the configuration for user authentication. Valid keys are:
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
* `endpoint` (String) - Endpoint on your server that will return the authentication signature needed for signing the user in. Defaults to `/pusher/user-auth`.
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
* `transport` (String) - Defines how the authentication endpoint will be called. There are two options available:
|
|
245
|
+
* `ajax` - the **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
|
|
246
|
+
* `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
247
|
|
|
246
|
-
|
|
248
|
+
* `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
249
|
|
|
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.
|
|
250
|
+
* `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
251
|
|
|
251
|
-
|
|
252
|
+
* `customHandler` (Function) - When present, this function is called instead of a request being made to the endpoint specified by `userAuthentication.endpoint`.
|
|
252
253
|
|
|
253
|
-
#### `auth` (Hash)
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
For more information see [authenticating users](https://pusher.com/docs/channels/server_api/authenticating-users/).
|
|
256
256
|
|
|
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
257
|
|
|
267
|
-
|
|
258
|
+
### `channelAuthorization` (Object)
|
|
268
259
|
|
|
269
|
-
|
|
260
|
+
Object containing the configuration for user authorization. Valid keys are:
|
|
270
261
|
|
|
271
|
-
|
|
262
|
+
* `endpoint` (String) - Endpoint on your server that will return the authorization signature needed for private and presence channels. Defaults to `/pusher/user-auth`.
|
|
272
263
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
auth: {
|
|
277
|
-
params: { foo: 'bar' },
|
|
278
|
-
headers: { 'X-CSRF-Token': 'SOME_CSRF_TOKEN' }
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
```
|
|
264
|
+
* `transport` (String) - Defines how the authorization endpoint will be called. There are two options available:
|
|
265
|
+
* `ajax` - the **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
|
|
266
|
+
* `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
267
|
|
|
283
|
-
|
|
268
|
+
* `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
269
|
|
|
285
|
-
|
|
270
|
+
* `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
271
|
|
|
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
|
-
```
|
|
272
|
+
* `customHandler` (Function) - When present, this function is called instead of a request being made to the endpoint specified by `channelAuthorization.endpoint`.
|
|
300
273
|
|
|
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
274
|
|
|
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
|
-
```
|
|
275
|
+
For more information see [authorizing users](https://pusher.com/docs/channels/server_api/authorizing-users).
|
|
276
|
+
|
|
339
277
|
|
|
340
278
|
#### `cluster` (String)
|
|
341
279
|
|
package/dist/node/pusher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v7.
|
|
2
|
+
* Pusher JavaScript Library v7.1.1-beta
|
|
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.
|
|
7490
|
+
VERSION: "7.1.1-beta",
|
|
7491
7491
|
PROTOCOL: 7,
|
|
7492
7492
|
wsPort: 80,
|
|
7493
7493
|
wssPort: 443,
|