@oxyhq/services 15.0.0 → 17.0.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 (280) hide show
  1. package/lib/commonjs/index.js +25 -55
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/client.js +0 -14
  4. package/lib/commonjs/ui/client.js.map +1 -1
  5. package/lib/commonjs/ui/components/OxyAccountDialog.js +764 -0
  6. package/lib/commonjs/ui/components/OxyAccountDialog.js.map +1 -0
  7. package/lib/commonjs/ui/components/OxyProvider.js +11 -6
  8. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  9. package/lib/commonjs/ui/components/OxySignInButton.js +10 -21
  10. package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
  11. package/lib/commonjs/ui/components/ProfileButton.js +25 -112
  12. package/lib/commonjs/ui/components/ProfileButton.js.map +1 -1
  13. package/lib/commonjs/ui/components/RequireOxyAuth.js +299 -0
  14. package/lib/commonjs/ui/components/RequireOxyAuth.js.map +1 -0
  15. package/lib/commonjs/ui/context/OxyContext.js +106 -2
  16. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  17. package/lib/commonjs/ui/hooks/mutations/mutationKeys.js +1 -1
  18. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +10 -10
  19. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  20. package/lib/commonjs/ui/hooks/queries/queryKeys.js +1 -1
  21. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +7 -8
  22. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  23. package/lib/commonjs/ui/hooks/useAuth.js +19 -30
  24. package/lib/commonjs/ui/hooks/useAuth.js.map +1 -1
  25. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js +37 -267
  26. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js.map +1 -1
  27. package/lib/commonjs/ui/index.js +5 -40
  28. package/lib/commonjs/ui/index.js.map +1 -1
  29. package/lib/commonjs/ui/navigation/accountDialogManager.js +91 -0
  30. package/lib/commonjs/ui/navigation/accountDialogManager.js.map +1 -0
  31. package/lib/commonjs/ui/navigation/routes.js +0 -2
  32. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  33. package/lib/commonjs/ui/screens/ConnectedAppsScreen.js +17 -18
  34. package/lib/commonjs/ui/screens/ConnectedAppsScreen.js.map +1 -1
  35. package/lib/commonjs/ui/screens/ManageAccountScreen.js +4 -3
  36. package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
  37. package/lib/commonjs/ui/session/createSessionClient.js +10 -2
  38. package/lib/commonjs/ui/session/createSessionClient.js.map +1 -1
  39. package/lib/module/index.js +20 -17
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/ui/client.js +1 -2
  42. package/lib/module/ui/client.js.map +1 -1
  43. package/lib/module/ui/components/OxyAccountDialog.js +761 -0
  44. package/lib/module/ui/components/OxyAccountDialog.js.map +1 -0
  45. package/lib/module/ui/components/OxyProvider.js +11 -6
  46. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  47. package/lib/module/ui/components/OxySignInButton.js +10 -21
  48. package/lib/module/ui/components/OxySignInButton.js.map +1 -1
  49. package/lib/module/ui/components/ProfileButton.js +26 -112
  50. package/lib/module/ui/components/ProfileButton.js.map +1 -1
  51. package/lib/module/ui/components/RequireOxyAuth.js +294 -0
  52. package/lib/module/ui/components/RequireOxyAuth.js.map +1 -0
  53. package/lib/module/ui/context/OxyContext.js +107 -3
  54. package/lib/module/ui/context/OxyContext.js.map +1 -1
  55. package/lib/module/ui/hooks/mutations/mutationKeys.js +1 -1
  56. package/lib/module/ui/hooks/mutations/useAccountMutations.js +8 -8
  57. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  58. package/lib/module/ui/hooks/queries/queryKeys.js +1 -1
  59. package/lib/module/ui/hooks/queries/useAccountQueries.js +5 -6
  60. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  61. package/lib/module/ui/hooks/useAuth.js +19 -30
  62. package/lib/module/ui/hooks/useAuth.js.map +1 -1
  63. package/lib/module/ui/hooks/useSwitchableAccounts.js +38 -267
  64. package/lib/module/ui/hooks/useSwitchableAccounts.js.map +1 -1
  65. package/lib/module/ui/index.js +1 -5
  66. package/lib/module/ui/index.js.map +1 -1
  67. package/lib/module/ui/navigation/accountDialogManager.js +81 -0
  68. package/lib/module/ui/navigation/accountDialogManager.js.map +1 -0
  69. package/lib/module/ui/navigation/routes.js +0 -2
  70. package/lib/module/ui/navigation/routes.js.map +1 -1
  71. package/lib/module/ui/screens/ConnectedAppsScreen.js +19 -20
  72. package/lib/module/ui/screens/ConnectedAppsScreen.js.map +1 -1
  73. package/lib/module/ui/screens/ManageAccountScreen.js +4 -3
  74. package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
  75. package/lib/module/ui/session/createSessionClient.js +10 -2
  76. package/lib/module/ui/session/createSessionClient.js.map +1 -1
  77. package/lib/typescript/commonjs/index.d.ts +6 -13
  78. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/ui/client.d.ts +0 -4
  80. package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/ui/components/OxyAccountDialog.d.ts +35 -0
  82. package/lib/typescript/commonjs/ui/components/OxyAccountDialog.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts +2 -2
  84. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts +11 -23
  87. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/ui/components/RequireOxyAuth.d.ts +55 -0
  89. package/lib/typescript/commonjs/ui/components/RequireOxyAuth.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +13 -1
  91. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +4 -4
  93. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +6 -7
  95. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts +13 -152
  98. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/ui/index.d.ts +2 -5
  100. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts +49 -0
  102. package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
  104. package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/ui/screens/ConnectedAppsScreen.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts +1 -1
  107. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts +9 -2
  109. package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/ui/types/navigation.d.ts +9 -0
  111. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/ui/utils/storageHelpers.d.ts +7 -7
  113. package/lib/typescript/module/index.d.ts +6 -13
  114. package/lib/typescript/module/index.d.ts.map +1 -1
  115. package/lib/typescript/module/ui/client.d.ts +0 -4
  116. package/lib/typescript/module/ui/client.d.ts.map +1 -1
  117. package/lib/typescript/module/ui/components/OxyAccountDialog.d.ts +35 -0
  118. package/lib/typescript/module/ui/components/OxyAccountDialog.d.ts.map +1 -0
  119. package/lib/typescript/module/ui/components/OxyProvider.d.ts +2 -2
  120. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  121. package/lib/typescript/module/ui/components/OxySignInButton.d.ts.map +1 -1
  122. package/lib/typescript/module/ui/components/ProfileButton.d.ts +11 -23
  123. package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -1
  124. package/lib/typescript/module/ui/components/RequireOxyAuth.d.ts +55 -0
  125. package/lib/typescript/module/ui/components/RequireOxyAuth.d.ts.map +1 -0
  126. package/lib/typescript/module/ui/context/OxyContext.d.ts +13 -1
  127. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  128. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +4 -4
  129. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  130. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +6 -7
  131. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  132. package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
  133. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts +13 -152
  134. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts.map +1 -1
  135. package/lib/typescript/module/ui/index.d.ts +2 -5
  136. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  137. package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts +49 -0
  138. package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts.map +1 -0
  139. package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
  140. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  141. package/lib/typescript/module/ui/screens/ConnectedAppsScreen.d.ts.map +1 -1
  142. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts +1 -1
  143. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  144. package/lib/typescript/module/ui/session/createSessionClient.d.ts +9 -2
  145. package/lib/typescript/module/ui/session/createSessionClient.d.ts.map +1 -1
  146. package/lib/typescript/module/ui/types/navigation.d.ts +9 -0
  147. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  148. package/lib/typescript/module/ui/utils/storageHelpers.d.ts +7 -7
  149. package/package.json +4 -4
  150. package/src/index.ts +23 -28
  151. package/src/ui/client.ts +0 -4
  152. package/src/ui/components/OxyAccountDialog.tsx +760 -0
  153. package/src/ui/components/OxyProvider.tsx +12 -6
  154. package/src/ui/components/OxySignInButton.tsx +10 -21
  155. package/src/ui/components/ProfileButton.tsx +23 -126
  156. package/src/ui/components/RequireOxyAuth.tsx +266 -0
  157. package/src/ui/context/OxyContext.tsx +146 -7
  158. package/src/ui/hooks/mutations/mutationKeys.ts +1 -1
  159. package/src/ui/hooks/mutations/useAccountMutations.ts +8 -8
  160. package/src/ui/hooks/queries/queryKeys.ts +1 -1
  161. package/src/ui/hooks/queries/useAccountQueries.ts +8 -9
  162. package/src/ui/hooks/useAuth.ts +19 -31
  163. package/src/ui/hooks/useSwitchableAccounts.ts +42 -376
  164. package/src/ui/index.ts +2 -5
  165. package/src/ui/navigation/accountDialogManager.ts +84 -0
  166. package/src/ui/navigation/routes.ts +1 -5
  167. package/src/ui/screens/ConnectedAppsScreen.tsx +23 -24
  168. package/src/ui/screens/ManageAccountScreen.tsx +3 -2
  169. package/src/ui/session/createSessionClient.ts +9 -1
  170. package/src/ui/types/navigation.ts +9 -0
  171. package/src/ui/utils/storageHelpers.ts +7 -7
  172. package/lib/commonjs/ui/components/AccountMenu.js +0 -598
  173. package/lib/commonjs/ui/components/AccountMenu.js.map +0 -1
  174. package/lib/commonjs/ui/components/AccountMenuButton.js +0 -135
  175. package/lib/commonjs/ui/components/AccountMenuButton.js.map +0 -1
  176. package/lib/commonjs/ui/components/AccountSwitcher.js +0 -780
  177. package/lib/commonjs/ui/components/AccountSwitcher.js.map +0 -1
  178. package/lib/commonjs/ui/components/AnotherDeviceQR.js +0 -116
  179. package/lib/commonjs/ui/components/AnotherDeviceQR.js.map +0 -1
  180. package/lib/commonjs/ui/components/ProfileMenu.js +0 -518
  181. package/lib/commonjs/ui/components/ProfileMenu.js.map +0 -1
  182. package/lib/commonjs/ui/components/SignInAccountChooser.js +0 -189
  183. package/lib/commonjs/ui/components/SignInAccountChooser.js.map +0 -1
  184. package/lib/commonjs/ui/components/SignInModal.js +0 -600
  185. package/lib/commonjs/ui/components/SignInModal.js.map +0 -1
  186. package/lib/commonjs/ui/hooks/useOxyAuthSession.js +0 -501
  187. package/lib/commonjs/ui/hooks/useOxyAuthSession.js.map +0 -1
  188. package/lib/commonjs/ui/hooks/usePasswordSignIn.js +0 -170
  189. package/lib/commonjs/ui/hooks/usePasswordSignIn.js.map +0 -1
  190. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +0 -51
  191. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +0 -1
  192. package/lib/commonjs/ui/screens/OxyAuthScreen.js +0 -312
  193. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +0 -1
  194. package/lib/commonjs/utils/deviceFlowSignIn.js +0 -109
  195. package/lib/commonjs/utils/deviceFlowSignIn.js.map +0 -1
  196. package/lib/module/ui/components/AccountMenu.js +0 -593
  197. package/lib/module/ui/components/AccountMenu.js.map +0 -1
  198. package/lib/module/ui/components/AccountMenuButton.js +0 -130
  199. package/lib/module/ui/components/AccountMenuButton.js.map +0 -1
  200. package/lib/module/ui/components/AccountSwitcher.js +0 -774
  201. package/lib/module/ui/components/AccountSwitcher.js.map +0 -1
  202. package/lib/module/ui/components/AnotherDeviceQR.js +0 -110
  203. package/lib/module/ui/components/AnotherDeviceQR.js.map +0 -1
  204. package/lib/module/ui/components/ProfileMenu.js +0 -514
  205. package/lib/module/ui/components/ProfileMenu.js.map +0 -1
  206. package/lib/module/ui/components/SignInAccountChooser.js +0 -183
  207. package/lib/module/ui/components/SignInAccountChooser.js.map +0 -1
  208. package/lib/module/ui/components/SignInModal.js +0 -591
  209. package/lib/module/ui/components/SignInModal.js.map +0 -1
  210. package/lib/module/ui/hooks/useOxyAuthSession.js +0 -495
  211. package/lib/module/ui/hooks/useOxyAuthSession.js.map +0 -1
  212. package/lib/module/ui/hooks/usePasswordSignIn.js +0 -165
  213. package/lib/module/ui/hooks/usePasswordSignIn.js.map +0 -1
  214. package/lib/module/ui/screens/AccountSwitcherScreen.js +0 -48
  215. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +0 -1
  216. package/lib/module/ui/screens/OxyAuthScreen.js +0 -306
  217. package/lib/module/ui/screens/OxyAuthScreen.js.map +0 -1
  218. package/lib/module/utils/deviceFlowSignIn.js +0 -106
  219. package/lib/module/utils/deviceFlowSignIn.js.map +0 -1
  220. package/lib/typescript/commonjs/ui/components/AccountMenu.d.ts +0 -47
  221. package/lib/typescript/commonjs/ui/components/AccountMenu.d.ts.map +0 -1
  222. package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts +0 -26
  223. package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts.map +0 -1
  224. package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts +0 -46
  225. package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts.map +0 -1
  226. package/lib/typescript/commonjs/ui/components/AnotherDeviceQR.d.ts +0 -34
  227. package/lib/typescript/commonjs/ui/components/AnotherDeviceQR.d.ts.map +0 -1
  228. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts +0 -49
  229. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts.map +0 -1
  230. package/lib/typescript/commonjs/ui/components/SignInAccountChooser.d.ts +0 -29
  231. package/lib/typescript/commonjs/ui/components/SignInAccountChooser.d.ts.map +0 -1
  232. package/lib/typescript/commonjs/ui/components/SignInModal.d.ts +0 -28
  233. package/lib/typescript/commonjs/ui/components/SignInModal.d.ts.map +0 -1
  234. package/lib/typescript/commonjs/ui/hooks/useOxyAuthSession.d.ts +0 -105
  235. package/lib/typescript/commonjs/ui/hooks/useOxyAuthSession.d.ts.map +0 -1
  236. package/lib/typescript/commonjs/ui/hooks/usePasswordSignIn.d.ts +0 -31
  237. package/lib/typescript/commonjs/ui/hooks/usePasswordSignIn.d.ts.map +0 -1
  238. package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts +0 -11
  239. package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts.map +0 -1
  240. package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts +0 -22
  241. package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts.map +0 -1
  242. package/lib/typescript/commonjs/utils/deviceFlowSignIn.d.ts +0 -97
  243. package/lib/typescript/commonjs/utils/deviceFlowSignIn.d.ts.map +0 -1
  244. package/lib/typescript/module/ui/components/AccountMenu.d.ts +0 -47
  245. package/lib/typescript/module/ui/components/AccountMenu.d.ts.map +0 -1
  246. package/lib/typescript/module/ui/components/AccountMenuButton.d.ts +0 -26
  247. package/lib/typescript/module/ui/components/AccountMenuButton.d.ts.map +0 -1
  248. package/lib/typescript/module/ui/components/AccountSwitcher.d.ts +0 -46
  249. package/lib/typescript/module/ui/components/AccountSwitcher.d.ts.map +0 -1
  250. package/lib/typescript/module/ui/components/AnotherDeviceQR.d.ts +0 -34
  251. package/lib/typescript/module/ui/components/AnotherDeviceQR.d.ts.map +0 -1
  252. package/lib/typescript/module/ui/components/ProfileMenu.d.ts +0 -49
  253. package/lib/typescript/module/ui/components/ProfileMenu.d.ts.map +0 -1
  254. package/lib/typescript/module/ui/components/SignInAccountChooser.d.ts +0 -29
  255. package/lib/typescript/module/ui/components/SignInAccountChooser.d.ts.map +0 -1
  256. package/lib/typescript/module/ui/components/SignInModal.d.ts +0 -28
  257. package/lib/typescript/module/ui/components/SignInModal.d.ts.map +0 -1
  258. package/lib/typescript/module/ui/hooks/useOxyAuthSession.d.ts +0 -105
  259. package/lib/typescript/module/ui/hooks/useOxyAuthSession.d.ts.map +0 -1
  260. package/lib/typescript/module/ui/hooks/usePasswordSignIn.d.ts +0 -31
  261. package/lib/typescript/module/ui/hooks/usePasswordSignIn.d.ts.map +0 -1
  262. package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts +0 -11
  263. package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts.map +0 -1
  264. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts +0 -22
  265. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +0 -1
  266. package/lib/typescript/module/utils/deviceFlowSignIn.d.ts +0 -97
  267. package/lib/typescript/module/utils/deviceFlowSignIn.d.ts.map +0 -1
  268. package/src/ui/components/AccountMenu.tsx +0 -645
  269. package/src/ui/components/AccountMenuButton.tsx +0 -126
  270. package/src/ui/components/AccountSwitcher.tsx +0 -751
  271. package/src/ui/components/AnotherDeviceQR.tsx +0 -119
  272. package/src/ui/components/ProfileMenu.tsx +0 -564
  273. package/src/ui/components/SignInAccountChooser.tsx +0 -162
  274. package/src/ui/components/SignInModal.tsx +0 -530
  275. package/src/ui/hooks/useOxyAuthSession.ts +0 -635
  276. package/src/ui/hooks/usePasswordSignIn.ts +0 -207
  277. package/src/ui/screens/AccountSwitcherScreen.tsx +0 -43
  278. package/src/ui/screens/OxyAuthScreen.tsx +0 -324
  279. package/src/utils/__tests__/deviceFlowSignIn.test.ts +0 -231
  280. package/src/utils/deviceFlowSignIn.ts +0 -152
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.RequireOxyAuth = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _theme = require("@oxyhq/bloom/theme");
10
+ var _typography = require("@oxyhq/bloom/typography");
11
+ var _OxyContext = require("../context/OxyContext.js");
12
+ var _OxySignInButton = require("./OxySignInButton.js");
13
+ var _OxyLogo = _interopRequireDefault(require("./OxyLogo.js"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ /**
17
+ * RequireOxyAuth — the optional signed-out gate primitive (React Native).
18
+ *
19
+ * ONE shared way for any Oxy app to opt into a signed-out gate. It is entirely
20
+ * OPTIONAL: a public app renders its children untouched (`prompt="off"`); an
21
+ * auth-required app blocks them behind a signed-out state (`prompt="hard"`); an
22
+ * app that mostly works signed-out but wants a nudge shows a dismissible banner
23
+ * (`prompt="soft"`). Every mode reuses the ONE account dialog the provider
24
+ * already mounts — opening the sign-in surface is always
25
+ * `useOxy().openAccountDialog('signin')`; there is NO second dialog.
26
+ *
27
+ * Readiness gating (CRITICAL): the gate keys on the SDK's own readiness state
28
+ * (`useOxy().canUsePrivateApi` / `isPrivateApiPending`), NEVER on app-local
29
+ * hooks. While auth is still resolving (`isPrivateApiPending`) it renders a
30
+ * neutral loading state so the signed-out wall never flashes before the
31
+ * device-first cold boot concludes (the documented cold-boot race).
32
+ *
33
+ * Styling follows the sibling `OxyAccountDialog`/`OxySignInButton` pattern —
34
+ * `useTheme()` + `StyleSheet` (NOT NativeWind), so the gate renders correctly in
35
+ * EVERY consumer, including apps that do not run NativeWind (e.g. the accounts
36
+ * app).
37
+ */
38
+
39
+ /**
40
+ * How `RequireOxyAuth` treats a signed-out (or still-resolving) session.
41
+ * - `off` — always render children (public app; a no-op provided for symmetry).
42
+ * - `soft` — render children, plus a dismissible sign-in banner when signed out.
43
+ * - `hard` — block children behind a centered signed-out state until signed in.
44
+ */
45
+
46
+ const DEFAULT_TITLE = 'Sign in to continue';
47
+ const DEFAULT_SUBTITLE = 'Sign in with your Oxy account to continue.';
48
+ const DEFAULT_BANNER_MESSAGE = "You're browsing signed out.";
49
+ const DEFAULT_BANNER_ACTION = 'Sign in';
50
+
51
+ /**
52
+ * Optional signed-out gate. Wrap any subtree (or the whole app via the
53
+ * provider's `requireAuth` prop) to opt into a shared, readiness-safe wall.
54
+ */
55
+ const RequireOxyAuth = ({
56
+ children,
57
+ prompt = 'hard',
58
+ loadingFallback,
59
+ signedOutFallback,
60
+ title,
61
+ subtitle,
62
+ bannerMessage,
63
+ bannerActionLabel
64
+ }) => {
65
+ const {
66
+ canUsePrivateApi,
67
+ isPrivateApiPending,
68
+ openAccountDialog
69
+ } = (0, _OxyContext.useOxy)();
70
+
71
+ // Public app: render straight through. Cheap enough to short-circuit before
72
+ // touching any gate UI.
73
+ if (prompt === 'off') {
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
75
+ children: children
76
+ });
77
+ }
78
+
79
+ // Signed in (and token ready): render the protected subtree in every mode.
80
+ if (canUsePrivateApi) {
81
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
82
+ children: children
83
+ });
84
+ }
85
+ if (prompt === 'soft') {
86
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(SoftGate, {
87
+ pending: isPrivateApiPending,
88
+ message: bannerMessage ?? DEFAULT_BANNER_MESSAGE,
89
+ actionLabel: bannerActionLabel ?? DEFAULT_BANNER_ACTION,
90
+ onSignIn: () => openAccountDialog('signin'),
91
+ children: children
92
+ });
93
+ }
94
+
95
+ // prompt === 'hard'
96
+ if (isPrivateApiPending) {
97
+ return loadingFallback ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
98
+ children: loadingFallback
99
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(NeutralLoading, {});
100
+ }
101
+ if (signedOutFallback) {
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
103
+ children: signedOutFallback
104
+ });
105
+ }
106
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(HardWall, {
107
+ title: title ?? DEFAULT_TITLE,
108
+ subtitle: subtitle ?? DEFAULT_SUBTITLE
109
+ });
110
+ };
111
+
112
+ // ---------------------------------------------------------------------------
113
+ // Soft gate — children + a dismissible sign-in banner while signed out.
114
+ // ---------------------------------------------------------------------------
115
+ exports.RequireOxyAuth = RequireOxyAuth;
116
+ const SoftGate = ({
117
+ children,
118
+ pending,
119
+ message,
120
+ actionLabel,
121
+ onSignIn
122
+ }) => {
123
+ const theme = (0, _theme.useTheme)();
124
+ const [dismissed, setDismissed] = (0, _react.useState)(false);
125
+
126
+ // Never surface the nudge while auth is still resolving — only once the boot
127
+ // has concluded signed out and the user has not dismissed it.
128
+ const showBanner = !pending && !dismissed;
129
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
130
+ style: styles.softRoot,
131
+ children: [showBanner ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
132
+ style: [styles.banner, {
133
+ backgroundColor: theme.colors.card,
134
+ borderColor: theme.colors.border
135
+ }],
136
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_OxyLogo.default, {
137
+ variant: "icon",
138
+ size: 20,
139
+ fillColor: theme.colors.primary
140
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
141
+ style: [styles.bannerText, {
142
+ color: theme.colors.text
143
+ }],
144
+ numberOfLines: 2,
145
+ children: message
146
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
147
+ onPress: onSignIn,
148
+ style: [styles.bannerCta, {
149
+ backgroundColor: theme.colors.primary
150
+ }],
151
+ accessibilityRole: "button",
152
+ accessibilityLabel: actionLabel,
153
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
154
+ style: styles.bannerCtaText,
155
+ children: actionLabel
156
+ })
157
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
158
+ onPress: () => setDismissed(true),
159
+ style: styles.bannerDismiss,
160
+ accessibilityRole: "button",
161
+ accessibilityLabel: "Dismiss",
162
+ hitSlop: 8,
163
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
164
+ style: [styles.bannerDismissText, {
165
+ color: theme.colors.textSecondary
166
+ }],
167
+ children: "\u2715"
168
+ })
169
+ })]
170
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
171
+ style: styles.softBody,
172
+ children: children
173
+ })]
174
+ });
175
+ };
176
+
177
+ // ---------------------------------------------------------------------------
178
+ // Hard wall — centered signed-out state with the "Sign in with Oxy" CTA.
179
+ // ---------------------------------------------------------------------------
180
+
181
+ const HardWall = ({
182
+ title,
183
+ subtitle
184
+ }) => {
185
+ const theme = (0, _theme.useTheme)();
186
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
187
+ style: [styles.wallRoot, {
188
+ backgroundColor: theme.colors.background
189
+ }],
190
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
191
+ style: [styles.logoBadge, {
192
+ backgroundColor: theme.colors.primarySubtle
193
+ }],
194
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_OxyLogo.default, {
195
+ variant: "icon",
196
+ size: 44,
197
+ fillColor: theme.colors.primary
198
+ })
199
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
200
+ style: [styles.wallTitle, {
201
+ color: theme.colors.text
202
+ }],
203
+ children: title
204
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
205
+ style: [styles.wallSubtitle, {
206
+ color: theme.colors.textSecondary
207
+ }],
208
+ children: subtitle
209
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_OxySignInButton.OxySignInButton, {
210
+ variant: "contained",
211
+ style: styles.wallCta
212
+ })]
213
+ });
214
+ };
215
+ const NeutralLoading = () => {
216
+ const theme = (0, _theme.useTheme)();
217
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
218
+ style: [styles.wallRoot, {
219
+ backgroundColor: theme.colors.background
220
+ }],
221
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
222
+ color: theme.colors.primary
223
+ })
224
+ });
225
+ };
226
+ const styles = _reactNative.StyleSheet.create({
227
+ softRoot: {
228
+ flex: 1
229
+ },
230
+ softBody: {
231
+ flex: 1
232
+ },
233
+ banner: {
234
+ flexDirection: 'row',
235
+ alignItems: 'center',
236
+ gap: 10,
237
+ paddingVertical: 8,
238
+ paddingHorizontal: 12,
239
+ borderBottomWidth: _reactNative.StyleSheet.hairlineWidth
240
+ },
241
+ bannerText: {
242
+ flex: 1,
243
+ fontSize: 13.5
244
+ },
245
+ bannerCta: {
246
+ paddingVertical: 6,
247
+ paddingHorizontal: 14,
248
+ borderRadius: 999
249
+ },
250
+ bannerCtaText: {
251
+ color: '#FFFFFF',
252
+ fontSize: 13,
253
+ fontWeight: '700'
254
+ },
255
+ bannerDismiss: {
256
+ width: 28,
257
+ height: 28,
258
+ alignItems: 'center',
259
+ justifyContent: 'center'
260
+ },
261
+ bannerDismissText: {
262
+ fontSize: 15,
263
+ fontWeight: '600'
264
+ },
265
+ wallRoot: {
266
+ flex: 1,
267
+ alignItems: 'center',
268
+ justifyContent: 'center',
269
+ padding: 24,
270
+ gap: 16
271
+ },
272
+ logoBadge: {
273
+ width: 88,
274
+ height: 88,
275
+ borderRadius: 44,
276
+ alignItems: 'center',
277
+ justifyContent: 'center',
278
+ marginBottom: 4
279
+ },
280
+ wallTitle: {
281
+ fontSize: 24,
282
+ fontWeight: '800',
283
+ letterSpacing: -0.4,
284
+ textAlign: 'center'
285
+ },
286
+ wallSubtitle: {
287
+ fontSize: 15,
288
+ lineHeight: 21,
289
+ textAlign: 'center',
290
+ maxWidth: 340
291
+ },
292
+ wallCta: {
293
+ marginTop: 8,
294
+ width: '100%',
295
+ maxWidth: 320
296
+ }
297
+ });
298
+ var _default = exports.default = RequireOxyAuth;
299
+ //# sourceMappingURL=RequireOxyAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_theme","_typography","_OxyContext","_OxySignInButton","_OxyLogo","_interopRequireDefault","_jsxRuntime","e","__esModule","default","DEFAULT_TITLE","DEFAULT_SUBTITLE","DEFAULT_BANNER_MESSAGE","DEFAULT_BANNER_ACTION","RequireOxyAuth","children","prompt","loadingFallback","signedOutFallback","title","subtitle","bannerMessage","bannerActionLabel","canUsePrivateApi","isPrivateApiPending","openAccountDialog","useOxy","jsx","Fragment","SoftGate","pending","message","actionLabel","onSignIn","NeutralLoading","HardWall","exports","theme","useTheme","dismissed","setDismissed","useState","showBanner","jsxs","View","style","styles","softRoot","banner","backgroundColor","colors","card","borderColor","border","variant","size","fillColor","primary","Text","bannerText","color","text","numberOfLines","Pressable","onPress","bannerCta","accessibilityRole","accessibilityLabel","bannerCtaText","bannerDismiss","hitSlop","bannerDismissText","textSecondary","softBody","wallRoot","background","logoBadge","primarySubtle","wallTitle","wallSubtitle","OxySignInButton","wallCta","ActivityIndicator","StyleSheet","create","flex","flexDirection","alignItems","gap","paddingVertical","paddingHorizontal","borderBottomWidth","hairlineWidth","fontSize","borderRadius","fontWeight","width","height","justifyContent","padding","marginBottom","letterSpacing","textAlign","lineHeight","maxWidth","marginTop","_default"],"sourceRoot":"../../../../src","sources":["ui/components/RequireOxyAuth.tsx"],"mappings":";;;;;;AAwBA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAgC,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAO,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA9BhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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esModule", {
5
5
  });
