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

@srcabc/notabot-server

v0.3.0

Published

Official Notabot server-side validation SDK (proof validation, unlock cookies, widget passkey subject tokens)

Readme

@srcabc/notabot-server

Official server-side Notabot validation SDK.

Install

npm install @srcabc/notabot-server

Validate a Protected Action

import { NotabotValidator } from "@srcabc/notabot-server"

const notabot = new NotabotValidator({
  siteKey: process.env.NOTABOT_SITE_KEY!,
  signingSecret: process.env.NOTABOT_SIGNING_SECRET!,
  apiBase: process.env.NOTABOT_API_BASE ?? "https://notabot.srcabc.com/api/v1",
  timeoutMs: 5000,
})

const result = await notabot.validateToken({
  proofToken: req.body.proof_token,
  action: "article_unlock",
  origin: req.headers.origin,
  correlationId: req.body.correlation_id,
})

if (!result.ok) {
  // Fail closed. Never allow the protected action on validation failure.
  throw new Error("verification_failed")
}

Contract

The SDK sends this body to POST /api/v1/verification/validate:

{
  "proof_token": "nbp_...",
  "action": "article_unlock",
  "origin": "https://customer.example",
  "correlation_id": "customer_req_..."
}

It signs the exact JSON body with the SVK v1 canonical request:

POST
/api/v1/verification/validate
sha256(raw_body)
site_key
timestamp
nonce

Do not send session_id or challenge_id; those are internal proof context fields.

The SDK fails closed on timeout, network errors, invalid JSON, replay, expiry, origin mismatch, and denied decisions. It never logs raw proof tokens.

Use validationReasonToStatus(reason) when you need the SDK's canonical validation-failure status mapping in a framework wrapper.

Unlock Cookies

import { createSignedUnlockCookie, verifySignedUnlockCookie } from "@srcabc/notabot-server"

const setCookie = createSignedUnlockCookie({
  secret: process.env.NOTABOT_UNLOCK_COOKIE_SECRET!,
  scope: "example.com/article",
  aud: "example.com",
  path: "/article",
  ttlSeconds: 3600,
  cookieName: "article_unlock",
})

const result = verifySignedUnlockCookie({
  secret: process.env.NOTABOT_UNLOCK_COOKIE_SECRET!,
  scope: "example.com/article",
  cookieValue,
})

For frameworks that set cookies with an object API, use buildUnlockCookie instead of parsing a Set-Cookie header string:

import { buildUnlockCookie } from "@srcabc/notabot-server"

const cookie = buildUnlockCookie({
  secret: process.env.NOTABOT_UNLOCK_COOKIE_SECRET!,
  scope: "example.com/article",
  aud: "example.com",
  path: "/article",
  ttlSeconds: 3600,
  cookieName: "article_unlock",
})

response.cookies.set({
  name: cookie.name,
  value: cookie.value,
  ...cookie.options,
})

Widget Passkey Subject Tokens

Mint a subject-identity token (nbs_...) so the widget can run durable passkey step-up. The token binds a stable, server-controlled subject to the widget's session and origin; the Notabot backend verifies it with the site signing secret. Issue it from your subject-token endpoint and return { subject_token }.

import { createWidgetSubjectToken } from "@srcabc/notabot-server"

const subject_token = createWidgetSubjectToken({
  siteKey: process.env.NOTABOT_SITE_KEY!,
  signingSecret: process.env.NOTABOT_SIGNING_SECRET!,
  subjectId,           // stable, server-controlled (e.g. a first-party cookie)
  sessionId,           // the widget's session id from the request body
  origin: req.headers.origin,
})

verifyWidgetSubjectToken checks the signature, structural claims, time window, and optional session/origin/audience/scope bindings, and never throws:

import { verifyWidgetSubjectToken } from "@srcabc/notabot-server"

const result = verifyWidgetSubjectToken({
  siteKey,
  token,
  signingSecret,
  expectedSessionId,
  expectedOrigin,
  requiredScope: "challenge",
})
if (!result.ok) {
  // result.reason: "invalid_subject_token_signature" | "subject_token_expired" | ...
}

The subject id is server-authoritative — never accept it from the client, or a caller could bind to another visitor's credentials.