w3pk 0.10.3 → 0.10.5
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 -57
- package/dist/chainlist/index.d.mts +96 -0
- package/dist/chainlist/index.d.ts +96 -0
- package/dist/index.d.mts +121 -134
- package/dist/index.d.ts +121 -134
- package/dist/index.js +33 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -60
- 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 +122 -237
- package/docs/BROWSER_COMPATIBILITY.md +26 -2
- package/docs/INTEGRATION_GUIDELINES.md +37 -306
- package/docs/PORTABILITY.md +66 -0
- package/docs/RECOVERY.md +58 -48
- package/docs/SECURITY.md +0 -136
- package/docs/notes/old-computer.md +99 -0
- package/package.json +2 -12
- package/dist/inspect/browser.d.mts +0 -106
- package/dist/inspect/browser.d.ts +0 -106
- package/dist/inspect/browser.js +0 -194
- package/dist/inspect/browser.js.map +0 -1
- package/dist/inspect/browser.mjs +0 -173
- package/dist/inspect/browser.mjs.map +0 -1
- package/dist/inspect/index.d.mts +0 -1
- package/dist/inspect/index.d.ts +0 -1
- package/dist/inspect/index.js +0 -196
- package/dist/inspect/index.js.map +0 -1
- package/dist/inspect/index.mjs +0 -173
- package/dist/inspect/index.mjs.map +0 -1
- package/dist/inspect/node.js +0 -287
- package/dist/inspect/node.js.map +0 -1
- package/dist/inspect/node.mjs +0 -251
- package/dist/inspect/node.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -59,7 +59,6 @@ const endpoints = await w3pk.getEndpoints(1)
|
|
|
59
59
|
- EIP-7951 PRIMARY mode (P-256 passkey signing)
|
|
60
60
|
- Build verification (IPFS CID hashing + DAO-maintained onchain registry)
|
|
61
61
|
- Three-layer backup & recovery (passkey sync, encrypted backups, social recovery)
|
|
62
|
-
- AI-powered host app inspection
|
|
63
62
|
|
|
64
63
|
## API
|
|
65
64
|
|
|
@@ -428,53 +427,6 @@ console.log('Onchain CID:', onchainCid)
|
|
|
428
427
|
console.log('Verified:', isValid ? '✅' : '❌')
|
|
429
428
|
```
|
|
430
429
|
|
|
431
|
-
### Security Inspection
|
|
432
|
-
|
|
433
|
-
> **⚠️ Privacy Notice:** This optional feature sends application source code to an external API (Rukh) for AI analysis. User IP address will be visible to the API server.
|
|
434
|
-
|
|
435
|
-
Analyze web3 applications to understand their transaction and signing methods:
|
|
436
|
-
|
|
437
|
-
**Browser (analyze current page):**
|
|
438
|
-
```typescript
|
|
439
|
-
import { inspect, inspectNow } from 'w3pk'
|
|
440
|
-
|
|
441
|
-
// Full inspection with custom options
|
|
442
|
-
const result = await inspect({
|
|
443
|
-
appUrl: 'https://example.com',
|
|
444
|
-
rukhUrl: 'https://rukh.w3hc.org',
|
|
445
|
-
model: 'anthropic',
|
|
446
|
-
focusMode: 'transactions'
|
|
447
|
-
})
|
|
448
|
-
console.log(result.report)
|
|
449
|
-
|
|
450
|
-
// Quick console inspection
|
|
451
|
-
await inspectNow() // Logs report directly to console
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
**Note:** Inspection API calls are sponsored by the [W3HC (Web3 Hackers Collective)](https://w3hc.org).
|
|
455
|
-
|
|
456
|
-
**Node.js (analyze local files):**
|
|
457
|
-
```typescript
|
|
458
|
-
import { inspect, gatherCode } from 'w3pk/inspect/node'
|
|
459
|
-
|
|
460
|
-
// Generate security report via Rukh API
|
|
461
|
-
const report = await inspect(
|
|
462
|
-
'../my-dapp', // App path
|
|
463
|
-
'https://rukh.w3hc.org', // Rukh API URL
|
|
464
|
-
'w3pk', // Context
|
|
465
|
-
'anthropic', // Model
|
|
466
|
-
'transactions' // Focus mode
|
|
467
|
-
)
|
|
468
|
-
|
|
469
|
-
// Or just gather code for analysis
|
|
470
|
-
const result = await gatherCode({
|
|
471
|
-
appPath: '../my-dapp',
|
|
472
|
-
focusMode: 'transactions',
|
|
473
|
-
maxFileSizeKB: 500
|
|
474
|
-
})
|
|
475
|
-
console.log(`Analyzed ${result.includedFiles.length} files`)
|
|
476
|
-
```
|
|
477
|
-
|
|
478
430
|
## Security & Verification
|
|
479
431
|
|
|
480
432
|
### Onchain Build Registry
|
|
@@ -493,7 +445,6 @@ Host applications should verify their installed W3PK build against this registry
|
|
|
493
445
|
- [Integration Guidelines](./docs/INTEGRATION_GUIDELINES.md)
|
|
494
446
|
- [API Reference](./docs/API_REFERENCE.md)
|
|
495
447
|
- [Build Verification](./docs/BUILD_VERIFICATION.md)
|
|
496
|
-
- [Security Inspection](./docs/INSPECTION.md)
|
|
497
448
|
- [EIP-7951](./docs/EIP-7951.md)
|
|
498
449
|
- [Security Architecture](./docs/SECURITY.md)
|
|
499
450
|
- [Post-Quantum Cryptography](./docs/POST_QUANTUM.md) - Quantum-safe migration roadmap
|
|
@@ -512,11 +463,4 @@ GPL-3.0
|
|
|
512
463
|
|
|
513
464
|
## Contact
|
|
514
465
|
|
|
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"/>
|
|
466
|
+
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
|
*/
|
|
@@ -396,6 +437,23 @@ declare class WalletMissingError extends Web3PasskeyError {
|
|
|
396
437
|
ethereumAddress: string;
|
|
397
438
|
constructor(credentialId: string, ethereumAddress: string);
|
|
398
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
|
+
}
|
|
399
457
|
|
|
400
458
|
/**
|
|
401
459
|
* Persistent Session Storage
|
|
@@ -479,6 +537,13 @@ interface Web3PasskeyConfig {
|
|
|
479
537
|
* Requires: snarkjs, circomlibjs
|
|
480
538
|
*/
|
|
481
539
|
zkProofs?: ZKProofConfig;
|
|
540
|
+
/**
|
|
541
|
+
* WebAuthn user verification for login, registration and signing
|
|
542
|
+
* (default: 'required'). With 'preferred', authenticators that can skip
|
|
543
|
+
* the biometric/PIN check (security keys, unlocked password managers)
|
|
544
|
+
* sign in with one click. PRF-derived secrets always require it.
|
|
545
|
+
*/
|
|
546
|
+
userVerification?: 'required' | 'preferred';
|
|
482
547
|
}
|
|
483
548
|
|
|
484
549
|
/**
|
|
@@ -487,6 +552,7 @@ interface Web3PasskeyConfig {
|
|
|
487
552
|
type BackupMethod = 'file' | 'qr' | 'phrase';
|
|
488
553
|
interface BackupStatus {
|
|
489
554
|
hasBackup: boolean;
|
|
555
|
+
evictionRisk: boolean;
|
|
490
556
|
lastBackupAt?: string;
|
|
491
557
|
methods: BackupMethod[];
|
|
492
558
|
passkeySync: PasskeySyncStatus;
|
|
@@ -622,6 +688,7 @@ declare class Web3Passkey {
|
|
|
622
688
|
address: string;
|
|
623
689
|
username: string;
|
|
624
690
|
hasBackup: boolean;
|
|
691
|
+
evictionRisk: boolean;
|
|
625
692
|
}>;
|
|
626
693
|
/**
|
|
627
694
|
* Login with WebAuthn using resident credentials
|
|
@@ -1007,6 +1074,7 @@ declare class Web3Passkey {
|
|
|
1007
1074
|
blob: Blob;
|
|
1008
1075
|
filename: string;
|
|
1009
1076
|
}>;
|
|
1077
|
+
private backupCredential;
|
|
1010
1078
|
/**
|
|
1011
1079
|
* Set up social recovery by splitting backup file among guardians
|
|
1012
1080
|
* Uses Shamir Secret Sharing to split the backup - requires M-of-N guardians to recover
|
|
@@ -1066,6 +1134,9 @@ declare class Web3Passkey {
|
|
|
1066
1134
|
*
|
|
1067
1135
|
* This allows the user to use the same PRIMARY mode webauthn account on multiple devices.
|
|
1068
1136
|
*
|
|
1137
|
+
* A PRF backup (from exportForSync()) takes a single assertion restricted
|
|
1138
|
+
* to its passkey and no password.
|
|
1139
|
+
*
|
|
1069
1140
|
* @param backupData - Backup file (JSON string or Blob) - can be pasted by user
|
|
1070
1141
|
* @param password - Password to decrypt backup (if password-encrypted)
|
|
1071
1142
|
* @returns Restored wallet info
|
|
@@ -1074,6 +1145,18 @@ declare class Web3Passkey {
|
|
|
1074
1145
|
mnemonic: string;
|
|
1075
1146
|
ethereumAddress: string;
|
|
1076
1147
|
}>;
|
|
1148
|
+
/**
|
|
1149
|
+
* Restore a PRF backup with its passkey and set this device up for it.
|
|
1150
|
+
* The public key is this device's when it has the passkey's metadata,
|
|
1151
|
+
* else the backup's, checked against the assertion's signature.
|
|
1152
|
+
*/
|
|
1153
|
+
private restorePrfBackup;
|
|
1154
|
+
/**
|
|
1155
|
+
* Set this device up for a passkey and a synced wallet: saves the
|
|
1156
|
+
* passkey's metadata (or points it at the wallet), stores the wallet
|
|
1157
|
+
* under the passkey-derived key and starts a session
|
|
1158
|
+
*/
|
|
1159
|
+
private bootstrapCredential;
|
|
1077
1160
|
/**
|
|
1078
1161
|
* Register new passkey with wallet from backup file
|
|
1079
1162
|
* Use case: Fresh device, user has backup file but no passkey yet
|
|
@@ -1094,16 +1177,30 @@ declare class Web3Passkey {
|
|
|
1094
1177
|
getSyncStatus(): Promise<any>;
|
|
1095
1178
|
/**
|
|
1096
1179
|
* Export wallet for syncing to another device
|
|
1097
|
-
*
|
|
1180
|
+
*
|
|
1181
|
+
* Prompts for the passkey and encrypts with a key derived from its WebAuthn
|
|
1182
|
+
* PRF output (`encryptionMethod: 'prf'`): a device where the passkey synced
|
|
1183
|
+
* restores it with one prompt and no password. Where the authenticator has
|
|
1184
|
+
* no PRF support, `password` makes it fall back to a password backup.
|
|
1185
|
+
*
|
|
1186
|
+
* @param password - Fallback password when PRF is unavailable
|
|
1187
|
+
* @throws PrfUnsupportedError when PRF is unavailable and no password is given
|
|
1098
1188
|
*/
|
|
1099
|
-
exportForSync(): Promise<{
|
|
1189
|
+
exportForSync(password?: string): Promise<{
|
|
1100
1190
|
blob: Blob;
|
|
1101
1191
|
filename: string;
|
|
1102
1192
|
qrCode?: string;
|
|
1103
1193
|
}>;
|
|
1104
1194
|
/**
|
|
1105
1195
|
* Import wallet from another device (sync wallet to this device)
|
|
1106
|
-
*
|
|
1196
|
+
*
|
|
1197
|
+
* Takes a PRF backup from exportForSync(): one assertion restricted to
|
|
1198
|
+
* the backup's passkey decrypts it, with no password, on any device where
|
|
1199
|
+
* the passkey synced, including one with no data for it. Works without a
|
|
1200
|
+
* login. For a password backup (exportForSync()'s fallback), use
|
|
1201
|
+
* syncWalletWithPasskey().
|
|
1202
|
+
*
|
|
1203
|
+
* @throws SyncBootstrapError ('CREDENTIAL_MISMATCH') when logged in with another passkey
|
|
1107
1204
|
*/
|
|
1108
1205
|
importFromSync(syncData: string | Blob): Promise<{
|
|
1109
1206
|
ethereumAddress: string;
|
|
@@ -1158,6 +1255,23 @@ declare class Web3Passkey {
|
|
|
1158
1255
|
* @param hours - Duration in hours
|
|
1159
1256
|
*/
|
|
1160
1257
|
setPersistentSessionDuration(hours: number): void;
|
|
1258
|
+
/**
|
|
1259
|
+
* Derive a 32-byte secret bound to the passkey, separate per origin and tag
|
|
1260
|
+
*
|
|
1261
|
+
* Evaluates the WebAuthn PRF extension on a fresh user-verified assertion
|
|
1262
|
+
* and runs HKDF-SHA256 on the output. The secret is never derived from or
|
|
1263
|
+
* stored with the mnemonic, so it never appears in backups, recovery
|
|
1264
|
+
* phrases, sessions or storage. When logged in, the assertion is
|
|
1265
|
+
* restricted to the current user's passkey.
|
|
1266
|
+
*
|
|
1267
|
+
* @param tag - Non-empty label without ':', e.g. "zk-identity"
|
|
1268
|
+
* @returns The secret and the credential it is bound to
|
|
1269
|
+
* @throws PrfUnsupportedError when the authenticator doesn't support PRF
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* const { secret, credentialId } = await w3pk.derivePrfSecret("zk-identity")
|
|
1273
|
+
*/
|
|
1274
|
+
derivePrfSecret(tag: string): Promise<PrfSecret>;
|
|
1161
1275
|
/**
|
|
1162
1276
|
* Derive ML-KEM-1024 public key from the current wallet
|
|
1163
1277
|
*
|
|
@@ -1443,31 +1557,6 @@ declare function verifyEIP7702Authorization(chainId: bigint, contractAddress: st
|
|
|
1443
1557
|
s: string;
|
|
1444
1558
|
} | string, expectedSigner: string): boolean;
|
|
1445
1559
|
|
|
1446
|
-
/** Client extension results consumed by w3pk (subset of the WebAuthn spec) */
|
|
1447
|
-
interface PrfExtensionResults {
|
|
1448
|
-
prf?: {
|
|
1449
|
-
enabled?: boolean;
|
|
1450
|
-
results?: {
|
|
1451
|
-
first?: ArrayBuffer;
|
|
1452
|
-
};
|
|
1453
|
-
};
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Native WebAuthn credential response (authentication)
|
|
1457
|
-
*/
|
|
1458
|
-
interface AuthenticationCredential {
|
|
1459
|
-
id: string;
|
|
1460
|
-
rawId: ArrayBuffer;
|
|
1461
|
-
type: 'public-key';
|
|
1462
|
-
response: {
|
|
1463
|
-
clientDataJSON: ArrayBuffer;
|
|
1464
|
-
authenticatorData: ArrayBuffer;
|
|
1465
|
-
signature: ArrayBuffer;
|
|
1466
|
-
userHandle?: ArrayBuffer;
|
|
1467
|
-
};
|
|
1468
|
-
getClientExtensionResults(): PrfExtensionResults;
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
1560
|
/**
|
|
1472
1561
|
* Sync Authentication Helper
|
|
1473
1562
|
* Handles passkey selection and authentication for cross-device sync scenarios
|
|
@@ -1477,6 +1566,9 @@ interface PasskeySelectionResult {
|
|
|
1477
1566
|
credentialId: string;
|
|
1478
1567
|
publicKey: string;
|
|
1479
1568
|
ethereumAddress?: string;
|
|
1569
|
+
username?: string;
|
|
1570
|
+
/** The selection assertion, to verify against a public key from a backup */
|
|
1571
|
+
assertion: AuthenticationCredential;
|
|
1480
1572
|
}
|
|
1481
1573
|
/**
|
|
1482
1574
|
* Prompts the user to select a passkey/webauthn credential
|
|
@@ -2145,111 +2237,6 @@ declare function getChainById(chainId: number, options?: ChainlistOptions): Prom
|
|
|
2145
2237
|
*/
|
|
2146
2238
|
declare function clearCache(): void;
|
|
2147
2239
|
|
|
2148
|
-
/**
|
|
2149
|
-
* Browser Inspection Module
|
|
2150
|
-
*
|
|
2151
|
-
* Provides client-side code inspection capabilities for analyzing running web3 applications.
|
|
2152
|
-
* Fetches JavaScript sources from the current page and analyzes transaction/signing patterns
|
|
2153
|
-
* to generate security reports via the Rukh API.
|
|
2154
|
-
*
|
|
2155
|
-
* This module is designed to be used directly in the browser console or embedded in
|
|
2156
|
-
* web applications to help end-users understand the security posture of the apps they use.
|
|
2157
|
-
*
|
|
2158
|
-
* @module inspect/browser
|
|
2159
|
-
*/
|
|
2160
|
-
/**
|
|
2161
|
-
* Configuration options for browser-based application inspection
|
|
2162
|
-
*/
|
|
2163
|
-
interface BrowserInspectOptions {
|
|
2164
|
-
/**
|
|
2165
|
-
* The origin/URL of the app to inspect
|
|
2166
|
-
* @default window.location.origin
|
|
2167
|
-
*/
|
|
2168
|
-
appUrl?: string;
|
|
2169
|
-
/**
|
|
2170
|
-
* Rukh API endpoint
|
|
2171
|
-
* @default 'https://rukh.w3hc.org'
|
|
2172
|
-
*/
|
|
2173
|
-
rukhUrl?: string;
|
|
2174
|
-
/**
|
|
2175
|
-
* Context to use for analysis
|
|
2176
|
-
* @default 'w3pk'
|
|
2177
|
-
*/
|
|
2178
|
-
context?: string;
|
|
2179
|
-
/**
|
|
2180
|
-
* AI model to use
|
|
2181
|
-
* @default 'anthropic'
|
|
2182
|
-
*/
|
|
2183
|
-
model?: "anthropic" | "mistral" | "openai";
|
|
2184
|
-
/**
|
|
2185
|
-
* Focus mode for analysis
|
|
2186
|
-
* @default 'transactions'
|
|
2187
|
-
*/
|
|
2188
|
-
focusMode?: "transactions" | "all";
|
|
2189
|
-
/**
|
|
2190
|
-
* Maximum total size in KB for all collected code (prevents exceeding API token limits)
|
|
2191
|
-
* @default 100
|
|
2192
|
-
*/
|
|
2193
|
-
maxTotalSizeKB?: number;
|
|
2194
|
-
}
|
|
2195
|
-
/**
|
|
2196
|
-
* Result of a browser-based inspection
|
|
2197
|
-
*/
|
|
2198
|
-
interface BrowserInspectResult {
|
|
2199
|
-
/**
|
|
2200
|
-
* The security report markdown generated by Rukh API
|
|
2201
|
-
*/
|
|
2202
|
-
report: string;
|
|
2203
|
-
/**
|
|
2204
|
-
* List of JavaScript file paths that were analyzed
|
|
2205
|
-
*/
|
|
2206
|
-
analyzedFiles: string[];
|
|
2207
|
-
/**
|
|
2208
|
-
* The application URL that was inspected
|
|
2209
|
-
*/
|
|
2210
|
-
appUrl: string;
|
|
2211
|
-
}
|
|
2212
|
-
/**
|
|
2213
|
-
* Inspects the currently running web application and returns a security report
|
|
2214
|
-
*
|
|
2215
|
-
* This function can be called by end-users in their browser console to analyze
|
|
2216
|
-
* the security of the web application they're currently using.
|
|
2217
|
-
*
|
|
2218
|
-
* @param options - Configuration options
|
|
2219
|
-
* @returns A security report analyzing transaction and signing methods
|
|
2220
|
-
*
|
|
2221
|
-
* @example
|
|
2222
|
-
* ```typescript
|
|
2223
|
-
* // In browser console or app code:
|
|
2224
|
-
* import { inspect } from 'w3pk';
|
|
2225
|
-
*
|
|
2226
|
-
* const report = await inspect();
|
|
2227
|
-
* console.log(report.report);
|
|
2228
|
-
* ```
|
|
2229
|
-
*
|
|
2230
|
-
* @example
|
|
2231
|
-
* ```typescript
|
|
2232
|
-
* // With custom options:
|
|
2233
|
-
* const report = await inspect({
|
|
2234
|
-
* appUrl: 'https://w3pk.w3hc.org',
|
|
2235
|
-
* model: 'anthropic',
|
|
2236
|
-
* focusMode: 'transactions'
|
|
2237
|
-
* });
|
|
2238
|
-
* ```
|
|
2239
|
-
*/
|
|
2240
|
-
declare function inspect(options?: BrowserInspectOptions): Promise<BrowserInspectResult>;
|
|
2241
|
-
/**
|
|
2242
|
-
* Quick inspection helper that logs the report to console
|
|
2243
|
-
* Perfect for use in browser DevTools console
|
|
2244
|
-
*
|
|
2245
|
-
* @example
|
|
2246
|
-
* ```javascript
|
|
2247
|
-
* // In browser console:
|
|
2248
|
-
* await w3pk.inspectNow()
|
|
2249
|
-
* ```
|
|
2250
|
-
*/
|
|
2251
|
-
declare function inspectNow(options?: BrowserInspectOptions): Promise<void>;
|
|
2252
|
-
|
|
2253
2240
|
interface MLKemKeypair {
|
|
2254
2241
|
publicKey: Uint8Array;
|
|
2255
2242
|
privateKey: Uint8Array;
|
|
@@ -2352,4 +2339,4 @@ declare function mlkemDecryptWithKey(payload: EncryptedPayload, privateKey: stri
|
|
|
2352
2339
|
|
|
2353
2340
|
declare function createWeb3Passkey(config?: Web3PasskeyConfig): Web3Passkey;
|
|
2354
2341
|
|
|
2355
|
-
export { ApiError, AuthenticationError, type BackupMethod, type BackupStatus,
|
|
2342
|
+
export { ApiError, AuthenticationError, type BackupMethod, type BackupStatus, 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, isStrongPassword, mlkemDecrypt, mlkemDecryptWithKey, mlkemEncrypt, mlkemEncryptWithKey, normalizeOrigin, parseSiweMessage, promptPasskeySelection, requestExternalWalletAuthorization, safeAtob, safeBtoa, searchExplainers, supportsEIP7702Authorization, validateEthereumAddress, validateMnemonic, validateSiweMessage, validateUsername, verifyBuildHash, verifyEIP7702Authorization, verifySiweSignature };
|