@thetechfossil/auth2 1.2.19 → 1.2.21

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 +275 -11
  5. package/dist/index.components.js.map +1 -1
  6. package/dist/index.components.mjs +275 -11
  7. package/dist/index.components.mjs.map +1 -1
  8. package/dist/index.d.mts +111 -3
  9. package/dist/index.d.ts +111 -3
  10. package/dist/index.js +470 -30
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +471 -32
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/index.next.d.mts +54 -1
  15. package/dist/index.next.d.ts +54 -1
  16. package/dist/index.next.js +332 -26
  17. package/dist/index.next.js.map +1 -1
  18. package/dist/index.next.mjs +332 -26
  19. package/dist/index.next.mjs.map +1 -1
  20. package/dist/index.next.server.d.mts +81 -2
  21. package/dist/index.next.server.d.ts +81 -2
  22. package/dist/index.next.server.js +406 -9
  23. package/dist/index.next.server.js.map +1 -1
  24. package/dist/index.next.server.mjs +403 -10
  25. package/dist/index.next.server.mjs.map +1 -1
  26. package/dist/index.node.d.mts +81 -2
  27. package/dist/index.node.d.ts +81 -2
  28. package/dist/index.node.js +406 -9
  29. package/dist/index.node.js.map +1 -1
  30. package/dist/index.node.mjs +403 -10
  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
