@knocklabs/node 0.6.11 → 0.6.12
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/README.md
CHANGED
|
@@ -28,7 +28,7 @@ KNOCK_SIGNING_KEY="S25vY2sga25vY2sh..."
|
|
|
28
28
|
You can also pass the Knock API key in the constructor. The signing key is passed separately to the `signUserToken` method (see below):
|
|
29
29
|
|
|
30
30
|
```javascript
|
|
31
|
-
|
|
31
|
+
import { Knock } from "@knocklabs/node";
|
|
32
32
|
|
|
33
33
|
const knockClient = new Knock("sk_12345");
|
|
34
34
|
```
|
|
@@ -38,7 +38,7 @@ const knockClient = new Knock("sk_12345");
|
|
|
38
38
|
### Sending notifications (triggering workflows)
|
|
39
39
|
|
|
40
40
|
```javascript
|
|
41
|
-
|
|
41
|
+
import { Knock } from "@knocklabs/node";
|
|
42
42
|
const knockClient = new Knock("sk_12345");
|
|
43
43
|
|
|
44
44
|
// The key of the workflow (from Knock dashboard)
|
|
@@ -62,7 +62,7 @@ await knockClient.workflows.trigger("dinosaurs-loose", {
|
|
|
62
62
|
### Canceling workflows
|
|
63
63
|
|
|
64
64
|
```javascript
|
|
65
|
-
|
|
65
|
+
import { Knock } from "@knocklabs/node";
|
|
66
66
|
const knockClient = new Knock("sk_12345");
|
|
67
67
|
|
|
68
68
|
await knockClient.workflows.cancel("dinosaurs-loose", triggerAlert.id, {
|
|
@@ -74,7 +74,7 @@ await knockClient.workflows.cancel("dinosaurs-loose", triggerAlert.id, {
|
|
|
74
74
|
### Identifying users
|
|
75
75
|
|
|
76
76
|
```javascript
|
|
77
|
-
|
|
77
|
+
import { Knock } from "@knocklabs/node";
|
|
78
78
|
const knockClient = new Knock("sk_12345");
|
|
79
79
|
|
|
80
80
|
await knockClient.users.identify("jhammond", {
|
|
@@ -86,7 +86,7 @@ await knockClient.users.identify("jhammond", {
|
|
|
86
86
|
### Retrieving users
|
|
87
87
|
|
|
88
88
|
```javascript
|
|
89
|
-
|
|
89
|
+
import { Knock } from "@knocklabs/node";
|
|
90
90
|
const knockClient = new Knock("sk_12345");
|
|
91
91
|
|
|
92
92
|
await knockClient.users.get("jhammond");
|
|
@@ -95,7 +95,7 @@ await knockClient.users.get("jhammond");
|
|
|
95
95
|
### Deleting users
|
|
96
96
|
|
|
97
97
|
```javascript
|
|
98
|
-
|
|
98
|
+
import { Knock } from "@knocklabs/node";
|
|
99
99
|
const knockClient = new Knock("sk_12345");
|
|
100
100
|
|
|
101
101
|
await knockClient.users.delete("jhammond");
|
|
@@ -104,7 +104,7 @@ await knockClient.users.delete("jhammond");
|
|
|
104
104
|
### Preferences
|
|
105
105
|
|
|
106
106
|
```javascript
|
|
107
|
-
|
|
107
|
+
import { Knock } from "@knocklabs/node";
|
|
108
108
|
const knockClient = new Knock("sk_12345");
|
|
109
109
|
|
|
110
110
|
// Set an entire preference set
|
|
@@ -124,7 +124,7 @@ const preferences = await knockClient.users.getPreferences("jhammond");
|
|
|
124
124
|
### Getting and setting channel data
|
|
125
125
|
|
|
126
126
|
```javascript
|
|
127
|
-
|
|
127
|
+
import { Knock } from "@knocklabs/node";
|
|
128
128
|
const knockClient = new Knock("sk_12345");
|
|
129
129
|
|
|
130
130
|
// Setting channel data for an APNS
|
|
@@ -139,12 +139,12 @@ await knockClient.users.getChannelData("jhammond", KNOCK_APNS_CHANNEL_ID);
|
|
|
139
139
|
### Slack
|
|
140
140
|
|
|
141
141
|
```javascript
|
|
142
|
-
|
|
142
|
+
import { Knock } from "@knocklabs/node";
|
|
143
143
|
const knockClient = new Knock("sk_12345");
|
|
144
144
|
|
|
145
145
|
const tenantId = "tenant-123";
|
|
146
146
|
const knockSlackChannelId = "7c1e0042-5ef2-411a-a43b-e541acb139ed";
|
|
147
|
-
// An optional object containing the query options passed to Slack:
|
|
147
|
+
// An optional object containing the query options passed to Slack:
|
|
148
148
|
// https://api.slack.com/methods/conversations.list#arg_cursor
|
|
149
149
|
const queryOptions = {
|
|
150
150
|
cursor: null,
|
|
@@ -154,18 +154,21 @@ const queryOptions = {
|
|
|
154
154
|
types: "public_channel",
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
|
|
158
157
|
// Retrieve a list of Slack channels
|
|
159
|
-
const channelsInput = {
|
|
158
|
+
const channelsInput = {
|
|
159
|
+
tenant: tenantId,
|
|
160
|
+
knockChannelId: knockSlackChannelId,
|
|
161
|
+
queryOptions,
|
|
162
|
+
};
|
|
160
163
|
await knockClient.slack.getChannels(channelsInput);
|
|
161
164
|
|
|
162
165
|
// Check Slack connection
|
|
163
|
-
const authInput = { tenant: tenantId, knockChannelId: knockSlackChannelId }
|
|
164
|
-
await knockClient.slack.authCheck(authInput)
|
|
166
|
+
const authInput = { tenant: tenantId, knockChannelId: knockSlackChannelId };
|
|
167
|
+
await knockClient.slack.authCheck(authInput);
|
|
165
168
|
|
|
166
169
|
// Revoke access token
|
|
167
|
-
const revokeInput = { tenant: tenantId, knockChannelId: knockSlackChannelId }
|
|
168
|
-
await knockClient.slack.revokeAccessToken(revokeInput)
|
|
170
|
+
const revokeInput = { tenant: tenantId, knockChannelId: knockSlackChannelId };
|
|
171
|
+
await knockClient.slack.revokeAccessToken(revokeInput);
|
|
169
172
|
```
|
|
170
173
|
|
|
171
174
|
### Signing JWTs
|
|
@@ -175,7 +178,7 @@ When using [enhanced security mode](https://docs.knock.app/client-integration/au
|
|
|
175
178
|
You will need to generate an environment specific signing key in the Knock dashboard under "API Keys", and then enable enhanced security mode for your environment.
|
|
176
179
|
|
|
177
180
|
```javascript
|
|
178
|
-
|
|
181
|
+
import { Knock } from "@knocklabs/node";
|
|
179
182
|
|
|
180
183
|
// When signing user tokens, you do not need to instantiate a Knock client.
|
|
181
184
|
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare enum Grants {
|
|
2
2
|
SlackChannelsRead = "slack/channels_read",
|
|
3
3
|
ChannelDataRead = "channel_data/read",
|
|
4
|
-
ChannelDataWrite = "channel_data/write"
|
|
4
|
+
ChannelDataWrite = "channel_data/write",
|
|
5
|
+
UserFeedRead = "user/feed_read"
|
|
5
6
|
}
|
|
6
7
|
export type TokenGrantOptions = Grants[];
|
|
7
8
|
export type TokenEntity = TenantTokenEntity | UserTokenEntity | ObjectTokenEntity;
|
package/dist/src/knock.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ declare class Knock {
|
|
|
22
22
|
readonly tenants: Tenants;
|
|
23
23
|
readonly slack: Slack;
|
|
24
24
|
constructor(key?: string | undefined, options?: KnockOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Delegate the notify function to the workflows trigger
|
|
27
|
+
*
|
|
28
|
+
* @deprecated use workflows.trigger instead.
|
|
29
|
+
*/
|
|
25
30
|
notify(workflowKey: string, properties: TriggerWorkflowProperties, options?: MethodOptions): Promise<import("./resources/workflows/interfaces").WorkflowRun>;
|
|
26
31
|
/**
|
|
27
32
|
* Generate JWT for authenticating client-side requests (e.g. in-app feeds)
|
package/dist/src/knock.js
CHANGED
|
@@ -54,7 +54,11 @@ class Knock {
|
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Delegate the notify function to the workflows trigger
|
|
59
|
+
*
|
|
60
|
+
* @deprecated use workflows.trigger instead.
|
|
61
|
+
*/
|
|
58
62
|
notify(workflowKey, properties, options) {
|
|
59
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
64
|
return this.workflows.trigger(workflowKey, properties, options);
|
|
@@ -35,6 +35,7 @@ export interface ListMessagesOptions extends PaginationOptions {
|
|
|
35
35
|
status?: MessageStatus[];
|
|
36
36
|
channel_id?: string;
|
|
37
37
|
trigger_data?: Record<string, any>;
|
|
38
|
+
workflow_categories?: String[];
|
|
38
39
|
}
|
|
39
40
|
export interface ListMessageActivitiesOptions extends PaginationOptions {
|
|
40
41
|
trigger_data?: Record<string, any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/node",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"description": "Library for interacting with the Knock API",
|
|
5
5
|
"homepage": "https://github.com/knocklabs/knock-node",
|
|
6
6
|
"author": "@knocklabs",
|
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=17.5.0"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|