@metamask/profile-sync-controller 3.1.0 → 3.2.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 (110) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/controllers/authentication/services.cjs +10 -3
  3. package/dist/controllers/authentication/services.cjs.map +1 -1
  4. package/dist/controllers/authentication/services.d.cts.map +1 -1
  5. package/dist/controllers/authentication/services.d.mts.map +1 -1
  6. package/dist/controllers/authentication/services.mjs +14 -3
  7. package/dist/controllers/authentication/services.mjs.map +1 -1
  8. package/dist/controllers/user-storage/UserStorageController.cjs +39 -218
  9. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  10. package/dist/controllers/user-storage/UserStorageController.d.cts +7 -2
  11. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  12. package/dist/controllers/user-storage/UserStorageController.d.mts +7 -2
  13. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  14. package/dist/controllers/user-storage/UserStorageController.mjs +36 -216
  15. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  16. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +1 -1
  17. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +1 -1
  18. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +45 -1
  19. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -1
  20. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +21 -0
  21. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -1
  22. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +21 -0
  23. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -1
  24. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +38 -0
  25. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -1
  26. package/dist/controllers/user-storage/{__fixtures__ → account-syncing/__fixtures__}/mockAccounts.cjs +3 -3
  27. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +1 -0
  28. package/dist/controllers/user-storage/{__fixtures__ → account-syncing/__fixtures__}/mockAccounts.d.cts +6 -6
  29. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +1 -0
  30. package/dist/controllers/user-storage/{__fixtures__ → account-syncing/__fixtures__}/mockAccounts.d.mts +6 -6
  31. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +1 -0
  32. package/dist/controllers/user-storage/{__fixtures__ → account-syncing/__fixtures__}/mockAccounts.mjs +3 -4
  33. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +1 -0
  34. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +50 -0
  35. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +1 -0
  36. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +85 -0
  37. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +1 -0
  38. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +85 -0
  39. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +1 -0
  40. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +44 -0
  41. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +1 -0
  42. package/dist/controllers/user-storage/account-syncing/constants.cjs.map +1 -0
  43. package/dist/controllers/user-storage/account-syncing/constants.d.cts.map +1 -0
  44. package/dist/controllers/user-storage/account-syncing/constants.d.mts.map +1 -0
  45. package/dist/controllers/user-storage/account-syncing/constants.mjs.map +1 -0
  46. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +194 -0
  47. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -0
  48. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +31 -0
  49. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -0
  50. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +31 -0
  51. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -0
  52. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +188 -0
  53. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -0
  54. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +35 -0
  55. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +1 -0
  56. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +8 -0
  57. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +1 -0
  58. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +8 -0
  59. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +1 -0
  60. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +31 -0
  61. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +1 -0
  62. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +47 -0
  63. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -0
  64. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +20 -0
  65. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -0
  66. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +20 -0
  67. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -0
  68. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +41 -0
  69. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -0
  70. package/dist/controllers/user-storage/account-syncing/types.cjs +3 -0
  71. package/dist/controllers/user-storage/account-syncing/types.cjs.map +1 -0
  72. package/dist/controllers/user-storage/account-syncing/types.d.cts +26 -0
  73. package/dist/controllers/user-storage/account-syncing/types.d.cts.map +1 -0
  74. package/dist/controllers/user-storage/account-syncing/types.d.mts +26 -0
  75. package/dist/controllers/user-storage/account-syncing/types.d.mts.map +1 -0
  76. package/dist/controllers/user-storage/account-syncing/types.mjs +2 -0
  77. package/dist/controllers/user-storage/account-syncing/types.mjs.map +1 -0
  78. package/dist/controllers/user-storage/{accounts/user-storage.cjs → account-syncing/utils.cjs} +12 -2
  79. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -0
  80. package/dist/controllers/user-storage/account-syncing/utils.d.cts +23 -0
  81. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -0
  82. package/dist/controllers/user-storage/account-syncing/utils.d.mts +23 -0
  83. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -0
  84. package/dist/controllers/user-storage/{accounts/user-storage.mjs → account-syncing/utils.mjs} +10 -1
  85. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -0
  86. package/dist/controllers/user-storage/services.cjs +10 -10
  87. package/dist/controllers/user-storage/services.cjs.map +1 -1
  88. package/dist/controllers/user-storage/services.d.cts.map +1 -1
  89. package/dist/controllers/user-storage/services.d.mts.map +1 -1
  90. package/dist/controllers/user-storage/services.mjs +10 -10
  91. package/dist/controllers/user-storage/services.mjs.map +1 -1
  92. package/package.json +6 -5
  93. package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +0 -1
  94. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +0 -1
  95. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +0 -1
  96. package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +0 -1
  97. package/dist/controllers/user-storage/accounts/constants.cjs.map +0 -1
  98. package/dist/controllers/user-storage/accounts/constants.d.cts.map +0 -1
  99. package/dist/controllers/user-storage/accounts/constants.d.mts.map +0 -1
  100. package/dist/controllers/user-storage/accounts/constants.mjs.map +0 -1
  101. package/dist/controllers/user-storage/accounts/user-storage.cjs.map +0 -1
  102. package/dist/controllers/user-storage/accounts/user-storage.d.cts +0 -32
  103. package/dist/controllers/user-storage/accounts/user-storage.d.cts.map +0 -1
  104. package/dist/controllers/user-storage/accounts/user-storage.d.mts +0 -32
  105. package/dist/controllers/user-storage/accounts/user-storage.d.mts.map +0 -1
  106. package/dist/controllers/user-storage/accounts/user-storage.mjs.map +0 -1
  107. /package/dist/controllers/user-storage/{accounts → account-syncing}/constants.cjs +0 -0
  108. /package/dist/controllers/user-storage/{accounts → account-syncing}/constants.d.cts +0 -0
  109. /package/dist/controllers/user-storage/{accounts → account-syncing}/constants.d.mts +0 -0
  110. /package/dist/controllers/user-storage/{accounts → account-syncing}/constants.mjs +0 -0
@@ -1,6 +1,50 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitFor = void 0;
6
+ exports.waitFor = exports.decryptBatchUpsertBody = exports.createMockUserStorageEntries = exports.createMockUserStorageEntry = void 0;
7
+ const encryption_1 = __importDefault(require("../../../shared/encryption/encryption.cjs"));
8
+ const mockStorage_1 = require("./mockStorage.cjs");
9
+ /**
10
+ * Test Utility - creates a realistic mock user-storage entry
11
+ * @param data - data to encrypt
12
+ * @returns user storage entry
13
+ */
14
+ async function createMockUserStorageEntry(data) {
15
+ return {
16
+ HashedKey: 'HASHED_KEY',
17
+ Data: await encryption_1.default.encryptString(JSON.stringify(data), mockStorage_1.MOCK_STORAGE_KEY),
18
+ };
19
+ }
20
+ exports.createMockUserStorageEntry = createMockUserStorageEntry;
21
+ /**
22
+ * Test Utility - creates a realistic mock user-storage get-all entry
23
+ * @param data - data array to encrypt
24
+ * @returns user storage entry
25
+ */
26
+ async function createMockUserStorageEntries(data) {
27
+ return await Promise.all(data.map((d) => createMockUserStorageEntry(d)));
28
+ }
29
+ exports.createMockUserStorageEntries = createMockUserStorageEntries;
30
+ /**
31
+ * Test Utility - decrypts a realistic batch upsert payload
32
+ * @param requestBody - nock body
33
+ * @param storageKey - storage key
34
+ * @returns decrypted body
35
+ */
36
+ async function decryptBatchUpsertBody(requestBody, storageKey) {
37
+ if (typeof requestBody === 'string') {
38
+ return requestBody;
39
+ }
40
+ return await Promise.all(Object.entries(requestBody.data).map(async ([entryKey, entryValue]) => {
41
+ return [
42
+ entryKey,
43
+ await encryption_1.default.decryptString(entryValue, storageKey),
44
+ ];
45
+ }));
46
+ }
47
+ exports.decryptBatchUpsertBody = decryptBatchUpsertBody;
4
48
  /**
5
49
  * Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.
6
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACI,MAAM,OAAO,GAAG,KAAK,EAC1B,WAAuB,EACvB,UAA0B,EAAE,EACb,EAAE;IACjB,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEtD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAClC,IAAI;gBACF,WAAW,EAAE,CAAC;gBACd,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,OAAO,EAAE,CAAC;aACX;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,SAAS,EAAE;oBACvC,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,SAAS,IAAI,CAAC,CAAC,CAAC;iBACpE;aACF;QACH,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,OAAO,WAsBlB","sourcesContent":["type WaitForOptions = {\n intervalMs?: number;\n timeoutMs?: number;\n};\n\n/**\n * Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.\n *\n * @param assertionFn - assertion function\n * @param options - set wait for options\n * @returns promise that you need to await in tests\n */\nexport const waitFor = async (\n assertionFn: () => void,\n options: WaitForOptions = {},\n): Promise<void> => {\n const { intervalMs = 50, timeoutMs = 2000 } = options;\n\n const startTime = Date.now();\n\n return new Promise<void>((resolve, reject) => {\n const intervalId = setInterval(() => {\n try {\n assertionFn();\n clearInterval(intervalId);\n resolve();\n } catch (error) {\n if (Date.now() - startTime >= timeoutMs) {\n clearInterval(intervalId);\n reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));\n }\n }\n }, intervalMs);\n });\n};\n"]}
1
+ {"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;;;;AAEA,2FAA+D;AAK/D,mDAAiD;AAEjD;;;;GAIG;AACI,KAAK,UAAU,0BAA0B,CAC9C,IAAa;IAEb,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,IAAI,EAAE,MAAM,oBAAU,CAAC,aAAa,CAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EACpB,8BAAgB,CACjB;KACF,CAAC;AACJ,CAAC;AAVD,gEAUC;AAED;;;;GAIG;AACI,KAAK,UAAU,4BAA4B,CAChD,IAAe;IAEf,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC;AAJD,oEAIC;AAED;;;;;GAKG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAsB,EACtB,UAAkB;IAElB,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,MAAM,CAAC,OAAO,CAAS,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAC1C,KAAK,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE;QAC/B,OAAO;YACL,QAAQ;YACR,MAAM,oBAAU,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC;SACvD,CAAC;IACJ,CAAC,CACF,CACF,CAAC;AACJ,CAAC;AAjBD,wDAiBC;AAOD;;;;;;GAMG;AACI,MAAM,OAAO,GAAG,KAAK,EAC1B,WAAuB,EACvB,UAA0B,EAAE,EACb,EAAE;IACjB,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEtD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAClC,IAAI;gBACF,WAAW,EAAE,CAAC;gBACd,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,OAAO,EAAE,CAAC;aACX;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,SAAS,EAAE;oBACvC,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,SAAS,IAAI,CAAC,CAAC,CAAC;iBACpE;aACF;QACH,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,OAAO,WAsBlB","sourcesContent":["import type nock from 'nock';\n\nimport encryption from '../../../shared/encryption/encryption';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { MOCK_STORAGE_KEY } from './mockStorage';\n\n/**\n * Test Utility - creates a realistic mock user-storage entry\n * @param data - data to encrypt\n * @returns user storage entry\n */\nexport async function createMockUserStorageEntry(\n data: unknown,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await encryption.encryptString(\n JSON.stringify(data),\n MOCK_STORAGE_KEY,\n ),\n };\n}\n\n/**\n * Test Utility - creates a realistic mock user-storage get-all entry\n * @param data - data array to encrypt\n * @returns user storage entry\n */\nexport async function createMockUserStorageEntries(\n data: unknown[],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n return await Promise.all(data.map((d) => createMockUserStorageEntry(d)));\n}\n\n/**\n * Test Utility - decrypts a realistic batch upsert payload\n * @param requestBody - nock body\n * @param storageKey - storage key\n * @returns decrypted body\n */\nexport async function decryptBatchUpsertBody(\n requestBody: nock.Body,\n storageKey: string,\n) {\n if (typeof requestBody === 'string') {\n return requestBody;\n }\n return await Promise.all(\n Object.entries<string>(requestBody.data).map(\n async ([entryKey, entryValue]) => {\n return [\n entryKey,\n await encryption.decryptString(entryValue, storageKey),\n ];\n },\n ),\n );\n}\n\ntype WaitForOptions = {\n intervalMs?: number;\n timeoutMs?: number;\n};\n\n/**\n * Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.\n *\n * @param assertionFn - assertion function\n * @param options - set wait for options\n * @returns promise that you need to await in tests\n */\nexport const waitFor = async (\n assertionFn: () => void,\n options: WaitForOptions = {},\n): Promise<void> => {\n const { intervalMs = 50, timeoutMs = 2000 } = options;\n\n const startTime = Date.now();\n\n return new Promise<void>((resolve, reject) => {\n const intervalId = setInterval(() => {\n try {\n assertionFn();\n clearInterval(intervalId);\n resolve();\n } catch (error) {\n if (Date.now() - startTime >= timeoutMs) {\n clearInterval(intervalId);\n reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));\n }\n }\n }, intervalMs);\n });\n};\n"]}
@@ -1,3 +1,24 @@
1
+ import type nock from "nock";
2
+ import type { GetUserStorageAllFeatureEntriesResponse, GetUserStorageResponse } from "../services.cjs";
3
+ /**
4
+ * Test Utility - creates a realistic mock user-storage entry
5
+ * @param data - data to encrypt
6
+ * @returns user storage entry
7
+ */
8
+ export declare function createMockUserStorageEntry(data: unknown): Promise<GetUserStorageResponse>;
9
+ /**
10
+ * Test Utility - creates a realistic mock user-storage get-all entry
11
+ * @param data - data array to encrypt
12
+ * @returns user storage entry
13
+ */
14
+ export declare function createMockUserStorageEntries(data: unknown[]): Promise<GetUserStorageAllFeatureEntriesResponse>;
15
+ /**
16
+ * Test Utility - decrypts a realistic batch upsert payload
17
+ * @param requestBody - nock body
18
+ * @param storageKey - storage key
19
+ * @returns decrypted body
20
+ */
21
+ export declare function decryptBatchUpsertBody(requestBody: nock.Body, storageKey: string): Promise<string | string[][]>;
1
22
  type WaitForOptions = {
2
23
  intervalMs?: number;
3
24
  timeoutMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,gBACL,MAAM,IAAI,YACd,cAAc,KACtB,QAAQ,IAAI,CAmBd,CAAC"}
1
+ {"version":3,"file":"test-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,aAAa;AAG7B,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAGrB;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAQjC;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAAC,uCAAuC,CAAC,CAElD;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,IAAI,CAAC,IAAI,EACtB,UAAU,EAAE,MAAM,gCAenB;AAED,KAAK,cAAc,GAAG;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,gBACL,MAAM,IAAI,YACd,cAAc,KACtB,QAAQ,IAAI,CAmBd,CAAC"}
@@ -1,3 +1,24 @@
1
+ import type nock from "nock";
2
+ import type { GetUserStorageAllFeatureEntriesResponse, GetUserStorageResponse } from "../services.mjs";
3
+ /**
4
+ * Test Utility - creates a realistic mock user-storage entry
5
+ * @param data - data to encrypt
6
+ * @returns user storage entry
7
+ */
8
+ export declare function createMockUserStorageEntry(data: unknown): Promise<GetUserStorageResponse>;
9
+ /**
10
+ * Test Utility - creates a realistic mock user-storage get-all entry
11
+ * @param data - data array to encrypt
12
+ * @returns user storage entry
13
+ */
14
+ export declare function createMockUserStorageEntries(data: unknown[]): Promise<GetUserStorageAllFeatureEntriesResponse>;
15
+ /**
16
+ * Test Utility - decrypts a realistic batch upsert payload
17
+ * @param requestBody - nock body
18
+ * @param storageKey - storage key
19
+ * @returns decrypted body
20
+ */
21
+ export declare function decryptBatchUpsertBody(requestBody: nock.Body, storageKey: string): Promise<string | string[][]>;
1
22
  type WaitForOptions = {
2
23
  intervalMs?: number;
3
24
  timeoutMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,gBACL,MAAM,IAAI,YACd,cAAc,KACtB,QAAQ,IAAI,CAmBd,CAAC"}
1
+ {"version":3,"file":"test-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,aAAa;AAG7B,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAGrB;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAQjC;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAAC,uCAAuC,CAAC,CAElD;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,IAAI,CAAC,IAAI,EACtB,UAAU,EAAE,MAAM,gCAenB;AAED,KAAK,cAAc,GAAG;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,gBACL,MAAM,IAAI,YACd,cAAc,KACtB,QAAQ,IAAI,CAmBd,CAAC"}
@@ -1,3 +1,41 @@
1
+ import encryption from "../../../shared/encryption/encryption.mjs";
2
+ import { MOCK_STORAGE_KEY } from "./mockStorage.mjs";
3
+ /**
4
+ * Test Utility - creates a realistic mock user-storage entry
5
+ * @param data - data to encrypt
6
+ * @returns user storage entry
7
+ */
8
+ export async function createMockUserStorageEntry(data) {
9
+ return {
10
+ HashedKey: 'HASHED_KEY',
11
+ Data: await encryption.encryptString(JSON.stringify(data), MOCK_STORAGE_KEY),
12
+ };
13
+ }
14
+ /**
15
+ * Test Utility - creates a realistic mock user-storage get-all entry
16
+ * @param data - data array to encrypt
17
+ * @returns user storage entry
18
+ */
19
+ export async function createMockUserStorageEntries(data) {
20
+ return await Promise.all(data.map((d) => createMockUserStorageEntry(d)));
21
+ }
22
+ /**
23
+ * Test Utility - decrypts a realistic batch upsert payload
24
+ * @param requestBody - nock body
25
+ * @param storageKey - storage key
26
+ * @returns decrypted body
27
+ */
28
+ export async function decryptBatchUpsertBody(requestBody, storageKey) {
29
+ if (typeof requestBody === 'string') {
30
+ return requestBody;
31
+ }
32
+ return await Promise.all(Object.entries(requestBody.data).map(async ([entryKey, entryValue]) => {
33
+ return [
34
+ entryKey,
35
+ await encryption.decryptString(entryValue, storageKey),
36
+ ];
37
+ }));
38
+ }
1
39
  /**
2
40
  * Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.
3
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,WAAuB,EACvB,UAA0B,EAAE,EACb,EAAE;IACjB,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEtD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAClC,IAAI;gBACF,WAAW,EAAE,CAAC;gBACd,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,OAAO,EAAE,CAAC;aACX;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,SAAS,EAAE;oBACvC,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,SAAS,IAAI,CAAC,CAAC,CAAC;iBACpE;aACF;QACH,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["type WaitForOptions = {\n intervalMs?: number;\n timeoutMs?: number;\n};\n\n/**\n * Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.\n *\n * @param assertionFn - assertion function\n * @param options - set wait for options\n * @returns promise that you need to await in tests\n */\nexport const waitFor = async (\n assertionFn: () => void,\n options: WaitForOptions = {},\n): Promise<void> => {\n const { intervalMs = 50, timeoutMs = 2000 } = options;\n\n const startTime = Date.now();\n\n return new Promise<void>((resolve, reject) => {\n const intervalId = setInterval(() => {\n try {\n assertionFn();\n clearInterval(intervalId);\n resolve();\n } catch (error) {\n if (Date.now() - startTime >= timeoutMs) {\n clearInterval(intervalId);\n reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));\n }\n }\n }, intervalMs);\n });\n};\n"]}
1
+ {"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,kDAA8C;AAK/D,OAAO,EAAE,gBAAgB,EAAE,0BAAsB;AAEjD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,IAAa;IAEb,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,IAAI,EAAE,MAAM,UAAU,CAAC,aAAa,CAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EACpB,gBAAgB,CACjB;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,IAAe;IAEf,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAsB,EACtB,UAAkB;IAElB,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,MAAM,CAAC,OAAO,CAAS,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAC1C,KAAK,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE;QAC/B,OAAO;YACL,QAAQ;YACR,MAAM,UAAU,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC;SACvD,CAAC;IACJ,CAAC,CACF,CACF,CAAC;AACJ,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,WAAuB,EACvB,UAA0B,EAAE,EACb,EAAE;IACjB,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEtD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAClC,IAAI;gBACF,WAAW,EAAE,CAAC;gBACd,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,OAAO,EAAE,CAAC;aACX;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,SAAS,EAAE;oBACvC,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,SAAS,IAAI,CAAC,CAAC,CAAC;iBACpE;aACF;QACH,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type nock from 'nock';\n\nimport encryption from '../../../shared/encryption/encryption';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { MOCK_STORAGE_KEY } from './mockStorage';\n\n/**\n * Test Utility - creates a realistic mock user-storage entry\n * @param data - data to encrypt\n * @returns user storage entry\n */\nexport async function createMockUserStorageEntry(\n data: unknown,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await encryption.encryptString(\n JSON.stringify(data),\n MOCK_STORAGE_KEY,\n ),\n };\n}\n\n/**\n * Test Utility - creates a realistic mock user-storage get-all entry\n * @param data - data array to encrypt\n * @returns user storage entry\n */\nexport async function createMockUserStorageEntries(\n data: unknown[],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n return await Promise.all(data.map((d) => createMockUserStorageEntry(d)));\n}\n\n/**\n * Test Utility - decrypts a realistic batch upsert payload\n * @param requestBody - nock body\n * @param storageKey - storage key\n * @returns decrypted body\n */\nexport async function decryptBatchUpsertBody(\n requestBody: nock.Body,\n storageKey: string,\n) {\n if (typeof requestBody === 'string') {\n return requestBody;\n }\n return await Promise.all(\n Object.entries<string>(requestBody.data).map(\n async ([entryKey, entryValue]) => {\n return [\n entryKey,\n await encryption.decryptString(entryValue, storageKey),\n ];\n },\n ),\n );\n}\n\ntype WaitForOptions = {\n intervalMs?: number;\n timeoutMs?: number;\n};\n\n/**\n * Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.\n *\n * @param assertionFn - assertion function\n * @param options - set wait for options\n * @returns promise that you need to await in tests\n */\nexport const waitFor = async (\n assertionFn: () => void,\n options: WaitForOptions = {},\n): Promise<void> => {\n const { intervalMs = 50, timeoutMs = 2000 } = options;\n\n const startTime = Date.now();\n\n return new Promise<void>((resolve, reject) => {\n const intervalId = setInterval(() => {\n try {\n assertionFn();\n clearInterval(intervalId);\n resolve();\n } catch (error) {\n if (Date.now() - startTime >= timeoutMs) {\n clearInterval(intervalId);\n reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));\n }\n }\n }, intervalMs);\n });\n};\n"]}
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MOCK_USER_STORAGE_ACCOUNTS = exports.MOCK_INTERNAL_ACCOUNTS = exports.getMockRandomDefaultAccountName = void 0;
4
4
  const keyring_api_1 = require("@metamask/keyring-api");
