@oxyhq/services 28.0.0 → 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 (324) hide show
  1. package/NOTICE +10 -9
  2. package/README.md +65 -2
  3. package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionModule.kt +178 -0
  4. package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionProvider.kt +99 -0
  5. package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionStore.kt +115 -0
  6. package/expo-module.config.json +1 -0
  7. package/lib/commonjs/index.js +60 -16
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/ui/boot/runProviderColdBoot.js +7 -0
  10. package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
  11. package/lib/commonjs/ui/client.js +12 -7
  12. package/lib/commonjs/ui/client.js.map +1 -1
  13. package/lib/commonjs/ui/components/OxyAccountDialogScreen.js +10 -27
  14. package/lib/commonjs/ui/components/OxyAccountDialogScreen.js.map +1 -1
  15. package/lib/commonjs/ui/components/OxyAuthChooser.js +132 -44
  16. package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
  17. package/lib/commonjs/ui/components/OxyProvider.js +4 -2
  18. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  19. package/lib/commonjs/ui/components/SurfaceScreen.js +31 -3
  20. package/lib/commonjs/ui/components/SurfaceScreen.js.map +1 -1
  21. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js +209 -84
  22. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  23. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js +25 -7
  24. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js.map +1 -1
  25. package/lib/commonjs/ui/components/authChooser/primitives.js +35 -22
  26. package/lib/commonjs/ui/components/authChooser/primitives.js.map +1 -1
  27. package/lib/commonjs/ui/components/authChooser/types.js +11 -0
  28. package/lib/commonjs/ui/components/authChooser/types.js.map +1 -1
  29. package/lib/commonjs/ui/context/OxyContext.js +257 -306
  30. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  31. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +27 -37
  32. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  33. package/lib/commonjs/ui/context/oxyContextHelpers.js +0 -29
  34. package/lib/commonjs/ui/context/oxyContextHelpers.js.map +1 -1
  35. package/lib/commonjs/ui/context/useOxyAccountGraph.js +6 -17
  36. package/lib/commonjs/ui/context/useOxyAccountGraph.js.map +1 -1
  37. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js +42 -0
  38. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js.map +1 -0
  39. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +0 -19
  40. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  41. package/lib/commonjs/ui/hooks/useDeviceSwitcher.js +57 -0
  42. package/lib/commonjs/ui/hooks/useDeviceSwitcher.js.map +1 -0
  43. package/lib/commonjs/ui/hooks/useI18n.js +22 -3
  44. package/lib/commonjs/ui/hooks/useI18n.js.map +1 -1
  45. package/lib/commonjs/ui/hooks/useSessionManagement.js +46 -153
  46. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  47. package/lib/commonjs/ui/index.js +12 -7
  48. package/lib/commonjs/ui/index.js.map +1 -1
  49. package/lib/commonjs/ui/navigation/routes.js +85 -73
  50. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  51. package/lib/commonjs/ui/navigation/surfaces.js +8 -7
  52. package/lib/commonjs/ui/navigation/surfaces.js.map +1 -1
  53. package/lib/commonjs/ui/runtime/createOxyRuntime.js +433 -0
  54. package/lib/commonjs/ui/runtime/createOxyRuntime.js.map +1 -0
  55. package/lib/commonjs/ui/runtime/index.js +63 -0
  56. package/lib/commonjs/ui/runtime/index.js.map +1 -0
  57. package/lib/commonjs/ui/runtime/runtimeContext.js +83 -0
  58. package/lib/commonjs/ui/runtime/runtimeContext.js.map +1 -0
  59. package/lib/commonjs/ui/runtime/types.js +6 -0
  60. package/lib/commonjs/ui/runtime/types.js.map +1 -0
  61. package/lib/commonjs/ui/runtime/useRuntimeSnapshot.js +57 -0
  62. package/lib/commonjs/ui/runtime/useRuntimeSnapshot.js.map +1 -0
  63. package/lib/commonjs/ui/server.js +1 -2
  64. package/lib/commonjs/ui/server.js.map +1 -1
  65. package/lib/commonjs/ui/session/authStore.js +45 -9
  66. package/lib/commonjs/ui/session/authStore.js.map +1 -1
  67. package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js +306 -0
  68. package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js.map +1 -0
  69. package/lib/commonjs/ui/stores/authStore.js +154 -55
  70. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  71. package/lib/commonjs/ui/utils/avatarUtils.js +2 -36
  72. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  73. package/lib/module/index.js +16 -8
  74. package/lib/module/index.js.map +1 -1
  75. package/lib/module/ui/boot/runProviderColdBoot.js +7 -0
  76. package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
  77. package/lib/module/ui/client.js +1 -2
  78. package/lib/module/ui/client.js.map +1 -1
  79. package/lib/module/ui/components/OxyAccountDialogScreen.js +10 -27
  80. package/lib/module/ui/components/OxyAccountDialogScreen.js.map +1 -1
  81. package/lib/module/ui/components/OxyAuthChooser.js +134 -44
  82. package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
  83. package/lib/module/ui/components/OxyProvider.js +5 -3
  84. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  85. package/lib/module/ui/components/SurfaceScreen.js +33 -5
  86. package/lib/module/ui/components/SurfaceScreen.js.map +1 -1
  87. package/lib/module/ui/components/authChooser/AccountsMenuView.js +210 -85
  88. package/lib/module/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  89. package/lib/module/ui/components/authChooser/SignInEntryView.js +25 -7
  90. package/lib/module/ui/components/authChooser/SignInEntryView.js.map +1 -1
  91. package/lib/module/ui/components/authChooser/primitives.js +35 -22
  92. package/lib/module/ui/components/authChooser/primitives.js.map +1 -1
  93. package/lib/module/ui/components/authChooser/types.js +11 -0
  94. package/lib/module/ui/components/authChooser/types.js.map +1 -1
  95. package/lib/module/ui/context/OxyContext.js +251 -303
  96. package/lib/module/ui/context/OxyContext.js.map +1 -1
  97. package/lib/module/ui/context/hooks/useAuthOperations.js +27 -37
  98. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  99. package/lib/module/ui/context/oxyContextHelpers.js +0 -28
  100. package/lib/module/ui/context/oxyContextHelpers.js.map +1 -1
  101. package/lib/module/ui/context/useOxyAccountGraph.js +6 -17
  102. package/lib/module/ui/context/useOxyAccountGraph.js.map +1 -1
  103. package/lib/module/ui/hooks/accountDialogSnapshot.js +38 -0
  104. package/lib/module/ui/hooks/accountDialogSnapshot.js.map +1 -0
  105. package/lib/module/ui/hooks/mutations/useAccountMutations.js +0 -19
  106. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  107. package/lib/module/ui/hooks/useDeviceSwitcher.js +53 -0
  108. package/lib/module/ui/hooks/useDeviceSwitcher.js.map +1 -0
  109. package/lib/module/ui/hooks/useI18n.js +24 -4
  110. package/lib/module/ui/hooks/useI18n.js.map +1 -1
  111. package/lib/module/ui/hooks/useSessionManagement.js +47 -155
  112. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  113. package/lib/module/ui/index.js +1 -2
  114. package/lib/module/ui/index.js.map +1 -1
  115. package/lib/module/ui/navigation/routes.js +84 -72
  116. package/lib/module/ui/navigation/routes.js.map +1 -1
  117. package/lib/module/ui/navigation/surfaces.js +6 -6
  118. package/lib/module/ui/navigation/surfaces.js.map +1 -1
  119. package/lib/module/ui/runtime/createOxyRuntime.js +430 -0
  120. package/lib/module/ui/runtime/createOxyRuntime.js.map +1 -0
  121. package/lib/module/ui/runtime/index.js +15 -0
  122. package/lib/module/ui/runtime/index.js.map +1 -0
  123. package/lib/module/ui/runtime/runtimeContext.js +75 -0
  124. package/lib/module/ui/runtime/runtimeContext.js.map +1 -0
  125. package/lib/module/ui/runtime/types.js +4 -0
  126. package/lib/module/ui/runtime/types.js.map +1 -0
  127. package/lib/module/ui/runtime/useRuntimeSnapshot.js +52 -0
  128. package/lib/module/ui/runtime/useRuntimeSnapshot.js.map +1 -0
  129. package/lib/module/ui/server.js +0 -1
  130. package/lib/module/ui/server.js.map +1 -1
  131. package/lib/module/ui/session/authStore.js +46 -11
  132. package/lib/module/ui/session/authStore.js.map +1 -1
  133. package/lib/module/ui/session/sharedDeviceCredentialStore.js +302 -0
  134. package/lib/module/ui/session/sharedDeviceCredentialStore.js.map +1 -0
  135. package/lib/module/ui/stores/authStore.js +154 -55
  136. package/lib/module/ui/stores/authStore.js.map +1 -1
  137. package/lib/module/ui/utils/avatarUtils.js +2 -35
  138. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  139. package/lib/typescript/commonjs/index.d.ts +5 -3
  140. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/ui/client.d.ts +1 -2
  143. package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts +11 -4
  149. package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts +3 -1
  151. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts +18 -6
  153. package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts +33 -1
  155. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts.map +1 -1
  156. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +35 -4
  157. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  158. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +8 -12
  159. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  160. package/lib/typescript/commonjs/ui/context/oxyContextHelpers.d.ts +0 -2
  161. package/lib/typescript/commonjs/ui/context/oxyContextHelpers.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +9 -1
  163. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  164. package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts +1 -3
  165. package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts.map +1 -1
  166. package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts +15 -0
  167. package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  169. package/lib/typescript/commonjs/ui/hooks/useDeviceSwitcher.d.ts +49 -0
  170. package/lib/typescript/commonjs/ui/hooks/useDeviceSwitcher.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/ui/hooks/useI18n.d.ts +13 -0
  172. package/lib/typescript/commonjs/ui/hooks/useI18n.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/ui/hooks/useSessionManagement.d.ts +23 -18
  174. package/lib/typescript/commonjs/ui/hooks/useSessionManagement.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/ui/index.d.ts +1 -2
  176. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/ui/navigation/routes.d.ts +15 -1
  178. package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/ui/runtime/createOxyRuntime.d.ts +144 -0
  181. package/lib/typescript/commonjs/ui/runtime/createOxyRuntime.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/ui/runtime/index.d.ts +16 -0
  183. package/lib/typescript/commonjs/ui/runtime/index.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/ui/runtime/runtimeContext.d.ts +43 -0
  185. package/lib/typescript/commonjs/ui/runtime/runtimeContext.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/ui/runtime/types.d.ts +89 -0
  187. package/lib/typescript/commonjs/ui/runtime/types.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/ui/runtime/useRuntimeSnapshot.d.ts +23 -0
  189. package/lib/typescript/commonjs/ui/runtime/useRuntimeSnapshot.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/ui/server.d.ts +0 -1
  191. package/lib/typescript/commonjs/ui/server.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/ui/session/authStore.d.ts +60 -9
  193. package/lib/typescript/commonjs/ui/session/authStore.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts +32 -0
  195. package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/ui/stores/authStore.d.ts +49 -5
  197. package/lib/typescript/commonjs/ui/stores/authStore.d.ts.map +1 -1
  198. package/lib/typescript/commonjs/ui/types/navigation.d.ts +26 -0
  199. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  200. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts +2 -10
  201. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
  202. package/lib/typescript/module/index.d.ts +5 -3
  203. package/lib/typescript/module/index.d.ts.map +1 -1
  204. package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  205. package/lib/typescript/module/ui/client.d.ts +1 -2
  206. package/lib/typescript/module/ui/client.d.ts.map +1 -1
  207. package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
  208. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
  209. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  210. package/lib/typescript/module/ui/components/SurfaceScreen.d.ts.map +1 -1
  211. package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts +11 -4
  212. package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  213. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts +3 -1
  214. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  215. package/lib/typescript/module/ui/components/authChooser/primitives.d.ts +18 -6
  216. package/lib/typescript/module/ui/components/authChooser/primitives.d.ts.map +1 -1
  217. package/lib/typescript/module/ui/components/authChooser/types.d.ts +33 -1
  218. package/lib/typescript/module/ui/components/authChooser/types.d.ts.map +1 -1
  219. package/lib/typescript/module/ui/context/OxyContext.d.ts +35 -4
  220. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  221. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +8 -12
  222. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  223. package/lib/typescript/module/ui/context/oxyContextHelpers.d.ts +0 -2
  224. package/lib/typescript/module/ui/context/oxyContextHelpers.d.ts.map +1 -1
  225. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +9 -1
  226. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  227. package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts +1 -3
  228. package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts.map +1 -1
  229. package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts +15 -0
  230. package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts.map +1 -0
  231. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  232. package/lib/typescript/module/ui/hooks/useDeviceSwitcher.d.ts +49 -0
  233. package/lib/typescript/module/ui/hooks/useDeviceSwitcher.d.ts.map +1 -0
  234. package/lib/typescript/module/ui/hooks/useI18n.d.ts +13 -0
  235. package/lib/typescript/module/ui/hooks/useI18n.d.ts.map +1 -1
  236. package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts +23 -18
  237. package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts.map +1 -1
  238. package/lib/typescript/module/ui/index.d.ts +1 -2
  239. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  240. package/lib/typescript/module/ui/navigation/routes.d.ts +15 -1
  241. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  242. package/lib/typescript/module/ui/navigation/surfaces.d.ts.map +1 -1
  243. package/lib/typescript/module/ui/runtime/createOxyRuntime.d.ts +144 -0
  244. package/lib/typescript/module/ui/runtime/createOxyRuntime.d.ts.map +1 -0
  245. package/lib/typescript/module/ui/runtime/index.d.ts +16 -0
  246. package/lib/typescript/module/ui/runtime/index.d.ts.map +1 -0
  247. package/lib/typescript/module/ui/runtime/runtimeContext.d.ts +43 -0
  248. package/lib/typescript/module/ui/runtime/runtimeContext.d.ts.map +1 -0
  249. package/lib/typescript/module/ui/runtime/types.d.ts +89 -0
  250. package/lib/typescript/module/ui/runtime/types.d.ts.map +1 -0
  251. package/lib/typescript/module/ui/runtime/useRuntimeSnapshot.d.ts +23 -0
  252. package/lib/typescript/module/ui/runtime/useRuntimeSnapshot.d.ts.map +1 -0
  253. package/lib/typescript/module/ui/server.d.ts +0 -1
  254. package/lib/typescript/module/ui/server.d.ts.map +1 -1
  255. package/lib/typescript/module/ui/session/authStore.d.ts +60 -9
  256. package/lib/typescript/module/ui/session/authStore.d.ts.map +1 -1
  257. package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts +32 -0
  258. package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -0
  259. package/lib/typescript/module/ui/stores/authStore.d.ts +49 -5
  260. package/lib/typescript/module/ui/stores/authStore.d.ts.map +1 -1
  261. package/lib/typescript/module/ui/types/navigation.d.ts +26 -0
  262. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  263. package/lib/typescript/module/ui/utils/avatarUtils.d.ts +2 -10
  264. package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
  265. package/package.json +6 -7
  266. package/plugins/withSharedDeviceSessionProvider.js +102 -0
  267. package/plugins/withSharedDeviceSessionReader.js +57 -0
  268. package/src/__tests__/esmSourcePurity.test.ts +61 -0
  269. package/src/index.ts +31 -9
  270. package/src/ui/boot/runProviderColdBoot.ts +7 -0
  271. package/src/ui/client.ts +1 -2
  272. package/src/ui/components/OxyAccountDialogScreen.tsx +10 -29
  273. package/src/ui/components/OxyAuthChooser.tsx +149 -50
  274. package/src/ui/components/OxyProvider.tsx +7 -5
  275. package/src/ui/components/SurfaceScreen.tsx +28 -4
  276. package/src/ui/components/authChooser/AccountsMenuView.tsx +246 -96
  277. package/src/ui/components/authChooser/SignInEntryView.tsx +31 -8
  278. package/src/ui/components/authChooser/primitives.tsx +37 -23
  279. package/src/ui/components/authChooser/types.ts +34 -1
  280. package/src/ui/context/OxyContext.tsx +269 -324
  281. package/src/ui/context/hooks/useAuthOperations.ts +32 -35
  282. package/src/ui/context/oxyContextHelpers.ts +0 -30
  283. package/src/ui/context/oxyContextTypes.ts +9 -1
  284. package/src/ui/context/useOxyAccountGraph.ts +5 -19
  285. package/src/ui/hooks/accountDialogSnapshot.ts +37 -0
  286. package/src/ui/hooks/mutations/useAccountMutations.ts +0 -19
  287. package/src/ui/hooks/queries/__tests__/userCache.test.ts +12 -1
  288. package/src/ui/hooks/useDeviceSwitcher.ts +110 -0
  289. package/src/ui/hooks/useI18n.ts +23 -3
  290. package/src/ui/hooks/useSessionManagement.ts +62 -211
  291. package/src/ui/index.ts +1 -2
  292. package/src/ui/navigation/routes.ts +85 -75
  293. package/src/ui/navigation/surfaces.ts +6 -9
  294. package/src/ui/runtime/createOxyRuntime.ts +623 -0
  295. package/src/ui/runtime/index.ts +34 -0
  296. package/src/ui/runtime/runtimeContext.tsx +111 -0
  297. package/src/ui/runtime/types.ts +110 -0
  298. package/src/ui/runtime/useRuntimeSnapshot.ts +52 -0
  299. package/src/ui/server.ts +0 -1
  300. package/src/ui/session/__tests__/authStore.test.ts +90 -0
  301. package/src/ui/session/__tests__/sharedDeviceCredentialStore.test.ts +289 -0
  302. package/src/ui/session/authStore.ts +78 -9
  303. package/src/ui/session/sharedDeviceCredentialStore.ts +318 -0
  304. package/src/ui/stores/authStore.ts +171 -43
  305. package/src/ui/types/navigation.ts +26 -0
  306. package/src/ui/utils/avatarUtils.ts +2 -37
  307. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js +0 -64
  308. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js.map +0 -1
  309. package/lib/commonjs/ui/stores/accountStore.js +0 -221
  310. package/lib/commonjs/ui/stores/accountStore.js.map +0 -1
  311. package/lib/module/ui/hooks/useSwitchableAccounts.js +0 -60
  312. package/lib/module/ui/hooks/useSwitchableAccounts.js.map +0 -1
  313. package/lib/module/ui/stores/accountStore.js +0 -213
  314. package/lib/module/ui/stores/accountStore.js.map +0 -1
  315. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts +0 -23
  316. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts.map +0 -1
  317. package/lib/typescript/commonjs/ui/stores/accountStore.d.ts +0 -27
  318. package/lib/typescript/commonjs/ui/stores/accountStore.d.ts.map +0 -1
  319. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts +0 -23
  320. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts.map +0 -1
  321. package/lib/typescript/module/ui/stores/accountStore.d.ts +0 -27
  322. package/lib/typescript/module/ui/stores/accountStore.d.ts.map +0 -1
  323. package/src/ui/hooks/useSwitchableAccounts.ts +0 -75
  324. package/src/ui/stores/accountStore.ts +0 -264
