@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/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { Receiver, StringIndexed, App } from '@slack/bolt';
2
- import { Logger, LogLevel } from '@slack/logger';
1
+ import { App, Receiver, StringIndexed } from "@slack/bolt";
2
+ import { LogLevel, Logger } from "@slack/logger";
3
+ import { CallbackOptions, InstallPathOptions, InstallProvider, InstallProviderOptions, StateStore } from "@slack/oauth";
3
4
 
5
+ //#region src/index.d.ts
4
6
  /**
5
7
  * A function to handle the request from the Slack app.
6
8
  * @param req - The request from the Slack app.
@@ -15,38 +17,97 @@ type VercelHandler = (req: Request) => Promise<Response>;
15
17
  * @property logLevel - The log level to use for the VercelReceiver.
16
18
  * @property customPropertiesExtractor - A function to extract custom properties from the request.
17
19
  */
20
+ /**
21
+ * Options for customizing the OAuth installer behavior.
22
+ * Mirrors the relevant subset of HTTPReceiverInstallerOptions,
23
+ * excluding path-related options (serverless uses file-based routing).
24
+ */
25
+ interface VercelInstallerOptions {
26
+ directInstall?: boolean;
27
+ renderHtmlForInstallPath?: (url: string) => string;
28
+ stateStore?: StateStore;
29
+ stateVerification?: boolean;
30
+ legacyStateVerification?: boolean;
31
+ stateCookieName?: string;
32
+ stateCookieExpirationSeconds?: number;
33
+ authVersion?: "v1" | "v2";
34
+ clientOptions?: InstallProviderOptions["clientOptions"];
35
+ authorizationUrl?: string;
36
+ metadata?: string;
37
+ userScopes?: string[];
38
+ installPathOptions?: InstallPathOptions;
39
+ callbackOptions?: CallbackOptions;
40
+ }
41
+ /**
42
+ * Configuration options for the VercelReceiver.
43
+ */
18
44
  interface VercelReceiverOptions {
19
- /**
20
- * The signing secret for the Slack app.
21
- * @default process.env.SLACK_SIGNING_SECRET
22
- */
23
- signingSecret?: string;
24
- /**
25
- * If true, verifies the Slack request signature.
26
- * @default true
27
- */
28
- signatureVerification?: boolean;
29
- /**
30
- * The logger to use for the VercelReceiver.
31
- * @default new ConsoleLogger()
32
- */
33
- logger?: Logger;
34
- /**
35
- * The log level to use for the VercelReceiver.
36
- * @default LogLevel.INFO
37
- */
38
- logLevel?: LogLevel;
39
- /**
40
- * A function to extract custom properties from incoming events.
41
- * @default undefined
42
- * @returns An object with custom properties.
43
- */
44
- customPropertiesExtractor?: (req: Request) => StringIndexed;
45
- /**
46
- * The timeout in milliseconds for event acknowledgment.
47
- * @default 3001
48
- */
49
- ackTimeoutMs?: number;
45
+ /**
46
+ * The signing secret for the Slack app.
47
+ * @default process.env.SLACK_SIGNING_SECRET
48
+ */
49
+ signingSecret?: string;
50
+ /**
51
+ * If true, verifies the Slack request signature.
52
+ * @default true
53
+ */
54
+ signatureVerification?: boolean;
55
+ /**
56
+ * The logger to use for the VercelReceiver.
57
+ * @default new ConsoleLogger()
58
+ */
59
+ logger?: Logger;
60
+ /**
61
+ * The log level to use for the VercelReceiver.
62
+ * @default LogLevel.INFO
63
+ */
64
+ logLevel?: LogLevel;
65
+ /**
66
+ * A function to extract custom properties from incoming events.
67
+ * @default undefined
68
+ * @returns An object with custom properties.
69
+ */
70
+ customPropertiesExtractor?: (req: Request) => StringIndexed;
71
+ /**
72
+ * The timeout in milliseconds for event acknowledgment.
73
+ * @default 3001
74
+ */
75
+ ackTimeoutMs?: number;
76
+ /**
77
+ * Your app's client ID, found under Basic Information on api.slack.com.
78
+ * Required for OAuth.
79
+ * @default process.env.SLACK_CLIENT_ID
80
+ */
81
+ clientId?: string;
82
+ /**
83
+ * Your app's client secret, found under Basic Information on api.slack.com.
84
+ * Required for OAuth.
85
+ * @default process.env.SLACK_CLIENT_SECRET
86
+ */
87
+ clientSecret?: string;
88
+ /**
89
+ * Secret used to generate and verify the state parameter for OAuth CSRF protection.
90
+ * Required unless a custom stateStore or stateVerification: false is provided.
91
+ * @default process.env.SLACK_STATE_SECRET
92
+ */
93
+ stateSecret?: string;
94
+ /**
95
+ * The bot scopes to request during the OAuth flow.
96
+ */
97
+ scopes?: string[];
98
+ /**
99
+ * The redirect URI registered with your Slack app for OAuth callbacks.
100
+ */
101
+ redirectUri?: string;
102
+ /**
103
+ * Storage backend for OAuth installations (tokens, team info, etc.).
104
+ * Required for OAuth in serverless -- the default in-memory store does not persist.
105
+ */
106
+ installationStore?: InstallProviderOptions["installationStore"];
107
+ /**
108
+ * Advanced options for the OAuth installer.
109
+ */
110
+ installerOptions?: VercelInstallerOptions;
50
111
  }
51
112
  /**
52
113
  * A Slack Bolt receiver implementation designed for Vercel's serverless environment.
@@ -69,61 +130,90 @@ interface VercelReceiverOptions {
69
130
  *
70
131
  */
