doct-ui-auth-kit 1.0.13 → 1.0.15

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 (85) hide show
  1. package/dist/adapters/http-auth-adapter.d.ts +13 -0
  2. package/dist/adapters/index.d.ts +1 -0
  3. package/dist/auth/index.d.ts +28 -0
  4. package/dist/auth-methods/apple.d.ts +19 -0
  5. package/dist/auth-methods/google.d.ts +5 -0
  6. package/dist/auth-methods/index.d.ts +2 -0
  7. package/dist/auth-methods/use-google-auth.d.ts +69 -0
  8. package/dist/components/common/back-button.d.ts +13 -0
  9. package/dist/components/common/default-footer.d.ts +5 -0
  10. package/dist/components/form/rhf-doct-phone-input.d.ts +2 -0
  11. package/dist/components/form/rhf-input-field.d.ts +2 -0
  12. package/dist/components/form/rhf-otp-input-field.d.ts +3 -0
  13. package/dist/components/layout/auth-layout-preset.d.ts +30 -0
  14. package/dist/components/layout/auth-layout-public.d.ts +17 -0
  15. package/dist/components/layout/auth-layout-wrapper.d.ts +42 -0
  16. package/dist/components/layout/auth-layout.d.ts +89 -0
  17. package/dist/components/layout/image-slider.d.ts +28 -0
  18. package/dist/components/layout/index.d.ts +8 -0
  19. package/dist/components/layout/main-layout.d.ts +30 -0
  20. package/dist/constants/brand.d.ts +9 -0
  21. package/dist/constants/demo-slider.d.ts +14 -0
  22. package/dist/constants/index.d.ts +4 -0
  23. package/dist/constants/layout-classes.d.ts +10 -0
  24. package/dist/constants/layout-presets.d.ts +10 -0
  25. package/dist/core/auth-api-adapter.d.ts +6 -0
  26. package/dist/core/auth-context.d.ts +21 -0
  27. package/dist/core/auth-flow.d.ts +1 -1
  28. package/dist/core/auth-provider.d.ts +8 -0
  29. package/dist/core/auth-types.d.ts +5 -0
  30. package/dist/core/device-detection.d.ts +19 -0
  31. package/dist/core/index.d.ts +12 -0
  32. package/dist/core/sso-session.d.ts +35 -0
  33. package/dist/core/use-auth-flow-router-sync.d.ts +1 -1
  34. package/dist/core/use-auth-flow.d.ts +9 -0
  35. package/dist/hooks/index.d.ts +5 -0
  36. package/dist/hooks/use-login-entry-form.d.ts +12 -0
  37. package/dist/hooks/use-main-auth-page-handlers.d.ts +9 -0
  38. package/dist/hooks/use-otp-verification.d.ts +3 -3
  39. package/dist/hooks/use-repeat-login.d.ts +9 -0
  40. package/dist/hooks/use-signup-form.d.ts +12 -0
  41. package/dist/index.d.ts +38 -0
  42. package/dist/index.js +321 -313
  43. package/dist/pages/index.d.ts +8 -0
  44. package/dist/pages/login-entry/index.d.ts +3 -0
  45. package/dist/pages/login-entry/login-entry-page.d.ts +21 -0
  46. package/dist/pages/login-entry/login-entry.d.ts +21 -0
  47. package/dist/pages/main-login/index.d.ts +3 -0
  48. package/dist/pages/main-login/main-login-page.d.ts +16 -0
  49. package/dist/pages/main-login/main-login.d.ts +25 -0
  50. package/dist/pages/otp-verification/index.d.ts +3 -0
  51. package/dist/pages/otp-verification/otp-verification-page.d.ts +23 -0
  52. package/dist/pages/otp-verification/otp-verification.d.ts +22 -0
  53. package/dist/pages/repeat-login/index.d.ts +3 -0
  54. package/dist/pages/repeat-login/repeat-login-page.d.ts +24 -0
  55. package/dist/pages/repeat-login/repeat-login.d.ts +25 -0
  56. package/dist/pages/signup/index.d.ts +3 -0
  57. package/dist/pages/signup/signup-page.d.ts +6 -0
  58. package/dist/pages/signup/signup.d.ts +7 -0
  59. package/dist/pages.js +1 -1
  60. package/dist/{signup-page-ChXnxtSS.js → signup-page-LsYojX4-.js} +43 -38
  61. package/dist/types/auth/auth-api-adapter.d.ts +57 -0
  62. package/dist/types/auth/auth-provider.d.ts +40 -0
  63. package/dist/types/auth/auth-types.d.ts +70 -0
  64. package/dist/types/auth/device-detection.d.ts +13 -0
  65. package/dist/types/auth/flow.d.ts +133 -0
  66. package/dist/types/auth/index.d.ts +10 -0
  67. package/dist/types/auth/router.d.ts +60 -0
  68. package/dist/types/auth/sso-session.d.ts +33 -0
  69. package/dist/types/components/auth-layout-types.d.ts +92 -0
  70. package/dist/types/components/forms.d.ts +77 -0
  71. package/dist/types/components/index.d.ts +7 -0
  72. package/dist/types/components/layout-presets.d.ts +29 -0
  73. package/dist/types/components/layout.d.ts +57 -0
  74. package/dist/types/index.d.ts +7 -0
  75. package/dist/types/pages/index.d.ts +9 -0
  76. package/dist/types/pages/login-form.d.ts +57 -0
  77. package/dist/types/pages/otp-verification.d.ts +1 -1
  78. package/dist/types/pages/repeat-login.d.ts +29 -0
  79. package/dist/types/pages/signup-form.d.ts +49 -0
  80. package/dist/utils/build-phone-recipient.d.ts +12 -0
  81. package/dist/utils/index.d.ts +5 -0
  82. package/dist/utils/set-form-errors-from-zod.d.ts +11 -0
  83. package/dist/validations/index.d.ts +6 -0
  84. package/dist/validations/schemas.d.ts +87 -0
  85. package/package.json +110 -109
