w3pk 0.10.2 → 0.10.4
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 +1 -8
- package/dist/chainlist/index.d.mts +96 -0
- package/dist/chainlist/index.d.ts +96 -0
- package/dist/index.d.mts +237 -113
- package/dist/index.d.ts +237 -113
- package/dist/index.js +31 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -31
- package/dist/index.mjs.map +1 -1
- package/dist/zk/index.js +3 -3
- package/dist/zk/index.js.map +1 -1
- package/dist/zk/index.mjs +4 -4
- package/dist/zk/index.mjs.map +1 -1
- package/dist/zk/utils.js +3 -3
- package/dist/zk/utils.js.map +1 -1
- package/dist/zk/utils.mjs +3 -3
- package/dist/zk/utils.mjs.map +1 -1
- package/docs/API_REFERENCE.md +191 -38
- package/docs/ARCHITECTURE.md +14 -13
- package/docs/BROWSER_COMPATIBILITY.md +24 -0
- package/docs/INTEGRATION_GUIDELINES.md +45 -20
- package/docs/PORTABILITY.md +66 -0
- package/docs/POST_QUANTUM.md +236 -1468
- package/docs/QUICK_START.md +4 -4
- package/docs/RECOVERY.md +93 -49
- package/docs/SECURITY.md +65 -58
- package/docs/notes/IFRAME_IMPLEMENTATION_PLAN.md +197 -0
- package/docs/notes/JULY_13_ROADMAP.md +29 -0
- package/docs/notes/NOTES.md +333 -0
- package/docs/notes/SIWE_IMPLEMENTATION.md +129 -0
- package/docs/notes/SYNCING_ACROSS_DEVICES.md +127 -0
- package/docs/notes/ethereum-post-quantum-roadmap.md +213 -0
- package/docs/notes/wulong-building-finding.md +109 -0
- package/package.json +43 -25
package/README.md
CHANGED
|
@@ -512,11 +512,4 @@ GPL-3.0
|
|
|
512
512
|
|
|
513
513
|
## Contact
|
|
514
514
|
|
|
515
|
-
|
|
516
|
-
- Element: [@julienbrg:matrix.org](https://matrix.to/#/@julienbrg:matrix.org)
|
|
517
|
-
- Farcaster: [julien-](https://warpcast.com/julien-)
|
|
518
|
-
- Telegram: [@julienbrg](https://t.me/julienbrg)
|
|
519
|
-
- Twitter: [@julienbrg](https://twitter.com/julienbrg)
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
<img src="https://bafkreid5xwxz4bed67bxb2wjmwsec4uhlcjviwy7pkzwoyu5oesjd3sp64.ipfs.w3s.link" alt="built-with-ethereum-w3hc" width="100"/>
|
|
515
|
+
Questions or feedback? Get in touch with [Julien](https://github.com/julienbrg): [https://julienberanger.com/contact](https://julienberanger.com/contact)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chainlist types
|
|
3
|
+
*/
|
|
4
|
+
interface Chain {
|
|
5
|
+
name: string;
|
|
6
|
+
chain: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
rpc: string[];
|
|
9
|
+
features?: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
}>;
|
|
12
|
+
faucets: string[];
|
|
13
|
+
nativeCurrency: {
|
|
14
|
+
name: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
decimals: number;
|
|
17
|
+
};
|
|
18
|
+
infoURL: string;
|
|
19
|
+
shortName: string;
|
|
20
|
+
chainId: number;
|
|
21
|
+
networkId: number;
|
|
22
|
+
slip44?: number;
|
|
23
|
+
ens?: {
|
|
24
|
+
registry: string;
|
|
25
|
+
};
|
|
26
|
+
explorers?: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
url: string;
|
|
29
|
+
icon?: string;
|
|
30
|
+
standard: string;
|
|
31
|
+
}>;
|
|
32
|
+
title?: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
redFlags?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface ChainlistOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Custom URL for chains.json data
|
|
39
|
+
* @default 'https://chainid.network/chains.json'
|
|
40
|
+
*/
|
|
41
|
+
chainsJsonUrl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Cache duration in milliseconds
|
|
44
|
+
* @default 3600000 (1 hour)
|
|
45
|
+
*/
|
|
46
|
+
cacheDuration?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Chainlist module for fetching RPC endpoints
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get RPC endpoints for a specific chain ID, excluding those that require API keys
|
|
55
|
+
*
|
|
56
|
+
* @param chainId - The chain ID to get endpoints for
|
|
57
|
+
* @param options - Optional configuration
|
|
58
|
+
* @returns Array of RPC URLs that don't require API keys
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { getEndpoints } from 'w3pk/chainlist'
|
|
63
|
+
*
|
|
64
|
+
* // Get Ethereum mainnet RPCs
|
|
65
|
+
* const endpoints = await getEndpoints(1)
|
|
66
|
+
* console.log(endpoints)
|
|
67
|
+
* // [
|
|
68
|
+
* // "https://api.mycryptoapi.com/eth",
|
|
69
|
+
* // "https://cloudflare-eth.com",
|
|
70
|
+
* // "https://ethereum-rpc.publicnode.com",
|
|
71
|
+
* // ...
|
|
72
|
+
* // ]
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function getEndpoints(chainId: number, options?: ChainlistOptions): Promise<string[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Get all available chains
|
|
78
|
+
*
|
|
79
|
+
* @param options - Optional configuration
|
|
80
|
+
* @returns Array of all chains
|
|
81
|
+
*/
|
|
82
|
+
declare function getAllChains(options?: ChainlistOptions): Promise<Chain[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Get chain information by chain ID
|
|
85
|
+
*
|
|
86
|
+
* @param chainId - The chain ID to get information for
|
|
87
|
+
* @param options - Optional configuration
|
|
88
|
+
* @returns Chain information or undefined if not found
|
|
89
|
+
*/
|
|
90
|
+
declare function getChainById(chainId: number, options?: ChainlistOptions): Promise<Chain | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear the chains data cache
|
|
93
|
+
*/
|
|
94
|
+
declare function clearCache(): void;
|
|
95
|
+
|
|
96
|
+
export { type Chain, type ChainlistOptions, clearCache, getAllChains, getChainById, getEndpoints };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chainlist types
|
|
3
|
+
*/
|
|
4
|
+
interface Chain {
|
|
5
|
+
name: string;
|
|
6
|
+
chain: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
rpc: string[];
|
|
9
|
+
features?: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
}>;
|
|
12
|
+
faucets: string[];
|
|
13
|
+
nativeCurrency: {
|
|
14
|
+
name: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
decimals: number;
|
|
17
|
+
};
|
|
18
|
+
infoURL: string;
|
|
19
|
+
shortName: string;
|
|
20
|
+
chainId: number;
|
|
21
|
+
networkId: number;
|
|
22
|
+
slip44?: number;
|
|
23
|
+
ens?: {
|
|
24
|
+
registry: string;
|
|
25
|
+
};
|
|
26
|
+
explorers?: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
url: string;
|
|
29
|
+
icon?: string;
|
|
30
|
+
standard: string;
|
|
31
|
+
}>;
|
|
32
|
+
title?: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
redFlags?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface ChainlistOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Custom URL for chains.json data
|
|
39
|
+
* @default 'https://chainid.network/chains.json'
|
|
40
|
+
*/
|
|
41
|
+
chainsJsonUrl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Cache duration in milliseconds
|
|
44
|
+
* @default 3600000 (1 hour)
|
|
45
|
+
*/
|
|
46
|
+
cacheDuration?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Chainlist module for fetching RPC endpoints
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get RPC endpoints for a specific chain ID, excluding those that require API keys
|
|
55
|
+
*
|
|
56
|
+
* @param chainId - The chain ID to get endpoints for
|
|
57
|
+
* @param options - Optional configuration
|
|
58
|
+
* @returns Array of RPC URLs that don't require API keys
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { getEndpoints } from 'w3pk/chainlist'
|
|
63
|
+
*
|
|
64
|
+
* // Get Ethereum mainnet RPCs
|
|
65
|
+
* const endpoints = await getEndpoints(1)
|
|
66
|
+
* console.log(endpoints)
|
|
67
|
+
* // [
|
|
68
|
+
* // "https://api.mycryptoapi.com/eth",
|
|
69
|
+
* // "https://cloudflare-eth.com",
|
|
70
|
+
* // "https://ethereum-rpc.publicnode.com",
|
|
71
|
+
* // ...
|
|
72
|
+
* // ]
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function getEndpoints(chainId: number, options?: ChainlistOptions): Promise<string[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Get all available chains
|
|
78
|
+
*
|
|
79
|
+
* @param options - Optional configuration
|
|
80
|
+
* @returns Array of all chains
|
|
81
|
+
*/
|
|
82
|
+
declare function getAllChains(options?: ChainlistOptions): Promise<Chain[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Get chain information by chain ID
|
|
85
|
+
*
|
|
86
|
+
* @param chainId - The chain ID to get information for
|
|
87
|
+
* @param options - Optional configuration
|
|
88
|
+
* @returns Chain information or undefined if not found
|
|
89
|
+
*/
|
|
90
|
+
declare function getChainById(chainId: number, options?: ChainlistOptions): Promise<Chain | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear the chains data cache
|
|
93
|
+
*/
|
|
94
|
+
declare function clearCache(): void;
|
|
95
|
+
|
|
96
|
+
export { type Chain, type ChainlistOptions, clearCache, getAllChains, getChainById, getEndpoints };
|
package/dist/index.d.mts
CHANGED
|
@@ -246,6 +246,47 @@ declare class StealthAddressModule {
|
|
|
246
246
|
get isAvailable(): boolean;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
/** Client extension results consumed by w3pk (subset of the WebAuthn spec) */
|
|
250
|
+
interface PrfExtensionResults {
|
|
251
|
+
prf?: {
|
|
252
|
+
enabled?: boolean;
|
|
253
|
+
results?: {
|
|
254
|
+
first?: ArrayBuffer;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Native WebAuthn credential response (authentication)
|
|
260
|
+
*/
|
|
261
|
+
interface AuthenticationCredential {
|
|
262
|
+
id: string;
|
|
263
|
+
rawId: ArrayBuffer;
|
|
264
|
+
type: 'public-key';
|
|
265
|
+
response: {
|
|
266
|
+
clientDataJSON: ArrayBuffer;
|
|
267
|
+
authenticatorData: ArrayBuffer;
|
|
268
|
+
signature: ArrayBuffer;
|
|
269
|
+
userHandle?: ArrayBuffer;
|
|
270
|
+
};
|
|
271
|
+
getClientExtensionResults(): PrfExtensionResults;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* WebAuthn PRF evaluation
|
|
276
|
+
*
|
|
277
|
+
* The PRF extension releases HMAC(credential secret, salt) only on a live,
|
|
278
|
+
* user-verified assertion. The browser hashes each input as
|
|
279
|
+
* SHA-256("WebAuthn PRF" || 0x00 || input) before it reaches the
|
|
280
|
+
* authenticator, so inputs here can be any bytes.
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
interface PrfSecret {
|
|
284
|
+
/** 32-byte secret for this origin and tag */
|
|
285
|
+
secret: Uint8Array;
|
|
286
|
+
/** Credential the secret is bound to; a new credential gives a new secret */
|
|
287
|
+
credentialId: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
249
290
|
/**
|
|
250
291
|
* Shared types used across the SDK
|
|
251
292
|
*/
|
|
@@ -379,6 +420,40 @@ declare class ApiError extends Web3PasskeyError {
|
|
|
379
420
|
statusCode?: number | undefined;
|
|
380
421
|
constructor(message: string, statusCode?: number | undefined, originalError?: unknown);
|
|
381
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* The passkey authenticated, but this device has no credential metadata.
|
|
425
|
+
* The app should start a sync or restore flow.
|
|
426
|
+
*/
|
|
427
|
+
declare class SyncRequiredError extends Web3PasskeyError {
|
|
428
|
+
credentialId: string;
|
|
429
|
+
constructor(credentialId: string);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* The credential metadata is on this device, but the wallet record is gone.
|
|
433
|
+
* The app should offer a restore from backup.
|
|
434
|
+
*/
|
|
435
|
+
declare class WalletMissingError extends Web3PasskeyError {
|
|
436
|
+
credentialId: string;
|
|
437
|
+
ethereumAddress: string;
|
|
438
|
+
constructor(credentialId: string, ethereumAddress: string);
|
|
439
|
+
}
|
|
440
|
+
type SyncBootstrapReason = "PASSKEY_BACKUP" | "NO_CREDENTIAL" | "CREDENTIAL_MISMATCH" | "PUBLIC_KEY_MISMATCH";
|
|
441
|
+
/**
|
|
442
|
+
* A sync can't set up this device's passkey metadata from the backup.
|
|
443
|
+
*/
|
|
444
|
+
declare class SyncBootstrapError extends Web3PasskeyError {
|
|
445
|
+
reason: SyncBootstrapReason;
|
|
446
|
+
credentialId: string;
|
|
447
|
+
constructor(reason: SyncBootstrapReason, credentialId: string);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* The authenticator returned no WebAuthn PRF output, so no
|
|
451
|
+
* passkey-bound secret can be derived. There is no fallback.
|
|
452
|
+
*/
|
|
453
|
+
declare class PrfUnsupportedError extends Web3PasskeyError {
|
|
454
|
+
credentialId: string;
|
|
455
|
+
constructor(credentialId: string);
|
|
456
|
+
}
|
|
382
457
|
|
|
383
458
|
/**
|
|
384
459
|
* Persistent Session Storage
|
|
@@ -391,9 +466,11 @@ declare class ApiError extends Web3PasskeyError {
|
|
|
391
466
|
* user-verified assertion. Nothing stored on disk can re-derive it.
|
|
392
467
|
* - requireReauth: true → the key is NOT stored; every restore re-evaluates
|
|
393
468
|
* the PRF on a live assertion. The blob is hardware-bound at rest.
|
|
394
|
-
* - requireReauth: false → the key is stored
|
|
395
|
-
*
|
|
396
|
-
*
|
|
469
|
+
* - requireReauth: false → the raw key is stored next to the blob so silent
|
|
470
|
+
* restore works without a prompt, and re-imported as non-extractable. Any
|
|
471
|
+
* script on the origin can read it, which adds little: it could already
|
|
472
|
+
* use a stored key to decrypt. It is refreshed at every real (prompted)
|
|
473
|
+
* login.
|
|
397
474
|
* - Authenticators without PRF get no persistent sessions (in-memory only) —
|
|
398
475
|
* there is deliberately no weaker fallback encryption.
|
|
399
476
|
* - Only enabled for STANDARD and YOLO modes (STRICT mode excluded)
|
|
@@ -462,6 +539,90 @@ interface Web3PasskeyConfig {
|
|
|
462
539
|
zkProofs?: ZKProofConfig;
|
|
463
540
|
}
|
|
464
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Backup and Recovery Type Definitions
|
|
544
|
+
*/
|
|
545
|
+
type BackupMethod = 'file' | 'qr' | 'phrase';
|
|
546
|
+
interface BackupStatus {
|
|
547
|
+
hasBackup: boolean;
|
|
548
|
+
evictionRisk: boolean;
|
|
549
|
+
lastBackupAt?: string;
|
|
550
|
+
methods: BackupMethod[];
|
|
551
|
+
passkeySync: PasskeySyncStatus;
|
|
552
|
+
recoveryPhrase: RecoveryPhraseStatus;
|
|
553
|
+
socialRecovery?: SocialRecoveryStatus;
|
|
554
|
+
securityScore: SecurityScore;
|
|
555
|
+
}
|
|
556
|
+
interface PasskeySyncStatus {
|
|
557
|
+
enabled: boolean;
|
|
558
|
+
deviceCount: number;
|
|
559
|
+
lastSyncTime?: string;
|
|
560
|
+
platform: 'apple' | 'google' | 'microsoft' | 'unknown';
|
|
561
|
+
}
|
|
562
|
+
interface RecoveryPhraseStatus {
|
|
563
|
+
verified: boolean;
|
|
564
|
+
verificationCount: number;
|
|
565
|
+
lastVerified?: string;
|
|
566
|
+
encryptedBackups: EncryptedBackupInfo[];
|
|
567
|
+
}
|
|
568
|
+
interface EncryptedBackupInfo {
|
|
569
|
+
id: string;
|
|
570
|
+
method: 'qr' | 'file';
|
|
571
|
+
location: string;
|
|
572
|
+
createdAt: string;
|
|
573
|
+
deviceFingerprint?: string;
|
|
574
|
+
}
|
|
575
|
+
interface SocialRecoveryStatus {
|
|
576
|
+
enabled: boolean;
|
|
577
|
+
guardians: Guardian$1[];
|
|
578
|
+
threshold: number;
|
|
579
|
+
sharesDistributed: number;
|
|
580
|
+
verifiedGuardians: number;
|
|
581
|
+
}
|
|
582
|
+
interface Guardian$1 {
|
|
583
|
+
id: string;
|
|
584
|
+
name: string;
|
|
585
|
+
email?: string;
|
|
586
|
+
publicKey?: string;
|
|
587
|
+
shareEncrypted: string;
|
|
588
|
+
status: 'pending' | 'active' | 'revoked';
|
|
589
|
+
addedAt: string;
|
|
590
|
+
lastVerified?: string;
|
|
591
|
+
}
|
|
592
|
+
interface SecurityScore {
|
|
593
|
+
total: number;
|
|
594
|
+
breakdown: {
|
|
595
|
+
passkeyActive: number;
|
|
596
|
+
passkeyMultiDevice: number;
|
|
597
|
+
phraseVerified: number;
|
|
598
|
+
encryptedBackup: number;
|
|
599
|
+
socialRecovery: number;
|
|
600
|
+
};
|
|
601
|
+
level: 'vulnerable' | 'protected' | 'secured' | 'fort-knox';
|
|
602
|
+
nextMilestone: string;
|
|
603
|
+
}
|
|
604
|
+
interface QRBackupOptions {
|
|
605
|
+
password?: string;
|
|
606
|
+
errorCorrection?: 'L' | 'M' | 'Q' | 'H';
|
|
607
|
+
}
|
|
608
|
+
interface RecoveryScenario {
|
|
609
|
+
type: 'lost-device' | 'lost-phrase' | 'lost-both' | 'switch-platform';
|
|
610
|
+
description: string;
|
|
611
|
+
}
|
|
612
|
+
interface SimulationResult {
|
|
613
|
+
scenario: RecoveryScenario;
|
|
614
|
+
success: boolean;
|
|
615
|
+
availableMethods: RecoveryMethod[];
|
|
616
|
+
timeEstimate: string;
|
|
617
|
+
educationalNote: string;
|
|
618
|
+
}
|
|
619
|
+
interface RecoveryMethod {
|
|
620
|
+
method: string;
|
|
621
|
+
success: boolean;
|
|
622
|
+
time: string;
|
|
623
|
+
requirements: string[];
|
|
624
|
+
}
|
|
625
|
+
|
|
465
626
|
/**
|
|
466
627
|
* Main Web3Passkey SDK
|
|
467
628
|
*
|
|
@@ -495,6 +656,7 @@ declare class Web3Passkey {
|
|
|
495
656
|
private walletStorage;
|
|
496
657
|
private currentUser;
|
|
497
658
|
private currentWallet;
|
|
659
|
+
private persisted;
|
|
498
660
|
private sessionManager;
|
|
499
661
|
stealth?: StealthAddressModule;
|
|
500
662
|
private zkModule?;
|
|
@@ -518,6 +680,8 @@ declare class Web3Passkey {
|
|
|
518
680
|
}): Promise<{
|
|
519
681
|
address: string;
|
|
520
682
|
username: string;
|
|
683
|
+
hasBackup: boolean;
|
|
684
|
+
evictionRisk: boolean;
|
|
521
685
|
}>;
|
|
522
686
|
/**
|
|
523
687
|
* Login with WebAuthn using resident credentials
|
|
@@ -540,6 +704,14 @@ declare class Web3Passkey {
|
|
|
540
704
|
logout(): Promise<void>;
|
|
541
705
|
get isAuthenticated(): boolean;
|
|
542
706
|
get user(): UserInfo | null;
|
|
707
|
+
/**
|
|
708
|
+
* Whether the browser granted persistent storage (`navigator.storage.persist()`),
|
|
709
|
+
* requested after each register, login and restore: true means the origin's
|
|
710
|
+
* storage is exempt from storage-pressure eviction. null until the browser
|
|
711
|
+
* answers (Firefox asks the user), or where the API is missing.
|
|
712
|
+
*/
|
|
713
|
+
get storagePersisted(): boolean | null;
|
|
714
|
+
private requestPersistentStorage;
|
|
543
715
|
/**
|
|
544
716
|
* List existing credentials (usernames and addresses)
|
|
545
717
|
* Useful for allowing users to select which wallet to login to
|
|
@@ -874,7 +1046,12 @@ declare class Web3Passkey {
|
|
|
874
1046
|
/**
|
|
875
1047
|
* Get backup status
|
|
876
1048
|
*/
|
|
877
|
-
getBackupStatus(): Promise<
|
|
1049
|
+
getBackupStatus(): Promise<BackupStatus>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Record that the user wrote down their recovery phrase
|
|
1052
|
+
* Call it once the user confirms, so getBackupStatus() reports a backup
|
|
1053
|
+
*/
|
|
1054
|
+
confirmRecoveryPhraseBackup(): Promise<void>;
|
|
878
1055
|
/**
|
|
879
1056
|
* Create simplified backup file
|
|
880
1057
|
* This backup can be used to:
|
|
@@ -890,6 +1067,7 @@ declare class Web3Passkey {
|
|
|
890
1067
|
blob: Blob;
|
|
891
1068
|
filename: string;
|
|
892
1069
|
}>;
|
|
1070
|
+
private backupCredential;
|
|
893
1071
|
/**
|
|
894
1072
|
* Set up social recovery by splitting backup file among guardians
|
|
895
1073
|
* Uses Shamir Secret Sharing to split the backup - requires M-of-N guardians to recover
|
|
@@ -949,6 +1127,9 @@ declare class Web3Passkey {
|
|
|
949
1127
|
*
|
|
950
1128
|
* This allows the user to use the same PRIMARY mode webauthn account on multiple devices.
|
|
951
1129
|
*
|
|
1130
|
+
* A PRF backup (from exportForSync()) takes a single assertion restricted
|
|
1131
|
+
* to its passkey and no password.
|
|
1132
|
+
*
|
|
952
1133
|
* @param backupData - Backup file (JSON string or Blob) - can be pasted by user
|
|
953
1134
|
* @param password - Password to decrypt backup (if password-encrypted)
|
|
954
1135
|
* @returns Restored wallet info
|
|
@@ -957,6 +1138,18 @@ declare class Web3Passkey {
|
|
|
957
1138
|
mnemonic: string;
|
|
958
1139
|
ethereumAddress: string;
|
|
959
1140
|
}>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Restore a PRF backup with its passkey and set this device up for it.
|
|
1143
|
+
* The public key is this device's when it has the passkey's metadata,
|
|
1144
|
+
* else the backup's, checked against the assertion's signature.
|
|
1145
|
+
*/
|
|
1146
|
+
private restorePrfBackup;
|
|
1147
|
+
/**
|
|
1148
|
+
* Set this device up for a passkey and a synced wallet: saves the
|
|
1149
|
+
* passkey's metadata (or points it at the wallet), stores the wallet
|
|
1150
|
+
* under the passkey-derived key and starts a session
|
|
1151
|
+
*/
|
|
1152
|
+
private bootstrapCredential;
|
|
960
1153
|
/**
|
|
961
1154
|
* Register new passkey with wallet from backup file
|
|
962
1155
|
* Use case: Fresh device, user has backup file but no passkey yet
|
|
@@ -977,16 +1170,30 @@ declare class Web3Passkey {
|
|
|
977
1170
|
getSyncStatus(): Promise<any>;
|
|
978
1171
|
/**
|
|
979
1172
|
* Export wallet for syncing to another device
|
|
980
|
-
*
|
|
1173
|
+
*
|
|
1174
|
+
* Prompts for the passkey and encrypts with a key derived from its WebAuthn
|
|
1175
|
+
* PRF output (`encryptionMethod: 'prf'`): a device where the passkey synced
|
|
1176
|
+
* restores it with one prompt and no password. Where the authenticator has
|
|
1177
|
+
* no PRF support, `password` makes it fall back to a password backup.
|
|
1178
|
+
*
|
|
1179
|
+
* @param password - Fallback password when PRF is unavailable
|
|
1180
|
+
* @throws PrfUnsupportedError when PRF is unavailable and no password is given
|
|
981
1181
|
*/
|
|
982
|
-
exportForSync(): Promise<{
|
|
1182
|
+
exportForSync(password?: string): Promise<{
|
|
983
1183
|
blob: Blob;
|
|
984
1184
|
filename: string;
|
|
985
1185
|
qrCode?: string;
|
|
986
1186
|
}>;
|
|
987
1187
|
/**
|
|
988
1188
|
* Import wallet from another device (sync wallet to this device)
|
|
989
|
-
*
|
|
1189
|
+
*
|
|
1190
|
+
* Takes a PRF backup from exportForSync(): one assertion restricted to
|
|
1191
|
+
* the backup's passkey decrypts it, with no password, on any device where
|
|
1192
|
+
* the passkey synced, including one with no data for it. Works without a
|
|
1193
|
+
* login. For a password backup (exportForSync()'s fallback), use
|
|
1194
|
+
* syncWalletWithPasskey().
|
|
1195
|
+
*
|
|
1196
|
+
* @throws SyncBootstrapError ('CREDENTIAL_MISMATCH') when logged in with another passkey
|
|
990
1197
|
*/
|
|
991
1198
|
importFromSync(syncData: string | Blob): Promise<{
|
|
992
1199
|
ethereumAddress: string;
|
|
@@ -1023,7 +1230,7 @@ declare class Web3Passkey {
|
|
|
1023
1230
|
extendSession(): void;
|
|
1024
1231
|
/**
|
|
1025
1232
|
* Clear active session
|
|
1026
|
-
* Also clears ALL persistent sessions from
|
|
1233
|
+
* Also clears ALL persistent sessions from localStorage
|
|
1027
1234
|
*
|
|
1028
1235
|
* @throws {StorageError} if persistent sessions could not be cleared
|
|
1029
1236
|
*/
|
|
@@ -1041,6 +1248,23 @@ declare class Web3Passkey {
|
|
|
1041
1248
|
* @param hours - Duration in hours
|
|
1042
1249
|
*/
|
|
1043
1250
|
setPersistentSessionDuration(hours: number): void;
|
|
1251
|
+
/**
|
|
1252
|
+
* Derive a 32-byte secret bound to the passkey, separate per origin and tag
|
|
1253
|
+
*
|
|
1254
|
+
* Evaluates the WebAuthn PRF extension on a fresh user-verified assertion
|
|
1255
|
+
* and runs HKDF-SHA256 on the output. The secret is never derived from or
|
|
1256
|
+
* stored with the mnemonic, so it never appears in backups, recovery
|
|
1257
|
+
* phrases, sessions or storage. When logged in, the assertion is
|
|
1258
|
+
* restricted to the current user's passkey.
|
|
1259
|
+
*
|
|
1260
|
+
* @param tag - Non-empty label without ':', e.g. "zk-identity"
|
|
1261
|
+
* @returns The secret and the credential it is bound to
|
|
1262
|
+
* @throws PrfUnsupportedError when the authenticator doesn't support PRF
|
|
1263
|
+
*
|
|
1264
|
+
* @example
|
|
1265
|
+
* const { secret, credentialId } = await w3pk.derivePrfSecret("zk-identity")
|
|
1266
|
+
*/
|
|
1267
|
+
derivePrfSecret(tag: string): Promise<PrfSecret>;
|
|
1044
1268
|
/**
|
|
1045
1269
|
* Derive ML-KEM-1024 public key from the current wallet
|
|
1046
1270
|
*
|
|
@@ -1326,31 +1550,6 @@ declare function verifyEIP7702Authorization(chainId: bigint, contractAddress: st
|
|
|
1326
1550
|
s: string;
|
|
1327
1551
|
} | string, expectedSigner: string): boolean;
|
|
1328
1552
|
|
|
1329
|
-
/** Client extension results consumed by w3pk (subset of the WebAuthn spec) */
|
|
1330
|
-
interface PrfExtensionResults {
|
|
1331
|
-
prf?: {
|
|
1332
|
-
enabled?: boolean;
|
|
1333
|
-
results?: {
|
|
1334
|
-
first?: ArrayBuffer;
|
|
1335
|
-
};
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
/**
|
|
1339
|
-
* Native WebAuthn credential response (authentication)
|
|
1340
|
-
*/
|
|
1341
|
-
interface AuthenticationCredential {
|
|
1342
|
-
id: string;
|
|
1343
|
-
rawId: ArrayBuffer;
|
|
1344
|
-
type: 'public-key';
|
|
1345
|
-
response: {
|
|
1346
|
-
clientDataJSON: ArrayBuffer;
|
|
1347
|
-
authenticatorData: ArrayBuffer;
|
|
1348
|
-
signature: ArrayBuffer;
|
|
1349
|
-
userHandle?: ArrayBuffer;
|
|
1350
|
-
};
|
|
1351
|
-
getClientExtensionResults(): PrfExtensionResults;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
1553
|
/**
|
|
1355
1554
|
* Sync Authentication Helper
|
|
1356
1555
|
* Handles passkey selection and authentication for cross-device sync scenarios
|
|
@@ -1360,6 +1559,9 @@ interface PasskeySelectionResult {
|
|
|
1360
1559
|
credentialId: string;
|
|
1361
1560
|
publicKey: string;
|
|
1362
1561
|
ethereumAddress?: string;
|
|
1562
|
+
username?: string;
|
|
1563
|
+
/** The selection assertion, to verify against a public key from a backup */
|
|
1564
|
+
assertion: AuthenticationCredential;
|
|
1363
1565
|
}
|
|
1364
1566
|
/**
|
|
1365
1567
|
* Prompts the user to select a passkey/webauthn credential
|
|
@@ -1417,85 +1619,6 @@ declare function getCurrentOrigin(): string;
|
|
|
1417
1619
|
*/
|
|
1418
1620
|
declare function deriveAddressFromP256PublicKey(publicKeySpki: string): Promise<string>;
|
|
1419
1621
|
|
|
1420
|
-
/**
|
|
1421
|
-
* Backup and Recovery Type Definitions
|
|
1422
|
-
*/
|
|
1423
|
-
interface BackupStatus {
|
|
1424
|
-
passkeySync: PasskeySyncStatus;
|
|
1425
|
-
recoveryPhrase: RecoveryPhraseStatus;
|
|
1426
|
-
socialRecovery?: SocialRecoveryStatus;
|
|
1427
|
-
securityScore: SecurityScore;
|
|
1428
|
-
}
|
|
1429
|
-
interface PasskeySyncStatus {
|
|
1430
|
-
enabled: boolean;
|
|
1431
|
-
deviceCount: number;
|
|
1432
|
-
lastSyncTime?: string;
|
|
1433
|
-
platform: 'apple' | 'google' | 'microsoft' | 'unknown';
|
|
1434
|
-
}
|
|
1435
|
-
interface RecoveryPhraseStatus {
|
|
1436
|
-
verified: boolean;
|
|
1437
|
-
verificationCount: number;
|
|
1438
|
-
lastVerified?: string;
|
|
1439
|
-
encryptedBackups: EncryptedBackupInfo[];
|
|
1440
|
-
}
|
|
1441
|
-
interface EncryptedBackupInfo {
|
|
1442
|
-
id: string;
|
|
1443
|
-
method: 'qr' | 'file';
|
|
1444
|
-
location: string;
|
|
1445
|
-
createdAt: string;
|
|
1446
|
-
deviceFingerprint?: string;
|
|
1447
|
-
}
|
|
1448
|
-
interface SocialRecoveryStatus {
|
|
1449
|
-
enabled: boolean;
|
|
1450
|
-
guardians: Guardian$1[];
|
|
1451
|
-
threshold: number;
|
|
1452
|
-
sharesDistributed: number;
|
|
1453
|
-
verifiedGuardians: number;
|
|
1454
|
-
}
|
|
1455
|
-
interface Guardian$1 {
|
|
1456
|
-
id: string;
|
|
1457
|
-
name: string;
|
|
1458
|
-
email?: string;
|
|
1459
|
-
publicKey?: string;
|
|
1460
|
-
shareEncrypted: string;
|
|
1461
|
-
status: 'pending' | 'active' | 'revoked';
|
|
1462
|
-
addedAt: string;
|
|
1463
|
-
lastVerified?: string;
|
|
1464
|
-
}
|
|
1465
|
-
interface SecurityScore {
|
|
1466
|
-
total: number;
|
|
1467
|
-
breakdown: {
|
|
1468
|
-
passkeyActive: number;
|
|
1469
|
-
passkeyMultiDevice: number;
|
|
1470
|
-
phraseVerified: number;
|
|
1471
|
-
encryptedBackup: number;
|
|
1472
|
-
socialRecovery: number;
|
|
1473
|
-
};
|
|
1474
|
-
level: 'vulnerable' | 'protected' | 'secured' | 'fort-knox';
|
|
1475
|
-
nextMilestone: string;
|
|
1476
|
-
}
|
|
1477
|
-
interface QRBackupOptions {
|
|
1478
|
-
password?: string;
|
|
1479
|
-
errorCorrection?: 'L' | 'M' | 'Q' | 'H';
|
|
1480
|
-
}
|
|
1481
|
-
interface RecoveryScenario {
|
|
1482
|
-
type: 'lost-device' | 'lost-phrase' | 'lost-both' | 'switch-platform';
|
|
1483
|
-
description: string;
|
|
1484
|
-
}
|
|
1485
|
-
interface SimulationResult {
|
|
1486
|
-
scenario: RecoveryScenario;
|
|
1487
|
-
success: boolean;
|
|
1488
|
-
availableMethods: RecoveryMethod[];
|
|
1489
|
-
timeEstimate: string;
|
|
1490
|
-
educationalNote: string;
|
|
1491
|
-
}
|
|
1492
|
-
interface RecoveryMethod {
|
|
1493
|
-
method: string;
|
|
1494
|
-
success: boolean;
|
|
1495
|
-
time: string;
|
|
1496
|
-
requirements: string[];
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
1622
|
/**
|
|
1500
1623
|
* Recovery Scenario Simulator
|
|
1501
1624
|
* Educational tool to help users understand recovery options
|
|
@@ -2217,6 +2340,7 @@ interface MLKemKeypair {
|
|
|
2217
2340
|
privateKey: Uint8Array;
|
|
2218
2341
|
}
|
|
2219
2342
|
interface EncryptedPayload {
|
|
2343
|
+
version?: 2;
|
|
2220
2344
|
recipients: Array<{
|
|
2221
2345
|
publicKey: string;
|
|
2222
2346
|
ciphertext: string;
|
|
@@ -2313,4 +2437,4 @@ declare function mlkemDecryptWithKey(payload: EncryptedPayload, privateKey: stri
|
|
|
2313
2437
|
|
|
2314
2438
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
2315
2439
|
|
|
2316
|
-
export { ApiError, AuthenticationError, type BackupStatus, type BrowserInspectOptions, type BrowserInspectResult, CryptoError, DEFAULT_MODE, DEFAULT_TAG, type DeviceInfo, type EIP1193Provider, type EIP7702Authorization, type EncryptedBackupInfo, type EncryptedPayload, type Guardian, type GuardianInvite, type MLKemKeypair, 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, deriveMLKemKeypair, deriveStealthKeys, deriveWalletFromMnemonic, detectWalletProvider, encodeEIP7702AuthorizationMessage, extractRS, generateBIP39Wallet, generateSiweNonce, generateStealthAddress, getAllChains, getAllTopics, getChainById, getCurrentBuildHash, getCurrentOrigin, getDefaultProvider, getEndpoints, getExplainer, getOriginSpecificAddress, getPackageVersion, getW3pkBuildHash, hashEIP7702AuthorizationMessage, inspect, inspectNow, isStrongPassword, mlkemDecrypt, mlkemDecryptWithKey, mlkemEncrypt, mlkemEncryptWithKey, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|
|
2440
|
+
export { ApiError, AuthenticationError, type BackupMethod, type BackupStatus, type BrowserInspectOptions, type BrowserInspectResult, CryptoError, DEFAULT_MODE, DEFAULT_TAG, type DeviceInfo, type EIP1193Provider, type EIP7702Authorization, type EncryptedBackupInfo, type EncryptedPayload, type Guardian, type GuardianInvite, type MLKemKeypair, type PasskeySelectionResult, type PrfSecret, PrfUnsupportedError, 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, SyncBootstrapError, type SyncBootstrapReason, type SyncCapabilities, SyncRequiredError, type SyncStatus, type SyncVault, type UserInfo, WalletError, type WalletInfo, WalletMissingError, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, arrayBufferToBase64Url, assertEthereumAddress, assertMnemonic, assertUsername, authenticateWithPasskey, base64ToArrayBuffer, base64UrlDecode, base64UrlToArrayBuffer, canControlStealthAddress, checkStealthAddress, clearCache, computeStealthPrivateKey, createSiweMessage, createWalletFromMnemonic, createWeb3Passkey, createWeb3Passkey as default, deriveAddressFromP256PublicKey, deriveIndexFromOriginModeAndTag, deriveMLKemKeypair, deriveStealthKeys, deriveWalletFromMnemonic, detectWalletProvider, encodeEIP7702AuthorizationMessage, extractRS, generateBIP39Wallet, generateSiweNonce, generateStealthAddress, getAllChains, getAllTopics, getChainById, getCurrentBuildHash, getCurrentOrigin, getDefaultProvider, getEndpoints, getExplainer, getOriginSpecificAddress, getPackageVersion, getW3pkBuildHash, hashEIP7702AuthorizationMessage, inspect, inspectNow, isStrongPassword, mlkemDecrypt, mlkemDecryptWithKey, mlkemEncrypt, mlkemEncryptWithKey, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|