@oxyhq/services 16.0.0 → 18.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/README.md +77 -98
- package/lib/commonjs/index.js +40 -51
- 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 +742 -0
- package/lib/commonjs/ui/components/OxyAccountDialog.js.map +1 -0
- package/lib/commonjs/ui/components/OxyConsentScreen.js +461 -0
- package/lib/commonjs/ui/components/OxyConsentScreen.js.map +1 -0
- package/lib/commonjs/ui/components/OxyProvider.js +13 -6
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/OxySignInButton.js +180 -22
- 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/components/oauthNavigation.js +73 -0
- package/lib/commonjs/ui/components/oauthNavigation.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +122 -4
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +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/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 +19 -16
- 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 +739 -0
- package/lib/module/ui/components/OxyAccountDialog.js.map +1 -0
- package/lib/module/ui/components/OxyConsentScreen.js +454 -0
- package/lib/module/ui/components/OxyConsentScreen.js.map +1 -0
- package/lib/module/ui/components/OxyProvider.js +13 -6
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/OxySignInButton.js +181 -22
- 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/components/oauthNavigation.js +70 -0
- package/lib/module/ui/components/oauthNavigation.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +123 -5
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +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/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 +8 -12
- 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 +51 -0
- package/lib/typescript/commonjs/ui/components/OxyAccountDialog.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts +45 -0
- package/lib/typescript/commonjs/ui/components/OxyConsentScreen.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 +56 -0
- 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/components/oauthNavigation.d.ts +36 -0
- package/lib/typescript/commonjs/ui/components/oauthNavigation.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +27 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.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/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 +27 -0
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +8 -12
- 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 +51 -0
- package/lib/typescript/module/ui/components/OxyAccountDialog.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts +45 -0
- package/lib/typescript/module/ui/components/OxyConsentScreen.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 +56 -0
- 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/components/oauthNavigation.d.ts +36 -0
- package/lib/typescript/module/ui/components/oauthNavigation.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts +27 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.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/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 +27 -0
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +33 -27
- package/src/ui/client.ts +0 -4
- package/src/ui/components/OxyAccountDialog.tsx +735 -0
- package/src/ui/components/OxyConsentScreen.tsx +456 -0
- package/src/ui/components/OxyProvider.tsx +14 -6
- package/src/ui/components/OxySignInButton.tsx +227 -22
- package/src/ui/components/ProfileButton.tsx +23 -126
- package/src/ui/components/RequireOxyAuth.tsx +266 -0
- package/src/ui/components/__tests__/OxyConsentScreen.test.tsx +130 -0
- package/src/ui/components/oauthNavigation.ts +89 -0
- package/src/ui/context/OxyContext.tsx +176 -9
- package/src/ui/context/__tests__/OxyContext.coldBoot.test.tsx +165 -0
- package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
- 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 +0 -4
- package/src/ui/screens/ManageAccountScreen.tsx +3 -2
- package/src/ui/session/createSessionClient.ts +9 -1
- package/src/ui/types/navigation.ts +27 -0
- 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,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAgC,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAO,uBAAAE,CAAA,WA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AACF,CAAC,CAAC;AAAC,IAAAE,QAAA,GAAAtE,OAAA,CAAA3B,OAAA,GAEYK,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.openAuthorizeUrlNative = openAuthorizeUrlNative;
|
|
7
|
+
exports.redirectToAuthorize = redirectToAuthorize;
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _core = require("@oxyhq/core");
|
|
10
|
+
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); } /**
|
|
11
|
+
* Platform navigation for the third-party "Sign in with Oxy" OAuth flow.
|
|
12
|
+
*
|
|
13
|
+
* Kept out of `OxySignInButton` so the button's routing logic can be unit-tested
|
|
14
|
+
* without driving a real browser navigation (jsdom's `location.assign` is
|
|
15
|
+
* non-configurable and cannot be spied). Both entry points hand a fully-built
|
|
16
|
+
* `auth.oxy.so/authorize` URL to the platform — never FedCM, an SSO bounce, or
|
|
17
|
+
* an Oxy session cookie.
|
|
18
|
+
*/
|
|
19
|
+
/** Minimal shape of the optional `expo-web-browser` auth-session result. */
|
|
20
|
+
|
|
21
|
+
/** Minimal shape of the optional `expo-web-browser` native module we depend on. */
|
|
22
|
+
|
|
23
|
+
/** Outcome of opening the authorize URL on native. */
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Web: hand the TOP-LEVEL document to the OAuth authorize URL (a full-page
|
|
27
|
+
* redirect, not a popup) so the RP returns to its registered `redirect_uri`.
|
|
28
|
+
* No-op where `location` is unavailable (SSR / non-browser hosts).
|
|
29
|
+
*/
|
|
30
|
+
function redirectToAuthorize(url) {
|
|
31
|
+
globalThis.location?.assign(url);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Native: open the authorize URL in an in-app auth session via the optional
|
|
36
|
+
* `expo-web-browser` module (`openAuthSessionAsync` returns to `redirectUri`),
|
|
37
|
+
* degrading to `Linking.openURL` when the module is not installed — the same
|
|
38
|
+
* dynamic-import-with-fallback pattern services uses for haptics/netinfo.
|
|
39
|
+
*
|
|
40
|
+
* Returns the deep-link URL the session came back to when it can be observed, so
|
|
41
|
+
* the caller can hand `?code=…&state=…` back to the RP for the token exchange.
|
|
42
|
+
*/
|
|
43
|
+
async function openAuthorizeUrlNative(url, redirectUri) {
|
|
44
|
+
try {
|
|
45
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-web-browser')));
|
|
46
|
+
if (mod && typeof mod.openAuthSessionAsync === 'function') {
|
|
47
|
+
const result = await mod.openAuthSessionAsync(url, redirectUri);
|
|
48
|
+
const redirectUrl = result && result.type === 'success' && typeof result.url === 'string' ? result.url : null;
|
|
49
|
+
return {
|
|
50
|
+
redirectUrl
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
_core.logger.warn('OxySignInButton: expo-web-browser auth session failed; falling back to Linking.openURL', {
|
|
55
|
+
component: 'oauthNavigation'
|
|
56
|
+
}, error);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Fallback: Linking cannot observe the return URL, so the RP completes the
|
|
60
|
+
// exchange from its own deep-link handler. A rejected openURL (e.g. an
|
|
61
|
+
// unregistered scheme) must not throw out of the sign-in flow.
|
|
62
|
+
try {
|
|
63
|
+
await _reactNative.Linking.openURL(url);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
_core.logger.warn('OxySignInButton: Linking.openURL rejected the authorize URL', {
|
|
66
|
+
component: 'oauthNavigation'
|
|
67
|
+
}, error);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
redirectUrl: null
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=oauthNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_core","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","redirectToAuthorize","url","globalThis","location","assign","openAuthorizeUrlNative","redirectUri","mod","Promise","resolve","then","openAuthSessionAsync","result","redirectUrl","type","error","logger","warn","component","Linking","openURL"],"sourceRoot":"../../../../src","sources":["ui/components/oauthNavigation.ts"],"mappings":";;;;;;;AAUA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAqC,SAAAE,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,CA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ChCH,KACJ,CAAC;EACL;;EAEA;EACA;EACA;EACA,IAAI;IACA,MAAMI,oBAAO,CAACC,OAAO,CAACnB,GAAG,CAAC;EAC9B,CAAC,CAAC,OAAOc,KAAK,EAAE;IACZC,YAAM,CAACC,IAAI,CACP,6DAA6D,EAC7D;MAAEC,SAAS,EAAE;IAAkB,CAAC,EAChCH,KACJ,CAAC;EACL;EACA,OAAO;IAAEF,WAAW,EAAE;EAAK,CAAC;AAChC","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");
|
|
@@ -116,6 +118,7 @@ const OxyProvider = ({
|
|
|
116
118
|
authRedirectUri,
|
|
117
119
|
storageKeyPrefix = 'oxy_session',
|
|
118
120
|
clientId: clientIdProp,
|
|
121
|
+
coldBoot = true,
|
|
119
122
|
onAuthStateChange,
|
|
120
123
|
onError
|
|
121
124
|
}) => {
|
|
@@ -171,6 +174,7 @@ const OxyProvider = ({
|
|
|
171
174
|
userRef.current = user;
|
|
172
175
|
isAuthenticatedRef.current = isAuthenticated;
|
|
173
176
|
const [initialized, setInitialized] = (0, _react.useState)(false);
|
|
177
|
+
const [accountDialogOpen, setAccountDialogOpen] = (0, _react.useState)(false);
|
|
174
178
|
const setAuthState = _authStore.useAuthStore.setState;
|
|
175
179
|
|
|
176
180
|
// Keep the shared `oxyClient` singleton's token store in lockstep with the
|
|
@@ -311,10 +315,19 @@ const OxyProvider = ({
|
|
|
311
315
|
const markAuthResolvedRef = (0, _react.useRef)(markAuthResolved);
|
|
312
316
|
markAuthResolvedRef.current = markAuthResolved;
|
|
313
317
|
|
|
318
|
+
// Re-boot indirection: the SessionClient is built in the ref initializer below
|
|
319
|
+
// (before `runColdBoot` is defined), but its `onSessionAppeared` must re-run the
|
|
320
|
+
// cold boot to self-acquire when a sibling signs in on this device. A ref bridges
|
|
321
|
+
// the ordering; it is assigned right after `runColdBoot` is declared.
|
|
322
|
+
const runColdBootRef = (0, _react.useRef)(null);
|
|
323
|
+
|
|
314
324
|
// Server-authoritative device session client. Built ONCE per `oxyServices`
|
|
315
325
|
// instance. `onUnauthenticated` (a device signout-all pushed over the socket,
|
|
316
326
|
// or bootstrapped as zero-account) clears the persisted store + local state so
|
|
317
327
|
// a reload does not try to restore a session the device no longer has.
|
|
328
|
+
// `signedOutSocketAuth` + `onSessionAppeared` power the signed-out sync channel:
|
|
329
|
+
// an idle tab joins its `device:<id>` room (web via the `oxy_device` cookie,
|
|
330
|
+
// native via the shared device token) and self-acquires on a sibling sign-in.
|
|
318
331
|
const sessionClientPairRef = (0, _react.useRef)(null);
|
|
319
332
|
if (!sessionClientPairRef.current) {
|
|
320
333
|
sessionClientPairRef.current = (0, _index.createSessionClient)(oxyServices, authStore, () => {
|
|
@@ -322,6 +335,21 @@ const OxyProvider = ({
|
|
|
322
335
|
void clearSessionStateRef.current().catch(clearError => {
|
|
323
336
|
logger('Failed to clear local state on remote sign-out', clearError);
|
|
324
337
|
});
|
|
338
|
+
}, {
|
|
339
|
+
signedOutSocketAuth: async () => {
|
|
340
|
+
// Web (`*.oxy.so`): the first-party `oxy_device` cookie rides the
|
|
341
|
+
// same-site handshake automatically — just connect.
|
|
342
|
+
if ((0, _isWebBrowser.isWebBrowser)()) return true;
|
|
343
|
+
// Native (no cookie jar): present the shared device token if we have one.
|
|
344
|
+
try {
|
|
345
|
+
return (await authStore.loadDeviceToken()) ?? false;
|
|
346
|
+
} catch {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
onSessionAppeared: () => {
|
|
351
|
+
void runColdBootRef.current?.();
|
|
352
|
+
}
|
|
325
353
|
});
|
|
326
354
|
}
|
|
327
355
|
const {
|
|
@@ -601,6 +629,58 @@ const OxyProvider = ({
|
|
|
601
629
|
});
|
|
602
630
|
}, [commitSession]);
|
|
603
631
|
|
|
632
|
+
// ── Unified account dialog ─────────────────────────────────────────────────
|
|
633
|
+
// The single account-chooser + sign-in surface. Built ONCE per provider mount
|
|
634
|
+
// and bound to the live `oxyServices` + `sessionClient` + this provider's
|
|
635
|
+
// `handleWebSession` commit funnel. `handleWebSession` is threaded through a ref
|
|
636
|
+
// so the controller keeps a STABLE `commitSession` (rebuilding the controller
|
|
637
|
+
// on every commit-identity change would drop its subscription + state).
|
|
638
|
+
const handleWebSessionRef = (0, _react.useRef)(handleWebSession);
|
|
639
|
+
handleWebSessionRef.current = handleWebSession;
|
|
640
|
+
const accountDialogControllerRef = (0, _react.useRef)(null);
|
|
641
|
+
if (!accountDialogControllerRef.current) {
|
|
642
|
+
accountDialogControllerRef.current = (0, _core.createAccountDialogController)({
|
|
643
|
+
oxyServices,
|
|
644
|
+
sessionClient,
|
|
645
|
+
clientId,
|
|
646
|
+
locale: currentLanguage,
|
|
647
|
+
commitSession: session => handleWebSessionRef.current(session),
|
|
648
|
+
onSignedIn: () => setAccountDialogOpen(false),
|
|
649
|
+
openUrl: url => {
|
|
650
|
+
void _reactNative.Linking.openURL(url);
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
const accountDialogController = accountDialogControllerRef.current;
|
|
655
|
+
const openAccountDialog = (0, _react.useCallback)(view => {
|
|
656
|
+
accountDialogControllerRef.current?.setView(view ?? 'accounts');
|
|
657
|
+
setAccountDialogOpen(true);
|
|
658
|
+
}, []);
|
|
659
|
+
const closeAccountDialog = (0, _react.useCallback)(() => {
|
|
660
|
+
accountDialogControllerRef.current?.cancelSignIn();
|
|
661
|
+
setAccountDialogOpen(false);
|
|
662
|
+
}, []);
|
|
663
|
+
|
|
664
|
+
// Start driving the dialog on mount; tear it down on unmount.
|
|
665
|
+
(0, _react.useEffect)(() => {
|
|
666
|
+
const controller = accountDialogControllerRef.current;
|
|
667
|
+
controller?.start();
|
|
668
|
+
return () => controller?.destroy();
|
|
669
|
+
}, []);
|
|
670
|
+
|
|
671
|
+
// Expose the live open/close controls to the imperative manager so
|
|
672
|
+
// `showSignInModal()` (and any app-level imperative "sign in" handler) works.
|
|
673
|
+
(0, _react.useEffect)(() => (0, _accountDialogManager.registerAccountDialogControls)({
|
|
674
|
+
open: openAccountDialog,
|
|
675
|
+
close: closeAccountDialog
|
|
676
|
+
}), [openAccountDialog, closeAccountDialog]);
|
|
677
|
+
|
|
678
|
+
// Broadcast visibility so `OxySignInButton`'s "Signing in…" affordance stays
|
|
679
|
+
// accurate regardless of what opened or dismissed the dialog.
|
|
680
|
+
(0, _react.useEffect)(() => {
|
|
681
|
+
(0, _accountDialogManager.notifyAccountDialogVisibility)(accountDialogOpen);
|
|
682
|
+
}, [accountDialogOpen]);
|
|
683
|
+
|
|
604
684
|
// Keyless password sign-in: username/email + password.
|
|
605
685
|
const signInWithPassword = (0, _react.useCallback)(async (identifier, password, opts) => {
|
|
606
686
|
const deviceToken = (await authStore.loadDeviceToken()) ?? undefined;
|
|
@@ -695,6 +775,17 @@ const OxyProvider = ({
|
|
|
695
775
|
},
|
|
696
776
|
onSignedOut: () => {
|
|
697
777
|
markAuthResolvedRef.current();
|
|
778
|
+
// Open the signed-out realtime channel so this idle tab joins its
|
|
779
|
+
// `device:<id>` room (web `oxy_device` cookie / native device token)
|
|
780
|
+
// and self-acquires when a sibling signs in. Idempotent, best-effort.
|
|
781
|
+
void sessionClient.start().catch(startError => {
|
|
782
|
+
if (__DEV__) {
|
|
783
|
+
_core.logger.debug('signed-out socket start failed (non-fatal)', {
|
|
784
|
+
component: 'OxyContext',
|
|
785
|
+
method: 'runColdBoot'
|
|
786
|
+
}, startError);
|
|
787
|
+
}
|
|
788
|
+
});
|
|
698
789
|
},
|
|
699
790
|
onStepError: (id, error) => {
|
|
700
791
|
if (__DEV__) {
|
|
@@ -716,9 +807,25 @@ const OxyProvider = ({
|
|
|
716
807
|
// Backstop: resolve on every exit path so the gate can never hang.
|
|
717
808
|
markAuthResolvedRef.current();
|
|
718
809
|
}
|
|
719
|
-
}, [oxyServices, authStore]);
|
|
810
|
+
}, [oxyServices, authStore, sessionClient]);
|
|
811
|
+
// Bridge for `onSessionAppeared` (SessionClient) → re-run the cold boot to
|
|
812
|
+
// self-acquire when a sibling signs in on this device while this tab is idle.
|
|
813
|
+
runColdBootRef.current = runColdBoot;
|
|
720
814
|
(0, _react.useEffect)(() => {
|
|
721
|
-
if (
|
|
815
|
+
if (initialized) {
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
// IdP mode (`coldBoot={false}`): this provider is NOT the ecosystem session
|
|
819
|
+
// authority, so it never runs the device-first restore and never opens the
|
|
820
|
+
// signed-out device-state socket (`runColdBoot` → `onSignedOut` is the sole
|
|
821
|
+
// place that socket starts). Resolve auth immediately as signed out so there
|
|
822
|
+
// is no boot spinner; a deliberate sign-in still commits a normal session.
|
|
823
|
+
if (!coldBoot) {
|
|
824
|
+
setInitialized(true);
|
|
825
|
+
markAuthResolved();
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (!storage) {
|
|
722
829
|
return;
|
|
723
830
|
}
|
|
724
831
|
setInitialized(true);
|
|
@@ -727,7 +834,7 @@ const OxyProvider = ({
|
|
|
727
834
|
logger('Cold boot failed', error);
|
|
728
835
|
}
|
|
729
836
|
});
|
|
730
|
-
}, [runColdBoot, storage, initialized, logger]);
|
|
837
|
+
}, [coldBoot, runColdBoot, storage, initialized, logger, markAuthResolved]);
|
|
731
838
|
|
|
732
839
|
// Exposed `refreshSessions`: re-bootstrap the server-authoritative device
|
|
733
840
|
// state and reproject — the manual counterpart to the realtime socket.
|
|
@@ -793,6 +900,9 @@ const OxyProvider = ({
|
|
|
793
900
|
(0, _react.useEffect)(() => {
|
|
794
901
|
if (isAuthenticated && initialized && tokenReady) {
|
|
795
902
|
refreshAccounts();
|
|
903
|
+
// Reload the dialog's own account graph too, so a session restored OUTSIDE
|
|
904
|
+
// the dialog (cold boot / password sign-in) surfaces its graph accounts.
|
|
905
|
+
void accountDialogControllerRef.current?.refresh();
|
|
796
906
|
}
|
|
797
907
|
}, [isAuthenticated, initialized, tokenReady, refreshAccounts]);
|
|
798
908
|
const runPostAccountSwitchSideEffects = (0, _react.useCallback)(async () => {
|
|
@@ -877,11 +987,15 @@ const OxyProvider = ({
|
|
|
877
987
|
useFollow: useFollowHook,
|
|
878
988
|
showBottomSheet: showBottomSheetForContext,
|
|
879
989
|
openAvatarPicker,
|
|
990
|
+
accountDialogController,
|
|
991
|
+
isAccountDialogOpen: accountDialogOpen,
|
|
992
|
+
openAccountDialog,
|
|
993
|
+
closeAccountDialog,
|
|
880
994
|
accounts,
|
|
881
995
|
switchToAccount,
|
|
882
996
|
refreshAccounts,
|
|
883
997
|
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]);
|
|
998
|
+
}), [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
999
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OxyContext.Provider, {
|
|
886
1000
|
value: contextValue,
|
|
887
1001
|
children: children
|
|
@@ -937,6 +1051,10 @@ const LOADING_STATE = {
|
|
|
937
1051
|
clientId: null,
|
|
938
1052
|
oxyServices: LOADING_STATE_OXY_SERVICES,
|
|
939
1053
|
openAvatarPicker: () => {},
|
|
1054
|
+
accountDialogController: null,
|
|
1055
|
+
isAccountDialogOpen: false,
|
|
1056
|
+
openAccountDialog: () => {},
|
|
1057
|
+
closeAccountDialog: () => {},
|
|
940
1058
|
accounts: [],
|
|
941
1059
|
switchToAccount: () => rejectMissingProvider(),
|
|
942
1060
|
refreshAccounts: () => rejectMissingProvider(),
|