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

@webhandle/users-data-service

v1.0.4

Published

Functionality for storing users and groups, as well as loading the user object based on the session stored in a cookie.

Downloads

510

Readme

@webhandle/users-data-service

Functionality for storing users and groups, as well as loading the user object based on the session stored in a cookie.

Major Exposed Functions

// the caller must wait for the callback because of the encryption that takes
// place when writing the cookie
res.createUserSession(userName, callback)


// the caller must wait for the callback because of the encryption that takes
// place when writing the cookie
res.removeUserSession(callback)

// If there is a user session, the user object will be here
req.user

There is a auth service which can check if a user is allowed to log in and code to safely hash a user's password.

/**
 * Attempts to log in a user with name `name` and pass `pass`. If successful, a user is returned.
 * All other conditions result in an error on callback or a rejection of the promise.
 * @param {string} name 
 * @param {string} pass 
 * @param {function} [callback] With signature (err, user)
 * @returns A promise which has the same resolve behavior as the callback.
 */
login(name, pass, callback /* (err, user) */) 


/**
 * Updates pass but does not save.
 * @param {User} user 
 * @param {string} newPassword 
 * @returns The user object
 */
updatePass(user /* User */, newPassword) 

/**
 * Finds a user
 * @param {string} name The login name of the user
 * @param {function} callback A function with signature (err, user)
 * @returns a promise which will resolve to a user object if a matching user is found.
 */
findUser(name, callback) 



/**
 * Creates a new user if one by this name does not exist
 * @param {String} name
 * @param {String} pass
 * @param {Array[string]} groups
 * @returns The user, either existing or created.
*/
async createUserIfNoneExists(name, pass, groups) {

The auth services is available at webhandle.services.authService and at

import setup from '@webhandle/users-data-service/initialize-webhandle-component.mjs'
let manager = await setup(webhandle)

manager.services.authService
manager.services.usersDataService
manager.services.groupsDataService

usersDataService and groupsDataService are instances of @dankolz/abstract-data-service

Config

{
	"@webhandle/users-data-service": {
		"usersCollectionName": "webhandleusers_users"
		, "groupsCollectionName": "webhandleusers_groups"
		, "sessionLength": 2592000000
		, "databaseName": null
		, "iterations": 156
		, "salt": "two may keep it if one is dead"
		, "algorithm": "sha256"
		, "maxFailures": 10
	}
}

sessionLength defaults to 30 days. maxFailures is how many time the user can attempt login before the account is disabled. The salt is used to make the hashed passwords harder to guess.

If the databaseName is null, it will use webhandle.primaryDatabase. If it's set, it will use webhandle.dbs[databaseName].