doct-ui-auth-kit 1.0.22 → 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';
@@ -30,18 +31,22 @@ interface LinkOrMergeBaseParams {
30
31
  }
31
32
  export type LinkOrMergeAccountParams = (LinkOrMergeBaseParams & {
32
33
  conflictField: 'email';
33
- oldEmail?: string;
34
- oldCountryCode?: string;
35
- oldPhone?: string;
34
+ oldEmail: string;
36
35
  newEmail: string;
37
36
  }) | (LinkOrMergeBaseParams & {
38
37
  conflictField: 'phone';
39
- oldEmail?: string;
40
- oldCountryCode?: string;
41
- oldPhone?: string;
38
+ oldCountryCode: string;
39
+ oldPhone: string;
42
40
  newCountryCode: string;
43
41
  newPhone: string;
44
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
+ }
45
50
  /**
46
51
  * Adapter implemented by the consumer to talk to the central auth service.
47
52
  * All methods return promises; the SDK handles loading/error state.
@@ -75,7 +80,12 @@ export interface AuthApiAdapter {
75
80
  * duplicate new email/mobile. Implementations should only send the fields
76
81
  * for `params.conflictField`.
77
82
  */
78
- 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>;
79
89
  /** Optional: clear server-side cookie/session on sign out. */
80
90
  logout?(): Promise<void>;
81
91
  }
@@ -5,22 +5,46 @@ 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' | 'otp';
9
+ export interface LinkOrMergeOtpTarget {
10
+ type: IdentifierType;
11
+ value: string;
12
+ countryCode?: string;
13
+ phone?: string;
14
+ maskedValue?: string;
15
+ }
8
16
  export type LinkOrMergeState = {
17
+ stage: LinkOrMergeStage;
9
18
  conflictField: 'email';
10
19
  name: string;
20
+ existingEmail?: string;
21
+ existingCountryCode?: string;
22
+ existingPhone?: string;
11
23
  oldEmail?: string;
12
- oldCountryCode?: string;
13
- oldPhone?: string;
14
24
  newEmail: string;
25
+ otpTarget?: LinkOrMergeOtpTarget;
15
26
  } | {
27
+ stage: LinkOrMergeStage;
16
28
  conflictField: 'phone';
17
29
  name: string;
18
- oldEmail?: string;
30
+ existingEmail?: string;
31
+ existingCountryCode?: string;
32
+ existingPhone?: string;
19
33
  oldCountryCode?: string;
20
34
  oldPhone?: string;
21
35
  newCountryCode: string;
22
36
  newPhone: string;
37
+ otpTarget?: LinkOrMergeOtpTarget;
23
38
  };
39
+ export type LinkOrMergeSetupPayload = (Omit<Extract<LinkOrMergeState, {
40
+ conflictField: 'email';
41
+ }>, 'stage'> & {
42
+ stage?: LinkOrMergeStage;
43
+ }) | (Omit<Extract<LinkOrMergeState, {
44
+ conflictField: 'phone';
45
+ }>, 'stage'> & {
46
+ stage?: LinkOrMergeStage;
47
+ });
24
48
  /** Full state for the auth flow. */
25
49
  export interface AuthFlowState {
26
50
  step: AuthStep;
@@ -85,7 +109,10 @@ export type AuthFlowAction = {
85
109
  maskedRecipient?: string;
86
110
  } | ({
87
111
  type: 'SET_STEP_LINK_OR_MERGE';
88
- } & LinkOrMergeState) | {
112
+ } & LinkOrMergeSetupPayload) | {
113
+ type: 'SET_LINK_OR_MERGE_OTP_STAGE';
114
+ otpTarget: LinkOrMergeOtpTarget;
115
+ } | {
89
116
  type: 'SET_STEP_PROVIDER_PENDING';
90
117
  } | {
91
118
  type: 'SET_STEP_AUTHENTICATED';
@@ -147,7 +174,8 @@ export interface AuthFlowActions {
147
174
  provider: 'google' | 'apple';
148
175
  credential: string;
149
176
  }) => void;
150
- verifyLinkOrMerge: () => Promise<void>;
177
+ continueLinkOrMerge: () => Promise<void>;
178
+ verifyLinkOrMerge: (otp: string) => Promise<void>;
151
179
  goBack: () => void;
152
180
  reset: () => void;
153
181
  signOut: () => void;
@@ -88,7 +88,9 @@ export interface SignupPageFullProps extends SignupPageProps {
88
88
  export interface LinkOrMergePageProps {
89
89
  details: LinkOrMergeState;
90
90
  onBack?: (() => void) | undefined;
91
- onVerify: () => Promise<void>;
91
+ onContinue: () => Promise<void>;
92
+ onVerify: (otp: string) => Promise<void>;
93
+ onResendCode?: (() => void) | undefined;
92
94
  }
93
95
  /** Props for OtpVerification (inner form without layout). */
94
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.22",
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",