cookie-pusher
Version:
Cookie-aware HTTP client based on axios and tough-cookie
29 lines (28 loc) • 1.12 kB
TypeScript
import { AxiosError } from "./exceptions";
import defaultHttpHeaders from "./default-http-headers.config";
import type { Headers } from "./utilities";
import type { AxiosRequestConfig, AxiosResponse } from "axios";
import toughCookie from "tough-cookie";
import neverThrow from "neverthrow";
export type { AxiosRequestConfig, AxiosResponse, } from "axios";
export declare const Cookie: typeof toughCookie.Cookie;
export declare type ClientConfig = AxiosRequestConfig & {
url: string;
};
export declare class Client {
defaultHeaders: Headers;
lastUrls: URL[];
setReferer?: (config: ClientConfig, client: Client) => URL;
cookies: toughCookie.CookieJar;
constructor({ userAgent, acceptLanguage, }?: {
userAgent?: string;
acceptLanguage?: string;
});
readonly setLanguage: (language: keyof typeof defaultHttpHeaders.languageToAcceptLanguageStringMap) => void;
readonly access: (config: ClientConfig) => neverThrow.ResultAsync<AxiosResponse, AxiosError>;
}
declare const _default: {
Cookie: typeof toughCookie.Cookie;
Client: typeof Client;
};
export default _default;