@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
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DeviceManager = void 0;
|
|
7
|
-
var _errors = require("./errors");
|
|
8
|
-
/**
|
|
9
|
-
* Device Manager
|
|
10
|
-
*
|
|
11
|
-
* Manages device identification and device sessions (Native + Web)
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const DEVICE_STORAGE_KEY = 'oxy_device_info';
|
|
15
|
-
/**
|
|
16
|
-
* Device Manager Class
|
|
17
|
-
*/
|
|
18
|
-
class DeviceManager {
|
|
19
|
-
cachedDevice = null;
|
|
20
|
-
constructor(adapter) {
|
|
21
|
-
this.adapter = adapter;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Invalidate cached device
|
|
26
|
-
*/
|
|
27
|
-
invalidateCache() {
|
|
28
|
-
this.cachedDevice = null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get device fingerprint
|
|
33
|
-
*/
|
|
34
|
-
getDeviceFingerprint() {
|
|
35
|
-
const fingerprint = {
|
|
36
|
-
userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown',
|
|
37
|
-
platform: typeof navigator !== 'undefined' ? navigator.platform : 'unknown',
|
|
38
|
-
language: typeof navigator !== 'undefined' ? navigator.language : undefined,
|
|
39
|
-
timezone: typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().timeZone : undefined
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Add screen info if available
|
|
43
|
-
if (typeof screen !== 'undefined') {
|
|
44
|
-
fingerprint.screen = {
|
|
45
|
-
width: screen.width,
|
|
46
|
-
height: screen.height,
|
|
47
|
-
colorDepth: screen.colorDepth
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return fingerprint;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Generate a unique device ID
|
|
55
|
-
*/
|
|
56
|
-
async generateDeviceId() {
|
|
57
|
-
const randomBytes = await this.adapter.crypto.getRandomBytes(32);
|
|
58
|
-
return Array.from(randomBytes, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get a user-friendly device name based on platform
|
|
63
|
-
*/
|
|
64
|
-
getDefaultDeviceName() {
|
|
65
|
-
const fingerprint = this.getDeviceFingerprint();
|
|
66
|
-
const platform = (fingerprint.platform || '').toLowerCase();
|
|
67
|
-
const userAgent = (fingerprint.userAgent || '').toLowerCase();
|
|
68
|
-
if (platform.includes('win')) return 'Windows Computer';
|
|
69
|
-
if (platform.includes('mac')) return 'Mac Computer';
|
|
70
|
-
if (platform.includes('linux')) return 'Linux Computer';
|
|
71
|
-
if (userAgent.includes('iphone')) return 'iPhone';
|
|
72
|
-
if (userAgent.includes('ipad')) return 'iPad';
|
|
73
|
-
if (userAgent.includes('android')) return 'Android Device';
|
|
74
|
-
if (this.adapter.platform === 'web') return 'Web Browser';
|
|
75
|
-
return 'Unknown Device';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get stored device info or create new one
|
|
80
|
-
*/
|
|
81
|
-
async getCurrentDevice() {
|
|
82
|
-
if (this.cachedDevice) {
|
|
83
|
-
return this.cachedDevice;
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const stored = await this.adapter.storage.get(DEVICE_STORAGE_KEY);
|
|
87
|
-
if (stored) {
|
|
88
|
-
const deviceInfo = JSON.parse(stored);
|
|
89
|
-
|
|
90
|
-
// Update last used timestamp
|
|
91
|
-
deviceInfo.lastUsed = new Date().toISOString();
|
|
92
|
-
await this.saveDeviceInfo(deviceInfo);
|
|
93
|
-
const device = {
|
|
94
|
-
deviceId: deviceInfo.deviceId,
|
|
95
|
-
deviceName: deviceInfo.deviceName,
|
|
96
|
-
deviceType: this.getDeviceType(),
|
|
97
|
-
platform: this.adapter.platform === 'native' ? 'ios' : 'web',
|
|
98
|
-
// Simplified
|
|
99
|
-
fingerprint: deviceInfo.fingerprint,
|
|
100
|
-
createdAt: deviceInfo.createdAt,
|
|
101
|
-
updatedAt: deviceInfo.lastUsed
|
|
102
|
-
};
|
|
103
|
-
this.cachedDevice = device;
|
|
104
|
-
return device;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Create new device info
|
|
108
|
-
return await this.createNewDevice();
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.error('[DeviceManager] Error getting device info:', error);
|
|
111
|
-
return await this.createNewDevice();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Create new device info and store it
|
|
117
|
-
*/
|
|
118
|
-
async createNewDevice() {
|
|
119
|
-
const deviceId = await this.generateDeviceId();
|
|
120
|
-
const fingerprint = JSON.stringify(this.getDeviceFingerprint());
|
|
121
|
-
const now = new Date().toISOString();
|
|
122
|
-
const device = {
|
|
123
|
-
deviceId,
|
|
124
|
-
deviceName: this.getDefaultDeviceName(),
|
|
125
|
-
deviceType: this.getDeviceType(),
|
|
126
|
-
platform: this.adapter.platform === 'native' ? 'ios' : 'web',
|
|
127
|
-
// Simplified
|
|
128
|
-
fingerprint,
|
|
129
|
-
createdAt: now,
|
|
130
|
-
updatedAt: now
|
|
131
|
-
};
|
|
132
|
-
const deviceInfo = {
|
|
133
|
-
deviceId,
|
|
134
|
-
deviceName: device.deviceName,
|
|
135
|
-
fingerprint,
|
|
136
|
-
createdAt: now,
|
|
137
|
-
lastUsed: now
|
|
138
|
-
};
|
|
139
|
-
await this.saveDeviceInfo(deviceInfo);
|
|
140
|
-
this.cachedDevice = device;
|
|
141
|
-
return device;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Get device type
|
|
146
|
-
*/
|
|
147
|
-
getDeviceType() {
|
|
148
|
-
if (this.adapter.platform === 'web') {
|
|
149
|
-
return 'desktop'; // Simplified - could detect mobile web
|
|
150
|
-
}
|
|
151
|
-
// For native, would need Platform.OS detection
|
|
152
|
-
return 'mobile';
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Save device info to storage
|
|
157
|
-
*/
|
|
158
|
-
async saveDeviceInfo(deviceInfo) {
|
|
159
|
-
try {
|
|
160
|
-
await this.adapter.storage.set(DEVICE_STORAGE_KEY, JSON.stringify(deviceInfo));
|
|
161
|
-
} catch (error) {
|
|
162
|
-
console.error('[DeviceManager] Error saving device info:', error);
|
|
163
|
-
throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.DEVICE_CREATION_FAILED, `Failed to save device info: ${error instanceof Error ? error.message : String(error)}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Update device name
|
|
169
|
-
*/
|
|
170
|
-
async updateDeviceName(deviceName) {
|
|
171
|
-
const device = await this.getCurrentDevice();
|
|
172
|
-
if (!device) {
|
|
173
|
-
throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.DEVICE_NOT_FOUND, 'Device not found');
|
|
174
|
-
}
|
|
175
|
-
device.deviceName = deviceName;
|
|
176
|
-
device.updatedAt = new Date().toISOString();
|
|
177
|
-
const deviceInfo = {
|
|
178
|
-
deviceId: device.deviceId,
|
|
179
|
-
deviceName: device.deviceName,
|
|
180
|
-
fingerprint: device.fingerprint,
|
|
181
|
-
createdAt: device.createdAt || new Date().toISOString(),
|
|
182
|
-
lastUsed: device.updatedAt
|
|
183
|
-
};
|
|
184
|
-
await this.saveDeviceInfo(deviceInfo);
|
|
185
|
-
this.cachedDevice = device;
|
|
186
|
-
return device;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Get device info for session creation
|
|
191
|
-
*/
|
|
192
|
-
async getDeviceInfo() {
|
|
193
|
-
const device = await this.getCurrentDevice();
|
|
194
|
-
if (!device) {
|
|
195
|
-
throw (0, _errors.createIdentitySessionError)(_errors.IdentitySessionErrorCodes.DEVICE_NOT_FOUND, 'Device not found');
|
|
196
|
-
}
|
|
197
|
-
const fingerprint = this.getDeviceFingerprint();
|
|
198
|
-
return {
|
|
199
|
-
deviceName: device.deviceName,
|
|
200
|
-
deviceType: device.deviceType,
|
|
201
|
-
platform: device.platform,
|
|
202
|
-
browser: typeof navigator !== 'undefined' ? this.getBrowserName() : undefined,
|
|
203
|
-
os: typeof navigator !== 'undefined' ? navigator.platform : undefined,
|
|
204
|
-
lastActive: new Date().toISOString(),
|
|
205
|
-
userAgent: fingerprint.userAgent,
|
|
206
|
-
fingerprint: device.fingerprint
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Get browser name from user agent
|
|
212
|
-
*/
|
|
213
|
-
getBrowserName() {
|
|
214
|
-
if (typeof navigator === 'undefined') return undefined;
|
|
215
|
-
const ua = navigator.userAgent.toLowerCase();
|
|
216
|
-
if (ua.includes('chrome')) return 'Chrome';
|
|
217
|
-
if (ua.includes('firefox')) return 'Firefox';
|
|
218
|
-
if (ua.includes('safari') && !ua.includes('chrome')) return 'Safari';
|
|
219
|
-
if (ua.includes('edge')) return 'Edge';
|
|
220
|
-
if (ua.includes('opera')) return 'Opera';
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Clear stored device info
|
|
226
|
-
*/
|
|
227
|
-
async clearDeviceInfo() {
|
|
228
|
-
try {
|
|
229
|
-
await this.adapter.storage.remove(DEVICE_STORAGE_KEY);
|
|
230
|
-
this.invalidateCache();
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.error('[DeviceManager] Error clearing device info:', error);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
exports.DeviceManager = DeviceManager;
|
|
237
|
-
//# sourceMappingURL=DeviceManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_errors","require","DEVICE_STORAGE_KEY","DeviceManager","cachedDevice","constructor","adapter","invalidateCache","getDeviceFingerprint","fingerprint","userAgent","navigator","platform","language","undefined","timezone","Intl","DateTimeFormat","resolvedOptions","timeZone","screen","width","height","colorDepth","generateDeviceId","randomBytes","crypto","getRandomBytes","Array","from","byte","toString","padStart","join","getDefaultDeviceName","toLowerCase","includes","getCurrentDevice","stored","storage","get","deviceInfo","JSON","parse","lastUsed","Date","toISOString","saveDeviceInfo","device","deviceId","deviceName","deviceType","getDeviceType","createdAt","updatedAt","createNewDevice","error","console","stringify","now","set","createIdentitySessionError","IdentitySessionErrorCodes","DEVICE_CREATION_FAILED","Error","message","String","updateDeviceName","DEVICE_NOT_FOUND","getDeviceInfo","browser","getBrowserName","os","lastActive","ua","clearDeviceInfo","remove","exports"],"sourceRoot":"../../../../src","sources":["core/identity-session/DeviceManager.ts"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;;AASA,MAAMC,kBAAkB,GAAG,iBAAiB;AAU5C;AACA;AACA;AACO,MAAMC,aAAa,CAAC;EAEjBC,YAAY,GAAkB,IAAI;EAE1CC,WAAWA,CAACC,OAAwB,EAAE;IACpC,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;EACEC,eAAeA,CAAA,EAAS;IACtB,IAAI,CAACH,YAAY,GAAG,IAAI;EAC1B;;EAEA;AACF;AACA;EACUI,oBAAoBA,CAAA,EAA4B;IACtD,MAAMC,WAAoC,GAAG;MAC3CC,SAAS,EAAE,OAAOC,SAAS,KAAK,WAAW,GAAGA,SAAS,CAACD,SAAS,GAAG,SAAS;MAC7EE,QAAQ,EAAE,OAAOD,SAAS,KAAK,WAAW,GAAGA,SAAS,CAACC,QAAQ,GAAG,SAAS;MAC3EC,QAAQ,EAAE,OAAOF,SAAS,KAAK,WAAW,GAAGA,SAAS,CAACE,QAAQ,GAAGC,SAAS;MAC3EC,QAAQ,EAAE,OAAOC,IAAI,KAAK,WAAW,GAAGA,IAAI,CAACC,cAAc,CAAC,CAAC,CAACC,eAAe,CAAC,CAAC,CAACC,QAAQ,GAAGL;IAC7F,CAAC;;IAED;IACA,IAAI,OAAOM,MAAM,KAAK,WAAW,EAAE;MACjCX,WAAW,CAACW,MAAM,GAAG;QACnBC,KAAK,EAAED,MAAM,CAACC,KAAK;QACnBC,MAAM,EAAEF,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BAAkB,CAAC;MACrD,IAAI,CAACK,eAAe,CAAC,CAAC;IACxB,CAAC,CAAC,OAAOiD,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,6CAA6C,EAAEA,KAAK,CAAC;IACrE;EACF;AACF;AAACqB,OAAA,CAAA1E,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
# Identity Session Core - Integration Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The Identity Session Core provides a unified API for identity and session management across all platforms (React Native, Web, Node). All identity and session operations go through this core - never access `KeyManager`, storage, or APIs directly.
|
|
6
|
-
|
|
7
|
-
## Architecture
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
UI/Hooks Layer
|
|
11
|
-
↓
|
|
12
|
-
IdentitySessionCore (unified API)
|
|
13
|
-
↓
|
|
14
|
-
Managers (Identity, Session, Device, Refresh)
|
|
15
|
-
↓
|
|
16
|
-
Platform Adapters (Expo 54, Node)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Key Principles
|
|
20
|
-
|
|
21
|
-
1. **Frontend: Use `useOxy()` hook** - This is the only API you need for React/React Native applications
|
|
22
|
-
2. **Backend: Use `createIdentitySessionCore()`** - Only for Node.js/backend applications
|
|
23
|
-
3. **Never access storage, APIs, or KeyManager directly** - Always go through the core or `useOxy()`
|
|
24
|
-
4. **Identity operations are NATIVE ONLY** - Web cannot create/import identities
|
|
25
|
-
5. **Session operations work on NATIVE + WEB** - sessions can be used on both platforms
|
|
26
|
-
6. **Models are aligned with backend** - same types, same error codes
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install @oxyhq/services
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Basic Usage
|
|
35
|
-
|
|
36
|
-
### Using the React Hook (Recommended)
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { OxyProvider, useOxy } from '@oxyhq/services';
|
|
40
|
-
import { Platform } from 'react-native';
|
|
41
|
-
|
|
42
|
-
function App() {
|
|
43
|
-
return (
|
|
44
|
-
<OxyProvider baseURL="https://api.example.com">
|
|
45
|
-
<MyComponent />
|
|
46
|
-
</OxyProvider>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function MyComponent() {
|
|
51
|
-
const { createIdentity, signIn, hasIdentity, isLoading, error } = useOxy();
|
|
52
|
-
|
|
53
|
-
const handleCreateIdentity = async () => {
|
|
54
|
-
if (Platform.OS === 'web') {
|
|
55
|
-
alert('Identity creation is only available on native platforms');
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const result = await createIdentity('myusername');
|
|
61
|
-
console.log('Identity created, synced:', result.synced);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
console.error('Failed to create identity:', err);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const handleSignIn = async () => {
|
|
68
|
-
try {
|
|
69
|
-
const user = await signIn('My Device');
|
|
70
|
-
console.log('Signed in:', user);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.error('Failed to sign in:', err);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
if (error) return <Text>Error: {error}</Text>;
|
|
77
|
-
if (isLoading) return <Text>Loading...</Text>;
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<View>
|
|
81
|
-
<Button onPress={handleCreateIdentity} title="Create Identity" />
|
|
82
|
-
<Button onPress={handleSignIn} title="Sign In" />
|
|
83
|
-
</View>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Direct Core Usage (Backend/Node.js Only)
|
|
89
|
-
|
|
90
|
-
**Note:** For frontend applications, always use `useOxy()` hook. Direct core usage is only for backend/Node.js applications.
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import { createIdentitySessionCore } from '@oxyhq/services';
|
|
94
|
-
|
|
95
|
-
// Backend/Node.js only
|
|
96
|
-
const core = await createIdentitySessionCore('https://api.example.com');
|
|
97
|
-
const identity = await core.getCurrentIdentity();
|
|
98
|
-
const session = await core.getSession();
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## API Reference
|
|
102
|
-
|
|
103
|
-
### Using `useOxy` Hook (Recommended)
|
|
104
|
-
|
|
105
|
-
The `useOxy` hook provides all identity and session operations through a simple, reactive API:
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
const {
|
|
109
|
-
// Identity (Native Only)
|
|
110
|
-
createIdentity,
|
|
111
|
-
importIdentity,
|
|
112
|
-
deleteIdentityAndClearAccount,
|
|
113
|
-
hasIdentity,
|
|
114
|
-
getPublicKey,
|
|
115
|
-
isIdentitySynced,
|
|
116
|
-
syncIdentity,
|
|
117
|
-
identity,
|
|
118
|
-
publicKey,
|
|
119
|
-
identitySyncState,
|
|
120
|
-
|
|
121
|
-
// Session (Native + Web)
|
|
122
|
-
signIn,
|
|
123
|
-
logout,
|
|
124
|
-
logoutAll,
|
|
125
|
-
switchSession,
|
|
126
|
-
refreshSession,
|
|
127
|
-
session,
|
|
128
|
-
sessions,
|
|
129
|
-
activeSessionId,
|
|
130
|
-
isAuthenticated,
|
|
131
|
-
|
|
132
|
-
// Device (Native + Web)
|
|
133
|
-
getDeviceSessions,
|
|
134
|
-
logoutAllDeviceSessions,
|
|
135
|
-
updateDeviceName,
|
|
136
|
-
device,
|
|
137
|
-
|
|
138
|
-
// State
|
|
139
|
-
user,
|
|
140
|
-
isLoading,
|
|
141
|
-
isTokenReady,
|
|
142
|
-
isStorageReady,
|
|
143
|
-
error,
|
|
144
|
-
} = useOxy();
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Identity Operations (Native Only)
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
// Create new identity
|
|
151
|
-
const result = await createIdentity(username?);
|
|
152
|
-
// result.synced indicates if identity was synced with backend
|
|
153
|
-
|
|
154
|
-
// Import identity from backup
|
|
155
|
-
const result = await importIdentity(backupData, password, username?);
|
|
156
|
-
// result.synced indicates if identity was synced with backend
|
|
157
|
-
|
|
158
|
-
// Delete identity and clear all account data
|
|
159
|
-
await deleteIdentityAndClearAccount(skipBackup?, force?, userConfirmed?);
|
|
160
|
-
|
|
161
|
-
// Check if identity exists
|
|
162
|
-
const has = await hasIdentity();
|
|
163
|
-
|
|
164
|
-
// Get public key
|
|
165
|
-
const publicKey = await getPublicKey();
|
|
166
|
-
|
|
167
|
-
// Check if identity is synced
|
|
168
|
-
const synced = await isIdentitySynced();
|
|
169
|
-
|
|
170
|
-
// Manually sync identity
|
|
171
|
-
const user = await syncIdentity(username?);
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Session Operations (Native + Web)
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
// Sign in (create session)
|
|
178
|
-
const user = await signIn(deviceName?);
|
|
179
|
-
|
|
180
|
-
// Logout (invalidate current or specific session)
|
|
181
|
-
await logout(sessionId?);
|
|
182
|
-
|
|
183
|
-
// Logout all sessions
|
|
184
|
-
await logoutAll();
|
|
185
|
-
|
|
186
|
-
// Switch to different session
|
|
187
|
-
await switchSession(sessionId);
|
|
188
|
-
|
|
189
|
-
// Refresh current session
|
|
190
|
-
const session = await refreshSession();
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Device Operations (Native + Web)
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
// Get all device sessions
|
|
197
|
-
const deviceSessions = await getDeviceSessions();
|
|
198
|
-
|
|
199
|
-
// Logout all sessions for current device
|
|
200
|
-
await logoutAllDeviceSessions();
|
|
201
|
-
|
|
202
|
-
// Update device name
|
|
203
|
-
await updateDeviceName(deviceName);
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Direct Core Usage (Advanced)
|
|
207
|
-
|
|
208
|
-
For advanced use cases, you can access the core directly:
|
|
209
|
-
|
|
210
|
-
```typescript
|
|
211
|
-
import { createIdentitySessionCore } from '@oxyhq/services';
|
|
212
|
-
|
|
213
|
-
const core = await createIdentitySessionCore('https://api.example.com');
|
|
214
|
-
const identity = await core.getCurrentIdentity();
|
|
215
|
-
const session = await core.getSession();
|
|
216
|
-
|
|
217
|
-
// Subscribe to events
|
|
218
|
-
const unsubscribe = core.subscribe((event) => {
|
|
219
|
-
switch (event.type) {
|
|
220
|
-
case 'identity:created':
|
|
221
|
-
console.log('Identity created:', event.identity);
|
|
222
|
-
break;
|
|
223
|
-
case 'session:created':
|
|
224
|
-
console.log('Session created:', event.session);
|
|
225
|
-
break;
|
|
226
|
-
case 'session:invalidated':
|
|
227
|
-
console.log('Session invalidated:', event.sessionId);
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// Cleanup
|
|
233
|
-
unsubscribe();
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
## Error Handling
|
|
237
|
-
|
|
238
|
-
All errors use unified error codes:
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
import {
|
|
242
|
-
IdentitySessionError,
|
|
243
|
-
IdentitySessionErrorCodes
|
|
244
|
-
} from '@oxyhq/services';
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
await createIdentity();
|
|
248
|
-
} catch (error) {
|
|
249
|
-
if (error instanceof IdentitySessionError) {
|
|
250
|
-
switch (error.code) {
|
|
251
|
-
case IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB:
|
|
252
|
-
// Handle web platform error
|
|
253
|
-
break;
|
|
254
|
-
case IdentitySessionErrorCodes.IDENTITY_ALREADY_EXISTS:
|
|
255
|
-
// Handle already exists error
|
|
256
|
-
break;
|
|
257
|
-
default:
|
|
258
|
-
console.error('Error:', error.message);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Type Exports
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
import type {
|
|
268
|
-
Identity,
|
|
269
|
-
Session,
|
|
270
|
-
Device,
|
|
271
|
-
DeviceInfo,
|
|
272
|
-
BackupData,
|
|
273
|
-
IdentitySessionEvent,
|
|
274
|
-
} from '@oxyhq/services';
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
## Platform Detection
|
|
278
|
-
|
|
279
|
-
The core automatically detects the platform and validates operations. Identity operations will throw `IDENTITY_NOT_AVAILABLE_ON_WEB` on web platforms.
|
|
280
|
-
|
|
281
|
-
## Notes
|
|
282
|
-
|
|
283
|
-
- The core handles all platform-specific logic internally
|
|
284
|
-
- Storage, crypto, and fetch are abstracted through platform adapters
|
|
285
|
-
- All models are aligned with backend (IUser, ISession)
|
|
286
|
-
- Error codes are unified across frontend and backend
|
|
287
|
-
- The core is designed to be "plugged in" to any Oxy app (Mention, Homiio, Noted, etc.)
|