6
6
  exports.useOxy = exports.OxyProvider = exports.OxyContextProvider = void 0;
7
7
  var _react = require("react");
8
+ var _reactNative = require("react-native");
8
9
  var _core = require("@oxyhq/core");
10
+ var _accountDialogManager = require("../navigation/accountDialogManager.js");
9
11
  var _authStore = require("../stores/authStore.js");
10
12
  var _shallow = require("zustand/react/shallow");
11
13
  var _useLanguageManagement = require("../hooks/useLanguageManagement.js");
@@ -171,6 +173,7 @@ const OxyProvider = ({
171
173
  userRef.current = user;
172
174
  isAuthenticatedRef.current = isAuthenticated;
173
175
  const [initialized, setInitialized] = (0, _react.useState)(false);
176
+ const [accountDialogOpen, setAccountDialogOpen] = (0, _react.useState)(false);
174
177
  const setAuthState = _authStore.useAuthStore.setState;
175
178
 
176
179
  // Keep the shared `oxyClient` singleton's token store in lockstep with the
@@ -311,10 +314,19 @@ const OxyProvider = ({
311
314
  const markAuthResolvedRef = (0, _react.useRef)(markAuthResolved);
312
315
  markAuthResolvedRef.current = markAuthResolved;
313
316
 
317
+ // Re-boot indirection: the SessionClient is built in the ref initializer below
318
+ // (before `runColdBoot` is defined), but its `onSessionAppeared` must re-run the
319
+ // cold boot to self-acquire when a sibling signs in on this device. A ref bridges
320
+ // the ordering; it is assigned right after `runColdBoot` is declared.
321
+ const runColdBootRef = (0, _react.useRef)(null);
322
+
314
323
  // Server-authoritative device session client. Built ONCE per `oxyServices`
315
324
  // instance. `onUnauthenticated` (a device signout-all pushed over the socket,
316
325
  // or bootstrapped as zero-account) clears the persisted store + local state so
317
326
  // a reload does not try to restore a session the device no longer has.
327
+ // `signedOutSocketAuth` + `onSessionAppeared` power the signed-out sync channel:
328
+ // an idle tab joins its `device:<id>` room (web via the `oxy_device` cookie,
329
+ // native via the shared device token) and self-acquires on a sibling sign-in.
318
330
  const sessionClientPairRef = (0, _react.useRef)(null);
319
331
  if (!sessionClientPairRef.current) {
320
332
  sessionClientPairRef.current = (0, _index.createSessionClient)(oxyServices, authStore, () => {
@@ -322,6 +334,21 @@ const OxyProvider = ({
322
334
  void clearSessionStateRef.current().catch(clearError => {
323
335
  logger('Failed to clear local state on remote sign-out', clearError);
324
336
  });
337
+ }, {
338
+ signedOutSocketAuth: async () => {
339
+ // Web (`*.oxy.so`): the first-party `oxy_device` cookie rides the
340
+ // same-site handshake automatically — just connect.
341
+ if ((0, _isWebBrowser.isWebBrowser)()) return true;
342
+ // Native (no cookie jar): present the shared device token if we have one.
343
+ try {
344
+ return (await authStore.loadDeviceToken()) ?? false;
345
+ } catch {
346
+ return false;
347
+ }
348
+ },
349
+ onSessionAppeared: () => {
350
+ void runColdBootRef.current?.();
351
+ }
325
352
  });
326
353
  }
327
354
  const {
@@ -601,6 +628,58 @@ const OxyProvider = ({
601
628
  });
602
629
  }, [commitSession]);
603
630
 
631
+ // ── Unified account dialog ─────────────────────────────────────────────────
632
+ // The single account-chooser + sign-in surface. Built ONCE per provider mount
633
+ // and bound to the live `oxyServices` + `sessionClient` + this provider's
634
+ // `handleWebSession` commit funnel. `handleWebSession` is threaded through a ref
635
+ // so the controller keeps a STABLE `commitSession` (rebuilding the controller
636
+ // on every commit-identity change would drop its subscription + state).
637
+ const handleWebSessionRef = (0, _react.useRef)(handleWebSession);
638
+ handleWebSessionRef.current = handleWebSession;
639
+ const accountDialogControllerRef = (0, _react.useRef)(null);
640
+ if (!accountDialogControllerRef.current) {
641
+ accountDialogControllerRef.current = (0, _core.createAccountDialogController)({
642
+ oxyServices,
643
+ sessionClient,
644
+ clientId,
645
+ locale: currentLanguage,
646
+ commitSession: session => handleWebSessionRef.current(session),
647
+ onSignedIn: () => setAccountDialogOpen(false),
648
+ openUrl: url => {
649
+ void _reactNative.Linking.openURL(url);
650
+ }
651
+ });
652
+ }
653
+ const accountDialogController = accountDialogControllerRef.current;
654
+ const openAccountDialog = (0, _react.useCallback)(view => {
655
+ accountDialogControllerRef.current?.setView(view ?? 'accounts');
656
+ setAccountDialogOpen(true);
657
+ }, []);
658
+ const closeAccountDialog = (0, _react.useCallback)(() => {
659
+ accountDialogControllerRef.current?.cancelSignIn();
660
+ setAccountDialogOpen(false);
661
+ }, []);
662
+
663
+ // Start driving the dialog on mount; tear it down on unmount.
664
+ (0, _react.useEffect)(() => {
665
+ const controller = accountDialogControllerRef.current;
666
+ controller?.start();
667
+ return () => controller?.destroy();
668
+ }, []);
669
+
670
+ // Expose the live open/close controls to the imperative manager so
671
+ // `showSignInModal()` (and any app-level imperative "sign in" handler) works.
672
+ (0, _react.useEffect)(() => (0, _accountDialogManager.registerAccountDialogControls)({
673
+ open: openAccountDialog,
674
+ close: closeAccountDialog
675
+ }), [openAccountDialog, closeAccountDialog]);
676
+
677
+ // Broadcast visibility so `OxySignInButton`'s "Signing in…" affordance stays
678
+ // accurate regardless of what opened or dismissed the dialog.
679
+ (0, _react.useEffect)(() => {
680
+ (0, _accountDialogManager.notifyAccountDialogVisibility)(accountDialogOpen);
681
+ }, [accountDialogOpen]);
682
+
604
683
  // Keyless password sign-in: username/email + password.
605
684
  const signInWithPassword = (0, _react.useCallback)(async (identifier, password, opts) => {
606
685
  const deviceToken = (await authStore.loadDeviceToken()) ?? undefined;
@@ -695,6 +774,17 @@ const OxyProvider = ({
695
774
  },
696
775
  onSignedOut: () => {
697
776
  markAuthResolvedRef.current();
777
+ // Open the signed-out realtime channel so this idle tab joins its
778
+ // `device:<id>` room (web `oxy_device` cookie / native device token)
779
+ // and self-acquires when a sibling signs in. Idempotent, best-effort.
780
+ void sessionClient.start().catch(startError => {
781
+ if (__DEV__) {
782
+ _core.logger.debug('signed-out socket start failed (non-fatal)', {
783
+ component: 'OxyContext',
784
+ method: 'runColdBoot'
785
+ }, startError);
786
+ }
787
+ });
698
788
  },
699
789
  onStepError: (id, error) => {
700
790
  if (__DEV__) {
@@ -716,7 +806,10 @@ const OxyProvider = ({
716
806
  // Backstop: resolve on every exit path so the gate can never hang.
717
807
  markAuthResolvedRef.current();
718
808
  }
719
- }, [oxyServices, authStore]);
809
+ }, [oxyServices, authStore, sessionClient]);
810
+ // Bridge for `onSessionAppeared` (SessionClient) → re-run the cold boot to
811
+ // self-acquire when a sibling signs in on this device while this tab is idle.
812
+ runColdBootRef.current = runColdBoot;
720
813
  (0, _react.useEffect)(() => {
721
814
  if (!storage || initialized) {
722
815
  return;
@@ -793,6 +886,9 @@ const OxyProvider = ({
793
886
  (0, _react.useEffect)(() => {
794
887
  if (isAuthenticated && initialized && tokenReady) {
795
888
  refreshAccounts();
889
+ // Reload the dialog's own account graph too, so a session restored OUTSIDE
890
+ // the dialog (cold boot / password sign-in) surfaces its graph accounts.
891
+ void accountDialogControllerRef.current?.refresh();
796
892
  }
797
893
  }, [isAuthenticated, initialized, tokenReady, refreshAccounts]);
798
894
  const runPostAccountSwitchSideEffects = (0, _react.useCallback)(async () => {
@@ -877,11 +973,15 @@ const OxyProvider = ({
877
973
  useFollow: useFollowHook,
878
974
  showBottomSheet: showBottomSheetForContext,
879
975
  openAvatarPicker,
976
+ accountDialogController,
977
+ isAccountDialogOpen: accountDialogOpen,
978
+ openAccountDialog,
979
+ closeAccountDialog,
880
980
  accounts,
881
981
  switchToAccount,
882
982
  refreshAccounts,
883
983
  createAccount: createAccountFn
884
- }), [user, sessions, activeSessionId, isAuthenticated, isLoading, tokenReady, hasAccessToken, canUsePrivateApi, isPrivateApiPending, authResolved, storage, error, currentLanguage, currentLanguageMetadata, currentLanguageName, currentNativeLanguageName, hasIdentity, getPublicKey, signIn, signInWithPassword, completeTwoFactorSignIn, handleWebSession, logout, logoutAll, switchSessionForContext, refreshSessionsForContext, setLanguage, getDeviceSessions, logoutAllDeviceSessions, updateDeviceName, clearSessionState, clearAllAccountData, storageKeyPrefix, clientId, oxyServices, useFollowHook, showBottomSheetForContext, openAvatarPicker, accounts, switchToAccount, refreshAccounts, createAccountFn]);
984
+ }), [user, sessions, activeSessionId, isAuthenticated, isLoading, tokenReady, hasAccessToken, canUsePrivateApi, isPrivateApiPending, authResolved, storage, error, currentLanguage, currentLanguageMetadata, currentLanguageName, currentNativeLanguageName, hasIdentity, getPublicKey, signIn, signInWithPassword, completeTwoFactorSignIn, handleWebSession, logout, logoutAll, switchSessionForContext, refreshSessionsForContext, setLanguage, getDeviceSessions, logoutAllDeviceSessions, updateDeviceName, clearSessionState, clearAllAccountData, storageKeyPrefix, clientId, oxyServices, useFollowHook, showBottomSheetForContext, openAvatarPicker, accountDialogController, accountDialogOpen, openAccountDialog, closeAccountDialog, accounts, switchToAccount, refreshAccounts, createAccountFn]);
885
985
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(OxyContext.Provider, {
886
986
  value: contextValue,
887
987
  children: children
@@ -937,6 +1037,10 @@ const LOADING_STATE = {
937
1037
  clientId: null,
938
1038
  oxyServices: LOADING_STATE_OXY_SERVICES,
939
1039
  openAvatarPicker: () => {},
1040
+ accountDialogController: null,
1041
+ isAccountDialogOpen: false,
1042
+ openAccountDialog: () => {},
1043
+ closeAccountDialog: () => {},
940
1044
  accounts: [],
941
1045
  switchToAccount: () => rejectMissingProvider(),
942
1046
  refreshAccounts: () => rejectMissingProvider(),