@mesob/auth-react 0.0.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.
Files changed (46) hide show
  1. package/dist/components/auth-card.d.ts +9 -0
  2. package/dist/components/auth-card.js +11 -0
  3. package/dist/components/auth-card.js.map +1 -0
  4. package/dist/components/auth-page-layout.d.ts +14 -0
  5. package/dist/components/auth-page-layout.js +28 -0
  6. package/dist/components/auth-page-layout.js.map +1 -0
  7. package/dist/components/countdown.d.ts +10 -0
  8. package/dist/components/countdown.js +57 -0
  9. package/dist/components/countdown.js.map +1 -0
  10. package/dist/components/forgot-password.d.ts +13 -0
  11. package/dist/components/forgot-password.js +67 -0
  12. package/dist/components/forgot-password.js.map +1 -0
  13. package/dist/components/pages/forgot-password-page.d.ts +17 -0
  14. package/dist/components/pages/forgot-password-page.js +224 -0
  15. package/dist/components/pages/forgot-password-page.js.map +1 -0
  16. package/dist/components/pages/reset-password-page.d.ts +19 -0
  17. package/dist/components/pages/reset-password-page.js +357 -0
  18. package/dist/components/pages/reset-password-page.js.map +1 -0
  19. package/dist/components/pages/sign-in-page.d.ts +19 -0
  20. package/dist/components/pages/sign-in-page.js +343 -0
  21. package/dist/components/pages/sign-in-page.js.map +1 -0
  22. package/dist/components/pages/sign-up-page.d.ts +18 -0
  23. package/dist/components/pages/sign-up-page.js +360 -0
  24. package/dist/components/pages/sign-up-page.js.map +1 -0
  25. package/dist/components/pages/verify-email-page.d.ts +19 -0
  26. package/dist/components/pages/verify-email-page.js +356 -0
  27. package/dist/components/pages/verify-email-page.js.map +1 -0
  28. package/dist/components/pages/verify-phone-page.d.ts +20 -0
  29. package/dist/components/pages/verify-phone-page.js +368 -0
  30. package/dist/components/pages/verify-phone-page.js.map +1 -0
  31. package/dist/components/reset-password-form.d.ts +16 -0
  32. package/dist/components/reset-password-form.js +142 -0
  33. package/dist/components/reset-password-form.js.map +1 -0
  34. package/dist/components/sign-in.d.ts +16 -0
  35. package/dist/components/sign-in.js +128 -0
  36. package/dist/components/sign-in.js.map +1 -0
  37. package/dist/components/sign-up.d.ts +17 -0
  38. package/dist/components/sign-up.js +179 -0
  39. package/dist/components/sign-up.js.map +1 -0
  40. package/dist/components/verification-form.d.ts +15 -0
  41. package/dist/components/verification-form.js +155 -0
  42. package/dist/components/verification-form.js.map +1 -0
  43. package/dist/index.d.ts +222 -0
  44. package/dist/index.js +1640 -0
  45. package/dist/index.js.map +1 -0
  46. package/package.json +48 -0
