supabase_chat_seal 0.1.0
supabase_chat_seal: ^0.1.0 copied to clipboard
Permissive (MIT) end-to-end encryption for supabase_chat: a sealed box over X25519 ECDH + AES-256-GCM with safety-number verification. No copyleft dependencies, so it is safe to use in closed-source apps.
supabase_chat_seal example #
Permissively-licensed (MIT) end-to-end encryption for a 1:1 room: verify the peer, then send. The server only ever sees ciphertext.
import 'package:supabase_chat/supabase_chat.dart';
import 'package:supabase_chat_seal/supabase_chat_seal.dart';
Future<void> main() async {
// One-time per install (persist the private key + trust store yourself).
final identity = await SealIdentity.generate();
final manager = SealManager(
identity: identity,
directory: SupabasePublicKeyDirectory(supabase), // your SupabaseClient
currentUserId: myUserId,
);
await manager.publishOwnKeys();
// Wrap a ChatRoom from supabase_chat.
final secure = SealedChatRoom(
chatRoom,
manager,
recipientUserIds: [peerUserId],
);
await secure.join();
secure.messages.listen((items) {
for (final m in items) {
print(m.plaintext ?? (m.decryptFailed ? 'π (cannot decrypt)' : ''));
}
});
// Strict mode (default): verify the peer before the first send.
final number = await secure.safetyNumber(); // same 60 digits on both sides
// β¦after the user confirms it matches out of band:
await secure.markVerified();
await secure.send('hello, end-to-end π');
}
A complete, backend-free console walkthrough lives at seal_demo.dart:
dart run example/seal_demo.dart