@@ -703,23 +703,27 @@ class SignInFuture implements SignInFutureResource {
703703 } ) ;
704704 }
705705
706+ private async _create ( params : SignInFutureCreateParams ) : Promise < void > {
707+ await this . resource . __internal_basePost ( {
708+ path : this . resource . pathRoot ,
709+ body : params ,
710+ } ) ;
711+ }
712+
706713 async create ( params : SignInFutureCreateParams ) : Promise < { error : unknown } > {
707714 return runAsyncResourceTask ( this . resource , async ( ) => {
708- await this . resource . __internal_basePost ( {
709- path : this . resource . pathRoot ,
710- body : params ,
711- } ) ;
715+ await this . _create ( params ) ;
712716 } ) ;
713717 }
714718
715719 async password ( params : SignInFuturePasswordParams ) : Promise < { error : unknown } > {
716- if ( [ params . identifier , params . email , params . phoneNumber ] . filter ( Boolean ) . length > 1 ) {
717- throw new Error ( 'Only one of identifier, email , or phoneNumber can be provided' ) ;
720+ if ( [ params . identifier , params . emailAddress , params . phoneNumber ] . filter ( Boolean ) . length > 1 ) {
721+ throw new Error ( 'Only one of identifier, emailAddress , or phoneNumber can be provided' ) ;
718722 }
719723
720724 return runAsyncResourceTask ( this . resource , async ( ) => {
721725 // TODO @userland -errors:
722- const identifier = params . identifier || params . email || params . phoneNumber ;
726+ const identifier = params . identifier || params . emailAddress || params . phoneNumber ;
723727 const previousIdentifier = this . resource . identifier ;
724728 await this . resource . __internal_basePost ( {
725729 path : this . resource . pathRoot ,
@@ -744,7 +748,7 @@ class SignInFuture implements SignInFutureResource {
744748
745749 return runAsyncResourceTask ( this . resource , async ( ) => {
746750 if ( emailAddress ) {
747- await this . create ( { identifier : emailAddress } ) ;
751+ await this . _create ( { identifier : emailAddress } ) ;
748752 }
749753
750754 const emailCodeFactor = this . selectFirstFactor ( { strategy : 'email_code' , emailAddressId } ) ;
@@ -785,7 +789,7 @@ class SignInFuture implements SignInFutureResource {
785789
786790 return runAsyncResourceTask ( this . resource , async ( ) => {
787791 if ( emailAddress ) {
788- await this . create ( { identifier : emailAddress } ) ;
792+ await this . _create ( { identifier : emailAddress } ) ;
789793 }
790794
791795 const emailLinkFactor = this . selectFirstFactor ( { strategy : 'email_link' , emailAddressId } ) ;
@@ -848,7 +852,7 @@ class SignInFuture implements SignInFutureResource {
848852
849853 return runAsyncResourceTask ( this . resource , async ( ) => {
850854 if ( phoneNumber ) {
851- await this . create ( { identifier : phoneNumber } ) ;
855+ await this . _create ( { identifier : phoneNumber } ) ;
852856 }
853857
854858 const phoneCodeFactor = this . selectFirstFactor ( { strategy : 'phone_code' , phoneNumberId } ) ;
@@ -880,14 +884,19 @@ class SignInFuture implements SignInFutureResource {
880884 throw new Error ( 'modal flow is not supported yet' ) ;
881885 }
882886
883- if ( ! this . resource . id ) {
884- await this . create ( {
885- strategy,
886- redirectUrl : SignIn . clerk . buildUrlWithAuth ( redirectCallbackUrl ) ,
887- actionCompleteRedirectUrl : redirectUrl ,
888- } ) ;
887+ let actionCompleteRedirectUrl = redirectUrl ;
888+ try {
889+ new URL ( redirectUrl ) ;
890+ } catch {
891+ actionCompleteRedirectUrl = window . location . origin + redirectUrl ;
889892 }
890893
894+ await this . _create ( {
895+ strategy,
896+ redirectUrl : SignIn . clerk . buildUrlWithAuth ( redirectCallbackUrl ) ,
897+ actionCompleteRedirectUrl,
898+ } ) ;
899+
891900 const { status, externalVerificationRedirectURL } = this . resource . firstFactorVerification ;
892901
893902 if ( status === 'unverified' && externalVerificationRedirectURL ) {
@@ -924,7 +933,7 @@ class SignInFuture implements SignInFutureResource {
924933 throw new Error ( `Unsupported Web3 provider: ${ provider } ` ) ;
925934 }
926935
927- await this . create ( { identifier } ) ;
936+ await this . _create ( { identifier } ) ;
928937
929938 const web3FirstFactor = this . resource . supportedFirstFactors ?. find (
930939 f => f . strategy === strategy ,
0 commit comments