tradestation-api-ts
Version:
A comprehensive TypeScript wrapper for TradeStation WebAPI v3
35 lines (34 loc) • 1.25 kB
TypeScript
import { ClientConfig } from '../types/config';
export declare class TokenManager {
private accessToken;
private refreshToken;
private tokenExpiry;
private refreshing;
private readonly axiosInstance;
private readonly config;
private static readonly REFRESH_THRESHOLD;
constructor(config?: Partial<ClientConfig>);
private shouldRefreshToken;
/**
* Gets a valid access token, refreshing it if necessary.
* This is the main method that should be used to get an access token.
* @returns A promise that resolves to a valid access token
* @throws Error if unable to get a valid token
*/
getValidAccessToken(): Promise<string>;
/**
* Refreshes the access token using the refresh token.
* If the response includes a new refresh token, it will be stored for future use.
* @throws Error if refresh fails or no refresh token is available
*/
refreshAccessToken(): Promise<void>;
private updateTokens;
/**
* Returns the current refresh token
* @returns The current refresh token or null if none is available
*/
getRefreshToken(): string | null;
private getAccessToken;
isTokenExpired(): boolean;
hasValidToken(): boolean;
}