@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,742 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _vectorIcons = require("@expo/vector-icons");
|
|
10
|
+
var _reactNativeQrcodeSvg = _interopRequireDefault(require("react-native-qrcode-svg"));
|
|
11
|
+
var _avatar = require("@oxyhq/bloom/avatar");
|
|
12
|
+
var _button = require("@oxyhq/bloom/button");
|
|
13
|
+
var _dialog = require("@oxyhq/bloom/dialog");
|
|
14
|
+
var _typography = require("@oxyhq/bloom/typography");
|
|
15
|
+
var _theme = require("@oxyhq/bloom/theme");
|
|
16
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
17
|
+
var _OxyContext = require("../context/OxyContext.js");
|
|
18
|
+
var _useI18n = require("../hooks/useI18n.js");
|
|
19
|
+
var _OxyLogo = _interopRequireDefault(require("./OxyLogo.js"));
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
/**
|
|
23
|
+
* OxyAccountDialog — the ONE unified account dialog for `@oxyhq/services`.
|
|
24
|
+
*
|
|
25
|
+
* A thin React Native binding over the headless `AccountDialogController` in
|
|
26
|
+
* `@oxyhq/core` (bound via `useSyncExternalStore`), presented as a bottom-sheet
|
|
27
|
+
* modal. It REPLACES the five drifting device/account surfaces the SDK shipped
|
|
28
|
+
* before (`ProfileMenu`, `AccountMenu`, `AccountSwitcher`, `SignInAccountChooser`,
|
|
29
|
+
* and `SignInModal`) with a single implementation whose data + state machine live
|
|
30
|
+
* in core, so the RN and web (auth-sdk) bindings render the SAME list from the
|
|
31
|
+
* SAME logic and cannot diverge.
|
|
32
|
+
*
|
|
33
|
+
* Views (from `snapshot.view`):
|
|
34
|
+
* - `accounts` — the unified `SwitchableAccount[]` list (device sign-ins ∪ graph
|
|
35
|
+
* accounts). Tapping a row switches through `controller.switchTo(accountId)`
|
|
36
|
+
* (the uniform switch), the active row is flagged, and a "+ Add account" row
|
|
37
|
+
* opens the sign-in entry. This is what `ProfileButton` opens.
|
|
38
|
+
* - `add` / `signin` — the sign-in entry: primary "Sign in with Oxy" (device
|
|
39
|
+
* flow), "Scan a QR", and a secondary "Use a password" hand-off that opens
|
|
40
|
+
* auth.oxy.so (password + 2FA are NOT in the SDK).
|
|
41
|
+
* - `qr` — the cross-device QR handoff + its waiting state.
|
|
42
|
+
*
|
|
43
|
+
* Per-account color re-theming uses Bloom's `APP_COLOR_PRESETS` + `BloomColorScope`
|
|
44
|
+
* (same visual language auth.oxy.so uses). Base theming is `useTheme()` + a
|
|
45
|
+
* `StyleSheet`, so the dialog renders correctly in EVERY consumer — including apps
|
|
46
|
+
* that do not use NativeWind (e.g. the accounts app).
|
|
47
|
+
*
|
|
48
|
+
* The surface is Bloom's `<Dialog>` (`@oxyhq/bloom/dialog`) with a responsive
|
|
49
|
+
* `placement` — a bottom sheet on narrow viewports, a centered card on wide ones.
|
|
50
|
+
* It REPLACES the hand-rolled RN `<Modal>` + `<GestureHandlerRootView>` + manual
|
|
51
|
+
* backdrop/card wrapper this component used before. That RN `<Modal>` is invisible
|
|
52
|
+
* under React StrictMode on web: react-native-web's `ModalPortal` appends its host
|
|
53
|
+
* node during render but removes it in an effect cleanup and never re-attaches, so
|
|
54
|
+
* the dialog never paints in a dev Vite build. Bloom's `<Dialog>` renders through
|
|
55
|
+
* its own Portal and has no such lifecycle hazard.
|
|
56
|
+
*
|
|
57
|
+
* Open/close is CONTROLLED by `isAccountDialogOpen` (the `open` prop); the Dialog
|
|
58
|
+
* stays mounted whenever the controller exists so it can animate its own close.
|
|
59
|
+
* Backdrop / swipe-to-dismiss is disabled (`dismissOnBackdrop={false}`) on purpose:
|
|
60
|
+
* Bloom's controlled `bottom` placement does not fire `onClose` on a gesture or
|
|
61
|
+
* backdrop dismissal, so allowing it would desync `isAccountDialogOpen` from the
|
|
62
|
+
* sheet and block reopening. The header close button (and a successful switch)
|
|
63
|
+
* drive `closeAccountDialog`, which flips `open` and runs the exit animation.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/** Diameter of a row avatar. */const ROW_AVATAR_SIZE = 40;
|
|
67
|
+
/** High-contrast QR colors — intentionally fixed (NOT themed) for scan reliability. */
|
|
68
|
+
const QR_PLATE_BG = '#FFFFFF';
|
|
69
|
+
const QR_FOREGROUND = '#000000';
|
|
70
|
+
const QR_SIZE = 196;
|
|
71
|
+
const isWeb = _reactNative.Platform.OS === 'web';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Resolve an account's stored color (a named Bloom preset, e.g. `'purple'`) to
|
|
75
|
+
* a concrete brand hex for the row accent. Falls back to the theme primary when
|
|
76
|
+
* the account has no color or the value is not a recognized preset, so the accent
|
|
77
|
+
* renders in EVERY consumer regardless of NativeWind availability.
|
|
78
|
+
*/
|
|
79
|
+
function resolveAccentHex(color, fallback) {
|
|
80
|
+
const preset = toPreset(color);
|
|
81
|
+
return preset ? _theme.APP_COLOR_PRESETS[preset].hex : fallback;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Narrow a stored color string to a known `AppColorName`, or `undefined`. */
|
|
85
|
+
function toPreset(color) {
|
|
86
|
+
if (!color) return undefined;
|
|
87
|
+
return _theme.APP_COLOR_NAMES.includes(color) ? color : undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The unified account dialog. Mounted once by `OxyProvider`; opened imperatively
|
|
91
|
+
* via `useOxy().openAccountDialog(view?)` (or the back-compat `showSignInModal`).
|
|
92
|
+
*/
|
|
93
|
+
const OxyAccountDialog = () => {
|
|
94
|
+
const {
|
|
95
|
+
accountDialogController: controller,
|
|
96
|
+
isAccountDialogOpen,
|
|
97
|
+
closeAccountDialog,
|
|
98
|
+
showBottomSheet,
|
|
99
|
+
logoutAll,
|
|
100
|
+
refreshAccounts
|
|
101
|
+
} = (0, _OxyContext.useOxy)();
|
|
102
|
+
const theme = (0, _theme.useTheme)();
|
|
103
|
+
const {
|
|
104
|
+
t
|
|
105
|
+
} = (0, _useI18n.useI18n)();
|
|
106
|
+
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
107
|
+
|
|
108
|
+
// Bind the headless controller. `getSnapshot` returns a stable reference
|
|
109
|
+
// between changes, so it is `useSyncExternalStore`-safe. Guard the no-provider
|
|
110
|
+
// loading state (`controller` is `null`) with an inert store.
|
|
111
|
+
const subscribe = (0, _react.useCallback)(listener => controller ? controller.subscribe(listener) : () => undefined, [controller]);
|
|
112
|
+
const getSnapshot = (0, _react.useCallback)(() => controller ? controller.getSnapshot() : EMPTY_SNAPSHOT, [controller]);
|
|
113
|
+
const snapshot = (0, _react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
114
|
+
const [switching, setSwitching] = (0, _react.useState)(false);
|
|
115
|
+
const handleSwitch = (0, _react.useCallback)(async accountId => {
|
|
116
|
+
if (!controller || switching) return;
|
|
117
|
+
if (accountId === snapshot.activeAccountId) {
|
|
118
|
+
closeAccountDialog();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
setSwitching(true);
|
|
122
|
+
try {
|
|
123
|
+
await controller.switchTo(accountId);
|
|
124
|
+
// A switch succeeds unless the controller recorded an error. On success
|
|
125
|
+
// reload the app's account graph and drop cached account-scoped data so
|
|
126
|
+
// the new active identity re-fetches — the same side effects the
|
|
127
|
+
// context's own `switchToAccount` performs.
|
|
128
|
+
if (!controller.getSnapshot().error) {
|
|
129
|
+
void refreshAccounts();
|
|
130
|
+
queryClient.invalidateQueries();
|
|
131
|
+
closeAccountDialog();
|
|
132
|
+
}
|
|
133
|
+
} finally {
|
|
134
|
+
setSwitching(false);
|
|
135
|
+
}
|
|
136
|
+
}, [controller, switching, snapshot.activeAccountId, closeAccountDialog, refreshAccounts, queryClient]);
|
|
137
|
+
const handleManage = (0, _react.useCallback)(() => {
|
|
138
|
+
closeAccountDialog();
|
|
139
|
+
showBottomSheet?.('ManageAccount');
|
|
140
|
+
}, [closeAccountDialog, showBottomSheet]);
|
|
141
|
+
const handleSignOutAll = (0, _react.useCallback)(() => {
|
|
142
|
+
closeAccountDialog();
|
|
143
|
+
void logoutAll();
|
|
144
|
+
}, [closeAccountDialog, logoutAll]);
|
|
145
|
+
const handlers = (0, _react.useMemo)(() => ({
|
|
146
|
+
onSwitch: accountId => {
|
|
147
|
+
void handleSwitch(accountId);
|
|
148
|
+
},
|
|
149
|
+
onAdd: () => controller?.add(),
|
|
150
|
+
onManage: handleManage,
|
|
151
|
+
onClose: closeAccountDialog
|
|
152
|
+
}), [handleSwitch, controller, handleManage, closeAccountDialog]);
|
|
153
|
+
if (!controller) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const {
|
|
157
|
+
view
|
|
158
|
+
} = snapshot;
|
|
159
|
+
const showBack = view === 'qr' || view === 'add' && snapshot.accounts.length > 0;
|
|
160
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_dialog.Dialog, {
|
|
161
|
+
open: isAccountDialogOpen,
|
|
162
|
+
onClose: closeAccountDialog,
|
|
163
|
+
placement: {
|
|
164
|
+
base: 'bottom',
|
|
165
|
+
md: 'center'
|
|
166
|
+
},
|
|
167
|
+
dismissOnBackdrop: false,
|
|
168
|
+
maxWidth: 420,
|
|
169
|
+
label: headerCopy(view, snapshot.accounts.length, t).title,
|
|
170
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DialogHeader, {
|
|
171
|
+
snapshot: snapshot,
|
|
172
|
+
theme: theme,
|
|
173
|
+
t: t,
|
|
174
|
+
showBack: showBack,
|
|
175
|
+
onBack: () => controller.setView('accounts'),
|
|
176
|
+
onClose: closeAccountDialog
|
|
177
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
178
|
+
style: styles.body,
|
|
179
|
+
contentContainerStyle: styles.bodyContent,
|
|
180
|
+
showsVerticalScrollIndicator: false,
|
|
181
|
+
children: view === 'accounts' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AccountsView, {
|
|
182
|
+
snapshot: snapshot,
|
|
183
|
+
theme: theme,
|
|
184
|
+
t: t,
|
|
185
|
+
handlers: handlers
|
|
186
|
+
}) : view === 'qr' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(QrView, {
|
|
187
|
+
snapshot: snapshot,
|
|
188
|
+
theme: theme,
|
|
189
|
+
t: t,
|
|
190
|
+
onRetry: () => void controller.showQr()
|
|
191
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(SignInView, {
|
|
192
|
+
snapshot: snapshot,
|
|
193
|
+
theme: theme,
|
|
194
|
+
t: t,
|
|
195
|
+
handlers: handlers,
|
|
196
|
+
onSignInWithOxy: () => void controller.signInWithOxy(),
|
|
197
|
+
onScanQr: () => void controller.showQr(),
|
|
198
|
+
onUsePassword: () => controller.openPasswordAtOxyAuth({
|
|
199
|
+
returnUrl: isWeb ? currentHref() : undefined
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})]
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
// Header
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
|
|
210
|
+
const DialogHeader = ({
|
|
211
|
+
snapshot,
|
|
212
|
+
theme,
|
|
213
|
+
t,
|
|
214
|
+
showBack,
|
|
215
|
+
onBack,
|
|
216
|
+
onClose
|
|
217
|
+
}) => {
|
|
218
|
+
const {
|
|
219
|
+
title,
|
|
220
|
+
subtitle
|
|
221
|
+
} = headerCopy(snapshot.view, snapshot.accounts.length, t);
|
|
222
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
223
|
+
style: styles.header,
|
|
224
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
225
|
+
style: styles.headerBar,
|
|
226
|
+
children: [showBack ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
227
|
+
onPress: onBack,
|
|
228
|
+
style: [styles.iconButton, {
|
|
229
|
+
backgroundColor: theme.colors.backgroundSecondary
|
|
230
|
+
}],
|
|
231
|
+
accessibilityRole: "button",
|
|
232
|
+
accessibilityLabel: t('common.actions.back') || 'Back',
|
|
233
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
234
|
+
name: "chevron-left",
|
|
235
|
+
size: 22,
|
|
236
|
+
color: theme.colors.textSecondary
|
|
237
|
+
})
|
|
238
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
239
|
+
style: styles.iconButton
|
|
240
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_OxyLogo.default, {
|
|
241
|
+
variant: "icon",
|
|
242
|
+
size: 34,
|
|
243
|
+
fillColor: theme.colors.primary
|
|
244
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
245
|
+
onPress: onClose,
|
|
246
|
+
style: [styles.iconButton, {
|
|
247
|
+
backgroundColor: theme.colors.backgroundSecondary
|
|
248
|
+
}],
|
|
249
|
+
accessibilityRole: "button",
|
|
250
|
+
accessibilityLabel: t('common.actions.close') || 'Close',
|
|
251
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
252
|
+
name: "close",
|
|
253
|
+
size: 20,
|
|
254
|
+
color: theme.colors.textSecondary
|
|
255
|
+
})
|
|
256
|
+
})]
|
|
257
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
258
|
+
style: [styles.title, {
|
|
259
|
+
color: theme.colors.text
|
|
260
|
+
}],
|
|
261
|
+
numberOfLines: 1,
|
|
262
|
+
children: title
|
|
263
|
+
}), subtitle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
264
|
+
style: [styles.subtitle, {
|
|
265
|
+
color: theme.colors.textSecondary
|
|
266
|
+
}],
|
|
267
|
+
numberOfLines: 2,
|
|
268
|
+
children: subtitle
|
|
269
|
+
}) : null]
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
// Accounts view
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
|
|
277
|
+
const AccountsView = ({
|
|
278
|
+
snapshot,
|
|
279
|
+
theme,
|
|
280
|
+
t,
|
|
281
|
+
handlers
|
|
282
|
+
}) => {
|
|
283
|
+
if (snapshot.loading && snapshot.accounts.length === 0) {
|
|
284
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
285
|
+
style: styles.centeredBlock,
|
|
286
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
287
|
+
name: "loading",
|
|
288
|
+
size: 24,
|
|
289
|
+
color: theme.colors.textSecondary
|
|
290
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
291
|
+
style: [styles.mutedText, {
|
|
292
|
+
color: theme.colors.textSecondary
|
|
293
|
+
}],
|
|
294
|
+
children: t('accountSwitcher.loading') || 'Loading accounts…'
|
|
295
|
+
})]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
299
|
+
style: styles.rows,
|
|
300
|
+
children: [snapshot.accounts.map(account => /*#__PURE__*/(0, _jsxRuntime.jsx)(AccountRow, {
|
|
301
|
+
account: account,
|
|
302
|
+
theme: theme,
|
|
303
|
+
switching: snapshot.switchingAccountId === account.accountId,
|
|
304
|
+
disabled: snapshot.switchingAccountId !== null,
|
|
305
|
+
onPress: () => handlers.onSwitch(account.accountId)
|
|
306
|
+
}, account.accountId)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
307
|
+
style: [styles.addRow, {
|
|
308
|
+
borderColor: theme.colors.border
|
|
309
|
+
}],
|
|
310
|
+
onPress: handlers.onAdd,
|
|
311
|
+
accessibilityRole: "button",
|
|
312
|
+
accessibilityLabel: t('signin.addAccountTitle') || 'Add another account',
|
|
313
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
314
|
+
style: [styles.addBadge, {
|
|
315
|
+
borderColor: theme.colors.border
|
|
316
|
+
}],
|
|
317
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
318
|
+
name: "plus",
|
|
319
|
+
size: 20,
|
|
320
|
+
color: theme.colors.textSecondary
|
|
321
|
+
})
|
|
322
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
323
|
+
style: [styles.rowName, {
|
|
324
|
+
color: theme.colors.textSecondary
|
|
325
|
+
}],
|
|
326
|
+
children: t('signin.addAccountTitle') || 'Add another account'
|
|
327
|
+
})]
|
|
328
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
329
|
+
style: styles.footerLinks,
|
|
330
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
331
|
+
onPress: handlers.onManage,
|
|
332
|
+
accessibilityRole: "button",
|
|
333
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
334
|
+
style: [styles.linkText, {
|
|
335
|
+
color: theme.colors.primary
|
|
336
|
+
}],
|
|
337
|
+
children: t('accountMenu.manage') || 'Manage accounts'
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
})]
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
const AccountRow = ({
|
|
344
|
+
account,
|
|
345
|
+
theme,
|
|
346
|
+
switching,
|
|
347
|
+
disabled,
|
|
348
|
+
onPress
|
|
349
|
+
}) => {
|
|
350
|
+
const accent = resolveAccentHex(account.color, theme.colors.primary);
|
|
351
|
+
const rowStyle = [styles.accountRow, {
|
|
352
|
+
borderColor: account.isCurrent ? accent : theme.colors.border,
|
|
353
|
+
backgroundColor: theme.colors.card
|
|
354
|
+
}, disabled && !switching ? styles.rowDisabled : null];
|
|
355
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_theme.BloomColorScope, {
|
|
356
|
+
colorPreset: toPreset(account.color),
|
|
357
|
+
asChild: true,
|
|
358
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
359
|
+
style: rowStyle,
|
|
360
|
+
onPress: onPress,
|
|
361
|
+
disabled: disabled,
|
|
362
|
+
accessibilityRole: "button",
|
|
363
|
+
accessibilityState: {
|
|
364
|
+
selected: account.isCurrent,
|
|
365
|
+
disabled
|
|
366
|
+
},
|
|
367
|
+
accessibilityLabel: account.displayName,
|
|
368
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
369
|
+
style: [styles.avatarRing, {
|
|
370
|
+
borderColor: account.isCurrent ? accent : 'transparent'
|
|
371
|
+
}],
|
|
372
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_avatar.Avatar, {
|
|
373
|
+
source: account.user.avatar ?? undefined,
|
|
374
|
+
variant: "thumb",
|
|
375
|
+
name: account.displayName,
|
|
376
|
+
size: ROW_AVATAR_SIZE
|
|
377
|
+
})
|
|
378
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
379
|
+
style: styles.rowMeta,
|
|
380
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
381
|
+
style: [styles.rowName, {
|
|
382
|
+
color: theme.colors.text
|
|
383
|
+
}],
|
|
384
|
+
numberOfLines: 1,
|
|
385
|
+
children: account.displayName
|
|
386
|
+
}), account.email ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
387
|
+
style: [styles.rowHandle, {
|
|
388
|
+
color: theme.colors.textSecondary
|
|
389
|
+
}],
|
|
390
|
+
numberOfLines: 1,
|
|
391
|
+
children: account.email
|
|
392
|
+
}) : null]
|
|
393
|
+
}), switching ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
394
|
+
name: "loading",
|
|
395
|
+
size: 20,
|
|
396
|
+
color: accent
|
|
397
|
+
}) : account.isCurrent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
398
|
+
name: "check-circle",
|
|
399
|
+
size: 20,
|
|
400
|
+
color: accent
|
|
401
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
402
|
+
name: "chevron-right",
|
|
403
|
+
size: 20,
|
|
404
|
+
color: theme.colors.textSecondary
|
|
405
|
+
})]
|
|
406
|
+
})
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// ---------------------------------------------------------------------------
|
|
411
|
+
// Sign-in view (add / signin)
|
|
412
|
+
// ---------------------------------------------------------------------------
|
|
413
|
+
|
|
414
|
+
const SignInView = ({
|
|
415
|
+
snapshot,
|
|
416
|
+
theme,
|
|
417
|
+
t,
|
|
418
|
+
handlers,
|
|
419
|
+
onSignInWithOxy,
|
|
420
|
+
onScanQr,
|
|
421
|
+
onUsePassword
|
|
422
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
423
|
+
style: styles.signInBlock,
|
|
424
|
+
children: [snapshot.accounts.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
425
|
+
style: styles.rows,
|
|
426
|
+
children: [snapshot.accounts.map(account => /*#__PURE__*/(0, _jsxRuntime.jsx)(AccountRow, {
|
|
427
|
+
account: account,
|
|
428
|
+
theme: theme,
|
|
429
|
+
switching: snapshot.switchingAccountId === account.accountId,
|
|
430
|
+
disabled: snapshot.switchingAccountId !== null,
|
|
431
|
+
onPress: () => handlers.onSwitch(account.accountId)
|
|
432
|
+
}, account.accountId)), /*#__PURE__*/(0, _jsxRuntime.jsx)(Dividerish, {
|
|
433
|
+
theme: theme,
|
|
434
|
+
label: t('signin.or') || 'or'
|
|
435
|
+
})]
|
|
436
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
437
|
+
variant: "primary",
|
|
438
|
+
onPress: onSignInWithOxy,
|
|
439
|
+
style: styles.primaryButton,
|
|
440
|
+
children: "Sign in with Oxy"
|
|
441
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
442
|
+
variant: "secondary",
|
|
443
|
+
onPress: onScanQr,
|
|
444
|
+
style: styles.secondaryButton,
|
|
445
|
+
children: t('accountSwitcher.scanQr') || 'Scan a QR from another device'
|
|
446
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
447
|
+
onPress: onUsePassword,
|
|
448
|
+
accessibilityRole: "button",
|
|
449
|
+
style: styles.passwordLink,
|
|
450
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
451
|
+
style: [styles.linkText, {
|
|
452
|
+
color: theme.colors.textSecondary
|
|
453
|
+
}],
|
|
454
|
+
children: "Use a password instead"
|
|
455
|
+
})
|
|
456
|
+
})]
|
|
457
|
+
});
|
|
458
|
+
const Dividerish = ({
|
|
459
|
+
theme,
|
|
460
|
+
label
|
|
461
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
462
|
+
style: styles.dividerRow,
|
|
463
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
464
|
+
style: [styles.dividerLine, {
|
|
465
|
+
backgroundColor: theme.colors.border
|
|
466
|
+
}]
|
|
467
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
468
|
+
style: [styles.dividerText, {
|
|
469
|
+
color: theme.colors.textSecondary
|
|
470
|
+
}],
|
|
471
|
+
children: label
|
|
472
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
473
|
+
style: [styles.dividerLine, {
|
|
474
|
+
backgroundColor: theme.colors.border
|
|
475
|
+
}]
|
|
476
|
+
})]
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// ---------------------------------------------------------------------------
|
|
480
|
+
// QR view
|
|
481
|
+
// ---------------------------------------------------------------------------
|
|
482
|
+
|
|
483
|
+
const QrView = ({
|
|
484
|
+
snapshot,
|
|
485
|
+
theme,
|
|
486
|
+
t,
|
|
487
|
+
onRetry
|
|
488
|
+
}) => {
|
|
489
|
+
const {
|
|
490
|
+
signIn
|
|
491
|
+
} = snapshot;
|
|
492
|
+
if (signIn.phase === 'error') {
|
|
493
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
494
|
+
style: styles.centeredBlock,
|
|
495
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
496
|
+
style: [styles.errorText, {
|
|
497
|
+
color: theme.colors.error
|
|
498
|
+
}],
|
|
499
|
+
children: signIn.error || 'Sign-in failed. Please try again.'
|
|
500
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
501
|
+
variant: "secondary",
|
|
502
|
+
onPress: onRetry,
|
|
503
|
+
style: styles.secondaryButton,
|
|
504
|
+
children: t('common.actions.tryAgain') || 'Try again'
|
|
505
|
+
})]
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (signIn.phase === 'starting' || signIn.phase === 'authorized' || !signIn.qrPayload) {
|
|
509
|
+
const label = signIn.phase === 'authorized' ? t('signin.status.signingIn') || 'Signing in…' : t('accountSwitcher.loading') || 'Preparing sign-in…';
|
|
510
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
511
|
+
style: styles.centeredBlock,
|
|
512
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
|
|
513
|
+
name: "loading",
|
|
514
|
+
size: 26,
|
|
515
|
+
color: theme.colors.primary
|
|
516
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
517
|
+
style: [styles.mutedText, {
|
|
518
|
+
color: theme.colors.textSecondary
|
|
519
|
+
}],
|
|
520
|
+
children: label
|
|
521
|
+
})]
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
525
|
+
style: styles.centeredBlock,
|
|
526
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
527
|
+
style: styles.qrPlate,
|
|
528
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeQrcodeSvg.default, {
|
|
529
|
+
value: signIn.qrPayload,
|
|
530
|
+
size: QR_SIZE,
|
|
531
|
+
backgroundColor: QR_PLATE_BG,
|
|
532
|
+
color: QR_FOREGROUND
|
|
533
|
+
})
|
|
534
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
535
|
+
style: [styles.mutedText, {
|
|
536
|
+
color: theme.colors.textSecondary
|
|
537
|
+
}],
|
|
538
|
+
children: t('accountSwitcher.scanWithOxy') || 'Scan with any Oxy app and approve.'
|
|
539
|
+
})]
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// ---------------------------------------------------------------------------
|
|
544
|
+
// Copy + helpers
|
|
545
|
+
// ---------------------------------------------------------------------------
|
|
546
|
+
|
|
547
|
+
function headerCopy(view, accountCount, t) {
|
|
548
|
+
switch (view) {
|
|
549
|
+
case 'accounts':
|
|
550
|
+
return {
|
|
551
|
+
title: t('accountSwitcher.sections.yourAccounts') || 'Your accounts',
|
|
552
|
+
subtitle: t('signin.chooser.subtitle') || 'Choose which account to continue with.'
|
|
553
|
+
};
|
|
554
|
+
case 'qr':
|
|
555
|
+
return {
|
|
556
|
+
title: t('accountSwitcher.scanTitle') || 'Scan with Oxy',
|
|
557
|
+
subtitle: t('accountSwitcher.scanSubtitle') || 'Approve from your phone.'
|
|
558
|
+
};
|
|
559
|
+
default:
|
|
560
|
+
return accountCount > 0 ? {
|
|
561
|
+
title: t('signin.addAccountTitle') || 'Add another account',
|
|
562
|
+
subtitle: t('signin.addAccountSubtitle') || 'Sign in with another account.'
|
|
563
|
+
} : {
|
|
564
|
+
title: t('signin.title') || 'Sign in',
|
|
565
|
+
subtitle: t('signin.subtitle') || 'One identity for the whole ecosystem.'
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/** Current document URL on web; `undefined` where `location` is absent. */
|
|
571
|
+
function currentHref() {
|
|
572
|
+
const location = globalThis.location;
|
|
573
|
+
return typeof location?.href === 'string' ? location.href : undefined;
|
|
574
|
+
}
|
|
575
|
+
const EMPTY_SNAPSHOT = {
|
|
576
|
+
view: 'accounts',
|
|
577
|
+
accounts: [],
|
|
578
|
+
activeAccountId: null,
|
|
579
|
+
loading: false,
|
|
580
|
+
error: null,
|
|
581
|
+
switchingAccountId: null,
|
|
582
|
+
signIn: {
|
|
583
|
+
phase: 'idle',
|
|
584
|
+
authorizeCode: null,
|
|
585
|
+
qrPayload: null,
|
|
586
|
+
expiresAt: null,
|
|
587
|
+
error: null
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
const styles = _reactNative.StyleSheet.create({
|
|
591
|
+
header: {
|
|
592
|
+
alignItems: 'center',
|
|
593
|
+
marginBottom: 12
|
|
594
|
+
},
|
|
595
|
+
headerBar: {
|
|
596
|
+
width: '100%',
|
|
597
|
+
flexDirection: 'row',
|
|
598
|
+
alignItems: 'center',
|
|
599
|
+
justifyContent: 'space-between',
|
|
600
|
+
marginBottom: 8
|
|
601
|
+
},
|
|
602
|
+
iconButton: {
|
|
603
|
+
width: 32,
|
|
604
|
+
height: 32,
|
|
605
|
+
borderRadius: 16,
|
|
606
|
+
alignItems: 'center',
|
|
607
|
+
justifyContent: 'center'
|
|
608
|
+
},
|
|
609
|
+
title: {
|
|
610
|
+
fontSize: 22,
|
|
611
|
+
fontWeight: '800',
|
|
612
|
+
letterSpacing: -0.4,
|
|
613
|
+
textAlign: 'center',
|
|
614
|
+
marginTop: 6
|
|
615
|
+
},
|
|
616
|
+
subtitle: {
|
|
617
|
+
fontSize: 14,
|
|
618
|
+
lineHeight: 19,
|
|
619
|
+
textAlign: 'center',
|
|
620
|
+
marginTop: 4
|
|
621
|
+
},
|
|
622
|
+
body: {
|
|
623
|
+
width: '100%'
|
|
624
|
+
},
|
|
625
|
+
bodyContent: {
|
|
626
|
+
paddingTop: 4,
|
|
627
|
+
paddingBottom: 4
|
|
628
|
+
},
|
|
629
|
+
rows: {
|
|
630
|
+
width: '100%',
|
|
631
|
+
gap: 8
|
|
632
|
+
},
|
|
633
|
+
accountRow: {
|
|
634
|
+
flexDirection: 'row',
|
|
635
|
+
alignItems: 'center',
|
|
636
|
+
gap: 12,
|
|
637
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
638
|
+
borderRadius: 16,
|
|
639
|
+
paddingVertical: 10,
|
|
640
|
+
paddingHorizontal: 12
|
|
641
|
+
},
|
|
642
|
+
rowDisabled: {
|
|
643
|
+
opacity: 0.6
|
|
644
|
+
},
|
|
645
|
+
avatarRing: {
|
|
646
|
+
borderRadius: 9999,
|
|
647
|
+
borderWidth: 2,
|
|
648
|
+
padding: 1
|
|
649
|
+
},
|
|
650
|
+
rowMeta: {
|
|
651
|
+
flex: 1,
|
|
652
|
+
minWidth: 0
|
|
653
|
+
},
|
|
654
|
+
rowName: {
|
|
655
|
+
fontSize: 15,
|
|
656
|
+
fontWeight: '600'
|
|
657
|
+
},
|
|
658
|
+
rowHandle: {
|
|
659
|
+
fontSize: 12.5,
|
|
660
|
+
marginTop: 1
|
|
661
|
+
},
|
|
662
|
+
addRow: {
|
|
663
|
+
flexDirection: 'row',
|
|
664
|
+
alignItems: 'center',
|
|
665
|
+
gap: 12,
|
|
666
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
667
|
+
borderStyle: 'dashed',
|
|
668
|
+
borderRadius: 16,
|
|
669
|
+
paddingVertical: 10,
|
|
670
|
+
paddingHorizontal: 12,
|
|
671
|
+
marginTop: 8
|
|
672
|
+
},
|
|
673
|
+
addBadge: {
|
|
674
|
+
width: ROW_AVATAR_SIZE,
|
|
675
|
+
height: ROW_AVATAR_SIZE,
|
|
676
|
+
borderRadius: 9999,
|
|
677
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
678
|
+
alignItems: 'center',
|
|
679
|
+
justifyContent: 'center'
|
|
680
|
+
},
|
|
681
|
+
footerLinks: {
|
|
682
|
+
alignItems: 'center',
|
|
683
|
+
marginTop: 16
|
|
684
|
+
},
|
|
685
|
+
linkText: {
|
|
686
|
+
fontSize: 14,
|
|
687
|
+
fontWeight: '600'
|
|
688
|
+
},
|
|
689
|
+
signInBlock: {
|
|
690
|
+
width: '100%'
|
|
691
|
+
},
|
|
692
|
+
primaryButton: {
|
|
693
|
+
width: '100%',
|
|
694
|
+
borderRadius: 14,
|
|
695
|
+
marginTop: 8
|
|
696
|
+
},
|
|
697
|
+
secondaryButton: {
|
|
698
|
+
width: '100%',
|
|
699
|
+
borderRadius: 14,
|
|
700
|
+
marginTop: 10
|
|
701
|
+
},
|
|
702
|
+
passwordLink: {
|
|
703
|
+
alignSelf: 'center',
|
|
704
|
+
paddingVertical: 10,
|
|
705
|
+
marginTop: 12
|
|
706
|
+
},
|
|
707
|
+
dividerRow: {
|
|
708
|
+
flexDirection: 'row',
|
|
709
|
+
alignItems: 'center',
|
|
710
|
+
width: '100%',
|
|
711
|
+
marginVertical: 14
|
|
712
|
+
},
|
|
713
|
+
dividerLine: {
|
|
714
|
+
flex: 1,
|
|
715
|
+
height: _reactNative.StyleSheet.hairlineWidth
|
|
716
|
+
},
|
|
717
|
+
dividerText: {
|
|
718
|
+
marginHorizontal: 12,
|
|
719
|
+
fontSize: 13
|
|
720
|
+
},
|
|
721
|
+
centeredBlock: {
|
|
722
|
+
alignItems: 'center',
|
|
723
|
+
justifyContent: 'center',
|
|
724
|
+
gap: 12,
|
|
725
|
+
paddingVertical: 24
|
|
726
|
+
},
|
|
727
|
+
mutedText: {
|
|
728
|
+
fontSize: 14,
|
|
729
|
+
textAlign: 'center'
|
|
730
|
+
},
|
|
731
|
+
errorText: {
|
|
732
|
+
fontSize: 14,
|
|
733
|
+
textAlign: 'center'
|
|
734
|
+
},
|
|
735
|
+
qrPlate: {
|
|
736
|
+
padding: 16,
|
|
737
|
+
borderRadius: 16,
|
|
738
|
+
backgroundColor: QR_PLATE_BG
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
var _default = exports.default = OxyAccountDialog;
|
|
742
|
+
//# sourceMappingURL=OxyAccountDialog.js.map
|