@anywalletkit/extension-kit 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/index.cjs +188 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -22
- package/dist/index.d.ts +60 -22
- package/dist/index.js +188 -64
- 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). */
|
|
@@ -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,6 +209,9 @@ 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;
|
|
@@ -232,6 +268,13 @@ declare class Session {
|
|
|
232
268
|
private readonly _alarm;
|
|
233
269
|
private readonly _now;
|
|
234
270
|
private readonly _onLock;
|
|
271
|
+
/**
|
|
272
|
+
* Every operation on the stored record runs here, one after another: a `touch` that read the
|
|
273
|
+
* record before a `lock` removed it would otherwise write it back and undo the lock.
|
|
274
|
+
*/
|
|
275
|
+
private _queue;
|
|
276
|
+
/** Bumped by every lock; a `touch` writes only when no lock happened since it read the record. */
|
|
277
|
+
private _epoch;
|
|
235
278
|
constructor(options: SessionOptions);
|
|
236
279
|
/** Store the DEK and arm the auto-lock. The caller's copy is zeroized. */
|
|
237
280
|
unlock(dek: Uint8Array): Promise<void>;
|
|
@@ -250,6 +293,9 @@ declare class Session {
|
|
|
250
293
|
/** Change the timer (options page); re-arms from now when unlocked. 0 disables. */
|
|
251
294
|
setAutoLockMs(ms: number): Promise<void>;
|
|
252
295
|
onLock(callback: () => void): () => void;
|
|
296
|
+
private _serial;
|
|
297
|
+
/** The lock itself; callers are already in the queue. */
|
|
298
|
+
private _lockNow;
|
|
253
299
|
private _expiry;
|
|
254
300
|
private _arm;
|
|
255
301
|
private _read;
|
|
@@ -655,33 +701,25 @@ declare function memoryApprovalWindow(): ApprovalWindow & {
|
|
|
655
701
|
userClose(id: string): void;
|
|
656
702
|
};
|
|
657
703
|
|
|
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
704
|
declare class RouterError extends Error {
|
|
678
705
|
readonly code: number;
|
|
679
706
|
readonly data: unknown;
|
|
680
707
|
constructor(code: number, message: string, data?: unknown);
|
|
681
708
|
static from(e: RelayError): RouterError;
|
|
682
709
|
}
|
|
683
|
-
/**
|
|
684
|
-
|
|
710
|
+
/** Options for {@link toRelayError}. */
|
|
711
|
+
interface RelayErrorOptions {
|
|
712
|
+
/** Gets every error that is NOT passed to the page, in full — the extension's own log. */
|
|
713
|
+
log?: (error: unknown) => void;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Any error → the `RelayError` for the page. Wallet refusals keep their EIP-1193 code
|
|
717
|
+
* ({@link RouterError}, {@link ReviewDeclined}, a core `UserRejectedError` → 4001), a node's own
|
|
718
|
+
* JSON-RPC error keeps its code and revert data; their messages lose URLs. Everything else is
|
|
719
|
+
* `-32603 Internal error` on the page and goes to `options.log` in full — transport errors name
|
|
720
|
+
* the RPC URL (often with the provider key in it) and the request.
|
|
721
|
+
*/
|
|
722
|
+
declare function toRelayError(e: unknown, options?: RelayErrorOptions): RelayError;
|
|
685
723
|
/** Read-only methods answered from our RPC without asking the user. */
|
|
686
724
|
declare const READ_METHODS: ReadonlySet<string>;
|
|
687
725
|
/** Methods that produce a signature — the review flow's business (step 4), never answered here. */
|
|
@@ -1476,4 +1514,4 @@ declare class RecipientBook {
|
|
|
1476
1514
|
}>;
|
|
1477
1515
|
}
|
|
1478
1516
|
|
|
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 };
|
|
1517
|
+
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). */
|
|
@@ -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,6 +209,9 @@ 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;
|
|
@@ -232,6 +268,13 @@ declare class Session {
|
|
|
232
268
|
private readonly _alarm;
|
|
233
269
|
private readonly _now;
|
|
234
270
|
private readonly _onLock;
|
|
271
|
+
/**
|
|
272
|
+
* Every operation on the stored record runs here, one after another: a `touch` that read the
|
|
273
|
+
* record before a `lock` removed it would otherwise write it back and undo the lock.
|
|
274
|
+
*/
|
|
275
|
+
private _queue;
|
|
276
|
+
/** Bumped by every lock; a `touch` writes only when no lock happened since it read the record. */
|
|
277
|
+
private _epoch;
|
|
235
278
|
constructor(options: SessionOptions);
|
|
236
279
|
/** Store the DEK and arm the auto-lock. The caller's copy is zeroized. */
|
|
237
280
|
unlock(dek: Uint8Array): Promise<void>;
|
|
@@ -250,6 +293,9 @@ declare class Session {
|
|
|
250
293
|
/** Change the timer (options page); re-arms from now when unlocked. 0 disables. */
|
|
251
294
|
setAutoLockMs(ms: number): Promise<void>;
|
|
252
295
|
onLock(callback: () => void): () => void;
|
|
296
|
+
private _serial;
|
|
297
|
+
/** The lock itself; callers are already in the queue. */
|
|
298
|
+
private _lockNow;
|
|
253
299
|
private _expiry;
|
|
254
300
|
private _arm;
|
|
255
301
|
private _read;
|
|
@@ -655,33 +701,25 @@ declare function memoryApprovalWindow(): ApprovalWindow & {
|
|
|
655
701
|
userClose(id: string): void;
|
|
656
702
|
};
|
|
657
703
|
|
|
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
704
|
declare class RouterError extends Error {
|
|
678
705
|
readonly code: number;
|
|
679
706
|
readonly data: unknown;
|
|
680
707
|
constructor(code: number, message: string, data?: unknown);
|
|
681
708
|
static from(e: RelayError): RouterError;
|
|
682
709
|
}
|
|
683
|
-
/**
|
|
684
|
-
|
|
710
|
+
/** Options for {@link toRelayError}. */
|
|
711
|
+
interface RelayErrorOptions {
|
|
712
|
+
/** Gets every error that is NOT passed to the page, in full — the extension's own log. */
|
|
713
|
+
log?: (error: unknown) => void;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Any error → the `RelayError` for the page. Wallet refusals keep their EIP-1193 code
|
|
717
|
+
* ({@link RouterError}, {@link ReviewDeclined}, a core `UserRejectedError` → 4001), a node's own
|
|
718
|
+
* JSON-RPC error keeps its code and revert data; their messages lose URLs. Everything else is
|
|
719
|
+
* `-32603 Internal error` on the page and goes to `options.log` in full — transport errors name
|
|
720
|
+
* the RPC URL (often with the provider key in it) and the request.
|
|
721
|
+
*/
|
|
722
|
+
declare function toRelayError(e: unknown, options?: RelayErrorOptions): RelayError;
|
|
685
723
|
/** Read-only methods answered from our RPC without asking the user. */
|
|
686
724
|
declare const READ_METHODS: ReadonlySet<string>;
|
|
687
725
|
/** Methods that produce a signature — the review flow's business (step 4), never answered here. */
|
|
@@ -1476,4 +1514,4 @@ declare class RecipientBook {
|
|
|
1476
1514
|
}>;
|
|
1477
1515
|
}
|
|
1478
1516
|
|
|
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 };
|
|
1517
|
+
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 };
|