@thetechfossil/auth2 1.2.19 → 1.2.20

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 (38) hide show
  1. package/README.md +1 -1
  2. package/dist/index.components.d.mts +1 -0
  3. package/dist/index.components.d.ts +1 -0
  4. package/dist/index.components.js +204 -3
  5. package/dist/index.components.js.map +1 -1
  6. package/dist/index.components.mjs +204 -3
  7. package/dist/index.components.mjs.map +1 -1
  8. package/dist/index.d.mts +110 -3
  9. package/dist/index.d.ts +110 -3
  10. package/dist/index.js +399 -22
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +400 -24
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/index.next.d.mts +53 -1
  15. package/dist/index.next.d.ts +53 -1
  16. package/dist/index.next.js +261 -18
  17. package/dist/index.next.js.map +1 -1
  18. package/dist/index.next.mjs +261 -18
  19. package/dist/index.next.mjs.map +1 -1
  20. package/dist/index.next.server.d.mts +80 -2
  21. package/dist/index.next.server.d.ts +80 -2
  22. package/dist/index.next.server.js +335 -1
  23. package/dist/index.next.server.js.map +1 -1
  24. package/dist/index.next.server.mjs +332 -2
  25. package/dist/index.next.server.mjs.map +1 -1
  26. package/dist/index.node.d.mts +80 -2
  27. package/dist/index.node.d.ts +80 -2
  28. package/dist/index.node.js +335 -1
  29. package/dist/index.node.js.map +1 -1
  30. package/dist/index.node.mjs +332 -2
  31. package/dist/index.node.mjs.map +1 -1
  32. package/dist/index.react-native.d.mts +227 -0
  33. package/dist/index.react-native.d.ts +227 -0
  34. package/dist/index.react-native.js +1684 -0
  35. package/dist/index.react-native.js.map +1 -0
  36. package/dist/index.react-native.mjs +1648 -0
  37. package/dist/index.react-native.mjs.map +1 -0
  38. package/package.json +119 -102
