w3pk 0.9.2 → 0.9.3
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 +11 -5
- package/dist/index.d.mts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +30 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -25
- package/dist/index.mjs.map +1 -1
- package/docs/API_REFERENCE.md +90 -34
- package/docs/RECOVERY.md +138 -99
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -355,8 +355,13 @@ console.log('Security Score:', status.securityScore.total) // 0-100
|
|
|
355
355
|
// Create encrypted backup file
|
|
356
356
|
const { blob, filename } = await w3pk.createBackupFile('password', password)
|
|
357
357
|
|
|
358
|
-
// Setup social recovery (M-of-N guardians)
|
|
359
|
-
|
|
358
|
+
// Setup social recovery (M-of-N guardians) - guardians store backup file fragments
|
|
359
|
+
import { SocialRecoveryManager } from 'w3pk'
|
|
360
|
+
const backupFileJson = await blob.text()
|
|
361
|
+
const socialRecovery = new SocialRecoveryManager()
|
|
362
|
+
const guardians = await socialRecovery.setupSocialRecovery(
|
|
363
|
+
backupFileJson,
|
|
364
|
+
w3pk.user.ethereumAddress,
|
|
360
365
|
[
|
|
361
366
|
{ name: 'Alice', email: 'alice@example.com' },
|
|
362
367
|
{ name: 'Bob', phone: '+1234567890' },
|
|
@@ -366,10 +371,11 @@ await w3pk.setupSocialRecovery(
|
|
|
366
371
|
)
|
|
367
372
|
|
|
368
373
|
// Generate guardian invite
|
|
369
|
-
const invite = await
|
|
374
|
+
const invite = await socialRecovery.generateGuardianInvite(guardians[0])
|
|
370
375
|
|
|
371
|
-
// Recover from guardian shares
|
|
372
|
-
const {
|
|
376
|
+
// Recover from guardian shares - reconstructs encrypted backup file
|
|
377
|
+
const { backupFileJson } = await socialRecovery.recoverFromGuardians([share1, share2])
|
|
378
|
+
await w3pk.registerWithBackupFile(backupFileJson, password, 'username')
|
|
373
379
|
|
|
374
380
|
// Restore from backup file
|
|
375
381
|
await w3pk.restoreFromBackupFile(encryptedData, password)
|
package/dist/index.d.mts
CHANGED
|
@@ -1753,6 +1753,93 @@ interface RecoveryProgress {
|
|
|
1753
1753
|
canRecover: boolean;
|
|
1754
1754
|
}
|
|
1755
1755
|
|
|
1756
|
+
/**
|
|
1757
|
+
* Social Recovery Manager
|
|
1758
|
+
* Manages guardian-based wallet recovery using Shamir Secret Sharing
|
|
1759
|
+
*/
|
|
1760
|
+
|
|
1761
|
+
declare class SocialRecoveryManager {
|
|
1762
|
+
private storageKey;
|
|
1763
|
+
/**
|
|
1764
|
+
* Get storage (localStorage or in-memory fallback)
|
|
1765
|
+
*/
|
|
1766
|
+
private getItem;
|
|
1767
|
+
/**
|
|
1768
|
+
* Set storage (localStorage or in-memory fallback)
|
|
1769
|
+
*/
|
|
1770
|
+
private setItem;
|
|
1771
|
+
/**
|
|
1772
|
+
* Set up social recovery
|
|
1773
|
+
* Splits encrypted backup file into M-of-N shares and distributes to guardians
|
|
1774
|
+
*
|
|
1775
|
+
* @param backupFileJson - The complete backup file JSON string (password-encrypted)
|
|
1776
|
+
* @param ethereumAddress - The Ethereum address for verification
|
|
1777
|
+
* @param guardians - Array of guardian information
|
|
1778
|
+
* @param threshold - Minimum number of guardians needed for recovery
|
|
1779
|
+
*/
|
|
1780
|
+
setupSocialRecovery(backupFileJson: string, ethereumAddress: string, guardians: {
|
|
1781
|
+
name: string;
|
|
1782
|
+
email?: string;
|
|
1783
|
+
phone?: string;
|
|
1784
|
+
}[], threshold: number): Promise<Guardian[]>;
|
|
1785
|
+
/**
|
|
1786
|
+
* Get current social recovery configuration
|
|
1787
|
+
*/
|
|
1788
|
+
getSocialRecoveryConfig(): SocialRecoveryConfig | null;
|
|
1789
|
+
/**
|
|
1790
|
+
* Generate guardian invitation
|
|
1791
|
+
* Creates QR code and educational materials for guardian
|
|
1792
|
+
*/
|
|
1793
|
+
generateGuardianInvite(guardian: Guardian): Promise<GuardianInvite>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Generate QR code from share data
|
|
1796
|
+
* Uses 'qrcode' library if available, falls back to canvas text
|
|
1797
|
+
*/
|
|
1798
|
+
private generateQRCode;
|
|
1799
|
+
/**
|
|
1800
|
+
* Create fallback QR representation
|
|
1801
|
+
*/
|
|
1802
|
+
private createPlaceholderQR;
|
|
1803
|
+
/**
|
|
1804
|
+
* Wrap text for display
|
|
1805
|
+
*/
|
|
1806
|
+
private wrapText;
|
|
1807
|
+
/**
|
|
1808
|
+
* Get guardian explainer text
|
|
1809
|
+
*/
|
|
1810
|
+
private getGuardianExplainer;
|
|
1811
|
+
/**
|
|
1812
|
+
* Recover backup file from guardian shares
|
|
1813
|
+
* Returns the reconstructed backup file JSON that can be used with restoreFromBackupFile()
|
|
1814
|
+
*/
|
|
1815
|
+
recoverFromGuardians(shareData: string[]): Promise<{
|
|
1816
|
+
backupFileJson: string;
|
|
1817
|
+
ethereumAddress: string;
|
|
1818
|
+
}>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Get recovery progress
|
|
1821
|
+
*/
|
|
1822
|
+
getRecoveryProgress(collectedShares: string[]): RecoveryProgress;
|
|
1823
|
+
/**
|
|
1824
|
+
* Mark guardian as verified
|
|
1825
|
+
* Note: This updates guardian status but does NOT automatically refresh security score.
|
|
1826
|
+
* The security score will be updated on the next call to BackupManager.getBackupStatus()
|
|
1827
|
+
*/
|
|
1828
|
+
markGuardianVerified(guardianId: string): void;
|
|
1829
|
+
/**
|
|
1830
|
+
* Revoke a guardian
|
|
1831
|
+
*/
|
|
1832
|
+
revokeGuardian(guardianId: string): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Add new guardian (requires re-sharing with new backup file)
|
|
1835
|
+
*/
|
|
1836
|
+
addGuardian(backupFileJson: string, newGuardian: {
|
|
1837
|
+
name: string;
|
|
1838
|
+
email?: string;
|
|
1839
|
+
phone?: string;
|
|
1840
|
+
}): Promise<Guardian>;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1756
1843
|
/**
|
|
1757
1844
|
* Cross-Device Sync Type Definitions
|
|
1758
1845
|
*/
|
|
@@ -1982,4 +2069,4 @@ declare function inspectNow(options?: BrowserInspectOptions): Promise<void>;
|
|
|
1982
2069
|
|
|
1983
2070
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
1984
2071
|
|
|
1985
|
-
export { ApiError, AuthenticationError, type BackupStatus, type BrowserInspectOptions, type BrowserInspectResult, CryptoError, DEFAULT_MODE, DEFAULT_TAG, type DeviceInfo, type EIP1193Provider, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type PasskeySelectionResult, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SiweMessage, 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, arrayBufferToBase64Url, assertEthereumAddress, assertMnemonic, assertUsername, authenticateWithPasskey, base64ToArrayBuffer, base64UrlDecode, base64UrlToArrayBuffer, canControlStealthAddress, checkStealthAddress, clearCache, computeStealthPrivateKey, createSiweMessage, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveAddressFromP256PublicKey, deriveIndexFromOriginModeAndTag, deriveStealthKeys, deriveWalletFromMnemonic, detectWalletProvider, encodeEIP7702AuthorizationMessage, extractRS, generateBIP39Wallet, generateSiweNonce, generateStealthAddress, getAllChains, getAllTopics, getChainById, getCurrentBuildHash, getCurrentOrigin, getDefaultProvider, getEndpoints, getExplainer, getOriginSpecificAddress, getPackageVersion, getW3pkBuildHash, hashEIP7702AuthorizationMessage, inspect, inspectNow, isStrongPassword, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|
|
2072
|
+
export { ApiError, AuthenticationError, type BackupStatus, type BrowserInspectOptions, type BrowserInspectResult, CryptoError, DEFAULT_MODE, DEFAULT_TAG, type DeviceInfo, type EIP1193Provider, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type PasskeySelectionResult, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SiweMessage, type SocialRecoveryConfig, SocialRecoveryManager, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, arrayBufferToBase64Url, assertEthereumAddress, assertMnemonic, assertUsername, authenticateWithPasskey, base64ToArrayBuffer, base64UrlDecode, base64UrlToArrayBuffer, canControlStealthAddress, checkStealthAddress, clearCache, computeStealthPrivateKey, createSiweMessage, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveAddressFromP256PublicKey, deriveIndexFromOriginModeAndTag, deriveStealthKeys, deriveWalletFromMnemonic, detectWalletProvider, encodeEIP7702AuthorizationMessage, extractRS, generateBIP39Wallet, generateSiweNonce, generateStealthAddress, getAllChains, getAllTopics, getChainById, getCurrentBuildHash, getCurrentOrigin, getDefaultProvider, getEndpoints, getExplainer, getOriginSpecificAddress, getPackageVersion, getW3pkBuildHash, hashEIP7702AuthorizationMessage, inspect, inspectNow, isStrongPassword, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1753,6 +1753,93 @@ interface RecoveryProgress {
|
|
|
1753
1753
|
canRecover: boolean;
|
|
1754
1754
|
}
|
|
1755
1755
|
|
|
1756
|
+
/**
|
|
1757
|
+
* Social Recovery Manager
|
|
1758
|
+
* Manages guardian-based wallet recovery using Shamir Secret Sharing
|
|
1759
|
+
*/
|
|
1760
|
+
|
|
1761
|
+
declare class SocialRecoveryManager {
|
|
1762
|
+
private storageKey;
|
|
1763
|
+
/**
|
|
1764
|
+
* Get storage (localStorage or in-memory fallback)
|
|
1765
|
+
*/
|
|
1766
|
+
private getItem;
|
|
1767
|
+
/**
|
|
1768
|
+
* Set storage (localStorage or in-memory fallback)
|
|
1769
|
+
*/
|
|
1770
|
+
private setItem;
|
|
1771
|
+
/**
|
|
1772
|
+
* Set up social recovery
|
|
1773
|
+
* Splits encrypted backup file into M-of-N shares and distributes to guardians
|
|
1774
|
+
*
|
|
1775
|
+
* @param backupFileJson - The complete backup file JSON string (password-encrypted)
|
|
1776
|
+
* @param ethereumAddress - The Ethereum address for verification
|
|
1777
|
+
* @param guardians - Array of guardian information
|
|
1778
|
+
* @param threshold - Minimum number of guardians needed for recovery
|
|
1779
|
+
*/
|
|
1780
|
+
setupSocialRecovery(backupFileJson: string, ethereumAddress: string, guardians: {
|
|
1781
|
+
name: string;
|
|
1782
|
+
email?: string;
|
|
1783
|
+
phone?: string;
|
|
1784
|
+
}[], threshold: number): Promise<Guardian[]>;
|
|
1785
|
+
/**
|
|
1786
|
+
* Get current social recovery configuration
|
|
1787
|
+
*/
|
|
1788
|
+
getSocialRecoveryConfig(): SocialRecoveryConfig | null;
|
|
1789
|
+
/**
|
|
1790
|
+
* Generate guardian invitation
|
|
1791
|
+
* Creates QR code and educational materials for guardian
|
|
1792
|
+
*/
|
|
1793
|
+
generateGuardianInvite(guardian: Guardian): Promise<GuardianInvite>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Generate QR code from share data
|
|
1796
|
+
* Uses 'qrcode' library if available, falls back to canvas text
|
|
1797
|
+
*/
|
|
1798
|
+
private generateQRCode;
|
|
1799
|
+
/**
|
|
1800
|
+
* Create fallback QR representation
|
|
1801
|
+
*/
|
|
1802
|
+
private createPlaceholderQR;
|
|
1803
|
+
/**
|
|
1804
|
+
* Wrap text for display
|
|
1805
|
+
*/
|
|
1806
|
+
private wrapText;
|
|
1807
|
+
/**
|
|
1808
|
+
* Get guardian explainer text
|
|
1809
|
+
*/
|
|
1810
|
+
private getGuardianExplainer;
|
|
1811
|
+
/**
|
|
1812
|
+
* Recover backup file from guardian shares
|
|
1813
|
+
* Returns the reconstructed backup file JSON that can be used with restoreFromBackupFile()
|
|
1814
|
+
*/
|
|
1815
|
+
recoverFromGuardians(shareData: string[]): Promise<{
|
|
1816
|
+
backupFileJson: string;
|
|
1817
|
+
ethereumAddress: string;
|
|
1818
|
+
}>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Get recovery progress
|
|
1821
|
+
*/
|
|
1822
|
+
getRecoveryProgress(collectedShares: string[]): RecoveryProgress;
|
|
1823
|
+
/**
|
|
1824
|
+
* Mark guardian as verified
|
|
1825
|
+
* Note: This updates guardian status but does NOT automatically refresh security score.
|
|
1826
|
+
* The security score will be updated on the next call to BackupManager.getBackupStatus()
|
|
1827
|
+
*/
|
|
1828
|
+
markGuardianVerified(guardianId: string): void;
|
|
1829
|
+
/**
|
|
1830
|
+
* Revoke a guardian
|
|
1831
|
+
*/
|
|
1832
|
+
revokeGuardian(guardianId: string): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Add new guardian (requires re-sharing with new backup file)
|
|
1835
|
+
*/
|
|
1836
|
+
addGuardian(backupFileJson: string, newGuardian: {
|
|
1837
|
+
name: string;
|
|
1838
|
+
email?: string;
|
|
1839
|
+
phone?: string;
|
|
1840
|
+
}): Promise<Guardian>;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1756
1843
|
/**
|
|
1757
1844
|
* Cross-Device Sync Type Definitions
|
|
1758
1845
|
*/
|
|
@@ -1982,4 +2069,4 @@ declare function inspectNow(options?: BrowserInspectOptions): Promise<void>;
|
|
|
1982
2069
|
|
|
1983
2070
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
1984
2071
|
|
|
1985
|
-
export { ApiError, AuthenticationError, type BackupStatus, type BrowserInspectOptions, type BrowserInspectResult, CryptoError, DEFAULT_MODE, DEFAULT_TAG, type DeviceInfo, type EIP1193Provider, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type PasskeySelectionResult, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SiweMessage, 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, arrayBufferToBase64Url, assertEthereumAddress, assertMnemonic, assertUsername, authenticateWithPasskey, base64ToArrayBuffer, base64UrlDecode, base64UrlToArrayBuffer, canControlStealthAddress, checkStealthAddress, clearCache, computeStealthPrivateKey, createSiweMessage, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveAddressFromP256PublicKey, deriveIndexFromOriginModeAndTag, deriveStealthKeys, deriveWalletFromMnemonic, detectWalletProvider, encodeEIP7702AuthorizationMessage, extractRS, generateBIP39Wallet, generateSiweNonce, generateStealthAddress, getAllChains, getAllTopics, getChainById, getCurrentBuildHash, getCurrentOrigin, getDefaultProvider, getEndpoints, getExplainer, getOriginSpecificAddress, getPackageVersion, getW3pkBuildHash, hashEIP7702AuthorizationMessage, inspect, inspectNow, isStrongPassword, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|
|
2072
|
+
export { ApiError, AuthenticationError, type BackupStatus, type BrowserInspectOptions, type BrowserInspectResult, CryptoError, DEFAULT_MODE, DEFAULT_TAG, type DeviceInfo, type EIP1193Provider, type EIP7702Authorization, type EncryptedBackupInfo, type Guardian, type GuardianInvite, type PasskeySelectionResult, type QRBackupOptions, type RecoveryProgress, type RecoveryScenario, type RecoveryShare, RecoverySimulator, RegistrationError, type SecurityScore, type SignAuthorizationParams, type SimulationResult, type SiweMessage, type SocialRecoveryConfig, SocialRecoveryManager, type StealthAddressConfig, StealthAddressModule, type StealthAddressResult, type StealthKeys, StorageError, type SyncCapabilities, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, arrayBufferToBase64Url, assertEthereumAddress, assertMnemonic, assertUsername, authenticateWithPasskey, base64ToArrayBuffer, base64UrlDecode, base64UrlToArrayBuffer, canControlStealthAddress, checkStealthAddress, clearCache, computeStealthPrivateKey, createSiweMessage, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveAddressFromP256PublicKey, deriveIndexFromOriginModeAndTag, deriveStealthKeys, deriveWalletFromMnemonic, detectWalletProvider, encodeEIP7702AuthorizationMessage, extractRS, generateBIP39Wallet, generateSiweNonce, generateStealthAddress, getAllChains, getAllTopics, getChainById, getCurrentBuildHash, getCurrentOrigin, getDefaultProvider, getEndpoints, getExplainer, getOriginSpecificAddress, getPackageVersion, getW3pkBuildHash, hashEIP7702AuthorizationMessage, inspect, inspectNow, isStrongPassword, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|