0.0.19-b β€’ Published 10 months ago

@scobru/shogun v0.0.19-b

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

icon: ethereum

SHOGUN - Decentralized Wallet Manager

A decentralized wallet manager that uses Gun.js to handle wallets and private keys directly in the browser. It provides a complete authentication and key management system with support for stealth addresses and ActivityPub integration.

{% content-ref url="broken-reference" %} Broken link {% endcontent-ref %}

✨ Key Features

  • πŸ” Advanced Security
    • Secure private key management with Web Crypto API
    • Stealth address support
    • End-to-end encryption
    • Secure entropy management
    • ActivityPub key management
    • HD wallet derivation
    • Off-chain payment channels
  • 🌐 Decentralization
    • Distributed storage with Gun.js
    • P2P synchronization
    • No central server
    • ActivityPub federation support
    • Decentralized messaging
    • Stealth transactions
  • πŸ”„ Portability
    • Complete data import/export
    • Encrypted backups
    • Multi-device support
    • Cross-platform compatibility
    • HD wallet recovery
  • πŸ’° Payment Features
    • HD wallet management
    • Stealth addresses
    • Off-chain micropayments
    • Payment channels
    • Transaction privacy
  • πŸ’¬ Communication
    • Decentralized chat
    • Private messaging
    • Group channels
    • Announcement channels
    • RSS integration

πŸ› οΈ Requirements

  • Node.js >= 16.0.0
  • npm >= 7.0.0
  • Modern browser with Web Crypto API support
  • For Node.js: crypto module support

πŸš€ Installation

npm install @scobru/shogun

πŸ“š Quick Start

Basic Usage

import { Shogun } from '@scobru/shogun'

// Inizializza Shogun con la configurazione Gun
const shogun = new Shogun({
  peers: ['https://your-gun-peer.com/gun'],
  localStorage: false,
  radisk: false,
  multicast: false
}, APP_KEY_PAIR);

// Crea account
try {
  await shogun.createAccount('username', 'password');
} catch (error) {
  console.error('Account creation failed:', error);
}

// Login
const pubKey = await shogun.login('username', 'password');

// Crea HD wallet
const wallet = await shogun.createHDWallet();

console.log('Address:', wallet.address);
console.log('HD Path:', wallet.entropy);

// Crea stealth address
const stealthAddress = await shogun.generateStealthAddress(recipientPubKey);

// Configura canale di pagamento
const channel = await shogun.createPaymentChannel(relayAddress, deposit);

// Avvia chat
await shogun.joinChat('username', 'password', 'Display Name');

Module-specific Examples

See individual module documentation for detailed examples:

πŸ”’ Security

Key Management

  • HD wallet support with BIP32/BIP39
  • Stealth address generation
  • Private key encryption
  • Secure key derivation
  • Multi-layer encryption

Secure Storage

  • Encrypted GunDB storage
  • Distributed data storage
  • No plain text private keys
  • Secure key backup
  • State verification

πŸ“¦ Core Interfaces

interface ShogunConfig {
  peers: string[];
  localStorage?: boolean;
  radisk?: boolean;
  multicast?: boolean;
  debug?: boolean;
}

interface WalletConfig {
  hdPath?: string;
  strength?: number;
  network?: string;
}

interface PaymentChannelConfig {
  challengePeriod: number;
  deposit: string;
  relay: string;
}

interface ChatConfig {
  superpeers: string[];
  encryption?: boolean;
  rssEnabled?: boolean;
}

πŸ§ͺ Testing

# Run all tests
npm test

# Test specific modules
npm test -- --grep "Wallet"
npm test -- --grep "Micropayments"
npm test -- --grep "Chat"

πŸ’» Compatibility

  • Browsers:
    • Chrome >= 80
    • Firefox >= 78
    • Safari >= 14
    • Edge >= 80
    • Web Crypto API support required
  • Node.js:
    • Version >= 16.0.0
    • crypto module support

