doct-ui-auth-kit 1.0.12 → 1.0.13

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.
@@ -0,0 +1,22 @@
1
+ /** Default destination when no explicit `onClick` or `href` is provided. */
2
+ export declare const DEFAULT_ENTERPRISE_LOGIN_URL = "https://docthub.com/";
3
+ export interface EnterpriseHeaderProps {
4
+ /**
5
+ * Custom click handler. Takes precedence over `href`. Use this when you
6
+ * want to navigate within a SPA router instead of doing a full page load.
7
+ */
8
+ onClick?: () => void;
9
+ /**
10
+ * Override the default redirect URL. Ignored when `onClick` is provided.
11
+ * Defaults to `https://docthub.com/`.
12
+ */
13
+ href?: string;
14
+ }
15
+ /**
16
+ * Header CTA that takes the user to the enterprise login surface.
17
+ * Hidden on small screens (sm:flex).
18
+ *
19
+ * Provide `onClick` for SPA navigation, or `href` for a plain anchor. Without
20
+ * either, the button redirects to the default `docthub.com` enterprise URL.
21
+ */
22
+ export declare function EnterpriseHeader({ onClick, href, }?: EnterpriseHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export { BackButton, type BackButtonProps } from './back-button';
2
+ export { DefaultFooter } from './default-footer';
3
+ export { DEFAULT_ENTERPRISE_LOGIN_URL, EnterpriseHeader, type EnterpriseHeaderProps, } from './enterprise-header';
@@ -0,0 +1,35 @@
1
+ import type { AuthFlowRouter, AuthFlowRoutes, OtpValidateFn } from '@/types';
2
+ /** Props for the `AuthFlow` orchestrator. */
3
+ export interface AuthFlowProps {
4
+ /**
5
+ * Optional router adapter. When supplied alongside `routes`, the SDK
6
+ * keeps `state.step` and the URL in sync (forward, back/forward, deep
7
+ * links). Omit both to render as a single-screen flow with no URL.
8
+ */
9
+ router?: AuthFlowRouter;
10
+ /**
11
+ * Optional map of `AuthStep → URL path`. Steps omitted from the map
12
+ * render without changing the URL.
13
+ */
14
+ routes?: AuthFlowRoutes;
15
+ /**
16
+ * Optional consumer-supplied OTP validator. Runs after the built-in
17
+ * 6-digit check and before the kit fires `verifyOtp` — return `true` to
18
+ * accept, or a string message to surface as the field error.
19
+ */
20
+ validateOtp?: OtpValidateFn;
21
+ /**
22
+ * Optional override for the Enterprise Login CTA in the method-select
23
+ * header. When provided, replaces the default redirect to docthub.com.
24
+ */
25
+ onEnterpriseLogin?: () => void;
26
+ }
27
+ /**
28
+ * Auth flow orchestrator ("auto" mode): renders the correct page component based on the current flow state.
29
+ * Consumer wraps with `SSOAuthProvider` and drops `AuthFlow` in — the SDK handles all transitions.
30
+ *
31
+ * Pass `router` + `routes` to make the flow URL-aware: each step gets its
32
+ * own URL, browser back/forward Just Works, and deep-linkable steps
33
+ * (METHOD_SELECT / PHONE_ENTRY / EMAIL_ENTRY) can be opened directly.
34
+ */
35
+ export declare function AuthFlow({ router, routes, validateOtp, onEnterpriseLogin, }?: AuthFlowProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Two-way sync between the auth flow state machine and a consumer-provided
3
+ * URL router adapter. Mounted by `<AuthFlow router routes>` when both are
4
+ * supplied. Without them, AuthFlow runs as a single-screen flow (no URL).
5
+ *
6
+ * Sync rules:
7
+ * - State → URL: when `state.step` changes, navigate to its mapped path.
8
+ * First sync uses `replace` (no history entry); subsequent forward
9
+ * transitions use `push`. Backward transitions (UI back button, reset)
10
+ * use `replace` so the kit doesn't pile new entries on top of stale ones
11
+ * — that pile-up is what makes the browser back button feel "stuck"
12
+ * bouncing between two URLs.
13
+ * - URL → State: subscribe to history changes (back/forward). When the URL
14
+ * moves to a routed step that's safe to deep-link into (METHOD_SELECT /
15
+ * PHONE_ENTRY / EMAIL_ENTRY), dispatch the corresponding action. We mark
16
+ * the dispatch so the next State → URL pass skips its push (the URL is
17
+ * already where it needs to be — pushing would add a redundant entry
18
+ * that breaks subsequent back navigation).
19
+ * - Deep-link guard: stateful steps (OTP, SIGNUP_DETAILS, REPEAT_LOGIN)
20
+ * cannot be entered cold from a URL — the SDK snaps the URL back to the
21
+ * current state's path instead.
22
+ */
23
+ import type { AuthFlowRouter, AuthFlowRoutes } from '@/types';
24
+ /**
25
+ * Wires `router` to the auth flow state machine. No-op when either
26
+ * `router` or `routes` is missing.
27
+ */
28
+ export declare function useAuthFlowRouterSync(router: AuthFlowRouter | undefined, routes: AuthFlowRoutes | undefined): void;
@@ -0,0 +1,15 @@
1
+ import type { OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn } from '@/types';
2
+ export type { OtpFormValues, OtpValidateFn, OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn, } from '@/types';
3
+ /** Instruction line below recipient (Figma: "Kindly check your Email Inbox."). */
4
+ export declare const DEFAULT_OTP_INSTRUCTIONS: Record<OtpVerificationMode, string>;
5
+ export declare const DEFAULT_OTP_TITLES: Record<OtpVerificationMode, string>;
6
+ /** Re-export for consumers who import from hooks. */
7
+ export { getResendCooldownSeconds, OTP_LENGTH, RESEND_COOLDOWN_EMAIL_SECONDS, RESEND_COOLDOWN_PHONE_SECONDS, } from '@/validations';
8
+ /**
9
+ * Form state, resend countdown, and validation for OTP verification.
10
+ *
11
+ * **Resend cooldown:** mode-dependent timer (60s phone / 120s email) blocks re-sends until elapsed.
12
+ * **Dual submission:** `submitApi` (async, hook owns flow) vs `onSubmit` (sync, caller owns flow).
13
+ * **Validation:** otpFormSchema ensures all 6 digits are present before submission.
14
+ */
15
+ export declare function useOtpVerification({ mode, onSubmit, onResendCode, submitApi, onSuccess, onError, validate, }: UseOtpVerificationOptions): UseOtpVerificationReturn;