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.

This commit is contained in:
anonpenguin23 2025-10-29 07:02:46 +02:00
parent 0e95ad49c5
commit a97fb21200
2 changed files with 16 additions and 5 deletions

View File

@ -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;
}
/**

View File

@ -82,8 +82,6 @@ export class PubSubClient {
dataBase64 = base64EncodeBytes(data);
}
console.log("[PubSubClient] Publishing to topic:", topic);
await this.httpClient.post(
"/v1/pubsub/publish",
{