@oxyhq/services 5.17.16 → 5.17.18
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.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 +27 -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/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/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/context/OxyContext.js +110 -192
- 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/mutations/useAccountMutations.js +78 -64
- 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/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/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 +5 -1
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +2 -2
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- 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/OxyAuthScreen.js +134 -66
- package/lib/commonjs/ui/screens/OxyAuthScreen.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/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.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 +15 -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/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/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/context/OxyContext.js +112 -184
- 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/mutations/useAccountMutations.js +79 -64
- 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/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/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 +5 -1
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +2 -2
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- 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/OxyAuthScreen.js +135 -68
- package/lib/module/ui/screens/OxyAuthScreen.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/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.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 +220 -8
- 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/IconButton/utils.d.ts +1 -1
- package/lib/typescript/ui/components/OxyProvider.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/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/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/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/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/AccountSettingsScreen.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/PrivacySettingsScreen.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.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 +19 -3
- 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/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/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/types.tsx +6 -0
- package/src/ui/context/OxyContext.tsx +173 -185
- package/src/ui/context/hooks/useAuthOperations.ts +177 -36
- package/src/ui/context/hooks/useSessionManagement.ts +399 -0
- package/src/ui/hooks/mutations/useAccountMutations.ts +82 -65
- 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/useProfileEditing.ts +3 -3
- package/src/ui/hooks/useSessionManagement.ts +5 -10
- package/src/ui/hooks/useSessionSocket.ts +46 -175
- package/src/ui/hooks/useStorage.ts +24 -76
- package/src/ui/index.ts +22 -13
- package/src/ui/navigation/routes.ts +6 -2
- package/src/ui/screens/AccountCenterScreen.tsx +2 -2
- package/src/ui/screens/AccountOverviewScreen.tsx +1 -1
- package/src/ui/screens/AccountSettingsScreen.tsx +34 -37
- package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
- package/src/ui/screens/OxyAuthScreen.tsx +138 -64
- package/src/ui/screens/PrivacySettingsScreen.tsx +6 -12
- 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,29 +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
|
-
//
|
|
102
|
+
|
|
103
|
+
// Invalidate all related queries to refresh everywhere
|
|
104
|
+
invalidateUserQueries(queryClient);
|
|
103
105
|
invalidateAccountQueries(queryClient);
|
|
104
|
-
|
|
105
|
-
logger.debug('Profile update complete', { component: 'useUpdateProfile' });
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
};
|
|
@@ -111,7 +111,7 @@ export const useUpdateProfile = () => {
|
|
|
111
111
|
* Upload avatar with progress tracking and offline queue support
|
|
112
112
|
*/
|
|
113
113
|
export const useUploadAvatar = () => {
|
|
114
|
-
const { oxyServices, activeSessionId
|
|
114
|
+
const { oxyServices, activeSessionId } = useOxy();
|
|
115
115
|
const queryClient = useQueryClient();
|
|
116
116
|
|
|
117
117
|
return useMutation({
|
|
@@ -119,9 +119,15 @@ export const useUploadAvatar = () => {
|
|
|
119
119
|
// Ensure we have a valid token before making the request
|
|
120
120
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
121
121
|
try {
|
|
122
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
122
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
123
123
|
} catch (tokenError) {
|
|
124
|
-
|
|
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
|
+
}
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
|
|
@@ -142,7 +148,8 @@ export const useUploadAvatar = () => {
|
|
|
142
148
|
|
|
143
149
|
// Handle authentication errors
|
|
144
150
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
145
|
-
|
|
151
|
+
// Session sync should be handled by the app layer
|
|
152
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
// TanStack Query will automatically retry on network errors
|
|
@@ -176,35 +183,24 @@ export const useUploadAvatar = () => {
|
|
|
176
183
|
}
|
|
177
184
|
toast.error(error instanceof Error ? error.message : 'Failed to upload avatar');
|
|
178
185
|
},
|
|
179
|
-
onSuccess:
|
|
180
|
-
logger.debug(
|
|
181
|
-
'Avatar upload successful',
|
|
182
|
-
{ component: 'useUploadAvatar', method: 'onSuccess', data }
|
|
183
|
-
);
|
|
184
|
-
|
|
186
|
+
onSuccess: (data) => {
|
|
185
187
|
queryClient.setQueryData(queryKeys.accounts.current(), data);
|
|
186
188
|
if (activeSessionId) {
|
|
187
189
|
queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
|
|
188
190
|
}
|
|
189
191
|
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
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);
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
// Invalidate all related queries to refresh everywhere
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// Explicitly refetch to ensure UI updates
|
|
200
|
-
await queryClient.refetchQueries({ queryKey: queryKeys.accounts.current() });
|
|
201
|
-
|
|
201
|
+
invalidateUserQueries(queryClient);
|
|
202
|
+
invalidateAccountQueries(queryClient);
|
|
202
203
|
toast.success('Avatar updated successfully');
|
|
203
|
-
|
|
204
|
-
logger.debug(
|
|
205
|
-
'Avatar update complete - cache invalidated and refetched',
|
|
206
|
-
{ component: 'useUploadAvatar', method: 'onSuccess' }
|
|
207
|
-
);
|
|
208
204
|
},
|
|
209
205
|
});
|
|
210
206
|
};
|
|
@@ -245,6 +241,9 @@ export const useUpdateAccountSettings = () => {
|
|
|
245
241
|
onSuccess: (data) => {
|
|
246
242
|
queryClient.setQueryData(queryKeys.accounts.current(), data);
|
|
247
243
|
|
|
244
|
+
// Update authStore so frontend components see the changes immediately
|
|
245
|
+
useAuthStore.getState().setUser(data);
|
|
246
|
+
|
|
248
247
|
invalidateAccountQueries(queryClient);
|
|
249
248
|
toast.success('Settings updated successfully');
|
|
250
249
|
},
|
|
@@ -258,14 +257,12 @@ export const useUpdateAccountSettings = () => {
|
|
|
258
257
|
* Update privacy settings with optimistic updates and authentication handling
|
|
259
258
|
*/
|
|
260
259
|
export const useUpdatePrivacySettings = () => {
|
|
261
|
-
const { oxyServices, activeSessionId,
|
|
260
|
+
const { oxyServices, activeSessionId, user } = useOxy();
|
|
262
261
|
const queryClient = useQueryClient();
|
|
263
262
|
|
|
264
263
|
return useMutation({
|
|
265
264
|
mutationFn: async ({ settings, userId }: { settings: Record<string, any>; userId?: string }) => {
|
|
266
|
-
|
|
267
|
-
// Never use user?.id as it may be set to publicKey
|
|
268
|
-
const targetUserId = userId || oxyServices.getCurrentUserId();
|
|
265
|
+
const targetUserId = userId || user?.id;
|
|
269
266
|
if (!targetUserId) {
|
|
270
267
|
throw new Error('User ID is required');
|
|
271
268
|
}
|
|
@@ -274,9 +271,16 @@ export const useUpdatePrivacySettings = () => {
|
|
|
274
271
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
275
272
|
try {
|
|
276
273
|
// Try to get token for the session
|
|
277
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
274
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
278
275
|
} catch (tokenError) {
|
|
279
|
-
|
|
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
|
+
}
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
|
|
@@ -288,7 +292,8 @@ export const useUpdatePrivacySettings = () => {
|
|
|
288
292
|
|
|
289
293
|
// Handle authentication errors
|
|
290
294
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
291
|
-
|
|
295
|
+
// Session sync should be handled by the app layer
|
|
296
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
292
297
|
}
|
|
293
298
|
|
|
294
299
|
// TanStack Query will automatically retry on network errors
|
|
@@ -297,7 +302,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
297
302
|
},
|
|
298
303
|
// Optimistic update
|
|
299
304
|
onMutate: async ({ settings, userId }) => {
|
|
300
|
-
const targetUserId = userId ||
|
|
305
|
+
const targetUserId = userId || user?.id;
|
|
301
306
|
if (!targetUserId) return;
|
|
302
307
|
|
|
303
308
|
// Cancel outgoing refetches
|
|
@@ -331,7 +336,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
331
336
|
},
|
|
332
337
|
// On error, rollback
|
|
333
338
|
onError: (error, { userId }, context) => {
|
|
334
|
-
const targetUserId = userId ||
|
|
339
|
+
const targetUserId = userId || user?.id;
|
|
335
340
|
if (context?.previousPrivacySettings && targetUserId) {
|
|
336
341
|
queryClient.setQueryData(queryKeys.privacy.settings(targetUserId), context.previousPrivacySettings);
|
|
337
342
|
}
|
|
@@ -342,7 +347,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
342
347
|
},
|
|
343
348
|
// On success, invalidate and refetch
|
|
344
349
|
onSuccess: (data, { userId }) => {
|
|
345
|
-
const targetUserId = userId ||
|
|
350
|
+
const targetUserId = userId || user?.id;
|
|
346
351
|
if (targetUserId) {
|
|
347
352
|
queryClient.setQueryData(queryKeys.privacy.settings(targetUserId), data);
|
|
348
353
|
}
|
|
@@ -354,12 +359,15 @@ export const useUpdatePrivacySettings = () => {
|
|
|
354
359
|
privacySettings: data,
|
|
355
360
|
};
|
|
356
361
|
queryClient.setQueryData<User>(queryKeys.accounts.current(), updatedUser);
|
|
362
|
+
|
|
363
|
+
// Update authStore so frontend components see the changes immediately
|
|
364
|
+
useAuthStore.getState().setUser(updatedUser);
|
|
357
365
|
}
|
|
358
366
|
invalidateAccountQueries(queryClient);
|
|
359
367
|
},
|
|
360
368
|
// Always refetch after error or success
|
|
361
369
|
onSettled: (data, error, { userId }) => {
|
|
362
|
-
const targetUserId = userId ||
|
|
370
|
+
const targetUserId = userId || user?.id;
|
|
363
371
|
if (targetUserId) {
|
|
364
372
|
queryClient.invalidateQueries({ queryKey: queryKeys.privacy.settings(targetUserId) });
|
|
365
373
|
}
|
|
@@ -372,7 +380,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
372
380
|
* Upload file with authentication handling and progress tracking
|
|
373
381
|
*/
|
|
374
382
|
export const useUploadFile = () => {
|
|
375
|
-
const { oxyServices, activeSessionId
|
|
383
|
+
const { oxyServices, activeSessionId } = useOxy();
|
|
376
384
|
|
|
377
385
|
return useMutation({
|
|
378
386
|
mutationFn: async ({
|
|
@@ -390,9 +398,16 @@ export const useUploadFile = () => {
|
|
|
390
398
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
391
399
|
try {
|
|
392
400
|
// Try to get token for the session
|
|
393
|
-
await oxyServices.getTokenBySession(activeSessionId
|
|
401
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
394
402
|
} catch (tokenError) {
|
|
395
|
-
|
|
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
|
+
}
|
|
396
411
|
}
|
|
397
412
|
}
|
|
398
413
|
|
|
@@ -404,7 +419,8 @@ export const useUploadFile = () => {
|
|
|
404
419
|
|
|
405
420
|
// Handle authentication errors
|
|
406
421
|
if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
|
|
407
|
-
|
|
422
|
+
// Session sync should be handled by the app layer
|
|
423
|
+
throw new Error('Authentication failed. Please sign in again.');
|
|
408
424
|
}
|
|
409
425
|
|
|
410
426
|
// TanStack Query will automatically retry on network errors
|
|
@@ -413,3 +429,4 @@ export const useUploadFile = () => {
|
|
|
413
429
|
},
|
|
414
430
|
});
|
|
415
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
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { useI18n } from './useI18n';
|
|
3
3
|
import { useUpdateProfile } from './mutations/useAccountMutations';
|
|
4
|
-
import {
|
|
4
|
+
import { useAuthStore } from '../stores/authStore';
|
|
5
5
|
|
|
6
6
|
export interface ProfileUpdateData {
|
|
7
7
|
displayName?: string;
|
|
@@ -34,7 +34,6 @@ export interface ProfileUpdateData {
|
|
|
34
34
|
export const useProfileEditing = () => {
|
|
35
35
|
const { t } = useI18n();
|
|
36
36
|
const updateProfileMutation = useUpdateProfile();
|
|
37
|
-
const { data: currentUser } = useCurrentUser();
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Save profile updates to the server using TanStack Query
|
|
@@ -72,6 +71,7 @@ export const useProfileEditing = () => {
|
|
|
72
71
|
|
|
73
72
|
// Handle name field
|
|
74
73
|
if (updates.displayName !== undefined || updates.lastName !== undefined) {
|
|
74
|
+
const currentUser = useAuthStore.getState().user;
|
|
75
75
|
const currentName = currentUser?.name;
|
|
76
76
|
updateData.name = {
|
|
77
77
|
first: updates.displayName ?? (typeof currentName === 'object' ? currentName?.first : '') ?? '',
|
|
@@ -86,7 +86,7 @@ export const useProfileEditing = () => {
|
|
|
86
86
|
// Error toast is handled by the mutation
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
|
-
}, [updateProfileMutation, t
|
|
89
|
+
}, [updateProfileMutation, t]);
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Update a single profile field
|
|
@@ -9,9 +9,6 @@ import type { OxyServices } from '../../core';
|
|
|
9
9
|
import type { QueryClient } from '@tanstack/react-query';
|
|
10
10
|
import { clearQueryCache } from './queryClient';
|
|
11
11
|
|
|
12
|
-
const getDeviceIdForSession = (sessions: ClientSession[] = [], sessionId: string | null) =>
|
|
13
|
-
sessionId ? sessions.find((s) => s.sessionId === sessionId)?.deviceId : undefined;
|
|
14
|
-
|
|
15
12
|
export interface UseSessionManagementOptions {
|
|
16
13
|
oxyServices: OxyServices;
|
|
17
14
|
storage: StorageInterface | null;
|
|
@@ -147,8 +144,7 @@ export const useSessionManagement = ({
|
|
|
147
144
|
try {
|
|
148
145
|
await storage.removeItem(storageKeys.activeSessionId);
|
|
149
146
|
await storage.removeItem(storageKeys.sessionIds);
|
|
150
|
-
//
|
|
151
|
-
await storage.removeItem('oxy_identity_synced').catch(() => {});
|
|
147
|
+
// Note: Identity sync state ('oxy_identity_synced') is managed by accounts app
|
|
152
148
|
} catch (error) {
|
|
153
149
|
handleAuthError(error, {
|
|
154
150
|
defaultMessage: CLEAR_STORAGE_ERROR,
|
|
@@ -164,7 +160,6 @@ export const useSessionManagement = ({
|
|
|
164
160
|
setSessions([]);
|
|
165
161
|
setActiveSessionId(null);
|
|
166
162
|
logoutStore();
|
|
167
|
-
oxyServices.clearTokens();
|
|
168
163
|
|
|
169
164
|
// Clear TanStack Query cache (in-memory)
|
|
170
165
|
if (queryClient) {
|
|
@@ -184,12 +179,11 @@ export const useSessionManagement = ({
|
|
|
184
179
|
|
|
185
180
|
await clearSessionStorage();
|
|
186
181
|
onAuthStateChange?.(null);
|
|
187
|
-
}, [clearSessionStorage, logoutStore, onAuthStateChange, queryClient, storage, logger
|
|
182
|
+
}, [clearSessionStorage, logoutStore, onAuthStateChange, queryClient, storage, logger]);
|
|
188
183
|
|
|
189
184
|
const activateSession = useCallback(
|
|
190
185
|
async (sessionId: string, user: User): Promise<void> => {
|
|
191
|
-
|
|
192
|
-
await oxyServices.getTokenBySession(sessionId, deviceId);
|
|
186
|
+
await oxyServices.getTokenBySession(sessionId);
|
|
193
187
|
setTokenReady?.(true);
|
|
194
188
|
setActiveSessionId(sessionId);
|
|
195
189
|
loginSuccess(user);
|
|
@@ -199,7 +193,6 @@ export const useSessionManagement = ({
|
|
|
199
193
|
},
|
|
200
194
|
[
|
|
201
195
|
applyLanguagePreference,
|
|
202
|
-
sessions,
|
|
203
196
|
loginSuccess,
|
|
204
197
|
onAuthStateChange,
|
|
205
198
|
oxyServices,
|
|
@@ -403,3 +396,5 @@ export const useSessionManagement = ({
|
|
|
403
396
|
isRefreshInFlight,
|
|
404
397
|
};
|
|
405
398
|
};
|
|
399
|
+
|
|
400
|
+
|