@oxyhq/services 5.2.2 → 5.2.4
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/core/index.js +117 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/models/secureSession.js +2 -0
- package/lib/commonjs/models/secureSession.js.map +1 -0
- package/lib/commonjs/ui/context/LegacyOxyContext.js +643 -0
- package/lib/commonjs/ui/context/LegacyOxyContext.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +215 -450
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/SecureOxyContext.js +408 -0
- package/lib/commonjs/ui/context/SecureOxyContext.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +3 -3
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +31 -30
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +4 -4
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js +34 -34
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +2 -2
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/core/index.js +117 -0
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/models/secureSession.js +2 -0
- package/lib/module/models/secureSession.js.map +1 -0
- package/lib/module/ui/context/LegacyOxyContext.js +639 -0
- package/lib/module/ui/context/LegacyOxyContext.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +214 -450
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/SecureOxyContext.js +403 -0
- package/lib/module/ui/context/SecureOxyContext.js.map +1 -0
- package/lib/module/ui/screens/AccountCenterScreen.js +3 -3
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +31 -30
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +4 -4
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js +34 -34
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +2 -2
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/typescript/core/index.d.ts +51 -0
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/models/secureSession.d.ts +25 -0
- package/lib/typescript/models/secureSession.d.ts.map +1 -0
- package/lib/typescript/ui/context/LegacyOxyContext.d.ts +40 -0
- package/lib/typescript/ui/context/LegacyOxyContext.d.ts.map +1 -0
- package/lib/typescript/ui/context/OxyContext.d.ts +11 -12
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/SecureOxyContext.d.ts +39 -0
- package/lib/typescript/ui/context/SecureOxyContext.d.ts.map +1 -0
- package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/index.ts +117 -0
- package/src/index.ts +2 -2
- package/src/models/secureSession.ts +27 -0
- package/src/ui/context/LegacyOxyContext.tsx +735 -0
- package/src/ui/context/OxyContext.tsx +412 -674
- package/src/ui/context/SecureOxyContext.tsx +473 -0
- package/src/ui/screens/AccountCenterScreen.tsx +4 -4
- package/src/ui/screens/AccountSwitcherScreen.tsx +36 -34
- package/src/ui/screens/AppInfoScreen.tsx +3 -3
- package/src/ui/screens/SessionManagementScreen.tsx +31 -35
- package/src/ui/screens/SignInScreen.tsx +2 -2
|
@@ -31,7 +31,7 @@ const AppInfoScreen: React.FC<BaseScreenProps> = ({
|
|
|
31
31
|
theme,
|
|
32
32
|
navigate,
|
|
33
33
|
}) => {
|
|
34
|
-
const { user,
|
|
34
|
+
const { user, sessions } = useOxy();
|
|
35
35
|
const [systemInfo, setSystemInfo] = useState<SystemInfo | null>(null);
|
|
36
36
|
|
|
37
37
|
const isDarkTheme = theme === 'dark';
|
|
@@ -76,7 +76,7 @@ const AppInfoScreen: React.FC<BaseScreenProps> = ({
|
|
|
76
76
|
isAuthenticated: !!user,
|
|
77
77
|
userId: user?.id || 'Not authenticated',
|
|
78
78
|
username: user?.username || 'N/A',
|
|
79
|
-
totalUsers:
|
|
79
|
+
totalUsers: sessions?.length || 0,
|
|
80
80
|
},
|
|
81
81
|
apiConfiguration: {
|
|
82
82
|
apiUrl: 'http://localhost:3001',
|
|
@@ -164,7 +164,7 @@ const AppInfoScreen: React.FC<BaseScreenProps> = ({
|
|
|
164
164
|
<InfoRow label="Premium Status" value={user.isPremium ? 'Premium' : 'Standard'} />
|
|
165
165
|
</>
|
|
166
166
|
)}
|
|
167
|
-
<InfoRow label="Total
|
|
167
|
+
<InfoRow label="Total Active Sessions" value={sessions?.length?.toString() || '0'} />
|
|
168
168
|
</InfoSection>
|
|
169
169
|
|
|
170
170
|
<InfoSection title="API Configuration">
|
|
@@ -31,8 +31,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
31
31
|
onClose,
|
|
32
32
|
theme,
|
|
33
33
|
}) => {
|
|
34
|
-
const {
|
|
35
|
-
const [sessions, setSessions] = useState<Session[]>([]);
|
|
34
|
+
const { sessions: userSessions, activeSessionId, refreshSessions, logout, oxyServices } = useOxy();
|
|
36
35
|
const [loading, setLoading] = useState(true);
|
|
37
36
|
const [refreshing, setRefreshing] = useState(false);
|
|
38
37
|
const [actionLoading, setActionLoading] = useState<string | null>(null);
|
|
@@ -54,8 +53,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
54
53
|
setLoading(true);
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
setSessions(userSessions);
|
|
56
|
+
await refreshSessions();
|
|
59
57
|
} catch (error) {
|
|
60
58
|
console.error('Failed to load sessions:', error);
|
|
61
59
|
Alert.alert(
|
|
@@ -81,10 +79,10 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
81
79
|
onPress: async () => {
|
|
82
80
|
try {
|
|
83
81
|
setActionLoading(sessionId);
|
|
84
|
-
await
|
|
82
|
+
await logout(sessionId);
|
|
85
83
|
|
|
86
|
-
//
|
|
87
|
-
|
|
84
|
+
// Refresh sessions to update the list
|
|
85
|
+
await refreshSessions();
|
|
88
86
|
|
|
89
87
|
Alert.alert('Success', 'Session logged out successfully');
|
|
90
88
|
} catch (error) {
|
|
@@ -103,7 +101,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
103
101
|
};
|
|
104
102
|
|
|
105
103
|
const handleLogoutOtherSessions = async () => {
|
|
106
|
-
const otherSessionsCount =
|
|
104
|
+
const otherSessionsCount = userSessions.filter(s => s.sessionId !== activeSessionId).length;
|
|
107
105
|
|
|
108
106
|
if (otherSessionsCount === 0) {
|
|
109
107
|
Alert.alert('Info', 'No other sessions to logout.');
|
|
@@ -121,10 +119,15 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
121
119
|
onPress: async () => {
|
|
122
120
|
try {
|
|
123
121
|
setActionLoading('others');
|
|
124
|
-
|
|
122
|
+
// Logout each non-active session
|
|
123
|
+
for (const session of userSessions) {
|
|
124
|
+
if (session.sessionId !== activeSessionId) {
|
|
125
|
+
await logout(session.sessionId);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
125
128
|
|
|
126
|
-
//
|
|
127
|
-
|
|
129
|
+
// Refresh sessions to update the list
|
|
130
|
+
await refreshSessions();
|
|
128
131
|
|
|
129
132
|
Alert.alert('Success', 'Other sessions logged out successfully');
|
|
130
133
|
} catch (error) {
|
|
@@ -232,30 +235,30 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
232
235
|
/>
|
|
233
236
|
}
|
|
234
237
|
>
|
|
235
|
-
{
|
|
238
|
+
{userSessions.length > 0 ? (
|
|
236
239
|
<>
|
|
237
|
-
{
|
|
240
|
+
{userSessions.map((session) => (
|
|
238
241
|
<View
|
|
239
|
-
key={session.
|
|
242
|
+
key={session.sessionId}
|
|
240
243
|
style={[
|
|
241
244
|
styles.sessionCard,
|
|
242
245
|
{
|
|
243
246
|
backgroundColor: secondaryBackgroundColor,
|
|
244
247
|
borderColor,
|
|
245
|
-
borderLeftColor: session.
|
|
248
|
+
borderLeftColor: session.sessionId === activeSessionId ? successColor : borderColor,
|
|
246
249
|
},
|
|
247
250
|
]}
|
|
248
251
|
>
|
|
249
252
|
<View style={styles.sessionHeader}>
|
|
250
253
|
<View style={styles.sessionTitleRow}>
|
|
251
254
|
<Text style={styles.deviceIcon}>
|
|
252
|
-
|
|
255
|
+
📱
|
|
253
256
|
</Text>
|
|
254
257
|
<View style={styles.sessionTitleText}>
|
|
255
258
|
<Text style={[styles.deviceName, { color: textColor }]}>
|
|
256
|
-
{session.
|
|
259
|
+
Session {session.sessionId.substring(0, 8)}...
|
|
257
260
|
</Text>
|
|
258
|
-
{session.
|
|
261
|
+
{session.sessionId === activeSessionId && (
|
|
259
262
|
<Text style={[styles.currentBadge, { color: successColor }]}>
|
|
260
263
|
Current Session
|
|
261
264
|
</Text>
|
|
@@ -266,30 +269,23 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
266
269
|
|
|
267
270
|
<View style={styles.sessionDetails}>
|
|
268
271
|
<Text style={[styles.sessionDetail, { color: isDarkTheme ? '#BBBBBB' : '#666666' }]}>
|
|
269
|
-
|
|
272
|
+
Device ID: {session.deviceId.substring(0, 12)}...
|
|
270
273
|
</Text>
|
|
271
|
-
{session.browser && (
|
|
272
|
-
<Text style={[styles.sessionDetail, { color: isDarkTheme ? '#BBBBBB' : '#666666' }]}>
|
|
273
|
-
{session.browser}
|
|
274
|
-
</Text>
|
|
275
|
-
)}
|
|
276
274
|
<Text style={[styles.sessionDetail, { color: isDarkTheme ? '#BBBBBB' : '#666666' }]}>
|
|
277
|
-
Last active: {
|
|
275
|
+
Last active: {new Date(session.lastActive).toLocaleDateString()}
|
|
276
|
+
</Text>
|
|
277
|
+
<Text style={[styles.sessionDetail, { color: isDarkTheme ? '#BBBBBB' : '#666666' }]}>
|
|
278
|
+
Expires: {new Date(session.expiresAt).toLocaleDateString()}
|
|
278
279
|
</Text>
|
|
279
|
-
{session.ipAddress && (
|
|
280
|
-
<Text style={[styles.sessionDetail, { color: isDarkTheme ? '#BBBBBB' : '#666666' }]}>
|
|
281
|
-
IP: {session.ipAddress}
|
|
282
|
-
</Text>
|
|
283
|
-
)}
|
|
284
280
|
</View>
|
|
285
281
|
|
|
286
|
-
{
|
|
282
|
+
{session.sessionId !== activeSessionId && (
|
|
287
283
|
<TouchableOpacity
|
|
288
284
|
style={[styles.logoutButton, { backgroundColor: isDarkTheme ? '#400000' : '#FFEBEE' }]}
|
|
289
|
-
onPress={() => handleLogoutSession(session.
|
|
290
|
-
disabled={actionLoading === session.
|
|
285
|
+
onPress={() => handleLogoutSession(session.sessionId)}
|
|
286
|
+
disabled={actionLoading === session.sessionId}
|
|
291
287
|
>
|
|
292
|
-
{actionLoading === session.
|
|
288
|
+
{actionLoading === session.sessionId ? (
|
|
293
289
|
<ActivityIndicator size="small" color={dangerColor} />
|
|
294
290
|
) : (
|
|
295
291
|
<Text style={[styles.logoutButtonText, { color: dangerColor }]}>
|
|
@@ -305,7 +301,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
305
301
|
<TouchableOpacity
|
|
306
302
|
style={[styles.bulkActionButton, { backgroundColor: isDarkTheme ? '#1A1A1A' : '#F0F0F0', borderColor }]}
|
|
307
303
|
onPress={handleLogoutOtherSessions}
|
|
308
|
-
disabled={actionLoading === 'others' ||
|
|
304
|
+
disabled={actionLoading === 'others' || userSessions.filter(s => s.sessionId !== activeSessionId).length === 0}
|
|
309
305
|
>
|
|
310
306
|
{actionLoading === 'others' ? (
|
|
311
307
|
<ActivityIndicator size="small" color={primaryColor} />
|
|
@@ -25,13 +25,13 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
25
25
|
const [password, setPassword] = useState('');
|
|
26
26
|
const [errorMessage, setErrorMessage] = useState('');
|
|
27
27
|
|
|
28
|
-
const { login, isLoading, user, isAuthenticated,
|
|
28
|
+
const { login, isLoading, user, isAuthenticated, sessions } = useOxy();
|
|
29
29
|
|
|
30
30
|
const colors = useThemeColors(theme);
|
|
31
31
|
const commonStyles = createCommonStyles(theme);
|
|
32
32
|
|
|
33
33
|
// Check if this should be treated as "Add Account" mode
|
|
34
|
-
const isAddAccountMode = user && isAuthenticated &&
|
|
34
|
+
const isAddAccountMode = user && isAuthenticated && sessions && sessions.length > 0;
|
|
35
35
|
|
|
36
36
|
const handleLogin = async () => {
|
|
37
37
|
if (!username || !password) {
|