@sudowealth/schwab-api
Version:
TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety
55 lines (54 loc) • 1.81 kB
TypeScript
import { EnhancedTokenManager } from './enhanced-token-manager.js';
import { type AuthClientOptions, type FullAuthClient } from './types.js';
/**
* Authentication strategy for the auth factory
* Only the Enhanced strategy is supported in this version
*/
export declare enum AuthStrategy {
/**
* Enhanced OAuth 2.0 code flow authentication
* - Built-in token persistence and refresh capabilities
* - Includes retry logic, automatic reconnection, and token validation
* - Comprehensive error handling and debugging tools
* - Reliable token management for serverless environments
*/
ENHANCED = "enhanced"
}
/**
* Configuration options for creating an authentication client
*/
export interface AuthFactoryConfig {
/**
* Authentication strategy to use (only ENHANCED is supported)
* @default AuthStrategy.ENHANCED
*/
strategy?: AuthStrategy | string;
/**
* OAuth client options (required)
*/
oauthConfig: AuthClientOptions;
}
export type { FullAuthClient };
/**
* Creates an authentication client using the EnhancedTokenManager
*
* @example
* ```typescript
* const auth = createSchwabAuth({
* oauthConfig: {
* clientId: 'your-client-id',
* clientSecret: 'your-client-secret',
* redirectUri: 'your-redirect-uri',
* // Optional storage callbacks
* save: async (tokens) => localStorage.setItem('tokens', JSON.stringify(tokens)),
* load: async () => JSON.parse(localStorage.getItem('tokens') || 'null')
* }
* });
*
* // Get authorization URL
* const { authUrl } = auth.getAuthorizationUrl();
* // Exchange code for tokens
* const tokens = await auth.exchangeCode('authorization-code');
* ```
*/
export declare function createSchwabAuth(config: AuthFactoryConfig): EnhancedTokenManager;