@@ -13,6 +13,7 @@ import type {
1313 PreparePhoneNumberVerificationParams ,
1414 PrepareVerificationParams ,
1515 PrepareWeb3WalletVerificationParams ,
16+ SetActiveNavigate ,
1617 SignUpAuthenticateWithWeb3Params ,
1718 SignUpCreateParams ,
1819 SignUpField ,
@@ -40,6 +41,7 @@ import { _authenticateWithPopup } from '../../utils/authenticateWithPopup';
4041import { CaptchaChallenge } from '../../utils/captcha/CaptchaChallenge' ;
4142import { createValidatePassword } from '../../utils/passwords/password' ;
4243import { normalizeUnsafeMetadata } from '../../utils/resourceParams' ;
44+ import { runAsyncResourceTask } from '../../utils/runAsyncResourceTask' ;
4345import {
4446 clerkInvalidFAPIResponse ,
4547 clerkMissingOptionError ,
@@ -470,9 +472,55 @@ export class SignUp extends BaseResource implements SignUpResource {
470472}
471473
472474class SignUpFuture implements SignUpFutureResource {
475+ verifications = {
476+ sendEmailCode : this . sendEmailCode . bind ( this ) ,
477+ verifyEmailCode : this . verifyEmailCode . bind ( this ) ,
478+ } ;
479+
473480 constructor ( readonly resource : SignUp ) { }
474481
475482 get status ( ) {
476483 return this . resource . status ;
477484 }
485+
486+ get unverifiedFields ( ) {
487+ return this . resource . unverifiedFields ;
488+ }
489+
490+ async password ( { emailAddress, password } : { emailAddress : string ; password : string } ) : Promise < { error : unknown } > {
491+ return runAsyncResourceTask ( this . resource , async ( ) => {
492+ await this . resource . __internal_basePost ( {
493+ path : this . resource . pathRoot ,
494+ body : { emailAddress, password } ,
495+ } ) ;
496+ } ) ;
497+ }
498+
499+ async sendEmailCode ( ) : Promise < { error : unknown } > {
500+ return runAsyncResourceTask ( this . resource , async ( ) => {
501+ await this . resource . __internal_basePost ( {
502+ body : { strategy : 'email_code' } ,
503+ action : 'prepare_verification' ,
504+ } ) ;
505+ } ) ;
506+ }
507+
508+ async verifyEmailCode ( { code } : { code : string } ) : Promise < { error : unknown } > {
509+ return runAsyncResourceTask ( this . resource , async ( ) => {
510+ await this . resource . __internal_basePost ( {
511+ body : { strategy : 'email_code' , code } ,
512+ action : 'attempt_verification' ,
513+ } ) ;
514+ } ) ;
515+ }
516+
517+ async finalize ( { navigate } : { navigate ?: SetActiveNavigate } ) : Promise < { error : unknown } > {
518+ return runAsyncResourceTask ( this . resource , async ( ) => {
519+ if ( ! this . resource . createdSessionId ) {
520+ throw new Error ( 'Cannot finalize sign-up without a created session.' ) ;
521+ }
522+
523+ await SignUp . clerk . setActive ( { session : this . resource . createdSessionId , navigate } ) ;
524+ } ) ;
525+ }
478526}
0 commit comments