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 🙏

© 2025 – Pkg Stats / Ryan Hefner

locke

v0.4.5

Published

* 01. Authenticating a user (createUser, authPassword, authToken) * 02. jsonp * 03. Graceful handling of invalid functions (404) * 04. Creating apps (createApp, getApps) * 05. Closing sessions (closeSession, closeAllSessions) * 06. Deleting a user (deleteUser) * 07. Updating password (updatePassword) * 08. Deleting apps (deleteApp) * 09. Forgot password (sendPasswordReset, resetPassword) * 10. Validating user (sendValidation, validateUser)

Readme

Features (from a testing perspective)

    1. Authenticating a user (createUser, authPassword, authToken)
    1. jsonp
    1. Graceful handling of invalid functions (404)
    1. Creating apps (createApp, getApps)
    1. Closing sessions (closeSession, closeAllSessions)
    1. Deleting a user (deleteUser)
    1. Updating password (updatePassword)
    1. Deleting apps (deleteApp)
    1. Forgot password (sendPasswordReset, resetPassword)
    1. Validating user (sendValidation, validateUser)

Basic functions - getting started

createUser(app, email, password)

  • { status: "Could not find an app with that name" }
  • { status: "The given email is already in use for this app" }
  • { status: "Password too short - use at least 6 characters" }
  • { status: "Password too common - use something more unique" }
  • { status: "OK" } A new user has been created for the given app

authPassword(app, email, password, secondsToLive)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect password" }
  • { status: "The parameter 'secondsToLive' must be an integer >0" }
  • { status: "OK", token: ".......", validated: false }

authToken(app, email, token)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect token" }
  • { status: "Token timed out" }
  • { status: "OK", validated: false }

Getting further - deleting, closing and updating

deleteUser(app, email, password)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect password" }
  • { status: "OK" }

closeSession(app, email, token)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect token" }
  • { status: "OK" }

closeAllSessions(app, email, password)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect password" }
  • { status: "OK" }

updatePassword(app, email, oldPassword, newPassword)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect password" }
  • { status: "Password too short - use at least 6 characters" }
  • { status: "Password too common - use something more unique" }
  • { status: "OK" }

Email validation and resetting password; the emailing functions

sendValidation(app, email)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "The user has already been validated" }
  • { status: "OK" }

sendPasswordReset(app, email)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "OK" }

resetPassword(app, email, resetToken, newPassword)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "Incorrect token" }
  • { status: "Password too short - use at least 6 characters" }
  • { status: "Password too common - use something more unique" }
  • { status: "OK" }

validateUser(app, email, validationToken)

  • { status: "Could not find an app with that name" }
  • { status: "There is no user with that email for the given app" }
  • { status: "The user has already been validated" }
  • { status: "Incorrect token" }
  • { status: "OK" }

Managing apps - for app developers only

createApp(email, token, app)

  • { status: "There is no user with that email for the locke-app" }
  • { status: "Incorrect token" }
  • { status: "App name is already is use" }
  • { status: "OK" }

getApps(email, token)

  • { status: "There is no user with that email for the locke-app" }
  • { status: "Incorrect token" }
  • { status: "OK", apps: { app1: { userCount: x }, app2: { userCount: y } } }

deleteApp(email, password, app)

  • { status: "There is no user with that email for the locke-app" }
  • { status: "Incorrect password" }
  • { status: "Could not find an app with that name" }
  • { status: "OK" }

Invariants exposed by the interface

  • Ensure the parameter 'secondsToLive' for 'authPassword' times out on time
  • Ensure calling 'authToken' reset the timeout for the token to the time specified when it was created using 'authPassword'
  • Ensure no duplicate tokens are ever generated
  • Ensure 'updatePassword' and 'resetPassword' invalidates all passwordReset tokens for the given user
  • Ensure 'updatePassword' and 'resetPassword' does not invalid tokens for user validation and authentication
  • Ensure emails are actually sent by 'sendValidation' and 'sendPasswordReset'
  • Ensure that only the latest password will work for the password-protected functions (authPassword, deleteUser, updatePassword)

Internal invariants

  • Ensure 'closeSession' and 'closeSessions' deletes the tokens from the backend permanently
  • Ensure 'deleteUser' deletes the given user from the backend permanently
  • Ensure 'updatePassword' deletes the old password from the backend permanently

Invariants I don't know how to test

  • Ensure the token generated (by all token generating functions; 'authPassword', 'sendValidation', 'sendPasswordReset') are unpredictable (high entropy etc)

Ideas for the future

  • Throttling of different kinds
  • Captchas for breaking throttling - maybe?

Disclaimer

Evil developers will still be able to scam stupid users. Not more than they are already doing though.

On the other hand, developers with good intentions will be less likely to screw up. And the amount of wheel they have to reinvent will be minimal.