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

redisess

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redisess - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

9

dist/index.d.ts

@@ -1,7 +0,2 @@

import { SessionManager } from './SessionManager';
import { Redis } from 'ioredis';
declare function redisess(client: Redis, options?: SessionManager.Options): SessionManager;
declare namespace redisess {
var SessionManager: typeof import("./SessionManager").SessionManager;
}
export = redisess;
export * from './SessionManager';
export * from './Session';
"use strict";
const SessionManager_1 = require("./SessionManager");
function redisess(client, options) {
return new SessionManager_1.SessionManager(client, options);
}
redisess.SessionManager = SessionManager_1.SessionManager;
module.exports = redisess;
//# sourceMappingURL=index.js.map
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./SessionManager"), exports);
__exportStar(require("./Session"), exports);

@@ -7,3 +7,3 @@ "use strict";

this._src = src;
this._sha = null;
this._sha = '';
this._numberOfKeys = numberOfKeys || 0;

@@ -22,3 +22,3 @@ }

// Retry
this._sha = null;
this._sha = '';
return await this._execute(client, ...args);

@@ -41,2 +41,1 @@ }

exports.RedisScript = RedisScript;
//# sourceMappingURL=RedisScript.js.map

@@ -13,5 +13,5 @@ import { SessionManager } from './SessionManager';

private _userId;
private _ttl?;
private _lastAccess?;
private _expires?;
private _ttl;
private _lastAccess;
private _expires;
/**

@@ -18,0 +18,0 @@ *

@@ -23,3 +23,3 @@ "use strict";

this._sessionId = opts.sessionId;
this._userId = opts.userId;
this._userId = opts.userId || '';
this._ttl = opts.ttl || 0;

@@ -105,3 +105,3 @@ this._lastAccess = 0;

const resp = await client.hmget(sessKey, ...args);
this._userId = resp[0];
this._userId = resp[0] || '';
this._lastAccess = Number(resp[1]) || 0;

@@ -259,2 +259,1 @@ this._expires = Number(resp[2]) || 0;

exports.Session = Session;
//# sourceMappingURL=Session.js.map

@@ -20,9 +20,9 @@ import { Redis } from 'ioredis';

private readonly _additionalFields?;
private readonly _killScript?;
private readonly _writeScript?;
private readonly _wipeScript?;
private readonly _killAllScript?;
private readonly _killScript;
private readonly _writeScript;
private readonly _wipeScript;
private readonly _killAllScript;
private _wipeTimer?;
private _wipeInterval?;
private _timediff;
private _timeDiff;
/**

@@ -38,2 +38,4 @@ *

constructor(client: Redis, props?: SessionManager.Options);
get namespace(): string | undefined;
get ttl(): number | undefined;
/**

@@ -73,3 +75,3 @@ * Returns the number of sessions within the last n seconds.

*/
get(sessionId: string, noUpdate?: boolean): Promise<Session>;
get(sessionId: string, noUpdate?: boolean): Promise<Session | undefined>;
/**

@@ -104,3 +106,3 @@ * Retrieves all session ids which were active within the last n seconds.

*/
getOldestUserSession(userId: string, noUpdate?: boolean): Promise<Session>;
getOldestUserSession(userId: string, noUpdate?: boolean): Promise<Session | undefined>;
/**

@@ -107,0 +109,0 @@ * Returns true if sessionId exists, false otherwise,

@@ -32,5 +32,4 @@ "use strict";

this._ttl = Number(props.ttl) >= 0 ? Number(props.ttl) : (30 * 60);
this._timediff = null;
this._timeDiff = 0;
this._wipeInterval = props.wipeInterval || 1000;
this._wipeTimer = null;
client.once('close', () => this.quit());

@@ -106,2 +105,8 @@ this._killScript = new RedisScript_1.RedisScript(`

}
get namespace() {
return this._ns;
}
get ttl() {
return this._ttl;
}
/**

@@ -291,4 +296,6 @@ * Returns the number of sessions within the last n seconds.

quit() {
clearTimeout(this._wipeInterval);
this._wipeInterval = null;
if (this._wipeTimer) {
clearTimeout(this._wipeTimer);
this._wipeTimer = undefined;
}
}

@@ -307,3 +314,3 @@ // noinspection JSMethodCanBeStatic

// Synchronize redis server time with local time
this._timediff = (Date.now() / 1000) -
this._timeDiff = (Date.now() / 1000) -
Math.floor(Number(resp[0]) + (Number(resp[1]) / 1000000));

@@ -313,3 +320,3 @@ return this._now();

_now() {
return Math.floor(Date.now() / 1000 + this._timediff);
return Math.floor(Date.now() / 1000 + this._timeDiff);
}

@@ -329,3 +336,3 @@ async _getClient() {

}
if (this._timediff == null)
if (this._timeDiff == null)
await this._syncTime(this._client);

@@ -335,4 +342,6 @@ return this._client;

async _wipe() {
clearTimeout(this._wipeTimer);
this._wipeTimer = null;
if (this._wipeTimer) {
clearTimeout(this._wipeTimer);
this._wipeTimer = undefined;
}
const client = await this._getClient();

@@ -343,2 +352,1 @@ await this._wipeScript.execute(client, this._ns, this._now());

exports.SessionManager = SessionManager;
//# sourceMappingURL=SessionManager.js.map
{
"name": "redisess",
"description": "Powerful redis session manager for NodeJS",
"version": "1.1.3",
"version": "1.2.0",
"author": "Panates Ltd.",

@@ -63,6 +63,9 @@ "contributors": [

"compile": "tsc -b tsconfig.json",
"test": "ts-mocha -p test/tsconfig.json --paths --reporter spec test/**/*.spec.ts",
"cover": "nyc --reporter=cobertura --reporter html --reporter text npm run test",
"test": "mocha --reporter spec test/*.test.js",
"travis-cover": "nyc --reporter lcovonly npm run test"
},
"dependencies": {
"ts-mocha": "^8.0.0"
}
}

@@ -26,6 +26,7 @@

```js
const express = require("express");
const Redis = require("ioredis");
const {SessionManager} = require("redisess");
```ts
import express from 'express';
import Redis from 'ioredis';
import {SessionManager} from 'redisess';
const redis = new Redis();

@@ -32,0 +33,0 @@

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