@@ -0,0 +1,227 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { TextInputProps, ViewStyle, TextStyle } from 'react-native';
3
+
4
+ interface LinkedAccount {
5
+ provider: 'google' | 'github';
6
+ providerId: string;
7
+ email: string;
8
+ avatar?: string;
9
+ }
10
+ interface User {
11
+ id: string;
12
+ _id?: string;
13
+ name: string;
14
+ email: string;
15
+ phoneNumber?: string;
16
+ avatar?: string;
17
+ role: string;
18
+ emailVerified?: boolean;
19
+ twoFactorEnabled?: boolean;
20
+ linkedAccounts?: LinkedAccount[];
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ }
24
+ interface AuthResponse {
25
+ success: boolean;
26
+ message: string;
27
+ user?: User;
28
+ token?: string;
29
+ csrfToken?: string;
30
+ }
31
+ interface LoginData {
32
+ email?: string;
33
+ phoneNumber?: string;
34
+ password?: string;
35
+ otp?: string;
36
+ }
37
+ interface VerifyData {
38
+ email?: string;
39
+ phoneNumber?: string;
40
+ otp: string;
41
+ }
42
+ interface RegisterData {
43
+ name: string;
44
+ email?: string;
45
+ phoneNumber?: string;
46
+ password: string;
47
+ }
48
+ interface UpdateUserData {
49
+ name?: string;
50
+ avatar?: string;
51
+ email?: string;
52
+ username?: string;
53
+ phoneNumber?: string;
54
+ }
55
+ interface AuthConfig {
56
+ baseUrl: string;
57
+ localStorageKey?: string;
58
+ token?: string;
59
+ csrfEnabled?: boolean;
60
+ enableSocket?: boolean;
61
+ upfilesConfig?: UpfilesConfig;
62
+ }
63
+ interface UpfilesConfig {
64
+ baseUrl: string;
65
+ apiKey?: string;
66
+ apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
67
+ presignUrl?: string;
68
+ presignPath?: string;
69
+ folderPath?: string;
70
+ }
71
+
72
+ declare class AuthServiceRN {
73
+ private client;
74
+ private token;
75
+ private config;
76
+ constructor(config: AuthConfig);
77
+ setToken(token: string | null): void;
78
+ getToken(): string | null;
79
+ isAuthenticated(): boolean;
80
+ getCurrentUser(): User | null;
81
+ login(data: LoginData): Promise<AuthResponse>;
82
+ register(data: RegisterData): Promise<AuthResponse>;
83
+ verify(data: VerifyData): Promise<AuthResponse>;
84
+ logout(): Promise<void>;
85
+ getProfile(): Promise<User>;
86
+ updateProfile(data: UpdateUserData): Promise<AuthResponse>;
87
+ forgotPassword(email: string): Promise<AuthResponse>;
88
+ resetPassword(token: string, password: string): Promise<AuthResponse>;
89
+ changePassword(oldPassword: string, newPassword: string): Promise<AuthResponse>;
90
+ }
91
+
92
+ interface AuthContextValue {
93
+ user: User | null;
94
+ isLoaded: boolean;
95
+ isSignedIn: boolean;
96
+ loading: boolean;
97
+ token: string | null;
98
+ signIn: (data: LoginData) => Promise<AuthResponse>;
99
+ signUp: (data: RegisterData) => Promise<AuthResponse>;
100
+ signOut: () => Promise<void>;
101
+ verify: (data: VerifyData) => Promise<AuthResponse>;
102
+ updateProfile: (data: UpdateUserData) => Promise<AuthResponse>;
103
+ getProfile: () => Promise<User>;
104
+ forgotPassword: (email: string) => Promise<AuthResponse>;
105
+ resetPassword: (token: string, password: string) => Promise<AuthResponse>;
106
+ changePassword: (oldPassword: string, newPassword: string) => Promise<AuthResponse>;
107
+ authService: AuthServiceRN;
108
+ }
109
+ interface AuthProviderProps {
110
+ children: ReactNode;
111
+ config?: Partial<AuthConfig>;
112
+ }
113
+ declare const AuthProvider: React.FC<AuthProviderProps>;
114
+ declare const useAuth: () => AuthContextValue;
115
+
116
+ interface LoginFormTheme {
117
+ backgroundColor?: string;
118
+ textColor?: string;
119
+ secondaryTextColor?: string;
120
+ mutedTextColor?: string;
121
+ accentColor?: string;
122
+ inputBackgroundColor?: string;
123
+ inputBorderColor?: string;
124
+ borderColor?: string;
125
+ }
126
+ interface LoginFormProps {
127
+ onSuccess?: (response: any) => void;
128
+ onOtpRequired?: (email: string) => void;
129
+ onRegisterPress?: () => void;
130
+ onForgotPasswordPress?: () => void;
131
+ showRegisterLink?: boolean;
132
+ showForgotPassword?: boolean;
133
+ usePasswordLogin?: boolean;
134
+ theme?: LoginFormTheme;
135
+ }
136
+ declare const LoginForm: React.FC<LoginFormProps>;
137
+
138
+ interface RegisterFormProps {
139
+ onSuccess?: (response: any) => void;
140
+ onOtpRequired?: (email: string) => void;
141
+ onLoginPress?: () => void;
142
+ showLoginLink?: boolean;
143
+ }
144
+ declare const RegisterForm: React.FC<RegisterFormProps>;
145
+
146
+ interface OtpFormTheme {
147
+ backgroundColor?: string;
148
+ textColor?: string;
149
+ secondaryTextColor?: string;
150
+ accentColor?: string;
151
+ inputBackgroundColor?: string;
152
+ inputBorderColor?: string;
153
+ inputFilledBackgroundColor?: string;
154
+ }
155
+ interface OtpFormProps {
156
+ email: string;
157
+ onSuccess?: (response: any) => void;
158
+ onResendOtp?: () => void;
159
+ onBackPress?: () => void;
160
+ otpLength?: number;
161
+ theme?: OtpFormTheme;
162
+ }
163
+ declare const OtpForm: React.FC<OtpFormProps>;
164
+
165
+ interface ForgotPasswordProps {
166
+ onSuccess?: (email: string) => void;
167
+ onBackPress?: () => void;
168
+ }
169
+ declare const ForgotPassword: React.FC<ForgotPasswordProps>;
170
+
171
+ interface ResetPasswordProps {
172
+ token: string;
173
+ onSuccess?: () => void;
174
+ onBackPress?: () => void;
175
+ }
176
+ declare const ResetPassword: React.FC<ResetPasswordProps>;
177
+
178
+ interface UserProfileProps {
179
+ onEditPress?: () => void;
180
+ onLogoutPress?: () => void;
181
+ showLogoutButton?: boolean;
182
+ }
183
+ declare const UserProfile: React.FC<UserProfileProps>;
184
+
185
+ interface ProtectedRouteProps {
186
+ children: ReactNode;
187
+ fallback?: ReactNode;
188
+ loadingComponent?: ReactNode;
189
+ }
190
+ declare const ProtectedRoute: React.FC<ProtectedRouteProps>;
191
+
192
+ interface InputTheme {
193
+ backgroundColor?: string;
194
+ borderColor?: string;
195
+ textColor?: string;
196
+ labelColor?: string;
197
+ placeholderColor?: string;
198
+ accentColor?: string;
199
+ }
200
+ interface InputProps extends TextInputProps {
201
+ label?: string;
202
+ error?: string;
203
+ containerStyle?: ViewStyle;
204
+ isPassword?: boolean;
205
+ theme?: InputTheme;
206
+ }
207
+ declare const Input: React.FC<InputProps>;
208
+
209
+ interface ButtonTheme {
210
+ primaryColor?: string;
211
+ primaryTextColor?: string;
212
+ secondaryColor?: string;
213
+ secondaryTextColor?: string;
214
+ }
215
+ interface ButtonProps {
216
+ title: string;
217
+ onPress: () => void;
218
+ loading?: boolean;
219
+ disabled?: boolean;
220
+ variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
221
+ style?: ViewStyle;
222
+ textStyle?: TextStyle;
223
+ theme?: ButtonTheme;
224
+ }
225
+ declare const Button: React.FC<ButtonProps>;
226
+
227
+ export { type AuthConfig, AuthProvider, type AuthResponse, AuthServiceRN, Button, ForgotPassword, Input, type LoginData, LoginForm, OtpForm, ProtectedRoute, type RegisterData, RegisterForm, ResetPassword, type User, UserProfile, useAuth };