Skip to content

feat: add @metamask/profile-controller package - #10558

Open
hmalik88 wants to merge 39 commits into
mainfrom
hm/add-profile-controller
Open

hmalik88 wants to merge 39 commits into
mainfrom
hm/add-profile-controller

Conversation

@hmalik88

@hmalik88 hmalik88 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

  • Adds @metamask/profile-controller, a new package for managing MetaMask user profile state
  • ProfileService communicates with the MetaMask Profile API (profile.api.cx.metamask.io), exposing getProfile, createProfile, replaceProfile, updateProfile, deleteProfile, checkUsernameAvailability, getXAuthUrl, connectX, and getXAccount via the messenger, with superstruct validation on all inputs and responses
  • ProfileController manages profile state derived from the API and exposes all operations via the messenger; also exports useGetProfile and useCheckUsernameAvailability React hooks for UI components via @metamask/react-data-query

References

N/A

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 communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
New authenticated profile and OAuth surface area with persisted user state; consumers must wire ProfileService, auth, and messenger correctly before enabling in production clients.

Overview
Introduces @metamask/profile-controller, a new monorepo package for MetaMask user profiles (username, bio, avatar, linked addresses, trading privacy) and optional X (Twitter) linking via OAuth PKCE.

ProfileService is a BaseDataService client for the MetaMask Profile API: CRUD on profiles, username availability checks, and X auth/connect/account endpoints. Requests use AuthenticationController:getBearerToken and superstruct validation on inputs and responses; reads/writes go through the messenger query/mutation cache where applicable.

ProfileController holds persisted metamaskProfile / optional xProfile state, maps API snake_case to camelCase, and exposes create/replace/update/delete, username checks, and X flow helpers through messenger actions (delegating mutations to ProfileService).

Also ships useGetProfile and useCheckUsernameAvailability hooks wired to @metamask/react-data-query, plus tests, package scaffolding, and repo wiring (README dependency graph, CODEOWNERS / codeowners.ts / teams.json, root tsconfig references, oxlint suppression for jest config).

Reviewed by Cursor Bugbot for commit e8e3851. Bugbot is set up for automated code reviews on this repo. Configure here.

@hmalik88
hmalik88 marked this pull request as ready for review September 29, 2026 01:04
@hmalik88
hmalik88 deployed to default-branch September 29, 2026 01:05 — with GitHub Actions Active

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/profile-controller/src/ProfileController.ts Outdated
Comment thread packages/profile-controller/src/ProfileService.ts
@hmalik88
hmalik88 requested a review from a team as a code owner September 29, 2026 01:50

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b673db4. Configure here.

Comment thread packages/profile-controller/src/ProfileController.ts Outdated
Comment thread packages/profile-controller/src/ProfileController-method-action-types.ts Outdated
Comment thread packages/profile-controller/src/ProfileController-method-action-types.ts Outdated
Comment thread packages/profile-controller/src/ProfileController.ts Outdated
'ProfileService:createProfile',
params,
);
const mapped = this.#mapApiResponseToProfile(response);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lint error: Argument of type 'unknown' is not assignable to parameter of type '{ profile_id: string; username: string; display_name: string; bio: string | null; linked_addresses: string[]; avatar_url: string | null; trading_privacy: "private" | "public"; connected_to_x: boolean; created_at: string; updated_at: string; }'.

const mapped = this.#mapApiResponseToProfile(response);
this.update((state) => {
state.metamaskProfile = mapped;
if (response.x_profile) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lint error: 'response' is of type 'unknown'.

@gantunesr gantunesr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good overall, just need to resolve lint failures

This branch was successfully deployed

1 active (outdated) deployment
default-branch — 19ce0e86 Deployed Sep 29, 2026 by hmalik88 via Determine whether this PR is a release PR #4831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants