shogun-core 3.3.1 → 3.3.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.
Files changed (147) hide show
  1. package/dist/ship/examples/ephemeral-cli.js +234 -0
  2. package/dist/ship/examples/identity-cli.js +503 -0
  3. package/dist/ship/examples/messenger-cli.js +745 -0
  4. package/dist/ship/examples/stealth-cli.js +433 -0
  5. package/dist/ship/examples/storage-cli.js +615 -0
  6. package/dist/ship/examples/vault-cli.js +444 -0
  7. package/dist/ship/examples/wallet-cli.js +767 -0
  8. package/dist/ship/implementation/SHIP_00.js +478 -0
  9. package/dist/ship/implementation/SHIP_01.js +433 -0
  10. package/dist/ship/implementation/SHIP_02.js +1366 -0
  11. package/dist/ship/implementation/SHIP_03.js +855 -0
  12. package/dist/ship/implementation/SHIP_04.js +589 -0
  13. package/dist/ship/implementation/SHIP_05.js +1064 -0
  14. package/dist/ship/implementation/SHIP_06.js +350 -0
  15. package/dist/ship/implementation/SHIP_07.js +635 -0
  16. package/dist/ship/index.js +17 -0
  17. package/dist/ship/interfaces/ISHIP_00.js +135 -0
  18. package/dist/ship/interfaces/ISHIP_01.js +128 -0
  19. package/dist/ship/interfaces/ISHIP_02.js +57 -0
  20. package/dist/ship/interfaces/ISHIP_03.js +61 -0
  21. package/dist/ship/interfaces/ISHIP_04.js +62 -0
  22. package/dist/ship/interfaces/ISHIP_05.js +59 -0
  23. package/dist/ship/interfaces/ISHIP_06.js +144 -0
  24. package/dist/ship/interfaces/ISHIP_07.js +194 -0
  25. package/dist/types/ship/examples/ephemeral-cli.d.ts +13 -0
  26. package/dist/types/ship/examples/identity-cli.d.ts +40 -0
  27. package/dist/types/ship/examples/messenger-cli.d.ts +37 -0
  28. package/dist/types/ship/examples/stealth-cli.d.ts +31 -0
  29. package/dist/types/ship/examples/storage-cli.d.ts +48 -0
  30. package/dist/types/ship/examples/vault-cli.d.ts +13 -0
  31. package/dist/types/ship/examples/wallet-cli.d.ts +131 -0
  32. package/dist/types/ship/implementation/SHIP_00.d.ts +113 -0
  33. package/dist/types/ship/implementation/SHIP_01.d.ts +80 -0
  34. package/dist/types/ship/implementation/SHIP_02.d.ts +297 -0
  35. package/dist/types/ship/implementation/SHIP_03.d.ts +127 -0
  36. package/dist/types/ship/implementation/SHIP_04.d.ts +76 -0
  37. package/dist/types/ship/implementation/SHIP_05.d.ts +70 -0
  38. package/dist/types/ship/implementation/SHIP_06.d.ts +66 -0
  39. package/dist/types/ship/implementation/SHIP_07.d.ts +101 -0
  40. package/dist/types/ship/index.d.ts +14 -0
  41. package/dist/types/ship/interfaces/ISHIP_00.d.ts +410 -0
  42. package/dist/types/ship/interfaces/ISHIP_01.d.ts +343 -0
  43. package/dist/types/ship/interfaces/ISHIP_02.d.ts +470 -0
  44. package/dist/types/ship/interfaces/ISHIP_03.d.ts +295 -0
  45. package/dist/types/ship/interfaces/ISHIP_04.d.ts +245 -0
  46. package/dist/types/ship/interfaces/ISHIP_05.d.ts +234 -0
  47. package/dist/types/ship/interfaces/ISHIP_06.d.ts +370 -0
  48. package/dist/types/ship/interfaces/ISHIP_07.d.ts +522 -0
  49. package/package.json +1 -1
  50. /package/dist/{config → src/config}/simplified-config.js +0 -0
  51. /package/dist/{core.js → src/core.js} +0 -0
  52. /package/dist/{examples → src/examples}/api-test.js +0 -0
  53. /package/dist/{examples → src/examples}/simple-api-test.js +0 -0
  54. /package/dist/{gundb → src/gundb}/api.js +0 -0
  55. /package/dist/{gundb → src/gundb}/crypto.js +0 -0
  56. /package/dist/{gundb → src/gundb}/db.js +0 -0
  57. /package/dist/{gundb → src/gundb}/derive.js +0 -0
  58. /package/dist/{gundb → src/gundb}/errors.js +0 -0
  59. /package/dist/{gundb → src/gundb}/index.js +0 -0
  60. /package/dist/{gundb → src/gundb}/rxjs.js +0 -0
  61. /package/dist/{gundb → src/gundb}/types.js +0 -0
  62. /package/dist/{index.js → src/index.js} +0 -0
  63. /package/dist/{interfaces → src/interfaces}/common.js +0 -0
  64. /package/dist/{interfaces → src/interfaces}/events.js +0 -0
  65. /package/dist/{interfaces → src/interfaces}/plugin.js +0 -0
  66. /package/dist/{interfaces → src/interfaces}/shogun.js +0 -0
  67. /package/dist/{managers → src/managers}/AuthManager.js +0 -0
  68. /package/dist/{managers → src/managers}/CoreInitializer.js +0 -0
  69. /package/dist/{managers → src/managers}/EventManager.js +0 -0
  70. /package/dist/{managers → src/managers}/PluginManager.js +0 -0
  71. /package/dist/{migration-test.js → src/migration-test.js} +0 -0
  72. /package/dist/{plugins → src/plugins}/base.js +0 -0
  73. /package/dist/{plugins → src/plugins}/index.js +0 -0
  74. /package/dist/{plugins → src/plugins}/nostr/index.js +0 -0
  75. /package/dist/{plugins → src/plugins}/nostr/nostrConnector.js +0 -0
  76. /package/dist/{plugins → src/plugins}/nostr/nostrConnectorPlugin.js +0 -0
  77. /package/dist/{plugins → src/plugins}/nostr/nostrSigner.js +0 -0
  78. /package/dist/{plugins → src/plugins}/nostr/types.js +0 -0
  79. /package/dist/{plugins → src/plugins}/oauth/index.js +0 -0
  80. /package/dist/{plugins → src/plugins}/oauth/oauthConnector.js +0 -0
  81. /package/dist/{plugins → src/plugins}/oauth/oauthPlugin.js +0 -0
  82. /package/dist/{plugins → src/plugins}/oauth/types.js +0 -0
  83. /package/dist/{plugins → src/plugins}/web3/index.js +0 -0
  84. /package/dist/{plugins → src/plugins}/web3/types.js +0 -0
  85. /package/dist/{plugins → src/plugins}/web3/web3Connector.js +0 -0
  86. /package/dist/{plugins → src/plugins}/web3/web3ConnectorPlugin.js +0 -0
  87. /package/dist/{plugins → src/plugins}/web3/web3Signer.js +0 -0
  88. /package/dist/{plugins → src/plugins}/webauthn/index.js +0 -0
  89. /package/dist/{plugins → src/plugins}/webauthn/types.js +0 -0
  90. /package/dist/{plugins → src/plugins}/webauthn/webauthn.js +0 -0
  91. /package/dist/{plugins → src/plugins}/webauthn/webauthnPlugin.js +0 -0
  92. /package/dist/{plugins → src/plugins}/webauthn/webauthnSigner.js +0 -0
  93. /package/dist/{storage → src/storage}/storage.js +0 -0
  94. /package/dist/{types → src/types}/events.js +0 -0
  95. /package/dist/{types → src/types}/shogun.js +0 -0
  96. /package/dist/{utils → src/utils}/errorHandler.js +0 -0
  97. /package/dist/{utils → src/utils}/eventEmitter.js +0 -0
  98. /package/dist/{utils → src/utils}/validation.js +0 -0
  99. /package/dist/types/{config → src/config}/simplified-config.d.ts +0 -0
  100. /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
  101. /package/dist/types/{examples → src/examples}/api-test.d.ts +0 -0
  102. /package/dist/types/{examples → src/examples}/simple-api-test.d.ts +0 -0
  103. /package/dist/types/{gundb → src/gundb}/api.d.ts +0 -0
  104. /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
  105. /package/dist/types/{gundb → src/gundb}/db.d.ts +0 -0
  106. /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
  107. /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
  108. /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
  109. /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
  110. /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
  111. /package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
  112. /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
  113. /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
  114. /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
  115. /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
  116. /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
  117. /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
  118. /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
  119. /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
  120. /package/dist/types/{migration-test.d.ts → src/migration-test.d.ts} +0 -0
  121. /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
  122. /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
  123. /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
  124. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
  125. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
  126. /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
  127. /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
  128. /package/dist/types/{plugins → src/plugins}/oauth/index.d.ts +0 -0
  129. /package/dist/types/{plugins → src/plugins}/oauth/oauthConnector.d.ts +0 -0
  130. /package/dist/types/{plugins → src/plugins}/oauth/oauthPlugin.d.ts +0 -0
  131. /package/dist/types/{plugins → src/plugins}/oauth/types.d.ts +0 -0
  132. /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
  133. /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
  134. /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
  135. /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
  136. /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
  137. /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
  138. /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
  139. /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
  140. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
  141. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
  142. /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
  143. /package/dist/types/{types → src/types}/events.d.ts +0 -0
  144. /package/dist/types/{types → src/types}/shogun.d.ts +0 -0
  145. /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
  146. /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
  147. /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
