@anywalletkit/extension-kit 0.1.2 → 0.1.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 +12 -3
- package/dist/index.cjs +194 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -24
- package/dist/index.d.ts +65 -24
- package/dist/index.js +194 -67
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
package/dist/index.d.cts
CHANGED
|
@@ -39,6 +39,31 @@ declare const VAULT_MIN_SCRYPT: {
|
|
|
39
39
|
};
|
|
40
40
|
/** Shortest password `create` / `changePassword` accept. `unlock` takes whatever opens the vault. */
|
|
41
41
|
declare const VAULT_MIN_PASSWORD_LENGTH = 8;
|
|
42
|
+
/**
|
|
43
|
+
* Upper bounds on what an envelope (and the options) may carry, checked before any KDF runs: an
|
|
44
|
+
* envelope edited on disk must not make unlock hang (PBKDF2 iterations) or exhaust the worker's
|
|
45
|
+
* memory (scrypt N × r), and its size stays within what `chrome.storage.local` holds.
|
|
46
|
+
*/
|
|
47
|
+
declare const VAULT_LIMITS: Readonly<{
|
|
48
|
+
/** scrypt cost: 2^20 × 16 = 2 GiB is the most any envelope may ask for. */
|
|
49
|
+
scrypt: Readonly<{
|
|
50
|
+
N: number;
|
|
51
|
+
r: 16;
|
|
52
|
+
p: 4;
|
|
53
|
+
}>;
|
|
54
|
+
/** PBKDF2-SHA256 iterations (v1 envelopes). */
|
|
55
|
+
iterations: 5000000;
|
|
56
|
+
/** Sealed secrets in one vault. */
|
|
57
|
+
secrets: 1000;
|
|
58
|
+
/** Registered passkeys. */
|
|
59
|
+
passkeys: 32;
|
|
60
|
+
/** Plaintext bytes of one secret (`setSecret`). */
|
|
61
|
+
secretBytes: number;
|
|
62
|
+
/** base64 characters of one sealed box (iv or data). */
|
|
63
|
+
boxChars: number;
|
|
64
|
+
/** JSON characters of the whole envelope. */
|
|
65
|
+
envelopeChars: number;
|
|
66
|
+
}>;
|
|
42
67
|
interface SealedBox {
|
|
43
68
|
/** 96-bit AES-GCM nonce, base64. */
|
|
44
69
|
iv: string;
|
|
@@ -116,8 +141,14 @@ interface VaultKdfInfo {
|
|
|
116
141
|
/** Human line for the UI, e.g. "scrypt N=2^17 r=8 p=1". */
|
|
117
142
|
summary: string;
|
|
118
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* One `Vault` per storage area: writes to the envelope are serialized inside the instance, so two
|
|
146
|
+
* instances over the same area could still overwrite each other.
|
|
147
|
+
*/
|
|
119
148
|
declare class Vault {
|
|
120
149
|
private readonly _storage;
|
|
150
|
+
/** Every read-modify-write of the envelope runs here, one after another (a parallel write would drop the other's change). */
|
|
151
|
+
private _queue;
|
|
121
152
|
private readonly _kdf;
|
|
122
153
|
private readonly _iterations;
|
|
123
154
|
private readonly _scrypt;
|
|
@@ -138,6 +169,7 @@ declare class Vault {
|
|
|
138
169
|
* way out, secrets untouched.
|
|
139
170
|
*/
|
|
140
171
|
unlock(password: string): Promise<Uint8Array>;
|
|
172
|
+
private _unlock;
|
|
141
173
|
/** Re-wrap the DEK under a new password (fresh salt, current KDF). Secrets and passkeys are untouched. */
|
|
142
174
|
changePassword(oldPassword: string, newPassword: string): Promise<void>;
|
|
143
175
|
/** Public view of the registered passkeys (ids, labels; whether each can verify assertions). */
|
|
@@ -156,7 +188,7 @@ declare class Vault {
|
|
|
156
188
|
* Register a passkey as a second unlock path: the DEK (from the unlocked session)
|
|
157
189
|
* is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
|
|
158
190
|
* the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
|
|
159
|
-
* thereby upgraded) first.
|
|
191
|
+
* thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
|
|
160
192
|
*/
|
|
161
193
|
addPasskey(dek: Uint8Array, passkey: {
|
|
162
194
|
id: string;
|
|
@@ -165,6 +197,7 @@ declare class Vault {
|
|
|
165
197
|
publicKey?: string | undefined;
|
|
166
198
|
alg?: number | undefined;
|
|
167
199
|
}): Promise<void>;
|
|
200
|
+
private _addPasskey;
|
|
168
201
|
/** Unseal the DEK with a passkey's PRF output. `wrong-password` when the box does not open, `missing` when the id is unknown. */
|
|
169
202
|
unlockWithPasskey(id: string, prf: Uint8Array): Promise<Uint8Array>;
|
|
170
203
|
removePasskey(id: string): Promise<void>;
|
|
@@ -176,10 +209,16 @@ declare class Vault {
|
|
|
176
209
|
deleteSecret(sourceId: string): Promise<void>;
|
|
177
210
|
/** Remove the whole vault. The explicit destructive flow only (back up → wipe → create). */
|
|
178
211
|
destroy(): Promise<void>;
|
|
212
|
+
private _exclusive;
|
|
213
|
+
/** Store an envelope this build will open again (bounds checked before it is written). */
|
|
214
|
+
private _write;
|
|
179
215
|
private _random;
|
|
180
216
|
/** A fresh envelope (v2 by default, v1 with `kdf: 'pbkdf2'`) wrapping `dek` under `password`. */
|
|
181
217
|
private _sealEnvelope;
|
|
182
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* The caller's DEK must open this envelope's secrets — it is the key the password protects, not
|
|
220
|
+
* any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
|
|
221
|
+
*/
|
|
183
222
|
private _requireDek;
|
|
184
223
|
private _derivePbkdf2;
|
|
185
224
|
private _deriveScrypt;
|
|
@@ -232,6 +271,13 @@ declare class Session {
|
|
|
232
271
|
private readonly _alarm;
|
|
233
272
|
private readonly _now;
|
|
234
273
|
private readonly _onLock;
|
|
274
|
+
/**
|
|
275
|
+
* Every operation on the stored record runs here, one after another: a `touch` that read the
|
|
276
|
+
* record before a `lock` removed it would otherwise write it back and undo the lock.
|
|
277
|
+
*/
|
|
278
|
+
private _queue;
|
|
279
|
+
/** Bumped by every lock; a `touch` writes only when no lock happened since it read the record. */
|
|
280
|
+
private _epoch;
|
|
235
281
|
constructor(options: SessionOptions);
|
|
236
282
|
/** Store the DEK and arm the auto-lock. The caller's copy is zeroized. */
|
|
237
283
|
unlock(dek: Uint8Array): Promise<void>;
|
|
@@ -250,6 +296,9 @@ declare class Session {
|
|
|
250
296
|
/** Change the timer (options page); re-arms from now when unlocked. 0 disables. */
|
|
251
297
|
setAutoLockMs(ms: number): Promise<void>;
|
|
252
298
|
onLock(callback: () => void): () => void;
|
|
299
|
+
private _serial;
|
|
300
|
+
/** The lock itself; callers are already in the queue. */
|
|
301
|
+
private _lockNow;
|
|
253
302
|
private _expiry;
|
|
254
303
|
private _arm;
|
|
255
304
|
private _read;
|
|
@@ -655,33 +704,25 @@ declare function memoryApprovalWindow(): ApprovalWindow & {
|
|
|
655
704
|
userClose(id: string): void;
|
|
656
705
|
};
|
|
657
706
|
|
|
658
|
-
/**
|
|
659
|
-
* The request router: what a dApp may ask and what happens to each request.
|
|
660
|
-
* Policy ported from Vaulty's in-app browser (`mobile/lib/browser.ts`):
|
|
661
|
-
*
|
|
662
|
-
* - the origin is the browser's (checked by the service worker before this runs);
|
|
663
|
-
* - accounts are exposed only to origins the user connected (`eth_requestAccounts`
|
|
664
|
-
* → approval window); `eth_accounts` is `[]` otherwise;
|
|
665
|
-
* - chain switching and adding go through the approval window; a chain can be
|
|
666
|
-
* added only if the asset catalog knows it, with https RPCs;
|
|
667
|
-
* - read-only JSON-RPC is answered from the wallet's own clients (the networks
|
|
668
|
-
* table's failover list), never from a URL the page names;
|
|
669
|
-
* - `eth_sign` (blind hash signing) is never offered; the other signing methods
|
|
670
|
-
* go to the `sign` hook (the review flow) when the wallet provides one;
|
|
671
|
-
* - everything else is refused with 4200.
|
|
672
|
-
*
|
|
673
|
-
* Errors leave as {@link RouterError} (EIP-1193 codes) or {@link ReviewDeclined}
|
|
674
|
-
* (4001); the service worker turns both into a `RelayResponse.error`.
|
|
675
|
-
*/
|
|
676
|
-
|
|
677
707
|
declare class RouterError extends Error {
|
|
678
708
|
readonly code: number;
|
|
679
709
|
readonly data: unknown;
|
|
680
710
|
constructor(code: number, message: string, data?: unknown);
|
|
681
711
|
static from(e: RelayError): RouterError;
|
|
682
712
|
}
|
|
683
|
-
/**
|
|
684
|
-
|
|
713
|
+
/** Options for {@link toRelayError}. */
|
|
714
|
+
interface RelayErrorOptions {
|
|
715
|
+
/** Gets every error that is NOT passed to the page, in full — the extension's own log. */
|
|
716
|
+
log?: (error: unknown) => void;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Any error → the `RelayError` for the page. Wallet refusals keep their EIP-1193 code
|
|
720
|
+
* ({@link RouterError}, {@link ReviewDeclined}, a core `UserRejectedError` → 4001), a node's own
|
|
721
|
+
* JSON-RPC error keeps its code and revert data; their messages lose URLs. Everything else is
|
|
722
|
+
* `-32603 Internal error` on the page and goes to `options.log` in full — transport errors name
|
|
723
|
+
* the RPC URL (often with the provider key in it) and the request.
|
|
724
|
+
*/
|
|
725
|
+
declare function toRelayError(e: unknown, options?: RelayErrorOptions): RelayError;
|
|
685
726
|
/** Read-only methods answered from our RPC without asking the user. */
|
|
686
727
|
declare const READ_METHODS: ReadonlySet<string>;
|
|
687
728
|
/** Methods that produce a signature — the review flow's business (step 4), never answered here. */
|
|
@@ -1476,4 +1517,4 @@ declare class RecipientBook {
|
|
|
1476
1517
|
}>;
|
|
1477
1518
|
}
|
|
1478
1519
|
|
|
1479
|
-
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageRequest, type PageResponse, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
|
1520
|
+
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageRequest, type PageResponse, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,31 @@ declare const VAULT_MIN_SCRYPT: {
|
|
|
39
39
|
};
|
|
40
40
|
/** Shortest password `create` / `changePassword` accept. `unlock` takes whatever opens the vault. */
|
|
41
41
|
declare const VAULT_MIN_PASSWORD_LENGTH = 8;
|
|
42
|
+
/**
|
|
43
|
+
* Upper bounds on what an envelope (and the options) may carry, checked before any KDF runs: an
|
|
44
|
+
* envelope edited on disk must not make unlock hang (PBKDF2 iterations) or exhaust the worker's
|
|
45
|
+
* memory (scrypt N × r), and its size stays within what `chrome.storage.local` holds.
|
|
46
|
+
*/
|
|
47
|
+
declare const VAULT_LIMITS: Readonly<{
|
|
48
|
+
/** scrypt cost: 2^20 × 16 = 2 GiB is the most any envelope may ask for. */
|
|
49
|
+
scrypt: Readonly<{
|
|
50
|
+
N: number;
|
|
51
|
+
r: 16;
|
|
52
|
+
p: 4;
|
|
53
|
+
}>;
|
|
54
|
+
/** PBKDF2-SHA256 iterations (v1 envelopes). */
|
|
55
|
+
iterations: 5000000;
|
|
56
|
+
/** Sealed secrets in one vault. */
|
|
57
|
+
secrets: 1000;
|
|
58
|
+
/** Registered passkeys. */
|
|
59
|
+
passkeys: 32;
|
|
60
|
+
/** Plaintext bytes of one secret (`setSecret`). */
|
|
61
|
+
secretBytes: number;
|
|
62
|
+
/** base64 characters of one sealed box (iv or data). */
|
|
63
|
+
boxChars: number;
|
|
64
|
+
/** JSON characters of the whole envelope. */
|
|
65
|
+
envelopeChars: number;
|
|
66
|
+
}>;
|
|
42
67
|
interface SealedBox {
|
|
43
68
|
/** 96-bit AES-GCM nonce, base64. */
|
|
44
69
|
iv: string;
|
|
@@ -116,8 +141,14 @@ interface VaultKdfInfo {
|
|
|
116
141
|
/** Human line for the UI, e.g. "scrypt N=2^17 r=8 p=1". */
|
|
117
142
|
summary: string;
|
|
118
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* One `Vault` per storage area: writes to the envelope are serialized inside the instance, so two
|
|
146
|
+
* instances over the same area could still overwrite each other.
|
|
147
|
+
*/
|
|
119
148
|
declare class Vault {
|
|
120
149
|
private readonly _storage;
|
|
150
|
+
/** Every read-modify-write of the envelope runs here, one after another (a parallel write would drop the other's change). */
|
|
151
|
+
private _queue;
|
|
121
152
|
private readonly _kdf;
|
|
122
153
|
private readonly _iterations;
|
|
123
154
|
private readonly _scrypt;
|
|
@@ -138,6 +169,7 @@ declare class Vault {
|
|
|
138
169
|
* way out, secrets untouched.
|
|
139
170
|
*/
|
|
140
171
|
unlock(password: string): Promise<Uint8Array>;
|
|
172
|
+
private _unlock;
|
|
141
173
|
/** Re-wrap the DEK under a new password (fresh salt, current KDF). Secrets and passkeys are untouched. */
|
|
142
174
|
changePassword(oldPassword: string, newPassword: string): Promise<void>;
|
|
143
175
|
/** Public view of the registered passkeys (ids, labels; whether each can verify assertions). */
|
|
@@ -156,7 +188,7 @@ declare class Vault {
|
|
|
156
188
|
* Register a passkey as a second unlock path: the DEK (from the unlocked session)
|
|
157
189
|
* is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
|
|
158
190
|
* the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
|
|
159
|
-
* thereby upgraded) first.
|
|
191
|
+
* thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
|
|
160
192
|
*/
|
|
161
193
|
addPasskey(dek: Uint8Array, passkey: {
|
|
162
194
|
id: string;
|
|
@@ -165,6 +197,7 @@ declare class Vault {
|
|
|
165
197
|
publicKey?: string | undefined;
|
|
166
198
|
alg?: number | undefined;
|
|
167
199
|
}): Promise<void>;
|
|
200
|
+
private _addPasskey;
|
|
168
201
|
/** Unseal the DEK with a passkey's PRF output. `wrong-password` when the box does not open, `missing` when the id is unknown. */
|
|
169
202
|
unlockWithPasskey(id: string, prf: Uint8Array): Promise<Uint8Array>;
|
|
170
203
|
removePasskey(id: string): Promise<void>;
|
|
@@ -176,10 +209,16 @@ declare class Vault {
|
|
|
176
209
|
deleteSecret(sourceId: string): Promise<void>;
|
|
177
210
|
/** Remove the whole vault. The explicit destructive flow only (back up → wipe → create). */
|
|
178
211
|
destroy(): Promise<void>;
|
|
212
|
+
private _exclusive;
|
|
213
|
+
/** Store an envelope this build will open again (bounds checked before it is written). */
|
|
214
|
+
private _write;
|
|
179
215
|
private _random;
|
|
180
216
|
/** A fresh envelope (v2 by default, v1 with `kdf: 'pbkdf2'`) wrapping `dek` under `password`. */
|
|
181
217
|
private _sealEnvelope;
|
|
182
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* The caller's DEK must open this envelope's secrets — it is the key the password protects, not
|
|
220
|
+
* any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
|
|
221
|
+
*/
|
|
183
222
|
private _requireDek;
|
|
184
223
|
private _derivePbkdf2;
|
|
185
224
|
private _deriveScrypt;
|
|
@@ -232,6 +271,13 @@ declare class Session {
|
|
|
232
271
|
private readonly _alarm;
|
|
233
272
|
private readonly _now;
|
|
234
273
|
private readonly _onLock;
|
|
274
|
+
/**
|
|
275
|
+
* Every operation on the stored record runs here, one after another: a `touch` that read the
|
|
276
|
+
* record before a `lock` removed it would otherwise write it back and undo the lock.
|
|
277
|
+
*/
|
|
278
|
+
private _queue;
|
|
279
|
+
/** Bumped by every lock; a `touch` writes only when no lock happened since it read the record. */
|
|
280
|
+
private _epoch;
|
|
235
281
|
constructor(options: SessionOptions);
|
|
236
282
|
/** Store the DEK and arm the auto-lock. The caller's copy is zeroized. */
|
|
237
283
|
unlock(dek: Uint8Array): Promise<void>;
|
|
@@ -250,6 +296,9 @@ declare class Session {
|
|
|
250
296
|
/** Change the timer (options page); re-arms from now when unlocked. 0 disables. */
|
|
251
297
|
setAutoLockMs(ms: number): Promise<void>;
|
|
252
298
|
onLock(callback: () => void): () => void;
|
|
299
|
+
private _serial;
|
|
300
|
+
/** The lock itself; callers are already in the queue. */
|
|
301
|
+
private _lockNow;
|
|
253
302
|
private _expiry;
|
|
254
303
|
private _arm;
|
|
255
304
|
private _read;
|
|
@@ -655,33 +704,25 @@ declare function memoryApprovalWindow(): ApprovalWindow & {
|
|
|
655
704
|
userClose(id: string): void;
|
|
656
705
|
};
|
|
657
706
|
|
|
658
|
-
/**
|
|
659
|
-
* The request router: what a dApp may ask and what happens to each request.
|
|
660
|
-
* Policy ported from Vaulty's in-app browser (`mobile/lib/browser.ts`):
|
|
661
|
-
*
|
|
662
|
-
* - the origin is the browser's (checked by the service worker before this runs);
|
|
663
|
-
* - accounts are exposed only to origins the user connected (`eth_requestAccounts`
|
|
664
|
-
* → approval window); `eth_accounts` is `[]` otherwise;
|
|
665
|
-
* - chain switching and adding go through the approval window; a chain can be
|
|
666
|
-
* added only if the asset catalog knows it, with https RPCs;
|
|
667
|
-
* - read-only JSON-RPC is answered from the wallet's own clients (the networks
|
|
668
|
-
* table's failover list), never from a URL the page names;
|
|
669
|
-
* - `eth_sign` (blind hash signing) is never offered; the other signing methods
|
|
670
|
-
* go to the `sign` hook (the review flow) when the wallet provides one;
|
|
671
|
-
* - everything else is refused with 4200.
|
|
672
|
-
*
|
|
673
|
-
* Errors leave as {@link RouterError} (EIP-1193 codes) or {@link ReviewDeclined}
|
|
674
|
-
* (4001); the service worker turns both into a `RelayResponse.error`.
|
|
675
|
-
*/
|
|
676
|
-
|
|
677
707
|
declare class RouterError extends Error {
|
|
678
708
|
readonly code: number;
|
|
679
709
|
readonly data: unknown;
|
|
680
710
|
constructor(code: number, message: string, data?: unknown);
|
|
681
711
|
static from(e: RelayError): RouterError;
|
|
682
712
|
}
|
|
683
|
-
/**
|
|
684
|
-
|
|
713
|
+
/** Options for {@link toRelayError}. */
|
|
714
|
+
interface RelayErrorOptions {
|
|
715
|
+
/** Gets every error that is NOT passed to the page, in full — the extension's own log. */
|
|
716
|
+
log?: (error: unknown) => void;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Any error → the `RelayError` for the page. Wallet refusals keep their EIP-1193 code
|
|
720
|
+
* ({@link RouterError}, {@link ReviewDeclined}, a core `UserRejectedError` → 4001), a node's own
|
|
721
|
+
* JSON-RPC error keeps its code and revert data; their messages lose URLs. Everything else is
|
|
722
|
+
* `-32603 Internal error` on the page and goes to `options.log` in full — transport errors name
|
|
723
|
+
* the RPC URL (often with the provider key in it) and the request.
|
|
724
|
+
*/
|
|
725
|
+
declare function toRelayError(e: unknown, options?: RelayErrorOptions): RelayError;
|
|
685
726
|
/** Read-only methods answered from our RPC without asking the user. */
|
|
686
727
|
declare const READ_METHODS: ReadonlySet<string>;
|
|
687
728
|
/** Methods that produce a signature — the review flow's business (step 4), never answered here. */
|
|
@@ -1476,4 +1517,4 @@ declare class RecipientBook {
|
|
|
1476
1517
|
}>;
|
|
1477
1518
|
}
|
|
1478
1519
|
|
|
1479
|
-
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageRequest, type PageResponse, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
|
1520
|
+
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageRequest, type PageResponse, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|