AS AgentScopeAPI 手册 / API Reference

DingTalkCallbackCrypto

public final class DingTalkCallbackCrypto
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkCallbackCrypto.java:53–190

DingTalk 回调 Crypto,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.channel.dingtalk 包。核心成员包括 verify、decrypt、hasAesKey、DingTalkCallbackCrypto。

Implements DingTalk's HTTP-callback request verification and optional body decryption for robot message reception. See the DingTalk docs on verifying robot requests and callback body encryption.

Inputs:

  • appSecret — the enterprise-internal app secret. Used as the HMAC key for request signature verification: each callback carries timestamp and sign headers, where sign = Base64(HmacSHA256(appSecret, timestamp + "\n" + appSecret)) and the timestamp is a millisecond epoch DingTalk requires to be no older than one hour; timestamps ahead of local time are tolerated only within a clock-skew allowance.

  • aesKey — optional 43-character base64 (no padding). When the robot is configured with encryption, the callback body is a {"encrypt": ...} envelope instead of plain JSON, and this key (decoded with an appended "=" to 32 bytes, its first 16 bytes also used as the CBC IV) decrypts it. May be null for robots configured without encryption.

Instances are immutable and thread-safe; #verify and #decrypt may be invoked concurrently from multiple request threads.

构造器摘要Constructor Summary

构造器Constructor说明Description
public DingTalkCallbackCrypto(String appSecret, String aesKey)
初始化 `DingTalkCallbackCrypto` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public boolean verify(String timestamp, String sign)
执行 `verify` 方法。
Verifies the `timestamp`/`sign` request headers of a callback: the timestamp must be a millisecond epoch no older than `#MAX_TIMESTAMP_AGE_MS` and no further ahead of local time than `#MAX_FUTURE_TIMESTAMP_MS`, and `sign` must equal ` Base64(HmacSHA256(appSecret, timestamp + "\n" + appSecret))`.
public String decrypt(String encryptBase64)
设置该参数。
Decrypts the `encrypt` body field and returns the inner JSON payload as a UTF-8 string.
public boolean hasAesKey()
判断是否具有 `hasAesKey`。
Returns whether this channel is configured with an `aesKey` (encrypted callbacks).

构造器详情Constructor Detail

DingTalkCallbackCrypto

public DingTalkCallbackCrypto(String appSecret, String aesKey)

初始化 DingTalkCallbackCrypto 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
appSecretString应用密钥(类型 `String`)。The app secret.
aesKeyStringaes 键(类型 `String`)。The aes key.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkCallbackCrypto.java:69–90

方法详情Method Detail

verify

public boolean verify(String timestamp, String sign)

执行 verify 方法。

Verifies the timestamp/sign request headers of a callback: the timestamp must be a millisecond epoch no older than #MAX_TIMESTAMP_AGE_MS and no further ahead of local time than #MAX_FUTURE_TIMESTAMP_MS, and sign must equal ` Base64(HmacSHA256(appSecret, timestamp + "\n…

参数Parameters
名称Name类型Type说明Description
timestampString时间戳(类型 `String`)。The timestamp.
signStringsign(类型 `String`)。The sign.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkCallbackCrypto.java:98–125

decrypt

public String decrypt(String encryptBase64)

设置该参数。

Decrypts the encrypt body field and returns the inner JSON payload as a UTF-8 string.

参数Parameters
名称Name类型Type说明Description
encryptBase64Stringencrypt 基类 64(类型 `String`)。The encrypt base 64.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkCallbackCrypto.java:139–166

hasAesKey

public boolean hasAesKey()

判断是否具有 hasAesKey。

Returns whether this channel is configured with an aesKey (encrypted callbacks).

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkCallbackCrypto.java:169–171
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.