• Exchange an OAuth authorization code for an access token with AniList. Centralized helper to avoid duplicated token exchange logic and provide consistent error handling.

    IMPORTANT: This helper assumes a runtime with a global fetch and AbortController (e.g., Electron main process running a recent Node/Electron runtime). If your environment does not provide these globals, you can pass in explicit implementations via the optional deps parameter.

    Parameters

    • params: TokenExchangeParams

      Token exchange parameters

    • Optionaldeps: {
          fetch?: {
              (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
              (input: string | Request | URL, init?: RequestInit): Promise<Response>;
          };
          AbortController?: new () => AbortController;
      }

      Optional dependency injection for fetch and AbortController implementations.

      • Optionalfetch?: {
            (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
            (input: string | Request | URL, init?: RequestInit): Promise<Response>;
        }
      • OptionalAbortController?: new () => AbortController

    Returns Promise<TokenExchangeResponse>