w3pk 0.7.0 → 0.7.2

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 CHANGED
@@ -19,8 +19,8 @@ import { createWeb3Passkey } from 'w3pk'
19
19
  const w3pk = createWeb3Passkey()
20
20
 
21
21
  // Register (auto-generates wallet and stores it securely)
22
- const { mnemonic } = await w3pk.register({ username: 'alice' })
23
- console.log('⚠️ Save this recovery phrase:', mnemonic)
22
+ const { address, username } = await w3pk.register({ username: 'alice' })
23
+ console.log(' Registered:', username, 'with address:', address)
24
24
 
25
25
  // Login (for subsequent sessions)
26
26
  await w3pk.login()
@@ -46,26 +46,22 @@ const rpcUrl = endpoints[0]
46
46
  - 🌱 HD wallet generation (BIP39/BIP44)
47
47
  - 🔢 Multi-address derivation
48
48
  - 🥷 ERC-5564 stealth addresses (privacy-preserving transactions with view tags)
49
+ - 🧮 ZK primitives (zero-knowledge proof generation and verification)
49
50
  - 🔗 Chainlist support (2390+ networks, auto-filtered RPC endpoints)
50
51
  - ⚡ EIP-7702 network detection (329+ supported networks)
51
-
52
- **Optional: Zero-Knowledge Proofs**
53
-
54
- Requires additional dependencies (~70MB):
55
- ```bash
56
- npm install snarkjs circomlibjs
57
- ```
58
-
59
- See [ZK Integration Guide](./docs/ZK_INTEGRATION_GUIDE.md) to get started.
52
+ - 🛡️ Three-layer backup & recovery system
53
+ - Passkey auto-sync (iCloud/Google/Microsoft)
54
+ - Encrypted backups (ZIP/QR with password protection)
55
+ - Social recovery (Shamir Secret Sharing)
60
56
 
61
57
  ## API
62
58
 
63
59
  ### Authentication Flow
64
60
 
65
61
  ```typescript
66
- // Register (auto-stores wallet)
67
- const { mnemonic } = await w3pk.register({ username: 'alice' })
68
- // Returns: { mnemonic } - SAVE THIS!
62
+ // Register (generates and stores wallet securely)
63
+ const { address, username } = await w3pk.register({ username: 'alice' })
64
+ // Returns: { address, username }
69
65
 
70
66
  // Subsequent sessions: just login
71
67
  await w3pk.login()
@@ -78,12 +74,15 @@ w3pk.isAuthenticated
78
74
  w3pk.user
79
75
  ```
80
76
 
81
- **Advanced: Pre-generate wallet (optional)**
77
+ **Important: Backup your wallet!**
82
78
  ```typescript
83
- // If you want to see the wallet before registering:
84
- const { mnemonic } = await w3pk.generateWallet()
85
- const { mnemonic } = await w3pk.register({ username: 'alice' })
86
- // register() will use the pre-generated wallet
79
+ // After registration, users can create a backup
80
+ const mnemonic = await w3pk.exportMnemonic({ requireAuth: true })
81
+ console.log('⚠️ Save this recovery phrase:', mnemonic)
82
+
83
+ // Or create encrypted backups:
84
+ const zipBackup = await w3pk.createZipBackup('strong-password')
85
+ const qrBackup = await w3pk.createQRBackup('optional-password')
87
86
  ```
88
87
 
89
88
  ### Wallet Operations
@@ -218,6 +217,63 @@ if (result.isForUser) {
218
217
  const myPayments = await w3pk.stealth?.scanAnnouncements(announcements)
219
218
  ```
220
219
 
220
+ ### Backup & Recovery
221
+
222
+ ```typescript
223
+ import { isStrongPassword } from 'w3pk'
224
+
225
+ // Validate password strength before creating backups
226
+ const password = 'MyS3cur3!Password@2042'
227
+ if (!isStrongPassword(password)) {
228
+ throw new Error('Password does not meet security requirements')
229
+ }
230
+ // Requirements: 12+ chars, uppercase, lowercase, number, special char, not common
231
+
232
+ // Get backup status
233
+ const status = await w3pk.getBackupStatus()
234
+ console.log('Security Score:', status.securityScore.score) // 0-100
235
+
236
+ // Create encrypted ZIP backup
237
+ const blob = await w3pk.createZipBackup(password)
238
+ // Save blob to file system
239
+
240
+ // Create QR backup
241
+ const { qrCodeDataURL } = await w3pk.createQRBackup('password')
242
+ // Display QR code or save as image
243
+
244
+ // Setup social recovery (3-of-5 guardians)
245
+ await w3pk.setupSocialRecovery(
246
+ [
247
+ { name: 'Alice', email: 'alice@example.com' },
248
+ { name: 'Bob', phone: '+1234567890' },
249
+ { name: 'Charlie' }
250
+ ],
251
+ 3 // threshold
252
+ )
253
+
254
+ // Generate guardian invite
255
+ const invite = await w3pk.generateGuardianInvite(guardianId)
256
+ // Share invite.qrCode or invite.shareCode with guardian
257
+
258
+ // Recover from guardian shares
259
+ const { mnemonic } = await w3pk.recoverFromGuardians([
260
+ share1, share2, share3
261
+ ])
262
+
263
+ // Restore from backup
264
+ await w3pk.restoreFromBackup(encryptedData, password)
265
+
266
+ // Simulate recovery scenarios for testing
267
+ const result = await w3pk.simulateRecoveryScenario({
268
+ type: 'lost-device',
269
+ hasBackup: true,
270
+ hasSocialRecovery: true
271
+ })
272
+ console.log('Can recover:', result.canRecover)
273
+ ```
274
+
275
+ See [Recovery Guide](./docs/RECOVERY.md) for complete documentation.
276
+
221
277
  ## Browser Compatibility
222
278
 
223
279
  **Supported (95%+ of users):**
@@ -233,6 +289,7 @@ const myPayments = await w3pk.stealth?.scanAnnouncements(announcements)
233
289
  ## Documentation
234
290
 
235
291
  - [Quick Start Guide](./docs/QUICK_START.md) - Get started in 5 minutes
292
+ - [Recovery & Backup System](./docs/RECOVERY.md) - Three-layer backup architecture
236
293
  - [Browser Compatibility](./docs/BROWSER_COMPATIBILITY.md) - Supported browsers, devices, and OS versions
237
294
  - [Security Architecture](./docs/SECURITY.md) - Integration best practices
238
295
  - [ERC-5564 Stealth Addresses](./docs/ERC5564_STEALTH_ADDRESSES.md) - Complete guide with examples