doct-ui-auth-kit 1.0.8 → 1.0.9

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 (80) hide show
  1. package/package.json +3 -2
  2. package/dist/adapters/http-auth-adapter.d.ts +0 -8
  3. package/dist/adapters/index.d.ts +0 -1
  4. package/dist/auth/index.d.ts +0 -23
  5. package/dist/auth-methods/apple.d.ts +0 -19
  6. package/dist/auth-methods/google.d.ts +0 -5
  7. package/dist/auth-methods/index.d.ts +0 -2
  8. package/dist/auth-methods/use-google-auth.d.ts +0 -69
  9. package/dist/components/common/default-footer.d.ts +0 -5
  10. package/dist/components/common/enterprise-header.d.ts +0 -5
  11. package/dist/components/common/index.d.ts +0 -2
  12. package/dist/components/form/rhf-doct-phone-input.d.ts +0 -3
  13. package/dist/components/form/rhf-input-field.d.ts +0 -3
  14. package/dist/components/form/rhf-otp-input-field.d.ts +0 -3
  15. package/dist/components/layout/auth-layout-preset.d.ts +0 -30
  16. package/dist/components/layout/auth-layout-public.d.ts +0 -13
  17. package/dist/components/layout/auth-layout-wrapper.d.ts +0 -59
  18. package/dist/components/layout/auth-layout.d.ts +0 -89
  19. package/dist/components/layout/image-slider.d.ts +0 -28
  20. package/dist/components/layout/index.d.ts +0 -8
  21. package/dist/components/layout/main-layout.d.ts +0 -30
  22. package/dist/constants/demo-slider.d.ts +0 -14
  23. package/dist/constants/index.d.ts +0 -2
  24. package/dist/constants/layout-presets.d.ts +0 -6
  25. package/dist/core/auth-api-adapter.d.ts +0 -6
  26. package/dist/core/auth-context.d.ts +0 -17
  27. package/dist/core/auth-flow.d.ts +0 -5
  28. package/dist/core/auth-provider.d.ts +0 -8
  29. package/dist/core/auth-types.d.ts +0 -5
  30. package/dist/core/device-detection.d.ts +0 -15
  31. package/dist/core/index.d.ts +0 -11
  32. package/dist/core/sso-session.d.ts +0 -29
  33. package/dist/core/use-auth-flow.d.ts +0 -5
  34. package/dist/hooks/index.d.ts +0 -5
  35. package/dist/hooks/use-login-entry-form.d.ts +0 -12
  36. package/dist/hooks/use-main-auth-page-handlers.d.ts +0 -9
  37. package/dist/hooks/use-otp-verification.d.ts +0 -15
  38. package/dist/hooks/use-repeat-login.d.ts +0 -9
  39. package/dist/hooks/use-signup-form.d.ts +0 -12
  40. package/dist/index.d.ts +0 -11
  41. package/dist/pages/index.d.ts +0 -8
  42. package/dist/pages/login-entry/index.d.ts +0 -3
  43. package/dist/pages/login-entry/login-entry-page.d.ts +0 -21
  44. package/dist/pages/login-entry/login-entry.d.ts +0 -21
  45. package/dist/pages/main-login/index.d.ts +0 -3
  46. package/dist/pages/main-login/main-login-page.d.ts +0 -16
  47. package/dist/pages/main-login/main-login.d.ts +0 -25
  48. package/dist/pages/otp-verification/index.d.ts +0 -3
  49. package/dist/pages/otp-verification/otp-verification-page.d.ts +0 -23
  50. package/dist/pages/otp-verification/otp-verification.d.ts +0 -22
  51. package/dist/pages/repeat-login/index.d.ts +0 -3
  52. package/dist/pages/repeat-login/repeat-login-page.d.ts +0 -24
  53. package/dist/pages/repeat-login/repeat-login.d.ts +0 -25
  54. package/dist/pages/signup/index.d.ts +0 -3
  55. package/dist/pages/signup/signup-page.d.ts +0 -6
  56. package/dist/pages/signup/signup.d.ts +0 -7
  57. package/dist/types/auth/auth-api-adapter.d.ts +0 -39
  58. package/dist/types/auth/auth-provider.d.ts +0 -40
  59. package/dist/types/auth/auth-types.d.ts +0 -70
  60. package/dist/types/auth/device-detection.d.ts +0 -10
  61. package/dist/types/auth/flow.d.ts +0 -122
  62. package/dist/types/auth/index.d.ts +0 -9
  63. package/dist/types/auth/sso-session.d.ts +0 -33
  64. package/dist/types/components/auth-layout-types.d.ts +0 -94
  65. package/dist/types/components/forms.d.ts +0 -68
  66. package/dist/types/components/index.d.ts +0 -7
  67. package/dist/types/components/layout-presets.d.ts +0 -24
  68. package/dist/types/components/layout.d.ts +0 -57
  69. package/dist/types/index.d.ts +0 -7
  70. package/dist/types/pages/index.d.ts +0 -9
  71. package/dist/types/pages/login-form.d.ts +0 -56
  72. package/dist/types/pages/main-login.d.ts +0 -40
  73. package/dist/types/pages/otp-verification.d.ts +0 -40
  74. package/dist/types/pages/pages.d.ts +0 -133
  75. package/dist/types/pages/repeat-login.d.ts +0 -29
  76. package/dist/types/pages/signup-form.d.ts +0 -48
  77. package/dist/utils/index.d.ts +0 -4
  78. package/dist/utils/set-form-errors-from-zod.d.ts +0 -11
  79. package/dist/validations/index.d.ts +0 -6
  80. package/dist/validations/schemas.d.ts +0 -73
