Skip to content

Commit f516a7e

Browse files
authored
docs(types): Add JSDoc comments (#6994)
1 parent c619d0d commit f516a7e

File tree

3 files changed

+393
-39
lines changed

3 files changed

+393
-39
lines changed

.changeset/khaki-beers-argue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/types/src/signInFuture.ts

Lines changed: 143 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,84 +5,164 @@ import type { OAuthStrategy, Web3Strategy } from './strategies';
55
import type { VerificationResource } from './verification';
66

77
export interface SignInFutureCreateParams {
8+
/**
9+
* The authentication identifier for the sign-in. This can be the value of the user's email address, phone number,
10+
* username, or Web3 wallet address.
11+
*/
812
identifier?: string;
13+
/**
14+
* The first factor verification strategy to use in the sign-in flow. Depends on the `identifier` value. Each
15+
* authentication identifier supports different verification strategies.
16+
*/
917
strategy?: OAuthStrategy | 'saml' | 'enterprise_sso';
18+
/**
19+
* The full URL or path that the OAuth provider should redirect to after successful authorization on their part.
20+
*/
1021
redirectUrl?: string;
22+
/**
23+
* The URL that the user will be redirected to, after successful authorization from the OAuth provider and
24+
* Clerk sign-in.
25+
*/
1126
actionCompleteRedirectUrl?: string;
27+
/**
28+
* When set to `true`, the `SignIn` will attempt to retrieve information from the active `SignUp` instance and use it
29+
* to complete the sign-in process. This is useful when you want to seamlessly transition a user from a sign-up
30+
* attempt to a sign-in attempt.
31+
*/
1232
transfer?: boolean;
33+
/**
34+
* The [ticket _or token_](https://clerk.com/docs/guides/development/custom-flows/authentication/application-invitations)
35+
* generated from the Backend API. **Required** if `strategy` is set to `'ticket'`.
36+
*/
1337
ticket?: string;
1438
}
1539

16-
export type SignInFuturePasswordParams =
40+
export type SignInFuturePasswordParams = {
41+
/**
42+
* The user's password. Only supported if
43+
* [password](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#password) is enabled.
44+
*/
45+
password: string;
46+
} & (
1747
| {
18-
password: string;
48+
/**
49+
* The authentication identifier for the sign-in. This can be the value of the user's email address, phone number,
50+
* username, or Web3 wallet address.
51+
*/
1952
identifier: string;
2053
emailAddress?: never;
2154
phoneNumber?: never;
2255
}
2356
| {
24-
password: string;
57+
/**
58+
* The user's email address. Only supported if [Email address](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#email)
59+
* is enabled.
60+
*/
2561
emailAddress: string;
2662
identifier?: never;
2763
phoneNumber?: never;
2864
}
2965
| {
30-
password: string;
66+
/**
67+
* The user's phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164). Only supported if
68+
* [phone number](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#phone) is enabled.
69+
*/
3170
phoneNumber: string;
3271
identifier?: never;
3372
emailAddress?: never;
3473
}
3574
| {
36-
password: string;
3775
phoneNumber?: never;
3876
identifier?: never;
3977
emailAddress?: never;
40-
};
78+
}
79+
);
4180

4281
export type SignInFutureEmailCodeSendParams =
4382
| {
83+
/**
84+
* The user's email address. Only supported if [Email address](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#email)
85+
* is enabled.
86+
*/
4487
emailAddress?: string;
4588
emailAddressId?: never;
4689
}
4790
| {
91+
/**
92+
* The ID for the user's email address that will receive an email with the one-time authentication code.
93+
*/
4894
emailAddressId?: string;
4995
emailAddress?: never;
5096
};
5197

52-
export type SignInFutureEmailLinkSendParams =
98+
export type SignInFutureEmailLinkSendParams = {
99+
/**
100+
* The full URL that the user will be redirected to when they visit the email link.
101+
*/
102+
verificationUrl: string;
103+
} & (
53104
| {
105+
/**
106+
* The user's email address. Only supported if [Email address](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#email)
107+
* is enabled.
108+
*/
54109
emailAddress?: string;
55-
verificationUrl: string;
56110
emailAddressId?: never;
57111
}
58112
| {
113+
/**
114+
* The ID for the user's email address that will receive an email with the email link.
115+
*/
59116
emailAddressId?: string;
60-
verificationUrl: string;
61117
emailAddress?: never;
62-
};
118+
}
119+
);
63120

64121
export interface SignInFutureEmailCodeVerifyParams {
122+
/**
123+
* The one-time code that was sent to the user.
124+
*/
65125
code: string;
66126
}
67127

68128
export interface SignInFutureResetPasswordSubmitParams {
129+
/**
130+
* The new password for the user.
131+
*/
69132
password: string;
133+
/**
134+
* If `true`, signs the user out of all other authenticated sessions.
135+
*/
70136
signOutOfOtherSessions?: boolean;
71137
}
72138

73-
export type SignInFuturePhoneCodeSendParams =
139+
export type SignInFuturePhoneCodeSendParams = {
140+
/**
141+
* The mechanism to use to send the code to the provided phone number. Defaults to `'sms'`.
142+
*/
143+
channel?: PhoneCodeChannel;
144+
} & (
74145
| {
146+
/**
147+
* The user's phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164). Only supported if
148+
* [phone number](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#phone) is enabled.
149+
*/
75150
phoneNumber?: string;
76-
channel?: PhoneCodeChannel;
77151
phoneNumberId?: never;
78152
}
79153
| {
154+
/**
155+
* The ID for the user's phone number that will receive a message with the one-time authentication code.
156+
*/
80157
phoneNumberId: string;
81-
channel?: PhoneCodeChannel;
82158
phoneNumber?: never;
83-
};
159+
}
160+
);
84161

