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

@permitplane/backend

v0.1.0

Published

Server-side helpers for PermitPlane vendor backends (integration/v1).

Readme

@permitplane/backend (Node)

Server-side helpers for PermitPlane vendor backends: a typed client for the /integration/v1 backend routes, typed errors, safe retries and webhook signature verification. TypeScript, ESM only, zero runtime dependencies (global fetch, node:crypto). Node >= 22.

Install

npm install @permitplane/backend

Licensed under Apache-2.0. Homepage: https://permitplane.com

Use

import { PermitPlaneBackend, deriveIdempotencyKey } from "@permitplane/backend";

const pp = new PermitPlaneBackend({
  baseUrl: "https://licensing.example.com", // https only; a path prefix is allowed
  token: process.env.PERMITPLANE_BACKEND_TOKEN!, // VendorBackend bearer secret
});

// resolve -> read the enrollment -> authorize
const { customer_id } = await pp.resolveCustomer({
  product_id, namespace_id, external_subject: user.id, verification_reference: "myapp-verified:" + user.id,
});
const enrollment = await pp.getEnrollment(enrollmentId);
await pp.authorizeEnrollment(enrollmentId, {
  customer_id, mode: "trial", verification_reference: "myapp-verified:" + user.id,
  expected_revision: enrollment.revision,
});

// issue a licence; derive the key from your own order so a restarted worker replays
await pp.issueLicense(
  { product_id, namespace_id, customer_id, policy_id, paid_through: new Date("2027-01-01T00:00:00Z"), reason: "Order ord_123" },
  { idempotencyKey: deriveIdempotencyKey("order", "ord_123", "issue") },
);

Wire objects stay snake_case. Also available: denyEnrollment, listPolicies, getLicense, actOnLicense, deliverLicenseKey, revokeLicenseKey, issueLicenseFile.

Offline (air-gapped) installs: issueLicenseFile signs a licence file (scope license_files.issue). valid_days (1 to 21) and installation_key_thumbprint (43 base64url characters, binds the file to one installation) are optional. Write license_file to disk exactly as returned.

const issued = await pp.issueLicenseFile(licenseId, {
  product_id, customer_id, valid_days: 7, installation_key_thumbprint: thumbprint,
});
await writeFile(issued.filename, issued.license_file, "utf8");

Self-hosting behind a sub-path works: baseUrl: "https://host/licensing" (a trailing slash is normalised; backslashes, % escapes and dot segments are rejected). Plain http is accepted only for 127.0.0.1, localhost and [::1] and only with allowInsecureHttp: true.

Errors

Everything extends PermitPlaneError. Server errors are ApiError subclasses carrying status, code, requestId, details, retryAfterSeconds, idempotencyKey, method and path.

try {
  await pp.authorizeEnrollment(id, input);
} catch (err) {
  if (err instanceof RevisionConflictError) { /* reload the enrollment and retry */ }
  else if (err instanceof IdempotencyConflictError) { /* same key, different body: a bug */ }
  else throw err;
}

The server's text is in err.serverMessage; err.message is <code> (HTTP <status>, request <id>). Error objects never contain the token, request bodies or response bodies.

Idempotency and retries

Keyed operations (resolve, authorize, deny, issue, act) always send an Idempotency-Key: yours via { idempotencyKey }, or a generated one reused for every automatic retry and exposed as err.idempotencyKey. The server keeps receipts for 24 hours for resolve/authorize/deny and permanently for issue/act. A changed body with the same key gives IdempotencyConflictError.

Automatic retries (default 2, so at most 3 attempts; timeoutMs 15000 per attempt; maxRetryDelayMs 5000; timeouts and delays must be positive and finite, retries an integer from 0 to 10, else ConfigurationError or, per call, RequestValidationError) apply to GETs and keyed POSTs on transport errors, timeouts, 502, 503, 504, 429 and 409 operation_in_progress. deliverLicenseKey, revokeLicenseKey and issueLicenseFile are never retried automatically; repeating them yourself is safe (a repeated issueLicenseFile signs and records a new file).

The server currently sends Retry-After: 60 on every 429 and 503. That is above maxRetryDelayMs, so those surface immediately as RateLimitedError or ServiceUnavailableError with retryAfterSeconds = 60. Do not block a request handler for a minute; queue the work and retry later.

Security

  • The token is server-only. Never ship it to apps or browsers.
  • Redirects are refused (UnexpectedResponseError); the token is never forwarded elsewhere.
  • deliverLicenseKey responses contain a secret licence key. Do not log them.

Webhooks

Header PermitPlane-Signature: t=<unix seconds>,v1=<sig>[,v1=<sig>], where sig is the lowercase hex HMAC-SHA256 of "<t>." + raw body keyed with the UTF-8 bytes of the full secret (ppwhsec_...). Tolerance is 300 seconds (inclusive), uppercase hex is tolerated, and any matching v1 is accepted, so you can pass old and new secrets together.

app.post("/webhooks/permitplane", express.raw({ type: "application/json" }), (req, res) => {
  const event = parseWebhookEvent({
    payload: req.body, // the RAW body, never re-serialized JSON
    header: req.get(WEBHOOK_SIGNATURE_HEADER),
    secrets: [process.env.PP_WEBHOOK_SECRET!],
  });
  // dedupe on the event id, then call getLicense for the authoritative state
  res.sendStatus(204);
});

Do not rely on arrival order; fetch the current state with getLicense.

Development

npm ci --include=dev   # NODE_ENV=production would skip dev dependencies
npm test && npm pack --dry-run