@@ -3,33 +3,68 @@
3
3
  /**
4
4
  * Platform `AuthStateStore` for `@oxyhq/services`.
5
5
  *
6
- * The zero-cookie device model persists the durable device credential
7
- * (`deviceId` + `deviceSecret`) per origin (web) / per device (native), and the
8
- * SDK re-mints the access token from that credential on cold boot. `@oxyhq/core`
9
- * owns the store shape + logic (`createWebAuthStateStore` /
10
- * `createNativeAuthStateStore`); this module only selects the platform storage
11
- * seam:
6
+ * The device model persists the durable device credential (`deviceId` +
7
+ * `deviceSecret`) per origin (web) / per device (native), and the SDK re-mints
8
+ * the access token from that credential on cold boot. `@oxyhq/core` owns the
9
+ * store shape + logic (`createWebAuthStateStore` / `createNativeAuthStateStore` /
10
+ * `createMemoryAuthStateStore`); this module only selects the seam:
12
11
  *
12
+ * - `storage: 'ephemeral'` → `createMemoryAuthStateStore()`, on EVERY platform.
13
13
  * - web → `createWebAuthStateStore()` (localStorage, in-memory fallback).
14
14
  * - native → `createNativeAuthStateStore(secureKV)` for the SESSION blob over
15
15
  * the shared `createNativeSecureKeyValueStorage()` adapter
16
- * (`expo-secure-store`, AsyncStorage fallback).
16
+ * (`expo-secure-store`, AsyncStorage fallback), WRAPPED so every credential
17
+ * it persists is also mirrored into the device-wide shared slot.
18
+ *
19
+ * The native wrapper is how several official apps end up on ONE `DeviceSession`
20
+ * (and therefore one active context): whichever app proves a credential publishes
21
+ * it, and a later-installed sibling adopts it during cold boot instead of asking
22
+ * for the Commons identity key. The mirror is additive — it can neither change
23
+ * nor fail the app's own durable write.
17
24
  */
