feat(web): add logout command and tests

This commit is contained in:
Peter Steinberger
2025-11-26 01:29:02 +01:00
parent 1fd4485716
commit a2586b8b06
8 changed files with 99 additions and 14 deletions

View File

@@ -133,6 +133,21 @@ export async function webAuthExists() {
.catch(() => false);
}
export async function logoutWeb(runtime: RuntimeEnv = defaultRuntime) {
const exists = await webAuthExists();
if (!exists) {
runtime.log(info("No WhatsApp Web session found; nothing to delete."));
return false;
}
await fs.rm(WA_WEB_AUTH_DIR, { recursive: true, force: true });
runtime.log(
success(
"Cleared WhatsApp Web credentials. Run `warelay login --provider web` to relink.",
),
);
return true;
}
function readWebSelfId() {
// Read the cached WhatsApp Web identity (jid + E.164) from disk if present.
const credsPath = path.join(WA_WEB_AUTH_DIR, "creds.json");