@oxyhq/services 5.16.39 → 5.16.41

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.
Files changed (267) hide show
  1. package/lib/commonjs/adapters/expo/crypto.js +56 -0
  2. package/lib/commonjs/adapters/expo/crypto.js.map +1 -0
  3. package/lib/commonjs/adapters/expo/fetch.js +30 -0
  4. package/lib/commonjs/adapters/expo/fetch.js.map +1 -0
  5. package/lib/commonjs/adapters/expo/index.js +48 -0
  6. package/lib/commonjs/adapters/expo/index.js.map +1 -0
  7. package/lib/commonjs/adapters/expo/storage.js +201 -0
  8. package/lib/commonjs/adapters/expo/storage.js.map +1 -0
  9. package/lib/commonjs/adapters/index.js +41 -0
  10. package/lib/commonjs/adapters/index.js.map +1 -0
  11. package/lib/commonjs/adapters/node/crypto.js +40 -0
  12. package/lib/commonjs/adapters/node/crypto.js.map +1 -0
  13. package/lib/commonjs/adapters/node/fetch.js +62 -0
  14. package/lib/commonjs/adapters/node/fetch.js.map +1 -0
  15. package/lib/commonjs/adapters/node/index.js +34 -0
  16. package/lib/commonjs/adapters/node/index.js.map +1 -0
  17. package/lib/commonjs/adapters/node/storage.js +163 -0
  18. package/lib/commonjs/adapters/node/storage.js.map +1 -0
  19. package/lib/commonjs/core/identity-session/DeviceManager.js +237 -0
  20. package/lib/commonjs/core/identity-session/DeviceManager.js.map +1 -0
  21. package/lib/commonjs/core/identity-session/INTEGRATION_GUIDE.md +287 -0
  22. package/lib/commonjs/core/identity-session/IdentityManager.js +400 -0
  23. package/lib/commonjs/core/identity-session/IdentityManager.js.map +1 -0
  24. package/lib/commonjs/core/identity-session/IdentitySessionCore.js +394 -0
  25. package/lib/commonjs/core/identity-session/IdentitySessionCore.js.map +1 -0
  26. package/lib/commonjs/core/identity-session/RefreshManager.js +137 -0
  27. package/lib/commonjs/core/identity-session/RefreshManager.js.map +1 -0
  28. package/lib/commonjs/core/identity-session/SessionManager.js +427 -0
  29. package/lib/commonjs/core/identity-session/SessionManager.js.map +1 -0
  30. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js +24 -0
  31. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js.map +1 -0
  32. package/lib/commonjs/core/identity-session/errors.js +176 -0
  33. package/lib/commonjs/core/identity-session/errors.js.map +1 -0
  34. package/lib/commonjs/core/identity-session/index.js +80 -0
  35. package/lib/commonjs/core/identity-session/index.js.map +1 -0
  36. package/lib/commonjs/core/identity-session/types.js +2 -0
  37. package/lib/commonjs/core/identity-session/types.js.map +1 -0
  38. package/lib/commonjs/core/index.js +2 -21
  39. package/lib/commonjs/core/index.js.map +1 -1
  40. package/lib/commonjs/index.js +58 -8
  41. package/lib/commonjs/index.js.map +1 -1
  42. package/lib/commonjs/models/interfaces.js +7 -0
  43. package/lib/commonjs/models/interfaces.js.map +1 -1
  44. package/lib/commonjs/ui/context/OxyContext.js +434 -820
  45. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  46. package/lib/commonjs/ui/hooks/useAvatarPicker.js +52 -0
  47. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +1 -0
  48. package/lib/commonjs/ui/hooks/useIdentityTransfer.js +125 -0
  49. package/lib/commonjs/ui/hooks/useIdentityTransfer.js.map +1 -0
  50. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js +81 -0
  51. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js.map +1 -0
  52. package/lib/commonjs/ui/screens/AccountCenterScreen.js +7 -2
  53. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  54. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +12 -5
  55. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  56. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +2 -2
  57. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  58. package/lib/commonjs/ui/screens/ProfileScreen.js +6 -6
  59. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  60. package/lib/commonjs/ui/utils/sessionHelpers.js +7 -1
  61. package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
  62. package/lib/commonjs/utils/index.js +0 -7
  63. package/lib/commonjs/utils/index.js.map +1 -1
  64. package/lib/commonjs/utils/sessionUtils.js +8 -1
  65. package/lib/commonjs/utils/sessionUtils.js.map +1 -1
  66. package/lib/module/adapters/expo/crypto.js +51 -0
  67. package/lib/module/adapters/expo/crypto.js.map +1 -0
  68. package/lib/module/adapters/expo/fetch.js +26 -0
  69. package/lib/module/adapters/expo/fetch.js.map +1 -0
  70. package/lib/module/adapters/expo/index.js +45 -0
  71. package/lib/module/adapters/expo/index.js.map +1 -0
  72. package/lib/module/adapters/expo/storage.js +198 -0
  73. package/lib/module/adapters/expo/storage.js.map +1 -0
  74. package/lib/module/adapters/index.js +38 -0
  75. package/lib/module/adapters/index.js.map +1 -0
  76. package/lib/module/adapters/node/crypto.js +36 -0
  77. package/lib/module/adapters/node/crypto.js.map +1 -0
  78. package/lib/module/adapters/node/fetch.js +57 -0
  79. package/lib/module/adapters/node/fetch.js.map +1 -0
  80. package/lib/module/adapters/node/index.js +31 -0
  81. package/lib/module/adapters/node/index.js.map +1 -0
  82. package/lib/module/adapters/node/storage.js +159 -0
  83. package/lib/module/adapters/node/storage.js.map +1 -0
  84. package/lib/module/core/identity-session/DeviceManager.js +232 -0
  85. package/lib/module/core/identity-session/DeviceManager.js.map +1 -0
  86. package/lib/module/core/identity-session/INTEGRATION_GUIDE.md +287 -0
  87. package/lib/module/core/identity-session/IdentityManager.js +395 -0
  88. package/lib/module/core/identity-session/IdentityManager.js.map +1 -0
  89. package/lib/module/core/identity-session/IdentitySessionCore.js +390 -0
  90. package/lib/module/core/identity-session/IdentitySessionCore.js.map +1 -0
  91. package/lib/module/core/identity-session/RefreshManager.js +132 -0
  92. package/lib/module/core/identity-session/RefreshManager.js.map +1 -0
  93. package/lib/module/core/identity-session/SessionManager.js +422 -0
  94. package/lib/module/core/identity-session/SessionManager.js.map +1 -0
  95. package/lib/module/core/identity-session/createIdentitySessionCore.js +21 -0
  96. package/lib/module/core/identity-session/createIdentitySessionCore.js.map +1 -0
  97. package/lib/module/core/identity-session/errors.js +170 -0
  98. package/lib/module/core/identity-session/errors.js.map +1 -0
  99. package/lib/module/core/identity-session/index.js +17 -0
  100. package/lib/module/core/identity-session/index.js.map +1 -0
  101. package/lib/module/core/identity-session/types.js +2 -0
  102. package/lib/module/core/identity-session/types.js.map +1 -0
  103. package/lib/module/core/index.js +2 -3
  104. package/lib/module/core/index.js.map +1 -1
  105. package/lib/module/index.js +12 -2
  106. package/lib/module/index.js.map +1 -1
  107. package/lib/module/models/interfaces.js +7 -0
  108. package/lib/module/models/interfaces.js.map +1 -1
  109. package/lib/module/ui/context/OxyContext.js +436 -822
  110. package/lib/module/ui/context/OxyContext.js.map +1 -1
  111. package/lib/module/ui/hooks/useAvatarPicker.js +48 -0
  112. package/lib/module/ui/hooks/useAvatarPicker.js.map +1 -0
  113. package/lib/module/ui/hooks/useIdentityTransfer.js +121 -0
  114. package/lib/module/ui/hooks/useIdentityTransfer.js.map +1 -0
  115. package/lib/module/ui/hooks/useTransferCodesPersistence.js +77 -0
  116. package/lib/module/ui/hooks/useTransferCodesPersistence.js.map +1 -0
  117. package/lib/module/ui/screens/AccountCenterScreen.js +7 -2
  118. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  119. package/lib/module/ui/screens/AccountSettingsScreen.js +12 -5
  120. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  121. package/lib/module/ui/screens/AccountSwitcherScreen.js +2 -2
  122. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  123. package/lib/module/ui/screens/ProfileScreen.js +6 -6
  124. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  125. package/lib/module/ui/utils/sessionHelpers.js +7 -1
  126. package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
  127. package/lib/module/utils/index.js +2 -1
  128. package/lib/module/utils/index.js.map +1 -1
  129. package/lib/module/utils/sessionUtils.js +8 -1
  130. package/lib/module/utils/sessionUtils.js.map +1 -1
  131. package/lib/typescript/adapters/expo/crypto.d.ts +17 -0
  132. package/lib/typescript/adapters/expo/crypto.d.ts.map +1 -0
  133. package/lib/typescript/adapters/expo/fetch.d.ts +16 -0
  134. package/lib/typescript/adapters/expo/fetch.d.ts.map +1 -0
  135. package/lib/typescript/adapters/expo/index.d.ts +23 -0
  136. package/lib/typescript/adapters/expo/index.d.ts.map +1 -0
  137. package/lib/typescript/adapters/expo/storage.d.ts +23 -0
  138. package/lib/typescript/adapters/expo/storage.d.ts.map +1 -0
  139. package/lib/typescript/adapters/index.d.ts +13 -0
  140. package/lib/typescript/adapters/index.d.ts.map +1 -0
  141. package/lib/typescript/adapters/node/crypto.d.ts +17 -0
  142. package/lib/typescript/adapters/node/crypto.d.ts.map +1 -0
  143. package/lib/typescript/adapters/node/fetch.d.ts +16 -0
  144. package/lib/typescript/adapters/node/fetch.d.ts.map +1 -0
  145. package/lib/typescript/adapters/node/index.d.ts +23 -0
  146. package/lib/typescript/adapters/node/index.d.ts.map +1 -0
  147. package/lib/typescript/adapters/node/storage.d.ts +23 -0
  148. package/lib/typescript/adapters/node/storage.d.ts.map +1 -0
  149. package/lib/typescript/core/identity-session/DeviceManager.d.ts +64 -0
  150. package/lib/typescript/core/identity-session/DeviceManager.d.ts.map +1 -0
  151. package/lib/typescript/core/identity-session/IdentityManager.d.ts +88 -0
  152. package/lib/typescript/core/identity-session/IdentityManager.d.ts.map +1 -0
  153. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts +141 -0
  154. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts.map +1 -0
  155. package/lib/typescript/core/identity-session/RefreshManager.d.ts +36 -0
  156. package/lib/typescript/core/identity-session/RefreshManager.d.ts.map +1 -0
  157. package/lib/typescript/core/identity-session/SessionManager.d.ts +104 -0
  158. package/lib/typescript/core/identity-session/SessionManager.d.ts.map +1 -0
  159. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts +11 -0
  160. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts.map +1 -0
  161. package/lib/typescript/core/identity-session/errors.d.ts +63 -0
  162. package/lib/typescript/core/identity-session/errors.d.ts.map +1 -0
  163. package/lib/typescript/core/identity-session/index.d.ts +14 -0
  164. package/lib/typescript/core/identity-session/index.d.ts.map +1 -0
  165. package/lib/typescript/core/identity-session/types.d.ts +196 -0
  166. package/lib/typescript/core/identity-session/types.d.ts.map +1 -0
  167. package/lib/typescript/core/index.d.ts +1 -3
  168. package/lib/typescript/core/index.d.ts.map +1 -1
  169. package/lib/typescript/core/mixins/index.d.ts +2 -2
  170. package/lib/typescript/index.d.ts +3 -2
  171. package/lib/typescript/index.d.ts.map +1 -1
  172. package/lib/typescript/models/interfaces.d.ts +5 -36
  173. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  174. package/lib/typescript/models/session.d.ts +3 -16
  175. package/lib/typescript/models/session.d.ts.map +1 -1
  176. package/lib/typescript/ui/context/OxyContext.d.ts +2 -25
  177. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  178. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +7 -8
  179. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  180. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +1 -1
  181. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
  182. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +5 -5
  183. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  184. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +18 -0
  185. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +1 -0
  186. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts +24 -0
  187. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts.map +1 -0
  188. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts +6 -0
  189. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts.map +1 -0
  190. package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
  191. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  192. package/lib/typescript/ui/utils/sessionHelpers.d.ts +1 -0
  193. package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
  194. package/lib/typescript/utils/index.d.ts +0 -2
  195. package/lib/typescript/utils/index.d.ts.map +1 -1
  196. package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
  197. package/package.json +1 -1
  198. package/src/adapters/expo/crypto.ts +55 -0
  199. package/src/adapters/expo/fetch.ts +28 -0
  200. package/src/adapters/expo/index.ts +51 -0
  201. package/src/adapters/expo/storage.ts +228 -0
  202. package/src/adapters/index.ts +40 -0
  203. package/src/adapters/node/crypto.ts +39 -0
  204. package/src/adapters/node/fetch.ts +59 -0
  205. package/src/adapters/node/index.ts +37 -0
  206. package/src/adapters/node/storage.ts +170 -0
  207. package/src/core/identity-session/DeviceManager.ts +273 -0
  208. package/src/core/identity-session/INTEGRATION_GUIDE.md +287 -0
  209. package/src/core/identity-session/IdentityManager.ts +474 -0
  210. package/src/core/identity-session/IdentitySessionCore.ts +464 -0
  211. package/src/core/identity-session/RefreshManager.ts +189 -0
  212. package/src/core/identity-session/SessionManager.ts +500 -0
  213. package/src/core/identity-session/createIdentitySessionCore.ts +19 -0
  214. package/src/core/identity-session/errors.ts +197 -0
  215. package/src/core/identity-session/index.ts +15 -0
  216. package/src/core/identity-session/types.ts +188 -0
  217. package/src/core/index.ts +3 -4
  218. package/src/index.ts +28 -3
  219. package/src/models/interfaces.ts +12 -39
  220. package/src/models/session.ts +6 -16
  221. package/src/ui/context/OxyContext.tsx +442 -871
  222. package/src/ui/hooks/auth/index.ts +1 -0
  223. package/src/ui/hooks/useAvatarPicker.ts +62 -0
  224. package/src/ui/hooks/useIdentityTransfer.ts +135 -0
  225. package/src/ui/hooks/useTransferCodesPersistence.ts +80 -0
  226. package/src/ui/screens/AccountCenterScreen.tsx +7 -2
  227. package/src/ui/screens/AccountSettingsScreen.tsx +15 -8
  228. package/src/ui/screens/AccountSwitcherScreen.tsx +2 -2
  229. package/src/ui/screens/ProfileScreen.tsx +10 -10
  230. package/src/ui/utils/sessionHelpers.ts +7 -0
  231. package/src/utils/index.ts +1 -2
  232. package/src/utils/sessionUtils.ts +8 -0
  233. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +0 -704
  234. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +0 -1
  235. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +0 -73
  236. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js.map +0 -1
  237. package/lib/commonjs/ui/hooks/useDeviceManagement.js +0 -73
  238. package/lib/commonjs/ui/hooks/useDeviceManagement.js.map +0 -1
  239. package/lib/commonjs/ui/hooks/useSessionManagement.js +0 -281
  240. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +0 -1
  241. package/lib/commonjs/utils/deviceManager.js +0 -177
  242. package/lib/commonjs/utils/deviceManager.js.map +0 -1
  243. package/lib/module/ui/context/hooks/useAuthOperations.js +0 -698
  244. package/lib/module/ui/context/hooks/useAuthOperations.js.map +0 -1
  245. package/lib/module/ui/context/hooks/useDeviceManagement.js +0 -68
  246. package/lib/module/ui/context/hooks/useDeviceManagement.js.map +0 -1
  247. package/lib/module/ui/hooks/useDeviceManagement.js +0 -68
  248. package/lib/module/ui/hooks/useDeviceManagement.js.map +0 -1
  249. package/lib/module/ui/hooks/useSessionManagement.js +0 -276
  250. package/lib/module/ui/hooks/useSessionManagement.js.map +0 -1
  251. package/lib/module/utils/deviceManager.js +0 -171
  252. package/lib/module/utils/deviceManager.js.map +0 -1
  253. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +0 -59
  254. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +0 -1
  255. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts +0 -27
  256. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts.map +0 -1
  257. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts +0 -27
  258. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts.map +0 -1
  259. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +0 -41
  260. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +0 -1
  261. package/lib/typescript/utils/deviceManager.d.ts +0 -66
  262. package/lib/typescript/utils/deviceManager.d.ts.map +0 -1
  263. package/src/ui/context/hooks/useAuthOperations.ts +0 -773
  264. package/src/ui/context/hooks/useDeviceManagement.ts +0 -108
  265. package/src/ui/hooks/useDeviceManagement.ts +0 -108
  266. package/src/ui/hooks/useSessionManagement.ts +0 -401
  267. package/src/utils/deviceManager.ts +0 -198
