@mesob/auth-react 0.0.7 → 0.1.0

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 (75) hide show
  1. package/dist/components/auth/auth-page-layout.d.ts +1 -3
  2. package/dist/components/auth/auth-page-layout.js +1 -17
  3. package/dist/components/auth/auth-page-layout.js.map +1 -1
  4. package/dist/components/auth/countdown.js +70 -9
  5. package/dist/components/auth/countdown.js.map +1 -1
  6. package/dist/components/auth/forgot-password.js +101 -35
  7. package/dist/components/auth/forgot-password.js.map +1 -1
  8. package/dist/components/auth/pages/forgot-password-page.d.ts +2 -13
  9. package/dist/components/auth/pages/forgot-password-page.js +198 -126
  10. package/dist/components/auth/pages/forgot-password-page.js.map +1 -1
  11. package/dist/components/auth/pages/reset-password-page.d.ts +1 -12
  12. package/dist/components/auth/pages/reset-password-page.js +288 -200
  13. package/dist/components/auth/pages/reset-password-page.js.map +1 -1
  14. package/dist/components/auth/pages/sign-in-page.d.ts +1 -12
  15. package/dist/components/auth/pages/sign-in-page.js +352 -230
  16. package/dist/components/auth/pages/sign-in-page.js.map +1 -1
  17. package/dist/components/auth/pages/sign-up-page.d.ts +1 -11
  18. package/dist/components/auth/pages/sign-up-page.js +310 -216
  19. package/dist/components/auth/pages/sign-up-page.js.map +1 -1
  20. package/dist/components/auth/pages/verify-email-page.d.ts +2 -12
  21. package/dist/components/auth/pages/verify-email-page.js +203 -135
  22. package/dist/components/auth/pages/verify-email-page.js.map +1 -1
  23. package/dist/components/auth/pages/verify-phone-page.d.ts +1 -11
  24. package/dist/components/auth/pages/verify-phone-page.js +206 -137
  25. package/dist/components/auth/pages/verify-phone-page.js.map +1 -1
  26. package/dist/components/auth/reset-password-form.d.ts +1 -1
  27. package/dist/components/auth/reset-password-form.js +188 -106
  28. package/dist/components/auth/reset-password-form.js.map +1 -1
  29. package/dist/components/auth/sign-in.d.ts +3 -3
  30. package/dist/components/auth/sign-in.js +228 -109
  31. package/dist/components/auth/sign-in.js.map +1 -1
  32. package/dist/components/auth/sign-up.js +210 -122
  33. package/dist/components/auth/sign-up.js.map +1 -1
  34. package/dist/components/auth/verification-form.d.ts +1 -1
  35. package/dist/components/auth/verification-form.js +101 -53
  36. package/dist/components/auth/verification-form.js.map +1 -1
  37. package/dist/components/error-boundary.d.ts +27 -0
  38. package/dist/components/error-boundary.js +49 -0
  39. package/dist/components/error-boundary.js.map +1 -0
  40. package/dist/components/iam/permissions/permissions-page.d.ts +5 -0
  41. package/dist/components/iam/permissions/permissions-page.js +201 -0
  42. package/dist/components/iam/permissions/permissions-page.js.map +1 -0
  43. package/dist/components/iam/roles/roles-page.d.ts +5 -0
  44. package/dist/components/iam/roles/roles-page.js +199 -0
  45. package/dist/components/iam/roles/roles-page.js.map +1 -0
  46. package/dist/components/iam/sessions/sessions-page.d.ts +5 -0
  47. package/dist/components/iam/sessions/sessions-page.js +202 -0
  48. package/dist/components/iam/sessions/sessions-page.js.map +1 -0
  49. package/dist/components/iam/tenants/tenants-page.d.ts +5 -0
  50. package/dist/components/iam/tenants/tenants-page.js +202 -0
  51. package/dist/components/iam/tenants/tenants-page.js.map +1 -0
  52. package/dist/components/iam/users/users-page.d.ts +5 -0
  53. package/dist/components/iam/users/users-page.js +211 -0
  54. package/dist/components/iam/users/users-page.js.map +1 -0
  55. package/dist/components/profile/profile-page.d.ts +8 -0
  56. package/dist/components/profile/profile-page.js +163 -0
  57. package/dist/components/profile/profile-page.js.map +1 -0
  58. package/dist/components/shared/data-table/data-table.d.ts +22 -0
  59. package/dist/components/shared/data-table/data-table.js +85 -0
  60. package/dist/components/shared/data-table/data-table.js.map +1 -0
  61. package/dist/components/skeletons/auth-form-skeleton.d.ts +5 -0
  62. package/dist/components/skeletons/auth-form-skeleton.js +32 -0
  63. package/dist/components/skeletons/auth-form-skeleton.js.map +1 -0
  64. package/dist/components/skeletons/profile-skeleton.d.ts +5 -0
  65. package/dist/components/skeletons/profile-skeleton.js +33 -0
  66. package/dist/components/skeletons/profile-skeleton.js.map +1 -0
  67. package/dist/components/skeletons/table-skeleton.d.ts +9 -0
  68. package/dist/components/skeletons/table-skeleton.js +39 -0
  69. package/dist/components/skeletons/table-skeleton.js.map +1 -0
  70. package/dist/handle-error-BqDMxnQZ.d.ts +8 -0
  71. package/dist/index.d.ts +75 -208
  72. package/dist/index.js +2091 -1057
  73. package/dist/index.js.map +1 -1
  74. package/package.json +9 -3
  75. package/dist/handle-error-H0iqQxJ5.d.ts +0 -6