18
- import { createWebAuthStateStore, createNativeAuthStateStore } from '@oxyhq/core';
25
+ import { createWebAuthStateStore, createNativeAuthStateStore, createMemoryAuthStateStore, createSharedMirroringAuthStateStore } from '@oxyhq/core';
19
26
  import { isReactNative } from "../utils/storageHelpers.js";
20
27
  import { createNativeSecureKeyValueStorage } from "./nativeSecureStorage.js";
21
-
28
+ import { createPlatformSharedDeviceCredentialStore } from "./sharedDeviceCredentialStore.js";
22
29
  /**
23
30
  * Build the platform {@link AuthStateStore} for this runtime.
24
31
  *
25
32
  * Native persists the SESSION blob (`deviceId` + `deviceSecret` + cached access
26
33
  * token) per-app in SecureStore; the SDK re-mints the access token from the
27
34
  * device credential on the next cold boot.
35
+ *
36
+ * ## The ephemeral check is FIRST, and the order is load-bearing
37
+ *
38
+ * It short-circuits above the `isReactNative()` branch so an ephemeral caller can
39
+ * never reach the native path — and therefore can never reach the shared-slot
40
+ * mirroring wrapper. Checked after that branch instead, an origin that has
41
+ * declined to persist a credential would publish one into the device-wide slot
42
+ * every sibling app adopts on cold boot: it would keep nothing itself while
43
+ * deciding which session five other apps boot into.
44
+ *
45
+ * That is unreachable today because the only ephemeral caller is a web origin, so
46
+ * `isReactNative()` is false there anyway. Unreachable today is exactly the kind
47
+ * of guarantee that stops holding when someone adds the second caller, so it is
48
+ * structural here rather than incidental, and
49
+ * `__tests__/session/authStoreEphemeral.test.ts` holds the ordering directly.
28
50
  */
