@mesob/auth-react 0.1.0 → 0.2.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 (116) hide show
  1. package/dist/components/auth/{auth-page-layout.d.ts → auth-layout.d.ts} +3 -3
  2. package/dist/components/auth/{auth-page-layout.js → auth-layout.js} +4 -4
  3. package/dist/components/auth/auth-layout.js.map +1 -0
  4. package/dist/components/auth/countdown.js +15 -6
  5. package/dist/components/auth/countdown.js.map +1 -1
  6. package/dist/components/auth/forgot-password.d.ts +1 -9
  7. package/dist/components/auth/forgot-password.js +267 -43
  8. package/dist/components/auth/forgot-password.js.map +1 -1
  9. package/dist/components/auth/reset-password-form.d.ts +2 -10
  10. package/dist/components/auth/reset-password-form.js +366 -118
  11. package/dist/components/auth/reset-password-form.js.map +1 -1
  12. package/dist/components/auth/sign-in.d.ts +2 -10
  13. package/dist/components/auth/sign-in.js +358 -130
  14. package/dist/components/auth/sign-in.js.map +1 -1
  15. package/dist/components/auth/sign-up.d.ts +2 -10
  16. package/dist/components/auth/sign-up.js +379 -131
  17. package/dist/components/auth/sign-up.js.map +1 -1
  18. package/dist/components/auth/verification-form.d.ts +2 -16
  19. package/dist/components/auth/verification-form.js +15 -6
  20. package/dist/components/auth/verification-form.js.map +1 -1
  21. package/dist/components/auth/verify-email.d.ts +10 -0
  22. package/dist/components/auth/{pages/verify-email-page.js → verify-email.js} +54 -34
  23. package/dist/components/auth/verify-email.js.map +1 -0
  24. package/dist/components/auth/verify-phone.d.ts +11 -0
  25. package/dist/components/auth/{pages/verify-phone-page.js → verify-phone.js} +53 -46
  26. package/dist/components/auth/verify-phone.js.map +1 -0
  27. package/dist/components/error-boundary.d.ts +2 -2
  28. package/dist/components/iam/permissions.d.ts +5 -0
  29. package/dist/components/iam/{permissions/permissions-page.js → permissions.js} +29 -13
  30. package/dist/components/iam/permissions.js.map +1 -0
  31. package/dist/components/iam/roles.d.ts +5 -0
  32. package/dist/components/iam/{roles/roles-page.js → roles.js} +29 -13
  33. package/dist/components/iam/roles.js.map +1 -0
  34. package/dist/components/iam/sessions.d.ts +5 -0
  35. package/dist/components/iam/{sessions/sessions-page.js → sessions.js} +13 -11
  36. package/dist/components/iam/sessions.js.map +1 -0
  37. package/dist/components/iam/tenants.d.ts +5 -0
  38. package/dist/components/iam/{tenants/tenants-page.js → tenants.js} +13 -11
  39. package/dist/components/iam/tenants.js.map +1 -0
  40. package/dist/components/iam/users.d.ts +5 -0
  41. package/dist/components/iam/{users/users-page.js → users.js} +13 -11
  42. package/dist/components/iam/users.js.map +1 -0
  43. package/dist/components/profile/account.d.ts +5 -0
  44. package/dist/components/profile/account.js +66 -0
  45. package/dist/components/profile/account.js.map +1 -0
  46. package/dist/components/profile/change-email-form.d.ts +5 -0
  47. package/dist/components/profile/change-email-form.js +721 -0
  48. package/dist/components/profile/change-email-form.js.map +1 -0
  49. package/dist/components/profile/change-password-form.d.ts +5 -0
  50. package/dist/components/profile/change-password-form.js +256 -0
  51. package/dist/components/profile/change-password-form.js.map +1 -0
  52. package/dist/components/profile/change-phone-form.d.ts +5 -0
  53. package/dist/components/profile/change-phone-form.js +758 -0
  54. package/dist/components/profile/change-phone-form.js.map +1 -0
  55. package/dist/components/profile/change-profile.d.ts +9 -0
  56. package/dist/components/profile/change-profile.js +37 -0
  57. package/dist/components/profile/change-profile.js.map +1 -0
  58. package/dist/components/profile/otp-verification-modal.d.ts +15 -0
  59. package/dist/components/profile/otp-verification-modal.js +261 -0
  60. package/dist/components/profile/otp-verification-modal.js.map +1 -0
  61. package/dist/components/profile/request-change-email-form.d.ts +10 -0
  62. package/dist/components/profile/request-change-email-form.js +293 -0
  63. package/dist/components/profile/request-change-email-form.js.map +1 -0
  64. package/dist/components/profile/request-change-phone-form.d.ts +10 -0
  65. package/dist/components/profile/request-change-phone-form.js +331 -0
  66. package/dist/components/profile/request-change-phone-form.js.map +1 -0
  67. package/dist/components/profile/security.d.ts +5 -0
  68. package/dist/components/profile/security.js +1439 -0
  69. package/dist/components/profile/security.js.map +1 -0
  70. package/dist/components/profile/verify-change-email-form.d.ts +11 -0
  71. package/dist/components/profile/verify-change-email-form.js +402 -0
  72. package/dist/components/profile/verify-change-email-form.js.map +1 -0
  73. package/dist/components/profile/verify-change-phone-form.d.ts +11 -0
  74. package/dist/components/profile/verify-change-phone-form.js +406 -0
  75. package/dist/components/profile/verify-change-phone-form.js.map +1 -0
  76. package/dist/components/shared/{data-table/data-table.js → data-table.js} +2 -2
  77. package/dist/components/shared/data-table.js.map +1 -0
  78. package/dist/index.d.ts +42 -88
  79. package/dist/index.js +2297 -1299
  80. package/dist/index.js.map +1 -1
  81. package/dist/types-D3s9oE-5.d.ts +75 -0
  82. package/dist/verification-form-ipSRTtQB.d.ts +22 -0
  83. package/package.json +3 -2
  84. package/dist/components/auth/auth-page-layout.js.map +0 -1
  85. package/dist/components/auth/pages/forgot-password-page.d.ts +0 -6
  86. package/dist/components/auth/pages/forgot-password-page.js +0 -362
  87. package/dist/components/auth/pages/forgot-password-page.js.map +0 -1
  88. package/dist/components/auth/pages/reset-password-page.d.ts +0 -9
  89. package/dist/components/auth/pages/reset-password-page.js +0 -514
  90. package/dist/components/auth/pages/reset-password-page.js.map +0 -1
  91. package/dist/components/auth/pages/sign-in-page.d.ts +0 -8
  92. package/dist/components/auth/pages/sign-in-page.js +0 -565
  93. package/dist/components/auth/pages/sign-in-page.js.map +0 -1
  94. package/dist/components/auth/pages/sign-up-page.d.ts +0 -9
  95. package/dist/components/auth/pages/sign-up-page.js +0 -518
  96. package/dist/components/auth/pages/sign-up-page.js.map +0 -1
  97. package/dist/components/auth/pages/verify-email-page.d.ts +0 -10
  98. package/dist/components/auth/pages/verify-email-page.js.map +0 -1
  99. package/dist/components/auth/pages/verify-phone-page.d.ts +0 -11
  100. package/dist/components/auth/pages/verify-phone-page.js.map +0 -1
  101. package/dist/components/iam/permissions/permissions-page.d.ts +0 -5
  102. package/dist/components/iam/permissions/permissions-page.js.map +0 -1
  103. package/dist/components/iam/roles/roles-page.d.ts +0 -5
  104. package/dist/components/iam/roles/roles-page.js.map +0 -1
  105. package/dist/components/iam/sessions/sessions-page.d.ts +0 -5
  106. package/dist/components/iam/sessions/sessions-page.js.map +0 -1
  107. package/dist/components/iam/tenants/tenants-page.d.ts +0 -5
  108. package/dist/components/iam/tenants/tenants-page.js.map +0 -1
  109. package/dist/components/iam/users/users-page.d.ts +0 -5
  110. package/dist/components/iam/users/users-page.js.map +0 -1
  111. package/dist/components/profile/profile-page.d.ts +0 -8
  112. package/dist/components/profile/profile-page.js +0 -163
  113. package/dist/components/profile/profile-page.js.map +0 -1
  114. package/dist/components/shared/data-table/data-table.js.map +0 -1
  115. package/dist/handle-error-BqDMxnQZ.d.ts +0 -8
  116. /package/dist/components/shared/{data-table/data-table.d.ts → data-table.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,107 +1,49 @@
1
1
  export { AuthCard } from './components/auth/auth-card.js';
2
- export { ForgotPasswordPage } from './components/auth/pages/forgot-password-page.js';
3
- export { ResetPasswordPage } from './components/auth/pages/reset-password-page.js';
4
- export { SignInPage } from './components/auth/pages/sign-in-page.js';
5
- export { SignUpPage } from './components/auth/pages/sign-up-page.js';
6
- export { VerifyEmailPage } from './components/auth/pages/verify-email-page.js';
7
- export { VerifyPhonePage } from './components/auth/pages/verify-phone-page.js';
8
- export { VerificationForm } from './components/auth/verification-form.js';
2
+ export { ForgotPassword } from './components/auth/forgot-password.js';
3
+ export { ResetPasswordForm } from './components/auth/reset-password-form.js';
4
+ export { SignIn } from './components/auth/sign-in.js';
5
+ export { SignUp } from './components/auth/sign-up.js';
6
+ export { A as AuthErrorContent, V as VerificationForm, h as handleError } from './verification-form-ipSRTtQB.js';
7
+ export { VerifyEmail } from './components/auth/verify-email.js';
8
+ export { VerifyPhone } from './components/auth/verify-phone.js';
9
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';
10
+ export { Permissions } from './components/iam/permissions.js';
11
+ export { Roles } from './components/iam/roles.js';
12
+ export { Sessions } from './components/iam/sessions.js';
13
+ export { Tenants } from './components/iam/tenants.js';
14
+ export { Users } from './components/iam/users.js';
15
+ export { Account } from './components/profile/account.js';
16
+ export { Security } from './components/profile/security.js';
17
+ export { DataTable, DataTableColumn } from './components/shared/data-table.js';
17
18
  export { AuthFormSkeleton } from './components/skeletons/auth-form-skeleton.js';
18
19
  export { ProfileSkeleton } from './components/skeletons/profile-skeleton.js';
19
20
  export { TableSkeleton } from './components/skeletons/table-skeleton.js';
20
21
  import * as react_jsx_runtime from 'react/jsx-runtime';
21
22
  import { ReactNode } from 'react';
22
- export { A as AuthErrorContent, h as handleError } from './handle-error-BqDMxnQZ.js';
23
+ import { A as AuthClientConfig, a as AuthResponse, U as User, S as Session } from './types-D3s9oE-5.js';
24
+ export { b as UserRole } from './types-D3s9oE-5.js';
23
25
 
24
26
  declare function useSessionCookieName(): string;
25
27
 
26
28
  declare function useTranslator(namespace?: string): (key: string, params?: Record<string, string | number>) => string;
27
29
 
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
- };
62
- type UserRole = {
63
- id: string;
64
- roleId: string;
65
- code: string;
66
- name: string;
67
- description: string;
68
- };
69
- type User = {
70
- id: string;
71
- tenantId: string;
72
- fullName: string;
73
- email: string | null;
74
- phone: string | null;
75
- handle: string;
76
- image: string | null;
77
- emailVerified: boolean;
78
- phoneVerified: boolean;
79
- lastSignInAt: string | null;
80
- userRoles?: UserRole[];
81
- };
82
- type Session = {
83
- id: string;
84
- expiresAt: string;
85
- createdAt?: string;
86
- userAgent: string | null;
87
- ip: string | null;
88
- };
89
- type AuthResponse = {
90
- user: User;
91
- session: Session;
92
- sessionToken: string;
93
- sessionExpiresAt: string;
94
- };
95
-
96
30
  type OpenApiHooks = any;
