@oxyhq/services 5.5.9 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/README.md +16 -2
  2. package/lib/commonjs/core/index.js +69 -82
  3. package/lib/commonjs/core/index.js.map +1 -1
  4. package/lib/commonjs/index.js +24 -183
  5. package/lib/commonjs/index.js.map +1 -1
  6. package/lib/commonjs/node/index.js +0 -2
  7. package/lib/commonjs/node/index.js.map +1 -1
  8. package/lib/commonjs/ui/components/FollowButton.js +100 -229
  9. package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
  10. package/lib/commonjs/ui/components/OxyPayButton.js +131 -0
  11. package/lib/commonjs/ui/components/OxyPayButton.js.map +1 -0
  12. package/lib/commonjs/ui/components/OxyProvider.js +41 -198
  13. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  14. package/lib/commonjs/ui/components/OxySignInButton.js +15 -2
  15. package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
  16. package/lib/commonjs/ui/components/icon/FAIRWalletIcon.js +66 -0
  17. package/lib/commonjs/ui/components/icon/FAIRWalletIcon.js.map +1 -0
  18. package/lib/commonjs/ui/components/icon/index.js +7 -0
  19. package/lib/commonjs/ui/components/icon/index.js.map +1 -1
  20. package/lib/commonjs/ui/components/index.js +7 -0
  21. package/lib/commonjs/ui/components/index.js.map +1 -1
  22. package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +14 -7
  23. package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
  24. package/lib/commonjs/ui/components/internal/PinInput.js +108 -0
  25. package/lib/commonjs/ui/components/internal/PinInput.js.map +1 -0
  26. package/lib/commonjs/ui/components/internal/TextField.js +20 -0
  27. package/lib/commonjs/ui/components/internal/TextField.js.map +1 -1
  28. package/lib/commonjs/ui/context/OxyContext.js +26 -36
  29. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  30. package/lib/commonjs/ui/hooks/index.js +2 -15
  31. package/lib/commonjs/ui/hooks/index.js.map +1 -1
  32. package/lib/commonjs/ui/hooks/useFollow.js +52 -136
  33. package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
  34. package/lib/commonjs/ui/hooks/useSessionSocket.js +52 -0
  35. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -0
  36. package/lib/commonjs/ui/index.js +8 -191
  37. package/lib/commonjs/ui/index.js.map +1 -1
  38. package/lib/commonjs/ui/navigation/OxyRouter.js +52 -60
  39. package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
  40. package/lib/commonjs/ui/screens/AccountCenterScreen.js +18 -30
  41. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  42. package/lib/commonjs/ui/screens/AccountOverviewScreen.js +4 -22
  43. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  44. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +6 -14
  45. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  46. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +37 -66
  47. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  48. package/lib/commonjs/ui/screens/AppInfoScreen.js +21 -44
  49. package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
  50. package/lib/commonjs/ui/screens/FeedbackScreen.js +44 -23
  51. package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
  52. package/lib/commonjs/ui/screens/FileManagementScreen.js +59 -78
  53. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  54. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +1588 -0
  55. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -0
  56. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +22 -36
  57. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  58. package/lib/commonjs/ui/screens/RecoverAccountScreen.js +269 -0
  59. package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -0
  60. package/lib/commonjs/ui/screens/SessionManagementScreen.js +47 -69
  61. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  62. package/lib/commonjs/ui/screens/SignInScreen.js +99 -333
  63. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  64. package/lib/commonjs/ui/screens/SignUpScreen.js +136 -340
  65. package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
  66. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +192 -0
  67. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -0
  68. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +135 -0
  69. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +1 -0
  70. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +108 -0
  71. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +1 -0
  72. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +126 -0
  73. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +1 -0
  74. package/lib/commonjs/ui/screens/internal/SignUpSummaryStep.js +84 -0
  75. package/lib/commonjs/ui/screens/internal/SignUpSummaryStep.js.map +1 -0
  76. package/lib/commonjs/ui/screens/internal/SignUpWelcomeStep.js +59 -0
  77. package/lib/commonjs/ui/screens/internal/SignUpWelcomeStep.js.map +1 -0
  78. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +15 -2
  79. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  80. package/lib/commonjs/ui/stores/authStore.js +31 -0
  81. package/lib/commonjs/ui/stores/authStore.js.map +1 -0
  82. package/lib/commonjs/ui/stores/followStore.js +124 -0
  83. package/lib/commonjs/ui/stores/followStore.js.map +1 -0
  84. package/lib/commonjs/ui/styles/index.js +0 -11
  85. package/lib/commonjs/ui/styles/index.js.map +1 -1
  86. package/lib/commonjs/ui/utils/confirmAction.js +28 -0
  87. package/lib/commonjs/ui/utils/confirmAction.js.map +1 -0
  88. package/lib/module/core/index.js +69 -81
  89. package/lib/module/core/index.js.map +1 -1
  90. package/lib/module/index.js +14 -17
  91. package/lib/module/index.js.map +1 -1
  92. package/lib/module/node/index.js +0 -3
  93. package/lib/module/node/index.js.map +1 -1
  94. package/lib/module/ui/components/FollowButton.js +100 -229
  95. package/lib/module/ui/components/FollowButton.js.map +1 -1
  96. package/lib/module/ui/components/OxyPayButton.js +125 -0
  97. package/lib/module/ui/components/OxyPayButton.js.map +1 -0
  98. package/lib/module/ui/components/OxyProvider.js +42 -199
  99. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  100. package/lib/module/ui/components/OxySignInButton.js +15 -2
  101. package/lib/module/ui/components/OxySignInButton.js.map +1 -1
  102. package/lib/module/ui/components/icon/FAIRWalletIcon.js +60 -0
  103. package/lib/module/ui/components/icon/FAIRWalletIcon.js.map +1 -0
  104. package/lib/module/ui/components/icon/index.js +1 -0
  105. package/lib/module/ui/components/icon/index.js.map +1 -1
  106. package/lib/module/ui/components/index.js +1 -0
  107. package/lib/module/ui/components/index.js.map +1 -1
  108. package/lib/module/ui/components/internal/GroupedPillButtons.js +15 -8
  109. package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
  110. package/lib/module/ui/components/internal/PinInput.js +103 -0
  111. package/lib/module/ui/components/internal/PinInput.js.map +1 -0
  112. package/lib/module/ui/components/internal/TextField.js +20 -0
  113. package/lib/module/ui/components/internal/TextField.js.map +1 -1
  114. package/lib/module/ui/context/OxyContext.js +26 -36
  115. package/lib/module/ui/context/OxyContext.js.map +1 -1
  116. package/lib/module/ui/hooks/index.js +1 -2
  117. package/lib/module/ui/hooks/index.js.map +1 -1
  118. package/lib/module/ui/hooks/useFollow.js +52 -137
  119. package/lib/module/ui/hooks/useFollow.js.map +1 -1
  120. package/lib/module/ui/hooks/useSessionSocket.js +47 -0
  121. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -0
  122. package/lib/module/ui/index.js +2 -13
  123. package/lib/module/ui/index.js.map +1 -1
  124. package/lib/module/ui/navigation/OxyRouter.js +53 -61
  125. package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
  126. package/lib/module/ui/screens/AccountCenterScreen.js +6 -18
  127. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  128. package/lib/module/ui/screens/AccountOverviewScreen.js +5 -23
  129. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  130. package/lib/module/ui/screens/AccountSettingsScreen.js +7 -15
  131. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  132. package/lib/module/ui/screens/AccountSwitcherScreen.js +38 -67
  133. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  134. package/lib/module/ui/screens/AppInfoScreen.js +22 -45
  135. package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
  136. package/lib/module/ui/screens/FeedbackScreen.js +44 -23
  137. package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
  138. package/lib/module/ui/screens/FileManagementScreen.js +59 -78
  139. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  140. package/lib/module/ui/screens/PaymentGatewayScreen.js +1583 -0
  141. package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -0
  142. package/lib/module/ui/screens/PremiumSubscriptionScreen.js +23 -37
  143. package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  144. package/lib/module/ui/screens/RecoverAccountScreen.js +263 -0
  145. package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -0
  146. package/lib/module/ui/screens/SessionManagementScreen.js +47 -69
  147. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  148. package/lib/module/ui/screens/SignInScreen.js +100 -334
  149. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  150. package/lib/module/ui/screens/SignUpScreen.js +137 -341
  151. package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
  152. package/lib/module/ui/screens/internal/SignInPasswordStep.js +186 -0
  153. package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -0
  154. package/lib/module/ui/screens/internal/SignInUsernameStep.js +129 -0
  155. package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +1 -0
  156. package/lib/module/ui/screens/internal/SignUpIdentityStep.js +102 -0
  157. package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +1 -0
  158. package/lib/module/ui/screens/internal/SignUpSecurityStep.js +120 -0
  159. package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +1 -0
  160. package/lib/module/ui/screens/internal/SignUpSummaryStep.js +79 -0
  161. package/lib/module/ui/screens/internal/SignUpSummaryStep.js.map +1 -0
  162. package/lib/module/ui/screens/internal/SignUpWelcomeStep.js +54 -0
  163. package/lib/module/ui/screens/internal/SignUpWelcomeStep.js.map +1 -0
  164. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +16 -3
  165. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  166. package/lib/module/ui/stores/authStore.js +27 -0
  167. package/lib/module/ui/stores/authStore.js.map +1 -0
  168. package/lib/module/ui/stores/followStore.js +120 -0
  169. package/lib/module/ui/stores/followStore.js.map +1 -0
  170. package/lib/module/ui/styles/index.js +0 -1
  171. package/lib/module/ui/styles/index.js.map +1 -1
  172. package/lib/module/ui/utils/confirmAction.js +25 -0
  173. package/lib/module/ui/utils/confirmAction.js.map +1 -0
  174. package/lib/typescript/core/index.d.ts +28 -10
  175. package/lib/typescript/core/index.d.ts.map +1 -1
  176. package/lib/typescript/index.d.ts +5 -4
  177. package/lib/typescript/index.d.ts.map +1 -1
  178. package/lib/typescript/models/secureSession.d.ts +0 -1
  179. package/lib/typescript/models/secureSession.d.ts.map +1 -1
  180. package/lib/typescript/node/index.d.ts +0 -1
  181. package/lib/typescript/node/index.d.ts.map +1 -1
  182. package/lib/typescript/ui/components/FollowButton.d.ts +1 -77
  183. package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
  184. package/lib/typescript/ui/components/OxyPayButton.d.ts +29 -0
  185. package/lib/typescript/ui/components/OxyPayButton.d.ts.map +1 -0
  186. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  187. package/lib/typescript/ui/components/OxySignInButton.d.ts.map +1 -1
  188. package/lib/typescript/ui/components/icon/FAIRWalletIcon.d.ts +8 -0
  189. package/lib/typescript/ui/components/icon/FAIRWalletIcon.d.ts.map +1 -0
  190. package/lib/typescript/ui/components/icon/index.d.ts +1 -0
  191. package/lib/typescript/ui/components/icon/index.d.ts.map +1 -1
  192. package/lib/typescript/ui/components/index.d.ts +1 -0
  193. package/lib/typescript/ui/components/index.d.ts.map +1 -1
  194. package/lib/typescript/ui/components/internal/GroupedPillButtons.d.ts.map +1 -1
  195. package/lib/typescript/ui/components/internal/PinInput.d.ts +12 -0
  196. package/lib/typescript/ui/components/internal/PinInput.d.ts.map +1 -0
  197. package/lib/typescript/ui/components/internal/TextField.d.ts +1 -0
  198. package/lib/typescript/ui/components/internal/TextField.d.ts.map +1 -1
  199. package/lib/typescript/ui/context/OxyContext.d.ts +0 -2
  200. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  201. package/lib/typescript/ui/hooks/index.d.ts +1 -2
  202. package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
  203. package/lib/typescript/ui/hooks/useFollow.d.ts +14 -15
  204. package/lib/typescript/ui/hooks/useFollow.d.ts.map +1 -1
  205. package/lib/typescript/ui/hooks/useSessionSocket.d.ts +11 -0
  206. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -0
  207. package/lib/typescript/ui/index.d.ts +2 -5
  208. package/lib/typescript/ui/index.d.ts.map +1 -1
  209. package/lib/typescript/ui/navigation/OxyRouter.d.ts.map +1 -1
  210. package/lib/typescript/ui/navigation/types.d.ts +5 -23
  211. package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
  212. package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
  213. package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
  214. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  215. package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
  216. package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
  217. package/lib/typescript/ui/screens/FeedbackScreen.d.ts.map +1 -1
  218. package/lib/typescript/ui/screens/FileManagementScreen.d.ts.map +1 -1
  219. package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts +27 -0
  220. package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -0
  221. package/lib/typescript/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
  222. package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts +8 -0
  223. package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -0
  224. package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
  225. package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
  226. package/lib/typescript/ui/screens/SignUpScreen.d.ts.map +1 -1
  227. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +27 -0
  228. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -0
  229. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +26 -0
  230. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +1 -0
  231. package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts +20 -0
  232. package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +1 -0
  233. package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts +24 -0
  234. package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +1 -0
  235. package/lib/typescript/ui/screens/internal/SignUpSummaryStep.d.ts +15 -0
  236. package/lib/typescript/ui/screens/internal/SignUpSummaryStep.d.ts.map +1 -0
  237. package/lib/typescript/ui/screens/internal/SignUpWelcomeStep.d.ts +13 -0
  238. package/lib/typescript/ui/screens/internal/SignUpWelcomeStep.d.ts.map +1 -0
  239. package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
  240. package/lib/typescript/ui/stores/authStore.d.ts +14 -0
  241. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -0
  242. package/lib/typescript/ui/stores/followStore.d.ts +15 -0
  243. package/lib/typescript/ui/stores/followStore.d.ts.map +1 -0
  244. package/lib/typescript/ui/styles/index.d.ts +0 -1
  245. package/lib/typescript/ui/styles/index.d.ts.map +1 -1
  246. package/lib/typescript/ui/utils/confirmAction.d.ts +7 -0
  247. package/lib/typescript/ui/utils/confirmAction.d.ts.map +1 -0
  248. package/package.json +12 -7
  249. package/src/core/index.ts +78 -88
  250. package/src/index.ts +8 -45
  251. package/src/models/secureSession.ts +1 -2
  252. package/src/node/index.ts +0 -3
  253. package/src/ui/components/FollowButton.tsx +100 -322
  254. package/src/ui/components/OxyPayButton.tsx +133 -0
  255. package/src/ui/components/OxyProvider.tsx +39 -201
  256. package/src/ui/components/OxySignInButton.tsx +13 -2
  257. package/src/ui/components/icon/FAIRWalletIcon.tsx +49 -0
  258. package/src/ui/components/icon/index.ts +1 -0
  259. package/src/ui/components/index.ts +1 -0
  260. package/src/ui/components/internal/GroupedPillButtons.tsx +12 -8
  261. package/src/ui/components/internal/PinInput.tsx +102 -0
  262. package/src/ui/components/internal/TextField.tsx +9 -0
  263. package/src/ui/context/OxyContext.tsx +26 -40
  264. package/src/ui/hooks/index.ts +1 -2
  265. package/src/ui/hooks/useFollow.ts +58 -129
  266. package/src/ui/hooks/useSessionSocket.ts +50 -0
  267. package/src/ui/index.ts +2 -37
  268. package/src/ui/navigation/OxyRouter.tsx +47 -63
  269. package/src/ui/navigation/types.ts +5 -26
  270. package/src/ui/screens/AccountCenterScreen.tsx +12 -21
  271. package/src/ui/screens/AccountOverviewScreen.tsx +6 -30
  272. package/src/ui/screens/AccountSettingsScreen.tsx +7 -22
  273. package/src/ui/screens/AccountSwitcherScreen.tsx +46 -88
  274. package/src/ui/screens/AppInfoScreen.tsx +27 -47
  275. package/src/ui/screens/FeedbackScreen.tsx +34 -19
  276. package/src/ui/screens/FileManagementScreen.tsx +293 -321
  277. package/src/ui/screens/PaymentGatewayScreen.tsx +1315 -0
  278. package/src/ui/screens/PremiumSubscriptionScreen.tsx +109 -124
  279. package/src/ui/screens/RecoverAccountScreen.tsx +260 -0
  280. package/src/ui/screens/SessionManagementScreen.tsx +65 -137
  281. package/src/ui/screens/SignInScreen.tsx +89 -283
  282. package/src/ui/screens/SignUpScreen.tsx +138 -291
  283. package/src/ui/screens/internal/SignInPasswordStep.tsx +179 -0
  284. package/src/ui/screens/internal/SignInUsernameStep.tsx +139 -0
  285. package/src/ui/screens/internal/SignUpIdentityStep.tsx +114 -0
  286. package/src/ui/screens/internal/SignUpSecurityStep.tsx +132 -0
  287. package/src/ui/screens/internal/SignUpSummaryStep.tsx +66 -0
  288. package/src/ui/screens/internal/SignUpWelcomeStep.tsx +52 -0
  289. package/src/ui/screens/karma/KarmaRewardsScreen.tsx +13 -3
  290. package/src/ui/stores/authStore.ts +24 -0
  291. package/src/ui/stores/followStore.ts +80 -0
  292. package/src/ui/styles/index.ts +0 -1
  293. package/src/ui/utils/confirmAction.ts +23 -0
  294. package/lib/commonjs/ui/components/bottomSheet/index.js +0 -37
  295. package/lib/commonjs/ui/components/bottomSheet/index.js.map +0 -1
  296. package/lib/commonjs/ui/hooks/useAuthFetch.js +0 -217
  297. package/lib/commonjs/ui/hooks/useAuthFetch.js.map +0 -1
  298. package/lib/commonjs/ui/hooks/useOxyFollow.js +0 -190
  299. package/lib/commonjs/ui/hooks/useOxyFollow.js.map +0 -1
  300. package/lib/commonjs/ui/screens/BillingManagementScreen.js +0 -636
  301. package/lib/commonjs/ui/screens/BillingManagementScreen.js.map +0 -1
  302. package/lib/commonjs/ui/store/index.js +0 -67
  303. package/lib/commonjs/ui/store/index.js.map +0 -1
  304. package/lib/commonjs/ui/store/setupOxyStore.js +0 -63
  305. package/lib/commonjs/ui/store/setupOxyStore.js.map +0 -1
  306. package/lib/commonjs/ui/store/slices/authSlice.js +0 -56
  307. package/lib/commonjs/ui/store/slices/authSlice.js.map +0 -1
  308. package/lib/commonjs/ui/store/slices/followSlice.js +0 -238
  309. package/lib/commonjs/ui/store/slices/followSlice.js.map +0 -1
  310. package/lib/commonjs/ui/store/slices/index.js +0 -129
  311. package/lib/commonjs/ui/store/slices/index.js.map +0 -1
  312. package/lib/commonjs/ui/store/slices/types.js +0 -19
  313. package/lib/commonjs/ui/store/slices/types.js.map +0 -1
  314. package/lib/commonjs/ui/styles/shadows.js +0 -123
  315. package/lib/commonjs/ui/styles/shadows.js.map +0 -1
  316. package/lib/commonjs/utils/polyfills.js +0 -42
  317. package/lib/commonjs/utils/polyfills.js.map +0 -1
  318. package/lib/module/ui/components/bottomSheet/index.js +0 -5
  319. package/lib/module/ui/components/bottomSheet/index.js.map +0 -1
  320. package/lib/module/ui/hooks/useAuthFetch.js +0 -212
  321. package/lib/module/ui/hooks/useAuthFetch.js.map +0 -1
  322. package/lib/module/ui/hooks/useOxyFollow.js +0 -186
  323. package/lib/module/ui/hooks/useOxyFollow.js.map +0 -1
  324. package/lib/module/ui/screens/BillingManagementScreen.js +0 -631
  325. package/lib/module/ui/screens/BillingManagementScreen.js.map +0 -1
  326. package/lib/module/ui/store/index.js +0 -33
  327. package/lib/module/ui/store/index.js.map +0 -1
  328. package/lib/module/ui/store/setupOxyStore.js +0 -59
  329. package/lib/module/ui/store/setupOxyStore.js.map +0 -1
  330. package/lib/module/ui/store/slices/authSlice.js +0 -48
  331. package/lib/module/ui/store/slices/authSlice.js.map +0 -1
  332. package/lib/module/ui/store/slices/followSlice.js +0 -232
  333. package/lib/module/ui/store/slices/followSlice.js.map +0 -1
  334. package/lib/module/ui/store/slices/index.js +0 -11
  335. package/lib/module/ui/store/slices/index.js.map +0 -1
  336. package/lib/module/ui/store/slices/types.js +0 -15
  337. package/lib/module/ui/store/slices/types.js.map +0 -1
  338. package/lib/module/ui/styles/shadows.js +0 -119
  339. package/lib/module/ui/styles/shadows.js.map +0 -1
  340. package/lib/module/utils/polyfills.js +0 -36
  341. package/lib/module/utils/polyfills.js.map +0 -1
  342. package/lib/typescript/types/react-redux.d.ts +0 -5
  343. package/lib/typescript/ui/components/bottomSheet/index.d.ts +0 -4
  344. package/lib/typescript/ui/components/bottomSheet/index.d.ts.map +0 -1
  345. package/lib/typescript/ui/hooks/useAuthFetch.d.ts +0 -34
  346. package/lib/typescript/ui/hooks/useAuthFetch.d.ts.map +0 -1
  347. package/lib/typescript/ui/hooks/useOxyFollow.d.ts +0 -81
  348. package/lib/typescript/ui/hooks/useOxyFollow.d.ts.map +0 -1
  349. package/lib/typescript/ui/screens/BillingManagementScreen.d.ts +0 -5
  350. package/lib/typescript/ui/screens/BillingManagementScreen.d.ts.map +0 -1
  351. package/lib/typescript/ui/store/index.d.ts +0 -27
  352. package/lib/typescript/ui/store/index.d.ts.map +0 -1
  353. package/lib/typescript/ui/store/setupOxyStore.d.ts +0 -29
  354. package/lib/typescript/ui/store/setupOxyStore.d.ts.map +0 -1
  355. package/lib/typescript/ui/store/slices/authSlice.d.ts +0 -32
  356. package/lib/typescript/ui/store/slices/authSlice.d.ts.map +0 -1
  357. package/lib/typescript/ui/store/slices/followSlice.d.ts +0 -120
  358. package/lib/typescript/ui/store/slices/followSlice.d.ts.map +0 -1
  359. package/lib/typescript/ui/store/slices/index.d.ts +0 -9
  360. package/lib/typescript/ui/store/slices/index.d.ts.map +0 -1
  361. package/lib/typescript/ui/store/slices/types.d.ts +0 -16
  362. package/lib/typescript/ui/store/slices/types.d.ts.map +0 -1
  363. package/lib/typescript/ui/styles/shadows.d.ts +0 -233
  364. package/lib/typescript/ui/styles/shadows.d.ts.map +0 -1
  365. package/lib/typescript/utils/polyfills.d.ts +0 -6
  366. package/lib/typescript/utils/polyfills.d.ts.map +0 -1
  367. package/src/__tests__/backend-middleware.test.ts +0 -209
  368. package/src/__tests__/polyfills.test.ts +0 -30
  369. package/src/__tests__/setup.ts +0 -43
  370. package/src/__tests__/ui/hooks/authfetch-integration.test.ts +0 -197
  371. package/src/__tests__/ui/hooks/backward-compatibility.test.ts +0 -159
  372. package/src/__tests__/ui/hooks/real-world-scenarios.test.ts +0 -224
  373. package/src/__tests__/ui/hooks/url-resolution.test.ts +0 -129
  374. package/src/__tests__/ui/hooks/useAuthFetch-separation.test.ts +0 -69
  375. package/src/__tests__/ui/hooks/useAuthFetch.test.ts +0 -70
  376. package/src/__tests__/ui/hooks/useOxyFollow.test.tsx +0 -92
  377. package/src/__tests__/ui/screens/AccountSettingsScreen.test.tsx +0 -112
  378. package/src/__tests__/ui/store/setupOxyStore.test.ts +0 -50
  379. package/src/__tests__/validate-structure.js +0 -91
  380. package/src/__tests__/validation.js +0 -42
  381. package/src/types/react-redux.d.ts +0 -5
  382. package/src/ui/components/bottomSheet/index.tsx +0 -14
  383. package/src/ui/hooks/useAuthFetch.ts +0 -238
  384. package/src/ui/hooks/useOxyFollow.ts +0 -188
  385. package/src/ui/screens/BillingManagementScreen.tsx +0 -589
  386. package/src/ui/store/index.ts +0 -36
  387. package/src/ui/store/setupOxyStore.ts +0 -58
  388. package/src/ui/store/slices/authSlice.ts +0 -43
  389. package/src/ui/store/slices/followSlice.ts +0 -207
  390. package/src/ui/store/slices/index.ts +0 -31
  391. package/src/ui/store/slices/types.ts +0 -33
  392. package/src/ui/styles/shadows.ts +0 -112
  393. package/src/utils/polyfills.ts +0 -34
