@slack/bolt 3.8.0 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +212 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +796 -0
- package/dist/App.js.map +1 -0
- package/dist/WorkflowStep.d.ts +106 -0
- package/dist/WorkflowStep.d.ts.map +1 -0
- package/dist/WorkflowStep.js +196 -0
- package/dist/WorkflowStep.js.map +1 -0
- package/dist/conversation-store.d.ts +31 -0
- package/dist/conversation-store.d.ts.map +1 -0
- package/dist/conversation-store.js +72 -0
- package/dist/conversation-store.js.map +1 -0
- package/dist/errors.d.ts +79 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +120 -0
- package/dist/errors.js.map +1 -0
- package/dist/helpers.d.ts +24 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +100 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/builtin.d.ts +52 -0
- package/dist/middleware/builtin.d.ts.map +1 -0
- package/dist/middleware/builtin.js +311 -0
- package/dist/middleware/builtin.js.map +1 -0
- package/dist/middleware/process.d.ts +5 -0
- package/dist/middleware/process.d.ts.map +1 -0
- package/dist/middleware/process.js +25 -0
- package/dist/middleware/process.js.map +1 -0
- package/dist/receivers/AwsLambdaReceiver.d.ts +53 -0
- package/dist/receivers/AwsLambdaReceiver.d.ts.map +1 -0
- package/dist/receivers/AwsLambdaReceiver.js +188 -0
- package/dist/receivers/AwsLambdaReceiver.js.map +1 -0
- package/dist/receivers/ExpressReceiver.d.ts +77 -0
- package/dist/receivers/ExpressReceiver.d.ts.map +1 -0
- package/dist/receivers/ExpressReceiver.js +445 -0
- package/dist/receivers/ExpressReceiver.js.map +1 -0
- package/dist/receivers/HTTPReceiver.d.ts +109 -0
- package/dist/receivers/HTTPReceiver.d.ts.map +1 -0
- package/dist/receivers/HTTPReceiver.js +501 -0
- package/dist/receivers/HTTPReceiver.js.map +1 -0
- package/dist/receivers/SocketModeReceiver.d.ts +61 -0
- package/dist/receivers/SocketModeReceiver.d.ts.map +1 -0
- package/dist/receivers/SocketModeReceiver.js +175 -0
- package/dist/receivers/SocketModeReceiver.js.map +1 -0
- 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/http-utils.d.ts +5 -0
- package/dist/receivers/http-utils.d.ts.map +1 -0
- package/dist/receivers/http-utils.js +35 -0
- package/dist/receivers/http-utils.js.map +1 -0
- package/dist/receivers/render-html-for-install-path.d.ts +3 -0
- package/dist/receivers/render-html-for-install-path.d.ts.map +1 -0
- package/dist/receivers/render-html-for-install-path.js +25 -0
- package/dist/receivers/render-html-for-install-path.js.map +1 -0
- 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 +41 -0
- package/dist/receivers/verify-request.d.ts.map +1 -0
- package/dist/receivers/verify-request.js +98 -0
- package/dist/receivers/verify-request.js.map +1 -0
- package/dist/types/actions/block-action.d.ts +231 -0
- package/dist/types/actions/block-action.d.ts.map +1 -0
- package/dist/types/actions/block-action.js +3 -0
- package/dist/types/actions/block-action.js.map +1 -0
- package/dist/types/actions/dialog-action.d.ts +47 -0
- package/dist/types/actions/dialog-action.d.ts.map +1 -0
- package/dist/types/actions/dialog-action.js +3 -0
- package/dist/types/actions/dialog-action.js.map +1 -0
- package/dist/types/actions/index.d.ts +46 -0
- package/dist/types/actions/index.d.ts.map +1 -0
- package/dist/types/actions/index.js +17 -0
- package/dist/types/actions/index.js.map +1 -0
- package/dist/types/actions/interactive-message.d.ts +66 -0
- package/dist/types/actions/interactive-message.d.ts.map +1 -0
- package/dist/types/actions/interactive-message.js +3 -0
- package/dist/types/actions/interactive-message.js.map +1 -0
- package/dist/types/actions/workflow-step-edit.d.ts +49 -0
- package/dist/types/actions/workflow-step-edit.d.ts.map +1 -0
- package/dist/types/actions/workflow-step-edit.js +3 -0
- package/dist/types/actions/workflow-step-edit.js.map +1 -0
- package/dist/types/command/index.d.ts +36 -0
- package/dist/types/command/index.d.ts.map +1 -0
- package/dist/types/command/index.js +3 -0
- package/dist/types/command/index.js.map +1 -0
- package/dist/types/events/base-events.d.ts +699 -0
- package/dist/types/events/base-events.d.ts.map +1 -0
- package/dist/types/events/base-events.js +5 -0
- package/dist/types/events/base-events.js.map +1 -0
- package/dist/types/events/index.d.ts +63 -0
- package/dist/types/events/index.d.ts.map +1 -0
- package/dist/types/events/index.js +14 -0
- package/dist/types/events/index.js.map +1 -0
- package/dist/types/events/message-events.d.ts +312 -0
- package/dist/types/events/message-events.d.ts.map +1 -0
- package/dist/types/events/message-events.js +3 -0
- package/dist/types/events/message-events.js.map +1 -0
- package/dist/types/helpers.d.ts +17 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/helpers.js +3 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +22 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/middleware.d.ts +65 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/middleware.js +14 -0
- package/dist/types/middleware.js.map +1 -0
- package/dist/types/options/index.d.ts +192 -0
- package/dist/types/options/index.d.ts.map +1 -0
- package/dist/types/options/index.js +3 -0
- package/dist/types/options/index.js.map +1 -0
- package/dist/types/receiver.d.ts +16 -0
- package/dist/types/receiver.d.ts.map +1 -0
- package/dist/types/receiver.js +3 -0
- package/dist/types/receiver.js.map +1 -0
- package/dist/types/shortcuts/global-shortcut.d.ts +29 -0
- package/dist/types/shortcuts/global-shortcut.d.ts.map +1 -0
- package/dist/types/shortcuts/global-shortcut.js +3 -0
- package/dist/types/shortcuts/global-shortcut.js.map +1 -0
- package/dist/types/shortcuts/index.d.ts +23 -0
- package/dist/types/shortcuts/index.d.ts.map +1 -0
- package/dist/types/shortcuts/index.js +16 -0
- package/dist/types/shortcuts/index.js.map +1 -0
- package/dist/types/shortcuts/message-shortcut.d.ts +43 -0
- package/dist/types/shortcuts/message-shortcut.d.ts.map +1 -0
- package/dist/types/shortcuts/message-shortcut.js +3 -0
- package/dist/types/shortcuts/message-shortcut.js.map +1 -0
- package/dist/types/utilities.d.ts +23 -0
- package/dist/types/utilities.d.ts.map +1 -0
- package/dist/types/utilities.js +3 -0
- package/dist/types/utilities.js.map +1 -0
- package/dist/types/view/index.d.ts +175 -0
- package/dist/types/view/index.d.ts.map +1 -0
- package/dist/types/view/index.js +3 -0
- package/dist/types/view/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/package.json +0 -88
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Server, ServerOptions } from 'http';
|
|
3
|
+
import { Server as HTTPSServer, ServerOptions as HTTPSServerOptions } from 'https';
|
|
4
|
+
import { ListenOptions } from 'net';
|
|
5
|
+
import { Request, Application, RequestHandler, IRouter } from 'express';
|
|
6
|
+
import { Logger, LogLevel } from '@slack/logger';
|
|
7
|
+
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions } from '@slack/oauth';
|
|
8
|
+
import App from '../App';
|
|
9
|
+
import { AnyMiddlewareArgs, Receiver } from '../types';
|
|
10
|
+
import { StringIndexed } from '../types/helpers';
|
|
11
|
+
export declare const respondToSslCheck: RequestHandler;
|
|
12
|
+
export declare const respondToUrlVerification: RequestHandler;
|
|
13
|
+
export interface ExpressReceiverOptions {
|
|
14
|
+
signingSecret: string | (() => PromiseLike<string>);
|
|
15
|
+
logger?: Logger;
|
|
16
|
+
logLevel?: LogLevel;
|
|
17
|
+
endpoints?: string | {
|
|
18
|
+
[endpointType: string]: string;
|
|
19
|
+
};
|
|
20
|
+
signatureVerification?: boolean;
|
|
21
|
+
processBeforeResponse?: boolean;
|
|
22
|
+
clientId?: string;
|
|
23
|
+
clientSecret?: string;
|
|
24
|
+
stateSecret?: InstallProviderOptions['stateSecret'];
|
|
25
|
+
redirectUri?: string;
|
|
26
|
+
installationStore?: InstallProviderOptions['installationStore'];
|
|
27
|
+
scopes?: InstallURLOptions['scopes'];
|
|
28
|
+
installerOptions?: InstallerOptions;
|
|
29
|
+
app?: Application;
|
|
30
|
+
router?: IRouter;
|
|
31
|
+
customPropertiesExtractor?: (request: Request) => StringIndexed;
|
|
32
|
+
}
|
|
33
|
+
interface InstallerOptions {
|
|
34
|
+
stateStore?: InstallProviderOptions['stateStore'];
|
|
35
|
+
stateVerification?: InstallProviderOptions['stateVerification'];
|
|
36
|
+
authVersion?: InstallProviderOptions['authVersion'];
|
|
37
|
+
metadata?: InstallURLOptions['metadata'];
|
|
38
|
+
installPath?: string;
|
|
39
|
+
directInstall?: boolean;
|
|
40
|
+
renderHtmlForInstallPath?: (url: string) => string;
|
|
41
|
+
redirectUriPath?: string;
|
|
42
|
+
callbackOptions?: CallbackOptions;
|
|
43
|
+
userScopes?: InstallURLOptions['userScopes'];
|
|
44
|
+
clientOptions?: InstallProviderOptions['clientOptions'];
|
|
45
|
+
authorizationUrl?: InstallProviderOptions['authorizationUrl'];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Receives HTTP requests with Events, Slash Commands, and Actions
|
|
49
|
+
*/
|
|
50
|
+
export default class ExpressReceiver implements Receiver {
|
|
51
|
+
app: Application;
|
|
52
|
+
private server?;
|
|
53
|
+
private bolt;
|
|
54
|
+
private logger;
|
|
55
|
+
private processBeforeResponse;
|
|
56
|
+
private signatureVerification;
|
|
57
|
+
router: IRouter;
|
|
58
|
+
installer: InstallProvider | undefined;
|
|
59
|
+
installerOptions?: InstallerOptions;
|
|
60
|
+
private customPropertiesExtractor;
|
|
61
|
+
constructor({ signingSecret, logger, logLevel, endpoints, processBeforeResponse, signatureVerification, clientId, clientSecret, stateSecret, redirectUri, installationStore, scopes, installerOptions, app, router, customPropertiesExtractor, }: ExpressReceiverOptions);
|
|
62
|
+
private requestHandler;
|
|
63
|
+
init(bolt: App): void;
|
|
64
|
+
start(port: number): Promise<Server>;
|
|
65
|
+
start(portOrListenOptions: number | ListenOptions, serverOptions?: ServerOptions): Promise<Server>;
|
|
66
|
+
start(portOrListenOptions: number | ListenOptions, httpsServerOptions?: HTTPSServerOptions): Promise<HTTPSServer>;
|
|
67
|
+
stop(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export declare function verifySignatureAndParseRawBody(logger: Logger, signingSecret: string | (() => PromiseLike<string>)): RequestHandler;
|
|
70
|
+
/**
|
|
71
|
+
* This request handler has two responsibilities:
|
|
72
|
+
* - Verify the request signature
|
|
73
|
+
* - Parse request.body and assign the successfully parsed object to it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function verifySignatureAndParseBody(signingSecret: string, body: string, headers: Record<string, any>): AnyMiddlewareArgs['body'];
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=ExpressReceiver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressReceiver.d.ts","sourceRoot":"","sources":["../../src/receivers/ExpressReceiver.ts"],"names":[],"mappings":";AACA,OAAO,EAAgB,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAqC,MAAM,IAAI,WAAW,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,OAAO,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAgB,EAAE,OAAO,EAAY,WAAW,EAAE,cAAc,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAKnG,OAAO,EAAE,MAAM,EAAiB,QAAQ,EAAE,M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AC3C,EAAE,sBAAsB;YAyGX,cAAc;IAqErB,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAKrB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACpC,KAAK,CAAC,mBAAmB,EAAE,MAAM,GAAG,aAAa,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAClG,KAAK,CACV,mBAAmB,EAAE,MAAM,GAAG,aAAa,EAC3C,kBAAkB,CAAC,EAAE,kBAAkB,GACtC,OAAO,CAAC,WAAW,CAAC;IA2DhB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAe7B;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GAAG,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC,GAClD,cAAc,CAEhB;AA0FD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,iBAAiB,CAAC,MAAM,CAAC,CAW3B"}
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.verifySignatureAndParseBody = exports.verifySignatureAndParseRawBody = exports.respondToUrlVerification = exports.respondToSslCheck = void 0;
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
27
|
+
const http_1 = require("http");
|
|
28
|
+
const https_1 = require("https");
|
|
29
|
+
const express_1 = __importStar(require("express"));
|
|
30
|
+
const raw_body_1 = __importDefault(require("raw-body"));
|
|
31
|
+
const querystring_1 = __importDefault(require("querystring"));
|
|
32
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
33
|
+
const tsscmp_1 = __importDefault(require("tsscmp"));
|
|
34
|
+
const logger_1 = require("@slack/logger");
|
|
35
|
+
const oauth_1 = require("@slack/oauth");
|
|
36
|
+
const errors_1 = require("../errors");
|
|
37
|
+
const render_html_for_install_path_1 = __importDefault(require("./render-html-for-install-path"));
|
|
38
|
+
const verify_redirect_opts_1 = require("./verify-redirect-opts");
|
|
39
|
+
const http_utils_1 = require("./http-utils");
|
|
40
|
+
// Option keys for tls.createServer() and tls.createSecureContext(), exclusive of those for http.createServer()
|
|
41
|
+
const httpsOptionKeys = [
|
|
42
|
+
'ALPNProtocols',
|
|
43
|
+
'clientCertEngine',
|
|
44
|
+
'enableTrace',
|
|
45
|
+
'handshakeTimeout',
|
|
46
|
+
'rejectUnauthorized',
|
|
47
|
+
'requestCert',
|
|
48
|
+
'sessionTimeout',
|
|
49
|
+
'SNICallback',
|
|
50
|
+
'ticketKeys',
|
|
51
|
+
'pskCallback',
|
|
52
|
+
'pskIdentityHint',
|
|
53
|
+
'ca',
|
|
54
|
+
'cert',
|
|
55
|
+
'sigalgs',
|
|
56
|
+
'ciphers',
|
|
57
|
+
'clientCertEngine',
|
|
58
|
+
'crl',
|
|
59
|
+
'dhparam',
|
|
60
|
+
'ecdhCurve',
|
|
61
|
+
'honorCipherOrder',
|
|
62
|
+
'key',
|
|
63
|
+
'privateKeyEngine',
|
|
64
|
+
'privateKeyIdentifier',
|
|
65
|
+
'maxVersion',
|
|
66
|
+
'minVersion',
|
|
67
|
+
'passphrase',
|
|
68
|
+
'pfx',
|
|
69
|
+
'secureOptions',
|
|
70
|
+
'secureProtocol',
|
|
71
|
+
'sessionIdContext',
|
|
72
|
+
];
|
|
73
|
+
const missingServerErrorDescription = 'The receiver cannot be started because private state was mutated. Please report this to the maintainers.';
|
|
74
|
+
const respondToSslCheck = (req, res, next) => {
|
|
75
|
+
if (req.body && req.body.ssl_check) {
|
|
76
|
+
res.send();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
next();
|
|
80
|
+
};
|
|
81
|
+
exports.respondToSslCheck = respondToSslCheck;
|
|
82
|
+
const respondToUrlVerification = (req, res, next) => {
|
|
83
|
+
if (req.body && req.body.type && req.body.type === 'url_verification') {
|
|
84
|
+
res.json({ challenge: req.body.challenge });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
next();
|
|
88
|
+
};
|
|
89
|
+
exports.respondToUrlVerification = respondToUrlVerification;
|
|
90
|
+
/**
|
|
91
|
+
* Receives HTTP requests with Events, Slash Commands, and Actions
|
|
92
|
+
*/
|
|
93
|
+
class ExpressReceiver {
|
|
94
|
+
constructor({ signingSecret = '', logger = undefined, logLevel = logger_1.LogLevel.INFO, endpoints = { events: '/slack/events' }, processBeforeResponse = false, signatureVerification = true, clientId = undefined, clientSecret = undefined, stateSecret = undefined, redirectUri = undefined, installationStore = undefined, scopes = undefined, installerOptions = {}, app = undefined, router = undefined, customPropertiesExtractor = (_req) => ({}), }) {
|
|
95
|
+
var _a;
|
|
96
|
+
this.installer = undefined;
|
|
97
|
+
this.app = app !== undefined ? app : (0, express_1.default)();
|
|
98
|
+
if (typeof logger !== 'undefined') {
|
|
99
|
+
this.logger = logger;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.logger = new logger_1.ConsoleLogger();
|
|
103
|
+
this.logger.setLevel(logLevel);
|
|
104
|
+
}
|
|
105
|
+
this.signatureVerification = signatureVerification;
|
|
106
|
+
const bodyParser = this.signatureVerification ?
|
|
107
|
+
buildVerificationBodyParserMiddleware(this.logger, signingSecret) :
|
|
108
|
+
buildBodyParserMiddleware(this.logger);
|
|
109
|
+
const expressMiddleware = [
|
|
110
|
+
bodyParser,
|
|
111
|
+
exports.respondToSslCheck,
|
|
112
|
+
exports.respondToUrlVerification,
|
|
113
|
+
this.requestHandler.bind(this),
|
|
114
|
+
];
|
|
115
|
+
this.processBeforeResponse = processBeforeResponse;
|
|
116
|
+
const endpointList = typeof endpoints === 'string' ? [endpoints] : Object.values(endpoints);
|
|
117
|
+
this.router = router !== undefined ? router : (0, express_1.Router)();
|
|
118
|
+
endpointList.forEach((endpoint) => {
|
|
119
|
+
this.router.post(endpoint, ...expressMiddleware);
|
|
120
|
+
});
|
|
121
|
+
this.customPropertiesExtractor = customPropertiesExtractor;
|
|
122
|
+
// Verify redirect options if supplied, throws coded error if invalid
|
|
123
|
+
(0, verify_redirect_opts_1.verifyRedirectOpts)({ redirectUri, redirectUriPath: installerOptions.redirectUriPath });
|
|
124
|
+
if (clientId !== undefined &&
|
|
125
|
+
clientSecret !== undefined &&
|
|
126
|
+
(installerOptions.stateVerification === false || // state store not needed
|
|
127
|
+
stateSecret !== undefined ||
|
|
128
|
+
installerOptions.stateStore !== undefined) // user provided state store
|
|
129
|
+
) {
|
|
130
|
+
this.installer = new oauth_1.InstallProvider({
|
|
131
|
+
clientId,
|
|
132
|
+
clientSecret,
|
|
133
|
+
stateSecret,
|
|
134
|
+
installationStore,
|
|
135
|
+
logLevel,
|
|
136
|
+
logger,
|
|
137
|
+
stateStore: installerOptions.stateStore,
|
|
138
|
+
stateVerification: installerOptions.stateVerification,
|
|
139
|
+
authVersion: (_a = installerOptions.authVersion) !== null && _a !== void 0 ? _a : 'v2',
|
|
140
|
+
clientOptions: installerOptions.clientOptions,
|
|
141
|
+
authorizationUrl: installerOptions.authorizationUrl,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
// create install url options
|
|
145
|
+
const installUrlOptions = {
|
|
146
|
+
metadata: installerOptions.metadata,
|
|
147
|
+
scopes: scopes !== null && scopes !== void 0 ? scopes : [],
|
|
148
|
+
userScopes: installerOptions.userScopes,
|
|
149
|
+
redirectUri,
|
|
150
|
+
};
|
|
151
|
+
// Add OAuth routes to receiver
|
|
152
|
+
if (this.installer !== undefined) {
|
|
153
|
+
const redirectUriPath = installerOptions.redirectUriPath === undefined ?
|
|
154
|
+
'/slack/oauth_redirect' :
|
|
155
|
+
installerOptions.redirectUriPath;
|
|
156
|
+
const { callbackOptions, stateVerification } = installerOptions;
|
|
157
|
+
this.router.use(redirectUriPath, async (req, res) => {
|
|
158
|
+
if (stateVerification === false) {
|
|
159
|
+
// when stateVerification is disabled pass install options directly to handler
|
|
160
|
+
// since they won't be encoded in the state param of the generated url
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
162
|
+
await this.installer.handleCallback(req, res, callbackOptions, installUrlOptions);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
166
|
+
await this.installer.handleCallback(req, res, callbackOptions);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const installPath = installerOptions.installPath === undefined ? '/slack/install' : installerOptions.installPath;
|
|
170
|
+
this.router.get(installPath, async (_req, res, next) => {
|
|
171
|
+
try {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
173
|
+
const url = await this.installer.generateInstallUrl(installUrlOptions, stateVerification);
|
|
174
|
+
if (installerOptions.directInstall) {
|
|
175
|
+
// If a Slack app sets "Direct Install URL" in the Slack app configuration,
|
|
176
|
+
// the installation flow of the app should start with the Slack authorize URL.
|
|
177
|
+
// See https://api.slack.com/start/distributing/directory#direct_install for more details.
|
|
178
|
+
res.redirect(url);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// The installation starts from a landing page served by this app.
|
|
182
|
+
const renderHtml = installerOptions.renderHtmlForInstallPath !== undefined ?
|
|
183
|
+
installerOptions.renderHtmlForInstallPath :
|
|
184
|
+
render_html_for_install_path_1.default;
|
|
185
|
+
res.send(renderHtml(url));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
next(error);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
this.app.use(this.router);
|
|
194
|
+
}
|
|
195
|
+
async requestHandler(req, res) {
|
|
196
|
+
var _a;
|
|
197
|
+
let isAcknowledged = false;
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
if (!isAcknowledged) {
|
|
200
|
+
this.logger.error('An incoming event was not acknowledged within 3 seconds. Ensure that the ack() argument is called in a listener.');
|
|
201
|
+
}
|
|
202
|
+
}, 3001);
|
|
203
|
+
let storedResponse;
|
|
204
|
+
const event = {
|
|
205
|
+
body: req.body,
|
|
206
|
+
ack: async (response) => {
|
|
207
|
+
this.logger.debug('ack() begin');
|
|
208
|
+
if (isAcknowledged) {
|
|
209
|
+
throw new errors_1.ReceiverMultipleAckError();
|
|
210
|
+
}
|
|
211
|
+
isAcknowledged = true;
|
|
212
|
+
if (this.processBeforeResponse) {
|
|
213
|
+
if (!response) {
|
|
214
|
+
storedResponse = '';
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
storedResponse = response;
|
|
218
|
+
}
|
|
219
|
+
this.logger.debug('ack() response stored');
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
if (!response) {
|
|
223
|
+
res.send('');
|
|
224
|
+
}
|
|
225
|
+
else if (typeof response === 'string') {
|
|
226
|
+
res.send(response);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
res.json(response);
|
|
230
|
+
}
|
|
231
|
+
this.logger.debug('ack() response sent');
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
retryNum: (0, http_utils_1.extractRetryNum)(req),
|
|
235
|
+
retryReason: (0, http_utils_1.extractRetryReason)(req),
|
|
236
|
+
customProperties: this.customPropertiesExtractor(req),
|
|
237
|
+
};
|
|
238
|
+
try {
|
|
239
|
+
await ((_a = this.bolt) === null || _a === void 0 ? void 0 : _a.processEvent(event));
|
|
240
|
+
if (storedResponse !== undefined) {
|
|
241
|
+
if (typeof storedResponse === 'string') {
|
|
242
|
+
res.send(storedResponse);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
res.json(storedResponse);
|
|
246
|
+
}
|
|
247
|
+
this.logger.debug('stored response sent');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
const e = err;
|
|
252
|
+
if ('code' in e) {
|
|
253
|
+
// CodedError has code: string
|
|
254
|
+
const errorCode = err.code;
|
|
255
|
+
if (errorCode === errors_1.ErrorCode.AuthorizationError) {
|
|
256
|
+
// authorize function threw an exception, which means there is no valid installation data
|
|
257
|
+
res.status(401).send();
|
|
258
|
+
isAcknowledged = true;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
res.status(500).send();
|
|
263
|
+
throw err;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
init(bolt) {
|
|
267
|
+
this.bolt = bolt;
|
|
268
|
+
}
|
|
269
|
+
start(portOrListenOptions, serverOptions = {}) {
|
|
270
|
+
let createServerFn = http_1.createServer;
|
|
271
|
+
// Look for HTTPS-specific serverOptions to determine which factory function to use
|
|
272
|
+
if (Object.keys(serverOptions).filter((k) => httpsOptionKeys.includes(k)).length > 0) {
|
|
273
|
+
createServerFn = https_1.createServer;
|
|
274
|
+
}
|
|
275
|
+
if (this.server !== undefined) {
|
|
276
|
+
return Promise.reject(new errors_1.ReceiverInconsistentStateError('The receiver cannot be started because it was already started.'));
|
|
277
|
+
}
|
|
278
|
+
this.server = createServerFn(serverOptions, this.app);
|
|
279
|
+
return new Promise((resolve, reject) => {
|
|
280
|
+
if (this.server === undefined) {
|
|
281
|
+
throw new errors_1.ReceiverInconsistentStateError(missingServerErrorDescription);
|
|
282
|
+
}
|
|
283
|
+
this.server.on('error', (error) => {
|
|
284
|
+
if (this.server === undefined) {
|
|
285
|
+
throw new errors_1.ReceiverInconsistentStateError(missingServerErrorDescription);
|
|
286
|
+
}
|
|
287
|
+
this.server.close();
|
|
288
|
+
// If the error event occurs before listening completes (like EADDRINUSE), this works well. However, if the
|
|
289
|
+
// error event happens some after the Promise is already resolved, the error would be silently swallowed up.
|
|
290
|
+
// The documentation doesn't describe any specific errors that can occur after listening has started, so this
|
|
291
|
+
// feels safe.
|
|
292
|
+
reject(error);
|
|
293
|
+
});
|
|
294
|
+
this.server.on('close', () => {
|
|
295
|
+
// Not removing all listeners because consumers could have added their own `close` event listener, and those
|
|
296
|
+
// should be called. If the consumer doesn't dispose of any references to the server properly, this would be
|
|
297
|
+
// a memory leak.
|
|
298
|
+
// this.server?.removeAllListeners();
|
|
299
|
+
this.server = undefined;
|
|
300
|
+
});
|
|
301
|
+
this.server.listen(portOrListenOptions, () => {
|
|
302
|
+
if (this.server === undefined) {
|
|
303
|
+
return reject(new errors_1.ReceiverInconsistentStateError(missingServerErrorDescription));
|
|
304
|
+
}
|
|
305
|
+
return resolve(this.server);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
// TODO: the arguments should be defined as the arguments to close() (which happen to be none), but for sake of
|
|
310
|
+
// generic types
|
|
311
|
+
stop() {
|
|
312
|
+
if (this.server === undefined) {
|
|
313
|
+
return Promise.reject(new errors_1.ReceiverInconsistentStateError('The receiver cannot be stopped because it was not started.'));
|
|
314
|
+
}
|
|
315
|
+
return new Promise((resolve, reject) => {
|
|
316
|
+
var _a;
|
|
317
|
+
(_a = this.server) === null || _a === void 0 ? void 0 : _a.close((error) => {
|
|
318
|
+
if (error !== undefined) {
|
|
319
|
+
return reject(error);
|
|
320
|
+
}
|
|
321
|
+
this.server = undefined;
|
|
322
|
+
return resolve();
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.default = ExpressReceiver;
|
|
328
|
+
function verifySignatureAndParseRawBody(logger, signingSecret) {
|
|
329
|
+
return buildVerificationBodyParserMiddleware(logger, signingSecret);
|
|
330
|
+
}
|
|
331
|
+
exports.verifySignatureAndParseRawBody = verifySignatureAndParseRawBody;
|
|
332
|
+
/**
|
|
333
|
+
* This request handler has two responsibilities:
|
|
334
|
+
* - Verify the request signature
|
|
335
|
+
* - Parse request.body and assign the successfully parsed object to it.
|
|
336
|
+
*/
|
|
337
|
+
function buildVerificationBodyParserMiddleware(logger, signingSecret) {
|
|
338
|
+
return async (req, res, next) => {
|
|
339
|
+
let stringBody;
|
|
340
|
+
// On some environments like GCP (Google Cloud Platform),
|
|
341
|
+
// req.body can be pre-parsed and be passed as req.rawBody here
|
|
342
|
+
const preparsedRawBody = req.rawBody;
|
|
343
|
+
if (preparsedRawBody !== undefined) {
|
|
344
|
+
stringBody = preparsedRawBody.toString();
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
stringBody = (await (0, raw_body_1.default)(req)).toString();
|
|
348
|
+
}
|
|
349
|
+
// *** Parsing body ***
|
|
350
|
+
// As the verification passed, parse the body as an object and assign it to req.body
|
|
351
|
+
// Following middlewares can expect `req.body` is already a parsed one.
|
|
352
|
+
try {
|
|
353
|
+
// This handler parses `req.body` or `req.rawBody`(on Google Could Platform)
|
|
354
|
+
// and overwrites `req.body` with the parsed JS object.
|
|
355
|
+
req.body = verifySignatureAndParseBody(typeof signingSecret === 'string' ? signingSecret : await signingSecret(), stringBody, req.headers);
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
if (error) {
|
|
359
|
+
if (error instanceof errors_1.ReceiverAuthenticityError) {
|
|
360
|
+
logError(logger, 'Request verification failed', error);
|
|
361
|
+
return res.status(401).send();
|
|
362
|
+
}
|
|
363
|
+
logError(logger, 'Parsing request body failed', error);
|
|
364
|
+
return res.status(400).send();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return next();
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function logError(logger, message, error) {
|
|
371
|
+
const logMessage = 'code' in error ?
|
|
372
|
+
`${message} (code: ${error.code}, message: ${error.message})` :
|
|
373
|
+
`${message} (error: ${error})`;
|
|
374
|
+
logger.warn(logMessage);
|
|
375
|
+
}
|
|
376
|
+
function verifyRequestSignature(signingSecret, body, signature, requestTimestamp) {
|
|
377
|
+
if (signature === undefined || requestTimestamp === undefined) {
|
|
378
|
+
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Some headers are missing.');
|
|
379
|
+
}
|
|
380
|
+
const ts = Number(requestTimestamp);
|
|
381
|
+
// eslint-disable-next-line no-restricted-globals
|
|
382
|
+
if (isNaN(ts)) {
|
|
383
|
+
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Timestamp is invalid.');
|
|
384
|
+
}
|
|
385
|
+
// Divide current date to match Slack ts format
|
|
386
|
+
// Subtract 5 minutes from current time
|
|
387
|
+
const fiveMinutesAgo = Math.floor(Date.now() / 1000) - 60 * 5;
|
|
388
|
+
if (ts < fiveMinutesAgo) {
|
|
389
|
+
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Timestamp is too old.');
|
|
390
|
+
}
|
|
391
|
+
const hmac = crypto_1.default.createHmac('sha256', signingSecret);
|
|
392
|
+
const [version, hash] = signature.split('=');
|
|
393
|
+
hmac.update(`${version}:${ts}:${body}`);
|
|
394
|
+
if (!(0, tsscmp_1.default)(hash, hmac.digest('hex'))) {
|
|
395
|
+
throw new errors_1.ReceiverAuthenticityError('Slack request signing verification failed. Signature mismatch.');
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* This request handler has two responsibilities:
|
|
400
|
+
* - Verify the request signature
|
|
401
|
+
* - Parse request.body and assign the successfully parsed object to it.
|
|
402
|
+
*/
|
|
403
|
+
function verifySignatureAndParseBody(signingSecret, body, headers) {
|
|
404
|
+
// *** Request verification ***
|
|
405
|
+
const { 'x-slack-signature': signature, 'x-slack-request-timestamp': requestTimestamp, 'content-type': contentType, } = headers;
|
|
406
|
+
verifyRequestSignature(signingSecret, body, signature, requestTimestamp);
|
|
407
|
+
return parseRequestBody(body, contentType);
|
|
408
|
+
}
|
|
409
|
+
exports.verifySignatureAndParseBody = verifySignatureAndParseBody;
|
|
410
|
+
function buildBodyParserMiddleware(logger) {
|
|
411
|
+
return async (req, res, next) => {
|
|
412
|
+
let stringBody;
|
|
413
|
+
// On some environments like GCP (Google Cloud Platform),
|
|
414
|
+
// req.body can be pre-parsed and be passed as req.rawBody here
|
|
415
|
+
const preparsedRawBody = req.rawBody;
|
|
416
|
+
if (preparsedRawBody !== undefined) {
|
|
417
|
+
stringBody = preparsedRawBody.toString();
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
stringBody = (await (0, raw_body_1.default)(req)).toString();
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
const { 'content-type': contentType } = req.headers;
|
|
424
|
+
req.body = parseRequestBody(stringBody, contentType);
|
|
425
|
+
}
|
|
426
|
+
catch (error) {
|
|
427
|
+
if (error) {
|
|
428
|
+
logError(logger, 'Parsing request body failed', error);
|
|
429
|
+
return res.status(400).send();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return next();
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function parseRequestBody(stringBody, contentType) {
|
|
436
|
+
if (contentType === 'application/x-www-form-urlencoded') {
|
|
437
|
+
const parsedBody = querystring_1.default.parse(stringBody);
|
|
438
|
+
if (typeof parsedBody.payload === 'string') {
|
|
439
|
+
return JSON.parse(parsedBody.payload);
|
|
440
|
+
}
|
|
441
|
+
return parsedBody;
|
|
442
|
+
}
|
|
443
|
+
return JSON.parse(stringBody);
|
|
444
|
+
}
|
|
445
|
+
//# sourceMappingURL=ExpressReceiver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressReceiver.js","sourceRoot":"","sources":["../../src/receivers/ExpressReceiver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,+BAA2D;AAC3D,iCAAsH;AAEtH,mDAAmG;AACnG,wDAA+B;AAC/B,8DAAsC;AACtC,oDAA4B;AAC5B,oDAA4B;AAC5B,0CAAgE;AAChE,wCAA2G;AAE3G,sCAMmB;AAEnB,kGAA6E;AAC7E,iEAA4D;AAE5D,6CAAmE;AAEnE,+GAA+G;AAC/G,MAAM,eAAe,GAAG;IACtB,eAAe;IACf,kBAAkB;IAClB,aAAa;IACb,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,aAAa;IACb,iBAAiB;IACjB,IAAI;IACJ,MAAM;IACN,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,KAAK;IACL,SAAS;IACT,WAAW;IACX,kBAAkB;IAClB,KAAK;IACL,kBAAkB;IAClB,sBAAsB;IACtB,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,KAAK;IACL,eAAe;IACf,gBAAgB;IAChB,kBAAkB;CACnB,CAAC;AAEF,MAAM,6BAA6B,GAAG,0GAA0G,CAAC;AAE1I,MAAM,iBAAiB,GAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAClE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,UAAkB,CAAC;QACvB,yDAAyD;QACzD,+DAA+D;QAC/D,MAAM,gBAAgB,GAAS,GAAW,CAAC,OAAO,CAAC;QACnD,IAAI,gBAAgB,KAAK,SAAS,EAAE;YAClC,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC;SAC1C;aAAM;YACL,UAAU,GAAG,CAAC,MAAM,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SAC9C;QACD,IAAI;YACF,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;YACpD,GAAG,CAAC,IAAI,GAAG,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;SACtD;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,KAAK,EAAE;gBACT,QAAQ,CAAC,MAAM,EAAE,6BAA6B,EAAE,KAAK,CAAC,CAAC;gBACvD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;aAC/B;SACF;QACD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAkB,EAAE,WAA+B;IAC3E,IAAI,WAAW,KAAK,mCAAmC,EAAE;QACvD,MAAM,UAAU,GAAG,qBAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,EAAE;YAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Server, ServerOptions, RequestListener, IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { Server as HTTPSServer, ServerOptions as HTTPSServerOptions } from 'https';
|
|
4
|
+
import { ListenOptions } from 'net';
|
|
5
|
+
import { Logger, LogLevel } from '@slack/logger';
|
|
6
|
+
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions } from '@slack/oauth';
|
|
7
|
+
import { BufferedIncomingMessage } from './verify-request';
|
|
8
|
+
import App from '../App';
|
|
9
|
+
import { Receiver } from '../types';
|
|
10
|
+
import { CodedError } from '../errors';
|
|
11
|
+
import { CustomRoute } from './custom-routes';
|
|
12
|
+
import { StringIndexed } from '../types/helpers';
|
|
13
|
+
export interface HTTPReceiverOptions {
|
|
14
|
+
signingSecret: string;
|
|
15
|
+
endpoints?: string | string[];
|
|
16
|
+
port?: number;
|
|
17
|
+
customRoutes?: CustomRoute[];
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
logLevel?: LogLevel;
|
|
20
|
+
processBeforeResponse?: boolean;
|
|
21
|
+
signatureVerification?: boolean;
|
|
22
|
+
clientId?: string;
|
|
23
|
+
clientSecret?: string;
|
|
24
|
+
stateSecret?: InstallProviderOptions['stateSecret'];
|
|
25
|
+
redirectUri?: string;
|
|
26
|
+
installationStore?: InstallProviderOptions['installationStore'];
|
|
27
|
+
scopes?: InstallURLOptions['scopes'];
|
|
28
|
+
installerOptions?: HTTPReceiverInstallerOptions;
|
|
29
|
+
customPropertiesExtractor?: (request: BufferedIncomingMessage) => StringIndexed;
|
|
30
|
+
dispatchErrorHandler?: (args: HTTPReceiverDispatchErrorHandlerArgs) => void;
|
|
31
|
+
processEventErrorHandler?: (args: HTTPReceiverProcessEventErrorHandlerArgs) => Promise<boolean>;
|
|
32
|
+
unhandledRequestHandler?: (args: HTTPReceiverUnhandledRequestHandlerArgs) => void;
|
|
33
|
+
unhandledRequestTimeoutMillis?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface HTTPReceiverInstallerOptions {
|
|
36
|
+
installPath?: string;
|
|
37
|
+
directInstall?: boolean;
|
|
38
|
+
renderHtmlForInstallPath?: (url: string) => string;
|
|
39
|
+
redirectUriPath?: string;
|
|
40
|
+
stateStore?: InstallProviderOptions['stateStore'];
|
|
41
|
+
stateVerification?: InstallProviderOptions['stateVerification'];
|
|
42
|
+
authVersion?: InstallProviderOptions['authVersion'];
|
|
43
|
+
clientOptions?: InstallProviderOptions['clientOptions'];
|
|
44
|
+
authorizationUrl?: InstallProviderOptions['authorizationUrl'];
|
|
45
|
+
metadata?: InstallURLOptions['metadata'];
|
|
46
|
+
userScopes?: InstallURLOptions['userScopes'];
|
|
47
|
+
callbackOptions?: CallbackOptions;
|
|
48
|
+
port?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface HTTPReceiverDispatchErrorHandlerArgs {
|
|
51
|
+
error: Error | CodedError;
|
|
52
|
+
logger: Logger;
|
|
53
|
+
request: IncomingMessage;
|
|
54
|
+
response: ServerResponse;
|
|
55
|
+
}
|
|
56
|
+
export declare function defaultDispatchErrorHandler(args: HTTPReceiverDispatchErrorHandlerArgs): void;
|
|
57
|
+
export interface HTTPReceiverProcessEventErrorHandlerArgs {
|
|
58
|
+
error: Error | CodedError;
|
|
59
|
+
logger: Logger;
|
|
60
|
+
request: IncomingMessage;
|
|
61
|
+
response: ServerResponse;
|
|
62
|
+
storedResponse: any;
|
|
63
|
+
}
|
|
64
|
+
export declare function defaultProcessEventErrorHandler(args: HTTPReceiverProcessEventErrorHandlerArgs): Promise<boolean>;
|
|
65
|
+
export interface HTTPReceiverUnhandledRequestHandlerArgs {
|
|
66
|
+
logger: Logger;
|
|
67
|
+
request: IncomingMessage;
|
|
68
|
+
response: ServerResponse;
|
|
69
|
+
}
|
|
70
|
+
export declare function defaultUnhandledRequestHandler(args: HTTPReceiverUnhandledRequestHandlerArgs): void;
|
|
71
|
+
/**
|
|
72
|
+
* Receives HTTP requests with Events, Slash Commands, and Actions
|
|
73
|
+
*/
|
|
74
|
+
export default class HTTPReceiver implements Receiver {
|
|
75
|
+
private endpoints;
|
|
76
|
+
private port;
|
|
77
|
+
private routes;
|
|
78
|
+
private signingSecret;
|
|
79
|
+
private processBeforeResponse;
|
|
80
|
+
private signatureVerification;
|
|
81
|
+
private app?;
|
|
82
|
+
requestListener: RequestListener;
|
|
83
|
+
private server?;
|
|
84
|
+
installer?: InstallProvider;
|
|
85
|
+
private installPath?;
|
|
86
|
+
private directInstall?;
|
|
87
|
+
private renderHtmlForInstallPath;
|
|
88
|
+
private installRedirectUriPath?;
|
|
89
|
+
private installUrlOptions?;
|
|
90
|
+
private installCallbackOptions?;
|
|
91
|
+
private stateVerification?;
|
|
92
|
+
private logger;
|
|
93
|
+
private customPropertiesExtractor;
|
|
94
|
+
private dispatchErrorHandler;
|
|
95
|
+
private processEventErrorHandler;
|
|
96
|
+
private unhandledRequestHandler;
|
|
97
|
+
private unhandledRequestTimeoutMillis;
|
|
98
|
+
constructor({ signingSecret, endpoints, port, customRoutes, logger, logLevel, processBeforeResponse, signatureVerification, clientId, clientSecret, stateSecret, redirectUri, installationStore, scopes, installerOptions, customPropertiesExtractor, dispatchErrorHandler, processEventErrorHandler, unhandledRequestHandler, unhandledRequestTimeoutMillis, }: HTTPReceiverOptions);
|
|
99
|
+
init(app: App): void;
|
|
100
|
+
start(port: number): Promise<Server>;
|
|
101
|
+
start(portOrListenOptions: number | ListenOptions, serverOptions?: ServerOptions): Promise<Server>;
|
|
102
|
+
start(portOrListenOptions: number | ListenOptions, httpsServerOptions?: HTTPSServerOptions): Promise<HTTPSServer>;
|
|
103
|
+
stop(): Promise<void>;
|
|
104
|
+
private unboundRequestListener;
|
|
105
|
+
private handleIncomingEvent;
|
|
106
|
+
private handleInstallPathRequest;
|
|
107
|
+
private handleInstallRedirectRequest;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=HTTPReceiver.d.ts.map
|