@metamask/profile-sync-controller 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/auth/mocks/package.json +2 -2
- package/auth/package.json +2 -2
- package/dist/controllers/authentication/AuthenticationController.cjs +211 -0
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
- package/dist/{types/controllers/authentication/AuthenticationController.d.ts → controllers/authentication/AuthenticationController.d.cts} +5 -5
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.d.mts +78 -0
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.mjs +206 -11
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/__fixtures__/index.cjs +18 -0
- package/dist/controllers/authentication/__fixtures__/index.cjs.map +1 -0
- package/dist/controllers/authentication/__fixtures__/index.d.cts +2 -0
- package/dist/controllers/authentication/__fixtures__/index.d.cts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/index.d.mts +2 -0
- package/dist/controllers/authentication/__fixtures__/index.d.mts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/index.mjs +2 -0
- package/dist/controllers/authentication/__fixtures__/index.mjs.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +52 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -0
- package/dist/{types/controllers/authentication/__fixtures__/mockResponses.d.ts → controllers/authentication/__fixtures__/mockResponses.d.cts} +2 -2
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts +23 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +46 -0
- package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.cjs +37 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.cjs.map +1 -0
- package/dist/{types/controllers/authentication/__fixtures__/mockServices.d.ts → controllers/authentication/__fixtures__/mockServices.d.cts} +2 -2
- package/dist/controllers/authentication/__fixtures__/mockServices.d.cts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.d.mts +10 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.d.mts.map +1 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.mjs +35 -0
- package/dist/controllers/authentication/__fixtures__/mockServices.mjs.map +1 -0
- package/dist/controllers/authentication/auth-snap-requests.cjs +39 -0
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -0
- package/dist/{types/controllers/authentication/auth-snap-requests.d.ts → controllers/authentication/auth-snap-requests.d.cts} +2 -2
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -0
- package/dist/controllers/authentication/auth-snap-requests.d.mts +17 -0
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -0
- package/dist/controllers/authentication/auth-snap-requests.mjs +33 -9
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
- package/dist/controllers/authentication/index.cjs +39 -0
- package/dist/controllers/authentication/index.cjs.map +1 -0
- package/dist/controllers/authentication/index.d.cts +7 -0
- package/dist/controllers/authentication/index.d.cts.map +1 -0
- package/dist/controllers/authentication/index.d.mts +7 -0
- package/dist/controllers/authentication/index.d.mts.map +1 -0
- package/dist/controllers/authentication/index.mjs +6 -18
- package/dist/controllers/authentication/index.mjs.map +1 -1
- package/dist/controllers/authentication/services.cjs +127 -0
- package/dist/controllers/authentication/services.cjs.map +1 -0
- package/dist/{types/controllers/authentication/services.d.ts → controllers/authentication/services.d.cts} +1 -1
- package/dist/controllers/authentication/services.d.cts.map +1 -0
- package/dist/controllers/authentication/services.d.mts +70 -0
- package/dist/controllers/authentication/services.d.mts.map +1 -0
- package/dist/controllers/authentication/services.mjs +118 -19
- package/dist/controllers/authentication/services.mjs.map +1 -1
- package/dist/controllers/index.cjs +29 -0
- package/dist/controllers/index.cjs.map +1 -0
- package/dist/controllers/index.d.cts +3 -0
- package/dist/controllers/index.d.cts.map +1 -0
- package/dist/controllers/index.d.mts +3 -0
- package/dist/controllers/index.d.mts.map +1 -0
- package/dist/controllers/index.mjs +2 -24
- package/dist/controllers/index.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +462 -0
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/UserStorageController.d.ts → controllers/user-storage/UserStorageController.d.cts} +44 -15
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.d.mts +156 -0
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.mjs +457 -18
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/index.cjs +19 -0
- package/dist/controllers/user-storage/__fixtures__/index.cjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.cts +3 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.mts +3 -0
- package/dist/controllers/user-storage/__fixtures__/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/index.mjs +3 -0
- package/dist/controllers/user-storage/__fixtures__/index.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs +127 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockAccounts.d.ts → controllers/user-storage/__fixtures__/mockAccounts.d.cts} +6 -6
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts +63 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs +123 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +48 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockResponses.d.ts → controllers/user-storage/__fixtures__/mockResponses.d.cts} +6 -4
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +21 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +39 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +41 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockServices.d.ts → controllers/user-storage/__fixtures__/mockServices.d.cts} +3 -3
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +11 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +39 -0
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs +36 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/__fixtures__/mockStorage.d.ts → controllers/user-storage/__fixtures__/mockStorage.d.cts} +2 -2
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts +5 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs +9 -0
- package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +31 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +14 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +14 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +27 -0
- package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.cjs +51 -0
- package/dist/controllers/user-storage/accounts/constants.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/accounts/constants.d.ts → controllers/user-storage/accounts/constants.d.cts} +1 -1
- package/dist/controllers/user-storage/accounts/constants.d.cts.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.d.mts +4 -0
- package/dist/controllers/user-storage/accounts/constants.d.mts.map +1 -0
- package/dist/controllers/user-storage/accounts/constants.mjs +47 -11
- package/dist/controllers/user-storage/accounts/constants.mjs.map +1 -1
- package/dist/controllers/user-storage/accounts/user-storage.cjs +34 -0
- package/dist/controllers/user-storage/accounts/user-storage.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/accounts/user-storage.d.ts → controllers/user-storage/accounts/user-storage.d.cts} +3 -3
- package/dist/controllers/user-storage/accounts/user-storage.d.cts.map +1 -0
- package/dist/controllers/user-storage/accounts/user-storage.d.mts +32 -0
- package/dist/controllers/user-storage/accounts/user-storage.d.mts.map +1 -0
- package/dist/controllers/user-storage/accounts/user-storage.mjs +27 -9
- package/dist/controllers/user-storage/accounts/user-storage.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/cache.cjs +79 -0
- package/dist/controllers/user-storage/encryption/cache.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/encryption/cache.d.ts → controllers/user-storage/encryption/cache.d.cts} +1 -1
- package/dist/controllers/user-storage/encryption/cache.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/cache.d.mts +31 -0
- package/dist/controllers/user-storage/encryption/cache.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/cache.mjs +71 -11
- package/dist/controllers/user-storage/encryption/cache.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/encryption.cjs +151 -0
- package/dist/controllers/user-storage/encryption/encryption.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/encryption/encryption.d.ts → controllers/user-storage/encryption/encryption.d.cts} +2 -2
- package/dist/controllers/user-storage/encryption/encryption.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/encryption.d.mts +27 -0
- package/dist/controllers/user-storage/encryption/encryption.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/encryption.mjs +145 -10
- package/dist/controllers/user-storage/encryption/encryption.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/index.cjs +25 -0
- package/dist/controllers/user-storage/encryption/index.cjs.map +1 -0
- package/dist/controllers/user-storage/encryption/index.d.cts +5 -0
- package/dist/controllers/user-storage/encryption/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/index.d.mts +5 -0
- package/dist/controllers/user-storage/encryption/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/index.mjs +4 -15
- package/dist/controllers/user-storage/encryption/index.mjs.map +1 -1
- package/dist/controllers/user-storage/encryption/utils.cjs +17 -0
- package/dist/controllers/user-storage/encryption/utils.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/encryption/utils.d.ts → controllers/user-storage/encryption/utils.d.cts} +1 -1
- package/dist/controllers/user-storage/encryption/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/encryption/utils.d.mts +4 -0
- package/dist/controllers/user-storage/encryption/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/encryption/utils.mjs +9 -10
- package/dist/controllers/user-storage/encryption/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/index.cjs +40 -0
- package/dist/controllers/user-storage/index.cjs.map +1 -0
- package/dist/controllers/user-storage/index.d.cts +8 -0
- package/dist/controllers/user-storage/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/index.d.mts +8 -0
- package/dist/controllers/user-storage/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/index.mjs +7 -30
- package/dist/controllers/user-storage/index.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs +25 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts +4 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts +4 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs +20 -0
- package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +65 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +13 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +13 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +65 -0
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.cjs +64 -0
- package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.d.cts +21 -0
- package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.d.mts +21 -0
- package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/services.mjs +58 -0
- package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.cjs +171 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.cts +35 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.mts +35 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.mjs +162 -0
- package/dist/controllers/user-storage/network-syncing/sync-all.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs +28 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +9 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +9 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs +22 -0
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.cjs +16 -0
- package/dist/controllers/user-storage/network-syncing/types.cjs.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.d.cts +18 -0
- package/dist/controllers/user-storage/network-syncing/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.d.mts +18 -0
- package/dist/controllers/user-storage/network-syncing/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/network-syncing/types.mjs +11 -0
- package/dist/controllers/user-storage/network-syncing/types.mjs.map +1 -0
- package/dist/controllers/user-storage/schema.cjs +56 -0
- package/dist/controllers/user-storage/schema.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/schema.d.ts → controllers/user-storage/schema.d.cts} +2 -1
- package/dist/controllers/user-storage/schema.d.cts.map +1 -0
- package/dist/controllers/user-storage/schema.d.mts +38 -0
- package/dist/controllers/user-storage/schema.d.mts.map +1 -0
- package/dist/controllers/user-storage/schema.mjs +48 -16
- package/dist/controllers/user-storage/schema.mjs.map +1 -1
- package/dist/controllers/user-storage/services.cjs +119 -0
- package/dist/controllers/user-storage/services.cjs.map +1 -0
- package/dist/{types/controllers/user-storage/services.d.ts → controllers/user-storage/services.d.cts} +4 -5
- package/dist/controllers/user-storage/services.d.cts.map +1 -0
- package/dist/controllers/user-storage/services.d.mts +48 -0
- package/dist/controllers/user-storage/services.d.mts.map +1 -0
- package/dist/controllers/user-storage/services.mjs +116 -21
- package/dist/controllers/user-storage/services.mjs.map +1 -1
- package/dist/controllers/user-storage/utils.cjs +30 -0
- package/dist/controllers/user-storage/utils.cjs.map +1 -0
- package/dist/controllers/user-storage/utils.d.cts +17 -0
- package/dist/controllers/user-storage/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/utils.d.mts +17 -0
- package/dist/controllers/user-storage/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/utils.mjs +25 -0
- package/dist/controllers/user-storage/utils.mjs.map +1 -0
- package/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -39
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-auth.cjs +139 -0
- package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -0
- package/dist/{types/sdk/__fixtures__/mock-auth.d.ts → sdk/__fixtures__/mock-auth.d.cts} +2 -2
- package/dist/sdk/__fixtures__/mock-auth.d.cts.map +1 -0
- package/dist/sdk/__fixtures__/mock-auth.d.mts +42 -0
- package/dist/sdk/__fixtures__/mock-auth.d.mts.map +1 -0
- package/dist/sdk/__fixtures__/mock-auth.mjs +134 -0
- package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -0
- package/dist/sdk/__fixtures__/mock-userstorage.cjs +58 -0
- package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -0
- package/dist/{types/sdk/__fixtures__/mock-userstorage.d.ts → sdk/__fixtures__/mock-userstorage.d.cts} +2 -2
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -0
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts +19 -0
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -0
- package/dist/sdk/__fixtures__/mock-userstorage.mjs +54 -0
- package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -0
- package/dist/sdk/__fixtures__/test-utils.cjs +74 -0
- package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -0
- package/dist/{types/sdk/__fixtures__/test-utils.d.ts → sdk/__fixtures__/test-utils.d.cts} +6 -6
- package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -0
- package/dist/sdk/__fixtures__/test-utils.d.mts +25 -0
- package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -0
- package/dist/sdk/__fixtures__/test-utils.mjs +69 -0
- package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +106 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/flow-siwe.d.ts → sdk/authentication-jwt-bearer/flow-siwe.d.cts} +2 -2
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +23 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +101 -11
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +125 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/flow-srp.d.ts → sdk/authentication-jwt-bearer/flow-srp.d.cts} +4 -2
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +19 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +119 -13
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +180 -0
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/services.d.ts → sdk/authentication-jwt-bearer/services.d.cts} +4 -4
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +63 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.mjs +166 -25
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
- package/dist/{types/sdk/authentication-jwt-bearer/types.d.ts → sdk/authentication-jwt-bearer/types.d.cts} +2 -2
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +67 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/types.mjs +8 -7
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +124 -0
- package/dist/sdk/authentication.cjs.map +1 -0
- package/dist/{types/sdk/authentication.d.ts → sdk/authentication.d.cts} +7 -7
- package/dist/sdk/authentication.d.cts.map +1 -0
- package/dist/sdk/authentication.d.mts +32 -0
- package/dist/sdk/authentication.d.mts.map +1 -0
- package/dist/sdk/authentication.mjs +102 -24
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/encryption.cjs +23 -0
- package/dist/sdk/encryption.cjs.map +1 -0
- package/dist/sdk/encryption.d.cts +4 -0
- package/dist/sdk/encryption.d.cts.map +1 -0
- package/dist/sdk/encryption.d.mts +4 -0
- package/dist/sdk/encryption.d.mts.map +1 -0
- package/dist/sdk/encryption.mjs +3 -13
- package/dist/sdk/encryption.mjs.map +1 -1
- package/dist/sdk/env.cjs +85 -0
- package/dist/sdk/env.cjs.map +1 -0
- package/dist/{types/sdk/env.d.ts → sdk/env.d.cts} +1 -1
- package/dist/sdk/env.d.cts.map +1 -0
- package/dist/sdk/env.d.mts +34 -0
- package/dist/sdk/env.d.mts.map +1 -0
- package/dist/sdk/env.mjs +78 -12
- package/dist/sdk/env.mjs.map +1 -1
- package/dist/sdk/errors.cjs +53 -0
- package/dist/sdk/errors.cjs.map +1 -0
- package/dist/{types/sdk/errors.d.ts → sdk/errors.d.cts} +1 -1
- package/dist/sdk/errors.d.cts.map +1 -0
- package/dist/sdk/errors.d.mts +22 -0
- package/dist/sdk/errors.d.mts.map +1 -0
- package/dist/sdk/errors.mjs +42 -19
- package/dist/sdk/errors.mjs.map +1 -1
- package/dist/sdk/index.cjs +23 -0
- package/dist/sdk/index.cjs.map +1 -0
- package/dist/sdk/index.d.cts +7 -0
- package/dist/sdk/index.d.cts.map +1 -0
- package/dist/sdk/index.d.mts +7 -0
- package/dist/sdk/index.d.mts.map +1 -0
- package/dist/sdk/index.mjs +6 -78
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +176 -0
- package/dist/sdk/user-storage.cjs.map +1 -0
- package/dist/{types/sdk/user-storage.d.ts → sdk/user-storage.d.cts} +4 -4
- package/dist/sdk/user-storage.d.cts.map +1 -0
- package/dist/sdk/user-storage.d.mts +27 -0
- package/dist/sdk/user-storage.d.mts.map +1 -0
- package/dist/sdk/user-storage.mjs +146 -16
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.cjs +70 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -0
- package/dist/{types/sdk/utils/eip-6963-metamask-provider.d.ts → sdk/utils/eip-6963-metamask-provider.d.cts} +2 -2
- package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +1 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +25 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +1 -0
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs +64 -8
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +73 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
- package/dist/{types/sdk/utils/messaging-signing-snap-requests.d.ts → sdk/utils/messaging-signing-snap-requests.d.cts} +2 -7
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +35 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +65 -16
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/sdk/utils/validate-login-response.cjs +22 -0
- package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
- package/dist/{types/sdk/utils/validate-login-response.d.ts → sdk/utils/validate-login-response.d.cts} +2 -2
- package/dist/sdk/utils/validate-login-response.d.cts.map +1 -0
- package/dist/sdk/utils/validate-login-response.d.mts +10 -0
- package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
- package/dist/sdk/utils/validate-login-response.mjs +17 -7
- package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
- package/package.json +62 -30
- package/sdk/package.json +9 -0
- package/user-storage/mocks/package.json +2 -2
- package/user-storage/package.json +2 -2
- package/dist/chunk-2CWF7ZTL.mjs +0 -129
- package/dist/chunk-2CWF7ZTL.mjs.map +0 -1
- package/dist/chunk-2VEMA6OE.mjs +0 -47
- package/dist/chunk-2VEMA6OE.mjs.map +0 -1
- package/dist/chunk-4LMFZDL4.js +0 -114
- package/dist/chunk-4LMFZDL4.js.map +0 -1
- package/dist/chunk-4TMLEABQ.js +0 -79
- package/dist/chunk-4TMLEABQ.js.map +0 -1
- package/dist/chunk-5MQUI24U.js +0 -47
- package/dist/chunk-5MQUI24U.js.map +0 -1
- package/dist/chunk-5XSXZTED.mjs +0 -57
- package/dist/chunk-5XSXZTED.mjs.map +0 -1
- package/dist/chunk-6DAK2U35.mjs +0 -11
- package/dist/chunk-6DAK2U35.mjs.map +0 -1
- package/dist/chunk-76NMME23.mjs +0 -114
- package/dist/chunk-76NMME23.mjs.map +0 -1
- package/dist/chunk-76VRE4BI.mjs +0 -18
- package/dist/chunk-76VRE4BI.mjs.map +0 -1
- package/dist/chunk-BKQE7DB5.js +0 -170
- package/dist/chunk-BKQE7DB5.js.map +0 -1
- package/dist/chunk-CAIIVJAO.mjs +0 -11
- package/dist/chunk-CAIIVJAO.mjs.map +0 -1
- package/dist/chunk-COBJUBZE.mjs +0 -170
- package/dist/chunk-COBJUBZE.mjs.map +0 -1
- package/dist/chunk-D4SNJOID.mjs +0 -269
- package/dist/chunk-D4SNJOID.mjs.map +0 -1
- package/dist/chunk-DF24ZX4H.js +0 -76
- package/dist/chunk-DF24ZX4H.js.map +0 -1
- package/dist/chunk-DRB2MN4T.js +0 -16
- package/dist/chunk-DRB2MN4T.js.map +0 -1
- package/dist/chunk-EHZFPUJH.mjs +0 -53
- package/dist/chunk-EHZFPUJH.mjs.map +0 -1
- package/dist/chunk-F6BAOSH2.js +0 -269
- package/dist/chunk-F6BAOSH2.js.map +0 -1
- package/dist/chunk-GQXYWBFK.js +0 -28
- package/dist/chunk-GQXYWBFK.js.map +0 -1
- package/dist/chunk-H25EBXG5.mjs +0 -58
- package/dist/chunk-H25EBXG5.mjs.map +0 -1
- package/dist/chunk-IGY2S5BC.js +0 -36
- package/dist/chunk-IGY2S5BC.js.map +0 -1
- package/dist/chunk-JAQ5TPSZ.js +0 -53
- package/dist/chunk-JAQ5TPSZ.js.map +0 -1
- package/dist/chunk-KHASG4H3.mjs +0 -11
- package/dist/chunk-KHASG4H3.mjs.map +0 -1
- package/dist/chunk-KIVBL6OM.js +0 -129
- package/dist/chunk-KIVBL6OM.js.map +0 -1
- package/dist/chunk-KTCSRECK.mjs +0 -76
- package/dist/chunk-KTCSRECK.mjs.map +0 -1
- package/dist/chunk-LGXQBALM.mjs +0 -106
- package/dist/chunk-LGXQBALM.mjs.map +0 -1
- package/dist/chunk-LLG4D2SC.js +0 -157
- package/dist/chunk-LLG4D2SC.js.map +0 -1
- package/dist/chunk-M7AUA5W7.mjs +0 -79
- package/dist/chunk-M7AUA5W7.mjs.map +0 -1
- package/dist/chunk-MBTBE4P5.js +0 -54
- package/dist/chunk-MBTBE4P5.js.map +0 -1
- package/dist/chunk-MK7ABX2V.mjs +0 -186
- package/dist/chunk-MK7ABX2V.mjs.map +0 -1
- package/dist/chunk-NEBLEB3X.mjs +0 -107
- package/dist/chunk-NEBLEB3X.mjs.map +0 -1
- package/dist/chunk-NIUQ34PY.js +0 -11
- package/dist/chunk-NIUQ34PY.js.map +0 -1
- package/dist/chunk-NMIF3LSX.mjs +0 -29
- package/dist/chunk-NMIF3LSX.mjs.map +0 -1
- package/dist/chunk-OLFO6R7Z.mjs +0 -546
- package/dist/chunk-OLFO6R7Z.mjs.map +0 -1
- package/dist/chunk-PBRUOBEQ.js +0 -11
- package/dist/chunk-PBRUOBEQ.js.map +0 -1
- package/dist/chunk-PCOIRDTO.js +0 -18
- package/dist/chunk-PCOIRDTO.js.map +0 -1
- package/dist/chunk-PQMPSEVJ.js +0 -546
- package/dist/chunk-PQMPSEVJ.js.map +0 -1
- package/dist/chunk-PRYLTXW4.js +0 -92
- package/dist/chunk-PRYLTXW4.js.map +0 -1
- package/dist/chunk-PU7MAIST.mjs +0 -129
- package/dist/chunk-PU7MAIST.mjs.map +0 -1
- package/dist/chunk-QCQU4BQL.js +0 -68
- package/dist/chunk-QCQU4BQL.js.map +0 -1
- package/dist/chunk-QDGLIUUS.mjs +0 -16
- package/dist/chunk-QDGLIUUS.mjs.map +0 -1
- package/dist/chunk-RG4II6WH.js +0 -57
- package/dist/chunk-RG4II6WH.js.map +0 -1
- package/dist/chunk-TFFQFIJV.mjs +0 -54
- package/dist/chunk-TFFQFIJV.mjs.map +0 -1
- package/dist/chunk-TP7SP3AG.mjs +0 -133
- package/dist/chunk-TP7SP3AG.mjs.map +0 -1
- package/dist/chunk-U5UIDVOO.mjs +0 -36
- package/dist/chunk-U5UIDVOO.mjs.map +0 -1
- package/dist/chunk-UAXWZN5J.js +0 -58
- package/dist/chunk-UAXWZN5J.js.map +0 -1
- package/dist/chunk-UEHMUVQQ.js +0 -133
- package/dist/chunk-UEHMUVQQ.js.map +0 -1
- package/dist/chunk-UEWCUBMX.mjs +0 -68
- package/dist/chunk-UEWCUBMX.mjs.map +0 -1
- package/dist/chunk-UHP2Y32K.mjs +0 -92
- package/dist/chunk-UHP2Y32K.mjs.map +0 -1
- package/dist/chunk-UHX7HJAI.js +0 -11
- package/dist/chunk-UHX7HJAI.js.map +0 -1
- package/dist/chunk-UIRAMHNM.js +0 -186
- package/dist/chunk-UIRAMHNM.js.map +0 -1
- package/dist/chunk-VWDRFRJU.js +0 -107
- package/dist/chunk-VWDRFRJU.js.map +0 -1
- package/dist/chunk-Y45XUW33.js +0 -129
- package/dist/chunk-Y45XUW33.js.map +0 -1
- package/dist/chunk-YHGWG3EQ.js +0 -29
- package/dist/chunk-YHGWG3EQ.js.map +0 -1
- package/dist/chunk-YLURF2PF.mjs +0 -157
- package/dist/chunk-YLURF2PF.mjs.map +0 -1
- package/dist/chunk-ZUPTMFEA.mjs +0 -28
- package/dist/chunk-ZUPTMFEA.mjs.map +0 -1
- package/dist/chunk-ZX2KHPXG.js +0 -106
- package/dist/chunk-ZX2KHPXG.js.map +0 -1
- package/dist/controllers/authentication/AuthenticationController.js +0 -13
- package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.js +0 -10
- package/dist/controllers/authentication/auth-snap-requests.js.map +0 -1
- package/dist/controllers/authentication/index.js +0 -19
- package/dist/controllers/authentication/index.js.map +0 -1
- package/dist/controllers/authentication/services.js +0 -21
- package/dist/controllers/authentication/services.js.map +0 -1
- package/dist/controllers/index.js +0 -25
- package/dist/controllers/index.js.map +0 -1
- package/dist/controllers/user-storage/UserStorageController.js +0 -20
- package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
- package/dist/controllers/user-storage/accounts/constants.js +0 -12
- package/dist/controllers/user-storage/accounts/constants.js.map +0 -1
- package/dist/controllers/user-storage/accounts/user-storage.js +0 -11
- package/dist/controllers/user-storage/accounts/user-storage.js.map +0 -1
- package/dist/controllers/user-storage/encryption/cache.js +0 -13
- package/dist/controllers/user-storage/encryption/cache.js.map +0 -1
- package/dist/controllers/user-storage/encryption/encryption.js +0 -12
- package/dist/controllers/user-storage/encryption/encryption.js.map +0 -1
- package/dist/controllers/user-storage/encryption/index.js +0 -16
- package/dist/controllers/user-storage/encryption/index.js.map +0 -1
- package/dist/controllers/user-storage/encryption/utils.js +0 -12
- package/dist/controllers/user-storage/encryption/utils.js.map +0 -1
- package/dist/controllers/user-storage/index.js +0 -31
- package/dist/controllers/user-storage/index.js.map +0 -1
- package/dist/controllers/user-storage/schema.js +0 -18
- package/dist/controllers/user-storage/schema.js.map +0 -1
- package/dist/controllers/user-storage/services.js +0 -22
- package/dist/controllers/user-storage/services.js.map +0 -1
- package/dist/index.js +0 -40
- package/dist/index.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -13
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -15
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/services.js +0 -27
- package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/types.js +0 -8
- package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
- package/dist/sdk/authentication.js +0 -26
- package/dist/sdk/authentication.js.map +0 -1
- package/dist/sdk/encryption.js +0 -14
- package/dist/sdk/encryption.js.map +0 -1
- package/dist/sdk/env.js +0 -14
- package/dist/sdk/env.js.map +0 -1
- package/dist/sdk/errors.js +0 -20
- package/dist/sdk/errors.js.map +0 -1
- package/dist/sdk/index.js +0 -79
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/user-storage.js +0 -18
- package/dist/sdk/user-storage.js.map +0 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.js +0 -10
- package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.js +0 -18
- package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
- package/dist/sdk/utils/validate-login-response.js +0 -8
- package/dist/sdk/utils/validate-login-response.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/controllers/authentication/AuthenticationController.d.ts.map +0 -1
- package/dist/types/controllers/authentication/__fixtures__/index.d.ts +0 -2
- package/dist/types/controllers/authentication/__fixtures__/index.d.ts.map +0 -1
- package/dist/types/controllers/authentication/__fixtures__/mockResponses.d.ts.map +0 -1
- package/dist/types/controllers/authentication/__fixtures__/mockServices.d.ts.map +0 -1
- package/dist/types/controllers/authentication/auth-snap-requests.d.ts.map +0 -1
- package/dist/types/controllers/authentication/index.d.ts +0 -7
- package/dist/types/controllers/authentication/index.d.ts.map +0 -1
- package/dist/types/controllers/authentication/services.d.ts.map +0 -1
- package/dist/types/controllers/index.d.ts +0 -3
- package/dist/types/controllers/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/UserStorageController.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/index.d.ts +0 -3
- package/dist/types/controllers/user-storage/__fixtures__/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockAccounts.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockResponses.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockServices.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/__fixtures__/mockStorage.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/accounts/constants.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/accounts/user-storage.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/cache.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/encryption.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/index.d.ts +0 -5
- package/dist/types/controllers/user-storage/encryption/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/encryption/utils.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/index.d.ts +0 -8
- package/dist/types/controllers/user-storage/index.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/schema.d.ts.map +0 -1
- package/dist/types/controllers/user-storage/services.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/sdk/__fixtures__/mock-auth.d.ts.map +0 -1
- package/dist/types/sdk/__fixtures__/mock-userstorage.d.ts.map +0 -1
- package/dist/types/sdk/__fixtures__/test-utils.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
- package/dist/types/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
- package/dist/types/sdk/authentication.d.ts.map +0 -1
- package/dist/types/sdk/encryption.d.ts +0 -4
- package/dist/types/sdk/encryption.d.ts.map +0 -1
- package/dist/types/sdk/env.d.ts.map +0 -1
- package/dist/types/sdk/errors.d.ts.map +0 -1
- package/dist/types/sdk/index.d.ts +0 -7
- package/dist/types/sdk/index.d.ts.map +0 -1
- package/dist/types/sdk/user-storage.d.ts.map +0 -1
- package/dist/types/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
- package/dist/types/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
- package/dist/types/sdk/utils/validate-login-response.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- update subpath exports to use new .d.cts definition files. ([#4709](https://github.com/MetaMask/core/pull/4709))
|
|
15
|
+
- move profile-sync-sdk snap methods to snap auth class ([#4708](https://github.com/MetaMask/core/pull/4708))
|
|
16
|
+
- move and validate `connectSnap` and `isSnapConnected` methods to only be available for SRP auth.
|
|
17
|
+
|
|
18
|
+
### Removed
|
|
19
|
+
|
|
20
|
+
- test: remove unused test mock ([#4703](https://github.com/MetaMask/core/pull/4703))
|
|
21
|
+
|
|
22
|
+
## [0.6.0]
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Add network synchronisation logic ([#4694](https://github.com/MetaMask/core/pull/4694), [#4687](https://github.com/MetaMask/core/pull/4687), [#4685](https://github.com/MetaMask/core/pull/4685), [#4684](https://github.com/MetaMask/core/pull/4684))
|
|
27
|
+
- Add a `canSync` check for account synchronisation ([#4690](https://github.com/MetaMask/core/pull/4690))
|
|
28
|
+
- Add `onAccountAdded` and `onAccountNameUpdated` events to `UserStorageController` ([#4707](https://github.com/MetaMask/core/pull/4707))
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- Bump `@metamask/snaps-sdk` from `^6.1.1` to `^6.5.0` ([#4689](https://github.com/MetaMask/core/pull/4689))
|
|
33
|
+
- Bump `@metamask/snaps-utils` from `^7.8.1` to `^8.1.1` ([#4689](https://github.com/MetaMask/core/pull/4689))
|
|
34
|
+
- Bump peer dependency `@metamask/snaps-controllers` from `^9.3.0` to `^9.7.0` ([#4689](https://github.com/MetaMask/core/pull/4689))
|
|
35
|
+
|
|
36
|
+
### Removed
|
|
37
|
+
|
|
38
|
+
- **BREAKING:** Remove `getAccountByAddress` action ([#4693](https://github.com/MetaMask/core/pull/4693))
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files ([#4648](https://github.com/MetaMask/core/pull/4648))
|
|
43
|
+
- Previously, this package shipped with only one variant of type declaration
|
|
44
|
+
files, and these files were only CommonJS-compatible, and the `exports`
|
|
45
|
+
field in `package.json` linked to these files. This is an anti-pattern and
|
|
46
|
+
was rightfully flagged by the
|
|
47
|
+
["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as
|
|
48
|
+
["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md).
|
|
49
|
+
All of the ATTW checks now pass.
|
|
50
|
+
- Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648)).
|
|
51
|
+
- Previously, the build tool we used to generate JavaScript files extracted
|
|
52
|
+
common code to "chunk" files. While this was intended to make this package
|
|
53
|
+
more tree-shakeable, it also made debugging more difficult for our
|
|
54
|
+
development teams. These chunk files are no longer present.
|
|
55
|
+
- Remove extra slash when constructing user storage url ([#4702](https://github.com/MetaMask/core/pull/4702))
|
|
56
|
+
- Await encryption promise ([#4705](https://github.com/MetaMask/core/pull/4705))
|
|
57
|
+
|
|
10
58
|
## [0.5.0]
|
|
11
59
|
|
|
12
60
|
### Added
|
|
@@ -149,7 +197,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
149
197
|
|
|
150
198
|
- Initial release
|
|
151
199
|
|
|
152
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.
|
|
200
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.7.0...HEAD
|
|
201
|
+
[0.7.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.6.0...@metamask/profile-sync-controller@0.7.0
|
|
202
|
+
[0.6.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.5.0...@metamask/profile-sync-controller@0.6.0
|
|
153
203
|
[0.5.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.4.0...@metamask/profile-sync-controller@0.5.0
|
|
154
204
|
[0.4.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.3.0...@metamask/profile-sync-controller@0.4.0
|
|
155
205
|
[0.3.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.2.1...@metamask/profile-sync-controller@0.3.0
|
package/auth/mocks/package.json
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"main": "../../dist/controllers/authentication/__fixtures__/index.
|
|
8
|
-
"types": "../../dist/
|
|
7
|
+
"main": "../../dist/controllers/authentication/__fixtures__/index.cjs",
|
|
8
|
+
"types": "../../dist/controllers/authentication/__fixtures__/index.d.cts"
|
|
9
9
|
}
|
package/auth/package.json
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"main": "../dist/controllers/authentication/index.
|
|
8
|
-
"types": "../dist/
|
|
7
|
+
"main": "../dist/controllers/authentication/index.cjs",
|
|
8
|
+
"types": "../dist/controllers/authentication/index.d.cts"
|
|
9
9
|
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_isUnlocked, _AuthenticationController_keyringController, _AuthenticationController_registerMessageHandlers, _AuthenticationController_assertLoggedIn, _AuthenticationController_performAuthenticationFlow, _AuthenticationController_hasValidSession, _AuthenticationController__snapPublicKeyCache, _AuthenticationController_snapGetPublicKey, _AuthenticationController__snapSignMessageCache, _AuthenticationController_snapSignMessage;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.defaultState = void 0;
|
|
16
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
+
const auth_snap_requests_1 = require("./auth-snap-requests.cjs");
|
|
18
|
+
const services_1 = require("./services.cjs");
|
|
19
|
+
const THIRTY_MIN_MS = 1000 * 60 * 30;
|
|
20
|
+
const controllerName = 'AuthenticationController';
|
|
21
|
+
exports.defaultState = {
|
|
22
|
+
isSignedIn: false,
|
|
23
|
+
};
|
|
24
|
+
const metadata = {
|
|
25
|
+
isSignedIn: {
|
|
26
|
+
persist: true,
|
|
27
|
+
anonymous: true,
|
|
28
|
+
},
|
|
29
|
+
sessionData: {
|
|
30
|
+
persist: true,
|
|
31
|
+
anonymous: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Controller that enables authentication for restricted endpoints.
|
|
36
|
+
* Used for Global Profile Syncing and Notifications
|
|
37
|
+
*/
|
|
38
|
+
class AuthenticationController extends base_controller_1.BaseController {
|
|
39
|
+
constructor({ messenger, state, metametrics, }) {
|
|
40
|
+
super({
|
|
41
|
+
messenger,
|
|
42
|
+
metadata,
|
|
43
|
+
name: controllerName,
|
|
44
|
+
state: { ...exports.defaultState, ...state },
|
|
45
|
+
});
|
|
46
|
+
_AuthenticationController_instances.add(this);
|
|
47
|
+
_AuthenticationController_metametrics.set(this, void 0);
|
|
48
|
+
_AuthenticationController_isUnlocked.set(this, false);
|
|
49
|
+
_AuthenticationController_keyringController.set(this, {
|
|
50
|
+
setupLockedStateSubscriptions: () => {
|
|
51
|
+
const { isUnlocked } = this.messagingSystem.call('KeyringController:getState');
|
|
52
|
+
__classPrivateFieldSet(this, _AuthenticationController_isUnlocked, isUnlocked, "f");
|
|
53
|
+
this.messagingSystem.subscribe('KeyringController:unlock', () => {
|
|
54
|
+
__classPrivateFieldSet(this, _AuthenticationController_isUnlocked, true, "f");
|
|
55
|
+
});
|
|
56
|
+
this.messagingSystem.subscribe('KeyringController:lock', () => {
|
|
57
|
+
__classPrivateFieldSet(this, _AuthenticationController_isUnlocked, false, "f");
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
_AuthenticationController__snapPublicKeyCache.set(this, void 0);
|
|
62
|
+
_AuthenticationController__snapSignMessageCache.set(this, {});
|
|
63
|
+
if (!metametrics) {
|
|
64
|
+
throw new Error('`metametrics` field is required');
|
|
65
|
+
}
|
|
66
|
+
__classPrivateFieldSet(this, _AuthenticationController_metametrics, metametrics, "f");
|
|
67
|
+
__classPrivateFieldGet(this, _AuthenticationController_keyringController, "f").setupLockedStateSubscriptions();
|
|
68
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_registerMessageHandlers).call(this);
|
|
69
|
+
}
|
|
70
|
+
async performSignIn() {
|
|
71
|
+
const { accessToken } = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_performAuthenticationFlow).call(this);
|
|
72
|
+
return accessToken;
|
|
73
|
+
}
|
|
74
|
+
performSignOut() {
|
|
75
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertLoggedIn).call(this);
|
|
76
|
+
this.update((state) => {
|
|
77
|
+
state.isSignedIn = false;
|
|
78
|
+
state.sessionData = undefined;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async getBearerToken() {
|
|
82
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertLoggedIn).call(this);
|
|
83
|
+
if (__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_hasValidSession).call(this, this.state.sessionData)) {
|
|
84
|
+
return this.state.sessionData.accessToken;
|
|
85
|
+
}
|
|
86
|
+
const { accessToken } = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_performAuthenticationFlow).call(this);
|
|
87
|
+
return accessToken;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Will return a session profile.
|
|
91
|
+
* Throws if a user is not logged in.
|
|
92
|
+
*
|
|
93
|
+
* @returns profile for the session.
|
|
94
|
+
*/
|
|
95
|
+
async getSessionProfile() {
|
|
96
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertLoggedIn).call(this);
|
|
97
|
+
if (__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_hasValidSession).call(this, this.state.sessionData)) {
|
|
98
|
+
return this.state.sessionData.profile;
|
|
99
|
+
}
|
|
100
|
+
const { profile } = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_performAuthenticationFlow).call(this);
|
|
101
|
+
return profile;
|
|
102
|
+
}
|
|
103
|
+
isSignedIn() {
|
|
104
|
+
return this.state.isSignedIn;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(), _AuthenticationController_keyringController = new WeakMap(), _AuthenticationController__snapPublicKeyCache = new WeakMap(), _AuthenticationController__snapSignMessageCache = new WeakMap(), _AuthenticationController_instances = new WeakSet(), _AuthenticationController_registerMessageHandlers = function _AuthenticationController_registerMessageHandlers() {
|
|
108
|
+
this.messagingSystem.registerActionHandler('AuthenticationController:getBearerToken', this.getBearerToken.bind(this));
|
|
109
|
+
this.messagingSystem.registerActionHandler('AuthenticationController:getSessionProfile', this.getSessionProfile.bind(this));
|
|
110
|
+
this.messagingSystem.registerActionHandler('AuthenticationController:isSignedIn', this.isSignedIn.bind(this));
|
|
111
|
+
this.messagingSystem.registerActionHandler('AuthenticationController:performSignIn', this.performSignIn.bind(this));
|
|
112
|
+
this.messagingSystem.registerActionHandler('AuthenticationController:performSignOut', this.performSignOut.bind(this));
|
|
113
|
+
}, _AuthenticationController_assertLoggedIn = function _AuthenticationController_assertLoggedIn() {
|
|
114
|
+
if (!this.state.isSignedIn) {
|
|
115
|
+
throw new Error(`${controllerName}: Unable to call method, user is not authenticated`);
|
|
116
|
+
}
|
|
117
|
+
}, _AuthenticationController_performAuthenticationFlow = async function _AuthenticationController_performAuthenticationFlow() {
|
|
118
|
+
try {
|
|
119
|
+
// 1. Nonce
|
|
120
|
+
const publicKey = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapGetPublicKey).call(this);
|
|
121
|
+
const nonce = await (0, services_1.getNonce)(publicKey);
|
|
122
|
+
if (!nonce) {
|
|
123
|
+
throw new Error(`Unable to get nonce`);
|
|
124
|
+
}
|
|
125
|
+
// 2. Login
|
|
126
|
+
const rawMessage = (0, services_1.createLoginRawMessage)(nonce, publicKey);
|
|
127
|
+
const signature = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapSignMessage).call(this, rawMessage);
|
|
128
|
+
const loginResponse = await (0, services_1.login)(rawMessage, signature, {
|
|
129
|
+
metametricsId: await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId(),
|
|
130
|
+
agent: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").agent,
|
|
131
|
+
});
|
|
132
|
+
if (!loginResponse?.token) {
|
|
133
|
+
throw new Error(`Unable to login`);
|
|
134
|
+
}
|
|
135
|
+
const profile = {
|
|
136
|
+
identifierId: loginResponse.profile.identifier_id,
|
|
137
|
+
profileId: loginResponse.profile.profile_id,
|
|
138
|
+
};
|
|
139
|
+
// 3. Trade for Access Token
|
|
140
|
+
const accessToken = await (0, services_1.getAccessToken)(loginResponse.token, __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").agent);
|
|
141
|
+
if (!accessToken) {
|
|
142
|
+
throw new Error(`Unable to get Access Token`);
|
|
143
|
+
}
|
|
144
|
+
// Update Internal State
|
|
145
|
+
this.update((state) => {
|
|
146
|
+
state.isSignedIn = true;
|
|
147
|
+
const expiresIn = new Date();
|
|
148
|
+
expiresIn.setTime(expiresIn.getTime() + THIRTY_MIN_MS);
|
|
149
|
+
state.sessionData = {
|
|
150
|
+
profile,
|
|
151
|
+
accessToken,
|
|
152
|
+
expiresIn: expiresIn.toString(),
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
profile,
|
|
157
|
+
accessToken,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
console.error('Failed to authenticate', e);
|
|
162
|
+
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
163
|
+
throw new Error(`${controllerName}: Failed to authenticate - ${errorMessage}`);
|
|
164
|
+
}
|
|
165
|
+
}, _AuthenticationController_hasValidSession = function _AuthenticationController_hasValidSession(sessionData) {
|
|
166
|
+
if (!sessionData) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
const prevDate = Date.parse(sessionData.expiresIn);
|
|
170
|
+
if (isNaN(prevDate)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const currentDate = new Date();
|
|
174
|
+
const diffMs = Math.abs(currentDate.getTime() - prevDate);
|
|
175
|
+
return THIRTY_MIN_MS > diffMs;
|
|
176
|
+
}, _AuthenticationController_snapGetPublicKey =
|
|
177
|
+
/**
|
|
178
|
+
* Returns the auth snap public key.
|
|
179
|
+
*
|
|
180
|
+
* @returns The snap public key.
|
|
181
|
+
*/
|
|
182
|
+
async function _AuthenticationController_snapGetPublicKey() {
|
|
183
|
+
if (__classPrivateFieldGet(this, _AuthenticationController__snapPublicKeyCache, "f")) {
|
|
184
|
+
return __classPrivateFieldGet(this, _AuthenticationController__snapPublicKeyCache, "f");
|
|
185
|
+
}
|
|
186
|
+
if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
|
|
187
|
+
throw new Error('#snapGetPublicKey - unable to call snap, wallet is locked');
|
|
188
|
+
}
|
|
189
|
+
const result = (await this.messagingSystem.call('SnapController:handleRequest', (0, auth_snap_requests_1.createSnapPublicKeyRequest)()));
|
|
190
|
+
__classPrivateFieldSet(this, _AuthenticationController__snapPublicKeyCache, result, "f");
|
|
191
|
+
return result;
|
|
192
|
+
}, _AuthenticationController_snapSignMessage =
|
|
193
|
+
/**
|
|
194
|
+
* Signs a specific message using an underlying auth snap.
|
|
195
|
+
*
|
|
196
|
+
* @param message - A specific tagged message to sign.
|
|
197
|
+
* @returns A Signature created by the snap.
|
|
198
|
+
*/
|
|
199
|
+
async function _AuthenticationController_snapSignMessage(message) {
|
|
200
|
+
if (__classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message]) {
|
|
201
|
+
return __classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message];
|
|
202
|
+
}
|
|
203
|
+
if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
|
|
204
|
+
throw new Error('#snapSignMessage - unable to call snap, wallet is locked');
|
|
205
|
+
}
|
|
206
|
+
const result = (await this.messagingSystem.call('SnapController:handleRequest', (0, auth_snap_requests_1.createSnapSignMessageRequest)(message)));
|
|
207
|
+
__classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message] = result;
|
|
208
|
+
return result;
|
|
209
|
+
};
|
|
210
|
+
exports.default = AuthenticationController;
|
|
211
|
+
//# sourceMappingURL=AuthenticationController.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticationController.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,+DAA2D;AAQ3D,iEAG8B;AAC9B,6CAKoB;AAEpB,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAErC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA8BrC,QAAA,YAAY,GAAkC;IACzD,UAAU,EAAE,KAAK;CAClB,CAAC;AACF,MAAM,QAAQ,GAAiD;IAC7D,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AA0DF;;;GAGG;AACH,MAAqB,wBAAyB,SAAQ,gCAIrD;IAsBC,YAAY,EACV,SAAS,EACT,KAAK,EACL,WAAW,GASZ;QAC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AAwB","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedControllerMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport {\n createSnapPublicKeyRequest,\n createSnapSignMessageRequest,\n} from './auth-snap-requests';\nimport {\n createLoginRawMessage,\n getAccessToken,\n getNonce,\n login,\n} from './services';\n\nconst THIRTY_MIN_MS = 1000 * 60 * 30;\n\nconst controllerName = 'AuthenticationController';\n\n// State\ntype SessionProfile = {\n identifierId: string;\n profileId: string;\n};\n\ntype SessionData = {\n /** profile - anonymous profile data for the given logged in user */\n profile: SessionProfile;\n /** accessToken - used to make requests authorized endpoints */\n accessToken: string;\n /** expiresIn - string date to determine if new access token is required */\n expiresIn: string;\n};\n\ntype MetaMetricsAuth = {\n getMetaMetricsId: () => string | Promise<string>;\n agent: 'extension' | 'mobile';\n};\n\nexport type AuthenticationControllerState = {\n /**\n * Global isSignedIn state.\n * Can be used to determine if \"Profile Syncing\" is enabled.\n */\n isSignedIn: boolean;\n sessionData?: SessionData;\n};\nexport const defaultState: AuthenticationControllerState = {\n isSignedIn: false,\n};\nconst metadata: StateMetadata<AuthenticationControllerState> = {\n isSignedIn: {\n persist: true,\n anonymous: true,\n },\n sessionData: {\n persist: true,\n anonymous: false,\n },\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof AuthenticationController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: AuthenticationController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performSignIn'\n | 'performSignOut'\n | 'getBearerToken'\n | 'getSessionProfile'\n | 'isSignedIn'\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | AuthenticationControllerGetStateAction;\nexport type AuthenticationControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AuthenticationControllerState\n>;\nexport type AuthenticationControllerPerformSignIn = ActionsObj['performSignIn'];\nexport type AuthenticationControllerPerformSignOut =\n ActionsObj['performSignOut'];\nexport type AuthenticationControllerGetBearerToken =\n ActionsObj['getBearerToken'];\nexport type AuthenticationControllerGetSessionProfile =\n ActionsObj['getSessionProfile'];\nexport type AuthenticationControllerIsSignedIn = ActionsObj['isSignedIn'];\n\nexport type AuthenticationControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n AuthenticationControllerState\n >;\n\nexport type Events = AuthenticationControllerStateChangeEvent;\n\n// Allowed Actions\nexport type AllowedActions =\n | HandleSnapRequest\n | KeyringControllerGetStateAction;\n\nexport type AllowedEvents =\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent;\n\n// Messenger\nexport type AuthenticationControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Controller that enables authentication for restricted endpoints.\n * Used for Global Profile Syncing and Notifications\n */\nexport default class AuthenticationController extends BaseController<\n typeof controllerName,\n AuthenticationControllerState,\n AuthenticationControllerMessenger\n> {\n #metametrics: MetaMetricsAuth;\n\n #isUnlocked = false;\n\n #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n constructor({\n messenger,\n state,\n metametrics,\n }: {\n messenger: AuthenticationControllerMessenger;\n state?: AuthenticationControllerState;\n /**\n * Not using the Messaging System as we\n * do not want to tie this strictly to extension\n */\n metametrics: MetaMetricsAuth;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n if (!metametrics) {\n throw new Error('`metametrics` field is required');\n }\n\n this.#metametrics = metametrics;\n\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getBearerToken',\n this.getBearerToken.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getSessionProfile',\n this.getSessionProfile.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:isSignedIn',\n this.isSignedIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignIn',\n this.performSignIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignOut',\n this.performSignOut.bind(this),\n );\n }\n\n public async performSignIn(): Promise<string> {\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n public performSignOut(): void {\n this.#assertLoggedIn();\n\n this.update((state) => {\n state.isSignedIn = false;\n state.sessionData = undefined;\n });\n }\n\n public async getBearerToken(): Promise<string> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.accessToken;\n }\n\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n /**\n * Will return a session profile.\n * Throws if a user is not logged in.\n *\n * @returns profile for the session.\n */\n public async getSessionProfile(): Promise<SessionProfile> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.profile;\n }\n\n const { profile } = await this.#performAuthenticationFlow();\n return profile;\n }\n\n public isSignedIn(): boolean {\n return this.state.isSignedIn;\n }\n\n #assertLoggedIn(): void {\n if (!this.state.isSignedIn) {\n throw new Error(\n `${controllerName}: Unable to call method, user is not authenticated`,\n );\n }\n }\n\n async #performAuthenticationFlow(): Promise<{\n profile: SessionProfile;\n accessToken: string;\n }> {\n try {\n // 1. Nonce\n const publicKey = await this.#snapGetPublicKey();\n const nonce = await getNonce(publicKey);\n if (!nonce) {\n throw new Error(`Unable to get nonce`);\n }\n\n // 2. Login\n const rawMessage = createLoginRawMessage(nonce, publicKey);\n const signature = await this.#snapSignMessage(rawMessage);\n const loginResponse = await login(rawMessage, signature, {\n metametricsId: await this.#metametrics.getMetaMetricsId(),\n agent: this.#metametrics.agent,\n });\n if (!loginResponse?.token) {\n throw new Error(`Unable to login`);\n }\n\n const profile: SessionProfile = {\n identifierId: loginResponse.profile.identifier_id,\n profileId: loginResponse.profile.profile_id,\n };\n\n // 3. Trade for Access Token\n const accessToken = await getAccessToken(\n loginResponse.token,\n this.#metametrics.agent,\n );\n if (!accessToken) {\n throw new Error(`Unable to get Access Token`);\n }\n\n // Update Internal State\n this.update((state) => {\n state.isSignedIn = true;\n const expiresIn = new Date();\n expiresIn.setTime(expiresIn.getTime() + THIRTY_MIN_MS);\n state.sessionData = {\n profile,\n accessToken,\n expiresIn: expiresIn.toString(),\n };\n });\n\n return {\n profile,\n accessToken,\n };\n } catch (e) {\n console.error('Failed to authenticate', e);\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new Error(\n `${controllerName}: Failed to authenticate - ${errorMessage}`,\n );\n }\n }\n\n #hasValidSession(\n sessionData: SessionData | undefined,\n ): sessionData is SessionData {\n if (!sessionData) {\n return false;\n }\n\n const prevDate = Date.parse(sessionData.expiresIn);\n if (isNaN(prevDate)) {\n return false;\n }\n\n const currentDate = new Date();\n const diffMs = Math.abs(currentDate.getTime() - prevDate);\n\n return THIRTY_MIN_MS > diffMs;\n }\n\n #_snapPublicKeyCache: string | undefined;\n\n /**\n * Returns the auth snap public key.\n *\n * @returns The snap public key.\n */\n async #snapGetPublicKey(): Promise<string> {\n if (this.#_snapPublicKeyCache) {\n return this.#_snapPublicKeyCache;\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapGetPublicKey - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapPublicKeyRequest(),\n )) as string;\n\n this.#_snapPublicKeyCache = result;\n\n return result;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapSignMessage - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from
|
|
2
|
-
import { BaseController } from
|
|
3
|
-
import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent } from
|
|
4
|
-
import type { HandleSnapRequest } from
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent } from "@metamask/keyring-controller";
|
|
4
|
+
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
5
5
|
declare const controllerName = "AuthenticationController";
|
|
6
6
|
type SessionProfile = {
|
|
7
7
|
identifierId: string;
|
|
@@ -75,4 +75,4 @@ export default class AuthenticationController extends BaseController<typeof cont
|
|
|
75
75
|
isSignedIn(): boolean;
|
|
76
76
|
}
|
|
77
77
|
export {};
|
|
78
|
-
//# sourceMappingURL=AuthenticationController.d.
|
|
78
|
+
//# sourceMappingURL=AuthenticationController.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticationController.d.cts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAE9B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAerE,QAAA,MAAM,cAAc,6BAA6B,CAAC;AAGlD,KAAK,cAAc,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,oEAAoE;IACpE,OAAO,EAAE,cAAc,CAAC;IACxB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,gBAAgB,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,6BAE1B,CAAC;AAaF,KAAK,gBAAgB,CAAC,UAAU,SAAS,MAAM,wBAAwB,IAAI;KACxE,CAAC,IAAI,UAAU,GAAG;QACjB,IAAI,EAAE,GAAG,OAAO,cAAc,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC;KACtC;CACF,CAAC;AACF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AAC;QAC7C,KAAK,CAAC,EAAE,6BAA6B,CAAC;QACtC;;;WAGG;QACH,WAAW,EAAE,eAAe,CAAC;KAC9B;IAiDY,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC,cAAc,IAAI,IAAI;IAShB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAW9C;;;;;OAKG;IACU,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAWlD,UAAU,IAAI,OAAO;CAqJ7B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent } from "@metamask/keyring-controller";
|
|
4
|
+
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
5
|
+
declare const controllerName = "AuthenticationController";
|
|
6
|
+
type SessionProfile = {
|
|
7
|
+
identifierId: string;
|
|
8
|
+
profileId: string;
|
|
9
|
+
};
|
|
10
|
+
type SessionData = {
|
|
11
|
+
/** profile - anonymous profile data for the given logged in user */
|
|
12
|
+
profile: SessionProfile;
|
|
13
|
+
/** accessToken - used to make requests authorized endpoints */
|
|
14
|
+
accessToken: string;
|
|
15
|
+
/** expiresIn - string date to determine if new access token is required */
|
|
16
|
+
expiresIn: string;
|
|
17
|
+
};
|
|
18
|
+
type MetaMetricsAuth = {
|
|
19
|
+
getMetaMetricsId: () => string | Promise<string>;
|
|
20
|
+
agent: 'extension' | 'mobile';
|
|
21
|
+
};
|
|
22
|
+
export type AuthenticationControllerState = {
|
|
23
|
+
/**
|
|
24
|
+
* Global isSignedIn state.
|
|
25
|
+
* Can be used to determine if "Profile Syncing" is enabled.
|
|
26
|
+
*/
|
|
27
|
+
isSignedIn: boolean;
|
|
28
|
+
sessionData?: SessionData;
|
|
29
|
+
};
|
|
30
|
+
export declare const defaultState: AuthenticationControllerState;
|
|
31
|
+
type CreateActionsObj<Controller extends keyof AuthenticationController> = {
|
|
32
|
+
[K in Controller]: {
|
|
33
|
+
type: `${typeof controllerName}:${K}`;
|
|
34
|
+
handler: AuthenticationController[K];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type ActionsObj = CreateActionsObj<'performSignIn' | 'performSignOut' | 'getBearerToken' | 'getSessionProfile' | 'isSignedIn'>;
|
|
38
|
+
export type Actions = ActionsObj[keyof ActionsObj] | AuthenticationControllerGetStateAction;
|
|
39
|
+
export type AuthenticationControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AuthenticationControllerState>;
|
|
40
|
+
export type AuthenticationControllerPerformSignIn = ActionsObj['performSignIn'];
|
|
41
|
+
export type AuthenticationControllerPerformSignOut = ActionsObj['performSignOut'];
|
|
42
|
+
export type AuthenticationControllerGetBearerToken = ActionsObj['getBearerToken'];
|
|
43
|
+
export type AuthenticationControllerGetSessionProfile = ActionsObj['getSessionProfile'];
|
|
44
|
+
export type AuthenticationControllerIsSignedIn = ActionsObj['isSignedIn'];
|
|
45
|
+
export type AuthenticationControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, AuthenticationControllerState>;
|
|
46
|
+
export type Events = AuthenticationControllerStateChangeEvent;
|
|
47
|
+
export type AllowedActions = HandleSnapRequest | KeyringControllerGetStateAction;
|
|
48
|
+
export type AllowedEvents = KeyringControllerLockEvent | KeyringControllerUnlockEvent;
|
|
49
|
+
export type AuthenticationControllerMessenger = RestrictedControllerMessenger<typeof controllerName, Actions | AllowedActions, Events | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
50
|
+
/**
|
|
51
|
+
* Controller that enables authentication for restricted endpoints.
|
|
52
|
+
* Used for Global Profile Syncing and Notifications
|
|
53
|
+
*/
|
|
54
|
+
export default class AuthenticationController extends BaseController<typeof controllerName, AuthenticationControllerState, AuthenticationControllerMessenger> {
|
|
55
|
+
#private;
|
|
56
|
+
constructor({ messenger, state, metametrics, }: {
|
|
57
|
+
messenger: AuthenticationControllerMessenger;
|
|
58
|
+
state?: AuthenticationControllerState;
|
|
59
|
+
/**
|
|
60
|
+
* Not using the Messaging System as we
|
|
61
|
+
* do not want to tie this strictly to extension
|
|
62
|
+
*/
|
|
63
|
+
metametrics: MetaMetricsAuth;
|
|
64
|
+
});
|
|
65
|
+
performSignIn(): Promise<string>;
|
|
66
|
+
performSignOut(): void;
|
|
67
|
+
getBearerToken(): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Will return a session profile.
|
|
70
|
+
* Throws if a user is not logged in.
|
|
71
|
+
*
|
|
72
|
+
* @returns profile for the session.
|
|
73
|
+
*/
|
|
74
|
+
getSessionProfile(): Promise<SessionProfile>;
|
|
75
|
+
isSignedIn(): boolean;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=AuthenticationController.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticationController.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAE9B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAerE,QAAA,MAAM,cAAc,6BAA6B,CAAC;AAGlD,KAAK,cAAc,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,oEAAoE;IACpE,OAAO,EAAE,cAAc,CAAC;IACxB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;C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