feat: database context

This commit is contained in:
2025-05-24 11:19:16 +02:00
parent b8f3fa0a32
commit eaf3596580
8 changed files with 165 additions and 28 deletions

View File

@ -0,0 +1,30 @@
import { deriveDeviceKey, getDeviceId } from "@/util/deviceId";
import { useEffect, useState, type FC } from "react";
const IndexPage: FC = () => {
const [deviceId, setDeviceId] = useState("");
const [deviceKey, setDeviceKey] = useState("");
useEffect(() => {
getDeviceId().then((id) => {
setDeviceId(id);
deriveDeviceKey(id).then((key) => {
crypto.subtle.exportKey("raw", key).then((key) => {
const enc = new TextDecoder();
setDeviceKey(enc.decode(key));
});
});
});
}, []);
return (
<div>
<p>Id:</p>
<p>{deviceId}</p>
<p>Key:</p>
<p>{deviceKey}</p>
</div>
);
};
export default IndexPage;