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.27 kB
import { type EnhancedTokenManager } from '../auth/enhanced-token-manager'; import { type Middleware } from './compose'; /** * Options for token authentication middleware */ export interface TokenAuthOptions { /** * The token manager to use for authentication */ tokenManager: EnhancedTokenManager; /** * Advanced token authentication options */ advanced?: { /** * Whether to refresh tokens that will expire soon * @default true */ refreshExpiring?: boolean; /** * Time in milliseconds before token expiration to trigger a refresh * @default 300_000 (5 minutes) */ refreshThresholdMs?: number; }; } /** * Default token authentication options */ export declare const DEFAULT_TOKEN_AUTH_OPTIONS: Omit<TokenAuthOptions, 'tokenManager'>; /** * Create a middleware that adds authentication headers to requests * and handles token refresh when needed. * * This middleware is designed to work with the unified ITokenLifecycleManager interface. * * @param options The token manager or options object * @returns A middleware function */ export declare function withTokenAuth(options: EnhancedTokenManager | TokenAuthOptions): Middleware;