Skip to content

Commit

Permalink
feat: logout client
Browse files Browse the repository at this point in the history
close #255
  • Loading branch information
pedroslopez committed Jun 18, 2020
1 parent b0baeaa commit 300b367
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ declare namespace WAWebJS {
/** Closes the client */
destroy(): Promise<void>

/** Logs out the client, closing the current session */
logout(): Promise<void>

/** Get chat instance by ID */
getChatById(chatId: string): Promise<Chat>

Expand Down
9 changes: 9 additions & 0 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>
Expand Down

0 comments on commit 300b367

Please sign in to comment.