@oxyhq/services 5.7.5 → 5.8.2

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 (303) hide show
  1. package/README.md +76 -76
  2. package/lib/commonjs/core/index.js +177 -102
  3. package/lib/commonjs/core/index.js.map +1 -1
  4. package/lib/commonjs/index.js +69 -28
  5. package/lib/commonjs/index.js.map +1 -1
  6. package/lib/commonjs/ui/components/Avatar.js +15 -6
  7. package/lib/commonjs/ui/components/Avatar.js.map +1 -1
  8. package/lib/commonjs/ui/components/FollowButton.js +100 -12
  9. package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
  10. package/lib/commonjs/ui/components/GroupedItem.js +58 -13
  11. package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
  12. package/lib/commonjs/ui/components/GroupedSection.js +7 -1
  13. package/lib/commonjs/ui/components/GroupedSection.js.map +1 -1
  14. package/lib/commonjs/ui/components/Header.js +356 -0
  15. package/lib/commonjs/ui/components/Header.js.map +1 -0
  16. package/lib/commonjs/ui/components/OxyProvider.js +28 -7
  17. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  18. package/lib/commonjs/ui/components/index.js +7 -0
  19. package/lib/commonjs/ui/components/index.js.map +1 -1
  20. package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +1 -1
  21. package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
  22. package/lib/commonjs/ui/components/internal/TextField.js +606 -546
  23. package/lib/commonjs/ui/components/internal/TextField.js.map +1 -1
  24. package/lib/commonjs/ui/components/internal/TextField.md +436 -0
  25. package/lib/commonjs/ui/context/OxyContext.js +181 -199
  26. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  27. package/lib/commonjs/ui/hooks/index.js +6 -0
  28. package/lib/commonjs/ui/hooks/index.js.map +1 -1
  29. package/lib/commonjs/ui/hooks/useFollow.js +59 -2
  30. package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
  31. package/lib/commonjs/ui/hooks/useSessionSocket.js +5 -2
  32. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  33. package/lib/commonjs/ui/navigation/OxyRouter.js +11 -1
  34. package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
  35. package/lib/commonjs/ui/screens/AccountCenterScreen.js +6 -6
  36. package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
  37. package/lib/commonjs/ui/screens/AccountManagementDemo.js +3 -3
  38. package/lib/commonjs/ui/screens/AccountManagementDemo.js.map +1 -1
  39. package/lib/commonjs/ui/screens/AccountOverviewScreen.js +241 -598
  40. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  41. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +1160 -406
  42. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  43. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +135 -237
  44. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  45. package/lib/commonjs/ui/screens/AppInfoScreen.js +246 -463
  46. package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
  47. package/lib/commonjs/ui/screens/FeedbackScreen.js +3 -3
  48. package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
  49. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +808 -650
  50. package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
  51. package/lib/commonjs/ui/screens/ProfileScreen.js +214 -37
  52. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  53. package/lib/commonjs/ui/screens/RecoverAccountScreen.js +51 -72
  54. package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -1
  55. package/lib/commonjs/ui/screens/SessionManagementScreen.js +11 -29
  56. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  57. package/lib/commonjs/ui/screens/SignInScreen.js +30 -303
  58. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  59. package/lib/commonjs/ui/screens/SignUpScreen.js +4 -4
  60. package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
  61. package/lib/commonjs/ui/screens/UserLinksScreen.js +90 -0
  62. package/lib/commonjs/ui/screens/UserLinksScreen.js.map +1 -0
  63. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +19 -31
  64. package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -1
  65. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +7 -10
  66. package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +1 -1
  67. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +11 -5
  68. package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
  69. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +11 -4
  70. package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
  71. package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +9 -6
  72. package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
  73. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +3 -30
  74. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  75. package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js +37 -46
  76. package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
  77. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +9 -12
  78. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  79. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +9 -12
  80. package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  81. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +9 -12
  82. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  83. package/lib/commonjs/ui/stores/authStore.js +36 -6
  84. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  85. package/lib/commonjs/ui/stores/followStore.js +106 -1
  86. package/lib/commonjs/ui/stores/followStore.js.map +1 -1
  87. package/lib/commonjs/ui/styles/authStyles.js +337 -0
  88. package/lib/commonjs/ui/styles/authStyles.js.map +1 -0
  89. package/lib/commonjs/ui/styles/index.js +11 -0
  90. package/lib/commonjs/ui/styles/index.js.map +1 -1
  91. package/lib/module/core/index.js +177 -41
  92. package/lib/module/core/index.js.map +1 -1
  93. package/lib/module/index.js +24 -4
  94. package/lib/module/index.js.map +1 -1
  95. package/lib/module/ui/components/Avatar.js +15 -6
  96. package/lib/module/ui/components/Avatar.js.map +1 -1
  97. package/lib/module/ui/components/FollowButton.js +101 -13
  98. package/lib/module/ui/components/FollowButton.js.map +1 -1
  99. package/lib/module/ui/components/GroupedItem.js +59 -14
  100. package/lib/module/ui/components/GroupedItem.js.map +1 -1
  101. package/lib/module/ui/components/GroupedSection.js +7 -1
  102. package/lib/module/ui/components/GroupedSection.js.map +1 -1
  103. package/lib/module/ui/components/Header.js +351 -0
  104. package/lib/module/ui/components/Header.js.map +1 -0
  105. package/lib/module/ui/components/OxyProvider.js +30 -9
  106. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  107. package/lib/module/ui/components/index.js +1 -0
  108. package/lib/module/ui/components/index.js.map +1 -1
  109. package/lib/module/ui/components/internal/GroupedPillButtons.js +1 -1
  110. package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
  111. package/lib/module/ui/components/internal/TextField.js +607 -547
  112. package/lib/module/ui/components/internal/TextField.js.map +1 -1
  113. package/lib/module/ui/components/internal/TextField.md +436 -0
  114. package/lib/module/ui/context/OxyContext.js +180 -198
  115. package/lib/module/ui/context/OxyContext.js.map +1 -1
  116. package/lib/module/ui/hooks/index.js +1 -1
  117. package/lib/module/ui/hooks/index.js.map +1 -1
  118. package/lib/module/ui/hooks/useFollow.js +57 -1
  119. package/lib/module/ui/hooks/useFollow.js.map +1 -1
  120. package/lib/module/ui/hooks/useSessionSocket.js +5 -2
  121. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  122. package/lib/module/ui/navigation/OxyRouter.js +11 -1
  123. package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
  124. package/lib/module/ui/screens/AccountCenterScreen.js +6 -6
  125. package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
  126. package/lib/module/ui/screens/AccountManagementDemo.js +3 -3
  127. package/lib/module/ui/screens/AccountManagementDemo.js.map +1 -1
  128. package/lib/module/ui/screens/AccountOverviewScreen.js +242 -597
  129. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  130. package/lib/module/ui/screens/AccountSettingsScreen.js +1161 -407
  131. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  132. package/lib/module/ui/screens/AccountSwitcherScreen.js +135 -237
  133. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  134. package/lib/module/ui/screens/AppInfoScreen.js +248 -465
  135. package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
  136. package/lib/module/ui/screens/FeedbackScreen.js +3 -3
  137. package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
  138. package/lib/module/ui/screens/PaymentGatewayScreen.js +809 -651
  139. package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
  140. package/lib/module/ui/screens/ProfileScreen.js +214 -37
  141. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  142. package/lib/module/ui/screens/RecoverAccountScreen.js +53 -74
  143. package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -1
  144. package/lib/module/ui/screens/SessionManagementScreen.js +11 -29
  145. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  146. package/lib/module/ui/screens/SignInScreen.js +32 -305
  147. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  148. package/lib/module/ui/screens/SignUpScreen.js +5 -5
  149. package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
  150. package/lib/module/ui/screens/UserLinksScreen.js +85 -0
  151. package/lib/module/ui/screens/UserLinksScreen.js.map +1 -0
  152. package/lib/module/ui/screens/internal/SignInPasswordStep.js +19 -31
  153. package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -1
  154. package/lib/module/ui/screens/internal/SignInUsernameStep.js +7 -10
  155. package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +1 -1
  156. package/lib/module/ui/screens/internal/SignUpIdentityStep.js +11 -5
  157. package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
  158. package/lib/module/ui/screens/internal/SignUpSecurityStep.js +11 -4
  159. package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
  160. package/lib/module/ui/screens/karma/KarmaAboutScreen.js +9 -6
  161. package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
  162. package/lib/module/ui/screens/karma/KarmaCenterScreen.js +3 -30
  163. package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  164. package/lib/module/ui/screens/karma/KarmaFAQScreen.js +37 -46
  165. package/lib/module/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
  166. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +9 -12
  167. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  168. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +9 -12
  169. package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
  170. package/lib/module/ui/screens/karma/KarmaRulesScreen.js +9 -12
  171. package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  172. package/lib/module/ui/stores/authStore.js +36 -6
  173. package/lib/module/ui/stores/authStore.js.map +1 -1
  174. package/lib/module/ui/stores/followStore.js +106 -1
  175. package/lib/module/ui/stores/followStore.js.map +1 -1
  176. package/lib/module/ui/styles/authStyles.js +332 -0
  177. package/lib/module/ui/styles/authStyles.js.map +1 -0
  178. package/lib/module/ui/styles/index.js +1 -0
  179. package/lib/module/ui/styles/index.js.map +1 -1
  180. package/lib/typescript/core/index.d.ts +68 -24
  181. package/lib/typescript/core/index.d.ts.map +1 -1
  182. package/lib/typescript/index.d.ts +13 -3
  183. package/lib/typescript/index.d.ts.map +1 -1
  184. package/lib/typescript/ui/components/Avatar.d.ts.map +1 -1
  185. package/lib/typescript/ui/components/FollowButton.d.ts +1 -0
  186. package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
  187. package/lib/typescript/ui/components/GroupedItem.d.ts +6 -0
  188. package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
  189. package/lib/typescript/ui/components/GroupedSection.d.ts +6 -0
  190. package/lib/typescript/ui/components/GroupedSection.d.ts.map +1 -1
  191. package/lib/typescript/ui/components/Header.d.ts +24 -0
  192. package/lib/typescript/ui/components/Header.d.ts.map +1 -0
  193. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  194. package/lib/typescript/ui/components/index.d.ts +1 -0
  195. package/lib/typescript/ui/components/index.d.ts.map +1 -1
  196. package/lib/typescript/ui/components/internal/TextField.d.ts +31 -16
  197. package/lib/typescript/ui/components/internal/TextField.d.ts.map +1 -1
  198. package/lib/typescript/ui/context/OxyContext.d.ts +5 -2
  199. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  200. package/lib/typescript/ui/hooks/index.d.ts +1 -1
  201. package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
  202. package/lib/typescript/ui/hooks/useFollow.d.ts +20 -0
  203. package/lib/typescript/ui/hooks/useFollow.d.ts.map +1 -1
  204. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  205. package/lib/typescript/ui/navigation/OxyRouter.d.ts.map +1 -1
  206. package/lib/typescript/ui/navigation/types.d.ts +9 -2
  207. package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
  208. package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
  209. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  210. package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
  211. package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
  212. package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
  213. package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
  214. package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts +5 -1
  215. package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -1
  216. package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
  217. package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
  218. package/lib/typescript/ui/screens/UserLinksScreen.d.ts +15 -0
  219. package/lib/typescript/ui/screens/UserLinksScreen.d.ts.map +1 -0
  220. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +1 -1
  221. package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -1
  222. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +0 -1
  223. package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +1 -1
  224. package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +1 -1
  225. package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +1 -1
  226. package/lib/typescript/ui/screens/karma/KarmaAboutScreen.d.ts.map +1 -1
  227. package/lib/typescript/ui/screens/karma/KarmaCenterScreen.d.ts.map +1 -1
  228. package/lib/typescript/ui/screens/karma/KarmaFAQScreen.d.ts.map +1 -1
  229. package/lib/typescript/ui/screens/karma/KarmaLeaderboardScreen.d.ts.map +1 -1
  230. package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
  231. package/lib/typescript/ui/screens/karma/KarmaRulesScreen.d.ts.map +1 -1
  232. package/lib/typescript/ui/stores/authStore.d.ts +3 -1
  233. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  234. package/lib/typescript/ui/stores/followStore.d.ts +10 -0
  235. package/lib/typescript/ui/stores/followStore.d.ts.map +1 -1
  236. package/lib/typescript/ui/styles/authStyles.d.ts +326 -0
  237. package/lib/typescript/ui/styles/authStyles.d.ts.map +1 -0
  238. package/lib/typescript/ui/styles/index.d.ts +1 -0
  239. package/lib/typescript/ui/styles/index.d.ts.map +1 -1
  240. package/package.json +1 -4
  241. package/src/core/index.ts +195 -41
  242. package/src/index.ts +64 -4
  243. package/src/ui/components/Avatar.tsx +11 -5
  244. package/src/ui/components/FollowButton.tsx +95 -11
  245. package/src/ui/components/GroupedItem.tsx +57 -9
  246. package/src/ui/components/GroupedSection.tsx +12 -0
  247. package/src/ui/components/Header.tsx +405 -0
  248. package/src/ui/components/OxyProvider.tsx +37 -15
  249. package/src/ui/components/index.ts +1 -0
  250. package/src/ui/components/internal/GroupedPillButtons.tsx +1 -1
  251. package/src/ui/components/internal/TextField.md +436 -0
  252. package/src/ui/components/internal/TextField.tsx +720 -620
  253. package/src/ui/context/OxyContext.tsx +211 -195
  254. package/src/ui/hooks/index.ts +1 -1
  255. package/src/ui/hooks/useFollow.ts +63 -0
  256. package/src/ui/hooks/useSessionSocket.ts +5 -2
  257. package/src/ui/navigation/OxyRouter.tsx +11 -1
  258. package/src/ui/navigation/types.ts +10 -2
  259. package/src/ui/screens/AccountCenterScreen.tsx +5 -5
  260. package/src/ui/screens/AccountManagementDemo.tsx +9 -9
  261. package/src/ui/screens/AccountOverviewScreen.tsx +265 -414
  262. package/src/ui/screens/AccountSettingsScreen.tsx +1173 -403
  263. package/src/ui/screens/AccountSwitcherScreen.tsx +158 -202
  264. package/src/ui/screens/AppInfoScreen.tsx +270 -497
  265. package/src/ui/screens/FeedbackScreen.tsx +3 -3
  266. package/src/ui/screens/PaymentGatewayScreen.tsx +668 -365
  267. package/src/ui/screens/ProfileScreen.tsx +196 -33
  268. package/src/ui/screens/RecoverAccountScreen.tsx +46 -74
  269. package/src/ui/screens/SessionManagementScreen.tsx +14 -22
  270. package/src/ui/screens/SignInScreen.tsx +27 -294
  271. package/src/ui/screens/SignUpScreen.tsx +5 -5
  272. package/src/ui/screens/UserLinksScreen.tsx +96 -0
  273. package/src/ui/screens/internal/SignInPasswordStep.tsx +11 -22
  274. package/src/ui/screens/internal/SignInUsernameStep.tsx +3 -10
  275. package/src/ui/screens/internal/SignUpIdentityStep.tsx +2 -5
  276. package/src/ui/screens/internal/SignUpSecurityStep.tsx +3 -4
  277. package/src/ui/screens/karma/KarmaAboutScreen.tsx +9 -2
  278. package/src/ui/screens/karma/KarmaCenterScreen.tsx +1 -20
  279. package/src/ui/screens/karma/KarmaFAQScreen.tsx +40 -24
  280. package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +9 -3
  281. package/src/ui/screens/karma/KarmaRewardsScreen.tsx +9 -3
  282. package/src/ui/screens/karma/KarmaRulesScreen.tsx +9 -3
  283. package/src/ui/stores/authStore.ts +34 -7
  284. package/src/ui/stores/followStore.ts +102 -1
  285. package/src/ui/styles/authStyles.ts +352 -0
  286. package/src/ui/styles/index.ts +1 -0
  287. package/lib/commonjs/core/auth-manager.js +0 -440
  288. package/lib/commonjs/core/auth-manager.js.map +0 -1
  289. package/lib/commonjs/core/use-auth.js +0 -244
  290. package/lib/commonjs/core/use-auth.js.map +0 -1
  291. package/lib/module/core/auth-manager.js +0 -432
  292. package/lib/module/core/auth-manager.js.map +0 -1
  293. package/lib/module/core/use-auth.js +0 -235
  294. package/lib/module/core/use-auth.js.map +0 -1
  295. package/lib/typescript/core/auth-manager.d.ts +0 -136
  296. package/lib/typescript/core/auth-manager.d.ts.map +0 -1
  297. package/lib/typescript/core/use-auth.d.ts +0 -79
  298. package/lib/typescript/core/use-auth.d.ts.map +0 -1
  299. package/src/__tests__/middleware.test.ts +0 -105
  300. package/src/__tests__/setup.ts +0 -10
  301. package/src/__tests__/zero-config-auth.test.ts +0 -607
  302. package/src/core/auth-manager.ts +0 -500
  303. package/src/core/use-auth.tsx +0 -245
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import React, { createContext, useContext, useEffect, useCallback, useMemo } from 'react';
3
+ import React, { createContext, useContext, useEffect, useCallback, useMemo, useRef } from 'react';
4
+ import { OxyServices } from '../../core';
4
5
  import { DeviceManager } from '../../utils/deviceManager';
