@oxyhq/services 5.16.44 → 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 -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
|
@@ -14,23 +14,6 @@ export interface ChallengeResponse {
|
|
|
14
14
|
expiresAt: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export interface RegistrationRequest {
|
|
18
|
-
publicKey: string;
|
|
19
|
-
username: string;
|
|
20
|
-
email?: string;
|
|
21
|
-
signature: string;
|
|
22
|
-
timestamp: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface ChallengeVerifyRequest {
|
|
26
|
-
publicKey: string;
|
|
27
|
-
challenge: string;
|
|
28
|
-
signature: string;
|
|
29
|
-
timestamp: number;
|
|
30
|
-
deviceName?: string;
|
|
31
|
-
deviceFingerprint?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
17
|
export interface PublicKeyCheckResponse {
|
|
35
18
|
registered: boolean;
|
|
36
19
|
message: string;
|
|
@@ -43,35 +26,32 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
43
26
|
}
|
|
44
27
|
|
|
45
28
|
/**
|
|
46
|
-
* Register a new identity
|
|
47
|
-
*
|
|
29
|
+
* Register a new identity (bootstrap - no session required)
|
|
30
|
+
*
|
|
31
|
+
* This is the ONLY operation that Services allows without an active session.
|
|
32
|
+
* It's exclusively for the initial bootstrap of Accounts app.
|
|
48
33
|
*
|
|
49
34
|
* @param publicKey - The user's ECDSA public key (hex)
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param username - Optional username
|
|
35
|
+
* @param name - Optional first name
|
|
36
|
+
* @param lastName - Optional last name
|
|
37
|
+
* @param username - Optional username
|
|
38
|
+
* @returns Object containing userId and user data
|
|
53
39
|
*/
|
|
54
|
-
async
|
|
40
|
+
async registerIdentity(
|
|
55
41
|
publicKey: string,
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
name?: string,
|
|
43
|
+
lastName?: string,
|
|
58
44
|
username?: string
|
|
59
|
-
): Promise<{
|
|
45
|
+
): Promise<{ userId: string; user: User }> {
|
|
60
46
|
try {
|
|
61
|
-
const
|
|
47
|
+
const res = await this.makeRequest<{ userId: string; user: User }>('POST', '/api/identity/register', {
|
|
62
48
|
publicKey,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// Include username if provided
|
|
68
|
-
if (username && username.trim()) {
|
|
69
|
-
payload.username = username.trim();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const res = await this.makeRequest<{ message: string; user: User }>('POST', '/api/auth/register', payload, { cache: false });
|
|
49
|
+
name,
|
|
50
|
+
lastName,
|
|
51
|
+
username,
|
|
52
|
+
}, { cache: false });
|
|
73
53
|
|
|
74
|
-
if (!res ||
|
|
54
|
+
if (!res || !res.userId) {
|
|
75
55
|
throw new OxyAuthenticationError('Registration failed', 'REGISTER_FAILED', 400);
|
|
76
56
|
}
|
|
77
57
|
|
|
@@ -85,12 +65,12 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
85
65
|
* Request an authentication challenge
|
|
86
66
|
* The client must sign this challenge with their private key
|
|
87
67
|
*
|
|
88
|
-
* @param
|
|
68
|
+
* @param userId - The user's ID (ObjectId)
|
|
89
69
|
*/
|
|
90
|
-
async requestChallenge(
|
|
70
|
+
async requestChallenge(userId: string): Promise<ChallengeResponse> {
|
|
91
71
|
try {
|
|
92
72
|
return await this.makeRequest<ChallengeResponse>('POST', '/api/auth/challenge', {
|
|
93
|
-
|
|
73
|
+
userId,
|
|
94
74
|
}, { cache: false });
|
|
95
75
|
} catch (error) {
|
|
96
76
|
throw this.handleError(error);
|
|
@@ -100,16 +80,16 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
100
80
|
/**
|
|
101
81
|
* Verify a signed challenge and create a session
|
|
102
82
|
*
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
83
|
+
* @param userId - The user's ID (ObjectId)
|
|
84
|
+
* @param nonce - The nonce (challenge) string from requestChallenge
|
|
105
85
|
* @param signature - Signature of the auth message
|
|
106
86
|
* @param timestamp - Timestamp when the signature was created
|
|
107
87
|
* @param deviceName - Optional device name
|
|
108
88
|
* @param deviceFingerprint - Optional device fingerprint
|
|
109
89
|
*/
|
|
110
90
|
async verifyChallenge(
|
|
111
|
-
|
|
112
|
-
|
|
91
|
+
userId: string,
|
|
92
|
+
nonce: string,
|
|
113
93
|
signature: string,
|
|
114
94
|
timestamp: number,
|
|
115
95
|
deviceName?: string,
|
|
@@ -117,8 +97,8 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
117
97
|
): Promise<SessionLoginResponse> {
|
|
118
98
|
try {
|
|
119
99
|
return await this.makeRequest<SessionLoginResponse>('POST', '/api/auth/verify', {
|
|
120
|
-
|
|
121
|
-
|
|
100
|
+
userId,
|
|
101
|
+
nonce,
|
|
122
102
|
signature,
|
|
123
103
|
timestamp,
|
|
124
104
|
deviceName,
|
|
@@ -147,6 +127,7 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
147
127
|
|
|
148
128
|
/**
|
|
149
129
|
* Get user by public key
|
|
130
|
+
* Services never caches profile - always fetch fresh from backend
|
|
150
131
|
*/
|
|
151
132
|
async getUserByPublicKey(publicKey: string): Promise<User> {
|
|
152
133
|
try {
|
|
@@ -154,7 +135,7 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
154
135
|
'GET',
|
|
155
136
|
`/api/auth/user/${encodeURIComponent(publicKey)}`,
|
|
156
137
|
undefined,
|
|
157
|
-
{ cache:
|
|
138
|
+
{ cache: false } // Services never caches profile - only tokens
|
|
158
139
|
);
|
|
159
140
|
} catch (error) {
|
|
160
141
|
throw this.handleError(error);
|
|
@@ -163,12 +144,12 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
163
144
|
|
|
164
145
|
/**
|
|
165
146
|
* Get user by session ID
|
|
147
|
+
* Services never caches profile - always fetch fresh from backend
|
|
166
148
|
*/
|
|
167
149
|
async getUserBySession(sessionId: string): Promise<User> {
|
|
168
150
|
try {
|
|
169
151
|
return await this.makeRequest<User>('GET', `/api/session/user/${sessionId}`, undefined, {
|
|
170
|
-
cache:
|
|
171
|
-
cacheTTL: 2 * 60 * 1000,
|
|
152
|
+
cache: false, // Services never caches profile - only tokens
|
|
172
153
|
});
|
|
173
154
|
} catch (error) {
|
|
174
155
|
throw this.handleError(error);
|
|
@@ -191,8 +172,7 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
191
172
|
'/api/session/users/batch',
|
|
192
173
|
{ sessionIds: uniqueSessionIds },
|
|
193
174
|
{
|
|
194
|
-
cache:
|
|
195
|
-
cacheTTL: 2 * 60 * 1000,
|
|
175
|
+
cache: false,
|
|
196
176
|
deduplicate: true,
|
|
197
177
|
}
|
|
198
178
|
);
|
|
@@ -204,16 +184,23 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
204
184
|
/**
|
|
205
185
|
* Get access token by session ID
|
|
206
186
|
*/
|
|
207
|
-
async getTokenBySession(
|
|
187
|
+
async getTokenBySession(
|
|
188
|
+
sessionId: string,
|
|
189
|
+
deviceId?: string
|
|
190
|
+
): Promise<{ accessToken: string; refreshToken: string; expiresAt: string; sessionId: string; deviceId: string }> {
|
|
208
191
|
try {
|
|
209
|
-
const res = await this.makeRequest<{ accessToken: string; expiresAt: string }>(
|
|
192
|
+
const res = await this.makeRequest<{ accessToken: string; refreshToken: string; expiresAt: string; sessionId: string; deviceId: string }>(
|
|
210
193
|
'GET',
|
|
211
194
|
`/api/session/token/${sessionId}`,
|
|
212
195
|
undefined,
|
|
213
|
-
{
|
|
196
|
+
{
|
|
197
|
+
cache: false,
|
|
198
|
+
retry: false,
|
|
199
|
+
headers: deviceId ? { 'x-device-id': deviceId } : undefined,
|
|
200
|
+
}
|
|
214
201
|
);
|
|
215
|
-
|
|
216
|
-
this.setTokens(res.accessToken);
|
|
202
|
+
|
|
203
|
+
this.setTokens(res.accessToken, res.refreshToken);
|
|
217
204
|
|
|
218
205
|
return res;
|
|
219
206
|
} catch (error) {
|
|
@@ -309,35 +296,5 @@ export function OxyServicesAuthMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
309
296
|
}
|
|
310
297
|
}
|
|
311
298
|
|
|
312
|
-
// ==========================================
|
|
313
|
-
// Deprecated methods - kept for reference
|
|
314
|
-
// ==========================================
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* @deprecated Use register() with public key authentication instead
|
|
318
|
-
*/
|
|
319
|
-
async signUp(username: string, email: string, password: string): Promise<{ message: string; token: string; user: User }> {
|
|
320
|
-
throw new OxyAuthenticationError(
|
|
321
|
-
'Password-based signup is no longer supported. Use register() with public key.',
|
|
322
|
-
'DEPRECATED',
|
|
323
|
-
410
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* @deprecated Use requestChallenge() and verifyChallenge() instead
|
|
329
|
-
*/
|
|
330
|
-
async signIn(
|
|
331
|
-
username: string,
|
|
332
|
-
password: string,
|
|
333
|
-
deviceName?: string,
|
|
334
|
-
deviceFingerprint?: any
|
|
335
|
-
): Promise<SessionLoginResponse | { mfaRequired: true; mfaToken: string; expiresAt: string }> {
|
|
336
|
-
throw new OxyAuthenticationError(
|
|
337
|
-
'Password-based login is no longer supported. Use challenge-response authentication.',
|
|
338
|
-
'DEPRECATED',
|
|
339
|
-
410
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
299
|
};
|
|
343
300
|
}
|
|
@@ -16,8 +16,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
16
16
|
async getProfileByUsername(username: string): Promise<User> {
|
|
17
17
|
try {
|
|
18
18
|
return await this.makeRequest<User>('GET', `/api/profiles/username/${username}`, undefined, {
|
|
19
|
-
cache:
|
|
20
|
-
cacheTTL: 5 * 60 * 1000, // 5 minutes cache for profiles
|
|
19
|
+
cache: false, // Never cache profiles
|
|
21
20
|
});
|
|
22
21
|
} catch (error) {
|
|
23
22
|
throw this.handleError(error);
|
|
@@ -38,8 +37,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
38
37
|
'/api/profiles/search',
|
|
39
38
|
paramsObj,
|
|
40
39
|
{
|
|
41
|
-
cache:
|
|
42
|
-
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
40
|
+
cache: false, // Never cache profiles
|
|
43
41
|
}
|
|
44
42
|
);
|
|
45
43
|
|
|
@@ -97,7 +95,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
97
95
|
[key: string]: any;
|
|
98
96
|
}>> {
|
|
99
97
|
return this.withAuthRetry(async () => {
|
|
100
|
-
return await this.makeRequest('GET', '/api/profiles/recommendations', undefined, { cache:
|
|
98
|
+
return await this.makeRequest('GET', '/api/profiles/recommendations', undefined, { cache: false });
|
|
101
99
|
}, 'getProfileRecommendations');
|
|
102
100
|
}
|
|
103
101
|
|
|
@@ -107,8 +105,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
107
105
|
async getUserById(userId: string): Promise<User> {
|
|
108
106
|
try {
|
|
109
107
|
return await this.makeRequest<User>('GET', `/api/users/${userId}`, undefined, {
|
|
110
|
-
cache:
|
|
111
|
-
cacheTTL: 5 * 60 * 1000, // 5 minutes cache
|
|
108
|
+
cache: false, // Never cache profiles
|
|
112
109
|
});
|
|
113
110
|
} catch (error) {
|
|
114
111
|
throw this.handleError(error);
|
|
@@ -117,12 +114,12 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
117
114
|
|
|
118
115
|
/**
|
|
119
116
|
* Get current user
|
|
117
|
+
* Services never caches profile - always fetch fresh from backend
|
|
120
118
|
*/
|
|
121
119
|
async getCurrentUser(): Promise<User> {
|
|
122
120
|
return this.withAuthRetry(async () => {
|
|
123
121
|
return await this.makeRequest<User>('GET', '/api/users/me', undefined, {
|
|
124
|
-
cache:
|
|
125
|
-
cacheTTL: 1 * 60 * 1000, // 1 minute cache for current user
|
|
122
|
+
cache: false, // Services never caches profile - only tokens
|
|
126
123
|
});
|
|
127
124
|
}, 'getCurrentUser');
|
|
128
125
|
}
|
|
@@ -168,8 +165,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
168
165
|
throw new Error('User ID is required');
|
|
169
166
|
}
|
|
170
167
|
return await this.makeRequest<any>('GET', `/api/privacy/${id}/privacy`, undefined, {
|
|
171
|
-
cache:
|
|
172
|
-
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
168
|
+
cache: false,
|
|
173
169
|
});
|
|
174
170
|
} catch (error) {
|
|
175
171
|
throw this.handleError(error);
|
|
@@ -275,8 +271,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
275
271
|
async getFollowStatus(userId: string): Promise<{ isFollowing: boolean }> {
|
|
276
272
|
try {
|
|
277
273
|
return await this.makeRequest('GET', `/api/users/${userId}/follow-status`, undefined, {
|
|
278
|
-
cache:
|
|
279
|
-
cacheTTL: 1 * 60 * 1000, // 1 minute cache
|
|
274
|
+
cache: false,
|
|
280
275
|
});
|
|
281
276
|
} catch (error) {
|
|
282
277
|
throw this.handleError(error);
|
|
@@ -293,8 +288,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
293
288
|
try {
|
|
294
289
|
const params = buildPaginationParams(pagination || {});
|
|
295
290
|
const response = await this.makeRequest<{ data: User[]; pagination: { total: number; hasMore: boolean } }>('GET', `/api/users/${userId}/followers`, params, {
|
|
296
|
-
cache:
|
|
297
|
-
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
291
|
+
cache: false,
|
|
298
292
|
});
|
|
299
293
|
return {
|
|
300
294
|
followers: response.data || [],
|
|
@@ -316,8 +310,7 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
316
310
|
try {
|
|
317
311
|
const params = buildPaginationParams(pagination || {});
|
|
318
312
|
const response = await this.makeRequest<{ data: User[]; pagination: { total: number; hasMore: boolean } }>('GET', `/api/users/${userId}/following`, params, {
|
|
319
|
-
cache:
|
|
320
|
-
cacheTTL: 2 * 60 * 1000, // 2 minutes cache
|
|
313
|
+
cache: false,
|
|
321
314
|
});
|
|
322
315
|
return {
|
|
323
316
|
following: response.data || [],
|
|
@@ -399,4 +392,3 @@ export function OxyServicesUserMixin<T extends typeof OxyServicesBase>(Base: T)
|
|
|
399
392
|
}
|
|
400
393
|
};
|
|
401
394
|
}
|
|
402
|
-
|
|
@@ -141,8 +141,22 @@ class TokenService {
|
|
|
141
141
|
return this.refreshPromise;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
const hasToken = !!this.tokenStore.accessToken;
|
|
145
|
+
const needsRefresh = this.isTokenExpiringSoon();
|
|
146
|
+
|
|
147
|
+
// If no access token but we have refresh token, attempt refresh once
|
|
148
|
+
if (!hasToken && this.tokenStore.refreshToken) {
|
|
149
|
+
this.refreshPromise = this._performRefresh();
|
|
150
|
+
try {
|
|
151
|
+
await this.refreshPromise;
|
|
152
|
+
} finally {
|
|
153
|
+
this.refreshPromise = null;
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
144
158
|
// If token not expiring soon, no refresh needed
|
|
145
|
-
if (!
|
|
159
|
+
if (!needsRefresh) {
|
|
146
160
|
return;
|
|
147
161
|
}
|
|
148
162
|
|
|
@@ -160,26 +174,24 @@ class TokenService {
|
|
|
160
174
|
* Perform token refresh
|
|
161
175
|
*/
|
|
162
176
|
private async _performRefresh(): Promise<void> {
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
165
|
-
throw new Error('No
|
|
177
|
+
const refreshToken = this.tokenStore.refreshToken;
|
|
178
|
+
if (!refreshToken) {
|
|
179
|
+
throw new Error('No refresh token to refresh');
|
|
166
180
|
}
|
|
167
181
|
|
|
168
182
|
try {
|
|
169
|
-
const decoded = jwtDecode<AccessTokenPayload>(token);
|
|
170
|
-
if (!decoded.sessionId) {
|
|
171
|
-
throw new Error('Token missing sessionId');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
183
|
if (!this.baseURL) {
|
|
175
184
|
throw new Error('TokenService not initialized with baseURL');
|
|
176
185
|
}
|
|
177
186
|
|
|
178
|
-
const refreshUrl = `${this.baseURL}/api/
|
|
179
|
-
|
|
187
|
+
const refreshUrl = `${this.baseURL}/api/auth/refresh`;
|
|
180
188
|
const response = await fetch(refreshUrl, {
|
|
181
|
-
method: '
|
|
182
|
-
headers: {
|
|
189
|
+
method: 'POST',
|
|
190
|
+
headers: {
|
|
191
|
+
'Accept': 'application/json',
|
|
192
|
+
'Content-Type': 'application/json',
|
|
193
|
+
},
|
|
194
|
+
body: JSON.stringify({ refreshToken }),
|
|
183
195
|
signal: AbortSignal.timeout(5000),
|
|
184
196
|
});
|
|
185
197
|
|
|
@@ -187,7 +199,7 @@ class TokenService {
|
|
|
187
199
|
throw new Error(`Token refresh failed: ${response.status}`);
|
|
188
200
|
}
|
|
189
201
|
|
|
190
|
-
const { accessToken: newToken } = await response.json();
|
|
202
|
+
const { accessToken: newToken, refreshToken: newRefresh } = await response.json();
|
|
191
203
|
|
|
192
204
|
if (!newToken) {
|
|
193
205
|
throw new Error('No access token in refresh response');
|
|
@@ -199,7 +211,7 @@ class TokenService {
|
|
|
199
211
|
throw new Error(`Invalid userId format in refreshed token: ${newDecoded.userId.substring(0, 20)}...`);
|
|
200
212
|
}
|
|
201
213
|
|
|
202
|
-
this.setTokens(newToken);
|
|
214
|
+
this.setTokens(newToken, newRefresh || refreshToken);
|
|
203
215
|
} catch (error) {
|
|
204
216
|
// Clear tokens on refresh failure (likely expired or invalid)
|
|
205
217
|
this.clearTokens();
|
|
@@ -223,4 +235,3 @@ class TokenService {
|
|
|
223
235
|
|
|
224
236
|
// Export singleton instance
|
|
225
237
|
export const tokenService = TokenService.getInstance();
|
|
226
|
-
|
package/src/crypto/index.ts
CHANGED
|
@@ -16,9 +16,7 @@ export {
|
|
|
16
16
|
} from './signatureService';
|
|
17
17
|
export { type BackupData } from './types';
|
|
18
18
|
|
|
19
|
-
// Export core crypto utilities (shared across platforms)
|
|
20
|
-
export * from './core';
|
|
21
|
-
|
|
22
19
|
// Re-export for convenience
|
|
23
20
|
export { KeyManager as default } from './keyManager';
|
|
24
21
|
|
|
22
|
+
|
package/src/crypto/keyManager.ts
CHANGED
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Key Manager - ECDSA secp256k1 Key Generation and Storage
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This module handles secure generation, storage, and retrieval of cryptographic keys.
|
|
4
|
+
* Handles secure generation, storage, and retrieval of cryptographic keys.
|
|
7
5
|
* Private keys are stored securely using expo-secure-store and never leave the device.
|
|
8
|
-
*
|
|
9
|
-
* **IMPORTANT**: Third-party apps should NOT use KeyManager directly.
|
|
10
|
-
* Instead, use the OxyServices authentication flows which communicate with the
|
|
11
|
-
* Oxy Accounts app via deep links/QR codes to obtain user authorization.
|
|
12
|
-
*
|
|
13
|
-
* The Oxy Accounts app is the sole owner of the user's private key and identity.
|
|
14
|
-
* Other apps request authentication from the Accounts app, which signs challenges
|
|
15
|
-
* and returns authorization to the requesting app via the API.
|
|
16
|
-
*
|
|
17
|
-
* @see {@link https://github.com/OxyHQ/OxyHQServices/blob/main/packages/services/src/crypto/README.md|Crypto Module Documentation}
|
|
18
6
|
*/
|
|
19
7
|
|
|
20
8
|
import { ec as EC } from 'elliptic';
|
|
21
9
|
import type { ECKeyPair } from 'elliptic';
|
|
22
10
|
import { Platform } from 'react-native';
|
|
23
|
-
import {
|
|
24
|
-
isValidPublicKey as validatePublicKey,
|
|
25
|
-
isValidPrivateKey as validatePrivateKey,
|
|
26
|
-
derivePublicKey as derivePublicKeyFromPrivate,
|
|
27
|
-
shortenPublicKey as shortenKey,
|
|
28
|
-
getEllipticCurve,
|
|
29
|
-
} from './core';
|
|
30
11
|
|
|
31
12
|
// Lazy imports for React Native specific modules
|
|
32
13
|
let SecureStore: typeof import('expo-secure-store') | null = null;
|
|
33
14
|
let ExpoCrypto: typeof import('expo-crypto') | null = null;
|
|
34
15
|
|
|
35
|
-
const ec =
|
|
16
|
+
const ec = new EC('secp256k1');
|
|
36
17
|
|
|
37
18
|
const STORAGE_KEYS = {
|
|
38
19
|
PRIVATE_KEY: 'oxy_identity_private_key',
|
|
@@ -143,9 +124,8 @@ export class KeyManager {
|
|
|
143
124
|
/**
|
|
144
125
|
* Invalidate cached identity state
|
|
145
126
|
* Called internally when identity is created/deleted/imported
|
|
146
|
-
* Can also be called externally to force a fresh state check (e.g., on app startup)
|
|
147
127
|
*/
|
|
148
|
-
static invalidateCache(): void {
|
|
128
|
+
private static invalidateCache(): void {
|
|
149
129
|
KeyManager.cachedPublicKey = null;
|
|
150
130
|
KeyManager.cachedHasIdentity = null;
|
|
151
131
|
}
|
|
@@ -454,9 +434,6 @@ export class KeyManager {
|
|
|
454
434
|
return false; // Identity storage is only available on native platforms
|
|
455
435
|
}
|
|
456
436
|
try {
|
|
457
|
-
// Invalidate cache before restoring to ensure fresh state
|
|
458
|
-
KeyManager.invalidateCache();
|
|
459
|
-
|
|
460
437
|
const store = await initSecureStore();
|
|
461
438
|
|
|
462
439
|
// Check if backup exists
|
|
@@ -523,21 +500,34 @@ export class KeyManager {
|
|
|
523
500
|
* Derive public key from a private key (without storing)
|
|
524
501
|
*/
|
|
525
502
|
static derivePublicKey(privateKey: string): string {
|
|
526
|
-
|
|
503
|
+
const keyPair = ec.keyFromPrivate(privateKey);
|
|
504
|
+
return keyPair.getPublic('hex');
|
|
527
505
|
}
|
|
528
506
|
|
|
529
507
|
/**
|
|
530
508
|
* Validate that a string is a valid public key
|
|
531
509
|
*/
|
|
532
510
|
static isValidPublicKey(publicKey: string): boolean {
|
|
533
|
-
|
|
511
|
+
try {
|
|
512
|
+
ec.keyFromPublic(publicKey, 'hex');
|
|
513
|
+
return true;
|
|
514
|
+
} catch {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
534
517
|
}
|
|
535
518
|
|
|
536
519
|
/**
|
|
537
520
|
* Validate that a string is a valid private key
|
|
538
521
|
*/
|
|
539
522
|
static isValidPrivateKey(privateKey: string): boolean {
|
|
540
|
-
|
|
523
|
+
try {
|
|
524
|
+
const keyPair = ec.keyFromPrivate(privateKey);
|
|
525
|
+
// Verify it can derive a public key
|
|
526
|
+
keyPair.getPublic('hex');
|
|
527
|
+
return true;
|
|
528
|
+
} catch {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
541
531
|
}
|
|
542
532
|
|
|
543
533
|
/**
|
|
@@ -545,7 +535,8 @@ export class KeyManager {
|
|
|
545
535
|
* Format: first 8 chars...last 8 chars
|
|
546
536
|
*/
|
|
547
537
|
static shortenPublicKey(publicKey: string): string {
|
|
548
|
-
|
|
538
|
+
if (publicKey.length <= 20) return publicKey;
|
|
539
|
+
return `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}`;
|
|
549
540
|
}
|
|
550
541
|
}
|
|
551
542
|
|
package/src/crypto/polyfill.ts
CHANGED
|
@@ -76,6 +76,5 @@ if (typeof globalObject.crypto === 'undefined') {
|
|
|
76
76
|
(globalObject.crypto as CryptoLike).getRandomValues = cryptoPolyfill.getRandomValues;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
//
|
|
80
|
-
export { Buffer };
|
|
79
|
+
// No longer re-exporting `Buffer` from this module; import from 'buffer' where needed.
|
|
81
80
|
|
|
@@ -3,27 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Handles signing and verification of messages using ECDSA secp256k1.
|
|
5
5
|
* Used for authenticating requests and proving identity ownership.
|
|
6
|
-
*
|
|
7
|
-
* This service provides async methods for cross-platform compatibility (React Native + Node).
|
|
8
|
-
* For Node.js-only synchronous operations, use the node/signatureService module.
|
|
9
6
|
*/
|
|
10
7
|
|
|
8
|
+
import { ec as EC } from 'elliptic';
|
|
11
9
|
import { KeyManager } from './keyManager';
|
|
12
|
-
import {
|
|
13
|
-
verifySignatureCore,
|
|
14
|
-
isValidPublicKey as validatePublicKey,
|
|
15
|
-
isTimestampFresh,
|
|
16
|
-
buildAuthMessage,
|
|
17
|
-
buildRegistrationMessage,
|
|
18
|
-
buildRequestMessage,
|
|
19
|
-
shortenPublicKey as shortenKey,
|
|
20
|
-
getEllipticCurve,
|
|
21
|
-
} from './core';
|
|
22
10
|
|
|
23
11
|
// Lazy import for expo-crypto
|
|
24
12
|
let ExpoCrypto: typeof import('expo-crypto') | null = null;
|
|
25
13
|
|
|
26
|
-
const ec =
|
|
14
|
+
const ec = new EC('secp256k1');
|
|
27
15
|
|
|
28
16
|
/**
|
|
29
17
|
* Check if we're in a React Native environment
|
|
@@ -162,8 +150,9 @@ export class SignatureService {
|
|
|
162
150
|
*/
|
|
163
151
|
static async verify(message: string, signature: string, publicKey: string): Promise<boolean> {
|
|
164
152
|
try {
|
|
153
|
+
const key = ec.keyFromPublic(publicKey, 'hex');
|
|
165
154
|
const messageHash = await sha256(message);
|
|
166
|
-
return
|
|
155
|
+
return key.verify(messageHash, signature);
|
|
167
156
|
} catch {
|
|
168
157
|
return false;
|
|
169
158
|
}
|
|
@@ -184,8 +173,9 @@ export class SignatureService {
|
|
|
184
173
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
185
174
|
const getCrypto = new Function('return require("crypto")');
|
|
186
175
|
const crypto = getCrypto();
|
|
176
|
+
const key = ec.keyFromPublic(publicKey, 'hex');
|
|
187
177
|
const messageHash = crypto.createHash('sha256').update(message).digest('hex');
|
|
188
|
-
return
|
|
178
|
+
return key.verify(messageHash, signature);
|
|
189
179
|
} catch {
|
|
190
180
|
return false;
|
|
191
181
|
}
|
|
@@ -223,7 +213,8 @@ export class SignatureService {
|
|
|
223
213
|
const { message, signature, publicKey, timestamp } = signedMessage;
|
|
224
214
|
|
|
225
215
|
// Check timestamp freshness
|
|
226
|
-
|
|
216
|
+
const now = Date.now();
|
|
217
|
+
if (now - timestamp > maxAgeMs) {
|
|
227
218
|
return false;
|
|
228
219
|
}
|
|
229
220
|
|
|
@@ -243,7 +234,7 @@ export class SignatureService {
|
|
|
243
234
|
}
|
|
244
235
|
|
|
245
236
|
const timestamp = Date.now();
|
|
246
|
-
const message =
|
|
237
|
+
const message = `auth:${publicKey}:${challenge}:${timestamp}`;
|
|
247
238
|
const signature = await SignatureService.sign(message);
|
|
248
239
|
|
|
249
240
|
return {
|
|
@@ -264,36 +255,15 @@ export class SignatureService {
|
|
|
264
255
|
const { challenge: signature, publicKey, timestamp } = response;
|
|
265
256
|
|
|
266
257
|
// Check timestamp freshness
|
|
267
|
-
|
|
258
|
+
const now = Date.now();
|
|
259
|
+
if (now - timestamp > maxAgeMs) {
|
|
268
260
|
return false;
|
|
269
261
|
}
|
|
270
262
|
|
|
271
|
-
const message =
|
|
263
|
+
const message = `auth:${publicKey}:${originalChallenge}:${timestamp}`;
|
|
272
264
|
return SignatureService.verify(message, signature, publicKey);
|
|
273
265
|
}
|
|
274
266
|
|
|
275
|
-
/**
|
|
276
|
-
* Create a registration signature
|
|
277
|
-
* Used when registering a new identity with the server
|
|
278
|
-
* Format matches server expectation: oxy:register:{publicKey}:{timestamp}
|
|
279
|
-
*/
|
|
280
|
-
static async createRegistrationSignature(): Promise<{ signature: string; publicKey: string; timestamp: number }> {
|
|
281
|
-
const publicKey = await KeyManager.getPublicKey();
|
|
282
|
-
if (!publicKey) {
|
|
283
|
-
throw new Error('No identity found. Please create or import an identity first.');
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const timestamp = Date.now();
|
|
287
|
-
const message = buildRegistrationMessage(publicKey, timestamp);
|
|
288
|
-
const signature = await SignatureService.sign(message);
|
|
289
|
-
|
|
290
|
-
return {
|
|
291
|
-
signature,
|
|
292
|
-
publicKey,
|
|
293
|
-
timestamp,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
267
|
/**
|
|
298
268
|
* Sign arbitrary data for API requests
|
|
299
269
|
* Creates a canonical string representation and signs it
|
|
@@ -309,7 +279,13 @@ export class SignatureService {
|
|
|
309
279
|
}
|
|
310
280
|
|
|
311
281
|
const timestamp = Date.now();
|
|
312
|
-
|
|
282
|
+
|
|
283
|
+
// Create canonical string representation
|
|
284
|
+
const sortedKeys = Object.keys(data).sort();
|
|
285
|
+
const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
|
|
286
|
+
const canonicalString = canonicalParts.join('|');
|
|
287
|
+
|
|
288
|
+
const message = `request:${publicKey}:${timestamp}:${canonicalString}`;
|
|
313
289
|
const signature = await SignatureService.sign(message);
|
|
314
290
|
|
|
315
291
|
return {
|