Shogun SDK Documentation v1.1.4 - v1.2.9

Shogun Core 📦

npm License TypeScript

Shogun Core is a comprehensive SDK for building decentralized applications (dApps) that simplifies authentication, wallet management, and decentralized data storage. It combines GunDB's peer-to-peer networking with modern authentication standards and blockchain integration to provide a secure, user-friendly foundation for Web3 applications.

  • Core SDK: Main SDK entry point, configuration, and plugin management
  • GunDB Integration: Enhanced wrapper around GunDB with direct authentication and RxJS support
  • WebAuthn Plugin: Passwordless authentication with biometrics and security keys
  • Web3 Plugin: Ethereum wallet integration and blockchain authentication
  • Nostr Plugin: Bitcoin and Nostr protocol integration for decentralized identity
  • Contracts SDK: Tools for interacting with Shogun Protocol smart contracts

For extended functionality, install these separate plugins:

npm install shogun-core
# or
yarn add shogun-core

# Optional external plugins
npm install @shogun/bip44 @shogun/stealth-address
import { ShogunCore } from "shogun-core";

// Initialize Shogun Core
const shogun = new ShogunCore({
peers: ["https://your-gun-peer.com/gun"],
scope: "my-app",

// Enable built-in authentication plugins
webauthn: { enabled: true },
web3: { enabled: true },
nostr: { enabled: true },

// Configure logging
logging: {
enabled: true,
level: "info"
}
});

// Basic authentication
const loginResult = await shogun.login("username", "password");
if (loginResult.success) {
console.log("User logged in:", loginResult.userPub);
}

// Access built-in plugins
const webauthnPlugin = shogun.getPlugin("webauthn");
const web3Plugin = shogun.getPlugin("web3");
const nostrPlugin = shogun.getPlugin("nostr");

// Work with decentralized data
const gundb = shogun.gundb;
await gundb.put("user/profile", { name: "John Doe", status: "online" });
const profile = await gundb.get("user/profile");

// Reactive data with RxJS
shogun.rx.observe("user/profile").subscribe(profile => {
console.log("Profile updated:", profile);
});
// Register external plugins
import { HDWalletPlugin } from "@shogun/bip44";
import { StealthPlugin } from "@shogun/stealth-address";

shogun.register(new HDWalletPlugin());
shogun.register(new StealthPlugin());

const bip44Plugin = shogun.getPlugin("bip44");
const stealthPlugin = shogun.getPlugin("stealth");
// Listen for authentication events
shogun.on("auth:login", (data) => {
console.log("User logged in:", data.userPub);
});

shogun.on("auth:logout", () => {
console.log("User logged out");
});

shogun.on("error", (error) => {
console.error("SDK error:", error);
});

For detailed documentation on each component:

  • Core SDK API - Main SDK initialization, configuration, and authentication
  • GunDB Integration - Decentralized database operations and reactive data

Full API documentation is available at shogun-core-docs.vercel.app.

Shogun Core is ideal for building:

  • Decentralized Social Networks: Chat apps, forums, and social platforms with user-owned data
  • Web3 Wallets: Browser-based cryptocurrency wallets with multiple authentication options
  • Enterprise dApps: Business applications requiring secure, decentralized data storage
  • Gaming Platforms: Real-time multiplayer games with decentralized leaderboards and assets
  • Privacy-Focused Applications: Apps requiring anonymous interactions and stealth features
  • Collaborative Tools: Real-time document editing, project management, and team coordination
  • IoT and Edge Computing: Decentralized device management and data collection

Shogun Core supports all modern browsers with:

  • WebAuthn API support (Chrome 67+, Firefox 60+, Safari 14+)
  • WebCrypto API support
  • IndexedDB support
  • WebSocket support for real-time synchronization

Full Node.js support for server-side applications, testing, and automation.

We welcome contributions! Please follow our contribution guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please follow Conventional Commits for commit messages.

MIT License - see LICENSE file for details.