package/dist/index.d.ts CHANGED
@@ -1,21 +1,64 @@
1
1
  export { AuthCard } from './components/auth/auth-card.js';
2
- export { AuthPageLayout } from './components/auth/auth-page-layout.js';
3
- export { Countdown } from './components/auth/countdown.js';
4
- export { ForgotPassword } from './components/auth/forgot-password.js';
5
2
  export { ForgotPasswordPage } from './components/auth/pages/forgot-password-page.js';
6
3
  export { ResetPasswordPage } from './components/auth/pages/reset-password-page.js';
7
4
  export { SignInPage } from './components/auth/pages/sign-in-page.js';
8
5
  export { SignUpPage } from './components/auth/pages/sign-up-page.js';
9
6
  export { VerifyEmailPage } from './components/auth/pages/verify-email-page.js';
10
7
  export { VerifyPhonePage } from './components/auth/pages/verify-phone-page.js';
11
- export { ResetPasswordForm } from './components/auth/reset-password-form.js';
12
- export { SignIn } from './components/auth/sign-in.js';
13
- export { SignUp } from './components/auth/sign-up.js';
14
8
  export { VerificationForm } from './components/auth/verification-form.js';
9
+ export { AuthErrorBoundary, ErrorBoundary } from './components/error-boundary.js';
10
+ export { PermissionsPage } from './components/iam/permissions/permissions-page.js';
11
+ export { RolesPage } from './components/iam/roles/roles-page.js';
12
+ export { SessionsPage } from './components/iam/sessions/sessions-page.js';
13
+ export { TenantsPage } from './components/iam/tenants/tenants-page.js';
14
+ export { UsersPage } from './components/iam/users/users-page.js';
15
+ export { ProfilePage } from './components/profile/profile-page.js';
16
+ export { DataTable, DataTableColumn } from './components/shared/data-table/data-table.js';
17
+ export { AuthFormSkeleton } from './components/skeletons/auth-form-skeleton.js';
18
+ export { ProfileSkeleton } from './components/skeletons/profile-skeleton.js';
19
+ export { TableSkeleton } from './components/skeletons/table-skeleton.js';
15
20
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
21
  import { ReactNode } from 'react';
17
- import './handle-error-H0iqQxJ5.js';
22
+ export { A as AuthErrorContent, h as handleError } from './handle-error-BqDMxnQZ.js';
18
23
 
