-
-
Notifications
You must be signed in to change notification settings - Fork 270
feat: added 'getAccessToken' with refresh token if expired #7800
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
base: main
Are you sure you want to change the base?
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. |
|
@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. |
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
packages/seedless-onboarding-controller/src/SeedlessOnboardingController.ts
Show resolved
Hide resolved
|
@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. |
Explanation
This PR adds a new public method getAccessToken() with automatic token refresh capability to prevent clients from using expired access tokens when retrieving them from state.
Issue:
Previously, clients could directly access state.accessToken from the controller state, which could potentially return an expired token. This could lead to failed API calls and poor user experience when the token had expired but wasn't refreshed.
Solution:
Added a new public method
getAccessToken()that automatically refreshes expired tokens: Uses the #executeWithTokenRefresh wrapper to check token expiration and refresh if needed before returningReferences
Checklist
Note
Medium Risk
Adds a new public token-access path that can trigger refresh/auth flows; mistakes could surface as unexpected authentication errors or stale token usage for consumers.
Overview
Introduces a new public
getAccessToken()method (and messenger actionSeedlessOnboardingController:getAccessToken) so clients can fetch the currentaccessTokenwithout reading controller state directly.getAccessToken()is wrapped in the controller lock and uses the existing refresh flow to proactively refresh expired node/metadata/access tokens before returning an access token; the token-expiry checks were refactored into a shared#checkTokensExpired()helper. Tests were added to cover success, missing token, unauthenticated user, refresh-on-expiry, and refresh failure cases, and exports/types were reorganized so messenger/actions/options are defined/exported fromSeedlessOnboardingController.Written by Cursor Bugbot for commit 4594ee9. This will update automatically on new commits. Configure here.