@vercel/slack-bolt 1.3.1 → 1.4.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/README.md +84 -8
- package/dist/cli.d.mts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +357 -507
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +385 -497
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +181 -90
- package/dist/index.d.ts +181 -90
- package/dist/index.js +491 -367
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +489 -365
- package/dist/index.mjs.map +1 -1
- package/dist/preview-DAWKwXt1.mjs +689 -0
- package/dist/preview-DAWKwXt1.mjs.map +1 -0
- package/dist/preview-DeqpNNn_.js +794 -0
- package/dist/preview-DeqpNNn_.js.map +1 -0
- package/dist/preview.d.mts +47 -44
- package/dist/preview.d.ts +47 -44
- package/dist/preview.js +3 -13
- package/dist/preview.mjs +2 -6
- package/package.json +9 -8
- package/dist/chunk-B5E7QPZP.mjs +0 -11
- package/dist/chunk-B5E7QPZP.mjs.map +0 -1
- package/dist/chunk-F7WJK2MS.mjs +0 -980
- package/dist/chunk-F7WJK2MS.mjs.map +0 -1
- package/dist/chunk-QHMZVK6J.js +0 -14
- package/dist/chunk-QHMZVK6J.js.map +0 -1
- package/dist/chunk-VI33CCYY.js +0 -1003
- package/dist/chunk-VI33CCYY.js.map +0 -1
- package/dist/preview.js.map +0 -1
- package/dist/preview.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ bun add @vercel/slack-bolt
|
|
|
24
24
|
|
|
25
25
|
Responsible for handling and parsing any incoming requests from Slack and then forwarding them to your Bolt app for event processing.
|
|
26
26
|
|
|
27
|
+
This example shows a single-tenant app with a fixed bot token. For multi-tenant apps that need OAuth, see [OAuth](#oauth-multi-tenant-apps) below.
|
|
28
|
+
|
|
27
29
|
```typescript
|
|
28
30
|
import { App } from "@slack/bolt";
|
|
29
31
|
import { VercelReceiver } from "@vercel/slack-bolt";
|
|
@@ -46,19 +48,30 @@ export { app, receiver };
|
|
|
46
48
|
|
|
47
49
|
#### Parameters
|
|
48
50
|
|
|
49
|
-
| Name | Type | Default Value
|
|
50
|
-
| --------------------------- | --------------------------------- |
|
|
51
|
-
| `signingSecret` | `string` | `process.env.SLACK_SIGNING_SECRET`
|
|
52
|
-
| `signatureVerification` | `boolean` | `true`
|
|
53
|
-
| `logger` | `Logger`<sup>2</sup> | `new ConsoleLogger()`
|
|
54
|
-
| `logLevel` | `LogLevel`<sup>2</sup> | `LogLevel.INFO`
|
|
55
|
-
| `customPropertiesExtractor` | `(req: Request) => StringIndexed` | `undefined`
|
|
56
|
-
| `ackTimeoutMs` | `number` | `3001`
|
|
51
|
+
| Name | Type | Default Value | Required | Description |
|
|
52
|
+
| --------------------------- | --------------------------------- | ------------------------------------ | -------------- | ---------------------------------------------------------------------- |
|
|
53
|
+
| `signingSecret` | `string` | `process.env.SLACK_SIGNING_SECRET` | No<sup>1</sup> | Signing secret for your Slack app used to verify requests. |
|
|
54
|
+
| `signatureVerification` | `boolean` | `true` | No | Enable or disable request signature verification. |
|
|
55
|
+
| `logger` | `Logger`<sup>2</sup> | `new ConsoleLogger()` | No | Logger used for diagnostics. |
|
|
56
|
+
| `logLevel` | `LogLevel`<sup>2</sup> | `LogLevel.INFO` | No | Minimum log level for the logger. |
|
|
57
|
+
| `customPropertiesExtractor` | `(req: Request) => StringIndexed` | `undefined` | No | Return value is merged into Bolt event `customProperties`<sup>2</sup>. |
|
|
58
|
+
| `ackTimeoutMs` | `number` | `3001` | No | Milliseconds to wait for `ack()` before returning a timeout error. |
|
|
59
|
+
| `clientId` | `string` | `process.env.SLACK_CLIENT_ID` | No<sup>3</sup> | Your app's client ID (required for OAuth). |
|
|
60
|
+
| `clientSecret` | `string` | `process.env.SLACK_CLIENT_SECRET` | No<sup>3</sup> | Your app's client secret (required for OAuth). |
|
|
61
|
+
| `stateSecret` | `string` | `process.env.SLACK_STATE_SECRET` | No<sup>3</sup> | Secret for OAuth CSRF state parameter. |
|
|
62
|
+
| `scopes` | `string[]` | `undefined` | No | Bot scopes to request during the OAuth flow. |
|
|
63
|
+
| `redirectUri` | `string` | `undefined` | No | Redirect URI registered with your Slack app. |
|
|
64
|
+
| `installationStore` | `InstallationStore`<sup>2</sup> | `undefined` | No<sup>4</sup> | Persistent storage backend for OAuth installations. |
|
|
65
|
+
| `installerOptions` | `VercelInstallerOptions` | `{}` | No | Advanced OAuth options (user scopes, direct install, state store, etc). |
|
|
57
66
|
|
|
58
67
|
<sup>1</sup> Optional if `process.env.SLACK_SIGNING_SECRET` is provided.
|
|
59
68
|
|
|
60
69
|
<sup>2</sup> Provided by the [`@slack/bolt`](https://www.npmjs.com/package/@slack/bolt) library. More information [here](https://docs.slack.dev/tools/bolt-js/reference#app-options).
|
|
61
70
|
|
|
71
|
+
<sup>3</sup> Required for OAuth. Read from `process.env` automatically if not provided.
|
|
72
|
+
|
|
73
|
+
<sup>4</sup> Required for OAuth in serverless environments -- the default in-memory store does not persist across cold starts.
|
|
74
|
+
|
|
62
75
|
### `createHandler`
|
|
63
76
|
|
|
64
77
|
A function that returns a Vercel-compatible request handler that will initialize and start your Bolt app to process the event.
|
|
@@ -81,6 +94,69 @@ export const POST = createHandler(app, receiver);
|
|
|
81
94
|
|
|
82
95
|
<sup>1</sup> Provided by the [`@slack/bolt`](https://www.npmjs.com/package/@slack/bolt) library. More information [here](https://docs.slack.dev/tools/bolt-js/reference#app-options).
|
|
83
96
|
|
|
97
|
+
## OAuth (Multi-Tenant Apps)
|
|
98
|
+
|
|
99
|
+
`VercelReceiver` has built-in support for Slack's [OAuth v2 flow](https://docs.slack.dev/authentication/installing-with-oauth), allowing your app to be installed by multiple workspaces. For background on how OAuth works with Bolt, see the [Bolt OAuth guide](https://slack.dev/bolt-js/concepts/authenticating-oauth).
|
|
100
|
+
|
|
101
|
+
### Environment variables
|
|
102
|
+
|
|
103
|
+
Set these in your Vercel project (or `.env.local` for local development):
|
|
104
|
+
|
|
105
|
+
| Variable | Description |
|
|
106
|
+
| --------------------- | -------------------------------------------------------- |
|
|
107
|
+
| `SLACK_CLIENT_ID` | App client ID, found under **Basic Information** on [api.slack.com](https://api.slack.com/apps). |
|
|
108
|
+
| `SLACK_CLIENT_SECRET` | App client secret, found in the same section. |
|
|
109
|
+
| `SLACK_STATE_SECRET` | A random string used to sign the OAuth state parameter. |
|
|
110
|
+
| `SLACK_SIGNING_SECRET`| Signing secret for verifying incoming Slack requests. |
|
|
111
|
+
|
|
112
|
+
All four are read from `process.env` automatically.
|
|
113
|
+
|
|
114
|
+
### Receiver setup
|
|
115
|
+
|
|
116
|
+
When using OAuth, the receiver manages token retrieval via the `installationStore` -- you no longer pass `token` or `signingSecret` to the `App` constructor.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { App } from "@slack/bolt";
|
|
120
|
+
import { VercelReceiver } from "@vercel/slack-bolt";
|
|
121
|
+
|
|
122
|
+
const receiver = new VercelReceiver({
|
|
123
|
+
scopes: ["chat:write", "commands"],
|
|
124
|
+
installationStore: myInstallationStore,
|
|
125
|
+
installerOptions: {
|
|
126
|
+
directInstall: true,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const app = new App({
|
|
131
|
+
receiver,
|
|
132
|
+
deferInitialization: true,
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Route handlers
|
|
137
|
+
|
|
138
|
+
Expose two GET routes for the OAuth flow. The paths can be anything -- just make sure the callback path matches the **Redirect URL** in your Slack app settings.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// app/api/slack/install/route.ts
|
|
142
|
+
import { receiver } from "@/bolt/app";
|
|
143
|
+
|
|
144
|
+
export const GET = receiver.handleInstall;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// app/api/slack/oauth-redirect/route.ts
|
|
149
|
+
import { receiver } from "@/bolt/app";
|
|
150
|
+
|
|
151
|
+
export const GET = receiver.handleCallback;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Installation store
|
|
155
|
+
|
|
156
|
+
An `installationStore` is required in serverless environments. The default in-memory store does not survive cold starts, so each new function invocation would lose all installation data.
|
|
157
|
+
|
|
158
|
+
Your store must implement `storeInstallation`, `fetchInstallation`, and optionally `deleteInstallation`. Any persistent backend works (Redis, PostgreSQL, DynamoDB, etc). See the [Bolt InstallationStore docs](https://slack.dev/bolt-js/concepts/authenticating-oauth#the-installation-store) for the full interface, and the [Next.js example](https://github.com/vercel-labs/slack-bolt/tree/examples/examples/nextjs) for a working Redis implementation.
|
|
159
|
+
|
|
84
160
|
### `preview`
|
|
85
161
|
|
|
86
162
|
Programmatic API for creating and configuring a Slack app for a Vercel preview deployment. This is the function that powers the `vercel-slack build` CLI. Imported from `@vercel/slack-bolt/preview`.
|
package/dist/cli.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|