Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain project #3

Merged
merged 17 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const bypass2 = new API({ headless: true, skip_chromium_download: false });
```javascript
import API from "./buil/API"
const bypass = new API();
// The second parameter is just the default axios config. Use it as if you're using axios
// The second parameter is just the default fetch config.
await bypass.request("https://myprotectedsite.com", { method: "PUT",
headers: {
Referer: "https://myprotectedsite.com",
Expand Down
19 changes: 10 additions & 9 deletions built/API.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AxiosRequestConfig, AxiosResponse } from "axios";
export default class API {
export declare class API {
private requests;
private cookies;
private options;
Expand All @@ -24,10 +23,14 @@ export default class API {
/**
* @description First checks if there are any valid cookies for the URL requested. If not, it will request the URL and get the cookies using Puppeteer. If there are valid cookies, it will use those cookies to make the request.
* @param url Request URL
* @param options Axios config. Be careful of of using a custom User-Agent/Cookie header, as it will be overwritten.
* @returns Promise<AxiosResponse>
* @param options RequestInit config. Be careful of of using a custom User-Agent/Cookie header, as it will be overwritten.
* @returns Promise<string>
*/
request(url: string, options?: AxiosRequestConfig): Promise<AxiosResponse>;
request(url: string, options?: RequestInit): Promise<{
content: string;
statusCode: number;
headers: Headers;
}>;
/**
* @description Checks if there is a request object for the URL
* @param url URL to check for
Expand All @@ -48,7 +51,7 @@ export default class API {
/**
* @description Gets the headers for the URL requested to bypass CloudFlare
* @param url URL to fetch
* @returns Promise<{ "User-Agent": string, "Cookie": string }>
* @returns Promise<{ 'User-Agent': string, 'Cookie': string }>
*/
private getHeaders;
/**
Expand All @@ -57,12 +60,10 @@ export default class API {
* @returns Cookie
*/
private toToughCookie;
private wait;
}
interface Options {
export interface Options {
headless?: boolean;
skip_chromium_download?: boolean;
chromium_path?: string;
wait_for_network_idle?: boolean;
}
export {};
152 changes: 74 additions & 78 deletions built/API.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading