From 8e9b8fa71a5cd3c375c578b6feedfba4c705a46e Mon Sep 17 00:00:00 2001 From: Jacob Schlecht Date: Sat, 23 May 2026 13:17:45 -0600 Subject: [PATCH] feat: Add a logout function for disposal of the client (#163) * feat: Add a logout function for disposal of the client Signed-off-by: Jacob Schlecht * fix: typo Signed-off-by: Jacob Schlecht --------- Signed-off-by: Jacob Schlecht --- src/Client.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Client.ts b/src/Client.ts index 3119525c..6782c702 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -395,6 +395,18 @@ export class Client extends AsyncEventEmitter { this.connect(); } + /** + * Log out of current session + * + * This function prepares the client for disposal by removing all event listeners and killing the events socket. + */ + async logout(): Promise { + await this.api.post("/auth/session/logout"); + this.events.removeAllListeners(); + this.removeAllListeners(); + this.events.disconnect(); + } + /** * Prepare a markdown-based message to be displayed to the user as plain text. * @param source Source markdown text