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

Remove axios 0.23.0 #405

Merged
merged 1 commit into from
Dec 4, 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
41 changes: 0 additions & 41 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"dependencies": {
"asn1-parser": "1.1.8",
"axios": "0.23.0",
"buffer": "6.0.3",
"keccak": "3.0.2",
"qs": "6.10.3",
Expand Down
12 changes: 6 additions & 6 deletions src/background/providers/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Callbacks, Provider } from '.';

import { Storage } from '../storage';
import Token from '../token';
import axios from 'axios';
import qs from 'qs';

const ISSUE_HEADER_NAME = 'cf-chl-bypass';
Expand Down Expand Up @@ -91,7 +90,7 @@ export class CloudflareProvider implements Provider {
}

// Download the commitment
const { data } = await axios.get<Response>(COMMITMENT_URL);
const data: Response = await fetch(COMMITMENT_URL).then((r) => r.json());
const commitment = data.CF[version as string];
if (commitment === undefined) {
throw new Error(`No commitment for the version ${version} is found`);
Expand Down Expand Up @@ -143,12 +142,13 @@ export class CloudflareProvider implements Provider {
[ISSUE_HEADER_NAME]: CloudflareProvider.ID.toString(),
};

const response = await axios.post<string, { data: string }>(url, body, {
const response = await fetch(url, {
method: 'POST',
body,
headers,
responseType: 'text',
});
}).then((r) => r.text());

const { signatures } = qs.parse(response.data);
const { signatures } = qs.parse(response);
if (signatures === undefined) {
throw new Error('There is no signatures parameter in the issuance response.');
}
Expand Down
12 changes: 6 additions & 6 deletions src/background/providers/hcaptcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as voprf from '../voprf';
import { Callbacks, Provider } from '.';
import Token from '../token';
import { Storage } from '../storage';
import axios from 'axios';
import qs from 'qs';

const COMMITMENT_URL =
Expand Down Expand Up @@ -107,7 +106,7 @@ export class HcaptchaProvider implements Provider {
}

// Download the commitment
const { data } = await axios.get<Response>(COMMITMENT_URL);
const data: Response = await fetch(COMMITMENT_URL).then((r) => r.json());
const commitment = data.HC[version as string];
if (commitment === undefined) {
throw new Error(`No commitment for the version ${version} is found`);
Expand Down Expand Up @@ -135,12 +134,13 @@ export class HcaptchaProvider implements Provider {
'cf-chl-bypass': this.getID().toString(),
};

const response = await axios.post<string, { data: string }>(url, requestBody, {
const response = await fetch(url, {
method: 'POST',
body: requestBody,
headers,
responseType: 'text',
});
}).then((r) => r.text());

const { signatures } = qs.parse(response.data);
const { signatures } = qs.parse(response);
if (signatures === undefined) {
throw new Error('There is no signatures parameter in the issuance response.');
}
Expand Down