pusher 5.1.0-beta → 5.1.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.
@@ -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,12 @@
1
+ # Changelog
2
+
3
+ ## 5.1.2
4
+
5
+ - [CHANGED] Add types/node-fetch to dependencies.
6
+ ## 5.1.1-beta (2022-06-01)
7
+
8
+ [FIXED] Updated typescript types with new user features.
9
+
1
10
  ## 5.1.0-beta (2022-04-22)
2
11
 
3
12
  [ADDED] Support for terminating user connections based on user id
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/index.d.ts CHANGED
@@ -24,11 +24,29 @@ declare class Pusher {
24
24
  get(opts: Pusher.GetOptions): Promise<Response>
25
25
  post(opts: Pusher.PostOptions): Promise<Response>
26
26
 
27
+ /**
28
+ * @deprecated Use authorizeChannel
29
+ */
27
30
  authenticate(
28
31
  socketId: string,
29
32
  channel: string,
30
33
  data?: Pusher.PresenceChannelData
31
- ): Pusher.AuthResponse
34
+ ): Pusher.ChannelAuthResponse
35
+
36
+ authorizeChannel(
37
+ socketId: string,
38
+ channel: string,
39
+ data?: Pusher.PresenceChannelData
40
+ ): Pusher.ChannelAuthResponse
41
+
42
+ authenticateUser(
43
+ socketId: string,
44
+ userData: Pusher.UserChannelData
45
+ ): Pusher.UserAuthResponse
46
+
47
+ sendToUser(userId: string, event: string, data: any): Promise<Response>
48
+
49
+ terminateUserConnections(userId: string): Promise<Response>
32
50
 
33
51
  webhook(request: Pusher.WebHookRequest): Pusher.WebHook
34
52
  createSignedQueryString(opts: Pusher.SignedQueryStringOptions): string
@@ -106,12 +124,26 @@ declare namespace Pusher {
106
124
  params?: Params
107
125
  }
108
126
 
127
+ /**
128
+ * @deprecated Use ChannelAuthResponse
129
+ */
109
130
  export interface AuthResponse {
110
131
  auth: string
111
132
  channel_data?: string
112
133
  shared_secret?: string
113
134
  }
114
135
 
136
+ export interface ChannelAuthResponse {
137
+ auth: string
138
+ channel_data?: string
139
+ shared_secret?: string
140
+ }
141
+
142
+ export interface UserAuthResponse {
143
+ auth: string
144
+ user_data: string
145
+ }
146
+
115
147
  export interface PresenceChannelData {
116
148
  user_id: string
117
149
  user_info?: {
@@ -119,6 +151,11 @@ declare namespace Pusher {
119
151
  }
120
152
  }
121
153
 
154
+ export interface UserChannelData {
155
+ id: string
156
+ [key: string]: any
157
+ }
158
+
122
159
  export interface WebHookRequest {
123
160
  headers: object
124
161
  rawBody: string
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.0-beta",
4
+ "version": "5.1.2",
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",
@@ -54,7 +54,7 @@
54
54
  "realtime"
55
55
  ],
56
56
  "license": "MIT",
57
- "repository": "git://github.com/pusher/pusher-rest-node",
57
+ "repository": "git://github.com/pusher/pusher-http-node",
58
58
  "main": "lib/pusher",
59
59
  "typings": "index.d.ts",
60
60
  "engines": {