@slack/bolt 3.6.0 → 3.7.0
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/LICENSE +1 -1
- package/dist/App.d.ts +4 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +121 -85
- package/dist/App.js.map +1 -1
- package/dist/WorkflowStep.d.ts.map +1 -1
- package/dist/WorkflowStep.js +27 -28
- package/dist/WorkflowStep.js.map +1 -1
- package/dist/conversation-store.d.ts.map +1 -1
- package/dist/conversation-store.js +5 -3
- package/dist/conversation-store.js.map +1 -1
- package/dist/errors.d.ts +9 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +17 -9
- package/dist/errors.js.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +1 -0
- package/dist/helpers.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/builtin.d.ts.map +1 -1
- package/dist/middleware/builtin.js +13 -6
- package/dist/middleware/builtin.js.map +1 -1
- package/dist/middleware/process.d.ts +1 -1
- package/dist/middleware/process.d.ts.map +1 -1
- package/dist/middleware/process.js +1 -2
- package/dist/middleware/process.js.map +1 -1
- package/dist/receivers/AwsLambdaReceiver.d.ts.map +1 -1
- package/dist/receivers/AwsLambdaReceiver.js +10 -19
- package/dist/receivers/AwsLambdaReceiver.js.map +1 -1
- package/dist/receivers/ExpressReceiver.d.ts +17 -7
- package/dist/receivers/ExpressReceiver.d.ts.map +1 -1
- package/dist/receivers/ExpressReceiver.js +162 -87
- package/dist/receivers/ExpressReceiver.js.map +1 -1
- package/dist/receivers/HTTPReceiver.d.ts +13 -1
- package/dist/receivers/HTTPReceiver.d.ts.map +1 -1
- package/dist/receivers/HTTPReceiver.js +147 -74
- package/dist/receivers/HTTPReceiver.js.map +1 -1
- package/dist/receivers/SocketModeReceiver.d.ts +14 -1
- package/dist/receivers/SocketModeReceiver.d.ts.map +1 -1
- package/dist/receivers/SocketModeReceiver.js +90 -38
- package/dist/receivers/SocketModeReceiver.js.map +1 -1
- package/dist/receivers/custom-routes.d.ts +14 -0
- package/dist/receivers/custom-routes.d.ts.map +1 -0
- package/dist/receivers/custom-routes.js +33 -0
- package/dist/receivers/custom-routes.js.map +1 -0
- package/dist/receivers/render-html-for-install-path.d.ts +1 -0
- package/dist/receivers/render-html-for-install-path.d.ts.map +1 -1
- package/dist/receivers/render-html-for-install-path.js +6 -1
- package/dist/receivers/render-html-for-install-path.js.map +1 -1
- package/dist/receivers/verify-redirect-opts.d.ts +7 -0
- package/dist/receivers/verify-redirect-opts.d.ts.map +1 -0
- package/dist/receivers/verify-redirect-opts.js +23 -0
- package/dist/receivers/verify-redirect-opts.js.map +1 -0
- package/dist/receivers/verify-request.d.ts +1 -0
- package/dist/receivers/verify-request.d.ts.map +1 -1
- package/dist/receivers/verify-request.js +8 -4
- package/dist/receivers/verify-request.js.map +1 -1
- package/dist/types/actions/block-action.d.ts.map +1 -1
- package/dist/types/actions/index.d.ts +4 -4
- package/dist/types/actions/index.d.ts.map +1 -1
- package/dist/types/actions/index.js.map +1 -1
- package/dist/types/actions/workflow-step-edit.d.ts.map +1 -1
- package/dist/types/events/base-events.d.ts +5 -5
- package/dist/types/events/base-events.d.ts.map +1 -1
- package/dist/types/events/base-events.js.map +1 -1
- package/dist/types/events/index.d.ts +4 -4
- package/dist/types/events/index.d.ts.map +1 -1
- package/dist/types/events/index.js.map +1 -1
- package/dist/types/events/message-events.d.ts.map +1 -1
- package/dist/types/helpers.d.ts +2 -2
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/types/options/index.d.ts +2 -2
- package/dist/types/options/index.d.ts.map +1 -1
- package/dist/types/receiver.d.ts.map +1 -1
- package/dist/types/shortcuts/index.d.ts +2 -2
- package/dist/types/shortcuts/index.d.ts.map +1 -1
- package/dist/types/shortcuts/index.js.map +1 -1
- package/dist/types/shortcuts/message-shortcut.d.ts.map +1 -1
- package/dist/types/utilities.d.ts.map +1 -1
- package/package.json +13 -15
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2016-2018 Robots & Pencils
|
|
4
|
-
Copyright (c) 2019 Slack Technologies,
|
|
4
|
+
Copyright (c) 2019- Slack Technologies, LLC
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/App.d.ts
CHANGED
|
@@ -13,10 +13,13 @@ import { CodedError } from './errors';
|
|
|
13
13
|
export interface AppOptions {
|
|
14
14
|
signingSecret?: HTTPReceiverOptions['signingSecret'];
|
|
15
15
|
endpoints?: HTTPReceiverOptions['endpoints'];
|
|
16
|
+
customRoutes?: HTTPReceiverOptions['customRoutes'];
|
|
16
17
|
processBeforeResponse?: HTTPReceiverOptions['processBeforeResponse'];
|
|
18
|
+
signatureVerification?: HTTPReceiverOptions['signatureVerification'];
|
|
17
19
|
clientId?: HTTPReceiverOptions['clientId'];
|
|
18
20
|
clientSecret?: HTTPReceiverOptions['clientSecret'];
|
|
19
21
|
stateSecret?: HTTPReceiverOptions['stateSecret'];
|
|
22
|
+
redirectUri?: HTTPReceiverOptions['redirectUri'];
|
|
20
23
|
installationStore?: HTTPReceiverOptions['installationStore'];
|
|
21
24
|
scopes?: HTTPReceiverOptions['scopes'];
|
|
22
25
|
installerOptions?: HTTPReceiverOptions['installerOptions'];
|
|
@@ -104,7 +107,7 @@ export default class App {
|
|
|
104
107
|
private installerOptions;
|
|
105
108
|
private socketMode;
|
|
106
109
|
private developerMode;
|
|
107
|
-
constructor({ signingSecret, endpoints, agent, clientTls, receiver, convoStore, token, appToken, botId, botUserId, authorize, logger, logLevel, ignoreSelf, clientOptions, processBeforeResponse, clientId, clientSecret, stateSecret, installationStore, scopes, installerOptions, socketMode, developerMode, tokenVerificationEnabled, }?: AppOptions);
|
|
110
|
+
constructor({ signingSecret, endpoints, customRoutes, agent, clientTls, receiver, convoStore, token, appToken, botId, botUserId, authorize, logger, logLevel, ignoreSelf, clientOptions, processBeforeResponse, signatureVerification, clientId, clientSecret, stateSecret, redirectUri, installationStore, scopes, installerOptions, socketMode, developerMode, tokenVerificationEnabled, }?: AppOptions);
|
|
108
111
|
/**
|
|
109
112
|
* Register a new middleware, processed in the order registered.
|
|
110
113
|
*
|
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,KAAK,CAAC;AAE3C,OAAO,EAAE,SAAS,EAA4C,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAiB,MAAM,eAAe,CAAC;AAEhE,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,YAAY,EAAE,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAe7E,OAAO,EAAE,iBAAiB,EAAoC,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EAEX,aAAa,EAKb,aAAa,EACb,WAAW,EAEX,eAAe,EACf,QAAQ,EACR,aAAa,EAUd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,UAAU,EAA0E,MAAM,UAAU,CAAC;AAiB9G,iCAAiC;AACjC,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,EAAE,m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MAAM,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC,EAAE,GACpG,IAAI;IA2BA,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,UAAU,CAAC,0BAA0B,CAAC,EAAE,GAAG,IAAI;IAInG,OAAO,CAAC,MAAM,SAAS,aAAa,GAAG,kBAAkB,EAC9D,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,GAAG,SAAS,EAAE,UAAU,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,EAAE,GAC7D,IAAI;IAEA,OAAO,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa,EACzD,WAAW,EAAE,iBAAiB,EAC9B,GAAG,SAAS,EAAE,UAAU,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,EAAE,GAC7D,IAAI;IAaA,IAAI,CAAC,cAAc,SAAS,eAAe,GAAG,eAAe,EAClE,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,GAAG,SAAS,EAAE,UAAU,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,EAAE,GAClE,IAAI;IACA,IAAI,CAAC,cAAc,SAAS,eAAe,GAAG,eAAe,EAClE,WAAW,EAAE,eAAe,EAC5B,GAAG,SAAS,EAAE,UAAU,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,EAAE,GAClE,IAAI;IA6BA,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAI9C;;OAEG;IACU,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAsP9D;;OAEG;IACH,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/App.js
CHANGED
|
@@ -11,14 +11,21 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
11
11
|
const SocketModeReceiver_1 = __importDefault(require("./receivers/SocketModeReceiver"));
|
|
12
12
|
const HTTPReceiver_1 = __importDefault(require("./receivers/HTTPReceiver"));
|
|
13
13
|
const builtin_1 = require("./middleware/builtin");
|
|
14
|
-
const process_1 = require("./middleware/process");
|
|
14
|
+
const process_1 = __importDefault(require("./middleware/process"));
|
|
15
15
|
const conversation_store_1 = require("./conversation-store");
|
|
16
16
|
const helpers_1 = require("./helpers");
|
|
17
17
|
const errors_1 = require("./errors");
|
|
18
18
|
// eslint-disable-next-line import/order
|
|
19
19
|
const allSettled = require("promise.allsettled"); // eslint-disable-line @typescript-eslint/no-require-imports
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-commonjs
|
|
21
21
|
const packageJson = require('../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
22
|
+
// ----------------------------
|
|
23
|
+
// For listener registration methods
|
|
24
|
+
const validViewTypes = ['view_closed', 'view_submission'];
|
|
25
|
+
// ----------------------------
|
|
26
|
+
// For the constructor
|
|
27
|
+
const tokenUsage = 'Apps used in one workspace should be initialized with a token. Apps used in many workspaces ' +
|
|
28
|
+
'should be initialized with oauth installer or authorize.';
|
|
22
29
|
var logger_2 = require("@slack/logger");
|
|
23
30
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logger_2.LogLevel; } });
|
|
24
31
|
class WebClientPool {
|
|
@@ -39,7 +46,7 @@ class WebClientPool {
|
|
|
39
46
|
* A Slack App
|
|
40
47
|
*/
|
|
41
48
|
class App {
|
|
42
|
-
constructor({ signingSecret = undefined, endpoints = undefined, agent = undefined, clientTls = undefined, receiver = undefined, convoStore = undefined, token = undefined, appToken = undefined, botId = undefined, botUserId = undefined, authorize = undefined, logger = undefined, logLevel = undefined, ignoreSelf = true, clientOptions = undefined, processBeforeResponse = false, clientId = undefined, clientSecret = undefined, stateSecret = undefined, installationStore = undefined, scopes = undefined, installerOptions = undefined, socketMode = undefined, developerMode = false, tokenVerificationEnabled = true, } = {}) {
|
|
49
|
+
constructor({ signingSecret = undefined, endpoints = undefined, customRoutes = undefined, agent = undefined, clientTls = undefined, receiver = undefined, convoStore = undefined, token = undefined, appToken = undefined, botId = undefined, botUserId = undefined, authorize = undefined, logger = undefined, logLevel = undefined, ignoreSelf = true, clientOptions = undefined, processBeforeResponse = false, signatureVerification = true, clientId = undefined, clientSecret = undefined, stateSecret = undefined, redirectUri = undefined, installationStore = undefined, scopes = undefined, installerOptions = undefined, socketMode = undefined, developerMode = false, tokenVerificationEnabled = true, } = {}) {
|
|
43
50
|
// Some payloads don't have teamId anymore. So we use EnterpriseId in those scenarios
|
|
44
51
|
this.clients = {};
|
|
45
52
|
// this.logLevel = logLevel;
|
|
@@ -56,6 +63,7 @@ class App {
|
|
|
56
63
|
// Set logLevel to Info if one wasn't passed in
|
|
57
64
|
this.logLevel = logLevel !== null && logLevel !== void 0 ? logLevel : logger_1.LogLevel.INFO;
|
|
58
65
|
}
|
|
66
|
+
// Set up logger
|
|
59
67
|
if (typeof logger === 'undefined') {
|
|
60
68
|
// Initialize with the default logger
|
|
61
69
|
const consoleLogger = new logger_1.ConsoleLogger();
|
|
@@ -69,6 +77,7 @@ class App {
|
|
|
69
77
|
this.logger.setLevel(this.logLevel);
|
|
70
78
|
}
|
|
71
79
|
this.errorHandler = defaultErrorHandler(this.logger);
|
|
80
|
+
// Set up client options
|
|
72
81
|
this.clientOptions = clientOptions !== undefined ? clientOptions : {};
|
|
73
82
|
if (agent !== undefined && this.clientOptions.agent === undefined) {
|
|
74
83
|
this.clientOptions.agent = agent;
|
|
@@ -81,11 +90,7 @@ class App {
|
|
|
81
90
|
this.clientOptions.logLevel = logLevel;
|
|
82
91
|
}
|
|
83
92
|
else {
|
|
84
|
-
|
|
85
|
-
// If the constructor has both, logLevel is ignored
|
|
86
|
-
this.logger.warn("As `logger` is passed as well, `logLevel` argument won't be used. Set the log level to the `logger` instance instead.");
|
|
87
|
-
}
|
|
88
|
-
// Since v3.4, WebClient starts sharing loggger with App
|
|
93
|
+
// Since v3.4, WebClient starts sharing logger with App
|
|
89
94
|
this.clientOptions.logger = this.logger;
|
|
90
95
|
}
|
|
91
96
|
// The public WebClient instance (app.client)
|
|
@@ -123,8 +128,12 @@ class App {
|
|
|
123
128
|
},
|
|
124
129
|
};
|
|
125
130
|
}
|
|
126
|
-
//
|
|
131
|
+
// Initialize receiver
|
|
127
132
|
if (receiver !== undefined) {
|
|
133
|
+
// Custom receiver
|
|
134
|
+
if (this.socketMode) {
|
|
135
|
+
throw new errors_1.AppInitializationError('receiver cannot be passed when socketMode is set to true');
|
|
136
|
+
}
|
|
128
137
|
this.receiver = receiver;
|
|
129
138
|
}
|
|
130
139
|
else if (this.socketMode) {
|
|
@@ -138,14 +147,16 @@ class App {
|
|
|
138
147
|
clientId,
|
|
139
148
|
clientSecret,
|
|
140
149
|
stateSecret,
|
|
150
|
+
redirectUri,
|
|
141
151
|
installationStore,
|
|
142
152
|
scopes,
|
|
143
153
|
logger,
|
|
144
154
|
logLevel: this.logLevel,
|
|
145
155
|
installerOptions: this.installerOptions,
|
|
156
|
+
customRoutes,
|
|
146
157
|
});
|
|
147
158
|
}
|
|
148
|
-
else if (signingSecret === undefined) {
|
|
159
|
+
else if (signatureVerification && signingSecret === undefined) {
|
|
149
160
|
// No custom receiver
|
|
150
161
|
throw new errors_1.AppInitializationError('Signing secret not found, so could not initialize the default receiver. Set a signing secret or use a ' +
|
|
151
162
|
'custom receiver.');
|
|
@@ -154,12 +165,15 @@ class App {
|
|
|
154
165
|
this.logger.debug('Initializing HTTPReceiver');
|
|
155
166
|
// Create default HTTPReceiver
|
|
156
167
|
this.receiver = new HTTPReceiver_1.default({
|
|
157
|
-
signingSecret,
|
|
168
|
+
signingSecret: signingSecret || '',
|
|
158
169
|
endpoints,
|
|
170
|
+
customRoutes,
|
|
159
171
|
processBeforeResponse,
|
|
172
|
+
signatureVerification,
|
|
160
173
|
clientId,
|
|
161
174
|
clientSecret,
|
|
162
175
|
stateSecret,
|
|
176
|
+
redirectUri,
|
|
163
177
|
installationStore,
|
|
164
178
|
scopes,
|
|
165
179
|
logger,
|
|
@@ -168,8 +182,9 @@ class App {
|
|
|
168
182
|
});
|
|
169
183
|
}
|
|
170
184
|
let usingOauth = false;
|
|
171
|
-
|
|
172
|
-
|
|
185
|
+
const httpReceiver = this.receiver;
|
|
186
|
+
if (httpReceiver.installer !== undefined &&
|
|
187
|
+
httpReceiver.installer.authorize !== undefined) {
|
|
173
188
|
// This supports using the built in HTTPReceiver, declaring your own HTTPReceiver
|
|
174
189
|
// and theoretically, doing a fully custom (non express) receiver that implements OAuth
|
|
175
190
|
usingOauth = true;
|
|
@@ -191,24 +206,25 @@ class App {
|
|
|
191
206
|
throw new errors_1.AppInitializationError(`Both authorize options and oauth installer options provided. ${tokenUsage}`);
|
|
192
207
|
}
|
|
193
208
|
else if (authorize === undefined && usingOauth) {
|
|
194
|
-
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
210
|
+
this.authorize = httpReceiver.installer.authorize;
|
|
195
211
|
}
|
|
196
212
|
else if (authorize !== undefined && !usingOauth) {
|
|
197
213
|
this.authorize = authorize;
|
|
198
214
|
}
|
|
199
215
|
else {
|
|
200
216
|
this.logger.error('Never should have reached this point, please report to the team');
|
|
201
|
-
helpers_1.assertNever();
|
|
217
|
+
(0, helpers_1.assertNever)();
|
|
202
218
|
}
|
|
203
219
|
// Conditionally use a global middleware that ignores events (including messages) that are sent from this app
|
|
204
220
|
if (ignoreSelf) {
|
|
205
|
-
this.use(builtin_1.ignoreSelf());
|
|
221
|
+
this.use((0, builtin_1.ignoreSelf)());
|
|
206
222
|
}
|
|
207
223
|
// Use conversation state global middleware
|
|
208
224
|
if (convoStore !== false) {
|
|
209
225
|
// Use the memory store by default, or another store if provided
|
|
210
226
|
const store = convoStore === undefined ? new conversation_store_1.MemoryStore() : convoStore;
|
|
211
|
-
this.use(conversation_store_1.conversationContext(store));
|
|
227
|
+
this.use((0, conversation_store_1.conversationContext)(store));
|
|
212
228
|
}
|
|
213
229
|
// Should be last to avoid exposing partially initialized app
|
|
214
230
|
this.receiver.init(this);
|
|
@@ -243,6 +259,7 @@ class App {
|
|
|
243
259
|
// TODO: HTTPReceiver['start'] should be the actual receiver's return type
|
|
244
260
|
return this.receiver.start(...args);
|
|
245
261
|
}
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
246
263
|
stop(...args) {
|
|
247
264
|
return this.receiver.stop(...args);
|
|
248
265
|
}
|
|
@@ -263,27 +280,27 @@ class App {
|
|
|
263
280
|
}
|
|
264
281
|
this.listeners.push([
|
|
265
282
|
builtin_1.onlyEvents,
|
|
266
|
-
builtin_1.matchEventType(eventNameOrPattern),
|
|
283
|
+
(0, builtin_1.matchEventType)(eventNameOrPattern),
|
|
267
284
|
...listeners,
|
|
268
285
|
]);
|
|
269
286
|
}
|
|
270
287
|
message(...patternsOrMiddleware) {
|
|
271
288
|
const messageMiddleware = patternsOrMiddleware.map((patternOrMiddleware) => {
|
|
272
289
|
if (typeof patternOrMiddleware === 'string' || util_1.default.types.isRegExp(patternOrMiddleware)) {
|
|
273
|
-
return builtin_1.matchMessage(patternOrMiddleware);
|
|
290
|
+
return (0, builtin_1.matchMessage)(patternOrMiddleware);
|
|
274
291
|
}
|
|
275
292
|
return patternOrMiddleware;
|
|
276
293
|
});
|
|
277
294
|
this.listeners.push([
|
|
278
295
|
builtin_1.onlyEvents,
|
|
279
|
-
builtin_1.matchEventType('message'),
|
|
296
|
+
(0, builtin_1.matchEventType)('message'),
|
|
280
297
|
...messageMiddleware,
|
|
281
298
|
]);
|
|
282
299
|
}
|
|
283
300
|
shortcut(callbackIdOrConstraints, ...listeners) {
|
|
284
|
-
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints)
|
|
285
|
-
|
|
286
|
-
|
|
301
|
+
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints) ?
|
|
302
|
+
{ callback_id: callbackIdOrConstraints } :
|
|
303
|
+
callbackIdOrConstraints;
|
|
287
304
|
// Fail early if the constraints contain invalid keys
|
|
288
305
|
const unknownConstraintKeys = Object.keys(constraints).filter((k) => k !== 'callback_id' && k !== 'type');
|
|
289
306
|
if (unknownConstraintKeys.length > 0) {
|
|
@@ -292,37 +309,37 @@ class App {
|
|
|
292
309
|
}
|
|
293
310
|
this.listeners.push([
|
|
294
311
|
builtin_1.onlyShortcuts,
|
|
295
|
-
builtin_1.matchConstraints(constraints),
|
|
312
|
+
(0, builtin_1.matchConstraints)(constraints),
|
|
296
313
|
...listeners,
|
|
297
314
|
]);
|
|
298
315
|
}
|
|
299
316
|
action(actionIdOrConstraints, ...listeners) {
|
|
300
317
|
// Normalize Constraints
|
|
301
|
-
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints)
|
|
302
|
-
|
|
303
|
-
|
|
318
|
+
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints) ?
|
|
319
|
+
{ action_id: actionIdOrConstraints } :
|
|
320
|
+
actionIdOrConstraints;
|
|
304
321
|
// Fail early if the constraints contain invalid keys
|
|
305
322
|
const unknownConstraintKeys = Object.keys(constraints).filter((k) => k !== 'action_id' && k !== 'block_id' && k !== 'callback_id' && k !== 'type');
|
|
306
323
|
if (unknownConstraintKeys.length > 0) {
|
|
307
324
|
this.logger.error(`Action listener cannot be attached using unknown constraint keys: ${unknownConstraintKeys.join(', ')}`);
|
|
308
325
|
return;
|
|
309
326
|
}
|
|
310
|
-
this.listeners.push([builtin_1.onlyActions, builtin_1.matchConstraints(constraints), ...listeners]);
|
|
327
|
+
this.listeners.push([builtin_1.onlyActions, (0, builtin_1.matchConstraints)(constraints), ...listeners]);
|
|
311
328
|
}
|
|
312
329
|
command(commandName, ...listeners) {
|
|
313
|
-
this.listeners.push([builtin_1.onlyCommands, builtin_1.matchCommandName(commandName), ...listeners]);
|
|
330
|
+
this.listeners.push([builtin_1.onlyCommands, (0, builtin_1.matchCommandName)(commandName), ...listeners]);
|
|
314
331
|
}
|
|
315
332
|
// TODO: reflect the type in constraits to Source
|
|
316
333
|
options(actionIdOrConstraints, ...listeners) {
|
|
317
|
-
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
this.listeners.push([builtin_1.onlyOptions, builtin_1.matchConstraints(constraints), ...listeners]);
|
|
334
|
+
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints) ?
|
|
335
|
+
{ action_id: actionIdOrConstraints } :
|
|
336
|
+
actionIdOrConstraints;
|
|
337
|
+
this.listeners.push([builtin_1.onlyOptions, (0, builtin_1.matchConstraints)(constraints), ...listeners]);
|
|
321
338
|
}
|
|
322
339
|
view(callbackIdOrConstraints, ...listeners) {
|
|
323
|
-
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints)
|
|
324
|
-
|
|
325
|
-
|
|
340
|
+
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints) ?
|
|
341
|
+
{ callback_id: callbackIdOrConstraints, type: 'view_submission' } :
|
|
342
|
+
callbackIdOrConstraints;
|
|
326
343
|
// Fail early if the constraints contain invalid keys
|
|
327
344
|
const unknownConstraintKeys = Object.keys(constraints).filter((k) => k !== 'callback_id' && k !== 'type');
|
|
328
345
|
if (unknownConstraintKeys.length > 0) {
|
|
@@ -335,7 +352,7 @@ class App {
|
|
|
335
352
|
}
|
|
336
353
|
this.listeners.push([
|
|
337
354
|
builtin_1.onlyViewActions,
|
|
338
|
-
builtin_1.matchConstraints(constraints),
|
|
355
|
+
(0, builtin_1.matchConstraints)(constraints),
|
|
339
356
|
...listeners,
|
|
340
357
|
]);
|
|
341
358
|
}
|
|
@@ -356,7 +373,7 @@ class App {
|
|
|
356
373
|
// or even all of the args, as properties of the error. This would give error handling code some ability to deal
|
|
357
374
|
// with "finally" type error situations.
|
|
358
375
|
// Introspect the body to determine what type of incoming event is being handled, and any channel context
|
|
359
|
-
const { type, conversationId } = helpers_1.getTypeAndConversation(body);
|
|
376
|
+
const { type, conversationId } = (0, helpers_1.getTypeAndConversation)(body);
|
|
360
377
|
// If the type could not be determined, warn and exit
|
|
361
378
|
if (type === undefined) {
|
|
362
379
|
this.logger.warn('Could not determine the type of an incoming event. No listeners will be called.');
|
|
@@ -377,9 +394,13 @@ class App {
|
|
|
377
394
|
}
|
|
378
395
|
}
|
|
379
396
|
catch (error) {
|
|
397
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
398
|
+
const e = error;
|
|
380
399
|
this.logger.warn('Authorization of incoming event did not succeed. No listeners will be called.');
|
|
381
|
-
|
|
382
|
-
|
|
400
|
+
e.code = errors_1.ErrorCode.AuthorizationError;
|
|
401
|
+
// disabling due to https://github.com/typescript-eslint/typescript-eslint/issues/1277
|
|
402
|
+
// eslint-disable-next-line consistent-return
|
|
403
|
+
return this.handleError(e);
|
|
383
404
|
}
|
|
384
405
|
// Try to set teamId from AuthorizeResult before using one from source
|
|
385
406
|
if (authorizeResult.teamId === undefined && source.teamId !== undefined) {
|
|
@@ -394,27 +415,43 @@ class App {
|
|
|
394
415
|
const createSay = (channelId) => {
|
|
395
416
|
const token = selectToken(context);
|
|
396
417
|
return (message) => {
|
|
397
|
-
const postMessageArguments = typeof message === 'string'
|
|
398
|
-
|
|
399
|
-
|
|
418
|
+
const postMessageArguments = typeof message === 'string' ?
|
|
419
|
+
{ token, text: message, channel: channelId } :
|
|
420
|
+
{ ...message, token, channel: channelId };
|
|
400
421
|
return this.client.chat.postMessage(postMessageArguments);
|
|
401
422
|
};
|
|
402
423
|
};
|
|
403
|
-
// Set body and payload
|
|
424
|
+
// Set body and payload
|
|
425
|
+
// TODO: this value should eventually conform to AnyMiddlewareArgs
|
|
426
|
+
let payload;
|
|
427
|
+
switch (type) {
|
|
428
|
+
case helpers_1.IncomingEventType.Event:
|
|
429
|
+
payload = bodyArg.event;
|
|
430
|
+
break;
|
|
431
|
+
case helpers_1.IncomingEventType.ViewAction:
|
|
432
|
+
payload = bodyArg.view;
|
|
433
|
+
break;
|
|
434
|
+
case helpers_1.IncomingEventType.Shortcut:
|
|
435
|
+
payload = bodyArg;
|
|
436
|
+
break;
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
438
|
+
// @ts-ignore: Fallthrough case in switch
|
|
439
|
+
case helpers_1.IncomingEventType.Action:
|
|
440
|
+
if (isBlockActionOrInteractiveMessageBody(bodyArg)) {
|
|
441
|
+
const { actions } = bodyArg;
|
|
442
|
+
[payload] = actions;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
// If above conditional does not hit, fall through to fallback payload in default block below
|
|
446
|
+
default:
|
|
447
|
+
payload = bodyArg;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
404
450
|
// NOTE: the following doesn't work because... distributive?
|
|
405
451
|
// const listenerArgs: Partial<AnyMiddlewareArgs> = {
|
|
406
452
|
const listenerArgs = {
|
|
407
453
|
body: bodyArg,
|
|
408
|
-
payload
|
|
409
|
-
? bodyArg.event
|
|
410
|
-
: type === helpers_1.IncomingEventType.ViewAction
|
|
411
|
-
? bodyArg.view
|
|
412
|
-
: type === helpers_1.IncomingEventType.Shortcut
|
|
413
|
-
? bodyArg
|
|
414
|
-
: type === helpers_1.IncomingEventType.Action &&
|
|
415
|
-
isBlockActionOrInteractiveMessageBody(bodyArg)
|
|
416
|
-
? bodyArg.actions[0]
|
|
417
|
-
: bodyArg,
|
|
454
|
+
payload,
|
|
418
455
|
};
|
|
419
456
|
// Set aliases
|
|
420
457
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
@@ -493,7 +530,7 @@ class App {
|
|
|
493
530
|
}
|
|
494
531
|
// Dispatch event through the global middleware chain
|
|
495
532
|
try {
|
|
496
|
-
await process_1.
|
|
533
|
+
await (0, process_1.default)(this.middleware, listenerArgs, context, client, this.logger, async () => {
|
|
497
534
|
// Dispatch the event through the listener middleware chains and aggregate their results
|
|
498
535
|
// TODO: change the name of this.middleware and this.listeners to help this make more sense
|
|
499
536
|
const listenerResults = this.listeners.map(async (origListenerMiddleware) => {
|
|
@@ -501,11 +538,17 @@ class App {
|
|
|
501
538
|
const listenerMiddleware = [...origListenerMiddleware];
|
|
502
539
|
// Don't process the last item in the listenerMiddleware array - it shouldn't get a next fn
|
|
503
540
|
const listener = listenerMiddleware.pop();
|
|
504
|
-
if (listener
|
|
505
|
-
return
|
|
506
|
-
// When the listener middleware chain is done processing, call the listener without a next fn
|
|
507
|
-
listener({ ...listenerArgs, context, client, logger: this.logger }));
|
|
541
|
+
if (listener === undefined) {
|
|
542
|
+
return undefined;
|
|
508
543
|
}
|
|
544
|
+
return (0, process_1.default)(listenerMiddleware, listenerArgs, context, client, this.logger,
|
|
545
|
+
// When the listener middleware chain is done processing, call the listener without a next fn
|
|
546
|
+
async () => listener({
|
|
547
|
+
...listenerArgs,
|
|
548
|
+
context,
|
|
549
|
+
client,
|
|
550
|
+
logger: this.logger,
|
|
551
|
+
}));
|
|
509
552
|
});
|
|
510
553
|
const settledListenerResults = await allSettled(listenerResults);
|
|
511
554
|
const rejectedListenerResults = settledListenerResults.filter((lr) => lr.status === 'rejected');
|
|
@@ -518,21 +561,21 @@ class App {
|
|
|
518
561
|
});
|
|
519
562
|
}
|
|
520
563
|
catch (error) {
|
|
521
|
-
|
|
564
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
565
|
+
const e = error;
|
|
566
|
+
// disabling due to https://github.com/typescript-eslint/typescript-eslint/issues/1277
|
|
567
|
+
// eslint-disable-next-line consistent-return
|
|
568
|
+
return this.handleError(e);
|
|
522
569
|
}
|
|
523
570
|
}
|
|
524
571
|
/**
|
|
525
572
|
* Global error handler. The final destination for all errors (hopefully).
|
|
526
573
|
*/
|
|
527
574
|
handleError(error) {
|
|
528
|
-
return this.errorHandler(errors_1.asCodedError(error));
|
|
575
|
+
return this.errorHandler((0, errors_1.asCodedError)(error));
|
|
529
576
|
}
|
|
530
577
|
}
|
|
531
578
|
exports.default = App;
|
|
532
|
-
// ----------------------------
|
|
533
|
-
// For the constructor
|
|
534
|
-
const tokenUsage = 'Apps used in one workspace should be initialized with a token. Apps used in many workspaces ' +
|
|
535
|
-
'should be initialized with oauth installer or authorize.';
|
|
536
579
|
function defaultErrorHandler(logger) {
|
|
537
580
|
return (error) => {
|
|
538
581
|
logger.error(error);
|
|
@@ -543,14 +586,12 @@ function defaultErrorHandler(logger) {
|
|
|
543
586
|
// singleAuthorization
|
|
544
587
|
function runAuthTestForBotToken(client, authorization) {
|
|
545
588
|
// TODO: warn when something needed isn't found
|
|
546
|
-
return authorization.botUserId !== undefined && authorization.botId !== undefined
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
};
|
|
553
|
-
});
|
|
589
|
+
return authorization.botUserId !== undefined && authorization.botId !== undefined ?
|
|
590
|
+
Promise.resolve({ botUserId: authorization.botUserId, botId: authorization.botId }) :
|
|
591
|
+
client.auth.test({ token: authorization.botToken }).then((result) => ({
|
|
592
|
+
botUserId: result.user_id,
|
|
593
|
+
botId: result.bot_id,
|
|
594
|
+
}));
|
|
554
595
|
}
|
|
555
596
|
async function buildAuthorizeResult(isEnterpriseInstall, authTestResult, authorization) {
|
|
556
597
|
return { isEnterpriseInstall, botToken: authorization.botToken, ...(await authTestResult) };
|
|
@@ -562,9 +603,7 @@ function singleAuthorization(client, authorization, tokenVerificationEnabled) {
|
|
|
562
603
|
if (tokenVerificationEnabled) {
|
|
563
604
|
// call auth.test immediately
|
|
564
605
|
cachedAuthTestResult = runAuthTestForBotToken(client, authorization);
|
|
565
|
-
return async ({ isEnterpriseInstall }) =>
|
|
566
|
-
return buildAuthorizeResult(isEnterpriseInstall, cachedAuthTestResult, authorization);
|
|
567
|
-
};
|
|
606
|
+
return async ({ isEnterpriseInstall }) => buildAuthorizeResult(isEnterpriseInstall, cachedAuthTestResult, authorization);
|
|
568
607
|
}
|
|
569
608
|
return async ({ isEnterpriseInstall }) => {
|
|
570
609
|
// hold off calling auth.test API until the first access to authorize function
|
|
@@ -606,7 +645,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
606
645
|
// This is the only place where this function might return undefined
|
|
607
646
|
return bodyAsActionOrOptionsOrViewActionOrShortcut.user.team_id;
|
|
608
647
|
}
|
|
609
|
-
return helpers_1.assertNever(type);
|
|
648
|
+
return (0, helpers_1.assertNever)(type);
|
|
610
649
|
})();
|
|
611
650
|
const enterpriseId = (() => {
|
|
612
651
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
@@ -638,7 +677,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
638
677
|
}
|
|
639
678
|
return undefined;
|
|
640
679
|
}
|
|
641
|
-
return helpers_1.assertNever(type);
|
|
680
|
+
return (0, helpers_1.assertNever)(type);
|
|
642
681
|
})();
|
|
643
682
|
const userId = (() => {
|
|
644
683
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
@@ -671,7 +710,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
671
710
|
if (type === helpers_1.IncomingEventType.Command) {
|
|
672
711
|
return body.user_id;
|
|
673
712
|
}
|
|
674
|
-
return helpers_1.assertNever(type);
|
|
713
|
+
return (0, helpers_1.assertNever)(type);
|
|
675
714
|
})();
|
|
676
715
|
return {
|
|
677
716
|
userId,
|
|
@@ -706,17 +745,14 @@ function isBlockActionOrInteractiveMessageBody(body) {
|
|
|
706
745
|
function selectToken(context) {
|
|
707
746
|
return context.botToken !== undefined ? context.botToken : context.userToken;
|
|
708
747
|
}
|
|
709
|
-
function buildRespondFn(axiosInstance,
|
|
748
|
+
function buildRespondFn(axiosInstance, responseUrl) {
|
|
710
749
|
return async (message) => {
|
|
711
750
|
const normalizedArgs = typeof message === 'string' ? { text: message } : message;
|
|
712
|
-
return axiosInstance.post(
|
|
751
|
+
return axiosInstance.post(responseUrl, normalizedArgs);
|
|
713
752
|
};
|
|
714
753
|
}
|
|
715
754
|
// ----------------------------
|
|
716
|
-
// For listener registration methods
|
|
717
|
-
const validViewTypes = ['view_closed', 'view_submission'];
|
|
718
|
-
// ----------------------------
|
|
719
755
|
// Instrumentation
|
|
720
756
|
// Don't change the position of the following code
|
|
721
|
-
web_api_1.addAppMetadata({ name: packageJson.name, version: packageJson.version });
|
|
757
|
+
(0, web_api_1.addAppMetadata)({ name: packageJson.name, version: packageJson.version });
|
|
722
758
|
//# sourceMappingURL=App.js.map
|