@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.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,24 +182,48 @@ 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
|
|
|
123
|
-
interface
|
|
191
|
+
interface AuthContextValue {
|
|
124
192
|
user: User | null;
|
|
125
|
-
|
|
193
|
+
isLoaded: boolean;
|
|
194
|
+
isSignedIn: boolean;
|
|
126
195
|
loading: boolean;
|
|
127
|
-
|
|
128
|
-
|
|
196
|
+
signIn: (data: LoginData) => Promise<AuthResponse>;
|
|
197
|
+
signUp: (data: RegisterData) => Promise<AuthResponse>;
|
|
198
|
+
signOut: () => Promise<void>;
|
|
129
199
|
verify: (data: VerifyData) => Promise<AuthResponse>;
|
|
130
200
|
verifyEmailToken: (token: string) => Promise<AuthResponse>;
|
|
131
|
-
logout: () => Promise<void>;
|
|
132
201
|
updateProfile: (data: UpdateUserData) => Promise<AuthResponse>;
|
|
133
202
|
getProfile: () => Promise<User>;
|
|
134
|
-
|
|
135
|
-
|
|
203
|
+
signInWithOAuth: (provider: OAuthProvider) => void;
|
|
204
|
+
linkOAuthProvider: (provider: OAuthProvider) => void;
|
|
205
|
+
unlinkOAuthProvider: (provider: OAuthProvider) => Promise<AuthResponse>;
|
|
206
|
+
forgotPassword: (email: string) => Promise<AuthResponse>;
|
|
207
|
+
resetPassword: (token: string, password: string) => Promise<AuthResponse>;
|
|
208
|
+
changePassword: (oldPassword: string, newPassword: string) => Promise<AuthResponse>;
|
|
209
|
+
updateAvatar: (avatar: string) => Promise<AuthResponse>;
|
|
210
|
+
requestEmailChange: (newEmail: string) => Promise<AuthResponse>;
|
|
211
|
+
verifyEmailChange: (token: string) => Promise<AuthResponse>;
|
|
212
|
+
generate2FA: () => Promise<any>;
|
|
213
|
+
enable2FA: (token: string) => Promise<AuthResponse>;
|
|
214
|
+
disable2FA: (token: string) => Promise<AuthResponse>;
|
|
215
|
+
validate2FA: (token: string) => Promise<AuthResponse>;
|
|
216
|
+
getSessions: () => Promise<any>;
|
|
217
|
+
revokeSession: (sessionId: string) => Promise<AuthResponse>;
|
|
218
|
+
revokeAllSessions: () => Promise<AuthResponse>;
|
|
219
|
+
authService: AuthService;
|
|
136
220
|
}
|
|
137
|
-
|
|
221
|
+
interface AuthProviderProps {
|
|
222
|
+
children: ReactNode;
|
|
223
|
+
config?: Partial<AuthConfig>;
|
|
224
|
+
}
|
|
225
|
+
declare const AuthProvider: React.FC<AuthProviderProps>;
|
|
226
|
+
declare const useAuth$1: () => AuthContextValue;
|
|
138
227
|
|
|
139
228
|
interface LoginFormProps {
|
|
140
229
|
onSuccess?: (response: {
|
|
@@ -188,20 +277,170 @@ interface EmailVerificationPageProps {
|
|
|
188
277
|
}
|
|
189
278
|
declare const EmailVerificationPage: React.FC<EmailVerificationPageProps>;
|
|
190
279
|
|
|
280
|
+
interface SignInProps {
|
|
281
|
+
redirectUrl?: string;
|
|
282
|
+
appearance?: {
|
|
283
|
+
elements?: {
|
|
284
|
+
formButtonPrimary?: React.CSSProperties;
|
|
285
|
+
card?: React.CSSProperties;
|
|
286
|
+
headerTitle?: React.CSSProperties;
|
|
287
|
+
formFieldInput?: React.CSSProperties;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
routing?: 'path' | 'virtual';
|
|
291
|
+
path?: string;
|
|
292
|
+
}
|
|
293
|
+
declare const SignIn: React.FC<SignInProps>;
|
|
294
|
+
|
|
295
|
+
interface SignUpProps {
|
|
296
|
+
redirectUrl?: string;
|
|
297
|
+
appearance?: {
|
|
298
|
+
elements?: {
|
|
299
|
+
formButtonPrimary?: React.CSSProperties;
|
|
300
|
+
card?: React.CSSProperties;
|
|
301
|
+
headerTitle?: React.CSSProperties;
|
|
302
|
+
formFieldInput?: React.CSSProperties;
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
declare const SignUp: React.FC<SignUpProps>;
|
|
307
|
+
|
|
308
|
+
interface SignOutProps {
|
|
309
|
+
redirectUrl?: string;
|
|
310
|
+
}
|
|
311
|
+
declare const SignOut: React.FC<SignOutProps>;
|
|
312
|
+
|
|
313
|
+
interface UserButtonProps {
|
|
314
|
+
showName?: boolean;
|
|
315
|
+
appearance?: {
|
|
316
|
+
elements?: {
|
|
317
|
+
userButtonBox?: React.CSSProperties;
|
|
318
|
+
userButtonTrigger?: React.CSSProperties;
|
|
319
|
+
userButtonPopoverCard?: React.CSSProperties;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
declare const UserButton: React.FC<UserButtonProps>;
|
|
324
|
+
|
|
325
|
+
interface ProtectedRouteProps {
|
|
326
|
+
children: ReactNode;
|
|
327
|
+
fallback?: ReactNode;
|
|
328
|
+
redirectTo?: string;
|
|
329
|
+
}
|
|
330
|
+
declare const ProtectedRoute: React.FC<ProtectedRouteProps>;
|
|
331
|
+
|
|
332
|
+
interface PublicRouteProps {
|
|
333
|
+
children: ReactNode;
|
|
334
|
+
redirectTo?: string;
|
|
335
|
+
}
|
|
336
|
+
declare const PublicRoute: React.FC<PublicRouteProps>;
|
|
337
|
+
|
|
338
|
+
interface VerifyEmailProps {
|
|
339
|
+
token?: string;
|
|
340
|
+
onSuccess?: () => void;
|
|
341
|
+
onError?: (error: string) => void;
|
|
342
|
+
}
|
|
343
|
+
declare const VerifyEmail: React.FC<VerifyEmailProps>;
|
|
344
|
+
|
|
345
|
+
interface ForgotPasswordProps {
|
|
346
|
+
appearance?: {
|
|
347
|
+
elements?: {
|
|
348
|
+
formButtonPrimary?: React.CSSProperties;
|
|
349
|
+
card?: React.CSSProperties;
|
|
350
|
+
headerTitle?: React.CSSProperties;
|
|
351
|
+
formFieldInput?: React.CSSProperties;
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
declare const ForgotPassword: React.FC<ForgotPasswordProps>;
|
|
356
|
+
|
|
357
|
+
interface ResetPasswordProps {
|
|
358
|
+
token?: string;
|
|
359
|
+
appearance?: {
|
|
360
|
+
elements?: {
|
|
361
|
+
formButtonPrimary?: React.CSSProperties;
|
|
362
|
+
card?: React.CSSProperties;
|
|
363
|
+
headerTitle?: React.CSSProperties;
|
|
364
|
+
formFieldInput?: React.CSSProperties;
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
declare const ResetPassword: React.FC<ResetPasswordProps>;
|
|
369
|
+
|
|
370
|
+
interface ChangePasswordProps {
|
|
371
|
+
onSuccess?: () => void;
|
|
372
|
+
appearance?: {
|
|
373
|
+
elements?: {
|
|
374
|
+
formButtonPrimary?: React.CSSProperties;
|
|
375
|
+
card?: React.CSSProperties;
|
|
376
|
+
headerTitle?: React.CSSProperties;
|
|
377
|
+
formFieldInput?: React.CSSProperties;
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
declare const ChangePassword: React.FC<ChangePasswordProps>;
|
|
382
|
+
|
|
383
|
+
interface UserProfileProps {
|
|
384
|
+
showAvatar?: boolean;
|
|
385
|
+
showEmailChange?: boolean;
|
|
386
|
+
showPasswordChange?: boolean;
|
|
387
|
+
}
|
|
388
|
+
declare const UserProfile: React.FC<UserProfileProps>;
|
|
389
|
+
|
|
390
|
+
interface UseAuthReturnBase {
|
|
391
|
+
user: User | null;
|
|
392
|
+
isAuthenticated: boolean;
|
|
393
|
+
loading: boolean;
|
|
394
|
+
register: (data: RegisterData) => Promise<AuthResponse>;
|
|
395
|
+
login: (data: LoginData) => Promise<AuthResponse>;
|
|
396
|
+
verify: (data: VerifyData) => Promise<AuthResponse>;
|
|
397
|
+
verifyEmailToken: (token: string) => Promise<AuthResponse>;
|
|
398
|
+
logout: () => Promise<void>;
|
|
399
|
+
updateProfile: (data: UpdateUserData) => Promise<AuthResponse>;
|
|
400
|
+
getProfile: () => Promise<User>;
|
|
401
|
+
getAllUsers: () => Promise<User[]>;
|
|
402
|
+
getUserById: (id: string) => Promise<User>;
|
|
403
|
+
}
|
|
404
|
+
declare const useAuth: (config: AuthConfig) => UseAuthReturnBase;
|
|
405
|
+
|
|
191
406
|
declare const index$1_AuthFlow: typeof AuthFlow;
|
|
407
|
+
declare const index$1_AuthProvider: typeof AuthProvider;
|
|
408
|
+
declare const index$1_ChangePassword: typeof ChangePassword;
|
|
192
409
|
declare const index$1_EmailVerificationPage: typeof EmailVerificationPage;
|
|
410
|
+
declare const index$1_ForgotPassword: typeof ForgotPassword;
|
|
193
411
|
declare const index$1_LoginForm: typeof LoginForm;
|
|
194
412
|
declare const index$1_OtpForm: typeof OtpForm;
|
|
413
|
+
declare const index$1_ProtectedRoute: typeof ProtectedRoute;
|
|
414
|
+
declare const index$1_PublicRoute: typeof PublicRoute;
|
|
195
415
|
declare const index$1_RegisterForm: typeof RegisterForm;
|
|
196
|
-
declare const index$
|
|
416
|
+
declare const index$1_ResetPassword: typeof ResetPassword;
|
|
417
|
+
declare const index$1_SignIn: typeof SignIn;
|
|
418
|
+
declare const index$1_SignOut: typeof SignOut;
|
|
419
|
+
declare const index$1_SignUp: typeof SignUp;
|
|
420
|
+
declare const index$1_UserButton: typeof UserButton;
|
|
421
|
+
declare const index$1_UserProfile: typeof UserProfile;
|
|
422
|
+
declare const index$1_VerifyEmail: typeof VerifyEmail;
|
|
197
423
|
declare namespace index$1 {
|
|
198
424
|
export {
|
|
199
425
|
index$1_AuthFlow as AuthFlow,
|
|
426
|
+
index$1_AuthProvider as AuthProvider,
|
|
427
|
+
index$1_ChangePassword as ChangePassword,
|
|
200
428
|
index$1_EmailVerificationPage as EmailVerificationPage,
|
|
429
|
+
index$1_ForgotPassword as ForgotPassword,
|
|
201
430
|
index$1_LoginForm as LoginForm,
|
|
202
431
|
index$1_OtpForm as OtpForm,
|
|
432
|
+
index$1_ProtectedRoute as ProtectedRoute,
|
|
433
|
+
index$1_PublicRoute as PublicRoute,
|
|
203
434
|
index$1_RegisterForm as RegisterForm,
|
|
204
|
-
index$
|
|
435
|
+
index$1_ResetPassword as ResetPassword,
|
|
436
|
+
index$1_SignIn as SignIn,
|
|
437
|
+
index$1_SignOut as SignOut,
|
|
438
|
+
index$1_SignUp as SignUp,
|
|
439
|
+
index$1_UserButton as UserButton,
|
|
440
|
+
index$1_UserProfile as UserProfile,
|
|
441
|
+
index$1_VerifyEmail as VerifyEmail,
|
|
442
|
+
useAuth$1 as useAuth,
|
|
443
|
+
useAuth as useAuthLegacy,
|
|
205
444
|
};
|
|
206
445
|
}
|
|
207
446
|
|
|
@@ -225,4 +464,4 @@ declare namespace index {
|
|
|
225
464
|
};
|
|
226
465
|
}
|
|
227
466
|
|
|
228
|
-
export { AuthConfig, AuthResponse, AuthService, CsrfTokenResponse, HttpClient, LinkedAccount, LoginData, OAuthConfig, OAuthProvider, RegisterData, UpdateUserData, UseAuthReturn, User, VerifyData, index as node, index$1 as react };
|
|
467
|
+
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, index as node, index$1 as react, useAuth$1 as useAuth };
|