doct-ui-auth-kit 1.0.23 → 1.0.24

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.
@@ -3,6 +3,7 @@
3
3
  * Consumers implement AuthApiAdapter to connect the SDK to their central auth service.
4
4
  */
5
5
  import type { AuthenticateWithProviderParams, CompleteProfileParams, SendOtpResponse, SSOSession, UserType, VerifyOtpResponse } from './auth-types';
6
+ import type { LinkOrMergeOtpTarget } from './flow';
6
7
  /** Parameters for sending OTP to phone or email. */
7
8
  export interface SendOtpParams {
8
9
  type: 'phone' | 'email';
@@ -39,6 +40,13 @@ export type LinkOrMergeAccountParams = (LinkOrMergeBaseParams & {
39
40
  newCountryCode: string;
40
41
  newPhone: string;
41
42
  });
43
+ export type LinkOrMergeAccountResponse = SSOSession | {
44
+ otpTarget: LinkOrMergeOtpTarget;
45
+ } | void;
46
+ export interface VerifyLinkOrMergeOtpParams extends LinkOrMergeOtpTarget {
47
+ otp: string;
48
+ conflictField: 'email' | 'phone';
49
+ }
42
50
  /**
43
51
  * Adapter implemented by the consumer to talk to the central auth service.
44
52
  * All methods return promises; the SDK handles loading/error state.
@@ -72,7 +80,12 @@ export interface AuthApiAdapter {
72
80
  * duplicate new email/mobile. Implementations should only send the fields
73
81
  * for `params.conflictField`.
74
82
  */
75
- linkOrMergeAccount?(params: LinkOrMergeAccountParams): Promise<SSOSession | void>;
83
+ linkOrMergeAccount?(params: LinkOrMergeAccountParams): Promise<LinkOrMergeAccountResponse>;
84
+ /**
85
+ * Optional: verify the OTP sent by linkOrMergeAccount. Called after the
86
+ * user enters the OTP received on the existing/old email or mobile.
87
+ */
88
+ verifyLinkOrMergeOtp?(params: VerifyLinkOrMergeOtpParams): Promise<SSOSession>;
76
89
  /** Optional: clear server-side cookie/session on sign out. */
77
90
  logout?(): Promise<void>;
78
91
  }
@@ -5,7 +5,14 @@ import type { AuthStep, SSOSession, UserType } from './auth-types';
5
5
  /** Identifier type for OTP / profile steps. */
6
6
  export type IdentifierType = 'phone' | 'email';
7
7
  export type LinkOrMergeConflictField = IdentifierType;
8
- export type LinkOrMergeStage = 'summary' | 'verification';
8
+ export type LinkOrMergeStage = 'summary' | 'otp';
9
+ export interface LinkOrMergeOtpTarget {
10
+ type: IdentifierType;
11
+ value: string;
12
+ countryCode?: string;
13
+ phone?: string;
14
+ maskedValue?: string;
15
+ }
9
16
  export type LinkOrMergeState = {
10
17
  stage: LinkOrMergeStage;
11
18
  conflictField: 'email';
@@ -15,6 +22,7 @@ export type LinkOrMergeState = {
15
22
  existingPhone?: string;
16
23
  oldEmail?: string;
17
24
  newEmail: string;
25
+ otpTarget?: LinkOrMergeOtpTarget;
18
26
  } | {
19
27
  stage: LinkOrMergeStage;
20
28
  conflictField: 'phone';
@@ -26,17 +34,7 @@ export type LinkOrMergeState = {
26
34
  oldPhone?: string;
27
35
  newCountryCode: string;
28
36
  newPhone: string;
29
- };
30
- export type LinkOrMergeVerificationInput = {
31
- conflictField: 'email';
32
- oldEmail: string;
33
- newEmail: string;
34
- } | {
35
- conflictField: 'phone';
36
- oldCountryCode: string;
37
- oldPhone: string;
38
- newCountryCode: string;
39
- newPhone: string;
37
+ otpTarget?: LinkOrMergeOtpTarget;
40
38
  };
41
39
  export type LinkOrMergeSetupPayload = (Omit<Extract<LinkOrMergeState, {
42
40
  conflictField: 'email';
@@ -112,7 +110,8 @@ export type AuthFlowAction = {
112
110
  } | ({
113
111
  type: 'SET_STEP_LINK_OR_MERGE';
114
112
  } & LinkOrMergeSetupPayload) | {
115
- type: 'SET_LINK_OR_MERGE_VERIFICATION_STAGE';
113
+ type: 'SET_LINK_OR_MERGE_OTP_STAGE';
114
+ otpTarget: LinkOrMergeOtpTarget;
116
115
  } | {
117
116
  type: 'SET_STEP_PROVIDER_PENDING';
118
117
  } | {
@@ -175,8 +174,8 @@ export interface AuthFlowActions {
175
174
  provider: 'google' | 'apple';
176
175
  credential: string;
177
176
  }) => void;
178
- continueLinkOrMerge: () => void;
179
- verifyLinkOrMerge: (data: LinkOrMergeVerificationInput) => Promise<void>;
177
+ continueLinkOrMerge: () => Promise<void>;
178
+ verifyLinkOrMerge: (otp: string) => Promise<void>;
180
179
  goBack: () => void;
181
180
  reset: () => void;
182
181
  signOut: () => void;
@@ -2,7 +2,7 @@
2
2
  * Props and public types for auth page components.
3
3
  */
4
4
  import type { UserType } from '../auth/auth-types';
5
- import type { IdentifierType, LinkOrMergeState, LinkOrMergeVerificationInput } from '../auth/flow';
5
+ import type { IdentifierType, LinkOrMergeState } from '../auth/flow';
6
6
  import type { LoginEntryMode } from './login-form';
7
7
  import type { UseMainAuthPageHandlersOptions } from './main-login';
8
8
  import type { OtpValidateFn, OtpVerificationMode } from './otp-verification';
@@ -88,8 +88,9 @@ export interface SignupPageFullProps extends SignupPageProps {
88
88
  export interface LinkOrMergePageProps {
89
89
  details: LinkOrMergeState;
90
90
  onBack?: (() => void) | undefined;
91
- onContinue: () => void;
92
- onVerify: (data: LinkOrMergeVerificationInput) => Promise<void>;
91
+ onContinue: () => Promise<void>;
92
+ onVerify: (otp: string) => Promise<void>;
93
+ onResendCode?: (() => void) | undefined;
93
94
  }
94
95
  /** Props for OtpVerification (inner form without layout). */
95
96
  export interface OtpVerificationProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doct-ui-auth-kit",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Composable React auth SDK – layouts, login/signup/OTP pages, SSO provider, and auth flow hooks for Docthub",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",