Welcome to Vaultys Peer SDK ๐
Build powerful peer-to-peer applications that your users will love! Whether you're creating a chat app, file-sharing platform, or collaborative tool, Vaultys Peer SDK gives you everything you need to ship fast.
Why Vaultys Peer SDK?โ
๐ฏ The Problemโ
Building P2P applications is hard. You need to:
- Understand WebRTC complexity
- Handle connection management
- Implement reconnection logic
- Manage peer discovery
- Deal with NAT traversal
- Build message protocols
- Handle file transfers
- ...and so much more
โจ The Solutionโ
Vaultys Peer SDK abstracts away the complexity while giving you full control. We handle the hard parts so you can focus on building amazing features.
// This is all it takes to get started!
import { setupVaultysPeerSDK } from '@vaultys/peer-sdk';
const peer = setupVaultysPeerSDK();
await peer.initialize('did:example:alice');
// Connect and chat with a friend
const friend = await peer.addContact('did:example:bob');
await peer.sendMessage(friend.did, 'Hello P2P World! ๐');
๐ฎ What Can You Build?โ
The possibilities are endless! Here are just a few examples:
๐ฌ Real-time Chat Appsโ
Build WhatsApp-like messaging with end-to-end encryption, file sharing, and group chats.
๐ File Sharing Platformsโ
Create Dropbox-style file sharing without servers. Direct transfers between users.
๐ฎ Multiplayer Gamesโ
Low-latency networking for real-time gameplay. Perfect for turn-based or action games.
๐น Video Conferencingโ
Add Zoom-like video calls to your app with WebRTC media streaming.
๐ค Collaboration Toolsโ
Real-time collaborative editing, whiteboarding, and screen sharing.
๐ Secure Communicationโ
Private channels for sensitive data with end-to-end encryption.
๐ Quick Startโ
Get your first P2P app running in under 5 minutes with passwordless authentication and automatic offline message handling:
1. Installationโ
# Using npm
npm install @vaultys/peer-sdk
# Using yarn
yarn add @vaultys/peer-sdk
# Using pnpm
pnpm add @vaultys/peer-sdk
2. Basic Setupโ
import { setupVaultysPeerSDK } from '@vaultys/peer-sdk';
import { VaultysId } from '@vaultys/id'; // Batteries included!
// Authenticate with passkey - incredibly simple!
const identity = await VaultysId.authenticate({
passkey: true, // Enable biometric/security key auth
fallbackToPin: true // Optional PIN fallback
});
// No passwords needed! ๐
// Initialize the SDK with authenticated identity
const peerService = setupVaultysPeerSDK({
identity, // Use authenticated identity
debug: true,
// Optional: Bring your own signaling server
relay: {
host: 'your-server.com',
port: 443,
secure: true
}
});
// Already authenticated and connected!
await peerService.initialize(identity.did);
console.log('Connected with DID:', peerService.myDid);
3. Connect with Friendsโ
// Add contacts - lazy loading means no connection overhead!
const friend = await peerService.addContact('did:vaultys:friend', {
nickname: 'My Friend',
accepted: true
});
// Add thousands of contacts efficiently
const contacts = await peerService.bulkAddContacts(thousandsOfDids);
// No connections established yet - zero overhead!
// Connection only happens when you send a message
// Send a message (connection established now!)
await peer.sendMessage(friend.did, 'Hey there! ๐');
// NOW the connection is established!
// Peer offline? No problem! Messages queue automatically
await peer.sendMessage(friend.did, 'This message will queue if offline');
// It will be delivered seamlessly when they come back online!
// Listen for messages
peer.on('message-received', (message) => {
console.log(`${message.from}: ${message.content}`);
});
// Track delivery status
peer.on('message-delivered', (msg) => {
console.log(`โ
Message ${msg.id} delivered to ${msg.to}`);
});
4. Share Filesโ
// Send a file
const file = document.querySelector('input[type="file"]').files[0];
const buffer = await file.arrayBuffer();
await peerService.sendMessage(friend.did, 'Check this file!', 'file', {
name: file.name,
size: file.size,
type: file.type,
data: buffer
});
// Receive files
peerService.on('message-received', (message) => {
if (message.type === 'file') {
const blob = new Blob([message.fileData.data]);
const url = URL.createObjectURL(blob);
// Download or display the file
}
});
๐๏ธ Architecture Overviewโ
Vaultys Peer SDK is built with a clean, modular architecture:
Core Componentsโ
- PeerService: Main service for peer management
- VaultysPeer: Individual peer connection handling
- Storage Provider: Pluggable storage interface
- Event Bus: Decoupled event system
- Message Queue: Automatic offline message queueing and delivery
- Health Monitor: Connection health tracking
- Delivery Manager: Ensures 100% message delivery with retry logic
- Coming Soon: Relay Server: Open-source signaling server with message relay
๐ฏ Key Featuresโ
๐ Batteries Includedโ
Powered by VaultysId - the leading open-source Decentralized Identity System. Get enterprise-grade DID management out of the box, with W3C compliance and verifiable credentials. Passkey and FIDO2 authentication has never been so easy! Enable passwordless login with just one line of code.
โก Lazy Loading at Scaleโ
Manage thousands of peers with zero overhead. Connections are established only when messages are exchanged. Perfect for large-scale applications with dynamic peer networks.
๐ฌ Never Lose a Messageโ
Automatic message queueing for offline peers! If a peer is offline, messages are queued seamlessly and delivered automatically when they reconnect. No manual retry logic needed - the SDK handles everything for you.
๐๏ธ Bring Your Own Infrastructureโ
Complete control over your P2P stack. Bring your own signaling server today. Coming soon: We're open-sourcing our production-grade signaling server that also acts as a message relay for ultimate reliability! Plus custom DID system support for maximum flexibility.
๐ Passwordless Authenticationโ
Passkey/FIDO2 made simple! VaultysId brings biometric and security key authentication to your P2P apps with minimal code. Say goodbye to passwords forever.
๐ DID-based Identityโ
Use Decentralized Identifiers for peer identification. No central authority needed.
๐ฌ Rich Messagingโ
Send text, files, images, and custom data types between peers.
๐ Audio/Video Callsโ
Built-in support for WebRTC media streams with easy-to-use APIs.
๐ฅ Group Managementโ
Organize peers into groups for broadcast messaging and management.
๐พ Flexible Storageโ
Choose from multiple storage backends or bring your own.
๐ Auto-Reconnectionโ
Automatic connection recovery with exponential backoff.
๐ฅ Health Monitoringโ
Real-time connection health tracking and diagnostics.
๐ฆ TypeScript Firstโ
Full TypeScript support with comprehensive type definitions.
๐จ Design Principlesโ
1. Simple by Defaultโ
Get started with minimal configuration. Advanced features when you need them.
2. Extensibleโ
Plugin architecture for storage, events, and protocols.
3. Reliableโ
Automatic reconnection, message queueing, and error recovery.
4. Privacy-Firstโ
No central servers for messages. Your data stays between peers.
5. Cross-Platformโ
Works in modern browsers and Node.js environments.
๐ Learning Pathโ
For Beginnersโ
- Start with the Quick Start Guide
- Build the Chat App Tutorial
- Explore Basic Examples
For Advanced Usersโ
- Read about Architecture
- Learn Custom Storage Providers
- Implement Advanced Patterns
๐ค Communityโ
Get Helpโ
- ๐ฌ Discord Community
- ๐ Report Issues
- ๐ก Discussions
Contributeโ
- โญ Star on GitHub
- ๐ด Fork & Contribute
- ๐ Contributing Guide
๐ Ready to Build?โ
You now have everything you need to start building amazing P2P applications!
Built with ๐ by the Vaultys team and the P2P community