feat: load all saved accounts
This commit is contained in:
@ -1,30 +1,14 @@
|
|||||||
import { deriveDeviceKey, getDeviceId } from "@/util/deviceId";
|
import { useAccountRepo } from "@/repository/account";
|
||||||
import { useEffect, useState, type FC } from "react";
|
import { useEffect, type FC } from "react";
|
||||||
|
|
||||||
const IndexPage: FC = () => {
|
const IndexPage: FC = () => {
|
||||||
const [deviceId, setDeviceId] = useState("");
|
const repo = useAccountRepo();
|
||||||
const [deviceKey, setDeviceKey] = useState("");
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDeviceId().then((id) => {
|
repo.loadAll().then((res) => console.log({ res }));
|
||||||
setDeviceId(id);
|
}, [repo]);
|
||||||
deriveDeviceKey(id).then((key) => {
|
|
||||||
crypto.subtle.exportKey("raw", key).then((key) => {
|
|
||||||
const enc = new TextDecoder();
|
|
||||||
setDeviceKey(enc.decode(key));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return <div></div>;
|
||||||
<div>
|
|
||||||
<p>Id:</p>
|
|
||||||
<p>{deviceId}</p>
|
|
||||||
<p>Key:</p>
|
|
||||||
<p>{deviceKey}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default IndexPage;
|
export default IndexPage;
|
||||||
|
Reference in New Issue
Block a user