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