@yash101/schwab-api-client
Version:
A TypeScript client library for interacting with the Charles Schwab Brokerage APIs.
50 lines • 2.07 kB
TypeScript
import { AppConfig } from "./appconfig";
import { IDToken } from "./idtoken";
/**
* Represents a set of authentication tokens, including access and refresh tokens,
* along with their expiration times. Provides methods to retrieve, set, and check
* the expiration status of these tokens.
*/
export declare class AuthTokens {
protected accessToken: string;
protected refreshToken: string;
protected scope: string;
protected idToken?: IDToken;
protected atExpiresAt?: Date;
protected rtExpiresAt?: Date;
getAccessToken(): string;
getRefreshToken(): string;
getAccessTokenExpiresAt(): Date;
getRefreshTokenExpiresAt(): Date;
getUserId(): IDToken | undefined;
getScope(): string;
isAccessTokenExpired(): boolean;
isRefreshTokenExpired(): boolean;
setAccessToken(token: string): void;
setRefreshToken(token: string): void;
setAccessTokenExpiresAt(expiresAt: Date): void;
setRefreshTokenExpiresAt(expiresAt: Date): void;
setIdToken(token: IDToken): void;
setScope(scope: string): void;
getAuthHeader(): string;
}
/**
* Represents a set of authentication tokens with automatic refresh capabilities.
* Inherits from AuthTokens and adds functionality to refresh the access token
* using the refresh token at regular intervals.
*/
export declare class AutoRefreshAuthTokens extends AuthTokens {
protected refreshInterval?: NodeJS.Timeout;
protected appConfig: AppConfig;
protected refreshIntervalTimer: number;
protected onRefreshTokenChanged: (orig: AutoRefreshAuthTokens) => any;
constructor(appConfig: AppConfig, refreshToken: string, accessToken?: string, refreshInterval?: number);
private doRefreshAccessToken;
start(): this;
stop(): this;
refreshImmediately(): this;
setRefreshInterval(interval: number): this;
setOnRefreshTokenChanged(callback: (orig: AutoRefreshAuthTokens) => any): this;
static fromAuthCode(code: string, appConfig: AppConfig, apiUri?: string): Promise<AutoRefreshAuthTokens>;
}
//# sourceMappingURL=tokens.d.ts.map