doct-ui-auth-kit 1.0.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 (56) hide show
  1. package/README.md +266 -0
  2. package/dist/adapters/http-auth-adapter.d.ts +11 -0
  3. package/dist/adapters/index.d.ts +1 -0
  4. package/dist/auth-methods/apple.d.ts +19 -0
  5. package/dist/auth-methods/google.d.ts +65 -0
  6. package/dist/auth-methods/index.d.ts +2 -0
  7. package/dist/components/auth/repeat-login.d.ts +24 -0
  8. package/dist/components/form/rhf-doct-phone-input.d.ts +2 -0
  9. package/dist/components/form/rhf-input-field.d.ts +2 -0
  10. package/dist/components/form/rhf-otp-input-field.d.ts +2 -0
  11. package/dist/components/form/rhf-password-field.d.ts +2 -0
  12. package/dist/components/layout/auth-layout.d.ts +89 -0
  13. package/dist/components/layout/image-slider.d.ts +45 -0
  14. package/dist/components/layout/index.d.ts +6 -0
  15. package/dist/components/layout/main-layout.d.ts +74 -0
  16. package/dist/constants/demo-slider.d.ts +16 -0
  17. package/dist/constants/index.d.ts +1 -0
  18. package/dist/core/auth-api-adapter.d.ts +38 -0
  19. package/dist/core/auth-context.d.ts +67 -0
  20. package/dist/core/auth-flow.d.ts +5 -0
  21. package/dist/core/auth-provider.d.ts +39 -0
  22. package/dist/core/auth-types.d.ts +68 -0
  23. package/dist/core/device-detection.d.ts +23 -0
  24. package/dist/core/index.d.ts +11 -0
  25. package/dist/core/sso-session.d.ts +35 -0
  26. package/dist/core/use-auth-flow.d.ts +79 -0
  27. package/dist/docthub.svg +5 -0
  28. package/dist/hooks/index.d.ts +3 -0
  29. package/dist/hooks/use-login-entry-form.d.ts +32 -0
  30. package/dist/hooks/use-otp-verification.d.ts +29 -0
  31. package/dist/hooks/use-signup-form.d.ts +37 -0
  32. package/dist/index.d.ts +26 -0
  33. package/dist/index.js +7405 -0
  34. package/dist/logo.png +0 -0
  35. package/dist/pages/conflict.d.ts +12 -0
  36. package/dist/pages/foreign-email-collect.d.ts +16 -0
  37. package/dist/pages/index.d.ts +7 -0
  38. package/dist/pages/login-entry.d.ts +23 -0
  39. package/dist/pages/main-login.d.ts +26 -0
  40. package/dist/pages/otp-verification.d.ts +21 -0
  41. package/dist/pages/repeat-login.d.ts +20 -0
  42. package/dist/pages/signup.d.ts +17 -0
  43. package/dist/pages.js +10 -0
  44. package/dist/signup-Cnybfnhd.js +720 -0
  45. package/dist/slider/slide-1.png +0 -0
  46. package/dist/slider/slide-2.png +0 -0
  47. package/dist/slider/slide-3.png +0 -0
  48. package/dist/slider/slide-4.png +0 -0
  49. package/dist/slider/slide-5.png +0 -0
  50. package/dist/types/auth-layout-types.d.ts +94 -0
  51. package/dist/types/common.d.ts +25 -0
  52. package/dist/types/forms.d.ts +124 -0
  53. package/dist/types/index.d.ts +6 -0
  54. package/dist/types/user.d.ts +31 -0
  55. package/dist/vite.svg +1 -0
  56. package/package.json +104 -0
