@metamask-previews/profile-sync-controller 24.0.0-preview-e94ec490 → 24.0.0-preview-b13da658

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/controllers/user-storage/UserStorageController.cjs +4 -80
  3. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  4. package/dist/controllers/user-storage/UserStorageController.d.cts +5 -54
  5. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  6. package/dist/controllers/user-storage/UserStorageController.d.mts +5 -54
  7. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  8. package/dist/controllers/user-storage/UserStorageController.mjs +0 -76
  9. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  10. package/dist/controllers/user-storage/constants.cjs +0 -3
  11. package/dist/controllers/user-storage/constants.cjs.map +1 -1
  12. package/dist/controllers/user-storage/constants.d.cts +0 -2
  13. package/dist/controllers/user-storage/constants.d.cts.map +1 -1
  14. package/dist/controllers/user-storage/constants.d.mts +0 -2
  15. package/dist/controllers/user-storage/constants.d.mts.map +1 -1
  16. package/dist/controllers/user-storage/constants.mjs +0 -3
  17. package/dist/controllers/user-storage/constants.mjs.map +1 -1
  18. package/package.json +1 -3
  19. package/dist/controllers/user-storage/account-syncing/constants.cjs +0 -51
  20. package/dist/controllers/user-storage/account-syncing/constants.cjs.map +0 -1
  21. package/dist/controllers/user-storage/account-syncing/constants.d.cts +0 -4
  22. package/dist/controllers/user-storage/account-syncing/constants.d.cts.map +0 -1
  23. package/dist/controllers/user-storage/account-syncing/constants.d.mts +0 -4
  24. package/dist/controllers/user-storage/account-syncing/constants.d.mts.map +0 -1
  25. package/dist/controllers/user-storage/account-syncing/constants.mjs +0 -48
  26. package/dist/controllers/user-storage/account-syncing/constants.mjs.map +0 -1
  27. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +0 -271
  28. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +0 -1
  29. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +0 -38
  30. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +0 -1
  31. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +0 -38
  32. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +0 -1
  33. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +0 -265
  34. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +0 -1
  35. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +0 -41
  36. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +0 -1
  37. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +0 -8
  38. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +0 -1
  39. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +0 -8
  40. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +0 -1
  41. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +0 -37
  42. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +0 -1
  43. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +0 -61
  44. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +0 -1
  45. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +0 -30
  46. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +0 -1
  47. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +0 -30
  48. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +0 -1
  49. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +0 -55
  50. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +0 -1
  51. package/dist/controllers/user-storage/account-syncing/types.cjs +0 -3
  52. package/dist/controllers/user-storage/account-syncing/types.cjs.map +0 -1
  53. package/dist/controllers/user-storage/account-syncing/types.d.cts +0 -25
  54. package/dist/controllers/user-storage/account-syncing/types.d.cts.map +0 -1
  55. package/dist/controllers/user-storage/account-syncing/types.d.mts +0 -25
  56. package/dist/controllers/user-storage/account-syncing/types.d.mts.map +0 -1
  57. package/dist/controllers/user-storage/account-syncing/types.mjs +0 -2
  58. package/dist/controllers/user-storage/account-syncing/types.mjs.map +0 -1
  59. package/dist/controllers/user-storage/account-syncing/utils.cjs +0 -36
  60. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +0 -1
  61. package/dist/controllers/user-storage/account-syncing/utils.d.cts +0 -18
  62. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +0 -1
  63. package/dist/controllers/user-storage/account-syncing/utils.d.mts +0 -18
  64. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +0 -1
  65. package/dist/controllers/user-storage/account-syncing/utils.mjs +0 -31
  66. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +0 -1
