Skip to content

Commit 641f512

Browse files
committed
chore: Add react jsdocs
1 parent 5c6625a commit 641f512

36 files changed

+689
-1
lines changed

packages/react/src/auth/forms/email-link-auth-form.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ import { form } from "~/components/form";
2828
import { Policies } from "~/components/policies";
2929
import { useCallback, useEffect, useState } from "react";
3030

31+
/** Props for the EmailLinkAuthForm component. */
3132
export type EmailLinkAuthFormProps = {
33+
/** Callback function called when the sign-in link email is sent. */
3234
onEmailSent?: () => void;
35+
/** Callback function called when sign-in is completed via the email link. */
3336
onSignIn?: (credential: UserCredential) => void;
3437
};
3538

39+
/**
40+
* Creates a memoized action function for sending a sign-in link to an email address.
41+
*
42+
* @returns A callback function that sends a sign-in link to the specified email address.
43+
*/
3644
export function useEmailLinkAuthFormAction() {
3745
const ui = useUI();
3846

@@ -53,6 +61,12 @@ export function useEmailLinkAuthFormAction() {
5361
);
5462
}
5563

64+
/**
65+
* Creates a form hook for email link authentication.
66+
*
67+
* @param onSuccess - Optional callback function called when the sign-in link email is sent.
68+
* @returns A form instance configured for email link authentication.
69+
*/
5670
export function useEmailLinkAuthForm(onSuccess?: EmailLinkAuthFormProps["onEmailSent"]) {
5771
const schema = useEmailLinkAuthFormSchema();
5872
const action = useEmailLinkAuthFormAction();
@@ -75,6 +89,13 @@ export function useEmailLinkAuthForm(onSuccess?: EmailLinkAuthFormProps["onEmail
7589
});
7690
}
7791

92+
/**
93+
* Hook that automatically completes the email link sign-in process when the component mounts.
94+
*
95+
* Checks if the current URL contains a valid email link sign-in link and completes the authentication.
96+
*
97+
* @param onSignIn - Optional callback function called when sign-in is completed.
98+
*/
7899
export function useEmailLinkAuthFormCompleteSignIn(onSignIn?: EmailLinkAuthFormProps["onSignIn"]) {
79100
const ui = useUI();
80101

@@ -91,6 +112,14 @@ export function useEmailLinkAuthFormCompleteSignIn(onSignIn?: EmailLinkAuthFormP
91112
}, [onSignIn]);
92113
}
93114

115+
/**
116+
* A form component for email link authentication.
117+
*
118+
* Sends a sign-in link to the user's email address and automatically completes sign-in
119+
* if the user arrives via an email link.
120+
*
121+
* @returns The email link auth form component.
122+
*/
94123
export function EmailLinkAuthForm({ onEmailSent, onSignIn }: EmailLinkAuthFormProps) {
95124
const ui = useUI();
96125
const [emailSent, setEmailSent] = useState(false);

packages/react/src/auth/forms/forgot-password-auth-form.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ import { form } from "~/components/form";
2222
import { Policies } from "~/components/policies";
2323
import { useCallback, useState } from "react";
2424

25+
/** Props for the ForgotPasswordAuthForm component. */
2526
export type ForgotPasswordAuthFormProps = {
27+
/** Callback function called when the password reset email is sent. */
2628
onPasswordSent?: () => void;
29+
/** Callback function called when the back to sign in link is clicked. */
2730
onBackToSignInClick?: () => void;
2831
};
2932

33+
/**
34+
* Creates a memoized action function for sending a password reset email.
35+
*
36+
* @returns A callback function that sends a password reset email to the specified address.
37+
*/
3038
export function useForgotPasswordAuthFormAction() {
3139
const ui = useUI();
3240

@@ -47,6 +55,12 @@ export function useForgotPasswordAuthFormAction() {
4755
);
4856
}
4957

58+
/**
59+
* Creates a form hook for forgot password authentication.
60+
*
61+
* @param onSuccess - Optional callback function called when the password reset email is sent.
62+
* @returns A form instance configured for forgot password.
63+
*/
5064
export function useForgotPasswordAuthForm(onSuccess?: ForgotPasswordAuthFormProps["onPasswordSent"]) {
5165
const schema = useForgotPasswordAuthFormSchema();
5266
const action = useForgotPasswordAuthFormAction();
@@ -69,6 +83,13 @@ export function useForgotPasswordAuthForm(onSuccess?: ForgotPasswordAuthFormProp
6983
});
7084
}
7185

