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.
- package/dist/ship/examples/ephemeral-cli.js +234 -0
- package/dist/ship/examples/identity-cli.js +503 -0
- package/dist/ship/examples/messenger-cli.js +745 -0
- package/dist/ship/examples/stealth-cli.js +433 -0
- package/dist/ship/examples/storage-cli.js +615 -0
- package/dist/ship/examples/vault-cli.js +444 -0
- package/dist/ship/examples/wallet-cli.js +767 -0
- package/dist/ship/implementation/SHIP_00.js +478 -0
- package/dist/ship/implementation/SHIP_01.js +433 -0
- package/dist/ship/implementation/SHIP_02.js +1366 -0
- package/dist/ship/implementation/SHIP_03.js +855 -0
- package/dist/ship/implementation/SHIP_04.js +589 -0
- package/dist/ship/implementation/SHIP_05.js +1064 -0
- package/dist/ship/implementation/SHIP_06.js +350 -0
- package/dist/ship/implementation/SHIP_07.js +635 -0
- package/dist/ship/index.js +17 -0
- package/dist/ship/interfaces/ISHIP_00.js +135 -0
- package/dist/ship/interfaces/ISHIP_01.js +128 -0
- package/dist/ship/interfaces/ISHIP_02.js +57 -0
- package/dist/ship/interfaces/ISHIP_03.js +61 -0
- package/dist/ship/interfaces/ISHIP_04.js +62 -0
- package/dist/ship/interfaces/ISHIP_05.js +59 -0
- package/dist/ship/interfaces/ISHIP_06.js +144 -0
- package/dist/ship/interfaces/ISHIP_07.js +194 -0
- package/dist/types/ship/examples/ephemeral-cli.d.ts +13 -0
- package/dist/types/ship/examples/identity-cli.d.ts +40 -0
- package/dist/types/ship/examples/messenger-cli.d.ts +37 -0
- package/dist/types/ship/examples/stealth-cli.d.ts +31 -0
- package/dist/types/ship/examples/storage-cli.d.ts +48 -0
- package/dist/types/ship/examples/vault-cli.d.ts +13 -0
- package/dist/types/ship/examples/wallet-cli.d.ts +131 -0
- package/dist/types/ship/implementation/SHIP_00.d.ts +113 -0
- package/dist/types/ship/implementation/SHIP_01.d.ts +80 -0
- package/dist/types/ship/implementation/SHIP_02.d.ts +297 -0
- package/dist/types/ship/implementation/SHIP_03.d.ts +127 -0
- package/dist/types/ship/implementation/SHIP_04.d.ts +76 -0
- package/dist/types/ship/implementation/SHIP_05.d.ts +70 -0
- package/dist/types/ship/implementation/SHIP_06.d.ts +66 -0
- package/dist/types/ship/implementation/SHIP_07.d.ts +101 -0
- package/dist/types/ship/index.d.ts +14 -0
- package/dist/types/ship/interfaces/ISHIP_00.d.ts +410 -0
- package/dist/types/ship/interfaces/ISHIP_01.d.ts +343 -0
- package/dist/types/ship/interfaces/ISHIP_02.d.ts +470 -0
- package/dist/types/ship/interfaces/ISHIP_03.d.ts +295 -0
- package/dist/types/ship/interfaces/ISHIP_04.d.ts +245 -0
- package/dist/types/ship/interfaces/ISHIP_05.d.ts +234 -0
- package/dist/types/ship/interfaces/ISHIP_06.d.ts +370 -0
- package/dist/types/ship/interfaces/ISHIP_07.d.ts +522 -0
- package/package.json +1 -1
- /package/dist/{config → src/config}/simplified-config.js +0 -0
- /package/dist/{core.js → src/core.js} +0 -0
- /package/dist/{examples → src/examples}/api-test.js +0 -0
- /package/dist/{examples → src/examples}/simple-api-test.js +0 -0
- /package/dist/{gundb → src/gundb}/api.js +0 -0
- /package/dist/{gundb → src/gundb}/crypto.js +0 -0
- /package/dist/{gundb → src/gundb}/db.js +0 -0
- /package/dist/{gundb → src/gundb}/derive.js +0 -0
- /package/dist/{gundb → src/gundb}/errors.js +0 -0
- /package/dist/{gundb → src/gundb}/index.js +0 -0
- /package/dist/{gundb → src/gundb}/rxjs.js +0 -0
- /package/dist/{gundb → src/gundb}/types.js +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{interfaces → src/interfaces}/common.js +0 -0
- /package/dist/{interfaces → src/interfaces}/events.js +0 -0
- /package/dist/{interfaces → src/interfaces}/plugin.js +0 -0
- /package/dist/{interfaces → src/interfaces}/shogun.js +0 -0
- /package/dist/{managers → src/managers}/AuthManager.js +0 -0
- /package/dist/{managers → src/managers}/CoreInitializer.js +0 -0
- /package/dist/{managers → src/managers}/EventManager.js +0 -0
- /package/dist/{managers → src/managers}/PluginManager.js +0 -0
- /package/dist/{migration-test.js → src/migration-test.js} +0 -0
- /package/dist/{plugins → src/plugins}/base.js +0 -0
- /package/dist/{plugins → src/plugins}/index.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/index.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/nostrConnector.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/nostrConnectorPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/nostrSigner.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/types.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/index.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/oauthConnector.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/oauthPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/types.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/index.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/types.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/web3Connector.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/web3ConnectorPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/web3Signer.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/index.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/types.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/webauthn.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/webauthnPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/webauthnSigner.js +0 -0
- /package/dist/{storage → src/storage}/storage.js +0 -0
- /package/dist/{types → src/types}/events.js +0 -0
- /package/dist/{types → src/types}/shogun.js +0 -0
- /package/dist/{utils → src/utils}/errorHandler.js +0 -0
- /package/dist/{utils → src/utils}/eventEmitter.js +0 -0
- /package/dist/{utils → src/utils}/validation.js +0 -0
- /package/dist/types/{config → src/config}/simplified-config.d.ts +0 -0
- /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
- /package/dist/types/{examples → src/examples}/api-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/simple-api-test.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/api.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/db.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
- /package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
- /package/dist/types/{migration-test.d.ts → src/migration-test.d.ts} +0 -0
- /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/oauthConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/oauthPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
- /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
- /package/dist/types/{types → src/types}/events.d.ts +0 -0
- /package/dist/types/{types → src/types}/shogun.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIP-03: Dual-Key Stealth Address Interface
|
|
3
|
+
*
|
|
4
|
+
* @title ISHIP_03 - Privacy-Preserving Stealth Addresses
|
|
5
|
+
* @notice Interface for ERC-5564 compatible stealth addresses
|
|
6
|
+
*
|
|
7
|
+
* ## Abstract
|
|
8
|
+
*
|
|
9
|
+
* This standard extends SHIP-00 and SHIP-02 to enable:
|
|
10
|
+
* - Dual-key stealth addresses (viewing + spending keys)
|
|
11
|
+
* - ERC-5564 / Fluidkey compatibility
|
|
12
|
+
* - Enhanced transaction privacy
|
|
13
|
+
* - Stealth address scanning and opening
|
|
14
|
+
* - Deterministic key derivation from SHIP-00 identity
|
|
15
|
+
*
|
|
16
|
+
* ## Specification
|
|
17
|
+
*
|
|
18
|
+
* Based on:
|
|
19
|
+
* - SHIP-00 for identity foundation
|
|
20
|
+
* - SHIP-02 for Ethereum address derivation
|
|
21
|
+
* - ERC-5564 for stealth address standard
|
|
22
|
+
* - Fluidkey Stealth Account Kit
|
|
23
|
+
* - ECDH for shared secret derivation
|
|
24
|
+
*
|
|
25
|
+
* ## Key Concepts
|
|
26
|
+
*
|
|
27
|
+
* **Viewing Key**: Used to scan blockchain for incoming stealth payments
|
|
28
|
+
* **Spending Key**: Used to spend funds received at stealth addresses
|
|
29
|
+
* **Ephemeral Key**: One-time key used by sender to generate stealth address
|
|
30
|
+
*
|
|
31
|
+
* ## Dependencies
|
|
32
|
+
*
|
|
33
|
+
* - SHIP-00: Identity and authentication foundation
|
|
34
|
+
* - SHIP-02: Ethereum wallet operations
|
|
35
|
+
* - @fluidkey/stealth-account-kit: ERC-5564 implementation
|
|
36
|
+
* - ethers: Ethereum operations
|
|
37
|
+
*
|
|
38
|
+
* ## Usage
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const identity = new SHIP_00({ gunOptions: { peers: ['...'] } });
|
|
42
|
+
* await identity.login('alice', 'password123');
|
|
43
|
+
*
|
|
44
|
+
* const eth = new SHIP_02(identity);
|
|
45
|
+
* await eth.initialize();
|
|
46
|
+
*
|
|
47
|
+
* const stealth = new SHIP_03(identity, eth);
|
|
48
|
+
* await stealth.initialize();
|
|
49
|
+
*
|
|
50
|
+
* // Get stealth keys (derived from SHIP-00 identity)
|
|
51
|
+
* const keys = await stealth.getStealthKeys();
|
|
52
|
+
*
|
|
53
|
+
* // Generate stealth address for recipient
|
|
54
|
+
* const stealthAddr = await stealth.generateStealthAddress(
|
|
55
|
+
* recipientViewingKey,
|
|
56
|
+
* recipientSpendingKey
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* @notice Dual stealth keys (viewing + spending)
|
|
62
|
+
*/
|
|
63
|
+
export interface StealthKeys {
|
|
64
|
+
viewingKey: {
|
|
65
|
+
publicKey: string;
|
|
66
|
+
privateKey: string;
|
|
67
|
+
};
|
|
68
|
+
spendingKey: {
|
|
69
|
+
publicKey: string;
|
|
70
|
+
privateKey: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @notice Ephemeral key pair for stealth generation
|
|
75
|
+
*/
|
|
76
|
+
export interface EphemeralKeyPair {
|
|
77
|
+
publicKey: string;
|
|
78
|
+
privateKey: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @notice Stealth address generation result
|
|
82
|
+
*/
|
|
83
|
+
export interface StealthAddressResult {
|
|
84
|
+
success: boolean;
|
|
85
|
+
stealthAddress?: string;
|
|
86
|
+
ephemeralPublicKey?: string;
|
|
87
|
+
viewTag?: string;
|
|
88
|
+
error?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @notice Stealth metadata for announcements (ERC-5564)
|
|
92
|
+
*/
|
|
93
|
+
export interface StealthMetadata {
|
|
94
|
+
ephemeralPublicKey: string;
|
|
95
|
+
viewTag: string;
|
|
96
|
+
stealthAddress: string;
|
|
97
|
+
createdAt: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @notice Announced stealth payment data
|
|
101
|
+
*/
|
|
102
|
+
export interface AnnouncedStealth {
|
|
103
|
+
stealthAddress: string;
|
|
104
|
+
ephemeralPublicKey: string;
|
|
105
|
+
viewTag: string;
|
|
106
|
+
schemeId: number;
|
|
107
|
+
announcer: string;
|
|
108
|
+
txHash?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @notice Scanned stealth address that belongs to user
|
|
112
|
+
*/
|
|
113
|
+
export interface OwnedStealthAddress {
|
|
114
|
+
stealthAddress: string;
|
|
115
|
+
ephemeralPublicKey: string;
|
|
116
|
+
privateKey: string;
|
|
117
|
+
wallet: any;
|
|
118
|
+
metadata: StealthMetadata;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @notice Configuration for SHIP-03
|
|
122
|
+
*/
|
|
123
|
+
export interface SHIP_03_Config {
|
|
124
|
+
/** Enable ERC-5564 compatibility mode */
|
|
125
|
+
erc5564Compatible?: boolean;
|
|
126
|
+
/** Default scheme ID for ERC-5564 */
|
|
127
|
+
defaultSchemeId?: number;
|
|
128
|
+
/** Enable view tag optimization */
|
|
129
|
+
enableViewTag?: boolean;
|
|
130
|
+
/** Auto-scan for stealth addresses */
|
|
131
|
+
autoScan?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @title ISHIP_03 - Dual-Key Stealth Addresses
|
|
135
|
+
* @notice Main interface for privacy-preserving stealth addresses
|
|
136
|
+
*/
|
|
137
|
+
export interface ISHIP_03 {
|
|
138
|
+
/**
|
|
139
|
+
* @notice Initialize the stealth address system
|
|
140
|
+
* @dev Must be called after SHIP-02 initialization
|
|
141
|
+
* @returns Promise that resolves when initialization is complete
|
|
142
|
+
*/
|
|
143
|
+
initialize(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* @notice Check if system is initialized
|
|
146
|
+
* @returns True if initialized, false otherwise
|
|
147
|
+
*/
|
|
148
|
+
isInitialized(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* @notice Get or generate user's stealth keys (viewing + spending)
|
|
151
|
+
* @dev Keys are deterministically derived from SHIP-00 identity
|
|
152
|
+
* @returns Promise resolving to StealthKeys
|
|
153
|
+
*/
|
|
154
|
+
getStealthKeys(): Promise<StealthKeys>;
|
|
155
|
+
/**
|
|
156
|
+
* @notice Get public stealth keys by username (alias)
|
|
157
|
+
* @param username User's alias/username
|
|
158
|
+
* @returns Promise resolving to public keys or null
|
|
159
|
+
*/
|
|
160
|
+
getPublicStealthKeysByUsername(username: string): Promise<{
|
|
161
|
+
viewingPublicKey: string;
|
|
162
|
+
spendingPublicKey: string;
|
|
163
|
+
} | null>;
|
|
164
|
+
/**
|
|
165
|
+
* @notice Get public stealth keys for another user by Gun public key
|
|
166
|
+
* @param userPub User's SHIP-00 public key
|
|
167
|
+
* @returns Promise resolving to public keys or null
|
|
168
|
+
*/
|
|
169
|
+
getPublicStealthKeys(userPub: string): Promise<{
|
|
170
|
+
viewingPublicKey: string;
|
|
171
|
+
spendingPublicKey: string;
|
|
172
|
+
} | null>;
|
|
173
|
+
/**
|
|
174
|
+
* @notice Search directory for users with published stealth keys
|
|
175
|
+
* @returns Promise resolving to array of users with stealth keys
|
|
176
|
+
*/
|
|
177
|
+
searchStealthDirectory(): Promise<Array<{
|
|
178
|
+
username?: string;
|
|
179
|
+
gunPub: string;
|
|
180
|
+
viewingPublicKey: string;
|
|
181
|
+
spendingPublicKey: string;
|
|
182
|
+
timestamp?: number;
|
|
183
|
+
}>>;
|
|
184
|
+
/**
|
|
185
|
+
* @notice Export stealth keys (encrypted)
|
|
186
|
+
* @returns Promise resolving to encrypted keys JSON
|
|
187
|
+
*/
|
|
188
|
+
exportStealthKeys(): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* @notice Import stealth keys (encrypted)
|
|
191
|
+
* @param encryptedKeys Encrypted keys JSON
|
|
192
|
+
* @returns Promise that resolves when import is complete
|
|
193
|
+
*/
|
|
194
|
+
importStealthKeys(encryptedKeys: string): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* @notice Publish public stealth keys to Gun network
|
|
197
|
+
* @dev Makes your stealth keys discoverable by others
|
|
198
|
+
* @returns Promise that resolves when keys are published
|
|
199
|
+
*/
|
|
200
|
+
publishStealthKeys(): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* @notice Generate ephemeral key pair for stealth address creation
|
|
203
|
+
* @returns Promise resolving to EphemeralKeyPair
|
|
204
|
+
*/
|
|
205
|
+
generateEphemeralKeyPair(): Promise<EphemeralKeyPair>;
|
|
206
|
+
/**
|
|
207
|
+
* @notice Generate stealth address for a recipient
|
|
208
|
+
* @param recipientViewingKey Recipient's viewing public key
|
|
209
|
+
* @param recipientSpendingKey Recipient's spending public key
|
|
210
|
+
* @param ephemeralPrivateKey Optional ephemeral key (auto-generated if not provided)
|
|
211
|
+
* @returns Promise resolving to StealthAddressResult
|
|
212
|
+
*/
|
|
213
|
+
generateStealthAddress(recipientViewingKey: string, recipientSpendingKey: string, ephemeralPrivateKey?: string): Promise<StealthAddressResult>;
|
|
214
|
+
/**
|
|
215
|
+
* @notice Generate multiple stealth addresses (batch)
|
|
216
|
+
* @param recipients Array of recipient key pairs
|
|
217
|
+
* @param ephemeralPrivateKey Optional shared ephemeral key
|
|
218
|
+
* @returns Promise resolving to array of results
|
|
219
|
+
*/
|
|
220
|
+
generateMultipleStealthAddresses(recipients: Array<{
|
|
221
|
+
viewingKey: string;
|
|
222
|
+
spendingKey: string;
|
|
223
|
+
}>, ephemeralPrivateKey?: string): Promise<StealthAddressResult[]>;
|
|
224
|
+
/**
|
|
225
|
+
* @notice Open/unlock a stealth address to derive private key
|
|
226
|
+
* @param stealthAddress The stealth address to open
|
|
227
|
+
* @param ephemeralPublicKey Ephemeral public key from announcement
|
|
228
|
+
* @returns Promise resolving to wallet with stealth private key
|
|
229
|
+
*/
|
|
230
|
+
openStealthAddress(stealthAddress: string, ephemeralPublicKey: string): Promise<any>;
|
|
231
|
+
/**
|
|
232
|
+
* @notice Check if a stealth address belongs to user
|
|
233
|
+
* @param stealthAddress Address to check
|
|
234
|
+
* @param ephemeralPublicKey Ephemeral public key from announcement
|
|
235
|
+
* @returns Promise resolving to boolean
|
|
236
|
+
*/
|
|
237
|
+
isStealthAddressMine(stealthAddress: string, ephemeralPublicKey: string): Promise<boolean>;
|
|
238
|
+
/**
|
|
239
|
+
* @notice Get private key for owned stealth address
|
|
240
|
+
* @param stealthAddress The stealth address
|
|
241
|
+
* @param ephemeralPublicKey Ephemeral public key from announcement
|
|
242
|
+
* @returns Promise resolving to private key hex string
|
|
243
|
+
*/
|
|
244
|
+
getStealthPrivateKey(stealthAddress: string, ephemeralPublicKey: string): Promise<string>;
|
|
245
|
+
/**
|
|
246
|
+
* @notice Scan announced stealth addresses for ownership
|
|
247
|
+
* @param announcements Array of announced stealth data
|
|
248
|
+
* @returns Promise resolving to owned stealth addresses
|
|
249
|
+
*/
|
|
250
|
+
scanStealthAddresses(announcements: AnnouncedStealth[]): Promise<OwnedStealthAddress[]>;
|
|
251
|
+
/**
|
|
252
|
+
* @notice Quick scan using view tags (optimization)
|
|
253
|
+
* @param announcements Array with view tags
|
|
254
|
+
* @returns Promise resolving to potentially owned addresses (need full verification)
|
|
255
|
+
*/
|
|
256
|
+
quickScanWithViewTags(announcements: AnnouncedStealth[]): Promise<AnnouncedStealth[]>;
|
|
257
|
+
/**
|
|
258
|
+
* @notice Create ERC-5564 announcement metadata
|
|
259
|
+
* @param stealthAddress Generated stealth address
|
|
260
|
+
* @param ephemeralPublicKey Ephemeral public key
|
|
261
|
+
* @returns StealthMetadata object
|
|
262
|
+
*/
|
|
263
|
+
createAnnouncementMetadata(stealthAddress: string, ephemeralPublicKey: string): StealthMetadata;
|
|
264
|
+
/**
|
|
265
|
+
* @notice Parse announcement from transaction data
|
|
266
|
+
* @param txData Transaction data or logs
|
|
267
|
+
* @returns Promise resolving to AnnouncedStealth or null
|
|
268
|
+
*/
|
|
269
|
+
parseAnnouncement(txData: any): Promise<AnnouncedStealth | null>;
|
|
270
|
+
/**
|
|
271
|
+
* @notice Get all owned stealth addresses
|
|
272
|
+
* @returns Promise resolving to array of owned stealth addresses
|
|
273
|
+
*/
|
|
274
|
+
getAllOwnedStealthAddresses(): Promise<OwnedStealthAddress[]>;
|
|
275
|
+
/**
|
|
276
|
+
* @notice Clear cache and reset state
|
|
277
|
+
* @returns Promise that resolves when cleared
|
|
278
|
+
*/
|
|
279
|
+
clearCache(): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* @notice Verify stealth address was correctly generated
|
|
282
|
+
* @param stealthAddress Address to verify
|
|
283
|
+
* @param ephemeralPublicKey Ephemeral key used
|
|
284
|
+
* @param spendingPublicKey Spending public key
|
|
285
|
+
* @returns Promise resolving to boolean
|
|
286
|
+
*/
|
|
287
|
+
verifyStealthAddress(stealthAddress: string, ephemeralPublicKey: string, spendingPublicKey: string): Promise<boolean>;
|
|
288
|
+
}
|
|
289
|
+
export type SHIP_03_Events = {
|
|
290
|
+
stealthKeysGenerated: (keys: StealthKeys) => void;
|
|
291
|
+
stealthAddressGenerated: (result: StealthAddressResult) => void;
|
|
292
|
+
stealthAddressOpened: (wallet: any) => void;
|
|
293
|
+
stealthAddressScanned: (owned: OwnedStealthAddress[]) => void;
|
|
294
|
+
error: (error: Error) => void;
|
|
295
|
+
};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIP-04: Multi-Modal Authentication Interface
|
|
3
|
+
*
|
|
4
|
+
* @title ISHIP_04 - Alternative Authentication Methods
|
|
5
|
+
* @notice Interface for multi-modal authentication extending SHIP-00
|
|
6
|
+
*
|
|
7
|
+
* ## Abstract
|
|
8
|
+
*
|
|
9
|
+
* This standard extends SHIP-00 to provide multiple authentication methods:
|
|
10
|
+
* - OAuth (Google, GitHub, Discord, etc.)
|
|
11
|
+
* - WebAuthn/Passkeys (biometric authentication)
|
|
12
|
+
* - Nostr (decentralized social protocol)
|
|
13
|
+
* - Web3 (MetaMask, WalletConnect, etc.)
|
|
14
|
+
*
|
|
15
|
+
* ## Dependencies
|
|
16
|
+
*
|
|
17
|
+
* - SHIP-00: Base identity foundation
|
|
18
|
+
* - Shogun Core Plugins: OAuth, WebAuthn, Nostr, Web3
|
|
19
|
+
*
|
|
20
|
+
* ## Inclusive Hierarchy
|
|
21
|
+
*
|
|
22
|
+
* SHIP-04 extends SHIP-00 (✅ allowed):
|
|
23
|
+
* ```
|
|
24
|
+
* SHIP-04 (Multi-Modal Auth)
|
|
25
|
+
* ↓ depends on
|
|
26
|
+
* SHIP-00 (Identity Foundation)
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* ## Usage
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const identity = new SHIP_00(config);
|
|
33
|
+
* const multiAuth = new SHIP_04(identity);
|
|
34
|
+
*
|
|
35
|
+
* // Login with OAuth
|
|
36
|
+
* await multiAuth.loginWithOAuth('google');
|
|
37
|
+
*
|
|
38
|
+
* // Or WebAuthn
|
|
39
|
+
* await multiAuth.loginWithWebAuthn('alice');
|
|
40
|
+
*
|
|
41
|
+
* // Result is SHIP-00 compatible!
|
|
42
|
+
* const user = identity.getCurrentUser();
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import type { ISHIP_00, AuthResult } from "./ISHIP_00";
|
|
46
|
+
/**
|
|
47
|
+
* Available authentication methods
|
|
48
|
+
* Exported as const enum to allow usage as both type and value
|
|
49
|
+
*/
|
|
50
|
+
export declare const enum AuthMethod {
|
|
51
|
+
PASSWORD = "password",// Traditional (SHIP-00)
|
|
52
|
+
OAUTH = "oauth",// OAuth providers
|
|
53
|
+
WEBAUTHN = "webauthn",// Biometric/Passkey
|
|
54
|
+
NOSTR = "nostr",// Nostr protocol
|
|
55
|
+
WEB3 = "web3"
|
|
56
|
+
}
|
|
57
|
+
export type AuthMethodType = "password" | "oauth" | "webauthn" | "nostr" | "web3";
|
|
58
|
+
/**
|
|
59
|
+
* OAuth provider types
|
|
60
|
+
* Note: Must match Shogun Core plugin types
|
|
61
|
+
*/
|
|
62
|
+
export type OAuthProvider = "google" | "github" | "discord" | "twitter" | "custom";
|
|
63
|
+
/**
|
|
64
|
+
* OAuth authentication result
|
|
65
|
+
*/
|
|
66
|
+
export interface OAuthAuthResult extends AuthResult {
|
|
67
|
+
provider?: OAuthProvider;
|
|
68
|
+
email?: string;
|
|
69
|
+
profilePicture?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* WebAuthn authentication result
|
|
73
|
+
*/
|
|
74
|
+
export interface WebAuthnAuthResult extends AuthResult {
|
|
75
|
+
credentialId?: string;
|
|
76
|
+
authenticatorType?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Nostr authentication result
|
|
80
|
+
*/
|
|
81
|
+
export interface NostrAuthResult extends AuthResult {
|
|
82
|
+
nostrPubkey?: string;
|
|
83
|
+
relays?: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Web3 authentication result
|
|
87
|
+
*/
|
|
88
|
+
export interface Web3AuthResult extends AuthResult {
|
|
89
|
+
walletAddress?: string;
|
|
90
|
+
chainId?: number;
|
|
91
|
+
walletType?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Authentication method info
|
|
95
|
+
*/
|
|
96
|
+
export interface AuthMethodInfo {
|
|
97
|
+
method: AuthMethod;
|
|
98
|
+
available: boolean;
|
|
99
|
+
configured: boolean;
|
|
100
|
+
lastUsed?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* SHIP-04 Configuration
|
|
104
|
+
*/
|
|
105
|
+
export interface SHIP_04_Config {
|
|
106
|
+
/** Enable OAuth authentication */
|
|
107
|
+
enableOAuth?: boolean;
|
|
108
|
+
/** OAuth providers configuration */
|
|
109
|
+
oauthProviders?: {
|
|
110
|
+
[key in OAuthProvider]?: {
|
|
111
|
+
clientId: string;
|
|
112
|
+
clientSecret?: string;
|
|
113
|
+
redirectUri: string;
|
|
114
|
+
scopes?: string[];
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/** Enable WebAuthn authentication */
|
|
118
|
+
enableWebAuthn?: boolean;
|
|
119
|
+
/** WebAuthn RP name */
|
|
120
|
+
webAuthnRpName?: string;
|
|
121
|
+
/** WebAuthn RP ID */
|
|
122
|
+
webAuthnRpId?: string;
|
|
123
|
+
/** Enable Nostr authentication */
|
|
124
|
+
enableNostr?: boolean;
|
|
125
|
+
/** Nostr relays */
|
|
126
|
+
nostrRelays?: string[];
|
|
127
|
+
/** Enable Web3 authentication */
|
|
128
|
+
enableWeb3?: boolean;
|
|
129
|
+
/** Preferred Web3 provider */
|
|
130
|
+
web3Provider?: "metamask" | "walletconnect" | "coinbase";
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @title ISHIP_04 - Multi-Modal Authentication
|
|
134
|
+
* @notice Main interface for alternative authentication methods
|
|
135
|
+
* @dev Extends SHIP-00 with OAuth, WebAuthn, Nostr, and Web3 auth
|
|
136
|
+
*/
|
|
137
|
+
export interface ISHIP_04 {
|
|
138
|
+
/**
|
|
139
|
+
* @notice Initialize multi-modal auth system
|
|
140
|
+
* @dev Initializes all enabled authentication plugins
|
|
141
|
+
* @returns Promise that resolves when initialization is complete
|
|
142
|
+
*/
|
|
143
|
+
initialize(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* @notice Check if system is initialized
|
|
146
|
+
* @returns True if initialized
|
|
147
|
+
*/
|
|
148
|
+
isInitialized(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* @notice Get the underlying SHIP-00 identity provider
|
|
151
|
+
* @returns SHIP-00 instance
|
|
152
|
+
*/
|
|
153
|
+
getIdentity(): ISHIP_00;
|
|
154
|
+
/**
|
|
155
|
+
* @notice Login with OAuth provider
|
|
156
|
+
* @param provider OAuth provider (google, github, etc.)
|
|
157
|
+
* @param redirectUri Optional redirect URI override
|
|
158
|
+
* @returns Promise resolving to OAuth auth result
|
|
159
|
+
*/
|
|
160
|
+
loginWithOAuth(provider: OAuthProvider, redirectUri?: string): Promise<OAuthAuthResult>;
|
|
161
|
+
/**
|
|
162
|
+
* @notice Handle OAuth callback after redirect
|
|
163
|
+
* @param code Authorization code from OAuth provider
|
|
164
|
+
* @param provider OAuth provider
|
|
165
|
+
* @returns Promise resolving to auth result
|
|
166
|
+
*/
|
|
167
|
+
handleOAuthCallback(code: string, provider: OAuthProvider): Promise<OAuthAuthResult>;
|
|
168
|
+
/**
|
|
169
|
+
* @notice Check if OAuth is available and configured
|
|
170
|
+
* @param provider Optional specific provider to check
|
|
171
|
+
* @returns True if OAuth is available
|
|
172
|
+
*/
|
|
173
|
+
isOAuthAvailable(provider?: OAuthProvider): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* @notice Register new user with WebAuthn
|
|
176
|
+
* @param username Username for the account
|
|
177
|
+
* @returns Promise resolving to WebAuthn auth result
|
|
178
|
+
*/
|
|
179
|
+
registerWithWebAuthn(username: string): Promise<WebAuthnAuthResult>;
|
|
180
|
+
/**
|
|
181
|
+
* @notice Login with WebAuthn (biometric/passkey)
|
|
182
|
+
* @param username Username to authenticate
|
|
183
|
+
* @returns Promise resolving to WebAuthn auth result
|
|
184
|
+
*/
|
|
185
|
+
loginWithWebAuthn(username: string): Promise<WebAuthnAuthResult>;
|
|
186
|
+
/**
|
|
187
|
+
* @notice Check if WebAuthn is supported
|
|
188
|
+
* @returns True if WebAuthn is available
|
|
189
|
+
*/
|
|
190
|
+
isWebAuthnAvailable(): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* @notice Connect and authenticate with Nostr
|
|
193
|
+
* @returns Promise resolving to Nostr auth result
|
|
194
|
+
*/
|
|
195
|
+
connectNostr(): Promise<NostrAuthResult>;
|
|
196
|
+
/**
|
|
197
|
+
* @notice Login with Nostr extension (nos2x, Alby, etc.)
|
|
198
|
+
* @returns Promise resolving to Nostr auth result
|
|
199
|
+
*/
|
|
200
|
+
loginWithNostr(): Promise<NostrAuthResult>;
|
|
201
|
+
/**
|
|
202
|
+
* @notice Check if Nostr is available
|
|
203
|
+
* @returns True if Nostr extension detected
|
|
204
|
+
*/
|
|
205
|
+
isNostrAvailable(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* @notice Connect Web3 wallet (MetaMask, WalletConnect, etc.)
|
|
208
|
+
* @returns Promise resolving to Web3 auth result
|
|
209
|
+
*/
|
|
210
|
+
connectWeb3(): Promise<Web3AuthResult>;
|
|
211
|
+
/**
|
|
212
|
+
* @notice Login with Web3 wallet
|
|
213
|
+
* @param message Optional message to sign
|
|
214
|
+
* @returns Promise resolving to Web3 auth result
|
|
215
|
+
*/
|
|
216
|
+
loginWithWeb3(message?: string): Promise<Web3AuthResult>;
|
|
217
|
+
/**
|
|
218
|
+
* @notice Check if Web3 is available
|
|
219
|
+
* @returns True if Web3 provider detected
|
|
220
|
+
*/
|
|
221
|
+
isWeb3Available(): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* @notice Get all available authentication methods
|
|
224
|
+
* @returns Array of available auth methods with info
|
|
225
|
+
*/
|
|
226
|
+
getAvailableAuthMethods(): AuthMethodInfo[];
|
|
227
|
+
/**
|
|
228
|
+
* @notice Get current authentication method
|
|
229
|
+
* @returns Current auth method or null
|
|
230
|
+
*/
|
|
231
|
+
getCurrentAuthMethod(): AuthMethod | null;
|
|
232
|
+
/**
|
|
233
|
+
* @notice Clear authentication data
|
|
234
|
+
* @returns Promise that resolves when cleared
|
|
235
|
+
*/
|
|
236
|
+
clearAuth(): Promise<void>;
|
|
237
|
+
}
|
|
238
|
+
export type SHIP_04_Events = {
|
|
239
|
+
oauthConnected: (result: OAuthAuthResult) => void;
|
|
240
|
+
webauthnRegistered: (result: WebAuthnAuthResult) => void;
|
|
241
|
+
nostrConnected: (result: NostrAuthResult) => void;
|
|
242
|
+
web3Connected: (result: Web3AuthResult) => void;
|
|
243
|
+
authMethodChanged: (method: AuthMethod) => void;
|
|
244
|
+
error: (error: Error) => void;
|
|
245
|
+
};
|