@oxyhq/services 5.17.17 → 5.17.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/README.md +32 -38
  2. package/lib/commonjs/core/CrossDomainAuth.js +277 -0
  3. package/lib/commonjs/core/CrossDomainAuth.js.map +1 -0
  4. package/lib/commonjs/core/HttpService.js +82 -15
  5. package/lib/commonjs/core/HttpService.js.map +1 -1
  6. package/lib/commonjs/core/OxyServices.base.js +11 -3
  7. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  8. package/lib/commonjs/core/OxyServices.js +4 -1
  9. package/lib/commonjs/core/OxyServices.js.map +1 -1
  10. package/lib/commonjs/core/index.js +30 -0
  11. package/lib/commonjs/core/index.js.map +1 -1
  12. package/lib/commonjs/core/mixins/OxyServices.assets.js +16 -3
  13. package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
  14. package/lib/commonjs/core/mixins/OxyServices.auth.js +73 -32
  15. package/lib/commonjs/core/mixins/OxyServices.auth.js.map +1 -1
  16. package/lib/commonjs/core/mixins/OxyServices.fedcm.js +289 -0
  17. package/lib/commonjs/core/mixins/OxyServices.fedcm.js.map +1 -0
  18. package/lib/commonjs/core/mixins/OxyServices.popup.js +352 -0
  19. package/lib/commonjs/core/mixins/OxyServices.popup.js.map +1 -0
  20. package/lib/commonjs/core/mixins/OxyServices.redirect.js +378 -0
  21. package/lib/commonjs/core/mixins/OxyServices.redirect.js.map +1 -0
  22. package/lib/commonjs/core/mixins/OxyServices.user.js +35 -24
  23. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  24. package/lib/commonjs/core/mixins/index.js +27 -15
  25. package/lib/commonjs/core/mixins/index.js.map +1 -1
  26. package/lib/commonjs/crypto/index.js +30 -0
  27. package/lib/commonjs/crypto/index.js.map +1 -1
  28. package/lib/commonjs/crypto/keyManager.js +902 -0
  29. package/lib/commonjs/crypto/keyManager.js.map +1 -0
  30. package/lib/commonjs/crypto/polyfill.js +14 -5
  31. package/lib/commonjs/crypto/polyfill.js.map +1 -1
  32. package/lib/commonjs/crypto/recoveryPhrase.js +152 -0
  33. package/lib/commonjs/crypto/recoveryPhrase.js.map +1 -0
  34. package/lib/commonjs/crypto/signatureService.js +289 -0
  35. package/lib/commonjs/crypto/signatureService.js.map +1 -0
  36. package/lib/commonjs/i18n/locales/en-US.json +1 -1
  37. package/lib/commonjs/index.js +40 -26
  38. package/lib/commonjs/index.js.map +1 -1
  39. package/lib/commonjs/models/interfaces.js +0 -15
  40. package/lib/commonjs/models/interfaces.js.map +1 -1
  41. package/lib/commonjs/ui/components/BottomSheetRouter.js +9 -1
  42. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  43. package/lib/commonjs/ui/components/Icon.js.map +1 -1
  44. package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
  45. package/lib/commonjs/ui/components/OxyProvider.js +41 -11
  46. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  47. package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
  48. package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
  49. package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
  50. package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
  51. package/lib/commonjs/ui/context/OxyContext.js +110 -199
  52. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  53. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +150 -19
  54. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  55. package/lib/commonjs/ui/context/hooks/useSessionManagement.js +279 -0
  56. package/lib/commonjs/ui/context/hooks/useSessionManagement.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +79 -72
  58. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  59. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +38 -51
  60. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  61. package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js +3 -3
  62. package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js.map +1 -1
  63. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +18 -12
  64. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  65. package/lib/commonjs/ui/hooks/useProfileEditing.js +3 -5
  66. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  67. package/lib/commonjs/ui/hooks/useSessionManagement.js +4 -8
  68. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  69. package/lib/commonjs/ui/hooks/useSessionSocket.js +162 -315
  70. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  71. package/lib/commonjs/ui/hooks/useStorage.js +24 -58
  72. package/lib/commonjs/ui/hooks/useStorage.js.map +1 -1
  73. package/lib/commonjs/ui/index.js +50 -21
  74. package/lib/commonjs/ui/index.js.map +1 -1
  75. package/lib/commonjs/ui/navigation/routes.js +5 -1
  76. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  77. package/lib/commonjs/ui/screens/AccountCenterScreen.js +2 -2
  78. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  79. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  80. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +29 -24
  81. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  82. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +3 -3
  83. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  84. package/lib/commonjs/ui/screens/OxyAuthScreen.js +134 -66
  85. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  86. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +6 -13
  87. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  88. package/lib/commonjs/ui/stores/accountStore.js +2 -4
  89. package/lib/commonjs/ui/stores/accountStore.js.map +1 -1
  90. package/lib/commonjs/ui/stores/authStore.js +45 -32
  91. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  92. package/lib/commonjs/ui/styles/spacing.js +54 -2
  93. package/lib/commonjs/ui/styles/spacing.js.map +1 -1
  94. package/lib/commonjs/ui/utils/avatarUtils.js +37 -41
  95. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  96. package/lib/commonjs/ui/utils/storageHelpers.js.map +1 -1
  97. package/lib/commonjs/utils/errorUtils.js +13 -0
  98. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  99. package/lib/commonjs/utils/validationUtils.js +15 -1
  100. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  101. package/lib/module/core/CrossDomainAuth.js +271 -0
  102. package/lib/module/core/CrossDomainAuth.js.map +1 -0
  103. package/lib/module/core/HttpService.js +82 -15
  104. package/lib/module/core/HttpService.js.map +1 -1
  105. package/lib/module/core/OxyServices.base.js +11 -4
  106. package/lib/module/core/OxyServices.base.js.map +1 -1
  107. package/lib/module/core/OxyServices.js +4 -1
  108. package/lib/module/core/OxyServices.js.map +1 -1
  109. package/lib/module/core/index.js +6 -1
  110. package/lib/module/core/index.js.map +1 -1
  111. package/lib/module/core/mixins/OxyServices.assets.js +16 -3
  112. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
  113. package/lib/module/core/mixins/OxyServices.auth.js +73 -32
  114. package/lib/module/core/mixins/OxyServices.auth.js.map +1 -1
  115. package/lib/module/core/mixins/OxyServices.fedcm.js +286 -0
  116. package/lib/module/core/mixins/OxyServices.fedcm.js.map +1 -0
  117. package/lib/module/core/mixins/OxyServices.popup.js +349 -0
  118. package/lib/module/core/mixins/OxyServices.popup.js.map +1 -0
  119. package/lib/module/core/mixins/OxyServices.redirect.js +375 -0
  120. package/lib/module/core/mixins/OxyServices.redirect.js.map +1 -0
  121. package/lib/module/core/mixins/OxyServices.user.js +35 -24
  122. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  123. package/lib/module/core/mixins/index.js +15 -3
  124. package/lib/module/core/mixins/index.js.map +1 -1
  125. package/lib/module/crypto/index.js +8 -4
  126. package/lib/module/crypto/index.js.map +1 -1
  127. package/lib/module/crypto/keyManager.js +899 -0
  128. package/lib/module/crypto/keyManager.js.map +1 -0
  129. package/lib/module/crypto/polyfill.js +6 -5
  130. package/lib/module/crypto/polyfill.js.map +1 -1
  131. package/lib/module/crypto/recoveryPhrase.js +147 -0
  132. package/lib/module/crypto/recoveryPhrase.js.map +1 -0
  133. package/lib/module/crypto/signatureService.js +286 -0
  134. package/lib/module/crypto/signatureService.js.map +1 -0
  135. package/lib/module/i18n/locales/en-US.json +1 -1
  136. package/lib/module/index.js +6 -9
  137. package/lib/module/index.js.map +1 -1
  138. package/lib/module/models/interfaces.js +0 -15
  139. package/lib/module/models/interfaces.js.map +1 -1
  140. package/lib/module/ui/components/BottomSheetRouter.js +6 -2
  141. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  142. package/lib/module/ui/components/Icon.js.map +1 -1
  143. package/lib/module/ui/components/IconButton/utils.js.map +1 -1
  144. package/lib/module/ui/components/OxyProvider.js +41 -11
  145. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  146. package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
  147. package/lib/module/ui/components/TextField/helpers.js.map +1 -1
  148. package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
  149. package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
  150. package/lib/module/ui/context/OxyContext.js +112 -191
  151. package/lib/module/ui/context/OxyContext.js.map +1 -1
  152. package/lib/module/ui/context/hooks/useAuthOperations.js +150 -19
  153. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  154. package/lib/module/ui/context/hooks/useSessionManagement.js +274 -0
  155. package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -0
  156. package/lib/module/ui/hooks/mutations/useAccountMutations.js +80 -72
  157. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  158. package/lib/module/ui/hooks/queries/useAccountQueries.js +31 -44
  159. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  160. package/lib/module/ui/hooks/queries/useSecurityQueries.js +1 -1
  161. package/lib/module/ui/hooks/queries/useSecurityQueries.js.map +1 -1
  162. package/lib/module/ui/hooks/queries/useServicesQueries.js +13 -7
  163. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  164. package/lib/module/ui/hooks/useProfileEditing.js +3 -5
  165. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  166. package/lib/module/ui/hooks/useSessionManagement.js +4 -8
  167. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  168. package/lib/module/ui/hooks/useSessionSocket.js +162 -315
  169. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  170. package/lib/module/ui/hooks/useStorage.js +25 -59
  171. package/lib/module/ui/hooks/useStorage.js.map +1 -1
  172. package/lib/module/ui/index.js +15 -10
  173. package/lib/module/ui/index.js.map +1 -1
  174. package/lib/module/ui/navigation/routes.js +5 -1
  175. package/lib/module/ui/navigation/routes.js.map +1 -1
  176. package/lib/module/ui/screens/AccountCenterScreen.js +2 -2
  177. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  178. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  179. package/lib/module/ui/screens/AccountSettingsScreen.js +29 -24
  180. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  181. package/lib/module/ui/screens/AccountSwitcherScreen.js +3 -3
  182. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  183. package/lib/module/ui/screens/OxyAuthScreen.js +135 -68
  184. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  185. package/lib/module/ui/screens/PrivacySettingsScreen.js +6 -13
  186. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  187. package/lib/module/ui/stores/accountStore.js +2 -4
  188. package/lib/module/ui/stores/accountStore.js.map +1 -1
  189. package/lib/module/ui/stores/authStore.js +45 -32
  190. package/lib/module/ui/stores/authStore.js.map +1 -1
  191. package/lib/module/ui/styles/spacing.js +6 -2
  192. package/lib/module/ui/styles/spacing.js.map +1 -1
  193. package/lib/module/ui/utils/avatarUtils.js +37 -40
  194. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  195. package/lib/module/ui/utils/storageHelpers.js.map +1 -1
  196. package/lib/module/utils/errorUtils.js +7 -0
  197. package/lib/module/utils/errorUtils.js.map +1 -1
  198. package/lib/module/utils/validationUtils.js +13 -0
  199. package/lib/module/utils/validationUtils.js.map +1 -1
  200. package/lib/typescript/core/CrossDomainAuth.d.ts +161 -0
  201. package/lib/typescript/core/CrossDomainAuth.d.ts.map +1 -0
  202. package/lib/typescript/core/HttpService.d.ts +1 -1
  203. package/lib/typescript/core/HttpService.d.ts.map +1 -1
  204. package/lib/typescript/core/OxyServices.base.d.ts +0 -6
  205. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  206. package/lib/typescript/core/OxyServices.d.ts +5 -36
  207. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  208. package/lib/typescript/core/index.d.ts +4 -0
  209. package/lib/typescript/core/index.d.ts.map +1 -1
  210. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  211. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  212. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +40 -20
  213. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  214. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  215. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  216. package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts +195 -0
  217. package/lib/typescript/core/mixins/OxyServices.fedcm.d.ts.map +1 -0
  218. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  219. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  220. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  221. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  222. package/lib/typescript/core/mixins/OxyServices.popup.d.ts +206 -0
  223. package/lib/typescript/core/mixins/OxyServices.popup.d.ts.map +1 -0
  224. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  225. package/lib/typescript/core/mixins/OxyServices.redirect.d.ts +246 -0
  226. package/lib/typescript/core/mixins/OxyServices.redirect.d.ts.map +1 -0
  227. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  228. package/lib/typescript/core/mixins/OxyServices.user.d.ts +6 -4
  229. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  230. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  231. package/lib/typescript/core/mixins/index.d.ts +220 -8
  232. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  233. package/lib/typescript/crypto/index.d.ts +6 -3
  234. package/lib/typescript/crypto/index.d.ts.map +1 -1
  235. package/lib/typescript/crypto/keyManager.d.ts +190 -0
  236. package/lib/typescript/crypto/keyManager.d.ts.map +1 -0
  237. package/lib/typescript/crypto/polyfill.d.ts +4 -3
  238. package/lib/typescript/crypto/polyfill.d.ts.map +1 -1
  239. package/lib/typescript/crypto/recoveryPhrase.d.ts +59 -0
  240. package/lib/typescript/crypto/recoveryPhrase.d.ts.map +1 -0
  241. package/lib/typescript/crypto/signatureService.d.ts +87 -0
  242. package/lib/typescript/crypto/signatureService.d.ts.map +1 -0
  243. package/lib/typescript/index.d.ts +5 -6
  244. package/lib/typescript/index.d.ts.map +1 -1
  245. package/lib/typescript/models/interfaces.d.ts +2 -14
  246. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  247. package/lib/typescript/models/session.d.ts +0 -9
  248. package/lib/typescript/models/session.d.ts.map +1 -1
  249. package/lib/typescript/types/bip39.d.ts +32 -0
  250. package/lib/typescript/ui/components/BottomSheetRouter.d.ts +5 -0
  251. package/lib/typescript/ui/components/BottomSheetRouter.d.ts.map +1 -1
  252. package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
  253. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  254. package/lib/typescript/ui/components/TextField/Addons/Outline.d.ts +2 -2
  255. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
  256. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
  257. package/lib/typescript/ui/components/TextField/helpers.d.ts +8 -8
  258. package/lib/typescript/ui/components/TextField/types.d.ts +1 -0
  259. package/lib/typescript/ui/components/TextField/types.d.ts.map +1 -1
  260. package/lib/typescript/ui/components/types.d.ts +4 -0
  261. package/lib/typescript/ui/components/types.d.ts.map +1 -1
  262. package/lib/typescript/ui/context/OxyContext.d.ts +57 -3
  263. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  264. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -3
  265. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  266. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +41 -0
  267. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -0
  268. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  269. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  270. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  271. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  272. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  273. package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -2
  274. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  275. package/lib/typescript/ui/hooks/useStorage.d.ts +3 -9
  276. package/lib/typescript/ui/hooks/useStorage.d.ts.map +1 -1
  277. package/lib/typescript/ui/index.d.ts +6 -2
  278. package/lib/typescript/ui/index.d.ts.map +1 -1
  279. package/lib/typescript/ui/navigation/routes.d.ts +1 -1
  280. package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
  281. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  282. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts +1 -1
  283. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  284. package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  285. package/lib/typescript/ui/stores/accountStore.d.ts.map +1 -1
  286. package/lib/typescript/ui/stores/authStore.d.ts +8 -7
  287. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  288. package/lib/typescript/ui/styles/spacing.d.ts +5 -0
  289. package/lib/typescript/ui/styles/spacing.d.ts.map +1 -1
  290. package/lib/typescript/ui/types/navigation.d.ts +2 -1
  291. package/lib/typescript/ui/types/navigation.d.ts.map +1 -1
  292. package/lib/typescript/ui/utils/avatarUtils.d.ts +2 -13
  293. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  294. package/lib/typescript/ui/utils/storageHelpers.d.ts +0 -3
  295. package/lib/typescript/ui/utils/storageHelpers.d.ts.map +1 -1
  296. package/lib/typescript/utils/errorUtils.d.ts +6 -0
  297. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  298. package/lib/typescript/utils/validationUtils.d.ts +8 -0
  299. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  300. package/package.json +8 -7
  301. package/src/core/CrossDomainAuth.ts +307 -0
  302. package/src/core/HttpService.ts +99 -16
  303. package/src/core/OxyServices.base.ts +20 -3
  304. package/src/core/OxyServices.ts +7 -3
  305. package/src/core/index.ts +9 -1
  306. package/src/core/mixins/OxyServices.assets.ts +14 -3
  307. package/src/core/mixins/OxyServices.auth.ts +105 -36
  308. package/src/core/mixins/OxyServices.fedcm.ts +315 -0
  309. package/src/core/mixins/OxyServices.popup.ts +402 -0
  310. package/src/core/mixins/OxyServices.redirect.ts +397 -0
  311. package/src/core/mixins/OxyServices.user.ts +39 -24
  312. package/src/core/mixins/index.ts +19 -3
  313. package/src/crypto/index.ts +16 -5
  314. package/src/crypto/keyManager.ts +966 -0
  315. package/src/crypto/polyfill.ts +6 -5
  316. package/src/crypto/recoveryPhrase.ts +166 -0
  317. package/src/crypto/signatureService.ts +323 -0
  318. package/src/i18n/locales/en-US.json +1 -1
  319. package/src/index.ts +19 -15
  320. package/src/models/interfaces.ts +4 -16
  321. package/src/models/session.ts +2 -11
  322. package/src/types/bip39.d.ts +32 -0
  323. package/src/ui/components/BottomSheetRouter.tsx +6 -1
  324. package/src/ui/components/Icon.tsx +1 -1
  325. package/src/ui/components/IconButton/utils.ts +1 -1
  326. package/src/ui/components/OxyProvider.tsx +44 -12
  327. package/src/ui/components/TextField/Addons/Outline.tsx +2 -2
  328. package/src/ui/components/TextField/Adornment/utils.ts +2 -2
  329. package/src/ui/components/TextField/helpers.tsx +10 -10
  330. package/src/ui/components/TextField/types.tsx +1 -1
  331. package/src/ui/components/TouchableRipple/utils.ts +2 -2
  332. package/src/ui/components/Typography/AnimatedText.tsx +2 -2
  333. package/src/ui/components/types.tsx +6 -0
  334. package/src/ui/context/OxyContext.tsx +173 -195
  335. package/src/ui/context/hooks/useAuthOperations.ts +177 -36
  336. package/src/ui/context/hooks/useSessionManagement.ts +399 -0
  337. package/src/ui/hooks/mutations/useAccountMutations.ts +83 -76
  338. package/src/ui/hooks/queries/useAccountQueries.ts +29 -35
  339. package/src/ui/hooks/queries/useSecurityQueries.ts +1 -1
  340. package/src/ui/hooks/queries/useServicesQueries.ts +14 -6
  341. package/src/ui/hooks/useProfileEditing.ts +3 -3
  342. package/src/ui/hooks/useSessionManagement.ts +5 -10
  343. package/src/ui/hooks/useSessionSocket.ts +46 -175
  344. package/src/ui/hooks/useStorage.ts +24 -76
  345. package/src/ui/index.ts +22 -13
  346. package/src/ui/navigation/routes.ts +6 -2
  347. package/src/ui/screens/AccountCenterScreen.tsx +2 -2
  348. package/src/ui/screens/AccountOverviewScreen.tsx +1 -1
  349. package/src/ui/screens/AccountSettingsScreen.tsx +34 -37
  350. package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
  351. package/src/ui/screens/OxyAuthScreen.tsx +138 -64
  352. package/src/ui/screens/PrivacySettingsScreen.tsx +6 -12
  353. package/src/ui/stores/accountStore.ts +1 -11
  354. package/src/ui/stores/authStore.ts +43 -44
  355. package/src/ui/styles/spacing.ts +15 -2
  356. package/src/ui/types/navigation.ts +2 -2
  357. package/src/ui/utils/avatarUtils.ts +39 -46
  358. package/src/ui/utils/storageHelpers.ts +0 -4
  359. package/src/utils/__tests__/validationUtils.test.ts +16 -1
  360. package/src/utils/errorUtils.ts +8 -1
  361. package/src/utils/validationUtils.ts +12 -0
  362. package/lib/commonjs/core/services/SessionService.js +0 -163
  363. package/lib/commonjs/core/services/SessionService.js.map +0 -1
  364. package/lib/commonjs/core/services/TokenService.js +0 -220
  365. package/lib/commonjs/core/services/TokenService.js.map +0 -1
  366. package/lib/commonjs/crypto/types.js +0 -2
  367. package/lib/commonjs/crypto/types.js.map +0 -1
  368. package/lib/commonjs/ui/context/OxyContextBase.js +0 -21
  369. package/lib/commonjs/ui/context/OxyContextBase.js.map +0 -1
  370. package/lib/commonjs/ui/context/hooks/useStorage.js +0 -79
  371. package/lib/commonjs/ui/context/hooks/useStorage.js.map +0 -1
  372. package/lib/commonjs/ui/hooks/useAvatarPicker.js +0 -56
  373. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +0 -1
  374. package/lib/module/core/services/SessionService.js +0 -159
  375. package/lib/module/core/services/SessionService.js.map +0 -1
  376. package/lib/module/core/services/TokenService.js +0 -217
  377. package/lib/module/core/services/TokenService.js.map +0 -1
  378. package/lib/module/crypto/types.js +0 -2
  379. package/lib/module/crypto/types.js.map +0 -1
  380. package/lib/module/ui/context/OxyContextBase.js +0 -16
  381. package/lib/module/ui/context/OxyContextBase.js.map +0 -1
  382. package/lib/module/ui/context/hooks/useStorage.js +0 -74
  383. package/lib/module/ui/context/hooks/useStorage.js.map +0 -1
  384. package/lib/module/ui/hooks/useAvatarPicker.js +0 -50
  385. package/lib/module/ui/hooks/useAvatarPicker.js.map +0 -1
  386. package/lib/typescript/core/services/SessionService.d.ts +0 -78
  387. package/lib/typescript/core/services/SessionService.d.ts.map +0 -1
  388. package/lib/typescript/core/services/TokenService.d.ts +0 -72
  389. package/lib/typescript/core/services/TokenService.d.ts.map +0 -1
  390. package/lib/typescript/crypto/types.d.ts +0 -22
  391. package/lib/typescript/crypto/types.d.ts.map +0 -1
  392. package/lib/typescript/ui/context/OxyContextBase.d.ts +0 -63
  393. package/lib/typescript/ui/context/OxyContextBase.d.ts.map +0 -1
  394. package/lib/typescript/ui/context/hooks/useStorage.d.ts +0 -22
  395. package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +0 -1
  396. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +0 -19
  397. package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +0 -1
  398. package/src/core/services/SessionService.ts +0 -173
  399. package/src/core/services/TokenService.ts +0 -237
  400. package/src/crypto/types.ts +0 -23
  401. package/src/ui/context/OxyContextBase.tsx +0 -78
  402. package/src/ui/context/hooks/useStorage.ts +0 -104
  403. package/src/ui/hooks/useAvatarPicker.ts +0 -61
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useOxy = exports.OxyContext = void 0;
7
- var _react = require("react");
8
- const OxyContext = exports.OxyContext = /*#__PURE__*/(0, _react.createContext)(null);
9
- /**
10
- * Hook to access the Oxy context.
11
- * Must be used within an OxyContextProvider.
12
- */
13
- const useOxy = () => {
14
- const context = (0, _react.useContext)(OxyContext);
15
- if (!context) {
16
- throw new Error('useOxy must be used within an OxyContextProvider');
17
- }
18
- return context;
19
- };
20
- exports.useOxy = useOxy;
21
- //# sourceMappingURL=OxyContextBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","OxyContext","exports","createContext","useOxy","context","useContext","Error"],"sourceRoot":"../../../../src","sources":["ui/context/OxyContextBase.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAwDO,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,gBAAG,IAAAE,oBAAa,EAAyB,IAAI,CAAC;AAWrE;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,CAAA,KAAuB;EACzC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,UAAU,CAAC;EACtC,IAAI,CAACI,OAAO,EAAE;IACV,MAAM,IAAIE,KAAK,CAAC,kDAAkD,CAAC;EACvE;EACA,OAAOF,OAAO;AAClB,CAAC;AAACH,OAAA,CAAAE,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useStorage = void 0;
7
- var _react = require("react");
8
- var _storageHelpers = require("../../utils/storageHelpers");
9
- var _errorHandlers = require("../../utils/errorHandlers");
10
- const DEFAULT_ERROR_CODE = 'STORAGE_INIT_ERROR';
11
-
12
- /**
13
- * React hook that exposes a platform-agnostic storage reference.
14
- * Handles initialization, error propagation, and lazy re-initialization.
15
- *
16
- * @param options - Optional configuration for error reporting and logging
17
- */
18
- const useStorage = ({
19
- onError,
20
- logger,
21
- errorCode = DEFAULT_ERROR_CODE
22
- } = {}) => {
23
- const [storage, setStorage] = (0, _react.useState)(null);
24
- const [error, setError] = (0, _react.useState)(null);
25
- const initializingRef = (0, _react.useRef)(null);
26
- const notifyError = (0, _react.useCallback)(err => {
27
- const message = (0, _errorHandlers.extractErrorMessage)(err, 'Failed to initialize storage');
28
- setError(message);
29
- if (logger) {
30
- logger(message, err);
31
- }
32
- onError?.({
33
- message,
34
- code: errorCode,
35
- status: 500
36
- });
37
- }, [errorCode, logger, onError]);
38
- const createStorageInstance = (0, _react.useCallback)(async () => {
39
- try {
40
- const platformStorage = await (0, _storageHelpers.createPlatformStorage)();
41
- setStorage(platformStorage);
42
- setError(null);
43
- return platformStorage;
44
- } catch (err) {
45
- notifyError(err);
46
- setStorage(null);
47
- return null;
48
- }
49
- }, [notifyError]);
50
- const refresh = (0, _react.useCallback)(async () => {
51
- if (!initializingRef.current) {
52
- initializingRef.current = createStorageInstance().finally(() => {
53
- initializingRef.current = null;
54
- });
55
- }
56
- return initializingRef.current;
57
- }, [createStorageInstance]);
58
- (0, _react.useEffect)(() => {
59
- refresh().catch(err => {
60
- notifyError(err);
61
- });
62
- }, [refresh, notifyError]);
63
- const withStorage = (0, _react.useCallback)(async callback => {
64
- const resolvedStorage = storage ?? (await refresh());
65
- if (!resolvedStorage) {
66
- return null;
67
- }
68
- return callback(resolvedStorage);
69
- }, [refresh, storage]);
70
- return {
71
- storage,
72
- isReady: Boolean(storage) && !error,
73
- error,
74
- refresh,
75
- withStorage
76
- };
77
- };
78
- exports.useStorage = useStorage;
79
- //# sourceMappingURL=useStorage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_storageHelpers","_errorHandlers","DEFAULT_ERROR_CODE","useStorage","onError","logger","errorCode","storage","setStorage","useState","error","setError","initializingRef","useRef","notifyError","useCallback","err","message","extractErrorMessage","code","status","createStorageInstance","platformStorage","createPlatformStorage","refresh","current","finally","useEffect","catch","withStorage","callback","resolvedStorage","isReady","Boolean","exports"],"sourceRoot":"../../../../../src","sources":["ui/context/hooks/useStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAgBA,MAAMG,kBAAkB,GAAG,oBAAoB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,UAAU,GAAGA,CAAC;EACzBC,OAAO;EACPC,MAAM;EACNC,SAAS,GAAGJ;AACK,CAAC,GAAG,CAAC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C,CAAC,CAAC;IACJ;IAEA,OAAOb,eAAe,CAACa,OAAO;EAChC,CAAC,EAAE,CAACJ,qBAAqB,CAAC,CAAC;EAE3B,IAAAM,gBAAS,EAAC,MAAM;IACdH,OAAO,CAAC,CAAC,CAACI,KAAK,CAAEZ,GAAG,IAAK;MACvBF,WAAW,CAACE,GAAG,CAAC;IAClB,CAAC,CAAC;EACJ,CAAC,EAAE,CAACQ,OAAO,EAAEV,WAAW,CAAC,CAAC;EAE1B,MAAMe,WAAW,GAAG,IAAAd,kBAAW,EAC7B,MAAWe,QAA2D,IAAwB;IAC5F,MAAMC,eAAe,GAAGxB,OAAO,KAAK,MAAMiB,OAAO,CAAC,CAAC,CAAC;IACpD,IAAI,CAACO,eAAe,EAAE;MACpB,OAAO,IAAI;IACb;IACA,OAAOD,QAAQ,CAACC,eAAe,CAAC;EAClC,CAAC,EACD,CAACP,OAAO,EAAEjB,OAAO,CACnB,CAAC;EAED,OAAO;IACLA,OAAO;IACPyB,OAAO,EAAEC,OAAO,CAAC1B,OAAO,CAAC,IAAI,CAACG,KAAK;IACnCA,KAAK;IACLc,OAAO;IACPK;EACF,CAAC;AACH,CAAC;AAACK,OAAA,CAAA/B,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useAvatarPicker = void 0;
7
- var _react = require("react");
8
- var _sonner = require("../../lib/sonner");
9
- var _i18n = require("../../i18n");
10
- var _avatarUtils = require("../utils/avatarUtils");
11
- /**
12
- * Provides avatar picker action wired to bottom sheet selection and profile update.
13
- */
14
-
15
- const useAvatarPicker = ({
16
- oxyServices,
17
- currentLanguage,
18
- activeSessionId,
19
- currentDeviceId,
20
- queryClient,
21
- showBottomSheet
22
- }) => {
23
- const openAvatarPicker = (0, _react.useCallback)(() => {
24
- showBottomSheet({
25
- screen: 'FileManagement',
26
- props: {
27
- selectMode: true,
28
- multiSelect: false,
29
- disabledMimeTypes: ['video/', 'audio/', 'application/pdf'],
30
- afterSelect: 'none',
31
- onSelect: async file => {
32
- if (!file.contentType.startsWith('image/')) {
33
- _sonner.toast.error((0, _i18n.translate)(currentLanguage, 'editProfile.toasts.selectImage') || 'Please select an image file');
34
- return;
35
- }
36
- try {
37
- await (0, _avatarUtils.updateAvatarVisibility)(file.id, oxyServices, 'OxyContext');
38
- await (0, _avatarUtils.updateProfileWithAvatar)({
39
- avatar: file.id
40
- }, oxyServices, activeSessionId, queryClient, {
41
- deviceId: currentDeviceId || undefined
42
- });
43
- _sonner.toast.success((0, _i18n.translate)(currentLanguage, 'editProfile.toasts.avatarUpdated') || 'Avatar updated');
44
- } catch (e) {
45
- _sonner.toast.error(e.message || (0, _i18n.translate)(currentLanguage, 'editProfile.toasts.updateAvatarFailed') || 'Failed to update avatar');
46
- }
47
- }
48
- }
49
- });
50
- }, [activeSessionId, currentDeviceId, currentLanguage, oxyServices, queryClient, showBottomSheet]);
51
- return {
52
- openAvatarPicker
53
- };
54
- };
55
- exports.useAvatarPicker = useAvatarPicker;
56
- //# sourceMappingURL=useAvatarPicker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_sonner","_i18n","_avatarUtils","useAvatarPicker","oxyServices","currentLanguage","activeSessionId","currentDeviceId","queryClient","showBottomSheet","openAvatarPicker","useCallback","screen","props","selectMode","multiSelect","disabledMimeTypes","afterSelect","onSelect","file","contentType","startsWith","toast","error","translate","updateAvatarVisibility","id","updateProfileWithAvatar","avatar","deviceId","undefined","success","e","message","exports"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAvatarPicker.ts"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAPA;AACA;AACA;;AAkBO,MAAMI,eAAe,GAAGA,CAAC;EAC9BC,WAAW;EACXC,eAAe;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AAO;IAAEC;EAAiB,CAAC;AAC7B,CAAC;AAACwB,OAAA,CAAA/B,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,159 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * SessionService - Single Source of Truth for Session Management
5
- *
6
- * Handles all session operations: creation, validation, refresh, invalidation.
7
- * Manages active session state and provides session data to other services.
8
- *
9
- * Architecture:
10
- * - Single source of truth for session operations
11
- * - Handles both online and offline sessions
12
- * - Integrates with TokenService for token management
13
- * - userId is always MongoDB ObjectId, never publicKey
14
- */
15
-
16
- import { tokenService } from './TokenService';
17
- /**
18
- * SessionService - Singleton pattern for global session management
19
- */
20
- class SessionService {
21
- oxyServices = null;
22
- activeSession = null;
23
- sessions = [];
24
- constructor() {}
25
- static getInstance() {
26
- if (!SessionService.instance) {
27
- SessionService.instance = new SessionService();
28
- }
29
- return SessionService.instance;
30
- }
31
-
32
- /**
33
- * Initialize SessionService with OxyServices instance
34
- */
35
- initialize(oxyServices) {
36
- this.oxyServices = oxyServices;
37
- }
38
-
39
- /**
40
- * Get active session
41
- */
42
- getActiveSession() {
43
- return this.activeSession;
44
- }
45
-
46
- /**
47
- * Get all sessions
48
- */
49
- getAllSessions() {
50
- return [...this.sessions];
51
- }
52
-
53
- /**
54
- * Create a new session (sign in)
55
- * @param publicKey - User's public key for authentication
56
- * @returns User object and session data
57
- */
58
- async createSession(publicKey) {
59
- if (!this.oxyServices) {
60
- throw new Error('SessionService not initialized with OxyServices');
61
- }
62
-
63
- // This will be implemented by delegating to existing sign-in logic
64
- // For now, this is a placeholder that shows the interface
65
- throw new Error('SessionService.createSession not yet implemented - use existing signIn flow');
66
- }
67
-
68
- /**
69
- * Refresh current session
70
- */
71
- async refreshSession() {
72
- if (!this.activeSession) {
73
- throw new Error('No active session to refresh');
74
- }
75
-
76
- // Refresh token first
77
- await tokenService.refreshTokenIfNeeded();
78
-
79
- // Then refresh session data from server
80
- // Implementation will be added
81
- return this.activeSession;
82
- }
83
-
84
- /**
85
- * Validate current session
86
- */
87
- async validateSession() {
88
- if (!this.activeSession) {
89
- return false;
90
- }
91
-
92
- // Check if session expired
93
- if (new Date(this.activeSession.expiresAt) < new Date()) {
94
- return false;
95
- }
96
-
97
- // Check if token is valid
98
- const token = tokenService.getAccessToken();
99
- if (!token) {
100
- return false;
101
- }
102
-
103
- // Additional validation can be added here
104
- return true;
105
- }
106
-
107
- /**
108
- * Invalidate current session (sign out)
109
- */
110
- async invalidateSession() {
111
- if (!this.activeSession || !this.oxyServices) {
112
- return;
113
- }
114
- try {
115
- // Call API to invalidate session on server
116
- await this.oxyServices.makeRequest('POST', `/api/session/${this.activeSession.sessionId}/logout`, undefined, {
117
- cache: false
118
- });
119
- } catch (error) {
120
- // Continue with local cleanup even if API call fails
121
- console.warn('Failed to invalidate session on server:', error);
122
- }
123
-
124
- // Clear tokens
125
- tokenService.clearTokens();
126
-
127
- // Clear active session
128
- this.activeSession = null;
129
- this.sessions = this.sessions.filter(s => s.sessionId !== this.activeSession?.sessionId);
130
- }
131
-
132
- /**
133
- * Set active session (internal use)
134
- */
135
- setActiveSession(session) {
136
- this.activeSession = session;
137
-
138
- // Update sessions list
139
- const existingIndex = this.sessions.findIndex(s => s.sessionId === session.sessionId);
140
- if (existingIndex >= 0) {
141
- this.sessions[existingIndex] = session;
142
- } else {
143
- this.sessions.push(session);
144
- }
145
- }
146
-
147
- /**
148
- * Clear all sessions (logout all)
149
- */
150
- clearAllSessions() {
151
- this.activeSession = null;
152
- this.sessions = [];
153
- tokenService.clearTokens();
154
- }
155
- }
156
-
157
- // Export singleton instance
158
- export const sessionService = SessionService.getInstance();
159
- //# sourceMappingURL=SessionService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["tokenService","SessionService","oxyServices","activeSession","sessions","constructor","getInstance","instance","initialize","getActiveSession","getAllSessions","createSession","publicKey","Error","refreshSession","refreshTokenIfNeeded","validateSession","Date","expiresAt","token","getAccessToken","invalidateSession","makeRequest","sessionId","undefined","cache","error","console","warn","clearTokens","filter","s","setActiveSession","session","existingIndex","findIndex","push","clearAllSessions","sessionService"],"sourceRoot":"../../../../src","sources":["core/services/SessionService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,YAAY,QAAQ,gBAAgB;AAc7C;AACA;AACA;AACA,MAAMC,cAAc,CAAC;EAEXC,WAAW,GAAuB,IAAI;EACtCC,aAAa,GAAmB,IAAI;EACpCC,QAAQ,GAAc,EAAE;EAExBC,WAAWA,CAAA,EAAG,CAAC;EAEvB,OAAOC,WAAWA,CAAA,EAAmB;IACnC,IAAI,CAACL,cAAc,CAACM,QAAQ,EAAE;MAC5BN,cAAc,CAACM,QAAQ,GAAG,IAAIN,cAAc,CAAC,CAAC;IAChD;IACA,OAAOA,cAAc,CAACM,QAAQ;EAChC;;EAEA;AACF;AACA;EACEC,UAAUA,CAACN,WAAwB,EAAQ;IACzC,IAAI,CAACA,WAAW,GAAGA,WAAW;EAChC;;EAEA;AACF;AACA;EACEO,gBAAgBA,CAAA,EAAmB;IACjC,OAAO,IAAI,CAACN,aAAa;EAC3B;;EAEA;AACF;AACA;EACEO,cAAcA,CAAA,EAAc;IAC1B,OAAO,CAAC,GAAG,IAAI,CAACN,QAAQ,CAAC;EAC3B;;EAEA;AACF;AACA;AACA;AACA;EACE,MAAMO,aAAaA,CAACC,SAAiB,EAA6C;IAChF,IAAI,CAAC,IAAI,CAACV,WAAW,EAAE;MACrB,MAAM,IAAIW,KAAK,CAAC,iDAAiD,CAAC;IACpE;;IAEA;IACA;IACA,MAAM,IAAIA,KAAK,CAAC,6EAA6E,CAAC;EAChG;;EAEA;AACF;AACA;EACE,MAAMC,cAAcA,CAAA,EAAqB;IACvC,IAAI,CAAC,IAAI,CAACX,aAAa,EAAE;MACvB,MAAM,IAAIU,KAAK,CAAC,8BAA8B,CAAC;IACjD;;IAEA;IACA,MAAMb,YAAY,CAACe,oBAAoB,CAAC,CAAC;;IA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G,IAAI,CAAC9B,QAAQ,CAAC+B,SAAS,CAACJ,CAAC,IAAIA,CAAC,CAACR,SAAS,KAAKU,OAAO,CAACV,SAAS,CAAC;IACrF,IAAIW,aAAa,IAAI,CAAC,EAAE;MACtB,IAAI,CAAC9B,QAAQ,CAAC8B,aAAa,CAAC,GAAGD,OAAO;IACxC,CAAC,MAAM;MACL,IAAI,CAAC7B,QAAQ,CAACgC,IAAI,CAACH,OAAO,CAAC;IAC7B;EACF;;EAEA;AACF;AACA;EACEI,gBAAgBA,CAAA,EAAS;IACvB,IAAI,CAAClC,aAAa,GAAG,IAAI;IACzB,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClBJ,YAAY,CAAC6B,WAAW,CAAC,CAAC;EAC5B;AACF;;AAEA;AACA,OAAO,MAAMS,cAAc,GAAGrC,cAAc,CAACK,WAAW,CAAC,CAAC","ignoreList":[]}
@@ -1,217 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * TokenService - Single Source of Truth for Token Management
5
- *
6
- * Handles all token storage, retrieval, refresh, and validation.
7
- * Used by HttpService, SocketService, and other services that need tokens.
8
- *
9
- * Architecture:
10
- * - Single storage location (no duplication)
11
- * - Automatic token refresh when expiring soon
12
- * - Type-safe token payload handling
13
- * - userId is always MongoDB ObjectId, never publicKey
14
- */
15
-
16
- import { jwtDecode } from 'jwt-decode';
17
-
18
- /**
19
- * AccessTokenPayload - Matches the token payload structure from API
20
- * userId is always MongoDB ObjectId (24 hex characters), never publicKey
21
- */
22
-
23
- /**
24
- * TokenService - Singleton pattern for global token management
25
- */
26
- class TokenService {
27
- tokenStore = {
28
- accessToken: null,
29
- refreshToken: null
30
- };
31
- refreshPromise = null;
32
- baseURL = null;
33
- constructor() {}
34
- static getInstance() {
35
- if (!TokenService.instance) {
36
- TokenService.instance = new TokenService();
37
- }
38
- return TokenService.instance;
39
- }
40
-
41
- /**
42
- * Initialize TokenService with base URL for refresh requests
43
- */
44
- initialize(baseURL) {
45
- this.baseURL = baseURL;
46
- }
47
-
48
- /**
49
- * Get current access token
50
- */
51
- getAccessToken() {
52
- return this.tokenStore.accessToken;
53
- }
54
-
55
- /**
56
- * Get current refresh token
57
- */
58
- getRefreshToken() {
59
- return this.tokenStore.refreshToken;
60
- }
61
-
62
- /**
63
- * Set tokens (called after login or token refresh)
64
- */
65
- setTokens(accessToken, refreshToken = '') {
66
- this.tokenStore.accessToken = accessToken;
67
- this.tokenStore.refreshToken = refreshToken || this.tokenStore.refreshToken;
68
- }
69
-
70
- /**
71
- * Clear all tokens (called on logout)
72
- */
73
- clearTokens() {
74
- this.tokenStore.accessToken = null;
75
- this.tokenStore.refreshToken = null;
76
- this.refreshPromise = null;
77
- }
78
-
79
- /**
80
- * Check if access token exists
81
- */
82
- hasAccessToken() {
83
- return !!this.tokenStore.accessToken;
84
- }
85
-
86
- /**
87
- * Check if token is expiring soon (within 60 seconds)
88
- */
89
- isTokenExpiringSoon() {
90
- const token = this.tokenStore.accessToken;
91
- if (!token) return false;
92
- try {
93
- const decoded = jwtDecode(token);
94
- if (!decoded.exp) return false;
95
- const currentTime = Math.floor(Date.now() / 1000);
96
- return decoded.exp - currentTime < 60; // Expiring within 60 seconds
97
- } catch {
98
- return false;
99
- }
100
- }
101
-
102
- /**
103
- * Get userId from current access token
104
- * Returns MongoDB ObjectId (never publicKey)
105
- */
106
- getUserIdFromToken() {
107
- const token = this.tokenStore.accessToken;
108
- if (!token) return null;
109
- try {
110
- const decoded = jwtDecode(token);
111
- return decoded.userId || null;
112
- } catch {
113
- return null;
114
- }
115
- }
116
-
117
- /**
118
- * Refresh access token if expiring soon
119
- * Returns promise that resolves when token is refreshed (or already valid)
120
- */
121
- async refreshTokenIfNeeded() {
122
- // If already refreshing, wait for that promise
123
- if (this.refreshPromise) {
124
- return this.refreshPromise;
125
- }
126
- const hasToken = !!this.tokenStore.accessToken;
127
- const needsRefresh = this.isTokenExpiringSoon();
128
-
129
- // If no access token but we have refresh token, attempt refresh once
130
- if (!hasToken && this.tokenStore.refreshToken) {
131
- this.refreshPromise = this._performRefresh();
132
- try {
133
- await this.refreshPromise;
134
- } finally {
135
- this.refreshPromise = null;
136
- }
137
- return;
138
- }
139
-
140
- // If token not expiring soon, no refresh needed
141
- if (!needsRefresh) {
142
- return;
143
- }
144
-
145
- // Start refresh
146
- this.refreshPromise = this._performRefresh();
147
- try {
148
- await this.refreshPromise;
149
- } finally {
150
- this.refreshPromise = null;
151
- }
152
- }
153
-
154
- /**
155
- * Perform token refresh
156
- */
157
- async _performRefresh() {
158
- const refreshToken = this.tokenStore.refreshToken;
159
- if (!refreshToken) {
160
- throw new Error('No refresh token to refresh');
161
- }
162
- try {
163
- if (!this.baseURL) {
164
- throw new Error('TokenService not initialized with baseURL');
165
- }
166
- const refreshUrl = `${this.baseURL}/api/auth/refresh`;
167
- const response = await fetch(refreshUrl, {
168
- method: 'POST',
169
- headers: {
170
- 'Accept': 'application/json',
171
- 'Content-Type': 'application/json'
172
- },
173
- body: JSON.stringify({
174
- refreshToken
175
- }),
176
- signal: AbortSignal.timeout(5000)
177
- });
178
- if (!response.ok) {
179
- throw new Error(`Token refresh failed: ${response.status}`);
180
- }
181
- const {
182
- accessToken: newToken,
183
- refreshToken: newRefresh
184
- } = await response.json();
185
- if (!newToken) {
186
- throw new Error('No access token in refresh response');
187
- }
188
-
189
- // Validate new token has correct userId format (ObjectId)
190
- const newDecoded = jwtDecode(newToken);
191
- if (newDecoded.userId && !/^[0-9a-fA-F]{24}$/.test(newDecoded.userId)) {
192
- throw new Error(`Invalid userId format in refreshed token: ${newDecoded.userId.substring(0, 20)}...`);
193
- }
194
- this.setTokens(newToken, newRefresh || refreshToken);
195
- } catch (error) {
196
- // Clear tokens on refresh failure (likely expired or invalid)
197
- this.clearTokens();
198
- throw error;
199
- }
200
- }
201
-
202
- /**
203
- * Get authorization header with automatic refresh
204
- */
205
- async getAuthHeader() {
206
- // Refresh if needed
207
- await this.refreshTokenIfNeeded().catch(() => {
208
- // Ignore refresh errors, will use current token or return null
209
- });
210
- const token = this.tokenStore.accessToken;
211
- return token ? `Bearer ${token}` : null;
212
- }
213
- }
214
-
215
- // Export singleton instance
216
- export const tokenService = TokenService.getInstance();
217
- //# sourceMappingURL=TokenService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["jwtDecode","TokenService","tokenStore","accessToken","refreshToken","refreshPromise","baseURL","constructor","getInstance","instance","initialize","getAccessToken","getRefreshToken","setTokens","clearTokens","hasAccessToken","isTokenExpiringSoon","token","decoded","exp","currentTime","Math","floor","Date","now","getUserIdFromToken","userId","refreshTokenIfNeeded","hasToken","needsRefresh","_performRefresh","Error","refreshUrl","response","fetch","method","headers","body","JSON","stringify","signal","AbortSignal","timeout","ok","status","newToken","newRefresh","json","newDecoded","test","substring","error","getAuthHeader","catch","tokenService"],"sourceRoot":"../../../../src","sources":["core/services/TokenService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,YAAY;;AAEtC;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA,MAAMC,YAAY,CAAC;EAETC,UAAU,GAAe;IAC/BC,WAAW,EAAE,IAAI;IACjBC,YAAY,EAAE;EAChB,CAAC;EACOC,cAAc,GAAyB,IAAI;EAC3CC,OAAO,GAAkB,IAAI;EAE7BC,WAAWA,CAAA,EAAG,CAAC;EAEvB,OAAOC,WAAWA,CAAA,EAAiB;IACjC,IAAI,CAACP,YAAY,CAACQ,QAAQ,EAAE;MAC1BR,YAAY,CAACQ,QAAQ,GAAG,IAAIR,YAAY,CAAC,CAAC;IAC5C;IACA,OAAOA,YAAY,CAACQ,QAAQ;EAC9B;;EAEA;AACF;AACA;EACEC,UAAUA,CAACJ,OAAe,EAAQ;IAChC,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;EACEK,cAAcA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAACT,UAAU,CAACC,WAAW;EACpC;;EA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AAC0B,KAAK,CAAC,MAAM;MAC5C;IAAA,CACD,CAAC;IAEF,MAAMpC,KAAK,GAAG,IAAI,CAACf,UAAU,CAACC,WAAW;IACzC,OAAOc,KAAK,GAAG,UAAUA,KAAK,EAAE,GAAG,IAAI;EACzC;AACF;;AAEA;AACA,OAAO,MAAMqC,YAAY,GAAGrD,YAAY,CAACO,WAAW,CAAC,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["crypto/types.ts"],"mappings":"","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- import { createContext, useContext } from 'react';
4
- export const OxyContext = /*#__PURE__*/createContext(null);
5
- /**
6
- * Hook to access the Oxy context.
7
- * Must be used within an OxyContextProvider.
8
- */
9
- export const useOxy = () => {
10
- const context = useContext(OxyContext);
11
- if (!context) {
12
- throw new Error('useOxy must be used within an OxyContextProvider');
13
- }
14
- return context;
15
- };
16
- //# sourceMappingURL=OxyContextBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createContext","useContext","OxyContext","useOxy","context","Error"],"sourceRoot":"../../../../src","sources":["ui/context/OxyContextBase.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAwDjD,OAAO,MAAMC,UAAU,gBAAGF,aAAa,CAAyB,IAAI,CAAC;AAWrE;AACA;AACA;AACA;AACA,OAAO,MAAMG,MAAM,GAAGA,CAAA,KAAuB;EACzC,MAAMC,OAAO,GAAGH,UAAU,CAACC,UAAU,CAAC;EACtC,IAAI,CAACE,OAAO,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,kDAAkD,CAAC;EACvE;EACA,OAAOD,OAAO;AAClB,CAAC","ignoreList":[]}
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- import { useCallback, useEffect, useRef, useState } from 'react';
4
- import { createPlatformStorage } from '../../utils/storageHelpers';
5
- import { extractErrorMessage } from '../../utils/errorHandlers';
6
- const DEFAULT_ERROR_CODE = 'STORAGE_INIT_ERROR';
7
-
8
- /**
9
- * React hook that exposes a platform-agnostic storage reference.
10
- * Handles initialization, error propagation, and lazy re-initialization.
11
- *
12
- * @param options - Optional configuration for error reporting and logging
13
- */
14
- export const useStorage = ({
15
- onError,
16
- logger,
17
- errorCode = DEFAULT_ERROR_CODE
18
- } = {}) => {
19
- const [storage, setStorage] = useState(null);
20
- const [error, setError] = useState(null);
21
- const initializingRef = useRef(null);
22
- const notifyError = useCallback(err => {
23
- const message = extractErrorMessage(err, 'Failed to initialize storage');
24
- setError(message);
25
- if (logger) {
26
- logger(message, err);
27
- }
28
- onError?.({
29
- message,
30
- code: errorCode,
31
- status: 500
32
- });
33
- }, [errorCode, logger, onError]);
34
- const createStorageInstance = useCallback(async () => {
35
- try {
36
- const platformStorage = await createPlatformStorage();
37
- setStorage(platformStorage);
38
- setError(null);
39
- return platformStorage;
40
- } catch (err) {
41
- notifyError(err);
42
- setStorage(null);
43
- return null;
44
- }
45
- }, [notifyError]);
46
- const refresh = useCallback(async () => {
47
- if (!initializingRef.current) {
48
- initializingRef.current = createStorageInstance().finally(() => {
49
- initializingRef.current = null;
50
- });
51
- }
52
- return initializingRef.current;
53
- }, [createStorageInstance]);
54
- useEffect(() => {
55
- refresh().catch(err => {
56
- notifyError(err);
57
- });
58
- }, [refresh, notifyError]);
59
- const withStorage = useCallback(async callback => {
60
- const resolvedStorage = storage ?? (await refresh());
61
- if (!resolvedStorage) {
62
- return null;
63
- }
64
- return callback(resolvedStorage);
65
- }, [refresh, storage]);
66
- return {
67
- storage,
68
- isReady: Boolean(storage) && !error,
69
- error,
70
- refresh,
71
- withStorage
72
- };
73
- };
74
- //# sourceMappingURL=useStorage.js.map