@oxyhq/services 27.1.3 → 29.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 (387) hide show
  1. package/LICENSE +202 -661
  2. package/NOTICE +16 -0
  3. package/README.md +67 -2
  4. package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionModule.kt +178 -0
  5. package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionProvider.kt +99 -0
  6. package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionStore.kt +115 -0
  7. package/expo-module.config.json +1 -0
  8. package/lib/commonjs/index.js +78 -16
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/ui/boot/runProviderColdBoot.js +7 -0
  11. package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
  12. package/lib/commonjs/ui/client.js +12 -7
  13. package/lib/commonjs/ui/client.js.map +1 -1
  14. package/lib/commonjs/ui/components/OxyAccountDialogScreen.js +10 -27
  15. package/lib/commonjs/ui/components/OxyAccountDialogScreen.js.map +1 -1
  16. package/lib/commonjs/ui/components/OxyAuthChooser.js +132 -44
  17. package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
  18. package/lib/commonjs/ui/components/OxyProvider.js +4 -2
  19. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  20. package/lib/commonjs/ui/components/SurfaceScreen.js +31 -3
  21. package/lib/commonjs/ui/components/SurfaceScreen.js.map +1 -1
  22. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js +209 -84
  23. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  24. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js +25 -7
  25. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js.map +1 -1
  26. package/lib/commonjs/ui/components/authChooser/primitives.js +35 -22
  27. package/lib/commonjs/ui/components/authChooser/primitives.js.map +1 -1
  28. package/lib/commonjs/ui/components/authChooser/signInProgress.js +5 -0
  29. package/lib/commonjs/ui/components/authChooser/signInProgress.js.map +1 -1
  30. package/lib/commonjs/ui/components/authChooser/types.js +11 -0
  31. package/lib/commonjs/ui/components/authChooser/types.js.map +1 -1
  32. package/lib/commonjs/ui/context/OxyContext.js +257 -306
  33. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  34. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +27 -37
  35. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  36. package/lib/commonjs/ui/context/oxyContextHelpers.js +0 -29
  37. package/lib/commonjs/ui/context/oxyContextHelpers.js.map +1 -1
  38. package/lib/commonjs/ui/context/useOxyAccountGraph.js +6 -17
  39. package/lib/commonjs/ui/context/useOxyAccountGraph.js.map +1 -1
  40. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js +42 -0
  41. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js.map +1 -0
  42. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +0 -19
  43. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  44. package/lib/commonjs/ui/hooks/useDeviceSwitcher.js +57 -0
  45. package/lib/commonjs/ui/hooks/useDeviceSwitcher.js.map +1 -0
  46. package/lib/commonjs/ui/hooks/useI18n.js +22 -3
  47. package/lib/commonjs/ui/hooks/useI18n.js.map +1 -1
  48. package/lib/commonjs/ui/hooks/useSessionManagement.js +46 -153
  49. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  50. package/lib/commonjs/ui/index.js +12 -7
  51. package/lib/commonjs/ui/index.js.map +1 -1
  52. package/lib/commonjs/ui/navigation/routes.js +85 -73
  53. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  54. package/lib/commonjs/ui/navigation/surfaces.js +8 -7
  55. package/lib/commonjs/ui/navigation/surfaces.js.map +1 -1
  56. package/lib/commonjs/ui/runtime/createOxyRuntime.js +433 -0
  57. package/lib/commonjs/ui/runtime/createOxyRuntime.js.map +1 -0
  58. package/lib/commonjs/ui/runtime/index.js +63 -0
  59. package/lib/commonjs/ui/runtime/index.js.map +1 -0
  60. package/lib/commonjs/ui/runtime/runtimeContext.js +83 -0
  61. package/lib/commonjs/ui/runtime/runtimeContext.js.map +1 -0
  62. package/lib/commonjs/ui/runtime/types.js +6 -0
  63. package/lib/commonjs/ui/runtime/types.js.map +1 -0
  64. package/lib/commonjs/ui/runtime/useRuntimeSnapshot.js +57 -0
  65. package/lib/commonjs/ui/runtime/useRuntimeSnapshot.js.map +1 -0
  66. package/lib/commonjs/ui/screens/AccountMembersScreen.js +3 -4
  67. package/lib/commonjs/ui/screens/AccountMembersScreen.js.map +1 -1
  68. package/lib/commonjs/ui/screens/CreateAccountScreen.js +3 -12
  69. package/lib/commonjs/ui/screens/CreateAccountScreen.js.map +1 -1
  70. package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js +6 -5
  71. package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js.map +1 -1
  72. package/lib/commonjs/ui/screens/trust/TrustLeaderboardScreen.js +4 -4
  73. package/lib/commonjs/ui/screens/trust/TrustLeaderboardScreen.js.map +1 -1
  74. package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js +1 -1
  75. package/lib/commonjs/ui/screens/trust/TrustRulesScreen.js +4 -2
  76. package/lib/commonjs/ui/screens/trust/TrustRulesScreen.js.map +1 -1
  77. package/lib/commonjs/ui/server.js +1 -2
  78. package/lib/commonjs/ui/server.js.map +1 -1
  79. package/lib/commonjs/ui/session/authStore.js +45 -9
  80. package/lib/commonjs/ui/session/authStore.js.map +1 -1
  81. package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js +306 -0
  82. package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js.map +1 -0
  83. package/lib/commonjs/ui/stores/authStore.js +154 -55
  84. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  85. package/lib/commonjs/ui/stores/followTargetStore.js +27 -0
  86. package/lib/commonjs/ui/stores/followTargetStore.js.map +1 -1
  87. package/lib/commonjs/ui/utils/avatarUtils.js +2 -36
  88. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  89. package/lib/module/index.js +20 -9
  90. package/lib/module/index.js.map +1 -1
  91. package/lib/module/ui/boot/runProviderColdBoot.js +7 -0
  92. package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
  93. package/lib/module/ui/client.js +1 -2
  94. package/lib/module/ui/client.js.map +1 -1
  95. package/lib/module/ui/components/OxyAccountDialogScreen.js +10 -27
  96. package/lib/module/ui/components/OxyAccountDialogScreen.js.map +1 -1
  97. package/lib/module/ui/components/OxyAuthChooser.js +134 -44
  98. package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
  99. package/lib/module/ui/components/OxyProvider.js +5 -3
  100. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  101. package/lib/module/ui/components/SurfaceScreen.js +33 -5
  102. package/lib/module/ui/components/SurfaceScreen.js.map +1 -1
  103. package/lib/module/ui/components/authChooser/AccountsMenuView.js +210 -85
  104. package/lib/module/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  105. package/lib/module/ui/components/authChooser/SignInEntryView.js +25 -7
  106. package/lib/module/ui/components/authChooser/SignInEntryView.js.map +1 -1
  107. package/lib/module/ui/components/authChooser/primitives.js +35 -22
  108. package/lib/module/ui/components/authChooser/primitives.js.map +1 -1
  109. package/lib/module/ui/components/authChooser/signInProgress.js +5 -0
  110. package/lib/module/ui/components/authChooser/signInProgress.js.map +1 -1
  111. package/lib/module/ui/components/authChooser/types.js +11 -0
  112. package/lib/module/ui/components/authChooser/types.js.map +1 -1
  113. package/lib/module/ui/context/OxyContext.js +251 -303
  114. package/lib/module/ui/context/OxyContext.js.map +1 -1
  115. package/lib/module/ui/context/hooks/useAuthOperations.js +27 -37
  116. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  117. package/lib/module/ui/context/oxyContextHelpers.js +0 -28
  118. package/lib/module/ui/context/oxyContextHelpers.js.map +1 -1
  119. package/lib/module/ui/context/useOxyAccountGraph.js +6 -17
  120. package/lib/module/ui/context/useOxyAccountGraph.js.map +1 -1
  121. package/lib/module/ui/hooks/accountDialogSnapshot.js +38 -0
  122. package/lib/module/ui/hooks/accountDialogSnapshot.js.map +1 -0
  123. package/lib/module/ui/hooks/mutations/useAccountMutations.js +0 -19
  124. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  125. package/lib/module/ui/hooks/useDeviceSwitcher.js +53 -0
  126. package/lib/module/ui/hooks/useDeviceSwitcher.js.map +1 -0
  127. package/lib/module/ui/hooks/useI18n.js +24 -4
  128. package/lib/module/ui/hooks/useI18n.js.map +1 -1
  129. package/lib/module/ui/hooks/useSessionManagement.js +47 -155
  130. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  131. package/lib/module/ui/index.js +1 -2
  132. package/lib/module/ui/index.js.map +1 -1
  133. package/lib/module/ui/navigation/routes.js +84 -72
  134. package/lib/module/ui/navigation/routes.js.map +1 -1
  135. package/lib/module/ui/navigation/surfaces.js +6 -6
  136. package/lib/module/ui/navigation/surfaces.js.map +1 -1
  137. package/lib/module/ui/runtime/createOxyRuntime.js +430 -0
  138. package/lib/module/ui/runtime/createOxyRuntime.js.map +1 -0
  139. package/lib/module/ui/runtime/index.js +15 -0
  140. package/lib/module/ui/runtime/index.js.map +1 -0
  141. package/lib/module/ui/runtime/runtimeContext.js +75 -0
  142. package/lib/module/ui/runtime/runtimeContext.js.map +1 -0
  143. package/lib/module/ui/runtime/types.js +4 -0
  144. package/lib/module/ui/runtime/types.js.map +1 -0
  145. package/lib/module/ui/runtime/useRuntimeSnapshot.js +52 -0
  146. package/lib/module/ui/runtime/useRuntimeSnapshot.js.map +1 -0
  147. package/lib/module/ui/screens/AccountMembersScreen.js +4 -5
  148. package/lib/module/ui/screens/AccountMembersScreen.js.map +1 -1
  149. package/lib/module/ui/screens/CreateAccountScreen.js +4 -13
  150. package/lib/module/ui/screens/CreateAccountScreen.js.map +1 -1
  151. package/lib/module/ui/screens/trust/TrustCenterScreen.js +6 -5
  152. package/lib/module/ui/screens/trust/TrustCenterScreen.js.map +1 -1
  153. package/lib/module/ui/screens/trust/TrustLeaderboardScreen.js +5 -5
  154. package/lib/module/ui/screens/trust/TrustLeaderboardScreen.js.map +1 -1
  155. package/lib/module/ui/screens/trust/TrustRewardsScreen.js +1 -1
  156. package/lib/module/ui/screens/trust/TrustRulesScreen.js +4 -2
  157. package/lib/module/ui/screens/trust/TrustRulesScreen.js.map +1 -1
  158. package/lib/module/ui/server.js +0 -1
  159. package/lib/module/ui/server.js.map +1 -1
  160. package/lib/module/ui/session/authStore.js +46 -11
  161. package/lib/module/ui/session/authStore.js.map +1 -1
  162. package/lib/module/ui/session/sharedDeviceCredentialStore.js +302 -0
  163. package/lib/module/ui/session/sharedDeviceCredentialStore.js.map +1 -0
  164. package/lib/module/ui/stores/authStore.js +154 -55
  165. package/lib/module/ui/stores/authStore.js.map +1 -1
  166. package/lib/module/ui/stores/followTargetStore.js +25 -0
  167. package/lib/module/ui/stores/followTargetStore.js.map +1 -1
  168. package/lib/module/ui/utils/avatarUtils.js +2 -35
  169. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  170. package/lib/typescript/commonjs/index.d.ts +6 -4
  171. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  172. package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/ui/client.d.ts +1 -2
  174. package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
  176. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  178. package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts +11 -4
  180. package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts +3 -1
  182. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  183. package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts +18 -6
  184. package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts.map +1 -1
  185. package/lib/typescript/commonjs/ui/components/authChooser/signInProgress.d.ts.map +1 -1
  186. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts +33 -1
  187. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +35 -4
  189. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  190. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +8 -12
  191. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/ui/context/oxyContextHelpers.d.ts +0 -2
  193. package/lib/typescript/commonjs/ui/context/oxyContextHelpers.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +9 -1
  195. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  196. package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts +1 -3
  197. package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts.map +1 -1
  198. package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts +15 -0
  199. package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts.map +1 -0
  200. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  201. package/lib/typescript/commonjs/ui/hooks/useDeviceSwitcher.d.ts +49 -0
  202. package/lib/typescript/commonjs/ui/hooks/useDeviceSwitcher.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/ui/hooks/useI18n.d.ts +13 -0
  204. package/lib/typescript/commonjs/ui/hooks/useI18n.d.ts.map +1 -1
  205. package/lib/typescript/commonjs/ui/hooks/useSessionManagement.d.ts +23 -18
  206. package/lib/typescript/commonjs/ui/hooks/useSessionManagement.d.ts.map +1 -1
  207. package/lib/typescript/commonjs/ui/index.d.ts +1 -2
  208. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  209. package/lib/typescript/commonjs/ui/navigation/routes.d.ts +15 -1
  210. package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
  211. package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts.map +1 -1
  212. package/lib/typescript/commonjs/ui/runtime/createOxyRuntime.d.ts +144 -0
  213. package/lib/typescript/commonjs/ui/runtime/createOxyRuntime.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/ui/runtime/index.d.ts +16 -0
  215. package/lib/typescript/commonjs/ui/runtime/index.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/ui/runtime/runtimeContext.d.ts +43 -0
  217. package/lib/typescript/commonjs/ui/runtime/runtimeContext.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/ui/runtime/types.d.ts +89 -0
  219. package/lib/typescript/commonjs/ui/runtime/types.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/ui/runtime/useRuntimeSnapshot.d.ts +23 -0
  221. package/lib/typescript/commonjs/ui/runtime/useRuntimeSnapshot.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/ui/screens/AccountMembersScreen.d.ts.map +1 -1
  223. package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts.map +1 -1
  224. package/lib/typescript/commonjs/ui/screens/trust/TrustLeaderboardScreen.d.ts.map +1 -1
  225. package/lib/typescript/commonjs/ui/screens/trust/TrustRulesScreen.d.ts.map +1 -1
  226. package/lib/typescript/commonjs/ui/server.d.ts +0 -1
  227. package/lib/typescript/commonjs/ui/server.d.ts.map +1 -1
  228. package/lib/typescript/commonjs/ui/session/authStore.d.ts +60 -9
  229. package/lib/typescript/commonjs/ui/session/authStore.d.ts.map +1 -1
  230. package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts +32 -0
  231. package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -0
  232. package/lib/typescript/commonjs/ui/stores/authStore.d.ts +49 -5
  233. package/lib/typescript/commonjs/ui/stores/authStore.d.ts.map +1 -1
  234. package/lib/typescript/commonjs/ui/stores/followTargetStore.d.ts +8 -1
  235. package/lib/typescript/commonjs/ui/stores/followTargetStore.d.ts.map +1 -1
  236. package/lib/typescript/commonjs/ui/types/navigation.d.ts +26 -0
  237. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  238. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts +2 -10
  239. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
  240. package/lib/typescript/module/index.d.ts +6 -4
  241. package/lib/typescript/module/index.d.ts.map +1 -1
  242. package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  243. package/lib/typescript/module/ui/client.d.ts +1 -2
  244. package/lib/typescript/module/ui/client.d.ts.map +1 -1
  245. package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
  246. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
  247. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  248. package/lib/typescript/module/ui/components/SurfaceScreen.d.ts.map +1 -1
  249. package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts +11 -4
  250. package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  251. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts +3 -1
  252. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  253. package/lib/typescript/module/ui/components/authChooser/primitives.d.ts +18 -6
  254. package/lib/typescript/module/ui/components/authChooser/primitives.d.ts.map +1 -1
  255. package/lib/typescript/module/ui/components/authChooser/signInProgress.d.ts.map +1 -1
  256. package/lib/typescript/module/ui/components/authChooser/types.d.ts +33 -1
  257. package/lib/typescript/module/ui/components/authChooser/types.d.ts.map +1 -1
  258. package/lib/typescript/module/ui/context/OxyContext.d.ts +35 -4
  259. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  260. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +8 -12
  261. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  262. package/lib/typescript/module/ui/context/oxyContextHelpers.d.ts +0 -2
  263. package/lib/typescript/module/ui/context/oxyContextHelpers.d.ts.map +1 -1
  264. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +9 -1
  265. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  266. package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts +1 -3
  267. package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts.map +1 -1
  268. package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts +15 -0
  269. package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts.map +1 -0
  270. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  271. package/lib/typescript/module/ui/hooks/useDeviceSwitcher.d.ts +49 -0
  272. package/lib/typescript/module/ui/hooks/useDeviceSwitcher.d.ts.map +1 -0
  273. package/lib/typescript/module/ui/hooks/useI18n.d.ts +13 -0
  274. package/lib/typescript/module/ui/hooks/useI18n.d.ts.map +1 -1
  275. package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts +23 -18
  276. package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts.map +1 -1
  277. package/lib/typescript/module/ui/index.d.ts +1 -2
  278. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  279. package/lib/typescript/module/ui/navigation/routes.d.ts +15 -1
  280. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  281. package/lib/typescript/module/ui/navigation/surfaces.d.ts.map +1 -1
  282. package/lib/typescript/module/ui/runtime/createOxyRuntime.d.ts +144 -0
  283. package/lib/typescript/module/ui/runtime/createOxyRuntime.d.ts.map +1 -0
  284. package/lib/typescript/module/ui/runtime/index.d.ts +16 -0
  285. package/lib/typescript/module/ui/runtime/index.d.ts.map +1 -0
  286. package/lib/typescript/module/ui/runtime/runtimeContext.d.ts +43 -0
  287. package/lib/typescript/module/ui/runtime/runtimeContext.d.ts.map +1 -0
  288. package/lib/typescript/module/ui/runtime/types.d.ts +89 -0
  289. package/lib/typescript/module/ui/runtime/types.d.ts.map +1 -0
  290. package/lib/typescript/module/ui/runtime/useRuntimeSnapshot.d.ts +23 -0
  291. package/lib/typescript/module/ui/runtime/useRuntimeSnapshot.d.ts.map +1 -0
  292. package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts.map +1 -1
  293. package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts.map +1 -1
  294. package/lib/typescript/module/ui/screens/trust/TrustLeaderboardScreen.d.ts.map +1 -1
  295. package/lib/typescript/module/ui/screens/trust/TrustRulesScreen.d.ts.map +1 -1
  296. package/lib/typescript/module/ui/server.d.ts +0 -1
  297. package/lib/typescript/module/ui/server.d.ts.map +1 -1
  298. package/lib/typescript/module/ui/session/authStore.d.ts +60 -9
  299. package/lib/typescript/module/ui/session/authStore.d.ts.map +1 -1
  300. package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts +32 -0
  301. package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -0
  302. package/lib/typescript/module/ui/stores/authStore.d.ts +49 -5
  303. package/lib/typescript/module/ui/stores/authStore.d.ts.map +1 -1
  304. package/lib/typescript/module/ui/stores/followTargetStore.d.ts +8 -1
  305. package/lib/typescript/module/ui/stores/followTargetStore.d.ts.map +1 -1
  306. package/lib/typescript/module/ui/types/navigation.d.ts +26 -0
  307. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  308. package/lib/typescript/module/ui/utils/avatarUtils.d.ts +2 -10
  309. package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
  310. package/package.json +8 -8
  311. package/plugins/withSharedDeviceSessionProvider.js +102 -0
  312. package/plugins/withSharedDeviceSessionReader.js +57 -0
  313. package/src/__tests__/esmSourcePurity.test.ts +61 -0
  314. package/src/index.ts +36 -9
  315. package/src/ui/boot/runProviderColdBoot.ts +7 -0
  316. package/src/ui/client.ts +1 -2
  317. package/src/ui/components/OxyAccountDialogScreen.tsx +10 -29
  318. package/src/ui/components/OxyAuthChooser.tsx +149 -50
  319. package/src/ui/components/OxyProvider.tsx +7 -5
  320. package/src/ui/components/SurfaceScreen.tsx +28 -4
  321. package/src/ui/components/__tests__/followTargetButton.test.ts +39 -0
  322. package/src/ui/components/authChooser/AccountsMenuView.tsx +246 -96
  323. package/src/ui/components/authChooser/SignInEntryView.tsx +31 -8
  324. package/src/ui/components/authChooser/primitives.tsx +37 -23
  325. package/src/ui/components/authChooser/signInProgress.ts +4 -0
  326. package/src/ui/components/authChooser/types.ts +34 -1
  327. package/src/ui/context/OxyContext.tsx +269 -324
  328. package/src/ui/context/hooks/useAuthOperations.ts +32 -35
  329. package/src/ui/context/oxyContextHelpers.ts +0 -30
  330. package/src/ui/context/oxyContextTypes.ts +9 -1
  331. package/src/ui/context/useOxyAccountGraph.ts +5 -19
  332. package/src/ui/hooks/accountDialogSnapshot.ts +37 -0
  333. package/src/ui/hooks/mutations/useAccountMutations.ts +0 -19
  334. package/src/ui/hooks/queries/__tests__/userCache.test.ts +12 -1
  335. package/src/ui/hooks/useDeviceSwitcher.ts +110 -0
  336. package/src/ui/hooks/useI18n.ts +23 -3
  337. package/src/ui/hooks/useSessionManagement.ts +62 -211
  338. package/src/ui/index.ts +1 -2
  339. package/src/ui/navigation/routes.ts +85 -75
  340. package/src/ui/navigation/surfaces.ts +6 -9
  341. package/src/ui/runtime/createOxyRuntime.ts +623 -0
  342. package/src/ui/runtime/index.ts +34 -0
  343. package/src/ui/runtime/runtimeContext.tsx +111 -0
  344. package/src/ui/runtime/types.ts +110 -0
  345. package/src/ui/runtime/useRuntimeSnapshot.ts +52 -0
  346. package/src/ui/screens/AccountMembersScreen.tsx +6 -5
  347. package/src/ui/screens/CreateAccountScreen.tsx +3 -16
  348. package/src/ui/screens/trust/TrustCenterScreen.tsx +7 -7
  349. package/src/ui/screens/trust/TrustLeaderboardScreen.tsx +4 -5
  350. package/src/ui/screens/trust/TrustRewardsScreen.tsx +1 -1
  351. package/src/ui/screens/trust/TrustRulesScreen.tsx +3 -2
  352. package/src/ui/server.ts +0 -1
  353. package/src/ui/session/__tests__/authStore.test.ts +90 -0
  354. package/src/ui/session/__tests__/sharedDeviceCredentialStore.test.ts +289 -0
  355. package/src/ui/session/authStore.ts +78 -9
  356. package/src/ui/session/sharedDeviceCredentialStore.ts +318 -0
  357. package/src/ui/stores/authStore.ts +171 -43
  358. package/src/ui/stores/followTargetStore.ts +24 -1
  359. package/src/ui/types/navigation.ts +26 -0
  360. package/src/ui/utils/avatarUtils.ts +2 -37
  361. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js +0 -64
  362. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js.map +0 -1
  363. package/lib/commonjs/ui/screens/trust/trustTier.js +0 -23
  364. package/lib/commonjs/ui/screens/trust/trustTier.js.map +0 -1
  365. package/lib/commonjs/ui/stores/accountStore.js +0 -221
  366. package/lib/commonjs/ui/stores/accountStore.js.map +0 -1
  367. package/lib/module/ui/hooks/useSwitchableAccounts.js +0 -60
  368. package/lib/module/ui/hooks/useSwitchableAccounts.js.map +0 -1
  369. package/lib/module/ui/screens/trust/trustTier.js +0 -19
  370. package/lib/module/ui/screens/trust/trustTier.js.map +0 -1
  371. package/lib/module/ui/stores/accountStore.js +0 -213
  372. package/lib/module/ui/stores/accountStore.js.map +0 -1
  373. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts +0 -23
  374. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts.map +0 -1
  375. package/lib/typescript/commonjs/ui/screens/trust/trustTier.d.ts +0 -9
  376. package/lib/typescript/commonjs/ui/screens/trust/trustTier.d.ts.map +0 -1
  377. package/lib/typescript/commonjs/ui/stores/accountStore.d.ts +0 -27
  378. package/lib/typescript/commonjs/ui/stores/accountStore.d.ts.map +0 -1
  379. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts +0 -23
  380. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts.map +0 -1
  381. package/lib/typescript/module/ui/screens/trust/trustTier.d.ts +0 -9
  382. package/lib/typescript/module/ui/screens/trust/trustTier.d.ts.map +0 -1
  383. package/lib/typescript/module/ui/stores/accountStore.d.ts +0 -27
  384. package/lib/typescript/module/ui/stores/accountStore.d.ts.map +0 -1
  385. package/src/ui/hooks/useSwitchableAccounts.ts +0 -75
  386. package/src/ui/screens/trust/trustTier.ts +0 -20
  387. package/src/ui/stores/accountStore.ts +0 -264
