pusher 5.1.3 → 5.3.2

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.
@@ -1,3 +1,5 @@
1
+ name: Release
2
+
1
3
  on:
2
4
  push:
3
5
  branches: [master]
@@ -7,7 +9,7 @@ jobs:
7
9
  runs-on: ubuntu-latest
8
10
  steps:
9
11
  - name: Checkout code
10
- uses: actions/checkout@v2
12
+ uses: actions/checkout@v4
11
13
  with:
12
14
  fetch-depth: 0
13
15
  - name: Prepare tag
@@ -26,7 +28,7 @@ jobs:
26
28
  id: release_output
27
29
  if: ${{ steps.prepare_tag.outcome == 'success' }}
28
30
  run: |
29
- echo "::set-output name=tag::${{ env.TAG }}"
31
+ echo "tag=${{ env.TAG }}" >> $GITHUB_OUTPUT
30
32
  outputs:
31
33
  tag: ${{ steps.release_output.outputs.tag }}
32
34
 
@@ -34,8 +36,10 @@ jobs:
34
36
  runs-on: ubuntu-latest
35
37
  needs: check-release-tag
36
38
  if: ${{ needs.check-release-tag.outputs.tag }}
39
+ permissions:
40
+ contents: write
37
41
  steps:
38
- - uses: actions/checkout@v2
42
+ - uses: actions/checkout@v4
39
43
  - name: Prepare tag
40
44
  run: |
41
45
  export TAG=v$(jq -r '.version' package.json)
@@ -49,34 +53,26 @@ jobs:
49
53
  csplit -s CHANGELOG.md "/##/" {1}
50
54
  cat xx01 > CHANGELOG.tmp
51
55
  - name: Create Release
52
- uses: actions/create-release@v1
53
- env:
54
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56
+ uses: softprops/action-gh-release@v2
55
57
  with:
56
58
  tag_name: ${{ env.TAG }}
57
- release_name: ${{ env.TAG }}
59
+ name: ${{ env.TAG }}
58
60
  body_path: CHANGELOG.tmp
59
61
  draft: false
60
62
  prerelease: false
63
+ env:
64
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61
65
 
62
66
  publish-to-npm:
63
67
  runs-on: ubuntu-latest
64
68
  needs: create-github-release
65
69
  steps:
66
- - uses: actions/checkout@v2
67
- - uses: flood-io/is-published-on-npm@8478347e2650eb228d303975415458183d0a37e4
68
- id: is-published
69
- - run: echo "This version is already published on NPM"
70
- if: ${{ steps.is-published.outputs.published == 'true' }}
71
- - uses: actions/setup-node@v2
72
- if: ${{ steps.is-published.outputs.published == 'false' }}
70
+ - uses: actions/checkout@v4
71
+ - uses: actions/setup-node@v4
73
72
  with:
74
- node-version: "14"
75
- registry-url: https://registry.npmjs.org/
73
+ node-version: "20"
74
+ registry-url: "https://registry.npmjs.org"
76
75
  - run: npm install
77
- if: ${{ steps.is-published.outputs.published == 'false' }}
78
76
  - run: npm publish --access public
79
- if: ${{ steps.is-published.outputs.published == 'false' }}
80
77
  env:
81
78
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
82
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -11,13 +11,16 @@ jobs:
11
11
  name: Prepare release
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
17
+ fetch-depth: 0
15
18
  - name: Get current version
16
19
  shell: bash
17
20
  run: |
18
21
  CURRENT_VERSION=$(jq -r '.version' package.json)
19
22
  echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20
- - uses: actions/checkout@v2
23
+ - uses: actions/checkout@v4
21
24
  with:
22
25
  repository: pusher/actions
23
26
  token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
@@ -26,11 +29,12 @@ jobs:
26
29
  id: bump
27
30
  with:
28
31
  current_version: ${{ env.CURRENT_VERSION }}
