doct-ui-auth-kit 1.0.13 → 1.0.15
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.
- package/dist/adapters/http-auth-adapter.d.ts +13 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/auth/index.d.ts +28 -0
- package/dist/auth-methods/apple.d.ts +19 -0
- package/dist/auth-methods/google.d.ts +5 -0
- package/dist/auth-methods/index.d.ts +2 -0
- package/dist/auth-methods/use-google-auth.d.ts +69 -0
- package/dist/components/common/back-button.d.ts +13 -0
- package/dist/components/common/default-footer.d.ts +5 -0
- package/dist/components/form/rhf-doct-phone-input.d.ts +2 -0
- package/dist/components/form/rhf-input-field.d.ts +2 -0
- package/dist/components/form/rhf-otp-input-field.d.ts +3 -0
- package/dist/components/layout/auth-layout-preset.d.ts +30 -0
- package/dist/components/layout/auth-layout-public.d.ts +17 -0
- package/dist/components/layout/auth-layout-wrapper.d.ts +42 -0
- package/dist/components/layout/auth-layout.d.ts +89 -0
- package/dist/components/layout/image-slider.d.ts +28 -0
- package/dist/components/layout/index.d.ts +8 -0
- package/dist/components/layout/main-layout.d.ts +30 -0
- package/dist/constants/brand.d.ts +9 -0
- package/dist/constants/demo-slider.d.ts +14 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/layout-classes.d.ts +10 -0
- package/dist/constants/layout-presets.d.ts +10 -0
- package/dist/core/auth-api-adapter.d.ts +6 -0
- package/dist/core/auth-context.d.ts +21 -0
- package/dist/core/auth-flow.d.ts +1 -1
- package/dist/core/auth-provider.d.ts +8 -0
- package/dist/core/auth-types.d.ts +5 -0
- package/dist/core/device-detection.d.ts +19 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/sso-session.d.ts +35 -0
- package/dist/core/use-auth-flow-router-sync.d.ts +1 -1
- package/dist/core/use-auth-flow.d.ts +9 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/use-login-entry-form.d.ts +12 -0
- package/dist/hooks/use-main-auth-page-handlers.d.ts +9 -0
- package/dist/hooks/use-otp-verification.d.ts +3 -3
- package/dist/hooks/use-repeat-login.d.ts +9 -0
- package/dist/hooks/use-signup-form.d.ts +12 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +321 -313
- package/dist/pages/index.d.ts +8 -0
- package/dist/pages/login-entry/index.d.ts +3 -0
- package/dist/pages/login-entry/login-entry-page.d.ts +21 -0
- package/dist/pages/login-entry/login-entry.d.ts +21 -0
- package/dist/pages/main-login/index.d.ts +3 -0
- package/dist/pages/main-login/main-login-page.d.ts +16 -0
- package/dist/pages/main-login/main-login.d.ts +25 -0
- package/dist/pages/otp-verification/index.d.ts +3 -0
- package/dist/pages/otp-verification/otp-verification-page.d.ts +23 -0
- package/dist/pages/otp-verification/otp-verification.d.ts +22 -0
- package/dist/pages/repeat-login/index.d.ts +3 -0
- package/dist/pages/repeat-login/repeat-login-page.d.ts +24 -0
- package/dist/pages/repeat-login/repeat-login.d.ts +25 -0
- package/dist/pages/signup/index.d.ts +3 -0
- package/dist/pages/signup/signup-page.d.ts +6 -0
- package/dist/pages/signup/signup.d.ts +7 -0
- package/dist/pages.js +1 -1
- package/dist/{signup-page-ChXnxtSS.js → signup-page-LsYojX4-.js} +43 -38
- package/dist/types/auth/auth-api-adapter.d.ts +57 -0
- package/dist/types/auth/auth-provider.d.ts +40 -0
- package/dist/types/auth/auth-types.d.ts +70 -0
- package/dist/types/auth/device-detection.d.ts +13 -0
- package/dist/types/auth/flow.d.ts +133 -0
- package/dist/types/auth/index.d.ts +10 -0
- package/dist/types/auth/router.d.ts +60 -0
- package/dist/types/auth/sso-session.d.ts +33 -0
- package/dist/types/components/auth-layout-types.d.ts +92 -0
- package/dist/types/components/forms.d.ts +77 -0
- package/dist/types/components/index.d.ts +7 -0
- package/dist/types/components/layout-presets.d.ts +29 -0
- package/dist/types/components/layout.d.ts +57 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/pages/index.d.ts +9 -0
- package/dist/types/pages/login-form.d.ts +57 -0
- package/dist/types/pages/otp-verification.d.ts +1 -1
- package/dist/types/pages/repeat-login.d.ts +29 -0
- package/dist/types/pages/signup-form.d.ts +49 -0
- package/dist/utils/build-phone-recipient.d.ts +12 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/set-form-errors-from-zod.d.ts +11 -0
- package/dist/validations/index.d.ts +6 -0
- package/dist/validations/schemas.d.ts +87 -0
- package/package.json +110 -109
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference HTTP adapter for connecting to a real auth API (e.g. doct-auth-mock-api).
|
|
3
|
+
* Consumers can use this adapter directly or create their own implementing `AuthApiAdapter`.
|
|
4
|
+
* Usage: `SSOAuthProvider config={{ apiAdapter: createHttpAuthAdapter('http://localhost:3001') }}`
|
|
5
|
+
*/
|
|
6
|
+
import type { AuthApiAdapter } from '../core/auth-api-adapter';
|
|
7
|
+
/**
|
|
8
|
+
* Creates an AuthApiAdapter that calls the given API base URL.
|
|
9
|
+
* Expects routes: POST /api/auth/send-otp, verify-otp, complete-profile,
|
|
10
|
+
* authenticate-provider, validate-session, refresh-session; GET validate-session
|
|
11
|
+
* (with credentials) for validateSessionFromCookie.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createHttpAuthAdapter(baseUrl: string): AuthApiAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createHttpAuthAdapter } from './http-auth-adapter';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Auth API — `Auth.Provider` / `Auth.Login` / `Auth.Signup` / `Auth.Otp`.
|
|
3
|
+
* Less flexible but zero-config for basic usage. For full control, use
|
|
4
|
+
* SSOAuthProvider + individual page components directly.
|
|
5
|
+
*/
|
|
6
|
+
import { SSOAuthProvider } from '../core/auth-provider';
|
|
7
|
+
import type { OtpVerificationProps } from '../pages/otp-verification';
|
|
8
|
+
import type { SignupPageProps } from '../pages/signup';
|
|
9
|
+
/** Simple API: full login/signup flow (method select → identifier → OTP → profile). Use inside Auth.Provider. */
|
|
10
|
+
declare function AuthLogin(): React.ReactElement;
|
|
11
|
+
/** Simple API: signup (profile completion) screen with signup layout preset. Layout only; pass props for behavior. */
|
|
12
|
+
declare function AuthSignup(props: SignupPageProps): React.ReactElement;
|
|
13
|
+
/** Simple API: OTP verification screen with verification layout preset. Layout only; pass props for behavior. */
|
|
14
|
+
declare function AuthOtp(props: OtpVerificationProps): React.ReactElement;
|
|
15
|
+
/**
|
|
16
|
+
* Auth SDK simple + namespace API.
|
|
17
|
+
* - Auth.Provider: config (methods, MFA, rememberMe, apiAdapter, callbacks).
|
|
18
|
+
* - Auth.Login: full flow (simple).
|
|
19
|
+
* - Auth.Signup: signup screen with signup preset (simple).
|
|
20
|
+
* - Auth.Otp: OTP screen with verification preset (simple).
|
|
21
|
+
*/
|
|
22
|
+
export declare const Auth: {
|
|
23
|
+
Provider: typeof SSOAuthProvider;
|
|
24
|
+
Login: typeof AuthLogin;
|
|
25
|
+
Signup: typeof AuthSignup;
|
|
26
|
+
Otp: typeof AuthOtp;
|
|
27
|
+
};
|
|
28
|
+
export type { SignupPageProps, OtpVerificationProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Sign-In (future-ready stub).
|
|
3
|
+
* Implement when backend supports Apple ID credential validation.
|
|
4
|
+
*/
|
|
5
|
+
export interface UseAppleSignInOptions {
|
|
6
|
+
/** Apple client ID (Services ID). */
|
|
7
|
+
clientId: string;
|
|
8
|
+
/** Redirect URI registered in Apple Developer. */
|
|
9
|
+
redirectUri: string;
|
|
10
|
+
/** Callback when user signs in; receives the authorization code or id_token. */
|
|
11
|
+
onCredential: (credential: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Stub: Apple Sign-In hook. Not implemented yet.
|
|
15
|
+
* Use adapter.authenticateWithProvider({ provider: 'apple', credential }) when you have the token.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useAppleSignIn(options: UseAppleSignInOptions): {
|
|
18
|
+
triggerSignIn: () => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** GSI callback payload when user signs in. */
|
|
2
|
+
interface CredentialResponse {
|
|
3
|
+
credential: string;
|
|
4
|
+
}
|
|
5
|
+
/** OAuth2 Code Client callback payload (popup mode). */
|
|
6
|
+
interface CodeResponse {
|
|
7
|
+
code: string;
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
google?: {
|
|
12
|
+
accounts: {
|
|
13
|
+
id: {
|
|
14
|
+
initialize: (config: {
|
|
15
|
+
client_id: string;
|
|
16
|
+
callback: (response: CredentialResponse) => void;
|
|
17
|
+
auto_select?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* When false, avoids using FedCM for One Tap prompts (helps when FedCM is
|
|
20
|
+
* disabled via browser/site settings).
|
|
21
|
+
*/
|
|
22
|
+
use_fedcm_for_prompt?: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
prompt: (momentListener?: (moment: {
|
|
25
|
+
getMomentType: () => string;
|
|
26
|
+
}) => void) => void;
|
|
27
|
+
};
|
|
28
|
+
oauth2: {
|
|
29
|
+
initCodeClient: (config: {
|
|
30
|
+
client_id: string;
|
|
31
|
+
scope: string;
|
|
32
|
+
ux_mode: 'popup';
|
|
33
|
+
callback: (response: CodeResponse) => void;
|
|
34
|
+
error_callback?: (error: {
|
|
35
|
+
type: string;
|
|
36
|
+
message?: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
}) => {
|
|
39
|
+
requestCode: () => void;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export interface UseGoogleAuthOptions {
|
|
47
|
+
/** Google OAuth 2.0 client ID. Hook is a no-op when empty. */
|
|
48
|
+
clientId: string;
|
|
49
|
+
/**
|
|
50
|
+
* Called with a Google credential suitable for backend verification.
|
|
51
|
+
*
|
|
52
|
+
* - **One Tap** returns an **ID token**.
|
|
53
|
+
* - **Button click** uses OAuth popup and returns an **authorization code**.
|
|
54
|
+
*
|
|
55
|
+
* Your backend should verify/exchange this value for a session.
|
|
56
|
+
*/
|
|
57
|
+
onCredential: (credential: string) => void;
|
|
58
|
+
/** When true, shows One Tap prompt automatically after init. Default false. */
|
|
59
|
+
enableOneTap?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface UseGoogleAuthReturn {
|
|
62
|
+
/**
|
|
63
|
+
* Opens the Google sign-in popup (OAuth code flow).
|
|
64
|
+
* Intended for use with a custom "Continue with Google" button.
|
|
65
|
+
*/
|
|
66
|
+
loginWithGoogle: () => Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export declare function useGoogleAuth({ clientId, onCredential, enableOneTap, }: UseGoogleAuthOptions): UseGoogleAuthReturn;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Props for the shared auth back button. */
|
|
2
|
+
export interface BackButtonProps {
|
|
3
|
+
/** Click handler that navigates the user back. */
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
/** Optional aria-label override. @default 'Go back' */
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Outlined square back button used at the top of auth pages
|
|
10
|
+
* (LoginEntry, OtpVerification, etc.). 36px box with a 20px arrow,
|
|
11
|
+
* 2px neutral-10 border and 10px radius — matches Figma spec.
|
|
12
|
+
*/
|
|
13
|
+
export declare function BackButton({ onClick, ariaLabel, }: Readonly<BackButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { RHFDoctPhoneInputFieldProps } from '../../types/components/forms';
|
|
2
|
+
export declare function RHFDoctPhoneInputField({ name, label, countryCode, countryCodeName, phoneArrayName, selectedCountryName, countries, defaultCountry, onValuesChange, onCountryChange, onCountryCodeChange, placeholder, disabled, required, className, helperText, control, ...doctPhoneInputProps }: Readonly<RHFDoctPhoneInputFieldProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { RHFInputFieldProps } from '../../types/components/forms';
|
|
2
|
+
export declare function RHFInputField({ name, label, placeholder, className, control, required, type, disabled, onKeyDown, maxLength, numericOnly, autoFocus, }: RHFInputFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RHFOtpInputFieldProps } from '../../types/components/forms';
|
|
2
|
+
/** RHF-controlled wrapper around `DoctOtpInput` from docthub-core-components. Manages a string[] field value for OTP digit inputs. */
|
|
3
|
+
export declare function RHFOtpInputField({ name, label, className, control, length, inputClassName, autoFocus, }: RHFOtpInputFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { LayoutPresetName } from '../../types/components/layout-presets';
|
|
3
|
+
export interface AuthLayoutPresetProps {
|
|
4
|
+
/**
|
|
5
|
+
* Preset name. Controls structure only (layoutType, variant, maxWidth, contentWidth, align).
|
|
6
|
+
* Use "" for no preset (children rendered as-is; use AuthLayout.Root for full composition).
|
|
7
|
+
*/
|
|
8
|
+
preset: LayoutPresetName;
|
|
9
|
+
/** Main content (e.g. form). Rendered in layout body. */
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** Optional slot overrides. When not provided, slot is empty. */
|
|
12
|
+
logo?: ReactNode;
|
|
13
|
+
/** Title element or string rendered below the logo. */
|
|
14
|
+
title?: ReactNode;
|
|
15
|
+
/** Description element or string rendered below the title. */
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
/** Footer element rendered at the bottom of the layout. */
|
|
18
|
+
footer?: ReactNode;
|
|
19
|
+
/** Header element rendered above the main content area. */
|
|
20
|
+
header?: ReactNode;
|
|
21
|
+
/** Custom back button element rendered in place of the logo slot. */
|
|
22
|
+
backButton?: ReactNode;
|
|
23
|
+
/** Extra class for root. */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Layout shell driven by a preset. Structure only — no auth logic.
|
|
28
|
+
* Use for advanced usage when you need a consistent layout without wiring AuthFlow.
|
|
29
|
+
*/
|
|
30
|
+
export declare function AuthLayoutPreset({ preset, children, logo, title, description, footer, header, backButton, className, }: AuthLayoutPresetProps): React.ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public AuthLayout API: compound components + preset-based layout.
|
|
3
|
+
* Merged here to avoid circular dependencies (preset uses wrapper, wrapper uses compound).
|
|
4
|
+
*/
|
|
5
|
+
import { AuthLayoutPreset } from './auth-layout-preset';
|
|
6
|
+
/** Compound layout + preset-based layout. Use .Root/.Header/... for composition, .Preset for preset. */
|
|
7
|
+
export declare const AuthLayout: {
|
|
8
|
+
Preset: typeof AuthLayoutPreset;
|
|
9
|
+
Root: ({ children, variant, maxWidth, className, }: Readonly<import(".").AuthLayoutRootProps>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
Header: ({ children, className, }: Readonly<import(".").AuthLayoutHeaderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
Main: ({ children, sm, className, }: Readonly<import(".").AuthLayoutMainProps>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
Logo: ({ children, align, className, }: Readonly<import(".").AuthLayoutLogoProps>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
Title: ({ children, align, className, }: Readonly<import(".").AuthLayoutTitleProps>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
Description: ({ children, align, className, }: Readonly<import(".").AuthLayoutDescriptionProps>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
Body: ({ children, className, }: Readonly<import(".").AuthLayoutBodyProps>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
Footer: ({ children, className, }: Readonly<import(".").AuthLayoutFooterProps>) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { AuthLayoutAlign, AuthLayoutMaxWidth, AuthLayoutVariant } from '../../types/components/auth-layout-types';
|
|
3
|
+
/** Layout mode: `'withSlider'` renders inside a split-screen with an image slider, `'standalone'` renders without. */
|
|
4
|
+
export type AuthLayoutType = 'withSlider' | 'standalone';
|
|
5
|
+
/** Props for the AuthLayoutWrapper component that assembles the auth page shell. */
|
|
6
|
+
export interface AuthLayoutWrapperProps {
|
|
7
|
+
/** Main content (typically the form body) rendered inside the layout. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Layout mode controlling the outer chrome. @default `'withSlider'` */
|
|
10
|
+
layoutType?: AuthLayoutType;
|
|
11
|
+
/** Logo or back-button element rendered at the top of the content area. */
|
|
12
|
+
logo?: ReactNode;
|
|
13
|
+
/** Heading element or string rendered below the logo. */
|
|
14
|
+
title?: ReactNode;
|
|
15
|
+
/** Descriptive text or element rendered below the title. */
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
/** Footer element rendered at the bottom of the content area. */
|
|
18
|
+
footer?: ReactNode;
|
|
19
|
+
/** Header element rendered above the main content area. */
|
|
20
|
+
header?: ReactNode;
|
|
21
|
+
/** Called when the back button is clicked. Pass `null` to hide the back button explicitly. */
|
|
22
|
+
onBack?: (() => void) | null;
|
|
23
|
+
/** Custom back button element. When provided, overrides the default back arrow button. */
|
|
24
|
+
backButton?: ReactNode;
|
|
25
|
+
/** Image URLs for the slider panel (only used when `layoutType` is `'withSlider'`). */
|
|
26
|
+
sliderImages?: string[];
|
|
27
|
+
/** Auto-play interval in milliseconds for the slider. */
|
|
28
|
+
sliderAutoPlayInterval?: number;
|
|
29
|
+
/** Titles displayed alongside each slider image. */
|
|
30
|
+
sliderTitles?: (ReactNode | string)[];
|
|
31
|
+
/** Layout variant controlling responsive behavior (e.g. `'desktop'`, `'mobile'`). */
|
|
32
|
+
variant?: AuthLayoutVariant | undefined;
|
|
33
|
+
/** Maximum width constraint for the content area (e.g. `'sm'`, `'md'`, `'lg'`). @default `'sm'` */
|
|
34
|
+
maxWidth?: AuthLayoutMaxWidth;
|
|
35
|
+
/** Content width preset: `'sm'` for narrow forms, `'default'` for standard width. @default `'default'` */
|
|
36
|
+
contentWidth?: 'sm' | 'default';
|
|
37
|
+
/** Horizontal alignment of logo, title, and description. @default `'center'` */
|
|
38
|
+
align?: AuthLayoutAlign;
|
|
39
|
+
/** Additional CSS class name(s) applied to the outermost layout element. */
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare function AuthLayoutWrapper({ children, layoutType, logo, title, description, footer, header, onBack, backButton, sliderImages, sliderAutoPlayInterval, sliderTitles, variant, maxWidth, contentWidth, align, className, }: AuthLayoutWrapperProps): React.ReactElement;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { AuthLayoutBodyProps, AuthLayoutDescriptionProps, AuthLayoutFooterProps, AuthLayoutHeaderProps, AuthLayoutLogoProps, AuthLayoutMainProps, AuthLayoutRootProps, AuthLayoutTitleProps } from '../../types/components/auth-layout-types';
|
|
2
|
+
/**
|
|
3
|
+
* Root container component for auth layouts.
|
|
4
|
+
* Provides layout context to child slot components.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <AuthLayout.Root variant="desktop" maxWidth="md">
|
|
9
|
+
* <AuthLayout.Header>...</AuthLayout.Header>
|
|
10
|
+
* <AuthLayout.Logo>...</AuthLayout.Logo>
|
|
11
|
+
* <AuthLayout.Title>...</AuthLayout.Title>
|
|
12
|
+
* <AuthLayout.Description>...</AuthLayout.Description>
|
|
13
|
+
* <AuthLayout.Body>...</AuthLayout.Body>
|
|
14
|
+
* <AuthLayout.Footer>...</AuthLayout.Footer>
|
|
15
|
+
* </AuthLayout.Root>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function AuthLayoutRoot({ children, variant, maxWidth, className, }: Readonly<AuthLayoutRootProps>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* Header slot component - renders differently based on layout variant.
|
|
21
|
+
* In desktop variant, renders top-right. In mobile variant, renders above logo.
|
|
22
|
+
*/
|
|
23
|
+
declare function AuthLayoutHeader({ children, className, }: Readonly<AuthLayoutHeaderProps>): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Logo slot component - alignment configurable via align prop
|
|
26
|
+
*/
|
|
27
|
+
declare function AuthLayoutLogo({ children, align, className, }: Readonly<AuthLayoutLogoProps>): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* Title slot component - alignment configurable via align prop
|
|
30
|
+
*/
|
|
31
|
+
declare function AuthLayoutTitle({ children, align, className, }: Readonly<AuthLayoutTitleProps>): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Description slot component - alignment configurable via align prop
|
|
34
|
+
*/
|
|
35
|
+
declare function AuthLayoutDescription({ children, align, className, }: Readonly<AuthLayoutDescriptionProps>): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
/**
|
|
37
|
+
* Body slot component - main content area with vertical spacing
|
|
38
|
+
*/
|
|
39
|
+
declare function AuthLayoutBody({ children, className, }: Readonly<AuthLayoutBodyProps>): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* Main content wrapper - centers and constrains width of inner slots
|
|
42
|
+
*/
|
|
43
|
+
declare function AuthLayoutMain({ children, sm, className, }: Readonly<AuthLayoutMainProps>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
/**
|
|
45
|
+
* Footer slot component - centered with consistent spacing
|
|
46
|
+
*/
|
|
47
|
+
declare function AuthLayoutFooter({ children, className, }: Readonly<AuthLayoutFooterProps>): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
/**
|
|
49
|
+
* Compound component for authentication layouts.
|
|
50
|
+
* Uses composition pattern for maximum flexibility and scalability.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <AuthLayout.Root variant="desktop" maxWidth="md">
|
|
55
|
+
* <AuthLayout.Header>
|
|
56
|
+
* <EnterpriseHeader />
|
|
57
|
+
* </AuthLayout.Header>
|
|
58
|
+
* <AuthLayout.Main>
|
|
59
|
+
* <AuthLayout.Logo>
|
|
60
|
+
* <img src="/logo.svg" alt="Docthub" />
|
|
61
|
+
* </AuthLayout.Logo>
|
|
62
|
+
* <AuthLayout.Title>
|
|
63
|
+
* <h1>The Healthcare Career App</h1>
|
|
64
|
+
* </AuthLayout.Title>
|
|
65
|
+
* <AuthLayout.Description>
|
|
66
|
+
* <p>Continue to Signup</p>
|
|
67
|
+
* </AuthLayout.Description>
|
|
68
|
+
* <AuthLayout.Body>
|
|
69
|
+
* <button>Continue with Mobile</button>
|
|
70
|
+
* <button>Continue with Email</button>
|
|
71
|
+
* </AuthLayout.Body>
|
|
72
|
+
* </AuthLayout.Main>
|
|
73
|
+
* <AuthLayout.Footer>
|
|
74
|
+
* <p>Terms and Privacy</p>
|
|
75
|
+
* </AuthLayout.Footer>
|
|
76
|
+
* </AuthLayout.Root>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare const AuthLayout: {
|
|
80
|
+
Root: typeof AuthLayoutRoot;
|
|
81
|
+
Header: typeof AuthLayoutHeader;
|
|
82
|
+
Main: typeof AuthLayoutMain;
|
|
83
|
+
Logo: typeof AuthLayoutLogo;
|
|
84
|
+
Title: typeof AuthLayoutTitle;
|
|
85
|
+
Description: typeof AuthLayoutDescription;
|
|
86
|
+
Body: typeof AuthLayoutBody;
|
|
87
|
+
Footer: typeof AuthLayoutFooter;
|
|
88
|
+
};
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ImageSliderProps } from '../../types';
|
|
2
|
+
export type { ImageSliderProps } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Image slider component with indicator dots.
|
|
5
|
+
* Supports both controlled and uncontrolled modes.
|
|
6
|
+
*
|
|
7
|
+
* @example Uncontrolled mode (manages its own state)
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <ImageSlider
|
|
10
|
+
* images={['/image1.jpg', '/image2.jpg']}
|
|
11
|
+
* autoPlayInterval={3000}
|
|
12
|
+
* onSlideChange={(index) => console.log('Slide changed to', index)}
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example Controlled mode (parent manages state)
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const [activeIndex, setActiveIndex] = useState(0);
|
|
19
|
+
*
|
|
20
|
+
* <ImageSlider
|
|
21
|
+
* images={['/image1.jpg', '/image2.jpg']}
|
|
22
|
+
* activeIndex={activeIndex}
|
|
23
|
+
* onSlideChange={setActiveIndex}
|
|
24
|
+
* onNavigate={setActiveIndex}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function ImageSlider({ images, autoPlayInterval, className, hideIndicators, onSlideChange, activeIndex: controlledIndex, onNavigate, }: Readonly<ImageSliderProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { AuthLayoutAlign, AuthLayoutBodyProps, AuthLayoutDescriptionProps, AuthLayoutFooterProps, AuthLayoutHeaderProps, AuthLayoutLogoProps, AuthLayoutMainProps, AuthLayoutMaxWidth, AuthLayoutRootProps, AuthLayoutTitleProps, AuthLayoutVariant, } from '../../types/components/auth-layout-types';
|
|
2
|
+
export { AuthLayoutPreset, type AuthLayoutPresetProps, } from './auth-layout-preset';
|
|
3
|
+
export { AuthLayout } from './auth-layout-public';
|
|
4
|
+
export { type AuthLayoutType, AuthLayoutWrapper, type AuthLayoutWrapperProps, } from './auth-layout-wrapper';
|
|
5
|
+
export type { ImageSliderProps } from './image-slider';
|
|
6
|
+
export { ImageSlider } from './image-slider';
|
|
7
|
+
export type { MainLayoutProps } from './main-layout';
|
|
8
|
+
export { MainLayout } from './main-layout';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MainLayoutProps, MarketingPanelProps } from '../../types';
|
|
2
|
+
export type { MainLayoutProps, MarketingPanelProps } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Marketing panel component - displays CTA, image slider, and indicators
|
|
5
|
+
*/
|
|
6
|
+
declare function MarketingPanel({ sliderImages, sliderAutoPlayInterval, activeSlideIndex, onSlideChange, ctaText, sliderTitles, className, }: Readonly<MarketingPanelProps>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* Main layout component - two-panel layout for authentication pages.
|
|
9
|
+
* Left panel displays marketing content, right panel displays auth content.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <MainLayout
|
|
14
|
+
* sliderImages={['/image1.jpg', '/image2.jpg']}
|
|
15
|
+
* ctaText="Get Healthcare Career App Now!"
|
|
16
|
+
* >
|
|
17
|
+
* <AuthLayout.Root variant="desktop" maxWidth="md">
|
|
18
|
+
* <AuthLayout.Header>...</AuthLayout.Header>
|
|
19
|
+
* <AuthLayout.Main>
|
|
20
|
+
* <AuthLayout.Logo>...</AuthLayout.Logo>
|
|
21
|
+
* <AuthLayout.Title>...</AuthLayout.Title>
|
|
22
|
+
* <AuthLayout.Body>...</AuthLayout.Body>
|
|
23
|
+
* </AuthLayout.Main>
|
|
24
|
+
* <AuthLayout.Footer>...</AuthLayout.Footer>
|
|
25
|
+
* </AuthLayout.Root>
|
|
26
|
+
* </MainLayout>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function MainLayout({ sliderImages, sliderAutoPlayInterval, ctaText, sliderTitles, className, marketingClassName, contentClassName, children, }: Readonly<MainLayoutProps>): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export { MarketingPanel };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand asset paths used by auth pages.
|
|
3
|
+
* Consumers can serve these from their own /public directory or override
|
|
4
|
+
* the asset by replacing the file.
|
|
5
|
+
*/
|
|
6
|
+
/** Primary Docthub wordmark used in the auth page header. */
|
|
7
|
+
export declare const BRAND_LOGO_URL = "/main-logo.svg";
|
|
8
|
+
/** Compact Docthub mark used on the signup page. */
|
|
9
|
+
export declare const SIGNUP_LOGO_URL = "/docthub.svg";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Demo data for MainLayout marketing slider.
|
|
3
|
+
* Used in Storybook and anywhere a consistent demo slider is needed.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Marketing slider images exported from Figma.
|
|
7
|
+
* These are static PNG images saved in /public/slider/.
|
|
8
|
+
*
|
|
9
|
+
* To update: Export frames from Figma (nodes 2179:2215, 2179:2226, 2179:2236, 2179:2246, 2179:2256)
|
|
10
|
+
* and save as slide-1.png through slide-5.png in the public/slider/ directory.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEMO_SLIDER_IMAGES: string[];
|
|
13
|
+
/** Default auto-play interval (ms) for the demo slider. */
|
|
14
|
+
export declare const DEMO_SLIDER_AUTO_PLAY_INTERVAL = 5000;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared layout className overrides used by multiple auth pages.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Top-anchors the AuthLayout `<main>` content on screens where the form should
|
|
6
|
+
* stick to the top (per Figma 1721:4649 / 1721:4942: ~20px top on mobile,
|
|
7
|
+
* ~104px on desktop) instead of being vertically centered. Targets the inner
|
|
8
|
+
* `<main>` element rendered by AuthLayout.Main without modifying the wrapper.
|
|
9
|
+
*/
|
|
10
|
+
export declare const AUTH_TOP_ANCHORED_MAIN_CLASS = "[&_main]:!justify-start [&_main]:!pt-5 md:[&_main]:!pt-[104px]";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout preset configurations. Structure only — no auth behavior.
|
|
3
|
+
* Used by AuthLayout when preset="login" | "signup" | "verification".
|
|
4
|
+
*/
|
|
5
|
+
import type { LayoutPresetConfig, LayoutPresetName } from '../types/components/layout-presets';
|
|
6
|
+
/**
|
|
7
|
+
* Returns layout structure config for a preset name.
|
|
8
|
+
* Empty string returns undefined (caller uses full composition / no preset).
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLayoutPresetConfig(preset: LayoutPresetName): LayoutPresetConfig | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API adapter interface for the SSO auth SDK.
|
|
3
|
+
* Consumers implement this to connect the SDK to their central auth service.
|
|
4
|
+
* The SDK never performs HTTP calls directly.
|
|
5
|
+
*/
|
|
6
|
+
export type { AuthApiAdapter, CheckIdentifierParams, CheckIdentifierResponse, SendOtpParams, VerifyOtpParams, } from '../types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth context: provides `useAuthFlow` (full state + actions) and `useAuthSession` (session-only)
|
|
3
|
+
* hooks for consumers. Must be used within an `SSOAuthProvider` tree.
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthFlowContextValue } from '../types';
|
|
6
|
+
export type { AuthFlowActions, AuthFlowContextValue, AuthFlowProviderConfig, } from '../types';
|
|
7
|
+
export declare const AuthFlowContext: import("react").Context<AuthFlowContextValue | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Hook to access auth flow state and actions. Must be used within SSOAuthProvider.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useAuthFlow(): AuthFlowContextValue;
|
|
12
|
+
/**
|
|
13
|
+
* Hook to access SSO session state only. Must be used within SSOAuthProvider.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useAuthSession(): {
|
|
16
|
+
session: import("../types").SSOSession | null;
|
|
17
|
+
isAuthenticated: boolean;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
signOut: () => void;
|
|
20
|
+
authMethod: import("../types").AuthMethod | null;
|
|
21
|
+
};
|
package/dist/core/auth-flow.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SSOAuthProviderProps } from '../types';
|
|
2
|
+
export type { SSOAuthConfig, SSOAuthProviderProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* SSO Auth provider: manages the auth flow state machine and provides context to all child components.
|
|
5
|
+
* On mount, checks for an existing session (token or cookie-based via `validateSessionFromCookie`).
|
|
6
|
+
* Dispatches reducer actions and exposes async `AuthFlowActions` for each auth step.
|
|
7
|
+
*/
|
|
8
|
+
export declare function SSOAuthProvider({ config, children }: SSOAuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export of auth domain types from central types folder.
|
|
3
|
+
* Prefer importing from @/types; this file keeps @/core/auth-types working.
|
|
4
|
+
*/
|
|
5
|
+
export type { AuthError, AuthErrorCode, AuthenticateWithProviderParams, AuthMethod, AuthStep, CompleteProfileParams, RepeatLoginInfo, SendOtpResponse, SSOSession, SSOUser, UserType, VerifyOtpResponse, } from '../types';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device-based repeat login detection.
|
|
3
|
+
* Stores last-used method and masked identifier in localStorage (device-local UX only).
|
|
4
|
+
*/
|
|
5
|
+
import type { StoredRepeatLogin } from '../types';
|
|
6
|
+
export type { StoredRepeatLogin } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Reads repeat-login info from localStorage if present.
|
|
9
|
+
* Safe to call in browser; returns null in SSR or when not found.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRepeatLoginInfo(): StoredRepeatLogin | null;
|
|
12
|
+
/**
|
|
13
|
+
* Saves repeat-login info to localStorage after successful auth.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setRepeatLoginInfo(info: StoredRepeatLogin): void;
|
|
16
|
+
/**
|
|
17
|
+
* Clears repeat-login info (e.g. on sign out).
|
|
18
|
+
*/
|
|
19
|
+
export declare function clearRepeatLoginInfo(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSO Auth SDK core: types, adapter, provider, flow, session, device detection.
|
|
3
|
+
*/
|
|
4
|
+
export * from './auth-api-adapter';
|
|
5
|
+
export * from './auth-context';
|
|
6
|
+
export * from './auth-flow';
|
|
7
|
+
export * from './auth-provider';
|
|
8
|
+
export * from './auth-types';
|
|
9
|
+
export * from './device-detection';
|
|
10
|
+
export * from './sso-session';
|
|
11
|
+
export * from './use-auth-flow';
|
|
12
|
+
export * from './use-auth-flow-router-sync';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSO session management: token persistence strategies.
|
|
3
|
+
* - `localStorageTokenStorage`: single-origin, suitable for dev.
|
|
4
|
+
* - `serverCookieTokenStorage`: HttpOnly cookie-based, for production SSO.
|
|
5
|
+
* - `createAxiosAuthInterceptors`: attaches withCredentials + 401 handling to an axios instance.
|
|
6
|
+
*/
|
|
7
|
+
import type { AxiosAuthInterceptorInstance, TokenStorageStrategy } from '../types';
|
|
8
|
+
export type { AxiosAuthInterceptorInstance, AxiosRequestConfig, TokenStorageStrategy, } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Token storage using localStorage (single-origin).
|
|
11
|
+
* Suitable for dev or when all Docthub apps share the same origin.
|
|
12
|
+
*/
|
|
13
|
+
export declare function localStorageTokenStorage(): TokenStorageStrategy;
|
|
14
|
+
/**
|
|
15
|
+
* Token storage when the token lives in a server-set cookie (e.g. HttpOnly).
|
|
16
|
+
* The client never reads or writes the token; the server sets the cookie on
|
|
17
|
+
* login and reads it from the request. Use with validateSessionFromCookie
|
|
18
|
+
* in your adapter and createAxiosAuthInterceptors (withCredentials) so the
|
|
19
|
+
* cookie is sent on every request.
|
|
20
|
+
*/
|
|
21
|
+
export declare function serverCookieTokenStorage(): TokenStorageStrategy;
|
|
22
|
+
/**
|
|
23
|
+
* Attaches request and response interceptors to an axios instance for SSO auth
|
|
24
|
+
* when using server-side cookies (e.g. serverCookieTokenStorage):
|
|
25
|
+
* - Request: sets withCredentials so the browser sends cookies on every request.
|
|
26
|
+
* - Response: on 401, calls onUnauthorized (e.g. redirect to login).
|
|
27
|
+
*
|
|
28
|
+
* @param axiosInstance - Your axios instance (e.g. axios.create({ baseURL: '...' }))
|
|
29
|
+
* @param onUnauthorized - Optional callback when a response has status 401
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAxiosAuthInterceptors(axiosInstance: AxiosAuthInterceptorInstance, onUnauthorized?: () => void): void;
|
|
32
|
+
/**
|
|
33
|
+
* useAuthSession hook is implemented in auth-context (uses AuthFlowContext).
|
|
34
|
+
* Re-exported from core index for consumer convenience.
|
|
35
|
+
*/
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* cannot be entered cold from a URL — the SDK snaps the URL back to the
|
|
21
21
|
* current state's path instead.
|
|
22
22
|
*/
|
|
23
|
-
import type { AuthFlowRouter, AuthFlowRoutes } from '
|
|
23
|
+
import type { AuthFlowRouter, AuthFlowRoutes } from '../types';
|
|
24
24
|
/**
|
|
25
25
|
* Wires `router` to the auth flow state machine. No-op when either
|
|
26
26
|
* `router` or `routes` is missing.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth flow state machine: reducer and state type.
|
|
3
|
+
* Side effects (API calls, token persistence) are performed by the provider; this module is pure.
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthFlowAction, AuthFlowState, AuthStep } from '../types';
|
|
6
|
+
export type { AuthFlowAction, AuthFlowState, IdentifierType } from '../types';
|
|
7
|
+
export declare const INITIAL_STEP: AuthStep;
|
|
8
|
+
export declare function getInitialAuthFlowState(): AuthFlowState;
|
|
9
|
+
export declare function authFlowReducer(state: AuthFlowState, action: AuthFlowAction): AuthFlowState;
|