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

attest-auth

v0.2.0

Published

Login by attestation

Downloads

37

Readme

attest-auth

Verify a keypair using a challenge

npm install attest-auth

Usage

const Authenticator = require('attest-auth')
const curve = require('noise-handshake/dh')

const keypair = curve.generateKeyPair()
const serverKeys = curve.generateKeyPair()

const server = new Authenticator(serverKeys, { curve })

let serverLogin = server.createServerLogin({
  timeout: 2 * 60 * 1000,
  description: 'Bitfinex'
})

serverLogin.on('verify', function () {
  console.log(serverLogin.publicKey.slice(0, 4).toString('hex'), 'logged in!')
})

const challengeInfo = serverLogin.getChallenge()

// User passes challenge somehow to auth device
const metadata = Buffer.from('put metadata here.')

const trustedLogin = Authenticator.createClientLogin(keypair, serverKeys.pub, challengeInfo, { curve, metadata })

trustedLogin.on('verify', function (info) {
  console.log(info.publicKey.slice(0, 8), 'logged in!', info)
  console.log(Buffer.from(info.metadata, 'base64').toString()) // put metadata here.
})

// Verify the challenge using our local key pair
serverLogin = server.verify(trustedLogin.request, { metadata })

console.log(serverLogin.clientMetadata.toString()) // put metadata here.

// Pass the server response back so the trustedLogin knows it worked as well
trustedLogin.verify(serverLogin.response)

API

const auth = new Authenticator(severKeyPair, [options])

Make a new authenticator.

serverLogin = auth.createServerLogin([options])

Make a server login instance.

options object takes the following parameters:

{
  curve  // specify curve to be used for dh, must be noise-handshake compliant
}

const challengeMessage = serverLogin.getChallenge()

Pass this challenge to the client to login

serverLogin.on('verify', () => ...)

Emitted when the client has proved the challenge using a key pair

serverLogin.on('error', () => ...)

Emitted when the login fails or times out.

serverLogin.publicKey

Populated after the client has verified the login.

trustedLogin = Authenticator.createClientLogin(clientKeyPair, serverPublicKey, challenge, [options])

Created a client login pointing to the server and the challenge.

options object takes the following parameters:

{
  curve,    // specify a curve/an array of curves to be used for dh, must be noise-handshake compliant
  metadata  // optional metadata to be passed as a buffer
}

trustedLogin.request

Send this request to the server to login.

serverLogin = auth.verify(loginRequest, [options])

Verified a login from the client. Returns the matched login instance, or throws otherwise.

If verified the serverLogin instance emits verify at this stage.

options object takes the following parameters:

{
  metadata  // optional metadata to be passed as a buffer
}

serverLogin.response

Contains the response buffer after a succesful login, send this back to the client.

response object has the form

{
  type,
  publicKey,   // hex encoded public key
  description,
  metadata     // base64 encoded metadata
}

trustedLogin.verify(loginResponse)

Verify that the server logged the user in, throws otherwise.