@oxyhq/services 13.0.2 → 13.1.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 (403) hide show
  1. package/lib/commonjs/index.js +18 -11
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/components/AccountMenuButton.js +8 -10
  4. package/lib/commonjs/ui/components/AccountMenuButton.js.map +1 -1
  5. package/lib/commonjs/ui/components/AccountSwitcher.js +65 -35
  6. package/lib/commonjs/ui/components/AccountSwitcher.js.map +1 -1
  7. package/lib/commonjs/ui/components/ProfileButton.js +233 -0
  8. package/lib/commonjs/ui/components/ProfileButton.js.map +1 -0
  9. package/lib/commonjs/ui/components/ProfileMenu.js +374 -0
  10. package/lib/commonjs/ui/components/ProfileMenu.js.map +1 -0
  11. package/lib/commonjs/ui/context/OxyContext.js +213 -101
  12. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  13. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +28 -1
  14. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  15. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -2
  16. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  17. package/lib/commonjs/ui/hooks/queries/usePaymentQueries.js +12 -12
  18. package/lib/commonjs/ui/hooks/queries/usePaymentQueries.js.map +1 -1
  19. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +8 -7
  20. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  21. package/lib/commonjs/ui/index.js +14 -0
  22. package/lib/commonjs/ui/index.js.map +1 -1
  23. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +11 -6
  24. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  25. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +3 -3
  26. package/lib/commonjs/ui/screens/CreateAccountScreen.js +6 -4
  27. package/lib/commonjs/ui/screens/CreateAccountScreen.js.map +1 -1
  28. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +8 -7
  29. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js.map +1 -1
  30. package/lib/commonjs/ui/screens/FileManagementScreen.js +13 -13
  31. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  32. package/lib/commonjs/ui/screens/HistoryViewScreen.js +7 -7
  33. package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -1
  34. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +5 -5
  35. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js.map +1 -1
  36. package/lib/commonjs/ui/screens/ManageAccountScreen.js +17 -18
  37. package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
  38. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +3 -3
  39. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  40. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +9 -9
  41. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  42. package/lib/commonjs/ui/screens/ProfileScreen.js +1 -1
  43. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  44. package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +4 -4
  45. package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -1
  46. package/lib/commonjs/ui/screens/SearchSettingsScreen.js +6 -6
  47. package/lib/commonjs/ui/screens/SearchSettingsScreen.js.map +1 -1
  48. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +6 -6
  49. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  50. package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js +4 -4
  51. package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js.map +1 -1
  52. package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js +4 -4
  53. package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js.map +1 -1
  54. package/lib/commonjs/ui/utils/activeAuthuser.js +76 -8
  55. package/lib/commonjs/ui/utils/activeAuthuser.js.map +1 -1
  56. package/lib/module/index.js +5 -5
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/module/ui/components/AccountMenuButton.js +8 -10
  59. package/lib/module/ui/components/AccountMenuButton.js.map +1 -1
  60. package/lib/module/ui/components/AccountSwitcher.js +65 -35
  61. package/lib/module/ui/components/AccountSwitcher.js.map +1 -1
  62. package/lib/module/ui/components/ProfileButton.js +228 -0
  63. package/lib/module/ui/components/ProfileButton.js.map +1 -0
  64. package/lib/module/ui/components/ProfileMenu.js +370 -0
  65. package/lib/module/ui/components/ProfileMenu.js.map +1 -0
  66. package/lib/module/ui/context/OxyContext.js +214 -102
  67. package/lib/module/ui/context/OxyContext.js.map +1 -1
  68. package/lib/module/ui/context/hooks/useAuthOperations.js +29 -2
  69. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  70. package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -2
  71. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  72. package/lib/module/ui/hooks/queries/usePaymentQueries.js +12 -12
  73. package/lib/module/ui/hooks/queries/usePaymentQueries.js.map +1 -1
  74. package/lib/module/ui/hooks/queries/useServicesQueries.js +9 -7
  75. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  76. package/lib/module/ui/index.js +2 -0
  77. package/lib/module/ui/index.js.map +1 -1
  78. package/lib/module/ui/screens/AccountSettingsScreen.js +11 -6
  79. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  80. package/lib/module/ui/screens/AccountSwitcherScreen.js +3 -3
  81. package/lib/module/ui/screens/CreateAccountScreen.js +6 -4
  82. package/lib/module/ui/screens/CreateAccountScreen.js.map +1 -1
  83. package/lib/module/ui/screens/EditProfileFieldScreen.js +8 -7
  84. package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
  85. package/lib/module/ui/screens/FileManagementScreen.js +13 -13
  86. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  87. package/lib/module/ui/screens/HistoryViewScreen.js +7 -7
  88. package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
  89. package/lib/module/ui/screens/LanguageSelectorScreen.js +5 -5
  90. package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
  91. package/lib/module/ui/screens/ManageAccountScreen.js +17 -18
  92. package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
  93. package/lib/module/ui/screens/PremiumSubscriptionScreen.js +3 -3
  94. package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  95. package/lib/module/ui/screens/PrivacySettingsScreen.js +9 -9
  96. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  97. package/lib/module/ui/screens/ProfileScreen.js +1 -1
  98. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  99. package/lib/module/ui/screens/SavesCollectionsScreen.js +4 -4
  100. package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
  101. package/lib/module/ui/screens/SearchSettingsScreen.js +6 -6
  102. package/lib/module/ui/screens/SearchSettingsScreen.js.map +1 -1
  103. package/lib/module/ui/screens/WelcomeNewUserScreen.js +6 -6
  104. package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  105. package/lib/module/ui/screens/trust/TrustCenterScreen.js +4 -4
  106. package/lib/module/ui/screens/trust/TrustCenterScreen.js.map +1 -1
  107. package/lib/module/ui/screens/trust/TrustRewardsScreen.js +4 -4
  108. package/lib/module/ui/screens/trust/TrustRewardsScreen.js.map +1 -1
  109. package/lib/module/ui/utils/activeAuthuser.js +74 -9
  110. package/lib/module/ui/utils/activeAuthuser.js.map +1 -1
  111. package/lib/typescript/commonjs/index.d.ts +4 -1
  112. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts +5 -7
  114. package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/ui/components/ActivityIndicator.d.ts +1 -1
  117. package/lib/typescript/commonjs/ui/components/ActivityIndicator.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/ui/components/CrossFadeIcon.d.ts +2 -1
  119. package/lib/typescript/commonjs/ui/components/CrossFadeIcon.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/ui/components/FontLoader.d.ts +1 -1
  121. package/lib/typescript/commonjs/ui/components/FontLoader.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/ui/components/HelperText.d.ts +1 -1
  123. package/lib/typescript/commonjs/ui/components/HelperText.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts +46 -0
  125. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts +39 -0
  127. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/ui/components/TextField/Addons/Outline.d.ts +2 -1
  129. package/lib/typescript/commonjs/ui/components/TextField/Addons/Outline.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/ui/components/TextField/Addons/Underline.d.ts +2 -1
  131. package/lib/typescript/commonjs/ui/components/TextField/Addons/Underline.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/ui/components/TextField/Adornment/TextFieldAffix.d.ts +1 -1
  133. package/lib/typescript/commonjs/ui/components/TextField/Adornment/TextFieldIcon.d.ts +1 -1
  134. package/lib/typescript/commonjs/ui/components/TextField/Label/InputLabel.d.ts +1 -1
  135. package/lib/typescript/commonjs/ui/components/TextField/Label/LabelBackground.d.ts +2 -1
  136. package/lib/typescript/commonjs/ui/components/TextField/Label/LabelBackground.d.ts.map +1 -1
  137. package/lib/typescript/commonjs/ui/components/TextField/TextFieldFlat.d.ts +2 -1
  138. package/lib/typescript/commonjs/ui/components/TextField/TextFieldFlat.d.ts.map +1 -1
  139. package/lib/typescript/commonjs/ui/components/TextField/TextFieldOutlined.d.ts +2 -1
  140. package/lib/typescript/commonjs/ui/components/TextField/TextFieldOutlined.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +11 -26
  142. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/ui/context/ThemeContext.d.ts +1 -1
  144. package/lib/typescript/commonjs/ui/context/ThemeContext.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/ui/index.d.ts +2 -0
  148. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts +3 -3
  151. package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/ui/utils/activeAuthuser.d.ts +24 -0
  155. package/lib/typescript/commonjs/ui/utils/activeAuthuser.d.ts.map +1 -1
  156. package/lib/typescript/module/index.d.ts +64 -61
  157. package/lib/typescript/module/index.d.ts.map +1 -1
  158. package/lib/typescript/module/ui/client.d.ts +26 -26
  159. package/lib/typescript/module/ui/client.d.ts.map +1 -1
  160. package/lib/typescript/module/ui/components/AccountMenuButton.d.ts +5 -7
  161. package/lib/typescript/module/ui/components/AccountMenuButton.d.ts.map +1 -1
  162. package/lib/typescript/module/ui/components/AccountSwitcher.d.ts +1 -1
  163. package/lib/typescript/module/ui/components/AccountSwitcher.d.ts.map +1 -1
  164. package/lib/typescript/module/ui/components/ActivityIndicator.d.ts +2 -2
  165. package/lib/typescript/module/ui/components/ActivityIndicator.d.ts.map +1 -1
  166. package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts +1 -1
  167. package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts.map +1 -1
  168. package/lib/typescript/module/ui/components/CrossFadeIcon.d.ts +4 -3
  169. package/lib/typescript/module/ui/components/CrossFadeIcon.d.ts.map +1 -1
  170. package/lib/typescript/module/ui/components/FontLoader.d.ts +1 -1
  171. package/lib/typescript/module/ui/components/FontLoader.d.ts.map +1 -1
  172. package/lib/typescript/module/ui/components/HelperText.d.ts +1 -1
  173. package/lib/typescript/module/ui/components/HelperText.d.ts.map +1 -1
  174. package/lib/typescript/module/ui/components/Icon.d.ts +1 -1
  175. package/lib/typescript/module/ui/components/Icon.d.ts.map +1 -1
  176. package/lib/typescript/module/ui/components/IconButton/IconButton.d.ts +3 -3
  177. package/lib/typescript/module/ui/components/IconButton/IconButton.d.ts.map +1 -1
  178. package/lib/typescript/module/ui/components/IconButton/utils.d.ts +1 -1
  179. package/lib/typescript/module/ui/components/IconButton/utils.d.ts.map +1 -1
  180. package/lib/typescript/module/ui/components/OxyPayButton.d.ts +1 -1
  181. package/lib/typescript/module/ui/components/OxyPayButton.d.ts.map +1 -1
  182. package/lib/typescript/module/ui/components/OxyProvider.d.ts +1 -1
  183. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  184. package/lib/typescript/module/ui/components/ProfileButton.d.ts +46 -0
  185. package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -0
  186. package/lib/typescript/module/ui/components/ProfileMenu.d.ts +39 -0
  187. package/lib/typescript/module/ui/components/ProfileMenu.d.ts.map +1 -0
  188. package/lib/typescript/module/ui/components/StepBasedScreen.d.ts +2 -2
  189. package/lib/typescript/module/ui/components/StepBasedScreen.d.ts.map +1 -1
  190. package/lib/typescript/module/ui/components/Surface.d.ts +2 -2
  191. package/lib/typescript/module/ui/components/Surface.d.ts.map +1 -1
  192. package/lib/typescript/module/ui/components/TextField/Addons/Outline.d.ts +3 -2
  193. package/lib/typescript/module/ui/components/TextField/Addons/Outline.d.ts.map +1 -1
  194. package/lib/typescript/module/ui/components/TextField/Addons/Underline.d.ts +3 -2
  195. package/lib/typescript/module/ui/components/TextField/Addons/Underline.d.ts.map +1 -1
  196. package/lib/typescript/module/ui/components/TextField/Adornment/TextFieldAdornment.d.ts +3 -3
  197. package/lib/typescript/module/ui/components/TextField/Adornment/TextFieldAdornment.d.ts.map +1 -1
  198. package/lib/typescript/module/ui/components/TextField/Adornment/TextFieldAffix.d.ts +3 -3
  199. package/lib/typescript/module/ui/components/TextField/Adornment/TextFieldAffix.d.ts.map +1 -1
  200. package/lib/typescript/module/ui/components/TextField/Adornment/TextFieldIcon.d.ts +4 -4
  201. package/lib/typescript/module/ui/components/TextField/Adornment/TextFieldIcon.d.ts.map +1 -1
  202. package/lib/typescript/module/ui/components/TextField/Adornment/types.d.ts +1 -1
  203. package/lib/typescript/module/ui/components/TextField/Adornment/types.d.ts.map +1 -1
  204. package/lib/typescript/module/ui/components/TextField/Adornment/utils.d.ts +1 -1
  205. package/lib/typescript/module/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
  206. package/lib/typescript/module/ui/components/TextField/Label/InputLabel.d.ts +2 -2
  207. package/lib/typescript/module/ui/components/TextField/Label/InputLabel.d.ts.map +1 -1
  208. package/lib/typescript/module/ui/components/TextField/Label/LabelBackground.d.ts +3 -2
  209. package/lib/typescript/module/ui/components/TextField/Label/LabelBackground.d.ts.map +1 -1
  210. package/lib/typescript/module/ui/components/TextField/TextFieldFlat.d.ts +3 -2
  211. package/lib/typescript/module/ui/components/TextField/TextFieldFlat.d.ts.map +1 -1
  212. package/lib/typescript/module/ui/components/TextField/TextFieldOutlined.d.ts +3 -2
  213. package/lib/typescript/module/ui/components/TextField/TextFieldOutlined.d.ts.map +1 -1
  214. package/lib/typescript/module/ui/components/TextField/helpers.d.ts +3 -3
  215. package/lib/typescript/module/ui/components/TextField/helpers.d.ts.map +1 -1
  216. package/lib/typescript/module/ui/components/TextField/types.d.ts +1 -1
  217. package/lib/typescript/module/ui/components/TextField/types.d.ts.map +1 -1
  218. package/lib/typescript/module/ui/components/TextField.d.ts +4 -4
  219. package/lib/typescript/module/ui/components/TextField.d.ts.map +1 -1
  220. package/lib/typescript/module/ui/components/TouchableRipple/TouchableRipple.d.ts +3 -3
  221. package/lib/typescript/module/ui/components/TouchableRipple/TouchableRipple.d.ts.map +1 -1
  222. package/lib/typescript/module/ui/components/TouchableRipple/TouchableRipple.native.d.ts +3 -3
  223. package/lib/typescript/module/ui/components/TouchableRipple/TouchableRipple.native.d.ts.map +1 -1
  224. package/lib/typescript/module/ui/components/TouchableRipple/utils.d.ts +1 -1
  225. package/lib/typescript/module/ui/components/TouchableRipple/utils.d.ts.map +1 -1
  226. package/lib/typescript/module/ui/components/Typography/AnimatedText.d.ts +3 -3
  227. package/lib/typescript/module/ui/components/Typography/AnimatedText.d.ts.map +1 -1
  228. package/lib/typescript/module/ui/components/accountMenuRows.d.ts +1 -1
  229. package/lib/typescript/module/ui/components/accountMenuRows.d.ts.map +1 -1
  230. package/lib/typescript/module/ui/components/feedback/ProgressIndicator.d.ts +1 -1
  231. package/lib/typescript/module/ui/components/feedback/ProgressIndicator.d.ts.map +1 -1
  232. package/lib/typescript/module/ui/components/feedback/constants.d.ts +1 -1
  233. package/lib/typescript/module/ui/components/feedback/constants.d.ts.map +1 -1
  234. package/lib/typescript/module/ui/components/feedback/useFeedbackForm.d.ts +1 -1
  235. package/lib/typescript/module/ui/components/feedback/useFeedbackForm.d.ts.map +1 -1
  236. package/lib/typescript/module/ui/components/payment/PaymentDetailsStep.d.ts +1 -1
  237. package/lib/typescript/module/ui/components/payment/PaymentDetailsStep.d.ts.map +1 -1
  238. package/lib/typescript/module/ui/components/payment/PaymentMethodStep.d.ts +1 -1
  239. package/lib/typescript/module/ui/components/payment/PaymentMethodStep.d.ts.map +1 -1
  240. package/lib/typescript/module/ui/components/payment/PaymentReviewStep.d.ts +1 -1
  241. package/lib/typescript/module/ui/components/payment/PaymentReviewStep.d.ts.map +1 -1
  242. package/lib/typescript/module/ui/components/payment/PaymentSuccessStep.d.ts +1 -1
  243. package/lib/typescript/module/ui/components/payment/PaymentSuccessStep.d.ts.map +1 -1
  244. package/lib/typescript/module/ui/components/payment/PaymentSummaryStep.d.ts +1 -1
  245. package/lib/typescript/module/ui/components/payment/PaymentSummaryStep.d.ts.map +1 -1
  246. package/lib/typescript/module/ui/components/payment/constants.d.ts +1 -1
  247. package/lib/typescript/module/ui/components/payment/constants.d.ts.map +1 -1
  248. package/lib/typescript/module/ui/components/payment/paymentStyles.d.ts +1 -1
  249. package/lib/typescript/module/ui/components/payment/paymentStyles.d.ts.map +1 -1
  250. package/lib/typescript/module/ui/components/theming.d.ts +1 -1
  251. package/lib/typescript/module/ui/components/theming.d.ts.map +1 -1
  252. package/lib/typescript/module/ui/context/OxyContext.d.ts +14 -29
  253. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  254. package/lib/typescript/module/ui/context/ThemeContext.d.ts +1 -1
  255. package/lib/typescript/module/ui/context/ThemeContext.d.ts.map +1 -1
  256. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +2 -2
  257. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  258. package/lib/typescript/module/ui/hooks/queries/usePaymentQueries.d.ts +1 -1
  259. package/lib/typescript/module/ui/hooks/queries/usePaymentQueries.d.ts.map +1 -1
  260. package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  261. package/lib/typescript/module/ui/hooks/queryClient.d.ts +1 -1
  262. package/lib/typescript/module/ui/hooks/queryClient.d.ts.map +1 -1
  263. package/lib/typescript/module/ui/hooks/useAuth.d.ts +1 -1
  264. package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
  265. package/lib/typescript/module/ui/hooks/useAvatarPicker.d.ts +1 -1
  266. package/lib/typescript/module/ui/hooks/useAvatarPicker.d.ts.map +1 -1
  267. package/lib/typescript/module/ui/hooks/useLanguageManagement.d.ts +1 -1
  268. package/lib/typescript/module/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  269. package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts +1 -1
  270. package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts.map +1 -1
  271. package/lib/typescript/module/ui/hooks/useStorage.d.ts +1 -1
  272. package/lib/typescript/module/ui/hooks/useStorage.d.ts.map +1 -1
  273. package/lib/typescript/module/ui/index.d.ts +30 -28
  274. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  275. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +1 -1
  276. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  277. package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
  278. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  279. package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts +1 -1
  280. package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts.map +1 -1
  281. package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts +1 -1
  282. package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  283. package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts +4 -4
  284. package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
  285. package/lib/typescript/module/ui/screens/AccountVerificationScreen.d.ts +1 -1
  286. package/lib/typescript/module/ui/screens/AccountVerificationScreen.d.ts.map +1 -1
  287. package/lib/typescript/module/ui/screens/AppInfoScreen.d.ts +1 -1
  288. package/lib/typescript/module/ui/screens/AppInfoScreen.d.ts.map +1 -1
  289. package/lib/typescript/module/ui/screens/AvatarCropScreen.d.ts +1 -1
  290. package/lib/typescript/module/ui/screens/AvatarCropScreen.d.ts.map +1 -1
  291. package/lib/typescript/module/ui/screens/ConnectedAppsScreen.d.ts +1 -1
  292. package/lib/typescript/module/ui/screens/ConnectedAppsScreen.d.ts.map +1 -1
  293. package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts +1 -1
  294. package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts.map +1 -1
  295. package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts +1 -1
  296. package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  297. package/lib/typescript/module/ui/screens/FAQScreen.d.ts +1 -1
  298. package/lib/typescript/module/ui/screens/FAQScreen.d.ts.map +1 -1
  299. package/lib/typescript/module/ui/screens/FeedbackScreen.d.ts +1 -1
  300. package/lib/typescript/module/ui/screens/FeedbackScreen.d.ts.map +1 -1
  301. package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts +1 -1
  302. package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts.map +1 -1
  303. package/lib/typescript/module/ui/screens/FollowersListScreen.d.ts +1 -1
  304. package/lib/typescript/module/ui/screens/FollowersListScreen.d.ts.map +1 -1
  305. package/lib/typescript/module/ui/screens/FollowingListScreen.d.ts +1 -1
  306. package/lib/typescript/module/ui/screens/FollowingListScreen.d.ts.map +1 -1
  307. package/lib/typescript/module/ui/screens/HelpSupportScreen.d.ts +1 -1
  308. package/lib/typescript/module/ui/screens/HelpSupportScreen.d.ts.map +1 -1
  309. package/lib/typescript/module/ui/screens/HistoryViewScreen.d.ts +1 -1
  310. package/lib/typescript/module/ui/screens/HistoryViewScreen.d.ts.map +1 -1
  311. package/lib/typescript/module/ui/screens/LanguageSelectorScreen.d.ts +1 -1
  312. package/lib/typescript/module/ui/screens/LanguageSelectorScreen.d.ts.map +1 -1
  313. package/lib/typescript/module/ui/screens/LearnMoreUsernamesScreen.d.ts +1 -1
  314. package/lib/typescript/module/ui/screens/LearnMoreUsernamesScreen.d.ts.map +1 -1
  315. package/lib/typescript/module/ui/screens/LegalDocumentsScreen.d.ts +1 -1
  316. package/lib/typescript/module/ui/screens/LegalDocumentsScreen.d.ts.map +1 -1
  317. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts +1 -1
  318. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  319. package/lib/typescript/module/ui/screens/NotificationsScreen.d.ts +1 -1
  320. package/lib/typescript/module/ui/screens/NotificationsScreen.d.ts.map +1 -1
  321. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts +1 -1
  322. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  323. package/lib/typescript/module/ui/screens/PaymentGatewayScreen.d.ts +2 -2
  324. package/lib/typescript/module/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
  325. package/lib/typescript/module/ui/screens/PreferencesScreen.d.ts +1 -1
  326. package/lib/typescript/module/ui/screens/PreferencesScreen.d.ts.map +1 -1
  327. package/lib/typescript/module/ui/screens/PremiumSubscriptionScreen.d.ts +1 -1
  328. package/lib/typescript/module/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
  329. package/lib/typescript/module/ui/screens/PrivacySettingsScreen.d.ts +1 -1
  330. package/lib/typescript/module/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  331. package/lib/typescript/module/ui/screens/ProfileScreen.d.ts +1 -1
  332. package/lib/typescript/module/ui/screens/ProfileScreen.d.ts.map +1 -1
  333. package/lib/typescript/module/ui/screens/SavesCollectionsScreen.d.ts +1 -1
  334. package/lib/typescript/module/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
  335. package/lib/typescript/module/ui/screens/SearchSettingsScreen.d.ts +1 -1
  336. package/lib/typescript/module/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
  337. package/lib/typescript/module/ui/screens/UserLinksScreen.d.ts +1 -1
  338. package/lib/typescript/module/ui/screens/UserLinksScreen.d.ts.map +1 -1
  339. package/lib/typescript/module/ui/screens/UserListScreen.d.ts +1 -1
  340. package/lib/typescript/module/ui/screens/UserListScreen.d.ts.map +1 -1
  341. package/lib/typescript/module/ui/screens/WelcomeNewUserScreen.d.ts +1 -1
  342. package/lib/typescript/module/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
  343. package/lib/typescript/module/ui/screens/trust/TrustAboutScreen.d.ts +1 -1
  344. package/lib/typescript/module/ui/screens/trust/TrustAboutScreen.d.ts.map +1 -1
  345. package/lib/typescript/module/ui/screens/trust/TrustCenterScreen.d.ts +1 -1
  346. package/lib/typescript/module/ui/screens/trust/TrustCenterScreen.d.ts.map +1 -1
  347. package/lib/typescript/module/ui/screens/trust/TrustFAQScreen.d.ts +1 -1
  348. package/lib/typescript/module/ui/screens/trust/TrustFAQScreen.d.ts.map +1 -1
  349. package/lib/typescript/module/ui/screens/trust/TrustLeaderboardScreen.d.ts +1 -1
  350. package/lib/typescript/module/ui/screens/trust/TrustLeaderboardScreen.d.ts.map +1 -1
  351. package/lib/typescript/module/ui/screens/trust/TrustRewardsScreen.d.ts +1 -1
  352. package/lib/typescript/module/ui/screens/trust/TrustRewardsScreen.d.ts.map +1 -1
  353. package/lib/typescript/module/ui/screens/trust/TrustRulesScreen.d.ts +1 -1
  354. package/lib/typescript/module/ui/screens/trust/TrustRulesScreen.d.ts.map +1 -1
  355. package/lib/typescript/module/ui/server.d.ts +2 -2
  356. package/lib/typescript/module/ui/server.d.ts.map +1 -1
  357. package/lib/typescript/module/ui/types/fileManagement.d.ts +1 -1
  358. package/lib/typescript/module/ui/types/fileManagement.d.ts.map +1 -1
  359. package/lib/typescript/module/ui/types/navigation.d.ts +1 -1
  360. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  361. package/lib/typescript/module/ui/utils/activeAuthuser.d.ts +24 -0
  362. package/lib/typescript/module/ui/utils/activeAuthuser.d.ts.map +1 -1
  363. package/lib/typescript/module/ui/utils/fileManagement.d.ts +1 -1
  364. package/lib/typescript/module/ui/utils/fileManagement.d.ts.map +1 -1
  365. package/package.json +21 -20
  366. package/src/index.ts +8 -5
  367. package/src/ui/components/AccountMenuButton.tsx +9 -11
  368. package/src/ui/components/AccountSwitcher.tsx +71 -37
  369. package/src/ui/components/ProfileButton.tsx +270 -0
  370. package/src/ui/components/ProfileMenu.tsx +416 -0
  371. package/src/ui/context/OxyContext.tsx +217 -130
  372. package/src/ui/context/hooks/useAuthOperations.ts +35 -2
  373. package/src/ui/hooks/queries/useAccountQueries.ts +2 -2
  374. package/src/ui/hooks/queries/usePaymentQueries.ts +12 -12
  375. package/src/ui/hooks/queries/useServicesQueries.ts +9 -6
  376. package/src/ui/index.ts +2 -0
  377. package/src/ui/screens/AccountSettingsScreen.tsx +9 -5
  378. package/src/ui/screens/AccountSwitcherScreen.tsx +3 -3
  379. package/src/ui/screens/CreateAccountScreen.tsx +6 -4
  380. package/src/ui/screens/EditProfileFieldScreen.tsx +8 -7
  381. package/src/ui/screens/FileManagementScreen.tsx +13 -13
  382. package/src/ui/screens/HistoryViewScreen.tsx +7 -7
  383. package/src/ui/screens/LanguageSelectorScreen.tsx +5 -5
  384. package/src/ui/screens/ManageAccountScreen.tsx +17 -18
  385. package/src/ui/screens/PremiumSubscriptionScreen.tsx +3 -3
  386. package/src/ui/screens/PrivacySettingsScreen.tsx +9 -9
  387. package/src/ui/screens/ProfileScreen.tsx +1 -1
  388. package/src/ui/screens/SavesCollectionsScreen.tsx +5 -5
  389. package/src/ui/screens/SearchSettingsScreen.tsx +6 -6
  390. package/src/ui/screens/WelcomeNewUserScreen.tsx +6 -6
  391. package/src/ui/screens/trust/TrustCenterScreen.tsx +5 -5
  392. package/src/ui/screens/trust/TrustRewardsScreen.tsx +4 -4
  393. package/src/ui/utils/__tests__/activeAuthuser.test.ts +75 -0
  394. package/src/ui/utils/activeAuthuser.ts +74 -8
  395. package/lib/commonjs/ui/components/ActiveAccountBanner.js +0 -144
  396. package/lib/commonjs/ui/components/ActiveAccountBanner.js.map +0 -1
  397. package/lib/module/ui/components/ActiveAccountBanner.js +0 -141
  398. package/lib/module/ui/components/ActiveAccountBanner.js.map +0 -1
  399. package/lib/typescript/commonjs/ui/components/ActiveAccountBanner.d.ts +0 -4
  400. package/lib/typescript/commonjs/ui/components/ActiveAccountBanner.d.ts.map +0 -1
  401. package/lib/typescript/module/ui/components/ActiveAccountBanner.d.ts +0 -4
  402. package/lib/typescript/module/ui/components/ActiveAccountBanner.d.ts.map +0 -1
  403. package/src/ui/components/ActiveAccountBanner.tsx +0 -130
