w3pk 0.7.7 → 0.8.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/README.md +19 -15
- package/dist/index.d.mts +117 -35
- package/dist/index.d.ts +117 -35
- package/dist/index.js +74 -186
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -186
- package/dist/index.mjs.map +1 -1
- package/docs/API_REFERENCE.md +86 -80
- package/docs/ARCHITECTURE.md +847 -0
- package/docs/BUILD_VERIFICATION.md +5 -5
- package/docs/INTEGRATION_GUIDELINES.md +568 -0
- package/docs/RECOVERY.md +338 -696
- package/docs/SECURITY.md +54 -3
- package/package.json +3 -5
- package/docs/.internal/ATTACK_VECTORS.md +0 -2123
- package/docs/.internal/IMPLEMENTATION_SUMMARY.md +0 -322
- package/docs/.internal/PHILOSOPHY.md +0 -1788
- package/docs/.internal/SECURITY_LEVELS.md +0 -207
- package/docs/.internal/SECURITY_v0.7.6_CHANGES.md +0 -333
- package/docs/.internal/URL_DERIVATION.md +0 -374
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ const rpcUrl = endpoints[0]
|
|
|
54
54
|
- 🔍 Build verification (IPFS CIDv1 hashing for package integrity)
|
|
55
55
|
- 🛡️ Three-layer backup & recovery system
|
|
56
56
|
- Passkey auto-sync (iCloud/Google/Microsoft)
|
|
57
|
-
- Encrypted backups (
|
|
57
|
+
- Encrypted backups (QR codes and backup files with password protection)
|
|
58
58
|
- Social recovery (Shamir Secret Sharing)
|
|
59
59
|
|
|
60
60
|
## API
|
|
@@ -62,12 +62,19 @@ const rpcUrl = endpoints[0]
|
|
|
62
62
|
### Authentication Flow
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
|
-
//
|
|
66
|
-
const
|
|
67
|
-
|
|
65
|
+
// Check for existing wallet first (recommended)
|
|
66
|
+
const hasWallet = await w3pk.hasExistingCredential()
|
|
67
|
+
if (hasWallet) {
|
|
68
|
+
// Login to existing wallet
|
|
69
|
+
await w3pk.login()
|
|
70
|
+
} else {
|
|
71
|
+
// Register new wallet (generates and stores wallet securely)
|
|
72
|
+
const { address, username } = await w3pk.register({ username: 'alice' })
|
|
73
|
+
}
|
|
68
74
|
|
|
69
|
-
//
|
|
70
|
-
await w3pk.
|
|
75
|
+
// Advanced: List all wallets on device
|
|
76
|
+
const wallets = await w3pk.listExistingCredentials()
|
|
77
|
+
wallets.forEach(w => console.log(w.username, w.ethereumAddress))
|
|
71
78
|
|
|
72
79
|
// Logout
|
|
73
80
|
await w3pk.logout()
|
|
@@ -246,10 +253,6 @@ if (!isStrongPassword(password)) {
|
|
|
246
253
|
const status = await w3pk.getBackupStatus()
|
|
247
254
|
console.log('Security Score:', status.securityScore.score) // 0-100
|
|
248
255
|
|
|
249
|
-
// Create encrypted ZIP backup
|
|
250
|
-
const blob = await w3pk.createZipBackup(password)
|
|
251
|
-
// Save blob to file system
|
|
252
|
-
|
|
253
256
|
// Create QR backup
|
|
254
257
|
const { qrCodeDataURL } = await w3pk.createQRBackup('password')
|
|
255
258
|
// Display QR code or save as image
|
|
@@ -295,10 +298,10 @@ import { getCurrentBuildHash, verifyBuildHash } from 'w3pk'
|
|
|
295
298
|
// Get IPFS hash of installed w3pk build
|
|
296
299
|
const hash = await getCurrentBuildHash()
|
|
297
300
|
console.log('Build hash:', hash)
|
|
298
|
-
// =>
|
|
301
|
+
// => bafybeicujqydugwds3yuuipeh6xgiphi342cb6eh7w5z3ryz2hijnrqezm
|
|
299
302
|
|
|
300
303
|
// Verify against trusted hash (from GitHub releases)
|
|
301
|
-
const trusted = '
|
|
304
|
+
const trusted = 'bafybeicujqydugwds3yuuipeh6xgiphi342cb6eh7w5z3ryz2hijnrqezm'
|
|
302
305
|
const isValid = await verifyBuildHash(trusted)
|
|
303
306
|
if (isValid) {
|
|
304
307
|
console.log('✅ Build integrity verified!')
|
|
@@ -312,7 +315,7 @@ See [Build Verification Guide](./docs/BUILD_VERIFICATION.md) for complete docume
|
|
|
312
315
|
### Current Build Hash (v0.7.6)
|
|
313
316
|
|
|
314
317
|
```
|
|
315
|
-
|
|
318
|
+
bafybeicujqydugwds3yuuipeh6xgiphi342cb6eh7w5z3ryz2hijnrqezm
|
|
316
319
|
```
|
|
317
320
|
|
|
318
321
|
**Verify package integrity:**
|
|
@@ -320,7 +323,7 @@ bafybeifysgwvsyog2akxjk4cjky2grqqyzfehamuwyk6zy56srgkc5jopi
|
|
|
320
323
|
```typescript
|
|
321
324
|
import { verifyBuildHash } from 'w3pk'
|
|
322
325
|
|
|
323
|
-
const TRUSTED_HASH = '
|
|
326
|
+
const TRUSTED_HASH = 'bafybeicujqydugwds3yuuipeh6xgiphi342cb6eh7w5z3ryz2hijnrqezm'
|
|
324
327
|
const isValid = await verifyBuildHash(TRUSTED_HASH)
|
|
325
328
|
|
|
326
329
|
if (!isValid) {
|
|
@@ -340,9 +343,10 @@ See [Build Verification Guide](./docs/BUILD_VERIFICATION.md) for complete docume
|
|
|
340
343
|
## Documentation
|
|
341
344
|
|
|
342
345
|
- [Quick Start Guide](./docs/QUICK_START.md) - Get started in 5 minutes
|
|
346
|
+
- [Integration Guidelines](./docs/INTEGRATION_GUIDELINES.md) - Best practices for production apps
|
|
343
347
|
- [API Reference](./docs/API_REFERENCE.md) - Complete API documentation
|
|
344
348
|
- [Build Verification](./docs/BUILD_VERIFICATION.md) - Package integrity verification
|
|
345
|
-
- [Security Architecture](./docs/SECURITY.md) -
|
|
349
|
+
- [Security Architecture](./docs/SECURITY.md) - Security model and threat analysis
|
|
346
350
|
- [Recovery & Backup System](./docs/RECOVERY.md) - Three-layer backup architecture
|
|
347
351
|
- [ZK Proofs](./docs/ZK.md) - Zero-Knowledge cryptography utilities
|
|
348
352
|
- [Browser compatibility](./docs/BROWSER_COMPATIBILITY.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -288,6 +288,47 @@ declare class Web3Passkey {
|
|
|
288
288
|
logout(): Promise<void>;
|
|
289
289
|
get isAuthenticated(): boolean;
|
|
290
290
|
get user(): UserInfo | null;
|
|
291
|
+
/**
|
|
292
|
+
* Check if there are existing credentials on this device
|
|
293
|
+
* Useful for preventing accidental multiple wallet creation
|
|
294
|
+
*
|
|
295
|
+
* @returns true if at least one credential exists
|
|
296
|
+
* @example
|
|
297
|
+
* const hasWallet = await w3pk.hasExistingCredential()
|
|
298
|
+
* if (hasWallet) {
|
|
299
|
+
* // Prompt user to login instead of registering
|
|
300
|
+
* await w3pk.login()
|
|
301
|
+
* }
|
|
302
|
+
*/
|
|
303
|
+
hasExistingCredential(): Promise<boolean>;
|
|
304
|
+
/**
|
|
305
|
+
* Get the number of existing credentials on this device
|
|
306
|
+
*
|
|
307
|
+
* @returns count of credentials
|
|
308
|
+
* @example
|
|
309
|
+
* const count = await w3pk.getExistingCredentialCount()
|
|
310
|
+
* if (count > 0) {
|
|
311
|
+
* console.warn(`You have ${count} wallet(s) on this device`)
|
|
312
|
+
* }
|
|
313
|
+
*/
|
|
314
|
+
getExistingCredentialCount(): Promise<number>;
|
|
315
|
+
/**
|
|
316
|
+
* List existing credentials (usernames and addresses)
|
|
317
|
+
* Useful for allowing users to select which wallet to login to
|
|
318
|
+
*
|
|
319
|
+
* @returns array of credentials with username, address, and metadata
|
|
320
|
+
* @example
|
|
321
|
+
* const wallets = await w3pk.listExistingCredentials()
|
|
322
|
+
* wallets.forEach(w => {
|
|
323
|
+
* console.log(`${w.username}: ${w.ethereumAddress}`)
|
|
324
|
+
* })
|
|
325
|
+
*/
|
|
326
|
+
listExistingCredentials(): Promise<Array<{
|
|
327
|
+
username: string;
|
|
328
|
+
ethereumAddress: string;
|
|
329
|
+
createdAt: string;
|
|
330
|
+
lastUsed: string;
|
|
331
|
+
}>>;
|
|
291
332
|
/**
|
|
292
333
|
* Generate new BIP39 wallet with 12-word mnemonic
|
|
293
334
|
*/
|
|
@@ -316,7 +357,7 @@ declare class Web3Passkey {
|
|
|
316
357
|
}>;
|
|
317
358
|
/**
|
|
318
359
|
* Export mnemonic (disabled for security)
|
|
319
|
-
* Use
|
|
360
|
+
* Use createBackupFile() instead
|
|
320
361
|
* @deprecated
|
|
321
362
|
* @throws WalletError
|
|
322
363
|
*/
|
|
@@ -369,59 +410,105 @@ declare class Web3Passkey {
|
|
|
369
410
|
*/
|
|
370
411
|
getBackupStatus(): Promise<any>;
|
|
371
412
|
/**
|
|
372
|
-
* Create
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
*
|
|
413
|
+
* Create simplified backup file
|
|
414
|
+
* This backup can be used to:
|
|
415
|
+
* - Restore wallet with existing passkey
|
|
416
|
+
* - Register new passkey with this wallet
|
|
417
|
+
* - Sync wallet across devices
|
|
418
|
+
* - Split among guardians for social recovery
|
|
419
|
+
*
|
|
420
|
+
* @param encryptionType - 'password' (default), 'passkey', or 'hybrid'
|
|
421
|
+
* @param password - Required for 'password' and 'hybrid' encryption
|
|
380
422
|
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
qrCodeDataURL: string;
|
|
385
|
-
instructions: string;
|
|
423
|
+
createBackupFile(encryptionType?: 'password' | 'passkey' | 'hybrid', password?: string): Promise<{
|
|
424
|
+
blob: Blob;
|
|
425
|
+
filename: string;
|
|
386
426
|
}>;
|
|
387
427
|
/**
|
|
388
|
-
* Set up social recovery
|
|
389
|
-
*
|
|
428
|
+
* Set up social recovery by splitting backup file among guardians
|
|
429
|
+
* Uses Shamir Secret Sharing to split the backup - requires M-of-N guardians to recover
|
|
430
|
+
*
|
|
431
|
+
* @param guardians - List of guardian names/emails
|
|
432
|
+
* @param threshold - Number of guardians required to recover (M-of-N)
|
|
433
|
+
* @param password - Optional password for additional encryption layer
|
|
390
434
|
*/
|
|
391
435
|
setupSocialRecovery(guardians: {
|
|
392
436
|
name: string;
|
|
393
437
|
email?: string;
|
|
394
|
-
|
|
395
|
-
|
|
438
|
+
}[], threshold: number, password?: string): Promise<{
|
|
439
|
+
guardianShares: any[];
|
|
440
|
+
setupComplete: boolean;
|
|
441
|
+
}>;
|
|
396
442
|
/**
|
|
397
|
-
* Generate guardian invitation
|
|
398
|
-
|
|
399
|
-
|
|
443
|
+
* Generate guardian invitation document and QR code
|
|
444
|
+
*
|
|
445
|
+
* @param guardianShare - The guardian's share data
|
|
446
|
+
* @param message - Optional custom message for the guardian
|
|
447
|
+
*/
|
|
448
|
+
generateGuardianInvite(guardianShare: any, message?: string): Promise<{
|
|
449
|
+
qrCodeDataURL?: string;
|
|
450
|
+
shareDocument: string;
|
|
451
|
+
downloadBlob: Blob;
|
|
452
|
+
filename: string;
|
|
453
|
+
}>;
|
|
400
454
|
/**
|
|
401
455
|
* Recover wallet from guardian shares
|
|
456
|
+
* Combines M-of-N guardian shares to reconstruct the backup file
|
|
457
|
+
*
|
|
458
|
+
* @param shares - Array of guardian share objects (JSON strings or parsed objects)
|
|
459
|
+
* @param password - Password to decrypt the backup (if password-protected)
|
|
402
460
|
*/
|
|
403
|
-
recoverFromGuardians(shares: string
|
|
461
|
+
recoverFromGuardians(shares: Array<string | any>, password?: string): Promise<{
|
|
404
462
|
mnemonic: string;
|
|
405
463
|
ethereumAddress: string;
|
|
406
464
|
}>;
|
|
407
465
|
/**
|
|
408
|
-
* Restore wallet from
|
|
466
|
+
* Restore wallet from backup file with existing passkey
|
|
467
|
+
* Use case: User has passkey synced to this device
|
|
468
|
+
*
|
|
469
|
+
* After restoration, you can either:
|
|
470
|
+
* - Use importMnemonic() to associate with current logged-in user
|
|
471
|
+
* - Use registerWithBackupFile() to create new passkey for this wallet
|
|
409
472
|
*/
|
|
410
|
-
|
|
473
|
+
restoreFromBackupFile(backupData: string | Blob, password?: string): Promise<{
|
|
411
474
|
mnemonic: string;
|
|
412
475
|
ethereumAddress: string;
|
|
413
476
|
}>;
|
|
414
477
|
/**
|
|
415
|
-
*
|
|
478
|
+
* Register new passkey with wallet from backup file
|
|
479
|
+
* Use case: Fresh device, user has backup file but no passkey yet
|
|
480
|
+
*
|
|
481
|
+
* This creates a NEW passkey and associates it with the wallet from the backup
|
|
482
|
+
*
|
|
483
|
+
* @param backupData - Backup file (JSON string or Blob)
|
|
484
|
+
* @param password - Password to decrypt the backup
|
|
485
|
+
* @param username - Username for the new passkey
|
|
416
486
|
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
487
|
+
registerWithBackupFile(backupData: string | Blob, password: string, username: string): Promise<{
|
|
488
|
+
address: string;
|
|
489
|
+
username: string;
|
|
420
490
|
}>;
|
|
421
491
|
/**
|
|
422
492
|
* Get cross-device sync status
|
|
423
493
|
*/
|
|
424
494
|
getSyncStatus(): Promise<any>;
|
|
495
|
+
/**
|
|
496
|
+
* Export wallet for syncing to another device
|
|
497
|
+
* Uses passkey encryption so it works on devices where the passkey is synced
|
|
498
|
+
*/
|
|
499
|
+
exportForSync(): Promise<{
|
|
500
|
+
blob: Blob;
|
|
501
|
+
filename: string;
|
|
502
|
+
qrCode?: string;
|
|
503
|
+
}>;
|
|
504
|
+
/**
|
|
505
|
+
* Import wallet from another device (sync wallet to this device)
|
|
506
|
+
* Use case: User has passkey on both devices, wallet only on one
|
|
507
|
+
*/
|
|
508
|
+
importFromSync(syncData: string | Blob): Promise<{
|
|
509
|
+
ethereumAddress: string;
|
|
510
|
+
success: boolean;
|
|
511
|
+
}>;
|
|
425
512
|
/**
|
|
426
513
|
* Detect platform sync capabilities
|
|
427
514
|
*/
|
|
@@ -517,7 +604,7 @@ interface RecoveryPhraseStatus {
|
|
|
517
604
|
}
|
|
518
605
|
interface EncryptedBackupInfo {
|
|
519
606
|
id: string;
|
|
520
|
-
method: '
|
|
607
|
+
method: 'qr' | 'file';
|
|
521
608
|
location: string;
|
|
522
609
|
createdAt: string;
|
|
523
610
|
deviceFingerprint?: string;
|
|
@@ -551,11 +638,6 @@ interface SecurityScore {
|
|
|
551
638
|
level: 'vulnerable' | 'protected' | 'secured' | 'fort-knox';
|
|
552
639
|
nextMilestone: string;
|
|
553
640
|
}
|
|
554
|
-
interface ZipBackupOptions {
|
|
555
|
-
password: string;
|
|
556
|
-
includeInstructions?: boolean;
|
|
557
|
-
deviceBinding?: boolean;
|
|
558
|
-
}
|
|
559
641
|
interface QRBackupOptions {
|
|
560
642
|
password?: string;
|
|
561
643
|
errorCorrection?: 'L' | 'M' | 'Q' | 'H';
|
|
@@ -786,4 +868,4 @@ interface SyncStatus {
|
|
|
786
868
|
|
|
787
869
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
788
870
|
|
|
789
|
-
export { ApiError, AuthenticationError, type BackupStatus, CryptoError, DEFAULT_TAG, type DeviceInfo, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SocialRecoveryConfig, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError,
|
|
871
|
+
export { ApiError, AuthenticationError, type BackupStatus, CryptoError, DEFAULT_TAG, type DeviceInfo, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SocialRecoveryConfig, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, assertEthereumAddress, assertMnemonic, assertUsername, createWeb3Passkey, createWeb3Passkey as default, getAllTopics, getCurrentBuildHash, getCurrentOrigin, getExplainer, getPackageVersion, getW3pkBuildHash, isStrongPassword, normalizeOrigin, searchExplainers, validateEthereumAddress, validateMnemonic, validateUsername, verifyBuildHash };
|
package/dist/index.d.ts
CHANGED
|
@@ -288,6 +288,47 @@ declare class Web3Passkey {
|
|
|
288
288
|
logout(): Promise<void>;
|
|
289
289
|
get isAuthenticated(): boolean;
|
|
290
290
|
get user(): UserInfo | null;
|
|
291
|
+
/**
|
|
292
|
+
* Check if there are existing credentials on this device
|
|
293
|
+
* Useful for preventing accidental multiple wallet creation
|
|
294
|
+
*
|
|
295
|
+
* @returns true if at least one credential exists
|
|
296
|
+
* @example
|
|
297
|
+
* const hasWallet = await w3pk.hasExistingCredential()
|
|
298
|
+
* if (hasWallet) {
|
|
299
|
+
* // Prompt user to login instead of registering
|
|
300
|
+
* await w3pk.login()
|
|
301
|
+
* }
|
|
302
|
+
*/
|
|
303
|
+
hasExistingCredential(): Promise<boolean>;
|
|
304
|
+
/**
|
|
305
|
+
* Get the number of existing credentials on this device
|
|
306
|
+
*
|
|
307
|
+
* @returns count of credentials
|
|
308
|
+
* @example
|
|
309
|
+
* const count = await w3pk.getExistingCredentialCount()
|
|
310
|
+
* if (count > 0) {
|
|
311
|
+
* console.warn(`You have ${count} wallet(s) on this device`)
|
|
312
|
+
* }
|
|
313
|
+
*/
|
|
314
|
+
getExistingCredentialCount(): Promise<number>;
|
|
315
|
+
/**
|
|
316
|
+
* List existing credentials (usernames and addresses)
|
|
317
|
+
* Useful for allowing users to select which wallet to login to
|
|
318
|
+
*
|
|
319
|
+
* @returns array of credentials with username, address, and metadata
|
|
320
|
+
* @example
|
|
321
|
+
* const wallets = await w3pk.listExistingCredentials()
|
|
322
|
+
* wallets.forEach(w => {
|
|
323
|
+
* console.log(`${w.username}: ${w.ethereumAddress}`)
|
|
324
|
+
* })
|
|
325
|
+
*/
|
|
326
|
+
listExistingCredentials(): Promise<Array<{
|
|
327
|
+
username: string;
|
|
328
|
+
ethereumAddress: string;
|
|
329
|
+
createdAt: string;
|
|
330
|
+
lastUsed: string;
|
|
331
|
+
}>>;
|
|
291
332
|
/**
|
|
292
333
|
* Generate new BIP39 wallet with 12-word mnemonic
|
|
293
334
|
*/
|
|
@@ -316,7 +357,7 @@ declare class Web3Passkey {
|
|
|
316
357
|
}>;
|
|
317
358
|
/**
|
|
318
359
|
* Export mnemonic (disabled for security)
|
|
319
|
-
* Use
|
|
360
|
+
* Use createBackupFile() instead
|
|
320
361
|
* @deprecated
|
|
321
362
|
* @throws WalletError
|
|
322
363
|
*/
|
|
@@ -369,59 +410,105 @@ declare class Web3Passkey {
|
|
|
369
410
|
*/
|
|
370
411
|
getBackupStatus(): Promise<any>;
|
|
371
412
|
/**
|
|
372
|
-
* Create
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
*
|
|
413
|
+
* Create simplified backup file
|
|
414
|
+
* This backup can be used to:
|
|
415
|
+
* - Restore wallet with existing passkey
|
|
416
|
+
* - Register new passkey with this wallet
|
|
417
|
+
* - Sync wallet across devices
|
|
418
|
+
* - Split among guardians for social recovery
|
|
419
|
+
*
|
|
420
|
+
* @param encryptionType - 'password' (default), 'passkey', or 'hybrid'
|
|
421
|
+
* @param password - Required for 'password' and 'hybrid' encryption
|
|
380
422
|
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
qrCodeDataURL: string;
|
|
385
|
-
instructions: string;
|
|
423
|
+
createBackupFile(encryptionType?: 'password' | 'passkey' | 'hybrid', password?: string): Promise<{
|
|
424
|
+
blob: Blob;
|
|
425
|
+
filename: string;
|
|
386
426
|
}>;
|
|
387
427
|
/**
|
|
388
|
-
* Set up social recovery
|
|
389
|
-
*
|
|
428
|
+
* Set up social recovery by splitting backup file among guardians
|
|
429
|
+
* Uses Shamir Secret Sharing to split the backup - requires M-of-N guardians to recover
|
|
430
|
+
*
|
|
431
|
+
* @param guardians - List of guardian names/emails
|
|
432
|
+
* @param threshold - Number of guardians required to recover (M-of-N)
|
|
433
|
+
* @param password - Optional password for additional encryption layer
|
|
390
434
|
*/
|
|
391
435
|
setupSocialRecovery(guardians: {
|
|
392
436
|
name: string;
|
|
393
437
|
email?: string;
|
|
394
|
-
|
|
395
|
-
|
|
438
|
+
}[], threshold: number, password?: string): Promise<{
|
|
439
|
+
guardianShares: any[];
|
|
440
|
+
setupComplete: boolean;
|
|
441
|
+
}>;
|
|
396
442
|
/**
|
|
397
|
-
* Generate guardian invitation
|
|
398
|
-
|
|
399
|
-
|
|
443
|
+
* Generate guardian invitation document and QR code
|
|
444
|
+
*
|
|
445
|
+
* @param guardianShare - The guardian's share data
|
|
446
|
+
* @param message - Optional custom message for the guardian
|
|
447
|
+
*/
|
|
448
|
+
generateGuardianInvite(guardianShare: any, message?: string): Promise<{
|
|
449
|
+
qrCodeDataURL?: string;
|
|
450
|
+
shareDocument: string;
|
|
451
|
+
downloadBlob: Blob;
|
|
452
|
+
filename: string;
|
|
453
|
+
}>;
|
|
400
454
|
/**
|
|
401
455
|
* Recover wallet from guardian shares
|
|
456
|
+
* Combines M-of-N guardian shares to reconstruct the backup file
|
|
457
|
+
*
|
|
458
|
+
* @param shares - Array of guardian share objects (JSON strings or parsed objects)
|
|
459
|
+
* @param password - Password to decrypt the backup (if password-protected)
|
|
402
460
|
*/
|
|
403
|
-
recoverFromGuardians(shares: string
|
|
461
|
+
recoverFromGuardians(shares: Array<string | any>, password?: string): Promise<{
|
|
404
462
|
mnemonic: string;
|
|
405
463
|
ethereumAddress: string;
|
|
406
464
|
}>;
|
|
407
465
|
/**
|
|
408
|
-
* Restore wallet from
|
|
466
|
+
* Restore wallet from backup file with existing passkey
|
|
467
|
+
* Use case: User has passkey synced to this device
|
|
468
|
+
*
|
|
469
|
+
* After restoration, you can either:
|
|
470
|
+
* - Use importMnemonic() to associate with current logged-in user
|
|
471
|
+
* - Use registerWithBackupFile() to create new passkey for this wallet
|
|
409
472
|
*/
|
|
410
|
-
|
|
473
|
+
restoreFromBackupFile(backupData: string | Blob, password?: string): Promise<{
|
|
411
474
|
mnemonic: string;
|
|
412
475
|
ethereumAddress: string;
|
|
413
476
|
}>;
|
|
414
477
|
/**
|
|
415
|
-
*
|
|
478
|
+
* Register new passkey with wallet from backup file
|
|
479
|
+
* Use case: Fresh device, user has backup file but no passkey yet
|
|
480
|
+
*
|
|
481
|
+
* This creates a NEW passkey and associates it with the wallet from the backup
|
|
482
|
+
*
|
|
483
|
+
* @param backupData - Backup file (JSON string or Blob)
|
|
484
|
+
* @param password - Password to decrypt the backup
|
|
485
|
+
* @param username - Username for the new passkey
|
|
416
486
|
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
487
|
+
registerWithBackupFile(backupData: string | Blob, password: string, username: string): Promise<{
|
|
488
|
+
address: string;
|
|
489
|
+
username: string;
|
|
420
490
|
}>;
|
|
421
491
|
/**
|
|
422
492
|
* Get cross-device sync status
|
|
423
493
|
*/
|
|
424
494
|
getSyncStatus(): Promise<any>;
|
|
495
|
+
/**
|
|
496
|
+
* Export wallet for syncing to another device
|
|
497
|
+
* Uses passkey encryption so it works on devices where the passkey is synced
|
|
498
|
+
*/
|
|
499
|
+
exportForSync(): Promise<{
|
|
500
|
+
blob: Blob;
|
|
501
|
+
filename: string;
|
|
502
|
+
qrCode?: string;
|
|
503
|
+
}>;
|
|
504
|
+
/**
|
|
505
|
+
* Import wallet from another device (sync wallet to this device)
|
|
506
|
+
* Use case: User has passkey on both devices, wallet only on one
|
|
507
|
+
*/
|
|
508
|
+
importFromSync(syncData: string | Blob): Promise<{
|
|
509
|
+
ethereumAddress: string;
|
|
510
|
+
success: boolean;
|
|
511
|
+
}>;
|
|
425
512
|
/**
|
|
426
513
|
* Detect platform sync capabilities
|
|
427
514
|
*/
|
|
@@ -517,7 +604,7 @@ interface RecoveryPhraseStatus {
|
|
|
517
604
|
}
|
|
518
605
|
interface EncryptedBackupInfo {
|
|
519
606
|
id: string;
|
|
520
|
-
method: '
|
|
607
|
+
method: 'qr' | 'file';
|
|
521
608
|
location: string;
|
|
522
609
|
createdAt: string;
|
|
523
610
|
deviceFingerprint?: string;
|
|
@@ -551,11 +638,6 @@ interface SecurityScore {
|
|
|
551
638
|
level: 'vulnerable' | 'protected' | 'secured' | 'fort-knox';
|
|
552
639
|
nextMilestone: string;
|
|
553
640
|
}
|
|
554
|
-
interface ZipBackupOptions {
|
|
555
|
-
password: string;
|
|
556
|
-
includeInstructions?: boolean;
|
|
557
|
-
deviceBinding?: boolean;
|
|
558
|
-
}
|
|
559
641
|
interface QRBackupOptions {
|
|
560
642
|
password?: string;
|
|
561
643
|
errorCorrection?: 'L' | 'M' | 'Q' | 'H';
|
|
@@ -786,4 +868,4 @@ interface SyncStatus {
|
|
|
786
868
|
|
|
787
869
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
788
870
|
|
|
789
|
-
export { ApiError, AuthenticationError, type BackupStatus, CryptoError, DEFAULT_TAG, type DeviceInfo, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SocialRecoveryConfig, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError,
|
|
871
|
+
export { ApiError, AuthenticationError, type BackupStatus, CryptoError, DEFAULT_TAG, type DeviceInfo, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SocialRecoveryConfig, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, assertEthereumAddress, assertMnemonic, assertUsername, createWeb3Passkey, createWeb3Passkey as default, getAllTopics, getCurrentBuildHash, getCurrentOrigin, getExplainer, getPackageVersion, getW3pkBuildHash, isStrongPassword, normalizeOrigin, searchExplainers, validateEthereumAddress, validateMnemonic, validateUsername, verifyBuildHash };
|