@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
@@ -8,7 +8,6 @@ var _react = require("react");
8
8
  var _socket = _interopRequireDefault(require("socket.io-client"));
9
9
  var _sonner = require("../../lib/sonner");
10
10
  var _loggerUtils = require("../../utils/loggerUtils");
11
- var _TokenService = require("../../core/services/TokenService");
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  function useSessionSocket({
14
13
  userId,
@@ -18,16 +17,13 @@ function useSessionSocket({
18
17
  logout,
19
18
  clearSessionState,
20
19
  baseURL,
21
- getAccessToken,
22
20
  onRemoteSignOut,
23
21
  onSessionRemoved
24
22
  }) {
25
23
  const socketRef = (0, _react.useRef)(null);
26
24
  const joinedRoomRef = (0, _react.useRef)(null);
27
- const accessTokenRef = (0, _react.useRef)(null);
28
- const handlersSetupRef = (0, _react.useRef)(false);
29
- const lastRegisteredSocketIdRef = (0, _react.useRef)(null);
30
- const getAccessTokenRef = (0, _react.useRef)(getAccessToken);
25
+
26
+ // Store callbacks in refs to avoid re-joining when they change
31
27
  const refreshSessionsRef = (0, _react.useRef)(refreshSessions);
32
28
  const logoutRef = (0, _react.useRef)(logout);
33
29
  const clearSessionStateRef = (0, _react.useRef)(clearSessionState);
@@ -35,6 +31,8 @@ function useSessionSocket({
35
31
  const onSessionRemovedRef = (0, _react.useRef)(onSessionRemoved);
36
32
  const activeSessionIdRef = (0, _react.useRef)(activeSessionId);
37
33
  const currentDeviceIdRef = (0, _react.useRef)(currentDeviceId);
34
+
35
+ // Update refs when callbacks change
38
36
  (0, _react.useEffect)(() => {
39
37
  refreshSessionsRef.current = refreshSessions;
40
38
  logoutRef.current = logout;
@@ -43,363 +41,212 @@ function useSessionSocket({
43
41
  onSessionRemovedRef.current = onSessionRemoved;
44
42
  activeSessionIdRef.current = activeSessionId;
45
43
  currentDeviceIdRef.current = currentDeviceId;
46
- getAccessTokenRef.current = getAccessToken;
47
- }, [refreshSessions, logout, clearSessionState, onRemoteSignOut, onSessionRemoved, activeSessionId, currentDeviceId, getAccessToken]);
44
+ }, [refreshSessions, logout, clearSessionState, onRemoteSignOut, onSessionRemoved, activeSessionId, currentDeviceId]);
48
45
  (0, _react.useEffect)(() => {
49
46
  if (!userId || !baseURL) {
50
- if (socketRef.current) {
51
- socketRef.current.disconnect();
52
- socketRef.current = null;
47
+ // Clean up if userId or baseURL becomes invalid
48
+ if (socketRef.current && joinedRoomRef.current) {
49
+ socketRef.current.emit('leave', {
50
+ userId: joinedRoomRef.current
51
+ });
53
52
  joinedRoomRef.current = null;
54
53
  }
55
54
  return;
56
55
  }
57
- const freshToken = getAccessTokenRef.current();
58
- if (!freshToken) {
59
- _loggerUtils.logger.debug('Deferring socket creation - no access token available yet', {
60
- component: 'useSessionSocket',
61
- userId
56
+ const roomId = `user:${userId}`;
57
+
58
+ // Only create socket if it doesn't exist
59
+ if (!socketRef.current) {
60
+ socketRef.current = (0, _socket.default)(baseURL, {
61
+ transports: ['websocket']
62
62
  });
63
- if (socketRef.current) {
64
- socketRef.current.disconnect();
65
- socketRef.current = null;
66
- joinedRoomRef.current = null;
67
- }
68
- return;
69
63
  }
70
- const initializeSocket = async () => {
71
- try {
72
- await _TokenService.tokenService.refreshTokenIfNeeded();
73
- } catch (error) {
74
- _loggerUtils.logger.debug('Token refresh failed before socket connection', {
75
- component: 'useSessionSocket',
76
- userId,
77
- error
64
+ const socket = socketRef.current;
65
+
66
+ // Only join if we haven't already joined this room
67
+ if (joinedRoomRef.current !== roomId) {
68
+ // Leave previous room if switching users
69
+ if (joinedRoomRef.current) {
70
+ socket.emit('leave', {
71
+ userId: joinedRoomRef.current
78
72
  });
79
73
  }
80
- const accessToken = getAccessTokenRef.current();
81
- const tokenChanged = accessTokenRef.current !== accessToken;
82
- if (!socketRef.current || tokenChanged) {
83
- if (socketRef.current) {
84
- socketRef.current.disconnect();
85
- socketRef.current = null;
86
- }
87
- const socketOptions = {
88
- transports: ['websocket']
89
- };
90
- const freshToken = getAccessTokenRef.current();
91
- if (freshToken) {
92
- socketOptions.auth = {
93
- token: freshToken
94
- };
95
- } else {
96
- _loggerUtils.logger.debug('No access token available for socket authentication', {
97
- component: 'useSessionSocket',
98
- userId
99
- });
100
- return;
101
- }
102
- socketRef.current = (0, _socket.default)(baseURL, socketOptions);
103
- accessTokenRef.current = freshToken;
104
- joinedRoomRef.current = null;
105
- handlersSetupRef.current = false;
74
+ socket.emit('join', {
75
+ userId: roomId
76
+ });
77
+ joinedRoomRef.current = roomId;
78
+ if (__DEV__) {
79
+ console.log('Emitting join for room:', roomId);
106
80
  }
107
- const socket = socketRef.current;
108
- if (!socket) return;
109
- if (!joinedRoomRef.current && socket.connected) {
110
- joinedRoomRef.current = `user:${userId}`;
81
+ }
82
+
83
+ // Set up event handlers (only once per socket instance)
84
+ const handleConnect = () => {
85
+ if (__DEV__) {
86
+ console.log('Socket connected:', socket.id);
111
87
  }
112
- const handleConnect = () => {
113
- const currentToken = getAccessTokenRef.current();
114
- if (__DEV__) {
115
- console.log('[useSessionSocket] Socket connected', {
116
- socketId: socket.id,
117
- userId,
118
- room: `user:${userId}`,
119
- hasAuth: !!currentToken
120
- });
121
- _loggerUtils.logger.debug('Socket connected', {
122
- component: 'useSessionSocket',
123
- socketId: socket.id,
124
- userId
125
- });
126
- }
127
- // Server auto-joins room on connection when authenticated
128
- // Just track that we're connected
129
- if (userId) {
130
- joinedRoomRef.current = `user:${userId}`;
88
+ };
89
+ const handleSessionUpdate = async data => {
90
+ if (__DEV__) {
91
+ console.log('Received session_update:', data);
92
+ }
93
+ const currentActiveSessionId = activeSessionIdRef.current;
94
+ const currentDeviceId = currentDeviceIdRef.current;
95
+
96
+ // Handle different event types
97
+ if (data.type === 'session_removed') {
98
+ // Track removed session
99
+ if (data.sessionId && onSessionRemovedRef.current) {
100
+ onSessionRemovedRef.current(data.sessionId);
131
101
  }
132
- };
133
- const handleDisconnect = async reason => {
134
- _loggerUtils.logger.debug('Socket disconnected', {
135
- component: 'useSessionSocket',
136
- reason,
137
- userId
138
- });
139
- joinedRoomRef.current = null;
140
102
 
141
- // If disconnected due to auth error, try to refresh token and reconnect
142
- if (reason === 'io server disconnect' || reason.includes('auth') || reason.includes('Authentication')) {
103
+ // If the removed sessionId matches the current activeSessionId, immediately clear state
104
+ if (data.sessionId === currentActiveSessionId) {
105
+ if (onRemoteSignOutRef.current) {
106
+ onRemoteSignOutRef.current();
107
+ } else {
108
+ _sonner.toast.info('You have been signed out remotely.');
109
+ }
110
+ // Use clearSessionState since session was already removed server-side
111
+ // Await to ensure storage cleanup completes before continuing
143
112
  try {
144
- // Refresh token and reconnect
145
- await _TokenService.tokenService.refreshTokenIfNeeded();
146
- const freshToken = getAccessTokenRef.current();
147
- if (freshToken && socketRef.current) {
148
- // Update auth and reconnect
149
- socketRef.current.auth = {
150
- token: freshToken
151
- };
152
- socketRef.current.connect();
153
- }
113
+ await clearSessionStateRef.current();
154
114
  } catch (error) {
155
- _loggerUtils.logger.debug('Failed to refresh token after disconnect', {
156
- component: 'useSessionSocket',
157
- userId,
158
- error
159
- });
115
+ if (__DEV__) {
116
+ _loggerUtils.logger.error('Failed to clear session state after session_removed', error instanceof Error ? error : new Error(String(error)), {
117
+ component: 'useSessionSocket'
118
+ });
119
+ }
160
120
  }
161
- }
162
- };
163
- const handleError = error => {
164
- _loggerUtils.logger.error('Socket error', error, {
165
- component: 'useSessionSocket',
166
- userId
167
- });
168
- };
169
- const handleConnectError = async error => {
170
- _loggerUtils.logger.debug('Socket connection error', {
171
- component: 'useSessionSocket',
172
- userId,
173
- error: error.message
174
- });
175
-
176
- // If error is due to expired/invalid token, try to refresh and reconnect
177
- if (error.message.includes('Authentication') || error.message.includes('expired') || error.message.includes('token')) {
178
- try {
179
- await _TokenService.tokenService.refreshTokenIfNeeded();
180
- const freshToken = getAccessTokenRef.current();
181
- if (freshToken && socketRef.current) {
182
- // Update auth and reconnect
183
- socketRef.current.auth = {
184
- token: freshToken
185
- };
186
- socketRef.current.connect();
121
+ } else {
122
+ // Otherwise, just refresh the sessions list (with error handling)
123
+ refreshSessionsRef.current().catch(error => {
124
+ // Silently handle errors from refresh - they're expected if sessions were removed
125
+ if (__DEV__) {
126
+ _loggerUtils.logger.debug('Failed to refresh sessions after session_removed', {
127
+ component: 'useSessionSocket'
128
+ }, error);
187
129
  }
188
- } catch (refreshError) {
189
- _loggerUtils.logger.debug('Failed to refresh token after connection error', {
190
- component: 'useSessionSocket',
191
- userId,
192
- error: refreshError
193
- });
130
+ });
131
+ }
132
+ } else if (data.type === 'device_removed') {
133
+ // Track all removed sessions from this device
134
+ if (data.sessionIds && onSessionRemovedRef.current) {
135
+ for (const sessionId of data.sessionIds) {
136
+ onSessionRemovedRef.current(sessionId);
194
137
  }
195
138
  }
196
- };
197
- const handleSessionUpdate = async data => {
198
- _loggerUtils.logger.debug('Received session_update event', {
199
- component: 'useSessionSocket',
200
- type: data.type,
201
- socketId: socket.id,
202
- socketConnected: socket.connected,
203
- roomId: joinedRoomRef.current
204
- });
205
- const currentActiveSessionId = activeSessionIdRef.current;
206
- const currentDeviceId = currentDeviceIdRef.current;
207
139
 
208
- // Handle different event types
209
- if (data.type === 'session_removed') {
210
- // Track removed session
211
- if (data.sessionId && onSessionRemovedRef.current) {
212
- onSessionRemovedRef.current(data.sessionId);
140
+ // If the removed deviceId matches the current device, immediately clear state
141
+ if (data.deviceId && data.deviceId === currentDeviceId) {
142
+ if (onRemoteSignOutRef.current) {
143
+ onRemoteSignOutRef.current();
144
+ } else {
145
+ _sonner.toast.info('This device has been removed. You have been signed out.');
213
146
  }
214
-
215
- // If the removed sessionId matches the current activeSessionId, immediately clear state
216
- if (data.sessionId === currentActiveSessionId) {
217
- if (onRemoteSignOutRef.current) {
218
- onRemoteSignOutRef.current();
219
- } else {
220
- _sonner.toast.info('You have been signed out remotely.');
221
- }
222
- // Use clearSessionState since session was already removed server-side
223
- // Await to ensure storage cleanup completes before continuing
224
- try {
225
- await clearSessionStateRef.current();
226
- } catch (error) {
227
- if (__DEV__) {
228
- _loggerUtils.logger.error('Failed to clear session state after session_removed', error instanceof Error ? error : new Error(String(error)), {
229
- component: 'useSessionSocket'
230
- });
231
- }
147
+ // Use clearSessionState since sessions were already removed server-side
148
+ // Await to ensure storage cleanup completes before continuing
149
+ try {
150
+ await clearSessionStateRef.current();
151
+ } catch (error) {
152
+ if (__DEV__) {
153
+ _loggerUtils.logger.error('Failed to clear session state after device_removed', error instanceof Error ? error : new Error(String(error)), {
154
+ component: 'useSessionSocket'
155
+ });
232
156
  }
233
- } else {
234
- // Otherwise, just refresh the sessions list (with error handling)
235
- refreshSessionsRef.current().catch(error => {
236
- // Silently handle errors from refresh - they're expected if sessions were removed
237
- if (__DEV__) {
238
- _loggerUtils.logger.debug('Failed to refresh sessions after session_removed', {
239
- component: 'useSessionSocket'
240
- }, error);
241
- }
242
- });
243
157
  }
244
- } else if (data.type === 'device_removed') {
245
- // Track all removed sessions from this device
246
- if (data.sessionIds && onSessionRemovedRef.current) {
247
- for (const sessionId of data.sessionIds) {
248
- onSessionRemovedRef.current(sessionId);
158
+ } else {
159
+ // Otherwise, refresh sessions and device list (with error handling)
160
+ refreshSessionsRef.current().catch(error => {
161
+ // Silently handle errors from refresh - they're expected if sessions were removed
162
+ if (__DEV__) {
163
+ _loggerUtils.logger.debug('Failed to refresh sessions after device_removed', {
164
+ component: 'useSessionSocket'
165
+ }, error);
249
166
  }
167
+ });
168
+ }
169
+ } else if (data.type === 'sessions_removed') {
170
+ // Track all removed sessions
171
+ if (data.sessionIds && onSessionRemovedRef.current) {
172
+ for (const sessionId of data.sessionIds) {
173
+ onSessionRemovedRef.current(sessionId);
250
174
  }
175
+ }
251
176
 
252
- // If the removed deviceId matches the current device, immediately clear state
253
- if (data.deviceId && data.deviceId === currentDeviceId) {
254
- if (onRemoteSignOutRef.current) {
255
- onRemoteSignOutRef.current();
256
- } else {
257
- _sonner.toast.info('This device has been removed. You have been signed out.');
258
- }
259
- // Use clearSessionState since sessions were already removed server-side
260
- // Await to ensure storage cleanup completes before continuing
261
- try {
262
- await clearSessionStateRef.current();
263
- } catch (error) {
264
- if (__DEV__) {
265
- _loggerUtils.logger.error('Failed to clear session state after device_removed', error instanceof Error ? error : new Error(String(error)), {
266
- component: 'useSessionSocket'
267
- });
268
- }
269
- }
177
+ // If the current activeSessionId is in the removed sessionIds list, immediately clear state
178
+ if (data.sessionIds && currentActiveSessionId && data.sessionIds.includes(currentActiveSessionId)) {
179
+ if (onRemoteSignOutRef.current) {
180
+ onRemoteSignOutRef.current();
270
181
  } else {
271
- // Otherwise, refresh sessions and device list (with error handling)
272
- refreshSessionsRef.current().catch(error => {
273
- // Silently handle errors from refresh - they're expected if sessions were removed
274
- if (__DEV__) {
275
- _loggerUtils.logger.debug('Failed to refresh sessions after device_removed', {
276
- component: 'useSessionSocket'
277
- }, error);
278
- }
279
- });
280
- }
281
- } else if (data.type === 'sessions_removed') {
282
- // Track all removed sessions
283
- if (data.sessionIds && onSessionRemovedRef.current) {
284
- for (const sessionId of data.sessionIds) {
285
- onSessionRemovedRef.current(sessionId);
286
- }
182
+ _sonner.toast.info('You have been signed out remotely.');
287
183
  }
288
-
289
- // If the current activeSessionId is in the removed sessionIds list, immediately clear state
290
- if (data.sessionIds && currentActiveSessionId && data.sessionIds.includes(currentActiveSessionId)) {
291
- if (onRemoteSignOutRef.current) {
292
- onRemoteSignOutRef.current();
293
- } else {
294
- _sonner.toast.info('You have been signed out remotely.');
295
- }
296
- // Use clearSessionState since sessions were already removed server-side
297
- // Await to ensure storage cleanup completes before continuing
298
- try {
299
- await clearSessionStateRef.current();
300
- } catch (error) {
301
- if (__DEV__) {
302
- _loggerUtils.logger.error('Failed to clear session state after sessions_removed', error instanceof Error ? error : new Error(String(error)), {
303
- component: 'useSessionSocket'
304
- });
305
- }
184
+ // Use clearSessionState since sessions were already removed server-side
185
+ // Await to ensure storage cleanup completes before continuing
186
+ try {
187
+ await clearSessionStateRef.current();
188
+ } catch (error) {
189
+ if (__DEV__) {
190
+ _loggerUtils.logger.error('Failed to clear session state after sessions_removed', error instanceof Error ? error : new Error(String(error)), {
191
+ component: 'useSessionSocket'
192
+ });
306
193
  }
307
- } else {
308
- // Otherwise, refresh sessions list (with error handling)
309
- refreshSessionsRef.current().catch(error => {
310
- // Silently handle errors from refresh - they're expected if sessions were removed
311
- if (__DEV__) {
312
- _loggerUtils.logger.debug('Failed to refresh sessions after sessions_removed', {
313
- component: 'useSessionSocket'
314
- }, error);
315
- }
316
- });
317
194
  }
318
195
  } else {
319
- // For other event types (e.g., session_created), refresh sessions (with error handling)
196
+ // Otherwise, refresh sessions list (with error handling)
320
197
  refreshSessionsRef.current().catch(error => {
321
- // Log but don't throw - refresh errors shouldn't break the socket handler
198
+ // Silently handle errors from refresh - they're expected if sessions were removed
322
199
  if (__DEV__) {
323
- _loggerUtils.logger.debug('Failed to refresh sessions after session_update', {
200
+ _loggerUtils.logger.debug('Failed to refresh sessions after sessions_removed', {
324
201
  component: 'useSessionSocket'
325
202
  }, error);
326
203
  }
327
204
  });
328
-
329
- // If the current session was logged out (legacy behavior), handle it specially
330
- if (data.sessionId === currentActiveSessionId) {
331
- if (onRemoteSignOutRef.current) {
332
- onRemoteSignOutRef.current();
333
- } else {
334
- _sonner.toast.info('You have been signed out remotely.');
335
- }
336
- // Use clearSessionState since session was already removed server-side
337
- // Await to ensure storage cleanup completes before continuing
338
- try {
339
- await clearSessionStateRef.current();
340
- } catch (error) {
341
- _loggerUtils.logger.error('Failed to clear session state after session_update', error instanceof Error ? error : new Error(String(error)), {
342
- component: 'useSessionSocket'
343
- });
344
- }
345
- }
346
205
  }
347
- };
206
+ } else {
207
+ // For other event types (e.g., session_created), refresh sessions (with error handling)
208
+ refreshSessionsRef.current().catch(error => {
209
+ // Log but don't throw - refresh errors shouldn't break the socket handler
210
+ if (__DEV__) {
211
+ _loggerUtils.logger.debug('Failed to refresh sessions after session_update', {
212
+ component: 'useSessionSocket'
213
+ }, error);
214
+ }
215
+ });
348
216
 
349
- // Register event handlers (only once per socket instance)
350
- // Track by socket.id to prevent duplicate registrations when socket reconnects
351
- const currentSocketId = socket.id || 'pending';
352
- if (!handlersSetupRef.current || lastRegisteredSocketIdRef.current !== currentSocketId) {
353
- // Remove old handlers if socket changed (reconnection)
354
- if (socketRef.current && handlersSetupRef.current && lastRegisteredSocketIdRef.current) {
217
+ // If the current session was logged out (legacy behavior), handle it specially
218
+ if (data.sessionId === currentActiveSessionId) {
219
+ if (onRemoteSignOutRef.current) {
220
+ onRemoteSignOutRef.current();
221
+ } else {
222
+ _sonner.toast.info('You have been signed out remotely.');
223
+ }
224
+ // Use clearSessionState since session was already removed server-side
225
+ // Await to ensure storage cleanup completes before continuing
355
226
  try {
356
- socketRef.current.off('connect', handleConnect);
357
- socketRef.current.off('disconnect', handleDisconnect);
358
- socketRef.current.off('error', handleError);
359
- socketRef.current.off('session_update', handleSessionUpdate);
227
+ await clearSessionStateRef.current();
360
228
  } catch (error) {
361
- // Ignore errors when removing handlers
229
+ if (__DEV__) {
230
+ console.error('Failed to clear session state after session_update:', error);
231
+ }
362
232
  }
363
233
  }
364
-
365
- // Register handlers on current socket
366
- socket.on('connect', handleConnect);
367
- socket.on('disconnect', handleDisconnect);
368
- socket.on('error', handleError);
369
- socket.on('connect_error', handleConnectError);
370
- socket.on('session_update', handleSessionUpdate);
371
- handlersSetupRef.current = true;
372
- lastRegisteredSocketIdRef.current = currentSocketId;
373
- _loggerUtils.logger.debug('Event handlers set up', {
374
- component: 'useSessionSocket',
375
- socketId: socket.id,
376
- userId
377
- });
378
- }
379
- if (!socket.connected) {
380
- _loggerUtils.logger.debug('Socket not connected, connecting...', {
381
- component: 'useSessionSocket',
382
- userId
383
- });
384
- socket.connect();
385
234
  }
386
235
  };
387
- initializeSocket();
236
+ socket.on('connect', handleConnect);
237
+ socket.on('session_update', handleSessionUpdate);
388
238
  return () => {
389
- // Only clean up handlers if socket still exists and handlers were set up
390
- if (socketRef.current && handlersSetupRef.current) {
391
- try {
392
- socketRef.current.off('connect');
393
- socketRef.current.off('disconnect');
394
- socketRef.current.off('error');
395
- socketRef.current.off('connect_error');
396
- socketRef.current.off('session_update');
397
- } catch (error) {
398
- // Ignore errors when removing handlers
399
- }
400
- handlersSetupRef.current = false;
239
+ socket.off('connect', handleConnect);
240
+ socket.off('session_update', handleSessionUpdate);
241
+
242
+ // Only leave on unmount if we're still in this room
243
+ if (joinedRoomRef.current === roomId) {
244
+ socket.emit('leave', {
245
+ userId: roomId
246
+ });
247
+ joinedRoomRef.current = null;
401
248
  }
402
249
  };
403
- }, [userId, baseURL]); // Only depend on userId and baseURL - functions are in refs
250
+ }, [userId, baseURL]); // Only depend on userId and baseURL - callbacks are in refs
404
251
  }
405
252
  //# sourceMappingURL=useSessionSocket.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_socket","_interopRequireDefault","_sonner","_loggerUtils","_TokenService","e","__esModule","default","useSessionSocket","userId","activeSessionId","currentDeviceId","refreshSessions","logout","clearSessionState","baseURL","getAccessToken","onRemoteSignOut","onSessionRemoved","socketRef","useRef","joinedRoomRef","accessTokenRef","handlersSetupRef","lastRegisteredSocketIdRef","getAccessTokenRef","refreshSessionsRef","logoutRef","clearSessionStateRef","onRemoteSignOutRef","onSessionRemovedRef","activeSessionIdRef","currentDeviceIdRef","useEffect","current","disconnect","freshToken","logger","debug","component","initializeSocket","tokenService","refreshTokenIfNeeded","error","accessToken","tokenChanged","socketOptions","transports","auth","token","io","socket","connected","handleConnect","currentToken","__DEV__","console","log","socketId","id","room","hasAuth","handleDisconnect","reason","includes","connect","handleError","handleConnectError","message","refreshError","handleSessionUpdate","data","type","socketConnected","roomId","currentActiveSessionId","sessionId","toast","info","Error","String","catch","sessionIds","deviceId","currentSocketId","off","on"],"sourceRoot":"../../../../src","sources":["ui/hooks/useSessionSocket.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAAgE,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAezD,SAASG,gBAAgBA,CAAC;EAAEC,MAAM;EAAEC,eAAe;EAAEC,eAAe;EAAEC,eAAe;EAAEC,MAAM;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC,cAAc;EAAEC,eAAe;EAAEC;AAAwC,CAAC,EAAE;EAC5M,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAM,IAAI,CAAC;EACnC,MAAMC,aAAa,GAAG,IAAAD,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,EAAE,kBAAkB;UAAEmB,QAAQ,EAAEP,MAAM,CAACQ,EAAE;UAAElD;QAAO,CAAC,CAAC;MACvG;MAEE,IAAI,CAAC0C,MAAM,CAACC,SAAS,EAAE;QACrBf,mBAAM,CAACC,KAAK,CAAC,qCAAqC,EAAE;UAAEC,SAAS,EAAE,kBAAkB;UAAE9B;QAAO,CAAC,CAAC;QAC9F0C,MAAM,CAACc,OAAO,CAAC,CAAC;MAClB;IACF,CAAC;IAEDzB,gBAAgB,CAAC,CAAC;IAElB,OAAO,MAAM;MACX;MACA,IAAIrB,SAAS,CAACe,OAAO,IAAIX,gBAAgB,CAACW,OAAO,EAAE;QACjD,IAAI;UACFf,SAAS,CAACe,OAAO,CAACmD,GAAG,CAAC,SAAS,CAAC;UAChClE,SAAS,CAACe,OAAO,CAACmD,GAAG,CAAC,YAAY,CAAC;UACnClE,SAAS,CAACe,OAAO,CAACmD,GAAG,CAAC,OAAO,CAAC;UAC9BlE,SAAS,CAACe,OAAO,CAACmD,GAAG,CAAC,eAAe,CAAC;UACtClE,SAAS,CAACe,OAAO,CAACmD,GAAG,CAAC,gBAAgB,CAAC;QACzC,CAAC,CAAC,OAAO1C,KAAK,EAAE;UACd;QAAA;QAEFpB,gBAAgB,CAACW,OAAO,GAAG,KAAK;MAClC;IACF,CAAC;EACH,CAAC,EAAE,CAACzB,MAAM,EAAEM,OAAO,CAAC,CAAC,CAAC,CAAC;AACzB","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_socket","_interopRequireDefault","_sonner","_loggerUtils","e","__esModule","default","useSessionSocket","userId","activeSessionId","currentDeviceId","refreshSessions","logout","clearSessionState","baseURL","onRemoteSignOut","onSessionRemoved","socketRef","useRef","joinedRoomRef","refreshSessionsRef","logoutRef","clearSessionStateRef","onRemoteSignOutRef","onSessionRemovedRef","activeSessionIdRef","currentDeviceIdRef","useEffect","current","emit","roomId","io","transports","socket","__DEV__","console","log","handleConnect","id","handleSessionUpdate","data","currentActiveSessionId","type","sessionId","toast","info","error","logger","Error","String","component","catch","debug","sessionIds","deviceId","includes","on","off"],"sourceRoot":"../../../../src","sources":["ui/hooks/useSessionSocket.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAAiD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAc1C,SAASG,gBAAgBA,CAAC;EAAEC,MAAM;EAAEC,eAAe;EAAEC,eAAe;EAAEC,eAAe;EAAEC,MAAM;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC,eAAe;EAAEC;AAAwC,CAAC,EAAE;EAC5L,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAM,IAAI,CAAC;EACnC,MAAMC,aAAa,GAAG,IAAAD,aAAM,EAAgB,IAAI,CAAC;;EAEjD;EACA,MAAME,kBAAkB,GAAG,IAAAF,aAAM,EAACP,eAAe,CAAC;EAClD,MAAMU,SAAS,GAAG,IAAAH,aAAM,EAACN,MAAM,CAAC;EAChC,MAAMU,oBAAoB,GAAG,IAAAJ,aAAM,EAACL,iBAAiB,CAAC;EACtD,MAAMU,kBAAkB,GAAG,IAAAL,aAAM,EAACH,eAAe,CAAC;EAClD,MAAMS,mBAAmB,GAAG,IAAAN,aAAM,EAACF,gBAAgB,CAAC;EACpD,MAAMS,kBAAkB,GAAG,IAAAP,aAAM,EAACT,eAAe,CAAC;EAClD,MAAMiB,kBAAkB,GAAG,IAAAR,aAAM,EAACR,eAAe,CAAC;;EAElD;EACA,IAAAiB,gBAAS,EAAC,MAAM;IACdP,kBAAkB,CAACQ,OAAO,GAAGjB,eAAe;IAC5CU,SAAS,CAACO,OAAO,GAAGhB,MAAM;IAC1BU,oBAAoB,CAACM,OAAO,GAAGf,iBAAiB;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