29
- export function createPlatformAuthStateStore() {
51
+ export function createPlatformAuthStateStore(options = {}) {
52
+ // FIRST, above every platform branch — see the docblock for why the ordering
53
+ // is the guarantee and not a coincidence.
54
+ if (options.storage === 'ephemeral') {
55
+ return createMemoryAuthStateStore();
56
+ }
30
57
  if (!isReactNative()) {
31
58
  return createWebAuthStateStore();
32
59
  }
33
- return createNativeAuthStateStore(createNativeSecureKeyValueStorage());
60
+ const local = createNativeAuthStateStore(createNativeSecureKeyValueStorage());
61
+ if (options.sessionMode === 'identity') {
62
+ return local;
63
+ }
64
+ const shared = createPlatformSharedDeviceCredentialStore();
65
+ return shared ? createSharedMirroringAuthStateStore({
66
+ local,
67
+ shared
68
+ }) : local;
34
69
  }
35
70
  //# sourceMappingURL=authStore.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createWebAuthStateStore","createNativeAuthStateStore","isReactNative","createNativeSecureKeyValueStorage","createPlatformAuthStateStore"],"sourceRoot":"../../../../src","sources":["ui/session/authStore.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,uBAAuB,EACvBC,0BAA0B,QAErB,aAAa;AACpB,SAASC,aAAa,QAAQ,4BAAyB;AACvD,SAASC,iCAAiC,QAAQ,0BAAuB;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAA,EAAmB;EAC7D,IAAI,CAACF,aAAa,CAAC,CAAC,EAAE;IACpB,OAAOF,uBAAuB,CAAC,CAAC;EAClC;EAEA,OAAOC,0BAA0B,CAACE,iCAAiC,CAAC,CAAC,CAAC;AACxE","ignoreList":[]}
1
+ {"version":3,"names":["createWebAuthStateStore","createNativeAuthStateStore","createMemoryAuthStateStore","createSharedMirroringAuthStateStore","isReactNative","createNativeSecureKeyValueStorage","createPlatformSharedDeviceCredentialStore","createPlatformAuthStateStore","options","storage","local","sessionMode","shared"],"sourceRoot":"../../../../src","sources":["ui/session/authStore.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,uBAAuB,EACvBC,0BAA0B,EAC1BC,0BAA0B,EAC1BC,mCAAmC,QAG9B,aAAa;AACpB,SAASC,aAAa,QAAQ,4BAAyB;AACvD,SAASC,iCAAiC,QAAQ,0BAAuB;AACzE,SAASC,yCAAyC,QAAQ,kCAA+B;AAgCzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC1CC,OAAsC,GAAG,CAAC,CAAC,EAC3B;EAChB;EACA;EACA,IAAIA,OAAO,CAACC,OAAO,KAAK,WAAW,EAAE;IACnC,OAAOP,0BAA0B,CAAC,CAAC;EACrC;EAEA,IAAI,CAACE,aAAa,CAAC,CAAC,EAAE;IACpB,OAAOJ,uBAAuB,CAAC,CAAC;EAClC;EAEA,MAAMU,KAAK,GAAGT,0BAA0B,CAACI,iCAAiC,CAAC,CAAC,CAAC;EAC7E,IAAIG,OAAO,CAACG,WAAW,KAAK,UAAU,EAAE;IACtC,OAAOD,KAAK;EACd;EACA,MAAME,MAAM,GAAGN,yCAAyC,CAAC,CAAC;EAC1D,OAAOM,MAAM,GAAGT,mCAAmC,CAAC;IAAEO,KAAK;IAAEE;EAAO,CAAC,CAAC,GAAGF,KAAK;AAChF","ignoreList":[]}
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The platform half of the shared native DeviceSession credential.
5
+ *
6
+ * `@oxyhq/core` owns the rules (`sharedDeviceCredential.ts`: when to adopt, when
7
+ * to publish, and above all that an unreadable slot is never an empty one). This
8
+ * module owns only where the bytes live, which is genuinely different per
9
+ * platform:
10
+ *
11
+ * - **iOS** — one `expo-secure-store` item in the approved Keychain Access Group
12
+ * `group.so.oxy.shared`, under its OWN `keychainService`
13
+ * ({@link IOS_DEVICE_SESSION_KEYCHAIN_SERVICE}). Every identity slot uses a
14
+ * different service (`oxy_identity`, `oxy_identity_backup`,
15
+ * `oxy_identity_mnemonic`) and the legacy cross-app identity keypair uses the
16
+ * same group with NO service at all — so this item cannot alias any of them.
17
+ * That separation is the point of the whole phase: the group-shared identity
18
+ * key and the group-shared device-session credential are different secrets
19
+ * with different blast radii and must not be conflated.
20
+ * - **Android** — the signature-protected `OxyDeviceSession` broker (its own
21
+ * EncryptedSharedPreferences file, its own ContentProvider, its own
22
+ * `signature`-level permission). It carries a session credential; it can NOT
23
+ * reach the identity keypair, which lives in a different file behind a
24
+ * different provider.
25
+ * - **web / anything else** — no shared slot. Each origin is its own device by
26
+ * design, so the factory returns `null` and the cold boot simply omits the
27
+ * lane.
28
+ *
29
+ * ## What is written here, and what is not
30
+ *
31
+ * Only `{deviceId, deviceSecret}`. No access token, no account id, no user id,
32
+ * and never any identity key material.
33
+ *
34
+ * ## Accessibility
35
+ *
36
+ * `WHEN_UNLOCKED_THIS_DEVICE_ONLY`: a device credential must not travel to
37
+ * another handset in an iCloud/encrypted backup restore — the restored device is
38
+ * a different device and has to establish its own session. It also keeps the item
39
+ * out of reach while the phone is locked, which is why a read can legitimately
40
+ * fail and why the `unavailable` verdict exists at all.
41
+ */
42
+ import { Platform } from 'react-native';
43
+ import { requireOptionalNativeModule } from 'expo-modules-core';
44
+ import { normalizeSharedDeviceSessionRead } from '@oxyhq/core';
45
+
46
+ /**
47
+ * The iOS Keychain Access Group every official Oxy app declares in its
48
+ * entitlements. Shared with the identity slots — the group is the app-group
49
+ * boundary, not the secret's identity.
50
+ */
51
+ export const IOS_KEYCHAIN_ACCESS_GROUP = 'group.so.oxy.shared';
52
+
53
+ /**
54
+ * The iOS `keychainService` for the DEVICE SESSION credential. Deliberately
55
+ * distinct from every identity and recovery service; do not reuse one of those
56
+ * here, and do not drop it (an item written with no service shares the legacy
57
+ * identity slot's namespace inside the group).
58
+ */
59
+ export const IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = 'oxy_device_session';
60
+
61
+ /** The single key holding the JSON-encoded `{deviceId, deviceSecret}` pair. */
62
+ export const SHARED_DEVICE_SESSION_STORAGE_KEY = 'oxy_shared_device_session_v1';
63
+
64
+ // Variable indirection so Metro's static analyzer never traces expo-secure-store
65
+ // into the web bundle; the module is native-only and optional.
66
+ const SECURE_STORE_MODULE = 'expo-secure-store';
67
+
68
+ /**
69
+ * The subset of `expo-secure-store` this module needs. Unlike the adapter in
70
+ * `nativeSecureStorage.ts` it must pass OPTIONS — the access group and the
71
+ * dedicated service are the entire mechanism here, so an options-less wrapper
72
+ * would silently write a package-private item that no sibling app can see.
73
+ */
74
+
75
+ let keychainStorePromise = null;
76
+ function loadKeychainGroupStore() {
77
+ if (!keychainStorePromise) {
78
+ const moduleName = SECURE_STORE_MODULE;
79
+ keychainStorePromise = import(moduleName).then(mod => {
80
+ if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function' && typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number') {
81
+ return {
82
+ getItemAsync: mod.getItemAsync.bind(mod),
83
+ setItemAsync: mod.setItemAsync.bind(mod),
84
+ deleteItemAsync: mod.deleteItemAsync.bind(mod),
85
+ WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY
86
+ };
87
+ }
88
+ return null;
89
+ }).catch(() => null);
90
+ }
91
+ return keychainStorePromise;
92
+ }
93
+
94
+ /** Parse the stored JSON into a credential, or `null` for anything malformed. */
95
+ function parseStoredCredential(raw) {
96
+ if (!raw) {
97
+ return null;
98
+ }
99
+ let parsed;
100
+ try {
101
+ parsed = JSON.parse(raw);
102
+ } catch {
103
+ return null;
104
+ }
105
+ if (!parsed || typeof parsed !== 'object') {
106
+ return null;
107
+ }
108
+ const candidate = parsed;
109
+ if (typeof candidate.deviceId !== 'string' || candidate.deviceId.length === 0 || typeof candidate.deviceSecret !== 'string' || candidate.deviceSecret.length === 0) {
110
+ return null;
111
+ }
112
+ return {
113
+ deviceId: candidate.deviceId,
114
+ deviceSecret: candidate.deviceSecret
115
+ };
116
+ }
117
+
118
+ /**
119
+ * The iOS store: one keychain item in the shared access group.
120
+ *
121
+ * A THROWN read is `unavailable`, a `null` read is `absent`. That mapping is the
122
+ * whole safety contract — `expo-secure-store` returns `null` for a genuinely
123
+ * missing item and throws when the keychain itself refuses, and collapsing the
124
+ * two is what would let a locked phone look like a device that never had a
125
+ * session.
126
+ */
127
+ function createKeychainGroupCredentialStore() {
128
+ const readOptions = {
129
+ keychainService: IOS_DEVICE_SESSION_KEYCHAIN_SERVICE,
130
+ keychainAccessGroup: IOS_KEYCHAIN_ACCESS_GROUP
131
+ };
132
+ return {
133
+ read: async () => {
134
+ const store = await loadKeychainGroupStore();
135
+ if (!store) {
136
+ return {
137
+ state: 'unsupported'
138
+ };
139
+ }
140
+ let raw;
141
+ try {
142
+ raw = await store.getItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, readOptions);
143
+ } catch (error) {
144
+ return {
145
+ state: 'unavailable',
146
+ cause: error
147
+ };
148
+ }
149
+ if (raw === null) {
150
+ return {
151
+ state: 'absent'
152
+ };
153
+ }
154
+ const credential = parseStoredCredential(raw);
155
+ if (!credential) {
156
+ // Something IS stored and we cannot read it. Reporting `absent` would
157
+ // authorise overwriting whatever a newer build put there.
158
+ return {
159
+ state: 'unavailable',
160
+ cause: new Error('shared device session item is present but not parseable')
161
+ };
162
+ }
163
+ return {
164
+ state: 'present',
165
+ credential
166
+ };
167
+ },
168
+ publish: async credential => {
169
+ const store = await loadKeychainGroupStore();
170
+ if (!store) {
171
+ return false;
172
+ }
173
+ const value = JSON.stringify(credential);
174
+ try {
175
+ await store.setItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, value, {
176
+ ...readOptions,
177
+ keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
178
+ });
179
+ // Read-back verify. A keychain write can resolve without the item having
180
+ // landed under the access group (a missing entitlement is the usual
181
+ // cause), and a phantom credential would send a fresh install into a mint
182
+ // that can never succeed.
183
+ return (await store.getItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, readOptions)) === value;
184
+ } catch {
185
+ return false;
186
+ }
187
+ },
188
+ clear: async () => {
189
+ const store = await loadKeychainGroupStore();
190
+ if (!store) {
191
+ return;
192
+ }
193
+ try {
194
+ await store.deleteItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, readOptions);
195
+ } catch {
196
+ // Best-effort: the slot is a join point, not a source of truth.
197
+ }
198
+ }
199
+ };
200
+ }
201
+
202
+ /**
203
+ * The Android broker's JS surface. `read` returns an UNTRUSTED payload that
204
+ * {@link normalizeSharedDeviceSessionRead} narrows; `write` reports whether the
205
+ * native read-back confirmed the bytes.
206
+ */
207
+
208
+ let brokerModule;
209
+
210
+ /**
211
+ * Resolve the `OxyDeviceSession` broker, or `null` when it is not autolinked.
212
+ *
213
+ * `requireOptionalNativeModule` (a static import Metro always resolves) rather
214
+ * than a dynamic `import(moduleName)`: the latter compiles to `require(variable)`
215
+ * in the CJS build, which Metro cannot resolve inside a consuming app — it
216
+ * silently returns `null` there, which is exactly how the cross-app identity
217
+ * bridge broke once. Same reasoning as `backgroundSession.ts` next door.
218
+ */
219
+ function loadBrokerModule() {
220
+ if (brokerModule === undefined) {
221
+ const native = requireOptionalNativeModule('OxyDeviceSession');
222
+ brokerModule = native && typeof native.read === 'function' && typeof native.write === 'function' && typeof native.clear === 'function' ? {
223
+ read: native.read.bind(native),
224
+ write: native.write.bind(native),
225
+ clear: native.clear.bind(native)
226
+ } : null;
227
+ }
228
+ return brokerModule;
229
+ }
230
+
231
+ /**
232
+ * The Android store: the signature-protected `OxyDeviceSession` broker.
233
+ *
234
+ * The broker already answers with an explicit status, so the only work here is
235
+ * narrowing an UNTRUSTED payload — `normalizeSharedDeviceSessionRead` resolves
236
+ * anything it does not recognise to `unavailable`, never `absent`.
237
+ */
238
+ function createBrokerCredentialStore() {
239
+ return {
240
+ read: async () => {
241
+ const broker = loadBrokerModule();
242
+ if (!broker) {
243
+ return {
244
+ state: 'unsupported'
245
+ };
246
+ }
247
+ try {
248
+ return normalizeSharedDeviceSessionRead(await broker.read());
249
+ } catch (error) {
250
+ return {
251
+ state: 'unavailable',
252
+ cause: error
253
+ };
254
+ }
255
+ },
256
+ publish: async credential => {
257
+ const broker = loadBrokerModule();
258
+ if (!broker) {
259
+ return false;
260
+ }
261
+ try {
262
+ // The broker read-back-verifies natively and returns the verdict.
263
+ return await broker.write(credential.deviceId, credential.deviceSecret);
264
+ } catch {
265
+ return false;
266
+ }
267
+ },
268
+ clear: async () => {
269
+ const broker = loadBrokerModule();
270
+ if (!broker) {
271
+ return;
272
+ }
273
+ try {
274
+ await broker.clear();
275
+ } catch {
276
+ // Best-effort — see the iOS store.
277
+ }
278
+ }
279
+ };
280
+ }
281
+
282
+ /**
283
+ * The shared DeviceSession credential slot for this runtime, or `null` when
284
+ * there is none.
285
+ *
286
+ * The branch is on the PLATFORM, not on which module happens to load, because
287
+ * `expo-secure-store` loads perfectly well on Android — it would just quietly
288
+ * ignore `keychainAccessGroup` and read a package-private item, which looks
289
+ * exactly like an empty shared slot. This is the same iOS-vs-Android split
290
+ * `KeyManager` makes for the shared identity, for the same reason.
291
+ *
292
+ * Any other native platform gets the broker, which answers `unsupported` when
293
+ * the module is not linked — so the lane is simply off, which is the safe
294
+ * direction.
295
+ */
296
+ export function createPlatformSharedDeviceCredentialStore() {
297
+ if (Platform.OS === 'web') {
298
+ return null;
299
+ }
300
+ return Platform.OS === 'ios' ? createKeychainGroupCredentialStore() : createBrokerCredentialStore();
301
+ }
302
+ //# sourceMappingURL=sharedDeviceCredentialStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","requireOptionalNativeModule","normalizeSharedDeviceSessionRead","IOS_KEYCHAIN_ACCESS_GROUP","IOS_DEVICE_SESSION_KEYCHAIN_SERVICE","SHARED_DEVICE_SESSION_STORAGE_KEY","SECURE_STORE_MODULE","keychainStorePromise","loadKeychainGroupStore","moduleName","then","mod","getItemAsync","setItemAsync","deleteItemAsync","WHEN_UNLOCKED_THIS_DEVICE_ONLY","bind","catch","parseStoredCredential","raw","parsed","JSON","parse","candidate","deviceId","length","deviceSecret","createKeychainGroupCredentialStore","readOptions","keychainService","keychainAccessGroup","read","store","state","error","cause","credential","Error","publish","value","stringify","keychainAccessible","clear","brokerModule","loadBrokerModule","undefined","native","write","createBrokerCredentialStore","broker","createPlatformSharedDeviceCredentialStore","OS"],"sourceRoot":"../../../../src","sources":["ui/session/sharedDeviceCredentialStore.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,2BAA2B,QAAQ,mBAAmB;AAC/D,SACEC,gCAAgC,QAI3B,aAAa;;AAEpB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,qBAAqB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mCAAmC,GAAG,oBAAoB;;AAEvE;AACA,OAAO,MAAMC,iCAAiC,GAAG,8BAA8B;;AAE/E;AACA;AACA,MAAMC,mBAAmB,GAAG,mBAAmB;;AAE/C;AACA;AACA;AACA;AACA;AACA;;AAQA,IAAIC,oBAA+D,GAAG,IAAI;AAE1E,SAASC,sBAAsBA,CAAA,EAAuC;EACpE,IAAI,CAACD,oBAAoB,EAAE;IACzB,MAAME,UAAU,GAAGH,mBAAmB;IACtCC,oBAAoB,GAAG,MAAM,CAACE,UAAU,CAAC,CACtCC,IAAI,CAAEC,GAAgC,IAAK;MAC1C,IACE,OAAOA,GAAG,CAACC,YAAY,KAAK,UAAU,IACtC,OAAOD,GAAG,CAACE,YAAY,KAAK,UAAU,IACtC,OAAOF,GAAG,CAACG,eAAe,KAAK,UAAU,IACzC,OAAOH,GAAG,CAACI,8BAA8B,KAAK,QAAQ,EACtD;QACA,OAAO;UACLH,YAAY,EAAED,GAAG,CAACC,YAAY,CAACI,IAAI,CAACL,GAAG,CAAC;UACxCE,YAAY,EAAEF,GAAG,CAACE,YAAY,CAACG,IAAI,CAACL,GAAG,CAAC;UACxCG,eAAe,EAAEH,GAAG,CAACG,eAAe,CAACE,IAAI,CAACL,GAAG,CAAC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AE,MAAOF,UAAU,IAAuB;MAC/C,MAAMa,MAAM,GAAGL,gBAAgB,CAAC,CAAC;MACjC,IAAI,CAACK,MAAM,EAAE;QACX,OAAO,KAAK;MACd;MACA,IAAI;QACF;QACA,OAAO,MAAMA,MAAM,CAACF,KAAK,CAACX,UAAU,CAACZ,QAAQ,EAAEY,UAAU,CAACV,YAAY,CAAC;MACzE,CAAC,CAAC,MAAM;QACN,OAAO,KAAK;MACd;IACF,CAAC;IAEDgB,KAAK,EAAE,MAAAA,CAAA,KAA2B;MAChC,MAAMO,MAAM,GAAGL,gBAAgB,CAAC,CAAC;MACjC,IAAI,CAACK,MAAM,EAAE;QACX;MACF;MACA,IAAI;QACF,MAAMA,MAAM,CAACP,KAAK,CAAC,CAAC;MACtB,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,yCAAyCA,CAAA,EAAuC;EAC9F,IAAIlD,QAAQ,CAACmD,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO,IAAI;EACb;EACA,OAAOnD,QAAQ,CAACmD,EAAE,KAAK,KAAK,GAAGxB,kCAAkC,CAAC,CAAC,GAAGqB,2BAA2B,CAAC,CAAC;AACrG","ignoreList":[]}
@@ -1,66 +1,165 @@
1
1
  "use strict";
