Actually make the login attempt to the well-known JMAP endpoint

This commit is contained in:
Eli Ribble 2024-08-27 10:48:49 -07:00
parent c6400d58d3
commit faca28f802
3 changed files with 28 additions and 11 deletions

13
package-lock.json generated
View File

@ -16,6 +16,7 @@
"@types/node": "^16.18.104",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"base-64": "^1.0.0",
"bootstrap": "^5.3.3",
"react": "^18.3.1",
"react-bootstrap": "^2.10.4",
@ -25,6 +26,7 @@
"web-vitals": "^2.1.4"
},
"devDependencies": {
"@types/base-64": "^1.0.2",
"prettier": "3.3.3"
}
},
@ -4051,6 +4053,12 @@
"@babel/types": "^7.20.7"
}
},
"node_modules/@types/base-64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/base-64/-/base-64-1.0.2.tgz",
"integrity": "sha512-uPgKMmM9fmn7I+Zi6YBqctOye4SlJsHKcisjHIMWpb2YKZRc36GpKyNuQ03JcT+oNXg1m7Uv4wU94EVltn8/cw==",
"dev": true
},
"node_modules/@types/body-parser": {
"version": "1.19.5",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
@ -5540,6 +5548,11 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"node_modules/base-64": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz",
"integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
},
"node_modules/batch": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz",

View File

@ -11,6 +11,7 @@
"@types/node": "^16.18.104",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"base-64": "^1.0.0",
"bootstrap": "^5.3.3",
"react": "^18.3.1",
"react-bootstrap": "^2.10.4",
@ -44,6 +45,7 @@
]
},
"devDependencies": {
"@types/base-64": "^1.0.2",
"prettier": "3.3.3"
}
}

View File

@ -1,5 +1,6 @@
import "./App.css";
import "bootstrap/dist/css/bootstrap.min.css";
import * as base64 from "base-64";
//import MailboxList from "./Mailbox";
import AuthModal from "./AuthModal";
@ -13,17 +14,18 @@ interface IAuth {
const App = () => {
const [state, setInternalState] = useState<IAuth | null>(null);
const fetchUserData = () => {
fetch("https://jsonplaceholder.typicode.com/users")
.then((response) => {
return response.json();
})
.then((data) => {
//setUsers(data)
});
};
const doLogin = (username: string, password: string) => {
alert("I be authin '" + username)
const doLogin = (email: string, password: string) => {
const domain = email.split("@")[1];
const well_known_url = "https://" + domain + "/.well-known/jmap"
let headers = new Headers();
headers.append("Authorization", "Basic " + base64.encode(email + ":" + password));
fetch(well_known_url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
};
const loadAuth = () => {
const auth = localStorage.getItem("auth");