@@ -1,55 +0,0 @@
1
- import { KeyringTypes } from "@metamask/keyring-controller";
2
- import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
3
- /**
4
- * Checks if account syncing can be performed based on a set of conditions
5
- *
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(options) {
10
- const { getMessenger, getUserStorageControllerInstance } = options;
11
- const { isBackupAndSyncEnabled, isAccountSyncingEnabled, isAccountSyncingInProgress, } = getUserStorageControllerInstance().state;
12
- const isAuthEnabled = getMessenger().call('AuthenticationController:isSignedIn');
13
- if (!isBackupAndSyncEnabled ||
14
- !isAccountSyncingEnabled ||
15
- !isAuthEnabled ||
16
- isAccountSyncingInProgress) {
17
- return false;
18
- }
19
- return true;
20
- }
21
- /**
22
- * Get the list of internal accounts
23
- * This function returns only the internal accounts that are from the primary SRP
24
- * and are from the HD keyring
25
- *
26
- * @param options - parameters used for getting the list of internal accounts
27
- * @param entropySourceId - The entropy source ID used to derive the key,
28
- * when multiple sources are available (Multi-SRP).
29
- * @returns the list of internal accounts
30
- */
31
- export async function getInternalAccountsList(options, entropySourceId) {
32
- const { getMessenger } = options;
33
- let internalAccountsList = getMessenger().call('AccountsController:listAccounts');
34
- const doEachInternalAccountHaveEntropySource = internalAccountsList.every((account) => Boolean(account.options.entropySource));
35
- if (!doEachInternalAccountHaveEntropySource) {
36
- await getMessenger().call('AccountsController:updateAccounts');
37
- internalAccountsList = getMessenger().call('AccountsController:listAccounts');
38
- }
39
- return internalAccountsList.filter((account) => entropySourceId === account.options.entropySource &&
40
- account.metadata.keyring.type === String(KeyringTypes.hd));
41
- }
42
- /**
43
- * Get the list of user storage accounts
44
- *
45
- * @param options - parameters used for getting the list of user storage accounts
46
- * @param entropySourceId - The entropy source ID used to derive the storage key,
47
- * when multiple sources are available (Multi-SRP).
48
- * @returns the list of user storage accounts
49
- */
50
- export async function getUserStorageAccountsList(options, entropySourceId) {
51
- const { getUserStorageControllerInstance } = options;
52
- const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(USER_STORAGE_FEATURE_NAMES.accounts, entropySourceId);
53
- return (rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null);
54
- }
55
- //# 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":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,0BAA0B,EAAE,2CAAuC;AAE5E;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EACJ,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,GAC3B,GAAG,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC7C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,sBAAsB;QACvB,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAA8B,EAC9B,eAAuB;IAEvB,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC,IAAI,CAC5C,iCAAiC,CAClC,CAAC;IAEF,MAAM,sCAAsC,GAAG,oBAAoB,CAAC,KAAK,CACvE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CACpD,CAAC;IAEF,IAAI,CAAC,sCAAsC,EAAE;QAC3C,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC/D,oBAAoB,GAAG,YAAY,EAAE,CAAC,IAAI,CACxC,iCAAiC,CAClC,CAAC;KACH;IAED,OAAO,oBAAoB,CAAC,MAAM,CAChC,CAAC,OAAO,EAAE,EAAE,CACV,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,aAAa;QACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAA8B,EAC9B,eAAwB;IAExB,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,0BAA0B,CAAC,QAAQ,EACnC,eAAe,CAChB,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 { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountSyncingOptions, UserStorageAccount } from './types';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n *\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 options: AccountSyncingOptions,\n): boolean {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const {\n isBackupAndSyncEnabled,\n isAccountSyncingEnabled,\n isAccountSyncingInProgress,\n } = getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isBackupAndSyncEnabled ||\n !isAccountSyncingEnabled ||\n !isAuthEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n * This function returns only the internal accounts that are from the primary SRP\n * and are from the HD keyring\n *\n * @param options - parameters used for getting the list of internal accounts\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n entropySourceId: string,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n let internalAccountsList = getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n const doEachInternalAccountHaveEntropySource = internalAccountsList.every(\n (account) => Boolean(account.options.entropySource),\n );\n\n if (!doEachInternalAccountHaveEntropySource) {\n await getMessenger().call('AccountsController:updateAccounts');\n internalAccountsList = getMessenger().call(\n 'AccountsController:listAccounts',\n );\n }\n\n return internalAccountsList.filter(\n (account) =>\n entropySourceId === account.options.entropySource &&\n account.metadata.keyring.type === String(KeyringTypes.hd), // sync only EVM accounts until we support multichain accounts\n );\n}\n\n/**\n * Get the list of user storage accounts\n *\n * @param options - parameters used for getting the list of user storage accounts\n * @param entropySourceId - The entropy source ID used to derive the storage key,\n * when multiple sources are available (Multi-SRP).\n * @returns the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n entropySourceId?: string,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n entropySourceId,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceCallback } from '@metamask/controller-utils';\n\nimport type {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from './constants';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\nimport type UserStorageController from '../UserStorageController';\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 AccountSyncingOptions = {\n getUserStorageControllerInstance: () => UserStorageController;\n getMessenger: () => UserStorageControllerMessenger;\n trace?: TraceCallback;\n};\n"]}
@@ -1,25 +0,0 @@
1
- import type { TraceCallback } from "@metamask/controller-utils";
2
- import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.cjs";
3
- import type { UserStorageControllerMessenger } from "../UserStorageController.cjs";
4
- import type UserStorageController from "../UserStorageController.cjs";
5
- export type UserStorageAccount = {
6
- /**
7
- * The Version 'v' of the User Storage.
8
- * NOTE - will allow us to support upgrade/downgrades in the future
9
- */
10
- [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;
11
- /** the id 'i' of the account */
12
- i: string;
13
- /** the address 'a' of the account */
14
- a: string;
15
- /** the name 'n' of the account */
16
- n: string;
17
- /** the nameLastUpdatedAt timestamp 'nlu' of the account */
18
- nlu?: number;
19
- };
20
- export type AccountSyncingOptions = {
21
- getUserStorageControllerInstance: () => UserStorageController;
22
- getMessenger: () => UserStorageControllerMessenger;
23
- trace?: TraceCallback;
24
- };
25
- //# 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,aAAa,EAAE,mCAAmC;AAEhE,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,wBAAoB;AACrB,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAC/E,OAAO,KAAK,qBAAqB,qCAAiC;AAElE,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,qBAAqB,GAAG;IAClC,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;IAC9D,YAAY,EAAE,MAAM,8BAA8B,CAAC;IACnD,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { TraceCallback } from "@metamask/controller-utils";
2
- import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.mjs";
3
- import type { UserStorageControllerMessenger } from "../UserStorageController.mjs";
4
- import type UserStorageController from "../UserStorageController.mjs";
5
- export type UserStorageAccount = {
6
- /**
7
- * The Version 'v' of the User Storage.
8
- * NOTE - will allow us to support upgrade/downgrades in the future
9
- */
10
- [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;
11
- /** the id 'i' of the account */
12
- i: string;
13
- /** the address 'a' of the account */
14
- a: string;
15
- /** the name 'n' of the account */
16
- n: string;
17
- /** the nameLastUpdatedAt timestamp 'nlu' of the account */
18
- nlu?: number;
19
- };
20
- export type AccountSyncingOptions = {
21
- getUserStorageControllerInstance: () => UserStorageController;
22
- getMessenger: () => UserStorageControllerMessenger;
23
- trace?: TraceCallback;
24
- };
25
- //# 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,aAAa,EAAE,mCAAmC;AAEhE,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,wBAAoB;AACrB,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAC/E,OAAO,KAAK,qBAAqB,qCAAiC;AAElE,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,qBAAqB,GAAG;IAClC,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;IAC9D,YAAY,EAAE,MAAM,8BAA8B,CAAC;IACnD,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceCallback } from '@metamask/controller-utils';\n\nimport type {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from './constants';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\nimport type UserStorageController from '../UserStorageController';\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 AccountSyncingOptions = {\n getUserStorageControllerInstance: () => UserStorageController;\n getMessenger: () => UserStorageControllerMessenger;\n trace?: TraceCallback;\n};\n"]}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapInternalAccountToUserStorageAccount = exports.isNameDefaultAccountName = void 0;
4
- const constants_1 = require("./constants.cjs");
5
- /**
6
- * Tells if the given name is a default account name.
7
- * Default account names are localized names that are automatically generated by the clients.
8
- *
9
- * @param name - the name to check
10
- * @returns true if the name is a default account name, false otherwise
11
- */
12
- const isNameDefaultAccountName = (name) => {
13
- return constants_1.LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {
14
- return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);
15
- });
16
- };
17
- exports.isNameDefaultAccountName = isNameDefaultAccountName;
18
- /**
19
- * Map an internal account to a user storage account
20
- *
21
- * @param internalAccount - An internal account
22
- * @returns A user storage account
23
- */
24
- const mapInternalAccountToUserStorageAccount = (internalAccount) => {
25
- const { address, id, metadata } = internalAccount;
26
- const { name, nameLastUpdatedAt } = metadata;
27
- return {
28
- [constants_1.USER_STORAGE_VERSION_KEY]: constants_1.USER_STORAGE_VERSION,
29
- a: address,
30
- i: id,
31
- n: name,
32
- ...((0, exports.isNameDefaultAccountName)(name) ? {} : { nlu: nameLastUpdatedAt }),
33
- };
34
- };
35
- exports.mapInternalAccountToUserStorageAccount = mapInternalAccountToUserStorageAccount;
36
- //# sourceMappingURL=utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":";;;AAEA,+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;;;;;GAKG;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","sourcesContent":["import 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 *\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"]}
@@ -1,18 +0,0 @@
1
- import type { InternalAccount } from "@metamask/keyring-internal-api";
2
- import type { UserStorageAccount } from "./types.cjs";
3
- /**
4
- * Tells if the given name is a default account name.
5
- * Default account names are localized names that are automatically generated by the clients.
6
- *
7
- * @param name - the name to check
8
- * @returns true if the name is a default account name, false otherwise
9
- */
10
- export declare const isNameDefaultAccountName: (name: string) => boolean;
11
- /**
12
- * Map an internal account to a user storage account
13
- *
14
- * @param internalAccount - An internal account
15
- * @returns A user storage account
16
- */
17
- export declare const mapInternalAccountToUserStorageAccount: (internalAccount: InternalAccount) => UserStorageAccount;
18
- //# sourceMappingURL=utils.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC"}
@@ -1,18 +0,0 @@
1
- import type { InternalAccount } from "@metamask/keyring-internal-api";
2
- import type { UserStorageAccount } from "./types.mjs";
3
- /**
4
- * Tells if the given name is a default account name.
5
- * Default account names are localized names that are automatically generated by the clients.
6
- *
7
- * @param name - the name to check
8
- * @returns true if the name is a default account name, false otherwise
9
- */
10
- export declare const isNameDefaultAccountName: (name: string) => boolean;
11
- /**
12
- * Map an internal account to a user storage account
13
- *
14
- * @param internalAccount - An internal account
15
- * @returns A user storage account
16
- */
17
- export declare const mapInternalAccountToUserStorageAccount: (internalAccount: InternalAccount) => UserStorageAccount;
18
- //# sourceMappingURL=utils.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC"}
@@ -1,31 +0,0 @@
1
- import { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION, LOCALIZED_DEFAULT_ACCOUNT_NAMES } from "./constants.mjs";
2
- /**
3
- * Tells if the given name is a default account name.
4
- * Default account names are localized names that are automatically generated by the clients.
5
- *
6
- * @param name - the name to check
7
- * @returns true if the name is a default account name, false otherwise
8
- */
9
- export const isNameDefaultAccountName = (name) => {
10
- return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {
11
- return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);
12
- });
13
- };
14
- /**
15
- * Map an internal account to a user storage account
16
- *
17
- * @param internalAccount - An internal account
18
- * @returns A user storage account
19
- */
20
- export const mapInternalAccountToUserStorageAccount = (internalAccount) => {
21
- const { address, id, metadata } = internalAccount;
22
- const { name, nameLastUpdatedAt } = metadata;
23
- return {
24
- [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,
25
- a: address,
26
- i: id,
27
- n: name,
28
- ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),
29
- };
30
- };
31
- //# sourceMappingURL=utils.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAEA,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;;;;;GAKG;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","sourcesContent":["import 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 *\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"]}