Ok
This commit is contained in:
@@ -5,6 +5,12 @@ export default function App() {
|
|||||||
const appRef = useRef<Enclave | null>(null);
|
const appRef = useRef<Enclave | null>(null);
|
||||||
if (!appRef.current) {
|
if (!appRef.current) {
|
||||||
appRef.current = new Enclave();
|
appRef.current = new Enclave();
|
||||||
|
appRef.current
|
||||||
|
.init()
|
||||||
|
.then(() => {
|
||||||
|
console.log("Encalve initialized");
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+10
-4
@@ -1,5 +1,9 @@
|
|||||||
|
import { getServerList, KnownServer } from "@/lib/serverList";
|
||||||
import EnclaveServer from "./server";
|
import EnclaveServer from "./server";
|
||||||
import * as ed from "@noble/ed25519";
|
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.
|
* Top-level application state and client-side logic.
|
||||||
@@ -17,14 +21,16 @@ import * as ed from "@noble/ed25519";
|
|||||||
export default class Enclave {
|
export default class Enclave {
|
||||||
private clientSecretKey: Uint8Array;
|
private clientSecretKey: Uint8Array;
|
||||||
private clientPublicKey: Uint8Array;
|
private clientPublicKey: Uint8Array;
|
||||||
public server: EnclaveServer;
|
public server?: EnclaveServer;
|
||||||
|
public serverList: KnownServer[];
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
this.clientSecretKey = ed.utils.randomSecretKey();
|
this.clientSecretKey = ed.utils.randomSecretKey();
|
||||||
this.clientPublicKey = ed.getPublicKey(this.clientSecretKey);
|
this.clientPublicKey = ed.getPublicKey(this.clientSecretKey);
|
||||||
|
this.serverList = [];
|
||||||
|
}
|
||||||
|
|
||||||
this.server = new EnclaveServer("localhost:3415");
|
public async init() {
|
||||||
|
this.serverList = await getServerList();
|
||||||
this.server.connect(this.clientPublicKey, this.clientSecretKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
type KnownServer = {
|
export interface KnownServer {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
hostname: string;
|
hostname: string;
|
||||||
isWss: boolean;
|
isWss: boolean;
|
||||||
};
|
}
|
||||||
|
|
||||||
export async function saveServerList(servers: KnownServer[]): Promise<void> {
|
export async function saveServerList(servers: KnownServer[]): Promise<void> {
|
||||||
await invoke("save_server_list", { servers });
|
await invoke("save_server_list", { servers });
|
||||||
|
|||||||
Reference in New Issue
Block a user