@metamask-previews/profile-controller 1.2.0-preview-35f016caa → 1.2.1-preview-a26804c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,10 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.1]
11
+
12
+ ### Added
13
+
14
+ - Add `clearState` method ([#11177](https://github.com/MetaMask/core/pull/11177))
15
+
10
16
  ### Changed
11
17
 
12
18
  - Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
13
19
 
20
+ ### Fixed
21
+
22
+ - Fix `ProfileService.disconnectX` to call `DELETE profiles/x/account` instead of the non-existent `DELETE profiles/{profileId}/x` endpoint, since the linked X account is resolved server-side from the verified bearer token ([#11195](https://github.com/MetaMask/core/pull/11195))
23
+
14
24
  ## [1.2.0]
15
25
 
16
26
  ### Added
@@ -62,7 +72,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
62
72
  - Add `ProfileController` for managing user profile state, exposing `getMetaMaskProfile`, `getXprofile`, `createProfile`, `replaceProfile`, `updateProfile`, `deleteProfile`, `checkUsernameAvailability`, `getXAuthUrl`, `connectX`, and `getXAccount` via the messenger ([#10558](https://github.com/MetaMask/core/pull/10558))
63
73
  - Add `ProfileService` for communicating with the MetaMask Profile API, exposing `getProfile`, `createProfile`, `replaceProfile`, `updateProfile`, `deleteProfile`, `checkUsernameAvailability`, `getXAuthUrl`, `connectX`, and `getXAccount` via the messenger, with superstruct validation on all inputs and responses ([#10558](https://github.com/MetaMask/core/pull/10558))
64
74
 
65
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-controller@1.2.0...HEAD
75
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-controller@1.2.1...HEAD
76
+ [1.2.1]: https://github.com/MetaMask/core/compare/@metamask/profile-controller@1.2.0...@metamask/profile-controller@1.2.1
66
77
  [1.2.0]: https://github.com/MetaMask/core/compare/@metamask/profile-controller@1.1.1...@metamask/profile-controller@1.2.0
67
78
  [1.1.1]: https://github.com/MetaMask/core/compare/@metamask/profile-controller@1.1.0...@metamask/profile-controller@1.1.1
68
79
  [1.1.0]: https://github.com/MetaMask/core/compare/@metamask/profile-controller@1.0.1...@metamask/profile-controller@1.1.0
@@ -127,8 +127,15 @@ export type ProfileControllerDisconnectXAction = {
127
127
  type: `ProfileController:disconnectX`;
128
128
  handler: ProfileController['disconnectX'];
129
129
  };
130
+ /**
131
+ * Clears the controller state, including the profile and X profile.
132
+ */
133
+ export type ProfileControllerClearStateAction = {
134
+ type: `ProfileController:clearState`;
135
+ handler: ProfileController['clearState'];
136
+ };
130
137
  /**
131
138
  * Union of all ProfileController action types.
132
139
  */
133
- export type ProfileControllerMethodActions = ProfileControllerGetProfileAction | ProfileControllerGetXProfileAction | ProfileControllerCreateProfileAction | ProfileControllerReplaceProfileAction | ProfileControllerUpdateProfileAction | ProfileControllerDeleteProfileAction | ProfileControllerCheckUsernameAvailabilityAction | ProfileControllerConnectXAction | ProfileControllerFetchAndUpdateXAccountAction | ProfileControllerFetchAndUpdateProfileAction | ProfileControllerGetXAuthorizationUrlAction | ProfileControllerDisconnectXAction;
140
+ export type ProfileControllerMethodActions = ProfileControllerGetProfileAction | ProfileControllerGetXProfileAction | ProfileControllerCreateProfileAction | ProfileControllerReplaceProfileAction | ProfileControllerUpdateProfileAction | ProfileControllerDeleteProfileAction | ProfileControllerCheckUsernameAvailabilityAction | ProfileControllerConnectXAction | ProfileControllerFetchAndUpdateXAccountAction | ProfileControllerFetchAndUpdateProfileAction | ProfileControllerGetXAuthorizationUrlAction | ProfileControllerDisconnectXAction | ProfileControllerClearStateAction;
134
141
  //# sourceMappingURL=ProfileController-method-action-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileController-method-action-types.d.ts","sourceRo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EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,iCAAiC,GACjC,kCAAkC,GAClC,oCAAoC,GACpC,qCAAqC,GACrC,oCAAoC,GACpC,oCAAoC,GACpC,gDAAgD,GAChD,+BAA+B,GAC/B,6CAA6C,GAC7C,4CAA4C,GAC5C,2CAA2C,GAC3C,kCAAkC,CAAC"}
1
+ {"version":3,"file":"ProfileController-method-action-types.d.ts","sourceRoot":"","sources":["../src/ProfileController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI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C,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,iCAAiC,GACjC,kCAAkC,GAClC,oCAAoC,GACpC,qCAAqC,GACrC,oCAAoC,GACpC,oCAAoC,GACpC,gDAAgD,GAChD,+BAA+B,GAC/B,6CAA6C,GAC7C,4CAA4C,GAC5C,2CAA2C,GAC3C,kCAAkC,GAClC,iCAAiC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileController-method-action-types.js","sourceRoot":"","sources":["../src/ProfileController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ProfileController } from './ProfileController.js';\n\n/**\n * Returns the current MetaMask profile from state, or undefined if none has been created.\n *\n * @returns The MetaMask profile, or undefined.\n */\nexport type ProfileControllerGetProfileAction = {\n type: `ProfileController:getProfile`;\n handler: ProfileController['getProfile'];\n};\n\n/**\n * Returns the currently linked X profile from state, or undefined if none has been connected.\n *\n * @returns The X profile, or undefined.\n */\nexport type ProfileControllerGetXProfileAction = {\n type: `ProfileController:getXProfile`;\n handler: ProfileController['getXProfile'];\n};\n\n/**\n * Creates a new MetaMask profile, updates state, and returns the created profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created MetaMask profile.\n */\nexport type ProfileControllerCreateProfileAction = {\n type: `ProfileController:createProfile`;\n handler: ProfileController['createProfile'];\n};\n\n/**\n * Fully replaces the current profile and updates state.\n *\n * @param input - The replacement profile data.\n * @throws If no profile has been created yet.\n */\nexport type ProfileControllerReplaceProfileAction = {\n type: `ProfileController:replaceProfile`;\n handler: ProfileController['replaceProfile'];\n};\n\n/**\n * Partially updates the current profile and updates state.\n *\n * @param input - The fields to update.\n * @throws If no profile has been created yet.\n */\nexport type ProfileControllerUpdateProfileAction = {\n type: `ProfileController:updateProfile`;\n handler: ProfileController['updateProfile'];\n};\n\n/**\n * Deletes the current profile and resets state, including clearing any linked X profile.\n *\n * @throws If no profile has been created yet.\n */\nexport type ProfileControllerDeleteProfileAction = {\n type: `ProfileController:deleteProfile`;\n handler: ProfileController['deleteProfile'];\n};\n\n/**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n */\nexport type ProfileControllerCheckUsernameAvailabilityAction = {\n type: `ProfileController:checkUsernameAvailability`;\n handler: ProfileController['checkUsernameAvailability'];\n};\n\n/**\n * Completes the X OAuth flow for the profile in state and returns the\n * linked X profile. Updates controller state with the linked X profile.\n *\n * @param params - The parameters for the X OAuth flow.\n * @param params.code - The OAuth authorization code from the X redirect.\n * @param params.state - The state parameter returned by the X redirect.\n * @returns The linked X profile.\n */\nexport type ProfileControllerConnectXAction = {\n type: `ProfileController:connectX`;\n handler: ProfileController['connectX'];\n};\n\n/**\n * Fetches the X account linked to the authenticated profile, updates state,\n * and returns the X profile. The profile is resolved server-side from the\n * verified bearer token.\n *\n * @returns The linked X profile.\n */\nexport type ProfileControllerFetchAndUpdateXAccountAction = {\n type: `ProfileController:fetchAndUpdateXAccount`;\n handler: ProfileController['fetchAndUpdateXAccount'];\n};\n\n/**\n * Fetches a profile by its identifier and updates state.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The fetched profile.\n */\nexport type ProfileControllerFetchAndUpdateProfileAction = {\n type: `ProfileController:fetchAndUpdateProfile`;\n handler: ProfileController['fetchAndUpdateProfile'];\n};\n\n/**\n * Initiates the X OAuth flow by fetching the authorization URL from the backend.\n * The profile is resolved server-side from the verified bearer token.\n * Returns session data for the caller to use; nothing is stored in controller state.\n *\n * @returns The X authorization URL and state parameter.\n */\nexport type ProfileControllerGetXAuthorizationUrlAction = {\n type: `ProfileController:getXAuthorizationUrl`;\n handler: ProfileController['getXAuthorizationUrl'];\n};\n\n/**\n * Disconnects the X account linked to the given profile. If the given\n * profile matches the profile in state, clears `xProfile` from state and\n * marks the profile in state as no longer connected to X.\n *\n * @param profileId - The ID of the profile to disconnect the linked X account\n * from (sourced from {@link getProfile}).\n */\nexport type ProfileControllerDisconnectXAction = {\n type: `ProfileController:disconnectX`;\n handler: ProfileController['disconnectX'];\n};\n\n/**\n * Union of all ProfileController action types.\n */\nexport type ProfileControllerMethodActions =\n | ProfileControllerGetProfileAction\n | ProfileControllerGetXProfileAction\n | ProfileControllerCreateProfileAction\n | ProfileControllerReplaceProfileAction\n | ProfileControllerUpdateProfileAction\n | ProfileControllerDeleteProfileAction\n | ProfileControllerCheckUsernameAvailabilityAction\n | ProfileControllerConnectXAction\n | ProfileControllerFetchAndUpdateXAccountAction\n | ProfileControllerFetchAndUpdateProfileAction\n | ProfileControllerGetXAuthorizationUrlAction\n | ProfileControllerDisconnectXAction;\n"]}
1
+ {"version":3,"file":"ProfileController-method-action-types.js","sourceRoot":"","sources":["../src/ProfileController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ProfileController } from './ProfileController.js';\n\n/**\n * Returns the current MetaMask profile from state, or undefined if none has been created.\n *\n * @returns The MetaMask profile, or undefined.\n */\nexport type ProfileControllerGetProfileAction = {\n type: `ProfileController:getProfile`;\n handler: ProfileController['getProfile'];\n};\n\n/**\n * Returns the currently linked X profile from state, or undefined if none has been connected.\n *\n * @returns The X profile, or undefined.\n */\nexport type ProfileControllerGetXProfileAction = {\n type: `ProfileController:getXProfile`;\n handler: ProfileController['getXProfile'];\n};\n\n/**\n * Creates a new MetaMask profile, updates state, and returns the created profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created MetaMask profile.\n */\nexport type ProfileControllerCreateProfileAction = {\n type: `ProfileController:createProfile`;\n handler: ProfileController['createProfile'];\n};\n\n/**\n * Fully replaces the current profile and updates state.\n *\n * @param input - The replacement profile data.\n * @throws If no profile has been created yet.\n */\nexport type ProfileControllerReplaceProfileAction = {\n type: `ProfileController:replaceProfile`;\n handler: ProfileController['replaceProfile'];\n};\n\n/**\n * Partially updates the current profile and updates state.\n *\n * @param input - The fields to update.\n * @throws If no profile has been created yet.\n */\nexport type ProfileControllerUpdateProfileAction = {\n type: `ProfileController:updateProfile`;\n handler: ProfileController['updateProfile'];\n};\n\n/**\n * Deletes the current profile and resets state, including clearing any linked X profile.\n *\n * @throws If no profile has been created yet.\n */\nexport type ProfileControllerDeleteProfileAction = {\n type: `ProfileController:deleteProfile`;\n handler: ProfileController['deleteProfile'];\n};\n\n/**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n */\nexport type ProfileControllerCheckUsernameAvailabilityAction = {\n type: `ProfileController:checkUsernameAvailability`;\n handler: ProfileController['checkUsernameAvailability'];\n};\n\n/**\n * Completes the X OAuth flow for the profile in state and returns the\n * linked X profile. Updates controller state with the linked X profile.\n *\n * @param params - The parameters for the X OAuth flow.\n * @param params.code - The OAuth authorization code from the X redirect.\n * @param params.state - The state parameter returned by the X redirect.\n * @returns The linked X profile.\n */\nexport type ProfileControllerConnectXAction = {\n type: `ProfileController:connectX`;\n handler: ProfileController['connectX'];\n};\n\n/**\n * Fetches the X account linked to the authenticated profile, updates state,\n * and returns the X profile. The profile is resolved server-side from the\n * verified bearer token.\n *\n * @returns The linked X profile.\n */\nexport type ProfileControllerFetchAndUpdateXAccountAction = {\n type: `ProfileController:fetchAndUpdateXAccount`;\n handler: ProfileController['fetchAndUpdateXAccount'];\n};\n\n/**\n * Fetches a profile by its identifier and updates state.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The fetched profile.\n */\nexport type ProfileControllerFetchAndUpdateProfileAction = {\n type: `ProfileController:fetchAndUpdateProfile`;\n handler: ProfileController['fetchAndUpdateProfile'];\n};\n\n/**\n * Initiates the X OAuth flow by fetching the authorization URL from the backend.\n * The profile is resolved server-side from the verified bearer token.\n * Returns session data for the caller to use; nothing is stored in controller state.\n *\n * @returns The X authorization URL and state parameter.\n */\nexport type ProfileControllerGetXAuthorizationUrlAction = {\n type: `ProfileController:getXAuthorizationUrl`;\n handler: ProfileController['getXAuthorizationUrl'];\n};\n\n/**\n * Disconnects the X account linked to the given profile. If the given\n * profile matches the profile in state, clears `xProfile` from state and\n * marks the profile in state as no longer connected to X.\n *\n * @param profileId - The ID of the profile to disconnect the linked X account\n * from (sourced from {@link getProfile}).\n */\nexport type ProfileControllerDisconnectXAction = {\n type: `ProfileController:disconnectX`;\n handler: ProfileController['disconnectX'];\n};\n\n/**\n * Clears the controller state, including the profile and X profile.\n */\nexport type ProfileControllerClearStateAction = {\n type: `ProfileController:clearState`;\n handler: ProfileController['clearState'];\n};\n\n/**\n * Union of all ProfileController action types.\n */\nexport type ProfileControllerMethodActions =\n | ProfileControllerGetProfileAction\n | ProfileControllerGetXProfileAction\n | ProfileControllerCreateProfileAction\n | ProfileControllerReplaceProfileAction\n | ProfileControllerUpdateProfileAction\n | ProfileControllerDeleteProfileAction\n | ProfileControllerCheckUsernameAvailabilityAction\n | ProfileControllerConnectXAction\n | ProfileControllerFetchAndUpdateXAccountAction\n | ProfileControllerFetchAndUpdateProfileAction\n | ProfileControllerGetXAuthorizationUrlAction\n | ProfileControllerDisconnectXAction\n | ProfileControllerClearStateAction;\n"]}
@@ -181,6 +181,10 @@ export declare class ProfileController extends BaseController<typeof controllerN
181
181
  * from (sourced from {@link getProfile}).
182
182
  */
183
183
  disconnectX(profileId: string): Promise<void>;
184
+ /**
185
+ * Clears the controller state, including the profile and X profile.
186
+ */
187
+ clearState(): void;
184
188
  }
185
189
  export {};
186
190
  //# sourceMappingURL=ProfileController.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileController.d.ts","sourceRoot":"","sources":["../src/ProfileController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAE5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,KAAK,EACV,6CAA6C,EAC7C,4BAA4B,EAC5B,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,iCAAiC,EAClC,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EACV,mBAAmB,EAGnB,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,EAE7B,MAAM,qBAAqB,CAAC;AAE7B,QAAA,MAAM,cAAc,sBAAsB,CAAC;AAI3C,8DAA8D;AAC9D,MAAM,MAAM,OAAO,GAAG;IACpB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,eAAe,EAAE,aAAa,EAAE,CAAC;IACjC,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,cAAc,EAAE,QAAQ,GAAG,SAAS,C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AAI,OAAO,CAAC,IAAI,CAAC,CAOnC;IAED;;;;;OAKG;IACG,yBAAyB,CAC7B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,4BAA4B,CAAC,CAKvC;IAED;;;;;;;;OAQG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAUzE;IAED;;;;;;OAMG;IACG,sBAAsB,IAAI,OAAO,CAAC,QAAQ,CAAC,CAOhD;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU/D;IAED;;;;;;OAMG;IACG,oBAAoB,IAAI,OAAO,CAAC,eAAe,CAAC,CAGrD;IAED;;;;;;;OAOG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQlD;IAED;;OAEG;IACH,UAAU,IAAI,IAAI,CAEjB;CACF"}
@@ -49,6 +49,7 @@ const MESSENGER_EXPOSED_METHODS = [
49
49
  'fetchAndUpdateProfile',
50
50
  'getXAuthorizationUrl',
51
51
  'disconnectX',
52
+ 'clearState',
52
53
  ];
53
54
  // === CONTROLLER ===
54
55
  /** Manages MetaMask profile state and delegates API operations to ProfileService. */
@@ -288,5 +289,11 @@ export class ProfileController extends BaseController {
288
289
  }
289
290
  });
290
291
  }
292
+ /**
293
+ * Clears the controller state, including the profile and X profile.
294
+ */
295
+ clearState() {
296
+ this.update(() => getDefaultProfileControllerState());
297
+ }
291
298
  }
292
299
  //# sourceMappingURL=ProfileController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileController.js","sourceRoot":"","sources":["../src/ProfileController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAgC3D,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAuG3C,gBAAgB;AAE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ask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { CaipAccountId } from '@metamask/utils';\n\nimport type { ProfileControllerMethodActions } from './ProfileController-method-action-types.js';\nimport type {\n ProfileServiceCheckUsernameAvailabilityAction,\n ProfileServiceConnectXAction,\n ProfileServiceCreateProfileAction,\n ProfileServiceDeleteProfileAction,\n ProfileServiceDisconnectXAction,\n ProfileServiceGetProfileAction,\n ProfileServiceGetXAccountAction,\n ProfileServiceGetXAuthUrlAction,\n ProfileServiceReplaceProfileAction,\n ProfileServiceUpdateProfileAction,\n} from './ProfileService-method-action-types.js';\nimport type {\n CreateProfileParams,\n CreateProfileResponse,\n ProfileApiResponse,\n ReplaceProfileParams,\n UpdateProfileParams,\n UsernameAvailabilityResponse,\n ConnectXResponse,\n} from './ProfileService.js';\n\nconst controllerName = 'ProfileController';\n\n// === TYPES ===\n\n/** Representation of a profile stored in controller state. */\nexport type Profile = {\n /** The canonical profile ID connected to the profile. */\n profileId: string;\n /** The username for the profile. */\n username: string;\n /** The display name for the profile. */\n displayName: string;\n /** The bio for the profile. */\n bio: string;\n /** The linked addresses for the profile. */\n linkedAddresses: CaipAccountId[];\n /** The avatar URL for the profile. */\n avatarUrl: string;\n /** Whether the profile's trading activity is visible to the public. */\n tradingPrivacy: 'public' | 'private';\n /** Whether the profile is connected to X. */\n connectedToX: boolean;\n /** The date and time the profile was created. */\n createdAt: string;\n /** The date and time the profile was updated. */\n updatedAt: string;\n};\n\n/** Representation of a linked X (Twitter) profile stored in controller state. */\nexport type XProfile = {\n /** The unique identifier for the X profile. This is the user ID of the X profile. */\n xUserId: string;\n /** The URL for the X profile. */\n xProfileUrl: string;\n /** The username for the X profile. */\n username: string;\n /** The display name for the X profile. */\n displayName: string;\n /** The avatar URL for the X profile. */\n avatarUrl: string;\n /** The date and time the X profile was created. */\n createdAt: string;\n /** The date and time the X profile was updated. */\n updatedAt: string;\n};\n\n/** Ephemeral session data for initiating the X OAuth flow. Not stored in controller state. */\nexport type ConnectXSession = {\n /** The X authorization URL to open in a system browser. */\n authorizationUrl: string;\n /** The OAuth state parameter to compare against the X redirect callback. */\n state: string;\n};\n\n/** State managed by ProfileController. */\nexport type ProfileControllerState = {\n profile: Profile;\n xProfile?: XProfile;\n};\n\n// === MESSENGER ===\n\n/** The `ProfileController:getState` action type. */\nexport type ProfileControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ProfileControllerState\n>;\n\n/** Union of all actions exposed by ProfileController. */\nexport type ProfileControllerActions =\n | ProfileControllerGetStateAction\n | ProfileControllerMethodActions;\n\n/** The `ProfileController:stateChanged` event type. */\nexport type ProfileControllerChangeEvent = ControllerStateChangedEvent<\n typeof controllerName,\n ProfileControllerState\n>;\n\n/** Union of all events emitted by ProfileController. */\nexport type ProfileControllerEvents = ProfileControllerChangeEvent;\n\ntype AllowedActions =\n | ProfileServiceCreateProfileAction\n | ProfileServiceReplaceProfileAction\n | ProfileServiceUpdateProfileAction\n | ProfileServiceDeleteProfileAction\n | ProfileServiceCheckUsernameAvailabilityAction\n | ProfileServiceConnectXAction\n | ProfileServiceGetXAccountAction\n | ProfileServiceGetXAuthUrlAction\n | ProfileServiceDisconnectXAction\n | ProfileServiceGetProfileAction;\n\nexport type AllowedEvents = never;\n\n/** Messenger type for ProfileController, scoped to its actions, events, and allowed service calls. */\nexport type ProfileControllerMessenger = Messenger<\n typeof controllerName,\n ProfileControllerActions | AllowedActions,\n ProfileControllerEvents | AllowedEvents\n>;\n\n// === STATE ===\n\nconst profileControllerMetadata = {\n profile: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n xProfile: {\n includeInStateLogs: false,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n} satisfies StateMetadata<ProfileControllerState>;\n\n/**\n * Returns the default initial state for ProfileController.\n *\n * @returns A ProfileControllerState with empty profile fields and no X profile.\n */\nexport function getDefaultProfileControllerState(): ProfileControllerState {\n return {\n profile: {\n profileId: '',\n username: '',\n displayName: '',\n bio: '',\n linkedAddresses: [],\n avatarUrl: '',\n tradingPrivacy: 'public',\n connectedToX: false,\n createdAt: '',\n updatedAt: '',\n },\n };\n}\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getProfile',\n 'getXProfile',\n 'createProfile',\n 'replaceProfile',\n 'updateProfile',\n 'deleteProfile',\n 'checkUsernameAvailability',\n 'connectX',\n 'fetchAndUpdateXAccount',\n 'fetchAndUpdateProfile',\n 'getXAuthorizationUrl',\n 'disconnectX',\n] as const;\n\n// === CONTROLLER ===\n\n/** Manages MetaMask profile state and delegates API operations to ProfileService. */\nexport class ProfileController extends BaseController<\n typeof controllerName,\n ProfileControllerState,\n ProfileControllerMessenger\n> {\n /**\n * Creates a new ProfileController instance.\n *\n * @param options - Constructor options.\n * @param options.messenger - The messenger scoped to ProfileController.\n * @param options.state - Optional partial initial state to merge with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: ProfileControllerMessenger;\n state?: Partial<ProfileControllerState>;\n }) {\n super({\n messenger,\n name: controllerName,\n metadata: profileControllerMetadata,\n state: {\n ...getDefaultProfileControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Returns true if a profile has been created and exists in state.\n *\n * @returns True if a profile exists, false otherwise.\n */\n #hasProfile(): boolean {\n return this.state.profile.profileId !== '';\n }\n\n /**\n * Returns the profile ID from state, throwing if no profile exists yet.\n *\n * @returns The current profile ID.\n * @throws If no profile has been created.\n */\n #getProfileIdOrThrow(): string {\n const { profileId } = this.state.profile;\n if (!profileId) {\n throw new Error('ProfileController: no profile found in state');\n }\n return profileId;\n }\n\n /**\n * Maps an API response to a MetaMask profile.\n *\n * @param response - The API response to map.\n * @returns The mapped MetaMask profile.\n */\n #mapApiResponseToProfile(response: ProfileApiResponse): Profile {\n return {\n profileId: response.profile_id,\n username: response.username,\n displayName: response.display_name,\n bio: response.bio ?? '',\n linkedAddresses: response.linked_addresses,\n avatarUrl: response.avatar_url,\n tradingPrivacy: response.trading_privacy,\n connectedToX: response.connected_to_x,\n createdAt: response.created_at,\n updatedAt: response.updated_at,\n };\n }\n\n /**\n * Maps an API response to an X profile.\n *\n * @param response - The API response to map.\n * @returns The mapped X profile.\n */\n #mapXResponseToXProfile(response: ConnectXResponse): XProfile {\n return {\n xUserId: response.x_user_id,\n xProfileUrl: response.x_profile_url,\n username: response.username,\n displayName: response.display_name,\n avatarUrl: response.avatar_url,\n createdAt: response.created_at,\n updatedAt: response.updated_at,\n };\n }\n\n /**\n * Returns the current MetaMask profile from state, or undefined if none has been created.\n *\n * @returns The MetaMask profile, or undefined.\n */\n getProfile(): Profile | undefined {\n if (!this.#hasProfile()) {\n return undefined;\n }\n return this.state.profile;\n }\n\n /**\n * Returns the currently linked X profile from state, or undefined if none has been connected.\n *\n * @returns The X profile, or undefined.\n */\n getXProfile(): XProfile | undefined {\n return this.state.xProfile;\n }\n\n /**\n * Creates a new MetaMask profile, updates state, and returns the created profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created MetaMask profile.\n */\n async createProfile(params: CreateProfileParams): Promise<Profile> {\n const response: CreateProfileResponse = await this.messenger.call(\n 'ProfileService:createProfile',\n params,\n );\n const mapped = this.#mapApiResponseToProfile(response);\n this.update((state) => {\n state.profile = mapped;\n });\n return mapped;\n }\n\n /**\n * Fully replaces the current profile and updates state.\n *\n * @param input - The replacement profile data.\n * @throws If no profile has been created yet.\n */\n async replaceProfile(input: ReplaceProfileParams): Promise<void> {\n const profileId = this.#getProfileIdOrThrow();\n const response = await this.messenger.call(\n 'ProfileService:replaceProfile',\n profileId,\n input,\n );\n this.update((state) => {\n state.profile = this.#mapApiResponseToProfile(response);\n });\n }\n\n /**\n * Partially updates the current profile and updates state.\n *\n * @param input - The fields to update.\n * @throws If no profile has been created yet.\n */\n async updateProfile(input: UpdateProfileParams): Promise<void> {\n const profileId = this.#getProfileIdOrThrow();\n const response = await this.messenger.call(\n 'ProfileService:updateProfile',\n profileId,\n input,\n );\n this.update((state) => {\n state.profile = this.#mapApiResponseToProfile(response);\n });\n }\n\n /**\n * Deletes the current profile and resets state, including clearing any linked X profile.\n *\n * @throws If no profile has been created yet.\n */\n async deleteProfile(): Promise<void> {\n const profileId = this.#getProfileIdOrThrow();\n await this.messenger.call('ProfileService:deleteProfile', profileId);\n this.update((state) => {\n state.profile = getDefaultProfileControllerState().profile;\n state.xProfile = undefined;\n });\n }\n\n /**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n */\n async checkUsernameAvailability(\n username: string,\n ): Promise<UsernameAvailabilityResponse> {\n return await this.messenger.call(\n 'ProfileService:checkUsernameAvailability',\n username,\n );\n }\n\n /**\n * Completes the X OAuth flow for the profile in state and returns the\n * linked X profile. Updates controller state with the linked X profile.\n *\n * @param params - The parameters for the X OAuth flow.\n * @param params.code - The OAuth authorization code from the X redirect.\n * @param params.state - The state parameter returned by the X redirect.\n * @returns The linked X profile.\n */\n async connectX(params: { code: string; state: string }): Promise<XProfile> {\n const response = await this.messenger.call('ProfileService:connectX', {\n code: params.code,\n state: params.state,\n });\n const mapped = this.#mapXResponseToXProfile(response);\n this.update((state) => {\n state.xProfile = mapped;\n });\n return mapped;\n }\n\n /**\n * Fetches the X account linked to the authenticated profile, updates state,\n * and returns the X profile. The profile is resolved server-side from the\n * verified bearer token.\n *\n * @returns The linked X profile.\n */\n async fetchAndUpdateXAccount(): Promise<XProfile> {\n const response = await this.messenger.call('ProfileService:getXAccount');\n const mapped = this.#mapXResponseToXProfile(response);\n this.update((state) => {\n state.xProfile = mapped;\n });\n return mapped;\n }\n\n /**\n * Fetches a profile by its identifier and updates state.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The fetched profile.\n */\n async fetchAndUpdateProfile(profileId: string): Promise<Profile> {\n const response = await this.messenger.call(\n 'ProfileService:getProfile',\n profileId,\n );\n const mapped = this.#mapApiResponseToProfile(response);\n this.update((state) => {\n state.profile = mapped;\n });\n return mapped;\n }\n\n /**\n * Initiates the X OAuth flow by fetching the authorization URL from the backend.\n * The profile is resolved server-side from the verified bearer token.\n * Returns session data for the caller to use; nothing is stored in controller state.\n *\n * @returns The X authorization URL and state parameter.\n */\n async getXAuthorizationUrl(): Promise<ConnectXSession> {\n const response = await this.messenger.call('ProfileService:getXAuthUrl');\n return { authorizationUrl: response.url, state: response.state };\n }\n\n /**\n * Disconnects the X account linked to the given profile. If the given\n * profile matches the profile in state, clears `xProfile` from state and\n * marks the profile in state as no longer connected to X.\n *\n * @param profileId - The ID of the profile to disconnect the linked X account\n * from (sourced from {@link getProfile}).\n */\n async disconnectX(profileId: string): Promise<void> {\n await this.messenger.call('ProfileService:disconnectX', profileId);\n this.update((state) => {\n if (state.profile.profileId === profileId) {\n state.xProfile = undefined;\n state.profile.connectedToX = false;\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ProfileController.js","sourceRoot":"","sources":["../src/ProfileController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAgC3D,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAuG3C,gBAAgB;AAEhB,MAAM,yBAAyB,GAAG;IAChC,OAAO,EAAE;QACP,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;CAC8C,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO;QACL,OAAO,EAAE;YACP,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,EAAE;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AAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,oBAAoB;QACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACzE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC1C,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC;gBAC3B,KAAK,CAAC,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;YACrC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,gCAAgC,EAAE,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { CaipAccountId } from '@metamask/utils';\n\nimport type { ProfileControllerMethodActions } from './ProfileController-method-action-types.js';\nimport type {\n ProfileServiceCheckUsernameAvailabilityAction,\n ProfileServiceConnectXAction,\n ProfileServiceCreateProfileAction,\n ProfileServiceDeleteProfileAction,\n ProfileServiceDisconnectXAction,\n ProfileServiceGetProfileAction,\n ProfileServiceGetXAccountAction,\n ProfileServiceGetXAuthUrlAction,\n ProfileServiceReplaceProfileAction,\n ProfileServiceUpdateProfileAction,\n} from './ProfileService-method-action-types.js';\nimport type {\n CreateProfileParams,\n CreateProfileResponse,\n ProfileApiResponse,\n ReplaceProfileParams,\n UpdateProfileParams,\n UsernameAvailabilityResponse,\n ConnectXResponse,\n} from './ProfileService.js';\n\nconst controllerName = 'ProfileController';\n\n// === TYPES ===\n\n/** Representation of a profile stored in controller state. */\nexport type Profile = {\n /** The canonical profile ID connected to the profile. */\n profileId: string;\n /** The username for the profile. */\n username: string;\n /** The display name for the profile. */\n displayName: string;\n /** The bio for the profile. */\n bio: string;\n /** The linked addresses for the profile. */\n linkedAddresses: CaipAccountId[];\n /** The avatar URL for the profile. */\n avatarUrl: string;\n /** Whether the profile's trading activity is visible to the public. */\n tradingPrivacy: 'public' | 'private';\n /** Whether the profile is connected to X. */\n connectedToX: boolean;\n /** The date and time the profile was created. */\n createdAt: string;\n /** The date and time the profile was updated. */\n updatedAt: string;\n};\n\n/** Representation of a linked X (Twitter) profile stored in controller state. */\nexport type XProfile = {\n /** The unique identifier for the X profile. This is the user ID of the X profile. */\n xUserId: string;\n /** The URL for the X profile. */\n xProfileUrl: string;\n /** The username for the X profile. */\n username: string;\n /** The display name for the X profile. */\n displayName: string;\n /** The avatar URL for the X profile. */\n avatarUrl: string;\n /** The date and time the X profile was created. */\n createdAt: string;\n /** The date and time the X profile was updated. */\n updatedAt: string;\n};\n\n/** Ephemeral session data for initiating the X OAuth flow. Not stored in controller state. */\nexport type ConnectXSession = {\n /** The X authorization URL to open in a system browser. */\n authorizationUrl: string;\n /** The OAuth state parameter to compare against the X redirect callback. */\n state: string;\n};\n\n/** State managed by ProfileController. */\nexport type ProfileControllerState = {\n profile: Profile;\n xProfile?: XProfile;\n};\n\n// === MESSENGER ===\n\n/** The `ProfileController:getState` action type. */\nexport type ProfileControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ProfileControllerState\n>;\n\n/** Union of all actions exposed by ProfileController. */\nexport type ProfileControllerActions =\n | ProfileControllerGetStateAction\n | ProfileControllerMethodActions;\n\n/** The `ProfileController:stateChanged` event type. */\nexport type ProfileControllerChangeEvent = ControllerStateChangedEvent<\n typeof controllerName,\n ProfileControllerState\n>;\n\n/** Union of all events emitted by ProfileController. */\nexport type ProfileControllerEvents = ProfileControllerChangeEvent;\n\ntype AllowedActions =\n | ProfileServiceCreateProfileAction\n | ProfileServiceReplaceProfileAction\n | ProfileServiceUpdateProfileAction\n | ProfileServiceDeleteProfileAction\n | ProfileServiceCheckUsernameAvailabilityAction\n | ProfileServiceConnectXAction\n | ProfileServiceGetXAccountAction\n | ProfileServiceGetXAuthUrlAction\n | ProfileServiceDisconnectXAction\n | ProfileServiceGetProfileAction;\n\nexport type AllowedEvents = never;\n\n/** Messenger type for ProfileController, scoped to its actions, events, and allowed service calls. */\nexport type ProfileControllerMessenger = Messenger<\n typeof controllerName,\n ProfileControllerActions | AllowedActions,\n ProfileControllerEvents | AllowedEvents\n>;\n\n// === STATE ===\n\nconst profileControllerMetadata = {\n profile: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n xProfile: {\n includeInStateLogs: false,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n} satisfies StateMetadata<ProfileControllerState>;\n\n/**\n * Returns the default initial state for ProfileController.\n *\n * @returns A ProfileControllerState with empty profile fields and no X profile.\n */\nexport function getDefaultProfileControllerState(): ProfileControllerState {\n return {\n profile: {\n profileId: '',\n username: '',\n displayName: '',\n bio: '',\n linkedAddresses: [],\n avatarUrl: '',\n tradingPrivacy: 'public',\n connectedToX: false,\n createdAt: '',\n updatedAt: '',\n },\n };\n}\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getProfile',\n 'getXProfile',\n 'createProfile',\n 'replaceProfile',\n 'updateProfile',\n 'deleteProfile',\n 'checkUsernameAvailability',\n 'connectX',\n 'fetchAndUpdateXAccount',\n 'fetchAndUpdateProfile',\n 'getXAuthorizationUrl',\n 'disconnectX',\n 'clearState',\n] as const;\n\n// === CONTROLLER ===\n\n/** Manages MetaMask profile state and delegates API operations to ProfileService. */\nexport class ProfileController extends BaseController<\n typeof controllerName,\n ProfileControllerState,\n ProfileControllerMessenger\n> {\n /**\n * Creates a new ProfileController instance.\n *\n * @param options - Constructor options.\n * @param options.messenger - The messenger scoped to ProfileController.\n * @param options.state - Optional partial initial state to merge with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: ProfileControllerMessenger;\n state?: Partial<ProfileControllerState>;\n }) {\n super({\n messenger,\n name: controllerName,\n metadata: profileControllerMetadata,\n state: {\n ...getDefaultProfileControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Returns true if a profile has been created and exists in state.\n *\n * @returns True if a profile exists, false otherwise.\n */\n #hasProfile(): boolean {\n return this.state.profile.profileId !== '';\n }\n\n /**\n * Returns the profile ID from state, throwing if no profile exists yet.\n *\n * @returns The current profile ID.\n * @throws If no profile has been created.\n */\n #getProfileIdOrThrow(): string {\n const { profileId } = this.state.profile;\n if (!profileId) {\n throw new Error('ProfileController: no profile found in state');\n }\n return profileId;\n }\n\n /**\n * Maps an API response to a MetaMask profile.\n *\n * @param response - The API response to map.\n * @returns The mapped MetaMask profile.\n */\n #mapApiResponseToProfile(response: ProfileApiResponse): Profile {\n return {\n profileId: response.profile_id,\n username: response.username,\n displayName: response.display_name,\n bio: response.bio ?? '',\n linkedAddresses: response.linked_addresses,\n avatarUrl: response.avatar_url,\n tradingPrivacy: response.trading_privacy,\n connectedToX: response.connected_to_x,\n createdAt: response.created_at,\n updatedAt: response.updated_at,\n };\n }\n\n /**\n * Maps an API response to an X profile.\n *\n * @param response - The API response to map.\n * @returns The mapped X profile.\n */\n #mapXResponseToXProfile(response: ConnectXResponse): XProfile {\n return {\n xUserId: response.x_user_id,\n xProfileUrl: response.x_profile_url,\n username: response.username,\n displayName: response.display_name,\n avatarUrl: response.avatar_url,\n createdAt: response.created_at,\n updatedAt: response.updated_at,\n };\n }\n\n /**\n * Returns the current MetaMask profile from state, or undefined if none has been created.\n *\n * @returns The MetaMask profile, or undefined.\n */\n getProfile(): Profile | undefined {\n if (!this.#hasProfile()) {\n return undefined;\n }\n return this.state.profile;\n }\n\n /**\n * Returns the currently linked X profile from state, or undefined if none has been connected.\n *\n * @returns The X profile, or undefined.\n */\n getXProfile(): XProfile | undefined {\n return this.state.xProfile;\n }\n\n /**\n * Creates a new MetaMask profile, updates state, and returns the created profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created MetaMask profile.\n */\n async createProfile(params: CreateProfileParams): Promise<Profile> {\n const response: CreateProfileResponse = await this.messenger.call(\n 'ProfileService:createProfile',\n params,\n );\n const mapped = this.#mapApiResponseToProfile(response);\n this.update((state) => {\n state.profile = mapped;\n });\n return mapped;\n }\n\n /**\n * Fully replaces the current profile and updates state.\n *\n * @param input - The replacement profile data.\n * @throws If no profile has been created yet.\n */\n async replaceProfile(input: ReplaceProfileParams): Promise<void> {\n const profileId = this.#getProfileIdOrThrow();\n const response = await this.messenger.call(\n 'ProfileService:replaceProfile',\n profileId,\n input,\n );\n this.update((state) => {\n state.profile = this.#mapApiResponseToProfile(response);\n });\n }\n\n /**\n * Partially updates the current profile and updates state.\n *\n * @param input - The fields to update.\n * @throws If no profile has been created yet.\n */\n async updateProfile(input: UpdateProfileParams): Promise<void> {\n const profileId = this.#getProfileIdOrThrow();\n const response = await this.messenger.call(\n 'ProfileService:updateProfile',\n profileId,\n input,\n );\n this.update((state) => {\n state.profile = this.#mapApiResponseToProfile(response);\n });\n }\n\n /**\n * Deletes the current profile and resets state, including clearing any linked X profile.\n *\n * @throws If no profile has been created yet.\n */\n async deleteProfile(): Promise<void> {\n const profileId = this.#getProfileIdOrThrow();\n await this.messenger.call('ProfileService:deleteProfile', profileId);\n this.update((state) => {\n state.profile = getDefaultProfileControllerState().profile;\n state.xProfile = undefined;\n });\n }\n\n /**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n */\n async checkUsernameAvailability(\n username: string,\n ): Promise<UsernameAvailabilityResponse> {\n return await this.messenger.call(\n 'ProfileService:checkUsernameAvailability',\n username,\n );\n }\n\n /**\n * Completes the X OAuth flow for the profile in state and returns the\n * linked X profile. Updates controller state with the linked X profile.\n *\n * @param params - The parameters for the X OAuth flow.\n * @param params.code - The OAuth authorization code from the X redirect.\n * @param params.state - The state parameter returned by the X redirect.\n * @returns The linked X profile.\n */\n async connectX(params: { code: string; state: string }): Promise<XProfile> {\n const response = await this.messenger.call('ProfileService:connectX', {\n code: params.code,\n state: params.state,\n });\n const mapped = this.#mapXResponseToXProfile(response);\n this.update((state) => {\n state.xProfile = mapped;\n });\n return mapped;\n }\n\n /**\n * Fetches the X account linked to the authenticated profile, updates state,\n * and returns the X profile. The profile is resolved server-side from the\n * verified bearer token.\n *\n * @returns The linked X profile.\n */\n async fetchAndUpdateXAccount(): Promise<XProfile> {\n const response = await this.messenger.call('ProfileService:getXAccount');\n const mapped = this.#mapXResponseToXProfile(response);\n this.update((state) => {\n state.xProfile = mapped;\n });\n return mapped;\n }\n\n /**\n * Fetches a profile by its identifier and updates state.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The fetched profile.\n */\n async fetchAndUpdateProfile(profileId: string): Promise<Profile> {\n const response = await this.messenger.call(\n 'ProfileService:getProfile',\n profileId,\n );\n const mapped = this.#mapApiResponseToProfile(response);\n this.update((state) => {\n state.profile = mapped;\n });\n return mapped;\n }\n\n /**\n * Initiates the X OAuth flow by fetching the authorization URL from the backend.\n * The profile is resolved server-side from the verified bearer token.\n * Returns session data for the caller to use; nothing is stored in controller state.\n *\n * @returns The X authorization URL and state parameter.\n */\n async getXAuthorizationUrl(): Promise<ConnectXSession> {\n const response = await this.messenger.call('ProfileService:getXAuthUrl');\n return { authorizationUrl: response.url, state: response.state };\n }\n\n /**\n * Disconnects the X account linked to the given profile. If the given\n * profile matches the profile in state, clears `xProfile` from state and\n * marks the profile in state as no longer connected to X.\n *\n * @param profileId - The ID of the profile to disconnect the linked X account\n * from (sourced from {@link getProfile}).\n */\n async disconnectX(profileId: string): Promise<void> {\n await this.messenger.call('ProfileService:disconnectX', profileId);\n this.update((state) => {\n if (state.profile.profileId === profileId) {\n state.xProfile = undefined;\n state.profile.connectedToX = false;\n }\n });\n }\n\n /**\n * Clears the controller state, including the profile and X profile.\n */\n clearState(): void {\n this.update(() => getDefaultProfileControllerState());\n }\n}\n"]}
@@ -114,11 +114,16 @@ export type ProfileServiceGetXAccountAction = {
114
114
  handler: ProfileService['getXAccount'];
115
115
  };
116
116
  /**
117
- * Disconnects the X account linked to the given profile.
118
- * A `404` response is treated as success (the X account is already
119
- * disconnected, or the profile is unknown), making the operation idempotent.
117
+ * Disconnects the X account linked to the authenticated profile.
118
+ * Identity is resolved server-side from the verified bearer token, so the
119
+ * request targets the shared account endpoint rather than a profile-scoped
120
+ * path.
121
+ * A `404` response is treated as success (no X account is linked), making
122
+ * the operation idempotent.
120
123
  *
121
- * @param profileId - The ID of the profile to disconnect the linked X account from.
124
+ * @param profileId - The ID of the profile whose cached data should be
125
+ * invalidated after the disconnection. The API resolves the linked X account
126
+ * from the bearer token, not from this value.
122
127
  * @returns The result of the mutation.
123
128
  * @throws {HttpError} If the API returns a non-2xx response other than `404`.
124
129
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileService-method-action-types.d.ts","sourceRoot":"","sources":["../src/ProfileService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;C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5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,8BAA8B,GAC9B,iCAAiC,GACjC,kCAAkC,GAClC,iCAAiC,GACjC,iCAAiC,GACjC,6CAA6C,GAC7C,+BAA+B,GAC/B,4BAA4B,GAC5B,+BAA+B,GAC/B,+BAA+B,CAAC"}
1
+ {"version":3,"file":"ProfileService-method-action-types.d.ts","sourceRoot":"","sources":["../src/ProfileService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,cAAc,CAAC,2BAA2B,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,8BAA8B,GAC9B,iCAAiC,GACjC,kCAAkC,GAClC,iCAAiC,GACjC,iCAAiC,GACjC,6CAA6C,GAC7C,+BAA+B,GAC/B,4BAA4B,GAC5B,+BAA+B,GAC/B,+BAA+B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileService-method-action-types.js","sourceRoot":"","sources":["../src/ProfileService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ProfileService } from './ProfileService.js';\n\n/**\n * Fetches a profile by its identifier.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The profile data from the API.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceGetProfileAction = {\n type: `ProfileService:getProfile`;\n handler: ProfileService['getProfile'];\n};\n\n/**\n * Creates a new MetaMask profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\nexport type ProfileServiceCreateProfileAction = {\n type: `ProfileService:createProfile`;\n handler: ProfileService['createProfile'];\n};\n\n/**\n * Fully replaces an existing profile (PUT).\n *\n * @param profileId - The identifier of the profile to replace.\n * @param params - The replacement profile data.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\nexport type ProfileServiceReplaceProfileAction = {\n type: `ProfileService:replaceProfile`;\n handler: ProfileService['replaceProfile'];\n};\n\n/**\n * Partially updates an existing profile (PATCH).\n *\n * @param profileId - The identifier of the profile to update.\n * @param params - The fields to update.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\nexport type ProfileServiceUpdateProfileAction = {\n type: `ProfileService:updateProfile`;\n handler: ProfileService['updateProfile'];\n};\n\n/**\n * Deletes a profile by its identifier.\n *\n * @param profileId - The identifier of the profile to delete.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response.\n */\nexport type ProfileServiceDeleteProfileAction = {\n type: `ProfileService:deleteProfile`;\n handler: ProfileService['deleteProfile'];\n};\n\n/**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceCheckUsernameAvailabilityAction = {\n type: `ProfileService:checkUsernameAvailability`;\n handler: ProfileService['checkUsernameAvailability'];\n};\n\n/**\n * Fetches the X OAuth PKCE authorization URL and its associated state parameter.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns An object containing the authorization URL and the state token.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceGetXAuthUrlAction = {\n type: `ProfileService:getXAuthUrl`;\n handler: ProfileService['getXAuthUrl'];\n};\n\n/**\n * Completes the X OAuth PKCE flow and links the X account to the profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @param params - The OAuth callback code and state from the X redirect.\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceConnectXAction = {\n type: `ProfileService:connectX`;\n handler: ProfileService['connectX'];\n};\n\n/**\n * Fetches the X account currently linked to the authenticated profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceGetXAccountAction = {\n type: `ProfileService:getXAccount`;\n handler: ProfileService['getXAccount'];\n};\n\n/**\n * Disconnects the X account linked to the given profile.\n * A `404` response is treated as success (the X account is already\n * disconnected, or the profile is unknown), making the operation idempotent.\n *\n * @param profileId - The ID of the profile to disconnect the linked X account from.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response other than `404`.\n */\nexport type ProfileServiceDisconnectXAction = {\n type: `ProfileService:disconnectX`;\n handler: ProfileService['disconnectX'];\n};\n\n/**\n * Union of all ProfileService action types.\n */\nexport type ProfileServiceMethodActions =\n | ProfileServiceGetProfileAction\n | ProfileServiceCreateProfileAction\n | ProfileServiceReplaceProfileAction\n | ProfileServiceUpdateProfileAction\n | ProfileServiceDeleteProfileAction\n | ProfileServiceCheckUsernameAvailabilityAction\n | ProfileServiceGetXAuthUrlAction\n | ProfileServiceConnectXAction\n | ProfileServiceGetXAccountAction\n | ProfileServiceDisconnectXAction;\n"]}
1
+ {"version":3,"file":"ProfileService-method-action-types.js","sourceRoot":"","sources":["../src/ProfileService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ProfileService } from './ProfileService.js';\n\n/**\n * Fetches a profile by its identifier.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The profile data from the API.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceGetProfileAction = {\n type: `ProfileService:getProfile`;\n handler: ProfileService['getProfile'];\n};\n\n/**\n * Creates a new MetaMask profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\nexport type ProfileServiceCreateProfileAction = {\n type: `ProfileService:createProfile`;\n handler: ProfileService['createProfile'];\n};\n\n/**\n * Fully replaces an existing profile (PUT).\n *\n * @param profileId - The identifier of the profile to replace.\n * @param params - The replacement profile data.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\nexport type ProfileServiceReplaceProfileAction = {\n type: `ProfileService:replaceProfile`;\n handler: ProfileService['replaceProfile'];\n};\n\n/**\n * Partially updates an existing profile (PATCH).\n *\n * @param profileId - The identifier of the profile to update.\n * @param params - The fields to update.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\nexport type ProfileServiceUpdateProfileAction = {\n type: `ProfileService:updateProfile`;\n handler: ProfileService['updateProfile'];\n};\n\n/**\n * Deletes a profile by its identifier.\n *\n * @param profileId - The identifier of the profile to delete.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response.\n */\nexport type ProfileServiceDeleteProfileAction = {\n type: `ProfileService:deleteProfile`;\n handler: ProfileService['deleteProfile'];\n};\n\n/**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceCheckUsernameAvailabilityAction = {\n type: `ProfileService:checkUsernameAvailability`;\n handler: ProfileService['checkUsernameAvailability'];\n};\n\n/**\n * Fetches the X OAuth PKCE authorization URL and its associated state parameter.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns An object containing the authorization URL and the state token.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceGetXAuthUrlAction = {\n type: `ProfileService:getXAuthUrl`;\n handler: ProfileService['getXAuthUrl'];\n};\n\n/**\n * Completes the X OAuth PKCE flow and links the X account to the profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @param params - The OAuth callback code and state from the X redirect.\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceConnectXAction = {\n type: `ProfileService:connectX`;\n handler: ProfileService['connectX'];\n};\n\n/**\n * Fetches the X account currently linked to the authenticated profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\nexport type ProfileServiceGetXAccountAction = {\n type: `ProfileService:getXAccount`;\n handler: ProfileService['getXAccount'];\n};\n\n/**\n * Disconnects the X account linked to the authenticated profile.\n * Identity is resolved server-side from the verified bearer token, so the\n * request targets the shared account endpoint rather than a profile-scoped\n * path.\n * A `404` response is treated as success (no X account is linked), making\n * the operation idempotent.\n *\n * @param profileId - The ID of the profile whose cached data should be\n * invalidated after the disconnection. The API resolves the linked X account\n * from the bearer token, not from this value.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response other than `404`.\n */\nexport type ProfileServiceDisconnectXAction = {\n type: `ProfileService:disconnectX`;\n handler: ProfileService['disconnectX'];\n};\n\n/**\n * Union of all ProfileService action types.\n */\nexport type ProfileServiceMethodActions =\n | ProfileServiceGetProfileAction\n | ProfileServiceCreateProfileAction\n | ProfileServiceReplaceProfileAction\n | ProfileServiceUpdateProfileAction\n | ProfileServiceDeleteProfileAction\n | ProfileServiceCheckUsernameAvailabilityAction\n | ProfileServiceGetXAuthUrlAction\n | ProfileServiceConnectXAction\n | ProfileServiceGetXAccountAction\n | ProfileServiceDisconnectXAction;\n"]}
@@ -310,11 +310,16 @@ export declare class ProfileService extends BaseDataService<typeof serviceName,
310
310
  */
311
311
  getXAccount(): Promise<XAccountResponse>;
312
312
  /**
313
- * Disconnects the X account linked to the given profile.
314
- * A `404` response is treated as success (the X account is already
315
- * disconnected, or the profile is unknown), making the operation idempotent.
313
+ * Disconnects the X account linked to the authenticated profile.
314
+ * Identity is resolved server-side from the verified bearer token, so the
315
+ * request targets the shared account endpoint rather than a profile-scoped
316
+ * path.
317
+ * A `404` response is treated as success (no X account is linked), making
318
+ * the operation idempotent.
316
319
  *
317
- * @param profileId - The ID of the profile to disconnect the linked X account from.
320
+ * @param profileId - The ID of the profile whose cached data should be
321
+ * invalidated after the disconnection. The API resolves the linked X account
322
+ * from the bearer token, not from this value.
318
323
  * @returns The result of the mutation.
319
324
  * @throws {HttpError} If the API returns a non-2xx response other than `404`.
320
325
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileService.d.ts","sourceRoot":"","sources":["../src/ProfileService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAYlF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAE3F,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAM5C,uEAAuE;A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G;IACG,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAU7C;IAED;;;;;;;;;;;;;OAaG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBlD;CACF"}
@@ -333,11 +333,16 @@ export class ProfileService extends BaseDataService {
333
333
  });
334
334
  }
335
335
  /**
336
- * Disconnects the X account linked to the given profile.
337
- * A `404` response is treated as success (the X account is already
338
- * disconnected, or the profile is unknown), making the operation idempotent.
336
+ * Disconnects the X account linked to the authenticated profile.
337
+ * Identity is resolved server-side from the verified bearer token, so the
338
+ * request targets the shared account endpoint rather than a profile-scoped
339
+ * path.
340
+ * A `404` response is treated as success (no X account is linked), making
341
+ * the operation idempotent.
339
342
  *
340
- * @param profileId - The ID of the profile to disconnect the linked X account from.
343
+ * @param profileId - The ID of the profile whose cached data should be
344
+ * invalidated after the disconnection. The API resolves the linked X account
345
+ * from the bearer token, not from this value.
341
346
  * @returns The result of the mutation.
342
347
  * @throws {HttpError} If the API returns a non-2xx response other than `404`.
343
348
  */
@@ -346,7 +351,7 @@ export class ProfileService extends BaseDataService {
346
351
  mutationKey: [`${this.name}:disconnectX`, profileId],
347
352
  mutationFn: async () => {
348
353
  try {
349
- return await this.#fetch(`profiles/${encodeURIComponent(profileId)}/x`, {
354
+ return await this.#fetch('profiles/x/account', {
350
355
  method: 'DELETE',
351
356
  error: ProfileServiceErrorMessage.DISCONNECT_X_FAILED,
352
357
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileService.js","sourceRoot":"","sources":["../src/ProfileService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAO9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGvD,OAAO,EACL,KAAK,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,IAAI,IAAI,UAAU,GACnB,M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ACL,CAAC;CACF","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n CreateServicePolicyOptions,\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport {\n array,\n boolean,\n enums,\n intersection,\n nullable,\n optional,\n sensitive,\n string,\n type as structType,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { CaipAccountIdStruct } from '@metamask/utils';\n\nimport type { ProfileServiceMethodActions } from './ProfileService-method-action-types.js';\n\nexport const serviceName = 'ProfileService';\n\n// ---------------------------------------------------------------------------\n// Error messages\n// ---------------------------------------------------------------------------\n\n/** Human-readable error messages for each ProfileService operation. */\nexport const ProfileServiceErrorMessage = {\n GET_PROFILE_FAILED: 'ProfileService: failed to fetch profile',\n CREATE_PROFILE_FAILED: 'ProfileService: failed to create profile',\n REPLACE_PROFILE_FAILED: 'ProfileService: failed to replace profile',\n UPDATE_PROFILE_FAILED: 'ProfileService: failed to update profile',\n DELETE_PROFILE_FAILED: 'ProfileService: failed to delete profile',\n CHECK_USERNAME_AVAILABILITY_FAILED:\n 'ProfileService: failed to check username availability',\n GET_X_AUTH_URL_FAILED: 'ProfileService: failed to get X authentication URL',\n CONNECT_X_FAILED: 'ProfileService: failed to connect X account',\n GET_X_ACCOUNT_FAILED: 'ProfileService: failed to get X account',\n DISCONNECT_X_FAILED: 'ProfileService: failed to disconnect X account',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Superstruct schemas\n// ---------------------------------------------------------------------------\n\nconst TradingPrivacyStruct = enums(['public', 'private'] as const);\n\nconst ProfileApiResponseStruct = structType({\n profile_id: string(),\n username: string(),\n display_name: string(),\n bio: nullable(string()),\n linked_addresses: array(CaipAccountIdStruct),\n avatar_url: string(),\n trading_privacy: TradingPrivacyStruct,\n connected_to_x: boolean(),\n created_at: string(),\n updated_at: string(),\n});\n\nconst UsernameAvailabilityErrorStruct = structType({\n code: string(),\n message: string(),\n});\n\nconst UsernameAvailabilityResponseStruct = structType({\n username: string(),\n available: boolean(),\n valid: boolean(),\n normalized: string(),\n errors: array(UsernameAvailabilityErrorStruct),\n});\n\nconst XAuthUrlResponseStruct = structType({\n url: sensitive(string()),\n state: sensitive(string()),\n});\n\nconst ConnectXResponseStruct = structType({\n x_user_id: string(),\n x_profile_url: string(),\n username: string(),\n display_name: string(),\n avatar_url: string(),\n created_at: string(),\n updated_at: string(),\n});\n\nconst CreateProfileResponseStruct = intersection([\n ProfileApiResponseStruct,\n structType({ x_profile: optional(ConnectXResponseStruct) }),\n]);\n\nconst ConnectXParamsStruct = structType({\n code: sensitive(string()),\n state: sensitive(string()),\n});\n\nconst CreateProfileParamsStruct = structType({\n profile_id: string(),\n username: string(),\n display_name: string(),\n bio: optional(nullable(string())),\n linked_addresses: array(CaipAccountIdStruct),\n avatar_url: optional(string()),\n trading_privacy: TradingPrivacyStruct,\n});\n\nconst ReplaceProfileParamsStruct = structType({\n username: string(),\n display_name: string(),\n bio: optional(nullable(string())),\n linked_addresses: array(CaipAccountIdStruct),\n avatar_url: optional(string()),\n trading_privacy: TradingPrivacyStruct,\n});\n\nconst UpdateProfileParamsStruct = structType({\n username: optional(string()),\n display_name: optional(string()),\n bio: optional(nullable(string())),\n linked_addresses: optional(array(CaipAccountIdStruct)),\n avatar_url: optional(string()),\n trading_privacy: optional(TradingPrivacyStruct),\n});\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getProfile',\n 'createProfile',\n 'replaceProfile',\n 'updateProfile',\n 'deleteProfile',\n 'checkUsernameAvailability',\n 'getXAuthUrl',\n 'connectX',\n 'getXAccount',\n 'disconnectX',\n] as const;\n\n/** The shape of a profile returned by the MetaMask Profile API. */\nexport type ProfileApiResponse = Infer<typeof ProfileApiResponseStruct>;\n\n/** The response shape for createProfile — includes an optional linked X profile if the user had already connected X. */\nexport type CreateProfileResponse = Infer<typeof CreateProfileResponseStruct>;\n\n/** The response shape for a username availability check. */\nexport type UsernameAvailabilityResponse = Infer<\n typeof UsernameAvailabilityResponseStruct\n>;\n\n/** The response shape returned when connecting or fetching an X account. */\nexport type ConnectXResponse = Infer<typeof ConnectXResponseStruct>;\n\n/** The response shape returned when requesting the X OAuth authentication URL. */\nexport type XAuthUrlResponse = Infer<typeof XAuthUrlResponseStruct>;\n\n/** Alias for {@link ConnectXResponse} returned when fetching the linked X account. */\nexport type XAccountResponse = ConnectXResponse;\n\n/** Parameters for creating a new MetaMask profile. */\nexport type CreateProfileParams = Infer<typeof CreateProfileParamsStruct>;\n\n/** Parameters for fully replacing an existing MetaMask profile (PUT). */\nexport type ReplaceProfileParams = Infer<typeof ReplaceProfileParamsStruct>;\n\n/** Parameters for partially updating an existing MetaMask profile (PATCH). */\nexport type UpdateProfileParams = Infer<typeof UpdateProfileParamsStruct>;\n\n/** Parameters for completing the X OAuth PKCE flow. */\nexport type ConnectXParams = Infer<typeof ConnectXParamsStruct>;\n\n// ---------------------------------------------------------------------------\n// Messenger types\n// ---------------------------------------------------------------------------\n\n/** Union of all actions exposed by ProfileService, including cache invalidation. */\nexport type ProfileServiceActions =\n | ProfileServiceMethodActions\n | DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/** Event emitted when the ProfileService query cache is updated. */\nexport type ProfileServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/** Event emitted with per-query granularity when the ProfileService cache is updated. */\nexport type ProfileServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/** Union of all events emitted by ProfileService. */\nexport type ProfileServiceEvents =\n | ProfileServiceCacheUpdatedEvent\n | ProfileServiceGranularCacheUpdatedEvent;\n\ntype AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerTokenAction;\n\ntype AllowedEvents = never;\n\n/** Messenger type for ProfileService, scoped to its actions and events. */\nexport type ProfileServiceMessenger = Messenger<\n typeof serviceName,\n ProfileServiceActions | AllowedActions,\n ProfileServiceEvents | AllowedEvents\n>;\n\n// ---------------------------------------------------------------------------\n// Service\n// ---------------------------------------------------------------------------\n\n/** Communicates with the MetaMask Profile API and exposes all operations via the messenger. */\nexport class ProfileService extends BaseDataService<\n typeof serviceName,\n ProfileServiceMessenger\n> {\n readonly #baseUrl: string;\n\n get #v1Url(): string {\n return `${this.#baseUrl}/v1`;\n }\n\n /**\n * Creates a new ProfileService instance.\n *\n * @param options - Constructor options.\n * @param options.messenger - The messenger scoped to ProfileService.\n * @param options.baseUrl - Base URL for the MetaMask Profile API.\n * @param options.policyOptions - Optional service policy configuration.\n */\n constructor({\n messenger,\n baseUrl,\n policyOptions,\n }: {\n messenger: ProfileServiceMessenger;\n baseUrl: string;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({ name: serviceName, messenger, policyOptions });\n this.#baseUrl = baseUrl;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Gets the authentication headers for the request.\n *\n * @returns The authentication headers.\n */\n async #getAuthHeaders(): Promise<Record<string, string>> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return { Authorization: `Bearer ${token}` };\n }\n\n /**\n * Executes an authenticated HTTP request and returns the parsed JSON response.\n *\n * @param endpoint - The path relative to the v1 base URL.\n * @param options - Request options.\n * @param options.method - The HTTP method. Defaults to 'GET'.\n * @param options.error - The error message to use if the response is not OK.\n * @param options.json - Optional JSON body. If provided, sets Content-Type and serializes as body.\n * @returns The parsed JSON response.\n * @throws {HttpError} If the response is not a 2xx status code.\n */\n async #fetch(\n endpoint: string,\n options: { method: 'DELETE'; error: string },\n ): Promise<null>;\n\n async #fetch<ResponseType extends Json>(\n endpoint: string,\n options: {\n method?: string;\n error: string;\n json?: unknown;\n searchParams?: Record<string, string>;\n },\n ): Promise<ResponseType>;\n\n async #fetch<ResponseType extends Json>(\n endpoint: string,\n {\n method = 'GET',\n error,\n json,\n searchParams,\n }: {\n method?: string;\n error: string;\n json?: unknown;\n searchParams?: Record<string, string>;\n },\n ): Promise<ResponseType | null> {\n const authHeaders = await this.#getAuthHeaders();\n const url = new URL(`${this.#v1Url}/${endpoint}`);\n if (searchParams) {\n for (const [key, value] of Object.entries(searchParams)) {\n url.searchParams.append(key, value);\n }\n }\n const response = await fetch(url.toString(), {\n ...(method === 'GET' ? {} : { method }),\n headers: {\n ...authHeaders,\n ...(json === undefined ? {} : { 'Content-Type': 'application/json' }),\n },\n ...(json === undefined ? {} : { body: JSON.stringify(json) }),\n });\n if (!response.ok) {\n throw new HttpError(response.status, `${error}: ${response.status}`);\n }\n if (method === 'DELETE') {\n return null;\n }\n return (await response.json()) as ResponseType;\n }\n\n /**\n * Fetches a profile by its identifier.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The profile data from the API.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async getProfile(profileId: string): Promise<ProfileApiResponse> {\n return this.fetchQuery({\n queryKey: [`${this.name}:getProfile`, profileId],\n responseStruct: ProfileApiResponseStruct,\n queryFn: async () =>\n this.#fetch<ProfileApiResponse>(\n `profiles/${encodeURIComponent(profileId)}`,\n {\n error: ProfileServiceErrorMessage.GET_PROFILE_FAILED,\n },\n ),\n });\n }\n\n /**\n * Creates a new MetaMask profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\n async createProfile(\n params: CreateProfileParams,\n ): Promise<CreateProfileResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:createProfile`],\n responseStruct: CreateProfileResponseStruct,\n mutationFn: async () =>\n this.#fetch<CreateProfileResponse>('profiles', {\n method: 'POST',\n error: ProfileServiceErrorMessage.CREATE_PROFILE_FAILED,\n json: params,\n }),\n });\n }\n\n /**\n * Fully replaces an existing profile (PUT).\n *\n * @param profileId - The identifier of the profile to replace.\n * @param params - The replacement profile data.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\n async replaceProfile(\n profileId: string,\n params: ReplaceProfileParams,\n ): Promise<ProfileApiResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:replaceProfile`, profileId],\n responseStruct: ProfileApiResponseStruct,\n mutationFn: async () =>\n this.#fetch<ProfileApiResponse>(\n `profiles/${encodeURIComponent(profileId)}`,\n {\n method: 'PUT',\n error: ProfileServiceErrorMessage.REPLACE_PROFILE_FAILED,\n json: params,\n },\n ),\n });\n }\n\n /**\n * Partially updates an existing profile (PATCH).\n *\n * @param profileId - The identifier of the profile to update.\n * @param params - The fields to update.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\n async updateProfile(\n profileId: string,\n params: UpdateProfileParams,\n ): Promise<ProfileApiResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:updateProfile`, profileId],\n responseStruct: ProfileApiResponseStruct,\n mutationFn: async () =>\n this.#fetch<ProfileApiResponse>(\n `profiles/${encodeURIComponent(profileId)}`,\n {\n method: 'PATCH',\n error: ProfileServiceErrorMessage.UPDATE_PROFILE_FAILED,\n json: params,\n },\n ),\n });\n }\n\n /**\n * Deletes a profile by its identifier.\n *\n * @param profileId - The identifier of the profile to delete.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response.\n */\n async deleteProfile(profileId: string): Promise<void> {\n return this.executeMutation({\n mutationKey: [`${this.name}:deleteProfile`, profileId],\n mutationFn: async () =>\n this.#fetch(`profiles/${encodeURIComponent(profileId)}`, {\n method: 'DELETE',\n error: ProfileServiceErrorMessage.DELETE_PROFILE_FAILED,\n }),\n });\n }\n\n /**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async checkUsernameAvailability(\n username: string,\n ): Promise<UsernameAvailabilityResponse> {\n return this.fetchQuery({\n queryKey: [`${this.name}:checkUsernameAvailability`, username],\n staleTime: 0,\n responseStruct: UsernameAvailabilityResponseStruct,\n queryFn: async () =>\n this.#fetch<UsernameAvailabilityResponse>(\n 'profiles/username/availability',\n {\n error:\n ProfileServiceErrorMessage.CHECK_USERNAME_AVAILABILITY_FAILED,\n searchParams: { username },\n },\n ),\n });\n }\n\n /**\n * Fetches the X OAuth PKCE authorization URL and its associated state parameter.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns An object containing the authorization URL and the state token.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async getXAuthUrl(): Promise<XAuthUrlResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:getXAuthUrl`],\n responseStruct: XAuthUrlResponseStruct,\n mutationFn: async () =>\n this.#fetch<XAuthUrlResponse>('profiles/x/authentication-url', {\n error: ProfileServiceErrorMessage.GET_X_AUTH_URL_FAILED,\n }),\n });\n }\n\n /**\n * Completes the X OAuth PKCE flow and links the X account to the profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @param params - The OAuth callback code and state from the X redirect.\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async connectX(params: ConnectXParams): Promise<ConnectXResponse> {\n const response = await this.executeMutation({\n mutationKey: [`${this.name}:connectX`],\n responseStruct: ConnectXResponseStruct,\n mutationFn: async () =>\n this.#fetch<ConnectXResponse>('profiles/x/connect', {\n method: 'POST',\n error: ProfileServiceErrorMessage.CONNECT_X_FAILED,\n json: params,\n }),\n });\n // The response does not identify the profile, so drop every cached\n // profile: `connected_to_x` is now out of date.\n await this.invalidateQueries({ queryKey: [`${this.name}:getProfile`] });\n return response;\n }\n\n /**\n * Fetches the X account currently linked to the authenticated profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async getXAccount(): Promise<XAccountResponse> {\n return this.fetchQuery({\n queryKey: [`${this.name}:getXAccount`],\n staleTime: 0,\n responseStruct: ConnectXResponseStruct,\n queryFn: async () =>\n this.#fetch<ConnectXResponse>('profiles/x/account', {\n error: ProfileServiceErrorMessage.GET_X_ACCOUNT_FAILED,\n }),\n });\n }\n\n /**\n * Disconnects the X account linked to the given profile.\n * A `404` response is treated as success (the X account is already\n * disconnected, or the profile is unknown), making the operation idempotent.\n *\n * @param profileId - The ID of the profile to disconnect the linked X account from.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response other than `404`.\n */\n async disconnectX(profileId: string): Promise<void> {\n await this.executeMutation({\n mutationKey: [`${this.name}:disconnectX`, profileId],\n mutationFn: async () => {\n try {\n return await this.#fetch(\n `profiles/${encodeURIComponent(profileId)}/x`,\n {\n method: 'DELETE',\n error: ProfileServiceErrorMessage.DISCONNECT_X_FAILED,\n },\n );\n } catch (error) {\n if (error instanceof HttpError && error.httpStatus === 404) {\n return null;\n }\n throw error;\n }\n },\n });\n // The cached profile no longer reflects `connected_to_x`.\n await this.invalidateQueries({\n queryKey: [`${this.name}:getProfile`, profileId],\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ProfileService.js","sourceRoot":"","sources":["../src/ProfileService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAO9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGvD,OAAO,EACL,KAAK,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,IAAI,IAA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C;CACF","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n CreateServicePolicyOptions,\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport {\n array,\n boolean,\n enums,\n intersection,\n nullable,\n optional,\n sensitive,\n string,\n type as structType,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { CaipAccountIdStruct } from '@metamask/utils';\n\nimport type { ProfileServiceMethodActions } from './ProfileService-method-action-types.js';\n\nexport const serviceName = 'ProfileService';\n\n// ---------------------------------------------------------------------------\n// Error messages\n// ---------------------------------------------------------------------------\n\n/** Human-readable error messages for each ProfileService operation. */\nexport const ProfileServiceErrorMessage = {\n GET_PROFILE_FAILED: 'ProfileService: failed to fetch profile',\n CREATE_PROFILE_FAILED: 'ProfileService: failed to create profile',\n REPLACE_PROFILE_FAILED: 'ProfileService: failed to replace profile',\n UPDATE_PROFILE_FAILED: 'ProfileService: failed to update profile',\n DELETE_PROFILE_FAILED: 'ProfileService: failed to delete profile',\n CHECK_USERNAME_AVAILABILITY_FAILED:\n 'ProfileService: failed to check username availability',\n GET_X_AUTH_URL_FAILED: 'ProfileService: failed to get X authentication URL',\n CONNECT_X_FAILED: 'ProfileService: failed to connect X account',\n GET_X_ACCOUNT_FAILED: 'ProfileService: failed to get X account',\n DISCONNECT_X_FAILED: 'ProfileService: failed to disconnect X account',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Superstruct schemas\n// ---------------------------------------------------------------------------\n\nconst TradingPrivacyStruct = enums(['public', 'private'] as const);\n\nconst ProfileApiResponseStruct = structType({\n profile_id: string(),\n username: string(),\n display_name: string(),\n bio: nullable(string()),\n linked_addresses: array(CaipAccountIdStruct),\n avatar_url: string(),\n trading_privacy: TradingPrivacyStruct,\n connected_to_x: boolean(),\n created_at: string(),\n updated_at: string(),\n});\n\nconst UsernameAvailabilityErrorStruct = structType({\n code: string(),\n message: string(),\n});\n\nconst UsernameAvailabilityResponseStruct = structType({\n username: string(),\n available: boolean(),\n valid: boolean(),\n normalized: string(),\n errors: array(UsernameAvailabilityErrorStruct),\n});\n\nconst XAuthUrlResponseStruct = structType({\n url: sensitive(string()),\n state: sensitive(string()),\n});\n\nconst ConnectXResponseStruct = structType({\n x_user_id: string(),\n x_profile_url: string(),\n username: string(),\n display_name: string(),\n avatar_url: string(),\n created_at: string(),\n updated_at: string(),\n});\n\nconst CreateProfileResponseStruct = intersection([\n ProfileApiResponseStruct,\n structType({ x_profile: optional(ConnectXResponseStruct) }),\n]);\n\nconst ConnectXParamsStruct = structType({\n code: sensitive(string()),\n state: sensitive(string()),\n});\n\nconst CreateProfileParamsStruct = structType({\n profile_id: string(),\n username: string(),\n display_name: string(),\n bio: optional(nullable(string())),\n linked_addresses: array(CaipAccountIdStruct),\n avatar_url: optional(string()),\n trading_privacy: TradingPrivacyStruct,\n});\n\nconst ReplaceProfileParamsStruct = structType({\n username: string(),\n display_name: string(),\n bio: optional(nullable(string())),\n linked_addresses: array(CaipAccountIdStruct),\n avatar_url: optional(string()),\n trading_privacy: TradingPrivacyStruct,\n});\n\nconst UpdateProfileParamsStruct = structType({\n username: optional(string()),\n display_name: optional(string()),\n bio: optional(nullable(string())),\n linked_addresses: optional(array(CaipAccountIdStruct)),\n avatar_url: optional(string()),\n trading_privacy: optional(TradingPrivacyStruct),\n});\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getProfile',\n 'createProfile',\n 'replaceProfile',\n 'updateProfile',\n 'deleteProfile',\n 'checkUsernameAvailability',\n 'getXAuthUrl',\n 'connectX',\n 'getXAccount',\n 'disconnectX',\n] as const;\n\n/** The shape of a profile returned by the MetaMask Profile API. */\nexport type ProfileApiResponse = Infer<typeof ProfileApiResponseStruct>;\n\n/** The response shape for createProfile — includes an optional linked X profile if the user had already connected X. */\nexport type CreateProfileResponse = Infer<typeof CreateProfileResponseStruct>;\n\n/** The response shape for a username availability check. */\nexport type UsernameAvailabilityResponse = Infer<\n typeof UsernameAvailabilityResponseStruct\n>;\n\n/** The response shape returned when connecting or fetching an X account. */\nexport type ConnectXResponse = Infer<typeof ConnectXResponseStruct>;\n\n/** The response shape returned when requesting the X OAuth authentication URL. */\nexport type XAuthUrlResponse = Infer<typeof XAuthUrlResponseStruct>;\n\n/** Alias for {@link ConnectXResponse} returned when fetching the linked X account. */\nexport type XAccountResponse = ConnectXResponse;\n\n/** Parameters for creating a new MetaMask profile. */\nexport type CreateProfileParams = Infer<typeof CreateProfileParamsStruct>;\n\n/** Parameters for fully replacing an existing MetaMask profile (PUT). */\nexport type ReplaceProfileParams = Infer<typeof ReplaceProfileParamsStruct>;\n\n/** Parameters for partially updating an existing MetaMask profile (PATCH). */\nexport type UpdateProfileParams = Infer<typeof UpdateProfileParamsStruct>;\n\n/** Parameters for completing the X OAuth PKCE flow. */\nexport type ConnectXParams = Infer<typeof ConnectXParamsStruct>;\n\n// ---------------------------------------------------------------------------\n// Messenger types\n// ---------------------------------------------------------------------------\n\n/** Union of all actions exposed by ProfileService, including cache invalidation. */\nexport type ProfileServiceActions =\n | ProfileServiceMethodActions\n | DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/** Event emitted when the ProfileService query cache is updated. */\nexport type ProfileServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/** Event emitted with per-query granularity when the ProfileService cache is updated. */\nexport type ProfileServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/** Union of all events emitted by ProfileService. */\nexport type ProfileServiceEvents =\n | ProfileServiceCacheUpdatedEvent\n | ProfileServiceGranularCacheUpdatedEvent;\n\ntype AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerTokenAction;\n\ntype AllowedEvents = never;\n\n/** Messenger type for ProfileService, scoped to its actions and events. */\nexport type ProfileServiceMessenger = Messenger<\n typeof serviceName,\n ProfileServiceActions | AllowedActions,\n ProfileServiceEvents | AllowedEvents\n>;\n\n// ---------------------------------------------------------------------------\n// Service\n// ---------------------------------------------------------------------------\n\n/** Communicates with the MetaMask Profile API and exposes all operations via the messenger. */\nexport class ProfileService extends BaseDataService<\n typeof serviceName,\n ProfileServiceMessenger\n> {\n readonly #baseUrl: string;\n\n get #v1Url(): string {\n return `${this.#baseUrl}/v1`;\n }\n\n /**\n * Creates a new ProfileService instance.\n *\n * @param options - Constructor options.\n * @param options.messenger - The messenger scoped to ProfileService.\n * @param options.baseUrl - Base URL for the MetaMask Profile API.\n * @param options.policyOptions - Optional service policy configuration.\n */\n constructor({\n messenger,\n baseUrl,\n policyOptions,\n }: {\n messenger: ProfileServiceMessenger;\n baseUrl: string;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({ name: serviceName, messenger, policyOptions });\n this.#baseUrl = baseUrl;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Gets the authentication headers for the request.\n *\n * @returns The authentication headers.\n */\n async #getAuthHeaders(): Promise<Record<string, string>> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return { Authorization: `Bearer ${token}` };\n }\n\n /**\n * Executes an authenticated HTTP request and returns the parsed JSON response.\n *\n * @param endpoint - The path relative to the v1 base URL.\n * @param options - Request options.\n * @param options.method - The HTTP method. Defaults to 'GET'.\n * @param options.error - The error message to use if the response is not OK.\n * @param options.json - Optional JSON body. If provided, sets Content-Type and serializes as body.\n * @returns The parsed JSON response.\n * @throws {HttpError} If the response is not a 2xx status code.\n */\n async #fetch(\n endpoint: string,\n options: { method: 'DELETE'; error: string },\n ): Promise<null>;\n\n async #fetch<ResponseType extends Json>(\n endpoint: string,\n options: {\n method?: string;\n error: string;\n json?: unknown;\n searchParams?: Record<string, string>;\n },\n ): Promise<ResponseType>;\n\n async #fetch<ResponseType extends Json>(\n endpoint: string,\n {\n method = 'GET',\n error,\n json,\n searchParams,\n }: {\n method?: string;\n error: string;\n json?: unknown;\n searchParams?: Record<string, string>;\n },\n ): Promise<ResponseType | null> {\n const authHeaders = await this.#getAuthHeaders();\n const url = new URL(`${this.#v1Url}/${endpoint}`);\n if (searchParams) {\n for (const [key, value] of Object.entries(searchParams)) {\n url.searchParams.append(key, value);\n }\n }\n const response = await fetch(url.toString(), {\n ...(method === 'GET' ? {} : { method }),\n headers: {\n ...authHeaders,\n ...(json === undefined ? {} : { 'Content-Type': 'application/json' }),\n },\n ...(json === undefined ? {} : { body: JSON.stringify(json) }),\n });\n if (!response.ok) {\n throw new HttpError(response.status, `${error}: ${response.status}`);\n }\n if (method === 'DELETE') {\n return null;\n }\n return (await response.json()) as ResponseType;\n }\n\n /**\n * Fetches a profile by its identifier.\n *\n * @param profileId - The profile identifier to fetch.\n * @returns The profile data from the API.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async getProfile(profileId: string): Promise<ProfileApiResponse> {\n return this.fetchQuery({\n queryKey: [`${this.name}:getProfile`, profileId],\n responseStruct: ProfileApiResponseStruct,\n queryFn: async () =>\n this.#fetch<ProfileApiResponse>(\n `profiles/${encodeURIComponent(profileId)}`,\n {\n error: ProfileServiceErrorMessage.GET_PROFILE_FAILED,\n },\n ),\n });\n }\n\n /**\n * Creates a new MetaMask profile.\n *\n * @param params - The profile creation parameters.\n * @returns The created profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\n async createProfile(\n params: CreateProfileParams,\n ): Promise<CreateProfileResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:createProfile`],\n responseStruct: CreateProfileResponseStruct,\n mutationFn: async () =>\n this.#fetch<CreateProfileResponse>('profiles', {\n method: 'POST',\n error: ProfileServiceErrorMessage.CREATE_PROFILE_FAILED,\n json: params,\n }),\n });\n }\n\n /**\n * Fully replaces an existing profile (PUT).\n *\n * @param profileId - The identifier of the profile to replace.\n * @param params - The replacement profile data.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\n async replaceProfile(\n profileId: string,\n params: ReplaceProfileParams,\n ): Promise<ProfileApiResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:replaceProfile`, profileId],\n responseStruct: ProfileApiResponseStruct,\n mutationFn: async () =>\n this.#fetch<ProfileApiResponse>(\n `profiles/${encodeURIComponent(profileId)}`,\n {\n method: 'PUT',\n error: ProfileServiceErrorMessage.REPLACE_PROFILE_FAILED,\n json: params,\n },\n ),\n });\n }\n\n /**\n * Partially updates an existing profile (PATCH).\n *\n * @param profileId - The identifier of the profile to update.\n * @param params - The fields to update.\n * @returns The updated profile data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response do not match the expected shape.\n */\n async updateProfile(\n profileId: string,\n params: UpdateProfileParams,\n ): Promise<ProfileApiResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:updateProfile`, profileId],\n responseStruct: ProfileApiResponseStruct,\n mutationFn: async () =>\n this.#fetch<ProfileApiResponse>(\n `profiles/${encodeURIComponent(profileId)}`,\n {\n method: 'PATCH',\n error: ProfileServiceErrorMessage.UPDATE_PROFILE_FAILED,\n json: params,\n },\n ),\n });\n }\n\n /**\n * Deletes a profile by its identifier.\n *\n * @param profileId - The identifier of the profile to delete.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response.\n */\n async deleteProfile(profileId: string): Promise<void> {\n return this.executeMutation({\n mutationKey: [`${this.name}:deleteProfile`, profileId],\n mutationFn: async () =>\n this.#fetch(`profiles/${encodeURIComponent(profileId)}`, {\n method: 'DELETE',\n error: ProfileServiceErrorMessage.DELETE_PROFILE_FAILED,\n }),\n });\n }\n\n /**\n * Checks whether a username is available.\n *\n * @param username - The username to check.\n * @returns Availability details including validity and normalized form.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async checkUsernameAvailability(\n username: string,\n ): Promise<UsernameAvailabilityResponse> {\n return this.fetchQuery({\n queryKey: [`${this.name}:checkUsernameAvailability`, username],\n staleTime: 0,\n responseStruct: UsernameAvailabilityResponseStruct,\n queryFn: async () =>\n this.#fetch<UsernameAvailabilityResponse>(\n 'profiles/username/availability',\n {\n error:\n ProfileServiceErrorMessage.CHECK_USERNAME_AVAILABILITY_FAILED,\n searchParams: { username },\n },\n ),\n });\n }\n\n /**\n * Fetches the X OAuth PKCE authorization URL and its associated state parameter.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns An object containing the authorization URL and the state token.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async getXAuthUrl(): Promise<XAuthUrlResponse> {\n return this.executeMutation({\n mutationKey: [`${this.name}:getXAuthUrl`],\n responseStruct: XAuthUrlResponseStruct,\n mutationFn: async () =>\n this.#fetch<XAuthUrlResponse>('profiles/x/authentication-url', {\n error: ProfileServiceErrorMessage.GET_X_AUTH_URL_FAILED,\n }),\n });\n }\n\n /**\n * Completes the X OAuth PKCE flow and links the X account to the profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @param params - The OAuth callback code and state from the X redirect.\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async connectX(params: ConnectXParams): Promise<ConnectXResponse> {\n const response = await this.executeMutation({\n mutationKey: [`${this.name}:connectX`],\n responseStruct: ConnectXResponseStruct,\n mutationFn: async () =>\n this.#fetch<ConnectXResponse>('profiles/x/connect', {\n method: 'POST',\n error: ProfileServiceErrorMessage.CONNECT_X_FAILED,\n json: params,\n }),\n });\n // The response does not identify the profile, so drop every cached\n // profile: `connected_to_x` is now out of date.\n await this.invalidateQueries({ queryKey: [`${this.name}:getProfile`] });\n return response;\n }\n\n /**\n * Fetches the X account currently linked to the authenticated profile.\n * The profile is resolved server-side from the verified bearer token.\n *\n * @returns The linked X account data.\n * @throws {HttpError} If the API returns a non-2xx response.\n * @throws {StructError} If the response does not match the expected shape.\n */\n async getXAccount(): Promise<XAccountResponse> {\n return this.fetchQuery({\n queryKey: [`${this.name}:getXAccount`],\n staleTime: 0,\n responseStruct: ConnectXResponseStruct,\n queryFn: async () =>\n this.#fetch<ConnectXResponse>('profiles/x/account', {\n error: ProfileServiceErrorMessage.GET_X_ACCOUNT_FAILED,\n }),\n });\n }\n\n /**\n * Disconnects the X account linked to the authenticated profile.\n * Identity is resolved server-side from the verified bearer token, so the\n * request targets the shared account endpoint rather than a profile-scoped\n * path.\n * A `404` response is treated as success (no X account is linked), making\n * the operation idempotent.\n *\n * @param profileId - The ID of the profile whose cached data should be\n * invalidated after the disconnection. The API resolves the linked X account\n * from the bearer token, not from this value.\n * @returns The result of the mutation.\n * @throws {HttpError} If the API returns a non-2xx response other than `404`.\n */\n async disconnectX(profileId: string): Promise<void> {\n await this.executeMutation({\n mutationKey: [`${this.name}:disconnectX`, profileId],\n mutationFn: async () => {\n try {\n return await this.#fetch('profiles/x/account', {\n method: 'DELETE',\n error: ProfileServiceErrorMessage.DISCONNECT_X_FAILED,\n });\n } catch (error) {\n if (error instanceof HttpError && error.httpStatus === 404) {\n return null;\n }\n throw error;\n }\n },\n });\n // The cached profile no longer reflects `connected_to_x`.\n await this.invalidateQueries({\n queryKey: [`${this.name}:getProfile`, profileId],\n });\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { Profile, XProfile, ConnectXSession, ProfileControllerState, ProfileControllerGetStateAction, ProfileControllerActions, ProfileControllerChangeEvent, ProfileControllerEvents, ProfileControllerMessenger, } from './ProfileController.js';
2
2
  export { ProfileController, getDefaultProfileControllerState, } from './ProfileController.js';
3
- export type { ProfileControllerCheckUsernameAvailabilityAction, ProfileControllerConnectXAction, ProfileControllerCreateProfileAction, ProfileControllerDeleteProfileAction, ProfileControllerDisconnectXAction, ProfileControllerGetProfileAction, ProfileControllerFetchAndUpdateXAccountAction, ProfileControllerFetchAndUpdateProfileAction, ProfileControllerGetXProfileAction, ProfileControllerReplaceProfileAction, ProfileControllerGetXAuthorizationUrlAction, ProfileControllerUpdateProfileAction, } from './ProfileController-method-action-types.js';
3
+ export type { ProfileControllerCheckUsernameAvailabilityAction, ProfileControllerConnectXAction, ProfileControllerCreateProfileAction, ProfileControllerDeleteProfileAction, ProfileControllerDisconnectXAction, ProfileControllerGetProfileAction, ProfileControllerFetchAndUpdateXAccountAction, ProfileControllerFetchAndUpdateProfileAction, ProfileControllerGetXProfileAction, ProfileControllerReplaceProfileAction, ProfileControllerGetXAuthorizationUrlAction, ProfileControllerUpdateProfileAction, ProfileControllerClearStateAction, } from './ProfileController-method-action-types.js';
4
4
  export type { ProfileApiResponse, CreateProfileResponse, CreateProfileParams, ReplaceProfileParams, UpdateProfileParams, ConnectXParams, UsernameAvailabilityResponse, XAuthUrlResponse, ConnectXResponse, XAccountResponse, ProfileServiceActions, ProfileServiceEvents, ProfileServiceMessenger, } from './ProfileService.js';
5
5
  export { ProfileService, ProfileServiceErrorMessage, } from './ProfileService.js';
6
6
  export type { MockProfileServiceHandlers } from './ProfileServiceMock.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,gDAAgD,EAChD,+BAA+B,EAC/B,oCAAoC,EACpC,oCAAoC,EACpC,kCAAkC,EAClC,iCAAiC,EACjC,6CAA6C,EAC7C,4CAA4C,EAC5C,kCAAkC,EAClC,qCAAqC,EACrC,2CAA2C,EAC3C,oCAAoC,GACrC,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,4BAA4B,EAC5B,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,6CAA6C,EAC7C,4BAA4B,EAC5B,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,yCAAyC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,gDAAgD,EAChD,+BAA+B,EAC/B,oCAAoC,EACpC,oCAAoC,EACpC,kCAAkC,EAClC,iCAAiC,EACjC,6CAA6C,EAC7C,4CAA4C,EAC5C,kCAAkC,EAClC,qCAAqC,EACrC,2CAA2C,EAC3C,oCAAoC,EACpC,iCAAiC,GAClC,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,4BAA4B,EAC5B,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,6CAA6C,EAC7C,4BAA4B,EAC5B,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,yCAAyC,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,iBAAiB,EACjB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AA8BhC,OAAO,EACL,cAAc,EACd,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC","sourcesContent":["export type {\n Profile,\n XProfile,\n ConnectXSession,\n ProfileControllerState,\n ProfileControllerGetStateAction,\n ProfileControllerActions,\n ProfileControllerChangeEvent,\n ProfileControllerEvents,\n ProfileControllerMessenger,\n} from './ProfileController.js';\nexport {\n ProfileController,\n getDefaultProfileControllerState,\n} from './ProfileController.js';\nexport type {\n ProfileControllerCheckUsernameAvailabilityAction,\n ProfileControllerConnectXAction,\n ProfileControllerCreateProfileAction,\n ProfileControllerDeleteProfileAction,\n ProfileControllerDisconnectXAction,\n ProfileControllerGetProfileAction,\n ProfileControllerFetchAndUpdateXAccountAction,\n ProfileControllerFetchAndUpdateProfileAction,\n ProfileControllerGetXProfileAction,\n ProfileControllerReplaceProfileAction,\n ProfileControllerGetXAuthorizationUrlAction,\n ProfileControllerUpdateProfileAction,\n} from './ProfileController-method-action-types.js';\nexport type {\n ProfileApiResponse,\n CreateProfileResponse,\n CreateProfileParams,\n ReplaceProfileParams,\n UpdateProfileParams,\n ConnectXParams,\n UsernameAvailabilityResponse,\n XAuthUrlResponse,\n ConnectXResponse,\n XAccountResponse,\n ProfileServiceActions,\n ProfileServiceEvents,\n ProfileServiceMessenger,\n} from './ProfileService.js';\nexport {\n ProfileService,\n ProfileServiceErrorMessage,\n} from './ProfileService.js';\nexport type { MockProfileServiceHandlers } from './ProfileServiceMock.js';\nexport {\n buildMockProfileService,\n MOCK_PROFILE_API_RESPONSE,\n MOCK_X_CONNECT_RESPONSE,\n MOCK_X_AUTH_URL_RESPONSE,\n} from './ProfileServiceMock.js';\nexport type {\n ProfileServiceCheckUsernameAvailabilityAction,\n ProfileServiceConnectXAction,\n ProfileServiceCreateProfileAction,\n ProfileServiceDeleteProfileAction,\n ProfileServiceDisconnectXAction,\n ProfileServiceGetProfileAction,\n ProfileServiceGetXAccountAction,\n ProfileServiceGetXAuthUrlAction,\n ProfileServiceReplaceProfileAction,\n ProfileServiceUpdateProfileAction,\n} from './ProfileService-method-action-types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,iBAAiB,EACjB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,EACL,cAAc,EACd,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC","sourcesContent":["export type {\n Profile,\n XProfile,\n ConnectXSession,\n ProfileControllerState,\n ProfileControllerGetStateAction,\n ProfileControllerActions,\n ProfileControllerChangeEvent,\n ProfileControllerEvents,\n ProfileControllerMessenger,\n} from './ProfileController.js';\nexport {\n ProfileController,\n getDefaultProfileControllerState,\n} from './ProfileController.js';\nexport type {\n ProfileControllerCheckUsernameAvailabilityAction,\n ProfileControllerConnectXAction,\n ProfileControllerCreateProfileAction,\n ProfileControllerDeleteProfileAction,\n ProfileControllerDisconnectXAction,\n ProfileControllerGetProfileAction,\n ProfileControllerFetchAndUpdateXAccountAction,\n ProfileControllerFetchAndUpdateProfileAction,\n ProfileControllerGetXProfileAction,\n ProfileControllerReplaceProfileAction,\n ProfileControllerGetXAuthorizationUrlAction,\n ProfileControllerUpdateProfileAction,\n ProfileControllerClearStateAction,\n} from './ProfileController-method-action-types.js';\nexport type {\n ProfileApiResponse,\n CreateProfileResponse,\n CreateProfileParams,\n ReplaceProfileParams,\n UpdateProfileParams,\n ConnectXParams,\n UsernameAvailabilityResponse,\n XAuthUrlResponse,\n ConnectXResponse,\n XAccountResponse,\n ProfileServiceActions,\n ProfileServiceEvents,\n ProfileServiceMessenger,\n} from './ProfileService.js';\nexport {\n ProfileService,\n ProfileServiceErrorMessage,\n} from './ProfileService.js';\nexport type { MockProfileServiceHandlers } from './ProfileServiceMock.js';\nexport {\n buildMockProfileService,\n MOCK_PROFILE_API_RESPONSE,\n MOCK_X_CONNECT_RESPONSE,\n MOCK_X_AUTH_URL_RESPONSE,\n} from './ProfileServiceMock.js';\nexport type {\n ProfileServiceCheckUsernameAvailabilityAction,\n ProfileServiceConnectXAction,\n ProfileServiceCreateProfileAction,\n ProfileServiceDeleteProfileAction,\n ProfileServiceDisconnectXAction,\n ProfileServiceGetProfileAction,\n ProfileServiceGetXAccountAction,\n ProfileServiceGetXAuthUrlAction,\n ProfileServiceReplaceProfileAction,\n ProfileServiceUpdateProfileAction,\n} from './ProfileService-method-action-types.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/profile-controller",
3
- "version": "1.2.0-preview-35f016caa",
3
+ "version": "1.2.1-preview-a26804c",
4
4
  "description": "Controller for managing user profile data including username, bio, avatar, and linked accounts via the MetaMask Profile API",
5
5
  "keywords": [
6
6
  "Ethereum",