@metamask-previews/profile-controller 1.0.1-preview-8555a5583 → 1.0.1-preview-aa49ca5
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 +4 -4
- package/dist/ProfileServiceMock.d.ts +25 -0
- package/dist/ProfileServiceMock.d.ts.map +1 -0
- package/dist/ProfileServiceMock.js +65 -0
- package/dist/ProfileServiceMock.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,21 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- Add `
|
|
12
|
+
- Add `ProfileServiceMock` for mocking profile-api responses ([#10745](https://github.com/MetaMask/core/pull/10745))
|
|
13
|
+
- Add `getXAuthorizationUrl` method to `ProfileController` for initiating the X OAuth flow. It fetches the authorization URL via `ProfileService:getXAuthUrl` (the profile is resolved server-side from the verified bearer token), and returns the authorization URL and state parameter as ephemeral session data, without storing them in controller state ([#10668](https://github.com/MetaMask/core/pull/10668), [#10793](https://github.com/MetaMask/core/pull/10793))
|
|
13
14
|
- Add `disconnectX` method to `ProfileController` for unlinking the X account from a profile. It delegates to `ProfileService:disconnectX`, and when the disconnected profile matches the profile in state, clears `xProfile` from controller state and sets `connectedToX` to `false` ([#10668](https://github.com/MetaMask/core/pull/10668))
|
|
14
15
|
- Add `disconnectX` method to `ProfileService` for sending an authenticated `DELETE` request to the `profiles/{profileId}/x` endpoint; a `404` response is treated as success (the X account is already disconnected) ([#10668](https://github.com/MetaMask/core/pull/10668))
|
|
15
16
|
- Add `fetchAndUpdateProfile` method to the `ProfileController` to fetch a profile from the profile-api and update the controller's state ([#10793](https://github.com/MetaMask/core/pull/10793))
|
|
16
17
|
|
|
17
18
|
### Changed
|
|
18
19
|
|
|
19
|
-
- `getXAuthorizationUrl` no longer accepts a `linkedAddress` parameter
|
|
20
|
-
- `connectX`
|
|
20
|
+
- `getXAuthorizationUrl` no longer accepts a `linkedAddress` parameter ([#10668](https://github.com/MetaMask/core/pull/10668))
|
|
21
|
+
- `connectX` updates controller state (`xProfile`) on success ([#10668](https://github.com/MetaMask/core/pull/10668), [#10793](https://github.com/MetaMask/core/pull/10793))
|
|
21
22
|
- Bump `@metamask/profile-sync-controller` from `^34.0.0` to `^34.0.3` ([#10752](https://github.com/MetaMask/core/pull/10752), [#10756](https://github.com/MetaMask/core/pull/10756), [#10761](https://github.com/MetaMask/core/pull/10761))
|
|
22
23
|
|
|
23
24
|
### Fixed
|
|
24
25
|
|
|
25
26
|
- Fix the `ProfileController` messenger event type: the controller exposes `ProfileController:stateChanged` (emitted on state changes), not `ProfileController:stateChange` ([#10668](https://github.com/MetaMask/core/pull/10668))
|
|
26
|
-
- Fix the `ProfileController`'s `connectX` and `getXAuthorizationUrl` methods to prevent throwing when a profile ID doesn't exist in state ([#10793](https://github.com/MetaMask/core/pull/10793))
|
|
27
27
|
- Fix the `ProfileService`'s response type to not have `avatar_url` as nullable ([#10793](https://github.com/MetaMask/core/pull/10793))
|
|
28
28
|
|
|
29
29
|
## [1.0.1]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ConnectXParams, CreateProfileParams, CreateProfileResponse, ProfileApiResponse, ProfileServiceMessenger, ReplaceProfileParams, UpdateProfileParams, UsernameAvailabilityResponse, XAccountResponse, XAuthUrlResponse, ConnectXResponse } from './ProfileService.js';
|
|
2
|
+
export declare const MOCK_PROFILE_API_RESPONSE: ProfileApiResponse;
|
|
3
|
+
export declare const MOCK_X_CONNECT_RESPONSE: ConnectXResponse;
|
|
4
|
+
export declare const MOCK_X_AUTH_URL_RESPONSE: XAuthUrlResponse;
|
|
5
|
+
export type MockProfileServiceHandlers = {
|
|
6
|
+
getProfile?: (profileId: string) => Promise<ProfileApiResponse>;
|
|
7
|
+
createProfile?: (params: CreateProfileParams) => Promise<CreateProfileResponse>;
|
|
8
|
+
replaceProfile?: (profileId: string, params: ReplaceProfileParams) => Promise<ProfileApiResponse>;
|
|
9
|
+
updateProfile?: (profileId: string, params: UpdateProfileParams) => Promise<ProfileApiResponse>;
|
|
10
|
+
deleteProfile?: (profileId: string) => Promise<void>;
|
|
11
|
+
checkUsernameAvailability?: (username: string) => Promise<UsernameAvailabilityResponse>;
|
|
12
|
+
getXAuthUrl?: () => Promise<XAuthUrlResponse>;
|
|
13
|
+
connectX?: (params: ConnectXParams) => Promise<ConnectXResponse>;
|
|
14
|
+
getXAccount?: () => Promise<XAccountResponse>;
|
|
15
|
+
disconnectX?: (profileId: string) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Registers stub action handlers for all ProfileService methods on the provided messenger.
|
|
19
|
+
* Use this in place of instantiating a real ProfileService when the profile API is unavailable.
|
|
20
|
+
*
|
|
21
|
+
* @param messenger - The ProfileServiceMessenger to register handlers on.
|
|
22
|
+
* @param handlers - Optional per-method overrides. Unspecified methods return fixture data.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildMockProfileService(messenger: ProfileServiceMessenger, handlers?: MockProfileServiceHandlers): void;
|
|
25
|
+
//# sourceMappingURL=ProfileServiceMock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProfileServiceMock.d.ts","sourceRoot":"","sources":["../src/ProfileServiceMock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,yBAAyB,EAAE,kBAiBvC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EA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
display_name: 'Mock User',
|
|
5
|
+
bio: null,
|
|
6
|
+
linked_addresses: [
|
|
7
|
+
'eip155:1:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb',
|
|
8
|
+
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:EEivRh9T4GTLEJprEaKQyjSQzW13JRb5D7jSpvPQ8296',
|
|
9
|
+
'bip122:000000000019d6689c085ae165831e93:128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6',
|
|
10
|
+
'tron:728126428:TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH',
|
|
11
|
+
'stellar:pubnet:GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H',
|
|
12
|
+
],
|
|
13
|
+
avatar_url: 'https://pbs.twimg.com/profile_images/mock.jpg',
|
|
14
|
+
trading_privacy: 'public',
|
|
15
|
+
connected_to_x: true,
|
|
16
|
+
created_at: '2024-01-01T00:00:00.000Z',
|
|
17
|
+
updated_at: '2024-01-01T00:00:00.000Z',
|
|
18
|
+
};
|
|
19
|
+
export const MOCK_X_CONNECT_RESPONSE = {
|
|
20
|
+
x_user_id: 'mock-x-user-id',
|
|
21
|
+
x_profile_url: 'https://x.com/mockuser',
|
|
22
|
+
username: 'mockuser',
|
|
23
|
+
display_name: 'Mock User',
|
|
24
|
+
avatar_url: 'https://pbs.twimg.com/profile_images/mock.jpg',
|
|
25
|
+
created_at: '2024-01-01T00:00:00.000Z',
|
|
26
|
+
updated_at: '2024-01-01T00:00:00.000Z',
|
|
27
|
+
};
|
|
28
|
+
export const MOCK_X_AUTH_URL_RESPONSE = {
|
|
29
|
+
url: 'https://x.com/i/oauth2/authorize?mock=true',
|
|
30
|
+
state: 'mock-oauth-state',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Registers stub action handlers for all ProfileService methods on the provided messenger.
|
|
34
|
+
* Use this in place of instantiating a real ProfileService when the profile API is unavailable.
|
|
35
|
+
*
|
|
36
|
+
* @param messenger - The ProfileServiceMessenger to register handlers on.
|
|
37
|
+
* @param handlers - Optional per-method overrides. Unspecified methods return fixture data.
|
|
38
|
+
*/
|
|
39
|
+
export function buildMockProfileService(messenger, handlers = {}) {
|
|
40
|
+
messenger.registerActionHandler('ProfileService:getProfile', handlers.getProfile ??
|
|
41
|
+
(async (_profileId) => MOCK_PROFILE_API_RESPONSE));
|
|
42
|
+
messenger.registerActionHandler('ProfileService:createProfile', handlers.createProfile ??
|
|
43
|
+
(async (_params) => MOCK_PROFILE_API_RESPONSE));
|
|
44
|
+
messenger.registerActionHandler('ProfileService:replaceProfile', handlers.replaceProfile ??
|
|
45
|
+
(async (_profileId, _params) => MOCK_PROFILE_API_RESPONSE));
|
|
46
|
+
messenger.registerActionHandler('ProfileService:updateProfile', handlers.updateProfile ??
|
|
47
|
+
(async (_profileId, _params) => MOCK_PROFILE_API_RESPONSE));
|
|
48
|
+
messenger.registerActionHandler('ProfileService:deleteProfile', handlers.deleteProfile ?? (async (_profileId) => undefined));
|
|
49
|
+
messenger.registerActionHandler('ProfileService:checkUsernameAvailability', handlers.checkUsernameAvailability ??
|
|
50
|
+
(async (username) => ({
|
|
51
|
+
username,
|
|
52
|
+
available: true,
|
|
53
|
+
valid: true,
|
|
54
|
+
normalized: username,
|
|
55
|
+
errors: [],
|
|
56
|
+
})));
|
|
57
|
+
messenger.registerActionHandler('ProfileService:getXAuthUrl', handlers.getXAuthUrl ??
|
|
58
|
+
(async () => MOCK_X_AUTH_URL_RESPONSE));
|
|
59
|
+
messenger.registerActionHandler('ProfileService:connectX', handlers.connectX ??
|
|
60
|
+
(async (_params) => MOCK_X_CONNECT_RESPONSE));
|
|
61
|
+
messenger.registerActionHandler('ProfileService:getXAccount', handlers.getXAccount ??
|
|
62
|
+
(async () => MOCK_X_CONNECT_RESPONSE));
|
|
63
|
+
messenger.registerActionHandler('ProfileService:disconnectX', handlers.disconnectX ?? (async (_profileId) => undefined));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ProfileServiceMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProfileServiceMock.js","sourceRoot":"","sources":["../src/ProfileServiceMock.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,yBAAyB,GAAuB;IAC3D,UAAU,EAAE,iBAAiB;IAC7B,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,WAAW;IACzB,GAAG,EAAE,IAAI;IACT,gBAAgB,EAAE;QAChB,qDAAqD;QACrD,sFAAsF;QACtF,4EAA4E;QAC5E,mDAAmD;QACnD,yEAAyE;KAC1E;IACD,UAAU,EAAE,+CAA+C;IAC3D,eAAe,EAAE,QAAQ;IACzB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,0BAA0B;IACtC,UAAU,EAAE,0BAA0B;CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACvD,SAAS,EAAE,gBAAgB;IAC3B,aAAa,EAAE,wBAAwB;IACvC,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,WAAW;IACzB,UAAU,EAAE,+CAA+C;IAC3D,UAAU,EAAE,0BAA0B;IACtC,UAAU,EAAE,0BAA0B;CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAqB;IACxD,GAAG,EAAE,4CAA4C;IACjD,KAAK,EAAE,kBAAkB;CAC1B,CAAC;AAyBF;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,SAAkC,EAClC,QAAQ,GAA+B,EAAE;IAEzC,SAAS,CAAC,qBAAqB,CAC7B,2BAA2B,EAC3B,QAAQ,CAAC,UAAU;QACjB,CAAC,KAAK,EAAE,UAAU,EAA+B,EAAE,CACjD,yBAAyB,CAAC,CAC/B,CAAC;IAEF,SAAS,CAAC,qBAAqB,CAC7B,8BAA8B,EAC9B,QAAQ,CAAC,aAAa;QACpB,CAAC,KAAK,EAAE,OAAO,EAAkC,EAAE,CACjD,yBA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CAAC,KAAK,EAAE,UAAU,EAAiB,EAAE,CAAC,SAAS,CAAC,CACzE,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ConnectXParams,\n CreateProfileParams,\n CreateProfileResponse,\n ProfileApiResponse,\n ProfileServiceMessenger,\n ReplaceProfileParams,\n UpdateProfileParams,\n UsernameAvailabilityResponse,\n XAccountResponse,\n XAuthUrlResponse,\n ConnectXResponse,\n} from './ProfileService.js';\n\nexport const MOCK_PROFILE_API_RESPONSE: ProfileApiResponse = {\n profile_id: 'mock-profile-id',\n username: 'mockuser',\n display_name: 'Mock User',\n bio: null,\n linked_addresses: [\n 'eip155:1:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb',\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:EEivRh9T4GTLEJprEaKQyjSQzW13JRb5D7jSpvPQ8296',\n 'bip122:000000000019d6689c085ae165831e93:128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6',\n 'tron:728126428:TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH',\n 'stellar:pubnet:GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H',\n ],\n avatar_url: 'https://pbs.twimg.com/profile_images/mock.jpg',\n trading_privacy: 'public',\n connected_to_x: true,\n created_at: '2024-01-01T00:00:00.000Z',\n updated_at: '2024-01-01T00:00:00.000Z',\n};\n\nexport const MOCK_X_CONNECT_RESPONSE: ConnectXResponse = {\n x_user_id: 'mock-x-user-id',\n x_profile_url: 'https://x.com/mockuser',\n username: 'mockuser',\n display_name: 'Mock User',\n avatar_url: 'https://pbs.twimg.com/profile_images/mock.jpg',\n created_at: '2024-01-01T00:00:00.000Z',\n updated_at: '2024-01-01T00:00:00.000Z',\n};\n\nexport const MOCK_X_AUTH_URL_RESPONSE: XAuthUrlResponse = {\n url: 'https://x.com/i/oauth2/authorize?mock=true',\n state: 'mock-oauth-state',\n};\n\nexport type MockProfileServiceHandlers = {\n getProfile?: (profileId: string) => Promise<ProfileApiResponse>;\n createProfile?: (\n params: CreateProfileParams,\n ) => Promise<CreateProfileResponse>;\n replaceProfile?: (\n profileId: string,\n params: ReplaceProfileParams,\n ) => Promise<ProfileApiResponse>;\n updateProfile?: (\n profileId: string,\n params: UpdateProfileParams,\n ) => Promise<ProfileApiResponse>;\n deleteProfile?: (profileId: string) => Promise<void>;\n checkUsernameAvailability?: (\n username: string,\n ) => Promise<UsernameAvailabilityResponse>;\n getXAuthUrl?: () => Promise<XAuthUrlResponse>;\n connectX?: (params: ConnectXParams) => Promise<ConnectXResponse>;\n getXAccount?: () => Promise<XAccountResponse>;\n disconnectX?: (profileId: string) => Promise<void>;\n};\n\n/**\n * Registers stub action handlers for all ProfileService methods on the provided messenger.\n * Use this in place of instantiating a real ProfileService when the profile API is unavailable.\n *\n * @param messenger - The ProfileServiceMessenger to register handlers on.\n * @param handlers - Optional per-method overrides. Unspecified methods return fixture data.\n */\nexport function buildMockProfileService(\n messenger: ProfileServiceMessenger,\n handlers: MockProfileServiceHandlers = {},\n): void {\n messenger.registerActionHandler(\n 'ProfileService:getProfile',\n handlers.getProfile ??\n (async (_profileId): Promise<ProfileApiResponse> =>\n MOCK_PROFILE_API_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:createProfile',\n handlers.createProfile ??\n (async (_params): Promise<CreateProfileResponse> =>\n MOCK_PROFILE_API_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:replaceProfile',\n handlers.replaceProfile ??\n (async (_profileId, _params): Promise<ProfileApiResponse> =>\n MOCK_PROFILE_API_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:updateProfile',\n handlers.updateProfile ??\n (async (_profileId, _params): Promise<ProfileApiResponse> =>\n MOCK_PROFILE_API_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:deleteProfile',\n handlers.deleteProfile ?? (async (_profileId): Promise<void> => undefined),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:checkUsernameAvailability',\n handlers.checkUsernameAvailability ??\n (async (username): Promise<UsernameAvailabilityResponse> => ({\n username,\n available: true,\n valid: true,\n normalized: username,\n errors: [],\n })),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:getXAuthUrl',\n handlers.getXAuthUrl ??\n (async (): Promise<XAuthUrlResponse> => MOCK_X_AUTH_URL_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:connectX',\n handlers.connectX ??\n (async (_params): Promise<ConnectXResponse> => MOCK_X_CONNECT_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:getXAccount',\n handlers.getXAccount ??\n (async (): Promise<XAccountResponse> => MOCK_X_CONNECT_RESPONSE),\n );\n\n messenger.registerActionHandler(\n 'ProfileService:disconnectX',\n handlers.disconnectX ?? (async (_profileId): Promise<void> => undefined),\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export { ProfileController, getDefaultProfileControllerState, } from './ProfileC
|
|
|
3
3
|
export type { ProfileControllerCheckUsernameAvailabilityAction, ProfileControllerConnectXAction, ProfileControllerCreateProfileAction, ProfileControllerDeleteProfileAction, ProfileControllerDisconnectXAction, ProfileControllerGetProfileAction, ProfileControllerFetchAndUpdateXAccountAction, ProfileControllerFetchAndUpdateProfileAction, ProfileControllerGetXProfileAction, ProfileControllerReplaceProfileAction, ProfileControllerGetXAuthorizationUrlAction, ProfileControllerUpdateProfileAction, } 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
|
+
export type { MockProfileServiceHandlers } from './ProfileServiceMock.js';
|
|
7
|
+
export { buildMockProfileService, MOCK_PROFILE_API_RESPONSE, MOCK_X_CONNECT_RESPONSE, MOCK_X_AUTH_URL_RESPONSE, } from './ProfileServiceMock.js';
|
|
6
8
|
export type { ProfileServiceCheckUsernameAvailabilityAction, ProfileServiceConnectXAction, ProfileServiceCreateProfileAction, ProfileServiceDeleteProfileAction, ProfileServiceDisconnectXAction, ProfileServiceGetProfileAction, ProfileServiceGetXAccountAction, ProfileServiceGetXAuthUrlAction, ProfileServiceReplaceProfileAction, ProfileServiceUpdateProfileAction, } from './ProfileService-method-action-types.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,C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+B,EAC/B,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,yCAAyC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ProfileController, getDefaultProfileControllerState, } from './ProfileController.js';
|
|
2
2
|
export { ProfileService, ProfileServiceErrorMessage, } from './ProfileService.js';
|
|
3
|
+
export { buildMockProfileService, MOCK_PROFILE_API_RESPONSE, MOCK_X_CONNECT_RESPONSE, MOCK_X_AUTH_URL_RESPONSE, } from './ProfileServiceMock.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
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","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 {\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;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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/profile-controller",
|
|
3
|
-
"version": "1.0.1-preview-
|
|
3
|
+
"version": "1.0.1-preview-aa49ca5",
|
|
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",
|