@tencent-connect/qqbot-nodejs 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +205 -0
- package/USAGE.md +804 -0
- package/dist/QQBot.d.ts +536 -0
- package/dist/QQBot.d.ts.map +1 -0
- package/dist/QQBot.js +752 -0
- package/dist/QQBot.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/access-policy.d.ts +54 -0
- package/dist/middleware/access-policy.d.ts.map +1 -0
- package/dist/middleware/access-policy.js +93 -0
- package/dist/middleware/access-policy.js.map +1 -0
- package/dist/middleware/concurrency-guard.d.ts +105 -0
- package/dist/middleware/concurrency-guard.d.ts.map +1 -0
- package/dist/middleware/concurrency-guard.js +325 -0
- package/dist/middleware/concurrency-guard.js.map +1 -0
- package/dist/middleware/content-sanitizer.d.ts +47 -0
- package/dist/middleware/content-sanitizer.d.ts.map +1 -0
- package/dist/middleware/content-sanitizer.js +85 -0
- package/dist/middleware/content-sanitizer.js.map +1 -0
- package/dist/middleware/envelope-formatter.d.ts +51 -0
- package/dist/middleware/envelope-formatter.d.ts.map +1 -0
- package/dist/middleware/envelope-formatter.js +97 -0
- package/dist/middleware/envelope-formatter.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +36 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +59 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/history-buffer.d.ts +84 -0
- package/dist/middleware/history-buffer.d.ts.map +1 -0
- package/dist/middleware/history-buffer.js +113 -0
- package/dist/middleware/history-buffer.js.map +1 -0
- package/dist/middleware/index.d.ts +71 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +48 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/mention-gate.d.ts +99 -0
- package/dist/middleware/mention-gate.d.ts.map +1 -0
- package/dist/middleware/mention-gate.js +117 -0
- package/dist/middleware/mention-gate.js.map +1 -0
- package/dist/middleware/message-filter.d.ts +38 -0
- package/dist/middleware/message-filter.d.ts.map +1 -0
- package/dist/middleware/message-filter.js +60 -0
- package/dist/middleware/message-filter.js.map +1 -0
- package/dist/middleware/quote-ref.d.ts +106 -0
- package/dist/middleware/quote-ref.d.ts.map +1 -0
- package/dist/middleware/quote-ref.js +168 -0
- package/dist/middleware/quote-ref.js.map +1 -0
- package/dist/middleware/rate-limiter.d.ts +43 -0
- package/dist/middleware/rate-limiter.d.ts.map +1 -0
- package/dist/middleware/rate-limiter.js +77 -0
- package/dist/middleware/rate-limiter.js.map +1 -0
- package/dist/middleware/slash-command.d.ts +112 -0
- package/dist/middleware/slash-command.d.ts.map +1 -0
- package/dist/middleware/slash-command.js +203 -0
- package/dist/middleware/slash-command.js.map +1 -0
- package/dist/middleware/types.d.ts +175 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +138 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/middleware/typing-indicator.d.ts +54 -0
- package/dist/middleware/typing-indicator.d.ts.map +1 -0
- package/dist/middleware/typing-indicator.js +68 -0
- package/dist/middleware/typing-indicator.js.map +1 -0
- package/dist/protocol/api/api-client.d.ts +27 -0
- package/dist/protocol/api/api-client.d.ts.map +1 -0
- package/dist/protocol/api/api-client.js +119 -0
- package/dist/protocol/api/api-client.js.map +1 -0
- package/dist/protocol/api/media-chunked.d.ts +68 -0
- package/dist/protocol/api/media-chunked.d.ts.map +1 -0
- package/dist/protocol/api/media-chunked.js +298 -0
- package/dist/protocol/api/media-chunked.js.map +1 -0
- package/dist/protocol/api/media.d.ts +46 -0
- package/dist/protocol/api/media.d.ts.map +1 -0
- package/dist/protocol/api/media.js +101 -0
- package/dist/protocol/api/media.js.map +1 -0
- package/dist/protocol/api/messages.d.ts +86 -0
- package/dist/protocol/api/messages.d.ts.map +1 -0
- package/dist/protocol/api/messages.js +200 -0
- package/dist/protocol/api/messages.js.map +1 -0
- package/dist/protocol/api/retry.d.ts +23 -0
- package/dist/protocol/api/retry.d.ts.map +1 -0
- package/dist/protocol/api/retry.js +102 -0
- package/dist/protocol/api/retry.js.map +1 -0
- package/dist/protocol/api/routes.d.ts +23 -0
- package/dist/protocol/api/routes.d.ts.map +1 -0
- package/dist/protocol/api/routes.js +50 -0
- package/dist/protocol/api/routes.js.map +1 -0
- package/dist/protocol/api/token.d.ts +38 -0
- package/dist/protocol/api/token.d.ts.map +1 -0
- package/dist/protocol/api/token.js +191 -0
- package/dist/protocol/api/token.js.map +1 -0
- package/dist/protocol/gateway/codec.d.ts +9 -0
- package/dist/protocol/gateway/codec.d.ts.map +1 -0
- package/dist/protocol/gateway/codec.js +32 -0
- package/dist/protocol/gateway/codec.js.map +1 -0
- package/dist/protocol/gateway/constants.d.ts +71 -0
- package/dist/protocol/gateway/constants.d.ts.map +1 -0
- package/dist/protocol/gateway/constants.js +91 -0
- package/dist/protocol/gateway/constants.js.map +1 -0
- package/dist/protocol/gateway/event-dispatcher.d.ts +97 -0
- package/dist/protocol/gateway/event-dispatcher.d.ts.map +1 -0
- package/dist/protocol/gateway/event-dispatcher.js +155 -0
- package/dist/protocol/gateway/event-dispatcher.js.map +1 -0
- package/dist/protocol/gateway/gateway-connection.d.ts +73 -0
- package/dist/protocol/gateway/gateway-connection.d.ts.map +1 -0
- package/dist/protocol/gateway/gateway-connection.js +293 -0
- package/dist/protocol/gateway/gateway-connection.js.map +1 -0
- package/dist/protocol/gateway/reconnect.d.ts +25 -0
- package/dist/protocol/gateway/reconnect.d.ts.map +1 -0
- package/dist/protocol/gateway/reconnect.js +118 -0
- package/dist/protocol/gateway/reconnect.js.map +1 -0
- package/dist/protocol/index.d.ts +41 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +46 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/transport/index.d.ts +8 -0
- package/dist/protocol/transport/index.d.ts.map +1 -0
- package/dist/protocol/transport/index.js +4 -0
- package/dist/protocol/transport/index.js.map +1 -0
- package/dist/protocol/transport/types.d.ts +109 -0
- package/dist/protocol/transport/types.d.ts.map +1 -0
- package/dist/protocol/transport/types.js +15 -0
- package/dist/protocol/transport/types.js.map +1 -0
- package/dist/protocol/transport/webhook-server-node.d.ts +14 -0
- package/dist/protocol/transport/webhook-server-node.d.ts.map +1 -0
- package/dist/protocol/transport/webhook-server-node.js +57 -0
- package/dist/protocol/transport/webhook-server-node.js.map +1 -0
- package/dist/protocol/transport/webhook-verify.d.ts +49 -0
- package/dist/protocol/transport/webhook-verify.d.ts.map +1 -0
- package/dist/protocol/transport/webhook-verify.js +98 -0
- package/dist/protocol/transport/webhook-verify.js.map +1 -0
- package/dist/protocol/transport/webhook.d.ts +37 -0
- package/dist/protocol/transport/webhook.d.ts.map +1 -0
- package/dist/protocol/transport/webhook.js +183 -0
- package/dist/protocol/transport/webhook.js.map +1 -0
- package/dist/protocol/types.d.ts +270 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +59 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/protocol/utils/audio.d.ts +79 -0
- package/dist/protocol/utils/audio.d.ts.map +1 -0
- package/dist/protocol/utils/audio.js +501 -0
- package/dist/protocol/utils/audio.js.map +1 -0
- package/dist/protocol/utils/decode-media-path.d.ts +26 -0
- package/dist/protocol/utils/decode-media-path.d.ts.map +1 -0
- package/dist/protocol/utils/decode-media-path.js +79 -0
- package/dist/protocol/utils/decode-media-path.js.map +1 -0
- package/dist/protocol/utils/ffmpeg.d.ts +38 -0
- package/dist/protocol/utils/ffmpeg.d.ts.map +1 -0
- package/dist/protocol/utils/ffmpeg.js +119 -0
- package/dist/protocol/utils/ffmpeg.js.map +1 -0
- package/dist/protocol/utils/file-utils.d.ts +42 -0
- package/dist/protocol/utils/file-utils.d.ts.map +1 -0
- package/dist/protocol/utils/file-utils.js +108 -0
- package/dist/protocol/utils/file-utils.js.map +1 -0
- package/dist/protocol/utils/format.d.ts +10 -0
- package/dist/protocol/utils/format.d.ts.map +1 -0
- package/dist/protocol/utils/format.js +68 -0
- package/dist/protocol/utils/format.js.map +1 -0
- package/dist/protocol/utils/image-size.d.ts +56 -0
- package/dist/protocol/utils/image-size.d.ts.map +1 -0
- package/dist/protocol/utils/image-size.js +185 -0
- package/dist/protocol/utils/image-size.js.map +1 -0
- package/dist/protocol/utils/media-source.d.ts +145 -0
- package/dist/protocol/utils/media-source.d.ts.map +1 -0
- package/dist/protocol/utils/media-source.js +175 -0
- package/dist/protocol/utils/media-source.js.map +1 -0
- package/dist/protocol/utils/media-tags.d.ts +15 -0
- package/dist/protocol/utils/media-tags.d.ts.map +1 -0
- package/dist/protocol/utils/media-tags.js +150 -0
- package/dist/protocol/utils/media-tags.js.map +1 -0
- package/dist/protocol/utils/media-type.d.ts +41 -0
- package/dist/protocol/utils/media-type.d.ts.map +1 -0
- package/dist/protocol/utils/media-type.js +89 -0
- package/dist/protocol/utils/media-type.js.map +1 -0
- package/dist/protocol/utils/payload.d.ts +52 -0
- package/dist/protocol/utils/payload.d.ts.map +1 -0
- package/dist/protocol/utils/payload.js +100 -0
- package/dist/protocol/utils/payload.js.map +1 -0
- package/dist/protocol/utils/ref-attachments.d.ts +80 -0
- package/dist/protocol/utils/ref-attachments.d.ts.map +1 -0
- package/dist/protocol/utils/ref-attachments.js +121 -0
- package/dist/protocol/utils/ref-attachments.js.map +1 -0
- package/dist/protocol/utils/ref-index-store.d.ts +69 -0
- package/dist/protocol/utils/ref-index-store.d.ts.map +1 -0
- package/dist/protocol/utils/ref-index-store.js +227 -0
- package/dist/protocol/utils/ref-index-store.js.map +1 -0
- package/dist/protocol/utils/reply-limiter.d.ts +75 -0
- package/dist/protocol/utils/reply-limiter.d.ts.map +1 -0
- package/dist/protocol/utils/reply-limiter.js +123 -0
- package/dist/protocol/utils/reply-limiter.js.map +1 -0
- package/dist/protocol/utils/session-store.d.ts +73 -0
- package/dist/protocol/utils/session-store.d.ts.map +1 -0
- package/dist/protocol/utils/session-store.js +274 -0
- package/dist/protocol/utils/session-store.js.map +1 -0
- package/dist/protocol/utils/target.d.ts +53 -0
- package/dist/protocol/utils/target.d.ts.map +1 -0
- package/dist/protocol/utils/target.js +104 -0
- package/dist/protocol/utils/target.js.map +1 -0
- package/dist/protocol/utils/text-chunk.d.ts +21 -0
- package/dist/protocol/utils/text-chunk.d.ts.map +1 -0
- package/dist/protocol/utils/text-chunk.js +25 -0
- package/dist/protocol/utils/text-chunk.js.map +1 -0
- package/dist/protocol/utils/text-parsing.d.ts +40 -0
- package/dist/protocol/utils/text-parsing.d.ts.map +1 -0
- package/dist/protocol/utils/text-parsing.js +126 -0
- package/dist/protocol/utils/text-parsing.js.map +1 -0
- package/dist/protocol/utils/upload-cache.d.ts +27 -0
- package/dist/protocol/utils/upload-cache.d.ts.map +1 -0
- package/dist/protocol/utils/upload-cache.js +73 -0
- package/dist/protocol/utils/upload-cache.js.map +1 -0
- package/dist/protocol/utils/voice-text.d.ts +9 -0
- package/dist/protocol/utils/voice-text.d.ts.map +1 -0
- package/dist/protocol/utils/voice-text.js +16 -0
- package/dist/protocol/utils/voice-text.js.map +1 -0
- package/dist/storage/index.d.ts +23 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +21 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/kv-store.d.ts +85 -0
- package/dist/storage/kv-store.d.ts.map +1 -0
- package/dist/storage/kv-store.js +184 -0
- package/dist/storage/kv-store.js.map +1 -0
- package/dist/storage/session-adapter.d.ts +35 -0
- package/dist/storage/session-adapter.d.ts.map +1 -0
- package/dist/storage/session-adapter.js +48 -0
- package/dist/storage/session-adapter.js.map +1 -0
- package/dist/streaming.d.ts +67 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +207 -0
- package/dist/streaming.js.map +1 -0
- package/package.json +90 -0
- package/src/QQBot.ts +1123 -0
- package/src/index.ts +175 -0
- package/src/middleware/access-policy.ts +139 -0
- package/src/middleware/concurrency-guard.ts +450 -0
- package/src/middleware/content-sanitizer.ts +125 -0
- package/src/middleware/envelope-formatter.ts +140 -0
- package/src/middleware/error-handler.ts +77 -0
- package/src/middleware/history-buffer.ts +169 -0
- package/src/middleware/index.ts +129 -0
- package/src/middleware/mention-gate.ts +227 -0
- package/src/middleware/message-filter.ts +82 -0
- package/src/middleware/quote-ref.ts +237 -0
- package/src/middleware/rate-limiter.ts +112 -0
- package/src/middleware/slash-command.ts +307 -0
- package/src/middleware/types.ts +273 -0
- package/src/middleware/typing-indicator.ts +107 -0
- package/src/protocol/api/api-client.ts +170 -0
- package/src/protocol/api/media-chunked.ts +517 -0
- package/src/protocol/api/media.ts +188 -0
- package/src/protocol/api/messages.ts +345 -0
- package/src/protocol/api/retry.ts +157 -0
- package/src/protocol/api/routes.ts +62 -0
- package/src/protocol/api/token.ts +250 -0
- package/src/protocol/gateway/codec.ts +33 -0
- package/src/protocol/gateway/constants.ts +98 -0
- package/src/protocol/gateway/event-dispatcher.ts +275 -0
- package/src/protocol/gateway/gateway-connection.ts +375 -0
- package/src/protocol/gateway/reconnect.ts +155 -0
- package/src/protocol/index.ts +238 -0
- package/src/protocol/transport/index.ts +17 -0
- package/src/protocol/transport/types.ts +121 -0
- package/src/protocol/transport/webhook-server-node.ts +64 -0
- package/src/protocol/transport/webhook-verify.ts +118 -0
- package/src/protocol/transport/webhook.ts +237 -0
- package/src/protocol/types.ts +305 -0
- package/src/protocol/utils/audio.ts +663 -0
- package/src/protocol/utils/decode-media-path.ts +88 -0
- package/src/protocol/utils/ffmpeg.ts +131 -0
- package/src/protocol/utils/file-utils.ts +121 -0
- package/src/protocol/utils/format.ts +69 -0
- package/src/protocol/utils/image-size.ts +236 -0
- package/src/protocol/utils/media-source.ts +243 -0
- package/src/protocol/utils/media-tags.ts +177 -0
- package/src/protocol/utils/media-type.ts +102 -0
- package/src/protocol/utils/payload.ts +157 -0
- package/src/protocol/utils/ref-attachments.ts +190 -0
- package/src/protocol/utils/ref-index-store.ts +279 -0
- package/src/protocol/utils/reply-limiter.ts +164 -0
- package/src/protocol/utils/session-store.ts +346 -0
- package/src/protocol/utils/target.ts +121 -0
- package/src/protocol/utils/text-chunk.ts +29 -0
- package/src/protocol/utils/text-parsing.ts +153 -0
- package/src/protocol/utils/upload-cache.ts +107 -0
- package/src/protocol/utils/voice-text.ts +16 -0
- package/src/storage/index.ts +24 -0
- package/src/storage/kv-store.ts +243 -0
- package/src/storage/session-adapter.ts +66 -0
- package/src/streaming.ts +255 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket reconnection state machine and close-code handler.
|
|
3
|
+
*/
|
|
4
|
+
import { GatewayCloseCode, MAX_QUICK_DISCONNECT_COUNT, MAX_RECONNECT_ATTEMPTS, QUICK_DISCONNECT_THRESHOLD, RATE_LIMIT_DELAY, RECONNECT_DELAYS, } from "./constants.js";
|
|
5
|
+
export class ReconnectState {
|
|
6
|
+
accountId;
|
|
7
|
+
log;
|
|
8
|
+
attempts = 0;
|
|
9
|
+
lastConnectTime = 0;
|
|
10
|
+
quickDisconnectCount = 0;
|
|
11
|
+
constructor(accountId, log) {
|
|
12
|
+
this.accountId = accountId;
|
|
13
|
+
this.log = log;
|
|
14
|
+
}
|
|
15
|
+
onConnected() {
|
|
16
|
+
this.attempts = 0;
|
|
17
|
+
this.lastConnectTime = Date.now();
|
|
18
|
+
}
|
|
19
|
+
isExhausted() {
|
|
20
|
+
return this.attempts >= MAX_RECONNECT_ATTEMPTS;
|
|
21
|
+
}
|
|
22
|
+
getNextDelay(customDelay) {
|
|
23
|
+
const delay = customDelay ?? RECONNECT_DELAYS[Math.min(this.attempts, RECONNECT_DELAYS.length - 1)];
|
|
24
|
+
this.attempts++;
|
|
25
|
+
this.log?.debug?.(`[${this.accountId}] Reconnecting in ${delay}ms (attempt ${this.attempts})`);
|
|
26
|
+
return delay;
|
|
27
|
+
}
|
|
28
|
+
handleClose(code, isAborted) {
|
|
29
|
+
if (code === GatewayCloseCode.INSUFFICIENT_INTENTS ||
|
|
30
|
+
code === GatewayCloseCode.DISALLOWED_INTENTS) {
|
|
31
|
+
const reason = code === GatewayCloseCode.INSUFFICIENT_INTENTS ? "offline/sandbox-only" : "banned";
|
|
32
|
+
this.log?.error(`[${this.accountId}] Bot is ${reason}. Please contact QQ platform.`);
|
|
33
|
+
return {
|
|
34
|
+
shouldReconnect: false,
|
|
35
|
+
clearSession: false,
|
|
36
|
+
refreshToken: false,
|
|
37
|
+
fatal: true,
|
|
38
|
+
reason,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (code === GatewayCloseCode.AUTH_FAILED) {
|
|
42
|
+
this.log?.info(`[${this.accountId}] Invalid token (4004), will refresh token and reconnect`);
|
|
43
|
+
return {
|
|
44
|
+
shouldReconnect: !isAborted,
|
|
45
|
+
clearSession: false,
|
|
46
|
+
refreshToken: true,
|
|
47
|
+
fatal: false,
|
|
48
|
+
reason: "invalid token (4004)",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (code === GatewayCloseCode.RATE_LIMITED) {
|
|
52
|
+
this.log?.info(`[${this.accountId}] Rate limited (4008), waiting ${RATE_LIMIT_DELAY}ms`);
|
|
53
|
+
return {
|
|
54
|
+
shouldReconnect: !isAborted,
|
|
55
|
+
reconnectDelay: RATE_LIMIT_DELAY,
|
|
56
|
+
clearSession: false,
|
|
57
|
+
refreshToken: false,
|
|
58
|
+
fatal: false,
|
|
59
|
+
reason: "rate limited (4008)",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (code === GatewayCloseCode.INVALID_SESSION ||
|
|
63
|
+
code === GatewayCloseCode.SEQ_OUT_OF_RANGE ||
|
|
64
|
+
code === GatewayCloseCode.SESSION_TIMEOUT) {
|
|
65
|
+
const codeDesc = {
|
|
66
|
+
[GatewayCloseCode.INVALID_SESSION]: "session no longer valid",
|
|
67
|
+
[GatewayCloseCode.SEQ_OUT_OF_RANGE]: "invalid seq on resume",
|
|
68
|
+
[GatewayCloseCode.SESSION_TIMEOUT]: "session timed out",
|
|
69
|
+
};
|
|
70
|
+
this.log?.info(`[${this.accountId}] Error ${code} (${codeDesc[code]}), will re-identify`);
|
|
71
|
+
return {
|
|
72
|
+
shouldReconnect: !isAborted,
|
|
73
|
+
clearSession: true,
|
|
74
|
+
refreshToken: true,
|
|
75
|
+
fatal: false,
|
|
76
|
+
reason: codeDesc[code],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (code >= GatewayCloseCode.SERVER_ERROR_START && code <= GatewayCloseCode.SERVER_ERROR_END) {
|
|
80
|
+
this.log?.info(`[${this.accountId}] Internal error (${code}), will re-identify`);
|
|
81
|
+
return {
|
|
82
|
+
shouldReconnect: !isAborted && code !== GatewayCloseCode.NORMAL,
|
|
83
|
+
clearSession: true,
|
|
84
|
+
refreshToken: true,
|
|
85
|
+
fatal: false,
|
|
86
|
+
reason: `internal error (${code})`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const connectionDuration = Date.now() - this.lastConnectTime;
|
|
90
|
+
if (connectionDuration < QUICK_DISCONNECT_THRESHOLD && this.lastConnectTime > 0) {
|
|
91
|
+
this.quickDisconnectCount++;
|
|
92
|
+
this.log?.debug?.(`[${this.accountId}] Quick disconnect detected (${connectionDuration}ms), count: ${this.quickDisconnectCount}`);
|
|
93
|
+
if (this.quickDisconnectCount >= MAX_QUICK_DISCONNECT_COUNT) {
|
|
94
|
+
this.log?.error(`[${this.accountId}] Too many quick disconnects. This may indicate a permission issue.`);
|
|
95
|
+
this.quickDisconnectCount = 0;
|
|
96
|
+
return {
|
|
97
|
+
shouldReconnect: !isAborted && code !== 1000,
|
|
98
|
+
reconnectDelay: RATE_LIMIT_DELAY,
|
|
99
|
+
clearSession: false,
|
|
100
|
+
refreshToken: false,
|
|
101
|
+
fatal: false,
|
|
102
|
+
reason: "too many quick disconnects",
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.quickDisconnectCount = 0;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
shouldReconnect: !isAborted && code !== GatewayCloseCode.NORMAL,
|
|
111
|
+
clearSession: false,
|
|
112
|
+
refreshToken: false,
|
|
113
|
+
fatal: false,
|
|
114
|
+
reason: `close code ${code}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=reconnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconnect.js","sourceRoot":"","sources":["../../../src/protocol/gateway/reconnect.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAWxB,MAAM,OAAO,cAAc;IAMN;IACA;IANX,QAAQ,GAAG,CAAC,CAAC;IACb,eAAe,GAAG,CAAC,CAAC;IACpB,oBAAoB,GAAG,CAAC,CAAC;IAEjC,YACmB,SAAiB,EACjB,GAAY;QADZ,cAAS,GAAT,SAAS,CAAQ;QACjB,QAAG,GAAH,GAAG,CAAS;IAC5B,CAAC;IAEJ,WAAW;QACT,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,IAAI,sBAAsB,CAAC;IACjD,CAAC;IAED,YAAY,CAAC,WAAoB;QAC/B,MAAM,KAAK,GACT,WAAW,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,EAAE,CAAC;QA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GAAG,IAAI,CAAC,eAAe,CAAC;QAC7D,IAAI,kBAAkB,GAAG,0BAA0B,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;YAChF,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CACf,IAAI,IAAI,CAAC,SAAS,gCAAgC,kBAAkB,eAAe,IAAI,CAAC,oBAAoB,EAAE,CAC/G,CAAC;YAEF,IAAI,IAAI,CAAC,oBAAoB,IAAI,0BAA0B,EAAE,CAAC;gBAC5D,IAAI,CAAC,GAAG,EAAE,KAAK,CACb,IAAI,IAAI,CAAC,SAAS,qEAAqE,CACxF,CAAC;gBACF,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;gBAC9B,OAAO;oBACL,eAAe,EAAE,CAAC,SAAS,IAAI,IAAI,KAAK,IAAI;oBAC5C,cAAc,EAAE,gBAAgB;oBAChC,YAAY,EAAE,KAAK;oBACnB,YAAY,EAAE,KAAK;oBACnB,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,4BAA4B;iBACrC,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;QAChC,CAAC;QAED,OAAO;YACL,eAAe,EAAE,CAAC,SAAS,IAAI,IAAI,KAAK,gBAAgB,CAAC,MAAM;YAC/D,YAAY,EAAE,KAAK;YACnB,YAAY,EAAE,KAAK;YACnB,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,cAAc,IAAI,EAAE;SAC7B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level protocol exports for the QQ Open Platform.
|
|
3
|
+
*
|
|
4
|
+
* Most users should consume the high-level {@link QQBot} facade from
|
|
5
|
+
* the package root. This entry point is intended for advanced users who
|
|
6
|
+
* need to compose primitives directly.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
export { ApiClient, type RequestOptions } from "./api/api-client.js";
|
|
10
|
+
export { TokenManager, type BackgroundRefreshOptions } from "./api/token.js";
|
|
11
|
+
export { MessageApi, type MessageApiConfig, getNextMsgSeq, } from "./api/messages.js";
|
|
12
|
+
export { MediaApi, type MediaApiConfig, type SanitizeFileNameFn, type UploadCacheAdapter, } from "./api/media.js";
|
|
13
|
+
export { ChunkedMediaApi, type ChunkedMediaApiConfig, type ChunkedMediaSource, type ChunkedUploadProgress, type UploadChunkedOptions, UploadDailyLimitExceededError, } from "./api/media-chunked.js";
|
|
14
|
+
export { withRetry, buildPartFinishPersistentPolicy, COMPLETE_UPLOAD_RETRY_POLICY, PART_FINISH_RETRY_POLICY, PART_FINISH_RETRYABLE_CODES, UPLOAD_PREPARE_FALLBACK_CODE, UPLOAD_RETRY_POLICY, type PersistentRetryPolicy, type RetryPolicy, } from "./api/retry.js";
|
|
15
|
+
export { channelMessagePath, dmMessagePath, gatewayPath, interactionPath, mediaUploadPath, messagePath, streamMessagePath, uploadCompletePath, uploadPartFinishPath, uploadPreparePath, } from "./api/routes.js";
|
|
16
|
+
export { FULL_INTENTS, GatewayCloseCode, GatewayEvent, GatewayOp, InteractionType, MAX_QUICK_DISCONNECT_COUNT, MAX_RECONNECT_ATTEMPTS, QUICK_DISCONNECT_THRESHOLD, RATE_LIMIT_DELAY, RECONNECT_DELAYS, } from "./gateway/constants.js";
|
|
17
|
+
export { decodeGatewayMessageData, readOptionalMessageSceneExt } from "./gateway/codec.js";
|
|
18
|
+
export { ReconnectState, type CloseAction } from "./gateway/reconnect.js";
|
|
19
|
+
export { dispatchEvent, type DispatchResult, type InboundMessage, type InboundAttachment, type InboundMsgElement, } from "./gateway/event-dispatcher.js";
|
|
20
|
+
export { GatewayConnection, type GatewayConnectionOptions, type PersistedSession, type SessionPersistencePort, } from "./gateway/gateway-connection.js";
|
|
21
|
+
export { formatDuration, formatErrorMessage, formatFileSize } from "./utils/format.js";
|
|
22
|
+
export { CHUNKED_UPLOAD_MAX_SIZE, LARGE_FILE_THRESHOLD, MAX_UPLOAD_SIZE, MEDIA_FILE_TYPE_INFO, getFileTypeName, getImageMimeType, getMaxUploadSize, getMimeType, sanitizeFileName, } from "./utils/file-utils.js";
|
|
23
|
+
export { UploadCache, computeFileHash } from "./utils/upload-cache.js";
|
|
24
|
+
export { ReplyLimiter, type ReplyLimitResult, type ReplyLimiterConfig, } from "./utils/reply-limiter.js";
|
|
25
|
+
export { FUZZY_MEDIA_TAG_REGEX, SELF_CLOSING_TAG_REGEX, normalizeMediaTags, } from "./utils/media-tags.js";
|
|
26
|
+
export { TRANSCRIPT_SOURCE_LABELS, formatAttachmentTags, formatRefEntryForAgent, renderAttachmentTags, type AttachmentSummary, type RefAttachmentSummary, type RefIndexEntry, type RenderMode, type RenderOptions, } from "./utils/ref-attachments.js";
|
|
27
|
+
export { JsonlRefIndexStore, type JsonlRefIndexStoreOptions, type RefIndexStoreLogger, } from "./utils/ref-index-store.js";
|
|
28
|
+
export { FileSessionStore, type FileSessionStoreOptions, type SessionState, type SessionStoreLogger, } from "./utils/session-store.js";
|
|
29
|
+
export { MSG_TYPE_QUOTE, buildAttachmentSummaries, filterInternalMarkers, parseFaceTags, parseRefIndices, } from "./utils/text-parsing.js";
|
|
30
|
+
export { materializeForOneShotUpload, normalizeSource, openLocalFile, tryParseDataUrl, type MediaSource, type OpenedLocalFile, type RawMediaSource, } from "./utils/media-source.js";
|
|
31
|
+
export { DEFAULT_IMAGE_SIZE, extractQQBotImageSize, formatQQBotMarkdownImage, getImageSizeFromDataUrl, getImageSizeFromUrl, hasQQBotImageSize, parseImageSize, type ImageBytesFetcher, type ImageSize, } from "./utils/image-size.js";
|
|
32
|
+
export { checkSilkWasmAvailable, detectFfmpeg, isWindows, resetFfmpegCache, } from "./utils/ffmpeg.js";
|
|
33
|
+
export { audioFileToSilkBase64, convertSilkToWav, ffmpegToPCM, isAudioFile, isVoiceAttachment, loadSilkWasm, parseWavFallback, pcmToSilk, pcmToWav, shouldTranscodeVoice, stripAmrHeader, waitForFile, wasmDecodeMp3ToPCM, type AudioLogger, } from "./utils/audio.js";
|
|
34
|
+
export { decodeCronPayload, encodePayloadForCron, isCronReminderPayload, isMediaPayload, parseQQBotPayload, type CronReminderPayload, type MediaPayload, type ParseResult, type QQBotPayload, } from "./utils/payload.js";
|
|
35
|
+
export { TEXT_CHUNK_LIMIT, chunkText, type ChunkTextFn, } from "./utils/text-chunk.js";
|
|
36
|
+
export { formatVoiceText } from "./utils/voice-text.js";
|
|
37
|
+
export { decodeMediaPath, type MediaPathDecodeLogger, } from "./utils/decode-media-path.js";
|
|
38
|
+
export { IMAGE_MIME_TYPES, MEDIA_KIND_LABELS, detectMediaKind, getCleanExtension, isDataSource, isHttpSource, isImageFile, isRemoteOrDataSource, isVideoFile, type MediaKind, } from "./utils/media-type.js";
|
|
39
|
+
export { looksLikeQQBotTarget, normalizeTarget, parseTarget, targetToChatScope, type ParsedTarget, type TargetType, } from "./utils/target.js";
|
|
40
|
+
export { WebhookTransport, NodeHttpWebhookServer, verifyWebhookSignature, signValidationResponse, ed25519Sign, type EventTransport, type EventTransportCallbacks, type WebhookTransportOptions, type WebhookServerAdapter, type WebhookRequest, type WebhookResponse, type WebhookRequestHandler, } from "./transport/index.js";
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,KAAK,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EACL,UAAU,EACV,KAAK,gBAAgB,EACrB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,QAAQ,EAC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Low-level protocol exports for the QQ Open Platform.
|
|
3
|
+
*
|
|
4
|
+
* Most users should consume the high-level {@link QQBot} facade from
|
|
5
|
+
* the package root. This entry point is intended for advanced users who
|
|
6
|
+
* need to compose primitives directly.
|
|
7
|
+
*/
|
|
8
|
+
// ---- Types ----
|
|
9
|
+
export * from "./types.js";
|
|
10
|
+
// ---- API ----
|
|
11
|
+
export { ApiClient } from "./api/api-client.js";
|
|
12
|
+
export { TokenManager } from "./api/token.js";
|
|
13
|
+
export { MessageApi, getNextMsgSeq, } from "./api/messages.js";
|
|
14
|
+
export { MediaApi, } from "./api/media.js";
|
|
15
|
+
export { ChunkedMediaApi, UploadDailyLimitExceededError, } from "./api/media-chunked.js";
|
|
16
|
+
export { withRetry, buildPartFinishPersistentPolicy, COMPLETE_UPLOAD_RETRY_POLICY, PART_FINISH_RETRY_POLICY, PART_FINISH_RETRYABLE_CODES, UPLOAD_PREPARE_FALLBACK_CODE, UPLOAD_RETRY_POLICY, } from "./api/retry.js";
|
|
17
|
+
export { channelMessagePath, dmMessagePath, gatewayPath, interactionPath, mediaUploadPath, messagePath, streamMessagePath, uploadCompletePath, uploadPartFinishPath, uploadPreparePath, } from "./api/routes.js";
|
|
18
|
+
// ---- Gateway ----
|
|
19
|
+
export { FULL_INTENTS, GatewayCloseCode, GatewayEvent, GatewayOp, InteractionType, MAX_QUICK_DISCONNECT_COUNT, MAX_RECONNECT_ATTEMPTS, QUICK_DISCONNECT_THRESHOLD, RATE_LIMIT_DELAY, RECONNECT_DELAYS, } from "./gateway/constants.js";
|
|
20
|
+
export { decodeGatewayMessageData, readOptionalMessageSceneExt } from "./gateway/codec.js";
|
|
21
|
+
export { ReconnectState } from "./gateway/reconnect.js";
|
|
22
|
+
export { dispatchEvent, } from "./gateway/event-dispatcher.js";
|
|
23
|
+
export { GatewayConnection, } from "./gateway/gateway-connection.js";
|
|
24
|
+
// ---- Utils ----
|
|
25
|
+
export { formatDuration, formatErrorMessage, formatFileSize } from "./utils/format.js";
|
|
26
|
+
export { CHUNKED_UPLOAD_MAX_SIZE, LARGE_FILE_THRESHOLD, MAX_UPLOAD_SIZE, MEDIA_FILE_TYPE_INFO, getFileTypeName, getImageMimeType, getMaxUploadSize, getMimeType, sanitizeFileName, } from "./utils/file-utils.js";
|
|
27
|
+
export { UploadCache, computeFileHash } from "./utils/upload-cache.js";
|
|
28
|
+
export { ReplyLimiter, } from "./utils/reply-limiter.js";
|
|
29
|
+
export { FUZZY_MEDIA_TAG_REGEX, SELF_CLOSING_TAG_REGEX, normalizeMediaTags, } from "./utils/media-tags.js";
|
|
30
|
+
export { TRANSCRIPT_SOURCE_LABELS, formatAttachmentTags, formatRefEntryForAgent, renderAttachmentTags, } from "./utils/ref-attachments.js";
|
|
31
|
+
export { JsonlRefIndexStore, } from "./utils/ref-index-store.js";
|
|
32
|
+
export { FileSessionStore, } from "./utils/session-store.js";
|
|
33
|
+
export { MSG_TYPE_QUOTE, buildAttachmentSummaries, filterInternalMarkers, parseFaceTags, parseRefIndices, } from "./utils/text-parsing.js";
|
|
34
|
+
export { materializeForOneShotUpload, normalizeSource, openLocalFile, tryParseDataUrl, } from "./utils/media-source.js";
|
|
35
|
+
export { DEFAULT_IMAGE_SIZE, extractQQBotImageSize, formatQQBotMarkdownImage, getImageSizeFromDataUrl, getImageSizeFromUrl, hasQQBotImageSize, parseImageSize, } from "./utils/image-size.js";
|
|
36
|
+
export { checkSilkWasmAvailable, detectFfmpeg, isWindows, resetFfmpegCache, } from "./utils/ffmpeg.js";
|
|
37
|
+
export { audioFileToSilkBase64, convertSilkToWav, ffmpegToPCM, isAudioFile, isVoiceAttachment, loadSilkWasm, parseWavFallback, pcmToSilk, pcmToWav, shouldTranscodeVoice, stripAmrHeader, waitForFile, wasmDecodeMp3ToPCM, } from "./utils/audio.js";
|
|
38
|
+
export { decodeCronPayload, encodePayloadForCron, isCronReminderPayload, isMediaPayload, parseQQBotPayload, } from "./utils/payload.js";
|
|
39
|
+
export { TEXT_CHUNK_LIMIT, chunkText, } from "./utils/text-chunk.js";
|
|
40
|
+
export { formatVoiceText } from "./utils/voice-text.js";
|
|
41
|
+
export { decodeMediaPath, } from "./utils/decode-media-path.js";
|
|
42
|
+
export { IMAGE_MIME_TYPES, MEDIA_KIND_LABELS, detectMediaKind, getCleanExtension, isDataSource, isHttpSource, isImageFile, isRemoteOrDataSource, isVideoFile, } from "./utils/media-type.js";
|
|
43
|
+
export { looksLikeQQBotTarget, normalizeTarget, parseTarget, targetToChatScope, } from "./utils/target.js";
|
|
44
|
+
// ---- Transport ----
|
|
45
|
+
export { WebhookTransport, NodeHttpWebhookServer, verifyWebhookSignature, signValidationResponse, ed25519Sign, } from "./transport/index.js";
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kBAAkB;AAClB,cAAc,YAAY,CAAC;AAE3B,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAuB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAiC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EACL,UAAU,EAEV,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,QAAQ,GAIT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKf,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,SAAS,EACT,+BAA+B,EAC/B,4BAA4B,EAC5B,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,mBAAmB,GAGpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,eAAe,EACf,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,oBAAoB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ACjC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,GAGf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,SAAS,EACT,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,kBAAkB,GAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,GAKlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,SAAS,GAEV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,eAAe,GAEhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,WAAW,GAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,iBAAiB,GAGlB,MAAM,mBAAmB,CAAC;AAE3B,sBAAsB;AACtB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,GAQZ,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport module — event receiving mechanisms.
|
|
3
|
+
*/
|
|
4
|
+
export type { EventTransport, EventTransportCallbacks, WebhookTransportOptions, WebSocketTransportOptions, WebhookServerAdapter, WebhookRequest, WebhookResponse, WebhookRequestHandler, } from "./types.js";
|
|
5
|
+
export { WebhookTransport } from "./webhook.js";
|
|
6
|
+
export { NodeHttpWebhookServer } from "./webhook-server-node.js";
|
|
7
|
+
export { verifyWebhookSignature, signValidationResponse, ed25519Sign } from "./webhook-verify.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/protocol/transport/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/protocol/transport/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventTransport — abstract interface for receiving QQ Bot events.
|
|
3
|
+
*
|
|
4
|
+
* The SDK supports multiple transport mechanisms for receiving events
|
|
5
|
+
* from the QQ Open Platform:
|
|
6
|
+
*
|
|
7
|
+
* - **WebSocket** (default): long-lived connection with heartbeat, RESUME, etc.
|
|
8
|
+
* - **Webhook** (HTTP callback): QQ POSTs events to your HTTPS endpoint.
|
|
9
|
+
*
|
|
10
|
+
* Both transports deliver events through the same callback interface,
|
|
11
|
+
* so the middleware chain and event listeners work identically regardless
|
|
12
|
+
* of transport choice.
|
|
13
|
+
*/
|
|
14
|
+
import type { InboundMessage } from "../gateway/event-dispatcher.js";
|
|
15
|
+
import type { InteractionEvent, Logger } from "../types.js";
|
|
16
|
+
/** Callbacks invoked by any transport when events arrive. */
|
|
17
|
+
export interface EventTransportCallbacks {
|
|
18
|
+
onReady?: (data: unknown) => void;
|
|
19
|
+
onResumed?: (data: unknown) => void;
|
|
20
|
+
onError?: (error: Error) => void;
|
|
21
|
+
onMessage: (msg: InboundMessage) => void | Promise<void>;
|
|
22
|
+
onInteraction?: (event: InteractionEvent) => void | Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An event transport that can start/stop receiving events.
|
|
26
|
+
*
|
|
27
|
+
* Implementations:
|
|
28
|
+
* - `WebSocketTransport` — wraps GatewayConnection
|
|
29
|
+
* - `WebhookTransport` — HTTP server receiving POST callbacks
|
|
30
|
+
*/
|
|
31
|
+
export interface EventTransport {
|
|
32
|
+
/** Start receiving events. Resolves when the transport is stopped. */
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
/** Stop receiving events and clean up resources. */
|
|
35
|
+
stop(): void;
|
|
36
|
+
}
|
|
37
|
+
export interface WebSocketTransportOptions {
|
|
38
|
+
/** Account info. */
|
|
39
|
+
account: {
|
|
40
|
+
accountId: string;
|
|
41
|
+
appId: string;
|
|
42
|
+
clientSecret: string;
|
|
43
|
+
};
|
|
44
|
+
/** Abort signal for graceful shutdown. */
|
|
45
|
+
abortSignal: AbortSignal;
|
|
46
|
+
/** Logger. */
|
|
47
|
+
log?: Logger;
|
|
48
|
+
/** User-Agent. */
|
|
49
|
+
userAgent?: string;
|
|
50
|
+
/** Intent mask. */
|
|
51
|
+
intents?: number;
|
|
52
|
+
/** Token fetcher. */
|
|
53
|
+
getAccessToken: () => Promise<string>;
|
|
54
|
+
/** Clear cached token. */
|
|
55
|
+
clearTokenCache?: () => void;
|
|
56
|
+
/** Get gateway WS URL. */
|
|
57
|
+
getGatewayUrl: (token: string) => Promise<string>;
|
|
58
|
+
/** Session persistence. */
|
|
59
|
+
session?: import("../gateway/gateway-connection.js").SessionPersistencePort;
|
|
60
|
+
}
|
|
61
|
+
export interface WebhookTransportOptions {
|
|
62
|
+
/** Bot AppID. */
|
|
63
|
+
appId: string;
|
|
64
|
+
/** Bot AppSecret (used for Ed25519 signature verification). */
|
|
65
|
+
appSecret: string;
|
|
66
|
+
/** Port to listen on. Defaults to 8080. */
|
|
67
|
+
port?: number;
|
|
68
|
+
/** Path to listen on. Defaults to "/". */
|
|
69
|
+
path?: string;
|
|
70
|
+
/** Account ID for logging. */
|
|
71
|
+
accountId?: string;
|
|
72
|
+
/** Logger. */
|
|
73
|
+
log?: Logger;
|
|
74
|
+
/** Abort signal for graceful shutdown. */
|
|
75
|
+
abortSignal?: AbortSignal;
|
|
76
|
+
/**
|
|
77
|
+
* Bring your own HTTP server adapter (Express/Fastify/Koa/etc).
|
|
78
|
+
* If not provided, SDK uses built-in node:http server.
|
|
79
|
+
*/
|
|
80
|
+
server?: WebhookServerAdapter;
|
|
81
|
+
}
|
|
82
|
+
/** Incoming HTTP request shape (framework-agnostic). */
|
|
83
|
+
export interface WebhookRequest {
|
|
84
|
+
/** Raw request body as Buffer. */
|
|
85
|
+
body: Buffer;
|
|
86
|
+
/** Request headers (lowercase keys). */
|
|
87
|
+
headers: Record<string, string | string[] | undefined>;
|
|
88
|
+
}
|
|
89
|
+
/** Response shape that the webhook handler returns. */
|
|
90
|
+
export interface WebhookResponse {
|
|
91
|
+
status: number;
|
|
92
|
+
headers?: Record<string, string>;
|
|
93
|
+
body: string;
|
|
94
|
+
}
|
|
95
|
+
/** Handler function type for webhook. */
|
|
96
|
+
export type WebhookRequestHandler = (req: WebhookRequest) => Promise<WebhookResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* Adapter interface for plugging in any HTTP server framework.
|
|
99
|
+
*
|
|
100
|
+
* If you use Express/Fastify/Koa, implement this interface and pass it
|
|
101
|
+
* as `webhook.server`. Otherwise the SDK uses a built-in `node:http` server.
|
|
102
|
+
*/
|
|
103
|
+
export interface WebhookServerAdapter {
|
|
104
|
+
/** Start listening and route requests to handler. */
|
|
105
|
+
listen(port: number, path: string, handler: WebhookRequestHandler): Promise<void>;
|
|
106
|
+
/** Stop the server. */
|
|
107
|
+
close(): void;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/protocol/transport/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI5D,6DAA6D;AAC7D,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AAID;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,oDAAoD;IACpD,IAAI,IAAI,IAAI,CAAC;CACd;AAID,MAAM,WAA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G,SAAS,CAAC,CAAC;CACxD;AAED,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAEtF;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,uBAAuB;IACvB,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventTransport — abstract interface for receiving QQ Bot events.
|
|
3
|
+
*
|
|
4
|
+
* The SDK supports multiple transport mechanisms for receiving events
|
|
5
|
+
* from the QQ Open Platform:
|
|
6
|
+
*
|
|
7
|
+
* - **WebSocket** (default): long-lived connection with heartbeat, RESUME, etc.
|
|
8
|
+
* - **Webhook** (HTTP callback): QQ POSTs events to your HTTPS endpoint.
|
|
9
|
+
*
|
|
10
|
+
* Both transports deliver events through the same callback interface,
|
|
11
|
+
* so the middleware chain and event listeners work identically regardless
|
|
12
|
+
* of transport choice.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/protocol/transport/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in node:http webhook server adapter.
|
|
3
|
+
*
|
|
4
|
+
* A minimal HTTP server that receives QQ webhook callbacks. If you prefer
|
|
5
|
+
* Express/Fastify/Koa, implement `WebhookServerAdapter` and pass it as
|
|
6
|
+
* `webhook.server` in QQBotOptions.
|
|
7
|
+
*/
|
|
8
|
+
import type { WebhookRequestHandler, WebhookServerAdapter } from "./types.js";
|
|
9
|
+
export declare class NodeHttpWebhookServer implements WebhookServerAdapter {
|
|
10
|
+
private server;
|
|
11
|
+
listen(port: number, path: string, handler: WebhookRequestHandler): Promise<void>;
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=webhook-server-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-server-node.d.ts","sourceRoot":"","sources":["../../../src/protocol/transport/webhook-server-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9E,qBAAa,qBAAsB,YAAW,oBAAoB;IAChE,OAAO,CAAC,MAAM,CAA4B;IAEpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CvF,KAAK,IAAI,IAAI;CAMd"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in node:http webhook server adapter.
|
|
3
|
+
*
|
|
4
|
+
* A minimal HTTP server that receives QQ webhook callbacks. If you prefer
|
|
5
|
+
* Express/Fastify/Koa, implement `WebhookServerAdapter` and pass it as
|
|
6
|
+
* `webhook.server` in QQBotOptions.
|
|
7
|
+
*/
|
|
8
|
+
import * as http from "node:http";
|
|
9
|
+
export class NodeHttpWebhookServer {
|
|
10
|
+
server = null;
|
|
11
|
+
async listen(port, path, handler) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const server = http.createServer(async (req, res) => {
|
|
14
|
+
// Only accept POST to the configured path
|
|
15
|
+
if (req.method !== "POST" || req.url !== path) {
|
|
16
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
17
|
+
res.end("Not Found");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Collect body
|
|
21
|
+
const chunks = [];
|
|
22
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
23
|
+
req.on("end", async () => {
|
|
24
|
+
try {
|
|
25
|
+
const body = Buffer.concat(chunks);
|
|
26
|
+
const headers = {};
|
|
27
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
28
|
+
headers[key.toLowerCase()] = value;
|
|
29
|
+
}
|
|
30
|
+
const response = await handler({ body, headers });
|
|
31
|
+
res.writeHead(response.status, {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
...(response.headers ?? {}),
|
|
34
|
+
});
|
|
35
|
+
res.end(response.body);
|
|
36
|
+
}
|
|
37
|
+
catch (_err) {
|
|
38
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
39
|
+
res.end("Internal Server Error");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
server.on("error", reject);
|
|
44
|
+
server.listen(port, () => {
|
|
45
|
+
this.server = server;
|
|
46
|
+
resolve();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
close() {
|
|
51
|
+
if (this.server) {
|
|
52
|
+
this.server.close();
|
|
53
|
+
this.server = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=webhook-server-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-server-node.js","sourceRoot":"","sources":["../../../src/protocol/transport/webhook-server-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,MAAM,OAAO,qBAAqB;IACxB,MAAM,GAAuB,IAAI,CAAC;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AAQ,CAAC,OAAO,IAAI,EAAE,CAAC;yBAC5B,CAAC,CAAC;wBACH,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACzB,CAAC;oBAAC,OAAO,IAAI,EAAE,CAAC;wBACd,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;wBACrD,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;oBACnC,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;gBACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBACrB,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook signature verification — Ed25519.
|
|
3
|
+
*
|
|
4
|
+
* QQ Open Platform uses Ed25519 for webhook callback verification:
|
|
5
|
+
* 1. Bot secret is padded/truncated to 32 bytes as the Ed25519 seed.
|
|
6
|
+
* 2. The private key signs `timestamp + body` for request verification.
|
|
7
|
+
* 3. For callback URL validation (op:13), signs `event_ts + plain_token`.
|
|
8
|
+
*
|
|
9
|
+
* Reference: https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/interface-framework/event-emit.html
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Sign a message using the bot's Ed25519 private key.
|
|
13
|
+
* Returns hex-encoded signature.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ed25519Sign(botSecret: string, message: Buffer): string;
|
|
16
|
+
/**
|
|
17
|
+
* Verify an Ed25519 signature from a QQ webhook callback request.
|
|
18
|
+
*
|
|
19
|
+
* @param params.body - Raw request body (Buffer)
|
|
20
|
+
* @param params.timestamp - Value of `X-Signature-Timestamp` header
|
|
21
|
+
* @param params.signature - Value of `X-Signature-Ed25519` header (hex string)
|
|
22
|
+
* @param params.botSecret - The bot's AppSecret
|
|
23
|
+
* @returns `true` if signature is valid
|
|
24
|
+
*/
|
|
25
|
+
export declare function verifyWebhookSignature(params: {
|
|
26
|
+
body: Buffer;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
signature: string;
|
|
29
|
+
botSecret: string;
|
|
30
|
+
}): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Generate the response for callback URL validation (op:13).
|
|
33
|
+
*
|
|
34
|
+
* QQ sends `{ op: 13, d: { plain_token, event_ts } }` to verify
|
|
35
|
+
* the callback URL. We must return `{ plain_token, signature }`.
|
|
36
|
+
*
|
|
37
|
+
* @param params.plainToken - The `plain_token` from the validation request
|
|
38
|
+
* @param params.eventTs - The `event_ts` from the validation request
|
|
39
|
+
* @param params.botSecret - The bot's AppSecret
|
|
40
|
+
*/
|
|
41
|
+
export declare function signValidationResponse(params: {
|
|
42
|
+
plainToken: string;
|
|
43
|
+
eventTs: string;
|
|
44
|
+
botSecret: string;
|
|
45
|
+
}): {
|
|
46
|
+
plain_token: string;
|
|
47
|
+
signature: string;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=webhook-verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-verify.d.ts","sourceRoot":"","sources":["../../../src/protocol/transport/webhook-verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuCH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAItE;AAID;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAcV;AAID;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAW7C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook signature verification — Ed25519.
|
|
3
|
+
*
|
|
4
|
+
* QQ Open Platform uses Ed25519 for webhook callback verification:
|
|
5
|
+
* 1. Bot secret is padded/truncated to 32 bytes as the Ed25519 seed.
|
|
6
|
+
* 2. The private key signs `timestamp + body` for request verification.
|
|
7
|
+
* 3. For callback URL validation (op:13), signs `event_ts + plain_token`.
|
|
8
|
+
*
|
|
9
|
+
* Reference: https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/interface-framework/event-emit.html
|
|
10
|
+
*/
|
|
11
|
+
import * as crypto from "node:crypto";
|
|
12
|
+
// ============ Seed derivation ============
|
|
13
|
+
/**
|
|
14
|
+
* Derive an Ed25519 seed (32 bytes) from the bot secret.
|
|
15
|
+
* QQ's spec: repeat the secret until >= 32 chars, then truncate to 32.
|
|
16
|
+
*/
|
|
17
|
+
function deriveSeed(botSecret) {
|
|
18
|
+
let seed = botSecret;
|
|
19
|
+
while (seed.length < 32) {
|
|
20
|
+
seed = seed + seed;
|
|
21
|
+
}
|
|
22
|
+
return Buffer.from(seed.slice(0, 32), "utf-8");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate Ed25519 key pair from bot secret.
|
|
26
|
+
*/
|
|
27
|
+
function getKeyPair(botSecret) {
|
|
28
|
+
const seed = deriveSeed(botSecret);
|
|
29
|
+
// Node.js Ed25519: create private key from raw 32-byte seed
|
|
30
|
+
const privateKey = crypto.createPrivateKey({
|
|
31
|
+
key: Buffer.concat([
|
|
32
|
+
// Ed25519 PKCS8 DER prefix for 32-byte seed
|
|
33
|
+
Buffer.from("302e020100300506032b657004220420", "hex"),
|
|
34
|
+
seed,
|
|
35
|
+
]),
|
|
36
|
+
format: "der",
|
|
37
|
+
type: "pkcs8",
|
|
38
|
+
});
|
|
39
|
+
const publicKey = crypto.createPublicKey(privateKey);
|
|
40
|
+
return { privateKey, publicKey };
|
|
41
|
+
}
|
|
42
|
+
// ============ Signature generation ============
|
|
43
|
+
/**
|
|
44
|
+
* Sign a message using the bot's Ed25519 private key.
|
|
45
|
+
* Returns hex-encoded signature.
|
|
46
|
+
*/
|
|
47
|
+
export function ed25519Sign(botSecret, message) {
|
|
48
|
+
const { privateKey } = getKeyPair(botSecret);
|
|
49
|
+
const signature = crypto.sign(null, message, privateKey);
|
|
50
|
+
return signature.toString("hex");
|
|
51
|
+
}
|
|
52
|
+
// ============ Signature verification ============
|
|
53
|
+
/**
|
|
54
|
+
* Verify an Ed25519 signature from a QQ webhook callback request.
|
|
55
|
+
*
|
|
56
|
+
* @param params.body - Raw request body (Buffer)
|
|
57
|
+
* @param params.timestamp - Value of `X-Signature-Timestamp` header
|
|
58
|
+
* @param params.signature - Value of `X-Signature-Ed25519` header (hex string)
|
|
59
|
+
* @param params.botSecret - The bot's AppSecret
|
|
60
|
+
* @returns `true` if signature is valid
|
|
61
|
+
*/
|
|
62
|
+
export function verifyWebhookSignature(params) {
|
|
63
|
+
const { body, timestamp, signature, botSecret } = params;
|
|
64
|
+
try {
|
|
65
|
+
const { publicKey } = getKeyPair(botSecret);
|
|
66
|
+
const message = Buffer.concat([
|
|
67
|
+
Buffer.from(timestamp, "utf-8"),
|
|
68
|
+
body,
|
|
69
|
+
]);
|
|
70
|
+
const sigBuffer = Buffer.from(signature, "hex");
|
|
71
|
+
return crypto.verify(null, message, publicKey, sigBuffer);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// ============ Callback URL validation (op:13) ============
|
|
78
|
+
/**
|
|
79
|
+
* Generate the response for callback URL validation (op:13).
|
|
80
|
+
*
|
|
81
|
+
* QQ sends `{ op: 13, d: { plain_token, event_ts } }` to verify
|
|
82
|
+
* the callback URL. We must return `{ plain_token, signature }`.
|
|
83
|
+
*
|
|
84
|
+
* @param params.plainToken - The `plain_token` from the validation request
|
|
85
|
+
* @param params.eventTs - The `event_ts` from the validation request
|
|
86
|
+
* @param params.botSecret - The bot's AppSecret
|
|
87
|
+
*/
|
|
88
|
+
export function signValidationResponse(params) {
|
|
89
|
+
const { plainToken, eventTs, botSecret } = params;
|
|
90
|
+
// Sign: event_ts + plain_token
|
|
91
|
+
const message = Buffer.from(eventTs + plainToken, "utf-8");
|
|
92
|
+
const signature = ed25519Sign(botSecret, message);
|
|
93
|
+
return {
|
|
94
|
+
plain_token: plainToken,
|
|
95
|
+
signature,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=webhook-verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-verify.js","sourceRoot":"","sources":["../../../src/protocol/transport/webhook-verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,4CAA4C;AAE5C;;;GAGG;AACH,SAAS,UAAU,CAAC,SAAiB;IACnC,IAAI,IAAI,GAAG,SAAS,CAAC;IACrB,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CA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