@oxyhq/services 5.17.17 → 5.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -38
- package/lib/commonjs/core/CrossDomainAuth.js +277 -0
- package/lib/commonjs/core/CrossDomainAuth.js.map +1 -0
- package/lib/commonjs/core/HttpService.js +82 -15
- package/lib/commonjs/core/HttpService.js.map +1 -1
- package/lib/commonjs/core/OxyServices.base.js +11 -3
- package/lib/commonjs/core/OxyServices.base.js.map +1 -1
- package/lib/commonjs/core/OxyServices.js +4 -1
- package/lib/commonjs/core/OxyServices.js.map +1 -1
- package/lib/commonjs/core/index.js +30 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.assets.js +16 -3
- package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.auth.js +73 -32
- package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.features.js +372 -0
- package/lib/commonjs/core/mixins/OxyServices.features.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.fedcm.js +289 -0
- package/lib/commonjs/core/mixins/OxyServices.fedcm.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.popup.js +352 -0
- package/lib/commonjs/core/mixins/OxyServices.popup.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.redirect.js +378 -0
- package/lib/commonjs/core/mixins/OxyServices.redirect.js.map +1 -0
- package/lib/commonjs/core/mixins/OxyServices.user.js +35 -24
- package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/commonjs/core/mixins/index.js +28 -15
- package/lib/commonjs/core/mixins/index.js.map +1 -1
- package/lib/commonjs/crypto/index.js +30 -0
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +902 -0
- package/lib/commonjs/crypto/keyManager.js.map +1 -0
- package/lib/commonjs/crypto/polyfill.js +14 -5
- package/lib/commonjs/crypto/polyfill.js.map +1 -1
- package/lib/commonjs/crypto/recoveryPhrase.js +152 -0
- package/lib/commonjs/crypto/recoveryPhrase.js.map +1 -0
- package/lib/commonjs/crypto/signatureService.js +289 -0
- package/lib/commonjs/crypto/signatureService.js.map +1 -0
- package/lib/commonjs/i18n/locales/en-US.json +1 -1
- package/lib/commonjs/index.js +40 -26
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/interfaces.js +0 -15
- package/lib/commonjs/models/interfaces.js.map +1 -1
- package/lib/commonjs/ui/components/BottomSheetRouter.js +9 -1
- package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +11 -1
- package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
- package/lib/commonjs/ui/components/Icon.js.map +1 -1
- package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +41 -11
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/SettingRow.js +17 -4
- package/lib/commonjs/ui/components/SettingRow.js.map +1 -1
- package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
- package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
- package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
- package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
- package/lib/commonjs/ui/components/feedback/FormInput.js +72 -0
- package/lib/commonjs/ui/components/feedback/FormInput.js.map +1 -0
- package/lib/commonjs/ui/components/feedback/ProgressIndicator.js +33 -0
- package/lib/commonjs/ui/components/feedback/ProgressIndicator.js.map +1 -0
- package/lib/commonjs/ui/components/feedback/constants.js +59 -0
- package/lib/commonjs/ui/components/feedback/constants.js.map +1 -0
- package/lib/commonjs/ui/components/feedback/feedbackStyles.js +262 -0
- package/lib/commonjs/ui/components/feedback/feedbackStyles.js.map +1 -0
- package/lib/commonjs/ui/components/feedback/index.js +54 -0
- package/lib/commonjs/ui/components/feedback/index.js.map +1 -0
- package/lib/commonjs/ui/components/feedback/types.js +6 -0
- package/lib/commonjs/ui/components/feedback/types.js.map +1 -0
- package/lib/commonjs/ui/components/feedback/useFeedbackForm.js +52 -0
- package/lib/commonjs/ui/components/feedback/useFeedbackForm.js.map +1 -0
- package/lib/commonjs/ui/components/modals/DeleteAccountModal.js +282 -0
- package/lib/commonjs/ui/components/modals/DeleteAccountModal.js.map +1 -0
- package/lib/commonjs/ui/components/modals/index.js +14 -0
- package/lib/commonjs/ui/components/modals/index.js.map +1 -0
- package/lib/commonjs/ui/components/payment/PaymentDetailsStep.js +309 -0
- package/lib/commonjs/ui/components/payment/PaymentDetailsStep.js.map +1 -0
- package/lib/commonjs/ui/components/payment/PaymentMethodStep.js +79 -0
- package/lib/commonjs/ui/components/payment/PaymentMethodStep.js.map +1 -0
- package/lib/commonjs/ui/components/payment/PaymentReviewStep.js +108 -0
- package/lib/commonjs/ui/components/payment/PaymentReviewStep.js.map +1 -0
- package/lib/commonjs/ui/components/payment/PaymentSuccessStep.js +79 -0
- package/lib/commonjs/ui/components/payment/PaymentSuccessStep.js.map +1 -0
- package/lib/commonjs/ui/components/payment/PaymentSummaryStep.js +176 -0
- package/lib/commonjs/ui/components/payment/PaymentSummaryStep.js.map +1 -0
- package/lib/commonjs/ui/components/payment/constants.js +53 -0
- package/lib/commonjs/ui/components/payment/constants.js.map +1 -0
- package/lib/commonjs/ui/components/payment/index.js +80 -0
- package/lib/commonjs/ui/components/payment/index.js.map +1 -0
- package/lib/commonjs/ui/components/payment/paymentStyles.js +409 -0
- package/lib/commonjs/ui/components/payment/paymentStyles.js.map +1 -0
- package/lib/commonjs/ui/components/payment/types.js +6 -0
- package/lib/commonjs/ui/components/payment/types.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +110 -199
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +150 -19
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useSessionManagement.js +279 -0
- package/lib/commonjs/ui/context/hooks/useSessionManagement.js.map +1 -0
- package/lib/commonjs/ui/hooks/index.js +26 -0
- package/lib/commonjs/ui/hooks/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +79 -72
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +38 -51
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js +3 -3
- package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +18 -12
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAsyncAction.js +95 -0
- package/lib/commonjs/ui/hooks/useAsyncAction.js.map +1 -0
- package/lib/commonjs/ui/hooks/useProfileEditing.js +3 -5
- package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionManagement.js +4 -8
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +162 -315
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSettingToggle.js +126 -0
- package/lib/commonjs/ui/hooks/useSettingToggle.js.map +1 -0
- package/lib/commonjs/ui/hooks/useStorage.js +24 -58
- package/lib/commonjs/ui/hooks/useStorage.js.map +1 -1
- package/lib/commonjs/ui/index.js +50 -21
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +6 -1
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +6 -4
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +33 -30
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +29 -24
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +3 -3
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FAQScreen.js +315 -0
- package/lib/commonjs/ui/screens/FAQScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/FeedbackScreen.js +73 -590
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HelpSupportScreen.js +8 -7
- package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +134 -66
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +67 -1395
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +6 -13
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +13 -5
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +16 -10
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +23 -11
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/accountStore.js +2 -4
- package/lib/commonjs/ui/stores/accountStore.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +45 -32
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/styles/spacing.js +54 -2
- package/lib/commonjs/ui/styles/spacing.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +37 -41
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/commonjs/ui/utils/storageHelpers.js.map +1 -1
- package/lib/commonjs/utils/errorUtils.js +13 -0
- package/lib/commonjs/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/utils/validationUtils.js +15 -1
- package/lib/commonjs/utils/validationUtils.js.map +1 -1
- package/lib/module/core/CrossDomainAuth.js +271 -0
- package/lib/module/core/CrossDomainAuth.js.map +1 -0
- package/lib/module/core/HttpService.js +82 -15
- package/lib/module/core/HttpService.js.map +1 -1
- package/lib/module/core/OxyServices.base.js +11 -4
- package/lib/module/core/OxyServices.base.js.map +1 -1
- package/lib/module/core/OxyServices.js +4 -1
- package/lib/module/core/OxyServices.js.map +1 -1
- package/lib/module/core/index.js +6 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.assets.js +16 -3
- package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.auth.js +73 -32
- package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.features.js +369 -0
- package/lib/module/core/mixins/OxyServices.features.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.fedcm.js +286 -0
- package/lib/module/core/mixins/OxyServices.fedcm.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.popup.js +349 -0
- package/lib/module/core/mixins/OxyServices.popup.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.redirect.js +375 -0
- package/lib/module/core/mixins/OxyServices.redirect.js.map +1 -0
- package/lib/module/core/mixins/OxyServices.user.js +35 -24
- package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/module/core/mixins/index.js +16 -3
- package/lib/module/core/mixins/index.js.map +1 -1
- package/lib/module/crypto/index.js +8 -4
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/crypto/keyManager.js +899 -0
- package/lib/module/crypto/keyManager.js.map +1 -0
- package/lib/module/crypto/polyfill.js +6 -5
- package/lib/module/crypto/polyfill.js.map +1 -1
- package/lib/module/crypto/recoveryPhrase.js +147 -0
- package/lib/module/crypto/recoveryPhrase.js.map +1 -0
- package/lib/module/crypto/signatureService.js +286 -0
- package/lib/module/crypto/signatureService.js.map +1 -0
- package/lib/module/i18n/locales/en-US.json +1 -1
- package/lib/module/index.js +6 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/interfaces.js +0 -15
- package/lib/module/models/interfaces.js.map +1 -1
- package/lib/module/ui/components/BottomSheetRouter.js +6 -2
- package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +11 -1
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/Icon.js.map +1 -1
- package/lib/module/ui/components/IconButton/utils.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +41 -11
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/SettingRow.js +17 -4
- package/lib/module/ui/components/SettingRow.js.map +1 -1
- package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
- package/lib/module/ui/components/TextField/helpers.js.map +1 -1
- package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
- package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
- package/lib/module/ui/components/feedback/FormInput.js +67 -0
- package/lib/module/ui/components/feedback/FormInput.js.map +1 -0
- package/lib/module/ui/components/feedback/ProgressIndicator.js +28 -0
- package/lib/module/ui/components/feedback/ProgressIndicator.js.map +1 -0
- package/lib/module/ui/components/feedback/constants.js +55 -0
- package/lib/module/ui/components/feedback/constants.js.map +1 -0
- package/lib/module/ui/components/feedback/feedbackStyles.js +257 -0
- package/lib/module/ui/components/feedback/feedbackStyles.js.map +1 -0
- package/lib/module/ui/components/feedback/index.js +8 -0
- package/lib/module/ui/components/feedback/index.js.map +1 -0
- package/lib/module/ui/components/feedback/types.js +4 -0
- package/lib/module/ui/components/feedback/types.js.map +1 -0
- package/lib/module/ui/components/feedback/useFeedbackForm.js +47 -0
- package/lib/module/ui/components/feedback/useFeedbackForm.js.map +1 -0
- package/lib/module/ui/components/modals/DeleteAccountModal.js +276 -0
- package/lib/module/ui/components/modals/DeleteAccountModal.js.map +1 -0
- package/lib/module/ui/components/modals/index.js +4 -0
- package/lib/module/ui/components/modals/index.js.map +1 -0
- package/lib/module/ui/components/payment/PaymentDetailsStep.js +303 -0
- package/lib/module/ui/components/payment/PaymentDetailsStep.js.map +1 -0
- package/lib/module/ui/components/payment/PaymentMethodStep.js +73 -0
- package/lib/module/ui/components/payment/PaymentMethodStep.js.map +1 -0
- package/lib/module/ui/components/payment/PaymentReviewStep.js +102 -0
- package/lib/module/ui/components/payment/PaymentReviewStep.js.map +1 -0
- package/lib/module/ui/components/payment/PaymentSuccessStep.js +73 -0
- package/lib/module/ui/components/payment/PaymentSuccessStep.js.map +1 -0
- package/lib/module/ui/components/payment/PaymentSummaryStep.js +170 -0
- package/lib/module/ui/components/payment/PaymentSummaryStep.js.map +1 -0
- package/lib/module/ui/components/payment/constants.js +47 -0
- package/lib/module/ui/components/payment/constants.js.map +1 -0
- package/lib/module/ui/components/payment/index.js +10 -0
- package/lib/module/ui/components/payment/index.js.map +1 -0
- package/lib/module/ui/components/payment/paymentStyles.js +404 -0
- package/lib/module/ui/components/payment/paymentStyles.js.map +1 -0
- package/lib/module/ui/components/payment/types.js +4 -0
- package/lib/module/ui/components/payment/types.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +112 -191
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +150 -19
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/context/hooks/useSessionManagement.js +274 -0
- package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -0
- package/lib/module/ui/hooks/index.js +2 -0
- package/lib/module/ui/hooks/index.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +80 -72
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +31 -44
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useSecurityQueries.js +1 -1
- package/lib/module/ui/hooks/queries/useSecurityQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +13 -7
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useAsyncAction.js +89 -0
- package/lib/module/ui/hooks/useAsyncAction.js.map +1 -0
- package/lib/module/ui/hooks/useProfileEditing.js +3 -5
- package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/module/ui/hooks/useSessionManagement.js +4 -8
- package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +162 -315
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/hooks/useSettingToggle.js +120 -0
- package/lib/module/ui/hooks/useSettingToggle.js.map +1 -0
- package/lib/module/ui/hooks/useStorage.js +25 -59
- package/lib/module/ui/hooks/useStorage.js.map +1 -1
- package/lib/module/ui/index.js +15 -10
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +6 -1
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +6 -4
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +33 -30
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +29 -24
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +3 -3
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/FAQScreen.js +310 -0
- package/lib/module/ui/screens/FAQScreen.js.map +1 -0
- package/lib/module/ui/screens/FeedbackScreen.js +64 -581
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/HelpSupportScreen.js +8 -7
- package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +135 -68
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +67 -1397
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/module/ui/screens/PrivacySettingsScreen.js +6 -13
- package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +13 -5
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SavesCollectionsScreen.js +16 -10
- package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +23 -11
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/stores/accountStore.js +2 -4
- package/lib/module/ui/stores/accountStore.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +45 -32
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/styles/spacing.js +6 -2
- package/lib/module/ui/styles/spacing.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +37 -40
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/ui/utils/storageHelpers.js.map +1 -1
- package/lib/module/utils/errorUtils.js +7 -0
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/utils/validationUtils.js +13 -0
- package/lib/module/utils/validationUtils.js.map +1 -1
- package/lib/typescript/core/CrossDomainAuth.d.ts +161 -0
- package/lib/typescript/core/CrossDomainAuth.d.ts.map +1 -0
- package/lib/typescript/core/HttpService.d.ts +1 -1
- package/lib/typescript/core/HttpService.d.ts.map +1 -1
- package/lib/typescript/core/OxyServices.base.d.ts +0 -6
- package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
- package/lib/typescript/core/OxyServices.d.ts +5 -36
- package/lib/typescript/core/OxyServices.d.ts.map +1 -1
- package/lib/typescript/core/index.d.ts +4 -0
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts +40 -20
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.features.d.ts +229 -0
- package/lib/typescript/core/mixins/OxyServices.features.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts +195 -0
- package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.popup.d.ts +206 -0
- package/lib/typescript/core/mixins/OxyServices.popup.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.redirect.d.ts +246 -0
- package/lib/typescript/core/mixins/OxyServices.redirect.d.ts.map +1 -0
- package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.user.d.ts +6 -4
- package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +291 -9
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/crypto/index.d.ts +6 -3
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts +190 -0
- package/lib/typescript/crypto/keyManager.d.ts.map +1 -0
- package/lib/typescript/crypto/polyfill.d.ts +4 -3
- package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
- package/lib/typescript/crypto/recoveryPhrase.d.ts +59 -0
- package/lib/typescript/crypto/recoveryPhrase.d.ts.map +1 -0
- package/lib/typescript/crypto/signatureService.d.ts +87 -0
- package/lib/typescript/crypto/signatureService.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -6
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +2 -14
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/models/session.d.ts +0 -9
- package/lib/typescript/models/session.d.ts.map +1 -1
- package/lib/typescript/types/bip39.d.ts +32 -0
- package/lib/typescript/ui/components/BottomSheetRouter.d.ts +5 -0
- package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
- package/lib/typescript/ui/components/GroupedItem.d.ts +5 -1
- package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/components/SettingRow.d.ts +6 -0
- package/lib/typescript/ui/components/SettingRow.d.ts.map +1 -1
- package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
- package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
- package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
- package/lib/typescript/ui/components/TextField/helpers.d.ts +8 -8
- package/lib/typescript/ui/components/TextField/types.d.ts +1 -0
- package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
- package/lib/typescript/ui/components/feedback/FormInput.d.ts +20 -0
- package/lib/typescript/ui/components/feedback/FormInput.d.ts.map +1 -0
- package/lib/typescript/ui/components/feedback/ProgressIndicator.d.ts +11 -0
- package/lib/typescript/ui/components/feedback/ProgressIndicator.d.ts.map +1 -0
- package/lib/typescript/ui/components/feedback/constants.d.ts +5 -0
- package/lib/typescript/ui/components/feedback/constants.d.ts.map +1 -0
- package/lib/typescript/ui/components/feedback/feedbackStyles.d.ts +280 -0
- package/lib/typescript/ui/components/feedback/feedbackStyles.d.ts.map +1 -0
- package/lib/typescript/ui/components/feedback/index.d.ts +7 -0
- package/lib/typescript/ui/components/feedback/index.d.ts.map +1 -0
- package/lib/typescript/ui/components/feedback/types.d.ts +46 -0
- package/lib/typescript/ui/components/feedback/types.d.ts.map +1 -0
- package/lib/typescript/ui/components/feedback/useFeedbackForm.d.ts +9 -0
- package/lib/typescript/ui/components/feedback/useFeedbackForm.d.ts.map +1 -0
- package/lib/typescript/ui/components/modals/DeleteAccountModal.d.ts +19 -0
- package/lib/typescript/ui/components/modals/DeleteAccountModal.d.ts.map +1 -0
- package/lib/typescript/ui/components/modals/index.d.ts +2 -0
- package/lib/typescript/ui/components/modals/index.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/PaymentDetailsStep.d.ts +21 -0
- package/lib/typescript/ui/components/payment/PaymentDetailsStep.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/PaymentMethodStep.d.ts +14 -0
- package/lib/typescript/ui/components/payment/PaymentMethodStep.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/PaymentReviewStep.d.ts +16 -0
- package/lib/typescript/ui/components/payment/PaymentReviewStep.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/PaymentSuccessStep.d.ts +10 -0
- package/lib/typescript/ui/components/payment/PaymentSuccessStep.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/PaymentSummaryStep.d.ts +15 -0
- package/lib/typescript/ui/components/payment/PaymentSummaryStep.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/constants.d.ts +7 -0
- package/lib/typescript/ui/components/payment/constants.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/index.d.ts +9 -0
- package/lib/typescript/ui/components/payment/index.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/paymentStyles.d.ts +396 -0
- package/lib/typescript/ui/components/payment/paymentStyles.d.ts.map +1 -0
- package/lib/typescript/ui/components/payment/types.d.ts +40 -0
- package/lib/typescript/ui/components/payment/types.d.ts.map +1 -0
- package/lib/typescript/ui/components/types.d.ts +4 -0
- package/lib/typescript/ui/components/types.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +57 -3
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -3
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +41 -0
- package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/index.d.ts +2 -0
- package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useAsyncAction.d.ts +51 -0
- package/lib/typescript/ui/hooks/useAsyncAction.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -2
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSettingToggle.d.ts +55 -0
- package/lib/typescript/ui/hooks/useSettingToggle.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useStorage.d.ts +3 -9
- package/lib/typescript/ui/hooks/useStorage.d.ts.map +1 -1
- package/lib/typescript/ui/index.d.ts +6 -2
- package/lib/typescript/ui/index.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/FAQScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/FAQScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/FeedbackScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/HelpSupportScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/OxyAuthScreen.d.ts +1 -1
- package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts +3 -15
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/stores/accountStore.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +8 -7
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/styles/spacing.d.ts +5 -0
- package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
- package/lib/typescript/ui/types/navigation.d.ts +2 -1
- package/lib/typescript/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts +2 -13
- package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/ui/utils/storageHelpers.d.ts +0 -3
- package/lib/typescript/ui/utils/storageHelpers.d.ts.map +1 -1
- package/lib/typescript/utils/errorUtils.d.ts +6 -0
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/utils/validationUtils.d.ts +8 -0
- package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/core/CrossDomainAuth.ts +307 -0
- package/src/core/HttpService.ts +99 -16
- package/src/core/OxyServices.base.ts +20 -3
- package/src/core/OxyServices.ts +7 -3
- package/src/core/index.ts +9 -1
- package/src/core/mixins/OxyServices.assets.ts +14 -3
- package/src/core/mixins/OxyServices.auth.ts +105 -36
- package/src/core/mixins/OxyServices.features.ts +428 -0
- package/src/core/mixins/OxyServices.fedcm.ts +315 -0
- package/src/core/mixins/OxyServices.popup.ts +402 -0
- package/src/core/mixins/OxyServices.redirect.ts +397 -0
- package/src/core/mixins/OxyServices.user.ts +39 -24
- package/src/core/mixins/index.ts +33 -14
- package/src/crypto/index.ts +16 -5
- package/src/crypto/keyManager.ts +966 -0
- package/src/crypto/polyfill.ts +6 -5
- package/src/crypto/recoveryPhrase.ts +166 -0
- package/src/crypto/signatureService.ts +323 -0
- package/src/i18n/locales/en-US.json +1 -1
- package/src/index.ts +19 -15
- package/src/models/interfaces.ts +4 -16
- package/src/models/session.ts +2 -11
- package/src/types/bip39.d.ts +32 -0
- package/src/ui/components/BottomSheetRouter.tsx +6 -1
- package/src/ui/components/GroupedItem.tsx +19 -1
- package/src/ui/components/Icon.tsx +1 -1
- package/src/ui/components/IconButton/utils.ts +1 -1
- package/src/ui/components/OxyProvider.tsx +44 -12
- package/src/ui/components/SettingRow.tsx +26 -4
- package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
- package/src/ui/components/TextField/Adornment/utils.ts +2 -2
- package/src/ui/components/TextField/helpers.tsx +10 -10
- package/src/ui/components/TextField/types.tsx +1 -1
- package/src/ui/components/TouchableRipple/utils.ts +2 -2
- package/src/ui/components/Typography/AnimatedText.tsx +2 -2
- package/src/ui/components/feedback/FormInput.tsx +84 -0
- package/src/ui/components/feedback/ProgressIndicator.tsx +35 -0
- package/src/ui/components/feedback/constants.ts +22 -0
- package/src/ui/components/feedback/feedbackStyles.ts +247 -0
- package/src/ui/components/feedback/index.ts +6 -0
- package/src/ui/components/feedback/types.ts +52 -0
- package/src/ui/components/feedback/useFeedbackForm.ts +44 -0
- package/src/ui/components/modals/DeleteAccountModal.tsx +294 -0
- package/src/ui/components/modals/index.ts +1 -0
- package/src/ui/components/payment/PaymentDetailsStep.tsx +222 -0
- package/src/ui/components/payment/PaymentMethodStep.tsx +89 -0
- package/src/ui/components/payment/PaymentReviewStep.tsx +126 -0
- package/src/ui/components/payment/PaymentSuccessStep.tsx +71 -0
- package/src/ui/components/payment/PaymentSummaryStep.tsx +159 -0
- package/src/ui/components/payment/constants.ts +39 -0
- package/src/ui/components/payment/index.ts +9 -0
- package/src/ui/components/payment/paymentStyles.ts +397 -0
- package/src/ui/components/payment/types.ts +45 -0
- package/src/ui/components/types.tsx +6 -0
- package/src/ui/context/OxyContext.tsx +173 -195
- package/src/ui/context/hooks/useAuthOperations.ts +177 -36
- package/src/ui/context/hooks/useSessionManagement.ts +399 -0
- package/src/ui/hooks/index.ts +3 -1
- package/src/ui/hooks/mutations/useAccountMutations.ts +83 -76
- package/src/ui/hooks/queries/useAccountQueries.ts +29 -35
- package/src/ui/hooks/queries/useSecurityQueries.ts +1 -1
- package/src/ui/hooks/queries/useServicesQueries.ts +14 -6
- package/src/ui/hooks/useAsyncAction.ts +129 -0
- package/src/ui/hooks/useProfileEditing.ts +3 -3
- package/src/ui/hooks/useSessionManagement.ts +5 -10
- package/src/ui/hooks/useSessionSocket.ts +46 -175
- package/src/ui/hooks/useSettingToggle.ts +147 -0
- package/src/ui/hooks/useStorage.ts +24 -76
- package/src/ui/index.ts +22 -13
- package/src/ui/navigation/routes.ts +8 -2
- package/src/ui/screens/AccountCenterScreen.tsx +4 -4
- package/src/ui/screens/AccountOverviewScreen.tsx +36 -38
- package/src/ui/screens/AccountSettingsScreen.tsx +34 -37
- package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
- package/src/ui/screens/FAQScreen.tsx +332 -0
- package/src/ui/screens/FeedbackScreen.tsx +91 -626
- package/src/ui/screens/HelpSupportScreen.tsx +7 -5
- package/src/ui/screens/OxyAuthScreen.tsx +138 -64
- package/src/ui/screens/PaymentGatewayScreen.tsx +96 -1275
- package/src/ui/screens/PrivacySettingsScreen.tsx +6 -12
- package/src/ui/screens/ProfileScreen.tsx +11 -6
- package/src/ui/screens/SavesCollectionsScreen.tsx +19 -10
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +10 -10
- package/src/ui/stores/accountStore.ts +1 -11
- package/src/ui/stores/authStore.ts +43 -44
- package/src/ui/styles/spacing.ts +15 -2
- package/src/ui/types/navigation.ts +2 -2
- package/src/ui/utils/avatarUtils.ts +39 -46
- package/src/ui/utils/storageHelpers.ts +0 -4
- package/src/utils/__tests__/validationUtils.test.ts +16 -1
- package/src/utils/errorUtils.ts +8 -1
- package/src/utils/validationUtils.ts +12 -0
- package/lib/commonjs/core/services/SessionService.js +0 -163
- package/lib/commonjs/core/services/SessionService.js.map +0 -1
- package/lib/commonjs/core/services/TokenService.js +0 -220
- package/lib/commonjs/core/services/TokenService.js.map +0 -1
- package/lib/commonjs/crypto/types.js +0 -2
- package/lib/commonjs/crypto/types.js.map +0 -1
- package/lib/commonjs/ui/context/OxyContextBase.js +0 -21
- package/lib/commonjs/ui/context/OxyContextBase.js.map +0 -1
- package/lib/commonjs/ui/context/hooks/useStorage.js +0 -79
- package/lib/commonjs/ui/context/hooks/useStorage.js.map +0 -1
- package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -56
- package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
- package/lib/module/core/services/SessionService.js +0 -159
- package/lib/module/core/services/SessionService.js.map +0 -1
- package/lib/module/core/services/TokenService.js +0 -217
- package/lib/module/core/services/TokenService.js.map +0 -1
- package/lib/module/crypto/types.js +0 -2
- package/lib/module/crypto/types.js.map +0 -1
- package/lib/module/ui/context/OxyContextBase.js +0 -16
- package/lib/module/ui/context/OxyContextBase.js.map +0 -1
- package/lib/module/ui/context/hooks/useStorage.js +0 -74
- package/lib/module/ui/context/hooks/useStorage.js.map +0 -1
- package/lib/module/ui/hooks/useAvatarPicker.js +0 -50
- package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
- package/lib/typescript/core/services/SessionService.d.ts +0 -78
- package/lib/typescript/core/services/SessionService.d.ts.map +0 -1
- package/lib/typescript/core/services/TokenService.d.ts +0 -72
- package/lib/typescript/core/services/TokenService.d.ts.map +0 -1
- package/lib/typescript/crypto/types.d.ts +0 -22
- package/lib/typescript/crypto/types.d.ts.map +0 -1
- package/lib/typescript/ui/context/OxyContextBase.d.ts +0 -63
- package/lib/typescript/ui/context/OxyContextBase.d.ts.map +0 -1
- package/lib/typescript/ui/context/hooks/useStorage.d.ts +0 -22
- package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -19
- package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
- package/src/core/services/SessionService.ts +0 -173
- package/src/core/services/TokenService.ts +0 -237
- package/src/crypto/types.ts +0 -23
- package/src/ui/context/OxyContextBase.tsx +0 -78
- package/src/ui/context/hooks/useStorage.ts +0 -104
- package/src/ui/hooks/useAvatarPicker.ts +0 -61
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import type { User } from '../../../models/interfaces';
|
|
3
|
-
import type { ClientSession } from '../../../models/session';
|
|
4
3
|
import { queryKeys, invalidateAccountQueries, invalidateUserQueries } from '../queries/queryKeys';
|
|
5
4
|
import { useOxy } from '../../context/OxyContext';
|
|
6
5
|
import { toast } from '../../../lib/sonner';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const getDeviceIdForSession = (sessions: ClientSession[] = [], sessionId: string | null) =>
|
|
11
|
-
sessionId ? sessions.find((s) => s.sessionId === sessionId)?.deviceId : undefined;
|
|
6
|
+
import { refreshAvatarInStore } from '../../utils/avatarUtils';
|
|
7
|
+
import { useAuthStore } from '../../stores/authStore';
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* Update user profile with optimistic updates and offline queue support
|
|
15
11
|
*/
|
|
16
12
|
export const useUpdateProfile = () => {
|
|
17
|
-
const { oxyServices, activeSessionId, user
|
|
13
|
+
const { oxyServices, activeSessionId, user } = useOxy();
|
|
18
14
|
const queryClient = useQueryClient();
|
|
19
15
|
|
|
20
16
|
return useMutation({
|
|
@@ -23,9 +19,16 @@ export const useUpdateProfile = () => {
|
|
|
23
19
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
24
20
|
try {
|
|
25
21
|
// Try to get token for the session
|
|
26
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
22
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
27
23
|
} catch (tokenError) {
|
|
28
|
-
|
|
24
|
+
// If getting token fails, might be an offline session - try syncing
|
|
25
|
+
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
26
|
+
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
27
|
+
// Session sync should be handled by the app layer
|
|
28
|
+
throw new Error('Session needs to be synced. Please try again.');
|
|
29
|
+
} else {
|
|
30
|
+
throw tokenError;
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -37,7 +40,8 @@ export const useUpdateProfile = () => {
|
|
|
37
40
|
|
|
38
41
|
// Handle authentication errors
|
|
39
42
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
40
|
-
|
|
43
|
+
// Session sync should be handled by the app layer
|
|
44
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
// TanStack Query will automatically retry on network errors
|
|
@@ -80,39 +84,25 @@ export const useUpdateProfile = () => {
|
|
|
80
84
|
}
|
|
81
85
|
toast.error(error instanceof Error ? error.message : 'Failed to update profile');
|
|
82
86
|
},
|
|
83
|
-
// On success,
|
|
84
|
-
onSuccess:
|
|
85
|
-
logger.debug('Profile update successful', {
|
|
86
|
-
component: 'useUpdateProfile',
|
|
87
|
-
username: data.username,
|
|
88
|
-
updatedFields: Object.keys(updates)
|
|
89
|
-
});
|
|
90
|
-
|
|
87
|
+
// On success, invalidate and refetch
|
|
88
|
+
onSuccess: (data, updates) => {
|
|
91
89
|
// Update cache with server response
|
|
92
90
|
queryClient.setQueryData(queryKeys.accounts.current(), data);
|
|
93
91
|
if (activeSessionId) {
|
|
94
92
|
queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
|
|
95
93
|
}
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
|
|
95
|
+
// Update authStore so frontend components see the changes immediately
|
|
96
|
+
useAuthStore.getState().setUser(data);
|
|
97
|
+
|
|
98
|
+
// If avatar was updated, refresh accountStore with cache-busted URL
|
|
99
|
+
if (updates.avatar && activeSessionId && oxyServices) {
|
|
100
|
+
refreshAvatarInStore(activeSessionId, updates.avatar, oxyServices);
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
queryClient.refetchQueries({
|
|
106
|
-
queryKey: queryKeys.accounts.all,
|
|
107
|
-
type: 'active'
|
|
108
|
-
}),
|
|
109
|
-
queryClient.refetchQueries({
|
|
110
|
-
queryKey: queryKeys.users.all,
|
|
111
|
-
type: 'active'
|
|
112
|
-
})
|
|
113
|
-
]);
|
|
114
|
-
|
|
115
|
-
logger.debug('Profile update complete', { component: 'useUpdateProfile' });
|
|
102
|
+
|
|
103
|
+
// Invalidate all related queries to refresh everywhere
|
|
104
|
+
invalidateUserQueries(queryClient);
|
|
105
|
+
invalidateAccountQueries(queryClient);
|
|
116
106
|
},
|
|
117
107
|
});
|
|
118
108
|
};
|
|
@@ -121,7 +111,7 @@ export const useUpdateProfile = () => {
|
|
|
121
111
|
* Upload avatar with progress tracking and offline queue support
|
|
122
112
|
*/
|
|
123
113
|
export const useUploadAvatar = () => {
|
|
124
|
-
const { oxyServices, activeSessionId
|
|
114
|
+
const { oxyServices, activeSessionId } = useOxy();
|
|
125
115
|
const queryClient = useQueryClient();
|
|
126
116
|
|
|
127
117
|
return useMutation({
|
|
@@ -129,9 +119,15 @@ export const useUploadAvatar = () => {
|
|
|
129
119
|
// Ensure we have a valid token before making the request
|
|
130
120
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
131
121
|
try {
|
|
132
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
122
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
133
123
|
} catch (tokenError) {
|
|
134
|
-
|
|
124
|
+
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
125
|
+
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
126
|
+
// Session sync should be handled by the app layer
|
|
127
|
+
throw new Error('Session needs to be synced. Please try again.');
|
|
128
|
+
} else {
|
|
129
|
+
throw tokenError;
|
|
130
|
+
}
|
|
135
131
|
}
|
|
136
132
|
}
|
|
137
133
|
|
|
@@ -152,7 +148,8 @@ export const useUploadAvatar = () => {
|
|
|
152
148
|
|
|
153
149
|
// Handle authentication errors
|
|
154
150
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
155
|
-
|
|
151
|
+
// Session sync should be handled by the app layer
|
|
152
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
// TanStack Query will automatically retry on network errors
|
|
@@ -186,35 +183,24 @@ export const useUploadAvatar = () => {
|
|
|
186
183
|
}
|
|
187
184
|
toast.error(error instanceof Error ? error.message : 'Failed to upload avatar');
|
|
188
185
|
},
|
|
189
|
-
onSuccess:
|
|
190
|
-
logger.debug(
|
|
191
|
-
'Avatar upload successful',
|
|
192
|
-
{ component: 'useUploadAvatar', method: 'onSuccess', data }
|
|
193
|
-
);
|
|
194
|
-
|
|
186
|
+
onSuccess: (data) => {
|
|
195
187
|
queryClient.setQueryData(queryKeys.accounts.current(), data);
|
|
196
188
|
if (activeSessionId) {
|
|
197
189
|
queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
|
|
198
190
|
}
|
|
199
191
|
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
|
|
192
|
+
// Update authStore so frontend components see the changes immediately
|
|
193
|
+
useAuthStore.getState().setUser(data);
|
|
194
|
+
|
|
195
|
+
// Refresh accountStore with cache-busted URL if avatar was updated
|
|
196
|
+
if (data?.avatar && activeSessionId && oxyServices) {
|
|
197
|
+
refreshAvatarInStore(activeSessionId, data.avatar, oxyServices);
|
|
203
198
|
}
|
|
204
199
|
|
|
205
200
|
// Invalidate all related queries to refresh everywhere
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// Explicitly refetch to ensure UI updates
|
|
210
|
-
await queryClient.refetchQueries({ queryKey: queryKeys.accounts.current() });
|
|
211
|
-
|
|
201
|
+
invalidateUserQueries(queryClient);
|
|
202
|
+
invalidateAccountQueries(queryClient);
|
|
212
203
|
toast.success('Avatar updated successfully');
|
|
213
|
-
|
|
214
|
-
logger.debug(
|
|
215
|
-
'Avatar update complete - cache invalidated and refetched',
|
|
216
|
-
{ component: 'useUploadAvatar', method: 'onSuccess' }
|
|
217
|
-
);
|
|
218
204
|
},
|
|
219
205
|
});
|
|
220
206
|
};
|
|
@@ -255,6 +241,9 @@ export const useUpdateAccountSettings = () => {
|
|
|
255
241
|
onSuccess: (data) => {
|
|
256
242
|
queryClient.setQueryData(queryKeys.accounts.current(), data);
|
|
257
243
|
|
|
244
|
+
// Update authStore so frontend components see the changes immediately
|
|
245
|
+
useAuthStore.getState().setUser(data);
|
|
246
|
+
|
|
258
247
|
invalidateAccountQueries(queryClient);
|
|
259
248
|
toast.success('Settings updated successfully');
|
|
260
249
|
},
|
|
@@ -268,14 +257,12 @@ export const useUpdateAccountSettings = () => {
|
|
|
268
257
|
* Update privacy settings with optimistic updates and authentication handling
|
|
269
258
|
*/
|
|
270
259
|
export const useUpdatePrivacySettings = () => {
|
|
271
|
-
const { oxyServices, activeSessionId,
|
|
260
|
+
const { oxyServices, activeSessionId, user } = useOxy();
|
|
272
261
|
const queryClient = useQueryClient();
|
|
273
262
|
|
|
274
263
|
return useMutation({
|
|
275
264
|
mutationFn: async ({ settings, userId }: { settings: Record<string, any>; userId?: string }) => {
|
|
276
|
-
|
|
277
|
-
// Never use user?.id as it may be set to publicKey
|
|
278
|
-
const targetUserId = userId || oxyServices.getCurrentUserId();
|
|
265
|
+
const targetUserId = userId || user?.id;
|
|
279
266
|
if (!targetUserId) {
|
|
280
267
|
throw new Error('User ID is required');
|
|
281
268
|
}
|
|
@@ -284,9 +271,16 @@ export const useUpdatePrivacySettings = () => {
|
|
|
284
271
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
285
272
|
try {
|
|
286
273
|
// Try to get token for the session
|
|
287
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
274
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
288
275
|
} catch (tokenError) {
|
|
289
|
-
|
|
276
|
+
// If getting token fails, might be an offline session - try syncing
|
|
277
|
+
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
278
|
+
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
279
|
+
// Session sync should be handled by the app layer
|
|
280
|
+
throw new Error('Session needs to be synced. Please try again.');
|
|
281
|
+
} else {
|
|
282
|
+
throw tokenError;
|
|
283
|
+
}
|
|
290
284
|
}
|
|
291
285
|
}
|
|
292
286
|
|
|
@@ -298,7 +292,8 @@ export const useUpdatePrivacySettings = () => {
|
|
|
298
292
|
|
|
299
293
|
// Handle authentication errors
|
|
300
294
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
301
|
-
|
|
295
|
+
// Session sync should be handled by the app layer
|
|
296
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
302
297
|
}
|
|
303
298
|
|
|
304
299
|
// TanStack Query will automatically retry on network errors
|
|
@@ -307,7 +302,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
307
302
|
},
|
|
308
303
|
// Optimistic update
|
|
309
304
|
onMutate: async ({ settings, userId }) => {
|
|
310
|
-
const targetUserId = userId ||
|
|
305
|
+
const targetUserId = userId || user?.id;
|
|
311
306
|
if (!targetUserId) return;
|
|
312
307
|
|
|
313
308
|
// Cancel outgoing refetches
|
|
@@ -341,7 +336,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
341
336
|
},
|
|
342
337
|
// On error, rollback
|
|
343
338
|
onError: (error, { userId }, context) => {
|
|
344
|
-
const targetUserId = userId ||
|
|
339
|
+
const targetUserId = userId || user?.id;
|
|
345
340
|
if (context?.previousPrivacySettings && targetUserId) {
|
|
346
341
|
queryClient.setQueryData(queryKeys.privacy.settings(targetUserId), context.previousPrivacySettings);
|
|
347
342
|
}
|
|
@@ -352,7 +347,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
352
347
|
},
|
|
353
348
|
// On success, invalidate and refetch
|
|
354
349
|
onSuccess: (data, { userId }) => {
|
|
355
|
-
const targetUserId = userId ||
|
|
350
|
+
const targetUserId = userId || user?.id;
|
|
356
351
|
if (targetUserId) {
|
|
357
352
|
queryClient.setQueryData(queryKeys.privacy.settings(targetUserId), data);
|
|
358
353
|
}
|
|
@@ -364,12 +359,15 @@ export const useUpdatePrivacySettings = () => {
|
|
|
364
359
|
privacySettings: data,
|
|
365
360
|
};
|
|
366
361
|
queryClient.setQueryData<User>(queryKeys.accounts.current(), updatedUser);
|
|
362
|
+
|
|
363
|
+
// Update authStore so frontend components see the changes immediately
|
|
364
|
+
useAuthStore.getState().setUser(updatedUser);
|
|
367
365
|
}
|
|
368
366
|
invalidateAccountQueries(queryClient);
|
|
369
367
|
},
|
|
370
368
|
// Always refetch after error or success
|
|
371
369
|
onSettled: (data, error, { userId }) => {
|
|
372
|
-
const targetUserId = userId ||
|
|
370
|
+
const targetUserId = userId || user?.id;
|
|
373
371
|
if (targetUserId) {
|
|
374
372
|
queryClient.invalidateQueries({ queryKey: queryKeys.privacy.settings(targetUserId) });
|
|
375
373
|
}
|
|
@@ -382,7 +380,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
382
380
|
* Upload file with authentication handling and progress tracking
|
|
383
381
|
*/
|
|
384
382
|
export const useUploadFile = () => {
|
|
385
|
-
const { oxyServices, activeSessionId
|
|
383
|
+
const { oxyServices, activeSessionId } = useOxy();
|
|
386
384
|
|
|
387
385
|
return useMutation({
|
|
388
386
|
mutationFn: async ({
|
|
@@ -400,9 +398,16 @@ export const useUploadFile = () => {
|
|
|
400
398
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
401
399
|
try {
|
|
402
400
|
// Try to get token for the session
|
|
403
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
401
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
404
402
|
} catch (tokenError) {
|
|
405
|
-
|
|
403
|
+
// If getting token fails, might be an offline session - try syncing
|
|
404
|
+
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
405
|
+
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
406
|
+
// Session sync should be handled by the app layer
|
|
407
|
+
throw new Error('Session needs to be synced. Please try again.');
|
|
408
|
+
} else {
|
|
409
|
+
throw tokenError;
|
|
410
|
+
}
|
|
406
411
|
}
|
|
407
412
|
}
|
|
408
413
|
|
|
@@ -414,7 +419,8 @@ export const useUploadFile = () => {
|
|
|
414
419
|
|
|
415
420
|
// Handle authentication errors
|
|
416
421
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
417
|
-
|
|
422
|
+
// Session sync should be handled by the app layer
|
|
423
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
418
424
|
}
|
|
419
425
|
|
|
420
426
|
// TanStack Query will automatically retry on network errors
|
|
@@ -423,3 +429,4 @@ export const useUploadFile = () => {
|
|
|
423
429
|
},
|
|
424
430
|
});
|
|
425
431
|
};
|
|
432
|
+
|
|
@@ -2,8 +2,7 @@ import { useQuery, useQueries } from '@tanstack/react-query';
|
|
|
2
2
|
import type { User } from '../../../models/interfaces';
|
|
3
3
|
import type { OxyServices } from '../../../core';
|
|
4
4
|
import { queryKeys } from './queryKeys';
|
|
5
|
-
import { useOxy } from '../../context/
|
|
6
|
-
import { logger } from '../../../utils/loggerUtils';
|
|
5
|
+
import { useOxy } from '../../context/OxyContext';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Get user profile by session ID
|
|
@@ -20,8 +19,8 @@ export const useUserProfile = (sessionId: string | null, options?: { enabled?: b
|
|
|
20
19
|
return await oxyServices.getUserBySession(sessionId);
|
|
21
20
|
},
|
|
22
21
|
enabled: (options?.enabled !== false) && !!sessionId,
|
|
23
|
-
staleTime:
|
|
24
|
-
gcTime:
|
|
22
|
+
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
23
|
+
gcTime: 30 * 60 * 1000, // 30 minutes
|
|
25
24
|
});
|
|
26
25
|
};
|
|
27
26
|
|
|
@@ -39,8 +38,8 @@ export const useUserProfiles = (sessionIds: string[], options?: { enabled?: bool
|
|
|
39
38
|
return results[0]?.user || null;
|
|
40
39
|
},
|
|
41
40
|
enabled: (options?.enabled !== false) && !!sessionId,
|
|
42
|
-
staleTime:
|
|
43
|
-
gcTime:
|
|
41
|
+
staleTime: 5 * 60 * 1000,
|
|
42
|
+
gcTime: 30 * 60 * 1000,
|
|
44
43
|
})),
|
|
45
44
|
});
|
|
46
45
|
};
|
|
@@ -54,25 +53,14 @@ export const useCurrentUser = (options?: { enabled?: boolean }) => {
|
|
|
54
53
|
return useQuery({
|
|
55
54
|
queryKey: queryKeys.accounts.current(),
|
|
56
55
|
queryFn: async () => {
|
|
57
|
-
logger.debug('Fetching current user', {
|
|
58
|
-
component: 'useCurrentUser',
|
|
59
|
-
sessionId: activeSessionId ?? undefined
|
|
60
|
-
});
|
|
61
56
|
if (!activeSessionId) {
|
|
62
57
|
throw new Error('No active session');
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
logger.debug('Current user fetched', {
|
|
66
|
-
component: 'useCurrentUser',
|
|
67
|
-
username: userData.username
|
|
68
|
-
});
|
|
69
|
-
return userData;
|
|
59
|
+
return await oxyServices.getUserBySession(activeSessionId);
|
|
70
60
|
},
|
|
71
61
|
enabled: (options?.enabled !== false) && isAuthenticated && !!activeSessionId,
|
|
72
|
-
staleTime:
|
|
73
|
-
gcTime:
|
|
74
|
-
refetchOnMount: 'always', // Always refetch on mount
|
|
75
|
-
refetchOnWindowFocus: false,
|
|
62
|
+
staleTime: 1 * 60 * 1000, // 1 minute for current user
|
|
63
|
+
gcTime: 30 * 60 * 1000,
|
|
76
64
|
});
|
|
77
65
|
};
|
|
78
66
|
|
|
@@ -91,8 +79,8 @@ export const useUserById = (userId: string | null, options?: { enabled?: boolean
|
|
|
91
79
|
return await oxyServices.getUserById(userId);
|
|
92
80
|
},
|
|
93
81
|
enabled: (options?.enabled !== false) && !!userId,
|
|
94
|
-
staleTime:
|
|
95
|
-
gcTime:
|
|
82
|
+
staleTime: 5 * 60 * 1000,
|
|
83
|
+
gcTime: 30 * 60 * 1000,
|
|
96
84
|
});
|
|
97
85
|
};
|
|
98
86
|
|
|
@@ -111,8 +99,8 @@ export const useUserByUsername = (username: string | null, options?: { enabled?:
|
|
|
111
99
|
return await oxyServices.getProfileByUsername(username);
|
|
112
100
|
},
|
|
113
101
|
enabled: (options?.enabled !== false) && !!username,
|
|
114
|
-
staleTime:
|
|
115
|
-
gcTime:
|
|
102
|
+
staleTime: 5 * 60 * 1000,
|
|
103
|
+
gcTime: 30 * 60 * 1000,
|
|
116
104
|
});
|
|
117
105
|
};
|
|
118
106
|
|
|
@@ -131,8 +119,8 @@ export const useUsersBySessions = (sessionIds: string[], options?: { enabled?: b
|
|
|
131
119
|
return await oxyServices.getUsersBySessions(sessionIds);
|
|
132
120
|
},
|
|
133
121
|
enabled: (options?.enabled !== false) && sessionIds.length > 0,
|
|
134
|
-
staleTime:
|
|
135
|
-
gcTime:
|
|
122
|
+
staleTime: 5 * 60 * 1000,
|
|
123
|
+
gcTime: 30 * 60 * 1000,
|
|
136
124
|
});
|
|
137
125
|
};
|
|
138
126
|
|
|
@@ -140,11 +128,8 @@ export const useUsersBySessions = (sessionIds: string[], options?: { enabled?: b
|
|
|
140
128
|
* Get privacy settings for a user
|
|
141
129
|
*/
|
|
142
130
|
export const usePrivacySettings = (userId?: string, options?: { enabled?: boolean }) => {
|
|
143
|
-
const { oxyServices, activeSessionId,
|
|
144
|
-
|
|
145
|
-
// Never use user?.id as it may be set to publicKey
|
|
146
|
-
const targetUserId = userId || oxyServices.getCurrentUserId() || undefined;
|
|
147
|
-
const deviceId = activeSessionId ? sessions.find((s) => s.sessionId === activeSessionId)?.deviceId : undefined;
|
|
131
|
+
const { oxyServices, activeSessionId, user } = useOxy();
|
|
132
|
+
const targetUserId = userId || user?.id;
|
|
148
133
|
|
|
149
134
|
return useQuery({
|
|
150
135
|
queryKey: queryKeys.privacy.settings(targetUserId),
|
|
@@ -157,9 +142,16 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
157
142
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
158
143
|
try {
|
|
159
144
|
// Try to get token for the session
|
|
160
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
145
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
161
146
|
} catch (tokenError) {
|
|
162
|
-
|
|
147
|
+
// If getting token fails, might be an offline session - try syncing
|
|
148
|
+
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
149
|
+
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
150
|
+
// Session sync should be handled by the app layer (e.g., accounts app's useIdentity hook)
|
|
151
|
+
throw new Error('Session needs to be synced. Please try again.');
|
|
152
|
+
} else {
|
|
153
|
+
throw tokenError;
|
|
154
|
+
}
|
|
163
155
|
}
|
|
164
156
|
}
|
|
165
157
|
|
|
@@ -171,7 +163,8 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
171
163
|
|
|
172
164
|
// Handle authentication errors
|
|
173
165
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
174
|
-
|
|
166
|
+
// Session sync should be handled by the app layer
|
|
167
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
175
168
|
}
|
|
176
169
|
|
|
177
170
|
// TanStack Query will automatically retry on network errors
|
|
@@ -179,7 +172,8 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
179
172
|
}
|
|
180
173
|
},
|
|
181
174
|
enabled: (options?.enabled !== false) && !!targetUserId,
|
|
182
|
-
staleTime:
|
|
175
|
+
staleTime: 2 * 60 * 1000, // 2 minutes
|
|
183
176
|
gcTime: 10 * 60 * 1000, // 10 minutes
|
|
184
177
|
});
|
|
185
178
|
};
|
|
179
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { queryKeys } from './queryKeys';
|
|
3
|
-
import { useOxy } from '../../context/
|
|
3
|
+
import { useOxy } from '../../context/OxyContext';
|
|
4
4
|
import type { SecurityActivity, SecurityEventType } from '../../../models/interfaces';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import type { ClientSession } from '../../../models/session';
|
|
3
3
|
import { queryKeys } from './queryKeys';
|
|
4
|
-
import { useOxy } from '../../context/
|
|
4
|
+
import { useOxy } from '../../context/OxyContext';
|
|
5
5
|
import { fetchSessionsWithFallback, mapSessionsToClient } from '../../utils/sessionHelpers';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -89,8 +89,7 @@ export const useDeviceSessions = (options?: { enabled?: boolean }) => {
|
|
|
89
89
|
* Get user devices
|
|
90
90
|
*/
|
|
91
91
|
export const useUserDevices = (options?: { enabled?: boolean }) => {
|
|
92
|
-
const { oxyServices, isAuthenticated, activeSessionId
|
|
93
|
-
const deviceId = activeSessionId ? sessions.find((s) => s.sessionId === activeSessionId)?.deviceId : undefined;
|
|
92
|
+
const { oxyServices, isAuthenticated, activeSessionId } = useOxy();
|
|
94
93
|
|
|
95
94
|
return useQuery({
|
|
96
95
|
queryKey: queryKeys.devices.list(),
|
|
@@ -99,9 +98,16 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
|
|
|
99
98
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
100
99
|
try {
|
|
101
100
|
// Try to get token for the session
|
|
102
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
101
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
103
102
|
} catch (tokenError) {
|
|
104
|
-
|
|
103
|
+
// If getting token fails, might be an offline session - try syncing
|
|
104
|
+
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
105
|
+
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
106
|
+
// Session sync should be handled by the app layer
|
|
107
|
+
throw new Error('Session needs to be synced. Please try again.');
|
|
108
|
+
} else {
|
|
109
|
+
throw tokenError;
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
|
|
@@ -113,7 +119,8 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
|
|
|
113
119
|
|
|
114
120
|
// Handle authentication errors
|
|
115
121
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
116
|
-
|
|
122
|
+
// Session sync should be handled by the app layer
|
|
123
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
// TanStack Query will automatically retry on network errors
|
|
@@ -142,3 +149,4 @@ export const useSecurityInfo = (options?: { enabled?: boolean }) => {
|
|
|
142
149
|
gcTime: 30 * 60 * 1000,
|
|
143
150
|
});
|
|
144
151
|
};
|
|
152
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { toast } from '../../lib/sonner';
|
|
3
|
+
|
|
4
|
+
interface UseAsyncActionOptions<T> {
|
|
5
|
+
/** Function to execute */
|
|
6
|
+
action: () => Promise<T>;
|
|
7
|
+
/** Success message to display */
|
|
8
|
+
successMessage?: string;
|
|
9
|
+
/** Error message to display (or function to get message from error) */
|
|
10
|
+
errorMessage?: string | ((error: any) => string);
|
|
11
|
+
/** Callback on success */
|
|
12
|
+
onSuccess?: (result: T) => void;
|
|
13
|
+
/** Callback on error */
|
|
14
|
+
onError?: (error: any) => void;
|
|
15
|
+
/** Show loading toast */
|
|
16
|
+
showLoadingToast?: boolean;
|
|
17
|
+
/** Loading message */
|
|
18
|
+
loadingMessage?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface UseAsyncActionReturn<T> {
|
|
22
|
+
/** Execute the action */
|
|
23
|
+
execute: () => Promise<T | undefined>;
|
|
24
|
+
/** Whether the action is currently executing */
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
/** The last error that occurred */
|
|
27
|
+
error: Error | null;
|
|
28
|
+
/** Reset the error state */
|
|
29
|
+
resetError: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Hook for handling async actions with loading state, error handling, and toast notifications.
|
|
34
|
+
* Reduces boilerplate for common patterns like try-catch with toast feedback.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const { execute, isLoading } = useAsyncAction({
|
|
38
|
+
* action: () => api.saveSettings(settings),
|
|
39
|
+
* successMessage: 'Settings saved!',
|
|
40
|
+
* errorMessage: 'Failed to save settings',
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* <Button onPress={execute} disabled={isLoading}>Save</Button>
|
|
44
|
+
*/
|
|
45
|
+
export function useAsyncAction<T = void>(
|
|
46
|
+
options: UseAsyncActionOptions<T>
|
|
47
|
+
): UseAsyncActionReturn<T> {
|
|
48
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
49
|
+
const [error, setError] = useState<Error | null>(null);
|
|
50
|
+
|
|
51
|
+
const execute = useCallback(async (): Promise<T | undefined> => {
|
|
52
|
+
const {
|
|
53
|
+
action,
|
|
54
|
+
successMessage,
|
|
55
|
+
errorMessage,
|
|
56
|
+
onSuccess,
|
|
57
|
+
onError,
|
|
58
|
+
showLoadingToast,
|
|
59
|
+
loadingMessage,
|
|
60
|
+
} = options;
|
|
61
|
+
|
|
62
|
+
setIsLoading(true);
|
|
63
|
+
setError(null);
|
|
64
|
+
|
|
65
|
+
if (showLoadingToast && loadingMessage) {
|
|
66
|
+
toast.loading(loadingMessage);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const result = await action();
|
|
71
|
+
|
|
72
|
+
if (successMessage) {
|
|
73
|
+
toast.success(successMessage);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onSuccess?.(result);
|
|
77
|
+
return result;
|
|
78
|
+
} catch (err: any) {
|
|
79
|
+
const message = typeof errorMessage === 'function'
|
|
80
|
+
? errorMessage(err)
|
|
81
|
+
: errorMessage || err?.message || 'An error occurred';
|
|
82
|
+
|
|
83
|
+
toast.error(message);
|
|
84
|
+
setError(err instanceof Error ? err : new Error(message));
|
|
85
|
+
onError?.(err);
|
|
86
|
+
return undefined;
|
|
87
|
+
} finally {
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
}
|
|
90
|
+
}, [options]);
|
|
91
|
+
|
|
92
|
+
const resetError = useCallback(() => {
|
|
93
|
+
setError(null);
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
return { execute, isLoading, error, resetError };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Simplified version that just executes an async action with toast feedback.
|
|
101
|
+
* Useful for one-off actions.
|
|
102
|
+
*/
|
|
103
|
+
export async function executeWithToast<T>(
|
|
104
|
+
action: () => Promise<T>,
|
|
105
|
+
options?: {
|
|
106
|
+
successMessage?: string;
|
|
107
|
+
errorMessage?: string;
|
|
108
|
+
loadingMessage?: string;
|
|
109
|
+
}
|
|
110
|
+
): Promise<T | undefined> {
|
|
111
|
+
const { successMessage, errorMessage, loadingMessage } = options || {};
|
|
112
|
+
|
|
113
|
+
if (loadingMessage) {
|
|
114
|
+
toast.loading(loadingMessage);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
const result = await action();
|
|
119
|
+
if (successMessage) {
|
|
120
|
+
toast.success(successMessage);
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
} catch (err: any) {
|
|
124
|
+
toast.error(errorMessage || err?.message || 'An error occurred');
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default useAsyncAction;
|