@@ -0,0 +1,144 @@
1
+ import type { DeviceDirectory, DeviceSessionState } from '@oxyhq/contracts';
2
+ import type { ClientSession, User } from '@oxyhq/core';
3
+ import type { IdentitySessionBinding } from '../session/identityBinding.js';
4
+ import type { OxyRuntimeSnapshot } from './types.js';
5
+ /**
6
+ * A change of SUBJECT — the account the session acts as.
7
+ *
8
+ * `previous === null` is an initial sign-in (nothing account-scoped is cached
9
+ * yet); `next === null` is a sign-out; both non-null and different is a switch,
10
+ * the only case that must invalidate a warm cache.
11
+ */
12
+ export interface SubjectTransition {
13
+ previous: string | null;
14
+ next: string | null;
15
+ }
16
+ /**
17
+ * The three seams the runtime reads, declared STRUCTURALLY rather than as the
18
+ * concrete `OxyServices` / `SessionClient` / `SessionClientHost` types.
19
+ *
20
+ * The real classes satisfy them, so nothing changes at the call site — but a
21
+ * test can hand the runtime three plain objects instead of casting a stub
22
+ * through `unknown`, which is how a stub silently drifts from the interface it
23
+ * pretends to implement.
24
+ */
25
+ export interface RuntimeClient {
26
+ getAccessToken(): string | null;
27
+ getUsersByIds(ids: string[]): Promise<User[]>;
28
+ }
29
+ export interface RuntimeSessionClient {
30
+ getState(): DeviceSessionState | null;
31
+ getDirectory(): DeviceDirectory | null;
32
+ subscribe(listener: (state: DeviceSessionState | null) => void): () => void;
33
+ refreshDirectory(): Promise<void>;
34
+ activateContext(contextId: string): Promise<void>;
35
+ signOutContext(contextId: string): Promise<void>;
36
+ signOutPrincipal(principalId: string): Promise<void>;
37
+ }
38
+ export interface RuntimeSessionHost {
39
+ setCurrentAccountId(accountId: string | null): void;
40
+ }
41
+ export interface OxyRuntimeConfig {
42
+ oxyServices: RuntimeClient;
43
+ sessionClient: RuntimeSessionClient;
44
+ sessionClientHost: RuntimeSessionHost;
45
+ /** `null` for every account-mode runtime; the pin binding in identity mode. */
46
+ identity: IdentitySessionBinding | null;
47
+ /**
48
+ * Reset account-scoped caches. Called BETWEEN the bearer commit and the
49
+ * snapshot publish, which is the whole point of routing every fact change
50
+ * through one transition (ADR 0002's ordering invariant): a consumer woken by
51
+ * a switch must never read a cache entry belonging to the previous subject.
52
+ */
53
+ onSubjectChange?: (transition: SubjectTransition) => void;
54
+ /**
55
+ * The device reports zero accounts. Local UI teardown only — the durable
56
+ * device credential is the caller's decision, gated on a `request`-origin
57
+ * verdict.
58
+ */
59
+ onDeviceEmpty: () => Promise<void>;
60
+ /** Persist the projected session-id list (display/bookkeeping storage). */
61
+ onSessionsProjected?: (sessionIds: string[]) => void;
62
+ /**
63
+ * Identity mode only: the pinned account is unknown or has left this device's
64
+ * session set, so the session must be re-derived from the local identity key.
65
+ * Projecting anything here would mean projecting somebody else's account.
66
+ */
67
+ onIdentityUnbound?: (binding: IdentitySessionBinding, revision: number) => void;
68
+ logger: (message: string, error?: unknown) => void;
69
+ }
70
+ /**
71
+ * The headless session runtime (ADR 0004).
72
+ *
73
+ * It owns the session facts and the ORDER in which they become visible. React
74
+ * is an adapter: the provider hands components this object and they subscribe
75
+ * with selectors, so an unrelated change (a locale, a dialog opening) cannot
76
+ * rebuild an auth consumer's view.
77
+ */
78
+ export interface OxyRuntime {
79
+ getSnapshot(): OxyRuntimeSnapshot;
80
+ subscribe(listener: () => void): () => void;
81
+ /** Begin projecting `SessionClient` transitions. Returns the disposer. */
82
+ start(): () => void;
83
+ /**
84
+ * Project the client's current device state onto the snapshot. Idempotent and
85
+ * revision-guarded: a projection whose profile fetch was overtaken by a
86
+ * fresher state discards itself rather than publishing a stale subject.
87
+ */
88
+ reconcileFromClient(): Promise<void>;
89
+ /** Read the device directory and publish it (opts this runtime into ADR 0002). */
90
+ refreshDirectory(): Promise<void>;
91
+ /**
92
+ * Make one `principal acting as account` context active (ADR 0002).
93
+ *
94
+ * `contextId`, never an account id: on a device holding two people the same
95
+ * organization is reachable through both, and an account id cannot name which
96
+ * route to take.
97
+ */
98
+ activateContext(contextId: string): Promise<void>;
99
+ /**
100
+ * Remove ONE `principal → account` pair. The same account reached through a
101
+ * second person is a different session with a different audit actor, and it
102
+ * stays.
103
+ *
104
+ * Context ids are NOT stable across a removal: the server offers the pair
105
+ * again under a NEW id on the next directory read, so nothing may cache one
106
+ * across this call.
107
+ */
108
+ signOutContext(contextId: string): Promise<void>;
109
+ /** Remove ONE PERSON and every context they reach, and nobody else's. */
110
+ signOutPrincipal(principalId: string): Promise<void>;
111
+ /**
112
+ * Run several fact changes as ONE transition.
113
+ *
114
+ * A session commit sets the optimistic session mirror, the active session id
115
+ * and the account. Left as three transitions those are three publishes, and
116
+ * — worse — the account is compared against a different baseline each time,
117
+ * so an account-scoped cache reset could run against a half-applied session.
118
+ * Batched, subscribers are woken once, after all of it, with the reset having
119
+ * run exactly once in between.
120
+ */
121
+ batch(mutate: () => void): void;
122
+ setAccount(user: User): void;
123
+ setLoading(loading: boolean): void;
124
+ setError(error: string | null): void;
125
+ setStorageReady(ready: boolean): void;
126
+ setTokenReady(ready: boolean): void;
127
+ setHasAccessToken(has: boolean): void;
128
+ setSwitching(switching: boolean): void;
129
+ markAuthResolved(): void;
130
+ /**
131
+ * Merge an optimistic local session mirror so the UI moves before the server
132
+ * round-trip. The authoritative projection overwrites it a moment later; both
133
+ * write the SAME field, so there is still exactly one owner.
134
+ */
135
+ mergeSessions(incoming: ClientSession[], options?: {
136
+ merge?: boolean;
137
+ preserveSessionIds?: string[];
138
+ }): void;
139
+ setActiveSessionId(sessionId: string | null): void;
140
+ /** Local teardown: drop the session projection without touching the server. */
141
+ clearSession(): void;
142
+ }
143
+ export declare function createOxyRuntime(config: OxyRuntimeConfig): OxyRuntime;
144
+ //# sourceMappingURL=createOxyRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOxyRuntime.d.ts","sourceRoot":"","sources":["../../../../../src/ui/runtime/createOxyRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAiB,IAAI,EAAE,MAAM,aAAa,CAAC;AAYtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAoC,MAAM,YAAS,CAAC;AAEpF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,cAAc,IAAI,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,IAAI,kBAAkB,GAAG,IAAI,CAAC;IACtC,YAAY,IAAI,eAAe,GAAG,IAAI,CAAC;IACvC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,KAAK,IA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D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAyYrE"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The headless session runtime (ADR 0004).
3
+ *
4
+ * `createOxyRuntime` owns the session facts and the order in which they become
5
+ * visible; `useRuntimeSnapshot` / `useRuntimeSelector` are the React adapter
6
+ * over it. Nothing here imports React except the adapter, and nothing in the
7
+ * runtime reads React state — which is what lets the provider hold ONE stable
8
+ * reference and stop rebuilding a 58-field context value on every keystroke.
9
+ */
10
+ export { createOxyRuntime } from './createOxyRuntime.js';
11
+ export type { OxyRuntime, OxyRuntimeConfig, RuntimeClient, RuntimeSessionClient, RuntimeSessionHost, SubjectTransition, } from './createOxyRuntime.js';
12
+ export { useRuntimeSnapshot, useRuntimeSelector } from './useRuntimeSnapshot.js';
13
+ export { OxyRuntimeHandleProvider, OxyRuntimeMissingError, useActiveAccount, useDeviceDirectory, useOxyRuntime, useOxySnapshot, } from './runtimeContext.js';
14
+ export type { ActiveAccount } from './runtimeContext.js';
15
+ export type { OxyRuntimeError, OxyRuntimeSnapshot, OxyRuntimeStatus, OxyTokenStatus, } from './types.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AACtD,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,uBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC9E,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,GACf,MAAM,qBAAkB,CAAC;AAC1B,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAkB,CAAC;AACtD,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAS,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { DeviceDirectory } from '@oxyhq/contracts';
2
+ import type { DeviceContext, User } from '@oxyhq/core';
3
+ import type { OxyRuntime } from './createOxyRuntime.js';
4
+ import type { OxyRuntimeStatus } from './types.js';
5
+ export declare const OxyRuntimeHandleProvider: import("react").Provider<OxyRuntime | null>;
6
+ export declare class OxyRuntimeMissingError extends Error {
7
+ readonly code = "oxy_runtime_missing";
8
+ constructor();
9
+ }
10
+ /** The runtime this provider owns. THROWS when no `<OxyProvider>` is mounted. */
11
+ export declare function useOxyRuntime(): OxyRuntime;
12
+ export interface ActiveAccount {
13
+ /**
14
+ * The human whose authentication backs the session — the audit actor. Equal
15
+ * to {@link ActiveAccount.account} unless a delegated context is active.
16
+ */
17
+ principal: User | null;
18
+ /** The account the session acts AS — what a profile header renders. */
19
+ account: User | null;
20
+ /** The resolved `principal acting as account` pair, when a directory is held. */
21
+ context: DeviceContext | null;
22
+ /** Whether the actor and the subject are different accounts. */
23
+ isDelegated: boolean;
24
+ status: OxyRuntimeStatus;
25
+ }
26
+ /**
27
+ * Who this app is running as, with the actor and the subject kept apart.
28
+ *
29
+ * Unlike `useOxy()`, this re-renders only when one of those five facts moves —
30
+ * a locale change, a dialog opening or a session-list refresh does not reach it.
31
+ */
32
+ export declare function useActiveAccount(): ActiveAccount;
33
+ /**
34
+ * The device directory — every principal on this device and the contexts each
35
+ * may act as (ADR 0002).
36
+ *
37
+ * `null` until something calls `runtime.refreshDirectory()`. A client that
38
+ * never asks for one never pays for the round trip.
39
+ */
40
+ export declare function useDeviceDirectory(): DeviceDirectory | null;
41
+ /** The whole runtime snapshot. Prefer a narrower hook where one exists. */
42
+ export declare function useOxySnapshot(): ReturnType<OxyRuntime['getSnapshot']>;
43
+ //# sourceMappingURL=runtimeContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/runtime/runtimeContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAS,CAAC;AAgBhD,eAAO,MAAM,wBAAwB,6CAAmC,CAAC;AAKzE,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,IAAI,yBAAyB;;CAMvC;AAED,iFAAiF;AACjF,wBAAgB,aAAa,IAAI,UAAU,CAM1C;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,uEAAuE;IACvE,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,iFAAiF;IACjF,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,gEAAgE;IAChE,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AA2BD;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAKD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,GAAG,IAAI,CAE3D;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,IAAI,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAEtE"}
@@ -0,0 +1,89 @@
1
+ import type { DeviceDirectory, DeviceSessionState } from '@oxyhq/contracts';
2
+ import type { ClientSession, DeviceContext, User } from '@oxyhq/core';
3
+ /**
4
+ * The runtime's coarse verdict about this device's session.
5
+ *
6
+ * `'booting'` is NOT "signed out but we are still looking": it is the honest
7
+ * "undetermined" that every readiness gate in the SDK exists to express, and it
8
+ * ends exactly once at the first cold-boot resolution. `'error'` is reserved for
9
+ * a resolved boot that produced no account AND recorded a failure — a failed
10
+ * sign-in against a signed-out device is `'signed_out'` with an `error`, because
11
+ * the device really is signed out.
12
+ */
13
+ export type OxyRuntimeStatus = 'booting' | 'authenticated' | 'signed_out' | 'error';
14
+ /**
15
+ * Whether a bearer usable for private calls is planted right now.
16
+ *
17
+ * `'refreshing'` covers both halves of the gap the SDK already tracked with two
18
+ * separate booleans: a bearer that is present but whose readiness gate is shut
19
+ * (a commit in flight), and an authenticated account whose bearer has been
20
+ * invalidated and is being re-minted. Both mean the same thing to a caller —
21
+ * wait, do not treat this as signed out.
22
+ */
23
+ export type OxyTokenStatus = 'missing' | 'refreshing' | 'ready' | 'error';
24
+ export interface OxyRuntimeError {
25
+ message: string;
26
+ code: string;
27
+ }
28
+ /**
29
+ * The ONE observable state of an `OxyRuntime` (ADR 0004).
30
+ *
31
+ * Frozen and referentially stable: a new object is published only when
32
+ * something actually changed, so `useSyncExternalStore` can compare by identity
33
+ * and a selector over an unchanged field never re-renders.
34
+ *
35
+ * Every field is either a fact the runtime owns or a pure derivation of one.
36
+ * There is no second writable store: `sessions`, `activeSessionId`, `status`
37
+ * and `tokenStatus` are computed by the one snapshot builder, so two of them can
38
+ * never disagree about the same device.
39
+ */
40
+ export interface OxyRuntimeSnapshot {
41
+ status: OxyRuntimeStatus;
42
+ /**
43
+ * The device DIRECTORY (ADR 0002) — principals and the contexts each may act
44
+ * as. `null` until something asks for one; the flat lane never pays for it.
45
+ */
46
+ device: DeviceDirectory | null;
47
+ /**
48
+ * The flat, server-authoritative device state. Kept beside {@link device}
49
+ * because it is what the compatibility projections below are derived from,
50
+ * and because the two describe the same device at the same `revision`.
51
+ */
52
+ deviceState: DeviceSessionState | null;
53
+ /** The active `principal acting as account` pair, when a directory is held. */
54
+ activeContext: DeviceContext | null;
55
+ /**
56
+ * The human whose authentication backs the session — the audit actor.
57
+ *
58
+ * Equal to {@link account} on a device with no directory and on any
59
+ * non-delegated context: the flat lane cannot tell the two apart, and saying
60
+ * so by making them the same object is more honest than leaving this `null`.
61
+ */
62
+ principal: User | null;
63
+ /** The account the session acts AS — what a profile header renders. */
64
+ account: User | null;
65
+ tokenStatus: OxyTokenStatus;
66
+ /**
67
+ * Whether the first cold boot has concluded. Monotonic: once `true` it never
68
+ * reverts, so a later transient signed-out state is never mistaken for
69
+ * "still booting".
70
+ */
71
+ authResolved: boolean;
72
+ /** A context activation / account switch is in flight. */
73
+ switching: boolean;
74
+ error: OxyRuntimeError | null;
75
+ sessions: ClientSession[];
76
+ activeSessionId: string | null;
77
+ /** A sign-in / sign-out operation is in flight. */
78
+ isLoading: boolean;
79
+ /** The local display/bookkeeping storage has resolved. */
80
+ storageReady: boolean;
81
+ /** A bearer is planted on the client instance right now. */
82
+ hasAccessToken: boolean;
83
+ /**
84
+ * The commit gate. Shut while a session commit is mid-flight so a consumer
85
+ * cannot fire a private call between the token landing and the projection.
86
+ */
87
+ tokenReady: boolean;
88
+ }
89
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/ui/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,eAAe,GAAG,YAAY,GAAG,OAAO,CAAC;AAEpF;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,CAAC;IAEzB;;;OAGG;IACH,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAE/B;;;;OAIG;IACH,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEvC,+EAA+E;IAC/E,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IACH,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAEvB,uEAAuE;IACvE,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IAErB,WAAW,EAAE,cAAc,CAAC;IAE5B;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB,0DAA0D;IAC1D,SAAS,EAAE,OAAO,CAAC;IAEnB,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAM9B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IAEnB,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAC;IAEtB,4DAA4D;IAC5D,cAAc,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,23 @@
1
+ import type { OxyRuntime } from './createOxyRuntime.js';
2
+ import type { OxyRuntimeSnapshot } from './types.js';
3
+ /**
4
+ * Subscribe to the whole runtime snapshot.
5
+ *
6
+ * The runtime publishes a frozen object only when a fact actually changed, so
7
+ * identity comparison is exact: a locale change, a dialog opening or an
8
+ * unrelated query settling does not wake anything subscribed here.
9
+ */
10
+ export declare function useRuntimeSnapshot(runtime: OxyRuntime): OxyRuntimeSnapshot;
11
+ /**
12
+ * Subscribe to one derived value of the runtime snapshot.
13
+ *
14
+ * The selection is cached against the snapshot it was computed from, which is
15
+ * what makes a selector returning a fresh object (`{user, isAuthenticated}`)
16
+ * safe here: `useSyncExternalStore` calls `getSnapshot` several times per
17
+ * commit and would otherwise see a new object every call and loop.
18
+ *
19
+ * `selector` must be stable — hoist it to module scope or wrap it in
20
+ * `useCallback`. An inline arrow re-subscribes on every render.
21
+ */
22
+ export declare function useRuntimeSelector<T>(runtime: OxyRuntime, selector: (snapshot: OxyRuntimeSnapshot) => T, isEqual?: (a: T, b: T) => boolean): T;
23
+ //# sourceMappingURL=useRuntimeSnapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRuntimeSnapshot.d.ts","sourceRoot":"","sources":["../../../../../src/ui/runtime/useRuntimeSnapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAS,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,CAE1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,CAAC,EAC7C,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,GAChC,CAAC,CAqBH"}
@@ -1 +1 @@
1
- {"version":3,"file":"AccountMembersScreen.d.ts","sourceRoot":"","sources":["../../../../../src/ui/screens/AccountMembersScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAqB,CAAC;AAkB3D;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAgbnD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"AccountMembersScreen.d.ts","sourceRoot":"","sources":["../../../../../src/ui/screens/AccountMembersScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAqB,CAAC;AAkB3D;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAibnD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CreateAccountScreen.d.ts","sourceRoot":"","sources":["../../../../../src/ui/screens/CreateAccountScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAqB,CAAC;AAmG3D;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAkVlD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"CreateAccountScreen.d.ts","sourceRoot":"","sources":["../../../../../src/ui/screens/CreateAccountScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAqB,CAAC;AAsF3D;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAkVlD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TrustLeaderboardScreen.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/trust/TrustLeaderboardScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAAwB,CAAC;AAa9D,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAuJrD,CAAC;AA0CF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"TrustLeaderboardScreen.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/trust/TrustLeaderboardScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAAwB,CAAC;AAY9D,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAuJrD,CAAC;AA0CF,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TrustRulesScreen.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/trust/TrustRulesScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAAwB,CAAC;AAiB9D,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqF/C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"TrustRulesScreen.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/trust/TrustRulesScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAAwB,CAAC;AAiB9D,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqF/C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -22,7 +22,6 @@ export declare const useStorage: () => {
22
22
  };
23
23
  export declare const ProfileScreen: () => null;
24
24
  export declare const useAuthStore: () => {};
25
- export declare const useAccountStore: () => {};
26
25
  export declare const toast: (() => void) & {
27
26
  success: () => void;
28
27
  error: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/ui/server.ts"],"names":[],"mappings":"AAAA;;;;;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AW,CAAC;AAGrC,eAAO,MAAM,KAAK;;;;;;;CAUjB,CAAC;AAGF,OAAO,EACH,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACtB,MAAM,0BAAuB,CAAC;AAC/B,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAAuB,CAAC"}
@@ -1,25 +1,76 @@
1
1
  /**
2
2
  * Platform `AuthStateStore` for `@oxyhq/services`.
3
3
  *
4
- * The zero-cookie device model persists the durable device credential
5
- * (`deviceId` + `deviceSecret`) per origin (web) / per device (native), and the
6
- * SDK re-mints the access token from that credential on cold boot. `@oxyhq/core`
7
- * owns the store shape + logic (`createWebAuthStateStore` /
8
- * `createNativeAuthStateStore`); this module only selects the platform storage
9
- * seam:
4
+ * The device model persists the durable device credential (`deviceId` +
5
+ * `deviceSecret`) per origin (web) / per device (native), and the SDK re-mints
6
+ * the access token from that credential on cold boot. `@oxyhq/core` owns the
7
+ * store shape + logic (`createWebAuthStateStore` / `createNativeAuthStateStore` /
8
+ * `createMemoryAuthStateStore`); this module only selects the seam:
10
9
  *
10
+ * - `storage: 'ephemeral'` → `createMemoryAuthStateStore()`, on EVERY platform.
11
11
  * - web → `createWebAuthStateStore()` (localStorage, in-memory fallback).
12
12
  * - native → `createNativeAuthStateStore(secureKV)` for the SESSION blob over
13
13
  * the shared `createNativeSecureKeyValueStorage()` adapter
14
- * (`expo-secure-store`, AsyncStorage fallback).
14
+ * (`expo-secure-store`, AsyncStorage fallback), WRAPPED so every credential
15
+ * it persists is also mirrored into the device-wide shared slot.
16
+ *
17
+ * The native wrapper is how several official apps end up on ONE `DeviceSession`
18
+ * (and therefore one active context): whichever app proves a credential publishes
19
+ * it, and a later-installed sibling adopts it during cold boot instead of asking
20
+ * for the Commons identity key. The mirror is additive — it can neither change
21
+ * nor fail the app's own durable write.
15
22
  */
16
- import { type AuthStateStore } from '@oxyhq/core';
23
+ import { type AuthStateStore, type SessionMode } from '@oxyhq/core';
24
+ export interface PlatformAuthStateStoreOptions {
25
+ /**
26
+ * Who owns the session this provider resolves. Only `'account'` mirrors into
27
+ * the device-wide shared slot.
28
+ *
29
+ * `'identity'` (the vault) is deliberately excluded, which keeps its storage
30
+ * behaviour byte-for-byte what it is today. The vault's credential is a
31
+ * perfectly valid device credential, so publishing it would arguably be
32
+ * correct — but it would also let every ordinary app on the device join the
33
+ * vault's device session as a side effect of the vault persisting a token, and
34
+ * "a background write changes which session five other apps boot into" is not
35
+ * a decision a storage seam gets to make.
36
+ */
37
+ sessionMode?: SessionMode;
38
+ /**
39
+ * Whether this origin/app may persist a durable device credential AT ALL.
40
+ *
41
+ * `'ephemeral'` stores nothing durable and mirrors nothing: the session lives
42
+ * in memory for the lifetime of the page and is gone on reload. Its one caller
43
+ * is `auth.oxy.so` with the browser hub enabled (issue #937 Phase 5, ADR 0003),
44
+ * where the durable credential for the browser profile is the server-side
45
+ * DeviceSession behind the `__Host-oxy-device` handle.
46
+ *
47
+ * See `OxyProviderProps.deviceCredentialStorage` for why the answer to "let the
48
+ * hub be authoritative" is to stop persisting the other credential rather than
49
+ * to consult it second.
50
+ */
51
+ storage?: 'persistent' | 'ephemeral';
52
+ }
17
53
  /**
18
54
  * Build the platform {@link AuthStateStore} for this runtime.
19
55
  *
20
56
  * Native persists the SESSION blob (`deviceId` + `deviceSecret` + cached access
21
57
  * token) per-app in SecureStore; the SDK re-mints the access token from the
22
58
  * device credential on the next cold boot.
59
+ *
60
+ * ## The ephemeral check is FIRST, and the order is load-bearing
61
+ *
62
+ * It short-circuits above the `isReactNative()` branch so an ephemeral caller can
63
+ * never reach the native path — and therefore can never reach the shared-slot
64
+ * mirroring wrapper. Checked after that branch instead, an origin that has
65
+ * declined to persist a credential would publish one into the device-wide slot
66
+ * every sibling app adopts on cold boot: it would keep nothing itself while
67
+ * deciding which session five other apps boot into.
68
+ *
69
+ * That is unreachable today because the only ephemeral caller is a web origin, so
70
+ * `isReactNative()` is false there anyway. Unreachable today is exactly the kind
71
+ * of guarantee that stops holding when someone adds the second caller, so it is
72
+ * structural here rather than incidental, and
73
+ * `__tests__/session/authStoreEphemeral.test.ts` holds the ordering directly.
23
74
  */
24
- export declare function createPlatformAuthStateStore(): AuthStateStore;
75
+ export declare function createPlatformAuthStateStore(options?: PlatformAuthStateStoreOptions): AuthStateStore;
25
76
  //# sourceMappingURL=authStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/authStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAIrB;;;;;;GAMG;AACH,wBAAgB,4BAA4B,IAAI,cAAc,CAM7D"}
1
+ {"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/authStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAKrB,MAAM,WAAW,6BAA6B;IAC5C;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,6BAAkC,GAC1C,cAAc,CAiBhB"}
@@ -0,0 +1,32 @@
1
+ import { type SharedDeviceCredentialStore } from '@oxyhq/core';
2
+ /**
3
+ * The iOS Keychain Access Group every official Oxy app declares in its
4
+ * entitlements. Shared with the identity slots — the group is the app-group
5
+ * boundary, not the secret's identity.
6
+ */
7
+ export declare const IOS_KEYCHAIN_ACCESS_GROUP = "group.so.oxy.shared";
8
+ /**
9
+ * The iOS `keychainService` for the DEVICE SESSION credential. Deliberately
10
+ * distinct from every identity and recovery service; do not reuse one of those
11
+ * here, and do not drop it (an item written with no service shares the legacy
12
+ * identity slot's namespace inside the group).
13
+ */
14
+ export declare const IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = "oxy_device_session";
15
+ /** The single key holding the JSON-encoded `{deviceId, deviceSecret}` pair. */
16
+ export declare const SHARED_DEVICE_SESSION_STORAGE_KEY = "oxy_shared_device_session_v1";
17
+ /**
18
+ * The shared DeviceSession credential slot for this runtime, or `null` when
19
+ * there is none.
20
+ *
21
+ * The branch is on the PLATFORM, not on which module happens to load, because
22
+ * `expo-secure-store` loads perfectly well on Android — it would just quietly
23
+ * ignore `keychainAccessGroup` and read a package-private item, which looks
24
+ * exactly like an empty shared slot. This is the same iOS-vs-Android split
25
+ * `KeyManager` makes for the shared identity, for the same reason.
26
+ *
27
+ * Any other native platform gets the broker, which answers `unsupported` when
28
+ * the module is not linked — so the lane is simply off, which is the safe
29
+ * direction.
30
+ */
31
+ export declare function createPlatformSharedDeviceCredentialStore(): SharedDeviceCredentialStore | null;
32
+ //# sourceMappingURL=sharedDeviceCredentialStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedDeviceCredentialStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/sharedDeviceCredentialStore.ts"],"names":[],"mappings":"AAyCA,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,uBAAuB,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AA0OhF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yCAAyC,IAAI,2BAA2B,GAAG,IAAI,CAK9F"}
@@ -1,17 +1,61 @@
1
1
  import type { User } from '@oxyhq/core';
2
+ import type { OxyRuntime } from '../runtime/index.js';
3
+ /**
4
+ * The signed-in user, as a zustand-shaped read/write surface.
5
+ *
6
+ * It used to BE a zustand store, and that made it a second owner of the
7
+ * session: the provider wrote `user`/`isAuthenticated` here, `SessionClient`
8
+ * wrote the same facts into its device state, and nothing reconciled them —
9
+ * when they disagreed, which one was right was not answerable. It is now a
10
+ * projection of the ONE `OxyRuntime` (ADR 0004): reads come off the runtime
11
+ * snapshot and writes go into the runtime, so there is nothing left to drift.
12
+ *
13
+ * The zustand SHAPE is kept deliberately — `useAuthStore(selector)`,
14
+ * `.getState()`, `.setState()`, `.subscribe()` — because a dozen call sites
15
+ * across this package and the Commons app read the user out of band, from
16
+ * mutation success handlers and cache helpers that are not inside a render.
17
+ * Rewriting them is Phase 8's cut, not this one's.
18
+ *
19
+ * `fetchUser` and `lastUserFetch` are GONE rather than projected: they were a
20
+ * five-minute profile cache with zero readers anywhere in the monorepo, and the
21
+ * Query cache has owned that job since long before this change.
22
+ */
2
23
  export interface AuthState {
3
24
  user: User | null;
4
25
  isAuthenticated: boolean;
5
26
  isLoading: boolean;
6
27
  error: string | null;
7
- lastUserFetch: number | null;
8
28
  loginSuccess: (user: User) => void;
9
29
  loginFailure: (error: string) => void;
10
30
  logout: () => void;
11
- fetchUser: (oxyServices: {
12
- getCurrentUser: () => Promise<User>;
13
- }, forceRefresh?: boolean) => Promise<void>;
31
+ /** Replace the signed-in profile after a write (a rename, a new avatar). */
14
32
  setUser: (user: User) => void;
15
33
  }
16
- export declare const useAuthStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AuthState>>;
34
+ /** The subset of `AuthState` a caller may push back in through `setState`. */
35
+ export type AuthStatePatch = Partial<Pick<AuthState, 'user' | 'isLoading' | 'error'>>;
36
+ /**
37
+ * Point this surface at the provider's runtime. Called once by
38
+ * `OxyRuntimeProvider`; the returned function detaches it again on unmount.
39
+ *
40
+ * With nothing bound, reads answer signed-out and writes are dropped. That is
41
+ * the honest answer for the two places it happens — the SSR shim, and a unit
42
+ * test poking the store with no provider mounted — and it is why binding is an
43
+ * explicit call rather than a lazily-created default runtime, which is exactly
44
+ * the fabricated-forever-loading runtime ADR 0004 deleted.
45
+ */
46
+ export declare function bindAuthStoreToRuntime(runtime: OxyRuntime): () => void;
47
+ declare function useAuthStoreHook<T>(selector: (state: AuthState) => T): T;
48
+ /**
49
+ * Read the signed-in user. Zustand-shaped, projected from the runtime.
50
+ *
51
+ * A selector that builds an object must be wrapped in `useShallow` (as every
52
+ * call site here already does) — otherwise a structurally-equal result reads as
53
+ * a change on every publish.
54
+ */
55
+ export declare const useAuthStore: typeof useAuthStoreHook & {
56
+ getState: () => AuthState;
57
+ setState: (patch: AuthStatePatch) => void;
58
+ subscribe: (listener: () => void) => (() => void);
59
+ };
60
+ export {};
17
61
  //# sourceMappingURL=authStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/stores/authStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,CAAC,WAAW,EAAE;QAAE,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3G,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,YAAY,wEA0CtB,CAAC"}
1
+ {"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/stores/authStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4EAA4E;IAC5E,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAC/B;AAED,8EAA8E;AAC9E,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;AAuEtF;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,IAAI,CActE;AA6BD,iBAAS,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,CAejE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;oBAnDJ,SAAS;sBAEL,cAAc,KAAG,IAAI;0BAkBjB,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;CAmCpD,CAAC"}
@@ -21,7 +21,7 @@
21
21
  * three separate answers, and a UI that keeps only the last one cannot explain
22
22
  * why a follow the user can see in their list does nothing in this app.
23
23
  */
24
- import type { FollowApplicationMode, FollowStatus } from '@oxyhq/contracts';
24
+ import type { FollowApplicationMode, FollowRecord, FollowStatus } from '@oxyhq/contracts';
25
25
  /** The status of one target, or `undefined` when it has never been read. */
26
26
  type StatusMap = Record<string, FollowStatus | undefined>;
27
27
  interface FollowTargetState {
@@ -65,6 +65,13 @@ export declare function isFollowedGlobally(status: FollowStatus): boolean;
65
65
  * that as authoritative would leave disable/unfollow as no-ops forever.
66
66
  */
67
67
  export declare function isCompleteFollowStatus(status: FollowStatus): boolean;
68
+ /** Convert one list row into the status shape the follow-target store expects. */
69
+ export declare function followRecordToStatus(record: FollowRecord): FollowStatus;
70
+ /**
71
+ * Bulk-convert a follow list page into a status map keyed by target id — the
72
+ * input shape for `useFollowTargetStore.getState().seed(...)`.
73
+ */
74
+ export declare function followRecordsToStatusMap(records: FollowRecord[]): Record<string, FollowStatus>;
68
75
  /**
69
76
  * Apply a mode change to a cached status without a round trip.
70
77
  *
@@ -1 +1 @@
1
- {"version":3,"file":"followTargetStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/stores/followTargetStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE5E,4EAA4E;AAC5E,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC,CAAC;AAE1D,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAE3C,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5D;;;;OAIG;IACH,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAA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