@oxyhq/services 5.7.5 → 5.8.2
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 +76 -76
- package/lib/commonjs/core/index.js +177 -102
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/index.js +69 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/Avatar.js +15 -6
- package/lib/commonjs/ui/components/Avatar.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +100 -12
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +58 -13
- package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedSection.js +7 -1
- package/lib/commonjs/ui/components/GroupedSection.js.map +1 -1
- package/lib/commonjs/ui/components/Header.js +356 -0
- package/lib/commonjs/ui/components/Header.js.map +1 -0
- package/lib/commonjs/ui/components/OxyProvider.js +28 -7
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/index.js +7 -0
- package/lib/commonjs/ui/components/index.js.map +1 -1
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +1 -1
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/commonjs/ui/components/internal/TextField.js +606 -546
- package/lib/commonjs/ui/components/internal/TextField.js.map +1 -1
- package/lib/commonjs/ui/components/internal/TextField.md +436 -0
- package/lib/commonjs/ui/context/OxyContext.js +181 -199
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/index.js +6 -0
- package/lib/commonjs/ui/hooks/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/useFollow.js +59 -2
- package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +5 -2
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/navigation/OxyRouter.js +11 -1
- package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +6 -6
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountManagementDemo.js +3 -3
- package/lib/commonjs/ui/screens/AccountManagementDemo.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +241 -598
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +1160 -406
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +135 -237
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +246 -463
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js +3 -3
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +808 -650
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +214 -37
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js +51 -72
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js +11 -29
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +30 -303
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignUpScreen.js +4 -4
- package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/UserLinksScreen.js +90 -0
- package/lib/commonjs/ui/screens/UserLinksScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +19 -31
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +7 -10
- package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +11 -5
- package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +11 -4
- package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +9 -6
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +3 -30
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js +37 -46
- package/lib/commonjs/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +9 -12
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +9 -12
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +9 -12
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +36 -6
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/stores/followStore.js +106 -1
- package/lib/commonjs/ui/stores/followStore.js.map +1 -1
- package/lib/commonjs/ui/styles/authStyles.js +337 -0
- package/lib/commonjs/ui/styles/authStyles.js.map +1 -0
- package/lib/commonjs/ui/styles/index.js +11 -0
- package/lib/commonjs/ui/styles/index.js.map +1 -1
- package/lib/module/core/index.js +177 -41
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/index.js +24 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/Avatar.js +15 -6
- package/lib/module/ui/components/Avatar.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +101 -13
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +59 -14
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/GroupedSection.js +7 -1
- package/lib/module/ui/components/GroupedSection.js.map +1 -1
- package/lib/module/ui/components/Header.js +351 -0
- package/lib/module/ui/components/Header.js.map +1 -0
- package/lib/module/ui/components/OxyProvider.js +30 -9
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/index.js +1 -0
- package/lib/module/ui/components/index.js.map +1 -1
- package/lib/module/ui/components/internal/GroupedPillButtons.js +1 -1
- package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/module/ui/components/internal/TextField.js +607 -547
- package/lib/module/ui/components/internal/TextField.js.map +1 -1
- package/lib/module/ui/components/internal/TextField.md +436 -0
- package/lib/module/ui/context/OxyContext.js +180 -198
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/index.js +1 -1
- package/lib/module/ui/hooks/index.js.map +1 -1
- package/lib/module/ui/hooks/useFollow.js +57 -1
- package/lib/module/ui/hooks/useFollow.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +5 -2
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/navigation/OxyRouter.js +11 -1
- package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +6 -6
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountManagementDemo.js +3 -3
- package/lib/module/ui/screens/AccountManagementDemo.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +242 -597
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +1161 -407
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +135 -237
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +248 -465
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js +3 -3
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +809 -651
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +214 -37
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/RecoverAccountScreen.js +53 -74
- package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js +11 -29
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +32 -305
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/SignUpScreen.js +5 -5
- package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/module/ui/screens/UserLinksScreen.js +85 -0
- package/lib/module/ui/screens/UserLinksScreen.js.map +1 -0
- package/lib/module/ui/screens/internal/SignInPasswordStep.js +19 -31
- package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -1
- package/lib/module/ui/screens/internal/SignInUsernameStep.js +7 -10
- package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +1 -1
- package/lib/module/ui/screens/internal/SignUpIdentityStep.js +11 -5
- package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +1 -1
- package/lib/module/ui/screens/internal/SignUpSecurityStep.js +11 -4
- package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js +9 -6
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +3 -30
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaFAQScreen.js +37 -46
- package/lib/module/ui/screens/karma/KarmaFAQScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +9 -12
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +9 -12
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js +9 -12
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +36 -6
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/stores/followStore.js +106 -1
- package/lib/module/ui/stores/followStore.js.map +1 -1
- package/lib/module/ui/styles/authStyles.js +332 -0
- package/lib/module/ui/styles/authStyles.js.map +1 -0
- package/lib/module/ui/styles/index.js +1 -0
- package/lib/module/ui/styles/index.js.map +1 -1
- package/lib/typescript/core/index.d.ts +68 -24
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +13 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/Avatar.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts +1 -0
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/ui/components/GroupedItem.d.ts +6 -0
- package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/ui/components/GroupedSection.d.ts +6 -0
- package/lib/typescript/ui/components/GroupedSection.d.ts.map +1 -1
- package/lib/typescript/ui/components/Header.d.ts +24 -0
- package/lib/typescript/ui/components/Header.d.ts.map +1 -0
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/components/index.d.ts +1 -0
- package/lib/typescript/ui/components/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/internal/TextField.d.ts +31 -16
- package/lib/typescript/ui/components/internal/TextField.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +5 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/index.d.ts +1 -1
- package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useFollow.d.ts +20 -0
- package/lib/typescript/ui/hooks/useFollow.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/OxyRouter.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/types.d.ts +9 -2
- package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts +5 -1
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/UserLinksScreen.d.ts +15 -0
- package/lib/typescript/ui/screens/UserLinksScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +1 -1
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +0 -1
- package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaAboutScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaFAQScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaLeaderboardScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaRulesScreen.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +3 -1
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/stores/followStore.d.ts +10 -0
- package/lib/typescript/ui/stores/followStore.d.ts.map +1 -1
- package/lib/typescript/ui/styles/authStyles.d.ts +326 -0
- package/lib/typescript/ui/styles/authStyles.d.ts.map +1 -0
- package/lib/typescript/ui/styles/index.d.ts +1 -0
- package/lib/typescript/ui/styles/index.d.ts.map +1 -1
- package/package.json +1 -4
- package/src/core/index.ts +195 -41
- package/src/index.ts +64 -4
- package/src/ui/components/Avatar.tsx +11 -5
- package/src/ui/components/FollowButton.tsx +95 -11
- package/src/ui/components/GroupedItem.tsx +57 -9
- package/src/ui/components/GroupedSection.tsx +12 -0
- package/src/ui/components/Header.tsx +405 -0
- package/src/ui/components/OxyProvider.tsx +37 -15
- package/src/ui/components/index.ts +1 -0
- package/src/ui/components/internal/GroupedPillButtons.tsx +1 -1
- package/src/ui/components/internal/TextField.md +436 -0
- package/src/ui/components/internal/TextField.tsx +720 -620
- package/src/ui/context/OxyContext.tsx +211 -195
- package/src/ui/hooks/index.ts +1 -1
- package/src/ui/hooks/useFollow.ts +63 -0
- package/src/ui/hooks/useSessionSocket.ts +5 -2
- package/src/ui/navigation/OxyRouter.tsx +11 -1
- package/src/ui/navigation/types.ts +10 -2
- package/src/ui/screens/AccountCenterScreen.tsx +5 -5
- package/src/ui/screens/AccountManagementDemo.tsx +9 -9
- package/src/ui/screens/AccountOverviewScreen.tsx +265 -414
- package/src/ui/screens/AccountSettingsScreen.tsx +1173 -403
- package/src/ui/screens/AccountSwitcherScreen.tsx +158 -202
- package/src/ui/screens/AppInfoScreen.tsx +270 -497
- package/src/ui/screens/FeedbackScreen.tsx +3 -3
- package/src/ui/screens/PaymentGatewayScreen.tsx +668 -365
- package/src/ui/screens/ProfileScreen.tsx +196 -33
- package/src/ui/screens/RecoverAccountScreen.tsx +46 -74
- package/src/ui/screens/SessionManagementScreen.tsx +14 -22
- package/src/ui/screens/SignInScreen.tsx +27 -294
- package/src/ui/screens/SignUpScreen.tsx +5 -5
- package/src/ui/screens/UserLinksScreen.tsx +96 -0
- package/src/ui/screens/internal/SignInPasswordStep.tsx +11 -22
- package/src/ui/screens/internal/SignInUsernameStep.tsx +3 -10
- package/src/ui/screens/internal/SignUpIdentityStep.tsx +2 -5
- package/src/ui/screens/internal/SignUpSecurityStep.tsx +3 -4
- package/src/ui/screens/karma/KarmaAboutScreen.tsx +9 -2
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +1 -20
- package/src/ui/screens/karma/KarmaFAQScreen.tsx +40 -24
- package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +9 -3
- package/src/ui/screens/karma/KarmaRewardsScreen.tsx +9 -3
- package/src/ui/screens/karma/KarmaRulesScreen.tsx +9 -3
- package/src/ui/stores/authStore.ts +34 -7
- package/src/ui/stores/followStore.ts +102 -1
- package/src/ui/styles/authStyles.ts +352 -0
- package/src/ui/styles/index.ts +1 -0
- package/lib/commonjs/core/auth-manager.js +0 -440
- package/lib/commonjs/core/auth-manager.js.map +0 -1
- package/lib/commonjs/core/use-auth.js +0 -244
- package/lib/commonjs/core/use-auth.js.map +0 -1
- package/lib/module/core/auth-manager.js +0 -432
- package/lib/module/core/auth-manager.js.map +0 -1
- package/lib/module/core/use-auth.js +0 -235
- package/lib/module/core/use-auth.js.map +0 -1
- package/lib/typescript/core/auth-manager.d.ts +0 -136
- package/lib/typescript/core/auth-manager.d.ts.map +0 -1
- package/lib/typescript/core/use-auth.d.ts +0 -79
- package/lib/typescript/core/use-auth.d.ts.map +0 -1
- package/src/__tests__/middleware.test.ts +0 -105
- package/src/__tests__/setup.ts +0 -10
- package/src/__tests__/zero-config-auth.test.ts +0 -607
- package/src/core/auth-manager.ts +0 -500
- package/src/core/use-auth.tsx +0 -245
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useOxy = exports.default = exports.OxyContextProvider = void 0;
|
|
6
|
+
exports.useOxy = exports.default = exports.OxyProvider = exports.OxyContextProvider = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _core = require("../../core");
|
|
8
9
|
var _deviceManager = require("../../utils/deviceManager");
|
|
9
10
|
var _useSessionSocket = require("../hooks/useSessionSocket");
|
|
10
11
|
var _sonner = require("../../lib/sonner");
|
|
@@ -61,17 +62,32 @@ const getStorage = async () => {
|
|
|
61
62
|
|
|
62
63
|
// Storage keys for secure sessions
|
|
63
64
|
const getSecureStorageKeys = (prefix = 'oxy_secure') => ({
|
|
64
|
-
|
|
65
|
-
// Array of SecureClientSession objects
|
|
66
|
-
activeSessionId: `${prefix}_active_session_id` // ID of currently active session
|
|
65
|
+
activeSessionId: `${prefix}_active_session_id` // Only store the active session ID
|
|
67
66
|
});
|
|
68
|
-
const
|
|
67
|
+
const OxyProvider = ({
|
|
69
68
|
children,
|
|
70
|
-
oxyServices,
|
|
69
|
+
oxyServices: providedOxyServices,
|
|
70
|
+
baseURL,
|
|
71
71
|
storageKeyPrefix = 'oxy_secure',
|
|
72
72
|
onAuthStateChange,
|
|
73
|
+
onError,
|
|
73
74
|
bottomSheetRef
|
|
74
75
|
}) => {
|
|
76
|
+
// Create oxyServices automatically if not provided
|
|
77
|
+
const oxyServicesRef = (0, _react.useRef)(null);
|
|
78
|
+
if (!oxyServicesRef.current) {
|
|
79
|
+
if (providedOxyServices) {
|
|
80
|
+
oxyServicesRef.current = providedOxyServices;
|
|
81
|
+
} else if (baseURL) {
|
|
82
|
+
oxyServicesRef.current = new _core.OxyServices({
|
|
83
|
+
baseURL
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
throw new Error('Either oxyServices or baseURL must be provided to OxyContextProvider');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const oxyServices = oxyServicesRef.current;
|
|
90
|
+
|
|
75
91
|
// Zustand state
|
|
76
92
|
const user = (0, _authStore.useAuthStore)(state => state.user);
|
|
77
93
|
const isAuthenticated = (0, _authStore.useAuthStore)(state => state.isAuthenticated);
|
|
@@ -108,7 +124,7 @@ const OxyContextProvider = ({
|
|
|
108
124
|
initStorage();
|
|
109
125
|
}, []);
|
|
110
126
|
|
|
111
|
-
// Effect to initialize authentication state
|
|
127
|
+
// Effect to initialize authentication state - only store session ID
|
|
112
128
|
(0, _react.useEffect)(() => {
|
|
113
129
|
const initAuth = async () => {
|
|
114
130
|
if (!storage) return;
|
|
@@ -116,79 +132,49 @@ const OxyContextProvider = ({
|
|
|
116
132
|
isLoading: true
|
|
117
133
|
});
|
|
118
134
|
try {
|
|
119
|
-
//
|
|
120
|
-
const sessionsData = await storage.getItem(keys.sessions);
|
|
135
|
+
// Only load the active session ID from storage
|
|
121
136
|
const storedActiveSessionId = await storage.getItem(keys.activeSessionId);
|
|
122
|
-
console.log('SecureAuth - sessionsData:', sessionsData);
|
|
123
137
|
console.log('SecureAuth - activeSessionId:', storedActiveSessionId);
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
if (storedActiveSessionId) {
|
|
139
|
+
// Validate the stored session with the backend
|
|
140
|
+
try {
|
|
141
|
+
const validation = await oxyServices.validateSession(storedActiveSessionId);
|
|
142
|
+
if (validation.valid) {
|
|
143
|
+
console.log('SecureAuth - session validated successfully');
|
|
144
|
+
setActiveSessionId(storedActiveSessionId);
|
|
145
|
+
|
|
146
|
+
// Get access token for API calls
|
|
147
|
+
await oxyServices.getTokenBySession(storedActiveSessionId);
|
|
148
|
+
|
|
149
|
+
// Load full user data from backend
|
|
150
|
+
const fullUser = await oxyServices.getUserBySession(storedActiveSessionId);
|
|
151
|
+
loginSuccess(fullUser);
|
|
152
|
+
setMinimalUser({
|
|
153
|
+
id: fullUser.id,
|
|
154
|
+
username: fullUser.username,
|
|
155
|
+
avatar: fullUser.avatar
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Load sessions from backend
|
|
159
|
+
const serverSessions = await oxyServices.getSessionsBySessionId(storedActiveSessionId);
|
|
160
|
+
const clientSessions = serverSessions.map(serverSession => ({
|
|
161
|
+
sessionId: serverSession.sessionId,
|
|
162
|
+
deviceId: serverSession.deviceId,
|
|
163
|
+
expiresAt: serverSession.expiresAt || new Date().toISOString(),
|
|
164
|
+
lastActive: serverSession.lastActive || new Date().toISOString(),
|
|
165
|
+
userId: serverSession.userId || fullUser.id
|
|
166
|
+
}));
|
|
167
|
+
setSessions(clientSessions);
|
|
168
|
+
if (onAuthStateChange) {
|
|
169
|
+
onAuthStateChange(fullUser);
|
|
145
170
|
}
|
|
146
171
|
} else {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Update storage if we made changes
|
|
153
|
-
if (shouldUpdateStorage) {
|
|
154
|
-
await saveSessionsToStorage(migratedSessions);
|
|
155
|
-
}
|
|
156
|
-
setSessions(migratedSessions);
|
|
157
|
-
if (storedActiveSessionId && migratedSessions.length > 0) {
|
|
158
|
-
const activeSession = migratedSessions.find(s => s.sessionId === storedActiveSessionId);
|
|
159
|
-
if (activeSession) {
|
|
160
|
-
console.log('SecureAuth - activeSession found:', activeSession);
|
|
161
|
-
|
|
162
|
-
// Validate session
|
|
163
|
-
try {
|
|
164
|
-
const validation = await oxyServices.validateSession(activeSession.sessionId);
|
|
165
|
-
if (validation.valid) {
|
|
166
|
-
console.log('SecureAuth - session validated successfully');
|
|
167
|
-
setActiveSessionId(activeSession.sessionId);
|
|
168
|
-
|
|
169
|
-
// Get access token for API calls
|
|
170
|
-
await oxyServices.getTokenBySession(activeSession.sessionId);
|
|
171
|
-
|
|
172
|
-
// Load full user data
|
|
173
|
-
const fullUser = await oxyServices.getUserBySession(activeSession.sessionId);
|
|
174
|
-
loginSuccess(fullUser);
|
|
175
|
-
setMinimalUser({
|
|
176
|
-
id: fullUser.id,
|
|
177
|
-
username: fullUser.username,
|
|
178
|
-
avatar: fullUser.avatar
|
|
179
|
-
});
|
|
180
|
-
if (onAuthStateChange) {
|
|
181
|
-
onAuthStateChange(fullUser);
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
console.log('SecureAuth - session invalid, removing');
|
|
185
|
-
await removeInvalidSession(activeSession.sessionId);
|
|
186
|
-
}
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.error('SecureAuth - session validation error:', error);
|
|
189
|
-
await removeInvalidSession(activeSession.sessionId);
|
|
190
|
-
}
|
|
172
|
+
console.log('SecureAuth - session invalid, clearing storage');
|
|
173
|
+
await clearAllStorage();
|
|
191
174
|
}
|
|
175
|
+
} catch (error) {
|
|
176
|
+
console.error('SecureAuth - session validation error:', error);
|
|
177
|
+
await clearAllStorage();
|
|
192
178
|
}
|
|
193
179
|
}
|
|
194
180
|
} catch (err) {
|
|
@@ -203,33 +189,13 @@ const OxyContextProvider = ({
|
|
|
203
189
|
if (storage) {
|
|
204
190
|
initAuth();
|
|
205
191
|
}
|
|
206
|
-
}, [storage, oxyServices, keys, onAuthStateChange]);
|
|
207
|
-
|
|
208
|
-
// Effect to restore token on app load or session switch
|
|
209
|
-
(0, _react.useEffect)(() => {
|
|
210
|
-
const restoreToken = async () => {
|
|
211
|
-
if (activeSessionId && oxyServices) {
|
|
212
|
-
try {
|
|
213
|
-
await oxyServices.getTokenBySession(activeSessionId);
|
|
214
|
-
setTokenReady(true);
|
|
215
|
-
} catch (err) {
|
|
216
|
-
// If token restoration fails, force logout
|
|
217
|
-
await logout();
|
|
218
|
-
setTokenReady(false);
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
setTokenReady(true); // No session, so token is not needed
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
restoreToken();
|
|
225
|
-
// Only run when activeSessionId or oxyServices changes
|
|
226
|
-
}, [activeSessionId, oxyServices]);
|
|
192
|
+
}, [storage, oxyServices, keys, onAuthStateChange, loginSuccess, setMinimalUser]);
|
|
227
193
|
|
|
228
|
-
// Remove invalid session
|
|
194
|
+
// Remove invalid session - refresh sessions from backend
|
|
229
195
|
const removeInvalidSession = (0, _react.useCallback)(async sessionId => {
|
|
196
|
+
// Remove from local state
|
|
230
197
|
const filteredSessions = sessions.filter(s => s.sessionId !== sessionId);
|
|
231
198
|
setSessions(filteredSessions);
|
|
232
|
-
await saveSessionsToStorage(filteredSessions);
|
|
233
199
|
|
|
234
200
|
// If there are other sessions, switch to the first one
|
|
235
201
|
if (filteredSessions.length > 0) {
|
|
@@ -246,13 +212,7 @@ const OxyContextProvider = ({
|
|
|
246
212
|
}
|
|
247
213
|
}, [sessions, storage, keys, onAuthStateChange, logoutStore]);
|
|
248
214
|
|
|
249
|
-
// Save
|
|
250
|
-
const saveSessionsToStorage = (0, _react.useCallback)(async sessionsList => {
|
|
251
|
-
if (!storage) return;
|
|
252
|
-
await storage.setItem(keys.sessions, JSON.stringify(sessionsList));
|
|
253
|
-
}, [storage, keys.sessions]);
|
|
254
|
-
|
|
255
|
-
// Save active session ID to storage
|
|
215
|
+
// Save active session ID to storage (only session ID, no user data)
|
|
256
216
|
const saveActiveSessionId = (0, _react.useCallback)(async sessionId => {
|
|
257
217
|
if (!storage) return;
|
|
258
218
|
await storage.setItem(keys.activeSessionId, sessionId);
|
|
@@ -262,7 +222,6 @@ const OxyContextProvider = ({
|
|
|
262
222
|
const clearAllStorage = (0, _react.useCallback)(async () => {
|
|
263
223
|
if (!storage) return;
|
|
264
224
|
try {
|
|
265
|
-
await storage.removeItem(keys.sessions);
|
|
266
225
|
await storage.removeItem(keys.activeSessionId);
|
|
267
226
|
} catch (err) {
|
|
268
227
|
console.error('Clear secure storage error:', err);
|
|
@@ -304,8 +263,8 @@ const OxyContextProvider = ({
|
|
|
304
263
|
}
|
|
305
264
|
}, [oxyServices, onAuthStateChange, loginSuccess, saveActiveSessionId]);
|
|
306
265
|
|
|
307
|
-
// Secure login method
|
|
308
|
-
const login = async (username, password, deviceName) => {
|
|
266
|
+
// Secure login method - only store session ID, retrieve data from backend
|
|
267
|
+
const login = (0, _react.useCallback)(async (username, password, deviceName) => {
|
|
309
268
|
if (!storage) throw new Error('Storage not initialized');
|
|
310
269
|
_authStore.useAuthStore.setState({
|
|
311
270
|
isLoading: true,
|
|
@@ -321,49 +280,28 @@ const OxyContextProvider = ({
|
|
|
321
280
|
console.log('SecureAuth - Using device ID:', deviceInfo.deviceId);
|
|
322
281
|
const response = await oxyServices.secureLogin(username, password, deviceName || deviceInfo.deviceName || _deviceManager.DeviceManager.getDefaultDeviceName(), deviceFingerprint);
|
|
323
282
|
|
|
324
|
-
//
|
|
325
|
-
const clientSession = {
|
|
326
|
-
sessionId: response.sessionId,
|
|
327
|
-
deviceId: response.deviceId,
|
|
328
|
-
expiresAt: response.expiresAt,
|
|
329
|
-
lastActive: new Date().toISOString(),
|
|
330
|
-
userId: response.user.id
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
// Check if this user already has a session (prevent duplicate accounts)
|
|
334
|
-
const existingUserSessionIndex = sessions.findIndex(s => s.userId === response.user.id);
|
|
335
|
-
let updatedSessions;
|
|
336
|
-
if (existingUserSessionIndex !== -1) {
|
|
337
|
-
// User already has a session - replace it with the new one (reused session scenario)
|
|
338
|
-
const existingSession = sessions[existingUserSessionIndex];
|
|
339
|
-
updatedSessions = [...sessions];
|
|
340
|
-
updatedSessions[existingUserSessionIndex] = clientSession;
|
|
341
|
-
console.log(`Reusing/updating existing session for user ${response.user.id}. Previous session: ${existingSession.sessionId}, New session: ${response.sessionId}`);
|
|
342
|
-
|
|
343
|
-
// If the replaced session was the active one, update active session
|
|
344
|
-
if (activeSessionId === existingSession.sessionId) {
|
|
345
|
-
setActiveSessionId(response.sessionId);
|
|
346
|
-
await saveActiveSessionId(response.sessionId);
|
|
347
|
-
}
|
|
348
|
-
} else {
|
|
349
|
-
// Add new session for new user
|
|
350
|
-
updatedSessions = [...sessions, clientSession];
|
|
351
|
-
console.log(`Added new session for user ${response.user.id} on device ${response.deviceId}`);
|
|
352
|
-
}
|
|
353
|
-
setSessions(updatedSessions);
|
|
354
|
-
await saveSessionsToStorage(updatedSessions);
|
|
355
|
-
|
|
356
|
-
// Set as active session
|
|
283
|
+
// Set as active session (only store session ID)
|
|
357
284
|
setActiveSessionId(response.sessionId);
|
|
358
285
|
await saveActiveSessionId(response.sessionId);
|
|
359
286
|
|
|
360
287
|
// Get access token for API calls
|
|
361
288
|
await oxyServices.getTokenBySession(response.sessionId);
|
|
362
289
|
|
|
363
|
-
// Load full user data
|
|
290
|
+
// Load full user data from backend
|
|
364
291
|
const fullUser = await oxyServices.getUserBySession(response.sessionId);
|
|
365
292
|
loginSuccess(fullUser);
|
|
366
293
|
setMinimalUser(response.user);
|
|
294
|
+
|
|
295
|
+
// Load sessions from backend
|
|
296
|
+
const serverSessions = await oxyServices.getSessionsBySessionId(response.sessionId);
|
|
297
|
+
const clientSessions = serverSessions.map(serverSession => ({
|
|
298
|
+
sessionId: serverSession.sessionId,
|
|
299
|
+
deviceId: serverSession.deviceId,
|
|
300
|
+
expiresAt: serverSession.expiresAt || new Date().toISOString(),
|
|
301
|
+
lastActive: serverSession.lastActive || new Date().toISOString(),
|
|
302
|
+
userId: serverSession.userId || fullUser.id
|
|
303
|
+
}));
|
|
304
|
+
setSessions(clientSessions);
|
|
367
305
|
if (onAuthStateChange) {
|
|
368
306
|
onAuthStateChange(fullUser);
|
|
369
307
|
}
|
|
@@ -376,19 +314,18 @@ const OxyContextProvider = ({
|
|
|
376
314
|
isLoading: false
|
|
377
315
|
});
|
|
378
316
|
}
|
|
379
|
-
};
|
|
317
|
+
}, [storage, oxyServices, saveActiveSessionId, loginSuccess, setMinimalUser, onAuthStateChange, loginFailure]);
|
|
380
318
|
|
|
381
319
|
// Logout method
|
|
382
|
-
const logout = async targetSessionId => {
|
|
320
|
+
const logout = (0, _react.useCallback)(async targetSessionId => {
|
|
383
321
|
if (!activeSessionId) return;
|
|
384
322
|
try {
|
|
385
323
|
const sessionToLogout = targetSessionId || activeSessionId;
|
|
386
324
|
await oxyServices.logoutSecureSession(activeSessionId, sessionToLogout);
|
|
387
325
|
|
|
388
|
-
// Remove session from local
|
|
326
|
+
// Remove session from local state
|
|
389
327
|
const filteredSessions = sessions.filter(s => s.sessionId !== sessionToLogout);
|
|
390
328
|
setSessions(filteredSessions);
|
|
391
|
-
await saveSessionsToStorage(filteredSessions);
|
|
392
329
|
|
|
393
330
|
// If logging out active session
|
|
394
331
|
if (sessionToLogout === activeSessionId) {
|
|
@@ -412,10 +349,10 @@ const OxyContextProvider = ({
|
|
|
412
349
|
error: 'Logout failed'
|
|
413
350
|
});
|
|
414
351
|
}
|
|
415
|
-
};
|
|
352
|
+
}, [activeSessionId, oxyServices, sessions, switchToSession, logoutStore, setMinimalUser, storage, keys.activeSessionId, onAuthStateChange]);
|
|
416
353
|
|
|
417
354
|
// Logout all sessions
|
|
418
|
-
const logoutAll = async () => {
|
|
355
|
+
const logoutAll = (0, _react.useCallback)(async () => {
|
|
419
356
|
console.log('logoutAll called with activeSessionId:', activeSessionId);
|
|
420
357
|
if (!activeSessionId) {
|
|
421
358
|
console.error('No active session ID found, cannot logout all');
|
|
@@ -454,10 +391,30 @@ const OxyContextProvider = ({
|
|
|
454
391
|
});
|
|
455
392
|
throw error;
|
|
456
393
|
}
|
|
457
|
-
};
|
|
394
|
+
}, [activeSessionId, oxyServices, logoutStore, setMinimalUser, clearAllStorage, onAuthStateChange]);
|
|
395
|
+
|
|
396
|
+
// Effect to restore token on app load or session switch
|
|
397
|
+
(0, _react.useEffect)(() => {
|
|
398
|
+
const restoreToken = async () => {
|
|
399
|
+
if (activeSessionId && oxyServices) {
|
|
400
|
+
try {
|
|
401
|
+
await oxyServices.getTokenBySession(activeSessionId);
|
|
402
|
+
setTokenReady(true);
|
|
403
|
+
} catch (err) {
|
|
404
|
+
// If token restoration fails, force logout
|
|
405
|
+
await logout();
|
|
406
|
+
setTokenReady(false);
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
setTokenReady(true); // No session, so token is not needed
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
restoreToken();
|
|
413
|
+
// Only run when activeSessionId or oxyServices changes
|
|
414
|
+
}, [activeSessionId, oxyServices, logout]);
|
|
458
415
|
|
|
459
416
|
// Sign up method
|
|
460
|
-
const signUp = async (username, email, password) => {
|
|
417
|
+
const signUp = (0, _react.useCallback)(async (username, email, password) => {
|
|
461
418
|
if (!storage) throw new Error('Storage not initialized');
|
|
462
419
|
_authStore.useAuthStore.setState({
|
|
463
420
|
isLoading: true,
|
|
@@ -480,41 +437,77 @@ const OxyContextProvider = ({
|
|
|
480
437
|
isLoading: false
|
|
481
438
|
});
|
|
482
439
|
}
|
|
483
|
-
};
|
|
440
|
+
}, [storage, oxyServices, login, loginFailure]);
|
|
484
441
|
|
|
485
442
|
// Switch session method
|
|
486
|
-
const switchSession = async sessionId => {
|
|
443
|
+
const switchSession = (0, _react.useCallback)(async sessionId => {
|
|
487
444
|
await switchToSession(sessionId);
|
|
488
|
-
};
|
|
445
|
+
}, [switchToSession]);
|
|
489
446
|
|
|
490
447
|
// Remove session method
|
|
491
|
-
const removeSession = async sessionId => {
|
|
448
|
+
const removeSession = (0, _react.useCallback)(async sessionId => {
|
|
492
449
|
await logout(sessionId);
|
|
493
|
-
};
|
|
450
|
+
}, [logout]);
|
|
494
451
|
|
|
495
452
|
// Refresh sessions method
|
|
496
|
-
const refreshSessions = async () => {
|
|
497
|
-
|
|
453
|
+
const refreshSessions = (0, _react.useCallback)(async () => {
|
|
454
|
+
console.log('refreshSessions called with activeSessionId:', activeSessionId);
|
|
455
|
+
if (!activeSessionId) {
|
|
456
|
+
console.log('refreshSessions: No activeSessionId, returning');
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
498
459
|
try {
|
|
460
|
+
console.log('refreshSessions: Calling getSessionsBySessionId...');
|
|
499
461
|
const serverSessions = await oxyServices.getSessionsBySessionId(activeSessionId);
|
|
462
|
+
console.log('refreshSessions: Server sessions received:', serverSessions);
|
|
500
463
|
|
|
501
464
|
// Update local sessions with server data
|
|
502
465
|
const updatedSessions = serverSessions.map(serverSession => ({
|
|
503
466
|
sessionId: serverSession.sessionId,
|
|
504
467
|
deviceId: serverSession.deviceId,
|
|
505
|
-
expiresAt: new Date().toISOString(),
|
|
506
|
-
|
|
507
|
-
|
|
468
|
+
expiresAt: serverSession.expiresAt || new Date().toISOString(),
|
|
469
|
+
lastActive: serverSession.lastActive || new Date().toISOString(),
|
|
470
|
+
userId: serverSession.userId || user?.id
|
|
508
471
|
}));
|
|
472
|
+
console.log('refreshSessions: Updated sessions:', updatedSessions);
|
|
509
473
|
setSessions(updatedSessions);
|
|
510
|
-
|
|
474
|
+
console.log('refreshSessions: Sessions updated in state');
|
|
511
475
|
} catch (error) {
|
|
512
476
|
console.error('Refresh sessions error:', error);
|
|
477
|
+
|
|
478
|
+
// If the current session is invalid, try to find another valid session
|
|
479
|
+
if (sessions.length > 1) {
|
|
480
|
+
console.log('Current session invalid, trying to switch to another session...');
|
|
481
|
+
const otherSessions = sessions.filter(s => s.sessionId !== activeSessionId);
|
|
482
|
+
for (const session of otherSessions) {
|
|
483
|
+
try {
|
|
484
|
+
// Try to validate this session
|
|
485
|
+
await oxyServices.validateSession(session.sessionId);
|
|
486
|
+
console.log('Found valid session, switching to:', session.sessionId);
|
|
487
|
+
await switchToSession(session.sessionId);
|
|
488
|
+
return; // Successfully switched to another session
|
|
489
|
+
} catch (sessionError) {
|
|
490
|
+
console.log('Session validation failed for:', session.sessionId, sessionError);
|
|
491
|
+
continue; // Try next session
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// If no valid sessions found, clear all sessions
|
|
497
|
+
console.log('No valid sessions found, clearing all sessions');
|
|
498
|
+
setSessions([]);
|
|
499
|
+
setActiveSessionId(null);
|
|
500
|
+
logoutStore();
|
|
501
|
+
setMinimalUser(null);
|
|
502
|
+
await clearAllStorage();
|
|
503
|
+
if (onAuthStateChange) {
|
|
504
|
+
onAuthStateChange(null);
|
|
505
|
+
}
|
|
513
506
|
}
|
|
514
|
-
};
|
|
507
|
+
}, [activeSessionId, oxyServices, user?.id, sessions, switchToSession, logoutStore, setMinimalUser, clearAllStorage, onAuthStateChange]);
|
|
515
508
|
|
|
516
509
|
// Device management methods
|
|
517
|
-
const getDeviceSessions = async () => {
|
|
510
|
+
const getDeviceSessions = (0, _react.useCallback)(async () => {
|
|
518
511
|
if (!activeSessionId) throw new Error('No active session');
|
|
519
512
|
try {
|
|
520
513
|
return await oxyServices.getDeviceSessions(activeSessionId);
|
|
@@ -522,8 +515,8 @@ const OxyContextProvider = ({
|
|
|
522
515
|
console.error('Get device sessions error:', error);
|
|
523
516
|
throw error;
|
|
524
517
|
}
|
|
525
|
-
};
|
|
526
|
-
const logoutAllDeviceSessions = async () => {
|
|
518
|
+
}, [activeSessionId, oxyServices]);
|
|
519
|
+
const logoutAllDeviceSessions = (0, _react.useCallback)(async () => {
|
|
527
520
|
if (!activeSessionId) throw new Error('No active session');
|
|
528
521
|
try {
|
|
529
522
|
await oxyServices.logoutAllDeviceSessions(activeSessionId);
|
|
@@ -541,8 +534,8 @@ const OxyContextProvider = ({
|
|
|
541
534
|
console.error('Logout all device sessions error:', error);
|
|
542
535
|
throw error;
|
|
543
536
|
}
|
|
544
|
-
};
|
|
545
|
-
const updateDeviceName = async deviceName => {
|
|
537
|
+
}, [activeSessionId, oxyServices, logoutStore, setMinimalUser, clearAllStorage, onAuthStateChange]);
|
|
538
|
+
const updateDeviceName = (0, _react.useCallback)(async deviceName => {
|
|
546
539
|
if (!activeSessionId) throw new Error('No active session');
|
|
547
540
|
try {
|
|
548
541
|
await oxyServices.updateDeviceName(activeSessionId, deviceName);
|
|
@@ -553,7 +546,7 @@ const OxyContextProvider = ({
|
|
|
553
546
|
console.error('Update device name error:', error);
|
|
554
547
|
throw error;
|
|
555
548
|
}
|
|
556
|
-
};
|
|
549
|
+
}, [activeSessionId, oxyServices]);
|
|
557
550
|
|
|
558
551
|
// Bottom sheet control methods
|
|
559
552
|
const showBottomSheet = (0, _react.useCallback)(screenOrConfig => {
|
|
@@ -570,6 +563,7 @@ const OxyContextProvider = ({
|
|
|
570
563
|
bottomSheetRef.current.present();
|
|
571
564
|
} else {
|
|
572
565
|
console.warn('No expand or present method available on bottomSheetRef');
|
|
566
|
+
console.log('Available methods on bottomSheetRef.current:', Object.keys(bottomSheetRef.current));
|
|
573
567
|
}
|
|
574
568
|
|
|
575
569
|
// Then navigate to the specified screen if provided
|
|
@@ -589,6 +583,8 @@ const OxyContextProvider = ({
|
|
|
589
583
|
}
|
|
590
584
|
} else {
|
|
591
585
|
console.warn('bottomSheetRef is not available');
|
|
586
|
+
console.warn('To fix this, ensure you pass a bottomSheetRef to OxyProvider:');
|
|
587
|
+
console.warn('<OxyProvider baseURL="..." bottomSheetRef={yourBottomSheetRef}>');
|
|
592
588
|
}
|
|
593
589
|
}, [bottomSheetRef]);
|
|
594
590
|
const hideBottomSheet = (0, _react.useCallback)(() => {
|
|
@@ -603,16 +599,16 @@ const OxyContextProvider = ({
|
|
|
603
599
|
userId: user?.id,
|
|
604
600
|
activeSessionId,
|
|
605
601
|
refreshSessions,
|
|
606
|
-
logout
|
|
602
|
+
logout,
|
|
607
603
|
baseURL: oxyServices.getBaseURL(),
|
|
608
|
-
onRemoteSignOut: () => {
|
|
604
|
+
onRemoteSignOut: (0, _react.useCallback)(() => {
|
|
609
605
|
_sonner.toast.info('You have been signed out remotely.');
|
|
610
606
|
logout();
|
|
611
|
-
}
|
|
607
|
+
}, [logout])
|
|
612
608
|
});
|
|
613
609
|
|
|
614
610
|
// Context value
|
|
615
|
-
const contextValue = {
|
|
611
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
616
612
|
user,
|
|
617
613
|
minimalUser,
|
|
618
614
|
sessions,
|
|
@@ -622,36 +618,19 @@ const OxyContextProvider = ({
|
|
|
622
618
|
error,
|
|
623
619
|
login,
|
|
624
620
|
logout,
|
|
625
|
-
logoutAll
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
await switchToSession(sessionId);
|
|
634
|
-
},
|
|
635
|
-
removeSession: async sessionId => {
|
|
636
|
-
await removeSession(sessionId);
|
|
637
|
-
},
|
|
638
|
-
refreshSessions: async () => {
|
|
639
|
-
await refreshSessions();
|
|
640
|
-
},
|
|
641
|
-
getDeviceSessions: async () => {
|
|
642
|
-
return await getDeviceSessions();
|
|
643
|
-
},
|
|
644
|
-
logoutAllDeviceSessions: async () => {
|
|
645
|
-
await logoutAllDeviceSessions();
|
|
646
|
-
},
|
|
647
|
-
updateDeviceName: async deviceName => {
|
|
648
|
-
await updateDeviceName(deviceName);
|
|
649
|
-
},
|
|
621
|
+
logoutAll,
|
|
622
|
+
signUp,
|
|
623
|
+
switchSession,
|
|
624
|
+
removeSession,
|
|
625
|
+
refreshSessions,
|
|
626
|
+
getDeviceSessions,
|
|
627
|
+
logoutAllDeviceSessions,
|
|
628
|
+
updateDeviceName,
|
|
650
629
|
oxyServices,
|
|
651
630
|
bottomSheetRef,
|
|
652
631
|
showBottomSheet,
|
|
653
632
|
hideBottomSheet
|
|
654
|
-
};
|
|
633
|
+
}), [user, minimalUser, sessions, activeSessionId, isAuthenticated, isLoading, error, login, logout, logoutAll, signUp, switchSession, removeSession, refreshSessions, getDeviceSessions, logoutAllDeviceSessions, updateDeviceName, oxyServices, bottomSheetRef, showBottomSheet, hideBottomSheet]);
|
|
655
634
|
|
|
656
635
|
// Wrap children rendering to block until token is ready
|
|
657
636
|
if (!tokenReady) {
|
|
@@ -665,8 +644,11 @@ const OxyContextProvider = ({
|
|
|
665
644
|
});
|
|
666
645
|
};
|
|
667
646
|
|
|
647
|
+
// Alias for backward compatibility
|
|
648
|
+
exports.OxyProvider = OxyProvider;
|
|
649
|
+
const OxyContextProvider = exports.OxyContextProvider = OxyProvider;
|
|
650
|
+
|
|
668
651
|
// Hook to use the context
|
|
669
|
-
exports.OxyContextProvider = OxyContextProvider;
|
|
670
652
|
const useOxy = () => {
|
|
671
653
|
const context = (0, _react.useContext)(OxyContext);
|
|
672
654
|
if (!context) {
|