@metamask/profile-sync-controller 8.1.1 → 10.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 +22 -1
- package/README.md +32 -0
- package/auth/mocks/package.json +2 -2
- package/dist/controllers/authentication/AuthenticationController.cjs +53 -86
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +11 -23
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +11 -23
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +53 -86
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- 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 +34 -0
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +55 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +55 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.mjs +28 -0
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.cjs +71 -127
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +5 -4
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +5 -4
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +71 -127
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +2 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +2 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +1 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +1 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.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/{__fixtures__ → mocks}/mockResponses.cjs +3 -3
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -0
- package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.d.cts +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -0
- package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.d.mts +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -0
- package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.mjs +3 -3
- 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/dist/controllers/user-storage/network-syncing/controller-integration.cjs +14 -14
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +14 -14
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.cjs +27 -23
- package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.cts +16 -7
- package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.mts +16 -7
- package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.mjs +27 -23
- package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +13 -5
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +13 -5
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -1
- package/dist/controllers/user-storage/types.cjs +3 -0
- package/dist/controllers/user-storage/types.cjs.map +1 -0
- package/dist/controllers/user-storage/types.d.cts +23 -0
- package/dist/controllers/user-storage/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/types.d.mts +23 -0
- package/dist/controllers/user-storage/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/types.mjs +2 -0
- package/dist/controllers/user-storage/types.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +7 -8
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +2 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +2 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +8 -9
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +10 -2
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +3 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +3 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +10 -2
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +1 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +1 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/mocks/auth.cjs +44 -0
- package/dist/sdk/mocks/auth.cjs.map +1 -0
- package/dist/sdk/{__fixtures__/mock-auth.d.cts → mocks/auth.d.cts} +22 -25
- package/dist/sdk/mocks/auth.d.cts.map +1 -0
- package/dist/sdk/{__fixtures__/mock-auth.d.mts → mocks/auth.d.mts} +22 -25
- package/dist/sdk/mocks/auth.d.mts.map +1 -0
- package/dist/sdk/mocks/auth.mjs +41 -0
- package/dist/sdk/mocks/auth.mjs.map +1 -0
- package/dist/sdk/mocks/userstorage.cjs +43 -0
- package/dist/sdk/mocks/userstorage.cjs.map +1 -0
- package/dist/sdk/mocks/userstorage.d.cts +10 -0
- package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
- package/dist/sdk/mocks/userstorage.d.mts +10 -0
- package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
- package/dist/sdk/mocks/userstorage.mjs +15 -0
- package/dist/sdk/mocks/userstorage.mjs.map +1 -0
- package/dist/sdk/user-storage.cjs +34 -39
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +11 -6
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +11 -6
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +34 -39
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +12 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +6 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +6 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +10 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/shared/types/services.cjs +3 -0
- package/dist/shared/types/services.cjs.map +1 -0
- package/dist/shared/types/services.d.cts +10 -0
- package/dist/shared/types/services.d.cts.map +1 -0
- package/dist/shared/types/services.d.mts +10 -0
- package/dist/shared/types/services.d.mts.map +1 -0
- package/dist/shared/types/services.mjs +2 -0
- package/dist/shared/types/services.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 +0 -47
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts +0 -23
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts +0 -23
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +0 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +0 -41
- 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/authentication/services.cjs +0 -132
- package/dist/controllers/authentication/services.cjs.map +0 -1
- package/dist/controllers/authentication/services.d.cts +0 -72
- package/dist/controllers/authentication/services.d.cts.map +0 -1
- package/dist/controllers/authentication/services.d.mts +0 -72
- package/dist/controllers/authentication/services.d.mts.map +0 -1
- package/dist/controllers/authentication/services.mjs +0 -129
- package/dist/controllers/authentication/services.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/controllers/user-storage/services.cjs +0 -306
- package/dist/controllers/user-storage/services.cjs.map +0 -1
- package/dist/controllers/user-storage/services.d.cts +0 -85
- package/dist/controllers/user-storage/services.d.cts.map +0 -1
- package/dist/controllers/user-storage/services.d.mts +0 -85
- package/dist/controllers/user-storage/services.d.mts.map +0 -1
- package/dist/controllers/user-storage/services.mjs +0 -276
- package/dist/controllers/user-storage/services.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.map +0 -1
- 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/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}/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,162 +0,0 @@
|
|
|
1
|
-
import { Messenger } from "@metamask/base-controller";
|
|
2
|
-
import { MOCK_STORAGE_KEY_SIGNATURE } from "./index.mjs";
|
|
3
|
-
const typedMockFn = (_type) => jest.fn();
|
|
4
|
-
/**
|
|
5
|
-
* creates a custom user storage messenger, in case tests need different permissions
|
|
6
|
-
*
|
|
7
|
-
* @param props - overrides
|
|
8
|
-
* @param props.overrideEvents - override events
|
|
9
|
-
* @returns base messenger, and messenger. You can pass this into the mocks below to mock messenger calls
|
|
10
|
-
*/
|
|
11
|
-
export function createCustomUserStorageMessenger(props) {
|
|
12
|
-
const baseMessenger = new Messenger();
|
|
13
|
-
const messenger = baseMessenger.getRestricted({
|
|
14
|
-
name: 'UserStorageController',
|
|
15
|
-
allowedActions: [
|
|
16
|
-
'KeyringController:getState',
|
|
17
|
-
'KeyringController:withKeyring',
|
|
18
|
-
'SnapController:handleRequest',
|
|
19
|
-
'AuthenticationController:getBearerToken',
|
|
20
|
-
'AuthenticationController:getSessionProfile',
|
|
21
|
-
'AuthenticationController:isSignedIn',
|
|
22
|
-
'AuthenticationController:performSignOut',
|
|
23
|
-
'AuthenticationController:performSignIn',
|
|
24
|
-
'AccountsController:listAccounts',
|
|
25
|
-
'AccountsController:updateAccountMetadata',
|
|
26
|
-
'NetworkController:getState',
|
|
27
|
-
'NetworkController:addNetwork',
|
|
28
|
-
'NetworkController:updateNetwork',
|
|
29
|
-
'NetworkController:removeNetwork',
|
|
30
|
-
],
|
|
31
|
-
allowedEvents: props?.overrideEvents ?? [
|
|
32
|
-
'KeyringController:lock',
|
|
33
|
-
'KeyringController:unlock',
|
|
34
|
-
'AccountsController:accountAdded',
|
|
35
|
-
'AccountsController:accountRenamed',
|
|
36
|
-
'NetworkController:networkRemoved',
|
|
37
|
-
],
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
baseMessenger,
|
|
41
|
-
messenger,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Jest Mock Utility to generate a mock User Storage Messenger
|
|
46
|
-
*
|
|
47
|
-
* @param overrideMessengers - override messengers if need to modify the underlying permissions
|
|
48
|
-
* @returns series of mocks to actions that can be called
|
|
49
|
-
*/
|
|
50
|
-
export function mockUserStorageMessenger(overrideMessengers) {
|
|
51
|
-
const { baseMessenger, messenger } = overrideMessengers ?? createCustomUserStorageMessenger();
|
|
52
|
-
const mockSnapGetPublicKey = jest.fn().mockResolvedValue('MOCK_PUBLIC_KEY');
|
|
53
|
-
const mockSnapSignMessage = jest
|
|
54
|
-
.fn()
|
|
55
|
-
.mockResolvedValue(MOCK_STORAGE_KEY_SIGNATURE);
|
|
56
|
-
const mockAuthGetBearerToken = typedMockFn('AuthenticationController:getBearerToken').mockResolvedValue('MOCK_BEARER_TOKEN');
|
|
57
|
-
const mockAuthGetSessionProfile = typedMockFn('AuthenticationController:getSessionProfile').mockResolvedValue({
|
|
58
|
-
identifierId: '',
|
|
59
|
-
profileId: 'MOCK_PROFILE_ID',
|
|
60
|
-
});
|
|
61
|
-
const mockAuthPerformSignIn = typedMockFn('AuthenticationController:performSignIn').mockResolvedValue('New Access Token');
|
|
62
|
-
const mockAuthIsSignedIn = typedMockFn('AuthenticationController:isSignedIn').mockReturnValue(true);
|
|
63
|
-
const mockAuthPerformSignOut = typedMockFn('AuthenticationController:performSignOut');
|
|
64
|
-
const mockKeyringWithKeyring = typedMockFn('KeyringController:withKeyring');
|
|
65
|
-
const mockAccountsListAccounts = jest.fn();
|
|
66
|
-
const mockKeyringGetAccounts = jest.fn();
|
|
67
|
-
const mockKeyringAddAccounts = jest.fn();
|
|
68
|
-
const mockAccountsUpdateAccountMetadata = typedMockFn('AccountsController:updateAccountMetadata').mockResolvedValue(true);
|
|
69
|
-
const mockNetworkControllerGetState = typedMockFn('NetworkController:getState').mockReturnValue({
|
|
70
|
-
selectedNetworkClientId: '',
|
|
71
|
-
networksMetadata: {},
|
|
72
|
-
networkConfigurationsByChainId: {},
|
|
73
|
-
});
|
|
74
|
-
const mockNetworkControllerAddNetwork = typedMockFn('NetworkController:addNetwork');
|
|
75
|
-
const mockNetworkControllerRemoveNetwork = typedMockFn('NetworkController:removeNetwork');
|
|
76
|
-
const mockNetworkControllerUpdateNetwork = typedMockFn('NetworkController:updateNetwork');
|
|
77
|
-
jest.spyOn(messenger, 'call').mockImplementation((...args) => {
|
|
78
|
-
const typedArgs = args;
|
|
79
|
-
const [actionType] = typedArgs;
|
|
80
|
-
if (actionType === 'SnapController:handleRequest') {
|
|
81
|
-
const [, params] = typedArgs;
|
|
82
|
-
if (params.request.method === 'getPublicKey') {
|
|
83
|
-
return mockSnapGetPublicKey();
|
|
84
|
-
}
|
|
85
|
-
if (params.request.method === 'signMessage') {
|
|
86
|
-
return mockSnapSignMessage();
|
|
87
|
-
}
|
|
88
|
-
throw new Error(`MOCK_FAIL - unsupported SnapController:handleRequest call: ${params.request.method}`);
|
|
89
|
-
}
|
|
90
|
-
if (actionType === 'AuthenticationController:getBearerToken') {
|
|
91
|
-
return mockAuthGetBearerToken();
|
|
92
|
-
}
|
|
93
|
-
if (actionType === 'AuthenticationController:getSessionProfile') {
|
|
94
|
-
return mockAuthGetSessionProfile();
|
|
95
|
-
}
|
|
96
|
-
if (actionType === 'AuthenticationController:performSignIn') {
|
|
97
|
-
return mockAuthPerformSignIn();
|
|
98
|
-
}
|
|
99
|
-
if (actionType === 'AuthenticationController:isSignedIn') {
|
|
100
|
-
return mockAuthIsSignedIn();
|
|
101
|
-
}
|
|
102
|
-
if (actionType === 'AuthenticationController:performSignOut') {
|
|
103
|
-
return mockAuthPerformSignOut();
|
|
104
|
-
}
|
|
105
|
-
if (actionType === 'KeyringController:getState') {
|
|
106
|
-
return { isUnlocked: true };
|
|
107
|
-
}
|
|
108
|
-
if (actionType === 'KeyringController:withKeyring') {
|
|
109
|
-
const [, ...params] = typedArgs;
|
|
110
|
-
const [, operation] = params;
|
|
111
|
-
const keyring = {
|
|
112
|
-
getAccounts: mockKeyringGetAccounts,
|
|
113
|
-
addAccounts: mockKeyringAddAccounts,
|
|
114
|
-
};
|
|
115
|
-
return operation(keyring);
|
|
116
|
-
}
|
|
117
|
-
if (actionType === 'AccountsController:listAccounts') {
|
|
118
|
-
return mockAccountsListAccounts();
|
|
119
|
-
}
|
|
120
|
-
if (typedArgs[0] === 'AccountsController:updateAccountMetadata') {
|
|
121
|
-
const [, ...params] = typedArgs;
|
|
122
|
-
return mockAccountsUpdateAccountMetadata(...params);
|
|
123
|
-
}
|
|
124
|
-
if (actionType === 'NetworkController:getState') {
|
|
125
|
-
return mockNetworkControllerGetState();
|
|
126
|
-
}
|
|
127
|
-
if (actionType === 'NetworkController:addNetwork') {
|
|
128
|
-
const [, ...params] = typedArgs;
|
|
129
|
-
return mockNetworkControllerAddNetwork(...params);
|
|
130
|
-
}
|
|
131
|
-
if (actionType === 'NetworkController:removeNetwork') {
|
|
132
|
-
const [, ...params] = typedArgs;
|
|
133
|
-
return mockNetworkControllerRemoveNetwork(...params);
|
|
134
|
-
}
|
|
135
|
-
if (actionType === 'NetworkController:updateNetwork') {
|
|
136
|
-
const [, ...params] = typedArgs;
|
|
137
|
-
return mockNetworkControllerUpdateNetwork(...params);
|
|
138
|
-
}
|
|
139
|
-
throw new Error(`MOCK_FAIL - unsupported messenger call: ${actionType}`);
|
|
140
|
-
});
|
|
141
|
-
return {
|
|
142
|
-
baseMessenger,
|
|
143
|
-
messenger,
|
|
144
|
-
mockSnapGetPublicKey,
|
|
145
|
-
mockSnapSignMessage,
|
|
146
|
-
mockAuthGetBearerToken,
|
|
147
|
-
mockAuthGetSessionProfile,
|
|
148
|
-
mockAuthPerformSignIn,
|
|
149
|
-
mockAuthIsSignedIn,
|
|
150
|
-
mockAuthPerformSignOut,
|
|
151
|
-
mockKeyringGetAccounts,
|
|
152
|
-
mockKeyringAddAccounts,
|
|
153
|
-
mockKeyringWithKeyring,
|
|
154
|
-
mockAccountsUpdateAccountMetadata,
|
|
155
|
-
mockAccountsListAccounts,
|
|
156
|
-
mockNetworkControllerGetState,
|
|
157
|
-
mockNetworkControllerAddNetwork,
|
|
158
|
-
mockNetworkControllerRemoveNetwork,
|
|
159
|
-
mockNetworkControllerUpdateNetwork,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=mockMessenger.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockMessenger.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockMessenger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAGtD,OAAO,EAAE,0BAA0B,EAAE,oBAAU;AAmB/C,MAAM,WAAW,GAAG,CAQlB,KAAiB,EACjB,EAAE,CAAC,IAAI,CAAC,EAAE,EAAsC,CAAC;AAOnD;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAC,KAEhD;IACC,MAAM,aAAa,GAAG,IAAI,SAAS,EAAiC,CAAC;IACrE,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,CAAC;QAC5C,IAAI,EAAE,uBAAuB;QAC7B,cAAc,EAAE;YACd,4BAA4B;YAC5B,+BAA+B;YAC/B,8BAA8B;YAC9B,yCAAyC;YACzC,4CAA4C;YAC5C,qCAAqC;YACrC,yCAAyC;YACzC,wCAAwC;YACxC,iCAAiC;YACjC,0CAA0C;YAC1C,4BAA4B;YAC5B,8BAA8B;YAC9B,iCAAi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,UAAU,KAAK,iCAAiC,EAAE;YACpD,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC;YAChC,OAAO,kCAAkC,CAAC,GAAG,MAAM,CAAC,CAAC;SACtD;QAED,MAAM,IAAI,KAAK,CACb,2CAA2C,UAAoB,EAAE,CAClE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,aAAa;QACb,SAAS;QACT,oBAAoB;QACpB,mBAAmB;QACnB,sBAAsB;QACtB,yBAAyB;QACzB,qBAAqB;QACrB,kBAAkB;QAClB,sBAAsB;QACtB,sBAAsB;QACtB,sBAAsB;QACtB,sBAAsB;QACtB,iCAAiC;QACjC,wBAAwB;QACxB,6BAA6B;QAC7B,+BAA+B;QAC/B,kCAAkC;QAClC,kCAAkC;KACnC,CAAC;AACJ,CAAC","sourcesContent":["import type { NotNamespacedBy } from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport type { EthKeyring } from '@metamask/keyring-internal-api';\n\nimport { MOCK_STORAGE_KEY_SIGNATURE } from '.';\nimport type {\n AllowedActions,\n AllowedEvents,\n UserStorageControllerMessenger,\n} from '..';\n\ntype GetHandler<ActionType extends AllowedActions['type']> = Extract<\n AllowedActions,\n { type: ActionType }\n>['handler'];\n\ntype CallParams = {\n [K in AllowedActions['type']]: [\n K,\n ...Parameters<Extract<AllowedActions, { type: K }>['handler']>,\n ];\n}[AllowedActions['type']];\n\nconst typedMockFn = <\n ActionType extends AllowedActions['type'],\n Handler = GetHandler<ActionType>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Func extends (...args: any) => any = Handler extends (...args: any[]) => any\n ? Handler\n : never,\n>(\n _type: ActionType,\n) => jest.fn<ReturnType<Func>, Parameters<Func>>();\n\ntype ExternalEvents = NotNamespacedBy<\n 'UserStorageController',\n AllowedEvents['type']\n>;\n\n/**\n * creates a custom user storage messenger, in case tests need different permissions\n *\n * @param props - overrides\n * @param props.overrideEvents - override events\n * @returns base messenger, and messenger. You can pass this into the mocks below to mock messenger calls\n */\nexport function createCustomUserStorageMessenger(props?: {\n overrideEvents?: ExternalEvents[];\n}) {\n const baseMessenger = new Messenger<AllowedActions, AllowedEvents>();\n const messenger = baseMessenger.getRestricted({\n name: 'UserStorageController',\n allowedActions: [\n 'KeyringController:getState',\n 'KeyringController:withKeyring',\n 'SnapController:handleRequest',\n 'AuthenticationController:getBearerToken',\n 'AuthenticationController:getSessionProfile',\n 'AuthenticationController:isSignedIn',\n 'AuthenticationController:performSignOut',\n 'AuthenticationController:performSignIn',\n 'AccountsController:listAccounts',\n 'AccountsController:updateAccountMetadata',\n 'NetworkController:getState',\n 'NetworkController:addNetwork',\n 'NetworkController:updateNetwork',\n 'NetworkController:removeNetwork',\n ],\n allowedEvents: props?.overrideEvents ?? [\n 'KeyringController:lock',\n 'KeyringController:unlock',\n 'AccountsController:accountAdded',\n 'AccountsController:accountRenamed',\n 'NetworkController:networkRemoved',\n ],\n });\n\n return {\n baseMessenger,\n messenger,\n };\n}\n\ntype OverrideMessengers = {\n baseMessenger: Messenger<AllowedActions, AllowedEvents>;\n messenger: UserStorageControllerMessenger;\n};\n\n/**\n * Jest Mock Utility to generate a mock User Storage Messenger\n *\n * @param overrideMessengers - override messengers if need to modify the underlying permissions\n * @returns series of mocks to actions that can be called\n */\nexport function mockUserStorageMessenger(\n overrideMessengers?: OverrideMessengers,\n) {\n const { baseMessenger, messenger } =\n overrideMessengers ?? createCustomUserStorageMessenger();\n\n const mockSnapGetPublicKey = jest.fn().mockResolvedValue('MOCK_PUBLIC_KEY');\n const mockSnapSignMessage = jest\n .fn()\n .mockResolvedValue(MOCK_STORAGE_KEY_SIGNATURE);\n\n const mockAuthGetBearerToken = typedMockFn(\n 'AuthenticationController:getBearerToken',\n ).mockResolvedValue('MOCK_BEARER_TOKEN');\n\n const mockAuthGetSessionProfile = typedMockFn(\n 'AuthenticationController:getSessionProfile',\n ).mockResolvedValue({\n identifierId: '',\n profileId: 'MOCK_PROFILE_ID',\n });\n\n const mockAuthPerformSignIn = typedMockFn(\n 'AuthenticationController:performSignIn',\n ).mockResolvedValue('New Access Token');\n\n const mockAuthIsSignedIn = typedMockFn(\n 'AuthenticationController:isSignedIn',\n ).mockReturnValue(true);\n\n const mockAuthPerformSignOut = typedMockFn(\n 'AuthenticationController:performSignOut',\n );\n\n const mockKeyringWithKeyring = typedMockFn('KeyringController:withKeyring');\n\n const mockAccountsListAccounts = jest.fn();\n\n const mockKeyringGetAccounts = jest.fn();\n const mockKeyringAddAccounts = jest.fn();\n\n const mockAccountsUpdateAccountMetadata = typedMockFn(\n 'AccountsController:updateAccountMetadata',\n ).mockResolvedValue(true as never);\n\n const mockNetworkControllerGetState = typedMockFn(\n 'NetworkController:getState',\n ).mockReturnValue({\n selectedNetworkClientId: '',\n networksMetadata: {},\n networkConfigurationsByChainId: {},\n });\n\n const mockNetworkControllerAddNetwork = typedMockFn(\n 'NetworkController:addNetwork',\n );\n\n const mockNetworkControllerRemoveNetwork = typedMockFn(\n 'NetworkController:removeNetwork',\n );\n\n const mockNetworkControllerUpdateNetwork = typedMockFn(\n 'NetworkController:updateNetwork',\n );\n\n jest.spyOn(messenger, 'call').mockImplementation((...args) => {\n const typedArgs = args as unknown as CallParams;\n const [actionType] = typedArgs;\n\n if (actionType === 'SnapController:handleRequest') {\n const [, params] = typedArgs;\n if (params.request.method === 'getPublicKey') {\n return mockSnapGetPublicKey();\n }\n\n if (params.request.method === 'signMessage') {\n return mockSnapSignMessage();\n }\n\n throw new Error(\n `MOCK_FAIL - unsupported SnapController:handleRequest call: ${\n params.request.method as string\n }`,\n );\n }\n\n if (actionType === 'AuthenticationController:getBearerToken') {\n return mockAuthGetBearerToken();\n }\n\n if (actionType === 'AuthenticationController:getSessionProfile') {\n return mockAuthGetSessionProfile();\n }\n\n if (actionType === 'AuthenticationController:performSignIn') {\n return mockAuthPerformSignIn();\n }\n\n if (actionType === 'AuthenticationController:isSignedIn') {\n return mockAuthIsSignedIn();\n }\n\n if (actionType === 'AuthenticationController:performSignOut') {\n return mockAuthPerformSignOut();\n }\n\n if (actionType === 'KeyringController:getState') {\n return { isUnlocked: true };\n }\n\n if (actionType === 'KeyringController:withKeyring') {\n const [, ...params] = typedArgs;\n const [, operation] = params;\n\n const keyring = {\n getAccounts: mockKeyringGetAccounts,\n addAccounts: mockKeyringAddAccounts,\n } as unknown as EthKeyring<never>;\n\n return operation(keyring);\n }\n\n if (actionType === 'AccountsController:listAccounts') {\n return mockAccountsListAccounts();\n }\n\n if (typedArgs[0] === 'AccountsController:updateAccountMetadata') {\n const [, ...params] = typedArgs;\n return mockAccountsUpdateAccountMetadata(...params);\n }\n\n if (actionType === 'NetworkController:getState') {\n return mockNetworkControllerGetState();\n }\n\n if (actionType === 'NetworkController:addNetwork') {\n const [, ...params] = typedArgs;\n return mockNetworkControllerAddNetwork(...params);\n }\n\n if (actionType === 'NetworkController:removeNetwork') {\n const [, ...params] = typedArgs;\n return mockNetworkControllerRemoveNetwork(...params);\n }\n\n if (actionType === 'NetworkController:updateNetwork') {\n const [, ...params] = typedArgs;\n return mockNetworkControllerUpdateNetwork(...params);\n }\n\n throw new Error(\n `MOCK_FAIL - unsupported messenger call: ${actionType as string}`,\n );\n });\n\n return {\n baseMessenger,\n messenger,\n mockSnapGetPublicKey,\n mockSnapSignMessage,\n mockAuthGetBearerToken,\n mockAuthGetSessionProfile,\n mockAuthPerformSignIn,\n mockAuthIsSignedIn,\n mockAuthPerformSignOut,\n mockKeyringGetAccounts,\n mockKeyringAddAccounts,\n mockKeyringWithKeyring,\n mockAccountsUpdateAccountMetadata,\n mockAccountsListAccounts,\n mockNetworkControllerGetState,\n mockNetworkControllerAddNetwork,\n mockNetworkControllerRemoveNetwork,\n mockNetworkControllerUpdateNetwork,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings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EAC/E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,8CAA8C,kDAQzD","sourcesContent":["import {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport {\n createEntryPath,\n USER_STORAGE_FEATURE_NAMES,\n} from '../../../shared/storage-schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n *\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n *\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n const decryptedData = [];\n\n for (const data of dataArr) {\n decryptedData.push({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n });\n }\n\n return decryptedData;\n}\n\n/**\n * Creates a mock user-storage api GET request\n *\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n *\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchPutResponse = (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchDeleteResponse = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageResponse = (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageAllFeatureEntriesResponse = (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAKxC,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AASrB,eAAO,MAAM,0BAA0B,SAC/B,gCAAgC,GAAG,8BAA8B,WAUxE,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;;GAKG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAWlD;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,gCAAsG;;;;GAO7G;AAED;;;;;;GAMG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,8BAAyE,EAC/E,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B;;;;CAOrC,CAAC;AAEF,eAAO,MAAM,qCAAqC,UAC1C,8BAA8B;;;;CAOrC,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,8CAA8C,UACnD,8BAA8B;;;;CAOrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAKxC,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AASrB,eAAO,MAAM,0BAA0B,SAC/B,gCAAgC,GAAG,8BAA8B,WAUxE,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;;GAKG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAWlD;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,gCAAsG;;;;GAO7G;AAED;;;;;;GAMG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,8BAAyE,EAC/E,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B;;;;CAOrC,CAAC;AAEF,eAAO,MAAM,qCAAqC,UAC1C,8BAA8B;;;;CAOrC,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,8CAA8C,UACnD,8BAA8B;;;;CAOrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,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0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport {\n createEntryPath,\n USER_STORAGE_FEATURE_NAMES,\n} from '../../../shared/storage-schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n *\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n *\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n const decryptedData = [];\n\n for (const data of dataArr) {\n decryptedData.push({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n });\n }\n\n return decryptedData;\n}\n\n/**\n * Creates a mock user-storage api GET request\n *\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n *\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchPutResponse = (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchDeleteResponse = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageResponse = (\n path: UserStoragePathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageAllFeatureEntriesResponse = (\n path: UserStoragePathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -1,82 +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.mockEndpointBatchDeleteUserStorage = exports.mockEndpointDeleteUserStorageAllFeatureEntries = exports.mockEndpointDeleteUserStorage = exports.mockEndpointBatchUpsertUserStorage = exports.mockEndpointUpsertUserStorage = exports.mockEndpointGetUserStorage = exports.mockEndpointGetUserStorageAllFeatureEntries = void 0;
|
|
7
|
-
const nock_1 = __importDefault(require("nock"));
|
|
8
|
-
const mockResponses_1 = require("./mockResponses.cjs");
|
|
9
|
-
const storage_schema_1 = require("../../../shared/storage-schema.cjs");
|
|
10
|
-
const mockEndpointGetUserStorageAllFeatureEntries = async (path = storage_schema_1.USER_STORAGE_FEATURE_NAMES.notifications, mockReply) => {
|
|
11
|
-
const mockResponse = await (0, mockResponses_1.getMockUserStorageAllFeatureEntriesResponse)(path);
|
|
12
|
-
const reply = mockReply ?? {
|
|
13
|
-
status: 200,
|
|
14
|
-
body: mockResponse.response,
|
|
15
|
-
};
|
|
16
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
17
|
-
.get('')
|
|
18
|
-
.reply(reply.status, reply.body);
|
|
19
|
-
return mockEndpoint;
|
|
20
|
-
};
|
|
21
|
-
exports.mockEndpointGetUserStorageAllFeatureEntries = mockEndpointGetUserStorageAllFeatureEntries;
|
|
22
|
-
const mockEndpointGetUserStorage = async (path = `${storage_schema_1.USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`, mockReply) => {
|
|
23
|
-
const mockResponse = await (0, mockResponses_1.getMockUserStorageGetResponse)(path);
|
|
24
|
-
const reply = mockReply ?? {
|
|
25
|
-
status: 200,
|
|
26
|
-
body: mockResponse.response,
|
|
27
|
-
};
|
|
28
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
29
|
-
.get('')
|
|
30
|
-
.reply(reply.status, reply.body);
|
|
31
|
-
return mockEndpoint;
|
|
32
|
-
};
|
|
33
|
-
exports.mockEndpointGetUserStorage = mockEndpointGetUserStorage;
|
|
34
|
-
const mockEndpointUpsertUserStorage = (path = `${storage_schema_1.USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`, mockReply, expectCallback) => {
|
|
35
|
-
const mockResponse = (0, mockResponses_1.getMockUserStoragePutResponse)(path);
|
|
36
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
37
|
-
.put('')
|
|
38
|
-
.reply(mockReply?.status ?? 204, async (_, requestBody) => {
|
|
39
|
-
await expectCallback?.(requestBody);
|
|
40
|
-
});
|
|
41
|
-
return mockEndpoint;
|
|
42
|
-
};
|
|
43
|
-
exports.mockEndpointUpsertUserStorage = mockEndpointUpsertUserStorage;
|
|
44
|
-
const mockEndpointBatchUpsertUserStorage = (path = storage_schema_1.USER_STORAGE_FEATURE_NAMES.notifications, mockReply, callback) => {
|
|
45
|
-
const mockResponse = (0, mockResponses_1.getMockUserStorageBatchPutResponse)(path);
|
|
46
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
47
|
-
.put('')
|
|
48
|
-
.reply(mockReply?.status ?? 204, async (uri, requestBody) => {
|
|
49
|
-
return await callback?.(uri, requestBody);
|
|
50
|
-
});
|
|
51
|
-
return mockEndpoint;
|
|
52
|
-
};
|
|
53
|
-
exports.mockEndpointBatchUpsertUserStorage = mockEndpointBatchUpsertUserStorage;
|
|
54
|
-
const mockEndpointDeleteUserStorage = (path = `${storage_schema_1.USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`, mockReply) => {
|
|
55
|
-
const mockResponse = (0, mockResponses_1.deleteMockUserStorageResponse)(path);
|
|
56
|
-
const reply = mockReply ?? {
|
|
57
|
-
status: 200,
|
|
58
|
-
};
|
|
59
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url).delete('').reply(reply.status);
|
|
60
|
-
return mockEndpoint;
|
|
61
|
-
};
|
|
62
|
-
exports.mockEndpointDeleteUserStorage = mockEndpointDeleteUserStorage;
|
|
63
|
-
const mockEndpointDeleteUserStorageAllFeatureEntries = (path = storage_schema_1.USER_STORAGE_FEATURE_NAMES.notifications, mockReply) => {
|
|
64
|
-
const mockResponse = (0, mockResponses_1.deleteMockUserStorageAllFeatureEntriesResponse)(path);
|
|
65
|
-
const reply = mockReply ?? {
|
|
66
|
-
status: 200,
|
|
67
|
-
};
|
|
68
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url).delete('').reply(reply.status);
|
|
69
|
-
return mockEndpoint;
|
|
70
|
-
};
|
|
71
|
-
exports.mockEndpointDeleteUserStorageAllFeatureEntries = mockEndpointDeleteUserStorageAllFeatureEntries;
|
|
72
|
-
const mockEndpointBatchDeleteUserStorage = (path = 'notifications', mockReply, callback) => {
|
|
73
|
-
const mockResponse = (0, mockResponses_1.getMockUserStorageBatchDeleteResponse)(path);
|
|
74
|
-
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
75
|
-
.put('')
|
|
76
|
-
.reply(mockReply?.status ?? 204, async (uri, requestBody) => {
|
|
77
|
-
return await callback?.(uri, requestBody);
|
|
78
|
-
});
|
|
79
|
-
return mockEndpoint;
|
|
80
|
-
};
|
|
81
|
-
exports.mockEndpointBatchDeleteUserStorage = mockEndpointBatchDeleteUserStorage;
|
|
82
|
-
//# sourceMappingURL=mockServices.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"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C,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3E,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,6BAA6B,iCAYxC;AAEK,MAAM,8CAA8C,GAAG,CAC5D,OAAuC,2CAA0B,CAAC,aAAa,EAC/E,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,8DAA8C,EAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;KACZ,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3E,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,8CAA8C,kDAYzD;AAEK,MAAM,kCAAkC,GAAG,CAChD,OAAuC,eAAe,EACtD,SAAqC,EACrC,QAAiE,EACjE,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,qDAAqC,EAAC,IAAI,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,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;AAZW,QAAA,kCAAkC,sCAY7C","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,15 +0,0 @@
|
|
|
1
|
-
import nock from "nock";
|
|
2
|
-
import { type UserStoragePathWithFeatureAndKey, type UserStoragePathWithFeatureOnly } from "../../../shared/storage-schema.cjs";
|
|
3
|
-
type MockReply = {
|
|
4
|
-
status: nock.StatusCode;
|
|
5
|
-
body?: nock.Body;
|
|
6
|
-
};
|
|
7
|
-
export declare const mockEndpointGetUserStorageAllFeatureEntries: (path?: UserStoragePathWithFeatureOnly, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
8
|
-
export declare const mockEndpointGetUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
9
|
-
export declare const mockEndpointUpsertUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: Pick<MockReply, 'status'>, expectCallback?: ((requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
10
|
-
export declare const mockEndpointBatchUpsertUserStorage: (path?: UserStoragePathWithFeatureOnly, mockReply?: Pick<MockReply, 'status'>, callback?: ((uri: string, requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
11
|
-
export declare const mockEndpointDeleteUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: MockReply) => nock.Scope;
|
|
12
|
-
export declare const mockEndpointDeleteUserStorageAllFeatureEntries: (path?: UserStoragePathWithFeatureOnly, mockReply?: MockReply) => nock.Scope;
|
|
13
|
-
export declare const mockEndpointBatchDeleteUserStorage: (path?: UserStoragePathWithFeatureOnly, mockReply?: Pick<MockReply, 'status'>, callback?: ((uri: string, requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=mockServices.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAWxB,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACpC,2CAAuC;AAExC,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,2CAA2C,UAChD,8BAA8B,cACxB,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAC/B,gCAAgC,cAC1B,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC,cAC1B,KAAK,SAAS,EAAE,QAAQ,CAAC,kCACN,SAAS,KAAK,QAAQ,IAAI,CAAC,4BAS3D,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B,cACxB,KAAK,SAAS,EAAE,QAAQ,CAAC,oBACpB,MAAM,eAAe,SAAS,KAAK,QAAQ,IAAI,CAAC,4BASlE,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC,cAC1B,SAAS,eAUtB,CAAC;AAEF,eAAO,MAAM,8CAA8C,UACnD,8BAA8B,cACxB,SAAS,eAUtB,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B,cACxB,KAAK,SAAS,EAAE,QAAQ,CAAC,oBACpB,MAAM,eAAe,SAAS,KAAK,QAAQ,IAAI,CAAC,4BASlE,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import nock from "nock";
|
|
2
|
-
import { type UserStoragePathWithFeatureAndKey, type UserStoragePathWithFeatureOnly } from "../../../shared/storage-schema.mjs";
|
|
3
|
-
type MockReply = {
|
|
4
|
-
status: nock.StatusCode;
|
|
5
|
-
body?: nock.Body;
|
|
6
|
-
};
|
|
7
|
-
export declare const mockEndpointGetUserStorageAllFeatureEntries: (path?: UserStoragePathWithFeatureOnly, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
8
|
-
export declare const mockEndpointGetUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
9
|
-
export declare const mockEndpointUpsertUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: Pick<MockReply, 'status'>, expectCallback?: ((requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
10
|
-
export declare const mockEndpointBatchUpsertUserStorage: (path?: UserStoragePathWithFeatureOnly, mockReply?: Pick<MockReply, 'status'>, callback?: ((uri: string, requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
11
|
-
export declare const mockEndpointDeleteUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: MockReply) => nock.Scope;
|
|
12
|
-
export declare const mockEndpointDeleteUserStorageAllFeatureEntries: (path?: UserStoragePathWithFeatureOnly, mockReply?: MockReply) => nock.Scope;
|
|
13
|
-
export declare const mockEndpointBatchDeleteUserStorage: (path?: UserStoragePathWithFeatureOnly, mockReply?: Pick<MockReply, 'status'>, callback?: ((uri: string, requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=mockServices.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAWxB,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACpC,2CAAuC;AAExC,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,2CAA2C,UAChD,8BAA8B,cACxB,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAC/B,gCAAgC,cAC1B,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC,cAC1B,KAAK,SAAS,EAAE,QAAQ,CAAC,kCACN,SAAS,KAAK,QAAQ,IAAI,CAAC,4BAS3D,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B,cACxB,KAAK,SAAS,EAAE,QAAQ,CAAC,oBACpB,MAAM,eAAe,SAAS,KAAK,QAAQ,IAAI,CAAC,4BASlE,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC,cAC1B,SAAS,eAUtB,CAAC;AAEF,eAAO,MAAM,8CAA8C,UACnD,8BAA8B,cACxB,SAAS,eAUtB,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B,cACxB,KAAK,SAAS,EAAE,QAAQ,CAAC,oBACpB,MAAM,eAAe,SAAS,KAAK,QAAQ,IAAI,CAAC,4BASlE,CAAC"}
|
|
@@ -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,0BAA0B,GAAG,KAAK,EAC7C,OAAyC,GAAG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AC,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
|