Skip to content

feat(kyc-controller): add JWKS cache - #10894

Merged
jiexi merged 6 commits into
mainfrom
jl/KYC-47/jwks-1day-ttl-cache
Oct 20, 2026
Merged

jiexi merged 6 commits into
mainfrom
jl/KYC-47/jwks-1day-ttl-cache

Conversation

@jiexi

@jiexi jiexi commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Adds 1d TTL caching idOS JWKS fetches

See: https://consensyssoftware.atlassian.net/browse/KYC-47

Screen.Recording.2026-10-20.at.12.05.21.PM.mov

Notice the second token refresh does not result in jwks.json fetches


Note

Medium Risk
JWKS caching affects JWT verification during UKYC session creation; a stale key set could persist up to 24h unless invalidated, though issuer rotation is expected to be infrequent.

Overview
Caches idOS JWKS fetches for 24 hours in KycService so repeated UKYC session verification does not hit the enclave and relay well-known endpoints on every call.

#fetchWellKnownJwks now goes through fetchQuery with a one-day staleTime and matching gcTime (so entries are not garbage-collected while still fresh). Only successful, validated JWKS responses are cached; HTTP failures and malformed bodies are retried on the next call, and concurrent callers for the same URL share a single in-flight request. fetchIdosEnclaveJwks and fetchIdosRelayJwks inherit this behavior; docs and the changelog note that KycService:invalidateQueries clears these entries. Tests cover TTL reuse, no caching on errors, deduplication, and test teardown via service.destroy().

Reviewed by Cursor Bugbot for commit 055abd7. Bugbot is set up for automated code reviews on this repo. Configure here.

@jiexi
jiexi requested review from a team as code owners October 19, 2026 21:04
@jiexi jiexi changed the title add JWKS cache feat(kyc-controller): add JWKS cache Oct 19, 2026
@jiexi
jiexi deployed to default-branch October 19, 2026 21:04 — with GitHub Actions Active
Co-authored-by: Cursor <cursoragent@cursor.com>
amitabh94
amitabh94 previously approved these changes Oct 19, 2026
@jiexi

