认证签名
EdgeCron 客户侧 API 的 HMAC-SHA256 签名规则。
客户侧 API 按固定中间件顺序处理请求:
RequestID -> APIKey -> Signature -> RateLimitApp -> BillingMiddleware必填请求头
| Header | Type | Description |
|---|---|---|
X-Key-ID | string | API Key ID,例如 ak_...。 |
X-Timestamp | integer | Unix 秒级时间戳。 |
X-Signature | string | HMAC-SHA256 小写十六进制签名。 |
Content-Type | string | 带 JSON 请求体时使用 application/json。 |
签名 payload
签名输入为:
timestamp + "\n" + payloadpayload 的规则:
- 查询参数按 key 排序后拼接。
- 有请求体时使用原始 body 字符串。
- 查询和 body 同时存在时,使用
sorted_query + "&" + raw_body。
Node.js 示例
import crypto from 'node:crypto';
function sign(secret: string, timestamp: number, payload: string) {
return crypto
.createHmac('sha256', secret)
.update(`${timestamp}\n${payload}`)
.digest('hex');
}