@oxyhq/services 5.16.43 → 5.17.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 +29 -10
- package/lib/commonjs/core/OxyServices.js +1 -1
- package/lib/commonjs/core/index.js +20 -15
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.auth.js +36 -53
- package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.user.js +10 -17
- package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/commonjs/core/services/TokenService.js +27 -13
- package/lib/commonjs/core/services/TokenService.js.map +1 -1
- package/lib/commonjs/crypto/index.js +0 -16
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +21 -22
- package/lib/commonjs/crypto/keyManager.js.map +1 -1
- package/lib/commonjs/crypto/polyfill.js +1 -10
- package/lib/commonjs/crypto/polyfill.js.map +1 -1
- package/lib/commonjs/crypto/signatureService.js +18 -32
- package/lib/commonjs/crypto/signatureService.js.map +1 -1
- package/lib/commonjs/index.js +13 -134
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/interfaces.js +0 -7
- package/lib/commonjs/models/interfaces.js.map +1 -1
- package/lib/commonjs/node/index.js +1 -10
- package/lib/commonjs/node/index.js.map +1 -1
- package/lib/commonjs/ui/components/BottomSheetRouter.js +1 -9
- package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +779 -450
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +551 -0
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -0
- package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +73 -0
- package/lib/commonjs/ui/context/hooks/useDeviceManagement.js.map +1 -0
- package/lib/commonjs/ui/context/hooks/useStorage.js +79 -0
- package/lib/commonjs/ui/context/hooks/useStorage.js.map +1 -0
- package/lib/commonjs/ui/hooks/index.js +0 -20
- package/lib/commonjs/ui/hooks/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/index.js +0 -12
- package/lib/commonjs/ui/hooks/mutations/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +23 -74
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/index.js +0 -12
- package/lib/commonjs/ui/hooks/queries/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/queryKeys.js +1 -3
- package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +28 -64
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +6 -4
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/useDeviceManagement.js +73 -0
- package/lib/commonjs/ui/hooks/useDeviceManagement.js.map +1 -0
- package/lib/commonjs/ui/hooks/useProfileEditing.js +5 -3
- package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionManagement.js +284 -0
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -0
- package/lib/commonjs/ui/index.js +2 -10
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +1 -5
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +4 -9
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +19 -37
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +5 -5
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +15 -2
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +97 -76
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +6 -6
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +6 -54
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/styles/spacing.js +2 -54
- package/lib/commonjs/ui/styles/spacing.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +12 -9
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/commonjs/ui/utils/sessionHelpers.js +1 -7
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/deviceManager.js +177 -0
- package/lib/commonjs/utils/deviceManager.js.map +1 -0
- package/lib/commonjs/utils/errorUtils.js +0 -13
- package/lib/commonjs/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/sessionUtils.js +1 -8
- package/lib/commonjs/utils/sessionUtils.js.map +1 -1
- package/lib/commonjs/utils/validationUtils.js +1 -15
- package/lib/commonjs/utils/validationUtils.js.map +1 -1
- package/lib/module/core/OxyServices.js +1 -1
- package/lib/module/core/index.js +4 -6
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.auth.js +36 -53
- package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.user.js +10 -17
- package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/module/core/services/TokenService.js +27 -13
- package/lib/module/core/services/TokenService.js.map +1 -1
- package/lib/module/crypto/index.js +0 -3
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/crypto/keyManager.js +21 -22
- package/lib/module/crypto/keyManager.js.map +1 -1
- package/lib/module/crypto/polyfill.js +1 -2
- package/lib/module/crypto/polyfill.js.map +1 -1
- package/lib/module/crypto/signatureService.js +18 -32
- package/lib/module/crypto/signatureService.js.map +1 -1
- package/lib/module/index.js +7 -19
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/interfaces.js +0 -7
- package/lib/module/models/interfaces.js.map +1 -1
- package/lib/module/node/index.js +0 -3
- package/lib/module/node/index.js.map +1 -1
- package/lib/module/ui/components/BottomSheetRouter.js +2 -6
- package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +779 -450
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +545 -0
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -0
- package/lib/module/ui/context/hooks/useDeviceManagement.js +68 -0
- package/lib/module/ui/context/hooks/useDeviceManagement.js.map +1 -0
- package/lib/module/ui/context/hooks/useStorage.js +74 -0
- package/lib/module/ui/context/hooks/useStorage.js.map +1 -0
- package/lib/module/ui/hooks/index.js +0 -1
- package/lib/module/ui/hooks/index.js.map +1 -1
- package/lib/module/ui/hooks/mutations/index.js +1 -1
- package/lib/module/ui/hooks/mutations/index.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +21 -71
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/queries/index.js +1 -1
- package/lib/module/ui/hooks/queries/index.js.map +1 -1
- package/lib/module/ui/hooks/queries/queryKeys.js +1 -3
- package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +27 -61
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +6 -4
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useDeviceManagement.js +68 -0
- package/lib/module/ui/hooks/useDeviceManagement.js.map +1 -0
- package/lib/module/ui/hooks/useProfileEditing.js +5 -3
- package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/module/ui/hooks/useSessionManagement.js +279 -0
- package/lib/module/ui/hooks/useSessionManagement.js.map +1 -0
- package/lib/module/ui/index.js +1 -2
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +1 -5
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +4 -9
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +19 -37
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +5 -5
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +15 -2
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/screens/PrivacySettingsScreen.js +98 -77
- package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +6 -6
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +6 -54
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/styles/spacing.js +2 -6
- package/lib/module/ui/styles/spacing.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +12 -9
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/ui/utils/sessionHelpers.js +1 -7
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/deviceManager.js +171 -0
- package/lib/module/utils/deviceManager.js.map +1 -0
- package/lib/module/utils/errorUtils.js +0 -7
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/utils/index.js +1 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/sessionUtils.js +1 -8
- package/lib/module/utils/sessionUtils.js.map +1 -1
- package/lib/module/utils/validationUtils.js +0 -13
- package/lib/module/utils/validationUtils.js.map +1 -1
- package/lib/typescript/core/OxyServices.d.ts +1 -1
- package/lib/typescript/core/index.d.ts +3 -3
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts +21 -44
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -0
- package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +8 -15
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/core/services/TokenService.d.ts.map +1 -1
- package/lib/typescript/crypto/index.d.ts +0 -1
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts +2 -15
- package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
- package/lib/typescript/crypto/polyfill.d.ts +1 -2
- package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
- package/lib/typescript/crypto/signatureService.d.ts +0 -13
- package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +7 -12
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +36 -5
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/models/session.d.ts +18 -3
- package/lib/typescript/models/session.d.ts.map +1 -1
- package/lib/typescript/node/index.d.ts +0 -1
- package/lib/typescript/node/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/BottomSheetRouter.d.ts +0 -5
- package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
- package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
- package/lib/typescript/ui/components/TextField/helpers.d.ts +2 -2
- package/lib/typescript/ui/components/TextField/types.d.ts +0 -1
- package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +28 -5
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +59 -0
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -0
- package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts +27 -0
- package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts.map +1 -0
- package/lib/typescript/ui/context/hooks/useStorage.d.ts +22 -0
- package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/index.d.ts +0 -1
- package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/index.d.ts +1 -1
- package/lib/typescript/ui/hooks/mutations/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +8 -19
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +1 -1
- package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/index.d.ts +1 -1
- package/lib/typescript/ui/hooks/queries/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/queryKeys.d.ts +0 -2
- package/lib/typescript/ui/hooks/queries/queryKeys.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +5 -17
- 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/useDeviceManagement.d.ts +27 -0
- package/lib/typescript/ui/hooks/useDeviceManagement.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts +41 -0
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -0
- package/lib/typescript/ui/index.d.ts +0 -1
- 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/AccountCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +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/authStore.d.ts +1 -8
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/styles/spacing.d.ts +0 -5
- package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts +4 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/ui/utils/sessionHelpers.d.ts +0 -1
- package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/utils/deviceManager.d.ts +66 -0
- package/lib/typescript/utils/deviceManager.d.ts.map +1 -0
- package/lib/typescript/utils/errorUtils.d.ts +0 -6
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +2 -0
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
- package/lib/typescript/utils/validationUtils.d.ts +0 -8
- package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
- package/package.json +1 -6
- package/src/core/OxyServices.ts +1 -1
- package/src/core/index.ts +5 -8
- package/src/core/mixins/OxyServices.auth.ts +44 -87
- package/src/core/mixins/OxyServices.user.ts +10 -18
- package/src/core/services/TokenService.ts +27 -16
- package/src/crypto/index.ts +1 -3
- package/src/crypto/keyManager.ts +21 -30
- package/src/crypto/polyfill.ts +1 -2
- package/src/crypto/signatureService.ts +19 -43
- package/src/index.ts +6 -41
- package/src/models/interfaces.ts +39 -12
- package/src/models/session.ts +19 -7
- package/src/node/index.ts +0 -3
- package/src/ui/components/BottomSheetRouter.tsx +1 -6
- package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
- package/src/ui/components/TextField/helpers.tsx +2 -2
- package/src/ui/components/TextField/types.tsx +1 -1
- package/src/ui/context/OxyContext.tsx +831 -463
- package/src/ui/context/hooks/useAuthOperations.ts +620 -0
- package/src/ui/context/hooks/useDeviceManagement.ts +108 -0
- package/src/ui/context/hooks/useStorage.ts +104 -0
- package/src/ui/hooks/index.ts +1 -2
- package/src/ui/hooks/mutations/index.ts +0 -2
- package/src/ui/hooks/mutations/useAccountMutations.ts +20 -66
- package/src/ui/hooks/queries/index.ts +0 -2
- package/src/ui/hooks/queries/queryKeys.ts +0 -2
- package/src/ui/hooks/queries/useAccountQueries.ts +19 -53
- package/src/ui/hooks/queries/useServicesQueries.ts +5 -5
- package/src/ui/hooks/useDeviceManagement.ts +108 -0
- package/src/ui/hooks/useProfileEditing.ts +3 -3
- package/src/ui/hooks/useSessionManagement.ts +405 -0
- package/src/ui/index.ts +1 -2
- package/src/ui/navigation/routes.ts +2 -6
- package/src/ui/screens/AccountCenterScreen.tsx +4 -9
- package/src/ui/screens/AccountSettingsScreen.tsx +31 -49
- package/src/ui/screens/AccountSwitcherScreen.tsx +5 -5
- package/src/ui/screens/OxyAuthScreen.tsx +19 -4
- package/src/ui/screens/PrivacySettingsScreen.tsx +101 -67
- package/src/ui/screens/ProfileScreen.tsx +10 -10
- package/src/ui/stores/authStore.ts +8 -48
- package/src/ui/styles/spacing.ts +2 -15
- package/src/ui/utils/avatarUtils.ts +21 -19
- package/src/ui/utils/sessionHelpers.ts +0 -7
- package/src/utils/__tests__/validationUtils.test.ts +1 -16
- package/src/utils/deviceManager.ts +198 -0
- package/src/utils/errorUtils.ts +1 -8
- package/src/utils/index.ts +2 -1
- package/src/utils/sessionUtils.ts +0 -8
- package/src/utils/validationUtils.ts +0 -12
- package/lib/commonjs/adapters/expo/crypto.js +0 -56
- package/lib/commonjs/adapters/expo/crypto.js.map +0 -1
- package/lib/commonjs/adapters/expo/fetch.js +0 -30
- package/lib/commonjs/adapters/expo/fetch.js.map +0 -1
- package/lib/commonjs/adapters/expo/index.js +0 -48
- package/lib/commonjs/adapters/expo/index.js.map +0 -1
- package/lib/commonjs/adapters/expo/storage.js +0 -201
- package/lib/commonjs/adapters/expo/storage.js.map +0 -1
- package/lib/commonjs/adapters/index.js +0 -37
- package/lib/commonjs/adapters/index.js.map +0 -1
- package/lib/commonjs/adapters/node/crypto.js +0 -40
- package/lib/commonjs/adapters/node/crypto.js.map +0 -1
- package/lib/commonjs/adapters/node/fetch.js +0 -62
- package/lib/commonjs/adapters/node/fetch.js.map +0 -1
- package/lib/commonjs/adapters/node/index.js +0 -34
- package/lib/commonjs/adapters/node/index.js.map +0 -1
- package/lib/commonjs/adapters/node/storage.js +0 -163
- package/lib/commonjs/adapters/node/storage.js.map +0 -1
- package/lib/commonjs/core/identity-session/DeviceManager.js +0 -237
- package/lib/commonjs/core/identity-session/DeviceManager.js.map +0 -1
- package/lib/commonjs/core/identity-session/INTEGRATION_GUIDE.md +0 -287
- package/lib/commonjs/core/identity-session/IdentityManager.js +0 -400
- package/lib/commonjs/core/identity-session/IdentityManager.js.map +0 -1
- package/lib/commonjs/core/identity-session/IdentitySessionCore.js +0 -394
- package/lib/commonjs/core/identity-session/IdentitySessionCore.js.map +0 -1
- package/lib/commonjs/core/identity-session/RefreshManager.js +0 -137
- package/lib/commonjs/core/identity-session/RefreshManager.js.map +0 -1
- package/lib/commonjs/core/identity-session/SessionManager.js +0 -427
- package/lib/commonjs/core/identity-session/SessionManager.js.map +0 -1
- package/lib/commonjs/core/identity-session/createIdentitySessionCore.js +0 -24
- package/lib/commonjs/core/identity-session/createIdentitySessionCore.js.map +0 -1
- package/lib/commonjs/core/identity-session/errors.js +0 -176
- package/lib/commonjs/core/identity-session/errors.js.map +0 -1
- package/lib/commonjs/core/identity-session/index.js +0 -80
- package/lib/commonjs/core/identity-session/index.js.map +0 -1
- package/lib/commonjs/core/identity-session/types.js +0 -2
- package/lib/commonjs/core/identity-session/types.js.map +0 -1
- package/lib/commonjs/crypto/README.md +0 -142
- package/lib/commonjs/crypto/core.js +0 -147
- package/lib/commonjs/crypto/core.js.map +0 -1
- package/lib/commonjs/node/signatureService.js +0 -107
- package/lib/commonjs/node/signatureService.js.map +0 -1
- package/lib/commonjs/ui/hooks/auth/index.js +0 -37
- package/lib/commonjs/ui/hooks/auth/index.js.map +0 -1
- package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js +0 -171
- package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js.map +0 -1
- package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -52
- package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
- package/lib/commonjs/ui/hooks/useIdentityTransfer.js +0 -125
- package/lib/commonjs/ui/hooks/useIdentityTransfer.js.map +0 -1
- package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js +0 -81
- package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js.map +0 -1
- package/lib/commonjs/ui/hooks/useTransferQueries.js +0 -85
- package/lib/commonjs/ui/hooks/useTransferQueries.js.map +0 -1
- package/lib/commonjs/ui/stores/transferStore.js +0 -157
- package/lib/commonjs/ui/stores/transferStore.js.map +0 -1
- package/lib/module/adapters/expo/crypto.js +0 -51
- package/lib/module/adapters/expo/crypto.js.map +0 -1
- package/lib/module/adapters/expo/fetch.js +0 -26
- package/lib/module/adapters/expo/fetch.js.map +0 -1
- package/lib/module/adapters/expo/index.js +0 -45
- package/lib/module/adapters/expo/index.js.map +0 -1
- package/lib/module/adapters/expo/storage.js +0 -198
- package/lib/module/adapters/expo/storage.js.map +0 -1
- package/lib/module/adapters/index.js +0 -34
- package/lib/module/adapters/index.js.map +0 -1
- package/lib/module/adapters/node/crypto.js +0 -36
- package/lib/module/adapters/node/crypto.js.map +0 -1
- package/lib/module/adapters/node/fetch.js +0 -57
- package/lib/module/adapters/node/fetch.js.map +0 -1
- package/lib/module/adapters/node/index.js +0 -31
- package/lib/module/adapters/node/index.js.map +0 -1
- package/lib/module/adapters/node/storage.js +0 -159
- package/lib/module/adapters/node/storage.js.map +0 -1
- package/lib/module/core/identity-session/DeviceManager.js +0 -232
- package/lib/module/core/identity-session/DeviceManager.js.map +0 -1
- package/lib/module/core/identity-session/INTEGRATION_GUIDE.md +0 -287
- package/lib/module/core/identity-session/IdentityManager.js +0 -395
- package/lib/module/core/identity-session/IdentityManager.js.map +0 -1
- package/lib/module/core/identity-session/IdentitySessionCore.js +0 -390
- package/lib/module/core/identity-session/IdentitySessionCore.js.map +0 -1
- package/lib/module/core/identity-session/RefreshManager.js +0 -132
- package/lib/module/core/identity-session/RefreshManager.js.map +0 -1
- package/lib/module/core/identity-session/SessionManager.js +0 -422
- package/lib/module/core/identity-session/SessionManager.js.map +0 -1
- package/lib/module/core/identity-session/createIdentitySessionCore.js +0 -21
- package/lib/module/core/identity-session/createIdentitySessionCore.js.map +0 -1
- package/lib/module/core/identity-session/errors.js +0 -170
- package/lib/module/core/identity-session/errors.js.map +0 -1
- package/lib/module/core/identity-session/index.js +0 -17
- package/lib/module/core/identity-session/index.js.map +0 -1
- package/lib/module/core/identity-session/types.js +0 -2
- package/lib/module/core/identity-session/types.js.map +0 -1
- package/lib/module/crypto/README.md +0 -142
- package/lib/module/crypto/core.js +0 -133
- package/lib/module/crypto/core.js.map +0 -1
- package/lib/module/node/signatureService.js +0 -101
- package/lib/module/node/signatureService.js.map +0 -1
- package/lib/module/ui/hooks/auth/index.js +0 -7
- package/lib/module/ui/hooks/auth/index.js.map +0 -1
- package/lib/module/ui/hooks/auth/useUsernameValidation.js +0 -167
- package/lib/module/ui/hooks/auth/useUsernameValidation.js.map +0 -1
- package/lib/module/ui/hooks/useAvatarPicker.js +0 -48
- package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
- package/lib/module/ui/hooks/useIdentityTransfer.js +0 -121
- package/lib/module/ui/hooks/useIdentityTransfer.js.map +0 -1
- package/lib/module/ui/hooks/useTransferCodesPersistence.js +0 -77
- package/lib/module/ui/hooks/useTransferCodesPersistence.js.map +0 -1
- package/lib/module/ui/hooks/useTransferQueries.js +0 -80
- package/lib/module/ui/hooks/useTransferQueries.js.map +0 -1
- package/lib/module/ui/stores/transferStore.js +0 -152
- package/lib/module/ui/stores/transferStore.js.map +0 -1
- package/lib/typescript/adapters/expo/crypto.d.ts +0 -17
- package/lib/typescript/adapters/expo/crypto.d.ts.map +0 -1
- package/lib/typescript/adapters/expo/fetch.d.ts +0 -16
- package/lib/typescript/adapters/expo/fetch.d.ts.map +0 -1
- package/lib/typescript/adapters/expo/index.d.ts +0 -23
- package/lib/typescript/adapters/expo/index.d.ts.map +0 -1
- package/lib/typescript/adapters/expo/storage.d.ts +0 -23
- package/lib/typescript/adapters/expo/storage.d.ts.map +0 -1
- package/lib/typescript/adapters/index.d.ts +0 -17
- package/lib/typescript/adapters/index.d.ts.map +0 -1
- package/lib/typescript/adapters/node/crypto.d.ts +0 -17
- package/lib/typescript/adapters/node/crypto.d.ts.map +0 -1
- package/lib/typescript/adapters/node/fetch.d.ts +0 -16
- package/lib/typescript/adapters/node/fetch.d.ts.map +0 -1
- package/lib/typescript/adapters/node/index.d.ts +0 -23
- package/lib/typescript/adapters/node/index.d.ts.map +0 -1
- package/lib/typescript/adapters/node/storage.d.ts +0 -23
- package/lib/typescript/adapters/node/storage.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/DeviceManager.d.ts +0 -64
- package/lib/typescript/core/identity-session/DeviceManager.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/IdentityManager.d.ts +0 -88
- package/lib/typescript/core/identity-session/IdentityManager.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts +0 -141
- package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/RefreshManager.d.ts +0 -36
- package/lib/typescript/core/identity-session/RefreshManager.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/SessionManager.d.ts +0 -104
- package/lib/typescript/core/identity-session/SessionManager.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts +0 -11
- package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/errors.d.ts +0 -63
- package/lib/typescript/core/identity-session/errors.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/index.d.ts +0 -14
- package/lib/typescript/core/identity-session/index.d.ts.map +0 -1
- package/lib/typescript/core/identity-session/types.d.ts +0 -196
- package/lib/typescript/core/identity-session/types.d.ts.map +0 -1
- package/lib/typescript/crypto/core.d.ts +0 -56
- package/lib/typescript/crypto/core.d.ts.map +0 -1
- package/lib/typescript/node/signatureService.d.ts +0 -55
- package/lib/typescript/node/signatureService.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/auth/index.d.ts +0 -6
- package/lib/typescript/ui/hooks/auth/index.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts +0 -32
- package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -18
- package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts +0 -24
- package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts +0 -6
- package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useTransferQueries.d.ts +0 -26
- package/lib/typescript/ui/hooks/useTransferQueries.d.ts.map +0 -1
- package/lib/typescript/ui/stores/transferStore.d.ts +0 -36
- package/lib/typescript/ui/stores/transferStore.d.ts.map +0 -1
- package/src/adapters/expo/crypto.ts +0 -55
- package/src/adapters/expo/fetch.ts +0 -28
- package/src/adapters/expo/index.ts +0 -51
- package/src/adapters/expo/storage.ts +0 -228
- package/src/adapters/index.ts +0 -34
- package/src/adapters/node/crypto.ts +0 -39
- package/src/adapters/node/fetch.ts +0 -59
- package/src/adapters/node/index.ts +0 -37
- package/src/adapters/node/storage.ts +0 -170
- package/src/core/identity-session/DeviceManager.ts +0 -273
- package/src/core/identity-session/INTEGRATION_GUIDE.md +0 -287
- package/src/core/identity-session/IdentityManager.ts +0 -474
- package/src/core/identity-session/IdentitySessionCore.ts +0 -464
- package/src/core/identity-session/RefreshManager.ts +0 -189
- package/src/core/identity-session/SessionManager.ts +0 -500
- package/src/core/identity-session/createIdentitySessionCore.ts +0 -19
- package/src/core/identity-session/errors.ts +0 -197
- package/src/core/identity-session/index.ts +0 -15
- package/src/core/identity-session/types.ts +0 -188
- package/src/crypto/README.md +0 -142
- package/src/crypto/__tests__/core.test.ts +0 -203
- package/src/crypto/core.ts +0 -142
- package/src/node/signatureService.ts +0 -126
- package/src/ui/hooks/auth/index.ts +0 -9
- package/src/ui/hooks/auth/useUsernameValidation.ts +0 -177
- package/src/ui/hooks/useAvatarPicker.ts +0 -62
- package/src/ui/hooks/useIdentityTransfer.ts +0 -135
- package/src/ui/hooks/useTransferCodesPersistence.ts +0 -80
- package/src/ui/hooks/useTransferQueries.ts +0 -102
- package/src/ui/stores/transferStore.ts +0 -201
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import type { ApiError } from '../../../models/interfaces';
|
|
3
|
+
import { DeviceManager } from '../../../utils/deviceManager';
|
|
4
|
+
import type { OxyServices } from '../../../core';
|
|
5
|
+
import { handleAuthError } from '../../utils/errorHandlers';
|
|
6
|
+
|
|
7
|
+
export interface UseDeviceManagementOptions {
|
|
8
|
+
oxyServices: OxyServices;
|
|
9
|
+
activeSessionId: string | null;
|
|
10
|
+
onError?: (error: ApiError) => void;
|
|
11
|
+
clearSessionState: () => Promise<void>;
|
|
12
|
+
logger?: (message: string, error?: unknown) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface UseDeviceManagementResult {
|
|
16
|
+
getDeviceSessions: () => Promise<
|
|
17
|
+
Array<{
|
|
18
|
+
sessionId: string;
|
|
19
|
+
deviceId: string;
|
|
20
|
+
deviceName?: string;
|
|
21
|
+
lastActive?: string;
|
|
22
|
+
expiresAt?: string;
|
|
23
|
+
}>
|
|
24
|
+
>;
|
|
25
|
+
logoutAllDeviceSessions: () => Promise<void>;
|
|
26
|
+
updateDeviceName: (deviceName: string) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Provide device session management helpers tied to the current active session.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Device management configuration
|
|
33
|
+
*/
|
|
34
|
+
export const useDeviceManagement = ({
|
|
35
|
+
oxyServices,
|
|
36
|
+
activeSessionId,
|
|
37
|
+
onError,
|
|
38
|
+
clearSessionState,
|
|
39
|
+
logger,
|
|
40
|
+
}: UseDeviceManagementOptions): UseDeviceManagementResult => {
|
|
41
|
+
const getDeviceSessions = useCallback(async (): Promise<
|
|
42
|
+
Array<{
|
|
43
|
+
sessionId: string;
|
|
44
|
+
deviceId: string;
|
|
45
|
+
deviceName?: string;
|
|
46
|
+
lastActive?: string;
|
|
47
|
+
expiresAt?: string;
|
|
48
|
+
}>
|
|
49
|
+
> => {
|
|
50
|
+
if (!activeSessionId) throw new Error('No active session');
|
|
51
|
+
try {
|
|
52
|
+
return await oxyServices.getDeviceSessions(activeSessionId);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
handleAuthError(error, {
|
|
55
|
+
defaultMessage: 'Failed to get device sessions',
|
|
56
|
+
code: 'GET_DEVICE_SESSIONS_ERROR',
|
|
57
|
+
onError,
|
|
58
|
+
logger,
|
|
59
|
+
});
|
|
60
|
+
throw error instanceof Error ? error : new Error('Failed to get device sessions');
|
|
61
|
+
}
|
|
62
|
+
}, [activeSessionId, logger, onError, oxyServices]);
|
|
63
|
+
|
|
64
|
+
const logoutAllDeviceSessions = useCallback(async (): Promise<void> => {
|
|
65
|
+
if (!activeSessionId) throw new Error('No active session');
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
await oxyServices.logoutAllDeviceSessions(activeSessionId);
|
|
69
|
+
await clearSessionState();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
handleAuthError(error, {
|
|
72
|
+
defaultMessage: 'Failed to logout all device sessions',
|
|
73
|
+
code: 'LOGOUT_ALL_DEVICES_ERROR',
|
|
74
|
+
onError,
|
|
75
|
+
logger,
|
|
76
|
+
});
|
|
77
|
+
throw error instanceof Error ? error : new Error('Failed to logout all device sessions');
|
|
78
|
+
}
|
|
79
|
+
}, [activeSessionId, clearSessionState, logger, onError, oxyServices]);
|
|
80
|
+
|
|
81
|
+
const updateDeviceName = useCallback(
|
|
82
|
+
async (deviceName: string): Promise<void> => {
|
|
83
|
+
if (!activeSessionId) throw new Error('No active session');
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
await oxyServices.updateDeviceName(activeSessionId, deviceName);
|
|
87
|
+
await DeviceManager.updateDeviceName(deviceName);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
handleAuthError(error, {
|
|
90
|
+
defaultMessage: 'Failed to update device name',
|
|
91
|
+
code: 'UPDATE_DEVICE_NAME_ERROR',
|
|
92
|
+
onError,
|
|
93
|
+
logger,
|
|
94
|
+
});
|
|
95
|
+
throw error instanceof Error ? error : new Error('Failed to update device name');
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
[activeSessionId, logger, onError, oxyServices],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
getDeviceSessions,
|
|
103
|
+
logoutAllDeviceSessions,
|
|
104
|
+
updateDeviceName,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import type { ApiError } from '../../../models/interfaces';
|
|
3
|
+
import { createPlatformStorage, type StorageInterface } from '../../utils/storageHelpers';
|
|
4
|
+
import { extractErrorMessage } from '../../utils/errorHandlers';
|
|
5
|
+
|
|
6
|
+
export interface UseStorageOptions {
|
|
7
|
+
onError?: (error: ApiError) => void;
|
|
8
|
+
logger?: (message: string, error?: unknown) => void;
|
|
9
|
+
errorCode?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UseStorageResult {
|
|
13
|
+
storage: StorageInterface | null;
|
|
14
|
+
isReady: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
refresh: () => Promise<StorageInterface | null>;
|
|
17
|
+
withStorage: <T>(callback: (storage: StorageInterface) => Promise<T>) => Promise<T | null>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DEFAULT_ERROR_CODE = 'STORAGE_INIT_ERROR';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* React hook that exposes a platform-agnostic storage reference.
|
|
24
|
+
* Handles initialization, error propagation, and lazy re-initialization.
|
|
25
|
+
*
|
|
26
|
+
* @param options - Optional configuration for error reporting and logging
|
|
27
|
+
*/
|
|
28
|
+
export const useStorage = ({
|
|
29
|
+
onError,
|
|
30
|
+
logger,
|
|
31
|
+
errorCode = DEFAULT_ERROR_CODE,
|
|
32
|
+
}: UseStorageOptions = {}): UseStorageResult => {
|
|
33
|
+
const [storage, setStorage] = useState<StorageInterface | null>(null);
|
|
34
|
+
const [error, setError] = useState<string | null>(null);
|
|
35
|
+
const initializingRef = useRef<Promise<StorageInterface | null> | null>(null);
|
|
36
|
+
|
|
37
|
+
const notifyError = useCallback(
|
|
38
|
+
(err: unknown) => {
|
|
39
|
+
const message = extractErrorMessage(err, 'Failed to initialize storage');
|
|
40
|
+
setError(message);
|
|
41
|
+
|
|
42
|
+
if (logger) {
|
|
43
|
+
logger(message, err);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
onError?.({
|
|
47
|
+
message,
|
|
48
|
+
code: errorCode,
|
|
49
|
+
status: 500,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
[errorCode, logger, onError],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const createStorageInstance = useCallback(async (): Promise<StorageInterface | null> => {
|
|
56
|
+
try {
|
|
57
|
+
const platformStorage = await createPlatformStorage();
|
|
58
|
+
setStorage(platformStorage);
|
|
59
|
+
setError(null);
|
|
60
|
+
return platformStorage;
|
|
61
|
+
} catch (err) {
|
|
62
|
+
notifyError(err);
|
|
63
|
+
setStorage(null);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}, [notifyError]);
|
|
67
|
+
|
|
68
|
+
const refresh = useCallback(async (): Promise<StorageInterface | null> => {
|
|
69
|
+
if (!initializingRef.current) {
|
|
70
|
+
initializingRef.current = createStorageInstance().finally(() => {
|
|
71
|
+
initializingRef.current = null;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return initializingRef.current;
|
|
76
|
+
}, [createStorageInstance]);
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
refresh().catch((err) => {
|
|
80
|
+
notifyError(err);
|
|
81
|
+
});
|
|
82
|
+
}, [refresh, notifyError]);
|
|
83
|
+
|
|
84
|
+
const withStorage = useCallback(
|
|
85
|
+
async <T,>(callback: (resolvedStorage: StorageInterface) => Promise<T>): Promise<T | null> => {
|
|
86
|
+
const resolvedStorage = storage ?? (await refresh());
|
|
87
|
+
if (!resolvedStorage) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return callback(resolvedStorage);
|
|
91
|
+
},
|
|
92
|
+
[refresh, storage],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
storage,
|
|
97
|
+
isReady: Boolean(storage) && !error,
|
|
98
|
+
error,
|
|
99
|
+
refresh,
|
|
100
|
+
withStorage,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
|
package/src/ui/hooks/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useFollow, useFollowerCounts } from './useFollow';
|
|
2
2
|
export { useFileDownloadUrl, setOxyFileUrlInstance } from './useFileDownloadUrl';
|
|
3
3
|
export { useThemeStyles } from './useThemeStyles';
|
|
4
|
-
export { useThemeColors } from './useThemeColors';
|
|
5
|
-
export * from './auth';
|
|
4
|
+
export { useThemeColors } from './useThemeColors';
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import type { User } from '../../../models/interfaces';
|
|
3
|
+
import type { ClientSession } from '../../../models/session';
|
|
3
4
|
import { queryKeys, invalidateAccountQueries, invalidateUserQueries } from '../queries/queryKeys';
|
|
4
5
|
import { useOxy } from '../../context/OxyContext';
|
|
5
6
|
import { toast } from '../../../lib/sonner';
|
|
6
7
|
import { refreshAvatarInStore } from '../../utils/avatarUtils';
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
const getDeviceIdForSession = (sessions: ClientSession[] = [], sessionId: string | null) =>
|
|
10
|
+
sessionId ? sessions.find((s) => s.sessionId === sessionId)?.deviceId : undefined;
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Update user profile with optimistic updates and offline queue support
|
|
11
14
|
*/
|
|
12
15
|
export const useUpdateProfile = () => {
|
|
13
|
-
const { oxyServices, activeSessionId, user, syncIdentity } = useOxy();
|
|
16
|
+
const { oxyServices, activeSessionId, user, syncIdentity, sessions } = useOxy();
|
|
14
17
|
const queryClient = useQueryClient();
|
|
15
18
|
|
|
16
19
|
return useMutation({
|
|
@@ -19,7 +22,7 @@ export const useUpdateProfile = () => {
|
|
|
19
22
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
20
23
|
try {
|
|
21
24
|
// Try to get token for the session
|
|
22
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
25
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
23
26
|
} catch (tokenError) {
|
|
24
27
|
// If getting token fails, might be an offline session - try syncing
|
|
25
28
|
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
@@ -27,7 +30,7 @@ export const useUpdateProfile = () => {
|
|
|
27
30
|
try {
|
|
28
31
|
await syncIdentity();
|
|
29
32
|
// Retry getting token after sync
|
|
30
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
33
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
31
34
|
} catch (syncError) {
|
|
32
35
|
throw new Error('Session needs to be synced. Please try again.');
|
|
33
36
|
}
|
|
@@ -49,7 +52,7 @@ export const useUpdateProfile = () => {
|
|
|
49
52
|
if (activeSessionId) {
|
|
50
53
|
try {
|
|
51
54
|
await syncIdentity();
|
|
52
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
55
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
53
56
|
// Retry the update after getting token
|
|
54
57
|
return await oxyServices.updateProfile(updates);
|
|
55
58
|
} catch (retryError) {
|
|
@@ -108,9 +111,6 @@ export const useUpdateProfile = () => {
|
|
|
108
111
|
queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
// Update authStore so frontend components see the changes immediately
|
|
112
|
-
useAuthStore.getState().setUser(data);
|
|
113
|
-
|
|
114
114
|
// If avatar was updated, refresh accountStore with cache-busted URL
|
|
115
115
|
if (updates.avatar && activeSessionId && oxyServices) {
|
|
116
116
|
refreshAvatarInStore(activeSessionId, updates.avatar, oxyServices);
|
|
@@ -127,7 +127,7 @@ export const useUpdateProfile = () => {
|
|
|
127
127
|
* Upload avatar with progress tracking and offline queue support
|
|
128
128
|
*/
|
|
129
129
|
export const useUploadAvatar = () => {
|
|
130
|
-
const { oxyServices, activeSessionId, syncIdentity } = useOxy();
|
|
130
|
+
const { oxyServices, activeSessionId, syncIdentity, sessions } = useOxy();
|
|
131
131
|
const queryClient = useQueryClient();
|
|
132
132
|
|
|
133
133
|
return useMutation({
|
|
@@ -135,13 +135,13 @@ export const useUploadAvatar = () => {
|
|
|
135
135
|
// Ensure we have a valid token before making the request
|
|
136
136
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
137
137
|
try {
|
|
138
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
138
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
139
139
|
} catch (tokenError) {
|
|
140
140
|
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
141
141
|
if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
|
|
142
142
|
try {
|
|
143
143
|
await syncIdentity();
|
|
144
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
144
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
145
145
|
} catch (syncError) {
|
|
146
146
|
throw new Error('Session needs to be synced. Please try again.');
|
|
147
147
|
}
|
|
@@ -171,7 +171,7 @@ export const useUploadAvatar = () => {
|
|
|
171
171
|
if (activeSessionId) {
|
|
172
172
|
try {
|
|
173
173
|
await syncIdentity();
|
|
174
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
174
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
175
175
|
// Retry upload
|
|
176
176
|
const uploadResult = await oxyServices.assetUpload(file as any, 'public');
|
|
177
177
|
const fileId = uploadResult?.file?.id || uploadResult?.id || uploadResult;
|
|
@@ -224,9 +224,6 @@ export const useUploadAvatar = () => {
|
|
|
224
224
|
queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
// Update authStore so frontend components see the changes immediately
|
|
228
|
-
useAuthStore.getState().setUser(data);
|
|
229
|
-
|
|
230
227
|
// Refresh accountStore with cache-busted URL if avatar was updated
|
|
231
228
|
if (data?.avatar && activeSessionId && oxyServices) {
|
|
232
229
|
refreshAvatarInStore(activeSessionId, data.avatar, oxyServices);
|
|
@@ -276,9 +273,6 @@ export const useUpdateAccountSettings = () => {
|
|
|
276
273
|
onSuccess: (data) => {
|
|
277
274
|
queryClient.setQueryData(queryKeys.accounts.current(), data);
|
|
278
275
|
|
|
279
|
-
// Update authStore so frontend components see the changes immediately
|
|
280
|
-
useAuthStore.getState().setUser(data);
|
|
281
|
-
|
|
282
276
|
invalidateAccountQueries(queryClient);
|
|
283
277
|
toast.success('Settings updated successfully');
|
|
284
278
|
},
|
|
@@ -292,7 +286,7 @@ export const useUpdateAccountSettings = () => {
|
|
|
292
286
|
* Update privacy settings with optimistic updates and authentication handling
|
|
293
287
|
*/
|
|
294
288
|
export const useUpdatePrivacySettings = () => {
|
|
295
|
-
const { oxyServices, activeSessionId, syncIdentity } = useOxy();
|
|
289
|
+
const { oxyServices, activeSessionId, syncIdentity, sessions } = useOxy();
|
|
296
290
|
const queryClient = useQueryClient();
|
|
297
291
|
|
|
298
292
|
return useMutation({
|
|
@@ -308,7 +302,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
308
302
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
309
303
|
try {
|
|
310
304
|
// Try to get token for the session
|
|
311
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
305
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
312
306
|
} catch (tokenError) {
|
|
313
307
|
// If getting token fails, might be an offline session - try syncing
|
|
314
308
|
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
@@ -316,7 +310,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
316
310
|
try {
|
|
317
311
|
await syncIdentity();
|
|
318
312
|
// Retry getting token after sync
|
|
319
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
313
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
320
314
|
} catch (syncError) {
|
|
321
315
|
throw new Error('Session needs to be synced. Please try again.');
|
|
322
316
|
}
|
|
@@ -338,7 +332,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
338
332
|
if (activeSessionId) {
|
|
339
333
|
try {
|
|
340
334
|
await syncIdentity();
|
|
341
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
335
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
342
336
|
// Retry the update after getting token
|
|
343
337
|
return await oxyServices.updatePrivacySettings(settings, targetUserId);
|
|
344
338
|
} catch (retryError) {
|
|
@@ -412,9 +406,6 @@ export const useUpdatePrivacySettings = () => {
|
|
|
412
406
|
privacySettings: data,
|
|
413
407
|
};
|
|
414
408
|
queryClient.setQueryData<User>(queryKeys.accounts.current(), updatedUser);
|
|
415
|
-
|
|
416
|
-
// Update authStore so frontend components see the changes immediately
|
|
417
|
-
useAuthStore.getState().setUser(updatedUser);
|
|
418
409
|
}
|
|
419
410
|
invalidateAccountQueries(queryClient);
|
|
420
411
|
},
|
|
@@ -433,7 +424,7 @@ export const useUpdatePrivacySettings = () => {
|
|
|
433
424
|
* Upload file with authentication handling and progress tracking
|
|
434
425
|
*/
|
|
435
426
|
export const useUploadFile = () => {
|
|
436
|
-
const { oxyServices, activeSessionId, syncIdentity } = useOxy();
|
|
427
|
+
const { oxyServices, activeSessionId, syncIdentity, sessions } = useOxy();
|
|
437
428
|
|
|
438
429
|
return useMutation({
|
|
439
430
|
mutationFn: async ({
|
|
@@ -451,7 +442,7 @@ export const useUploadFile = () => {
|
|
|
451
442
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
452
443
|
try {
|
|
453
444
|
// Try to get token for the session
|
|
454
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
445
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
455
446
|
} catch (tokenError) {
|
|
456
447
|
// If getting token fails, might be an offline session - try syncing
|
|
457
448
|
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
@@ -459,7 +450,7 @@ export const useUploadFile = () => {
|
|
|
459
450
|
try {
|
|
460
451
|
await syncIdentity();
|
|
461
452
|
// Retry getting token after sync
|
|
462
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
453
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
463
454
|
} catch (syncError) {
|
|
464
455
|
throw new Error('Session needs to be synced. Please try again.');
|
|
465
456
|
}
|
|
@@ -481,7 +472,7 @@ export const useUploadFile = () => {
|
|
|
481
472
|
if (activeSessionId) {
|
|
482
473
|
try {
|
|
483
474
|
await syncIdentity();
|
|
484
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
475
|
+
await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
|
|
485
476
|
// Retry the upload after getting token
|
|
486
477
|
return await oxyServices.assetUpload(file as any, visibility, metadata, onProgress);
|
|
487
478
|
} catch (retryError) {
|
|
@@ -498,40 +489,3 @@ export const useUploadFile = () => {
|
|
|
498
489
|
},
|
|
499
490
|
});
|
|
500
491
|
};
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Unblock a user with query invalidation
|
|
504
|
-
*/
|
|
505
|
-
export const useUnblockUser = () => {
|
|
506
|
-
const { oxyServices } = useOxy();
|
|
507
|
-
const queryClient = useQueryClient();
|
|
508
|
-
|
|
509
|
-
return useMutation({
|
|
510
|
-
mutationFn: async (userId: string) => {
|
|
511
|
-
return await oxyServices.unblockUser(userId);
|
|
512
|
-
},
|
|
513
|
-
onSuccess: () => {
|
|
514
|
-
// Invalidate blocked users query to refetch the list
|
|
515
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.privacy.blocked() });
|
|
516
|
-
},
|
|
517
|
-
});
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Unrestrict a user with query invalidation
|
|
522
|
-
*/
|
|
523
|
-
export const useUnrestrictUser = () => {
|
|
524
|
-
const { oxyServices } = useOxy();
|
|
525
|
-
const queryClient = useQueryClient();
|
|
526
|
-
|
|
527
|
-
return useMutation({
|
|
528
|
-
mutationFn: async (userId: string) => {
|
|
529
|
-
return await oxyServices.unrestrictUser(userId);
|
|
530
|
-
},
|
|
531
|
-
onSuccess: () => {
|
|
532
|
-
// Invalidate restricted users query to refetch the list
|
|
533
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.privacy.restricted() });
|
|
534
|
-
},
|
|
535
|
-
});
|
|
536
|
-
};
|
|
537
|
-
|
|
@@ -53,8 +53,6 @@ export const queryKeys = {
|
|
|
53
53
|
privacy: {
|
|
54
54
|
all: ['privacy'] as const,
|
|
55
55
|
settings: (userId?: string) => [...queryKeys.privacy.all, 'settings', userId || 'current'] as const,
|
|
56
|
-
blocked: () => [...queryKeys.privacy.all, 'blocked'] as const,
|
|
57
|
-
restricted: () => [...queryKeys.privacy.all, 'restricted'] as const,
|
|
58
56
|
},
|
|
59
57
|
|
|
60
58
|
// Security activity queries
|
|
@@ -19,8 +19,8 @@ export const useUserProfile = (sessionId: string | null, options?: { enabled?: b
|
|
|
19
19
|
return await oxyServices.getUserBySession(sessionId);
|
|
20
20
|
},
|
|
21
21
|
enabled: (options?.enabled !== false) && !!sessionId,
|
|
22
|
-
staleTime:
|
|
23
|
-
gcTime:
|
|
22
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
23
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -38,8 +38,8 @@ export const useUserProfiles = (sessionIds: string[], options?: { enabled?: bool
|
|
|
38
38
|
return results[0]?.user || null;
|
|
39
39
|
},
|
|
40
40
|
enabled: (options?.enabled !== false) && !!sessionId,
|
|
41
|
-
staleTime:
|
|
42
|
-
gcTime:
|
|
41
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
42
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
43
43
|
})),
|
|
44
44
|
});
|
|
45
45
|
};
|
|
@@ -59,8 +59,8 @@ export const useCurrentUser = (options?: { enabled?: boolean }) => {
|
|
|
59
59
|
return await oxyServices.getUserBySession(activeSessionId);
|
|
60
60
|
},
|
|
61
61
|
enabled: (options?.enabled !== false) && isAuthenticated && !!activeSessionId,
|
|
62
|
-
staleTime:
|
|
63
|
-
gcTime:
|
|
62
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
63
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
|
|
@@ -79,8 +79,8 @@ export const useUserById = (userId: string | null, options?: { enabled?: boolean
|
|
|
79
79
|
return await oxyServices.getUserById(userId);
|
|
80
80
|
},
|
|
81
81
|
enabled: (options?.enabled !== false) && !!userId,
|
|
82
|
-
staleTime:
|
|
83
|
-
gcTime:
|
|
82
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
83
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
86
|
|
|
@@ -99,8 +99,8 @@ export const useUserByUsername = (username: string | null, options?: { enabled?:
|
|
|
99
99
|
return await oxyServices.getProfileByUsername(username);
|
|
100
100
|
},
|
|
101
101
|
enabled: (options?.enabled !== false) && !!username,
|
|
102
|
-
staleTime:
|
|
103
|
-
gcTime:
|
|
102
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
103
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
104
104
|
});
|
|
105
105
|
};
|
|
106
106
|
|
|
@@ -119,8 +119,8 @@ export const useUsersBySessions = (sessionIds: string[], options?: { enabled?: b
|
|
|
119
119
|
return await oxyServices.getUsersBySessions(sessionIds);
|
|
120
120
|
},
|
|
121
121
|
enabled: (options?.enabled !== false) && sessionIds.length > 0,
|
|
122
|
-
staleTime:
|
|
123
|
-
gcTime:
|
|
122
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
123
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
126
|
|
|
@@ -128,10 +128,11 @@ export const useUsersBySessions = (sessionIds: string[], options?: { enabled?: b
|
|
|
128
128
|
* Get privacy settings for a user
|
|
129
129
|
*/
|
|
130
130
|
export const usePrivacySettings = (userId?: string, options?: { enabled?: boolean }) => {
|
|
131
|
-
const { oxyServices, activeSessionId, syncIdentity } = useOxy();
|
|
131
|
+
const { oxyServices, activeSessionId, syncIdentity, sessions } = useOxy();
|
|
132
132
|
// Use getCurrentUserId() which returns MongoDB ObjectId from JWT token
|
|
133
133
|
// Never use user?.id as it may be set to publicKey
|
|
134
134
|
const targetUserId = userId || oxyServices.getCurrentUserId() || undefined;
|
|
135
|
+
const deviceId = activeSessionId ? sessions.find((s) => s.sessionId === activeSessionId)?.deviceId : undefined;
|
|
135
136
|
|
|
136
137
|
return useQuery({
|
|
137
138
|
queryKey: queryKeys.privacy.settings(targetUserId),
|
|
@@ -144,7 +145,7 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
144
145
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
145
146
|
try {
|
|
146
147
|
// Try to get token for the session
|
|
147
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
148
|
+
await oxyServices.getTokenBySession(activeSessionId, deviceId);
|
|
148
149
|
} catch (tokenError) {
|
|
149
150
|
// If getting token fails, might be an offline session - try syncing
|
|
150
151
|
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
@@ -152,7 +153,7 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
152
153
|
try {
|
|
153
154
|
await syncIdentity();
|
|
154
155
|
// Retry getting token after sync
|
|
155
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
156
|
+
await oxyServices.getTokenBySession(activeSessionId, deviceId);
|
|
156
157
|
} catch (syncError) {
|
|
157
158
|
throw new Error('Session needs to be synced. Please try again.');
|
|
158
159
|
}
|
|
@@ -174,7 +175,7 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
174
175
|
if (activeSessionId) {
|
|
175
176
|
try {
|
|
176
177
|
await syncIdentity();
|
|
177
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
178
|
+
await oxyServices.getTokenBySession(activeSessionId, deviceId);
|
|
178
179
|
// Retry the request after getting token
|
|
179
180
|
return await oxyServices.getPrivacySettings(targetUserId);
|
|
180
181
|
} catch (retryError) {
|
|
@@ -190,42 +191,7 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
|
|
|
190
191
|
}
|
|
191
192
|
},
|
|
192
193
|
enabled: (options?.enabled !== false) && !!targetUserId,
|
|
193
|
-
staleTime:
|
|
194
|
-
gcTime:
|
|
194
|
+
staleTime: 0, // Always fetch fresh - Services never caches profile
|
|
195
|
+
gcTime: 0, // No garbage collection time - always fetch fresh
|
|
195
196
|
});
|
|
196
197
|
};
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Get blocked users
|
|
200
|
-
*/
|
|
201
|
-
export const useBlockedUsers = (options?: { enabled?: boolean }) => {
|
|
202
|
-
const { oxyServices, isAuthenticated } = useOxy();
|
|
203
|
-
|
|
204
|
-
return useQuery({
|
|
205
|
-
queryKey: queryKeys.privacy.blocked(),
|
|
206
|
-
queryFn: async () => {
|
|
207
|
-
return await oxyServices.getBlockedUsers();
|
|
208
|
-
},
|
|
209
|
-
enabled: (options?.enabled !== false) && isAuthenticated,
|
|
210
|
-
staleTime: 1 * 60 * 1000, // 1 minute
|
|
211
|
-
gcTime: 5 * 60 * 1000, // 5 minutes
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Get restricted users
|
|
217
|
-
*/
|
|
218
|
-
export const useRestrictedUsers = (options?: { enabled?: boolean }) => {
|
|
219
|
-
const { oxyServices, isAuthenticated } = useOxy();
|
|
220
|
-
|
|
221
|
-
return useQuery({
|
|
222
|
-
queryKey: queryKeys.privacy.restricted(),
|
|
223
|
-
queryFn: async () => {
|
|
224
|
-
return await oxyServices.getRestrictedUsers();
|
|
225
|
-
},
|
|
226
|
-
enabled: (options?.enabled !== false) && isAuthenticated,
|
|
227
|
-
staleTime: 1 * 60 * 1000, // 1 minute
|
|
228
|
-
gcTime: 5 * 60 * 1000, // 5 minutes
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
|
|
@@ -89,7 +89,8 @@ 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, syncIdentity } = useOxy();
|
|
92
|
+
const { oxyServices, isAuthenticated, activeSessionId, syncIdentity, sessions } = useOxy();
|
|
93
|
+
const deviceId = activeSessionId ? sessions.find((s) => s.sessionId === activeSessionId)?.deviceId : undefined;
|
|
93
94
|
|
|
94
95
|
return useQuery({
|
|
95
96
|
queryKey: queryKeys.devices.list(),
|
|
@@ -98,7 +99,7 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
|
|
|
98
99
|
if (!oxyServices.hasValidToken() && activeSessionId) {
|
|
99
100
|
try {
|
|
100
101
|
// Try to get token for the session
|
|
101
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
102
|
+
await oxyServices.getTokenBySession(activeSessionId, deviceId);
|
|
102
103
|
} catch (tokenError) {
|
|
103
104
|
// If getting token fails, might be an offline session - try syncing
|
|
104
105
|
const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
|
|
@@ -106,7 +107,7 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
|
|
|
106
107
|
try {
|
|
107
108
|
await syncIdentity();
|
|
108
109
|
// Retry getting token after sync
|
|
109
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
110
|
+
await oxyServices.getTokenBySession(activeSessionId, deviceId);
|
|
110
111
|
} catch (syncError) {
|
|
111
112
|
throw new Error('Session needs to be synced. Please try again.');
|
|
112
113
|
}
|
|
@@ -128,7 +129,7 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
|
|
|
128
129
|
if (activeSessionId) {
|
|
129
130
|
try {
|
|
130
131
|
await syncIdentity();
|
|
131
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
132
|
+
await oxyServices.getTokenBySession(activeSessionId, deviceId);
|
|
132
133
|
// Retry the request after getting token
|
|
133
134
|
return await oxyServices.getUserDevices();
|
|
134
135
|
} catch (retryError) {
|
|
@@ -165,4 +166,3 @@ export const useSecurityInfo = (options?: { enabled?: boolean }) => {
|
|
|
165
166
|
gcTime: 30 * 60 * 1000,
|
|
166
167
|
});
|
|
167
168
|
};
|
|
168
|
-
|