@slack/bolt 3.11.3 → 4.0.0-nextGen.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/App.d.ts +57 -27
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +138 -48
- package/dist/App.js.map +1 -1
- package/dist/Manifest.d.ts +5 -0
- package/dist/Manifest.d.ts.map +1 -0
- package/dist/Manifest.js +16 -0
- package/dist/Manifest.js.map +1 -0
- package/dist/SlackFunction-utils.d.ts +4 -0
- package/dist/SlackFunction-utils.d.ts.map +1 -0
- package/dist/SlackFunction-utils.js +27 -0
- package/dist/SlackFunction-utils.js.map +1 -0
- package/dist/SlackFunction.d.ts +181 -0
- package/dist/SlackFunction.d.ts.map +1 -0
- package/dist/SlackFunction.js +418 -0
- package/dist/SlackFunction.js.map +1 -0
- package/dist/Subscription.d.ts +61 -0
- package/dist/Subscription.d.ts.map +1 -0
- package/dist/Subscription.js +169 -0
- package/dist/Subscription.js.map +1 -0
- package/dist/cli/get-hooks.d.ts +2 -0
- package/dist/cli/get-hooks.d.ts.map +1 -0
- package/dist/cli/get-hooks.js +18 -0
- package/dist/cli/get-hooks.js.map +1 -0
- package/dist/cli/get-manifest.d.ts +3 -0
- package/dist/cli/get-manifest.d.ts.map +1 -0
- package/dist/cli/get-manifest.js +16 -0
- package/dist/cli/get-manifest.js.map +1 -0
- package/dist/cli/hook-utils/manifest.d.ts +7 -0
- package/dist/cli/hook-utils/manifest.d.ts.map +1 -0
- package/dist/cli/hook-utils/manifest.js +104 -0
- package/dist/cli/hook-utils/manifest.js.map +1 -0
- package/dist/cli/hook-utils/manifest.spec.d.ts +2 -0
- package/dist/cli/hook-utils/manifest.spec.d.ts.map +1 -0
- package/dist/cli/hook-utils/manifest.spec.js +75 -0
- package/dist/cli/hook-utils/manifest.spec.js.map +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +37 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/start.d.ts +3 -0
- package/dist/cli/start.d.ts.map +1 -0
- package/dist/cli/start.js +40 -0
- package/dist/cli/start.js.map +1 -0
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +25 -1
- package/dist/errors.js.map +1 -1
- package/dist/helpers.d.ts +2 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +8 -0
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/middleware/builtin.d.ts.map +1 -1
- package/dist/middleware/builtin.js +0 -1
- package/dist/middleware/builtin.js.map +1 -1
- package/dist/middleware/process.d.ts.map +1 -1
- package/dist/middleware/process.js.map +1 -1
- package/dist/receivers/ExpressReceiver.d.ts +1 -1
- package/dist/receivers/ExpressReceiver.js +2 -1
- package/dist/receivers/ExpressReceiver.js.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.d.ts.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.js +2 -1
- package/dist/receivers/HTTPModuleFunctions.js.map +1 -1
- package/dist/receivers/HTTPReceiver.js +4 -4
- package/dist/receivers/HTTPReceiver.js.map +1 -1
- package/dist/receivers/SocketModeFunctions.js +2 -1
- package/dist/receivers/SocketModeFunctions.js.map +1 -1
- package/dist/receivers/SocketModeReceiver.js.map +1 -1
- package/dist/receivers/render-html-for-install-path.js +1 -1
- package/dist/receivers/verify-request.d.ts +2 -2
- package/dist/receivers/verify-request.d.ts.map +1 -1
- package/dist/receivers/verify-request.js +6 -5
- package/dist/receivers/verify-request.js.map +1 -1
- package/dist/types/actions/block-action.d.ts +4 -3
- package/dist/types/actions/block-action.d.ts.map +1 -1
- package/dist/types/actions/dialog-action.d.ts +4 -0
- package/dist/types/actions/dialog-action.d.ts.map +1 -1
- package/dist/types/events/base-events.d.ts +32 -2
- 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/message-events.d.ts +37 -1
- package/dist/types/events/message-events.d.ts.map +1 -1
- package/dist/types/functions/index.d.ts +26 -0
- package/dist/types/functions/index.d.ts.map +1 -0
- package/dist/types/functions/index.js +3 -0
- package/dist/types/functions/index.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/middleware.d.ts +25 -5
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/middleware.js.map +1 -1
- package/dist/types/subscription/index.d.ts +80 -0
- package/dist/types/subscription/index.d.ts.map +1 -0
- package/dist/types/subscription/index.js +3 -0
- package/dist/types/subscription/index.js.map +1 -0
- package/dist/types/view/index.d.ts +6 -5
- package/dist/types/view/index.d.ts.map +1 -1
- package/package.json +16 -5
- package/src/cli/get-hooks.js +16 -0
- package/src/cli/get-manifest.js +16 -0
- package/src/cli/hook-utils/manifest.js +114 -0
- package/src/cli/start.js +43 -0
package/README.md
CHANGED
|
@@ -91,8 +91,11 @@ The arguments are grouped into properties of one object, so that it's easier to
|
|
|
91
91
|
```js
|
|
92
92
|
// Reverse all messages the app can hear
|
|
93
93
|
app.message(async ({ message, say }) => {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// Filter out message events with subtypes (see https://api.slack.com/events/message)
|
|
95
|
+
if (message.subtype === undefined || message.subtype === 'bot_message') {
|
|
96
|
+
const reversedText = [...message.text].reverse().join("");
|
|
97
|
+
await say(reversedText);
|
|
98
|
+
}
|
|
96
99
|
});
|
|
97
100
|
```
|
|
98
101
|
|
package/dist/App.d.ts
CHANGED
|
@@ -8,8 +8,11 @@ import SocketModeReceiver from './receivers/SocketModeReceiver';
|
|
|
8
8
|
import HTTPReceiver, { HTTPReceiverOptions } from './receivers/HTTPReceiver';
|
|
9
9
|
import { ConversationStore } from './conversation-store';
|
|
10
10
|
import { WorkflowStep } from './WorkflowStep';
|
|
11
|
+
import { SubscriptionOptions } from './Subscription';
|
|
12
|
+
import { SlackFunction } from './SlackFunction';
|
|
11
13
|
import { Middleware, AnyMiddlewareArgs, SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs, SlackEventMiddlewareArgs, SlackOptionsMiddlewareArgs, SlackShortcutMiddlewareArgs, SlackViewMiddlewareArgs, SlackAction, SlackShortcut, Context, OptionsSource, BlockAction, SlackViewAction, Receiver, ReceiverEvent } from './types';
|
|
12
14
|
import { CodedError } from './errors';
|
|
15
|
+
import { StringIndexed } from './types/helpers';
|
|
13
16
|
/** App initialization options */
|
|
14
17
|
export interface AppOptions {
|
|
15
18
|
signingSecret?: HTTPReceiverOptions['signingSecret'];
|
|
@@ -100,11 +103,11 @@ export interface ExtendedErrorHandler {
|
|
|
100
103
|
}
|
|
101
104
|
export interface AnyErrorHandler extends ErrorHandler, ExtendedErrorHandler {
|
|
102
105
|
}
|
|
103
|
-
declare type MessageEventMiddleware = Middleware<SlackEventMiddlewareArgs<'message'
|
|
106
|
+
declare type MessageEventMiddleware<CustomContext extends StringIndexed = StringIndexed> = Middleware<SlackEventMiddlewareArgs<'message'>, CustomContext>;
|
|
104
107
|
/**
|
|
105
108
|
* A Slack App
|
|
106
109
|
*/
|
|
107
|
-
export default class App {
|
|
110
|
+
export default class App<AppCustomContext extends StringIndexed = StringIndexed> {
|
|
108
111
|
/** Slack Web API client */
|
|
109
112
|
client: WebClient;
|
|
110
113
|
private clientOptions;
|
|
@@ -140,13 +143,7 @@ export default class App {
|
|
|
140
143
|
*
|
|
141
144
|
* @param m global middleware function
|
|
142
145
|
*/
|
|
143
|
-
use(m: Middleware<AnyMiddlewareArgs>): this;
|
|
144
|
-
/**
|
|
145
|
-
* Register WorkflowStep middleware
|
|
146
|
-
*
|
|
147
|
-
* @param workflowStep global workflow step middleware function
|
|
148
|
-
*/
|
|
149
|
-
step(workflowStep: WorkflowStep): this;
|
|
146
|
+
use<MiddlewareCustomContext extends StringIndexed = StringIndexed>(m: Middleware<AnyMiddlewareArgs, AppCustomContext & MiddlewareCustomContext>): this;
|
|
150
147
|
/**
|
|
151
148
|
* Convenience method to call start on the receiver
|
|
152
149
|
*
|
|
@@ -156,20 +153,45 @@ export default class App {
|
|
|
156
153
|
*/
|
|
157
154
|
start(...args: Parameters<HTTPReceiver['start'] | SocketModeReceiver['start']>): ReturnType<HTTPReceiver['start']>;
|
|
158
155
|
stop(...args: any[]): Promise<unknown>;
|
|
159
|
-
event<EventType extends string = string>(eventName: EventType, ...listeners: Middleware<SlackEventMiddlewareArgs<EventType>>[]): void;
|
|
160
|
-
event<EventType extends RegExp = RegExp>(eventName: EventType, ...listeners: Middleware<SlackEventMiddlewareArgs<string>>[]): void;
|
|
161
156
|
/**
|
|
157
|
+
* Register WorkflowStep middleware
|
|
158
|
+
*
|
|
159
|
+
* Not to be confused with next-gen platform Workflows + Functions
|
|
160
|
+
*
|
|
161
|
+
* @param workflowStep global workflow step middleware function
|
|
162
|
+
*/
|
|
163
|
+
step(workflowStep: WorkflowStep): this;
|
|
164
|
+
/**
|
|
165
|
+
* Process a subscription event
|
|
166
|
+
*
|
|
167
|
+
* @param listeners middleware that process and react to subscription payloads
|
|
168
|
+
*/
|
|
169
|
+
subscription(options: SubscriptionOptions): this;
|
|
170
|
+
/**
|
|
171
|
+
* Register an event listener
|
|
172
|
+
*/
|
|
173
|
+
event<EventType extends string = string, MiddlewareCustomContext extends StringIndexed = StringIndexed>(eventName: EventType, ...listeners: Middleware<SlackEventMiddlewareArgs<EventType>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
174
|
+
event<EventType extends RegExp = RegExp, MiddlewareCustomContext extends StringIndexed = StringIndexed>(eventName: EventType, ...listeners: Middleware<SlackEventMiddlewareArgs<string>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
175
|
+
/**
|
|
176
|
+
* Register a Slack Function
|
|
177
|
+
*
|
|
178
|
+
* @param slackFn a main function to register
|
|
179
|
+
*
|
|
180
|
+
* */
|
|
181
|
+
function(slackFn: SlackFunction): void;
|
|
182
|
+
/**
|
|
183
|
+
* Process a message event
|
|
162
184
|
*
|
|
163
185
|
* @param listeners Middlewares that process and react to a message event
|
|
164
186
|
*/
|
|
165
|
-
message(...listeners: MessageEventMiddleware[]): void;
|
|
187
|
+
message<MiddlewareCustomContext extends StringIndexed = StringIndexed>(...listeners: MessageEventMiddleware<AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
166
188
|
/**
|
|
167
189
|
*
|
|
168
190
|
* @param pattern Used for filtering out messages that don't match.
|
|
169
191
|
* Strings match via {@link String.prototype.includes}.
|
|
170
192
|
* @param listeners Middlewares that process and react to the message events that matched the provided patterns.
|
|
171
193
|
*/
|
|
172
|
-
message(pattern: string | RegExp, ...listeners: MessageEventMiddleware[]): void;
|
|
194
|
+
message<MiddlewareCustomContext extends StringIndexed = StringIndexed>(pattern: string | RegExp, ...listeners: MessageEventMiddleware<AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
173
195
|
/**
|
|
174
196
|
*
|
|
175
197
|
* @param filter Middleware that can filter out messages. Generally this is done by returning before
|
|
@@ -178,34 +200,42 @@ export default class App {
|
|
|
178
200
|
* via {@link String.prototype.includes}.
|
|
179
201
|
* @param listeners Middlewares that process and react to the message events that matched the provided pattern.
|
|
180
202
|
*/
|
|
181
|
-
message(filter: MessageEventMiddleware
|
|
203
|
+
message<MiddlewareCustomContext extends StringIndexed = StringIndexed>(filter: MessageEventMiddleware<AppCustomContext & MiddlewareCustomContext>, pattern: string | RegExp, ...listeners: MessageEventMiddleware<AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
182
204
|
/**
|
|
183
205
|
*
|
|
184
206
|
* @param filter Middleware that can filter out messages. Generally this is done by returning before calling
|
|
185
207
|
* {@link AllMiddlewareArgs.next} if there is no match. See {@link directMention} for an example.
|
|
186
208
|
* @param listeners Middlewares that process and react to the message events that matched the provided patterns.
|
|
187
209
|
*/
|
|
188
|
-
message(filter: MessageEventMiddleware, ...listeners: MessageEventMiddleware[]): void;
|
|
210
|
+
message<MiddlewareCustomContext extends StringIndexed = StringIndexed>(filter: MessageEventMiddleware, ...listeners: MessageEventMiddleware<AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
189
211
|
/**
|
|
190
212
|
* This allows for further control of the filtering and response logic. Patterns and middlewares are processed in
|
|
191
213
|
* the order provided. If any patterns do not match, or a middleware does not call {@link AllMiddlewareArgs.next},
|
|
192
214
|
* all remaining patterns and middlewares will be skipped.
|
|
193
215
|
* @param patternsOrMiddleware A mix of patterns and/or middlewares.
|
|
194
216
|
*/
|
|
195
|
-
message(...patternsOrMiddleware: (string | RegExp | MessageEventMiddleware)[]): void;
|
|
196
|
-
|
|
197
|
-
|
|
217
|
+
message<MiddlewareCustomContext extends StringIndexed = StringIndexed>(...patternsOrMiddleware: (string | RegExp | MessageEventMiddleware<AppCustomContext & MiddlewareCustomContext>)[]): void;
|
|
218
|
+
/**
|
|
219
|
+
* Process a shortcut event
|
|
220
|
+
*/
|
|
221
|
+
shortcut<Shortcut extends SlackShortcut = SlackShortcut, MiddlewareCustomContext extends StringIndexed = StringIndexed>(callbackId: string | RegExp, ...listeners: Middleware<SlackShortcutMiddlewareArgs<Shortcut>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
222
|
+
shortcut<Shortcut extends SlackShortcut = SlackShortcut, Constraints extends ShortcutConstraints<Shortcut> = ShortcutConstraints<Shortcut>, MiddlewareCustomContext extends StringIndexed = StringIndexed>(constraints: Constraints, ...listeners: Middleware<SlackShortcutMiddlewareArgs<Extract<Shortcut, {
|
|
198
223
|
type: Constraints['type'];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
224
|
+
}>>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
225
|
+
/**
|
|
226
|
+
* Process a block_action event
|
|
227
|
+
* https://api.slack.com/reference/interaction-payloads/block-actions
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
action<Action extends SlackAction = SlackAction, MiddlewareCustomContext extends StringIndexed = StringIndexed>(actionId: string | RegExp, ...listeners: Middleware<SlackActionMiddlewareArgs<Action>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
231
|
+
action<Action extends SlackAction = SlackAction, Constraints extends ActionConstraints<Action> = ActionConstraints<Action>, MiddlewareCustomContext extends StringIndexed = StringIndexed>(constraints: Constraints, ...listeners: Middleware<SlackActionMiddlewareArgs<Extract<Action, {
|
|
202
232
|
type: Constraints['type'];
|
|
203
|
-
}
|
|
204
|
-
command(commandName: string | RegExp, ...listeners: Middleware<SlackCommandMiddlewareArgs>[]): void;
|
|
205
|
-
options<Source extends OptionsSource = 'block_suggestion'>(actionId: string | RegExp, ...listeners: Middleware<SlackOptionsMiddlewareArgs<Source
|
|
206
|
-
options<Source extends OptionsSource = OptionsSource>(constraints: ActionConstraints, ...listeners: Middleware<SlackOptionsMiddlewareArgs<Source
|
|
207
|
-
view<ViewActionType extends SlackViewAction = SlackViewAction>(callbackId: string | RegExp, ...listeners: Middleware<SlackViewMiddlewareArgs<ViewActionType
|
|
208
|
-
view<ViewActionType extends SlackViewAction = SlackViewAction>(constraints: ViewConstraints, ...listeners: Middleware<SlackViewMiddlewareArgs<ViewActionType
|
|
233
|
+
}>>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
234
|
+
command<MiddlewareCustomContext extends StringIndexed = StringIndexed>(commandName: string | RegExp, ...listeners: Middleware<SlackCommandMiddlewareArgs, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
235
|
+
options<Source extends OptionsSource = 'block_suggestion', MiddlewareCustomContext extends StringIndexed = StringIndexed>(actionId: string | RegExp, ...listeners: Middleware<SlackOptionsMiddlewareArgs<Source>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
236
|
+
options<Source extends OptionsSource = OptionsSource, MiddlewareCustomContext extends StringIndexed = StringIndexed>(constraints: ActionConstraints, ...listeners: Middleware<SlackOptionsMiddlewareArgs<Source>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
237
|
+
view<ViewActionType extends SlackViewAction = SlackViewAction, MiddlewareCustomContext extends StringIndexed = StringIndexed>(callbackId: string | RegExp, ...listeners: Middleware<SlackViewMiddlewareArgs<ViewActionType>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
238
|
+
view<ViewActionType extends SlackViewAction = SlackViewAction, MiddlewareCustomContext extends StringIndexed = StringIndexed>(constraints: ViewConstraints, ...listeners: Middleware<SlackViewMiddlewareArgs<ViewActionType>, AppCustomContext & MiddlewareCustomContext>[]): void;
|
|
209
239
|
error(errorHandler: ErrorHandler): void;
|
|
210
240
|
error(errorHandler: ExtendedErrorHandler): void;
|
|
211
241
|
/**
|
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,EAAE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ver"));
|
|
|
13
13
|
const builtin_1 = require("./middleware/builtin");
|
|
14
14
|
const process_1 = __importDefault(require("./middleware/process"));
|
|
15
15
|
const conversation_store_1 = require("./conversation-store");
|
|
16
|
+
const Subscription_1 = require("./Subscription");
|
|
16
17
|
const helpers_1 = require("./helpers");
|
|
17
18
|
const errors_1 = require("./errors");
|
|
18
19
|
const middleware_1 = require("./types/middleware");
|
|
@@ -21,6 +22,10 @@ const allSettled = require("promise.allsettled"); // eslint-disable-line @typesc
|
|
|
21
22
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-commonjs
|
|
22
23
|
const packageJson = require('../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
23
24
|
// ----------------------------
|
|
25
|
+
// For CLI local run use case
|
|
26
|
+
const cliAppTokenOverride = process.env.SLACK_CLI_XAPP;
|
|
27
|
+
const cliBotTokenOverride = process.env.SLACK_CLI_XOXB;
|
|
28
|
+
// ----------------------------
|
|
24
29
|
// For listener registration methods
|
|
25
30
|
const validViewTypes = ['view_closed', 'view_submission'];
|
|
26
31
|
// ----------------------------
|
|
@@ -48,12 +53,11 @@ class WebClientPool {
|
|
|
48
53
|
*/
|
|
49
54
|
class App {
|
|
50
55
|
constructor({ signingSecret = undefined, endpoints = undefined, port = 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, extendedErrorHandler = false, deferInitialization = false, } = {}) {
|
|
51
|
-
// this.logLevel = logLevel;
|
|
52
56
|
// Some payloads don't have teamId anymore. So we use EnterpriseId in those scenarios
|
|
53
57
|
this.clients = {};
|
|
54
58
|
/* ------------------------ Developer mode ----------------------------- */
|
|
55
59
|
this.developerMode = developerMode;
|
|
56
|
-
if (developerMode) {
|
|
60
|
+
if (developerMode || cliAppTokenOverride) {
|
|
57
61
|
// Set logLevel to Debug in Developer Mode if one wasn't passed in
|
|
58
62
|
this.logLevel = logLevel !== null && logLevel !== void 0 ? logLevel : logger_1.LogLevel.DEBUG;
|
|
59
63
|
// Set SocketMode to true if one wasn't passed in
|
|
@@ -100,12 +104,12 @@ class App {
|
|
|
100
104
|
}
|
|
101
105
|
// The public WebClient instance (app.client)
|
|
102
106
|
// Since v3.4, it can have the passed token in the case of single workspace installation.
|
|
103
|
-
this.client = new web_api_1.WebClient(token, this.clientOptions);
|
|
107
|
+
this.client = new web_api_1.WebClient(cliBotTokenOverride || token, this.clientOptions);
|
|
104
108
|
this.axios = axios_1.default.create({
|
|
105
109
|
httpAgent: agent,
|
|
106
110
|
httpsAgent: agent,
|
|
107
111
|
// disabling axios' automatic proxy support:
|
|
108
|
-
// axios would read from
|
|
112
|
+
// axios would read from env vars to configure a proxy automatically, but it doesn't support TLS destinations.
|
|
109
113
|
// for compatibility with https://api.slack.com, and for a larger set of possible proxies (SOCKS or other
|
|
110
114
|
// protocols), users of this package should use the `agent` option to configure a proxy.
|
|
111
115
|
proxy: false,
|
|
@@ -120,7 +124,7 @@ class App {
|
|
|
120
124
|
};
|
|
121
125
|
if (socketMode && port !== undefined && this.installerOptions.port === undefined) {
|
|
122
126
|
// SocketModeReceiver only uses a custom port number when listening for the OAuth flow.
|
|
123
|
-
// Therefore only installerOptions.port is available in the constructor arguments.
|
|
127
|
+
// Therefore, only installerOptions.port is available in the constructor arguments.
|
|
124
128
|
this.installerOptions.port = port;
|
|
125
129
|
}
|
|
126
130
|
if (this.developerMode &&
|
|
@@ -138,7 +142,7 @@ class App {
|
|
|
138
142
|
},
|
|
139
143
|
};
|
|
140
144
|
}
|
|
141
|
-
this.receiver = this.initReceiver(receiver, signingSecret, endpoints, port, customRoutes, processBeforeResponse, signatureVerification, clientId, clientSecret, stateSecret, redirectUri, installationStore, scopes, appToken, logger);
|
|
145
|
+
this.receiver = this.initReceiver(receiver, signingSecret, endpoints, port, customRoutes, processBeforeResponse, signatureVerification, clientId, clientSecret, stateSecret, redirectUri, installationStore, scopes, cliAppTokenOverride || appToken, logger);
|
|
142
146
|
/* ------------------------ Set authorize ----------------------------- */
|
|
143
147
|
this.tokenVerificationEnabled = tokenVerificationEnabled;
|
|
144
148
|
let argAuthorization;
|
|
@@ -149,7 +153,15 @@ class App {
|
|
|
149
153
|
botToken: token,
|
|
150
154
|
};
|
|
151
155
|
}
|
|
156
|
+
if (cliBotTokenOverride !== undefined) {
|
|
157
|
+
argAuthorization = {
|
|
158
|
+
botId,
|
|
159
|
+
botUserId,
|
|
160
|
+
botToken: cliBotTokenOverride,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
152
163
|
if (deferInitialization) {
|
|
164
|
+
// TODO: Deal with this
|
|
153
165
|
this.argToken = token;
|
|
154
166
|
this.argAuthorize = authorize;
|
|
155
167
|
this.argAuthorization = argAuthorization;
|
|
@@ -157,7 +169,7 @@ class App {
|
|
|
157
169
|
// You need to run `await app.init();` on your own
|
|
158
170
|
}
|
|
159
171
|
else {
|
|
160
|
-
this.authorize = this.initAuthorizeInConstructor(token, authorize, argAuthorization);
|
|
172
|
+
this.authorize = this.initAuthorizeInConstructor(cliBotTokenOverride || token, authorize, argAuthorization);
|
|
161
173
|
this.initialized = true;
|
|
162
174
|
}
|
|
163
175
|
// Conditionally use a global middleware that ignores events (including messages) that are sent from this app
|
|
@@ -217,16 +229,6 @@ class App {
|
|
|
217
229
|
this.middleware.push(m);
|
|
218
230
|
return this;
|
|
219
231
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Register WorkflowStep middleware
|
|
222
|
-
*
|
|
223
|
-
* @param workflowStep global workflow step middleware function
|
|
224
|
-
*/
|
|
225
|
-
step(workflowStep) {
|
|
226
|
-
const m = workflowStep.getMiddleware();
|
|
227
|
-
this.middleware.push(m);
|
|
228
|
-
return this;
|
|
229
|
-
}
|
|
230
232
|
/**
|
|
231
233
|
* Convenience method to call start on the receiver
|
|
232
234
|
*
|
|
@@ -245,6 +247,34 @@ class App {
|
|
|
245
247
|
stop(...args) {
|
|
246
248
|
return this.receiver.stop(...args);
|
|
247
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Register WorkflowStep middleware
|
|
252
|
+
*
|
|
253
|
+
* Not to be confused with next-gen platform Workflows + Functions
|
|
254
|
+
*
|
|
255
|
+
* @param workflowStep global workflow step middleware function
|
|
256
|
+
*/
|
|
257
|
+
step(workflowStep) {
|
|
258
|
+
const m = workflowStep.getMiddleware();
|
|
259
|
+
this.middleware.push(m);
|
|
260
|
+
return this;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Process a subscription event
|
|
264
|
+
*
|
|
265
|
+
* @param listeners middleware that process and react to subscription payloads
|
|
266
|
+
*/
|
|
267
|
+
subscription(options) {
|
|
268
|
+
/*
|
|
269
|
+
* TODO If it becomes possible for users to set a custom unique resource id,
|
|
270
|
+
* custom id should be supplied in place of the default.
|
|
271
|
+
* */
|
|
272
|
+
const defaultId = 'DEFAULTID';
|
|
273
|
+
const s = new Subscription_1.Subscription(defaultId, options);
|
|
274
|
+
const m = s.getMiddleware();
|
|
275
|
+
this.middleware.push(m);
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
248
278
|
event(eventNameOrPattern, ...listeners) {
|
|
249
279
|
let invalidEventName = false;
|
|
250
280
|
if (typeof eventNameOrPattern === 'string') {
|
|
@@ -268,6 +298,16 @@ class App {
|
|
|
268
298
|
..._listeners,
|
|
269
299
|
]);
|
|
270
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Register a Slack Function
|
|
303
|
+
*
|
|
304
|
+
* @param slackFn a main function to register
|
|
305
|
+
*
|
|
306
|
+
* */
|
|
307
|
+
function(slackFn) {
|
|
308
|
+
const m = slackFn.getMiddleware();
|
|
309
|
+
this.middleware.push(m);
|
|
310
|
+
}
|
|
271
311
|
message(...patternsOrMiddleware) {
|
|
272
312
|
const messageMiddleware = patternsOrMiddleware.map((patternOrMiddleware) => {
|
|
273
313
|
if (typeof patternOrMiddleware === 'string' || util_1.default.types.isRegExp(patternOrMiddleware)) {
|
|
@@ -324,7 +364,7 @@ class App {
|
|
|
324
364
|
..._listeners,
|
|
325
365
|
]);
|
|
326
366
|
}
|
|
327
|
-
// TODO: reflect the type in
|
|
367
|
+
// TODO: reflect the type in constraints to Source
|
|
328
368
|
options(actionIdOrConstraints, ...listeners) {
|
|
329
369
|
const constraints = typeof actionIdOrConstraints === 'string' || util_1.default.types.isRegExp(actionIdOrConstraints) ?
|
|
330
370
|
{ action_id: actionIdOrConstraints } :
|
|
@@ -384,6 +424,7 @@ class App {
|
|
|
384
424
|
// Check if type event with the authorizations object or if it has a top level is_enterprise_install property
|
|
385
425
|
const isEnterpriseInstall = isBodyWithTypeEnterpriseInstall(bodyArg, type);
|
|
386
426
|
const source = buildSource(type, conversationId, bodyArg, isEnterpriseInstall);
|
|
427
|
+
// Get the result of any custom authorize provided
|
|
387
428
|
let authorizeResult;
|
|
388
429
|
if (type === helpers_1.IncomingEventType.Event && isEventTypeToSkipAuthorize(event.body.event.type)) {
|
|
389
430
|
authorizeResult = {
|
|
@@ -406,7 +447,9 @@ class App {
|
|
|
406
447
|
error: e,
|
|
407
448
|
logger: this.logger,
|
|
408
449
|
body: bodyArg,
|
|
409
|
-
context: {
|
|
450
|
+
context: {
|
|
451
|
+
isEnterpriseInstall,
|
|
452
|
+
},
|
|
410
453
|
});
|
|
411
454
|
}
|
|
412
455
|
}
|
|
@@ -418,6 +461,7 @@ class App {
|
|
|
418
461
|
if (authorizeResult.enterpriseId === undefined && source.enterpriseId !== undefined) {
|
|
419
462
|
authorizeResult.enterpriseId = source.enterpriseId;
|
|
420
463
|
}
|
|
464
|
+
// Try to set custom properties if they exist
|
|
421
465
|
if (typeof event.customProperties !== 'undefined') {
|
|
422
466
|
const customProps = event.customProperties;
|
|
423
467
|
const builtinKeyDetected = middleware_1.contextBuiltinKeys.find((key) => key in customProps);
|
|
@@ -425,9 +469,34 @@ class App {
|
|
|
425
469
|
throw new errors_1.InvalidCustomPropertyError('customProperties cannot have the same names with the built-in ones');
|
|
426
470
|
}
|
|
427
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Set the Slack Function Bot Access Token if it exists in event payload to the context.
|
|
474
|
+
*
|
|
475
|
+
* A bot_access_token will exist in any payload that has been generated
|
|
476
|
+
* in the context of a Slack Function execution. This includes function_execution
|
|
477
|
+
* events themselves, as well as interactivity payloads (e.g. block_actions, views).
|
|
478
|
+
*
|
|
479
|
+
* This token must be used for further Slack API calls which are relevant to this
|
|
480
|
+
* Slack Function execution in order for any interactivity context data to be
|
|
481
|
+
* properly sent by Slack.
|
|
482
|
+
*
|
|
483
|
+
* Bolt will set this value in the event Context and
|
|
484
|
+
* use this token in place of any other token (for example the token
|
|
485
|
+
* that the App was configured with) to initialize the Web Client.
|
|
486
|
+
*
|
|
487
|
+
* Sometimes the bot_access_token is located in the event
|
|
488
|
+
* Sometimes it is located directly in the body.
|
|
489
|
+
*/
|
|
490
|
+
let slackFunctionBotAccessToken = body.bot_access_token;
|
|
491
|
+
if (slackFunctionBotAccessToken === undefined && 'event' in body) {
|
|
492
|
+
slackFunctionBotAccessToken = body.event.bot_access_token;
|
|
493
|
+
}
|
|
494
|
+
// Declare the event context
|
|
428
495
|
const context = {
|
|
429
496
|
...authorizeResult,
|
|
430
497
|
...event.customProperties,
|
|
498
|
+
slackFunctionBotAccessToken,
|
|
499
|
+
isEnterpriseInstall,
|
|
431
500
|
retryNum: event.retryNum,
|
|
432
501
|
retryReason: event.retryReason,
|
|
433
502
|
};
|
|
@@ -467,8 +536,6 @@ class App {
|
|
|
467
536
|
payload = bodyArg;
|
|
468
537
|
break;
|
|
469
538
|
}
|
|
470
|
-
// NOTE: the following doesn't work because... distributive?
|
|
471
|
-
// const listenerArgs: Partial<AnyMiddlewareArgs> = {
|
|
472
539
|
const listenerArgs = {
|
|
473
540
|
body: bodyArg,
|
|
474
541
|
payload,
|
|
@@ -522,7 +589,7 @@ class App {
|
|
|
522
589
|
// Events API requests are acknowledged right away, since there's no data expected
|
|
523
590
|
await ack();
|
|
524
591
|
}
|
|
525
|
-
// Get the client
|
|
592
|
+
// Get or create the client
|
|
526
593
|
let { client } = this;
|
|
527
594
|
const token = selectToken(context);
|
|
528
595
|
if (token !== undefined) {
|
|
@@ -562,7 +629,7 @@ class App {
|
|
|
562
629
|
return undefined;
|
|
563
630
|
}
|
|
564
631
|
return (0, process_1.default)(listenerMiddleware, listenerArgs, context, client, this.logger,
|
|
565
|
-
// When all
|
|
632
|
+
// When all the listener middleware are done processing,
|
|
566
633
|
// `listener` here will be called without a `next` execution
|
|
567
634
|
async () => listener({
|
|
568
635
|
...listenerArgs,
|
|
@@ -619,23 +686,26 @@ class App {
|
|
|
619
686
|
return receiver;
|
|
620
687
|
}
|
|
621
688
|
if (this.socketMode === true) {
|
|
622
|
-
if (appToken === undefined) {
|
|
689
|
+
if (cliAppTokenOverride === undefined && appToken === undefined) {
|
|
623
690
|
throw new errors_1.AppInitializationError('You must provide an appToken when socketMode is set to true. To generate an appToken see: https://api.slack.com/apis/connections/socket#token');
|
|
624
691
|
}
|
|
625
692
|
this.logger.debug('Initializing SocketModeReceiver');
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
693
|
+
const xaxpToken = cliAppTokenOverride || appToken;
|
|
694
|
+
if (xaxpToken !== undefined) {
|
|
695
|
+
return new SocketModeReceiver_1.default({
|
|
696
|
+
appToken: xaxpToken,
|
|
697
|
+
clientId,
|
|
698
|
+
clientSecret,
|
|
699
|
+
stateSecret,
|
|
700
|
+
redirectUri,
|
|
701
|
+
installationStore,
|
|
702
|
+
scopes,
|
|
703
|
+
logger,
|
|
704
|
+
logLevel: this.logLevel,
|
|
705
|
+
installerOptions: this.installerOptions,
|
|
706
|
+
customRoutes,
|
|
707
|
+
});
|
|
708
|
+
}
|
|
639
709
|
}
|
|
640
710
|
if (signatureVerification === true && signingSecret === undefined) {
|
|
641
711
|
// Using default receiver HTTPReceiver, signature verification enabled, missing signingSecret
|
|
@@ -666,8 +736,8 @@ class App {
|
|
|
666
736
|
const httpReceiver = this.receiver;
|
|
667
737
|
if (httpReceiver.installer !== undefined &&
|
|
668
738
|
httpReceiver.installer.authorize !== undefined) {
|
|
669
|
-
// This supports using the built
|
|
670
|
-
// and theoretically, doing a fully custom (non
|
|
739
|
+
// This supports using the built-in HTTPReceiver, declaring your own HTTPReceiver
|
|
740
|
+
// and theoretically, doing a fully custom (non-Express.js) receiver that implements OAuth
|
|
671
741
|
usingOauth = true;
|
|
672
742
|
}
|
|
673
743
|
if (token !== undefined) {
|
|
@@ -762,6 +832,10 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
762
832
|
if (type === helpers_1.IncomingEventType.Command) {
|
|
763
833
|
return body.team_id;
|
|
764
834
|
}
|
|
835
|
+
if (type === helpers_1.IncomingEventType.Subscription) {
|
|
836
|
+
const bodyAsSubscriptionInteraction = body;
|
|
837
|
+
return bodyAsSubscriptionInteraction.team.id;
|
|
838
|
+
}
|
|
765
839
|
if (type === helpers_1.IncomingEventType.Action ||
|
|
766
840
|
type === helpers_1.IncomingEventType.Options ||
|
|
767
841
|
type === helpers_1.IncomingEventType.ViewAction ||
|
|
@@ -781,7 +855,7 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
781
855
|
if (type === helpers_1.IncomingEventType.Event) {
|
|
782
856
|
const bodyAsEvent = body;
|
|
783
857
|
if (Array.isArray(bodyAsEvent.authorizations) && bodyAsEvent.authorizations[0] !== undefined) {
|
|
784
|
-
// The
|
|
858
|
+
// The enterprise_id here can be null when the workspace is not in an Enterprise Grid
|
|
785
859
|
const theId = bodyAsEvent.authorizations[0].enterprise_id;
|
|
786
860
|
return theId !== null ? theId : undefined;
|
|
787
861
|
}
|
|
@@ -790,6 +864,10 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
790
864
|
if (type === helpers_1.IncomingEventType.Command) {
|
|
791
865
|
return body.enterprise_id;
|
|
792
866
|
}
|
|
867
|
+
if (type === helpers_1.IncomingEventType.Subscription) {
|
|
868
|
+
const bodyAsSubscriptionInteraction = body;
|
|
869
|
+
return bodyAsSubscriptionInteraction.team.enterprise_id;
|
|
870
|
+
}
|
|
793
871
|
if (type === helpers_1.IncomingEventType.Action ||
|
|
794
872
|
type === helpers_1.IncomingEventType.Options ||
|
|
795
873
|
type === helpers_1.IncomingEventType.ViewAction ||
|
|
@@ -829,6 +907,10 @@ function buildSource(type, channelId, body, isEnterpriseInstall) {
|
|
|
829
907
|
}
|
|
830
908
|
return undefined;
|
|
831
909
|
}
|
|
910
|
+
if (type === helpers_1.IncomingEventType.Subscription) {
|
|
911
|
+
const bodyAsSubscriptionInteraction = body;
|
|
912
|
+
return bodyAsSubscriptionInteraction.user.id;
|
|
913
|
+
}
|
|
832
914
|
if (type === helpers_1.IncomingEventType.Action ||
|
|
833
915
|
type === helpers_1.IncomingEventType.Options ||
|
|
834
916
|
type === helpers_1.IncomingEventType.ViewAction ||
|
|
@@ -857,13 +939,18 @@ function isBodyWithTypeEnterpriseInstall(body, type) {
|
|
|
857
939
|
return !!bodyAsEvent.authorizations[0].is_enterprise_install;
|
|
858
940
|
}
|
|
859
941
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
return body.is_enterprise_install === 'true';
|
|
942
|
+
if (type === helpers_1.IncomingEventType.Subscription) {
|
|
943
|
+
return body.team.enterprise_id !== undefined;
|
|
863
944
|
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
945
|
+
if ('is_enterprise_install' in body) {
|
|
946
|
+
// command payloads have this property set as a string
|
|
947
|
+
if (typeof body.is_enterprise_install === 'string') {
|
|
948
|
+
return body.is_enterprise_install === 'true';
|
|
949
|
+
}
|
|
950
|
+
// all remaining types have a boolean property
|
|
951
|
+
if (body.is_enterprise_install !== undefined) {
|
|
952
|
+
return body.is_enterprise_install;
|
|
953
|
+
}
|
|
867
954
|
}
|
|
868
955
|
// as a fallback we assume it's a single team installation (but this should never happen)
|
|
869
956
|
return false;
|
|
@@ -871,9 +958,12 @@ function isBodyWithTypeEnterpriseInstall(body, type) {
|
|
|
871
958
|
function isBlockActionOrInteractiveMessageBody(body) {
|
|
872
959
|
return body.actions !== undefined;
|
|
873
960
|
}
|
|
874
|
-
|
|
961
|
+
/**
|
|
962
|
+
* Returns in order of preference, a bot token, bot access token or user token for client, say()
|
|
963
|
+
* */
|
|
875
964
|
function selectToken(context) {
|
|
876
|
-
|
|
965
|
+
var _a, _b;
|
|
966
|
+
return (_b = (_a = context.slackFunctionBotAccessToken) !== null && _a !== void 0 ? _a : context.botToken) !== null && _b !== void 0 ? _b : context.userToken;
|
|
877
967
|
}
|
|
878
968
|
function buildRespondFn(axiosInstance, responseUrl) {
|
|
879
969
|
return async (message) => {
|