w3pk 0.7.0 → 0.7.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/README.md +53 -0
- package/dist/index.d.mts +620 -1
- package/dist/index.d.ts +620 -1
- package/dist/index.js +780 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +780 -5
- package/dist/index.mjs.map +1 -1
- package/docs/MIGRATION.md +15 -15
- package/docs/RECOVERY.md +973 -0
- package/docs/SECURITY.md +331 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -48,6 +48,10 @@ const rpcUrl = endpoints[0]
|
|
|
48
48
|
- 🥷 ERC-5564 stealth addresses (privacy-preserving transactions with view tags)
|
|
49
49
|
- 🔗 Chainlist support (2390+ networks, auto-filtered RPC endpoints)
|
|
50
50
|
- ⚡ EIP-7702 network detection (329+ supported networks)
|
|
51
|
+
- 🛡️ Three-layer backup & recovery system
|
|
52
|
+
- Passkey auto-sync (iCloud/Google/Microsoft)
|
|
53
|
+
- Encrypted backups (ZIP/QR with password protection)
|
|
54
|
+
- Social recovery (Shamir Secret Sharing)
|
|
51
55
|
|
|
52
56
|
**Optional: Zero-Knowledge Proofs**
|
|
53
57
|
|
|
@@ -218,6 +222,54 @@ if (result.isForUser) {
|
|
|
218
222
|
const myPayments = await w3pk.stealth?.scanAnnouncements(announcements)
|
|
219
223
|
```
|
|
220
224
|
|
|
225
|
+
### Backup & Recovery
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
// Get backup status
|
|
229
|
+
const status = await w3pk.getBackupStatus()
|
|
230
|
+
console.log('Security Score:', status.securityScore.score) // 0-100
|
|
231
|
+
|
|
232
|
+
// Create encrypted ZIP backup
|
|
233
|
+
const blob = await w3pk.createZipBackup('MyS3cur3!Password@2042')
|
|
234
|
+
// Save blob to file system
|
|
235
|
+
|
|
236
|
+
// Create QR backup
|
|
237
|
+
const { qrCodeDataURL } = await w3pk.createQRBackup('password')
|
|
238
|
+
// Display QR code or save as image
|
|
239
|
+
|
|
240
|
+
// Setup social recovery (3-of-5 guardians)
|
|
241
|
+
await w3pk.setupSocialRecovery(
|
|
242
|
+
[
|
|
243
|
+
{ name: 'Alice', email: 'alice@example.com' },
|
|
244
|
+
{ name: 'Bob', phone: '+1234567890' },
|
|
245
|
+
{ name: 'Charlie' }
|
|
246
|
+
],
|
|
247
|
+
3 // threshold
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
// Generate guardian invite
|
|
251
|
+
const invite = await w3pk.generateGuardianInvite(guardianId)
|
|
252
|
+
// Share invite.qrCode or invite.shareCode with guardian
|
|
253
|
+
|
|
254
|
+
// Recover from guardian shares
|
|
255
|
+
const { mnemonic } = await w3pk.recoverFromGuardians([
|
|
256
|
+
share1, share2, share3
|
|
257
|
+
])
|
|
258
|
+
|
|
259
|
+
// Restore from backup
|
|
260
|
+
await w3pk.restoreFromBackup(encryptedData, password)
|
|
261
|
+
|
|
262
|
+
// Simulate recovery scenarios for testing
|
|
263
|
+
const result = await w3pk.simulateRecoveryScenario({
|
|
264
|
+
type: 'lost-device',
|
|
265
|
+
hasBackup: true,
|
|
266
|
+
hasSocialRecovery: true
|
|
267
|
+
})
|
|
268
|
+
console.log('Can recover:', result.canRecover)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
See [Recovery Guide](./docs/RECOVERY.md) for complete documentation.
|
|
272
|
+
|
|
221
273
|
## Browser Compatibility
|
|
222
274
|
|
|
223
275
|
**Supported (95%+ of users):**
|
|
@@ -233,6 +285,7 @@ const myPayments = await w3pk.stealth?.scanAnnouncements(announcements)
|
|
|
233
285
|
## Documentation
|
|
234
286
|
|
|
235
287
|
- [Quick Start Guide](./docs/QUICK_START.md) - Get started in 5 minutes
|
|
288
|
+
- [Recovery & Backup System](./docs/RECOVERY.md) - Three-layer backup architecture
|
|
236
289
|
- [Browser Compatibility](./docs/BROWSER_COMPATIBILITY.md) - Supported browsers, devices, and OS versions
|
|
237
290
|
- [Security Architecture](./docs/SECURITY.md) - Integration best practices
|
|
238
291
|
- [ERC-5564 Stealth Addresses](./docs/ERC5564_STEALTH_ADDRESSES.md) - Complete guide with examples
|
package/dist/index.d.mts
CHANGED
|
@@ -424,6 +424,108 @@ declare class Web3Passkey {
|
|
|
424
424
|
* Access ZK proof module (if available)
|
|
425
425
|
*/
|
|
426
426
|
get zk(): any;
|
|
427
|
+
/**
|
|
428
|
+
* Get comprehensive backup status
|
|
429
|
+
* Shows user exactly what protects their wallet
|
|
430
|
+
*/
|
|
431
|
+
getBackupStatus(): Promise<any>;
|
|
432
|
+
/**
|
|
433
|
+
* Create password-protected ZIP backup
|
|
434
|
+
* @param password - Strong password to encrypt the backup
|
|
435
|
+
* @param options - Optional backup configuration
|
|
436
|
+
*/
|
|
437
|
+
createZipBackup(password: string, options?: {
|
|
438
|
+
includeInstructions?: boolean;
|
|
439
|
+
deviceBinding?: boolean;
|
|
440
|
+
}): Promise<Blob>;
|
|
441
|
+
/**
|
|
442
|
+
* Create QR code backup
|
|
443
|
+
* @param password - Optional password to encrypt QR code
|
|
444
|
+
* @param options - QR code configuration
|
|
445
|
+
*/
|
|
446
|
+
createQRBackup(password?: string, options?: {
|
|
447
|
+
errorCorrection?: "L" | "M" | "Q" | "H";
|
|
448
|
+
}): Promise<{
|
|
449
|
+
qrCodeDataURL: string;
|
|
450
|
+
instructions: string;
|
|
451
|
+
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Set up social recovery
|
|
454
|
+
* Splits mnemonic into M-of-N shares for guardian-based recovery
|
|
455
|
+
*
|
|
456
|
+
* @param guardians - Array of guardian information
|
|
457
|
+
* @param threshold - Number of guardians required to recover (M in M-of-N)
|
|
458
|
+
*/
|
|
459
|
+
setupSocialRecovery(guardians: {
|
|
460
|
+
name: string;
|
|
461
|
+
email?: string;
|
|
462
|
+
phone?: string;
|
|
463
|
+
}[], threshold: number): Promise<any[]>;
|
|
464
|
+
/**
|
|
465
|
+
* Generate guardian invitation
|
|
466
|
+
* Creates QR code and instructions for a guardian
|
|
467
|
+
*/
|
|
468
|
+
generateGuardianInvite(guardianId: string): Promise<any>;
|
|
469
|
+
/**
|
|
470
|
+
* Recover wallet from guardian shares
|
|
471
|
+
* @param shares - Array of share data from guardians (JSON strings)
|
|
472
|
+
*/
|
|
473
|
+
recoverFromGuardians(shares: string[]): Promise<{
|
|
474
|
+
mnemonic: string;
|
|
475
|
+
ethereumAddress: string;
|
|
476
|
+
}>;
|
|
477
|
+
/**
|
|
478
|
+
* Restore wallet from encrypted backup
|
|
479
|
+
* @param backupData - Backup file contents (JSON string)
|
|
480
|
+
* @param password - Password used to encrypt the backup
|
|
481
|
+
*/
|
|
482
|
+
restoreFromBackup(backupData: string, password: string): Promise<{
|
|
483
|
+
mnemonic: string;
|
|
484
|
+
ethereumAddress: string;
|
|
485
|
+
}>;
|
|
486
|
+
/**
|
|
487
|
+
* Restore wallet from QR code
|
|
488
|
+
* @param qrData - Scanned QR code data (JSON string)
|
|
489
|
+
* @param password - Optional password if QR was encrypted
|
|
490
|
+
*/
|
|
491
|
+
restoreFromQR(qrData: string, password?: string): Promise<{
|
|
492
|
+
mnemonic: string;
|
|
493
|
+
ethereumAddress: string;
|
|
494
|
+
}>;
|
|
495
|
+
/**
|
|
496
|
+
* Get cross-device sync status
|
|
497
|
+
* Shows which devices have access and sync capabilities
|
|
498
|
+
*/
|
|
499
|
+
getSyncStatus(): Promise<any>;
|
|
500
|
+
/**
|
|
501
|
+
* Detect sync capabilities
|
|
502
|
+
* Shows what platform sync is available (iCloud, Google, etc.)
|
|
503
|
+
*/
|
|
504
|
+
detectSyncCapabilities(): Promise<any>;
|
|
505
|
+
/**
|
|
506
|
+
* Simulate recovery scenario (educational)
|
|
507
|
+
* Tests what happens in various loss scenarios
|
|
508
|
+
*
|
|
509
|
+
* @param scenario - Type of scenario to simulate
|
|
510
|
+
*/
|
|
511
|
+
simulateRecoveryScenario(scenario: {
|
|
512
|
+
type: "lost-device" | "lost-phrase" | "lost-both" | "switch-platform";
|
|
513
|
+
description: string;
|
|
514
|
+
}): Promise<any>;
|
|
515
|
+
/**
|
|
516
|
+
* Run interactive recovery test
|
|
517
|
+
* Tests all recovery scenarios and provides feedback
|
|
518
|
+
*/
|
|
519
|
+
runRecoveryTest(): Promise<{
|
|
520
|
+
scenarios: any[];
|
|
521
|
+
overallScore: number;
|
|
522
|
+
feedback: string;
|
|
523
|
+
}>;
|
|
524
|
+
/**
|
|
525
|
+
* Get educational content
|
|
526
|
+
* @param topic - Topic to explain (e.g., 'whatIsPasskey', 'socialRecoveryExplained')
|
|
527
|
+
*/
|
|
528
|
+
getEducation(topic: string): Promise<any>;
|
|
427
529
|
/**
|
|
428
530
|
* Check if there's an active session
|
|
429
531
|
*/
|
|
@@ -485,6 +587,523 @@ declare function deriveWalletFromMnemonic(mnemonic: string, index?: number): {
|
|
|
485
587
|
privateKey: string;
|
|
486
588
|
};
|
|
487
589
|
|
|
590
|
+
/**
|
|
591
|
+
* Backup and Recovery Type Definitions
|
|
592
|
+
*/
|
|
593
|
+
interface BackupStatus {
|
|
594
|
+
passkeySync: PasskeySyncStatus;
|
|
595
|
+
recoveryPhrase: RecoveryPhraseStatus;
|
|
596
|
+
socialRecovery?: SocialRecoveryStatus;
|
|
597
|
+
securityScore: SecurityScore;
|
|
598
|
+
}
|
|
599
|
+
interface PasskeySyncStatus {
|
|
600
|
+
enabled: boolean;
|
|
601
|
+
deviceCount: number;
|
|
602
|
+
lastSyncTime?: number;
|
|
603
|
+
platform: 'apple' | 'google' | 'microsoft' | 'unknown';
|
|
604
|
+
}
|
|
605
|
+
interface RecoveryPhraseStatus {
|
|
606
|
+
verified: boolean;
|
|
607
|
+
verificationCount: number;
|
|
608
|
+
lastVerified?: number;
|
|
609
|
+
encryptedBackups: EncryptedBackupInfo[];
|
|
610
|
+
}
|
|
611
|
+
interface EncryptedBackupInfo {
|
|
612
|
+
id: string;
|
|
613
|
+
method: 'zip' | 'qr' | 'file';
|
|
614
|
+
location: string;
|
|
615
|
+
createdAt: number;
|
|
616
|
+
deviceFingerprint?: string;
|
|
617
|
+
}
|
|
618
|
+
interface SocialRecoveryStatus {
|
|
619
|
+
enabled: boolean;
|
|
620
|
+
guardians: Guardian$1[];
|
|
621
|
+
threshold: number;
|
|
622
|
+
sharesDistributed: number;
|
|
623
|
+
verifiedGuardians: number;
|
|
624
|
+
}
|
|
625
|
+
interface Guardian$1 {
|
|
626
|
+
id: string;
|
|
627
|
+
name: string;
|
|
628
|
+
email?: string;
|
|
629
|
+
publicKey?: string;
|
|
630
|
+
shareEncrypted: string;
|
|
631
|
+
status: 'pending' | 'active' | 'revoked';
|
|
632
|
+
addedAt: number;
|
|
633
|
+
lastVerified?: number;
|
|
634
|
+
}
|
|
635
|
+
interface SecurityScore {
|
|
636
|
+
total: number;
|
|
637
|
+
breakdown: {
|
|
638
|
+
passkeyActive: number;
|
|
639
|
+
passkeyMultiDevice: number;
|
|
640
|
+
phraseVerified: number;
|
|
641
|
+
encryptedBackup: number;
|
|
642
|
+
socialRecovery: number;
|
|
643
|
+
};
|
|
644
|
+
level: 'vulnerable' | 'protected' | 'secured' | 'fort-knox';
|
|
645
|
+
nextMilestone: string;
|
|
646
|
+
}
|
|
647
|
+
interface BackupMetadata {
|
|
648
|
+
id: string;
|
|
649
|
+
ethereumAddress: string;
|
|
650
|
+
method: 'zip' | 'qr' | 'file';
|
|
651
|
+
createdAt: number;
|
|
652
|
+
deviceFingerprint?: string;
|
|
653
|
+
addressChecksum: string;
|
|
654
|
+
}
|
|
655
|
+
interface ZipBackupOptions {
|
|
656
|
+
password: string;
|
|
657
|
+
includeInstructions?: boolean;
|
|
658
|
+
deviceBinding?: boolean;
|
|
659
|
+
}
|
|
660
|
+
interface QRBackupOptions {
|
|
661
|
+
password?: string;
|
|
662
|
+
errorCorrection?: 'L' | 'M' | 'Q' | 'H';
|
|
663
|
+
}
|
|
664
|
+
interface RecoveryScenario {
|
|
665
|
+
type: 'lost-device' | 'lost-phrase' | 'lost-both' | 'switch-platform';
|
|
666
|
+
description: string;
|
|
667
|
+
}
|
|
668
|
+
interface SimulationResult {
|
|
669
|
+
scenario: RecoveryScenario;
|
|
670
|
+
success: boolean;
|
|
671
|
+
availableMethods: RecoveryMethod[];
|
|
672
|
+
timeEstimate: string;
|
|
673
|
+
educationalNote: string;
|
|
674
|
+
}
|
|
675
|
+
interface RecoveryMethod {
|
|
676
|
+
method: string;
|
|
677
|
+
success: boolean;
|
|
678
|
+
time: string;
|
|
679
|
+
requirements: string[];
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Main Backup Manager
|
|
684
|
+
* Orchestrates all backup and recovery operations
|
|
685
|
+
*/
|
|
686
|
+
|
|
687
|
+
declare class BackupManager {
|
|
688
|
+
private storage;
|
|
689
|
+
private zipCreator;
|
|
690
|
+
private qrCreator;
|
|
691
|
+
constructor();
|
|
692
|
+
/**
|
|
693
|
+
* Get comprehensive backup status
|
|
694
|
+
* Shows user exactly what protects their wallet
|
|
695
|
+
*/
|
|
696
|
+
getBackupStatus(ethereumAddress: string): Promise<BackupStatus>;
|
|
697
|
+
/**
|
|
698
|
+
* Detect passkey sync capabilities
|
|
699
|
+
*/
|
|
700
|
+
private detectPasskeySync;
|
|
701
|
+
/**
|
|
702
|
+
* Check if platform supports resident keys (required for passkey sync)
|
|
703
|
+
*/
|
|
704
|
+
private checkResidentKeySupport;
|
|
705
|
+
/**
|
|
706
|
+
* Calculate security score
|
|
707
|
+
*/
|
|
708
|
+
private calculateSecurityScore;
|
|
709
|
+
/**
|
|
710
|
+
* Create password-protected ZIP backup
|
|
711
|
+
*/
|
|
712
|
+
createZipBackup(mnemonic: string, ethereumAddress: string, options: ZipBackupOptions): Promise<Blob>;
|
|
713
|
+
/**
|
|
714
|
+
* Create QR code backup
|
|
715
|
+
*/
|
|
716
|
+
createQRBackup(mnemonic: string, ethereumAddress: string, options?: QRBackupOptions): Promise<{
|
|
717
|
+
qrCodeDataURL: string;
|
|
718
|
+
instructions: string;
|
|
719
|
+
}>;
|
|
720
|
+
/**
|
|
721
|
+
* Restore from ZIP backup
|
|
722
|
+
*/
|
|
723
|
+
restoreFromZipBackup(backupData: string, password: string): Promise<{
|
|
724
|
+
mnemonic: string;
|
|
725
|
+
ethereumAddress: string;
|
|
726
|
+
}>;
|
|
727
|
+
/**
|
|
728
|
+
* Restore from QR backup
|
|
729
|
+
*/
|
|
730
|
+
restoreFromQR(qrData: string, password?: string): Promise<{
|
|
731
|
+
mnemonic: string;
|
|
732
|
+
ethereumAddress: string;
|
|
733
|
+
}>;
|
|
734
|
+
/**
|
|
735
|
+
* Simulate recovery scenario (educational)
|
|
736
|
+
*/
|
|
737
|
+
simulateRecoveryScenario(scenario: RecoveryScenario, currentStatus: BackupStatus): Promise<SimulationResult>;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* IndexedDB Storage for Backup Metadata
|
|
742
|
+
*/
|
|
743
|
+
|
|
744
|
+
declare class BackupStorage {
|
|
745
|
+
private dbName;
|
|
746
|
+
private version;
|
|
747
|
+
private db;
|
|
748
|
+
/**
|
|
749
|
+
* Initialize the database
|
|
750
|
+
*/
|
|
751
|
+
init(): Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Store backup metadata
|
|
754
|
+
*/
|
|
755
|
+
storeBackupMetadata(metadata: BackupMetadata): Promise<void>;
|
|
756
|
+
/**
|
|
757
|
+
* Get all backups for an address
|
|
758
|
+
*/
|
|
759
|
+
getBackupsByAddress(ethereumAddress: string): Promise<BackupMetadata[]>;
|
|
760
|
+
/**
|
|
761
|
+
* Get backup by ID
|
|
762
|
+
*/
|
|
763
|
+
getBackupById(id: string): Promise<BackupMetadata | null>;
|
|
764
|
+
/**
|
|
765
|
+
* Delete backup metadata
|
|
766
|
+
*/
|
|
767
|
+
deleteBackup(id: string): Promise<void>;
|
|
768
|
+
/**
|
|
769
|
+
* Get count of backups by method
|
|
770
|
+
*/
|
|
771
|
+
getBackupCountByMethod(method: 'zip' | 'qr' | 'file'): Promise<number>;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Social Recovery Type Definitions
|
|
776
|
+
*/
|
|
777
|
+
interface Guardian {
|
|
778
|
+
id: string;
|
|
779
|
+
name: string;
|
|
780
|
+
email?: string;
|
|
781
|
+
phone?: string;
|
|
782
|
+
publicKey?: string;
|
|
783
|
+
shareEncrypted: string;
|
|
784
|
+
status: 'pending' | 'active' | 'revoked';
|
|
785
|
+
addedAt: number;
|
|
786
|
+
lastVerified?: number;
|
|
787
|
+
}
|
|
788
|
+
interface GuardianInvite {
|
|
789
|
+
guardianId: string;
|
|
790
|
+
qrCode: string;
|
|
791
|
+
shareCode: string;
|
|
792
|
+
explainer: string;
|
|
793
|
+
link?: string;
|
|
794
|
+
}
|
|
795
|
+
interface SocialRecoveryConfig {
|
|
796
|
+
threshold: number;
|
|
797
|
+
totalGuardians: number;
|
|
798
|
+
guardians: Guardian[];
|
|
799
|
+
createdAt: number;
|
|
800
|
+
ethereumAddress: string;
|
|
801
|
+
}
|
|
802
|
+
interface RecoveryShare {
|
|
803
|
+
guardianId: string;
|
|
804
|
+
share: string;
|
|
805
|
+
index: number;
|
|
806
|
+
}
|
|
807
|
+
interface RecoveryProgress {
|
|
808
|
+
collected: number;
|
|
809
|
+
required: number;
|
|
810
|
+
guardians: {
|
|
811
|
+
id: string;
|
|
812
|
+
name: string;
|
|
813
|
+
hasProvided: boolean;
|
|
814
|
+
}[];
|
|
815
|
+
canRecover: boolean;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Social Recovery Manager
|
|
820
|
+
* Manages guardian-based wallet recovery using Shamir Secret Sharing
|
|
821
|
+
*/
|
|
822
|
+
|
|
823
|
+
declare class SocialRecoveryManager {
|
|
824
|
+
private storageKey;
|
|
825
|
+
/**
|
|
826
|
+
* Get storage (localStorage or in-memory fallback)
|
|
827
|
+
*/
|
|
828
|
+
private getItem;
|
|
829
|
+
/**
|
|
830
|
+
* Set storage (localStorage or in-memory fallback)
|
|
831
|
+
*/
|
|
832
|
+
private setItem;
|
|
833
|
+
/**
|
|
834
|
+
* Set up social recovery
|
|
835
|
+
* Splits mnemonic into M-of-N shares and distributes to guardians
|
|
836
|
+
*/
|
|
837
|
+
setupSocialRecovery(mnemonic: string, ethereumAddress: string, guardians: {
|
|
838
|
+
name: string;
|
|
839
|
+
email?: string;
|
|
840
|
+
phone?: string;
|
|
841
|
+
}[], threshold: number): Promise<Guardian[]>;
|
|
842
|
+
/**
|
|
843
|
+
* Get current social recovery configuration
|
|
844
|
+
*/
|
|
845
|
+
getSocialRecoveryConfig(): SocialRecoveryConfig | null;
|
|
846
|
+
/**
|
|
847
|
+
* Generate guardian invitation
|
|
848
|
+
* Creates QR code and educational materials for guardian
|
|
849
|
+
*/
|
|
850
|
+
generateGuardianInvite(guardian: Guardian): Promise<GuardianInvite>;
|
|
851
|
+
/**
|
|
852
|
+
* Generate QR code from share data
|
|
853
|
+
*/
|
|
854
|
+
private generateQRCode;
|
|
855
|
+
/**
|
|
856
|
+
* Create placeholder QR code
|
|
857
|
+
*/
|
|
858
|
+
private createPlaceholderQR;
|
|
859
|
+
/**
|
|
860
|
+
* Wrap text for display
|
|
861
|
+
*/
|
|
862
|
+
private wrapText;
|
|
863
|
+
/**
|
|
864
|
+
* Get guardian explainer text
|
|
865
|
+
*/
|
|
866
|
+
private getGuardianExplainer;
|
|
867
|
+
/**
|
|
868
|
+
* Recover mnemonic from guardian shares
|
|
869
|
+
*/
|
|
870
|
+
recoverFromGuardians(shareData: string[]): Promise<{
|
|
871
|
+
mnemonic: string;
|
|
872
|
+
ethereumAddress: string;
|
|
873
|
+
}>;
|
|
874
|
+
/**
|
|
875
|
+
* Get recovery progress
|
|
876
|
+
*/
|
|
877
|
+
getRecoveryProgress(collectedShares: string[]): RecoveryProgress;
|
|
878
|
+
/**
|
|
879
|
+
* Mark guardian as verified
|
|
880
|
+
*/
|
|
881
|
+
markGuardianVerified(guardianId: string): void;
|
|
882
|
+
/**
|
|
883
|
+
* Revoke a guardian
|
|
884
|
+
*/
|
|
885
|
+
revokeGuardian(guardianId: string): void;
|
|
886
|
+
/**
|
|
887
|
+
* Add new guardian (requires re-sharing)
|
|
888
|
+
*/
|
|
889
|
+
addGuardian(mnemonic: string, newGuardian: {
|
|
890
|
+
name: string;
|
|
891
|
+
email?: string;
|
|
892
|
+
phone?: string;
|
|
893
|
+
}): Promise<Guardian>;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Cross-Device Sync Type Definitions
|
|
898
|
+
*/
|
|
899
|
+
interface SyncVault {
|
|
900
|
+
id: string;
|
|
901
|
+
encryptedData: string;
|
|
902
|
+
deviceFingerprints: string[];
|
|
903
|
+
syncMethod: 'icloud' | 'google' | 'microsoft' | 'custom';
|
|
904
|
+
version: number;
|
|
905
|
+
updatedAt: number;
|
|
906
|
+
}
|
|
907
|
+
interface DeviceInfo {
|
|
908
|
+
id: string;
|
|
909
|
+
name: string;
|
|
910
|
+
platform: 'ios' | 'android' | 'macos' | 'windows' | 'linux' | 'unknown';
|
|
911
|
+
lastActive: number;
|
|
912
|
+
trusted: boolean;
|
|
913
|
+
canRevoke: boolean;
|
|
914
|
+
}
|
|
915
|
+
interface SyncCapabilities {
|
|
916
|
+
passkeysSync: boolean;
|
|
917
|
+
platform: 'apple' | 'google' | 'microsoft' | 'none';
|
|
918
|
+
estimatedDevices: number;
|
|
919
|
+
syncEnabled: boolean;
|
|
920
|
+
}
|
|
921
|
+
interface SyncStatus {
|
|
922
|
+
enabled: boolean;
|
|
923
|
+
devices: DeviceInfo[];
|
|
924
|
+
lastSyncTime?: number;
|
|
925
|
+
platform: string;
|
|
926
|
+
}
|
|
927
|
+
interface SyncResult {
|
|
928
|
+
success: boolean;
|
|
929
|
+
steps: SyncStep[];
|
|
930
|
+
}
|
|
931
|
+
interface SyncStep {
|
|
932
|
+
title: string;
|
|
933
|
+
action: string;
|
|
934
|
+
educational: string;
|
|
935
|
+
status: 'waiting' | 'in-progress' | 'completed' | 'failed';
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Encrypted Sync Vault
|
|
940
|
+
* Manages encrypted wallet data for cross-device sync
|
|
941
|
+
*/
|
|
942
|
+
|
|
943
|
+
declare class VaultSync {
|
|
944
|
+
/**
|
|
945
|
+
* Create encrypted sync package
|
|
946
|
+
* Uses passkey + device fingerprint for encryption
|
|
947
|
+
*/
|
|
948
|
+
createSyncPackage(mnemonic: string, credentialId: string, publicKey: string): Promise<SyncVault>;
|
|
949
|
+
/**
|
|
950
|
+
* Detect available sync method
|
|
951
|
+
*/
|
|
952
|
+
private detectSyncMethod;
|
|
953
|
+
/**
|
|
954
|
+
* Restore from sync vault
|
|
955
|
+
* Interactive guide for multi-device setup
|
|
956
|
+
*/
|
|
957
|
+
restoreFromSync(vault: SyncVault, credentialId: string, publicKey: string): Promise<string>;
|
|
958
|
+
/**
|
|
959
|
+
* Get setup flow for new device
|
|
960
|
+
* Educational flow with step-by-step instructions
|
|
961
|
+
*/
|
|
962
|
+
getSetupFlow(): Promise<SyncResult>;
|
|
963
|
+
/**
|
|
964
|
+
* Educational message about how sync works
|
|
965
|
+
*/
|
|
966
|
+
getSyncExplainer(): string;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Device Manager
|
|
971
|
+
* Track and manage trusted devices with wallet access
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
declare class DeviceManager {
|
|
975
|
+
private storageKey;
|
|
976
|
+
/**
|
|
977
|
+
* Register current device
|
|
978
|
+
*/
|
|
979
|
+
registerDevice(): Promise<DeviceInfo>;
|
|
980
|
+
/**
|
|
981
|
+
* Get all registered devices
|
|
982
|
+
*/
|
|
983
|
+
getDevices(): Promise<DeviceInfo[]>;
|
|
984
|
+
/**
|
|
985
|
+
* Get sync status with device list
|
|
986
|
+
*/
|
|
987
|
+
getSyncStatus(): Promise<SyncStatus>;
|
|
988
|
+
/**
|
|
989
|
+
* Revoke a device
|
|
990
|
+
*/
|
|
991
|
+
revokeDevice(deviceId: string): Promise<void>;
|
|
992
|
+
/**
|
|
993
|
+
* Update device last active timestamp
|
|
994
|
+
*/
|
|
995
|
+
updateLastActive(): Promise<void>;
|
|
996
|
+
/**
|
|
997
|
+
* Get device name
|
|
998
|
+
*/
|
|
999
|
+
private getDeviceName;
|
|
1000
|
+
/**
|
|
1001
|
+
* Detect device platform
|
|
1002
|
+
*/
|
|
1003
|
+
private detectPlatform;
|
|
1004
|
+
/**
|
|
1005
|
+
* Get platform display name
|
|
1006
|
+
*/
|
|
1007
|
+
private getPlatformName;
|
|
1008
|
+
/**
|
|
1009
|
+
* Get formatted device list for display
|
|
1010
|
+
*/
|
|
1011
|
+
getDeviceListFormatted(): Promise<string>;
|
|
1012
|
+
/**
|
|
1013
|
+
* Format time difference for display
|
|
1014
|
+
*/
|
|
1015
|
+
private formatTimeDiff;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Platform Detection for Passkey Sync
|
|
1020
|
+
* Detects available sync platforms (iCloud, Google, Microsoft)
|
|
1021
|
+
*/
|
|
1022
|
+
|
|
1023
|
+
declare class PlatformDetector {
|
|
1024
|
+
/**
|
|
1025
|
+
* Detect available sync capabilities
|
|
1026
|
+
* Shows what's automatically protecting the user
|
|
1027
|
+
*/
|
|
1028
|
+
detectSyncCapabilities(): Promise<SyncCapabilities>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Detect user's platform
|
|
1031
|
+
*/
|
|
1032
|
+
private detectPlatform;
|
|
1033
|
+
/**
|
|
1034
|
+
* Check if passkey sync is supported
|
|
1035
|
+
*/
|
|
1036
|
+
private checkPasskeySync;
|
|
1037
|
+
/**
|
|
1038
|
+
* Estimate number of synced devices
|
|
1039
|
+
* Note: This is a rough estimate, actual count requires server-side tracking
|
|
1040
|
+
*/
|
|
1041
|
+
private estimateDeviceCount;
|
|
1042
|
+
/**
|
|
1043
|
+
* Get platform-specific educational message
|
|
1044
|
+
*/
|
|
1045
|
+
getPlatformEducation(platform: 'apple' | 'google' | 'microsoft' | 'none'): string;
|
|
1046
|
+
/**
|
|
1047
|
+
* Get sync setup instructions
|
|
1048
|
+
*/
|
|
1049
|
+
getSyncInstructions(platform: 'apple' | 'google' | 'microsoft' | 'none'): string[];
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Recovery Scenario Simulator
|
|
1054
|
+
* Educational tool to help users understand recovery options
|
|
1055
|
+
*/
|
|
1056
|
+
|
|
1057
|
+
declare class RecoverySimulator {
|
|
1058
|
+
/**
|
|
1059
|
+
* Predefined recovery scenarios
|
|
1060
|
+
*/
|
|
1061
|
+
getScenarios(): RecoveryScenario[];
|
|
1062
|
+
/**
|
|
1063
|
+
* Simulate a recovery scenario
|
|
1064
|
+
*/
|
|
1065
|
+
simulateScenario(scenario: RecoveryScenario, currentStatus: BackupStatus): Promise<SimulationResult>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Estimate fastest recovery time
|
|
1068
|
+
*/
|
|
1069
|
+
private estimateFastestRecovery;
|
|
1070
|
+
/**
|
|
1071
|
+
* Get educational note for scenario
|
|
1072
|
+
*/
|
|
1073
|
+
private getEducationalNote;
|
|
1074
|
+
/**
|
|
1075
|
+
* Run interactive test
|
|
1076
|
+
*/
|
|
1077
|
+
runInteractiveTest(currentStatus: BackupStatus): Promise<{
|
|
1078
|
+
scenarios: SimulationResult[];
|
|
1079
|
+
overallScore: number;
|
|
1080
|
+
feedback: string;
|
|
1081
|
+
}>;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Educational Content
|
|
1086
|
+
* Explainers for users to understand security concepts
|
|
1087
|
+
*/
|
|
1088
|
+
interface EducationalModule {
|
|
1089
|
+
title: string;
|
|
1090
|
+
content: string;
|
|
1091
|
+
visual?: string;
|
|
1092
|
+
interactive?: string;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Get explainer by topic
|
|
1096
|
+
*/
|
|
1097
|
+
declare function getExplainer(topic: string): EducationalModule | null;
|
|
1098
|
+
/**
|
|
1099
|
+
* Get all explainer topics
|
|
1100
|
+
*/
|
|
1101
|
+
declare function getAllTopics(): string[];
|
|
1102
|
+
/**
|
|
1103
|
+
* Search explainers
|
|
1104
|
+
*/
|
|
1105
|
+
declare function searchExplainers(query: string): EducationalModule[];
|
|
1106
|
+
|
|
488
1107
|
/**
|
|
489
1108
|
* Web3 Passkey SDK
|
|
490
1109
|
* Passwordless authentication with encrypted wallets
|
|
@@ -492,4 +1111,4 @@ declare function deriveWalletFromMnemonic(mnemonic: string, index?: number): {
|
|
|
492
1111
|
|
|
493
1112
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
494
1113
|
|
|
495
|
-
export { ApiError, AuthenticationError, CryptoError, RegistrationError, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, canControlStealthAddress, checkStealthAddress, computeStealthPrivateKey, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveStealthKeys, deriveWalletFromMnemonic, generateBIP39Wallet, generateStealthAddress };
|
|
1114
|
+
export { ApiError, AuthenticationError, BackupManager, type BackupStatus, BackupStorage, CryptoError, type DeviceInfo, DeviceManager, type EncryptedBackupInfo, type Guardian, type GuardianInvite, PlatformDetector, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SimulationResult, type SocialRecoveryConfig, SocialRecoveryManager, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, VaultSync, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, type ZipBackupOptions, canControlStealthAddress, checkStealthAddress, computeStealthPrivateKey, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveStealthKeys, deriveWalletFromMnemonic, generateBIP39Wallet, generateStealthAddress, getAllTopics, getExplainer, searchExplainers };
|