@oxyhq/services 5.25.0 → 5.26.1

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 (532) hide show
  1. package/README.md +60 -8
  2. package/lib/commonjs/core/AuthManager.js +405 -0
  3. package/lib/commonjs/core/AuthManager.js.map +1 -0
  4. package/lib/commonjs/core/HttpService.js +39 -1
  5. package/lib/commonjs/core/HttpService.js.map +1 -1
  6. package/lib/commonjs/core/index.js +16 -0
  7. package/lib/commonjs/core/index.js.map +1 -1
  8. package/lib/commonjs/core/mixins/OxyServices.fedcm.js +38 -44
  9. package/lib/commonjs/core/mixins/OxyServices.fedcm.js.map +1 -1
  10. package/lib/commonjs/core/mixins/OxyServices.popup.js +9 -7
  11. package/lib/commonjs/core/mixins/OxyServices.popup.js.map +1 -1
  12. package/lib/commonjs/crypto/keyManager.js +16 -21
  13. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  14. package/lib/commonjs/index.js +386 -18
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/lib/sonner.js +13 -17
  17. package/lib/commonjs/lib/sonner.js.map +1 -1
  18. package/lib/commonjs/lib/sonner.native.js +24 -0
  19. package/lib/commonjs/lib/sonner.native.js.map +1 -0
  20. package/lib/commonjs/lib/sonner.web.js +24 -0
  21. package/lib/commonjs/lib/sonner.web.js.map +1 -0
  22. package/lib/commonjs/shared/index.js +227 -0
  23. package/lib/commonjs/shared/index.js.map +1 -0
  24. package/lib/commonjs/shared/utils/colorUtils.js +161 -0
  25. package/lib/commonjs/shared/utils/colorUtils.js.map +1 -0
  26. package/lib/commonjs/shared/utils/debugUtils.js +84 -0
  27. package/lib/commonjs/shared/utils/debugUtils.js.map +1 -0
  28. package/lib/commonjs/shared/utils/errorUtils.js +190 -0
  29. package/lib/commonjs/shared/utils/errorUtils.js.map +1 -0
  30. package/lib/commonjs/shared/utils/index.js +196 -0
  31. package/lib/commonjs/shared/utils/index.js.map +1 -0
  32. package/lib/commonjs/shared/utils/networkUtils.js +213 -0
  33. package/lib/commonjs/shared/utils/networkUtils.js.map +1 -0
  34. package/lib/commonjs/shared/utils/themeUtils.js +118 -0
  35. package/lib/commonjs/shared/utils/themeUtils.js.map +1 -0
  36. package/lib/commonjs/ui/client.js +1 -1
  37. package/lib/commonjs/ui/components/BottomSheetRouter.js +1 -1
  38. package/lib/commonjs/ui/components/FollowButton.js +1 -1
  39. package/lib/commonjs/ui/components/FontLoader.js +1 -1
  40. package/lib/commonjs/ui/components/FontLoader.js.map +1 -1
  41. package/lib/commonjs/ui/components/GroupedItem.js +1 -1
  42. package/lib/commonjs/ui/components/Header.js +1 -1
  43. package/lib/commonjs/ui/components/OxyProvider.js +10 -2
  44. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  45. package/lib/commonjs/ui/components/OxySignInButton.js +19 -20
  46. package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
  47. package/lib/commonjs/ui/components/ProfileCard.js +1 -1
  48. package/lib/commonjs/ui/components/ProfileCard.js.map +1 -1
  49. package/lib/commonjs/ui/components/QuickActions.js +1 -1
  50. package/lib/commonjs/ui/components/QuickActions.js.map +1 -1
  51. package/lib/commonjs/ui/components/Section.js +1 -1
  52. package/lib/commonjs/ui/components/SectionTitle.js +1 -1
  53. package/lib/commonjs/ui/components/SignInModal.js +546 -0
  54. package/lib/commonjs/ui/components/SignInModal.js.map +1 -0
  55. package/lib/commonjs/ui/components/payment/PaymentDetailsStep.js +1 -1
  56. package/lib/commonjs/ui/context/OxyContext.js +3 -2
  57. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  58. package/lib/commonjs/ui/hooks/mutations/mutationFactory.js +1 -1
  59. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +1 -1
  60. package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js +1 -1
  61. package/lib/commonjs/ui/hooks/useAsyncAction.js +1 -1
  62. package/lib/commonjs/ui/hooks/{use-color-scheme.js → useColorScheme.js} +1 -1
  63. package/lib/commonjs/ui/hooks/useColorScheme.js.map +1 -0
  64. package/lib/commonjs/ui/hooks/useSessionSocket.js +7 -13
  65. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  66. package/lib/commonjs/ui/hooks/useSettingToggle.js +1 -1
  67. package/lib/commonjs/ui/hooks/useThemeColors.js +1 -1
  68. package/lib/commonjs/ui/hooks/useThemeStyles.js +1 -1
  69. package/lib/commonjs/ui/navigation/bottomSheetManager.js +5 -2
  70. package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
  71. package/lib/commonjs/ui/navigation/routes.js +7 -8
  72. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  73. package/lib/commonjs/ui/screens/AccountCenterScreen.js +8 -8
  74. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  75. package/lib/commonjs/ui/screens/AccountOverviewScreen.js +7 -7
  76. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  77. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +3 -3
  78. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +5 -5
  79. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  80. package/lib/commonjs/ui/screens/AccountVerificationScreen.js +1 -1
  81. package/lib/commonjs/ui/screens/AppInfoScreen.js +2 -2
  82. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +2 -2
  83. package/lib/commonjs/ui/screens/FAQScreen.js +1 -1
  84. package/lib/commonjs/ui/screens/FeedbackScreen.js +1 -1
  85. package/lib/commonjs/ui/screens/FileManagementScreen.js +2 -2
  86. package/lib/commonjs/ui/screens/FollowersListScreen.js +18 -0
  87. package/lib/commonjs/ui/screens/FollowersListScreen.js.map +1 -0
  88. package/lib/commonjs/ui/screens/FollowingListScreen.js +18 -0
  89. package/lib/commonjs/ui/screens/FollowingListScreen.js.map +1 -0
  90. package/lib/commonjs/ui/screens/HelpSupportScreen.js +2 -2
  91. package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -1
  92. package/lib/commonjs/ui/screens/HistoryViewScreen.js +2 -2
  93. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +2 -2
  94. package/lib/commonjs/ui/screens/LearnMoreUsernamesScreen.js +229 -0
  95. package/lib/commonjs/ui/screens/LearnMoreUsernamesScreen.js.map +1 -0
  96. package/lib/commonjs/ui/screens/LegalDocumentsScreen.js +2 -2
  97. package/lib/commonjs/ui/screens/LegalDocumentsScreen.js.map +1 -1
  98. package/lib/commonjs/ui/screens/OxyAuthScreen.js +9 -21
  99. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  100. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +2 -2
  101. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +1 -1
  102. package/lib/commonjs/ui/screens/ProfileScreen.js +1 -1
  103. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  104. package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +2 -2
  105. package/lib/commonjs/ui/screens/SessionManagementScreen.js +1 -1
  106. package/lib/commonjs/ui/screens/UserListScreen.js +411 -0
  107. package/lib/commonjs/ui/screens/UserListScreen.js.map +1 -0
  108. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +1 -1
  109. package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +1 -1
  110. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
  111. package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js +1 -1
  112. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  113. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +1 -1
  114. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
  115. package/lib/commonjs/ui/stores/authStore.js +4 -6
  116. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  117. package/lib/commonjs/ui/utils/colorUtils.js +43 -46
  118. package/lib/commonjs/ui/utils/colorUtils.js.map +1 -1
  119. package/lib/commonjs/ui/utils/fileManagement.js +1 -1
  120. package/lib/commonjs/ui/utils/themeUtils.js +29 -39
  121. package/lib/commonjs/ui/utils/themeUtils.js.map +1 -1
  122. package/lib/commonjs/ui/utils/{user-utils.js → userUtils.js} +1 -1
  123. package/lib/commonjs/ui/utils/userUtils.js.map +1 -0
  124. package/lib/commonjs/utils/errorUtils.js +0 -13
  125. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  126. package/lib/commonjs/utils/hookUtils.js +8 -8
  127. package/lib/commonjs/utils/hookUtils.js.map +1 -1
  128. package/lib/commonjs/utils/platform.js +129 -0
  129. package/lib/commonjs/utils/platform.js.map +1 -0
  130. package/lib/commonjs/web/WebOxyContext.js +273 -41
  131. package/lib/commonjs/web/WebOxyContext.js.map +1 -1
  132. package/lib/commonjs/web/index.js +177 -4
  133. package/lib/commonjs/web/index.js.map +1 -1
  134. package/lib/commonjs/web.js +12 -12
  135. package/lib/commonjs/web.js.map +1 -1
  136. package/lib/module/core/AuthManager.js +399 -0
  137. package/lib/module/core/AuthManager.js.map +1 -0
  138. package/lib/module/core/HttpService.js +39 -1
  139. package/lib/module/core/HttpService.js.map +1 -1
  140. package/lib/module/core/index.js +2 -0
  141. package/lib/module/core/index.js.map +1 -1
  142. package/lib/module/core/mixins/OxyServices.fedcm.js +38 -44
  143. package/lib/module/core/mixins/OxyServices.fedcm.js.map +1 -1
  144. package/lib/module/core/mixins/OxyServices.popup.js +9 -7
  145. package/lib/module/core/mixins/OxyServices.popup.js.map +1 -1
  146. package/lib/module/crypto/keyManager.js +16 -21
  147. package/lib/module/crypto/keyManager.js.map +1 -1
  148. package/lib/module/index.js +34 -3
  149. package/lib/module/index.js.map +1 -1
  150. package/lib/module/lib/sonner.js +11 -16
  151. package/lib/module/lib/sonner.js.map +1 -1
  152. package/lib/module/lib/sonner.native.js +19 -0
  153. package/lib/module/lib/sonner.native.js.map +1 -0
  154. package/lib/module/lib/sonner.web.js +19 -0
  155. package/lib/module/lib/sonner.web.js.map +1 -0
  156. package/lib/module/shared/index.js +37 -0
  157. package/lib/module/shared/index.js.map +1 -0
  158. package/lib/module/shared/utils/colorUtils.js +150 -0
  159. package/lib/module/shared/utils/colorUtils.js.map +1 -0
  160. package/lib/module/shared/utils/debugUtils.js +75 -0
  161. package/lib/module/shared/utils/debugUtils.js.map +1 -0
  162. package/lib/module/shared/utils/errorUtils.js +176 -0
  163. package/lib/module/shared/utils/errorUtils.js.map +1 -0
  164. package/lib/module/shared/utils/index.js +21 -0
  165. package/lib/module/shared/utils/index.js.map +1 -0
  166. package/lib/module/shared/utils/networkUtils.js +202 -0
  167. package/lib/module/shared/utils/networkUtils.js.map +1 -0
  168. package/lib/module/shared/utils/themeUtils.js +109 -0
  169. package/lib/module/shared/utils/themeUtils.js.map +1 -0
  170. package/lib/module/ui/client.js +1 -1
  171. package/lib/module/ui/client.js.map +1 -1
  172. package/lib/module/ui/components/BottomSheetRouter.js +1 -1
  173. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  174. package/lib/module/ui/components/FollowButton.js +1 -1
  175. package/lib/module/ui/components/FollowButton.js.map +1 -1
  176. package/lib/module/ui/components/FontLoader.js +1 -1
  177. package/lib/module/ui/components/FontLoader.js.map +1 -1
  178. package/lib/module/ui/components/GroupedItem.js +1 -1
  179. package/lib/module/ui/components/GroupedItem.js.map +1 -1
  180. package/lib/module/ui/components/Header.js +1 -1
  181. package/lib/module/ui/components/Header.js.map +1 -1
  182. package/lib/module/ui/components/OxyProvider.js +10 -2
  183. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  184. package/lib/module/ui/components/OxySignInButton.js +20 -21
  185. package/lib/module/ui/components/OxySignInButton.js.map +1 -1
  186. package/lib/module/ui/components/ProfileCard.js +1 -1
  187. package/lib/module/ui/components/ProfileCard.js.map +1 -1
  188. package/lib/module/ui/components/QuickActions.js +1 -1
  189. package/lib/module/ui/components/QuickActions.js.map +1 -1
  190. package/lib/module/ui/components/Section.js +1 -1
  191. package/lib/module/ui/components/Section.js.map +1 -1
  192. package/lib/module/ui/components/SectionTitle.js +1 -1
  193. package/lib/module/ui/components/SectionTitle.js.map +1 -1
  194. package/lib/module/ui/components/SignInModal.js +536 -0
  195. package/lib/module/ui/components/SignInModal.js.map +1 -0
  196. package/lib/module/ui/components/payment/PaymentDetailsStep.js +1 -1
  197. package/lib/module/ui/components/payment/PaymentDetailsStep.js.map +1 -1
  198. package/lib/module/ui/context/OxyContext.js +2 -2
  199. package/lib/module/ui/context/OxyContext.js.map +1 -1
  200. package/lib/module/ui/hooks/mutations/mutationFactory.js +1 -1
  201. package/lib/module/ui/hooks/mutations/mutationFactory.js.map +1 -1
  202. package/lib/module/ui/hooks/mutations/useAccountMutations.js +1 -1
  203. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  204. package/lib/module/ui/hooks/mutations/useServicesMutations.js +1 -1
  205. package/lib/module/ui/hooks/mutations/useServicesMutations.js.map +1 -1
  206. package/lib/module/ui/hooks/useAsyncAction.js +1 -1
  207. package/lib/module/ui/hooks/useAsyncAction.js.map +1 -1
  208. package/lib/module/ui/hooks/{use-color-scheme.js → useColorScheme.js} +1 -1
  209. package/lib/module/ui/hooks/useColorScheme.js.map +1 -0
  210. package/lib/module/ui/hooks/useSessionSocket.js +7 -13
  211. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  212. package/lib/module/ui/hooks/useSettingToggle.js +1 -1
  213. package/lib/module/ui/hooks/useSettingToggle.js.map +1 -1
  214. package/lib/module/ui/hooks/useThemeColors.js +1 -1
  215. package/lib/module/ui/hooks/useThemeColors.js.map +1 -1
  216. package/lib/module/ui/hooks/useThemeStyles.js +1 -1
  217. package/lib/module/ui/hooks/useThemeStyles.js.map +1 -1
  218. package/lib/module/ui/navigation/bottomSheetManager.js +5 -2
  219. package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
  220. package/lib/module/ui/navigation/routes.js +7 -8
  221. package/lib/module/ui/navigation/routes.js.map +1 -1
  222. package/lib/module/ui/screens/AccountCenterScreen.js +8 -8
  223. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  224. package/lib/module/ui/screens/AccountOverviewScreen.js +7 -7
  225. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  226. package/lib/module/ui/screens/AccountSettingsScreen.js +3 -3
  227. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  228. package/lib/module/ui/screens/AccountSwitcherScreen.js +5 -5
  229. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  230. package/lib/module/ui/screens/AccountVerificationScreen.js +1 -1
  231. package/lib/module/ui/screens/AccountVerificationScreen.js.map +1 -1
  232. package/lib/module/ui/screens/AppInfoScreen.js +2 -2
  233. package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
  234. package/lib/module/ui/screens/EditProfileFieldScreen.js +2 -2
  235. package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
  236. package/lib/module/ui/screens/FAQScreen.js +1 -1
  237. package/lib/module/ui/screens/FAQScreen.js.map +1 -1
  238. package/lib/module/ui/screens/FeedbackScreen.js +1 -1
  239. package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
  240. package/lib/module/ui/screens/FileManagementScreen.js +2 -2
  241. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  242. package/lib/module/ui/screens/FollowersListScreen.js +13 -0
  243. package/lib/module/ui/screens/FollowersListScreen.js.map +1 -0
  244. package/lib/module/ui/screens/FollowingListScreen.js +13 -0
  245. package/lib/module/ui/screens/FollowingListScreen.js.map +1 -0
  246. package/lib/module/ui/screens/HelpSupportScreen.js +2 -2
  247. package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -1
  248. package/lib/module/ui/screens/HistoryViewScreen.js +2 -2
  249. package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
  250. package/lib/module/ui/screens/LanguageSelectorScreen.js +2 -2
  251. package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
  252. package/lib/module/ui/screens/LearnMoreUsernamesScreen.js +224 -0
  253. package/lib/module/ui/screens/LearnMoreUsernamesScreen.js.map +1 -0
  254. package/lib/module/ui/screens/LegalDocumentsScreen.js +2 -2
  255. package/lib/module/ui/screens/LegalDocumentsScreen.js.map +1 -1
  256. package/lib/module/ui/screens/OxyAuthScreen.js +9 -21
  257. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  258. package/lib/module/ui/screens/PremiumSubscriptionScreen.js +2 -2
  259. package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  260. package/lib/module/ui/screens/PrivacySettingsScreen.js +1 -1
  261. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  262. package/lib/module/ui/screens/ProfileScreen.js +1 -1
  263. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  264. package/lib/module/ui/screens/SavesCollectionsScreen.js +2 -2
  265. package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
  266. package/lib/module/ui/screens/SessionManagementScreen.js +1 -1
  267. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  268. package/lib/module/ui/screens/UserListScreen.js +405 -0
  269. package/lib/module/ui/screens/UserListScreen.js.map +1 -0
  270. package/lib/module/ui/screens/WelcomeNewUserScreen.js +1 -1
  271. package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  272. package/lib/module/ui/screens/karma/KarmaAboutScreen.js +1 -1
  273. package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
  274. package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
  275. package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  276. package/lib/module/ui/screens/karma/KarmaFAQScreen.js +1 -1
  277. package/lib/module/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
  278. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  279. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  280. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +1 -1
  281. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  282. package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
  283. package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  284. package/lib/module/ui/stores/authStore.js +4 -6
  285. package/lib/module/ui/stores/authStore.js.map +1 -1
  286. package/lib/module/ui/utils/colorUtils.js +7 -40
  287. package/lib/module/ui/utils/colorUtils.js.map +1 -1
  288. package/lib/module/ui/utils/fileManagement.js +1 -1
  289. package/lib/module/ui/utils/fileManagement.js.map +1 -1
  290. package/lib/module/ui/utils/themeUtils.js +7 -35
  291. package/lib/module/ui/utils/themeUtils.js.map +1 -1
  292. package/lib/module/ui/utils/{user-utils.js → userUtils.js} +1 -1
  293. package/lib/module/ui/utils/userUtils.js.map +1 -0
  294. package/lib/module/utils/errorUtils.js +0 -7
  295. package/lib/module/utils/errorUtils.js.map +1 -1
  296. package/lib/module/utils/hookUtils.js +8 -8
  297. package/lib/module/utils/hookUtils.js.map +1 -1
  298. package/lib/module/utils/platform.js +118 -0
  299. package/lib/module/utils/platform.js.map +1 -0
  300. package/lib/module/web/WebOxyContext.js +272 -41
  301. package/lib/module/web/WebOxyContext.js.map +1 -1
  302. package/lib/module/web/index.js +26 -5
  303. package/lib/module/web/index.js.map +1 -1
  304. package/lib/module/web.js +2 -1
  305. package/lib/module/web.js.map +1 -1
  306. package/lib/typescript/commonjs/core/AuthManager.d.ts +144 -0
  307. package/lib/typescript/commonjs/core/AuthManager.d.ts.map +1 -0
  308. package/lib/typescript/commonjs/core/HttpService.d.ts.map +1 -1
  309. package/lib/typescript/commonjs/core/index.d.ts +2 -0
  310. package/lib/typescript/commonjs/core/index.d.ts.map +1 -1
  311. package/lib/typescript/commonjs/core/mixins/OxyServices.fedcm.d.ts.map +1 -1
  312. package/lib/typescript/commonjs/core/mixins/OxyServices.popup.d.ts.map +1 -1
  313. package/lib/typescript/commonjs/crypto/keyManager.d.ts.map +1 -1
  314. package/lib/typescript/commonjs/index.d.ts +16 -2
  315. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  316. package/lib/typescript/commonjs/lib/sonner.d.ts +11 -14
  317. package/lib/typescript/commonjs/lib/sonner.d.ts.map +1 -1
  318. package/lib/typescript/commonjs/lib/sonner.native.d.ts +15 -0
  319. package/lib/typescript/commonjs/lib/sonner.native.d.ts.map +1 -0
  320. package/lib/typescript/commonjs/lib/sonner.web.d.ts +15 -0
  321. package/lib/typescript/commonjs/lib/sonner.web.d.ts.map +1 -0
  322. package/lib/typescript/commonjs/models/session.d.ts +4 -0
  323. package/lib/typescript/commonjs/models/session.d.ts.map +1 -1
  324. package/lib/typescript/commonjs/shared/index.d.ts +29 -0
  325. package/lib/typescript/commonjs/shared/index.d.ts.map +1 -0
  326. package/lib/typescript/commonjs/shared/utils/colorUtils.d.ts +105 -0
  327. package/lib/typescript/commonjs/shared/utils/colorUtils.d.ts.map +1 -0
  328. package/lib/typescript/commonjs/shared/utils/debugUtils.d.ts +49 -0
  329. package/lib/typescript/commonjs/shared/utils/debugUtils.d.ts.map +1 -0
  330. package/lib/typescript/commonjs/shared/utils/errorUtils.d.ts +98 -0
  331. package/lib/typescript/commonjs/shared/utils/errorUtils.d.ts.map +1 -0
  332. package/lib/typescript/commonjs/shared/utils/index.d.ts +14 -0
  333. package/lib/typescript/commonjs/shared/utils/index.d.ts.map +1 -0
  334. package/lib/typescript/commonjs/shared/utils/networkUtils.d.ts +140 -0
  335. package/lib/typescript/commonjs/shared/utils/networkUtils.d.ts.map +1 -0
  336. package/lib/typescript/commonjs/shared/utils/themeUtils.d.ts +91 -0
  337. package/lib/typescript/commonjs/shared/utils/themeUtils.d.ts.map +1 -0
  338. package/lib/typescript/commonjs/ui/components/FontLoader.d.ts +1 -1
  339. package/lib/typescript/commonjs/ui/components/FontLoader.d.ts.map +1 -1
  340. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  341. package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts.map +1 -1
  342. package/lib/typescript/commonjs/ui/components/SignInModal.d.ts +18 -0
  343. package/lib/typescript/commonjs/ui/components/SignInModal.d.ts.map +1 -0
  344. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +1 -2
  345. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  346. package/lib/typescript/commonjs/ui/hooks/{use-color-scheme.d.ts → useColorScheme.d.ts} +1 -1
  347. package/lib/typescript/commonjs/ui/hooks/useColorScheme.d.ts.map +1 -0
  348. package/lib/typescript/commonjs/ui/hooks/useSessionSocket.d.ts.map +1 -1
  349. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +2 -0
  350. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  351. package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
  352. package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
  353. package/lib/typescript/commonjs/ui/screens/FollowersListScreen.d.ts +9 -0
  354. package/lib/typescript/commonjs/ui/screens/FollowersListScreen.d.ts.map +1 -0
  355. package/lib/typescript/commonjs/ui/screens/FollowingListScreen.d.ts +9 -0
  356. package/lib/typescript/commonjs/ui/screens/FollowingListScreen.d.ts.map +1 -0
  357. package/lib/typescript/commonjs/ui/screens/LearnMoreUsernamesScreen.d.ts +5 -0
  358. package/lib/typescript/commonjs/ui/screens/LearnMoreUsernamesScreen.d.ts.map +1 -0
  359. package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  360. package/lib/typescript/commonjs/ui/screens/UserListScreen.d.ts +11 -0
  361. package/lib/typescript/commonjs/ui/screens/UserListScreen.d.ts.map +1 -0
  362. package/lib/typescript/commonjs/ui/stores/authStore.d.ts.map +1 -1
  363. package/lib/typescript/commonjs/ui/utils/colorUtils.d.ts +7 -11
  364. package/lib/typescript/commonjs/ui/utils/colorUtils.d.ts.map +1 -1
  365. package/lib/typescript/commonjs/ui/utils/themeUtils.d.ts +6 -19
  366. package/lib/typescript/commonjs/ui/utils/themeUtils.d.ts.map +1 -1
  367. package/lib/typescript/commonjs/ui/utils/{user-utils.d.ts → userUtils.d.ts} +1 -1
  368. package/lib/typescript/commonjs/ui/utils/userUtils.d.ts.map +1 -0
  369. package/lib/typescript/commonjs/utils/errorUtils.d.ts +0 -6
  370. package/lib/typescript/commonjs/utils/errorUtils.d.ts.map +1 -1
  371. package/lib/typescript/commonjs/utils/platform.d.ts +41 -0
  372. package/lib/typescript/commonjs/utils/platform.d.ts.map +1 -0
  373. package/lib/typescript/commonjs/web/WebOxyContext.d.ts +117 -9
  374. package/lib/typescript/commonjs/web/WebOxyContext.d.ts.map +1 -1
  375. package/lib/typescript/commonjs/web/index.d.ts +19 -8
  376. package/lib/typescript/commonjs/web/index.d.ts.map +1 -1
  377. package/lib/typescript/commonjs/web.d.ts +2 -1
  378. package/lib/typescript/commonjs/web.d.ts.map +1 -1
  379. package/lib/typescript/module/core/AuthManager.d.ts +144 -0
  380. package/lib/typescript/module/core/AuthManager.d.ts.map +1 -0
  381. package/lib/typescript/module/core/HttpService.d.ts.map +1 -1
  382. package/lib/typescript/module/core/index.d.ts +2 -0
  383. package/lib/typescript/module/core/index.d.ts.map +1 -1
  384. package/lib/typescript/module/core/mixins/OxyServices.fedcm.d.ts.map +1 -1
  385. package/lib/typescript/module/core/mixins/OxyServices.popup.d.ts.map +1 -1
  386. package/lib/typescript/module/crypto/keyManager.d.ts.map +1 -1
  387. package/lib/typescript/module/index.d.ts +16 -2
  388. package/lib/typescript/module/index.d.ts.map +1 -1
  389. package/lib/typescript/module/lib/sonner.d.ts +11 -14
  390. package/lib/typescript/module/lib/sonner.d.ts.map +1 -1
  391. package/lib/typescript/module/lib/sonner.native.d.ts +15 -0
  392. package/lib/typescript/module/lib/sonner.native.d.ts.map +1 -0
  393. package/lib/typescript/module/lib/sonner.web.d.ts +15 -0
  394. package/lib/typescript/module/lib/sonner.web.d.ts.map +1 -0
  395. package/lib/typescript/module/models/session.d.ts +4 -0
  396. package/lib/typescript/module/models/session.d.ts.map +1 -1
  397. package/lib/typescript/module/shared/index.d.ts +29 -0
  398. package/lib/typescript/module/shared/index.d.ts.map +1 -0
  399. package/lib/typescript/module/shared/utils/colorUtils.d.ts +105 -0
  400. package/lib/typescript/module/shared/utils/colorUtils.d.ts.map +1 -0
  401. package/lib/typescript/module/shared/utils/debugUtils.d.ts +49 -0
  402. package/lib/typescript/module/shared/utils/debugUtils.d.ts.map +1 -0
  403. package/lib/typescript/module/shared/utils/errorUtils.d.ts +98 -0
  404. package/lib/typescript/module/shared/utils/errorUtils.d.ts.map +1 -0
  405. package/lib/typescript/module/shared/utils/index.d.ts +14 -0
  406. package/lib/typescript/module/shared/utils/index.d.ts.map +1 -0
  407. package/lib/typescript/module/shared/utils/networkUtils.d.ts +140 -0
  408. package/lib/typescript/module/shared/utils/networkUtils.d.ts.map +1 -0
  409. package/lib/typescript/module/shared/utils/themeUtils.d.ts +91 -0
  410. package/lib/typescript/module/shared/utils/themeUtils.d.ts.map +1 -0
  411. package/lib/typescript/module/ui/components/FontLoader.d.ts +1 -1
  412. package/lib/typescript/module/ui/components/FontLoader.d.ts.map +1 -1
  413. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  414. package/lib/typescript/module/ui/components/OxySignInButton.d.ts.map +1 -1
  415. package/lib/typescript/module/ui/components/SignInModal.d.ts +18 -0
  416. package/lib/typescript/module/ui/components/SignInModal.d.ts.map +1 -0
  417. package/lib/typescript/module/ui/context/OxyContext.d.ts +1 -2
  418. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  419. package/lib/typescript/module/ui/hooks/{use-color-scheme.d.ts → useColorScheme.d.ts} +1 -1
  420. package/lib/typescript/module/ui/hooks/useColorScheme.d.ts.map +1 -0
  421. package/lib/typescript/module/ui/hooks/useSessionSocket.d.ts.map +1 -1
  422. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +2 -0
  423. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  424. package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
  425. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  426. package/lib/typescript/module/ui/screens/FollowersListScreen.d.ts +9 -0
  427. package/lib/typescript/module/ui/screens/FollowersListScreen.d.ts.map +1 -0
  428. package/lib/typescript/module/ui/screens/FollowingListScreen.d.ts +9 -0
  429. package/lib/typescript/module/ui/screens/FollowingListScreen.d.ts.map +1 -0
  430. package/lib/typescript/module/ui/screens/LearnMoreUsernamesScreen.d.ts +5 -0
  431. package/lib/typescript/module/ui/screens/LearnMoreUsernamesScreen.d.ts.map +1 -0
  432. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  433. package/lib/typescript/module/ui/screens/UserListScreen.d.ts +11 -0
  434. package/lib/typescript/module/ui/screens/UserListScreen.d.ts.map +1 -0
  435. package/lib/typescript/module/ui/stores/authStore.d.ts.map +1 -1
  436. package/lib/typescript/module/ui/utils/colorUtils.d.ts +7 -11
  437. package/lib/typescript/module/ui/utils/colorUtils.d.ts.map +1 -1
  438. package/lib/typescript/module/ui/utils/themeUtils.d.ts +6 -19
  439. package/lib/typescript/module/ui/utils/themeUtils.d.ts.map +1 -1
  440. package/lib/typescript/module/ui/utils/{user-utils.d.ts → userUtils.d.ts} +1 -1
  441. package/lib/typescript/module/ui/utils/userUtils.d.ts.map +1 -0
  442. package/lib/typescript/module/utils/errorUtils.d.ts +0 -6
  443. package/lib/typescript/module/utils/errorUtils.d.ts.map +1 -1
  444. package/lib/typescript/module/utils/platform.d.ts +41 -0
  445. package/lib/typescript/module/utils/platform.d.ts.map +1 -0
  446. package/lib/typescript/module/web/WebOxyContext.d.ts +117 -9
  447. package/lib/typescript/module/web/WebOxyContext.d.ts.map +1 -1
  448. package/lib/typescript/module/web/index.d.ts +19 -8
  449. package/lib/typescript/module/web/index.d.ts.map +1 -1
  450. package/lib/typescript/module/web.d.ts +2 -1
  451. package/lib/typescript/module/web.d.ts.map +1 -1
  452. package/package.json +8 -2
  453. package/src/core/AuthManager.ts +436 -0
  454. package/src/core/HttpService.ts +43 -1
  455. package/src/core/index.ts +4 -0
  456. package/src/core/mixins/OxyServices.fedcm.ts +37 -42
  457. package/src/core/mixins/OxyServices.popup.ts +10 -7
  458. package/src/crypto/keyManager.ts +16 -21
  459. package/src/index.ts +83 -12
  460. package/src/lib/sonner.native.ts +28 -0
  461. package/src/lib/sonner.ts +11 -28
  462. package/src/lib/sonner.web.ts +28 -0
  463. package/src/models/session.ts +4 -0
  464. package/src/shared/index.ts +82 -0
  465. package/src/shared/utils/colorUtils.ts +155 -0
  466. package/src/shared/utils/debugUtils.ts +73 -0
  467. package/src/shared/utils/errorUtils.ts +181 -0
  468. package/src/shared/utils/index.ts +59 -0
  469. package/src/shared/utils/networkUtils.ts +248 -0
  470. package/src/shared/utils/themeUtils.ts +115 -0
  471. package/src/ui/components/BottomSheetRouter.tsx +1 -1
  472. package/src/ui/components/FontLoader.tsx +1 -2
  473. package/src/ui/components/GroupedItem.tsx +1 -1
  474. package/src/ui/components/Header.tsx +1 -1
  475. package/src/ui/components/OxyProvider.tsx +10 -0
  476. package/src/ui/components/OxySignInButton.tsx +20 -22
  477. package/src/ui/components/ProfileCard.tsx +1 -1
  478. package/src/ui/components/QuickActions.tsx +1 -1
  479. package/src/ui/components/Section.tsx +1 -1
  480. package/src/ui/components/SectionTitle.tsx +1 -1
  481. package/src/ui/components/SignInModal.tsx +534 -0
  482. package/src/ui/context/OxyContext.tsx +1 -2
  483. package/src/ui/hooks/queries/queryKeys.ts +2 -2
  484. package/src/ui/hooks/useSessionSocket.ts +12 -17
  485. package/src/ui/hooks/useThemeColors.ts +1 -1
  486. package/src/ui/hooks/useThemeStyles.ts +1 -1
  487. package/src/ui/navigation/bottomSheetManager.ts +5 -1
  488. package/src/ui/navigation/routes.ts +8 -9
  489. package/src/ui/screens/AccountCenterScreen.tsx +7 -7
  490. package/src/ui/screens/AccountOverviewScreen.tsx +6 -6
  491. package/src/ui/screens/AccountSettingsScreen.tsx +2 -2
  492. package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
  493. package/src/ui/screens/AppInfoScreen.tsx +1 -1
  494. package/src/ui/screens/EditProfileFieldScreen.tsx +1 -1
  495. package/src/ui/screens/FileManagementScreen.tsx +1 -1
  496. package/src/ui/screens/FollowersListScreen.tsx +14 -0
  497. package/src/ui/screens/FollowingListScreen.tsx +14 -0
  498. package/src/ui/screens/HelpSupportScreen.tsx +1 -1
  499. package/src/ui/screens/HistoryViewScreen.tsx +1 -1
  500. package/src/ui/screens/LanguageSelectorScreen.tsx +1 -1
  501. package/src/ui/screens/LearnMoreUsernamesScreen.tsx +231 -0
  502. package/src/ui/screens/LegalDocumentsScreen.tsx +1 -1
  503. package/src/ui/screens/OxyAuthScreen.tsx +10 -21
  504. package/src/ui/screens/PremiumSubscriptionScreen.tsx +1 -1
  505. package/src/ui/screens/ProfileScreen.tsx +1 -1
  506. package/src/ui/screens/SavesCollectionsScreen.tsx +1 -1
  507. package/src/ui/screens/UserListScreen.tsx +416 -0
  508. package/src/ui/screens/karma/KarmaAboutScreen.tsx +1 -1
  509. package/src/ui/screens/karma/KarmaCenterScreen.tsx +1 -1
  510. package/src/ui/screens/karma/KarmaFAQScreen.tsx +1 -1
  511. package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +1 -1
  512. package/src/ui/screens/karma/KarmaRewardsScreen.tsx +1 -1
  513. package/src/ui/screens/karma/KarmaRulesScreen.tsx +1 -1
  514. package/src/ui/stores/authStore.ts +5 -6
  515. package/src/ui/utils/colorUtils.ts +15 -43
  516. package/src/ui/utils/themeUtils.ts +14 -39
  517. package/src/utils/errorUtils.ts +1 -6
  518. package/src/utils/hookUtils.ts +8 -8
  519. package/src/utils/platform.ts +117 -0
  520. package/src/web/WebOxyContext.tsx +331 -41
  521. package/src/web/index.ts +76 -6
  522. package/src/web.ts +1 -1
  523. package/lib/commonjs/ui/hooks/use-color-scheme.js.map +0 -1
  524. package/lib/commonjs/ui/utils/user-utils.js.map +0 -1
  525. package/lib/module/ui/hooks/use-color-scheme.js.map +0 -1
  526. package/lib/module/ui/utils/user-utils.js.map +0 -1
  527. package/lib/typescript/commonjs/ui/hooks/use-color-scheme.d.ts.map +0 -1
  528. package/lib/typescript/commonjs/ui/utils/user-utils.d.ts.map +0 -1
  529. package/lib/typescript/module/ui/hooks/use-color-scheme.d.ts.map +0 -1
  530. package/lib/typescript/module/ui/utils/user-utils.d.ts.map +0 -1
  531. /package/src/ui/hooks/{use-color-scheme.ts → useColorScheme.ts} +0 -0
  532. /package/src/ui/utils/{user-utils.ts → userUtils.ts} +0 -0