@@ -0,0 +1,297 @@
1
+ /**
2
+ * SHIP-02: Ethereum HD Wallet Implementation
3
+ *
4
+ * Full port of shogun-BIP44 with SHIP-00 derivation.
5
+ * Extends SHIP-00 to provide deterministic Ethereum address derivation.
6
+ *
7
+ * Based on:
8
+ * - SHIP-00 for identity foundation (replaces mnemonic dependency)
9
+ * - BIP-32 for hierarchical deterministic wallets
10
+ * - BIP-44 for multi-account hierarchy
11
+ * - Ethers.js for Ethereum operations
12
+ * - Gun/SEA for encrypted storage
13
+ *
14
+ * Features:
15
+ * ✅ Deterministic address derivation from SHIP-00 identity (no mnemonics needed)
16
+ * ✅ BIP-44 compliant HD wallet support
17
+ * ✅ Multiple address management
18
+ * ✅ Transaction signing
19
+ * ✅ Message signing and verification
20
+ * ✅ Gun persistence with encryption
21
+ * ✅ Export/import functionality
22
+ * ✅ Address book management
23
+ *
24
+ * Note: Stealth addresses moved to SHIP-03
25
+ */
26
+ import type { ISHIP_00 } from "../interfaces/ISHIP_00";
27
+ import type { ISHIP_02, DerivationResult, StealthAddressResult, SignatureResult, Transaction, AddressEntry, AddressBook, SHIP_02_Config, WalletInfo } from "../interfaces/ISHIP_02";
28
+ import { ethers } from "ethers";
29
+ /**
30
+ * SHIP-02 Reference Implementation
31
+ *
32
+ * Provides Ethereum address derivation on top of SHIP-00 identity.
33
+ * All addresses are deterministically derived from the user's SHIP-00 keypair.
34
+ */
35
+ declare class SHIP_02 implements ISHIP_02 {
36
+ private identity;
37
+ private config;
38
+ private initialized;
39
+ static readonly NODES: {
40
+ readonly ADDRESS_BOOK: "addressbook";
41
+ readonly MNEMONIC: "mnemonic";
42
+ readonly WALLET_PATHS: "wallet_paths";
43
+ };
44
+ private masterSeed;
45
+ private mnemonic;
46
+ private hdWallet;
47
+ private addressCache;
48
+ private walletCache;
49
+ private nextIndex;
50
+ private persistToGun;
51
+ private provider;
52
+ private mainWallet;
53
+ private walletPaths;
54
+ constructor(identity: ISHIP_00, config?: SHIP_02_Config);
55
+ initialize(useMnemonic?: boolean): Promise<void>;
56
+ isInitialized(): boolean;
57
+ deriveEthereumAddress(path?: string): Promise<DerivationResult>;
58
+ deriveMultipleAddresses(count: number, startIndex?: number): Promise<DerivationResult[]>;
59
+ getPrimaryAddress(): Promise<string>;
60
+ deriveBIP44Address(coinType?: number, account?: number, change?: number, index?: number): Promise<DerivationResult>;
61
+ deriveMultipleAccounts(accountCount: number): Promise<DerivationResult[]>;
62
+ /**
63
+ * @deprecated Use SHIP-03 for dual-key stealth addresses
64
+ */
65
+ generateStealthAddress(recipientPublicKey?: string): Promise<StealthAddressResult>;
66
+ /**
67
+ * @deprecated Use SHIP-03 for stealth operations
68
+ */
69
+ deriveSharedSecret(publicKey: string): Promise<string>;
70
+ /**
71
+ * @deprecated Use SHIP-03 for stealth operations
72
+ */
73
+ isStealthAddress(address: string): Promise<boolean>;
74
+ getPrivateKeyForAddress(address: string): Promise<string>;
75
+ getPublicKeyForAddress(address: string): Promise<string>;
76
+ getPathForAddress(address: string): Promise<string | undefined>;
77
+ signTransaction(tx: Transaction, address: string): Promise<SignatureResult>;
78
+ /**
79
+ * Send transaction to Ethereum network
80
+ * Combines signing + broadcasting in one step
81
+ */
82
+ sendTransaction(tx: Transaction, address: string, waitForConfirmation?: boolean): Promise<{
83
+ success: boolean;
84
+ txHash?: string;
85
+ receipt?: ethers.TransactionReceipt;
86
+ error?: string;
87
+ }>;
88
+ signMessage(message: string | Uint8Array, address: string): Promise<string>;
89
+ verifySignature(message: string | Uint8Array, signature: string, address: string): Promise<boolean>;
90
+ getAllAddresses(): Promise<AddressEntry[]>;
91
+ getAddressByIndex(index: number): Promise<AddressEntry | undefined>;
92
+ setAddressLabel(address: string, label: string): Promise<void>;
93
+ exportAddressBook(): Promise<AddressBook>;
94
+ importAddressBook(addressBook: AddressBook): Promise<void>;
95
+ /**
96
+ * Enable persistence to Gun database
97
+ */
98
+ enableGunPersistence(): void;
99
+ /**
100
+ * Disable persistence to Gun database
101
+ */
102
+ disableGunPersistence(): void;
103
+ /**
104
+ * Save address book to Gun (private storage)
105
+ */
106
+ private saveAddressBookToGun;
107
+ /**
108
+ * Load address book from Gun
109
+ */
110
+ loadAddressBookFromGun(): Promise<AddressBook | null>;
111
+ /**
112
+ * Sync local cache with Gun storage
113
+ */
114
+ syncWithGun(): Promise<void>;
115
+ ownsAddress(address: string): Promise<boolean>;
116
+ getMasterPublicKey(): Promise<string>;
117
+ clearCache(): Promise<void>;
118
+ /**
119
+ * Generate new BIP-39 mnemonic (12 words)
120
+ * Compatible with MetaMask and other wallets
121
+ */
122
+ generateNewMnemonic(): string;
123
+ /**
124
+ * Get addresses that would be derived from a mnemonic (standard BIP-44)
125
+ * Useful to verify compatibility with MetaMask
126
+ */
127
+ getStandardBIP44Addresses(mnemonic: string, count?: number): string[];
128
+ /**
129
+ * Get current mnemonic (if using mnemonic mode)
130
+ */
131
+ getMnemonic(): Promise<string | null>;
132
+ /**
133
+ * Get user's master mnemonic from Gun or localStorage
134
+ * Used by createWallet/loadWallets for frontend compatibility
135
+ */
136
+ getUserMasterMnemonic(): Promise<string | null>;
137
+ /**
138
+ * Export mnemonic (encrypted)
139
+ */
140
+ exportMnemonic(): Promise<string | null>;
141
+ /**
142
+ * Import mnemonic and re-initialize wallet
143
+ */
144
+ importMnemonic(encryptedMnemonic: string): Promise<void>;
145
+ /**
146
+ * Save mnemonic to Gun (encrypted)
147
+ */
148
+ private saveMnemonicToGun;
149
+ /**
150
+ * Load mnemonic from Gun (encrypted)
151
+ */
152
+ private loadMnemonicFromGun;
153
+ /**
154
+ * Get storage identifier for current user
155
+ */
156
+ getStorageUserIdentifier(): string;
157
+ /**
158
+ * Encrypt sensitive data using SEA
159
+ */
160
+ encryptSensitiveData(text: string): Promise<string>;
161
+ /**
162
+ * Decrypt sensitive data using SEA
163
+ */
164
+ decryptSensitiveData(encryptedText: string): Promise<string | null>;
165
+ /**
166
+ * Export master seed (encrypted)
167
+ * SECURITY: Handle with extreme care!
168
+ */
169
+ exportMasterSeed(): Promise<string>;
170
+ /**
171
+ * Export all wallet data (encrypted)
172
+ */
173
+ exportWalletData(): Promise<string>;
174
+ /**
175
+ * Import wallet data (encrypted)
176
+ */
177
+ importWalletData(encryptedData: string): Promise<void>;
178
+ /**
179
+ * Ensure system is initialized
180
+ */
181
+ private ensureInitialized;
182
+ /**
183
+ * Derive master seed from SHIP-00 keypair
184
+ */
185
+ private deriveMasterSeed;
186
+ /**
187
+ * Build BIP-44 derivation path
188
+ */
189
+ private buildBIP44Path;
190
+ /**
191
+ * Set RPC provider URL
192
+ */
193
+ setRpcUrl(rpcUrl: string): Promise<void>;
194
+ /**
195
+ * Get current RPC provider
196
+ */
197
+ getProvider(): ethers.JsonRpcProvider | null;
198
+ /**
199
+ * Get signer (main wallet connected to provider)
200
+ */
201
+ getSigner(): ethers.Wallet;
202
+ /**
203
+ * Set custom signer
204
+ */
205
+ setSigner(signer: ethers.Wallet): Promise<void>;
206
+ /**
207
+ * Get main wallet (derived from Gun user keys, not BIP-44)
208
+ * This provides a consistent "main" wallet independent of HD derivation
209
+ */
210
+ getMainWallet(): ethers.Wallet;
211
+ /**
212
+ * Get main wallet credentials
213
+ */
214
+ getMainWalletCredentials(): {
215
+ address: string;
216
+ priv: string;
217
+ };
218
+ /**
219
+ * Create new wallet with auto-incremented index
220
+ * Frontend-friendly API that returns ready-to-use wallet object
221
+ */
222
+ createWallet(): Promise<WalletInfo>;
223
+ /**
224
+ * Load all wallets from stored paths
225
+ * Reconstructs wallet objects from mnemonic/seed and paths
226
+ */
227
+ loadWallets(): Promise<WalletInfo[]>;
228
+ /**
229
+ * Export wallet keys for all derived addresses
230
+ */
231
+ exportWalletKeys(): Promise<string>;
232
+ /**
233
+ * Export Gun SEA keypair
234
+ */
235
+ exportGunPair(): Promise<string>;
236
+ /**
237
+ * Export all user data (mnemonic, wallets, Gun pair)
238
+ */
239
+ exportAllUserData(): Promise<string>;
240
+ /**
241
+ * Import wallet keys and restore wallets
242
+ */
243
+ importWalletKeys(walletsData: string): Promise<number>;
244
+ /**
245
+ * Import Gun SEA keypair
246
+ * Note: This is a placeholder for compatibility
247
+ * SHIP-02 doesn't manage Gun keys directly (use SHIP-00 for that)
248
+ */
249
+ importGunPair(pairData: string): Promise<boolean>;
250
+ /**
251
+ * Import all user data from backup
252
+ */
253
+ importAllUserData(backupData: string, options?: {
254
+ importMnemonic?: boolean;
255
+ importWallets?: boolean;
256
+ importGunPair?: boolean;
257
+ }): Promise<{
258
+ success: boolean;
259
+ mnemonicImported?: boolean;
260
+ walletsImported?: number;
261
+ gunPairImported?: boolean;
262
+ }>;
263
+ /**
264
+ * Initialize wallet paths from Gun storage
265
+ */
266
+ initializeWalletPaths(): Promise<void>;
267
+ /**
268
+ * Save wallet paths to localStorage
269
+ */
270
+ saveWalletPathsToLocalStorage(): Promise<void>;
271
+ /**
272
+ * Load wallet paths from localStorage
273
+ */
274
+ loadWalletPathsFromLocalStorage(): Promise<void>;
275
+ /**
276
+ * Save wallet paths to Gun
277
+ */
278
+ private saveWalletPathsToGun;
279
+ /**
280
+ * Load wallet paths from Gun
281
+ */
282
+ private loadWalletPathsFromGun;
283
+ /**
284
+ * Generate deterministic private key from string seed
285
+ * Uses same algorithm as shogun-BIP44 for compatibility
286
+ */
287
+ private generatePrivateKeyFromString;
288
+ /**
289
+ * Initialize wallet paths and test encryption system
290
+ */
291
+ initializeWalletPathsAndTestEncryption(): Promise<void>;
292
+ /**
293
+ * Cleanup resources
294
+ */
295
+ cleanup(): Promise<void>;
296
+ }
297
+ export { SHIP_02 };
@@ -0,0 +1,127 @@
1
+ /**
2
+ * SHIP-03: Dual-Key Stealth Address Implementation
3
+ *
4
+ * Full port of shogun-stealth-address with Fluidkey integration.
5
+ * Extends SHIP-00 and SHIP-02 to provide ERC-5564 compatible stealth addresses.
6
+ *
7
+ * Based on:
8
+ * - SHIP-00 for identity foundation
9
+ * - SHIP-02 for Ethereum operations
10
+ * - ERC-5564 for stealth address standard
11
+ * - Fluidkey Stealth Account Kit
12
+ * - @scure/bip32 for HD key derivation
13
+ *
14
+ * Features:
15
+ * ✅ Dual-key stealth (viewing + spending keys)
16
+ * ✅ ERC-5564 / Fluidkey compatible
17
+ * ✅ Deterministic derivation from SHIP-00
18
+ * ✅ View tag optimization for scanning
19
+ * ✅ Announcement metadata
20
+ * ✅ Batch generation
21
+ * ✅ Fluidkey generateStealthAddresses
22
+ * ✅ Fluidkey generateStealthPrivateKey
23
+ */
24
+ import type { ISHIP_00 } from "../interfaces/ISHIP_00";
25
+ import type { ISHIP_02 } from "../interfaces/ISHIP_02";
26
+ import type { ISHIP_03, StealthKeys, EphemeralKeyPair, StealthAddressResult, StealthMetadata, AnnouncedStealth, OwnedStealthAddress, SHIP_03_Config } from "../interfaces/ISHIP_03";
27
+ /**
28
+ * SHIP-03 Reference Implementation
29
+ *
30
+ * Full Fluidkey-compatible stealth address system derived from SHIP-00.
31
+ * All keys are deterministically derived from the user's SHIP-00 identity.
32
+ */
33
+ declare class SHIP_03 implements ISHIP_03 {
34
+ private identity;
35
+ private eth;
36
+ private config;
37
+ private initialized;
38
+ static readonly NODES: {
39
+ readonly STEALTH_KEYS_PUBLIC: "stealth_keys_public";
40
+ readonly STEALTH_ANNOUNCEMENTS: "stealth_announcements";
41
+ };
42
+ private viewingKey;
43
+ private spendingKey;
44
+ private ownedStealthAddresses;
45
+ private announcementCache;
46
+ constructor(identity: ISHIP_00, eth: ISHIP_02, config?: SHIP_03_Config);
47
+ initialize(): Promise<void>;
48
+ isInitialized(): boolean;
49
+ getStealthKeys(): Promise<StealthKeys>;
50
+ /**
51
+ * Get public stealth keys by username (alias)
52
+ * Resolves username → Gun pub → stealth keys
53
+ */
54
+ getPublicStealthKeysByUsername(username: string): Promise<{
55
+ viewingPublicKey: string;
56
+ spendingPublicKey: string;
57
+ } | null>;
58
+ /**
59
+ * Get public stealth keys by Gun public key
60
+ */
61
+ getPublicStealthKeys(userPub: string): Promise<{
62
+ viewingPublicKey: string;
63
+ spendingPublicKey: string;
64
+ } | null>;
65
+ /**
66
+ * Search stealth keys in directory (all published keys)
67
+ * Returns list of users who have published stealth keys
68
+ */
69
+ searchStealthDirectory(): Promise<Array<{
70
+ username?: string;
71
+ gunPub: string;
72
+ viewingPublicKey: string;
73
+ spendingPublicKey: string;
74
+ timestamp?: number;
75
+ }>>;
76
+ exportStealthKeys(): Promise<string>;
77
+ importStealthKeys(encryptedKeys: string): Promise<void>;
78
+ generateEphemeralKeyPair(): Promise<EphemeralKeyPair>;
79
+ generateStealthAddress(recipientViewingKey: string, recipientSpendingKey: string, ephemeralPrivateKey?: string): Promise<StealthAddressResult>;
80
+ generateMultipleStealthAddresses(recipients: Array<{
81
+ viewingKey: string;
82
+ spendingKey: string;
83
+ }>, ephemeralPrivateKey?: string): Promise<StealthAddressResult[]>;
84
+ openStealthAddress(stealthAddress: string, ephemeralPublicKey: string): Promise<any>;
85
+ isStealthAddressMine(stealthAddress: string, ephemeralPublicKey: string): Promise<boolean>;
86
+ getStealthPrivateKey(stealthAddress: string, ephemeralPublicKey: string): Promise<string>;
87
+ scanStealthAddresses(announcements: AnnouncedStealth[]): Promise<OwnedStealthAddress[]>;
88
+ quickScanWithViewTags(announcements: AnnouncedStealth[]): Promise<AnnouncedStealth[]>;
89
+ createAnnouncementMetadata(stealthAddress: string, ephemeralPublicKey: string): StealthMetadata;
90
+ parseAnnouncement(txData: any): Promise<AnnouncedStealth | null>;
91
+ getAllOwnedStealthAddresses(): Promise<OwnedStealthAddress[]>;
92
+ clearCache(): Promise<void>;
93
+ verifyStealthAddress(stealthAddress: string, ephemeralPublicKey: string, spendingPublicKey: string): Promise<boolean>;
94
+ /**
95
+ * Ensure system is initialized
96
+ */
97
+ private ensureInitialized;
98
+ /**
99
+ * Derive stealth keys deterministically from SHIP-00 identity
100
+ *
101
+ * Uses simple deterministic derivation instead of Fluidkey's generateKeysFromSignature
102
+ * because it requires specific EIP-712 signature format.
103
+ *
104
+ * We use Fluidkey only for:
105
+ * - generateStealthAddresses (address generation)
106
+ * - generateStealthPrivateKey (opening addresses)
107
+ */
108
+ private deriveStealthKeysFromIdentity;
109
+ /**
110
+ * Publish public stealth keys to Gun for others to use (PUBLIC METHOD)
111
+ */
112
+ publishStealthKeys(): Promise<void>;
113
+ /**
114
+ * Compute view tag for quick scanning
115
+ */
116
+ private computeViewTag;
117
+ /**
118
+ * Fallback method to open stealth address (manual ECDH computation)
119
+ * Used when Fluidkey is not available or fails
120
+ */
121
+ private openStealthAddressFallback;
122
+ /**
123
+ * Add two private keys using modular arithmetic (secp256k1)
124
+ */
125
+ private addPrivateKeys;
126
+ }
127
+ export { SHIP_03 };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * SHIP-04: Multi-Modal Authentication Implementation
3
+ *
4
+ * Extends SHIP-00 to provide alternative authentication methods.
5
+ * Integrates existing Shogun Core plugins for OAuth, WebAuthn, Nostr, and Web3.
6
+ *
7
+ * Based on:
8
+ * - SHIP-00 for identity foundation
9
+ * - Shogun Core Plugins (OAuth, WebAuthn, Nostr, Web3)
10
+ * - External OAuth providers (Google, GitHub, etc.)
11
+ * - WebAuthn API for biometric auth
12
+ * - Nostr protocol for decentralized social
13
+ * - Web3 providers (MetaMask, WalletConnect)
14
+ *
15
+ * Features:
16
+ * ✅ OAuth authentication (Google, GitHub, Discord, etc.)
17
+ * ✅ WebAuthn/Passkeys (biometric, hardware keys)
18
+ * ✅ Nostr protocol integration
19
+ * ✅ Web3 wallet connection (MetaMask, etc.)
20
+ * ✅ SHIP-00 compatible (all methods return SEA keypair)
21
+ * ✅ Plugin-based architecture (modular)
22
+ *
23
+ * Inclusive Hierarchy:
24
+ * SHIP-04 → depends on → SHIP-00 ✅
25
+ */
26
+ import type { ISHIP_00 } from "../interfaces/ISHIP_00";
27
+ import type { ISHIP_04, OAuthProvider, OAuthAuthResult, WebAuthnAuthResult, NostrAuthResult, Web3AuthResult, AuthMethodInfo, SHIP_04_Config } from "../interfaces/ISHIP_04";
28
+ import { AuthMethod } from "../interfaces/ISHIP_04";
29
+ /**
30
+ * SHIP-04 Reference Implementation
31
+ *
32
+ * Provides multiple authentication methods on top of SHIP-00.
33
+ * All authentication methods are converted to SHIP-00 compatible format.
34
+ */
35
+ declare class SHIP_04 implements ISHIP_04 {
36
+ private identity;
37
+ private config;
38
+ private initialized;
39
+ static readonly NODES: {
40
+ readonly AUTH_METHOD: "current_auth_method";
41
+ };
42
+ private oauthPlugin;
43
+ private webauthnPlugin;
44
+ private nostrPlugin;
45
+ private web3Plugin;
46
+ private currentAuthMethod;
47
+ constructor(identity: ISHIP_00, config?: SHIP_04_Config);
48
+ initialize(): Promise<void>;
49
+ isInitialized(): boolean;
50
+ getIdentity(): ISHIP_00;
51
+ loginWithOAuth(provider: OAuthProvider, redirectUri?: string): Promise<OAuthAuthResult>;
52
+ handleOAuthCallback(code: string, provider: OAuthProvider): Promise<OAuthAuthResult>;
53
+ isOAuthAvailable(provider?: OAuthProvider): boolean;
54
+ registerWithWebAuthn(username: string): Promise<WebAuthnAuthResult>;
55
+ loginWithWebAuthn(username: string): Promise<WebAuthnAuthResult>;
56
+ isWebAuthnAvailable(): boolean;
57
+ connectNostr(): Promise<NostrAuthResult>;
58
+ loginWithNostr(): Promise<NostrAuthResult>;
59
+ isNostrAvailable(): boolean;
60
+ connectWeb3(): Promise<Web3AuthResult>;
61
+ loginWithWeb3(message?: string): Promise<Web3AuthResult>;
62
+ isWeb3Available(): boolean;
63
+ getAvailableAuthMethods(): AuthMethodInfo[];
64
+ getCurrentAuthMethod(): AuthMethod | null;
65
+ clearAuth(): Promise<void>;
66
+ /**
67
+ * Save current auth method to Gun (optional persistence)
68
+ */
69
+ private saveAuthMethod;
70
+ /**
71
+ * Load last used auth method from Gun
72
+ */
73
+ loadAuthMethod(): Promise<AuthMethod | null>;
74
+ private ensureInitialized;
75
+ }
76
+ export { SHIP_04 };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * SHIP-05: Decentralized File Storage Implementation
3
+ *
4
+ * Simple encrypted file storage on IPFS.
5
+ * Extends SHIP-00 to provide encrypted file storage capabilities.
6
+ *
7
+ * Based on:
8
+ * - SHIP-00 for identity foundation
9
+ * - IPFS for decentralized file storage
10
+ * - shogun-ipfs for IPFS operations
11
+ * - Deterministic encryption from wallet signatures
12
+ *
13
+ * Features:
14
+ * ✅ Encrypted file upload with wallet signature
15
+ * ✅ Deterministic encryption keys from wallet
16
+ * ✅ IPFS storage (Pinata, IPFS node, or custom)
17
+ * ✅ File metadata on GunDB
18
+ * ✅ File download and decryption
19
+ */
20
+ import type { ISHIP_00 } from "../interfaces/ISHIP_00";
21
+ import type { ISHIP_05, UploadResult, FileMetadata, UploadOptions, DownloadOptions, EncryptionOptions, SHIP_05_Config } from "../interfaces/ISHIP_05";
22
+ /**
23
+ * SHIP-05 Reference Implementation
24
+ *
25
+ * Provides encrypted file storage on IPFS.
26
+ * All encryption is deterministic based on wallet signatures.
27
+ */
28
+ declare class SHIP_05 implements ISHIP_05 {
29
+ private identity;
30
+ private config;
31
+ private initialized;
32
+ static readonly NODES: {
33
+ readonly USER_FILES: "user_files";
34
+ };
35
+ private ipfsStorage;
36
+ private fileCache;
37
+ constructor(identity: ISHIP_00, config?: SHIP_05_Config);
38
+ initialize(options?: SHIP_05_Config): Promise<void>;
39
+ isInitialized(): boolean;
40
+ getIdentity(): ISHIP_00;
41
+ uploadFile(file: File | Buffer, options?: UploadOptions): Promise<UploadResult>;
42
+ uploadJson(data: any, options?: UploadOptions): Promise<UploadResult>;
43
+ downloadFile(hash: string, options?: DownloadOptions): Promise<string | Blob>;
44
+ getFileMetadata(hash: string): Promise<FileMetadata | null>;
45
+ deleteFile(hash: string): Promise<{
46
+ success: boolean;
47
+ error?: string;
48
+ }>;
49
+ getUserFiles(): Promise<FileMetadata[]>;
50
+ encryptData(data: string | Buffer, options?: EncryptionOptions): Promise<string>;
51
+ decryptData(encryptedData: string, options?: EncryptionOptions): Promise<string>;
52
+ isFileAccessible(hash: string): Promise<boolean>;
53
+ getStorageStats(): Promise<{
54
+ totalFiles: number;
55
+ totalMB: number;
56
+ encryptedFiles: number;
57
+ plainFiles: number;
58
+ }>;
59
+ private ensureInitialized;
60
+ private initializeIPFS;
61
+ private uploadToIPFS;
62
+ private uploadToIPFSFallback;
63
+ private unpinFromIPFS;
64
+ private downloadFromIPFS;
65
+ private saveFileMetadata;
66
+ private removeFileMetadata;
67
+ private getUserFilesFromGun;
68
+ private fileToBase64;
69
+ }
70
+ export { SHIP_05 };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * SHIP-06: Ephemeral P2P Messaging Implementation
3
+ *
4
+ * Two modes:
5
+ * 1. Standalone: new SHIP_06(gunPeers[], roomId) - NO authentication!
6
+ * - Uses ShogunCore internally with silent: true, disableAutoRecall: true
7
+ * - Zero logs, zero storage, pure relay communication
8
+ * - Room hashed with Web Crypto API SHA-256 for deterministic IDs
9
+ *
10
+ * 2. With Identity: new SHIP_06(ISHIP_00, roomId) - Authenticated sessions
11
+ * - Uses existing Gun instance from SHIP-00
12
+ * - All ShogunCore features available
13
+ *
14
+ * Architecture:
15
+ * - Gun Relay for P2P communication (no WebRTC complexity!)
16
+ * - SEA for ephemeral key generation and ECDH encryption
17
+ * - Pure relay mode: radisk: false, localStorage: false, multicast: false
18
+ */
19
+ import type { ISHIP_00 } from "../interfaces/ISHIP_00";
20
+ import type { ISHIP_06, EphemeralMessage, EphemeralConfig, PeerInfo } from "../interfaces/ISHIP_06";
21
+ import type { SEAPair } from "../interfaces/ISHIP_00";
22
+ declare class SHIP_06 implements ISHIP_06 {
23
+ private identity;
24
+ private roomId;
25
+ private config;
26
+ private connected;
27
+ private swarmId;
28
+ private myAddress;
29
+ private myPair;
30
+ private gun;
31
+ private sea;
32
+ private roomNode;
33
+ private presenceNode;
34
+ private messagesNode;
35
+ private peers;
36
+ private messageHandlers;
37
+ private encryptedMessageHandlers;
38
+ private peerSeenHandlers;
39
+ private peerLeftHandlers;
40
+ private heartbeatInterval;
41
+ private processedMessages;
42
+ constructor(identityOrPeers: ISHIP_00 | string[], roomId: string, config?: Partial<EphemeralConfig> | {
43
+ debug?: boolean;
44
+ });
45
+ getIdentity(): ISHIP_00;
46
+ connect(): Promise<void>;
47
+ disconnect(): void;
48
+ isConnected(): boolean;
49
+ getSwarmId(): string;
50
+ getAddress(): string;
51
+ private announcePresence;
52
+ private startHeartbeat;
53
+ private listenForPeers;
54
+ sendBroadcast(message: string): Promise<void>;
55
+ sendDirect(peerAddress: string, message: string): Promise<void>;
56
+ private listenForMessages;
57
+ onMessage(callback: (message: EphemeralMessage) => void): void;
58
+ onPeerSeen(callback: (address: string) => void): void;
59
+ onPeerLeft(callback: (address: string) => void): void;
60
+ onEncryptedMessage(callback: (address: string, data: any) => void): void;
61
+ getPeers(): string[];
62
+ getPeerInfo(address: string): PeerInfo | null;
63
+ getEphemeralPair(): Promise<SEAPair>;
64
+ setEphemeralPair(pair: SEAPair): Promise<void>;
65
+ }
66
+ export { SHIP_06 };