@thetechfossil/auth2 1.2.2 → 1.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.
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { NextRequest, NextResponse } from 'next/server';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  interface LinkedAccount {
5
5
  provider: 'google' | 'github';
@@ -11,6 +11,8 @@ interface User {
11
11
  _id: string;
12
12
  name: string;
13
13
  email: string;
14
+ phoneNumber?: string;
15
+ avatar?: string;
14
16
  role: string;
15
17
  linkedAccounts?: LinkedAccount[];
16
18
  createdAt: string;
@@ -24,21 +26,28 @@ interface AuthResponse {
24
26
  csrfToken?: string;
25
27
  }
26
28
  interface LoginData {
27
- email: string;
29
+ email?: string;
30
+ phoneNumber?: string;
28
31
  password?: string;
29
32
  otp?: string;
30
33
  }
31
34
  interface VerifyData {
32
- email: string;
35
+ email?: string;
36
+ phoneNumber?: string;
33
37
  otp: string;
34
38
  }
35
39
  interface RegisterData {
36
40
  name: string;
37
- email: string;
41
+ email?: string;
42
+ phoneNumber?: string;
38
43
  password: string;
39
44
  }
40
45
  interface UpdateUserData {
41
- name: string;
46
+ name?: string;
47
+ avatar?: string;
48
+ email?: string;
49
+ username?: string;
50
+ phoneNumber?: string;
42
51
  }
43
52
  type OAuthProvider = 'google' | 'github';
44
53
  interface OAuthConfig {
@@ -57,11 +66,13 @@ interface AuthConfig {
57
66
  }
58
67
  interface Session {
59
68
  id: string;
60
- userId: string;
61
- deviceInfo?: string;
69
+ userId?: string;
70
+ token?: string;
71
+ userAgent?: string;
62
72
  ipAddress?: string;
63
- lastActive: string;
73
+ expiresAt: string;
64
74
  createdAt: string;
75
+ updatedAt?: string;
65
76
  }
66
77
  interface MFASetup {
67
78
  success: boolean;
@@ -171,6 +182,7 @@ declare class HttpClient {
171
182
  private axiosInstance;
172
183
  private csrfToken;
173
184
  private frontendBaseUrl;
185
+ private baseUrl;
174
186
  constructor(baseUrl: string, defaultHeaders?: Record<string, string>);
175
187
  get<T>(endpoint: string, headers?: Record<string, string>): Promise<T>;
176
188
  post<T>(endpoint: string, data?: any, headers?: Record<string, string>): Promise<T>;
@@ -240,6 +252,16 @@ interface AuthProviderProps {
240
252
  declare const AuthProvider: React.FC<AuthProviderProps>;
241
253
  declare const useAuth: () => AuthContextValue;
242
254
 
255
+ type Theme = 'light' | 'dark';
256
+ interface ThemeContextType {
257
+ theme: Theme;
258
+ mounted: boolean;
259
+ }
260
+ declare function AuthThemeProvider({ children }: {
261
+ children: ReactNode;
262
+ }): react_jsx_runtime.JSX.Element;
263
+ declare function useAuthTheme(): ThemeContextType;
264
+
243
265
  interface LoginFormProps {
244
266
  onSuccess?: (response: {
245
267
  message: string;
@@ -266,6 +288,7 @@ interface RegisterFormProps {
266
288
  authConfig?: AuthConfig;
267
289
  oauthProviders?: Array<'google' | 'github'>;
268
290
  showOAuthButtons?: boolean;
291
+ invitationToken?: string | null;
269
292
  }
270
293
  declare const RegisterForm: React.FC<RegisterFormProps>;
271
294
 
@@ -273,6 +296,7 @@ interface OtpFormProps {
273
296
  email: string;
274
297
  onVerifySuccess?: () => void;
275
298
  onBackToLogin?: () => void;
299
+ baseUrl?: string;
276
300
  }
277
301
  declare const OtpForm: React.FC<OtpFormProps>;
278
302
 
@@ -402,6 +426,17 @@ interface UserProfileProps {
402
426
  }
403
427
  declare const UserProfile: React.FC<UserProfileProps>;
404
428
 
429
+ interface PhoneInputProps {
430
+ value: string;
431
+ onChange: (value: string) => void;
432
+ disabled?: boolean;
433
+ required?: boolean;
434
+ placeholder?: string;
435
+ id?: string;
436
+ style?: React.CSSProperties;
437
+ }
438
+ declare const PhoneInput: React.FC<PhoneInputProps>;
439
+
405
440
  interface UseNextAuthReturn {
406
441
  user: User | null;
407
442
  isAuthenticated: boolean;
@@ -422,60 +457,4 @@ interface UseNextAuthReturn {
422
457
  }
423
458
  declare const useNextAuth: (config: AuthConfig) => UseNextAuthReturn;
424
459
 
425
- declare class AuthClient extends AuthService {
426
- constructor(config: AuthConfig);
427
- register(data: RegisterData): Promise<AuthResponse>;
428
- login(data: LoginData): Promise<AuthResponse>;
429
- verify(data: VerifyData): Promise<AuthResponse>;
430
- logout(): Promise<void>;
431
- getProfile(): Promise<User>;
432
- getUserById(id: string): Promise<User>;
433
- updateProfile(data: UpdateUserData): Promise<AuthResponse>;
434
- getAllUsers(): Promise<User[]>;
435
- }
436
-
437
- declare class NextServerAuth extends AuthClient {
438
- constructor(config: AuthConfig);
439
- static parseTokenFromHeaders(headers: Headers): string | null;
440
- static parseTokenFromCookies(cookies: string): string | null;
441
- static parseTokenFromRequest(req: any): string | null;
442
- verifyToken(token: string): Promise<User | null>;
443
- static createAuthenticatedClient(config: AuthConfig, token: string): NextServerAuth;
444
- }
445
-
446
- interface AuthServerConfig {
447
- authApiUrl?: string;
448
- tokenCookieName?: string;
449
- }
450
- declare class AuthServer {
451
- private config;
452
- constructor(config?: AuthServerConfig);
453
- getToken(): Promise<string | null>;
454
- getCurrentUser(): Promise<User | null>;
455
- isAuthenticated(): Promise<boolean>;
456
- requireAuth(redirectTo?: string): Promise<User>;
457
- redirectIfAuthenticated(redirectTo?: string): Promise<void>;
458
- getProfile(): Promise<User | null>;
459
- }
460
- declare function getAuthServer(config?: AuthServerConfig): AuthServer;
461
- declare function currentUser(): Promise<User | null>;
462
- declare function auth(): Promise<{
463
- user: User | null;
464
- userId: string | null;
465
- isAuthenticated: boolean;
466
- token: string | null;
467
- }>;
468
- declare function requireAuth(redirectTo?: string): Promise<User>;
469
- declare function redirectIfAuthenticated(redirectTo?: string): Promise<void>;
470
-
471
- interface AuthMiddlewareConfig {
472
- publicRoutes?: string[];
473
- protectedRoutes?: string[];
474
- loginUrl?: string;
475
- afterLoginUrl?: string;
476
- tokenCookieName?: string;
477
- }
478
- declare function authMiddleware(config?: AuthMiddlewareConfig): (request: NextRequest) => NextResponse<unknown>;
479
- declare function createAuthMiddleware(config?: AuthMiddlewareConfig): (request: NextRequest) => NextResponse<unknown>;
480
-
481
- export { AuditLog, AuthConfig, AuthFlow, AuthProvider, AuthResponse, AuthServer, AuthService, ChangePassword, CsrfTokenResponse, EmailVerificationPage, ForgotPassword, HttpClient, LinkedAccount, LoginData, LoginForm, MFASetup, NextServerAuth, OAuthConfig, OAuthProvider, OtpForm, ProtectedRoute, PublicRoute, RegisterData, RegisterForm, ResetPassword, Session, SignIn, SignOut, SignUp, UpdateUserData, UseAuthReturn, User, UserButton, UserProfile, VerifyData, VerifyEmail, auth, authMiddleware, createAuthMiddleware, currentUser, getAuthServer, redirectIfAuthenticated, requireAuth, useAuth, useAuth$1 as useAuthLegacy, useNextAuth };
460
+ export { AuditLog, AuthConfig, AuthFlow, AuthProvider, AuthResponse, AuthService, AuthThemeProvider, ChangePassword, CsrfTokenResponse, EmailVerificationPage, ForgotPassword, HttpClient, LinkedAccount, LoginData, LoginForm, MFASetup, OAuthConfig, OAuthProvider, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterData, RegisterForm, RegisterFormProps, ResetPassword, Session, SignIn, SignOut, SignUp, UpdateUserData, UseAuthReturn, User, UserButton, UserProfile, VerifyData, VerifyEmail, useAuth, useAuth$1 as useAuthLegacy, useAuthTheme, useNextAuth };