mirror of
https://github.com/DeBrosOfficial/network-ts-sdk.git
synced 2025-12-12 18:28:50 +00:00
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:
parent
0e95ad49c5
commit
a97fb21200
@ -170,9 +170,12 @@ export class AuthClient {
|
|||||||
chain_type?: "ETH" | "SOL";
|
chain_type?: "ETH" | "SOL";
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
access_token: string;
|
access_token: string;
|
||||||
refresh_token: string;
|
refresh_token?: string;
|
||||||
subject: string;
|
subject: string;
|
||||||
namespace: string;
|
namespace: string;
|
||||||
|
api_key?: string;
|
||||||
|
expires_in?: number;
|
||||||
|
token_type?: string;
|
||||||
}> {
|
}> {
|
||||||
const response = await this.httpClient.post("/v1/auth/verify", {
|
const response = await this.httpClient.post("/v1/auth/verify", {
|
||||||
wallet: params.wallet,
|
wallet: params.wallet,
|
||||||
@ -182,10 +185,20 @@ export class AuthClient {
|
|||||||
chain_type: params.chain_type || "ETH",
|
chain_type: params.chain_type || "ETH",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Automatically set the JWT
|
// Persist JWT
|
||||||
this.setJwt(response.access_token);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -82,8 +82,6 @@ export class PubSubClient {
|
|||||||
dataBase64 = base64EncodeBytes(data);
|
dataBase64 = base64EncodeBytes(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("[PubSubClient] Publishing to topic:", topic);
|
|
||||||
|
|
||||||
await this.httpClient.post(
|
await this.httpClient.post(
|
||||||
"/v1/pubsub/publish",
|
"/v1/pubsub/publish",
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user