UNPKG

splitwise

Version:

A TypeScript SDK for the Splitwise API.

35 lines 1.6 kB
/** * Shared internals for the OAuth token endpoint: * - POSTing form-encoded credentials * - Parsing the response into an OAuthToken * - Translating HTTP/network failures into SDK error types * * Both client-credentials and authorization-code flows hit the same endpoint * with the same response shape, so they share this code path. */ import type { OAuthToken } from './types.js'; export declare const DEFAULT_TOKEN_URL = "https://secure.splitwise.com/oauth/token"; export declare const DEFAULT_AUTHORIZE_URL = "https://secure.splitwise.com/oauth/authorize"; export interface PostTokenRequestOptions { fetch?: typeof fetch; tokenUrl?: string; /** Per-request timeout in ms. Default 30000. */ timeout?: number; /** Max retries for transient failures (network errors, 5xx). Default 2. */ maxRetries?: number; /** Optional caller-supplied AbortSignal. */ signal?: AbortSignal; } /** * POSTs `params` form-encoded to the token endpoint and returns the parsed token. * * 401/400 responses are mapped to SplitwiseAuthenticationError because the OAuth * spec uses 400 for things like `invalid_grant` even though the SDK normally * reserves 400 for validation errors. * * Honors timeout, AbortSignal, and exponential-backoff retry on transient * failures (matching the main HttpClient's behavior). 4xx responses are not * retried since they indicate the credentials themselves are bad. */ export declare function postTokenRequest(params: Record<string, string>, options?: PostTokenRequestOptions): Promise<OAuthToken>; //# sourceMappingURL=internal.d.ts.map