@metamask/profile-sync-controller 8.0.0 → 8.1.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 (46) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  3. package/dist/controllers/user-storage/UserStorageController.d.cts +2 -2
  4. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  5. package/dist/controllers/user-storage/UserStorageController.d.mts +2 -2
  6. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  7. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  8. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs +15 -7
  9. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs.map +1 -1
  10. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +6 -3
  11. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts.map +1 -1
  12. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +6 -3
  13. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts.map +1 -1
  14. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs +15 -7
  15. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs.map +1 -1
  16. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +8 -2
  17. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +1 -1
  18. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +4 -2
  19. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +1 -1
  20. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +4 -2
  21. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +1 -1
  22. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +8 -2
  23. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +1 -1
  24. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +11 -2
  25. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
  26. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
  27. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
  28. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +12 -3
  29. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
  30. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +3 -1
  31. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
  32. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +2 -0
  33. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
  34. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +2 -0
  35. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
  36. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +4 -2
  37. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
  38. package/dist/controllers/user-storage/account-syncing/utils.cjs +36 -6
  39. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
  40. package/dist/controllers/user-storage/account-syncing/utils.d.cts +14 -4
  41. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
  42. package/dist/controllers/user-storage/account-syncing/utils.d.mts +14 -4
  43. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
  44. package/dist/controllers/user-storage/account-syncing/utils.mjs +33 -4
  45. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
  46. package/package.json +2 -2
@@ -1 +1 @@
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;;;;;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;AAEF;;;;;GAKG;AACH,MAAM,UAAU,yCAAyC,CACvD,OAAwB;IAExB,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AACnE,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 *\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 *\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 === String(KeyringTypes.hd);\n}\n"]}
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;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAA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Y,EAAE,CAAC,IAAI,CACrE,+BAA+B,EAC/B;QACE,IAAI,EAAE,YAAY,CAAC,EAAE;QACrB,KAAK,EAAE,CAAC;KACT,EACD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,OAAO,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;IACrC,CAAC,CACF,CAAa,CAAC;IAEf,OAAO,oCAAoC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACxE,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 { AccountSyncingOptions, 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\n/**\n * Transforms a list of any internal accounts to a list of internal accounts that\n * have the correct keyring type and are from the primary SRP.\n *\n * @param internalAccountsList - The list of internal accounts\n * @param options - Parameters used for checking if the internal account is from the primary SRP\n * @returns Returns a list of internal accounts that have the correct keyring type and are from the primary SRP.\n */\nexport async function mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList(\n internalAccountsList: InternalAccount[],\n options: AccountSyncingOptions,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n const primarySRPHdKeyringAccountsAddresses = (await getMessenger().call(\n 'KeyringController:withKeyring',\n {\n type: KeyringTypes.hd,\n index: 0,\n },\n async (keyring) => {\n return await keyring.getAccounts();\n },\n )) as string[];\n\n return internalAccountsList.filter((account) =>\n primarySRPHdKeyringAccountsAddresses?.includes(account.address),\n );\n}\n\n/**\n * Checks if the given internal account is from the primary SRP and is from the HD keyring.\n *\n * @param account - The internal account to check\n * @param options - Parameters used for checking if the internal account is from the primary SRP\n * @returns Returns true if the internal account is from the primary SRP, false otherwise.\n */\nexport async function isInternalAccountFromPrimarySRPHdKeyring(\n account: InternalAccount,\n options: AccountSyncingOptions,\n): Promise<boolean> {\n if (account.metadata.keyring.type !== KeyringTypes.hd) {\n return false;\n }\n\n const { getMessenger } = options;\n\n const primarySRPHdKeyringAccountsAddresses = (await getMessenger().call(\n 'KeyringController:withKeyring',\n {\n type: KeyringTypes.hd,\n index: 0,\n },\n async (keyring) => {\n return await keyring.getAccounts();\n },\n )) as string[];\n\n return primarySRPHdKeyringAccountsAddresses.includes(account.address);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/profile-sync-controller",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "The profile sync helps developers synchronize data across multiple clients and devices in a privacy-preserving way. All data saved in the user storage database is encrypted client-side to preserve privacy. The user storage provides a modular design, giving developers the flexibility to construct and manage their storage spaces in a way that best suits their needs",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -102,7 +102,7 @@
102
102
  "dependencies": {
103
103
  "@metamask/base-controller": "^8.0.0",
104
104
  "@metamask/keyring-api": "^17.0.0",
105
- "@metamask/keyring-controller": "^19.1.0",
105
+ "@metamask/keyring-controller": "^19.2.0",
106
106
  "@metamask/network-controller": "^22.2.1",
107
107
  "@metamask/snaps-sdk": "^6.17.1",
108
108
  "@metamask/snaps-utils": "^8.10.0",