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.
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:
Full API documentation is available at shogun-core-docs.vercel.app.
Shogun Core is ideal for building:
Shogun Core supports all modern browsers with:
Full Node.js support for server-side applications, testing, and automation.
We welcome contributions! Please follow our contribution guidelines:
git checkout -b feature/amazing-feature
)git commit -m 'feat: add amazing feature'
)git push origin feature/amazing-feature
)Please follow Conventional Commits for commit messages.
MIT License - see LICENSE file for details.