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

chore: update readme #2

Merged
merged 6 commits into from
Sep 16, 2024
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
9 changes: 0 additions & 9 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ on:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.11.0
- run: yarn install --frozen-lockfile
- run: yarn test
neat:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"printWidth": 200,
"tabWidth": 4,
"trailingComma": "none"
"trailingComma": "none",
"singleQuote": false
}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
# node-curl-impersonate

Fork of [curl-impersonate-node](https://github.com/wearrrrr/curl-impersonate-node) that adds windows support.

## Install

```sh
# yarn
yarn add node-curl-impersonate

# npm
npm i node-curl-impersonate
```

## Usage

```ts
// normal request
const response = await new RequestBuilder().url(/** YOUR URL HERE **/).header("x-foo-bar", "baz").send();

// make a post request
const response = await new RequestBuilder().url(/** YOUR URL HERE **/).method("POST").body({ foo: "bar" }).send();

// use a browser preset (options vary by platform)
const response = await new RequestBuilder().url(/** YOUR URL HERE **/).preset({ name: "chrome", version: "110" }).send();
```
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.r
rules: {
semi: "error",
curly: "error",
quotes: ["error", "double"]
quotes: ["error", "double", { allowTemplateLiterals: true }]
}
});
6 changes: 3 additions & 3 deletions src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type ChromePresetVersion = "107" | "110" | "116";
export const ChromePresets: Record<ChromePresetVersion, Preset> = {
"107": {
headers: {
"sec-ch-ua": '\\"Google Chrome\\";v=\\"107\\", \\"Chromium\\";v=\\"107\\", \\"Not=A?Brand\\";v=\\"24\\"',
"sec-ch-ua": `\\"Google Chrome\\";v=\\"107\\", \\"Chromium\\";v=\\"107\\", \\"Not=A?Brand\\";v=\\"24\\"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "Windows",
"Upgrade-Insecure-Requests": "1",
Expand All @@ -40,7 +40,7 @@ export const ChromePresets: Record<ChromePresetVersion, Preset> = {
},
"110": {
headers: {
"sec-ch-ua": '\\"Chromium\\";v="110\\", \\"Not A(Brand\\";v=\\"24\\", \\"Google Chrome\\";v=\\"110\\"',
"sec-ch-ua": `\\"Chromium\\";v="110\\", \\"Not A(Brand\\";v=\\"24\\", \\"Google Chrome\\";v=\\"110\\"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "Windows",
"Upgrade-Insecure-Requests": "1",
Expand All @@ -66,7 +66,7 @@ export const ChromePresets: Record<ChromePresetVersion, Preset> = {
},
"116": {
headers: {
"sec-ch-ua": '\\"Chromium\\";v=\\"116\\", \\"Not A;Brand\\";v=\\"99\\", \\"Google Chrome\\";v=\\"116\\"',
"sec-ch-ua": `\\"Chromium\\";v=\\"116\\", \\"Not A;Brand\\";v=\\"99\\", \\"Google Chrome\\";v=\\"116\\"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "Windows",
"Upgrade-Insecure-Requests": "1",
Expand Down
2 changes: 1 addition & 1 deletion src/request_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export class RequestBuilder {
const headers = this.buildHeaderFlags({ ...this._headers, ...preset.headers });
const flags = this.buildFlags(this._flags);

const command = [path.join(BINARY_PATH, browser.binary), ...flags, ...preset.flags, ...headers, "-s", '-w "\\n%{json}"', `-X ${this._method}`, `"${this._url}"`].join(" ");
const command = [path.join(BINARY_PATH, browser.binary), ...flags, ...preset.flags, ...headers, "-s", `-w "\\n%{json}"`, `-X ${this._method}`, `"${this._url}"`].join(" ");

return new Promise((resolve, reject) => {
exec(command, { cwd: BINARY_PATH }, (err, stdout, stderr) => {
Expand Down
766 changes: 383 additions & 383 deletions yarn.lock

Large diffs are not rendered by default.

Loading