@@ -64,7 +64,7 @@ export interface CreateAuthRouteHandlers {
64
64
provider : BuiltinOAuthProviderNames ;
65
65
isSignUp : boolean ;
66
66
} > ,
67
- ) : Promise < never > ;
67
+ ) : Promise < never | Response > ;
68
68
onEmailPasswordSignIn (
69
69
params : ParamsOrError < { tokenData : TokenData } > ,
70
70
) : Promise < Response > ;
@@ -79,19 +79,19 @@ export interface CreateAuthRouteHandlers {
79
79
{ tokenData : TokenData } ,
80
80
{ verificationToken ?: string }
81
81
> ,
82
- ) : Promise < never > ;
82
+ ) : Promise < never | Response > ;
83
83
onWebAuthnSignUp (
84
84
params : ParamsOrError < { tokenData : TokenData | null } > ,
85
85
) : Promise < Response > ;
86
86
onWebAuthnSignIn (
87
87
params : ParamsOrError < { tokenData : TokenData } > ,
88
- ) : Promise < never > ;
88
+ ) : Promise < never | Response > ;
89
89
onMagicLinkCallback (
90
90
params : ParamsOrError < { tokenData : TokenData ; isSignUp : boolean } > ,
91
- ) : Promise < never > ;
91
+ ) : Promise < never | Response > ;
92
92
onMagicLinkSignIn (
93
93
params : ParamsOrError < { tokenData : TokenData } > ,
94
- ) : Promise < never > ;
94
+ ) : Promise < never | Response > ;
95
95
onBuiltinUICallback (
96
96
params : ParamsOrError <
97
97
(
@@ -105,8 +105,8 @@ export interface CreateAuthRouteHandlers {
105
105
}
106
106
) & { isSignUp : boolean }
107
107
> ,
108
- ) : Promise < never > ;
109
- onSignout ( evt : APIEvent ) : Promise < never > ;
108
+ ) : Promise < never | Response > ;
109
+ onSignout ( evt : APIEvent ) : Promise < never | Response > ;
110
110
}
111
111
112
112
export class SolidServerAuth extends SolidAuthHelpers {
@@ -142,7 +142,6 @@ export class SolidServerAuth extends SolidAuthHelpers {
142
142
143
143
setAuthCookie ( token : string ) {
144
144
const expirationDate = Auth . getTokenExpiration ( token ) ;
145
-
146
145
setCookie ( this . options . authCookieName , token , {
147
146
httpOnly : true ,
148
147
path : "/" ,
@@ -473,8 +472,7 @@ export class SolidServerAuth extends SolidAuthHelpers {
473
472
switch ( evt . params . auth ) {
474
473
case "emailpassword/signin" : {
475
474
const data = await _getReqBody ( req ) ;
476
- const isAction = _isAction ( data ) ;
477
- if ( ! isAction && ! onEmailPasswordSignIn ) {
475
+ if ( ! onEmailPasswordSignIn ) {
478
476
throw new ConfigurationError (
479
477
`'onEmailPasswordSignIn' auth route handler not configured` ,
480
478
) ;
@@ -500,8 +498,7 @@ export class SolidServerAuth extends SolidAuthHelpers {
500
498
}
501
499
case "emailpassword/signup" : {
502
500
const data = await _getReqBody ( req ) ;
503
- const isAction = _isAction ( data ) ;
504
- if ( ! isAction && ! onEmailPasswordSignUp ) {
501
+ if ( ! onEmailPasswordSignUp ) {
505
502
throw new ConfigurationError (
506
503
`'onEmailPasswordSignUp' auth route handler not configured` ,
507
504
) ;
@@ -546,7 +543,6 @@ export class SolidServerAuth extends SolidAuthHelpers {
546
543
) ;
547
544
}
548
545
const data = await _getReqBody ( req ) ;
549
- const isAction = _isAction ( data ) ;
550
546
const [ email ] = _extractParams (
551
547
data ,
552
548
[ "email" ] ,
@@ -562,14 +558,11 @@ export class SolidServerAuth extends SolidAuthHelpers {
562
558
) . toString ( ) ,
563
559
) ;
564
560
this . setVerifierCookie ( verifier ) ;
565
- return isAction
566
- ? Response . json ( { _data : null } )
567
- : new Response ( null , { status : 204 } ) ;
561
+ return Response . json ( { _data : null } ) ;
568
562
}
569
563
case "emailpassword/reset-password" : {
570
564
const data = await _getReqBody ( req ) ;
571
- const isAction = _isAction ( data ) ;
572
- if ( ! isAction && ! onEmailPasswordReset ) {
565
+ if ( ! onEmailPasswordReset ) {
573
566
throw new ConfigurationError (
574
567
`'onEmailPasswordReset' auth route handler not configured` ,
575
568
) ;
@@ -600,7 +593,6 @@ export class SolidServerAuth extends SolidAuthHelpers {
600
593
}
601
594
case "emailpassword/resend-verification-email" : {
602
595
const data = await _getReqBody ( req ) ;
603
- const isAction = _isAction ( data ) ;
604
596
const verificationToken =
605
597
data instanceof FormData
606
598
? data . get ( "verification_token" ) ?. toString ( )
@@ -614,9 +606,7 @@ export class SolidServerAuth extends SolidAuthHelpers {
614
606
await (
615
607
await this . core
616
608
) . resendVerificationEmail ( verificationToken . toString ( ) ) ;
617
- return isAction
618
- ? Response . json ( { _data : null } )
619
- : new Response ( null , { status : 204 } ) ;
609
+ return Response . json ( { _data : null } ) ;
620
610
} else if ( email ) {
621
611
const { verifier } = await (
622
612
await this . core
@@ -629,9 +619,7 @@ export class SolidServerAuth extends SolidAuthHelpers {
629
619
sameSite : "strict" ,
630
620
path : "/" ,
631
621
} ) ;
632
- return isAction
633
- ? Response . json ( { _data : null } )
634
- : new Response ( null , { status : 204 } ) ;
622
+ return Response . json ( { _data : null } ) ;
635
623
} else {
636
624
throw new InvalidDataError (
637
625
"verification_token or email missing from request body" ,
@@ -697,7 +685,6 @@ export class SolidServerAuth extends SolidAuthHelpers {
697
685
) ;
698
686
}
699
687
const data = await _getReqBody ( req ) ;
700
- const isAction = _isAction ( data ) ;
701
688
const [ email ] = _extractParams (
702
689
data ,
703
690
[ "email" ] ,
@@ -714,9 +701,7 @@ export class SolidServerAuth extends SolidAuthHelpers {
714
701
) . toString ( ) ,
715
702
) ;
716
703
this . setVerifierCookie ( verifier ) ;
717
- return isAction
718
- ? Response . json ( { _data : null } )
719
- : new Response ( null , { status : 204 } ) ;
704
+ return Response . json ( { _data : null } ) ;
720
705
}
721
706
case "magiclink/send" : {
722
707
if ( ! this . options . magicLinkFailurePath ) {
@@ -725,7 +710,6 @@ export class SolidServerAuth extends SolidAuthHelpers {
725
710
) ;
726
711
}
727
712
const data = await _getReqBody ( req ) ;
728
- const isAction = _isAction ( data ) ;
729
713
const [ email ] = _extractParams (
730
714
data ,
731
715
[ "email" ] ,
@@ -742,9 +726,7 @@ export class SolidServerAuth extends SolidAuthHelpers {
742
726
) . toString ( ) ,
743
727
) ;
744
728
this . setVerifierCookie ( verifier ) ;
745
- return isAction
746
- ? Response . json ( { _data : null } )
747
- : new Response ( null , { status : 204 } ) ;
729
+ return Response . json ( { _data : null } ) ;
748
730
}
749
731
default :
750
732
return new Response ( "Unknown auth route" , {
@@ -954,10 +936,6 @@ function _getReqBody(
954
936
: req . formData ( ) ;
955
937
}
956
938
957
- function _isAction ( data : any ) {
958
- return typeof data === "object" && data . _action === true ;
959
- }
960
-
961
939
function _wrapError ( err : Error ) {
962
940
return {
963
941
_error : {
0 commit comments