w3pk 0.2.0 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,59 @@
1
+ /**
2
+ * Stealth address cryptography for privacy-preserving transactions
3
+ */
4
+ interface StealthKeys {
5
+ metaAddress: string;
6
+ viewingKey: string;
7
+ spendingKey: string;
8
+ }
9
+ /**
10
+ * Check if a stealth address can be controlled by the stealth keys
11
+ * Useful for scanning and proving ownership of stealth addresses
12
+ */
13
+ declare function canControlStealthAddress(viewingKey: string, spendingKey: string, ephemeralPubkey: string, targetAddress: string): boolean;
14
+
15
+ /**
16
+ * Stealth Address Module for w3pk SDK
17
+ * Provides privacy-preserving stealth address generation capabilities
18
+ */
19
+
20
+ interface StealthAddressConfig$1 {
21
+ }
22
+ interface StealthAddressResult {
23
+ stealthAddress: string;
24
+ stealthPrivateKey: string;
25
+ ephemeralPublicKey: string;
26
+ }
27
+ /**
28
+ * Main Stealth Address Module
29
+ * Integrates with w3pk WebAuthn for seamless privacy-preserving stealth address generation
30
+ */
31
+ declare class StealthAddressModule {
32
+ private config;
33
+ private getMnemonic;
34
+ constructor(config: StealthAddressConfig$1, getMnemonic: () => Promise<string | null>);
35
+ /**
36
+ * Generate a fresh stealth address for privacy-preserving transactions
37
+ * Returns the stealth address and private key for the user to handle transactions
38
+ */
39
+ generateStealthAddress(): Promise<StealthAddressResult>;
40
+ /**
41
+ * Get stealth keys for manual operations
42
+ */
43
+ getKeys(): Promise<StealthKeys>;
44
+ /**
45
+ * Check if stealth addresses are available (always true if properly configured)
46
+ */
47
+ get isAvailable(): boolean;
48
+ }
49
+
1
50
  /**
2
51
  * Shared types used across the SDK
3
52
  */
4
53
  interface UserInfo {
5
54
  id: string;
6
55
  username: string;
56
+ displayName: string;
7
57
  ethereumAddress: string;
8
58
  }
9
59
  interface WalletInfo {
@@ -43,6 +93,8 @@ declare class ApiError extends Web3PasskeyError {
43
93
  * SDK Configuration
44
94
  */
45
95
 
96
+ interface StealthAddressConfig {
97
+ }
46
98
  interface Web3PasskeyConfig {
47
99
  /**
48
100
  * Base URL of the WebAuthn API
@@ -67,25 +119,21 @@ interface Web3PasskeyConfig {
67
119
  * Auth state change callback
68
120
  */
69
121
  onAuthStateChanged?: (isAuthenticated: boolean, user?: UserInfo) => void;
122
+ /**
123
+ * Optional stealth address configuration
124
+ * If provided, enables privacy-preserving stealth address generation
125
+ */
126
+ stealthAddresses?: StealthAddressConfig;
70
127
  }
71
128
 
72
129
  /**
73
- * Authentication-related types
130
+ * Main Web3Passkey SDK class
74
131
  */
75
132
 
76
133
  interface AuthResult {
77
134
  verified: boolean;
78
- user?: {
79
- id: string;
80
- username: string;
81
- ethereumAddress: string;
82
- };
135
+ user?: UserInfo;
83
136
  }
84
-
85
- /**
86
- * Main Web3Passkey SDK class
87
- */
88
-
89
137
  declare class Web3Passkey {
90
138
  private config;
91
139
  private apiClient;
@@ -94,11 +142,18 @@ declare class Web3Passkey {
94
142
  private currentUser;
95
143
  private isAuthenticatedState;
96
144
  private isBrowser;
145
+ private stealthAddresses;
97
146
  constructor(config: Web3PasskeyConfig);
98
147
  private loadAuthState;
99
148
  private saveAuthState;
100
149
  private clearAuthState;
101
150
  private notifyAuthStateChange;
151
+ private createUserInfo;
152
+ /**
153
+ * Get mnemonic for current authenticated user
154
+ * Used by stealth address module
155
+ */
156
+ private getMnemonic;
102
157
  /**
103
158
  * Generate a new BIP39 wallet
104
159
  * @returns Wallet info with mnemonic (user MUST backup)
@@ -110,23 +165,22 @@ declare class Web3Passkey {
110
165
  hasWallet(): Promise<boolean>;
111
166
  /**
112
167
  * Register a new user with WebAuthn
168
+ * Handles the complete registration flow internally
169
+ * Automatically generates wallet if not provided
170
+ *
113
171
  * @param username Username for the account
114
- * @param ethereumAddress Ethereum address from generated wallet
115
- * @param mnemonic BIP39 mnemonic to encrypt and store
116
- * @param credentialId WebAuthn credential ID (from registration response)
117
- * @param challenge Challenge used in registration
172
+ * @param ethereumAddress Optional: Ethereum address (will generate if not provided)
173
+ * @param mnemonic Optional: BIP39 mnemonic (will generate if not provided)
174
+ * @returns Object containing ethereumAddress and mnemonic (only if generated)
118
175
  */
119
176
  register(options: {
120
177
  username: string;
178
+ ethereumAddress?: string;
179
+ mnemonic?: string;
180
+ }): Promise<{
121
181
  ethereumAddress: string;
122
- mnemonic: string;
123
- credentialId: string;
124
- challenge: string;
125
- }): Promise<void>;
126
- /**
127
- * Authenticate with Ethereum address
128
- */
129
- authenticate(ethereumAddress: string): Promise<AuthResult>;
182
+ mnemonic?: string;
183
+ }>;
130
184
  /**
131
185
  * Authenticate without username (usernameless flow)
132
186
  */
@@ -137,12 +191,11 @@ declare class Web3Passkey {
137
191
  logout(): void;
138
192
  /**
139
193
  * Sign a message with encrypted wallet
140
- * Requires fresh WebAuthn authentication
194
+ * Handles fresh WebAuthn authentication internally
195
+ *
141
196
  * @param message Message to sign
142
- * @param credentialId WebAuthn credential ID (from fresh auth)
143
- * @param challenge Challenge from fresh auth
144
197
  */
145
- signMessage(message: string, credentialId: string, challenge: string): Promise<string>;
198
+ signMessage(message: string): Promise<string>;
146
199
  /**
147
200
  * Check if user is authenticated
148
201
  */
@@ -159,6 +212,10 @@ declare class Web3Passkey {
159
212
  * Check if running in browser environment
160
213
  */
161
214
  get isBrowserEnvironment(): boolean;
215
+ /**
216
+ * Get stealth address module (if configured)
217
+ */
218
+ get stealth(): StealthAddressModule | null;
162
219
  }
163
220
 
164
221
  /**
@@ -168,4 +225,4 @@ declare class Web3Passkey {
168
225
 
169
226
  declare function createWeb3Passkey(config: Web3PasskeyConfig): Web3Passkey;
170
227
 
171
- export { ApiError, type AuthResult, AuthenticationError, CryptoError, RegistrationError, StorageError, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, createWeb3Passkey, createWeb3Passkey as default };
228
+ export { ApiError, AuthenticationError, CryptoError, RegistrationError, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, canControlStealthAddress, createWeb3Passkey, createWeb3Passkey as default };