5
5
  const keyring_controller_1 = require("@metamask/keyring-controller");
6
- const constants_1 = require("../accounts/constants.cjs");
7
- const user_storage_1 = require("../accounts/user-storage.cjs");
6
+ const constants_1 = require("../constants.cjs");
7
+ const utils_1 = require("../utils.cjs");
8
8
  /**
9
9
  * Map an array of internal accounts to an array of user storage accounts
10
10
  * Only used for testing purposes
11
11
  * @param internalAccounts - An array of internal accounts
12
12
  * @returns An array of user storage accounts
13
13
  */
14
- const mapInternalAccountsListToUserStorageAccountsList = (internalAccounts) => internalAccounts.map(user_storage_1.mapInternalAccountToUserStorageAccount);
14
+ const mapInternalAccountsListToUserStorageAccountsList = (internalAccounts) => internalAccounts.map(utils_1.mapInternalAccountToUserStorageAccount);
15
15
  /**
16
16
  * Get a random default account name from the list of localized default account names
17
17
  * @returns A random default account name
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockAccounts.cjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,qEAA4D;AAG5D,gDAA+D;AAC/D,wCAAkE;AAElE;;;;;GAKG;AACH,MAAM,gDAAgD,GAAG,CACvD,gBAAmC,EACnC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,8CAAsC,CAAC,CAAC;AAElE;;;GAGG;AACI,MAAM,+BAA+B,GAAG,GAAG,EAAE,CAClD,2CAA+B,CAC7B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,2CAA+B,CAAC,MAAM,CAAC,CACnE,CAAC;AAHS,QAAA,+BAA+B,mCAGxC;AAES,QAAA,sBAAsB,GAAG;IACpC,KAAK,EAAE,EAAE;IACT,GAAG,EAAE;QACH;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,MAAM;gBACZ,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;IACD,gBAAgB,EAAE;QAChB;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,GAAG,IAAA,uCAA+B,GAAE,IAAI;gBAC9C,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;IACD,oCAAoC,EAAE;QACpC;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,wDAAwD;gBAC9D,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;IACD,iCAAiC,EAAE;QACjC;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,qDAAqD;gBAC3D,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;IACD,6CAA6C,EAAE;QAC7C;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,qDAAqD;gBAC3D,iBAAiB,EAAE,IAAI;gBACvB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;IACD,GAAG,EAAE;QACH;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,MAAM;gBACZ,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;QACD;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,WAAW;gBACjB,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;QACD;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;QACD;YACE,OAAO,EAAE,OAAO;YAChB,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,4BAAc,CAAC,GAAG;YACxB,QAAQ,EAAE;gBACR,IAAI,EAAE,cAAc;gBACpB,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,iCAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,0BAA0B,GAAG;IACxC,oBAAoB,EAAE,gDAAgD,CACpE,8BAAsB,CAAC,GAAwB,CAChD;IACD,GAAG,EAAE,gDAAgD,CACnD,8BAAsB,CAAC,GAAwB,CAChD;IACD,gCAAgC,EAC9B,gDAAgD,CAAC;QAC/C,GAAG,8BAAsB,CAAC,gBAAgB;QAC1C;YACE,GAAG,8BAAsB,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAC7C,OAAO,EAAE,UAAU;YACnB,QAAQ,EAAE;gBACR,IAAI,EAAE,GAAG,IAAA,uCAA+B,GAAE,IAAI;gBAC9C,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;IACzB,gBAAgB,EAAE,gDAAgD,CAChE,8BAAsB,CAAC,gBAAqC,CAC7D;IACD,oCAAoC,EAClC,gDAAgD,CAAC;QAC/C;YACE,GAAG,8BAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,4DAA4D;aACnE;SACF;KACmB,CAAC;IACzB,iCAAiC,EAC/B,gDAAgD,CAAC;QAC/C;YACE,GAAG,8BAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,yDAAyD;gBAC/D,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;CAC1B,CAAC","sourcesContent":["import { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from '../constants';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\n\n/**\n * Map an array of internal accounts to an array of user storage accounts\n * Only used for testing purposes\n * @param internalAccounts - An array of internal accounts\n * @returns An array of user storage accounts\n */\nconst mapInternalAccountsListToUserStorageAccountsList = (\n internalAccounts: InternalAccount[],\n) => internalAccounts.map(mapInternalAccountToUserStorageAccount);\n\n/**\n * Get a random default account name from the list of localized default account names\n * @returns A random default account name\n */\nexport const getMockRandomDefaultAccountName = () =>\n LOCALIZED_DEFAULT_ACCOUNT_NAMES[\n Math.floor(Math.random() * LOCALIZED_DEFAULT_ACCOUNT_NAMES.length)\n ];\n\nexport const MOCK_INTERNAL_ACCOUNTS = {\n EMPTY: [],\n ONE: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'test',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_DEFAULT_NAME: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: `${getMockRandomDefaultAccountName()} 1`,\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name without nameLastUpdatedAt',\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED_MOST_RECENT: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 9999,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ALL: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'test',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0x456',\n id: '2',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Account 2',\n nameLastUpdatedAt: 2,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0x789',\n id: '3',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Účet 2',\n nameLastUpdatedAt: 3,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0xabc',\n id: '4',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'My Account 4',\n nameLastUpdatedAt: 4,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n};\n\nexport const MOCK_USER_STORAGE_ACCOUNTS = {\n SAME_AS_INTERNAL_ALL: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ALL as InternalAccount[],\n ),\n ONE: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ONE as InternalAccount[],\n ),\n TWO_DEFAULT_NAMES_WITH_ONE_BOGUS:\n mapInternalAccountsListToUserStorageAccountsList([\n ...MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME,\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME[0],\n address: '0x000000',\n metadata: {\n name: `${getMockRandomDefaultAccountName()} 1`,\n nameLastUpdatedAt: 2,\n },\n },\n ] as InternalAccount[]),\n ONE_DEFAULT_NAME: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME as InternalAccount[],\n ),\n ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED:\n mapInternalAccountsListToUserStorageAccountsList([\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],\n metadata: {\n name: 'User storage account custom name without nameLastUpdatedAt',\n },\n },\n ] as InternalAccount[]),\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED:\n mapInternalAccountsListToUserStorageAccountsList([\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],\n metadata: {\n name: 'User storage account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 3,\n },\n },\n ] as InternalAccount[]),\n};\n"]}
@@ -80,11 +80,11 @@ export declare const MOCK_INTERNAL_ACCOUNTS: {
80
80
  }[];
81
81
  };
82
82
  export declare const MOCK_USER_STORAGE_ACCOUNTS: {
83
- SAME_AS_INTERNAL_ALL: import("../accounts/user-storage.cjs").UserStorageAccount[];
84
- ONE: import("../accounts/user-storage.cjs").UserStorageAccount[];
85
- TWO_DEFAULT_NAMES_WITH_ONE_BOGUS: import("../accounts/user-storage.cjs").UserStorageAccount[];
86
- ONE_DEFAULT_NAME: import("../accounts/user-storage.cjs").UserStorageAccount[];
87
- ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: import("../accounts/user-storage.cjs").UserStorageAccount[];
88
- ONE_CUSTOM_NAME_WITH_LAST_UPDATED: import("../accounts/user-storage.cjs").UserStorageAccount[];
83
+ SAME_AS_INTERNAL_ALL: import("../types.cjs").UserStorageAccount[];
84
+ ONE: import("../types.cjs").UserStorageAccount[];
85
+ TWO_DEFAULT_NAMES_WITH_ONE_BOGUS: import("../types.cjs").UserStorageAccount[];
86
+ ONE_DEFAULT_NAME: import("../types.cjs").UserStorageAccount[];
87
+ ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: import("../types.cjs").UserStorageAccount[];
88
+ ONE_CUSTOM_NAME_WITH_LAST_UPDATED: import("../types.cjs").UserStorageAccount[];
89
89
  };
90
90
  //# sourceMappingURL=mockAccounts.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockAccounts.d.cts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAgB5D;;;GAGG;AACH,eAAO,MAAM,+BAA+B,mbAGzC,CAAC;AAEJ,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHlC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;CAyCtC,CAAC"}
@@ -80,11 +80,11 @@ export declare const MOCK_INTERNAL_ACCOUNTS: {
80
80
  }[];
81
81
  };
