@oxyhq/services 5.17.17 → 5.17.18

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 (403) hide show
  1. package/README.md +32 -38
  2. package/lib/commonjs/core/CrossDomainAuth.js +277 -0
  3. package/lib/commonjs/core/CrossDomainAuth.js.map +1 -0
  4. package/lib/commonjs/core/HttpService.js +82 -15
  5. package/lib/commonjs/core/HttpService.js.map +1 -1
  6. package/lib/commonjs/core/OxyServices.base.js +11 -3
  7. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  8. package/lib/commonjs/core/OxyServices.js +4 -1
  9. package/lib/commonjs/core/OxyServices.js.map +1 -1
  10. package/lib/commonjs/core/index.js +30 -0
  11. package/lib/commonjs/core/index.js.map +1 -1
  12. package/lib/commonjs/core/mixins/OxyServices.assets.js +16 -3
  13. package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
  14. package/lib/commonjs/core/mixins/OxyServices.auth.js +73 -32
  15. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
  16. package/lib/commonjs/core/mixins/OxyServices.fedcm.js +289 -0
  17. package/lib/commonjs/core/mixins/OxyServices.fedcm.js.map +1 -0
  18. package/lib/commonjs/core/mixins/OxyServices.popup.js +352 -0
  19. package/lib/commonjs/core/mixins/OxyServices.popup.js.map +1 -0
  20. package/lib/commonjs/core/mixins/OxyServices.redirect.js +378 -0
  21. package/lib/commonjs/core/mixins/OxyServices.redirect.js.map +1 -0
  22. package/lib/commonjs/core/mixins/OxyServices.user.js +35 -24
  23. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  24. package/lib/commonjs/core/mixins/index.js +27 -15
  25. package/lib/commonjs/core/mixins/index.js.map +1 -1
  26. package/lib/commonjs/crypto/index.js +30 -0
  27. package/lib/commonjs/crypto/index.js.map +1 -1
  28. package/lib/commonjs/crypto/keyManager.js +902 -0
  29. package/lib/commonjs/crypto/keyManager.js.map +1 -0
  30. package/lib/commonjs/crypto/polyfill.js +14 -5
  31. package/lib/commonjs/crypto/polyfill.js.map +1 -1
  32. package/lib/commonjs/crypto/recoveryPhrase.js +152 -0
  33. package/lib/commonjs/crypto/recoveryPhrase.js.map +1 -0
  34. package/lib/commonjs/crypto/signatureService.js +289 -0
  35. package/lib/commonjs/crypto/signatureService.js.map +1 -0
  36. package/lib/commonjs/i18n/locales/en-US.json +1 -1
  37. package/lib/commonjs/index.js +40 -26
  38. package/lib/commonjs/index.js.map +1 -1
  39. package/lib/commonjs/models/interfaces.js +0 -15
  40. package/lib/commonjs/models/interfaces.js.map +1 -1
  41. package/lib/commonjs/ui/components/BottomSheetRouter.js +9 -1
  42. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  43. package/lib/commonjs/ui/components/Icon.js.map +1 -1
  44. package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
  45. package/lib/commonjs/ui/components/OxyProvider.js +41 -11
  46. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  47. package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
  48. package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
  49. package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
  50. package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
  51. package/lib/commonjs/ui/context/OxyContext.js +110 -199
  52. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  53. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +150 -19
  54. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  55. package/lib/commonjs/ui/context/hooks/useSessionManagement.js +279 -0
  56. package/lib/commonjs/ui/context/hooks/useSessionManagement.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +79 -72
  58. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  59. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +38 -51
  60. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  61. package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js +3 -3
  62. package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js.map +1 -1
  63. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +18 -12
  64. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  65. package/lib/commonjs/ui/hooks/useProfileEditing.js +3 -5
  66. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  67. package/lib/commonjs/ui/hooks/useSessionManagement.js +4 -8
  68. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  69. package/lib/commonjs/ui/hooks/useSessionSocket.js +162 -315
  70. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  71. package/lib/commonjs/ui/hooks/useStorage.js +24 -58
  72. package/lib/commonjs/ui/hooks/useStorage.js.map +1 -1
  73. package/lib/commonjs/ui/index.js +50 -21
  74. package/lib/commonjs/ui/index.js.map +1 -1
  75. package/lib/commonjs/ui/navigation/routes.js +5 -1
  76. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  77. package/lib/commonjs/ui/screens/AccountCenterScreen.js +2 -2
  78. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  79. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  80. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +29 -24
  81. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  82. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +3 -3
  83. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  84. package/lib/commonjs/ui/screens/OxyAuthScreen.js +134 -66
  85. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  86. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +6 -13
  87. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  88. package/lib/commonjs/ui/stores/accountStore.js +2 -4
  89. package/lib/commonjs/ui/stores/accountStore.js.map +1 -1
  90. package/lib/commonjs/ui/stores/authStore.js +45 -32
  91. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  92. package/lib/commonjs/ui/styles/spacing.js +54 -2
  93. package/lib/commonjs/ui/styles/spacing.js.map +1 -1
  94. package/lib/commonjs/ui/utils/avatarUtils.js +37 -41
  95. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  96. package/lib/commonjs/ui/utils/storageHelpers.js.map +1 -1
  97. package/lib/commonjs/utils/errorUtils.js +13 -0
  98. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  99. package/lib/commonjs/utils/validationUtils.js +15 -1
  100. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  101. package/lib/module/core/CrossDomainAuth.js +271 -0
  102. package/lib/module/core/CrossDomainAuth.js.map +1 -0
  103. package/lib/module/core/HttpService.js +82 -15
  104. package/lib/module/core/HttpService.js.map +1 -1
  105. package/lib/module/core/OxyServices.base.js +11 -4
  106. package/lib/module/core/OxyServices.base.js.map +1 -1
  107. package/lib/module/core/OxyServices.js +4 -1
  108. package/lib/module/core/OxyServices.js.map +1 -1
  109. package/lib/module/core/index.js +6 -1
  110. package/lib/module/core/index.js.map +1 -1
  111. package/lib/module/core/mixins/OxyServices.assets.js +16 -3
  112. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
  113. package/lib/module/core/mixins/OxyServices.auth.js +73 -32
  114. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
  115. package/lib/module/core/mixins/OxyServices.fedcm.js +286 -0
  116. package/lib/module/core/mixins/OxyServices.fedcm.js.map +1 -0
  117. package/lib/module/core/mixins/OxyServices.popup.js +349 -0
  118. package/lib/module/core/mixins/OxyServices.popup.js.map +1 -0
  119. package/lib/module/core/mixins/OxyServices.redirect.js +375 -0
  120. package/lib/module/core/mixins/OxyServices.redirect.js.map +1 -0
  121. package/lib/module/core/mixins/OxyServices.user.js +35 -24
  122. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  123. package/lib/module/core/mixins/index.js +15 -3
  124. package/lib/module/core/mixins/index.js.map +1 -1
  125. package/lib/module/crypto/index.js +8 -4
  126. package/lib/module/crypto/index.js.map +1 -1
  127. package/lib/module/crypto/keyManager.js +899 -0
  128. package/lib/module/crypto/keyManager.js.map +1 -0
  129. package/lib/module/crypto/polyfill.js +6 -5
  130. package/lib/module/crypto/polyfill.js.map +1 -1
  131. package/lib/module/crypto/recoveryPhrase.js +147 -0
  132. package/lib/module/crypto/recoveryPhrase.js.map +1 -0
  133. package/lib/module/crypto/signatureService.js +286 -0
  134. package/lib/module/crypto/signatureService.js.map +1 -0
  135. package/lib/module/i18n/locales/en-US.json +1 -1
  136. package/lib/module/index.js +6 -9
  137. package/lib/module/index.js.map +1 -1
  138. package/lib/module/models/interfaces.js +0 -15
  139. package/lib/module/models/interfaces.js.map +1 -1
  140. package/lib/module/ui/components/BottomSheetRouter.js +6 -2
  141. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  142. package/lib/module/ui/components/Icon.js.map +1 -1
  143. package/lib/module/ui/components/IconButton/utils.js.map +1 -1
  144. package/lib/module/ui/components/OxyProvider.js +41 -11
  145. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  146. package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
  147. package/lib/module/ui/components/TextField/helpers.js.map +1 -1
  148. package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
  149. package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
  150. package/lib/module/ui/context/OxyContext.js +112 -191
  151. package/lib/module/ui/context/OxyContext.js.map +1 -1
  152. package/lib/module/ui/context/hooks/useAuthOperations.js +150 -19
  153. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  154. package/lib/module/ui/context/hooks/useSessionManagement.js +274 -0
  155. package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -0
  156. package/lib/module/ui/hooks/mutations/useAccountMutations.js +80 -72
  157. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  158. package/lib/module/ui/hooks/queries/useAccountQueries.js +31 -44
  159. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  160. package/lib/module/ui/hooks/queries/useSecurityQueries.js +1 -1
  161. package/lib/module/ui/hooks/queries/useSecurityQueries.js.map +1 -1
  162. package/lib/module/ui/hooks/queries/useServicesQueries.js +13 -7
  163. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  164. package/lib/module/ui/hooks/useProfileEditing.js +3 -5
  165. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  166. package/lib/module/ui/hooks/useSessionManagement.js +4 -8
  167. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  168. package/lib/module/ui/hooks/useSessionSocket.js +162 -315
  169. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  170. package/lib/module/ui/hooks/useStorage.js +25 -59
  171. package/lib/module/ui/hooks/useStorage.js.map +1 -1
  172. package/lib/module/ui/index.js +15 -10
  173. package/lib/module/ui/index.js.map +1 -1
  174. package/lib/module/ui/navigation/routes.js +5 -1
  175. package/lib/module/ui/navigation/routes.js.map +1 -1
  176. package/lib/module/ui/screens/AccountCenterScreen.js +2 -2
  177. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  178. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  179. package/lib/module/ui/screens/AccountSettingsScreen.js +29 -24
  180. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  181. package/lib/module/ui/screens/AccountSwitcherScreen.js +3 -3
  182. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  183. package/lib/module/ui/screens/OxyAuthScreen.js +135 -68
  184. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  185. package/lib/module/ui/screens/PrivacySettingsScreen.js +6 -13
  186. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  187. package/lib/module/ui/stores/accountStore.js +2 -4
  188. package/lib/module/ui/stores/accountStore.js.map +1 -1
  189. package/lib/module/ui/stores/authStore.js +45 -32
  190. package/lib/module/ui/stores/authStore.js.map +1 -1
  191. package/lib/module/ui/styles/spacing.js +6 -2
  192. package/lib/module/ui/styles/spacing.js.map +1 -1
  193. package/lib/module/ui/utils/avatarUtils.js +37 -40
  194. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  195. package/lib/module/ui/utils/storageHelpers.js.map +1 -1
  196. package/lib/module/utils/errorUtils.js +7 -0
  197. package/lib/module/utils/errorUtils.js.map +1 -1
  198. package/lib/module/utils/validationUtils.js +13 -0
  199. package/lib/module/utils/validationUtils.js.map +1 -1
  200. package/lib/typescript/core/CrossDomainAuth.d.ts +161 -0
  201. package/lib/typescript/core/CrossDomainAuth.d.ts.map +1 -0
  202. package/lib/typescript/core/HttpService.d.ts +1 -1
  203. package/lib/typescript/core/HttpService.d.ts.map +1 -1
  204. package/lib/typescript/core/OxyServices.base.d.ts +0 -6
  205. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  206. package/lib/typescript/core/OxyServices.d.ts +5 -36
  207. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  208. package/lib/typescript/core/index.d.ts +4 -0
  209. package/lib/typescript/core/index.d.ts.map +1 -1
  210. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  211. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  212. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +40 -20
  213. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  214. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  215. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  216. package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts +195 -0
  217. package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts.map +1 -0
  218. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  219. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  220. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  221. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  222. package/lib/typescript/core/mixins/OxyServices.popup.d.ts +206 -0
  223. package/lib/typescript/core/mixins/OxyServices.popup.d.ts.map +1 -0
  224. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  225. package/lib/typescript/core/mixins/OxyServices.redirect.d.ts +246 -0
  226. package/lib/typescript/core/mixins/OxyServices.redirect.d.ts.map +1 -0
  227. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  228. package/lib/typescript/core/mixins/OxyServices.user.d.ts +6 -4
  229. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  230. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  231. package/lib/typescript/core/mixins/index.d.ts +220 -8
  232. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  233. package/lib/typescript/crypto/index.d.ts +6 -3
  234. package/lib/typescript/crypto/index.d.ts.map +1 -1
  235. package/lib/typescript/crypto/keyManager.d.ts +190 -0
  236. package/lib/typescript/crypto/keyManager.d.ts.map +1 -0
  237. package/lib/typescript/crypto/polyfill.d.ts +4 -3
  238. package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
  239. package/lib/typescript/crypto/recoveryPhrase.d.ts +59 -0
  240. package/lib/typescript/crypto/recoveryPhrase.d.ts.map +1 -0
  241. package/lib/typescript/crypto/signatureService.d.ts +87 -0
  242. package/lib/typescript/crypto/signatureService.d.ts.map +1 -0
  243. package/lib/typescript/index.d.ts +5 -6
  244. package/lib/typescript/index.d.ts.map +1 -1
  245. package/lib/typescript/models/interfaces.d.ts +2 -14
  246. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  247. package/lib/typescript/models/session.d.ts +0 -9
  248. package/lib/typescript/models/session.d.ts.map +1 -1
  249. package/lib/typescript/types/bip39.d.ts +32 -0
  250. package/lib/typescript/ui/components/BottomSheetRouter.d.ts +5 -0
  251. package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
  252. package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
  253. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  254. package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
  255. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
  256. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
  257. package/lib/typescript/ui/components/TextField/helpers.d.ts +8 -8
  258. package/lib/typescript/ui/components/TextField/types.d.ts +1 -0
  259. package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
  260. package/lib/typescript/ui/components/types.d.ts +4 -0
  261. package/lib/typescript/ui/components/types.d.ts.map +1 -1
  262. package/lib/typescript/ui/context/OxyContext.d.ts +57 -3
  263. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  264. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -3
  265. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  266. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +41 -0
  267. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -0
  268. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  269. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  270. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  271. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  272. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  273. package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -2
  274. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  275. package/lib/typescript/ui/hooks/useStorage.d.ts +3 -9
  276. package/lib/typescript/ui/hooks/useStorage.d.ts.map +1 -1
  277. package/lib/typescript/ui/index.d.ts +6 -2
  278. package/lib/typescript/ui/index.d.ts.map +1 -1
  279. package/lib/typescript/ui/navigation/routes.d.ts +1 -1
  280. package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
  281. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  282. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts +1 -1
  283. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  284. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  285. package/lib/typescript/ui/stores/accountStore.d.ts.map +1 -1
  286. package/lib/typescript/ui/stores/authStore.d.ts +8 -7
  287. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  288. package/lib/typescript/ui/styles/spacing.d.ts +5 -0
  289. package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
  290. package/lib/typescript/ui/types/navigation.d.ts +2 -1
  291. package/lib/typescript/ui/types/navigation.d.ts.map +1 -1
  292. package/lib/typescript/ui/utils/avatarUtils.d.ts +2 -13
  293. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  294. package/lib/typescript/ui/utils/storageHelpers.d.ts +0 -3
  295. package/lib/typescript/ui/utils/storageHelpers.d.ts.map +1 -1
  296. package/lib/typescript/utils/errorUtils.d.ts +6 -0
  297. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  298. package/lib/typescript/utils/validationUtils.d.ts +8 -0
  299. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  300. package/package.json +8 -7
  301. package/src/core/CrossDomainAuth.ts +307 -0
  302. package/src/core/HttpService.ts +99 -16
  303. package/src/core/OxyServices.base.ts +20 -3
  304. package/src/core/OxyServices.ts +7 -3
  305. package/src/core/index.ts +9 -1
  306. package/src/core/mixins/OxyServices.assets.ts +14 -3
  307. package/src/core/mixins/OxyServices.auth.ts +105 -36
  308. package/src/core/mixins/OxyServices.fedcm.ts +315 -0
  309. package/src/core/mixins/OxyServices.popup.ts +402 -0
  310. package/src/core/mixins/OxyServices.redirect.ts +397 -0
  311. package/src/core/mixins/OxyServices.user.ts +39 -24
  312. package/src/core/mixins/index.ts +19 -3
  313. package/src/crypto/index.ts +16 -5
  314. package/src/crypto/keyManager.ts +966 -0
  315. package/src/crypto/polyfill.ts +6 -5
  316. package/src/crypto/recoveryPhrase.ts +166 -0
  317. package/src/crypto/signatureService.ts +323 -0
  318. package/src/i18n/locales/en-US.json +1 -1
  319. package/src/index.ts +19 -15
  320. package/src/models/interfaces.ts +4 -16
  321. package/src/models/session.ts +2 -11
  322. package/src/types/bip39.d.ts +32 -0
  323. package/src/ui/components/BottomSheetRouter.tsx +6 -1
  324. package/src/ui/components/Icon.tsx +1 -1
  325. package/src/ui/components/IconButton/utils.ts +1 -1
  326. package/src/ui/components/OxyProvider.tsx +44 -12
  327. package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
  328. package/src/ui/components/TextField/Adornment/utils.ts +2 -2
  329. package/src/ui/components/TextField/helpers.tsx +10 -10
  330. package/src/ui/components/TextField/types.tsx +1 -1
  331. package/src/ui/components/TouchableRipple/utils.ts +2 -2
  332. package/src/ui/components/Typography/AnimatedText.tsx +2 -2
  333. package/src/ui/components/types.tsx +6 -0
  334. package/src/ui/context/OxyContext.tsx +173 -195
  335. package/src/ui/context/hooks/useAuthOperations.ts +177 -36
  336. package/src/ui/context/hooks/useSessionManagement.ts +399 -0
  337. package/src/ui/hooks/mutations/useAccountMutations.ts +83 -76
  338. package/src/ui/hooks/queries/useAccountQueries.ts +29 -35
  339. package/src/ui/hooks/queries/useSecurityQueries.ts +1 -1
  340. package/src/ui/hooks/queries/useServicesQueries.ts +14 -6
  341. package/src/ui/hooks/useProfileEditing.ts +3 -3
  342. package/src/ui/hooks/useSessionManagement.ts +5 -10
  343. package/src/ui/hooks/useSessionSocket.ts +46 -175
  344. package/src/ui/hooks/useStorage.ts +24 -76
  345. package/src/ui/index.ts +22 -13
  346. package/src/ui/navigation/routes.ts +6 -2
  347. package/src/ui/screens/AccountCenterScreen.tsx +2 -2
  348. package/src/ui/screens/AccountOverviewScreen.tsx +1 -1
  349. package/src/ui/screens/AccountSettingsScreen.tsx +34 -37
  350. package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
  351. package/src/ui/screens/OxyAuthScreen.tsx +138 -64
  352. package/src/ui/screens/PrivacySettingsScreen.tsx +6 -12
  353. package/src/ui/stores/accountStore.ts +1 -11
  354. package/src/ui/stores/authStore.ts +43 -44
  355. package/src/ui/styles/spacing.ts +15 -2
  356. package/src/ui/types/navigation.ts +2 -2
  357. package/src/ui/utils/avatarUtils.ts +39 -46
  358. package/src/ui/utils/storageHelpers.ts +0 -4
  359. package/src/utils/__tests__/validationUtils.test.ts +16 -1
  360. package/src/utils/errorUtils.ts +8 -1
  361. package/src/utils/validationUtils.ts +12 -0
  362. package/lib/commonjs/core/services/SessionService.js +0 -163
  363. package/lib/commonjs/core/services/SessionService.js.map +0 -1
  364. package/lib/commonjs/core/services/TokenService.js +0 -220
  365. package/lib/commonjs/core/services/TokenService.js.map +0 -1
  366. package/lib/commonjs/crypto/types.js +0 -2
  367. package/lib/commonjs/crypto/types.js.map +0 -1
  368. package/lib/commonjs/ui/context/OxyContextBase.js +0 -21
  369. package/lib/commonjs/ui/context/OxyContextBase.js.map +0 -1
  370. package/lib/commonjs/ui/context/hooks/useStorage.js +0 -79
  371. package/lib/commonjs/ui/context/hooks/useStorage.js.map +0 -1
  372. package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -56
  373. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
  374. package/lib/module/core/services/SessionService.js +0 -159
  375. package/lib/module/core/services/SessionService.js.map +0 -1
  376. package/lib/module/core/services/TokenService.js +0 -217
  377. package/lib/module/core/services/TokenService.js.map +0 -1
  378. package/lib/module/crypto/types.js +0 -2
  379. package/lib/module/crypto/types.js.map +0 -1
  380. package/lib/module/ui/context/OxyContextBase.js +0 -16
  381. package/lib/module/ui/context/OxyContextBase.js.map +0 -1
  382. package/lib/module/ui/context/hooks/useStorage.js +0 -74
  383. package/lib/module/ui/context/hooks/useStorage.js.map +0 -1
  384. package/lib/module/ui/hooks/useAvatarPicker.js +0 -50
  385. package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
  386. package/lib/typescript/core/services/SessionService.d.ts +0 -78
  387. package/lib/typescript/core/services/SessionService.d.ts.map +0 -1
  388. package/lib/typescript/core/services/TokenService.d.ts +0 -72
  389. package/lib/typescript/core/services/TokenService.d.ts.map +0 -1
  390. package/lib/typescript/crypto/types.d.ts +0 -22
  391. package/lib/typescript/crypto/types.d.ts.map +0 -1
  392. package/lib/typescript/ui/context/OxyContextBase.d.ts +0 -63
  393. package/lib/typescript/ui/context/OxyContextBase.d.ts.map +0 -1
  394. package/lib/typescript/ui/context/hooks/useStorage.d.ts +0 -22
  395. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +0 -1
  396. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -19
  397. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
  398. package/src/core/services/SessionService.ts +0 -173
  399. package/src/core/services/TokenService.ts +0 -237
  400. package/src/crypto/types.ts +0 -23
  401. package/src/ui/context/OxyContextBase.tsx +0 -78
  402. package/src/ui/context/hooks/useStorage.ts +0 -104
  403. package/src/ui/hooks/useAvatarPicker.ts +0 -61
