【问题标题】:Verification of Slash Commands using Bolt-JS使用 Bolt-JS 验证斜线命令
【发布时间】:2021-08-22 16:04:36
【问题描述】:

我目前正在使用 BoltJS 编写一个 Slack 机器人,并希望使用 integrated verify() method 添加验证,这需要签名密钥以及传入的请求。问题是,触发 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;
}

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

【问题讨论】:

    标签: javascript slack slack-api slack-commands


    【解决方案1】:

    来自 slack 的文档指出:

    某些 SDK 会自动执行签名验证,可通过简单的插入式替换旧验证令牌的签名密钥来访问。有关更多详细信息,请参阅 SDK 支持部分。 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

    【讨论】:

      猜你喜欢
      • 2022-11-26
      • 2020-07-17
      • 2022-01-25
      • 2021-06-11
      • 1970-01-01
      • 2021-08-28
      • 2022-10-20
      • 1970-01-01
      • 2023-03-17
      相关资源
      最近更新 更多