@oxyhq/services 12.1.1 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/index.js +73 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/AccountMenuButton.js +26 -9
- package/lib/commonjs/ui/components/AccountMenuButton.js.map +1 -1
- package/lib/commonjs/ui/components/AccountSwitcher.js +792 -0
- package/lib/commonjs/ui/components/AccountSwitcher.js.map +1 -0
- package/lib/commonjs/ui/components/ActiveAccountBanner.js +144 -0
- package/lib/commonjs/ui/components/ActiveAccountBanner.js.map +1 -0
- package/lib/commonjs/ui/components/SignInModal.js +9 -2
- package/lib/commonjs/ui/components/SignInModal.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +72 -27
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +8 -0
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/index.js +42 -0
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +4 -1
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountMembersScreen.js +469 -0
- package/lib/commonjs/ui/screens/AccountMembersScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +264 -0
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +51 -0
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/{CreateManagedAccountScreen.js → CreateAccountScreen.js} +116 -25
- package/lib/commonjs/ui/screens/CreateAccountScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/ManageAccountScreen.js +11 -11
- package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +10 -2
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/utils/crossApex.js +74 -0
- package/lib/commonjs/utils/crossApex.js.map +1 -0
- package/lib/module/index.js +21 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/AccountMenuButton.js +26 -9
- package/lib/module/ui/components/AccountMenuButton.js.map +1 -1
- package/lib/module/ui/components/AccountSwitcher.js +786 -0
- package/lib/module/ui/components/AccountSwitcher.js.map +1 -0
- package/lib/module/ui/components/ActiveAccountBanner.js +141 -0
- package/lib/module/ui/components/ActiveAccountBanner.js.map +1 -0
- package/lib/module/ui/components/SignInModal.js +9 -2
- package/lib/module/ui/components/SignInModal.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +72 -27
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +8 -0
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/index.js +5 -0
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +4 -1
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountMembersScreen.js +464 -0
- package/lib/module/ui/screens/AccountMembersScreen.js.map +1 -0
- package/lib/module/ui/screens/AccountSettingsScreen.js +259 -0
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -0
- package/lib/module/ui/screens/AccountSwitcherScreen.js +48 -0
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -0
- package/lib/module/ui/screens/{CreateManagedAccountScreen.js → CreateAccountScreen.js} +117 -26
- package/lib/module/ui/screens/CreateAccountScreen.js.map +1 -0
- package/lib/module/ui/screens/ManageAccountScreen.js +11 -11
- package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +10 -2
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/utils/crossApex.js +69 -0
- package/lib/module/utils/crossApex.js.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +8 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts +13 -4
- package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts +47 -0
- package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/{ActingAsBanner.d.ts → ActiveAccountBanner.d.ts} +1 -1
- package/lib/typescript/commonjs/ui/components/ActiveAccountBanner.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/SignInModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +33 -5
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/index.d.ts +5 -0
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- 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/AccountMembersScreen.d.ts +10 -0
- package/lib/typescript/commonjs/ui/screens/AccountMembersScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts +12 -0
- package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts +11 -0
- package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts +11 -0
- package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/crossApex.d.ts +55 -0
- package/lib/typescript/commonjs/utils/crossApex.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +8 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AccountMenuButton.d.ts +13 -4
- package/lib/typescript/module/ui/components/AccountMenuButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AccountSwitcher.d.ts +47 -0
- package/lib/typescript/module/ui/components/AccountSwitcher.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/{ActingAsBanner.d.ts → ActiveAccountBanner.d.ts} +1 -1
- package/lib/typescript/module/ui/components/ActiveAccountBanner.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/SignInModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts +33 -5
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/index.d.ts +5 -0
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- 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/AccountMembersScreen.d.ts +10 -0
- package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts +12 -0
- package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts +11 -0
- package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts +11 -0
- package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/module/utils/crossApex.d.ts +55 -0
- package/lib/typescript/module/utils/crossApex.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +22 -4
- package/src/ui/components/AccountMenuButton.tsx +25 -10
- package/src/ui/components/AccountSwitcher.tsx +763 -0
- package/src/ui/components/ActiveAccountBanner.tsx +130 -0
- package/src/ui/components/SignInModal.tsx +18 -6
- package/src/ui/context/OxyContext.tsx +121 -35
- package/src/ui/context/hooks/useAuthOperations.ts +8 -0
- package/src/ui/index.ts +5 -0
- package/src/ui/navigation/routes.ts +8 -2
- package/src/ui/screens/AccountMembersScreen.tsx +481 -0
- package/src/ui/screens/AccountSettingsScreen.tsx +261 -0
- package/src/ui/screens/AccountSwitcherScreen.tsx +43 -0
- package/src/ui/screens/{CreateManagedAccountScreen.tsx → CreateAccountScreen.tsx} +140 -22
- package/src/ui/screens/ManageAccountScreen.tsx +19 -19
- package/src/ui/screens/OxyAuthScreen.tsx +20 -6
- package/src/utils/crossApex.ts +75 -0
- package/lib/commonjs/ui/components/ActingAsBanner.js +0 -140
- package/lib/commonjs/ui/components/ActingAsBanner.js.map +0 -1
- package/lib/commonjs/ui/screens/CreateManagedAccountScreen.js.map +0 -1
- package/lib/module/ui/components/ActingAsBanner.js +0 -137
- package/lib/module/ui/components/ActingAsBanner.js.map +0 -1
- package/lib/module/ui/screens/CreateManagedAccountScreen.js.map +0 -1
- package/lib/typescript/commonjs/ui/components/ActingAsBanner.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/screens/CreateManagedAccountScreen.d.ts +0 -5
- package/lib/typescript/commonjs/ui/screens/CreateManagedAccountScreen.d.ts.map +0 -1
- package/lib/typescript/module/ui/components/ActingAsBanner.d.ts.map +0 -1
- package/lib/typescript/module/ui/screens/CreateManagedAccountScreen.d.ts +0 -5
- package/lib/typescript/module/ui/screens/CreateManagedAccountScreen.d.ts.map +0 -1
- package/src/ui/components/ActingAsBanner.tsx +0 -129
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-apex web detection for sign-in durability gating.
|
|
3
|
+
*
|
|
4
|
+
* On a web Relying Party whose registrable apex differs from the central Oxy
|
|
5
|
+
* Identity Provider apex (`oxy.so`), the ONLY sign-in completion that survives a
|
|
6
|
+
* page reload is the interactive "Continue with Oxy" IdP flow, because it is the
|
|
7
|
+
* only one that establishes a first-party `fedcm_session` cookie at
|
|
8
|
+
* `auth.<apex>` — the anchor the cross-domain cold-boot restore reads on reload.
|
|
9
|
+
*
|
|
10
|
+
* The other sign-in completions the SDK can drive do NOT plant a `fedcm_session`:
|
|
11
|
+
* - password / public-key sign-in mints a bearer directly against the Oxy API
|
|
12
|
+
* (its refresh cookie is host-scoped to `api.oxy.so` and `SameSite=Lax`, so
|
|
13
|
+
* it is unreachable cross-site from the RP), and
|
|
14
|
+
* - the Commons-app device-flow handoff (cross-device QR / same-device
|
|
15
|
+
* deep-link) is approved OUTSIDE the browser, so no IdP browser session is
|
|
16
|
+
* established.
|
|
17
|
+
* On a cross-apex RP each of these leaves the user signed in for the current
|
|
18
|
+
* page only — a reload logs them out. See OxyHQServices AGENTS.md
|
|
19
|
+
* "Auth / Session Contract".
|
|
20
|
+
*
|
|
21
|
+
* Same-apex `*.oxy.so` apps (e.g. `accounts.oxy.so`) are first-party with
|
|
22
|
+
* `api.oxy.so`: their refresh cookie rides same-site requests so reload restore
|
|
23
|
+
* works without `fedcm_session`, and they are therefore NOT gated.
|
|
24
|
+
*
|
|
25
|
+
* Returns `false` off-browser (React Native has no `window.location`) and for
|
|
26
|
+
* hosts without a registrable apex (localhost / raw IP / single-label dev
|
|
27
|
+
* hosts), so native and local development keep every sign-in method.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Whether the given host is a web RP on a registrable apex other than the
|
|
31
|
+
* central Oxy IdP apex (`oxy.so`). See the module doc for why this gates the
|
|
32
|
+
* non-durable sign-in paths.
|
|
33
|
+
*
|
|
34
|
+
* @param hostname - The host to classify. Defaults to the current
|
|
35
|
+
* `window.location.hostname`; resolves to `undefined` off-browser (React
|
|
36
|
+
* Native / SSR), which yields `false`. The explicit parameter mirrors
|
|
37
|
+
* `autoDetectAuthWebUrl(location?)` and keeps the predicate unit-testable
|
|
38
|
+
* without manipulating the global `window.location`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isCrossApexWeb(hostname?: string | undefined): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when an app attempts a direct (non-IdP) sign-in — password or
|
|
43
|
+
* public-key — on a cross-apex web RP, where such a sign-in would not survive a
|
|
44
|
+
* page reload because no `fedcm_session` is established (see {@link isCrossApexWeb}).
|
|
45
|
+
*
|
|
46
|
+
* Apps on a cross-apex apex must sign in through the interactive
|
|
47
|
+
* "Continue with Oxy" IdP flow (`OxySignInButton` / `showSignInModal()`), which
|
|
48
|
+
* plants the durable session.
|
|
49
|
+
*/
|
|
50
|
+
export declare class CrossApexDirectSignInError extends Error {
|
|
51
|
+
readonly name = "CrossApexDirectSignInError";
|
|
52
|
+
readonly code = "CROSS_APEX_DIRECT_SIGN_IN_UNSUPPORTED";
|
|
53
|
+
constructor();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=crossApex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crossApex.d.ts","sourceRoot":"","sources":["../../../../src/utils/crossApex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,GAAE,MAAM,GAAG,SAEN,GACZ,OAAO,CAMT;AAED;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAkB,IAAI,gCAAgC;IACtD,QAAQ,CAAC,IAAI,2CAA2C;;CASzD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/services",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
"dependencies": {
|
|
109
|
-
"@oxyhq/contracts": "0.
|
|
109
|
+
"@oxyhq/contracts": "0.6.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"nativewind": "5.0.0-preview.3",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"peerDependencies": {
|
|
153
153
|
"@expo/vector-icons": "^15.0.3",
|
|
154
154
|
"@oxyhq/bloom": ">=0.16.0",
|
|
155
|
-
"@oxyhq/core": "^
|
|
155
|
+
"@oxyhq/core": "^4.0.0",
|
|
156
156
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
157
157
|
"@react-native-community/netinfo": "^11.4.1",
|
|
158
158
|
"@tanstack/query-async-storage-persister": "^5.100",
|
package/src/index.ts
CHANGED
|
@@ -180,6 +180,10 @@ export {
|
|
|
180
180
|
extractErrorMessage,
|
|
181
181
|
} from './ui/utils/errorHandlers';
|
|
182
182
|
export type { HandleAuthErrorOptions } from './ui/utils/errorHandlers';
|
|
183
|
+
// Thrown by `signInWithPassword` / `signIn` on a cross-apex web RP, where a
|
|
184
|
+
// direct (non-IdP) sign-in would not survive a page reload — apps catch it to
|
|
185
|
+
// route the user to the durable "Continue with Oxy" IdP flow.
|
|
186
|
+
export { CrossApexDirectSignInError, isCrossApexWeb } from './utils/crossApex';
|
|
183
187
|
|
|
184
188
|
// ---------------------------------------------------------------------------
|
|
185
189
|
// File filtering
|
|
@@ -201,15 +205,23 @@ export type { FollowButtonProps, SingleFollowButtonProps, MultiFollowButtonProps
|
|
|
201
205
|
export { LogoIcon } from './ui/components/logo/LogoIcon';
|
|
202
206
|
export { LogoText } from './ui/components/logo/LogoText';
|
|
203
207
|
|
|
204
|
-
//
|
|
205
|
-
|
|
208
|
+
// Subtle "active account" context cue for the account graph (not Commons/DID).
|
|
209
|
+
// Shows which account is active when the user has switched into a non-personal
|
|
210
|
+
// account; reads as the current account, not as delegation.
|
|
211
|
+
export { default as ActiveAccountBanner } from './ui/components/ActiveAccountBanner';
|
|
206
212
|
|
|
207
|
-
// Unified account menu (popover on web,
|
|
213
|
+
// Unified account menu (device-only switcher — popover on web, sheet on native)
|
|
208
214
|
export { default as AccountMenu } from './ui/components/AccountMenu';
|
|
209
215
|
export type { AccountMenuProps, AccountMenuAnchor } from './ui/components/AccountMenu';
|
|
210
216
|
export { default as AccountMenuButton } from './ui/components/AccountMenuButton';
|
|
211
217
|
export type { AccountMenuButtonProps } from './ui/components/AccountMenuButton';
|
|
212
218
|
|
|
219
|
+
// Unified account switcher (device sign-ins + account graph). `AccountMenuButton`
|
|
220
|
+
// opens this; the `AccountSwitcherView` body also backs the `AccountSwitcher`
|
|
221
|
+
// bottom-sheet route.
|
|
222
|
+
export { default as AccountSwitcher, AccountSwitcherView } from './ui/components/AccountSwitcher';
|
|
223
|
+
export type { AccountSwitcherProps, AccountSwitcherActions } from './ui/components/AccountSwitcher';
|
|
224
|
+
|
|
213
225
|
// Unified device-account hook (hydrates every signed-in account on the device
|
|
214
226
|
// with real name/email/avatar/color for the account switcher).
|
|
215
227
|
export { useDeviceAccounts } from './ui/hooks/useDeviceAccounts';
|
|
@@ -219,12 +231,18 @@ export type {
|
|
|
219
231
|
UseDeviceAccountsResult,
|
|
220
232
|
} from './ui/hooks/useDeviceAccounts';
|
|
221
233
|
|
|
222
|
-
// Unified "Manage your Oxy Account" screen
|
|
234
|
+
// Unified "Manage your Oxy Account" screen (the caller's own personal account)
|
|
223
235
|
export { default as ManageAccountScreen } from './ui/screens/ManageAccountScreen';
|
|
224
236
|
export { default as NotificationsScreen } from './ui/screens/NotificationsScreen';
|
|
225
237
|
export { default as PreferencesScreen } from './ui/screens/PreferencesScreen';
|
|
226
238
|
export { default as ConnectedAppsScreen } from './ui/screens/ConnectedAppsScreen';
|
|
227
239
|
|
|
240
|
+
// Account-graph screens (organization / project / bot accounts)
|
|
241
|
+
export { default as AccountSwitcherScreen } from './ui/screens/AccountSwitcherScreen';
|
|
242
|
+
export { default as CreateAccountScreen } from './ui/screens/CreateAccountScreen';
|
|
243
|
+
export { default as AccountMembersScreen } from './ui/screens/AccountMembersScreen';
|
|
244
|
+
export { default as AccountSettingsScreen } from './ui/screens/AccountSettingsScreen';
|
|
245
|
+
|
|
228
246
|
// ---------------------------------------------------------------------------
|
|
229
247
|
// Bottom-sheet navigation
|
|
230
248
|
// ---------------------------------------------------------------------------
|
|
@@ -3,9 +3,11 @@ import { useCallback, useRef, useState } from 'react';
|
|
|
3
3
|
import { TouchableOpacity, StyleSheet, Platform, type LayoutChangeEvent } from 'react-native';
|
|
4
4
|
import { getAccountDisplayName } from '@oxyhq/core';
|
|
5
5
|
import Avatar from './Avatar';
|
|
6
|
-
import
|
|
6
|
+
import AccountSwitcher from './AccountSwitcher';
|
|
7
|
+
import type { AccountMenuAnchor } from './AccountMenu';
|
|
7
8
|
import { useOxy } from '../context/OxyContext';
|
|
8
9
|
import { useI18n } from '../hooks/useI18n';
|
|
10
|
+
import { showBottomSheet } from '../navigation/bottomSheetManager';
|
|
9
11
|
|
|
10
12
|
export interface AccountMenuButtonProps {
|
|
11
13
|
/** Avatar size (px). Defaults to 36 (Google account chip size). */
|
|
@@ -19,18 +21,27 @@ export interface AccountMenuButtonProps {
|
|
|
19
21
|
const isWeb = Platform.OS === 'web';
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
|
-
* Avatar entry-point that opens the unified {@link
|
|
23
|
-
* active account from `useOxy()` — never
|
|
24
|
+
* Avatar entry-point that opens the unified {@link AccountSwitcher}. Reads the
|
|
25
|
+
* EFFECTIVE active account from `useOxy().activeAccount` — never receives user
|
|
26
|
+
* data via props.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
28
|
+
* The chip reflects the account the user is currently switched into (an org /
|
|
29
|
+
* project / bot / shared account) exactly as it reflects their personal account:
|
|
30
|
+
* a switch makes the whole app — including this header avatar — become that
|
|
31
|
+
* account. `activeAccount` falls back to the personal user when no switch is
|
|
32
|
+
* active, so the chip always shows the current account.
|
|
33
|
+
*
|
|
34
|
+
* Renders a small avatar chip (top-right friendly). Click → opens the switcher
|
|
35
|
+
* (device sign-ins + account graph). Pure component: owns only the open-state
|
|
36
|
+
* and the trigger's measured anchor. Create-account and per-account settings
|
|
37
|
+
* route through the global bottom-sheet manager.
|
|
27
38
|
*/
|
|
28
39
|
const AccountMenuButton: React.FC<AccountMenuButtonProps> = ({
|
|
29
40
|
size = 36,
|
|
30
41
|
onNavigateManage,
|
|
31
42
|
onAddAccount,
|
|
32
43
|
}) => {
|
|
33
|
-
const {
|
|
44
|
+
const { activeAccount, oxyServices, isAuthenticated } = useOxy();
|
|
34
45
|
const { t, locale } = useI18n();
|
|
35
46
|
const [open, setOpen] = useState(false);
|
|
36
47
|
const [anchor, setAnchor] = useState<AccountMenuAnchor | null>(null);
|
|
@@ -66,9 +77,9 @@ const AccountMenuButton: React.FC<AccountMenuButtonProps> = ({
|
|
|
66
77
|
}
|
|
67
78
|
}, [measureAnchor, open]);
|
|
68
79
|
|
|
69
|
-
const displayName = getAccountDisplayName(
|
|
70
|
-
const avatarUri =
|
|
71
|
-
? oxyServices.getFileDownloadUrl(
|
|
80
|
+
const displayName = getAccountDisplayName(activeAccount, locale);
|
|
81
|
+
const avatarUri = activeAccount?.avatar
|
|
82
|
+
? oxyServices.getFileDownloadUrl(activeAccount.avatar, 'thumb')
|
|
72
83
|
: undefined;
|
|
73
84
|
|
|
74
85
|
const accessibilityLabel = isAuthenticated
|
|
@@ -91,11 +102,15 @@ const AccountMenuButton: React.FC<AccountMenuButtonProps> = ({
|
|
|
91
102
|
>
|
|
92
103
|
<Avatar uri={avatarUri} name={displayName} size={size} />
|
|
93
104
|
</TouchableOpacity>
|
|
94
|
-
<
|
|
105
|
+
<AccountSwitcher
|
|
95
106
|
open={open}
|
|
96
107
|
onClose={handleClose}
|
|
97
108
|
onNavigateManage={onNavigateManage}
|
|
98
109
|
onAddAccount={onAddAccount}
|
|
110
|
+
onCreateAccount={() => showBottomSheet('CreateAccount')}
|
|
111
|
+
onOpenAccountSettings={(accountId) =>
|
|
112
|
+
showBottomSheet({ screen: 'AccountSettings', props: { accountId } })
|
|
113
|
+
}
|
|
99
114
|
anchor={anchor}
|
|
100
115
|
/>
|
|
101
116
|
</>
|