@oxyhq/services 5.5.6 → 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.
Files changed (34) hide show
  1. package/lib/commonjs/core/index.js +13 -13
  2. package/lib/commonjs/core/index.js.map +1 -1
  3. package/lib/commonjs/ui/context/OxyContext.js +467 -87
  4. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  5. package/lib/commonjs/ui/hooks/useAuthFetch.js +79 -29
  6. package/lib/commonjs/ui/hooks/useAuthFetch.js.map +1 -1
  7. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  8. package/lib/module/core/index.js +13 -6
  9. package/lib/module/core/index.js.map +1 -1
  10. package/lib/module/ui/context/OxyContext.js +467 -87
  11. package/lib/module/ui/context/OxyContext.js.map +1 -1
  12. package/lib/module/ui/hooks/useAuthFetch.js +79 -29
  13. package/lib/module/ui/hooks/useAuthFetch.js.map +1 -1
  14. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  15. package/lib/typescript/core/index.d.ts +7 -6
  16. package/lib/typescript/core/index.d.ts.map +1 -1
  17. package/lib/typescript/ui/context/OxyContext.d.ts +11 -7
  18. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  19. package/lib/typescript/ui/hooks/useAuthFetch.d.ts +10 -4
  20. package/lib/typescript/ui/hooks/useAuthFetch.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/src/__tests__/backend-middleware.test.ts +209 -0
  23. package/src/__tests__/ui/hooks/useAuthFetch.test.ts +70 -0
  24. package/src/core/index.ts +13 -7
  25. package/src/ui/context/OxyContext.tsx +522 -99
  26. package/src/ui/hooks/useAuthFetch.ts +83 -29
  27. package/src/ui/screens/SessionManagementScreen.tsx +9 -9
  28. package/lib/commonjs/core/AuthManager.js +0 -352
  29. package/lib/commonjs/core/AuthManager.js.map +0 -1
  30. package/lib/module/core/AuthManager.js +0 -347
  31. package/lib/module/core/AuthManager.js.map +0 -1
  32. package/lib/typescript/core/AuthManager.d.ts +0 -100
  33. package/lib/typescript/core/AuthManager.d.ts.map +0 -1
  34. package/src/core/AuthManager.ts +0 -366
@@ -1,62 +1,94 @@
1
1
  /**
2
- * Simplified Authenticated Fetch Hook
2
+ * Zero Config Authenticated Fetch Hook
3
3
  *
4
- * Clean, professional hook that uses the centralized AuthManager
5
- * No more duplicate authentication logic or race conditions
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 centralized AuthManager for all authentication operations
43
+ * Uses the existing OxyServices instance from useOxy context
31
44
  */
32
45
  export function useAuthFetch(): AuthFetchAPI {
33
- const { authManager, isAuthenticated, user, login, logout, signUp } = useOxy();
46
+ const { oxyServices, isAuthenticated, user, login, logout, signUp, activeSessionId, setApiUrl } = useOxy();
34
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
35
54
  const authFetch = useCallback(async (input: RequestInfo | URL, init?: AuthFetchOptions): Promise<Response> => {
36
- const url = resolveURL(input, authManager.getBaseURL());
37
- const options = await addAuthHeaders(init, authManager);
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);
38
61
 
39
62
  try {
40
63
  let response = await fetch(url, options);
41
64
 
42
65
  // Handle token expiry and automatic refresh
43
66
  if (response.status === 401 && isAuthenticated) {
44
- try {
45
- await authManager.refreshToken();
46
- const retryOptions = await addAuthHeaders(init, authManager);
47
- response = await fetch(url, retryOptions);
48
- } catch (refreshError) {
49
- console.warn('[AuthFetch] Token refresh failed:', refreshError);
50
- throw new Error('Authentication expired. Please login again.');
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
+ }
51
80
  }
52
81
  }
53
82
 
54
83
  return response;
55
84
  } catch (error) {
56
- console.error('[AuthFetch] Request failed:', error);
57
- throw error;
85
+ // Re-throw with additional context if needed
86
+ if (error instanceof Error) {
87
+ throw error;
88
+ }
89
+ throw new Error('Request failed');
58
90
  }
59
- }, [authManager, isAuthenticated]);
91
+ }, [oxyServices, activeSessionId, isAuthenticated]);
60
92
 
61
93
  // JSON convenience methods
