diff --git a/index.d.ts b/index.d.ts index 1c61870..9bbe074 100644 --- a/index.d.ts +++ b/index.d.ts @@ -28,6 +28,9 @@ declare namespace WAWebJS { /** Closes the client */ destroy(): Promise + /** Logs out the client, closing the current session */ + logout(): Promise + /** Get chat instance by ID */ getChatById(chatId: string): Promise diff --git a/src/Client.js b/src/Client.js index 26a93dc..c240a30 100644 --- a/src/Client.js +++ b/src/Client.js @@ -359,6 +359,15 @@ class Client extends EventEmitter { await this.pupBrowser.close(); } + /** + * Logs out the client, closing the current session + */ + async logout() { + return await this.pupPage.evaluate(() => { + return window.Store.AppState.logout(); + }); + } + /** * Returns the version of WhatsApp Web currently being run * @returns Promise