🀝 Contributing

  1. 🍴 Fork the repository
  2. πŸ”§ Create feature branch
  3. πŸ’Ύ Commit changes
  4. πŸš€ Push branch
  5. πŸ“ Create Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Add unit tests for new features
  • Update documentation
  • Follow semantic versioning
  • Add JSDoc comments

πŸ“„ License

MIT

πŸ—ΊοΈ Roadmap

Version 1.x

  • Basic wallet management
  • HD wallet support
  • Stealth addresses
  • ActivityPub integration
  • Basic chat functionality

Version 2.x

  • Enhanced privacy features
  • Improved chat capabilities
  • Advanced payment channels
  • Cross-chain support
  • Enhanced security features

Version 3.x

  • DAO integration
  • Smart contract templates
  • Advanced federation
  • AI-powered features
  • Mobile optimization

πŸ—οΈ Architecture

Core Components

Shogun (Main Class)
β”œβ”€β”€ Authentication
β”‚   β”œβ”€β”€ WebAuthn
β”‚   └── GunAuth
β”œβ”€β”€ Wallet
β”‚   β”œβ”€β”€ HDWallet
β”‚   β”œβ”€β”€ StealthAddresses
β”‚   └── JsonRpcConnector
β”œβ”€β”€ Communication
β”‚   β”œβ”€β”€ Chat
β”‚   └── ActivityPub
β”œβ”€β”€ Payments
β”‚   β”œβ”€β”€ Micropayments
β”‚   └── PaymentChannels
└── Storage
    └── GunStorage

Data Flow

graph TD
    A[User] --> B[Shogun]
    B --> C[Wallet]
    B --> D[Communication]
    B --> E[Payments]
    C --> F[Storage]
    D --> F
    E --> F
    F --> G[GunDB]

πŸ“± Mobile Support

  • React Native compatibility
  • Mobile-optimized storage
  • Biometric authentication
  • Push notifications
  • Offline support

πŸ”§ Configuration

const config = {
  // Gun.js configuration
  gun: {
    peers: ['https://peer1.com/gun', 'https://peer2.com/gun'],
    localStorage: false,
    radisk: true
  },
  
  // Wallet configuration
  wallet: {
    hdPath: "m/44'/60'/0'/0",
    network: 'mainnet',
    strength: 256
  },
  
  // Chat configuration
  chat: {
    encryption: true,
    rssEnabled: true,
    superpeers: ['https://superpeer1.com']
  },
  
  // Payment configuration
  payment: {
    challengePeriod: 86400,
    minDeposit: '0.1'
  }
};
0.0.19-b

10 months ago

0.0.19

10 months ago

0.0.18-c

10 months ago

0.0.18-b

10 months ago

0.0.18-a

10 months ago

0.0.18

10 months ago

0.0.17-m1

10 months ago

0.0.17-m

10 months ago

0.0.17-g

10 months ago

0.0.17-l

10 months ago

0.0.17-i

10 months ago

0.0.17-h

10 months ago

0.0.17-f

10 months ago

0.0.17-e

10 months ago

0.0.17-d

10 months ago

0.0.17-a

10 months ago

0.0.17

10 months ago

0.0.16-c

10 months ago

0.0.16-b

10 months ago

0.0.16

10 months ago

0.0.15-g

10 months ago

0.0.15-f

10 months ago

0.0.15-e

10 months ago

0.0.15-d

10 months ago

0.0.15-c

10 months ago

0.0.15

10 months ago

0.0.14-d

10 months ago

0.0.14-c

10 months ago

0.0.14-b

10 months ago

0.0.14-a

10 months ago

0.0.14

10 months ago

0.0.13-g

10 months ago

0.0.13-f

10 months ago

0.0.13-e

10 months ago

0.0.13-d

10 months ago

0.0.13-c

10 months ago

0.0.13-b

10 months ago

0.0.13

10 months ago

0.0.12-c

10 months ago

0.0.12-b

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago