@mesob/auth-react 0.1.1 → 0.2.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 (117) hide show
  1. package/dist/components/auth/auth-card.js +1 -1
  2. package/dist/components/auth/auth-card.js.map +1 -1
  3. package/dist/components/auth/{auth-page-layout.d.ts → auth-layout.d.ts} +3 -3
  4. package/dist/components/auth/{auth-page-layout.js → auth-layout.js} +4 -4
  5. package/dist/components/auth/auth-layout.js.map +1 -0
  6. package/dist/components/auth/countdown.js +15 -6
  7. package/dist/components/auth/countdown.js.map +1 -1
  8. package/dist/components/auth/forgot-password.d.ts +1 -9
  9. package/dist/components/auth/forgot-password.js +267 -43
  10. package/dist/components/auth/forgot-password.js.map +1 -1
  11. package/dist/components/auth/reset-password-form.d.ts +2 -10
  12. package/dist/components/auth/reset-password-form.js +366 -118
  13. package/dist/components/auth/reset-password-form.js.map +1 -1
  14. package/dist/components/auth/sign-in.d.ts +2 -10
  15. package/dist/components/auth/sign-in.js +358 -130
  16. package/dist/components/auth/sign-in.js.map +1 -1
  17. package/dist/components/auth/sign-up.d.ts +2 -10
  18. package/dist/components/auth/sign-up.js +379 -131
  19. package/dist/components/auth/sign-up.js.map +1 -1
  20. package/dist/components/auth/verification-form.d.ts +2 -16
  21. package/dist/components/auth/verification-form.js +15 -6
  22. package/dist/components/auth/verification-form.js.map +1 -1
  23. package/dist/components/auth/verify-email.d.ts +10 -0
  24. package/dist/components/auth/{pages/verify-email-page.js → verify-email.js} +54 -34
  25. package/dist/components/auth/verify-email.js.map +1 -0
  26. package/dist/components/auth/verify-phone.d.ts +11 -0
  27. package/dist/components/auth/{pages/verify-phone-page.js → verify-phone.js} +53 -46
  28. package/dist/components/auth/verify-phone.js.map +1 -0
  29. package/dist/components/iam/permissions.d.ts +5 -0
  30. package/dist/components/iam/{permissions/permissions-page.js → permissions.js} +29 -13
  31. package/dist/components/iam/permissions.js.map +1 -0
  32. package/dist/components/iam/roles.d.ts +5 -0
  33. package/dist/components/iam/{roles/roles-page.js → roles.js} +29 -13
  34. package/dist/components/iam/roles.js.map +1 -0
  35. package/dist/components/iam/sessions.d.ts +5 -0
  36. package/dist/components/iam/{sessions/sessions-page.js → sessions.js} +13 -11
  37. package/dist/components/iam/sessions.js.map +1 -0
  38. package/dist/components/iam/tenants.d.ts +5 -0
  39. package/dist/components/iam/{tenants/tenants-page.js → tenants.js} +13 -11
  40. package/dist/components/iam/tenants.js.map +1 -0
  41. package/dist/components/iam/users.d.ts +5 -0
  42. package/dist/components/iam/{users/users-page.js → users.js} +13 -11
  43. package/dist/components/iam/users.js.map +1 -0
  44. package/dist/components/profile/account.d.ts +5 -0
  45. package/dist/components/profile/account.js +66 -0
  46. package/dist/components/profile/account.js.map +1 -0
  47. package/dist/components/profile/change-email-form.d.ts +5 -0
  48. package/dist/components/profile/change-email-form.js +721 -0
  49. package/dist/components/profile/change-email-form.js.map +1 -0
  50. package/dist/components/profile/change-password-form.d.ts +5 -0
  51. package/dist/components/profile/change-password-form.js +256 -0
  52. package/dist/components/profile/change-password-form.js.map +1 -0
  53. package/dist/components/profile/change-phone-form.d.ts +5 -0
  54. package/dist/components/profile/change-phone-form.js +758 -0
  55. package/dist/components/profile/change-phone-form.js.map +1 -0
  56. package/dist/components/profile/change-profile.d.ts +9 -0
  57. package/dist/components/profile/change-profile.js +37 -0
  58. package/dist/components/profile/change-profile.js.map +1 -0
  59. package/dist/components/profile/otp-verification-modal.d.ts +15 -0
  60. package/dist/components/profile/otp-verification-modal.js +261 -0
  61. package/dist/components/profile/otp-verification-modal.js.map +1 -0
  62. package/dist/components/profile/request-change-email-form.d.ts +10 -0
  63. package/dist/components/profile/request-change-email-form.js +293 -0
  64. package/dist/components/profile/request-change-email-form.js.map +1 -0
  65. package/dist/components/profile/request-change-phone-form.d.ts +10 -0
  66. package/dist/components/profile/request-change-phone-form.js +331 -0
  67. package/dist/components/profile/request-change-phone-form.js.map +1 -0
  68. package/dist/components/profile/security.d.ts +5 -0
  69. package/dist/components/profile/security.js +1439 -0
  70. package/dist/components/profile/security.js.map +1 -0
  71. package/dist/components/profile/verify-change-email-form.d.ts +11 -0
  72. package/dist/components/profile/verify-change-email-form.js +402 -0
  73. package/dist/components/profile/verify-change-email-form.js.map +1 -0
  74. package/dist/components/profile/verify-change-phone-form.d.ts +11 -0
  75. package/dist/components/profile/verify-change-phone-form.js +406 -0
  76. package/dist/components/profile/verify-change-phone-form.js.map +1 -0
  77. package/dist/components/shared/{data-table/data-table.js → data-table.js} +2 -2
  78. package/dist/components/shared/data-table.js.map +1 -0
  79. package/dist/index.d.ts +42 -93
  80. package/dist/index.js +2298 -1300
  81. package/dist/index.js.map +1 -1
  82. package/dist/types-D3s9oE-5.d.ts +75 -0
  83. package/dist/verification-form-ipSRTtQB.d.ts +22 -0
  84. package/package.json +3 -2
  85. package/dist/components/auth/auth-page-layout.js.map +0 -1
  86. package/dist/components/auth/pages/forgot-password-page.d.ts +0 -6
  87. package/dist/components/auth/pages/forgot-password-page.js +0 -362
  88. package/dist/components/auth/pages/forgot-password-page.js.map +0 -1
  89. package/dist/components/auth/pages/reset-password-page.d.ts +0 -9
  90. package/dist/components/auth/pages/reset-password-page.js +0 -514
  91. package/dist/components/auth/pages/reset-password-page.js.map +0 -1
  92. package/dist/components/auth/pages/sign-in-page.d.ts +0 -8
  93. package/dist/components/auth/pages/sign-in-page.js +0 -565
  94. package/dist/components/auth/pages/sign-in-page.js.map +0 -1
  95. package/dist/components/auth/pages/sign-up-page.d.ts +0 -9
  96. package/dist/components/auth/pages/sign-up-page.js +0 -518
  97. package/dist/components/auth/pages/sign-up-page.js.map +0 -1
  98. package/dist/components/auth/pages/verify-email-page.d.ts +0 -10
  99. package/dist/components/auth/pages/verify-email-page.js.map +0 -1
  100. package/dist/components/auth/pages/verify-phone-page.d.ts +0 -11
  101. package/dist/components/auth/pages/verify-phone-page.js.map +0 -1
  102. package/dist/components/iam/permissions/permissions-page.d.ts +0 -5
  103. package/dist/components/iam/permissions/permissions-page.js.map +0 -1
  104. package/dist/components/iam/roles/roles-page.d.ts +0 -5
  105. package/dist/components/iam/roles/roles-page.js.map +0 -1
  106. package/dist/components/iam/sessions/sessions-page.d.ts +0 -5
  107. package/dist/components/iam/sessions/sessions-page.js.map +0 -1
  108. package/dist/components/iam/tenants/tenants-page.d.ts +0 -5
  109. package/dist/components/iam/tenants/tenants-page.js.map +0 -1
  110. package/dist/components/iam/users/users-page.d.ts +0 -5
  111. package/dist/components/iam/users/users-page.js.map +0 -1
  112. package/dist/components/profile/profile-page.d.ts +0 -8
  113. package/dist/components/profile/profile-page.js +0 -163
  114. package/dist/components/profile/profile-page.js.map +0 -1
  115. package/dist/components/shared/data-table/data-table.js.map +0 -1
  116. package/dist/handle-error-BqDMxnQZ.d.ts +0 -8
  117. /package/dist/components/shared/{data-table/data-table.d.ts → data-table.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,112 +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 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
- };
67
- type UserRole = {
68
- id: string;
69
- roleId: string;
70
- code: string;
71
- name: string;
72
- description: string;
73
- };
74
- type User = {
75
- id: string;
76
- tenantId: string;
77
- fullName: string;
78
- email: string | null;
79
- phone: string | null;
80
- handle: string;
81
- image: string | null;
82
- emailVerified: boolean;
83
- phoneVerified: boolean;
84
- lastSignInAt: string | null;
85
- userRoles?: UserRole[];
86
- };
87
- type Session = {
88
- id: string;
89
- expiresAt: string;
90
- createdAt?: string;
91
- userAgent: string | null;
92
- ip: string | null;
93
- };
94
- type AuthResponse = {
95
- user: User;
96
- session: Session;
97
- sessionToken: string;
98
- sessionExpiresAt: string;
99
- };
100
-
101
30
  type OpenApiHooks = any;
102
- 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 = {
103
39
  user: User | null;
104
40
  session: Session | null;
105
- isLoading: boolean;
106
- isAuthenticated: boolean;
41
+ status: AuthStatus;
107
42
  error: Error | null;
108
43
  };
109
- type SessionContextValue = SessionState & {
44
+ type SessionContextValue = AuthState & {
45
+ isLoading: boolean;
46
+ isAuthenticated: boolean;
110
47
  refresh: () => Promise<void>;
111
48
  signOut: () => Promise<void>;
112
49
  };
@@ -118,11 +55,23 @@ type ApiContextValue = {
118
55
  };
119
56
  type ConfigContextValue = {
120
57
  config: AuthClientConfig;
58
+ cookieName: string;
121
59
  t: (key: string, params?: Record<string, string | number>) => string;
122
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
+ */
123
67
  declare function useSession(): SessionContextValue;
124
68
  declare function useApi(): ApiContextValue;
125
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;
126
75
  type MesobAuthProviderProps = {
127
76
  config: AuthClientConfig;
128
77
  children: ReactNode;
@@ -133,4 +82,4 @@ declare const getSessionCookieName: (config: AuthClientConfig) => string;
133
82
 
134
83
  declare function normalizePhone(phone: string): string;
135
84
 
136
- 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 };