@@ -51,6 +51,7 @@ import type {
51
51
SignInWithPasswordlessCredentials ,
52
52
SignUpWithPasswordCredentials ,
53
53
SignInWithSSO ,
54
+ SignOut ,
54
55
Subscription ,
55
56
SupportedStorage ,
56
57
User ,
@@ -1075,15 +1076,17 @@ export default class GoTrueClient {
1075
1076
*
1076
1077
* For server-side management, you can revoke all refresh tokens for a user by passing a user's JWT through to `auth.api.signOut(JWT: string)`.
1077
1078
* There is no way to revoke a user's access token jwt until it expires. It is recommended to set a shorter expiry on the jwt for this reason.
1079
+ *
1080
+ * If using others scope, no `SIGNED_OUT` event is fired!
1078
1081
*/
1079
- async signOut ( ) : Promise < { error : AuthError | null } > {
1082
+ async signOut ( { scope } : SignOut = { scope : 'global' } ) : Promise < { error : AuthError | null } > {
1080
1083
const { data, error : sessionError } = await this . getSession ( )
1081
1084
if ( sessionError ) {
1082
1085
return { error : sessionError }
1083
1086
}
1084
1087
const accessToken = data . session ?. access_token
1085
1088
if ( accessToken ) {
1086
- const { error } = await this . admin . signOut ( accessToken )
1089
+ const { error } = await this . admin . signOut ( accessToken , scope )
1087
1090
if ( error ) {
1088
1091
// ignore 404s since user might not exist anymore
1089
1092
// ignore 401s since an invalid or expired JWT should sign out the current session
@@ -1092,9 +1095,11 @@ export default class GoTrueClient {
1092
1095
}
1093
1096
}
1094
1097
}
1095
- await this . _removeSession ( )
1096
- await removeItemAsync ( this . storage , `${ this . storageKey } -code-verifier` )
1097
- await this . _notifyAllSubscribers ( 'SIGNED_OUT' , null )
1098
+ if ( scope !== 'others' ) {
1099
+ await this . _removeSession ( )
1100
+ await removeItemAsync ( this . storage , `${ this . storageKey } -code-verifier` )
1101
+ await this . _notifyAllSubscribers ( 'SIGNED_OUT' , null )
1102
+ }
1098
1103
return { error : null }
1099
1104
}
1100
1105
0 commit comments