@veridex/sdk 1.0.0-beta.1
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/CHANGELOG.md +73 -0
- package/LICENSE +21 -0
- package/README.md +212 -0
- package/dist/chains/aptos/index.d.mts +140 -0
- package/dist/chains/aptos/index.d.ts +140 -0
- package/dist/chains/aptos/index.js +563 -0
- package/dist/chains/aptos/index.js.map +1 -0
- package/dist/chains/aptos/index.mjs +536 -0
- package/dist/chains/aptos/index.mjs.map +1 -0
- package/dist/chains/evm/index.d.mts +5 -0
- package/dist/chains/evm/index.d.ts +5 -0
- package/dist/chains/evm/index.js +1233 -0
- package/dist/chains/evm/index.js.map +1 -0
- package/dist/chains/evm/index.mjs +1205 -0
- package/dist/chains/evm/index.mjs.map +1 -0
- package/dist/chains/solana/index.d.mts +116 -0
- package/dist/chains/solana/index.d.ts +116 -0
- package/dist/chains/solana/index.js +513 -0
- package/dist/chains/solana/index.js.map +1 -0
- package/dist/chains/solana/index.mjs +491 -0
- package/dist/chains/solana/index.mjs.map +1 -0
- package/dist/chains/starknet/index.d.mts +172 -0
- package/dist/chains/starknet/index.d.ts +172 -0
- package/dist/chains/starknet/index.js +534 -0
- package/dist/chains/starknet/index.js.map +1 -0
- package/dist/chains/starknet/index.mjs +507 -0
- package/dist/chains/starknet/index.mjs.map +1 -0
- package/dist/chains/sui/index.d.mts +182 -0
- package/dist/chains/sui/index.d.ts +182 -0
- package/dist/chains/sui/index.js +560 -0
- package/dist/chains/sui/index.js.map +1 -0
- package/dist/chains/sui/index.mjs +533 -0
- package/dist/chains/sui/index.mjs.map +1 -0
- package/dist/constants.d.mts +150 -0
- package/dist/constants.d.ts +150 -0
- package/dist/constants.js +430 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +392 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index-0NXfbk0z.d.ts +637 -0
- package/dist/index-D0dLVjTA.d.mts +637 -0
- package/dist/index.d.mts +3101 -0
- package/dist/index.d.ts +3101 -0
- package/dist/index.js +13186 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13011 -0
- package/dist/index.mjs.map +1 -0
- package/dist/payload.d.mts +125 -0
- package/dist/payload.d.ts +125 -0
- package/dist/payload.js +315 -0
- package/dist/payload.js.map +1 -0
- package/dist/payload.mjs +269 -0
- package/dist/payload.mjs.map +1 -0
- package/dist/queries/index.d.mts +148 -0
- package/dist/queries/index.d.ts +148 -0
- package/dist/queries/index.js +1533 -0
- package/dist/queries/index.js.map +1 -0
- package/dist/queries/index.mjs +1508 -0
- package/dist/queries/index.mjs.map +1 -0
- package/dist/types-ChIsqCiw.d.mts +565 -0
- package/dist/types-ChIsqCiw.d.ts +565 -0
- package/dist/types-FJL7j6gQ.d.mts +172 -0
- package/dist/types-FJL7j6gQ.d.ts +172 -0
- package/dist/types.d.mts +407 -0
- package/dist/types.d.ts +407 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.d.mts +81 -0
- package/dist/utils.d.ts +81 -0
- package/dist/utils.js +430 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +390 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/wormhole.d.mts +167 -0
- package/dist/wormhole.d.ts +167 -0
- package/dist/wormhole.js +468 -0
- package/dist/wormhole.js.map +1 -0
- package/dist/wormhole.mjs +422 -0
- package/dist/wormhole.mjs.map +1 -0
- package/package.json +151 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import { RegisterSessionParams, RevokeSessionParams, SessionValidationResult, SessionKey as SessionKey$1, IdentityState } from './types.js';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature$1, D as DispatchResult, V as VaultCreationResult } from './types-ChIsqCiw.js';
|
|
4
|
+
import { b as SessionConfig, d as SessionManagerConfig, S as SessionKey, A as ActionParams, c as SessionSignature, g as SessionSignedAction, f as SessionEventCallback } from './types-FJL7j6gQ.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Veridex Protocol SDK - Passkey Manager
|
|
8
|
+
*
|
|
9
|
+
* Chain-agnostic WebAuthn/Passkey credential management
|
|
10
|
+
*/
|
|
11
|
+
interface PasskeyCredential {
|
|
12
|
+
credentialId: string;
|
|
13
|
+
publicKeyX: bigint;
|
|
14
|
+
publicKeyY: bigint;
|
|
15
|
+
keyHash: string;
|
|
16
|
+
}
|
|
17
|
+
interface WebAuthnSignature {
|
|
18
|
+
authenticatorData: string;
|
|
19
|
+
clientDataJSON: string;
|
|
20
|
+
challengeIndex: number;
|
|
21
|
+
typeIndex: number;
|
|
22
|
+
r: bigint;
|
|
23
|
+
s: bigint;
|
|
24
|
+
}
|
|
25
|
+
interface PasskeyManagerConfig {
|
|
26
|
+
rpName?: string;
|
|
27
|
+
rpId?: string;
|
|
28
|
+
timeout?: number;
|
|
29
|
+
userVerification?: 'required' | 'preferred' | 'discouraged';
|
|
30
|
+
authenticatorAttachment?: 'platform' | 'cross-platform';
|
|
31
|
+
/** Relayer API URL for cross-device credential recovery */
|
|
32
|
+
relayerUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Manages WebAuthn passkey credentials for Veridex Protocol
|
|
36
|
+
*/
|
|
37
|
+
declare class PasskeyManager {
|
|
38
|
+
private config;
|
|
39
|
+
private credential;
|
|
40
|
+
constructor(config?: PasskeyManagerConfig);
|
|
41
|
+
static isSupported(): boolean;
|
|
42
|
+
static isPlatformAuthenticatorAvailable(): Promise<boolean>;
|
|
43
|
+
register(username: string, displayName: string): Promise<PasskeyCredential>;
|
|
44
|
+
sign(challenge: Uint8Array): Promise<WebAuthnSignature>;
|
|
45
|
+
/**
|
|
46
|
+
* Authenticate using a discoverable credential (passkey)
|
|
47
|
+
* This allows sign-in without knowing the credential ID ahead of time.
|
|
48
|
+
* The authenticator will show all available passkeys for this RP.
|
|
49
|
+
*
|
|
50
|
+
* @param challenge - Optional challenge bytes. If not provided, a random challenge is used.
|
|
51
|
+
* @returns The credential that was used to authenticate, along with the signature
|
|
52
|
+
*/
|
|
53
|
+
authenticate(challenge?: Uint8Array): Promise<{
|
|
54
|
+
credential: PasskeyCredential;
|
|
55
|
+
signature: WebAuthnSignature;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Load a credential by its ID from localStorage
|
|
59
|
+
* Used for discoverable credential authentication
|
|
60
|
+
*/
|
|
61
|
+
private loadCredentialById;
|
|
62
|
+
/**
|
|
63
|
+
* Check if there's a stored credential for this RP
|
|
64
|
+
*/
|
|
65
|
+
hasStoredCredential(key?: string): boolean;
|
|
66
|
+
getCredential(): PasskeyCredential | null;
|
|
67
|
+
setCredential(credential: PasskeyCredential): void;
|
|
68
|
+
createCredentialFromPublicKey(credentialId: string, publicKeyX: bigint, publicKeyY: bigint): PasskeyCredential;
|
|
69
|
+
clearCredential(): void;
|
|
70
|
+
saveToLocalStorage(key?: string): void;
|
|
71
|
+
loadFromLocalStorage(key?: string): PasskeyCredential | null;
|
|
72
|
+
removeFromLocalStorage(key?: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Save the current credential to the relayer for cross-device recovery.
|
|
75
|
+
* This should be called after registration.
|
|
76
|
+
*/
|
|
77
|
+
saveCredentialToRelayer(): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Load a credential from the relayer by credential ID.
|
|
80
|
+
* Used during discoverable credential authentication when localStorage is empty.
|
|
81
|
+
*/
|
|
82
|
+
loadCredentialFromRelayer(credentialId: string): Promise<PasskeyCredential | null>;
|
|
83
|
+
/**
|
|
84
|
+
* Load a credential from the relayer by keyHash.
|
|
85
|
+
* Useful when you know the user's keyHash but not their credential ID.
|
|
86
|
+
*/
|
|
87
|
+
loadCredentialFromRelayerByKeyHash(keyHash: string): Promise<PasskeyCredential | null>;
|
|
88
|
+
private extractPublicKeyFromAttestation;
|
|
89
|
+
private parseCOSEKey;
|
|
90
|
+
private tryParseCOSEKeyStrategies;
|
|
91
|
+
private parseCOSEKeyWithCBORStructure;
|
|
92
|
+
private tryParseASN1Structure;
|
|
93
|
+
private find32ByteSequences;
|
|
94
|
+
private isValidCoordinate;
|
|
95
|
+
private bytesToBigInt;
|
|
96
|
+
private bytesToHex;
|
|
97
|
+
private analyzeCOSEStructure;
|
|
98
|
+
private parseAuthenticationResponse;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Veridex Protocol SDK - Session Manager
|
|
103
|
+
*
|
|
104
|
+
* Manages ephemeral session keys for fast, native L1-speed transactions
|
|
105
|
+
* after initial biometric authentication.
|
|
106
|
+
*
|
|
107
|
+
* Key Features:
|
|
108
|
+
* - One-time Passkey auth to create session
|
|
109
|
+
* - Instant software-backed signing for subsequent transactions
|
|
110
|
+
* - Query-based validation on Spokes (no VAA wait)
|
|
111
|
+
* - ~400ms transactions after initial setup
|
|
112
|
+
* - Secure encrypted storage (AES-GCM)
|
|
113
|
+
* - Auto-refresh before expiry
|
|
114
|
+
* - Per-session value limits
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Interface for Hub contract interactions
|
|
119
|
+
*
|
|
120
|
+
* This should be implemented by chain clients (e.g., EVMHubClientAdapter).
|
|
121
|
+
*/
|
|
122
|
+
interface HubClient {
|
|
123
|
+
/**
|
|
124
|
+
* Register a session on the Hub
|
|
125
|
+
*
|
|
126
|
+
* @param params Registration parameters with Passkey signature
|
|
127
|
+
* @returns Promise that resolves when registration completes
|
|
128
|
+
*/
|
|
129
|
+
registerSession(params: RegisterSessionParams): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Revoke a session on the Hub
|
|
132
|
+
*
|
|
133
|
+
* @param params Revocation parameters with Passkey signature
|
|
134
|
+
* @returns Promise that resolves when revocation completes
|
|
135
|
+
*/
|
|
136
|
+
revokeSession(params: RevokeSessionParams): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Manages session key lifecycle and signing operations
|
|
140
|
+
*
|
|
141
|
+
* Usage:
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const manager = new SessionManager(credential, hubClient, passkeySign, config);
|
|
144
|
+
*
|
|
145
|
+
* // Create session (requires biometric)
|
|
146
|
+
* const session = await manager.createSession();
|
|
147
|
+
*
|
|
148
|
+
* // Sign actions instantly (no biometric)
|
|
149
|
+
* const signature = await manager.signWithSession(action);
|
|
150
|
+
*
|
|
151
|
+
* // Revoke session (requires biometric)
|
|
152
|
+
* await manager.revokeSession();
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare class SessionManager {
|
|
156
|
+
private credential;
|
|
157
|
+
private hubClient;
|
|
158
|
+
private passkeySign;
|
|
159
|
+
private currentSession;
|
|
160
|
+
private storage;
|
|
161
|
+
private config;
|
|
162
|
+
private refreshTimer;
|
|
163
|
+
private eventCallbacks;
|
|
164
|
+
private debug;
|
|
165
|
+
/**
|
|
166
|
+
* @param credential User's Passkey credential (for Hub interaction)
|
|
167
|
+
* @param hubClient Hub client for on-chain session operations
|
|
168
|
+
* @param passkeySign Function to sign challenges with Passkey
|
|
169
|
+
* @param config Session configuration
|
|
170
|
+
* @param managerConfig SessionManager configuration
|
|
171
|
+
*/
|
|
172
|
+
constructor(credential: PasskeyCredential, hubClient: HubClient, passkeySign: (challenge: Uint8Array) => Promise<any>, config: Partial<SessionConfig>, managerConfig?: SessionManagerConfig);
|
|
173
|
+
/**
|
|
174
|
+
* Create a new session (requires biometric authentication)
|
|
175
|
+
*
|
|
176
|
+
* Steps:
|
|
177
|
+
* 1. Generate ephemeral secp256k1 key pair
|
|
178
|
+
* 2. Sign session registration with Passkey
|
|
179
|
+
* 3. Register session on Hub contract
|
|
180
|
+
* 4. Store session securely (encrypted)
|
|
181
|
+
* 5. Start auto-refresh timer (if enabled)
|
|
182
|
+
*
|
|
183
|
+
* @returns Created session key
|
|
184
|
+
* @throws SessionError if registration fails
|
|
185
|
+
*/
|
|
186
|
+
createSession(): Promise<SessionKey>;
|
|
187
|
+
/**
|
|
188
|
+
* Load existing session from storage
|
|
189
|
+
*
|
|
190
|
+
* @returns Loaded session or null if no valid session exists
|
|
191
|
+
*/
|
|
192
|
+
loadSession(): Promise<SessionKey | null>;
|
|
193
|
+
/**
|
|
194
|
+
* Revoke the current session (requires biometric authentication)
|
|
195
|
+
*
|
|
196
|
+
* @throws SessionError if no active session or revocation fails
|
|
197
|
+
*/
|
|
198
|
+
revokeSession(): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Sign an action with the session key (instant, no biometric)
|
|
201
|
+
*
|
|
202
|
+
* @param action Action parameters to sign
|
|
203
|
+
* @returns Session signature
|
|
204
|
+
* @throws SessionError if no active session, expired, or value exceeds limit
|
|
205
|
+
*/
|
|
206
|
+
signWithSession(action: ActionParams): Promise<SessionSignature>;
|
|
207
|
+
/**
|
|
208
|
+
* Sign an action and prepare for submission
|
|
209
|
+
*
|
|
210
|
+
* @param action Action parameters
|
|
211
|
+
* @returns Session-signed action ready for submission
|
|
212
|
+
*/
|
|
213
|
+
signAction(action: ActionParams): Promise<SessionSignedAction>;
|
|
214
|
+
/**
|
|
215
|
+
* Check if a session is currently active
|
|
216
|
+
*
|
|
217
|
+
* @returns True if an active, non-expired session exists
|
|
218
|
+
*/
|
|
219
|
+
isActive(): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Get current session information (if active)
|
|
222
|
+
*
|
|
223
|
+
* @returns Current session or null
|
|
224
|
+
*/
|
|
225
|
+
getSession(): SessionKey | null;
|
|
226
|
+
/**
|
|
227
|
+
* Get time remaining until session expiry (in seconds)
|
|
228
|
+
*
|
|
229
|
+
* @returns Seconds until expiry, or 0 if no active session
|
|
230
|
+
*/
|
|
231
|
+
getTimeRemaining(): number;
|
|
232
|
+
/**
|
|
233
|
+
* Schedule automatic session refresh
|
|
234
|
+
*/
|
|
235
|
+
private scheduleRefresh;
|
|
236
|
+
/**
|
|
237
|
+
* Refresh the current session (creates a new session)
|
|
238
|
+
*
|
|
239
|
+
* @returns New session key
|
|
240
|
+
*/
|
|
241
|
+
refreshSession(): Promise<SessionKey>;
|
|
242
|
+
/**
|
|
243
|
+
* Register an event callback
|
|
244
|
+
*/
|
|
245
|
+
on(callback: SessionEventCallback): void;
|
|
246
|
+
/**
|
|
247
|
+
* Unregister an event callback
|
|
248
|
+
*/
|
|
249
|
+
off(callback: SessionEventCallback): void;
|
|
250
|
+
/**
|
|
251
|
+
* Emit a session event
|
|
252
|
+
*/
|
|
253
|
+
private emit;
|
|
254
|
+
/**
|
|
255
|
+
* Log debug message (if debug enabled)
|
|
256
|
+
*/
|
|
257
|
+
private log;
|
|
258
|
+
/**
|
|
259
|
+
* Cleanup resources
|
|
260
|
+
*/
|
|
261
|
+
dispose(): void;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
interface EVMClientConfig {
|
|
265
|
+
chainId: number;
|
|
266
|
+
wormholeChainId: number;
|
|
267
|
+
rpcUrl: string;
|
|
268
|
+
hubContractAddress: string;
|
|
269
|
+
wormholeCoreBridge: string;
|
|
270
|
+
name?: string;
|
|
271
|
+
explorerUrl?: string;
|
|
272
|
+
vaultFactory?: string;
|
|
273
|
+
vaultImplementation?: string;
|
|
274
|
+
tokenBridge?: string;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* EVM implementation of the ChainClient interface
|
|
278
|
+
*/
|
|
279
|
+
declare class EVMClient implements ChainClient {
|
|
280
|
+
private config;
|
|
281
|
+
private provider;
|
|
282
|
+
private hubContract;
|
|
283
|
+
private factoryContract;
|
|
284
|
+
private cachedImplementation;
|
|
285
|
+
constructor(config: EVMClientConfig);
|
|
286
|
+
getConfig(): ChainConfig;
|
|
287
|
+
getNonce(userKeyHash: string): Promise<bigint>;
|
|
288
|
+
/**
|
|
289
|
+
* Get user state from Hub (Issue #9/#10)
|
|
290
|
+
* Returns comprehensive state including last action hash
|
|
291
|
+
*/
|
|
292
|
+
getUserState(userKeyHash: string): Promise<{
|
|
293
|
+
keyHash: string;
|
|
294
|
+
nonce: bigint;
|
|
295
|
+
lastActionHash: string;
|
|
296
|
+
}>;
|
|
297
|
+
/**
|
|
298
|
+
* Get user's last action hash from Hub (Issue #9/#10)
|
|
299
|
+
* Returns zero hash if user has no actions yet
|
|
300
|
+
*/
|
|
301
|
+
getUserLastActionHash(userKeyHash: string): Promise<string>;
|
|
302
|
+
/**
|
|
303
|
+
* Register a new session key for temporary authentication
|
|
304
|
+
* Enables native L1 speed for repeat transactions without biometric auth
|
|
305
|
+
*
|
|
306
|
+
* @param params Session registration parameters
|
|
307
|
+
* @param signer Ethereum signer to pay gas
|
|
308
|
+
* @returns Transaction receipt
|
|
309
|
+
*/
|
|
310
|
+
registerSession(params: RegisterSessionParams, signer: ethers.Signer): Promise<ethers.TransactionReceipt>;
|
|
311
|
+
/**
|
|
312
|
+
* Check if a session is currently active (queryable via Wormhole CCQ)
|
|
313
|
+
*
|
|
314
|
+
* @param userKeyHash Hash of the user's Passkey public key
|
|
315
|
+
* @param sessionKeyHash Hash of the session key to check
|
|
316
|
+
* @returns Session validation result
|
|
317
|
+
*/
|
|
318
|
+
isSessionActive(userKeyHash: string, sessionKeyHash: string): Promise<SessionValidationResult>;
|
|
319
|
+
/**
|
|
320
|
+
* Revoke a session key immediately
|
|
321
|
+
*
|
|
322
|
+
* @param params Session revocation parameters
|
|
323
|
+
* @param signer Ethereum signer to pay gas
|
|
324
|
+
* @returns Transaction receipt
|
|
325
|
+
*/
|
|
326
|
+
revokeSession(params: RevokeSessionParams, signer: ethers.Signer): Promise<ethers.TransactionReceipt>;
|
|
327
|
+
/**
|
|
328
|
+
* Get all sessions for a user
|
|
329
|
+
*
|
|
330
|
+
* @param userKeyHash Hash of the user's Passkey public key
|
|
331
|
+
* @returns Array of all sessions (active and expired/revoked)
|
|
332
|
+
*/
|
|
333
|
+
getUserSessions(userKeyHash: string): Promise<SessionKey$1[]>;
|
|
334
|
+
/**
|
|
335
|
+
* Get the number of sessions for a user
|
|
336
|
+
*
|
|
337
|
+
* @param userKeyHash Hash of the user's Passkey public key
|
|
338
|
+
* @returns Number of sessions
|
|
339
|
+
*/
|
|
340
|
+
getUserSessionCount(userKeyHash: string): Promise<number>;
|
|
341
|
+
getMessageFee(): Promise<bigint>;
|
|
342
|
+
buildTransferPayload(params: TransferParams): Promise<string>;
|
|
343
|
+
buildExecutePayload(params: ExecuteParams): Promise<string>;
|
|
344
|
+
buildBridgePayload(params: BridgeParams): Promise<string>;
|
|
345
|
+
dispatch(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, signer: ethers.Signer): Promise<DispatchResult>;
|
|
346
|
+
/**
|
|
347
|
+
* Dispatch an action to the Hub via relayer (gasless)
|
|
348
|
+
* The relayer pays for gas and submits the transaction on behalf of the user
|
|
349
|
+
*/
|
|
350
|
+
dispatchGasless(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, relayerUrl: string): Promise<DispatchResult>;
|
|
351
|
+
getVaultAddress(userKeyHash: string): Promise<string | null>;
|
|
352
|
+
/**
|
|
353
|
+
* Compute vault address deterministically without querying the chain
|
|
354
|
+
* Uses CREATE2 with EIP-1167 minimal proxy pattern
|
|
355
|
+
*/
|
|
356
|
+
computeVaultAddress(userKeyHash: string): string;
|
|
357
|
+
/**
|
|
358
|
+
* Build EIP-1167 minimal proxy initcode
|
|
359
|
+
*/
|
|
360
|
+
private buildProxyInitCode;
|
|
361
|
+
vaultExists(userKeyHash: string): Promise<boolean>;
|
|
362
|
+
createVault(userKeyHash: string, signer: ethers.Signer): Promise<VaultCreationResult>;
|
|
363
|
+
/**
|
|
364
|
+
* Create a vault with a sponsor wallet paying for gas
|
|
365
|
+
*
|
|
366
|
+
* @param userKeyHash - The user's passkey hash
|
|
367
|
+
* @param sponsorPrivateKey - Private key of the wallet that will pay gas
|
|
368
|
+
* @param rpcUrl - Optional RPC URL to use (defaults to client's RPC)
|
|
369
|
+
* @returns VaultCreationResult with address and transaction details
|
|
370
|
+
*/
|
|
371
|
+
createVaultSponsored(userKeyHash: string, sponsorPrivateKey: string, rpcUrl?: string): Promise<VaultCreationResult>;
|
|
372
|
+
estimateVaultCreationGas(userKeyHash: string): Promise<bigint>;
|
|
373
|
+
getFactoryAddress(): string | undefined;
|
|
374
|
+
getImplementationAddress(): string | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Fetch implementation address from factory contract
|
|
377
|
+
*/
|
|
378
|
+
fetchImplementationAddress(): Promise<string | null>;
|
|
379
|
+
/**
|
|
380
|
+
* Get the provider instance
|
|
381
|
+
*/
|
|
382
|
+
getProvider(): ethers.JsonRpcProvider;
|
|
383
|
+
/**
|
|
384
|
+
* Get native token balance for an address
|
|
385
|
+
*/
|
|
386
|
+
getNativeBalance(address: string): Promise<bigint>;
|
|
387
|
+
/**
|
|
388
|
+
* Get ERC20 token balance for an address
|
|
389
|
+
*/
|
|
390
|
+
getTokenBalance(tokenAddress: string, ownerAddress: string): Promise<bigint>;
|
|
391
|
+
/**
|
|
392
|
+
* Get token allowance
|
|
393
|
+
*/
|
|
394
|
+
getTokenAllowance(tokenAddress: string, ownerAddress: string, spenderAddress: string): Promise<bigint>;
|
|
395
|
+
/**
|
|
396
|
+
* Estimate gas for a dispatch transaction
|
|
397
|
+
*/
|
|
398
|
+
estimateDispatchGas(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint): Promise<bigint>;
|
|
399
|
+
/**
|
|
400
|
+
* Get current gas price
|
|
401
|
+
*/
|
|
402
|
+
getGasPrice(): Promise<bigint>;
|
|
403
|
+
/**
|
|
404
|
+
* Get current block number
|
|
405
|
+
*/
|
|
406
|
+
getBlockNumber(): Promise<number>;
|
|
407
|
+
/**
|
|
408
|
+
* Get transaction receipt
|
|
409
|
+
*/
|
|
410
|
+
getTransactionReceipt(hash: string): Promise<ethers.TransactionReceipt | null>;
|
|
411
|
+
/**
|
|
412
|
+
* Wait for transaction confirmation
|
|
413
|
+
*/
|
|
414
|
+
waitForTransaction(hash: string, confirmations?: number): Promise<ethers.TransactionReceipt | null>;
|
|
415
|
+
/**
|
|
416
|
+
* Get the identity for a given key hash
|
|
417
|
+
* Returns zero hash if key is not registered to any identity
|
|
418
|
+
*
|
|
419
|
+
* @param keyHash Hash of the passkey to look up
|
|
420
|
+
* @returns Identity (first passkey's keyHash) or zero hash
|
|
421
|
+
*/
|
|
422
|
+
getIdentityForKey(keyHash: string): Promise<string>;
|
|
423
|
+
/**
|
|
424
|
+
* Get all authorized keys for an identity
|
|
425
|
+
*
|
|
426
|
+
* @param identity The identity key hash (first passkey's keyHash)
|
|
427
|
+
* @returns Array of authorized key hashes
|
|
428
|
+
*/
|
|
429
|
+
getAuthorizedKeys(identity: string): Promise<string[]>;
|
|
430
|
+
/**
|
|
431
|
+
* Get count of authorized keys for an identity
|
|
432
|
+
*
|
|
433
|
+
* @param identity The identity key hash
|
|
434
|
+
* @returns Number of authorized keys
|
|
435
|
+
*/
|
|
436
|
+
getAuthorizedKeyCount(identity: string): Promise<number>;
|
|
437
|
+
/**
|
|
438
|
+
* Check if a key is authorized for an identity
|
|
439
|
+
*
|
|
440
|
+
* @param identity The identity key hash
|
|
441
|
+
* @param keyHash The key hash to check
|
|
442
|
+
* @returns Whether the key is authorized
|
|
443
|
+
*/
|
|
444
|
+
isAuthorizedForIdentity(identity: string, keyHash: string): Promise<boolean>;
|
|
445
|
+
/**
|
|
446
|
+
* Check if a key is the root identity key
|
|
447
|
+
*
|
|
448
|
+
* @param keyHash The key hash to check
|
|
449
|
+
* @returns Whether the key is a root identity
|
|
450
|
+
*/
|
|
451
|
+
isIdentityRootKey(keyHash: string): Promise<boolean>;
|
|
452
|
+
/**
|
|
453
|
+
* Get comprehensive identity state for a key
|
|
454
|
+
*
|
|
455
|
+
* @param keyHash Hash of any key in the identity
|
|
456
|
+
* @returns Identity state including count, max, and root status
|
|
457
|
+
*/
|
|
458
|
+
getIdentityState(keyHash: string): Promise<IdentityState>;
|
|
459
|
+
/**
|
|
460
|
+
* Register a new identity with the first passkey
|
|
461
|
+
* This makes the passkey the root identity key
|
|
462
|
+
*
|
|
463
|
+
* @param signature WebAuthn signature
|
|
464
|
+
* @param publicKeyX Passkey public key X coordinate
|
|
465
|
+
* @param publicKeyY Passkey public key Y coordinate
|
|
466
|
+
* @param signer Ethereum signer to pay gas
|
|
467
|
+
* @returns Transaction receipt and identity hash
|
|
468
|
+
*/
|
|
469
|
+
registerIdentity(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, signer: ethers.Signer): Promise<{
|
|
470
|
+
receipt: ethers.TransactionReceipt;
|
|
471
|
+
identity: string;
|
|
472
|
+
}>;
|
|
473
|
+
/**
|
|
474
|
+
* Add a backup passkey to an existing identity
|
|
475
|
+
* Requires WebAuthn signature from an authorized key
|
|
476
|
+
*
|
|
477
|
+
* @param signature WebAuthn signature from existing authorized key
|
|
478
|
+
* @param publicKeyX Existing key's X coordinate
|
|
479
|
+
* @param publicKeyY Existing key's Y coordinate
|
|
480
|
+
* @param newPublicKeyX New backup key's X coordinate
|
|
481
|
+
* @param newPublicKeyY New backup key's Y coordinate
|
|
482
|
+
* @param nonce Current nonce for the signing key
|
|
483
|
+
* @param signer Ethereum signer to pay gas
|
|
484
|
+
* @returns Transaction receipt and sequence number
|
|
485
|
+
*/
|
|
486
|
+
addBackupKey(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, newPublicKeyX: bigint, newPublicKeyY: bigint, nonce: bigint, signer: ethers.Signer): Promise<{
|
|
487
|
+
receipt: ethers.TransactionReceipt;
|
|
488
|
+
sequence: bigint;
|
|
489
|
+
}>;
|
|
490
|
+
/**
|
|
491
|
+
* Remove a passkey from an identity
|
|
492
|
+
* Cannot remove the last remaining key
|
|
493
|
+
*
|
|
494
|
+
* @param signature WebAuthn signature from an authorized key
|
|
495
|
+
* @param publicKeyX Signing key's X coordinate
|
|
496
|
+
* @param publicKeyY Signing key's Y coordinate
|
|
497
|
+
* @param keyToRemove Hash of the key to remove
|
|
498
|
+
* @param nonce Current nonce for the signing key
|
|
499
|
+
* @param signer Ethereum signer to pay gas
|
|
500
|
+
* @returns Transaction receipt and sequence number
|
|
501
|
+
*/
|
|
502
|
+
removeKey(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, keyToRemove: string, nonce: bigint, signer: ethers.Signer): Promise<{
|
|
503
|
+
receipt: ethers.TransactionReceipt;
|
|
504
|
+
sequence: bigint;
|
|
505
|
+
}>;
|
|
506
|
+
/**
|
|
507
|
+
* Setup guardians for an identity
|
|
508
|
+
* @param signature WebAuthn signature from owner
|
|
509
|
+
* @param publicKeyX Owner's public key X coordinate
|
|
510
|
+
* @param publicKeyY Owner's public key Y coordinate
|
|
511
|
+
* @param guardians Array of guardian key hashes
|
|
512
|
+
* @param threshold Required approvals for recovery
|
|
513
|
+
* @param signer Ethers signer for transaction
|
|
514
|
+
*/
|
|
515
|
+
setupGuardians(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, guardians: string[], threshold: bigint, signer: ethers.Signer): Promise<{
|
|
516
|
+
receipt: ethers.TransactionReceipt;
|
|
517
|
+
sequence: bigint;
|
|
518
|
+
}>;
|
|
519
|
+
/**
|
|
520
|
+
* Add a guardian to an identity
|
|
521
|
+
*/
|
|
522
|
+
addGuardian(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, guardianKeyHash: string, signer: ethers.Signer): Promise<{
|
|
523
|
+
receipt: ethers.TransactionReceipt;
|
|
524
|
+
sequence: bigint;
|
|
525
|
+
}>;
|
|
526
|
+
/**
|
|
527
|
+
* Remove a guardian from an identity
|
|
528
|
+
*/
|
|
529
|
+
removeGuardian(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, guardianKeyHash: string, signer: ethers.Signer): Promise<{
|
|
530
|
+
receipt: ethers.TransactionReceipt;
|
|
531
|
+
sequence: bigint;
|
|
532
|
+
}>;
|
|
533
|
+
/**
|
|
534
|
+
* Initiate recovery as a guardian
|
|
535
|
+
*/
|
|
536
|
+
initiateRecovery(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, identityToRecover: string, newOwnerKeyHash: string, signer: ethers.Signer): Promise<{
|
|
537
|
+
receipt: ethers.TransactionReceipt;
|
|
538
|
+
sequence: bigint;
|
|
539
|
+
}>;
|
|
540
|
+
/**
|
|
541
|
+
* Approve recovery as a guardian
|
|
542
|
+
*/
|
|
543
|
+
approveRecovery(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, identityToRecover: string, signer: ethers.Signer): Promise<{
|
|
544
|
+
receipt: ethers.TransactionReceipt;
|
|
545
|
+
sequence: bigint;
|
|
546
|
+
}>;
|
|
547
|
+
/**
|
|
548
|
+
* Execute recovery after timelock (anyone can call)
|
|
549
|
+
*/
|
|
550
|
+
executeRecovery(identityToRecover: string, newPublicKeyX: bigint, newPublicKeyY: bigint, signer: ethers.Signer): Promise<{
|
|
551
|
+
receipt: ethers.TransactionReceipt;
|
|
552
|
+
sequence: bigint;
|
|
553
|
+
}>;
|
|
554
|
+
/**
|
|
555
|
+
* Cancel recovery as owner
|
|
556
|
+
*/
|
|
557
|
+
cancelRecovery(signature: WebAuthnSignature$1, publicKeyX: bigint, publicKeyY: bigint, signer: ethers.Signer): Promise<{
|
|
558
|
+
receipt: ethers.TransactionReceipt;
|
|
559
|
+
sequence: bigint;
|
|
560
|
+
}>;
|
|
561
|
+
/**
|
|
562
|
+
* Get guardians for an identity
|
|
563
|
+
*/
|
|
564
|
+
getGuardians(identityKeyHash: string): Promise<{
|
|
565
|
+
guardians: string[];
|
|
566
|
+
threshold: bigint;
|
|
567
|
+
isConfigured: boolean;
|
|
568
|
+
}>;
|
|
569
|
+
/**
|
|
570
|
+
* Get recovery status for an identity
|
|
571
|
+
*/
|
|
572
|
+
getRecoveryStatus(identityKeyHash: string): Promise<{
|
|
573
|
+
isActive: boolean;
|
|
574
|
+
newOwnerKeyHash: string;
|
|
575
|
+
initiatedAt: bigint;
|
|
576
|
+
approvalCount: bigint;
|
|
577
|
+
threshold: bigint;
|
|
578
|
+
canExecuteAt: bigint;
|
|
579
|
+
expiresAt: bigint;
|
|
580
|
+
}>;
|
|
581
|
+
/**
|
|
582
|
+
* Check if a guardian has approved recovery
|
|
583
|
+
*/
|
|
584
|
+
hasGuardianApproved(identityKeyHash: string, guardianKeyHash: string): Promise<boolean>;
|
|
585
|
+
/**
|
|
586
|
+
* Helper to extract sequence from transaction receipt
|
|
587
|
+
*/
|
|
588
|
+
private _extractSequenceFromReceipt;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Veridex Protocol SDK - EVM Hub Client Adapter
|
|
593
|
+
*
|
|
594
|
+
* Adapts EVMClient to work with SessionManager's HubClient interface.
|
|
595
|
+
* Provides a clean integration layer between session management and chain clients.
|
|
596
|
+
*/
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Adapter that makes EVMClient compatible with SessionManager's HubClient interface
|
|
600
|
+
*
|
|
601
|
+
* Usage:
|
|
602
|
+
* ```typescript
|
|
603
|
+
* const hubAdapter = new EVMHubClientAdapter(evmClient, signer);
|
|
604
|
+
* const sessionManager = new SessionManager(
|
|
605
|
+
* credential,
|
|
606
|
+
* hubAdapter,
|
|
607
|
+
* config
|
|
608
|
+
* );
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
declare class EVMHubClientAdapter implements HubClient {
|
|
612
|
+
private evmClient;
|
|
613
|
+
private signer;
|
|
614
|
+
constructor(evmClient: EVMClient, signer: ethers.Signer);
|
|
615
|
+
/**
|
|
616
|
+
* Register a session on the Hub
|
|
617
|
+
*
|
|
618
|
+
* @param params Registration parameters with Passkey signature
|
|
619
|
+
* @returns Promise that resolves when registration completes
|
|
620
|
+
*/
|
|
621
|
+
registerSession(params: RegisterSessionParams): Promise<void>;
|
|
622
|
+
/**
|
|
623
|
+
* Revoke a session on the Hub
|
|
624
|
+
*
|
|
625
|
+
* @param params Revocation parameters with Passkey signature
|
|
626
|
+
* @returns Promise that resolves when revocation completes
|
|
627
|
+
*/
|
|
628
|
+
revokeSession(params: RevokeSessionParams): Promise<void>;
|
|
629
|
+
/**
|
|
630
|
+
* Update the signer (e.g., when switching accounts)
|
|
631
|
+
*
|
|
632
|
+
* @param signer New Ethereum signer
|
|
633
|
+
*/
|
|
634
|
+
updateSigner(signer: ethers.Signer): void;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export { EVMHubClientAdapter as E, type HubClient as H, PasskeyManager as P, SessionManager as S, EVMClient as a, type EVMClientConfig as b };
|