82
82
  export declare const MOCK_USER_STORAGE_ACCOUNTS: {
83
- SAME_AS_INTERNAL_ALL: import("../accounts/user-storage.mjs").UserStorageAccount[];
84
- ONE: import("../accounts/user-storage.mjs").UserStorageAccount[];
85
- TWO_DEFAULT_NAMES_WITH_ONE_BOGUS: import("../accounts/user-storage.mjs").UserStorageAccount[];
86
- ONE_DEFAULT_NAME: import("../accounts/user-storage.mjs").UserStorageAccount[];
87
- ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: import("../accounts/user-storage.mjs").UserStorageAccount[];
88
- ONE_CUSTOM_NAME_WITH_LAST_UPDATED: import("../accounts/user-storage.mjs").UserStorageAccount[];
83
+ SAME_AS_INTERNAL_ALL: import("../types.mjs").UserStorageAccount[];
84
+ ONE: import("../types.mjs").UserStorageAccount[];
85
+ TWO_DEFAULT_NAMES_WITH_ONE_BOGUS: import("../types.mjs").UserStorageAccount[];
86
+ ONE_DEFAULT_NAME: import("../types.mjs").UserStorageAccount[];
87
+ ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: import("../types.mjs").UserStorageAccount[];
88
+ ONE_CUSTOM_NAME_WITH_LAST_UPDATED: import("../types.mjs").UserStorageAccount[];
89
89
  };
