-
Notifications
You must be signed in to change notification settings - Fork 430
feat: add missing SocketMode options #2735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
misscoded
wants to merge
5
commits into
main
Choose a base branch
from
2292-expose-socket-mode-options
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e805c4e
Add missing SocketMode options
misscoded 4089a3f
Bundle SocketModeOptions into single prop
misscoded b5e1c99
Merge branch 'main' into 2292-expose-socket-mode-options
misscoded bf4bd03
Merge branch 'main' into 2292-expose-socket-mode-options
misscoded ea3b4b8
Merge branch 'main' into 2292-expose-socket-mode-options
misscoded File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import type { Agent } from 'node:http'; | |
| import type { SecureContextOptions } from 'node:tls'; | ||
| import util from 'node:util'; | ||
| import { ConsoleLogger, LogLevel, type Logger } from '@slack/logger'; | ||
| import type { SocketModeOptions } from '@slack/socket-mode'; | ||
| import { type ChatPostMessageArguments, WebClient, type WebClientOptions, addAppMetadata } from '@slack/web-api'; | ||
| import axios, { type AxiosInstance, type AxiosResponse } from 'axios'; | ||
| import type { Assistant } from './Assistant'; | ||
|
|
@@ -106,43 +107,47 @@ const tokenUsage = | |
|
|
||
| /** App initialization options */ | ||
| export interface AppOptions { | ||
| signingSecret?: HTTPReceiverOptions['signingSecret']; | ||
| endpoints?: HTTPReceiverOptions['endpoints']; | ||
| port?: HTTPReceiverOptions['port']; | ||
| customRoutes?: HTTPReceiverOptions['customRoutes']; | ||
| processBeforeResponse?: HTTPReceiverOptions['processBeforeResponse']; | ||
| signatureVerification?: HTTPReceiverOptions['signatureVerification']; | ||
| clientId?: HTTPReceiverOptions['clientId']; | ||
| clientSecret?: HTTPReceiverOptions['clientSecret']; | ||
| stateSecret?: HTTPReceiverOptions['stateSecret']; // required when using default stateStore | ||
| redirectUri?: HTTPReceiverOptions['redirectUri']; | ||
| installationStore?: HTTPReceiverOptions['installationStore']; // default MemoryInstallationStore | ||
| scopes?: HTTPReceiverOptions['scopes']; | ||
| installerOptions?: HTTPReceiverOptions['installerOptions']; | ||
| agent?: Agent; | ||
| clientTls?: Pick<SecureContextOptions, 'pfx' | 'key' | 'passphrase' | 'cert' | 'ca'>; | ||
| convoStore?: ConversationStore | false; | ||
| token?: AuthorizeResult['botToken']; // either token or authorize | ||
| appToken?: string; // TODO should this be included in AuthorizeResult | ||
| attachFunctionToken?: boolean; | ||
| authorize?: Authorize<boolean>; // either token or authorize | ||
| autoReconnectEnabled?: SocketModeOptions['autoReconnectEnabled']; | ||
| botId?: AuthorizeResult['botId']; // only used when authorize is not defined, shortcut for fetching | ||
| botUserId?: AuthorizeResult['botUserId']; // only used when authorize is not defined, shortcut for fetching | ||
| authorize?: Authorize<boolean>; // either token or authorize | ||
| receiver?: Receiver; | ||
| logger?: Logger; | ||
| logLevel?: LogLevel; | ||
| ignoreSelf?: boolean; | ||
| clientId?: HTTPReceiverOptions['clientId']; | ||
| /** | ||
| * Configurations for the web client used to send Slack API method requests. | ||
| * | ||
| * See {@link https://tools.slack.dev/node-slack-sdk/reference/web-api/interfaces/WebClientOptions} for more information. | ||
| */ | ||
| clientOptions?: WebClientOptions; | ||
| socketMode?: boolean; | ||
| developerMode?: boolean; | ||
| tokenVerificationEnabled?: boolean; | ||
| clientPingTimeout?: SocketModeOptions['clientPingTimeout']; | ||
| clientSecret?: HTTPReceiverOptions['clientSecret']; | ||
| clientTls?: Pick<SecureContextOptions, 'pfx' | 'key' | 'passphrase' | 'cert' | 'ca'>; | ||
| convoStore?: ConversationStore | false; | ||
| customRoutes?: HTTPReceiverOptions['customRoutes']; | ||
| deferInitialization?: boolean; | ||
| developerMode?: boolean; | ||
| endpoints?: HTTPReceiverOptions['endpoints']; | ||
| extendedErrorHandler?: boolean; | ||
| attachFunctionToken?: boolean; | ||
| ignoreSelf?: boolean; | ||
| installationStore?: HTTPReceiverOptions['installationStore']; // default MemoryInstallationStore | ||
| installerOptions?: HTTPReceiverOptions['installerOptions']; | ||
| logger?: Logger; | ||
| logLevel?: LogLevel; | ||
| pingPongLoggingEnabled?: SocketModeOptions['pingPongLoggingEnabled']; | ||
| port?: HTTPReceiverOptions['port']; | ||
| processBeforeResponse?: HTTPReceiverOptions['processBeforeResponse']; | ||
| receiver?: Receiver; | ||
| redirectUri?: HTTPReceiverOptions['redirectUri']; | ||
| scopes?: HTTPReceiverOptions['scopes']; | ||
| serverPingTimeout?: SocketModeOptions['serverPingTimeout']; | ||
| signatureVerification?: HTTPReceiverOptions['signatureVerification']; | ||
| signingSecret?: HTTPReceiverOptions['signingSecret']; | ||
| socketMode?: boolean; | ||
| stateSecret?: HTTPReceiverOptions['stateSecret']; // required when using default stateStore | ||
| token?: AuthorizeResult['botToken']; // either token or authorize | ||
| tokenVerificationEnabled?: boolean; | ||
| } | ||
|
|
||
| export { LogLevel, Logger } from '@slack/logger'; | ||
|
|
@@ -275,38 +280,42 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed> | |
| private attachFunctionToken: boolean; | ||
|
|
||
| public constructor({ | ||
| signingSecret = undefined, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. All still exist, just alphabetized. |
||
| endpoints = undefined, | ||
| port = undefined, | ||
| customRoutes = undefined, | ||
| authorize = undefined, | ||
| agent = undefined, | ||
| clientTls = undefined, | ||
| receiver = undefined, | ||
| convoStore = undefined, | ||
| token = undefined, | ||
| appToken = undefined, | ||
| attachFunctionToken = true, | ||
| autoReconnectEnabled = undefined, | ||
| botId = undefined, | ||
| botUserId = undefined, | ||
| authorize = undefined, | ||
| clientId = undefined, | ||
| clientOptions = undefined, | ||
| clientPingTimeout = undefined, | ||
| clientSecret = undefined, | ||
| clientTls = undefined, | ||
| convoStore = undefined, | ||
| customRoutes = undefined, | ||
| deferInitialization = false, | ||
| developerMode = false, | ||
| endpoints = undefined, | ||
| extendedErrorHandler = false, | ||
| ignoreSelf = true, | ||
| installationStore = undefined, | ||
| installerOptions = undefined, | ||
| logger = undefined, | ||
| logLevel = undefined, | ||
| ignoreSelf = true, | ||
| clientOptions = undefined, | ||
| processBeforeResponse = false, | ||
| signatureVerification = true, | ||
| clientId = undefined, | ||
| clientSecret = undefined, | ||
| stateSecret = undefined, | ||
| port = undefined, | ||
| receiver = undefined, | ||
| token = undefined, | ||
| pingPongLoggingEnabled = undefined, | ||
| redirectUri = undefined, | ||
| installationStore = undefined, | ||
| serverPingTimeout = undefined, | ||
| scopes = undefined, | ||
| installerOptions = undefined, | ||
| signatureVerification = true, | ||
| signingSecret = undefined, | ||
| socketMode = undefined, | ||
| developerMode = false, | ||
| stateSecret = undefined, | ||
| tokenVerificationEnabled = true, | ||
| extendedErrorHandler = false, | ||
| deferInitialization = false, | ||
| attachFunctionToken = true, | ||
| }: AppOptions = {}) { | ||
| /* ------------------------ Developer mode ----------------------------- */ | ||
| this.developerMode = developerMode; | ||
|
|
@@ -420,6 +429,10 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed> | |
| scopes, | ||
| appToken, | ||
| logger, | ||
| autoReconnectEnabled, | ||
| clientPingTimeout, | ||
| pingPongLoggingEnabled, | ||
| serverPingTimeout, | ||
| ); | ||
|
|
||
| /* ------------------------ Set authorize ----------------------------- */ | ||
|
|
@@ -1267,6 +1280,10 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed> | |
| scopes?: HTTPReceiverOptions['scopes'], | ||
| appToken?: string, | ||
| logger?: Logger, | ||
| autoReconnectEnabled?: SocketModeOptions['autoReconnectEnabled'], | ||
| clientPingTimeout?: SocketModeOptions['clientPingTimeout'], | ||
| pingPongLoggingEnabled?: SocketModeOptions['pingPongLoggingEnabled'], | ||
| serverPingTimeout?: SocketModeOptions['serverPingTimeout'], | ||
| ): Receiver { | ||
| if (receiver !== undefined) { | ||
| // Custom receiver supplied | ||
|
|
@@ -1284,16 +1301,20 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed> | |
| this.logger.debug('Initializing SocketModeReceiver'); | ||
| return new SocketModeReceiver({ | ||
| appToken, | ||
| autoReconnectEnabled, | ||
| clientId, | ||
| clientPingTimeout, | ||
| clientSecret, | ||
| stateSecret, | ||
| redirectUri, | ||
| customRoutes, | ||
| installerOptions: this.installerOptions, | ||
| installationStore, | ||
| pingPongLoggingEnabled, | ||
| redirectUri, | ||
| serverPingTimeout, | ||
| stateSecret, | ||
| scopes, | ||
| logger, | ||
| logLevel: this.logLevel, | ||
| installerOptions: this.installerOptions, | ||
| customRoutes, | ||
| }); | ||
| } | ||
| if (signatureVerification === true && signingSecret === undefined) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,20 +28,24 @@ import { verifyRedirectOpts } from './verify-redirect-opts'; | |
| // TODO: we throw away the key names for endpoints, so maybe we should use this interface. is it better for migrations? | ||
| // if that's the reason, let's document that with a comment. | ||
| export interface SocketModeReceiverOptions { | ||
| logger?: Logger; | ||
| logLevel?: LogLevel; | ||
| appToken: string; // App Level Token | ||
| autoReconnectEnabled?: boolean; | ||
| clientId?: string; | ||
| clientPingTimeout?: number; | ||
| clientSecret?: string; | ||
| stateSecret?: InstallProviderOptions['stateSecret']; // required when using default stateStore | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again 😉 (alphabetized) |
||
| redirectUri?: string; | ||
| installationStore?: InstallProviderOptions['installationStore']; // default MemoryInstallationStore | ||
| scopes?: InstallURLOptions['scopes']; | ||
| installerOptions?: InstallerOptions; | ||
| appToken: string; // App Level Token | ||
| customRoutes?: CustomRoute[]; | ||
| // biome-ignore lint/suspicious/noExplicitAny: user-provided custom properties can be anything | ||
| customPropertiesExtractor?: (args: any) => StringIndexed; | ||
| customRoutes?: CustomRoute[]; | ||
| installationStore?: InstallProviderOptions['installationStore']; // default MemoryInstallationStore | ||
| installerOptions?: InstallerOptions; | ||
| logger?: Logger; | ||
| logLevel?: LogLevel; | ||
| pingPongLoggingEnabled?: boolean; | ||
| processEventErrorHandler?: (args: SocketModeReceiverProcessEventErrorHandlerArgs) => Promise<boolean>; | ||
| redirectUri?: string; | ||
| scopes?: InstallURLOptions['scopes']; | ||
| serverPingTimeout?: number; | ||
| stateSecret?: InstallProviderOptions['stateSecret']; // required when using default stateStore | ||
| } | ||
|
|
||
| export interface CustomRoute { | ||
|
|
@@ -94,24 +98,32 @@ export default class SocketModeReceiver implements Receiver { | |
|
|
||
| public constructor({ | ||
| appToken, | ||
| logger = undefined, | ||
| logLevel = LogLevel.INFO, | ||
| autoReconnectEnabled = false, | ||
| clientId = undefined, | ||
| clientPingTimeout = undefined, | ||
| clientSecret = undefined, | ||
| stateSecret = undefined, | ||
| redirectUri = undefined, | ||
| installationStore = undefined, | ||
| scopes = undefined, | ||
| installerOptions = {}, | ||
| customRoutes = [], | ||
| customPropertiesExtractor = (_args) => ({}), | ||
| customRoutes = [], | ||
| installerOptions = {}, | ||
| installationStore = undefined, | ||
| logger = undefined, | ||
| logLevel = LogLevel.INFO, | ||
| pingPongLoggingEnabled = false, | ||
| processEventErrorHandler = defaultProcessEventErrorHandler, | ||
| redirectUri = undefined, | ||
| scopes = undefined, | ||
| serverPingTimeout = undefined, | ||
| stateSecret = undefined, | ||
| }: SocketModeReceiverOptions) { | ||
| this.client = new SocketModeClient({ | ||
| appToken, | ||
| logLevel, | ||
| logger, | ||
| autoReconnectEnabled, | ||
| clientOptions: installerOptions.clientOptions, | ||
| clientPingTimeout, | ||
| logger, | ||
| logLevel, | ||
| pingPongLoggingEnabled, | ||
| serverPingTimeout, | ||
| }); | ||
|
|
||
| this.logger = | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These all still exist, just made them alphabetical order bc it was driving me nuts 🫠 (but a sanity check is very welcome!).