@@ -493,12 +493,18 @@ class SignInFuture implements SignInFutureResource {
493493 submitPassword : this . submitResetPassword . bind ( this ) ,
494494 } ;
495495
496+ fetchStatus : 'idle' | 'fetching' = 'idle' ;
497+
496498 constructor ( readonly resource : SignIn ) { }
497499
498500 get status ( ) {
499501 return this . resource . status ;
500502 }
501503
504+ get availableStrategies ( ) {
505+ return this . resource . supportedFirstFactors ?? [ ] ;
506+ }
507+
502508 async sendResetPasswordEmailCode ( ) : Promise < { error : unknown } > {
503509 eventBus . emit ( 'resource:error' , { resource : this . resource , error : null } ) ;
504510 try {
@@ -583,12 +589,13 @@ class SignInFuture implements SignInFutureResource {
583589 }
584590 }
585591
586- async password ( { identifier, password } : { identifier : string ; password : string } ) : Promise < { error : unknown } > {
592+ async password ( { identifier, password } : { identifier ? : string ; password : string } ) : Promise < { error : unknown } > {
587593 eventBus . emit ( 'resource:error' , { resource : this . resource , error : null } ) ;
594+ const previousIdentifier = this . resource . identifier ;
588595 try {
589596 await this . resource . __internal_basePost ( {
590597 path : this . resource . pathRoot ,
591- body : { identifier, password } ,
598+ body : { identifier : identifier || previousIdentifier , password } ,
592599 } ) ;
593600 } catch ( err : unknown ) {
594601 eventBus . emit ( 'resource:error' , { resource : this . resource , error : err } ) ;
@@ -678,4 +685,20 @@ class SignInFuture implements SignInFutureResource {
678685
679686 return { error : null } ;
680687 }
688+
689+ async finalize ( ) : Promise < { error : unknown } > {
690+ eventBus . emit ( 'resource:error' , { resource : this . resource , error : null } ) ;
691+ try {
692+ if ( ! this . resource . createdSessionId ) {
693+ throw new Error ( 'Cannot finalize sign-in without a created session.' ) ;
694+ }
695+
696+ await SignIn . clerk . setActive ( { session : this . resource . createdSessionId } ) ;
697+ } catch ( err : unknown ) {
698+ eventBus . emit ( 'resource:error' , { resource : this . resource , error : err } ) ;
699+ return { error : err } ;
700+ }
701+
702+ return { error : null } ;
703+ }
681704}
0 commit comments