@oxyhq/services 5.16.44 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (506) hide show
  1. package/README.md +29 -10
  2. package/lib/commonjs/core/OxyServices.js +1 -1
  3. package/lib/commonjs/core/index.js +20 -15
  4. package/lib/commonjs/core/index.js.map +1 -1
  5. package/lib/commonjs/core/mixins/OxyServices.auth.js +36 -53
  6. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
  7. package/lib/commonjs/core/mixins/OxyServices.user.js +10 -17
  8. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  9. package/lib/commonjs/core/services/TokenService.js +27 -13
  10. package/lib/commonjs/core/services/TokenService.js.map +1 -1
  11. package/lib/commonjs/crypto/index.js +0 -16
  12. package/lib/commonjs/crypto/index.js.map +1 -1
  13. package/lib/commonjs/crypto/keyManager.js +21 -22
  14. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  15. package/lib/commonjs/crypto/polyfill.js +1 -10
  16. package/lib/commonjs/crypto/polyfill.js.map +1 -1
  17. package/lib/commonjs/crypto/signatureService.js +18 -32
  18. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  19. package/lib/commonjs/index.js +13 -134
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/models/interfaces.js +0 -7
  22. package/lib/commonjs/models/interfaces.js.map +1 -1
  23. package/lib/commonjs/node/index.js +1 -10
  24. package/lib/commonjs/node/index.js.map +1 -1
  25. package/lib/commonjs/ui/components/BottomSheetRouter.js +1 -9
  26. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  27. package/lib/commonjs/ui/context/OxyContext.js +779 -450
  28. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  29. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +551 -0
  30. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -0
  31. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +73 -0
  32. package/lib/commonjs/ui/context/hooks/useDeviceManagement.js.map +1 -0
  33. package/lib/commonjs/ui/context/hooks/useStorage.js +79 -0
  34. package/lib/commonjs/ui/context/hooks/useStorage.js.map +1 -0
  35. package/lib/commonjs/ui/hooks/index.js +0 -20
  36. package/lib/commonjs/ui/hooks/index.js.map +1 -1
  37. package/lib/commonjs/ui/hooks/mutations/index.js +0 -12
  38. package/lib/commonjs/ui/hooks/mutations/index.js.map +1 -1
  39. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +23 -74
  40. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  41. package/lib/commonjs/ui/hooks/queries/index.js +0 -12
  42. package/lib/commonjs/ui/hooks/queries/index.js.map +1 -1
  43. package/lib/commonjs/ui/hooks/queries/queryKeys.js +1 -3
  44. package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -1
  45. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +28 -64
  46. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  47. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +6 -4
  48. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  49. package/lib/commonjs/ui/hooks/useDeviceManagement.js +73 -0
  50. package/lib/commonjs/ui/hooks/useDeviceManagement.js.map +1 -0
  51. package/lib/commonjs/ui/hooks/useProfileEditing.js +5 -3
  52. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  53. package/lib/commonjs/ui/hooks/useSessionManagement.js +284 -0
  54. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -0
  55. package/lib/commonjs/ui/index.js +2 -10
  56. package/lib/commonjs/ui/index.js.map +1 -1
  57. package/lib/commonjs/ui/navigation/routes.js +1 -5
  58. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  59. package/lib/commonjs/ui/screens/AccountCenterScreen.js +4 -9
  60. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  61. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +19 -37
  62. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  63. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +5 -5
  64. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  65. package/lib/commonjs/ui/screens/OxyAuthScreen.js +15 -2
  66. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  67. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +97 -76
  68. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  69. package/lib/commonjs/ui/screens/ProfileScreen.js +6 -6
  70. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  71. package/lib/commonjs/ui/stores/authStore.js +6 -54
  72. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  73. package/lib/commonjs/ui/styles/spacing.js +2 -54
  74. package/lib/commonjs/ui/styles/spacing.js.map +1 -1
  75. package/lib/commonjs/ui/utils/avatarUtils.js +12 -9
  76. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  77. package/lib/commonjs/ui/utils/sessionHelpers.js +1 -7
  78. package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
  79. package/lib/commonjs/utils/deviceManager.js +177 -0
  80. package/lib/commonjs/utils/deviceManager.js.map +1 -0
  81. package/lib/commonjs/utils/errorUtils.js +0 -13
  82. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  83. package/lib/commonjs/utils/index.js +7 -0
  84. package/lib/commonjs/utils/index.js.map +1 -1
  85. package/lib/commonjs/utils/sessionUtils.js +1 -8
  86. package/lib/commonjs/utils/sessionUtils.js.map +1 -1
  87. package/lib/commonjs/utils/validationUtils.js +1 -15
  88. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  89. package/lib/module/core/OxyServices.js +1 -1
  90. package/lib/module/core/index.js +4 -6
  91. package/lib/module/core/index.js.map +1 -1
  92. package/lib/module/core/mixins/OxyServices.auth.js +36 -53
  93. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
  94. package/lib/module/core/mixins/OxyServices.user.js +10 -17
  95. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  96. package/lib/module/core/services/TokenService.js +27 -13
  97. package/lib/module/core/services/TokenService.js.map +1 -1
  98. package/lib/module/crypto/index.js +0 -3
  99. package/lib/module/crypto/index.js.map +1 -1
  100. package/lib/module/crypto/keyManager.js +21 -22
  101. package/lib/module/crypto/keyManager.js.map +1 -1
  102. package/lib/module/crypto/polyfill.js +1 -2
  103. package/lib/module/crypto/polyfill.js.map +1 -1
  104. package/lib/module/crypto/signatureService.js +18 -32
  105. package/lib/module/crypto/signatureService.js.map +1 -1
  106. package/lib/module/index.js +7 -19
  107. package/lib/module/index.js.map +1 -1
  108. package/lib/module/models/interfaces.js +0 -7
  109. package/lib/module/models/interfaces.js.map +1 -1
  110. package/lib/module/node/index.js +0 -3
  111. package/lib/module/node/index.js.map +1 -1
  112. package/lib/module/ui/components/BottomSheetRouter.js +2 -6
  113. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  114. package/lib/module/ui/context/OxyContext.js +779 -450
  115. package/lib/module/ui/context/OxyContext.js.map +1 -1
  116. package/lib/module/ui/context/hooks/useAuthOperations.js +545 -0
  117. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -0
  118. package/lib/module/ui/context/hooks/useDeviceManagement.js +68 -0
  119. package/lib/module/ui/context/hooks/useDeviceManagement.js.map +1 -0
  120. package/lib/module/ui/context/hooks/useStorage.js +74 -0
  121. package/lib/module/ui/context/hooks/useStorage.js.map +1 -0
  122. package/lib/module/ui/hooks/index.js +0 -1
  123. package/lib/module/ui/hooks/index.js.map +1 -1
  124. package/lib/module/ui/hooks/mutations/index.js +1 -1
  125. package/lib/module/ui/hooks/mutations/index.js.map +1 -1
  126. package/lib/module/ui/hooks/mutations/useAccountMutations.js +21 -71
  127. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  128. package/lib/module/ui/hooks/queries/index.js +1 -1
  129. package/lib/module/ui/hooks/queries/index.js.map +1 -1
  130. package/lib/module/ui/hooks/queries/queryKeys.js +1 -3
  131. package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -1
  132. package/lib/module/ui/hooks/queries/useAccountQueries.js +27 -61
  133. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  134. package/lib/module/ui/hooks/queries/useServicesQueries.js +6 -4
  135. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  136. package/lib/module/ui/hooks/useDeviceManagement.js +68 -0
  137. package/lib/module/ui/hooks/useDeviceManagement.js.map +1 -0
  138. package/lib/module/ui/hooks/useProfileEditing.js +5 -3
  139. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  140. package/lib/module/ui/hooks/useSessionManagement.js +279 -0
  141. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -0
  142. package/lib/module/ui/index.js +1 -2
  143. package/lib/module/ui/index.js.map +1 -1
  144. package/lib/module/ui/navigation/routes.js +1 -5
  145. package/lib/module/ui/navigation/routes.js.map +1 -1
  146. package/lib/module/ui/screens/AccountCenterScreen.js +4 -9
  147. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  148. package/lib/module/ui/screens/AccountSettingsScreen.js +19 -37
  149. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  150. package/lib/module/ui/screens/AccountSwitcherScreen.js +5 -5
  151. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  152. package/lib/module/ui/screens/OxyAuthScreen.js +15 -2
  153. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  154. package/lib/module/ui/screens/PrivacySettingsScreen.js +98 -77
  155. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  156. package/lib/module/ui/screens/ProfileScreen.js +6 -6
  157. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  158. package/lib/module/ui/stores/authStore.js +6 -54
  159. package/lib/module/ui/stores/authStore.js.map +1 -1
  160. package/lib/module/ui/styles/spacing.js +2 -6
  161. package/lib/module/ui/styles/spacing.js.map +1 -1
  162. package/lib/module/ui/utils/avatarUtils.js +12 -9
  163. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  164. package/lib/module/ui/utils/sessionHelpers.js +1 -7
  165. package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
  166. package/lib/module/utils/deviceManager.js +171 -0
  167. package/lib/module/utils/deviceManager.js.map +1 -0
  168. package/lib/module/utils/errorUtils.js +0 -7
  169. package/lib/module/utils/errorUtils.js.map +1 -1
  170. package/lib/module/utils/index.js +1 -2
  171. package/lib/module/utils/index.js.map +1 -1
  172. package/lib/module/utils/sessionUtils.js +1 -8
  173. package/lib/module/utils/sessionUtils.js.map +1 -1
  174. package/lib/module/utils/validationUtils.js +0 -13
  175. package/lib/module/utils/validationUtils.js.map +1 -1
  176. package/lib/typescript/core/OxyServices.d.ts +1 -1
  177. package/lib/typescript/core/index.d.ts +3 -3
  178. package/lib/typescript/core/index.d.ts.map +1 -1
  179. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +21 -44
  180. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  181. package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -0
  182. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  183. package/lib/typescript/core/mixins/index.d.ts +8 -15
  184. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  185. package/lib/typescript/core/services/TokenService.d.ts.map +1 -1
  186. package/lib/typescript/crypto/index.d.ts +0 -1
  187. package/lib/typescript/crypto/index.d.ts.map +1 -1
  188. package/lib/typescript/crypto/keyManager.d.ts +2 -15
  189. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  190. package/lib/typescript/crypto/polyfill.d.ts +1 -2
  191. package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
  192. package/lib/typescript/crypto/signatureService.d.ts +0 -13
  193. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  194. package/lib/typescript/index.d.ts +7 -12
  195. package/lib/typescript/index.d.ts.map +1 -1
  196. package/lib/typescript/models/interfaces.d.ts +36 -5
  197. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  198. package/lib/typescript/models/session.d.ts +18 -3
  199. package/lib/typescript/models/session.d.ts.map +1 -1
  200. package/lib/typescript/node/index.d.ts +0 -1
  201. package/lib/typescript/node/index.d.ts.map +1 -1
  202. package/lib/typescript/ui/components/BottomSheetRouter.d.ts +0 -5
  203. package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
  204. package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
  205. package/lib/typescript/ui/components/TextField/helpers.d.ts +2 -2
  206. package/lib/typescript/ui/components/TextField/types.d.ts +0 -1
  207. package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
  208. package/lib/typescript/ui/context/OxyContext.d.ts +28 -5
  209. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  210. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +59 -0
  211. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -0
  212. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts +27 -0
  213. package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts.map +1 -0
  214. package/lib/typescript/ui/context/hooks/useStorage.d.ts +22 -0
  215. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +1 -0
  216. package/lib/typescript/ui/hooks/index.d.ts +0 -1
  217. package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
  218. package/lib/typescript/ui/hooks/mutations/index.d.ts +1 -1
  219. package/lib/typescript/ui/hooks/mutations/index.d.ts.map +1 -1
  220. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +8 -19
  221. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  222. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +1 -1
  223. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
  224. package/lib/typescript/ui/hooks/queries/index.d.ts +1 -1
  225. package/lib/typescript/ui/hooks/queries/index.d.ts.map +1 -1
  226. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts +0 -2
  227. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts.map +1 -1
  228. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +5 -17
  229. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  230. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  231. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts +27 -0
  232. package/lib/typescript/ui/hooks/useDeviceManagement.d.ts.map +1 -0
  233. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  234. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +41 -0
  235. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -0
  236. package/lib/typescript/ui/index.d.ts +0 -1
  237. package/lib/typescript/ui/index.d.ts.map +1 -1
  238. package/lib/typescript/ui/navigation/routes.d.ts +1 -1
  239. package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
  240. package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
  241. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  242. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  243. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  244. package/lib/typescript/ui/stores/authStore.d.ts +1 -8
  245. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  246. package/lib/typescript/ui/styles/spacing.d.ts +0 -5
  247. package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
  248. package/lib/typescript/ui/utils/avatarUtils.d.ts +4 -1
  249. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  250. package/lib/typescript/ui/utils/sessionHelpers.d.ts +0 -1
  251. package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
  252. package/lib/typescript/utils/deviceManager.d.ts +66 -0
  253. package/lib/typescript/utils/deviceManager.d.ts.map +1 -0
  254. package/lib/typescript/utils/errorUtils.d.ts +0 -6
  255. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  256. package/lib/typescript/utils/index.d.ts +2 -0
  257. package/lib/typescript/utils/index.d.ts.map +1 -1
  258. package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
  259. package/lib/typescript/utils/validationUtils.d.ts +0 -8
  260. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  261. package/package.json +1 -6
  262. package/src/core/OxyServices.ts +1 -1
  263. package/src/core/index.ts +5 -8
  264. package/src/core/mixins/OxyServices.auth.ts +44 -87
  265. package/src/core/mixins/OxyServices.user.ts +10 -18
  266. package/src/core/services/TokenService.ts +27 -16
  267. package/src/crypto/index.ts +1 -3
  268. package/src/crypto/keyManager.ts +21 -30
  269. package/src/crypto/polyfill.ts +1 -2
  270. package/src/crypto/signatureService.ts +19 -43
  271. package/src/index.ts +6 -41
  272. package/src/models/interfaces.ts +39 -12
  273. package/src/models/session.ts +19 -7
  274. package/src/node/index.ts +0 -3
  275. package/src/ui/components/BottomSheetRouter.tsx +1 -6
  276. package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
  277. package/src/ui/components/TextField/helpers.tsx +2 -2
  278. package/src/ui/components/TextField/types.tsx +1 -1
  279. package/src/ui/context/OxyContext.tsx +831 -463
  280. package/src/ui/context/hooks/useAuthOperations.ts +620 -0
  281. package/src/ui/context/hooks/useDeviceManagement.ts +108 -0
  282. package/src/ui/context/hooks/useStorage.ts +104 -0
  283. package/src/ui/hooks/index.ts +1 -2
  284. package/src/ui/hooks/mutations/index.ts +0 -2
  285. package/src/ui/hooks/mutations/useAccountMutations.ts +20 -66
  286. package/src/ui/hooks/queries/index.ts +0 -2
  287. package/src/ui/hooks/queries/queryKeys.ts +0 -2
  288. package/src/ui/hooks/queries/useAccountQueries.ts +19 -53
  289. package/src/ui/hooks/queries/useServicesQueries.ts +5 -5
  290. package/src/ui/hooks/useDeviceManagement.ts +108 -0
  291. package/src/ui/hooks/useProfileEditing.ts +3 -3
  292. package/src/ui/hooks/useSessionManagement.ts +405 -0
  293. package/src/ui/index.ts +1 -2
  294. package/src/ui/navigation/routes.ts +2 -6
  295. package/src/ui/screens/AccountCenterScreen.tsx +4 -9
  296. package/src/ui/screens/AccountSettingsScreen.tsx +31 -49
  297. package/src/ui/screens/AccountSwitcherScreen.tsx +5 -5
  298. package/src/ui/screens/OxyAuthScreen.tsx +19 -4
  299. package/src/ui/screens/PrivacySettingsScreen.tsx +101 -67
  300. package/src/ui/screens/ProfileScreen.tsx +10 -10
  301. package/src/ui/stores/authStore.ts +8 -48
  302. package/src/ui/styles/spacing.ts +2 -15
  303. package/src/ui/utils/avatarUtils.ts +21 -19
  304. package/src/ui/utils/sessionHelpers.ts +0 -7
  305. package/src/utils/__tests__/validationUtils.test.ts +1 -16
  306. package/src/utils/deviceManager.ts +198 -0
  307. package/src/utils/errorUtils.ts +1 -8
  308. package/src/utils/index.ts +2 -1
  309. package/src/utils/sessionUtils.ts +0 -8
  310. package/src/utils/validationUtils.ts +0 -12
  311. package/lib/commonjs/adapters/expo/crypto.js +0 -56
  312. package/lib/commonjs/adapters/expo/crypto.js.map +0 -1
  313. package/lib/commonjs/adapters/expo/fetch.js +0 -30
  314. package/lib/commonjs/adapters/expo/fetch.js.map +0 -1
  315. package/lib/commonjs/adapters/expo/index.js +0 -48
  316. package/lib/commonjs/adapters/expo/index.js.map +0 -1
  317. package/lib/commonjs/adapters/expo/storage.js +0 -201
  318. package/lib/commonjs/adapters/expo/storage.js.map +0 -1
  319. package/lib/commonjs/adapters/index.js +0 -48
  320. package/lib/commonjs/adapters/index.js.map +0 -1
  321. package/lib/commonjs/adapters/node/crypto.js +0 -40
  322. package/lib/commonjs/adapters/node/crypto.js.map +0 -1
  323. package/lib/commonjs/adapters/node/fetch.js +0 -62
  324. package/lib/commonjs/adapters/node/fetch.js.map +0 -1
  325. package/lib/commonjs/adapters/node/index.js +0 -34
  326. package/lib/commonjs/adapters/node/index.js.map +0 -1
  327. package/lib/commonjs/adapters/node/storage.js +0 -163
  328. package/lib/commonjs/adapters/node/storage.js.map +0 -1
  329. package/lib/commonjs/core/identity-session/DeviceManager.js +0 -237
  330. package/lib/commonjs/core/identity-session/DeviceManager.js.map +0 -1
  331. package/lib/commonjs/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  332. package/lib/commonjs/core/identity-session/IdentityManager.js +0 -400
  333. package/lib/commonjs/core/identity-session/IdentityManager.js.map +0 -1
  334. package/lib/commonjs/core/identity-session/IdentitySessionCore.js +0 -394
  335. package/lib/commonjs/core/identity-session/IdentitySessionCore.js.map +0 -1
  336. package/lib/commonjs/core/identity-session/RefreshManager.js +0 -137
  337. package/lib/commonjs/core/identity-session/RefreshManager.js.map +0 -1
  338. package/lib/commonjs/core/identity-session/SessionManager.js +0 -427
  339. package/lib/commonjs/core/identity-session/SessionManager.js.map +0 -1
  340. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js +0 -24
  341. package/lib/commonjs/core/identity-session/createIdentitySessionCore.js.map +0 -1
  342. package/lib/commonjs/core/identity-session/errors.js +0 -176
  343. package/lib/commonjs/core/identity-session/errors.js.map +0 -1
  344. package/lib/commonjs/core/identity-session/index.js +0 -80
  345. package/lib/commonjs/core/identity-session/index.js.map +0 -1
  346. package/lib/commonjs/core/identity-session/types.js +0 -2
  347. package/lib/commonjs/core/identity-session/types.js.map +0 -1
  348. package/lib/commonjs/crypto/README.md +0 -142
  349. package/lib/commonjs/crypto/core.js +0 -147
  350. package/lib/commonjs/crypto/core.js.map +0 -1
  351. package/lib/commonjs/node/signatureService.js +0 -107
  352. package/lib/commonjs/node/signatureService.js.map +0 -1
  353. package/lib/commonjs/ui/hooks/auth/index.js +0 -37
  354. package/lib/commonjs/ui/hooks/auth/index.js.map +0 -1
  355. package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js +0 -171
  356. package/lib/commonjs/ui/hooks/auth/useUsernameValidation.js.map +0 -1
  357. package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -52
  358. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
  359. package/lib/commonjs/ui/hooks/useIdentityTransfer.js +0 -125
  360. package/lib/commonjs/ui/hooks/useIdentityTransfer.js.map +0 -1
  361. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js +0 -81
  362. package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js.map +0 -1
  363. package/lib/commonjs/ui/hooks/useTransferQueries.js +0 -85
  364. package/lib/commonjs/ui/hooks/useTransferQueries.js.map +0 -1
  365. package/lib/commonjs/ui/stores/transferStore.js +0 -157
  366. package/lib/commonjs/ui/stores/transferStore.js.map +0 -1
  367. package/lib/module/adapters/expo/crypto.js +0 -51
  368. package/lib/module/adapters/expo/crypto.js.map +0 -1
  369. package/lib/module/adapters/expo/fetch.js +0 -26
  370. package/lib/module/adapters/expo/fetch.js.map +0 -1
  371. package/lib/module/adapters/expo/index.js +0 -45
  372. package/lib/module/adapters/expo/index.js.map +0 -1
  373. package/lib/module/adapters/expo/storage.js +0 -198
  374. package/lib/module/adapters/expo/storage.js.map +0 -1
  375. package/lib/module/adapters/index.js +0 -45
  376. package/lib/module/adapters/index.js.map +0 -1
  377. package/lib/module/adapters/node/crypto.js +0 -36
  378. package/lib/module/adapters/node/crypto.js.map +0 -1
  379. package/lib/module/adapters/node/fetch.js +0 -57
  380. package/lib/module/adapters/node/fetch.js.map +0 -1
  381. package/lib/module/adapters/node/index.js +0 -31
  382. package/lib/module/adapters/node/index.js.map +0 -1
  383. package/lib/module/adapters/node/storage.js +0 -159
  384. package/lib/module/adapters/node/storage.js.map +0 -1
  385. package/lib/module/core/identity-session/DeviceManager.js +0 -232
  386. package/lib/module/core/identity-session/DeviceManager.js.map +0 -1
  387. package/lib/module/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  388. package/lib/module/core/identity-session/IdentityManager.js +0 -395
  389. package/lib/module/core/identity-session/IdentityManager.js.map +0 -1
  390. package/lib/module/core/identity-session/IdentitySessionCore.js +0 -390
  391. package/lib/module/core/identity-session/IdentitySessionCore.js.map +0 -1
  392. package/lib/module/core/identity-session/RefreshManager.js +0 -132
  393. package/lib/module/core/identity-session/RefreshManager.js.map +0 -1
  394. package/lib/module/core/identity-session/SessionManager.js +0 -422
  395. package/lib/module/core/identity-session/SessionManager.js.map +0 -1
  396. package/lib/module/core/identity-session/createIdentitySessionCore.js +0 -21
  397. package/lib/module/core/identity-session/createIdentitySessionCore.js.map +0 -1
  398. package/lib/module/core/identity-session/errors.js +0 -170
  399. package/lib/module/core/identity-session/errors.js.map +0 -1
  400. package/lib/module/core/identity-session/index.js +0 -17
  401. package/lib/module/core/identity-session/index.js.map +0 -1
  402. package/lib/module/core/identity-session/types.js +0 -2
  403. package/lib/module/core/identity-session/types.js.map +0 -1
  404. package/lib/module/crypto/README.md +0 -142
  405. package/lib/module/crypto/core.js +0 -133
  406. package/lib/module/crypto/core.js.map +0 -1
  407. package/lib/module/node/signatureService.js +0 -101
  408. package/lib/module/node/signatureService.js.map +0 -1
  409. package/lib/module/ui/hooks/auth/index.js +0 -7
  410. package/lib/module/ui/hooks/auth/index.js.map +0 -1
  411. package/lib/module/ui/hooks/auth/useUsernameValidation.js +0 -167
  412. package/lib/module/ui/hooks/auth/useUsernameValidation.js.map +0 -1
  413. package/lib/module/ui/hooks/useAvatarPicker.js +0 -48
  414. package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
  415. package/lib/module/ui/hooks/useIdentityTransfer.js +0 -121
  416. package/lib/module/ui/hooks/useIdentityTransfer.js.map +0 -1
  417. package/lib/module/ui/hooks/useTransferCodesPersistence.js +0 -77
  418. package/lib/module/ui/hooks/useTransferCodesPersistence.js.map +0 -1
  419. package/lib/module/ui/hooks/useTransferQueries.js +0 -80
  420. package/lib/module/ui/hooks/useTransferQueries.js.map +0 -1
  421. package/lib/module/ui/stores/transferStore.js +0 -152
  422. package/lib/module/ui/stores/transferStore.js.map +0 -1
  423. package/lib/typescript/adapters/expo/crypto.d.ts +0 -17
  424. package/lib/typescript/adapters/expo/crypto.d.ts.map +0 -1
  425. package/lib/typescript/adapters/expo/fetch.d.ts +0 -16
  426. package/lib/typescript/adapters/expo/fetch.d.ts.map +0 -1
  427. package/lib/typescript/adapters/expo/index.d.ts +0 -23
  428. package/lib/typescript/adapters/expo/index.d.ts.map +0 -1
  429. package/lib/typescript/adapters/expo/storage.d.ts +0 -23
  430. package/lib/typescript/adapters/expo/storage.d.ts.map +0 -1
  431. package/lib/typescript/adapters/index.d.ts +0 -17
  432. package/lib/typescript/adapters/index.d.ts.map +0 -1
  433. package/lib/typescript/adapters/node/crypto.d.ts +0 -17
  434. package/lib/typescript/adapters/node/crypto.d.ts.map +0 -1
  435. package/lib/typescript/adapters/node/fetch.d.ts +0 -16
  436. package/lib/typescript/adapters/node/fetch.d.ts.map +0 -1
  437. package/lib/typescript/adapters/node/index.d.ts +0 -23
  438. package/lib/typescript/adapters/node/index.d.ts.map +0 -1
  439. package/lib/typescript/adapters/node/storage.d.ts +0 -23
  440. package/lib/typescript/adapters/node/storage.d.ts.map +0 -1
  441. package/lib/typescript/core/identity-session/DeviceManager.d.ts +0 -64
  442. package/lib/typescript/core/identity-session/DeviceManager.d.ts.map +0 -1
  443. package/lib/typescript/core/identity-session/IdentityManager.d.ts +0 -88
  444. package/lib/typescript/core/identity-session/IdentityManager.d.ts.map +0 -1
  445. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts +0 -141
  446. package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts.map +0 -1
  447. package/lib/typescript/core/identity-session/RefreshManager.d.ts +0 -36
  448. package/lib/typescript/core/identity-session/RefreshManager.d.ts.map +0 -1
  449. package/lib/typescript/core/identity-session/SessionManager.d.ts +0 -104
  450. package/lib/typescript/core/identity-session/SessionManager.d.ts.map +0 -1
  451. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts +0 -11
  452. package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts.map +0 -1
  453. package/lib/typescript/core/identity-session/errors.d.ts +0 -63
  454. package/lib/typescript/core/identity-session/errors.d.ts.map +0 -1
  455. package/lib/typescript/core/identity-session/index.d.ts +0 -14
  456. package/lib/typescript/core/identity-session/index.d.ts.map +0 -1
  457. package/lib/typescript/core/identity-session/types.d.ts +0 -196
  458. package/lib/typescript/core/identity-session/types.d.ts.map +0 -1
  459. package/lib/typescript/crypto/core.d.ts +0 -56
  460. package/lib/typescript/crypto/core.d.ts.map +0 -1
  461. package/lib/typescript/node/signatureService.d.ts +0 -55
  462. package/lib/typescript/node/signatureService.d.ts.map +0 -1
  463. package/lib/typescript/ui/hooks/auth/index.d.ts +0 -6
  464. package/lib/typescript/ui/hooks/auth/index.d.ts.map +0 -1
  465. package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts +0 -32
  466. package/lib/typescript/ui/hooks/auth/useUsernameValidation.d.ts.map +0 -1
  467. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -18
  468. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
  469. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts +0 -24
  470. package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts.map +0 -1
  471. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts +0 -6
  472. package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts.map +0 -1
  473. package/lib/typescript/ui/hooks/useTransferQueries.d.ts +0 -26
  474. package/lib/typescript/ui/hooks/useTransferQueries.d.ts.map +0 -1
  475. package/lib/typescript/ui/stores/transferStore.d.ts +0 -36
  476. package/lib/typescript/ui/stores/transferStore.d.ts.map +0 -1
  477. package/src/adapters/expo/crypto.ts +0 -55
  478. package/src/adapters/expo/fetch.ts +0 -28
  479. package/src/adapters/expo/index.ts +0 -51
  480. package/src/adapters/expo/storage.ts +0 -228
  481. package/src/adapters/index.ts +0 -48
  482. package/src/adapters/node/crypto.ts +0 -39
  483. package/src/adapters/node/fetch.ts +0 -59
  484. package/src/adapters/node/index.ts +0 -37
  485. package/src/adapters/node/storage.ts +0 -170
  486. package/src/core/identity-session/DeviceManager.ts +0 -273
  487. package/src/core/identity-session/INTEGRATION_GUIDE.md +0 -287
  488. package/src/core/identity-session/IdentityManager.ts +0 -474
  489. package/src/core/identity-session/IdentitySessionCore.ts +0 -464
  490. package/src/core/identity-session/RefreshManager.ts +0 -189
  491. package/src/core/identity-session/SessionManager.ts +0 -500
  492. package/src/core/identity-session/createIdentitySessionCore.ts +0 -19
  493. package/src/core/identity-session/errors.ts +0 -197
  494. package/src/core/identity-session/index.ts +0 -15
  495. package/src/core/identity-session/types.ts +0 -188
  496. package/src/crypto/README.md +0 -142
  497. package/src/crypto/__tests__/core.test.ts +0 -203
  498. package/src/crypto/core.ts +0 -142
  499. package/src/node/signatureService.ts +0 -126
  500. package/src/ui/hooks/auth/index.ts +0 -9
  501. package/src/ui/hooks/auth/useUsernameValidation.ts +0 -177
  502. package/src/ui/hooks/useAvatarPicker.ts +0 -62
  503. package/src/ui/hooks/useIdentityTransfer.ts +0 -135
  504. package/src/ui/hooks/useTransferCodesPersistence.ts +0 -80
  505. package/src/ui/hooks/useTransferQueries.ts +0 -102
  506. package/src/ui/stores/transferStore.ts +0 -201
