From a97fb21200a8eff7dab344d66777742b95369f87 Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Wed, 29 Oct 2025 07:02:46 +0200 Subject: [PATCH] Enhance AuthClient to support optional refresh tokens and API keys in the authentication response; update token persistence logic for improved session management. Remove debug logging from PubSubClient to reduce console output. --- src/auth/client.ts | 19 ++++++++++++++++--- src/pubsub/client.ts | 2 -- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/auth/client.ts b/src/auth/client.ts index 0b7348b..49f55d3 100644 --- a/src/auth/client.ts +++ b/src/auth/client.ts @@ -170,9 +170,12 @@ export class AuthClient { chain_type?: "ETH" | "SOL"; }): Promise<{ access_token: string; - refresh_token: string; + refresh_token?: string; subject: string; namespace: string; + api_key?: string; + expires_in?: number; + token_type?: string; }> { const response = await this.httpClient.post("/v1/auth/verify", { wallet: params.wallet, @@ -182,10 +185,20 @@ export class AuthClient { chain_type: params.chain_type || "ETH", }); - // Automatically set the JWT + // Persist JWT this.setJwt(response.access_token); - return response; + // Persist API key if server provided it (created in verifyHandler) + if ((response as any).api_key) { + this.setApiKey((response as any).api_key); + } + + // Persist refresh token if present (optional, for silent renewal) + if ((response as any).refresh_token) { + await this.storage.set("refreshToken", (response as any).refresh_token); + } + + return response as any; } /** diff --git a/src/pubsub/client.ts b/src/pubsub/client.ts index 7cffd82..f059313 100644 --- a/src/pubsub/client.ts +++ b/src/pubsub/client.ts @@ -82,8 +82,6 @@ export class PubSubClient { dataBase64 = base64EncodeBytes(data); } - console.log("[PubSubClient] Publishing to topic:", topic); - await this.httpClient.post( "/v1/pubsub/publish", {