diff --git a/package-lock.json b/package-lock.json index 8b1082e..7ff37b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "BSD-3-Clause", "dependencies": { "asn1-parser": "1.1.8", - "axios": "0.23.0", "buffer": "6.0.3", "keccak": "3.0.2", "qs": "6.10.3", @@ -2144,14 +2143,6 @@ "node": ">=8" } }, - "node_modules/axios": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.23.0.tgz", - "integrity": "sha512-NmvAE4i0YAv5cKq8zlDoPd1VLKAqX5oLuZKs8xkJa4qi6RGn0uhCYFjWtHHC9EM/MwOwYWOs53W+V0aqEXq1sg==", - "dependencies": { - "follow-redirects": "^1.14.4" - } - }, "node_modules/babel-jest": { "version": "28.1.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-28.1.0.tgz", @@ -3482,25 +3473,6 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", "dev": true }, - "node_modules/follow-redirects": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", - "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -9038,14 +9010,6 @@ "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, - "axios": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.23.0.tgz", - "integrity": "sha512-NmvAE4i0YAv5cKq8zlDoPd1VLKAqX5oLuZKs8xkJa4qi6RGn0uhCYFjWtHHC9EM/MwOwYWOs53W+V0aqEXq1sg==", - "requires": { - "follow-redirects": "^1.14.4" - } - }, "babel-jest": { "version": "28.1.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-28.1.0.tgz", @@ -10011,11 +9975,6 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", "dev": true }, - "follow-redirects": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", - "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==" - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", diff --git a/package.json b/package.json index 5244349..4776993 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/background/providers/cloudflare.ts b/src/background/providers/cloudflare.ts index bc972ff..ff9e298 100644 --- a/src/background/providers/cloudflare.ts +++ b/src/background/providers/cloudflare.ts @@ -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'; @@ -91,7 +90,7 @@ export class CloudflareProvider implements Provider { } // Download the commitment - const { data } = await axios.get(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`); @@ -143,12 +142,13 @@ export class CloudflareProvider implements Provider { [ISSUE_HEADER_NAME]: CloudflareProvider.ID.toString(), }; - const response = await axios.post(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.'); } diff --git a/src/background/providers/hcaptcha.ts b/src/background/providers/hcaptcha.ts index 2660e0e..334f6ad 100644 --- a/src/background/providers/hcaptcha.ts +++ b/src/background/providers/hcaptcha.ts @@ -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 = @@ -107,7 +106,7 @@ export class HcaptchaProvider implements Provider { } // Download the commitment - const { data } = await axios.get(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`); @@ -135,12 +134,13 @@ export class HcaptchaProvider implements Provider { 'cf-chl-bypass': this.getID().toString(), }; - const response = await axios.post(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.'); }