@@ -22,7 +22,6 @@ import { MaterialCommunityIcons } from '@expo/vector-icons';
22
22
  import { toast } from '../../lib/sonner';
23
23
  import { fontFamilies } from '../styles/fonts';
24
24
  import { confirmAction } from '../utils/confirmAction';
25
- import { useAuthStore } from '../stores/authStore';
26
25
  import { Header, GroupedSection, Section } from '../components';
27
26
  import { useI18n } from '../hooks/useI18n';
28
27
  import { useThemeStyles } from '../hooks/useThemeStyles';
@@ -77,13 +76,9 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
77
76
  const normalizedTheme = normalizeTheme(theme);
78
77
 
79
78
  // Use TanStack Query for user data
80
- const { data: user, isLoading: userLoading } = useCurrentUser({ enabled: isAuthenticated });
79
+ const { data: finalUser, isLoading: userLoading } = useCurrentUser({ enabled: isAuthenticated });
81
80
  const updateProfileMutation = useUpdateProfile();
82
81
  const uploadAvatarMutation = useUploadAvatar();
83
-
84
- // Fallback to store for backward compatibility
85
- const userFromStore = useAuthStore((state) => state.user);
86
- const finalUser = user || userFromStore;
87
82
  const [isLoading, setIsLoading] = useState(false);