29
- - uses: actions/setup-node@v2
32
+ token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
33
+ - uses: actions/setup-node@v4
30
34
  with:
31
- node-version: "14"
35
+ node-version: "20"
32
36
  - run: npm install
33
- - name: Push
37
+ - name: Commit and push version bump
34
38
  shell: bash
35
39
  run: |
36
40
  echo "$(jq '.version = "${{ steps.bump.outputs.new_version }}"' package.json)" > package.json
@@ -7,7 +7,7 @@ on:
7
7
 
8
8
  jobs:
9
9
  test:
10
- runs-on: ubuntu-20.04
10
+ runs-on: ubuntu-latest
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
@@ -17,7 +17,7 @@ jobs:
17
17
 
18
18
  steps:
19
19
  - name: Checkout
20
- uses: actions/checkout@v2
20
+ uses: actions/checkout@v4
21
21
 
22
22
  - name: Setup Node.js
23
23
  uses: actions/setup-node@v2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.3.2
4
+
5
+ - [Added] missing error types for Typescript support
6
+
7
+ ## 5.3.1
8
+
9
+ - [CHANGED] Fix Github Actions.
10
+
11
+ ## 5.2.0
12
+
13
+ - [CHANGED] Remove old notification references. It's no longer being used
14
+
3
15
  ## 5.1.3
4
16
 
5
17
  [FIXED] Parsing of the extraTokens in webhook's isValid method
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  In order to use this library, you need to have an account on <https://pusher.com/channels>. After registering, you will need the application credentials for your app.
7
7
 
8
+ For reporting issues, bugs, and feature requests, please feel free to open a pull request or open an issue. If you do not receive a timely response, feel free to check our [support portal](https://docs.bird.com/pusher).
9
+
8
10
  ## Supported platforms
9
11
 
10
12
  This SDK supports **Node.js** version 10+.
package/index.d.ts CHANGED
@@ -190,5 +190,31 @@ declare namespace Pusher {
190
190
  getTime(): Date
191
191
  }
192
192
 
193
+ export class RequestError extends Error {
194
+ constructor(
195
+ message: string,
196
+ url: string,
197
+ error: Error,
198
+ status?: number,
199
+ body?: string
200
+ )
201
+ url: string
202
+ error: Error
203
+ status?: number
204
+ body?: string
205
+ }
206
+
207
+ export class WebHookError extends Error {
208
+ constructor(
209
+ message: string,
210
+ contentType: string,
211
+ body: string,
212
+ signature: string
213
+ )
214
+ contentType: string
215
+ body: string
216
+ signature: string
217
+ }
218
+
193
219
  export { Response }
194
220
  }
package/lib/pusher.js CHANGED
@@ -9,7 +9,6 @@ const requests = require("./requests")
9
9
  const PusherConfig = require("./pusher_config")
10
10
  const Token = require("./token")
11
11
  const WebHook = require("./webhook")
12
- const NotificationClient = require("./notification_client")
13
12
 
