@metamask/profile-sync-controller 8.1.1 → 9.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.
- package/CHANGELOG.md +10 -1
- package/README.md +32 -0
- package/auth/mocks/package.json +2 -2
- package/dist/controllers/authentication/index.cjs +1 -1
- package/dist/controllers/authentication/index.cjs.map +1 -1
- package/dist/controllers/authentication/index.d.cts +1 -1
- package/dist/controllers/authentication/index.d.cts.map +1 -1
- package/dist/controllers/authentication/index.d.mts +1 -1
- package/dist/controllers/authentication/index.d.mts.map +1 -1
- package/dist/controllers/authentication/index.mjs +1 -1
- package/dist/controllers/authentication/index.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/index.cjs.map +1 -0
- package/dist/controllers/authentication/mocks/index.d.cts.map +1 -0
- package/dist/controllers/authentication/mocks/index.d.mts.map +1 -0
- package/dist/controllers/authentication/mocks/index.mjs.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -0
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.cjs +2 -2
- package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.mjs +2 -2
- package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/index.cjs +1 -1
- package/dist/controllers/user-storage/index.cjs.map +1 -1
- package/dist/controllers/user-storage/index.d.cts +1 -1
- package/dist/controllers/user-storage/index.d.cts.map +1 -1
- package/dist/controllers/user-storage/index.d.mts +1 -1
- package/dist/controllers/user-storage/index.d.mts.map +1 -1
- package/dist/controllers/user-storage/index.mjs +1 -1
- package/dist/controllers/user-storage/index.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/index.cjs.map +1 -0
- package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/mocks/index.mjs.map +1 -0
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -0
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -0
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -0
- package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -0
- package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -0
- package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -0
- package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -0
- package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -0
- package/package.json +14 -14
- package/user-storage/mocks/package.json +2 -2
- package/dist/controllers/authentication/__fixtures__/index.cjs.map +0 -1
- package/dist/controllers/authentication/__fixtures__/index.d.cts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/index.d.mts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/index.mjs.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockServices.cjs +0 -37
- package/dist/controllers/authentication/__fixtures__/mockServices.cjs.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockServices.d.cts +0 -10
- package/dist/controllers/authentication/__fixtures__/mockServices.d.cts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockServices.d.mts +0 -10
- package/dist/controllers/authentication/__fixtures__/mockServices.d.mts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockServices.mjs +0 -35
- package/dist/controllers/authentication/__fixtures__/mockServices.mjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/index.cjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/index.d.cts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/index.d.mts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/index.mjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs +0 -167
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +0 -105
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +0 -105
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs +0 -162
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +0 -82
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts +0 -15
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +0 -15
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +0 -76
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.cts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +0 -78
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +0 -38
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +0 -38
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +0 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +0 -68
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs +0 -178
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts +0 -91
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts +0 -91
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs +0 -174
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +0 -58
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +0 -87
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +0 -87
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +0 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +0 -52
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +0 -1
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs +0 -43
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs.map +0 -1
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts +0 -11
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts.map +0 -1
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts +0 -11
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts.map +0 -1
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs +0 -36
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs.map +0 -1
- package/dist/sdk/__fixtures__/mock-auth.cjs +0 -124
- package/dist/sdk/__fixtures__/mock-auth.cjs.map +0 -1
- package/dist/sdk/__fixtures__/mock-auth.d.cts +0 -42
- package/dist/sdk/__fixtures__/mock-auth.d.cts.map +0 -1
- package/dist/sdk/__fixtures__/mock-auth.d.mts +0 -42
- package/dist/sdk/__fixtures__/mock-auth.d.mts.map +0 -1
- package/dist/sdk/__fixtures__/mock-auth.mjs +0 -119
- package/dist/sdk/__fixtures__/mock-auth.mjs.map +0 -1
- package/dist/sdk/__fixtures__/mock-userstorage.cjs +0 -111
- package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +0 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts +0 -20
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +0 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts +0 -20
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +0 -1
- package/dist/sdk/__fixtures__/mock-userstorage.mjs +0 -81
- package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +0 -1
- package/dist/sdk/__fixtures__/test-utils.cjs +0 -90
- package/dist/sdk/__fixtures__/test-utils.cjs.map +0 -1
- package/dist/sdk/__fixtures__/test-utils.d.cts +0 -37
- package/dist/sdk/__fixtures__/test-utils.d.cts.map +0 -1
- package/dist/sdk/__fixtures__/test-utils.d.mts +0 -37
- package/dist/sdk/__fixtures__/test-utils.d.mts.map +0 -1
- package/dist/sdk/__fixtures__/test-utils.mjs +0 -84
- package/dist/sdk/__fixtures__/test-utils.mjs.map +0 -1
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.cjs +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.d.cts +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.d.mts +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.mjs +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/mockResponses.cjs +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/mockResponses.d.cts +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/mockResponses.d.mts +0 -0
- /package/dist/controllers/authentication/{__fixtures__ → mocks}/mockResponses.mjs +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.cjs +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.d.cts +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.d.mts +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.mjs +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.cjs +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.d.cts +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.d.mts +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.mjs +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.cjs +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.d.cts +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.d.mts +0 -0
- /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.mjs +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
function $importDefault(module) {
|
|
2
|
-
if (module?.__esModule) {
|
|
3
|
-
return module.default;
|
|
4
|
-
}
|
|
5
|
-
return module;
|
|
6
|
-
}
|
|
7
|
-
import $nock from "nock";
|
|
8
|
-
const nock = $importDefault($nock);
|
|
9
|
-
import { getMockUserStorageGetResponse, getMockUserStoragePutResponse, getMockUserStorageAllFeatureEntriesResponse, getMockUserStorageBatchPutResponse, getMockUserStorageBatchDeleteResponse, deleteMockUserStorageAllFeatureEntriesResponse, deleteMockUserStorageResponse } from "./mockResponses.mjs";
|
|
10
|
-
import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
|
|
11
|
-
export const mockEndpointGetUserStorageAllFeatureEntries = async (path = USER_STORAGE_FEATURE_NAMES.notifications, mockReply) => {
|
|
12
|
-
const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);
|
|
13
|
-
const reply = mockReply ?? {
|
|
14
|
-
status: 200,
|
|
15
|
-
body: mockResponse.response,
|
|
16
|
-
};
|
|
17
|
-
const mockEndpoint = nock(mockResponse.url)
|
|
18
|
-
.get('')
|
|
19
|
-
.reply(reply.status, reply.body);
|
|
20
|
-
return mockEndpoint;
|
|
21
|
-
};
|
|
22
|
-
export const mockEndpointGetUserStorage = async (path = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`, mockReply) => {
|
|
23
|
-
const mockResponse = await getMockUserStorageGetResponse(path);
|
|
24
|
-
const reply = mockReply ?? {
|
|
25
|
-
status: 200,
|
|
26
|
-
body: mockResponse.response,
|
|
27
|
-
};
|
|
28
|
-
const mockEndpoint = nock(mockResponse.url)
|
|
29
|
-
.get('')
|
|
30
|
-
.reply(reply.status, reply.body);
|
|
31
|
-
return mockEndpoint;
|
|
32
|
-
};
|
|
33
|
-
export const mockEndpointUpsertUserStorage = (path = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`, mockReply, expectCallback) => {
|
|
34
|
-
const mockResponse = getMockUserStoragePutResponse(path);
|
|
35
|
-
const mockEndpoint = nock(mockResponse.url)
|
|
36
|
-
.put('')
|
|
37
|
-
.reply(mockReply?.status ?? 204, async (_, requestBody) => {
|
|
38
|
-
await expectCallback?.(requestBody);
|
|
39
|
-
});
|
|
40
|
-
return mockEndpoint;
|
|
41
|
-
};
|
|
42
|
-
export const mockEndpointBatchUpsertUserStorage = (path = USER_STORAGE_FEATURE_NAMES.notifications, mockReply, callback) => {
|
|
43
|
-
const mockResponse = getMockUserStorageBatchPutResponse(path);
|
|
44
|
-
const mockEndpoint = nock(mockResponse.url)
|
|
45
|
-
.put('')
|
|
46
|
-
.reply(mockReply?.status ?? 204, async (uri, requestBody) => {
|
|
47
|
-
return await callback?.(uri, requestBody);
|
|
48
|
-
});
|
|
49
|
-
return mockEndpoint;
|
|
50
|
-
};
|
|
51
|
-
export const mockEndpointDeleteUserStorage = (path = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`, mockReply) => {
|
|
52
|
-
const mockResponse = deleteMockUserStorageResponse(path);
|
|
53
|
-
const reply = mockReply ?? {
|
|
54
|
-
status: 200,
|
|
55
|
-
};
|
|
56
|
-
const mockEndpoint = nock(mockResponse.url).delete('').reply(reply.status);
|
|
57
|
-
return mockEndpoint;
|
|
58
|
-
};
|
|
59
|
-
export const mockEndpointDeleteUserStorageAllFeatureEntries = (path = USER_STORAGE_FEATURE_NAMES.notifications, mockReply) => {
|
|
60
|
-
const mockResponse = deleteMockUserStorageAllFeatureEntriesResponse(path);
|
|
61
|
-
const reply = mockReply ?? {
|
|
62
|
-
status: 200,
|
|
63
|
-
};
|
|
64
|
-
const mockEndpoint = nock(mockResponse.url).delete('').reply(reply.status);
|
|
65
|
-
return mockEndpoint;
|
|
66
|
-
};
|
|
67
|
-
export const mockEndpointBatchDeleteUserStorage = (path = 'notifications', mockReply, callback) => {
|
|
68
|
-
const mockResponse = getMockUserStorageBatchDeleteResponse(path);
|
|
69
|
-
const mockEndpoint = nock(mockResponse.url)
|
|
70
|
-
.put('')
|
|
71
|
-
.reply(mockReply?.status ?? 204, async (uri, requestBody) => {
|
|
72
|
-
return await callback?.(uri, requestBody);
|
|
73
|
-
});
|
|
74
|
-
return mockEndpoint;
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=mockServices.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,2CAA2C,EAC3C,kCAAkC,EAClC,qCAAqC,EACrC,8CAA8C,EAC9C,6BAA6B,EAC9B,4BAAwB;AACzB,OAAO,EACL,0BAA0B,EAG3B,2CAAuC;AAOxC,MAAM,CAAC,MAAM,2CAA2C,GAAG,KAAK,EAC9D,OAAuC,0BAA0B,CAAC,aAAa,EAC/E,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,2CAA2C,CAAC,IAAI,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA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Y,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;QAC1D,OAAO,MAAM,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACL,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n getMockUserStorageBatchPutResponse,\n getMockUserStorageBatchDeleteResponse,\n deleteMockUserStorageAllFeatureEntriesResponse,\n deleteMockUserStorageResponse,\n} from './mockResponses';\nimport {\n USER_STORAGE_FEATURE_NAMES,\n type UserStoragePathWithFeatureAndKey,\n type UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n mockReply?: Pick<MockReply, 'status'>,\n expectCallback?: (requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (_, requestBody) => {\n await expectCallback?.(requestBody);\n });\n return mockEndpoint;\n};\n\nexport const mockEndpointBatchUpsertUserStorage = (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n mockReply?: Pick<MockReply, 'status'>,\n callback?: (uri: string, requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStorageBatchPutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (uri, requestBody) => {\n return await callback?.(uri, requestBody);\n });\n return mockEndpoint;\n};\n\nexport const mockEndpointDeleteUserStorage = (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n mockReply?: MockReply,\n) => {\n const mockResponse = deleteMockUserStorageResponse(path);\n const reply = mockReply ?? {\n status: 200,\n };\n\n const mockEndpoint = nock(mockResponse.url).delete('').reply(reply.status);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointDeleteUserStorageAllFeatureEntries = (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n mockReply?: MockReply,\n) => {\n const mockResponse = deleteMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n };\n\n const mockEndpoint = nock(mockResponse.url).delete('').reply(reply.status);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointBatchDeleteUserStorage = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: Pick<MockReply, 'status'>,\n callback?: (uri: string, requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStorageBatchDeleteResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (uri, requestBody) => {\n return await callback?.(uri, requestBody);\n });\n return mockEndpoint;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mFAA0E;AAE7D,QAAA,0BAA0B,GAAG,gBAAgB,CAAC;AAC9C,QAAA,gBAAgB,GAAG,IAAA,6BAAgB,EAAC,kCAA0B,CAAC,CAAC;AAChE,QAAA,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAEpE,sFAAsF;AACtF,kHAAkH;AAClH,IAAI,uBAA+B,CAAC;AAC7B,MAAM,2BAA2B,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE,CACjE,CAAC,uBAAuB,KAAvB,uBAAuB,GAAK,MAAM,oBAAU,CAAC,aAAa,CACzD,IAAI,IAAI,yBAAiB,EACzB,wBAAgB,CACjB,EAAC,CAAC;AAJQ,QAAA,2BAA2B,+BAInC","sourcesContent":["import encryption, { createSHA256Hash } from '../../../shared/encryption';\n\nexport const MOCK_STORAGE_KEY_SIGNATURE = 'mockStorageKey';\nexport const MOCK_STORAGE_KEY = createSHA256Hash(MOCK_STORAGE_KEY_SIGNATURE);\nexport const MOCK_STORAGE_DATA = JSON.stringify({ hello: 'world' });\n\n// NOTE - using encryption.encryptString directly in fixtures causes issues on mobile.\n// This is because this fixture is getting added in at run time. Will be improved once we support multiple exports\nlet cachedMockEncryptedData: string;\nexport const MOCK_ENCRYPTED_STORAGE_DATA = async (data?: string) =>\n (cachedMockEncryptedData ??= await encryption.encryptString(\n data ?? MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n ));\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockStorage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAC3D,eAAO,MAAM,gBAAgB,QAA+C,CAAC;AAC7E,eAAO,MAAM,iBAAiB,QAAqC,CAAC;AAKpE,eAAO,MAAM,2BAA2B,UAAiB,MAAM,oBAI3D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockStorage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAC3D,eAAO,MAAM,gBAAgB,QAA+C,CAAC;AAC7E,eAAO,MAAM,iBAAiB,QAAqC,CAAC;AAKpE,eAAO,MAAM,2BAA2B,UAAiB,MAAM,oBAI3D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockStorage.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,6CAAmC;AAE1E,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAEpE,sFAAsF;AACtF,kHAAkH;AAClH,IAAI,uBAA+B,CAAC;AACpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE,CACjE,CAAC,uBAAuB,KAAvB,uBAAuB,GAAK,MAAM,UAAU,CAAC,aAAa,CACzD,IAAI,IAAI,iBAAiB,EACzB,gBAAgB,CACjB,EAAC,CAAC","sourcesContent":["import encryption, { createSHA256Hash } from '../../../shared/encryption';\n\nexport const MOCK_STORAGE_KEY_SIGNATURE = 'mockStorageKey';\nexport const MOCK_STORAGE_KEY = createSHA256Hash(MOCK_STORAGE_KEY_SIGNATURE);\nexport const MOCK_STORAGE_DATA = JSON.stringify({ hello: 'world' });\n\n// NOTE - using encryption.encryptString directly in fixtures causes issues on mobile.\n// This is because this fixture is getting added in at run time. Will be improved once we support multiple exports\nlet cachedMockEncryptedData: string;\nexport const MOCK_ENCRYPTED_STORAGE_DATA = async (data?: string) =>\n (cachedMockEncryptedData ??= await encryption.encryptString(\n data ?? MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n ));\n"]}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.waitFor = exports.decryptBatchUpsertBody = exports.createMockUserStorageEntries = exports.createMockUserStorageEntry = void 0;
|
|
7
|
-
const mockStorage_1 = require("./mockStorage.cjs");
|
|
8
|
-
const encryption_1 = __importDefault(require("../../../shared/encryption/encryption.cjs"));
|
|
9
|
-
/**
|
|
10
|
-
* Test Utility - creates a realistic mock user-storage entry
|
|
11
|
-
*
|
|
12
|
-
* @param data - data to encrypt
|
|
13
|
-
* @returns user storage entry
|
|
14
|
-
*/
|
|
15
|
-
async function createMockUserStorageEntry(data) {
|
|
16
|
-
return {
|
|
17
|
-
HashedKey: 'HASHED_KEY',
|
|
18
|
-
Data: await encryption_1.default.encryptString(JSON.stringify(data), mockStorage_1.MOCK_STORAGE_KEY),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
exports.createMockUserStorageEntry = createMockUserStorageEntry;
|
|
22
|
-
/**
|
|
23
|
-
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
24
|
-
*
|
|
25
|
-
* @param data - data array to encrypt
|
|
26
|
-
* @returns user storage entry
|
|
27
|
-
*/
|
|
28
|
-
async function createMockUserStorageEntries(data) {
|
|
29
|
-
return await Promise.all(data.map((d) => createMockUserStorageEntry(d)));
|
|
30
|
-
}
|
|
31
|
-
exports.createMockUserStorageEntries = createMockUserStorageEntries;
|
|
32
|
-
/**
|
|
33
|
-
* Test Utility - decrypts a realistic batch upsert payload
|
|
34
|
-
*
|
|
35
|
-
* @param requestBody - nock body
|
|
36
|
-
* @param storageKey - storage key
|
|
37
|
-
* @returns decrypted body
|
|
38
|
-
*/
|
|
39
|
-
async function decryptBatchUpsertBody(requestBody, storageKey) {
|
|
40
|
-
if (typeof requestBody === 'string') {
|
|
41
|
-
return requestBody;
|
|
42
|
-
}
|
|
43
|
-
return await Promise.all(Object.entries(requestBody.data).map(async ([entryKey, entryValue]) => {
|
|
44
|
-
return [
|
|
45
|
-
entryKey,
|
|
46
|
-
await encryption_1.default.decryptString(entryValue, storageKey),
|
|
47
|
-
];
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
exports.decryptBatchUpsertBody = decryptBatchUpsertBody;
|
|
51
|
-
/**
|
|
52
|
-
* Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.
|
|
53
|
-
*
|
|
54
|
-
* @param assertionFn - assertion function
|
|
55
|
-
* @param options - set wait for options
|
|
56
|
-
* @returns promise that you need to await in tests
|
|
57
|
-
*/
|
|
58
|
-
const waitFor = async (assertionFn, options = {}) => {
|
|
59
|
-
const { intervalMs = 50, timeoutMs = 2000 } = options;
|
|
60
|
-
const startTime = Date.now();
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
const intervalId = setInterval(() => {
|
|
63
|
-
try {
|
|
64
|
-
assertionFn();
|
|
65
|
-
clearInterval(intervalId);
|
|
66
|
-
resolve();
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
if (Date.now() - startTime >= timeoutMs) {
|
|
70
|
-
clearInterval(intervalId);
|
|
71
|
-
reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}, intervalMs);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
exports.waitFor = waitFor;
|
|
78
|
-
//# sourceMappingURL=test-utils.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;;;;AAEA,mDAAiD;AACjD,2FAA+D;AAM/D;;;;;GAKG;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;;;;;GAKG;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;;;;;;GAMG;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,MAAM;gBACN,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 { MOCK_STORAGE_KEY } from './mockStorage';\nimport encryption from '../../../shared/encryption/encryption';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\n\n/**\n * Test Utility - creates a realistic mock user-storage entry\n *\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 *\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 *\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 {\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,38 +0,0 @@
|
|
|
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
|
-
*
|
|
6
|
-
* @param data - data to encrypt
|
|
7
|
-
* @returns user storage entry
|
|
8
|
-
*/
|
|
9
|
-
export declare function createMockUserStorageEntry(data: unknown): Promise<GetUserStorageResponse>;
|
|
10
|
-
/**
|
|
11
|
-
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
12
|
-
*
|
|
13
|
-
* @param data - data array to encrypt
|
|
14
|
-
* @returns user storage entry
|
|
15
|
-
*/
|
|
16
|
-
export declare function createMockUserStorageEntries(data: unknown[]): Promise<GetUserStorageAllFeatureEntriesResponse>;
|
|
17
|
-
/**
|
|
18
|
-
* Test Utility - decrypts a realistic batch upsert payload
|
|
19
|
-
*
|
|
20
|
-
* @param requestBody - nock body
|
|
21
|
-
* @param storageKey - storage key
|
|
22
|
-
* @returns decrypted body
|
|
23
|
-
*/
|
|
24
|
-
export declare function decryptBatchUpsertBody(requestBody: nock.Body, storageKey: string): Promise<string | string[][]>;
|
|
25
|
-
type WaitForOptions = {
|
|
26
|
-
intervalMs?: number;
|
|
27
|
-
timeoutMs?: number;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.
|
|
31
|
-
*
|
|
32
|
-
* @param assertionFn - assertion function
|
|
33
|
-
* @param options - set wait for options
|
|
34
|
-
* @returns promise that you need to await in tests
|
|
35
|
-
*/
|
|
36
|
-
export declare const waitFor: (assertionFn: () => void, options?: WaitForOptions) => Promise<void>;
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=test-utils.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAI7B,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAErB;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAQjC;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAAC,uCAAuC,CAAC,CAElD;AAED;;;;;;GAMG;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,38 +0,0 @@
|
|
|
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
|
-
*
|
|
6
|
-
* @param data - data to encrypt
|
|
7
|
-
* @returns user storage entry
|
|
8
|
-
*/
|
|
9
|
-
export declare function createMockUserStorageEntry(data: unknown): Promise<GetUserStorageResponse>;
|
|
10
|
-
/**
|
|
11
|
-
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
12
|
-
*
|
|
13
|
-
* @param data - data array to encrypt
|
|
14
|
-
* @returns user storage entry
|
|
15
|
-
*/
|
|
16
|
-
export declare function createMockUserStorageEntries(data: unknown[]): Promise<GetUserStorageAllFeatureEntriesResponse>;
|
|
17
|
-
/**
|
|
18
|
-
* Test Utility - decrypts a realistic batch upsert payload
|
|
19
|
-
*
|
|
20
|
-
* @param requestBody - nock body
|
|
21
|
-
* @param storageKey - storage key
|
|
22
|
-
* @returns decrypted body
|
|
23
|
-
*/
|
|
24
|
-
export declare function decryptBatchUpsertBody(requestBody: nock.Body, storageKey: string): Promise<string | string[][]>;
|
|
25
|
-
type WaitForOptions = {
|
|
26
|
-
intervalMs?: number;
|
|
27
|
-
timeoutMs?: number;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.
|
|
31
|
-
*
|
|
32
|
-
* @param assertionFn - assertion function
|
|
33
|
-
* @param options - set wait for options
|
|
34
|
-
* @returns promise that you need to await in tests
|
|
35
|
-
*/
|
|
36
|
-
export declare const waitFor: (assertionFn: () => void, options?: WaitForOptions) => Promise<void>;
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=test-utils.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAI7B,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAErB;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAQjC;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAAC,uCAAuC,CAAC,CAElD;AAED;;;;;;GAMG;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,68 +0,0 @@
|
|
|
1
|
-
import { MOCK_STORAGE_KEY } from "./mockStorage.mjs";
|
|
2
|
-
import encryption from "../../../shared/encryption/encryption.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Test Utility - creates a realistic mock user-storage entry
|
|
5
|
-
*
|
|
6
|
-
* @param data - data to encrypt
|
|
7
|
-
* @returns user storage entry
|
|
8
|
-
*/
|
|
9
|
-
export async function createMockUserStorageEntry(data) {
|
|
10
|
-
return {
|
|
11
|
-
HashedKey: 'HASHED_KEY',
|
|
12
|
-
Data: await encryption.encryptString(JSON.stringify(data), MOCK_STORAGE_KEY),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
17
|
-
*
|
|
18
|
-
* @param data - data array to encrypt
|
|
19
|
-
* @returns user storage entry
|
|
20
|
-
*/
|
|
21
|
-
export async function createMockUserStorageEntries(data) {
|
|
22
|
-
return await Promise.all(data.map((d) => createMockUserStorageEntry(d)));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Test Utility - decrypts a realistic batch upsert payload
|
|
26
|
-
*
|
|
27
|
-
* @param requestBody - nock body
|
|
28
|
-
* @param storageKey - storage key
|
|
29
|
-
* @returns decrypted body
|
|
30
|
-
*/
|
|
31
|
-
export async function decryptBatchUpsertBody(requestBody, storageKey) {
|
|
32
|
-
if (typeof requestBody === 'string') {
|
|
33
|
-
return requestBody;
|
|
34
|
-
}
|
|
35
|
-
return await Promise.all(Object.entries(requestBody.data).map(async ([entryKey, entryValue]) => {
|
|
36
|
-
return [
|
|
37
|
-
entryKey,
|
|
38
|
-
await encryption.decryptString(entryValue, storageKey),
|
|
39
|
-
];
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Testing Utility - waitFor. Waits for and checks (at an interval) if assertion is reached.
|
|
44
|
-
*
|
|
45
|
-
* @param assertionFn - assertion function
|
|
46
|
-
* @param options - set wait for options
|
|
47
|
-
* @returns promise that you need to await in tests
|
|
48
|
-
*/
|
|
49
|
-
export const waitFor = async (assertionFn, options = {}) => {
|
|
50
|
-
const { intervalMs = 50, timeoutMs = 2000 } = options;
|
|
51
|
-
const startTime = Date.now();
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
const intervalId = setInterval(() => {
|
|
54
|
-
try {
|
|
55
|
-
assertionFn();
|
|
56
|
-
clearInterval(intervalId);
|
|
57
|
-
resolve();
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
if (Date.now() - startTime >= timeoutMs) {
|
|
61
|
-
clearInterval(intervalId);
|
|
62
|
-
reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, intervalMs);
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=test-utils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,0BAAsB;AACjD,OAAO,UAAU,kDAA8C;AAM/D;;;;;GAKG;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;;;;;GAKG;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;;;;;;GAMG;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,MAAM;gBACN,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 { MOCK_STORAGE_KEY } from './mockStorage';\nimport encryption from '../../../shared/encryption/encryption';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\n\n/**\n * Test Utility - creates a realistic mock user-storage entry\n *\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 *\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 *\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 {\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,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MOCK_USER_STORAGE_ACCOUNTS = exports.MOCK_INTERNAL_ACCOUNTS = exports.getMockRandomDefaultAccountName = void 0;
|
|
4
|
-
const keyring_api_1 = require("@metamask/keyring-api");
|
|
5
|
-
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
6
|
-
const constants_1 = require("../constants.cjs");
|
|
7
|
-
const utils_1 = require("../utils.cjs");
|
|
8
|
-
/**
|
|
9
|
-
* Map an array of internal accounts to an array of user storage accounts
|
|
10
|
-
* Only used for testing purposes
|
|
11
|
-
*
|
|
12
|
-
* @param internalAccounts - An array of internal accounts
|
|
13
|
-
* @returns An array of user storage accounts
|
|
14
|
-
*/
|
|
15
|
-
const mapInternalAccountsListToUserStorageAccountsList = (internalAccounts) => internalAccounts.map(utils_1.mapInternalAccountToUserStorageAccount);
|
|
16
|
-
/**
|
|
17
|
-
* Get a random default account name from the list of localized default account names
|
|
18
|
-
*
|
|
19
|
-
* @returns A random default account name
|
|
20
|
-
*/
|
|
21
|
-
const getMockRandomDefaultAccountName = () => constants_1.LOCALIZED_DEFAULT_ACCOUNT_NAMES[Math.floor(Math.random() * constants_1.LOCALIZED_DEFAULT_ACCOUNT_NAMES.length)];
|
|
22
|
-
exports.getMockRandomDefaultAccountName = getMockRandomDefaultAccountName;
|
|
23
|
-
exports.MOCK_INTERNAL_ACCOUNTS = {
|
|
24
|
-
EMPTY: [],
|
|
25
|
-
ONE: [
|
|
26
|
-
{
|
|
27
|
-
address: '0x123',
|
|
28
|
-
id: '1',
|
|
29
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
30
|
-
metadata: {
|
|
31
|
-
name: 'test',
|
|
32
|
-
nameLastUpdatedAt: 1,
|
|
33
|
-
keyring: {
|
|
34
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
ONE_DEFAULT_NAME: [
|
|
40
|
-
{
|
|
41
|
-
address: '0x123',
|
|
42
|
-
id: '1',
|
|
43
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
44
|
-
metadata: {
|
|
45
|
-
name: `${(0, exports.getMockRandomDefaultAccountName)()} 1`,
|
|
46
|
-
nameLastUpdatedAt: 1,
|
|
47
|
-
keyring: {
|
|
48
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: [
|
|
54
|
-
{
|
|
55
|
-
address: '0x123',
|
|
56
|
-
id: '1',
|
|
57
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
58
|
-
metadata: {
|
|
59
|
-
name: 'Internal account custom name without nameLastUpdatedAt',
|
|
60
|
-
keyring: {
|
|
61
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
ONE_CUSTOM_NAME_WITH_LAST_UPDATED: [
|
|
67
|
-
{
|
|
68
|
-
address: '0x123',
|
|
69
|
-
id: '1',
|
|
70
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
71
|
-
metadata: {
|
|
72
|
-
name: 'Internal account custom name with nameLastUpdatedAt',
|
|
73
|
-
nameLastUpdatedAt: 1,
|
|
74
|
-
keyring: {
|
|
75
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
ONE_CUSTOM_NAME_WITH_LAST_UPDATED_MOST_RECENT: [
|
|
81
|
-
{
|
|
82
|
-
address: '0x123',
|
|
83
|
-
id: '1',
|
|
84
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
85
|
-
metadata: {
|
|
86
|
-
name: 'Internal account custom name with nameLastUpdatedAt',
|
|
87
|
-
nameLastUpdatedAt: 9999,
|
|
88
|
-
keyring: {
|
|
89
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
ALL: [
|
|
95
|
-
{
|
|
96
|
-
address: '0x123',
|
|
97
|
-
id: '1',
|
|
98
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
99
|
-
metadata: {
|
|
100
|
-
name: 'test',
|
|
101
|
-
nameLastUpdatedAt: 1,
|
|
102
|
-
keyring: {
|
|
103
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
address: '0x456',
|
|
109
|
-
id: '2',
|
|
110
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
111
|
-
metadata: {
|
|
112
|
-
name: 'Account 2',
|
|
113
|
-
nameLastUpdatedAt: 2,
|
|
114
|
-
keyring: {
|
|
115
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
address: '0x789',
|
|
121
|
-
id: '3',
|
|
122
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
123
|
-
metadata: {
|
|
124
|
-
name: 'Účet 2',
|
|
125
|
-
nameLastUpdatedAt: 3,
|
|
126
|
-
keyring: {
|
|
127
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
address: '0xabc',
|
|
133
|
-
id: '4',
|
|
134
|
-
type: keyring_api_1.EthAccountType.Eoa,
|
|
135
|
-
metadata: {
|
|
136
|
-
name: 'My Account 4',
|
|
137
|
-
nameLastUpdatedAt: 4,
|
|
138
|
-
keyring: {
|
|
139
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
};
|
|
145
|
-
exports.MOCK_USER_STORAGE_ACCOUNTS = {
|
|
146
|
-
SAME_AS_INTERNAL_ALL: mapInternalAccountsListToUserStorageAccountsList(exports.MOCK_INTERNAL_ACCOUNTS.ALL),
|
|
147
|
-
ONE: mapInternalAccountsListToUserStorageAccountsList(exports.MOCK_INTERNAL_ACCOUNTS.ONE),
|
|
148
|
-
TWO_DEFAULT_NAMES_WITH_ONE_BOGUS: mapInternalAccountsListToUserStorageAccountsList([
|
|
149
|
-
...exports.MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME,
|
|
150
|
-
{
|
|
151
|
-
...exports.MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME[0],
|
|
152
|
-
address: '0x000000',
|
|
153
|
-
metadata: {
|
|
154
|
-
name: `${(0, exports.getMockRandomDefaultAccountName)()} 1`,
|
|
155
|
-
nameLastUpdatedAt: 2,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
]),
|
|
159
|
-
ONE_DEFAULT_NAME: mapInternalAccountsListToUserStorageAccountsList(exports.MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME),
|
|
160
|
-
ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: mapInternalAccountsListToUserStorageAccountsList([
|
|
161
|
-
{
|
|
162
|
-
...exports.MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],
|
|
163
|
-
metadata: {
|
|
164
|
-
name: 'User storage account custom name without nameLastUpdatedAt',
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
]),
|
|
168
|
-
ONE_CUSTOM_NAME_WITH_LAST_UPDATED: mapInternalAccountsListToUserStorageAccountsList([
|
|
169
|
-
{
|
|
170
|
-
...exports.MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],
|
|
171
|
-
metadata: {
|
|
172
|
-
name: 'User storage account custom name with nameLastUpdatedAt',
|
|
173
|
-
nameLastUpdatedAt: 3,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
]),
|
|
177
|
-
};
|
|
178
|
-
//# sourceMappingURL=mockAccounts.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;GAMG;AACH,MAAM,gDAAgD,GAAG,CACvD,gBAAmC,EACnC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,8CAAsC,CAAC,CAAC;AAElE;;;;GAIG;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,G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,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 *\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 *\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"]}
|