@hmcts/rpx-xui-node-lib
Version:
Common nodejs library components for XUI
131 lines • 4.84 kB
TypeScript
/**
* Default Session Idle Time
*
* If the timeout configuration has not been set, or the User has no roles ( although the
* User shouldn't reach this point if they have no roles associated with them ) the
* default session idle time will be used.
*/
export declare const DEFAULT_SESSION_TIMEOUT: {
idleModalDisplayTime: number;
pattern: string;
totalIdleTime: number;
};
/**
* Is Role Match
*
* Checks if a User's role, matches a specified Regular Expression.
*
* We use a Regular Expression so that we can set the default session timeout via configuration ie. '.', hence we used
* JS .match over .includes.
*
* There will be a different default session timeout per application, and different session timeouts per user groups
* hence setting it via configuration.
*
* The following AC apply:
*
* should return true if there is a match of the User's role to the Session Timeout regex pattern so
* that the App knows that we need to have a specified Session Timeout for that user role.
* should return true if there is a partial match of the User's role to the Session Timeout regex pattern.
* should return false if there is no match of the User's role to the Session Timeout regex pattern.
* should return true for a wildcard regex pattern, note that this pattern acts as our configurable DEFAULT.
*
* @param role - 'pui-case-manager'
* @param pattern - 'case-manager' / 'pui-' / '.'
* @returns {boolean}
*/
export declare const isRoleMatch: (role: string, pattern: string) => boolean;
/**
* Any Roles Match
*
* Checks an array of roles for pattern matches.
*
* The following AC apply:
*
* should return true if any of a Users roles match a regex pattern.
* should return true if any of a Users roles match a Regular Expression wildcard.
* should return false if none of a Users roles match the regex pattern.
*
* @param roles - [
* 'pui-case-manager',
* 'pui-finance-manager',
* ]
* @param pattern - 'case-manager' / 'pui-' / '.'
*/
export declare const anyRolesMatch: (roles: string[], pattern: string) => boolean;
/**
* Sort User Roles
*
* Should sort the User's Roles alphabetically. Why? So that a priority order can be given to the Session Timeout +
* configuration list.
*
* We clone the original array, so that we avoid mutation.
*
* Example: If we want a PUI Session Timeout to be given preference over another Session Timeout it would be further
* up the Session Timeout Configuration list.
*
* @param - [
* 'caseworker-divorce-financialremedy',
* 'pui-user-manager',
* 'caseworker-probate-solicitor',
* 'caseworker',
* 'caseworker-probate',
* 'pui-finance-manager',
* 'caseworker-divorce-solicitor',
* ]
* @return - [
* 'caseworker',
* 'caseworker-divorce-financialremedy',
* 'caseworker-divorce-solicitor',
* 'caseworker-probate',
* 'caseworker-probate-solicitor',
* 'pui-user-manager',
* 'pui-finance-manager',
* ]
*/
export declare const sortUserRoles: (roles: string[]) => string[];
export interface RoleGroupSessionTimeout {
idleModalDisplayTime: number;
pattern: string;
totalIdleTime: number;
}
/**
* Get User Session Timeout
*
* We calculate the timeout for this user.
*
* A user is given a specified timeout based on their User Roles, and a given set of
* statically configured Session Timeouts, defined by the XUI team for a User Role Group.
*
* Example:
*
* A Department of Work & Pensions User on Manage Cases should have a Total Idle Time of 12 minutes, and
* and should show the Session Timeout Modal 3 minutes before the end of their session.
*
* Whereas a Manage Organisation application user should have an Total Idle Time of 50 minutes,
* and should show the Session Timeout Modal 10 minutes before the end of their session.
*
* Note that the Session Timeout needs to be easily configurable and will change for each XUI
* application, and each User role group.
*
* Important: the Session Timeout configuration should be in PRIORITY ORDER, with the DEFAULT for
* this application being the last item in the array.
*
* Jargon:
*
* Session Timeout Modal - The modal popup that appears BEFORE the users Total Idle Time is over.
* Total Idle Time - The Users total idle time, this includes time in which we show the Session Timeout Modal to the User.
* Session Timeout Configuration - An array that contains the Applications and User Groups session timeout times.
* Session Timeout - The idle timeout time for that User.
*
* @param userRoles - [
* 'pui-organisation-manager',
* ]
* @param sessionTimeouts - @see unit tests
* @returns
*/
export declare const getUserSessionTimeout: (userRoles: string[], sessionTimeouts: RoleGroupSessionTimeout[]) => {
idleModalDisplayTime: number;
pattern: string;
totalIdleTime: number;
};
//# sourceMappingURL=userTimeout.d.ts.map