Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update require -> import #73

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ KNOCK_SIGNING_KEY="S25vY2sga25vY2sh..."
You can also pass the Knock API key in the constructor. The signing key is passed separately to the `signUserToken` method (see below):

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";

const knockClient = new Knock("sk_12345");
```
Expand All @@ -38,7 +38,7 @@ const knockClient = new Knock("sk_12345");
### Sending notifications (triggering workflows)

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

// The key of the workflow (from Knock dashboard)
Expand All @@ -62,7 +62,7 @@ await knockClient.workflows.trigger("dinosaurs-loose", {
### Canceling workflows

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

await knockClient.workflows.cancel("dinosaurs-loose", triggerAlert.id, {
Expand All @@ -74,7 +74,7 @@ await knockClient.workflows.cancel("dinosaurs-loose", triggerAlert.id, {
### Identifying users

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

await knockClient.users.identify("jhammond", {
Expand All @@ -86,7 +86,7 @@ await knockClient.users.identify("jhammond", {
### Retrieving users

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

await knockClient.users.get("jhammond");
Expand All @@ -95,7 +95,7 @@ await knockClient.users.get("jhammond");
### Deleting users

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

await knockClient.users.delete("jhammond");
Expand All @@ -104,7 +104,7 @@ await knockClient.users.delete("jhammond");
### Preferences

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

// Set an entire preference set
Expand All @@ -124,7 +124,7 @@ const preferences = await knockClient.users.getPreferences("jhammond");
### Getting and setting channel data

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

// Setting channel data for an APNS
Expand All @@ -139,12 +139,12 @@ await knockClient.users.getChannelData("jhammond", KNOCK_APNS_CHANNEL_ID);
### Slack

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";
const knockClient = new Knock("sk_12345");

const tenantId = "tenant-123";
const knockSlackChannelId = "7c1e0042-5ef2-411a-a43b-e541acb139ed";
// An optional object containing the query options passed to Slack:
// An optional object containing the query options passed to Slack:
// https://api.slack.com/methods/conversations.list#arg_cursor
const queryOptions = {
cursor: null,
Expand All @@ -154,18 +154,21 @@ const queryOptions = {
types: "public_channel",
};


// Retrieve a list of Slack channels
const channelsInput = { tenant: tenantId, knockChannelId: knockSlackChannelId, queryOptions };
const channelsInput = {
tenant: tenantId,
knockChannelId: knockSlackChannelId,
queryOptions,
};
await knockClient.slack.getChannels(channelsInput);

// Check Slack connection
const authInput = { tenant: tenantId, knockChannelId: knockSlackChannelId }
await knockClient.slack.authCheck(authInput)
const authInput = { tenant: tenantId, knockChannelId: knockSlackChannelId };
await knockClient.slack.authCheck(authInput);

// Revoke access token
const revokeInput = { tenant: tenantId, knockChannelId: knockSlackChannelId }
await knockClient.slack.revokeAccessToken(revokeInput)
const revokeInput = { tenant: tenantId, knockChannelId: knockSlackChannelId };
await knockClient.slack.revokeAccessToken(revokeInput);
```

### Signing JWTs
Expand All @@ -175,7 +178,7 @@ When using [enhanced security mode](https://docs.knock.app/client-integration/au
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.

```javascript
const { Knock } = require("@knocklabs/node");
import { Knock } from "@knocklabs/node";

// When signing user tokens, you do not need to instantiate a Knock client.

Expand Down