package/README.md CHANGED
@@ -23,7 +23,7 @@ A comprehensive TypeScript client library for the Oxy API providing authenticati
23
23
  ## ✨ Features
24
24
 
25
25
  - 🔐 **Zero-Config Authentication**: Automatic token management and refresh
26
- - 🌐 **Cross-Domain SSO**: Sign in once, authenticated everywhere (FedCM-based)
26
+ - 🌐 **Cross-Domain SSO**: Sign in once, authenticated everywhere (FedCM, popup, redirect)
27
27
  - 📱 **Universal Provider**: Single `OxyProvider` works on iOS, Android, and Web
28
28
  - 🎨 **UI Components**: Pre-built components for auth, profiles, and more
29
29
  - ✍️ **Inter Font Included**: Default Oxy ecosystem font with automatic loading
@@ -33,6 +33,20 @@ A comprehensive TypeScript client library for the Oxy API providing authenticati
33
33
  - 🚀 **Performance Optimized**: Automatic caching with TanStack Query
34
34
  - 🛡️ **Production Ready**: Error handling, retry logic, and security best practices
35
35
 
36
+ ## 🏗️ Architecture
37
+
38
+ OxyServices uses a modular architecture with multiple entry points for different use cases:
39
+
40
+ | Entry Point | Use Case | Dependencies |
41
+ |------------|----------|--------------|
42
+ | `@oxyhq/services` | Expo apps (native + web) | Full (RN, Expo) |
43
+ | `@oxyhq/services/web` | Pure React apps (Vite, Next.js) | React only |
44
+ | `@oxyhq/services/core` | Node.js / Backend | None |
45
+ | `@oxyhq/services/shared` | Utilities anywhere | None |
46
+ | `@oxyhq/services/crypto` | Identity management | Node crypto |
47
+
48
+ 📖 **[Complete Architecture Guide](./docs/ARCHITECTURE.md)**
49
+
36
50
  ## 📦 Installation