2
2
 
3
- import { create } from 'zustand';
4
- import { createLogger, normalizeUserIdentity } from '@oxyhq/core';
5
- const log = createLogger('AuthStore');
6
- export const useAuthStore = create((set, get) => ({
3
+ import { useCallback, useRef, useSyncExternalStore } from 'react';
4
+
5
+ /**
6
+ * The signed-in user, as a zustand-shaped read/write surface.
7
+ *
8
+ * It used to BE a zustand store, and that made it a second owner of the
9
+ * session: the provider wrote `user`/`isAuthenticated` here, `SessionClient`
10
+ * wrote the same facts into its device state, and nothing reconciled them —
11
+ * when they disagreed, which one was right was not answerable. It is now a
12
+ * projection of the ONE `OxyRuntime` (ADR 0004): reads come off the runtime
13
+ * snapshot and writes go into the runtime, so there is nothing left to drift.
14
+ *
15
+ * The zustand SHAPE is kept deliberately — `useAuthStore(selector)`,
16
+ * `.getState()`, `.setState()`, `.subscribe()` — because a dozen call sites
17
+ * across this package and the Commons app read the user out of band, from
18
+ * mutation success handlers and cache helpers that are not inside a render.
19
+ * Rewriting them is Phase 8's cut, not this one's.
20
+ *
21
+ * `fetchUser` and `lastUserFetch` are GONE rather than projected: they were a
22
+ * five-minute profile cache with zero readers anywhere in the monorepo, and the
23
+ * Query cache has owned that job since long before this change.
24
+ */
25
+
26
+ /** The subset of `AuthState` a caller may push back in through `setState`. */
27
+
28
+ let boundRuntime = null;
29
+ let unbindRuntime = null;
30
+ const listeners = new Set();
31
+ const loginSuccess = user => {
32
+ boundRuntime?.setAccount(user);
33
+ };
34
+ const loginFailure = error => {
35
+ boundRuntime?.batch(() => {
36
+ boundRuntime?.setLoading(false);
37
+ boundRuntime?.setError(error);
38
+ });
39
+ };
40
+ const logout = () => {
41
+ boundRuntime?.clearSession();
42
+ };
43
+ const setUser = user => {
44
+ boundRuntime?.setAccount(user);
45
+ };
46
+ const SIGNED_OUT = Object.freeze({
7
47
  user: null,
8
48
  isAuthenticated: false,
9
49
  isLoading: false,
10
50
  error: null,
11
- lastUserFetch: null,
12
- loginSuccess: user => set({
13
- isLoading: false,
14
- isAuthenticated: true,
15
- user: normalizeUserIdentity(user),
16
- lastUserFetch: Date.now()
17
- }),
18
- loginFailure: error => set({
19
- isLoading: false,
20
- error
21
- }),
22
- logout: () => set({
23
- user: null,
24
- isAuthenticated: false,
25
- lastUserFetch: null
26
- }),
27
- setUser: user => set({
28
- user: normalizeUserIdentity(user),
29
- lastUserFetch: Date.now()
30
- }),
31
- fetchUser: async (oxyServices, forceRefresh = false) => {
32
- const state = get();
33
- const now = Date.now();
34
- const cacheAge = state.lastUserFetch ? now - state.lastUserFetch : Number.POSITIVE_INFINITY;
35
- const cacheValid = cacheAge < 5 * 60 * 1000; // 5 minutes cache
51
+ loginSuccess,
52
+ loginFailure,
53
+ logout,
54
+ setUser
55
+ });
56
+ let state = SIGNED_OUT;
57
+ function project(runtime) {
58
+ if (runtime === null) {
59
+ return SIGNED_OUT;
60
+ }
61
+ const snapshot = runtime.getSnapshot();
62
+ return Object.freeze({
63
+ user: snapshot.account,
64
+ isAuthenticated: snapshot.account !== null,
65
+ isLoading: snapshot.isLoading,
66
+ error: snapshot.error?.message ?? null,
67
+ loginSuccess,
68
+ loginFailure,
69
+ logout,
70
+ setUser
71
+ });
72
+ }
73
+ function republish() {
74
+ const next = project(boundRuntime);
75
+ if (next.user === state.user && next.isAuthenticated === state.isAuthenticated && next.isLoading === state.isLoading && next.error === state.error) {
76
+ return;
77
+ }
78
+ state = next;
79
+ for (const listener of [...listeners]) {
80
+ listener();
81
+ }
82
+ }
36
83
 
37
- // Use cached data if available and not forcing refresh
38
- if (!forceRefresh && state.user && cacheValid) {
39
- log.info('Using cached user data', {
40
- cacheAge
41
- });
84
+ /**
85
+ * Point this surface at the provider's runtime. Called once by
86
+ * `OxyRuntimeProvider`; the returned function detaches it again on unmount.
87
+ *
88
+ * With nothing bound, reads answer signed-out and writes are dropped. That is
89
+ * the honest answer for the two places it happens — the SSR shim, and a unit
90
+ * test poking the store with no provider mounted — and it is why binding is an
91
+ * explicit call rather than a lazily-created default runtime, which is exactly
92
+ * the fabricated-forever-loading runtime ADR 0004 deleted.
93
+ */
94
+ export function bindAuthStoreToRuntime(runtime) {
95
+ unbindRuntime?.();
96
+ boundRuntime = runtime;
97
+ unbindRuntime = runtime.subscribe(republish);
98
+ republish();
99
+ return () => {
100
+ if (boundRuntime !== runtime) {
42
101
  return;
43
102
  }
44
- set({
45
- isLoading: true,
46
- error: null
47
- });
48
- try {
49
- const user = normalizeUserIdentity(await oxyServices.getCurrentUser());
50
- set({
51
- user,
52
- isLoading: false,
53
- isAuthenticated: true,
54
- lastUserFetch: now
55
- });
56
- } catch (error) {
57
- const errorMessage = error instanceof Error ? error.message : 'Failed to fetch user';
58
- log.error('Error fetching user', error);
59
- set({
60
- error: errorMessage,
61
- isLoading: false
62
- });
103
+ unbindRuntime?.();
104
+ unbindRuntime = null;
105
+ boundRuntime = null;
106
+ republish();
107
+ };
108
+ }
109
+ const getState = () => state;
110
+ const setState = patch => {
111
+ boundRuntime?.batch(() => {
112
+ if (patch.isLoading !== undefined) {
113
+ boundRuntime?.setLoading(patch.isLoading);
63
114
  }
64
- }
65
- }));
115
+ if (patch.error !== undefined) {
116
+ boundRuntime?.setError(patch.error);
117
+ }
118
+ if (patch.user !== undefined) {
119
+ if (patch.user === null) {
120
+ boundRuntime?.clearSession();
121
+ } else {
122
+ boundRuntime?.setAccount(patch.user);
123
+ }
124
+ }
125
+ });
126
+ };
127
+ const subscribe = listener => {
128
+ listeners.add(listener);
129
+ return () => {
130
+ listeners.delete(listener);
131
+ };
132
+ };
133
+ function useAuthStoreHook(selector) {
134
+ // The selection is cached against the state object it came from, so a
135
+ // selector returning a fresh object cannot make `useSyncExternalStore` see a
136
+ // new value on every call and loop.
137
+ const cache = useRef(null);
138
+ const getSelection = useCallback(() => {
139
+ const cached = cache.current;
140
+ if (cached !== null && cached.state === state) {
141
+ return cached.value;
142
+ }
143
+ const value = selector(state);
144
+ cache.current = {
145
+ state,
146
+ value
147
+ };
148
+ return value;
149
+ }, [selector]);
150
+ return useSyncExternalStore(subscribe, getSelection, getSelection);
151
+ }
152
+
153
+ /**
154
+ * Read the signed-in user. Zustand-shaped, projected from the runtime.
155
+ *
156
+ * A selector that builds an object must be wrapped in `useShallow` (as every
157
+ * call site here already does) — otherwise a structurally-equal result reads as
158
+ * a change on every publish.
159
+ */
160
+ export const useAuthStore = Object.assign(useAuthStoreHook, {
161
+ getState,
162
+ setState,
163
+ subscribe
164
+ });
66
165
  //# sourceMappingURL=authStore.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["create","createLogger","normalizeUserIdentity","log","useAuthStore","set","get","user","isAuthenticated","isLoading","error","lastUserFetch","loginSuccess","Date","now","loginFailure","logout","setUser","fetchUser","oxyServices","forceRefresh","state","cacheAge","Number","POSITIVE_INFINITY","cacheValid","info","getCurrentUser","errorMessage","Error","message"],"sourceRoot":"../../../../src","sources":["ui/stores/authStore.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,SAAS;AAChC,SAASC,YAAY,EAAEC,qBAAqB,QAAQ,aAAa;AAGjE,MAAMC,GAAG,GAAGF,YAAY,CAAC,WAAW,CAAC;AAgBrC,OAAO,MAAMG,YAAY,GAAGJ,MAAM,CAAY,CAACK,GAAwC,EAAEC,GAAoB,MAAM;EACjHC,IAAI,EAAE,IAAI;EACVC,eAAe,EAAE,KAAK;EACtBC,SAAS,EAAE,KAAK;EAChBC,KAAK,EAAE,IAAI;EACXC,aAAa,EAAE,IAAI;EAEnBC,YAAY,EAAGL,IAAU,IAAKF,GAAG,CAAC;IAChCI,SAAS,EAAE,KAAK;IAChBD,eAAe,EAAE,IAAI;IACrBD,IAAI,EAAEL,qBAAqB,CAACK,IAAI,CAAC;IACjCI,aAAa,EAAEE,IAAI,CAACC,GAAG,CAAC;EAC1B,CAAC,CAAC;EACFC,YAAY,EAAGL,KAAa,IAAKL,GAAG,CAAC;IAAEI,SAAS,EAAE,KAAK;IAAEC;EAAM,CAAC,CAAC;EACjEM,MAAM,EAAEA,CAAA,KAAMX,GAAG,CAAC;IAChBE,IAAI,EAAE,IAAI;IACVC,eAAe,EAAE,KAAK;IACtBG,aAAa,EAAE;EACjB,CAAC,CAAC;EACFM,OAAO,EAAGV,IAAU,IAAKF,GAAG,CAAC;IAAEE,IAAI,EAAEL,qBAAqB,CAACK,IAAI,CAAC;IAAEI,aAAa,EAAEE,IAAI,CAACC,GAAG,CAAC;EAAE,CAAC,CAAC;EAC9FI,SAAS,EAAE,MAAAA,CAAOC,WAAW,EAAEC,YAAY,GAAG,KAAK,KAAK;IACtD,MAAMC,KAAK,GAAGf,GAAG,CAAC,CAAC;IACnB,MAAMQ,GAAG,GAAGD,IAAI,CAACC,GAAG,CAAC,CAAC;IACtB,MAAMQ,QAAQ,GAAGD,KAAK,CAACV,aAAa,GAAGG,GAAG,GAAGO,KAAK,CAACV,aAAa,GAAGY,MAAM,CAACC,iBAAiB;IAC3F,MAAMC,UAAU,GAAGH,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;;IAE7C;IACA,IAAI,CAACF,YAAY,IAAIC,KAAK,CAACd,IAAI,IAAIkB,UAAU,EAAE;MAC7CtB,GAAG,CAACuB,IAAI,CAAC,wBAAwB,EAAE;QAAEJ;MAAS,CAAC,CAAC;MAChD;IACF;IAEAjB,GAAG,CAAC;MAAEI,SAAS,EAAE,IAAI;MAAEC,KAAK,EAAE;IAAK,CAAC,CAAC;IACrC,IAAI;MACF,MAAMH,IAAI,GAAGL,qBAAqB,CAAC,MAAMiB,WAAW,CAACQ,cAAc,CAAC,CAAC,CAAC;MACtEtB,GAAG,CAAC;QAAEE,IAAI;QAAEE,SAAS,EAAE,KAAK;QAAED,eAAe,EAAE,IAAI;QAAEG,aAAa,EAAEG;MAAI,CAAC,CAAC;IAC5E,CAAC,CAAC,OAAOJ,KAAK,EAAE;MACd,MAAMkB,YAAY,GAAGlB,KAAK,YAAYmB,KAAK,GAAGnB,KAAK,CAACoB,OAAO,GAAG,sBAAsB;MACpF3B,GAAG,CAACO,KAAK,CAAC,qBAAqB,EAAEA,KAAK,CAAC;MACvCL,GAAG,CAAC;QAAEK,KAAK,EAAEkB,YAAY;QAAEnB,SAAS,EAAE;MAAM,CAAC,CAAC;IAChD;EACF;AACF,CAAC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useRef","useSyncExternalStore","boundRuntime","unbindRuntime","listeners","Set","loginSuccess","user","setAccount","loginFailure","error","batch","setLoading","setError","logout","clearSession","setUser","SIGNED_OUT","Object","freeze","isAuthenticated","isLoading","state","project","runtime","snapshot","getSnapshot","account","message","republish","next","listener","bindAuthStoreToRuntime","subscribe","getState","setState","patch","undefined","add","delete","useAuthStoreHook","selector","cache","getSelection","cached","current","value","useAuthStore","assign"],"sourceRoot":"../../../../src","sources":["ui/stores/authStore.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,EAAEC,oBAAoB,QAAQ,OAAO;;AAIjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;;AAGA,IAAIC,YAA+B,GAAG,IAAI;AAC1C,IAAIC,aAAkC,GAAG,IAAI;AAC7C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;AAEvC,MAAMC,YAAY,GAAIC,IAAU,IAAW;EACzCL,YAAY,EAAEM,UAAU,CAACD,IAAI,CAAC;AAChC,CAAC;AAED,MAAME,YAAY,GAAIC,KAAa,IAAW;EAC5CR,YAAY,EAAES,KAAK,CAAC,MAAM;IACxBT,YAAY,EAAEU,UAAU,CAAC,KAAK,CAAC;IAC/BV,YAAY,EAAEW,QAAQ,CAACH,KAAK,CAAC;EAC/B,CAAC,CAAC;AACJ,CAAC;AAED,MAAMI,MAAM,GAAGA,CAAA,KAAY;EACzBZ,YAAY,EAAEa,YAAY,CAAC,CAAC;AAC9B,CAAC;AAED,MAAMC,OAAO,GAAIT,IAAU,IAAW;EACpCL,YAAY,EAAEM,UAAU,CAACD,IAAI,CAAC;AAChC,CAAC;AAED,MAAMU,UAAqB,GAAGC,MAAM,CAACC,MAAM,CAAC;EAC1CZ,IAAI,EAAE,IAAI;EACVa,eAAe,EAAE,KAAK;EACtBC,SAAS,EAAE,KAAK;EAChBX,KAAK,EAAE,IAAI;EACXJ,YAAY;EACZG,YAAY;EACZK,MAAM;EACNE;AACF,CAAC,CAAC;AAEF,IAAIM,KAAgB,GAAGL,UAAU;AAEjC,SAASM,OAAOA,CAACC,OAA0B,EAAa;EACtD,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpB,OAAOP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