feat: authenticate sentinel and tx-api calls#40667
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (4 files, +124 -9)
💸 @MetaMask/transactions (2 files, +119 -0)
|
Builds ready [35ef7aa]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [d92e017]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [678cee1]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Builds ready [a1fafb6]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [5d6a092]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [1ff8f9d]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| * Optional bearer token getter, set by the extension at init to authenticate | ||
| * Sentinel and Transaction API calls via core-backend (AuthenticationController). | ||
| */ | ||
| let getBearerTokenForSentinel: (() => Promise<string | undefined>) | undefined; |
There was a problem hiding this comment.
Dangling state isn't ideal, but I appreciate it simplifies the calls to these utils.
Is there a global messenger reference we could use to retrieve it from the AuthenticationController dynamically?
There was a problem hiding this comment.
From what I understand no, there is no messenger available to retrieve it here, as sentinel-api or its direct callers (transaction-relay.ts, subscription-service.ts, etc.) are plain utility modules, they aren’t part of the controller init system and don’t get a restricted messenger as an init parameter. There could be a possibility to thread a messenger from all the indirect callers, but at the cost of complicating the PR and actually beginning to migrate sentinel-api to its own controller. It seems like a lot for such a small change.
| try { | ||
| const token = await getBearerTokenForSentinel(); | ||
| if (token) { | ||
| headers.Authorization = token.startsWith('Bearer ') |
There was a problem hiding this comment.
Why do we have to validate the result here, could this return other token formats?
There was a problem hiding this comment.
No, sorry for that, I cleaned it up
Builds ready [1e1afdf]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Builds ready [4ffe39e]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|



Description
Authenticate calls to Sentinel and Transaction API, with a focus on calls submitting transactions.
Authenticating simulations require a transaction controller update, it is out of the scope of this PR.
A linked PR for mobile is at MetaMask/metamask-mobile#27410
Changelog
CHANGELOG entry: authenticate transaction submission to sentinel and transaction API
Related issues
Fixes:
Manual testing steps
For each of these:
eth_sendRelayTransaction)Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds AuthenticationController-derived bearer tokens to outbound Sentinel and relay (Transaction API) requests, touching request construction and controller initialization paths. Risk is moderate due to potential header/authorization regressions affecting transaction submission and polling flows.
Overview
Adds optional bearer-token authentication for Sentinel and transaction relay requests. The extension now wires an
AuthenticationController:getBearerTokengetter into Smart Transactions init and a global Sentinel auth setter, and uses it to attachAuthorization: Bearer ...when available.Sentinel network-flag fetches and relay transaction submit/poll now call
getSentinelApiHeadersAsync()and pass headers through;jsonRpcRequestwas extended to accept optional extra headers. Tests were updated/added to cover token present/absent/throwing cases and to assert headers are included, and@metamask/smart-transactions-controllerwas bumped to^22.7.0.Written by Cursor Bugbot for commit 4ffe39e. This will update automatically on new commits. Configure here.