14
13
  const validateChannel = function (channel) {
15
14
  if (
@@ -52,10 +51,8 @@ const validateUserData = function (userData) {
52
51
  * @constructor
53
52
  * @param {Object} options
54
53
  * @param {String} [options.host="api.pusherapp.com"] API hostname
55
- * @param {String} [options.notification_host="api.pusherapp.com"] Notification API hostname
56
54
  * @param {Boolean} [options.useTLS=false] whether to use TLS
57
55
  * @param {Boolean} [options.encrypted=false] deprecated; renamed to `useTLS`
58
- * @param {Boolean} [options.notification_encrypted=false] whether to use TLS for notifications
59
56
  * @param {Integer} [options.port] port, default depends on the scheme
60
57
  * @param {Integer} options.appId application ID
61
58
  * @param {String} options.key application key
@@ -65,11 +62,6 @@ const validateUserData = function (userData) {
65
62
  */
66
63
  function Pusher(options) {
67
64
  this.config = new PusherConfig(options)
68
- const notificationOptions = Object.assign({}, options, {
69
- host: options.notificationHost,
70
- encrypted: options.notificationEncrypted,
71
- })
72
- this.notificationClient = new NotificationClient(notificationOptions)
73
65
  }
74
66
 
75
67
  /** Create a Pusher instance using a URL.
@@ -237,10 +229,6 @@ Pusher.prototype.triggerBatch = function (batch) {
237
229
  return events.triggerBatch(this, batch)
238
230
  }
239
231
 
240
- Pusher.prototype.notify = function () {
241
- this.notificationClient.notify.apply(this.notificationClient, arguments)
242
- }
243
-
244
232
  /** Makes a POST request to Pusher, handles the authentication.
245
233
  *
246
234
  * Returns a promise resolving to a response, or rejecting to a RequestError.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pusher",
3
3
  "description": "Node.js client to interact with the Pusher Channels REST API",
4
- "version": "5.1.3",
4
+ "version": "5.3.2",
5
5
  "author": "Pusher <support@pusher.com>",
6
6
  "contributors": [
7
7
  {
@@ -1,25 +0,0 @@
1
- const requests = require("./requests")
2
- const NotificationConfig = require("./notification_config")
3
-
4
- function NotificationClient(options) {
5
- this.config = new NotificationConfig(options)
6
- }
7
-
8
- NotificationClient.prototype.notify = function (interests, notification) {
9
- if (!Array.isArray(interests)) {
10
- throw new Error("Interests must be an array")
11
- }
12
-
13
- if (interests.length == 0) {
14
- throw new Error("Interests array must not be empty")
15
- }
16
-
17
- const body = Object.assign({ interests: interests }, notification)
18
- return requests.send(this.config, {
19
- method: "POST",
20
- body: body,
21
- path: "/notifications",
22
- })
23
- }
24
-
25
- module.exports = NotificationClient
@@ -1,18 +0,0 @@
1
- const Config = require("./config")
2
-
3
- const DEFAULT_HOST = "nativepush-cluster1.pusher.com"
4
- const API_PREFIX = "server_api"
5
- const API_VERSION = "v1"
6
-
7
- function NotificationConfig(options) {
8
- Config.call(this, options)
9
- this.host = options.host || DEFAULT_HOST
10
- }
11
-
12
- Object.assign(NotificationConfig.prototype, Config.prototype)
13
-
14
- NotificationConfig.prototype.prefixPath = function (subPath) {
15
- return "/" + API_PREFIX + "/" + API_VERSION + "/apps/" + this.appId + subPath
16
- }
17
-
18
- module.exports = NotificationConfig
@@ -1,49 +0,0 @@
1
- const expect = require("expect.js")
2
- const NotificationClient = require("../../../lib/notification_client")
3
- const nock = require("nock")
4
-
5
- describe("NativeNotificationClient", function () {
6
- let client
7
-
8
- beforeEach(function () {
9
- client = new NotificationClient({
10
- appId: 1234,
11
- key: "f00d",
12
- secret: "tofu",
13
- })
14
- nock.cleanAll()
15
- nock.disableNetConnect()
16
- })
17
-
18
- afterEach(function () {
19
- nock.cleanAll()
20
- nock.enableNetConnect()
21
- })
22
-
23
- xit("should send in the success case", function (done) {
24
- const mock = nock("nativepush-cluster1.pusher.com:80")
25
- client.notify(
26
- ["yolo"],
27
- {
28
- apns: {
29
- aps: {
30
- alert: {
31
- title: "yolo",
32
- body: "woot",
33
- },
34
- },
35
- },
36
- gcm: {
37
- notification: {
38
- title: "huzzah",
39
- icon: "woot",
40
- },
41
- },
42
- },
43
- function () {
44
- expect(mock.isDone()).to.be(true)
45
- done()
46
- }
47
- )
48
- })
49
- })