@oxyhq/services 10.2.10 → 10.3.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.map +1 -1
- package/lib/commonjs/ui/components/ActingAsBanner.js +2 -1
- package/lib/commonjs/ui/components/ActingAsBanner.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +107 -1
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/ui/components/StepBasedScreen.js +19 -10
- package/lib/commonjs/ui/components/StepBasedScreen.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +38 -122
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +9 -7
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/useDeviceAccounts.js +20 -25
- package/lib/commonjs/ui/hooks/useDeviceAccounts.js.map +1 -1
- package/lib/commonjs/ui/hooks/useFollow.js +7 -0
- package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
- package/lib/commonjs/ui/hooks/useFollow.types.js +4 -0
- package/lib/commonjs/ui/hooks/useProfileEditing.js +19 -10
- package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +1 -2
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ConnectedAppsScreen.js +1 -2
- package/lib/commonjs/ui/screens/ConnectedAppsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +11 -13
- package/lib/commonjs/ui/screens/EditProfileFieldScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js +2 -3
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HelpSupportScreen.js +2 -2
- package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HistoryViewScreen.js +2 -2
- package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +2 -3
- package/lib/commonjs/ui/screens/LanguageSelectorScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js +2 -2
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ManageAccountScreen.js +1 -2
- package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/NotificationsScreen.js +2 -2
- package/lib/commonjs/ui/screens/NotificationsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +2 -2
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PreferencesScreen.js +2 -2
- package/lib/commonjs/ui/screens/PreferencesScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +4 -3
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +3 -4
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js +2 -2
- package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/trust/TrustFAQScreen.js +2 -2
- package/lib/commonjs/ui/screens/trust/TrustFAQScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js +2 -2
- package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/stores/followStore.js +68 -0
- package/lib/commonjs/ui/stores/followStore.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/ActingAsBanner.js +2 -1
- package/lib/module/ui/components/ActingAsBanner.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +109 -3
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/StepBasedScreen.js +19 -10
- package/lib/module/ui/components/StepBasedScreen.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +38 -122
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +9 -7
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/useDeviceAccounts.js +20 -25
- package/lib/module/ui/hooks/useDeviceAccounts.js.map +1 -1
- package/lib/module/ui/hooks/useFollow.js +7 -0
- package/lib/module/ui/hooks/useFollow.js.map +1 -1
- package/lib/module/ui/hooks/useFollow.types.js +2 -0
- package/lib/module/ui/hooks/useProfileEditing.js +19 -10
- package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/ConnectedAppsScreen.js +1 -1
- package/lib/module/ui/screens/ConnectedAppsScreen.js.map +1 -1
- package/lib/module/ui/screens/EditProfileFieldScreen.js +10 -11
- package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/HelpSupportScreen.js +1 -1
- package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/module/ui/screens/HistoryViewScreen.js +1 -1
- package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/module/ui/screens/LanguageSelectorScreen.js +1 -1
- package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
- package/lib/module/ui/screens/LegalDocumentsScreen.js +1 -1
- package/lib/module/ui/screens/LegalDocumentsScreen.js.map +1 -1
- package/lib/module/ui/screens/ManageAccountScreen.js +1 -1
- package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/NotificationsScreen.js +1 -1
- package/lib/module/ui/screens/NotificationsScreen.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/module/ui/screens/PreferencesScreen.js +1 -1
- package/lib/module/ui/screens/PreferencesScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +5 -4
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SavesCollectionsScreen.js +2 -3
- package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/module/ui/screens/trust/TrustCenterScreen.js +1 -1
- package/lib/module/ui/screens/trust/TrustCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/trust/TrustFAQScreen.js +1 -1
- package/lib/module/ui/screens/trust/TrustFAQScreen.js.map +1 -1
- package/lib/module/ui/screens/trust/TrustRewardsScreen.js +1 -1
- package/lib/module/ui/screens/trust/TrustRewardsScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/stores/followStore.js +68 -0
- package/lib/module/ui/stores/followStore.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +1 -1
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ActingAsBanner.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/FollowButton.d.ts +24 -4
- package/lib/typescript/commonjs/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/StepBasedScreen.d.ts +5 -3
- package/lib/typescript/commonjs/ui/components/StepBasedScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +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 +52 -6
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useDeviceAccounts.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useFollow.d.ts +3 -1
- package/lib/typescript/commonjs/ui/hooks/useFollow.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useFollow.types.d.ts +2 -0
- package/lib/typescript/commonjs/ui/hooks/useFollow.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useProfileEditing.d.ts +22 -18
- package/lib/typescript/commonjs/ui/hooks/useProfileEditing.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/stores/authStore.d.ts +2 -10
- package/lib/typescript/commonjs/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/stores/followStore.d.ts +2 -1
- package/lib/typescript/commonjs/ui/stores/followStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts +0 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts +2 -1
- package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ActingAsBanner.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/FollowButton.d.ts +24 -4
- package/lib/typescript/module/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/StepBasedScreen.d.ts +5 -3
- package/lib/typescript/module/ui/components/StepBasedScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +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 +52 -6
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useDeviceAccounts.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useFollow.d.ts +3 -1
- package/lib/typescript/module/ui/hooks/useFollow.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useFollow.types.d.ts +2 -0
- package/lib/typescript/module/ui/hooks/useFollow.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useProfileEditing.d.ts +22 -18
- package/lib/typescript/module/ui/hooks/useProfileEditing.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/stores/authStore.d.ts +2 -10
- package/lib/typescript/module/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/stores/followStore.d.ts +2 -1
- package/lib/typescript/module/ui/stores/followStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/types/navigation.d.ts +0 -1
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/avatarUtils.d.ts +2 -1
- package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/index.ts +1 -0
- package/src/ui/components/ActingAsBanner.tsx +2 -4
- package/src/ui/components/FollowButton.tsx +154 -10
- package/src/ui/components/StepBasedScreen.tsx +37 -22
- package/src/ui/context/hooks/useAuthOperations.ts +51 -144
- package/src/ui/hooks/mutations/useAccountMutations.ts +9 -8
- package/src/ui/hooks/useDeviceAccounts.ts +20 -24
- package/src/ui/hooks/useFollow.ts +8 -1
- package/src/ui/hooks/useFollow.types.ts +3 -0
- package/src/ui/hooks/useProfileEditing.ts +43 -30
- package/src/ui/screens/AppInfoScreen.tsx +1 -1
- package/src/ui/screens/ConnectedAppsScreen.tsx +1 -1
- package/src/ui/screens/EditProfileFieldScreen.tsx +24 -14
- package/src/ui/screens/FeedbackScreen.tsx +1 -1
- package/src/ui/screens/HelpSupportScreen.tsx +1 -1
- package/src/ui/screens/HistoryViewScreen.tsx +1 -1
- package/src/ui/screens/LanguageSelectorScreen.tsx +1 -1
- package/src/ui/screens/LegalDocumentsScreen.tsx +1 -1
- package/src/ui/screens/ManageAccountScreen.tsx +1 -1
- package/src/ui/screens/NotificationsScreen.tsx +1 -1
- package/src/ui/screens/PaymentGatewayScreen.tsx +1 -1
- package/src/ui/screens/PreferencesScreen.tsx +1 -1
- package/src/ui/screens/ProfileScreen.tsx +4 -4
- package/src/ui/screens/SavesCollectionsScreen.tsx +3 -6
- package/src/ui/screens/trust/TrustCenterScreen.tsx +1 -1
- package/src/ui/screens/trust/TrustFAQScreen.tsx +1 -1
- package/src/ui/screens/trust/TrustRewardsScreen.tsx +1 -1
- package/src/ui/stores/authStore.ts +4 -13
- package/src/ui/stores/followStore.ts +47 -1
- package/src/ui/types/navigation.ts +0 -4
- package/src/ui/utils/avatarUtils.ts +3 -2
- package/lib/commonjs/ui/styles/spacing.js +0 -68
- package/lib/commonjs/ui/styles/spacing.js.map +0 -1
- package/lib/commonjs/ui/utils/themeUtils.js +0 -37
- package/lib/commonjs/ui/utils/themeUtils.js.map +0 -1
- package/lib/module/ui/styles/spacing.js +0 -16
- package/lib/module/ui/styles/spacing.js.map +0 -1
- package/lib/module/ui/utils/themeUtils.js +0 -13
- package/lib/module/ui/utils/themeUtils.js.map +0 -1
- package/lib/typescript/commonjs/ui/styles/spacing.d.ts +0 -13
- package/lib/typescript/commonjs/ui/styles/spacing.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/utils/themeUtils.d.ts +0 -11
- package/lib/typescript/commonjs/ui/utils/themeUtils.d.ts.map +0 -1
- package/lib/typescript/module/ui/styles/spacing.d.ts +0 -13
- package/lib/typescript/module/ui/styles/spacing.d.ts.map +0 -1
- package/lib/typescript/module/ui/utils/themeUtils.d.ts +0 -11
- package/lib/typescript/module/ui/utils/themeUtils.d.ts.map +0 -1
- package/src/ui/styles/spacing.ts +0 -22
- package/src/ui/utils/themeUtils.ts +0 -18
|
@@ -13,20 +13,31 @@ import Animated, {
|
|
|
13
13
|
} from 'react-native-reanimated';
|
|
14
14
|
import { useTheme } from '@oxyhq/bloom/theme';
|
|
15
15
|
import type { ThemeColors } from '@oxyhq/bloom/theme';
|
|
16
|
+
import type { OxyServices } from '@oxyhq/core';
|
|
16
17
|
import { createAuthStyles } from '../styles/authStyles';
|
|
17
18
|
import type { BaseScreenProps, StepController } from '../types/navigation';
|
|
18
|
-
import type { RouteName } from '../
|
|
19
|
+
import type { RouteName } from '../navigation/routes';
|
|
19
20
|
import { screenContentStyle } from '../constants/spacing';
|
|
20
21
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
type StepStyles = Record<string, unknown> & {
|
|
24
|
+
stepContainer: ViewStyle;
|
|
25
|
+
progressContainer: ViewStyle;
|
|
26
|
+
progressDot: ViewStyle;
|
|
27
|
+
};
|
|
28
|
+
type StepComponentProps = BaseScreenProps & Record<string, unknown>;
|
|
29
|
+
|
|
30
|
+
function isVoidCallback(value: unknown): value is () => void {
|
|
31
|
+
return typeof value === 'function';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isAuthenticatedCallback(value: unknown): value is (payload?: unknown) => void {
|
|
35
|
+
return typeof value === 'function';
|
|
36
|
+
}
|
|
25
37
|
|
|
26
38
|
export interface StepConfig {
|
|
27
39
|
id: string;
|
|
28
|
-
|
|
29
|
-
component: React.ComponentType<any>;
|
|
40
|
+
component: React.ComponentType<StepComponentProps>;
|
|
30
41
|
props?: Record<string, unknown>;
|
|
31
42
|
canProceed?: (stepData?: unknown) => boolean;
|
|
32
43
|
onEnter?: () => void;
|
|
@@ -42,8 +53,7 @@ export interface StepBasedScreenProps extends Omit<BaseScreenProps, 'navigate'>
|
|
|
42
53
|
onComplete?: (stepData: unknown[]) => void;
|
|
43
54
|
stepData?: unknown[];
|
|
44
55
|
navigate: (screen: RouteName, props?: Record<string, unknown>) => void;
|
|
45
|
-
|
|
46
|
-
oxyServices: any;
|
|
56
|
+
oxyServices: OxyServices;
|
|
47
57
|
getNavigationProps?: () => Record<string, unknown>;
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -153,7 +163,7 @@ const StepBasedScreen: React.FC<StepBasedScreenProps> = ({
|
|
|
153
163
|
secondaryText: colors.textSecondary,
|
|
154
164
|
}), [colors]);
|
|
155
165
|
const insets = useSafeAreaInsets();
|
|
156
|
-
const styles = useMemo(() => ({
|
|
166
|
+
const styles = useMemo<StepStyles>(() => ({
|
|
157
167
|
...createAuthStyles(authColors, themeString),
|
|
158
168
|
// Additional styles for step components
|
|
159
169
|
modernHeader: {
|
|
@@ -222,7 +232,7 @@ const StepBasedScreen: React.FC<StepBasedScreenProps> = ({
|
|
|
222
232
|
},
|
|
223
233
|
progressContainer: {
|
|
224
234
|
flexDirection: 'row' as const,
|
|
225
|
-
width: '100%',
|
|
235
|
+
width: '100%' as const,
|
|
226
236
|
justifyContent: 'center' as const,
|
|
227
237
|
marginTop: 24, // Space for bottom sheet handle (~20px) + small buffer
|
|
228
238
|
marginBottom: 0, // BottomSheet handles all bottom spacing
|
|
@@ -410,15 +420,26 @@ const StepBasedScreen: React.FC<StepBasedScreenProps> = ({
|
|
|
410
420
|
[currentStep, updateStepData]
|
|
411
421
|
);
|
|
412
422
|
|
|
413
|
-
const
|
|
423
|
+
const normalizedTheme = typeof theme === 'string' ? theme : undefined;
|
|
424
|
+
const normalizedGoBack = isVoidCallback(goBack) ? goBack : undefined;
|
|
425
|
+
const normalizedOnAuthenticated = isAuthenticatedCallback(onAuthenticated) ? onAuthenticated : undefined;
|
|
426
|
+
|
|
427
|
+
const baseStepProps = useMemo<BaseScreenProps>(() => ({
|
|
428
|
+
theme: normalizedTheme,
|
|
429
|
+
navigate,
|
|
430
|
+
goBack: normalizedGoBack,
|
|
431
|
+
onAuthenticated: normalizedOnAuthenticated,
|
|
432
|
+
}), [normalizedTheme, navigate, normalizedGoBack, normalizedOnAuthenticated]);
|
|
433
|
+
|
|
434
|
+
const stepProps = useMemo<StepComponentProps>(() => ({
|
|
414
435
|
...currentStepConfig?.props,
|
|
436
|
+
// Step data - spread before base props so navigation/auth props remain stable.
|
|
437
|
+
...(state.stepData[currentStep] as Record<string, unknown> | undefined),
|
|
438
|
+
|
|
415
439
|
// Common props
|
|
440
|
+
...baseStepProps,
|
|
416
441
|
colors,
|
|
417
442
|
styles,
|
|
418
|
-
theme,
|
|
419
|
-
navigate,
|
|
420
|
-
goBack,
|
|
421
|
-
onAuthenticated,
|
|
422
443
|
oxyServices,
|
|
423
444
|
|
|
424
445
|
// Step navigation
|
|
@@ -428,20 +449,14 @@ const StepBasedScreen: React.FC<StepBasedScreenProps> = ({
|
|
|
428
449
|
currentStep: currentStep,
|
|
429
450
|
totalSteps: steps.length,
|
|
430
451
|
|
|
431
|
-
// Step data - spread the step data properties directly as props
|
|
432
|
-
...(state.stepData[currentStep] as Record<string, unknown> | undefined),
|
|
433
|
-
|
|
434
452
|
// Step data management
|
|
435
453
|
updateStepData: updateCurrentStepData,
|
|
436
454
|
allStepData: state.stepData,
|
|
437
455
|
}), [
|
|
438
456
|
currentStepConfig?.props,
|
|
457
|
+
baseStepProps,
|
|
439
458
|
colors,
|
|
440
459
|
styles,
|
|
441
|
-
theme,
|
|
442
|
-
navigate,
|
|
443
|
-
goBack,
|
|
444
|
-
onAuthenticated,
|
|
445
460
|
oxyServices,
|
|
446
461
|
nextStep,
|
|
447
462
|
prevStep,
|
|
@@ -11,11 +11,6 @@ import { SignatureService } from '@oxyhq/core';
|
|
|
11
11
|
import { isWebBrowser } from '../../hooks/useWebSSO';
|
|
12
12
|
import { clearActiveAuthuser, clearSsoBounceState } from '../../utils/activeAuthuser';
|
|
13
13
|
|
|
14
|
-
/** Type guard for error objects with optional code and status properties */
|
|
15
|
-
function isErrorWithCodeOrStatus(error: unknown): error is { code?: string; status?: number; message?: string } {
|
|
16
|
-
return typeof error === 'object' && error !== null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
14
|
export interface UseAuthOperationsOptions {
|
|
20
15
|
oxyServices: OxyServices;
|
|
21
16
|
storage: StorageInterface | null;
|
|
@@ -55,7 +50,6 @@ const LOGOUT_ALL_ERROR_CODE = 'LOGOUT_ALL_ERROR';
|
|
|
55
50
|
*/
|
|
56
51
|
export const useAuthOperations = ({
|
|
57
52
|
oxyServices,
|
|
58
|
-
storage,
|
|
59
53
|
sessions,
|
|
60
54
|
activeSessionId,
|
|
61
55
|
setActiveSessionId,
|
|
@@ -77,7 +71,7 @@ export const useAuthOperations = ({
|
|
|
77
71
|
sessionsRef.current = sessions;
|
|
78
72
|
|
|
79
73
|
/**
|
|
80
|
-
* Internal function to perform challenge-response sign in
|
|
74
|
+
* Internal function to perform challenge-response sign in.
|
|
81
75
|
*/
|
|
82
76
|
const performSignIn = useCallback(
|
|
83
77
|
async (publicKey: string): Promise<User> => {
|
|
@@ -86,36 +80,8 @@ export const useAuthOperations = ({
|
|
|
86
80
|
const deviceInfo = await DeviceManager.getDeviceInfo();
|
|
87
81
|
const deviceName = deviceInfo.deviceName || DeviceManager.getDefaultDeviceName();
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// Try to request challenge from server (online)
|
|
93
|
-
try {
|
|
94
|
-
const challengeResponse = await oxyServices.requestChallenge(publicKey);
|
|
95
|
-
challenge = challengeResponse.challenge;
|
|
96
|
-
} catch (error) {
|
|
97
|
-
// Network error - generate challenge locally for offline sign-in
|
|
98
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
99
|
-
const isNetworkError =
|
|
100
|
-
errorMessage.includes('Network') ||
|
|
101
|
-
errorMessage.includes('network') ||
|
|
102
|
-
errorMessage.includes('Failed to fetch') ||
|
|
103
|
-
errorMessage.includes('fetch failed') ||
|
|
104
|
-
(isErrorWithCodeOrStatus(error) && error.code === 'NETWORK_ERROR') ||
|
|
105
|
-
(isErrorWithCodeOrStatus(error) && error.status === 0);
|
|
106
|
-
|
|
107
|
-
if (isNetworkError) {
|
|
108
|
-
if (__DEV__ && logger) {
|
|
109
|
-
logger('Network unavailable, performing offline sign-in');
|
|
110
|
-
}
|
|
111
|
-
// Generate challenge locally
|
|
112
|
-
challenge = await SignatureService.generateChallenge();
|
|
113
|
-
isOffline = true;
|
|
114
|
-
} else {
|
|
115
|
-
// Re-throw non-network errors
|
|
116
|
-
throw error;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
83
|
+
const challengeResponse = await oxyServices.requestChallenge(publicKey);
|
|
84
|
+
const challenge = challengeResponse.challenge;
|
|
119
85
|
|
|
120
86
|
// Note: Biometric authentication check should be handled by the app layer
|
|
121
87
|
// (e.g., accounts app) before calling signIn. The biometric preference is stored
|
|
@@ -127,123 +93,65 @@ export const useAuthOperations = ({
|
|
|
127
93
|
let fullUser: User;
|
|
128
94
|
let sessionResponse: SessionLoginResponse;
|
|
129
95
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
user: {
|
|
155
|
-
id: publicKey,
|
|
156
|
-
username: '',
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
// Store offline session locally
|
|
161
|
-
const offlineSession: ClientSession = {
|
|
162
|
-
sessionId: localSessionId,
|
|
163
|
-
deviceId: localDeviceId,
|
|
164
|
-
expiresAt,
|
|
165
|
-
lastActive: new Date().toISOString(),
|
|
166
|
-
userId: publicKey,
|
|
167
|
-
isCurrent: true,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
setActiveSessionId(localSessionId);
|
|
171
|
-
await saveActiveSessionId(localSessionId);
|
|
172
|
-
updateSessions([offlineSession], { merge: true });
|
|
173
|
-
|
|
174
|
-
// Mark session as offline for later sync
|
|
175
|
-
if (storage) {
|
|
176
|
-
await storage.setItem(`oxy_session_${localSessionId}_offline`, 'true');
|
|
177
|
-
}
|
|
178
|
-
|
|
96
|
+
// `verifyChallenge` plants the first access token internally, mirroring
|
|
97
|
+
// `claimSessionByToken`, so the client is authenticated as soon as this
|
|
98
|
+
// resolves.
|
|
99
|
+
sessionResponse = await oxyServices.verifyChallenge(
|
|
100
|
+
publicKey,
|
|
101
|
+
challenge,
|
|
102
|
+
signature,
|
|
103
|
+
timestamp,
|
|
104
|
+
deviceName,
|
|
105
|
+
deviceFingerprint,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Get full user data
|
|
109
|
+
fullUser = await oxyServices.getUserBySession(sessionResponse.sessionId);
|
|
110
|
+
|
|
111
|
+
// Fetch device sessions
|
|
112
|
+
let allDeviceSessions: ClientSession[] = [];
|
|
113
|
+
try {
|
|
114
|
+
allDeviceSessions = await fetchSessionsWithFallback(oxyServices, sessionResponse.sessionId, {
|
|
115
|
+
fallbackDeviceId: sessionResponse.deviceId,
|
|
116
|
+
fallbackUserId: fullUser.id,
|
|
117
|
+
logger,
|
|
118
|
+
});
|
|
119
|
+
} catch (error) {
|
|
179
120
|
if (__DEV__ && logger) {
|
|
180
|
-
logger('
|
|
121
|
+
logger('Failed to fetch device sessions after login', error);
|
|
181
122
|
}
|
|
182
|
-
}
|
|
183
|
-
// Online sign-in: use normal flow.
|
|
184
|
-
// Verify and create session. `verifyChallenge` plants the first
|
|
185
|
-
// access token (and refresh token) from the `/auth/verify` response
|
|
186
|
-
// body internally — mirroring `claimSessionByToken` — so the client is
|
|
187
|
-
// authenticated as soon as this resolves. Session IDs are not public
|
|
188
|
-
// token-minting credentials; a token-less verify response simply leaves
|
|
189
|
-
// the client without a bearer here.
|
|
190
|
-
sessionResponse = await oxyServices.verifyChallenge(
|
|
191
|
-
publicKey,
|
|
192
|
-
challenge,
|
|
193
|
-
signature,
|
|
194
|
-
timestamp,
|
|
195
|
-
deviceName,
|
|
196
|
-
deviceFingerprint,
|
|
197
|
-
);
|
|
123
|
+
}
|
|
198
124
|
|
|
199
|
-
|
|
200
|
-
|
|
125
|
+
// Check for existing session for same user and switch to it to avoid duplicates
|
|
126
|
+
const existingSession = allDeviceSessions.find(
|
|
127
|
+
(session) =>
|
|
128
|
+
session.userId?.toString() === fullUser.id?.toString() &&
|
|
129
|
+
session.sessionId !== sessionResponse.sessionId,
|
|
130
|
+
);
|
|
201
131
|
|
|
202
|
-
|
|
203
|
-
|
|
132
|
+
if (existingSession) {
|
|
133
|
+
// Switch to existing session instead of creating duplicate
|
|
204
134
|
try {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
logger,
|
|
209
|
-
});
|
|
210
|
-
} catch (error) {
|
|
135
|
+
await oxyServices.logoutSession(sessionResponse.sessionId, sessionResponse.sessionId);
|
|
136
|
+
} catch (logoutError) {
|
|
137
|
+
// Non-critical - continue to switch session even if logout fails
|
|
211
138
|
if (__DEV__ && logger) {
|
|
212
|
-
logger('Failed to
|
|
139
|
+
logger('Failed to logout duplicate session, continuing with switch', logoutError);
|
|
213
140
|
}
|
|
214
141
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
session.userId?.toString() === fullUser.id?.toString() &&
|
|
220
|
-
session.sessionId !== sessionResponse.sessionId,
|
|
142
|
+
await switchSession(existingSession.sessionId);
|
|
143
|
+
updateSessions(
|
|
144
|
+
allDeviceSessions.filter((session) => session.sessionId !== sessionResponse.sessionId),
|
|
145
|
+
{ merge: false },
|
|
221
146
|
);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// Switch to existing session instead of creating duplicate
|
|
225
|
-
try {
|
|
226
|
-
await oxyServices.logoutSession(sessionResponse.sessionId, sessionResponse.sessionId);
|
|
227
|
-
} catch (logoutError) {
|
|
228
|
-
// Non-critical - continue to switch session even if logout fails
|
|
229
|
-
if (__DEV__ && logger) {
|
|
230
|
-
logger('Failed to logout duplicate session, continuing with switch', logoutError);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
await switchSession(existingSession.sessionId);
|
|
234
|
-
updateSessions(
|
|
235
|
-
allDeviceSessions.filter((session) => session.sessionId !== sessionResponse.sessionId),
|
|
236
|
-
{ merge: false },
|
|
237
|
-
);
|
|
238
|
-
onAuthStateChange?.(fullUser);
|
|
239
|
-
return fullUser;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
setActiveSessionId(sessionResponse.sessionId);
|
|
243
|
-
await saveActiveSessionId(sessionResponse.sessionId);
|
|
244
|
-
updateSessions(allDeviceSessions, { merge: true });
|
|
147
|
+
onAuthStateChange?.(fullUser);
|
|
148
|
+
return fullUser;
|
|
245
149
|
}
|
|
246
150
|
|
|
151
|
+
setActiveSessionId(sessionResponse.sessionId);
|
|
152
|
+
await saveActiveSessionId(sessionResponse.sessionId);
|
|
153
|
+
updateSessions(allDeviceSessions, { merge: true });
|
|
154
|
+
|
|
247
155
|
await applyLanguagePreference(fullUser);
|
|
248
156
|
loginSuccess(fullUser);
|
|
249
157
|
onAuthStateChange?.(fullUser);
|
|
@@ -260,7 +168,6 @@ export const useAuthOperations = ({
|
|
|
260
168
|
setActiveSessionId,
|
|
261
169
|
switchSession,
|
|
262
170
|
updateSessions,
|
|
263
|
-
storage,
|
|
264
171
|
],
|
|
265
172
|
);
|
|
266
173
|
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
User,
|
|
8
8
|
UserPreferences,
|
|
9
9
|
} from '@oxyhq/core';
|
|
10
|
+
import type { UserProfileUpdate } from '@oxyhq/contracts';
|
|
10
11
|
import {
|
|
11
12
|
queryKeys,
|
|
12
13
|
invalidateAccountQueries,
|
|
@@ -29,7 +30,7 @@ export const useUpdateProfile = () => {
|
|
|
29
30
|
|
|
30
31
|
return useMutation({
|
|
31
32
|
mutationKey: [...mutationKeys.account.updateProfile],
|
|
32
|
-
mutationFn: async (updates:
|
|
33
|
+
mutationFn: async (updates: UserProfileUpdate) => {
|
|
33
34
|
return authenticatedApiCall<User>(
|
|
34
35
|
oxyServices,
|
|
35
36
|
activeSessionId,
|
|
@@ -46,17 +47,18 @@ export const useUpdateProfile = () => {
|
|
|
46
47
|
|
|
47
48
|
// Optimistically update
|
|
48
49
|
if (previousUser) {
|
|
49
|
-
|
|
50
|
+
const optimisticUser: User = {
|
|
50
51
|
...previousUser,
|
|
51
52
|
...updates,
|
|
52
|
-
|
|
53
|
+
name: updates.name
|
|
54
|
+
? { ...previousUser.name, ...updates.name }
|
|
55
|
+
: previousUser.name,
|
|
56
|
+
};
|
|
57
|
+
queryClient.setQueryData<User>(queryKeys.accounts.current(), optimisticUser);
|
|
53
58
|
|
|
54
59
|
// Also update profile query if sessionId is available
|
|
55
60
|
if (activeSessionId) {
|
|
56
|
-
queryClient.setQueryData<User>(queryKeys.users.profile(activeSessionId),
|
|
57
|
-
...previousUser,
|
|
58
|
-
...updates,
|
|
59
|
-
});
|
|
61
|
+
queryClient.setQueryData<User>(queryKeys.users.profile(activeSessionId), optimisticUser);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -684,4 +686,3 @@ export const useUploadFile = () => {
|
|
|
684
686
|
},
|
|
685
687
|
});
|
|
686
688
|
};
|
|
687
|
-
|
|
@@ -252,19 +252,16 @@ export function useDeviceAccounts(): UseDeviceAccountsResult {
|
|
|
252
252
|
|
|
253
253
|
if (fromSharedApex) {
|
|
254
254
|
// Shared apex path: every entry carries a real per-account user.
|
|
255
|
-
built = sharedAccounts.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const accountUser: DeviceAccountUser = entry.user
|
|
260
|
-
id: '',
|
|
261
|
-
username: '',
|
|
262
|
-
};
|
|
255
|
+
built = sharedAccounts.flatMap((entry): DeviceAccount[] => {
|
|
256
|
+
if (!entry.user) {
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
const accountUser: DeviceAccountUser = entry.user;
|
|
263
260
|
const displayName = getAccountDisplayName(accountUser, locale);
|
|
264
261
|
const handle = getAccountFallbackHandle(accountUser);
|
|
265
|
-
const email = entry.user
|
|
262
|
+
const email = entry.user.email ?? null;
|
|
266
263
|
const secondaryHandle = handle ? `@${handle}` : null;
|
|
267
|
-
return {
|
|
264
|
+
return [{
|
|
268
265
|
sessionId: entry.sessionId,
|
|
269
266
|
authuser: entry.authuser,
|
|
270
267
|
// Provisional; finalised by `markCurrentAccount` below so the
|
|
@@ -274,37 +271,36 @@ export function useDeviceAccounts(): UseDeviceAccountsResult {
|
|
|
274
271
|
// Real email, or null (NEVER synthesized). The UI uses the
|
|
275
272
|
// `@handle` line only when email is genuinely absent.
|
|
276
273
|
email: email ?? secondaryHandle,
|
|
277
|
-
avatarUrl: resolveAvatarUrl(entry.user
|
|
278
|
-
color: entry.user
|
|
274
|
+
avatarUrl: resolveAvatarUrl(entry.user.avatar),
|
|
275
|
+
color: entry.user.color ?? null,
|
|
279
276
|
user: accountUser,
|
|
280
|
-
};
|
|
277
|
+
}];
|
|
281
278
|
});
|
|
282
279
|
} else {
|
|
283
280
|
// Local fallback path: build from the SDK's multi-session store. The
|
|
284
281
|
// active session row gets the full loaded `user`; inactive fallback
|
|
285
282
|
// rows carry only what the `ClientSession` exposes (no synthesized
|
|
286
283
|
// identity — they show the active user's data only when active).
|
|
287
|
-
built = (sessions ?? []).
|
|
284
|
+
built = (sessions ?? []).flatMap((session: ClientSession): DeviceAccount[] => {
|
|
288
285
|
const isCurrent = session.sessionId === activeSessionId;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
286
|
+
if (!isCurrent || !user) {
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
const accountUser: DeviceAccountUser = user;
|
|
292
290
|
const displayName = getAccountDisplayName(accountUser, locale);
|
|
293
291
|
const handle = getAccountFallbackHandle(accountUser);
|
|
294
|
-
const email =
|
|
292
|
+
const email = user.email ?? null;
|
|
295
293
|
const secondaryHandle = handle ? `@${handle}` : null;
|
|
296
|
-
|
|
297
|
-
const color = isCurrent && user?.color ? user.color : null;
|
|
298
|
-
return {
|
|
294
|
+
return [{
|
|
299
295
|
sessionId: session.sessionId,
|
|
300
296
|
authuser: session.authuser,
|
|
301
297
|
isCurrent,
|
|
302
298
|
displayName,
|
|
303
299
|
email: email ?? secondaryHandle,
|
|
304
|
-
avatarUrl: resolveAvatarUrl(avatar),
|
|
305
|
-
color,
|
|
300
|
+
avatarUrl: resolveAvatarUrl(user.avatar),
|
|
301
|
+
color: user.color ?? null,
|
|
306
302
|
user: accountUser,
|
|
307
|
-
};
|
|
303
|
+
}];
|
|
308
304
|
});
|
|
309
305
|
}
|
|
310
306
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useMemo, useEffect } from 'react';
|
|
2
2
|
import { useFollowStore } from '../stores/followStore';
|
|
3
3
|
import { useOxy } from '../context/OxyContext';
|
|
4
|
-
import { logger as loggerUtil, type OxyServices } from '@oxyhq/core';
|
|
4
|
+
import { logger as loggerUtil, type OxyServices, type BulkFollowResult } from '@oxyhq/core';
|
|
5
5
|
import { useShallow } from 'zustand/react/shallow';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -144,6 +144,12 @@ export const useFollow = (userId?: string | string[]) => {
|
|
|
144
144
|
await Promise.all(userIds.map(uid => store.fetchFollowStatus(uid, oxyServices)));
|
|
145
145
|
}, [canUsePrivateApi, userIds, oxyServices]);
|
|
146
146
|
|
|
147
|
+
// Bulk follow — follows ALL users in ONE network call (never unfollows).
|
|
148
|
+
const followAllUsers = useCallback(async (): Promise<BulkFollowResult> => {
|
|
149
|
+
if (!canUsePrivateApi) throw new Error('Authentication is required to follow users');
|
|
150
|
+
return useFollowStore.getState().followManyUsers(userIds, oxyServices);
|
|
151
|
+
}, [canUsePrivateApi, userIds, oxyServices]);
|
|
152
|
+
|
|
147
153
|
const clearErrorForUser = useCallback((targetUserId: string) => {
|
|
148
154
|
useFollowStore.getState().clearFollowError(targetUserId);
|
|
149
155
|
}, []);
|
|
@@ -177,6 +183,7 @@ export const useFollow = (userId?: string | string[]) => {
|
|
|
177
183
|
setFollowStatusForUser,
|
|
178
184
|
fetchStatusForUser,
|
|
179
185
|
fetchAllStatuses,
|
|
186
|
+
followAllUsers,
|
|
180
187
|
clearErrorForUser,
|
|
181
188
|
isAnyLoading: multiUserLoadingState.isAnyLoading,
|
|
182
189
|
hasAnyError: multiUserLoadingState.hasAnyError,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Type-only definition for the useFollow hook to allow context exposure without runtime import cycles.
|
|
2
2
|
// Expand this as needed to better reflect the real return type.
|
|
3
3
|
|
|
4
|
+
import type { BulkFollowResult } from '@oxyhq/core';
|
|
5
|
+
|
|
4
6
|
export type SingleFollowResult = {
|
|
5
7
|
isFollowing: boolean;
|
|
6
8
|
isLoading: boolean;
|
|
@@ -23,6 +25,7 @@ export type MultiFollowResult = {
|
|
|
23
25
|
setFollowStatusForUser: (userId: string, following: boolean) => void;
|
|
24
26
|
fetchStatusForUser: (userId: string) => Promise<void>;
|
|
25
27
|
fetchAllStatuses: () => Promise<void>;
|
|
28
|
+
followAllUsers: () => Promise<BulkFollowResult>;
|
|
26
29
|
clearErrorForUser: (userId: string) => void;
|
|
27
30
|
isAnyLoading: boolean;
|
|
28
31
|
hasAnyError: boolean;
|