import { ResourceType } from '../../enums/Resource'; import { IFetchArgs } from '../../types/args/FetchArgs'; import { IPostArgs } from '../../types/args/PostArgs'; import { IAuthCookie } from '../../types/auth/AuthCookie'; import { ITransactionHeader } from '../../types/auth/TransactionHeader'; import { BrowserRettiwtConfig } from '../config/BrowserRettiwtConfig'; import { BrowserAuthCredential, BrowserAuthService } from './BrowserAuthService'; /** * Browser-compatible fetcher service. * Uses native DOMParser instead of JSDOM, and browser cookies instead of base64 encoded API key. * * @public */ export declare class BrowserFetcherService { /** Shared GraphQL query ID resolver (singleton across all instances). */ private static _queryIdResolver; /** The AuthService instance to use. */ protected readonly _auth: BrowserAuthService; /** The delay/delay function to use (ms). */ private readonly _delay?; /** The service used to handle HTTP and API errors */ private readonly _errorHandler; /** The max wait time for a response. */ private readonly _timeout; /** The config object. */ protected readonly config: BrowserRettiwtConfig; /** The authentication cookies. */ private _cookies?; /** * @param config - The browser config object for configuring the Rettiwt instance. */ constructor(config: BrowserRettiwtConfig); /** * Sets the authentication cookies for this service. * * @param cookies - The authentication cookies */ setCookies(cookies: IAuthCookie): void; /** * Checks the authorization status based on the requested resource. * * @param resource - The requested resource. * * @throws An error if not authorized to access the requested resource. */ private _checkAuthorization; /** * Returns the AuthCredentials based on cookies or guest authentication. * * @returns The generated AuthCredential */ protected _getCredential(): Promise; /** * Generates the header for the transaction ID. * Uses native DOMParser instead of JSDOM. * * @param method - The target method. * @param url - The target URL. * * @returns The header containing the transaction ID. */ protected _getTransactionHeader(method: string, url: string): Promise; /** * Handles X.com migration using native DOMParser instead of JSDOM. * * @returns The parsed Document */ protected _handleXMigration(): Promise; /** * Validates the given args against the given resource. * * @param resource - The resource against which validation is to be done. * @param args - The args to be validated. * * @returns The validated args. */ private _validateArgs; /** * Introduces a delay using the configured delay/delay function. */ private _wait; /** * Makes an HTTP request according to the given parameters. * * @param resource - The requested resource. * @param config - The request configuration. * * @typeParam T - The type of the returned response data. * * @returns The raw data response received. */ request(resource: ResourceType, args: IFetchArgs | IPostArgs): Promise; }