-
-
Notifications
You must be signed in to change notification settings - Fork 256
chore: call revoke token in background #6184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: call revoke token in background #6184
Conversation
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
| await this.#createNewVaultWithAuthData({ | ||
| password, | ||
| rawToprfEncryptionKey: toprfEncryptionKey, | ||
| rawToprfPwEncryptionKey: toprfPwEncryptionKey, | ||
| rawToprfAuthKeyPair: toprfAuthKeyPair, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that #createNewVaultWithAuthData is potentially an expensive operation.
it runs encryptWithDetail(pw, vaultData), which involves the intentionally slow pbkdf2 key derivation step.
as you are increasing the usage of vault encryption, you are driving up cpu usage.
| this.#revokeRefreshTokenAndUpdateState(revokeToken) | ||
| .then(() => { | ||
| // re-creating vault to persist the new revoke token | ||
| return this.#createNewVaultWithAuthData({ | ||
| password, | ||
| rawToprfEncryptionKey: toprfEncryptionKey, | ||
| rawToprfPwEncryptionKey: toprfPwEncryptionKey, | ||
| rawToprfAuthKeyPair: toprfAuthKeyPair, | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| log('Error revoking refresh token', error); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writing the vault asynchronously like this is dangerous as it can lead to vault corruption.
imagine another piece of code updates the vault in the meantime. when this code here is executed after that, the vault will be overwritten with some old data.
| this.#revokeRefreshTokenAndUpdateState(revokeToken) | ||
| .then(() => { | ||
| // re-creating vault to persist the new revoke token. | ||
| // TODO: Optimize this function such that updates to vault wont require re-creating the vault. | ||
| return this.#createNewVaultWithAuthData({ | ||
| password: globalPassword, | ||
| rawToprfEncryptionKey: latestEncKey, | ||
| rawToprfPwEncryptionKey: latestPwEncKey, | ||
| rawToprfAuthKeyPair: latestAuthKeyPair, | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| log('Error revoking refresh token', error); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above, we can't do this
## Explanation Support Relay quotes requiring multiple transactions, such as a token approval and deposit. Use fallback gas limit if missing in transaction data. ## References Related to [#6184](MetaMask/MetaMask-planning#6184) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds multi-transaction support for Relay quotes with batch submission, fallback gas handling, and shared transaction ID collection utility. > > - **Relay strategy**: > - Support multiple transactions per quote: submit via `TransactionController:addTransactionBatch`, collect required IDs with `collectTransactionIds`, wait for all confirmations, and return last tx `hash`. > - Poll Relay status from the last step; set `isIntentComplete` when `skipTransaction`. > - Normalize params with fallback `gas` using `RELAY_FALLBACK_GAS_LIMIT`. > - Quote fees: compute source network fee using total gas across items or fallback when missing. > - **Utils**: > - Add `utils/transaction#collectTransactionIds` and use it in Bridge/Relay; remove in-file implementation from Bridge. > - **Types/Mocks**: > - Make `RelayQuote.steps[].items[].data.gas` optional; extend messenger to handle `TransactionController:addTransactionBatch`. > - **Changelog**: > - Note support for Relay quotes with multiple transactions. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7c30789. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Explanation
References
Changelog
Checklist