From 73c2360acd5f4f53f16908cec7ea285ef697522e Mon Sep 17 00:00:00 2001 From: JKamsker Date: Mon, 19 Sep 2022 23:55:06 +0200 Subject: [PATCH] Added path for autoresolve --- package-lock.json | 96 ++++++++++++++++++++++++++++++----------- package.json | 2 + src/ChecksumResolver.js | 37 ++++++++++++---- 3 files changed, 103 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4efd64c..c3abde1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,8 @@ "react-ga": "^3.3.0", "react-google-recaptcha-v3": "^1.10.0", "react-notifications-component": "^3.1.0", + "react-router": "^6.4.0", + "react-router-dom": "^6.4.0", "react-scripts": "^4.0.3", "reactstrap": "^8.9.0", "typescript": "^4.2.3" @@ -3006,6 +3008,14 @@ "node": ">= 8" } }, + "node_modules/@remix-run/router": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.0.0.tgz", + "integrity": "sha512-SCR1cxRSMNKjaVYptCzBApPDqGwa3FGdjVHc+rOToocNPHQdIYLZBfv/3f+KvYuXDkUGVIW9IAzmPNZDRL1I4A==", + "engines": { + "node": ">=14" + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", @@ -18742,6 +18752,35 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.4.0.tgz", + "integrity": "sha512-B+5bEXFlgR1XUdHYR6P94g299SjrfCBMmEDJNcFbpAyRH1j1748yt9NdDhW3++nw1lk3zQJ6aOO66zUx3KlTZg==", + "dependencies": { + "@remix-run/router": "1.0.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.4.0.tgz", + "integrity": "sha512-4Aw1xmXKeleYYQ3x0Lcl2undHR6yMjXZjd9DKZd53SGOYqirrUThyUb0wwAX5VZAyvSuzjNJmZlJ3rR9+/vzqg==", + "dependencies": { + "react-router": "6.4.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/react-scripts": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-4.0.3.tgz", @@ -26305,8 +26344,7 @@ "@material-ui/types": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@material-ui/types/-/types-5.1.0.tgz", - "integrity": "sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==", - "requires": {} + "integrity": "sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==" }, "@material-ui/utils": { "version": "4.11.2", @@ -26377,6 +26415,11 @@ } } }, + "@remix-run/router": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.0.0.tgz", + "integrity": "sha512-SCR1cxRSMNKjaVYptCzBApPDqGwa3FGdjVHc+rOToocNPHQdIYLZBfv/3f+KvYuXDkUGVIW9IAzmPNZDRL1I4A==" + }, "@rollup/plugin-node-resolve": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", @@ -26673,8 +26716,7 @@ "@testing-library/user-event": { "version": "7.2.1", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-7.2.1.tgz", - "integrity": "sha512-oZ0Ib5I4Z2pUEcoo95cT1cr6slco9WY7yiPpG+RGNkj8YcYgJnM7pXmYmorNOReh8MIGcKSqXyeGjxnr8YiZbA==", - "requires": {} + "integrity": "sha512-oZ0Ib5I4Z2pUEcoo95cT1cr6slco9WY7yiPpG+RGNkj8YcYgJnM7pXmYmorNOReh8MIGcKSqXyeGjxnr8YiZbA==" }, "@types/anymatch": { "version": "1.3.1", @@ -27327,8 +27369,7 @@ "acorn-jsx": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", - "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", - "requires": {} + "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==" }, "acorn-walk": { "version": "7.2.0", @@ -27372,14 +27413,12 @@ "ajv-errors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", - "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", - "requires": {} + "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==" }, "ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "requires": {} + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==" }, "alphanum-sort": { "version": "1.0.2", @@ -27889,8 +27928,7 @@ "babel-plugin-named-asset-import": { "version": "0.3.7", "resolved": "https://registry.npmjs.org/babel-plugin-named-asset-import/-/babel-plugin-named-asset-import-0.3.7.tgz", - "integrity": "sha512-squySRkf+6JGnvjoUtDEjSREJEBirnXi9NqP6rjSYsylxQxqBTz+pkmf395i9E2zsvmYUaI40BHo6SqZUdydlw==", - "requires": {} + "integrity": "sha512-squySRkf+6JGnvjoUtDEjSREJEBirnXi9NqP6rjSYsylxQxqBTz+pkmf395i9E2zsvmYUaI40BHo6SqZUdydlw==" }, "babel-plugin-polyfill-corejs2": { "version": "0.1.10", @@ -30681,8 +30719,7 @@ "eslint-plugin-react-hooks": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz", - "integrity": "sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ==", - "requires": {} + "integrity": "sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ==" }, "eslint-plugin-testing-library": { "version": "3.10.2", @@ -31532,8 +31569,7 @@ "fork-me-on-github": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fork-me-on-github/-/fork-me-on-github-1.0.6.tgz", - "integrity": "sha512-5R9pXa2JvyBsewGPn8woZGNz5oOb9vi8j1mjMzleHSwBojj/D8O33OEeItIe9/wtRtD4bSU0Egs6Qzp5FU/adA==", - "requires": {} + "integrity": "sha512-5R9pXa2JvyBsewGPn8woZGNz5oOb9vi8j1mjMzleHSwBojj/D8O33OEeItIe9/wtRtD4bSU0Egs6Qzp5FU/adA==" }, "fork-ts-checker-webpack-plugin": { "version": "4.1.6", @@ -34500,8 +34536,7 @@ "jest-pnp-resolver": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz", - "integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==", - "requires": {} + "integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==" }, "jest-regex-util": { "version": "26.0.0", @@ -38658,8 +38693,7 @@ "react-ga": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.3.0.tgz", - "integrity": "sha512-o8RScHj6Lb8cwy3GMrVH6NJvL+y0zpJvKtc0+wmH7Bt23rszJmnqEQxRbyrqUzk9DTJIHoP42bfO5rswC9SWBQ==", - "requires": {} + "integrity": "sha512-o8RScHj6Lb8cwy3GMrVH6NJvL+y0zpJvKtc0+wmH7Bt23rszJmnqEQxRbyrqUzk9DTJIHoP42bfO5rswC9SWBQ==" }, "react-google-recaptcha-v3": { "version": "1.10.0", @@ -38682,8 +38716,7 @@ "react-notifications-component": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/react-notifications-component/-/react-notifications-component-3.1.0.tgz", - "integrity": "sha512-qq+zgqVIa2zhlw+RvO2QSPk7xHLvZWTHl9VKRO56sMUef/UrcUTqOswL0DSJtRIpZYZhclquQUfDxD6H2w8aWA==", - "requires": {} + "integrity": "sha512-qq+zgqVIa2zhlw+RvO2QSPk7xHLvZWTHl9VKRO56sMUef/UrcUTqOswL0DSJtRIpZYZhclquQUfDxD6H2w8aWA==" }, "react-popper": { "version": "1.3.11", @@ -38711,6 +38744,22 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", "integrity": "sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==" }, + "react-router": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.4.0.tgz", + "integrity": "sha512-B+5bEXFlgR1XUdHYR6P94g299SjrfCBMmEDJNcFbpAyRH1j1748yt9NdDhW3++nw1lk3zQJ6aOO66zUx3KlTZg==", + "requires": { + "@remix-run/router": "1.0.0" + } + }, + "react-router-dom": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.4.0.tgz", + "integrity": "sha512-4Aw1xmXKeleYYQ3x0Lcl2undHR6yMjXZjd9DKZd53SGOYqirrUThyUb0wwAX5VZAyvSuzjNJmZlJ3rR9+/vzqg==", + "requires": { + "react-router": "6.4.0" + } + }, "react-scripts": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-4.0.3.tgz", @@ -42903,8 +42952,7 @@ "ws": { "version": "7.5.7", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", - "requires": {} + "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==" }, "xml-name-validator": { "version": "3.0.0", diff --git a/package.json b/package.json index 3c478df..8d67eaf 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "react-ga": "^3.3.0", "react-google-recaptcha-v3": "^1.10.0", "react-notifications-component": "^3.1.0", + "react-router": "^6.4.0", + "react-router-dom": "^6.4.0", "react-scripts": "^4.0.3", "reactstrap": "^8.9.0", "typescript": "^4.2.3" diff --git a/src/ChecksumResolver.js b/src/ChecksumResolver.js index fecf4d3..8c685ca 100644 --- a/src/ChecksumResolver.js +++ b/src/ChecksumResolver.js @@ -34,6 +34,7 @@ import { withGoogleReCaptcha, } from 'react-google-recaptcha-v3' + const useStyles = (theme) => ({ paper: { marginTop: theme.spacing(8), @@ -68,10 +69,24 @@ class ChecksumResolver extends React.Component { this.state = { checksum: '', fileName: 'input.aax', - activationBytes: '' + activationBytes: '', } } + componentDidMount() { + let path = window.location.pathname; + let checksumMatch = window.location.pathname.match(/([a-fA-F0-9]{40})/) + if(!checksumMatch) return; + let checksum = checksumMatch[1]; + // this.setState({}); + this.setChecksum(checksum); + this.requestActivationBytes(checksum); + // let { id } = this.props.params + // // this.fetchData(id) + // console.log(id) + // debugger; + } + DarkerDisabledTextField = withStyles({ root: { marginRight: 8, @@ -133,15 +148,17 @@ class ChecksumResolver extends React.Component { }) } - requestActivationBytes = async () => { - const { checksum } = this.state + requestActivationBytes = async (checksumX) => { + const checksum = checksumX ? checksumX : this.state.checksum - const { executeRecaptcha } = this.props.googleReCaptchaProps + window.history.pushState('page2', 'Title', '/' + checksum); + + let executeRecaptcha = this.props.googleReCaptchaProps.executeRecaptcha - if (!executeRecaptcha) { + while(!executeRecaptcha) { console.log('Recaptcha has not been loaded') - - return + executeRecaptcha = this.props.googleReCaptchaProps?.executeRecaptcha + await new Promise(r => setTimeout(r, 100)); } const token = await executeRecaptcha('homepage') @@ -150,7 +167,7 @@ class ChecksumResolver extends React.Component { let request = await fetch( `${process.env.REACT_APP_APISERVER}/api/v2/activation/${checksum}`, { - headers: new Headers({'x-captcha-result': token}) + headers: new Headers({ 'x-captcha-result': token }), }, ) let result = await request.json() @@ -218,6 +235,9 @@ class ChecksumResolver extends React.Component { render() { const { classes } = this.props const { checksum, activationBytes, fileName, file } = this.state + // const id = this.props.match.params.id; + // let { id } = useParams(); + // console.log("IDDDDDD"+ id); return ( @@ -326,3 +346,4 @@ class ChecksumResolver extends React.Component { } export default withGoogleReCaptcha(withStyles(useStyles)(ChecksumResolver)) +