@@ -1,20 +1,16 @@
1
1
  import { useMutation, useQueryClient } from '@tanstack/react-query';
2
2
  import type { User } from '../../../models/interfaces';
3
- import type { ClientSession } from '../../../models/session';
4
3
  import { queryKeys, invalidateAccountQueries, invalidateUserQueries } from '../queries/queryKeys';
5
4
  import { useOxy } from '../../context/OxyContext';
6
5
  import { toast } from '../../../lib/sonner';
7
- import { refreshAccountInStore } from '../../utils/avatarUtils';
8
- import { logger } from '../../../utils/loggerUtils';
9
-
10
- const getDeviceIdForSession = (sessions: ClientSession[] = [], sessionId: string | null) =>
11
- sessionId ? sessions.find((s) => s.sessionId === sessionId)?.deviceId : undefined;
6
+ import { refreshAvatarInStore } from '../../utils/avatarUtils';
7
+ import { useAuthStore } from '../../stores/authStore';
12
8
 
13
9
  /**
14
10
  * Update user profile with optimistic updates and offline queue support
15
11
  */
16
12
  export const useUpdateProfile = () => {
17
- const { oxyServices, activeSessionId, user, sessions } = useOxy();
13
+ const { oxyServices, activeSessionId, user } = useOxy();
18
14
  const queryClient = useQueryClient();
19
15
 
20
16
  return useMutation({
@@ -23,9 +19,16 @@ export const useUpdateProfile = () => {
23
19
  if (!oxyServices.hasValidToken() && activeSessionId) {
24
20
  try {
25
21
  // Try to get token for the session
26
- await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
22
+ await oxyServices.getTokenBySession(activeSessionId);
27
23
  } catch (tokenError) {
28
- throw tokenError;
24
+ // If getting token fails, might be an offline session - try syncing
25
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
26
+ if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
27
+ // Session sync should be handled by the app layer
28
+ throw new Error('Session needs to be synced. Please try again.');
29
+ } else {
30
+ throw tokenError;
31
+ }
29
32
  }
30
33
  }
31
34
 
@@ -37,7 +40,8 @@ export const useUpdateProfile = () => {
37
40
 
38
41
  // Handle authentication errors
39
42
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
40
- throw error;
43
+ // Session sync should be handled by the app layer
44
+ throw new Error('Authentication failed. Please sign in again.');
41
45
  }
42
46
 
43
47
  // TanStack Query will automatically retry on network errors
@@ -80,39 +84,25 @@ export const useUpdateProfile = () => {
80
84
  }
81
85
  toast.error(error instanceof Error ? error.message : 'Failed to update profile');
82
86
  },
83
- // On success, update cache and sync to store
84
- onSuccess: async (data, updates) => {
85
- logger.debug('Profile update successful', {
86
- component: 'useUpdateProfile',
87
- username: data.username,
88
- updatedFields: Object.keys(updates)
89
- });
90
-
87
+ // On success, invalidate and refetch
88
+ onSuccess: (data, updates) => {
91
89
  // Update cache with server response
92
90
  queryClient.setQueryData(queryKeys.accounts.current(), data);
93
91
  if (activeSessionId) {
94
92
  queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
95
93
  }
96
-
97
- // Refresh accountStore with all updated profile data (synchronizes immediately)
98
- if (activeSessionId && oxyServices) {
99
- refreshAccountInStore(activeSessionId, data, oxyServices);
94
+
95
+ // Update authStore so frontend components see the changes immediately
96
+ useAuthStore.getState().setUser(data);
97
+
98
+ // If avatar was updated, refresh accountStore with cache-busted URL
99
+ if (updates.avatar && activeSessionId && oxyServices) {
100
+ refreshAvatarInStore(activeSessionId, updates.avatar, oxyServices);
100
101
  }
101
-
102
- // Force refetch of all active queries to ensure UI updates immediately
103
- // Using refetchQueries instead of invalidateQueries to bypass staleTime
104
- await Promise.all([
105
- queryClient.refetchQueries({
106
- queryKey: queryKeys.accounts.all,
107
- type: 'active'
108
- }),
109
- queryClient.refetchQueries({
110
- queryKey: queryKeys.users.all,
111
- type: 'active'
112
- })
113
- ]);
114
-
115
- logger.debug('Profile update complete', { component: 'useUpdateProfile' });
102
+
103
+ // Invalidate all related queries to refresh everywhere
104
+ invalidateUserQueries(queryClient);
105
+ invalidateAccountQueries(queryClient);
116
106
  },
117
107
  });
118
108
  };
@@ -121,7 +111,7 @@ export const useUpdateProfile = () => {
121
111
  * Upload avatar with progress tracking and offline queue support
122
112
  */
123
113
  export const useUploadAvatar = () => {
124
- const { oxyServices, activeSessionId, sessions } = useOxy();
114
+ const { oxyServices, activeSessionId } = useOxy();
125
115
  const queryClient = useQueryClient();
126
116
 
127
117
  return useMutation({
@@ -129,9 +119,15 @@ export const useUploadAvatar = () => {
129
119
  // Ensure we have a valid token before making the request
130
120
  if (!oxyServices.hasValidToken() && activeSessionId) {
131
121
  try {
132
- await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
122
+ await oxyServices.getTokenBySession(activeSessionId);
133
123
  } catch (tokenError) {
134
- throw tokenError;
124
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
125
+ if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
126
+ // Session sync should be handled by the app layer
127
+ throw new Error('Session needs to be synced. Please try again.');
128
+ } else {
129
+ throw tokenError;
130
+ }
135
131
  }
136
132
  }
137
133
 
@@ -152,7 +148,8 @@ export const useUploadAvatar = () => {
152
148
 
153
149
  // Handle authentication errors
154
150
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
155
- throw error;
151
+ // Session sync should be handled by the app layer
152
+ throw new Error('Authentication failed. Please sign in again.');
156
153
  }
157
154
 
158
155
  // TanStack Query will automatically retry on network errors
@@ -186,35 +183,24 @@ export const useUploadAvatar = () => {
186
183
  }
187
184
  toast.error(error instanceof Error ? error.message : 'Failed to upload avatar');
188
185
  },
189
- onSuccess: async (data) => {
190
- logger.debug(
191
- 'Avatar upload successful',
192
- { component: 'useUploadAvatar', method: 'onSuccess', data }
193
- );
194
-
186
+ onSuccess: (data) => {
195
187
  queryClient.setQueryData(queryKeys.accounts.current(), data);
196
188
  if (activeSessionId) {
197
189
  queryClient.setQueryData(queryKeys.users.profile(activeSessionId), data);
198
190
  }
199
191
 
200
- // Refresh accountStore with all updated profile data (including avatar)
201
- if (activeSessionId && oxyServices) {
202
- refreshAccountInStore(activeSessionId, data, oxyServices);
192
+ // Update authStore so frontend components see the changes immediately
193
+ useAuthStore.getState().setUser(data);
194
+
195
+ // Refresh accountStore with cache-busted URL if avatar was updated
196
+ if (data?.avatar && activeSessionId && oxyServices) {
197
+ refreshAvatarInStore(activeSessionId, data.avatar, oxyServices);
203
198
  }
204
199
 
205
200
  // Invalidate all related queries to refresh everywhere
206
- await invalidateUserQueries(queryClient);
207
- await invalidateAccountQueries(queryClient);
208
-
209
- // Explicitly refetch to ensure UI updates
210
- await queryClient.refetchQueries({ queryKey: queryKeys.accounts.current() });
211
-
201
+ invalidateUserQueries(queryClient);
202
+ invalidateAccountQueries(queryClient);
212
203
  toast.success('Avatar updated successfully');
213
-
214
- logger.debug(
215
- 'Avatar update complete - cache invalidated and refetched',
216
- { component: 'useUploadAvatar', method: 'onSuccess' }
217
- );
218
204
  },
219
205
  });
220
206
  };
@@ -255,6 +241,9 @@ export const useUpdateAccountSettings = () => {
255
241
  onSuccess: (data) => {
256
242
  queryClient.setQueryData(queryKeys.accounts.current(), data);
257
243
 
244
+ // Update authStore so frontend components see the changes immediately
245
+ useAuthStore.getState().setUser(data);
246
+
258
247
  invalidateAccountQueries(queryClient);
259
248
  toast.success('Settings updated successfully');
260
249
  },
@@ -268,14 +257,12 @@ export const useUpdateAccountSettings = () => {
268
257
  * Update privacy settings with optimistic updates and authentication handling
269
258
  */
270
259
  export const useUpdatePrivacySettings = () => {
271
- const { oxyServices, activeSessionId, sessions } = useOxy();
260
+ const { oxyServices, activeSessionId, user } = useOxy();
272
261
  const queryClient = useQueryClient();
273
262
 
274
263
  return useMutation({
275
264
  mutationFn: async ({ settings, userId }: { settings: Record<string, any>; userId?: string }) => {
276
- // Use getCurrentUserId() which returns MongoDB ObjectId from JWT token
277
- // Never use user?.id as it may be set to publicKey
278
- const targetUserId = userId || oxyServices.getCurrentUserId();
265
+ const targetUserId = userId || user?.id;
279
266
  if (!targetUserId) {
280
267
  throw new Error('User ID is required');
281
268
  }
@@ -284,9 +271,16 @@ export const useUpdatePrivacySettings = () => {
284
271
  if (!oxyServices.hasValidToken() && activeSessionId) {
285
272
  try {
286
273
  // Try to get token for the session
287
- await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
274
+ await oxyServices.getTokenBySession(activeSessionId);
288
275
  } catch (tokenError) {
289
- throw tokenError;
276
+ // If getting token fails, might be an offline session - try syncing
277
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
278
+ if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
279
+ // Session sync should be handled by the app layer
280
+ throw new Error('Session needs to be synced. Please try again.');
281
+ } else {
282
+ throw tokenError;
283
+ }
290
284
  }
291
285
  }
292
286
 
@@ -298,7 +292,8 @@ export const useUpdatePrivacySettings = () => {
298
292
 
299
293
  // Handle authentication errors
300
294
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
301
- throw error;
295
+ // Session sync should be handled by the app layer
296
+ throw new Error('Authentication failed. Please sign in again.');
302
297
  }
303
298
 
304
299
  // TanStack Query will automatically retry on network errors
@@ -307,7 +302,7 @@ export const useUpdatePrivacySettings = () => {
307
302
  },
308
303
  // Optimistic update
309
304
  onMutate: async ({ settings, userId }) => {
310
- const targetUserId = userId || oxyServices.getCurrentUserId();
305
+ const targetUserId = userId || user?.id;
311
306
  if (!targetUserId) return;
312
307
 
313
308
  // Cancel outgoing refetches
@@ -341,7 +336,7 @@ export const useUpdatePrivacySettings = () => {
341
336
  },
342
337
  // On error, rollback
343
338
  onError: (error, { userId }, context) => {
344
- const targetUserId = userId || oxyServices.getCurrentUserId();
339
+ const targetUserId = userId || user?.id;
345
340
  if (context?.previousPrivacySettings && targetUserId) {
346
341
  queryClient.setQueryData(queryKeys.privacy.settings(targetUserId), context.previousPrivacySettings);
347
342
  }
@@ -352,7 +347,7 @@ export const useUpdatePrivacySettings = () => {
352
347
  },
353
348
  // On success, invalidate and refetch
354
349
  onSuccess: (data, { userId }) => {
355
- const targetUserId = userId || oxyServices.getCurrentUserId();
350
+ const targetUserId = userId || user?.id;
356
351
  if (targetUserId) {
357
352
  queryClient.setQueryData(queryKeys.privacy.settings(targetUserId), data);
358
353
  }
@@ -364,12 +359,15 @@ export const useUpdatePrivacySettings = () => {
364
359
  privacySettings: data,
365
360
  };
366
361
  queryClient.setQueryData<User>(queryKeys.accounts.current(), updatedUser);
362
+
363
+ // Update authStore so frontend components see the changes immediately
364
+ useAuthStore.getState().setUser(updatedUser);
367
365
  }
368
366
  invalidateAccountQueries(queryClient);
369
367
  },
370
368
  // Always refetch after error or success
371
369
  onSettled: (data, error, { userId }) => {
372
- const targetUserId = userId || oxyServices.getCurrentUserId();
370
+ const targetUserId = userId || user?.id;
373
371
  if (targetUserId) {
374
372
  queryClient.invalidateQueries({ queryKey: queryKeys.privacy.settings(targetUserId) });
375
373
  }
@@ -382,7 +380,7 @@ export const useUpdatePrivacySettings = () => {
382
380
  * Upload file with authentication handling and progress tracking
383
381
  */
384
382
  export const useUploadFile = () => {
385
- const { oxyServices, activeSessionId, sessions } = useOxy();
383
+ const { oxyServices, activeSessionId } = useOxy();
386
384
 
387
385
  return useMutation({
388
386
  mutationFn: async ({
@@ -400,9 +398,16 @@ export const useUploadFile = () => {
400
398
  if (!oxyServices.hasValidToken() && activeSessionId) {
401
399
  try {
402
400
  // Try to get token for the session
403
- await oxyServices.getTokenBySession(activeSessionId, getDeviceIdForSession(sessions, activeSessionId));
401
+ await oxyServices.getTokenBySession(activeSessionId);
404
402
  } catch (tokenError) {
405
- throw tokenError;
403
+ // If getting token fails, might be an offline session - try syncing
404
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
405
+ if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
406
+ // Session sync should be handled by the app layer
407
+ throw new Error('Session needs to be synced. Please try again.');
408
+ } else {
409
+ throw tokenError;
410
+ }
406
411
  }
407
412
  }
408
413
 
@@ -414,7 +419,8 @@ export const useUploadFile = () => {
414
419
 
415
420
  // Handle authentication errors
416
421
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
417
- throw error;
422
+ // Session sync should be handled by the app layer
423
+ throw new Error('Authentication failed. Please sign in again.');
418
424
  }
419
425
 
420
426
  // TanStack Query will automatically retry on network errors
@@ -423,3 +429,4 @@ export const useUploadFile = () => {
423
429
  },
424
430
  });
425
431
  };
432
+
@@ -2,8 +2,7 @@ import { useQuery, useQueries } from '@tanstack/react-query';
2
2
  import type { User } from '../../../models/interfaces';
3
3
  import type { OxyServices } from '../../../core';
4
4
  import { queryKeys } from './queryKeys';
5
- import { useOxy } from '../../context/OxyContextBase';
6
- import { logger } from '../../../utils/loggerUtils';
5
+ import { useOxy } from '../../context/OxyContext';
7
6
 
8
7
  /**
9
8
  * Get user profile by session ID
@@ -20,8 +19,8 @@ export const useUserProfile = (sessionId: string | null, options?: { enabled?: b
20
19
  return await oxyServices.getUserBySession(sessionId);
21
20
  },
22
21
  enabled: (options?.enabled !== false) && !!sessionId,
23
- staleTime: 30000, // 30 seconds - reasonable freshness without constant refetching
24
- gcTime: 5 * 60 * 1000, // 5 minutes - keep in cache for quick access
22
+ staleTime: 5 * 60 * 1000, // 5 minutes
23
+ gcTime: 30 * 60 * 1000, // 30 minutes
25
24
  });
26
25
  };
27
26
 
@@ -39,8 +38,8 @@ export const useUserProfiles = (sessionIds: string[], options?: { enabled?: bool
39
38
  return results[0]?.user || null;
40
39
  },
41
40
  enabled: (options?.enabled !== false) && !!sessionId,
42
- staleTime: 30000, // 30 seconds
43
- gcTime: 5 * 60 * 1000, // 5 minutes
41
+ staleTime: 5 * 60 * 1000,
42
+ gcTime: 30 * 60 * 1000,
44
43
  })),
45
44
  });
46
45
  };
@@ -54,25 +53,14 @@ export const useCurrentUser = (options?: { enabled?: boolean }) => {
54
53
  return useQuery({
55
54
  queryKey: queryKeys.accounts.current(),
56
55
  queryFn: async () => {
57
- logger.debug('Fetching current user', {
58
- component: 'useCurrentUser',
59
- sessionId: activeSessionId ?? undefined
60
- });
61
56
  if (!activeSessionId) {
62
57
  throw new Error('No active session');
63
58
  }
64
- const userData = await oxyServices.getUserBySession(activeSessionId);
65
- logger.debug('Current user fetched', {
66
- component: 'useCurrentUser',
67
- username: userData.username
68
- });
69
- return userData;
59
+ return await oxyServices.getUserBySession(activeSessionId);
70
60
  },
71
61
  enabled: (options?.enabled !== false) && isAuthenticated && !!activeSessionId,
72
- staleTime: 30000, // 30 seconds - balances freshness with performance
73
- gcTime: 5 * 60 * 1000, // 5 minutes
74
- refetchOnMount: 'always', // Always refetch on mount
75
- refetchOnWindowFocus: false,
62
+ staleTime: 1 * 60 * 1000, // 1 minute for current user
63
+ gcTime: 30 * 60 * 1000,
76
64
  });
77
65
  };
78
66
 
@@ -91,8 +79,8 @@ export const useUserById = (userId: string | null, options?: { enabled?: boolean
91
79
  return await oxyServices.getUserById(userId);
92
80
  },
93
81
  enabled: (options?.enabled !== false) && !!userId,
94
- staleTime: 60000, // 1 minute - other users' profiles change less frequently
95
- gcTime: 10 * 60 * 1000, // 10 minutes
82
+ staleTime: 5 * 60 * 1000,
83
+ gcTime: 30 * 60 * 1000,
96
84
  });
97
85
  };
98
86
 
@@ -111,8 +99,8 @@ export const useUserByUsername = (username: string | null, options?: { enabled?:
111
99
  return await oxyServices.getProfileByUsername(username);
112
100
  },
113
101
  enabled: (options?.enabled !== false) && !!username,
114
- staleTime: 60000, // 1 minute
115
- gcTime: 10 * 60 * 1000, // 10 minutes
102
+ staleTime: 5 * 60 * 1000,
103
+ gcTime: 30 * 60 * 1000,
116
104
  });
117
105
  };
118
106
 
@@ -131,8 +119,8 @@ export const useUsersBySessions = (sessionIds: string[], options?: { enabled?: b
131
119
  return await oxyServices.getUsersBySessions(sessionIds);
132
120
  },
133
121
  enabled: (options?.enabled !== false) && sessionIds.length > 0,
134
- staleTime: 30000, // 30 seconds
135
- gcTime: 5 * 60 * 1000, // 5 minutes
122
+ staleTime: 5 * 60 * 1000,
123
+ gcTime: 30 * 60 * 1000,
136
124
  });
137
125
  };
138
126
 
@@ -140,11 +128,8 @@ export const useUsersBySessions = (sessionIds: string[], options?: { enabled?: b
140
128
  * Get privacy settings for a user
141
129
  */
142
130
  export const usePrivacySettings = (userId?: string, options?: { enabled?: boolean }) => {
143
- const { oxyServices, activeSessionId, sessions } = useOxy();
144
- // Use getCurrentUserId() which returns MongoDB ObjectId from JWT token
145
- // Never use user?.id as it may be set to publicKey
146
- const targetUserId = userId || oxyServices.getCurrentUserId() || undefined;
147
- const deviceId = activeSessionId ? sessions.find((s) => s.sessionId === activeSessionId)?.deviceId : undefined;
131
+ const { oxyServices, activeSessionId, user } = useOxy();
132
+ const targetUserId = userId || user?.id;
148
133
 
149
134
  return useQuery({
150
135
  queryKey: queryKeys.privacy.settings(targetUserId),
@@ -157,9 +142,16 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
157
142
  if (!oxyServices.hasValidToken() && activeSessionId) {
158
143
  try {
159
144
  // Try to get token for the session
160
- await oxyServices.getTokenBySession(activeSessionId, deviceId);
145
+ await oxyServices.getTokenBySession(activeSessionId);
161
146
  } catch (tokenError) {
162
- throw tokenError;
147
+ // If getting token fails, might be an offline session - try syncing
148
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
149
+ if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
150
+ // Session sync should be handled by the app layer (e.g., accounts app's useIdentity hook)
151
+ throw new Error('Session needs to be synced. Please try again.');
152
+ } else {
153
+ throw tokenError;
154
+ }
163
155
  }
164
156
  }
165
157
 
@@ -171,7 +163,8 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
171
163
 
172
164
  // Handle authentication errors
173
165
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
174
- throw error;
166
+ // Session sync should be handled by the app layer
167
+ throw new Error('Authentication failed. Please sign in again.');
175
168
  }
176
169
 
177
170
  // TanStack Query will automatically retry on network errors
@@ -179,7 +172,8 @@ export const usePrivacySettings = (userId?: string, options?: { enabled?: boolea
179
172
  }
180
173
  },
181
174
  enabled: (options?.enabled !== false) && !!targetUserId,
182
- staleTime: 60000, // 1 minute - privacy settings don't change frequently
175
+ staleTime: 2 * 60 * 1000, // 2 minutes
183
176
  gcTime: 10 * 60 * 1000, // 10 minutes
184
177
  });
185
178
  };
179
+
@@ -1,6 +1,6 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import { queryKeys } from './queryKeys';
3
- import { useOxy } from '../../context/OxyContextBase';
3
+ import { useOxy } from '../../context/OxyContext';
4
4
  import type { SecurityActivity, SecurityEventType } from '../../../models/interfaces';
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import type { ClientSession } from '../../../models/session';
3
3
  import { queryKeys } from './queryKeys';
4
- import { useOxy } from '../../context/OxyContextBase';
4
+ import { useOxy } from '../../context/OxyContext';
5
5
  import { fetchSessionsWithFallback, mapSessionsToClient } from '../../utils/sessionHelpers';
6
6
 
7
7
  /**
@@ -89,8 +89,7 @@ export const useDeviceSessions = (options?: { enabled?: boolean }) => {
89
89
  * Get user devices
90
90
  */
91
91
  export const useUserDevices = (options?: { enabled?: boolean }) => {
92
- const { oxyServices, isAuthenticated, activeSessionId, sessions } = useOxy();
93
- const deviceId = activeSessionId ? sessions.find((s) => s.sessionId === activeSessionId)?.deviceId : undefined;
92
+ const { oxyServices, isAuthenticated, activeSessionId } = useOxy();
94
93
 
95
94
  return useQuery({
96
95
  queryKey: queryKeys.devices.list(),
@@ -99,9 +98,16 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
99
98
  if (!oxyServices.hasValidToken() && activeSessionId) {
100
99
  try {
101
100
  // Try to get token for the session
102
- await oxyServices.getTokenBySession(activeSessionId, deviceId);
101
+ await oxyServices.getTokenBySession(activeSessionId);
103
102
  } catch (tokenError) {
104
- throw tokenError;
103
+ // If getting token fails, might be an offline session - try syncing
104
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
105
+ if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
106
+ // Session sync should be handled by the app layer
107
+ throw new Error('Session needs to be synced. Please try again.');
108
+ } else {
109
+ throw tokenError;
110
+ }
105
111
  }
106
112
  }
107
113
 
@@ -113,7 +119,8 @@ export const useUserDevices = (options?: { enabled?: boolean }) => {
113
119
 
114
120
  // Handle authentication errors
115
121
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
116
- throw error;
122
+ // Session sync should be handled by the app layer
123
+ throw new Error('Authentication failed. Please sign in again.');
117
124
  }
118
125
 
119
126
  // TanStack Query will automatically retry on network errors
@@ -142,3 +149,4 @@ export const useSecurityInfo = (options?: { enabled?: boolean }) => {
142
149
  gcTime: 30 * 60 * 1000,
143
150
  });
144
151
  };
152
+
@@ -1,7 +1,7 @@
1
1
  import { useCallback } from 'react';
2
2
  import { useI18n } from './useI18n';
3
3
  import { useUpdateProfile } from './mutations/useAccountMutations';
4
- import { useCurrentUser } from './queries/useAccountQueries';
4
+ import { useAuthStore } from '../stores/authStore';
5
5
 
6
6
  export interface ProfileUpdateData {
7
7
  displayName?: string;
@@ -34,7 +34,6 @@ export interface ProfileUpdateData {
34
34
  export const useProfileEditing = () => {
35
35
  const { t } = useI18n();
36
36
  const updateProfileMutation = useUpdateProfile();
37
- const { data: currentUser } = useCurrentUser();
38
37
 
39
38
  /**
40
39
  * Save profile updates to the server using TanStack Query
@@ -72,6 +71,7 @@ export const useProfileEditing = () => {
72
71
 
73
72
  // Handle name field
74
73
  if (updates.displayName !== undefined || updates.lastName !== undefined) {
74
+ const currentUser = useAuthStore.getState().user;
75
75
  const currentName = currentUser?.name;
76
76
  updateData.name = {
77
77
  first: updates.displayName ?? (typeof currentName === 'object' ? currentName?.first : '') ?? '',
@@ -86,7 +86,7 @@ export const useProfileEditing = () => {
86
86
  // Error toast is handled by the mutation
87
87
  return false;
88
88
  }
89
- }, [updateProfileMutation, t, currentUser]);
89
+ }, [updateProfileMutation, t]);
90
90
 
91
91
  /**
92
92
  * Update a single profile field
@@ -9,9 +9,6 @@ import type { OxyServices } from '../../core';
9
9
  import type { QueryClient } from '@tanstack/react-query';
10
10
  import { clearQueryCache } from './queryClient';
11
11
 
12
- const getDeviceIdForSession = (sessions: ClientSession[] = [], sessionId: string | null) =>
13
- sessionId ? sessions.find((s) => s.sessionId === sessionId)?.deviceId : undefined;
14
-
15
12
  export interface UseSessionManagementOptions {
16
13
  oxyServices: OxyServices;
17
14
  storage: StorageInterface | null;
@@ -147,8 +144,7 @@ export const useSessionManagement = ({
147
144
  try {
148
145
  await storage.removeItem(storageKeys.activeSessionId);
149
146
  await storage.removeItem(storageKeys.sessionIds);
150
- // Clear identity sync state
151
- await storage.removeItem('oxy_identity_synced').catch(() => {});
147
+ // Note: Identity sync state ('oxy_identity_synced') is managed by accounts app
152
148
  } catch (error) {
153
149
  handleAuthError(error, {
154
150
  defaultMessage: CLEAR_STORAGE_ERROR,
@@ -164,7 +160,6 @@ export const useSessionManagement = ({
164
160
  setSessions([]);
165
161
  setActiveSessionId(null);
166
162
  logoutStore();
167
- oxyServices.clearTokens();
168
163
 
169
164
  // Clear TanStack Query cache (in-memory)
170
165
  if (queryClient) {
@@ -184,12 +179,11 @@ export const useSessionManagement = ({
184
179
 
185
180
  await clearSessionStorage();
186
181
  onAuthStateChange?.(null);
187
- }, [clearSessionStorage, logoutStore, onAuthStateChange, queryClient, storage, logger, oxyServices]);
182
+ }, [clearSessionStorage, logoutStore, onAuthStateChange, queryClient, storage, logger]);
188
183
 
189
184
  const activateSession = useCallback(
190
185
  async (sessionId: string, user: User): Promise<void> => {
191
- const deviceId = getDeviceIdForSession(sessions, sessionId);
192
- await oxyServices.getTokenBySession(sessionId, deviceId);
186
+ await oxyServices.getTokenBySession(sessionId);
193
187
  setTokenReady?.(true);
194
188
  setActiveSessionId(sessionId);
195
189
  loginSuccess(user);
@@ -199,7 +193,6 @@ export const useSessionManagement = ({
199
193
  },
200
194
  [
201
195
  applyLanguagePreference,
202
- sessions,
203
196
  loginSuccess,
204
197
  onAuthStateChange,
205
198
  oxyServices,
@@ -403,3 +396,5 @@ export const useSessionManagement = ({
403
396
  isRefreshInFlight,
404
397
  };
405
398
  };
399
+
400
+