86+
/**
87+
* A form component for requesting a password reset email.
88+
*
89+
* Displays a success message after the email is sent.
90+
*
91+
* @returns The forgot password form component.
92+
*/
7293
export function ForgotPasswordAuthForm({ onBackToSignInClick, onPasswordSent }: ForgotPasswordAuthFormProps) {
7394
const ui = useUI();
7495
const [emailSent, setEmailSent] = useState(false);

packages/react/src/auth/forms/mfa/sms-multi-factor-assertion-form.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ type PhoneMultiFactorInfo = MultiFactorInfo & {
3636
phoneNumber?: string;
3737
};
3838

39+
/**
40+
* Creates a memoized action function for verifying a phone number during SMS multi-factor assertion.
41+
*
42+
* @returns A callback function that verifies a phone number using the provided hint and reCAPTCHA verifier.
43+
*/
3944
export function useSmsMultiFactorAssertionPhoneFormAction() {
4045
const ui = useUI();
4146

@@ -47,12 +52,22 @@ export function useSmsMultiFactorAssertionPhoneFormAction() {
4752
);
4853
}
4954

55+
/** Options for the SMS multi-factor assertion phone form hook. */
5056
type UseSmsMultiFactorAssertionPhoneForm = {
57+
/** The multi-factor info hint containing phone number information. */
5158
hint: MultiFactorInfo;
59+
/** The reCAPTCHA verifier instance. */
5260
recaptchaVerifier: RecaptchaVerifier;
61+
/** Callback function called when phone verification is successful. */
5362
onSuccess: (verificationId: string) => void;
5463
};
5564

65+
/**
66+
* Creates a form hook for SMS multi-factor assertion phone number verification.
67+
*
68+
* @param options - The phone form options.
69+
* @returns A form instance configured for phone number verification.
70+
*/
5671
export function useSmsMultiFactorAssertionPhoneForm({
5772
hint,
5873
recaptchaVerifier,
@@ -120,6 +135,11 @@ function SmsMultiFactorAssertionPhoneForm(props: SmsMultiFactorAssertionPhoneFor
120135
);
121136
}
122137

138+
/**
139+
* Creates a memoized action function for verifying the SMS verification code during multi-factor assertion.
140+
*
141+
* @returns A callback function that verifies the code and signs in with the multi-factor assertion.
142+
*/
123143
export function useSmsMultiFactorAssertionVerifyFormAction() {
124144
const ui = useUI();
125145

@@ -133,11 +153,20 @@ export function useSmsMultiFactorAssertionVerifyFormAction() {
133153
);
134154
}
135155

156+
/** Options for the SMS multi-factor assertion verify form hook. */
136157
type UseSmsMultiFactorAssertionVerifyForm = {
158+
/** The verification ID from the phone verification step. */
137159
verificationId: string;
160+
/** Callback function called when verification is successful. */
138161
onSuccess: (credential: UserCredential) => void;
139162
};
140163

164+
/**
165+
* Creates a form hook for SMS multi-factor assertion verification code input.
166+
*
167+
* @param options - The verify form options.
168+
* @returns A form instance configured for verification code input.
169+
*/
141170
export function useSmsMultiFactorAssertionVerifyForm({
142171
verificationId,
143172
onSuccess,
@@ -206,11 +235,21 @@ function SmsMultiFactorAssertionVerifyForm(props: SmsMultiFactorAssertionVerifyF
206235
);
207236
}
208237

238+
/** Props for the SmsMultiFactorAssertionForm component. */
209239
export type SmsMultiFactorAssertionFormProps = {
240+
/** The multi-factor info hint containing phone number information. */
210241
hint: MultiFactorInfo;
242+
/** Optional callback function called when multi-factor assertion is successful. */
211243
onSuccess?: (credential: UserCredential) => void;
212244
};
213245

246+
/**
247+
* A form component for SMS multi-factor authentication assertion.
248+
*
249+
* Handles the two-step process: first verifying the phone number, then verifying the SMS code.
250+
*
251+
* @returns The SMS multi-factor assertion form component.
252+
*/
214253
export function SmsMultiFactorAssertionForm(props: SmsMultiFactorAssertionFormProps) {
215254
const [verification, setVerification] = useState<{
216255
verificationId: string;

packages/react/src/auth/forms/mfa/sms-multi-factor-enrollment-form.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ import {
3232
useUI,
3333
} from "~/hooks";
3434

35+
/**
36+
* Creates a memoized action function for verifying a phone number during SMS multi-factor enrollment.
37+
*
38+
* @returns A callback function that verifies a phone number for MFA enrollment using the provided reCAPTCHA verifier.
39+
*/
3540
export function useSmsMultiFactorEnrollmentPhoneAuthFormAction() {
3641
const ui = useUI();
3742

@@ -44,12 +49,22 @@ export function useSmsMultiFactorEnrollmentPhoneAuthFormAction() {
4449
);
4550
}
4651

52+
/** Options for the SMS multi-factor enrollment phone number form hook. */
4753
export type UseSmsMultiFactorEnrollmentPhoneNumberForm = {
54+
/** The reCAPTCHA verifier instance. */
4855
recaptchaVerifier: RecaptchaVerifier;
56+
/** Callback function called when phone verification is successful. */
4957
onSuccess: (verificationId: string, displayName?: string) => void;
58+
/** Optional function to format the phone number before verification. */
5059
formatPhoneNumber?: (phoneNumber: string) => string;
5160
};
5261

62+
/**
63+
* Creates a form hook for SMS multi-factor enrollment phone number verification.
64+
*
65+
* @param options - The phone number form options.
66+
* @returns A form instance configured for phone number input and verification for MFA enrollment.
67+
*/
5368
export function useSmsMultiFactorEnrollmentPhoneNumberForm({
5469
recaptchaVerifier,
5570
onSuccess,
@@ -131,6 +146,11 @@ function MultiFactorEnrollmentPhoneNumberForm(props: MultiFactorEnrollmentPhoneN
131146
);
132147
}
133148

149+
/**
150+
* Creates a memoized action function for verifying the SMS verification code during multi-factor enrollment.
151+
*
152+
* @returns A callback function that verifies the code and enrolls the phone number as a multi-factor authentication method.
153+
*/
134154
export function useMultiFactorEnrollmentVerifyPhoneNumberFormAction() {
135155
const ui = useUI();
136156
return useCallback(
@@ -151,12 +171,22 @@ export function useMultiFactorEnrollmentVerifyPhoneNumberFormAction() {
151171
);
152172
}
153173

174+
/** Options for the multi-factor enrollment verify phone number form hook. */
154175
type UseMultiFactorEnrollmentVerifyPhoneNumberForm = {
176+
/** The verification ID from the phone verification step. */
155177
verificationId: string;
178+
/** Optional display name for the enrolled MFA method. */
156179
displayName?: string;
180+
/** Callback function called when enrollment is successful. */
157181
onSuccess: () => void;
158182
};
159183

184+
/**
185+
* Creates a form hook for SMS multi-factor enrollment verification code input.
186+
*
187+
* @param options - The verify phone number form options.
188+
* @returns A form instance configured for verification code input during MFA enrollment.
189+
*/
160190
export function useMultiFactorEnrollmentVerifyPhoneNumberForm({
161191
verificationId,
162192
displayName,
@@ -184,12 +214,21 @@ export function useMultiFactorEnrollmentVerifyPhoneNumberForm({
184214
});
185215
}
186216

217+
/** Props for the MultiFactorEnrollmentVerifyPhoneNumberForm component. */
187218
type MultiFactorEnrollmentVerifyPhoneNumberFormProps = {
219+
/** The verification ID from the phone verification step. */
188220
verificationId: string;
221+
/** Optional display name for the enrolled MFA method. */
189222
displayName?: string;
223+
/** Callback function called when enrollment is successful. */
190224
onSuccess: () => void;
191225
};
192226

227+
/**
228+
* A form component for verifying the SMS code during multi-factor enrollment.
229+
*
230+
* @returns The verify phone number form component.
231+
*/
193232
export function MultiFactorEnrollmentVerifyPhoneNumberForm(props: MultiFactorEnrollmentVerifyPhoneNumberFormProps) {
194233
const ui = useUI();
195234
const form = useMultiFactorEnrollmentVerifyPhoneNumberForm({
@@ -227,10 +266,20 @@ export function MultiFactorEnrollmentVerifyPhoneNumberForm(props: MultiFactorEnr
227266
);
228267
}
229268

269+
/** Props for the SmsMultiFactorEnrollmentForm component. */
230270
export type SmsMultiFactorEnrollmentFormProps = {
271+
/** Optional callback function called when enrollment is successful. */
231272
onSuccess?: () => void;
232273
};
233274

275+
/**
276+
* A form component for SMS multi-factor authentication enrollment.
277+
*
278+
* Handles the two-step process: first entering the phone number and display name, then verifying the SMS code.
279+
*
280+
* @returns The SMS multi-factor enrollment form component.
281+
* @throws {Error} Throws an error if the user is not authenticated.
282+
*/
234283
export function SmsMultiFactorEnrollmentForm(props: SmsMultiFactorEnrollmentFormProps) {
235284
const ui = useUI();
236285

packages/react/src/auth/forms/mfa/totp-multi-factor-assertion-form.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import { signInWithMultiFactorAssertion, FirebaseUIError, getTranslation } from
2020
import { form } from "~/components/form";
2121
import { useMultiFactorTotpAuthVerifyFormSchema, useUI } from "~/hooks";
2222

23+
/**
24+
* Creates a memoized action function for verifying a TOTP code during multi-factor assertion.
25+
*
26+
* @returns A callback function that verifies the TOTP code and signs in with the multi-factor assertion.
27+
*/
2328
export function useTotpMultiFactorAssertionFormAction() {
2429
const ui = useUI();
2530

@@ -32,11 +37,20 @@ export function useTotpMultiFactorAssertionFormAction() {
3237
);
3338
}
3439

40+
/** Options for the TOTP multi-factor assertion form hook. */
3541
export type UseTotpMultiFactorAssertionForm = {
42+
/** The multi-factor info hint containing TOTP information. */
3643
hint: MultiFactorInfo;
44+
/** Callback function called when verification is successful. */
3745
onSuccess: (credential: UserCredential) => void;
3846
};
3947

48+
/**
49+
* Creates a form hook for TOTP multi-factor assertion verification code input.
50+
*
51+
* @param options - The TOTP assertion form options.
52+
* @returns A form instance configured for TOTP verification code input.
53+
*/
4054
export function useTotpMultiFactorAssertionForm({ hint, onSuccess }: UseTotpMultiFactorAssertionForm) {
4155
const action = useTotpMultiFactorAssertionFormAction();
4256
const schema = useMultiFactorTotpAuthVerifyFormSchema();
@@ -59,11 +73,21 @@ export function useTotpMultiFactorAssertionForm({ hint, onSuccess }: UseTotpMult
5973
});
6074
}
6175

76+
/** Props for the TotpMultiFactorAssertionForm component. */
6277
export type TotpMultiFactorAssertionFormProps = {
78+
/** The multi-factor info hint containing TOTP information. */
6379
hint: MultiFactorInfo;
80+
/** Optional callback function called when multi-factor assertion is successful. */
6481
onSuccess?: (credential: UserCredential) => void;
6582
};
6683

84+
/**
85+
* A form component for TOTP multi-factor authentication assertion.
86+
*
87+
* Allows users to enter a 6-digit TOTP code from their authenticator app.
88+
*
89+
* @returns The TOTP multi-factor assertion form component.
90+
*/
6791
export function TotpMultiFactorAssertionForm(props: TotpMultiFactorAssertionFormProps) {
6892
const ui = useUI();
6993
const form = useTotpMultiFactorAssertionForm({

0 commit comments

Comments
 (0)