shogun-core 3.2.2 → 3.3.0

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.
Files changed (32) hide show
  1. package/README.md +12 -0
  2. package/dist/browser/shogun-core.js +108133 -43791
  3. package/dist/browser/shogun-core.js.map +1 -1
  4. package/dist/ship/examples/messenger-cli.js +173 -60
  5. package/dist/ship/examples/wallet-cli.js +767 -0
  6. package/dist/ship/implementation/SHIP_00.js +478 -0
  7. package/dist/ship/implementation/SHIP_01.js +300 -695
  8. package/dist/ship/implementation/SHIP_02.js +1366 -0
  9. package/dist/ship/implementation/SHIP_03.js +855 -0
  10. package/dist/ship/interfaces/ISHIP_00.js +135 -0
  11. package/dist/ship/interfaces/ISHIP_01.js +81 -24
  12. package/dist/ship/interfaces/ISHIP_02.js +57 -0
  13. package/dist/ship/interfaces/ISHIP_03.js +61 -0
  14. package/dist/src/gundb/db.js +55 -11
  15. package/dist/src/index.js +10 -2
  16. package/dist/src/managers/CoreInitializer.js +41 -13
  17. package/dist/src/storage/storage.js +22 -9
  18. package/dist/types/ship/examples/messenger-cli.d.ts +7 -1
  19. package/dist/types/ship/examples/wallet-cli.d.ts +131 -0
  20. package/dist/types/ship/implementation/SHIP_00.d.ts +113 -0
  21. package/dist/types/ship/implementation/SHIP_01.d.ts +47 -76
  22. package/dist/types/ship/implementation/SHIP_02.d.ts +297 -0
  23. package/dist/types/ship/implementation/SHIP_03.d.ts +127 -0
  24. package/dist/types/ship/interfaces/ISHIP_00.d.ts +410 -0
  25. package/dist/types/ship/interfaces/ISHIP_01.d.ts +157 -119
  26. package/dist/types/ship/interfaces/ISHIP_02.d.ts +470 -0
  27. package/dist/types/ship/interfaces/ISHIP_03.d.ts +295 -0
  28. package/dist/types/src/gundb/db.d.ts +10 -3
  29. package/dist/types/src/index.d.ts +7 -0
  30. package/dist/types/src/interfaces/shogun.d.ts +2 -0
  31. package/dist/types/src/storage/storage.d.ts +2 -1
  32. package/package.json +23 -9
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ /**
3
+ * SHIP-00: Decentralized Identity & Authentication Interface
4
+ *
5
+ * @title ISHIP_00 - Identity Foundation
6
+ * @notice Base interface for decentralized identity in Shogun ecosystem
7
+ *
8
+ * ## Abstract
9
+ *
10
+ * This standard defines the foundational interface for identity that enables:
11
+ * - Username/password authentication with deterministic key generation
12
+ * - SEA key pair management (export, import, backup)
13
+ * - Public key publication and discovery on GunDB
14
+ * - User registry and lookup system
15
+ * - Blockchain address derivation (Ethereum, Bitcoin, etc.)
16
+ *
17
+ * ## Specification
18
+ *
19
+ * Based on:
20
+ * - GunDB for P2P identity storage
21
+ * - SEA (Security, Encryption, Authorization) for key management
22
+ * - Shogun Core DataBase API for authentication
23
+ * - BIP32-like derivation for blockchain addresses
24
+ *
25
+ * ## Usage
26
+ *
27
+ * SHIP-00 serves as the foundation for all other SHIPs:
28
+ * - SHIP-01 (Messaging) depends on SHIP-00 for identity
29
+ * - SHIP-02 (Address Derivation) extends SHIP-00
30
+ * - SHIP-03 (Multi-Modal Auth) extends SHIP-00
31
+ * - SHIP-04 (File Storage) uses SHIP-00 for ACL
32
+ */
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ // ============================================================================
35
+ // IMPLEMENTATION EXAMPLE
36
+ // ============================================================================
37
+ /**
38
+ * Example of how to implement ISHIP_00
39
+ *
40
+ * ```typescript
41
+ * import { ShogunCore } from 'shogun-core';
42
+ * import { ISHIP_00, SEAPair, AuthResult, SignupResult } from './interfaces/ISHIP_00';
43
+ *
44
+ * class IdentityManager implements ISHIP_00 {
45
+ * private shogun: ShogunCore;
46
+ *
47
+ * constructor(config: IdentityConfig) {
48
+ * this.shogun = new ShogunCore({
49
+ * gunOptions: {
50
+ * peers: config.peers,
51
+ * radisk: config.radisk,
52
+ * localStorage: config.localStorage
53
+ * },
54
+ * scope: config.scope
55
+ * });
56
+ * }
57
+ *
58
+ * async signup(username: string, password: string): Promise<SignupResult> {
59
+ * // Use Shogun Core signUp method
60
+ * const result = await this.shogun.signUp(username, password);
61
+ *
62
+ * if (result.success) {
63
+ * // Publish public key
64
+ * await this.publishPublicKey();
65
+ *
66
+ * // Derive Ethereum address
67
+ * const derivedAddress = await this.deriveEthereumAddress(result.userPub);
68
+ *
69
+ * return {
70
+ * success: true,
71
+ * userPub: result.userPub,
72
+ * username: username,
73
+ * derivedAddress: derivedAddress
74
+ * };
75
+ * }
76
+ *
77
+ * return {
78
+ * success: false,
79
+ * error: result.error || 'Signup failed'
80
+ * };
81
+ * }
82
+ *
83
+ * async login(username: string, password: string): Promise<AuthResult> {
84
+ * // Use Shogun Core login method
85
+ * const result = await this.shogun.login(username, password);
86
+ *
87
+ * if (result.success) {
88
+ * const derivedAddress = await this.deriveEthereumAddress(result.userPub);
89
+ *
90
+ * return {
91
+ * success: true,
92
+ * userPub: result.userPub,
93
+ * username: username,
94
+ * derivedAddress: derivedAddress
95
+ * };
96
+ * }
97
+ *
98
+ * return {
99
+ * success: false,
100
+ * error: result.error || 'Login failed'
101
+ * };
102
+ * }
103
+ *
104
+ * exportKeyPair(): SEAPair | null {
105
+ * if (!this.isLoggedIn()) return null;
106
+ *
107
+ * const seaPair = (this.shogun.db.gun.user() as any)?._?.sea;
108
+ * if (!seaPair) return null;
109
+ *
110
+ * return {
111
+ * pub: seaPair.pub,
112
+ * priv: seaPair.priv,
113
+ * epub: seaPair.epub,
114
+ * epriv: seaPair.epriv
115
+ * };
116
+ * }
117
+ *
118
+ * async getUserByAlias(username: string): Promise<UserData | null> {
119
+ * // Use Shogun Core getUserByAlias method
120
+ * return await this.shogun.db.getUserByAlias(username);
121
+ * }
122
+ *
123
+ * async deriveEthereumAddress(publicKey?: string): Promise<string> {
124
+ * // Use shogun-derive package
125
+ * const derived = await derive(seaPair.priv, null, {
126
+ * includeSecp256k1Ethereum: true
127
+ * });
128
+ *
129
+ * return derived.secp256k1Ethereum.address;
130
+ * }
131
+ *
132
+ * // ... implement other methods
133
+ * }
134
+ * ```
135
+ */
@@ -4,19 +4,25 @@
4
4
  *
