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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.1.1-beta
4
+
5
+ [FIXED] Exported Typescript types in index.d.ts
6
+
3
7
  ## 7.1.0-beta
4
8
 
5
9
  [ADDED] Support for authenticating users with the `signin` method
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
- #### `authEndpoint` (String)
238
+ ### `userAuthentication` (Object)
239
239
 
240
- Endpoint on your server that will return the authentication signature needed for private and presence channels. Defaults to `'/pusher/auth'`.
240
+ Object containing the configuration for user authentication. Valid keys are:
241
241
 
242
- For more information see [authenticating users](https://pusher.com/docs/authenticating_users).
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
- #### `authTransport` (String)
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
- Defines how the authentication endpoint, defined using authEndpoint, will be called. There are two options available: `ajax` and `jsonp`.
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
- * `ajax` - The **default** option where an `XMLHttpRequest` object will be used to make a request. The parameters will be passed as `POST` parameters.
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
- For more information see the [Channel authentication transport section of our authenticating users docs](http://pusher.com/docs/authenticating_users#authTransport).
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
- Allows passing additional data to authorizers. Supports query string params and headers (AJAX only). For example, following will pass `foo=bar` via the query string and `baz: boo` via headers:
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
- Additional parameters to be sent when the channel authentication endpoint is called. When using [ajax authentication](https://pusher.com/docs/authenticating_users#ajax_authentication) the parameters are passed as additional `POST` parameters. When using [jsonp authentication](http://pusher.com/docs/authenticating_users#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)](http://en.wikipedia.org/wiki/Cross-site_request_forgery).
258
+ ### `channelAuthorization` (Object)
268
259
 
269
- ##### CSRF
260
+ Object containing the configuration for user authorization. Valid keys are:
270
261
 
271
- If you require a CSRF header for incoming requests to the private channel authentication endpoint on your server, you should add a CSRF token to the `auth` hash under `headers`. This is applicable to frameworks which apply CSRF protection by default.
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
- ```js
274
- const pusher = new Pusher(APP_KEY, {
275
- cluster: APP_CLUSTER,
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
- #### `authorizer` (Function)
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
- If you need custom authorization behavior you can provide your own `authorizer` function as follows:
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
- ```js
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
- ```js
306
- let authorizer = (channel, options) => {
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
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v7.0.6
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.0.6",
7490
+ VERSION: "7.1.1-beta",
7491
7491
  PROTOCOL: 7,
7492
7492
  wsPort: 80,
7493
7493
  wssPort: 443,