@metamask/profile-sync-controller 23.0.0 → 25.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/dist/controllers/authentication/AuthenticationController.cjs +4 -0
  3. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  4. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  5. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  6. package/dist/controllers/authentication/AuthenticationController.mjs +4 -0
  7. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  8. package/dist/controllers/user-storage/UserStorageController.cjs +14 -87
  9. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  10. package/dist/controllers/user-storage/UserStorageController.d.cts +3 -52
  11. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  12. package/dist/controllers/user-storage/UserStorageController.d.mts +3 -52
  13. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  14. package/dist/controllers/user-storage/UserStorageController.mjs +10 -83
  15. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  16. package/dist/controllers/user-storage/constants.cjs +0 -3
  17. package/dist/controllers/user-storage/constants.cjs.map +1 -1
  18. package/dist/controllers/user-storage/constants.d.cts +0 -2
  19. package/dist/controllers/user-storage/constants.d.cts.map +1 -1
  20. package/dist/controllers/user-storage/constants.d.mts +0 -2
  21. package/dist/controllers/user-storage/constants.d.mts.map +1 -1
  22. package/dist/controllers/user-storage/constants.mjs +0 -3
  23. package/dist/controllers/user-storage/constants.mjs.map +1 -1
  24. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +28 -2
  25. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  26. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  27. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  28. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +28 -2
  29. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  30. package/package.json +10 -10
  31. package/dist/controllers/user-storage/account-syncing/constants.cjs +0 -51
  32. package/dist/controllers/user-storage/account-syncing/constants.cjs.map +0 -1
  33. package/dist/controllers/user-storage/account-syncing/constants.d.cts +0 -4
  34. package/dist/controllers/user-storage/account-syncing/constants.d.cts.map +0 -1
  35. package/dist/controllers/user-storage/account-syncing/constants.d.mts +0 -4
  36. package/dist/controllers/user-storage/account-syncing/constants.d.mts.map +0 -1
  37. package/dist/controllers/user-storage/account-syncing/constants.mjs +0 -48
  38. package/dist/controllers/user-storage/account-syncing/constants.mjs.map +0 -1
  39. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +0 -253
  40. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +0 -1
  41. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +0 -38
  42. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +0 -1
  43. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +0 -38
  44. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +0 -1
  45. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +0 -247
  46. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +0 -1
  47. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +0 -35
  48. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +0 -1
  49. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +0 -8
  50. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +0 -1
  51. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +0 -8
  52. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +0 -1
  53. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +0 -31
  54. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +0 -1
  55. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +0 -61
  56. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +0 -1
  57. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +0 -30
  58. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +0 -1
  59. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +0 -30
  60. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +0 -1
  61. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +0 -55
  62. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +0 -1
  63. package/dist/controllers/user-storage/account-syncing/types.cjs +0 -3
  64. package/dist/controllers/user-storage/account-syncing/types.cjs.map +0 -1
  65. package/dist/controllers/user-storage/account-syncing/types.d.cts +0 -25
  66. package/dist/controllers/user-storage/account-syncing/types.d.cts.map +0 -1
  67. package/dist/controllers/user-storage/account-syncing/types.d.mts +0 -25
  68. package/dist/controllers/user-storage/account-syncing/types.d.mts.map +0 -1
  69. package/dist/controllers/user-storage/account-syncing/types.mjs +0 -2
  70. package/dist/controllers/user-storage/account-syncing/types.mjs.map +0 -1
  71. package/dist/controllers/user-storage/account-syncing/utils.cjs +0 -36
  72. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +0 -1
  73. package/dist/controllers/user-storage/account-syncing/utils.d.cts +0 -18
  74. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +0 -1
  75. package/dist/controllers/user-storage/account-syncing/utils.d.mts +0 -18
  76. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +0 -1
  77. package/dist/controllers/user-storage/account-syncing/utils.mjs +0 -31
  78. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +0 -1
@@ -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"]}