37
51
 
38
52
  ```bash
@@ -111,6 +125,25 @@ function App() {
111
125
  </WebOxyProvider>
112
126
  );
113
127
  }
128
+
129
+ function LoginButton() {
130
+ const { signIn, signOut, user, isAuthenticated, isFedCMSupported } = useAuth();
131
+
132
+ if (isAuthenticated) {
133
+ return (
134
+ <div>
135
+ <p>Welcome, {user?.username}!</p>
136
+ <button onClick={signOut}>Sign Out</button>
137
+ </div>
138
+ );
139
+ }
140
+
141
+ return (
142
+ <button onClick={signIn}>
143
+ {isFedCMSupported() ? 'Sign in with Oxy' : 'Sign in'}
144
+ </button>
145
+ );
146
+ }
114
147
  ```
115
148
 
116
149
  ⚠️ **Important:** If you're using Expo, always use `OxyProvider` instead - it already handles web in addition to native platforms. Never use `WebOxyProvider` in Expo apps.
@@ -127,10 +160,28 @@ import { WebOxyProvider, useAuth, OxyServices } from '@oxyhq/services/web';
127
160
  import { WebOxyProvider } from '@oxyhq/services';
128
161
  ```
129
162
 
163
+ **Authentication Methods Available:**
164
+ - **FedCM** (Browser-native, Google-style) - Best UX, no popups
165
+ - **Popup** - OAuth2-style popup window
166
+ - **Redirect** - Full page redirect (fallback)
167
+
168
+ ```typescript
169
+ const { signIn, signInWithFedCM, signInWithPopup, signInWithRedirect, isFedCMSupported } = useAuth();
170
+
171
+ // Auto-select best method (FedCM → Popup → Redirect)
172
+ await signIn();
173
+
174
+ // Or use specific method
175
+ await signInWithFedCM();
176
+ await signInWithPopup();
177
+ signInWithRedirect();
178
+ ```
179
+
130
180
  **Benefits:**
131
181
  - Smaller bundle size (no React Native dependencies)
132
182
  - No need for react-native-web or complex build configuration
133
183
  - Faster builds and smaller production bundles
184
+ - Full FedCM support for modern browsers
134
185
  - All web-compatible features included (auth, hooks, stores, etc.)
135
186
 
136
187
  **Note:** If you must use the main entry point (`@oxyhq/services`), you'll need to configure your bundler with react-native-web aliases. See the [Web Bundler Configuration](#web-bundler-configuration) section below.
@@ -177,16 +228,18 @@ app.listen(3000);
177
228
 
178
229
  **Inter is the default font for all Oxy ecosystem apps.** This package includes the Inter font family and provides automatic font loading for both web and native platforms.
179
230
 
180
- ### Quick Setup
231
+ ### Automatic Loading
232
+
233
+ **If you're using `OxyProvider`, fonts are loaded automatically.** No additional setup needed:
181
234
 
182
235
  ```typescript
