@slack/bolt 3.4.1 → 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/README.md +7 -2
- package/dist/App.d.ts +4 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +122 -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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- 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 +82 -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 +15 -17
- package/dist/ExpressReceiver.d.ts +0 -59
- package/dist/ExpressReceiver.d.ts.map +0 -1
- package/dist/ExpressReceiver.js +0 -293
- package/dist/ExpressReceiver.js.map +0 -1
- package/dist/SocketModeReceiver.d.ts +0 -43
- package/dist/SocketModeReceiver.d.ts.map +0 -1
- package/dist/SocketModeReceiver.js +0 -129
- package/dist/SocketModeReceiver.js.map +0 -1
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/README.md
CHANGED
|
@@ -100,7 +100,7 @@ In addition to the [`client` property passed to listeners](#making-things-happen
|
|
|
100
100
|
|
|
101
101
|
### Acknowledging events
|
|
102
102
|
|
|
103
|
-
Some types of events need to be acknowledged in order to ensure a consistent user experience inside the Slack client (web, mobile, and desktop apps). This includes all action, shortcut, view, command, and options requests. Listeners for these events need to call the `ack()` function, which is passed in as an argument.
|
|
103
|
+
Some types of events need to be acknowledged in order to ensure a consistent user experience inside the Slack client (web, mobile, and desktop apps). This includes all action, shortcut, view, command, and options requests. Listeners for these events need to call the `ack()` function, which is passed in as an argument.
|
|
104
104
|
|
|
105
105
|
In general, the Slack platform expects an acknowledgement within 3 seconds, so listeners should call this function as soon as possible.
|
|
106
106
|
|
|
@@ -114,7 +114,7 @@ Depending on the type of incoming event a listener is meant for, `ack()` should
|
|
|
114
114
|
|
|
115
115
|
* Legacy message button clicks, menu selections, and slash commands: Either call `ack()` with no parameters, a `string` to to update the message with a simple message, or an `object` to replace it with a complex message. Replacing the message to remove the interactive elements is a best practice for any action that should only be performed once.
|
|
116
116
|
|
|
117
|
-
* Events API events **do not** need an `ack()` function since they are automatically acknowledged by your app.
|
|
117
|
+
* Events API events **do not** need an `ack()` function since they are automatically acknowledged by your app.
|
|
118
118
|
|
|
119
119
|
## Getting Help
|
|
120
120
|
|
|
@@ -124,3 +124,8 @@ If you otherwise get stuck, we're here to help. The following are the best ways
|
|
|
124
124
|
|
|
125
125
|
* [Issue Tracker](http://github.com/slackapi/bolt-js/issues) for questions, bug reports, feature requests, and general discussion related to Bolt for JavaScript. Try searching for an existing issue before creating a new one.
|
|
126
126
|
* [Email](mailto:support@slack.com) our developer support team: `support@slack.com`
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
We welcome contributions from everyone! Please check out our
|
|
130
|
+
[Contributor's Guide](.github/contributing.md) for how to contribute in a
|
|
131
|
+
helpful and collaborative way.
|
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,EAC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P9D;;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);
|
|
@@ -240,8 +256,10 @@ class App {
|
|
|
240
256
|
* @param args receiver-specific start arguments
|
|
241
257
|
*/
|
|
242
258
|
start(...args) {
|
|
259
|
+
// TODO: HTTPReceiver['start'] should be the actual receiver's return type
|
|
243
260
|
return this.receiver.start(...args);
|
|
244
261
|
}
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
245
263
|
stop(...args) {
|
|
246
264
|
return this.receiver.stop(...args);
|
|
247
265
|
}
|
|
@@ -262,27 +280,27 @@ class App {
|
|
|
262
280
|
}
|
|
263
281
|
this.listeners.push([
|
|
264
282
|
builtin_1.onlyEvents,
|
|
265
|
-
builtin_1.matchEventType(eventNameOrPattern),
|
|
283
|
+
(0, builtin_1.matchEventType)(eventNameOrPattern),
|
|
266
284
|
...listeners,
|
|
267
285
|
]);
|
|
268
286
|
}
|
|
269
287
|
message(...patternsOrMiddleware) {
|
|
270
288
|
const messageMiddleware = patternsOrMiddleware.map((patternOrMiddleware) => {
|
|
271
289
|
if (typeof patternOrMiddleware === 'string' || util_1.default.types.isRegExp(patternOrMiddleware)) {
|
|
272
|
-
return builtin_1.matchMessage(patternOrMiddleware);
|
|
290
|
+
return (0, builtin_1.matchMessage)(patternOrMiddleware);
|
|
273
291
|
}
|
|
274
292
|
return patternOrMiddleware;
|
|
275
293
|
});
|
|
276
294
|
this.listeners.push([
|
|
277
295
|
builtin_1.onlyEvents,
|
|
278
|
-
builtin_1.matchEventType('message'),
|
|
296
|
+
(0, builtin_1.matchEventType)('message'),
|
|
279
297
|
...messageMiddleware,
|
|
280
298
|
]);
|
|
281
299
|
}
|
|
282
300
|
shortcut(callbackIdOrConstraints, ...listeners) {
|
|
283
|
-
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints)
|
|
284
|
-
|
|
285
|
-
|
|
301
|
+
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints) ?
|
|
302
|
+
{ callback_id: callbackIdOrConstraints } :
|
|
303
|
+
callbackIdOrConstraints;
|
|
286
304
|
// Fail early if the constraints contain invalid keys
|
|
287
305
|
const unknownConstraintKeys = Object.keys(constraints).filter((k) => k !== 'callback_id' && k !== 'type');
|
|
288
306
|
if (unknownConstraintKeys.length > 0) {
|
|
@@ -291,37 +309,37 @@ class App {
|
|
|
291
309
|
}
|
|
292
310
|
this.listeners.push([
|
|
293
311
|
builtin_1.onlyShortcuts,
|
|
294
|
-
builtin_1.matchConstraints(constraints),
|
|
312
|
+
(0, builtin_1.matchConstraints)(constraints),
|
|
295
313
|
...listeners,
|
|
296
314
|
]);
|
|
297
315
|
}
|
|
298
316
|
action(actionIdOrConstraints, ...listeners) {
|
|
299
317
|
// Normalize Constraints
|
|
300
|
-
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints)
|
|
301
|
-
|
|
302
|
-
|
|
318
|
+
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints) ?
|
|
319
|
+
{ action_id: actionIdOrConstraints } :
|
|
320
|
+
actionIdOrConstraints;
|
|
303
321
|
// Fail early if the constraints contain invalid keys
|
|
304
322
|
const unknownConstraintKeys = Object.keys(constraints).filter((k) => k !== 'action_id' && k !== 'block_id' && k !== 'callback_id' && k !== 'type');
|
|
305
323
|
if (unknownConstraintKeys.length > 0) {
|
|
306
324
|
this.logger.error(`Action listener cannot be attached using unknown constraint keys: ${unknownConstraintKeys.join(', ')}`);
|
|
307
325
|
return;
|
|
308
326
|
}
|
|
309
|
-
this.listeners.push([builtin_1.onlyActions, builtin_1.matchConstraints(constraints), ...listeners]);
|
|
327
|
+
this.listeners.push([builtin_1.onlyActions, (0, builtin_1.matchConstraints)(constraints), ...listeners]);
|
|
310
328
|
}
|
|
311
329
|
command(commandName, ...listeners) {
|
|
312
|
-
this.listeners.push([builtin_1.onlyCommands, builtin_1.matchCommandName(commandName), ...listeners]);
|
|
330
|
+
this.listeners.push([builtin_1.onlyCommands, (0, builtin_1.matchCommandName)(commandName), ...listeners]);
|
|
313
331
|
}
|
|
314
332
|
// TODO: reflect the type in constraits to Source
|
|
315
333
|
options(actionIdOrConstraints, ...listeners) {
|
|
316
|
-
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
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]);
|
|
320
338
|
}
|
|
321
339
|
view(callbackIdOrConstraints, ...listeners) {
|
|
322
|
-
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints)
|
|
323
|
-
|
|
324
|
-
|
|
340
|
+
const constraints = typeof callbackIdOrConstraints === 'string' || util_1.default.types.isRegExp(callbackIdOrConstraints) ?
|
|
341
|
+
{ callback_id: callbackIdOrConstraints, type: 'view_submission' } :
|
|
342
|
+
callbackIdOrConstraints;
|
|
325
343
|
// Fail early if the constraints contain invalid keys
|
|
326
344
|
const unknownConstraintKeys = Object.keys(constraints).filter((k) => k !== 'callback_id' && k !== 'type');
|
|
327
345
|
if (unknownConstraintKeys.length > 0) {
|
|
@@ -334,7 +352,7 @@ class App {
|
|
|
334
352
|
}
|
|
335
353
|
this.listeners.push([
|
|
336
354
|
builtin_1.onlyViewActions,
|
|
337
|
-
builtin_1.matchConstraints(constraints),
|
|
355
|
+
(0, builtin_1.matchConstraints)(constraints),
|
|
338
356
|
...listeners,
|
|
339
357
|
]);
|
|
340
358
|
}
|
|
@@ -355,7 +373,7 @@ class App {
|
|
|
355
373
|
// or even all of the args, as properties of the error. This would give error handling code some ability to deal
|
|
356
374
|
// with "finally" type error situations.
|
|
357
375
|
// Introspect the body to determine what type of incoming event is being handled, and any channel context
|
|
358
|
-
const { type, conversationId } = helpers_1.getTypeAndConversation(body);
|
|
376
|
+
const { type, conversationId } = (0, helpers_1.getTypeAndConversation)(body);
|
|
359
377
|
// If the type could not be determined, warn and exit
|
|
360
378
|
if (type === undefined) {
|
|
361
379
|
this.logger.warn('Could not determine the type of an incoming event. No listeners will be called.');
|
|
@@ -376,9 +394,13 @@ class App {
|
|
|
376
394
|
}
|
|
377
395
|
}
|
|
378
396
|
catch (error) {
|
|
397
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
398
|
+
const e = error;
|
|
379
399
|
this.logger.warn('Authorization of incoming event did not succeed. No listeners will be called.');
|
|
380
|
-
|
|
381
|
-
|
|
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);
|
|
382
404
|
}
|
|
383
405
|
// Try to set teamId from AuthorizeResult before using one from source
|
|
384
406
|
if (authorizeResult.teamId === undefined && source.teamId !== undefined) {
|
|
@@ -393,27 +415,43 @@ class App {
|
|
|
393
415
|
const createSay = (channelId) => {
|
|
394
416
|
const token = selectToken(context);
|
|
395
417
|
return (message) => {
|
|
396
|
-
const postMessageArguments = typeof message === 'string'
|
|
397
|
-
|
|
398
|
-
|
|
418
|
+
const postMessageArguments = typeof message === 'string' ?
|
|
419
|
+
{ token, text: message, channel: channelId } :
|
|
420
|
+
{ ...message, token, channel: channelId };
|
|
399
421
|
return this.client.chat.postMessage(postMessageArguments);
|
|
400
422
|
};
|
|
401
423
|
};
|
|
402
|
-
// 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
|
+
}
|
|
403
450
|
// NOTE: the following doesn't work because... distributive?
|
|
404
451
|
// const listenerArgs: Partial<AnyMiddlewareArgs> = {
|
|
405
452
|
const listenerArgs = {
|
|
406
453
|
body: bodyArg,
|
|
407
|
-
payload
|
|
408
|
-
? bodyArg.event
|
|
409
|
-
: type === helpers_1.IncomingEventType.ViewAction
|
|
410
|
-
? bodyArg.view
|
|
411
|
-
: type === helpers_1.IncomingEventType.Shortcut
|
|
412
|
-
? bodyArg
|
|
413
|
-
: type === helpers_1.IncomingEventType.Action &&
|
|
414
|
-
isBlockActionOrInteractiveMessageBody(bodyArg)
|
|
415
|
-
? bodyArg.actions[0]
|
|
416
|
-
: bodyArg,
|
|
454
|
+
payload,
|
|
417
455
|
};
|
|
418
456
|
// Set aliases
|
|
419
457
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
@@ -492,7 +530,7 @@ class App {
|
|
|
492
530
|
}
|
|
493
531
|
// Dispatch event through the global middleware chain
|
|
494
532
|
try {
|
|
495
|
-
await process_1.
|
|
533
|
+
await (0, process_1.default)(this.middleware, listenerArgs, context, client, this.logger, async () => {
|
|
496
534
|
// Dispatch the event through the listener middleware chains and aggregate their results
|
|
497
535
|
// TODO: change the name of this.middleware and this.listeners to help this make more sense
|
|
498
536
|
const listenerResults = this.listeners.map(async (origListenerMiddleware) => {
|
|
@@ -500,11 +538,17 @@ class App {
|
|
|
500
538
|
const listenerMiddleware = [...origListenerMiddleware];
|
|
501
539
|
// Don't process the last item in the listenerMiddleware array - it shouldn't get a next fn
|
|
502
540
|
const listener = listenerMiddleware.pop();
|
|
503
|
-
if (listener
|
|
504
|
-
return
|
|
505
|
-
// When the listener middleware chain is done processing, call the listener without a next fn
|
|
506
|
-
listener({ ...listenerArgs, context, client, logger: this.logger }));
|
|
541
|
+
if (listener === undefined) {
|
|
542
|
+
return undefined;
|
|
507
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
|
+
}));
|
|
508
552
|
});
|
|
509
553
|
const settledListenerResults = await allSettled(listenerResults);
|
|
510
554
|
const rejectedListenerResults = settledListenerResults.filter((lr) => lr.status === 'rejected');
|
|
@@ -517,21 +561,21 @@ class App {
|
|
|
517
561
|
});
|
|
518
562
|
}
|
|
519
563
|
catch (error) {
|
|
520
|
-
|
|
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);
|
|
521
569
|
}
|
|
522
570
|
}
|
|
523
571
|
/**
|
|
524
572
|
* Global error handler. The final destination for all errors (hopefully).
|
|
525
573
|
*/
|
|
526
574
|
handleError(error) {
|
|
527
|
-
return this.errorHandler(errors_1.asCodedError(error));
|
|
575
|
+
return this.errorHandler((0, errors_1.asCodedError)(error));
|
|
528
576
|
}
|
|
529
577
|
}
|
|
530
578
|
exports.default = App;
|
|
531
|
-
// ----------------------------
|
|
532
|
-
// For the constructor
|
|
533
|
-
const tokenUsage = 'Apps used in one workspace should be initialized with a token. Apps used in many workspaces ' +
|
|
534
|
-
'should be initialized with oauth installer or authorize.';
|
|
535
579
|
function defaultErrorHandler(logger) {
|
|
536
580
|
return (error) => {
|
|
537
581
|
logger.error(error);
|
|
@@ -542,14 +586,12 @@ function defaultErrorHandler(logger) {
|
|
|
542
586
|
// singleAuthorization
|
|
543
587
|
function runAuthTestForBotToken(client, authorization) {
|
|
544
588
|
// TODO: warn when something needed isn't found
|
|
545
|
-
return authorization.botUserId !== undefined && authorization.botId !== undefined
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
};
|
|
552
|
-
});
|
|
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
|
+
}));
|
|
553
595
|
}
|
|
554
596
|
async function buildAuthorizeResult(isEnterpriseInstall, authTestResult, authorization) {
|
|
555
597
|
return { isEnterpriseInstall, botToken: authorization.botToken, ...(await authTestResult) };
|
|
@@ -561,9 +603,7 @@ function singleAuthorization(client, authorization, tokenVerificationEnabled) {
|
|
|
561
603
|
if (tokenVerificationEnabled) {
|
|
562
604
|
// call auth.test immediately
|
|
563
605
|
cachedAuthTestResult = runAuthTestForBotToken(client, authorization);
|
|
564
|
-
return async ({ isEnterpriseInstall }) =>
|
|
565
|
-
return buildAuthorizeResult(isEnterpriseInstall, cachedAuthTestResult, authorization);
|
|
566
|
-
};
|
|
606
|
+
return async ({ isEnterpriseInstall }) => buildAuthorizeResult(isEnterpriseInstall, cachedAuthTestResult, authorization);
|
|
567
607
|
}
|
|
568
608
|
return async ({ isEnterpriseInstall }) => {
|
|
569
609
|
// hold off calling auth.test API until the first access to authorize function
|
|
@@ -605,7 +645,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
605
645
|
// This is the only place where this function might return undefined
|
|
606
646
|
return bodyAsActionOrOptionsOrViewActionOrShortcut.user.team_id;
|
|
607
647
|
}
|
|
608
|
-
return helpers_1.assertNever(type);
|
|
648
|
+
return (0, helpers_1.assertNever)(type);
|
|
609
649
|
})();
|
|
610
650
|
const enterpriseId = (() => {
|
|
611
651
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
@@ -637,7 +677,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
637
677
|
}
|
|
638
678
|
return undefined;
|
|
639
679
|
}
|
|
640
|
-
return helpers_1.assertNever(type);
|
|
680
|
+
return (0, helpers_1.assertNever)(type);
|
|
641
681
|
})();
|
|
642
682
|
const userId = (() => {
|
|
643
683
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
@@ -670,7 +710,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
670
710
|
if (type === helpers_1.IncomingEventType.Command) {
|
|
671
711
|
return body.user_id;
|
|
672
712
|
}
|
|
673
|
-
return helpers_1.assertNever(type);
|
|
713
|
+
return (0, helpers_1.assertNever)(type);
|
|
674
714
|
})();
|
|
675
715
|
return {
|
|
676
716
|
userId,
|
|
@@ -705,17 +745,14 @@ function isBlockActionOrInteractiveMessageBody(body) {
|
|
|
705
745
|
function selectToken(context) {
|
|
706
746
|
return context.botToken !== undefined ? context.botToken : context.userToken;
|
|
707
747
|
}
|
|
708
|
-
function buildRespondFn(axiosInstance,
|
|
748
|
+
function buildRespondFn(axiosInstance, responseUrl) {
|
|
709
749
|
return async (message) => {
|
|
710
750
|
const normalizedArgs = typeof message === 'string' ? { text: message } : message;
|
|
711
|
-
return axiosInstance.post(
|
|
751
|
+
return axiosInstance.post(responseUrl, normalizedArgs);
|
|
712
752
|
};
|
|
713
753
|
}
|
|
714
754
|
// ----------------------------
|
|
715
|
-
// For listener registration methods
|
|
716
|
-
const validViewTypes = ['view_closed', 'view_submission'];
|
|
717
|
-
// ----------------------------
|
|
718
755
|
// Instrumentation
|
|
719
756
|
// Don't change the position of the following code
|
|
720
|
-
web_api_1.addAppMetadata({ name: packageJson.name, version: packageJson.version });
|
|
757
|
+
(0, web_api_1.addAppMetadata)({ name: packageJson.name, version: packageJson.version });
|
|
721
758
|
//# sourceMappingURL=App.js.map
|