From 6d5c27c972bb12f6f5a4c3b73a4a8ffc2910a052 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 24 Jun 2023 02:47:57 -0400 Subject: [PATCH] refactor: have login route to pubkey login if it is configured. have loginPubkey return a LoginResponse --- src/client.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 631481f..118673b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -105,6 +105,10 @@ export class Client { } async login(): Promise { + if (!this._options.privateKey) { + return this.loginPubkey(); + } + return this.post("/api/v1/auth/login", { email: this._options.email, password: this._options.password, @@ -131,7 +135,7 @@ export class Client { return json.status as boolean; } - async loginPubkey(): Promise { + async loginPubkey(): Promise { if (!this._options.privateKey) { throw new Error("Private key is required"); } @@ -158,6 +162,8 @@ export class Client { ); this.jwtSessionKey = loginRet.token; + + return { token: loginRet.token }; } logout(request: LogoutRequest): Promise {