@@ -16,6 +16,8 @@ interface User {
16
16
  phoneNumber?: string;
17
17
  avatar?: string;
18
18
  role: string;
19
+ emailVerified?: boolean;
20
+ twoFactorEnabled?: boolean;
19
21
  linkedAccounts?: LinkedAccount[];
20
22
  createdAt: string;
21
23
  updatedAt: string;
@@ -65,6 +67,7 @@ interface AuthConfig {
65
67
  localStorageKey?: string;
66
68
  token?: string;
67
69
  csrfEnabled?: boolean;
70
+ enableSocket?: boolean;
68
71
  upfilesConfig?: UpfilesConfig;
69
72
  }
70
73
  interface UpfilesConfig {
@@ -132,17 +135,57 @@ interface UseAuthReturn {
132
135
  }>;
133
136
  revokeSession: (sessionId: string) => Promise<AuthResponse>;
134
137
  revokeAllSessions: () => Promise<AuthResponse>;
138
+ adminCreateUser: (data: {
139
+ email: string;
140
+ name: string;
141
+ phoneNumber?: string;
142
+ password?: string;
143
+ }) => Promise<AuthResponse & {
144
+ user?: User;
145
+ }>;
146
+ adminVerifyUser: (userId: string) => Promise<AuthResponse>;
147
+ adminSuspendUser: (userId: string) => Promise<AuthResponse>;
148
+ adminActivateUser: (userId: string) => Promise<AuthResponse>;
135
149
  }
136
150
 
151
+ type SocketEventHandler<T = any> = (data: T) => void;
152
+
137
153
  declare class AuthService {
138
154
  private httpClient;
155
+ private socketService;
139
156
  private config;
140
157
  private token;
141
158
  private upfilesClient;
159
+ private cachedUser;
160
+ private userCacheTimestamp;
161
+ private readonly USER_CACHE_TTL;
142
162
  constructor(config: AuthConfig);
143
163
  private loadTokenFromStorage;
144
164
  private saveTokenToStorage;
145
165
  private removeTokenFromStorage;
166
+ private connectSocket;
167
+ private disconnectSocket;
168
+ onUserUpdated(handler: SocketEventHandler<{
169
+ user: User;
170
+ }>): () => void;
171
+ onSessionRevoked(handler: SocketEventHandler<{
172
+ sessionId?: string;
173
+ }>): () => void;
174
+ onAllSessionsRevoked(handler: SocketEventHandler<{}>): () => void;
175
+ onPasswordChanged(handler: SocketEventHandler<{}>): () => void;
176
+ on2FAChanged(handler: SocketEventHandler<{
177
+ enabled: boolean;
178
+ }>): () => void;
179
+ onSocketConnected(handler: SocketEventHandler<{}>): () => void;
180
+ onSocketDisconnected(handler: SocketEventHandler<{
181
+ reason: string;
182
+ }>): () => void;
183
+ onSocketError(handler: SocketEventHandler<{
184
+ error: string;
185
+ }>): () => void;
186
+ isSocketConnected(): boolean;
187
+ clearUserCache(): void;
188
+ private isCacheValid;
146
189
  isAuthenticated(): boolean;
147
190
  getToken(): string | null;
148
191
  getCurrentUser(): User | null;
@@ -156,7 +199,7 @@ declare class AuthService {
156
199
  verify(data: VerifyData): Promise<AuthResponse>;
157
200
  verifyEmailToken(token: string): Promise<AuthResponse>;
158
201
  logout(): Promise<void>;
159
- getProfile(): Promise<User>;
202
+ getProfile(forceRefresh?: boolean): Promise<User>;
160
203
  updateProfile(data: UpdateUserData): Promise<AuthResponse>;
161
204
  getAllUsers(): Promise<User[]>;
162
205
  getUserById(id: string): Promise<User>;
@@ -187,6 +230,14 @@ declare class AuthService {
187
230
  success: boolean;
188
231
  logs: any[];
189
232
  }>;
233
+ adminCreateUser(data: {
234
+ email: string;
235
+ name: string;
236
+ phoneNumber?: string;
237
+ password?: string;
238
+ }): Promise<AuthResponse & {
239
+ user?: User;
240
+ }>;
190
241
  adminVerifyUser(userId: string): Promise<AuthResponse>;
191
242
  adminForcePasswordReset(userId: string): Promise<AuthResponse>;
192
243
  adminSuspendUser(userId: string): Promise<AuthResponse>;
@@ -236,6 +287,7 @@ interface AuthContextValue {
236
287
  isLoaded: boolean;
237
288
  isSignedIn: boolean;
238
289
  loading: boolean;
290
+ isSocketConnected: boolean;
239
291
  signIn: (data: LoginData) => Promise<AuthResponse>;
240
292
  signUp: (data: RegisterData) => Promise<AuthResponse>;
241
293
  signOut: () => Promise<void>;
@@ -16,6 +16,8 @@ interface User {
16
16
  phoneNumber?: string;
17
17
  avatar?: string;
18
18
  role: string;
19
+ emailVerified?: boolean;
20
+ twoFactorEnabled?: boolean;
19
21
  linkedAccounts?: LinkedAccount[];
20
22
  createdAt: string;
21
23
  updatedAt: string;
@@ -65,6 +67,7 @@ interface AuthConfig {
65
67
  localStorageKey?: string;
66
68
  token?: string;
67
69
  csrfEnabled?: boolean;
70
+ enableSocket?: boolean;
68
71
  upfilesConfig?: UpfilesConfig;
69
72
  }
70
73
  interface UpfilesConfig {
@@ -132,17 +135,57 @@ interface UseAuthReturn {
132
135
  }>;
133
136
  revokeSession: (sessionId: string) => Promise<AuthResponse>;
134
137
  revokeAllSessions: () => Promise<AuthResponse>;
138
+ adminCreateUser: (data: {
139
+ email: string;
140
+ name: string;
141
+ phoneNumber?: string;
142
+ password?: string;
143
+ }) => Promise<AuthResponse & {
144
+ user?: User;
145
+ }>;
146
+ adminVerifyUser: (userId: string) => Promise<AuthResponse>;
147
+ adminSuspendUser: (userId: string) => Promise<AuthResponse>;
148
+ adminActivateUser: (userId: string) => Promise<AuthResponse>;
135
149
  }
136
150
 
151
+ type SocketEventHandler<T = any> = (data: T) => void;
152
+
137
153
  declare class AuthService {
138
154
  private httpClient;
155
+ private socketService;
139
156
  private config;
140
157
  private token;
141
158
  private upfilesClient;
159
+ private cachedUser;
160
+ private userCacheTimestamp;
161
+ private readonly USER_CACHE_TTL;
142
162
  constructor(config: AuthConfig);
143
163
  private loadTokenFromStorage;
144
164
  private saveTokenToStorage;
145
165
  private removeTokenFromStorage;
166
+ private connectSocket;
167
+ private disconnectSocket;
168
+ onUserUpdated(handler: SocketEventHandler<{
169
+ user: User;
170
+ }>): () => void;
171
+ onSessionRevoked(handler: SocketEventHandler<{
172
+ sessionId?: string;
173
+ }>): () => void;
174
+ onAllSessionsRevoked(handler: SocketEventHandler<{}>): () => void;
175
+ onPasswordChanged(handler: SocketEventHandler<{}>): () => void;
176
+ on2FAChanged(handler: SocketEventHandler<{
177
+ enabled: boolean;
178
+ }>): () => void;
179
+ onSocketConnected(handler: SocketEventHandler<{}>): () => void;
180
+ onSocketDisconnected(handler: SocketEventHandler<{
181
+ reason: string;
182
+ }>): () => void;
183
+ onSocketError(handler: SocketEventHandler<{
184
+ error: string;
185
+ }>): () => void;
186
+ isSocketConnected(): boolean;
187
+ clearUserCache(): void;
188
+ private isCacheValid;
146
189
  isAuthenticated(): boolean;
147
190
  getToken(): string | null;
148
191
  getCurrentUser(): User | null;
@@ -156,7 +199,7 @@ declare class AuthService {
156
199
  verify(data: VerifyData): Promise<AuthResponse>;
157
200
  verifyEmailToken(token: string): Promise<AuthResponse>;
158
201
  logout(): Promise<void>;
159
- getProfile(): Promise<User>;
202
+ getProfile(forceRefresh?: boolean): Promise<User>;
160
203
  updateProfile(data: UpdateUserData): Promise<AuthResponse>;
161
204
  getAllUsers(): Promise<User[]>;
162
205
  getUserById(id: string): Promise<User>;
@@ -187,6 +230,14 @@ declare class AuthService {
187
230
  success: boolean;
188
231
  logs: any[];
189
232
  }>;
233
+ adminCreateUser(data: {
234
+ email: string;
235
+ name: string;
236
+ phoneNumber?: string;
237
+ password?: string;
238
+ }): Promise<AuthResponse & {
239
+ user?: User;
240
+ }>;
190
241
  adminVerifyUser(userId: string): Promise<AuthResponse>;
191
242
  adminForcePasswordReset(userId: string): Promise<AuthResponse>;
192
243
  adminSuspendUser(userId: string): Promise<AuthResponse>;
@@ -236,6 +287,7 @@ interface AuthContextValue {
236
287
  isLoaded: boolean;
237
288
  isSignedIn: boolean;
238
289
  loading: boolean;
290
+ isSocketConnected: boolean;
239
291
  signIn: (data: LoginData) => Promise<AuthResponse>;
240
292
  signUp: (data: RegisterData) => Promise<AuthResponse>;
241
293
  signOut: () => Promise<void>;
@@ -2,6 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var axios = require('axios');
5
+ var socket_ioClient = require('socket.io-client');
5
6
  var upfiles = require('@thetechfossil/upfiles');
6
7
  var React = require('react');
7
8
  var jsxRuntime = require('react/jsx-runtime');
@@ -128,16 +129,134 @@ var HttpClient = class {
128
129
  }
129
130
  }
130
131
  };
132
+ var SocketService = class {
133
+ constructor(config) {
134
+ this.socket = null;
135
+ this.token = null;
136
+ this.eventHandlers = /* @__PURE__ */ new Map();
137
+ this.isConnecting = false;
138
+ this.config = {
139
+ autoConnect: false,
140
+ reconnection: true,
141
+ reconnectionAttempts: 5,
142
+ reconnectionDelay: 1e3,
143
+ ...config
144
+ };
145
+ }
146
+ connect(token) {
147
+ if (this.socket?.connected || this.isConnecting) {
148
+ return;
149
+ }
150
+ this.token = token;
151
+ this.isConnecting = true;
152
+ this.socket = socket_ioClient.io(this.config.baseUrl, {
153
+ auth: { token },
154
+ autoConnect: true,
155
+ reconnection: this.config.reconnection,
156
+ reconnectionAttempts: this.config.reconnectionAttempts,
157
+ reconnectionDelay: this.config.reconnectionDelay,
158
+ transports: ["websocket", "polling"]
159
+ });
160
+ this.setupEventListeners();
161
+ }
162
+ setupEventListeners() {
163
+ if (!this.socket) return;
164
+ this.socket.on("connect", () => {
165
+ this.isConnecting = false;
166
+ console.log("[Auth SDK] Socket connected");
167
+ this.emit("connected", {});
168
+ });
169
+ this.socket.on("disconnect", (reason) => {
170
+ console.log("[Auth SDK] Socket disconnected:", reason);
171
+ this.emit("disconnected", { reason });
172
+ });
173
+ this.socket.on("connect_error", (error) => {
174
+ this.isConnecting = false;
175
+ console.error("[Auth SDK] Socket connection error:", error.message);
176
+ this.emit("error", { error: error.message });
177
+ });
178
+ this.socket.on("user:updated", (data) => {
179
+ this.emit("user:updated", data);
180
+ });
181
+ this.socket.on("session:revoked", (data) => {
182
+ this.emit("session:revoked", data);
183
+ });
184
+ this.socket.on("session:all-revoked", () => {
185
+ this.emit("session:all-revoked", {});
186
+ });
187
+ this.socket.on("auth:password-changed", () => {
188
+ this.emit("auth:password-changed", {});
189
+ });
190
+ this.socket.on("auth:2fa-changed", (data) => {
191
+ this.emit("auth:2fa-changed", data);
192
+ });
193
+ this.socket.on("user:refresh", () => {
194
+ this.emit("user:refresh", {});
195
+ });
196
+ }
197
+ disconnect() {
198
+ if (this.socket) {
199
+ this.socket.disconnect();
200
+ this.socket = null;
201
+ this.token = null;
202
+ this.isConnecting = false;
203
+ }
204
+ }
205
+ isConnected() {
206
+ return this.socket?.connected ?? false;
207
+ }
208
+ // Event subscription
209
+ on(event, handler) {
210
+ if (!this.eventHandlers.has(event)) {
211
+ this.eventHandlers.set(event, /* @__PURE__ */ new Set());
212
+ }
213
+ this.eventHandlers.get(event).add(handler);
214
+ return () => {
215
+ this.eventHandlers.get(event)?.delete(handler);
216
+ };
217
+ }
218
+ off(event, handler) {
219
+ if (handler) {
220
+ this.eventHandlers.get(event)?.delete(handler);
221
+ } else {
222
+ this.eventHandlers.delete(event);
223
+ }
224
+ }
225
+ emit(event, data) {
226
+ const handlers = this.eventHandlers.get(event);
227
+ if (handlers) {
228
+ handlers.forEach((handler) => {
229
+ try {
230
+ handler(data);
231
+ } catch (error) {
232
+ console.error(`[Auth SDK] Error in event handler for ${event}:`, error);
233
+ }
234
+ });
235
+ }
236
+ }
237
+ // Request fresh user data from server
238
+ requestUserRefresh() {
239
+ if (this.socket?.connected) {
240
+ this.socket.emit("request:user");
241
+ }
242
+ }
243
+ };
131
244
  var AuthService = class {
245
+ // 5 minutes cache
132
246
  constructor(config) {
133
247
  this.token = null;
134
248
  this.upfilesClient = null;
249
+ this.cachedUser = null;
250
+ this.userCacheTimestamp = 0;
251
+ this.USER_CACHE_TTL = 5 * 60 * 1e3;
135
252
  this.config = {
136
253
  localStorageKey: "auth_token",
137
254
  csrfEnabled: true,
255
+ enableSocket: true,
138
256
  ...config
139
257
  };
140
258
  this.httpClient = new HttpClient(this.config.baseUrl);
259
+ this.socketService = new SocketService({ baseUrl: this.config.baseUrl });
141
260
  this.loadTokenFromStorage();
142
261
  if (this.config.upfilesConfig) {
143
262
  this.upfilesClient = new upfiles.UpfilesClient({
@@ -154,6 +273,9 @@ var AuthService = class {
154
273
  this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
155
274
  }
156
275
  }
276
+ if (this.token && this.config.enableSocket !== false) {
277
+ this.connectSocket();
278
+ }
157
279
  }
158
280
  loadTokenFromStorage() {
159
281
  if (typeof window !== "undefined" && this.config.localStorageKey) {
@@ -186,6 +308,57 @@ var AuthService = class {
186
308
  }
187
309
  }
188
310
  }
311
+ // Socket connection management
312
+ connectSocket() {
313
+ if (this.token && this.config.enableSocket !== false && typeof window !== "undefined") {
314
+ this.socketService.connect(this.token);
315
+ }
316
+ }
317
+ disconnectSocket() {
318
+ this.socketService.disconnect();
319
+ }
320
+ // Socket event subscription
321
+ onUserUpdated(handler) {
322
+ return this.socketService.on("user:updated", (data) => {
323
+ if (data.user) {
324
+ this.cachedUser = data.user;
325
+ this.userCacheTimestamp = Date.now();
326
+ }
327
+ handler(data);
328
+ });
329
+ }
330
+ onSessionRevoked(handler) {
331
+ return this.socketService.on("session:revoked", handler);
332
+ }
333
+ onAllSessionsRevoked(handler) {
334
+ return this.socketService.on("session:all-revoked", handler);
335
+ }
336
+ onPasswordChanged(handler) {
337
+ return this.socketService.on("auth:password-changed", handler);
338
+ }
339
+ on2FAChanged(handler) {
340
+ return this.socketService.on("auth:2fa-changed", handler);
341
+ }
342
+ onSocketConnected(handler) {
343
+ return this.socketService.on("connected", handler);
344
+ }
345
+ onSocketDisconnected(handler) {
346
+ return this.socketService.on("disconnected", handler);
347
+ }
348
+ onSocketError(handler) {
349
+ return this.socketService.on("error", handler);
350
+ }
351
+ isSocketConnected() {
352
+ return this.socketService.isConnected();
353
+ }
354
+ // Cache management
355
+ clearUserCache() {
356
+ this.cachedUser = null;
357
+ this.userCacheTimestamp = 0;
358
+ }
359
+ isCacheValid() {
360
+ return this.cachedUser !== null && Date.now() - this.userCacheTimestamp < this.USER_CACHE_TTL;
361
+ }
189
362
  isAuthenticated() {
190
363
  return !!this.token;
191
364
  }
@@ -251,6 +424,11 @@ var AuthService = class {
251
424
  this.token = response.token;
252
425
  this.httpClient.setAuthToken(response.token);
253
426
  this.saveTokenToStorage(response.token);
427
+ if (response.user) {
428
+ this.cachedUser = response.user;
429
+ this.userCacheTimestamp = Date.now();
430
+ }
431
+ this.connectSocket();
254
432
  return response;
255
433
  }
256
434
  if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
@@ -260,6 +438,11 @@ var AuthService = class {
260
438
  this.token = response.token;
261
439
  this.httpClient.setAuthToken(response.token);
262
440
  this.saveTokenToStorage(response.token);
441
+ if (response.user) {
442
+ this.cachedUser = response.user;
443
+ this.userCacheTimestamp = Date.now();
444
+ }
445
+ this.connectSocket();
263
446
  return response;
264
447
  }
265
448
  throw new Error(response.message || "Login failed");
@@ -303,21 +486,29 @@ var AuthService = class {
303
486
  }
304
487
  }
305
488
  async logout() {
489
+ this.disconnectSocket();
306
490
  try {
307
491
  await this.httpClient.post("/api/v1/auth/logout", {});
308
492
  } catch (error) {
309
493
  console.warn("Failed to call logout endpoint:", error);
310
494
  }
311
495
  this.token = null;
496
+ this.cachedUser = null;
497
+ this.userCacheTimestamp = 0;
312
498
  this.httpClient.removeAuthToken();
313
499
  this.httpClient.removeCsrfToken();
314
500
  this.removeTokenFromStorage();
315
501
  }
316
- async getProfile() {
502
+ async getProfile(forceRefresh = false) {
317
503
  if (!this.token) {
318
504
  throw new Error("Not authenticated");
319
505
  }
506
+ if (!forceRefresh && this.isCacheValid() && this.cachedUser) {
507
+ return this.cachedUser;
508
+ }
320
509
  const response = await this.httpClient.get("/api/v1/user/me");
510
+ this.cachedUser = response.user;
511
+ this.userCacheTimestamp = Date.now();
321
512
  return response.user;
322
513
  }
323
514
  async updateProfile(data) {
@@ -481,6 +672,16 @@ var AuthService = class {
481
672
  );
482
673
  return response;
483
674
  }
675
+ async adminCreateUser(data) {
676
+ if (!this.token) {
677
+ throw new Error("Not authenticated");
678
+ }
679
+ const response = await this.httpClient.post(
680
+ "/api/v1/admin/create-user",
681
+ data
682
+ );
683
+ return response;
684
+ }
484
685
  async adminVerifyUser(userId) {
485
686
  if (!this.token) {
486
687
  throw new Error("Not authenticated");
@@ -716,21 +917,49 @@ var AuthProvider = ({ children, config }) => {
716
917
  const [user, setUser] = React.useState(null);
717
918
  const [isLoaded, setIsLoaded] = React.useState(false);
718
919
  const [loading, setLoading] = React.useState(false);
719
- const checkAuthStatus = React.useCallback(async () => {
920
+ const [isSocketConnected, setIsSocketConnected] = React.useState(false);
921
+ React.useEffect(() => {
922
+ const unsubUserUpdated = authService.onUserUpdated(({ user: updatedUser }) => {
923
+ if (updatedUser) {
924
+ setUser(updatedUser);
925
+ }
926
+ });
927
+ const unsubSessionRevoked = authService.onSessionRevoked(() => {
928
+ authService.logout().then(() => {
929
+ setUser(null);
930
+ });
931
+ });
932
+ const unsubAllSessionsRevoked = authService.onAllSessionsRevoked(() => {
933
+ authService.logout().then(() => {
934
+ setUser(null);
935
+ });
936
+ });
937
+ const unsubPasswordChanged = authService.onPasswordChanged(() => {
938
+ authService.logout().then(() => {
939
+ setUser(null);
940
+ });
941
+ });
942
+ const unsubConnected = authService.onSocketConnected(() => {
943
+ setIsSocketConnected(true);
944
+ });
945
+ const unsubDisconnected = authService.onSocketDisconnected(() => {
946
+ setIsSocketConnected(false);
947
+ });
948
+ return () => {
949
+ unsubUserUpdated();
950
+ unsubSessionRevoked();
951
+ unsubAllSessionsRevoked();
952
+ unsubPasswordChanged();
953
+ unsubConnected();
954
+ unsubDisconnected();
955
+ };
956
+ }, [authService]);
957
+ React.useEffect(() => {
720
958
  const authenticated = authService.isAuthenticated();
721
959
  if (authenticated) {
722
- try {
723
- const freshUser = await authService.getProfile();
724
- setUser(freshUser);
725
- } catch (error) {
726
- console.error("Failed to fetch fresh user profile, falling back to token:", error);
727
- try {
728
- const currentUser = authService.getCurrentUser();
729
- setUser(currentUser);
730
- } catch (fallbackError) {
731
- console.error("Failed to get current user from token:", fallbackError);
732
- setUser(null);
733
- }
960
+ const currentUser = authService.getCurrentUser();
961
+ if (currentUser) {
962
+ setUser(currentUser);
734
963
  }
735
964
  } else {
736
965
  setUser(null);
@@ -738,8 +967,21 @@ var AuthProvider = ({ children, config }) => {
738
967
  setIsLoaded(true);
739
968
  }, [authService]);
740
969
  React.useEffect(() => {
741
- checkAuthStatus();
742
- }, [checkAuthStatus]);
970
+ if (!isLoaded) return;
971
+ const authenticated = authService.isAuthenticated();
972
+ if (!authenticated) return;
973
+ const fetchFreshUser = async () => {
974
+ try {
975
+ const freshUser = await authService.getProfile();
976
+ setUser(freshUser);
977
+ } catch (error) {
978
+ console.warn("[Auth SDK] Failed to fetch fresh user profile:", error);
979
+ }
980
+ };
981
+ if (isSocketConnected) {
982
+ fetchFreshUser();
983
+ }
984
+ }, [authService, isLoaded, isSocketConnected]);
743
985
  const signIn = React.useCallback(async (data) => {
744
986
  setLoading(true);
745
987
  try {
@@ -961,6 +1203,7 @@ var AuthProvider = ({ children, config }) => {
961
1203
  isLoaded,
962
1204
  isSignedIn: !!user,
963
1205
  loading,
1206
+ isSocketConnected,
964
1207
  signIn,
965
1208
  signUp,
966
1209
  signOut,
@@ -4469,11 +4712,11 @@ var ChangePassword = ({ onSuccess, appearance }) => {
4469
4712
 
4470
4713
  // src/react/components/utils/injectModalStyles.ts
4471
4714
  var injectModalStyles = () => {
4472
- if (document.getElementById("ttf-auth-modal-styles")) {
4715
+ if (document.getElementById("ktw-auth-modal-styles")) {
4473
4716
  return;
4474
4717
  }
4475
4718
  const styleElement = document.createElement("style");
4476
- styleElement.id = "ttf-auth-modal-styles";
4719
+ styleElement.id = "ktw-auth-modal-styles";
4477
4720
  styleElement.textContent = `
4478
4721
  /* ImageManager Modal Styles - Critical for proper modal display */
4479
4722
  /* Radix UI Dialog styles - Force visibility */