sdk/src/components/lume/LumeIdentity/LumeIdentityContext.ts

24 lines
603 B
TypeScript
Raw Normal View History

2023-10-10 10:40:39 +00:00
import { useState } from "react";
2023-10-09 16:25:38 +00:00
import {
login,
2023-10-10 10:40:39 +00:00
// loginComplete,
// logoutComplete,
2023-10-09 16:25:38 +00:00
} from "@lumeweb/libkernel/kernel";
export function useLumeIndentity() {
2023-10-09 16:25:38 +00:00
const [loggedIn, setLoggedIn] = useState(false);
return {
2023-10-09 16:25:38 +00:00
isSignedIn: loggedIn,
async signIn(key: Uint8Array) {
await login(key);
2023-10-10 10:40:39 +00:00
// await loginComplete(); # this function is buggy `auth.ts:42 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'promise') `
setLoggedIn(true);
},
async signOut() {
// await logoutComplete();
setLoggedIn(false);
},
};
2023-10-09 12:55:16 +00:00
}