28 lines
722 B
TypeScript
28 lines
722 B
TypeScript
|
|
import { createShade } from '@shade/sdk';
|
||
|
|
|
||
|
|
const alice = await createShade({
|
||
|
|
prekeyServer: '__PREKEY_SERVER__',
|
||
|
|
storage: 'sqlite:./.shade/alice.db',
|
||
|
|
address: 'alice',
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log(`Alice ready. Fingerprint: ${await alice.fingerprint}`);
|
||
|
|
|
||
|
|
// Send a message to Bob
|
||
|
|
const envelope = await alice.send('bob', 'Hey Bob, this is encrypted!');
|
||
|
|
|
||
|
|
// Forward to Bob's process (simple HTTP)
|
||
|
|
const res = await fetch('http://localhost:4001/receive', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
body: JSON.stringify({ from: 'alice', envelope }),
|
||
|
|
});
|
||
|
|
|
||
|
|
if (res.ok) {
|
||
|
|
console.log('✓ Message delivered');
|
||
|
|
} else {
|
||
|
|
console.error('Failed to deliver:', await res.text());
|
||
|
|
}
|
||
|
|
|
||
|
|
await alice.shutdown();
|