/** DingTalk webhook configuration. */ export interface DingtalkWebhookConfig { /** Full webhook URL, e.g. `https://oapi.dingtalk.com/robot/send?access_token=xxx`. */ webhookUrl: string; /** Optional signing secret (`SEC...`) — when set, requests are signed. */ secret?: string; /** HTTP timeout in ms (default 10s). */ timeoutMs?: number; /** Backoff delays between retries for transient network errors (default 1s/2s/4s). */ retryDelaysMs?: readonly number[]; /** Extra delay for the 130101 frequency-limit retry (default 10s). */ rateLimitDelayMs?: number; } /** Body shape accepted by the DingTalk robot API. */ export type DingtalkBody = { msgtype: "text"; text: { content: string; }; at?: { atMobiles?: string[]; atUserIds?: string[]; isAtAll?: boolean; }; } | { msgtype: "markdown"; markdown: { title: string; text: string; }; at?: { atMobiles?: string[]; atUserIds?: string[]; isAtAll?: boolean; }; }; /** Response of the DingTalk robot API. */ export interface DingtalkResponse { errcode: number; errmsg: string; } /** How to address people in a DingTalk group. */ export interface DingtalkAt { /** Phone numbers — required by DingTalk for `atMobiles` (robots can't resolve names). */ mobiles?: readonly string[]; /** User ids (unionid/`userId` when known). */ userIds?: readonly string[]; /** @everyone. */ all?: boolean; } /** DingTalk caps markdown body text at 20000 chars. */ export declare const MARKDOWN_LIMIT = 20000; /** * Compute the DingTalk webhook signature. The SDK expects * `timestamp + "\n" + secret` signed with HMAC-SHA256, base64-encoded, then * URL-encoded as the `sign` query param. */ export declare function signDingtalk(secret: string, timestampMs: number): string; /** * Verify an incoming signature against a secret (used by webhook receivers, if * ever needed). Both sides are compared after URL-decoding, so a sender that * encoded `+` as `%2B` (or vice versa) still verifies, and the timestamp must * be fresh (default: ±5 minutes) to be replay-resistant. */ export declare function verifyDingtalkSignature(secret: string, timestampMs: string, sign: string, nowMs?: number, maxAgeMs?: number): boolean; /** * Minimal DingTalk group-robot webhook client built on the global `fetch` * (Node ≥ 18 / ≥ 20 — no third-party HTTP dependency). Transient failures * (network errors, the 20/min frequency limit) are retried with backoff. */ export declare class DingtalkWebhook { readonly config: DingtalkWebhookConfig; constructor(config: DingtalkWebhookConfig); /** * Send a markdown message. `title` is shown as the message's card title in * DingTalk; `text` is the markdown body (truncated to 20000 chars, the API * limit). Optionally @-mention people. */ sendMarkdown(title: string, text: string, at?: DingtalkAt): Promise; /** Send a plain-text message (content shown verbatim, `\n` newlines allowed). */ sendText(content: string, at?: DingtalkAt): Promise; private send; } //# sourceMappingURL=webhook.d.ts.map