使用 Bolt-JS 验证斜杠命令

Verification of Slash Commands using Bolt-JS

我目前正在使用 BoltJS 编写一个 Slack 机器人,并希望使用 integrated verify() method 添加验证,这需要签名密码和传入请求。问题是,触发 app.command() 方法的命令不提供整个请求。它只提供有效载荷,因此 verify() 方法会抛出以下错误:

TypeError: stream.on is not a function

因为 none 个提供的参数有效。

//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 的文档指出:

Some SDKs perform signature verification automatically, accessible via an easy drop-in replacement of your signing secret for your old verification token. See the SDK support section for more detail. https://api.slack.com/authentication/verifying-requests-from-slack#about

Bolt for JS支持的SDK之一

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