@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.
Files changed (506) hide show
  1. package/README.md +29 -10
  2. package/lib/commonjs/core/OxyServices.js +1 -1
  3. package/lib/commonjs/core/index.js +20 -15
  4. package/lib/commonjs/core/index.js.map +1 -1
  5. package/lib/commonjs/core/mixins/OxyServices.auth.js +36 -53
  6. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
  7. package/lib/commonjs/core/mixins/OxyServices.user.js +10 -17
  8. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  9. package/lib/commonjs/core/services/TokenService.js +27 -13
  10. package/lib/commonjs/core/services/TokenService.js.map +1 -1
  11. package/lib/commonjs/crypto/index.js +0 -16
  12. package/lib/commonjs/crypto/index.js.map +1 -1
  13. package/lib/commonjs/crypto/keyManager.js +21 -22
  14. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  15. package/lib/commonjs/crypto/polyfill.js +1 -10
  16. package/lib/commonjs/crypto/polyfill.js.map +1 -1
  17. package/lib/commonjs/crypto/signatureService.js +18 -32
  18. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  19. package/lib/commonjs/index.js +13 -134
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/models/interfaces.js +0 -7
  22. package/lib/commonjs/models/interfaces.js.map +1 -1
  23. package/lib/commonjs/node/index.js +1 -10
  24. package/lib/commonjs/node/index.js.map +1 -1
  25. package/lib/commonjs/ui/components/BottomSheetRouter.js +1 -9
  26. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  27. package/lib/commonjs/ui/context/OxyContext.js +779 -450
  28. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  29. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +551 -0
  30. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -0
  31. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +73 -0
  32. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js.map +1 -0
  33. package/lib/commonjs/ui/context/hooks/useStorage.js +79 -0
  34. package/lib/commonjs/ui/context/hooks/useStorage.js.map +1 -0
  35. package/lib/commonjs/ui/hooks/index.js +0 -20
  36. package/lib/commonjs/ui/hooks/index.js.map +1 -1
  37. package/lib/commonjs/ui/hooks/mutations/index.js +0 -12
  38. package/lib/commonjs/ui/hooks/mutations/index.js.map +1 -1
  39. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +23 -74
  40. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  41. package/lib/commonjs/ui/hooks/queries/index.js +0 -12
  42. package/lib/commonjs/ui/hooks/queries/index.js.map +1 -1
  43. package/lib/commonjs/ui/hooks/queries/queryKeys.js +1 -3
  44. package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -1
  45. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +28 -64
  46. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  47. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +6 -4
  48. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  49. package/lib/commonjs/ui/hooks/useDeviceManagement.js +73 -0
  50. package/lib/commonjs/ui/hooks/useDeviceManagement.js.map +1 -0
  51. package/lib/commonjs/ui/hooks/useProfileEditing.js +5 -3
  52. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  53. package/lib/commonjs/ui/hooks/useSessionManagement.js +284 -0
  54. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -0
  55. package/lib/commonjs/ui/index.js +2 -10
  56. package/lib/commonjs/ui/index.js.map +1 -1
  57. package/lib/commonjs/ui/navigation/routes.js +1 -5
  58. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  59. package/lib/commonjs/ui/screens/AccountCenterScreen.js +4 -9
  60. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  61. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +19 -37
  62. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  63. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +5 -5
  64. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  65. package/lib/commonjs/ui/screens/OxyAuthScreen.js +15 -2
  66. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  67. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +97 -76
  68. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  69. package/lib/commonjs/ui/screens/ProfileScreen.js +6 -6
  70. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  71. package/lib/commonjs/ui/stores/authStore.js +6 -54
  72. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  73. package/lib/commonjs/ui/styles/spacing.js +2 -54
  74. package/lib/commonjs/ui/styles/spacing.js.map +1 -1
  75. package/lib/commonjs/ui/utils/avatarUtils.js +12 -9
  76. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  77. package/lib/commonjs/ui/utils/sessionHelpers.js +1 -7
  78. package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
  79. package/lib/commonjs/utils/deviceManager.js +177 -0
  80. package/lib/commonjs/utils/deviceManager.js.map +1 -0
  81. package/lib/commonjs/utils/errorUtils.js +0 -13
  82. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  83. package/lib/commonjs/utils/index.js +7 -0
  84. package/lib/commonjs/utils/index.js.map +1 -1
  85. package/lib/commonjs/utils/sessionUtils.js +1 -8
  86. package/lib/commonjs/utils/sessionUtils.js.map +1 -1
  87. package/lib/commonjs/utils/validationUtils.js +1 -15
  88. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  89. package/lib/module/core/OxyServices.js +1 -1
  90. package/lib/module/core/index.js +4 -6
  91. package/lib/module/core/index.js.map +1 -1
  92. package/lib/module/core/mixins/OxyServices.auth.js +36 -53
  93. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
  94. package/lib/module/core/mixins/OxyServices.user.js +10 -17
  95. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  96. package/lib/module/core/services/TokenService.js +27 -13
  97. package/lib/module/core/services/TokenService.js.map +1 -1
  98. package/lib/module/crypto/index.js +0 -3
  99. package/lib/module/crypto/index.js.map +1 -1
  100. package/lib/module/crypto/keyManager.js +21 -22
  101. package/lib/module/crypto/keyManager.js.map +1 -1
  102. package/lib/module/crypto/polyfill.js +1 -2
  103. package/lib/module/crypto/polyfill.js.map +1 -1
  104. package/lib/module/crypto/signatureService.js +18 -32
  105. package/lib/module/crypto/signatureService.js.map +1 -1
  106. package/lib/module/index.js +7 -19
  107. package/lib/module/index.js.map +1 -1
  108. package/lib/module/models/interfaces.js +0 -7
  109. package/lib/module/models/interfaces.js.map +1 -1
  110. package/lib/module/node/index.js +0 -3
  111. package/lib/module/node/index.js.map +1 -1
  112. package/lib/module/ui/components/BottomSheetRouter.js +2 -6
  113. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  114. package/lib/module/ui/context/OxyContext.js +779 -450
  115. package/lib/module/ui/context/OxyContext.js.map +1 -1
  116. package/lib/module/ui/context/hooks/useAuthOperations.js +545 -0
  117. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -0
  118. package/lib/module/ui/context/hooks/useDeviceManagement.js +68 -0
  119. package/lib/module/ui/context/hooks/useDeviceManagement.js.map +1 -0
  120. package/lib/module/ui/context/hooks/useStorage.js +74 -0
  121. package/lib/module/ui/context/hooks/useStorage.js.map +1 -0
  122. package/lib/module/ui/hooks/index.js +0 -1
  123. package/lib/module/ui/hooks/index.js.map +1 -1
  124. package/lib/module/ui/hooks/mutations/index.js +1 -1
  125. package/lib/module/ui/hooks/mutations/index.js.map +1 -1
  126. package/lib/module/ui/hooks/mutations/useAccountMutations.js +21 -71
  127. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  128. package/lib/module/ui/hooks/queries/index.js +1 -1
  129. package/lib/module/ui/hooks/queries/index.js.map +1 -1
  130. package/lib/module/ui/hooks/queries/queryKeys.js +1 -3
  131. package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -1
  132. package/lib/module/ui/hooks/queries/useAccountQueries.js +27 -61
  133. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  134. package/lib/module/ui/hooks/queries/useServicesQueries.js +6 -4
  135. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  136. package/lib/module/ui/hooks/useDeviceManagement.js +68 -0
  137. package/lib/module/ui/hooks/useDeviceManagement.js.map +1 -0
  138. package/lib/module/ui/hooks/useProfileEditing.js +5 -3
  139. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  140. package/lib/module/ui/hooks/useSessionManagement.js +279 -0
  141. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -0
  142. package/lib/module/ui/index.js +1 -2
  143. package/lib/module/ui/index.js.map +1 -1
  144. package/lib/module/ui/navigation/routes.js +1 -5
  145. package/lib/module/ui/navigation/routes.js.map +1 -1
  146. package/lib/module/ui/screens/AccountCenterScreen.js +4 -9
  147. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  148. package/lib/module/ui/screens/AccountSettingsScreen.js +19 -37
  149. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  150. package/lib/module/ui/screens/AccountSwitcherScreen.js +5 -5
  151. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  152. package/lib/module/ui/screens/OxyAuthScreen.js +15 -2
  153. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  154. package/lib/module/ui/screens/PrivacySettingsScreen.js +98 -77
  155. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  156. package/lib/module/ui/screens/ProfileScreen.js +6 -6
  157. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  158. package/lib/module/ui/stores/authStore.js +6 -54
  159. package/lib/module/ui/stores/authStore.js.map +1 -1
  160. package/lib/module/ui/styles/spacing.js +2 -6
  161. package/lib/module/ui/styles/spacing.js.map +1 -1
  162. package/lib/module/ui/utils/avatarUtils.js +12 -9
  163. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  164. package/lib/module/ui/utils/sessionHelpers.js +1 -7
  165. package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
  166. package/lib/module/utils/deviceManager.js +171 -0
  167. package/lib/module/utils/deviceManager.js.map +1 -0
  168. package/lib/module/utils/errorUtils.js +0 -7
  169. package/lib/module/utils/errorUtils.js.map +1 -1
  170. package/lib/module/utils/index.js +1 -2
  171. package/lib/module/utils/index.js.map +1 -1
  172. package/lib/module/utils/sessionUtils.js +1 -8
  173. package/lib/module/utils/sessionUtils.js.map +1 -1
  174. package/lib/module/utils/validationUtils.js +0 -13
  175. package/lib/module/utils/validationUtils.js.map +1 -1
  176. package/lib/typescript/core/OxyServices.d.ts +1 -1
  177. package/lib/typescript/core/index.d.ts +3 -3
  178. package/lib/typescript/core/index.d.ts.map +1 -1
  179. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +21 -44
  180. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  181. package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -0
  182. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  183. package/lib/typescript/core/mixins/index.d.ts +8 -15
  184. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  185. package/lib/typescript/core/services/TokenService.d.ts.map +1 -1
  186. package/lib/typescript/crypto/index.d.ts +0 -1
  187. package/lib/typescript/crypto/index.d.ts.map +1 -1
  188. package/lib/typescript/crypto/keyManager.d.ts +2 -15
  189. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  190. package/lib/typescript/crypto/polyfill.d.ts +1 -2
  191. package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
  192. package/lib/typescript/crypto/signatureService.d.ts +0 -13
  193. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  194. package/lib/typescript/index.d.ts +7 -12
  195. package/lib/typescript/index.d.ts.map +1 -1
  196. package/lib/typescript/models/interfaces.d.ts +36 -5
  197. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  198. package/lib/typescript/models/session.d.ts +18 -3
  199. package/lib/typescript/models/session.d.ts.map +1 -1
  200. package/lib/typescript/node/index.d.ts +0 -1
  201. package/lib/typescript/node/index.d.ts.map +1 -1
  202. package/lib/typescript/ui/components/BottomSheetRouter.d.ts +0 -5
  203. package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
  204. package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
  205. package/lib/typescript/ui/components/TextField/helpers.d.ts +2 -2
  206. package/lib/typescript/ui/components/TextField/types.d.ts +0 -1
  207. package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
  208. package/lib/typescript/ui/context/OxyContext.d.ts +28 -5
  209. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  210. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +59 -0
  211. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -0
  212. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts +27 -0
  213. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts.map +1 -0
  214. package/lib/typescript/ui/context/hooks/useStorage.d.ts +22 -0
  215. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +1 -0
  216. package/lib/typescript/ui/hooks/index.d.ts +0 -1
  217. package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
  218. package/lib/typescript/ui/hooks/mutations/index.d.ts +1 -1
  219. package/lib/typescript/ui/hooks/mutations/index.d.ts.map +1 -1
  220. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +8 -19
  221. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  222. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +1 -1
  223. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
  224. package/lib/typescript/ui/hooks/queries/index.d.ts +1 -1
  225. package/lib/typescript/ui/hooks/queries/index.d.ts.map +1 -1
  226. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts +0 -2
  227. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts.map +1 -1
  228. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +5 -17
  229. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  230. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  231. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts +27 -0
  232. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts.map +1 -0
  233. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  234. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +41 -0
  235. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -0
  236. package/lib/typescript/ui/index.d.ts +0 -1
  237. package/lib/typescript/ui/index.d.ts.map +1 -1
  238. package/lib/typescript/ui/navigation/routes.d.ts +1 -1
  239. package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
  240. package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
  241. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  242. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  243. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  244. package/lib/typescript/ui/stores/authStore.d.ts +1 -8
  245. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  246. package/lib/typescript/ui/styles/spacing.d.ts +0 -5
  247. package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
  248. package/lib/typescript/ui/utils/avatarUtils.d.ts +4 -1
  249. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  250. package/lib/typescript/ui/utils/sessionHelpers.d.ts +0 -1
  251. package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
  252. package/lib/typescript/utils/deviceManager.d.ts +66 -0
  253. package/lib/typescript/utils/deviceManager.d.ts.map +1 -0
  254. package/lib/typescript/utils/errorUtils.d.ts +0 -6
  255. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  256. package/lib/typescript/utils/index.d.ts +2 -0
  257. package/lib/typescript/utils/index.d.ts.map +1 -1
  258. package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
  259. package/lib/typescript/utils/validationUtils.d.ts +0 -8
  260. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  261. package/package.json +1 -6
  262. package/src/core/OxyServices.ts +1 -1
  263. package/src/core/index.ts +5 -8
  264. package/src/core/mixins/OxyServices.auth.ts +44 -87
  265. package/src/core/mixins/OxyServices.user.ts +10 -18
  266. package/src/core/services/TokenService.ts +27 -16
  267. package/src/crypto/index.ts +1 -3
  268. package/src/crypto/keyManager.ts +21 -30
  269. package/src/crypto/polyfill.ts +1 -2
  270. package/src/crypto/signatureService.ts +19 -43
  271. package/src/index.ts +6 -41
  272. package/src/models/interfaces.ts +39 -12
  273. package/src/models/session.ts +19 -7
  274. package/src/node/index.ts +0 -3
  275. package/src/ui/components/BottomSheetRouter.tsx +1 -6
  276. package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
  277. package/src/ui/components/TextField/helpers.tsx +2 -2
  278. package/src/ui/components/TextField/types.tsx +1 -1
  279. package/src/ui/context/OxyContext.tsx +831 -463
  280. package/src/ui/context/hooks/useAuthOperations.ts +620 -0
  281. package/src/ui/context/hooks/useDeviceManagement.ts +108 -0
  282. package/src/ui/context/hooks/useStorage.ts +104 -0
  283. package/src/ui/hooks/index.ts +1 -2
  284. package/src/ui/hooks/mutations/index.ts +0 -2
  285. package/src/ui/hooks/mutations/useAccountMutations.ts +20 -66
  286. package/src/ui/hooks/queries/index.ts +0 -2
  287. package/src/ui/hooks/queries/queryKeys.ts +0 -2
  288. package/src/ui/hooks/queries/useAccountQueries.ts +19 -53
  289. package/src/ui/hooks/queries/useServicesQueries.ts +5 -5
  290. package/src/ui/hooks/useDeviceManagement.ts +108 -0
  291. package/src/ui/hooks/useProfileEditing.ts +3 -3
  292. package/src/ui/hooks/useSessionManagement.ts +405 -0
  293. package/src/ui/index.ts +1 -2
  294. package/src/ui/navigation/routes.ts +2 -6
  295. package/src/ui/screens/AccountCenterScreen.tsx +4 -9
  296. package/src/ui/screens/AccountSettingsScreen.tsx +31 -49
  297. package/src/ui/screens/AccountSwitcherScreen.tsx +5 -5
  298. package/src/ui/screens/OxyAuthScreen.tsx +19 -4
  299. package/src/ui/screens/PrivacySettingsScreen.tsx +101 -67
  300. package/src/ui/screens/ProfileScreen.tsx +10 -10
  301. package/src/ui/stores/authStore.ts +8 -48
  302. package/src/ui/styles/spacing.ts +2 -15
  303. package/src/ui/utils/avatarUtils.ts +21 -19
  304. package/src/ui/utils/sessionHelpers.ts +0 -7
  305. package/src/utils/__tests__/validationUtils.test.ts +1 -16
  306. package/src/utils/deviceManager.ts +198 -0
  307. package/src/utils/errorUtils.ts +1 -8
  308. package/src/utils/index.ts +2 -1
  309. package/src/utils/sessionUtils.ts +0 -8
  310. package/src/utils/validationUtils.ts +0 -12
  311. package/lib/commonjs/adapters/expo/crypto.js +0 -56
  312. package/lib/commonjs/adapters/expo/crypto.js.map +0 -1
  313. package/lib/commonjs/adapters/expo/fetch.js +0 -30
  314. package/lib/commonjs/adapters/expo/fetch.js.map +0 -1
  315. package/lib/commonjs/adapters/expo/index.js +0 -48
  316. package/lib/commonjs/adapters/expo/index.js.map +0 -1
  317. package/lib/commonjs/adapters/expo/storage.js +0 -201
  318. package/lib/commonjs/adapters/expo/storage.js.map +0 -1
  319. package/lib/commonjs/adapters/index.js +0 -48
  320. package/lib/commonjs/adapters/index.js.map +0 -1
  321. package/lib/commonjs/adapters/node/crypto.js +0 -40
  322. package/lib/commonjs/adapters/node/crypto.js.map +0 -1
  323. package/lib/commonjs/adapters/node/fetch.js +0 -62
  324. package/lib/commonjs/adapters/node/fetch.js.map +0 -1
  325. package/lib/commonjs/adapters/node/index.js +0 -34
  326. package/lib/commonjs/adapters/node/index.js.map +0 -1
  327. package/lib/commonjs/adapters/node/storage.js +0 -163
  328. package/lib/commonjs/adapters/node/storage.js.map +0 -1
  329. package/lib/commonjs/core/identity-session/DeviceManager.js +0 -237
  330. package/lib/commonjs/core/identity-session/DeviceManager.js.map +0 -1
  331. package/lib/commonjs/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  332. package/lib/commonjs/core/identity-session/IdentityManager.js +0 -400
  333. package/lib/commonjs/core/identity-session/IdentityManager.js.map +0 -1
  334. package/lib/commonjs/core/identity-session/IdentitySessionCore.js +0 -394
  335. package/lib/commonjs/core/identity-session/IdentitySessionCore.js.map +0 -1
  336. package/lib/commonjs/core/identity-session/RefreshManager.js +0 -137
  337. package/lib/commonjs/core/identity-session/RefreshManager.js.map +0 -1
  338. package/lib/commonjs/core/identity-session/SessionManager.js +0 -427
  339. package/lib/commonjs/core/identity-session/SessionManager.js.map +0 -1
  340. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js +0 -24
  341. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js.map +0 -1
  342. package/lib/commonjs/core/identity-session/errors.js +0 -176
  343. package/lib/commonjs/core/identity-session/errors.js.map +0 -1
  344. package/lib/commonjs/core/identity-session/index.js +0 -80
  345. package/lib/commonjs/core/identity-session/index.js.map +0 -1
  346. package/lib/commonjs/core/identity-session/types.js +0 -2
  347. package/lib/commonjs/core/identity-session/types.js.map +0 -1
  348. package/lib/commonjs/crypto/README.md +0 -142
  349. package/lib/commonjs/crypto/core.js +0 -147
  350. package/lib/commonjs/crypto/core.js.map +0 -1
  351. package/lib/commonjs/node/signatureService.js +0 -107
  352. package/lib/commonjs/node/signatureService.js.map +0 -1
  353. package/lib/commonjs/ui/hooks/auth/index.js +0 -37
  354. package/lib/commonjs/ui/hooks/auth/index.js.map +0 -1
  355. package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js +0 -171
  356. package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js.map +0 -1
  357. package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -52
  358. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
  359. package/lib/commonjs/ui/hooks/useIdentityTransfer.js +0 -125
  360. package/lib/commonjs/ui/hooks/useIdentityTransfer.js.map +0 -1
  361. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js +0 -81
  362. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js.map +0 -1
  363. package/lib/commonjs/ui/hooks/useTransferQueries.js +0 -85
  364. package/lib/commonjs/ui/hooks/useTransferQueries.js.map +0 -1
  365. package/lib/commonjs/ui/stores/transferStore.js +0 -157
  366. package/lib/commonjs/ui/stores/transferStore.js.map +0 -1
  367. package/lib/module/adapters/expo/crypto.js +0 -51
  368. package/lib/module/adapters/expo/crypto.js.map +0 -1
  369. package/lib/module/adapters/expo/fetch.js +0 -26
  370. package/lib/module/adapters/expo/fetch.js.map +0 -1
  371. package/lib/module/adapters/expo/index.js +0 -45
  372. package/lib/module/adapters/expo/index.js.map +0 -1
  373. package/lib/module/adapters/expo/storage.js +0 -198
  374. package/lib/module/adapters/expo/storage.js.map +0 -1
  375. package/lib/module/adapters/index.js +0 -45
  376. package/lib/module/adapters/index.js.map +0 -1
  377. package/lib/module/adapters/node/crypto.js +0 -36
  378. package/lib/module/adapters/node/crypto.js.map +0 -1
  379. package/lib/module/adapters/node/fetch.js +0 -57
  380. package/lib/module/adapters/node/fetch.js.map +0 -1
  381. package/lib/module/adapters/node/index.js +0 -31
  382. package/lib/module/adapters/node/index.js.map +0 -1
  383. package/lib/module/adapters/node/storage.js +0 -159
  384. package/lib/module/adapters/node/storage.js.map +0 -1
  385. package/lib/module/core/identity-session/DeviceManager.js +0 -232
  386. package/lib/module/core/identity-session/DeviceManager.js.map +0 -1
  387. package/lib/module/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  388. package/lib/module/core/identity-session/IdentityManager.js +0 -395
  389. package/lib/module/core/identity-session/IdentityManager.js.map +0 -1
  390. package/lib/module/core/identity-session/IdentitySessionCore.js +0 -390
  391. package/lib/module/core/identity-session/IdentitySessionCore.js.map +0 -1
  392. package/lib/module/core/identity-session/RefreshManager.js +0 -132
  393. package/lib/module/core/identity-session/RefreshManager.js.map +0 -1
  394. package/lib/module/core/identity-session/SessionManager.js +0 -422
  395. package/lib/module/core/identity-session/SessionManager.js.map +0 -1
  396. package/lib/module/core/identity-session/createIdentitySessionCore.js +0 -21
  397. package/lib/module/core/identity-session/createIdentitySessionCore.js.map +0 -1
  398. package/lib/module/core/identity-session/errors.js +0 -170
  399. package/lib/module/core/identity-session/errors.js.map +0 -1
  400. package/lib/module/core/identity-session/index.js +0 -17
  401. package/lib/module/core/identity-session/index.js.map +0 -1
  402. package/lib/module/core/identity-session/types.js +0 -2
  403. package/lib/module/core/identity-session/types.js.map +0 -1
  404. package/lib/module/crypto/README.md +0 -142
  405. package/lib/module/crypto/core.js +0 -133
  406. package/lib/module/crypto/core.js.map +0 -1
  407. package/lib/module/node/signatureService.js +0 -101
  408. package/lib/module/node/signatureService.js.map +0 -1
  409. package/lib/module/ui/hooks/auth/index.js +0 -7
  410. package/lib/module/ui/hooks/auth/index.js.map +0 -1
  411. package/lib/module/ui/hooks/auth/useUsernameValidation.js +0 -167
  412. package/lib/module/ui/hooks/auth/useUsernameValidation.js.map +0 -1
  413. package/lib/module/ui/hooks/useAvatarPicker.js +0 -48
  414. package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
  415. package/lib/module/ui/hooks/useIdentityTransfer.js +0 -121
  416. package/lib/module/ui/hooks/useIdentityTransfer.js.map +0 -1
  417. package/lib/module/ui/hooks/useTransferCodesPersistence.js +0 -77
  418. package/lib/module/ui/hooks/useTransferCodesPersistence.js.map +0 -1
  419. package/lib/module/ui/hooks/useTransferQueries.js +0 -80
  420. package/lib/module/ui/hooks/useTransferQueries.js.map +0 -1
  421. package/lib/module/ui/stores/transferStore.js +0 -152
  422. package/lib/module/ui/stores/transferStore.js.map +0 -1
  423. package/lib/typescript/adapters/expo/crypto.d.ts +0 -17
  424. package/lib/typescript/adapters/expo/crypto.d.ts.map +0 -1
  425. package/lib/typescript/adapters/expo/fetch.d.ts +0 -16
  426. package/lib/typescript/adapters/expo/fetch.d.ts.map +0 -1
  427. package/lib/typescript/adapters/expo/index.d.ts +0 -23
  428. package/lib/typescript/adapters/expo/index.d.ts.map +0 -1
  429. package/lib/typescript/adapters/expo/storage.d.ts +0 -23
  430. package/lib/typescript/adapters/expo/storage.d.ts.map +0 -1
  431. package/lib/typescript/adapters/index.d.ts +0 -17
  432. package/lib/typescript/adapters/index.d.ts.map +0 -1
  433. package/lib/typescript/adapters/node/crypto.d.ts +0 -17
  434. package/lib/typescript/adapters/node/crypto.d.ts.map +0 -1
  435. package/lib/typescript/adapters/node/fetch.d.ts +0 -16
  436. package/lib/typescript/adapters/node/fetch.d.ts.map +0 -1
  437. package/lib/typescript/adapters/node/index.d.ts +0 -23
  438. package/lib/typescript/adapters/node/index.d.ts.map +0 -1
  439. package/lib/typescript/adapters/node/storage.d.ts +0 -23
  440. package/lib/typescript/adapters/node/storage.d.ts.map +0 -1
  441. package/lib/typescript/core/identity-session/DeviceManager.d.ts +0 -64
  442. package/lib/typescript/core/identity-session/DeviceManager.d.ts.map +0 -1
  443. package/lib/typescript/core/identity-session/IdentityManager.d.ts +0 -88
  444. package/lib/typescript/core/identity-session/IdentityManager.d.ts.map +0 -1
  445. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts +0 -141
  446. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts.map +0 -1
  447. package/lib/typescript/core/identity-session/RefreshManager.d.ts +0 -36
  448. package/lib/typescript/core/identity-session/RefreshManager.d.ts.map +0 -1
  449. package/lib/typescript/core/identity-session/SessionManager.d.ts +0 -104
  450. package/lib/typescript/core/identity-session/SessionManager.d.ts.map +0 -1
  451. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts +0 -11
  452. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts.map +0 -1
  453. package/lib/typescript/core/identity-session/errors.d.ts +0 -63
  454. package/lib/typescript/core/identity-session/errors.d.ts.map +0 -1
  455. package/lib/typescript/core/identity-session/index.d.ts +0 -14
  456. package/lib/typescript/core/identity-session/index.d.ts.map +0 -1
  457. package/lib/typescript/core/identity-session/types.d.ts +0 -196
  458. package/lib/typescript/core/identity-session/types.d.ts.map +0 -1
  459. package/lib/typescript/crypto/core.d.ts +0 -56
  460. package/lib/typescript/crypto/core.d.ts.map +0 -1
  461. package/lib/typescript/node/signatureService.d.ts +0 -55
  462. package/lib/typescript/node/signatureService.d.ts.map +0 -1
  463. package/lib/typescript/ui/hooks/auth/index.d.ts +0 -6
  464. package/lib/typescript/ui/hooks/auth/index.d.ts.map +0 -1
  465. package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts +0 -32
  466. package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts.map +0 -1
  467. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -18
  468. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
  469. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts +0 -24
  470. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts.map +0 -1
  471. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts +0 -6
  472. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts.map +0 -1
  473. package/lib/typescript/ui/hooks/useTransferQueries.d.ts +0 -26
  474. package/lib/typescript/ui/hooks/useTransferQueries.d.ts.map +0 -1
  475. package/lib/typescript/ui/stores/transferStore.d.ts +0 -36
  476. package/lib/typescript/ui/stores/transferStore.d.ts.map +0 -1
  477. package/src/adapters/expo/crypto.ts +0 -55
  478. package/src/adapters/expo/fetch.ts +0 -28
  479. package/src/adapters/expo/index.ts +0 -51
  480. package/src/adapters/expo/storage.ts +0 -228
  481. package/src/adapters/index.ts +0 -48
  482. package/src/adapters/node/crypto.ts +0 -39
  483. package/src/adapters/node/fetch.ts +0 -59
  484. package/src/adapters/node/index.ts +0 -37
  485. package/src/adapters/node/storage.ts +0 -170
  486. package/src/core/identity-session/DeviceManager.ts +0 -273
  487. package/src/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  488. package/src/core/identity-session/IdentityManager.ts +0 -474
  489. package/src/core/identity-session/IdentitySessionCore.ts +0 -464
  490. package/src/core/identity-session/RefreshManager.ts +0 -189
  491. package/src/core/identity-session/SessionManager.ts +0 -500
  492. package/src/core/identity-session/createIdentitySessionCore.ts +0 -19
  493. package/src/core/identity-session/errors.ts +0 -197
  494. package/src/core/identity-session/index.ts +0 -15
  495. package/src/core/identity-session/types.ts +0 -188
  496. package/src/crypto/README.md +0 -142
  497. package/src/crypto/__tests__/core.test.ts +0 -203
  498. package/src/crypto/core.ts +0 -142
  499. package/src/node/signatureService.ts +0 -126
  500. package/src/ui/hooks/auth/index.ts +0 -9
  501. package/src/ui/hooks/auth/useUsernameValidation.ts +0 -177
  502. package/src/ui/hooks/useAvatarPicker.ts +0 -62
  503. package/src/ui/hooks/useIdentityTransfer.ts +0 -135
  504. package/src/ui/hooks/useTransferCodesPersistence.ts +0 -80
  505. package/src/ui/hooks/useTransferQueries.ts +0 -102
  506. package/src/ui/stores/transferStore.ts +0 -201
