Skip to content
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

feat: auth & profile sync logic improvements #30174

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

mathieuartu
Copy link
Contributor

@mathieuartu mathieuartu commented Feb 6, 2025

Description

This PR improves the overall logic behind auth & profile syncing.

Changelog:

  • Bump @metamask/profile-sync-controller to v6.0.0 and @metamask/notification-services-controller to v0.19.0
  • Add new useSignOut hook to programmatically sign users out
  • Refactor the useAutoSignIn hook so it encapsulates all automatic sign in logic.
  • Remove all sign-out calls except for when basic functionality is turned off. Signing out should and will only happen when basic functionality is turned off.
  • Create new useAutoSignOut hook to manage automatic sign outs.
  • Remove UserStorageController MetaMetrics dependency
  • Remove notification related actions from UserStorageController allowedActions
  • Remove the capability for NotificationServicesController to enable profile syncing
  • Remove the profile syncing dependency for notifications. They only rely on Auth & user storage. Profile syncing is an umbrella term that encompasses only Account syncing for now.

Open in GitHub Codespaces

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/IDENTITY-18

Manual testing steps

  1. Do a fresh onboarding and verify that by default you are signed in when finishing (/login call in the network tab)
  2. Do a fresh onboarding, disable basic functionality in the onboarding settings and verify that:
    1. Profile syncing toggle is turned off
    2. Complete onboarding and verify that you're not signed in (no /login call in the network tab)
  3. Finish onboarding
  4. Go to the settings page
    1. Disable profile syncing
    2. Enable notifications
    3. Verify that notifications work
    4. Verify that the profile syncing setting was not automatically turned on
  5. Go to the settings page
    1. Turn basic functionality off
    2. Turn basic functionality on
    3. Turn any auth dependent feature on (MetaMetrics, Profile Syncing, Notifications...)
    4. Verify that you see a /login call in the network tab

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

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.

Copy link

socket-security bot commented Feb 6, 2025

Copy link

socket-security bot commented Feb 6, 2025

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Network access npm/@metamask/[email protected] 🚫

View full report↗︎

Next steps

What is network access?

This module accesses the network.

Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@mathieuartu
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

Builds ready [592b8ec]
Page Load Metrics (1926 ± 64 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint53621091865333160
domContentLoaded16052100189713464
load16232106192613364
domInteractive28105452211
backgroundConnect1078362311
firstReactRender1892452512
getState76113115
initialActions01000
loadScripts11401547139210651
setupStore1064282211
uiStartup18772414219214067
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -858 Bytes (-0.01%)
  • ui: 1.79 KiB (0.02%)
  • common: -6.85 KiB (-0.07%)

@mathieuartu mathieuartu marked this pull request as ready for review February 7, 2025 12:28
@mathieuartu mathieuartu requested review from a team as code owners February 7, 2025 12:29
@mathieuartu mathieuartu marked this pull request as draft February 7, 2025 17:27
@metamaskbot
Copy link
Collaborator

Builds ready [8de24e0]
Page Load Metrics (1619 ± 73 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint44421161566302145
domContentLoaded14292059159714971
load14372066161915273
domInteractive167241199
backgroundConnect770292210
firstReactRender15103383014
getState45511147
initialActions01000
loadScripts9981565114113464
setupStore688192211
uiStartup162826861871243117
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -817 Bytes (-0.01%)
  • ui: 1.67 KiB (0.02%)
  • common: -6.85 KiB (-0.07%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants