@thetechfossil/auth2 1.2.1 → 1.2.3
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/README.NEW.md +365 -0
- package/dist/index.components.d.ts +112 -2
- package/dist/index.components.js +1996 -20
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +1987 -22
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.ts +252 -13
- package/dist/index.js +2393 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2377 -134
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.ts +219 -25
- package/dist/index.next.js +2362 -262
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +2350 -262
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.ts +107 -2
- package/dist/index.next.server.js +329 -20
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +322 -21
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.ts +70 -2
- package/dist/index.node.js +184 -18
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +184 -18
- package/dist/index.node.mjs.map +1 -1
- package/next/index.js +2 -0
- package/next/index.mjs +2 -0
- package/next/package.json +5 -0
- package/next/server/package.json +5 -0
- package/next/server.js +2 -0
- package/next/server.mjs +2 -0
- package/package.json +34 -10
package/dist/index.next.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
interface LinkedAccount {
|
|
4
4
|
provider: 'google' | 'github';
|
|
@@ -35,7 +35,6 @@ interface RegisterData {
|
|
|
35
35
|
name: string;
|
|
36
36
|
email: string;
|
|
37
37
|
password: string;
|
|
38
|
-
frontendBaseUrl?: string;
|
|
39
38
|
}
|
|
40
39
|
interface UpdateUserData {
|
|
41
40
|
name: string;
|
|
@@ -55,6 +54,30 @@ interface AuthConfig {
|
|
|
55
54
|
token?: string;
|
|
56
55
|
csrfEnabled?: boolean;
|
|
57
56
|
}
|
|
57
|
+
interface Session {
|
|
58
|
+
id: string;
|
|
59
|
+
userId?: string;
|
|
60
|
+
token?: string;
|
|
61
|
+
userAgent?: string;
|
|
62
|
+
ipAddress?: string;
|
|
63
|
+
expiresAt: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt?: string;
|
|
66
|
+
}
|
|
67
|
+
interface MFASetup {
|
|
68
|
+
success: boolean;
|
|
69
|
+
qrCode?: string;
|
|
70
|
+
secret?: string;
|
|
71
|
+
message: string;
|
|
72
|
+
}
|
|
73
|
+
interface AuditLog {
|
|
74
|
+
id: string;
|
|
75
|
+
userId: string;
|
|
76
|
+
action: string;
|
|
77
|
+
details?: any;
|
|
78
|
+
ipAddress?: string;
|
|
79
|
+
timestamp: string;
|
|
80
|
+
}
|
|
58
81
|
interface UseAuthReturn {
|
|
59
82
|
user: User | null;
|
|
60
83
|
isAuthenticated: boolean;
|
|
@@ -73,6 +96,20 @@ interface UseAuthReturn {
|
|
|
73
96
|
unlinkOAuthProvider: (provider: OAuthProvider) => Promise<AuthResponse>;
|
|
74
97
|
csrfToken: string | null;
|
|
75
98
|
refreshCsrfToken: () => Promise<void>;
|
|
99
|
+
changePassword: (oldPassword: string, newPassword: string) => Promise<AuthResponse>;
|
|
100
|
+
updateAvatar: (avatar: string) => Promise<AuthResponse>;
|
|
101
|
+
requestEmailChange: (newEmail: string) => Promise<AuthResponse>;
|
|
102
|
+
verifyEmailChange: (token: string) => Promise<AuthResponse>;
|
|
103
|
+
generate2FA: () => Promise<MFASetup>;
|
|
104
|
+
enable2FA: (token: string) => Promise<AuthResponse>;
|
|
105
|
+
disable2FA: (token: string) => Promise<AuthResponse>;
|
|
106
|
+
validate2FA: (token: string) => Promise<AuthResponse>;
|
|
107
|
+
getSessions: () => Promise<{
|
|
108
|
+
success: boolean;
|
|
109
|
+
sessions: Session[];
|
|
110
|
+
}>;
|
|
111
|
+
revokeSession: (sessionId: string) => Promise<AuthResponse>;
|
|
112
|
+
revokeAllSessions: () => Promise<AuthResponse>;
|
|
76
113
|
}
|
|
77
114
|
|
|
78
115
|
declare class AuthService {
|
|
@@ -102,11 +139,39 @@ declare class AuthService {
|
|
|
102
139
|
getUserById(id: string): Promise<User>;
|
|
103
140
|
forgotPassword(email: string): Promise<AuthResponse>;
|
|
104
141
|
resetPassword(token: string, password: string): Promise<AuthResponse>;
|
|
142
|
+
changePassword(oldPassword: string, newPassword: string): Promise<AuthResponse>;
|
|
143
|
+
updateAvatar(avatar: string): Promise<AuthResponse>;
|
|
144
|
+
requestEmailChange(newEmail: string): Promise<AuthResponse>;
|
|
145
|
+
verifyEmailChange(token: string): Promise<AuthResponse>;
|
|
146
|
+
generate2FA(): Promise<{
|
|
147
|
+
success: boolean;
|
|
148
|
+
qrCode?: string;
|
|
149
|
+
secret?: string;
|
|
150
|
+
message: string;
|
|
151
|
+
}>;
|
|
152
|
+
enable2FA(token: string): Promise<AuthResponse>;
|
|
153
|
+
disable2FA(token: string): Promise<AuthResponse>;
|
|
154
|
+
validate2FA(token: string): Promise<AuthResponse>;
|
|
155
|
+
getSessions(): Promise<{
|
|
156
|
+
success: boolean;
|
|
157
|
+
sessions: any[];
|
|
158
|
+
}>;
|
|
159
|
+
revokeSession(sessionId: string): Promise<AuthResponse>;
|
|
160
|
+
revokeAllSessions(): Promise<AuthResponse>;
|
|
161
|
+
getAuditLogs(filters?: any): Promise<{
|
|
162
|
+
success: boolean;
|
|
163
|
+
logs: any[];
|
|
164
|
+
}>;
|
|
165
|
+
adminVerifyUser(userId: string): Promise<AuthResponse>;
|
|
166
|
+
adminForcePasswordReset(userId: string): Promise<AuthResponse>;
|
|
167
|
+
adminSuspendUser(userId: string): Promise<AuthResponse>;
|
|
168
|
+
adminActivateUser(userId: string): Promise<AuthResponse>;
|
|
105
169
|
}
|
|
106
170
|
|
|
107
171
|
declare class HttpClient {
|
|
108
172
|
private axiosInstance;
|
|
109
173
|
private csrfToken;
|
|
174
|
+
private frontendBaseUrl;
|
|
110
175
|
constructor(baseUrl: string, defaultHeaders?: Record<string, string>);
|
|
111
176
|
get<T>(endpoint: string, headers?: Record<string, string>): Promise<T>;
|
|
112
177
|
post<T>(endpoint: string, data?: any, headers?: Record<string, string>): Promise<T>;
|
|
@@ -117,6 +182,9 @@ declare class HttpClient {
|
|
|
117
182
|
setCsrfToken(token: string): void;
|
|
118
183
|
getCsrfToken(): string | null;
|
|
119
184
|
removeCsrfToken(): void;
|
|
185
|
+
setFrontendBaseUrl(url: string): void;
|
|
186
|
+
getFrontendBaseUrl(): string | null;
|
|
187
|
+
removeFrontendBaseUrl(): void;
|
|
120
188
|
private refreshCsrfToken;
|
|
121
189
|
}
|
|
122
190
|
|
|
@@ -134,7 +202,44 @@ interface UseAuthReturnBase {
|
|
|
134
202
|
getAllUsers: () => Promise<User[]>;
|
|
135
203
|
getUserById: (id: string) => Promise<User>;
|
|
136
204
|
}
|
|
137
|
-
declare const useAuth: (config: AuthConfig) => UseAuthReturnBase;
|
|
205
|
+
declare const useAuth$1: (config: AuthConfig) => UseAuthReturnBase;
|
|
206
|
+
|
|
207
|
+
interface AuthContextValue {
|
|
208
|
+
user: User | null;
|
|
209
|
+
isLoaded: boolean;
|
|
210
|
+
isSignedIn: boolean;
|
|
211
|
+
loading: boolean;
|
|
212
|
+
signIn: (data: LoginData) => Promise<AuthResponse>;
|
|
213
|
+
signUp: (data: RegisterData) => Promise<AuthResponse>;
|
|
214
|
+
signOut: () => Promise<void>;
|
|
215
|
+
verify: (data: VerifyData) => Promise<AuthResponse>;
|
|
216
|
+
verifyEmailToken: (token: string) => Promise<AuthResponse>;
|
|
217
|
+
updateProfile: (data: UpdateUserData) => Promise<AuthResponse>;
|
|
218
|
+
getProfile: () => Promise<User>;
|
|
219
|
+
signInWithOAuth: (provider: OAuthProvider) => void;
|
|
220
|
+
linkOAuthProvider: (provider: OAuthProvider) => void;
|
|
221
|
+
unlinkOAuthProvider: (provider: OAuthProvider) => Promise<AuthResponse>;
|
|
222
|
+
forgotPassword: (email: string) => Promise<AuthResponse>;
|
|
223
|
+
resetPassword: (token: string, password: string) => Promise<AuthResponse>;
|
|
224
|
+
changePassword: (oldPassword: string, newPassword: string) => Promise<AuthResponse>;
|
|
225
|
+
updateAvatar: (avatar: string) => Promise<AuthResponse>;
|
|
226
|
+
requestEmailChange: (newEmail: string) => Promise<AuthResponse>;
|
|
227
|
+
verifyEmailChange: (token: string) => Promise<AuthResponse>;
|
|
228
|
+
generate2FA: () => Promise<any>;
|
|
229
|
+
enable2FA: (token: string) => Promise<AuthResponse>;
|
|
230
|
+
disable2FA: (token: string) => Promise<AuthResponse>;
|
|
231
|
+
validate2FA: (token: string) => Promise<AuthResponse>;
|
|
232
|
+
getSessions: () => Promise<any>;
|
|
233
|
+
revokeSession: (sessionId: string) => Promise<AuthResponse>;
|
|
234
|
+
revokeAllSessions: () => Promise<AuthResponse>;
|
|
235
|
+
authService: AuthService;
|
|
236
|
+
}
|
|
237
|
+
interface AuthProviderProps {
|
|
238
|
+
children: ReactNode;
|
|
239
|
+
config?: Partial<AuthConfig>;
|
|
240
|
+
}
|
|
241
|
+
declare const AuthProvider: React.FC<AuthProviderProps>;
|
|
242
|
+
declare const useAuth: () => AuthContextValue;
|
|
138
243
|
|
|
139
244
|
interface LoginFormProps {
|
|
140
245
|
onSuccess?: (response: {
|
|
@@ -188,6 +293,116 @@ interface EmailVerificationPageProps {
|
|
|
188
293
|
}
|
|
189
294
|
declare const EmailVerificationPage: React.FC<EmailVerificationPageProps>;
|
|
190
295
|
|
|
296
|
+
interface SignInProps {
|
|
297
|
+
redirectUrl?: string;
|
|
298
|
+
appearance?: {
|
|
299
|
+
elements?: {
|
|
300
|
+
formButtonPrimary?: React.CSSProperties;
|
|
301
|
+
card?: React.CSSProperties;
|
|
302
|
+
headerTitle?: React.CSSProperties;
|
|
303
|
+
formFieldInput?: React.CSSProperties;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
routing?: 'path' | 'virtual';
|
|
307
|
+
path?: string;
|
|
308
|
+
}
|
|
309
|
+
declare const SignIn: React.FC<SignInProps>;
|
|
310
|
+
|
|
311
|
+
interface SignUpProps {
|
|
312
|
+
redirectUrl?: string;
|
|
313
|
+
appearance?: {
|
|
314
|
+
elements?: {
|
|
315
|
+
formButtonPrimary?: React.CSSProperties;
|
|
316
|
+
card?: React.CSSProperties;
|
|
317
|
+
headerTitle?: React.CSSProperties;
|
|
318
|
+
formFieldInput?: React.CSSProperties;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
declare const SignUp: React.FC<SignUpProps>;
|
|
323
|
+
|
|
324
|
+
interface SignOutProps {
|
|
325
|
+
redirectUrl?: string;
|
|
326
|
+
}
|
|
327
|
+
declare const SignOut: React.FC<SignOutProps>;
|
|
328
|
+
|
|
329
|
+
interface UserButtonProps {
|
|
330
|
+
showName?: boolean;
|
|
331
|
+
appearance?: {
|
|
332
|
+
elements?: {
|
|
333
|
+
userButtonBox?: React.CSSProperties;
|
|
334
|
+
userButtonTrigger?: React.CSSProperties;
|
|
335
|
+
userButtonPopoverCard?: React.CSSProperties;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
declare const UserButton: React.FC<UserButtonProps>;
|
|
340
|
+
|
|
341
|
+
interface ProtectedRouteProps {
|
|
342
|
+
children: ReactNode;
|
|
343
|
+
fallback?: ReactNode;
|
|
344
|
+
redirectTo?: string;
|
|
345
|
+
}
|
|
346
|
+
declare const ProtectedRoute: React.FC<ProtectedRouteProps>;
|
|
347
|
+
|
|
348
|
+
interface PublicRouteProps {
|
|
349
|
+
children: ReactNode;
|
|
350
|
+
redirectTo?: string;
|
|
351
|
+
}
|
|
352
|
+
declare const PublicRoute: React.FC<PublicRouteProps>;
|
|
353
|
+
|
|
354
|
+
interface VerifyEmailProps {
|
|
355
|
+
token?: string;
|
|
356
|
+
onSuccess?: () => void;
|
|
357
|
+
onError?: (error: string) => void;
|
|
358
|
+
}
|
|
359
|
+
declare const VerifyEmail: React.FC<VerifyEmailProps>;
|
|
360
|
+
|
|
361
|
+
interface ForgotPasswordProps {
|
|
362
|
+
appearance?: {
|
|
363
|
+
elements?: {
|
|
364
|
+
formButtonPrimary?: React.CSSProperties;
|
|
365
|
+
card?: React.CSSProperties;
|
|
366
|
+
headerTitle?: React.CSSProperties;
|
|
367
|
+
formFieldInput?: React.CSSProperties;
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
declare const ForgotPassword: React.FC<ForgotPasswordProps>;
|
|
372
|
+
|
|
373
|
+
interface ResetPasswordProps {
|
|
374
|
+
token?: string;
|
|
375
|
+
appearance?: {
|
|
376
|
+
elements?: {
|
|
377
|
+
formButtonPrimary?: React.CSSProperties;
|
|
378
|
+
card?: React.CSSProperties;
|
|
379
|
+
headerTitle?: React.CSSProperties;
|
|
380
|
+
formFieldInput?: React.CSSProperties;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
declare const ResetPassword: React.FC<ResetPasswordProps>;
|
|
385
|
+
|
|
386
|
+
interface ChangePasswordProps {
|
|
387
|
+
onSuccess?: () => void;
|
|
388
|
+
appearance?: {
|
|
389
|
+
elements?: {
|
|
390
|
+
formButtonPrimary?: React.CSSProperties;
|
|
391
|
+
card?: React.CSSProperties;
|
|
392
|
+
headerTitle?: React.CSSProperties;
|
|
393
|
+
formFieldInput?: React.CSSProperties;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
declare const ChangePassword: React.FC<ChangePasswordProps>;
|
|
398
|
+
|
|
399
|
+
interface UserProfileProps {
|
|
400
|
+
showAvatar?: boolean;
|
|
401
|
+
showEmailChange?: boolean;
|
|
402
|
+
showPasswordChange?: boolean;
|
|
403
|
+
}
|
|
404
|
+
declare const UserProfile: React.FC<UserProfileProps>;
|
|
405
|
+
|
|
191
406
|
interface UseNextAuthReturn {
|
|
192
407
|
user: User | null;
|
|
193
408
|
isAuthenticated: boolean;
|
|
@@ -208,25 +423,4 @@ interface UseNextAuthReturn {
|
|
|
208
423
|
}
|
|
209
424
|
declare const useNextAuth: (config: AuthConfig) => UseNextAuthReturn;
|
|
210
425
|
|
|
211
|
-
|
|
212
|
-
constructor(config: AuthConfig);
|
|
213
|
-
register(data: RegisterData): Promise<AuthResponse>;
|
|
214
|
-
login(data: LoginData): Promise<AuthResponse>;
|
|
215
|
-
verify(data: VerifyData): Promise<AuthResponse>;
|
|
216
|
-
logout(): Promise<void>;
|
|
217
|
-
getProfile(): Promise<User>;
|
|
218
|
-
getUserById(id: string): Promise<User>;
|
|
219
|
-
updateProfile(data: UpdateUserData): Promise<AuthResponse>;
|
|
220
|
-
getAllUsers(): Promise<User[]>;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
declare class NextServerAuth extends AuthClient {
|
|
224
|
-
constructor(config: AuthConfig);
|
|
225
|
-
static parseTokenFromHeaders(headers: Headers): string | null;
|
|
226
|
-
static parseTokenFromCookies(cookies: string): string | null;
|
|
227
|
-
static parseTokenFromRequest(req: any): string | null;
|
|
228
|
-
verifyToken(token: string): Promise<User | null>;
|
|
229
|
-
static createAuthenticatedClient(config: AuthConfig, token: string): NextServerAuth;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export { AuthConfig, AuthFlow, AuthResponse, AuthService, CsrfTokenResponse, EmailVerificationPage, HttpClient, LinkedAccount, LoginData, LoginForm, NextServerAuth, OAuthConfig, OAuthProvider, OtpForm, RegisterData, RegisterForm, UpdateUserData, UseAuthReturn, User, VerifyData, useAuth, useNextAuth };
|
|
426
|
+
export { AuditLog, AuthConfig, AuthFlow, AuthProvider, AuthResponse, AuthService, ChangePassword, CsrfTokenResponse, EmailVerificationPage, ForgotPassword, HttpClient, LinkedAccount, LoginData, LoginForm, MFASetup, OAuthConfig, OAuthProvider, OtpForm, ProtectedRoute, PublicRoute, RegisterData, RegisterForm, ResetPassword, Session, SignIn, SignOut, SignUp, UpdateUserData, UseAuthReturn, User, UserButton, UserProfile, VerifyData, VerifyEmail, useAuth, useAuth$1 as useAuthLegacy, useNextAuth };
|