File tree Expand file tree Collapse file tree 3 files changed +23
-13
lines changed Expand file tree Collapse file tree 3 files changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -88,10 +88,12 @@ export abstract class AuthCodeAbstract {
88
88
* Abstract method will implement logic in child classes for refreshing access token
89
89
* using refresh token available in current session.
90
90
* @param {SessionManager } sessionManager
91
+ * @param {boolean } [commitToSession=true] - Optional parameter, determines whether to commit the refreshed tokens to the session. Defaults to true.
91
92
* @returns {Promise<OAuth2CodeExchangeResponse> }
92
93
*/
93
94
public abstract refreshTokens (
94
- sessionManager : SessionManager
95
+ sessionManager : SessionManager ,
96
+ commitToSession ?: boolean
95
97
) : Promise < OAuth2CodeExchangeResponse > ;
96
98
97
99
/**
Original file line number Diff line number Diff line change @@ -69,10 +69,12 @@ export class AuthCodeWithPKCE extends AuthCodeAbstract {
69
69
* `AuthCodeAbstract` parent class, see corresponding comment in parent class for
70
70
* further explanation.
71
71
* @param {SessionManager } sessionManager
72
+ * @param {boolean } [commitToSession=true] - Optional parameter, determines whether to commit the refreshed tokens to the session. Defaults to true.
72
73
* @returns {Promise<OAuth2CodeExchangeResponse> }
73
74
*/
74
75
public async refreshTokens (
75
- sessionManager : SessionManager
76
+ sessionManager : SessionManager ,
77
+ commitToSession : boolean = true
76
78
) : Promise < OAuth2CodeExchangeResponse > {
77
79
const refreshToken = await utilities . getRefreshToken ( sessionManager ) ;
78
80
const body = new URLSearchParams ( {
@@ -82,11 +84,13 @@ export class AuthCodeWithPKCE extends AuthCodeAbstract {
82
84
} ) ;
83
85
84
86
const tokens = await this . fetchTokensFor ( sessionManager , body , true ) ;
85
- await utilities . commitTokensToSession (
86
- sessionManager ,
87
- tokens ,
88
- this . tokenValidationDetails
89
- ) ;
87
+ if ( commitToSession ) {
88
+ await utilities . commitTokensToSession (
89
+ sessionManager ,
90
+ tokens ,
91
+ this . tokenValidationDetails
92
+ ) ;
93
+ }
90
94
return tokens ;
91
95
}
92
96
Original file line number Diff line number Diff line change @@ -54,10 +54,12 @@ export class AuthorizationCode extends AuthCodeAbstract {
54
54
* `AuthCodeAbstract` parent class, see corresponding comment in parent class for
55
55
* further explanation.
56
56
* @param {SessionManager } sessionManager
57
+ * @param {boolean } [commitToSession=true] - Optional parameter, determines whether to commit the refreshed tokens to the session. Defaults to true.
57
58
* @returns {Promise<OAuth2CodeExchangeResponse> }
58
59
*/
59
60
public async refreshTokens (
60
- sessionManager : SessionManager
61
+ sessionManager : SessionManager ,
62
+ commitToSession : boolean = true
61
63
) : Promise < OAuth2CodeExchangeResponse > {
62
64
const refreshToken = await utilities . getRefreshToken ( sessionManager ) ;
63
65
@@ -73,11 +75,13 @@ export class AuthorizationCode extends AuthCodeAbstract {
73
75
} ) ;
74
76
75
77
const tokens = await this . fetchTokensFor ( sessionManager , body ) ;
76
- await utilities . commitTokensToSession (
77
- sessionManager ,
78
- tokens ,
79
- this . tokenValidationDetails
80
- ) ;
78
+ if ( commitToSession ) {
79
+ await utilities . commitTokensToSession (
80
+ sessionManager ,
81
+ tokens ,
82
+ this . tokenValidationDetails
83
+ ) ;
84
+ }
81
85
return tokens ;
82
86
}
83
87
You can’t perform that action at this time.
0 commit comments