@@ -1,209 +0,0 @@
1
- /**
2
- * Integration test for refactored authentication system
3
- * Tests the backend middleware functionality
4
- */
5
-
6
- import { OxyServices } from '../../core';
7
-
8
- describe('Authentication System Integration', () => {
9
- let oxyServices: OxyServices;
10
- let mockReq: any;
11
- let mockRes: any;
12
- let mockNext: any;
13
-
14
- beforeEach(() => {
15
- oxyServices = new OxyServices({
16
- baseURL: 'https://api.test.com'
17
- });
18
-
19
- // Mock Express request/response objects
20
- mockReq = {
21
- headers: {},
22
- user: undefined,
23
- userId: undefined,
24
- accessToken: undefined
25
- };
26
-
27
- mockRes = {
28
- status: jest.fn().mockReturnThis(),
29
- json: jest.fn().mockReturnThis()
30
- };
31
-
32
- mockNext = jest.fn();
33
- });
34
-
35
- describe('Middleware Creation', () => {
36
- test('should create authentication middleware', () => {
37
- const middleware = oxyServices.createAuthenticateTokenMiddleware();
38
- expect(typeof middleware).toBe('function');
39
- expect(middleware.length).toBe(3); // req, res, next
40
- });
41
-
42
- test('should create middleware with custom options', () => {
43
- const customErrorHandler = jest.fn();
44
- const middleware = oxyServices.createAuthenticateTokenMiddleware({
45
- loadFullUser: false,
46
- onError: customErrorHandler
47
- });
48
-
49
- expect(typeof middleware).toBe('function');
50
- });
51
- });
52
-
53
- describe('Token Validation', () => {
54
- test('should handle missing token', async () => {
55
- const middleware = oxyServices.createAuthenticateTokenMiddleware();
56
-
57
- await middleware(mockReq, mockRes, mockNext);
58
-
59
- expect(mockRes.status).toHaveBeenCalledWith(401);
60
- expect(mockRes.json).toHaveBeenCalledWith({
61
- message: 'Access token required',
62
- code: 'MISSING_TOKEN'
63
- });
64
- expect(mockNext).not.toHaveBeenCalled();
65
- });
66
-
67
- test('should handle invalid token format', async () => {
68
- mockReq.headers.authorization = 'InvalidFormat token123';
69
-
70
- const middleware = oxyServices.createAuthenticateTokenMiddleware();
71
- await middleware(mockReq, mockRes, mockNext);
72
-
73
- expect(mockRes.status).toHaveBeenCalledWith(401);
74
- expect(mockNext).not.toHaveBeenCalled();
75
- });
76
-
77
- test('should extract token from Bearer header', async () => {
78
- mockReq.headers.authorization = 'Bearer valid.jwt.token';
79
-
80
- const middleware = oxyServices.createAuthenticateTokenMiddleware();
81
- await middleware(mockReq, mockRes, mockNext);
82
-
83
- // Note: This will fail validation since it's not a real token,
84
- // but we can verify the token was extracted
85
- expect(mockRes.status).toHaveBeenCalled();
86
- });
87
- });
88
-
89
- describe('Standalone Token Validation', () => {
90
- test('should validate empty token', async () => {
91
- const result = await oxyServices.authenticateToken('');
92
-
93
- expect(result.valid).toBe(false);
94
- expect(result.error).toBe('Token is required');
95
- expect(result.userId).toBeUndefined();
96
- expect(result.user).toBeUndefined();
97
- });
98
-
99
- test('should validate invalid token', async () => {
100
- const result = await oxyServices.authenticateToken('invalid.jwt.token');
101
-
102
- expect(result.valid).toBe(false);
103
- expect(result.error).toBeTruthy();
104
- expect(result.userId).toBeUndefined();
105
- expect(result.user).toBeUndefined();
106
- });
107
-
108
- test('should handle validation errors gracefully', async () => {
109
- const result = await oxyServices.authenticateToken('malformed-token');
110
-
111
- expect(result.valid).toBe(false);
112
- expect(result.error).toMatch(/validation failed|Invalid/i);
113
- });
114
- });
115
-
116
- describe('Custom Error Handling', () => {
117
- test('should use custom error handler when provided', async () => {
118
- const customErrorHandler = jest.fn();
119
- const middleware = oxyServices.createAuthenticateTokenMiddleware({
120
- onError: customErrorHandler
121
- });
122
-
123
- await middleware(mockReq, mockRes, mockNext);
124
-
125
- expect(customErrorHandler).toHaveBeenCalledWith({
126
- message: 'Access token required',
127
- code: 'MISSING_TOKEN',
128
- status: 401
129
- });
130
- expect(mockRes.status).not.toHaveBeenCalled();
131
- });
132
- });
133
-
134
- describe('Backend Integration Example', () => {
135
- test('should work with Express.js route patterns', () => {
136
- // Simulate Express.js app setup
137
- const mockApp = {
138
- get: jest.fn(),
139
- post: jest.fn(),
140
- use: jest.fn()
141
- };
142
-
143
- // Create middleware
144
- const authenticateToken = oxyServices.createAuthenticateTokenMiddleware({
145
- loadFullUser: true
146
- });
147
-
148
- // Simulate route registration
149
- mockApp.get('/api/protected', authenticateToken, (req: any, res: any) => {
150
- res.json({
151
- message: 'Access granted',
152
- user: req.user,
153
- userId: req.userId
154
- });
155
- });
156
-
157
- expect(mockApp.get).toHaveBeenCalledWith(
158
- '/api/protected',
159
- authenticateToken,
160
- expect.any(Function)
161
- );
162
- });
163
-
164
- test('should provide consistent interface for different auth patterns', () => {
165
- // Pattern 1: Middleware
166
- const middleware = oxyServices.createAuthenticateTokenMiddleware();
167
- expect(typeof middleware).toBe('function');
168
-
169
- // Pattern 2: Standalone validation
170
- const validateToken = oxyServices.authenticateToken.bind(oxyServices);
171
- expect(typeof validateToken).toBe('function');
172
-
173
- // Pattern 3: Direct service methods
174
- expect(typeof oxyServices.getAccessToken).toBe('function');
175
- expect(typeof oxyServices.setTokens).toBe('function');
176
- expect(typeof oxyServices.clearTokens).toBe('function');
177
- });
178
- });
179
-
180
- describe('Zero-Config Setup Verification', () => {
181
- test('should work with minimal configuration', () => {
182
- // This simulates the zero-config setup promise
183
- const minimalSetup = () => {
184
- // Backend: Just create OxyServices and use middleware
185
- const services = new OxyServices({ baseURL: 'https://api.example.com' });
186
- const authMiddleware = services.createAuthenticateTokenMiddleware();
187
-
188
- return { services, authMiddleware };
189
- };
190
-
191
- const { services, authMiddleware } = minimalSetup();
192
-
193
- expect(services).toBeInstanceOf(OxyServices);
194
- expect(typeof authMiddleware).toBe('function');
195
- expect(services.getBaseURL()).toBe('https://api.example.com');
196
- });
197
-
198
- test('should support runtime configuration changes', () => {
199
- const services = new OxyServices({ baseURL: 'https://dev-api.com' });
200
-
201
- expect(services.getBaseURL()).toBe('https://dev-api.com');
202
-
203
- // Simulate runtime change to production
204
- services.setBaseURL('https://prod-api.com');
205
-
206
- expect(services.getBaseURL()).toBe('https://prod-api.com');
207
- });
208
- });
209
- });
@@ -1,30 +0,0 @@
1
- /**
2
- * Test file to verify FormData polyfill functionality
3
- */
4
-
5
- import { getFormDataConstructor } from '../utils/polyfills';
6
-
7
- describe('FormData Polyfill Tests', () => {
8
- it('should provide FormData constructor', () => {
9
- const FormDataConstructor = getFormDataConstructor();
10
- expect(FormDataConstructor).toBeDefined();
11
- expect(typeof FormDataConstructor).toBe('function');
12
- });
13
-
14
- it('should create FormData instance successfully', () => {
15
- const FormDataConstructor = getFormDataConstructor();
16
- const formData = new FormDataConstructor();
17
- expect(formData).toBeDefined();
18
- expect(typeof formData.append).toBe('function');
19
- });
20
-
21
- it('should handle form data append operations', () => {
22
- const FormDataConstructor = getFormDataConstructor();
23
- const formData = new FormDataConstructor();
24
-
25
- // Should not throw
26
- expect(() => {
27
- formData.append('test', 'value');
28
- }).not.toThrow();
29
- });
30
- });
@@ -1,43 +0,0 @@
1
- import '@testing-library/jest-dom';
2
-
3
- // Mock React Native APIs
4
- global.jest = require('jest');
5
-
6
- // Mock Dimensions
7
- jest.mock('react-native', () => {
8
- const RN = jest.requireActual('react-native');
9
- return {
10
- ...RN,
11
- Dimensions: {
12
- get: jest.fn().mockReturnValue({ width: 375, height: 800 }),
13
- },
14
- Platform: {
15
- OS: 'web',
16
- select: (options: any) => options.web || options.default,
17
- },
18
- };
19
- });
20
-
21
- // Mock AsyncStorage
22
- jest.mock('@react-native-async-storage/async-storage', () =>
23
- require('@react-native-async-storage/async-storage/jest/async-storage-mock')
24
- );
25
-
26
- // Mock react-native-gesture-handler
27
- jest.mock('react-native-gesture-handler', () => {
28
- const View = require('react-native').View;
29
- return {
30
- ScrollView: View,
31
- PanGestureHandler: View,
32
- TapGestureHandler: View,
33
- FlingGestureHandler: View,
34
- PinchGestureHandler: View,
35
- RotationGestureHandler: View,
36
- State: {},
37
- PanResponder: {
38
- create: jest.fn(() => ({
39
- panHandlers: {},
40
- })),
41
- },
42
- };
43
- });
@@ -1,197 +0,0 @@
1
- /**
2
- * Integration test demonstrating the separation of internal and public authFetch usage
3
- * This test simulates real-world usage patterns described in the issue
4
- */
5
-
6
- describe('AuthFetch Separation - Integration Test', () => {
7
- describe('Real-world usage simulation', () => {
8
- // Mock OxyServices to simulate the actual implementation
9
- class MockOxyServices {
10
- private internalBaseURL: string;
11
-
12
- constructor(config: { baseURL: string }) {
13
- this.internalBaseURL = config.baseURL;
14
- }
15
-
16
- // Internal URL management (used by the module itself)
17
- getBaseURL(): string {
18
- return this.internalBaseURL;
19
- }
20
-
21
- setBaseURL(url: string): void {
22
- if (!url) throw new Error('Base URL cannot be empty');
23
- this.internalBaseURL = url;
24
- }
25
-
26
- // Simulate internal module methods that make API calls
27
- authenticateToken(token: string): Promise<{ valid: boolean; error?: string }> {
28
- const url = `${this.internalBaseURL}/auth/validate`;
29
- console.log(`Internal module call to: ${url}`);
30
- return Promise.resolve({ valid: false, error: 'Invalid token' });
31
- }
32
-
33
- refreshTokens(): Promise<void> {
34
- const url = `${this.internalBaseURL}/auth/refresh`;
35
- console.log(`Internal module call to: ${url}`);
36
- return Promise.resolve();
37
- }
38
-
39
- getUserBySession(sessionId: string): Promise<any> {
40
- const url = `${this.internalBaseURL}/users/session/${sessionId}`;
41
- console.log(`Internal module call to: ${url}`);
42
- return Promise.resolve({ id: 'user123', username: 'testuser' });
43
- }
44
- }
45
-
46
- // Mock context state (simulating the new OxyContext implementation)
47
- class MockOxyContext {
48
- private oxyServices: MockOxyServices;
49
- private appBaseURL: string;
50
-
51
- constructor(oxyServices: MockOxyServices) {
52
- this.oxyServices = oxyServices;
53
- this.appBaseURL = oxyServices.getBaseURL(); // Initially same as internal URL
54
- }
55
-
56
- // Public methods for apps
57
- setApiUrl(url: string): void {
58
- if (!url) throw new Error('Base URL cannot be empty');
59
- this.appBaseURL = url; // Only affects public authFetch
60
- }
61
-
62
- getAppBaseURL(): string {
63
- return this.appBaseURL;
64
- }
65
-
66
- getOxyServices(): MockOxyServices {
67
- return this.oxyServices;
68
- }
69
- }
70
-
71
- // Mock authFetch (simulating the new useAuthFetch implementation)
72
- function createMockAuthFetch(context: MockOxyContext) {
73
- return {
74
- get: async (endpoint: string) => {
75
- const url = `${context.getAppBaseURL()}${endpoint}`;
76
- console.log(`Public authFetch call to: ${url}`);
77
- return { data: `Response from ${url}` };
78
- },
79
- post: async (endpoint: string, data: any) => {
80
- const url = `${context.getAppBaseURL()}${endpoint}`;
81
- console.log(`Public authFetch call to: ${url}`);
82
- return { data: `Posted to ${url}`, posted: data };
83
- }
84
- };
85
- }
86
-
87
- test('should demonstrate clean separation in Mention app scenario', async () => {
88
- console.log('\n=== Mention App Integration Test ===\n');
89
-
90
- // 1. Initialize OxyServices for internal module usage
91
- const oxyServices = new MockOxyServices({
92
- baseURL: 'https://api.oxy.so'
93
- });
94
-
95
- // 2. Create context (simulating OxyProvider)
96
- const context = new MockOxyContext(oxyServices);
97
-
98
- // 3. Create authFetch (simulating useAuthFetch hook)
99
- const authFetch = createMockAuthFetch(context);
100
-
101
- console.log('1. Initial state:');
102
-
103
- // Internal module calls should use Oxy API
104
- await oxyServices.authenticateToken('test-token');
105
- await oxyServices.getUserBySession('session123');
106
-
107
- // Public authFetch calls initially use Oxy API too
108
- await authFetch.get('/api/users/me');
109
- await authFetch.post('/api/mentions', { text: 'Hello world' });
110
-
111
- console.log('\n2. Mention app sets its own API URL:');
112
-
113
- // App configures its own API URL
114
- context.setApiUrl('https://mention.earth/api');
115
-
116
- console.log('\n3. After configuration:');
117
-
118
- // Internal module calls STILL use Oxy API (unchanged)
119
- await oxyServices.authenticateToken('test-token');
120
- await oxyServices.refreshTokens();
121
-
122
- // Public authFetch calls now use Mention's API
123
- await authFetch.get('/api/mentions');
124
- await authFetch.post('/api/mentions', { text: 'New mention' });
125
-
126
- // Verify URLs are correctly separated
127
- expect(oxyServices.getBaseURL()).toBe('https://api.oxy.so');
128
- expect(context.getAppBaseURL()).toBe('https://mention.earth/api');
129
-
130
- console.log('\n✅ Clean separation achieved!');
131
- });
132
-
133
- test('should support dynamic URL changes without affecting internal calls', async () => {
134
- console.log('\n=== Dynamic URL Changes Test ===\n');
135
-
136
- const oxyServices = new MockOxyServices({
137
- baseURL: 'https://api.oxy.so'
138
- });
139
- const context = new MockOxyContext(oxyServices);
140
- const authFetch = createMockAuthFetch(context);
141
-
142
- // Scenario: App switches between staging and production
143
- const environments = [
144
- 'https://staging.myapp.com/api',
145
- 'https://production.myapp.com/api',
146
- 'https://dev.myapp.com/api'
147
- ];
148
-
149
- for (const [index, env] of environments.entries()) {
150
- console.log(`${index + 1}. Switching to ${env}:`);
151
-
152
- context.setApiUrl(env);
153
-
154
- // Internal calls remain unchanged
155
- await oxyServices.authenticateToken('token');
156
-
157
- // Public calls use new environment
158
- await authFetch.get('/api/data');
159
-
160
- // Verify separation
161
- expect(oxyServices.getBaseURL()).toBe('https://api.oxy.so');
162
- expect(context.getAppBaseURL()).toBe(env);
163
- }
164
-
165
- console.log('\n✅ Dynamic URL changes work correctly!');
166
- });
167
-
168
- test('should handle zero-config setup as described in issue', () => {
169
- console.log('\n=== Zero-Config Setup Test ===\n');
170
-
171
- // Simulate the zero-config setup described in the issue
172
- console.log('1. Create OxyServices instance:');
173
- const oxyServices = new MockOxyServices({
174
- baseURL: 'https://your-api.com'
175
- });
176
-
177
- console.log('2. Wrap app with provider (simulated):');
178
- const context = new MockOxyContext(oxyServices);
179
-
180
- console.log('3. Use authFetch in components (simulated):');
181
- const authFetch = createMockAuthFetch(context);
182
-
183
- // Verify the setup works
184
- expect(oxyServices.getBaseURL()).toBe('https://your-api.com');
185
- expect(context.getAppBaseURL()).toBe('https://your-api.com');
186
-
187
- console.log('4. Change API URL at runtime:');
188
- context.setApiUrl('https://production-api.com');
189
-
190
- // Verify separation
191
- expect(oxyServices.getBaseURL()).toBe('https://your-api.com'); // Internal unchanged
192
- expect(context.getAppBaseURL()).toBe('https://production-api.com'); // Public changed
193
-
194
- console.log('\n✅ Zero-config setup with separation works!');
195
- });
196
- });
197
- });
@@ -1,159 +0,0 @@
1
- /**
2
- * Backward compatibility test - ensures existing API surface is unchanged
3
- */
4
-
5
- describe('Backward Compatibility', () => {
6
- describe('Existing API surface', () => {
7
- // Mock the components to test the API surface
8
- function mockUseOxy() {
9
- return {
10
- oxyServices: {
11
- getBaseURL: () => 'https://api.oxy.so',
12
- setBaseURL: (url: string) => {},
13
- },
14
- isAuthenticated: true,
15
- user: { id: 'user123', username: 'testuser' },
16
- login: async (username: string, password: string) => ({ id: 'user123' }),
17
- logout: async () => {},
18
- signUp: async (username: string, email: string, password: string) => ({ id: 'user123' }),
19
- activeSessionId: 'session123',
20
- setApiUrl: (url: string) => {}, // This should still exist
21
- getAppBaseURL: () => 'https://app.example.com', // New addition
22
- };
23
- }
24
-
25
- function mockUseAuthFetch() {
26
- const oxyContext = mockUseOxy();
27
-
28
- // Mock the AuthFetchAPI interface
29
- const authFetch = async (input: RequestInfo | URL, init?: any) => {
30
- return new Response('{"success": true}');
31
- };
32
-
33
- // Add convenience methods as per the interface
34
- Object.assign(authFetch, {
35
- get: async (endpoint: string, options?: any) => ({ data: 'get response' }),
36
- post: async (endpoint: string, data?: any, options?: any) => ({ data: 'post response' }),
37
- put: async (endpoint: string, data?: any, options?: any) => ({ data: 'put response' }),
38
- delete: async (endpoint: string, options?: any) => ({ data: 'delete response' }),
39
- isAuthenticated: oxyContext.isAuthenticated,
40
- user: oxyContext.user,
41
- login: oxyContext.login,
42
- logout: oxyContext.logout,
43
- signUp: oxyContext.signUp,
44
- setApiUrl: oxyContext.setApiUrl, // Existing API
45
- });
46
-
47
- return authFetch;
48
- }
49
-
50
- test('should maintain existing useAuthFetch API', async () => {
51
- const authFetch = mockUseAuthFetch();
52
-
53
- // Test that all existing methods are still available
54
- expect(typeof authFetch).toBe('function'); // Main function
55
- expect(typeof authFetch.get).toBe('function');
56
- expect(typeof authFetch.post).toBe('function');
57
- expect(typeof authFetch.put).toBe('function');
58
- expect(typeof authFetch.delete).toBe('function');
59
- expect(typeof authFetch.setApiUrl).toBe('function'); // Key API method
60
-
61
- // Test that auth properties are available
62
- expect(typeof authFetch.isAuthenticated).toBe('boolean');
63
- expect(authFetch.user).toBeTruthy();
64
- expect(typeof authFetch.login).toBe('function');
65
- expect(typeof authFetch.logout).toBe('function');
66
- expect(typeof authFetch.signUp).toBe('function');
67
- });
68
-
69
- test('should support existing usage patterns from documentation', async () => {
70
- // Test usage pattern from refactored-authentication.md
71
- const authFetch = mockUseAuthFetch();
72
-
73
- // Simple authenticated GET request
74
- const profile = await authFetch.get('/api/users/me');
75
- expect(profile).toEqual({ data: 'get response' });
76
-
77
- // Simple authenticated POST request
78
- const result = await authFetch.post('/api/users/me', { name: 'Updated Name' });
79
- expect(result).toEqual({ data: 'post response' });
80
-
81
- // Runtime API URL updates (this should still work)
82
- authFetch.setApiUrl('https://new-api.com');
83
-
84
- // Verify no breaking changes in the API surface
85
- expect(authFetch.isAuthenticated).toBe(true);
86
- expect(authFetch.user?.username).toBe('testuser');
87
- });
88
-
89
- test('should support existing OxyServices API', () => {
90
- const oxyContext = mockUseOxy();
91
- const oxyServices = oxyContext.oxyServices;
92
-
93
- // Existing OxyServices methods should still work
94
- expect(typeof oxyServices.getBaseURL).toBe('function');
95
- expect(typeof oxyServices.setBaseURL).toBe('function');
96
- expect(oxyServices.getBaseURL()).toBe('https://api.oxy.so');
97
-
98
- // This should not throw
99
- oxyServices.setBaseURL('https://new-oxy-url.com');
100
- });
101
-
102
- test('should demonstrate zero-config setup still works', () => {
103
- // From the documentation example
104
- console.log('Testing zero-config setup pattern...');
105
-
106
- // 1. Create OxyServices instance (existing pattern)
107
- const mockOxyServices = {
108
- baseURL: 'https://your-api.com',
109
- getBaseURL: () => 'https://your-api.com',
110
- };
111
-
112
- // 2. Wrap app with provider (existing pattern)
113
- const mockProvider = {
114
- oxyServices: mockOxyServices,
115
- };
116
-
117
- // 3. Use authFetch in components (existing pattern)
118
- const authFetch = mockUseAuthFetch();
119
-
120
- // All existing functionality should work
121
- expect(authFetch).toBeTruthy();
122
- expect(typeof authFetch.get).toBe('function');
123
- expect(typeof authFetch.setApiUrl).toBe('function');
124
-
125
- console.log('✅ Zero-config setup compatibility verified');
126
- });
127
- });
128
-
129
- describe('New functionality (additive)', () => {
130
- test('should add new getAppBaseURL without breaking existing API', () => {
131
- const oxyContext = mockUseOxy();
132
-
133
- // New method should be available
134
- expect(typeof oxyContext.getAppBaseURL).toBe('function');
135
- expect(oxyContext.getAppBaseURL()).toBe('https://app.example.com');
136
-
137
- // Existing methods should still work
138
- expect(typeof oxyContext.setApiUrl).toBe('function');
139
- });
140
-
141
- test('should demonstrate separation without breaking existing usage', () => {
142
- console.log('\nTesting that new separation doesn\'t break existing patterns...');
143
-
144
- const oxyContext = mockUseOxy();
145
-
146
- // Existing pattern: app sets API URL
147
- oxyContext.setApiUrl('https://myapp.example.com');
148
-
149
- // New behavior: this now only affects public authFetch, not internal calls
150
- // But from the app's perspective, the API call is identical
151
- expect(typeof oxyContext.setApiUrl).toBe('function');
152
-
153
- // Internal calls would still work independently (behind the scenes)
154
- expect(oxyContext.oxyServices.getBaseURL()).toBe('https://api.oxy.so');
155
-
156
- console.log('✅ Separation is transparent to existing users');
157
- });
158
- });
159
- });