diff --git a/package.json b/package.json index e29bc23..0eb2196 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "scripts": { "dev": "vite", + "typecheck": "tsc --noEmit", "build": "tsc && vite build", "preview": "vite preview", "tauri": "tauri" diff --git a/src-tauri/src/commands/accounts.rs b/src-tauri/src/commands/accounts.rs index a6862e8..8124468 100644 --- a/src-tauri/src/commands/accounts.rs +++ b/src-tauri/src/commands/accounts.rs @@ -2,11 +2,12 @@ use serde::{Deserialize, Serialize}; use std::fs; use tauri::{AppHandle, Manager}; +use crate::protocol::ClientMeta; + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Account { - pub display_name: String, - pub avatar: Option, + pub meta: ClientMeta, pub private_key: String, } diff --git a/src-tauri/src/protocol.rs b/src-tauri/src/protocol.rs index 3518cf2..163e0eb 100644 --- a/src-tauri/src/protocol.rs +++ b/src-tauri/src/protocol.rs @@ -3,9 +3,14 @@ use std::borrow::Cow; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ClientMeta {} +#[serde(rename_all = "camelCase")] +pub struct ClientMeta { + pub display_name: String, + pub avatar: Option, +} #[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct ServerMeta { pub name: String, pub description: String, diff --git a/src/app/app.ts b/src/app/app.ts index 5c572e9..a103451 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -62,8 +62,13 @@ export default class Enclave

{ const timestamp = Date.now(); + if (!this.server?.serverPublicKey) { + console.error("Server pubkey not initialized"); + return; + } + const signature = new TextEncoder().encode( - `${timestamp}@${this.server?.hostname}@${content}`, + `${timestamp}@${base58.encode(this.server?.serverPublicKey)}@${content}`, ); this.server?.websocket?.send({ diff --git a/src/components/page/PageView.tsx b/src/components/page/PageView.tsx index 9dfb093..7ba5401 100644 --- a/src/components/page/PageView.tsx +++ b/src/components/page/PageView.tsx @@ -1,6 +1,6 @@ import Enclave from "@/app/app"; import ChannelPage from "./channel/ChannelPage"; -import { Channel } from "@/app/protocol"; +import { Channel } from "@/lib/types"; export type ChannelPageProps = { kind: "channel"; diff --git a/src/components/view/AccountCard.tsx b/src/components/view/AccountCard.tsx index 2961dd7..67b8a9a 100644 --- a/src/components/view/AccountCard.tsx +++ b/src/components/view/AccountCard.tsx @@ -20,8 +20,8 @@ export default function AccountCard({

- - {account.displayName[0]} + + {account.meta.displayName[0]}
-

{account.displayName}

+

{account.meta.displayName}

Online diff --git a/src/components/view/NewProfileView.tsx b/src/components/view/NewProfileView.tsx index a5c06d8..4b3c07a 100644 --- a/src/components/view/NewProfileView.tsx +++ b/src/components/view/NewProfileView.tsx @@ -68,16 +68,16 @@ export function NewProfilePage({ const { secretKey } = ed.keygen(); - const newAccount = { - displayName: name, - privateKey: base58.encode(secretKey), - avatar: avatar ?? undefined, - }; - appRef.current.accounts.activeAccount = appRef.current.accounts.accounts.length; - appRef.current.accounts.accounts.push(newAccount); + appRef.current.accounts.accounts.push({ + meta: { + displayName: name, + avatar: avatar ?? undefined, + }, + privateKey: base58.encode(secretKey), + }); saveAccounts(appRef.current.accounts); } catch (e) { diff --git a/src/components/view/Sidebar.tsx b/src/components/view/Sidebar.tsx index eb0c94d..d786dc2 100644 --- a/src/components/view/Sidebar.tsx +++ b/src/components/view/Sidebar.tsx @@ -1,5 +1,5 @@ import Enclave from "@/app/app"; -import { Channel, ChannelKind } from "@/app/protocol"; +import { Channel, ChannelKind } from "@/lib/types"; import { ChevronDown, ChevronUp, HashIcon } from "lucide-react"; import { useState } from "react"; import AccountCard from "./AccountCard";