[bug] load secrets in wasm memory

This commit is contained in:
Sosthene 2025-09-04 13:18:26 +02:00
parent 4bf0d115e5
commit 7188a33ee8
2 changed files with 22 additions and 0 deletions

View File

@ -800,6 +800,25 @@ export class Service {
} }
} }
public async getAllSecretsFromDB(): Promise<SecretsStore> {
try {
const db = await Database.getInstance();
const sharedSecrets: Record<string, string> = await db.dumpStore('shared_secrets');
const unconfirmedSecrets = await db.dumpStore('unconfirmed_secrets');
const secretsStore = {
shared_secrets: sharedSecrets,
unconfirmed_secrets: Object.values(unconfirmedSecrets),
};
return secretsStore;
} catch (e) {
throw e;
}
}
public loadSecretsInWasm(secretsStore: SecretsStore) {
wasm.set_shared_secrets(JSON.stringify(secretsStore));
}
// Utility method: Create a test process // Utility method: Create a test process
async createTestProcess(processId: string): Promise<any> { async createTestProcess(processId: string): Promise<any> {
console.log(`🔧 Creating test process: ${processId}`); console.log(`🔧 Creating test process: ${processId}`);

View File

@ -426,6 +426,9 @@ export class Server {
// Get all processes from database // Get all processes from database
await service.getAllProcessesFromDb(); await service.getAllProcessesFromDb();
const secretsStore = await service.getAllSecretsFromDB();
service.loadSecretsInWasm(secretsStore);
// Connect to relays // Connect to relays
await service.connectToRelaysAndWaitForHandshake(); await service.connectToRelaysAndWaitForHandshake();