@@ -8,6 +8,7 @@ import type {
88 AuthenticateWithPopupParams ,
99 AuthenticateWithRedirectParams ,
1010 AuthenticateWithWeb3Params ,
11+ CaptchaWidgetType ,
1112 CreateEmailLinkFlowReturn ,
1213 PrepareEmailAddressVerificationParams ,
1314 PreparePhoneNumberVerificationParams ,
@@ -487,11 +488,35 @@ class SignUpFuture implements SignUpFutureResource {
487488 return this . resource . unverifiedFields ;
488489 }
489490
491+ private async getCaptchaToken ( ) : Promise < {
492+ captchaToken ?: string ;
493+ captchaWidgetType ?: CaptchaWidgetType ;
494+ captchaError ?: unknown ;
495+ } > {
496+ const captchaChallenge = new CaptchaChallenge ( SignUp . clerk ) ;
497+ const response = await captchaChallenge . managedOrInvisible ( { action : 'signup' } ) ;
498+ if ( ! response ) {
499+ throw new Error ( 'Captcha challenge failed' ) ;
500+ }
501+
502+ const { captchaError, captchaToken, captchaWidgetType } = response ;
503+ return { captchaToken, captchaWidgetType, captchaError } ;
504+ }
505+
490506 async password ( { emailAddress, password } : { emailAddress : string ; password : string } ) : Promise < { error : unknown } > {
491507 return runAsyncResourceTask ( this . resource , async ( ) => {
508+ const { captchaToken, captchaWidgetType, captchaError } = await this . getCaptchaToken ( ) ;
509+
492510 await this . resource . __internal_basePost ( {
493511 path : this . resource . pathRoot ,
494- body : { emailAddress, password } ,
512+ body : {
513+ strategy : 'password' ,
514+ emailAddress,
515+ password,
516+ captchaToken,
517+ captchaWidgetType,
518+ captchaError,
519+ } ,
495520 } ) ;
496521 } ) ;
497522 }
0 commit comments