@metamask/profile-sync-controller 0.8.0 → 0.9.0
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 +21 -1
- package/dist/controllers/authentication/services.cjs +1 -1
- package/dist/controllers/authentication/services.cjs.map +1 -1
- package/dist/controllers/authentication/services.mjs +1 -1
- package/dist/controllers/authentication/services.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +35 -9
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +11 -2
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +11 -2
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +36 -10
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +53 -17
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts +31 -5
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +31 -5
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +48 -13
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +15 -3
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts +3 -2
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +3 -2
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +14 -3
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +1 -1
- package/dist/controllers/user-storage/index.cjs +1 -1
- package/dist/controllers/user-storage/index.cjs.map +1 -1
- package/dist/controllers/user-storage/index.d.cts +1 -1
- package/dist/controllers/user-storage/index.d.cts.map +1 -1
- package/dist/controllers/user-storage/index.d.mts +1 -1
- package/dist/controllers/user-storage/index.d.mts.map +1 -1
- package/dist/controllers/user-storage/index.mjs +1 -1
- package/dist/controllers/user-storage/index.mjs.map +1 -1
- package/dist/controllers/user-storage/services.cjs +62 -6
- package/dist/controllers/user-storage/services.cjs.map +1 -1
- package/dist/controllers/user-storage/services.d.cts +11 -2
- package/dist/controllers/user-storage/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/services.d.mts +11 -2
- package/dist/controllers/user-storage/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/services.mjs +35 -3
- package/dist/controllers/user-storage/services.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-auth.cjs +1 -1
- package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-auth.mjs +1 -1
- package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.cjs +6 -4
- package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.mjs +6 -4
- package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.cjs +1 -1
- package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.mjs +1 -1
- package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.cts +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/index.cjs +2 -2
- package/dist/sdk/index.cjs.map +1 -1
- package/dist/sdk/index.d.cts +2 -2
- package/dist/sdk/index.d.cts.map +1 -1
- package/dist/sdk/index.d.mts +2 -2
- package/dist/sdk/index.d.mts.map +1 -1
- package/dist/sdk/index.mjs +2 -2
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +44 -6
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +3 -2
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +3 -2
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +42 -4
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/shared/encryption/cache.cjs.map +1 -0
- package/dist/shared/encryption/cache.d.cts.map +1 -0
- package/dist/shared/encryption/cache.d.mts.map +1 -0
- package/dist/shared/encryption/cache.mjs.map +1 -0
- package/dist/shared/encryption/encryption.cjs.map +1 -0
- package/dist/{controllers/user-storage → shared}/encryption/encryption.d.cts +1 -1
- package/dist/shared/encryption/encryption.d.cts.map +1 -0
- package/dist/{controllers/user-storage → shared}/encryption/encryption.d.mts +1 -1
- package/dist/shared/encryption/encryption.d.mts.map +1 -0
- package/dist/shared/encryption/encryption.mjs.map +1 -0
- package/dist/shared/encryption/index.cjs.map +1 -0
- package/dist/shared/encryption/index.d.cts.map +1 -0
- package/dist/shared/encryption/index.d.mts.map +1 -0
- package/dist/shared/encryption/index.mjs.map +1 -0
- package/dist/shared/encryption/utils.cjs.map +1 -0
- package/dist/shared/encryption/utils.d.cts.map +1 -0
- package/dist/shared/encryption/utils.d.mts.map +1 -0
- package/dist/shared/encryption/utils.mjs.map +1 -0
- package/dist/shared/env.cjs.map +1 -0
- package/dist/shared/env.d.cts.map +1 -0
- package/dist/shared/env.d.mts.map +1 -0
- package/dist/shared/env.mjs.map +1 -0
- package/dist/{controllers/user-storage/schema.cjs → shared/storage-schema.cjs} +1 -1
- package/dist/shared/storage-schema.cjs.map +1 -0
- package/dist/{controllers/user-storage/schema.d.mts → shared/storage-schema.d.cts} +6 -3
- package/dist/shared/storage-schema.d.cts.map +1 -0
- package/dist/{controllers/user-storage/schema.d.cts → shared/storage-schema.d.mts} +6 -3
- package/dist/shared/storage-schema.d.mts.map +1 -0
- package/dist/{controllers/user-storage/schema.mjs → shared/storage-schema.mjs} +1 -1
- package/dist/shared/storage-schema.mjs.map +1 -0
- package/dist/shared/types/encryption.cjs +3 -0
- package/dist/shared/types/encryption.cjs.map +1 -0
- package/dist/shared/types/encryption.d.cts +2 -0
- package/dist/shared/types/encryption.d.cts.map +1 -0
- package/dist/shared/types/encryption.d.mts +2 -0
- package/dist/shared/types/encryption.d.mts.map +1 -0
- package/dist/shared/types/encryption.mjs +2 -0
- package/dist/shared/types/encryption.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/controllers/user-storage/encryption/cache.cjs.map +0 -1
- package/dist/controllers/user-storage/encryption/cache.d.cts.map +0 -1
- package/dist/controllers/user-storage/encryption/cache.d.mts.map +0 -1
- package/dist/controllers/user-storage/encryption/cache.mjs.map +0 -1
- package/dist/controllers/user-storage/encryption/encryption.cjs.map +0 -1
- package/dist/controllers/user-storage/encryption/encryption.d.cts.map +0 -1
- package/dist/controllers/user-storage/encryption/encryption.d.mts.map +0 -1
- package/dist/controllers/user-storage/encryption/encryption.mjs.map +0 -1
- package/dist/controllers/user-storage/encryption/index.cjs.map +0 -1
- package/dist/controllers/user-storage/encryption/index.d.cts.map +0 -1
- package/dist/controllers/user-storage/encryption/index.d.mts.map +0 -1
- package/dist/controllers/user-storage/encryption/index.mjs.map +0 -1
- package/dist/controllers/user-storage/encryption/utils.cjs.map +0 -1
- package/dist/controllers/user-storage/encryption/utils.d.cts.map +0 -1
- package/dist/controllers/user-storage/encryption/utils.d.mts.map +0 -1
- package/dist/controllers/user-storage/encryption/utils.mjs.map +0 -1
- package/dist/controllers/user-storage/schema.cjs.map +0 -1
- package/dist/controllers/user-storage/schema.d.cts.map +0 -1
- package/dist/controllers/user-storage/schema.d.mts.map +0 -1
- package/dist/controllers/user-storage/schema.mjs.map +0 -1
- package/dist/sdk/encryption.cjs +0 -23
- package/dist/sdk/encryption.cjs.map +0 -1
- package/dist/sdk/encryption.d.cts +0 -4
- package/dist/sdk/encryption.d.cts.map +0 -1
- package/dist/sdk/encryption.d.mts +0 -4
- package/dist/sdk/encryption.d.mts.map +0 -1
- package/dist/sdk/encryption.mjs +0 -4
- package/dist/sdk/encryption.mjs.map +0 -1
- package/dist/sdk/env.cjs.map +0 -1
- package/dist/sdk/env.d.cts.map +0 -1
- package/dist/sdk/env.d.mts.map +0 -1
- package/dist/sdk/env.mjs.map +0 -1
- /package/dist/{controllers/user-storage → shared}/encryption/cache.cjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/cache.d.cts +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/cache.d.mts +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/cache.mjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/encryption.cjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/encryption.mjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/index.cjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/index.d.cts +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/index.d.mts +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/index.mjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/utils.cjs +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/utils.d.cts +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/utils.d.mts +0 -0
- /package/dist/{controllers/user-storage → shared}/encryption/utils.mjs +0 -0
- /package/dist/{sdk → shared}/env.cjs +0 -0
- /package/dist/{sdk → shared}/env.d.cts +0 -0
- /package/dist/{sdk → shared}/env.d.mts +0 -0
- /package/dist/{sdk → shared}/env.mjs +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- add batch PUT endpoint for account syncing ([#4724](https://github.com/MetaMask/core/pull/4724))
|
|
15
|
+
- add batch PUT endpoint support ([#4723](https://github.com/MetaMask/core/pull/4723))
|
|
16
|
+
|
|
17
|
+
## [0.8.1]
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- move and organize shared profile sync dependencies ([#4717](https://github.com/MetaMask/core/pull/4717))
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- fix: profile-sync-controller mobile compilation issues ([#4721](https://github.com/MetaMask/core/pull/4721))
|
|
26
|
+
- mobile does not support exported async arrow functions, so needed to convert these into normal async functions
|
|
27
|
+
|
|
10
28
|
## [0.8.0]
|
|
11
29
|
|
|
12
30
|
### Fixed
|
|
@@ -204,7 +222,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
204
222
|
|
|
205
223
|
- Initial release
|
|
206
224
|
|
|
207
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.
|
|
225
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.9.0...HEAD
|
|
226
|
+
[0.9.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.8.1...@metamask/profile-sync-controller@0.9.0
|
|
227
|
+
[0.8.1]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.8.0...@metamask/profile-sync-controller@0.8.1
|
|
208
228
|
[0.8.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.7.0...@metamask/profile-sync-controller@0.8.0
|
|
209
229
|
[0.7.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.6.0...@metamask/profile-sync-controller@0.7.0
|
|
210
230
|
[0.6.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.5.0...@metamask/profile-sync-controller@0.6.0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLoginRawMessage = exports.getAccessToken = exports.login = exports.getNonce = exports.OIDC_TOKENS_ENDPOINT = exports.AUTH_LOGIN_ENDPOINT = exports.AUTH_NONCE_ENDPOINT = void 0;
|
|
4
|
-
const env_1 = require("../../
|
|
4
|
+
const env_1 = require("../../shared/env.cjs");
|
|
5
5
|
const ENV_URLS = (0, env_1.getEnvUrls)(env_1.Env.PRD);
|
|
6
6
|
const AUTH_ENDPOINT = ENV_URLS.authApiUrl;
|
|
7
7
|
exports.AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/services.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/services.ts"],"names":[],"mappings":";;;AAAA,8CAA8E;AAE9E,MAAM,QAAQ,GAAG,IAAA,gBAAU,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAErC,MAAM,aAAa,GAAW,QAAQ,CAAC,UAAU,CAAC;AACrC,QAAA,mBAAmB,GAAG,GAAG,aAAa,eAAe,CAAC;AACtD,QAAA,mBAAmB,GAAG,GAAG,aAAa,mBAAmB,CAAC;AAEvE,MAAM,aAAa,GAAW,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;AAC3C,QAAA,oBAAoB,GAAG,GAAG,aAAa,eAAe,CAAC;AACpE,MAAM,cAAc,GAAG,CAAC,QAAgC,EAAE,EAAE;IAC1D,IAAI,QAAQ,KAAK,WAAW,EAAE;QAC5B,OAAO,IAAA,qBAAe,EAAC,SAAG,CAAC,GAAG,EAAE,cAAQ,CAAC,SAAS,CAAC,CAAC;KACrD;IACD,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,OAAO,IAAA,qBAAe,EAAC,SAAG,CAAC,GAAG,EAAE,cAAQ,CAAC,MAAM,CAAC,CAAC;KACl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qB,CACnC,KAAa,EACb,SAAiB;IAEjB,OAAO,YAAY,KAAK,IAAI,SAAS,EAAW,CAAC;AACnD,CAAC;AALD,sDAKC","sourcesContent":["import { Env, Platform, getEnvUrls, getOidcClientId } from '../../shared/env';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nconst AUTH_ENDPOINT: string = ENV_URLS.authApiUrl;\nexport const AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;\nexport const AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;\n\nconst OIDC_ENDPOINT: string = ENV_URLS.oidcApiUrl || '';\nexport const OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;\nconst OIDC_CLIENT_ID = (platform: 'mobile' | 'extension') => {\n if (platform === 'extension') {\n return getOidcClientId(Env.PRD, Platform.EXTENSION);\n }\n if (platform === 'mobile') {\n return getOidcClientId(Env.PRD, Platform.MOBILE);\n }\n\n throw new Error(`Unsupported platform - ${platform as string}`);\n};\nconst OIDC_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n\nexport type NonceResponse = {\n nonce: string;\n};\n\n/**\n * Auth Service - Get Nonce. Used for the initial JWTBearer flow\n *\n * @param publicKey - public key to associate a nonce with\n * @returns the nonce or null if failed\n */\nexport async function getNonce(publicKey: string): Promise<string | null> {\n const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);\n nonceUrl.searchParams.set('identifier', publicKey);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n return null;\n }\n\n const nonceJson: NonceResponse = await nonceResponse.json();\n return nonceJson?.nonce ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to get nonce', e);\n return null;\n }\n}\n\n/**\n * The Login API Server Response Shape\n */\nexport type LoginResponse = {\n token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: string;\n /**\n * Contains anonymous information about the logged in profile.\n *\n * @property identifier_id - a deterministic unique identifier on the method used to sign in\n * @property profile_id - a unique id for a given profile\n * @property metametrics_id - an anonymous server id\n */\n profile: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: string;\n };\n};\n\ntype ClientMetaMetrics = {\n metametricsId: string;\n agent: 'extension' | 'mobile';\n};\n\n/**\n * Auth Service - Login. Will perform login with a given signature and will return a single use JWT Token.\n *\n * @param rawMessage - the original message before signing\n * @param signature - the signed message\n * @param clientMetaMetrics - optional client metametrics id (to associate on backend)\n * @returns The Login Response\n */\nexport async function login(\n rawMessage: string,\n signature: string,\n clientMetaMetrics: ClientMetaMetrics,\n): Promise<LoginResponse | null> {\n try {\n const response = await fetch(AUTH_LOGIN_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: rawMessage,\n metametrics: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: clientMetaMetrics.metametricsId,\n agent: clientMetaMetrics.agent,\n },\n }),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const loginResponse: LoginResponse = await response.json();\n return loginResponse ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to login', e);\n return null;\n }\n}\n\n/**\n * The Auth API Token Response Shape\n */\nexport type OAuthTokenResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n access_token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: number;\n};\n\n/**\n * OIDC Service - Access Token. Trades the Auth Token for an access token (to be used for other authenticated endpoints)\n * NOTE - the access token is short lived, which means it is best practice to validate session before calling authenticated endpoints\n *\n * @param jwtToken - the JWT Auth Token, received from `/login`\n * @param platform - the OIDC platform to retrieve access token\n * @returns JWT Access token to store and use on authorized endpoints.\n */\nexport async function getAccessToken(\n jwtToken: string,\n platform: ClientMetaMetrics['agent'],\n): Promise<string | null> {\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', OIDC_GRANT_TYPE);\n urlEncodedBody.append('client_id', OIDC_CLIENT_ID(platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKENS_ENDPOINT, {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const accessTokenResponse: OAuthTokenResponse = await response.json();\n return accessTokenResponse?.access_token ?? null;\n } catch (e) {\n console.error(\n 'authentication-controller/services: unable to get access token',\n e,\n );\n return null;\n }\n}\n\n/**\n * Utility to create the raw login message for the JWT bearer flow (via SRP)\n *\n * @param nonce - nonce received from `/nonce` endpoint\n * @param publicKey - public key used to retrieve nonce and for message signing\n * @returns Raw Message which will be used for signing & logging in.\n */\nexport function createLoginRawMessage(\n nonce: string,\n publicKey: string,\n): `metamask:${string}:${string}` {\n return `metamask:${nonce}:${publicKey}` as const;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Env, Platform, getEnvUrls, getOidcClientId } from "../../
|
|
1
|
+
import { Env, Platform, getEnvUrls, getOidcClientId } from "../../shared/env.mjs";
|
|
2
2
|
const ENV_URLS = getEnvUrls(Env.PRD);
|
|
3
3
|
const AUTH_ENDPOINT = ENV_URLS.authApiUrl;
|
|
4
4
|
export const AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAA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cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IACrD,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAE7C,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,OAAO;YACP,IAAI,EAAE,cAAc,CAAC,QAAQ,EAAE;SAChC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;YAChB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,mBAAmB,GAAuB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtE,OAAO,mBAAmB,EAAE,YAAY,IAAI,IAAI,CAAC;KAClD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CACX,gEAAgE,EAChE,CAAC,CACF,CAAC;QACF,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAa,EACb,SAAiB;IAEjB,OAAO,YAAY,KAAK,IAAI,SAAS,EAAW,CAAC;AACnD,CAAC","sourcesContent":["import { Env, Platform, getEnvUrls, getOidcClientId } from '../../shared/env';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nconst AUTH_ENDPOINT: string = ENV_URLS.authApiUrl;\nexport const AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;\nexport const AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;\n\nconst OIDC_ENDPOINT: string = ENV_URLS.oidcApiUrl || '';\nexport const OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;\nconst OIDC_CLIENT_ID = (platform: 'mobile' | 'extension') => {\n if (platform === 'extension') {\n return getOidcClientId(Env.PRD, Platform.EXTENSION);\n }\n if (platform === 'mobile') {\n return getOidcClientId(Env.PRD, Platform.MOBILE);\n }\n\n throw new Error(`Unsupported platform - ${platform as string}`);\n};\nconst OIDC_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n\nexport type NonceResponse = {\n nonce: string;\n};\n\n/**\n * Auth Service - Get Nonce. Used for the initial JWTBearer flow\n *\n * @param publicKey - public key to associate a nonce with\n * @returns the nonce or null if failed\n */\nexport async function getNonce(publicKey: string): Promise<string | null> {\n const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);\n nonceUrl.searchParams.set('identifier', publicKey);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n return null;\n }\n\n const nonceJson: NonceResponse = await nonceResponse.json();\n return nonceJson?.nonce ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to get nonce', e);\n return null;\n }\n}\n\n/**\n * The Login API Server Response Shape\n */\nexport type LoginResponse = {\n token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: string;\n /**\n * Contains anonymous information about the logged in profile.\n *\n * @property identifier_id - a deterministic unique identifier on the method used to sign in\n * @property profile_id - a unique id for a given profile\n * @property metametrics_id - an anonymous server id\n */\n profile: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: string;\n };\n};\n\ntype ClientMetaMetrics = {\n metametricsId: string;\n agent: 'extension' | 'mobile';\n};\n\n/**\n * Auth Service - Login. Will perform login with a given signature and will return a single use JWT Token.\n *\n * @param rawMessage - the original message before signing\n * @param signature - the signed message\n * @param clientMetaMetrics - optional client metametrics id (to associate on backend)\n * @returns The Login Response\n */\nexport async function login(\n rawMessage: string,\n signature: string,\n clientMetaMetrics: ClientMetaMetrics,\n): Promise<LoginResponse | null> {\n try {\n const response = await fetch(AUTH_LOGIN_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: rawMessage,\n metametrics: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: clientMetaMetrics.metametricsId,\n agent: clientMetaMetrics.agent,\n },\n }),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const loginResponse: LoginResponse = await response.json();\n return loginResponse ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to login', e);\n return null;\n }\n}\n\n/**\n * The Auth API Token Response Shape\n */\nexport type OAuthTokenResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n access_token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: number;\n};\n\n/**\n * OIDC Service - Access Token. Trades the Auth Token for an access token (to be used for other authenticated endpoints)\n * NOTE - the access token is short lived, which means it is best practice to validate session before calling authenticated endpoints\n *\n * @param jwtToken - the JWT Auth Token, received from `/login`\n * @param platform - the OIDC platform to retrieve access token\n * @returns JWT Access token to store and use on authorized endpoints.\n */\nexport async function getAccessToken(\n jwtToken: string,\n platform: ClientMetaMetrics['agent'],\n): Promise<string | null> {\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', OIDC_GRANT_TYPE);\n urlEncodedBody.append('client_id', OIDC_CLIENT_ID(platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKENS_ENDPOINT, {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const accessTokenResponse: OAuthTokenResponse = await response.json();\n return accessTokenResponse?.access_token ?? null;\n } catch (e) {\n console.error(\n 'authentication-controller/services: unable to get access token',\n e,\n );\n return null;\n }\n}\n\n/**\n * Utility to create the raw login message for the JWT bearer flow (via SRP)\n *\n * @param nonce - nonce received from `/nonce` endpoint\n * @param publicKey - public key used to retrieve nonce and for message signing\n * @returns Raw Message which will be used for signing & logging in.\n */\nexport function createLoginRawMessage(\n nonce: string,\n publicKey: string,\n): `metamask:${string}:${string}` {\n return `metamask:${nonce}:${publicKey}` as const;\n}\n"]}
|
|
@@ -14,9 +14,9 @@ var _UserStorageController_instances, _UserStorageController_auth, _UserStorageC
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.defaultState = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
+
const encryption_1 = require("../../shared/encryption/index.cjs");
|
|
17
18
|
const auth_snap_requests_1 = require("../authentication/auth-snap-requests.cjs");
|
|
18
19
|
const user_storage_1 = require("./accounts/user-storage.cjs");
|
|
19
|
-
const encryption_1 = require("./encryption/index.cjs");
|
|
20
20
|
const controller_integration_1 = require("./network-syncing/controller-integration.cjs");
|
|
21
21
|
const services_1 = require("./services.cjs");
|
|
22
22
|
const controllerName = 'UserStorageController';
|
|
@@ -119,10 +119,11 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
119
119
|
if (!internalAccountsList) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
await
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
const internalAccountsListFormattedForUserStorage = internalAccountsList.map(user_storage_1.mapInternalAccountToUserStorageAccount);
|
|
123
|
+
await this.performBatchSetStorage('accounts', internalAccountsListFormattedForUserStorage.map((account) => [
|
|
124
|
+
account.a,
|
|
125
|
+
JSON.stringify(account),
|
|
126
|
+
]));
|
|
126
127
|
},
|
|
127
128
|
});
|
|
128
129
|
_UserStorageController_config.set(this, void 0);
|
|
@@ -274,6 +275,24 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
274
275
|
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
275
276
|
});
|
|
276
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Allows storage of multiple user data entries for one specific feature. Data stored must be string formatted.
|
|
280
|
+
* Developers can extend the entry path through the `schema.ts` file.
|
|
281
|
+
*
|
|
282
|
+
* @param path - string in the form of `${feature}` that matches schema
|
|
283
|
+
* @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs
|
|
284
|
+
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
285
|
+
*/
|
|
286
|
+
async performBatchSetStorage(path, values) {
|
|
287
|
+
__classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_assertProfileSyncingEnabled).call(this);
|
|
288
|
+
const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
|
|
289
|
+
await (0, services_1.batchUpsertUserStorage)(values, {
|
|
290
|
+
path,
|
|
291
|
+
bearerToken,
|
|
292
|
+
storageKey,
|
|
293
|
+
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
277
296
|
/**
|
|
278
297
|
* Retrieves the storage key, for internal use only!
|
|
279
298
|
*
|
|
@@ -301,6 +320,8 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
301
320
|
await __classPrivateFieldGet(this, _UserStorageController_accounts, "f").saveInternalAccountsListToUserStorage();
|
|
302
321
|
return;
|
|
303
322
|
}
|
|
323
|
+
// Prepare an array of internal accounts to be saved to the user storage
|
|
324
|
+
const internalAccountsToBeSavedToUserStorage = [];
|
|
304
325
|
// Compare internal accounts list with user storage accounts list
|
|
305
326
|
// First step: compare lengths
|
|
306
327
|
let internalAccountsList = await __classPrivateFieldGet(this, _UserStorageController_accounts, "f").getInternalAccountsList();
|
|
@@ -327,7 +348,7 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
327
348
|
for await (const internalAccount of internalAccountsList) {
|
|
328
349
|
const userStorageAccount = userStorageAccountsList.find((account) => account.a === internalAccount.address);
|
|
329
350
|
if (!userStorageAccount) {
|
|
330
|
-
|
|
351
|
+
internalAccountsToBeSavedToUserStorage.push(internalAccount);
|
|
331
352
|
continue;
|
|
332
353
|
}
|
|
333
354
|
// One or both accounts have default names
|
|
@@ -345,7 +366,7 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
345
366
|
}
|
|
346
367
|
// Internal account has custom name but user storage account has default name
|
|
347
368
|
if (isUserStorageAccountNameDefault) {
|
|
348
|
-
|
|
369
|
+
internalAccountsToBeSavedToUserStorage.push(internalAccount);
|
|
349
370
|
continue;
|
|
350
371
|
}
|
|
351
372
|
// Both accounts have custom names
|
|
@@ -356,7 +377,7 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
356
377
|
const isInternalAccountNameNewer = internalAccount.metadata.nameLastUpdatedAt >
|
|
357
378
|
userStorageAccount.nlu;
|
|
358
379
|
if (isInternalAccountNameNewer) {
|
|
359
|
-
|
|
380
|
+
internalAccountsToBeSavedToUserStorage.push(internalAccount);
|
|
360
381
|
continue;
|
|
361
382
|
}
|
|
362
383
|
}
|
|
@@ -368,10 +389,15 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
368
389
|
continue;
|
|
369
390
|
}
|
|
370
391
|
else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {
|
|
371
|
-
|
|
392
|
+
internalAccountsToBeSavedToUserStorage.push(internalAccount);
|
|
372
393
|
continue;
|
|
373
394
|
}
|
|
374
395
|
}
|
|
396
|
+
// Save the internal accounts list to the user storage
|
|
397
|
+
await this.performBatchSetStorage('accounts', internalAccountsToBeSavedToUserStorage.map((account) => [
|
|
398
|
+
account.address,
|
|
399
|
+
JSON.stringify((0, user_storage_1.mapInternalAccountToUserStorageAccount)(account)),
|
|
400
|
+
]));
|
|
375
401
|
}
|
|
376
402
|
catch (e) {
|
|
377
403
|
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserStorageController.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController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CAAC,eAAe,CAAC,IAAI,CAC7C,8BAA8B,EAC9B,IAAA,iDAA4B,EAAC,OAAO,CAAC,CACtC,CAAW,CAAC;IAEb,uBAAA,IAAI,oDAAuB,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IAE9C,OAAO,MAAM,CAAC;AAChB,CAAC,6HAGC,6BAAsC;IAEtC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACpB,KAAK,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC;kBAtekB,qBAAqB","sourcesContent":["import type {\n AccountsControllerListAccountsAction,\n AccountsControllerUpdateAccountMetadataAction,\n AccountsControllerAccountRenamedEvent,\n AccountsControllerAccountAddedEvent,\n} from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedControllerMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { InternalAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n KeyringControllerAddNewAccountAction,\n} from '@metamask/keyring-controller';\nimport type { NetworkConfiguration } from '@metamask/network-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport { createSnapSignMessageRequest } from '../authentication/auth-snap-requests';\nimport type {\n AuthenticationControllerGetBearerToken,\n AuthenticationControllerGetSessionProfile,\n AuthenticationControllerIsSignedIn,\n AuthenticationControllerPerformSignIn,\n AuthenticationControllerPerformSignOut,\n} from '../authentication/AuthenticationController';\nimport type { UserStorageAccount } from './accounts/user-storage';\nimport {\n isNameDefaultAccountName,\n mapInternalAccountToUserStorageAccount,\n} from './accounts/user-storage';\nimport { createSHA256Hash } from './encryption';\nimport { startNetworkSyncing } from './network-syncing/controller-integration';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from './schema';\nimport {\n getUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from './services';\n\n// TODO: add external NetworkController event\n// Need to listen for when a network gets added\ntype NetworkControllerNetworkAddedEvent = {\n type: 'NetworkController:networkAdded';\n payload: [networkConfiguration: NetworkConfiguration];\n};\n\n// TODO: add external NetworkController event\n// Need to listen for when a network is updated, or the default rpc/block explorer changes\ntype NetworkControllerNetworkChangedEvent = {\n type: 'NetworkController:networkChanged';\n payload: [networkConfiguration: NetworkConfiguration];\n};\n\n// TODO: add external NetworkController event\n// Need to listen for when a network gets deleted\ntype NetworkControllerNetworkDeletedEvent = {\n type: 'NetworkController:networkDeleted';\n payload: [networkConfiguration: NetworkConfiguration];\n};\n\n// TODO: fix external dependencies\nexport declare type NotificationServicesControllerDisableNotificationServices =\n {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: () => Promise<void>;\n };\n\nexport declare type NotificationServicesControllerSelectIsNotificationServicesEnabled =\n {\n type: `NotificationServicesController:selectIsNotificationServicesEnabled`;\n handler: () => boolean;\n };\n\nexport declare type NativeScrypt = (\n passwd: string,\n salt: Uint8Array,\n N: number,\n r: number,\n p: number,\n size: number,\n) => Promise<Uint8Array>;\n\nconst controllerName = 'UserStorageController';\n\n// State\nexport type UserStorageControllerState = {\n /**\n * Condition used by UI and to determine if we can use some of the User Storage methods.\n */\n isProfileSyncingEnabled: boolean | null;\n /**\n * Loading state for the profile syncing update\n */\n isProfileSyncingUpdateLoading: boolean;\n};\n\nexport const defaultState: UserStorageControllerState = {\n isProfileSyncingEnabled: true,\n isProfileSyncingUpdateLoading: false,\n};\n\nconst metadata: StateMetadata<UserStorageControllerState> = {\n isProfileSyncingEnabled: {\n persist: true,\n anonymous: true,\n },\n isProfileSyncingUpdateLoading: {\n persist: false,\n anonymous: false,\n },\n};\n\ntype ControllerConfig = {\n accountSyncing?: {\n /**\n * Callback that fires when account sync adds an account.\n * This is used for analytics.\n */\n onAccountAdded?: (profileId: string) => void;\n\n /**\n * Callback that fires when account sync updates the name of an account.\n * This is used for analytics.\n */\n onAccountNameUpdated?: (profileId: string) => void;\n };\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof UserStorageController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: UserStorageController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performGetStorage'\n | 'performGetStorageAllFeatureEntries'\n | 'performSetStorage'\n | 'getStorageKey'\n | 'enableProfileSyncing'\n | 'disableProfileSyncing'\n | 'syncInternalAccountsWithUserStorage'\n | 'saveInternalAccountToUserStorage'\n>;\nexport type UserStorageControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | UserStorageControllerGetStateAction;\nexport type UserStorageControllerPerformGetStorage =\n ActionsObj['performGetStorage'];\nexport type UserStorageControllerPerformGetStorageAllFeatureEntries =\n ActionsObj['performGetStorageAllFeatureEntries'];\nexport type UserStorageControllerPerformSetStorage =\n ActionsObj['performSetStorage'];\nexport type UserStorageControllerGetStorageKey = ActionsObj['getStorageKey'];\nexport type UserStorageControllerEnableProfileSyncing =\n ActionsObj['enableProfileSyncing'];\nexport type UserStorageControllerDisableProfileSyncing =\n ActionsObj['disableProfileSyncing'];\nexport type UserStorageControllerSyncInternalAccountsWithUserStorage =\n ActionsObj['syncInternalAccountsWithUserStorage'];\nexport type UserStorageControllerSaveInternalAccountToUserStorage =\n ActionsObj['saveInternalAccountToUserStorage'];\n\nexport type AllowedActions =\n // Keyring Requests\n | KeyringControllerGetStateAction\n // Snap Requests\n | HandleSnapRequest\n // Auth Requests\n | AuthenticationControllerGetBearerToken\n | AuthenticationControllerGetSessionProfile\n | AuthenticationControllerPerformSignIn\n | AuthenticationControllerIsSignedIn\n | AuthenticationControllerPerformSignOut\n // Metamask Notifications\n | NotificationServicesControllerDisableNotificationServices\n | NotificationServicesControllerSelectIsNotificationServicesEnabled\n // Account syncing\n | AccountsControllerListAccountsAction\n | AccountsControllerUpdateAccountMetadataAction\n | KeyringControllerAddNewAccountAction;\n\n// Messenger events\nexport type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type UserStorageControllerAccountSyncingInProgress = {\n type: `${typeof controllerName}:accountSyncingInProgress`;\n payload: [boolean];\n};\nexport type UserStorageControllerAccountSyncingComplete = {\n type: `${typeof controllerName}:accountSyncingComplete`;\n payload: [boolean];\n};\nexport type Events =\n | UserStorageControllerStateChangeEvent\n | UserStorageControllerAccountSyncingInProgress\n | UserStorageControllerAccountSyncingComplete;\n\nexport type AllowedEvents =\n | UserStorageControllerStateChangeEvent\n | UserStorageControllerAccountSyncingInProgress\n | UserStorageControllerAccountSyncingComplete\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n // Account Syncing Events\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRenamedEvent\n // Network Syncing Events\n | NetworkControllerNetworkAddedEvent\n | NetworkControllerNetworkChangedEvent\n | NetworkControllerNetworkDeletedEvent;\n\n// Messenger\nexport type UserStorageControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Reusable controller that allows any team to store synchronized data for a given user.\n * These can be settings shared cross MetaMask clients, or data we want to persist when uninstalling/reinstalling.\n *\n * NOTE:\n * - data stored on UserStorage is FULLY encrypted, with the only keys stored/managed on the client.\n * - No one can access this data unless they are have the SRP and are able to run the signing snap.\n */\nexport default class UserStorageController extends BaseController<\n typeof controllerName,\n UserStorageControllerState,\n UserStorageControllerMessenger\n> {\n #auth = {\n getBearerToken: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n },\n getProfileId: async () => {\n const sessionProfile = await this.messagingSystem.call(\n 'AuthenticationController:getSessionProfile',\n );\n return sessionProfile?.profileId;\n },\n isAuthEnabled: () => {\n return this.messagingSystem.call('AuthenticationController:isSignedIn');\n },\n signIn: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:performSignIn',\n );\n },\n signOut: async () => {\n return this.messagingSystem.call(\n 'AuthenticationController:performSignOut',\n );\n },\n };\n\n #accounts = {\n // This is replaced with the actual value in the constructor\n // We will remove this once the feature will be released\n isAccountSyncingEnabled: false,\n isAccountSyncingInProgress: false,\n canSync: () => {\n try {\n this.#assertProfileSyncingEnabled();\n\n return (\n this.#accounts.isAccountSyncingEnabled && this.#auth.isAuthEnabled()\n );\n } catch {\n return false;\n }\n },\n setupAccountSyncingSubscriptions: () => {\n this.messagingSystem.subscribe(\n 'AccountsController:accountAdded',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (this.#accounts.isAccountSyncingInProgress) {\n return;\n }\n await this.saveInternalAccountToUserStorage(account);\n },\n );\n\n this.messagingSystem.subscribe(\n 'AccountsController:accountRenamed',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (this.#accounts.isAccountSyncingInProgress) {\n return;\n }\n await this.saveInternalAccountToUserStorage(account);\n },\n );\n },\n getInternalAccountsList: async (): Promise<InternalAccount[]> => {\n return this.messagingSystem.call('AccountsController:listAccounts');\n },\n getUserStorageAccountsList: async (): Promise<\n UserStorageAccount[] | null\n > => {\n const rawAccountsListResponse =\n await this.performGetStorageAllFeatureEntries('accounts');\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ??\n null\n );\n },\n saveInternalAccountToUserStorage: async (\n internalAccount: InternalAccount,\n ) => {\n // Map the internal account to the user storage account schema\n const mappedAccount =\n mapInternalAccountToUserStorageAccount(internalAccount);\n\n await this.performSetStorage(\n `accounts.${internalAccount.address}`,\n JSON.stringify(mappedAccount),\n );\n },\n saveInternalAccountsListToUserStorage: async () => {\n const internalAccountsList =\n await this.#accounts.getInternalAccountsList();\n\n if (!internalAccountsList) {\n return;\n }\n\n const userStorageAccountsList = internalAccountsList.map(\n mapInternalAccountToUserStorageAccount,\n );\n\n await Promise.all(\n userStorageAccountsList.map(async (userStorageAccount) => {\n await this.performSetStorage(\n `accounts.${userStorageAccount.a}`,\n JSON.stringify(userStorageAccount),\n );\n }),\n );\n },\n };\n\n #config?: ControllerConfig;\n\n #notificationServices = {\n disableNotificationServices: async () => {\n return await this.messagingSystem.call(\n 'NotificationServicesController:disableNotificationServices',\n );\n },\n selectIsNotificationServicesEnabled: async () => {\n return this.messagingSystem.call(\n 'NotificationServicesController:selectIsNotificationServicesEnabled',\n );\n },\n };\n\n #isUnlocked = false;\n\n #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n #nativeScryptCrypto: NativeScrypt | undefined = undefined;\n\n getMetaMetricsState: () => boolean;\n\n constructor({\n messenger,\n state,\n env,\n config,\n getMetaMetricsState,\n nativeScryptCrypto,\n }: {\n messenger: UserStorageControllerMessenger;\n state?: UserStorageControllerState;\n config?: ControllerConfig;\n env?: {\n isAccountSyncingEnabled?: boolean;\n isNetworkSyncingEnabled?: boolean;\n };\n getMetaMetricsState: () => boolean;\n nativeScryptCrypto?: NativeScrypt;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#config = config;\n\n this.#accounts.isAccountSyncingEnabled = Boolean(\n env?.isAccountSyncingEnabled,\n );\n\n this.getMetaMetricsState = getMetaMetricsState;\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n this.#nativeScryptCrypto = nativeScryptCrypto;\n this.#accounts.setupAccountSyncingSubscriptions();\n\n // Network Syncing\n if (env?.isNetworkSyncingEnabled) {\n startNetworkSyncing({\n messenger,\n getStorageConfig: async () => {\n const { storageKey, bearerToken } =\n await this.#getStorageKeyAndBearerToken();\n return {\n storageKey,\n bearerToken,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n };\n },\n });\n }\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorage',\n this.performGetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n this.performGetStorageAllFeatureEntries.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performSetStorage',\n this.performSetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:getStorageKey',\n this.getStorageKey.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:enableProfileSyncing',\n this.enableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:disableProfileSyncing',\n this.disableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:syncInternalAccountsWithUserStorage',\n this.syncInternalAccountsWithUserStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:saveInternalAccountToUserStorage',\n this.saveInternalAccountToUserStorage.bind(this),\n );\n }\n\n public async enableProfileSyncing(): Promise<void> {\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n const authEnabled = this.#auth.isAuthEnabled();\n if (!authEnabled) {\n await this.#auth.signIn();\n }\n\n this.update((state) => {\n state.isProfileSyncingEnabled = true;\n });\n\n this.#setIsProfileSyncingUpdateLoading(false);\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to enable profile syncing - ${errorMessage}`,\n );\n }\n }\n\n public async setIsProfileSyncingEnabled(\n isProfileSyncingEnabled: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isProfileSyncingEnabled = isProfileSyncingEnabled;\n });\n }\n\n public async disableProfileSyncing(): Promise<void> {\n const isAlreadyDisabled = !this.state.isProfileSyncingEnabled;\n if (isAlreadyDisabled) {\n return;\n }\n\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n const isNotificationServicesEnabled =\n await this.#notificationServices.selectIsNotificationServicesEnabled();\n\n if (isNotificationServicesEnabled) {\n await this.#notificationServices.disableNotificationServices();\n }\n\n const isMetaMetricsParticipation = this.getMetaMetricsState();\n\n if (!isMetaMetricsParticipation) {\n await this.#auth.signOut();\n }\n\n this.#setIsProfileSyncingUpdateLoading(false);\n\n this.update((state) => {\n state.isProfileSyncingEnabled = false;\n });\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to disable profile syncing - ${errorMessage}`,\n );\n }\n }\n\n /**\n * Allows retrieval of stored data. Data stored is string formatted.\n * Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @returns the decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorage(\n path: UserStoragePathWithFeatureAndKey,\n ): Promise<string | null> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n const result = await getUserStorage({\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n\n return result;\n }\n\n /**\n * Allows retrieval of all stored data for a specific feature. Data stored is formatted as an array of strings.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @returns the array of decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorageAllFeatureEntries(\n path: UserStoragePathWithFeatureOnly,\n ): Promise<string[] | null> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n const result = await getUserStorageAllFeatureEntries({\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n\n return result;\n }\n\n /**\n * Allows storage of user data. Data stored must be string formatted.\n * Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param value - The string data you want to store.\n * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performSetStorage(\n path: UserStoragePathWithFeatureAndKey,\n value: string,\n ): Promise<void> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await upsertUserStorage(value, {\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n }\n\n /**\n * Retrieves the storage key, for internal use only!\n *\n * @returns the storage key\n */\n public async getStorageKey(): Promise<string> {\n this.#assertProfileSyncingEnabled();\n const storageKey = await this.#createStorageKey();\n return storageKey;\n }\n\n #assertProfileSyncingEnabled(): void {\n if (!this.state.isProfileSyncingEnabled) {\n throw new Error(\n `${controllerName}: Unable to call method, user is not authenticated`,\n );\n }\n }\n\n /**\n * Utility to get the bearer token and storage key\n */\n async #getStorageKeyAndBearerToken(): Promise<{\n bearerToken: string;\n storageKey: string;\n }> {\n const bearerToken = await this.#auth.getBearerToken();\n if (!bearerToken) {\n throw new Error('UserStorageController - unable to get bearer token');\n }\n const storageKey = await this.#createStorageKey();\n\n return { bearerToken, storageKey };\n }\n\n /**\n * Rather than storing the storage key, we can compute the storage key when needed.\n *\n * @returns the storage key\n */\n async #createStorageKey(): Promise<string> {\n const id: string = await this.#auth.getProfileId();\n if (!id) {\n throw new Error('UserStorageController - unable to create storage key');\n }\n\n const storageKeySignature = await this.#snapSignMessage(`metamask:${id}`);\n const storageKey = createSHA256Hash(storageKeySignature);\n return storageKey;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapSignMessage - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n\n #setIsProfileSyncingUpdateLoading(\n isProfileSyncingUpdateLoading: boolean,\n ): void {\n this.update((state) => {\n state.isProfileSyncingUpdateLoading = isProfileSyncingUpdateLoading;\n });\n }\n\n /**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n */\n async syncInternalAccountsWithUserStorage(): Promise<void> {\n if (!this.#accounts.canSync()) {\n return;\n }\n\n try {\n this.#accounts.isAccountSyncingInProgress = true;\n\n const profileId = await this.#auth.getProfileId();\n\n const userStorageAccountsList =\n await this.#accounts.getUserStorageAccountsList();\n\n if (!userStorageAccountsList || !userStorageAccountsList.length) {\n await this.#accounts.saveInternalAccountsListToUserStorage();\n return;\n }\n\n // Compare internal accounts list with user storage accounts list\n // First step: compare lengths\n let internalAccountsList = await this.#accounts.getInternalAccountsList();\n\n if (!internalAccountsList || !internalAccountsList.length) {\n throw new Error(`Failed to get internal accounts list`);\n }\n\n const hasMoreInternalAccountsThanUserStorageAccounts =\n internalAccountsList.length > userStorageAccountsList.length;\n\n // We don't want to remove existing accounts for a user\n // so we only add new accounts if the user has more accounts than the internal accounts list\n if (!hasMoreInternalAccountsThanUserStorageAccounts) {\n const numberOfAccountsToAdd =\n userStorageAccountsList.length - internalAccountsList.length;\n\n // Create new accounts to match the user storage accounts list\n const addNewAccountsPromises = Array.from({\n length: numberOfAccountsToAdd,\n }).map(async () => {\n await this.messagingSystem.call('KeyringController:addNewAccount');\n this.#config?.accountSyncing?.onAccountAdded?.(profileId);\n });\n\n await Promise.all(addNewAccountsPromises);\n }\n\n // Second step: compare account names\n // Get the internal accounts list again since new accounts might have been added in the previous step\n internalAccountsList = await this.#accounts.getInternalAccountsList();\n\n for await (const internalAccount of internalAccountsList) {\n const userStorageAccount = userStorageAccountsList.find(\n (account) => account.a === internalAccount.address,\n );\n\n if (!userStorageAccount) {\n await this.#accounts.saveInternalAccountToUserStorage(\n internalAccount,\n );\n continue;\n }\n\n // One or both accounts have default names\n const isInternalAccountNameDefault = isNameDefaultAccountName(\n internalAccount.metadata.name,\n );\n const isUserStorageAccountNameDefault = isNameDefaultAccountName(\n userStorageAccount.n,\n );\n\n // Internal account has default name\n if (isInternalAccountNameDefault) {\n if (!isUserStorageAccountNameDefault) {\n this.messagingSystem.call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n },\n );\n\n this.#config?.accountSyncing?.onAccountNameUpdated?.(profileId);\n }\n continue;\n }\n\n // Internal account has custom name but user storage account has default name\n if (isUserStorageAccountNameDefault) {\n await this.#accounts.saveInternalAccountToUserStorage(\n internalAccount,\n );\n continue;\n }\n\n // Both accounts have custom names\n\n // User storage account has a nameLastUpdatedAt timestamp\n // Note: not storing the undefined checks in constants to act as a type guard\n if (userStorageAccount.nlu !== undefined) {\n if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n const isInternalAccountNameNewer =\n internalAccount.metadata.nameLastUpdatedAt >\n userStorageAccount.nlu;\n\n if (isInternalAccountNameNewer) {\n await this.#accounts.saveInternalAccountToUserStorage(\n internalAccount,\n );\n continue;\n }\n }\n\n this.messagingSystem.call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n nameLastUpdatedAt: userStorageAccount.nlu,\n },\n );\n\n this.#config?.accountSyncing?.onAccountNameUpdated?.(profileId);\n\n continue;\n } else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n await this.#accounts.saveInternalAccountToUserStorage(\n internalAccount,\n );\n continue;\n }\n }\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to sync user storage accounts list - ${errorMessage}`,\n );\n } finally {\n this.#accounts.isAccountSyncingInProgress = false;\n }\n }\n\n /**\n * Saves an individual internal account to the user storage.\n * @param internalAccount - The internal account to save\n */\n async saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n ): Promise<void> {\n if (!this.#accounts.canSync()) {\n return;\n }\n\n try {\n await this.#accounts.saveInternalAccountToUserStorage(internalAccount);\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to save account to user storage - ${errorMessage}`,\n );\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UserStorageController.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,+DAA2D;AAW3D,kEAA2D;AAO3D,iFAAoF;AASpF,8DAGiC;AACjC,yFAA+E;AAC/E,6CAKoB;AAoCpB,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAclC,QAAA,YAAY,GAA+B;IACtD,uBAAuB,EAAE,IAAI;IAC7B,6BAA6B,EAAE,KAAK;CACrC,CAAC;AAEF,MAAM,QAAQ,GAA8C;IAC1D,uBAAuB,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,6BAA6B,EAAE;QAC7B,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAsHF;;;;;;;GAOG;AACH,MAAqB,qBAAsB,SAAQ,gCAIlD;IAwJC,YAAY,EACV,SAAS,EACT,KAAK,EACL,GAAG,EACH,MAAM,EACN,mBAAmB,EACnB,kBAAkB,GAWnB;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ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ACtC,CAAW,CAAC;IAEb,uBAAA,IAAI,oDAAuB,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IAE9C,OAAO,MAAM,CAAC;AAChB,CAAC,6HAGC,6BAAsC;IAEtC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACpB,KAAK,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC;kBA9fkB,qBAAqB","sourcesContent":["import type {\n AccountsControllerListAccountsAction,\n AccountsControllerUpdateAccountMetadataAction,\n AccountsControllerAccountRenamedEvent,\n AccountsControllerAccountAddedEvent,\n} from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedControllerMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { InternalAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n KeyringControllerAddNewAccountAction,\n} from '@metamask/keyring-controller';\nimport type { NetworkConfiguration } from '@metamask/network-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport { createSHA256Hash } from '../../shared/encryption';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n UserStoragePathWithKeyOnly,\n} from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\nimport { createSnapSignMessageRequest } from '../authentication/auth-snap-requests';\nimport type {\n AuthenticationControllerGetBearerToken,\n AuthenticationControllerGetSessionProfile,\n AuthenticationControllerIsSignedIn,\n AuthenticationControllerPerformSignIn,\n AuthenticationControllerPerformSignOut,\n} from '../authentication/AuthenticationController';\nimport type { UserStorageAccount } from './accounts/user-storage';\nimport {\n isNameDefaultAccountName,\n mapInternalAccountToUserStorageAccount,\n} from './accounts/user-storage';\nimport { startNetworkSyncing } from './network-syncing/controller-integration';\nimport {\n batchUpsertUserStorage,\n getUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from './services';\n\n// TODO: add external NetworkController event\n// Need to listen for when a network gets added\ntype NetworkControllerNetworkAddedEvent = {\n type: 'NetworkController:networkAdded';\n payload: [networkConfiguration: NetworkConfiguration];\n};\n\n// TODO: add external NetworkController event\n// Need to listen for when a network is updated, or the default rpc/block explorer changes\ntype NetworkControllerNetworkChangedEvent = {\n type: 'NetworkController:networkChanged';\n payload: [networkConfiguration: NetworkConfiguration];\n};\n\n// TODO: add external NetworkController event\n// Need to listen for when a network gets deleted\ntype NetworkControllerNetworkDeletedEvent = {\n type: 'NetworkController:networkDeleted';\n payload: [networkConfiguration: NetworkConfiguration];\n};\n\n// TODO: fix external dependencies\nexport declare type NotificationServicesControllerDisableNotificationServices =\n {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: () => Promise<void>;\n };\n\nexport declare type NotificationServicesControllerSelectIsNotificationServicesEnabled =\n {\n type: `NotificationServicesController:selectIsNotificationServicesEnabled`;\n handler: () => boolean;\n };\n\nconst controllerName = 'UserStorageController';\n\n// State\nexport type UserStorageControllerState = {\n /**\n * Condition used by UI and to determine if we can use some of the User Storage methods.\n */\n isProfileSyncingEnabled: boolean | null;\n /**\n * Loading state for the profile syncing update\n */\n isProfileSyncingUpdateLoading: boolean;\n};\n\nexport const defaultState: UserStorageControllerState = {\n isProfileSyncingEnabled: true,\n isProfileSyncingUpdateLoading: false,\n};\n\nconst metadata: StateMetadata<UserStorageControllerState> = {\n isProfileSyncingEnabled: {\n persist: true,\n anonymous: true,\n },\n isProfileSyncingUpdateLoading: {\n persist: false,\n anonymous: false,\n },\n};\n\ntype ControllerConfig = {\n accountSyncing?: {\n /**\n * Callback that fires when account sync adds an account.\n * This is used for analytics.\n */\n onAccountAdded?: (profileId: string) => void;\n\n /**\n * Callback that fires when account sync updates the name of an account.\n * This is used for analytics.\n */\n onAccountNameUpdated?: (profileId: string) => void;\n };\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof UserStorageController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: UserStorageController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performGetStorage'\n | 'performGetStorageAllFeatureEntries'\n | 'performSetStorage'\n | 'getStorageKey'\n | 'enableProfileSyncing'\n | 'disableProfileSyncing'\n | 'syncInternalAccountsWithUserStorage'\n | 'saveInternalAccountToUserStorage'\n>;\nexport type UserStorageControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | UserStorageControllerGetStateAction;\nexport type UserStorageControllerPerformGetStorage =\n ActionsObj['performGetStorage'];\nexport type UserStorageControllerPerformGetStorageAllFeatureEntries =\n ActionsObj['performGetStorageAllFeatureEntries'];\nexport type UserStorageControllerPerformSetStorage =\n ActionsObj['performSetStorage'];\nexport type UserStorageControllerGetStorageKey = ActionsObj['getStorageKey'];\nexport type UserStorageControllerEnableProfileSyncing =\n ActionsObj['enableProfileSyncing'];\nexport type UserStorageControllerDisableProfileSyncing =\n ActionsObj['disableProfileSyncing'];\nexport type UserStorageControllerSyncInternalAccountsWithUserStorage =\n ActionsObj['syncInternalAccountsWithUserStorage'];\nexport type UserStorageControllerSaveInternalAccountToUserStorage =\n ActionsObj['saveInternalAccountToUserStorage'];\n\nexport type AllowedActions =\n // Keyring Requests\n | KeyringControllerGetStateAction\n // Snap Requests\n | HandleSnapRequest\n // Auth Requests\n | AuthenticationControllerGetBearerToken\n | AuthenticationControllerGetSessionProfile\n | AuthenticationControllerPerformSignIn\n | AuthenticationControllerIsSignedIn\n | AuthenticationControllerPerformSignOut\n // Metamask Notifications\n | NotificationServicesControllerDisableNotificationServices\n | NotificationServicesControllerSelectIsNotificationServicesEnabled\n // Account syncing\n | AccountsControllerListAccountsAction\n | AccountsControllerUpdateAccountMetadataAction\n | KeyringControllerAddNewAccountAction;\n\n// Messenger events\nexport type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type UserStorageControllerAccountSyncingInProgress = {\n type: `${typeof controllerName}:accountSyncingInProgress`;\n payload: [boolean];\n};\nexport type UserStorageControllerAccountSyncingComplete = {\n type: `${typeof controllerName}:accountSyncingComplete`;\n payload: [boolean];\n};\nexport type Events =\n | UserStorageControllerStateChangeEvent\n | UserStorageControllerAccountSyncingInProgress\n | UserStorageControllerAccountSyncingComplete;\n\nexport type AllowedEvents =\n | UserStorageControllerStateChangeEvent\n | UserStorageControllerAccountSyncingInProgress\n | UserStorageControllerAccountSyncingComplete\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n // Account Syncing Events\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRenamedEvent\n // Network Syncing Events\n | NetworkControllerNetworkAddedEvent\n | NetworkControllerNetworkChangedEvent\n | NetworkControllerNetworkDeletedEvent;\n\n// Messenger\nexport type UserStorageControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Reusable controller that allows any team to store synchronized data for a given user.\n * These can be settings shared cross MetaMask clients, or data we want to persist when uninstalling/reinstalling.\n *\n * NOTE:\n * - data stored on UserStorage is FULLY encrypted, with the only keys stored/managed on the client.\n * - No one can access this data unless they are have the SRP and are able to run the signing snap.\n */\nexport default class UserStorageController extends BaseController<\n typeof controllerName,\n UserStorageControllerState,\n UserStorageControllerMessenger\n> {\n #auth = {\n getBearerToken: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n },\n getProfileId: async () => {\n const sessionProfile = await this.messagingSystem.call(\n 'AuthenticationController:getSessionProfile',\n );\n return sessionProfile?.profileId;\n },\n isAuthEnabled: () => {\n return this.messagingSystem.call('AuthenticationController:isSignedIn');\n },\n signIn: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:performSignIn',\n );\n },\n signOut: async () => {\n return this.messagingSystem.call(\n 'AuthenticationController:performSignOut',\n );\n },\n };\n\n #accounts = {\n // This is replaced with the actual value in the constructor\n // We will remove this once the feature will be released\n isAccountSyncingEnabled: false,\n isAccountSyncingInProgress: false,\n canSync: () => {\n try {\n this.#assertProfileSyncingEnabled();\n\n return (\n this.#accounts.isAccountSyncingEnabled && this.#auth.isAuthEnabled()\n );\n } catch {\n return false;\n }\n },\n setupAccountSyncingSubscriptions: () => {\n this.messagingSystem.subscribe(\n 'AccountsController:accountAdded',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (this.#accounts.isAccountSyncingInProgress) {\n return;\n }\n await this.saveInternalAccountToUserStorage(account);\n },\n );\n\n this.messagingSystem.subscribe(\n 'AccountsController:accountRenamed',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (this.#accounts.isAccountSyncingInProgress) {\n return;\n }\n await this.saveInternalAccountToUserStorage(account);\n },\n );\n },\n getInternalAccountsList: async (): Promise<InternalAccount[]> => {\n return this.messagingSystem.call('AccountsController:listAccounts');\n },\n getUserStorageAccountsList: async (): Promise<\n UserStorageAccount[] | null\n > => {\n const rawAccountsListResponse =\n await this.performGetStorageAllFeatureEntries('accounts');\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ??\n null\n );\n },\n saveInternalAccountToUserStorage: async (\n internalAccount: InternalAccount,\n ) => {\n // Map the internal account to the user storage account schema\n const mappedAccount =\n mapInternalAccountToUserStorageAccount(internalAccount);\n\n await this.performSetStorage(\n `accounts.${internalAccount.address}`,\n JSON.stringify(mappedAccount),\n );\n },\n saveInternalAccountsListToUserStorage: async () => {\n const internalAccountsList =\n await this.#accounts.getInternalAccountsList();\n\n if (!internalAccountsList) {\n return;\n }\n\n const internalAccountsListFormattedForUserStorage =\n internalAccountsList.map(mapInternalAccountToUserStorageAccount);\n\n await this.performBatchSetStorage(\n 'accounts',\n internalAccountsListFormattedForUserStorage.map((account) => [\n account.a,\n JSON.stringify(account),\n ]),\n );\n },\n };\n\n #config?: ControllerConfig;\n\n #notificationServices = {\n disableNotificationServices: async () => {\n return await this.messagingSystem.call(\n 'NotificationServicesController:disableNotificationServices',\n );\n },\n selectIsNotificationServicesEnabled: async () => {\n return this.messagingSystem.call(\n 'NotificationServicesController:selectIsNotificationServicesEnabled',\n );\n },\n };\n\n #isUnlocked = false;\n\n #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n #nativeScryptCrypto: NativeScrypt | undefined = undefined;\n\n getMetaMetricsState: () => boolean;\n\n constructor({\n messenger,\n state,\n env,\n config,\n getMetaMetricsState,\n nativeScryptCrypto,\n }: {\n messenger: UserStorageControllerMessenger;\n state?: UserStorageControllerState;\n config?: ControllerConfig;\n env?: {\n isAccountSyncingEnabled?: boolean;\n isNetworkSyncingEnabled?: boolean;\n };\n getMetaMetricsState: () => boolean;\n nativeScryptCrypto?: NativeScrypt;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#config = config;\n\n this.#accounts.isAccountSyncingEnabled = Boolean(\n env?.isAccountSyncingEnabled,\n );\n\n this.getMetaMetricsState = getMetaMetricsState;\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n this.#nativeScryptCrypto = nativeScryptCrypto;\n this.#accounts.setupAccountSyncingSubscriptions();\n\n // Network Syncing\n if (env?.isNetworkSyncingEnabled) {\n startNetworkSyncing({\n messenger,\n getStorageConfig: async () => {\n const { storageKey, bearerToken } =\n await this.#getStorageKeyAndBearerToken();\n return {\n storageKey,\n bearerToken,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n };\n },\n });\n }\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorage',\n this.performGetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n this.performGetStorageAllFeatureEntries.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performSetStorage',\n this.performSetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:getStorageKey',\n this.getStorageKey.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:enableProfileSyncing',\n this.enableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:disableProfileSyncing',\n this.disableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:syncInternalAccountsWithUserStorage',\n this.syncInternalAccountsWithUserStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:saveInternalAccountToUserStorage',\n this.saveInternalAccountToUserStorage.bind(this),\n );\n }\n\n public async enableProfileSyncing(): Promise<void> {\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n const authEnabled = this.#auth.isAuthEnabled();\n if (!authEnabled) {\n await this.#auth.signIn();\n }\n\n this.update((state) => {\n state.isProfileSyncingEnabled = true;\n });\n\n this.#setIsProfileSyncingUpdateLoading(false);\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to enable profile syncing - ${errorMessage}`,\n );\n }\n }\n\n public async setIsProfileSyncingEnabled(\n isProfileSyncingEnabled: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isProfileSyncingEnabled = isProfileSyncingEnabled;\n });\n }\n\n public async disableProfileSyncing(): Promise<void> {\n const isAlreadyDisabled = !this.state.isProfileSyncingEnabled;\n if (isAlreadyDisabled) {\n return;\n }\n\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n const isNotificationServicesEnabled =\n await this.#notificationServices.selectIsNotificationServicesEnabled();\n\n if (isNotificationServicesEnabled) {\n await this.#notificationServices.disableNotificationServices();\n }\n\n const isMetaMetricsParticipation = this.getMetaMetricsState();\n\n if (!isMetaMetricsParticipation) {\n await this.#auth.signOut();\n }\n\n this.#setIsProfileSyncingUpdateLoading(false);\n\n this.update((state) => {\n state.isProfileSyncingEnabled = false;\n });\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to disable profile syncing - ${errorMessage}`,\n );\n }\n }\n\n /**\n * Allows retrieval of stored data. Data stored is string formatted.\n * Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @returns the decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorage(\n path: UserStoragePathWithFeatureAndKey,\n ): Promise<string | null> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n const result = await getUserStorage({\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n\n return result;\n }\n\n /**\n * Allows retrieval of all stored data for a specific feature. Data stored is formatted as an array of strings.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @returns the array of decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorageAllFeatureEntries(\n path: UserStoragePathWithFeatureOnly,\n ): Promise<string[] | null> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n const result = await getUserStorageAllFeatureEntries({\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n\n return result;\n }\n\n /**\n * Allows storage of user data. Data stored must be string formatted.\n * Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param value - The string data you want to store.\n * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performSetStorage(\n path: UserStoragePathWithFeatureAndKey,\n value: string,\n ): Promise<void> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await upsertUserStorage(value, {\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n }\n\n /**\n * Allows storage of multiple user data entries for one specific feature. Data stored must be string formatted.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs\n * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n\n public async performBatchSetStorage(\n path: UserStoragePathWithFeatureOnly,\n values: [UserStoragePathWithKeyOnly, string][],\n ): Promise<void> {\n this.#assertProfileSyncingEnabled();\n\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await batchUpsertUserStorage(values, {\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n }\n\n /**\n * Retrieves the storage key, for internal use only!\n *\n * @returns the storage key\n */\n public async getStorageKey(): Promise<string> {\n this.#assertProfileSyncingEnabled();\n const storageKey = await this.#createStorageKey();\n return storageKey;\n }\n\n #assertProfileSyncingEnabled(): void {\n if (!this.state.isProfileSyncingEnabled) {\n throw new Error(\n `${controllerName}: Unable to call method, user is not authenticated`,\n );\n }\n }\n\n /**\n * Utility to get the bearer token and storage key\n */\n async #getStorageKeyAndBearerToken(): Promise<{\n bearerToken: string;\n storageKey: string;\n }> {\n const bearerToken = await this.#auth.getBearerToken();\n if (!bearerToken) {\n throw new Error('UserStorageController - unable to get bearer token');\n }\n const storageKey = await this.#createStorageKey();\n\n return { bearerToken, storageKey };\n }\n\n /**\n * Rather than storing the storage key, we can compute the storage key when needed.\n *\n * @returns the storage key\n */\n async #createStorageKey(): Promise<string> {\n const id: string = await this.#auth.getProfileId();\n if (!id) {\n throw new Error('UserStorageController - unable to create storage key');\n }\n\n const storageKeySignature = await this.#snapSignMessage(`metamask:${id}`);\n const storageKey = createSHA256Hash(storageKeySignature);\n return storageKey;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapSignMessage - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n\n #setIsProfileSyncingUpdateLoading(\n isProfileSyncingUpdateLoading: boolean,\n ): void {\n this.update((state) => {\n state.isProfileSyncingUpdateLoading = isProfileSyncingUpdateLoading;\n });\n }\n\n /**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n */\n async syncInternalAccountsWithUserStorage(): Promise<void> {\n if (!this.#accounts.canSync()) {\n return;\n }\n\n try {\n this.#accounts.isAccountSyncingInProgress = true;\n\n const profileId = await this.#auth.getProfileId();\n\n const userStorageAccountsList =\n await this.#accounts.getUserStorageAccountsList();\n\n if (!userStorageAccountsList || !userStorageAccountsList.length) {\n await this.#accounts.saveInternalAccountsListToUserStorage();\n return;\n }\n\n // Prepare an array of internal accounts to be saved to the user storage\n const internalAccountsToBeSavedToUserStorage: InternalAccount[] = [];\n\n // Compare internal accounts list with user storage accounts list\n // First step: compare lengths\n let internalAccountsList = await this.#accounts.getInternalAccountsList();\n\n if (!internalAccountsList || !internalAccountsList.length) {\n throw new Error(`Failed to get internal accounts list`);\n }\n\n const hasMoreInternalAccountsThanUserStorageAccounts =\n internalAccountsList.length > userStorageAccountsList.length;\n\n // We don't want to remove existing accounts for a user\n // so we only add new accounts if the user has more accounts than the internal accounts list\n if (!hasMoreInternalAccountsThanUserStorageAccounts) {\n const numberOfAccountsToAdd =\n userStorageAccountsList.length - internalAccountsList.length;\n\n // Create new accounts to match the user storage accounts list\n const addNewAccountsPromises = Array.from({\n length: numberOfAccountsToAdd,\n }).map(async () => {\n await this.messagingSystem.call('KeyringController:addNewAccount');\n this.#config?.accountSyncing?.onAccountAdded?.(profileId);\n });\n\n await Promise.all(addNewAccountsPromises);\n }\n\n // Second step: compare account names\n // Get the internal accounts list again since new accounts might have been added in the previous step\n internalAccountsList = await this.#accounts.getInternalAccountsList();\n\n for await (const internalAccount of internalAccountsList) {\n const userStorageAccount = userStorageAccountsList.find(\n (account) => account.a === internalAccount.address,\n );\n\n if (!userStorageAccount) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // One or both accounts have default names\n const isInternalAccountNameDefault = isNameDefaultAccountName(\n internalAccount.metadata.name,\n );\n const isUserStorageAccountNameDefault = isNameDefaultAccountName(\n userStorageAccount.n,\n );\n\n // Internal account has default name\n if (isInternalAccountNameDefault) {\n if (!isUserStorageAccountNameDefault) {\n this.messagingSystem.call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n },\n );\n\n this.#config?.accountSyncing?.onAccountNameUpdated?.(profileId);\n }\n continue;\n }\n\n // Internal account has custom name but user storage account has default name\n if (isUserStorageAccountNameDefault) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // Both accounts have custom names\n\n // User storage account has a nameLastUpdatedAt timestamp\n // Note: not storing the undefined checks in constants to act as a type guard\n if (userStorageAccount.nlu !== undefined) {\n if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n const isInternalAccountNameNewer =\n internalAccount.metadata.nameLastUpdatedAt >\n userStorageAccount.nlu;\n\n if (isInternalAccountNameNewer) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n this.messagingSystem.call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n nameLastUpdatedAt: userStorageAccount.nlu,\n },\n );\n\n this.#config?.accountSyncing?.onAccountNameUpdated?.(profileId);\n\n continue;\n } else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n // Save the internal accounts list to the user storage\n await this.performBatchSetStorage(\n 'accounts',\n internalAccountsToBeSavedToUserStorage.map((account) => [\n account.address,\n JSON.stringify(mapInternalAccountToUserStorageAccount(account)),\n ]),\n );\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to sync user storage accounts list - ${errorMessage}`,\n );\n } finally {\n this.#accounts.isAccountSyncingInProgress = false;\n }\n }\n\n /**\n * Saves an individual internal account to the user storage.\n * @param internalAccount - The internal account to save\n */\n async saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n ): Promise<void> {\n if (!this.#accounts.canSync()) {\n return;\n }\n\n try {\n await this.#accounts.saveInternalAccountToUserStorage(internalAccount);\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to save account to user storage - ${errorMessage}`,\n );\n }\n }\n}\n"]}
|
|
@@ -5,8 +5,9 @@ import type { InternalAccount } from "@metamask/keyring-api";
|
|
|
5
5
|
import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent, KeyringControllerAddNewAccountAction } from "@metamask/keyring-controller";
|
|
6
6
|
import type { NetworkConfiguration } from "@metamask/network-controller";
|
|
7
7
|
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
8
|
+
import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly, UserStoragePathWithKeyOnly } from "../../shared/storage-schema.cjs";
|
|
9
|
+
import type { NativeScrypt } from "../../shared/types/encryption.cjs";
|
|
8
10
|
import type { AuthenticationControllerGetBearerToken, AuthenticationControllerGetSessionProfile, AuthenticationControllerIsSignedIn, AuthenticationControllerPerformSignIn, AuthenticationControllerPerformSignOut } from "../authentication/AuthenticationController.cjs";
|
|
9
|
-
import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from "./schema.cjs";
|
|
10
11
|
type NetworkControllerNetworkAddedEvent = {
|
|
11
12
|
type: 'NetworkController:networkAdded';
|
|
12
13
|
payload: [networkConfiguration: NetworkConfiguration];
|
|
@@ -27,7 +28,6 @@ export declare type NotificationServicesControllerSelectIsNotificationServicesEn
|
|
|
27
28
|
type: `NotificationServicesController:selectIsNotificationServicesEnabled`;
|
|
28
29
|
handler: () => boolean;
|
|
29
30
|
};
|
|
30
|
-
export declare type NativeScrypt = (passwd: string, salt: Uint8Array, N: number, r: number, p: number, size: number) => Promise<Uint8Array>;
|
|
31
31
|
declare const controllerName = "UserStorageController";
|
|
32
32
|
export type UserStorageControllerState = {
|
|
33
33
|
/**
|
|
@@ -134,6 +134,15 @@ export default class UserStorageController extends BaseController<typeof control
|
|
|
134
134
|
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
135
135
|
*/
|
|
136
136
|
performSetStorage(path: UserStoragePathWithFeatureAndKey, value: string): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Allows storage of multiple user data entries for one specific feature. Data stored must be string formatted.
|
|
139
|
+
* Developers can extend the entry path through the `schema.ts` file.
|
|
140
|
+
*
|
|
141
|
+
* @param path - string in the form of `${feature}` that matches schema
|
|
142
|
+
* @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs
|
|
143
|
+
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
144
|
+
*/
|
|
145
|
+
performBatchSetStorage(path: UserStoragePathWithFeatureOnly, values: [UserStoragePathWithKeyOnly, string][]): Promise<void>;
|
|
137
146
|
/**
|
|
138
147
|
* Retrieves the storage key, for internal use only!
|
|
139
148
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserStorageController.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,6CAA6C,EAC7C,qCAAqC,EACrC,mCAAmC,EACpC,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAE9B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACrC,qCAAqC;AACtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"UserStorageController.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,6CAA6C,EAC7C,qCAAqC,EACrC,mCAAmC,EACpC,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAE9B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACrC,qCAAqC;AACtC,OAAO,KAAK,EAAE,oBA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9 @@ import type { InternalAccount } from "@metamask/keyring-api";
|
|
|
5
5
|
import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent, KeyringControllerAddNewAccountAction } from "@metamask/keyring-controller";
|
|
6
6
|
import type { NetworkConfiguration } from "@metamask/network-controller";
|
|
7
7
|
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
8
|
+
import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly, UserStoragePathWithKeyOnly } from "../../shared/storage-schema.mjs";
|
|
9
|
+
import type { NativeScrypt } from "../../shared/types/encryption.mjs";
|
|
8
10
|
import type { AuthenticationControllerGetBearerToken, AuthenticationControllerGetSessionProfile, AuthenticationControllerIsSignedIn, AuthenticationControllerPerformSignIn, AuthenticationControllerPerformSignOut } from "../authentication/AuthenticationController.mjs";
|
|
9
|
-
import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from "./schema.mjs";
|
|
10
11
|
type NetworkControllerNetworkAddedEvent = {
|
|
11
12
|
type: 'NetworkController:networkAdded';
|
|
12
13
|
payload: [networkConfiguration: NetworkConfiguration];
|
|
@@ -27,7 +28,6 @@ export declare type NotificationServicesControllerSelectIsNotificationServicesEn
|
|
|
27
28
|
type: `NotificationServicesController:selectIsNotificationServicesEnabled`;
|
|
28
29
|
handler: () => boolean;
|
|
29
30
|
};
|
|
30
|
-
export declare type NativeScrypt = (passwd: string, salt: Uint8Array, N: number, r: number, p: number, size: number) => Promise<Uint8Array>;
|
|
31
31
|
declare const controllerName = "UserStorageController";
|
|
32
32
|
export type UserStorageControllerState = {
|
|
33
33
|
/**
|
|
@@ -134,6 +134,15 @@ export default class UserStorageController extends BaseController<typeof control
|
|
|
134
134
|
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
135
135
|
*/
|
|
136
136
|
performSetStorage(path: UserStoragePathWithFeatureAndKey, value: string): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Allows storage of multiple user data entries for one specific feature. Data stored must be string formatted.
|
|
139
|
+
* Developers can extend the entry path through the `schema.ts` file.
|
|
140
|
+
*
|
|
141
|
+
* @param path - string in the form of `${feature}` that matches schema
|
|
142
|
+
* @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs
|
|
143
|
+
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
144
|
+
*/
|
|
145
|
+
performBatchSetStorage(path: UserStoragePathWithFeatureOnly, values: [UserStoragePathWithKeyOnly, string][]): Promise<void>;
|
|
137
146
|
/**
|
|
138
147
|
* Retrieves the storage key, for internal use only!
|
|
139
148
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserStorageController.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,6CAA6C,EAC7C,qCAAqC,EACrC,mCAAmC,EACpC,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAE9B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACrC,qCAAqC;AACtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"UserStorageController.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,6CAA6C,EAC7C,qCAAqC,EACrC,mCAAmC,EACpC,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAE9B,kCAAkC;AACnC,OAAO,EAA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