@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,551 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAuthOperations = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _deviceManager = require("../../../utils/deviceManager");
|
|
9
|
+
var _sessionHelpers = require("../../utils/sessionHelpers");
|
|
10
|
+
var _errorHandlers = require("../../utils/errorHandlers");
|
|
11
|
+
var _crypto = require("../../../crypto");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
const LOGIN_ERROR_CODE = 'LOGIN_ERROR';
|
|
14
|
+
const REGISTER_ERROR_CODE = 'REGISTER_ERROR';
|
|
15
|
+
const LOGOUT_ERROR_CODE = 'LOGOUT_ERROR';
|
|
16
|
+
const LOGOUT_ALL_ERROR_CODE = 'LOGOUT_ALL_ERROR';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Authentication operations using public key cryptography.
|
|
20
|
+
* No passwords required - identity is based on ECDSA key pairs.
|
|
21
|
+
*/
|
|
22
|
+
const useAuthOperations = ({
|
|
23
|
+
oxyServices,
|
|
24
|
+
storage,
|
|
25
|
+
sessions,
|
|
26
|
+
activeSessionId,
|
|
27
|
+
setActiveSessionId,
|
|
28
|
+
updateSessions,
|
|
29
|
+
saveActiveSessionId,
|
|
30
|
+
clearSessionState,
|
|
31
|
+
switchSession,
|
|
32
|
+
applyLanguagePreference,
|
|
33
|
+
onAuthStateChange,
|
|
34
|
+
onError,
|
|
35
|
+
loginSuccess,
|
|
36
|
+
loginFailure,
|
|
37
|
+
logoutStore,
|
|
38
|
+
setAuthState,
|
|
39
|
+
setIdentitySynced,
|
|
40
|
+
setSyncing,
|
|
41
|
+
logger
|
|
42
|
+
}) => {
|
|
43
|
+
/**
|
|
44
|
+
* Internal function to perform challenge-response sign in (works offline)
|
|
45
|
+
*/
|
|
46
|
+
const performSignIn = (0, _react.useCallback)(async publicKey => {
|
|
47
|
+
const deviceFingerprintObj = _deviceManager.DeviceManager.getDeviceFingerprint();
|
|
48
|
+
const deviceFingerprint = JSON.stringify(deviceFingerprintObj);
|
|
49
|
+
const deviceInfo = await _deviceManager.DeviceManager.getDeviceInfo();
|
|
50
|
+
const deviceName = deviceInfo.deviceName || _deviceManager.DeviceManager.getDefaultDeviceName();
|
|
51
|
+
const USER_ID_STORAGE_KEY = 'oxy_user_id';
|
|
52
|
+
|
|
53
|
+
// Online-only sign-in: require backend availability
|
|
54
|
+
// First, resolve userId (prefer locally stored value)
|
|
55
|
+
let userId = null;
|
|
56
|
+
if (storage) {
|
|
57
|
+
userId = await storage.getItem(USER_ID_STORAGE_KEY);
|
|
58
|
+
}
|
|
59
|
+
if (!userId) {
|
|
60
|
+
const userLookup = await oxyServices.getUserByPublicKey(publicKey);
|
|
61
|
+
userId = userLookup.id;
|
|
62
|
+
if (storage && userId) {
|
|
63
|
+
await storage.setItem(USER_ID_STORAGE_KEY, userId).catch(() => {});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const challengeResponse = await oxyServices.requestChallenge(userId);
|
|
67
|
+
const challenge = challengeResponse.challenge;
|
|
68
|
+
|
|
69
|
+
// Note: Biometric authentication check should be handled by the app layer
|
|
70
|
+
// (e.g., accounts app) before calling signIn. The biometric preference is stored
|
|
71
|
+
// in local storage as 'oxy_biometric_enabled' and can be checked there.
|
|
72
|
+
|
|
73
|
+
// Sign the challenge
|
|
74
|
+
const {
|
|
75
|
+
challenge: signature,
|
|
76
|
+
timestamp
|
|
77
|
+
} = await _crypto.SignatureService.signChallenge(challenge);
|
|
78
|
+
|
|
79
|
+
// Online sign-in: use normal flow
|
|
80
|
+
if (!userId) {
|
|
81
|
+
throw new Error('User ID not found');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Verify and create session using userId
|
|
85
|
+
const sessionResponse = await oxyServices.verifyChallenge(userId, challenge, signature, timestamp, deviceName, deviceFingerprint);
|
|
86
|
+
|
|
87
|
+
// Store tokens immediately (no extra round-trip)
|
|
88
|
+
oxyServices.setTokens(sessionResponse.accessToken, sessionResponse.refreshToken);
|
|
89
|
+
|
|
90
|
+
// Get full user data
|
|
91
|
+
const fullUser = await oxyServices.getUserBySession(sessionResponse.sessionId);
|
|
92
|
+
|
|
93
|
+
// IMPORTANT: user.id should be MongoDB ObjectId, not publicKey
|
|
94
|
+
// The API should return the correct id (ObjectId) from the database
|
|
95
|
+
// If it doesn't, we need to fix the API, not work around it here
|
|
96
|
+
// Validate that id is ObjectId format (24 hex characters)
|
|
97
|
+
if (fullUser.id && !/^[0-9a-fA-F]{24}$/.test(fullUser.id)) {
|
|
98
|
+
console.warn('[useAuthOperations] User.id is not MongoDB ObjectId format:', {
|
|
99
|
+
id: fullUser.id.substring(0, 20),
|
|
100
|
+
publicKey: fullUser.publicKey.substring(0, 20),
|
|
101
|
+
message: 'API should return MongoDB ObjectId as user.id, not publicKey'
|
|
102
|
+
});
|
|
103
|
+
// Don't override - let the API fix this issue
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Fetch device sessions
|
|
107
|
+
let allDeviceSessions = [];
|
|
108
|
+
try {
|
|
109
|
+
allDeviceSessions = await (0, _sessionHelpers.fetchSessionsWithFallback)(oxyServices, sessionResponse.sessionId, {
|
|
110
|
+
fallbackDeviceId: sessionResponse.deviceId,
|
|
111
|
+
fallbackUserId: fullUser.id,
|
|
112
|
+
logger
|
|
113
|
+
});
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (__DEV__) {
|
|
116
|
+
console.warn('Failed to fetch device sessions after login:', error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Check for existing session for same user
|
|
121
|
+
const existingSession = allDeviceSessions.find(session => session.userId?.toString() === fullUser.id?.toString() && session.sessionId !== sessionResponse.sessionId);
|
|
122
|
+
if (existingSession) {
|
|
123
|
+
// Logout duplicate session
|
|
124
|
+
try {
|
|
125
|
+
await oxyServices.logoutSession(sessionResponse.sessionId, sessionResponse.sessionId);
|
|
126
|
+
} catch (logoutError) {
|
|
127
|
+
if (__DEV__) {
|
|
128
|
+
console.warn('Failed to logout duplicate session:', logoutError);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
await switchSession(existingSession.sessionId);
|
|
132
|
+
updateSessions(allDeviceSessions.filter(session => session.sessionId !== sessionResponse.sessionId), {
|
|
133
|
+
merge: false
|
|
134
|
+
});
|
|
135
|
+
onAuthStateChange?.(fullUser);
|
|
136
|
+
return fullUser;
|
|
137
|
+
}
|
|
138
|
+
setActiveSessionId(sessionResponse.sessionId);
|
|
139
|
+
await saveActiveSessionId(sessionResponse.sessionId);
|
|
140
|
+
updateSessions(allDeviceSessions, {
|
|
141
|
+
merge: true
|
|
142
|
+
});
|
|
143
|
+
await applyLanguagePreference(fullUser);
|
|
144
|
+
loginSuccess(); // Services never caches profile - only tokens
|
|
145
|
+
onAuthStateChange?.(fullUser);
|
|
146
|
+
if (storage) {
|
|
147
|
+
await storage.setItem('oxy_identity_synced', 'true').catch(() => {});
|
|
148
|
+
}
|
|
149
|
+
setIdentitySynced(true);
|
|
150
|
+
return fullUser;
|
|
151
|
+
}, [applyLanguagePreference, logger, loginSuccess, onAuthStateChange, oxyServices, saveActiveSessionId, setActiveSessionId, setIdentitySynced, switchSession, updateSessions, storage]);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Create a new identity (offline-first)
|
|
155
|
+
* Identity is purely cryptographic - no username or email required
|
|
156
|
+
*/
|
|
157
|
+
const createIdentity = (0, _react.useCallback)(async () => {
|
|
158
|
+
if (!storage) throw new Error('Storage not initialized');
|
|
159
|
+
setAuthState({
|
|
160
|
+
isLoading: true,
|
|
161
|
+
error: null
|
|
162
|
+
});
|
|
163
|
+
try {
|
|
164
|
+
// Generate new key pair directly (works offline)
|
|
165
|
+
const {
|
|
166
|
+
publicKey,
|
|
167
|
+
privateKey
|
|
168
|
+
} = await _crypto.KeyManager.generateKeyPair();
|
|
169
|
+
await _crypto.KeyManager.importKeyPair(privateKey);
|
|
170
|
+
|
|
171
|
+
// Mark as not synced
|
|
172
|
+
// Note: createIdentity only creates the key locally (offline-first)
|
|
173
|
+
// Registration with server (registerIdentity) must be done by the app (Accounts) with profile data
|
|
174
|
+
await storage.setItem('oxy_identity_synced', 'false');
|
|
175
|
+
setIdentitySynced(false);
|
|
176
|
+
return {
|
|
177
|
+
synced: false // Always false - registration must be done separately by Accounts app
|
|
178
|
+
};
|
|
179
|
+
} catch (error) {
|
|
180
|
+
// CRITICAL: Never delete identity on error - it may have been successfully created
|
|
181
|
+
// Only log the error and let the user recover using their backup file
|
|
182
|
+
// Identity deletion should ONLY happen when explicitly requested by the user
|
|
183
|
+
if (__DEV__ && logger) {
|
|
184
|
+
logger('Error during identity creation (identity may still exist):', error);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Check if identity was actually created (keys exist)
|
|
188
|
+
const hasIdentity = await _crypto.KeyManager.hasIdentity().catch(() => false);
|
|
189
|
+
if (hasIdentity) {
|
|
190
|
+
// Identity exists - don't delete it! Just mark as not synced
|
|
191
|
+
await storage.setItem('oxy_identity_synced', 'false').catch(() => {});
|
|
192
|
+
setIdentitySynced(false);
|
|
193
|
+
if (__DEV__ && logger) {
|
|
194
|
+
logger('Identity was created but sync failed - user can sync later using backup file');
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
// No identity exists - this was a generation failure, safe to clean up sync flag
|
|
198
|
+
await storage.removeItem('oxy_identity_synced').catch(() => {});
|
|
199
|
+
setIdentitySynced(false);
|
|
200
|
+
}
|
|
201
|
+
const message = (0, _errorHandlers.handleAuthError)(error, {
|
|
202
|
+
defaultMessage: 'Failed to create identity',
|
|
203
|
+
code: REGISTER_ERROR_CODE,
|
|
204
|
+
onError,
|
|
205
|
+
setAuthError: msg => setAuthState({
|
|
206
|
+
error: msg
|
|
207
|
+
}),
|
|
208
|
+
logger
|
|
209
|
+
});
|
|
210
|
+
loginFailure(message);
|
|
211
|
+
throw error;
|
|
212
|
+
} finally {
|
|
213
|
+
setAuthState({
|
|
214
|
+
isLoading: false
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}, [oxyServices, storage, setAuthState, loginFailure, onError, logger, setIdentitySynced]);
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Check if identity is synced with server (reads from storage for persistence)
|
|
221
|
+
*/
|
|
222
|
+
const isIdentitySyncedFn = (0, _react.useCallback)(async () => {
|
|
223
|
+
if (!storage) return true;
|
|
224
|
+
const synced = await storage.getItem('oxy_identity_synced');
|
|
225
|
+
const isSynced = synced !== 'false';
|
|
226
|
+
setIdentitySynced(isSynced);
|
|
227
|
+
return isSynced;
|
|
228
|
+
}, [storage, setIdentitySynced]);
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Sync local identity with server (call when online)
|
|
232
|
+
* TanStack Query handles offline mutations automatically
|
|
233
|
+
*/
|
|
234
|
+
const syncIdentity = (0, _react.useCallback)(async () => {
|
|
235
|
+
if (!storage) throw new Error('Storage not initialized');
|
|
236
|
+
setAuthState({
|
|
237
|
+
isLoading: true,
|
|
238
|
+
error: null
|
|
239
|
+
});
|
|
240
|
+
setSyncing(true);
|
|
241
|
+
try {
|
|
242
|
+
const publicKey = await _crypto.KeyManager.getPublicKey();
|
|
243
|
+
if (!publicKey) {
|
|
244
|
+
throw new Error('No identity found on this device');
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Check if already synced
|
|
248
|
+
const alreadySynced = await storage.getItem('oxy_identity_synced');
|
|
249
|
+
if (alreadySynced === 'true') {
|
|
250
|
+
setIdentitySynced(true);
|
|
251
|
+
return await performSignIn(publicKey);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Check if already registered on server
|
|
255
|
+
const {
|
|
256
|
+
registered
|
|
257
|
+
} = await oxyServices.checkPublicKeyRegistered(publicKey);
|
|
258
|
+
if (!registered) {
|
|
259
|
+
// Identity is not registered - registration must be done by Accounts app with profile data
|
|
260
|
+
// syncIdentity only syncs already-registered identities
|
|
261
|
+
throw new Error('Identity is not registered. Please register your identity first using the Accounts app.');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Mark as synced (Zustand store + storage)
|
|
265
|
+
await storage.setItem('oxy_identity_synced', 'true');
|
|
266
|
+
setIdentitySynced(true);
|
|
267
|
+
|
|
268
|
+
// Sign in (Services never caches profile - only tokens)
|
|
269
|
+
const user = await performSignIn(publicKey);
|
|
270
|
+
|
|
271
|
+
// Check if user has username - required for syncing
|
|
272
|
+
if (!user.username) {
|
|
273
|
+
const usernameError = new Error('USERNAME_REQUIRED');
|
|
274
|
+
usernameError.code = 'USERNAME_REQUIRED';
|
|
275
|
+
throw usernameError;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// TanStack Query will automatically retry any pending mutations
|
|
279
|
+
|
|
280
|
+
return user;
|
|
281
|
+
} catch (error) {
|
|
282
|
+
const message = (0, _errorHandlers.handleAuthError)(error, {
|
|
283
|
+
defaultMessage: 'Failed to sync identity',
|
|
284
|
+
code: REGISTER_ERROR_CODE,
|
|
285
|
+
onError,
|
|
286
|
+
setAuthError: msg => setAuthState({
|
|
287
|
+
error: msg
|
|
288
|
+
}),
|
|
289
|
+
logger
|
|
290
|
+
});
|
|
291
|
+
loginFailure(message);
|
|
292
|
+
throw error;
|
|
293
|
+
} finally {
|
|
294
|
+
setAuthState({
|
|
295
|
+
isLoading: false
|
|
296
|
+
});
|
|
297
|
+
setSyncing(false);
|
|
298
|
+
}
|
|
299
|
+
}, [oxyServices, storage, setAuthState, performSignIn, loginFailure, onError, logger, setSyncing, setIdentitySynced]);
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Import identity from backup file data (offline-first)
|
|
303
|
+
*/
|
|
304
|
+
const importIdentity = (0, _react.useCallback)(async (backupData, password) => {
|
|
305
|
+
if (!storage) throw new Error('Storage not initialized');
|
|
306
|
+
|
|
307
|
+
// Validate arguments - ensure backupData is an object, not a string (old signature)
|
|
308
|
+
if (!backupData || typeof backupData !== 'object' || Array.isArray(backupData)) {
|
|
309
|
+
throw new Error('Invalid backup data. Please use the backup file import feature.');
|
|
310
|
+
}
|
|
311
|
+
if (!backupData.encrypted || !backupData.salt || !backupData.iv || !backupData.publicKey) {
|
|
312
|
+
throw new Error('Invalid backup data structure. Missing required fields.');
|
|
313
|
+
}
|
|
314
|
+
if (!password || typeof password !== 'string') {
|
|
315
|
+
throw new Error('Password is required for backup file import.');
|
|
316
|
+
}
|
|
317
|
+
setAuthState({
|
|
318
|
+
isLoading: true,
|
|
319
|
+
error: null
|
|
320
|
+
});
|
|
321
|
+
try {
|
|
322
|
+
// Decrypt private key from backup data
|
|
323
|
+
const Crypto = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-crypto')));
|
|
324
|
+
|
|
325
|
+
// Convert hex strings to Uint8Array
|
|
326
|
+
const saltBytes = new Uint8Array(backupData.salt.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []);
|
|
327
|
+
const ivBytes = new Uint8Array(backupData.iv.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []);
|
|
328
|
+
|
|
329
|
+
// Derive key from password (same algorithm as EncryptedBackupGenerator)
|
|
330
|
+
const saltHex = Array.from(saltBytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
331
|
+
let key = password + saltHex;
|
|
332
|
+
for (let i = 0; i < 10000; i++) {
|
|
333
|
+
key = await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, key);
|
|
334
|
+
}
|
|
335
|
+
const keyBytes = new Uint8Array(32);
|
|
336
|
+
for (let i = 0; i < 64 && i < key.length; i += 2) {
|
|
337
|
+
keyBytes[i / 2] = parseInt(key.substring(i, i + 2), 16);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Decrypt private key (XOR decryption - same as encryption)
|
|
341
|
+
const encryptedBytes = Buffer.from(backupData.encrypted, 'base64');
|
|
342
|
+
const decryptedBytes = new Uint8Array(encryptedBytes.length);
|
|
343
|
+
for (let i = 0; i < encryptedBytes.length; i++) {
|
|
344
|
+
decryptedBytes[i] = encryptedBytes[i] ^ keyBytes[i % keyBytes.length] ^ ivBytes[i % ivBytes.length];
|
|
345
|
+
}
|
|
346
|
+
const privateKey = new TextDecoder().decode(decryptedBytes);
|
|
347
|
+
|
|
348
|
+
// Import the key pair
|
|
349
|
+
const publicKey = await _crypto.KeyManager.importKeyPair(privateKey);
|
|
350
|
+
|
|
351
|
+
// Verify public key matches
|
|
352
|
+
if (publicKey !== backupData.publicKey) {
|
|
353
|
+
throw new Error('Backup file is corrupted or password is incorrect');
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Mark as not synced
|
|
357
|
+
await storage.setItem('oxy_identity_synced', 'false');
|
|
358
|
+
setIdentitySynced(false);
|
|
359
|
+
|
|
360
|
+
// Try to sync with server
|
|
361
|
+
try {
|
|
362
|
+
// Check if this identity is already registered
|
|
363
|
+
const {
|
|
364
|
+
registered
|
|
365
|
+
} = await oxyServices.checkPublicKeyRegistered(publicKey);
|
|
366
|
+
if (registered) {
|
|
367
|
+
// Identity exists, mark as synced
|
|
368
|
+
await storage.setItem('oxy_identity_synced', 'true');
|
|
369
|
+
setIdentitySynced(true);
|
|
370
|
+
return {
|
|
371
|
+
synced: true
|
|
372
|
+
};
|
|
373
|
+
} else {
|
|
374
|
+
// Identity is not registered - registration must be done by Accounts app with profile data
|
|
375
|
+
// importIdentity only imports already-registered identities
|
|
376
|
+
await storage.setItem('oxy_identity_synced', 'false');
|
|
377
|
+
setIdentitySynced(false);
|
|
378
|
+
return {
|
|
379
|
+
synced: false
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
} catch (syncError) {
|
|
383
|
+
// Offline - identity restored locally but not synced
|
|
384
|
+
if (__DEV__) {
|
|
385
|
+
console.log('[Auth] Identity imported locally, will sync when online:', syncError);
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
synced: false
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
} catch (error) {
|
|
392
|
+
const message = (0, _errorHandlers.handleAuthError)(error, {
|
|
393
|
+
defaultMessage: 'Failed to import identity. Please check your password and backup file.',
|
|
394
|
+
code: REGISTER_ERROR_CODE,
|
|
395
|
+
onError,
|
|
396
|
+
setAuthError: msg => setAuthState({
|
|
397
|
+
error: msg
|
|
398
|
+
}),
|
|
399
|
+
logger
|
|
400
|
+
});
|
|
401
|
+
loginFailure(message);
|
|
402
|
+
throw error;
|
|
403
|
+
} finally {
|
|
404
|
+
setAuthState({
|
|
405
|
+
isLoading: false
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}, [oxyServices, storage, setAuthState, loginFailure, onError, logger, setIdentitySynced]);
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Sign in with existing identity on device
|
|
412
|
+
*/
|
|
413
|
+
const signIn = (0, _react.useCallback)(async deviceName => {
|
|
414
|
+
if (!storage) throw new Error('Storage not initialized');
|
|
415
|
+
setAuthState({
|
|
416
|
+
isLoading: true,
|
|
417
|
+
error: null
|
|
418
|
+
});
|
|
419
|
+
try {
|
|
420
|
+
// Get stored public key
|
|
421
|
+
const publicKey = await _crypto.KeyManager.getPublicKey();
|
|
422
|
+
if (!publicKey) {
|
|
423
|
+
throw new Error('No identity found on this device. Please create or import an identity.');
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Ensure identity is registered before attempting sign-in
|
|
427
|
+
const {
|
|
428
|
+
registered
|
|
429
|
+
} = await oxyServices.checkPublicKeyRegistered(publicKey);
|
|
430
|
+
if (!registered) {
|
|
431
|
+
throw new Error('Identity is not registered. Please register your identity in the Accounts app before signing in.');
|
|
432
|
+
}
|
|
433
|
+
return await performSignIn(publicKey);
|
|
434
|
+
} catch (error) {
|
|
435
|
+
const message = (0, _errorHandlers.handleAuthError)(error, {
|
|
436
|
+
defaultMessage: 'Sign in failed',
|
|
437
|
+
code: LOGIN_ERROR_CODE,
|
|
438
|
+
onError,
|
|
439
|
+
setAuthError: msg => setAuthState({
|
|
440
|
+
error: msg
|
|
441
|
+
}),
|
|
442
|
+
logger
|
|
443
|
+
});
|
|
444
|
+
loginFailure(message);
|
|
445
|
+
throw error;
|
|
446
|
+
} finally {
|
|
447
|
+
setAuthState({
|
|
448
|
+
isLoading: false
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
}, [storage, setAuthState, performSignIn, loginFailure, onError, logger, oxyServices]);
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Logout from session
|
|
455
|
+
*/
|
|
456
|
+
const logout = (0, _react.useCallback)(async targetSessionId => {
|
|
457
|
+
if (!activeSessionId) return;
|
|
458
|
+
try {
|
|
459
|
+
const sessionToLogout = targetSessionId || activeSessionId;
|
|
460
|
+
await oxyServices.logoutSession(activeSessionId, sessionToLogout);
|
|
461
|
+
const filteredSessions = sessions.filter(session => session.sessionId !== sessionToLogout);
|
|
462
|
+
updateSessions(filteredSessions, {
|
|
463
|
+
merge: false
|
|
464
|
+
});
|
|
465
|
+
if (sessionToLogout === activeSessionId) {
|
|
466
|
+
if (filteredSessions.length > 0) {
|
|
467
|
+
await switchSession(filteredSessions[0].sessionId);
|
|
468
|
+
} else {
|
|
469
|
+
await clearSessionState();
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
} catch (error) {
|
|
474
|
+
const isInvalid = (0, _errorHandlers.isInvalidSessionError)(error);
|
|
475
|
+
if (isInvalid && targetSessionId === activeSessionId) {
|
|
476
|
+
await clearSessionState();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
(0, _errorHandlers.handleAuthError)(error, {
|
|
480
|
+
defaultMessage: 'Logout failed',
|
|
481
|
+
code: LOGOUT_ERROR_CODE,
|
|
482
|
+
onError,
|
|
483
|
+
setAuthError: msg => setAuthState({
|
|
484
|
+
error: msg
|
|
485
|
+
}),
|
|
486
|
+
logger,
|
|
487
|
+
status: isInvalid ? 401 : undefined
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}, [activeSessionId, clearSessionState, logger, onError, oxyServices, sessions, setAuthState, switchSession, updateSessions]);
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Logout from all sessions
|
|
494
|
+
*/
|
|
495
|
+
const logoutAll = (0, _react.useCallback)(async () => {
|
|
496
|
+
if (!activeSessionId) {
|
|
497
|
+
const error = new Error('No active session found');
|
|
498
|
+
setAuthState({
|
|
499
|
+
error: error.message
|
|
500
|
+
});
|
|
501
|
+
onError?.({
|
|
502
|
+
message: error.message,
|
|
503
|
+
code: LOGOUT_ALL_ERROR_CODE,
|
|
504
|
+
status: 404
|
|
505
|
+
});
|
|
506
|
+
throw error;
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
await oxyServices.logoutAllSessions(activeSessionId);
|
|
510
|
+
await clearSessionState();
|
|
511
|
+
} catch (error) {
|
|
512
|
+
(0, _errorHandlers.handleAuthError)(error, {
|
|
513
|
+
defaultMessage: 'Logout all failed',
|
|
514
|
+
code: LOGOUT_ALL_ERROR_CODE,
|
|
515
|
+
onError,
|
|
516
|
+
setAuthError: msg => setAuthState({
|
|
517
|
+
error: msg
|
|
518
|
+
}),
|
|
519
|
+
logger
|
|
520
|
+
});
|
|
521
|
+
throw error instanceof Error ? error : new Error('Logout all failed');
|
|
522
|
+
}
|
|
523
|
+
}, [activeSessionId, clearSessionState, logger, onError, oxyServices, setAuthState]);
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Check if device has an identity stored
|
|
527
|
+
*/
|
|
528
|
+
const hasIdentity = (0, _react.useCallback)(async () => {
|
|
529
|
+
return _crypto.KeyManager.hasIdentity();
|
|
530
|
+
}, []);
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Get the public key of the stored identity
|
|
534
|
+
*/
|
|
535
|
+
const getPublicKey = (0, _react.useCallback)(async () => {
|
|
536
|
+
return _crypto.KeyManager.getPublicKey();
|
|
537
|
+
}, []);
|
|
538
|
+
return {
|
|
539
|
+
createIdentity,
|
|
540
|
+
importIdentity,
|
|
541
|
+
signIn,
|
|
542
|
+
logout,
|
|
543
|
+
logoutAll,
|
|
544
|
+
hasIdentity,
|
|
545
|
+
getPublicKey,
|
|
546
|
+
isIdentitySynced: isIdentitySyncedFn,
|
|
547
|
+
syncIdentity
|
|
548
|
+
};
|
|
549
|
+
};
|
|
550
|
+
exports.useAuthOperations = useAuthOperations;
|
|
551
|
+
//# sourceMappingURL=useAuthOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_deviceManager","_sessionHelpers","_errorHandlers","_crypto","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","LOGIN_ERROR_CODE","REGISTER_ERROR_CODE","LOGOUT_ERROR_CODE","LOGOUT_ALL_ERROR_CODE","useAuthOperations","oxyServices","storage","sessions","activeSessionId","setActiveSessionId","updateSessions","saveActiveSessionId","clearSessionState","switchSession","applyLanguagePreference","onAuthStateChange","onError","loginSuccess","loginFailure","logoutStore","setAuthState","setIdentitySynced","setSyncing","logger","performSignIn","useCallback","publicKey","deviceFingerprintObj","DeviceManager","getDeviceFingerprint","deviceFingerprint","JSON","stringify","deviceInfo","getDeviceInfo","deviceName","getDefaultDeviceName","USER_ID_STORAGE_KEY","userId","getItem","userLookup","getUserByPublicKey","id","setItem","catch","challengeResponse","requestChallenge","challenge","signature","timestamp","SignatureService","signChallenge","Error","sessionResponse","verifyChallenge","setTokens","accessToken","refreshToken","fullUser","getUserBySession","sessionId","test","console","warn","substring","message","allDeviceSessions","fetchSessionsWithFallback","fallbackDeviceId","deviceId","fallbackUserId","error","__DEV__","existingSession","find","session","toString","logoutSession","logoutError","filter","merge","createIdentity","isLoading","privateKey","KeyManager","generateKeyPair","importKeyPair","synced","hasIdentity","removeItem","handleAuthError","defaultMessage","code","setAuthError","msg","isIdentitySyncedFn","isSynced","syncIdentity","getPublicKey","alreadySynced","registered","checkPublicKeyRegistered","user","username","usernameError","importIdentity","backupData","password","Array","isArray","encrypted","salt","iv","Crypto","Promise","resolve","then","saltBytes","Uint8Array","match","map","byte","parseInt","ivBytes","saltHex","from","b","padStart","join","key","digestStringAsync","CryptoDigestAlgorithm","SHA256","keyBytes","length","encryptedBytes","Buffer","decryptedBytes","TextDecoder","decode","syncError","log","signIn","logout","targetSessionId","sessionToLogout","filteredSessions","isInvalid","isInvalidSessionError","status","undefined","logoutAll","logoutAllSessions","isIdentitySynced","exports"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useAuthOperations.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAGA,IAAAI,OAAA,GAAAJ,OAAA;AAAgF,SAAAK,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EA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E,MAAMoE,WAAW,GAAG,IAAA/D,kBAAW,EAAC,YAA8B;IAC5D,OAAO2D,kBAAU,CAACI,WAAW,CAAC,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;;EAEN;AACF;AACA;EACE,MAAMU,YAAY,GAAG,IAAAzE,kBAAW,EAAC,YAAoC;IACnE,OAAO2D,kBAAU,CAACc,YAAY,CAAC,CAAC;EAClC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACLjB,cAAc;IACdwB,cAAc;IACdqC,MAAM;IACNC,MAAM;IACNQ,SAAS;IACT/D,WAAW;IACXU,YAAY;IACZuD,gBAAgB,EAAE1D,kBAAkB;IACpCE;EACF,CAAC;AACH,CAAC;AAACyD,OAAA,CAAAtJ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDeviceManagement = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _deviceManager = require("../../../utils/deviceManager");
|
|
9
|
+
var _errorHandlers = require("../../utils/errorHandlers");
|
|
10
|
+
/**
|
|
11
|
+
* Provide device session management helpers tied to the current active session.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Device management configuration
|
|
14
|
+
*/
|
|
15
|
+
const useDeviceManagement = ({
|
|
16
|
+
oxyServices,
|
|
17
|
+
activeSessionId,
|
|
18
|
+
onError,
|
|
19
|
+
clearSessionState,
|
|
20
|
+
logger
|
|
21
|
+
}) => {
|
|
22
|
+
const getDeviceSessions = (0, _react.useCallback)(async () => {
|
|
23
|
+
if (!activeSessionId) throw new Error('No active session');
|
|
24
|
+
try {
|
|
25
|
+
return await oxyServices.getDeviceSessions(activeSessionId);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
(0, _errorHandlers.handleAuthError)(error, {
|
|
28
|
+
defaultMessage: 'Failed to get device sessions',
|
|
29
|
+
code: 'GET_DEVICE_SESSIONS_ERROR',
|
|
30
|
+
onError,
|
|
31
|
+
logger
|
|
32
|
+
});
|
|
33
|
+
throw error instanceof Error ? error : new Error('Failed to get device sessions');
|
|
34
|
+
}
|
|
35
|
+
}, [activeSessionId, logger, onError, oxyServices]);
|
|
36
|
+
const logoutAllDeviceSessions = (0, _react.useCallback)(async () => {
|
|
37
|
+
if (!activeSessionId) throw new Error('No active session');
|
|
38
|
+
try {
|
|
39
|
+
await oxyServices.logoutAllDeviceSessions(activeSessionId);
|
|
40
|
+
await clearSessionState();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
(0, _errorHandlers.handleAuthError)(error, {
|
|
43
|
+
defaultMessage: 'Failed to logout all device sessions',
|
|
44
|
+
code: 'LOGOUT_ALL_DEVICES_ERROR',
|
|
45
|
+
onError,
|
|
46
|
+
logger
|
|
47
|
+
});
|
|
48
|
+
throw error instanceof Error ? error : new Error('Failed to logout all device sessions');
|
|
49
|
+
}
|
|
50
|
+
}, [activeSessionId, clearSessionState, logger, onError, oxyServices]);
|
|
51
|
+
const updateDeviceName = (0, _react.useCallback)(async deviceName => {
|
|
52
|
+
if (!activeSessionId) throw new Error('No active session');
|
|
53
|
+
try {
|
|
54
|
+
await oxyServices.updateDeviceName(activeSessionId, deviceName);
|
|
55
|
+
await _deviceManager.DeviceManager.updateDeviceName(deviceName);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
(0, _errorHandlers.handleAuthError)(error, {
|
|
58
|
+
defaultMessage: 'Failed to update device name',
|
|
59
|
+
code: 'UPDATE_DEVICE_NAME_ERROR',
|
|
60
|
+
onError,
|
|
61
|
+
logger
|
|
62
|
+
});
|
|
63
|
+
throw error instanceof Error ? error : new Error('Failed to update device name');
|
|
64
|
+
}
|
|
65
|
+
}, [activeSessionId, logger, onError, oxyServices]);
|
|
66
|
+
return {
|
|
67
|
+
getDeviceSessions,
|
|
68
|
+
logoutAllDeviceSessions,
|
|
69
|
+
updateDeviceName
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
exports.useDeviceManagement = useDeviceManagement;
|
|
73
|
+
//# sourceMappingURL=useDeviceManagement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_deviceManager","_errorHandlers","useDeviceManagement","oxyServices","activeSessionId","onError","clearSessionState","logger","getDeviceSessions","useCallback","Error","error","handleAuthError","defaultMessage","code","logoutAllDeviceSessions","updateDeviceName","deviceName","DeviceManager","exports"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useDeviceManagement.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AAwBA;AACA;AACA;AACA;AACA;AACO,MAAMG,mBAAmB,GAAGA,CAAC;EAClCC,WAAW;EACXC,eAAe;EACfC,OAAO;EACPC,iBAAiB;EACjBC;AAC0B,CAAC,KAAgC;EAC3D,MAAMC,iBAAiB,GAAG,IAAAC,kBAAW,EAAC,YAQjC;IACH,IAAI,CAACL,eAAe,EAAE,MAAM,IAAIM,KAAK,CAAC,mBAAmB,CAAC;IAC1D,IAAI;MACF,OAAO,MAAMP,WAAW,CAACK,iBAAiB,CAACJ,eAAe,CAAC;IAC7D,CAAC,CAAC,OAAOO,KAAK,EAAE;MACd,IAAAC,8BAAe,EAACD,KAAK,EAAE;QACrBE,cAAc,EAAE,+BAA+B;QAC/CC,IAAI,EAAE,2BAA2B;QACjCT,OAAO;QACPE;MACF,CAAC,CAAC;MACF,MAAMI,KAAK,YAAYD,KAAK,GAAGC,KAAK,GAAG,IAAID,KAAK,CAAC,+BAA+B,CAAC;IACnF;EACF,CAAC,EAAE,CAACN,eAAe,EAAEG,MAAM,EAAEF,OAAO,EAAEF,WAAW,CAAC,CAAC;EAEnD,MAAMY,uBAAuB,GAAG,IAAAN,kBAAW,EAAC,YAA2B;IACrE,IAAI,CAACL,eAA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