183
- import { FontLoader, fontFamilies, fontStyles } from '@oxyhq/services';
236
+ import { OxyProvider } from '@oxyhq/services';
184
237
 
185
238
  function App() {
186
239
  return (
187
- <FontLoader>
240
+ <OxyProvider baseURL="https://api.oxy.so">
188
241
  <YourAppContent />
189
- </FontLoader>
242
+ </OxyProvider>
190
243
  );
191
244
  }
192
245
  ```
@@ -210,8 +263,7 @@ const styles = StyleSheet.create({
210
263
 
211
264
  ### Available Exports
212
265
 
213
- - **`FontLoader`** - Component that loads Inter fonts automatically
214
- - **`setupFonts()`** - Function to manually load fonts
266
+ - **`setupFonts()`** - Function to manually load fonts (called automatically by OxyProvider)
215
267
  - **`fontFamilies`** - Object with all Inter weight variants (inter, interLight, interMedium, interSemiBold, interBold, interExtraBold, interBlack)
216
268
  - **`fontStyles`** - Pre-defined text styles (titleLarge, titleMedium, titleSmall, buttonText)
217
269
 
@@ -729,7 +781,7 @@ function AuthModal({ visible, onRequestClose }: { visible: boolean; onRequestClo
729
781
  <Modal visible onRequestClose={onRequestClose} animationType="slide">
730
782
  <OxyRouter
731
783
  oxyServices={oxyServices}
732
- initialScreen="SignIn"
784
+ initialScreen="OxyAuth"
733
785
  onClose={onRequestClose}
734
786
  onAuthenticated={onRequestClose}
735
787
  theme="light"
@@ -0,0 +1,405 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AuthManager = void 0;
7
+ exports.createAuthManager = createAuthManager;
8
+ /**
9
+ * AuthManager - Centralized Authentication Manager
10
+ *
11
+ * Provides a unified authentication interface for all platforms.
12
+ * Handles token storage, session management, and auth state changes.
13
+ *
14
+ * @module core/AuthManager
15
+ */
16
+
17
+ /**
18
+ * OxyServices with optional FedCM methods (provided by FedCM mixin).
19
+ */
20
+
21
+ /**
22
+ * Storage adapter interface for platform-agnostic storage.
23
+ */
24
+
25
+ /**
26
+ * Auth state change callback type.
27
+ */
28
+
29
+ /**
30
+ * Auth method types.
31
+ */
32
+
33
+ /**
34
+ * Auth manager configuration.
35
+ */
36
+
37
+ /**
38
+ * Storage keys used by AuthManager.
39
+ */
40
+ const STORAGE_KEYS = {
41
+ ACCESS_TOKEN: 'oxy_access_token',
42
+ REFRESH_TOKEN: 'oxy_refresh_token',
43
+ SESSION: 'oxy_session',
44
+ USER: 'oxy_user',
45
+ AUTH_METHOD: 'oxy_auth_method'
46
+ };
47
+
48
+ /**
49
+ * Default in-memory storage for non-browser environments.
50
+ */
51
+ class MemoryStorage {
52
+ store = new Map();
53
+ getItem(key) {
54
+ return this.store.get(key) ?? null;
55
+ }
56
+ setItem(key, value) {
57
+ this.store.set(key, value);
58
+ }
59
+ removeItem(key) {
60
+ this.store.delete(key);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Browser localStorage adapter.
66
+ */
67
+ class LocalStorageAdapter {
68
+ getItem(key) {
69
+ if (typeof window === 'undefined') return null;
70
+ try {
71
+ return localStorage.getItem(key);
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+ setItem(key, value) {
77
+ if (typeof window === 'undefined') return;
78
+ try {
79
+ localStorage.setItem(key, value);
80
+ } catch {
81
+ // Storage full or blocked
82
+ }
83
+ }
84
+ removeItem(key) {
85
+ if (typeof window === 'undefined') return;
86
+ try {
87
+ localStorage.removeItem(key);
88
+ } catch {
89
+ // Ignore errors
90
+ }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * AuthManager - Centralized authentication management.
96
+ *
97
+ * Provides a single point of control for:
98
+ * - Token storage and retrieval
99
+ * - Session management
100
+ * - Auth state change notifications
101
+ * - Multiple auth method support
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const authManager = new AuthManager(oxyServices);
106
+ *
107
+ * // Listen for auth changes
108
+ * authManager.onAuthStateChange((user) => {
109
+ * console.log('Auth state changed:', user);
110
+ * });
111
+ *
112
+ * // Handle successful auth
113
+ * await authManager.handleAuthSuccess(session);
114
+ *
115
+ * // Sign out
116
+ * await authManager.signOut();
117
+ * ```
118
+ */
119
+ class AuthManager {
120
+ listeners = new Set();
121
+ currentUser = null;
122
+ refreshTimer = null;
123
+ constructor(oxyServices, config = {}) {
124
+ this.oxyServices = oxyServices;
125
+ this.config = {
126
+ storage: config.storage ?? this.getDefaultStorage(),
127
+ autoRefresh: config.autoRefresh ?? true,
128
+ refreshBuffer: config.refreshBuffer ?? 5 * 60 * 1000 // 5 minutes
129
+ };
130
+ this.storage = this.config.storage;
131
+ }
132
+
133
+ /**
134
+ * Get default storage based on environment.
135
+ */
136
+ getDefaultStorage() {
137
+ if (typeof window !== 'undefined' && window.localStorage) {
138
+ return new LocalStorageAdapter();
139
+ }
140
+ return new MemoryStorage();
141
+ }
142
+
143
+ /**
144
+ * Subscribe to auth state changes.
145
+ *
146
+ * @param callback - Function called when auth state changes
147
+ * @returns Unsubscribe function
148
+ */
149
+ onAuthStateChange(callback) {
150
+ this.listeners.add(callback);
151
+ // Call immediately with current state
152
+ callback(this.currentUser);
153
+ return () => {
154
+ this.listeners.delete(callback);
155
+ };
156
+ }
157
+
158
+ /**
159
+ * Notify all listeners of auth state change.
160
+ */
161
+ notifyListeners() {
162
+ for (const listener of this.listeners) {
163
+ try {
164
+ listener(this.currentUser);
165
+ } catch {
166
+ // Ignore listener errors
167
+ }
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Handle successful authentication.
173
+ *
174
+ * @param session - Session response from auth
175
+ * @param method - Auth method used
176
+ */
177
+ async handleAuthSuccess(session, method = 'credentials') {
178
+ // Store tokens
179
+ if (session.accessToken) {
180
+ await this.storage.setItem(STORAGE_KEYS.ACCESS_TOKEN, session.accessToken);
181
+ this.oxyServices.httpService.setTokens(session.accessToken);
182
+ }
183
+
184
+ // Store refresh token if available
185
+ if (session.refreshToken) {
186
+ await this.storage.setItem(STORAGE_KEYS.REFRESH_TOKEN, session.refreshToken);
187
+ }
188
+
189
+ // Store session info
190
+ await this.storage.setItem(STORAGE_KEYS.SESSION, JSON.stringify({
191
+ sessionId: session.sessionId,
192
+ deviceId: session.deviceId,
193
+ expiresAt: session.expiresAt
194
+ }));
195
+
196
+ // Store user only if it has valid required fields (not an empty placeholder)
197
+ if (session.user && typeof session.user.id === 'string' && session.user.id.length > 0) {
198
+ await this.storage.setItem(STORAGE_KEYS.USER, JSON.stringify(session.user));
199
+ this.currentUser = session.user;
200
+ }
201
+
202
+ // Store auth method
203
+ await this.storage.setItem(STORAGE_KEYS.AUTH_METHOD, method);
204
+
205
+ // Setup auto-refresh if enabled
206
+ if (this.config.autoRefresh && session.expiresAt) {
207
+ this.setupTokenRefresh(session.expiresAt);
208
+ }
209
+
210
+ // Notify listeners
211
+ this.notifyListeners();
212
+ }
213
+
214
+ /**
215
+ * Setup automatic token refresh.
216
+ */
217
+ setupTokenRefresh(expiresAt) {
218
+ if (this.refreshTimer) {
219
+ clearTimeout(this.refreshTimer);
220
+ }
221
+ const expiresAtMs = new Date(expiresAt).getTime();
222
+ const now = Date.now();
223
+ const refreshAt = expiresAtMs - this.config.refreshBuffer;
224
+ const delay = Math.max(0, refreshAt - now);
225
+ if (delay > 0) {
226
+ this.refreshTimer = setTimeout(() => {
227
+ this.refreshToken().catch(() => {
228
+ // Refresh failed, user will need to re-auth
229
+ });
230
+ }, delay);
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Refresh the access token.
236
+ */
237
+ async refreshToken() {
238
+ const refreshToken = await this.storage.getItem(STORAGE_KEYS.REFRESH_TOKEN);
239
+ if (!refreshToken) {
240
+ return false;
241
+ }
242
+ try {
243
+ // Cast httpService to proper type (needed due to mixin composition)
244
+ const httpService = this.oxyServices.httpService;
245
+ const response = await httpService.request({
246
+ method: 'POST',
247
+ url: '/api/auth/refresh',
248
+ data: {
249
+ refreshToken
250
+ },
251
+ cache: false
252
+ });
253
+ await this.handleAuthSuccess(response, 'credentials');
254
+ return true;
255
+ } catch {
256
+ // Refresh failed, clear session and update state
257
+ await this.clearSession();
258
+ this.currentUser = null;
259
+ this.notifyListeners();
260
+ return false;
261
+ }
262
+ }
263
+
264
+ /**
265
+ * Sign out and clear all auth data.
266
+ */
267
+ async signOut() {
268
+ // Clear refresh timer
269
+ if (this.refreshTimer) {
270
+ clearTimeout(this.refreshTimer);
271
+ this.refreshTimer = null;
272
+ }
273
+
274
+ // Revoke FedCM credential if supported
275
+ try {
276
+ const services = this.oxyServices;
277
+ if (services.revokeFedCMCredential) {
278
+ await services.revokeFedCMCredential();
279
+ }
280
+ } catch {
281
+ // Ignore FedCM errors
282
+ }
283
+
284
+ // Clear HTTP client tokens
285
+ this.oxyServices.httpService.setTokens('');
286
+
287
+ // Clear storage
288
+ await this.clearSession();
289
+
290
+ // Update state and notify
291
+ this.currentUser = null;
292
+ this.notifyListeners();
293
+ }
294
+
295
+ /**
296
+ * Clear session data from storage.
297
+ */
298
+ async clearSession() {
299
+ await this.storage.removeItem(STORAGE_KEYS.ACCESS_TOKEN);
300
+ await this.storage.removeItem(STORAGE_KEYS.REFRESH_TOKEN);
301
+ await this.storage.removeItem(STORAGE_KEYS.SESSION);
302
+ await this.storage.removeItem(STORAGE_KEYS.USER);
303
+ await this.storage.removeItem(STORAGE_KEYS.AUTH_METHOD);
304
+ }
305
+
306
+ /**
307
+ * Get current user.
308
+ */
309
+ getCurrentUser() {
310
+ return this.currentUser;
311
+ }
312
+
313
+ /**
314
+ * Check if user is authenticated.
315
+ */
316
+ isAuthenticated() {
317
+ return this.currentUser !== null;
318
+ }
319
+
320
+ /**
321
+ * Get stored access token.
322
+ */
323
+ async getAccessToken() {
324
+ return this.storage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
325
+ }
326
+
327
+ /**
328
+ * Get the auth method used for current session.
329
+ */
330
+ async getAuthMethod() {
331
+ const method = await this.storage.getItem(STORAGE_KEYS.AUTH_METHOD);
332
+ return method;
333
+ }
334
+
335
+ /**
336
+ * Initialize auth state from storage.
337
+ *
338
+ * Call this on app startup to restore previous session.
339
+ */
340
+ async initialize() {
341
+ try {
342
+ // Try to restore user from storage
343
+ const userJson = await this.storage.getItem(STORAGE_KEYS.USER);
344
+ if (userJson) {
345
+ this.currentUser = JSON.parse(userJson);
346
+ }
347
+
348
+ // Restore token to HTTP client
349
+ const token = await this.storage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
350
+ if (token) {
351
+ this.oxyServices.httpService.setTokens(token);
352
+ }
353
+
354
+ // Check session expiry
355
+ const sessionJson = await this.storage.getItem(STORAGE_KEYS.SESSION);
356
+ if (sessionJson) {
357
+ const session = JSON.parse(sessionJson);
358
+ if (session.expiresAt) {
359
+ const expiresAt = new Date(session.expiresAt).getTime();
360
+ if (expiresAt <= Date.now()) {
361
+ // Session expired, try refresh
362
+ const refreshed = await this.refreshToken();
363
+ if (!refreshed) {
364
+ await this.clearSession();
365
+ this.currentUser = null;
366
+ }
367
+ } else if (this.config.autoRefresh) {
368
+ // Setup refresh timer
369
+ this.setupTokenRefresh(session.expiresAt);
370
+ }
371
+ }
372
+ }
373
+ return this.currentUser;
374
+ } catch {
375
+ // Failed to restore, start fresh
376
+ await this.clearSession();
377
+ this.currentUser = null;
378
+ return null;
379
+ }
380
+ }
381
+
382
+ /**
383
+ * Destroy the auth manager and clean up resources.
384
+ */
385
+ destroy() {
386
+ if (this.refreshTimer) {
387
+ clearTimeout(this.refreshTimer);
388
+ this.refreshTimer = null;
389
+ }
390
+ this.listeners.clear();
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Create an AuthManager instance.
396
+ *
397
+ * @param oxyServices - OxyServices instance
398
+ * @param config - Optional configuration
399
+ * @returns AuthManager instance
400
+ */
401
+ exports.AuthManager = AuthManager;
402
+ function createAuthManager(oxyServices, config) {
403
+ return new AuthManager(oxyServices, config);
404
+ }
405
+ //# sourceMappingURL=AuthManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["STORAGE_KEYS","ACCESS_TOKEN","REFRESH_TOKEN","SESSION","USER","AUTH_METHOD","MemoryStorage","store","Map","getItem","key","get","setItem","value","set","removeItem","delete","LocalStorageAdapter","window","localStorage","AuthManager","listeners","Set","currentUser","refreshTimer","constructor","oxyServices","config","storage","getDefaultStorage","autoRefresh","refreshBuffer","onAuthStateChange","callback","add","notifyListeners","listener","handleAuthSuccess","session","method","accessToken","httpService","setTokens","refreshToken","JSON","stringify","sessionId","deviceId","expiresAt","user","id","length","setupTokenRefresh","clearTimeout","expiresAtMs","Date","getTime","now","refreshAt","delay","Math","max","setTimeout","catch","response","request","url","data","cache","clearSession","signOut","services","revokeFedCMCredential","getCurrentUser","isAuthenticated","getAccessToken","getAuthMethod","initialize","userJson","parse","token","sessionJson","refreshed","destroy","clear","exports","createAuthManager"],"sourceRoot":"../../../src","sources":["core/AuthManager.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AACA,MAAMA,YAAY,GAAG;EACnBC,YAAY,EAAE,kBAAkB;EAChCC,aAAa,EAAE,mBAAmB;EAClCC,OAAO,EAAE,aAAa;EACtBC,IAAI,EAAE,UAAU;EAChBC,WAAW,EAAE;AACf,CAAU;;AAEV;AACA;AACA;AACA,MAAMC,aAAa,CAA2B;EACpCC,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAEzCC,OAAOA,CAACC,GAAW,EAAiB;IAClC,OAAO,IAAI,CAACH,KAAK,CAACI,GAAG,CAACD,GAAG,CAAC,IAAI,IAAI;EACpC;EAEAE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,CAACuC,SAAS,EAAE;cACd,MAAM,IAAI,CAACb,YAAY,CAAC,CAAC;cACzB,IAAI,CAAC9C,WAAW,GAAG,IAAI;YACzB;UACF,CAAC,MAAM,IAAI,IAAI,CAACI,MAAM,CAACG,WAAW,EAAE;YAClC;YACA,IAAI,CAACsB,iBAAiB,CAACd,OAAO,CAACU,SAAS,CAAC;UAC3C;QACF;MACF;MAEA,OAAO,IAAI,CAACzB,WAAW;IACzB,CAAC,CAAC,MAAM;MACN;MACA,MAAM,IAAI,CAAC8C,YAAY,CAAC,CAAC;MACzB,IAAI,CAAC9C,WAAW,GAAG,IAAI;MACvB,OAAO,IAAI;IACb;EACF;;EAEA;AACF;AACA;EACE4D,OAAOA,CAAA,EAAS;IACd,IAAI,IAAI,CAAC3D,YAAY,EAAE;MACrB6B,YAAY,CAAC,IAAI,CAAC7B,YAAY,CAAC;MAC/B,IAAI,CAACA,YAAY,GAAG,IAAI;IAC1B;IACA,IAAI,CAACH,SAAS,CAAC+D,KAAK,CAAC,CAAC;EACxB;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANAC,OAAA,CAAAjE,WAAA,GAAAA,WAAA;AAOO,SAASkE,iBAAiBA,CAC/B5D,WAAwB,EACxBC,MAA0B,EACb;EACb,OAAO,IAAIP,WAAW,CAACM,WAAW,EAAEC,MAAM,CAAC;AAC7C","ignoreList":[]}
@@ -9,6 +9,7 @@ var _requestUtils = require("../utils/requestUtils.js");
9
9
  var _asyncUtils = require("../utils/asyncUtils.js");
10
10
  var _errorUtils = require("../utils/errorUtils.js");
11
11
  var _jwtDecode = require("jwt-decode");
12
+ var _platform = require("../utils/platform.js");
12
13
  /**
13
14
  * Unified HTTP Service
14
15
  *
@@ -24,6 +25,11 @@ var _jwtDecode = require("jwt-decode");
24
25
  * - Request queuing
25
26
  */
26
27
 
28
+ /**
29
+ * Check if we're running in a native app environment (React Native, not web)
30
+ * This is used to determine CSRF handling mode
31
+ */
32
+ const isNativeApp = (0, _platform.isNative)();
27
33
  /**
28
34
  * Token store for authentication (singleton)
29
35
  */
@@ -208,6 +214,26 @@ class HttpService {
208
214
  headers['X-CSRF-Token'] = csrfToken;
209
215
  }
210
216
 
217
+ // Add native app header for React Native (required for CSRF validation)
218
+ // Native apps can't persist cookies like browsers, so the server uses
219
+ // header-only CSRF validation when this header is present
220
+ if (isNativeApp && isStateChangingMethod) {
221
+ headers['X-Native-App'] = 'true';
222
+ }
223
+
224
+ // Debug logging for CSRF issues
225
+ if (isStateChangingMethod && __DEV__) {
226
+ console.log('[HttpService] CSRF Debug:', {
227
+ url,
228
+ method,
229
+ isNativeApp,
230
+ platformOS: (0, _platform.getPlatformOS)(),
231
+ hasCsrfToken: !!csrfToken,
232
+ csrfTokenLength: csrfToken?.length,
233
+ hasNativeAppHeader: headers['X-Native-App'] === 'true'
234
+ });
235
+ }
236
+
211
237
  // Merge custom headers if provided
212
238
  if (config.headers) {
213
239
  Object.entries(config.headers).forEach(([key, value]) => {
@@ -380,16 +406,23 @@ class HttpService {
380
406
  // Return cached token if available
381
407
  const cachedToken = this.tokenStore.getCsrfToken();
382
408
  if (cachedToken) {
409
+ if (__DEV__) console.log('[HttpService] Using cached CSRF token');
383
410
  return cachedToken;
384
411
  }
385
412
 
386
413
  // Deduplicate concurrent CSRF token fetches
387
414
  const existingPromise = this.tokenStore.getCsrfTokenFetchPromise();
388
415
  if (existingPromise) {
416
+ if (__DEV__) console.log('[HttpService] Waiting for existing CSRF fetch');
389
417
  return existingPromise;
390
418
  }
391
419
  const fetchPromise = (async () => {
392
420
  try {
421
+ if (__DEV__) console.log('[HttpService] Fetching CSRF token from:', `${this.baseURL}/api/csrf-token`);
422
+
423
+ // Use AbortController for timeout (more compatible than AbortSignal.timeout)
424
+ const controller = new AbortController();
425
+ const timeoutId = setTimeout(() => controller.abort(), 5000);
393
426
  const response = await fetch(`${this.baseURL}/api/csrf-token`, {
394
427
  method: 'GET',
395
428
  headers: {
@@ -397,10 +430,13 @@ class HttpService {
397
430
  },
398
431
  credentials: 'include',
399
432
  // Required to receive and send cookies
400
- signal: AbortSignal.timeout(5000)
433
+ signal: controller.signal
401
434
  });
435
+ clearTimeout(timeoutId);
436
+ if (__DEV__) console.log('[HttpService] CSRF fetch response:', response.status, response.ok);
402
437
  if (response.ok) {
403
438
  const data = await response.json();
439
+ if (__DEV__) console.log('[HttpService] CSRF response data:', data);
404
440
  const token = data.csrfToken || null;
405
441
  this.tokenStore.setCsrfToken(token);
406
442
  this.logger.debug('CSRF token fetched');
@@ -414,9 +450,11 @@ class HttpService {
414
450
  this.logger.debug('CSRF token from header');
415
451
  return headerToken;
416
452
  }
453
+ if (__DEV__) console.log('[HttpService] CSRF fetch failed with status:', response.status);
417
454
  this.logger.warn('Failed to fetch CSRF token:', response.status);
418
455
  return null;
419
456
  } catch (error) {
457
+ if (__DEV__) console.log('[HttpService] CSRF fetch error:', error);
420
458
  this.logger.warn('CSRF token fetch error:', error);
421
459
  return null;
422
460
  } finally {