jiexi commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@11.1.0-preview-686aaf7
@metamask-previews/accounts-controller@40.1.0-preview-686aaf7
@metamask-previews/address-book-controller@8.0.0-preview-686aaf7
@metamask-previews/advanced-chart-core@1.0.0-preview-686aaf7
@metamask-previews/ai-controllers@2.0.0-preview-686aaf7
@metamask-previews/analytics-controller@4.0.0-preview-686aaf7
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-686aaf7
@metamask-previews/announcement-controller@9.0.0-preview-686aaf7
@metamask-previews/app-metadata-controller@3.0.0-preview-686aaf7
@metamask-previews/approval-controller@10.0.0-preview-686aaf7
@metamask-previews/assets-controller@19.1.0-preview-686aaf7
@metamask-previews/assets-controllers@112.1.2-preview-686aaf7
@metamask-previews/authenticated-user-storage@4.1.0-preview-686aaf7
@metamask-previews/base-controller@10.1.0-preview-686aaf7
@metamask-previews/base-data-service@2.1.0-preview-686aaf7
@metamask-previews/bitcoin-regtest-up@2.0.0-preview-686aaf7
@metamask-previews/bridge-controller@82.0.3-preview-686aaf7
@metamask-previews/bridge-status-controller@76.4.0-preview-686aaf7
@metamask-previews/build-utils@4.0.0-preview-686aaf7
@metamask-previews/chain-agnostic-permission@2.0.0-preview-686aaf7
@metamask-previews/chomp-api-service@6.0.1-preview-686aaf7
@metamask-previews/claims-controller@1.0.3-preview-686aaf7
@metamask-previews/client-controller@2.0.0-preview-686aaf7
@metamask-previews/client-utils@3.0.4-preview-686aaf7
@metamask-previews/compliance-controller@3.0.0-preview-686aaf7
@metamask-previews/composable-controller@13.0.0-preview-686aaf7
@metamask-previews/config-registry-controller@5.0.0-preview-686aaf7
@metamask-previews/connectivity-controller@1.0.0-preview-686aaf7
@metamask-previews/controller-utils@13.0.0-preview-686aaf7
@metamask-previews/core-backend@12.3.0-preview-686aaf7
@metamask-previews/cryptography@1.1.2-preview-686aaf7
@metamask-previews/delegation-controller@4.0.0-preview-686aaf7
@metamask-previews/earn-controller@13.0.2-preview-686aaf7
@metamask-previews/eip-5792-middleware@4.0.1-preview-686aaf7
@metamask-previews/eip-7702-internal-rpc-middleware@1.0.0-preview-686aaf7
@metamask-previews/eip1193-permission-middleware@3.0.0-preview-686aaf7
@metamask-previews/eth-block-tracker@16.0.0-preview-686aaf7
@metamask-previews/eth-json-rpc-middleware@25.0.0-preview-686aaf7
@metamask-previews/eth-json-rpc-provider@7.0.0-preview-686aaf7
@metamask-previews/foundryup@2.0.0-preview-686aaf7
@metamask-previews/gas-fee-controller@27.0.0-preview-686aaf7
@metamask-previews/gator-permissions-controller@6.0.1-preview-686aaf7
@metamask-previews/geolocation-controller@2.0.0-preview-686aaf7
@metamask-previews/java-tron-up@2.0.0-preview-686aaf7
@metamask-previews/json-rpc-engine@11.0.0-preview-686aaf7
@metamask-previews/json-rpc-middleware-stream@9.0.0-preview-686aaf7
@metamask-previews/keyring-controller@28.2.0-preview-686aaf7
@metamask-previews/kyc-controller@0.10.0-preview-686aaf7
@metamask-previews/local-node-utils@2.0.0-preview-686aaf7
@metamask-previews/logging-controller@10.0.0-preview-686aaf7
@metamask-previews/marketing-consent-controller@1.0.0-preview-686aaf7
@metamask-previews/message-manager@15.0.0-preview-686aaf7
@metamask-previews/messenger@3.0.0-preview-686aaf7
@metamask-previews/messenger-cli@1.0.0-preview-686aaf7
@metamask-previews/mfa-recovery-controller@0.0.0-preview-686aaf7
@metamask-previews/money-account-api-data-service@2.2.0-preview-686aaf7
@metamask-previews/money-account-balance-service@3.1.2-preview-686aaf7
@metamask-previews/money-account-controller@2.0.0-preview-686aaf7
@metamask-previews/money-account-mfa-whitelist@0.1.0-preview-686aaf7
@metamask-previews/money-account-upgrade-controller@5.1.0-preview-686aaf7
@metamask-previews/money-account-utils@2.1.0-preview-686aaf7
@metamask-previews/multichain-account-service@14.1.0-preview-686aaf7
@metamask-previews/multichain-api-middleware@5.0.0-preview-686aaf7
@metamask-previews/multichain-network-controller@4.0.0-preview-686aaf7
@metamask-previews/multichain-transactions-controller@8.0.0-preview-686aaf7
@metamask-previews/name-controller@10.0.0-preview-686aaf7
@metamask-previews/network-connection-banner-controller@1.0.0-preview-686aaf7
@metamask-previews/network-controller@37.1.0-preview-686aaf7
@metamask-previews/network-enablement-controller@7.0.2-preview-686aaf7
@metamask-previews/notification-services-controller@30.0.0-preview-686aaf7
@metamask-previews/passkey-controller@4.1.0-preview-686aaf7
@metamask-previews/permission-controller@14.0.0-preview-686aaf7
@metamask-previews/permission-log-controller@6.0.0-preview-686aaf7
@metamask-previews/perps-controller@20.1.0-preview-686aaf7
@metamask-previews/phishing-controller@18.2.1-preview-686aaf7
@metamask-previews/platform-api-docs@0.2.1-preview-686aaf7
@metamask-previews/polling-controller@17.0.0-preview-686aaf7
@metamask-previews/preferences-controller@24.0.0-preview-686aaf7
@metamask-previews/profile-controller@1.1.0-preview-686aaf7
@metamask-previews/profile-metrics-controller@5.1.3-preview-686aaf7
@metamask-previews/profile-sync-controller@34.0.3-preview-686aaf7
@metamask-previews/ramps-controller@27.0.1-preview-686aaf7
@metamask-previews/rate-limit-controller@8.0.0-preview-686aaf7
@metamask-previews/react-data-query@2.0.0-preview-686aaf7
@metamask-previews/remote-feature-flag-controller@7.0.0-preview-686aaf7
@metamask-previews/sample-controllers@6.0.0-preview-686aaf7
@metamask-previews/seedless-onboarding-controller@12.0.0-preview-686aaf7
@metamask-previews/selected-network-controller@27.0.0-preview-686aaf7
@metamask-previews/sentinel-api-service@2.1.0-preview-686aaf7
@metamask-previews/shield-controller@7.0.4-preview-686aaf7
@metamask-previews/signature-controller@40.0.0-preview-686aaf7
@metamask-previews/smart-transactions-controller@27.1.0-preview-686aaf7
@metamask-previews/snap-account-service@4.0.0-preview-686aaf7
@metamask-previews/social-controllers@3.8.0-preview-686aaf7
@metamask-previews/solana-test-validator-up@2.0.0-preview-686aaf7
@metamask-previews/stellar-quickstart-up@0.0.0-preview-686aaf7
@metamask-previews/storage-service@2.0.0-preview-686aaf7
@metamask-previews/subscription-controller@14.0.0-preview-686aaf7
@metamask-previews/transaction-controller@72.2.1-preview-686aaf7
@metamask-previews/transaction-pay-controller@30.1.0-preview-686aaf7
@metamask-previews/transaction-pay-middleware@0.0.0-preview-686aaf7
@metamask-previews/user-operation-controller@42.0.1-preview-686aaf7
@metamask-previews/utils@12.0.0-preview-686aaf7
@metamask-previews/wallet@18.0.0-preview-686aaf7
@metamask-previews/wallet-cli@0.0.0-preview-686aaf7

@amitabh94 amitabh94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jiexi
jiexi added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 1ac3296 Oct 20, 2026
45 checks passed
@jiexi
jiexi deleted the jl/KYC-47/jwks-1day-ttl-cache branch October 20, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants