惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
D
Docker
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
L
LangChain Blog
A
About on SuperTechFans
M
MIT News - Artificial intelligence
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(e2e): harden Telegram credential paths on Windows · o...
vincentkoc · 2026-05-24 · via Recent Commits to openclaw:main

@@ -2,8 +2,12 @@

2233

import { spawn } from "node:child_process";

44

import { createHash } from "node:crypto";

5-

import { chmod, copyFile, mkdir, readFile, rm, unlink, writeFile } from "node:fs/promises";

5+

import { copyFile, mkdir, mkdtemp, readFile, rm, unlink, writeFile } from "node:fs/promises";

6+

import { tmpdir } from "node:os";

7+

import path from "node:path";

8+

import { pathToFileURL } from "node:url";

69

import { normalizeCredentialPayloadForKind } from "../../qa/convex-credential-broker/convex/payload-validation.js";

10+

import { expandHome, writePrivateJson } from "./telegram-user-credential-paths.ts";

711812

type JsonObject = Record<string, unknown>;

913

@@ -38,16 +42,6 @@ function printUsage() {

3842

);

3943

}

404441-

function expandHome(path: string) {

42-

if (path === "~") {

43-

return process.env.HOME || path;

44-

}

45-

if (path.startsWith("~/")) {

46-

return `${process.env.HOME || "~"}${path.slice(1)}`;

47-

}

48-

return path;

49-

}

50-5145

function parseArgs(argv: string[]) {

5246

const args = argv.slice(2);

5347

const command = args[0] || usage();

@@ -168,17 +162,6 @@ async function tgzBase64(path: string) {

168162

return (await readFile(path)).toString("base64");

169163

}

170164171-

async function writePrivateJson(path: string, payload: JsonObject) {

172-

const expanded = expandHome(path);

173-

await mkdir(expanded.slice(0, expanded.lastIndexOf("/")), { recursive: true });

174-

await writeFile(expanded, `${JSON.stringify(payload, null, 2)}\n`, { mode: 0o600 });

175-

await chmodPrivate(expanded);

176-

}

177-178-

async function chmodPrivate(path: string) {

179-

await chmod(path, 0o600);

180-

}

181-182165

function runCommand(command: string, args: string[], cwd?: string) {

183166

return new Promise<void>((resolve, reject) => {

184167

const child = spawn(command, args, {

@@ -384,20 +367,17 @@ async function createTelegramUserPayload(opts: Map<string, string>) {

384367

throw new Error("Missing group id in env, user-driver config, or bot credentials file.");

385368

}

386369387-

const tempRoot = `/tmp/openclaw-telegram-user-credential-${Date.now()}-${Math.random()

388-

.toString(16)

389-

.slice(2)}`;

390-

const tdlibArchive = `${tempRoot}/tdlib.tgz`;

391-

const desktopArchive = `${tempRoot}/desktop-tdata.tgz`;

392-

await mkdir(tempRoot, { recursive: true });

370+

const tempRoot = await mkdtemp(path.join(tmpdir(), "openclaw-telegram-user-credential-"));

371+

const tdlibArchive = path.join(tempRoot, "tdlib.tgz");

372+

const desktopArchive = path.join(tempRoot, "desktop-tdata.tgz");

393373

try {

394374

await runCommand("tar", ["-C", userDriverDir, "-czf", tdlibArchive, "db", "files"]);

395375

if (desktopTdataArchiveInput) {

396376

await copyFile(expandHome(desktopTdataArchiveInput), desktopArchive);

397377

} else {

398378

await runCommand("tar", [

399379

"-C",

400-

`${expandHome(desktopTdataDir!)}/..`,

380+

path.dirname(expandHome(desktopTdataDir!)),

401381

"--exclude",

402382

"tdata/countries",

403383

"--exclude",

@@ -458,12 +438,9 @@ async function restoreTelegramUserPayload(params: {

458438

usage();

459439

}

460440

const payload = parseTelegramUserQaCredentialPayload(params.payload);

461-

const tempRoot = `/tmp/openclaw-telegram-user-restore-${Date.now()}-${Math.random()

462-

.toString(16)

463-

.slice(2)}`;

464-

const tdlibArchive = `${tempRoot}/tdlib.tgz`;

465-

const desktopArchive = `${tempRoot}/desktop-tdata.tgz`;

466-

await mkdir(tempRoot, { recursive: true });

441+

const tempRoot = await mkdtemp(path.join(tmpdir(), "openclaw-telegram-user-restore-"));

442+

const tdlibArchive = path.join(tempRoot, "tdlib.tgz");

443+

const desktopArchive = path.join(tempRoot, "desktop-tdata.tgz");

467444

await mkdir(expandHome(userDriverDir), { recursive: true });

468445

await mkdir(expandHome(desktopWorkdir), { recursive: true });

469446

try {

@@ -610,15 +587,21 @@ async function releaseTelegramUserLease(opts: Map<string, string>) {

610587

);

611588

}

612589613-

const { command, opts } = parseArgs(process.argv);

614-

if (command === "export") {

615-

await createTelegramUserPayload(opts);

616-

} else if (command === "restore") {

617-

await restoreTelegramUserPayloadFromFile(opts);

618-

} else if (command === "lease-restore") {

619-

await leaseAndRestoreTelegramUser(opts);

620-

} else if (command === "release") {

621-

await releaseTelegramUserLease(opts);

622-

} else {

623-

usage();

590+

async function main(argv = process.argv) {

591+

const { command, opts } = parseArgs(argv);

592+

if (command === "export") {

593+

await createTelegramUserPayload(opts);

594+

} else if (command === "restore") {

595+

await restoreTelegramUserPayloadFromFile(opts);

596+

} else if (command === "lease-restore") {

597+

await leaseAndRestoreTelegramUser(opts);

598+

} else if (command === "release") {

599+

await releaseTelegramUserLease(opts);

600+

} else {

601+

usage();

602+

}

603+

}

604+605+

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {

606+

await main();

624607

}