shogun-core 4.1.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -10
- package/dist/browser/shogun-core.js +590 -49
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/gundb/db.js +64 -48
- package/dist/plugins/index.js +4 -1
- package/dist/plugins/smartwallet/index.js +18 -0
- package/dist/plugins/smartwallet/smartWalletPlugin.js +511 -0
- package/dist/plugins/smartwallet/types.js +2 -0
- package/dist/types/plugins/index.d.ts +2 -0
- package/dist/types/plugins/smartwallet/index.d.ts +2 -0
- package/dist/types/plugins/smartwallet/smartWalletPlugin.d.ts +67 -0
- package/dist/types/plugins/smartwallet/types.d.ts +80 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Shogun Core is a comprehensive SDK for building decentralized applications (dApp
|
|
|
14
14
|
- 🔐 **Multiple Authentication Methods**: Traditional username/password, WebAuthn (biometrics), Web3 (MetaMask), Nostr, and ZK-Proof (anonymous)
|
|
15
15
|
- 🌐 **Decentralized Storage**: Built on GunDB for peer-to-peer data synchronization
|
|
16
16
|
- 🔌 **Plugin System**: Extensible architecture with built-in plugins for various authentication methods
|
|
17
|
+
- 💼 **Smart Wallet (Account Abstraction)**: Custom smart contract wallets with multi-sig, social recovery, and batch transactions
|
|
17
18
|
- 📱 **Reactive Programming**: RxJS integration for real-time data streams
|
|
18
19
|
- 🛡️ **Security**: End-to-end encryption and secure key management
|
|
19
20
|
- 🎯 **TypeScript**: Full TypeScript support with comprehensive type definitions
|
|
@@ -162,6 +163,14 @@ const shogun = new ShogunCore({
|
|
|
162
163
|
enabled: true,
|
|
163
164
|
defaultGroupId: "my-app-users",
|
|
164
165
|
},
|
|
166
|
+
|
|
167
|
+
// Enable Smart Wallet (Account Abstraction)
|
|
168
|
+
smartwallet: {
|
|
169
|
+
enabled: true,
|
|
170
|
+
factoryAddress: "0x...", // Deployed SmartWalletFactory contract address
|
|
171
|
+
defaultRequiredSignatures: 1,
|
|
172
|
+
defaultRequiredGuardians: 2,
|
|
173
|
+
},
|
|
165
174
|
});
|
|
166
175
|
|
|
167
176
|
console.log("Shogun Core initialized!");
|
|
@@ -719,16 +728,19 @@ See `src/examples/zkproof-credentials-example.ts` for complete examples.
|
|
|
719
728
|
|
|
720
729
|
### Comparison of Authentication Methods
|
|
721
730
|
|
|
722
|
-
| Feature | Password | WebAuthn | Web3 | Nostr | ZK-Proof |
|
|
723
|
-
|
|
724
|
-
| **Anonymous** | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
725
|
-
| **Multi-device** | ✅ | ✅ (seed) | ✅ | ✅ | ✅ (trapdoor) |
|
|
726
|
-
| **Hardware-free** | ✅ | ❌ | ❌ | ❌ | ✅ |
|
|
727
|
-
| **Privacy** | ⚠️ | ⚠️ | ⚠️ | ⚠️ | ✅ |
|
|
728
|
-
| **No wallet needed** | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
729
|
-
| **Verifiable credentials** | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
730
|
-
| **Group membership proofs** | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
731
|
-
| **
|
|
731
|
+
| Feature | Password | WebAuthn | Web3 | Nostr | ZK-Proof | Smart Wallet |
|
|
732
|
+
|---------|----------|----------|------|-------|----------|--------------|
|
|
733
|
+
| **Anonymous** | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
|
|
734
|
+
| **Multi-device** | ✅ | ✅ (seed) | ✅ | ✅ | ✅ (trapdoor) | ✅ (seed) |
|
|
735
|
+
| **Hardware-free** | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ |
|
|
736
|
+
| **Privacy** | ⚠️ | ⚠️ | ⚠️ | ⚠️ | ✅ | ⚠️ |
|
|
737
|
+
| **No wallet needed** | ✅ | ✅ | ❌ | ❌ | ✅ | ⚠️ (needs factory) |
|
|
738
|
+
| **Verifiable credentials** | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
|
|
739
|
+
| **Group membership proofs** | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
|
|
740
|
+
| **Multi-sig support** | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
741
|
+
| **Social recovery** | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
742
|
+
| **Account Abstraction** | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
743
|
+
| **Ease of use** | ✅✅✅ | ✅✅ | ✅✅ | ✅✅ | ✅✅ | ✅ |
|
|
732
744
|
|
|
733
745
|
**Quick Setup:**
|
|
734
746
|
```bash
|
|
@@ -744,6 +756,102 @@ yarn zkproof:example
|
|
|
744
756
|
yarn zkproof:credentials
|
|
745
757
|
```
|
|
746
758
|
|
|
759
|
+
### 6. Smart Wallet Plugin API ⭐ **NEW**
|
|
760
|
+
|
|
761
|
+
Account Abstraction with custom smart contract wallets supporting **multi-sig, social recovery, and batch transactions**:
|
|
762
|
+
|
|
763
|
+
```typescript
|
|
764
|
+
const smartWalletPlugin = shogun.getPlugin<SmartWalletPlugin>("smartwallet");
|
|
765
|
+
|
|
766
|
+
// Configure signer (derive EOA from WebAuthn seed phrase)
|
|
767
|
+
const signUpResult = await webauthnPlugin.signUp("alice", {
|
|
768
|
+
generateSeedPhrase: true
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
const wallet = await derive(signUpResult.seedPhrase!, "alice", {
|
|
772
|
+
includeSecp256k1Ethereum: true
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
// Set signer with derived private key
|
|
776
|
+
await smartWalletPlugin.setSigner(wallet.secp256k1Ethereum.privateKey);
|
|
777
|
+
|
|
778
|
+
// Create Smart Wallet with guardians
|
|
779
|
+
const result = await smartWalletPlugin.createWalletWithGuardians(
|
|
780
|
+
wallet.secp256k1Ethereum.address,
|
|
781
|
+
[guardian1, guardian2],
|
|
782
|
+
1, // 1 signature required
|
|
783
|
+
2 // 2 guardians for recovery
|
|
784
|
+
);
|
|
785
|
+
|
|
786
|
+
if (result.success) {
|
|
787
|
+
console.log("Smart Wallet created:", result.walletAddress);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// Execute transactions
|
|
791
|
+
await smartWalletPlugin.executeTransaction(
|
|
792
|
+
result.walletAddress!,
|
|
793
|
+
targetAddress,
|
|
794
|
+
calldata,
|
|
795
|
+
"0"
|
|
796
|
+
);
|
|
797
|
+
|
|
798
|
+
// Social Recovery
|
|
799
|
+
await smartWalletPlugin.initiateRecovery(
|
|
800
|
+
result.walletAddress!,
|
|
801
|
+
newOwnerAddress
|
|
802
|
+
);
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
**Features:**
|
|
806
|
+
- 🔐 **Multi-Signature**: Configure required signatures for transactions
|
|
807
|
+
- 👥 **Social Recovery**: Guardian-based recovery with timelock
|
|
808
|
+
- ⚡ **Batch Transactions**: Save gas with multiple operations
|
|
809
|
+
- 🔑 **Seed Phrase Integration**: Derive EOA from WebAuthn seed phrase
|
|
810
|
+
- 💼 **Account Abstraction**: Smart contract wallets with custom logic
|
|
811
|
+
|
|
812
|
+
**Full Integration Example:**
|
|
813
|
+
|
|
814
|
+
```typescript
|
|
815
|
+
import { ShogunCore } from "shogun-core";
|
|
816
|
+
import { derive } from "shogun-core/gundb/derive";
|
|
817
|
+
|
|
818
|
+
const shogun = new ShogunCore({
|
|
819
|
+
peers: ["https://gun-manhattan.herokuapp.com/gun"],
|
|
820
|
+
scope: "my-app",
|
|
821
|
+
webauthn: { enabled: true },
|
|
822
|
+
smartwallet: {
|
|
823
|
+
enabled: true,
|
|
824
|
+
factoryAddress: "0x..." // Deployed SmartWalletFactory
|
|
825
|
+
},
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
// 1. Register with WebAuthn
|
|
829
|
+
const webauthnPlugin = shogun.getPlugin("webauthn");
|
|
830
|
+
const signUpResult = await webauthnPlugin.signUp("alice", {
|
|
831
|
+
generateSeedPhrase: true
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
// 2. Derive Ethereum wallet from seed phrase
|
|
835
|
+
const wallet = await derive(signUpResult.seedPhrase!, "alice", {
|
|
836
|
+
includeSecp256k1Ethereum: true
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// 3. Setup Smart Wallet
|
|
840
|
+
const smartWalletPlugin = shogun.getPlugin("smartwallet");
|
|
841
|
+
await smartWalletPlugin.setSigner(wallet.secp256k1Ethereum.privateKey);
|
|
842
|
+
|
|
843
|
+
// 4. Create Smart Wallet
|
|
844
|
+
const walletResult = await smartWalletPlugin.createWalletWithGuardians(
|
|
845
|
+
wallet.secp256k1Ethereum.address,
|
|
846
|
+
[guardian1, guardian2],
|
|
847
|
+
1,
|
|
848
|
+
2
|
|
849
|
+
);
|
|
850
|
+
|
|
851
|
+
console.log("EOA:", wallet.secp256k1Ethereum.address);
|
|
852
|
+
console.log("Smart Wallet:", walletResult.walletAddress);
|
|
853
|
+
```
|
|
854
|
+
|
|
747
855
|
## ⭐ Multi-Device Support with Seed Phrases
|
|
748
856
|
|
|
749
857
|
WebAuthn authentication now supports **multi-device access** through BIP39 seed phrases, solving the device-bound limitation of traditional WebAuthn.
|