Files
bot/extensions/zalouser/src/probe.ts
zooqueen adb8e1f802 feat: merge upstream improvements via rebrand bridge
Squash merge of 1,462 upstream commits with openclaw→hanzo-bot
naming transforms applied. Conflicts resolved favoring our main
branch to preserve existing customizations.

Key upstream additions:
- iOS Security Stack (concurrency locks, runtime guards, TTS fallback)
- Discord CDN hostname allowlisting for SSRF protection
- Discord mention handling improvements
- Various bug fixes and stability improvements
2026-03-03 09:38:30 -08:00

35 lines
872 B
TypeScript

import type { BaseProbeResult } from "bot/plugin-sdk";
import type { ZcaUserInfo } from "./types.js";
import { getZaloUserInfo } from "./zalo-js.js";
export type ZalouserProbeResult = BaseProbeResult<string> & {
user?: ZcaUserInfo;
};
export async function probeZalouser(
profile: string,
timeoutMs?: number,
): Promise<ZalouserProbeResult> {
try {
const user = timeoutMs
? await Promise.race([
getZaloUserInfo(profile),
new Promise<null>((resolve) =>
setTimeout(() => resolve(null), Math.max(timeoutMs, 1000)),
),
])
: await getZaloUserInfo(profile);
if (!user) {
return { ok: false, error: "Not authenticated" };
}
return { ok: true, user };
} catch (error) {
return {
ok: false,
error: error instanceof Error ? error.message : String(error),
};
}
}