pusher 5.0.0 → 5.0.1

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/stale.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  # Configuration for probot-stale - https://github.com/probot/stale
2
2
 
3
3
  # Number of days of inactivity before an Issue or Pull Request becomes stale
4
- daysUntilStale: 365
4
+ daysUntilStale: 90
5
5
 
6
6
  # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7
7
  # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
@@ -23,4 +23,4 @@ markComment: >
23
23
  This issue has been automatically marked as stale because it has not had
24
24
  recent activity. It will be closed if no further activity occurs. If you'd
25
25
  like this issue to stay open please leave a comment indicating how this issue
26
- is affecting you. Thankyou.
26
+ is affecting you. Thank you.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
+ ## 5.0.1 (2022-01-24)
2
+
3
+ [FIXED] Incorrect `require` on `version.js` was causing a compilation error in Webpack
4
+ [FIXED] Inconsistent encoding for shared secret between other SDKs
5
+
1
6
  ## 5.0.0 (2021-02-18)
2
7
 
3
8
  [BREAKING CHANGE] `trigger` now accepts a `params` _object_ instead of a `socket_id` as the third parameter.
9
+
4
10
  [ADDED] Support for requesting channel attributes as part of a `trigger` and `triggerBatch` request via an `info` parameter.
5
11
 
6
12
  ## 4.0.2 (2020-11-30)
@@ -51,6 +57,7 @@ const pusher = new Pusher.forURL(process.env.PUSHER_URL, {
51
57
  [UPGRADED] development dependencies
52
58
 
53
59
  [ADDED] encryptionMasterKeyBase64 constructor parameter to make it easier to use the full range of 32 byte binary values in encryption key
60
+
54
61
  [DEPRECATED] encryptionMasterKey constructor parameter - use encryptionMasterKeyBase64
55
62
 
56
63
  ## 3.0.0 (2019-09-26)
package/README.md CHANGED
@@ -7,9 +7,9 @@ In order to use this library, you need to have an account on <https://pusher.com
7
7
 
8
8
  ## Supported platforms
9
9
 
10
- This SDK supports **Node.js** version 8+.
10
+ This SDK supports **Node.js** version 10+.
11
11
 
12
- We test the library against a selection of Node.js versions which we update over time. Please refer to [travis.yml](https://github.com/pusher/pusher-http-node/blob/master/.travis.yml) for the set of versions that are currently tested with CI.
12
+ We test the library against a selection of Node.js versions which we update over time. Please refer to [test.yml](https://github.com/pusher/pusher-http-node/blob/master/.github/workflows/test.yml) for the set of versions that are currently tested with CI.
13
13
 
14
14
  If you find any compatibility issues, please [raise an issue](https://github.com/pusher/pusher-http-node/issues/new) in the repository or contact support at [support@pusher.com](support@pusher.com). We will happily investigate reported problems ❤️.
15
15
 
@@ -237,7 +237,7 @@ pusher
237
237
  })
238
238
  ```
239
239
 
240
- ### End-to-end encryption [BETA]
240
+ ### End-to-end encryption
241
241
 
242
242
  This library supports end-to-end encryption of your private channels. This means that only you and your connected clients will be able to read your messages. Pusher cannot decrypt them. You can enable this feature by following these steps:
243
243
 
@@ -4,8 +4,7 @@ import * as Pusher from "pusher"
4
4
 
5
5
  const pusher = Pusher.forURL(process.env.PUSHER_URL, {
6
6
  encryptionMasterKeyBase64: Buffer.from(
7
- "01234567890123456789012345678901",
8
- "binary"
7
+ "01234567890123456789012345678901"
9
8
  ).toString("base64"),
10
9
  agent: new Agent({ keepAlive: true }),
11
10
  })
package/lib/config.js CHANGED
@@ -49,7 +49,7 @@ function Config(options) {
49
49
  )
50
50
  }
51
51
 
52
- this.encryptionMasterKey = options.encryptionMasterKey
52
+ this.encryptionMasterKey = Buffer.from(options.encryptionMasterKey)
53
53
  }
54
54
 
55
55
  // Handle base64 encoded 32 byte key to encourage use of the full range of byte values
@@ -61,10 +61,7 @@ function Config(options) {
61
61
  throw new Error("encryptionMasterKeyBase64 must be valid base64")
62
62
  }
63
63
 
64
- const decodedKey = Buffer.from(
65
- options.encryptionMasterKeyBase64,
66
- "base64"
67
- ).toString("binary")
64
+ const decodedKey = Buffer.from(options.encryptionMasterKeyBase64, "base64")
68
65
  if (decodedKey.length !== 32) {
69
66
  throw new Error(
70
67
  "encryptionMasterKeyBase64 must decode to 32 bytes, but the string " +
package/lib/pusher.js CHANGED
@@ -234,7 +234,9 @@ Pusher.prototype.createSignedQueryString = function (options) {
234
234
  Pusher.prototype.channelSharedSecret = function (channel) {
235
235
  return crypto
236
236
  .createHash("sha256")
237
- .update(channel + this.config.encryptionMasterKey)
237
+ .update(
238
+ Buffer.concat([Buffer.from(channel), this.config.encryptionMasterKey])
239
+ )
238
240
  .digest()
239
241
  }
240
242
 
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("../package").version
1
+ module.exports = require("../package.json").version
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.0.0",
4
+ "version": "5.0.1",
5
5
  "author": "Pusher <support@pusher.com>",
6
6
  "contributors": [
7
7
  {
@@ -149,14 +149,14 @@ describe("Pusher", function () {
149
149
  describe("Pusher with encryptionMasterKey", function () {
150
150
  let pusher
151
151
 
152
- const testMasterKey = "01234567890123456789012345678901"
152
+ const testMasterKeyBase64 = "zyrm8pvV2C9fJcBfhyXzvxbJVN/H7QLmbe0xJi1GhPU="
153
153
 
154
154
  beforeEach(function () {
155
155
  pusher = new Pusher({
156
156
  appId: 1234,
157
157
  key: "f00d",
158
158
  secret: "tofu",
159
- encryptionMasterKey: testMasterKey,
159
+ encryptionMasterKeyBase64: testMasterKeyBase64,
160
160
  })
161
161
  })
162
162
 
@@ -168,7 +168,7 @@ describe("Pusher with encryptionMasterKey", function () {
168
168
  auth:
169
169
  "f00d:962c48b78bf93d98ff4c92ee7dff04865821455b7b401e9d60a9e0a90af2c105",
170
170
  channel_data: '"foo"',
171
- shared_secret: "BYBsePpRCQkGPvbWu/5j8x+MmUF5sgPH5DmNBwkTzYs=",
171
+ shared_secret: "nlr49ISQHz91yS3cy/yWmW8wFMNeTnNL5tNHnbPJcLQ=",
172
172
  })
173
173
  })
174
174
  it("should not return a shared_secret for non-encrypted channels", function () {
@@ -102,7 +102,7 @@ describe("Pusher", function () {
102
102
  it("should support `encryptionMasterKey` of 32 bytes", function () {
103
103
  const key = "01234567890123456789012345678901"
104
104
  const pusher = new Pusher({ encryptionMasterKey: key })
105
- expect(pusher.config.encryptionMasterKey).to.equal(key)
105
+ expect(pusher.config.encryptionMasterKey.toString()).to.equal(key)
106
106
  })
107
107
 
108
108
  it("should reject `encryptionMasterKey` of 31 bytes", function () {
@@ -121,14 +121,14 @@ describe("Pusher", function () {
121
121
 
122
122
  it("should support `encryptionMasterKeyBase64` which decodes to 32 bytes", function () {
123
123
  const key = "01234567890123456789012345678901"
124
- const keyBase64 = Buffer.from(key, "binary").toString("base64")
124
+ const keyBase64 = Buffer.from(key).toString("base64")
125
125
  const pusher = new Pusher({ encryptionMasterKeyBase64: keyBase64 })
126
- expect(pusher.config.encryptionMasterKey).to.equal(key)
126
+ expect(pusher.config.encryptionMasterKey.toString()).to.equal(key)
127
127
  })
128
128
 
129
129
  it("should reject `encryptionMasterKeyBase64` which decodes to 31 bytes", function () {
130
130
  const key = "0123456789012345678901234567890"
131
- const keyBase64 = Buffer.from(key, "binary").toString("base64")
131
+ const keyBase64 = Buffer.from(key).toString("base64")
132
132
  expect(function () {
133
133
  new Pusher({ encryptionMasterKeyBase64: keyBase64 })
134
134
  }).to.throwException(/31 bytes/)
@@ -136,7 +136,7 @@ describe("Pusher", function () {
136
136
 
137
137
  it("should reject `encryptionMasterKeyBase64` which decodes to 33 bytes", function () {
138
138
  const key = "012345678901234567890123456789012"
139
- const keyBase64 = Buffer.from(key, "binary").toString("base64")
139
+ const keyBase64 = Buffer.from(key).toString("base64")
140
140
  expect(function () {
141
141
  new Pusher({ encryptionMasterKeyBase64: keyBase64 })
142
142
  }).to.throwException(/33 bytes/)
@@ -447,8 +447,7 @@ describe("Pusher with encryptionMasterKey", function () {
447
447
  let pusher
448
448
 
449
449
  const testMasterKey = Buffer.from(
450
- "01234567890123456789012345678901",
451
- "binary"
450
+ "01234567890123456789012345678901"
452
451
  ).toString("base64")
453
452
 
454
453
  beforeEach(function () {