@metamask/profile-sync-controller 0.5.0 → 0.7.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 +51 -1
- package/auth/mocks/package.json +2 -2
- package/auth/package.json +2 -2
- package/dist/controllers/authentication/AuthenticationController.cjs +211 -0
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
- package/dist/{types/controllers/authentication/AuthenticationController.d.ts → controllers/authentication/AuthenticationController.d.cts} +5 -5
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.d.mts +78 -0
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.mjs +206 -11
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/__fixtures__/index.cjs +18 -0
- package/dist/controllers/authentication/__fixtures__/index.cjs.map +1 -0
- package/dist/controllers/authentication/__fixtures__/index.d.cts +2 -0
- package/dist/controllers/authentication/__fixtures__/index.d.cts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/index.d.mts +2 -0
- package/dist/controllers/authentication/__fixtures__/index.d.mts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/index.mjs +2 -0
- package/dist/controllers/authentication/__fixtures__/index.mjs.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +52 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -0
- package/dist/{types/controllers/authentication/__fixtures__/mockResponses.d.ts → controllers/authentication/__fixtures__/mockResponses.d.cts} +2 -2
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts +23 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +46 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.cjs +37 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.cjs.map +1 -0
- package/dist/{types/controllers/authentication/__fixtures__/mockServices.d.ts → controllers/authentication/__fixtures__/mockServices.d.cts} +2 -2
- package/dist/controllers/authentication/__fixtures__/mockServices.d.cts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.d.mts +10 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.d.mts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.mjs +35 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.mjs.map +1 -0
- package/dist/controllers/authentication/auth-snap-requests.cjs +39 -0
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -0
- package/dist/{types/controllers/authentication/auth-snap-requests.d.ts → controllers/authentication/auth-snap-requests.d.cts} +2 -2
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -0
- package/dist/controllers/authentication/auth-snap-requests.d.mts +17 -0
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -0
- package/dist/controllers/authentication/auth-snap-requests.mjs +33 -9
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
- package/dist/controllers/authentication/index.cjs +39 -0
- package/dist/controllers/authentication/index.cjs.map +1 -0
- package/dist/controllers/authentication/index.d.cts +7 -0
- package/dist/controllers/authentication/index.d.cts.map +1 -0
- package/dist/controllers/authentication/index.d.mts +7 -0
- package/dist/controllers/authentication/index.d.mts.map +1 -0
- package/dist/controllers/authentication/index.mjs +6 -18
- package/dist/controllers/authentication/index.mjs.map +1 -1
- package/dist/controllers/authentication/services.cjs +127 -0
- package/dist/controllers/authentication/services.cjs.map +1 -0
- package/dist/{types/controllers/authentication/services.d.ts → controllers/authentication/services.d.cts} +1 -1
- package/dist/controllers/authentication/services.d.cts.map +1 -0
- package/dist/controllers/authentication/services.d.mts +70 -0
- package/dist/controllers/authentication/services.d.mts.map +1 -0
- package/dist/controllers/authentication/services.mjs +118 -19
- package/dist/controllers/authentication/services.mjs.map +1 -1
- package/dist/controllers/index.cjs +29 -0
- package/dist/controllers/index.cjs.map +1 -0
- package/dist/controllers/index.d.cts +3 -0
- package/dist/controllers/index.d.cts.map +1 -0
- package/dist/controllers/index.d.mts +3 -0
- package/dist/controllers/index.d.mts.map +1 -0
- package/dist/controllers/index.mjs +2 -24
- package/dist/controllers/index.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +462 -0
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/UserStorageController.d.ts → controllers/user-storage/UserStorageController.d.cts} +44 -15
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.d.mts +156 -0
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.mjs +457 -18
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/index.cjs +19 -0
- package/dist/controllers/user-storage/__fixtures__/index.cjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.cts +3 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.mts +3 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/index.mjs +3 -0
- package/dist/controllers/user-storage/__fixtures__/index.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs +127 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockAccounts.d.ts → controllers/user-storage/__fixtures__/mockAccounts.d.cts} +6 -6
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts +63 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs +123 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +48 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockResponses.d.ts → controllers/user-storage/__fixtures__/mockResponses.d.cts} +6 -4
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +21 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +39 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +41 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockServices.d.ts → controllers/user-storage/__fixtures__/mockServices.d.cts} +3 -3
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +11 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +39 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs +36 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockStorage.d.ts → controllers/user-storage/__fixtures__/mockStorage.d.cts} +2 -2
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts +5 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs +9 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +31 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +14 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +14 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +27 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.cjs +51 -0
- package/dist/controllers/user-storage/accounts/constants.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/accounts/constants.d.ts → controllers/user-storage/accounts/constants.d.cts} +1 -1
- package/dist/controllers/user-storage/accounts/constants.d.cts.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.d.mts +4 -0
- package/dist/controllers/user-storage/accounts/constants.d.mts.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.mjs +47 -11
- package/dist/controllers/user-storage/accounts/constants.mjs.map +1 -1
- package/dist/controllers/user-storage/accounts/user-storage.cjs +34 -0
- package/dist/controllers/user-storage/accounts/user-storage.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/accounts/user-storage.d.ts → controllers/user-storage/accounts/user-storage.d.cts} +3 -3
- package/dist/controllers/user-storage/accounts/user-storage.d.cts.map +1 -0
- package/dist/controllers/user-storage/accounts/user-storage.d.mts +32 -0
- package/dist/controllers/user-storage/accounts/user-storage.d.mts.map +1 -0
- package/dist/controllers/user-storage/accounts/user-storage.mjs +27 -9
- package/dist/controllers/user-storage/accounts/user-storage.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/cache.cjs +79 -0
- package/dist/controllers/user-storage/encryption/cache.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/encryption/cache.d.ts → controllers/user-storage/encryption/cache.d.cts} +1 -1
- package/dist/controllers/user-storage/encryption/cache.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/cache.d.mts +31 -0
- package/dist/controllers/user-storage/encryption/cache.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/cache.mjs +71 -11
- package/dist/controllers/user-storage/encryption/cache.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/encryption.cjs +151 -0
- package/dist/controllers/user-storage/encryption/encryption.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/encryption/encryption.d.ts → controllers/user-storage/encryption/encryption.d.cts} +2 -2
- package/dist/controllers/user-storage/encryption/encryption.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/encryption.d.mts +27 -0
- package/dist/controllers/user-storage/encryption/encryption.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/encryption.mjs +145 -10
- package/dist/controllers/user-storage/encryption/encryption.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/index.cjs +25 -0
- package/dist/controllers/user-storage/encryption/index.cjs.map +1 -0
- package/dist/controllers/user-storage/encryption/index.d.cts +5 -0
- package/dist/controllers/user-storage/encryption/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/index.d.mts +5 -0
- package/dist/controllers/user-storage/encryption/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/index.mjs +4 -15
- package/dist/controllers/user-storage/encryption/index.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/utils.cjs +17 -0
- package/dist/controllers/user-storage/encryption/utils.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/encryption/utils.d.ts → controllers/user-storage/encryption/utils.d.cts} +1 -1
- package/dist/controllers/user-storage/encryption/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/utils.d.mts +4 -0
- package/dist/controllers/user-storage/encryption/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/utils.mjs +9 -10
- package/dist/controllers/user-storage/encryption/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/index.cjs +40 -0
- package/dist/controllers/user-storage/index.cjs.map +1 -0
- package/dist/controllers/user-storage/index.d.cts +8 -0
- package/dist/controllers/user-storage/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/index.d.mts +8 -0
- package/dist/controllers/user-storage/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/index.mjs +7 -30
- package/dist/controllers/user-storage/index.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs +25 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts +4 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts +4 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs +20 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +65 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +13 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +13 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +65 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.cjs +64 -0
- package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.d.cts +21 -0
- package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.d.mts +21 -0
- package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.mjs +58 -0
- package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.cjs +171 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.cts +35 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.mts +35 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.mjs +162 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs +28 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +9 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +9 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs +22 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.cjs +16 -0
- package/dist/controllers/user-storage/network-syncing/types.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.d.cts +18 -0
- package/dist/controllers/user-storage/network-syncing/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.d.mts +18 -0
- package/dist/controllers/user-storage/network-syncing/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.mjs +11 -0
- package/dist/controllers/user-storage/network-syncing/types.mjs.map +1 -0
- package/dist/controllers/user-storage/schema.cjs +56 -0
- package/dist/controllers/user-storage/schema.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/schema.d.ts → controllers/user-storage/schema.d.cts} +2 -1
- package/dist/controllers/user-storage/schema.d.cts.map +1 -0
- package/dist/controllers/user-storage/schema.d.mts +38 -0
- package/dist/controllers/user-storage/schema.d.mts.map +1 -0
- package/dist/controllers/user-storage/schema.mjs +48 -16
- package/dist/controllers/user-storage/schema.mjs.map +1 -1
- package/dist/controllers/user-storage/services.cjs +119 -0
- package/dist/controllers/user-storage/services.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/services.d.ts → controllers/user-storage/services.d.cts} +4 -5
- package/dist/controllers/user-storage/services.d.cts.map +1 -0
- package/dist/controllers/user-storage/services.d.mts +48 -0
- package/dist/controllers/user-storage/services.d.mts.map +1 -0
- package/dist/controllers/user-storage/services.mjs +116 -21
- package/dist/controllers/user-storage/services.mjs.map +1 -1
- package/dist/controllers/user-storage/utils.cjs +30 -0
- package/dist/controllers/user-storage/utils.cjs.map +1 -0
- package/dist/controllers/user-storage/utils.d.cts +17 -0
- package/dist/controllers/user-storage/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/utils.d.mts +17 -0
- package/dist/controllers/user-storage/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/utils.mjs +25 -0
- package/dist/controllers/user-storage/utils.mjs.map +1 -0
- package/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -39
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-auth.cjs +139 -0
- package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -0
- package/dist/{types/sdk/__fixtures__/mock-auth.d.ts → sdk/__fixtures__/mock-auth.d.cts} +2 -2
- package/dist/sdk/__fixtures__/mock-auth.d.cts.map +1 -0
- package/dist/sdk/__fixtures__/mock-auth.d.mts +42 -0
- package/dist/sdk/__fixtures__/mock-auth.d.mts.map +1 -0
- package/dist/sdk/__fixtures__/mock-auth.mjs +134 -0
- package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -0
- package/dist/sdk/__fixtures__/mock-userstorage.cjs +58 -0
- package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -0
- package/dist/{types/sdk/__fixtures__/mock-userstorage.d.ts → sdk/__fixtures__/mock-userstorage.d.cts} +2 -2
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -0
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts +19 -0
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -0
- package/dist/sdk/__fixtures__/mock-userstorage.mjs +54 -0
- package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -0
- package/dist/sdk/__fixtures__/test-utils.cjs +74 -0
- package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -0
- package/dist/{types/sdk/__fixtures__/test-utils.d.ts → sdk/__fixtures__/test-utils.d.cts} +6 -6
- package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -0
- package/dist/sdk/__fixtures__/test-utils.d.mts +25 -0
- package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -0
- package/dist/sdk/__fixtures__/test-utils.mjs +69 -0
- package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +106 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/flow-siwe.d.ts → sdk/authentication-jwt-bearer/flow-siwe.d.cts} +2 -2
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +23 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +101 -11
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +125 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/flow-srp.d.ts → sdk/authentication-jwt-bearer/flow-srp.d.cts} +4 -2
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +19 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +119 -13
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +180 -0
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/services.d.ts → sdk/authentication-jwt-bearer/services.d.cts} +4 -4
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +63 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.mjs +166 -25
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/types.d.ts → sdk/authentication-jwt-bearer/types.d.cts} +2 -2
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +67 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/types.mjs +8 -7
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +124 -0
- package/dist/sdk/authentication.cjs.map +1 -0
- package/dist/{types/sdk/authentication.d.ts → sdk/authentication.d.cts} +7 -7
- package/dist/sdk/authentication.d.cts.map +1 -0
- package/dist/sdk/authentication.d.mts +32 -0
- package/dist/sdk/authentication.d.mts.map +1 -0
- package/dist/sdk/authentication.mjs +102 -24
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/encryption.cjs +23 -0
- package/dist/sdk/encryption.cjs.map +1 -0
- package/dist/sdk/encryption.d.cts +4 -0
- package/dist/sdk/encryption.d.cts.map +1 -0
- package/dist/sdk/encryption.d.mts +4 -0
- package/dist/sdk/encryption.d.mts.map +1 -0
- package/dist/sdk/encryption.mjs +3 -13
- package/dist/sdk/encryption.mjs.map +1 -1
- package/dist/sdk/env.cjs +85 -0
- package/dist/sdk/env.cjs.map +1 -0
- package/dist/{types/sdk/env.d.ts → sdk/env.d.cts} +1 -1
- package/dist/sdk/env.d.cts.map +1 -0
- package/dist/sdk/env.d.mts +34 -0
- package/dist/sdk/env.d.mts.map +1 -0
- package/dist/sdk/env.mjs +78 -12
- package/dist/sdk/env.mjs.map +1 -1
- package/dist/sdk/errors.cjs +53 -0
- package/dist/sdk/errors.cjs.map +1 -0
- package/dist/{types/sdk/errors.d.ts → sdk/errors.d.cts} +1 -1
- package/dist/sdk/errors.d.cts.map +1 -0
- package/dist/sdk/errors.d.mts +22 -0
- package/dist/sdk/errors.d.mts.map +1 -0
- package/dist/sdk/errors.mjs +42 -19
- package/dist/sdk/errors.mjs.map +1 -1
- package/dist/sdk/index.cjs +23 -0
- package/dist/sdk/index.cjs.map +1 -0
- package/dist/sdk/index.d.cts +7 -0
- package/dist/sdk/index.d.cts.map +1 -0
- package/dist/sdk/index.d.mts +7 -0
- package/dist/sdk/index.d.mts.map +1 -0
- package/dist/sdk/index.mjs +6 -78
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +176 -0
- package/dist/sdk/user-storage.cjs.map +1 -0
- package/dist/{types/sdk/user-storage.d.ts → sdk/user-storage.d.cts} +4 -4
- package/dist/sdk/user-storage.d.cts.map +1 -0
- package/dist/sdk/user-storage.d.mts +27 -0
- package/dist/sdk/user-storage.d.mts.map +1 -0
- package/dist/sdk/user-storage.mjs +146 -16
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.cjs +70 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -0
- package/dist/{types/sdk/utils/eip-6963-metamask-provider.d.ts → sdk/utils/eip-6963-metamask-provider.d.cts} +2 -2
- package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +1 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +25 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +1 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs +64 -8
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +73 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
- package/dist/{types/sdk/utils/messaging-signing-snap-requests.d.ts → sdk/utils/messaging-signing-snap-requests.d.cts} +2 -7
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +35 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +65 -16
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/sdk/utils/validate-login-response.cjs +22 -0
- package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
- package/dist/{types/sdk/utils/validate-login-response.d.ts → sdk/utils/validate-login-response.d.cts} +2 -2
- package/dist/sdk/utils/validate-login-response.d.cts.map +1 -0
- package/dist/sdk/utils/validate-login-response.d.mts +10 -0
- package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
- package/dist/sdk/utils/validate-login-response.mjs +17 -7
- package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
- package/package.json +62 -30
- package/sdk/package.json +9 -0
- package/user-storage/mocks/package.json +2 -2
- package/user-storage/package.json +2 -2
- package/dist/chunk-2CWF7ZTL.mjs +0 -129
- package/dist/chunk-2CWF7ZTL.mjs.map +0 -1
- package/dist/chunk-2VEMA6OE.mjs +0 -47
- package/dist/chunk-2VEMA6OE.mjs.map +0 -1
- package/dist/chunk-4LMFZDL4.js +0 -114
- package/dist/chunk-4LMFZDL4.js.map +0 -1
- package/dist/chunk-4TMLEABQ.js +0 -79
- package/dist/chunk-4TMLEABQ.js.map +0 -1
- package/dist/chunk-5MQUI24U.js +0 -47
- package/dist/chunk-5MQUI24U.js.map +0 -1
- package/dist/chunk-5XSXZTED.mjs +0 -57
- package/dist/chunk-5XSXZTED.mjs.map +0 -1
- package/dist/chunk-6DAK2U35.mjs +0 -11
- package/dist/chunk-6DAK2U35.mjs.map +0 -1
- package/dist/chunk-76NMME23.mjs +0 -114
- package/dist/chunk-76NMME23.mjs.map +0 -1
- package/dist/chunk-76VRE4BI.mjs +0 -18
- package/dist/chunk-76VRE4BI.mjs.map +0 -1
- package/dist/chunk-BKQE7DB5.js +0 -170
- package/dist/chunk-BKQE7DB5.js.map +0 -1
- package/dist/chunk-CAIIVJAO.mjs +0 -11
- package/dist/chunk-CAIIVJAO.mjs.map +0 -1
- package/dist/chunk-COBJUBZE.mjs +0 -170
- package/dist/chunk-COBJUBZE.mjs.map +0 -1
- package/dist/chunk-D4SNJOID.mjs +0 -269
- package/dist/chunk-D4SNJOID.mjs.map +0 -1
- package/dist/chunk-DF24ZX4H.js +0 -76
- package/dist/chunk-DF24ZX4H.js.map +0 -1
- package/dist/chunk-DRB2MN4T.js +0 -16
- package/dist/chunk-DRB2MN4T.js.map +0 -1
- package/dist/chunk-EHZFPUJH.mjs +0 -53
- package/dist/chunk-EHZFPUJH.mjs.map +0 -1
- package/dist/chunk-F6BAOSH2.js +0 -269
- package/dist/chunk-F6BAOSH2.js.map +0 -1
- package/dist/chunk-GQXYWBFK.js +0 -28
- package/dist/chunk-GQXYWBFK.js.map +0 -1
- package/dist/chunk-H25EBXG5.mjs +0 -58
- package/dist/chunk-H25EBXG5.mjs.map +0 -1
- package/dist/chunk-IGY2S5BC.js +0 -36
- package/dist/chunk-IGY2S5BC.js.map +0 -1
- package/dist/chunk-JAQ5TPSZ.js +0 -53
- package/dist/chunk-JAQ5TPSZ.js.map +0 -1
- package/dist/chunk-KHASG4H3.mjs +0 -11
- package/dist/chunk-KHASG4H3.mjs.map +0 -1
- package/dist/chunk-KIVBL6OM.js +0 -129
- package/dist/chunk-KIVBL6OM.js.map +0 -1
- package/dist/chunk-KTCSRECK.mjs +0 -76
- package/dist/chunk-KTCSRECK.mjs.map +0 -1
- package/dist/chunk-LGXQBALM.mjs +0 -106
- package/dist/chunk-LGXQBALM.mjs.map +0 -1
- package/dist/chunk-LLG4D2SC.js +0 -157
- package/dist/chunk-LLG4D2SC.js.map +0 -1
- package/dist/chunk-M7AUA5W7.mjs +0 -79
- package/dist/chunk-M7AUA5W7.mjs.map +0 -1
- package/dist/chunk-MBTBE4P5.js +0 -54
- package/dist/chunk-MBTBE4P5.js.map +0 -1
- package/dist/chunk-MK7ABX2V.mjs +0 -186
- package/dist/chunk-MK7ABX2V.mjs.map +0 -1
- package/dist/chunk-NEBLEB3X.mjs +0 -107
- package/dist/chunk-NEBLEB3X.mjs.map +0 -1
- package/dist/chunk-NIUQ34PY.js +0 -11
- package/dist/chunk-NIUQ34PY.js.map +0 -1
- package/dist/chunk-NMIF3LSX.mjs +0 -29
- package/dist/chunk-NMIF3LSX.mjs.map +0 -1
- package/dist/chunk-OLFO6R7Z.mjs +0 -546
- package/dist/chunk-OLFO6R7Z.mjs.map +0 -1
- package/dist/chunk-PBRUOBEQ.js +0 -11
- package/dist/chunk-PBRUOBEQ.js.map +0 -1
- package/dist/chunk-PCOIRDTO.js +0 -18
- package/dist/chunk-PCOIRDTO.js.map +0 -1
- package/dist/chunk-PQMPSEVJ.js +0 -546
- package/dist/chunk-PQMPSEVJ.js.map +0 -1
- package/dist/chunk-PRYLTXW4.js +0 -92
- package/dist/chunk-PRYLTXW4.js.map +0 -1
- package/dist/chunk-PU7MAIST.mjs +0 -129
- package/dist/chunk-PU7MAIST.mjs.map +0 -1
- package/dist/chunk-QCQU4BQL.js +0 -68
- package/dist/chunk-QCQU4BQL.js.map +0 -1
- package/dist/chunk-QDGLIUUS.mjs +0 -16
- package/dist/chunk-QDGLIUUS.mjs.map +0 -1
- package/dist/chunk-RG4II6WH.js +0 -57
- package/dist/chunk-RG4II6WH.js.map +0 -1
- package/dist/chunk-TFFQFIJV.mjs +0 -54
- package/dist/chunk-TFFQFIJV.mjs.map +0 -1
- package/dist/chunk-TP7SP3AG.mjs +0 -133
- package/dist/chunk-TP7SP3AG.mjs.map +0 -1
- package/dist/chunk-U5UIDVOO.mjs +0 -36
- package/dist/chunk-U5UIDVOO.mjs.map +0 -1
- package/dist/chunk-UAXWZN5J.js +0 -58
- package/dist/chunk-UAXWZN5J.js.map +0 -1
- package/dist/chunk-UEHMUVQQ.js +0 -133
- package/dist/chunk-UEHMUVQQ.js.map +0 -1
- package/dist/chunk-UEWCUBMX.mjs +0 -68
- package/dist/chunk-UEWCUBMX.mjs.map +0 -1
- package/dist/chunk-UHP2Y32K.mjs +0 -92
- package/dist/chunk-UHP2Y32K.mjs.map +0 -1
- package/dist/chunk-UHX7HJAI.js +0 -11
- package/dist/chunk-UHX7HJAI.js.map +0 -1
- package/dist/chunk-UIRAMHNM.js +0 -186
- package/dist/chunk-UIRAMHNM.js.map +0 -1
- package/dist/chunk-VWDRFRJU.js +0 -107
- package/dist/chunk-VWDRFRJU.js.map +0 -1
- package/dist/chunk-Y45XUW33.js +0 -129
- package/dist/chunk-Y45XUW33.js.map +0 -1
- package/dist/chunk-YHGWG3EQ.js +0 -29
- package/dist/chunk-YHGWG3EQ.js.map +0 -1
- package/dist/chunk-YLURF2PF.mjs +0 -157
- package/dist/chunk-YLURF2PF.mjs.map +0 -1
- package/dist/chunk-ZUPTMFEA.mjs +0 -28
- package/dist/chunk-ZUPTMFEA.mjs.map +0 -1
- package/dist/chunk-ZX2KHPXG.js +0 -106
- package/dist/chunk-ZX2KHPXG.js.map +0 -1
- package/dist/controllers/authentication/AuthenticationController.js +0 -13
- package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.js +0 -10
- package/dist/controllers/authentication/auth-snap-requests.js.map +0 -1
- package/dist/controllers/authentication/index.js +0 -19
- package/dist/controllers/authentication/index.js.map +0 -1
- package/dist/controllers/authentication/services.js +0 -21
- package/dist/controllers/authentication/services.js.map +0 -1
- package/dist/controllers/index.js +0 -25
- package/dist/controllers/index.js.map +0 -1
- package/dist/controllers/user-storage/UserStorageController.js +0 -20
- package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
- package/dist/controllers/user-storage/accounts/constants.js +0 -12
- package/dist/controllers/user-storage/accounts/constants.js.map +0 -1
- package/dist/controllers/user-storage/accounts/user-storage.js +0 -11
- package/dist/controllers/user-storage/accounts/user-storage.js.map +0 -1
- package/dist/controllers/user-storage/encryption/cache.js +0 -13
- package/dist/controllers/user-storage/encryption/cache.js.map +0 -1
- package/dist/controllers/user-storage/encryption/encryption.js +0 -12
- package/dist/controllers/user-storage/encryption/encryption.js.map +0 -1
- package/dist/controllers/user-storage/encryption/index.js +0 -16
- package/dist/controllers/user-storage/encryption/index.js.map +0 -1
- package/dist/controllers/user-storage/encryption/utils.js +0 -12
- package/dist/controllers/user-storage/encryption/utils.js.map +0 -1
- package/dist/controllers/user-storage/index.js +0 -31
- package/dist/controllers/user-storage/index.js.map +0 -1
- package/dist/controllers/user-storage/schema.js +0 -18
- package/dist/controllers/user-storage/schema.js.map +0 -1
- package/dist/controllers/user-storage/services.js +0 -22
- package/dist/controllers/user-storage/services.js.map +0 -1
- package/dist/index.js +0 -40
- package/dist/index.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -13
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -15
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/services.js +0 -27
- package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/types.js +0 -8
- package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
- package/dist/sdk/authentication.js +0 -26
- package/dist/sdk/authentication.js.map +0 -1
- package/dist/sdk/encryption.js +0 -14
- package/dist/sdk/encryption.js.map +0 -1
- package/dist/sdk/env.js +0 -14
- package/dist/sdk/env.js.map +0 -1
- package/dist/sdk/errors.js +0 -20
- package/dist/sdk/errors.js.map +0 -1
- package/dist/sdk/index.js +0 -79
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/user-storage.js +0 -18
- package/dist/sdk/user-storage.js.map +0 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.js +0 -10
- package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.js +0 -18
- package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
- package/dist/sdk/utils/validate-login-response.js +0 -8
- package/dist/sdk/utils/validate-login-response.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/controllers/authentication/AuthenticationController.d.ts.map +0 -1
- package/dist/types/controllers/authentication/__fixtures__/index.d.ts +0 -2
- package/dist/types/controllers/authentication/__fixtures__/index.d.ts.map +0 -1
- package/dist/types/controllers/authentication/__fixtures__/mockResponses.d.ts.map +0 -1
- package/dist/types/controllers/authentication/__fixtures__/mockServices.d.ts.map +0 -1
- package/dist/types/controllers/authentication/auth-snap-requests.d.ts.map +0 -1
- package/dist/types/controllers/authentication/index.d.ts +0 -7
- package/dist/types/controllers/authentication/index.d.ts.map +0 -1
- package/dist/types/controllers/authentication/services.d.ts.map +0 -1
- package/dist/types/controllers/index.d.ts +0 -3
- package/dist/types/controllers/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/UserStorageController.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/index.d.ts +0 -3
- package/dist/types/controllers/user-storage/__fixtures__/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockAccounts.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockResponses.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockServices.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockStorage.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/accounts/constants.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/accounts/user-storage.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/cache.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/encryption.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/index.d.ts +0 -5
- package/dist/types/controllers/user-storage/encryption/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/utils.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/index.d.ts +0 -8
- package/dist/types/controllers/user-storage/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/schema.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/services.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/sdk/__fixtures__/mock-auth.d.ts.map +0 -1
- package/dist/types/sdk/__fixtures__/mock-userstorage.d.ts.map +0 -1
- package/dist/types/sdk/__fixtures__/test-utils.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
- package/dist/types/sdk/authentication.d.ts.map +0 -1
- package/dist/types/sdk/encryption.d.ts +0 -4
- package/dist/types/sdk/encryption.d.ts.map +0 -1
- package/dist/types/sdk/env.d.ts.map +0 -1
- package/dist/types/sdk/errors.d.ts.map +0 -1
- package/dist/types/sdk/index.d.ts +0 -7
- package/dist/types/sdk/index.d.ts.map +0 -1
- package/dist/types/sdk/user-storage.d.ts.map +0 -1
- package/dist/types/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
- package/dist/types/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
- package/dist/types/sdk/utils/validate-login-response.d.ts.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
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 { NONCE_URL, SIWE_LOGIN_URL, SRP_LOGIN_URL, OIDC_TOKEN_URL, PAIR_IDENTIFIERS } from "../authentication-jwt-bearer/services.mjs";
|
|
10
|
+
import { Env } from "../env.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
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
23
|
+
expires_in: 300,
|
|
24
|
+
};
|
|
25
|
+
const MOCK_SIWE_LOGIN_RESPONSE = {
|
|
26
|
+
token: MOCK_JWT,
|
|
27
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
29
|
+
expires_in: 3600,
|
|
30
|
+
profile: {
|
|
31
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
33
|
+
profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',
|
|
34
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
36
|
+
metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',
|
|
37
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
39
|
+
identifier_id: 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',
|
|
40
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
42
|
+
identifier_type: 'SIWE',
|
|
43
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
45
|
+
encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export const MOCK_SRP_LOGIN_RESPONSE = {
|
|
49
|
+
token: MOCK_JWT,
|
|
50
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
52
|
+
expires_in: 3600,
|
|
53
|
+
profile: {
|
|
54
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
56
|
+
profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',
|
|
57
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
59
|
+
metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',
|
|
60
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
62
|
+
identifier_id: 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',
|
|
63
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
65
|
+
identifier_type: 'SRP',
|
|
66
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
68
|
+
encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
export const MOCK_OIDC_TOKEN_RESPONSE = {
|
|
72
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
74
|
+
access_token: MOCK_ACCESS_JWT,
|
|
75
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
77
|
+
expires_in: 3600,
|
|
78
|
+
};
|
|
79
|
+
export const handleMockNonce = (mockReply) => {
|
|
80
|
+
const reply = mockReply ?? { status: 200, body: MOCK_NONCE_RESPONSE };
|
|
81
|
+
const mockNonceEndpoint = nock(MOCK_NONCE_URL)
|
|
82
|
+
.persist()
|
|
83
|
+
.get('')
|
|
84
|
+
.query(true)
|
|
85
|
+
.reply(reply.status, reply.body);
|
|
86
|
+
return mockNonceEndpoint;
|
|
87
|
+
};
|
|
88
|
+
export const handleMockSiweLogin = (mockReply) => {
|
|
89
|
+
const reply = mockReply ?? { status: 200, body: MOCK_SIWE_LOGIN_RESPONSE };
|
|
90
|
+
const mockLoginEndpoint = nock(MOCK_SIWE_LOGIN_URL)
|
|
91
|
+
.persist()
|
|
92
|
+
.post('')
|
|
93
|
+
.reply(reply.status, reply.body);
|
|
94
|
+
return mockLoginEndpoint;
|
|
95
|
+
};
|
|
96
|
+
export const handleMockPairIdentifiers = (mockReply) => {
|
|
97
|
+
const reply = mockReply ?? { status: 204 };
|
|
98
|
+
const mockPairIdentifiersEndpoint = nock(MOCK_PAIR_IDENTIFIERS_URL)
|
|
99
|
+
.persist()
|
|
100
|
+
.post('')
|
|
101
|
+
.reply(reply.status, reply.body);
|
|
102
|
+
return mockPairIdentifiersEndpoint;
|
|
103
|
+
};
|
|
104
|
+
export const handleMockSrpLogin = (mockReply) => {
|
|
105
|
+
const reply = mockReply ?? { status: 200, body: MOCK_SRP_LOGIN_RESPONSE };
|
|
106
|
+
const mockLoginEndpoint = nock(MOCK_SRP_LOGIN_URL)
|
|
107
|
+
.persist()
|
|
108
|
+
.post('')
|
|
109
|
+
.reply(reply.status, reply.body);
|
|
110
|
+
return mockLoginEndpoint;
|
|
111
|
+
};
|
|
112
|
+
export const handleMockOAuth2Token = (mockReply) => {
|
|
113
|
+
const reply = mockReply ?? { status: 200, body: MOCK_OIDC_TOKEN_RESPONSE };
|
|
114
|
+
const mockTokenEndpoint = nock(MOCK_OIDC_TOKEN_URL)
|
|
115
|
+
.persist()
|
|
116
|
+
.post('')
|
|
117
|
+
.reply(reply.status, reply.body);
|
|
118
|
+
return mockTokenEndpoint;
|
|
119
|
+
};
|
|
120
|
+
export const arrangeAuthAPIs = (options) => {
|
|
121
|
+
const mockNonceUrl = handleMockNonce(options?.mockNonceUrl);
|
|
122
|
+
const mockOAuth2TokenUrl = handleMockOAuth2Token(options?.mockOAuth2TokenUrl);
|
|
123
|
+
const mockSrpLoginUrl = handleMockSrpLogin(options?.mockSrpLoginUrl);
|
|
124
|
+
const mockSiweLoginUrl = handleMockSiweLogin(options?.mockSiweLoginUrl);
|
|
125
|
+
const mockPairIdentifiersUrl = handleMockPairIdentifiers(options?.mockPairIdentifiers);
|
|
126
|
+
return {
|
|
127
|
+
mockNonceUrl,
|
|
128
|
+
mockOAuth2TokenUrl,
|
|
129
|
+
mockSrpLoginUrl,
|
|
130
|
+
mockSiweLoginUrl,
|
|
131
|
+
mockPairIdentifiersUrl,
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=mock-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-auth.mjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-auth.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EACjB,kDAA8C;AAC/C,OAAO,EAAE,GAAG,EAAE,mBAAe;AAO7B,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;IAChF,gEAAgE;IAChE,UAAU,EAAE,GAAG;CAChB,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,KAAK,EAAE,QAAQ;IACf,gF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AEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAC7D,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;IAC3E,MAAM,iBAAiB,GAAG,IAAI,CAAC,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;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 {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n} from '../authentication-jwt-bearer/services';\nimport { Env } from '../env';\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 // eslint-disable-next-line @typescript-eslint/naming-convention\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 // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: 3600,\n profile: {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_type: 'SIWE',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: 3600,\n profile: {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_type: 'SRP',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // eslint-disable-next-line @typescript-eslint/naming-convention\n access_token: MOCK_ACCESS_JWT,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
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.handleMockUserStoragePut = exports.handleMockUserStorageGetAllFeatureEntries = exports.handleMockUserStorageGet = exports.MOCK_STORAGE_RESPONSE = exports.MOCK_NOTIFICATIONS_DATA_ENCRYPTED = exports.MOCK_NOTIFICATIONS_DATA = exports.MOCK_STORAGE_KEY = void 0;
|
|
7
|
+
const nock_1 = __importDefault(require("nock"));
|
|
8
|
+
const encryption_1 = __importDefault(require("../encryption.cjs"));
|
|
9
|
+
const env_1 = require("../env.cjs");
|
|
10
|
+
const user_storage_1 = require("../user-storage.cjs");
|
|
11
|
+
// Example mock notifications storage entry (wildcard)
|
|
12
|
+
const MOCK_STORAGE_URL = (0, user_storage_1.STORAGE_URL)(env_1.Env.DEV, 'notifications/notificationSettings');
|
|
13
|
+
const MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = (0, user_storage_1.STORAGE_URL)(env_1.Env.DEV, 'notifications');
|
|
14
|
+
exports.MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';
|
|
15
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
|
+
exports.MOCK_NOTIFICATIONS_DATA = { is_compact: false };
|
|
18
|
+
const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () => await encryption_1.default.encryptString(JSON.stringify(exports.MOCK_NOTIFICATIONS_DATA), exports.MOCK_STORAGE_KEY);
|
|
19
|
+
exports.MOCK_NOTIFICATIONS_DATA_ENCRYPTED = MOCK_NOTIFICATIONS_DATA_ENCRYPTED;
|
|
20
|
+
const MOCK_STORAGE_RESPONSE = async () => ({
|
|
21
|
+
HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',
|
|
22
|
+
Data: await (0, exports.MOCK_NOTIFICATIONS_DATA_ENCRYPTED)(),
|
|
23
|
+
});
|
|
24
|
+
exports.MOCK_STORAGE_RESPONSE = MOCK_STORAGE_RESPONSE;
|
|
25
|
+
const handleMockUserStorageGet = async (mockReply) => {
|
|
26
|
+
const reply = mockReply ?? {
|
|
27
|
+
status: 200,
|
|
28
|
+
body: await (0, exports.MOCK_STORAGE_RESPONSE)(),
|
|
29
|
+
};
|
|
30
|
+
const mockEndpoint = (0, nock_1.default)(MOCK_STORAGE_URL)
|
|
31
|
+
.persist()
|
|
32
|
+
.get(/.*/u)
|
|
33
|
+
.reply(reply.status, reply.body);
|
|
34
|
+
return mockEndpoint;
|
|
35
|
+
};
|
|
36
|
+
exports.handleMockUserStorageGet = handleMockUserStorageGet;
|
|
37
|
+
const handleMockUserStorageGetAllFeatureEntries = async (mockReply) => {
|
|
38
|
+
const reply = mockReply ?? {
|
|
39
|
+
status: 200,
|
|
40
|
+
body: [await (0, exports.MOCK_STORAGE_RESPONSE)()],
|
|
41
|
+
};
|
|
42
|
+
const mockEndpoint = (0, nock_1.default)(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)
|
|
43
|
+
.persist()
|
|
44
|
+
.get('')
|
|
45
|
+
.reply(reply.status, reply.body);
|
|
46
|
+
return mockEndpoint;
|
|
47
|
+
};
|
|
48
|
+
exports.handleMockUserStorageGetAllFeatureEntries = handleMockUserStorageGetAllFeatureEntries;
|
|
49
|
+
const handleMockUserStoragePut = (mockReply) => {
|
|
50
|
+
const reply = mockReply ?? { status: 204 };
|
|
51
|
+
const mockEndpoint = (0, nock_1.default)(MOCK_STORAGE_URL)
|
|
52
|
+
.persist()
|
|
53
|
+
.put(/.*/u)
|
|
54
|
+
.reply(reply.status);
|
|
55
|
+
return mockEndpoint;
|
|
56
|
+
};
|
|
57
|
+
exports.handleMockUserStoragePut = handleMockUserStoragePut;
|
|
58
|
+
//# sourceMappingURL=mock-userstorage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-userstorage.cjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,mEAAuC;AACvC,oCAA6B;AAC7B,sDAA8C;AAO9C,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,IAAA,0BAAW,EAClC,SAAG,CAAC,GAAG,EACP,oCAAoC,CACrC,CAAC;AACF,MAAM,oCAAoC,GAAG,IAAA,0BAAW,EACtD,SAAG,CAAC,GAAG,EACP,eAAe,CAChB,CAAC;AAEW,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,gFAAgF;AAChF,gEAAgE;AACnD,QAAA,uBAAuB,GAAG,EAAE,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;AAEK,MAAM,wBAAwB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAChE,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC","sourcesContent":["import nock from 'nock';\n\nimport encryption from '../encryption';\nimport { Env } from '../env';\nimport { STORAGE_URL } from '../user-storage';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\n// Example mock notifications storage entry (wildcard)\nconst MOCK_STORAGE_URL = STORAGE_URL(\n Env.DEV,\n 'notifications/notificationSettings',\n);\nconst MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.DEV,\n 'notifications',\n);\n\nexport const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MOCK_NOTIFICATIONS_DATA = { is_compact: false };\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () =>\n await encryption.encryptString(\n JSON.stringify(MOCK_NOTIFICATIONS_DATA),\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async () => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),\n});\n\nexport const handleMockUserStorageGet = async (mockReply?: MockReply) => {\n const reply = mockReply ?? {\n status: 200,\n body: await MOCK_STORAGE_RESPONSE(),\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .get(/.*/u)\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStorageGetAllFeatureEntries = async (\n mockReply?: MockReply,\n) => {\n const reply = mockReply ?? {\n status: 200,\n body: [await MOCK_STORAGE_RESPONSE()],\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)\n .persist()\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStoragePut = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .put(/.*/u)\n .reply(reply.status);\n\n return mockEndpoint;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import nock from
|
|
1
|
+
import nock from "nock";
|
|
2
2
|
type MockReply = {
|
|
3
3
|
status: nock.StatusCode;
|
|
4
4
|
body?: nock.Body;
|
|
@@ -16,4 +16,4 @@ export declare const handleMockUserStorageGet: (mockReply?: MockReply) => Promis
|
|
|
16
16
|
export declare const handleMockUserStorageGetAllFeatureEntries: (mockReply?: MockReply) => Promise<nock.Scope>;
|
|
17
17
|
export declare const handleMockUserStoragePut: (mockReply?: MockReply) => nock.Scope;
|
|
18
18
|
export {};
|
|
19
|
-
//# sourceMappingURL=mock-userstorage.d.
|
|
19
|
+
//# sourceMappingURL=mock-userstorage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-userstorage.d.cts","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAMxB,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAYF,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAGnD,eAAO,MAAM,uBAAuB;;CAAwB,CAAC;AAC7D,eAAO,MAAM,iCAAiC,uBAI3C,CAAC;AAEJ,eAAO,MAAM,qBAAqB;;;EAGhC,CAAC;AAEH,eAAO,MAAM,wBAAwB,eAAsB,SAAS,wBAWnE,CAAC;AAEF,eAAO,MAAM,yCAAyC,eACxC,SAAS,wBAYtB,CAAC;AAEF,eAAO,MAAM,wBAAwB,eAAgB,SAAS,eAQ7D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import nock from "nock";
|
|
2
|
+
type MockReply = {
|
|
3
|
+
status: nock.StatusCode;
|
|
4
|
+
body?: nock.Body;
|
|
5
|
+
};
|
|
6
|
+
export declare const MOCK_STORAGE_KEY = "MOCK_STORAGE_KEY";
|
|
7
|
+
export declare const MOCK_NOTIFICATIONS_DATA: {
|
|
8
|
+
is_compact: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const MOCK_NOTIFICATIONS_DATA_ENCRYPTED: () => Promise<string>;
|
|
11
|
+
export declare const MOCK_STORAGE_RESPONSE: () => Promise<{
|
|
12
|
+
HashedKey: string;
|
|
13
|
+
Data: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const handleMockUserStorageGet: (mockReply?: MockReply) => Promise<nock.Scope>;
|
|
16
|
+
export declare const handleMockUserStorageGetAllFeatureEntries: (mockReply?: MockReply) => Promise<nock.Scope>;
|
|
17
|
+
export declare const handleMockUserStoragePut: (mockReply?: MockReply) => nock.Scope;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=mock-userstorage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-userstorage.d.mts","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAMxB,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAYF,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAGnD,eAAO,MAAM,uBAAuB;;CAAwB,CAAC;AAC7D,eAAO,MAAM,iCAAiC,uBAI3C,CAAC;AAEJ,eAAO,MAAM,qBAAqB;;;EAGhC,CAAC;AAEH,eAAO,MAAM,wBAAwB,eAAsB,SAAS,wBAWnE,CAAC;AAEF,eAAO,MAAM,yCAAyC,eACxC,SAAS,wBAYtB,CAAC;AAEF,eAAO,MAAM,wBAAwB,eAAgB,SAAS,eAQ7D,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 encryption from "../encryption.mjs";
|
|
10
|
+
import { Env } from "../env.mjs";
|
|
11
|
+
import { STORAGE_URL } from "../user-storage.mjs";
|
|
12
|
+
// Example mock notifications storage entry (wildcard)
|
|
13
|
+
const MOCK_STORAGE_URL = STORAGE_URL(Env.DEV, 'notifications/notificationSettings');
|
|
14
|
+
const MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(Env.DEV, 'notifications');
|
|
15
|
+
export const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';
|
|
16
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18
|
+
export const MOCK_NOTIFICATIONS_DATA = { is_compact: false };
|
|
19
|
+
export const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () => await encryption.encryptString(JSON.stringify(MOCK_NOTIFICATIONS_DATA), MOCK_STORAGE_KEY);
|
|
20
|
+
export const MOCK_STORAGE_RESPONSE = async () => ({
|
|
21
|
+
HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',
|
|
22
|
+
Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),
|
|
23
|
+
});
|
|
24
|
+
export const handleMockUserStorageGet = async (mockReply) => {
|
|
25
|
+
const reply = mockReply ?? {
|
|
26
|
+
status: 200,
|
|
27
|
+
body: await MOCK_STORAGE_RESPONSE(),
|
|
28
|
+
};
|
|
29
|
+
const mockEndpoint = nock(MOCK_STORAGE_URL)
|
|
30
|
+
.persist()
|
|
31
|
+
.get(/.*/u)
|
|
32
|
+
.reply(reply.status, reply.body);
|
|
33
|
+
return mockEndpoint;
|
|
34
|
+
};
|
|
35
|
+
export const handleMockUserStorageGetAllFeatureEntries = async (mockReply) => {
|
|
36
|
+
const reply = mockReply ?? {
|
|
37
|
+
status: 200,
|
|
38
|
+
body: [await MOCK_STORAGE_RESPONSE()],
|
|
39
|
+
};
|
|
40
|
+
const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)
|
|
41
|
+
.persist()
|
|
42
|
+
.get('')
|
|
43
|
+
.reply(reply.status, reply.body);
|
|
44
|
+
return mockEndpoint;
|
|
45
|
+
};
|
|
46
|
+
export const handleMockUserStoragePut = (mockReply) => {
|
|
47
|
+
const reply = mockReply ?? { status: 204 };
|
|
48
|
+
const mockEndpoint = nock(MOCK_STORAGE_URL)
|
|
49
|
+
.persist()
|
|
50
|
+
.put(/.*/u)
|
|
51
|
+
.reply(reply.status);
|
|
52
|
+
return mockEndpoint;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=mock-userstorage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-userstorage.mjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,UAAU,0BAAsB;AACvC,OAAO,EAAE,GAAG,EAAE,mBAAe;AAC7B,OAAO,EAAE,WAAW,EAAE,4BAAwB;AAO9C,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,WAAW,CAClC,GAAG,C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AE;SACT,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAChE,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport encryption from '../encryption';\nimport { Env } from '../env';\nimport { STORAGE_URL } from '../user-storage';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\n// Example mock notifications storage entry (wildcard)\nconst MOCK_STORAGE_URL = STORAGE_URL(\n Env.DEV,\n 'notifications/notificationSettings',\n);\nconst MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.DEV,\n 'notifications',\n);\n\nexport const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MOCK_NOTIFICATIONS_DATA = { is_compact: false };\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () =>\n await encryption.encryptString(\n JSON.stringify(MOCK_NOTIFICATIONS_DATA),\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async () => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),\n});\n\nexport const handleMockUserStorageGet = async (mockReply?: MockReply) => {\n const reply = mockReply ?? {\n status: 200,\n body: await MOCK_STORAGE_RESPONSE(),\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .get(/.*/u)\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStorageGetAllFeatureEntries = async (\n mockReply?: MockReply,\n) => {\n const reply = mockReply ?? {\n status: 200,\n body: [await MOCK_STORAGE_RESPONSE()],\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)\n .persist()\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStoragePut = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .put(/.*/u)\n .reply(reply.status);\n\n return mockEndpoint;\n};\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrangeAuth = exports.typedMockFn = void 0;
|
|
4
|
+
const authentication_1 = require("../authentication.cjs");
|
|
5
|
+
const types_1 = require("../authentication-jwt-bearer/types.cjs");
|
|
6
|
+
const env_1 = require("../env.cjs");
|
|
7
|
+
// Utility for mocking, the generics will constrain values
|
|
8
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention
|
|
10
|
+
const typedMockFn = () => jest.fn();
|
|
11
|
+
exports.typedMockFn = typedMockFn;
|
|
12
|
+
const mockAuthOptions = () => {
|
|
13
|
+
const mockGetLoginResponse = (0, exports.typedMockFn)();
|
|
14
|
+
const mockSetLoginResponse = (0, exports.typedMockFn)();
|
|
15
|
+
const mockGetIdentifier = (0, exports.typedMockFn)();
|
|
16
|
+
const mockSignMessage = (0, exports.typedMockFn)();
|
|
17
|
+
return {
|
|
18
|
+
mockGetLoginResponse,
|
|
19
|
+
mockSetLoginResponse,
|
|
20
|
+
mockGetIdentifier,
|
|
21
|
+
mockSignMessage,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Mock Utility - Arrange Auth
|
|
26
|
+
*
|
|
27
|
+
* @param type - choose SIWE or SRP Auth instance
|
|
28
|
+
* @param mockPublicKey - provide the mock public key
|
|
29
|
+
* @param authOptionsOverride - overrides
|
|
30
|
+
* @param authOptionsOverride.signing - override auth signing
|
|
31
|
+
* @returns Auth instance
|
|
32
|
+
*/
|
|
33
|
+
function arrangeAuth(type, mockPublicKey, authOptionsOverride) {
|
|
34
|
+
const authOptionsMock = mockAuthOptions();
|
|
35
|
+
authOptionsMock.mockGetLoginResponse.mockResolvedValue(null);
|
|
36
|
+
authOptionsMock.mockSetLoginResponse.mockResolvedValue();
|
|
37
|
+
authOptionsMock.mockGetIdentifier.mockResolvedValue(mockPublicKey);
|
|
38
|
+
authOptionsMock.mockSignMessage.mockResolvedValue(type === 'SRP' ? 'MOCK_SRP_SIGNATURE' : 'MOCK_SIWE_SIGNATURE');
|
|
39
|
+
if (type === 'SRP') {
|
|
40
|
+
const auth = new authentication_1.JwtBearerAuth({
|
|
41
|
+
env: env_1.Env.DEV,
|
|
42
|
+
platform: env_1.Platform.EXTENSION,
|
|
43
|
+
type: types_1.AuthType.SRP,
|
|
44
|
+
}, {
|
|
45
|
+
storage: {
|
|
46
|
+
getLoginResponse: authOptionsMock.mockGetLoginResponse,
|
|
47
|
+
setLoginResponse: authOptionsMock.mockSetLoginResponse,
|
|
48
|
+
},
|
|
49
|
+
signing: authOptionsOverride
|
|
50
|
+
? authOptionsOverride.signing
|
|
51
|
+
: {
|
|
52
|
+
getIdentifier: authOptionsMock.mockGetIdentifier,
|
|
53
|
+
signMessage: authOptionsMock.mockSignMessage,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return { auth, ...authOptionsMock };
|
|
57
|
+
}
|
|
58
|
+
if (type === 'SiWE') {
|
|
59
|
+
const auth = new authentication_1.JwtBearerAuth({
|
|
60
|
+
env: env_1.Env.DEV,
|
|
61
|
+
platform: env_1.Platform.EXTENSION,
|
|
62
|
+
type: types_1.AuthType.SiWE,
|
|
63
|
+
}, {
|
|
64
|
+
storage: {
|
|
65
|
+
getLoginResponse: authOptionsMock.mockGetLoginResponse,
|
|
66
|
+
setLoginResponse: authOptionsMock.mockSetLoginResponse,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return { auth, ...authOptionsMock };
|
|
70
|
+
}
|
|
71
|
+
throw new Error('Unable to arrange auth mock for invalid auth type');
|
|
72
|
+
}
|
|
73
|
+
exports.arrangeAuth = arrangeAuth;
|
|
74
|
+
//# sourceMappingURL=test-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.cjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/test-utils.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAKlD,kEAA8D;AAC9D,oCAAuC;AAMvC,0DAA0D;AAC1D,gFAAgF;AAChF,oGAAoG;AAC7F,MAAM,WAAW,GAAG,GAAuC,EAAE,CAClE,IAAI,CAAC,EAAE,EAAkC,CAAC;AAD/B,QAAA,WAAW,eACoB;AAE5C,MAAM,eAAe,GAAG,GAAG,EAAE;IAC3B,MAAM,oBAAoB,GACxB,IAAA,mBAAW,GAA0C,CAAC;IAExD,MAAM,oBAAoB,GACxB,IAAA,mBAAW,GAA0C,CAAC;IAExD,MAAM,iBAAiB,GAAG,IAAA,mBAAW,GAAuC,CAAC;IAE7E,MAAM,eAAe,GAAG,IAAA,mBAAW,GAAqC,CAAC;IAEzE,OAAO;QACL,oBAAoB;QACpB,oBAAoB;QACpB,iBAAiB;QACjB,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,WAAW,CACzB,IAAmB,EACnB,aAAqB,EACrB,mBAEC;IAED,MAAM,eAAe,GAAG,eAAe,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,EAAE,GAAG,eAAe,EAAE,CAAC;KACrC;IAED,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACvE,CAAC;AA1DD,kCA0DC","sourcesContent":["import { JwtBearerAuth } from '../authentication';\nimport type {\n AuthSigningOptions,\n AuthStorageOptions,\n} from '../authentication-jwt-bearer/types';\nimport { AuthType } from '../authentication-jwt-bearer/types';\nimport { Env, Platform } from '../env';\n\n// Alias mocking variables with ANY to test runtime safety.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type MockVariable = any;\n\n// Utility for mocking, the generics will constrain values\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention\nexport const typedMockFn = <Fn extends (...args: any[]) => any>() =>\n jest.fn<ReturnType<Fn>, Parameters<Fn>>();\n\nconst mockAuthOptions = () => {\n const mockGetLoginResponse =\n typedMockFn<AuthStorageOptions['getLoginResponse']>();\n\n const mockSetLoginResponse =\n typedMockFn<AuthStorageOptions['setLoginResponse']>();\n\n const mockGetIdentifier = typedMockFn<AuthSigningOptions['getIdentifier']>();\n\n const mockSignMessage = typedMockFn<AuthSigningOptions['signMessage']>();\n\n return {\n mockGetLoginResponse,\n mockSetLoginResponse,\n mockGetIdentifier,\n mockSignMessage,\n };\n};\n\n/**\n * Mock Utility - Arrange Auth\n *\n * @param type - choose SIWE or SRP Auth instance\n * @param mockPublicKey - provide the mock public key\n * @param authOptionsOverride - overrides\n * @param authOptionsOverride.signing - override auth signing\n * @returns Auth instance\n */\nexport function arrangeAuth(\n type: `${AuthType}`,\n mockPublicKey: string,\n authOptionsOverride?: {\n signing?: AuthSigningOptions;\n },\n) {\n const authOptionsMock = mockAuthOptions();\n authOptionsMock.mockGetLoginResponse.mockResolvedValue(null);\n authOptionsMock.mockSetLoginResponse.mockResolvedValue();\n authOptionsMock.mockGetIdentifier.mockResolvedValue(mockPublicKey);\n authOptionsMock.mockSignMessage.mockResolvedValue(\n type === 'SRP' ? 'MOCK_SRP_SIGNATURE' : 'MOCK_SIWE_SIGNATURE',\n );\n\n if (type === 'SRP') {\n const auth = new JwtBearerAuth(\n {\n env: Env.DEV,\n platform: Platform.EXTENSION,\n type: AuthType.SRP,\n },\n {\n storage: {\n getLoginResponse: authOptionsMock.mockGetLoginResponse,\n setLoginResponse: authOptionsMock.mockSetLoginResponse,\n },\n signing: authOptionsOverride\n ? authOptionsOverride.signing\n : {\n getIdentifier: authOptionsMock.mockGetIdentifier,\n signMessage: authOptionsMock.mockSignMessage,\n },\n },\n );\n\n return { auth, ...authOptionsMock };\n }\n\n if (type === 'SiWE') {\n const auth = new JwtBearerAuth(\n {\n env: Env.DEV,\n platform: Platform.EXTENSION,\n type: AuthType.SiWE,\n },\n {\n storage: {\n getLoginResponse: authOptionsMock.mockGetLoginResponse,\n setLoginResponse: authOptionsMock.mockSetLoginResponse,\n },\n },\n );\n\n return { auth, ...authOptionsMock };\n }\n\n throw new Error('Unable to arrange auth mock for invalid auth type');\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
import { JwtBearerAuth } from
|
|
3
|
-
import type { AuthSigningOptions } from
|
|
4
|
-
import { AuthType } from
|
|
2
|
+
import { JwtBearerAuth } from "../authentication.cjs";
|
|
3
|
+
import type { AuthSigningOptions } from "../authentication-jwt-bearer/types.cjs";
|
|
4
|
+
import { AuthType } from "../authentication-jwt-bearer/types.cjs";
|
|
5
5
|
export type MockVariable = any;
|
|
6
6
|
export declare const typedMockFn: <Fn extends (...args: any[]) => any>() => jest.Mock<ReturnType<Fn>, Parameters<Fn>>;
|
|
7
7
|
/**
|
|
@@ -16,10 +16,10 @@ export declare const typedMockFn: <Fn extends (...args: any[]) => any>() => jest
|
|
|
16
16
|
export declare function arrangeAuth(type: `${AuthType}`, mockPublicKey: string, authOptionsOverride?: {
|
|
17
17
|
signing?: AuthSigningOptions;
|
|
18
18
|
}): {
|
|
19
|
-
mockGetLoginResponse: jest.Mock<Promise<import("../authentication").LoginResponse | null>, []>;
|
|
20
|
-
mockSetLoginResponse: jest.Mock<Promise<void>, [val: import("../authentication").LoginResponse]>;
|
|
19
|
+
mockGetLoginResponse: jest.Mock<Promise<import("../authentication.cjs").LoginResponse | null>, []>;
|
|
20
|
+
mockSetLoginResponse: jest.Mock<Promise<void>, [val: import("../authentication.cjs").LoginResponse]>;
|
|
21
21
|
mockGetIdentifier: jest.Mock<Promise<string>, []>;
|
|
22
22
|
mockSignMessage: jest.Mock<Promise<string>, [message: string]>;
|
|
23
23
|
auth: JwtBearerAuth;
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=test-utils.d.
|
|
25
|
+
//# sourceMappingURL=test-utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.cts","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAClD,OAAO,KAAK,EACV,kBAAkB,EAEnB,+CAA2C;AAC5C,OAAO,EAAE,QAAQ,EAAE,+CAA2C;AAK9D,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC;AAK/B,eAAO,MAAM,WAAW,wBAAyB,GAAG,EAAE,KAAK,GAAG,gDACnB,CAAC;AAqB5C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,GAAG,QAAQ,EAAE,EACnB,aAAa,EAAE,MAAM,EACrB,mBAAmB,CAAC,EAAE;IACpB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;;;;;;EAqDF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { JwtBearerAuth } from "../authentication.mjs";
|
|
3
|
+
import type { AuthSigningOptions } from "../authentication-jwt-bearer/types.mjs";
|
|
4
|
+
import { AuthType } from "../authentication-jwt-bearer/types.mjs";
|
|
5
|
+
export type MockVariable = any;
|
|
6
|
+
export declare const typedMockFn: <Fn extends (...args: any[]) => any>() => jest.Mock<ReturnType<Fn>, Parameters<Fn>>;
|
|
7
|
+
/**
|
|
8
|
+
* Mock Utility - Arrange Auth
|
|
9
|
+
*
|
|
10
|
+
* @param type - choose SIWE or SRP Auth instance
|
|
11
|
+
* @param mockPublicKey - provide the mock public key
|
|
12
|
+
* @param authOptionsOverride - overrides
|
|
13
|
+
* @param authOptionsOverride.signing - override auth signing
|
|
14
|
+
* @returns Auth instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function arrangeAuth(type: `${AuthType}`, mockPublicKey: string, authOptionsOverride?: {
|
|
17
|
+
signing?: AuthSigningOptions;
|
|
18
|
+
}): {
|
|
19
|
+
mockGetLoginResponse: jest.Mock<Promise<import("../authentication.mjs").LoginResponse | null>, []>;
|
|
20
|
+
mockSetLoginResponse: jest.Mock<Promise<void>, [val: import("../authentication.mjs").LoginResponse]>;
|
|
21
|
+
mockGetIdentifier: jest.Mock<Promise<string>, []>;
|
|
22
|
+
mockSignMessage: jest.Mock<Promise<string>, [message: string]>;
|
|
23
|
+
auth: JwtBearerAuth;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=test-utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.mts","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/test-utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAClD,OAAO,KAAK,EACV,kBAAkB,EAEnB,+CAA2C;AAC5C,OAAO,EAAE,QAAQ,EAAE,+CAA2C;AAK9D,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC;AAK/B,eAAO,MAAM,WAAW,wBAAyB,GAAG,EAAE,KAAK,GAAG,gDACnB,CAAC;AAqB5C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,GAAG,QAAQ,EAAE,EACnB,aAAa,EAAE,MAAM,EACrB,mBAAmB,CAAC,EAAE;IACpB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;;;;;;EAqDF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { JwtBearerAuth } from "../authentication.mjs";
|
|
2
|
+
import { AuthType } from "../authentication-jwt-bearer/types.mjs";
|
|
3
|
+
import { Env, Platform } from "../env.mjs";
|
|
4
|
+
// Utility for mocking, the generics will constrain values
|
|
5
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention
|
|
7
|
+
export const typedMockFn = () => jest.fn();
|
|
8
|
+
const mockAuthOptions = () => {
|
|
9
|
+
const mockGetLoginResponse = typedMockFn();
|
|
10
|
+
const mockSetLoginResponse = typedMockFn();
|
|
11
|
+
const mockGetIdentifier = typedMockFn();
|
|
12
|
+
const mockSignMessage = typedMockFn();
|
|
13
|
+
return {
|
|
14
|
+
mockGetLoginResponse,
|
|
15
|
+
mockSetLoginResponse,
|
|
16
|
+
mockGetIdentifier,
|
|
17
|
+
mockSignMessage,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Mock Utility - Arrange Auth
|
|
22
|
+
*
|
|
23
|
+
* @param type - choose SIWE or SRP Auth instance
|
|
24
|
+
* @param mockPublicKey - provide the mock public key
|
|
25
|
+
* @param authOptionsOverride - overrides
|
|
26
|
+
* @param authOptionsOverride.signing - override auth signing
|
|
27
|
+
* @returns Auth instance
|
|
28
|
+
*/
|
|
29
|
+
export function arrangeAuth(type, mockPublicKey, authOptionsOverride) {
|
|
30
|
+
const authOptionsMock = mockAuthOptions();
|
|
31
|
+
authOptionsMock.mockGetLoginResponse.mockResolvedValue(null);
|
|
32
|
+
authOptionsMock.mockSetLoginResponse.mockResolvedValue();
|
|
33
|
+
authOptionsMock.mockGetIdentifier.mockResolvedValue(mockPublicKey);
|
|
34
|
+
authOptionsMock.mockSignMessage.mockResolvedValue(type === 'SRP' ? 'MOCK_SRP_SIGNATURE' : 'MOCK_SIWE_SIGNATURE');
|
|
35
|
+
if (type === 'SRP') {
|
|
36
|
+
const auth = new JwtBearerAuth({
|
|
37
|
+
env: Env.DEV,
|
|
38
|
+
platform: Platform.EXTENSION,
|
|
39
|
+
type: AuthType.SRP,
|
|
40
|
+
}, {
|
|
41
|
+
storage: {
|
|
42
|
+
getLoginResponse: authOptionsMock.mockGetLoginResponse,
|
|
43
|
+
setLoginResponse: authOptionsMock.mockSetLoginResponse,
|
|
44
|
+
},
|
|
45
|
+
signing: authOptionsOverride
|
|
46
|
+
? authOptionsOverride.signing
|
|
47
|
+
: {
|
|
48
|
+
getIdentifier: authOptionsMock.mockGetIdentifier,
|
|
49
|
+
signMessage: authOptionsMock.mockSignMessage,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return { auth, ...authOptionsMock };
|
|
53
|
+
}
|
|
54
|
+
if (type === 'SiWE') {
|
|
55
|
+
const auth = new JwtBearerAuth({
|
|
56
|
+
env: Env.DEV,
|
|
57
|
+
platform: Platform.EXTENSION,
|
|
58
|
+
type: AuthType.SiWE,
|
|
59
|
+
}, {
|
|
60
|
+
storage: {
|
|
61
|
+
getLoginResponse: authOptionsMock.mockGetLoginResponse,
|
|
62
|
+
setLoginResponse: authOptionsMock.mockSetLoginResponse,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
return { auth, ...authOptionsMock };
|
|
66
|
+
}
|
|
67
|
+
throw new Error('Unable to arrange auth mock for invalid auth type');
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=test-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAKlD,OAAO,EAAE,QAAQ,EAAE,+CAA2C;AAC9D,OAAO,EA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;YACD,OAAO,EAAE,mBAAmB;gBAC1B,CAAC,CAAC,mBAAmB,CAAC,OAAO;gBAC7B,CAAC,CAAC;oBACE,aAAa,EAAE,eAAe,CAAC,iBAAiB;oBAChD,WAAW,EAAE,eAAe,CAAC,eAAe;iBAC7C;SACN,CACF,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,GAAG,eAAe,EAAE,CAAC;KACrC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,MAAM,IAAI,GAAG,IAAI,aAAa,CAC5B;YACE,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,QAAQ,EAAE,QAAQ,CAAC,SAAS;YAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,EACD;YACE,OAAO,EAAE;gBACP,gBAAgB,EAAE,eAAe,CAAC,oBAAoB;gBACtD,gBAAgB,EAAE,eAAe,CAAC,oBAAoB;aACvD;SACF,CACF,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,GAAG,eAAe,EAAE,CAAC;KACrC;IAED,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { JwtBearerAuth } from '../authentication';\nimport type {\n AuthSigningOptions,\n AuthStorageOptions,\n} from '../authentication-jwt-bearer/types';\nimport { AuthType } from '../authentication-jwt-bearer/types';\nimport { Env, Platform } from '../env';\n\n// Alias mocking variables with ANY to test runtime safety.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type MockVariable = any;\n\n// Utility for mocking, the generics will constrain values\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention\nexport const typedMockFn = <Fn extends (...args: any[]) => any>() =>\n jest.fn<ReturnType<Fn>, Parameters<Fn>>();\n\nconst mockAuthOptions = () => {\n const mockGetLoginResponse =\n typedMockFn<AuthStorageOptions['getLoginResponse']>();\n\n const mockSetLoginResponse =\n typedMockFn<AuthStorageOptions['setLoginResponse']>();\n\n const mockGetIdentifier = typedMockFn<AuthSigningOptions['getIdentifier']>();\n\n const mockSignMessage = typedMockFn<AuthSigningOptions['signMessage']>();\n\n return {\n mockGetLoginResponse,\n mockSetLoginResponse,\n mockGetIdentifier,\n mockSignMessage,\n };\n};\n\n/**\n * Mock Utility - Arrange Auth\n *\n * @param type - choose SIWE or SRP Auth instance\n * @param mockPublicKey - provide the mock public key\n * @param authOptionsOverride - overrides\n * @param authOptionsOverride.signing - override auth signing\n * @returns Auth instance\n */\nexport function arrangeAuth(\n type: `${AuthType}`,\n mockPublicKey: string,\n authOptionsOverride?: {\n signing?: AuthSigningOptions;\n },\n) {\n const authOptionsMock = mockAuthOptions();\n authOptionsMock.mockGetLoginResponse.mockResolvedValue(null);\n authOptionsMock.mockSetLoginResponse.mockResolvedValue();\n authOptionsMock.mockGetIdentifier.mockResolvedValue(mockPublicKey);\n authOptionsMock.mockSignMessage.mockResolvedValue(\n type === 'SRP' ? 'MOCK_SRP_SIGNATURE' : 'MOCK_SIWE_SIGNATURE',\n );\n\n if (type === 'SRP') {\n const auth = new JwtBearerAuth(\n {\n env: Env.DEV,\n platform: Platform.EXTENSION,\n type: AuthType.SRP,\n },\n {\n storage: {\n getLoginResponse: authOptionsMock.mockGetLoginResponse,\n setLoginResponse: authOptionsMock.mockSetLoginResponse,\n },\n signing: authOptionsOverride\n ? authOptionsOverride.signing\n : {\n getIdentifier: authOptionsMock.mockGetIdentifier,\n signMessage: authOptionsMock.mockSignMessage,\n },\n },\n );\n\n return { auth, ...authOptionsMock };\n }\n\n if (type === 'SiWE') {\n const auth = new JwtBearerAuth(\n {\n env: Env.DEV,\n platform: Platform.EXTENSION,\n type: AuthType.SiWE,\n },\n {\n storage: {\n getLoginResponse: authOptionsMock.mockGetLoginResponse,\n setLoginResponse: authOptionsMock.mockSetLoginResponse,\n },\n },\n );\n\n return { auth, ...authOptionsMock };\n }\n\n throw new Error('Unable to arrange auth mock for invalid auth type');\n}\n"]}
|