@@ -1,773 +0,0 @@
1
- import { useCallback } from 'react';
2
- import type { ApiError, User } from '../../../models/interfaces';
3
- import type { AuthState } from '../../stores/authStore';
4
- import type { ClientSession, SessionLoginResponse } from '../../../models/session';
5
- import { DeviceManager } from '../../../utils/deviceManager';
6
- import { fetchSessionsWithFallback, mapSessionsToClient } from '../../utils/sessionHelpers';
7
- import { handleAuthError, isInvalidSessionError } from '../../utils/errorHandlers';
8
- import type { StorageInterface } from '../../utils/storageHelpers';
9
- import type { OxyServices } from '../../../core';
10
- import { KeyManager, SignatureService, type BackupData } from '../../../crypto';
11
-
12
- export interface UseAuthOperationsOptions {
13
- oxyServices: OxyServices;
14
- storage: StorageInterface | null;
15
- sessions: ClientSession[];
16
- activeSessionId: string | null;
17
- setActiveSessionId: (sessionId: string | null) => void;
18
- updateSessions: (sessions: ClientSession[], options?: { merge?: boolean }) => void;
19
- saveActiveSessionId: (sessionId: string) => Promise<void>;
20
- clearSessionState: () => Promise<void>;
21
- switchSession: (sessionId: string) => Promise<User>;
22
- applyLanguagePreference: (user: User) => Promise<void>;
23
- onAuthStateChange?: (user: User | null) => void;
24
- onError?: (error: ApiError) => void;
25
- loginSuccess: (user: User) => void;
26
- loginFailure: (message: string) => void;
27
- logoutStore: () => void;
28
- setAuthState: (state: Partial<AuthState>) => void;
29
- // Identity sync store actions
30
- setIdentitySynced: (synced: boolean) => void;
31
- setSyncing: (syncing: boolean) => void;
32
- logger?: (message: string, error?: unknown) => void;
33
- }
34
-
35
- export interface UseAuthOperationsResult {
36
- /** Create a new identity locally (offline-first) and optionally sync with server */
37
- createIdentity: (username?: string) => Promise<{ synced: boolean }>;
38
- /** Import an existing identity from backup file data */
39
- importIdentity: (backupData: BackupData, password: string) => Promise<{ synced: boolean }>;
40
- /** Sign in with existing identity on device */
41
- signIn: (deviceName?: string) => Promise<User>;
42
- /** Logout from current session */
43
- logout: (targetSessionId?: string) => Promise<void>;
44
- /** Logout from all sessions */
45
- logoutAll: () => Promise<void>;
46
- /** Check if device has an identity stored */
47
- hasIdentity: () => Promise<boolean>;
48
- /** Get the public key of the stored identity */
49
- getPublicKey: () => Promise<string | null>;
50
- /** Check if identity is synced with server */
51
- isIdentitySynced: () => Promise<boolean>;
52
- /** Sync local identity with server (when online) */
53
- syncIdentity: (username?: string) => Promise<User>;
54
- }
55
-
56
- const LOGIN_ERROR_CODE = 'LOGIN_ERROR';
57
- const REGISTER_ERROR_CODE = 'REGISTER_ERROR';
58
- const LOGOUT_ERROR_CODE = 'LOGOUT_ERROR';
59
- const LOGOUT_ALL_ERROR_CODE = 'LOGOUT_ALL_ERROR';
60
-
61
- /**
62
- * Authentication operations using public key cryptography.
63
- * No passwords required - identity is based on ECDSA key pairs.
64
- */
65
- export const useAuthOperations = ({
66
- oxyServices,
67
- storage,
68
- sessions,
69
- activeSessionId,
70
- setActiveSessionId,
71
- updateSessions,
72
- saveActiveSessionId,
73
- clearSessionState,
74
- switchSession,
75
- applyLanguagePreference,
76
- onAuthStateChange,
77
- onError,
78
- loginSuccess,
79
- loginFailure,
80
- logoutStore,
81
- setAuthState,
82
- setIdentitySynced,
83
- setSyncing,
84
- logger,
85
- }: UseAuthOperationsOptions): UseAuthOperationsResult => {
86
-
87
- /**
88
- * Clear session data if identity has changed
89
- * Internal helper to avoid code duplication
90
- */
91
- const clearSessionsIfIdentityChanged = useCallback(
92
- async (oldPublicKey: string | null, newPublicKey: string): Promise<void> => {
93
- if (oldPublicKey && oldPublicKey !== newPublicKey) {
94
- if (__DEV__ && logger) {
95
- logger('CRITICAL: Identity changed - clearing all session data', {
96
- oldPublicKey: oldPublicKey.substring(0, 16) + '...',
97
- newPublicKey: newPublicKey.substring(0, 16) + '...',
98
- });
99
- }
100
-
101
- // Clear all session state to prevent old identity's data from showing up
102
- await clearSessionState();
103
-
104
- // Logout from auth store (clears user, isAuthenticated, etc.)
105
- logoutStore();
106
-
107
- // Force KeyManager cache invalidation
108
- KeyManager.invalidateCache();
109
-
110
- if (__DEV__ && logger) {
111
- logger('Session state cleared for new identity');
112
- }
113
- }
114
- },
115
- [clearSessionState, logoutStore, logger]
116
- );
117
-
118
- /**
119
- * Internal function to perform challenge-response sign in (works offline)
120
- */
121
- const performSignIn = useCallback(
122
- async (publicKey: string): Promise<User> => {
123
- const deviceFingerprintObj = DeviceManager.getDeviceFingerprint();
124
- const deviceFingerprint = JSON.stringify(deviceFingerprintObj);
125
- const deviceInfo = await DeviceManager.getDeviceInfo();
126
- const deviceName = deviceInfo.deviceName || DeviceManager.getDefaultDeviceName();
127
-
128
- let challenge: string;
129
- let isOffline = false;
130
-
131
- // Try to request challenge from server (online)
132
- try {
133
- const challengeResponse = await oxyServices.requestChallenge(publicKey);
134
- challenge = challengeResponse.challenge;
135
- } catch (error) {
136
- // Network error - generate challenge locally for offline sign-in
137
- const errorMessage = error instanceof Error ? error.message : String(error);
138
- const isNetworkError =
139
- errorMessage.includes('Network') ||
140
- errorMessage.includes('network') ||
141
- errorMessage.includes('Failed to fetch') ||
142
- errorMessage.includes('fetch failed') ||
143
- (error as any)?.code === 'NETWORK_ERROR' ||
144
- (error as any)?.status === 0;
145
-
146
- if (isNetworkError) {
147
- if (__DEV__ && logger) {
148
- logger('Network unavailable, performing offline sign-in');
149
- }
150
- // Generate challenge locally
151
- challenge = await SignatureService.generateChallenge();
152
- isOffline = true;
153
- } else {
154
- // Re-throw non-network errors
155
- throw error;
156
- }
157
- }
158
-
159
- // Note: Biometric authentication check should be handled by the app layer
160
- // (e.g., accounts app) before calling signIn. The biometric preference is stored
161
- // in local storage as 'oxy_biometric_enabled' and can be checked there.
162
-
163
- // Sign the challenge
164
- const { challenge: signature, timestamp } = await SignatureService.signChallenge(challenge);
165
-
166
- let fullUser: User;
167
- let sessionResponse: SessionLoginResponse;
168
-
169
- if (isOffline) {
170
- // Offline sign-in: create local session and minimal user object
171
- if (__DEV__ && logger) {
172
- logger('Creating offline session');
173
- }
174
-
175
- // Generate a local session ID
176
- const localSessionId = `offline_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
177
- const localDeviceId = `device_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
178
- const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(); // 7 days
179
-
180
- // Create minimal user object with publicKey as id
181
- fullUser = {
182
- id: publicKey, // Use publicKey as id (per migration document)
183
- publicKey,
184
- username: '',
185
- privacySettings: {},
186
- } as User;
187
-
188
- sessionResponse = {
189
- sessionId: localSessionId,
190
- deviceId: localDeviceId,
191
- expiresAt,
192
- user: {
193
- id: publicKey,
194
- username: '',
195
- },
196
- };
197
-
198
- // Store offline session locally
199
- const offlineSession: ClientSession = {
200
- sessionId: localSessionId,
201
- deviceId: localDeviceId,
202
- expiresAt,
203
- lastActive: new Date().toISOString(),
204
- userId: publicKey,
205
- isCurrent: true,
206
- };
207
-
208
- setActiveSessionId(localSessionId);
209
- await saveActiveSessionId(localSessionId);
210
- updateSessions([offlineSession], { merge: true });
211
-
212
- // Mark session as offline for later sync
213
- if (storage) {
214
- await storage.setItem(`oxy_session_${localSessionId}_offline`, 'true');
215
- }
216
-
217
- if (__DEV__ && logger) {
218
- logger('Offline sign-in successful');
219
- }
220
- } else {
221
- // Online sign-in: use normal flow
222
- // Verify and create session
223
- sessionResponse = await oxyServices.verifyChallenge(
224
- publicKey,
225
- challenge,
226
- signature,
227
- timestamp,
228
- deviceName,
229
- deviceFingerprint,
230
- );
231
-
232
- // Get token for the session
233
- await oxyServices.getTokenBySession(sessionResponse.sessionId);
234
-
235
- // Get full user data
236
- fullUser = await oxyServices.getUserBySession(sessionResponse.sessionId);
237
-
238
- // IMPORTANT: user.id should be MongoDB ObjectId, not publicKey
239
- // The API should return the correct id (ObjectId) from the database
240
- // If it doesn't, we need to fix the API, not work around it here
241
- // Validate that id is ObjectId format (24 hex characters)
242
- if (fullUser.id && !/^[0-9a-fA-F]{24}$/.test(fullUser.id)) {
243
- console.warn('[useAuthOperations] User.id is not MongoDB ObjectId format:', {
244
- id: fullUser.id.substring(0, 20),
245
- publicKey: fullUser.publicKey.substring(0, 20),
246
- message: 'API should return MongoDB ObjectId as user.id, not publicKey'
247
- });
248
- // Don't override - let the API fix this issue
249
- }
250
-
251
- // Fetch device sessions
252
- let allDeviceSessions: ClientSession[] = [];
253
- try {
254
- allDeviceSessions = await fetchSessionsWithFallback(oxyServices, sessionResponse.sessionId, {
255
- fallbackDeviceId: sessionResponse.deviceId,
256
- fallbackUserId: fullUser.id,
257
- logger,
258
- });
259
- } catch (error) {
260
- if (__DEV__) {
261
- console.warn('Failed to fetch device sessions after login:', error);
262
- }
263
- }
264
-
265
- // Check for existing session for same user
266
- const existingSession = allDeviceSessions.find(
267
- (session) =>
268
- session.userId?.toString() === fullUser.id?.toString() &&
269
- session.sessionId !== sessionResponse.sessionId,
270
- );
271
-
272
- if (existingSession) {
273
- // Logout duplicate session
274
- try {
275
- await oxyServices.logoutSession(sessionResponse.sessionId, sessionResponse.sessionId);
276
- } catch (logoutError) {
277
- if (__DEV__) {
278
- console.warn('Failed to logout duplicate session:', logoutError);
279
- }
280
- }
281
- await switchSession(existingSession.sessionId);
282
- updateSessions(
283
- allDeviceSessions.filter((session) => session.sessionId !== sessionResponse.sessionId),
284
- { merge: false },
285
- );
286
- onAuthStateChange?.(fullUser);
287
- return fullUser;
288
- }
289
-
290
- setActiveSessionId(sessionResponse.sessionId);
291
- await saveActiveSessionId(sessionResponse.sessionId);
292
- updateSessions(allDeviceSessions, { merge: true });
293
- }
294
-
295
- await applyLanguagePreference(fullUser);
296
- loginSuccess(fullUser);
297
- onAuthStateChange?.(fullUser);
298
-
299
- return fullUser;
300
- },
301
- [
302
- applyLanguagePreference,
303
- logger,
304
- loginSuccess,
305
- onAuthStateChange,
306
- oxyServices,
307
- saveActiveSessionId,
308
- setActiveSessionId,
309
- switchSession,
310
- updateSessions,
311
- storage,
312
- ],
313
- );
314
-
315
- /**
316
- * Create a new identity (offline-first)
317
- * Identity is purely cryptographic - no username or email required
318
- *
319
- * This function generates keys locally and does NOT register with the server yet.
320
- * Registration will happen during syncIdentity() or when username is provided.
321
- *
322
- * @param username - Optional username to set during registration (if online)
323
- */
324
- const createIdentity = useCallback(
325
- async (username?: string): Promise<{ synced: boolean }> => {
326
- if (!storage) throw new Error('Storage not initialized');
327
-
328
- setAuthState({ isLoading: true, error: null });
329
-
330
- try {
331
- // CRITICAL: Get old public key before creating new identity
332
- // If identity changes, we must clear all session data to prevent data leakage
333
- const oldPublicKey = await KeyManager.getPublicKey().catch(() => null);
334
-
335
- if (__DEV__ && logger) {
336
- logger('Creating new identity', { hadPreviousIdentity: !!oldPublicKey });
337
- }
338
-
339
- // Generate new key pair directly (works offline)
340
- const { publicKey, privateKey } = await KeyManager.generateKeyPair();
341
- await KeyManager.importKeyPair(privateKey);
342
-
343
- if (__DEV__ && logger) {
344
- logger('Identity keys generated', { publicKey: publicKey.substring(0, 16) + '...' });
345
- }
346
-
347
- // Clear sessions if identity changed (prevents data leakage)
348
- await clearSessionsIfIdentityChanged(oldPublicKey, publicKey);
349
-
350
- // Mark as not synced initially
351
- await storage.setItem('oxy_identity_synced', 'false');
352
- setIdentitySynced(false);
353
-
354
- // If username provided, try to register immediately (online only)
355
- if (username) {
356
- // Validate username format before attempting registration
357
- const trimmedUsername = username.trim();
358
- if (trimmedUsername && /^[a-zA-Z0-9]{3,30}$/.test(trimmedUsername)) {
359
- try {
360
- const { signature, timestamp } = await SignatureService.createRegistrationSignature();
361
- await oxyServices.register(publicKey, signature, timestamp, trimmedUsername);
362
-
363
- // Mark as synced (Zustand store + storage)
364
- await storage.setItem('oxy_identity_synced', 'true');
365
- setIdentitySynced(true);
366
-
367
- if (__DEV__ && logger) {
368
- logger('Identity synced with server successfully with username');
369
- }
370
-
371
- return { synced: true };
372
- } catch (syncError) {
373
- // Offline or server error - identity created locally but not synced
374
- if (__DEV__ && logger) {
375
- logger('Identity created locally with username (offline), will sync when online', syncError);
376
- }
377
-
378
- return { synced: false };
379
- }
380
- }
381
- }
382
-
383
- // No username provided - defer registration until later
384
- if (__DEV__ && logger) {
385
- logger('Identity created locally without username, will register during sync');
386
- }
387
-
388
- return { synced: false };
389
- } catch (error) {
390
- // CRITICAL: Never delete identity on error - it may have been successfully created
391
- // Only log the error and let the user recover using their backup file
392
- // Identity deletion should ONLY happen when explicitly requested by the user
393
- if (__DEV__ && logger) {
394
- logger('Error during identity creation (identity may still exist):', error);
395
- }
396
-
397
- // Check if identity was actually created (keys exist)
398
- const hasIdentity = await KeyManager.hasIdentity().catch(() => false);
399
- if (hasIdentity) {
400
- // Identity exists - don't delete it! Just mark as not synced
401
- await storage.setItem('oxy_identity_synced', 'false').catch(() => {});
402
- setIdentitySynced(false);
403
- if (__DEV__ && logger) {
404
- logger('Identity was created but sync failed - user can sync later');
405
- }
406
- } else {
407
- // No identity exists - this was a generation failure, safe to clean up sync flag
408
- await storage.removeItem('oxy_identity_synced').catch(() => {});
409
- setIdentitySynced(false);
410
- }
411
-
412
- const message = handleAuthError(error, {
413
- defaultMessage: 'Failed to create identity',
414
- code: REGISTER_ERROR_CODE,
415
- onError,
416
- setAuthError: (msg: string) => setAuthState({ error: msg }),
417
- logger,
418
- });
419
- loginFailure(message);
420
- throw error;
421
- } finally {
422
- setAuthState({ isLoading: false });
423
- }
424
- },
425
- [oxyServices, storage, setAuthState, loginFailure, onError, logger, setIdentitySynced, clearSessionsIfIdentityChanged],
426
- );
427
-
428
- /**
429
- * Check if identity is synced with server (reads from storage for persistence)
430
- */
431
- const isIdentitySyncedFn = useCallback(async (): Promise<boolean> => {
432
- if (!storage) return true;
433
- const synced = await storage.getItem('oxy_identity_synced');
434
- const isSynced = synced !== 'false';
435
- setIdentitySynced(isSynced);
436
- return isSynced;
437
- }, [storage, setIdentitySynced]);
438
-
439
- /**
440
- * Sync local identity with server (call when online)
441
- * TanStack Query handles offline mutations automatically
442
- *
443
- * @param username - Optional username to set during sync
444
- */
445
- const syncIdentity = useCallback(
446
- async (username?: string): Promise<User> => {
447
- if (!storage) throw new Error('Storage not initialized');
448
-
449
- setAuthState({ isLoading: true, error: null });
450
- setSyncing(true);
451
-
452
- try {
453
- const publicKey = await KeyManager.getPublicKey();
454
- if (!publicKey) {
455
- throw new Error('No identity found on this device');
456
- }
457
-
458
- // Check if already synced
459
- const alreadySynced = await storage.getItem('oxy_identity_synced');
460
- if (alreadySynced === 'true') {
461
- setIdentitySynced(true);
462
- return await performSignIn(publicKey);
463
- }
464
-
465
- // Check if already registered on server
466
- const { registered } = await oxyServices.checkPublicKeyRegistered(publicKey);
467
-
468
- if (!registered) {
469
- // Register with server (identity is just the publicKey)
470
- const { signature, timestamp } = await SignatureService.createRegistrationSignature();
471
- await oxyServices.register(publicKey, signature, timestamp, username);
472
- }
473
-
474
- // Mark as synced (Zustand store + storage)
475
- await storage.setItem('oxy_identity_synced', 'true');
476
- setIdentitySynced(true);
477
-
478
- // Sign in
479
- const user = await performSignIn(publicKey);
480
-
481
- // TanStack Query will automatically retry any pending mutations
482
-
483
- return user;
484
- } catch (error) {
485
- const message = handleAuthError(error, {
486
- defaultMessage: 'Failed to sync identity',
487
- code: REGISTER_ERROR_CODE,
488
- onError,
489
- setAuthError: (msg: string) => setAuthState({ error: msg }),
490
- logger,
491
- });
492
- loginFailure(message);
493
- throw error;
494
- } finally {
495
- setAuthState({ isLoading: false });
496
- setSyncing(false);
497
- }
498
- },
499
- [oxyServices, storage, setAuthState, performSignIn, loginFailure, onError, logger, setSyncing, setIdentitySynced],
500
- );
501
-
502
- /**
503
- * Import identity from backup file data (offline-first)
504
- *
505
- * @param backupData - The backup data to import
506
- * @param password - Password to decrypt the backup
507
- * @param username - Optional username to set during registration
508
- */
509
- const importIdentity = useCallback(
510
- async (backupData: BackupData, password: string, username?: string): Promise<{ synced: boolean }> => {
511
- if (!storage) throw new Error('Storage not initialized');
512
-
513
- // Validate arguments - ensure backupData is an object, not a string (old signature)
514
- if (!backupData || typeof backupData !== 'object' || Array.isArray(backupData)) {
515
- throw new Error('Invalid backup data. Please use the backup file import feature.');
516
- }
517
-
518
- if (!backupData.encrypted || !backupData.salt || !backupData.iv || !backupData.publicKey) {
519
- throw new Error('Invalid backup data structure. Missing required fields.');
520
- }
521
-
522
- if (!password || typeof password !== 'string') {
523
- throw new Error('Password is required for backup file import.');
524
- }
525
-
526
- setAuthState({ isLoading: true, error: null });
527
-
528
- try {
529
- // CRITICAL: Get old public key before importing new identity
530
- // If identity changes, we must clear all session data to prevent data leakage
531
- const oldPublicKey = await KeyManager.getPublicKey().catch(() => null);
532
-
533
- if (__DEV__ && logger) {
534
- logger('Importing identity from backup', {
535
- hadPreviousIdentity: !!oldPublicKey,
536
- backupPublicKey: backupData.publicKey.substring(0, 16) + '...'
537
- });
538
- }
539
-
540
- // Decrypt private key from backup data
541
- const Crypto = await import('expo-crypto');
542
-
543
- // Convert hex strings to Uint8Array
544
- const saltBytes = new Uint8Array(
545
- backupData.salt.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []
546
- );
547
- const ivBytes = new Uint8Array(
548
- backupData.iv.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []
549
- );
550
-
551
- // Derive key from password (same algorithm as EncryptedBackupGenerator)
552
- const saltHex = Array.from(saltBytes).map(b => b.toString(16).padStart(2, '0')).join('');
553
- let key = password + saltHex;
554
- for (let i = 0; i < 10000; i++) {
555
- key = await Crypto.digestStringAsync(
556
- Crypto.CryptoDigestAlgorithm.SHA256,
557
- key
558
- );
559
- }
560
- const keyBytes = new Uint8Array(32);
561
- for (let i = 0; i < 64 && i < key.length; i += 2) {
562
- keyBytes[i / 2] = parseInt(key.substring(i, i + 2), 16);
563
- }
564
-
565
- // Decrypt private key (XOR decryption - same as encryption)
566
- const encryptedBytes = Buffer.from(backupData.encrypted, 'base64');
567
- const decryptedBytes = new Uint8Array(encryptedBytes.length);
568
- for (let i = 0; i < encryptedBytes.length; i++) {
569
- decryptedBytes[i] = encryptedBytes[i] ^ keyBytes[i % keyBytes.length] ^ ivBytes[i % ivBytes.length];
570
- }
571
- const privateKey = new TextDecoder().decode(decryptedBytes);
572
-
573
- // Import the key pair
574
- const publicKey = await KeyManager.importKeyPair(privateKey);
575
-
576
- if (__DEV__ && logger) {
577
- logger('Identity keys imported', { publicKey: publicKey.substring(0, 16) + '...' });
578
- }
579
-
580
- // Verify public key matches
581
- if (publicKey !== backupData.publicKey) {
582
- throw new Error('Backup file is corrupted or password is incorrect');
583
- }
584
-
585
- // Clear sessions if identity changed (prevents data leakage)
586
- await clearSessionsIfIdentityChanged(oldPublicKey, publicKey);
587
-
588
- // Mark as not synced
589
- await storage.setItem('oxy_identity_synced', 'false');
590
- setIdentitySynced(false);
591
-
592
- // Try to sync with server
593
- try {
594
- // Check if this identity is already registered
595
- const { registered } = await oxyServices.checkPublicKeyRegistered(publicKey);
596
-
597
- if (registered) {
598
- // Identity exists, mark as synced
599
- await storage.setItem('oxy_identity_synced', 'true');
600
- setIdentitySynced(true);
601
- return { synced: true };
602
- } else {
603
- // Need to register this identity (identity is just the publicKey)
604
- const { signature, timestamp } = await SignatureService.createRegistrationSignature();
605
- await oxyServices.register(publicKey, signature, timestamp, username);
606
-
607
- await storage.setItem('oxy_identity_synced', 'true');
608
- setIdentitySynced(true);
609
- return { synced: true };
610
- }
611
- } catch (syncError) {
612
- // Offline - identity restored locally but not synced
613
- if (__DEV__) {
614
- console.log('[Auth] Identity imported locally, will sync when online:', syncError);
615
- }
616
- return { synced: false };
617
- }
618
- } catch (error) {
619
- const message = handleAuthError(error, {
620
- defaultMessage: 'Failed to import identity. Please check your password and backup file.',
621
- code: REGISTER_ERROR_CODE,
622
- onError,
623
- setAuthError: (msg: string) => setAuthState({ error: msg }),
624
- logger,
625
- });
626
- loginFailure(message);
627
- throw error;
628
- } finally {
629
- setAuthState({ isLoading: false });
630
- }
631
- },
632
- [oxyServices, storage, setAuthState, loginFailure, onError, logger, setIdentitySynced, clearSessionsIfIdentityChanged],
633
- );
634
-
635
- /**
636
- * Sign in with existing identity on device
637
- */
638
- const signIn = useCallback(
639
- async (deviceName?: string): Promise<User> => {
640
- if (!storage) throw new Error('Storage not initialized');
641
-
642
- setAuthState({ isLoading: true, error: null });
643
-
644
- try {
645
- // Get stored public key
646
- const publicKey = await KeyManager.getPublicKey();
647
- if (!publicKey) {
648
- throw new Error('No identity found on this device. Please create or import an identity.');
649
- }
650
-
651
- return await performSignIn(publicKey);
652
- } catch (error) {
653
- const message = handleAuthError(error, {
654
- defaultMessage: 'Sign in failed',
655
- code: LOGIN_ERROR_CODE,
656
- onError,
657
- setAuthError: (msg: string) => setAuthState({ error: msg }),
658
- logger,
659
- });
660
- loginFailure(message);
661
- throw error;
662
- } finally {
663
- setAuthState({ isLoading: false });
664
- }
665
- },
666
- [storage, setAuthState, performSignIn, loginFailure, onError, logger],
667
- );
668
-
669
- /**
670
- * Logout from session
671
- */
672
- const logout = useCallback(
673
- async (targetSessionId?: string): Promise<void> => {
674
- if (!activeSessionId) return;
675
-
676
- try {
677
- const sessionToLogout = targetSessionId || activeSessionId;
678
- await oxyServices.logoutSession(activeSessionId, sessionToLogout);
679
-
680
- const filteredSessions = sessions.filter((session) => session.sessionId !== sessionToLogout);
681
- updateSessions(filteredSessions, { merge: false });
682
-
683
- if (sessionToLogout === activeSessionId) {
684
- if (filteredSessions.length > 0) {
685
- await switchSession(filteredSessions[0].sessionId);
686
- } else {
687
- await clearSessionState();
688
- return;
689
- }
690
- }
691
- } catch (error) {
692
- const isInvalid = isInvalidSessionError(error);
693
-
694
- if (isInvalid && targetSessionId === activeSessionId) {
695
- await clearSessionState();
696
- return;
697
- }
698
-
699
- handleAuthError(error, {
700
- defaultMessage: 'Logout failed',
701
- code: LOGOUT_ERROR_CODE,
702
- onError,
703
- setAuthError: (msg: string) => setAuthState({ error: msg }),
704
- logger,
705
- status: isInvalid ? 401 : undefined,
706
- });
707
- }
708
- },
709
- [
710
- activeSessionId,
711
- clearSessionState,
712
- logger,
713
- onError,
714
- oxyServices,
715
- sessions,
716
- setAuthState,
717
- switchSession,
718
- updateSessions,
719
- ],
720
- );
721
-
722
- /**
723
- * Logout from all sessions
724
- */
725
- const logoutAll = useCallback(async (): Promise<void> => {
726
- if (!activeSessionId) {
727
- const error = new Error('No active session found');
728
- setAuthState({ error: error.message });
729
- onError?.({ message: error.message, code: LOGOUT_ALL_ERROR_CODE, status: 404 });
730
- throw error;
731
- }
732
-
733
- try {
734
- await oxyServices.logoutAllSessions(activeSessionId);
735
- await clearSessionState();
736
- } catch (error) {
737
- handleAuthError(error, {
738
- defaultMessage: 'Logout all failed',
739
- code: LOGOUT_ALL_ERROR_CODE,
740
- onError,
741
- setAuthError: (msg: string) => setAuthState({ error: msg }),
742
- logger,
743
- });
744
- throw error instanceof Error ? error : new Error('Logout all failed');
745
- }
746
- }, [activeSessionId, clearSessionState, logger, onError, oxyServices, setAuthState]);
747
-
748
- /**
749
- * Check if device has an identity stored
750
- */
751
- const hasIdentity = useCallback(async (): Promise<boolean> => {
752
- return KeyManager.hasIdentity();
753
- }, []);
754
-
755
- /**
756
- * Get the public key of the stored identity
757
- */
758
- const getPublicKey = useCallback(async (): Promise<string | null> => {
759
- return KeyManager.getPublicKey();
760
- }, []);
761
-
762
- return {
763
- createIdentity,
764
- importIdentity,
765
- signIn,
766
- logout,
767
- logoutAll,
768
- hasIdentity,
769
- getPublicKey,
770
- isIdentitySynced: isIdentitySyncedFn,
771
- syncIdentity,
772
- };
773
- };