@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,0CAA0C,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,+BAA+B,GAAG,0BAA0B,CACvE,GAAG,CAAC,GAAG,CACR,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GACnB,opBAAop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,CAAC,MAAM,kCAAkC,GAAG;IAChD,UAAU,EAAE,sCAAsC;IAClD,UAAU,EAAE,sBAAsB;IAClC,OAAO,EAAE;QACP;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,MAAM;YACtB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;QACD;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,SAAS;YACzB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC","sourcesContent":["import { Env, Platform } from '../../shared/env.js';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PAIR_PROFILES_URL,\n PROFILE_LINEAGE_URL,\n CUSTOMER_SERVICE_TOKEN_URL,\n} from '../authentication-jwt-bearer/services.js';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PAIR_PROFILES_URL = PAIR_PROFILES_URL(Env.PRD);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\nexport const MOCK_CUSTOMER_SERVICE_TOKEN_URL = CUSTOMER_SERVICE_TOKEN_URL(\n Env.PRD,\n);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n profile_aliases: [],\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_CUSTOMER_SERVICE_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n refresh_token: 'ory_rt_mock_refresh_token',\n expires_in: 3600,\n token_type: 'bearer',\n};\n\nexport const MOCK_PAIR_PROFILES_RESPONSE = {\n profile: {\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n metametrics_id: MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n profile_aliases: [],\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userstorage.d.ts","sourceRoot":"","sources":["../../../src/sdk/mocks/userstorage.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,QAG5B,CAAC;AACF,eAAO,MAAM,oCAAoC,QAGhD,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAqC,CAAC;AACnE,eAAO,MAAM,uBAAuB,0BAA0B,CAAC;AAC/D,eAAO,MAAM,iCAAiC,UAAiB,MAAM,oBAIlE,CAAC;AAEJ,eAAO,MAAM,qBAAqB,UAAiB,MAAM;;;EAGvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userstorage.js","sourceRoot":"","sources":["../../../src/sdk/mocks/userstorage.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CACzC,GAAG,CAAC,GAAG,EACP,GAAG,0BAA0B,CAAC,aAAa,wBAAwB,CACpE,CAAC;AACF,MAAM,CAAC,MAAM,oCAAoC,GAAG,WAAW,CAC7D,GAAG,CAAC,GAAG,EACP,0BAA0B,CAAC,aAAa,CACzC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAC/D,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE,CACvE,MAAM,UAAU,CAAC,aAAa,CAC5B,IAAI,IAAI,uBAAuB,EAC/B,gBAAgB,CACjB,CAAC;AAEJ,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE,CAAC,CAAC;IAC7D,SAAS,EAAE,kEAAkE;IAC7E,IAAI,EAAE,MAAM,iCAAiC,CAAC,IAAI,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import encryption, { createSHA256Hash } from '../../shared/encryption/index.js';\nimport { Env } from '../../shared/env.js';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../shared/storage-schema.js';\nimport { STORAGE_URL } from '../user-storage.js';\n\n// Example mock notifications storage entry (wildcard)\nexport const MOCK_STORAGE_URL = STORAGE_URL(\n Env.PRD,\n `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n);\nexport const MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.PRD,\n USER_STORAGE_FEATURE_NAMES.notifications,\n);\n\nexport const MOCK_STORAGE_KEY = createSHA256Hash('mockStorageKey');\nexport const MOCK_NOTIFICATIONS_DATA = '{ is_compact: false }';\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async (data?: string) =>\n await encryption.encryptString(\n data ?? MOCK_NOTIFICATIONS_DATA,\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async (data?: string) => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(data),\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user-storage.d.ts","sourceRoot":"","sources":["../../src/sdk/user-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,uCAAuC,EAExC,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAA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AO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,aAAa,CACjB,IAAI,EAAE,6BAA6B,EACnC,MAAM,EAAE,CAAC,4BAA4B,EAAE,MAAM,CAAC,EAAE,EAChD,OAAO,CAAC,EAAE,wBAAwB,iBAGnC;IAEK,OAAO,CACX,IAAI,EAAE,uCAAuC,EAC7C,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;IAEK,kBAAkB,CACtB,IAAI,EAAE,6BAA6B,EACnC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAE1B;IAEK,UAAU,CACd,IAAI,EAAE,uCAAuC,EAC7C,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,qBAAqB,CACzB,IAAI,EAAE,6BAA6B,EACnC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,gBAAgB,CACpB,IAAI,EAAE,6BAA6B,EACnC,MAAM,EAAE,4BAA4B,EAAE,EACtC,OAAO,CAAC,EAAE,wBAAwB,iBAGnC;IAEK,aAAa,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB7D;CA0eF"}
|
package/dist/sdk/user-storage.js
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import { SHARED_SALT } from '../shared/encryption/constants.js';
|
|
2
|
-
import encryption, { createSHA256Hash } from '../shared/encryption/index.js';
|
|
3
|
-
import { getEnvUrls } from '../shared/env.js';
|
|
4
|
-
import { createEntryPath } from '../shared/storage-schema.js';
|
|
5
|
-
import { NotFoundError, UserStorageError } from './errors.js';
|
|
6
|
-
export const STORAGE_URL = (env, encryptedPath) => `${getEnvUrls(env).userStorageApiUrl}/api/v1/userstorage/${encryptedPath}`;
|
|
7
|
-
export class UserStorage {
|
|
8
|
-
config;
|
|
9
|
-
options;
|
|
10
|
-
env;
|
|
11
|
-
constructor(config, options) {
|
|
12
|
-
this.env = config.env;
|
|
13
|
-
this.config = config;
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
async setItem(path, value, options) {
|
|
17
|
-
await this.#upsertUserStorage(path, value, options);
|
|
18
|
-
}
|
|
19
|
-
async batchSetItems(path, values, options) {
|
|
20
|
-
await this.#batchUpsertUserStorage(path, values, options);
|
|
21
|
-
}
|
|
22
|
-
async getItem(path, options) {
|
|
23
|
-
return this.#getUserStorage(path, options);
|
|
24
|
-
}
|
|
25
|
-
async getAllFeatureItems(path, options) {
|
|
26
|
-
return this.#getUserStorageAllFeatureEntries(path, options);
|
|
27
|
-
}
|
|
28
|
-
async deleteItem(path, options) {
|
|
29
|
-
return this.#deleteUserStorage(path, options);
|
|
30
|
-
}
|
|
31
|
-
async deleteAllFeatureItems(path, options) {
|
|
32
|
-
return this.#deleteUserStorageAllFeatureEntries(path, options);
|
|
33
|
-
}
|
|
34
|
-
async batchDeleteItems(path, values, options) {
|
|
35
|
-
return this.#batchDeleteUserStorage(path, values, options);
|
|
36
|
-
}
|
|
37
|
-
async getStorageKey(entropySourceId) {
|
|
38
|
-
const userProfile = await this.config.auth.getUserProfile(entropySourceId);
|
|
39
|
-
const message = `metamask:${userProfile.profileId}`;
|
|
40
|
-
const storageKey = await this.options.storage?.getStorageKey(message, entropySourceId);
|
|
41
|
-
if (storageKey) {
|
|
42
|
-
return storageKey;
|
|
43
|
-
}
|
|
44
|
-
const storageKeySignature = await this.config.auth.signMessage(message, entropySourceId);
|
|
45
|
-
const hashedStorageKeySignature = createSHA256Hash(storageKeySignature);
|
|
46
|
-
await this.options.storage?.setStorageKey(message, hashedStorageKeySignature, entropySourceId);
|
|
47
|
-
return hashedStorageKeySignature;
|
|
48
|
-
}
|
|
49
|
-
async #upsertUserStorage(path, data, options) {
|
|
50
|
-
const entropySourceId = options?.entropySourceId;
|
|
51
|
-
try {
|
|
52
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
53
|
-
const profileScopeHeader = await this.#getProfileScopeHeader(entropySourceId, options?.useCanonicalScope);
|
|
54
|
-
const storageKey = await this.getStorageKey(entropySourceId);
|
|
55
|
-
const encryptedData = await encryption.encryptString(data, storageKey, options?.nativeScryptCrypto);
|
|
56
|
-
const encryptedPath = createEntryPath(path, storageKey);
|
|
57
|
-
const url = new URL(STORAGE_URL(this.env, encryptedPath));
|
|
58
|
-
const response = await fetch(url.toString(), {
|
|
59
|
-
method: 'PUT',
|
|
60
|
-
headers: {
|
|
61
|
-
'Content-Type': 'application/json',
|
|
62
|
-
...headers,
|
|
63
|
-
...profileScopeHeader,
|
|
64
|
-
},
|
|
65
|
-
body: JSON.stringify({ data: encryptedData }),
|
|
66
|
-
});
|
|
67
|
-
if (!response.ok) {
|
|
68
|
-
const responseBody = await response.json().catch(() => ({
|
|
69
|
-
message: 'unknown',
|
|
70
|
-
error: 'unknown',
|
|
71
|
-
}));
|
|
72
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
/* istanbul ignore next */
|
|
77
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
78
|
-
throw new UserStorageError(`failed to upsert user storage for path '${path}'. ${errorMessage}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async #batchUpsertUserStorage(path, data, options) {
|
|
82
|
-
const entropySourceId = options?.entropySourceId;
|
|
83
|
-
try {
|
|
84
|
-
if (!data.length) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
88
|
-
const profileScopeHeader = await this.#getProfileScopeHeader(entropySourceId, options?.useCanonicalScope);
|
|
89
|
-
const storageKey = await this.getStorageKey(entropySourceId);
|
|
90
|
-
const encryptedData = await Promise.all(data.map(async (d) => {
|
|
91
|
-
return [
|
|
92
|
-
this.#createEntryKey(d[0], storageKey),
|
|
93
|
-
await encryption.encryptString(d[1], storageKey, options?.nativeScryptCrypto),
|
|
94
|
-
];
|
|
95
|
-
}));
|
|
96
|
-
const url = new URL(STORAGE_URL(this.env, path));
|
|
97
|
-
const response = await fetch(url.toString(), {
|
|
98
|
-
method: 'PUT',
|
|
99
|
-
headers: {
|
|
100
|
-
'Content-Type': 'application/json',
|
|
101
|
-
...headers,
|
|
102
|
-
...profileScopeHeader,
|
|
103
|
-
},
|
|
104
|
-
body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),
|
|
105
|
-
});
|
|
106
|
-
if (!response.ok) {
|
|
107
|
-
const responseBody = await response.json().catch(() => ({
|
|
108
|
-
message: 'unknown',
|
|
109
|
-
error: 'unknown',
|
|
110
|
-
}));
|
|
111
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
/* istanbul ignore next */
|
|
116
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
117
|
-
throw new UserStorageError(`failed to batch upsert user storage for path '${path}'. ${errorMessage}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async #batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(path, encryptedData, entropySourceId, useCanonicalScope) {
|
|
121
|
-
try {
|
|
122
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
123
|
-
const profileScopeHeader = await this.#getProfileScopeHeader(entropySourceId, useCanonicalScope);
|
|
124
|
-
const url = new URL(STORAGE_URL(this.env, path));
|
|
125
|
-
const response = await fetch(url.toString(), {
|
|
126
|
-
method: 'PUT',
|
|
127
|
-
headers: {
|
|
128
|
-
'Content-Type': 'application/json',
|
|
129
|
-
...headers,
|
|
130
|
-
...profileScopeHeader,
|
|
131
|
-
},
|
|
132
|
-
body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),
|
|
133
|
-
});
|
|
134
|
-
// istanbul ignore next
|
|
135
|
-
if (!response.ok) {
|
|
136
|
-
const responseBody = await response.json().catch(() => ({
|
|
137
|
-
message: 'unknown',
|
|
138
|
-
error: 'unknown',
|
|
139
|
-
}));
|
|
140
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
/* istanbul ignore next */
|
|
145
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
146
|
-
// istanbul ignore next
|
|
147
|
-
throw new UserStorageError(`failed to batch upsert user storage for path '${path}'. ${errorMessage}`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async #getUserStorage(path, options) {
|
|
151
|
-
const entropySourceId = options?.entropySourceId;
|
|
152
|
-
try {
|
|
153
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
154
|
-
const storageKey = await this.getStorageKey(entropySourceId);
|
|
155
|
-
const encryptedPath = createEntryPath(path, storageKey);
|
|
156
|
-
const url = new URL(STORAGE_URL(this.env, encryptedPath));
|
|
157
|
-
const response = await fetch(url.toString(), {
|
|
158
|
-
headers: {
|
|
159
|
-
'Content-Type': 'application/json',
|
|
160
|
-
...headers,
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
if (response.status === 404) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
if (!response.ok) {
|
|
167
|
-
const responseBody = (await response.json());
|
|
168
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
169
|
-
}
|
|
170
|
-
const userStorage = await response.json();
|
|
171
|
-
const encryptedData = userStorage?.Data ?? null;
|
|
172
|
-
if (!encryptedData) {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
const decryptedData = await encryption.decryptString(encryptedData, storageKey, options?.nativeScryptCrypto);
|
|
176
|
-
// Re-encrypt the entry if it was encrypted with a random salt
|
|
177
|
-
const salt = encryption.getSalt(encryptedData);
|
|
178
|
-
if (salt.toString() !== SHARED_SALT.toString()) {
|
|
179
|
-
await this.#upsertUserStorage(path, decryptedData, options);
|
|
180
|
-
}
|
|
181
|
-
return decryptedData;
|
|
182
|
-
}
|
|
183
|
-
catch (e) {
|
|
184
|
-
/* istanbul ignore next */
|
|
185
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
186
|
-
throw new UserStorageError(`failed to get user storage for path '${path}'. ${errorMessage}`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async #getUserStorageAllFeatureEntries(path, options) {
|
|
190
|
-
const entropySourceId = options?.entropySourceId;
|
|
191
|
-
try {
|
|
192
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
193
|
-
const profileScopeHeader = await this.#getProfileScopeHeader(entropySourceId, options?.useCanonicalScope);
|
|
194
|
-
const storageKey = await this.getStorageKey(entropySourceId);
|
|
195
|
-
const url = new URL(STORAGE_URL(this.env, path));
|
|
196
|
-
const response = await fetch(url.toString(), {
|
|
197
|
-
headers: {
|
|
198
|
-
'Content-Type': 'application/json',
|
|
199
|
-
...headers,
|
|
200
|
-
...profileScopeHeader,
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
if (response.status === 404) {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
if (!response.ok) {
|
|
207
|
-
const responseBody = (await response.json());
|
|
208
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
209
|
-
}
|
|
210
|
-
const userStorage = await response.json();
|
|
211
|
-
if (!Array.isArray(userStorage)) {
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
const decryptedData = [];
|
|
215
|
-
const reEncryptedEntries = [];
|
|
216
|
-
for (const entry of userStorage) {
|
|
217
|
-
if (!entry.Data) {
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
try {
|
|
221
|
-
const data = await encryption.decryptString(entry.Data, storageKey, options?.nativeScryptCrypto);
|
|
222
|
-
decryptedData.push(data);
|
|
223
|
-
// Re-encrypt the entry was encrypted with a random salt
|
|
224
|
-
const salt = encryption.getSalt(entry.Data);
|
|
225
|
-
if (salt.toString() !== SHARED_SALT.toString()) {
|
|
226
|
-
reEncryptedEntries.push([
|
|
227
|
-
entry.HashedKey,
|
|
228
|
-
await encryption.encryptString(data, storageKey, options?.nativeScryptCrypto),
|
|
229
|
-
]);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
catch {
|
|
233
|
-
// do nothing
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
// Re-upload the re-encrypted entries
|
|
237
|
-
if (reEncryptedEntries.length) {
|
|
238
|
-
await this.#batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(path, reEncryptedEntries, entropySourceId, options?.useCanonicalScope);
|
|
239
|
-
}
|
|
240
|
-
return decryptedData;
|
|
241
|
-
}
|
|
242
|
-
catch (e) {
|
|
243
|
-
/* istanbul ignore next */
|
|
244
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
245
|
-
throw new UserStorageError(`failed to get user storage for path '${path}'. ${errorMessage}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async #deleteUserStorage(path, options) {
|
|
249
|
-
const entropySourceId = options?.entropySourceId;
|
|
250
|
-
try {
|
|
251
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
252
|
-
const storageKey = await this.getStorageKey(entropySourceId);
|
|
253
|
-
const encryptedPath = createEntryPath(path, storageKey);
|
|
254
|
-
const url = new URL(STORAGE_URL(this.env, encryptedPath));
|
|
255
|
-
const response = await fetch(url.toString(), {
|
|
256
|
-
method: 'DELETE',
|
|
257
|
-
headers: {
|
|
258
|
-
'Content-Type': 'application/json',
|
|
259
|
-
...headers,
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
if (response.status === 404) {
|
|
263
|
-
throw new NotFoundError(`feature/key set not found for path '${path}'.`);
|
|
264
|
-
}
|
|
265
|
-
if (!response.ok) {
|
|
266
|
-
const responseBody = (await response.json());
|
|
267
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
catch (e) {
|
|
271
|
-
if (e instanceof NotFoundError) {
|
|
272
|
-
throw e;
|
|
273
|
-
}
|
|
274
|
-
/* istanbul ignore next */
|
|
275
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
276
|
-
throw new UserStorageError(`failed to delete user storage for path '${path}'. ${errorMessage}`);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
async #deleteUserStorageAllFeatureEntries(path, options) {
|
|
280
|
-
try {
|
|
281
|
-
const entropySourceId = options?.entropySourceId;
|
|
282
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
283
|
-
const profileScopeHeader = await this.#getProfileScopeHeader(entropySourceId, options?.useCanonicalScope);
|
|
284
|
-
const url = new URL(STORAGE_URL(this.env, path));
|
|
285
|
-
const response = await fetch(url.toString(), {
|
|
286
|
-
method: 'DELETE',
|
|
287
|
-
headers: {
|
|
288
|
-
'Content-Type': 'application/json',
|
|
289
|
-
...headers,
|
|
290
|
-
...profileScopeHeader,
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
if (response.status === 404) {
|
|
294
|
-
throw new NotFoundError(`feature not found for path '${path}'.`);
|
|
295
|
-
}
|
|
296
|
-
if (!response.ok) {
|
|
297
|
-
const responseBody = (await response.json());
|
|
298
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
catch (e) {
|
|
302
|
-
if (e instanceof NotFoundError) {
|
|
303
|
-
throw e;
|
|
304
|
-
}
|
|
305
|
-
/* istanbul ignore next */
|
|
306
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
307
|
-
throw new UserStorageError(`failed to delete user storage for path '${path}'. ${errorMessage}`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
async #batchDeleteUserStorage(path, keysToDelete, options) {
|
|
311
|
-
try {
|
|
312
|
-
if (!keysToDelete.length) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const entropySourceId = options?.entropySourceId;
|
|
316
|
-
const headers = await this.#getAuthorizationHeader(entropySourceId);
|
|
317
|
-
const storageKey = await this.getStorageKey(entropySourceId);
|
|
318
|
-
const rawEntryKeys = keysToDelete.map((d) => this.#createEntryKey(d, storageKey));
|
|
319
|
-
const url = new URL(STORAGE_URL(this.env, path));
|
|
320
|
-
const response = await fetch(url.toString(), {
|
|
321
|
-
method: 'PUT',
|
|
322
|
-
headers: {
|
|
323
|
-
'Content-Type': 'application/json',
|
|
324
|
-
...headers,
|
|
325
|
-
},
|
|
326
|
-
body: JSON.stringify({ batch_delete: rawEntryKeys }),
|
|
327
|
-
});
|
|
328
|
-
if (!response.ok) {
|
|
329
|
-
const responseBody = await response.json().catch(() => ({
|
|
330
|
-
message: 'unknown',
|
|
331
|
-
error: 'unknown',
|
|
332
|
-
}));
|
|
333
|
-
throw new Error(`HTTP error message: ${responseBody.message}, error: ${responseBody.error}`);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
catch (e) {
|
|
337
|
-
/* istanbul ignore next */
|
|
338
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
339
|
-
throw new UserStorageError(`failed to batch delete user storage for path '${path}'. ${errorMessage}`);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
#createEntryKey(key, storageKey) {
|
|
343
|
-
return createSHA256Hash(key + storageKey);
|
|
344
|
-
}
|
|
345
|
-
async #getAuthorizationHeader(entropySourceId) {
|
|
346
|
-
const accessToken = await this.config.auth.getAccessToken(entropySourceId);
|
|
347
|
-
return { Authorization: `Bearer ${accessToken}` };
|
|
348
|
-
}
|
|
349
|
-
async #getProfileScopeHeader(entropySourceId, useCanonicalScope) {
|
|
350
|
-
if (useCanonicalScope) {
|
|
351
|
-
return {};
|
|
352
|
-
}
|
|
353
|
-
const profile = await this.config.auth.getUserProfile(entropySourceId);
|
|
354
|
-
if (profile.profileId !== profile.canonicalProfileId) {
|
|
355
|
-
// After SRP pairing the JWT `sub` is the canonical profile id, but
|
|
356
|
-
// user storage data is still keyed by the original per-SRP profileId.
|
|
357
|
-
// The `x-profile-id` header tells the backend to scope reads/writes to
|
|
358
|
-
// that alias partition until ADR 0005 migrates storage keys to canonical.
|
|
359
|
-
return { 'x-profile-id': profile.profileId };
|
|
360
|
-
}
|
|
361
|
-
return {};
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
//# sourceMappingURL=user-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user-storage.js","sourceRoot":"","sources":["../../src/sdk/user-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAO9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAE,aAAqB,EAAE,EAAE,CAC7D,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,iBAAiB,uBAAuB,aAAa,EAAE,CAAC;AA8C7E,MAAM,OAAO,WAAW;IACZ,MAAM,CAAoB;IAE7B,OAAO,CAAqB;IAEzB,GAAG,CAAM;IAEnB,YAAY,MAAyB,EAAE,OAA2B;QAChE,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} from '../shared/encryption/index.js';\nimport type { Env } from '../shared/env.js';\nimport { getEnvUrls } from '../shared/env.js';\nimport type {\n UserStorageGenericFeatureKey,\n UserStorageGenericFeatureName,\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../shared/storage-schema.js';\nimport { createEntryPath } from '../shared/storage-schema.js';\nimport type { NativeScrypt } from '../shared/types/encryption.js';\nimport type { IBaseAuth } from './authentication-jwt-bearer/types.js';\nimport { NotFoundError, UserStorageError } from './errors.js';\n\nexport const STORAGE_URL = (env: Env, encryptedPath: string) =>\n `${getEnvUrls(env).userStorageApiUrl}/api/v1/userstorage/${encryptedPath}`;\n\nexport type UserStorageConfig = {\n env: Env;\n auth: Pick<IBaseAuth, 'getAccessToken' | 'getUserProfile' | 'signMessage'>;\n};\n\nexport type StorageOptions = {\n getStorageKey: (\n message: `metamask:${string}`,\n entropySourceId?: string,\n ) => Promise<string | null>;\n setStorageKey: (\n message: `metamask:${string}`,\n val: string,\n entropySourceId?: string,\n ) => Promise<void>;\n};\n\nexport type UserStorageOptions = {\n storage?: StorageOptions;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n\n Data: string;\n}[];\n\nexport type UserStorageMethodOptions = {\n nativeScryptCrypto?: NativeScrypt;\n entropySourceId?: string;\n /**\n * When true, skip the `x-profile-id` header on feature-scoped requests,\n * letting the server default to the JWT `sub` (canonical profile ID).\n * Useful during canonical storage migration (ADR 0005) to read/verify\n * data stored under the canonical key.\n */\n useCanonicalScope?: boolean;\n};\n\ntype ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport class UserStorage {\n protected config: UserStorageConfig;\n\n public options: UserStorageOptions;\n\n protected env: Env;\n\n constructor(config: UserStorageConfig, options: UserStorageOptions) {\n this.env = config.env;\n this.config = config;\n this.options = options;\n }\n\n async setItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n value: string,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n await this.#upsertUserStorage(path, value, options);\n }\n\n async batchSetItems(\n path: UserStorageGenericFeatureName,\n values: [UserStorageGenericFeatureKey, string][],\n options?: UserStorageMethodOptions,\n ) {\n await this.#batchUpsertUserStorage(path, values, options);\n }\n\n async getItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<string | null> {\n return this.#getUserStorage(path, options);\n }\n\n async getAllFeatureItems(\n path: UserStorageGenericFeatureName,\n options?: UserStorageMethodOptions,\n ): Promise<string[] | null> {\n return this.#getUserStorageAllFeatureEntries(path, options);\n }\n\n async deleteItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n return this.#deleteUserStorage(path, options);\n }\n\n async deleteAllFeatureItems(\n path: UserStorageGenericFeatureName,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n return this.#deleteUserStorageAllFeatureEntries(path, options);\n }\n\n async batchDeleteItems(\n path: UserStorageGenericFeatureName,\n values: UserStorageGenericFeatureKey[],\n options?: UserStorageMethodOptions,\n ) {\n return this.#batchDeleteUserStorage(path, values, options);\n }\n\n async getStorageKey(entropySourceId?: string): Promise<string> {\n const userProfile = await this.config.auth.getUserProfile(entropySourceId);\n const message = `metamask:${userProfile.profileId}` as const;\n\n const storageKey = await this.options.storage?.getStorageKey(\n message,\n entropySourceId,\n );\n if (storageKey) {\n return storageKey;\n }\n\n const storageKeySignature = await this.config.auth.signMessage(\n message,\n entropySourceId,\n );\n const hashedStorageKeySignature = createSHA256Hash(storageKeySignature);\n await this.options.storage?.setStorageKey(\n message,\n hashedStorageKeySignature,\n entropySourceId,\n );\n return hashedStorageKeySignature;\n }\n\n async #upsertUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n data: string,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedData = await encryption.encryptString(\n data,\n storageKey,\n options?.nativeScryptCrypto,\n );\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n body: JSON.stringify({ data: encryptedData }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchUpsertUserStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n data: [string, string][],\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n if (!data.length) {\n return;\n }\n\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const encryptedData = await Promise.all(\n data.map(async (d) => {\n return [\n this.#createEntryKey(d[0], storageKey),\n await encryption.encryptString(\n d[1],\n storageKey,\n options?.nativeScryptCrypto,\n ),\n ];\n }),\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to batch upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n encryptedData: [string, string][],\n entropySourceId?: string,\n useCanonicalScope?: boolean,\n ): Promise<void> {\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n useCanonicalScope,\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),\n });\n\n // istanbul ignore next\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n // istanbul ignore next\n throw new UserStorageError(\n `failed to batch upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #getUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<string | null> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const userStorage = await response.json();\n const encryptedData = userStorage?.Data ?? null;\n\n if (!encryptedData) {\n return null;\n }\n\n const decryptedData = await encryption.decryptString(\n encryptedData,\n storageKey,\n options?.nativeScryptCrypto,\n );\n\n // Re-encrypt the entry if it was encrypted with a random salt\n const salt = encryption.getSalt(encryptedData);\n if (salt.toString() !== SHARED_SALT.toString()) {\n await this.#upsertUserStorage(path, decryptedData, options);\n }\n\n return decryptedData;\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to get user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #getUserStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n options?: UserStorageMethodOptions,\n ): Promise<string[] | null> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const userStorage: GetUserStorageAllFeatureEntriesResponse | null =\n await response.json();\n\n if (!Array.isArray(userStorage)) {\n return null;\n }\n\n const decryptedData: string[] = [];\n const reEncryptedEntries: [string, string][] = [];\n\n for (const entry of userStorage) {\n if (!entry.Data) {\n continue;\n }\n\n try {\n const data = await encryption.decryptString(\n entry.Data,\n storageKey,\n options?.nativeScryptCrypto,\n );\n decryptedData.push(data);\n\n // Re-encrypt the entry was encrypted with a random salt\n const salt = encryption.getSalt(entry.Data);\n if (salt.toString() !== SHARED_SALT.toString()) {\n reEncryptedEntries.push([\n entry.HashedKey,\n await encryption.encryptString(\n data,\n storageKey,\n options?.nativeScryptCrypto,\n ),\n ]);\n }\n } catch {\n // do nothing\n }\n }\n\n // Re-upload the re-encrypted entries\n if (reEncryptedEntries.length) {\n await this.#batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n path,\n reEncryptedEntries,\n entropySourceId,\n options?.useCanonicalScope,\n );\n }\n\n return decryptedData;\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to get user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #deleteUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n throw new NotFoundError(\n `feature/key set not found for path '${path}'.`,\n );\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n if (e instanceof NotFoundError) {\n throw e;\n }\n\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #deleteUserStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n try {\n const entropySourceId = options?.entropySourceId;\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n });\n\n if (response.status === 404) {\n throw new NotFoundError(`feature not found for path '${path}'.`);\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n if (e instanceof NotFoundError) {\n throw e;\n }\n\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchDeleteUserStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n keysToDelete: string[],\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n try {\n if (!keysToDelete.length) {\n return;\n }\n\n const entropySourceId = options?.entropySourceId;\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const rawEntryKeys = keysToDelete.map((d) =>\n this.#createEntryKey(d, storageKey),\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n\n body: JSON.stringify({ batch_delete: rawEntryKeys }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to batch delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n #createEntryKey(key: string, storageKey: string): string {\n return createSHA256Hash(key + storageKey);\n }\n\n async #getAuthorizationHeader(\n entropySourceId?: string,\n ): Promise<{ Authorization: string }> {\n const accessToken = await this.config.auth.getAccessToken(entropySourceId);\n return { Authorization: `Bearer ${accessToken}` };\n }\n\n async #getProfileScopeHeader(\n entropySourceId?: string,\n useCanonicalScope?: boolean,\n ): Promise<Record<string, string>> {\n if (useCanonicalScope) {\n return {};\n }\n const profile = await this.config.auth.getUserProfile(entropySourceId);\n if (profile.profileId !== profile.canonicalProfileId) {\n // After SRP pairing the JWT `sub` is the canonical profile id, but\n // user storage data is still keyed by the original per-SRP profileId.\n // The `x-profile-id` header tells the backend to scope reads/writes to\n // that alias partition until ADR 0005 migrates storage keys to canonical.\n return { 'x-profile-id': profile.profileId };\n }\n return {};\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip-6963-metamask-provider.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/eip-6963-metamask-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAG9C,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,2BAA2B,CAAC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;IAC9B,IAAI;IACJ,KAAK;IACL,aAAa;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAErE,KAAK,kBAAkB,GAAG,KAAK,GAAG,qBAAqB,CAAC;AAKxD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,GAAE,kBAA0B,GAC/B,OAAO,CAAC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AAmB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAE3D;;;WAGG;QACH,UAAU,CAAC,GAAG,EAAE;YACd,2BAA2B;YAC3B,MAAM,CAAC,mBAAmB,CACxB,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;YAEF,IAAI,QAAgC,CAAC;YACrC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,qCAAqC;gBACrC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBAC3D,QAAQ;oBACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ;wBACjE,IAAI,CAAC;YACT,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBAC/C,QAAQ;oBACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;YACrE,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACb,aAAa,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;YACjC,CAAC;YACD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\n// We can isolate and create a metamask function/closure\nexport type AnnounceProviderEventDetail = {\n info?: { rdns?: string };\n provider?: Eip1193Provider;\n};\nexport type AnnounceProviderEvent = CustomEvent<AnnounceProviderEventDetail>;\n\nexport const metamaskClientsRdns = {\n main: 'io.metamask',\n flask: 'io.metamask.flask',\n institutional: 'io.metamask.mmi',\n};\n\nexport type MetamaskClientRdnsKey = keyof typeof metamaskClientsRdns;\n\ntype MetaMaskClientType = 'any' | MetamaskClientRdnsKey;\n\n// Cache, as when the function is recalled, we can reuse instead of continue waiting\nconst providerCache: Partial<Record<MetaMaskClientType, Eip1193Provider>> = {};\n\n/**\n * This uses EIP6963 to find all metamask accounts and returns the first matching provider\n * the consumer requests (main, flask, institutional, or any)\n *\n * @param type - the MetaMask Wallet type (main, flask, institutional, or any)\n * @returns a ethers provider so you can make requests to that specific wallet\n */\nexport function getMetaMaskProviderEIP6963(\n type: MetaMaskClientType = 'any',\n): Promise<Eip1193Provider | null> {\n return new Promise<Eip1193Provider | null>((resolve) => {\n if (type !== 'any' && metamaskClientsRdns[type] === undefined) {\n resolve(null);\n return;\n }\n\n const cachedProvider = providerCache[type];\n if (cachedProvider) {\n resolve(cachedProvider);\n return;\n }\n\n const providers: { rdns: string; provider: Eip1193Provider }[] = [];\n\n const handleProviderEvent = (event: unknown) => {\n const typedEvent = event as CustomEvent<AnnounceProviderEventDetail>;\n const providerDetail = typedEvent?.detail;\n if (providerDetail?.provider && providerDetail?.info?.rdns) {\n providers.push({\n rdns: providerDetail?.info?.rdns,\n provider: providerDetail?.provider,\n });\n }\n };\n\n window.addEventListener('eip6963:announceProvider', handleProviderEvent);\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n\n /**\n * It may take some time for the events to be emitted from the different wallets.\n * So waiting a small period of time before we use the collected events.\n */\n setTimeout(() => {\n // remove attached listener\n window.removeEventListener(\n 'eip6963:announceProvider',\n handleProviderEvent,\n );\n\n let provider: Eip1193Provider | null;\n if (type === 'any') {\n // return the first MM client we find\n const metamaskClients = Object.values(metamaskClientsRdns);\n provider =\n providers.find((p) => metamaskClients.includes(p.rdns))?.provider ??\n null;\n } else {\n const metamaskRdns = metamaskClientsRdns[type];\n provider =\n providers.find((p) => p.rdns === metamaskRdns)?.provider ?? null;\n }\n\n if (provider) {\n providerCache[type] = provider;\n }\n return resolve(provider);\n }, 100);\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messaging-signing-snap-requests.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/messaging-signing-snap-requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,IAAI,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEpD,eAAO,MAAM,WAAW,uCAAuC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAS5E;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAM3B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,eAAO,MAAM,oBAAoB;IACzB,YAAY,WAAW,eAAe,oBAAoB,MAAM;IAehE,WAAW,WACL,eAAe,WAChB,YAAY,MAAM,EAAE,oBACX,MAAM;CAkB3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,IAAI,YAAY,MAAM,EAAE,CAIzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messaging-signing-snap-requests.js","sourceRoot":"","sources":["../../../src/sdk/utils/messaging-signing-snap-requests.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,WAAW,GAAG,oCAAo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MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,QAAyB,EACzB,OAA6B,EAC7B,eAAwB;QAExB,MAAM,aAAa,GAAW,MAAM,QAAQ,EAAE,OAAO,CAAC;YACpD,MAAM,EAAE,mBAAmB;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE;oBACP,MAAM,EAAE,aAAa;oBACrB,MAAM,EAAE;wBACN,OAAO;wBACP,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD;iBACF;aACF;SACF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAC7C,OAAe;IAEf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\nexport type Snap = {\n permissionName: string;\n id: string;\n version: string;\n initialPermissions: Record<string, unknown>;\n};\nexport type GetSnapsResponse = Record<string, Snap>;\n\nexport const SNAP_ORIGIN = 'npm:@metamask/message-signing-snap';\n\n/**\n * Requests Connection to the Message Signing Snap\n *\n * @param provider - MetaMask Wallet Provider\n * @returns snap connect result\n */\nexport async function connectSnap(provider: Eip1193Provider): Promise<string> {\n const result: string = await provider.request({\n method: 'wallet_requestSnaps',\n params: {\n [SNAP_ORIGIN]: {},\n },\n });\n\n return result;\n}\n\n/**\n * Gets Snaps from a MetaMask Wallet\n *\n * @param provider - MetaMask Wallet Provider\n * @returns All currently installed snaps.\n */\nexport async function getSnaps(\n provider: Eip1193Provider,\n): Promise<GetSnapsResponse> {\n const result: GetSnapsResponse = await provider.request({\n method: 'wallet_getSnaps',\n });\n\n return result;\n}\n\n/**\n * Check if snap is connected\n *\n * @param provider - MetaMask Wallet Provider\n * @returns if snap is connected\n */\nexport async function isSnapConnected(\n provider: Eip1193Provider,\n): Promise<boolean> {\n try {\n const snaps = await getSnaps(provider);\n if (!snaps) {\n return false;\n }\n return Object.keys(snaps).includes(SNAP_ORIGIN);\n } catch (e) {\n console.error('Failed to determine if snap is connected', e);\n return false;\n }\n}\n\nexport const MESSAGE_SIGNING_SNAP = {\n async getPublicKey(provider: Eip1193Provider, entropySourceId?: string) {\n const publicKey: string = await provider.request({\n method: 'wallet_invokeSnap',\n params: {\n snapId: SNAP_ORIGIN,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n },\n });\n\n return publicKey;\n },\n\n async signMessage(\n provider: Eip1193Provider,\n message: `metamask:${string}`,\n entropySourceId?: string,\n ) {\n const signedMessage: string = await provider?.request({\n method: 'wallet_invokeSnap',\n params: {\n snapId: SNAP_ORIGIN,\n request: {\n method: 'signMessage',\n params: {\n message,\n ...(entropySourceId ? { entropySourceId } : {}),\n },\n },\n },\n });\n\n return signedMessage;\n },\n};\n\n/**\n * Asserts that a message starts with \"metamask:\"\n *\n * @param message - The message to check.\n */\nexport function assertMessageStartsWithMetamask(\n message: string,\n): asserts message is `metamask:${string}` {\n if (!message.startsWith('metamask:')) {\n throw new Error('Message must start with \"metamask:\"');\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-login-response.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAgB5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-login-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication.js';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return true;\n }\n const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');\n const { exp } = JSON.parse(atob(base64));\n return !Number.isInteger(exp) || exp * 1000 <= Date.now();\n } catch {\n return true;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-pair-response.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,eAAe,CAwBlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-pair-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAiBzD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,OAAO,GAAG,KAAgC,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAA8C,CAAC;IACvE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\ntype RawProfileAlias = {\n alias_profile_id: string;\n canonical_profile_id: string;\n identifier_ids: { id: string; type: string }[];\n};\n\nexport type RawPairResponse = {\n profile: {\n profile_id: string;\n identifier_id: string;\n metametrics_id?: string;\n };\n profile_aliases?: RawProfileAlias[];\n};\n\n/**\n * Asserts that the raw API response from the profile pairing endpoint has the\n * expected shape before we attempt to map it into a `PairProfilesResponse`.\n * Throws if the response is malformed.\n *\n * @param input - The raw JSON parsed from the pair endpoint response body.\n */\nexport function validatePairResponse(\n input: unknown,\n): asserts input is RawPairResponse {\n if (!input || typeof input !== 'object') {\n throw new Error('validatePairResponse: input is not an object');\n }\n\n const assumed = input as Record<string, unknown>;\n const profile = assumed.profile as Record<string, unknown> | undefined;\n if (!profile || typeof profile !== 'object') {\n throw new Error(\n 'validatePairResponse: profile is missing or not an object',\n );\n }\n\n if (typeof profile.profile_id !== 'string' || !profile.profile_id) {\n throw new Error(\n 'validatePairResponse: profile.profile_id is missing or empty',\n );\n }\n\n if (typeof profile.identifier_id !== 'string' || !profile.identifier_id) {\n throw new Error(\n 'validatePairResponse: profile.identifier_id is missing or empty',\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/shared/encryption/cache.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,UAAU,CAAC;CACjB,CAAC;AAiBF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,UAAU,GACf,WAAW,GAAG,SAAS,CAazB;AAED;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,cAAc,EAAE,MAAM,GACrB,WAAW,GAAG,SAAS,CAczB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,UAAU,GACd,IAAI,CAeN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/shared/encryption/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,E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AC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,mBAAmB,EAAE,CAAC;QAC7D,cAAc,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE3C,kBAAkB;IAClB,IAAI,KAAK,CAAC,IAAI,GAAG,eAAe,EAAE,CAAC;QACjC,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { SHARED_SALT } from './constants.js';\nimport { byteArrayToBase64 } from './utils.js';\n\ntype CachedEntry = {\n salt: Uint8Array;\n base64Salt: string;\n key: Uint8Array;\n};\n\nconst MAX_PASSWORD_CACHES = 100;\nconst MAX_SALT_CACHES = 100;\n\n/**\n * In-Memory Caching derived keys based from a given salt and password.\n */\ntype PasswordMemCachedKDF = {\n [hashedPassword: string]: Map<string, Uint8Array>;\n};\nlet inMemCachedKDF: PasswordMemCachedKDF = {};\nconst getPasswordCache = (hashedPassword: string) => {\n inMemCachedKDF[hashedPassword] ??= new Map();\n return inMemCachedKDF[hashedPassword];\n};\n\n/**\n * Returns a given cached derived key from a hashed password and salt\n *\n * @param hashedPassword - hashed password for cache lookup\n * @param salt - provide salt to receive cached key\n * @returns cached key\n */\nexport function getCachedKeyBySalt(\n hashedPassword: string,\n salt: Uint8Array,\n): CachedEntry | undefined {\n const cache = getPasswordCache(hashedPassword);\n const base64Salt = byteArrayToBase64(salt);\n const cachedKey = cache.get(base64Salt);\n if (!cachedKey) {\n return undefined;\n }\n\n return {\n salt,\n base64Salt,\n key: cachedKey,\n };\n}\n\n/**\n * Gets the cached key that was generated without a salt, if it exists.\n * This is unique per hashed password.\n *\n * @param hashedPassword - hashed password for cache lookup\n * @returns the cached key\n */\nexport function getCachedKeyGeneratedWithSharedSalt(\n hashedPassword: string,\n): CachedEntry | undefined {\n const cache = getPasswordCache(hashedPassword);\n const base64Salt = byteArrayToBase64(SHARED_SALT);\n const cachedKey = cache.get(base64Salt);\n\n if (!cachedKey) {\n return undefined;\n }\n\n return {\n salt: SHARED_SALT,\n base64Salt,\n key: cachedKey,\n };\n}\n\n/**\n * Sets a key to the in memory cache.\n * We have set an arbitrary size of 10 cached keys per hashed password.\n *\n * @param hashedPassword - hashed password for cache lookup\n * @param salt - salt to set new derived key\n * @param key - derived key we are setting\n */\nexport function setCachedKey(\n hashedPassword: string,\n salt: Uint8Array,\n key: Uint8Array,\n): void {\n // Max password caches\n if (Object.keys(inMemCachedKDF).length > MAX_PASSWORD_CACHES) {\n inMemCachedKDF = {};\n }\n\n const cache = getPasswordCache(hashedPassword);\n const base64Salt = byteArrayToBase64(salt);\n\n // Max salt caches\n if (cache.size > MAX_SALT_CACHES) {\n cache.clear();\n }\n\n cache.set(base64Salt, key);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/shared/encryption/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAIrC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,QAAQ,QAAU,CAAC;AAChC,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,eAAO,MAAM,QAAQ,IAAI,CAAC;AAE1B,eAAO,MAAM,WAAW,yBAEtB,CAAC;AAEH,eAAO,MAAM,0BAA0B,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/shared/encryption/constants.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC,CAAC,WAAW;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC,CAAC,WAAW;AAEjD,kBAAkB;AAClB,+FAA+F;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC,CAAC,WAAW;AAC/C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,wDAAwD;AACzF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,uBAAuB;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,4BAA4B;AAEvD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC;IACxC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC","sourcesContent":["// Nonce/Key Sizes\nexport const ALGORITHM_NONCE_SIZE = 12; // 12 bytes\nexport const ALGORITHM_KEY_SIZE = 16; // 16 bytes\n\n// Scrypt settings\n// see: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#scrypt\nexport const SCRYPT_SALT_SIZE = 16; // 16 bytes\nexport const SCRYPT_N = 2 ** 17; // CPU/memory cost parameter (must be a power of 2, > 1)\nexport const SCRYPT_r = 8; // Block size parameter\nexport const SCRYPT_p = 1; // Parallelization parameter\n\nexport const SHARED_SALT = new Uint8Array([\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n]);\n\nexport const MAX_KDF_PROMISE_CACHE_SIZE = 20;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/shared/encryption/encryption.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAuB3D,MAAM,MAAM,gBAAgB,GAAG;IAE7B,CAAC,EAAE,GAAG,CAAC;IAGP,CAAC,EAAE,QAAQ,CAAC;IAGZ,CAAC,EAAE,MAAM,CAAC;IAGV,CAAC,EAAE;QACD,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IAGF,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,cAAM,kBAAkB;;IAOhB,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,CAAC,EAAE,YAAY,GAChC,OAAO,CAAC,MAAM,CAAC,CAWjB;IAEK,aAAa,CACjB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,CAAC,EAAE,YAAY,GAChC,OAAO,CAAC,MAAM,CAAC,CAmBjB;IAiFD,OAAO,CAAC,gBAAgB,EAAE,MAAM,2BAwB/B;IAED,8BAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAazD;CAqIF;AAED,QAAA,MAAM,UAAU,oBAA2B,CAAC;eAC7B,UAAU;AAEzB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD"}
|