@openclaw/zalo 2026.2.12 → 2026.2.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026.2.13
4
+
5
+ ### Changes
6
+
7
+ - Version alignment with core OpenClaw release numbers.
8
+
3
9
  ## 2026.2.6-3
4
10
 
5
11
  ### Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/zalo",
3
- "version": "2026.2.12",
3
+ "version": "2026.2.13",
4
4
  "description": "OpenClaw Zalo channel plugin",
5
5
  "type": "module",
6
6
  "dependencies": {
package/src/monitor.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { OpenClawConfig, MarkdownTableMode } from "openclaw/plugin-sdk";
3
- import { createReplyPrefixOptions } from "openclaw/plugin-sdk";
3
+ import {
4
+ createReplyPrefixOptions,
5
+ readJsonBodyWithLimit,
6
+ requestBodyErrorToText,
7
+ } from "openclaw/plugin-sdk";
4
8
  import type { ResolvedZaloAccount } from "./accounts.js";
5
9
  import {
6
10
  ZaloApiError,
@@ -61,37 +65,6 @@ function isSenderAllowed(senderId: string, allowFrom: string[]): boolean {
61
65
  });
62
66
  }
63
67
 
64
- async function readJsonBody(req: IncomingMessage, maxBytes: number) {
65
- const chunks: Buffer[] = [];
66
- let total = 0;
67
- return await new Promise<{ ok: boolean; value?: unknown; error?: string }>((resolve) => {
68
- req.on("data", (chunk: Buffer) => {
69
- total += chunk.length;
70
- if (total > maxBytes) {
71
- resolve({ ok: false, error: "payload too large" });
72
- req.destroy();
73
- return;
74
- }
75
- chunks.push(chunk);
76
- });
77
- req.on("end", () => {
78
- try {
79
- const raw = Buffer.concat(chunks).toString("utf8");
80
- if (!raw.trim()) {
81
- resolve({ ok: false, error: "empty payload" });
82
- return;
83
- }
84
- resolve({ ok: true, value: JSON.parse(raw) as unknown });
85
- } catch (err) {
86
- resolve({ ok: false, error: err instanceof Error ? err.message : String(err) });
87
- }
88
- });
89
- req.on("error", (err) => {
90
- resolve({ ok: false, error: err instanceof Error ? err.message : String(err) });
91
- });
92
- });
93
- }
94
-
95
68
  type WebhookTarget = {
96
69
  token: string;
97
70
  account: ResolvedZaloAccount;
@@ -177,10 +150,19 @@ export async function handleZaloWebhookRequest(
177
150
  return true;
178
151
  }
179
152
 
180
- const body = await readJsonBody(req, 1024 * 1024);
153
+ const body = await readJsonBodyWithLimit(req, {
154
+ maxBytes: 1024 * 1024,
155
+ timeoutMs: 30_000,
156
+ emptyObjectOnEmpty: false,
157
+ });
181
158
  if (!body.ok) {
182
- res.statusCode = body.error === "payload too large" ? 413 : 400;
183
- res.end(body.error ?? "invalid payload");
159
+ res.statusCode =
160
+ body.code === "PAYLOAD_TOO_LARGE" ? 413 : body.code === "REQUEST_BODY_TIMEOUT" ? 408 : 400;
161
+ res.end(
162
+ body.code === "REQUEST_BODY_TIMEOUT"
163
+ ? requestBodyErrorToText("REQUEST_BODY_TIMEOUT")
164
+ : body.error,
165
+ );
184
166
  return true;
185
167
  }
186
168