5
6
  import { useSessionSocket } from '../hooks/useSessionSocket';
6
7
  import { toast } from '../../lib/sonner';
@@ -58,17 +59,32 @@ const getStorage = async () => {
58
59
 
59
60
  // Storage keys for secure sessions
60
61
  const getSecureStorageKeys = (prefix = 'oxy_secure') => ({
61
- sessions: `${prefix}_sessions`,
62
- // Array of SecureClientSession objects
63
- activeSessionId: `${prefix}_active_session_id` // ID of currently active session
62
+ activeSessionId: `${prefix}_active_session_id` // Only store the active session ID
64
63
  });
65
- export const OxyContextProvider = ({
64
+ export const OxyProvider = ({
66
65
  children,
67
- oxyServices,
66
+ oxyServices: providedOxyServices,
67
+ baseURL,
68
68
  storageKeyPrefix = 'oxy_secure',
69
69
  onAuthStateChange,
70
+ onError,
70
71
  bottomSheetRef
71
72
  }) => {
73
+ // Create oxyServices automatically if not provided
74
+ const oxyServicesRef = useRef(null);
75
+ if (!oxyServicesRef.current) {
76
+ if (providedOxyServices) {
77
+ oxyServicesRef.current = providedOxyServices;
78
+ } else if (baseURL) {
79
+ oxyServicesRef.current = new OxyServices({
80
+ baseURL
81
+ });
82
+ } else {
83
+ throw new Error('Either oxyServices or baseURL must be provided to OxyContextProvider');
84
+ }
85
+ }
86
+ const oxyServices = oxyServicesRef.current;
87
+
72
88
  // Zustand state
73
89
  const user = useAuthStore(state => state.user);
74
90
  const isAuthenticated = useAuthStore(state => state.isAuthenticated);
@@ -105,7 +121,7 @@ export const OxyContextProvider = ({
105
121
  initStorage();
106
122
  }, []);
107
123
 
108
- // Effect to initialize authentication state
124
+ // Effect to initialize authentication state - only store session ID
109
125
  useEffect(() => {
110
126
  const initAuth = async () => {
111
127
  if (!storage) return;
@@ -113,79 +129,49 @@ export const OxyContextProvider = ({
113
129
  isLoading: true
114
130
  });
115
131
  try {
116
- // Load stored sessions
117
- const sessionsData = await storage.getItem(keys.sessions);
132
+ // Only load the active session ID from storage
118
133
  const storedActiveSessionId = await storage.getItem(keys.activeSessionId);
119
- console.log('SecureAuth - sessionsData:', sessionsData);
120
134
  console.log('SecureAuth - activeSessionId:', storedActiveSessionId);
121
- if (sessionsData) {
122
- const parsedSessions = JSON.parse(sessionsData);
123
-
124
- // Migrate old session format to include user info
125
- const migratedSessions = [];
126
- let shouldUpdateStorage = false;
127
- for (const session of parsedSessions) {
128
- if (!session.userId) {
129
- // Session is missing user info, try to fetch it
130
- try {
131
- const sessionUser = await oxyServices.getUserBySession(session.sessionId);
132
- migratedSessions.push({
133
- ...session,
134
- userId: sessionUser.id
135
- });
136
- shouldUpdateStorage = true;
137
- console.log(`Migrated session ${session.sessionId} for user ${sessionUser.id}`);
138
- } catch (error) {
139
- // Session might be invalid, skip it
140
- console.log(`Removing invalid session ${session.sessionId}:`, error);
141
- shouldUpdateStorage = true;
135
+ if (storedActiveSessionId) {
136
+ // Validate the stored session with the backend
137
+ try {
138
+ const validation = await oxyServices.validateSession(storedActiveSessionId);
139
+ if (validation.valid) {
140
+ console.log('SecureAuth - session validated successfully');
141
+ setActiveSessionId(storedActiveSessionId);
142
+
143
+ // Get access token for API calls
144
+ await oxyServices.getTokenBySession(storedActiveSessionId);
145
+
146
+ // Load full user data from backend
147
+ const fullUser = await oxyServices.getUserBySession(storedActiveSessionId);
148
+ loginSuccess(fullUser);
149
+ setMinimalUser({
150
+ id: fullUser.id,
151
+ username: fullUser.username,
152
+ avatar: fullUser.avatar
153
+ });
154
+
155
+ // Load sessions from backend
156
+ const serverSessions = await oxyServices.getSessionsBySessionId(storedActiveSessionId);
157
+ const clientSessions = serverSessions.map(serverSession => ({
158
+ sessionId: serverSession.sessionId,
159
+ deviceId: serverSession.deviceId,
160
+ expiresAt: serverSession.expiresAt || new Date().toISOString(),
161
+ lastActive: serverSession.lastActive || new Date().toISOString(),
162
+ userId: serverSession.userId || fullUser.id
163
+ }));
164
+ setSessions(clientSessions);
165
+ if (onAuthStateChange) {
166
+ onAuthStateChange(fullUser);
142
167
  }
143
168
  } else {
144
- // Session already has user info
145
- migratedSessions.push(session);
146
- }
147
- }
148
-
149
- // Update storage if we made changes
150
- if (shouldUpdateStorage) {
151
- await saveSessionsToStorage(migratedSessions);
152
- }
153
- setSessions(migratedSessions);
154
- if (storedActiveSessionId && migratedSessions.length > 0) {
155
- const activeSession = migratedSessions.find(s => s.sessionId === storedActiveSessionId);
156
- if (activeSession) {
157
- console.log('SecureAuth - activeSession found:', activeSession);
158
-
159
- // Validate session
160
- try {
161
- const validation = await oxyServices.validateSession(activeSession.sessionId);
162
- if (validation.valid) {
163
- console.log('SecureAuth - session validated successfully');
164
- setActiveSessionId(activeSession.sessionId);
165
-
166
- // Get access token for API calls
167
- await oxyServices.getTokenBySession(activeSession.sessionId);
168
-
169
- // Load full user data
170
- const fullUser = await oxyServices.getUserBySession(activeSession.sessionId);
171
- loginSuccess(fullUser);
172
- setMinimalUser({
173
- id: fullUser.id,
174
- username: fullUser.username,
175
- avatar: fullUser.avatar
176
- });
177
- if (onAuthStateChange) {
178
- onAuthStateChange(fullUser);
179
- }
180
- } else {
181
- console.log('SecureAuth - session invalid, removing');
182
- await removeInvalidSession(activeSession.sessionId);
183
- }
184
- } catch (error) {
185
- console.error('SecureAuth - session validation error:', error);
186
- await removeInvalidSession(activeSession.sessionId);
187
- }
169
+ console.log('SecureAuth - session invalid, clearing storage');
170
+ await clearAllStorage();
188
171
  }
172
+ } catch (error) {
173
+ console.error('SecureAuth - session validation error:', error);
174
+ await clearAllStorage();
189
175
  }
190
176
  }
191
177
  } catch (err) {
@@ -200,33 +186,13 @@ export const OxyContextProvider = ({
200
186
  if (storage) {
201
187
  initAuth();
202
188
  }
203
- }, [storage, oxyServices, keys, onAuthStateChange]);
204
-
205
- // Effect to restore token on app load or session switch
206
- useEffect(() => {
207
- const restoreToken = async () => {
208
- if (activeSessionId && oxyServices) {
209
- try {
210
- await oxyServices.getTokenBySession(activeSessionId);
211
- setTokenReady(true);
212
- } catch (err) {
213
- // If token restoration fails, force logout
214
- await logout();
215
- setTokenReady(false);
216
- }
217
- } else {
218
- setTokenReady(true); // No session, so token is not needed
219
- }
220
- };
221
- restoreToken();
222
- // Only run when activeSessionId or oxyServices changes
223
- }, [activeSessionId, oxyServices]);
189
+ }, [storage, oxyServices, keys, onAuthStateChange, loginSuccess, setMinimalUser]);
224
190
 
225
- // Remove invalid session
191
+ // Remove invalid session - refresh sessions from backend
226
192
  const removeInvalidSession = useCallback(async sessionId => {
193
+ // Remove from local state
227
194
  const filteredSessions = sessions.filter(s => s.sessionId !== sessionId);
228
195
  setSessions(filteredSessions);
229
- await saveSessionsToStorage(filteredSessions);
230
196
 
231
197
  // If there are other sessions, switch to the first one
232
198
  if (filteredSessions.length > 0) {
@@ -243,13 +209,7 @@ export const OxyContextProvider = ({
243
209
  }
244
210
  }, [sessions, storage, keys, onAuthStateChange, logoutStore]);
245
211
 
246
- // Save sessions to storage
247
- const saveSessionsToStorage = useCallback(async sessionsList => {
248
- if (!storage) return;
249
- await storage.setItem(keys.sessions, JSON.stringify(sessionsList));
250
- }, [storage, keys.sessions]);
251
-
252
- // Save active session ID to storage
212
+ // Save active session ID to storage (only session ID, no user data)
253
213
  const saveActiveSessionId = useCallback(async sessionId => {
254
214
  if (!storage) return;
255
215
  await storage.setItem(keys.activeSessionId, sessionId);
@@ -259,7 +219,6 @@ export const OxyContextProvider = ({
259
219
  const clearAllStorage = useCallback(async () => {
260
220
  if (!storage) return;
261
221
  try {
262
- await storage.removeItem(keys.sessions);
263
222
  await storage.removeItem(keys.activeSessionId);
264
223
  } catch (err) {
265
224
  console.error('Clear secure storage error:', err);
@@ -301,8 +260,8 @@ export const OxyContextProvider = ({
301
260
  }
302
261
  }, [oxyServices, onAuthStateChange, loginSuccess, saveActiveSessionId]);
303
262
 
304
- // Secure login method
305
- const login = async (username, password, deviceName) => {
263
+ // Secure login method - only store session ID, retrieve data from backend
264
+ const login = useCallback(async (username, password, deviceName) => {
306
265
  if (!storage) throw new Error('Storage not initialized');
307
266
  useAuthStore.setState({
308
267
  isLoading: true,
@@ -318,49 +277,28 @@ export const OxyContextProvider = ({
318
277
  console.log('SecureAuth - Using device ID:', deviceInfo.deviceId);
319
278
  const response = await oxyServices.secureLogin(username, password, deviceName || deviceInfo.deviceName || DeviceManager.getDefaultDeviceName(), deviceFingerprint);
320
279
 
321
- // Create client session object with user info for duplicate detection
322
- const clientSession = {
323
- sessionId: response.sessionId,
324
- deviceId: response.deviceId,
325
- expiresAt: response.expiresAt,
326
- lastActive: new Date().toISOString(),
327
- userId: response.user.id
328
- };
329
-
330
- // Check if this user already has a session (prevent duplicate accounts)
331
- const existingUserSessionIndex = sessions.findIndex(s => s.userId === response.user.id);
332
- let updatedSessions;
333
- if (existingUserSessionIndex !== -1) {
334
- // User already has a session - replace it with the new one (reused session scenario)
335
- const existingSession = sessions[existingUserSessionIndex];
336
- updatedSessions = [...sessions];
337
- updatedSessions[existingUserSessionIndex] = clientSession;
338
- console.log(`Reusing/updating existing session for user ${response.user.id}. Previous session: ${existingSession.sessionId}, New session: ${response.sessionId}`);
339
-
340
- // If the replaced session was the active one, update active session
341
- if (activeSessionId === existingSession.sessionId) {
342
- setActiveSessionId(response.sessionId);
343
- await saveActiveSessionId(response.sessionId);
344
- }
345
- } else {
346
- // Add new session for new user
347
- updatedSessions = [...sessions, clientSession];
348
- console.log(`Added new session for user ${response.user.id} on device ${response.deviceId}`);
349
- }
350
- setSessions(updatedSessions);
351
- await saveSessionsToStorage(updatedSessions);
352
-
353
- // Set as active session
280
+ // Set as active session (only store session ID)
354
281
  setActiveSessionId(response.sessionId);
355
282
  await saveActiveSessionId(response.sessionId);
356
283
 
357
284
  // Get access token for API calls
358
285
  await oxyServices.getTokenBySession(response.sessionId);
359
286
 
360
- // Load full user data
287
+ // Load full user data from backend
361
288
  const fullUser = await oxyServices.getUserBySession(response.sessionId);
362
289
  loginSuccess(fullUser);
363
290
  setMinimalUser(response.user);
291
+
292
+ // Load sessions from backend
293
+ const serverSessions = await oxyServices.getSessionsBySessionId(response.sessionId);
294
+ const clientSessions = serverSessions.map(serverSession => ({
295
+ sessionId: serverSession.sessionId,
296
+ deviceId: serverSession.deviceId,
297
+ expiresAt: serverSession.expiresAt || new Date().toISOString(),
298
+ lastActive: serverSession.lastActive || new Date().toISOString(),
299
+ userId: serverSession.userId || fullUser.id
300
+ }));
301
+ setSessions(clientSessions);
364
302
  if (onAuthStateChange) {
365
303
  onAuthStateChange(fullUser);
366
304
  }
@@ -373,19 +311,18 @@ export const OxyContextProvider = ({
373
311
  isLoading: false
374
312
  });
375
313
  }
376
- };
314
+ }, [storage, oxyServices, saveActiveSessionId, loginSuccess, setMinimalUser, onAuthStateChange, loginFailure]);
377
315
 
378
316
  // Logout method
379
- const logout = async targetSessionId => {
317
+ const logout = useCallback(async targetSessionId => {
380
318
  if (!activeSessionId) return;
381
319
  try {
382
320
  const sessionToLogout = targetSessionId || activeSessionId;
383
321
  await oxyServices.logoutSecureSession(activeSessionId, sessionToLogout);
384
322
 
385
- // Remove session from local storage
323
+ // Remove session from local state
386
324
  const filteredSessions = sessions.filter(s => s.sessionId !== sessionToLogout);
387
325
  setSessions(filteredSessions);
388
- await saveSessionsToStorage(filteredSessions);
389
326
 
390
327
  // If logging out active session
391
328
  if (sessionToLogout === activeSessionId) {
@@ -409,10 +346,10 @@ export const OxyContextProvider = ({
409
346
  error: 'Logout failed'
410
347
  });
411
348
  }
412
- };
349
+ }, [activeSessionId, oxyServices, sessions, switchToSession, logoutStore, setMinimalUser, storage, keys.activeSessionId, onAuthStateChange]);
413
350
 
414
351
  // Logout all sessions
415
- const logoutAll = async () => {
352
+ const logoutAll = useCallback(async () => {
416
353
  console.log('logoutAll called with activeSessionId:', activeSessionId);
417
354
  if (!activeSessionId) {
418
355
  console.error('No active session ID found, cannot logout all');
@@ -451,10 +388,30 @@ export const OxyContextProvider = ({
451
388
  });
452
389
  throw error;
453
390
  }
454
- };
391
+ }, [activeSessionId, oxyServices, logoutStore, setMinimalUser, clearAllStorage, onAuthStateChange]);
392
+
393
+ // Effect to restore token on app load or session switch
394
+ useEffect(() => {
395
+ const restoreToken = async () => {
396
+ if (activeSessionId && oxyServices) {
397
+ try {
398
+ await oxyServices.getTokenBySession(activeSessionId);
399
+ setTokenReady(true);
400
+ } catch (err) {
401
+ // If token restoration fails, force logout
402
+ await logout();
403
+ setTokenReady(false);
404
+ }
405
+ } else {
406
+ setTokenReady(true); // No session, so token is not needed
407
+ }
408
+ };
409
+ restoreToken();
410
+ // Only run when activeSessionId or oxyServices changes
411
+ }, [activeSessionId, oxyServices, logout]);
455
412
 
456
413
  // Sign up method
457
- const signUp = async (username, email, password) => {
414
+ const signUp = useCallback(async (username, email, password) => {
458
415
  if (!storage) throw new Error('Storage not initialized');
459
416
  useAuthStore.setState({
460
417
  isLoading: true,
@@ -477,41 +434,77 @@ export const OxyContextProvider = ({
477
434
  isLoading: false
478
435
  });
479
436
  }
480
- };
437
+ }, [storage, oxyServices, login, loginFailure]);
481
438
 
482
439
  // Switch session method
483
- const switchSession = async sessionId => {
440
+ const switchSession = useCallback(async sessionId => {
484
441
  await switchToSession(sessionId);
485
- };
442
+ }, [switchToSession]);
486
443
 
487
444
  // Remove session method
488
- const removeSession = async sessionId => {
445
+ const removeSession = useCallback(async sessionId => {
489
446
  await logout(sessionId);
490
- };
447
+ }, [logout]);
491
448
 
492
449
  // Refresh sessions method
493
- const refreshSessions = async () => {
494
- if (!activeSessionId) return;
450
+ const refreshSessions = useCallback(async () => {
451
+ console.log('refreshSessions called with activeSessionId:', activeSessionId);
452
+ if (!activeSessionId) {
453
+ console.log('refreshSessions: No activeSessionId, returning');
454
+ return;
455
+ }
495
456
  try {
457
+ console.log('refreshSessions: Calling getSessionsBySessionId...');
496
458
  const serverSessions = await oxyServices.getSessionsBySessionId(activeSessionId);
459
+ console.log('refreshSessions: Server sessions received:', serverSessions);
497
460
 
498
461
  // Update local sessions with server data
499
462
  const updatedSessions = serverSessions.map(serverSession => ({
500
463
  sessionId: serverSession.sessionId,
501
464
  deviceId: serverSession.deviceId,
502
- expiresAt: new Date().toISOString(),
503
- // You might want to get this from server
504
- lastActive: new Date().toISOString()
465
+ expiresAt: serverSession.expiresAt || new Date().toISOString(),
466
+ lastActive: serverSession.lastActive || new Date().toISOString(),
467
+ userId: serverSession.userId || user?.id
505
468
  }));
469
+ console.log('refreshSessions: Updated sessions:', updatedSessions);
506
470
  setSessions(updatedSessions);
507
- await saveSessionsToStorage(updatedSessions);
471
+ console.log('refreshSessions: Sessions updated in state');
508
472
  } catch (error) {
509
473
  console.error('Refresh sessions error:', error);
474
+
475
+ // If the current session is invalid, try to find another valid session
476
+ if (sessions.length > 1) {
477
+ console.log('Current session invalid, trying to switch to another session...');
478
+ const otherSessions = sessions.filter(s => s.sessionId !== activeSessionId);
479
+ for (const session of otherSessions) {
480
+ try {
481
+ // Try to validate this session
482
+ await oxyServices.validateSession(session.sessionId);
483
+ console.log('Found valid session, switching to:', session.sessionId);
484
+ await switchToSession(session.sessionId);
485
+ return; // Successfully switched to another session
486
+ } catch (sessionError) {
487
+ console.log('Session validation failed for:', session.sessionId, sessionError);
488
+ continue; // Try next session
489
+ }
490
+ }
491
+ }
492
+
493
+ // If no valid sessions found, clear all sessions
494
+ console.log('No valid sessions found, clearing all sessions');
495
+ setSessions([]);
496
+ setActiveSessionId(null);
497
+ logoutStore();
498
+ setMinimalUser(null);
499
+ await clearAllStorage();
500
+ if (onAuthStateChange) {
501
+ onAuthStateChange(null);
502
+ }
510
503
  }
511
- };
504
+ }, [activeSessionId, oxyServices, user?.id, sessions, switchToSession, logoutStore, setMinimalUser, clearAllStorage, onAuthStateChange]);
512
505
 
513
506
  // Device management methods
514
- const getDeviceSessions = async () => {
507
+ const getDeviceSessions = useCallback(async () => {
515
508
  if (!activeSessionId) throw new Error('No active session');
516
509
  try {
517
510
  return await oxyServices.getDeviceSessions(activeSessionId);
@@ -519,8 +512,8 @@ export const OxyContextProvider = ({
519
512
  console.error('Get device sessions error:', error);
520
513
  throw error;
521
514
  }
522
- };
523
- const logoutAllDeviceSessions = async () => {
515
+ }, [activeSessionId, oxyServices]);
516
+ const logoutAllDeviceSessions = useCallback(async () => {
524
517
  if (!activeSessionId) throw new Error('No active session');
525
518
  try {
526
519
  await oxyServices.logoutAllDeviceSessions(activeSessionId);
@@ -538,8 +531,8 @@ export const OxyContextProvider = ({
538
531
  console.error('Logout all device sessions error:', error);
539
532
  throw error;
540
533
  }
541
- };
542
- const updateDeviceName = async deviceName => {
534
+ }, [activeSessionId, oxyServices, logoutStore, setMinimalUser, clearAllStorage, onAuthStateChange]);
535
+ const updateDeviceName = useCallback(async deviceName => {
543
536
  if (!activeSessionId) throw new Error('No active session');
544
537
  try {
545
538
  await oxyServices.updateDeviceName(activeSessionId, deviceName);
@@ -550,7 +543,7 @@ export const OxyContextProvider = ({
550
543
  console.error('Update device name error:', error);
551
544
  throw error;
552
545
  }
553
- };
546
+ }, [activeSessionId, oxyServices]);
554
547
 
555
548
  // Bottom sheet control methods
556
549
  const showBottomSheet = useCallback(screenOrConfig => {
@@ -567,6 +560,7 @@ export const OxyContextProvider = ({
567
560
  bottomSheetRef.current.present();
568
561
  } else {
569
562
  console.warn('No expand or present method available on bottomSheetRef');
563
+ console.log('Available methods on bottomSheetRef.current:', Object.keys(bottomSheetRef.current));
570
564
  }
571
565
 
572
566
  // Then navigate to the specified screen if provided
@@ -586,6 +580,8 @@ export const OxyContextProvider = ({
586
580
  }
587
581
  } else {
588
582
  console.warn('bottomSheetRef is not available');
583
+ console.warn('To fix this, ensure you pass a bottomSheetRef to OxyProvider:');
584
+ console.warn('<OxyProvider baseURL="..." bottomSheetRef={yourBottomSheetRef}>');
589
585
  }
590
586
  }, [bottomSheetRef]);
591
587
  const hideBottomSheet = useCallback(() => {
@@ -600,16 +596,16 @@ export const OxyContextProvider = ({
600
596
  userId: user?.id,
601
597
  activeSessionId,
602
598
  refreshSessions,
603
- logout: () => logout(),
599
+ logout,
604
600
  baseURL: oxyServices.getBaseURL(),
605
- onRemoteSignOut: () => {
601
+ onRemoteSignOut: useCallback(() => {
606
602
  toast.info('You have been signed out remotely.');
607
603
  logout();
608
- }
604
+ }, [logout])
609
605
  });
610
606
 
611
607
  // Context value
612
- const contextValue = {
608
+ const contextValue = useMemo(() => ({
613
609
  user,
614
610
  minimalUser,
615
611
  sessions,
@@ -619,36 +615,19 @@ export const OxyContextProvider = ({
619
615
  error,
620
616
  login,
621
617
  logout,
622
- logoutAll: async () => {
623
- await logout();
624
- },
625
- signUp: async (username, email, password) => {
626
- await signUp(username, email, password);
627
- return user; // Return the latest user from Zustand
628
- },
629
- switchSession: async sessionId => {
630
- await switchToSession(sessionId);
631
- },
632
- removeSession: async sessionId => {
633
- await removeSession(sessionId);
634
- },
635
- refreshSessions: async () => {
636
- await refreshSessions();
637
- },
638
- getDeviceSessions: async () => {
639
- return await getDeviceSessions();
640
- },
641
- logoutAllDeviceSessions: async () => {
642
- await logoutAllDeviceSessions();
643
- },
644
- updateDeviceName: async deviceName => {
645
- await updateDeviceName(deviceName);
646
- },
618
+ logoutAll,
619
+ signUp,
620
+ switchSession,
621
+ removeSession,
622
+ refreshSessions,
623
+ getDeviceSessions,
624
+ logoutAllDeviceSessions,
625
+ updateDeviceName,
647
626
  oxyServices,
648
627
  bottomSheetRef,
649
628
  showBottomSheet,
650
629
  hideBottomSheet
651
- };
630
+ }), [user, minimalUser, sessions, activeSessionId, isAuthenticated, isLoading, error, login, logout, logoutAll, signUp, switchSession, removeSession, refreshSessions, getDeviceSessions, logoutAllDeviceSessions, updateDeviceName, oxyServices, bottomSheetRef, showBottomSheet, hideBottomSheet]);
652
631
 
653
632
  // Wrap children rendering to block until token is ready
654
633
  if (!tokenReady) {
@@ -662,6 +641,9 @@ export const OxyContextProvider = ({
662
641
  });
663
642
  };
664
643
 
644
+ // Alias for backward compatibility
645
+ export const OxyContextProvider = OxyProvider;
646
+
665
647
  // Hook to use the context
666
648
  export const useOxy = () => {
667
649
  const context = useContext(OxyContext);