Skip to main content

Getting Started with Vaultys P2P SDK

Welcome to Vaultys! This guide will help you quickly build peer-to-peer applications with decentralized identities, encrypted messaging, and real-time collaboration features.

๐ŸŽฏ Choose Your Pathโ€‹

๐ŸŽฎ Just Want to Try It?โ€‹

Open the Playground - Test all features instantly in your browser without writing any code!

๐Ÿš€ Ready to Build?โ€‹

Quick Start Guide - Build your first P2P app in 5 minutes

๐Ÿ“š Need Details?โ€‹

Installation Guide - Complete setup instructions for all platforms

๐ŸŽจ Want to Explore?โ€‹

Playground Guide - Learn all playground features and capabilities

๐Ÿ“ฆ What You'll Buildโ€‹

With the Vaultys SDK, you can create:

  • ๐Ÿ’ฌ P2P Chat Applications

    • End-to-end encrypted messaging
    • File and media sharing
    • Read receipts and typing indicators
    • Offline message queuing
  • ๐ŸŽจ Collaborative Tools

    • Real-time canvas drawing
    • Shared document editing
    • Live cursor tracking
    • Automatic synchronization
  • ๐Ÿ” Decentralized Identity Systems

    • Self-sovereign identities (DIDs)
    • WebAuthn/Passkey support
    • No central authority required
    • User-owned data
  • ๐Ÿ“ Distributed Applications

    • Direct peer connections
    • No backend servers needed
    • Automatic NAT traversal
    • Cross-platform support

โšก Quick Overviewโ€‹

1. Install the SDKโ€‹

npm install @vaultys/peer-sdk @vaultys/id

2. Create an Identityโ€‹

import { VaultysId } from '@vaultys/id';

// Software-based identity
const identity = await VaultysId.generatePerson();

// Or hardware-based with passkey
const identity = await VaultysId.createWebauthn(true);

console.log('My DID:', identity.did);

3. Connect to P2P Networkโ€‹

import { setupVaultysPeerSDK, BrowserStorageProvider } from '@vaultys/peer-sdk';

const peer = setupVaultysPeerSDK({
vaultysId: identity,
storageProvider: new BrowserStorageProvider()
});

await peer.initialize();
console.log('Connected to P2P network!');

4. Send Your First Messageโ€‹

// Add a contact
const contact = await peer.addContact('did:vaultys:alice123', {
nickname: 'Alice'
});

// Send a message
await peer.sendMessage(contact.did, 'Hello Alice! ๐Ÿ‘‹');

// Listen for replies
peer.on('message-received', (message) => {
console.log(`${message.from}: ${message.content}`);
});

๐Ÿ—๏ธ Architecture Overviewโ€‹

Core Componentsโ€‹

  1. Identity Layer (@vaultys/id)

    • Creates and manages decentralized identities
    • Supports software keys and hardware passkeys
    • No central authority or blockchain required
  2. P2P Network (@vaultys/peer-sdk)

    • Direct peer-to-peer connections via WebRTC
    • Automatic NAT traversal and reconnection
    • End-to-end encryption by default
  3. Storage Layer

    • Multiple storage providers (Browser, Node.js, Memory)
    • Automatic data persistence
    • Encrypted local storage

๐ŸŽ“ Learning Pathโ€‹

Beginnerโ€‹

  1. Try the Playground - Explore features interactively
  2. Quick Start - Build a simple chat app
  3. Basic Examples - Learn from code examples

Intermediateโ€‹

  1. P2P Chat Tutorial - Full chat implementation
  2. Collaborative Features - Add real-time collaboration
  3. React Integration - Use with React

Advancedโ€‹

  1. API Reference - Complete API documentation
  2. Storage Providers - Custom storage solutions
  3. Production Deployment - Deploy to production

๐Ÿ› ๏ธ Development Toolsโ€‹

Browser DevTools Integrationโ€‹

The SDK provides detailed logging in development mode:

const peer = setupVaultysPeerSDK({
vaultysId: identity,
debug: true // Enable detailed logging
});

Testing Utilitiesโ€‹

Test P2P features locally:

// Create mock identities for testing
const alice = await VaultysId.generatePerson();
const bob = await VaultysId.generatePerson();

// Open in different tabs/windows
window.location.hash = alice.did; // Tab 1
window.location.hash = bob.did; // Tab 2

๐Ÿ’ก Key Conceptsโ€‹

Decentralized Identity (DID)โ€‹

Every peer has a unique, cryptographically secure identifier:

  • Format: did:vaultys:5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
  • Self-generated, no registration needed
  • Portable across applications
  • User owns their identity

P2P Connectionโ€‹

Direct connections between peers:

  • No intermediate servers for data
  • End-to-end encrypted
  • Automatic reconnection
  • Works through firewalls (NAT traversal)

Storage Providersโ€‹

Flexible data persistence:

  • Browser: IndexedDB, LocalStorage
  • Node.js: File system
  • Memory: Temporary storage
  • Custom: Implement your own

๐Ÿš€ Ready to Start?โ€‹

๐Ÿค Get Helpโ€‹

๐Ÿ“„ Licenseโ€‹

The Vaultys SDK is open source and available under the MIT License. See LICENSE for details.


Ready to build the future of P2P applications? Let's go! ๐Ÿš€