62
94
  const get = useCallback(async (endpoint: string, options?: AuthFetchOptions) => {
@@ -95,7 +127,7 @@ export function useAuthFetch(): AuthFetchAPI {
95
127
  return handleJsonResponse(response);
96
128
  }, [authFetch]);
97
129
 
98
- // Attach convenience methods and auth state
130
+ // Attach convenience methods and auth state to the main function
99
131
  const fetchWithMethods = authFetch as AuthFetchAPI;
100
132
  fetchWithMethods.get = get;
101
133
  fetchWithMethods.post = post;
@@ -106,42 +138,63 @@ export function useAuthFetch(): AuthFetchAPI {
106
138
  fetchWithMethods.login = login;
107
139
  fetchWithMethods.logout = logout;
108
140
  fetchWithMethods.signUp = signUp;
141
+ fetchWithMethods.setApiUrl = setApiUrl;
109
142
 
110
143
  return fetchWithMethods;
111
144
  }
112
145
 
113
146
  /**
114
- * Helper functions - much simpler now
147
+ * Helper functions
115
148
  */
116
149
 
117
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
+
118
155
  const url = input.toString();
119
156
 
157
+ // If it's already a full URL (http/https), return as is
120
158
  if (url.startsWith('http://') || url.startsWith('https://')) {
121
159
  return url;
122
160
  }
123
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
124
166
  if (url.startsWith('/')) {
125
- return `${baseURL}${url}`;
167
+ return `${normalizedBaseURL}${url}`;
126
168
  }
127
169
 
128
- return `${baseURL}/${url}`;
170
+ // Otherwise, append to base URL with /
171
+ return `${normalizedBaseURL}/${url}`;
129
172
  }
130
173
 
