Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/keycloak.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ export interface KeycloakInitOptions {
*/
messageReceiveTimeout?: number

/**
* Configures whether the adapter should include the refresh token in the JWT.
* @default true
*/
refreshTokenIsJWT?: boolean

/**
* When onLoad is 'login-required', sets the 'ui_locales' query param in compliance with section 3.1.2.1
* of the OIDC 1.0 specification.
Expand Down
12 changes: 11 additions & 1 deletion lib/keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export default class Keycloak {
/** @type {string=} */
scope;
messageReceiveTimeout = 10000;
/** @type {boolean=} */
refreshTokenIsJWT;
/** @type {string=} */
idToken;
/** @type {KeycloakTokenParsed=} */
Expand Down Expand Up @@ -272,6 +274,12 @@ export default class Keycloak {
this.messageReceiveTimeout = initOptions.messageReceiveTimeout;
}

if (typeof initOptions.refreshTokenIsJWT === 'boolean') {
this.refreshTokenIsJWT = initOptions.refreshTokenIsJWT;
} else {
this.refreshTokenIsJWT = true;
}

await this.#loadConfig();
await this.#check3pCookiesSupported()
await this.#processInit(initOptions);
Expand Down Expand Up @@ -1535,7 +1543,9 @@ export default class Keycloak {

if (refreshToken) {
this.refreshToken = refreshToken;
this.refreshTokenParsed = decodeToken(refreshToken);
if (this.refreshTokenIsJWT === true) {
this.refreshTokenParsed = decodeToken(refreshToken);
}
} else {
delete this.refreshToken;
delete this.refreshTokenParsed;
Expand Down