New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

libresend-p2p

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libresend-p2p

Decentralized, encrypted, censorship-resistant messaging SDK

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

LibreSend 🔐

Messagerie décentralisée, chiffrée et anti-censure

npm version License: AGPL-3.0

LibreSend est un SDK de communication P2P complet, sans serveur central, sans email, sans numéro de téléphone. Votre identité = vos clés cryptographiques.

✨ Caractéristiques

  • Décentralisé : P2P via libp2p + WebRTC, DHT pour découverte
  • Chiffré : Double Ratchet (Signal Protocol) + libsodium
  • Anonyme : Métadonnées minimisées, compatible Tor
  • Résilient : Messages hors-ligne via Waku
  • Synchronisé : CRDT (Yjs) pour salons et historique
  • Libre : 100% open-source AGPL-3.0

📦 Installation

npm install libresend

🚀 Démarrage rapide

import { LibreSend } from 'libresend';

// Initialiser le client
const client = new LibreSend();
await client.initialize();

// Créer une identité (génère les clés cryptographiques)
const identity = await client.createIdentity('Alice');
console.log('Mon ID:', identity.peerId);

// Se connecter au réseau P2P
await client.connect();

// Envoyer un message chiffré E2E
await client.send('peer-id-destinataire', 'Hello, monde décentralisé!');

// Recevoir des messages
client.onMessage((message) => {
  console.log(`${message.from}: ${message.content}`);
});

📖 API

Classe LibreSend

Initialisation

const client = new LibreSend(options?: LibreSendOptions);

interface LibreSendOptions {
  bootstrapNodes?: string[];  // Nœuds bootstrap personnalisés
  enableRelay?: boolean;      // Activer le relay pour NAT traversal (défaut: true)
}

Méthodes principales

MéthodeDescription
initialize()Initialise le client et la crypto
createIdentity(name)Crée une nouvelle identité avec clés
loadIdentity(exported)Charge une identité exportée
connect()Se connecte au réseau P2P
disconnect()Se déconnecte proprement
send(peerId, content)Envoie un message chiffré
onMessage(callback)Écoute les messages entrants

Salons (Rooms) avec CRDT

// Créer ou rejoindre un salon
const room = await client.joinRoom('mon-salon');

// Envoyer un message au salon
await room.send('Hello tout le monde!');

// Écouter les messages du salon
room.onMessage((msg) => {
  console.log(`[${msg.sender}]: ${msg.content}`);
});

// Synchronisation automatique via CRDT (Yjs)
// Les messages sont ordonnés et convergent automatiquement

Gestion d'identité

// Exporter l'identité (pour backup)
const exported = await client.exportIdentity('mot-de-passe-fort');

// Importer sur un autre appareil
await client.loadIdentity(exported, 'mot-de-passe-fort');

// Obtenir le fingerprint pour vérification
const fingerprint = client.getFingerprint();
// "A1B2 C3D4 E5F6 ..."

🏗️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Votre Application                         │
└─────────────────────────────────────────────────────────────┘
                              │
┌─────────────────────────────▼─────────────────────────────────┐
│                     LibreSend SDK                             │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐          │
│  │   Identity   │ │   Messaging  │ │    Rooms     │          │
│  │   Manager    │ │   (E2E)      │ │   (CRDT)     │          │
│  └──────────────┘ └──────────────┘ └──────────────┘          │
└───────────────────────────────────────────────────────────────┘
                              │
┌─────────────────────────────▼─────────────────────────────────┐
│                      Réseau P2P                               │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐        │
│  │  WebRTC  │ │   DHT    │ │ GossipSub│ │  Relay   │        │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘        │
└───────────────────────────────────────────────────────────────┘

🔐 Sécurité

Algorithmes cryptographiques

ComposantAlgorithme
Identity KeyEd25519
Key ExchangeX25519 (Curve25519)
ChiffrementChaCha20-Poly1305
Key DerivationHKDF-SHA256
Password HashArgon2id

Garanties de sécurité

  • Forward Secrecy : Double Ratchet, nouvelle clé à chaque message
  • Protection MITM : Signatures Ed25519, vérification fingerprint
  • Protection Replay : Nonces uniques + timestamps + counters
  • Métadonnées minimales : Padding, timing aléatoire optionnel
  • Pas de serveur central : Aucun point de compromission unique

Double Ratchet (Signal Protocol)

Alice                                    Bob
  │                                        │
  │  1. X3DH Key Agreement                │
  │  ──────────────────────────────────►  │
  │                                        │
  │  2. Symmetric Ratchet (chaque msg)    │
  │  ◄─────────────────────────────────►  │
  │                                        │
  │  3. DH Ratchet (périodique)           │
  │  ◄─────────────────────────────────►  │

🔄 Migration depuis Socket.IO

LibreSend inclut un bridge pour migrer progressivement depuis Socket.IO :

import { LibreSendBridge } from 'libresend/bridge';

const bridge = new LibreSendBridge({
  mode: 'gateway',      // 'gateway' | 'hybrid'
  socketIOPort: 3001,
});

// Les clients Socket.IO existants fonctionnent sans modification
// Le bridge traduit automatiquement vers LibreSend

Voir le guide de migration complet.

🌐 NAT Traversal

LibreSend gère automatiquement le NAT traversal :

  • Connexion directe (même réseau)
  • STUN (NAT simple)
  • TURN (NAT symétrique)
  • Circuit Relay (libp2p, pairs volontaires)

Le chiffrement E2E est préservé dans tous les cas.

📊 Stockage hors-ligne

Les messages pour les pairs hors-ligne sont stockés temporairement via Waku :

  • TTL : 7 jours par défaut
  • Chiffrement E2E préservé
  • Récupération automatique à la reconnexion

🛠️ Configuration avancée

const client = new LibreSend({
  // Nœuds bootstrap personnalisés
  bootstrapNodes: [
    '/dns4/bootstrap.example.com/tcp/4001/p2p/...',
  ],
  
  // Désactiver le relay (connexions directes uniquement)
  enableRelay: false,
});

📋 Prérequis

  • Node.js >= 18.0.0
  • Navigateur moderne avec WebRTC (pour usage web)

🤝 Contribuer

Les contributions sont les bienvenues ! Voir le dépôt GitLab.

📜 Licence

AGPL-3.0 - Libre pour toujours.

LibreSend - Communication libre, chiffrée, décentralisée.

Keywords

p2p

FAQs

Package last updated on 04 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts