This commit is contained in:
2026-08-18 14:37:08 +02:00
parent f115a86291
commit bca54910be
3 changed files with 18 additions and 6 deletions
+6
View File
@@ -5,6 +5,12 @@ export default function App() {
const appRef = useRef<Enclave | null>(null);
if (!appRef.current) {
appRef.current = new Enclave();
appRef.current
.init()
.then(() => {
console.log("Encalve initialized");
})
.catch(console.error);
}
return (
+10 -4
View File
@@ -1,5 +1,9 @@
import { getServerList, KnownServer } from "@/lib/serverList";
import EnclaveServer from "./server";
import * as ed from "@noble/ed25519";
import { sha512 } from "@noble/hashes/sha2.js";
ed.hashes.sha512 = sha512;
/**
* Top-level application state and client-side logic.
@@ -17,14 +21,16 @@ import * as ed from "@noble/ed25519";
export default class Enclave {
private clientSecretKey: Uint8Array;
private clientPublicKey: Uint8Array;
public server: EnclaveServer;
public server?: EnclaveServer;
public serverList: KnownServer[];
public constructor() {
this.clientSecretKey = ed.utils.randomSecretKey();
this.clientPublicKey = ed.getPublicKey(this.clientSecretKey);
this.serverList = [];
}
this.server = new EnclaveServer("localhost:3415");
this.server.connect(this.clientPublicKey, this.clientSecretKey);
public async init() {
this.serverList = await getServerList();
}
}
+2 -2
View File
@@ -1,12 +1,12 @@
import { invoke } from "@tauri-apps/api/core";
type KnownServer = {
export interface KnownServer {
name: string;
description: string;
publicKey: string;
hostname: string;
isWss: boolean;
};
}
export async function saveServerList(servers: KnownServer[]): Promise<void> {
await invoke("save_server_list", { servers });