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

refactor: add login response validation #4541

Merged

Conversation

Prithpal-Sooriya
Copy link
Contributor

Explanation

Profile Syncing. Adds login response validation from the developer/users storage medium.
The user could lie and pass in an invalid login response, so this makes sure that there is some validation around the response shape.

NOTE - we can improve this in the future by adding a runtime parser/validator like Zod. But this is out of scope and we can add in a separate PR.

References

NOTIFY-881

Changelog

@metamask/profile-sync-controller

  • ADDED: Validation around the LoginResponse shape.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

* @param input - unknown/untyped input
* @returns boolean if input is LoginResponse
*/
export function validateLoginResponse(input: unknown): input is LoginResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@Prithpal-Sooriya Prithpal-Sooriya merged commit d9a386d into main Jul 19, 2024
116 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the fix/profile-syncing-add-login-response-validation branch July 19, 2024 11:54
@Prithpal-Sooriya Prithpal-Sooriya added the team-notifications Notification Team changes. https://github.com/orgs/MetaMask/teams/notifications label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-notifications Notification Team changes. https://github.com/orgs/MetaMask/teams/notifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants