@oxyhq/services 5.16.44 → 5.17.1
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/components/OxyProvider.js +9 -20
- package/lib/commonjs/ui/components/OxyProvider.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/components/OxyProvider.js +9 -20
- package/lib/module/ui/components/OxyProvider.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/OxyProvider.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/OxyProvider.tsx +10 -17
- 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 -48
- 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 -45
- 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 -48
- 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
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { toast } from '../../lib/sonner';
|
|
4
|
-
import { translate } from '../../i18n';
|
|
5
|
-
import type { RouteName } from '../navigation/routes';
|
|
6
|
-
import { showBottomSheet as globalShowBottomSheet } from '../navigation/bottomSheetManager';
|
|
7
|
-
import { updateAvatarVisibility, updateProfileWithAvatar } from '../utils/avatarUtils';
|
|
8
|
-
import type { OxyServices } from '../../core';
|
|
9
|
-
import type { User } from '../../models/interfaces';
|
|
10
|
-
|
|
11
|
-
interface UseAvatarPickerOptions {
|
|
12
|
-
oxyServices: OxyServices;
|
|
13
|
-
currentLanguage: string;
|
|
14
|
-
activeSessionId: string | null;
|
|
15
|
-
queryClient: ReturnType<typeof useQueryClient>;
|
|
16
|
-
syncIdentity: (username?: string) => Promise<User>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Hook to handle avatar picker functionality
|
|
21
|
-
*/
|
|
22
|
-
export function useAvatarPicker({
|
|
23
|
-
oxyServices,
|
|
24
|
-
currentLanguage,
|
|
25
|
-
activeSessionId,
|
|
26
|
-
queryClient,
|
|
27
|
-
syncIdentity,
|
|
28
|
-
}: UseAvatarPickerOptions) {
|
|
29
|
-
const openAvatarPicker = useCallback(() => {
|
|
30
|
-
globalShowBottomSheet({
|
|
31
|
-
screen: 'FileManagement' as RouteName,
|
|
32
|
-
props: {
|
|
33
|
-
selectMode: true,
|
|
34
|
-
multiSelect: false,
|
|
35
|
-
disabledMimeTypes: ['video/', 'audio/', 'application/pdf'],
|
|
36
|
-
afterSelect: 'none',
|
|
37
|
-
onSelect: async (file: any) => {
|
|
38
|
-
if (!file.contentType.startsWith('image/')) {
|
|
39
|
-
toast.error(translate(currentLanguage, 'editProfile.toasts.selectImage') || 'Please select an image file');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
await updateAvatarVisibility(file.id, oxyServices, 'useAvatarPicker');
|
|
44
|
-
await updateProfileWithAvatar(
|
|
45
|
-
{ avatar: file.id },
|
|
46
|
-
oxyServices,
|
|
47
|
-
activeSessionId,
|
|
48
|
-
queryClient,
|
|
49
|
-
() => syncIdentity()
|
|
50
|
-
);
|
|
51
|
-
toast.success(translate(currentLanguage, 'editProfile.toasts.avatarUpdated') || 'Avatar updated');
|
|
52
|
-
} catch (e: any) {
|
|
53
|
-
toast.error(e.message || translate(currentLanguage, 'editProfile.toasts.updateAvatarFailed') || 'Failed to update avatar');
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}, [oxyServices, currentLanguage, activeSessionId, queryClient, syncIdentity]);
|
|
59
|
-
|
|
60
|
-
return { openAvatarPicker };
|
|
61
|
-
}
|
|
62
|
-
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { toast } from '../../lib/sonner';
|
|
3
|
-
import { useTransferStore } from '../stores/transferStore';
|
|
4
|
-
import type { IdentitySessionCore } from '../../core/identity-session';
|
|
5
|
-
|
|
6
|
-
interface UseIdentityTransferOptions {
|
|
7
|
-
identityCore: IdentitySessionCore | null;
|
|
8
|
-
currentDeviceId: string | null;
|
|
9
|
-
activeSessionId: string | null;
|
|
10
|
-
getPublicKey: () => Promise<string | null>;
|
|
11
|
-
deleteIdentityAndClearAccount: (skipBackup?: boolean, force?: boolean, userConfirmed?: boolean) => Promise<void>;
|
|
12
|
-
logger: (message: string, err?: unknown) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Hook to handle identity transfer completion
|
|
17
|
-
* This hook processes the identity_transfer_complete event and deletes the identity from the source device
|
|
18
|
-
*/
|
|
19
|
-
export function useIdentityTransfer({
|
|
20
|
-
identityCore,
|
|
21
|
-
currentDeviceId,
|
|
22
|
-
activeSessionId,
|
|
23
|
-
getPublicKey,
|
|
24
|
-
deleteIdentityAndClearAccount,
|
|
25
|
-
logger,
|
|
26
|
-
}: UseIdentityTransferOptions) {
|
|
27
|
-
const getTransferCode = useTransferStore((state) => state.getTransferCode);
|
|
28
|
-
const clearTransferCode = useTransferStore((state) => state.clearTransferCode);
|
|
29
|
-
const updateTransferState = useTransferStore((state) => state.updateTransferState);
|
|
30
|
-
|
|
31
|
-
const handleIdentityTransferComplete = useCallback(
|
|
32
|
-
async (data: { transferId: string; sourceDeviceId: string; publicKey: string; transferCode?: string; completedAt: string }) => {
|
|
33
|
-
try {
|
|
34
|
-
logger('Received identity transfer complete notification', {
|
|
35
|
-
transferId: data.transferId,
|
|
36
|
-
sourceDeviceId: data.sourceDeviceId,
|
|
37
|
-
currentDeviceId,
|
|
38
|
-
hasActiveSession: activeSessionId !== null,
|
|
39
|
-
publicKey: data.publicKey.substring(0, 16) + '...',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const storedTransfer = getTransferCode(data.transferId);
|
|
43
|
-
|
|
44
|
-
if (!storedTransfer) {
|
|
45
|
-
logger('Transfer code not found for transferId', { transferId: data.transferId });
|
|
46
|
-
toast.error('Transfer verification failed: Code not found. Identity will not be deleted.');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const currentPublicKey = await getPublicKey();
|
|
51
|
-
if (!currentPublicKey) {
|
|
52
|
-
logger('No public key found on device - cannot verify transfer', { transferId: data.transferId });
|
|
53
|
-
toast.error('Transfer verification failed: No identity found on device. Identity will not be deleted.');
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const isSourceDevice = currentPublicKey === storedTransfer.publicKey;
|
|
58
|
-
if (!isSourceDevice) {
|
|
59
|
-
logger('Current device public key does not match stored transfer public key - this is not the source device', {
|
|
60
|
-
transferId: data.transferId,
|
|
61
|
-
currentPublicKey: currentPublicKey.substring(0, 16) + '...',
|
|
62
|
-
storedPublicKey: storedTransfer.publicKey.substring(0, 16) + '...',
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const publicKeyMatches = data.publicKey === storedTransfer.publicKey;
|
|
68
|
-
if (!publicKeyMatches) {
|
|
69
|
-
logger('Public key mismatch for transfer', {
|
|
70
|
-
transferId: data.transferId,
|
|
71
|
-
receivedPublicKey: data.publicKey.substring(0, 16) + '...',
|
|
72
|
-
storedPublicKey: storedTransfer.publicKey.substring(0, 16) + '...',
|
|
73
|
-
});
|
|
74
|
-
toast.error('Transfer verification failed: Public key mismatch. Identity will not be deleted.');
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const transferAge = Date.now() - storedTransfer.timestamp;
|
|
79
|
-
const tenMinutes = 10 * 60 * 1000;
|
|
80
|
-
if (transferAge > tenMinutes) {
|
|
81
|
-
logger('Transfer confirmation received too late', {
|
|
82
|
-
transferId: data.transferId,
|
|
83
|
-
age: transferAge,
|
|
84
|
-
ageMinutes: Math.round(transferAge / 60000),
|
|
85
|
-
});
|
|
86
|
-
toast.error('Transfer verification failed: Confirmation received too late. Identity will not be deleted.');
|
|
87
|
-
clearTransferCode(data.transferId);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
logger('All transfer verifications passed, deleting identity from source device', {
|
|
92
|
-
transferId: data.transferId,
|
|
93
|
-
sourceDeviceId: data.sourceDeviceId,
|
|
94
|
-
publicKey: data.publicKey.substring(0, 16) + '...',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const identityStillExists = identityCore ? await identityCore.hasIdentity() : false;
|
|
99
|
-
if (!identityStillExists) {
|
|
100
|
-
logger('Identity already deleted - skipping deletion', { transferId: data.transferId });
|
|
101
|
-
await updateTransferState(data.transferId, 'completed');
|
|
102
|
-
await clearTransferCode(data.transferId);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
await deleteIdentityAndClearAccount(false, false, true);
|
|
107
|
-
|
|
108
|
-
const identityDeleted = identityCore ? !(await identityCore.hasIdentity()) : true;
|
|
109
|
-
if (!identityDeleted) {
|
|
110
|
-
logger('Identity deletion failed - identity still exists', { transferId: data.transferId });
|
|
111
|
-
await updateTransferState(data.transferId, 'failed');
|
|
112
|
-
throw new Error('Identity deletion failed - identity still exists');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await updateTransferState(data.transferId, 'completed');
|
|
116
|
-
await clearTransferCode(data.transferId);
|
|
117
|
-
|
|
118
|
-
logger('Identity successfully deleted and transfer code cleared', { transferId: data.transferId });
|
|
119
|
-
toast.success('Identity successfully transferred and removed from this device');
|
|
120
|
-
} catch (deleteError: any) {
|
|
121
|
-
logger('Error during identity deletion', deleteError);
|
|
122
|
-
await updateTransferState(data.transferId, 'failed');
|
|
123
|
-
throw deleteError;
|
|
124
|
-
}
|
|
125
|
-
} catch (error: any) {
|
|
126
|
-
logger('Failed to delete identity after transfer', error);
|
|
127
|
-
toast.error(error?.message || 'Failed to remove identity from this device. Please try again manually from Security Settings.');
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
[deleteIdentityAndClearAccount, logger, getTransferCode, clearTransferCode, updateTransferState, currentDeviceId, activeSessionId, getPublicKey, identityCore]
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
return { handleIdentityTransferComplete };
|
|
134
|
-
}
|
|
135
|
-
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useStorage } from './useStorage';
|
|
3
|
-
import { useTransferStore } from '../stores/transferStore';
|
|
4
|
-
|
|
5
|
-
const TRANSFER_CODES_STORAGE_KEY = 'oxy_transfer_codes';
|
|
6
|
-
const ACTIVE_TRANSFER_STORAGE_KEY = 'oxy_active_transfer_id';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook to handle persistence of transfer codes to storage
|
|
10
|
-
* This hook automatically loads transfer codes on mount and persists them when they change
|
|
11
|
-
*/
|
|
12
|
-
export function useTransferCodesPersistence(storageKeyPrefix: string = 'oxy_session') {
|
|
13
|
-
const TRANSFER_CODES_KEY = `${storageKeyPrefix}_transfer_codes`;
|
|
14
|
-
const ACTIVE_TRANSFER_KEY = `${storageKeyPrefix}_active_transfer_id`;
|
|
15
|
-
|
|
16
|
-
const { storage, isReady: isStorageReady } = useStorage();
|
|
17
|
-
|
|
18
|
-
const isRestored = useTransferStore((state) => state.isRestored);
|
|
19
|
-
const restoreFromStorage = useTransferStore((state) => state.restoreFromStorage);
|
|
20
|
-
const markRestored = useTransferStore((state) => state.markRestored);
|
|
21
|
-
const cleanupExpired = useTransferStore((state) => state.cleanupExpired);
|
|
22
|
-
const { transferCodes, activeTransferId } = useTransferStore((state) => ({
|
|
23
|
-
transferCodes: state.transferCodes,
|
|
24
|
-
activeTransferId: state.activeTransferId,
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
// Load transfer codes from storage on startup (only once)
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (!storage || !isStorageReady || isRestored) return;
|
|
30
|
-
|
|
31
|
-
const loadTransferCodes = async () => {
|
|
32
|
-
try {
|
|
33
|
-
const storedCodes = await storage.getItem(TRANSFER_CODES_KEY);
|
|
34
|
-
const storedActiveTransferId = await storage.getItem(ACTIVE_TRANSFER_KEY);
|
|
35
|
-
|
|
36
|
-
const parsedCodes = storedCodes ? JSON.parse(storedCodes) : {};
|
|
37
|
-
const activeTransferId = storedActiveTransferId || null;
|
|
38
|
-
|
|
39
|
-
restoreFromStorage(parsedCodes, activeTransferId);
|
|
40
|
-
markRestored();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
// Mark as restored even on error to prevent retries
|
|
43
|
-
markRestored();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
loadTransferCodes();
|
|
48
|
-
}, [storage, isStorageReady, isRestored, restoreFromStorage, markRestored, TRANSFER_CODES_KEY, ACTIVE_TRANSFER_KEY]);
|
|
49
|
-
|
|
50
|
-
// Persist transfer codes to storage whenever store changes
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (!storage || !isStorageReady || !isRestored) return;
|
|
53
|
-
|
|
54
|
-
const persistTransferCodes = async () => {
|
|
55
|
-
try {
|
|
56
|
-
await storage.setItem(TRANSFER_CODES_KEY, JSON.stringify(transferCodes));
|
|
57
|
-
|
|
58
|
-
if (activeTransferId) {
|
|
59
|
-
await storage.setItem(ACTIVE_TRANSFER_KEY, activeTransferId);
|
|
60
|
-
} else {
|
|
61
|
-
await storage.removeItem(ACTIVE_TRANSFER_KEY);
|
|
62
|
-
}
|
|
63
|
-
} catch (error) {
|
|
64
|
-
// Silently fail - persistence errors are not critical
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
persistTransferCodes();
|
|
69
|
-
}, [transferCodes, activeTransferId, storage, isStorageReady, isRestored, TRANSFER_CODES_KEY, ACTIVE_TRANSFER_KEY]);
|
|
70
|
-
|
|
71
|
-
// Cleanup expired transfer codes (every minute)
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
const cleanup = setInterval(() => {
|
|
74
|
-
cleanupExpired();
|
|
75
|
-
}, 60000);
|
|
76
|
-
|
|
77
|
-
return () => clearInterval(cleanup);
|
|
78
|
-
}, [cleanupExpired]);
|
|
79
|
-
}
|
|
80
|
-
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { useTransferStore } from '../stores/transferStore';
|
|
3
|
-
import type { OxyServices } from '../../core';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Query keys for transfer-related queries
|
|
7
|
-
*/
|
|
8
|
-
export const transferQueryKeys = {
|
|
9
|
-
pending: () => ['transfers', 'pending'] as const,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Hook to check all pending transfers for completion
|
|
14
|
-
* Used when app comes back online
|
|
15
|
-
*
|
|
16
|
-
* This version accepts oxyServices and isAuthenticated as parameters to avoid
|
|
17
|
-
* circular dependency when used inside OxyContext
|
|
18
|
-
*/
|
|
19
|
-
export const useCheckPendingTransfers = (
|
|
20
|
-
oxyServices?: OxyServices | null,
|
|
21
|
-
isAuthenticated?: boolean
|
|
22
|
-
) => {
|
|
23
|
-
const getAllPendingTransfers = useTransferStore((state) => state.getAllPendingTransfers);
|
|
24
|
-
const pendingTransfers = getAllPendingTransfers();
|
|
25
|
-
|
|
26
|
-
return useQuery({
|
|
27
|
-
queryKey: [...transferQueryKeys.pending(), pendingTransfers.map(t => t.transferId).join(',')],
|
|
28
|
-
queryFn: async () => {
|
|
29
|
-
if (!oxyServices || pendingTransfers.length === 0) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const results: Array<{
|
|
34
|
-
transferId: string;
|
|
35
|
-
completed: boolean;
|
|
36
|
-
data?: {
|
|
37
|
-
transferId?: string;
|
|
38
|
-
sourceDeviceId?: string;
|
|
39
|
-
publicKey?: string;
|
|
40
|
-
transferCode?: string;
|
|
41
|
-
completedAt?: string;
|
|
42
|
-
};
|
|
43
|
-
}> = [];
|
|
44
|
-
|
|
45
|
-
// Check each pending transfer
|
|
46
|
-
for (const { transferId, data } of pendingTransfers) {
|
|
47
|
-
try {
|
|
48
|
-
const response = await oxyServices.makeRequest<{
|
|
49
|
-
completed: boolean;
|
|
50
|
-
transferId?: string;
|
|
51
|
-
sourceDeviceId?: string;
|
|
52
|
-
publicKey?: string;
|
|
53
|
-
transferCode?: string;
|
|
54
|
-
completedAt?: string;
|
|
55
|
-
}>(
|
|
56
|
-
'GET',
|
|
57
|
-
`/api/identity/check-transfer/${transferId}`,
|
|
58
|
-
undefined,
|
|
59
|
-
{ cache: false }
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
if (response.completed && response.publicKey === data.publicKey) {
|
|
63
|
-
results.push({
|
|
64
|
-
transferId,
|
|
65
|
-
completed: true,
|
|
66
|
-
data: response,
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
results.push({
|
|
70
|
-
transferId,
|
|
71
|
-
completed: false,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
} catch (error: any) {
|
|
75
|
-
// Handle 401 errors gracefully - skip this transfer
|
|
76
|
-
if (error?.status === 401 || error?.message?.includes('401') || error?.message?.includes('authentication')) {
|
|
77
|
-
if (__DEV__) {
|
|
78
|
-
console.warn(`[useCheckPendingTransfers] Authentication required for transfer ${transferId}, skipping`);
|
|
79
|
-
}
|
|
80
|
-
results.push({
|
|
81
|
-
transferId,
|
|
82
|
-
completed: false,
|
|
83
|
-
});
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
// For other errors, mark as not completed
|
|
87
|
-
results.push({
|
|
88
|
-
transferId,
|
|
89
|
-
completed: false,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return results;
|
|
95
|
-
},
|
|
96
|
-
enabled: (isAuthenticated ?? false) && !!oxyServices && pendingTransfers.length > 0,
|
|
97
|
-
staleTime: 30 * 1000, // 30 seconds
|
|
98
|
-
gcTime: 5 * 60 * 1000, // 5 minutes
|
|
99
|
-
retry: false, // Don't retry - we'll check again on next reconnect
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand';
|
|
2
|
-
import { useShallow } from 'zustand/react/shallow';
|
|
3
|
-
|
|
4
|
-
export interface TransferCodeData {
|
|
5
|
-
code: string;
|
|
6
|
-
sourceDeviceId: string | null;
|
|
7
|
-
publicKey: string;
|
|
8
|
-
timestamp: number;
|
|
9
|
-
state: 'pending' | 'completed' | 'failed';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface TransferState {
|
|
13
|
-
// Transfer codes map: transferId -> TransferCodeData
|
|
14
|
-
transferCodes: Record<string, TransferCodeData>;
|
|
15
|
-
|
|
16
|
-
// Active transfer ID (only one active transfer at a time)
|
|
17
|
-
activeTransferId: string | null;
|
|
18
|
-
|
|
19
|
-
// Restoration flag to prevent duplicate restorations
|
|
20
|
-
isRestored: boolean;
|
|
21
|
-
|
|
22
|
-
// Actions
|
|
23
|
-
storeTransferCode: (transferId: string, code: string, sourceDeviceId: string | null, publicKey: string) => void;
|
|
24
|
-
getTransferCode: (transferId: string) => TransferCodeData | null;
|
|
25
|
-
clearTransferCode: (transferId: string) => void;
|
|
26
|
-
updateTransferState: (transferId: string, state: 'pending' | 'completed' | 'failed') => void;
|
|
27
|
-
getAllPendingTransfers: () => Array<{ transferId: string; data: TransferCodeData }>;
|
|
28
|
-
getActiveTransferId: () => string | null;
|
|
29
|
-
setActiveTransferId: (transferId: string | null) => void;
|
|
30
|
-
restoreFromStorage: (codes: Record<string, TransferCodeData>, activeTransferId: string | null) => void;
|
|
31
|
-
markRestored: () => void;
|
|
32
|
-
cleanupExpired: () => void;
|
|
33
|
-
reset: () => void;
|
|
34
|
-
clearAll: () => void; // Alias for reset - use when clearing on identity change for semantic clarity
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const FIFTEEN_MINUTES = 15 * 60 * 1000;
|
|
38
|
-
|
|
39
|
-
const initialState = {
|
|
40
|
-
transferCodes: {} as Record<string, TransferCodeData>,
|
|
41
|
-
activeTransferId: null as string | null,
|
|
42
|
-
isRestored: false,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const useTransferStore = create<TransferState>((set, get) => ({
|
|
46
|
-
...initialState,
|
|
47
|
-
|
|
48
|
-
storeTransferCode: (transferId: string, code: string, sourceDeviceId: string | null, publicKey: string) => {
|
|
49
|
-
set((state) => ({
|
|
50
|
-
transferCodes: {
|
|
51
|
-
...state.transferCodes,
|
|
52
|
-
[transferId]: {
|
|
53
|
-
code,
|
|
54
|
-
sourceDeviceId,
|
|
55
|
-
publicKey,
|
|
56
|
-
timestamp: Date.now(),
|
|
57
|
-
state: 'pending',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
activeTransferId: transferId,
|
|
61
|
-
}));
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
getTransferCode: (transferId: string) => {
|
|
65
|
-
const state = get();
|
|
66
|
-
return state.transferCodes[transferId] || null;
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
clearTransferCode: (transferId: string) => {
|
|
70
|
-
set((state) => {
|
|
71
|
-
const { [transferId]: removed, ...rest } = state.transferCodes;
|
|
72
|
-
const newActiveTransferId = state.activeTransferId === transferId ? null : state.activeTransferId;
|
|
73
|
-
return {
|
|
74
|
-
transferCodes: rest,
|
|
75
|
-
activeTransferId: newActiveTransferId,
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
updateTransferState: (transferId: string, newState: 'pending' | 'completed' | 'failed') => {
|
|
81
|
-
set((state) => {
|
|
82
|
-
const existing = state.transferCodes[transferId];
|
|
83
|
-
if (!existing) {
|
|
84
|
-
return state;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const updated = {
|
|
88
|
-
...existing,
|
|
89
|
-
state: newState,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// Clear active transfer if completed or failed
|
|
93
|
-
const newActiveTransferId =
|
|
94
|
-
(newState === 'completed' || newState === 'failed') && state.activeTransferId === transferId
|
|
95
|
-
? null
|
|
96
|
-
: state.activeTransferId;
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
transferCodes: {
|
|
100
|
-
...state.transferCodes,
|
|
101
|
-
[transferId]: updated,
|
|
102
|
-
},
|
|
103
|
-
activeTransferId: newActiveTransferId,
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
getAllPendingTransfers: () => {
|
|
109
|
-
const state = get();
|
|
110
|
-
const pending: Array<{ transferId: string; data: TransferCodeData }> = [];
|
|
111
|
-
|
|
112
|
-
Object.entries(state.transferCodes).forEach(([transferId, data]) => {
|
|
113
|
-
if (data.state === 'pending') {
|
|
114
|
-
pending.push({ transferId, data });
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
return pending;
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
getActiveTransferId: () => {
|
|
122
|
-
return get().activeTransferId;
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
setActiveTransferId: (transferId: string | null) => {
|
|
126
|
-
set({ activeTransferId: transferId });
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
restoreFromStorage: (codes: Record<string, TransferCodeData>, activeTransferId: string | null) => {
|
|
130
|
-
const now = Date.now();
|
|
131
|
-
const validCodes: Record<string, TransferCodeData> = {};
|
|
132
|
-
|
|
133
|
-
// Only restore non-expired pending transfers
|
|
134
|
-
Object.entries(codes).forEach(([transferId, data]) => {
|
|
135
|
-
if (data.state === 'pending' && (now - data.timestamp) < FIFTEEN_MINUTES) {
|
|
136
|
-
validCodes[transferId] = data;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Verify active transfer is still valid
|
|
141
|
-
let validActiveTransferId = activeTransferId;
|
|
142
|
-
if (activeTransferId && (!validCodes[activeTransferId] || validCodes[activeTransferId].state !== 'pending')) {
|
|
143
|
-
validActiveTransferId = null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
set({
|
|
147
|
-
transferCodes: validCodes,
|
|
148
|
-
activeTransferId: validActiveTransferId,
|
|
149
|
-
isRestored: true,
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
markRestored: () => {
|
|
154
|
-
set({ isRestored: true });
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
cleanupExpired: () => {
|
|
158
|
-
const now = Date.now();
|
|
159
|
-
set((state) => {
|
|
160
|
-
const validCodes: Record<string, TransferCodeData> = {};
|
|
161
|
-
let newActiveTransferId = state.activeTransferId;
|
|
162
|
-
|
|
163
|
-
Object.entries(state.transferCodes).forEach(([transferId, data]) => {
|
|
164
|
-
const age = now - data.timestamp;
|
|
165
|
-
if (age < FIFTEEN_MINUTES) {
|
|
166
|
-
validCodes[transferId] = data;
|
|
167
|
-
} else if (transferId === state.activeTransferId) {
|
|
168
|
-
newActiveTransferId = null;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
transferCodes: validCodes,
|
|
174
|
-
activeTransferId: newActiveTransferId,
|
|
175
|
-
};
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
reset: () => {
|
|
180
|
-
set(initialState);
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
clearAll: () => {
|
|
184
|
-
// Delegate to reset to maintain single source of truth
|
|
185
|
-
get().reset();
|
|
186
|
-
},
|
|
187
|
-
}));
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Hook to get transfer codes for persistence
|
|
191
|
-
*/
|
|
192
|
-
export const useTransferCodesForPersistence = () => {
|
|
193
|
-
return useTransferStore(
|
|
194
|
-
useShallow((state) => ({
|
|
195
|
-
transferCodes: state.transferCodes,
|
|
196
|
-
activeTransferId: state.activeTransferId,
|
|
197
|
-
}))
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
|