@zango-core/appbuilder 1.0.0-rc.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 (169) hide show
  1. package/dist/ConfigurePage-DRzSb06z.js +29 -0
  2. package/dist/ConfigurePage-DRzSb06z.js.map +1 -0
  3. package/dist/LoginPageWithRoleSelection-xTr_eIWh.js +662 -0
  4. package/dist/LoginPageWithRoleSelection-xTr_eIWh.js.map +1 -0
  5. package/dist/PageTypeRegistry-5269IpiS.js +53 -0
  6. package/dist/PageTypeRegistry-5269IpiS.js.map +1 -0
  7. package/dist/index.framework-B8SMzgN1.js +28005 -0
  8. package/dist/index.framework-B8SMzgN1.js.map +1 -0
  9. package/dist/types/App.d.ts +14 -0
  10. package/dist/types/__tests__/mocks/data/appInitData.d.ts +197 -0
  11. package/dist/types/__tests__/mocks/data/authConfigData.d.ts +356 -0
  12. package/dist/types/__tests__/mocks/externalPackages.d.ts +42 -0
  13. package/dist/types/__tests__/mocks/handlers/appInit.handlers.d.ts +3 -0
  14. package/dist/types/__tests__/mocks/handlers/auth.handlers.d.ts +1 -0
  15. package/dist/types/__tests__/mocks/handlers/index.d.ts +5 -0
  16. package/dist/types/__tests__/mocks/handlers/profile.handlers.d.ts +15 -0
  17. package/dist/types/__tests__/mocks/handlers/session.handlers.d.ts +2 -0
  18. package/dist/types/__tests__/setup/setupDOMMatchers.d.ts +0 -0
  19. package/dist/types/__tests__/setup/setupMSW.d.ts +1 -0
  20. package/dist/types/__tests__/setup/setupTests.d.ts +34 -0
  21. package/dist/types/__tests__/utils/mockRouterUtils.d.ts +62 -0
  22. package/dist/types/__tests__/utils/renderWithProviders.d.ts +22 -0
  23. package/dist/types/__tests__/utils/waitForHelpers.d.ts +36 -0
  24. package/dist/types/auth/components/AuthMobileShell.d.ts +8 -0
  25. package/dist/types/auth/components/AuthProvider.d.ts +30 -0
  26. package/dist/types/auth/components/DynamicLoginForm.d.ts +9 -0
  27. package/dist/types/auth/components/ForgotPasswordForm.d.ts +11 -0
  28. package/dist/types/auth/components/LoginForm.d.ts +7 -0
  29. package/dist/types/auth/components/LoginRouter.d.ts +197 -0
  30. package/dist/types/auth/components/OAuthCallback.d.ts +19 -0
  31. package/dist/types/auth/components/OTPForm.d.ts +11 -0
  32. package/dist/types/auth/components/OTPInput.d.ts +8 -0
  33. package/dist/types/auth/components/PasswordResetRequired.d.ts +23 -0
  34. package/dist/types/auth/components/ProviderButton.d.ts +17 -0
  35. package/dist/types/auth/components/ResetPasswordForm.d.ts +12 -0
  36. package/dist/types/auth/components/RoleSelection.d.ts +25 -0
  37. package/dist/types/auth/components/SecondFactorAuth.d.ts +21 -0
  38. package/dist/types/auth/components/composable/OTPLoginForm.d.ts +17 -0
  39. package/dist/types/auth/components/composable/PasswordLoginForm.d.ts +17 -0
  40. package/dist/types/auth/components/composable/SSOButtons.d.ts +61 -0
  41. package/dist/types/auth/components/composable/index.d.ts +42 -0
  42. package/dist/types/auth/contexts/LoginContext.d.ts +6 -0
  43. package/dist/types/auth/hocs/withMultiStepAuth.d.ts +35 -0
  44. package/dist/types/auth/index.d.ts +23 -0
  45. package/dist/types/auth/pages/CompleteAuthFlow.d.ts +24 -0
  46. package/dist/types/auth/pages/LoginPage.d.ts +8 -0
  47. package/dist/types/auth/pages/LoginPageWithRoleSelection.d.ts +13 -0
  48. package/dist/types/auth/pages/OAuthCallbackPage.d.ts +17 -0
  49. package/dist/types/auth/pages/SAMLCallbackPage.d.ts +16 -0
  50. package/dist/types/auth/services/authService.d.ts +87 -0
  51. package/dist/types/auth/services/internal/apiClients.d.ts +9 -0
  52. package/dist/types/auth/services/internal/authState.d.ts +12 -0
  53. package/dist/types/auth/services/internal/errorHelper.d.ts +1 -0
  54. package/dist/types/auth/services/internal/oauthSamlService.d.ts +46 -0
  55. package/dist/types/auth/services/internal/passwordValidator.d.ts +17 -0
  56. package/dist/types/auth/services/network/api.d.ts +1629 -0
  57. package/dist/types/auth/services/network/base.d.ts +31 -0
  58. package/dist/types/auth/services/network/configuration.d.ts +74 -0
  59. package/dist/types/auth/services/network/index.d.ts +13 -0
  60. package/dist/types/auth/stores/index.d.ts +1 -0
  61. package/dist/types/auth/stores/useAuthStore.d.ts +6 -0
  62. package/dist/types/auth/types/index.d.ts +57 -0
  63. package/dist/types/auth/utils/authFlowHandler.d.ts +72 -0
  64. package/dist/types/auth/utils/authUtils.d.ts +21 -0
  65. package/dist/types/auth/utils/validators.d.ts +18 -0
  66. package/dist/types/components/ErrorBoundary.d.ts +23 -0
  67. package/dist/types/components/ErrorFallback.d.ts +8 -0
  68. package/dist/types/components/index.d.ts +1 -0
  69. package/dist/types/components/ui/avatar.d.ts +11 -0
  70. package/dist/types/components/ui/button.d.ts +10 -0
  71. package/dist/types/components/ui/collapsible.d.ts +5 -0
  72. package/dist/types/components/ui/dialog.d.ts +13 -0
  73. package/dist/types/components/ui/dropdown-menu.d.ts +10 -0
  74. package/dist/types/components/ui/empty.d.ts +8 -0
  75. package/dist/types/components/ui/index.d.ts +12 -0
  76. package/dist/types/components/ui/input.d.ts +3 -0
  77. package/dist/types/components/ui/separator.d.ts +4 -0
  78. package/dist/types/components/ui/sheet.d.ts +14 -0
  79. package/dist/types/components/ui/sidebar.d.ts +69 -0
  80. package/dist/types/components/ui/skeleton.d.ts +2 -0
  81. package/dist/types/components/ui/tooltip.d.ts +7 -0
  82. package/dist/types/framework/ZangoApp.d.ts +19 -0
  83. package/dist/types/framework/components/CachedLogo.d.ts +9 -0
  84. package/dist/types/framework/components/CustomPageFallback.d.ts +13 -0
  85. package/dist/types/framework/components/CustomPageLoader.d.ts +10 -0
  86. package/dist/types/framework/components/DocumentHead.d.ts +5 -0
  87. package/dist/types/framework/components/RouteErrorBoundary.d.ts +16 -0
  88. package/dist/types/framework/components/SessionSecurityDialog.d.ts +10 -0
  89. package/dist/types/framework/components/SessionSecurityProvider.d.ts +8 -0
  90. package/dist/types/framework/components/SmartLink.d.ts +13 -0
  91. package/dist/types/framework/components/layout/AppSidebar.d.ts +36 -0
  92. package/dist/types/framework/components/layout/Breadcrumbs.d.ts +2 -0
  93. package/dist/types/framework/components/layout/CommandPalette.d.ts +2 -0
  94. package/dist/types/framework/components/layout/Layout.d.ts +2 -0
  95. package/dist/types/framework/components/layout/Navbar.d.ts +9 -0
  96. package/dist/types/framework/components/layout/NavbarIcon.d.ts +12 -0
  97. package/dist/types/framework/components/layout/Topbar.d.ts +50 -0
  98. package/dist/types/framework/components/layout/UserProfileDrawer.d.ts +7 -0
  99. package/dist/types/framework/components/layout/profile/PasswordCard.d.ts +18 -0
  100. package/dist/types/framework/components/layout/profile/PersonalInfoCard.d.ts +12 -0
  101. package/dist/types/framework/components/layout/profile/ProfileRail.d.ts +23 -0
  102. package/dist/types/framework/components/layout/profile/SessionsCard.d.ts +8 -0
  103. package/dist/types/framework/components/layout/profile/TokensCard.d.ts +11 -0
  104. package/dist/types/framework/components/layout/profile/TwoFactorCard.d.ts +7 -0
  105. package/dist/types/framework/config/defaultLayoutConfig.d.ts +34 -0
  106. package/dist/types/framework/constants/routes.d.ts +5 -0
  107. package/dist/types/framework/contexts/AppContext.d.ts +57 -0
  108. package/dist/types/framework/contexts/AuthConfigContext.d.ts +22 -0
  109. package/dist/types/framework/hooks/useProfileData.d.ts +73 -0
  110. package/dist/types/framework/hooks/useRoutes.d.ts +10 -0
  111. package/dist/types/framework/hooks/useSessionSecurity.d.ts +17 -0
  112. package/dist/types/framework/hooks/useSmartNavigation.d.ts +15 -0
  113. package/dist/types/framework/index.d.ts +35 -0
  114. package/dist/types/framework/pages/ConfigurePage.d.ts +2 -0
  115. package/dist/types/framework/pages/CrudPage.d.ts +6 -0
  116. package/dist/types/framework/pages/LoginPage.d.ts +5 -0
  117. package/dist/types/framework/pages/LogoutPage.d.ts +2 -0
  118. package/dist/types/framework/pages/NotFoundPage.d.ts +6 -0
  119. package/dist/types/framework/pages/TrainingPage.d.ts +6 -0
  120. package/dist/types/framework/routing/PageTypeRegistry.d.ts +43 -0
  121. package/dist/types/framework/routing/PageTypeRouter.d.ts +12 -0
  122. package/dist/types/framework/routing/dynamicPageRegistry.d.ts +41 -0
  123. package/dist/types/framework/routing/getRenderComponent.d.ts +6 -0
  124. package/dist/types/framework/types/layout.types.d.ts +107 -0
  125. package/dist/types/framework/utils/apiConfig.d.ts +41 -0
  126. package/dist/types/framework/utils/apiInterceptor.d.ts +12 -0
  127. package/dist/types/framework/utils/apiUrlUtils.d.ts +9 -0
  128. package/dist/types/framework/utils/authThemeUtils.d.ts +64 -0
  129. package/dist/types/framework/utils/colorUtils.d.ts +53 -0
  130. package/dist/types/framework/utils/cookieUtils.d.ts +20 -0
  131. package/dist/types/framework/utils/csrf.d.ts +27 -0
  132. package/dist/types/framework/utils/logoCache.d.ts +21 -0
  133. package/dist/types/framework/utils/logoutUtils.d.ts +15 -0
  134. package/dist/types/framework/utils/redirectUtils.d.ts +48 -0
  135. package/dist/types/framework/utils/safeRedirect.d.ts +21 -0
  136. package/dist/types/framework/utils/storageKeys.d.ts +44 -0
  137. package/dist/types/framework/utils/storageSanitizer.d.ts +20 -0
  138. package/dist/types/hooks/index.d.ts +2 -0
  139. package/dist/types/hooks/queries/index.d.ts +4 -0
  140. package/dist/types/hooks/queries/useAppInitQuery.d.ts +1 -0
  141. package/dist/types/hooks/queries/useAuthConfigQuery.d.ts +1 -0
  142. package/dist/types/hooks/queries/useProfileQuery.d.ts +8 -0
  143. package/dist/types/hooks/useBreakpoint.d.ts +2 -0
  144. package/dist/types/hooks/useMobile.d.ts +1 -0
  145. package/dist/types/index.d.ts +0 -0
  146. package/dist/types/index.framework.d.ts +39 -0
  147. package/dist/types/index.zango.d.ts +12 -0
  148. package/dist/types/lib/index.d.ts +1 -0
  149. package/dist/types/lib/utils.d.ts +2 -0
  150. package/dist/types/schemas/appInit.schema.d.ts +61 -0
  151. package/dist/types/schemas/index.d.ts +10 -0
  152. package/dist/types/schemas/profile.schema.d.ts +18 -0
  153. package/dist/types/schemas/route.schema.d.ts +9 -0
  154. package/dist/types/schemas/session.schema.d.ts +8 -0
  155. package/dist/types/schemas/theme.schema.d.ts +27 -0
  156. package/dist/types/services/api/index.d.ts +2 -0
  157. package/dist/types/services/api.d.ts +109 -0
  158. package/dist/types/services/index.d.ts +7 -0
  159. package/dist/types/services/legacyAdapter.d.ts +10 -0
  160. package/dist/types/services/logger.d.ts +32 -0
  161. package/dist/types/services/normalizeResponse.d.ts +29 -0
  162. package/dist/types/types/auth.d.ts +103 -0
  163. package/dist/types/types/common.d.ts +343 -0
  164. package/dist/types/types/index.d.ts +278 -0
  165. package/dist/zango-appbuilder.js +99 -0
  166. package/dist/zango-appbuilder.js.map +1 -0
  167. package/dist/zango-appbuilder.umd.cjs +247 -0
  168. package/dist/zango-appbuilder.umd.cjs.map +1 -0
  169. package/package.json +140 -0
