@openclaw/zalo 2026.2.14 → 2026.2.15
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 +6 -0
- package/package.json +1 -1
- package/src/monitor.ts +3 -29
- package/src/probe.ts +2 -3
- package/src/token.ts +2 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/monitor.ts
CHANGED
|
@@ -2,7 +2,9 @@ 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,
|
|
5
6
|
readJsonBodyWithLimit,
|
|
7
|
+
resolveWebhookPath,
|
|
6
8
|
requestBodyErrorToText,
|
|
7
9
|
} from "openclaw/plugin-sdk";
|
|
8
10
|
import type { ResolvedZaloAccount } from "./accounts.js";
|
|
@@ -80,34 +82,6 @@ type WebhookTarget = {
|
|
|
80
82
|
|
|
81
83
|
const webhookTargets = new Map<string, WebhookTarget[]>();
|
|
82
84
|
|
|
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
85
|
export function registerZaloWebhookTarget(target: WebhookTarget): () => void {
|
|
112
86
|
const key = normalizeWebhookPath(target.path);
|
|
113
87
|
const normalizedTarget = { ...target, path: key };
|
|
@@ -700,7 +674,7 @@ export async function monitorZaloProvider(options: ZaloMonitorOptions): Promise<
|
|
|
700
674
|
throw new Error("Zalo webhook secret must be 8-256 characters");
|
|
701
675
|
}
|
|
702
676
|
|
|
703
|
-
const path = resolveWebhookPath(webhookPath, webhookUrl);
|
|
677
|
+
const path = resolveWebhookPath({ webhookPath, webhookUrl, defaultPath: null });
|
|
704
678
|
if (!path) {
|
|
705
679
|
throw new Error("Zalo webhookPath could not be derived");
|
|
706
680
|
}
|
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/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
|
|