Skip to main content

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โ€‹

  1. Start with the Quick Start Guide
  2. Build the Chat App Tutorial
  3. Explore Basic Examples

For Advanced Usersโ€‹

  1. Read about Architecture
  2. Learn Custom Storage Providers
  3. Implement Advanced Patterns

๐Ÿค Communityโ€‹

Get Helpโ€‹

Contributeโ€‹

๐Ÿš€ 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