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

@nan0web/auth-core

v1.0.0

Published

|Package name|[Status](https://github.com/nan0web/monorepo/blob/main/system.md#написання-сценаріїв)|Documentation|Test coverage|Features|Npm version| |---|---|---|---|---|---| |[@nan0web/auth-core](https://github.com/nan0web/auth-core/) |🟢 `99.4%` |🧪 [

Readme

@nan0web/auth-core

|Package name|Status|Documentation|Test coverage|Features|Npm version| |---|---|---|---|---|---| |@nan0web/auth-core |🟢 99.4% |🧪 English 🏴󠁧󠁢󠁥󠁮󠁧󠁿Українською 🇺🇦 |🟢 98.5% |✅ d.ts 📜 system.md 🕹️ playground |— |

Minimal authentication core providing:

  • User – user model with role handling and token management
  • Role – enumeration of user roles
  • Membership – group based permission sets
  • TokenExpiryService – simple token lifetime utilities
  • Auth – facade exporting the above

Installation

How to install with npm?

npm install @nan0web/auth-core

How to install with pnpm?

pnpm add @nan0web/auth-core

How to install with yarn?

yarn add @nan0web/auth-core

Basic usage – User

Create a user, assign roles and check role existence.

How to create a User and check roles?

import { User, Role } from "@nan0web/auth-core"
const user = new User({
	name: "Alice",
	email: "[email protected]",
	roles: ["admin", "user"],
})
console.info(user.toString({ detailed: true, hideDate: true }))
// Alice <[email protected]> admin, user
console.info(user.is("admin")) // ← true
console.info(user.is("guest")) // ← false

Token handling

Manage tokens with TokenExpiryService.

How to create a token and validate its expiry?

import { TokenExpiryService } from "@nan0web/auth-core"
const service = new TokenExpiryService(2000) // 2 seconds
const tokenTime = new Date()
console.info(service.isValid(tokenTime)) // ← true
// fast‑forward simulation
const past = new Date(Date.now() - 3000)
console.info(service.isValid(past)) // ← false
console.info(service.getExpiryDate(tokenTime).toISOString())
// the date in ISO format

Membership – group permissions

Join a group, check permissions, mint daily coins and see admin bypass.

How to use Membership to manage group permissions?

import { Membership, Role } from "@nan0web/auth-core"
const mem = new Membership()
// regular group with explicit permissions
mem.join("lawyers", "moderator", new Set(["r", "w"]), { dailyCoins: 10 })
console.info(mem.can("lawyers", "r")) // ← true
console.info(mem.can("lawyers", "d")) // ← false
mem.mintDailyCoins("lawyers")
const inner = mem.memberships.get("lawyers")
console.info(inner?.config.wallet === 10n) // ← true
// admin role bypasses all permission checks
mem.join("admins", "admin", new Set(), {})
console.info(mem.can("admins", "*")) // ← true

Auth facade

Exported object provides easy access to core classes.

How to use the Auth facade?

import { Auth } from "@nan0web/auth-core"
const user = new Auth.User({ name: "Bob" })
// Showing user name with createdAt date-time
console.info(user.toString())
// Bob
// YYYY-MM-DD HH:mm:SS

API reference

User

  • Properties

    • name – string
    • email – string
    • rolesRole[]
    • createdAtDate
    • updatedAtDate
  • Methods

    • is(role) – checks if the user has the specified role
    • toObject() – plain representation without private tokens

Role

  • Static ROLES

    • admin"a"
    • author"r"
    • moderator"m"
    • user"u"
  • Methods

    • toString() – returns role value

Membership

  • Properties

    • membershipsMap<string, { role: Role, perms: Set<string>, config: object }>
  • Methods

    • join(key, roleValue, perms, config) – add a group
    • can(key, perm) – permission check (admin role bypasses)
    • mintDailyCoins(key) – add daily coin amount from config (updates wallet in config)

TokenExpiryService

  • Constructor

    • new TokenExpiryService(lifetimeMs)
  • Methods

    • isValid(creationDate, lifetime?)
    • getExpiryDate(issuedAt?, lifetime?)
    • extendLifetime(creationDate, extensionMs?, maxLifetime?)

Auth

Facade exporting User, Role, TokenExpiryService, Membership.

All exported classes should be available

JavaScript

Types are described via JSDoc and the generated .d.ts files.

Uses d.ts for autocomplete

Contributing

How to contribute? - check here

License

How to license ISC? - check here