Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-user-idle

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-user-idle - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

3

CHANGELOG.md

@@ -0,1 +1,4 @@

## 1.0.4
- Fix incorrect user's inactivity timer
## 1.0.3

@@ -2,0 +5,0 @@ - Update gitignore

2

package.json
{
"name": "angular-user-idle",
"version": "1.0.3",
"version": "1.0.4",
"description": "User's idle service for Angular 4",

@@ -5,0 +5,0 @@ "main": "user-idle.umd.js",

@@ -8,2 +8,6 @@ import { Observable } from 'rxjs';

ping$: Observable<any>;
/**
* Events that can interrupts user's inactivity timer.
*/
private readonly activityEvents$;
private timerStart$;

@@ -28,9 +32,9 @@ private timeout$;

/**
* Interrupt timer by user's events.
* Timeout status.
*/
private interrupting;
private isTimeout;
/**
* Timeout status.
* Timer of user's inactivity is in progress.
*/
private isTimeout;
private isInactivityTimer;
private idleSubscription;

@@ -37,0 +41,0 @@ constructor(config: UserIdleServiceConfig);

@@ -39,3 +39,4 @@ (function (global, factory) {

}
this.idle$ = rxjs.Observable.merge(rxjs.Observable.fromEvent(window, 'mousemove'), rxjs.Observable.fromEvent(window, 'resize'), rxjs.Observable.fromEvent(document, 'keydown'));
this.activityEvents$ = rxjs.Observable.merge(rxjs.Observable.fromEvent(window, 'mousemove'), rxjs.Observable.fromEvent(window, 'resize'), rxjs.Observable.fromEvent(document, 'keydown'));
this.idle$ = rxjs.Observable.from(this.activityEvents$);
}

@@ -49,15 +50,13 @@ /**

* If any of user events is not active for idle-seconds when start timer.
* If this.interrupts is sets to true the timer will be stopped if user
* does any event (mousemove, resize or keydown).
* @type {Subscription}
*/
this.idleSubscription = this.idle$
.map(function () {
if (_this.interrupting) {
_this.timerStart$.next(false);
}
.bufferTime(5000) // Starting point of detecting of user's inactivity
.filter(function (arr) { return !arr.length && !_this.isInactivityTimer; })
.switchMap(function () {
_this.isInactivityTimer = true;
return rxjs.Observable.interval(1000)
.takeUntil(rxjs.Observable.merge(_this.activityEvents$, rxjs.Observable.timer(_this.idle * 1000)
.do(function () { return _this.timerStart$.next(true); })))
.finally(function () { return _this.isInactivityTimer = false; });
})
.bufferTime(this.idle * 1000)
.filter(function (arr) { return !arr.length; })
.map(function () { return _this.timerStart$.next(true); })
.subscribe();

@@ -64,0 +63,0 @@ this.setupTimer(this.timeout);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc