pusher 5.1.1-beta → 5.1.3

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.
@@ -0,0 +1,14 @@
1
+ ## What does this PR do?
2
+
3
+ [Description here]
4
+
5
+ ## Checklist
6
+
7
+ - [ ] All new functionality has tests.
8
+ - [ ] All tests are passing.
9
+ - [ ] New or changed API methods have been documented.
10
+ - [ ] `npm run format` has been run
11
+
12
+ ## CHANGELOG
13
+
14
+ - [CHANGED] Describe your change here. Look at CHANGELOG.md to see the format.
@@ -0,0 +1,82 @@
1
+ on:
2
+ push:
3
+ branches: [master]
4
+
5
+ jobs:
6
+ check-release-tag:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: Checkout code
10
+ uses: actions/checkout@v2
11
+ with:
12
+ fetch-depth: 0
13
+ - name: Prepare tag
14
+ id: prepare_tag
15
+ continue-on-error: true
16
+ run: |
17
+ export TAG=v$(jq -r '.version' package.json)
18
+ echo "TAG=$TAG" >> $GITHUB_ENV
19
+
20
+ export CHECK_TAG=$(git tag | grep $TAG)
21
+ if [[ $CHECK_TAG ]]; then
22
+ echo "Skipping because release tag already exists"
23
+ exit 1
24
+ fi
25
+ - name: Output
26
+ id: release_output
27
+ if: ${{ steps.prepare_tag.outcome == 'success' }}
28
+ run: |
29
+ echo "::set-output name=tag::${{ env.TAG }}"
30
+ outputs:
31
+ tag: ${{ steps.release_output.outputs.tag }}
32
+
33
+ create-github-release:
34
+ runs-on: ubuntu-latest
35
+ needs: check-release-tag
36
+ if: ${{ needs.check-release-tag.outputs.tag }}
37
+ steps:
38
+ - uses: actions/checkout@v2
39
+ - name: Prepare tag
40
+ run: |
41
+ export TAG=v$(jq -r '.version' package.json)
42
+ echo "TAG=$TAG" >> $GITHUB_ENV
43
+ - name: Setup git
44
+ run: |
45
+ git config user.email "pusher-ci@pusher.com"
46
+ git config user.name "Pusher CI"
47
+ - name: Prepare description
48
+ run: |
49
+ csplit -s CHANGELOG.md "/##/" {1}
50
+ cat xx01 > CHANGELOG.tmp
51
+ - name: Create Release
52
+ uses: actions/create-release@v1
53
+ env:
54
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
+ with:
56
+ tag_name: ${{ env.TAG }}
57
+ release_name: ${{ env.TAG }}
58
+ body_path: CHANGELOG.tmp
59
+ draft: false
60
+ prerelease: false
61
+
62
+ publish-to-npm:
63
+ runs-on: ubuntu-latest
64
+ needs: create-github-release
65
+ 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' }}
73
+ with:
74
+ node-version: "14"
75
+ registry-url: https://registry.npmjs.org/
76
+ - run: npm install
77
+ if: ${{ steps.is-published.outputs.published == 'false' }}
78
+ - run: npm publish --access public
79
+ if: ${{ steps.is-published.outputs.published == 'false' }}
80
+ env:
81
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
82
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,40 @@
1
+ name: release
2
+
3
+ on:
4
+ pull_request:
5
+ types: [labeled]
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ prepare-release:
11
+ name: Prepare release
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Get current version
16
+ shell: bash
17
+ run: |
18
+ CURRENT_VERSION=$(jq -r '.version' package.json)
19
+ echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20
+ - uses: actions/checkout@v2
21
+ with:
22
+ repository: pusher/actions
23
+ token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
24
+ path: .github/actions
25
+ - uses: ./.github/actions/prepare-version-bump
26
+ id: bump
27
+ with:
28
+ current_version: ${{ env.CURRENT_VERSION }}
29
+ - uses: actions/setup-node@v2
30
+ with:
31
+ node-version: "14"
32
+ - run: npm install
33
+ - name: Push
34
+ shell: bash
35
+ run: |
36
+ echo "$(jq '.version = "${{ steps.bump.outputs.new_version }}"' package.json)" > package.json
37
+
38
+ git add package.json CHANGELOG.md
39
+ git commit -m "Bump to version ${{ steps.bump.outputs.new_version }}"
40
+ git push
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 5.1.3
4
+
5
+ [FIXED] Parsing of the extraTokens in webhook's isValid method
6
+
7
+ ## 5.1.2
8
+
9
+ - [CHANGED] Add types/node-fetch to dependencies.
10
+
1
11
  ## 5.1.1-beta (2022-06-01)
2
12
 
3
13
  [FIXED] Updated typescript types with new user features.
@@ -85,7 +95,7 @@ const pusher = new Pusher.forURL(process.env.PUSHER_URL, {
85
95
 
86
96
  ## 2.2.1 (2019-07-03)
87
97
 
88
- no-op release to fix the description on https://www.npmjs.com/package/pusher
98
+ no-op release to fix the description on <https://www.npmjs.com/package/pusher>
89
99
 
90
100
  ## 2.2.0 (2018-11-26)
91
101
 
package/README.md CHANGED
@@ -158,6 +158,14 @@ pusher.triggerBatch(events)
158
158
 
159
159
  You can trigger a batch of up to 10 events.
160
160
 
161
+ #### Sending events to Authenticated Users
162
+
163
+ Events can be triggered to [Authenticated Users](#Authenticating-users)
164
+
165
+ ```javascript
166
+ pusher.sendToUser("user-1", "test_event", { message: "hello world" })
167
+ ```
168
+
161
169
  ### Excluding event recipients
162
170
 
163
171
  In order to avoid the client that triggered the event from also receiving it, a `socket_id` parameter can be added to the `params` object. For more information see: <http://pusher.com/docs/publisher_api_guide/publisher_excluding_recipients>.
package/lib/token.js CHANGED
@@ -7,31 +7,31 @@ const util = require("./util")
7
7
  * @param {String} key app key
8
8
  * @param {String} secret app secret
9
9
  */
10
- function Token(key, secret) {
11
- this.key = key
12
- this.secret = secret
13
- }
14
-
15
- /** Signs the string using the secret.
16
- *
17
- * @param {String} string
18
- * @returns {String}
19
- */
20
- Token.prototype.sign = function (string) {
21
- return crypto
22
- .createHmac("sha256", this.secret)
23
- .update(Buffer.from(string))
24
- .digest("hex")
25
- }
26
-
27
- /** Checks if the string has correct signature.
28
- *
29
- * @param {String} string
30
- * @param {String} signature
31
- * @returns {Boolean}
32
- */
33
- Token.prototype.verify = function (string, signature) {
34
- return util.secureCompare(this.sign(string), signature)
10
+ class Token {
11
+ constructor(key, secret) {
12
+ this.key = key
13
+ this.secret = secret
14
+ }
15
+ /** Signs the string using the secret.
16
+ *
17
+ * @param {String} string
18
+ * @returns {String}
19
+ */
20
+ sign(string) {
21
+ return crypto
22
+ .createHmac("sha256", this.secret)
23
+ .update(Buffer.from(string))
24
+ .digest("hex")
25
+ }
26
+ /** Checks if the string has correct signature.
27
+ *
28
+ * @param {String} string
29
+ * @param {String} signature
30
+ * @returns {Boolean}
31
+ */
32
+ verify(string, signature) {
33
+ return util.secureCompare(this.sign(string), signature)
34
+ }
35
35
  }
36
36
 
37
37
  module.exports = Token
package/lib/webhook.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const errors = require("./errors")
2
+ const Token = require("./token")
2
3
 
3
4
  /** Provides validation and access methods for a WebHook.
4
5
  *
@@ -46,7 +47,10 @@ WebHook.prototype.isValid = function (extraTokens) {
46
47
 
47
48
  const tokens = [this.token].concat(extraTokens)
48
49
  for (const i in tokens) {
49
- const token = tokens[i]
50
+ let token = tokens[i]
51
+ if (token instanceof Token === false) {
52
+ token = new Token(token.key, token.secret)
53
+ }
50
54
  if (this.key == token.key && token.verify(this.body, this.signature)) {
51
55
  return true
52
56
  }
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.1-beta",
4
+ "version": "5.1.3",
5
5
  "author": "Pusher <support@pusher.com>",
6
6
  "contributors": [
7
7
  {
@@ -26,11 +26,11 @@
26
26
  "is-base64": "^1.1.0",
27
27
  "node-fetch": "^2.6.1",
28
28
  "tweetnacl": "^1.0.0",
29
- "tweetnacl-util": "^0.15.0"
29
+ "tweetnacl-util": "^0.15.0",
30
+ "@types/node-fetch": "^2.5.7"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/node": "^14.14.6",
33
- "@types/node-fetch": "^2.5.7",
34
34
  "eslint": "^7.11.0",
35
35
  "expect.js": "=0.3.1",
36
36
  "express": "^4.17.1",