npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@streetjs/session

v1.0.0

Published

StreetJS session foundation: stateless, encrypted session tokens using AES-256-GCM (authenticated encryption) with key-entropy validation and CSRF/session-id helpers. Zero runtime dependencies.

Readme

@streetjs/session

The session foundation for StreetJS: stateless, encrypted session tokens using AES-256-GCM (authenticated encryption), with key-entropy validation and CSRF/session-id helpers.

Zero runtime dependencies. Built on Node.js core (crypto) only, matching the StreetJS minimal, carefully curated dependency footprint. Generic and reusable by any application.

npm install @streetjs/session

This is the standalone home of the session manager that also backs streetjs/session; the streetjs framework re-exports it, so there is a single implementation.

Quick start

import { SessionManager } from '@streetjs/session';

// 64-char hex key (32 bytes). Generate with: openssl rand -hex 32
const sessions = new SessionManager(process.env.SESSION_KEY!);

const token = sessions.encrypt({ userId: '7', roles: ['admin'], csrf });
const data = sessions.decrypt(token); // SessionData | null (null when tampered/invalid)

How it works

  • Stateless — the session lives entirely in the encrypted token (e.g. a cookie), so there is no server-side session store to scale or invalidate.
  • Authenticated encryption — AES-256-GCM produces iv | tag | ciphertext; any modification fails the auth tag and decrypt returns null. Plaintext is never retained.
  • Key validation — the constructor requires a 64-char hex key (32 bytes) and rejects low-entropy keys (e.g. an all-zeros default) to prevent an insecure misconfiguration.

API

const sm = new SessionManager(hexKey);
sm.encrypt(data: SessionData): string;          // base64 token
sm.decrypt(token: string): SessionData | null;  // null if tampered/invalid

SessionManager.generateCsrf(): string;          // base64url, 32 random bytes
SessionManager.generateSessionId(): string;     // base64url, 24 random bytes

SessionData is an open shape (userId?, email?, roles?, csrf?, plus any extra fields), so you can store whatever your app needs.

Security notes

  • Keep the key secret and rotate it via your secret store; a key change invalidates all existing tokens (they simply fail to decrypt).
  • Set the cookie HttpOnly, Secure, and SameSite at the HTTP layer; this package handles only the token crypto.
  • Pair with the CSRF token for state-changing requests (double-submit or header check).

Dependency injection

Depends on no container. Exports a SESSION_MANAGER token (a global Symbol):

import { SESSION_MANAGER, SessionManager } from '@streetjs/session';
container.register(SESSION_MANAGER, new SessionManager(key));

Public API

SessionManager · SessionData · SESSION_MANAGER token.

See ARCHITECTURE.md for design notes, and src/examples/integration.ts for a runnable cookie-session example.

License

MIT © street contributors