Add encrypted key support for chat and nodes

Introduces encrypted private key storage for nodes and users, updates chat message schema to support sender-side encryption, and adds supporting libraries and tests for cryptographic signing and identity unlock flows. Includes new database migrations, API route updates, and React components for identity unlock prompts.
This commit is contained in:
Christopher
2026-01-27 17:13:28 -08:00
parent 25f71e320b
commit 5903022f8a
46 changed files with 7457 additions and 113 deletions
+8 -1
View File
@@ -2,6 +2,7 @@ import { NextResponse } from 'next/server';
import { db } from '@/db';
import { nodes, users } from '@/db';
import { eq, inArray } from 'drizzle-orm';
import { getNodePublicKey } from '@/lib/swarm/node-keys';
export async function GET() {
try {
@@ -12,6 +13,9 @@ export async function GET() {
where: eq(nodes.domain, domain),
});
// Ensure we have a public key
const publicKey = await getNodePublicKey();
// Fetch admin users based on ADMIN_EMAILS env var
const adminEmails = (process.env.ADMIN_EMAILS || '')
.split(',')
@@ -37,6 +41,7 @@ export async function GET() {
description: process.env.NEXT_PUBLIC_NODE_DESCRIPTION || 'A swarm social network node.',
accentColor: process.env.NEXT_PUBLIC_ACCENT_COLOR || '#FFFFFF',
domain,
publicKey,
admins,
turnstileSiteKey: null,
});
@@ -44,9 +49,11 @@ export async function GET() {
return NextResponse.json({
...node,
publicKey, // Always include the public key
admins,
// Don't expose the secret key
// Don't expose the secret keys
turnstileSecretKey: undefined,
privateKeyEncrypted: undefined,
});
} catch (error) {
console.error('Node info error:', error);