@anywalletkit/extension-kit 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,17 +37,18 @@ pnpm add @anywalletkit/extension-kit @anywalletkit/core @anywalletkit/keyring
37
37
  | Session | `Session`, `chromeSessionStorage`, `chromeAlarms`, `SESSION_DEFAULT_AUTOLOCK_MS` | the DEK in `chrome.storage.session` with an expiry and an alarm; `getKey()` re-checks the expiry itself |
38
38
  | Keyring adapters | `chromeKeyringStorage`, `vaultSecretStorage` | `@anywalletkit/keyring` metadata as plain JSON, secrets through the vault, one DEK use per call |
39
39
  | Relay | `PageRequest` / `RelayRequest` shapes and guards, `isRelayMethod`, `pageRequestFrom`, `stampOrigin`, `checkSenderOrigin`, `RELAY_ERRORS` | page ⇄ content script ⇄ service worker messages; the content script takes only messages the page window itself posted (`pageRequestFrom(event, window)`: an iframe's `parent.postMessage` is not the site), and the origin is the browser's (`port.sender`), never the page's |
40
- | Router | `RequestRouter`, `READ_METHODS`, `SIGNING_METHODS`, `toRelayError` | what a dApp may call: accounts only for connected origins, chain add / switch through the approval window, reads from the wallet's own RPCs, `eth_sign` never offered, everything else 4200 |
41
- | Permissions | `PermissionStore`, `CHAIN_ACCOUNT_KEYS` | per-origin accounts (EVM, Solana, TON, Tron, Bitcoin, NEAR) and chain |
42
- | Approvals | `ApprovalQueue`, `ReviewDeclined`, `QueueLimitError`, `APPROVALS_MAX_PENDING_PER_ORIGIN` | one approval window at a time, at most 3 pending requests per origin and one pending `connect`; transport notes (`setVia`) for WalletConnect peers |
43
- | Signing | `classifySignRequest`, `prepareTransaction`, `createSignHandler`, `messageText` | connected-address and chain checks, EIP-7702 delegations from sites refused, nonce / gas / fees from the wallet's RPC |
40
+ | Router | `RequestRouter`, `READ_METHODS`, `SIGNING_METHODS`, `GETLOGS_MAX_SPAN_UNCONNECTED`, `toRelayError` | what a dApp may call: per-site grants (an origin sees the accounts it was granted that are active right now; connecting another account adds it to that origin only; signatures only for a granted and active account), chain add / switch through the approval window, reads from the wallet's own RPCs (`eth_getLogs` bounded to 1000 blocks for unconnected origins), `eth_sign` never offered, everything else 4200 |
41
+ | Permissions | `PermissionStore`, `CHAIN_ACCOUNT_KEYS` | per-origin accounts (EVM, Solana, TON, Tron, Bitcoin, NEAR) and chain; `grant` adds accounts to one origin |
42
+ | Approvals | `ApprovalQueue`, `ReviewDeclined`, `QueueLimitError`, `APPROVALS_MAX_PENDING_PER_ORIGIN`, `APPROVALS_MAX_PENDING_PER_SITE`, `APPROVALS_MAX_PENDING_TOTAL` | one approval window at a time; at most 3 pending requests per origin, 5 per site (registrable domain), 20 in all, one pending `connect`; a per-site sheet rate with a doubling cooldown; `declineOrigin` / `declineSite`; `exempt` for the wallet's own pages; transport notes (`setVia`) for WalletConnect peers |
43
+ | Limits | `siteOf`, `MULTI_LABEL_SUFFIXES`, `TokenBucket` | a conservative registrable domain (eTLD+1, no full Public Suffix List: the last two labels, three under known multi-label and hosting suffixes) and a keyed token bucket, for per-site limits |
44
+ | Signing | `classifySignRequest`, `prepareTransaction`, `createSignHandler`, `messageText`, `revealHidden`, `gasLimitExcessive` | connected-address and chain checks, EIP-7702 delegations from sites refused, nonce / gas / fees from the wallet's RPC, a site's gas limit checked against the estimate (`gasCheck`), invisible / bidi characters escaped as `⟨U+XXXX⟩` (`hiddenChars`), a personal_sign of a raw 32-byte hash refused unless `allowBlindHash` (then `blindHash`) |
44
45
  | Networks | `NetworksTable`, `DEFAULT_NETWORKS`, `parseAddChainParams`, Solana / TON / Tron endpoints | EVM networks with public RPC failover lists; `wallet_addEthereumChain` only for catalog chains, https only, `eth_chainId` verified, site-supplied RPCs stamped `custom` |
45
46
  | Review gate | `ReviewGate`, `evmCallMatcher`, `chainTxMatcher` | after one sheet reviewed a whole plan, exactly those operations pass once within a TTL |
46
47
  | Swaps | `quoteRoutes`, `reviewSwapPlan`, `executionFloor`, `SwapsStore`, `SwapTracker`, `parseSwapId` | progressive quotes over swap2 providers, one review sheet per plan (a gasless order is shown and matched by its EIP-712 hash), pre-approvals bound to the reviewing account (`meta.account`), pending swaps resumed across worker restarts |
47
48
  | Earn | `reviewEarnPlan`, `earnPlanMatchers` | one sheet for an Earn module's plan (approvals + call), bound to `meta.account` |
48
49
  | TON Connect | `parseConnectRequest`, `parseSendTransaction`, `parseSignData`, `tonProofMessage`, `tonSignDataMessage` | the pure-data half of TON Connect v2 (the digests `ton_proof` and `signData` sign, to verify them); the account signs with `signTonProof` / `signTonConnectData` (wallet-ton) — `sign()` refuses 32-byte digests |
49
50
  | Phishing | `PhishingDetector` | MetaMask `eth-phishing-detect` list format, shipped with the build (never fetched at runtime); a listed site is refused (`refusal` → `refuse` on `ApprovalQueue` and `RequestRouter`, 4100, no window); fuzzy lookalikes, brand-in-label, punycode warn |
50
- | SIWE | `parseSiwe`, `siweProblems`, `describeSiwe` | EIP-4361 sign-in messages: domain vs. the asking site, address, chain, expiry, nonce (warnings) |
51
+ | SIWE | `parseSiwe`, `siweProblems`, `describeSiwe`, `siweCrossSite` | EIP-4361 sign-in messages: domain vs. the asking site (`crossSite`), address, chain, expiry, nonce (warnings); bidi / zero-width characters refused |
51
52
  | Address poisoning | `lookalikeOf`, `RecipientBook` | warns when a new recipient imitates one the user confirmed |
52
53
  | WebAuthn | `verifyAssertion`, `approvalChallenge`, `derToRaw`, `rawToDer` | ES256 assertion check for "passkey on every signature"; the worker never trusts the page's word |
53
54
 
@@ -73,12 +74,32 @@ pnpm add @anywalletkit/extension-kit @anywalletkit/core @anywalletkit/keyring
73
74
  compromise, `rotateVaultKey(password)` makes a fresh DEK, re-seals every
74
75
  secret, drops the passkeys (register them again) and writes one envelope;
75
76
  hand the returned DEK to `session.unlock`, which replaces the old one.
76
- `setSecret` refuses a DEK that does not open the vault's secrets.
77
+ `rotateVaultKey(oldPassword, newPassword)` is the password change with a
78
+ fresh DEK. `setSecret` refuses a DEK that does not open the vault's secrets,
79
+ and `unlock` / `unlockWithPasskey` refuse (`wrong-password`) a box that opens
80
+ but holds another vault's key (a spliced dek or passkey box).
77
81
  - **Unlocked state.** Only the DEK is kept, in `chrome.storage.session`
78
82
  (memory-only, trusted contexts), with an expiry enforced on every read and an
79
83
  alarm that locks; key buffers this package owns are zeroized after use.
80
84
  `unlock` / `lock` / `touch` / `getKey` run one at a time, so activity racing a
81
- lock never brings the key back.
85
+ lock never brings the key back. `setAutoLockMs` never pushes the deadline out
86
+ (safe to call at every worker start); `touch` only for explicit user gestures.
87
+ - **Stored settings and grants.** `chrome.storage.local` is not authenticated.
88
+ `macJsonStorage(store, { label, key })` adds an HMAC-SHA256 under a key derived
89
+ from the DEK (`deriveStorageMacKey`); a plain, edited or foreign value reads as
90
+ `null` (`read()` says why: `unsigned` / `invalid`). Without a key (locked) it
91
+ reads the stored value unverified and writes it unsigned (or refuses, by
92
+ option), so verify at unlock; after `rotateVaultKey`, `rekey` the stores.
93
+ Rollback: share one `storageVersionLedger({ manifest, mark })` between the
94
+ stores (`versions`) and every signed value carries a version inside its MAC; a
95
+ signed manifest in the same area lists the latest of each, and `mark` (session
96
+ storage) remembers the highest manifest epoch. An older signed value put back,
97
+ or a deleted one, reads as `stale`; so does everything when the manifest is
98
+ missing, edited, or — while the browser session lives — older than the mark.
99
+ Not detectable: the whole area put back (or wiped) consistently when there is
100
+ no mark, i.e. across a browser restart or an extension reload — a restored
101
+ profile backup looks the same. `condemn(key)` after a refused manifest, then
102
+ rewrite the stores; on key rotation `ledger.rekey` first, then each store.
82
103
  - **Errors to pages.** `toRelayError(e, { log })` passes the wallet's own refusals
83
104
  (EIP-1193 codes) and a node's JSON-RPC error (code, revert data) with URLs
84
105
  removed; anything else is `-32603 Internal error` on the page and goes to `log`.