doct-ui-auth-kit 1.0.12 → 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/common/enterprise-header.d.ts +22 -0
- package/dist/components/common/index.d.ts +3 -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 +35 -0
- 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 +28 -0
- 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 +15 -0
- package/dist/hooks/use-repeat-login.d.ts +9 -0
- package/dist/hooks/use-signup-form.d.ts +12 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +1364 -1346
- package/dist/pages/index.d.ts +8 -0
- package/dist/pages/login-entry/index.d.ts +3 -0
- package/dist/pages/login-entry/login-entry-page.d.ts +21 -0
- package/dist/pages/login-entry/login-entry.d.ts +21 -0
- package/dist/pages/main-login/index.d.ts +3 -0
- package/dist/pages/main-login/main-login-page.d.ts +16 -0
- package/dist/pages/main-login/main-login.d.ts +25 -0
- package/dist/pages/otp-verification/index.d.ts +3 -0
- package/dist/pages/otp-verification/otp-verification-page.d.ts +23 -0
- package/dist/pages/otp-verification/otp-verification.d.ts +22 -0
- package/dist/pages/repeat-login/index.d.ts +3 -0
- package/dist/pages/repeat-login/repeat-login-page.d.ts +24 -0
- package/dist/pages/repeat-login/repeat-login.d.ts +25 -0
- package/dist/pages/signup/index.d.ts +3 -0
- package/dist/pages/signup/signup-page.d.ts +6 -0
- package/dist/pages/signup/signup.d.ts +7 -0
- package/dist/pages.js +1 -1
- package/dist/signup-page-ChXnxtSS.js +1683 -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/main-login.d.ts +51 -0
- package/dist/types/pages/otp-verification.d.ts +53 -0
- package/dist/types/pages/pages.d.ts +146 -0
- 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
- package/dist/signup-page-x-C4j5YV.js +0 -1629
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSO session management: token persistence strategies.
|
|
3
|
+
* - `localStorageTokenStorage`: single-origin, suitable for dev.
|
|
4
|
+
* - `serverCookieTokenStorage`: HttpOnly cookie-based, for production SSO.
|
|
5
|
+
* - `createAxiosAuthInterceptors`: attaches withCredentials + 401 handling to an axios instance.
|
|
6
|
+
*/
|
|
7
|
+
import type { AxiosAuthInterceptorInstance, TokenStorageStrategy } from '../types';
|
|
8
|
+
export type { AxiosAuthInterceptorInstance, AxiosRequestConfig, TokenStorageStrategy, } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Token storage using localStorage (single-origin).
|
|
11
|
+
* Suitable for dev or when all Docthub apps share the same origin.
|
|
12
|
+
*/
|
|
13
|
+
export declare function localStorageTokenStorage(): TokenStorageStrategy;
|
|
14
|
+
/**
|
|
15
|
+
* Token storage when the token lives in a server-set cookie (e.g. HttpOnly).
|
|
16
|
+
* The client never reads or writes the token; the server sets the cookie on
|
|
17
|
+
* login and reads it from the request. Use with validateSessionFromCookie
|
|
18
|
+
* in your adapter and createAxiosAuthInterceptors (withCredentials) so the
|
|
19
|
+
* cookie is sent on every request.
|
|
20
|
+
*/
|
|
21
|
+
export declare function serverCookieTokenStorage(): TokenStorageStrategy;
|
|
22
|
+
/**
|
|
23
|
+
* Attaches request and response interceptors to an axios instance for SSO auth
|
|
24
|
+
* when using server-side cookies (e.g. serverCookieTokenStorage):
|
|
25
|
+
* - Request: sets withCredentials so the browser sends cookies on every request.
|
|
26
|
+
* - Response: on 401, calls onUnauthorized (e.g. redirect to login).
|
|
27
|
+
*
|
|
28
|
+
* @param axiosInstance - Your axios instance (e.g. axios.create({ baseURL: '...' }))
|
|
29
|
+
* @param onUnauthorized - Optional callback when a response has status 401
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAxiosAuthInterceptors(axiosInstance: AxiosAuthInterceptorInstance, onUnauthorized?: () => void): void;
|
|
32
|
+
/**
|
|
33
|
+
* useAuthSession hook is implemented in auth-context (uses AuthFlowContext).
|
|
34
|
+
* Re-exported from core index for consumer convenience.
|
|
35
|
+
*/
|
|
@@ -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,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth flow state machine: reducer and state type.
|
|
3
|
+
* Side effects (API calls, token persistence) are performed by the provider; this module is pure.
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthFlowAction, AuthFlowState, AuthStep } from '../types';
|
|
6
|
+
export type { AuthFlowAction, AuthFlowState, IdentifierType } from '../types';
|
|
7
|
+
export declare const INITIAL_STEP: AuthStep;
|
|
8
|
+
export declare function getInitialAuthFlowState(): AuthFlowState;
|
|
9
|
+
export declare function authFlowReducer(state: AuthFlowState, action: AuthFlowAction): AuthFlowState;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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';
|