/** * OAuth 1.0 client for Yahoo Fantasy Sports API public requests * * Implements 2-legged OAuth 1.0 with HMAC-SHA1 signing for accessing * public endpoints without user authorization. * * @module */ /** * OAuth 1.0 signature method */ export type OAuth1SignatureMethod = 'HMAC-SHA1' | 'PLAINTEXT'; /** * OAuth 1.0 parameters for request signing */ export interface OAuth1Params { oauth_consumer_key: string; oauth_nonce: string; oauth_signature_method: string; oauth_timestamp: number; oauth_version: string; oauth_signature?: string; } /** * OAuth 1.0 client for 2-legged authentication (public mode) * * This client implements OAuth 1.0 request signing for accessing Yahoo's * public Fantasy Sports API endpoints without requiring user authorization. * * According to Yahoo's documentation, public requests use 2-legged OAuth, * which means signing requests with your consumer key/secret but without * an access token. * * @example * ```typescript * const oauth1 = new OAuth1Client( * 'your-consumer-key', * 'your-consumer-secret' * ); * * // Sign a request * const signedUrl = oauth1.signRequest( * 'GET', * 'https://fantasysports.yahooapis.com/fantasy/v2/game/nfl' * ); * * // Make the request * const response = await fetch(signedUrl); * ``` */ export declare class OAuth1Client { private consumerKey; private consumerSecret; /** * Creates a new OAuth 1.0 client for public API access * * @param consumerKey - OAuth consumer key (Client ID) from Yahoo Developer * @param consumerSecret - OAuth consumer secret (Client Secret) from Yahoo Developer * @throws {ConfigError} If consumer key or secret is missing */ constructor(consumerKey: string, consumerSecret: string); /** * Signs a request URL using OAuth 1.0 HMAC-SHA1 signature * * This implements 2-legged OAuth (no user token) for public endpoints. * The signed URL can be used directly with fetch() or other HTTP clients. * * @param method - HTTP method (GET, POST, PUT, DELETE) * @param url - Full URL to sign (without query parameters if using params object) * @param params - Optional additional parameters to include in signature * @param signatureMethod - Signature method (default: HMAC-SHA1) * @returns Signed URL with OAuth parameters appended * * @example * ```typescript * const signedUrl = oauth1.signRequest( * 'GET', * 'https://fantasysports.yahooapis.com/fantasy/v2/game/nfl' * ); * ``` */ signRequest(method: string, url: string, params?: Record, signatureMethod?: OAuth1SignatureMethod): string; /** * Generates OAuth signature for request * * @param method - HTTP method * @param baseUrl - Base URL without query parameters * @param params - All parameters to include in signature * @param signatureMethod - Signature method * @returns OAuth signature */ private generateSignature; /** * Generates a random nonce for OAuth request * * @returns Random nonce string */ private generateNonce; /** * Generates HMAC-SHA1 signature * * Uses the Web Crypto API (available in Node.js 15+ and browsers) * * @param data - Data to sign * @param key - Signing key * @returns Base64-encoded signature */ private hmacSha1; /** * Gets the OAuth parameters for debugging * * @returns Object containing consumer key and signature method */ getDebugInfo(): { consumerKey: string; signatureMethod: string; }; } //# sourceMappingURL=OAuth1Client.d.ts.map