@openclaw/zalo 2026.2.14 → 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,23 @@
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
+
15
+ ## 2026.2.15
16
+
17
+ ### Changes
18
+
19
+ - Version alignment with core OpenClaw release numbers.
20
+
3
21
  ## 2026.2.14
4
22
 
5
23
  ### Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/zalo",
3
- "version": "2026.2.14",
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
@@ -3,6 +3,11 @@ import type { OpenClawConfig, MarkdownTableMode } from "openclaw/plugin-sdk";
3
3
  import {
4
4
  createReplyPrefixOptions,
5
5
  readJsonBodyWithLimit,
6
+ registerWebhookTarget,
7
+ rejectNonPostWebhookRequest,
8
+ resolveSenderCommandAuthorization,
9
+ resolveWebhookPath,
10
+ resolveWebhookTargets,
6
11
  requestBodyErrorToText,
7
12
  } from "openclaw/plugin-sdk";
8
13
  import type { ResolvedZaloAccount } from "./accounts.js";
@@ -80,65 +85,21 @@ type WebhookTarget = {
80
85
 
81
86
  const webhookTargets = new Map<string, WebhookTarget[]>();
82
87
 
83
- function normalizeWebhookPath(raw: string): string {
84
- const trimmed = raw.trim();
85
- if (!trimmed) {
86
- return "/";
87
- }
88
- const withSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
89
- if (withSlash.length > 1 && withSlash.endsWith("/")) {
90
- return withSlash.slice(0, -1);
91
- }
92
- return withSlash;
93
- }
94
-
95
- function resolveWebhookPath(webhookPath?: string, webhookUrl?: string): string | null {
96
- const trimmedPath = webhookPath?.trim();
97
- if (trimmedPath) {
98
- return normalizeWebhookPath(trimmedPath);
99
- }
100
- if (webhookUrl?.trim()) {
101
- try {
102
- const parsed = new URL(webhookUrl);
103
- return normalizeWebhookPath(parsed.pathname || "/");
104
- } catch {
105
- return null;
106
- }
107
- }
108
- return null;
109
- }
110
-
111
88
  export function registerZaloWebhookTarget(target: WebhookTarget): () => void {
112
- const key = normalizeWebhookPath(target.path);
113
- const normalizedTarget = { ...target, path: key };
114
- const existing = webhookTargets.get(key) ?? [];
115
- const next = [...existing, normalizedTarget];
116
- webhookTargets.set(key, next);
117
- return () => {
118
- const updated = (webhookTargets.get(key) ?? []).filter((entry) => entry !== normalizedTarget);
119
- if (updated.length > 0) {
120
- webhookTargets.set(key, updated);
121
- } else {
122
- webhookTargets.delete(key);
123
- }
124
- };
89
+ return registerWebhookTarget(webhookTargets, target).unregister;
125
90
  }
126
91
 
127
92
  export async function handleZaloWebhookRequest(
128
93
  req: IncomingMessage,
129
94
  res: ServerResponse,
130
95
  ): Promise<boolean> {
131
- const url = new URL(req.url ?? "/", "http://localhost");
132
- const path = normalizeWebhookPath(url.pathname);
133
- const targets = webhookTargets.get(path);
134
- if (!targets || targets.length === 0) {
96
+ const resolved = resolveWebhookTargets(req, webhookTargets);
97
+ if (!resolved) {
135
98
  return false;
136
99
  }
100
+ const { targets } = resolved;
137
101
 
138
- if (req.method !== "POST") {
139
- res.statusCode = 405;
140
- res.setHeader("Allow", "POST");
141
- res.end("Method Not Allowed");
102
+ if (rejectNonPostWebhookRequest(req, res)) {
142
103
  return true;
143
104
  }
144
105
 
@@ -428,22 +389,20 @@ async function processMessageWithPipeline(params: {
428
389
  const dmPolicy = account.config.dmPolicy ?? "pairing";
429
390
  const configAllowFrom = (account.config.allowFrom ?? []).map((v) => String(v));
430
391
  const rawBody = text?.trim() || (mediaPath ? "<media:image>" : "");
431
- const shouldComputeAuth = core.channel.commands.shouldComputeCommandAuthorized(rawBody, config);
432
- const storeAllowFrom =
433
- !isGroup && (dmPolicy !== "open" || shouldComputeAuth)
434
- ? await core.channel.pairing.readAllowFromStore("zalo").catch(() => [])
435
- : [];
436
- const effectiveAllowFrom = [...configAllowFrom, ...storeAllowFrom];
437
- const useAccessGroups = config.commands?.useAccessGroups !== false;
438
- const senderAllowedForCommands = isSenderAllowed(senderId, effectiveAllowFrom);
439
- const commandAuthorized = shouldComputeAuth
440
- ? core.channel.commands.resolveCommandAuthorizedFromAuthorizers({
441
- useAccessGroups,
442
- authorizers: [
443
- { configured: effectiveAllowFrom.length > 0, allowed: senderAllowedForCommands },
444
- ],
445
- })
446
- : 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
+ });
447
406
 
448
407
  if (!isGroup) {
449
408
  if (dmPolicy === "disabled") {
@@ -700,7 +659,7 @@ export async function monitorZaloProvider(options: ZaloMonitorOptions): Promise<
700
659
  throw new Error("Zalo webhook secret must be 8-256 characters");
701
660
  }
702
661
 
703
- const path = resolveWebhookPath(webhookPath, webhookUrl);
662
+ const path = resolveWebhookPath({ webhookPath, webhookUrl, defaultPath: null });
704
663
  if (!path) {
705
664
  throw new Error("Zalo webhookPath could not be derived");
706
665
  }
@@ -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/probe.ts CHANGED
@@ -1,9 +1,8 @@
1
+ import type { BaseProbeResult } from "openclaw/plugin-sdk";
1
2
  import { getMe, ZaloApiError, type ZaloBotInfo, type ZaloFetch } from "./api.js";
2
3
 
3
- export type ZaloProbeResult = {
4
- ok: boolean;
4
+ export type ZaloProbeResult = BaseProbeResult<string> & {
5
5
  bot?: ZaloBotInfo;
6
- error?: string;
7
6
  elapsedMs: number;
8
7
  };
9
8
 
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";
package/src/token.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { readFileSync } from "node:fs";
2
- import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk";
2
+ import { type BaseTokenResolution, DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk";
3
3
  import type { ZaloConfig } from "./types.js";
4
4
 
5
- export type ZaloTokenResolution = {
6
- token: string;
5
+ export type ZaloTokenResolution = BaseTokenResolution & {
7
6
  source: "env" | "config" | "configFile" | "none";
8
7
  };
9
8