Skip to content

Developer Guide

SecureBitChat edited this page Aug 18, 2025 · 1 revision

Developer Guide

Overview

SecureBit.chat is built with modern web technologies and follows security-first principles.

Technology Stack

  • Frontend: Pure JavaScript + React (CDN)
  • Cryptography: Web Crypto API
  • Network: WebRTC P2P Data Channels
  • Payments: Lightning Network via WebLN
  • Styling: TailwindCSS + custom CSS

πŸ”§ Development Setup

Prerequisites

  • Node.js 16+ (for development tools)
  • Git
  • Modern browser with WebRTC support
  • Lightning wallet with WebLN

Local Development

# Clone repository
git clone https://github.com/SecureBitChat/securebit-chat.git
cd securebit-chat

# Install development dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

Development Tools

# Code formatting
npm run format

# Linting
npm run lint

# Security audit
npm audit

# Testing
npm test

πŸ” Security Development

Cryptographic Implementation

// Example: Key generation
async function generateKeyPair() {
  return await window.crypto.subtle.generateKey(
    {
      name: "ECDH",
      namedCurve: "P-384"
    },
    true,
    ["deriveKey", "deriveBits"]
  );
}

// Example: Message encryption
async function encryptMessage(message, key) {
  const iv = window.crypto.getRandomValues(new Uint8Array(12));
  const encoded = new TextEncoder().encode(message);
  
  const encrypted = await window.crypto.subtle.encrypt(
    {
      name: "AES-GCM",
      iv: iv
    },
    key,
    encoded
  );
  
  return { encrypted, iv };
}

Security Best Practices

  1. Never store sensitive data
  2. Use secure random generation
  3. Implement proper key rotation
  4. Validate all inputs
  5. Clean up memory properly

πŸ§ͺ Testing

Unit Tests

# Run unit tests
npm run test:unit

# Run with coverage
npm run test:coverage

Integration Tests

# Run integration tests
npm run test:integration

# Test Lightning integration
npm run test:lightning

Security Tests

# Run security tests
npm run test:security

# Cryptographic validation
npm run test:crypto

πŸ“¦ Building and Deployment

Production Build

# Create optimized build
npm run build

# Build artifacts in dist/

Deployment Options

  1. GitHub Pages: Automatic deployment
  2. Netlify: Drag and drop deployment
  3. Vercel: Git integration
  4. Custom server: Manual deployment

Environment Configuration

# Production environment
NODE_ENV=production
LIGHTNING_NODE_URL=your_node
STUN_SERVERS=stun:stun.l.google.com:19302
Clone this wiki locally