5
5
  * @title ISHIP_01 - Decentralized Encrypted Messaging
6
6
  * @notice Interface for decentralized encrypted messaging on GunDB
7
+ * @dev This interface depends on ISHIP_00 for identity and authentication
7
8
  *
8
9
  * ## Abstract
9
10
  *
10
11
  * This standard defines an interface for decentralized messaging that allows:
11
- * - Username/password authentication
12
- * - Public key publication on GunDB
13
12
  * - End-to-end encrypted message sending (ECDH)
14
13
  * - Real-time message reception
15
14
  * - Decentralized message history
16
15
  *
16
+ * ## Dependencies
17
+ *
18
+ * - ISHIP_00: Identity and authentication layer
19
+ * - GunDB: P2P storage
20
+ * - SEA: Cryptography (ECDH + AES-GCM)
21
+ *
17
22
  * ## Specification
18
23
  *
19
24
  * Based on:
25
+ * - SHIP-00 for identity management
20
26
  * - GunDB for P2P storage
21
27
  * - SEA (Security, Encryption, Authorization) for cryptography
22
28
  * - ECDH (Elliptic Curve Diffie-Hellman) for key agreement
@@ -26,46 +32,97 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
32
  // IMPLEMENTATION EXAMPLE
27
33
  // ============================================================================
