diff --git a/doc/api_authService.md b/doc/api_authService.md index 872a419..3d127a1 100644 --- a/doc/api_authService.md +++ b/doc/api_authService.md @@ -95,6 +95,8 @@ Sets the login timeout. CAUTION: .authenticated and isAuthenticated() might get different results when set manually. +WARNING: Maximum timeout is 2^31 - 1 ms (ca. 24.85d). + #### Parameters | Parameter | Type | Description | diff --git a/src/authService.js b/src/authService.js index 3d4ee60..a208639 100644 --- a/src/authService.js +++ b/src/authService.js @@ -148,6 +148,14 @@ export class AuthService { * @param {number} ttl Timeout time in ms */ setTimeout(ttl: number) { + const maxTimeout = 2147483647; // maximum period in ms (ca. 24.85d) for windows.setTimeout + + // limit timer ttl to max value allowed for windows.setTimeout function + if (ttl > maxTimeout) { + ttl = maxTimeout; + logger.warn('Token timeout limited to ', maxTimeout, ' ms (ca 24.85d).'); + } + this.clearTimeout(); const expiredTokenHandler = () => {