90
90
  //# sourceMappingURL=mockAccounts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockAccounts.d.mts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAgB5D;;;GAGG;AACH,eAAO,MAAM,+BAA+B,mbAGzC,CAAC;AAEJ,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHlC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;CAyCtC,CAAC"}
@@ -1,8 +1,7 @@
1
- import $metamaskkeyringapi from "@metamask/keyring-api";
2
- const { EthAccountType } = $metamaskkeyringapi;
1
+ import { EthAccountType } from "@metamask/keyring-api";
3
2
  import { KeyringTypes } from "@metamask/keyring-controller";
4
- import { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from "../accounts/constants.mjs";
5
- import { mapInternalAccountToUserStorageAccount } from "../accounts/user-storage.mjs";
3
+ import { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from "../constants.mjs";
4
+ import { mapInternalAccountToUserStorageAccount } from "../utils.mjs";
6
5
  /**
7
6
  * Map an array of internal accounts to an array of user storage accounts
8
7
  * Only used for testing purposes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockAccounts.mjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"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","sourcesContent":["import { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from '../constants';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\n\n/**\n * Map an array of internal accounts to an array of user storage accounts\n * Only used for testing purposes\n * @param internalAccounts - An array of internal accounts\n * @returns An array of user storage accounts\n */\nconst mapInternalAccountsListToUserStorageAccountsList = (\n internalAccounts: InternalAccount[],\n) => internalAccounts.map(mapInternalAccountToUserStorageAccount);\n\n/**\n * Get a random default account name from the list of localized default account names\n * @returns A random default account name\n */\nexport const getMockRandomDefaultAccountName = () =>\n LOCALIZED_DEFAULT_ACCOUNT_NAMES[\n Math.floor(Math.random() * LOCALIZED_DEFAULT_ACCOUNT_NAMES.length)\n ];\n\nexport const MOCK_INTERNAL_ACCOUNTS = {\n EMPTY: [],\n ONE: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'test',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_DEFAULT_NAME: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: `${getMockRandomDefaultAccountName()} 1`,\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name without nameLastUpdatedAt',\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED_MOST_RECENT: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 9999,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ALL: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'test',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0x456',\n id: '2',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Account 2',\n nameLastUpdatedAt: 2,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0x789',\n id: '3',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Účet 2',\n nameLastUpdatedAt: 3,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0xabc',\n id: '4',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'My Account 4',\n nameLastUpdatedAt: 4,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n};\n\nexport const MOCK_USER_STORAGE_ACCOUNTS = {\n SAME_AS_INTERNAL_ALL: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ALL as InternalAccount[],\n ),\n ONE: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ONE as InternalAccount[],\n ),\n TWO_DEFAULT_NAMES_WITH_ONE_BOGUS:\n mapInternalAccountsListToUserStorageAccountsList([\n ...MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME,\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME[0],\n address: '0x000000',\n metadata: {\n name: `${getMockRandomDefaultAccountName()} 1`,\n nameLastUpdatedAt: 2,\n },\n },\n ] as InternalAccount[]),\n ONE_DEFAULT_NAME: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME as InternalAccount[],\n ),\n ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED:\n mapInternalAccountsListToUserStorageAccountsList([\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],\n metadata: {\n name: 'User storage account custom name without nameLastUpdatedAt',\n },\n },\n ] as InternalAccount[]),\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED:\n mapInternalAccountsListToUserStorageAccountsList([\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],\n metadata: {\n name: 'User storage account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 3,\n },\n },\n ] as InternalAccount[]),\n};\n"]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExpectedAccountSyncBatchDeleteBody = exports.createExpectedAccountSyncBatchUpsertBody = exports.mockUserStorageMessengerForAccountSyncing = void 0;
4
+ const encryption_1 = require("../../../../shared/encryption/index.cjs");
5
+ const mockMessenger_1 = require("../../__fixtures__/mockMessenger.cjs");
6
+ const utils_1 = require("../utils.cjs");
7
+ const mockAccounts_1 = require("./mockAccounts.cjs");
8
+ /**
9
+ * Test Utility - create a mock user storage messenger for account syncing tests
10
+ *
11
+ * @param options - options for the mock messenger
12
+ * @param options.accounts - options for the accounts part of the controller
13
+ * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action
14
+ * @returns Mock User Storage Messenger
15
+ */
16
+ function mockUserStorageMessengerForAccountSyncing(options) {
17
+ const messengerMocks = (0, mockMessenger_1.mockUserStorageMessenger)();
18
+ messengerMocks.mockKeyringAddNewAccount.mockImplementation(async () => {
19
+ messengerMocks.baseMessenger.publish('AccountsController:accountAdded', mockAccounts_1.MOCK_INTERNAL_ACCOUNTS.ONE[0]);
20
+ return mockAccounts_1.MOCK_INTERNAL_ACCOUNTS.ONE[0].address;
21
+ });
22
+ messengerMocks.mockAccountsListAccounts.mockReturnValue((options?.accounts?.accountsList ??
23
+ mockAccounts_1.MOCK_INTERNAL_ACCOUNTS.ALL));
24
+ return messengerMocks;
25
+ }
26
+ exports.mockUserStorageMessengerForAccountSyncing = mockUserStorageMessengerForAccountSyncing;
27
+ /**
28
+ * Test Utility - creates a realistic expected batch upsert payload
29
+ * @param data - data supposed to be upserted
30
+ * @param storageKey - storage key
31
+ * @returns expected body
32
+ */
33
+ function createExpectedAccountSyncBatchUpsertBody(data, storageKey) {
34
+ return data.map(([entryKey, entryValue]) => [
35
+ (0, encryption_1.createSHA256Hash)(String(entryKey) + storageKey),
36
+ JSON.stringify((0, utils_1.mapInternalAccountToUserStorageAccount)(entryValue)),
37
+ ]);
38
+ }
39
+ exports.createExpectedAccountSyncBatchUpsertBody = createExpectedAccountSyncBatchUpsertBody;
40
+ /**
41
+ * Test Utility - creates a realistic expected batch delete payload
42
+ * @param data - data supposed to be deleted
43
+ * @param storageKey - storage key
44
+ * @returns expected body
45
+ */
46
+ function createExpectedAccountSyncBatchDeleteBody(data, storageKey) {
47
+ return data.map((entryKey) => (0, encryption_1.createSHA256Hash)(String(entryKey) + storageKey));
48
+ }
49
+ exports.createExpectedAccountSyncBatchDeleteBody = createExpectedAccountSyncBatchDeleteBody;
50
+ //# sourceMappingURL=test-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;AAEA,wEAAiE;AACjE,wEAA4E;AAC5E,wCAAkE;AAClE,qDAAwD;AAExD;;;;;;;GAOG;AACH,SAAgB,yCAAyC,CAAC,OAIzD;IACC,MAAM,cAAc,GAAG,IAAA,wCAAwB,GAAE,CAAC;IAElD,cAAc,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE;QACpE,cAAc,CAAC,aAAa,CAAC,OAAO,CAClC,iCAAiC,EACjC,qCAAsB,CAAC,GAAG,CAAC,CAAC,CAAoB,CACjD,CAAC;QACF,OAAO,qCAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,wBAAwB,CAAC,eAAe,CACrD,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY;QAC9B,qCAAsB,CAAC,GAAG,CAAsB,CACnD,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC;AArBD,8FAqBC;AAED;;;;;GAKG;AACH,SAAgB,wCAAwC,CACtD,IAAiC,EACjC,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;QAC1C,IAAA,6BAAgB,EAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,IAAA,8CAAsC,EAAC,UAAU,CAAC,CAAC;KACnE,CAAC,CAAC;AACL,CAAC;AARD,4FAQC;AAED;;;;;GAKG;AACH,SAAgB,wCAAwC,CACtD,IAAc,EACd,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC3B,IAAA,6BAAgB,EAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,CAChD,CAAC;AACJ,CAAC;AAPD,4FAOC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { createSHA256Hash } from '../../../../shared/encryption';\nimport { mockUserStorageMessenger } from '../../__fixtures__/mockMessenger';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\nimport { MOCK_INTERNAL_ACCOUNTS } from './mockAccounts';\n\n/**\n * Test Utility - create a mock user storage messenger for account syncing tests\n *\n * @param options - options for the mock messenger\n * @param options.accounts - options for the accounts part of the controller\n * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action\n * @returns Mock User Storage Messenger\n */\nexport function mockUserStorageMessengerForAccountSyncing(options?: {\n accounts?: {\n accountsList?: InternalAccount[];\n };\n}) {\n const messengerMocks = mockUserStorageMessenger();\n\n messengerMocks.mockKeyringAddNewAccount.mockImplementation(async () => {\n messengerMocks.baseMessenger.publish(\n 'AccountsController:accountAdded',\n MOCK_INTERNAL_ACCOUNTS.ONE[0] as InternalAccount,\n );\n return MOCK_INTERNAL_ACCOUNTS.ONE[0].address;\n });\n\n messengerMocks.mockAccountsListAccounts.mockReturnValue(\n (options?.accounts?.accountsList ??\n MOCK_INTERNAL_ACCOUNTS.ALL) as InternalAccount[],\n );\n\n return messengerMocks;\n}\n\n/**\n * Test Utility - creates a realistic expected batch upsert payload\n * @param data - data supposed to be upserted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchUpsertBody(\n data: [string, InternalAccount][],\n storageKey: string,\n) {\n return data.map(([entryKey, entryValue]) => [\n createSHA256Hash(String(entryKey) + storageKey),\n JSON.stringify(mapInternalAccountToUserStorageAccount(entryValue)),\n ]);\n}\n\n/**\n * Test Utility - creates a realistic expected batch delete payload\n * @param data - data supposed to be deleted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchDeleteBody(\n data: string[],\n storageKey: string,\n) {\n return data.map((entryKey) =>\n createSHA256Hash(String(entryKey) + storageKey),\n );\n}\n"]}
@@ -0,0 +1,85 @@
1
+ /// <reference types="jest" />
2
+ import type { InternalAccount } from "@metamask/keyring-internal-api";
3
+ /**
4
+ * Test Utility - create a mock user storage messenger for account syncing tests
5
+ *
6
+ * @param options - options for the mock messenger
7
+ * @param options.accounts - options for the accounts part of the controller
8
+ * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action
9
+ * @returns Mock User Storage Messenger
10
+ */
11
+ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
12
+ accounts?: {
13
+ accountsList?: InternalAccount[];
14
+ };
15
+ }): {
16
+ baseMessenger: import("@metamask/base-controller").ControllerMessenger<import("../../index.cjs").AllowedActions, import("../../index.cjs").AllowedEvents>;
17
+ messenger: import("@metamask/base-controller").RestrictedControllerMessenger<"UserStorageController", import("@metamask/snaps-controllers").HandleSnapRequest | {
18
+ type: "AuthenticationController:isSignedIn";
19
+ handler: () => boolean;
20
+ } | {
21
+ type: "AuthenticationController:performSignIn";
22
+ handler: () => Promise<string>;
23
+ } | {
24
+ type: "AuthenticationController:performSignOut";
25
+ handler: () => void;
26
+ } | {
27
+ type: "AuthenticationController:getBearerToken";
28
+ handler: () => Promise<string>;
29
+ } | {
30
+ type: "AuthenticationController:getSessionProfile";
31
+ handler: () => Promise<{
32
+ identifierId: string;
33
+ profileId: string;
34
+ }>;
35
+ } | import("@metamask/keyring-controller").KeyringControllerGetStateAction | import("../../index.cjs").NotificationServicesControllerDisableNotificationServices | import("../../index.cjs").NotificationServicesControllerSelectIsNotificationServicesEnabled | import("@metamask/accounts-controller").AccountsControllerListAccountsAction | import("@metamask/accounts-controller").AccountsControllerUpdateAccountMetadataAction | import("@metamask/keyring-controller").KeyringControllerAddNewAccountAction | import("@metamask/network-controller").NetworkControllerGetStateAction | import("@metamask/network-controller").NetworkControllerAddNetworkAction | import("@metamask/network-controller").NetworkControllerRemoveNetworkAction | import("@metamask/network-controller").NetworkControllerUpdateNetworkAction, import("@metamask/keyring-controller").KeyringControllerLockEvent | import("@metamask/keyring-controller").KeyringControllerUnlockEvent | import("../../index.cjs").UserStorageControllerStateChangeEvent | import("../../index.cjs").UserStorageControllerAccountSyncingInProgress | import("../../index.cjs").UserStorageControllerAccountSyncingComplete | import("@metamask/accounts-controller").AccountsControllerAccountAddedEvent | import("@metamask/accounts-controller").AccountsControllerAccountRenamedEvent | import("@metamask/network-controller").NetworkControllerNetworkRemovedEvent, "SnapController:handleRequest" | "KeyringController:getState" | "AuthenticationController:isSignedIn" | "AuthenticationController:performSignIn" | "AuthenticationController:performSignOut" | "AuthenticationController:getBearerToken" | "AuthenticationController:getSessionProfile" | "NotificationServicesController:disableNotificationServices" | "NotificationServicesController:selectIsNotificationServicesEnabled" | "AccountsController:listAccounts" | "AccountsController:updateAccountMetadata" | "KeyringController:addNewAccount" | "NetworkController:getState" | "NetworkController:addNetwork" | "NetworkController:removeNetwork" | "NetworkController:updateNetwork", "KeyringController:lock" | "KeyringController:unlock" | "AccountsController:accountAdded" | "AccountsController:accountRenamed" | "NetworkController:networkRemoved">;
36
+ mockSnapGetPublicKey: jest.Mock<any, any>;
37
+ mockSnapSignMessage: jest.Mock<any, any>;
38
+ mockAuthGetBearerToken: jest.Mock<Promise<string>, []>;
39
+ mockAuthGetSessionProfile: jest.Mock<Promise<{
40
+ identifierId: string;
41
+ profileId: string;
42
+ }>, []>;
43
+ mockAuthPerformSignIn: jest.Mock<Promise<string>, []>;
44
+ mockAuthIsSignedIn: jest.Mock<boolean, []>;
45
+ mockNotificationServicesIsEnabled: jest.Mock<boolean, []>;
46
+ mockNotificationServicesDisableNotifications: jest.Mock<Promise<void>, []>;
47
+ mockAuthPerformSignOut: jest.Mock<void, []>;
48
+ mockKeyringAddNewAccount: jest.Mock<Promise<string>, [accountCount?: number | undefined]>;
49
+ mockAccountsUpdateAccountMetadata: jest.Mock<void, [accountId: string, metadata: Partial<{
50
+ name: string;
51
+ importTime: number;
52
+ keyring: {
53
+ type: string;
54
+ };
55
+ nameLastUpdatedAt?: number | undefined;
56
+ snap?: {
57
+ name: string;
58
+ id: string;
59
+ enabled: boolean;
60
+ } | undefined;
61
+ lastSelected?: number | undefined;
62
+ }>]>;
63
+ mockAccountsListAccounts: jest.Mock<any, any>;
64
+ mockNetworkControllerGetState: jest.Mock<import("@metamask/network-controller").NetworkState, []>;
65
+ mockNetworkControllerAddNetwork: jest.Mock<import("@metamask/network-controller").NetworkConfiguration, [fields: import("@metamask/network-controller").AddNetworkFields]>;
66
+ mockNetworkControllerRemoveNetwork: jest.Mock<void, [chainId: `0x${string}`]>;
67
+ mockNetworkControllerUpdateNetwork: jest.Mock<Promise<import("@metamask/network-controller").NetworkConfiguration>, [`0x${string}`, import("@metamask/network-controller").UpdateNetworkFields, ({
68
+ replacementSelectedRpcEndpointIndex?: number | undefined;
69
+ } | undefined)?]>;
70
+ };
71
+ /**
72
+ * Test Utility - creates a realistic expected batch upsert payload
73
+ * @param data - data supposed to be upserted
74
+ * @param storageKey - storage key
75
+ * @returns expected body
76
+ */
77
+ export declare function createExpectedAccountSyncBatchUpsertBody(data: [string, InternalAccount][], storageKey: string): string[][];
78
+ /**
79
+ * Test Utility - creates a realistic expected batch delete payload
80
+ * @param data - data supposed to be deleted
81
+ * @param storageKey - storage key
82
+ * @returns expected body
83
+ */
84
+ export declare function createExpectedAccountSyncBatchDeleteBody(data: string[], storageKey: string): string[];
85
+ //# sourceMappingURL=test-utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.cts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE;;;;;;;GAOG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,CAAC,EAAE;IAClE,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EACjC,UAAU,EAAE,MAAM,cAMnB;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,EAAE,MAAM,YAKnB"}
@@ -0,0 +1,85 @@
1
+ /// <reference types="jest" />
2
+ import type { InternalAccount } from "@metamask/keyring-internal-api";
3
+ /**
4
+ * Test Utility - create a mock user storage messenger for account syncing tests
5
+ *
6
+ * @param options - options for the mock messenger
7
+ * @param options.accounts - options for the accounts part of the controller
8
+ * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action
9
+ * @returns Mock User Storage Messenger
10
+ */
11
+ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
12
+ accounts?: {
13
+ accountsList?: InternalAccount[];
14
+ };
15
+ }): {
16
+ baseMessenger: import("@metamask/base-controller").ControllerMessenger<import("../../index.mjs").AllowedActions, import("../../index.mjs").AllowedEvents>;
17
+ messenger: import("@metamask/base-controller").RestrictedControllerMessenger<"UserStorageController", import("@metamask/snaps-controllers").HandleSnapRequest | {
18
+ type: "AuthenticationController:isSignedIn";
19
+ handler: () => boolean;
20
+ } | {
21
+ type: "AuthenticationController:performSignIn";
22
+ handler: () => Promise<string>;
23
+ } | {
24
+ type: "AuthenticationController:performSignOut";
25
+ handler: () => void;
26
+ } | {
27
+ type: "AuthenticationController:getBearerToken";
28
+ handler: () => Promise<string>;
29
+ } | {
30
+ type: "AuthenticationController:getSessionProfile";
31
+ handler: () => Promise<{
32
+ identifierId: string;
33
+ profileId: string;
34
+ }>;
35
+ } | import("@metamask/keyring-controller").KeyringControllerGetStateAction | import("../../index.mjs").NotificationServicesControllerDisableNotificationServices | import("../../index.mjs").NotificationServicesControllerSelectIsNotificationServicesEnabled | import("@metamask/accounts-controller").AccountsControllerListAccountsAction | import("@metamask/accounts-controller").AccountsControllerUpdateAccountMetadataAction | import("@metamask/keyring-controller").KeyringControllerAddNewAccountAction | import("@metamask/network-controller").NetworkControllerGetStateAction | import("@metamask/network-controller").NetworkControllerAddNetworkAction | import("@metamask/network-controller").NetworkControllerRemoveNetworkAction | import("@metamask/network-controller").NetworkControllerUpdateNetworkAction, import("@metamask/keyring-controller").KeyringControllerLockEvent | import("@metamask/keyring-controller").KeyringControllerUnlockEvent | import("../../index.mjs").UserStorageControllerStateChangeEvent | import("../../index.mjs").UserStorageControllerAccountSyncingInProgress | import("../../index.mjs").UserStorageControllerAccountSyncingComplete | import("@metamask/accounts-controller").AccountsControllerAccountAddedEvent | import("@metamask/accounts-controller").AccountsControllerAccountRenamedEvent | import("@metamask/network-controller").NetworkControllerNetworkRemovedEvent, "SnapController:handleRequest" | "KeyringController:getState" | "AuthenticationController:isSignedIn" | "AuthenticationController:performSignIn" | "AuthenticationController:performSignOut" | "AuthenticationController:getBearerToken" | "AuthenticationController:getSessionProfile" | "NotificationServicesController:disableNotificationServices" | "NotificationServicesController:selectIsNotificationServicesEnabled" | "AccountsController:listAccounts" | "AccountsController:updateAccountMetadata" | "KeyringController:addNewAccount" | "NetworkController:getState" | "NetworkController:addNetwork" | "NetworkController:removeNetwork" | "NetworkController:updateNetwork", "KeyringController:lock" | "KeyringController:unlock" | "AccountsController:accountAdded" | "AccountsController:accountRenamed" | "NetworkController:networkRemoved">;
36
+ mockSnapGetPublicKey: jest.Mock<any, any>;
37
+ mockSnapSignMessage: jest.Mock<any, any>;
38
+ mockAuthGetBearerToken: jest.Mock<Promise<string>, []>;
39
+ mockAuthGetSessionProfile: jest.Mock<Promise<{
40
+ identifierId: string;
41
+ profileId: string;
42
+ }>, []>;
43
+ mockAuthPerformSignIn: jest.Mock<Promise<string>, []>;
44
+ mockAuthIsSignedIn: jest.Mock<boolean, []>;
45
+ mockNotificationServicesIsEnabled: jest.Mock<boolean, []>;
46
+ mockNotificationServicesDisableNotifications: jest.Mock<Promise<void>, []>;
47
+ mockAuthPerformSignOut: jest.Mock<void, []>;
48
+ mockKeyringAddNewAccount: jest.Mock<Promise<string>, [accountCount?: number | undefined]>;
49
+ mockAccountsUpdateAccountMetadata: jest.Mock<void, [accountId: string, metadata: Partial<{
50
+ name: string;
51
+ importTime: number;
52
+ keyring: {
53
+ type: string;
54
+ };
55
+ nameLastUpdatedAt?: number | undefined;
56
+ snap?: {
57
+ name: string;
58
+ id: string;
59
+ enabled: boolean;
60
+ } | undefined;
61
+ lastSelected?: number | undefined;
62
+ }>]>;
63
+ mockAccountsListAccounts: jest.Mock<any, any>;
64
+ mockNetworkControllerGetState: jest.Mock<import("@metamask/network-controller").NetworkState, []>;
65
+ mockNetworkControllerAddNetwork: jest.Mock<import("@metamask/network-controller").NetworkConfiguration, [fields: import("@metamask/network-controller").AddNetworkFields]>;
66
+ mockNetworkControllerRemoveNetwork: jest.Mock<void, [chainId: `0x${string}`]>;
67
+ mockNetworkControllerUpdateNetwork: jest.Mock<Promise<import("@metamask/network-controller").NetworkConfiguration>, [`0x${string}`, import("@metamask/network-controller").UpdateNetworkFields, ({
68
+ replacementSelectedRpcEndpointIndex?: number | undefined;
69
+ } | undefined)?]>;
70
+ };
71
+ /**
72
+ * Test Utility - creates a realistic expected batch upsert payload
73
+ * @param data - data supposed to be upserted
74
+ * @param storageKey - storage key
75
+ * @returns expected body
76
+ */
77
+ export declare function createExpectedAccountSyncBatchUpsertBody(data: [string, InternalAccount][], storageKey: string): string[][];
78
+ /**
79
+ * Test Utility - creates a realistic expected batch delete payload
80
+ * @param data - data supposed to be deleted
81
+ * @param storageKey - storage key
82
+ * @returns expected body
83
+ */
84
+ export declare function createExpectedAccountSyncBatchDeleteBody(data: string[], storageKey: string): string[];
85
+ //# sourceMappingURL=test-utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.mts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE;;;;;;;GAOG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,CAAC,EAAE;IAClE,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EACjC,UAAU,EAAE,MAAM,cAMnB;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,EAAE,MAAM,YAKnB"}
@@ -0,0 +1,44 @@
1
+ import { createSHA256Hash } from "../../../../shared/encryption/index.mjs";
2
+ import { mockUserStorageMessenger } from "../../__fixtures__/mockMessenger.mjs";
3
+ import { mapInternalAccountToUserStorageAccount } from "../utils.mjs";
4
+ import { MOCK_INTERNAL_ACCOUNTS } from "./mockAccounts.mjs";
5
+ /**
6
+ * Test Utility - create a mock user storage messenger for account syncing tests
7
+ *
8
+ * @param options - options for the mock messenger
9
+ * @param options.accounts - options for the accounts part of the controller
10
+ * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action
11
+ * @returns Mock User Storage Messenger
12
+ */
13
+ export function mockUserStorageMessengerForAccountSyncing(options) {
14
+ const messengerMocks = mockUserStorageMessenger();
15
+ messengerMocks.mockKeyringAddNewAccount.mockImplementation(async () => {
16
+ messengerMocks.baseMessenger.publish('AccountsController:accountAdded', MOCK_INTERNAL_ACCOUNTS.ONE[0]);
17
+ return MOCK_INTERNAL_ACCOUNTS.ONE[0].address;
18
+ });
19
+ messengerMocks.mockAccountsListAccounts.mockReturnValue((options?.accounts?.accountsList ??
20
+ MOCK_INTERNAL_ACCOUNTS.ALL));
21
+ return messengerMocks;
22
+ }
23
+ /**
24
+ * Test Utility - creates a realistic expected batch upsert payload
25
+ * @param data - data supposed to be upserted
26
+ * @param storageKey - storage key
27
+ * @returns expected body
28
+ */
29
+ export function createExpectedAccountSyncBatchUpsertBody(data, storageKey) {
30
+ return data.map(([entryKey, entryValue]) => [
31
+ createSHA256Hash(String(entryKey) + storageKey),
32
+ JSON.stringify(mapInternalAccountToUserStorageAccount(entryValue)),
33
+ ]);
34
+ }
35
+ /**
36
+ * Test Utility - creates a realistic expected batch delete payload
37
+ * @param data - data supposed to be deleted
38
+ * @param storageKey - storage key
39
+ * @returns expected body
40
+ */
41
+ export function createExpectedAccountSyncBatchDeleteBody(data, storageKey) {
42
+ return data.map((entryKey) => createSHA256Hash(String(entryKey) + storageKey));
43
+ }
44
+ //# sourceMappingURL=test-utils.mjs.map