doct-ui-auth-kit 1.0.13 → 1.0.14
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/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/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 +127 -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 +9 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type EmailFormValues, type LoginEntryFormValues, type LoginEntryMode, type PhoneFormValues, type UseLoginEntryFormOptions, type UseLoginEntryFormReturn, useLoginEntryForm, } from './use-login-entry-form';
|
|
2
|
+
export { type MainAuthPageHandlers, type MainLoginAppleProviderConfig, type MainLoginGoogleProviderConfig, type MainLoginPageProvidersConfig, type UseMainAuthPageHandlersOptions, useMainAuthPageHandlers, } from './use-main-auth-page-handlers';
|
|
3
|
+
export { DEFAULT_OTP_TITLES, OTP_LENGTH, type OtpFormValues, type OtpVerificationMode, RESEND_COOLDOWN_EMAIL_SECONDS, RESEND_COOLDOWN_PHONE_SECONDS, type UseOtpVerificationOptions, type UseOtpVerificationReturn, useOtpVerification, } from './use-otp-verification';
|
|
4
|
+
export { type UseRepeatLoginOptions, type UseRepeatLoginReturn, useRepeatLogin, } from './use-repeat-login';
|
|
5
|
+
export { type SignupEmailFormValues, type SignupEntryMode, type SignupFormValues, type SignupPhoneFormValues, type UseSignupFormOptions, type UseSignupFormReturn, useSignupForm, } from './use-signup-form';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UseLoginEntryFormOptions, UseLoginEntryFormReturn } from '../types';
|
|
2
|
+
export type { EmailFormValues, LoginEntryFormValues, LoginEntryMode, LoginEntrySubmitData, LoginEntrySuccessParams, PhoneFormValues, UseLoginEntryFormOptions, UseLoginEntryFormReturn, } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Form state and validation for the login entry screen (phone or email).
|
|
5
|
+
*
|
|
6
|
+
* **Dual submission pattern:**
|
|
7
|
+
* - `submitApi` (async): hook owns the flow — validate → submitApi(data) → onSuccess(). Future SSO API integration 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 (loginSchemas[mode]) → setFormErrorsFromZod → field-level errors.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useLoginEntryForm({ mode, onSubmit, submitApi, onSuccess, onError, }: UseLoginEntryFormOptions): UseLoginEntryFormReturn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { 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,10 +1,10 @@
|
|
|
1
|
-
import type { OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn } from '
|
|
2
|
-
export type { OtpFormValues, OtpValidateFn, OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn, } from '
|
|
1
|
+
import type { OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn } from '../types';
|
|
2
|
+
export type { OtpFormValues, OtpValidateFn, OtpVerificationMode, UseOtpVerificationOptions, UseOtpVerificationReturn, } from '../types';
|
|
3
3
|
/** Instruction line below recipient (Figma: "Kindly check your Email Inbox."). */
|
|
4
4
|
export declare const DEFAULT_OTP_INSTRUCTIONS: Record<OtpVerificationMode, string>;
|
|
5
5
|
export declare const DEFAULT_OTP_TITLES: Record<OtpVerificationMode, string>;
|
|
6
6
|
/** Re-export for consumers who import from hooks. */
|
|
7
|
-
export { getResendCooldownSeconds, OTP_LENGTH, RESEND_COOLDOWN_EMAIL_SECONDS, RESEND_COOLDOWN_PHONE_SECONDS, } from '
|
|
7
|
+
export { getResendCooldownSeconds, OTP_LENGTH, RESEND_COOLDOWN_EMAIL_SECONDS, RESEND_COOLDOWN_PHONE_SECONDS, } from '../validations';
|
|
8
8
|
/**
|
|
9
9
|
* Form state, resend countdown, and validation for OTP verification.
|
|
10
10
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { 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
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth SDK UI Kit – library entry point.
|
|
3
|
+
* Consumers can import components, layouts (composition + preset), hooks, core (SSO provider, flow, session), and auth methods.
|
|
4
|
+
*
|
|
5
|
+
* Import the kit styles once globally in your app (e.g. in main.tsx):
|
|
6
|
+
* `import 'doct-ui-auth-kit/style.css';`
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import {
|
|
11
|
+
* SSOAuthProvider,
|
|
12
|
+
* AuthFlow,
|
|
13
|
+
* useAuthFlow,
|
|
14
|
+
* useAuthSession,
|
|
15
|
+
* MainLayout,
|
|
16
|
+
* AuthLayout,
|
|
17
|
+
* ImageSlider,
|
|
18
|
+
* AuthLayoutWrapper,
|
|
19
|
+
* LoginEntry,
|
|
20
|
+
* OtpVerification,
|
|
21
|
+
* useGoogleAuth,
|
|
22
|
+
* } from 'doct-ui-auth-kit';
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import './index.css';
|
|
26
|
+
export { createHttpAuthAdapter } from './adapters';
|
|
27
|
+
export { Auth } from './auth';
|
|
28
|
+
export type { UseAppleSignInOptions, UseGoogleAuthOptions, UseGoogleAuthReturn, } from './auth-methods';
|
|
29
|
+
export { useAppleSignIn, useGoogleAuth } from './auth-methods';
|
|
30
|
+
export type { BackButtonProps } from './components/common';
|
|
31
|
+
export { BackButton, DefaultFooter, EnterpriseHeader, } from './components/common';
|
|
32
|
+
export type { AuthLayoutPresetProps, AuthLayoutType, AuthLayoutWrapperProps, } from './components/layout';
|
|
33
|
+
export { AuthLayout, AuthLayoutPreset, AuthLayoutWrapper, ImageSlider, MainLayout, } from './components/layout';
|
|
34
|
+
export * from './core';
|
|
35
|
+
export * from './hooks';
|
|
36
|
+
export type { LoginEntryPageProps, LoginEntryProps, MainLoginPageProps, MainLoginPageProvidersConfig, OtpVerificationPageProps, OtpVerificationProps, RepeatLoginPageProps, RepeatLoginProps, SignupPageFullProps, SignupPageProps, } from './pages/index';
|
|
37
|
+
export { LoginEntry, LoginEntryPage, MainLogin, MainLoginPage, OtpVerification, OtpVerificationPage, RepeatLogin, RepeatLoginPage, Signup, SignupPage, } from './pages/index';
|
|
38
|
+
export * from './types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page components barrel: *Page = full page with layout, bare name = form-only for composition.
|
|
3
|
+
*/
|
|
4
|
+
export { LoginEntry, type LoginEntryMode, LoginEntryPage, 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';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { 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 {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API adapter types for the SSO auth SDK.
|
|
3
|
+
* Consumers implement AuthApiAdapter to connect the SDK to their central auth service.
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthenticateWithProviderParams, CompleteProfileParams, SendOtpResponse, SSOSession, UserType, VerifyOtpResponse } from './auth-types';
|
|
6
|
+
/** Parameters for sending OTP to phone or email. */
|
|
7
|
+
export interface SendOtpParams {
|
|
8
|
+
type: 'phone' | 'email';
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
/** Parameters for verifying OTP. */
|
|
12
|
+
export interface VerifyOtpParams {
|
|
13
|
+
type: 'phone' | 'email';
|
|
14
|
+
value: string;
|
|
15
|
+
otp: string;
|
|
16
|
+
}
|
|
17
|
+
/** Optional lookup to branch flows before sending OTP (e.g. foreign existing user). */
|
|
18
|
+
export interface CheckIdentifierParams {
|
|
19
|
+
type: 'phone' | 'email';
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
/** Optional lookup response used by the provider to choose the next step. */
|
|
23
|
+
export interface CheckIdentifierResponse {
|
|
24
|
+
exists: boolean;
|
|
25
|
+
userType?: UserType;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adapter implemented by the consumer to talk to the central auth service.
|
|
29
|
+
* All methods return promises; the SDK handles loading/error state.
|
|
30
|
+
*/
|
|
31
|
+
export interface AuthApiAdapter {
|
|
32
|
+
/** Send OTP to the given phone or email. */
|
|
33
|
+
sendOtp(params: SendOtpParams): Promise<SendOtpResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Verify OTP. Returns session if existing user, or isNewUser flag for profile completion.
|
|
36
|
+
* May return conflict error when identifier is linked to another account.
|
|
37
|
+
*/
|
|
38
|
+
verifyOtp(params: VerifyOtpParams): Promise<VerifyOtpResponse>;
|
|
39
|
+
/** Complete profile for new users; returns SSO session. */
|
|
40
|
+
completeProfile(params: CompleteProfileParams): Promise<SSOSession>;
|
|
41
|
+
/** Authenticate with a third-party provider (Google/Apple) credential. */
|
|
42
|
+
authenticateWithProvider(params: AuthenticateWithProviderParams): Promise<VerifyOtpResponse>;
|
|
43
|
+
/** Validate an existing SSO session token; called on SDK mount. Returns null if invalid/expired. */
|
|
44
|
+
validateSession(token: string): Promise<SSOSession | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Optional: validate session using server-read cookie (no token from client).
|
|
47
|
+
* Required when using serverCookieTokenStorage. Client sends credentials;
|
|
48
|
+
* server reads cookie from the request and returns session or null.
|
|
49
|
+
*/
|
|
50
|
+
validateSessionFromCookie?(): Promise<SSOSession | null>;
|
|
51
|
+
/** Optional: refresh an expired SSO session using refresh token. */
|
|
52
|
+
refreshSession?(refreshToken: string): Promise<SSOSession | null>;
|
|
53
|
+
/** Optional: check identifier existence before OTP routing decisions. */
|
|
54
|
+
checkIdentifier?(params: CheckIdentifierParams): Promise<CheckIdentifierResponse>;
|
|
55
|
+
/** Optional: clear server-side cookie/session on sign out. */
|
|
56
|
+
logout?(): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { AuthApiAdapter } from './auth-api-adapter';
|
|
3
|
+
import type { AuthError, SSOSession } from './auth-types';
|
|
4
|
+
import type { 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
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for device-based repeat-login detection and persistence.
|
|
3
|
+
*/
|
|
4
|
+
import type { AuthMethod } from './auth-types';
|
|
5
|
+
/** Stored repeat-login info (method + masked identifier). */
|
|
6
|
+
export interface StoredRepeatLogin {
|
|
7
|
+
/** The authentication method used in the previous login (e.g. `'phone'`, `'email'`, `'google'`). */
|
|
8
|
+
method: AuthMethod;
|
|
9
|
+
/** Partially masked identifier shown to the user (e.g. `"****1234"` or `"j***@example.com"`). */
|
|
10
|
+
maskedIdentifier: string;
|
|
11
|
+
/** Unix epoch (ms) when this login record was stored. Used for expiry checks. */
|
|
12
|
+
timestamp: number;
|
|
13
|
+
}
|