@@ -0,0 +1,222 @@
1
+ export { AuthCard } from './components/auth-card.js';
2
+ export { AuthPageLayout } from './components/auth-page-layout.js';
3
+ export { Countdown } from './components/countdown.js';
4
+ export { ForgotPassword } from './components/forgot-password.js';
5
+ export { ForgotPasswordPage } from './components/pages/forgot-password-page.js';
6
+ export { ResetPasswordPage } from './components/pages/reset-password-page.js';
7
+ export { SignInPage } from './components/pages/sign-in-page.js';
8
+ export { SignUpPage } from './components/pages/sign-up-page.js';
9
+ export { VerifyEmailPage } from './components/pages/verify-email-page.js';
10
+ export { VerifyPhonePage } from './components/pages/verify-phone-page.js';
11
+ export { ResetPasswordForm } from './components/reset-password-form.js';
12
+ export { SignIn } from './components/sign-in.js';
13
+ export { SignUp } from './components/sign-up.js';
14
+ export { VerificationForm } from './components/verification-form.js';
15
+ import * as react_jsx_runtime from 'react/jsx-runtime';
16
+ import { ReactNode } from 'react';
17
+
18
+ type User = {
19
+ id: string;
20
+ tenantId: string;
21
+ fullName: string;
22
+ email: string | null;
23
+ phone: string | null;
24
+ handle: string;
25
+ image: string | null;
26
+ emailVerified: boolean;
27
+ phoneVerified: boolean;
28
+ lastSignInAt: string | null;
29
+ };
30
+ type Session = {
31
+ id: string;
32
+ expiresAt: string;
33
+ createdAt?: string;
34
+ userAgent: string | null;
35
+ ip: string | null;
36
+ };
37
+ type AuthResponse = {
38
+ user: User;
39
+ session: Session;
40
+ sessionToken: string;
41
+ sessionExpiresAt: string;
42
+ };
43
+ type VerificationResponse = {
44
+ verificationId: string;
45
+ requiresVerification?: boolean;
46
+ };
47
+ type SessionResponse = {
48
+ user: User | null;
49
+ session: Session | null;
50
+ };
51
+ type AuthErrorCode = 'USER_NOT_FOUND' | 'INVALID_PASSWORD' | 'USER_EXISTS' | 'VERIFICATION_EXPIRED' | 'VERIFICATION_MISMATCH' | 'VERIFICATION_NOT_FOUND' | 'TOO_MANY_ATTEMPTS' | 'REQUIRES_VERIFICATION' | 'UNAUTHORIZED' | 'ACCESS_DENIED' | 'HAS_NO_PASSWORD';
52
+
53
+ type AuthClientConfig = {
54
+ baseURL: string;
55
+ };
56
+ declare class AuthClient {
57
+ private baseURL;
58
+ constructor(config: AuthClientConfig);
59
+ private request;
60
+ signUpWithEmail(data: {
61
+ email: string;
62
+ password: string;
63
+ fullName: string;
64
+ handle?: string;
65
+ }): Promise<AuthResponse | VerificationResponse>;
66
+ signUpWithPhone(data: {
67
+ phone: string;
68
+ password: string;
69
+ fullName: string;
70
+ handle?: string;
71
+ }): Promise<AuthResponse | VerificationResponse>;
72
+ checkUser(data: {
73
+ identifier: string;
74
+ }): Promise<{
75
+ exists: boolean;
76
+ }>;
77
+ signInWithPassword(data: {
78
+ identifier: string;
79
+ password: string;
80
+ }): Promise<AuthResponse | VerificationResponse>;
81
+ signOut(): Promise<{
82
+ message: string;
83
+ }>;
84
+ requestEmailVerification(data?: {
85
+ email?: string;
86
+ }): Promise<{
87
+ verificationId: string;
88
+ }>;
89
+ verifyEmail(data: {
90
+ verificationId: string;
91
+ code: string;
92
+ }): Promise<AuthResponse>;
93
+ resendVerification(_verificationId: string): Promise<{
94
+ verificationId: string;
95
+ }>;
96
+ requestPhoneOtp(data: {
97
+ phone: string;
98
+ context: 'sign-up' | 'sign-in' | 'change-phone';
99
+ }): Promise<{
100
+ verificationId: string;
101
+ }>;
102
+ verifyPhoneOtp(data: {
103
+ verificationId: string;
104
+ code: string;
105
+ context: 'sign-up' | 'sign-in' | 'change-phone';
106
+ }): Promise<AuthResponse | {
107
+ user: User | null;
108
+ session: null;
109
+ verified: boolean;
110
+ }>;
111
+ forgotPassword(data: {
112
+ identifier: string;
113
+ }): Promise<{
114
+ message: string;
115
+ }>;
116
+ resetPassword(data: {
117
+ verificationId: string;
118
+ code: string;
119
+ password: string;
120
+ }): Promise<AuthResponse>;
121
+ changePassword(data: {
122
+ currentPassword: string;
123
+ newPassword: string;
124
+ }): Promise<{
125
+ message: string;
126
+ }>;
127
+ getSession(): Promise<SessionResponse>;
128
+ }
129
+
130
+ type AuthContextValue = {
131
+ user: User | null;
132
+ session: Session | null;
133
+ loading: boolean;
134
+ error: Error | null;
135
+ client: AuthClient;
136
+ refresh: () => Promise<void>;
137
+ setAuth: (data: AuthResponse) => void;
138
+ };
139
+ declare const useAuth: () => AuthContextValue;
140
+ type AuthProviderProps = {
141
+ client: AuthClient;
142
+ children: ReactNode;
143
+ };
144
+ declare const AuthProvider: ({ client, children }: AuthProviderProps) => react_jsx_runtime.JSX.Element;
145
+
146
+ declare const createAuthClient: (config: AuthClientConfig) => {
147
+ signUpWithEmail: (data: {
148
+ email: string;
149
+ password: string;
150
+ fullName: string;
151
+ handle?: string;
152
+ }) => Promise<AuthResponse | VerificationResponse>;
153
+ signUpWithPhone: (data: {
154
+ phone: string;
155
+ password: string;
156
+ fullName: string;
157
+ handle?: string;
158
+ }) => Promise<AuthResponse | VerificationResponse>;
159
+ signInWithPassword: (data: {
160
+ identifier: string;
161
+ password: string;
162
+ }) => Promise<AuthResponse | VerificationResponse>;
163
+ signOut: () => Promise<{
164
+ message: string;
165
+ }>;
166
+ requestEmailVerification: (data?: {
167
+ email?: string;
168
+ }) => Promise<{
169
+ verificationId: string;
170
+ }>;
171
+ verifyEmail: (data: {
172
+ verificationId: string;
173
+ code: string;
174
+ }) => Promise<AuthResponse>;
175
+ resendVerification: (_verificationId: string) => Promise<{
176
+ verificationId: string;
177
+ }>;
178
+ requestPhoneOtp: (data: {
179
+ phone: string;
180
+ context: "sign-up" | "sign-in" | "change-phone";
181
+ }) => Promise<{
182
+ verificationId: string;
183
+ }>;
184
+ verifyPhoneOtp: (data: {
185
+ verificationId: string;
186
+ code: string;
187
+ context: "sign-up" | "sign-in" | "change-phone";
188
+ }) => Promise<AuthResponse | {
189
+ user: User | null;
190
+ session: null;
191
+ verified: boolean;
192
+ }>;
193
+ forgotPassword: (data: {
194
+ identifier: string;
195
+ }) => Promise<{
196
+ message: string;
197
+ }>;
198
+ resetPassword: (data: {
199
+ verificationId: string;
200
+ code: string;
201
+ password: string;
202
+ }) => Promise<AuthResponse>;
203
+ changePassword: (data: {
204
+ currentPassword: string;
205
+ newPassword: string;
206
+ }) => Promise<{
207
+ message: string;
208
+ }>;
209
+ getSession: () => Promise<SessionResponse>;
210
+ useSession: () => never;
211
+ };
212
+
213
+ declare const useSession: () => {
214
+ user: User | null;
215
+ session: Session | null;
216
+ isLoading: boolean;
217
+ isAuthenticated: boolean;
218
+ error: Error | null;
219
+ refresh: () => Promise<void>;
220
+ };
221
+
222
+ export { AuthClient, type AuthErrorCode, AuthProvider, type AuthResponse, type Session, type SessionResponse, type User, type VerificationResponse, createAuthClient, useAuth, useSession };