import ReactDOM from 'react-dom'; import * as React from "react"; import {TextField} from "@mui/material"; import {EncryptStorage} from "storage-encryption"; import {useState} from "react"; let encryptStorage = new EncryptStorage('test'); // TODO la clef doit venir de l'utilisateur const app = document.getElementById('first'); const word = "shikiryu"; let csrf, url = ""; if (app) { url = "" + app.getAttribute('data-url'); csrf = "" + app.getAttribute('data-csrf'); ReactDOM.render(, app); } export default function FirstPage() { const [passphrase, setPassphrase] = useState(""); const onSubmit = async (event: React.FormEvent) => { event.preventDefault(); sessionStorage.setItem("key", passphrase); encryptStorage = new EncryptStorage(passphrase); encryptStorage.encrypt("checkword", word); let encryptedFormData = new FormData(); encryptedFormData.append("checkword", ""+localStorage.getItem("key")); encryptedFormData.append('_token', csrf); let response = await fetch(url, { method: 'POST', body: encryptedFormData }); const json = await response.json(); // TODO redirect if success }; const updatePassphrase = (e: React.ChangeEvent) => { setPassphrase(e.target.value); }; return (
); }