@@ -0,0 +1,545 @@
1
+ "use strict";
2
+
3
+ import { useCallback } from 'react';
4
+ import { DeviceManager } from '../../../utils/deviceManager';
5
+ import { fetchSessionsWithFallback } from '../../utils/sessionHelpers';
6
+ import { handleAuthError, isInvalidSessionError } from '../../utils/errorHandlers';
7
+ import { KeyManager, SignatureService } from '../../../crypto';
8
+ const LOGIN_ERROR_CODE = 'LOGIN_ERROR';
9
+ const REGISTER_ERROR_CODE = 'REGISTER_ERROR';
10
+ const LOGOUT_ERROR_CODE = 'LOGOUT_ERROR';
11
+ const LOGOUT_ALL_ERROR_CODE = 'LOGOUT_ALL_ERROR';
12
+
13
+ /**
14
+ * Authentication operations using public key cryptography.
15
+ * No passwords required - identity is based on ECDSA key pairs.
16
+ */
17
+ export const useAuthOperations = ({
18
+ oxyServices,
19
+ storage,
20
+ sessions,
21
+ activeSessionId,
22
+ setActiveSessionId,
23
+ updateSessions,
24
+ saveActiveSessionId,
25
+ clearSessionState,
26
+ switchSession,
27
+ applyLanguagePreference,
28
+ onAuthStateChange,
29
+ onError,
30
+ loginSuccess,
31
+ loginFailure,
32
+ logoutStore,
33
+ setAuthState,
34
+ setIdentitySynced,
35
+ setSyncing,
36
+ logger
37
+ }) => {
38
+ /**
39
+ * Internal function to perform challenge-response sign in (works offline)
40
+ */
41
+ const performSignIn = useCallback(async publicKey => {
42
+ const deviceFingerprintObj = DeviceManager.getDeviceFingerprint();
43
+ const deviceFingerprint = JSON.stringify(deviceFingerprintObj);
44
+ const deviceInfo = await DeviceManager.getDeviceInfo();
45
+ const deviceName = deviceInfo.deviceName || DeviceManager.getDefaultDeviceName();
46
+ const USER_ID_STORAGE_KEY = 'oxy_user_id';
47
+
48
+ // Online-only sign-in: require backend availability
49
+ // First, resolve userId (prefer locally stored value)
50
+ let userId = null;
51
+ if (storage) {
52
+ userId = await storage.getItem(USER_ID_STORAGE_KEY);
53
+ }
54
+ if (!userId) {
55
+ const userLookup = await oxyServices.getUserByPublicKey(publicKey);
56
+ userId = userLookup.id;
57
+ if (storage && userId) {
58
+ await storage.setItem(USER_ID_STORAGE_KEY, userId).catch(() => {});
59
+ }
60
+ }
61
+ const challengeResponse = await oxyServices.requestChallenge(userId);
62
+ const challenge = challengeResponse.challenge;
63
+
64
+ // Note: Biometric authentication check should be handled by the app layer
65
+ // (e.g., accounts app) before calling signIn. The biometric preference is stored
66
+ // in local storage as 'oxy_biometric_enabled' and can be checked there.
67
+
68
+ // Sign the challenge
69
+ const {
70
+ challenge: signature,
71
+ timestamp
72
+ } = await SignatureService.signChallenge(challenge);
73
+
74
+ // Online sign-in: use normal flow
75
+ if (!userId) {
76
+ throw new Error('User ID not found');
77
+ }
78
+
79
+ // Verify and create session using userId
80
+ const sessionResponse = await oxyServices.verifyChallenge(userId, challenge, signature, timestamp, deviceName, deviceFingerprint);
81
+
82
+ // Store tokens immediately (no extra round-trip)
83
+ oxyServices.setTokens(sessionResponse.accessToken, sessionResponse.refreshToken);
84
+
85
+ // Get full user data
86
+ const fullUser = await oxyServices.getUserBySession(sessionResponse.sessionId);
87
+
88
+ // IMPORTANT: user.id should be MongoDB ObjectId, not publicKey
89
+ // The API should return the correct id (ObjectId) from the database
90
+ // If it doesn't, we need to fix the API, not work around it here
91
+ // Validate that id is ObjectId format (24 hex characters)
92
+ if (fullUser.id && !/^[0-9a-fA-F]{24}$/.test(fullUser.id)) {
93
+ console.warn('[useAuthOperations] User.id is not MongoDB ObjectId format:', {
94
+ id: fullUser.id.substring(0, 20),
95
+ publicKey: fullUser.publicKey.substring(0, 20),
96
+ message: 'API should return MongoDB ObjectId as user.id, not publicKey'
97
+ });
98
+ // Don't override - let the API fix this issue
99
+ }
100
+
101
+ // Fetch device sessions
102
+ let allDeviceSessions = [];
103
+ try {
104
+ allDeviceSessions = await fetchSessionsWithFallback(oxyServices, sessionResponse.sessionId, {
105
+ fallbackDeviceId: sessionResponse.deviceId,
106
+ fallbackUserId: fullUser.id,
107
+ logger
108
+ });
109
+ } catch (error) {
110
+ if (__DEV__) {
111
+ console.warn('Failed to fetch device sessions after login:', error);
112
+ }
113
+ }
114
+
115
+ // Check for existing session for same user
116
+ const existingSession = allDeviceSessions.find(session => session.userId?.toString() === fullUser.id?.toString() && session.sessionId !== sessionResponse.sessionId);
117
+ if (existingSession) {
118
+ // Logout duplicate session
119
+ try {
120
+ await oxyServices.logoutSession(sessionResponse.sessionId, sessionResponse.sessionId);
121
+ } catch (logoutError) {
122
+ if (__DEV__) {
123
+ console.warn('Failed to logout duplicate session:', logoutError);
124
+ }
125
+ }
126
+ await switchSession(existingSession.sessionId);
127
+ updateSessions(allDeviceSessions.filter(session => session.sessionId !== sessionResponse.sessionId), {
128
+ merge: false
129
+ });
130
+ onAuthStateChange?.(fullUser);
131
+ return fullUser;
132
+ }
133
+ setActiveSessionId(sessionResponse.sessionId);
134
+ await saveActiveSessionId(sessionResponse.sessionId);
135
+ updateSessions(allDeviceSessions, {
136
+ merge: true
137
+ });
138
+ await applyLanguagePreference(fullUser);
139
+ loginSuccess(); // Services never caches profile - only tokens
140
+ onAuthStateChange?.(fullUser);
141
+ if (storage) {
142
+ await storage.setItem('oxy_identity_synced', 'true').catch(() => {});
143
+ }
144
+ setIdentitySynced(true);
145
+ return fullUser;
146
+ }, [applyLanguagePreference, logger, loginSuccess, onAuthStateChange, oxyServices, saveActiveSessionId, setActiveSessionId, setIdentitySynced, switchSession, updateSessions, storage]);
147
+
148
+ /**
149
+ * Create a new identity (offline-first)
150
+ * Identity is purely cryptographic - no username or email required
151
+ */
152
+ const createIdentity = useCallback(async () => {
153
+ if (!storage) throw new Error('Storage not initialized');
154
+ setAuthState({
155
+ isLoading: true,
156
+ error: null
157
+ });
158
+ try {
159
+ // Generate new key pair directly (works offline)
160
+ const {
161
+ publicKey,
162
+ privateKey
163
+ } = await KeyManager.generateKeyPair();
164
+ await KeyManager.importKeyPair(privateKey);
165
+
166
+ // Mark as not synced
167
+ // Note: createIdentity only creates the key locally (offline-first)
168
+ // Registration with server (registerIdentity) must be done by the app (Accounts) with profile data
169
+ await storage.setItem('oxy_identity_synced', 'false');
170
+ setIdentitySynced(false);
171
+ return {
172
+ synced: false // Always false - registration must be done separately by Accounts app
173
+ };
174
+ } catch (error) {
175
+ // CRITICAL: Never delete identity on error - it may have been successfully created
176
+ // Only log the error and let the user recover using their backup file
177
+ // Identity deletion should ONLY happen when explicitly requested by the user
178
+ if (__DEV__ && logger) {
179
+ logger('Error during identity creation (identity may still exist):', error);
180
+ }
181
+
182
+ // Check if identity was actually created (keys exist)
183
+ const hasIdentity = await KeyManager.hasIdentity().catch(() => false);
184
+ if (hasIdentity) {
185
+ // Identity exists - don't delete it! Just mark as not synced
186
+ await storage.setItem('oxy_identity_synced', 'false').catch(() => {});
187
+ setIdentitySynced(false);
188
+ if (__DEV__ && logger) {
189
+ logger('Identity was created but sync failed - user can sync later using backup file');
190
+ }
191
+ } else {
192
+ // No identity exists - this was a generation failure, safe to clean up sync flag
193
+ await storage.removeItem('oxy_identity_synced').catch(() => {});
194
+ setIdentitySynced(false);
195
+ }
196
+ const message = handleAuthError(error, {
197
+ defaultMessage: 'Failed to create identity',
198
+ code: REGISTER_ERROR_CODE,
199
+ onError,
200
+ setAuthError: msg => setAuthState({
201
+ error: msg
202
+ }),
203
+ logger
204
+ });
205
+ loginFailure(message);
206
+ throw error;
207
+ } finally {
208
+ setAuthState({
209
+ isLoading: false
210
+ });
211
+ }
212
+ }, [oxyServices, storage, setAuthState, loginFailure, onError, logger, setIdentitySynced]);
213
+
214
+ /**
215
+ * Check if identity is synced with server (reads from storage for persistence)
216
+ */
217
+ const isIdentitySyncedFn = useCallback(async () => {
218
+ if (!storage) return true;
219
+ const synced = await storage.getItem('oxy_identity_synced');
220
+ const isSynced = synced !== 'false';
221
+ setIdentitySynced(isSynced);
222
+ return isSynced;
223
+ }, [storage, setIdentitySynced]);
224
+
225
+ /**
226
+ * Sync local identity with server (call when online)
227
+ * TanStack Query handles offline mutations automatically
228
+ */
229
+ const syncIdentity = useCallback(async () => {
230
+ if (!storage) throw new Error('Storage not initialized');
231
+ setAuthState({
232
+ isLoading: true,
233
+ error: null
234
+ });
235
+ setSyncing(true);
236
+ try {
237
+ const publicKey = await KeyManager.getPublicKey();
238
+ if (!publicKey) {
239
+ throw new Error('No identity found on this device');
240
+ }
241
+
242
+ // Check if already synced
243
+ const alreadySynced = await storage.getItem('oxy_identity_synced');
244
+ if (alreadySynced === 'true') {
245
+ setIdentitySynced(true);
246
+ return await performSignIn(publicKey);
247
+ }
248
+
249
+ // Check if already registered on server
250
+ const {
251
+ registered
252
+ } = await oxyServices.checkPublicKeyRegistered(publicKey);
253
+ if (!registered) {
254
+ // Identity is not registered - registration must be done by Accounts app with profile data
255
+ // syncIdentity only syncs already-registered identities
256
+ throw new Error('Identity is not registered. Please register your identity first using the Accounts app.');
257
+ }
258
+
259
+ // Mark as synced (Zustand store + storage)
260
+ await storage.setItem('oxy_identity_synced', 'true');
261
+ setIdentitySynced(true);
262
+
263
+ // Sign in (Services never caches profile - only tokens)
264
+ const user = await performSignIn(publicKey);
265
+
266
+ // Check if user has username - required for syncing
267
+ if (!user.username) {
268
+ const usernameError = new Error('USERNAME_REQUIRED');
269
+ usernameError.code = 'USERNAME_REQUIRED';
270
+ throw usernameError;
271
+ }
272
+
273
+ // TanStack Query will automatically retry any pending mutations
274
+
275
+ return user;
276
+ } catch (error) {
277
+ const message = handleAuthError(error, {
278
+ defaultMessage: 'Failed to sync identity',
279
+ code: REGISTER_ERROR_CODE,
280
+ onError,
281
+ setAuthError: msg => setAuthState({
282
+ error: msg
283
+ }),
284
+ logger
285
+ });
286
+ loginFailure(message);
287
+ throw error;
288
+ } finally {
289
+ setAuthState({
290
+ isLoading: false
291
+ });
292
+ setSyncing(false);
293
+ }
294
+ }, [oxyServices, storage, setAuthState, performSignIn, loginFailure, onError, logger, setSyncing, setIdentitySynced]);
295
+
296
+ /**
297
+ * Import identity from backup file data (offline-first)
298
+ */
299
+ const importIdentity = useCallback(async (backupData, password) => {
300
+ if (!storage) throw new Error('Storage not initialized');
301
+
302
+ // Validate arguments - ensure backupData is an object, not a string (old signature)
303
+ if (!backupData || typeof backupData !== 'object' || Array.isArray(backupData)) {
304
+ throw new Error('Invalid backup data. Please use the backup file import feature.');
305
+ }
306
+ if (!backupData.encrypted || !backupData.salt || !backupData.iv || !backupData.publicKey) {
307
+ throw new Error('Invalid backup data structure. Missing required fields.');
308
+ }
309
+ if (!password || typeof password !== 'string') {
310
+ throw new Error('Password is required for backup file import.');
311
+ }
312
+ setAuthState({
313
+ isLoading: true,
314
+ error: null
315
+ });
316
+ try {
317
+ // Decrypt private key from backup data
318
+ const Crypto = await import('expo-crypto');
319
+
320
+ // Convert hex strings to Uint8Array
321
+ const saltBytes = new Uint8Array(backupData.salt.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []);
322
+ const ivBytes = new Uint8Array(backupData.iv.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []);
323
+
324
+ // Derive key from password (same algorithm as EncryptedBackupGenerator)
325
+ const saltHex = Array.from(saltBytes).map(b => b.toString(16).padStart(2, '0')).join('');
326
+ let key = password + saltHex;
327
+ for (let i = 0; i < 10000; i++) {
328
+ key = await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, key);
329
+ }
330
+ const keyBytes = new Uint8Array(32);
331
+ for (let i = 0; i < 64 && i < key.length; i += 2) {
332
+ keyBytes[i / 2] = parseInt(key.substring(i, i + 2), 16);
333
+ }
334
+
335
+ // Decrypt private key (XOR decryption - same as encryption)
336
+ const encryptedBytes = Buffer.from(backupData.encrypted, 'base64');
337
+ const decryptedBytes = new Uint8Array(encryptedBytes.length);
338
+ for (let i = 0; i < encryptedBytes.length; i++) {
339
+ decryptedBytes[i] = encryptedBytes[i] ^ keyBytes[i % keyBytes.length] ^ ivBytes[i % ivBytes.length];
340
+ }
341
+ const privateKey = new TextDecoder().decode(decryptedBytes);
342
+
343
+ // Import the key pair
344
+ const publicKey = await KeyManager.importKeyPair(privateKey);
345
+
346
+ // Verify public key matches
347
+ if (publicKey !== backupData.publicKey) {
348
+ throw new Error('Backup file is corrupted or password is incorrect');
349
+ }
350
+
351
+ // Mark as not synced
352
+ await storage.setItem('oxy_identity_synced', 'false');
353
+ setIdentitySynced(false);
354
+
355
+ // Try to sync with server
356
+ try {
357
+ // Check if this identity is already registered
358
+ const {
359
+ registered
360
+ } = await oxyServices.checkPublicKeyRegistered(publicKey);
361
+ if (registered) {
362
+ // Identity exists, mark as synced
363
+ await storage.setItem('oxy_identity_synced', 'true');
364
+ setIdentitySynced(true);
365
+ return {
366
+ synced: true
367
+ };
368
+ } else {
369
+ // Identity is not registered - registration must be done by Accounts app with profile data
370
+ // importIdentity only imports already-registered identities
371
+ await storage.setItem('oxy_identity_synced', 'false');
372
+ setIdentitySynced(false);
373
+ return {
374
+ synced: false
375
+ };
376
+ }
377
+ } catch (syncError) {
378
+ // Offline - identity restored locally but not synced
379
+ if (__DEV__) {
380
+ console.log('[Auth] Identity imported locally, will sync when online:', syncError);
381
+ }
382
+ return {
383
+ synced: false
384
+ };
385
+ }
386
+ } catch (error) {
387
+ const message = handleAuthError(error, {
388
+ defaultMessage: 'Failed to import identity. Please check your password and backup file.',
389
+ code: REGISTER_ERROR_CODE,
390
+ onError,
391
+ setAuthError: msg => setAuthState({
392
+ error: msg
393
+ }),
394
+ logger
395
+ });
396
+ loginFailure(message);
397
+ throw error;
398
+ } finally {
399
+ setAuthState({
400
+ isLoading: false
401
+ });
402
+ }
403
+ }, [oxyServices, storage, setAuthState, loginFailure, onError, logger, setIdentitySynced]);
404
+
405
+ /**
406
+ * Sign in with existing identity on device
407
+ */
408
+ const signIn = useCallback(async deviceName => {
409
+ if (!storage) throw new Error('Storage not initialized');
410
+ setAuthState({
411
+ isLoading: true,
412
+ error: null
413
+ });
414
+ try {
415
+ // Get stored public key
416
+ const publicKey = await KeyManager.getPublicKey();
417
+ if (!publicKey) {
418
+ throw new Error('No identity found on this device. Please create or import an identity.');
419
+ }
420
+
421
+ // Ensure identity is registered before attempting sign-in
422
+ const {
423
+ registered
424
+ } = await oxyServices.checkPublicKeyRegistered(publicKey);
425
+ if (!registered) {
426
+ throw new Error('Identity is not registered. Please register your identity in the Accounts app before signing in.');
427
+ }
428
+ return await performSignIn(publicKey);
429
+ } catch (error) {
430
+ const message = handleAuthError(error, {
431
+ defaultMessage: 'Sign in failed',
432
+ code: LOGIN_ERROR_CODE,
433
+ onError,
434
+ setAuthError: msg => setAuthState({
435
+ error: msg
436
+ }),
437
+ logger
438
+ });
439
+ loginFailure(message);
440
+ throw error;
441
+ } finally {
442
+ setAuthState({
443
+ isLoading: false
444
+ });
445
+ }
446
+ }, [storage, setAuthState, performSignIn, loginFailure, onError, logger, oxyServices]);
447
+
448
+ /**
449
+ * Logout from session
450
+ */
451
+ const logout = useCallback(async targetSessionId => {
452
+ if (!activeSessionId) return;
453
+ try {
454
+ const sessionToLogout = targetSessionId || activeSessionId;
455
+ await oxyServices.logoutSession(activeSessionId, sessionToLogout);
456
+ const filteredSessions = sessions.filter(session => session.sessionId !== sessionToLogout);
457
+ updateSessions(filteredSessions, {
458
+ merge: false
459
+ });
460
+ if (sessionToLogout === activeSessionId) {
461
+ if (filteredSessions.length > 0) {
462
+ await switchSession(filteredSessions[0].sessionId);
463
+ } else {
464
+ await clearSessionState();
465
+ return;
466
+ }
467
+ }
468
+ } catch (error) {
469
+ const isInvalid = isInvalidSessionError(error);
470
+ if (isInvalid && targetSessionId === activeSessionId) {
471
+ await clearSessionState();
472
+ return;
473
+ }
474
+ handleAuthError(error, {
475
+ defaultMessage: 'Logout failed',
476
+ code: LOGOUT_ERROR_CODE,
477
+ onError,
478
+ setAuthError: msg => setAuthState({
479
+ error: msg
480
+ }),
481
+ logger,
482
+ status: isInvalid ? 401 : undefined
483
+ });
484
+ }
485
+ }, [activeSessionId, clearSessionState, logger, onError, oxyServices, sessions, setAuthState, switchSession, updateSessions]);
486
+
487
+ /**
488
+ * Logout from all sessions
489
+ */
490
+ const logoutAll = useCallback(async () => {
491
+ if (!activeSessionId) {
492
+ const error = new Error('No active session found');
493
+ setAuthState({
494
+ error: error.message
495
+ });
496
+ onError?.({
497
+ message: error.message,
498
+ code: LOGOUT_ALL_ERROR_CODE,
499
+ status: 404
500
+ });
501
+ throw error;
502
+ }
503
+ try {
504
+ await oxyServices.logoutAllSessions(activeSessionId);
505
+ await clearSessionState();
506
+ } catch (error) {
507
+ handleAuthError(error, {
508
+ defaultMessage: 'Logout all failed',
509
+ code: LOGOUT_ALL_ERROR_CODE,
510
+ onError,
511
+ setAuthError: msg => setAuthState({
512
+ error: msg
513
+ }),
514
+ logger
515
+ });
516
+ throw error instanceof Error ? error : new Error('Logout all failed');
517
+ }
518
+ }, [activeSessionId, clearSessionState, logger, onError, oxyServices, setAuthState]);
519
+
520
+ /**
521
+ * Check if device has an identity stored
522
+ */
523
+ const hasIdentity = useCallback(async () => {
524
+ return KeyManager.hasIdentity();
525
+ }, []);
526
+
527
+ /**
528
+ * Get the public key of the stored identity
529
+ */
530
+ const getPublicKey = useCallback(async () => {
531
+ return KeyManager.getPublicKey();
532
+ }, []);
533
+ return {
534
+ createIdentity,
535
+ importIdentity,
536
+ signIn,
537
+ logout,
538
+ logoutAll,
539
+ hasIdentity,
540
+ getPublicKey,
541
+ isIdentitySynced: isIdentitySyncedFn,
542
+ syncIdentity
543
+ };
544
+ };
545
+ //# sourceMappingURL=useAuthOperations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","DeviceManager","fetchSessionsWithFallback","handleAuthError","isInvalidSessionError","KeyManager","SignatureService","LOGIN_ERROR_CODE","REGISTER_ERROR_CODE","LOGOUT_ERROR_CODE","LOGOUT_ALL_ERROR_CODE","useAuthOperations","oxyServices","storage","sessions","activeSessionId","setActiveSessionId","updateSessions","saveActiveSessionId","clearSessionState","switchSession","applyLanguagePreference","onAuthStateChange","onError","loginSuccess","loginFailure","logoutStore","setAuthState","setIdentitySynced","setSyncing","logger","performSignIn","publicKey","deviceFingerprintObj","getDeviceFingerprint","deviceFingerprint","JSON","stringify","deviceInfo","getDeviceInfo","deviceName","getDefaultDeviceName","USER_ID_STORAGE_KEY","userId","getItem","userLookup","getUserByPublicKey","id","setItem","catch","challengeResponse","requestChallenge","challenge","signature","timestamp","signChallenge","Error","sessionResponse","verifyChallenge","setTokens","accessToken","refreshToken","fullUser","getUserBySession","sessionId","test","console","warn","substring","message","allDeviceSessions","fallbackDeviceId","deviceId","fallbackUserId","error","__DEV__","existingSession","find","session","toString","logoutSession","logoutError","filter","merge","createIdentity","isLoading","privateKey","generateKeyPair","importKeyPair","synced","hasIdentity","removeItem","defaultMessage","code","setAuthError","msg","isIdentitySyncedFn","isSynced","syncIdentity","getPublicKey","alreadySynced","registered","checkPublicKeyRegistered","user","username","usernameError","importIdentity","backupData","password","Array","isArray","encrypted","salt","iv","Crypto","saltBytes","Uint8Array","match","map","byte","parseInt","ivBytes","saltHex","from","b","padStart","join","key","i","digestStringAsync","CryptoDigestAlgorithm","SHA256","keyBytes","length","encryptedBytes","Buffer","decryptedBytes","TextDecoder","decode","syncError","log","signIn","logout","targetSessionId","sessionToLogout","filteredSessions","isInvalid","status","undefined","logoutAll","logoutAllSessions","isIdentitySynced"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useAuthOperations.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAInC,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASC,yBAAyB,QAA6B,4BAA4B;AAC3F,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,2BAA2B;AAGlF,SAASC,UAAU,EAAEC,gBAAgB,QAAyB,iBAAiB;AA8C/E,MAAMC,gBAAgB,GAAG,aAAa;AACtC,MAAMC,mBAAmB,GAAG,gBAAgB;AAC5C,MAAMC,iBAAiB,GAAG,cAAc;AACxC,MAAMC,qBAAqB,GAAG,kBAAkB;;AAEhD;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,WAAW;EACXC,OAAO;EACPC,QAAQ;EACRC,eAAe;EACfC,kBAAkB;EAClBC,cAAc;EACdC,mBAAmB;EACnBC,iBAAiB;EACjBC,aAAa;EACbC,uBAAuB;EACvBC,iBAAiB;EACjBC,OAAO;EACPC,YAAY;EACZC,YAAY;EACZC,WAAW;EACTC,YAAY;EACZC,iBAAiB;EACjBC,UAAU;EACVC;AACsB,CAAC,KAA8B;EAEvD;AACF;AACA;EACE,MAAMC,aAAa,GAAG/B,WAAW,CAC/B,MAAOgC,SAAiB,IAAoB;IAC1C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vE;EACF,CAAC,EAAE,CAACzC,eAAe,EAAEI,iBAAiB,EAAEW,MAAM,EAAEP,OAAO,EAAEX,WAAW,EAAEe,YAAY,CAAC,CAAC;;EAEpF;AACF;AACA;EACE,MAAM+D,WAAW,GAAG1F,WAAW,CAAC,YAA8B;IAC5D,OAAOK,UAAU,CAACqF,WAAW,CAAC,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;;EAEN;AACF;AACA;EACE,MAAMS,YAAY,GAAGnG,WAAW,CAAC,YAAoC;IACnE,OAAOK,UAAU,CAAC8F,YAAY,CAAC,CAAC;EAClC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACLf,cAAc;IACdsB,cAAc;IACdmC,MAAM;IACNC,MAAM;IACNO,SAAS;IACT3D,WAAW;IACXS,YAAY;IACZoD,gBAAgB,EAAEvD,kBAAkB;IACpCE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ import { useCallback } from 'react';
4
+ import { DeviceManager } from '../../../utils/deviceManager';
5
+ import { handleAuthError } from '../../utils/errorHandlers';
6
+ /**
7
+ * Provide device session management helpers tied to the current active session.
8
+ *
9
+ * @param options - Device management configuration
10
+ */
11
+ export const useDeviceManagement = ({
12
+ oxyServices,
13
+ activeSessionId,
14
+ onError,
15
+ clearSessionState,
16
+ logger
17
+ }) => {
18
+ const getDeviceSessions = useCallback(async () => {
19
+ if (!activeSessionId) throw new Error('No active session');
20
+ try {
21
+ return await oxyServices.getDeviceSessions(activeSessionId);
22
+ } catch (error) {
23
+ handleAuthError(error, {
24
+ defaultMessage: 'Failed to get device sessions',
25
+ code: 'GET_DEVICE_SESSIONS_ERROR',
26
+ onError,
27
+ logger
28
+ });
29
+ throw error instanceof Error ? error : new Error('Failed to get device sessions');
30
+ }
31
+ }, [activeSessionId, logger, onError, oxyServices]);
32
+ const logoutAllDeviceSessions = useCallback(async () => {
33
+ if (!activeSessionId) throw new Error('No active session');
34
+ try {
35
+ await oxyServices.logoutAllDeviceSessions(activeSessionId);
36
+ await clearSessionState();
37
+ } catch (error) {
38
+ handleAuthError(error, {
39
+ defaultMessage: 'Failed to logout all device sessions',
40
+ code: 'LOGOUT_ALL_DEVICES_ERROR',
41
+ onError,
42
+ logger
43
+ });
44
+ throw error instanceof Error ? error : new Error('Failed to logout all device sessions');
45
+ }
46
+ }, [activeSessionId, clearSessionState, logger, onError, oxyServices]);
47
+ const updateDeviceName = useCallback(async deviceName => {
48
+ if (!activeSessionId) throw new Error('No active session');
49
+ try {
50
+ await oxyServices.updateDeviceName(activeSessionId, deviceName);
51
+ await DeviceManager.updateDeviceName(deviceName);
52
+ } catch (error) {
53
+ handleAuthError(error, {
54
+ defaultMessage: 'Failed to update device name',
55
+ code: 'UPDATE_DEVICE_NAME_ERROR',
56
+ onError,
57
+ logger
58
+ });
59
+ throw error instanceof Error ? error : new Error('Failed to update device name');
60
+ }
61
+ }, [activeSessionId, logger, onError, oxyServices]);
62
+ return {
63
+ getDeviceSessions,
64
+ logoutAllDeviceSessions,
65
+ updateDeviceName
66
+ };
67
+ };
68
+ //# sourceMappingURL=useDeviceManagement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","DeviceManager","handleAuthError","useDeviceManagement","oxyServices","activeSessionId","onError","clearSessionState","logger","getDeviceSessions","Error","error","defaultMessage","code","logoutAllDeviceSessions","updateDeviceName","deviceName"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useDeviceManagement.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAEnC,SAASC,aAAa,QAAQ,8BAA8B;AAE5D,SAASC,eAAe,QAAQ,2BAA2B;AAwB3D;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CAAC;EAClCC,WAAW;EACXC,eAAe;EACfC,OAAO;EACPC,iBAAiB;EACjBC;AAC0B,CAAC,KAAgC;EAC3D,MAAMC,iBAAiB,GAAGT,WAAW,CAAC,YAQjC;IAC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