@openclaw/zalo 2026.2.15 → 2026.2.17

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026.2.17
4
+
5
+ ### Changes
6
+
7
+ - Version alignment with core OpenClaw release numbers.
8
+
9
+ ## 2026.2.16
10
+
11
+ ### Changes
12
+
13
+ - Version alignment with core OpenClaw release numbers.
14
+
3
15
  ## 2026.2.15
4
16
 
5
17
  ### Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/zalo",
3
- "version": "2026.2.15",
3
+ "version": "2026.2.17",
4
4
  "description": "OpenClaw Zalo channel plugin",
5
5
  "type": "module",
6
6
  "dependencies": {
package/src/accounts.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { OpenClawConfig } from "openclaw/plugin-sdk";
2
2
  import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
3
- import type { ResolvedZaloAccount, ZaloAccountConfig, ZaloConfig } from "./types.js";
4
3
  import { resolveZaloToken } from "./token.js";
4
+ import type { ResolvedZaloAccount, ZaloAccountConfig, ZaloConfig } from "./types.js";
5
5
 
6
6
  export type { ResolvedZaloAccount };
7
7
 
@@ -1,8 +1,16 @@
1
- import type { OpenClawConfig } from "openclaw/plugin-sdk";
1
+ import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk";
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { zaloPlugin } from "./channel.js";
4
4
 
5
5
  describe("zalo directory", () => {
6
+ const runtimeEnv: RuntimeEnv = {
7
+ log: () => {},
8
+ error: () => {},
9
+ exit: (code: number): never => {
10
+ throw new Error(`exit ${code}`);
11
+ },
12
+ };
13
+
6
14
  it("lists peers from allowFrom", async () => {
7
15
  const cfg = {
8
16
  channels: {
@@ -17,11 +25,12 @@ describe("zalo directory", () => {
17
25
  expect(zaloPlugin.directory?.listGroups).toBeTruthy();
18
26
 
19
27
  await expect(
20
- zaloPlugin.directory!.listPeers({
28
+ zaloPlugin.directory!.listPeers!({
21
29
  cfg,
22
30
  accountId: undefined,
23
31
  query: undefined,
24
32
  limit: undefined,
33
+ runtime: runtimeEnv,
25
34
  }),
26
35
  ).resolves.toEqual(
27
36
  expect.arrayContaining([
@@ -32,11 +41,12 @@ describe("zalo directory", () => {
32
41
  );
33
42
 
34
43
  await expect(
35
- zaloPlugin.directory!.listGroups({
44
+ zaloPlugin.directory!.listGroups!({
36
45
  cfg,
37
46
  accountId: undefined,
38
47
  query: undefined,
39
48
  limit: undefined,
49
+ runtime: runtimeEnv,
40
50
  }),
41
51
  ).resolves.toEqual([]);
42
52
  });
package/src/monitor.ts CHANGED
@@ -2,9 +2,12 @@ import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { OpenClawConfig, MarkdownTableMode } from "openclaw/plugin-sdk";
3
3
  import {
4
4
  createReplyPrefixOptions,
5
- normalizeWebhookPath,
6
5
  readJsonBodyWithLimit,
6
+ registerWebhookTarget,
7
+ rejectNonPostWebhookRequest,
8
+ resolveSenderCommandAuthorization,
7
9
  resolveWebhookPath,
10
+ resolveWebhookTargets,
8
11
  requestBodyErrorToText,
9
12
  } from "openclaw/plugin-sdk";
10
13
  import type { ResolvedZaloAccount } from "./accounts.js";
@@ -83,36 +86,20 @@ type WebhookTarget = {
83
86
  const webhookTargets = new Map<string, WebhookTarget[]>();
84
87
 
85
88
  export function registerZaloWebhookTarget(target: WebhookTarget): () => void {
86
- const key = normalizeWebhookPath(target.path);
87
- const normalizedTarget = { ...target, path: key };
88
- const existing = webhookTargets.get(key) ?? [];
89
- const next = [...existing, normalizedTarget];
90
- webhookTargets.set(key, next);
91
- return () => {
92
- const updated = (webhookTargets.get(key) ?? []).filter((entry) => entry !== normalizedTarget);
93
- if (updated.length > 0) {
94
- webhookTargets.set(key, updated);
95
- } else {
96
- webhookTargets.delete(key);
97
- }
98
- };
89
+ return registerWebhookTarget(webhookTargets, target).unregister;
99
90
  }
100
91
 
101
92
  export async function handleZaloWebhookRequest(
102
93
  req: IncomingMessage,
103
94
  res: ServerResponse,
104
95
  ): Promise<boolean> {
105
- const url = new URL(req.url ?? "/", "http://localhost");
106
- const path = normalizeWebhookPath(url.pathname);
107
- const targets = webhookTargets.get(path);
108
- if (!targets || targets.length === 0) {
96
+ const resolved = resolveWebhookTargets(req, webhookTargets);
97
+ if (!resolved) {
109
98
  return false;
110
99
  }
100
+ const { targets } = resolved;
111
101
 
112
- if (req.method !== "POST") {
113
- res.statusCode = 405;
114
- res.setHeader("Allow", "POST");
115
- res.end("Method Not Allowed");
102
+ if (rejectNonPostWebhookRequest(req, res)) {
116
103
  return true;
117
104
  }
118
105
 
@@ -402,22 +389,20 @@ async function processMessageWithPipeline(params: {
402
389
  const dmPolicy = account.config.dmPolicy ?? "pairing";
403
390
  const configAllowFrom = (account.config.allowFrom ?? []).map((v) => String(v));
404
391
  const rawBody = text?.trim() || (mediaPath ? "<media:image>" : "");
405
- const shouldComputeAuth = core.channel.commands.shouldComputeCommandAuthorized(rawBody, config);
406
- const storeAllowFrom =
407
- !isGroup && (dmPolicy !== "open" || shouldComputeAuth)
408
- ? await core.channel.pairing.readAllowFromStore("zalo").catch(() => [])
409
- : [];
410
- const effectiveAllowFrom = [...configAllowFrom, ...storeAllowFrom];
411
- const useAccessGroups = config.commands?.useAccessGroups !== false;
412
- const senderAllowedForCommands = isSenderAllowed(senderId, effectiveAllowFrom);
413
- const commandAuthorized = shouldComputeAuth
414
- ? core.channel.commands.resolveCommandAuthorizedFromAuthorizers({
415
- useAccessGroups,
416
- authorizers: [
417
- { configured: effectiveAllowFrom.length > 0, allowed: senderAllowedForCommands },
418
- ],
419
- })
420
- : undefined;
392
+ const { senderAllowedForCommands, commandAuthorized } = await resolveSenderCommandAuthorization({
393
+ cfg: config,
394
+ rawBody,
395
+ isGroup,
396
+ dmPolicy,
397
+ configuredAllowFrom: configAllowFrom,
398
+ senderId,
399
+ isSenderAllowed,
400
+ readAllowFromStore: () => core.channel.pairing.readAllowFromStore("zalo"),
401
+ shouldComputeCommandAuthorized: (body, cfg) =>
402
+ core.channel.commands.shouldComputeCommandAuthorized(body, cfg),
403
+ resolveCommandAuthorizedFromAuthorizers: (params) =>
404
+ core.channel.commands.resolveCommandAuthorizedFromAuthorizers(params),
405
+ });
421
406
 
422
407
  if (!isGroup) {
423
408
  if (dmPolicy === "disabled") {
@@ -1,14 +1,11 @@
1
+ import { createServer, type RequestListener } from "node:http";
1
2
  import type { AddressInfo } from "node:net";
2
3
  import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk";
3
- import { createServer } from "node:http";
4
4
  import { describe, expect, it, vi } from "vitest";
5
- import type { ResolvedZaloAccount } from "./types.js";
6
5
  import { handleZaloWebhookRequest, registerZaloWebhookTarget } from "./monitor.js";
6
+ import type { ResolvedZaloAccount } from "./types.js";
7
7
 
8
- async function withServer(
9
- handler: Parameters<typeof createServer>[0],
10
- fn: (baseUrl: string) => Promise<void>,
11
- ) {
8
+ async function withServer(handler: RequestListener, fn: (baseUrl: string) => Promise<void>) {
12
9
  const server = createServer(handler);
13
10
  await new Promise<void>((resolve) => {
14
11
  server.listen(0, "127.0.0.1", () => resolve());
package/src/onboarding.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  import {
8
8
  addWildcardAllowFrom,
9
9
  DEFAULT_ACCOUNT_ID,
10
+ mergeAllowFromEntries,
10
11
  normalizeAccountId,
11
12
  promptAccountId,
12
13
  } from "openclaw/plugin-sdk";
@@ -147,11 +148,7 @@ async function promptZaloAllowFrom(params: {
147
148
  },
148
149
  });
149
150
  const normalized = String(entry).trim();
150
- const merged = [
151
- ...existingAllowFrom.map((item) => String(item).trim()).filter(Boolean),
152
- normalized,
153
- ];
154
- const unique = [...new Set(merged)];
151
+ const unique = mergeAllowFromEntries(existingAllowFrom, [normalized]);
155
152
 
156
153
  if (accountId === DEFAULT_ACCOUNT_ID) {
157
154
  return {
package/src/send.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { OpenClawConfig } from "openclaw/plugin-sdk";
2
- import type { ZaloFetch } from "./api.js";
3
2
  import { resolveZaloAccount } from "./accounts.js";
3
+ import type { ZaloFetch } from "./api.js";
4
4
  import { sendMessage, sendPhoto } from "./api.js";
5
5
  import { resolveZaloProxyFetch } from "./proxy.js";
6
6
  import { resolveZaloToken } from "./token.js";