@@ -14,7 +14,7 @@ import { useAuthOperations } from "./hooks/useAuthOperations.js";
14
14
  import { useDeviceManagement } from "../hooks/useDeviceManagement.js";
15
15
  import { getStorageKeys, createPlatformStorage } from "../utils/storageHelpers.js";
16
16
  import { isInvalidSessionError, isTimeoutOrNetworkError } from "../utils/errorHandlers.js";
17
- import { readActiveAuthuser, writeActiveAuthuser } from "../utils/activeAuthuser.js";
17
+ import { readActiveAuthuser, writeActiveAuthuser, clearSignedOut, isSilentRestoreSuppressed } from "../utils/activeAuthuser.js";
18
18
  import { showBottomSheet as globalShowBottomSheet } from "../navigation/bottomSheetManager.js";
19
19
  import { useQueryClient } from '@tanstack/react-query';
20
20
  import { clearQueryCache } from "../hooks/queryClient.js";
@@ -1091,6 +1091,54 @@ export const OxyProvider = ({
1091
1091
  }, priorSessionReadError);
1092
1092
  }
1093
1093
  }
1094
+
1095
+ // LAST-ACTIVE-ACCOUNT priority (web multi-account). When the user has an
1096
+ // explicit persisted active slot (`oxy_active_authuser`, written on every
1097
+ // device sign-in / account SWITCH / cookie restore), the multi-account
1098
+ // refresh-cookie restore is the ONLY cold-boot step that honors WHICH slot
1099
+ // was last active — `restoreViaRefreshCookie` selects it via
1100
+ // `selectActiveRefreshAccount(accounts, readActiveAuthuser())`. The
1101
+ // `fedcm-silent` and per-apex `silent-iframe` steps only ever recover the
1102
+ // PRIMARY central IdP session, so if either ran first they would clobber a
1103
+ // switched (managed/org) account back to the primary on reload — the exact
1104
+ // "switch is lost on reload" regression. So when a slot selection exists we
1105
+ // run cookie-restore BEFORE those probes (and disable the later duplicate).
1106
+ //
1107
+ // Read ONCE here (synchronously usable by the step `enabled` gates below).
1108
+ // It is non-null ONLY on first-party web apps that persist the slot. Both the
1109
+ // device sign-in/switch paths AND `handleWebSSOSession` (FedCM/SSO/credentials
1110
+ // commit funnel) now persist it — but only when the session genuinely joined
1111
+ // the device set: `establishDeviceRefreshSlot` returns an `authuser` ONLY on
1112
+ // first-party web (same registrable apex as the API), so a cross-apex RP never
1113
+ // writes a phantom slot and native has no localStorage. Both therefore keep
1114
+ // their existing order untouched. The earlier `stored-session` step still runs
1115
+ // first (FIX-A latency), and when a slot exists but its cookies have all
1116
+ // lapsed, cookie-restore simply returns no accounts and the chain falls through
1117
+ // to the cross-domain fallbacks exactly as before.
1118
+ const prioritizeMultiAccount = isWebBrowser() && readActiveAuthuser() !== null;
1119
+
1120
+ // DELIBERATELY-SIGNED-OUT gate (web): when the user pressed "Sign out", any
1121
+ // credential that can silently re-mint a session may still be live on the
1122
+ // next reload — the central IdP session (FedCM credential association /
1123
+ // per-apex `fedcm_session` cookie) AND the device refresh cookies. Since
1124
+ // PR #455 the PRIMARY web session also joins the `oxy_rt_<authuser>` device
1125
+ // set, so the un-gated cookie-restore steps would `refresh-all` that still-
1126
+ // present cookie and sign the user back in without intent — exactly the
1127
+ // "sign-out is silently undone" regression. So this flag gates EVERY
1128
+ // AUTOMATIC silent-restore cold-boot step: `stored-session`,
1129
+ // `cookie-restore-active`, `fedcm-silent`, `silent-iframe`, and
1130
+ // `cookie-restore`. The gate — not a cookie wipe — is the authority: the
1131
+ // account may stay "known" for a fast deliberate re-sign-in, but no step
1132
+ // restores it silently while the flag is set. Read the durable flag ONCE here
1133
+ // (synchronously usable by every step `enabled` gate). Any deliberate sign-in
1134
+ // (password, FedCM, account switch, device claim) clears it, so there is no
1135
+ // "stuck signed out" state. The `sso-bounce` step needs no extra gate: it is
1136
+ // already self-suppressed after sign-out (its `hasPriorSession` hint is
1137
+ // cleared). `sso-return` is NOT gated — it commits the result of a deliberate
1138
+ // top-level `/sso` bounce the user just initiated. `shared-key-signin` is
1139
+ // native-only and the flag never sets on native (`markSignedOut` no-ops
1140
+ // off-web), so its gate would be moot; it is left untouched.
1141
+ const silentRestoreBlocked = isSilentRestoreSuppressed();
1094
1142
  try {
1095
1143
  const outcome = await runColdBoot({
1096
1144
  steps: [{
@@ -1111,12 +1159,17 @@ export const OxyProvider = ({
1111
1159
  };
1112
1160
  }
1113
1161
  }, {
1114
- // 2) Stored-session bearer restore. NO `enabled` gate runs on ALL
1115
- // platforms. This is native's ONLY restore path (every web-only step
1116
- // is disabled off-browser, so native reaches exactly this) AND the
1117
- // common WEB reload winner.
1162
+ // 2) Stored-session bearer restore. Runs on ALL platforms EXCEPT when
1163
+ // the deliberately-signed-out flag is set (web only it never sets on
1164
+ // native, so native still always reaches exactly this step, its ONLY
1165
+ // restore path). This is also the common WEB reload winner.
1166
+ //
1167
+ // SIGNED-OUT GATE: after a deliberate full sign-out the stored session
1168
+ // state is cleared, so this would normally skip anyway — but the gate
1169
+ // makes that authoritative rather than incidental, so no residual
1170
+ // stored token can silently restore while the user is signed out.
1118
1171
  //
1119
- // ORDERING (FIX A): this step now runs BEFORE the slow web-only
1172
+ // ORDERING (FIX A): this step runs BEFORE the slow web-only
1120
1173
  // probes (`fedcm-silent`, `silent-iframe`, `cookie-restore`). On a
1121
1174
  // normal reload the local bearer validates in one round-trip and
1122
1175
  // wins; `runColdBoot` then short-circuits and never even evaluates
@@ -1127,6 +1180,7 @@ export const OxyProvider = ({
1127
1180
  // local session this step skips and the cross-domain fallback chain
1128
1181
  // (fedcm → iframe → cookie → sso-bounce) runs exactly as before.
1129
1182
  id: 'stored-session',
1183
+ enabled: () => !silentRestoreBlocked,
1130
1184
  run: async () => {
1131
1185
  const restored = await restoreStoredSession();
1132
1186
  if (restored) {
@@ -1195,6 +1249,38 @@ export const OxyProvider = ({
1195
1249
  session: true
1196
1250
  };
1197
1251
  }
1252
+ }, {
1253
+ // 2.75) LAST-ACTIVE multi-account restore (WEB, prioritized). Runs
1254
+ // ONLY when an explicit persisted slot selection exists
1255
+ // (`prioritizeMultiAccount`) — i.e. the user previously signed in or
1256
+ // SWITCHED accounts on this first-party app. It runs BEFORE the
1257
+ // `fedcm-silent` / `silent-iframe` probes (which only ever recover the
1258
+ // PRIMARY central session) so a switched managed/org account survives
1259
+ // reload instead of being clobbered back to the primary. The restore
1260
+ // itself is the SAME `restoreViaRefreshCookie` as the terminal-tier
1261
+ // step below: it rotates every device-local `oxy_rt_<authuser>` cookie
1262
+ // and picks the persisted slot via `selectActiveRefreshAccount`,
1263
+ // committing it (token + state + durable persistence + `markAuthResolved`).
1264
+ // When no slot is persisted this is disabled and the original order is
1265
+ // unchanged; when the slot's cookies have lapsed it returns no accounts
1266
+ // and the chain falls through to the cross-domain fallbacks below.
1267
+ //
1268
+ // SIGNED-OUT GATE: since PR #455 the primary's `oxy_rt` slot survives a
1269
+ // deliberate sign-out, so without this gate `refresh-all` would re-mint
1270
+ // and silently re-log-in the user on reload. The flag is cleared by any
1271
+ // deliberate sign-in (including an account SWITCH, which also writes the
1272
+ // new active slot), so the switch-survives-reload path is unaffected.
1273
+ id: 'cookie-restore-active',
1274
+ enabled: () => prioritizeMultiAccount && !silentRestoreBlocked,
1275
+ run: async () => {
1276
+ const restored = await restoreViaRefreshCookie();
1277
+ return restored ? {
1278
+ kind: 'session',
1279
+ session: true
1280
+ } : {
1281
+ kind: 'skip'
1282
+ };
1283
+ }
1198
1284
  }, {
1199
1285
  // 3) FedCM silent reauthn (Chrome) against the CENTRAL IdP
1200
1286
  // (auth.oxy.so). `silentSignInWithFedCM` plants the access token
@@ -1207,7 +1293,7 @@ export const OxyProvider = ({
1207
1293
  // already recovered a local session — the probe cannot improve on a
1208
1294
  // valid local bearer, and skipping it avoids the silent round-trip.
1209
1295
  id: 'fedcm-silent',
1210
- enabled: () => !storedSessionRestored && fedcmSupported && !servicesSilentAttempted.has(silentKey),
1296
+ enabled: () => !storedSessionRestored && !silentRestoreBlocked && fedcmSupported && !servicesSilentAttempted.has(silentKey),
1211
1297
  run: async () => {
1212
1298
  servicesSilentAttempted.add(silentKey);
1213
1299
  const session = await oxyServices.silentSignInWithFedCM?.();
@@ -1246,7 +1332,7 @@ export const OxyProvider = ({
1246
1332
  // FIX-D: bounded by `SILENT_IFRAME_TIMEOUT` (plus `iframe.onerror`
1247
1333
  // fail-fast in core) so a no-message iframe cannot stall cold boot.
1248
1334
  id: 'silent-iframe',
1249
- enabled: () => !storedSessionRestored && isWebBrowser(),
1335
+ enabled: () => !storedSessionRestored && !silentRestoreBlocked && isWebBrowser(),
1250
1336
  run: async () => {
1251
1337
  if (!commitWebSession) {
1252
1338
  return {
@@ -1278,8 +1364,20 @@ export const OxyProvider = ({
1278
1364
  // is correct; cross-domain restore is handled by the SSO bounce.
1279
1365
  // FIX-D: `restoreViaRefreshCookie` bounds the request with
1280
1366
  // `COOKIE_RESTORE_TIMEOUT` so a cross-domain stall cannot hang here.
1367
+ //
1368
+ // Disabled when `prioritizeMultiAccount` already ran the
1369
+ // `cookie-restore-active` step above (an explicit persisted slot) — that
1370
+ // earlier step is the identical restore, so this terminal-tier copy
1371
+ // would be a redundant second `refreshAllSessions`. It still runs in the
1372
+ // common no-persisted-slot case (e.g. first visit to a first-party app
1373
+ // whose central refresh cookies already exist).
1374
+ //
1375
+ // SIGNED-OUT GATE (same rationale as `cookie-restore-active`): the
1376
+ // primary's `oxy_rt` slot survives a deliberate sign-out (PR #455), so
1377
+ // this must be skipped while the signed-out flag is set or it would
1378
+ // silently re-restore the primary on reload.
1281
1379
  id: 'cookie-restore',
1282
- enabled: () => isWebBrowser(),
1380
+ enabled: () => isWebBrowser() && !prioritizeMultiAccount && !silentRestoreBlocked,
1283
1381
  run: async () => {
1284
1382
  const restored = await restoreViaRefreshCookie();
1285
1383
  return restored ? {
@@ -1519,13 +1617,48 @@ export const OxyProvider = ({
1519
1617
  throw new Error('Session response did not include an access token');
1520
1618
  }
1521
1619
  oxyServices.httpService.setTokens(session.accessToken);
1620
+
1621
+ // A committed web session re-enables automatic silent restore: clear the
1622
+ // durable "deliberately signed out" flag. This funnel is reached by deliberate
1623
+ // sign-ins (password, interactive FedCM, `/sso` return) AND by the silent
1624
+ // cold-boot steps — but those are GATED on the flag, so when it is set they
1625
+ // never run and never reach here; clearing is therefore only hit on a genuine
1626
+ // (re-)sign-in or when restore was already permitted, both correct.
1627
+ clearSignedOut();
1628
+
1629
+ // Register this primary session in the device's first-party multi-account
1630
+ // refresh-cookie set (web only). Every web primary-session restore funnels
1631
+ // through here — FedCM silent (`/fedcm/exchange`), per-apex `/auth/silent`
1632
+ // iframe, central `/sso` return, and keyless password sign-in. Of those, only
1633
+ // a same-apex `/fedcm/exchange` plants an `oxy_rt_<authuser>` slot as a side
1634
+ // effect; the cross-origin/credential-less restores (`/sso/exchange`,
1635
+ // `/auth/silent` postMessage) cannot set an `api.oxy.so` cookie at all. So
1636
+ // WITHOUT this call a web primary never joins the device set: `refresh-all`
1637
+ // returns zero accounts, and account-switch persistence + the
1638
+ // `cookie-restore-active` cold-boot step have no foundation. Calling the shared
1639
+ // `POST /auth/session` primitive here makes EVERY primary participate in the
1640
+ // set, re-plants the rotated token, and records the active `authuser` so the
1641
+ // next cold boot's `cookie-restore-active` reconciles the persisted active
1642
+ // (possibly switched) account instead of `fedcm-silent` clobbering it back to
1643
+ // the primary. Best-effort: a `null` result (native / transient failure)
1644
+ // leaves the in-session token untouched.
1645
+ const primaryAuthuser = await oxyServices.establishDeviceRefreshSlot();
1646
+ // A non-null slot is returned ONLY on first-party web (the helper gates on
1647
+ // platform + same registrable apex), so recording the active slot here is safe
1648
+ // and never writes a phantom authuser for a cross-apex RP or native.
1649
+ if (typeof primaryAuthuser === 'number') {
1650
+ writeActiveAuthuser(primaryAuthuser);
1651
+ }
1522
1652
  const clientSession = {
1523
1653
  sessionId: session.sessionId,
1524
1654
  deviceId: session.deviceId || '',
1525
1655
  expiresAt: session.expiresAt || new Date(Date.now() + DEFAULT_SESSION_VALIDITY_MS).toISOString(),
1526
1656
  lastActive: new Date().toISOString(),
1527
1657
  userId: session.user.id?.toString() ?? '',
1528
- isCurrent: true
1658
+ isCurrent: true,
1659
+ ...(typeof primaryAuthuser === 'number' ? {
1660
+ authuser: primaryAuthuser
1661
+ } : null)
1529
1662
  };
1530
1663
  updateSessions([clientSession], {
1531
1664
  merge: true
@@ -1760,42 +1893,8 @@ export const OxyProvider = ({
1760
1893
  });
1761
1894
 
1762
1895
  // --- Account graph state ---
1763
- const [actingAs, setActingAsState] = useState(null);
1764
1896
  const [accounts, setAccounts] = useState([]);
1765
1897
 
1766
- // Latest `actingAs`, mirrored into a ref so `refreshAccounts` can reconcile a
1767
- // stale switch without taking `actingAs` as a dependency (which would re-run
1768
- // the account load on every switch). See the reconciliation block below.
1769
- const actingAsRef = useRef(actingAs);
1770
- actingAsRef.current = actingAs;
1771
- // `setActingAs` is declared after `refreshAccounts`; route the reconciliation
1772
- // clear through a ref so the load callback can call the latest implementation.
1773
- const setActingAsRef = useRef(null);
1774
-
1775
- // Restore actingAs from storage on startup
1776
- useEffect(() => {
1777
- if (!storage || !initialized) return;
1778
- let mounted = true;
1779
- (async () => {
1780
- try {
1781
- const stored = await storage.getItem(`${storageKeyPrefix}_acting_as`);
1782
- if (mounted && stored) {
1783
- setActingAsState(stored);
1784
- oxyServices.setActingAs(stored);
1785
- }
1786
- } catch (err) {
1787
- if (__DEV__) {
1788
- loggerUtil.debug('Failed to restore actingAs from storage', {
1789
- component: 'OxyContext'
1790
- }, err);
1791
- }
1792
- }
1793
- })();
1794
- return () => {
1795
- mounted = false;
1796
- };
1797
- }, [storage, initialized, storageKeyPrefix, oxyServices]);
1798
-
1799
1898
  // Load the unified account graph when authenticated
1800
1899
  const refreshAccounts = useCallback(async () => {
1801
1900
  if (!isAuthenticated || !tokenReady || !oxyServices.getAccessToken()) {
@@ -1805,15 +1904,6 @@ export const OxyProvider = ({
1805
1904
  try {
1806
1905
  const list = await oxyServices.listAccounts();
1807
1906
  setAccounts(list);
1808
- // Reconcile a stale switch: if the active account was switched INTO an id
1809
- // that is no longer accessible (account removed/archived, or it belonged
1810
- // to a now-inactive sign-in), drop back to the personal account so the
1811
- // app never keeps sending a dead `X-Acting-As` header. `list` is the
1812
- // authoritative accessible set on a successful fetch.
1813
- const current = actingAsRef.current;
1814
- if (current && !list.some(node => node.accountId === current)) {
1815
- setActingAsRef.current?.(null);
1816
- }
1817
1907
  } catch (err) {
1818
1908
  if (isUnauthorizedStatus(err)) {
1819
1909
  setAccounts([]);
@@ -1832,48 +1922,76 @@ export const OxyProvider = ({
1832
1922
  refreshAccounts();
1833
1923
  }
1834
1924
  }, [isAuthenticated, initialized, tokenReady, refreshAccounts]);
1835
- const setActingAs = useCallback(accountId => {
1836
- oxyServices.setActingAs(accountId);
1837
- setActingAsState(accountId);
1838
- // Switching the acting-as identity changes every server response, but React
1839
- // Query keys are not namespaced by the acting-as target, so the cache would
1840
- // otherwise keep serving the previous account's data. Invalidate everything
1841
- // so each query refetches under the new identity (the next request carries
1842
- // the updated `X-Acting-As` header). `invalidateQueries` (not `clear`) keeps
1843
- // the account list/switcher populated mid-switch instead of blanking out.
1844
- queryClient.invalidateQueries();
1845
- // Persist to storage
1846
- if (storage) {
1847
- if (accountId) {
1848
- storage.setItem(`${storageKeyPrefix}_acting_as`, accountId).catch(persistError => {
1849
- loggerUtil.debug('Failed to persist acting-as account', {
1850
- component: 'OxyContext'
1851
- }, persistError);
1852
- });
1853
- } else {
1854
- storage.removeItem(`${storageKeyPrefix}_acting_as`).catch(persistError => {
1855
- loggerUtil.debug('Failed to clear acting-as account', {
1856
- component: 'OxyContext'
1857
- }, persistError);
1858
- });
1925
+
1926
+ // Switch the active session INTO an account from the unified graph. In the
1927
+ // REAL-SESSION model this is identical to switching device sign-ins: mint a
1928
+ // real session for the target and make the whole app that account. The removed
1929
+ // `X-Acting-As` delegation header is gone `oxyServices.switchToAccount`
1930
+ // plants the minted access token (the refresh token is the server-set httpOnly
1931
+ // `oxy_rt_<authuser>` cookie, so the session joins the device multi-account set
1932
+ // and survives reload / `refresh-all`). We then commit the session into context
1933
+ // state the SAME way sign-in / `switchSession` do, refresh the account graph,
1934
+ // and invalidate every query so all data reloads as the new account.
1935
+ const switchToAccount = useCallback(async accountId => {
1936
+ const result = await oxyServices.switchToAccount(accountId);
1937
+ if (!result?.user || !result?.sessionId) {
1938
+ throw new Error('Account switch did not return a valid session');
1939
+ }
1940
+
1941
+ // A switch is a deliberate sign-in into an account: re-enable automatic silent
1942
+ // restore by clearing any prior "deliberately signed out" flag.
1943
+ clearSignedOut();
1944
+
1945
+ // `oxyServices.switchToAccount` already planted `result.accessToken` as the
1946
+ // active token; mirror the minted session into the multi-account store and
1947
+ // mark it current, recording the device `authuser` slot so web silent-switch
1948
+ // and the device account chooser can address it.
1949
+ const now = new Date();
1950
+ const clientSession = {
1951
+ sessionId: result.sessionId,
1952
+ deviceId: result.deviceId || '',
1953
+ expiresAt: result.expiresAt || new Date(now.getTime() + DEFAULT_SESSION_VALIDITY_MS).toISOString(),
1954
+ lastActive: now.toISOString(),
1955
+ userId: result.user.id?.toString() ?? '',
1956
+ isCurrent: true,
1957
+ ...(typeof result.authuser === 'number' ? {
1958
+ authuser: result.authuser
1959
+ } : null)
1960
+ };
1961
+ updateSessions([clientSession], {
1962
+ merge: true
1963
+ });
1964
+ setActiveSessionId(result.sessionId);
1965
+ if (isWebBrowser() && typeof result.authuser === 'number') {
1966
+ writeActiveAuthuser(result.authuser);
1967
+ }
1968
+ await persistSessionDurably(result.sessionId);
1969
+
1970
+ // Fetch the canonical User for the new account (the switch result carries
1971
+ // only MinimalUserData); fall back to that minimal shape if the profile
1972
+ // fetch fails so the app still reflects the switched identity.
1973
+ let fullUser;
1974
+ try {
1975
+ fullUser = await oxyServices.getCurrentUser();
1976
+ } catch (profileError) {
1977
+ if (__DEV__) {
1978
+ loggerUtil.debug('Failed to fetch full user after account switch; using switch result user', {
1979
+ component: 'OxyContext',
1980
+ method: 'switchToAccount'
1981
+ }, profileError);
1859
1982
  }
1983
+ fullUser = result.user;
1860
1984
  }
1861
- }, [oxyServices, storage, storageKeyPrefix, queryClient]);
1862
- setActingAsRef.current = setActingAs;
1863
-
1864
- // The account switched into, resolved from the loaded graph.
1865
- const actingAsAccount = useMemo(() => {
1866
- if (!actingAs) return null;
1867
- return accounts.find(node => node.accountId === actingAs) ?? null;
1868
- }, [actingAs, accounts]);
1869
-
1870
- // The effective ACTIVE account presented across the app: the switched-into
1871
- // account's user when a switch is set and resolved, otherwise the signed-in
1872
- // user's own personal account. Derived (no effect) so identity surfaces always
1873
- // render the current account without separate syncing. Falls back to `user`
1874
- // while a just-set switch has not yet resolved in `accounts`, so the header
1875
- // never flashes empty mid-switch.
1876
- const activeAccount = useMemo(() => actingAs && actingAsAccount ? actingAsAccount.account : user, [actingAs, actingAsAccount, user]);
1985
+ loginSuccess(fullUser);
1986
+ onAuthStateChange?.(fullUser);
1987
+
1988
+ // Reload the switchable account graph (the new active account's relationships
1989
+ // differ) and invalidate every query so all data refetches as the new
1990
+ // account the deviceAccounts probe re-enumerates the multi-account set so
1991
+ // the switched account now appears as a device session.
1992
+ await refreshAccounts();
1993
+ queryClient.invalidateQueries();
1994
+ }, [oxyServices, updateSessions, setActiveSessionId, persistSessionDurably, loginSuccess, onAuthStateChange, refreshAccounts, queryClient]);
1877
1995
  const createAccountFn = useCallback(async data => {
1878
1996
  const account = await oxyServices.createAccount(data);
1879
1997
  await refreshAccounts();
@@ -1920,14 +2038,11 @@ export const OxyProvider = ({
1920
2038
  useFollow: useFollowHook,
1921
2039
  showBottomSheet: showBottomSheetForContext,
1922
2040
  openAvatarPicker,
1923
- actingAs,
1924
2041
  accounts,
1925
- actingAsAccount,
1926
- activeAccount,
1927
- setActingAs,
2042
+ switchToAccount,
1928
2043
  refreshAccounts,
1929
2044
  createAccount: createAccountFn
1930
- }), [activeSessionId, signIn, signInWithPassword, handleWebSSOSession, currentLanguage, currentLanguageMetadata, currentLanguageName, currentNativeLanguageName, error, getDeviceSessions, hasAccessToken, canUsePrivateApi, isPrivateApiPending, getPublicKey, hasIdentity, isAuthenticated, isLoading, logout, logoutAll, logoutAllDeviceSessions, oxyServices, storageKeyPrefix, clientId, refreshSessionsWithUser, sessions, setLanguage, storage, switchSessionForContext, tokenReady, hasAccessToken, canUsePrivateApi, isPrivateApiPending, authResolved, updateDeviceName, clearAllAccountData, useFollowHook, user, showBottomSheetForContext, openAvatarPicker, actingAs, accounts, actingAsAccount, activeAccount, setActingAs, refreshAccounts, createAccountFn]);
2045
+ }), [activeSessionId, signIn, signInWithPassword, handleWebSSOSession, currentLanguage, currentLanguageMetadata, currentLanguageName, currentNativeLanguageName, error, getDeviceSessions, hasAccessToken, canUsePrivateApi, isPrivateApiPending, getPublicKey, hasIdentity, isAuthenticated, isLoading, logout, logoutAll, logoutAllDeviceSessions, oxyServices, storageKeyPrefix, clientId, refreshSessionsWithUser, sessions, setLanguage, storage, switchSessionForContext, tokenReady, hasAccessToken, canUsePrivateApi, isPrivateApiPending, authResolved, updateDeviceName, clearAllAccountData, useFollowHook, user, showBottomSheetForContext, openAvatarPicker, accounts, switchToAccount, refreshAccounts, createAccountFn]);
1931
2046
  return /*#__PURE__*/_jsx(OxyContext.Provider, {
1932
2047
  value: contextValue,
1933
2048
  children: ssoCallbackIntercepting ? null : children
@@ -1986,11 +2101,8 @@ const LOADING_STATE = {
1986
2101
  clientId: null,
1987
2102
  oxyServices: LOADING_STATE_OXY_SERVICES,
1988
2103
  openAvatarPicker: () => {},
1989
- actingAs: null,
1990
2104
  accounts: [],
1991
- actingAsAccount: null,
1992
- activeAccount: null,
1993
- setActingAs: () => {},
2105
+ switchToAccount: () => rejectMissingProvider(),
1994
2106
  refreshAccounts: () => rejectMissingProvider(),
1995
2107
  createAccount: () => rejectMissingProvider()
1996
2108
  };