@metamask/profile-sync-controller 4.1.1 → 6.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 +28 -1
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +2 -2
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +2 -2
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +0 -5
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +0 -5
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -1
- package/dist/controllers/authentication/services.cjs +0 -2
- package/dist/controllers/authentication/services.cjs.map +1 -1
- package/dist/controllers/authentication/services.d.cts +5 -3
- package/dist/controllers/authentication/services.d.cts.map +1 -1
- package/dist/controllers/authentication/services.d.mts +5 -3
- package/dist/controllers/authentication/services.d.mts.map +1 -1
- package/dist/controllers/authentication/services.mjs +0 -2
- package/dist/controllers/authentication/services.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +11 -42
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +8 -15
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +8 -15
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +11 -42
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs +3 -15
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +10 -10
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +10 -10
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs +4 -16
- package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +5 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts +4 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +4 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +5 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +5 -2
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +3 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +3 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +5 -2
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs +2 -0
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts +1 -0
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts +1 -0
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs +2 -0
- package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +3 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +5 -5
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +5 -5
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +3 -1
- package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +4 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +3 -0
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +3 -0
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +4 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +3 -6
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +1 -0
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +1 -0
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +3 -6
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +6 -2
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +5 -0
- 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 +5 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +6 -2
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/types.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/types.d.cts +1 -1
- package/dist/controllers/user-storage/account-syncing/types.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/types.d.mts +1 -1
- package/dist/controllers/user-storage/account-syncing/types.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/types.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.cjs +3 -1
- package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.cts +2 -0
- package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.mts +2 -0
- package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.mjs +3 -1
- package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/add-network-utils.cjs +1 -0
- package/dist/controllers/user-storage/network-syncing/add-network-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/add-network-utils.d.cts +1 -0
- package/dist/controllers/user-storage/network-syncing/add-network-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/add-network-utils.d.mts +1 -0
- package/dist/controllers/user-storage/network-syncing/add-network-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/add-network-utils.mjs +1 -0
- package/dist/controllers/user-storage/network-syncing/add-network-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +2 -0
- 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 +2 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.cjs +5 -0
- package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.cts +5 -1
- package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.mts +5 -1
- package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.mjs +5 -0
- package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-all.cjs +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-all.mjs +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-all.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.map +1 -1
- 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/network-syncing/update-network-utils.cjs +3 -0
- package/dist/controllers/user-storage/network-syncing/update-network-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/update-network-utils.d.cts +3 -0
- package/dist/controllers/user-storage/network-syncing/update-network-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/update-network-utils.d.mts +3 -0
- package/dist/controllers/user-storage/network-syncing/update-network-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/update-network-utils.mjs +3 -0
- package/dist/controllers/user-storage/network-syncing/update-network-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/services.cjs +0 -1
- package/dist/controllers/user-storage/services.cjs.map +1 -1
- package/dist/controllers/user-storage/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/services.mjs +0 -1
- package/dist/controllers/user-storage/services.mjs.map +1 -1
- package/dist/controllers/user-storage/utils.cjs +2 -0
- package/dist/controllers/user-storage/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/utils.d.cts +2 -0
- package/dist/controllers/user-storage/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/utils.d.mts +2 -0
- package/dist/controllers/user-storage/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/utils.mjs +2 -0
- package/dist/controllers/user-storage/utils.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-auth.cjs +0 -15
- package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-auth.mjs +0 -15
- package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.cjs +0 -2
- package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.mjs +0 -2
- package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.cjs +2 -1
- package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.d.cts +1 -0
- package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.d.mts +1 -0
- package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -1
- package/dist/sdk/__fixtures__/test-utils.mjs +2 -1
- package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +1 -2
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +1 -2
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +0 -3
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs +0 -3
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +1 -3
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +1 -1
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +1 -1
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +1 -3
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.cjs +4 -4
- package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs +4 -4
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
- package/dist/shared/encryption/constants.cjs +0 -2
- package/dist/shared/encryption/constants.cjs.map +1 -1
- package/dist/shared/encryption/constants.d.cts.map +1 -1
- package/dist/shared/encryption/constants.d.mts.map +1 -1
- package/dist/shared/encryption/constants.mjs +0 -2
- package/dist/shared/encryption/constants.mjs.map +1 -1
- package/dist/shared/encryption/encryption.cjs +1 -0
- package/dist/shared/encryption/encryption.cjs.map +1 -1
- package/dist/shared/encryption/encryption.d.cts +1 -0
- package/dist/shared/encryption/encryption.d.cts.map +1 -1
- package/dist/shared/encryption/encryption.d.mts +1 -0
- package/dist/shared/encryption/encryption.d.mts.map +1 -1
- package/dist/shared/encryption/encryption.mjs +1 -0
- package/dist/shared/encryption/encryption.mjs.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;
|
|
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"}
|
|
@@ -6,8 +6,8 @@ function $importDefault(module) {
|
|
|
6
6
|
}
|
|
7
7
|
import $nock from "nock";
|
|
8
8
|
const nock = $importDefault($nock);
|
|
9
|
-
import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
|
|
10
9
|
import { getMockUserStorageGetResponse, getMockUserStoragePutResponse, getMockUserStorageAllFeatureEntriesResponse, getMockUserStorageBatchPutResponse, getMockUserStorageBatchDeleteResponse, deleteMockUserStorageAllFeatureEntriesResponse, deleteMockUserStorageResponse } from "./mockResponses.mjs";
|
|
10
|
+
import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
|
|
11
11
|
export const mockEndpointGetUserStorageAllFeatureEntries = async (path = USER_STORAGE_FEATURE_NAMES.notifications, mockReply) => {
|
|
12
12
|
const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);
|
|
13
13
|
const reply = mockReply ?? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,EACL,
|
|
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,2CAAu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,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,8CAA8C,CAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;KACZ,CAAC;IAEF,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3E,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,OAAuC,eAAe,EACtD,SAAqC,EACrC,QAAiE,EACjE,EAAE;IACF,MAAM,YAAY,GAAG,qCAAqC,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,IAAI,CAAC,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","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"]}
|
|
@@ -4,10 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.waitFor = exports.decryptBatchUpsertBody = exports.createMockUserStorageEntries = exports.createMockUserStorageEntry = void 0;
|
|
7
|
-
const encryption_1 = __importDefault(require("../../../shared/encryption/encryption.cjs"));
|
|
8
7
|
const mockStorage_1 = require("./mockStorage.cjs");
|
|
8
|
+
const encryption_1 = __importDefault(require("../../../shared/encryption/encryption.cjs"));
|
|
9
9
|
/**
|
|
10
10
|
* Test Utility - creates a realistic mock user-storage entry
|
|
11
|
+
*
|
|
11
12
|
* @param data - data to encrypt
|
|
12
13
|
* @returns user storage entry
|
|
13
14
|
*/
|
|
@@ -20,6 +21,7 @@ async function createMockUserStorageEntry(data) {
|
|
|
20
21
|
exports.createMockUserStorageEntry = createMockUserStorageEntry;
|
|
21
22
|
/**
|
|
22
23
|
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
24
|
+
*
|
|
23
25
|
* @param data - data array to encrypt
|
|
24
26
|
* @returns user storage entry
|
|
25
27
|
*/
|
|
@@ -29,6 +31,7 @@ async function createMockUserStorageEntries(data) {
|
|
|
29
31
|
exports.createMockUserStorageEntries = createMockUserStorageEntries;
|
|
30
32
|
/**
|
|
31
33
|
* Test Utility - decrypts a realistic batch upsert payload
|
|
34
|
+
*
|
|
32
35
|
* @param requestBody - nock body
|
|
33
36
|
* @param storageKey - storage key
|
|
34
37
|
* @returns decrypted body
|
|
@@ -62,7 +65,7 @@ const waitFor = async (assertionFn, options = {}) => {
|
|
|
62
65
|
clearInterval(intervalId);
|
|
63
66
|
resolve();
|
|
64
67
|
}
|
|
65
|
-
catch
|
|
68
|
+
catch {
|
|
66
69
|
if (Date.now() - startTime >= timeoutMs) {
|
|
67
70
|
clearInterval(intervalId);
|
|
68
71
|
reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;;;;AAEA,2FAA+D;
|
|
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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E,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"]}
|
|
@@ -2,18 +2,21 @@ import type nock from "nock";
|
|
|
2
2
|
import type { GetUserStorageAllFeatureEntriesResponse, GetUserStorageResponse } from "../services.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Test Utility - creates a realistic mock user-storage entry
|
|
5
|
+
*
|
|
5
6
|
* @param data - data to encrypt
|
|
6
7
|
* @returns user storage entry
|
|
7
8
|
*/
|
|
8
9
|
export declare function createMockUserStorageEntry(data: unknown): Promise<GetUserStorageResponse>;
|
|
9
10
|
/**
|
|
10
11
|
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
12
|
+
*
|
|
11
13
|
* @param data - data array to encrypt
|
|
12
14
|
* @returns user storage entry
|
|
13
15
|
*/
|
|
14
16
|
export declare function createMockUserStorageEntries(data: unknown[]): Promise<GetUserStorageAllFeatureEntriesResponse>;
|
|
15
17
|
/**
|
|
16
18
|
* Test Utility - decrypts a realistic batch upsert payload
|
|
19
|
+
*
|
|
17
20
|
* @param requestBody - nock body
|
|
18
21
|
* @param storageKey - storage key
|
|
19
22
|
* @returns decrypted body
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|
|
@@ -2,18 +2,21 @@ import type nock from "nock";
|
|
|
2
2
|
import type { GetUserStorageAllFeatureEntriesResponse, GetUserStorageResponse } from "../services.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Test Utility - creates a realistic mock user-storage entry
|
|
5
|
+
*
|
|
5
6
|
* @param data - data to encrypt
|
|
6
7
|
* @returns user storage entry
|
|
7
8
|
*/
|
|
8
9
|
export declare function createMockUserStorageEntry(data: unknown): Promise<GetUserStorageResponse>;
|
|
9
10
|
/**
|
|
10
11
|
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
12
|
+
*
|
|
11
13
|
* @param data - data array to encrypt
|
|
12
14
|
* @returns user storage entry
|
|
13
15
|
*/
|
|
14
16
|
export declare function createMockUserStorageEntries(data: unknown[]): Promise<GetUserStorageAllFeatureEntriesResponse>;
|
|
15
17
|
/**
|
|
16
18
|
* Test Utility - decrypts a realistic batch upsert payload
|
|
19
|
+
*
|
|
17
20
|
* @param requestBody - nock body
|
|
18
21
|
* @param storageKey - storage key
|
|
19
22
|
* @returns decrypted body
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,7 +1,8 @@
|
|
|
1
|
-
import encryption from "../../../shared/encryption/encryption.mjs";
|
|
2
1
|
import { MOCK_STORAGE_KEY } from "./mockStorage.mjs";
|
|
2
|
+
import encryption from "../../../shared/encryption/encryption.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Test Utility - creates a realistic mock user-storage entry
|
|
5
|
+
*
|
|
5
6
|
* @param data - data to encrypt
|
|
6
7
|
* @returns user storage entry
|
|
7
8
|
*/
|
|
@@ -13,6 +14,7 @@ export async function createMockUserStorageEntry(data) {
|
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Test Utility - creates a realistic mock user-storage get-all entry
|
|
17
|
+
*
|
|
16
18
|
* @param data - data array to encrypt
|
|
17
19
|
* @returns user storage entry
|
|
18
20
|
*/
|
|
@@ -21,6 +23,7 @@ export async function createMockUserStorageEntries(data) {
|
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Test Utility - decrypts a realistic batch upsert payload
|
|
26
|
+
*
|
|
24
27
|
* @param requestBody - nock body
|
|
25
28
|
* @param storageKey - storage key
|
|
26
29
|
* @returns decrypted body
|
|
@@ -53,7 +56,7 @@ export const waitFor = async (assertionFn, options = {}) => {
|
|
|
53
56
|
clearInterval(intervalId);
|
|
54
57
|
resolve();
|
|
55
58
|
}
|
|
56
|
-
catch
|
|
59
|
+
catch {
|
|
57
60
|
if (Date.now() - startTime >= timeoutMs) {
|
|
58
61
|
clearInterval(intervalId);
|
|
59
62
|
reject(new Error(`waitFor: timeout reached after ${timeoutMs}ms`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
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,CA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,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"]}
|
|
@@ -8,12 +8,14 @@ const utils_1 = require("../utils.cjs");
|
|
|
8
8
|
/**
|
|
9
9
|
* Map an array of internal accounts to an array of user storage accounts
|
|
10
10
|
* Only used for testing purposes
|
|
11
|
+
*
|
|
11
12
|
* @param internalAccounts - An array of internal accounts
|
|
12
13
|
* @returns An array of user storage accounts
|
|
13
14
|
*/
|
|
14
15
|
const mapInternalAccountsListToUserStorageAccountsList = (internalAccounts) => internalAccounts.map(utils_1.mapInternalAccountToUserStorageAccount);
|
|
15
16
|
/**
|
|
16
17
|
* Get a random default account name from the list of localized default account names
|
|
18
|
+
*
|
|
17
19
|
* @returns A random default account name
|
|
18
20
|
*/
|
|
19
21
|
const getMockRandomDefaultAccountName = () => constants_1.LOCALIZED_DEFAULT_ACCOUNT_NAMES[Math.floor(Math.random() * constants_1.LOCALIZED_DEFAULT_ACCOUNT_NAMES.length)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockAccounts.cjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,qEAA4D;AAG5D,gDAA+D;AAC/D,wCAAkE;AAElE
|
|
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,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DAAgD,CACpE,8BAAsB,CAAC,GAAwB,CAChD;IACD,GAAG,EAAE,gDAAgD,CACnD,8BAAsB,CAAC,GAAwB,CAChD;IACD,gCAAgC,EAC9B,gDAAgD,CAAC;QAC/C,GAAG,8BAAsB,CAAC,gBAAgB;QAC1C;YACE,GAAG,8BAAsB,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAC7C,OAAO,EAAE,UAAU;YACnB,QAAQ,EAAE;gBACR,IAAI,EAAE,GAAG,IAAA,uCAA+B,GAAE,IAAI;gBAC9C,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;IACzB,gBAAgB,EAAE,gDAAgD,CAChE,8BAAsB,CAAC,gBAAqC,CAC7D;IACD,oCAAoC,EAClC,gDAAgD,CAAC;QAC/C;YACE,GAAG,8BAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,4DAA4D;aACnE;SACF;KACmB,CAAC;IACzB,iCAAiC,EAC/B,gDAAgD,CAAC;QAC/C;YACE,GAAG,8BAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,yDAAyD;gBAC/D,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;CAC1B,CAAC","sourcesContent":["import { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from '../constants';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\n\n/**\n * Map an array of internal accounts to an array of user storage accounts\n * Only used for testing purposes\n *\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"]}
|
|
@@ -2,6 +2,7 @@ import { EthAccountType } from "@metamask/keyring-api";
|
|
|
2
2
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
3
3
|
/**
|
|
4
4
|
* Get a random default account name from the list of localized default account names
|
|
5
|
+
*
|
|
5
6
|
* @returns A random default account name
|
|
6
7
|
*/
|
|
7
8
|
export declare const getMockRandomDefaultAccountName: () => "Account" | "መለያ" | "الحساب" | "Профил" | "অ্যাকাউন্ট" | "Compte" | "Účet" | "Konto" | "Λογαριασμός" | "Cuenta" | "حساب" | "Tili" | "એકાઉન્ટ" | "חשבון" | "अकाउंट" | "खाता" | "Račun" | "Kont" | "Fiók" | "Akun" | "アカウント" | "ಖಾತೆ" | "계정" | "Paskyra" | "Konts" | "അക്കൗണ്ട്" | "खाते" | "Akaun" | "Conta" | "Cont" | "Счет" | "налог" | "Akaunti" | "கணக்கு" | "ఖాతా" | "บัญชี" | "Hesap" | "Обліковий запис" | "Tài khoản" | "账户" | "帳戶";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockAccounts.d.cts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;
|
|
1
|
+
{"version":3,"file":"mockAccounts.d.cts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAiB5D;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,mbAGzC,CAAC;AAEJ,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHlC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;CAyCtC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { EthAccountType } from "@metamask/keyring-api";
|
|
|
2
2
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
3
3
|
/**
|
|
4
4
|
* Get a random default account name from the list of localized default account names
|
|
5
|
+
*
|
|
5
6
|
* @returns A random default account name
|
|
6
7
|
*/
|
|
7
8
|
export declare const getMockRandomDefaultAccountName: () => "Account" | "መለያ" | "الحساب" | "Профил" | "অ্যাকাউন্ট" | "Compte" | "Účet" | "Konto" | "Λογαριασμός" | "Cuenta" | "حساب" | "Tili" | "એકાઉન્ટ" | "חשבון" | "अकाउंट" | "खाता" | "Račun" | "Kont" | "Fiók" | "Akun" | "アカウント" | "ಖಾತೆ" | "계정" | "Paskyra" | "Konts" | "അക്കൗണ്ട്" | "खाते" | "Akaun" | "Conta" | "Cont" | "Счет" | "налог" | "Akaunti" | "கணக்கு" | "ఖాతా" | "บัญชี" | "Hesap" | "Обліковий запис" | "Tài khoản" | "账户" | "帳戶";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockAccounts.d.mts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;
|
|
1
|
+
{"version":3,"file":"mockAccounts.d.mts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAiB5D;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,mbAGzC,CAAC;AAEJ,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHlC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;CAyCtC,CAAC"}
|
|
@@ -5,12 +5,14 @@ import { mapInternalAccountToUserStorageAccount } from "../utils.mjs";
|
|
|
5
5
|
/**
|
|
6
6
|
* Map an array of internal accounts to an array of user storage accounts
|
|
7
7
|
* Only used for testing purposes
|
|
8
|
+
*
|
|
8
9
|
* @param internalAccounts - An array of internal accounts
|
|
9
10
|
* @returns An array of user storage accounts
|
|
10
11
|
*/
|
|
11
12
|
const mapInternalAccountsListToUserStorageAccountsList = (internalAccounts) => internalAccounts.map(mapInternalAccountToUserStorageAccount);
|
|
12
13
|
/**
|
|
13
14
|
* Get a random default account name from the list of localized default account names
|
|
15
|
+
*
|
|
14
16
|
* @returns A random default account name
|
|
15
17
|
*/
|
|
16
18
|
export const getMockRandomDefaultAccountName = () => LOCALIZED_DEFAULT_ACCOUNT_NAMES[Math.floor(Math.random() * LOCALIZED_DEFAULT_ACCOUNT_NAMES.length)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockAccounts.mjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,+BAA+B,EAAE,yBAAqB;AAC/D,OAAO,EAAE,sCAAsC,EAAE,qBAAiB;AAElE
|
|
1
|
+
{"version":3,"file":"mockAccounts.mjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,+BAA+B,EAAE,yBAAqB;AAC/D,OAAO,EAAE,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,QAAQ,EAAE;gBACR,IAAI,EAAE,cAAc;gBACpB,iBAAiB,EAAE,CAAC;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,YAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,oBAAoB,EAAE,gDAAgD,CACpE,sBAAsB,CAAC,GAAwB,CAChD;IACD,GAAG,EAAE,gDAAgD,CACnD,sBAAsB,CAAC,GAAwB,CAChD;IACD,gCAAgC,EAC9B,gDAAgD,CAAC;QAC/C,GAAG,sBAAsB,CAAC,gBAAgB;QAC1C;YACE,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAC7C,OAAO,EAAE,UAAU;YACnB,QAAQ,EAAE;gBACR,IAAI,EAAE,GAAG,+BAA+B,EAAE,IAAI;gBAC9C,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;IACzB,gBAAgB,EAAE,gDAAgD,CAChE,sBAAsB,CAAC,gBAAqC,CAC7D;IACD,oCAAoC,EAClC,gDAAgD,CAAC;QAC/C;YACE,GAAG,sBAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,4DAA4D;aACnE;SACF;KACmB,CAAC;IACzB,iCAAiC,EAC/B,gDAAgD,CAAC;QAC/C;YACE,GAAG,sBAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,yDAAyD;gBAC/D,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;CAC1B,CAAC","sourcesContent":["import { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from '../constants';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\n\n/**\n * Map an array of internal accounts to an array of user storage accounts\n * Only used for testing purposes\n *\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"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createExpectedAccountSyncBatchDeleteBody = exports.createExpectedAccountSyncBatchUpsertBody = exports.mockUserStorageMessengerForAccountSyncing = void 0;
|
|
4
|
+
const mockAccounts_1 = require("./mockAccounts.cjs");
|
|
4
5
|
const encryption_1 = require("../../../../shared/encryption/index.cjs");
|
|
5
6
|
const mockMessenger_1 = require("../../__fixtures__/mockMessenger.cjs");
|
|
6
7
|
const utils_1 = require("../utils.cjs");
|
|
7
|
-
const mockAccounts_1 = require("./mockAccounts.cjs");
|
|
8
8
|
/**
|
|
9
9
|
* Test Utility - create a mock user storage messenger for account syncing tests
|
|
10
10
|
*
|
|
@@ -26,6 +26,7 @@ function mockUserStorageMessengerForAccountSyncing(options) {
|
|
|
26
26
|
exports.mockUserStorageMessengerForAccountSyncing = mockUserStorageMessengerForAccountSyncing;
|
|
27
27
|
/**
|
|
28
28
|
* Test Utility - creates a realistic expected batch upsert payload
|
|
29
|
+
*
|
|
29
30
|
* @param data - data supposed to be upserted
|
|
30
31
|
* @param storageKey - storage key
|
|
31
32
|
* @returns expected body
|
|
@@ -39,6 +40,7 @@ function createExpectedAccountSyncBatchUpsertBody(data, storageKey) {
|
|
|
39
40
|
exports.createExpectedAccountSyncBatchUpsertBody = createExpectedAccountSyncBatchUpsertBody;
|
|
40
41
|
/**
|
|
41
42
|
* Test Utility - creates a realistic expected batch delete payload
|
|
43
|
+
*
|
|
42
44
|
* @param data - data supposed to be deleted
|
|
43
45
|
* @param storageKey - storage key
|
|
44
46
|
* @returns expected body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;AAEA,wEAAiE;AACjE,wEAA4E;AAC5E,wCAAkE;
|
|
1
|
+
{"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;AAEA,qDAAwD;AACxD,wEAAiE;AACjE,wEAA4E;AAC5E,wCAAkE;AAElE;;;;;;;GAOG;AACH,SAAgB,yCAAyC,CAAC,OAIzD;IACC,MAAM,cAAc,GAAG,IAAA,wCAAwB,GAAE,CAAC;IAElD,cAAc,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE;QACpE,cAAc,CAAC,aAAa,CAAC,OAAO,CAClC,iCAAiC,EACjC,qCAAsB,CAAC,GAAG,CAAC,CAAC,CAAoB,CACjD,CAAC;QACF,OAAO,qCAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,wBAAwB,CAAC,eAAe,CACrD,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY;QAC9B,qCAAsB,CAAC,GAAG,CAAsB,CACnD,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC;AArBD,8FAqBC;AAED;;;;;;GAMG;AACH,SAAgB,wCAAwC,CACtD,IAAiC,EACjC,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;QAC1C,IAAA,6BAAgB,EAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,IAAA,8CAAsC,EAAC,UAAU,CAAC,CAAC;KACnE,CAAC,CAAC;AACL,CAAC;AARD,4FAQC;AAED;;;;;;GAMG;AACH,SAAgB,wCAAwC,CACtD,IAAc,EACd,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC3B,IAAA,6BAAgB,EAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,CAChD,CAAC;AACJ,CAAC;AAPD,4FAOC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { MOCK_INTERNAL_ACCOUNTS } from './mockAccounts';\nimport { createSHA256Hash } from '../../../../shared/encryption';\nimport { mockUserStorageMessenger } from '../../__fixtures__/mockMessenger';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\n\n/**\n * Test Utility - create a mock user storage messenger for account syncing tests\n *\n * @param options - options for the mock messenger\n * @param options.accounts - options for the accounts part of the controller\n * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action\n * @returns Mock User Storage Messenger\n */\nexport function mockUserStorageMessengerForAccountSyncing(options?: {\n accounts?: {\n accountsList?: InternalAccount[];\n };\n}) {\n const messengerMocks = mockUserStorageMessenger();\n\n messengerMocks.mockKeyringAddNewAccount.mockImplementation(async () => {\n messengerMocks.baseMessenger.publish(\n 'AccountsController:accountAdded',\n MOCK_INTERNAL_ACCOUNTS.ONE[0] as InternalAccount,\n );\n return MOCK_INTERNAL_ACCOUNTS.ONE[0].address;\n });\n\n messengerMocks.mockAccountsListAccounts.mockReturnValue(\n (options?.accounts?.accountsList ??\n MOCK_INTERNAL_ACCOUNTS.ALL) as InternalAccount[],\n );\n\n return messengerMocks;\n}\n\n/**\n * Test Utility - creates a realistic expected batch upsert payload\n *\n * @param data - data supposed to be upserted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchUpsertBody(\n data: [string, InternalAccount][],\n storageKey: string,\n) {\n return data.map(([entryKey, entryValue]) => [\n createSHA256Hash(String(entryKey) + storageKey),\n JSON.stringify(mapInternalAccountToUserStorageAccount(entryValue)),\n ]);\n}\n\n/**\n * Test Utility - creates a realistic expected batch delete payload\n *\n * @param data - data supposed to be deleted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchDeleteBody(\n data: string[],\n storageKey: string,\n) {\n return data.map((entryKey) =>\n createSHA256Hash(String(entryKey) + storageKey),\n );\n}\n"]}
|
|
@@ -13,8 +13,8 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
13
13
|
accountsList?: InternalAccount[];
|
|
14
14
|
};
|
|
15
15
|
}): {
|
|
16
|
-
baseMessenger: import("@metamask/base-controller").
|
|
17
|
-
messenger: import("@metamask/base-controller").
|
|
16
|
+
baseMessenger: import("@metamask/base-controller").Messenger<import("../../index.cjs").AllowedActions, import("../../index.cjs").AllowedEvents>;
|
|
17
|
+
messenger: import("@metamask/base-controller").RestrictedMessenger<"UserStorageController", import("@metamask/snaps-controllers").HandleSnapRequest | {
|
|
18
18
|
type: "AuthenticationController:isSignedIn";
|
|
19
19
|
handler: () => boolean;
|
|
20
20
|
} | {
|
|
@@ -32,7 +32,7 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
32
32
|
identifierId: string;
|
|
33
33
|
profileId: string;
|
|
34
34
|
}>;
|
|
35
|
-
} | import("@metamask/keyring-controller").KeyringControllerGetStateAction | import("
|
|
35
|
+
} | import("@metamask/keyring-controller").KeyringControllerGetStateAction | import("@metamask/accounts-controller").AccountsControllerListAccountsAction | import("@metamask/accounts-controller").AccountsControllerUpdateAccountMetadataAction | import("@metamask/keyring-controller").KeyringControllerAddNewAccountAction | import("@metamask/network-controller").NetworkControllerGetStateAction | import("@metamask/network-controller").NetworkControllerAddNetworkAction | import("@metamask/network-controller").NetworkControllerRemoveNetworkAction | import("@metamask/network-controller").NetworkControllerUpdateNetworkAction, import("@metamask/keyring-controller").KeyringControllerLockEvent | import("@metamask/keyring-controller").KeyringControllerUnlockEvent | import("../../index.cjs").UserStorageControllerStateChangeEvent | import("../../index.cjs").UserStorageControllerAccountSyncingInProgress | import("../../index.cjs").UserStorageControllerAccountSyncingComplete | import("@metamask/accounts-controller").AccountsControllerAccountAddedEvent | import("@metamask/accounts-controller").AccountsControllerAccountRenamedEvent | import("@metamask/network-controller").NetworkControllerNetworkRemovedEvent, "SnapController:handleRequest" | "KeyringController:getState" | "AuthenticationController:isSignedIn" | "AuthenticationController:performSignIn" | "AuthenticationController:performSignOut" | "AuthenticationController:getBearerToken" | "AuthenticationController:getSessionProfile" | "AccountsController:listAccounts" | "AccountsController:updateAccountMetadata" | "KeyringController:addNewAccount" | "NetworkController:getState" | "NetworkController:addNetwork" | "NetworkController:removeNetwork" | "NetworkController:updateNetwork", "KeyringController:lock" | "KeyringController:unlock" | "AccountsController:accountAdded" | "AccountsController:accountRenamed" | "NetworkController:networkRemoved">;
|
|
36
36
|
mockSnapGetPublicKey: jest.Mock<any, any>;
|
|
37
37
|
mockSnapSignMessage: jest.Mock<any, any>;
|
|
38
38
|
mockAuthGetBearerToken: jest.Mock<Promise<string>, []>;
|
|
@@ -42,8 +42,6 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
42
42
|
}>, []>;
|
|
43
43
|
mockAuthPerformSignIn: jest.Mock<Promise<string>, []>;
|
|
44
44
|
mockAuthIsSignedIn: jest.Mock<boolean, []>;
|
|
45
|
-
mockNotificationServicesIsEnabled: jest.Mock<boolean, []>;
|
|
46
|
-
mockNotificationServicesDisableNotifications: jest.Mock<Promise<void>, []>;
|
|
47
45
|
mockAuthPerformSignOut: jest.Mock<void, []>;
|
|
48
46
|
mockKeyringAddNewAccount: jest.Mock<Promise<string>, [accountCount?: number | undefined]>;
|
|
49
47
|
mockAccountsUpdateAccountMetadata: jest.Mock<void, [accountId: string, metadata: Partial<{
|
|
@@ -70,6 +68,7 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
70
68
|
};
|
|
71
69
|
/**
|
|
72
70
|
* Test Utility - creates a realistic expected batch upsert payload
|
|
71
|
+
*
|
|
73
72
|
* @param data - data supposed to be upserted
|
|
74
73
|
* @param storageKey - storage key
|
|
75
74
|
* @returns expected body
|
|
@@ -77,6 +76,7 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
77
76
|
export declare function createExpectedAccountSyncBatchUpsertBody(data: [string, InternalAccount][], storageKey: string): string[][];
|
|
78
77
|
/**
|
|
79
78
|
* Test Utility - creates a realistic expected batch delete payload
|
|
79
|
+
*
|
|
80
80
|
* @param data - data supposed to be deleted
|
|
81
81
|
* @param storageKey - storage key
|
|
82
82
|
* @returns expected body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.cts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE;;;;;;;GAOG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,CAAC,EAAE;IAClE,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CACH
|
|
1
|
+
{"version":3,"file":"test-utils.d.cts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE;;;;;;;GAOG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,CAAC,EAAE;IAClE,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA;AAED;;;;;;GAMG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EACjC,UAAU,EAAE,MAAM,cAMnB;AAED;;;;;;GAMG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,EAAE,MAAM,YAKnB"}
|
|
@@ -13,8 +13,8 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
13
13
|
accountsList?: InternalAccount[];
|
|
14
14
|
};
|
|
15
15
|
}): {
|
|
16
|
-
baseMessenger: import("@metamask/base-controller").
|
|
17
|
-
messenger: import("@metamask/base-controller").
|
|
16
|
+
baseMessenger: import("@metamask/base-controller").Messenger<import("../../index.mjs").AllowedActions, import("../../index.mjs").AllowedEvents>;
|
|
17
|
+
messenger: import("@metamask/base-controller").RestrictedMessenger<"UserStorageController", import("@metamask/snaps-controllers").HandleSnapRequest | {
|
|
18
18
|
type: "AuthenticationController:isSignedIn";
|
|
19
19
|
handler: () => boolean;
|
|
20
20
|
} | {
|
|
@@ -32,7 +32,7 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
32
32
|
identifierId: string;
|
|
33
33
|
profileId: string;
|
|
34
34
|
}>;
|
|
35
|
-
} | import("@metamask/keyring-controller").KeyringControllerGetStateAction | import("
|
|
35
|
+
} | import("@metamask/keyring-controller").KeyringControllerGetStateAction | import("@metamask/accounts-controller").AccountsControllerListAccountsAction | import("@metamask/accounts-controller").AccountsControllerUpdateAccountMetadataAction | import("@metamask/keyring-controller").KeyringControllerAddNewAccountAction | import("@metamask/network-controller").NetworkControllerGetStateAction | import("@metamask/network-controller").NetworkControllerAddNetworkAction | import("@metamask/network-controller").NetworkControllerRemoveNetworkAction | import("@metamask/network-controller").NetworkControllerUpdateNetworkAction, import("@metamask/keyring-controller").KeyringControllerLockEvent | import("@metamask/keyring-controller").KeyringControllerUnlockEvent | import("../../index.mjs").UserStorageControllerStateChangeEvent | import("../../index.mjs").UserStorageControllerAccountSyncingInProgress | import("../../index.mjs").UserStorageControllerAccountSyncingComplete | import("@metamask/accounts-controller").AccountsControllerAccountAddedEvent | import("@metamask/accounts-controller").AccountsControllerAccountRenamedEvent | import("@metamask/network-controller").NetworkControllerNetworkRemovedEvent, "SnapController:handleRequest" | "KeyringController:getState" | "AuthenticationController:isSignedIn" | "AuthenticationController:performSignIn" | "AuthenticationController:performSignOut" | "AuthenticationController:getBearerToken" | "AuthenticationController:getSessionProfile" | "AccountsController:listAccounts" | "AccountsController:updateAccountMetadata" | "KeyringController:addNewAccount" | "NetworkController:getState" | "NetworkController:addNetwork" | "NetworkController:removeNetwork" | "NetworkController:updateNetwork", "KeyringController:lock" | "KeyringController:unlock" | "AccountsController:accountAdded" | "AccountsController:accountRenamed" | "NetworkController:networkRemoved">;
|
|
36
36
|
mockSnapGetPublicKey: jest.Mock<any, any>;
|
|
37
37
|
mockSnapSignMessage: jest.Mock<any, any>;
|
|
38
38
|
mockAuthGetBearerToken: jest.Mock<Promise<string>, []>;
|
|
@@ -42,8 +42,6 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
42
42
|
}>, []>;
|
|
43
43
|
mockAuthPerformSignIn: jest.Mock<Promise<string>, []>;
|
|
44
44
|
mockAuthIsSignedIn: jest.Mock<boolean, []>;
|
|
45
|
-
mockNotificationServicesIsEnabled: jest.Mock<boolean, []>;
|
|
46
|
-
mockNotificationServicesDisableNotifications: jest.Mock<Promise<void>, []>;
|
|
47
45
|
mockAuthPerformSignOut: jest.Mock<void, []>;
|
|
48
46
|
mockKeyringAddNewAccount: jest.Mock<Promise<string>, [accountCount?: number | undefined]>;
|
|
49
47
|
mockAccountsUpdateAccountMetadata: jest.Mock<void, [accountId: string, metadata: Partial<{
|
|
@@ -70,6 +68,7 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
70
68
|
};
|
|
71
69
|
/**
|
|
72
70
|
* Test Utility - creates a realistic expected batch upsert payload
|
|
71
|
+
*
|
|
73
72
|
* @param data - data supposed to be upserted
|
|
74
73
|
* @param storageKey - storage key
|
|
75
74
|
* @returns expected body
|
|
@@ -77,6 +76,7 @@ export declare function mockUserStorageMessengerForAccountSyncing(options?: {
|
|
|
77
76
|
export declare function createExpectedAccountSyncBatchUpsertBody(data: [string, InternalAccount][], storageKey: string): string[][];
|
|
78
77
|
/**
|
|
79
78
|
* Test Utility - creates a realistic expected batch delete payload
|
|
79
|
+
*
|
|
80
80
|
* @param data - data supposed to be deleted
|
|
81
81
|
* @param storageKey - storage key
|
|
82
82
|
* @returns expected body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.mts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE;;;;;;;GAOG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,CAAC,EAAE;IAClE,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CACH
|
|
1
|
+
{"version":3,"file":"test-utils.d.mts","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE;;;;;;;GAOG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,CAAC,EAAE;IAClE,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA;AAED;;;;;;GAMG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,EACjC,UAAU,EAAE,MAAM,cAMnB;AAED;;;;;;GAMG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,EAAE,MAAM,YAKnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { MOCK_INTERNAL_ACCOUNTS } from "./mockAccounts.mjs";
|
|
1
2
|
import { createSHA256Hash } from "../../../../shared/encryption/index.mjs";
|
|
2
3
|
import { mockUserStorageMessenger } from "../../__fixtures__/mockMessenger.mjs";
|
|
3
4
|
import { mapInternalAccountToUserStorageAccount } from "../utils.mjs";
|
|
4
|
-
import { MOCK_INTERNAL_ACCOUNTS } from "./mockAccounts.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* Test Utility - create a mock user storage messenger for account syncing tests
|
|
7
7
|
*
|
|
@@ -22,6 +22,7 @@ export function mockUserStorageMessengerForAccountSyncing(options) {
|
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Test Utility - creates a realistic expected batch upsert payload
|
|
25
|
+
*
|
|
25
26
|
* @param data - data supposed to be upserted
|
|
26
27
|
* @param storageKey - storage key
|
|
27
28
|
* @returns expected body
|
|
@@ -34,6 +35,7 @@ export function createExpectedAccountSyncBatchUpsertBody(data, storageKey) {
|
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Test Utility - creates a realistic expected batch delete payload
|
|
38
|
+
*
|
|
37
39
|
* @param data - data supposed to be deleted
|
|
38
40
|
* @param storageKey - storage key
|
|
39
41
|
* @returns expected body
|