feat(client): add keypair generation

This commit is contained in:
nav
2026-04-08 21:34:38 +00:00
parent fb39a17dbb
commit fc226b1f18
3 changed files with 155 additions and 4 deletions

View File

@@ -9,11 +9,12 @@ import {
} from "../../../Yonexus.Protocol/src/index.js";
import type { YonexusClientConfig } from "./config.js";
import {
createInitialClientState,
ensureClientKeyPair,
hasClientKeyPair,
hasClientSecret,
type YonexusClientState,
type YonexusClientStateStore
createInitialClientState,
YonexusClientState,
YonexusClientStateStore
} from "./state.js";
import type { ClientConnectionState, ClientTransport } from "./transport.js";
@@ -66,7 +67,12 @@ export class YonexusClientRuntime {
}
this.phase = "starting";
this.clientState = await this.options.stateStore.load(this.options.config.identifier);
// Load existing state and ensure key pair exists
let state = await this.options.stateStore.load(this.options.config.identifier);
const keyResult = await ensureClientKeyPair(state, this.options.stateStore);
this.clientState = keyResult.state;
await this.options.transport.connect();
}