@metamask-previews/profile-sync-controller 29.0.0-preview-3866c0ff1 → 29.0.0-preview-e3275932a
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 +0 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs +7 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -0
- package/dist/controllers/authentication/{AuthenticationController-method-action-types.d.ts → AuthenticationController-method-action-types.d.cts} +2 -2
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts +102 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +1 -0
- package/dist/controllers/authentication/{AuthenticationController-method-action-types.js → AuthenticationController-method-action-types.mjs} +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.cjs +489 -0
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
- package/dist/controllers/authentication/{AuthenticationController.d.ts → AuthenticationController.d.cts} +10 -10
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.d.mts +130 -0
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
- package/dist/controllers/authentication/AuthenticationController.mjs +485 -0
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -0
- package/dist/controllers/authentication/index.cjs +35 -0
- package/dist/controllers/authentication/index.cjs.map +1 -0
- package/dist/controllers/authentication/{index.d.ts → index.d.cts} +5 -5
- 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 -0
- package/dist/controllers/authentication/index.mjs.map +1 -0
- package/dist/controllers/authentication/mocks/index.cjs +18 -0
- package/dist/controllers/authentication/mocks/index.cjs.map +1 -0
- package/dist/controllers/authentication/mocks/index.d.cts +2 -0
- package/dist/controllers/authentication/mocks/index.d.cts.map +1 -0
- package/dist/controllers/authentication/mocks/index.d.mts +2 -0
- package/dist/controllers/authentication/mocks/index.d.mts.map +1 -0
- package/dist/controllers/authentication/mocks/index.mjs +2 -0
- package/dist/controllers/authentication/mocks/index.mjs.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.cjs +126 -0
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -0
- package/dist/controllers/authentication/mocks/{mockResponses.d.ts → mockResponses.d.cts} +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +58 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -0
- package/dist/controllers/authentication/mocks/{mockResponses.js → mockResponses.mjs} +2 -2
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -0
- 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 +3 -0
- package/dist/controllers/index.mjs.map +1 -0
- package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs +7 -0
- package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +1 -0
- package/dist/controllers/user-storage/{UserStorageController-method-action-types.d.ts → UserStorageController-method-action-types.d.cts} +2 -2
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts +137 -0
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +1 -0
- package/dist/controllers/user-storage/{UserStorageController-method-action-types.js → UserStorageController-method-action-types.mjs} +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.cjs +412 -0
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
- package/dist/controllers/user-storage/{UserStorageController.d.ts → UserStorageController.d.cts} +14 -14
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.d.mts +182 -0
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
- package/dist/controllers/user-storage/UserStorageController.mjs +408 -0
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -0
- package/dist/controllers/user-storage/constants.cjs +19 -0
- package/dist/controllers/user-storage/constants.cjs.map +1 -0
- package/dist/controllers/user-storage/constants.d.cts +15 -0
- package/dist/controllers/user-storage/constants.d.cts.map +1 -0
- package/dist/controllers/user-storage/constants.d.mts +15 -0
- package/dist/controllers/user-storage/constants.d.mts.map +1 -0
- package/dist/controllers/user-storage/{constants.js → constants.mjs} +1 -1
- package/dist/controllers/user-storage/constants.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/constants.cjs +12 -0
- package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{constants.d.ts → constants.d.cts} +1 -1
- package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/constants.d.mts +9 -0
- package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{constants.js → constants.mjs} +1 -1
- package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +346 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{controller-integration.d.ts → controller-integration.d.cts} +3 -3
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +47 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{controller-integration.js → controller-integration.mjs} +6 -6
- package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +50 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.d.ts → setup-subscriptions.d.cts} +2 -2
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +8 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.js → setup-subscriptions.mjs} +4 -4
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +23 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{sync-utils.d.ts → sync-utils.d.cts} +2 -2
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +9 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{sync-utils.js → sync-utils.mjs} +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.cjs +3 -0
- package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{types.d.ts → types.d.cts} +6 -6
- package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.d.mts +37 -0
- package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.mjs +2 -0
- package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.cjs +64 -0
- package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{utils.d.ts → utils.d.cts} +3 -3
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts +36 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/{utils.js → utils.mjs} +2 -2
- package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -0
- package/dist/controllers/user-storage/index.cjs +38 -0
- package/dist/controllers/user-storage/index.cjs.map +1 -0
- package/dist/controllers/user-storage/{index.d.ts → index.d.cts} +8 -8
- package/dist/controllers/user-storage/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/index.d.mts +10 -0
- package/dist/controllers/user-storage/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/index.mjs +9 -0
- package/dist/controllers/user-storage/index.mjs.map +1 -0
- package/dist/controllers/user-storage/mocks/index.cjs +19 -0
- package/dist/controllers/user-storage/mocks/index.cjs.map +1 -0
- package/dist/controllers/user-storage/mocks/index.d.cts +3 -0
- package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -0
- package/dist/controllers/user-storage/mocks/index.d.mts +3 -0
- package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -0
- package/dist/controllers/user-storage/mocks/index.mjs +3 -0
- package/dist/controllers/user-storage/mocks/index.mjs.map +1 -0
- package/dist/controllers/user-storage/mocks/mockResponses.cjs +113 -0
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -0
- package/dist/controllers/user-storage/mocks/{mockResponses.d.ts → mockResponses.d.cts} +3 -3
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -0
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts +66 -0
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -0
- package/dist/controllers/user-storage/mocks/{mockResponses.js → mockResponses.mjs} +4 -4
- package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -0
- package/dist/controllers/user-storage/mocks/mockStorage.cjs +36 -0
- package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -0
- package/dist/controllers/user-storage/mocks/{mockStorage.d.ts → mockStorage.d.cts} +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -0
- package/dist/controllers/user-storage/mocks/mockStorage.d.mts +5 -0
- package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -0
- package/dist/controllers/user-storage/mocks/{mockStorage.js → mockStorage.mjs} +3 -3
- package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -0
- package/dist/controllers/user-storage/types.cjs +3 -0
- package/dist/controllers/user-storage/types.cjs.map +1 -0
- package/dist/controllers/user-storage/{types.d.ts → types.d.cts} +3 -3
- package/dist/controllers/user-storage/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/types.d.mts +23 -0
- package/dist/controllers/user-storage/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/types.mjs +2 -0
- package/dist/controllers/user-storage/types.mjs.map +1 -0
- package/dist/controllers/user-storage/utils.cjs +32 -0
- package/dist/controllers/user-storage/utils.cjs.map +1 -0
- package/dist/controllers/user-storage/{utils.d.ts → utils.d.cts} +1 -1
- package/dist/controllers/user-storage/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/utils.d.mts +19 -0
- package/dist/controllers/user-storage/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/{utils.js → utils.mjs} +1 -1
- 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 +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +114 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/{flow-siwe.d.ts → 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 +25 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +110 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +290 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/{flow-srp.d.ts → flow-srp.d.cts} +5 -5
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +44 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +263 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.cjs +400 -0
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/{services.d.ts → services.d.cts} +5 -5
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +105 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/{services.js → services.mjs} +6 -6
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/{types.d.ts → 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 +114 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/{types.js → types.mjs} +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +27 -0
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/{identifier.d.ts → identifier.d.cts} +2 -2
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +13 -0
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/{identifier.js → identifier.mjs} +2 -2
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +17 -0
- package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/{time.d.ts → time.d.cts} +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +8 -0
- package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/utils/{time.js → time.mjs} +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +1 -0
- package/dist/sdk/authentication.cjs +132 -0
- package/dist/sdk/authentication.cjs.map +1 -0
- package/dist/sdk/{authentication.d.ts → authentication.d.cts} +9 -9
- package/dist/sdk/authentication.d.cts.map +1 -0
- package/dist/sdk/authentication.d.mts +38 -0
- package/dist/sdk/authentication.d.mts.map +1 -0
- package/dist/sdk/authentication.mjs +112 -0
- package/dist/sdk/authentication.mjs.map +1 -0
- package/dist/sdk/constants.cjs +7 -0
- package/dist/sdk/constants.cjs.map +1 -0
- package/dist/sdk/{constants.d.ts → constants.d.cts} +1 -1
- package/dist/sdk/constants.d.cts.map +1 -0
- package/dist/sdk/constants.d.mts +4 -0
- package/dist/sdk/constants.d.mts.map +1 -0
- package/dist/sdk/{constants.js → constants.mjs} +1 -1
- package/dist/sdk/constants.mjs.map +1 -0
- package/dist/sdk/errors.cjs +76 -0
- package/dist/sdk/errors.cjs.map +1 -0
- package/dist/sdk/{errors.d.ts → errors.d.cts} +1 -1
- package/dist/sdk/errors.d.cts.map +1 -0
- package/dist/sdk/errors.d.mts +34 -0
- package/dist/sdk/errors.d.mts.map +1 -0
- package/dist/sdk/{errors.js → errors.mjs} +3 -4
- package/dist/sdk/errors.mjs.map +1 -0
- package/dist/sdk/index.cjs +24 -0
- package/dist/sdk/index.cjs.map +1 -0
- package/dist/sdk/index.d.cts +8 -0
- package/dist/sdk/index.d.cts.map +1 -0
- package/dist/sdk/index.d.mts +8 -0
- package/dist/sdk/index.d.mts.map +1 -0
- package/dist/sdk/index.mjs +8 -0
- package/dist/sdk/index.mjs.map +1 -0
- package/dist/sdk/mocks/auth.cjs +82 -0
- package/dist/sdk/mocks/auth.cjs.map +1 -0
- package/dist/sdk/mocks/{auth.d.ts → auth.d.cts} +2 -2
- package/dist/sdk/mocks/auth.d.cts.map +1 -0
- package/dist/sdk/mocks/auth.d.mts +69 -0
- package/dist/sdk/mocks/auth.d.mts.map +1 -0
- package/dist/sdk/mocks/{auth.js → auth.mjs} +3 -3
- package/dist/sdk/mocks/auth.mjs.map +1 -0
- package/dist/sdk/mocks/userstorage.cjs +43 -0
- package/dist/sdk/mocks/userstorage.cjs.map +1 -0
- package/dist/sdk/mocks/{userstorage.d.ts → userstorage.d.cts} +1 -1
- package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
- package/dist/sdk/mocks/userstorage.d.mts +10 -0
- package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
- package/dist/sdk/mocks/{userstorage.js → userstorage.mjs} +5 -5
- package/dist/sdk/mocks/userstorage.mjs.map +1 -0
- package/dist/sdk/user-storage.cjs +386 -0
- package/dist/sdk/user-storage.cjs.map +1 -0
- package/dist/sdk/{user-storage.d.ts → user-storage.d.cts} +5 -5
- package/dist/sdk/user-storage.d.cts.map +1 -0
- package/dist/sdk/user-storage.d.mts +47 -0
- package/dist/sdk/user-storage.d.mts.map +1 -0
- package/dist/sdk/user-storage.mjs +358 -0
- package/dist/sdk/user-storage.mjs.map +1 -0
- 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/sdk/utils/{eip-6963-metamask-provider.d.ts → 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.js → eip-6963-metamask-provider.mjs} +1 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +96 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
- package/dist/sdk/utils/{messaging-signing-snap-requests.d.ts → messaging-signing-snap-requests.d.cts} +2 -2
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +41 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
- package/dist/sdk/utils/{messaging-signing-snap-requests.js → messaging-signing-snap-requests.mjs} +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -0
- package/dist/sdk/utils/validate-login-response.cjs +49 -0
- package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
- package/dist/sdk/utils/{validate-login-response.d.ts → 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 +14 -0
- package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
- package/dist/sdk/utils/{validate-login-response.js → validate-login-response.mjs} +1 -1
- package/dist/sdk/utils/validate-login-response.mjs.map +1 -0
- package/dist/sdk/utils/validate-pair-response.cjs +29 -0
- package/dist/sdk/utils/validate-pair-response.cjs.map +1 -0
- package/dist/sdk/utils/{validate-pair-response.d.ts → validate-pair-response.d.cts} +1 -1
- package/dist/sdk/utils/validate-pair-response.d.cts.map +1 -0
- package/dist/sdk/utils/validate-pair-response.d.mts +26 -0
- package/dist/sdk/utils/validate-pair-response.d.mts.map +1 -0
- package/dist/sdk/utils/{validate-pair-response.js → validate-pair-response.mjs} +1 -1
- package/dist/sdk/utils/validate-pair-response.mjs.map +1 -0
- package/dist/shared/encryption/cache.cjs +77 -0
- package/dist/shared/encryption/cache.cjs.map +1 -0
- package/dist/shared/encryption/{cache.d.ts → cache.d.cts} +1 -1
- package/dist/shared/encryption/cache.d.cts.map +1 -0
- package/dist/shared/encryption/cache.d.mts +32 -0
- package/dist/shared/encryption/cache.d.mts.map +1 -0
- package/dist/shared/encryption/{cache.js → cache.mjs} +4 -4
- package/dist/shared/encryption/cache.mjs.map +1 -0
- package/dist/shared/encryption/constants.cjs +17 -0
- package/dist/shared/encryption/constants.cjs.map +1 -0
- package/dist/shared/encryption/{constants.d.ts → constants.d.cts} +2 -2
- package/dist/shared/encryption/constants.d.cts.map +1 -0
- package/dist/shared/encryption/constants.d.mts +9 -0
- package/dist/shared/encryption/constants.d.mts.map +1 -0
- package/dist/shared/encryption/{constants.js → constants.mjs} +1 -1
- package/dist/shared/encryption/constants.mjs.map +1 -0
- package/dist/shared/encryption/encryption.cjs +209 -0
- package/dist/shared/encryption/encryption.cjs.map +1 -0
- package/dist/shared/encryption/{encryption.d.ts → encryption.d.cts} +3 -3
- package/dist/shared/encryption/encryption.d.cts.map +1 -0
- package/dist/shared/encryption/encryption.d.mts +30 -0
- package/dist/shared/encryption/encryption.d.mts.map +1 -0
- package/dist/shared/encryption/encryption.mjs +205 -0
- package/dist/shared/encryption/encryption.mjs.map +1 -0
- package/dist/shared/encryption/index.cjs +25 -0
- package/dist/shared/encryption/index.cjs.map +1 -0
- package/dist/shared/encryption/index.d.cts +5 -0
- package/dist/shared/encryption/index.d.cts.map +1 -0
- package/dist/shared/encryption/index.d.mts +5 -0
- package/dist/shared/encryption/index.d.mts.map +1 -0
- package/dist/shared/encryption/index.mjs +5 -0
- package/dist/shared/encryption/index.mjs.map +1 -0
- package/dist/shared/encryption/utils.cjs +21 -0
- package/dist/shared/encryption/utils.cjs.map +1 -0
- package/dist/shared/encryption/{utils.d.ts → utils.d.cts} +3 -3
- package/dist/shared/encryption/utils.d.cts.map +1 -0
- package/dist/shared/encryption/utils.d.mts +5 -0
- package/dist/shared/encryption/utils.d.mts.map +1 -0
- package/dist/shared/encryption/{utils.js → utils.mjs} +1 -1
- package/dist/shared/encryption/utils.mjs.map +1 -0
- package/dist/shared/env.cjs +85 -0
- package/dist/shared/env.cjs.map +1 -0
- package/dist/shared/{env.d.ts → env.d.cts} +1 -1
- package/dist/shared/env.d.cts.map +1 -0
- package/dist/shared/env.d.mts +34 -0
- package/dist/shared/env.d.mts.map +1 -0
- package/dist/shared/{env.js → env.mjs} +1 -1
- package/dist/shared/env.mjs.map +1 -0
- package/dist/shared/storage-schema.cjs +42 -0
- package/dist/shared/storage-schema.cjs.map +1 -0
- package/dist/shared/{storage-schema.d.ts → storage-schema.d.cts} +1 -1
- package/dist/shared/storage-schema.d.cts.map +1 -0
- package/dist/shared/storage-schema.d.mts +34 -0
- package/dist/shared/storage-schema.d.mts.map +1 -0
- package/dist/shared/{storage-schema.js → storage-schema.mjs} +2 -2
- package/dist/shared/storage-schema.mjs.map +1 -0
- package/dist/shared/types/encryption.cjs +3 -0
- package/dist/shared/types/encryption.cjs.map +1 -0
- package/dist/shared/types/{encryption.d.ts → encryption.d.cts} +1 -1
- package/dist/shared/types/encryption.d.cts.map +1 -0
- package/dist/shared/types/encryption.d.mts +2 -0
- package/dist/shared/types/encryption.d.mts.map +1 -0
- package/dist/shared/types/encryption.mjs +2 -0
- package/dist/shared/types/encryption.mjs.map +1 -0
- package/dist/shared/types/services.cjs +3 -0
- package/dist/shared/types/services.cjs.map +1 -0
- package/dist/shared/types/{services.d.ts → services.d.cts} +2 -2
- package/dist/shared/types/services.d.cts.map +1 -0
- package/dist/shared/types/services.d.mts +17 -0
- package/dist/shared/types/services.d.mts.map +1 -0
- package/dist/shared/types/services.mjs +2 -0
- package/dist/shared/types/services.mjs.map +1 -0
- package/dist/shared/utils/entropy-source.cjs +37 -0
- package/dist/shared/utils/entropy-source.cjs.map +1 -0
- package/dist/shared/utils/{entropy-source.d.ts → entropy-source.d.cts} +2 -2
- package/dist/shared/utils/entropy-source.d.cts.map +1 -0
- package/dist/shared/utils/entropy-source.d.mts +22 -0
- package/dist/shared/utils/entropy-source.d.mts.map +1 -0
- package/dist/shared/utils/{entropy-source.js → entropy-source.mjs} +2 -2
- package/dist/shared/utils/entropy-source.mjs.map +1 -0
- package/dist/shared/utils/event-queue.cjs +24 -0
- package/dist/shared/utils/event-queue.cjs.map +1 -0
- package/dist/shared/utils/{event-queue.d.ts → event-queue.d.cts} +1 -1
- package/dist/shared/utils/event-queue.d.cts.map +1 -0
- package/dist/shared/utils/event-queue.d.mts +6 -0
- package/dist/shared/utils/event-queue.d.mts.map +1 -0
- package/dist/shared/utils/{event-queue.js → event-queue.mjs} +4 -2
- package/dist/shared/utils/event-queue.mjs.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
- package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
- package/dist/shared/utils/{hd-keyring-seed.d.ts → hd-keyring-seed.d.cts} +3 -3
- package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
- package/dist/shared/utils/{hd-keyring-seed.js → hd-keyring-seed.mjs} +1 -1
- package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
- package/dist/shared/utils/message-signing.cjs +147 -0
- package/dist/shared/utils/message-signing.cjs.map +1 -0
- package/dist/shared/utils/{message-signing.d.ts → message-signing.d.cts} +1 -1
- package/dist/shared/utils/message-signing.d.cts.map +1 -0
- package/dist/shared/utils/message-signing.d.mts +73 -0
- package/dist/shared/utils/message-signing.d.mts.map +1 -0
- package/dist/shared/utils/{message-signing.js → message-signing.mjs} +7 -7
- package/dist/shared/utils/message-signing.mjs.map +1 -0
- package/package.json +56 -22
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +0 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +0 -1
- package/dist/controllers/authentication/AuthenticationController.d.ts.map +0 -1
- package/dist/controllers/authentication/AuthenticationController.js +0 -536
- package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
- package/dist/controllers/authentication/index.d.ts.map +0 -1
- package/dist/controllers/authentication/index.js +0 -6
- package/dist/controllers/authentication/index.js.map +0 -1
- package/dist/controllers/authentication/mocks/index.d.ts +0 -2
- package/dist/controllers/authentication/mocks/index.d.ts.map +0 -1
- package/dist/controllers/authentication/mocks/index.js +0 -2
- package/dist/controllers/authentication/mocks/index.js.map +0 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +0 -1
- package/dist/controllers/authentication/mocks/mockResponses.js.map +0 -1
- package/dist/controllers/index.d.ts +0 -3
- package/dist/controllers/index.d.ts.map +0 -1
- package/dist/controllers/index.js +0 -3
- package/dist/controllers/index.js.map +0 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.ts.map +0 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.js.map +0 -1
- package/dist/controllers/user-storage/UserStorageController.d.ts.map +0 -1
- package/dist/controllers/user-storage/UserStorageController.js +0 -429
- package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
- package/dist/controllers/user-storage/constants.d.ts +0 -15
- package/dist/controllers/user-storage/constants.d.ts.map +0 -1
- package/dist/controllers/user-storage/constants.js.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/constants.d.ts.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/constants.js.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.ts.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.js.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.ts.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.js.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.ts.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.js.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/types.d.ts.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/types.js +0 -2
- package/dist/controllers/user-storage/contact-syncing/types.js.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/utils.d.ts.map +0 -1
- package/dist/controllers/user-storage/contact-syncing/utils.js.map +0 -1
- package/dist/controllers/user-storage/index.d.ts.map +0 -1
- package/dist/controllers/user-storage/index.js +0 -9
- package/dist/controllers/user-storage/index.js.map +0 -1
- package/dist/controllers/user-storage/mocks/index.d.ts +0 -3
- package/dist/controllers/user-storage/mocks/index.d.ts.map +0 -1
- package/dist/controllers/user-storage/mocks/index.js +0 -3
- package/dist/controllers/user-storage/mocks/index.js.map +0 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.ts.map +0 -1
- package/dist/controllers/user-storage/mocks/mockResponses.js.map +0 -1
- package/dist/controllers/user-storage/mocks/mockStorage.d.ts.map +0 -1
- package/dist/controllers/user-storage/mocks/mockStorage.js.map +0 -1
- package/dist/controllers/user-storage/types.d.ts.map +0 -1
- package/dist/controllers/user-storage/types.js +0 -2
- package/dist/controllers/user-storage/types.js.map +0 -1
- package/dist/controllers/user-storage/utils.d.ts.map +0 -1
- package/dist/controllers/user-storage/utils.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -99
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -255
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/utils/time.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/utils/time.js.map +0 -1
- package/dist/sdk/authentication.d.ts.map +0 -1
- package/dist/sdk/authentication.js +0 -100
- package/dist/sdk/authentication.js.map +0 -1
- package/dist/sdk/constants.d.ts.map +0 -1
- package/dist/sdk/constants.js.map +0 -1
- package/dist/sdk/errors.d.ts.map +0 -1
- package/dist/sdk/errors.js.map +0 -1
- package/dist/sdk/index.d.ts +0 -8
- package/dist/sdk/index.d.ts.map +0 -1
- package/dist/sdk/index.js +0 -8
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/mocks/auth.d.ts.map +0 -1
- package/dist/sdk/mocks/auth.js.map +0 -1
- package/dist/sdk/mocks/userstorage.d.ts.map +0 -1
- package/dist/sdk/mocks/userstorage.js.map +0 -1
- package/dist/sdk/user-storage.d.ts.map +0 -1
- package/dist/sdk/user-storage.js +0 -364
- package/dist/sdk/user-storage.js.map +0 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
- package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
- package/dist/sdk/utils/validate-login-response.d.ts.map +0 -1
- package/dist/sdk/utils/validate-login-response.js.map +0 -1
- package/dist/sdk/utils/validate-pair-response.d.ts.map +0 -1
- package/dist/sdk/utils/validate-pair-response.js.map +0 -1
- package/dist/shared/encryption/cache.d.ts.map +0 -1
- package/dist/shared/encryption/cache.js.map +0 -1
- package/dist/shared/encryption/constants.d.ts.map +0 -1
- package/dist/shared/encryption/constants.js.map +0 -1
- package/dist/shared/encryption/encryption.d.ts.map +0 -1
- package/dist/shared/encryption/encryption.js +0 -202
- package/dist/shared/encryption/encryption.js.map +0 -1
- package/dist/shared/encryption/index.d.ts +0 -5
- package/dist/shared/encryption/index.d.ts.map +0 -1
- package/dist/shared/encryption/index.js +0 -5
- package/dist/shared/encryption/index.js.map +0 -1
- package/dist/shared/encryption/utils.d.ts.map +0 -1
- package/dist/shared/encryption/utils.js.map +0 -1
- package/dist/shared/env.d.ts.map +0 -1
- package/dist/shared/env.js.map +0 -1
- package/dist/shared/storage-schema.d.ts.map +0 -1
- package/dist/shared/storage-schema.js.map +0 -1
- package/dist/shared/types/encryption.d.ts.map +0 -1
- package/dist/shared/types/encryption.js +0 -2
- package/dist/shared/types/encryption.js.map +0 -1
- package/dist/shared/types/services.d.ts.map +0 -1
- package/dist/shared/types/services.js +0 -2
- package/dist/shared/types/services.js.map +0 -1
- package/dist/shared/utils/entropy-source.d.ts.map +0 -1
- package/dist/shared/utils/entropy-source.js.map +0 -1
- package/dist/shared/utils/event-queue.d.ts.map +0 -1
- package/dist/shared/utils/event-queue.js.map +0 -1
- package/dist/shared/utils/hd-keyring-seed.d.ts.map +0 -1
- package/dist/shared/utils/hd-keyring-seed.js.map +0 -1
- package/dist/shared/utils/message-signing.d.ts.map +0 -1
- package/dist/shared/utils/message-signing.js.map +0 -1
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomerServiceToken = exports.getUserProfileLineage = exports.authenticate = exports.authorizeOIDC = exports.getNonce = exports.pairProfiles = exports.pairIdentifiers = exports.CUSTOMER_SERVICE_TOKEN_URL = exports.PROFILE_LINEAGE_URL = exports.PAIR_PROFILES_URL = exports.SIWE_LOGIN_URL = exports.SRP_LOGIN_URL = exports.OIDC_TOKEN_URL = exports.PAIR_IDENTIFIERS = exports.NONCE_URL = void 0;
|
|
4
|
+
const env_js_1 = require("../../shared/env.cjs");
|
|
5
|
+
const constants_js_1 = require("../constants.cjs");
|
|
6
|
+
const errors_js_1 = require("../errors.cjs");
|
|
7
|
+
const validate_pair_response_js_1 = require("../utils/validate-pair-response.cjs");
|
|
8
|
+
const types_js_1 = require("./types.cjs");
|
|
9
|
+
/**
|
|
10
|
+
* Parse Retry-After header into milliseconds if possible.
|
|
11
|
+
* Supports seconds or HTTP-date formats.
|
|
12
|
+
*
|
|
13
|
+
* @param retryAfterHeader - The Retry-After header value (seconds or HTTP-date)
|
|
14
|
+
* @returns The retry delay in milliseconds, or null if parsing fails
|
|
15
|
+
*/
|
|
16
|
+
function parseRetryAfter(retryAfterHeader) {
|
|
17
|
+
if (!retryAfterHeader) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const seconds = Number(retryAfterHeader);
|
|
21
|
+
if (!Number.isNaN(seconds)) {
|
|
22
|
+
return seconds * 1000;
|
|
23
|
+
}
|
|
24
|
+
const date = Date.parse(retryAfterHeader);
|
|
25
|
+
if (!Number.isNaN(date)) {
|
|
26
|
+
const diff = date - Date.now();
|
|
27
|
+
return diff > 0 ? diff : null;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extracts error details from a Response object.
|
|
33
|
+
*
|
|
34
|
+
* @param response - The HTTP response object
|
|
35
|
+
* @returns Formatted error message with HTTP status and response body
|
|
36
|
+
*/
|
|
37
|
+
async function getResponseErrorMessage(response) {
|
|
38
|
+
const { status } = response;
|
|
39
|
+
const clonedResponse = response.clone();
|
|
40
|
+
let message = 'Unknown error';
|
|
41
|
+
let error = 'unknown';
|
|
42
|
+
try {
|
|
43
|
+
const responseBody = (await response.json());
|
|
44
|
+
message =
|
|
45
|
+
'message' in responseBody
|
|
46
|
+
? responseBody.message
|
|
47
|
+
: responseBody.error_description;
|
|
48
|
+
error = responseBody.error ?? 'unknown';
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
try {
|
|
52
|
+
const textContent = await clonedResponse.text();
|
|
53
|
+
message = textContent
|
|
54
|
+
? textContent.slice(0, 150)
|
|
55
|
+
: 'Non-JSON error response';
|
|
56
|
+
error = 'non_json_response';
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
message = 'Unable to parse error response';
|
|
60
|
+
error = 'unparseable_response';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return `HTTP ${status} - ${message} (error: ${error})`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Type guard to check if an object is a Response-like object.
|
|
67
|
+
*
|
|
68
|
+
* @param obj - The object to check
|
|
69
|
+
* @returns True if the object is a Response-like object, false otherwise
|
|
70
|
+
*/
|
|
71
|
+
const isErrorResponse = (obj) => typeof obj === 'object' &&
|
|
72
|
+
obj !== null &&
|
|
73
|
+
'status' in obj &&
|
|
74
|
+
'headers' in obj;
|
|
75
|
+
/**
|
|
76
|
+
* Throws a domain-specific error for service failures.
|
|
77
|
+
* Handles both HTTP error responses and regular errors (network failures, etc.).
|
|
78
|
+
* For HTTP 429, throws RateLimitedError with Retry-After header parsing.
|
|
79
|
+
*
|
|
80
|
+
* @param error - The error (Response object or caught error)
|
|
81
|
+
* @param errorPrefix - Context prefix for the error message
|
|
82
|
+
* @param ErrorClass - The domain-specific error class to throw
|
|
83
|
+
* @throws RateLimitedError for 429, otherwise ErrorClass
|
|
84
|
+
*/
|
|
85
|
+
async function throwServiceError(error, errorPrefix, ErrorClass) {
|
|
86
|
+
// Re-throw RateLimitedError or matching ErrorClass as-is (don't double-wrap)
|
|
87
|
+
if (error instanceof errors_js_1.RateLimitedError || error instanceof ErrorClass) {
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
// Not a Response-like object - handle as regular error
|
|
91
|
+
if (!isErrorResponse(error)) {
|
|
92
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
93
|
+
throw new ErrorClass(`${errorPrefix}: ${errorMessage}`);
|
|
94
|
+
}
|
|
95
|
+
// Handle HTTP error response
|
|
96
|
+
const response = error;
|
|
97
|
+
const { status } = response;
|
|
98
|
+
const responseMessage = await getResponseErrorMessage(response);
|
|
99
|
+
if (status === constants_js_1.HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
|
|
100
|
+
const retryAfterHeader = response.headers.get('Retry-After');
|
|
101
|
+
const retryAfterMs = parseRetryAfter(retryAfterHeader);
|
|
102
|
+
throw new errors_js_1.RateLimitedError(`${errorPrefix}: ${responseMessage}`, retryAfterMs ?? undefined);
|
|
103
|
+
}
|
|
104
|
+
throw new ErrorClass(`${errorPrefix}: ${responseMessage}`);
|
|
105
|
+
}
|
|
106
|
+
const NONCE_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/nonce`;
|
|
107
|
+
exports.NONCE_URL = NONCE_URL;
|
|
108
|
+
const PAIR_IDENTIFIERS = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/identifiers/pair`;
|
|
109
|
+
exports.PAIR_IDENTIFIERS = PAIR_IDENTIFIERS;
|
|
110
|
+
const OIDC_TOKEN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).oidcApiUrl}/oauth2/token`;
|
|
111
|
+
exports.OIDC_TOKEN_URL = OIDC_TOKEN_URL;
|
|
112
|
+
const SRP_LOGIN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/srp/login`;
|
|
113
|
+
exports.SRP_LOGIN_URL = SRP_LOGIN_URL;
|
|
114
|
+
const SIWE_LOGIN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/siwe/login`;
|
|
115
|
+
exports.SIWE_LOGIN_URL = SIWE_LOGIN_URL;
|
|
116
|
+
const PAIR_PROFILES_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/profile/pair`;
|
|
117
|
+
exports.PAIR_PROFILES_URL = PAIR_PROFILES_URL;
|
|
118
|
+
const PROFILE_LINEAGE_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/profile/lineage`;
|
|
119
|
+
exports.PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL;
|
|
120
|
+
const CUSTOMER_SERVICE_TOKEN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/customer-service/token`;
|
|
121
|
+
exports.CUSTOMER_SERVICE_TOKEN_URL = CUSTOMER_SERVICE_TOKEN_URL;
|
|
122
|
+
const getAuthenticationUrl = (authType, env) => {
|
|
123
|
+
switch (authType) {
|
|
124
|
+
case types_js_1.AuthType.SRP:
|
|
125
|
+
return (0, exports.SRP_LOGIN_URL)(env);
|
|
126
|
+
case types_js_1.AuthType.SiWE:
|
|
127
|
+
return (0, exports.SIWE_LOGIN_URL)(env);
|
|
128
|
+
/* istanbul ignore next */
|
|
129
|
+
default:
|
|
130
|
+
throw new errors_js_1.ValidationError(`Invalid AuthType: ${authType} - unable to create Auth URL`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const parseProfileAliases = (raw) => {
|
|
134
|
+
return raw.map((alias) => ({
|
|
135
|
+
aliasProfileId: alias.alias_profile_id,
|
|
136
|
+
canonicalProfileId: alias.canonical_profile_id,
|
|
137
|
+
identifierIds: alias.identifier_ids ?? [],
|
|
138
|
+
}));
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Pair multiple identifiers under a single profile
|
|
142
|
+
*
|
|
143
|
+
* @param nonce - session nonce
|
|
144
|
+
* @param logins - pairing request payload
|
|
145
|
+
* @param accessToken - JWT access token used to access protected resources
|
|
146
|
+
* @param env - server environment
|
|
147
|
+
* @returns void.
|
|
148
|
+
*/
|
|
149
|
+
async function pairIdentifiers(nonce, logins, accessToken, env) {
|
|
150
|
+
const pairUrl = new URL((0, exports.PAIR_IDENTIFIERS)(env));
|
|
151
|
+
try {
|
|
152
|
+
const response = await fetch(pairUrl, {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: {
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
Authorization: `Bearer ${accessToken}`,
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify({
|
|
159
|
+
nonce,
|
|
160
|
+
logins,
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
return await throwServiceError(response, 'Failed to pair identifiers', errors_js_1.PairError);
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return await throwServiceError(error, 'Failed to pair identifiers', errors_js_1.PairError);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.pairIdentifiers = pairIdentifiers;
|
|
173
|
+
/**
|
|
174
|
+
* Pair multiple profiles using their OIDC access tokens.
|
|
175
|
+
* Idempotent — calling with already-paired tokens is a no-op.
|
|
176
|
+
*
|
|
177
|
+
* @param accessTokens - Two or more OIDC access tokens to pair
|
|
178
|
+
* @param authAccessToken - A valid access token for the Authorization header
|
|
179
|
+
* @param env - server environment
|
|
180
|
+
* @returns The pair response containing the canonical profile and aliases
|
|
181
|
+
*/
|
|
182
|
+
async function pairProfiles(accessTokens, authAccessToken, env) {
|
|
183
|
+
const pairUrl = new URL((0, exports.PAIR_PROFILES_URL)(env));
|
|
184
|
+
try {
|
|
185
|
+
const response = await fetch(pairUrl, {
|
|
186
|
+
method: 'POST',
|
|
187
|
+
headers: {
|
|
188
|
+
'Content-Type': 'application/json',
|
|
189
|
+
Authorization: `Bearer ${authAccessToken}`,
|
|
190
|
+
},
|
|
191
|
+
body: JSON.stringify({
|
|
192
|
+
jwts: accessTokens,
|
|
193
|
+
}),
|
|
194
|
+
});
|
|
195
|
+
if (!response.ok) {
|
|
196
|
+
return await throwServiceError(response, 'Failed to pair profiles', errors_js_1.PairError);
|
|
197
|
+
}
|
|
198
|
+
const pairResponse = await response.json();
|
|
199
|
+
(0, validate_pair_response_js_1.validatePairResponse)(pairResponse);
|
|
200
|
+
return {
|
|
201
|
+
profile: {
|
|
202
|
+
identifierId: pairResponse.profile.identifier_id,
|
|
203
|
+
metaMetricsId: pairResponse.profile.metametrics_id ?? '',
|
|
204
|
+
profileId: pairResponse.profile.profile_id,
|
|
205
|
+
canonicalProfileId: pairResponse.profile.profile_id,
|
|
206
|
+
},
|
|
207
|
+
profileAliases: parseProfileAliases(pairResponse.profile_aliases ?? []),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
return await throwServiceError(error, 'Failed to pair profiles', errors_js_1.PairError);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.pairProfiles = pairProfiles;
|
|
215
|
+
/**
|
|
216
|
+
* Service to Get Nonce for JWT Bearer Flow
|
|
217
|
+
*
|
|
218
|
+
* @param id - identifier ID
|
|
219
|
+
* @param env - server environment
|
|
220
|
+
* @returns the nonce.
|
|
221
|
+
*/
|
|
222
|
+
async function getNonce(id, env) {
|
|
223
|
+
const nonceUrl = new URL((0, exports.NONCE_URL)(env));
|
|
224
|
+
nonceUrl.searchParams.set('identifier', id);
|
|
225
|
+
try {
|
|
226
|
+
const nonceResponse = await fetch(nonceUrl.toString());
|
|
227
|
+
if (!nonceResponse.ok) {
|
|
228
|
+
return await throwServiceError(nonceResponse, 'Failed to get nonce', errors_js_1.NonceRetrievalError);
|
|
229
|
+
}
|
|
230
|
+
const nonceJson = await nonceResponse.json();
|
|
231
|
+
return {
|
|
232
|
+
nonce: nonceJson.nonce,
|
|
233
|
+
identifier: nonceJson.identifier,
|
|
234
|
+
expiresIn: nonceJson.expires_in,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
return await throwServiceError(error, 'Failed to get nonce', errors_js_1.NonceRetrievalError);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.getNonce = getNonce;
|
|
242
|
+
/**
|
|
243
|
+
* Service to Authorize And perform OIDC Flow to get the Access Token
|
|
244
|
+
*
|
|
245
|
+
* @param jwtToken - The original token received from Authentication. This is traded for the Access Token. (the authentication token is single-use)
|
|
246
|
+
* @param env - server environment
|
|
247
|
+
* @param platform - SDK platform
|
|
248
|
+
* @returns Access Token from Authorization server
|
|
249
|
+
*/
|
|
250
|
+
async function authorizeOIDC(jwtToken, env, platform) {
|
|
251
|
+
const grantType = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
|
|
252
|
+
const headers = {
|
|
253
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
254
|
+
};
|
|
255
|
+
const urlEncodedBody = new URLSearchParams();
|
|
256
|
+
urlEncodedBody.append('grant_type', grantType);
|
|
257
|
+
urlEncodedBody.append('client_id', (0, env_js_1.getOidcClientId)(env, platform));
|
|
258
|
+
urlEncodedBody.append('assertion', jwtToken);
|
|
259
|
+
try {
|
|
260
|
+
const response = await fetch((0, exports.OIDC_TOKEN_URL)(env), {
|
|
261
|
+
method: 'POST',
|
|
262
|
+
headers,
|
|
263
|
+
body: urlEncodedBody.toString(),
|
|
264
|
+
});
|
|
265
|
+
if (!response.ok) {
|
|
266
|
+
return await throwServiceError(response, 'Failed to get access token', errors_js_1.SignInError);
|
|
267
|
+
}
|
|
268
|
+
const accessTokenResponse = await response.json();
|
|
269
|
+
return {
|
|
270
|
+
accessToken: accessTokenResponse.access_token,
|
|
271
|
+
expiresIn: accessTokenResponse.expires_in,
|
|
272
|
+
obtainedAt: Date.now(),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
return await throwServiceError(error, 'Failed to get access token', errors_js_1.SignInError);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
exports.authorizeOIDC = authorizeOIDC;
|
|
280
|
+
/**
|
|
281
|
+
* Service to Authenticate/Login a user via SIWE or SRP derived key.
|
|
282
|
+
*
|
|
283
|
+
* @param rawMessage - raw message for validation when authenticating
|
|
284
|
+
* @param signature - signed raw message
|
|
285
|
+
* @param authType - authentication type/flow used
|
|
286
|
+
* @param env - server environment
|
|
287
|
+
* @param metametrics - optional metametrics
|
|
288
|
+
* @param identifierType - login identifier type included in metametrics
|
|
289
|
+
* (defaults to `SRP` when metametrics is present)
|
|
290
|
+
* @returns Authentication Token
|
|
291
|
+
*/
|
|
292
|
+
async function authenticate(rawMessage, signature, authType, env, metametrics, identifierType = 'SRP') {
|
|
293
|
+
const authenticationUrl = getAuthenticationUrl(authType, env);
|
|
294
|
+
try {
|
|
295
|
+
const response = await fetch(authenticationUrl, {
|
|
296
|
+
method: 'POST',
|
|
297
|
+
headers: {
|
|
298
|
+
'Content-Type': 'application/json',
|
|
299
|
+
...(authType === types_js_1.AuthType.SRP
|
|
300
|
+
? { 'X-MetaMask-Profile-Pairing': 'enabled' }
|
|
301
|
+
: {}),
|
|
302
|
+
},
|
|
303
|
+
body: JSON.stringify({
|
|
304
|
+
signature,
|
|
305
|
+
raw_message: rawMessage,
|
|
306
|
+
...(metametrics
|
|
307
|
+
? {
|
|
308
|
+
metametrics: {
|
|
309
|
+
metametrics_id: await metametrics.getMetaMetricsId(),
|
|
310
|
+
agent: metametrics.agent,
|
|
311
|
+
app_version: await metametrics.getAppVersion?.(),
|
|
312
|
+
identifier_type: identifierType,
|
|
313
|
+
},
|
|
314
|
+
}
|
|
315
|
+
: {}),
|
|
316
|
+
}),
|
|
317
|
+
});
|
|
318
|
+
if (!response.ok) {
|
|
319
|
+
return await throwServiceError(response, `Failed to login with ${authType}`, errors_js_1.SignInError);
|
|
320
|
+
}
|
|
321
|
+
const loginResponse = await response.json();
|
|
322
|
+
return {
|
|
323
|
+
token: loginResponse.token,
|
|
324
|
+
expiresIn: loginResponse.expires_in,
|
|
325
|
+
profile: {
|
|
326
|
+
identifierId: loginResponse.profile.identifier_id,
|
|
327
|
+
metaMetricsId: loginResponse.profile.metametrics_id,
|
|
328
|
+
profileId: loginResponse.profile.profile_id,
|
|
329
|
+
canonicalProfileId: loginResponse.profile.profile_id,
|
|
330
|
+
},
|
|
331
|
+
profileAliases: parseProfileAliases(loginResponse.profile_aliases ?? []),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
return await throwServiceError(error, `Failed to login with ${authType}`, errors_js_1.SignInError);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
exports.authenticate = authenticate;
|
|
339
|
+
/**
|
|
340
|
+
* Service to get the Profile Lineage
|
|
341
|
+
*
|
|
342
|
+
* @param env - server environment
|
|
343
|
+
* @param accessToken - JWT access token used to access protected resources
|
|
344
|
+
* @returns Profile Lineage information.
|
|
345
|
+
*/
|
|
346
|
+
async function getUserProfileLineage(env, accessToken) {
|
|
347
|
+
const profileLineageUrl = new URL((0, exports.PROFILE_LINEAGE_URL)(env));
|
|
348
|
+
try {
|
|
349
|
+
const response = await fetch(profileLineageUrl, {
|
|
350
|
+
method: 'GET',
|
|
351
|
+
headers: {
|
|
352
|
+
Authorization: `Bearer ${accessToken}`,
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
if (!response.ok) {
|
|
356
|
+
return await throwServiceError(response, 'Failed to get profile lineage', errors_js_1.SignInError);
|
|
357
|
+
}
|
|
358
|
+
const profileJson = await response.json();
|
|
359
|
+
return profileJson;
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
return await throwServiceError(error, 'Failed to get profile lineage', errors_js_1.SignInError);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
exports.getUserProfileLineage = getUserProfileLineage;
|
|
366
|
+
/**
|
|
367
|
+
* Service to get a Customer Service specific access token.
|
|
368
|
+
*
|
|
369
|
+
* Exchanges a valid OIDC access token for a short-lived token scoped to the
|
|
370
|
+
* customer-service audience, which Customer Service tooling consumes to
|
|
371
|
+
* identify and authenticate the user.
|
|
372
|
+
*
|
|
373
|
+
* @param env - server environment
|
|
374
|
+
* @param accessToken - JWT access token used to access protected resources
|
|
375
|
+
* @returns The customer-service access token.
|
|
376
|
+
*/
|
|
377
|
+
async function getCustomerServiceToken(env, accessToken) {
|
|
378
|
+
const customerServiceTokenUrl = new URL((0, exports.CUSTOMER_SERVICE_TOKEN_URL)(env));
|
|
379
|
+
try {
|
|
380
|
+
const response = await fetch(customerServiceTokenUrl, {
|
|
381
|
+
method: 'POST',
|
|
382
|
+
headers: {
|
|
383
|
+
Authorization: `Bearer ${accessToken}`,
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
if (!response.ok) {
|
|
387
|
+
return await throwServiceError(response, 'Failed to get customer service token', errors_js_1.SignInError);
|
|
388
|
+
}
|
|
389
|
+
const tokenResponse = await response.json();
|
|
390
|
+
if (typeof tokenResponse?.access_token !== 'string') {
|
|
391
|
+
throw new errors_js_1.SignInError('Failed to get customer service token: missing access_token');
|
|
392
|
+
}
|
|
393
|
+
return tokenResponse.access_token;
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
return await throwServiceError(error, 'Failed to get customer service token', errors_js_1.SignInError);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
exports.getCustomerServiceToken = getCustomerServiceToken;
|
|
400
|
+
//# sourceMappingURL=services.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":";;;AACA,iDAAkE;AAElE,mDAAoD;AACpD,6CAMsB;AACtB,mFAA0E;AAS1E,0CAAsC;AAEtC;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,gBAA+B;IACtD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,uBAAuB,CAAC,QAAkB;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IAC5B,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IAExC,IAAI,OAAO,GAAG,eAAe,CAAC;IAC9B,IAAI,KAAK,GAAG,SAAS,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,C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,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,iBAAiB,CAC5B,KAAK,EACL,+BAA+B,EAC/B,uBAAW,CACZ,CAAC;IACJ,CAAC;AACH,CAAC;AA/BD,sDA+BC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,uBAAuB,CAC3C,GAAQ,EACR,WAAmB;IAEnB,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,IAAA,kCAA0B,EAAC,GAAG,CAAC,CAAC,CAAC;IAEzE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uBAAuB,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,MAAM,iBAAiB,CAC5B,QAAQ,EACR,sCAAsC,EACtC,uBAAW,CACZ,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,OAAO,aAAa,EAAE,YAAY,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,IAAI,uBAAW,CACnB,4DAA4D,CAC7D,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC,YAAY,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,iBAAiB,CAC5B,KAAK,EACL,sCAAsC,EACtC,uBAAW,CACZ,CAAC;IACJ,CAAC;AACH,CAAC;AApCD,0DAoCC","sourcesContent":["import type { Env, Platform } from '../../shared/env.js';\nimport { getEnvUrls, getOidcClientId } from '../../shared/env.js';\nimport type { MetaMetricsAuth } from '../../shared/types/services.js';\nimport { HTTP_STATUS_CODES } from '../constants.js';\nimport {\n NonceRetrievalError,\n PairError,\n SignInError,\n ValidationError,\n RateLimitedError,\n} from '../errors.js';\nimport { validatePairResponse } from '../utils/validate-pair-response.js';\nimport type {\n AccessToken,\n ErrorMessage,\n LoginIdentifierType,\n ProfileAlias,\n UserProfile,\n UserProfileLineage,\n} from './types.js';\nimport { AuthType } from './types.js';\n\n/**\n * Parse Retry-After header into milliseconds if possible.\n * Supports seconds or HTTP-date formats.\n *\n * @param retryAfterHeader - The Retry-After header value (seconds or HTTP-date)\n * @returns The retry delay in milliseconds, or null if parsing fails\n */\nfunction parseRetryAfter(retryAfterHeader: string | null): number | null {\n if (!retryAfterHeader) {\n return null;\n }\n const seconds = Number(retryAfterHeader);\n if (!Number.isNaN(seconds)) {\n return seconds * 1000;\n }\n const date = Date.parse(retryAfterHeader);\n if (!Number.isNaN(date)) {\n const diff = date - Date.now();\n return diff > 0 ? diff : null;\n }\n return null;\n}\n\n/**\n * Extracts error details from a Response object.\n *\n * @param response - The HTTP response object\n * @returns Formatted error message with HTTP status and response body\n */\nasync function getResponseErrorMessage(response: Response): Promise<string> {\n const { status } = response;\n const clonedResponse = response.clone();\n\n let message = 'Unknown error';\n let error = 'unknown';\n\n try {\n const responseBody = (await response.json()) as\n | ErrorMessage\n // eslint-disable-next-line @typescript-eslint/naming-convention\n | { error_description: string; error: string };\n\n message =\n 'message' in responseBody\n ? responseBody.message\n : responseBody.error_description;\n error = responseBody.error ?? 'unknown';\n } catch {\n try {\n const textContent = await clonedResponse.text();\n message = textContent\n ? textContent.slice(0, 150)\n : 'Non-JSON error response';\n error = 'non_json_response';\n } catch {\n message = 'Unable to parse error response';\n error = 'unparseable_response';\n }\n }\n\n return `HTTP ${status} - ${message} (error: ${error})`;\n}\n\n/**\n * Type guard to check if an object is a Response-like object.\n *\n * @param obj - The object to check\n * @returns True if the object is a Response-like object, false otherwise\n */\nconst isErrorResponse = (obj: unknown): obj is Response =>\n typeof obj === 'object' &&\n obj !== null &&\n 'status' in obj &&\n 'headers' in obj;\n\n/**\n * Throws a domain-specific error for service failures.\n * Handles both HTTP error responses and regular errors (network failures, etc.).\n * For HTTP 429, throws RateLimitedError with Retry-After header parsing.\n *\n * @param error - The error (Response object or caught error)\n * @param errorPrefix - Context prefix for the error message\n * @param ErrorClass - The domain-specific error class to throw\n * @throws RateLimitedError for 429, otherwise ErrorClass\n */\nasync function throwServiceError(\n error: unknown,\n errorPrefix: string,\n ErrorClass: new (message: string) => Error,\n): Promise<never> {\n // Re-throw RateLimitedError or matching ErrorClass as-is (don't double-wrap)\n if (error instanceof RateLimitedError || error instanceof ErrorClass) {\n throw error;\n }\n\n // Not a Response-like object - handle as regular error\n if (!isErrorResponse(error)) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new ErrorClass(`${errorPrefix}: ${errorMessage}`);\n }\n\n // Handle HTTP error response\n const response = error;\n const { status } = response;\n const responseMessage = await getResponseErrorMessage(response);\n\n if (status === HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {\n const retryAfterHeader = response.headers.get('Retry-After');\n const retryAfterMs = parseRetryAfter(retryAfterHeader);\n throw new RateLimitedError(\n `${errorPrefix}: ${responseMessage}`,\n retryAfterMs ?? undefined,\n );\n }\n\n throw new ErrorClass(`${errorPrefix}: ${responseMessage}`);\n}\n\nexport const NONCE_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/nonce`;\n\nexport const PAIR_IDENTIFIERS = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/identifiers/pair`;\n\nexport const OIDC_TOKEN_URL = (env: Env): string =>\n `${getEnvUrls(env).oidcApiUrl}/oauth2/token`;\n\nexport const SRP_LOGIN_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/srp/login`;\n\nexport const SIWE_LOGIN_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/siwe/login`;\n\nexport const PAIR_PROFILES_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/profile/pair`;\n\nexport const PROFILE_LINEAGE_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/profile/lineage`;\n\nexport const CUSTOMER_SERVICE_TOKEN_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/customer-service/token`;\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 RawProfileAlias = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n alias_profile_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n canonical_profile_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_ids: { id: string; type: string }[];\n};\n\nconst parseProfileAliases = (raw: RawProfileAlias[]): ProfileAlias[] => {\n return raw.map((alias) => ({\n aliasProfileId: alias.alias_profile_id,\n canonicalProfileId: alias.canonical_profile_id,\n identifierIds: alias.identifier_ids ?? [],\n }));\n};\n\ntype PairRequest = {\n signature: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n encrypted_storage_key: string;\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 return await throwServiceError(\n response,\n 'Failed to pair identifiers',\n PairError,\n );\n }\n return undefined;\n } catch (error) {\n return await throwServiceError(\n error,\n 'Failed to pair identifiers',\n PairError,\n );\n }\n}\n\nexport type PairProfilesResponse = {\n profile: UserProfile;\n profileAliases: ProfileAlias[];\n};\n\n/**\n * Pair multiple profiles using their OIDC access tokens.\n * Idempotent — calling with already-paired tokens is a no-op.\n *\n * @param accessTokens - Two or more OIDC access tokens to pair\n * @param authAccessToken - A valid access token for the Authorization header\n * @param env - server environment\n * @returns The pair response containing the canonical profile and aliases\n */\nexport async function pairProfiles(\n accessTokens: string[],\n authAccessToken: string,\n env: Env,\n): Promise<PairProfilesResponse> {\n const pairUrl = new URL(PAIR_PROFILES_URL(env));\n\n try {\n const response = await fetch(pairUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${authAccessToken}`,\n },\n body: JSON.stringify({\n jwts: accessTokens,\n }),\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n 'Failed to pair profiles',\n PairError,\n );\n }\n\n const pairResponse: unknown = await response.json();\n validatePairResponse(pairResponse);\n\n return {\n profile: {\n identifierId: pairResponse.profile.identifier_id,\n metaMetricsId: pairResponse.profile.metametrics_id ?? '',\n profileId: pairResponse.profile.profile_id,\n canonicalProfileId: pairResponse.profile.profile_id,\n },\n profileAliases: parseProfileAliases(pairResponse.profile_aliases ?? []),\n };\n } catch (error) {\n return await throwServiceError(error, 'Failed to pair profiles', PairError);\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 return await throwServiceError(\n nonceResponse,\n 'Failed to get nonce',\n NonceRetrievalError,\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 (error) {\n return await throwServiceError(\n error,\n 'Failed to get nonce',\n NonceRetrievalError,\n );\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 = {\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 return await throwServiceError(\n response,\n 'Failed to get access token',\n SignInError,\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 (error) {\n return await throwServiceError(\n error,\n 'Failed to get access token',\n SignInError,\n );\n }\n}\n\ntype Authentication = {\n token: string;\n expiresIn: number;\n profile: UserProfile;\n profileAliases: ProfileAlias[];\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 * @param metametrics - optional metametrics\n * @param identifierType - login identifier type included in metametrics\n * (defaults to `SRP` when metametrics is present)\n * @returns Authentication Token\n */\nexport async function authenticate(\n rawMessage: string,\n signature: string,\n authType: AuthType,\n env: Env,\n metametrics?: MetaMetricsAuth,\n identifierType: LoginIdentifierType = 'SRP',\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 ...(authType === AuthType.SRP\n ? { 'X-MetaMask-Profile-Pairing': 'enabled' }\n : {}),\n },\n body: JSON.stringify({\n signature,\n raw_message: rawMessage,\n ...(metametrics\n ? {\n metametrics: {\n metametrics_id: await metametrics.getMetaMetricsId(),\n agent: metametrics.agent,\n app_version: await metametrics.getAppVersion?.(),\n identifier_type: identifierType,\n },\n }\n : {}),\n }),\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n `Failed to login with ${authType}`,\n SignInError,\n );\n }\n\n const loginResponse = await response.json();\n\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 canonicalProfileId: loginResponse.profile.profile_id,\n },\n profileAliases: parseProfileAliases(loginResponse.profile_aliases ?? []),\n };\n } catch (error) {\n return await throwServiceError(\n error,\n `Failed to login with ${authType}`,\n SignInError,\n );\n }\n}\n\n/**\n * Service to get the Profile Lineage\n *\n * @param env - server environment\n * @param accessToken - JWT access token used to access protected resources\n * @returns Profile Lineage information.\n */\nexport async function getUserProfileLineage(\n env: Env,\n accessToken: string,\n): Promise<UserProfileLineage> {\n const profileLineageUrl = new URL(PROFILE_LINEAGE_URL(env));\n\n try {\n const response = await fetch(profileLineageUrl, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n 'Failed to get profile lineage',\n SignInError,\n );\n }\n\n const profileJson: UserProfileLineage = await response.json();\n return profileJson;\n } catch (error) {\n return await throwServiceError(\n error,\n 'Failed to get profile lineage',\n SignInError,\n );\n }\n}\n\n/**\n * Service to get a Customer Service specific access token.\n *\n * Exchanges a valid OIDC access token for a short-lived token scoped to the\n * customer-service audience, which Customer Service tooling consumes to\n * identify and authenticate the user.\n *\n * @param env - server environment\n * @param accessToken - JWT access token used to access protected resources\n * @returns The customer-service access token.\n */\nexport async function getCustomerServiceToken(\n env: Env,\n accessToken: string,\n): Promise<string> {\n const customerServiceTokenUrl = new URL(CUSTOMER_SERVICE_TOKEN_URL(env));\n\n try {\n const response = await fetch(customerServiceTokenUrl, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n 'Failed to get customer service token',\n SignInError,\n );\n }\n\n const tokenResponse = await response.json();\n if (typeof tokenResponse?.access_token !== 'string') {\n throw new SignInError(\n 'Failed to get customer service token: missing access_token',\n );\n }\n return tokenResponse.access_token;\n } catch (error) {\n return await throwServiceError(\n error,\n 'Failed to get customer service token',\n SignInError,\n );\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Env, Platform } from
|
|
2
|
-
import type { MetaMetricsAuth } from
|
|
3
|
-
import type { AccessToken, LoginIdentifierType, ProfileAlias, UserProfile, UserProfileLineage } from
|
|
4
|
-
import { AuthType } from
|
|
1
|
+
import type { Env, Platform } from "../../shared/env.cjs";
|
|
2
|
+
import type { MetaMetricsAuth } from "../../shared/types/services.cjs";
|
|
3
|
+
import type { AccessToken, LoginIdentifierType, ProfileAlias, UserProfile, UserProfileLineage } from "./types.cjs";
|
|
4
|
+
import { AuthType } from "./types.cjs";
|
|
5
5
|
export declare const NONCE_URL: (env: Env) => string;
|
|
6
6
|
export declare const PAIR_IDENTIFIERS: (env: Env) => string;
|
|
7
7
|
export declare const OIDC_TOKEN_URL: (env: Env) => string;
|
|
@@ -102,4 +102,4 @@ export declare function getUserProfileLineage(env: Env, accessToken: string): Pr
|
|
|
102
102
|
*/
|
|
103
103
|
export declare function getCustomerServiceToken(env: Env, accessToken: string): Promise<string>;
|
|
104
104
|
export {};
|
|
105
|
-
//# sourceMappingURL=services.d.
|
|
105
|
+
//# sourceMappingURL=services.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,6BAA4B;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,wCAAuC;AAUtE,OAAO,KAAK,EACV,WAAW,EAEX,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,kBAAkB,EACnB,oBAAmB;AACpB,OAAO,EAAE,QAAQ,EAAE,oBAAmB;AAwHtC,eAAO,MAAM,SAAS,QAAS,GAAG,KAAG,MACS,CAAC;AAE/C,eAAO,MAAM,gBAAgB,QAAS,GAAG,KAAG,MACa,CAAC;AAE1D,eAAO,MAAM,cAAc,QAAS,GAAG,KAAG,MACI,CAAC;AAE/C,eAAO,MAAM,aAAa,QAAS,GAAG,KAAG,MACS,CAAC;AAEnD,eAAO,MAAM,cAAc,QAAS,GAAG,KAAG,MACS,CAAC;AAEpD,eAAO,MAAM,iBAAiB,QAAS,GAAG,KAAG,MACQ,CAAC;AAEtD,eAAO,MAAM,mBAAmB,QAAS,GAAG,KAAG,MACS,CAAC;AAEzD,eAAO,MAAM,0BAA0B,QAAS,GAAG,KAAG,MACS,CAAC;AAgBhE,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAmBF,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,WAAW,EAAE,MAAM,CAAC;IAEpB,qBAAqB,EAAE,MAAM,CAAC;IAE9B,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC;CACjC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAA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AC3C,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Env, Platform } from "../../shared/env.mjs";
|
|
2
|
+
import type { MetaMetricsAuth } from "../../shared/types/services.mjs";
|
|
3
|
+
import type { AccessToken, LoginIdentifierType, ProfileAlias, UserProfile, UserProfileLineage } from "./types.mjs";
|
|
4
|
+
import { AuthType } from "./types.mjs";
|
|
5
|
+
export declare const NONCE_URL: (env: Env) => string;
|
|
6
|
+
export declare const PAIR_IDENTIFIERS: (env: Env) => string;
|
|
7
|
+
export declare const OIDC_TOKEN_URL: (env: Env) => string;
|
|
8
|
+
export declare const SRP_LOGIN_URL: (env: Env) => string;
|
|
9
|
+
export declare const SIWE_LOGIN_URL: (env: Env) => string;
|
|
10
|
+
export declare const PAIR_PROFILES_URL: (env: Env) => string;
|
|
11
|
+
export declare const PROFILE_LINEAGE_URL: (env: Env) => string;
|
|
12
|
+
export declare const CUSTOMER_SERVICE_TOKEN_URL: (env: Env) => string;
|
|
13
|
+
type NonceResponse = {
|
|
14
|
+
nonce: string;
|
|
15
|
+
identifier: string;
|
|
16
|
+
expiresIn: number;
|
|
17
|
+
};
|
|
18
|
+
type PairRequest = {
|
|
19
|
+
signature: string;
|
|
20
|
+
raw_message: string;
|
|
21
|
+
encrypted_storage_key: string;
|
|
22
|
+
identifier_type: 'SIWE' | 'SRP';
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Pair multiple identifiers under a single profile
|
|
26
|
+
*
|
|
27
|
+
* @param nonce - session nonce
|
|
28
|
+
* @param logins - pairing request payload
|
|
29
|
+
* @param accessToken - JWT access token used to access protected resources
|
|
30
|
+
* @param env - server environment
|
|
31
|
+
* @returns void.
|
|
32
|
+
*/
|
|
33
|
+
export declare function pairIdentifiers(nonce: string, logins: PairRequest[], accessToken: string, env: Env): Promise<void>;
|
|
34
|
+
export type PairProfilesResponse = {
|
|
35
|
+
profile: UserProfile;
|
|
36
|
+
profileAliases: ProfileAlias[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Pair multiple profiles using their OIDC access tokens.
|
|
40
|
+
* Idempotent — calling with already-paired tokens is a no-op.
|
|
41
|
+
*
|
|
42
|
+
* @param accessTokens - Two or more OIDC access tokens to pair
|
|
43
|
+
* @param authAccessToken - A valid access token for the Authorization header
|
|
44
|
+
* @param env - server environment
|
|
45
|
+
* @returns The pair response containing the canonical profile and aliases
|
|
46
|
+
*/
|
|
47
|
+
export declare function pairProfiles(accessTokens: string[], authAccessToken: string, env: Env): Promise<PairProfilesResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Service to Get Nonce for JWT Bearer Flow
|
|
50
|
+
*
|
|
51
|
+
* @param id - identifier ID
|
|
52
|
+
* @param env - server environment
|
|
53
|
+
* @returns the nonce.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getNonce(id: string, env: Env): Promise<NonceResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Service to Authorize And perform OIDC Flow to get the Access Token
|
|
58
|
+
*
|
|
59
|
+
* @param jwtToken - The original token received from Authentication. This is traded for the Access Token. (the authentication token is single-use)
|
|
60
|
+
* @param env - server environment
|
|
61
|
+
* @param platform - SDK platform
|
|
62
|
+
* @returns Access Token from Authorization server
|
|
63
|
+
*/
|
|
64
|
+
export declare function authorizeOIDC(jwtToken: string, env: Env, platform: Platform): Promise<AccessToken>;
|
|
65
|
+
type Authentication = {
|
|
66
|
+
token: string;
|
|
67
|
+
expiresIn: number;
|
|
68
|
+
profile: UserProfile;
|
|
69
|
+
profileAliases: ProfileAlias[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Service to Authenticate/Login a user via SIWE or SRP derived key.
|
|
73
|
+
*
|
|
74
|
+
* @param rawMessage - raw message for validation when authenticating
|
|
75
|
+
* @param signature - signed raw message
|
|
76
|
+
* @param authType - authentication type/flow used
|
|
77
|
+
* @param env - server environment
|
|
78
|
+
* @param metametrics - optional metametrics
|
|
79
|
+
* @param identifierType - login identifier type included in metametrics
|
|
80
|
+
* (defaults to `SRP` when metametrics is present)
|
|
81
|
+
* @returns Authentication Token
|
|
82
|
+
*/
|
|
83
|
+
export declare function authenticate(rawMessage: string, signature: string, authType: AuthType, env: Env, metametrics?: MetaMetricsAuth, identifierType?: LoginIdentifierType): Promise<Authentication>;
|
|
84
|
+
/**
|
|
85
|
+
* Service to get the Profile Lineage
|
|
86
|
+
*
|
|
87
|
+
* @param env - server environment
|
|
88
|
+
* @param accessToken - JWT access token used to access protected resources
|
|
89
|
+
* @returns Profile Lineage information.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getUserProfileLineage(env: Env, accessToken: string): Promise<UserProfileLineage>;
|
|
92
|
+
/**
|
|
93
|
+
* Service to get a Customer Service specific access token.
|
|
94
|
+
*
|
|
95
|
+
* Exchanges a valid OIDC access token for a short-lived token scoped to the
|
|
96
|
+
* customer-service audience, which Customer Service tooling consumes to
|
|
97
|
+
* identify and authenticate the user.
|
|
98
|
+
*
|
|
99
|
+
* @param env - server environment
|
|
100
|
+
* @param accessToken - JWT access token used to access protected resources
|
|
101
|
+
* @returns The customer-service access token.
|
|
102
|
+
*/
|
|
103
|
+
export declare function getCustomerServiceToken(env: Env, accessToken: string): Promise<string>;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=services.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,6BAA4B;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,wCAAuC;AAUtE,OAAO,KAAK,EACV,WAAW,EAEX,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,kBAAkB,EACnB,oBAAmB;AACpB,OAAO,EAAE,QAAQ,EA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B,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CA2B3E;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,WAAW,CAAC,CAuCtB;AAED,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAAC;AACF;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,eAAe,EAC7B,cAAc,GAAE,mBAA2B,GAC1C,OAAO,CAAC,cAAc,CAAC,CAwDzB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA4B7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getEnvUrls, getOidcClientId } from
|
|
2
|
-
import { HTTP_STATUS_CODES } from
|
|
3
|
-
import { NonceRetrievalError, PairError, SignInError, ValidationError, RateLimitedError
|
|
4
|
-
import { validatePairResponse } from
|
|
5
|
-
import { AuthType } from
|
|
1
|
+
import { getEnvUrls, getOidcClientId } from "../../shared/env.mjs";
|
|
2
|
+
import { HTTP_STATUS_CODES } from "../constants.mjs";
|
|
3
|
+
import { NonceRetrievalError, PairError, SignInError, ValidationError, RateLimitedError } from "../errors.mjs";
|
|
4
|
+
import { validatePairResponse } from "../utils/validate-pair-response.mjs";
|
|
5
|
+
import { AuthType } from "./types.mjs";
|
|
6
6
|
/**
|
|
7
7
|
* Parse Retry-After header into milliseconds if possible.
|
|
8
8
|
* Supports seconds or HTTP-date formats.
|
|
@@ -379,4 +379,4 @@ export async function getCustomerServiceToken(env, accessToken) {
|
|
|
379
379
|
return await throwServiceError(error, 'Failed to get customer service token', SignInError);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
//# sourceMappingURL=services.
|
|
382
|
+
//# sourceMappingURL=services.mjs.map
|