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

@meyicloud-js/license-agent-client

v1.0.2

Published

Node.js client + Express middleware/router for a local license-agent service (status, activate, license-info, enforcement)

Readme

@meyicloud-js/license-agent-client

Node.js client + Express middleware/router for a local license-agent service.

This package standardizes licensing integration across Node applications by calling a sidecar license-agent that in turn talks to the license-platform:

App (Express/Node) → license-agent → license-platform

It provides:

  • Core client (status / limits / activate / license-info)
  • assertActive() helper (throws when license is inactive)
  • Express middleware to block product APIs when unlicensed
  • Express router exposing /v1/license/* endpoints used by the activation UI
  • Built-in activation UI assets (activate.html, license-gate.js) that apps can use by default or override

Install

npm install @meyicloud-js/license-agent-client

express is a peer dependency (your app provides it).


Environment variables

| Variable | Default | Description | |--------|--------|-------------| | LICENSE_AGENT_URL | http://license-agent:8090 | Base URL of local license-agent | | LICENSE_CACHE_SECONDS | 30 | Cache TTL (seconds) for status/limits | | LICENSE_TIMEOUT_SECONDS | 2 | HTTP timeout (seconds) | | REQUIRE_LICENSE | false | Enable API blocking via middleware |


Core usage (plain Node)

ESM (.mjs / type: module)

import { getClient } from "@meyicloud-js/license-agent-client";

const client = getClient();
const st = await client.status();
console.log(st.active, st.reason);

await client.assertActive(); // throws LicenseInactiveError if inactive

CommonJS

const { getClient } = require("@meyicloud-js/license-agent-client");

(async () => {
  const client = getClient();
  const st = await client.status();
  console.log(st.active, st.reason);

  await client.assertActive();
})();

Express: block APIs when unlicensed (middleware)

This matches the behavior you used in FastAPI: fail closed.

  • Inactive/expired/deactivated → 402
  • Agent unreachable → 503 (fail-closed)

ESM default import (recommended)

import express from "express";
import licenseGateMiddleware from "@meyicloud-js/license-agent-client";

const app = express();

app.use(licenseGateMiddleware({
  exemptPrefixes: ["/ui", "/health", "/v1/license"], // allow activation UI + license APIs
}));

app.get("/health", (_req, res) => res.json({ ok: true }));
app.get("/api/secure", (_req, res) => res.json({ ok: true }));

app.listen(8080);

Named import also works

import express from "express";
import { licenseGateMiddleware } from "@meyicloud-js/license-agent-client";

const app = express();
app.use(licenseGateMiddleware());

Express: expose license APIs (activate / info / status)

Mount the router under /v1/license:

import express from "express";
import { createLicenseRouter } from "@meyicloud-js/license-agent-client";

const app = express();

app.use("/v1/license", createLicenseRouter());

app.listen(8080);

Routes exposed:

  • POST /v1/license/activate
  • GET /v1/license/info?license_key=...
  • GET /v1/license/status

Serve the built-in activation UI (optional)

This package ships default UI files:

  • ui/activate.html
  • ui/license-gate.js

Mount them with Express:

import express from "express";
import { getBuiltinUiDir } from "@meyicloud-js/license-agent-client";

const app = express();

app.use("/ui", express.static(getBuiltinUiDir()));

// In your app pages, include:
// <script src="/ui/license-gate.js"></script>

app.listen(8080);

How the UI works

  • ui/license-gate.js calls GET /v1/license/status
  • If not active, it redirects to /ui/activate.html?next=...
  • ui/activate.html uses:
    • GET /v1/license/info
    • POST /v1/license/activate
    • GET /v1/license/status

So, for UI to work you must expose the router:

app.use("/v1/license", createLicenseRouter());

Override UI logic in an application

If an application needs custom UI or redirect rules, just serve your own /ui directory instead of the built-in one:

app.use("/ui", express.static("/app/my-ui"));

Or keep the built-in UI and only override one file by serving a more specific route first.


API reference

LicenseClient methods

  • status(force?: boolean) → calls GET /local/status
  • limits(force?: boolean) → calls GET /local/limits
  • activate({license_key, product_code, fingerprint?, version?, vm_meta?})POST /local/activate
  • licenseInfo(licenseKey)GET /local/license-info?license_key=...
  • assertActive() → throws LicenseInactiveError if inactive

Express helpers

  • licenseGateMiddleware({ exemptPrefixes?, failOpen? })
  • createLicenseRouter({ client?, defaultFingerprint?, defaultVersion? })
  • getBuiltinUiDir()

Common pitfalls

“licenseGateMiddleware is not a function” in ESM

Use either:

  • default import:
    import licenseGateMiddleware from "@meyicloud-js/license-agent-client";
  • or named import:
    import { licenseGateMiddleware } from "@meyicloud-js/license-agent-client";

License

MIT