mirror of
https://github.com/DeBrosOfficial/network-ts-sdk.git
synced 2025-12-11 01:58:49 +00:00
Compare commits
3 Commits
5c564b6327
...
a97fb21200
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a97fb21200 | ||
|
|
0e95ad49c5 | ||
|
|
fa357668cb |
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -82,6 +82,10 @@ export class HttpClient {
|
||||
return this.jwt || this.apiKey;
|
||||
}
|
||||
|
||||
getApiKey(): string | undefined {
|
||||
return this.apiKey;
|
||||
}
|
||||
|
||||
async request<T = any>(
|
||||
method: "GET" | "POST" | "PUT" | "DELETE",
|
||||
path: string,
|
||||
|
||||
@ -82,8 +82,6 @@ export class PubSubClient {
|
||||
dataBase64 = base64EncodeBytes(data);
|
||||
}
|
||||
|
||||
console.log("[PubSubClient] Publishing to topic:", topic);
|
||||
|
||||
await this.httpClient.post(
|
||||
"/v1/pubsub/publish",
|
||||
{
|
||||
@ -119,18 +117,19 @@ export class PubSubClient {
|
||||
} = {}
|
||||
): Promise<Subscription> {
|
||||
// Build WebSocket URL for this topic
|
||||
const wsUrl = new URL(this.wsConfig.wsURL || "ws://localhost:6001");
|
||||
const wsUrl = new URL(this.wsConfig.wsURL || "ws://127.0.0.1:6001");
|
||||
wsUrl.pathname = "/v1/pubsub/ws";
|
||||
wsUrl.searchParams.set("topic", topic);
|
||||
|
||||
const authToken = this.httpClient.getApiKey() ?? this.httpClient.getToken();
|
||||
|
||||
// Create WebSocket client
|
||||
const wsClient = new WSClient({
|
||||
...this.wsConfig,
|
||||
wsURL: wsUrl.toString(),
|
||||
authToken: this.httpClient.getToken(),
|
||||
authToken,
|
||||
});
|
||||
|
||||
console.log("[PubSubClient] Connecting to topic:", topic);
|
||||
await wsClient.connect();
|
||||
|
||||
// Create subscription wrapper
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user