@@ -0,0 +1,38 @@
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
+ import type { AuthenticateWithProviderParams, CompleteProfileParams, SendOtpResponse, SSOSession, VerifyOtpResponse } from './auth-types';
7
+ /** Parameters for sending OTP to phone or email. */
8
+ export interface SendOtpParams {
9
+ type: 'phone' | 'email';
10
+ value: string;
11
+ }
12
+ /** Parameters for verifying OTP. */
13
+ export interface VerifyOtpParams {
14
+ type: 'phone' | 'email';
15
+ value: string;
16
+ otp: string;
17
+ }
18
+ /**
19
+ * Adapter implemented by the consumer to talk to the central auth service.
20
+ * All methods return promises; the SDK handles loading/error state.
21
+ */
22
+ export interface AuthApiAdapter {
23
+ /** Send OTP to the given phone or email. */
24
+ sendOtp(params: SendOtpParams): Promise<SendOtpResponse>;
25
+ /**
26
+ * Verify OTP. Returns session if existing user, or isNewUser flag for profile completion.
27
+ * May return conflict error when identifier is linked to another account.
28
+ */
29
+ verifyOtp(params: VerifyOtpParams): Promise<VerifyOtpResponse>;
30
+ /** Complete profile for new users; returns SSO session. */
31
+ completeProfile(params: CompleteProfileParams): Promise<SSOSession>;
32
+ /** Authenticate with a third-party provider (Google/Apple) credential. */
33
+ authenticateWithProvider(params: AuthenticateWithProviderParams): Promise<VerifyOtpResponse>;
34
+ /** Validate an existing SSO session token; called on SDK mount. Returns null if invalid/expired. */
35
+ validateSession(token: string): Promise<SSOSession | null>;
36
+ /** Optional: refresh an expired SSO session using refresh token. */
37
+ refreshSession?(refreshToken: string): Promise<SSOSession | null>;
38
+ }
@@ -0,0 +1,67 @@
1
+ import type { SSOSession } from './auth-types';
2
+ import type { AuthFlowState } from './use-auth-flow';
3
+ /** Provider config slice exposed to flow for Google/Apple wiring. */
4
+ export interface AuthFlowProviderConfig {
5
+ google?: {
6
+ clientId: string;
7
+ enableOneTap?: boolean;
8
+ };
9
+ apple?: {
10
+ clientId: string;
11
+ redirectUri: string;
12
+ };
13
+ }
14
+ /** Async actions that perform I/O and dispatch to the flow reducer. */
15
+ export interface AuthFlowActions {
16
+ selectMethod: (method: 'phone' | 'email' | 'google' | 'apple') => void;
17
+ /** From REPEAT_LOGIN: continue with last used method. */
18
+ continueWithLastMethod: () => void;
19
+ submitIdentifier: (data: {
20
+ phone?: string;
21
+ email?: string;
22
+ }) => void;
23
+ /** Foreign (non-IN) phone flow: collect fullName + email, send OTP to email. */
24
+ submitForeignEmail: (data: {
25
+ fullName: string;
26
+ email: string;
27
+ }) => void;
28
+ verifyOtp: (otp: string) => void;
29
+ resendOtp: () => void;
30
+ completeProfile: (data: {
31
+ fullName: string;
32
+ phone?: string;
33
+ email?: string;
34
+ }) => void;
35
+ providerCallback: (params: {
36
+ provider: 'google' | 'apple';
37
+ credential: string;
38
+ }) => void;
39
+ goBack: () => void;
40
+ reset: () => void;
41
+ signOut: () => void;
42
+ }
43
+ export interface AuthFlowContextValue {
44
+ state: AuthFlowState;
45
+ actions: AuthFlowActions;
46
+ /** Session when step is AUTHENTICATED. */
47
+ session: SSOSession | null;
48
+ /** True while step is CHECKING_SESSION. */
49
+ isLoading: boolean;
50
+ /** Provider config for Google/Apple (One Tap, Sign-In button). */
51
+ providerConfig: AuthFlowProviderConfig | undefined;
52
+ }
53
+ export declare const AuthFlowContext: import("react").Context<AuthFlowContextValue | null>;
54
+ /**
55
+ * Hook to access auth flow state and actions. Must be used within SSOAuthProvider.
56
+ */
57
+ export declare function useAuthFlow(): AuthFlowContextValue;
58
+ /**
59
+ * Hook to access SSO session state only. Must be used within SSOAuthProvider.
60
+ */
61
+ export declare function useAuthSession(): {
62
+ session: SSOSession | null;
63
+ isAuthenticated: boolean;
64
+ isLoading: boolean;
65
+ signOut: () => void;
66
+ authMethod: import("./auth-types").AuthMethod | null;
67
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Full auth flow orchestrator. Renders the correct page per flow state.
3
+ * Use inside SSOAuthProvider + AuthLayout.Main.
4
+ */
5
+ export declare function AuthFlow(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,39 @@
1
+ import type { AuthApiAdapter } from './auth-api-adapter';
2
+ import type { AuthError, SSOSession } from './auth-types';
3
+ import type { TokenStorageStrategy } from './sso-session';
4
+ export interface SSOAuthConfig {
5
+ /** Consumer-provided adapter to their central auth service. */
6
+ apiAdapter: AuthApiAdapter;
7
+ /** Auth method configs (Google client ID, Apple client ID, etc.). */
8
+ providers?: {
9
+ google?: {
10
+ clientId: string;
11
+ enableOneTap?: boolean;
12
+ };
13
+ apple?: {
14
+ clientId: string;
15
+ redirectUri: string;
16
+ };
17
+ };
18
+ /** Called when SSO session is established (any method). */
19
+ onAuthSuccess: (session: SSOSession) => void;
20
+ /** Called on auth errors. */
21
+ onAuthError?: (error: AuthError) => void;
22
+ /** Optional: called when user signs out. */
23
+ onSignOut?: () => void;
24
+ /** SSO token persistence strategy. Defaults to localStorage. */
25
+ tokenStorage?: TokenStorageStrategy;
26
+ /** Branding customization (logo, slider images). */
27
+ branding?: {
28
+ logo?: React.ReactNode;
29
+ sliderImages?: string[];
30
+ };
31
+ }
32
+ export interface SSOAuthProviderProps {
33
+ config: SSOAuthConfig;
34
+ children: React.ReactNode;
35
+ }
36
+ /**
37
+ * SSO Auth provider: runs session check on mount, holds flow state, and provides async actions.
38
+ */
39
+ export declare function SSOAuthProvider({ config, children }: SSOAuthProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * SSO auth domain types: session, flow steps, adapter contracts, and error codes.
3
+ * Used by the flow engine, provider, and adapter implementations.
4
+ */
5
+ /** Auth methods available in the SSO system. */
6
+ export type AuthMethod = 'phone' | 'email' | 'google' | 'apple';
7
+ /** User payload in the SSO session. */
8
+ export interface SSOUser {
9
+ id: string;
10
+ name: string;
11
+ email?: string;
12
+ phone?: string;
13
+ avatar?: string;
14
+ isNewUser: boolean;
15
+ }
16
+ /** The SSO session — same structure regardless of auth method used. */
17
+ export interface SSOSession {
18
+ accessToken: string;
19
+ refreshToken?: string;
20
+ expiresAt: number;
21
+ user: SSOUser;
22
+ authMethod: AuthMethod;
23
+ }
24
+ /** Flow states for the state machine. */
25
+ export type AuthStep = 'CHECKING_SESSION' | 'REPEAT_LOGIN' | 'METHOD_SELECT' | 'PHONE_ENTRY' | 'EMAIL_ENTRY' | 'FOREIGN_EMAIL_COLLECT' | 'OTP_VERIFICATION' | 'PROFILE_COMPLETION' | 'PROVIDER_PENDING' | 'CONFLICT' | 'AUTHENTICATED';
26
+ /** Error codes from the central auth service. */
27
+ export type AuthErrorCode = 'IDENTIFIER_CONFLICT' | 'OTP_EXPIRED' | 'OTP_INVALID' | 'OTP_RATE_LIMIT' | 'SESSION_EXPIRED' | 'PROVIDER_AUTH_FAILED' | 'NETWORK_ERROR' | 'UNKNOWN';
28
+ /** Auth error with code and optional message / linked identifier. */
29
+ export interface AuthError {
30
+ code: AuthErrorCode;
31
+ message?: string;
32
+ /** Masked linked identifier when conflict (e.g. "+91 98XXXX0X0X"). */
33
+ linkedIdentifier?: string;
34
+ }
35
+ /** Response from sendOtp. */
36
+ export interface SendOtpResponse {
37
+ success: boolean;
38
+ /** Masked value for display (e.g. "+91 9825910X0X" or "j***@gmail.com"). */
39
+ maskedValue?: string;
40
+ error?: AuthError;
41
+ }
42
+ /** Result of verifyOtp or authenticateWithProvider: existing user gets session, new user gets profile step. */
43
+ export interface VerifyOtpResponse {
44
+ /** Present when user exists and is authenticated. */
45
+ session?: SSOSession;
46
+ /** True when user is new and must complete profile. */
47
+ isNewUser: boolean;
48
+ /** When isNewUser and conflict (e.g. email already linked), masked linked identifier. */
49
+ conflict?: AuthError;
50
+ }
51
+ /** Input for completeProfile (new users). */
52
+ export interface CompleteProfileParams {
53
+ fullName: string;
54
+ email?: string;
55
+ phone?: string;
56
+ }
57
+ /** Input for authenticateWithProvider (Google/Apple credential). */
58
+ export interface AuthenticateWithProviderParams {
59
+ provider: 'google' | 'apple';
60
+ /** Id token or equivalent from the provider. */
61
+ credential: string;
62
+ }
63
+ /** Repeat-login device history (method + masked identifier). */
64
+ export interface RepeatLoginInfo {
65
+ method: AuthMethod;
66
+ maskedIdentifier: string;
67
+ timestamp: number;
68
+ }
@@ -0,0 +1,23 @@
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 { AuthMethod } from './auth-types';
6
+ export interface StoredRepeatLogin {
7
+ method: AuthMethod;
8
+ maskedIdentifier: string;
9
+ timestamp: number;
10
+ }
11
+ /**
12
+ * Reads repeat-login info from localStorage if present.
13
+ * Safe to call in browser; returns null in SSR or when not found.
14
+ */
15
+ export declare function getRepeatLoginInfo(): StoredRepeatLogin | null;
16
+ /**
17
+ * Saves repeat-login info to localStorage after successful auth.
18
+ */
19
+ export declare function setRepeatLoginInfo(info: StoredRepeatLogin): void;
20
+ /**
21
+ * Clears repeat-login info (e.g. on sign out).
22
+ */
23
+ export declare function clearRepeatLoginInfo(): void;
@@ -0,0 +1,11 @@
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';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * SSO session management: token persistence strategies and useAuthSession hook.
3
+ * Token storage is consumer-configurable for cross-app SSO (e.g. shared cookie domain).
4
+ */
5
+ import type { AuthMethod, SSOSession } from './auth-types';
6
+ /** How/where the SSO token is stored for cross-app access. */
7
+ export interface TokenStorageStrategy {
8
+ get(): string | null;
9
+ set(token: string, expiresAt: number): void;
10
+ remove(): void;
11
+ }
12
+ /**
13
+ * Token storage using localStorage (single-origin).
14
+ * Suitable for dev or when all Docthub apps share the same origin.
15
+ */
16
+ export declare function localStorageTokenStorage(): TokenStorageStrategy;
17
+ /**
18
+ * Token storage using a cookie on the given domain (e.g. '.docthub.com').
19
+ * Allows subdomains to share the SSO session. Not httpOnly (set from client).
20
+ */
21
+ export declare function cookieTokenStorage(domain: string): TokenStorageStrategy;
22
+ /**
23
+ * Return type of useAuthSession. Session and loading come from AuthFlowContext.
24
+ */
25
+ export interface UseAuthSessionReturn {
26
+ session: SSOSession | null;
27
+ isAuthenticated: boolean;
28
+ isLoading: boolean;
29
+ signOut: () => void;
30
+ authMethod: AuthMethod | null;
31
+ }
32
+ /**
33
+ * useAuthSession hook is implemented in auth-context (uses AuthFlowContext).
34
+ * Re-exported from core index for consumer convenience.
35
+ */
@@ -0,0 +1,79 @@
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 { AuthError, AuthStep, SSOSession } from './auth-types';
6
+ /** Identifier type for OTP / profile steps. */
7
+ export type IdentifierType = 'phone' | 'email';
8
+ /** Full state for the auth flow. */
9
+ export interface AuthFlowState {
10
+ step: AuthStep;
11
+ /** Previous step for goBack. */
12
+ lastStep: AuthStep;
13
+ /** Current identifier value (phone or email) when in OTP or profile. */
14
+ identifierValue: string;
15
+ /** Type of identifier (phone vs email). */
16
+ identifierType: IdentifierType;
17
+ /** Masked value for display (e.g. "+91 9825910X0X"). */
18
+ maskedRecipient: string;
19
+ /** For PROFILE_COMPLETION: which field to collect (phone or email). */
20
+ signupMode: IdentifierType;
21
+ /** For REPEAT_LOGIN: last used method label. */
22
+ lastMethod: string;
23
+ /** Set when step is AUTHENTICATED. */
24
+ session: SSOSession | null;
25
+ /** Set when step is CONFLICT. */
26
+ conflictError: AuthError | null;
27
+ /** For FOREIGN_EMAIL_COLLECT: the non-IN phone we already have. */
28
+ foreignPhoneValue: string;
29
+ /** When set, foreign flow: use in completeProfile after OTP for new user. */
30
+ pendingFullName: string;
31
+ pendingEmail: string;
32
+ }
33
+ export declare const INITIAL_STEP: AuthStep;
34
+ export declare function getInitialAuthFlowState(): AuthFlowState;
35
+ /** Pure reducer actions. */
36
+ export type AuthFlowAction = {
37
+ type: 'SET_SESSION';
38
+ session: SSOSession;
39
+ } | {
40
+ type: 'SET_STEP_REPEAT_LOGIN';
41
+ lastMethod: string;
42
+ maskedIdentifier: string;
43
+ } | {
44
+ type: 'SET_STEP_METHOD_SELECT';
45
+ } | {
46
+ type: 'SET_STEP_PHONE_ENTRY';
47
+ } | {
48
+ type: 'SET_STEP_EMAIL_ENTRY';
49
+ } | {
50
+ type: 'SET_STEP_FOREIGN_EMAIL_COLLECT';
51
+ phoneValue: string;
52
+ maskedPhone?: string;
53
+ } | {
54
+ type: 'SET_STEP_OTP_VERIFICATION';
55
+ identifierType: IdentifierType;
56
+ value: string;
57
+ maskedValue: string;
58
+ /** Optional: from foreign flow for completeProfile after OTP. */
59
+ pendingFullName?: string;
60
+ pendingEmail?: string;
61
+ } | {
62
+ type: 'SET_STEP_PROFILE_COMPLETION';
63
+ signupMode: IdentifierType;
64
+ } | {
65
+ type: 'SET_STEP_PROVIDER_PENDING';
66
+ } | {
67
+ type: 'SET_STEP_CONFLICT';
68
+ error: AuthError;
69
+ } | {
70
+ type: 'SET_STEP_AUTHENTICATED';
71
+ session: SSOSession;
72
+ } | {
73
+ type: 'GO_BACK';
74
+ } | {
75
+ type: 'RESET';
76
+ } | {
77
+ type: 'SIGN_OUT';
78
+ };
79
+ export declare function authFlowReducer(state: AuthFlowState, action: AuthFlowAction): AuthFlowState;
@@ -0,0 +1,5 @@
1
+ <svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="46" height="46" rx="23" fill="#18A3A6"/>
3
+ <path d="M14.5039 15.972H17.8004C20.0002 15.8457 22.1711 16.5207 23.9114 17.872C24.6514 18.5147 25.2359 19.317 25.6208 20.2183C26.0057 21.1196 26.181 22.0965 26.1336 23.0754C26.1866 24.0779 26.0229 25.0799 25.6536 26.0134C25.2843 26.9468 24.7181 27.7896 23.9936 28.4844C22.3607 29.8691 20.2583 30.5737 18.1208 30.4526H14.5091L14.5039 15.972ZM17.1812 27.955H18.1173C19.5394 28.0467 20.9445 27.6055 22.0589 26.7174C22.5331 26.2712 22.9035 25.7262 23.1437 25.1211C23.384 24.5159 23.4885 23.8653 23.4495 23.2153C23.4881 22.5569 23.3759 21.8983 23.1215 21.2898C22.8671 20.6812 22.477 20.1388 21.9812 19.7038C20.7803 18.8089 19.3002 18.3702 17.8056 18.4662H17.1846L17.1812 27.955Z" fill="white"/>
4
+ <path d="M29.8948 15.9609H25.2891V18.006H29.8809V22.598H31.8777V15.9609H29.8948Z" fill="white"/>
5
+ </svg>
@@ -0,0 +1,3 @@
1
+ export { type EmailFormValues, type LoginEntryFormValues, type LoginEntryMode, type PhoneFormValues, type UseLoginEntryFormOptions, type UseLoginEntryFormReturn, useLoginEntryForm, } from './use-login-entry-form';
2
+ export { DEFAULT_OTP_TITLES, OTP_LENGTH, type OtpFormValues, type OtpVerificationMode, RESEND_COOLDOWN_SECONDS, type UseOtpVerificationOptions, type UseOtpVerificationReturn, useOtpVerification, } from './use-otp-verification';
3
+ export { type SignupEmailFormValues, type SignupEntryMode, type SignupFormValues, type SignupPhoneFormValues, type UseSignupFormOptions, type UseSignupFormReturn, useSignupForm, } from './use-signup-form';
@@ -0,0 +1,32 @@
1
+ import type { UseFormReturn } from 'react-hook-form';
2
+ import { z } from 'zod';
3
+ /** Login mode: phone number or email */
4
+ export type LoginEntryMode = 'phone' | 'email';
5
+ declare const phoneFormSchema: z.ZodObject<{
6
+ phone: z.ZodString;
7
+ }, z.core.$strip>;
8
+ declare const emailFormSchema: z.ZodObject<{
9
+ email: z.ZodString;
10
+ }, z.core.$strip>;
11
+ export type PhoneFormValues = z.infer<typeof phoneFormSchema>;
12
+ export type EmailFormValues = z.infer<typeof emailFormSchema>;
13
+ export type LoginEntryFormValues = PhoneFormValues | EmailFormValues;
14
+ export interface UseLoginEntryFormOptions {
15
+ mode: LoginEntryMode;
16
+ /** Called with valid form data on submit. Omit or pass undefined when not needed. */
17
+ onSubmit?: ((data: {
18
+ phone?: string;
19
+ email?: string;
20
+ }) => void) | undefined;
21
+ }
22
+ export interface UseLoginEntryFormReturn {
23
+ methods: UseFormReturn<LoginEntryFormValues>;
24
+ handleSubmit: (data: LoginEntryFormValues) => void;
25
+ isPhone: boolean;
26
+ }
27
+ /**
28
+ * Form state and validation for the login entry screen (phone or email).
29
+ * Use with LoginEntry component or build a custom UI with the returned methods.
30
+ */
31
+ export declare function useLoginEntryForm({ mode, onSubmit, }: UseLoginEntryFormOptions): UseLoginEntryFormReturn;
32
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { UseFormReturn } from 'react-hook-form';
2
+ import { z } from 'zod';
3
+ /** OTP verification mode: mobile (phone) or email */
4
+ export type OtpVerificationMode = 'phone' | 'email';
5
+ export declare const OTP_LENGTH = 6;
6
+ export declare const RESEND_COOLDOWN_SECONDS = 120;
7
+ declare const otpFormSchema: z.ZodObject<{
8
+ otp: z.ZodArray<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ export type OtpFormValues = z.infer<typeof otpFormSchema>;
11
+ export declare const DEFAULT_OTP_TITLES: Record<OtpVerificationMode, string>;
12
+ export interface UseOtpVerificationOptions {
13
+ onSubmit?: ((otp: string) => void) | undefined;
14
+ onResendCode?: (() => void) | undefined;
15
+ }
16
+ export interface UseOtpVerificationReturn {
17
+ methods: UseFormReturn<OtpFormValues>;
18
+ handleSubmit: (data: OtpFormValues) => void;
19
+ handleResend: () => void;
20
+ resendSecondsLeft: number;
21
+ canResend: boolean;
22
+ timerText: string;
23
+ }
24
+ /**
25
+ * Form state, resend countdown, and validation for OTP verification.
26
+ * Use with OtpVerification component or build a custom OTP UI.
27
+ */
28
+ export declare function useOtpVerification({ onSubmit, onResendCode, }?: UseOtpVerificationOptions): UseOtpVerificationReturn;
29
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { UseFormReturn } from 'react-hook-form';
2
+ import { z } from 'zod';
3
+ /** Signup mode: phone number or email as the second field (after full name) */
4
+ export type SignupEntryMode = 'phone' | 'email';
5
+ declare const signupPhoneFormSchema: z.ZodObject<{
6
+ fullName: z.ZodString;
7
+ phone: z.ZodString;
8
+ }, z.core.$strip>;
9
+ declare const signupEmailFormSchema: z.ZodObject<{
10
+ fullName: z.ZodString;
11
+ email: z.ZodString;
12
+ }, z.core.$strip>;
13
+ export type SignupPhoneFormValues = z.infer<typeof signupPhoneFormSchema>;
14
+ export type SignupEmailFormValues = z.infer<typeof signupEmailFormSchema>;
15
+ export type SignupFormValues = SignupPhoneFormValues | SignupEmailFormValues;
16
+ export interface UseSignupFormOptions {
17
+ /** Mode: phone number or email as second field */
18
+ mode: SignupEntryMode;
19
+ /** Called with valid form data on submit. Omit or pass undefined when not needed. */
20
+ onSubmit?: ((data: {
21
+ fullName: string;
22
+ phone?: string;
23
+ email?: string;
24
+ }) => void) | undefined;
25
+ }
26
+ export interface UseSignupFormReturn {
27
+ methods: UseFormReturn<SignupFormValues>;
28
+ handleSubmit: (data: SignupFormValues) => void;
29
+ /** True when mode is 'phone', false when mode is 'email'. Use to switch between phone/email input. */
30
+ isPhone: boolean;
31
+ }
32
+ /**
33
+ * Form state and validation for the signup screen (full name + phone or email).
34
+ * Use with SignupPage component or build a custom signup form.
35
+ */
36
+ export declare function useSignupForm({ mode, onSubmit, }: UseSignupFormOptions): UseSignupFormReturn;
37
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Auth SDK UI Kit – library entry point.
3
+ * Consumers can import components, layouts, hooks, core (SSO provider, flow, session), and auth methods.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import {
8
+ * SSOAuthProvider,
9
+ * AuthFlow,
10
+ * useAuthFlow,
11
+ * useAuthSession,
12
+ * MainLayout,
13
+ * AuthLayout,
14
+ * LoginEntry,
15
+ * OtpVerification,
16
+ * useGoogleOneTap,
17
+ * } from 'doct-ui-auth-kit';
18
+ * ```
19
+ */
20
+ export * from './adapters';
21
+ export * from './auth-methods';
22
+ export * from './components/layout';
23
+ export * from './core';
24
+ export * from './hooks';
25
+ export * from './pages';
26
+ export * from './types';