@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.
- package/LICENSE +202 -661
- package/NOTICE +16 -0
- package/README.md +67 -2
- package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionModule.kt +178 -0
- package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionProvider.kt +99 -0
- package/android/src/main/java/so/oxy/devicesession/OxyDeviceSessionStore.kt +115 -0
- package/expo-module.config.json +1 -0
- package/lib/commonjs/index.js +78 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/boot/runProviderColdBoot.js +7 -0
- package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/commonjs/ui/client.js +12 -7
- package/lib/commonjs/ui/client.js.map +1 -1
- package/lib/commonjs/ui/components/OxyAccountDialogScreen.js +10 -27
- package/lib/commonjs/ui/components/OxyAccountDialogScreen.js.map +1 -1
- package/lib/commonjs/ui/components/OxyAuthChooser.js +132 -44
- package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +4 -2
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/SurfaceScreen.js +31 -3
- package/lib/commonjs/ui/components/SurfaceScreen.js.map +1 -1
- package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js +209 -84
- package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js.map +1 -1
- package/lib/commonjs/ui/components/authChooser/SignInEntryView.js +25 -7
- package/lib/commonjs/ui/components/authChooser/SignInEntryView.js.map +1 -1
- package/lib/commonjs/ui/components/authChooser/primitives.js +35 -22
- package/lib/commonjs/ui/components/authChooser/primitives.js.map +1 -1
- package/lib/commonjs/ui/components/authChooser/signInProgress.js +5 -0
- package/lib/commonjs/ui/components/authChooser/signInProgress.js.map +1 -1
- package/lib/commonjs/ui/components/authChooser/types.js +11 -0
- package/lib/commonjs/ui/components/authChooser/types.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +257 -306
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +27 -37
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/context/oxyContextHelpers.js +0 -29
- package/lib/commonjs/ui/context/oxyContextHelpers.js.map +1 -1
- package/lib/commonjs/ui/context/useOxyAccountGraph.js +6 -17
- package/lib/commonjs/ui/context/useOxyAccountGraph.js.map +1 -1
- package/lib/commonjs/ui/hooks/accountDialogSnapshot.js +42 -0
- package/lib/commonjs/ui/hooks/accountDialogSnapshot.js.map +1 -0
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +0 -19
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/useDeviceSwitcher.js +57 -0
- package/lib/commonjs/ui/hooks/useDeviceSwitcher.js.map +1 -0
- package/lib/commonjs/ui/hooks/useI18n.js +22 -3
- package/lib/commonjs/ui/hooks/useI18n.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionManagement.js +46 -153
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/commonjs/ui/index.js +12 -7
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +85 -73
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/navigation/surfaces.js +8 -7
- package/lib/commonjs/ui/navigation/surfaces.js.map +1 -1
- package/lib/commonjs/ui/runtime/createOxyRuntime.js +433 -0
- package/lib/commonjs/ui/runtime/createOxyRuntime.js.map +1 -0
- package/lib/commonjs/ui/runtime/index.js +63 -0
- package/lib/commonjs/ui/runtime/index.js.map +1 -0
- package/lib/commonjs/ui/runtime/runtimeContext.js +83 -0
- package/lib/commonjs/ui/runtime/runtimeContext.js.map +1 -0
- package/lib/commonjs/ui/runtime/types.js +6 -0
- package/lib/commonjs/ui/runtime/types.js.map +1 -0
- package/lib/commonjs/ui/runtime/useRuntimeSnapshot.js +57 -0
- package/lib/commonjs/ui/runtime/useRuntimeSnapshot.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountMembersScreen.js +3 -4
- package/lib/commonjs/ui/screens/AccountMembersScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/CreateAccountScreen.js +3 -12
- package/lib/commonjs/ui/screens/CreateAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js +6 -5
- package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/trust/TrustLeaderboardScreen.js +4 -4
- package/lib/commonjs/ui/screens/trust/TrustLeaderboardScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js +1 -1
- package/lib/commonjs/ui/screens/trust/TrustRulesScreen.js +4 -2
- package/lib/commonjs/ui/screens/trust/TrustRulesScreen.js.map +1 -1
- package/lib/commonjs/ui/server.js +1 -2
- package/lib/commonjs/ui/server.js.map +1 -1
- package/lib/commonjs/ui/session/authStore.js +45 -9
- package/lib/commonjs/ui/session/authStore.js.map +1 -1
- package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js +306 -0
- package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js.map +1 -0
- package/lib/commonjs/ui/stores/authStore.js +154 -55
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/stores/followTargetStore.js +27 -0
- package/lib/commonjs/ui/stores/followTargetStore.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +2 -36
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/index.js +20 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/boot/runProviderColdBoot.js +7 -0
- package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/module/ui/client.js +1 -2
- package/lib/module/ui/client.js.map +1 -1
- package/lib/module/ui/components/OxyAccountDialogScreen.js +10 -27
- package/lib/module/ui/components/OxyAccountDialogScreen.js.map +1 -1
- package/lib/module/ui/components/OxyAuthChooser.js +134 -44
- package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +5 -3
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/SurfaceScreen.js +33 -5
- package/lib/module/ui/components/SurfaceScreen.js.map +1 -1
- package/lib/module/ui/components/authChooser/AccountsMenuView.js +210 -85
- package/lib/module/ui/components/authChooser/AccountsMenuView.js.map +1 -1
- package/lib/module/ui/components/authChooser/SignInEntryView.js +25 -7
- package/lib/module/ui/components/authChooser/SignInEntryView.js.map +1 -1
- package/lib/module/ui/components/authChooser/primitives.js +35 -22
- package/lib/module/ui/components/authChooser/primitives.js.map +1 -1
- package/lib/module/ui/components/authChooser/signInProgress.js +5 -0
- package/lib/module/ui/components/authChooser/signInProgress.js.map +1 -1
- package/lib/module/ui/components/authChooser/types.js +11 -0
- package/lib/module/ui/components/authChooser/types.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +251 -303
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +27 -37
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/context/oxyContextHelpers.js +0 -28
- package/lib/module/ui/context/oxyContextHelpers.js.map +1 -1
- package/lib/module/ui/context/useOxyAccountGraph.js +6 -17
- package/lib/module/ui/context/useOxyAccountGraph.js.map +1 -1
- package/lib/module/ui/hooks/accountDialogSnapshot.js +38 -0
- package/lib/module/ui/hooks/accountDialogSnapshot.js.map +1 -0
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +0 -19
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/useDeviceSwitcher.js +53 -0
- package/lib/module/ui/hooks/useDeviceSwitcher.js.map +1 -0
- package/lib/module/ui/hooks/useI18n.js +24 -4
- package/lib/module/ui/hooks/useI18n.js.map +1 -1
- package/lib/module/ui/hooks/useSessionManagement.js +47 -155
- package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/index.js +1 -2
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +84 -72
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/navigation/surfaces.js +6 -6
- package/lib/module/ui/navigation/surfaces.js.map +1 -1
- package/lib/module/ui/runtime/createOxyRuntime.js +430 -0
- package/lib/module/ui/runtime/createOxyRuntime.js.map +1 -0
- package/lib/module/ui/runtime/index.js +15 -0
- package/lib/module/ui/runtime/index.js.map +1 -0
- package/lib/module/ui/runtime/runtimeContext.js +75 -0
- package/lib/module/ui/runtime/runtimeContext.js.map +1 -0
- package/lib/module/ui/runtime/types.js +4 -0
- package/lib/module/ui/runtime/types.js.map +1 -0
- package/lib/module/ui/runtime/useRuntimeSnapshot.js +52 -0
- package/lib/module/ui/runtime/useRuntimeSnapshot.js.map +1 -0
- package/lib/module/ui/screens/AccountMembersScreen.js +4 -5
- package/lib/module/ui/screens/AccountMembersScreen.js.map +1 -1
- package/lib/module/ui/screens/CreateAccountScreen.js +4 -13
- package/lib/module/ui/screens/CreateAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/trust/TrustCenterScreen.js +6 -5
- package/lib/module/ui/screens/trust/TrustCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/trust/TrustLeaderboardScreen.js +5 -5
- package/lib/module/ui/screens/trust/TrustLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/trust/TrustRewardsScreen.js +1 -1
- package/lib/module/ui/screens/trust/TrustRulesScreen.js +4 -2
- package/lib/module/ui/screens/trust/TrustRulesScreen.js.map +1 -1
- package/lib/module/ui/server.js +0 -1
- package/lib/module/ui/server.js.map +1 -1
- package/lib/module/ui/session/authStore.js +46 -11
- package/lib/module/ui/session/authStore.js.map +1 -1
- package/lib/module/ui/session/sharedDeviceCredentialStore.js +302 -0
- package/lib/module/ui/session/sharedDeviceCredentialStore.js.map +1 -0
- package/lib/module/ui/stores/authStore.js +154 -55
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/stores/followTargetStore.js +25 -0
- package/lib/module/ui/stores/followTargetStore.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +2 -35
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +6 -4
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +1 -2
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts +11 -4
- package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts +3 -1
- package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts +18 -6
- package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/authChooser/signInProgress.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts +33 -1
- package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +35 -4
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +8 -12
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/oxyContextHelpers.d.ts +0 -2
- package/lib/typescript/commonjs/ui/context/oxyContextHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +9 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts +1 -3
- package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts +15 -0
- package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useDeviceSwitcher.d.ts +49 -0
- package/lib/typescript/commonjs/ui/hooks/useDeviceSwitcher.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useI18n.d.ts +13 -0
- package/lib/typescript/commonjs/ui/hooks/useI18n.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useSessionManagement.d.ts +23 -18
- package/lib/typescript/commonjs/ui/hooks/useSessionManagement.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/index.d.ts +1 -2
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts +15 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/runtime/createOxyRuntime.d.ts +144 -0
- package/lib/typescript/commonjs/ui/runtime/createOxyRuntime.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/runtime/index.d.ts +16 -0
- package/lib/typescript/commonjs/ui/runtime/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/runtime/runtimeContext.d.ts +43 -0
- package/lib/typescript/commonjs/ui/runtime/runtimeContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/runtime/types.d.ts +89 -0
- package/lib/typescript/commonjs/ui/runtime/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/runtime/useRuntimeSnapshot.d.ts +23 -0
- package/lib/typescript/commonjs/ui/runtime/useRuntimeSnapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/AccountMembersScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/trust/TrustLeaderboardScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/trust/TrustRulesScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/server.d.ts +0 -1
- package/lib/typescript/commonjs/ui/server.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/authStore.d.ts +60 -9
- package/lib/typescript/commonjs/ui/session/authStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts +32 -0
- package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/stores/authStore.d.ts +49 -5
- package/lib/typescript/commonjs/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/stores/followTargetStore.d.ts +8 -1
- package/lib/typescript/commonjs/ui/stores/followTargetStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts +26 -0
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts +2 -10
- package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +6 -4
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +1 -2
- package/lib/typescript/module/ui/client.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/SurfaceScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts +11 -4
- package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts +3 -1
- package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/authChooser/primitives.d.ts +18 -6
- package/lib/typescript/module/ui/components/authChooser/primitives.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/authChooser/signInProgress.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/authChooser/types.d.ts +33 -1
- package/lib/typescript/module/ui/components/authChooser/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts +35 -4
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +8 -12
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/oxyContextHelpers.d.ts +0 -2
- package/lib/typescript/module/ui/context/oxyContextHelpers.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +9 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts +1 -3
- package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts +15 -0
- package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useDeviceSwitcher.d.ts +49 -0
- package/lib/typescript/module/ui/hooks/useDeviceSwitcher.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useI18n.d.ts +13 -0
- package/lib/typescript/module/ui/hooks/useI18n.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts +23 -18
- package/lib/typescript/module/ui/hooks/useSessionManagement.d.ts.map +1 -1
- package/lib/typescript/module/ui/index.d.ts +1 -2
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts +15 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/surfaces.d.ts.map +1 -1
- package/lib/typescript/module/ui/runtime/createOxyRuntime.d.ts +144 -0
- package/lib/typescript/module/ui/runtime/createOxyRuntime.d.ts.map +1 -0
- package/lib/typescript/module/ui/runtime/index.d.ts +16 -0
- package/lib/typescript/module/ui/runtime/index.d.ts.map +1 -0
- package/lib/typescript/module/ui/runtime/runtimeContext.d.ts +43 -0
- package/lib/typescript/module/ui/runtime/runtimeContext.d.ts.map +1 -0
- package/lib/typescript/module/ui/runtime/types.d.ts +89 -0
- package/lib/typescript/module/ui/runtime/types.d.ts.map +1 -0
- package/lib/typescript/module/ui/runtime/useRuntimeSnapshot.d.ts +23 -0
- package/lib/typescript/module/ui/runtime/useRuntimeSnapshot.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/trust/TrustLeaderboardScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/trust/TrustRulesScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/server.d.ts +0 -1
- package/lib/typescript/module/ui/server.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/authStore.d.ts +60 -9
- package/lib/typescript/module/ui/session/authStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts +32 -0
- package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -0
- package/lib/typescript/module/ui/stores/authStore.d.ts +49 -5
- package/lib/typescript/module/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/stores/followTargetStore.d.ts +8 -1
- package/lib/typescript/module/ui/stores/followTargetStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/types/navigation.d.ts +26 -0
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/avatarUtils.d.ts +2 -10
- package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
- package/package.json +8 -8
- package/plugins/withSharedDeviceSessionProvider.js +102 -0
- package/plugins/withSharedDeviceSessionReader.js +57 -0
- package/src/__tests__/esmSourcePurity.test.ts +61 -0
- package/src/index.ts +36 -9
- package/src/ui/boot/runProviderColdBoot.ts +7 -0
- package/src/ui/client.ts +1 -2
- package/src/ui/components/OxyAccountDialogScreen.tsx +10 -29
- package/src/ui/components/OxyAuthChooser.tsx +149 -50
- package/src/ui/components/OxyProvider.tsx +7 -5
- package/src/ui/components/SurfaceScreen.tsx +28 -4
- package/src/ui/components/__tests__/followTargetButton.test.ts +39 -0
- package/src/ui/components/authChooser/AccountsMenuView.tsx +246 -96
- package/src/ui/components/authChooser/SignInEntryView.tsx +31 -8
- package/src/ui/components/authChooser/primitives.tsx +37 -23
- package/src/ui/components/authChooser/signInProgress.ts +4 -0
- package/src/ui/components/authChooser/types.ts +34 -1
- package/src/ui/context/OxyContext.tsx +269 -324
- package/src/ui/context/hooks/useAuthOperations.ts +32 -35
- package/src/ui/context/oxyContextHelpers.ts +0 -30
- package/src/ui/context/oxyContextTypes.ts +9 -1
- package/src/ui/context/useOxyAccountGraph.ts +5 -19
- package/src/ui/hooks/accountDialogSnapshot.ts +37 -0
- package/src/ui/hooks/mutations/useAccountMutations.ts +0 -19
- package/src/ui/hooks/queries/__tests__/userCache.test.ts +12 -1
- package/src/ui/hooks/useDeviceSwitcher.ts +110 -0
- package/src/ui/hooks/useI18n.ts +23 -3
- package/src/ui/hooks/useSessionManagement.ts +62 -211
- package/src/ui/index.ts +1 -2
- package/src/ui/navigation/routes.ts +85 -75
- package/src/ui/navigation/surfaces.ts +6 -9
- package/src/ui/runtime/createOxyRuntime.ts +623 -0
- package/src/ui/runtime/index.ts +34 -0
- package/src/ui/runtime/runtimeContext.tsx +111 -0
- package/src/ui/runtime/types.ts +110 -0
- package/src/ui/runtime/useRuntimeSnapshot.ts +52 -0
- package/src/ui/screens/AccountMembersScreen.tsx +6 -5
- package/src/ui/screens/CreateAccountScreen.tsx +3 -16
- package/src/ui/screens/trust/TrustCenterScreen.tsx +7 -7
- package/src/ui/screens/trust/TrustLeaderboardScreen.tsx +4 -5
- package/src/ui/screens/trust/TrustRewardsScreen.tsx +1 -1
- package/src/ui/screens/trust/TrustRulesScreen.tsx +3 -2
- package/src/ui/server.ts +0 -1
- package/src/ui/session/__tests__/authStore.test.ts +90 -0
- package/src/ui/session/__tests__/sharedDeviceCredentialStore.test.ts +289 -0
- package/src/ui/session/authStore.ts +78 -9
- package/src/ui/session/sharedDeviceCredentialStore.ts +318 -0
- package/src/ui/stores/authStore.ts +171 -43
- package/src/ui/stores/followTargetStore.ts +24 -1
- package/src/ui/types/navigation.ts +26 -0
- package/src/ui/utils/avatarUtils.ts +2 -37
- package/lib/commonjs/ui/hooks/useSwitchableAccounts.js +0 -64
- package/lib/commonjs/ui/hooks/useSwitchableAccounts.js.map +0 -1
- package/lib/commonjs/ui/screens/trust/trustTier.js +0 -23
- package/lib/commonjs/ui/screens/trust/trustTier.js.map +0 -1
- package/lib/commonjs/ui/stores/accountStore.js +0 -221
- package/lib/commonjs/ui/stores/accountStore.js.map +0 -1
- package/lib/module/ui/hooks/useSwitchableAccounts.js +0 -60
- package/lib/module/ui/hooks/useSwitchableAccounts.js.map +0 -1
- package/lib/module/ui/screens/trust/trustTier.js +0 -19
- package/lib/module/ui/screens/trust/trustTier.js.map +0 -1
- package/lib/module/ui/stores/accountStore.js +0 -213
- package/lib/module/ui/stores/accountStore.js.map +0 -1
- package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts +0 -23
- package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/screens/trust/trustTier.d.ts +0 -9
- package/lib/typescript/commonjs/ui/screens/trust/trustTier.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/stores/accountStore.d.ts +0 -27
- package/lib/typescript/commonjs/ui/stores/accountStore.d.ts.map +0 -1
- package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts +0 -23
- package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts.map +0 -1
- package/lib/typescript/module/ui/screens/trust/trustTier.d.ts +0 -9
- package/lib/typescript/module/ui/screens/trust/trustTier.d.ts.map +0 -1
- package/lib/typescript/module/ui/stores/accountStore.d.ts +0 -27
- package/lib/typescript/module/ui/stores/accountStore.d.ts.map +0 -1
- package/src/ui/hooks/useSwitchableAccounts.ts +0 -75
- package/src/ui/screens/trust/trustTier.ts +0 -20
- package/src/ui/stores/accountStore.ts +0 -264
|
@@ -7,20 +7,28 @@ exports.createPlatformAuthStateStore = createPlatformAuthStateStore;
|
|
|
7
7
|
var _core = require("@oxyhq/core");
|
|
8
8
|
var _storageHelpers = require("../utils/storageHelpers.js");
|
|
9
9
|
var _nativeSecureStorage = require("./nativeSecureStorage.js");
|
|
10
|
+
var _sharedDeviceCredentialStore = require("./sharedDeviceCredentialStore.js");
|
|
10
11
|
/**
|
|
11
12
|
* Platform `AuthStateStore` for `@oxyhq/services`.
|
|
12
13
|
*
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
* seam:
|
|
14
|
+
* The device model persists the durable device credential (`deviceId` +
|
|
15
|
+
* `deviceSecret`) per origin (web) / per device (native), and the SDK re-mints
|
|
16
|
+
* the access token from that credential on cold boot. `@oxyhq/core` owns the
|
|
17
|
+
* store shape + logic (`createWebAuthStateStore` / `createNativeAuthStateStore` /
|
|
18
|
+
* `createMemoryAuthStateStore`); this module only selects the seam:
|
|
19
19
|
*
|
|
20
|
+
* - `storage: 'ephemeral'` → `createMemoryAuthStateStore()`, on EVERY platform.
|
|
20
21
|
* - web → `createWebAuthStateStore()` (localStorage, in-memory fallback).
|
|
21
22
|
* - native → `createNativeAuthStateStore(secureKV)` for the SESSION blob over
|
|
22
23
|
* the shared `createNativeSecureKeyValueStorage()` adapter
|
|
23
|
-
* (`expo-secure-store`, AsyncStorage fallback)
|
|
24
|
+
* (`expo-secure-store`, AsyncStorage fallback), WRAPPED so every credential
|
|
25
|
+
* it persists is also mirrored into the device-wide shared slot.
|
|
26
|
+
*
|
|
27
|
+
* The native wrapper is how several official apps end up on ONE `DeviceSession`
|
|
28
|
+
* (and therefore one active context): whichever app proves a credential publishes
|
|
29
|
+
* it, and a later-installed sibling adopts it during cold boot instead of asking
|
|
30
|
+
* for the Commons identity key. The mirror is additive — it can neither change
|
|
31
|
+
* nor fail the app's own durable write.
|
|
24
32
|
*/
|
|
25
33
|
|
|
26
34
|
/**
|
|
@@ -29,11 +37,39 @@ var _nativeSecureStorage = require("./nativeSecureStorage.js");
|
|
|
29
37
|
* Native persists the SESSION blob (`deviceId` + `deviceSecret` + cached access
|
|
30
38
|
* token) per-app in SecureStore; the SDK re-mints the access token from the
|
|
31
39
|
* device credential on the next cold boot.
|
|
40
|
+
*
|
|
41
|
+
* ## The ephemeral check is FIRST, and the order is load-bearing
|
|
42
|
+
*
|
|
43
|
+
* It short-circuits above the `isReactNative()` branch so an ephemeral caller can
|
|
44
|
+
* never reach the native path — and therefore can never reach the shared-slot
|
|
45
|
+
* mirroring wrapper. Checked after that branch instead, an origin that has
|
|
46
|
+
* declined to persist a credential would publish one into the device-wide slot
|
|
47
|
+
* every sibling app adopts on cold boot: it would keep nothing itself while
|
|
48
|
+
* deciding which session five other apps boot into.
|
|
49
|
+
*
|
|
50
|
+
* That is unreachable today because the only ephemeral caller is a web origin, so
|
|
51
|
+
* `isReactNative()` is false there anyway. Unreachable today is exactly the kind
|
|
52
|
+
* of guarantee that stops holding when someone adds the second caller, so it is
|
|
53
|
+
* structural here rather than incidental, and
|
|
54
|
+
* `__tests__/session/authStoreEphemeral.test.ts` holds the ordering directly.
|
|
32
55
|
*/
|
|
33
|
-
function createPlatformAuthStateStore() {
|
|
56
|
+
function createPlatformAuthStateStore(options = {}) {
|
|
57
|
+
// FIRST, above every platform branch — see the docblock for why the ordering
|
|
58
|
+
// is the guarantee and not a coincidence.
|
|
59
|
+
if (options.storage === 'ephemeral') {
|
|
60
|
+
return (0, _core.createMemoryAuthStateStore)();
|
|
61
|
+
}
|
|
34
62
|
if (!(0, _storageHelpers.isReactNative)()) {
|
|
35
63
|
return (0, _core.createWebAuthStateStore)();
|
|
36
64
|
}
|
|
37
|
-
|
|
65
|
+
const local = (0, _core.createNativeAuthStateStore)((0, _nativeSecureStorage.createNativeSecureKeyValueStorage)());
|
|
66
|
+
if (options.sessionMode === 'identity') {
|
|
67
|
+
return local;
|
|
68
|
+
}
|
|
69
|
+
const shared = (0, _sharedDeviceCredentialStore.createPlatformSharedDeviceCredentialStore)();
|
|
70
|
+
return shared ? (0, _core.createSharedMirroringAuthStateStore)({
|
|
71
|
+
local,
|
|
72
|
+
shared
|
|
73
|
+
}) : local;
|
|
38
74
|
}
|
|
39
75
|
//# sourceMappingURL=authStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_core","require","_storageHelpers","_nativeSecureStorage","createPlatformAuthStateStore","isReactNative","createWebAuthStateStore","createNativeAuthStateStore","createNativeSecureKeyValueStorage"],"sourceRoot":"../../../../src","sources":["ui/session/authStore.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["_core","require","_storageHelpers","_nativeSecureStorage","_sharedDeviceCredentialStore","createPlatformAuthStateStore","options","storage","createMemoryAuthStateStore","isReactNative","createWebAuthStateStore","local","createNativeAuthStateStore","createNativeSecureKeyValueStorage","sessionMode","shared","createPlatformSharedDeviceCredentialStore","createSharedMirroringAuthStateStore"],"sourceRoot":"../../../../src","sources":["ui/session/authStore.ts"],"mappings":";;;;;;AAsBA,IAAAA,KAAA,GAAAC,OAAA;AAQA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,4BAAA,GAAAH,OAAA;AAhCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,4BAA4BA,CAC1CC,OAAsC,GAAG,CAAC,CAAC,EAC3B;EAChB;EACA;EACA,IAAIA,OAAO,CAACC,OAAO,KAAK,WAAW,EAAE;IACnC,OAAO,IAAAC,gCAA0B,EAAC,CAAC;EACrC;EAEA,IAAI,CAAC,IAAAC,6BAAa,EAAC,CAAC,EAAE;IACpB,OAAO,IAAAC,6BAAuB,EAAC,CAAC;EAClC;EAEA,MAAMC,KAAK,GAAG,IAAAC,gCAA0B,EAAC,IAAAC,sDAAiC,EAAC,CAAC,CAAC;EAC7E,IAAIP,OAAO,CAACQ,WAAW,KAAK,UAAU,EAAE;IACtC,OAAOH,KAAK;EACd;EACA,MAAMI,MAAM,GAAG,IAAAC,sEAAyC,EAAC,CAAC;EAC1D,OAAOD,MAAM,GAAG,IAAAE,yCAAmC,EAAC;IAAEN,KAAK;IAAEI;EAAO,CAAC,CAAC,GAAGJ,KAAK;AAChF","ignoreList":[]}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SHARED_DEVICE_SESSION_STORAGE_KEY = exports.IOS_KEYCHAIN_ACCESS_GROUP = exports.IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = void 0;
|
|
7
|
+
exports.createPlatformSharedDeviceCredentialStore = createPlatformSharedDeviceCredentialStore;
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _expoModulesCore = require("expo-modules-core");
|
|
10
|
+
var _core = require("@oxyhq/core");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /**
|
|
12
|
+
* The platform half of the shared native DeviceSession credential.
|
|
13
|
+
*
|
|
14
|
+
* `@oxyhq/core` owns the rules (`sharedDeviceCredential.ts`: when to adopt, when
|
|
15
|
+
* to publish, and above all that an unreadable slot is never an empty one). This
|
|
16
|
+
* module owns only where the bytes live, which is genuinely different per
|
|
17
|
+
* platform:
|
|
18
|
+
*
|
|
19
|
+
* - **iOS** — one `expo-secure-store` item in the approved Keychain Access Group
|
|
20
|
+
* `group.so.oxy.shared`, under its OWN `keychainService`
|
|
21
|
+
* ({@link IOS_DEVICE_SESSION_KEYCHAIN_SERVICE}). Every identity slot uses a
|
|
22
|
+
* different service (`oxy_identity`, `oxy_identity_backup`,
|
|
23
|
+
* `oxy_identity_mnemonic`) and the legacy cross-app identity keypair uses the
|
|
24
|
+
* same group with NO service at all — so this item cannot alias any of them.
|
|
25
|
+
* That separation is the point of the whole phase: the group-shared identity
|
|
26
|
+
* key and the group-shared device-session credential are different secrets
|
|
27
|
+
* with different blast radii and must not be conflated.
|
|
28
|
+
* - **Android** — the signature-protected `OxyDeviceSession` broker (its own
|
|
29
|
+
* EncryptedSharedPreferences file, its own ContentProvider, its own
|
|
30
|
+
* `signature`-level permission). It carries a session credential; it can NOT
|
|
31
|
+
* reach the identity keypair, which lives in a different file behind a
|
|
32
|
+
* different provider.
|
|
33
|
+
* - **web / anything else** — no shared slot. Each origin is its own device by
|
|
34
|
+
* design, so the factory returns `null` and the cold boot simply omits the
|
|
35
|
+
* lane.
|
|
36
|
+
*
|
|
37
|
+
* ## What is written here, and what is not
|
|
38
|
+
*
|
|
39
|
+
* Only `{deviceId, deviceSecret}`. No access token, no account id, no user id,
|
|
40
|
+
* and never any identity key material.
|
|
41
|
+
*
|
|
42
|
+
* ## Accessibility
|
|
43
|
+
*
|
|
44
|
+
* `WHEN_UNLOCKED_THIS_DEVICE_ONLY`: a device credential must not travel to
|
|
45
|
+
* another handset in an iCloud/encrypted backup restore — the restored device is
|
|
46
|
+
* a different device and has to establish its own session. It also keeps the item
|
|
47
|
+
* out of reach while the phone is locked, which is why a read can legitimately
|
|
48
|
+
* fail and why the `unavailable` verdict exists at all.
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* The iOS Keychain Access Group every official Oxy app declares in its
|
|
52
|
+
* entitlements. Shared with the identity slots — the group is the app-group
|
|
53
|
+
* boundary, not the secret's identity.
|
|
54
|
+
*/
|
|
55
|
+
const IOS_KEYCHAIN_ACCESS_GROUP = exports.IOS_KEYCHAIN_ACCESS_GROUP = 'group.so.oxy.shared';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The iOS `keychainService` for the DEVICE SESSION credential. Deliberately
|
|
59
|
+
* distinct from every identity and recovery service; do not reuse one of those
|
|
60
|
+
* here, and do not drop it (an item written with no service shares the legacy
|
|
61
|
+
* identity slot's namespace inside the group).
|
|
62
|
+
*/
|
|
63
|
+
const IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = exports.IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = 'oxy_device_session';
|
|
64
|
+
|
|
65
|
+
/** The single key holding the JSON-encoded `{deviceId, deviceSecret}` pair. */
|
|
66
|
+
const SHARED_DEVICE_SESSION_STORAGE_KEY = exports.SHARED_DEVICE_SESSION_STORAGE_KEY = 'oxy_shared_device_session_v1';
|
|
67
|
+
|
|
68
|
+
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
69
|
+
// into the web bundle; the module is native-only and optional.
|
|
70
|
+
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The subset of `expo-secure-store` this module needs. Unlike the adapter in
|
|
74
|
+
* `nativeSecureStorage.ts` it must pass OPTIONS — the access group and the
|
|
75
|
+
* dedicated service are the entire mechanism here, so an options-less wrapper
|
|
76
|
+
* would silently write a package-private item that no sibling app can see.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
let keychainStorePromise = null;
|
|
80
|
+
function loadKeychainGroupStore() {
|
|
81
|
+
if (!keychainStorePromise) {
|
|
82
|
+
const moduleName = SECURE_STORE_MODULE;
|
|
83
|
+
keychainStorePromise = (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(moduleName).then(mod => {
|
|
84
|
+
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function' && typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number') {
|
|
85
|
+
return {
|
|
86
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
87
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
88
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
89
|
+
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}).catch(() => null);
|
|
94
|
+
}
|
|
95
|
+
return keychainStorePromise;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Parse the stored JSON into a credential, or `null` for anything malformed. */
|
|
99
|
+
function parseStoredCredential(raw) {
|
|
100
|
+
if (!raw) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
let parsed;
|
|
104
|
+
try {
|
|
105
|
+
parsed = JSON.parse(raw);
|
|
106
|
+
} catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const candidate = parsed;
|
|
113
|
+
if (typeof candidate.deviceId !== 'string' || candidate.deviceId.length === 0 || typeof candidate.deviceSecret !== 'string' || candidate.deviceSecret.length === 0) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
deviceId: candidate.deviceId,
|
|
118
|
+
deviceSecret: candidate.deviceSecret
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The iOS store: one keychain item in the shared access group.
|
|
124
|
+
*
|
|
125
|
+
* A THROWN read is `unavailable`, a `null` read is `absent`. That mapping is the
|
|
126
|
+
* whole safety contract — `expo-secure-store` returns `null` for a genuinely
|
|
127
|
+
* missing item and throws when the keychain itself refuses, and collapsing the
|
|
128
|
+
* two is what would let a locked phone look like a device that never had a
|
|
129
|
+
* session.
|
|
130
|
+
*/
|
|
131
|
+
function createKeychainGroupCredentialStore() {
|
|
132
|
+
const readOptions = {
|
|
133
|
+
keychainService: IOS_DEVICE_SESSION_KEYCHAIN_SERVICE,
|
|
134
|
+
keychainAccessGroup: IOS_KEYCHAIN_ACCESS_GROUP
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
read: async () => {
|
|
138
|
+
const store = await loadKeychainGroupStore();
|
|
139
|
+
if (!store) {
|
|
140
|
+
return {
|
|
141
|
+
state: 'unsupported'
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
let raw;
|
|
145
|
+
try {
|
|
146
|
+
raw = await store.getItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, readOptions);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return {
|
|
149
|
+
state: 'unavailable',
|
|
150
|
+
cause: error
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (raw === null) {
|
|
154
|
+
return {
|
|
155
|
+
state: 'absent'
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const credential = parseStoredCredential(raw);
|
|
159
|
+
if (!credential) {
|
|
160
|
+
// Something IS stored and we cannot read it. Reporting `absent` would
|
|
161
|
+
// authorise overwriting whatever a newer build put there.
|
|
162
|
+
return {
|
|
163
|
+
state: 'unavailable',
|
|
164
|
+
cause: new Error('shared device session item is present but not parseable')
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
state: 'present',
|
|
169
|
+
credential
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
publish: async credential => {
|
|
173
|
+
const store = await loadKeychainGroupStore();
|
|
174
|
+
if (!store) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
const value = JSON.stringify(credential);
|
|
178
|
+
try {
|
|
179
|
+
await store.setItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, value, {
|
|
180
|
+
...readOptions,
|
|
181
|
+
keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
182
|
+
});
|
|
183
|
+
// Read-back verify. A keychain write can resolve without the item having
|
|
184
|
+
// landed under the access group (a missing entitlement is the usual
|
|
185
|
+
// cause), and a phantom credential would send a fresh install into a mint
|
|
186
|
+
// that can never succeed.
|
|
187
|
+
return (await store.getItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, readOptions)) === value;
|
|
188
|
+
} catch {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
clear: async () => {
|
|
193
|
+
const store = await loadKeychainGroupStore();
|
|
194
|
+
if (!store) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
await store.deleteItemAsync(SHARED_DEVICE_SESSION_STORAGE_KEY, readOptions);
|
|
199
|
+
} catch {
|
|
200
|
+
// Best-effort: the slot is a join point, not a source of truth.
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The Android broker's JS surface. `read` returns an UNTRUSTED payload that
|
|
208
|
+
* {@link normalizeSharedDeviceSessionRead} narrows; `write` reports whether the
|
|
209
|
+
* native read-back confirmed the bytes.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
let brokerModule;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Resolve the `OxyDeviceSession` broker, or `null` when it is not autolinked.
|
|
216
|
+
*
|
|
217
|
+
* `requireOptionalNativeModule` (a static import Metro always resolves) rather
|
|
218
|
+
* than a dynamic `import(moduleName)`: the latter compiles to `require(variable)`
|
|
219
|
+
* in the CJS build, which Metro cannot resolve inside a consuming app — it
|
|
220
|
+
* silently returns `null` there, which is exactly how the cross-app identity
|
|
221
|
+
* bridge broke once. Same reasoning as `backgroundSession.ts` next door.
|
|
222
|
+
*/
|
|
223
|
+
function loadBrokerModule() {
|
|
224
|
+
if (brokerModule === undefined) {
|
|
225
|
+
const native = (0, _expoModulesCore.requireOptionalNativeModule)('OxyDeviceSession');
|
|
226
|
+
brokerModule = native && typeof native.read === 'function' && typeof native.write === 'function' && typeof native.clear === 'function' ? {
|
|
227
|
+
read: native.read.bind(native),
|
|
228
|
+
write: native.write.bind(native),
|
|
229
|
+
clear: native.clear.bind(native)
|
|
230
|
+
} : null;
|
|
231
|
+
}
|
|
232
|
+
return brokerModule;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The Android store: the signature-protected `OxyDeviceSession` broker.
|
|
237
|
+
*
|
|
238
|
+
* The broker already answers with an explicit status, so the only work here is
|
|
239
|
+
* narrowing an UNTRUSTED payload — `normalizeSharedDeviceSessionRead` resolves
|
|
240
|
+
* anything it does not recognise to `unavailable`, never `absent`.
|
|
241
|
+
*/
|
|
242
|
+
function createBrokerCredentialStore() {
|
|
243
|
+
return {
|
|
244
|
+
read: async () => {
|
|
245
|
+
const broker = loadBrokerModule();
|
|
246
|
+
if (!broker) {
|
|
247
|
+
return {
|
|
248
|
+
state: 'unsupported'
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
return (0, _core.normalizeSharedDeviceSessionRead)(await broker.read());
|
|
253
|
+
} catch (error) {
|
|
254
|
+
return {
|
|
255
|
+
state: 'unavailable',
|
|
256
|
+
cause: error
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
publish: async credential => {
|
|
261
|
+
const broker = loadBrokerModule();
|
|
262
|
+
if (!broker) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
// The broker read-back-verifies natively and returns the verdict.
|
|
267
|
+
return await broker.write(credential.deviceId, credential.deviceSecret);
|
|
268
|
+
} catch {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
clear: async () => {
|
|
273
|
+
const broker = loadBrokerModule();
|
|
274
|
+
if (!broker) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
await broker.clear();
|
|
279
|
+
} catch {
|
|
280
|
+
// Best-effort — see the iOS store.
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The shared DeviceSession credential slot for this runtime, or `null` when
|
|
288
|
+
* there is none.
|
|
289
|
+
*
|
|
290
|
+
* The branch is on the PLATFORM, not on which module happens to load, because
|
|
291
|
+
* `expo-secure-store` loads perfectly well on Android — it would just quietly
|
|
292
|
+
* ignore `keychainAccessGroup` and read a package-private item, which looks
|
|
293
|
+
* exactly like an empty shared slot. This is the same iOS-vs-Android split
|
|
294
|
+
* `KeyManager` makes for the shared identity, for the same reason.
|
|
295
|
+
*
|
|
296
|
+
* Any other native platform gets the broker, which answers `unsupported` when
|
|
297
|
+
* the module is not linked — so the lane is simply off, which is the safe
|
|
298
|
+
* direction.
|
|
299
|
+
*/
|
|
300
|
+
function createPlatformSharedDeviceCredentialStore() {
|
|
301
|
+
if (_reactNative.Platform.OS === 'web') {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
return _reactNative.Platform.OS === 'ios' ? createKeychainGroupCredentialStore() : createBrokerCredentialStore();
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=sharedDeviceCredentialStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_expoModulesCore","_core","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IOS_KEYCHAIN_ACCESS_GROUP","exports","IOS_DEVICE_SESSION_KEYCHAIN_SERVICE","SHARED_DEVICE_SESSION_STORAGE_KEY","SECURE_STORE_MODULE","keychainStorePromise","loadKeychainGroupStore","moduleName","specifier","Promise","then","s","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","requireOptionalNativeModule","write","createBrokerCredentialStore","broker","normalizeSharedDeviceSessionRead","createPlatformSharedDeviceCredentialStore","Platform","OS"],"sourceRoot":"../../../../src","sources":["ui/session/sharedDeviceCredentialStore.ts"],"mappings":";;;;;;;AAuCA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKqB,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA,KA9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EAAED;QAAM,CAAC;MAC/C;IACF,CAAC;IAEDI,OAAO,EAAE,MAAOF,UAAU,IAAuB;MAC/C,MAAMc,MAAM,GAAGN,gBAAgB,CAAC,CAAC;MACjC,IAAI,CAACM,MAAM,EAAE;QACX,OAAO,KAAK;MACd;MACA,IAAI;QACF;QACA,OAAO,MAAMA,MAAM,CAACF,KAAK,CAACZ,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,MAAMQ,MAAM,GAAGN,gBAAgB,CAAC,CAAC;MACjC,IAAI,CAACM,MAAM,EAAE;QACX;MACF;MACA,IAAI;QACF,MAAMA,MAAM,CAACR,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;AACO,SAASU,yCAAyCA,CAAA,EAAuC;EAC9F,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO,IAAI;EACb;EACA,OAAOD,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG3B,kCAAkC,CAAC,CAAC,GAAGsB,2BAA2B,CAAC,CAAC;AACrG","ignoreList":[]}
|
|
@@ -3,68 +3,167 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.bindAuthStoreToRuntime = bindAuthStoreToRuntime;
|
|
6
7
|
exports.useAuthStore = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* The signed-in user, as a zustand-shaped read/write surface.
|
|
11
|
+
*
|
|
12
|
+
* It used to BE a zustand store, and that made it a second owner of the
|
|
13
|
+
* session: the provider wrote `user`/`isAuthenticated` here, `SessionClient`
|
|
14
|
+
* wrote the same facts into its device state, and nothing reconciled them —
|
|
15
|
+
* when they disagreed, which one was right was not answerable. It is now a
|
|
16
|
+
* projection of the ONE `OxyRuntime` (ADR 0004): reads come off the runtime
|
|
17
|
+
* snapshot and writes go into the runtime, so there is nothing left to drift.
|
|
18
|
+
*
|
|
19
|
+
* The zustand SHAPE is kept deliberately — `useAuthStore(selector)`,
|
|
20
|
+
* `.getState()`, `.setState()`, `.subscribe()` — because a dozen call sites
|
|
21
|
+
* across this package and the Commons app read the user out of band, from
|
|
22
|
+
* mutation success handlers and cache helpers that are not inside a render.
|
|
23
|
+
* Rewriting them is Phase 8's cut, not this one's.
|
|
24
|
+
*
|
|
25
|
+
* `fetchUser` and `lastUserFetch` are GONE rather than projected: they were a
|
|
26
|
+
* five-minute profile cache with zero readers anywhere in the monorepo, and the
|
|
27
|
+
* Query cache has owned that job since long before this change.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** The subset of `AuthState` a caller may push back in through `setState`. */
|
|
31
|
+
|
|
32
|
+
let boundRuntime = null;
|
|
33
|
+
let unbindRuntime = null;
|
|
34
|
+
const listeners = new Set();
|
|
35
|
+
const loginSuccess = user => {
|
|
36
|
+
boundRuntime?.setAccount(user);
|
|
37
|
+
};
|
|
38
|
+
const loginFailure = error => {
|
|
39
|
+
boundRuntime?.batch(() => {
|
|
40
|
+
boundRuntime?.setLoading(false);
|
|
41
|
+
boundRuntime?.setError(error);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const logout = () => {
|
|
45
|
+
boundRuntime?.clearSession();
|
|
46
|
+
};
|
|
47
|
+
const setUser = user => {
|
|
48
|
+
boundRuntime?.setAccount(user);
|
|
49
|
+
};
|
|
50
|
+
const SIGNED_OUT = Object.freeze({
|
|
11
51
|
user: null,
|
|
12
52
|
isAuthenticated: false,
|
|
13
53
|
isLoading: false,
|
|
14
54
|
error: null,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
user:
|
|
28
|
-
isAuthenticated:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
loginSuccess,
|
|
56
|
+
loginFailure,
|
|
57
|
+
logout,
|
|
58
|
+
setUser
|
|
59
|
+
});
|
|
60
|
+
let state = SIGNED_OUT;
|
|
61
|
+
function project(runtime) {
|
|
62
|
+
if (runtime === null) {
|
|
63
|
+
return SIGNED_OUT;
|
|
64
|
+
}
|
|
65
|
+
const snapshot = runtime.getSnapshot();
|
|
66
|
+
return Object.freeze({
|
|
67
|
+
user: snapshot.account,
|
|
68
|
+
isAuthenticated: snapshot.account !== null,
|
|
69
|
+
isLoading: snapshot.isLoading,
|
|
70
|
+
error: snapshot.error?.message ?? null,
|
|
71
|
+
loginSuccess,
|
|
72
|
+
loginFailure,
|
|
73
|
+
logout,
|
|
74
|
+
setUser
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function republish() {
|
|
78
|
+
const next = project(boundRuntime);
|
|
79
|
+
if (next.user === state.user && next.isAuthenticated === state.isAuthenticated && next.isLoading === state.isLoading && next.error === state.error) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
state = next;
|
|
83
|
+
for (const listener of [...listeners]) {
|
|
84
|
+
listener();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
40
87
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Point this surface at the provider's runtime. Called once by
|
|
90
|
+
* `OxyRuntimeProvider`; the returned function detaches it again on unmount.
|
|
91
|
+
*
|
|
92
|
+
* With nothing bound, reads answer signed-out and writes are dropped. That is
|
|
93
|
+
* the honest answer for the two places it happens — the SSR shim, and a unit
|
|
94
|
+
* test poking the store with no provider mounted — and it is why binding is an
|
|
95
|
+
* explicit call rather than a lazily-created default runtime, which is exactly
|
|
96
|
+
* the fabricated-forever-loading runtime ADR 0004 deleted.
|
|
97
|
+
*/
|
|
98
|
+
function bindAuthStoreToRuntime(runtime) {
|
|
99
|
+
unbindRuntime?.();
|
|
100
|
+
boundRuntime = runtime;
|
|
101
|
+
unbindRuntime = runtime.subscribe(republish);
|
|
102
|
+
republish();
|
|
103
|
+
return () => {
|
|
104
|
+
if (boundRuntime !== runtime) {
|
|
46
105
|
return;
|
|
47
106
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
} catch (error) {
|
|
61
|
-
const errorMessage = error instanceof Error ? error.message : 'Failed to fetch user';
|
|
62
|
-
log.error('Error fetching user', error);
|
|
63
|
-
set({
|
|
64
|
-
error: errorMessage,
|
|
65
|
-
isLoading: false
|
|
66
|
-
});
|
|
107
|
+
unbindRuntime?.();
|
|
108
|
+
unbindRuntime = null;
|
|
109
|
+
boundRuntime = null;
|
|
110
|
+
republish();
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const getState = () => state;
|
|
114
|
+
const setState = patch => {
|
|
115
|
+
boundRuntime?.batch(() => {
|
|
116
|
+
if (patch.isLoading !== undefined) {
|
|
117
|
+
boundRuntime?.setLoading(patch.isLoading);
|
|
67
118
|
}
|
|
68
|
-
|
|
69
|
-
|
|
119
|
+
if (patch.error !== undefined) {
|
|
120
|
+
boundRuntime?.setError(patch.error);
|
|
121
|
+
}
|
|
122
|
+
if (patch.user !== undefined) {
|
|
123
|
+
if (patch.user === null) {
|
|
124
|
+
boundRuntime?.clearSession();
|
|
125
|
+
} else {
|
|
126
|
+
boundRuntime?.setAccount(patch.user);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const subscribe = listener => {
|
|
132
|
+
listeners.add(listener);
|
|
133
|
+
return () => {
|
|
134
|
+
listeners.delete(listener);
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
function useAuthStoreHook(selector) {
|
|
138
|
+
// The selection is cached against the state object it came from, so a
|
|
139
|
+
// selector returning a fresh object cannot make `useSyncExternalStore` see a
|
|
140
|
+
// new value on every call and loop.
|
|
141
|
+
const cache = (0, _react.useRef)(null);
|
|
142
|
+
const getSelection = (0, _react.useCallback)(() => {
|
|
143
|
+
const cached = cache.current;
|
|
144
|
+
if (cached !== null && cached.state === state) {
|
|
145
|
+
return cached.value;
|
|
146
|
+
}
|
|
147
|
+
const value = selector(state);
|
|
148
|
+
cache.current = {
|
|
149
|
+
state,
|
|
150
|
+
value
|
|
151
|
+
};
|
|
152
|
+
return value;
|
|
153
|
+
}, [selector]);
|
|
154
|
+
return (0, _react.useSyncExternalStore)(subscribe, getSelection, getSelection);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Read the signed-in user. Zustand-shaped, projected from the runtime.
|
|
159
|
+
*
|
|
160
|
+
* A selector that builds an object must be wrapped in `useShallow` (as every
|
|
161
|
+
* call site here already does) — otherwise a structurally-equal result reads as
|
|
162
|
+
* a change on every publish.
|
|
163
|
+
*/
|
|
164
|
+
const useAuthStore = exports.useAuthStore = Object.assign(useAuthStoreHook, {
|
|
165
|
+
getState,
|
|
166
|
+
setState,
|
|
167
|
+
subscribe
|
|
168
|
+
});
|
|
70
169
|
//# sourceMappingURL=authStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_react","require","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","useRef","getSelection","useCallback","cached","current","value","useSyncExternalStore","useAuthStore","exports","assign"],"sourceRoot":"../../../../src","sources":["ui/stores/authStore.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA;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;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