@metamask/profile-sync-controller 0.4.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 +54 -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 -16
- 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} +8 -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 -76
- 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} +9 -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 -14
- 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-246Z6L5V.js +0 -534
- package/dist/chunk-246Z6L5V.js.map +0 -1
- package/dist/chunk-2677XY6G.mjs +0 -107
- package/dist/chunk-2677XY6G.mjs.map +0 -1
- 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-4ZGRRVMI.js +0 -133
- package/dist/chunk-4ZGRRVMI.js.map +0 -1
- package/dist/chunk-5EBUFNAN.mjs +0 -55
- package/dist/chunk-5EBUFNAN.mjs.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-7MSQV43P.mjs +0 -77
- package/dist/chunk-7MSQV43P.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-CHUZGCDV.js +0 -107
- package/dist/chunk-CHUZGCDV.js.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-J7NSK6BO.mjs +0 -133
- package/dist/chunk-J7NSK6BO.mjs.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-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-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-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-PQ5T4GHY.js +0 -55
- package/dist/chunk-PQ5T4GHY.js.map +0 -1
- package/dist/chunk-PRYLTXW4.js +0 -92
- package/dist/chunk-PRYLTXW4.js.map +0 -1
- package/dist/chunk-Q5KTSMRE.js +0 -120
- package/dist/chunk-Q5KTSMRE.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-SZ6WMC6C.mjs +0 -534
- package/dist/chunk-SZ6WMC6C.mjs.map +0 -1
- package/dist/chunk-T2YURW25.js +0 -77
- package/dist/chunk-T2YURW25.js.map +0 -1
- package/dist/chunk-TFFQFIJV.mjs +0 -54
- package/dist/chunk-TFFQFIJV.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-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-YHGWG3EQ.js +0 -29
- package/dist/chunk-YHGWG3EQ.js.map +0 -1
- package/dist/chunk-YKOMKXG4.mjs +0 -120
- package/dist/chunk-YKOMKXG4.mjs.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 -77
- 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 -16
- 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
package/dist/chunk-YKOMKXG4.mjs
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SIWEJwtBearerAuth
|
|
3
|
-
} from "./chunk-2CWF7ZTL.mjs";
|
|
4
|
-
import {
|
|
5
|
-
SRPJwtBearerAuth
|
|
6
|
-
} from "./chunk-J7NSK6BO.mjs";
|
|
7
|
-
import {
|
|
8
|
-
getNonce,
|
|
9
|
-
pairIdentifiers
|
|
10
|
-
} from "./chunk-YLURF2PF.mjs";
|
|
11
|
-
import {
|
|
12
|
-
getMetaMaskProviderEIP6963
|
|
13
|
-
} from "./chunk-5XSXZTED.mjs";
|
|
14
|
-
import {
|
|
15
|
-
connectSnap
|
|
16
|
-
} from "./chunk-5EBUFNAN.mjs";
|
|
17
|
-
import {
|
|
18
|
-
PairError,
|
|
19
|
-
UnsupportedAuthTypeError
|
|
20
|
-
} from "./chunk-TFFQFIJV.mjs";
|
|
21
|
-
import {
|
|
22
|
-
__privateAdd,
|
|
23
|
-
__privateGet,
|
|
24
|
-
__privateMethod,
|
|
25
|
-
__privateSet
|
|
26
|
-
} from "./chunk-U5UIDVOO.mjs";
|
|
27
|
-
|
|
28
|
-
// src/sdk/authentication.ts
|
|
29
|
-
var _type, _env, _sdk, _assertSIWE, assertSIWE_fn;
|
|
30
|
-
var JwtBearerAuth = class {
|
|
31
|
-
constructor(...args) {
|
|
32
|
-
__privateAdd(this, _assertSIWE);
|
|
33
|
-
__privateAdd(this, _type, void 0);
|
|
34
|
-
__privateAdd(this, _env, void 0);
|
|
35
|
-
__privateAdd(this, _sdk, void 0);
|
|
36
|
-
__privateSet(this, _type, args[0].type);
|
|
37
|
-
__privateSet(this, _env, args[0].env);
|
|
38
|
-
if (args[0].type === "SRP" /* SRP */) {
|
|
39
|
-
__privateSet(this, _sdk, new SRPJwtBearerAuth(args[0], args[1]));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (args[0].type === "SiWE" /* SiWE */) {
|
|
43
|
-
__privateSet(this, _sdk, new SIWEJwtBearerAuth(args[0], args[1]));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
throw new UnsupportedAuthTypeError("unsupported auth type");
|
|
47
|
-
}
|
|
48
|
-
async getAccessToken() {
|
|
49
|
-
return await __privateGet(this, _sdk).getAccessToken();
|
|
50
|
-
}
|
|
51
|
-
async connectSnap() {
|
|
52
|
-
const provider = await getMetaMaskProviderEIP6963();
|
|
53
|
-
if (!provider) {
|
|
54
|
-
throw new Error("failed to get MetaMaskProviderEIP6963 provider");
|
|
55
|
-
}
|
|
56
|
-
const res = await connectSnap(provider);
|
|
57
|
-
return res;
|
|
58
|
-
}
|
|
59
|
-
async getUserProfile() {
|
|
60
|
-
return await __privateGet(this, _sdk).getUserProfile();
|
|
61
|
-
}
|
|
62
|
-
async getIdentifier() {
|
|
63
|
-
return await __privateGet(this, _sdk).getIdentifier();
|
|
64
|
-
}
|
|
65
|
-
async signMessage(message) {
|
|
66
|
-
return await __privateGet(this, _sdk).signMessage(message);
|
|
67
|
-
}
|
|
68
|
-
async pairIdentifiers(pairing) {
|
|
69
|
-
const profile = await this.getUserProfile();
|
|
70
|
-
const n = await getNonce(profile.profileId, __privateGet(this, _env));
|
|
71
|
-
const logins = await Promise.all(
|
|
72
|
-
pairing.map(async (p) => {
|
|
73
|
-
try {
|
|
74
|
-
const raw = `metamask:${n.nonce}:${p.identifier}`;
|
|
75
|
-
const sig = await p.signMessage(raw);
|
|
76
|
-
return {
|
|
77
|
-
signature: sig,
|
|
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
|
-
raw_message: raw,
|
|
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
|
-
encrypted_storage_key: p.encryptedStorageKey,
|
|
84
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
86
|
-
identifier_type: p.identifierType
|
|
87
|
-
};
|
|
88
|
-
} catch (e) {
|
|
89
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? "");
|
|
90
|
-
throw new PairError(
|
|
91
|
-
`failed to sign pairing message: ${errorMessage}`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
const accessToken = await this.getAccessToken();
|
|
97
|
-
await pairIdentifiers(n.nonce, logins, accessToken, __privateGet(this, _env));
|
|
98
|
-
}
|
|
99
|
-
prepare(signer) {
|
|
100
|
-
__privateMethod(this, _assertSIWE, assertSIWE_fn).call(this, __privateGet(this, _type), __privateGet(this, _sdk));
|
|
101
|
-
__privateGet(this, _sdk).prepare(signer);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
_type = new WeakMap();
|
|
105
|
-
_env = new WeakMap();
|
|
106
|
-
_sdk = new WeakMap();
|
|
107
|
-
_assertSIWE = new WeakSet();
|
|
108
|
-
assertSIWE_fn = function(type, sdk) {
|
|
109
|
-
if (type === "SiWE" /* SiWE */) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
throw new UnsupportedAuthTypeError(
|
|
113
|
-
"This method is only available via SIWE auth type"
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
JwtBearerAuth
|
|
119
|
-
};
|
|
120
|
-
//# sourceMappingURL=chunk-YKOMKXG4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk/authentication.ts"],"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 { connectSnap } 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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAwBO,IAAM,gBAAN,MAA2D;AAAA,EAOhE,eAAe,MAA2B;AAwF1C;AA9FA;AAEA;AAEA;AAGE,uBAAK,OAAQ,KAAK,CAAC,EAAE;AACrB,uBAAK,MAAO,KAAK,CAAC,EAAE;AAEpB,QAAI,KAAK,CAAC,EAAE,0BAAuB;AACjC,yBAAK,MAAO,IAAI,iBAAiB,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AACjD;AAAA,IACF;AAEA,QAAI,KAAK,CAAC,EAAE,4BAAwB;AAClC,yBAAK,MAAO,IAAI,kBAAkB,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AAClD;AAAA,IACF;AAEA,UAAM,IAAI,yBAAyB,uBAAuB;AAAA,EAC5D;AAAA,EAEA,MAAM,iBAAkC;AACtC,WAAO,MAAM,mBAAK,MAAK,eAAe;AAAA,EACxC;AAAA,EAEA,MAAM,cAA+B;AACnC,UAAM,WAAW,MAAM,2BAA2B;AAClD,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,MAAM,gDAAgD;AAAA,IAClE;AACA,UAAM,MAAM,MAAM,YAAY,QAAQ;AACtC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,iBAAuC;AAC3C,WAAO,MAAM,mBAAK,MAAK,eAAe;AAAA,EACxC;AAAA,EAEA,MAAM,gBAAiC;AACrC,WAAO,MAAM,mBAAK,MAAK,cAAc;AAAA,EACvC;AAAA,EAEA,MAAM,YAAY,SAAkC;AAClD,WAAO,MAAM,mBAAK,MAAK,YAAY,OAAO;AAAA,EAC5C;AAAA,EAEA,MAAM,gBAAgB,SAAgC;AACpD,UAAM,UAAU,MAAM,KAAK,eAAe;AAC1C,UAAM,IAAI,MAAM,SAAS,QAAQ,WAAW,mBAAK,KAAI;AAErD,UAAM,SAAS,MAAM,QAAQ;AAAA,MAC3B,QAAQ,IAAI,OAAO,MAAM;AACvB,YAAI;AACF,gBAAM,MAAM,YAAY,EAAE,KAAK,IAAI,EAAE,UAAU;AAC/C,gBAAM,MAAM,MAAM,EAAE,YAAY,GAAG;AACnC,iBAAO;AAAA,YACL,WAAW;AAAA;AAAA;AAAA,YAGX,aAAa;AAAA;AAAA;AAAA,YAGb,uBAAuB,EAAE;AAAA;AAAA;AAAA,YAGzB,iBAAiB,EAAE;AAAA,UACrB;AAAA,QACF,SAAS,GAAG;AAEV,gBAAM,eACJ,aAAa,QAAQ,EAAE,UAAU,KAAK,UAAU,KAAK,EAAE;AACzD,gBAAM,IAAI;AAAA,YACR,mCAAmC,YAAY;AAAA,UACjD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,cAAc,MAAM,KAAK,eAAe;AAC9C,UAAM,gBAAgB,EAAE,OAAO,QAAQ,aAAa,mBAAK,KAAI;AAAA,EAC/D;AAAA,EAEA,QAAQ,QAKC;AACP,0BAAK,4BAAL,WAAiB,mBAAK,QAAO,mBAAK;AAClC,uBAAK,MAAK,QAAQ,MAAM;AAAA,EAC1B;AAcF;AA1GE;AAEA;AAEA;AA0FA;AAAA,gBAAW,SACT,MACA,KACkC;AAClC,MAAI,4BAAwB;AAC1B;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-YLURF2PF.mjs
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getEnvUrls,
|
|
3
|
-
getOidcClientId
|
|
4
|
-
} from "./chunk-KTCSRECK.mjs";
|
|
5
|
-
import {
|
|
6
|
-
NonceRetrievalError,
|
|
7
|
-
PairError,
|
|
8
|
-
SignInError,
|
|
9
|
-
ValidationError
|
|
10
|
-
} from "./chunk-TFFQFIJV.mjs";
|
|
11
|
-
|
|
12
|
-
// src/sdk/authentication-jwt-bearer/services.ts
|
|
13
|
-
var NONCE_URL = (env) => `${getEnvUrls(env).authApiUrl}/api/v2/nonce`;
|
|
14
|
-
var PAIR_IDENTIFIERS = (env) => `${getEnvUrls(env).authApiUrl}/api/v2/identifiers/pair`;
|
|
15
|
-
var OIDC_TOKEN_URL = (env) => `${getEnvUrls(env).oidcApiUrl}/oauth2/token`;
|
|
16
|
-
var SRP_LOGIN_URL = (env) => `${getEnvUrls(env).authApiUrl}/api/v2/srp/login`;
|
|
17
|
-
var SIWE_LOGIN_URL = (env) => `${getEnvUrls(env).authApiUrl}/api/v2/siwe/login`;
|
|
18
|
-
var getAuthenticationUrl = (authType, env) => {
|
|
19
|
-
switch (authType) {
|
|
20
|
-
case "SRP" /* SRP */:
|
|
21
|
-
return SRP_LOGIN_URL(env);
|
|
22
|
-
case "SiWE" /* SiWE */:
|
|
23
|
-
return SIWE_LOGIN_URL(env);
|
|
24
|
-
default:
|
|
25
|
-
throw new ValidationError(
|
|
26
|
-
`Invalid AuthType: ${authType} - unable to create Auth URL`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
async function pairIdentifiers(nonce, logins, accessToken, env) {
|
|
31
|
-
const pairUrl = new URL(PAIR_IDENTIFIERS(env));
|
|
32
|
-
try {
|
|
33
|
-
const response = await fetch(pairUrl, {
|
|
34
|
-
method: "POST",
|
|
35
|
-
headers: {
|
|
36
|
-
"Content-Type": "application/json",
|
|
37
|
-
Authorization: `Bearer ${accessToken}`
|
|
38
|
-
},
|
|
39
|
-
body: JSON.stringify({
|
|
40
|
-
nonce,
|
|
41
|
-
logins
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
const responseBody = await response.json();
|
|
46
|
-
throw new Error(
|
|
47
|
-
`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
} catch (e) {
|
|
51
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? "");
|
|
52
|
-
throw new PairError(`unable to pair identifiers: ${errorMessage}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async function getNonce(id, env) {
|
|
56
|
-
const nonceUrl = new URL(NONCE_URL(env));
|
|
57
|
-
nonceUrl.searchParams.set("identifier", id);
|
|
58
|
-
try {
|
|
59
|
-
const nonceResponse = await fetch(nonceUrl.toString());
|
|
60
|
-
if (!nonceResponse.ok) {
|
|
61
|
-
const responseBody = await nonceResponse.json();
|
|
62
|
-
throw new Error(
|
|
63
|
-
`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
const nonceJson = await nonceResponse.json();
|
|
67
|
-
return {
|
|
68
|
-
nonce: nonceJson.nonce,
|
|
69
|
-
identifier: nonceJson.identifier,
|
|
70
|
-
expiresIn: nonceJson.expires_in
|
|
71
|
-
};
|
|
72
|
-
} catch (e) {
|
|
73
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? "");
|
|
74
|
-
throw new NonceRetrievalError(`failed to generate nonce: ${errorMessage}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
async function authorizeOIDC(jwtToken, env, platform) {
|
|
78
|
-
const grantType = "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
79
|
-
const headers = new Headers({
|
|
80
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
81
|
-
});
|
|
82
|
-
const urlEncodedBody = new URLSearchParams();
|
|
83
|
-
urlEncodedBody.append("grant_type", grantType);
|
|
84
|
-
urlEncodedBody.append("client_id", getOidcClientId(env, platform));
|
|
85
|
-
urlEncodedBody.append("assertion", jwtToken);
|
|
86
|
-
try {
|
|
87
|
-
const response = await fetch(OIDC_TOKEN_URL(env), {
|
|
88
|
-
method: "POST",
|
|
89
|
-
headers,
|
|
90
|
-
body: urlEncodedBody.toString()
|
|
91
|
-
});
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
const responseBody = await response.json();
|
|
94
|
-
throw new Error(
|
|
95
|
-
`HTTP error: ${responseBody.error_description}, error code: ${responseBody.error}`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
const accessTokenResponse = await response.json();
|
|
99
|
-
return {
|
|
100
|
-
accessToken: accessTokenResponse.access_token,
|
|
101
|
-
expiresIn: accessTokenResponse.expires_in,
|
|
102
|
-
obtainedAt: Date.now()
|
|
103
|
-
};
|
|
104
|
-
} catch (e) {
|
|
105
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? "");
|
|
106
|
-
throw new SignInError(`unable to get access token: ${errorMessage}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async function authenticate(rawMessage, signature, authType, env) {
|
|
110
|
-
const authenticationUrl = getAuthenticationUrl(authType, env);
|
|
111
|
-
try {
|
|
112
|
-
const response = await fetch(authenticationUrl, {
|
|
113
|
-
method: "POST",
|
|
114
|
-
headers: {
|
|
115
|
-
"Content-Type": "application/json"
|
|
116
|
-
},
|
|
117
|
-
body: JSON.stringify({
|
|
118
|
-
signature,
|
|
119
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
121
|
-
raw_message: rawMessage
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
if (!response.ok) {
|
|
125
|
-
const responseBody = await response.json();
|
|
126
|
-
throw new Error(
|
|
127
|
-
`${authType} login HTTP error: ${responseBody.message}, error code: ${responseBody.error}`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
const loginResponse = await response.json();
|
|
131
|
-
return {
|
|
132
|
-
token: loginResponse.token,
|
|
133
|
-
expiresIn: loginResponse.expires_in,
|
|
134
|
-
profile: {
|
|
135
|
-
identifierId: loginResponse.profile.identifier_id,
|
|
136
|
-
metaMetricsId: loginResponse.profile.metametrics_id,
|
|
137
|
-
profileId: loginResponse.profile.profile_id
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
} catch (e) {
|
|
141
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? "");
|
|
142
|
-
throw new SignInError(`unable to perform SRP login: ${errorMessage}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
NONCE_URL,
|
|
148
|
-
PAIR_IDENTIFIERS,
|
|
149
|
-
OIDC_TOKEN_URL,
|
|
150
|
-
SRP_LOGIN_URL,
|
|
151
|
-
SIWE_LOGIN_URL,
|
|
152
|
-
pairIdentifiers,
|
|
153
|
-
getNonce,
|
|
154
|
-
authorizeOIDC,
|
|
155
|
-
authenticate
|
|
156
|
-
};
|
|
157
|
-
//# sourceMappingURL=chunk-YLURF2PF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk/authentication-jwt-bearer/services.ts"],"sourcesContent":["import type { Env, Platform } from '../env';\nimport { getEnvUrls, getOidcClientId } from '../env';\nimport {\n NonceRetrievalError,\n PairError,\n SignInError,\n ValidationError,\n} from '../errors';\nimport type { AccessToken, ErrorMessage, UserProfile } from './types';\nimport { AuthType } from './types';\n\nexport const NONCE_URL = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/nonce`;\n\nexport const PAIR_IDENTIFIERS = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/identifiers/pair`;\n\nexport const OIDC_TOKEN_URL = (env: Env) =>\n `${getEnvUrls(env).oidcApiUrl}/oauth2/token`;\n\nexport const SRP_LOGIN_URL = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/srp/login`;\n\nexport const SIWE_LOGIN_URL = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/siwe/login`;\n\nconst getAuthenticationUrl = (authType: AuthType, env: Env): string => {\n switch (authType) {\n case AuthType.SRP:\n return SRP_LOGIN_URL(env);\n case AuthType.SiWE:\n return SIWE_LOGIN_URL(env);\n /* istanbul ignore next */\n default:\n throw new ValidationError(\n `Invalid AuthType: ${authType as number} - unable to create Auth URL`,\n );\n }\n};\n\ntype NonceResponse = {\n nonce: string;\n identifier: string;\n expiresIn: number;\n};\n\ntype PairRequest = {\n signature: string;\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: string;\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: string;\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' | 'SRP';\n};\n\n/**\n * Pair multiple identifiers under a single profile\n *\n * @param nonce - session nonce\n * @param logins - pairing request payload\n * @param accessToken - JWT access token used to access protected resources\n * @param env - server environment\n * @returns void.\n */\nexport async function pairIdentifiers(\n nonce: string,\n logins: PairRequest[],\n accessToken: string,\n env: Env,\n): Promise<void> {\n const pairUrl = new URL(PAIR_IDENTIFIERS(env));\n\n try {\n const response = await fetch(pairUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n nonce,\n logins,\n }),\n });\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(`unable to pair identifiers: ${errorMessage}`);\n }\n}\n\n/**\n * Service to Get Nonce for JWT Bearer Flow\n *\n * @param id - identifier ID\n * @param env - server environment\n * @returns the nonce.\n */\nexport async function getNonce(id: string, env: Env): Promise<NonceResponse> {\n const nonceUrl = new URL(NONCE_URL(env));\n nonceUrl.searchParams.set('identifier', id);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n const responseBody = (await nonceResponse.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const nonceJson = await nonceResponse.json();\n return {\n nonce: nonceJson.nonce,\n identifier: nonceJson.identifier,\n expiresIn: nonceJson.expires_in,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new NonceRetrievalError(`failed to generate nonce: ${errorMessage}`);\n }\n}\n\n/**\n * Service to Authorize And perform OIDC Flow to get the Access Token\n *\n * @param jwtToken - The original token received from Authentication. This is traded for the Access Token. (the authentication token is single-use)\n * @param env - server environment\n * @param platform - SDK platform\n * @returns Access Token from Authorization server\n */\nexport async function authorizeOIDC(\n jwtToken: string,\n env: Env,\n platform: Platform,\n): Promise<AccessToken> {\n const grantType = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', grantType);\n urlEncodedBody.append('client_id', getOidcClientId(env, platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKEN_URL(env), {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n const responseBody = (await response.json()) as {\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 error_description: string;\n error: string;\n };\n throw new Error(\n `HTTP error: ${responseBody.error_description}, error code: ${responseBody.error}`,\n );\n }\n\n const accessTokenResponse = await response.json();\n return {\n accessToken: accessTokenResponse.access_token,\n expiresIn: accessTokenResponse.expires_in,\n obtainedAt: Date.now(),\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new SignInError(`unable to get access token: ${errorMessage}`);\n }\n}\n\ntype Authentication = {\n token: string;\n expiresIn: number;\n profile: UserProfile;\n};\n/**\n * Service to Authenticate/Login a user via SIWE or SRP derived key.\n *\n * @param rawMessage - raw message for validation when authenticating\n * @param signature - signed raw message\n * @param authType - authentication type/flow used\n * @param env - server environment\n * @returns Authentication Token\n */\nexport async function authenticate(\n rawMessage: string,\n signature: string,\n authType: AuthType,\n env: Env,\n): Promise<Authentication> {\n const authenticationUrl = getAuthenticationUrl(authType, env);\n\n try {\n const response = await fetch(authenticationUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\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: rawMessage,\n }),\n });\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `${authType} login HTTP error: ${responseBody.message}, error code: ${responseBody.error}`,\n );\n }\n\n const loginResponse = await response.json();\n return {\n token: loginResponse.token,\n expiresIn: loginResponse.expires_in,\n profile: {\n identifierId: loginResponse.profile.identifier_id,\n metaMetricsId: loginResponse.profile.metametrics_id,\n profileId: loginResponse.profile.profile_id,\n },\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new SignInError(`unable to perform SRP login: ${errorMessage}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWO,IAAM,YAAY,CAAC,QACxB,GAAG,WAAW,GAAG,EAAE,UAAU;AAExB,IAAM,mBAAmB,CAAC,QAC/B,GAAG,WAAW,GAAG,EAAE,UAAU;AAExB,IAAM,iBAAiB,CAAC,QAC7B,GAAG,WAAW,GAAG,EAAE,UAAU;AAExB,IAAM,gBAAgB,CAAC,QAC5B,GAAG,WAAW,GAAG,EAAE,UAAU;AAExB,IAAM,iBAAiB,CAAC,QAC7B,GAAG,WAAW,GAAG,EAAE,UAAU;AAE/B,IAAM,uBAAuB,CAAC,UAAoB,QAAqB;AACrE,UAAQ,UAAU;AAAA,IAChB;AACE,aAAO,cAAc,GAAG;AAAA,IAC1B;AACE,aAAO,eAAe,GAAG;AAAA,IAE3B;AACE,YAAM,IAAI;AAAA,QACR,qBAAqB,QAAkB;AAAA,MACzC;AAAA,EACJ;AACF;AA8BA,eAAsB,gBACpB,OACA,QACA,aACA,KACe;AACf,QAAM,UAAU,IAAI,IAAI,iBAAiB,GAAG,CAAC;AAE7C,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,SAAS;AAAA,MACpC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,eAAe,UAAU,WAAW;AAAA,MACtC;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,eAAgB,MAAM,SAAS,KAAK;AAC1C,YAAM,IAAI;AAAA,QACR,uBAAuB,aAAa,OAAO,YAAY,aAAa,KAAK;AAAA,MAC3E;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AAEV,UAAM,eACJ,aAAa,QAAQ,EAAE,UAAU,KAAK,UAAU,KAAK,EAAE;AACzD,UAAM,IAAI,UAAU,+BAA+B,YAAY,EAAE;AAAA,EACnE;AACF;AASA,eAAsB,SAAS,IAAY,KAAkC;AAC3E,QAAM,WAAW,IAAI,IAAI,UAAU,GAAG,CAAC;AACvC,WAAS,aAAa,IAAI,cAAc,EAAE;AAE1C,MAAI;AACF,UAAM,gBAAgB,MAAM,MAAM,SAAS,SAAS,CAAC;AACrD,QAAI,CAAC,cAAc,IAAI;AACrB,YAAM,eAAgB,MAAM,cAAc,KAAK;AAC/C,YAAM,IAAI;AAAA,QACR,uBAAuB,aAAa,OAAO,YAAY,aAAa,KAAK;AAAA,MAC3E;AAAA,IACF;AAEA,UAAM,YAAY,MAAM,cAAc,KAAK;AAC3C,WAAO;AAAA,MACL,OAAO,UAAU;AAAA,MACjB,YAAY,UAAU;AAAA,MACtB,WAAW,UAAU;AAAA,IACvB;AAAA,EACF,SAAS,GAAG;AAEV,UAAM,eACJ,aAAa,QAAQ,EAAE,UAAU,KAAK,UAAU,KAAK,EAAE;AACzD,UAAM,IAAI,oBAAoB,6BAA6B,YAAY,EAAE;AAAA,EAC3E;AACF;AAUA,eAAsB,cACpB,UACA,KACA,UACsB;AACtB,QAAM,YAAY;AAClB,QAAM,UAAU,IAAI,QAAQ;AAAA,IAC1B,gBAAgB;AAAA,EAClB,CAAC;AAED,QAAM,iBAAiB,IAAI,gBAAgB;AAC3C,iBAAe,OAAO,cAAc,SAAS;AAC7C,iBAAe,OAAO,aAAa,gBAAgB,KAAK,QAAQ,CAAC;AACjE,iBAAe,OAAO,aAAa,QAAQ;AAE3C,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,eAAe,GAAG,GAAG;AAAA,MAChD,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,eAAe,SAAS;AAAA,IAChC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,eAAgB,MAAM,SAAS,KAAK;AAM1C,YAAM,IAAI;AAAA,QACR,eAAe,aAAa,iBAAiB,iBAAiB,aAAa,KAAK;AAAA,MAClF;AAAA,IACF;AAEA,UAAM,sBAAsB,MAAM,SAAS,KAAK;AAChD,WAAO;AAAA,MACL,aAAa,oBAAoB;AAAA,MACjC,WAAW,oBAAoB;AAAA,MAC/B,YAAY,KAAK,IAAI;AAAA,IACvB;AAAA,EACF,SAAS,GAAG;AAEV,UAAM,eACJ,aAAa,QAAQ,EAAE,UAAU,KAAK,UAAU,KAAK,EAAE;AACzD,UAAM,IAAI,YAAY,+BAA+B,YAAY,EAAE;AAAA,EACrE;AACF;AAgBA,eAAsB,aACpB,YACA,WACA,UACA,KACyB;AACzB,QAAM,oBAAoB,qBAAqB,UAAU,GAAG;AAE5D,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,mBAAmB;AAAA,MAC9C,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA;AAAA;AAAA,QAGA,aAAa;AAAA,MACf,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,eAAgB,MAAM,SAAS,KAAK;AAC1C,YAAM,IAAI;AAAA,QACR,GAAG,QAAQ,sBAAsB,aAAa,OAAO,iBAAiB,aAAa,KAAK;AAAA,MAC1F;AAAA,IACF;AAEA,UAAM,gBAAgB,MAAM,SAAS,KAAK;AAC1C,WAAO;AAAA,MACL,OAAO,cAAc;AAAA,MACrB,WAAW,cAAc;AAAA,MACzB,SAAS;AAAA,QACP,cAAc,cAAc,QAAQ;AAAA,QACpC,eAAe,cAAc,QAAQ;AAAA,QACrC,WAAW,cAAc,QAAQ;AAAA,MACnC;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AAEV,UAAM,eACJ,aAAa,QAAQ,EAAE,UAAU,KAAK,UAAU,KAAK,EAAE;AACzD,UAAM,IAAI,YAAY,gCAAgC,YAAY,EAAE;AAAA,EACtE;AACF;","names":[]}
|
package/dist/chunk-ZUPTMFEA.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LOCALIZED_DEFAULT_ACCOUNT_NAMES,
|
|
3
|
-
USER_STORAGE_VERSION,
|
|
4
|
-
USER_STORAGE_VERSION_KEY
|
|
5
|
-
} from "./chunk-EHZFPUJH.mjs";
|
|
6
|
-
|
|
7
|
-
// src/controllers/user-storage/accounts/user-storage.ts
|
|
8
|
-
var isNameDefaultAccountName = (name) => {
|
|
9
|
-
return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {
|
|
10
|
-
return new RegExp(`^${prefix} ([0-9]+)$`, "u").test(name);
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var mapInternalAccountToUserStorageAccount = (internalAccount) => {
|
|
14
|
-
const { address, id, metadata } = internalAccount;
|
|
15
|
-
return {
|
|
16
|
-
[USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,
|
|
17
|
-
a: address,
|
|
18
|
-
i: id,
|
|
19
|
-
n: metadata.name,
|
|
20
|
-
nlu: metadata.nameLastUpdatedAt
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
isNameDefaultAccountName,
|
|
26
|
-
mapInternalAccountToUserStorageAccount
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=chunk-ZUPTMFEA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/controllers/user-storage/accounts/user-storage.ts"],"sourcesContent":["import type { InternalAccount } from '@metamask/keyring-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\n\nexport type UserStorageAccount = {\n /**\n * The Version 'v' of the User Storage.\n * NOTE - will allow us to support upgrade/downgrades in the future\n */\n [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;\n /** the id 'i' of the account */\n i: string;\n /** the address 'a' of the account */\n a: string;\n /** the name 'n' of the account */\n n: string;\n /** the nameLastUpdatedAt timestamp 'nlu' of the account */\n nlu?: number;\n};\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: metadata.name,\n nlu: metadata.nameLastUpdatedAt,\n };\n};\n"],"mappings":";;;;;;;AAgCO,IAAM,2BAA2B,CAAC,SAAiB;AACxD,SAAO,gCAAgC,KAAK,CAAC,WAAW;AACtD,WAAO,IAAI,OAAO,IAAI,MAAM,cAAc,GAAG,EAAE,KAAK,IAAI;AAAA,EAC1D,CAAC;AACH;AAOO,IAAM,yCAAyC,CACpD,oBACuB;AACvB,QAAM,EAAE,SAAS,IAAI,SAAS,IAAI;AAClC,SAAO;AAAA,IACL,CAAC,wBAAwB,GAAG;AAAA,IAC5B,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG,SAAS;AAAA,IACZ,KAAK,SAAS;AAAA,EAChB;AACF;","names":[]}
|
package/dist/chunk-ZX2KHPXG.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkDF24ZX4Hjs = require('./chunk-DF24ZX4H.js');
|
|
5
|
-
|
|
6
|
-
// src/controllers/authentication/services.ts
|
|
7
|
-
var ENV_URLS = _chunkDF24ZX4Hjs.getEnvUrls.call(void 0, "prd" /* PRD */);
|
|
8
|
-
var AUTH_ENDPOINT = ENV_URLS.authApiUrl;
|
|
9
|
-
var AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;
|
|
10
|
-
var AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;
|
|
11
|
-
var OIDC_ENDPOINT = ENV_URLS.oidcApiUrl || "";
|
|
12
|
-
var OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;
|
|
13
|
-
var OIDC_CLIENT_ID = (platform) => {
|
|
14
|
-
if (platform === "extension") {
|
|
15
|
-
return _chunkDF24ZX4Hjs.getOidcClientId.call(void 0, "prd" /* PRD */, "extension" /* EXTENSION */);
|
|
16
|
-
}
|
|
17
|
-
if (platform === "mobile") {
|
|
18
|
-
return _chunkDF24ZX4Hjs.getOidcClientId.call(void 0, "prd" /* PRD */, "mobile" /* MOBILE */);
|
|
19
|
-
}
|
|
20
|
-
throw new Error(`Unsupported platform - ${platform}`);
|
|
21
|
-
};
|
|
22
|
-
var OIDC_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
23
|
-
async function getNonce(publicKey) {
|
|
24
|
-
const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);
|
|
25
|
-
nonceUrl.searchParams.set("identifier", publicKey);
|
|
26
|
-
try {
|
|
27
|
-
const nonceResponse = await fetch(nonceUrl.toString());
|
|
28
|
-
if (!nonceResponse.ok) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const nonceJson = await nonceResponse.json();
|
|
32
|
-
return nonceJson?.nonce ?? null;
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.error("authentication-controller/services: unable to get nonce", e);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function login(rawMessage, signature, clientMetaMetrics) {
|
|
39
|
-
try {
|
|
40
|
-
const response = await fetch(AUTH_LOGIN_ENDPOINT, {
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": "application/json"
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify({
|
|
46
|
-
signature,
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
48
|
-
raw_message: rawMessage,
|
|
49
|
-
metametrics: {
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
51
|
-
metametrics_id: clientMetaMetrics.metametricsId,
|
|
52
|
-
agent: clientMetaMetrics.agent
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
if (!response.ok) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
const loginResponse = await response.json();
|
|
60
|
-
return loginResponse ?? null;
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.error("authentication-controller/services: unable to login", e);
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async function getAccessToken(jwtToken, platform) {
|
|
67
|
-
const headers = new Headers({
|
|
68
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
69
|
-
});
|
|
70
|
-
const urlEncodedBody = new URLSearchParams();
|
|
71
|
-
urlEncodedBody.append("grant_type", OIDC_GRANT_TYPE);
|
|
72
|
-
urlEncodedBody.append("client_id", OIDC_CLIENT_ID(platform));
|
|
73
|
-
urlEncodedBody.append("assertion", jwtToken);
|
|
74
|
-
try {
|
|
75
|
-
const response = await fetch(OIDC_TOKENS_ENDPOINT, {
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers,
|
|
78
|
-
body: urlEncodedBody.toString()
|
|
79
|
-
});
|
|
80
|
-
if (!response.ok) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const accessTokenResponse = await response.json();
|
|
84
|
-
return accessTokenResponse?.access_token ?? null;
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.error(
|
|
87
|
-
"authentication-controller/services: unable to get access token",
|
|
88
|
-
e
|
|
89
|
-
);
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function createLoginRawMessage(nonce, publicKey) {
|
|
94
|
-
return `metamask:${nonce}:${publicKey}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
exports.AUTH_NONCE_ENDPOINT = AUTH_NONCE_ENDPOINT; exports.AUTH_LOGIN_ENDPOINT = AUTH_LOGIN_ENDPOINT; exports.OIDC_TOKENS_ENDPOINT = OIDC_TOKENS_ENDPOINT; exports.getNonce = getNonce; exports.login = login; exports.getAccessToken = getAccessToken; exports.createLoginRawMessage = createLoginRawMessage;
|
|
106
|
-
//# sourceMappingURL=chunk-ZX2KHPXG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/controllers/authentication/services.ts"],"names":[],"mappings":";;;;;;AAEA,IAAM,WAAW,0BAAkB;AAEnC,IAAM,gBAAwB,SAAS;AAChC,IAAM,sBAAsB,GAAG,aAAa;AAC5C,IAAM,sBAAsB,GAAG,aAAa;AAEnD,IAAM,gBAAwB,SAAS,cAAc;AAC9C,IAAM,uBAAuB,GAAG,aAAa;AACpD,IAAM,iBAAiB,CAAC,aAAqC;AAC3D,MAAI,aAAa,aAAa;AAC5B,WAAO,4DAA2C;AAAA,EACpD;AACA,MAAI,aAAa,UAAU;AACzB,WAAO,sDAAwC;AAAA,EACjD;AAEA,QAAM,IAAI,MAAM,0BAA0B,QAAkB,EAAE;AAChE;AACA,IAAM,kBAAkB;AAYxB,eAAsB,SAAS,WAA2C;AACxE,QAAM,WAAW,IAAI,IAAI,mBAAmB;AAC5C,WAAS,aAAa,IAAI,cAAc,SAAS;AAEjD,MAAI;AACF,UAAM,gBAAgB,MAAM,MAAM,SAAS,SAAS,CAAC;AACrD,QAAI,CAAC,cAAc,IAAI;AACrB,aAAO;AAAA,IACT;AAEA,UAAM,YAA2B,MAAM,cAAc,KAAK;AAC1D,WAAO,WAAW,SAAS;AAAA,EAC7B,SAAS,GAAG;AACV,YAAQ,MAAM,2DAA2D,CAAC;AAC1E,WAAO;AAAA,EACT;AACF;AAqCA,eAAsB,MACpB,YACA,WACA,mBAC+B;AAC/B,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,qBAAqB;AAAA,MAChD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA;AAAA,QAEA,aAAa;AAAA,QACb,aAAa;AAAA;AAAA,UAEX,gBAAgB,kBAAkB;AAAA,UAClC,OAAO,kBAAkB;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO;AAAA,IACT;AAEA,UAAM,gBAA+B,MAAM,SAAS,KAAK;AACzD,WAAO,iBAAiB;AAAA,EAC1B,SAAS,GAAG;AACV,YAAQ,MAAM,uDAAuD,CAAC;AACtE,WAAO;AAAA,EACT;AACF;AAoBA,eAAsB,eACpB,UACA,UACwB;AACxB,QAAM,UAAU,IAAI,QAAQ;AAAA,IAC1B,gBAAgB;AAAA,EAClB,CAAC;AAED,QAAM,iBAAiB,IAAI,gBAAgB;AAC3C,iBAAe,OAAO,cAAc,eAAe;AACnD,iBAAe,OAAO,aAAa,eAAe,QAAQ,CAAC;AAC3D,iBAAe,OAAO,aAAa,QAAQ;AAE3C,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,sBAAsB;AAAA,MACjD,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,eAAe,SAAS;AAAA,IAChC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO;AAAA,IACT;AAEA,UAAM,sBAA0C,MAAM,SAAS,KAAK;AACpE,WAAO,qBAAqB,gBAAgB;AAAA,EAC9C,SAAS,GAAG;AACV,YAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AASO,SAAS,sBACd,OACA,WACgC;AAChC,SAAO,YAAY,KAAK,IAAI,SAAS;AACvC","sourcesContent":["import { Env, Platform, getEnvUrls, getOidcClientId } from '../../sdk/env';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nconst AUTH_ENDPOINT: string = ENV_URLS.authApiUrl;\nexport const AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;\nexport const AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;\n\nconst OIDC_ENDPOINT: string = ENV_URLS.oidcApiUrl || '';\nexport const OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;\nconst OIDC_CLIENT_ID = (platform: 'mobile' | 'extension') => {\n if (platform === 'extension') {\n return getOidcClientId(Env.PRD, Platform.EXTENSION);\n }\n if (platform === 'mobile') {\n return getOidcClientId(Env.PRD, Platform.MOBILE);\n }\n\n throw new Error(`Unsupported platform - ${platform as string}`);\n};\nconst OIDC_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n\nexport type NonceResponse = {\n nonce: string;\n};\n\n/**\n * Auth Service - Get Nonce. Used for the initial JWTBearer flow\n *\n * @param publicKey - public key to associate a nonce with\n * @returns the nonce or null if failed\n */\nexport async function getNonce(publicKey: string): Promise<string | null> {\n const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);\n nonceUrl.searchParams.set('identifier', publicKey);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n return null;\n }\n\n const nonceJson: NonceResponse = await nonceResponse.json();\n return nonceJson?.nonce ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to get nonce', e);\n return null;\n }\n}\n\n/**\n * The Login API Server Response Shape\n */\nexport type LoginResponse = {\n token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: string;\n /**\n * Contains anonymous information about the logged in profile.\n *\n * @property identifier_id - a deterministic unique identifier on the method used to sign in\n * @property profile_id - a unique id for a given profile\n * @property metametrics_id - an anonymous server id\n */\n profile: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: string;\n };\n};\n\ntype ClientMetaMetrics = {\n metametricsId: string;\n agent: 'extension' | 'mobile';\n};\n\n/**\n * Auth Service - Login. Will perform login with a given signature and will return a single use JWT Token.\n *\n * @param rawMessage - the original message before signing\n * @param signature - the signed message\n * @param clientMetaMetrics - optional client metametrics id (to associate on backend)\n * @returns The Login Response\n */\nexport async function login(\n rawMessage: string,\n signature: string,\n clientMetaMetrics: ClientMetaMetrics,\n): Promise<LoginResponse | null> {\n try {\n const response = await fetch(AUTH_LOGIN_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: rawMessage,\n metametrics: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: clientMetaMetrics.metametricsId,\n agent: clientMetaMetrics.agent,\n },\n }),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const loginResponse: LoginResponse = await response.json();\n return loginResponse ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to login', e);\n return null;\n }\n}\n\n/**\n * The Auth API Token Response Shape\n */\nexport type OAuthTokenResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n access_token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: number;\n};\n\n/**\n * OIDC Service - Access Token. Trades the Auth Token for an access token (to be used for other authenticated endpoints)\n * NOTE - the access token is short lived, which means it is best practice to validate session before calling authenticated endpoints\n *\n * @param jwtToken - the JWT Auth Token, received from `/login`\n * @param platform - the OIDC platform to retrieve access token\n * @returns JWT Access token to store and use on authorized endpoints.\n */\nexport async function getAccessToken(\n jwtToken: string,\n platform: ClientMetaMetrics['agent'],\n): Promise<string | null> {\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', OIDC_GRANT_TYPE);\n urlEncodedBody.append('client_id', OIDC_CLIENT_ID(platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKENS_ENDPOINT, {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const accessTokenResponse: OAuthTokenResponse = await response.json();\n return accessTokenResponse?.access_token ?? null;\n } catch (e) {\n console.error(\n 'authentication-controller/services: unable to get access token',\n e,\n );\n return null;\n }\n}\n\n/**\n * Utility to create the raw login message for the JWT bearer flow (via SRP)\n *\n * @param nonce - nonce received from `/nonce` endpoint\n * @param publicKey - public key used to retrieve nonce and for message signing\n * @returns Raw Message which will be used for signing & logging in.\n */\nexport function createLoginRawMessage(\n nonce: string,\n publicKey: string,\n): `metamask:${string}:${string}` {\n return `metamask:${nonce}:${publicKey}` as const;\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkF6BAOSH2js = require('../../chunk-F6BAOSH2.js');
|
|
5
|
-
require('../../chunk-ZX2KHPXG.js');
|
|
6
|
-
require('../../chunk-YHGWG3EQ.js');
|
|
7
|
-
require('../../chunk-DF24ZX4H.js');
|
|
8
|
-
require('../../chunk-IGY2S5BC.js');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.default = _chunkF6BAOSH2js.AuthenticationController; exports.defaultState = _chunkF6BAOSH2js.defaultState;
|
|
13
|
-
//# sourceMappingURL=AuthenticationController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkYHGWG3EQjs = require('../../chunk-YHGWG3EQ.js');
|
|
5
|
-
require('../../chunk-IGY2S5BC.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.createSnapPublicKeyRequest = _chunkYHGWG3EQjs.createSnapPublicKeyRequest; exports.createSnapSignMessageRequest = _chunkYHGWG3EQjs.createSnapSignMessageRequest;
|
|
10
|
-
//# sourceMappingURL=auth-snap-requests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkPRYLTXW4js = require('../../chunk-PRYLTXW4.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkF6BAOSH2js = require('../../chunk-F6BAOSH2.js');
|
|
9
|
-
require('../../chunk-ZX2KHPXG.js');
|
|
10
|
-
require('../../chunk-YHGWG3EQ.js');
|
|
11
|
-
require('../../chunk-DF24ZX4H.js');
|
|
12
|
-
require('../../chunk-IGY2S5BC.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.Controller = _chunkF6BAOSH2js.AuthenticationController; exports.Mocks = _chunkPRYLTXW4js.fixtures_exports; exports.default = _chunkPRYLTXW4js.authentication_default; exports.defaultState = _chunkF6BAOSH2js.defaultState;
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkZX2KHPXGjs = require('../../chunk-ZX2KHPXG.js');
|
|
10
|
-
require('../../chunk-DF24ZX4H.js');
|
|
11
|
-
require('../../chunk-IGY2S5BC.js');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
exports.AUTH_LOGIN_ENDPOINT = _chunkZX2KHPXGjs.AUTH_LOGIN_ENDPOINT; exports.AUTH_NONCE_ENDPOINT = _chunkZX2KHPXGjs.AUTH_NONCE_ENDPOINT; exports.OIDC_TOKENS_ENDPOINT = _chunkZX2KHPXGjs.OIDC_TOKENS_ENDPOINT; exports.createLoginRawMessage = _chunkZX2KHPXGjs.createLoginRawMessage; exports.getAccessToken = _chunkZX2KHPXGjs.getAccessToken; exports.getNonce = _chunkZX2KHPXGjs.getNonce; exports.login = _chunkZX2KHPXGjs.login;
|
|
21
|
-
//# sourceMappingURL=services.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkPRYLTXW4js = require('../chunk-PRYLTXW4.js');
|
|
4
|
-
require('../chunk-F6BAOSH2.js');
|
|
5
|
-
require('../chunk-ZX2KHPXG.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkCHUZGCDVjs = require('../chunk-CHUZGCDV.js');
|
|
9
|
-
require('../chunk-246Z6L5V.js');
|
|
10
|
-
require('../chunk-GQXYWBFK.js');
|
|
11
|
-
require('../chunk-JAQ5TPSZ.js');
|
|
12
|
-
require('../chunk-YHGWG3EQ.js');
|
|
13
|
-
require('../chunk-4LMFZDL4.js');
|
|
14
|
-
require('../chunk-5MQUI24U.js');
|
|
15
|
-
require('../chunk-NIUQ34PY.js');
|
|
16
|
-
require('../chunk-BKQE7DB5.js');
|
|
17
|
-
require('../chunk-UAXWZN5J.js');
|
|
18
|
-
require('../chunk-PCOIRDTO.js');
|
|
19
|
-
require('../chunk-DF24ZX4H.js');
|
|
20
|
-
require('../chunk-IGY2S5BC.js');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.Authentication = _chunkPRYLTXW4js.authentication_exports; exports.UserStorage = _chunkCHUZGCDVjs.user_storage_exports;
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunk246Z6L5Vjs = require('../../chunk-246Z6L5V.js');
|
|
5
|
-
require('../../chunk-GQXYWBFK.js');
|
|
6
|
-
require('../../chunk-JAQ5TPSZ.js');
|
|
7
|
-
require('../../chunk-YHGWG3EQ.js');
|
|
8
|
-
require('../../chunk-4LMFZDL4.js');
|
|
9
|
-
require('../../chunk-5MQUI24U.js');
|
|
10
|
-
require('../../chunk-NIUQ34PY.js');
|
|
11
|
-
require('../../chunk-BKQE7DB5.js');
|
|
12
|
-
require('../../chunk-UAXWZN5J.js');
|
|
13
|
-
require('../../chunk-PCOIRDTO.js');
|
|
14
|
-
require('../../chunk-DF24ZX4H.js');
|
|
15
|
-
require('../../chunk-IGY2S5BC.js');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.default = _chunk246Z6L5Vjs.UserStorageController; exports.defaultState = _chunk246Z6L5Vjs.defaultState;
|
|
20
|
-
//# sourceMappingURL=UserStorageController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkJAQ5TPSZjs = require('../../../chunk-JAQ5TPSZ.js');
|
|
6
|
-
require('../../../chunk-IGY2S5BC.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.LOCALIZED_DEFAULT_ACCOUNT_NAMES = _chunkJAQ5TPSZjs.LOCALIZED_DEFAULT_ACCOUNT_NAMES; exports.USER_STORAGE_VERSION = _chunkJAQ5TPSZjs.USER_STORAGE_VERSION; exports.USER_STORAGE_VERSION_KEY = _chunkJAQ5TPSZjs.USER_STORAGE_VERSION_KEY;
|
|
12
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkGQXYWBFKjs = require('../../../chunk-GQXYWBFK.js');
|
|
5
|
-
require('../../../chunk-JAQ5TPSZ.js');
|
|
6
|
-
require('../../../chunk-IGY2S5BC.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.isNameDefaultAccountName = _chunkGQXYWBFKjs.isNameDefaultAccountName; exports.mapInternalAccountToUserStorageAccount = _chunkGQXYWBFKjs.mapInternalAccountToUserStorageAccount;
|
|
11
|
-
//# sourceMappingURL=user-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|