97
- type SessionState = {
31
+ /**
32
+ * @deprecated Cookie is httpOnly and cannot be read client-side.
33
+ * Use `useSession().isAuthenticated` instead.
34
+ * This function always returns false on client.
35
+ */
36
+ declare function hasAuthCookie(_cookieName: string): boolean;
37
+ type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';
38
+ type AuthState = {
98
39
  user: User | null;
99
40
  session: Session | null;
100
- isLoading: boolean;
101
- isAuthenticated: boolean;
41
+ status: AuthStatus;
102
42
  error: Error | null;
103
43
  };
104
- type SessionContextValue = SessionState & {
44
+ type SessionContextValue = AuthState & {
45
+ isLoading: boolean;
46
+ isAuthenticated: boolean;
105
47
  refresh: () => Promise<void>;
106
48
  signOut: () => Promise<void>;
107
49
  };
@@ -113,11 +55,23 @@ type ApiContextValue = {
113
55
  };
114
56
  type ConfigContextValue = {
115
57
  config: AuthClientConfig;
58
+ cookieName: string;
116
59
  t: (key: string, params?: Record<string, string | number>) => string;
117
60
  };
61
+ /**
62
+ * Get session state including user, session, and auth status.
63
+ * - `status`: 'loading' | 'authenticated' | 'unauthenticated'
64
+ * - `isLoading`: true while fetching session
65
+ * - `isAuthenticated`: true if user and session exist
66
+ */
118
67
  declare function useSession(): SessionContextValue;
119
68
  declare function useApi(): ApiContextValue;
120
69
  declare function useConfig(): ConfigContextValue;
70
+ /**
71
+ * @deprecated Cookie is httpOnly, can't be checked client-side.
72
+ * Use `useSession().isAuthenticated` instead.
73
+ */
74
+ declare function useHasAuthCookie(): boolean;
121
75
  type MesobAuthProviderProps = {
122
76
  config: AuthClientConfig;
123
77
  children: ReactNode;
@@ -128,4 +82,4 @@ declare const getSessionCookieName: (config: AuthClientConfig) => string;
128
82
 
129
83
  declare function normalizePhone(phone: string): string;
130
84
 
131
- export { type AuthClientConfig, type AuthResponse, MesobAuthProvider, type Session, type User, type UserRole, getSessionCookieName, normalizePhone, useApi, useConfig, useSession, useSessionCookieName, useTranslator };
85
+ export { AuthClientConfig, AuthResponse, type AuthStatus, MesobAuthProvider, Session, User, getSessionCookieName, hasAuthCookie, normalizePhone, useApi, useConfig, useHasAuthCookie, useHasAuthCookie as useIsAuthenticated, useSession, useSessionCookieName, useTranslator };