@mesob/auth-react 0.0.8 → 0.1.1

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 +80 -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,69 @@
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 TenantConfig = {
42
+ enabled: boolean;
43
+ tenantId: string;
44
+ };
45
+ type NavigationConfig = {
46
+ locale?: string;
47
+ defaultRedirectUrl?: string;
48
+ onNavigate?: (path: string) => void;
49
+ linkComponent?: React.ComponentType<React.ComponentProps<'a'> & {
50
+ href: string;
51
+ }>;
52
+ links?: {
53
+ signIn?: string;
54
+ signUp?: string;
55
+ forgotPassword?: string;
56
+ };
57
+ };
58
+ type AuthClientConfig = {
59
+ baseURL: string;
60
+ ui: UIConfig;
61
+ features?: FeaturesConfig;
62
+ tenant?: TenantConfig;
63
+ navigation?: NavigationConfig;
64
+ messages?: Record<string, unknown>;
65
+ cookiePrefix?: string;
66
+ };
19
67
  type UserRole = {
20
68
  id: string;
21
69
  roleId: string;
@@ -49,216 +97,40 @@ type AuthResponse = {
49
97
  sessionToken: string;
50
98
  sessionExpiresAt: string;
51
99
  };
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
100
 
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 = {
101
+ type OpenApiHooks = any;
102
+ type SessionState = {
171
103
  user: User | null;
172
104
  session: Session | null;
173
- loading: boolean;
105
+ isLoading: boolean;
106
+ isAuthenticated: boolean;
174
107
  error: Error | null;
175
- client: AuthClient;
108
+ };
109
+ type SessionContextValue = SessionState & {
176
110
  refresh: () => Promise<void>;
177
- setAuth: (data: AuthResponse) => void;
111
+ signOut: () => Promise<void>;
178
112
  };
179
- declare const useAuth: () => AuthContextValue;
180
- type AuthProviderProps = {
181
- client: AuthClient;
182
- children: ReactNode;
113
+ type ApiContextValue = {
114
+ hooks: OpenApiHooks;
115
+ setAuth: (auth: AuthResponse) => void;
116
+ clearAuth: () => void;
117
+ refresh: () => Promise<void>;
183
118
  };
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;
119
+ type ConfigContextValue = {
120
+ config: AuthClientConfig;
121
+ t: (key: string, params?: Record<string, string | number>) => string;
251
122
  };
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>;
123
+ declare function useSession(): SessionContextValue;
124
+ declare function useApi(): ApiContextValue;
125
+ declare function useConfig(): ConfigContextValue;
126
+ type MesobAuthProviderProps = {
127
+ config: AuthClientConfig;
128
+ children: ReactNode;
260
129
  };
130
+ declare function MesobAuthProvider({ config, children, }: MesobAuthProviderProps): react_jsx_runtime.JSX.Element;
131
+
132
+ declare const getSessionCookieName: (config: AuthClientConfig) => string;
261
133
 
262
134
  declare function normalizePhone(phone: string): string;
263
135
 
264
- export { AuthClient, type AuthErrorCode, AuthProvider, type AuthResponse, type PendingAccountChange, type PendingAccountChangeResponse, type Session, type SessionResponse, type User, type VerificationResponse, createAuthClient, normalizePhone, useAuth, useSession };
136
+ export { type AuthClientConfig, type AuthResponse, MesobAuthProvider, type Session, type User, type UserRole, getSessionCookieName, normalizePhone, useApi, useConfig, useSession, useSessionCookieName, useTranslator };