@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,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  import { useCallback } from 'react';
4
+ import { DeviceManager } from '../../../utils/deviceManager';
4
5
  import { fetchSessionsWithFallback } from '../../utils/sessionHelpers';
5
6
  import { handleAuthError, isInvalidSessionError } from '../../utils/errorHandlers';
7
+ import { SignatureService } from '../../../crypto';
8
+ const LOGIN_ERROR_CODE = 'LOGIN_ERROR';
6
9
  const LOGOUT_ERROR_CODE = 'LOGOUT_ERROR';
7
10
  const LOGOUT_ALL_ERROR_CODE = 'LOGOUT_ALL_ERROR';
11
+
12
+ /**
13
+ * Authentication operations using public key cryptography.
14
+ * Accepts public key as parameter - identity management is handled by the app layer.
15
+ */
8
16
  export const useAuthOperations = ({
9
17
  oxyServices,
10
18
  storage,
@@ -24,15 +32,121 @@ export const useAuthOperations = ({
24
32
  setAuthState,
25
33
  logger
26
34
  }) => {
27
- const completeSignIn = useCallback(async sessionResponse => {
28
- if (!storage) throw new Error('Storage not initialized');
29
- setAuthState({
30
- isLoading: true,
31
- error: null
32
- });
35
+ /**
36
+ * Internal function to perform challenge-response sign in (works offline)
37
+ */
38
+ const performSignIn = useCallback(async publicKey => {
39
+ const deviceFingerprintObj = DeviceManager.getDeviceFingerprint();
40
+ const deviceFingerprint = JSON.stringify(deviceFingerprintObj);
41
+ const deviceInfo = await DeviceManager.getDeviceInfo();
42
+ const deviceName = deviceInfo.deviceName || DeviceManager.getDefaultDeviceName();
43
+ let challenge;
44
+ let isOffline = false;
45
+
46
+ // Try to request challenge from server (online)
33
47
  try {
34
- oxyServices.setTokens(sessionResponse.accessToken, sessionResponse.refreshToken);
35
- const fullUser = await oxyServices.getUserBySession(sessionResponse.sessionId);
48
+ const challengeResponse = await oxyServices.requestChallenge(publicKey);
49
+ challenge = challengeResponse.challenge;
50
+ } catch (error) {
51
+ // Network error - generate challenge locally for offline sign-in
52
+ const errorMessage = error instanceof Error ? error.message : String(error);
53
+ const isNetworkError = errorMessage.includes('Network') || errorMessage.includes('network') || errorMessage.includes('Failed to fetch') || errorMessage.includes('fetch failed') || error?.code === 'NETWORK_ERROR' || error?.status === 0;
54
+ if (isNetworkError) {
55
+ if (__DEV__ && logger) {
56
+ logger('Network unavailable, performing offline sign-in');
57
+ }
58
+ // Generate challenge locally
59
+ challenge = await SignatureService.generateChallenge();
60
+ isOffline = true;
61
+ } else {
62
+ // Re-throw non-network errors
63
+ throw error;
64
+ }
65
+ }
66
+
67
+ // Note: Biometric authentication check should be handled by the app layer
68
+ // (e.g., accounts app) before calling signIn. The biometric preference is stored
69
+ // in local storage as 'oxy_biometric_enabled' and can be checked there.
70
+
71
+ // Sign the challenge
72
+ const {
73
+ challenge: signature,
74
+ timestamp
75
+ } = await SignatureService.signChallenge(challenge);
76
+ let fullUser;
77
+ let sessionResponse;
78
+ if (isOffline) {
79
+ // Offline sign-in: create local session and minimal user object
80
+ if (__DEV__ && logger) {
81
+ logger('Creating offline session');
82
+ }
83
+
84
+ // Generate a local session ID
85
+ const localSessionId = `offline_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
86
+ const localDeviceId = `device_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
87
+ const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(); // 7 days
88
+
89
+ // Create minimal user object with publicKey as id
90
+ fullUser = {
91
+ id: publicKey,
92
+ // Use publicKey as id (per migration document)
93
+ publicKey,
94
+ username: '',
95
+ privacySettings: {}
96
+ };
97
+ sessionResponse = {
98
+ sessionId: localSessionId,
99
+ deviceId: localDeviceId,
100
+ expiresAt,
101
+ user: {
102
+ id: publicKey,
103
+ username: ''
104
+ }
105
+ };
106
+
107
+ // Store offline session locally
108
+ const offlineSession = {
109
+ sessionId: localSessionId,
110
+ deviceId: localDeviceId,
111
+ expiresAt,
112
+ lastActive: new Date().toISOString(),
113
+ userId: publicKey,
114
+ isCurrent: true
115
+ };
116
+ setActiveSessionId(localSessionId);
117
+ await saveActiveSessionId(localSessionId);
118
+ updateSessions([offlineSession], {
119
+ merge: true
120
+ });
121
+
122
+ // Mark session as offline for later sync
123
+ if (storage) {
124
+ await storage.setItem(`oxy_session_${localSessionId}_offline`, 'true');
125
+ }
126
+ if (__DEV__ && logger) {
127
+ logger('Offline sign-in successful');
128
+ }
129
+ } else {
130
+ // Online sign-in: use normal flow
131
+ // Verify and create session
132
+ sessionResponse = await oxyServices.verifyChallenge(publicKey, challenge, signature, timestamp, deviceName, deviceFingerprint);
133
+
134
+ // Get token for the session
135
+ try {
136
+ await oxyServices.getTokenBySession(sessionResponse.sessionId);
137
+ } catch (tokenError) {
138
+ const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
139
+ const status = tokenError?.status;
140
+ if (status === 404 || errorMessage.includes('404')) {
141
+ throw new Error(`Session was created but token could not be retrieved. Session ID: ${sessionResponse.sessionId.substring(0, 8)}...`);
142
+ }
143
+ throw tokenError;
144
+ }
145
+
146
+ // Get full user data
147
+ fullUser = await oxyServices.getUserBySession(sessionResponse.sessionId);
148
+
149
+ // Fetch device sessions
36
150
  let allDeviceSessions = [];
37
151
  try {
38
152
  allDeviceSessions = await fetchSessionsWithFallback(oxyServices, sessionResponse.sessionId, {
@@ -41,17 +155,21 @@ export const useAuthOperations = ({
41
155
  logger
42
156
  });
43
157
  } catch (error) {
44
- if (__DEV__) {
45
- console.warn('Failed to fetch device sessions after login:', error);
158
+ if (__DEV__ && logger) {
159
+ logger('Failed to fetch device sessions after login', error);
46
160
  }
47
161
  }
162
+
163
+ // Check for existing session for same user and switch to it to avoid duplicates
48
164
  const existingSession = allDeviceSessions.find(session => session.userId?.toString() === fullUser.id?.toString() && session.sessionId !== sessionResponse.sessionId);
49
165
  if (existingSession) {
166
+ // Switch to existing session instead of creating duplicate
50
167
  try {
51
168
  await oxyServices.logoutSession(sessionResponse.sessionId, sessionResponse.sessionId);
52
169
  } catch (logoutError) {
53
- if (__DEV__) {
54
- console.warn('Failed to logout duplicate session:', logoutError);
170
+ // Non-critical - continue to switch session even if logout fails
171
+ if (__DEV__ && logger) {
172
+ logger('Failed to logout duplicate session, continuing with switch', logoutError);
55
173
  }
56
174
  }
57
175
  await switchSession(existingSession.sessionId);
@@ -66,14 +184,27 @@ export const useAuthOperations = ({
66
184
  updateSessions(allDeviceSessions, {
67
185
  merge: true
68
186
  });
69
- await applyLanguagePreference(fullUser);
70
- loginSuccess();
71
- onAuthStateChange?.(fullUser);
72
- return fullUser;
187
+ }
188
+ await applyLanguagePreference(fullUser);
189
+ loginSuccess(fullUser);
190
+ onAuthStateChange?.(fullUser);
191
+ return fullUser;
192
+ }, [applyLanguagePreference, logger, loginSuccess, onAuthStateChange, oxyServices, saveActiveSessionId, setActiveSessionId, switchSession, updateSessions, storage]);
193
+
194
+ /**
195
+ * Sign in with existing public key
196
+ */
197
+ const signIn = useCallback(async (publicKey, deviceName) => {
198
+ setAuthState({
199
+ isLoading: true,
200
+ error: null
201
+ });
202
+ try {
203
+ return await performSignIn(publicKey);
73
204
  } catch (error) {
74
205
  const message = handleAuthError(error, {
75
206
  defaultMessage: 'Sign in failed',
76
- code: 'COMPLETE_SIGNIN_ERROR',
207
+ code: LOGIN_ERROR_CODE,
77
208
  onError,
78
209
  setAuthError: msg => setAuthState({
79
210
  error: msg
@@ -87,7 +218,7 @@ export const useAuthOperations = ({
87
218
  isLoading: false
88
219
  });
89
220
  }
90
- }, [storage, setAuthState, oxyServices, logger, saveActiveSessionId, setActiveSessionId, switchSession, updateSessions, applyLanguagePreference, loginSuccess, onAuthStateChange, onError, loginFailure]);
221
+ }, [setAuthState, performSignIn, loginFailure, onError, logger]);
91
222
 
92
223
  /**
93
224
  * Logout from session
@@ -161,7 +292,7 @@ export const useAuthOperations = ({
161
292
  }
162
293
  }, [activeSessionId, clearSessionState, logger, onError, oxyServices, setAuthState]);
163
294
  return {
164
- completeSignIn,
295
+ signIn,
165
296
  logout,
166
297
  logoutAll
167
298
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","fetchSessionsWithFallback","handleAuthError","isInvalidSessionError","LOGOUT_ERROR_CODE","LOGOUT_ALL_ERROR_CODE","useAuthOperations","oxyServices","storage","sessions","activeSessionId","setActiveSessionId","updateSessions","saveActiveSessionId","clearSessionState","switchSession","applyLanguagePreference","onAuthStateChange","onError","loginSuccess","loginFailure","logoutStore","setAuthState","logger","completeSignIn","sessionResponse","Error","isLoading","error","setTokens","accessToken","refreshToken","fullUser","getUserBySession","sessionId","allDeviceSessions","fallbackDeviceId","deviceId","fallbackUserId","id","__DEV__","console","warn","existingSession","find","session","userId","toString","logoutSession","logoutError","filter","merge","message","defaultMessage","code","setAuthError","msg","logout","targetSessionId","sessionToLogout","filteredSessions","length","isInvalid","status","undefined","logoutAll","logoutAllSessions"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useAuthOperations.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AAInC,SAASC,yBAAyB,QAAQ,4BAA4B;AACtE,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,2BAA2B;AA8BlF,MAAMC,iBAAiB,GAAG,cAAc;AACxC,MAAMC,qBAAqB,GAAG,kBAAkB;AAGhD,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;EACXC,YAAY;EACZC;AACwB,CAAC,KAA8B;EAEvD,MAAMC,cAAc,GAAGxB,WAAW,CAChC,MAAOyB,eAAqC,IAAoB;IAC9D,IAAI,CAACjB,OAAO,EAAE,MAAM,IAAIkB,KAAK,CAAC,yBAAyB,CAAC;IAExDJ,YAAY,CAAC;MAAEK,SAAS,EAAE,IAAI;MAAEC,KAAK,EAAE;IAAK,CAAC,CAAC;IAE9C,IAAI;MACFrB,WAAW,CAACsB,SAAS,CAACJ,eAAe,CAACK,WAAW,EAAEL,eAAe,CAACM,YAAY,CAAC;MAEhF,MAAMC,QAAQ,GAAG,MAAMzB,WAAW,CAAC0B,gBAAgB,CAACR,eAAe,CAACS,SAAS,CAAC;MAE9E,IAAIC,iBAAkC,GAAG,EAAE;MAC3C,IAAI;QACFA,iBAAiB,GAAG,MAAMlC,yBAAyB,CAACM,WAAW,EAAEkB,eAAe,CAACS,SAAS,EAAE;UAC1FE,gBAAgB,EAAEX,eAAe,CAACY,QAAQ;UAC1CC,cAAc,EAAEN,QAAQ,CAACO,EAAE;UAC3BhB;QACF,CAAC,CAAC;MACJ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Y,EAAGC,GAAW,IAAKlC,YAAY,CAAC;UAAEM,KAAK,EAAE4B;QAAI,CAAC,CAAC;QAC3DjC;MACF,CAAC,CAAC;MACF,MAAMK,KAAK,YAAYF,KAAK,GAAGE,KAAK,GAAG,IAAIF,KAAK,CAAC,mBAAmB,CAAC;IACvE;EACF,CAAC,EAAE,CAAChB,eAAe,EAAEI,iBAAiB,EAAES,MAAM,EAAEL,OAAO,EAAEX,WAAW,EAAEe,YAAY,CAAC,CAAC;EAEpF,OAAO;IACLE,cAAc;IACdiC,MAAM;IACNQ;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","DeviceManager","fetchSessionsWithFallback","handleAuthError","isInvalidSessionError","SignatureService","LOGIN_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","logger","performSignIn","publicKey","deviceFingerprintObj","getDeviceFingerprint","deviceFingerprint","JSON","stringify","deviceInfo","getDeviceInfo","deviceName","getDefaultDeviceName","challenge","isOffline","challengeResponse","requestChallenge","error","errorMessage","Error","message","String","isNetworkError","includes","code","status","__DEV__","generateChallenge","signature","timestamp","signChallenge","fullUser","sessionResponse","localSessionId","Date","now","Math","random","toString","substr","localDeviceId","expiresAt","toISOString","id","username","privacySettings","sessionId","deviceId","user","offlineSession","lastActive","userId","isCurrent","merge","setItem","verifyChallenge","getTokenBySession","tokenError","substring","getUserBySession","allDeviceSessions","fallbackDeviceId","fallbackUserId","existingSession","find","session","logoutSession","logoutError","filter","signIn","isLoading","defaultMessage","setAuthError","msg","logout","targetSessionId","sessionToLogout","filteredSessions","length","isInvalid","undefined","logoutAll","logoutAllSessions"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useAuthOperations.ts"],"mappings":";;AAAA,SAASA,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AY,CAAC;UAAEiB,KAAK,EAAEwD;QAAI,CAAC,CAAC;QAC3DxE;MACF,CAAC,CAAC;MACF,MAAMgB,KAAK,YAAYE,KAAK,GAAGF,KAAK,GAAG,IAAIE,KAAK,CAAC,mBAAmB,CAAC;IACvE;EACF,CAAC,EAAE,CAAC/B,eAAe,EAAEI,iBAAiB,EAAES,MAAM,EAAEL,OAAO,EAAEX,WAAW,EAAEe,YAAY,CAAC,CAAC;EAEpF,OAAO;IACLqE,MAAM;IACNK,MAAM;IACNO;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useMemo, useRef, useState } from 'react';
4
+ import { mergeSessions, normalizeAndSortSessions, sessionsArraysEqual } from '../../../utils/sessionUtils';
5
+ import { fetchSessionsWithFallback, validateSessionBatch } from '../../utils/sessionHelpers';
6
+ import { getStorageKeys } from '../../utils/storageHelpers';
7
+ import { handleAuthError, isInvalidSessionError } from '../../utils/errorHandlers';
8
+ import { clearQueryCache } from '../../hooks/queryClient';
9
+ const DEFAULT_SAVE_ERROR_MESSAGE = 'Failed to save session data';
10
+ const CLEAR_STORAGE_ERROR = 'Failed to clear storage';
11
+
12
+ /**
13
+ * Manage session state, persistence, and high-level multi-session operations.
14
+ *
15
+ * @param options - Session management configuration
16
+ */
17
+ export const useSessionManagement = ({
18
+ oxyServices,
19
+ storage,
20
+ storageKeyPrefix,
21
+ loginSuccess,
22
+ logoutStore,
23
+ applyLanguagePreference,
24
+ onAuthStateChange,
25
+ onError,
26
+ setAuthError,
27
+ logger,
28
+ setTokenReady,
29
+ queryClient
30
+ }) => {
31
+ const [sessions, setSessions] = useState([]);
32
+ const [activeSessionId, setActiveSessionId] = useState(null);
33
+ const refreshInFlightRef = useRef(null);
34
+ const removedSessionsRef = useRef(new Set());
35
+ const lastRefreshRef = useRef(0);
36
+ const storageKeys = useMemo(() => getStorageKeys(storageKeyPrefix), [storageKeyPrefix]);
37
+ const saveSessionIds = useCallback(async sessionIds => {
38
+ if (!storage) return;
39
+ try {
40
+ const uniqueIds = Array.from(new Set(sessionIds));
41
+ await storage.setItem(storageKeys.sessionIds, JSON.stringify(uniqueIds));
42
+ } catch (error) {
43
+ if (logger) {
44
+ logger(DEFAULT_SAVE_ERROR_MESSAGE, error);
45
+ } else if (__DEV__) {
46
+ console.warn('Failed to save session IDs:', error);
47
+ }
48
+ }
49
+ }, [logger, storage, storageKeys.sessionIds]);
50
+ const updateSessions = useCallback((incoming, options = {}) => {
51
+ setSessions(prevSessions => {
52
+ const processed = options.merge ? mergeSessions(prevSessions, incoming, activeSessionId, false) : normalizeAndSortSessions(incoming, activeSessionId, false);
53
+ if (storage) {
54
+ void saveSessionIds(processed.map(session => session.sessionId));
55
+ }
56
+ if (sessionsArraysEqual(prevSessions, processed)) {
57
+ return prevSessions;
58
+ }
59
+ return processed;
60
+ });
61
+ }, [activeSessionId, saveSessionIds, storage]);
62
+ const saveActiveSessionId = useCallback(async sessionId => {
63
+ if (!storage) return;
64
+ try {
65
+ await storage.setItem(storageKeys.activeSessionId, sessionId);
66
+ } catch (error) {
67
+ handleAuthError(error, {
68
+ defaultMessage: DEFAULT_SAVE_ERROR_MESSAGE,
69
+ code: 'SESSION_PERSISTENCE_ERROR',
70
+ onError,
71
+ setAuthError,
72
+ logger
73
+ });
74
+ }
75
+ }, [logger, onError, setAuthError, storage, storageKeys.activeSessionId]);
76
+ const removeActiveSessionId = useCallback(async () => {
77
+ if (!storage) return;
78
+ try {
79
+ await storage.removeItem(storageKeys.activeSessionId);
80
+ } catch (error) {
81
+ handleAuthError(error, {
82
+ defaultMessage: DEFAULT_SAVE_ERROR_MESSAGE,
83
+ code: 'SESSION_PERSISTENCE_ERROR',
84
+ onError,
85
+ setAuthError,
86
+ logger
87
+ });
88
+ }
89
+ }, [logger, onError, setAuthError, storage, storageKeys.activeSessionId]);
90
+ const clearSessionStorage = useCallback(async () => {
91
+ if (!storage) return;
92
+ try {
93
+ await storage.removeItem(storageKeys.activeSessionId);
94
+ await storage.removeItem(storageKeys.sessionIds);
95
+ } catch (error) {
96
+ handleAuthError(error, {
97
+ defaultMessage: CLEAR_STORAGE_ERROR,
98
+ code: 'STORAGE_ERROR',
99
+ onError,
100
+ setAuthError,
101
+ logger
102
+ });
103
+ }
104
+ }, [logger, onError, setAuthError, storage, storageKeys.activeSessionId, storageKeys.sessionIds]);
105
+ const clearSessionState = useCallback(async () => {
106
+ setSessions([]);
107
+ setActiveSessionId(null);
108
+ logoutStore();
109
+
110
+ // Clear TanStack Query cache (in-memory)
111
+ if (queryClient) {
112
+ queryClient.clear();
113
+ }
114
+
115
+ // Clear persisted query cache
116
+ if (storage) {
117
+ try {
118
+ await clearQueryCache(storage);
119
+ } catch (error) {
120
+ if (logger) {
121
+ logger('Failed to clear persisted query cache', error);
122
+ }
123
+ }
124
+ }
125
+ await clearSessionStorage();
126
+ onAuthStateChange?.(null);
127
+ }, [clearSessionStorage, logoutStore, onAuthStateChange, queryClient, storage, logger]);
128
+ const activateSession = useCallback(async (sessionId, user) => {
129
+ await oxyServices.getTokenBySession(sessionId);
130
+ setTokenReady?.(true);
131
+ setActiveSessionId(sessionId);
132
+ loginSuccess(user);
133
+ await saveActiveSessionId(sessionId);
134
+ await applyLanguagePreference(user);
135
+ onAuthStateChange?.(user);
136
+ }, [applyLanguagePreference, loginSuccess, onAuthStateChange, oxyServices, saveActiveSessionId, setTokenReady]);
137
+ const trackRemovedSession = useCallback(sessionId => {
138
+ removedSessionsRef.current.add(sessionId);
139
+ setTimeout(() => {
140
+ removedSessionsRef.current.delete(sessionId);
141
+ }, 5000);
142
+ }, []);
143
+ const findReplacementSession = useCallback(async sessionIds => {
144
+ if (!sessionIds.length) {
145
+ return null;
146
+ }
147
+ const validationResults = await validateSessionBatch(oxyServices, sessionIds, {
148
+ maxConcurrency: 3
149
+ });
150
+ const validSession = validationResults.find(result => result.valid);
151
+ if (!validSession) {
152
+ return null;
153
+ }
154
+ const validation = await oxyServices.validateSession(validSession.sessionId, {
155
+ useHeaderValidation: true
156
+ });
157
+ if (!validation?.valid || !validation.user) {
158
+ return null;
159
+ }
160
+ const user = validation.user;
161
+ await activateSession(validSession.sessionId, user);
162
+ return user;
163
+ }, [activateSession, oxyServices]);
164
+ const switchSession = useCallback(async sessionId => {
165
+ try {
166
+ const validation = await oxyServices.validateSession(sessionId, {
167
+ useHeaderValidation: true
168
+ });
169
+ if (!validation?.valid) {
170
+ throw new Error('Session is invalid or expired');
171
+ }
172
+ if (!validation.user) {
173
+ throw new Error('User data not available from session validation');
174
+ }
175
+ const user = validation.user;
176
+ await activateSession(sessionId, user);
177
+ try {
178
+ const deviceSessions = await fetchSessionsWithFallback(oxyServices, sessionId, {
179
+ fallbackUserId: user.id,
180
+ logger
181
+ });
182
+ updateSessions(deviceSessions, {
183
+ merge: true
184
+ });
185
+ } catch (error) {
186
+ if (__DEV__) {
187
+ console.warn('Failed to synchronize sessions after switch:', error);
188
+ }
189
+ }
190
+ return user;
191
+ } catch (error) {
192
+ const invalidSession = isInvalidSessionError(error);
193
+ if (invalidSession) {
194
+ updateSessions(sessions.filter(session => session.sessionId !== sessionId), {
195
+ merge: false
196
+ });
197
+ if (sessionId === activeSessionId) {
198
+ const otherSessionIds = sessions.filter(session => session.sessionId !== sessionId && !removedSessionsRef.current.has(session.sessionId)).map(session => session.sessionId);
199
+ const replacementUser = await findReplacementSession(otherSessionIds);
200
+ if (replacementUser) {
201
+ return replacementUser;
202
+ }
203
+ }
204
+ }
205
+ handleAuthError(error, {
206
+ defaultMessage: 'Failed to switch session',
207
+ code: invalidSession ? 'INVALID_SESSION' : 'SESSION_SWITCH_ERROR',
208
+ onError,
209
+ setAuthError,
210
+ logger
211
+ });
212
+ throw error instanceof Error ? error : new Error('Failed to switch session');
213
+ }
214
+ }, [activateSession, activeSessionId, findReplacementSession, logger, loginSuccess, onError, oxyServices, sessions, setAuthError, updateSessions]);
215
+ const refreshSessions = useCallback(async activeUserId => {
216
+ if (!activeSessionId) return;
217
+ if (refreshInFlightRef.current) {
218
+ await refreshInFlightRef.current;
219
+ return;
220
+ }
221
+ const now = Date.now();
222
+ if (now - lastRefreshRef.current < 500) {
223
+ return;
224
+ }
225
+ lastRefreshRef.current = now;
226
+ const refreshPromise = (async () => {
227
+ try {
228
+ const deviceSessions = await fetchSessionsWithFallback(oxyServices, activeSessionId, {
229
+ fallbackUserId: activeUserId,
230
+ logger
231
+ });
232
+ updateSessions(deviceSessions, {
233
+ merge: true
234
+ });
235
+ } catch (error) {
236
+ if (isInvalidSessionError(error)) {
237
+ const otherSessions = sessions.filter(session => session.sessionId !== activeSessionId && !removedSessionsRef.current.has(session.sessionId)).map(session => session.sessionId);
238
+ const replacementUser = await findReplacementSession(otherSessions);
239
+ if (!replacementUser) {
240
+ await clearSessionState();
241
+ }
242
+ return;
243
+ }
244
+ handleAuthError(error, {
245
+ defaultMessage: 'Failed to refresh sessions',
246
+ code: 'SESSION_REFRESH_ERROR',
247
+ onError,
248
+ setAuthError,
249
+ logger
250
+ });
251
+ } finally {
252
+ refreshInFlightRef.current = null;
253
+ lastRefreshRef.current = Date.now();
254
+ }
255
+ })();
256
+ refreshInFlightRef.current = refreshPromise;
257
+ await refreshPromise;
258
+ }, [activeSessionId, clearSessionState, findReplacementSession, logger, onError, oxyServices, sessions, setAuthError, updateSessions]);
259
+ const isRefreshInFlight = Boolean(refreshInFlightRef.current);
260
+ return {
261
+ sessions,
262
+ activeSessionId,
263
+ setActiveSessionId,
264
+ updateSessions,
265
+ switchSession,
266
+ refreshSessions,
267
+ clearSessionState,
268
+ saveActiveSessionId,
269
+ trackRemovedSession,
270
+ storageKeys,
271
+ isRefreshInFlight
272
+ };
273
+ };
274
+ //# sourceMappingURL=useSessionManagement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useMemo","useRef","useState","mergeSessions","normalizeAndSortSessions","sessionsArraysEqual","fetchSessionsWithFallback","validateSessionBatch","getStorageKeys","handleAuthError","isInvalidSessionError","clearQueryCache","DEFAULT_SAVE_ERROR_MESSAGE","CLEAR_STORAGE_ERROR","useSessionManagement","oxyServices","storage","storageKeyPrefix","loginSuccess","logoutStore","applyLanguagePreference","onAuthStateChange","onError","setAuthError","logger","setTokenReady","queryClient","sessions","setSessions","activeSessionId","setActiveSessionId","refreshInFlightRef","removedSessionsRef","Set","lastRefreshRef","storageKeys","saveSessionIds","sessionIds","uniqueIds","Array","from","setItem","JSON","stringify","error","__DEV__","console","warn","updateSessions","incoming","options","prevSessions","processed","merge","map","session","sessionId","saveActiveSessionId","defaultMessage","code","removeActiveSessionId","removeItem","clearSessionStorage","clearSessionState","clear","activateSession","user","getTokenBySession","trackRemovedSession","current","add","setTimeout","delete","findReplacementSession","length","validationResults","maxConcurrency","validSession","find","result","valid","validation","validateSession","useHeaderValidation","switchSession","Error","deviceSessions","fallbackUserId","id","invalidSession","filter","otherSessionIds","has","replacementUser","refreshSessions","activeUserId","now","Date","refreshPromise","otherSessions","isRefreshInFlight","Boolean"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useSessionManagement.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAG9D,SAASC,aAAa,EAAEC,wBAAwB,EAAEC,mBAAmB,QAAQ,6BAA6B;AAC1G,SAASC,yBAAyB,EAAuBC,oBAAoB,QAAQ,4BAA4B;AACjH,SAASC,cAAc,QAA+B,4BAA4B;AAClF,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,2BAA2B;AAGlF,SAASC,eAAe,QAAQ,yBAAyB;AA+BzD,MAAMC,0BAA0B,GAAG,6BAA6B;AAChE,MAAMC,mBAAmB,GAAG,yBAAyB;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAAC;EACnCC,WAAW;EACXC,OAAO;EACPC,gBAAgB;EAChBC,YAAY;EACZC,WAAW;EACXC,uBAAuB;EACvBC,iBAAiB;EACjBC,OAAO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