@@ -1,9 +0,0 @@
1
- import { MainAuthPageHandlers, UseMainAuthPageHandlersOptions } from '../types';
2
- export type { MainAuthPageHandlers, MainLoginAppleProviderConfig, MainLoginGoogleProviderConfig, MainLoginPageProvidersConfig, UseMainAuthPageHandlersOptions, } from '../types';
3
- /**
4
- * Centralizes Google/Apple OAuth and auth-method CTA handlers for the main login page.
5
- * When `providers.google` / `providers.apple` are configured, the SDK runs the OAuth flow internally
6
- * and calls `onCredential`; otherwise falls back to consumer-supplied overrides or no-op defaults.
7
- * Consumer apps pass callbacks (e.g. `onContinueWithMobile`) to wire navigation.
8
- */
9
- export declare function useMainAuthPageHandlers(options?: Readonly<UseMainAuthPageHandlersOptions>): MainAuthPageHandlers;
@@ -1,15 +0,0 @@
1
- import { OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn } from '../types';
2
- export type { OtpFormValues, 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, }: UseOtpVerificationOptions): UseOtpVerificationReturn;
@@ -1,9 +0,0 @@
1
- import { UseRepeatLoginOptions, UseRepeatLoginReturn } from '../types';
2
- export type { UseRepeatLoginOptions, UseRepeatLoginReturn } from '../types';
3
- /**
4
- * Business logic for repeat login (device-based returning-user detection).
5
- *
6
- * **Dual submission:** `continueApi` (async, hook owns flow) vs `onContinueWithLastMethod` (sync, caller owns flow).
7
- * Last-used method is read from localStorage by the provider and passed down as a prop.
8
- */
9
- export declare function useRepeatLogin(options?: UseRepeatLoginOptions): UseRepeatLoginReturn;
@@ -1,12 +0,0 @@
1
- import { UseSignupFormOptions, UseSignupFormReturn } from '../types';
2
- export type { SignupEmailFormValues, SignupEntryMode, SignupForeignFormValues, SignupFormValues, SignupPhoneFormValues, SignupSubmitData, UseSignupFormOptions, UseSignupFormReturn, } from '../types';
3
- /**
4
- * Form state and validation for the signup screen (full name + phone or email, or foreign: all three).
5
- *
6
- * **Dual submission pattern:**
7
- * - `submitApi` (async): hook owns the flow — validate → submitApi(data) → onSuccess(). Future SSO profile completion plugs in here.
8
- * - `onSubmit` (sync): caller owns the flow — hook validates then hands data back (used by AuthFlow).
9
- *
10
- * **Validation flow:** RHF form data → Zod schema (signupSchemas[mode]) → setFormErrorsFromZod → field-level errors.
11
- */
12
- export declare function useSignupForm({ mode, defaultPhone, onSubmit, submitApi, onSuccess, onError, }: UseSignupFormOptions): UseSignupFormReturn;
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export { createHttpAuthAdapter } from './adapters';
2
- export { Auth } from './auth';
3
- export type { UseAppleSignInOptions, UseGoogleAuthOptions, UseGoogleAuthReturn, } from './auth-methods';
4
- export { useAppleSignIn, useGoogleAuth } from './auth-methods';
5
- export type { AuthLayoutPresetProps, AuthLayoutType, AuthLayoutWrapperProps, } from './components/layout';
6
- export { AuthLayout, AuthLayoutPreset, AuthLayoutWrapper, ImageSlider, MainLayout, } from './components/layout';
7
- export * from './core';
8
- export * from './hooks';
9
- export type { LoginEntryPageProps, LoginEntryProps, MainLoginPageProps, MainLoginPageProvidersConfig, OtpVerificationPageProps, OtpVerificationProps, RepeatLoginPageProps, RepeatLoginProps, SignupPageFullProps, SignupPageProps, } from './pages';
10
- export { LoginEntry, LoginEntryPage, MainLogin, MainLoginPage, OtpVerification, OtpVerificationPage, RepeatLogin, RepeatLoginPage, Signup, SignupPage, } from './pages';
11
- export * from './types';
@@ -1,8 +0,0 @@
1
- /**
2
- * Page components barrel: *Page = full page with layout, bare name = form-only for composition.
3
- */
4
- export { LoginEntry, LoginEntryPage, type LoginEntryMode, type LoginEntryPageProps, type LoginEntryProps, } from './login-entry';
5
- export { MainLogin, type MainLoginAppleProviderConfig, type MainLoginGoogleProviderConfig, MainLoginPage, type MainLoginPageProps, type MainLoginPageProvidersConfig, } from './main-login';
6
- export { OtpVerification, type OtpVerificationMode, OtpVerificationPage, type OtpVerificationPageProps, type OtpVerificationProps, } from './otp-verification';
7
- export { RepeatLogin, RepeatLoginPage, type RepeatLoginPageProps, type RepeatLoginProps, } from './repeat-login';
8
- export { Signup, SignupPage, type SignupPageFullProps, type SignupPageProps, } from './signup';
@@ -1,3 +0,0 @@
1
- export type { LoginEntryMode, LoginEntryPageProps, LoginEntryProps, } from '../../types';
2
- export { LoginEntry } from './login-entry';
3
- export { LoginEntryPage } from './login-entry-page';
@@ -1,21 +0,0 @@
1
- import { LoginEntryPageProps } from '../../types';
2
- /**
3
- * Full LoginEntry page with AuthLayoutWrapper, back button, and slider/standalone layout.
4
- * Use when rendering the login entry screen as a standalone page.
5
- *
6
- * @example Next.js: API call in hook, redirect with mode + recipient for OTP page
7
- * ```tsx
8
- * <LoginEntryPage
9
- * mode="phone"
10
- * onBack={() => router.back()}
11
- * submitApi={(data) => api.sendOtp(data)}
12
- * onSuccess={(params) => router.push(`/otp?mode=${params.mode}&recipient=${encodeURIComponent(params.recipient)}`)}
13
- * />
14
- * ```
15
- *
16
- * @example Sync callback (caller owns API)
17
- * ```tsx
18
- * <LoginEntryPage mode="phone" onSubmit={(data) => sendOtp(data)} />
19
- * ```
20
- */
21
- export declare function LoginEntryPage(props: Readonly<LoginEntryPageProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +0,0 @@
1
- import { LoginEntryProps } from '../../types';
2
- /**
3
- * Login entry form body without layout wrapper.
4
- * Single form for phone or email based on mode. Use inside your own layout or AuthFlow.
5
- * Validation per PRODUCT_PROTOCOLS and edge cases 3–5, 18; cursor focus on first field (#26).
6
- *
7
- * @example With AuthFlow (sync onSubmit)
8
- * ```tsx
9
- * <LoginEntry mode="phone" onSubmit={(data) => actions.submitIdentifier(data)} />
10
- * ```
11
- *
12
- * @example Standalone Next.js (API + redirect in hook)
13
- * ```tsx
14
- * <LoginEntry
15
- * mode="phone"
16
- * submitApi={(data) => api.sendOtp(data)}
17
- * onSuccess={() => router.push('/otp')}
18
- * />
19
- * ```
20
- */
21
- export declare function LoginEntry(props: Readonly<LoginEntryProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +0,0 @@
1
- export { MainLoginPage } from './main-login-page';
2
- export { MainLogin } from './main-login';
3
- export type { MainLoginAppleProviderConfig, MainLoginGoogleProviderConfig, MainLoginPageProps, MainLoginPageProvidersConfig, } from '../../types';
@@ -1,16 +0,0 @@
1
- import { MainLoginPageProps } from '../../types';
2
- /**
3
- * Full MainLogin page with AuthLayoutWrapper, header, footer, and slider layout.
4
- * Includes default branding and layout configuration.
5
- *
6
- * @example
7
- * ```tsx
8
- * <MainLoginPage
9
- * onContinueWithMobile={() => navigate('/auth/phone')}
10
- * onContinueWithEmail={() => navigate('/auth/email')}
11
- * onContinueWithGoogle={() => navigate('/auth/google')}
12
- * onContinueWithApple={() => navigate('/auth/apple')}
13
- * />
14
- * ```
15
- */
16
- export declare const MainLoginPage: (props: Readonly<MainLoginPageProps>) => import("react/jsx-runtime").JSX.Element;
@@ -1,25 +0,0 @@
1
- import { MainAuthPageHandlers, MainLoginPageProps } from '../../types';
2
- interface MainLoginPageBodyProps {
3
- handlers: MainAuthPageHandlers;
4
- }
5
- /**
6
- * Renders the main login form body with four authentication options.
7
- * Each button triggers its corresponding handler from the handlers prop.
8
- */
9
- export declare const MainLoginPageBody: ({ handlers, }: Readonly<MainLoginPageBodyProps>) => import("react/jsx-runtime").JSX.Element;
10
- /**
11
- * Login body component without layout wrapper.
12
- * Displays four authentication method buttons (Mobile, Email, Google, Apple).
13
- *
14
- * Use this when you need custom layout or when integrating with AuthFlow.
15
- *
16
- * @example
17
- * ```tsx
18
- * <MainLogin
19
- * onContinueWithMobile={() => navigate('/auth/phone')}
20
- * onContinueWithEmail={() => navigate('/auth/email')}
21
- * />
22
- * ```
23
- */
24
- export declare function MainLogin(props: Readonly<MainLoginPageProps>): import("react/jsx-runtime").JSX.Element;
25
- export {};
@@ -1,3 +0,0 @@
1
- export type { OtpVerificationMode, OtpVerificationPageProps, OtpVerificationProps, } from '../../types';
2
- export { OtpVerification } from './otp-verification';
3
- export { OtpVerificationPage } from './otp-verification-page';
@@ -1,23 +0,0 @@
1
- import { OtpVerificationPageProps } from '../../types';
2
- /**
3
- * Full OTP verification page with AuthLayoutWrapper and back button.
4
- * Use when rendering the OTP screen as a standalone page.
5
- *
6
- * @example Next.js: API in hook, redirect from consumer
7
- * ```tsx
8
- * <OtpVerificationPage
9
- * mode="phone"
10
- * recipientDisplay="+91 9825910X0X"
11
- * onBack={() => router.back()}
12
- * submitApi={(otp) => api.verifyOtp(otp)}
13
- * onSuccess={() => router.push('/dashboard')}
14
- * onResendCode={() => api.resendOtp()}
15
- * />
16
- * ```
17
- *
18
- * @example Sync callback (AuthFlow)
19
- * ```tsx
20
- * <OtpVerificationPage onSubmit={(otp) => actions.verifyOtp(otp)} ... />
21
- * ```
22
- */
23
- export declare function OtpVerificationPage(props: Readonly<OtpVerificationPageProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,22 +0,0 @@
1
- import { OtpVerificationProps } from '../../types';
2
- /**
3
- * OTP verification form body without layout wrapper.
4
- * 6-digit OTP input, resend countdown, and submit. Use inside your own layout or AuthFlow.
5
- * Validation per edge cases 6, 7 (invalid/expired OTP); cursor focus on first OTP box (#26).
6
- *
7
- * @example With submitApi + onSuccess (consumer redirect)
8
- * ```tsx
9
- * <OtpVerification
10
- * mode="phone"
11
- * recipientDisplay="+91 9825910X0X"
12
- * submitApi={(otp) => api.verifyOtp(otp)}
13
- * onSuccess={() => router.push('/dashboard')}
14
- * />
15
- * ```
16
- *
17
- * @example Sync onSubmit (AuthFlow)
18
- * ```tsx
19
- * <OtpVerification onSubmit={(otp) => actions.verifyOtp(otp)} ... />
20
- * ```
21
- */
22
- export declare function OtpVerification(props: Readonly<OtpVerificationProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +0,0 @@
1
- export { RepeatLoginPage } from './repeat-login-page';
2
- export { RepeatLogin } from './repeat-login';
3
- export type { RepeatLoginPageProps, RepeatLoginProps } from '../../types';
@@ -1,24 +0,0 @@
1
- import { RepeatLoginPageProps } from '../../types';
2
- /**
3
- * Full Repeat Login page with AuthLayoutWrapper, logo, title, description, and footer.
4
- * Use when rendering the repeat login screen as a standalone page.
5
- *
6
- * @example Next.js: API in lib, redirect from consumer
7
- * ```tsx
8
- * <RepeatLoginPage
9
- * lastUsedMethod="Mobile"
10
- * continueApi={() => api.validateSession()}
11
- * onSuccess={() => router.push('/dashboard')}
12
- * onUseAnotherMethod={() => resetFlow()}
13
- * />
14
- * ```
15
- *
16
- * @example Sync (AuthFlow)
17
- * ```tsx
18
- * <RepeatLoginPage
19
- * onContinueWithLastMethod={() => actions.continueWithLastMethod()}
20
- * onUseAnotherMethod={() => actions.reset()}
21
- * />
22
- * ```
23
- */
24
- export declare function RepeatLoginPage(props: Readonly<RepeatLoginPageProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,25 +0,0 @@
1
- import { RepeatLoginProps } from '../../types';
2
- /**
3
- * Repeat login body without layout wrapper.
4
- * Primary CTA (continue with last method) and secondary "Use another method" button.
5
- * When continueApi is provided, primary runs: continueApi() → onSuccess() (e.g. redirect).
6
- *
7
- * @example With continueApi + onSuccess (consumer redirect)
8
- * ```tsx
9
- * <RepeatLogin
10
- * lastUsedMethod="Mobile"
11
- * continueApi={() => api.validateSession()}
12
- * onSuccess={() => router.push('/dashboard')}
13
- * onUseAnotherMethod={() => resetFlow()}
14
- * />
15
- * ```
16
- *
17
- * @example Sync (AuthFlow)
18
- * ```tsx
19
- * <RepeatLogin
20
- * onContinueWithLastMethod={() => actions.continueWithLastMethod()}
21
- * onUseAnotherMethod={() => actions.reset()}
22
- * />
23
- * ```
24
- */
25
- export declare function RepeatLogin(props: Readonly<RepeatLoginProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +0,0 @@
1
- export type { SignupEntryMode, SignupPageFullProps, SignupPageProps, } from '../../types';
2
- export { Signup } from './signup';
3
- export { SignupPage } from './signup-page';
@@ -1,6 +0,0 @@
1
- import { SignupPageFullProps } from '../../types';
2
- /**
3
- * Full signup page: AuthLayoutWrapper + logo + title + description + {@link Signup} form.
4
- * Use when rendering signup as a standalone route. For embedding in a custom layout, use {@link Signup} directly.
5
- */
6
- export declare function SignupPage(props: Readonly<SignupPageFullProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +0,0 @@
1
- import { SignupPageProps } from '../../types';
2
- /**
3
- * Form-only signup component (no layout wrapper). Use inside a custom layout or AuthFlow.
4
- * Supports `submitApi` (async, hook-driven — future SSO profile completion plugs in here)
5
- * and `onSubmit` (sync, caller-driven via AuthFlow actions).
6
- */
7
- export declare function Signup(props: Readonly<SignupPageProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,39 +0,0 @@
1
- import { AuthenticateWithProviderParams, CompleteProfileParams, SendOtpResponse, SSOSession, VerifyOtpResponse } from './auth-types';
2
- /** Parameters for sending OTP to phone or email. */
3
- export interface SendOtpParams {
4
- type: 'phone' | 'email';
5
- value: string;
6
- }
7
- /** Parameters for verifying OTP. */
8
- export interface VerifyOtpParams {
9
- type: 'phone' | 'email';
10
- value: string;
11
- otp: string;
12
- }
13
- /**
14
- * Adapter implemented by the consumer to talk to the central auth service.
15
- * All methods return promises; the SDK handles loading/error state.
16
- */
17
- export interface AuthApiAdapter {
18
- /** Send OTP to the given phone or email. */
19
- sendOtp(params: SendOtpParams): Promise<SendOtpResponse>;
20
- /**
21
- * Verify OTP. Returns session if existing user, or isNewUser flag for profile completion.
22
- * May return conflict error when identifier is linked to another account.
23
- */
24
- verifyOtp(params: VerifyOtpParams): Promise<VerifyOtpResponse>;
25
- /** Complete profile for new users; returns SSO session. */
26
- completeProfile(params: CompleteProfileParams): Promise<SSOSession>;
27
- /** Authenticate with a third-party provider (Google/Apple) credential. */
28
- authenticateWithProvider(params: AuthenticateWithProviderParams): Promise<VerifyOtpResponse>;
29
- /** Validate an existing SSO session token; called on SDK mount. Returns null if invalid/expired. */
30
- validateSession(token: string): Promise<SSOSession | null>;
31
- /**
32
- * Optional: validate session using server-read cookie (no token from client).
33
- * Required when using serverCookieTokenStorage. Client sends credentials;
34
- * server reads cookie from the request and returns session or null.
35
- */
36
- validateSessionFromCookie?(): Promise<SSOSession | null>;
37
- /** Optional: refresh an expired SSO session using refresh token. */
38
- refreshSession?(refreshToken: string): Promise<SSOSession | null>;
39
- }
@@ -1,40 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { AuthApiAdapter } from './auth-api-adapter';
3
- import { AuthError, SSOSession } from './auth-types';
4
- import { TokenStorageStrategy } from './sso-session';
5
- /** Consumer-provided config for SSOAuthProvider. */
6
- export interface SSOAuthConfig {
7
- /** Consumer-provided adapter to their central auth service. */
8
- apiAdapter: AuthApiAdapter;
9
- /** Auth method configs (Google client ID, Apple client ID, etc.). */
10
- providers?: {
11
- google?: {
12
- clientId: string;
13
- enableOneTap?: boolean;
14
- };
15
- apple?: {
16
- clientId: string;
17
- redirectUri: string;
18
- };
19
- };
20
- /** Called when SSO session is established (any method). */
21
- onAuthSuccess: (session: SSOSession) => void;
22
- /** Called on auth errors. */
23
- onAuthError?: (error: AuthError) => void;
24
- /** Optional: called when user signs out. */
25
- onSignOut?: () => void;
26
- /** SSO token persistence strategy. Defaults to localStorage. */
27
- tokenStorage?: TokenStorageStrategy;
28
- /** Branding customization (logo, slider images). */
29
- branding?: {
30
- logo?: ReactNode;
31
- sliderImages?: string[];
32
- };
33
- }
34
- /** Props for the SSOAuthProvider context wrapper that supplies auth state to the component tree. */
35
- export interface SSOAuthProviderProps {
36
- /** Auth configuration including API adapter, provider settings, and callbacks. */
37
- config: SSOAuthConfig;
38
- /** Child components that will have access to the SSO auth context. */
39
- children: ReactNode;
40
- }
@@ -1,70 +0,0 @@
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
- /** User type for layout and OTP routing: Indian (+91) vs Foreign (non +91). */
25
- export type UserType = 'INDIAN' | 'FOREIGN';
26
- /** Flow states for the state machine. */
27
- export type AuthStep = 'CHECKING_SESSION' | 'REPEAT_LOGIN' | 'METHOD_SELECT' | 'PHONE_ENTRY' | 'EMAIL_ENTRY' | 'OTP_VERIFICATION' | 'SIGNUP_DETAILS' | 'PROVIDER_PENDING' | 'AUTHENTICATED';
28
- /** Error codes from the central auth service. */
29
- export type AuthErrorCode = 'IDENTIFIER_CONFLICT' | 'OTP_EXPIRED' | 'OTP_INVALID' | 'OTP_RATE_LIMIT' | 'SESSION_EXPIRED' | 'PROVIDER_AUTH_FAILED' | 'NETWORK_ERROR' | 'UNKNOWN';
30
- /** Auth error with code and optional message / linked identifier. */
31
- export interface AuthError {
32
- code: AuthErrorCode;
33
- message?: string;
34
- /** Masked linked identifier when conflict (e.g. "+91 98XXXX0X0X"). */
35
- linkedIdentifier?: string;
36
- }
37
- /** Response from sendOtp. */
38
- export interface SendOtpResponse {
39
- success: boolean;
40
- /** Masked value for display (e.g. "+91 9825910X0X" or "j***@gmail.com"). */
41
- maskedValue?: string;
42
- error?: AuthError;
43
- }
44
- /** Result of verifyOtp or authenticateWithProvider: existing user gets session, new user gets profile step. */
45
- export interface VerifyOtpResponse {
46
- /** Present when user exists and is authenticated. */
47
- session?: SSOSession;
48
- /** True when user is new and must complete profile. */
49
- isNewUser: boolean;
50
- /** When isNewUser and conflict (e.g. email already linked), masked linked identifier. */
51
- conflict?: AuthError;
52
- }
53
- /** Input for completeProfile (new users). */
54
- export interface CompleteProfileParams {
55
- fullName: string;
56
- email?: string;
57
- phone?: string;
58
- }
59
- /** Input for authenticateWithProvider (Google/Apple credential). */
60
- export interface AuthenticateWithProviderParams {
61
- provider: 'google' | 'apple';
62
- /** Id token or equivalent from the provider. */
63
- credential: string;
64
- }
65
- /** Repeat-login device history (method + masked identifier). */
66
- export interface RepeatLoginInfo {
67
- method: AuthMethod;
68
- maskedIdentifier: string;
69
- timestamp: number;
70
- }
@@ -1,10 +0,0 @@
1
- import { AuthMethod } from './auth-types';
2
- /** Stored repeat-login info (method + masked identifier). */
3
- export interface StoredRepeatLogin {
4
- /** The authentication method used in the previous login (e.g. `'phone'`, `'email'`, `'google'`). */
5
- method: AuthMethod;
6
- /** Partially masked identifier shown to the user (e.g. `"****1234"` or `"j***@example.com"`). */
7
- maskedIdentifier: string;
8
- /** Unix epoch (ms) when this login record was stored. Used for expiry checks. */
9
- timestamp: number;
10
- }
@@ -1,122 +0,0 @@
1
- import { AuthStep, SSOSession, UserType } from './auth-types';
2
- /** Identifier type for OTP / profile steps. */
3
- export type IdentifierType = 'phone' | 'email';
4
- /** Full state for the auth flow. */
5
- export interface AuthFlowState {
6
- step: AuthStep;
7
- /** Previous step for goBack. */
8
- lastStep: AuthStep;
9
- /** Indian (+91) vs Foreign (non +91); drives layout and OTP routing. */
10
- userType: UserType;
11
- /** Current identifier value (phone or email) when in OTP or signup. */
12
- identifierValue: string;
13
- /** Type of identifier (phone vs email). */
14
- identifierType: IdentifierType;
15
- /** Masked value for display (e.g. "+91 9825910X0X"). */
16
- maskedRecipient: string;
17
- /** For SIGNUP_DETAILS (Indian): which field to collect (phone or email). */
18
- signupCollectField: IdentifierType;
19
- /** For REPEAT_LOGIN: last used method label. */
20
- lastMethod: string;
21
- /** Set when step is AUTHENTICATED. */
22
- session: SSOSession | null;
23
- /** Foreign flow: phone value when user entered phone before signup details. */
24
- pendingPhone: string;
25
- /** Foreign flow: signup form data for completeProfile after OTP verify. */
26
- pendingFullName: string;
27
- pendingEmail: string;
28
- }
29
- /** Pure reducer actions. */
30
- export type AuthFlowAction = {
31
- type: 'SET_SESSION';
32
- session: SSOSession;
33
- } | {
34
- type: 'SET_STEP_REPEAT_LOGIN';
35
- lastMethod: string;
36
- maskedIdentifier: string;
37
- } | {
38
- type: 'SET_STEP_METHOD_SELECT';
39
- } | {
40
- type: 'SET_STEP_PHONE_ENTRY';
41
- } | {
42
- type: 'SET_STEP_EMAIL_ENTRY';
43
- } | {
44
- type: 'SET_STEP_OTP_VERIFICATION';
45
- userType: UserType;
46
- identifierType: IdentifierType;
47
- value: string;
48
- maskedValue: string;
49
- /** Foreign flow: for completeProfile after OTP. */
50
- pendingFullName?: string;
51
- pendingEmail?: string;
52
- pendingPhone?: string;
53
- } | {
54
- type: 'SET_STEP_SIGNUP_DETAILS';
55
- userType: UserType;
56
- /** Indian: which field to collect (phone or email). Foreign: ignored. */
57
- signupCollectField: IdentifierType;
58
- /** Foreign only: phone value when user entered phone before signup. */
59
- pendingPhone?: string;
60
- /** When coming from identifier entry (foreign): preserve for later OTP. */
61
- identifierType?: IdentifierType;
62
- identifierValue?: string;
63
- maskedRecipient?: string;
64
- } | {
65
- type: 'SET_STEP_PROVIDER_PENDING';
66
- } | {
67
- type: 'SET_STEP_AUTHENTICATED';
68
- session: SSOSession;
69
- } | {
70
- type: 'GO_BACK';
71
- } | {
72
- type: 'RESET';
73
- } | {
74
- type: 'SIGN_OUT';
75
- };
76
- /** Provider config slice exposed to flow for Google/Apple wiring. */
77
- export interface AuthFlowProviderConfig {
78
- google?: {
79
- clientId: string;
80
- enableOneTap?: boolean;
81
- };
82
- apple?: {
83
- clientId: string;
84
- redirectUri: string;
85
- };
86
- }
87
- /** Async actions that perform I/O and dispatch to the flow reducer. */
88
- export interface AuthFlowActions {
89
- selectMethod: (method: 'phone' | 'email' | 'google' | 'apple') => void;
90
- /** From REPEAT_LOGIN: continue with last used method. */
91
- continueWithLastMethod: () => void;
92
- submitIdentifier: (data: {
93
- phone?: string;
94
- email?: string;
95
- }) => void;
96
- /** SIGNUP_DETAILS step: submit name + phone/email, then OTP (foreign) or complete (Indian). */
97
- submitSignupDetails: (data: {
98
- fullName: string;
99
- phone?: string;
100
- email?: string;
101
- }) => void;
102
- verifyOtp: (otp: string) => void;
103
- resendOtp: () => void;
104
- providerCallback: (params: {
105
- provider: 'google' | 'apple';
106
- credential: string;
107
- }) => void;
108
- goBack: () => void;
109
- reset: () => void;
110
- signOut: () => void;
111
- }
112
- /** Auth flow context value provided by SSOAuthProvider. */
113
- export interface AuthFlowContextValue {
114
- state: AuthFlowState;
115
- actions: AuthFlowActions;
116
- /** Session when step is AUTHENTICATED. */
117
- session: SSOSession | null;
118
- /** True while step is CHECKING_SESSION. */
119
- isLoading: boolean;
120
- /** Provider config for Google/Apple (One Tap, Sign-In button). */
121
- providerConfig: AuthFlowProviderConfig | undefined;
122
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Auth domain types: session, adapter, provider, flow state, errors, device detection.
3
- */
4
- export * from './auth-types';
5
- export * from './auth-api-adapter';
6
- export * from './auth-provider';
7
- export * from './sso-session';
8
- export * from './device-detection';
9
- export * from './flow';
@@ -1,33 +0,0 @@
1
- /**
2
- * SSO session and token storage types.
3
- */
4
- /** How/where the SSO token is stored for cross-app access. */
5
- export interface TokenStorageStrategy {
6
- get(): string | null;
7
- set(token: string, expiresAt: number): void;
8
- remove(): void;
9
- }
10
- /** Minimal request config type for the interceptor (no axios import). */
11
- export interface AxiosRequestConfig {
12
- headers?: Record<string, string> | {
13
- [key: string]: string;
14
- };
15
- withCredentials?: boolean;
16
- }
17
- /**
18
- * Axios instance shape needed to attach auth interceptors (avoids hard axios dependency).
19
- * Use createAxiosAuthInterceptors with your axios instance.
20
- */
21
- export interface AxiosAuthInterceptorInstance {
22
- interceptors: {
23
- request: {
24
- use(onFulfilled?: (config: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>, onRejected?: (err: unknown) => unknown): number;
25
- };
26
- response: {
27
- use(onFulfilled?: (res: unknown) => unknown, onRejected?: (err: unknown) => unknown): number;
28
- };
29
- };
30
- defaults: {
31
- withCredentials?: boolean;
32
- };
33
- }