From 88b10d44ab071d7d41e9755cf3ddb2bd53f487a6 Mon Sep 17 00:00:00 2001 From: JKamsker <11245306+JKamsker@users.noreply.github.com> Date: Sun, 18 Sep 2022 23:27:29 +0200 Subject: [PATCH] Finalized recaptcha --- .env | 1 + .env.development | 1 + .env.production | 1 + package.json | 2 +- src/ChecksumResolver.js | 22 ++++++++++++---------- src/index.js | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 .env create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env b/.env new file mode 100644 index 0000000..c1370ea --- /dev/null +++ b/.env @@ -0,0 +1 @@ +REACT_APP_APISERVER=https://api.audible-converter.ml \ No newline at end of file diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..981d973 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +REACT_APP_APISERVER=http://localhost:7172 diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..c1370ea --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +REACT_APP_APISERVER=https://api.audible-converter.ml \ No newline at end of file diff --git a/package.json b/package.json index 39172fd..3c478df 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build", - "start": "react-scripts start", + "start": "react-scripts --openssl-legacy-provider start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" diff --git a/src/ChecksumResolver.js b/src/ChecksumResolver.js index 41c076b..6302133 100644 --- a/src/ChecksumResolver.js +++ b/src/ChecksumResolver.js @@ -135,20 +135,22 @@ class ChecksumResolver extends React.Component { requestActivationBytes = async () => { const { checksum } = this.state - const { executeRecaptcha } = (this.props) - .googleReCaptchaProps; - + const { executeRecaptcha } = this.props.googleReCaptchaProps + if (!executeRecaptcha) { - console.log('Recaptcha has not been loaded'); - - return; + console.log('Recaptcha has not been loaded') + + return } - - const token = await executeRecaptcha('homepage'); - console.log(`XToken: ${token}`); + + const token = await executeRecaptcha('homepage') + console.log(`XToken: ${token}`) try { let request = await fetch( - 'https://api.audible-converter.ml/api/v2/activation/' + checksum, + `${process.env.REACT_APP_APISERVER}/api/v2/activation/${checksum}`, + { + headers: new Headers({'x-captcha-result': token}) + }, ) let result = await request.json() const { success, activationBytes } = result diff --git a/src/index.js b/src/index.js index a8b3892..bab53d2 100644 --- a/src/index.js +++ b/src/index.js @@ -12,7 +12,7 @@ import { GoogleReCaptcha, } from 'react-google-recaptcha-v3' -fetch('https://api.audible-converter.ml/api/v2/WakeUpNeo').then((data) => +fetch(`${process.env.REACT_APP_APISERVER}/api/v2/WakeUpNeo`).then((data) => console.log('Woke up, im ready to serve :D'), )