mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 14:28:35 +00:00
33 lines
718 B
TypeScript
33 lines
718 B
TypeScript
interface Login1 {
|
|
serverPublicKey: string;
|
|
salt: string;
|
|
}
|
|
|
|
/**
|
|
* This is the first step of the login process (pake)
|
|
* @param {*} email
|
|
* @param {*} clientPublicKey
|
|
* @returns
|
|
*/
|
|
const login1 = async (email: string, clientPublicKey: string) => {
|
|
const response = await fetch("/api/v1/auth/login1", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
email: email,
|
|
clientPublicKey,
|
|
}),
|
|
});
|
|
// need precise error handling about the status code
|
|
if (response?.status === 200) {
|
|
const data = (await response.json()) as unknown as Login1;
|
|
return data;
|
|
}
|
|
|
|
throw new Error("Wrong password");
|
|
};
|
|
|
|
export default login1;
|