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