131
- async function addAuthHeaders(init?: AuthFetchOptions, authManager?: any): Promise<RequestInit> {
174
+ async function addAuthHeaders(init?: AuthFetchOptions, oxyServices?: any, activeSessionId?: string, isAuthenticated?: boolean): Promise<RequestInit> {
132
175
  const headers = new Headers(init?.headers);
133
176
 
134
- if (authManager && !headers.has('Authorization')) {
177
+ // Add auth header if user is authenticated
178
+ if (isAuthenticated && oxyServices && !headers.has('Authorization')) {
135
179
  try {
136
- const accessToken = await authManager.getAccessToken();
180
+ // First try to get regular JWT access token
181
+ let accessToken = oxyServices.getAccessToken?.();
182
+
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
+ }
192
+
137
193
  if (accessToken) {
138
194
  headers.set('Authorization', `Bearer ${accessToken}`);
139
- } else if (authManager.isAuthenticated()) {
140
- throw new Error('Authentication state inconsistent. Please login again.');
141
195
  }
142
196
  } catch (error) {
143
- console.error('[AuthFetch] Failed to get access token:', error);
144
- throw error;
197
+ // Silent fail - will attempt request without token
145
198
  }
146
199
  }
147
200
 
@@ -177,6 +230,7 @@ async function handleJsonResponse(response: Response): Promise<any> {
177
230
  try {
178
231
  return await response.json();
179
232
  } catch {
233
+ // If response isn't JSON, return the response itself
180
234
  return response;
181
235
  }
182
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((s: any) => s.sessionId !== activeSessionId).length;
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: any) => (
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((s: any) => s.sessionId !== activeSessionId).length === 0}
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,352 +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
- try {
44
- // If we already have a valid JWT token, return it
45
- let token = this.oxyServices.getAccessToken();
46
- if (token) {
47
- return token;
48
- }
49
-
50
- // If we have an active session, get token from session
51
- if (this.currentState.activeSessionId) {
52
- const tokenData = await this.oxyServices.getTokenBySession(this.currentState.activeSessionId);
53
- token = tokenData.accessToken;
54
-
55
- // Cache it for future calls
56
- this.oxyServices.setTokens(token, '');
57
- return token;
58
- }
59
- return null;
60
- } catch (error) {
61
- console.error('[AuthManager] Failed to get access token:', error);
62
- return null;
63
- }
64
- }
65
-
66
- /**
67
- * Login with username/password
68
- */
69
- async login(username, password, deviceName) {
70
- this.updateState({
71
- isLoading: true,
72
- error: null
73
- });
74
- try {
75
- // Use secure session login
76
- const response = await this.oxyServices.secureLogin(username, password, deviceName);
77
-
78
- // Get and cache the access token
79
- const tokenData = await this.oxyServices.getTokenBySession(response.sessionId);
80
- this.oxyServices.setTokens(tokenData.accessToken, '');
81
-
82
- // Load full user data
83
- const user = await this.oxyServices.getUserBySession(response.sessionId);
84
-
85
- // Load sessions list
86
- const sessions = await this.oxyServices.getSessionsBySessionId(response.sessionId);
87
- this.updateState({
88
- isAuthenticated: true,
89
- accessToken: tokenData.accessToken,
90
- user,
91
- activeSessionId: response.sessionId,
92
- sessions,
93
- isLoading: false,
94
- error: null
95
- });
96
- } catch (error) {
97
- this.updateState({
98
- isLoading: false,
99
- error: error.message || 'Login failed'
100
- });
101
- throw error;
102
- }
103
- }
104
-
105
- /**
106
- * Sign up new user
107
- */
108
- async signUp(username, email, password) {
109
- this.updateState({
110
- isLoading: true,
111
- error: null
112
- });
113
- try {
114
- // Create account
115
- await this.oxyServices.signUp(username, email, password);
116
-
117
- // Auto-login after signup
118
- await this.login(username, password);
119
- } catch (error) {
120
- this.updateState({
121
- isLoading: false,
122
- error: error.message || 'Sign up failed'
123
- });
124
- throw error;
125
- }
126
- }
127
-
128
- /**
129
- * Logout current session or specific session
130
- */
131
- async logout(targetSessionId) {
132
- if (!this.currentState.activeSessionId) return;
133
- const sessionToLogout = targetSessionId || this.currentState.activeSessionId;
134
- try {
135
- await this.oxyServices.logoutSecureSession(this.currentState.activeSessionId, sessionToLogout);
136
- } catch (error) {
137
- console.warn('[AuthManager] Logout API call failed:', error);
138
- }
139
-
140
- // If logging out current session, clear all state
141
- if (sessionToLogout === this.currentState.activeSessionId) {
142
- this.clearAuthState();
143
- } else {
144
- // Just remove the specific session from the list
145
- const updatedSessions = this.currentState.sessions.filter(s => s.sessionId !== sessionToLogout);
146
- this.updateState({
147
- sessions: updatedSessions
148
- });
149
- }
150
- }
151
-
152
- /**
153
- * Initialize authentication from stored data
154
- */
155
- async initialize(activeSessionId) {
156
- if (!activeSessionId) {
157
- this.clearAuthState();
158
- return;
159
- }
160
- this.updateState({
161
- isLoading: true,
162
- error: null
163
- });
164
- try {
165
- // Validate the session
166
- const validation = await this.oxyServices.validateSession(activeSessionId);
167
- if (!validation.valid) {
168
- this.clearAuthState();
169
- return;
170
- }
171
-
172
- // Get access token
173
- const tokenData = await this.oxyServices.getTokenBySession(activeSessionId);
174
- this.oxyServices.setTokens(tokenData.accessToken, '');
175
-
176
- // Load user data
177
- const user = await this.oxyServices.getUserBySession(activeSessionId);
178
-
179
- // Load sessions list
180
- const sessions = await this.oxyServices.getSessionsBySessionId(activeSessionId);
181
- this.updateState({
182
- isAuthenticated: true,
183
- accessToken: tokenData.accessToken,
184
- user,
185
- activeSessionId,
186
- sessions,
187
- isLoading: false,
188
- error: null
189
- });
190
- } catch (error) {
191
- console.error('[AuthManager] Initialization failed:', error);
192
- this.clearAuthState();
193
- }
194
- }
195
-
196
- /**
197
- * Refresh current token
198
- */
199
- async refreshToken() {
200
- if (!this.currentState.activeSessionId) {
201
- throw new Error('No active session to refresh');
202
- }
203
- try {
204
- const tokenData = await this.oxyServices.getTokenBySession(this.currentState.activeSessionId);
205
- this.oxyServices.setTokens(tokenData.accessToken, '');
206
- this.updateState({
207
- accessToken: tokenData.accessToken
208
- });
209
- } catch (error) {
210
- console.error('[AuthManager] Token refresh failed:', error);
211
- this.clearAuthState();
212
- throw error;
213
- }
214
- }
215
-
216
- /**
217
- * Check if user is authenticated
218
- */
219
- isAuthenticated() {
220
- return this.currentState.isAuthenticated;
221
- }
222
-
223
- /**
224
- * Get current user
225
- */
226
- getCurrentUser() {
227
- return this.currentState.user;
228
- }
229
-
230
- /**
231
- * Get current session ID
232
- */
233
- getActiveSessionId() {
234
- return this.currentState.activeSessionId;
235
- }
236
-
237
- /**
238
- * Get base URL for API calls
239
- */
240
- getBaseURL() {
241
- return this.oxyServices.getBaseURL();
242
- }
243
-
244
- /**
245
- * Refresh sessions list
246
- */
247
- async refreshSessions() {
248
- if (!this.currentState.activeSessionId) return;
249
- try {
250
- const sessions = await this.oxyServices.getSessionsBySessionId(this.currentState.activeSessionId);
251
- this.updateState({
252
- sessions
253
- });
254
- } catch (error) {
255
- console.error('[AuthManager] Failed to refresh sessions:', error);
256
- }
257
- }
258
-
259
- /**
260
- * Get current sessions
261
- */
262
- getSessions() {
263
- return this.currentState.sessions;
264
- }
265
-
266
- /**
267
- * Switch to a different session
268
- */
269
- async switchSession(sessionId) {
270
- if (sessionId === this.currentState.activeSessionId) return;
271
- this.updateState({
272
- isLoading: true,
273
- error: null
274
- });
275
- try {
276
- // Get access token for this session
277
- const tokenData = await this.oxyServices.getTokenBySession(sessionId);
278
- this.oxyServices.setTokens(tokenData.accessToken, '');
279
-
280
- // Load user data
281
- const user = await this.oxyServices.getUserBySession(sessionId);
282
- this.updateState({
283
- activeSessionId: sessionId,
284
- accessToken: tokenData.accessToken,
285
- user,
286
- isLoading: false
287
- });
288
- } catch (error) {
289
- console.error('[AuthManager] Switch session failed:', error);
290
- this.updateState({
291
- isLoading: false,
292
- error: 'Failed to switch session'
293
- });
294
- throw error;
295
- }
296
- }
297
-
298
- /**
299
- * Remove a session (alias for logout with sessionId)
300
- */
301
- async removeSession(sessionId) {
302
- await this.logout(sessionId);
303
- }
304
-
305
- /**
306
- * Logout all sessions
307
- */
308
- async logoutAll() {
309
- if (!this.currentState.activeSessionId) {
310
- throw new Error('No active session found');
311
- }
312
- try {
313
- await this.oxyServices.logoutAllSecureSessions(this.currentState.activeSessionId);
314
- this.clearAuthState();
315
- } catch (error) {
316
- console.error('[AuthManager] Logout all failed:', error);
317
- throw error;
318
- }
319
- }
320
-
321
- /**
322
- * Clear authentication state
323
- */
324
- clearAuthState() {
325
- this.oxyServices.setTokens('', ''); // Clear tokens from service
326
-
327
- this.updateState({
328
- isAuthenticated: false,
329
- accessToken: null,
330
- user: null,
331
- activeSessionId: null,
332
- sessions: [],
333
- isLoading: false,
334
- error: null
335
- });
336
- }
337
-
338
- /**
339
- * Update state and notify listeners
340
- */
341
- updateState(updates) {
342
- this.currentState = {
343
- ...this.currentState,
344
- ...updates
345
- };
346
- if (this.onStateChange) {
347
- this.onStateChange(this.currentState);
348
- }
349
- }
350
- }
351
- exports.AuthManager = AuthManager;
352
- //# 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","token","tokenData","getTokenBySession","setTokens","console","login","username","password","deviceName","updateState","response","secureLogin","sessionId","getUserBySession","getSessionsBySessionId","message","signUp","email","logout","targetSessionId","sessionToLogout","logoutSecureSession","warn","clearAuthState","updatedSessions","filter","s","initialize","validation","validateSession","valid","refreshToken","Error","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;AACA;EACEC,QAAQA,CAAA,EAAc;IACpB,OAAO;MAAE,GAAG,IAAI,CAACZ;IAAa,CAAC;EACjC;;EAEA;AACF;AACA;AACA;EACE,MAAMa,cAAcA,CAAA,EAA2B;IAC7C,IAAI;MACF;MACA,IAAIC,KAAK,GAAG,IAAI,CAACJ,WAAW,CAACG,cAAc,CAAC,CAAC;MAC7C,IAAIC,KAAK,EAAE;QACT,OAAOA,KAAK;MACd;;MAEA;MACA,IAAI,IAAI,CAACd,YAAY,CAACI,eAAe,EAAE;QACrC,MAAMW,SAAS,GAAG,MAAM,IAAI,CAACL,WAAW,CAACM,iBAAiB,CAAC,IAAI,CAAChB,YAAY,CAACI,eAAe,CAAC;QAC7FU,KAAK,GAAGC,SAAS,CAACb,WAAW;;QAE7B;QACA,IAAI,CAACQ,WAAW,CAACO,SAAS,CAACH,KAAK,EAAE,EAAE,CAAC;QACrC,OAAOA,KAAK;MACd;MAEA,OAAO,IAAI;IACb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