@oxyhq/services 5.5.7 → 5.5.8
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 +13 -13
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +467 -87
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuthFetch.js +79 -45
- package/lib/commonjs/ui/hooks/useAuthFetch.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/core/index.js +13 -6
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +467 -87
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useAuthFetch.js +79 -45
- package/lib/module/ui/hooks/useAuthFetch.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/typescript/core/index.d.ts +7 -6
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +11 -7
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useAuthFetch.d.ts +10 -4
- package/lib/typescript/ui/hooks/useAuthFetch.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/backend-middleware.test.ts +209 -0
- package/src/__tests__/ui/hooks/useAuthFetch.test.ts +70 -0
- package/src/core/index.ts +13 -7
- package/src/ui/context/OxyContext.tsx +522 -99
- package/src/ui/hooks/useAuthFetch.ts +81 -47
- package/src/ui/screens/SessionManagementScreen.tsx +9 -9
- package/lib/commonjs/core/AuthManager.js +0 -378
- package/lib/commonjs/core/AuthManager.js.map +0 -1
- package/lib/module/core/AuthManager.js +0 -373
- package/lib/module/core/AuthManager.js.map +0 -1
- package/lib/typescript/core/AuthManager.d.ts +0 -100
- package/lib/typescript/core/AuthManager.d.ts.map +0 -1
- package/src/core/AuthManager.ts +0 -389
|
@@ -1,67 +1,94 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Zero Config Authenticated Fetch Hook
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Simple hook that provides fetch-like API with automatic authentication
|
|
5
|
+
* Leverages the existing useOxy hook and OxyProvider infrastructure
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const authFetch = useAuthFetch();
|
|
9
|
+
* const response = await authFetch('/api/protected');
|
|
10
|
+
* const data = await authFetch.get('/api/users');
|
|
6
11
|
*/
|
|
7
12
|
|
|
8
13
|
import { useCallback } from 'react';
|
|
9
14
|
import { useOxy } from '../context/OxyContext';
|
|
10
15
|
|
|
11
16
|
export interface AuthFetchOptions extends Omit<RequestInit, 'body'> {
|
|
12
|
-
body?: any;
|
|
17
|
+
body?: any; // Allow any type for body, we'll JSON.stringify if needed
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export interface AuthFetchAPI {
|
|
21
|
+
// Main fetch function (drop-in replacement)
|
|
16
22
|
(input: RequestInfo | URL, init?: AuthFetchOptions): Promise<Response>;
|
|
23
|
+
|
|
24
|
+
// Convenience methods for JSON APIs
|
|
17
25
|
get: (endpoint: string, options?: AuthFetchOptions) => Promise<any>;
|
|
18
26
|
post: (endpoint: string, data?: any, options?: AuthFetchOptions) => Promise<any>;
|
|
19
27
|
put: (endpoint: string, data?: any, options?: AuthFetchOptions) => Promise<any>;
|
|
20
28
|
delete: (endpoint: string, options?: AuthFetchOptions) => Promise<any>;
|
|
29
|
+
|
|
30
|
+
// Access to auth state and methods
|
|
21
31
|
isAuthenticated: boolean;
|
|
22
32
|
user: any;
|
|
23
33
|
login: (username: string, password: string) => Promise<any>;
|
|
24
34
|
logout: () => Promise<void>;
|
|
25
35
|
signUp: (username: string, email: string, password: string) => Promise<any>;
|
|
36
|
+
|
|
37
|
+
// API configuration
|
|
38
|
+
setApiUrl: (url: string) => void;
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
/**
|
|
29
42
|
* Hook that provides authenticated fetch functionality
|
|
30
|
-
* Uses the
|
|
43
|
+
* Uses the existing OxyServices instance from useOxy context
|
|
31
44
|
*/
|
|
32
45
|
export function useAuthFetch(): AuthFetchAPI {
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
console.log('[useAuthFetch] Hook initialized');
|
|
36
|
-
console.log('[useAuthFetch] authManager:', !!authManager);
|
|
37
|
-
console.log('[useAuthFetch] isAuthenticated:', isAuthenticated);
|
|
38
|
-
console.log('[useAuthFetch] user:', !!user);
|
|
46
|
+
const { oxyServices, isAuthenticated, user, login, logout, signUp, activeSessionId, setApiUrl } = useOxy();
|
|
39
47
|
|
|
48
|
+
// Validate that we have the required dependencies
|
|
49
|
+
if (!oxyServices) {
|
|
50
|
+
throw new Error('useAuthFetch requires OxyServices to be initialized. Make sure your app is wrapped with OxyProvider.');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Main fetch function with automatic auth headers
|
|
40
54
|
const authFetch = useCallback(async (input: RequestInfo | URL, init?: AuthFetchOptions): Promise<Response> => {
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
if (!oxyServices) {
|
|
56
|
+
throw new Error('OxyServices not initialized. Make sure to wrap your app in OxyProvider.');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const url = resolveURL(input, oxyServices.getBaseURL());
|
|
60
|
+
const options = await addAuthHeaders(init, oxyServices, activeSessionId || undefined, isAuthenticated);
|
|
43
61
|
|
|
44
62
|
try {
|
|
45
63
|
let response = await fetch(url, options);
|
|
46
64
|
|
|
47
65
|
// Handle token expiry and automatic refresh
|
|
48
66
|
if (response.status === 401 && isAuthenticated) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
// Try to refresh token if we have refresh capability
|
|
68
|
+
if (oxyServices.refreshTokens) {
|
|
69
|
+
try {
|
|
70
|
+
await oxyServices.refreshTokens();
|
|
71
|
+
const retryOptions = await addAuthHeaders(init, oxyServices, activeSessionId || undefined, isAuthenticated);
|
|
72
|
+
response = await fetch(url, retryOptions);
|
|
73
|
+
} catch (refreshError) {
|
|
74
|
+
// Refresh failed, throw authentication error
|
|
75
|
+
const error = new Error('Authentication expired. Please login again.') as any;
|
|
76
|
+
error.status = 401;
|
|
77
|
+
error.code = 'AUTH_EXPIRED';
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
56
80
|
}
|
|
57
81
|
}
|
|
58
82
|
|
|
59
83
|
return response;
|
|
60
84
|
} catch (error) {
|
|
61
|
-
|
|
62
|
-
|
|
85
|
+
// Re-throw with additional context if needed
|
|
86
|
+
if (error instanceof Error) {
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
throw new Error('Request failed');
|
|
63
90
|
}
|
|
64
|
-
}, [
|
|
91
|
+
}, [oxyServices, activeSessionId, isAuthenticated]);
|
|
65
92
|
|
|
66
93
|
// JSON convenience methods
|
|
67
94
|
const get = useCallback(async (endpoint: string, options?: AuthFetchOptions) => {
|
|
@@ -100,7 +127,7 @@ export function useAuthFetch(): AuthFetchAPI {
|
|
|
100
127
|
return handleJsonResponse(response);
|
|
101
128
|
}, [authFetch]);
|
|
102
129
|
|
|
103
|
-
// Attach convenience methods and auth state
|
|
130
|
+
// Attach convenience methods and auth state to the main function
|
|
104
131
|
const fetchWithMethods = authFetch as AuthFetchAPI;
|
|
105
132
|
fetchWithMethods.get = get;
|
|
106
133
|
fetchWithMethods.post = post;
|
|
@@ -111,58 +138,64 @@ export function useAuthFetch(): AuthFetchAPI {
|
|
|
111
138
|
fetchWithMethods.login = login;
|
|
112
139
|
fetchWithMethods.logout = logout;
|
|
113
140
|
fetchWithMethods.signUp = signUp;
|
|
141
|
+
fetchWithMethods.setApiUrl = setApiUrl;
|
|
114
142
|
|
|
115
143
|
return fetchWithMethods;
|
|
116
144
|
}
|
|
117
145
|
|
|
118
146
|
/**
|
|
119
|
-
* Helper functions
|
|
147
|
+
* Helper functions
|
|
120
148
|
*/
|
|
121
149
|
|
|
122
150
|
function resolveURL(input: RequestInfo | URL, baseURL: string): string {
|
|
151
|
+
if (!baseURL) {
|
|
152
|
+
throw new Error('Base URL not configured. Please provide a baseURL in OxyServices configuration.');
|
|
153
|
+
}
|
|
154
|
+
|
|
123
155
|
const url = input.toString();
|
|
124
156
|
|
|
157
|
+
// If it's already a full URL (http/https), return as is
|
|
125
158
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
126
159
|
return url;
|
|
127
160
|
}
|
|
128
161
|
|
|
162
|
+
// Normalize base URL (remove trailing slash)
|
|
163
|
+
const normalizedBaseURL = baseURL.replace(/\/$/, '');
|
|
164
|
+
|
|
165
|
+
// If URL starts with /, it's relative to base URL
|
|
129
166
|
if (url.startsWith('/')) {
|
|
130
|
-
return `${
|
|
167
|
+
return `${normalizedBaseURL}${url}`;
|
|
131
168
|
}
|
|
132
169
|
|
|
133
|
-
|
|
170
|
+
// Otherwise, append to base URL with /
|
|
171
|
+
return `${normalizedBaseURL}/${url}`;
|
|
134
172
|
}
|
|
135
173
|
|
|
136
|
-
async function addAuthHeaders(init?: AuthFetchOptions,
|
|
174
|
+
async function addAuthHeaders(init?: AuthFetchOptions, oxyServices?: any, activeSessionId?: string, isAuthenticated?: boolean): Promise<RequestInit> {
|
|
137
175
|
const headers = new Headers(init?.headers);
|
|
138
176
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
console.log('[AuthFetch] AuthManager type:', typeof authManager);
|
|
142
|
-
console.log('[AuthFetch] Has Authorization header already:', headers.has('Authorization'));
|
|
143
|
-
|
|
144
|
-
if (authManager && !headers.has('Authorization')) {
|
|
177
|
+
// Add auth header if user is authenticated
|
|
178
|
+
if (isAuthenticated && oxyServices && !headers.has('Authorization')) {
|
|
145
179
|
try {
|
|
146
|
-
|
|
180
|
+
// First try to get regular JWT access token
|
|
181
|
+
let accessToken = oxyServices.getAccessToken?.();
|
|
147
182
|
|
|
148
|
-
|
|
149
|
-
|
|
183
|
+
// If no JWT token but we have a secure session, try to get token from session
|
|
184
|
+
if (!accessToken && activeSessionId) {
|
|
185
|
+
try {
|
|
186
|
+
const tokenData = await oxyServices.getTokenBySession(activeSessionId);
|
|
187
|
+
accessToken = tokenData.accessToken;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
// Silent fail - will attempt request without token
|
|
190
|
+
}
|
|
191
|
+
}
|
|
150
192
|
|
|
151
193
|
if (accessToken) {
|
|
152
194
|
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
153
|
-
console.log('[AuthFetch] Added Authorization header successfully');
|
|
154
|
-
} else if (authManager.isAuthenticated()) {
|
|
155
|
-
console.error('[AuthFetch] User is authenticated but no token available');
|
|
156
|
-
throw new Error('Authentication state inconsistent. Please login again.');
|
|
157
|
-
} else {
|
|
158
|
-
console.log('[AuthFetch] User not authenticated, skipping auth header');
|
|
159
195
|
}
|
|
160
196
|
} catch (error) {
|
|
161
|
-
|
|
162
|
-
throw error;
|
|
197
|
+
// Silent fail - will attempt request without token
|
|
163
198
|
}
|
|
164
|
-
} else {
|
|
165
|
-
console.log('[AuthFetch] Skipping auth header - authManager:', !!authManager, 'hasAuthHeader:', headers.has('Authorization'));
|
|
166
199
|
}
|
|
167
200
|
|
|
168
201
|
const body = init?.body;
|
|
@@ -197,6 +230,7 @@ async function handleJsonResponse(response: Response): Promise<any> {
|
|
|
197
230
|
try {
|
|
198
231
|
return await response.json();
|
|
199
232
|
} catch {
|
|
233
|
+
// If response isn't JSON, return the response itself
|
|
200
234
|
return response;
|
|
201
235
|
}
|
|
202
236
|
}
|
|
@@ -82,10 +82,10 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
82
82
|
try {
|
|
83
83
|
setActionLoading(sessionId);
|
|
84
84
|
await logout(sessionId);
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
// Refresh sessions to update the list
|
|
87
87
|
await refreshSessions();
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
toast.success('Session logged out successfully');
|
|
90
90
|
} catch (error) {
|
|
91
91
|
console.error('Logout session failed:', error);
|
|
@@ -100,8 +100,8 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
const handleLogoutOtherSessions = async () => {
|
|
103
|
-
const otherSessionsCount = userSessions.filter(
|
|
104
|
-
|
|
103
|
+
const otherSessionsCount = userSessions.filter(s => s.sessionId !== activeSessionId).length;
|
|
104
|
+
|
|
105
105
|
if (otherSessionsCount === 0) {
|
|
106
106
|
toast.info('No other sessions to logout.');
|
|
107
107
|
return;
|
|
@@ -124,10 +124,10 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
124
124
|
await logout(session.sessionId);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
// Refresh sessions to update the list
|
|
129
129
|
await refreshSessions();
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
toast.success('Other sessions logged out successfully');
|
|
132
132
|
} catch (error) {
|
|
133
133
|
console.error('Logout other sessions failed:', error);
|
|
@@ -175,7 +175,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
175
175
|
if (diffInMinutes < 60) return `${diffInMinutes}m ago`;
|
|
176
176
|
if (diffInMinutes < 1440) return `${Math.floor(diffInMinutes / 60)}h ago`;
|
|
177
177
|
if (diffInMinutes < 10080) return `${Math.floor(diffInMinutes / 1440)}d ago`;
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
return date.toLocaleDateString();
|
|
180
180
|
};
|
|
181
181
|
|
|
@@ -230,7 +230,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
230
230
|
>
|
|
231
231
|
{userSessions.length > 0 ? (
|
|
232
232
|
<>
|
|
233
|
-
{userSessions.map((session
|
|
233
|
+
{userSessions.map((session) => (
|
|
234
234
|
<View
|
|
235
235
|
key={session.sessionId}
|
|
236
236
|
style={[
|
|
@@ -294,7 +294,7 @@ const SessionManagementScreen: React.FC<BaseScreenProps> = ({
|
|
|
294
294
|
<TouchableOpacity
|
|
295
295
|
style={[styles.bulkActionButton, { backgroundColor: isDarkTheme ? '#1A1A1A' : '#F0F0F0', borderColor }]}
|
|
296
296
|
onPress={handleLogoutOtherSessions}
|
|
297
|
-
disabled={actionLoading === 'others' || userSessions.filter(
|
|
297
|
+
disabled={actionLoading === 'others' || userSessions.filter(s => s.sessionId !== activeSessionId).length === 0}
|
|
298
298
|
>
|
|
299
299
|
{actionLoading === 'others' ? (
|
|
300
300
|
<ActivityIndicator size="small" color={primaryColor} />
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AuthManager = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Centralized Authentication Manager
|
|
9
|
-
*
|
|
10
|
-
* Single source of truth for all authentication operations
|
|
11
|
-
* Handles both JWT and session-based authentication seamlessly
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
class AuthManager {
|
|
15
|
-
currentState = {
|
|
16
|
-
isAuthenticated: false,
|
|
17
|
-
accessToken: null,
|
|
18
|
-
user: null,
|
|
19
|
-
activeSessionId: null,
|
|
20
|
-
sessions: [],
|
|
21
|
-
isLoading: false,
|
|
22
|
-
error: null
|
|
23
|
-
};
|
|
24
|
-
constructor(config) {
|
|
25
|
-
this.oxyServices = config.oxyServices;
|
|
26
|
-
this.onStateChange = config.onStateChange;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get current authentication state
|
|
31
|
-
*/
|
|
32
|
-
getState() {
|
|
33
|
-
return {
|
|
34
|
-
...this.currentState
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get access token for API calls
|
|
40
|
-
* This is the ONLY method that should be used to get tokens
|
|
41
|
-
*/
|
|
42
|
-
async getAccessToken() {
|
|
43
|
-
console.log('[AuthManager] getAccessToken called');
|
|
44
|
-
console.log('[AuthManager] Current state:', {
|
|
45
|
-
isAuthenticated: this.currentState.isAuthenticated,
|
|
46
|
-
activeSessionId: this.currentState.activeSessionId,
|
|
47
|
-
hasUser: !!this.currentState.user,
|
|
48
|
-
cachedToken: !!this.currentState.accessToken
|
|
49
|
-
});
|
|
50
|
-
try {
|
|
51
|
-
// If we have a cached token in state, return it
|
|
52
|
-
if (this.currentState.accessToken) {
|
|
53
|
-
console.log('[AuthManager] Returning cached token from state');
|
|
54
|
-
return this.currentState.accessToken;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// If we already have a valid JWT token in service, return it
|
|
58
|
-
let token = this.oxyServices.getAccessToken();
|
|
59
|
-
if (token) {
|
|
60
|
-
console.log('[AuthManager] Found token in OxyServices');
|
|
61
|
-
// Cache it in our state for consistency
|
|
62
|
-
this.updateState({
|
|
63
|
-
accessToken: token
|
|
64
|
-
});
|
|
65
|
-
return token;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// If we have an active session, get token from session
|
|
69
|
-
if (this.currentState.activeSessionId) {
|
|
70
|
-
console.log('[AuthManager] Getting token from session:', this.currentState.activeSessionId);
|
|
71
|
-
const tokenData = await this.oxyServices.getTokenBySession(this.currentState.activeSessionId);
|
|
72
|
-
token = tokenData.accessToken;
|
|
73
|
-
|
|
74
|
-
// Cache it both in service and state
|
|
75
|
-
this.oxyServices.setTokens(token, '');
|
|
76
|
-
this.updateState({
|
|
77
|
-
accessToken: token
|
|
78
|
-
});
|
|
79
|
-
console.log('[AuthManager] Successfully retrieved and cached token from session');
|
|
80
|
-
return token;
|
|
81
|
-
}
|
|
82
|
-
console.warn('[AuthManager] No way to get access token - not authenticated or no session');
|
|
83
|
-
return null;
|
|
84
|
-
} catch (error) {
|
|
85
|
-
console.error('[AuthManager] Failed to get access token:', error);
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Login with username/password
|
|
92
|
-
*/
|
|
93
|
-
async login(username, password, deviceName) {
|
|
94
|
-
this.updateState({
|
|
95
|
-
isLoading: true,
|
|
96
|
-
error: null
|
|
97
|
-
});
|
|
98
|
-
try {
|
|
99
|
-
// Use secure session login
|
|
100
|
-
const response = await this.oxyServices.secureLogin(username, password, deviceName);
|
|
101
|
-
|
|
102
|
-
// Get and cache the access token
|
|
103
|
-
const tokenData = await this.oxyServices.getTokenBySession(response.sessionId);
|
|
104
|
-
this.oxyServices.setTokens(tokenData.accessToken, '');
|
|
105
|
-
|
|
106
|
-
// Load full user data
|
|
107
|
-
const user = await this.oxyServices.getUserBySession(response.sessionId);
|
|
108
|
-
|
|
109
|
-
// Load sessions list
|
|
110
|
-
const sessions = await this.oxyServices.getSessionsBySessionId(response.sessionId);
|
|
111
|
-
this.updateState({
|
|
112
|
-
isAuthenticated: true,
|
|
113
|
-
accessToken: tokenData.accessToken,
|
|
114
|
-
user,
|
|
115
|
-
activeSessionId: response.sessionId,
|
|
116
|
-
sessions,
|
|
117
|
-
isLoading: false,
|
|
118
|
-
error: null
|
|
119
|
-
});
|
|
120
|
-
} catch (error) {
|
|
121
|
-
this.updateState({
|
|
122
|
-
isLoading: false,
|
|
123
|
-
error: error.message || 'Login failed'
|
|
124
|
-
});
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Sign up new user
|
|
131
|
-
*/
|
|
132
|
-
async signUp(username, email, password) {
|
|
133
|
-
this.updateState({
|
|
134
|
-
isLoading: true,
|
|
135
|
-
error: null
|
|
136
|
-
});
|
|
137
|
-
try {
|
|
138
|
-
// Create account
|
|
139
|
-
await this.oxyServices.signUp(username, email, password);
|
|
140
|
-
|
|
141
|
-
// Auto-login after signup
|
|
142
|
-
await this.login(username, password);
|
|
143
|
-
} catch (error) {
|
|
144
|
-
this.updateState({
|
|
145
|
-
isLoading: false,
|
|
146
|
-
error: error.message || 'Sign up failed'
|
|
147
|
-
});
|
|
148
|
-
throw error;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Logout current session or specific session
|
|
154
|
-
*/
|
|
155
|
-
async logout(targetSessionId) {
|
|
156
|
-
if (!this.currentState.activeSessionId) return;
|
|
157
|
-
const sessionToLogout = targetSessionId || this.currentState.activeSessionId;
|
|
158
|
-
try {
|
|
159
|
-
await this.oxyServices.logoutSecureSession(this.currentState.activeSessionId, sessionToLogout);
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.warn('[AuthManager] Logout API call failed:', error);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// If logging out current session, clear all state
|
|
165
|
-
if (sessionToLogout === this.currentState.activeSessionId) {
|
|
166
|
-
this.clearAuthState();
|
|
167
|
-
} else {
|
|
168
|
-
// Just remove the specific session from the list
|
|
169
|
-
const updatedSessions = this.currentState.sessions.filter(s => s.sessionId !== sessionToLogout);
|
|
170
|
-
this.updateState({
|
|
171
|
-
sessions: updatedSessions
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Initialize authentication from stored data
|
|
178
|
-
*/
|
|
179
|
-
async initialize(activeSessionId) {
|
|
180
|
-
if (!activeSessionId) {
|
|
181
|
-
this.clearAuthState();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
this.updateState({
|
|
185
|
-
isLoading: true,
|
|
186
|
-
error: null
|
|
187
|
-
});
|
|
188
|
-
try {
|
|
189
|
-
// Validate the session
|
|
190
|
-
const validation = await this.oxyServices.validateSession(activeSessionId);
|
|
191
|
-
if (!validation.valid) {
|
|
192
|
-
this.clearAuthState();
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Get access token
|
|
197
|
-
const tokenData = await this.oxyServices.getTokenBySession(activeSessionId);
|
|
198
|
-
this.oxyServices.setTokens(tokenData.accessToken, '');
|
|
199
|
-
|
|
200
|
-
// Load user data
|
|
201
|
-
const user = await this.oxyServices.getUserBySession(activeSessionId);
|
|
202
|
-
|
|
203
|
-
// Load sessions list
|
|
204
|
-
const sessions = await this.oxyServices.getSessionsBySessionId(activeSessionId);
|
|
205
|
-
this.updateState({
|
|
206
|
-
isAuthenticated: true,
|
|
207
|
-
accessToken: tokenData.accessToken,
|
|
208
|
-
user,
|
|
209
|
-
activeSessionId,
|
|
210
|
-
sessions,
|
|
211
|
-
isLoading: false,
|
|
212
|
-
error: null
|
|
213
|
-
});
|
|
214
|
-
} catch (error) {
|
|
215
|
-
console.error('[AuthManager] Initialization failed:', error);
|
|
216
|
-
this.clearAuthState();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Refresh current token
|
|
222
|
-
*/
|
|
223
|
-
async refreshToken() {
|
|
224
|
-
if (!this.currentState.activeSessionId) {
|
|
225
|
-
throw new Error('No active session to refresh');
|
|
226
|
-
}
|
|
227
|
-
try {
|
|
228
|
-
const tokenData = await this.oxyServices.getTokenBySession(this.currentState.activeSessionId);
|
|
229
|
-
this.oxyServices.setTokens(tokenData.accessToken, '');
|
|
230
|
-
this.updateState({
|
|
231
|
-
accessToken: tokenData.accessToken
|
|
232
|
-
});
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error('[AuthManager] Token refresh failed:', error);
|
|
235
|
-
this.clearAuthState();
|
|
236
|
-
throw error;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Check if user is authenticated
|
|
242
|
-
*/
|
|
243
|
-
isAuthenticated() {
|
|
244
|
-
const result = this.currentState.isAuthenticated;
|
|
245
|
-
console.log('[AuthManager] isAuthenticated check:', result);
|
|
246
|
-
return result;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Get current user
|
|
251
|
-
*/
|
|
252
|
-
getCurrentUser() {
|
|
253
|
-
return this.currentState.user;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Get current session ID
|
|
258
|
-
*/
|
|
259
|
-
getActiveSessionId() {
|
|
260
|
-
return this.currentState.activeSessionId;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Get base URL for API calls
|
|
265
|
-
*/
|
|
266
|
-
getBaseURL() {
|
|
267
|
-
return this.oxyServices.getBaseURL();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Refresh sessions list
|
|
272
|
-
*/
|
|
273
|
-
async refreshSessions() {
|
|
274
|
-
if (!this.currentState.activeSessionId) return;
|
|
275
|
-
try {
|
|
276
|
-
const sessions = await this.oxyServices.getSessionsBySessionId(this.currentState.activeSessionId);
|
|
277
|
-
this.updateState({
|
|
278
|
-
sessions
|
|
279
|
-
});
|
|
280
|
-
} catch (error) {
|
|
281
|
-
console.error('[AuthManager] Failed to refresh sessions:', error);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Get current sessions
|
|
287
|
-
*/
|
|
288
|
-
getSessions() {
|
|
289
|
-
return this.currentState.sessions;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Switch to a different session
|
|
294
|
-
*/
|
|
295
|
-
async switchSession(sessionId) {
|
|
296
|
-
if (sessionId === this.currentState.activeSessionId) return;
|
|
297
|
-
this.updateState({
|
|
298
|
-
isLoading: true,
|
|
299
|
-
error: null
|
|
300
|
-
});
|
|
301
|
-
try {
|
|
302
|
-
// Get access token for this session
|
|
303
|
-
const tokenData = await this.oxyServices.getTokenBySession(sessionId);
|
|
304
|
-
this.oxyServices.setTokens(tokenData.accessToken, '');
|
|
305
|
-
|
|
306
|
-
// Load user data
|
|
307
|
-
const user = await this.oxyServices.getUserBySession(sessionId);
|
|
308
|
-
this.updateState({
|
|
309
|
-
activeSessionId: sessionId,
|
|
310
|
-
accessToken: tokenData.accessToken,
|
|
311
|
-
user,
|
|
312
|
-
isLoading: false
|
|
313
|
-
});
|
|
314
|
-
} catch (error) {
|
|
315
|
-
console.error('[AuthManager] Switch session failed:', error);
|
|
316
|
-
this.updateState({
|
|
317
|
-
isLoading: false,
|
|
318
|
-
error: 'Failed to switch session'
|
|
319
|
-
});
|
|
320
|
-
throw error;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Remove a session (alias for logout with sessionId)
|
|
326
|
-
*/
|
|
327
|
-
async removeSession(sessionId) {
|
|
328
|
-
await this.logout(sessionId);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Logout all sessions
|
|
333
|
-
*/
|
|
334
|
-
async logoutAll() {
|
|
335
|
-
if (!this.currentState.activeSessionId) {
|
|
336
|
-
throw new Error('No active session found');
|
|
337
|
-
}
|
|
338
|
-
try {
|
|
339
|
-
await this.oxyServices.logoutAllSecureSessions(this.currentState.activeSessionId);
|
|
340
|
-
this.clearAuthState();
|
|
341
|
-
} catch (error) {
|
|
342
|
-
console.error('[AuthManager] Logout all failed:', error);
|
|
343
|
-
throw error;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Clear authentication state
|
|
349
|
-
*/
|
|
350
|
-
clearAuthState() {
|
|
351
|
-
this.oxyServices.setTokens('', ''); // Clear tokens from service
|
|
352
|
-
|
|
353
|
-
this.updateState({
|
|
354
|
-
isAuthenticated: false,
|
|
355
|
-
accessToken: null,
|
|
356
|
-
user: null,
|
|
357
|
-
activeSessionId: null,
|
|
358
|
-
sessions: [],
|
|
359
|
-
isLoading: false,
|
|
360
|
-
error: null
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Update state and notify listeners
|
|
366
|
-
*/
|
|
367
|
-
updateState(updates) {
|
|
368
|
-
this.currentState = {
|
|
369
|
-
...this.currentState,
|
|
370
|
-
...updates
|
|
371
|
-
};
|
|
372
|
-
if (this.onStateChange) {
|
|
373
|
-
this.onStateChange(this.currentState);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
exports.AuthManager = AuthManager;
|
|
378
|
-
//# sourceMappingURL=AuthManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["AuthManager","currentState","isAuthenticated","accessToken","user","activeSessionId","sessions","isLoading","error","constructor","config","oxyServices","onStateChange","getState","getAccessToken","console","log","hasUser","cachedToken","token","updateState","tokenData","getTokenBySession","setTokens","warn","login","username","password","deviceName","response","secureLogin","sessionId","getUserBySession","getSessionsBySessionId","message","signUp","email","logout","targetSessionId","sessionToLogout","logoutSecureSession","clearAuthState","updatedSessions","filter","s","initialize","validation","validateSession","valid","refreshToken","Error","result","getCurrentUser","getActiveSessionId","getBaseURL","refreshSessions","getSessions","switchSession","removeSession","logoutAll","logoutAllSecureSessions","updates","exports"],"sourceRoot":"../../../src","sources":["core/AuthManager.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAmBO,MAAMA,WAAW,CAAC;EAGfC,YAAY,GAAc;IAChCC,eAAe,EAAE,KAAK;IACtBC,WAAW,EAAE,IAAI;IACjBC,IAAI,EAAE,IAAI;IACVC,eAAe,EAAE,IAAI;IACrBC,QAAQ,EAAE,EAAE;IACZC,SAAS,EAAE,KAAK;IAChBC,KAAK,EAAE;EACT,CAAC;EAEDC,WAAWA,CAACC,MAAkB,EAAE;IAC9B,IAAI,CAACC,WAAW,GAAGD,MAAM,CAACC,WAAW;IACrC,IAAI,CAACC,aAAa,GAAGF,MAAM,CAACE,aAAa;EAC3C;;EAEA;AACF;AAC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