@slack/bolt 4.0.0-rc.1 → 4.0.0-rc.2
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 +22 -16
- package/dist/App.d.ts +32 -48
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +174 -86
- package/dist/App.js.map +1 -1
- package/dist/CustomFunction.d.ts +58 -0
- package/dist/CustomFunction.d.ts.map +1 -0
- package/dist/CustomFunction.js +144 -0
- package/dist/CustomFunction.js.map +1 -0
- package/dist/WorkflowStep.d.ts +89 -36
- package/dist/WorkflowStep.d.ts.map +1 -1
- package/dist/WorkflowStep.js +29 -8
- package/dist/WorkflowStep.js.map +1 -1
- package/dist/conversation-store.d.ts +1 -1
- package/dist/conversation-store.d.ts.map +1 -1
- package/dist/conversation-store.js +3 -3
- package/dist/conversation-store.js.map +1 -1
- package/dist/errors.d.ts +19 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +45 -32
- package/dist/errors.js.map +1 -1
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +5 -4
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -9
- package/dist/index.js.map +1 -1
- package/dist/middleware/builtin.d.ts +19 -22
- package/dist/middleware/builtin.d.ts.map +1 -1
- package/dist/middleware/builtin.js +93 -111
- package/dist/middleware/builtin.js.map +1 -1
- package/dist/middleware/process.d.ts +3 -3
- package/dist/middleware/process.d.ts.map +1 -1
- package/dist/middleware/process.js +1 -1
- package/dist/middleware/process.js.map +1 -1
- package/dist/receivers/AwsLambdaReceiver.d.ts +77 -16
- package/dist/receivers/AwsLambdaReceiver.d.ts.map +1 -1
- package/dist/receivers/AwsLambdaReceiver.js +53 -25
- package/dist/receivers/AwsLambdaReceiver.js.map +1 -1
- package/dist/receivers/BufferedIncomingMessage.d.ts +2 -1
- package/dist/receivers/BufferedIncomingMessage.d.ts.map +1 -1
- package/dist/receivers/ExpressReceiver.d.ts +13 -13
- package/dist/receivers/ExpressReceiver.d.ts.map +1 -1
- package/dist/receivers/ExpressReceiver.js +70 -70
- package/dist/receivers/ExpressReceiver.js.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.d.ts +18 -20
- package/dist/receivers/HTTPModuleFunctions.d.ts.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.js +187 -181
- package/dist/receivers/HTTPModuleFunctions.js.map +1 -1
- package/dist/receivers/HTTPReceiver.d.ts +14 -14
- package/dist/receivers/HTTPReceiver.d.ts.map +1 -1
- package/dist/receivers/HTTPReceiver.js +92 -44
- package/dist/receivers/HTTPReceiver.js.map +1 -1
- package/dist/receivers/HTTPResponseAck.d.ts +7 -7
- package/dist/receivers/HTTPResponseAck.d.ts.map +1 -1
- package/dist/receivers/HTTPResponseAck.js +37 -5
- package/dist/receivers/HTTPResponseAck.js.map +1 -1
- package/dist/receivers/ParamsIncomingMessage.d.ts +2 -2
- package/dist/receivers/ParamsIncomingMessage.d.ts.map +1 -1
- package/dist/receivers/SocketModeFunctions.d.ts +3 -5
- package/dist/receivers/SocketModeFunctions.d.ts.map +1 -1
- package/dist/receivers/SocketModeFunctions.js +14 -23
- package/dist/receivers/SocketModeFunctions.js.map +1 -1
- package/dist/receivers/SocketModeReceiver.d.ts +9 -9
- package/dist/receivers/SocketModeReceiver.d.ts.map +1 -1
- package/dist/receivers/SocketModeReceiver.js +29 -21
- package/dist/receivers/SocketModeReceiver.js.map +1 -1
- package/dist/receivers/custom-routes.d.ts +2 -2
- package/dist/receivers/custom-routes.d.ts.map +1 -1
- package/dist/receivers/custom-routes.js +10 -9
- package/dist/receivers/custom-routes.js.map +1 -1
- package/dist/receivers/verify-redirect-opts.d.ts +1 -1
- package/dist/receivers/verify-redirect-opts.d.ts.map +1 -1
- package/dist/receivers/verify-redirect-opts.js +3 -3
- package/dist/receivers/verify-redirect-opts.js.map +1 -1
- package/dist/receivers/verify-request.d.ts +1 -12
- package/dist/receivers/verify-request.d.ts.map +1 -1
- package/dist/receivers/verify-request.js +4 -18
- package/dist/receivers/verify-request.js.map +1 -1
- package/dist/types/actions/block-action.d.ts +17 -17
- package/dist/types/actions/block-action.d.ts.map +1 -1
- package/dist/types/actions/index.d.ts +25 -11
- package/dist/types/actions/index.d.ts.map +1 -1
- package/dist/types/actions/index.js +1 -0
- package/dist/types/actions/index.js.map +1 -1
- package/dist/types/actions/interactive-message.d.ts +3 -3
- package/dist/types/actions/interactive-message.d.ts.map +1 -1
- package/dist/types/actions/workflow-step-edit.d.ts +7 -7
- package/dist/types/actions/workflow-step-edit.d.ts.map +1 -1
- package/dist/types/command/index.d.ts +1 -2
- package/dist/types/command/index.d.ts.map +1 -1
- package/dist/types/events/index.d.ts +26 -24
- package/dist/types/events/index.d.ts.map +1 -1
- package/dist/types/events/index.js +4 -15
- package/dist/types/events/index.js.map +1 -1
- package/dist/types/middleware.d.ts +26 -14
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/middleware.js +3 -0
- package/dist/types/middleware.js.map +1 -1
- package/dist/types/options/index.d.ts +16 -51
- package/dist/types/options/index.d.ts.map +1 -1
- package/dist/types/receiver.d.ts +3 -3
- package/dist/types/receiver.d.ts.map +1 -1
- package/dist/types/shortcuts/global-shortcut.d.ts.map +1 -1
- package/dist/types/shortcuts/index.d.ts +14 -9
- package/dist/types/shortcuts/index.d.ts.map +1 -1
- package/dist/types/shortcuts/message-shortcut.d.ts.map +1 -1
- package/dist/types/utilities.d.ts +27 -18
- package/dist/types/utilities.d.ts.map +1 -1
- package/dist/types/utilities.js +7 -0
- package/dist/types/utilities.js.map +1 -1
- package/dist/types/view/index.d.ts +15 -7
- package/dist/types/view/index.d.ts.map +1 -1
- package/package.json +27 -41
- package/dist/WorkflowFunction.d.ts +0 -63
- package/dist/WorkflowFunction.d.ts.map +0 -1
- package/dist/WorkflowFunction.js +0 -130
- package/dist/WorkflowFunction.js.map +0 -1
- package/dist/receivers/http-utils.d.ts +0 -5
- package/dist/receivers/http-utils.d.ts.map +0 -1
- package/dist/receivers/http-utils.js +0 -19
- package/dist/receivers/http-utils.js.map +0 -1
- package/dist/receivers/render-html-for-install-path.d.ts +0 -3
- package/dist/receivers/render-html-for-install-path.d.ts.map +0 -1
- package/dist/receivers/render-html-for-install-path.js +0 -32
- package/dist/receivers/render-html-for-install-path.js.map +0 -1
- package/dist/types/events/base-events.d.ts +0 -1187
- package/dist/types/events/base-events.d.ts.map +0 -1
- package/dist/types/events/base-events.js +0 -5
- package/dist/types/events/base-events.js.map +0 -1
- package/dist/types/events/message-events.d.ts +0 -348
- package/dist/types/events/message-events.d.ts.map +0 -1
- package/dist/types/events/message-events.js +0 -3
- package/dist/types/events/message-events.js.map +0 -1
- package/dist/types/helpers.d.ts +0 -17
- package/dist/types/helpers.d.ts.map +0 -1
- package/dist/types/helpers.js +0 -3
- package/dist/types/helpers.js.map +0 -1
|
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
6
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
7
|
+
const node_querystring_1 = __importDefault(require("node:querystring"));
|
|
9
8
|
const logger_1 = require("@slack/logger");
|
|
10
9
|
const tsscmp_1 = __importDefault(require("tsscmp"));
|
|
11
10
|
const errors_1 = require("../errors");
|
|
@@ -16,19 +15,35 @@ const errors_1 = require("../errors");
|
|
|
16
15
|
* For OAuth flow endpoints, deploy another Lambda function built with ExpressReceiver.
|
|
17
16
|
*/
|
|
18
17
|
class AwsLambdaReceiver {
|
|
19
|
-
|
|
18
|
+
signingSecret;
|
|
19
|
+
app;
|
|
20
|
+
logger;
|
|
21
|
+
signatureVerification;
|
|
22
|
+
customPropertiesExtractor;
|
|
23
|
+
invalidRequestSignatureHandler;
|
|
24
|
+
constructor({ signingSecret, logger = undefined, logLevel = logger_1.LogLevel.INFO, signatureVerification = true, customPropertiesExtractor = (_) => ({}), invalidRequestSignatureHandler, }) {
|
|
20
25
|
// Initialize instance variables, substituting defaults for each value
|
|
21
26
|
this.signingSecret = signingSecret;
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
this.signatureVerification = signatureVerification;
|
|
28
|
+
this.logger =
|
|
29
|
+
logger ??
|
|
30
|
+
(() => {
|
|
31
|
+
const defaultLogger = new logger_1.ConsoleLogger();
|
|
32
|
+
defaultLogger.setLevel(logLevel);
|
|
33
|
+
return defaultLogger;
|
|
34
|
+
})();
|
|
27
35
|
this.customPropertiesExtractor = customPropertiesExtractor;
|
|
36
|
+
if (invalidRequestSignatureHandler) {
|
|
37
|
+
this.invalidRequestSignatureHandler = invalidRequestSignatureHandler;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.invalidRequestSignatureHandler = this.defaultInvalidRequestSignatureHandler;
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
43
|
init(app) {
|
|
30
44
|
this.app = app;
|
|
31
45
|
}
|
|
46
|
+
// biome-ignore lint/suspicious/noExplicitAny: TODO: what should the REceiver interface here be? probably needs work
|
|
32
47
|
start(..._args) {
|
|
33
48
|
return new Promise((resolve, reject) => {
|
|
34
49
|
try {
|
|
@@ -40,17 +55,18 @@ class AwsLambdaReceiver {
|
|
|
40
55
|
}
|
|
41
56
|
});
|
|
42
57
|
}
|
|
43
|
-
//
|
|
58
|
+
// biome-ignore lint/suspicious/noExplicitAny: TODO: what should the REceiver interface here be? probably needs work
|
|
44
59
|
stop(..._args) {
|
|
45
60
|
return new Promise((resolve, _reject) => {
|
|
46
61
|
resolve();
|
|
47
62
|
});
|
|
48
63
|
}
|
|
49
64
|
toHandler() {
|
|
65
|
+
// biome-ignore lint/suspicious/noExplicitAny: request context can be anything
|
|
50
66
|
return async (awsEvent, _awsContext, _awsCallback) => {
|
|
51
|
-
var _a;
|
|
52
67
|
this.logger.debug(`AWS event: ${JSON.stringify(awsEvent, null, 2)}`);
|
|
53
68
|
const rawBody = this.getRawBody(awsEvent);
|
|
69
|
+
// biome-ignore lint/suspicious/noExplicitAny: request bodies can be anything
|
|
54
70
|
const body = this.parseRequestBody(rawBody, this.getHeaderValue(awsEvent.headers, 'Content-Type'), this.logger);
|
|
55
71
|
// ssl_check (for Slash Commands)
|
|
56
72
|
if (typeof body !== 'undefined' &&
|
|
@@ -59,12 +75,15 @@ class AwsLambdaReceiver {
|
|
|
59
75
|
body.ssl_check != null) {
|
|
60
76
|
return Promise.resolve({ statusCode: 200, body: '' });
|
|
61
77
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
|
|
78
|
+
if (this.signatureVerification) {
|
|
79
|
+
// request signature verification
|
|
80
|
+
const signature = this.getHeaderValue(awsEvent.headers, 'X-Slack-Signature');
|
|
81
|
+
const ts = Number(this.getHeaderValue(awsEvent.headers, 'X-Slack-Request-Timestamp'));
|
|
82
|
+
if (!this.isValidRequestSignature(this.signingSecret, rawBody, signature, ts)) {
|
|
83
|
+
const awsResponse = Promise.resolve({ statusCode: 401, body: '' });
|
|
84
|
+
this.invalidRequestSignatureHandler({ rawBody, signature, ts, awsEvent, awsResponse });
|
|
85
|
+
return awsResponse;
|
|
86
|
+
}
|
|
68
87
|
}
|
|
69
88
|
// url_verification (Events API)
|
|
70
89
|
if (typeof body !== 'undefined' &&
|
|
@@ -87,6 +106,7 @@ class AwsLambdaReceiver {
|
|
|
87
106
|
}
|
|
88
107
|
}, 3001);
|
|
89
108
|
// Structure the ReceiverEvent
|
|
109
|
+
// biome-ignore lint/suspicious/noExplicitAny: request responses can be anything
|
|
90
110
|
let storedResponse;
|
|
91
111
|
const event = {
|
|
92
112
|
body,
|
|
@@ -109,7 +129,7 @@ class AwsLambdaReceiver {
|
|
|
109
129
|
};
|
|
110
130
|
// Send the event to the app for processing
|
|
111
131
|
try {
|
|
112
|
-
await
|
|
132
|
+
await this.app?.processEvent(event);
|
|
113
133
|
if (storedResponse !== undefined) {
|
|
114
134
|
if (typeof storedResponse === 'string') {
|
|
115
135
|
return { statusCode: 200, body: storedResponse };
|
|
@@ -126,11 +146,17 @@ class AwsLambdaReceiver {
|
|
|
126
146
|
this.logger.debug(`Error details: ${err}, storedResponse: ${storedResponse}`);
|
|
127
147
|
return { statusCode: 500, body: 'Internal server error' };
|
|
128
148
|
}
|
|
129
|
-
|
|
149
|
+
let path;
|
|
150
|
+
if ('path' in awsEvent) {
|
|
151
|
+
path = awsEvent.path;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
path = awsEvent.rawPath;
|
|
155
|
+
}
|
|
156
|
+
this.logger.info(`No request handler matched the request: ${path}`);
|
|
130
157
|
return { statusCode: 404, body: '' };
|
|
131
158
|
};
|
|
132
159
|
}
|
|
133
|
-
// eslint-disable-next-line class-methods-use-this
|
|
134
160
|
getRawBody(awsEvent) {
|
|
135
161
|
if (typeof awsEvent.body === 'undefined' || awsEvent.body == null) {
|
|
136
162
|
return '';
|
|
@@ -140,10 +166,10 @@ class AwsLambdaReceiver {
|
|
|
140
166
|
}
|
|
141
167
|
return awsEvent.body;
|
|
142
168
|
}
|
|
143
|
-
//
|
|
169
|
+
// biome-ignore lint/suspicious/noExplicitAny: request bodies can be anything
|
|
144
170
|
parseRequestBody(stringBody, contentType, logger) {
|
|
145
171
|
if (contentType === 'application/x-www-form-urlencoded') {
|
|
146
|
-
const parsedBody =
|
|
172
|
+
const parsedBody = node_querystring_1.default.parse(stringBody);
|
|
147
173
|
if (typeof parsedBody.payload === 'string') {
|
|
148
174
|
return JSON.parse(parsedBody.payload);
|
|
149
175
|
}
|
|
@@ -162,7 +188,6 @@ class AwsLambdaReceiver {
|
|
|
162
188
|
throw e;
|
|
163
189
|
}
|
|
164
190
|
}
|
|
165
|
-
// eslint-disable-next-line class-methods-use-this
|
|
166
191
|
isValidRequestSignature(signingSecret, body, signature, requestTimestamp) {
|
|
167
192
|
if (!signature || !requestTimestamp) {
|
|
168
193
|
return false;
|
|
@@ -173,7 +198,7 @@ class AwsLambdaReceiver {
|
|
|
173
198
|
if (requestTimestamp < fiveMinutesAgo) {
|
|
174
199
|
return false;
|
|
175
200
|
}
|
|
176
|
-
const hmac =
|
|
201
|
+
const hmac = node_crypto_1.default.createHmac('sha256', signingSecret);
|
|
177
202
|
const [version, hash] = signature.split('=');
|
|
178
203
|
hmac.update(`${version}:${requestTimestamp}:${body}`);
|
|
179
204
|
if (!(0, tsscmp_1.default)(hash, hmac.digest('hex'))) {
|
|
@@ -181,11 +206,14 @@ class AwsLambdaReceiver {
|
|
|
181
206
|
}
|
|
182
207
|
return true;
|
|
183
208
|
}
|
|
184
|
-
// eslint-disable-next-line class-methods-use-this
|
|
185
209
|
getHeaderValue(headers, key) {
|
|
186
210
|
const caseInsensitiveKey = Object.keys(headers).find((it) => key.toLowerCase() === it.toLowerCase());
|
|
187
211
|
return caseInsensitiveKey !== undefined ? headers[caseInsensitiveKey] : undefined;
|
|
188
212
|
}
|
|
213
|
+
defaultInvalidRequestSignatureHandler(args) {
|
|
214
|
+
const { signature, ts } = args;
|
|
215
|
+
this.logger.info(`Invalid request signature detected (X-Slack-Signature: ${signature}, X-Slack-Request-Timestamp: ${ts})`);
|
|
216
|
+
}
|
|
189
217
|
}
|
|
190
218
|
exports.default = AwsLambdaReceiver;
|
|
191
219
|
//# sourceMappingURL=AwsLambdaReceiver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AwsLambdaReceiver.js","sourceRoot":"","sources":["../../src/receivers/AwsLambdaReceiver.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AwsLambdaReceiver.js","sourceRoot":"","sources":["../../src/receivers/AwsLambdaRe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EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,cAAc,CAAC,OAA4B,EAAE,GAAW;QAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACrG,OAAO,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpF,CAAC;IAEO,qCAAqC,CAAC,IAAgD;QAC5F,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,0DAA0D,SAAS,gCAAgC,EAAE,GAAG,CACzG,CAAC;IACJ,CAAC;CACF;AAtPD,oCAsPC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import type { IncomingMessage } from 'node:http';
|
|
4
5
|
export interface BufferedIncomingMessage extends IncomingMessage {
|
|
5
6
|
rawBody: Buffer;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BufferedIncomingMessage.d.ts","sourceRoot":"","sources":["../../src/receivers/BufferedIncomingMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BufferedIncomingMessage.d.ts","sourceRoot":"","sources":["../../src/receivers/BufferedIncomingMessage.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import { Server, ServerOptions } from 'http';
|
|
5
|
-
import { Server as HTTPSServer, ServerOptions as HTTPSServerOptions } from 'https';
|
|
6
|
-
import { ListenOptions } from 'net';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import App from '../App';
|
|
11
|
-
import { AnyMiddlewareArgs, Receiver } from '../types';
|
|
12
|
-
import { StringIndexed } from '../types/
|
|
13
|
-
import
|
|
4
|
+
import { type Server, type ServerOptions } from 'node:http';
|
|
5
|
+
import { type Server as HTTPSServer, type ServerOptions as HTTPSServerOptions } from 'node:https';
|
|
6
|
+
import type { ListenOptions } from 'node:net';
|
|
7
|
+
import { LogLevel, type Logger } from '@slack/logger';
|
|
8
|
+
import { type CallbackOptions, type InstallPathOptions, InstallProvider, type InstallProviderOptions, type InstallURLOptions } from '@slack/oauth';
|
|
9
|
+
import { type Request, type Response, type Application, type RequestHandler, type IRouter } from 'express';
|
|
10
|
+
import type App from '../App';
|
|
11
|
+
import type { AnyMiddlewareArgs, Receiver } from '../types';
|
|
12
|
+
import type { StringIndexed } from '../types/utilities';
|
|
13
|
+
import * as httpFunc from './HTTPModuleFunctions';
|
|
14
14
|
export declare const respondToSslCheck: RequestHandler;
|
|
15
15
|
export declare const respondToUrlVerification: RequestHandler;
|
|
16
16
|
export interface ExpressReceiverOptions {
|
|
@@ -32,9 +32,9 @@ export interface ExpressReceiverOptions {
|
|
|
32
32
|
app?: Application;
|
|
33
33
|
router?: IRouter;
|
|
34
34
|
customPropertiesExtractor?: (request: Request) => StringIndexed;
|
|
35
|
-
dispatchErrorHandler?: (args: ReceiverDispatchErrorHandlerArgs) => Promise<void>;
|
|
36
|
-
processEventErrorHandler?: (args: ReceiverProcessEventErrorHandlerArgs) => Promise<boolean>;
|
|
37
|
-
unhandledRequestHandler?: (args: ReceiverUnhandledRequestHandlerArgs) => void;
|
|
35
|
+
dispatchErrorHandler?: (args: httpFunc.ReceiverDispatchErrorHandlerArgs) => Promise<void>;
|
|
36
|
+
processEventErrorHandler?: (args: httpFunc.ReceiverProcessEventErrorHandlerArgs) => Promise<boolean>;
|
|
37
|
+
unhandledRequestHandler?: (args: httpFunc.ReceiverUnhandledRequestHandlerArgs) => void;
|
|
38
38
|
unhandledRequestTimeoutMillis?: number;
|
|
39
39
|
}
|
|
40
40
|
interface InstallerOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressReceiver.d.ts","sourceRoot":"","sources":["../../src/receivers/ExpressReceiver.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ExpressReceiver.d.ts","sourceRoot":"","sources":["../../src/receivers/ExpressReceiver.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAgB,MAAM,WAAW,CAAC;AAE1E,OAAO,EACL,KAAK,MAAM,IAAI,WAAW,EAC1B,KAAK,aAAa,IAAI,kBAAkB,EAEzC,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAiB,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAgB,EACd,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,cAAc,EAEnB,KAAK,OAAO,EACb,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAE9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ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AAW,CAAC,MAAM,CAAC,CAAC,GAClD,cAAc,CAEhB;AAkFD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EAEZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,iBAAiB,CAAC,MAAM,CAAC,CAW3B;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAexE"}
|
|
@@ -27,21 +27,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.buildBodyParserMiddleware = exports.verifySignatureAndParseBody = exports.verifySignatureAndParseRawBody = exports.respondToUrlVerification = exports.respondToSslCheck = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
30
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
31
|
+
const node_http_1 = require("node:http");
|
|
32
|
+
const node_https_1 = require("node:https");
|
|
33
|
+
const node_querystring_1 = __importDefault(require("node:querystring"));
|
|
34
|
+
const logger_1 = require("@slack/logger");
|
|
35
|
+
const oauth_1 = require("@slack/oauth");
|
|
36
36
|
const express_1 = __importStar(require("express"));
|
|
37
37
|
const raw_body_1 = __importDefault(require("raw-body"));
|
|
38
38
|
const tsscmp_1 = __importDefault(require("tsscmp"));
|
|
39
|
-
const logger_1 = require("@slack/logger");
|
|
40
|
-
const oauth_1 = require("@slack/oauth");
|
|
41
39
|
const errors_1 = require("../errors");
|
|
42
|
-
const
|
|
43
|
-
const HTTPModuleFunctions_1 = require("./HTTPModuleFunctions");
|
|
40
|
+
const httpFunc = __importStar(require("./HTTPModuleFunctions"));
|
|
44
41
|
const HTTPResponseAck_1 = require("./HTTPResponseAck");
|
|
42
|
+
const verify_redirect_opts_1 = require("./verify-redirect-opts");
|
|
45
43
|
// Option keys for tls.createServer() and tls.createSecureContext(), exclusive of those for http.createServer()
|
|
46
44
|
const httpsOptionKeys = [
|
|
47
45
|
'ALPNProtocols',
|
|
@@ -77,7 +75,7 @@ const httpsOptionKeys = [
|
|
|
77
75
|
];
|
|
78
76
|
const missingServerErrorDescription = 'The receiver cannot be started because private state was mutated. Please report this to the maintainers.';
|
|
79
77
|
const respondToSslCheck = (req, res, next) => {
|
|
80
|
-
if (req.body
|
|
78
|
+
if (req.body?.ssl_check) {
|
|
81
79
|
res.send();
|
|
82
80
|
return;
|
|
83
81
|
}
|
|
@@ -85,7 +83,7 @@ const respondToSslCheck = (req, res, next) => {
|
|
|
85
83
|
};
|
|
86
84
|
exports.respondToSslCheck = respondToSslCheck;
|
|
87
85
|
const respondToUrlVerification = (req, res, next) => {
|
|
88
|
-
if (req.body
|
|
86
|
+
if (req.body?.type && req.body.type === 'url_verification') {
|
|
89
87
|
res.json({ challenge: req.body.challenge });
|
|
90
88
|
return;
|
|
91
89
|
}
|
|
@@ -96,9 +94,22 @@ exports.respondToUrlVerification = respondToUrlVerification;
|
|
|
96
94
|
* Receives HTTP requests with Events, Slash Commands, and Actions
|
|
97
95
|
*/
|
|
98
96
|
class ExpressReceiver {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
/* Express app */
|
|
98
|
+
app;
|
|
99
|
+
server;
|
|
100
|
+
bolt;
|
|
101
|
+
logger;
|
|
102
|
+
processBeforeResponse;
|
|
103
|
+
signatureVerification;
|
|
104
|
+
router;
|
|
105
|
+
installer = undefined;
|
|
106
|
+
installerOptions;
|
|
107
|
+
customPropertiesExtractor;
|
|
108
|
+
dispatchErrorHandler;
|
|
109
|
+
processEventErrorHandler;
|
|
110
|
+
unhandledRequestHandler;
|
|
111
|
+
unhandledRequestTimeoutMillis;
|
|
112
|
+
constructor({ signingSecret = '', logger = undefined, logLevel = logger_1.LogLevel.INFO, endpoints = { events: '/slack/events' }, processBeforeResponse = false, signatureVerification = true, clientId = undefined, clientSecret = undefined, stateSecret = undefined, redirectUri = undefined, installationStore = undefined, scopes = undefined, installerOptions = {}, app = undefined, router = undefined, customPropertiesExtractor = (_req) => ({}), dispatchErrorHandler = httpFunc.defaultAsyncDispatchErrorHandler, processEventErrorHandler = httpFunc.defaultProcessEventErrorHandler, unhandledRequestHandler = httpFunc.defaultUnhandledRequestHandler, unhandledRequestTimeoutMillis = 3001, }) {
|
|
102
113
|
this.app = app !== undefined ? app : (0, express_1.default)();
|
|
103
114
|
if (typeof logger !== 'undefined') {
|
|
104
115
|
this.logger = logger;
|
|
@@ -108,9 +119,9 @@ class ExpressReceiver {
|
|
|
108
119
|
this.logger.setLevel(logLevel);
|
|
109
120
|
}
|
|
110
121
|
this.signatureVerification = signatureVerification;
|
|
111
|
-
const bodyParser = this.signatureVerification
|
|
112
|
-
buildVerificationBodyParserMiddleware(this.logger, signingSecret)
|
|
113
|
-
buildBodyParserMiddleware(this.logger);
|
|
122
|
+
const bodyParser = this.signatureVerification
|
|
123
|
+
? buildVerificationBodyParserMiddleware(this.logger, signingSecret)
|
|
124
|
+
: buildBodyParserMiddleware(this.logger);
|
|
114
125
|
const expressMiddleware = [
|
|
115
126
|
bodyParser,
|
|
116
127
|
exports.respondToSslCheck,
|
|
@@ -120,9 +131,9 @@ class ExpressReceiver {
|
|
|
120
131
|
this.processBeforeResponse = processBeforeResponse;
|
|
121
132
|
const endpointList = typeof endpoints === 'string' ? [endpoints] : Object.values(endpoints);
|
|
122
133
|
this.router = router !== undefined ? router : (0, express_1.Router)();
|
|
123
|
-
|
|
134
|
+
for (const endpoint of endpointList) {
|
|
124
135
|
this.router.post(endpoint, ...expressMiddleware);
|
|
125
|
-
}
|
|
136
|
+
}
|
|
126
137
|
this.customPropertiesExtractor = customPropertiesExtractor;
|
|
127
138
|
this.dispatchErrorHandler = dispatchErrorHandler;
|
|
128
139
|
this.processEventErrorHandler = processEventErrorHandler;
|
|
@@ -142,7 +153,7 @@ class ExpressReceiver {
|
|
|
142
153
|
stateSecret,
|
|
143
154
|
installationStore,
|
|
144
155
|
logLevel,
|
|
145
|
-
logger,
|
|
156
|
+
logger, // pass logger that was passed in constructor, not one created locally
|
|
146
157
|
directInstall: installerOptions.directInstall,
|
|
147
158
|
stateStore: installerOptions.stateStore,
|
|
148
159
|
stateVerification: installerOptions.stateVerification,
|
|
@@ -150,7 +161,7 @@ class ExpressReceiver {
|
|
|
150
161
|
stateCookieName: installerOptions.stateCookieName,
|
|
151
162
|
stateCookieExpirationSeconds: installerOptions.stateCookieExpirationSeconds,
|
|
152
163
|
renderHtmlForInstallPath: installerOptions.renderHtmlForInstallPath,
|
|
153
|
-
authVersion:
|
|
164
|
+
authVersion: installerOptions.authVersion ?? 'v2',
|
|
154
165
|
clientOptions: installerOptions.clientOptions,
|
|
155
166
|
authorizationUrl: installerOptions.authorizationUrl,
|
|
156
167
|
});
|
|
@@ -158,16 +169,14 @@ class ExpressReceiver {
|
|
|
158
169
|
// create install url options
|
|
159
170
|
const installUrlOptions = {
|
|
160
171
|
metadata: installerOptions.metadata,
|
|
161
|
-
scopes: scopes
|
|
172
|
+
scopes: scopes ?? [],
|
|
162
173
|
userScopes: installerOptions.userScopes,
|
|
163
174
|
redirectUri,
|
|
164
175
|
};
|
|
165
176
|
// Add OAuth routes to receiver
|
|
166
177
|
if (this.installer !== undefined) {
|
|
167
178
|
const { installer } = this;
|
|
168
|
-
const redirectUriPath = installerOptions.redirectUriPath === undefined ?
|
|
169
|
-
'/slack/oauth_redirect' :
|
|
170
|
-
installerOptions.redirectUriPath;
|
|
179
|
+
const redirectUriPath = installerOptions.redirectUriPath === undefined ? '/slack/oauth_redirect' : installerOptions.redirectUriPath;
|
|
171
180
|
const { callbackOptions, stateVerification } = installerOptions;
|
|
172
181
|
this.router.use(redirectUriPath, async (req, res) => {
|
|
173
182
|
try {
|
|
@@ -213,7 +222,6 @@ class ExpressReceiver {
|
|
|
213
222
|
this.app.use(this.router);
|
|
214
223
|
}
|
|
215
224
|
async requestHandler(req, res) {
|
|
216
|
-
var _a;
|
|
217
225
|
const ack = new HTTPResponseAck_1.HTTPResponseAck({
|
|
218
226
|
logger: this.logger,
|
|
219
227
|
processBeforeResponse: this.processBeforeResponse,
|
|
@@ -225,14 +233,14 @@ class ExpressReceiver {
|
|
|
225
233
|
const event = {
|
|
226
234
|
body: req.body,
|
|
227
235
|
ack: ack.bind(),
|
|
228
|
-
retryNum:
|
|
229
|
-
retryReason:
|
|
236
|
+
retryNum: httpFunc.extractRetryNumFromHTTPRequest(req),
|
|
237
|
+
retryReason: httpFunc.extractRetryReasonFromHTTPRequest(req),
|
|
230
238
|
customProperties: this.customPropertiesExtractor(req),
|
|
231
239
|
};
|
|
232
240
|
try {
|
|
233
|
-
await
|
|
241
|
+
await this.bolt?.processEvent(event);
|
|
234
242
|
if (ack.storedResponse !== undefined) {
|
|
235
|
-
|
|
243
|
+
httpFunc.buildContentResponse(res, ack.storedResponse);
|
|
236
244
|
this.logger.debug('stored response sent');
|
|
237
245
|
}
|
|
238
246
|
}
|
|
@@ -255,10 +263,10 @@ class ExpressReceiver {
|
|
|
255
263
|
this.bolt = bolt;
|
|
256
264
|
}
|
|
257
265
|
start(portOrListenOptions, serverOptions = {}) {
|
|
258
|
-
let createServerFn =
|
|
266
|
+
let createServerFn = node_http_1.createServer;
|
|
259
267
|
// Look for HTTPS-specific serverOptions to determine which factory function to use
|
|
260
268
|
if (Object.keys(serverOptions).filter((k) => httpsOptionKeys.includes(k)).length > 0) {
|
|
261
|
-
createServerFn =
|
|
269
|
+
createServerFn = node_https_1.createServer;
|
|
262
270
|
}
|
|
263
271
|
if (this.server !== undefined) {
|
|
264
272
|
return Promise.reject(new errors_1.ReceiverInconsistentStateError('The receiver cannot be started because it was already started.'));
|
|
@@ -301,8 +309,7 @@ class ExpressReceiver {
|
|
|
301
309
|
return Promise.reject(new errors_1.ReceiverInconsistentStateError('The receiver cannot be stopped because it was not started.'));
|
|
302
310
|
}
|
|
303
311
|
return new Promise((resolve, reject) => {
|
|
304
|
-
|
|
305
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.close((error) => {
|
|
312
|
+
this.server?.close((error) => {
|
|
306
313
|
if (error !== undefined) {
|
|
307
314
|
return reject(error);
|
|
308
315
|
}
|
|
@@ -324,19 +331,10 @@ exports.verifySignatureAndParseRawBody = verifySignatureAndParseRawBody;
|
|
|
324
331
|
*/
|
|
325
332
|
function buildVerificationBodyParserMiddleware(logger, signingSecret) {
|
|
326
333
|
return async (req, res, next) => {
|
|
327
|
-
let stringBody;
|
|
328
|
-
// On some environments like GCP (Google Cloud Platform),
|
|
329
|
-
// req.body can be pre-parsed and be passed as req.rawBody here
|
|
330
|
-
const preparsedRawBody = req.rawBody;
|
|
331
|
-
if (preparsedRawBody !== undefined) {
|
|
332
|
-
stringBody = preparsedRawBody.toString();
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
stringBody = (await (0, raw_body_1.default)(req)).toString();
|
|
336
|
-
}
|
|
337
334
|
// *** Parsing body ***
|
|
338
335
|
// As the verification passed, parse the body as an object and assign it to req.body
|
|
339
|
-
|
|
336
|
+
const stringBody = await parseExpressRequestRawBody(req);
|
|
337
|
+
// Following middlewares can expect `req.body` is already parsed.
|
|
340
338
|
try {
|
|
341
339
|
// This handler parses `req.body` or `req.rawBody`(on Google Could Platform)
|
|
342
340
|
// and overwrites `req.body` with the parsed JS object.
|
|
@@ -346,19 +344,20 @@ function buildVerificationBodyParserMiddleware(logger, signingSecret) {
|
|
|
346
344
|
if (error) {
|
|
347
345
|
if (error instanceof errors_1.ReceiverAuthenticityError) {
|
|
348
346
|
logError(logger, 'Request verification failed', error);
|
|
349
|
-
|
|
347
|
+
res.status(401).send();
|
|
348
|
+
return;
|
|
350
349
|
}
|
|
351
350
|
logError(logger, 'Parsing request body failed', error);
|
|
352
|
-
|
|
351
|
+
res.status(400).send();
|
|
352
|
+
return;
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
next();
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
|
+
// biome-ignore lint/suspicious/noExplicitAny: errors can be anything
|
|
358
359
|
function logError(logger, message, error) {
|
|
359
|
-
const logMessage = 'code' in error ?
|
|
360
|
-
`${message} (code: ${error.code}, message: ${error.message})` :
|
|
361
|
-
`${message} (error: ${error})`;
|
|
360
|
+
const logMessage = 'code' in error ? `${message} (code: ${error.code}, message: ${error.message})` : `${message} (error: ${error})`;
|
|
362
361
|
logger.warn(logMessage);
|
|
363
362
|
}
|
|
364
363
|
function verifyRequestSignature(signingSecret, body, signature, requestTimestamp) {
|
|
@@ -366,8 +365,7 @@ function verifyRequestSignature(signingSecret, body, signature, requestTimestamp
|
|
|
366
365
|
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Some headers are missing.');
|
|
367
366
|
}
|
|
368
367
|
const ts = Number(requestTimestamp);
|
|
369
|
-
|
|
370
|
-
if (isNaN(ts)) {
|
|
368
|
+
if (Number.isNaN(ts)) {
|
|
371
369
|
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Timestamp is invalid.');
|
|
372
370
|
}
|
|
373
371
|
// Divide current date to match Slack ts format
|
|
@@ -376,7 +374,7 @@ function verifyRequestSignature(signingSecret, body, signature, requestTimestamp
|
|
|
376
374
|
if (ts < fiveMinutesAgo) {
|
|
377
375
|
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Timestamp is too old.');
|
|
378
376
|
}
|
|
379
|
-
const hmac =
|
|
377
|
+
const hmac = node_crypto_1.default.createHmac('sha256', signingSecret);
|
|
380
378
|
const [version, hash] = signature.split('=');
|
|
381
379
|
hmac.update(`${version}:${ts}:${body}`);
|
|
382
380
|
if (!(0, tsscmp_1.default)(hash, hmac.digest('hex'))) {
|
|
@@ -388,7 +386,9 @@ function verifyRequestSignature(signingSecret, body, signature, requestTimestamp
|
|
|
388
386
|
* - Verify the request signature
|
|
389
387
|
* - Parse `request.body` and assign the successfully parsed object to it.
|
|
390
388
|
*/
|
|
391
|
-
function verifySignatureAndParseBody(signingSecret, body,
|
|
389
|
+
function verifySignatureAndParseBody(signingSecret, body,
|
|
390
|
+
// biome-ignore lint/suspicious/noExplicitAny: TODO: headers should only be of a certain type, but some other functions here expect a more complicated type. revisit to type properly later.
|
|
391
|
+
headers) {
|
|
392
392
|
// *** Request verification ***
|
|
393
393
|
const { 'x-slack-signature': signature, 'x-slack-request-timestamp': requestTimestamp, 'content-type': contentType, } = headers;
|
|
394
394
|
verifyRequestSignature(signingSecret, body, signature, requestTimestamp);
|
|
@@ -397,16 +397,7 @@ function verifySignatureAndParseBody(signingSecret, body, headers) {
|
|
|
397
397
|
exports.verifySignatureAndParseBody = verifySignatureAndParseBody;
|
|
398
398
|
function buildBodyParserMiddleware(logger) {
|
|
399
399
|
return async (req, res, next) => {
|
|
400
|
-
|
|
401
|
-
// On some environments like GCP (Google Cloud Platform),
|
|
402
|
-
// req.body can be pre-parsed and be passed as req.rawBody here
|
|
403
|
-
const preparsedRawBody = req.rawBody;
|
|
404
|
-
if (preparsedRawBody !== undefined) {
|
|
405
|
-
stringBody = preparsedRawBody.toString();
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
stringBody = (await (0, raw_body_1.default)(req)).toString();
|
|
409
|
-
}
|
|
400
|
+
const stringBody = await parseExpressRequestRawBody(req);
|
|
410
401
|
try {
|
|
411
402
|
const { 'content-type': contentType } = req.headers;
|
|
412
403
|
req.body = parseRequestBody(stringBody, contentType);
|
|
@@ -414,17 +405,18 @@ function buildBodyParserMiddleware(logger) {
|
|
|
414
405
|
catch (error) {
|
|
415
406
|
if (error) {
|
|
416
407
|
logError(logger, 'Parsing request body failed', error);
|
|
417
|
-
|
|
408
|
+
res.status(400).send();
|
|
409
|
+
return;
|
|
418
410
|
}
|
|
419
411
|
}
|
|
420
|
-
|
|
412
|
+
next();
|
|
421
413
|
};
|
|
422
414
|
}
|
|
423
415
|
exports.buildBodyParserMiddleware = buildBodyParserMiddleware;
|
|
416
|
+
// biome-ignore lint/suspicious/noExplicitAny: request bodies can be anything
|
|
424
417
|
function parseRequestBody(stringBody, contentType) {
|
|
425
418
|
if (contentType === 'application/x-www-form-urlencoded') {
|
|
426
|
-
|
|
427
|
-
const parsedBody = querystring_1.default.parse(stringBody);
|
|
419
|
+
const parsedBody = node_querystring_1.default.parse(stringBody);
|
|
428
420
|
if (typeof parsedBody.payload === 'string') {
|
|
429
421
|
return JSON.parse(parsedBody.payload);
|
|
430
422
|
}
|
|
@@ -432,4 +424,12 @@ function parseRequestBody(stringBody, contentType) {
|
|
|
432
424
|
}
|
|
433
425
|
return JSON.parse(stringBody);
|
|
434
426
|
}
|
|
427
|
+
// On some environments like GCP (Google Cloud Platform),
|
|
428
|
+
// req.body can be pre-parsed and be passed as req.rawBody
|
|
429
|
+
async function parseExpressRequestRawBody(req) {
|
|
430
|
+
if ('rawBody' in req && req.rawBody) {
|
|
431
|
+
return Promise.resolve(req.rawBody.toString());
|
|
432
|
+
}
|
|
433
|
+
return (await (0, raw_body_1.default)(req)).toString();
|
|
434
|
+
}
|
|
435
435
|
//# sourceMappingURL=ExpressReceiver.js.map
|