28
34
  /**
29
- * Example of how to implement ISHIP_01
35
+ * Example of how to implement ISHIP_01 with ISHIP_00 dependency
30
36
  *
31
37
  * ```typescript
32
- * class SecureMessagingApp implements ISHIP_01 {
33
- * private shogun: ShogunCore;
38
+ * import { ISHIP_00 } from './ISHIP_00';
39
+ * import { ISHIP_01, DecryptedMessage, SendMessageResult } from './ISHIP_01';
34
40
  *
35
- * constructor(config: MessagingConfig) {
36
- * this.shogun = new ShogunCore(config);
41
+ * class SecureMessagingApp implements ISHIP_01 {
42
+ * constructor(private identity: ISHIP_00) {
43
+ * // Verify identity is authenticated
44
+ * if (!identity.isLoggedIn()) {
45
+ * throw new Error('User must be authenticated');
46
+ * }
37
47
  * }
38
48
  *
39
- * async signup(username: string, password: string): Promise<SignupResult> {
40
- * const result = await this.shogun.signUp(username, password);
41
- * return {
42
- * success: result.success,
43
- * userPub: result.pub,
44
- * derivedAddress: this.pubKeyToAddress(result.pub || "")
45
- * };
49
+ * getIdentity(): ISHIP_00 {
50
+ * return this.identity;
46
51
  * }
47
52
  *
48
53
  * async sendMessage(recipientUsername: string, message: string): Promise<SendMessageResult> {
49
- * // 1. Get recipient's epub
50
- * const recipientKey = await this.getRecipientPublicKey(recipientUsername);
54
+ * // 1. Get recipient's public key from identity provider
55
+ * const recipientKey = await this.identity.getPublicKey(recipientUsername);
56
+ * if (!recipientKey) {
57
+ * return { success: false, error: 'Recipient not found' };
58
+ * }
51
59
  *
52
- * // 2. Encrypt with ECDH
53
- * const encrypted = await this.shogun.db.crypto.encFor(
60
+ * // 2. Get sender's key pair from identity provider
61
+ * const senderPair = this.identity.getKeyPair();
62
+ * if (!senderPair) {
63
+ * return { success: false, error: 'Not authenticated' };
64
+ * }
65
+ *
66
+ * // 3. Encrypt with ECDH
67
+ * const encrypted = await crypto.encFor(
54
68
  * message,
55
- * this.shogun.db.user.is, // sender
56
- * { epub: recipientKey.epub } // receiver
69
+ * senderPair,
70
+ * { epub: recipientKey.epub }
57
71
  * );
58
72
  *
59
- * // 3. Save to GunDB
60
- * await this.shogun.db.user.get('messages/...').put({
73
+ * // 4. Save to GunDB
74
+ * const messageId = generateId();
75
+ * await gun.get('messages').get(messageId).put({
61
76
  * content: encrypted,
62
- * from: this.shogun.db.user.is.pub,
77
+ * from: senderPair.pub,
63
78
  * to: recipientUsername,
64
79
  * timestamp: Date.now().toString()
65
80
  * });
66
81
  *
67
- * return { success: true, messageId: '...' };
82
+ * return { success: true, messageId };
83
+ * }
84
+ *
85
+ * async listenForMessages(onMessage: (message: DecryptedMessage) => void): Promise<void> {
86
+ * const currentUser = this.identity.getCurrentUser();
87
+ * if (!currentUser) {
88
+ * throw new Error('Not authenticated');
89
+ * }
90
+ *
91
+ * gun.get('messages').map().on(async (data, key) => {
92
+ * if (data && data.to === currentUser.alias) {
93
+ * // Decrypt message
94
+ * const senderKey = await this.identity.getPublicKey(data.from);
95
+ * const receiverPair = this.identity.getKeyPair();
96
+ *
97
+ * if (senderKey && receiverPair) {
98
+ * const decrypted = await crypto.decFrom(
99
+ * data.content,
100
+ * { epub: senderKey.epub },
101
+ * receiverPair
102
+ * );
103
+ *
104
+ * onMessage({
105
+ * from: data.from,
106
+ * content: decrypted,
107
+ * timestamp: parseInt(data.timestamp)
108
+ * });
109
+ * }
110
+ * }
111
+ * });
112
+ * }
113
+ *
114
+ * async getMessageHistory(withUsername: string): Promise<MessageHistoryEntry[]> {
115
+ * // Implementation here
116
+ * return [];
68
117
  * }
69
118
  * }
119
+ *
120
+ * // Usage
121
+ * const identity = new SHIP_00(config);
122
+ * await identity.login('alice', 'password123');
123
+ * await identity.publishPublicKey();
124
+ *
125
+ * const messaging = new SecureMessagingApp(identity);
126
+ * await messaging.sendMessage('bob', 'Hello Bob!');
70
127
  * ```
71
128
  */
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * SHIP-02: Ethereum Address Derivation Interface
4
+ *
5
+ * @title ISHIP_02 - Deterministic Address Derivation
6
+ * @notice Interface for deriving Ethereum addresses from SHIP-00 identity
7
+ *
8
+ * ## Abstract
9
+ *
10
+ * This standard extends SHIP-00 to enable:
11
+ * - Deterministic Ethereum address derivation from identity keys
12
+ * - BIP-32/BIP-44 hierarchical deterministic (HD) wallet support
13
+ * - Stealth address generation for enhanced privacy
14
+ * - Multiple address management from single identity
15
+ * - Transaction signing with derived keys
16
+ *
17
+ * ## Specification
18
+ *
19
+ * Based on:
20
+ * - SHIP-00 for identity foundation
21
+ * - BIP-32 for hierarchical deterministic wallets
22
+ * - BIP-44 for multi-account hierarchy
23
+ * - Ethers.js for Ethereum operations
24
+ * - ECDH for stealth address generation
25
+ *
26
+ * ## Dependencies
27
+ *
28
+ * - SHIP-00: Identity and authentication foundation
29
+ * - ethers: Ethereum wallet and signing operations
30
+ *
31
+ * ## Usage
32
+ *
33
+ * SHIP-02 enables wallet functionality on top of SHIP-00 identity:
34
+ * ```typescript
35
+ * const identity = new SHIP_00({ gunOptions: { peers: ['...'] } });
36
+ * await identity.login('alice', 'password123');
37
+ *
38
+ * const addressDerivation = new SHIP_02(identity);
39
+ * await addressDerivation.initialize();
40
+ *
41
+ * const ethAddress = await addressDerivation.deriveEthereumAddress();
42
+ * ```
43
+ */
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.SHIP_02_EventType = void 0;
46
+ /**
47
+ * @notice Event types for SHIP-02 wallet operations
48
+ */
49
+ var SHIP_02_EventType;
50
+ (function (SHIP_02_EventType) {
51
+ SHIP_02_EventType["WALLET_CREATED"] = "walletCreated";
52
+ SHIP_02_EventType["ADDRESS_DERIVED"] = "addressDerived";
53
+ SHIP_02_EventType["TRANSACTION_SIGNED"] = "transactionSigned";
54
+ SHIP_02_EventType["MNEMONIC_GENERATED"] = "mnemonicGenerated";
55
+ SHIP_02_EventType["SYNC_COMPLETED"] = "syncCompleted";
56
+ SHIP_02_EventType["ERROR"] = "error";
57
+ })(SHIP_02_EventType || (exports.SHIP_02_EventType = SHIP_02_EventType = {}));
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * SHIP-03: Dual-Key Stealth Address Interface
4
+ *
5
+ * @title ISHIP_03 - Privacy-Preserving Stealth Addresses
6
+ * @notice Interface for ERC-5564 compatible stealth addresses
7
+ *
8
+ * ## Abstract
9
+ *
10
+ * This standard extends SHIP-00 and SHIP-02 to enable:
11
+ * - Dual-key stealth addresses (viewing + spending keys)
12
+ * - ERC-5564 / Fluidkey compatibility
13
+ * - Enhanced transaction privacy
14
+ * - Stealth address scanning and opening
15
+ * - Deterministic key derivation from SHIP-00 identity
16
+ *
17
+ * ## Specification
18
+ *
19
+ * Based on:
20
+ * - SHIP-00 for identity foundation
21
+ * - SHIP-02 for Ethereum address derivation
22
+ * - ERC-5564 for stealth address standard
23
+ * - Fluidkey Stealth Account Kit
24
+ * - ECDH for shared secret derivation
25
+ *
26
+ * ## Key Concepts
27
+ *
28
+ * **Viewing Key**: Used to scan blockchain for incoming stealth payments
29
+ * **Spending Key**: Used to spend funds received at stealth addresses
30
+ * **Ephemeral Key**: One-time key used by sender to generate stealth address
31
+ *
32
+ * ## Dependencies
33
+ *
34
+ * - SHIP-00: Identity and authentication foundation
35
+ * - SHIP-02: Ethereum wallet operations
36
+ * - @fluidkey/stealth-account-kit: ERC-5564 implementation
37
+ * - ethers: Ethereum operations
38
+ *
39
+ * ## Usage
40
+ *
41
+ * ```typescript
42
+ * const identity = new SHIP_00({ gunOptions: { peers: ['...'] } });
43
+ * await identity.login('alice', 'password123');
44
+ *
45
+ * const eth = new SHIP_02(identity);
46
+ * await eth.initialize();
47
+ *
48
+ * const stealth = new SHIP_03(identity, eth);
49
+ * await stealth.initialize();
50
+ *
51
+ * // Get stealth keys (derived from SHIP-00 identity)
52
+ * const keys = await stealth.getStealthKeys();
53
+ *
54
+ * // Generate stealth address for recipient
55
+ * const stealthAddr = await stealth.generateStealthAddress(
56
+ * recipientViewingKey,
57
+ * recipientSpendingKey
58
+ * );
59
+ * ```
60
+ */
61
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -79,11 +79,16 @@ const CONFIG = {
79
79
  },
