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

@n8n_io/license-sdk

v4.4.0

Published

License SDK

Readme

SDK

The SDK provides a convenient way to work with license keys issued by the n8n license-server.

Usage

import {
  LicenseManager,
  TLicenseBlock,
} from '@n8n_io/license-sdk/src/LicenseManager'
import pino from 'pino'

// bring your own logger, e.g. Pino, Winston etc.
const myLogger = pino()

// ------ INITIALIZATION ------

const license = new LicenseManager({
  // `server` also selects the trusted CA: only the staging CA for license-staging.n8n.io, otherwise production.
  // No option or environment variable can supply another CA.
  server: 'https://license.your-server.com',
  tenantId: 1, // referencing to resp. license-server entity
  productIdentifier: 'Demo Product v1.2.3', // up to 255 characters; must match product.identifierPattern on activation
  autoRenewEnabled: true,
  autoRenewTimer: true, // optional, set to false to schedule `renewIfDue()` yourself instead of the built-in timer
  renewOnInit: false,
  autoRenewOffset: 60 * 60 * 48, // = 48 hours
  renewalNotFoundGracePeriodMs: 24 * 60 * 60 * 1000, // optional, defaults to 24 hours
  logger: myLogger,
  loadCertStr: async () => {
    // code that returns a stored cert string from DB
    return '...'
  },
  saveCertStr: async (cert: TLicenseBlock) => {
    // code that persists a cert string into the DB
    // ...
  },
  deviceFingerprint: () => 'a-unique-instance-id', //optional! If omitted, a machine-ID fingerprint will be generated
  installId: 'example-install-id', // optional; use a stable ID for this installation
  onFeatureChange: () =>
    console.log('availability of some features has just changed'), //optional
  onLicenseRenewed: () => console.log('license was successfully renewed'), //optional
  onExpirySoon: () => console.log('license is about to expire'), //optional
  expirySoonOffsetMins: 180, //optional
})

// important! Attempts to load and initialize the cert:
await license.initialize()

// without a valid cert, no feature will be available:
if (license.hasFeatureEnabled('a-special-feature')) {
  // this code will never execute!
}

license.isValid() // -> false

license.getFeatureValue('another-feature') // -> undefined

license.getFeatures() // -> []

// ------ ACTIVATION ------

try {
  // download a license key by 'activating' a reservation.
  // Reservations are typically configured to be activatable only once.
  await license.activate('3fa85f64-5717-4562-b3fc-2c963f66afa6')

  license.isValid() // -> true

  license.getFeatureValue('foo') // -> 'bar'

  if (license.hasFeatureEnabled('a-feature-that-exists')) {
    //do stuff
  }

  const currentConsumption = getUsageFromSomewhere()

  if (license.hasQuotaLeft('quota:demoQuota', currentConsumption)) {
    //do stuff
  }

  // print a human-readable string representation.
  console.log(`${license}`)
} catch (e) {
  // handle error...
}

// ------ RENEWAL ------
// renewals happen automatically based on the config options `autoRenewEnabled` and `autoRenewOffset`
// but can also be enforced, as long as the current cert is not yet terminated:
await license.renew()

// with `autoRenewTimer: false`, run the periodic check from your own scheduler.
// It reloads the cert if the store changed, renews only when due, and throws on failure:
await license.renewIfDue()

// when another process renewed and saved a new cert, load it without a renewal.
// It is a no-op if the store is unchanged, and throws when the store cannot be read:
await license.reloadStoredCert()

Set productIdentifier to a string of at most 255 characters. The server rejects a longer one on activation and renewal (HTTP 400).

installId accepts a string or a sync or async function that returns a string. The SDK resolves it once per initialization and sends it on activation and renewal. Use a stable ID of 1 to 128 characters (ASCII letters, digits, _, or -). If the value doesn't match or the function throws, the SDK logs a warning and leaves the ID out. The server records it for usage attribution; license binding still uses the device fingerprint.

License details

Use these methods to read license details without parsing the human-readable toString() output:

  • isEphemeral(): boolean returns the loaded certificate's isEphemeral flag. It returns false when no certificate is loaded, including before initialize(). toString() prints isEphemeral: <n/a> in that case, so code that parsed the text and treated a missing isEphemeral: false line as ephemeral will get false from this method instead.
  • getDeviceFingerprint(): string | undefined returns the fingerprint computed for this instance during initialize(), using the configured deviceFingerprint callback or the default machine ID. It returns undefined before initialize() and after reset(), and is set even without a certificate. This is the instance fingerprint, which can differ from the certificate's deviceFingerprint.

Request correlation

The SDK sends an x-request-id header on every activation and renewal request, including renewals that return floating entitlements to the pool. Each call uses a fresh UUID generated by crypto.randomUUID(). The ID is random and is not derived from the license key, instance ID, device fingerprint, or request payload.

This ID helps correlate SDK requests with license-server logs when troubleshooting. The SDK uses the response's x-request-id if present, otherwise the ID it sent. Request failures include the ID in the error message and warning log through the configured logger. Successful requests log the ID at debug level.

Renewal errors

When /renew returns NOT_FOUND, the SDK keeps the local certificate. It deletes the certificate only after renewalNotFoundGracePeriodMs (24 hours by default) of uninterrupted NOT_FOUND replies. CONSUMER_TERMINATED deletes the certificate at once.