Skip to content

Commit f861a46

Browse files
committed
feat: update pkce client impl with new refreshTokens parameter
1 parent 5e76e69 commit f861a46

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/sdk/oauth2-flows/AuthCodeWithPKCE.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ export class AuthCodeWithPKCE extends AuthCodeAbstract {
6969
* `AuthCodeAbstract` parent class, see corresponding comment in parent class for
7070
* further explanation.
7171
* @param {SessionManager} sessionManager
72+
* @param {boolean} [commitToSession=true] - Optional parameter, determines whether to commit the refresh tokens to the session. Defaults to true.
7273
* @returns {Promise<OAuth2CodeExchangeResponse>}
7374
*/
7475
public async refreshTokens(
75-
sessionManager: SessionManager
76+
sessionManager: SessionManager,
77+
commitToSession: boolean = true
7678
): Promise<OAuth2CodeExchangeResponse> {
7779
const refreshToken = await utilities.getRefreshToken(sessionManager);
7880
const body = new URLSearchParams({
@@ -82,11 +84,13 @@ export class AuthCodeWithPKCE extends AuthCodeAbstract {
8284
});
8385

8486
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+
}
9094
return tokens;
9195
}
9296

0 commit comments

Comments
 (0)