85162
export interface SignInFuturePhoneCodeVerifyParams {
163+
/**
164+
* The one-time code that was sent to the user.
165+
*/
86166
code: string;
87167
}
88168

@@ -100,22 +180,38 @@ export interface SignInFutureSSOParams {
100180
}
101181

102182
export interface SignInFutureMFAPhoneCodeVerifyParams {
183+
/**
184+
* The one-time code that was sent to the user as part of the `signIn.mfa.sendPhoneCode()` method.
185+
*/
103186
code: string;
104187
}
105188

106189
export interface SignInFutureTOTPVerifyParams {
190+
/**
191+
* The TOTP generated by the user's authenticator app.
192+
*/
107193
code: string;
108194
}
109195

110196
export interface SignInFutureBackupCodeVerifyParams {
197+
/**
198+
* The backup code that was provided to the user when they set up two-step authentication.
199+
*/
111200
code: string;
112201
}
113202

114203
export interface SignInFutureTicketParams {
204+
/**
205+
* The [ticket _or token_](https://clerk.com/docs/guides/development/custom-flows/authentication/application-invitations)
206+
* generated from the Backend API.
207+
*/
115208
ticket: string;
116209
}
117210

118211
export interface SignInFutureWeb3Params {
212+
/**
213+
* The verification strategy to validate the user's sign-in request.
214+
*/
119215
strategy: Web3Strategy;
120216
}
121217

@@ -124,7 +220,9 @@ export interface SignInFutureFinalizeParams {
124220
}
125221

126222
/**
127-
* The current active `SignIn` instance, for use in custom flows.
223+
* The `SignInFuture` class holds the state of the current sign-in and provides helper methods to navigate and complete
224+
* the sign-in process. It is used to manage the sign-in lifecycle, including the first and second factor verification,
225+
* and the creation of a new session.
128226
*/
129227
export interface SignInFutureResource {
130228
/**
@@ -133,18 +231,19 @@ export interface SignInFutureResource {
133231
readonly id?: string;
134232

135233
/**
136-
* The list of first-factor strategies that are available for the current sign-in attempt.
234+
* Array of the first factors that are supported in the current sign-in. Each factor contains information about the
235+
* verification strategy that can be used.
137236
*/
138237
readonly supportedFirstFactors: SignInFirstFactor[];
139238

140239
/**
141-
* The list of second-factor strategies that are available for the current sign-in attempt.
240+
* Array of the second factors that are supported in the current sign-in. Each factor contains information about the
241+
* verification strategy that can be used. This property is populated only when the first factor is verified.
142242
*/
143243
readonly supportedSecondFactors: SignInSecondFactor[];
144244

145245
/**
146-
* The status of the current sign-in attempt as a string (for example, `'needs_identifier'`, `'needs_first_factor'`,
147-
* `'complete'`, etc.)
246+
* The current status of the sign-in.
148247
*/
149248
readonly status: SignInStatus;
150249

@@ -156,31 +255,50 @@ export interface SignInFutureResource {
156255

157256
readonly existingSession?: { sessionId: string };
158257

258+
/**
259+
* The state of the verification process for the selected first factor. Initially, this property contains an empty
260+
* verification object, since there is no first factor selected.
261+
*/
159262
readonly firstFactorVerification: VerificationResource;
160263

161264
/**
162-
* The second-factor verification for the current sign-in attempt.
265+
* The state of the verification process for the selected second factor. Initially, this property contains an empty
266+
* verification object, since there is no second factor selected.
163267
*/
164268
readonly secondFactorVerification: VerificationResource;
165269

166270
/**
167-
* The identifier for the current sign-in attempt.
271+
* The authentication identifier value for the current sign-in. `null` if the `strategy` is `'oauth_<provider>'`
272+
* or `'enterprise_sso'`.
168273
*/
169274
readonly identifier: string | null;
170275

171276
/**
172-
* The created session ID for the current sign-in attempt.
277+
* The identifier of the session that was created upon completion of the current sign-in. The value of this property
278+
* is `null` if the sign-in status is not `'complete'`.
173279
*/
174280
readonly createdSessionId: string | null;
175281

176282
/**
177-
* The user data for the current sign-in attempt.
283+
* An object containing information about the user of the current sign-in. This property is populated only once an
284+
* identifier is given to the `SignIn` object through `signIn.create()` or another method that populates the
285+
* `identifier` property.
178286
*/
179287
readonly userData: UserData;
180288

181289
/**
182-
* Used to supply an identifier for the sign-in attempt. Calling this method will populate data on the sign-in
183-
* attempt, such as `signIn.resource.supportedFirstFactors`.
290+
* Creates a new `SignIn` instance initialized with the provided parameters. The instance maintains the sign-in
291+
* lifecycle state through its `status` property, which updates as the authentication flow progresses.
292+
*
293+
* What you must pass to `params` depends on which [sign-in options](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options)
294+
* you have enabled in your app's settings in the Clerk Dashboard.
295+
*
296+
* You can complete the sign-in process in one step if you supply the required fields to `create()`. Otherwise,
297+
* Clerk's sign-in process provides great flexibility and allows users to easily create multi-step sign-in flows.
298+
*
299+
* > [!WARNING]
300+
* > Once the sign-in process is complete, call the `signIn.finalize()` method to set the newly created session as
301+
* > the active session.
184302
*/
185303
create: (params: SignInFutureCreateParams) => Promise<{ error: unknown }>;
186304

0 commit comments

Comments
 (0)