1.1.1 • Published 2 years ago

active-session-library v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Active Session Library (ASL)

Active Session Library (ASL) is responsible for monitoring user activity and executing a callback when the user is not active in a given period of time.

A component for React. This library works with React.

peerDependencies

react version >= 16

Installation

Inside your project directory, install Active Session Library (ASL) by running either of the following:

npm i active-session-library

Or

yarn add active-session-library

Usage

import { ActiveSessionProvider } from 'active-session-library';

<ActiveSessionProvider
	timeout={60000}
	postAction={() => {
		console.log('postAction ...');
	}}
	preAction={() => {
		console.log('preAction ...');
	}}
	isEnabled
    events={['click', 'mousemove', 'keydown', 'scroll', 'drag']}
>
	<div>Secured Page</div>
</ActiveSessionProvider>;

Examples

API

Active Session Library (ASL) exports its IActiveSessionProviderProps interface for working in Typescript projects.

All the props you will need are outlined below:

PropsTypeRequiredDefault valueDescription
timeoutnumbertrue-Activity Timeout in milliseconds
postAction() => void;true-It will be called when the user becomes inactive, and the timeout is reached
isEnabledbooleanfalsetrueEnable/Disable the active session feature
preAction() => void;false-It will be called when the component mounts
childrenReactNodefalse-Your components / pages
eventsEventTypefalse'click', 'mousemove', 'keydown', 'scroll', 'drag'The events to watch for activity on

Changelog

To see what has updated in a given version of Active Session Library (ASL), you can check the changelog file.

License

MIT