@metamask/profile-sync-controller 0.5.0 → 0.6.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 +38 -1
- 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 +111 -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} +2 -2
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +17 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +105 -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 +129 -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 +107 -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 +89 -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 -2
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +40 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +80 -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 +20 -14
- 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
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export var AuthType;
|
|
2
|
+
(function (AuthType) {
|
|
3
|
+
/* sign in using a private key derived from your secret recovery phrase (SRP).
|
|
4
|
+
Uses message signing snap to perform this operation */
|
|
5
|
+
AuthType["SRP"] = "SRP";
|
|
6
|
+
/* sign in with Ethereum */
|
|
7
|
+
AuthType["SiWE"] = "SiWE";
|
|
8
|
+
})(AuthType || (AuthType = {}));
|
|
8
9
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB;+DAC2D;IAC3D,uBAAW,CAAA;IAEX,2BAA2B;IAC3B,yBAAa,CAAA;AACf,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB","sourcesContent":["import type { Env, Platform } from '../env';\n\nexport enum AuthType {\n /* sign in using a private key derived from your secret recovery phrase (SRP). \n Uses message signing snap to perform this operation */\n SRP = 'SRP',\n\n /* sign in with Ethereum */\n SiWE = 'SiWE',\n}\n\nexport type AuthConfig = {\n env: Env;\n platform: Platform;\n type: AuthType;\n};\n\nexport type AccessToken = {\n /**\n * The JWT Access Token\n */\n accessToken: string;\n /**\n * Expiration in seconds\n */\n expiresIn: number;\n /**\n * Date in milliseconds\n */\n obtainedAt: number;\n};\n\nexport type UserProfile = {\n /**\n * The \"Identifier\" used to log in with.\n */\n identifierId: string;\n /**\n * The Unique profile for a logged in user. A Profile can be logged in via multiple Identifiers\n */\n profileId: string;\n /**\n * Server MetaMetrics ID. Allows grouping of user events cross platform.\n */\n metaMetricsId: string;\n};\n\nexport type LoginResponse = {\n token: AccessToken;\n profile: UserProfile;\n};\n\nexport type IBaseAuth = {\n getAccessToken: () => Promise<string>;\n getUserProfile: () => Promise<UserProfile>;\n getIdentifier: () => Promise<string>;\n signMessage: (message: string) => Promise<string>;\n};\n\nexport type AuthStorageOptions = {\n getLoginResponse: () => Promise<LoginResponse | null>;\n setLoginResponse: (val: LoginResponse) => Promise<void>;\n};\n\nexport type AuthSigningOptions = {\n signMessage: (message: string) => Promise<string>;\n getIdentifier: () => Promise<string>;\n};\n\nexport type ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport type Pair = {\n identifier: string;\n encryptedStorageKey: string;\n identifierType: 'SIWE' | 'SRP';\n signMessage: (message: string) => Promise<string>;\n};\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
17
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
20
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
21
|
+
};
|
|
22
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
23
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
24
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
25
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
26
|
+
};
|
|
27
|
+
var _JwtBearerAuth_instances, _JwtBearerAuth_type, _JwtBearerAuth_env, _JwtBearerAuth_sdk, _JwtBearerAuth_assertSIWE;
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SRPJwtBearerAuth = exports.SIWEJwtBearerAuth = exports.JwtBearerAuth = void 0;
|
|
30
|
+
const flow_siwe_1 = require("./authentication-jwt-bearer/flow-siwe.cjs");
|
|
31
|
+
const flow_srp_1 = require("./authentication-jwt-bearer/flow-srp.cjs");
|
|
32
|
+
const services_1 = require("./authentication-jwt-bearer/services.cjs");
|
|
33
|
+
const types_1 = require("./authentication-jwt-bearer/types.cjs");
|
|
34
|
+
const errors_1 = require("./errors.cjs");
|
|
35
|
+
const eip_6963_metamask_provider_1 = require("./utils/eip-6963-metamask-provider.cjs");
|
|
36
|
+
const messaging_signing_snap_requests_1 = require("./utils/messaging-signing-snap-requests.cjs");
|
|
37
|
+
class JwtBearerAuth {
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
_JwtBearerAuth_instances.add(this);
|
|
40
|
+
_JwtBearerAuth_type.set(this, void 0);
|
|
41
|
+
_JwtBearerAuth_env.set(this, void 0);
|
|
42
|
+
_JwtBearerAuth_sdk.set(this, void 0);
|
|
43
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_type, args[0].type, "f");
|
|
44
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_env, args[0].env, "f");
|
|
45
|
+
if (args[0].type === types_1.AuthType.SRP) {
|
|
46
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_sdk, new flow_srp_1.SRPJwtBearerAuth(args[0], args[1]), "f");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (args[0].type === types_1.AuthType.SiWE) {
|
|
50
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_sdk, new flow_siwe_1.SIWEJwtBearerAuth(args[0], args[1]), "f");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
throw new errors_1.UnsupportedAuthTypeError('unsupported auth type');
|
|
54
|
+
}
|
|
55
|
+
async getAccessToken() {
|
|
56
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getAccessToken();
|
|
57
|
+
}
|
|
58
|
+
async connectSnap() {
|
|
59
|
+
const provider = await (0, eip_6963_metamask_provider_1.getMetaMaskProviderEIP6963)();
|
|
60
|
+
if (!provider) {
|
|
61
|
+
throw new Error('failed to get MetaMaskProviderEIP6963 provider');
|
|
62
|
+
}
|
|
63
|
+
const res = await (0, messaging_signing_snap_requests_1.connectSnap)(provider);
|
|
64
|
+
return res;
|
|
65
|
+
}
|
|
66
|
+
async isSnapConnected() {
|
|
67
|
+
const provider = await (0, eip_6963_metamask_provider_1.getMetaMaskProviderEIP6963)();
|
|
68
|
+
if (!provider) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const isConnected = await (0, messaging_signing_snap_requests_1.isSnapConnected)(provider);
|
|
72
|
+
return isConnected;
|
|
73
|
+
}
|
|
74
|
+
async getUserProfile() {
|
|
75
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getUserProfile();
|
|
76
|
+
}
|
|
77
|
+
async getIdentifier() {
|
|
78
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getIdentifier();
|
|
79
|
+
}
|
|
80
|
+
async signMessage(message) {
|
|
81
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").signMessage(message);
|
|
82
|
+
}
|
|
83
|
+
async pairIdentifiers(pairing) {
|
|
84
|
+
const profile = await this.getUserProfile();
|
|
85
|
+
const n = await (0, services_1.getNonce)(profile.profileId, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
|
|
86
|
+
const logins = await Promise.all(pairing.map(async (p) => {
|
|
87
|
+
try {
|
|
88
|
+
const raw = `metamask:${n.nonce}:${p.identifier}`;
|
|
89
|
+
const sig = await p.signMessage(raw);
|
|
90
|
+
return {
|
|
91
|
+
signature: sig,
|
|
92
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
94
|
+
raw_message: raw,
|
|
95
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
97
|
+
encrypted_storage_key: p.encryptedStorageKey,
|
|
98
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
100
|
+
identifier_type: p.identifierType,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
/* istanbul ignore next */
|
|
105
|
+
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
106
|
+
throw new errors_1.PairError(`failed to sign pairing message: ${errorMessage}`);
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
const accessToken = await this.getAccessToken();
|
|
110
|
+
await (0, services_1.pairIdentifiers)(n.nonce, logins, accessToken, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
|
|
111
|
+
}
|
|
112
|
+
prepare(signer) {
|
|
113
|
+
__classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSIWE).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
|
|
114
|
+
__classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").prepare(signer);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.JwtBearerAuth = JwtBearerAuth;
|
|
118
|
+
_JwtBearerAuth_type = new WeakMap(), _JwtBearerAuth_env = new WeakMap(), _JwtBearerAuth_sdk = new WeakMap(), _JwtBearerAuth_instances = new WeakSet(), _JwtBearerAuth_assertSIWE = function _JwtBearerAuth_assertSIWE(type, sdk) {
|
|
119
|
+
if (type === types_1.AuthType.SiWE) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
throw new errors_1.UnsupportedAuthTypeError('This method is only available via SIWE auth type');
|
|
123
|
+
};
|
|
124
|
+
var flow_siwe_2 = require("./authentication-jwt-bearer/flow-siwe.cjs");
|
|
125
|
+
Object.defineProperty(exports, "SIWEJwtBearerAuth", { enumerable: true, get: function () { return flow_siwe_2.SIWEJwtBearerAuth; } });
|
|
126
|
+
var flow_srp_2 = require("./authentication-jwt-bearer/flow-srp.cjs");
|
|
127
|
+
Object.defineProperty(exports, "SRPJwtBearerAuth", { enumerable: true, get: function () { return flow_srp_2.SRPJwtBearerAuth; } });
|
|
128
|
+
__exportStar(require("./authentication-jwt-bearer/types.cjs"), exports);
|
|
129
|
+
//# sourceMappingURL=authentication.cjs.map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AgE;oBAChE,WAAW,EAAE,GAAG;oBAChB,gFAAgF;oBAChF,gEAAgE;oBAChE,qBAAqB,EAAE,CAAC,CAAC,mBAAmB;oBAC5C,gFAAgF;oBAChF,gEAAgE;oBAChE,eAAe,EAAE,CAAC,CAAC,cAAc;iBAClC,CAAC;aACH;YAAC,OAAO,CAAC,EAAE;gBACV,0BAA0B;gBAC1B,MAAM,YAAY,GAChB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3D,MAAM,IAAI,kBAAS,CACjB,mCAAmC,YAAY,EAAE,CAClD,CAAC;aACH;QACH,CAAC,CAAC,CACH,CAAC;QAEF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,MAAM,IAAA,0BAAe,EAAC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,uBAAA,IAAI,0BAAK,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,CAAC,MAKP;QACC,uBAAA,IAAI,2DAAY,MAAhB,IAAI,EAAa,uBAAA,IAAI,2BAAM,EAAE,uBAAA,IAAI,0BAAK,CAAC,CAAC;QACxC,uBAAA,IAAI,0BAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CAcF;AArHD,sCAqHC;sNAXG,IAAc,EACd,GAAyC;IAEzC,IAAI,IAAI,KAAK,gBAAQ,CAAC,IAAI,EAAE;QAC1B,OAAO;KACR;IAED,MAAM,IAAI,iCAAwB,CAChC,kDAAkD,CACnD,CAAC;AACJ,CAAC;AAGH,uEAA0E;AAAjE,8GAAA,iBAAiB,OAAA;AAC1B,qEAAwE;AAA/D,4GAAA,gBAAgB,OAAA;AACzB,wEAAkD","sourcesContent":["import { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nimport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nimport {\n getNonce,\n pairIdentifiers,\n} from './authentication-jwt-bearer/services';\nimport type { UserProfile, Pair } from './authentication-jwt-bearer/types';\nimport { AuthType } from './authentication-jwt-bearer/types';\nimport type { Env } from './env';\nimport { PairError, UnsupportedAuthTypeError } from './errors';\nimport { getMetaMaskProviderEIP6963 } from './utils/eip-6963-metamask-provider';\nimport {\n connectSnap,\n isSnapConnected,\n} from './utils/messaging-signing-snap-requests';\n\n// Computing the Classes, so we only get back the public methods for the interface.\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype Compute<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\ntype SIWEInterface = Compute<SIWEJwtBearerAuth>;\ntype SRPInterface = Compute<SRPJwtBearerAuth>;\n\ntype SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;\ntype SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;\ntype JwtBearerAuthParams = SiweParams | SRPParams;\n\nexport class JwtBearerAuth implements SIWEInterface, SRPInterface {\n #type: AuthType;\n\n #env: Env;\n\n #sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth;\n\n constructor(...args: JwtBearerAuthParams) {\n this.#type = args[0].type;\n this.#env = args[0].env;\n\n if (args[0].type === AuthType.SRP) {\n this.#sdk = new SRPJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n if (args[0].type === AuthType.SiWE) {\n this.#sdk = new SIWEJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n throw new UnsupportedAuthTypeError('unsupported auth type');\n }\n\n async getAccessToken(): Promise<string> {\n return await this.#sdk.getAccessToken();\n }\n\n async connectSnap(): Promise<string> {\n const provider = await getMetaMaskProviderEIP6963();\n if (!provider) {\n throw new Error('failed to get MetaMaskProviderEIP6963 provider');\n }\n const res = await connectSnap(provider);\n return res;\n }\n\n async isSnapConnected(): Promise<boolean> {\n const provider = await getMetaMaskProviderEIP6963();\n if (!provider) {\n return false;\n }\n\n const isConnected = await isSnapConnected(provider);\n return isConnected;\n }\n\n async getUserProfile(): Promise<UserProfile> {\n return await this.#sdk.getUserProfile();\n }\n\n async getIdentifier(): Promise<string> {\n return await this.#sdk.getIdentifier();\n }\n\n async signMessage(message: string): Promise<string> {\n return await this.#sdk.signMessage(message);\n }\n\n async pairIdentifiers(pairing: Pair[]): Promise<void> {\n const profile = await this.getUserProfile();\n const n = await getNonce(profile.profileId, this.#env);\n\n const logins = await Promise.all(\n pairing.map(async (p) => {\n try {\n const raw = `metamask:${n.nonce}:${p.identifier}`;\n const sig = await p.signMessage(raw);\n return {\n signature: sig,\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 raw_message: raw,\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: p.encryptedStorageKey,\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: p.identifierType,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(\n `failed to sign pairing message: ${errorMessage}`,\n );\n }\n }),\n );\n\n const accessToken = await this.getAccessToken();\n await pairIdentifiers(n.nonce, logins, accessToken, this.#env);\n }\n\n prepare(signer: {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n }): void {\n this.#assertSIWE(this.#type, this.#sdk);\n this.#sdk.prepare(signer);\n }\n\n #assertSIWE(\n type: AuthType,\n sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts sdk is SIWEJwtBearerAuth {\n if (type === AuthType.SiWE) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SIWE auth type',\n );\n }\n}\n\nexport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nexport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nexport * from './authentication-jwt-bearer/types';\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SIWEJwtBearerAuth } from
|
|
2
|
-
import { SRPJwtBearerAuth } from
|
|
3
|
-
import type { UserProfile, Pair } from
|
|
1
|
+
import { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.cjs";
|
|
2
|
+
import { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.cjs";
|
|
3
|
+
import type { UserProfile, Pair } from "./authentication-jwt-bearer/types.cjs";
|
|
4
4
|
type Compute<T> = T extends infer U ? {
|
|
5
5
|
[K in keyof U]: U[K];
|
|
6
6
|
} : never;
|
|
@@ -26,7 +26,7 @@ export declare class JwtBearerAuth implements SIWEInterface, SRPInterface {
|
|
|
26
26
|
domain: string;
|
|
27
27
|
}): void;
|
|
28
28
|
}
|
|
29
|
-
export { SIWEJwtBearerAuth } from
|
|
30
|
-
export { SRPJwtBearerAuth } from
|
|
31
|
-
export * from
|
|
32
|
-
//# sourceMappingURL=authentication.d.
|
|
29
|
+
export { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.cjs";
|
|
30
|
+
export { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.cjs";
|
|
31
|
+
export * from "./authentication-jwt-bearer/types.cjs";
|
|
32
|
+
//# sourceMappingURL=authentication.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.d.cts","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AAKxE,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,8CAA0C;AAa3E,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CA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/flow-srp.mjs";
|
|
3
|
+
import type { UserProfile, Pair } from "./authentication-jwt-bearer/types.mjs";
|
|
4
|
+
type Compute<T> = T extends infer U ? {
|
|
5
|
+
[K in keyof U]: U[K];
|
|
6
|
+
} : never;
|
|
7
|
+
type SIWEInterface = Compute<SIWEJwtBearerAuth>;
|
|
8
|
+
type SRPInterface = Compute<SRPJwtBearerAuth>;
|
|
9
|
+
type SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;
|
|
10
|
+
type SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;
|
|
11
|
+
type JwtBearerAuthParams = SiweParams | SRPParams;
|
|
12
|
+
export declare class JwtBearerAuth implements SIWEInterface, SRPInterface {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(...args: JwtBearerAuthParams);
|
|
15
|
+
getAccessToken(): Promise<string>;
|
|
16
|
+
connectSnap(): Promise<string>;
|
|
17
|
+
isSnapConnected(): Promise<boolean>;
|
|
18
|
+
getUserProfile(): Promise<UserProfile>;
|
|
19
|
+
getIdentifier(): Promise<string>;
|
|
20
|
+
signMessage(message: string): Promise<string>;
|
|
21
|
+
pairIdentifiers(pairing: Pair[]): Promise<void>;
|
|
22
|
+
prepare(signer: {
|
|
23
|
+
address: string;
|
|
24
|
+
chainId: number;
|
|
25
|
+
signMessage: (message: string) => Promise<string>;
|
|
26
|
+
domain: string;
|
|
27
|
+
}): void;
|
|
28
|
+
}
|
|
29
|
+
export { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
|
|
30
|
+
export { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
|
|
31
|
+
export * from "./authentication-jwt-bearer/types.mjs";
|
|
32
|
+
//# sourceMappingURL=authentication.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.d.mts","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kDAA8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iB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD"}
|
|
@@ -1,26 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../chunk-2CWF7ZTL.mjs";
|
|
7
|
-
import {
|
|
8
|
-
SRPJwtBearerAuth
|
|
9
|
-
} from "../chunk-TP7SP3AG.mjs";
|
|
10
|
-
import "../chunk-YLURF2PF.mjs";
|
|
11
|
-
import {
|
|
12
|
-
AuthType
|
|
13
|
-
} from "../chunk-CAIIVJAO.mjs";
|
|
14
|
-
import "../chunk-5XSXZTED.mjs";
|
|
15
|
-
import "../chunk-UEWCUBMX.mjs";
|
|
16
|
-
import "../chunk-QDGLIUUS.mjs";
|
|
17
|
-
import "../chunk-KTCSRECK.mjs";
|
|
18
|
-
import "../chunk-TFFQFIJV.mjs";
|
|
19
|
-
import "../chunk-U5UIDVOO.mjs";
|
|
20
|
-
export {
|
|
21
|
-
AuthType,
|
|
22
|
-
JwtBearerAuth,
|
|
23
|
-
SIWEJwtBearerAuth,
|
|
24
|
-
SRPJwtBearerAuth
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
6
|
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _JwtBearerAuth_instances, _JwtBearerAuth_type, _JwtBearerAuth_env, _JwtBearerAuth_sdk, _JwtBearerAuth_assertSIWE;
|
|
13
|
+
import { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
|
|
14
|
+
import { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
|
|
15
|
+
import { getNonce, pairIdentifiers } from "./authentication-jwt-bearer/services.mjs";
|
|
16
|
+
import { AuthType } from "./authentication-jwt-bearer/types.mjs";
|
|
17
|
+
import { PairError, UnsupportedAuthTypeError } from "./errors.mjs";
|
|
18
|
+
import { getMetaMaskProviderEIP6963 } from "./utils/eip-6963-metamask-provider.mjs";
|
|
19
|
+
import { connectSnap, isSnapConnected } from "./utils/messaging-signing-snap-requests.mjs";
|
|
20
|
+
export class JwtBearerAuth {
|
|
21
|
+
constructor(...args) {
|
|
22
|
+
_JwtBearerAuth_instances.add(this);
|
|
23
|
+
_JwtBearerAuth_type.set(this, void 0);
|
|
24
|
+
_JwtBearerAuth_env.set(this, void 0);
|
|
25
|
+
_JwtBearerAuth_sdk.set(this, void 0);
|
|
26
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_type, args[0].type, "f");
|
|
27
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_env, args[0].env, "f");
|
|
28
|
+
if (args[0].type === AuthType.SRP) {
|
|
29
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_sdk, new SRPJwtBearerAuth(args[0], args[1]), "f");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (args[0].type === AuthType.SiWE) {
|
|
33
|
+
__classPrivateFieldSet(this, _JwtBearerAuth_sdk, new SIWEJwtBearerAuth(args[0], args[1]), "f");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
throw new UnsupportedAuthTypeError('unsupported auth type');
|
|
37
|
+
}
|
|
38
|
+
async getAccessToken() {
|
|
39
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getAccessToken();
|
|
40
|
+
}
|
|
41
|
+
async connectSnap() {
|
|
42
|
+
const provider = await getMetaMaskProviderEIP6963();
|
|
43
|
+
if (!provider) {
|
|
44
|
+
throw new Error('failed to get MetaMaskProviderEIP6963 provider');
|
|
45
|
+
}
|
|
46
|
+
const res = await connectSnap(provider);
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
49
|
+
async isSnapConnected() {
|
|
50
|
+
const provider = await getMetaMaskProviderEIP6963();
|
|
51
|
+
if (!provider) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const isConnected = await isSnapConnected(provider);
|
|
55
|
+
return isConnected;
|
|
56
|
+
}
|
|
57
|
+
async getUserProfile() {
|
|
58
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getUserProfile();
|
|
59
|
+
}
|
|
60
|
+
async getIdentifier() {
|
|
61
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getIdentifier();
|
|
62
|
+
}
|
|
63
|
+
async signMessage(message) {
|
|
64
|
+
return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").signMessage(message);
|
|
65
|
+
}
|
|
66
|
+
async pairIdentifiers(pairing) {
|
|
67
|
+
const profile = await this.getUserProfile();
|
|
68
|
+
const n = await getNonce(profile.profileId, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
|
|
69
|
+
const logins = await Promise.all(pairing.map(async (p) => {
|
|
70
|
+
try {
|
|
71
|
+
const raw = `metamask:${n.nonce}:${p.identifier}`;
|
|
72
|
+
const sig = await p.signMessage(raw);
|
|
73
|
+
return {
|
|
74
|
+
signature: sig,
|
|
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
|
+
raw_message: raw,
|
|
78
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
80
|
+
encrypted_storage_key: p.encryptedStorageKey,
|
|
81
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
83
|
+
identifier_type: p.identifierType,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
/* istanbul ignore next */
|
|
88
|
+
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
89
|
+
throw new PairError(`failed to sign pairing message: ${errorMessage}`);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
const accessToken = await this.getAccessToken();
|
|
93
|
+
await pairIdentifiers(n.nonce, logins, accessToken, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
|
|
94
|
+
}
|
|
95
|
+
prepare(signer) {
|
|
96
|
+
__classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSIWE).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
|
|
97
|
+
__classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").prepare(signer);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_JwtBearerAuth_type = new WeakMap(), _JwtBearerAuth_env = new WeakMap(), _JwtBearerAuth_sdk = new WeakMap(), _JwtBearerAuth_instances = new WeakSet(), _JwtBearerAuth_assertSIWE = function _JwtBearerAuth_assertSIWE(type, sdk) {
|
|
101
|
+
if (type === AuthType.SiWE) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
throw new UnsupportedAuthTypeError('This method is only available via SIWE auth type');
|
|
105
|
+
};
|
|
106
|
+
export { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
|
|
107
|
+
export { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
|
|
108
|
+
export * from "./authentication-jwt-bearer/types.mjs";
|
|
26
109
|
//# sourceMappingURL=authentication.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"authentication.mjs","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,OAAO,EACL,QAAQ,EACR,eAAe,EAChB,iDAA6C;AAE9C,OAAO,EAAE,QAAQ,EAAE,8CAA0C;AAE7D,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,qBAAiB;AAC/D,OAAO,EAAE,0BAA0B,EAAE,+CAA2C;AAChF,OAAO,EACL,WAAW,EACX,eAAe,EAChB,oDAAgD;AAajD,MAAM,OAAO,aAAa;IAOxB,YAAY,GAAG,IAAyB;;QANxC,sCAAgB;QAEhB,qCAAU;QAEV,qCAA2C;QAGzC,uBAAA,IAAI,uBAAS,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,MAAA,CAAC;QAC1B,uBAAA,IAAI,sBAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAA,CAAC;QAExB,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,GAAG,EAAE;YACjC,uBAAA,IAAI,sBAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC;YACnD,OAAO;SACR;QAED,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE;YAClC,uBAAA,IAAI,sBAAQ,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAA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I,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE;QAC1B,OAAO;KACR;IAED,MAAM,IAAI,wBAAwB,CAChC,kDAAkD,CACnD,CAAC;AACJ,CAAC;AAGH,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD","sourcesContent":["import { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nimport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nimport {\n getNonce,\n pairIdentifiers,\n} from './authentication-jwt-bearer/services';\nimport type { UserProfile, Pair } from './authentication-jwt-bearer/types';\nimport { AuthType } from './authentication-jwt-bearer/types';\nimport type { Env } from './env';\nimport { PairError, UnsupportedAuthTypeError } from './errors';\nimport { getMetaMaskProviderEIP6963 } from './utils/eip-6963-metamask-provider';\nimport {\n connectSnap,\n isSnapConnected,\n} from './utils/messaging-signing-snap-requests';\n\n// Computing the Classes, so we only get back the public methods for the interface.\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype Compute<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\ntype SIWEInterface = Compute<SIWEJwtBearerAuth>;\ntype SRPInterface = Compute<SRPJwtBearerAuth>;\n\ntype SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;\ntype SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;\ntype JwtBearerAuthParams = SiweParams | SRPParams;\n\nexport class JwtBearerAuth implements SIWEInterface, SRPInterface {\n #type: AuthType;\n\n #env: Env;\n\n #sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth;\n\n constructor(...args: JwtBearerAuthParams) {\n this.#type = args[0].type;\n this.#env = args[0].env;\n\n if (args[0].type === AuthType.SRP) {\n this.#sdk = new SRPJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n if (args[0].type === AuthType.SiWE) {\n this.#sdk = new SIWEJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n throw new UnsupportedAuthTypeError('unsupported auth type');\n }\n\n async getAccessToken(): Promise<string> {\n return await this.#sdk.getAccessToken();\n }\n\n async connectSnap(): Promise<string> {\n const provider = await getMetaMaskProviderEIP6963();\n if (!provider) {\n throw new Error('failed to get MetaMaskProviderEIP6963 provider');\n }\n const res = await connectSnap(provider);\n return res;\n }\n\n async isSnapConnected(): Promise<boolean> {\n const provider = await getMetaMaskProviderEIP6963();\n if (!provider) {\n return false;\n }\n\n const isConnected = await isSnapConnected(provider);\n return isConnected;\n }\n\n async getUserProfile(): Promise<UserProfile> {\n return await this.#sdk.getUserProfile();\n }\n\n async getIdentifier(): Promise<string> {\n return await this.#sdk.getIdentifier();\n }\n\n async signMessage(message: string): Promise<string> {\n return await this.#sdk.signMessage(message);\n }\n\n async pairIdentifiers(pairing: Pair[]): Promise<void> {\n const profile = await this.getUserProfile();\n const n = await getNonce(profile.profileId, this.#env);\n\n const logins = await Promise.all(\n pairing.map(async (p) => {\n try {\n const raw = `metamask:${n.nonce}:${p.identifier}`;\n const sig = await p.signMessage(raw);\n return {\n signature: sig,\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 raw_message: raw,\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: p.encryptedStorageKey,\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: p.identifierType,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(\n `failed to sign pairing message: ${errorMessage}`,\n );\n }\n }),\n );\n\n const accessToken = await this.getAccessToken();\n await pairIdentifiers(n.nonce, logins, accessToken, this.#env);\n }\n\n prepare(signer: {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n }): void {\n this.#assertSIWE(this.#type, this.#sdk);\n this.#sdk.prepare(signer);\n }\n\n #assertSIWE(\n type: AuthType,\n sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts sdk is SIWEJwtBearerAuth {\n if (type === AuthType.SiWE) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SIWE auth type',\n );\n }\n}\n\nexport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nexport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nexport * from './authentication-jwt-bearer/types';\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const encryption_1 = __importDefault(require("../controllers/user-storage/encryption/encryption.cjs"));
|
|
21
|
+
__exportStar(require("../controllers/user-storage/encryption/encryption.cjs"), exports);
|
|
22
|
+
exports.default = encryption_1.default;
|
|
23
|
+
//# sourceMappingURL=encryption.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.cjs","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,uGAA2E;AAE3E,wFAAkE;AAClE,kBAAe,oBAAU,CAAC","sourcesContent":["import encryption from '../controllers/user-storage/encryption/encryption';\n\nexport * from '../controllers/user-storage/encryption/encryption';\nexport default encryption;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.cts","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,8DAA0D;AAE3E,sEAAkE;AAClE,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.mts","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,8DAA0D;AAE3E,sEAAkE;AAClE,eAAe,UAAU,CAAC"}
|
package/dist/sdk/encryption.mjs
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
createSHA256Hash
|
|
6
|
-
} from "../chunk-COBJUBZE.mjs";
|
|
7
|
-
import "../chunk-H25EBXG5.mjs";
|
|
8
|
-
import "../chunk-76VRE4BI.mjs";
|
|
9
|
-
import "../chunk-U5UIDVOO.mjs";
|
|
10
|
-
export {
|
|
11
|
-
createSHA256Hash,
|
|
12
|
-
encryption_default as default
|
|
13
|
-
};
|
|
1
|
+
import encryption from "../controllers/user-storage/encryption/encryption.mjs";
|
|
2
|
+
export * from "../controllers/user-storage/encryption/encryption.mjs";
|
|
3
|
+
export default encryption;
|
|
14
4
|
//# sourceMappingURL=encryption.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"encryption.mjs","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,8DAA0D;AAE3E,sEAAkE;AAClE,eAAe,UAAU,CAAC","sourcesContent":["import encryption from '../controllers/user-storage/encryption/encryption';\n\nexport * from '../controllers/user-storage/encryption/encryption';\nexport default encryption;\n"]}
|
package/dist/sdk/env.cjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOidcClientId = exports.getEnvUrls = exports.Platform = exports.Env = void 0;
|
|
4
|
+
var Env;
|
|
5
|
+
(function (Env) {
|
|
6
|
+
Env["DEV"] = "dev";
|
|
7
|
+
Env["UAT"] = "uat";
|
|
8
|
+
Env["PRD"] = "prd";
|
|
9
|
+
})(Env || (exports.Env = Env = {}));
|
|
10
|
+
var Platform;
|
|
11
|
+
(function (Platform) {
|
|
12
|
+
Platform["MOBILE"] = "mobile";
|
|
13
|
+
Platform["EXTENSION"] = "extension";
|
|
14
|
+
Platform["PORTFOLIO"] = "portfolio";
|
|
15
|
+
Platform["INFURA"] = "infura";
|
|
16
|
+
})(Platform || (exports.Platform = Platform = {}));
|
|
17
|
+
const ENV_URLS = {
|
|
18
|
+
dev: {
|
|
19
|
+
authApiUrl: 'https://authentication.dev-api.cx.metamask.io',
|
|
20
|
+
oidcApiUrl: 'https://oidc.dev-api.cx.metamask.io',
|
|
21
|
+
userStorageApiUrl: 'https://user-storage.dev-api.cx.metamask.io',
|
|
22
|
+
},
|
|
23
|
+
uat: {
|
|
24
|
+
authApiUrl: 'https://authentication.uat-api.cx.metamask.io',
|
|
25
|
+
oidcApiUrl: 'https://oidc.uat-api.cx.metamask.io',
|
|
26
|
+
userStorageApiUrl: 'https://user-storage.uat-api.cx.metamask.io',
|
|
27
|
+
},
|
|
28
|
+
prd: {
|
|
29
|
+
authApiUrl: 'https://authentication.api.cx.metamask.io',
|
|
30
|
+
oidcApiUrl: 'https://oidc.api.cx.metamask.io',
|
|
31
|
+
userStorageApiUrl: 'https://user-storage.api.cx.metamask.io',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Validates and returns correct environment endpoints
|
|
36
|
+
*
|
|
37
|
+
* @param env - environment field
|
|
38
|
+
* @returns the correct environment url
|
|
39
|
+
* @throws on invalid environment passed
|
|
40
|
+
*/
|
|
41
|
+
function getEnvUrls(env) {
|
|
42
|
+
if (!ENV_URLS[env]) {
|
|
43
|
+
throw new Error('invalid environment configuration');
|
|
44
|
+
}
|
|
45
|
+
return ENV_URLS[env];
|
|
46
|
+
}
|
|
47
|
+
exports.getEnvUrls = getEnvUrls;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the valid OIDC Client ID (used during authorization)
|
|
50
|
+
*
|
|
51
|
+
* @param env - environment field
|
|
52
|
+
* @param platform - platform field
|
|
53
|
+
* @returns the OIDC client id for the environment
|
|
54
|
+
*/
|
|
55
|
+
function getOidcClientId(env, platform) {
|
|
56
|
+
const clientIds = {
|
|
57
|
+
[Env.DEV]: {
|
|
58
|
+
[Platform.PORTFOLIO]: 'c7ca94a0-5d52-4635-9502-1a50a9c410cc',
|
|
59
|
+
[Platform.MOBILE]: 'e83c7cc9-267d-4fb4-8fec-f0e3bbe5ae8e',
|
|
60
|
+
[Platform.EXTENSION]: 'f1a963d7-50dc-4cb5-8d81-f1f3654f0df3',
|
|
61
|
+
[Platform.INFURA]: 'bd887006-0d55-481a-a395-5ff9a0dc52c9',
|
|
62
|
+
},
|
|
63
|
+
[Env.UAT]: {
|
|
64
|
+
[Platform.PORTFOLIO]: '8f2dd4ac-db07-4819-9ba5-1ee0ec1b56d1',
|
|
65
|
+
[Platform.MOBILE]: 'c3cfdcd2-51d6-4fae-ad2c-ff238c8fef53',
|
|
66
|
+
[Platform.EXTENSION]: 'a9de167c-c9a6-43d8-af39-d301fd44c485',
|
|
67
|
+
[Platform.INFURA]: '01929890-7002-4c97-9913-8f6c09a6d674',
|
|
68
|
+
},
|
|
69
|
+
[Env.PRD]: {
|
|
70
|
+
[Platform.PORTFOLIO]: '35e1cd62-49c5-4be8-8b6e-a5212f2d2cfb',
|
|
71
|
+
[Platform.MOBILE]: '75fa62a3-9ca0-4b91-9fe5-76bec86b0257',
|
|
72
|
+
[Platform.EXTENSION]: '1132f10a-b4e5-4390-a5f2-d9c6022db564',
|
|
73
|
+
[Platform.INFURA]: 'fdde9417-e193-4d23-9943-a8346b18d097',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
if (!clientIds[env]) {
|
|
77
|
+
throw new Error(`invalid env ${env}: cannot determine oidc client id`);
|
|
78
|
+
}
|
|
79
|
+
if (!clientIds[env][platform]) {
|
|
80
|
+
throw new Error(`invalid env ${env} and platform ${platform} combination: cannot determine oidc client id`);
|
|
81
|
+
}
|
|
82
|
+
return clientIds[env][platform];
|
|
83
|
+
}
|
|
84
|
+
exports.getOidcClientId = getOidcClientId;
|
|
85
|
+
//# sourceMappingURL=env.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.cjs","sourceRoot":"","sources":["../../src/sdk/env.ts"],"names":[],"mappings":";;;AAAA,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAED,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,6BAAiB,CAAA;AACnB,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAQD,MAAM,QAAQ,GAA8B;IAC1C,GAAG,EAAE;QACH,UAAU,EAAE,+CAA+C;QAC3D,UAAU,EAAE,qCAAqC;QACjD,iBAAiB,EAAE,6CAA6C;KACjE;IACD,GAAG,EAAE;QACH,UAAU,EAAE,+CAA+C;QAC3D,UAAU,EAAE,qC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1D;KACF,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,mCAAmC,CAAC,CAAC;KACxE;IAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CACb,eAAe,GAAG,iBAAiB,QAAQ,+CAA+C,CAC3F,CAAC;KACH;IAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC;AAjCD,0CAiCC","sourcesContent":["export enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\nexport enum Platform {\n MOBILE = 'mobile',\n EXTENSION = 'extension',\n PORTFOLIO = 'portfolio',\n INFURA = 'infura',\n}\n\ntype EnvUrlsEntry = {\n authApiUrl: string;\n oidcApiUrl: string;\n userStorageApiUrl: string;\n};\n\nconst ENV_URLS: Record<Env, EnvUrlsEntry> = {\n dev: {\n authApiUrl: 'https://authentication.dev-api.cx.metamask.io',\n oidcApiUrl: 'https://oidc.dev-api.cx.metamask.io',\n userStorageApiUrl: 'https://user-storage.dev-api.cx.metamask.io',\n },\n uat: {\n authApiUrl: 'https://authentication.uat-api.cx.metamask.io',\n oidcApiUrl: 'https://oidc.uat-api.cx.metamask.io',\n userStorageApiUrl: 'https://user-storage.uat-api.cx.metamask.io',\n },\n prd: {\n authApiUrl: 'https://authentication.api.cx.metamask.io',\n oidcApiUrl: 'https://oidc.api.cx.metamask.io',\n userStorageApiUrl: 'https://user-storage.api.cx.metamask.io',\n },\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrls(env: Env): EnvUrlsEntry {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n\n/**\n * Returns the valid OIDC Client ID (used during authorization)\n *\n * @param env - environment field\n * @param platform - platform field\n * @returns the OIDC client id for the environment\n */\nexport function getOidcClientId(env: Env, platform: Platform): string {\n const clientIds = {\n [Env.DEV]: {\n [Platform.PORTFOLIO]: 'c7ca94a0-5d52-4635-9502-1a50a9c410cc',\n [Platform.MOBILE]: 'e83c7cc9-267d-4fb4-8fec-f0e3bbe5ae8e',\n [Platform.EXTENSION]: 'f1a963d7-50dc-4cb5-8d81-f1f3654f0df3',\n [Platform.INFURA]: 'bd887006-0d55-481a-a395-5ff9a0dc52c9',\n },\n [Env.UAT]: {\n [Platform.PORTFOLIO]: '8f2dd4ac-db07-4819-9ba5-1ee0ec1b56d1',\n [Platform.MOBILE]: 'c3cfdcd2-51d6-4fae-ad2c-ff238c8fef53',\n [Platform.EXTENSION]: 'a9de167c-c9a6-43d8-af39-d301fd44c485',\n [Platform.INFURA]: '01929890-7002-4c97-9913-8f6c09a6d674',\n },\n [Env.PRD]: {\n [Platform.PORTFOLIO]: '35e1cd62-49c5-4be8-8b6e-a5212f2d2cfb',\n [Platform.MOBILE]: '75fa62a3-9ca0-4b91-9fe5-76bec86b0257',\n [Platform.EXTENSION]: '1132f10a-b4e5-4390-a5f2-d9c6022db564',\n [Platform.INFURA]: 'fdde9417-e193-4d23-9943-a8346b18d097',\n },\n };\n\n if (!clientIds[env]) {\n throw new Error(`invalid env ${env}: cannot determine oidc client id`);\n }\n\n if (!clientIds[env][platform]) {\n throw new Error(\n `invalid env ${env} and platform ${platform} combination: cannot determine oidc client id`,\n );\n }\n\n return clientIds[env][platform];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.cts","sourceRoot":"","sources":["../../src/sdk/env.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,oBAAY,QAAQ;IAClB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAoBF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAKjD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAiCpE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare enum Env {
|
|
2
|
+
DEV = "dev",
|
|
3
|
+
UAT = "uat",
|
|
4
|
+
PRD = "prd"
|
|
5
|
+
}
|
|
6
|
+
export declare enum Platform {
|
|
7
|
+
MOBILE = "mobile",
|
|
8
|
+
EXTENSION = "extension",
|
|
9
|
+
PORTFOLIO = "portfolio",
|
|
10
|
+
INFURA = "infura"
|
|
11
|
+
}
|
|
12
|
+
type EnvUrlsEntry = {
|
|
13
|
+
authApiUrl: string;
|
|
14
|
+
oidcApiUrl: string;
|
|
15
|
+
userStorageApiUrl: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Validates and returns correct environment endpoints
|
|
19
|
+
*
|
|
20
|
+
* @param env - environment field
|
|
21
|
+
* @returns the correct environment url
|
|
22
|
+
* @throws on invalid environment passed
|
|
23
|
+
*/
|
|
24
|
+
export declare function getEnvUrls(env: Env): EnvUrlsEntry;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the valid OIDC Client ID (used during authorization)
|
|
27
|
+
*
|
|
28
|
+
* @param env - environment field
|
|
29
|
+
* @param platform - platform field
|
|
30
|
+
* @returns the OIDC client id for the environment
|
|
31
|
+
*/
|
|
32
|
+
export declare function getOidcClientId(env: Env, platform: Platform): string;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=env.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.mts","sourceRoot":"","sources":["../../src/sdk/env.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,oBAAY,QAAQ;IAClB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAoBF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAKjD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAiCpE"}
|