New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@universal-packages/express-session

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@universal-packages/express-session - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

20

package.json
{
"name": "@universal-packages/express-session",
"version": "1.4.0",
"version": "1.5.0",
"description": "Express session manager.",

@@ -15,3 +15,3 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)",

"test:clear": "jest --clearCache",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json}\""
"format": "prettier --write \"./{src,tests}/**/*.{ts,tsx,js,jsx,json}\""
},

@@ -26,2 +26,3 @@ "dependencies": {

"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/cookie-parser": "^1.4.3",

@@ -34,4 +35,4 @@ "@types/express": "^4.17.14",

"jest-circus": "^28.1.0",
"node-fetch": "^2.6.7",
"prettier": "^2.8.7",
"node-fetch": "^2.6.7",
"ts-jest": "^28.0.4",

@@ -60,4 +61,15 @@ "typescript": "^4.7.3"

"printWidth": 180,
"trailingComma": "none"
"trailingComma": "none",
"importOrder": [
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": [
"typescript",
"jsx",
"classProperties",
"decorators-legacy"
]
}
}

13

README.md

@@ -145,4 +145,15 @@ # Express Session

We link the session with their authenticatable id to be able to grouping them later as active sessions.
Returns all the active sessions for the current session authenticatable.
### Static methods
#### **`activeSessions(authenticatableId: String, [options: Object])`** `Async`
Returns all the active sessions for the authenticatable id.
- **`authenticatableId`** `String`
The id of the authenticatable to get the active sessions from.
- **`options`** `Object`
Same options as [Token Registry](https://github.com/universal-packages/universal-token-registry#options)
## Global methods

@@ -149,0 +160,0 @@

@@ -0,3 +1,5 @@

import { MemoryEngine, RegistryOptions } from '@universal-packages/token-registry';
import { Request, Response } from 'express';
import { ExpressSessionOptions, SessionRegistrySubject } from './types';
export declare const MEMORY_ENGINE: MemoryEngine;
export default class Session {

@@ -18,3 +20,4 @@ id: string;

private readonly options;
constructor(request: Request, response: Response, options?: ExpressSessionOptions);
constructor(request: Request, response: Response, options?: RegistryOptions);
static activeSessions(authenticatableId: string | number | bigint, options?: ExpressSessionOptions): Promise<Record<string, SessionRegistrySubject>>;
initialize(): Promise<void>;

@@ -21,0 +24,0 @@ logIn(authenticatableId: string | number | bigint): Promise<void>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MEMORY_ENGINE = void 0;
const crypto_utils_1 = require("@universal-packages/crypto-utils");
const token_registry_1 = require("@universal-packages/token-registry");
// All sessions share this memory engine
const MEMORY_ENGINE = new token_registry_1.MemoryEngine();
exports.MEMORY_ENGINE = new token_registry_1.MemoryEngine();
class Session {

@@ -19,4 +20,4 @@ constructor(request, response, options) {

this.deviceId = null;
this.options = { engine: MEMORY_ENGINE, cookieName: 'session', ...options };
const engine = this.options.engine === 'memory' ? MEMORY_ENGINE : this.options.engine;
this.options = { engine: exports.MEMORY_ENGINE, cookieName: 'session', ...options };
const engine = this.options.engine === 'memory' ? exports.MEMORY_ENGINE : this.options.engine;
this.registry = new token_registry_1.Registry({ engine: engine, engineOptions: this.options.engineOptions, seed: this.options.registryId || this.options.seed });

@@ -26,2 +27,9 @@ this.request = request;

}
static async activeSessions(authenticatableId, options) {
const finalOptions = { engine: exports.MEMORY_ENGINE, cookieName: 'session', ...options };
const engine = finalOptions.engine === 'memory' ? exports.MEMORY_ENGINE : finalOptions.engine;
const registry = new token_registry_1.Registry({ engine: engine, engineOptions: finalOptions.engineOptions, seed: finalOptions.registryId || finalOptions.seed });
const category = `auth-${authenticatableId}`;
return await registry.retrieveAll(category);
}
async initialize() {

@@ -28,0 +36,0 @@ await this.registry.initialize();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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