keycloak-angular
Version:
Easy Keycloak integration for Angular applications.
48 lines (47 loc) • 1.78 kB
TypeScript
import Keycloak from 'keycloak-js';
import { UserActivityService } from './user-activity.service';
import * as i0 from "@angular/core";
/**
* Configuration options for the `AutoRefreshTokenService`.
*/
type AutoRefreshTokenOptions = {
/**
* Maximum allowed inactivity duration in milliseconds before
* the session times out. Default is `50000`.
*/
sessionTimeout?: number;
/**
* Action to take when the session times out due to inactivity.
* Options are:
* - `'login'`: Redirect to the Keycloak login page.
* - `'logout'`: Log the user out of the session.
* - `'none'`: Do nothing.
* Default is `'logout'`.
*/
onInactivityTimeout?: 'login' | 'logout' | 'none';
};
/**
* Service to automatically manage the Keycloak token refresh process
* based on user activity and token expiration events. This service
* integrates with Keycloak for session management and interacts with
* user activity monitoring to determine the appropriate action when
* the token expires.
*
* The service listens to `KeycloakSignal` for token-related events
* (e.g., `TokenExpired`) and provides configurable options for
* session timeout and inactivity handling.
*/
export declare class AutoRefreshTokenService {
private readonly keycloak;
private readonly userActivity;
private options;
private initialized;
constructor(keycloak: Keycloak, userActivity: UserActivityService);
private get defaultOptions();
private executeOnInactivityTimeout;
private processTokenExpiredEvent;
start(options?: AutoRefreshTokenOptions): void;
static ɵfac: i0.ɵɵFactoryDeclaration<AutoRefreshTokenService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AutoRefreshTokenService>;
}
export {};