@@ -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,3 @@
1
+ export type { LoginEntryMode, LoginEntryPageProps, LoginEntryProps, } from '../../types';
2
+ export { LoginEntry } from './login-entry';
3
+ export { LoginEntryPage } from './login-entry-page';
@@ -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,3 @@
1
+ export type { MainLoginAppleProviderConfig, MainLoginGoogleProviderConfig, MainLoginPageProps, MainLoginPageProvidersConfig, } from '../../types';
2
+ export { MainLogin } from './main-login';
3
+ export { MainLoginPage } from './main-login-page';
@@ -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,3 @@
1
+ export type { OtpVerificationMode, OtpVerificationPageProps, OtpVerificationProps, } from '../../types';
2
+ export { OtpVerification } from './otp-verification';
3
+ export { OtpVerificationPage } from './otp-verification-page';
@@ -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,3 @@
1
+ export type { RepeatLoginPageProps, RepeatLoginProps } from '../../types';
2
+ export { RepeatLogin } from './repeat-login';
3
+ export { RepeatLoginPage } from './repeat-login-page';
@@ -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,3 @@
1
+ export type { SignupEntryMode, SignupPageFullProps, SignupPageProps, } from '../../types';
2
+ export { Signup } from './signup';
3
+ export { SignupPage } from './signup-page';
@@ -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;
package/dist/pages.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { L as e, a as n, M as g, b as s, O as o, c as t, R as p, d as L, S as r, e as P } from "./signup-page-ChXnxtSS.js";
2
+ import { L as e, a as n, M as g, b as s, O as o, c as t, R as p, d as L, S as r, e as P } from "./signup-page-LsYojX4-.js";
3
3
  export {
4
4
  e as LoginEntry,
5
5
  n as LoginEntryPage,
@@ -2,7 +2,7 @@
2
2
  import { jsx as m, jsxs as k, Fragment as $e } from "react/jsx-runtime";
3
3
  import { DoctButton as B, DoctTypography as R, DoctPhoneInput as Ze, DoctLabeledInput as Qe, DoctCircularProgress as ve, DoctOtpInput as et } from "docthub-core-components";
4
4
  import { MdArrowBack as tt, MdChevronRight as nt } from "react-icons/md";
5
- import q, { createContext as lt, useContext as it, useState as K, useEffect as te, useRef as le } from "react";
5
+ import Y, { createContext as lt, useContext as it, useState as K, useEffect as te, useRef as le } from "react";
6
6
  import { useFormContext as ne, Controller as de, useForm as ye, FormProvider as Ce } from "react-hook-form";
7
7
  import { z as j } from "zod";
8
8
  var ae = { exports: {} }, ge = {};
@@ -10,7 +10,7 @@ var Oe;
10
10
  function ot() {
11
11
  if (Oe) return ge;
12
12
  Oe = 1;
13
- var n = q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
13
+ var n = Y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
14
14
  return ge.c = function(e) {
15
15
  return n.H.useMemoCache(e);
16
16
  }, ge;
@@ -19,7 +19,7 @@ var pe = {};
19
19
  var Te;
20
20
  function rt() {
21
21
  return Te || (Te = 1, process.env.NODE_ENV !== "production" && (function() {
22
- var n = q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
22
+ var n = Y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
23
23
  pe.c = function(e) {
24
24
  var t = n.H;
25
25
  return t === null && console.error(
@@ -277,7 +277,7 @@ function St(n) {
277
277
  let a;
278
278
  return e[7] !== o || e[8] !== s ? (a = /* @__PURE__ */ m("footer", { className: o, children: s }), e[7] = o, e[8] = s, e[9] = a) : a = e[9], a;
279
279
  }
280
- const H = {
280
+ const q = {
281
281
  Root: ht,
282
282
  Header: gt,
283
283
  Main: Ct,
@@ -436,32 +436,32 @@ function ie(n) {
436
436
  e[7] !== w || e[8] !== r ? (L = () => r ? typeof r == "string" ? /* @__PURE__ */ m(R, { variant: "body1", align: w, className: "text-neutral-black", children: r }) : r : null, e[7] = w, e[8] = r, e[9] = L) : L = e[9];
437
437
  const M = L;
438
438
  let I;
439
- e[10] !== a ? (I = a && /* @__PURE__ */ m(H.Header, { children: a }), e[10] = a, e[11] = I) : I = e[11];
439
+ e[10] !== a ? (I = a && /* @__PURE__ */ m(q.Header, { children: a }), e[10] = a, e[11] = I) : I = e[11];
440
440
  let U;
441
441
  e[12] !== $ ? (U = $(), e[12] = $, e[13] = U) : U = e[13];
442
- let z;
443
- e[14] !== w || e[15] !== U ? (z = /* @__PURE__ */ m(H.Logo, { align: w, children: U }), e[14] = w, e[15] = U, e[16] = z) : z = e[16];
444
442
  let G;
445
- e[17] !== w || e[18] !== T || e[19] !== o ? (G = o && /* @__PURE__ */ m(H.Title, { align: w, children: T() }), e[17] = w, e[18] = T, e[19] = o, e[20] = G) : G = e[20];
443
+ e[14] !== w || e[15] !== U ? (G = /* @__PURE__ */ m(q.Logo, { align: w, children: U }), e[14] = w, e[15] = U, e[16] = G) : G = e[16];
446
444
  let V;
447
- e[21] !== w || e[22] !== r || e[23] !== M ? (V = r && /* @__PURE__ */ m(H.Description, { align: w, children: M() }), e[21] = w, e[22] = r, e[23] = M, e[24] = V) : V = e[24];
445
+ e[17] !== w || e[18] !== T || e[19] !== o ? (V = o && /* @__PURE__ */ m(q.Title, { align: w, children: T() }), e[17] = w, e[18] = T, e[19] = o, e[20] = V) : V = e[20];
446
+ let H;
447
+ e[21] !== w || e[22] !== r || e[23] !== M ? (H = r && /* @__PURE__ */ m(q.Description, { align: w, children: M() }), e[21] = w, e[22] = r, e[23] = M, e[24] = H) : H = e[24];
448
448
  let W;
449
- e[25] !== t ? (W = /* @__PURE__ */ m(H.Body, { children: t }), e[25] = t, e[26] = W) : W = e[26];
450
- let Y;
451
- e[27] !== z || e[28] !== G || e[29] !== V || e[30] !== W || e[31] !== E ? (Y = /* @__PURE__ */ k(H.Main, { sm: E, children: [
452
- z,
449
+ e[25] !== t ? (W = /* @__PURE__ */ m(q.Body, { children: t }), e[25] = t, e[26] = W) : W = e[26];
450
+ let z;
451
+ e[27] !== G || e[28] !== V || e[29] !== H || e[30] !== W || e[31] !== E ? (z = /* @__PURE__ */ k(q.Main, { sm: E, children: [
453
452
  G,
454
453
  V,
454
+ H,
455
455
  W
456
- ] }), e[27] = z, e[28] = G, e[29] = V, e[30] = W, e[31] = E, e[32] = Y) : Y = e[32];
456
+ ] }), e[27] = G, e[28] = V, e[29] = H, e[30] = W, e[31] = E, e[32] = z) : z = e[32];
457
457
  let J;
458
- e[33] !== s ? (J = s && /* @__PURE__ */ m(H.Footer, { children: s }), e[33] = s, e[34] = J) : J = e[34];
458
+ e[33] !== s ? (J = s && /* @__PURE__ */ m(q.Footer, { children: s }), e[33] = s, e[34] = J) : J = e[34];
459
459
  let oe;
460
- e[35] !== I || e[36] !== Y || e[37] !== J ? (oe = /* @__PURE__ */ k($e, { children: [
460
+ e[35] !== I || e[36] !== z || e[37] !== J ? (oe = /* @__PURE__ */ k($e, { children: [
461
461
  I,
462
- Y,
462
+ z,
463
463
  J
464
- ] }), e[35] = I, e[36] = Y, e[37] = J, e[38] = oe) : oe = e[38];
464
+ ] }), e[35] = I, e[36] = z, e[37] = J, e[38] = oe) : oe = e[38];
465
465
  const X = oe;
466
466
  if (C === "withSlider") {
467
467
  let Q;
@@ -469,7 +469,7 @@ function ie(n) {
469
469
  className: y
470
470
  }, e[39] = y, e[40] = Q) : Q = e[40];
471
471
  let ee;
472
- e[41] !== X || e[42] !== x || e[43] !== O ? (ee = /* @__PURE__ */ m(H.Root, { variant: O, maxWidth: x, className: "bg-transparent", children: X }), e[41] = X, e[42] = x, e[43] = O, e[44] = ee) : ee = e[44];
472
+ e[41] !== X || e[42] !== x || e[43] !== O ? (ee = /* @__PURE__ */ m(q.Root, { variant: O, maxWidth: x, className: "bg-transparent", children: X }), e[41] = X, e[42] = x, e[43] = O, e[44] = ee) : ee = e[44];
473
473
  let se;
474
474
  return e[45] !== S || e[46] !== N || e[47] !== f || e[48] !== Q || e[49] !== ee ? (se = /* @__PURE__ */ m(wt, { sliderImages: N, sliderAutoPlayInterval: S, sliderTitles: f, ...Q, children: ee }), e[45] = S, e[46] = N, e[47] = f, e[48] = Q, e[49] = ee, e[50] = se) : se = e[50], se;
475
475
  }
@@ -478,7 +478,7 @@ function ie(n) {
478
478
  className: y
479
479
  }, e[51] = y, e[52] = Z) : Z = e[52];
480
480
  let re;
481
- return e[53] !== X || e[54] !== x || e[55] !== O || e[56] !== Z ? (re = /* @__PURE__ */ m(H.Root, { variant: O, maxWidth: x, ...Z, children: X }), e[53] = X, e[54] = x, e[55] = O, e[56] = Z, e[57] = re) : re = e[57], re;
481
+ return e[53] !== X || e[54] !== x || e[55] !== O || e[56] !== Z ? (re = /* @__PURE__ */ m(q.Root, { variant: O, maxWidth: x, ...Z, children: X }), e[53] = X, e[54] = x, e[55] = O, e[56] = Z, e[57] = re) : re = e[57], re;
482
482
  }
483
483
  function _t(n) {
484
484
  return {
@@ -900,7 +900,7 @@ var qe = {
900
900
  className: void 0,
901
901
  style: void 0,
902
902
  attr: void 0
903
- }, ke = q.createContext && /* @__PURE__ */ q.createContext(qe), Vt = ["attr", "size", "title"];
903
+ }, ke = Y.createContext && /* @__PURE__ */ Y.createContext(qe), Vt = ["attr", "size", "title"];
904
904
  function Ht(n, e) {
905
905
  if (n == null) return {};
906
906
  var t = qt(n, e), l, i;
@@ -970,12 +970,12 @@ function Jt(n, e) {
970
970
  return (e === "string" ? String : Number)(n);
971
971
  }
972
972
  function Ye(n) {
973
- return n && n.map((e, t) => /* @__PURE__ */ q.createElement(e.tag, he({
973
+ return n && n.map((e, t) => /* @__PURE__ */ Y.createElement(e.tag, he({
974
974
  key: t
975
975
  }, e.attr), Ye(e.child)));
976
976
  }
977
977
  function Ke(n) {
978
- return (e) => /* @__PURE__ */ q.createElement(Xt, me({
978
+ return (e) => /* @__PURE__ */ Y.createElement(Xt, me({
979
979
  attr: he({}, n.attr)
980
980
  }, e), Ye(n.child));
981
981
  }
@@ -986,7 +986,7 @@ function Xt(n) {
986
986
  size: i,
987
987
  title: o
988
988
  } = n, r = Ht(n, Vt), s = i || t.size || "1em", a;
989
- return t.className && (a = t.className), n.className && (a = (a ? a + " " : "") + n.className), /* @__PURE__ */ q.createElement("svg", me({
989
+ return t.className && (a = t.className), n.className && (a = (a ? a + " " : "") + n.className), /* @__PURE__ */ Y.createElement("svg", me({
990
990
  stroke: "currentColor",
991
991
  fill: "currentColor",
992
992
  strokeWidth: "0"
@@ -998,9 +998,9 @@ function Xt(n) {
998
998
  height: s,
999
999
  width: s,
1000
1000
  xmlns: "http://www.w3.org/2000/svg"
1001
- }), o && /* @__PURE__ */ q.createElement("title", null, o), n.children);
1001
+ }), o && /* @__PURE__ */ Y.createElement("title", null, o), n.children);
1002
1002
  };
1003
- return ke !== void 0 ? /* @__PURE__ */ q.createElement(ke.Consumer, null, (t) => e(t)) : e(qe);
1003
+ return ke !== void 0 ? /* @__PURE__ */ Y.createElement(ke.Consumer, null, (t) => e(t)) : e(qe);
1004
1004
  }
1005
1005
  function Zt(n) {
1006
1006
  return Ke({ attr: { viewBox: "0 0 384 512" }, child: [{ tag: "path", attr: { d: "M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z" }, child: [] }] })(n);
@@ -1097,26 +1097,27 @@ function rn(n) {
1097
1097
  e[4] !== f ? (N = () => {
1098
1098
  if (f <= 0)
1099
1099
  return;
1100
- const z = setInterval(() => {
1100
+ const G = setInterval(() => {
1101
1101
  p(an);
1102
1102
  }, 1e3);
1103
- return () => clearInterval(z);
1103
+ return () => clearInterval(G);
1104
1104
  }, S = [f], e[4] = f, e[5] = N, e[6] = S) : (N = e[5], S = e[6]), te(N, S);
1105
1105
  let x;
1106
- e[7] !== C || e[8] !== s || e[9] !== l || e[10] !== r || e[11] !== o || e[12] !== a ? (x = async (z) => {
1107
- const G = He.safeParse(z);
1108
- if (!G.success) {
1109
- const W = G.error.issues[0]?.message ?? "Invalid OTP";
1106
+ e[7] !== C || e[8] !== s || e[9] !== l || e[10] !== r || e[11] !== o || e[12] !== a ? (x = async (G) => {
1107
+ C.clearErrors("otp");
1108
+ const V = He.safeParse(G);
1109
+ if (!V.success) {
1110
+ const W = V.error.issues[0]?.message ?? "Invalid OTP";
1110
1111
  C.setError("otp", {
1111
1112
  message: W
1112
1113
  });
1113
1114
  return;
1114
1115
  }
1115
- const V = G.data.otp.join("");
1116
+ const H = V.data.otp.join("");
1116
1117
  if (a) {
1117
1118
  u(!0);
1118
1119
  try {
1119
- const W = await a(V);
1120
+ const W = await a(H);
1120
1121
  if (W !== !0) {
1121
1122
  C.setError("otp", {
1122
1123
  type: "validate",
@@ -1131,16 +1132,20 @@ function rn(n) {
1131
1132
  o || u(!1);
1132
1133
  }
1133
1134
  if (o) {
1134
- u(!0), o(V).then(() => {
1135
+ u(!0), o(H).then(() => {
1135
1136
  r?.();
1136
1137
  }).catch((W) => {
1137
- s?.(W);
1138
+ const z = W?.message;
1139
+ C.setError("otp", {
1140
+ type: "submit",
1141
+ message: typeof z == "string" && z.length > 0 ? z : "OTP verification failed"
1142
+ }), s?.(W);
1138
1143
  }).finally(() => {
1139
1144
  u(!1);
1140
1145
  });
1141
1146
  return;
1142
1147
  }
1143
- l?.(V);
1148
+ l?.(H);
1144
1149
  }, e[7] = C, e[8] = s, e[9] = l, e[10] = r, e[11] = o, e[12] = a, e[13] = x) : x = e[13];
1145
1150
  const A = x;
1146
1151
  let w;
@@ -1666,7 +1671,7 @@ export {
1666
1671
  On as d,
1667
1672
  Tn as e,
1668
1673
  _ as f,
1669
- H as g,
1674
+ q as g,
1670
1675
  _t as h,
1671
1676
  Tt as i,
1672
1677
  Be as j,
@@ -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
+ }