@metamask-previews/profile-sync-controller 3.1.1-preview-e218ba33 → 3.1.1-preview-2983d87f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/controllers/user-storage/UserStorageController.cjs +218 -39
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +1 -6
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +1 -6
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +215 -36
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/{account-syncing/__fixtures__ → __fixtures__}/mockAccounts.cjs +3 -3
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/__fixtures__ → __fixtures__}/mockAccounts.d.cts +6 -6
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/__fixtures__ → __fixtures__}/mockAccounts.d.mts +6 -6
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/__fixtures__ → __fixtures__}/mockAccounts.mjs +2 -2
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +1 -45
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +0 -21
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +0 -21
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +0 -38
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/accounts/constants.cjs.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.d.cts.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.d.mts.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.mjs.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/utils.cjs → accounts/user-storage.cjs} +2 -12
- package/dist/controllers/user-storage/accounts/user-storage.cjs.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/utils.d.mts → accounts/user-storage.d.cts} +17 -8
- package/dist/controllers/user-storage/accounts/user-storage.d.cts.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/utils.d.cts → accounts/user-storage.d.mts} +17 -8
- package/dist/controllers/user-storage/accounts/user-storage.d.mts.map +1 -0
- package/dist/controllers/user-storage/{account-syncing/utils.mjs → accounts/user-storage.mjs} +1 -10
- package/dist/controllers/user-storage/accounts/user-storage.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +0 -50
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +0 -85
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +0 -85
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +0 -44
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/constants.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/constants.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/constants.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/constants.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +0 -194
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +0 -31
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +0 -31
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +0 -188
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +0 -35
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +0 -8
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +0 -8
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +0 -31
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +0 -47
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +0 -20
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +0 -20
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +0 -41
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/types.cjs +0 -3
- package/dist/controllers/user-storage/account-syncing/types.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/types.d.cts +0 -26
- package/dist/controllers/user-storage/account-syncing/types.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/types.d.mts +0 -26
- package/dist/controllers/user-storage/account-syncing/types.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/types.mjs +0 -2
- package/dist/controllers/user-storage/account-syncing/types.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/utils.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/utils.mjs.map +0 -1
- /package/dist/controllers/user-storage/{account-syncing → accounts}/constants.cjs +0 -0
- /package/dist/controllers/user-storage/{account-syncing → accounts}/constants.d.cts +0 -0
- /package/dist/controllers/user-storage/{account-syncing → accounts}/constants.d.mts +0 -0
- /package/dist/controllers/user-storage/{account-syncing → accounts}/constants.mjs +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { saveInternalAccountToUserStorage } from "./controller-integration.mjs";
|
|
2
|
-
import { canPerformAccountSyncing } from "./sync-utils.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Initialize and setup events to listen to for account syncing
|
|
5
|
-
* @param config - configuration parameters
|
|
6
|
-
* @param options - parameters used for initializing and enabling account syncing
|
|
7
|
-
*/
|
|
8
|
-
export function setupAccountSyncingSubscriptions(config, options) {
|
|
9
|
-
const { getMessenger, getUserStorageControllerInstance } = options;
|
|
10
|
-
getMessenger().subscribe('AccountsController:accountAdded',
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
12
|
-
async (account) => {
|
|
13
|
-
if (!canPerformAccountSyncing(config, options) ||
|
|
14
|
-
!getUserStorageControllerInstance().state
|
|
15
|
-
.hasAccountSyncingSyncedAtLeastOnce) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
await saveInternalAccountToUserStorage(account, config, options);
|
|
19
|
-
});
|
|
20
|
-
getMessenger().subscribe('AccountsController:accountRenamed',
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
22
|
-
async (account) => {
|
|
23
|
-
if (!canPerformAccountSyncing(config, options) ||
|
|
24
|
-
!getUserStorageControllerInstance().state
|
|
25
|
-
.hasAccountSyncingSyncedAtLeastOnce) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
await saveInternalAccountToUserStorage(account, config, options);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=setup-subscriptions.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup-subscriptions.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,qCAAiC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAGxD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,YAAY,EAAE,CAAC,SAAS,CACtB,iCAAiC;IACjC,kEAAkE;IAClE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;IAEF,YAAY,EAAE,CAAC,SAAS,CACtB,mCAAmC;IACnC,kEAAkE;IAClE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { saveInternalAccountToUserStorage } from './controller-integration';\nimport { canPerformAccountSyncing } from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\n\n/**\n * Initialize and setup events to listen to for account syncing\n * @param config - configuration parameters\n * @param options - parameters used for initializing and enabling account syncing\n */\nexport function setupAccountSyncingSubscriptions(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n) {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n getMessenger().subscribe(\n 'AccountsController:accountAdded',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n\n getMessenger().subscribe(\n 'AccountsController:accountRenamed',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n}\n"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserStorageAccountsList = exports.getInternalAccountsList = exports.canPerformAccountSyncing = void 0;
|
|
4
|
-
const storage_schema_1 = require("../../../shared/storage-schema.cjs");
|
|
5
|
-
const utils_1 = require("./utils.cjs");
|
|
6
|
-
/**
|
|
7
|
-
* Checks if account syncing can be performed based on a set of conditions
|
|
8
|
-
* @param config - configuration parameters
|
|
9
|
-
* @param options - parameters used for checking if account syncing can be performed
|
|
10
|
-
* @returns Returns true if account syncing can be performed, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
function canPerformAccountSyncing(config, options) {
|
|
13
|
-
const { isAccountSyncingEnabled } = config;
|
|
14
|
-
const { getMessenger, getUserStorageControllerInstance } = options;
|
|
15
|
-
const { isProfileSyncingEnabled, isAccountSyncingInProgress } = getUserStorageControllerInstance().state;
|
|
16
|
-
const isAuthEnabled = getMessenger().call('AuthenticationController:isSignedIn');
|
|
17
|
-
if (!isProfileSyncingEnabled ||
|
|
18
|
-
!isAuthEnabled ||
|
|
19
|
-
!isAccountSyncingEnabled ||
|
|
20
|
-
isAccountSyncingInProgress) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
exports.canPerformAccountSyncing = canPerformAccountSyncing;
|
|
26
|
-
/**
|
|
27
|
-
* Get the list of internal accounts
|
|
28
|
-
* @param options - parameters used for getting the list of internal accounts
|
|
29
|
-
*/
|
|
30
|
-
async function getInternalAccountsList(options) {
|
|
31
|
-
const { getMessenger } = options;
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
33
|
-
const internalAccountsList = await getMessenger().call('AccountsController:listAccounts');
|
|
34
|
-
return internalAccountsList?.filter(utils_1.doesInternalAccountHaveCorrectKeyringType);
|
|
35
|
-
}
|
|
36
|
-
exports.getInternalAccountsList = getInternalAccountsList;
|
|
37
|
-
/**
|
|
38
|
-
* Get the list of user storage accounts
|
|
39
|
-
* @param options - parameters used for getting the list of user storage accounts
|
|
40
|
-
*/
|
|
41
|
-
async function getUserStorageAccountsList(options) {
|
|
42
|
-
const { getUserStorageControllerInstance } = options;
|
|
43
|
-
const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(storage_schema_1.USER_STORAGE_FEATURE_NAMES.accounts);
|
|
44
|
-
return (rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null);
|
|
45
|
-
}
|
|
46
|
-
exports.getUserStorageAccountsList = getUserStorageAccountsList;
|
|
47
|
-
//# sourceMappingURL=sync-utils.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":";;;AAEA,uEAA4E;AAM5E,uCAAoE;AAEpE;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,GAC3D,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC3C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,CAAC,uBAAuB;QACxB,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAvBD,4DAuBC;AAED;;;GAGG;AACI,KAAK,UAAU,uBAAuB,CAC3C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,6DAA6D;IAC7D,MAAM,oBAAoB,GAAG,MAAM,YAAY,EAAE,CAAC,IAAI,CACpD,iCAAiC,CAClC,CAAC;IAEF,OAAO,oBAAoB,EAAE,MAAM,CACjC,iDAAyC,CAC1C,CAAC;AACJ,CAAC;AAbD,0DAaC;AAED;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAC9C,OAA8B;IAE9B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,2CAA0B,CAAC,QAAQ,CACpC,CAAC;IAEJ,OAAO,CACL,uBAAuB,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAC7E,CAAC;AACJ,CAAC;AAbD,gEAaC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type {\n AccountSyncingConfig,\n AccountSyncingOptions,\n UserStorageAccount,\n} from './types';\nimport { doesInternalAccountHaveCorrectKeyringType } from './utils';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n * @param config - configuration parameters\n * @param options - parameters used for checking if account syncing can be performed\n * @returns Returns true if account syncing can be performed, false otherwise.\n */\nexport function canPerformAccountSyncing(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): boolean {\n const { isAccountSyncingEnabled } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const { isProfileSyncingEnabled, isAccountSyncingInProgress } =\n getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isProfileSyncingEnabled ||\n !isAuthEnabled ||\n !isAccountSyncingEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n * @param options - parameters used for getting the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const internalAccountsList = await getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n return internalAccountsList?.filter(\n doesInternalAccountHaveCorrectKeyringType,\n );\n}\n\n/**\n * Get the list of user storage accounts\n * @param options - parameters used for getting the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
|
-
import type { AccountSyncingConfig, AccountSyncingOptions, UserStorageAccount } from "./types.cjs";
|
|
3
|
-
/**
|
|
4
|
-
* Checks if account syncing can be performed based on a set of conditions
|
|
5
|
-
* @param config - configuration parameters
|
|
6
|
-
* @param options - parameters used for checking if account syncing can be performed
|
|
7
|
-
* @returns Returns true if account syncing can be performed, false otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export declare function canPerformAccountSyncing(config: AccountSyncingConfig, options: AccountSyncingOptions): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Get the list of internal accounts
|
|
12
|
-
* @param options - parameters used for getting the list of internal accounts
|
|
13
|
-
*/
|
|
14
|
-
export declare function getInternalAccountsList(options: AccountSyncingOptions): Promise<InternalAccount[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Get the list of user storage accounts
|
|
17
|
-
* @param options - parameters used for getting the list of user storage accounts
|
|
18
|
-
*/
|
|
19
|
-
export declare function getUserStorageAccountsList(options: AccountSyncingOptions): Promise<UserStorageAccount[] | null>;
|
|
20
|
-
//# sourceMappingURL=sync-utils.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EACnB,oBAAgB;AAGjB;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAoBT;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAW5B;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAWtC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
|
-
import type { AccountSyncingConfig, AccountSyncingOptions, UserStorageAccount } from "./types.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Checks if account syncing can be performed based on a set of conditions
|
|
5
|
-
* @param config - configuration parameters
|
|
6
|
-
* @param options - parameters used for checking if account syncing can be performed
|
|
7
|
-
* @returns Returns true if account syncing can be performed, false otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export declare function canPerformAccountSyncing(config: AccountSyncingConfig, options: AccountSyncingOptions): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Get the list of internal accounts
|
|
12
|
-
* @param options - parameters used for getting the list of internal accounts
|
|
13
|
-
*/
|
|
14
|
-
export declare function getInternalAccountsList(options: AccountSyncingOptions): Promise<InternalAccount[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Get the list of user storage accounts
|
|
17
|
-
* @param options - parameters used for getting the list of user storage accounts
|
|
18
|
-
*/
|
|
19
|
-
export declare function getUserStorageAccountsList(options: AccountSyncingOptions): Promise<UserStorageAccount[] | null>;
|
|
20
|
-
//# sourceMappingURL=sync-utils.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EACnB,oBAAgB;AAGjB;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAoBT;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAW5B;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAWtC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
|
|
2
|
-
import { doesInternalAccountHaveCorrectKeyringType } from "./utils.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Checks if account syncing can be performed based on a set of conditions
|
|
5
|
-
* @param config - configuration parameters
|
|
6
|
-
* @param options - parameters used for checking if account syncing can be performed
|
|
7
|
-
* @returns Returns true if account syncing can be performed, false otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export function canPerformAccountSyncing(config, options) {
|
|
10
|
-
const { isAccountSyncingEnabled } = config;
|
|
11
|
-
const { getMessenger, getUserStorageControllerInstance } = options;
|
|
12
|
-
const { isProfileSyncingEnabled, isAccountSyncingInProgress } = getUserStorageControllerInstance().state;
|
|
13
|
-
const isAuthEnabled = getMessenger().call('AuthenticationController:isSignedIn');
|
|
14
|
-
if (!isProfileSyncingEnabled ||
|
|
15
|
-
!isAuthEnabled ||
|
|
16
|
-
!isAccountSyncingEnabled ||
|
|
17
|
-
isAccountSyncingInProgress) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get the list of internal accounts
|
|
24
|
-
* @param options - parameters used for getting the list of internal accounts
|
|
25
|
-
*/
|
|
26
|
-
export async function getInternalAccountsList(options) {
|
|
27
|
-
const { getMessenger } = options;
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
29
|
-
const internalAccountsList = await getMessenger().call('AccountsController:listAccounts');
|
|
30
|
-
return internalAccountsList?.filter(doesInternalAccountHaveCorrectKeyringType);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Get the list of user storage accounts
|
|
34
|
-
* @param options - parameters used for getting the list of user storage accounts
|
|
35
|
-
*/
|
|
36
|
-
export async function getUserStorageAccountsList(options) {
|
|
37
|
-
const { getUserStorageControllerInstance } = options;
|
|
38
|
-
const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(USER_STORAGE_FEATURE_NAMES.accounts);
|
|
39
|
-
return (rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null);
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=sync-utils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,2CAAuC;AAM5E,OAAO,EAAE,yCAAyC,EAAE,oBAAgB;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,GAC3D,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC3C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,CAAC,uBAAuB;QACxB,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,6DAA6D;IAC7D,MAAM,oBAAoB,GAAG,MAAM,YAAY,EAAE,CAAC,IAAI,CACpD,iCAAiC,CAClC,CAAC;IAEF,OAAO,oBAAoB,EAAE,MAAM,CACjC,yCAAyC,CAC1C,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAA8B;IAE9B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,0BAA0B,CAAC,QAAQ,CACpC,CAAC;IAEJ,OAAO,CACL,uBAAuB,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAC7E,CAAC;AACJ,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type {\n AccountSyncingConfig,\n AccountSyncingOptions,\n UserStorageAccount,\n} from './types';\nimport { doesInternalAccountHaveCorrectKeyringType } from './utils';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n * @param config - configuration parameters\n * @param options - parameters used for checking if account syncing can be performed\n * @returns Returns true if account syncing can be performed, false otherwise.\n */\nexport function canPerformAccountSyncing(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): boolean {\n const { isAccountSyncingEnabled } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const { isProfileSyncingEnabled, isAccountSyncingInProgress } =\n getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isProfileSyncingEnabled ||\n !isAuthEnabled ||\n !isAccountSyncingEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n * @param options - parameters used for getting the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const internalAccountsList = await getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n return internalAccountsList?.filter(\n doesInternalAccountHaveCorrectKeyringType,\n );\n}\n\n/**\n * Get the list of user storage accounts\n * @param options - parameters used for getting the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { UserStorageControllerMessenger } from '../UserStorageController';\nimport type UserStorageController from '../UserStorageController';\nimport type {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from './constants';\n\nexport type UserStorageAccount = {\n /**\n * The Version 'v' of the User Storage.\n * NOTE - will allow us to support upgrade/downgrades in the future\n */\n [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;\n /** the id 'i' of the account */\n i: string;\n /** the address 'a' of the account */\n a: string;\n /** the name 'n' of the account */\n n: string;\n /** the nameLastUpdatedAt timestamp 'nlu' of the account */\n nlu?: number;\n};\n\nexport type AccountSyncingConfig = {\n isAccountSyncingEnabled: boolean;\n};\n\nexport type AccountSyncingOptions = {\n getUserStorageControllerInstance: () => UserStorageController;\n getMessenger: () => UserStorageControllerMessenger;\n};\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { UserStorageControllerMessenger } from "../UserStorageController.cjs";
|
|
2
|
-
import type UserStorageController from "../UserStorageController.cjs";
|
|
3
|
-
import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.cjs";
|
|
4
|
-
export type UserStorageAccount = {
|
|
5
|
-
/**
|
|
6
|
-
* The Version 'v' of the User Storage.
|
|
7
|
-
* NOTE - will allow us to support upgrade/downgrades in the future
|
|
8
|
-
*/
|
|
9
|
-
[USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;
|
|
10
|
-
/** the id 'i' of the account */
|
|
11
|
-
i: string;
|
|
12
|
-
/** the address 'a' of the account */
|
|
13
|
-
a: string;
|
|
14
|
-
/** the name 'n' of the account */
|
|
15
|
-
n: string;
|
|
16
|
-
/** the nameLastUpdatedAt timestamp 'nlu' of the account */
|
|
17
|
-
nlu?: number;
|
|
18
|
-
};
|
|
19
|
-
export type AccountSyncingConfig = {
|
|
20
|
-
isAccountSyncingEnabled: boolean;
|
|
21
|
-
};
|
|
22
|
-
export type AccountSyncingOptions = {
|
|
23
|
-
getUserStorageControllerInstance: () => UserStorageController;
|
|
24
|
-
getMessenger: () => UserStorageControllerMessenger;
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAC/E,OAAO,KAAK,qBAAqB,qCAAiC;AAClE,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,wBAAoB;AAErB,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,CAAC,wBAAwB,CAAC,EAAE,OAAO,oBAAoB,CAAC;IACxD,gCAAgC;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,kCAAkC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;IAC9D,YAAY,EAAE,MAAM,8BAA8B,CAAC;CACpD,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { UserStorageControllerMessenger } from "../UserStorageController.mjs";
|
|
2
|
-
import type UserStorageController from "../UserStorageController.mjs";
|
|
3
|
-
import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.mjs";
|
|
4
|
-
export type UserStorageAccount = {
|
|
5
|
-
/**
|
|
6
|
-
* The Version 'v' of the User Storage.
|
|
7
|
-
* NOTE - will allow us to support upgrade/downgrades in the future
|
|
8
|
-
*/
|
|
9
|
-
[USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;
|
|
10
|
-
/** the id 'i' of the account */
|
|
11
|
-
i: string;
|
|
12
|
-
/** the address 'a' of the account */
|
|
13
|
-
a: string;
|
|
14
|
-
/** the name 'n' of the account */
|
|
15
|
-
n: string;
|
|
16
|
-
/** the nameLastUpdatedAt timestamp 'nlu' of the account */
|
|
17
|
-
nlu?: number;
|
|
18
|
-
};
|
|
19
|
-
export type AccountSyncingConfig = {
|
|
20
|
-
isAccountSyncingEnabled: boolean;
|
|
21
|
-
};
|
|
22
|
-
export type AccountSyncingOptions = {
|
|
23
|
-
getUserStorageControllerInstance: () => UserStorageController;
|
|
24
|
-
getMessenger: () => UserStorageControllerMessenger;
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAC/E,OAAO,KAAK,qBAAqB,qCAAiC;AAClE,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,wBAAoB;AAErB,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,CAAC,wBAAwB,CAAC,EAAE,OAAO,oBAAoB,CAAC;IACxD,gCAAgC;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,kCAAkC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;IAC9D,YAAY,EAAE,MAAM,8BAA8B,CAAC;CACpD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { UserStorageControllerMessenger } from '../UserStorageController';\nimport type UserStorageController from '../UserStorageController';\nimport type {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from './constants';\n\nexport type UserStorageAccount = {\n /**\n * The Version 'v' of the User Storage.\n * NOTE - will allow us to support upgrade/downgrades in the future\n */\n [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;\n /** the id 'i' of the account */\n i: string;\n /** the address 'a' of the account */\n a: string;\n /** the name 'n' of the account */\n n: string;\n /** the nameLastUpdatedAt timestamp 'nlu' of the account */\n nlu?: number;\n};\n\nexport type AccountSyncingConfig = {\n isAccountSyncingEnabled: boolean;\n};\n\nexport type AccountSyncingOptions = {\n getUserStorageControllerInstance: () => UserStorageController;\n getMessenger: () => UserStorageControllerMessenger;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":";;;AAAA,qEAA4D;AAG5D,+CAIqB;AAGrB;;;;;;GAMG;AAEI,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IACvD,OAAO,2CAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAEF;;;;GAIG;AACI,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE7C,OAAO;QACL,CAAC,oCAAwB,CAAC,EAAE,gCAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI;QACP,GAAG,CAAC,IAAA,gCAAwB,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,sCAAsC,0CAajD;AAEF;;;;GAIG;AACH,SAAgB,yCAAyC,CACvD,OAAwB;IAExB,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,iCAAY,CAAC,EAAE,CAAC;AAC3D,CAAC;AAJD,8FAIC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\nimport type { UserStorageAccount } from './types';\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n const { name, nameLastUpdatedAt } = metadata;\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: name,\n ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),\n };\n};\n\n/**\n * Checks if the given internal account has the correct keyring type.\n * @param account - The internal account to check\n * @returns Returns true if the internal account has the correct keyring type, false otherwise.\n */\nexport function doesInternalAccountHaveCorrectKeyringType(\n account: InternalAccount,\n) {\n return account.metadata.keyring.type === KeyringTypes.hd;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,eAAe,WAGzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,eAAe,WAGzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,wBAAoB;AAGrB;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IACvD,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE7C,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,oBAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI;QACP,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,yCAAyC,CACvD,OAAwB;IAExB,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\nimport type { UserStorageAccount } from './types';\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n const { name, nameLastUpdatedAt } = metadata;\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: name,\n ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),\n };\n};\n\n/**\n * Checks if the given internal account has the correct keyring type.\n * @param account - The internal account to check\n * @returns Returns true if the internal account has the correct keyring type, false otherwise.\n */\nexport function doesInternalAccountHaveCorrectKeyringType(\n account: InternalAccount,\n) {\n return account.metadata.keyring.type === KeyringTypes.hd;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|