Better structure and docs

This commit is contained in:
2026-08-17 08:28:03 +02:00
parent 2a8e3f41d7
commit 210f6668cd
5 changed files with 79 additions and 21 deletions
+32
View File
@@ -0,0 +1,32 @@
import EnclaveServer from "./server";
import * as ed from "@noble/ed25519";
/**
* Top-level application state and client-side logic.
*
* Owns all active connections — currently `EnclaveServer` instances, one
* per connected server, keyed by server id — and will later also own
* `DMServer` connections once direct messages are implemented.
*
* This is where UI-facing logic lives: handling user actions (button
* clicks, switching the active server, sending a message from an input
* box), and exposing state for the UI layer to render. The UI itself
* should stay a pure display of what `Enclave` exposes — it should not
* reach into `EnclaveServer` or `EnclaveWebSocket` directly.
*/
export default class Enclave {
private clientSecretKey: Uint8Array;
private clientPublicKey: Uint8Array;
public server: EnclaveServer;
public constructor() {
this.clientSecretKey = ed.utils.randomSecretKey();
this.clientPublicKey = ed.getPublicKey(this.clientSecretKey);
this.server = new EnclaveServer(
"localhost:3415",
this.clientSecretKey,
this.clientPublicKey,
);
}
}