88
83
  const isSaving = updateProfileMutation.isPending;
89
84
  const isUpdatingAvatar = uploadAvatarMutation.isPending;
@@ -229,17 +224,17 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
229
224
  setUsername(finalUser.username || '');
230
225
  setEmail(finalUser.email || '');
231
226
  setBio(finalUser.bio || '');
232
- setLocation(typeof finalUser.location === 'string' ? finalUser.location : '');
227
+ setLocation(finalUser.location || '');
233
228
 
234
229
  // Handle locations - convert single location to array format
235
230
  if (finalUser.locations && Array.isArray(finalUser.locations)) {
236
- setLocations(finalUser.locations.map((loc, index) => ({
231
+ setLocations(finalUser.locations.map((loc: any, index: number) => ({
237
232
  id: loc.id || `existing-${index}`,
238
233
  name: loc.name,
239
234
  label: loc.label,
240
235
  coordinates: loc.coordinates
241
236
  })));
242
- } else if (finalUser.location && typeof finalUser.location === 'string') {
237
+ } else if (finalUser.location) {
243
238
  // Convert single location string to array format
244
239
  setLocations([{
245
240
  id: 'existing-0',
@@ -252,17 +247,17 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
252
247
 
253
248
  // Handle links - simple and direct like other fields
254
249
  if (finalUser.linksMetadata && Array.isArray(finalUser.linksMetadata)) {
255
- const urls = finalUser.linksMetadata.map(l => l.url);
250
+ const urls = finalUser.linksMetadata.map((l: any) => l.url);
256
251
  setLinks(urls);
257
- const metadataWithIds = finalUser.linksMetadata.map((link, index) => ({
252
+ const metadataWithIds = finalUser.linksMetadata.map((link: any, index: number) => ({
258
253
  ...link,
259
- id: (link as any).id || `existing-${index}`
254
+ id: link.id || `existing-${index}`
260
255
  }));
261
256
  setLinksMetadata(metadataWithIds);
262
257
  } else if (Array.isArray(finalUser.links)) {
263
- const simpleLinks = finalUser.links.map(l => typeof l === 'string' ? l : (l as any).link).filter(Boolean) as string[];
258
+ const simpleLinks = finalUser.links.map((l: any) => typeof l === 'string' ? l : l.link).filter(Boolean);
264
259
  setLinks(simpleLinks);
265
- const linksWithMetadata = simpleLinks.map((url, index) => ({
260
+ const linksWithMetadata = simpleLinks.map((url: string, index: number) => ({
266
261
  url,
267
262
  title: url.replace(/^https?:\/\//, '').replace(/\/$/, ''),
268
263
  description: `Link to ${url}`,
@@ -270,7 +265,7 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
270
265
  id: `existing-${index}`
271
266
  }));
272
267
  setLinksMetadata(linksWithMetadata);
273
- } else if (finalUser.website && typeof finalUser.website === 'string') {
268
+ } else if (finalUser.website) {
274
269
  setLinks([finalUser.website]);
275
270
  setLinksMetadata([{
276
271
  url: finalUser.website,
@@ -388,14 +383,7 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
388
383
  setLocations(tempLocations);
389
384
  break;
390
385
  case 'links':
391
- // Ensure all links have required fields
392
- const linksWithRequiredFields = tempLinksWithMetadata.map(link => ({
393
- url: link.url,
394
- title: link.title || link.url.replace(/^https?:\/\//, '').replace(/\/$/, ''),
395
- description: link.description || `Link to ${link.url}`,
396
- image: link.image,
397
- }));
398
- await updateProfileMutation.mutateAsync({ linksMetadata: linksWithRequiredFields });
386
+ await updateProfileMutation.mutateAsync({ linksMetadata: tempLinksWithMetadata });
399
387
  setLinksMetadata(tempLinksWithMetadata);
400
388
  setLinks(tempLinksWithMetadata.map(l => l.url));
401
389
  break;
@@ -521,54 +509,48 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
521
509
  const handleOpenLinksModal = useCallback(() => setShowEditLinksModal(true), []);
522
510
 
523
511
  // Handler to refresh data after modal saves
524
- // Note: Access user directly from store when invoked to get latest value,
525
- // not from closure which may be stale after modal saves update the backend
512
+ // Note: Query will automatically refetch after mutations invalidate it
526
513
  const handleModalSave = useCallback(() => {
527
- // Get fresh user data from store to ensure we have the latest values
528
- // after the modal's save operation updates the backend
529
- // Read from store directly (not from closure) to avoid stale data
530
- const currentUser = useAuthStore.getState().user;
531
-
532
514
  // Reload user data to reflect changes
533
- if (currentUser) {
534
- const userDisplayName = typeof currentUser.name === 'string'
535
- ? currentUser.name
536
- : currentUser.name?.first || currentUser.name?.full || '';
537
- const userLastName = typeof currentUser.name === 'object' ? currentUser.name?.last || '' : '';
515
+ if (finalUser) {
516
+ const userDisplayName = typeof finalUser.name === 'string'
517
+ ? finalUser.name
518
+ : finalUser.name?.first || finalUser.name?.full || '';
519
+ const userLastName = typeof finalUser.name === 'object' ? finalUser.name?.last || '' : '';
538
520
  setDisplayName(userDisplayName);
539
521
  setLastName(userLastName);
540
- setUsername(currentUser.username || '');
541
- setEmail(currentUser.email || '');
542
- setBio(currentUser.bio || '');
522
+ setUsername(finalUser.username || '');
523
+ setEmail(finalUser.email || '');
524
+ setBio(finalUser.bio || '');
543
525
 
544
526
  // Reload locations and links
545
- if (currentUser.locations && Array.isArray(currentUser.locations)) {
546
- setLocations(currentUser.locations.map((loc, index) => ({
527
+ if (finalUser.locations && Array.isArray(finalUser.locations)) {
528
+ setLocations(finalUser.locations.map((loc: any, index: number) => ({
547
529
  id: loc.id || `existing-${index}`,
548
530
  name: loc.name,
549
531
  label: loc.label,
550
532
  coordinates: loc.coordinates
551
533
  })));
552
- } else if (currentUser.location && typeof currentUser.location === 'string') {
534
+ } else if (finalUser.location) {
553
535
  setLocations([{
554
536
  id: 'existing-0',
555
- name: currentUser.location,
537
+ name: finalUser.location,
556
538
  label: 'Location'
557
539
  }]);
558
540
  } else {
559
541
  setLocations([]);
560
542
  }
561
543
 
562
- if (currentUser.linksMetadata && Array.isArray(currentUser.linksMetadata)) {
563
- setLinksMetadata(currentUser.linksMetadata.map((link, index) => ({
544
+ if (finalUser.linksMetadata && Array.isArray(finalUser.linksMetadata)) {
545
+ setLinksMetadata(finalUser.linksMetadata.map((link: any, index: number) => ({
564
546
  ...link,
565
- id: (link as any).id || `existing-${index}`
547
+ id: link.id || `existing-${index}`
566
548
  })));
567
549
  } else {
568
550
  setLinksMetadata([]);
569
551
  }
570
552
  }
571
- }, []); // Empty dependency array - callback reads fresh data from store at call time
553
+ }, [finalUser]); // Query will automatically refetch after mutations
572
554
 
573
555
  // Handle initialField prop - open appropriate modal
574
556
  useEffect(() => {
@@ -836,7 +818,7 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
836
818
  {/* Search results */}
837
819
  {locationSearchResults.length > 0 && (
838
820
  <View style={styles.searchResults}>
839
- {locationSearchResults.map((result) => (
821
+ {locationSearchResults.map((result: any) => (
840
822
  <TouchableOpacity
841
823
  key={result.place_id}
842
824
  style={styles.searchResultItem}
@@ -867,7 +849,7 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
867
849
  {tempLocations.length > 0 && (
868
850
  <View style={styles.locationsList}>
869
851
  <Text style={styles.locationsListTitle}>Your Locations ({tempLocations.length})</Text>
870
- {tempLocations.map((location, index) => (
852
+ {tempLocations.map((location: any, index: number) => (
871
853
  <View key={location.id} style={styles.locationItem}>
872
854
  <View style={styles.locationItemContent}>
873
855
  <View style={styles.locationItemDragHandle}>
@@ -995,7 +977,7 @@ const AccountSettingsScreen: React.FC<BaseScreenProps & { initialField?: string;
995
977
  onPress: () => setIsAddingLink(true),
996
978
  }]),
997
979
  // Existing links
998
- ...tempLinksWithMetadata.map((link, index) => ({
980
+ ...tempLinksWithMetadata.map((link: any, index: number) => ({
999
981
  id: link.id,
1000
982
  customIcon: link.image ? (
1001
983
  <Image source={{ uri: link.image }} style={{ width: 36, height: 36, borderRadius: 18 }} />
@@ -405,7 +405,7 @@ const ModernAccountSwitcherScreen: React.FC<BaseScreenProps> = ({
405
405
  ) : (
406
406
  <View style={styles.accountAvatarFallback}>
407
407
  <Text style={styles.accountAvatarText}>
408
- {displayName?.charAt(0).toUpperCase() || '?'}
408
+ {displayName.charAt(0).toUpperCase()}
409
409
  </Text>
410
410
  </View>
411
411
  )}
@@ -432,7 +432,7 @@ const ModernAccountSwitcherScreen: React.FC<BaseScreenProps> = ({
432
432
  </TouchableOpacity>
433
433
  <TouchableOpacity
434
434
  style={styles.removeButton}
435
- onPress={() => handleRemoveSession(sessionWithUser.sessionId, displayName || 'this account')}
435
+ onPress={() => handleRemoveSession(sessionWithUser.sessionId, displayName)}
436
436
  disabled={isSwitching || isRemoving}
437
437
  >
438
438
  {isRemoving ? (
@@ -460,7 +460,7 @@ const ModernAccountSwitcherScreen: React.FC<BaseScreenProps> = ({
460
460
  iconColor: '#007AFF',
461
461
  title: 'Add Another Account',
462
462
  subtitle: 'Sign in with a different account',
463
- onPress: () => navigate?.('SignIn'),
463
+ onPress: () => navigate?.('OxyAuth'),
464
464
  },
465
465
  {
466
466
  id: 'device-management',
@@ -561,7 +561,7 @@ const ModernAccountSwitcherScreen: React.FC<BaseScreenProps> = ({
561
561
  iconColor: '#ccc',
562
562
  title: t('accountSwitcher.empty.title') || 'No saved accounts',
563
563
  subtitle: t('accountSwitcher.empty.subtitle') || 'Add another account to switch between them quickly',
564
- onPress: () => navigate?.('SignIn'),
564
+ onPress: () => navigate?.('OxyAuth'),
565
565
  customContent: (
566
566
  <View style={styles.emptyStateContainer}>
567
567
  <OxyIcon name="person-outline" size={48} color="#ccc" />
@@ -571,7 +571,7 @@ const ModernAccountSwitcherScreen: React.FC<BaseScreenProps> = ({
571
571
  </Text>
572
572
  <TouchableOpacity
573
573
  style={styles.addAccountButton}
574
- onPress={() => navigate?.('SignIn')}
574
+ onPress={() => navigate?.('OxyAuth')}
575
575
  >
576
576
  <Text style={styles.addAccountButtonText}>{t('accountCenter.sections.addAccount') || 'Add Account'}</Text>
577
577
  </TouchableOpacity>
@@ -72,6 +72,22 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
72
72
  const pollingIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
73
73
  const isProcessingRef = useRef(false);
74
74
 
75
+ const resolveDeviceIdForSession = useCallback(
76
+ async (sessionId: string): Promise<string | undefined> => {
77
+ try {
78
+ const deviceSessions = await oxyServices.getDeviceSessions(sessionId);
79
+ const matchingSession = deviceSessions?.find((session) => session.sessionId === sessionId);
80
+ return matchingSession?.deviceId || undefined;
81
+ } catch (err) {
82
+ if (__DEV__) {
83
+ console.log('Failed to resolve deviceId for session', err);
84
+ }
85
+ return undefined;
86
+ }
87
+ },
88
+ [oxyServices],
89
+ );
90
+
75
91
  // Handle successful authorization
76
92
  const handleAuthSuccess = useCallback(async (sessionId: string) => {
77
93
  if (isProcessingRef.current) return;
@@ -86,7 +102,8 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
86
102
  }
87
103
  } else {
88
104
  // Fallback if switchSession not available (shouldn't happen, but for safety)
89
- await oxyServices.getTokenBySession(sessionId);
105
+ const deviceId = await resolveDeviceIdForSession(sessionId);
106
+ await oxyServices.getTokenBySession(sessionId, deviceId);
90
107
  const user = await oxyServices.getUserBySession(sessionId);
91
108
  if (onAuthenticated) {
92
109
  onAuthenticated(user);
@@ -99,7 +116,7 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
99
116
  setError('Authorization successful but failed to complete sign in. Please try again.');
100
117
  isProcessingRef.current = false;
101
118
  }
102
- }, [oxyServices, switchSession, onAuthenticated]);
119
+ }, [oxyServices, resolveDeviceIdForSession, switchSession, onAuthenticated]);
103
120
 
104
121
  // Connect to socket for real-time updates
105
122
  const connectSocket = useCallback((sessionToken: string) => {
@@ -523,5 +540,3 @@ const styles = StyleSheet.create({
523
540
  });
524
541
 
525
542
  export default OxyAuthScreen;
526
-
527
-
@@ -1,9 +1,10 @@
1
- import React, { useState, useCallback, useMemo } from 'react';
1
+ import React, { useState, useCallback, useEffect, useMemo } from 'react';
2
2
  import {
3
3
  View,
4
4
  Text,
5
5
  StyleSheet,
6
6
  ScrollView,
7
+ ActivityIndicator,
7
8
  TouchableOpacity,
8
9
  } from 'react-native';
9
10
  import type { BaseScreenProps } from '../types/navigation';
@@ -14,8 +15,6 @@ import { useThemeStyles } from '../hooks/useThemeStyles';
14
15
  import { normalizeTheme } from '../utils/themeUtils';
15
16
  import type { BlockedUser, RestrictedUser } from '../../models/interfaces';
16
17
  import { useOxy } from '../context/OxyContext';
17
- import { usePrivacySettings, useBlockedUsers, useRestrictedUsers } from '../hooks/queries';
18
- import { useUpdatePrivacySettings, useUnblockUser, useUnrestrictUser } from '../hooks/mutations';
19
18
 
20
19
  interface PrivacySettings {
21
20
  isPrivateAccount: boolean;
@@ -45,20 +44,8 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
45
44
  goBack,
46
45
  }) => {
47
46
  // Use useOxy() hook for OxyContext values
48
- const { oxyServices } = useOxy();
47
+ const { oxyServices, user } = useOxy();
49
48
  const { t } = useI18n();
50
-
51
- // TanStack Query hooks for server state
52
- const { data: privacySettingsData, isLoading: isLoadingSettings, error: settingsError } = usePrivacySettings();
53
- const { data: blockedUsers = [], isLoading: isLoadingBlocked } = useBlockedUsers();
54
- const { data: restrictedUsers = [], isLoading: isLoadingRestricted } = useRestrictedUsers();
55
-
56
- // Mutations
57
- const updatePrivacySettingsMutation = useUpdatePrivacySettings();
58
- const unblockUserMutation = useUnblockUser();
59
- const unrestrictUserMutation = useUnrestrictUser();
60
-
61
- // Client state for optimistic UI updates
62
49
  const [settings, setSettings] = useState<PrivacySettings>({
63
50
  isPrivateAccount: false,
64
51
  hideOnlineStatus: false,
@@ -80,64 +67,111 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
80
67
  autoFilter: true,
81
68
  muteKeywords: false,
82
69
  });
83
-
84
- // Update local state when server data changes
85
- React.useEffect(() => {
86
- if (privacySettingsData) {
87
- setSettings(privacySettingsData as PrivacySettings);
88
- }
89
- }, [privacySettingsData]);
90
-
91
- // Show error toast if settings failed to load
92
- React.useEffect(() => {
93
- if (settingsError) {
94
- toast.error(t('privacySettings.loadError') || 'Failed to load privacy settings');
95
- }
96
- }, [settingsError, t]);
97
-
98
- const isLoading = isLoadingSettings;
99
- const isSaving = updatePrivacySettingsMutation.isPending;
100
- const isLoadingUsers = isLoadingBlocked || isLoadingRestricted;
70
+ const [isLoading, setIsLoading] = useState(true);
71
+ const [isSaving, setIsSaving] = useState(false);
72
+ const [blockedUsers, setBlockedUsers] = useState<BlockedUser[]>([]);
73
+ const [restrictedUsers, setRestrictedUsers] = useState<RestrictedUser[]>([]);
74
+ const [isLoadingUsers, setIsLoadingUsers] = useState(false);
75
+
76
+ // Load settings and users
77
+ useEffect(() => {
78
+ const loadSettings = async () => {
79
+ try {
80
+ setIsLoading(true);
81
+ // Use getCurrentUserId() which returns MongoDB ObjectId from JWT token
82
+ // Never use user?.id as it may be set to publicKey
83
+ const userId = oxyServices?.getCurrentUserId();
84
+ if (userId && oxyServices) {
85
+ const privacySettings = await oxyServices.getPrivacySettings(userId);
86
+ if (privacySettings) {
87
+ setSettings(privacySettings);
88
+ }
89
+ }
90
+ } catch (error) {
91
+ console.error('Failed to load privacy settings:', error);
92
+ toast.error(t('privacySettings.loadError') || 'Failed to load privacy settings');
93
+ } finally {
94
+ setIsLoading(false);
95
+ }
96
+ };
97
+
98
+ loadSettings();
99
+ }, [oxyServices, t]);
100
+
101
+ // Load blocked and restricted users
102
+ useEffect(() => {
103
+ const loadUsers = async () => {
104
+ if (!oxyServices) return;
105
+ try {
106
+ setIsLoadingUsers(true);
107
+ const [blocked, restricted] = await Promise.all([
108
+ oxyServices.getBlockedUsers(),
109
+ oxyServices.getRestrictedUsers(),
110
+ ]);
111
+ setBlockedUsers(blocked);
112
+ setRestrictedUsers(restricted);
113
+ } catch (error) {
114
+ console.error('Failed to load blocked/restricted users:', error);
115
+ } finally {
116
+ setIsLoadingUsers(false);
117
+ }
118
+ };
119
+
120
+ loadUsers();
121
+ }, [oxyServices]);
101
122
 
102
123
  const updateSetting = useCallback(async (key: keyof PrivacySettings, value: boolean) => {
103
- // Optimistic update
104
- const newSettings = { ...settings, [key]: value };
105
- setSettings(newSettings);
106
-
107
- // Use mutation hook
108
- updatePrivacySettingsMutation.mutate(
109
- { settings: { [key]: value } },
110
- {
111
- onError: () => {
112
- // Revert on error
113
- setSettings(settings);
114
- toast.error(t('privacySettings.updateError') || 'Failed to update privacy setting');
115
- },
124
+ try {
125
+ setIsSaving(true);
126
+ const newSettings = { ...settings, [key]: value };
127
+ setSettings(newSettings);
128
+
129
+ // Use getCurrentUserId() which returns MongoDB ObjectId from JWT token
130
+ // Never use user?.id as it may be set to publicKey
131
+ const userId = oxyServices?.getCurrentUserId();
132
+ if (userId && oxyServices) {
133
+ await oxyServices.updatePrivacySettings({ [key]: value }, userId);
134
+ toast.success(t('privacySettings.updated') || 'Privacy settings updated');
116
135
  }
117
- );
118
- }, [settings, updatePrivacySettingsMutation, t]);
136
+ } catch (error) {
137
+ console.error(`Failed to update ${key}:`, error);
138
+ toast.error(t('privacySettings.updateError') || 'Failed to update privacy setting');
139
+ // Revert on error
140
+ setSettings(settings);
141
+ } finally {
142
+ setIsSaving(false);
143
+ }
144
+ }, [settings, oxyServices, t]);
119
145
 
120
146
  const handleUnblock = useCallback(async (userId: string) => {
121
- unblockUserMutation.mutate(userId, {
122
- onSuccess: () => {
123
- toast.success(t('privacySettings.userUnblocked') || 'User unblocked');
124
- },
125
- onError: () => {
126
- toast.error(t('privacySettings.unblockError') || 'Failed to unblock user');
127
- },
128
- });
129
- }, [unblockUserMutation, t]);
147
+ if (!oxyServices) return;
148
+ try {
149
+ await oxyServices.unblockUser(userId);
150
+ setBlockedUsers(prev => prev.filter(u => {
151
+ const id = typeof u.blockedId === 'string' ? u.blockedId : u.blockedId._id;
152
+ return id !== userId;
153
+ }));
154
+ toast.success(t('privacySettings.userUnblocked') || 'User unblocked');
155
+ } catch (error) {
156
+ console.error('Failed to unblock user:', error);
157
+ toast.error(t('privacySettings.unblockError') || 'Failed to unblock user');
158
+ }
159
+ }, [oxyServices, t]);
130
160
 
131
161
  const handleUnrestrict = useCallback(async (userId: string) => {
132
- unrestrictUserMutation.mutate(userId, {
133
- onSuccess: () => {
134
- toast.success(t('privacySettings.userUnrestricted') || 'User unrestricted');
135
- },
136
- onError: () => {
137
- toast.error(t('privacySettings.unrestrictError') || 'Failed to unrestrict user');
138
- },
139
- });
140
- }, [unrestrictUserMutation, t]);
162
+ if (!oxyServices) return;
163
+ try {
164
+ await oxyServices.unrestrictUser(userId);
165
+ setRestrictedUsers(prev => prev.filter(u => {
166
+ const id = typeof u.restrictedId === 'string' ? u.restrictedId : u.restrictedId._id;
167
+ return id !== userId;
168
+ }));
169
+ toast.success(t('privacySettings.userUnrestricted') || 'User unrestricted');
170
+ } catch (error) {
171
+ console.error('Failed to unrestrict user:', error);
172
+ toast.error(t('privacySettings.unrestrictError') || 'Failed to unrestrict user');
173
+ }
174
+ }, [oxyServices, t]);
141
175
 
142
176
  // Helper to extract user info from blocked/restricted objects
143
177
  const extractUserInfo = useCallback((
@@ -121,7 +121,7 @@ const ProfileScreen: React.FC<ProfileScreenProps> = ({ userId, username, theme,
121
121
  id: `existing-${index}`
122
122
  }));
123
123
  setLinks(linksWithMetadata);
124
- } else if (profileRes.website && typeof profileRes.website === 'string') {
124
+ } else if (profileRes.website) {
125
125
  setLinks([{
126
126
  url: profileRes.website,
127
127
  title: profileRes.website.replace(/^https?:\/\//, '').replace(/\/$/, ''),
@@ -252,32 +252,32 @@ const ProfileScreen: React.FC<ProfileScreenProps> = ({ userId, username, theme,
252
252
 
253
253
  {/* Info Grid Row */}
254
254
  <View style={styles.infoGrid}>
255
- {profile?.createdAt ? (
255
+ {profile?.createdAt && (
256
256
  <View style={styles.infoGridItem}>
257
257
  <Ionicons name="calendar-outline" size={16} color={colors.secondaryText} style={{ marginRight: 6 }} />
258
258
  <Text style={[styles.infoGridText, { color: colors.secondaryText }]}>
259
259
  {t('profile.joinedOn', { date: new Date(profile.createdAt).toLocaleDateString() }) || `Joined ${new Date(profile.createdAt).toLocaleDateString()}`}
260
260
  </Text>
261
261
  </View>
262
- ) : null}
263
- {profile?.location && typeof profile.location === 'string' ? (
262
+ )}
263
+ {profile?.location && (
264
264
  <View style={styles.infoGridItem}>
265
265
  <Ionicons name="location-outline" size={16} color={colors.secondaryText} style={{ marginRight: 6 }} />
266
266
  <Text style={[styles.infoGridText, { color: colors.secondaryText }]} numberOfLines={1}>{profile.location}</Text>
267
267
  </View>
268
- ) : null}
269
- {profile?.website && typeof profile.website === 'string' ? (
268
+ )}
269
+ {profile?.website && (
270
270
  <View style={styles.infoGridItem}>
271
271
  <Ionicons name="globe-outline" size={16} color={colors.secondaryText} style={{ marginRight: 6 }} />
272
272
  <Text style={[styles.infoGridText, { color: colors.secondaryText }]} numberOfLines={1}>{profile.website}</Text>
273
273
  </View>
274
- ) : null}
275
- {profile && 'company' in profile && typeof profile.company === 'string' && profile.company ? (
274
+ )}
275
+ {profile && 'company' in profile && typeof profile.company === 'string' && profile.company && (
276
276
  <View style={styles.infoGridItem}>
277
277
  <Ionicons name="business-outline" size={16} color={colors.secondaryText} style={{ marginRight: 6 }} />
278
- <Text style={[styles.infoGridText, { color: colors.secondaryText }]} numberOfLines={1}>{profile.company as string}</Text>
278
+ <Text style={[styles.infoGridText, { color: colors.secondaryText }]} numberOfLines={1}>{profile.company}</Text>
279
279
  </View>
280
- ) : null}
280
+ )}
281
281
  {profile && 'jobTitle' in profile && typeof profile.jobTitle === 'string' && profile.jobTitle && (
282
282
  <View style={styles.infoGridItem}>
283
283
  <Ionicons name="briefcase-outline" size={16} color={colors.secondaryText} style={{ marginRight: 6 }} />
@@ -1,84 +1,44 @@
1
1
  import { create } from 'zustand';
2
- import type { User } from '../../models/interfaces';
3
2
 
4
3
  export interface AuthState {
5
- user: User | null;
6
4
  isAuthenticated: boolean;
7
5
  isLoading: boolean;
8
6
  error: string | null;
9
- lastUserFetch: number | null; // Timestamp of last user fetch for caching
10
7
 
11
8
  // Identity sync state (offline-first)
12
9
  isIdentitySynced: boolean;
13
10
  isSyncing: boolean;
14
11
 
15
- loginSuccess: (user: User) => void;
12
+ loginSuccess: () => void;
16
13
  loginFailure: (error: string) => void;
17
14
  logout: () => void;
18
- fetchUser: (oxyServices: { getCurrentUser: () => Promise<User> }, forceRefresh?: boolean) => Promise<void>;
19
- setUser: (user: User) => void; // Direct user setter for caching
20
15
 
21
16
  // Identity sync actions
22
17
  setIdentitySynced: (synced: boolean) => void;
23
18
  setSyncing: (syncing: boolean) => void;
24
19
  }
25
20
 
26
- export const useAuthStore = create<AuthState>((set: (state: Partial<AuthState>) => void, get: () => AuthState) => ({
27
- user: null,
21
+ export const useAuthStore = create<AuthState>((set: (state: Partial<AuthState>) => void) => ({
28
22
  isAuthenticated: false,
29
23
  isLoading: false,
30
24
  error: null,
31
- lastUserFetch: null,
32
25
 
33
26
  // Identity sync state (offline-first)
34
- isIdentitySynced: true, // Assume synced until proven otherwise
27
+ isIdentitySynced: false, // Registration/identity sync not confirmed until done
35
28
  isSyncing: false,
36
29
 
37
- loginSuccess: (user: User) => set({
30
+ loginSuccess: () => set({
38
31
  isLoading: false,
39
- isAuthenticated: true,
40
- user,
41
- lastUserFetch: Date.now(),
42
- isIdentitySynced: true, // If login succeeded, identity is synced
32
+ isAuthenticated: true,
33
+ isIdentitySynced: true, // If login succeeded, registration is complete
43
34
  }),
44
35
  loginFailure: (error: string) => set({ isLoading: false, error }),
45
36
  logout: () => set({
46
- user: null,
47
- isAuthenticated: false,
48
- lastUserFetch: null,
49
- // Reset identity sync state when logging out (for accounts app, identity = account)
50
- isIdentitySynced: false,
37
+ isAuthenticated: false,
51
38
  isSyncing: false,
52
39
  }),
53
- setUser: (user: User) => set({ user, lastUserFetch: Date.now() }),
54
40
 
55
41
  // Identity sync actions
56
42
  setIdentitySynced: (synced: boolean) => set({ isIdentitySynced: synced }),
57
43
  setSyncing: (syncing: boolean) => set({ isSyncing: syncing }),
58
- fetchUser: async (oxyServices, forceRefresh = false) => {
59
- const state = get();
60
- const now = Date.now();
61
- const cacheAge = state.lastUserFetch ? now - state.lastUserFetch : Number.POSITIVE_INFINITY;
62
- const cacheValid = cacheAge < 5 * 60 * 1000; // 5 minutes cache
63
-
64
- // Use cached data if available and not forcing refresh
65
- if (!forceRefresh && state.user && cacheValid) {
66
- if (__DEV__) {
67
- console.log('AuthStore: Using cached user data (age:', cacheAge, 'ms)');
68
- }
69
- return;
70
- }
71
-
72
- set({ isLoading: true, error: null });
73
- try {
74
- const user = await oxyServices.getCurrentUser();
75
- set({ user, isLoading: false, isAuthenticated: true, lastUserFetch: now });
76
- } catch (error) {
77
- const errorMessage = error instanceof Error ? error.message : 'Failed to fetch user';
78
- if (__DEV__) {
79
- console.error('AuthStore: Error fetching user:', error);
80
- }
81
- set({ error: errorMessage, isLoading: false });
82
- }
83
- },
84
- }));
44
+ }));