@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,276 +0,0 @@
|
|
|
1
|
-
function $importDefault(module) {
|
|
2
|
-
if (module?.__esModule) {
|
|
3
|
-
return module.default;
|
|
4
|
-
}
|
|
5
|
-
return module;
|
|
6
|
-
}
|
|
7
|
-
import $log from "loglevel";
|
|
8
|
-
const log = $importDefault($log);
|
|
9
|
-
import encryption, { createSHA256Hash } from "../../shared/encryption/index.mjs";
|
|
10
|
-
import { SHARED_SALT } from "../../shared/encryption/constants.mjs";
|
|
11
|
-
import { Env, getEnvUrls } from "../../shared/env.mjs";
|
|
12
|
-
import { createEntryPath } from "../../shared/storage-schema.mjs";
|
|
13
|
-
const ENV_URLS = getEnvUrls(Env.PRD);
|
|
14
|
-
export const USER_STORAGE_API = ENV_URLS.userStorageApiUrl;
|
|
15
|
-
export const USER_STORAGE_ENDPOINT = `${USER_STORAGE_API}/api/v1/userstorage`;
|
|
16
|
-
/**
|
|
17
|
-
* User Storage Service - Get Storage Entry.
|
|
18
|
-
*
|
|
19
|
-
* @param opts - User Storage Options
|
|
20
|
-
* @returns The storage entry, or null if fails to find entry
|
|
21
|
-
*/
|
|
22
|
-
export async function getUserStorage(opts) {
|
|
23
|
-
try {
|
|
24
|
-
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
25
|
-
const encryptedPath = createEntryPath(path, storageKey);
|
|
26
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);
|
|
27
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
28
|
-
headers: {
|
|
29
|
-
'Content-Type': 'application/json',
|
|
30
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
// Acceptable error - since indicates entry does not exist.
|
|
34
|
-
if (userStorageResponse.status === 404) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
if (userStorageResponse.status !== 200) {
|
|
38
|
-
throw new Error(`Unable to get User Storage - HTTP ${userStorageResponse.status}`);
|
|
39
|
-
}
|
|
40
|
-
const userStorage = await userStorageResponse.json();
|
|
41
|
-
const encryptedData = userStorage?.Data ?? null;
|
|
42
|
-
/* istanbul ignore if - this is an edge case where our endpoint returns invalid JSON payload */
|
|
43
|
-
if (!encryptedData) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const decryptedData = await encryption.decryptString(encryptedData, opts.storageKey, nativeScryptCrypto);
|
|
47
|
-
// Re-encrypt and re-upload the entry if the salt is random
|
|
48
|
-
const salt = encryption.getSalt(encryptedData);
|
|
49
|
-
if (salt.toString() !== SHARED_SALT.toString()) {
|
|
50
|
-
await upsertUserStorage(decryptedData, opts);
|
|
51
|
-
}
|
|
52
|
-
return decryptedData;
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
log.error('Failed to get user storage', e);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* User Storage Service - Get all storage entries for a specific feature.
|
|
61
|
-
*
|
|
62
|
-
* @param opts - User Storage Options
|
|
63
|
-
* @returns The storage entry, or null if fails to find entry
|
|
64
|
-
*/
|
|
65
|
-
export async function getUserStorageAllFeatureEntries(opts) {
|
|
66
|
-
try {
|
|
67
|
-
const { bearerToken, path, nativeScryptCrypto } = opts;
|
|
68
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);
|
|
69
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
70
|
-
headers: {
|
|
71
|
-
'Content-Type': 'application/json',
|
|
72
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
// Acceptable error - since indicates feature does not exist.
|
|
76
|
-
if (userStorageResponse.status === 404) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
if (userStorageResponse.status !== 200) {
|
|
80
|
-
throw new Error(`Unable to get User Storage - HTTP ${userStorageResponse.status}`);
|
|
81
|
-
}
|
|
82
|
-
const userStorage = await userStorageResponse.json();
|
|
83
|
-
if (!Array.isArray(userStorage)) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
const decryptedData = [];
|
|
87
|
-
const reEncryptedEntries = [];
|
|
88
|
-
for (const entry of userStorage) {
|
|
89
|
-
/* istanbul ignore if - unreachable if statement, but kept as edge case */
|
|
90
|
-
if (!entry.Data) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const data = await encryption.decryptString(entry.Data, opts.storageKey, nativeScryptCrypto);
|
|
95
|
-
decryptedData.push(data);
|
|
96
|
-
// Re-encrypt the entry if the salt is different from the shared one
|
|
97
|
-
const salt = encryption.getSalt(entry.Data);
|
|
98
|
-
if (salt.toString() !== SHARED_SALT.toString()) {
|
|
99
|
-
reEncryptedEntries.push([
|
|
100
|
-
entry.HashedKey,
|
|
101
|
-
await encryption.encryptString(data, opts.storageKey, nativeScryptCrypto),
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// do nothing
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Re-upload the re-encrypted entries
|
|
110
|
-
if (reEncryptedEntries.length) {
|
|
111
|
-
await batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(reEncryptedEntries, opts);
|
|
112
|
-
}
|
|
113
|
-
return decryptedData;
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
log.error('Failed to get user storage', e);
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* User Storage Service - Set Storage Entry.
|
|
122
|
-
*
|
|
123
|
-
* @param data - data to store
|
|
124
|
-
* @param opts - storage options
|
|
125
|
-
*/
|
|
126
|
-
export async function upsertUserStorage(data, opts) {
|
|
127
|
-
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
128
|
-
const encryptedData = await encryption.encryptString(data, opts.storageKey, nativeScryptCrypto);
|
|
129
|
-
const encryptedPath = createEntryPath(path, storageKey);
|
|
130
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);
|
|
131
|
-
const res = await fetch(url.toString(), {
|
|
132
|
-
method: 'PUT',
|
|
133
|
-
headers: {
|
|
134
|
-
'Content-Type': 'application/json',
|
|
135
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
136
|
-
},
|
|
137
|
-
body: JSON.stringify({ data: encryptedData }),
|
|
138
|
-
});
|
|
139
|
-
if (!res.ok) {
|
|
140
|
-
throw new Error(`user-storage - unable to upsert data - HTTP ${res.status}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
145
|
-
* You cannot use this method to set multiple features at once.
|
|
146
|
-
*
|
|
147
|
-
* @param data - data to store, in the form of an array of [entryKey, entryValue] pairs
|
|
148
|
-
* @param opts - storage options
|
|
149
|
-
*/
|
|
150
|
-
export async function batchUpsertUserStorage(data, opts) {
|
|
151
|
-
if (!data.length) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
155
|
-
const encryptedData = [];
|
|
156
|
-
for (const d of data) {
|
|
157
|
-
encryptedData.push([
|
|
158
|
-
createSHA256Hash(d[0] + storageKey),
|
|
159
|
-
await encryption.encryptString(d[1], opts.storageKey, nativeScryptCrypto),
|
|
160
|
-
]);
|
|
161
|
-
}
|
|
162
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);
|
|
163
|
-
const formattedData = Object.fromEntries(encryptedData);
|
|
164
|
-
const res = await fetch(url.toString(), {
|
|
165
|
-
method: 'PUT',
|
|
166
|
-
headers: {
|
|
167
|
-
'Content-Type': 'application/json',
|
|
168
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
169
|
-
},
|
|
170
|
-
body: JSON.stringify({ data: formattedData }),
|
|
171
|
-
});
|
|
172
|
-
if (!res.ok) {
|
|
173
|
-
throw new Error(`user-storage - unable to batch upsert data - HTTP ${res.status}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
178
|
-
* You cannot use this method to set multiple features at once.
|
|
179
|
-
*
|
|
180
|
-
* @param encryptedData - data to store, in the form of an array of [hashedKey, encryptedData] pairs
|
|
181
|
-
* @param opts - storage options
|
|
182
|
-
*/
|
|
183
|
-
export async function batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(encryptedData, opts) {
|
|
184
|
-
if (!encryptedData.length) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const { bearerToken, path } = opts;
|
|
188
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);
|
|
189
|
-
const formattedData = Object.fromEntries(encryptedData);
|
|
190
|
-
const res = await fetch(url.toString(), {
|
|
191
|
-
method: 'PUT',
|
|
192
|
-
headers: {
|
|
193
|
-
'Content-Type': 'application/json',
|
|
194
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
195
|
-
},
|
|
196
|
-
body: JSON.stringify({ data: formattedData }),
|
|
197
|
-
});
|
|
198
|
-
if (!res.ok) {
|
|
199
|
-
throw new Error(`user-storage - unable to batch upsert data - HTTP ${res.status}`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* User Storage Service - Delete Storage Entry.
|
|
204
|
-
*
|
|
205
|
-
* @param opts - User Storage Options
|
|
206
|
-
*/
|
|
207
|
-
export async function deleteUserStorage(opts) {
|
|
208
|
-
const { bearerToken, path, storageKey } = opts;
|
|
209
|
-
const encryptedPath = createEntryPath(path, storageKey);
|
|
210
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);
|
|
211
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
212
|
-
method: 'DELETE',
|
|
213
|
-
headers: {
|
|
214
|
-
'Content-Type': 'application/json',
|
|
215
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
if (userStorageResponse.status === 404) {
|
|
219
|
-
throw new Error(`user-storage - feature/entry not found - HTTP ${userStorageResponse.status}`);
|
|
220
|
-
}
|
|
221
|
-
if (!userStorageResponse.ok) {
|
|
222
|
-
throw new Error(`user-storage - unable to delete data - HTTP ${userStorageResponse.status}`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* User Storage Service - Delete multiple storage entries for one specific feature.
|
|
227
|
-
* You cannot use this method to delete multiple features at once.
|
|
228
|
-
*
|
|
229
|
-
* @param data - data to delete, in the form of an array entryKey[]
|
|
230
|
-
* @param opts - storage options
|
|
231
|
-
*/
|
|
232
|
-
export async function batchDeleteUserStorage(data, opts) {
|
|
233
|
-
if (!data.length) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const { bearerToken, path, storageKey } = opts;
|
|
237
|
-
const encryptedData = [];
|
|
238
|
-
for (const d of data) {
|
|
239
|
-
encryptedData.push(createSHA256Hash(d + storageKey));
|
|
240
|
-
}
|
|
241
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);
|
|
242
|
-
const res = await fetch(url.toString(), {
|
|
243
|
-
method: 'PUT',
|
|
244
|
-
headers: {
|
|
245
|
-
'Content-Type': 'application/json',
|
|
246
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
247
|
-
},
|
|
248
|
-
body: JSON.stringify({ batch_delete: encryptedData }),
|
|
249
|
-
});
|
|
250
|
-
if (!res.ok) {
|
|
251
|
-
throw new Error(`user-storage - unable to batch delete data - HTTP ${res.status}`);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* User Storage Service - Delete all storage entries for a specific feature.
|
|
256
|
-
*
|
|
257
|
-
* @param opts - User Storage Options
|
|
258
|
-
*/
|
|
259
|
-
export async function deleteUserStorageAllFeatureEntries(opts) {
|
|
260
|
-
const { bearerToken, path } = opts;
|
|
261
|
-
const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);
|
|
262
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
263
|
-
method: 'DELETE',
|
|
264
|
-
headers: {
|
|
265
|
-
'Content-Type': 'application/json',
|
|
266
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
if (userStorageResponse.status === 404) {
|
|
270
|
-
throw new Error(`user-storage - feature not found - HTTP ${userStorageResponse.status}`);
|
|
271
|
-
}
|
|
272
|
-
if (!userStorageResponse.ok) {
|
|
273
|
-
throw new Error(`user-storage - unable to delete data - HTTP ${userStorageResponse.status}`);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
//# sourceMappingURL=services.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,IAAG,iBAAiB;;AAE3B,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,0CAAgC;AACvE,OAAO,EAAE,WAAW,EAAE,8CAA0C;AAChE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,6BAAyB;AAKnD,OAAO,EAAE,eAAe,EAAE,wCAAoC;AAG9D,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,GA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K;QACb,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;QAED,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;KACtD,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,IAAI,KAAK,CACb,qDAAqD,GAAG,CAAC,MAAM,EAAE,CAClE,CAAC;KACH;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,IAAyC;IAEzC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,qBAAqB,IAAI,IAAI,EAAE,CAAC,CAAC;IAExD,MAAM,mBAAmB,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;QACtD,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAC;IAEH,IAAI,mBAAmB,CAAC,MAAM,KAAK,GAAG,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,2CAA2C,mBAAmB,CAAC,MAAM,EAAE,CACxE,CAAC;KACH;IAED,IAAI,CAAC,mBAAmB,CAAC,EAAE,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,+CAA+C,mBAAmB,CAAC,MAAM,EAAE,CAC5E,CAAC;KACH;AACH,CAAC","sourcesContent":["import log from 'loglevel';\n\nimport encryption, { createSHA256Hash } from '../../shared/encryption';\nimport { SHARED_SALT } from '../../shared/encryption/constants';\nimport { Env, getEnvUrls } from '../../shared/env';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../shared/storage-schema';\nimport { createEntryPath } from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nexport const USER_STORAGE_API: string = ENV_URLS.userStorageApiUrl;\nexport const USER_STORAGE_ENDPOINT = `${USER_STORAGE_API}/api/v1/userstorage`;\n\n/**\n * This is the Server Response shape for a feature entry.\n */\nexport type GetUserStorageResponse = {\n HashedKey: string;\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n Data: string;\n}[];\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStoragePathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStoragePathWithFeatureOnly;\n};\n\nexport type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;\n\n/**\n * User Storage Service - Get Storage Entry.\n *\n * @param opts - User Storage Options\n * @returns The storage entry, or null if fails to find entry\n */\nexport async function getUserStorage(\n opts: UserStorageOptions,\n): Promise<string | null> {\n try {\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n // Acceptable error - since indicates entry does not exist.\n if (userStorageResponse.status === 404) {\n return null;\n }\n\n if (userStorageResponse.status !== 200) {\n throw new Error(\n `Unable to get User Storage - HTTP ${userStorageResponse.status}`,\n );\n }\n\n const userStorage: GetUserStorageResponse | null =\n await userStorageResponse.json();\n const encryptedData = userStorage?.Data ?? null;\n\n /* istanbul ignore if - this is an edge case where our endpoint returns invalid JSON payload */\n if (!encryptedData) {\n return null;\n }\n\n const decryptedData = await encryption.decryptString(\n encryptedData,\n opts.storageKey,\n nativeScryptCrypto,\n );\n\n // Re-encrypt and re-upload the entry if the salt is random\n const salt = encryption.getSalt(encryptedData);\n if (salt.toString() !== SHARED_SALT.toString()) {\n await upsertUserStorage(decryptedData, opts);\n }\n\n return decryptedData;\n } catch (e) {\n log.error('Failed to get user storage', e);\n return null;\n }\n}\n\n/**\n * User Storage Service - Get all storage entries for a specific feature.\n *\n * @param opts - User Storage Options\n * @returns The storage entry, or null if fails to find entry\n */\nexport async function getUserStorageAllFeatureEntries(\n opts: UserStorageAllFeatureEntriesOptions,\n): Promise<string[] | null> {\n try {\n const { bearerToken, path, nativeScryptCrypto } = opts;\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n // Acceptable error - since indicates feature does not exist.\n if (userStorageResponse.status === 404) {\n return null;\n }\n\n if (userStorageResponse.status !== 200) {\n throw new Error(\n `Unable to get User Storage - HTTP ${userStorageResponse.status}`,\n );\n }\n\n const userStorage: GetUserStorageAllFeatureEntriesResponse | null =\n await userStorageResponse.json();\n\n if (!Array.isArray(userStorage)) {\n return null;\n }\n\n const decryptedData: string[] = [];\n const reEncryptedEntries: [string, string][] = [];\n\n for (const entry of userStorage) {\n /* istanbul ignore if - unreachable if statement, but kept as edge case */\n if (!entry.Data) {\n continue;\n }\n\n try {\n const data = await encryption.decryptString(\n entry.Data,\n opts.storageKey,\n nativeScryptCrypto,\n );\n decryptedData.push(data);\n\n // Re-encrypt the entry if the salt is different from the shared one\n const salt = encryption.getSalt(entry.Data);\n if (salt.toString() !== SHARED_SALT.toString()) {\n reEncryptedEntries.push([\n entry.HashedKey,\n await encryption.encryptString(\n data,\n opts.storageKey,\n nativeScryptCrypto,\n ),\n ]);\n }\n } catch {\n // do nothing\n }\n }\n\n // Re-upload the re-encrypted entries\n if (reEncryptedEntries.length) {\n await batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n reEncryptedEntries,\n opts,\n );\n }\n\n return decryptedData;\n } catch (e) {\n log.error('Failed to get user storage', e);\n return null;\n }\n}\n\n/**\n * User Storage Service - Set Storage Entry.\n *\n * @param data - data to store\n * @param opts - storage options\n */\nexport async function upsertUserStorage(\n data: string,\n opts: UserStorageOptions,\n): Promise<void> {\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedData = await encryption.encryptString(\n data,\n opts.storageKey,\n nativeScryptCrypto,\n );\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: encryptedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to upsert data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Set multiple storage entries for one specific feature.\n * You cannot use this method to set multiple features at once.\n *\n * @param data - data to store, in the form of an array of [entryKey, entryValue] pairs\n * @param opts - storage options\n */\nexport async function batchUpsertUserStorage(\n data: [string, string][],\n opts: UserStorageBatchUpsertOptions,\n): Promise<void> {\n if (!data.length) {\n return;\n }\n\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedData: string[][] = [];\n\n for (const d of data) {\n encryptedData.push([\n createSHA256Hash(d[0] + storageKey),\n await encryption.encryptString(d[1], opts.storageKey, nativeScryptCrypto),\n ]);\n }\n\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const formattedData = Object.fromEntries(encryptedData);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: formattedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to batch upsert data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Set multiple storage entries for one specific feature.\n * You cannot use this method to set multiple features at once.\n *\n * @param encryptedData - data to store, in the form of an array of [hashedKey, encryptedData] pairs\n * @param opts - storage options\n */\nexport async function batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n encryptedData: [string, string][],\n opts: UserStorageBatchUpsertOptions,\n): Promise<void> {\n if (!encryptedData.length) {\n return;\n }\n\n const { bearerToken, path } = opts;\n\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const formattedData = Object.fromEntries(encryptedData);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: formattedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to batch upsert data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Delete Storage Entry.\n *\n * @param opts - User Storage Options\n */\nexport async function deleteUserStorage(\n opts: UserStorageOptions,\n): Promise<void> {\n const { bearerToken, path, storageKey } = opts;\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n if (userStorageResponse.status === 404) {\n throw new Error(\n `user-storage - feature/entry not found - HTTP ${userStorageResponse.status}`,\n );\n }\n\n if (!userStorageResponse.ok) {\n throw new Error(\n `user-storage - unable to delete data - HTTP ${userStorageResponse.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Delete multiple storage entries for one specific feature.\n * You cannot use this method to delete multiple features at once.\n *\n * @param data - data to delete, in the form of an array entryKey[]\n * @param opts - storage options\n */\nexport async function batchDeleteUserStorage(\n data: string[],\n opts: UserStorageBatchUpsertOptions,\n): Promise<void> {\n if (!data.length) {\n return;\n }\n\n const { bearerToken, path, storageKey } = opts;\n\n const encryptedData: string[] = [];\n\n for (const d of data) {\n encryptedData.push(createSHA256Hash(d + storageKey));\n }\n\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n\n body: JSON.stringify({ batch_delete: encryptedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to batch delete data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Delete all storage entries for a specific feature.\n *\n * @param opts - User Storage Options\n */\nexport async function deleteUserStorageAllFeatureEntries(\n opts: UserStorageAllFeatureEntriesOptions,\n): Promise<void> {\n const { bearerToken, path } = opts;\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n if (userStorageResponse.status === 404) {\n throw new Error(\n `user-storage - feature not found - HTTP ${userStorageResponse.status}`,\n );\n }\n\n if (!userStorageResponse.ok) {\n throw new Error(\n `user-storage - unable to delete data - HTTP ${userStorageResponse.status}`,\n );\n }\n}\n"]}
|
|
@@ -1,124 +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.arrangeAuthAPIs = exports.handleMockOAuth2Token = exports.handleMockSrpLogin = exports.handleMockPairIdentifiers = exports.handleMockSiweLogin = exports.handleMockNonce = exports.MOCK_OIDC_TOKEN_RESPONSE = exports.MOCK_SRP_LOGIN_RESPONSE = exports.MOCK_ACCESS_JWT = exports.MOCK_JWT = void 0;
|
|
7
|
-
const nock_1 = __importDefault(require("nock"));
|
|
8
|
-
const env_1 = require("../../shared/env.cjs");
|
|
9
|
-
const services_1 = require("../authentication-jwt-bearer/services.cjs");
|
|
10
|
-
const MOCK_NONCE_URL = (0, services_1.NONCE_URL)(env_1.Env.DEV);
|
|
11
|
-
const MOCK_SIWE_LOGIN_URL = (0, services_1.SIWE_LOGIN_URL)(env_1.Env.DEV);
|
|
12
|
-
const MOCK_PAIR_IDENTIFIERS_URL = (0, services_1.PAIR_IDENTIFIERS)(env_1.Env.DEV);
|
|
13
|
-
const MOCK_SRP_LOGIN_URL = (0, services_1.SRP_LOGIN_URL)(env_1.Env.DEV);
|
|
14
|
-
const MOCK_OIDC_TOKEN_URL = (0, services_1.OIDC_TOKEN_URL)(env_1.Env.DEV);
|
|
15
|
-
exports.MOCK_JWT = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';
|
|
16
|
-
exports.MOCK_ACCESS_JWT = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
17
|
-
const MOCK_NONCE_RESPONSE = {
|
|
18
|
-
nonce: 'xGMm9SoihEKeAEfV',
|
|
19
|
-
identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',
|
|
20
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
21
|
-
expires_in: 300,
|
|
22
|
-
};
|
|
23
|
-
const MOCK_SIWE_LOGIN_RESPONSE = {
|
|
24
|
-
token: exports.MOCK_JWT,
|
|
25
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
26
|
-
expires_in: 3600,
|
|
27
|
-
profile: {
|
|
28
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
29
|
-
profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',
|
|
30
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
31
|
-
metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',
|
|
32
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
33
|
-
identifier_id: 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',
|
|
34
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
35
|
-
identifier_type: 'SIWE',
|
|
36
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
37
|
-
encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
exports.MOCK_SRP_LOGIN_RESPONSE = {
|
|
41
|
-
token: exports.MOCK_JWT,
|
|
42
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
43
|
-
expires_in: 3600,
|
|
44
|
-
profile: {
|
|
45
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
46
|
-
profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',
|
|
47
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
48
|
-
metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',
|
|
49
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
50
|
-
identifier_id: 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',
|
|
51
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
52
|
-
identifier_type: 'SRP',
|
|
53
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
54
|
-
encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
exports.MOCK_OIDC_TOKEN_RESPONSE = {
|
|
58
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
59
|
-
access_token: exports.MOCK_ACCESS_JWT,
|
|
60
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
61
|
-
expires_in: 3600,
|
|
62
|
-
};
|
|
63
|
-
const handleMockNonce = (mockReply) => {
|
|
64
|
-
const reply = mockReply ?? { status: 200, body: MOCK_NONCE_RESPONSE };
|
|
65
|
-
const mockNonceEndpoint = (0, nock_1.default)(MOCK_NONCE_URL)
|
|
66
|
-
.persist()
|
|
67
|
-
.get('')
|
|
68
|
-
.query(true)
|
|
69
|
-
.reply(reply.status, reply.body);
|
|
70
|
-
return mockNonceEndpoint;
|
|
71
|
-
};
|
|
72
|
-
exports.handleMockNonce = handleMockNonce;
|
|
73
|
-
const handleMockSiweLogin = (mockReply) => {
|
|
74
|
-
const reply = mockReply ?? { status: 200, body: MOCK_SIWE_LOGIN_RESPONSE };
|
|
75
|
-
const mockLoginEndpoint = (0, nock_1.default)(MOCK_SIWE_LOGIN_URL)
|
|
76
|
-
.persist()
|
|
77
|
-
.post('')
|
|
78
|
-
.reply(reply.status, reply.body);
|
|
79
|
-
return mockLoginEndpoint;
|
|
80
|
-
};
|
|
81
|
-
exports.handleMockSiweLogin = handleMockSiweLogin;
|
|
82
|
-
const handleMockPairIdentifiers = (mockReply) => {
|
|
83
|
-
const reply = mockReply ?? { status: 204 };
|
|
84
|
-
const mockPairIdentifiersEndpoint = (0, nock_1.default)(MOCK_PAIR_IDENTIFIERS_URL)
|
|
85
|
-
.persist()
|
|
86
|
-
.post('')
|
|
87
|
-
.reply(reply.status, reply.body);
|
|
88
|
-
return mockPairIdentifiersEndpoint;
|
|
89
|
-
};
|
|
90
|
-
exports.handleMockPairIdentifiers = handleMockPairIdentifiers;
|
|
91
|
-
const handleMockSrpLogin = (mockReply) => {
|
|
92
|
-
const reply = mockReply ?? { status: 200, body: exports.MOCK_SRP_LOGIN_RESPONSE };
|
|
93
|
-
const mockLoginEndpoint = (0, nock_1.default)(MOCK_SRP_LOGIN_URL)
|
|
94
|
-
.persist()
|
|
95
|
-
.post('')
|
|
96
|
-
.reply(reply.status, reply.body);
|
|
97
|
-
return mockLoginEndpoint;
|
|
98
|
-
};
|
|
99
|
-
exports.handleMockSrpLogin = handleMockSrpLogin;
|
|
100
|
-
const handleMockOAuth2Token = (mockReply) => {
|
|
101
|
-
const reply = mockReply ?? { status: 200, body: exports.MOCK_OIDC_TOKEN_RESPONSE };
|
|
102
|
-
const mockTokenEndpoint = (0, nock_1.default)(MOCK_OIDC_TOKEN_URL)
|
|
103
|
-
.persist()
|
|
104
|
-
.post('')
|
|
105
|
-
.reply(reply.status, reply.body);
|
|
106
|
-
return mockTokenEndpoint;
|
|
107
|
-
};
|
|
108
|
-
exports.handleMockOAuth2Token = handleMockOAuth2Token;
|
|
109
|
-
const arrangeAuthAPIs = (options) => {
|
|
110
|
-
const mockNonceUrl = (0, exports.handleMockNonce)(options?.mockNonceUrl);
|
|
111
|
-
const mockOAuth2TokenUrl = (0, exports.handleMockOAuth2Token)(options?.mockOAuth2TokenUrl);
|
|
112
|
-
const mockSrpLoginUrl = (0, exports.handleMockSrpLogin)(options?.mockSrpLoginUrl);
|
|
113
|
-
const mockSiweLoginUrl = (0, exports.handleMockSiweLogin)(options?.mockSiweLoginUrl);
|
|
114
|
-
const mockPairIdentifiersUrl = (0, exports.handleMockPairIdentifiers)(options?.mockPairIdentifiers);
|
|
115
|
-
return {
|
|
116
|
-
mockNonceUrl,
|
|
117
|
-
mockOAuth2TokenUrl,
|
|
118
|
-
mockSrpLoginUrl,
|
|
119
|
-
mockSiweLoginUrl,
|
|
120
|
-
mockPairIdentifiersUrl,
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
exports.arrangeAuthAPIs = arrangeAuthAPIs;
|
|
124
|
-
//# sourceMappingURL=mock-auth.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-auth.cjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-auth.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,8CAAuC;AACvC,wEAM+C;AAO/C,MAAM,cAAc,GAAG,IAAA,oBAAS,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,IAAA,yBAAc,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AACpD,MAAM,yBAAyB,GAAG,IAAA,2BAAgB,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAC5D,MAAM,kBAAkB,GAAG,IAAA,wBAAa,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,mBAAmB,GAAG,IAAA,yBAAc,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAEvC,QAAA,QAAQ,GACnB,opBAAopB,CAAC;AAE1oB,QAAA,eAAe,GAC1B,6JAA6J,CAAC;AAEhK,MAAM,mBAA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B,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,kBAAkB,sBAQ7B;AAEK,MAAM,qBAAqB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAC7D,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,gCAAwB,EAAE,CAAC;IAC3E,MAAM,iBAAiB,GAAG,IAAA,cAAI,EAAC,mBAAmB,CAAC;SAChD,OAAO,EAAE;SACT,IAAI,CAAC,EAAE,CAAC;SACR,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC;AAEK,MAAM,eAAe,GAAG,CAAC,OAM/B,EAAE,EAAE;IACH,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GAAG,IAAA,6BAAqB,EAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACrE,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACxE,MAAM,sBAAsB,GAAG,IAAA,iCAAyB,EACtD,OAAO,EAAE,mBAAmB,CAC7B,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,sBAAsB;KACvB,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,eAAe,mBAsB1B","sourcesContent":["import nock from 'nock';\n\nimport { Env } from '../../shared/env';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n} from '../authentication-jwt-bearer/services';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nconst MOCK_NONCE_URL = NONCE_URL(Env.DEV);\nconst MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.DEV);\nconst MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.DEV);\nconst MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.DEV);\nconst MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.DEV);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nconst MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 300,\n};\n\nconst MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 3600,\n profile: {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_type: 'SIWE',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 3600,\n profile: {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_type: 'SRP',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n access_token: MOCK_ACCESS_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 3600,\n};\n\nexport const handleMockNonce = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_NONCE_RESPONSE };\n\n const mockNonceEndpoint = nock(MOCK_NONCE_URL)\n .persist()\n .get('')\n .query(true)\n .reply(reply.status, reply.body);\n\n return mockNonceEndpoint;\n};\n\nexport const handleMockSiweLogin = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_SIWE_LOGIN_RESPONSE };\n const mockLoginEndpoint = nock(MOCK_SIWE_LOGIN_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockLoginEndpoint;\n};\n\nexport const handleMockPairIdentifiers = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockPairIdentifiersEndpoint = nock(MOCK_PAIR_IDENTIFIERS_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockPairIdentifiersEndpoint;\n};\n\nexport const handleMockSrpLogin = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_SRP_LOGIN_RESPONSE };\n const mockLoginEndpoint = nock(MOCK_SRP_LOGIN_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockLoginEndpoint;\n};\n\nexport const handleMockOAuth2Token = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_OIDC_TOKEN_RESPONSE };\n const mockTokenEndpoint = nock(MOCK_OIDC_TOKEN_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockTokenEndpoint;\n};\n\nexport const arrangeAuthAPIs = (options?: {\n mockNonceUrl?: MockReply;\n mockOAuth2TokenUrl?: MockReply;\n mockSrpLoginUrl?: MockReply;\n mockSiweLoginUrl?: MockReply;\n mockPairIdentifiers?: MockReply;\n}) => {\n const mockNonceUrl = handleMockNonce(options?.mockNonceUrl);\n const mockOAuth2TokenUrl = handleMockOAuth2Token(options?.mockOAuth2TokenUrl);\n const mockSrpLoginUrl = handleMockSrpLogin(options?.mockSrpLoginUrl);\n const mockSiweLoginUrl = handleMockSiweLogin(options?.mockSiweLoginUrl);\n const mockPairIdentifiersUrl = handleMockPairIdentifiers(\n options?.mockPairIdentifiers,\n );\n\n return {\n mockNonceUrl,\n mockOAuth2TokenUrl,\n mockSrpLoginUrl,\n mockSiweLoginUrl,\n mockPairIdentifiersUrl,\n };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-auth.d.cts","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-auth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAWxB,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAQF,eAAO,MAAM,QAAQ,upBACioB,CAAC;AAEvpB,eAAO,MAAM,eAAe,gKACmI,CAAC;AAmChK,eAAO,MAAM,uBAAuB;;;;;;;;;;CAuBnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAOpC,CAAC;AAEF,eAAO,MAAM,eAAe,eAAgB,SAAS,eAUpD,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAAgB,SAAS,eAQxD,CAAC;AAEF,eAAO,MAAM,yBAAyB,eAAgB,SAAS,eAQ9D,CAAC;AAEF,eAAO,MAAM,kBAAkB,eAAgB,SAAS,eAQvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAgB,SAAS,eAQ1D,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc;IACxC,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;;;;;;CAgBA,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-auth.d.mts","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-auth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAWxB,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAQF,eAAO,MAAM,QAAQ,upBACioB,CAAC;AAEvpB,eAAO,MAAM,eAAe,gKACmI,CAAC;AAmChK,eAAO,MAAM,uBAAuB;;;;;;;;;;CAuBnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAOpC,CAAC;AAEF,eAAO,MAAM,eAAe,eAAgB,SAAS,eAUpD,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAAgB,SAAS,eAQxD,CAAC;AAEF,eAAO,MAAM,yBAAyB,eAAgB,SAAS,eAQ9D,CAAC;AAEF,eAAO,MAAM,kBAAkB,eAAgB,SAAS,eAQvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAgB,SAAS,eAQ1D,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc;IACxC,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;;;;;;CAgBA,CAAC"}
|
|
@@ -1,119 +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 { Env } from "../../shared/env.mjs";
|
|
10
|
-
import { NONCE_URL, SIWE_LOGIN_URL, SRP_LOGIN_URL, OIDC_TOKEN_URL, PAIR_IDENTIFIERS } from "../authentication-jwt-bearer/services.mjs";
|
|
11
|
-
const MOCK_NONCE_URL = NONCE_URL(Env.DEV);
|
|
12
|
-
const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.DEV);
|
|
13
|
-
const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.DEV);
|
|
14
|
-
const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.DEV);
|
|
15
|
-
const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.DEV);
|
|
16
|
-
export const MOCK_JWT = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';
|
|
17
|
-
export const MOCK_ACCESS_JWT = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
18
|
-
const MOCK_NONCE_RESPONSE = {
|
|
19
|
-
nonce: 'xGMm9SoihEKeAEfV',
|
|
20
|
-
identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',
|
|
21
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
22
|
-
expires_in: 300,
|
|
23
|
-
};
|
|
24
|
-
const MOCK_SIWE_LOGIN_RESPONSE = {
|
|
25
|
-
token: MOCK_JWT,
|
|
26
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
27
|
-
expires_in: 3600,
|
|
28
|
-
profile: {
|
|
29
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
30
|
-
profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',
|
|
31
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
32
|
-
metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',
|
|
33
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
34
|
-
identifier_id: 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',
|
|
35
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
36
|
-
identifier_type: 'SIWE',
|
|
37
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
38
|
-
encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
export const MOCK_SRP_LOGIN_RESPONSE = {
|
|
42
|
-
token: MOCK_JWT,
|
|
43
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
44
|
-
expires_in: 3600,
|
|
45
|
-
profile: {
|
|
46
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
47
|
-
profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',
|
|
48
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
49
|
-
metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',
|
|
50
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
51
|
-
identifier_id: 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',
|
|
52
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
53
|
-
identifier_type: 'SRP',
|
|
54
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
55
|
-
encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
export const MOCK_OIDC_TOKEN_RESPONSE = {
|
|
59
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
60
|
-
access_token: MOCK_ACCESS_JWT,
|
|
61
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
62
|
-
expires_in: 3600,
|
|
63
|
-
};
|
|
64
|
-
export const handleMockNonce = (mockReply) => {
|
|
65
|
-
const reply = mockReply ?? { status: 200, body: MOCK_NONCE_RESPONSE };
|
|
66
|
-
const mockNonceEndpoint = nock(MOCK_NONCE_URL)
|
|
67
|
-
.persist()
|
|
68
|
-
.get('')
|
|
69
|
-
.query(true)
|
|
70
|
-
.reply(reply.status, reply.body);
|
|
71
|
-
return mockNonceEndpoint;
|
|
72
|
-
};
|
|
73
|
-
export const handleMockSiweLogin = (mockReply) => {
|
|
74
|
-
const reply = mockReply ?? { status: 200, body: MOCK_SIWE_LOGIN_RESPONSE };
|
|
75
|
-
const mockLoginEndpoint = nock(MOCK_SIWE_LOGIN_URL)
|
|
76
|
-
.persist()
|
|
77
|
-
.post('')
|
|
78
|
-
.reply(reply.status, reply.body);
|
|
79
|
-
return mockLoginEndpoint;
|
|
80
|
-
};
|
|
81
|
-
export const handleMockPairIdentifiers = (mockReply) => {
|
|
82
|
-
const reply = mockReply ?? { status: 204 };
|
|
83
|
-
const mockPairIdentifiersEndpoint = nock(MOCK_PAIR_IDENTIFIERS_URL)
|
|
84
|
-
.persist()
|
|
85
|
-
.post('')
|
|
86
|
-
.reply(reply.status, reply.body);
|
|
87
|
-
return mockPairIdentifiersEndpoint;
|
|
88
|
-
};
|
|
89
|
-
export const handleMockSrpLogin = (mockReply) => {
|
|
90
|
-
const reply = mockReply ?? { status: 200, body: MOCK_SRP_LOGIN_RESPONSE };
|
|
91
|
-
const mockLoginEndpoint = nock(MOCK_SRP_LOGIN_URL)
|
|
92
|
-
.persist()
|
|
93
|
-
.post('')
|
|
94
|
-
.reply(reply.status, reply.body);
|
|
95
|
-
return mockLoginEndpoint;
|
|
96
|
-
};
|
|
97
|
-
export const handleMockOAuth2Token = (mockReply) => {
|
|
98
|
-
const reply = mockReply ?? { status: 200, body: MOCK_OIDC_TOKEN_RESPONSE };
|
|
99
|
-
const mockTokenEndpoint = nock(MOCK_OIDC_TOKEN_URL)
|
|
100
|
-
.persist()
|
|
101
|
-
.post('')
|
|
102
|
-
.reply(reply.status, reply.body);
|
|
103
|
-
return mockTokenEndpoint;
|
|
104
|
-
};
|
|
105
|
-
export const arrangeAuthAPIs = (options) => {
|
|
106
|
-
const mockNonceUrl = handleMockNonce(options?.mockNonceUrl);
|
|
107
|
-
const mockOAuth2TokenUrl = handleMockOAuth2Token(options?.mockOAuth2TokenUrl);
|
|
108
|
-
const mockSrpLoginUrl = handleMockSrpLogin(options?.mockSrpLoginUrl);
|
|
109
|
-
const mockSiweLoginUrl = handleMockSiweLogin(options?.mockSiweLoginUrl);
|
|
110
|
-
const mockPairIdentifiersUrl = handleMockPairIdentifiers(options?.mockPairIdentifiers);
|
|
111
|
-
return {
|
|
112
|
-
mockNonceUrl,
|
|
113
|
-
mockOAuth2TokenUrl,
|
|
114
|
-
mockSrpLoginUrl,
|
|
115
|
-
mockSiweLoginUrl,
|
|
116
|
-
mockPairIdentifiersUrl,
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=mock-auth.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-auth.mjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-auth.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,EAAE,GAAG,EAAE,6BAAyB;AACvC,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EACjB,kDAA8C;AAO/C,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACpD,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5D,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,QAAQ,GACnB,opBAAopB,CAAC;AAEvpB,MAAM,CAAC,MAAM,eAAe,GAC1B,6JAA6J,CAAC;AAEhK,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,kBAAkB;IACzB,UAAU,EAAE,4CAA4C;IACxD,gFAAgF;IAEhF,UAAU,EAAE,GAAG;CAChB,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,KAAK,EAAE,QAAQ;IACf,gFAAgF;IAEhF,UAAU,EAAE,IAAI;IAChB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,OAAO,EAAE;SACT,IAAI,CAAC,EAAE,CAAC;SACR,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAM/B,EAAE,EAAE;IACH,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACrE,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACxE,MAAM,sBAAsB,GAAG,yBAAyB,CACtD,OAAO,EAAE,mBAAmB,CAC7B,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,sBAAsB;KACvB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport { Env } from '../../shared/env';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n} from '../authentication-jwt-bearer/services';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nconst MOCK_NONCE_URL = NONCE_URL(Env.DEV);\nconst MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.DEV);\nconst MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.DEV);\nconst MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.DEV);\nconst MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.DEV);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nconst MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 300,\n};\n\nconst MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 3600,\n profile: {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_type: 'SIWE',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 3600,\n profile: {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n identifier_type: 'SRP',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n access_token: MOCK_ACCESS_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n\n expires_in: 3600,\n};\n\nexport const handleMockNonce = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_NONCE_RESPONSE };\n\n const mockNonceEndpoint = nock(MOCK_NONCE_URL)\n .persist()\n .get('')\n .query(true)\n .reply(reply.status, reply.body);\n\n return mockNonceEndpoint;\n};\n\nexport const handleMockSiweLogin = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_SIWE_LOGIN_RESPONSE };\n const mockLoginEndpoint = nock(MOCK_SIWE_LOGIN_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockLoginEndpoint;\n};\n\nexport const handleMockPairIdentifiers = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockPairIdentifiersEndpoint = nock(MOCK_PAIR_IDENTIFIERS_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockPairIdentifiersEndpoint;\n};\n\nexport const handleMockSrpLogin = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_SRP_LOGIN_RESPONSE };\n const mockLoginEndpoint = nock(MOCK_SRP_LOGIN_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockLoginEndpoint;\n};\n\nexport const handleMockOAuth2Token = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 200, body: MOCK_OIDC_TOKEN_RESPONSE };\n const mockTokenEndpoint = nock(MOCK_OIDC_TOKEN_URL)\n .persist()\n .post('')\n .reply(reply.status, reply.body);\n\n return mockTokenEndpoint;\n};\n\nexport const arrangeAuthAPIs = (options?: {\n mockNonceUrl?: MockReply;\n mockOAuth2TokenUrl?: MockReply;\n mockSrpLoginUrl?: MockReply;\n mockSiweLoginUrl?: MockReply;\n mockPairIdentifiers?: MockReply;\n}) => {\n const mockNonceUrl = handleMockNonce(options?.mockNonceUrl);\n const mockOAuth2TokenUrl = handleMockOAuth2Token(options?.mockOAuth2TokenUrl);\n const mockSrpLoginUrl = handleMockSrpLogin(options?.mockSrpLoginUrl);\n const mockSiweLoginUrl = handleMockSiweLogin(options?.mockSiweLoginUrl);\n const mockPairIdentifiersUrl = handleMockPairIdentifiers(\n options?.mockPairIdentifiers,\n );\n\n return {\n mockNonceUrl,\n mockOAuth2TokenUrl,\n mockSrpLoginUrl,\n mockSiweLoginUrl,\n mockPairIdentifiersUrl,\n };\n};\n"]}
|