71
132
  declare class VercelReceiver implements Receiver {
72
- private readonly signingSecret;
73
- private readonly signatureVerification;
74
- private readonly logger;
75
- private readonly customPropertiesExtractor?;
76
- private readonly ackTimeoutMs;
77
- private app?;
78
- /**
79
- * Gets the logger instance used by this receiver.
80
- * @returns The logger instance
81
- */
82
- getLogger(): Logger;
83
- /**
84
- * Creates a new VercelReceiver instance.
85
- *
86
- * @param options - Configuration options for the receiver
87
- * @throws {VercelReceiverError} When signing secret is not provided
88
- *
89
- * @example
90
- * ```typescript
91
- * const receiver = new VercelReceiver();
92
- * ```
93
- */
94
- constructor({ signingSecret, signatureVerification, logger, logLevel, customPropertiesExtractor, ackTimeoutMs, }?: VercelReceiverOptions);
95
- /**
96
- * Initializes the receiver with a Slack Bolt app instance.
97
- * This method is called automatically by the Bolt framework.
98
- *
99
- * @param app - The Slack Bolt app instance
100
- */
101
- init(app: App): void;
102
- /**
103
- * Starts the receiver and returns a handler function for processing requests.
104
- * This method is called automatically by the Bolt framework.
105
- *
106
- * @returns A handler function that processes incoming Slack requests
107
- */
108
- start(): Promise<VercelHandler>;
109
- /**
110
- * Stops the receiver. This method is called automatically by the Bolt framework.
111
- */
112
- stop(): Promise<void>;
113
- /**
114
- * Creates a handler function that processes incoming Slack requests.
115
- * This is the main entry point for handling Slack events in Vercel.
116
- * It is called automatically by the Bolt framework in the start() method.
117
- *
118
- * @returns A handler function compatible with Vercel's function signature
119
- */
120
- toHandler(): VercelHandler;
121
- private parseRequestBody;
122
- private handleSlackEvent;
123
- private verifyRequest;
124
- private createSlackReceiverEvent;
125
- handleError(error: unknown): Response;
126
- private createScopedLogger;
133
+ private readonly signingSecret;
134
+ private readonly signatureVerification;
135
+ private readonly logger;
136
+ private readonly customPropertiesExtractor?;
137
+ private readonly ackTimeoutMs;
138
+ private app?;
139
+ installer?: InstallProvider;
140
+ private installUrlOptions?;
141
+ private installCallbackOptions?;
142
+ private installPathOptions?;
143
+ private stateVerification?;
144
+ /**
145
+ * Gets the logger instance used by this receiver.
146
+ * @returns The logger instance
147
+ */
148
+ getLogger(): Logger;
149
+ /**
150
+ * Creates a new VercelReceiver instance.
151
+ *
152
+ * @param options - Configuration options for the receiver
153
+ * @throws {VercelReceiverError} When signing secret is not provided
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const receiver = new VercelReceiver();
158
+ * ```
159
+ */
160
+ constructor({
161
+ signingSecret,
162
+ signatureVerification,
163
+ logger,
164
+ logLevel,
165
+ customPropertiesExtractor,
166
+ ackTimeoutMs,
167
+ clientId,
168
+ clientSecret,
169
+ stateSecret,
170
+ scopes,
171
+ redirectUri,
172
+ installationStore,
173
+ installerOptions
174
+ }?: VercelReceiverOptions);
175
+ /**
176
+ * Initializes the receiver with a Slack Bolt app instance.
177
+ * This method is called automatically by the Bolt framework.
178
+ *
179
+ * @param app - The Slack Bolt app instance
180
+ */
181
+ init(app: App): void;
182
+ /**
183
+ * Starts the receiver and returns a handler function for processing requests.
184
+ * This method is called automatically by the Bolt framework.
185
+ *
186
+ * @returns A handler function that processes incoming Slack requests
187
+ */
188
+ start(): Promise<VercelHandler>;
189
+ /**
190
+ * Stops the receiver. This method is called automatically by the Bolt framework.
191
+ */
192
+ stop(): Promise<void>;
193
+ /**
194
+ * Handles requests to the OAuth install path.
195
+ * Renders an "Add to Slack" page or redirects directly to Slack's authorize URL.
196
+ */
197
+ handleInstall: (req: Request) => Promise<Response>;
198
+ /**
199
+ * Handles the OAuth redirect callback from Slack.
200
+ * Exchanges the authorization code for tokens and stores the installation.
201
+ */
202
+ handleCallback: (req: Request) => Promise<Response>;
203
+ /**
204
+ * Creates a handler function that processes incoming Slack requests.
205
+ * This is the main entry point for handling Slack events in Vercel.
206
+ * It is called automatically by the Bolt framework in the start() method.
207
+ *
208
+ * @returns A handler function compatible with Vercel's function signature
209
+ */
210
+ toHandler(): VercelHandler;
211
+ private parseRequestBody;
212
+ private handleSlackEvent;
213
+ private verifyRequest;
214
+ private createSlackReceiverEvent;
215
+ handleError(error: unknown): Response;
216
+ private createScopedLogger;
127
217
  }
128
218
  /**
129
219
  * Creates a Vercel-compatible handler function for a Slack Bolt app.
@@ -150,5 +240,6 @@ declare class VercelReceiver implements Receiver {
150
240
  * @throws {VercelReceiverError} If request processing fails.
151
241
  */
152
242
  declare function createHandler(app: App, receiver: VercelReceiver): VercelHandler;
153
-
154
- export { type VercelHandler, VercelReceiver, type VercelReceiverOptions, createHandler };
243
+ //#endregion
244
+ export { VercelHandler, VercelInstallerOptions, VercelReceiver, VercelReceiverOptions, createHandler };
245
+ //# sourceMappingURL=index.d.ts.map