mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:24:30 +00:00
refactor(zalouser): reuse shared QR temp file writer
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
import fsp from "node:fs/promises";
|
|
||||||
import path from "node:path";
|
|
||||||
import type {
|
import type {
|
||||||
ChannelOnboardingAdapter,
|
ChannelOnboardingAdapter,
|
||||||
ChannelOnboardingDmPolicy,
|
ChannelOnboardingDmPolicy,
|
||||||
@@ -14,7 +12,6 @@ import {
|
|||||||
normalizeAccountId,
|
normalizeAccountId,
|
||||||
promptAccountId,
|
promptAccountId,
|
||||||
promptChannelAccessConfig,
|
promptChannelAccessConfig,
|
||||||
resolvePreferredOpenClawTmpDir,
|
|
||||||
} from "openclaw/plugin-sdk/zalouser";
|
} from "openclaw/plugin-sdk/zalouser";
|
||||||
import {
|
import {
|
||||||
listZalouserAccountIds,
|
listZalouserAccountIds,
|
||||||
@@ -22,6 +19,7 @@ import {
|
|||||||
resolveZalouserAccountSync,
|
resolveZalouserAccountSync,
|
||||||
checkZcaAuthenticated,
|
checkZcaAuthenticated,
|
||||||
} from "./accounts.js";
|
} from "./accounts.js";
|
||||||
|
import { writeQrDataUrlToTempFile } from "./qr-temp-file.js";
|
||||||
import {
|
import {
|
||||||
logoutZaloProfile,
|
logoutZaloProfile,
|
||||||
resolveZaloAllowFromEntries,
|
resolveZaloAllowFromEntries,
|
||||||
@@ -103,25 +101,6 @@ async function noteZalouserHelp(prompter: WizardPrompter): Promise<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeQrDataUrlToTempFile(
|
|
||||||
qrDataUrl: string,
|
|
||||||
profile: string,
|
|
||||||
): Promise<string | null> {
|
|
||||||
const trimmed = qrDataUrl.trim();
|
|
||||||
const match = trimmed.match(/^data:image\/png;base64,(.+)$/i);
|
|
||||||
const base64 = (match?.[1] ?? "").trim();
|
|
||||||
if (!base64) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const safeProfile = profile.replace(/[^a-zA-Z0-9_-]+/g, "-") || "default";
|
|
||||||
const filePath = path.join(
|
|
||||||
resolvePreferredOpenClawTmpDir(),
|
|
||||||
`openclaw-zalouser-qr-${safeProfile}.png`,
|
|
||||||
);
|
|
||||||
await fsp.writeFile(filePath, Buffer.from(base64, "base64"));
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function promptZalouserAllowFrom(params: {
|
async function promptZalouserAllowFrom(params: {
|
||||||
cfg: OpenClawConfig;
|
cfg: OpenClawConfig;
|
||||||
prompter: WizardPrompter;
|
prompter: WizardPrompter;
|
||||||
|
|||||||
Reference in New Issue
Block a user