80
80
  };
81
81
  class DataBase {
82
- constructor(gun, appScope = "shogun") {
82
+ constructor(gun, appScope = "shogun", options) {
83
83
  this.user = null;
84
84
  this.onAuthCallbacks = [];
85
+ this.disableAutoRecall = false;
86
+ this.silent = false;
85
87
  // Initialize event emitter
86
88
  this.eventEmitter = new eventEmitter_1.EventEmitter();
89
+ // Set options
90
+ this.disableAutoRecall = options?.disableAutoRecall || false;
91
+ this.silent = options?.silent || false;
87
92
  // Validate Gun instance
88
93
  if (!gun) {
89
94
  throw new Error("Gun instance is required but was not provided");
@@ -101,7 +106,18 @@ class DataBase {
101
106
  throw new Error(`Gun instance is invalid: gun.on is not a function. Received gun.on type: ${typeof gun.on}`);
102
107
  }
103
108
  this.gun = gun;
104
- this.user = this.gun.user().recall({ sessionStorage: true });
109
+ // Recall only if NOT disabled and there's a "pair" in sessionStorage
110
+ if (!this.disableAutoRecall &&
111
+ typeof sessionStorage !== "undefined" &&
112
+ sessionStorage.getItem("pair")) {
113
+ this.user = this.gun.user().recall({ sessionStorage: true });
114
+ }
115
+ else {
116
+ if (!this.silent && !this.disableAutoRecall) {
117
+ console.log("No pair found in sessionStorage, using gun.user()");
118
+ }
119
+ this.user = this.gun.user();
120
+ }
105
121
  this.subscribeToAuthEvents();
106
122
  this.crypto = crypto;
107
123
  this.sea = sea_1.default;
@@ -508,7 +524,13 @@ class DataBase {
508
524
  }
509
525
  // Attempt to recall user session
510
526
  try {
511
- const recallResult = userInstance.recall({ sessionStorage: true });
527
+ if (typeof sessionStorage !== "undefined" &&
528
+ sessionStorage.getItem("pair")) {
529
+ const recallResult = userInstance.recall({ sessionStorage: true });
530
+ }
531
+ else {
532
+ const recallResult = userInstance;
533
+ }
512
534
  // console.log("recallResult", recallResult);
513
535
  }
514
536
  catch (recallError) {
@@ -1704,9 +1726,15 @@ class DataBase {
1704
1726
  /**
1705
1727
  * Recall user session
1706
1728
  */
1707
- recall() {
1729
+ recall(options) {
1708
1730
  if (this.user) {
1709
- this.user.recall({ sessionStorage: true });
1731
+ if (typeof sessionStorage !== "undefined" &&
1732
+ sessionStorage.getItem("pair")) {
1733
+ this.user.recall({ sessionStorage: true });
1734
+ }
1735
+ else {
1736
+ this.user;
1737
+ }
1710
1738
  }
1711
1739
  }
1712
1740
  /**
@@ -1754,7 +1782,13 @@ class DataBase {
1754
1782
  */
1755
1783
  saveSession(session) {
1756
1784
  if (this.user) {
1757
- this.user.recall({ sessionStorage: true });
1785
+ if (typeof sessionStorage !== "undefined" &&
1786
+ sessionStorage.getItem("pair")) {
1787
+ this.user.recall({ sessionStorage: true });
1788
+ }
1789
+ else {
1790
+ this.user;
1791
+ }
1758
1792
  }
1759
1793
  }
1760
1794
  /**
@@ -1762,7 +1796,13 @@ class DataBase {
1762
1796
  */
1763
1797
  loadSession() {
1764
1798
  if (this.user) {
1765
- return this.user.recall({ sessionStorage: true });
1799
+ if (typeof sessionStorage !== "undefined" &&
1800
+ sessionStorage.getItem("pair")) {
1801
+ return this.user.recall({ sessionStorage: true });
1802
+ }
1803
+ else {
1804
+ return this.user;
1805
+ }
1766
1806
  }
1767
1807
  return null;
1768
1808
  }
@@ -1799,11 +1839,15 @@ class DataBase {
1799
1839
  exports.DataBase = DataBase;
1800
1840
  // Errors
1801
1841
  DataBase.Errors = GunErrors;
1802
- const createGun = (config) => {
1803
- console.log("Creating Gun instance with config:", config);
1804
- console.log("Config peers:", config?.peers);
1842
+ const createGun = (config, silent) => {
1843
+ if (!silent) {
1844
+ console.log("Creating Gun instance with config:", config);
1845
+ console.log("Config peers:", config?.peers);
1846
+ }
1805
1847
  const gunInstance = (0, gun_1.default)(config);
1806
- console.log("Created Gun instance:", gunInstance);
1848
+ if (!silent) {
1849
+ console.log("Created Gun instance:", gunInstance);
1850
+ }
1807
1851
  return gunInstance;
1808
1852
  };
1809
1853
  exports.createGun = createGun;
package/dist/src/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.autoQuickStart = exports.AutoQuickStart = exports.createSimpleAPI = exports.quickStart = exports.QuickStart = exports.SimpleGunAPI = exports.DataBase = exports.GunErrors = exports.derive = exports.crypto = exports.RxJS = exports.SEA = exports.ShogunCore = exports.Gun = exports.MessengerCLI = exports.SHIP_01 = void 0;
20
+ exports.autoQuickStart = exports.AutoQuickStart = exports.createSimpleAPI = exports.quickStart = exports.QuickStart = exports.SimpleGunAPI = exports.DataBase = exports.GunErrors = exports.derive = exports.crypto = exports.RxJS = exports.SEA = exports.ShogunCore = exports.Gun = exports.WalletCLI = exports.MessengerCLI = exports.SHIP_03 = exports.SHIP_02 = exports.SHIP_01 = exports.SHIP_00 = void 0;
21
21
  const core_1 = require("./core");
22
22
  Object.defineProperty(exports, "ShogunCore", { enumerable: true, get: function () { return core_1.ShogunCore; } });
23
23
  const db_1 = require("./gundb/db");
@@ -42,9 +42,17 @@ __exportStar(require("./utils/errorHandler"), exports);
42
42
  __exportStar(require("./plugins"), exports);
43
43
  __exportStar(require("./interfaces/shogun"), exports);
44
44
  __exportStar(require("./config/simplified-config"), exports);
45
+ var SHIP_00_1 = require("../ship/implementation/SHIP_00");
46
+ Object.defineProperty(exports, "SHIP_00", { enumerable: true, get: function () { return SHIP_00_1.SHIP_00; } });
45
47
  var SHIP_01_1 = require("../ship/implementation/SHIP_01");
46
48
  Object.defineProperty(exports, "SHIP_01", { enumerable: true, get: function () { return SHIP_01_1.SHIP_01; } });
47
- // Export MessengerCLI only in Node.js environment (not browser)
49
+ var SHIP_02_1 = require("../ship/implementation/SHIP_02");
50
+ Object.defineProperty(exports, "SHIP_02", { enumerable: true, get: function () { return SHIP_02_1.SHIP_02; } });
51
+ var SHIP_03_1 = require("../ship/implementation/SHIP_03");
52
+ Object.defineProperty(exports, "SHIP_03", { enumerable: true, get: function () { return SHIP_03_1.SHIP_03; } });
53
+ // Export CLI tools only in Node.js environment (not browser)
48
54
  // This prevents "readline is not a function" errors in browser builds
49
55
  var messenger_cli_1 = require("../ship/examples/messenger-cli");
50
56
  Object.defineProperty(exports, "MessengerCLI", { enumerable: true, get: function () { return messenger_cli_1.MessengerCLI; } });
57
+ var wallet_cli_1 = require("../ship/examples/wallet-cli");
58
+ Object.defineProperty(exports, "WalletCLI", { enumerable: true, get: function () { return wallet_cli_1.WalletCLI; } });
@@ -34,7 +34,7 @@ class CoreInitializer {
34
34
  };
35
35
  }
36
36
  // Initialize storage
37
- this.core.storage = new storage_1.ShogunStorage();
37
+ this.core.storage = new storage_1.ShogunStorage(config.silent);
38
38
  // Setup error handler
39
39
  errorHandler_1.ErrorHandler.addListener((error) => {
40
40
  this.core.emit("error", {
@@ -62,25 +62,35 @@ class CoreInitializer {
62
62
  * Initialize Gun instance
63
63
  */
64
64
  async initializeGun(config) {
65
- console.log("Initialize Gun instance", config);
65
+ if (!config.silent) {
66
+ console.log("Initialize Gun instance", config);
67
+ }
66
68
  try {
67
69
  if (config.gunInstance && config.gunOptions === undefined) {
68
- console.log("Using provided Gun instance");
70
+ if (!config.silent) {
71
+ console.log("Using provided Gun instance");
72
+ }
69
73
  this.core._gun = config.gunInstance;
70
74
  }
71
75
  else if (config.gunOptions && config.gunInstance === undefined) {
72
- console.log("Creating new Gun instance");
73
- this.core._gun = (0, gundb_1.createGun)(config.gunOptions);
76
+ if (!config.silent) {
77
+ console.log("Creating new Gun instance");
78
+ }
79
+ this.core._gun = (0, gundb_1.createGun)(config.gunOptions, config.silent);
74
80
  }
75
81
  else if (config.gunInstance && config.gunOptions) {
76
82
  // Both provided, prefer gunInstance
77
- console.log("Both gunInstance and gunOptions provided, using gunInstance");
83
+ if (!config.silent) {
84
+ console.log("Both gunInstance and gunOptions provided, using gunInstance");
85
+ }
78
86
  this.core._gun = config.gunInstance;
79
87
  }
80
88
  else {
81
89
  // Neither provided, create a default Gun instance for testing
82
- console.log("No Gun instance or options provided, creating default instance");
83
- this.core._gun = (0, gundb_1.createGun)({ peers: config.gunOptions?.peers || [] });
90
+ if (!config.silent) {
91
+ console.log("No Gun instance or options provided, creating default instance");
92
+ }
93
+ this.core._gun = (0, gundb_1.createGun)({ peers: config.gunOptions?.peers || [] }, config.silent);
84
94
  }
85
95
  }
86
96
  catch (error) {
@@ -90,8 +100,10 @@ class CoreInitializer {
90
100
  throw new Error(`Failed to create Gun instance: ${error}`);
91
101
  }
92
102
  try {
93
- console.log("Initialize Gun instance", this.core.gun);
94
- this.core.db = new gundb_1.DataBase(this.core._gun, config.gunOptions?.scope || "");
103
+ if (!config.silent) {
104
+ console.log("Initialize Gun instance", this.core.gun);
105
+ }
106
+ this.core.db = new gundb_1.DataBase(this.core._gun, config.gunOptions?.scope || "", { disableAutoRecall: config.disableAutoRecall, silent: config.silent });
95
107
  // Note: user is a getter that returns _user, so we don't need to assign it
96
108
  }
97
109
  catch (error) {
@@ -106,7 +118,15 @@ class CoreInitializer {
106
118
  */
107
119
  async initializeGunUser() {
108
120
  try {
109
- this.core._user = this.core.gun.user().recall({ sessionStorage: true });
121
+ // Skip recall if disabled in config
122
+ if (!this.core.config.disableAutoRecall &&
123
+ typeof sessionStorage !== "undefined" &&
124
+ sessionStorage.getItem("pair")) {
125
+ this.core._user = this.core.gun.user().recall({ sessionStorage: true });
126
+ }
127
+ else {
128
+ this.core._user = this.core.gun.user();
129
+ }
110
130
  }
111
131
  catch (error) {
112
132
  if (typeof console !== "undefined" && console.error) {
@@ -115,7 +135,15 @@ class CoreInitializer {
115
135
  throw new Error(`Failed to initialize Gun user: ${error}`);
116
136
  }
117
137
  this.core.gun.on("auth", (user) => {
118
- this.core._user = this.core.gun.user().recall({ sessionStorage: true });
138
+ // Skip recall if disabled in config
139
+ if (!this.core.config.disableAutoRecall &&
140
+ typeof sessionStorage !== "undefined" &&
141
+ sessionStorage.getItem("pair")) {
142
+ this.core._user = this.core.gun.user().recall({ sessionStorage: true });
143
+ }
144
+ else {
145
+ this.core._user = this.core.gun.user();
146
+ }
119
147
  this.core.emit("auth:login", {
120
148
  userPub: user.pub,
121
149
  method: "password",
@@ -149,7 +177,7 @@ class CoreInitializer {
149
177
  */
150
178
  setupWalletDerivation() {
151
179
  this.core.gun.on("auth", async (user) => {
152
- if (!user)
180
+ if (!user.is)
153
181
  return;
154
182
  const priv = user._?.sea?.epriv;
155
183
  const pub = user._?.sea?.epub;