24
+ declare function useSessionCookieName(): string;
25
+
26
+ declare function useTranslator(namespace?: string): (key: string, params?: Record<string, string | number>) => string;
27
+
28
+ type UIConfig = {
29
+ logo: React.ReactNode;
30
+ name: React.ReactNode;
31
+ logoImage?: string;
32
+ };
33
+ type FeaturesConfig = {
34
+ enableSignup?: boolean;
35
+ enablePasswordReset?: boolean;
36
+ enableEmailSignup?: boolean;
37
+ enablePhoneSignup?: boolean;
38
+ enableSocialSignup?: boolean;
39
+ socialProviders?: string[];
40
+ };
41
+ type NavigationConfig = {
42
+ locale?: string;
43
+ defaultRedirectUrl?: string;
44
+ onNavigate?: (path: string) => void;
45
+ linkComponent?: React.ComponentType<React.ComponentProps<'a'> & {
46
+ href: string;
47
+ }>;
48
+ links?: {
49
+ signIn?: string;
50
+ signUp?: string;
51
+ forgotPassword?: string;
52
+ };
53
+ };
54
+ type AuthClientConfig = {
55
+ baseURL: string;
56
+ ui: UIConfig;
57
+ features?: FeaturesConfig;
58
+ navigation?: NavigationConfig;
59
+ messages?: Record<string, unknown>;
60
+ cookiePrefix?: string;
61
+ };
19
62
  type UserRole = {
20
63
  id: string;
21
64
  roleId: string;
@@ -49,216 +92,40 @@ type AuthResponse = {
49
92
  sessionToken: string;
50
93
  sessionExpiresAt: string;
51
94
  };
52
- type VerificationResponse = {
53
- verificationId: string;
54
- requiresVerification?: boolean;
55
- };
56
- type SessionResponse = {
57
- user: User | null;
58
- session: Session | null;
59
- };
60
- type PendingAccountChange = {
61
- changeType: 'email' | 'phone';
62
- newEmail: string | null;
63
- newPhone: string | null;
64
- expiresAt: string;
65
- };
66
- type PendingAccountChangeResponse = {
67
- accountChange: PendingAccountChange | null;
68
- verificationId: string | null;
69
- };
70
- 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';
71
95
 
72
- type AuthClientConfig = {
73
- baseURL: string;
74
- };
75
- declare class AuthClient {
76
- private baseURL;
77
- constructor(config: AuthClientConfig);
78
- private request;
79
- signUpWithEmail(data: {
80
- email: string;
81
- password: string;
82
- fullName: string;
83
- handle?: string;
84
- }): Promise<AuthResponse | VerificationResponse>;
85
- signUpWithPhone(data: {
86
- phone: string;
87
- password: string;
88
- fullName: string;
89
- handle?: string;
90
- }): Promise<AuthResponse | VerificationResponse>;
91
- checkUser(data: {
92
- identifier: string;
93
- }): Promise<{
94
- exists: boolean;
95
- }>;
96
- signInWithPassword(data: {
97
- identifier: string;
98
- password: string;
99
- }): Promise<AuthResponse | VerificationResponse>;
100
- signOut(): Promise<{
101
- message: string;
102
- }>;
103
- requestEmailVerification(data?: {
104
- email?: string;
105
- }): Promise<{
106
- verificationId: string;
107
- }>;
108
- verifyEmail(data: {
109
- verificationId: string;
110
- code: string;
111
- }): Promise<AuthResponse>;
112
- resendVerification(_verificationId: string): Promise<{
113
- verificationId: string;
114
- }>;
115
- requestPhoneOtp(data: {
116
- phone: string;
117
- context: 'sign-up' | 'sign-in' | 'change-phone';
118
- }): Promise<{
119
- verificationId: string;
120
- }>;
121
- verifyPhoneOtp(data: {
122
- verificationId: string;
123
- code: string;
124
- context: 'sign-up' | 'sign-in' | 'change-phone';
125
- }): Promise<AuthResponse | {
126
- user: User | null;
127
- session: null;
128
- verified: boolean;
129
- }>;
130
- forgotPassword(data: {
131
- identifier: string;
132
- }): Promise<{
133
- message: string;
134
- }>;
135
- resetPassword(data: {
136
- verificationId: string;
137
- code: string;
138
- password: string;
139
- }): Promise<AuthResponse>;
140
- verifyPassword(data: {
141
- password: string;
142
- }): Promise<{
143
- message: string;
144
- }>;
145
- changePassword(data: {
146
- currentPassword: string;
147
- newPassword: string;
148
- }): Promise<{
149
- message: string;
150
- }>;
151
- getSession(): Promise<SessionResponse>;
152
- getPendingAccountChange(): Promise<PendingAccountChangeResponse>;
153
- updateProfile(data: {
154
- fullName?: string;
155
- }): Promise<{
156
- user: User;
157
- }>;
158
- updateEmail(data: {
159
- email: string;
160
- }): Promise<{
161
- user: User;
162
- }>;
163
- updatePhone(data: {
164
- phone: string;
165
- }): Promise<{
166
- user: User;
167
- }>;
168
- }
169
-
170
- type AuthContextValue = {
96
+ type OpenApiHooks = any;
97
+ type SessionState = {
171
98
  user: User | null;
172
99
  session: Session | null;
173
- loading: boolean;
100
+ isLoading: boolean;
101
+ isAuthenticated: boolean;
174
102
  error: Error | null;
175
- client: AuthClient;
103
+ };
104
+ type SessionContextValue = SessionState & {
176
105
  refresh: () => Promise<void>;
177
- setAuth: (data: AuthResponse) => void;
106
+ signOut: () => Promise<void>;
178
107
  };
179
- declare const useAuth: () => AuthContextValue;
180
- type AuthProviderProps = {
181
- client: AuthClient;
182
- children: ReactNode;
108
+ type ApiContextValue = {
109
+ hooks: OpenApiHooks;
110
+ setAuth: (auth: AuthResponse) => void;
111
+ clearAuth: () => void;
112
+ refresh: () => Promise<void>;
183
113
  };
184
- declare const AuthProvider: ({ client, children }: AuthProviderProps) => react_jsx_runtime.JSX.Element;
185
-
186
- declare const createAuthClient: (config: AuthClientConfig) => {
187
- signUpWithEmail: (data: {
188
- email: string;
189
- password: string;
190
- fullName: string;
191
- handle?: string;
192
- }) => Promise<AuthResponse | VerificationResponse>;
193
- signUpWithPhone: (data: {
194
- phone: string;
195
- password: string;
196
- fullName: string;
197
- handle?: string;
198
- }) => Promise<AuthResponse | VerificationResponse>;
199
- signInWithPassword: (data: {
200
- identifier: string;
201
- password: string;
202
- }) => Promise<AuthResponse | VerificationResponse>;
203
- signOut: () => Promise<{
204
- message: string;
205
- }>;
206
- requestEmailVerification: (data?: {
207
- email?: string;
208
- }) => Promise<{
209
- verificationId: string;
210
- }>;
211
- verifyEmail: (data: {
212
- verificationId: string;
213
- code: string;
214
- }) => Promise<AuthResponse>;
215
- resendVerification: (_verificationId: string) => Promise<{
216
- verificationId: string;
217
- }>;
218
- requestPhoneOtp: (data: {
219
- phone: string;
220
- context: "sign-up" | "sign-in" | "change-phone";
221
- }) => Promise<{
222
- verificationId: string;
223
- }>;
224
- verifyPhoneOtp: (data: {
225
- verificationId: string;
226
- code: string;
227
- context: "sign-up" | "sign-in" | "change-phone";
228
- }) => Promise<AuthResponse | {
229
- user: User | null;
230
- session: null;
231
- verified: boolean;
232
- }>;
233
- forgotPassword: (data: {
234
- identifier: string;
235
- }) => Promise<{
236
- message: string;
237
- }>;
238
- resetPassword: (data: {
239
- verificationId: string;
240
- code: string;
241
- password: string;
242
- }) => Promise<AuthResponse>;
243
- changePassword: (data: {
244
- currentPassword: string;
245
- newPassword: string;
246
- }) => Promise<{
247
- message: string;
248
- }>;
249
- getSession: () => Promise<SessionResponse>;
250
- useSession: () => never;
114
+ type ConfigContextValue = {
115
+ config: AuthClientConfig;
116
+ t: (key: string, params?: Record<string, string | number>) => string;
251
117
  };
252
-
253
- declare const useSession: () => {
254
- user: User | null;
255
- session: Session | null;
256
- isLoading: boolean;
257
- isAuthenticated: boolean;
258
- error: Error | null;
259
- refresh: () => Promise<void>;
118
+ declare function useSession(): SessionContextValue;
119
+ declare function useApi(): ApiContextValue;
120
+ declare function useConfig(): ConfigContextValue;
121
+ type MesobAuthProviderProps = {
122
+ config: AuthClientConfig;
123
+ children: ReactNode;
260
124
  };
125
+ declare function MesobAuthProvider({ config, children, }: MesobAuthProviderProps): react_jsx_runtime.JSX.Element;
126
+
127
+ declare const getSessionCookieName: (config: AuthClientConfig) => string;
261
128
 
262
129
  declare function normalizePhone(phone: string): string;
263
130
 
264
- export { AuthClient, type AuthErrorCode, AuthProvider, type AuthResponse, type PendingAccountChange, type PendingAccountChangeResponse, type Session, type SessionResponse, type User, type VerificationResponse, createAuthClient, normalizePhone, useAuth, useSession };
131
+ export { type AuthClientConfig, type AuthResponse, MesobAuthProvider, type Session, type User, type UserRole, getSessionCookieName, normalizePhone, useApi, useConfig, useSession, useSessionCookieName, useTranslator };