Skip to main content

ProfileController Actions

14 actions registered.

NameDeprecated
checkUsernameAvailability
clearState
connectX
createProfile
deleteProfile
disconnectX
fetchAndUpdateProfile
fetchAndUpdateXAccount
getProfile
getState
getXAuthorizationUrl
getXProfile
replaceProfile
updateProfile

ProfileController:checkUsernameAvailability​

Package: @metamask/profile-controller

Checks whether a username is available.

Parameters:

NameDescription
usernameThe username to check.

Returns: Availability details including validity and normalized form.

Handler signature:

(username: string) => Promise<UsernameAvailabilityResponse>

ProfileController:clearState​

Package: @metamask/profile-controller

Clears the controller state, including the profile and X profile.

Handler signature:

() => void

ProfileController:connectX​

Package: @metamask/profile-controller

Completes the X OAuth flow for the profile in state and returns the linked X profile. Updates controller state with the linked X profile.

Parameters:

NameDescription
paramsThe parameters for the X OAuth flow.
params.codeThe OAuth authorization code from the X redirect.
params.stateThe state parameter returned by the X redirect.

Returns: The linked X profile.

Handler signature:

(params: {
code: string;
state: string;
}) => Promise<XProfile>

ProfileController:createProfile​

Package: @metamask/profile-controller

Creates a new MetaMask profile, updates state, and returns the created profile.

Parameters:

NameDescription
paramsThe profile creation parameters.

Returns: The created MetaMask profile.

Handler signature:

(params: CreateProfileParams) => Promise<Profile>

ProfileController:deleteProfile​

Package: @metamask/profile-controller

Deletes the current profile and resets state, including clearing any linked X profile.

Handler signature:

() => Promise<void>

ProfileController:disconnectX​

Package: @metamask/profile-controller

Disconnects the X account linked to the given profile. If the given profile matches the profile in state, clears xProfile from state and marks the profile in state as no longer connected to X.

Parameters:

NameDescription
profileIdThe ID of the profile to disconnect the linked X account from (sourced from getProfile).

Handler signature:

(profileId: string) => Promise<void>

ProfileController:fetchAndUpdateProfile​

Package: @metamask/profile-controller

Fetches a profile by its identifier and updates state.

Parameters:

NameDescription
profileIdThe profile identifier to fetch.

Returns: The fetched profile.

Handler signature:

(profileId: string) => Promise<Profile>

ProfileController:fetchAndUpdateXAccount​

Package: @metamask/profile-controller

Fetches the X account linked to the authenticated profile, updates state, and returns the X profile. The profile is resolved server-side from the verified bearer token.

Returns: The linked X profile.

Handler signature:

() => Promise<XProfile>

ProfileController:getProfile​

Package: @metamask/profile-controller

Returns the current MetaMask profile from state, or undefined if none has been created.

Returns: The MetaMask profile, or undefined.

Handler signature:

() => Profile | undefined

ProfileController:getState​

Package: @metamask/profile-controller

The ProfileController:getState action type.

Handler signature:

() => ProfileControllerState

ProfileController:getXAuthorizationUrl​

Package: @metamask/profile-controller

Initiates the X OAuth flow by fetching the authorization URL from the backend. The profile is resolved server-side from the verified bearer token. Returns session data for the caller to use; nothing is stored in controller state.

Returns: The X authorization URL and state parameter.

Handler signature:

() => Promise<ConnectXSession>

ProfileController:getXProfile​

Package: @metamask/profile-controller

Returns the currently linked X profile from state, or undefined if none has been connected.

Returns: The X profile, or undefined.

Handler signature:

() => XProfile | undefined

ProfileController:replaceProfile​

Package: @metamask/profile-controller

Fully replaces the current profile and updates state.

Parameters:

NameDescription
inputThe replacement profile data.

Handler signature:

(input: ReplaceProfileParams) => Promise<void>

ProfileController:updateProfile​

Package: @metamask/profile-controller

Partially updates the current profile and updates state.

Parameters:

NameDescription
inputThe fields to update.

Handler signature:

(input: UpdateProfileParams) => Promise<void>