Files
Synapsis/try_create_chat.ts
T
Christomatt eb63194c56 refactor: Migrate from ActivityPub federation to native Swarm network
- Remove ActivityPub infrastructure (webfinger, nodeinfo, inbox, activities, signatures)
- Implement native peer-to-peer Swarm network with gossip protocol
- Replace federated timeline with Swarm timeline aggregating posts from all nodes
- Migrate direct messaging to end-to-end encrypted Swarm Chat system
- Update user interactions (follow, like, repost) to use Swarm protocol
- Add cryptographic key management for DID-based identity system
- Remove server-bound identity model in favor of portable DID identities
- Update documentation to reflect Swarm architecture and capabilities
- Add debug utilities and chat testing tools for Swarm network
- Refactor database schema to support distributed user directory
- Update bot framework to work with Swarm network interactions
- Simplify API routes to use Swarm protocol instead of ActivityPub
- This transition enables true peer-to-peer communication, instant interactions, and encrypted messaging while maintaining sovereign identity through DIDs
2026-01-27 01:27:15 +01:00

47 lines
1.6 KiB
TypeScript

import { db } from './src/db/index';
import { users, chatConversations, chatMessages } from './src/db/schema';
import { eq, and } from 'drizzle-orm';
import { encryptMessage } from './src/lib/swarm/chat-crypto';
import crypto from 'crypto';
async function main() {
console.log('--- SIMULATING CHAT SEND ---');
try {
// 1. Get Sender (Cypher)
const sender = await db.query.users.findFirst({
where: eq(users.handle, 'cypher'),
});
if (!sender) throw new Error('Sender not found');
console.log('Sender found:', sender.handle);
// 2. Get Recipient (newinnightvale)
const recipientHandle = 'newinnightvale';
const recipient = await db.query.users.findFirst({
where: eq(users.handle, recipientHandle),
});
if (!recipient) throw new Error('Recipient not found');
console.log('Recipient found:', recipient.handle);
console.log('Recipient PK length:', recipient.publicKey?.length);
// 3. Encrypt
console.log('Encrypting...');
try {
const encrypted = encryptMessage('Hello World', recipient.publicKey);
console.log('Encryption successful. Length:', encrypted.length);
} catch (e) {
console.error('Encryption FAILED:', e);
// Dump key for manual inspection if needed (truncated)
console.log('Key start:', recipient.publicKey.substring(0, 50));
return;
}
console.log('Simulation complete (not inserting to DB to avoid pollution, but encryption passed).');
} catch (e) {
console.error('Error:', e);
}
process.exit(0);
}
main();