@@ -0,0 +1,62 @@
1
+ import { default as React } from 'react';
2
+ export declare const mockNavigate: import('vitest').Mock<import('@vitest/spy').Procedure>;
3
+ export declare const mockLocation: {
4
+ pathname: string;
5
+ search: string;
6
+ hash: string;
7
+ state: null;
8
+ key: string;
9
+ };
10
+ /**
11
+ * Helper to set mock location
12
+ */
13
+ export declare const setMockLocation: (location: Partial<typeof mockLocation>) => void;
14
+ /**
15
+ * Reset router mocks
16
+ */
17
+ export declare const resetRouterMocks: () => void;
18
+ /**
19
+ * Create a mock for react-router-dom
20
+ * Use with vi.mock('react-router-dom', () => createRouterMock())
21
+ */
22
+ export declare const createRouterMock: () => {
23
+ useNavigate: () => import('vitest').Mock<import('@vitest/spy').Procedure>;
24
+ useLocation: () => {
25
+ pathname: string;
26
+ search: string;
27
+ hash: string;
28
+ state: null;
29
+ key: string;
30
+ };
31
+ useParams: () => {};
32
+ useSearchParams: () => (URLSearchParams | import('vitest').Mock<import('@vitest/spy').Procedure>)[];
33
+ Link: ({ children, to, ...props }: {
34
+ children: React.ReactNode;
35
+ to: string;
36
+ [key: string]: unknown;
37
+ }) => React.ReactElement<{
38
+ href: string;
39
+ }, string | React.JSXElementConstructor<any>>;
40
+ NavLink: ({ children, to, ...props }: {
41
+ children: React.ReactNode;
42
+ to: string;
43
+ [key: string]: unknown;
44
+ }) => React.ReactElement<{
45
+ href: string;
46
+ }, string | React.JSXElementConstructor<any>>;
47
+ Outlet: () => null;
48
+ Routes: ({ children }: {
49
+ children: React.ReactNode;
50
+ }) => React.ReactNode;
51
+ Route: () => null;
52
+ MemoryRouter: ({ children }: {
53
+ children: React.ReactNode;
54
+ }) => React.ReactNode;
55
+ BrowserRouter: ({ children }: {
56
+ children: React.ReactNode;
57
+ }) => React.ReactNode;
58
+ };
59
+ /**
60
+ * Parse URL search params helper
61
+ */
62
+ export declare const parseSearchParams: (search: string) => Record<string, string>;
@@ -0,0 +1,22 @@
1
+ import { RenderOptions, RenderResult, render } from '@testing-library/react';
2
+ import { ReactElement } from 'react';
3
+ import { MemoryRouterProps } from 'react-router-dom';
4
+ interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
5
+ routerProps?: MemoryRouterProps;
6
+ initialEntries?: string[];
7
+ }
8
+ /**
9
+ * Render with MemoryRouter wrapper
10
+ * Use this for components that need routing context
11
+ */
12
+ export declare const renderWithRouter: (ui: ReactElement, options?: CustomRenderOptions) => RenderResult;
13
+ /**
14
+ * Re-export common testing library utilities
15
+ */
16
+ export { act, fireEvent, screen, waitFor, within } from '@testing-library/react';
17
+ export { default as userEvent } from '@testing-library/user-event';
18
+ /**
19
+ * Simple render without providers
20
+ * Use this for pure components without dependencies
21
+ */
22
+ export { render };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Wait for loading spinner to disappear
3
+ */
4
+ export declare const waitForLoadingToFinish: (testId?: string) => Promise<void>;
5
+ /**
6
+ * Wait for loading text to disappear
7
+ */
8
+ export declare const waitForLoadingTextToFinish: (text?: RegExp) => Promise<void>;
9
+ /**
10
+ * Wait for element to appear then disappear
11
+ */
12
+ export declare const waitForElementToDisappear: (testId: string) => Promise<void>;
13
+ /**
14
+ * Wait for async state updates (useful after act())
15
+ */
16
+ export declare const waitForStateUpdate: () => Promise<void>;
17
+ /**
18
+ * Wait for navigation to be called with expected path
19
+ */
20
+ export declare const waitForNavigation: (expectedPath: string, navigate: ReturnType<typeof import("vitest").vi.fn>) => Promise<void>;
21
+ /**
22
+ * Wait for element to be visible
23
+ */
24
+ export declare const waitForElement: (testId: string, timeout?: number) => Promise<void>;
25
+ /**
26
+ * Wait for text to be visible
27
+ */
28
+ export declare const waitForText: (text: string | RegExp, timeout?: number) => Promise<void>;
29
+ /**
30
+ * Delay helper for tests that need explicit timing
31
+ */
32
+ export declare const delay: (ms: number) => Promise<unknown>;
33
+ /**
34
+ * Wait for fetch request to complete
35
+ */
36
+ export declare const waitForRequest: (timeout?: number) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ export interface AuthMobileShellProps {
3
+ appName?: string;
4
+ appLogo?: string;
5
+ brandColor?: string;
6
+ children: React.ReactNode;
7
+ }
8
+ export declare const AuthMobileShell: React.FC<AuthMobileShellProps>;
@@ -0,0 +1,30 @@
1
+ import { default as React } from 'react';
2
+ import { AuthConfig, LoginCredentials, PasswordResetConfirm, PasswordResetRequest, UserRole } from '../../types';
3
+ import { AuthApiResponse } from '../../types/common';
4
+ interface AuthContextValue {
5
+ user: Record<string, unknown> | null;
6
+ loading: boolean;
7
+ error: string | null;
8
+ login: (credentials: LoginCredentials) => Promise<AuthApiResponse>;
9
+ logout: () => Promise<void>;
10
+ selectRole: (role: UserRole) => Promise<Record<string, unknown>>;
11
+ checkAuth: () => Promise<void>;
12
+ processAuthResult: (response: Record<string, unknown>) => Record<string, unknown>;
13
+ forgotPassword: (data: {
14
+ email?: string;
15
+ phone?: string;
16
+ method: string;
17
+ }) => Promise<unknown>;
18
+ resetPassword: (data: PasswordResetRequest | PasswordResetConfirm) => Promise<unknown>;
19
+ isAuthenticated: boolean;
20
+ pendingAuth: AuthApiResponse | null;
21
+ availableRoles: unknown[] | null;
22
+ authConfig: Record<string, unknown> | null;
23
+ requiresRoleSelection: boolean;
24
+ }
25
+ export declare const useAuthContext: () => AuthContextValue;
26
+ export declare const AuthProvider: ({ children, config }: {
27
+ children: React.ReactNode;
28
+ config?: AuthConfig;
29
+ }) => React.JSX.Element;
30
+ export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { LoginCredentials } from '../../types';
3
+ import { AuthResponse } from '../utils/authFlowHandler';
4
+ interface DynamicLoginFormProps {
5
+ onLogin: (data: LoginCredentials | AuthResponse) => Promise<void>;
6
+ showRememberMe?: boolean;
7
+ }
8
+ export declare const DynamicLoginForm: React.FC<DynamicLoginFormProps>;
9
+ export {};
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ interface ForgotPasswordFormProps {
3
+ onSubmit: (data: {
4
+ email?: string;
5
+ phone?: string;
6
+ method: string;
7
+ }) => Promise<void>;
8
+ logo?: React.ReactNode;
9
+ }
10
+ export declare const ForgotPasswordForm: React.FC<ForgotPasswordFormProps>;
11
+ export {};
@@ -0,0 +1,7 @@
1
+ interface LoginFormProps {
2
+ onLogin?: (values: Record<string, unknown>) => Promise<void>;
3
+ showRememberMe?: boolean;
4
+ showForgotPassword?: boolean;
5
+ }
6
+ export declare const LoginForm: ({ onLogin, showRememberMe, showForgotPassword }: LoginFormProps) => import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,197 @@
1
+ import { default as React } from 'react';
2
+ import { ApiConfig, AuthResult } from '../../types';
3
+ interface LoginRouterProps {
4
+ basePath?: string;
5
+ apiConfig?: ApiConfig;
6
+ onAuthComplete?: (result: AuthResult) => void;
7
+ logo?: React.ReactNode;
8
+ title?: string;
9
+ subtitle?: string;
10
+ roleSelectionTitle?: string;
11
+ roleSelectionSubtitle?: string;
12
+ twoFactorTitle?: string;
13
+ twoFactorSubtitle?: string;
14
+ passwordResetTitle?: string;
15
+ passwordResetSubtitle?: string;
16
+ }
17
+ interface MockRole {
18
+ id: number;
19
+ name: string;
20
+ description: string;
21
+ permissions: string[];
22
+ is_default: boolean;
23
+ }
24
+ /** @internal Mock API config for development/testing — no-op in production */
25
+ export declare const createMockApiConfig: (_selectedScenario: unknown) => ReturnType<typeof _createMockApiConfig>;
26
+ declare function _createMockApiConfig(_selectedScenario: unknown): {
27
+ loginEndpoint: string;
28
+ logoutEndpoint: string;
29
+ verifyEndpoint: string;
30
+ forgotPasswordEndpoint: string;
31
+ resetPasswordEndpoint: string;
32
+ loginMethodsEndpoint: string;
33
+ otpRequestEndpoint: string;
34
+ otpVerifyEndpoint: string;
35
+ apiClient: {
36
+ post: (endpoint: string, data: Record<string, unknown>) => Promise<{
37
+ requires2FA?: boolean;
38
+ requiresPasswordReset?: boolean;
39
+ passwordResetReason?: string;
40
+ twoFactorMethods?: string[];
41
+ user: {
42
+ id: number;
43
+ username: string;
44
+ email: string;
45
+ mobile: string;
46
+ name: string;
47
+ };
48
+ token: string;
49
+ roles: MockRole[];
50
+ success?: undefined;
51
+ message?: undefined;
52
+ } | {
53
+ success: boolean;
54
+ message: string;
55
+ user?: undefined;
56
+ token?: undefined;
57
+ roles?: undefined;
58
+ requires2FA?: undefined;
59
+ twoFactorMethods?: undefined;
60
+ requiresPasswordReset?: undefined;
61
+ passwordResetReason?: undefined;
62
+ } | {
63
+ message: string;
64
+ success?: undefined;
65
+ user?: undefined;
66
+ token?: undefined;
67
+ roles?: undefined;
68
+ requires2FA?: undefined;
69
+ twoFactorMethods?: undefined;
70
+ requiresPasswordReset?: undefined;
71
+ passwordResetReason?: undefined;
72
+ } | {
73
+ requires2FA?: boolean;
74
+ requiresPasswordReset?: boolean;
75
+ passwordResetReason?: string;
76
+ twoFactorMethods?: string[];
77
+ success: boolean;
78
+ message?: undefined;
79
+ user?: undefined;
80
+ token?: undefined;
81
+ roles?: undefined;
82
+ } | {
83
+ user: {
84
+ id: number;
85
+ email: string;
86
+ name: string;
87
+ username: string;
88
+ };
89
+ token: string;
90
+ roles: MockRole[];
91
+ requires2FA: boolean;
92
+ twoFactorMethods: string[];
93
+ success?: undefined;
94
+ message?: undefined;
95
+ requiresPasswordReset?: undefined;
96
+ passwordResetReason?: undefined;
97
+ } | {
98
+ user: {
99
+ id: number;
100
+ email: string;
101
+ name: string;
102
+ username: string;
103
+ };
104
+ token: string;
105
+ requiresPasswordReset: boolean;
106
+ passwordResetReason: string;
107
+ success?: undefined;
108
+ message?: undefined;
109
+ roles?: undefined;
110
+ requires2FA?: undefined;
111
+ twoFactorMethods?: undefined;
112
+ } | {
113
+ user: {
114
+ id: number;
115
+ email: string;
116
+ name: string;
117
+ username: string;
118
+ };
119
+ token: string;
120
+ success?: undefined;
121
+ message?: undefined;
122
+ roles?: undefined;
123
+ requires2FA?: undefined;
124
+ twoFactorMethods?: undefined;
125
+ requiresPasswordReset?: undefined;
126
+ passwordResetReason?: undefined;
127
+ }>;
128
+ get: (endpoint: string) => Promise<{
129
+ success: boolean;
130
+ response: {
131
+ auth_config: {
132
+ login_methods: {
133
+ password: {
134
+ enabled: boolean;
135
+ forgot_password_enabled: boolean;
136
+ allowed_usernames: string[];
137
+ };
138
+ otp: {
139
+ enabled: boolean;
140
+ allowed_methods: string[];
141
+ };
142
+ sso: {
143
+ enabled: boolean;
144
+ providers: {
145
+ id: number;
146
+ label: string;
147
+ }[];
148
+ };
149
+ oidc: {
150
+ enabled: boolean;
151
+ };
152
+ };
153
+ password_policy: {
154
+ min_length: number;
155
+ require_numbers: boolean;
156
+ require_lowercase: boolean;
157
+ require_uppercase: boolean;
158
+ require_special_chars: boolean;
159
+ password_expiry_days: number;
160
+ password_history_count: number;
161
+ allow_change: boolean;
162
+ reset: {
163
+ enabled: boolean;
164
+ method: string[];
165
+ expiry_hours: number;
166
+ };
167
+ };
168
+ session_policy: {
169
+ remember_me_enabled: boolean;
170
+ remember_me_duration_days: number;
171
+ };
172
+ two_factor_auth: {
173
+ required: boolean;
174
+ allowed_methods: never[];
175
+ };
176
+ };
177
+ };
178
+ id?: undefined;
179
+ username?: undefined;
180
+ email?: undefined;
181
+ } | {
182
+ id: number;
183
+ username: string;
184
+ email: string;
185
+ success?: undefined;
186
+ response?: undefined;
187
+ } | {
188
+ success?: undefined;
189
+ response?: undefined;
190
+ id?: undefined;
191
+ username?: undefined;
192
+ email?: undefined;
193
+ }>;
194
+ };
195
+ };
196
+ export declare const LoginRouter: React.FC<LoginRouterProps>;
197
+ export {};
@@ -0,0 +1,19 @@
1
+ import { default as React } from 'react';
2
+ import { ApiConfig, AuthResult, PendingAuthResult } from '../../types';
3
+ interface OAuthCallbackProps {
4
+ onSuccess?: (result: AuthResult | PendingAuthResult) => void;
5
+ onError?: (error: Error) => void;
6
+ apiConfig?: ApiConfig;
7
+ redirectPath?: string;
8
+ title?: string;
9
+ errorTitle?: string;
10
+ logo?: React.ReactNode;
11
+ roleSelectionTitle?: string;
12
+ roleSelectionSubtitle?: string;
13
+ twoFactorTitle?: string;
14
+ twoFactorSubtitle?: string;
15
+ passwordResetTitle?: string;
16
+ passwordResetSubtitle?: string;
17
+ }
18
+ export declare const OAuthCallback: ({ onSuccess, onError, apiConfig, redirectPath, title, errorTitle, logo, roleSelectionTitle, roleSelectionSubtitle, twoFactorTitle, twoFactorSubtitle, passwordResetTitle, passwordResetSubtitle, }: OAuthCallbackProps) => React.JSX.Element;
19
+ export {};
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { AuthResponse } from '../utils/authFlowHandler';
3
+ interface OTPFormProps {
4
+ onSuccess: (result: AuthResponse) => void;
5
+ onBack?: () => void;
6
+ submitButtonText?: string;
7
+ verifyButtonText?: string;
8
+ resendButtonText?: string;
9
+ }
10
+ export declare const OTPForm: React.FC<OTPFormProps>;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ interface OTPInputProps {
2
+ length?: number;
3
+ value?: string;
4
+ onChange?: (value: string) => void;
5
+ disabled?: boolean;
6
+ }
7
+ export declare const OTPInput: ({ length, value, onChange, disabled }: OTPInputProps) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+ interface PasswordRules {
3
+ minLength: number;
4
+ maxLength?: number;
5
+ requireUppercase: boolean;
6
+ requireLowercase: boolean;
7
+ requireNumbers: boolean;
8
+ requireSpecialChars: boolean;
9
+ }
10
+ interface PasswordResetRequiredProps {
11
+ reason?: string;
12
+ onReset: (data: {
13
+ password: string;
14
+ confirmPassword: string;
15
+ }) => Promise<void>;
16
+ loading?: boolean;
17
+ title?: string;
18
+ subtitle?: string;
19
+ passwordRules?: PasswordRules;
20
+ logo?: React.ReactNode;
21
+ }
22
+ export declare const PasswordResetRequired: React.FC<PasswordResetRequiredProps>;
23
+ export {};
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ interface ProviderButtonProps {
3
+ provider: Record<string, unknown> & {
4
+ label?: string;
5
+ id?: string;
6
+ provider_type?: string;
7
+ url?: string;
8
+ icon_url?: string;
9
+ name?: string;
10
+ provider?: string;
11
+ };
12
+ type?: 'default' | 'sso' | 'oidc';
13
+ prefix?: string;
14
+ postfix?: string;
15
+ }
16
+ export declare const ProviderButton: ({ provider, type, prefix, postfix, }: ProviderButtonProps) => React.ReactElement;
17
+ export {};
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ interface ResetPasswordFormProps {
3
+ onSubmit: (data: {
4
+ password: string;
5
+ confirmPassword: string;
6
+ token: string;
7
+ }) => Promise<void>;
8
+ token: string;
9
+ logo?: React.ReactNode;
10
+ }
11
+ export declare const ResetPasswordForm: React.FC<ResetPasswordFormProps>;
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ interface Role {
3
+ id: string;
4
+ name: string;
5
+ description?: string;
6
+ permissions?: string[];
7
+ is_default?: boolean;
8
+ }
9
+ interface RoleSelectionUser {
10
+ id?: string;
11
+ name?: string;
12
+ username?: string;
13
+ email?: string;
14
+ }
15
+ interface RoleSelectionProps {
16
+ user?: RoleSelectionUser;
17
+ roles: Role[];
18
+ onRoleSelect: (role: Role) => Promise<void>;
19
+ loading?: boolean;
20
+ title?: string;
21
+ subtitle?: string;
22
+ logo?: React.ReactNode;
23
+ }
24
+ export declare const RoleSelection: React.FC<RoleSelectionProps>;
25
+ export {};
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ interface User {
3
+ id?: string;
4
+ name?: string;
5
+ username?: string;
6
+ email?: string;
7
+ mobile?: string;
8
+ }
9
+ interface SecondFactorAuthProps {
10
+ user?: User;
11
+ availableMethods?: ('sms' | 'email' | 'totp')[];
12
+ onVerify: (result: unknown) => Promise<void>;
13
+ loading?: boolean;
14
+ otpDigits?: number;
15
+ retryInterval?: number;
16
+ title?: string;
17
+ subtitle?: string;
18
+ logo?: React.ReactNode;
19
+ }
20
+ export declare const SecondFactorAuth: React.FC<SecondFactorAuthProps>;
21
+ export {};
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ interface OTPLoginFormProps {
3
+ onSuccess?: (data: unknown) => void;
4
+ onBack?: () => void;
5
+ submitButtonText?: string;
6
+ verifyButtonText?: string;
7
+ resendButtonText?: string;
8
+ }
9
+ /**
10
+ * OTPLoginForm - Composable component for OTP-based login
11
+ *
12
+ * Automatically handles:
13
+ * - OTP request and verification
14
+ * - Delegates multi-step authentication to parent via LoginContext or onSuccess
15
+ */
16
+ export declare const OTPLoginForm: React.FC<OTPLoginFormProps>;
17
+ export {};
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ interface PasswordLoginFormProps {
3
+ onSuccess?: (data: unknown) => void;
4
+ showRememberMe?: boolean;
5
+ submitButtonText?: string;
6
+ }
7
+ /**
8
+ * PasswordLoginForm - Composable component for password-based login
9
+ *
10
+ * Automatically handles:
11
+ * - Auth configuration loading
12
+ * - Email/mobile tabs based on allowed usernames
13
+ * - Form validation
14
+ * - Delegates multi-step authentication to parent via LoginContext or onSuccess
15
+ */
16
+ export declare const PasswordLoginForm: React.FC<PasswordLoginFormProps>;
17
+ export {};
@@ -0,0 +1,61 @@
1
+ import { default as React } from 'react';
2
+ export interface SSOButtonsProps {
3
+ /**
4
+ * Layout mode for multiple providers
5
+ * - 'column': Stack buttons vertically (default)
6
+ * - 'grid': Display in a responsive grid (2 columns on desktop, 1 on mobile)
7
+ * - 'row': Display side by side (horizontal)
8
+ *
9
+ * Note: Single button always takes full width regardless of layout
10
+ */
11
+ layout?: 'column' | 'grid' | 'row';
12
+ /**
13
+ * Gap between buttons (in Tailwind spacing units)
14
+ * @default 2 for column/row, 3 for grid
15
+ */
16
+ gap?: number;
17
+ /**
18
+ * Custom class name for the container
19
+ */
20
+ className?: string;
21
+ /**
22
+ * Prefix text for the provider buttons
23
+ * @default "Continue with"
24
+ */
25
+ buttonTextPrefix?: string;
26
+ /**
27
+ * Postfix text for the provider buttons
28
+ * @default ""
29
+ */
30
+ buttonTextPostfix?: string;
31
+ }
32
+ /**
33
+ * SSOButtons - Self-contained component that renders SSO/OIDC provider buttons
34
+ *
35
+ * This component automatically:
36
+ * - Fetches auth configuration from API
37
+ * - Checks if SSO/OIDC is enabled
38
+ * - Renders provider buttons if available
39
+ * - Handles OAuth/SAML redirects
40
+ * - Returns null if no providers are configured
41
+ * - Single button takes full width automatically
42
+ * - Multiple buttons can be laid out in column/grid/row
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * import { SSOButtons } from '@zango/auth/composable';
47
+ *
48
+ * // Default: Column layout
49
+ * <SSOButtons />
50
+ *
51
+ * // Grid layout (2 columns)
52
+ * <SSOButtons layout="grid" />
53
+ *
54
+ * // Row layout (side by side)
55
+ * <SSOButtons layout="row" />
56
+ *
57
+ * // Custom gap
58
+ * <SSOButtons layout="grid" gap={4} />
59
+ * ```
60
+ */
61
+ export declare const SSOButtons: React.FC<SSOButtonsProps>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Composable Authentication Components
3
+ *
4
+ * Self-contained, reusable components for building custom authentication flows.
5
+ * All components automatically fetch their configuration from the API and handle
6
+ * the complete authentication flow internally.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { SSOButtons, PasswordLoginForm, OTPLoginForm } from '@zango/auth/composable';
11
+ *
12
+ * // Custom login card with choice between SSO and password login
13
+ * function CustomLoginCard() {
14
+ * const [showPasswordForm, setShowPasswordForm] = useState(false);
15
+ *
16
+ * return (
17
+ * <div>
18
+ * {!showPasswordForm ? (
19
+ * <>
20
+ * <h2>Choose Login Method</h2>
21
+ * <SSOButtons />
22
+ * <button onClick={() => setShowPasswordForm(true)}>
23
+ * Normal Login
24
+ * </button>
25
+ * </>
26
+ * ) : (
27
+ * <>
28
+ * <PasswordLoginForm />
29
+ * <button onClick={() => setShowPasswordForm(false)}>Back</button>
30
+ * </>
31
+ * )}
32
+ * </div>
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ export { LoginContext, useLoginContext } from '../../contexts/LoginContext';
38
+ export { PasswordResetRequired } from '../PasswordResetRequired';
39
+ export { RoleSelection } from '../RoleSelection';
40
+ export { OTPLoginForm } from './OTPLoginForm';
41
+ export { PasswordLoginForm } from './PasswordLoginForm';
42
+ export { SSOButtons } from './SSOButtons';