使用Bolt-JS验证斜杠命令



我目前正在使用BoltJS编写Slack bot,并希望使用集成的verify()方法添加验证,该方法需要签名秘密以及传入请求。问题是,触发app.command()方法的命令不提供整个请求。它只提供有效负载,因此verify()方法抛出以下错误:

TypeError: stream.on is not a function

,因为所提供的参数都无效。

//These are the parameters of the app.command method
export interface SlackCommandMiddlewareArgs {
payload: SlashCommand;
command: this['payload'];
body: this['payload'];
say: SayFn;
respond: RespondFn;
ack: AckFn<string | RespondArguments>;
}
//This is what the SlashCommand Object is made of for context
export interface SlashCommand extends StringIndexed {
token: string;
command: string;
text: string;
response_url: string;
trigger_id: string;
user_id: string;
user_name: string;
team_id: string;
team_domain: string;
channel_id: string;
channel_name: string;
api_app_id: string;
enterprise_id?: string;
enterprise_name?: string;
is_enterprise_install?: string;
}

是否有任何方法可以在命令处理程序接收请求之前捕获请求,以便我可以验证它,或者我完全错过了其他东西?我还没有在文档中找到任何与此相关的内容,但我会在此期间继续查找。

来自slack的文档,声明:

一些sdk自动执行签名验证,通过简单地替换您的旧验证令牌的签名秘密来访问。有关更多细节,请参阅SDK支持部分。https://api.slack.com/authentication/verifying-requests-from-slack关于

螺栓用于JS支持的SDK之一

https://api.slack.com/authentication/verifying-requests-from-slack verifying-requests-from-slack-using-signing-secrets__sdk-support

最新更新