UNPKG

@sudowealth/schwab-api

Version:

TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety

41 lines (40 loc) 1.45 kB
/** * Centralized token validation utilities */ import { type TokenData } from './types'; /** * Token validation result with detailed information */ export interface TokenValidationResult { valid: boolean; reason?: string; canRefresh?: boolean; isExpiring?: boolean; expiresInSeconds?: number; format?: { isValid: boolean; issues?: string[]; }; } /** * Validate TokenData (partial token information) * This handles cases where refresh token or expiration might be optional */ export declare function validateTokenData(tokenData: TokenData): boolean; /** * Perform detailed validation with comprehensive reporting * @param tokenData The token data to validate * @param refreshThresholdMs Time before expiration to consider token as expiring (default: 5 minutes) * @returns Detailed validation result */ export declare function validateTokenDetailed(tokenData: TokenData, refreshThresholdMs?: number): TokenValidationResult; /** * Check if a token is expired or expiring soon * @param expiresAt The expiration timestamp * @param thresholdMs Time before expiration to consider token as expiring */ export declare function isTokenExpiring(expiresAt?: number, thresholdMs?: number): boolean; /** * Ensure TokenData has all required fields with defaults */ export declare function ensureCompleteTokenData(tokenData: Partial<TokenData>, defaultExpiresInSeconds?: number): Required<TokenData>;