@eventcatalog/license

中文文档
0.0.9发布于 2026/09/30MITTypeScriptES Module近 30 天下载 9.2万

License verification for EventCatalog

原始使用文档
文档目录24 节
  1. Features
  2. Installation
  3. Quick Start
  4. Offline JWT Verification
  5. Online License Key Verification
  6. EventCatalog Enterprise
  7. API Reference
  8. verifyOfflineLicense(opts?: VerifyOptions): Promise<Entitle…
  9. verifyOnlineLicense(key: string, plugin: string): Promise<b…
  10. isEventCatalogEnterpriseEnabled(): Promise<boolean>
  11. hasCommercialLicense(): Promise<boolean>
  12. isFeatureEnabled(name: string): boolean
  13. getEntitlements(): Entitlements | null
  14. License Discovery
  15. Environment Variables
  16. EC_LICENSE
  17. EC_PUBLIC_KEY_PATH
  18. License Format
  19. Offline License Errors
  20. Online License Errors
  21. Building
  22. Development
  23. Testing License Verification
  24. License

@eventcatalog/license

License verification library for EventCatalog supporting both offline JWT verification and online license key validation.

Features

  • Dual verification modes - Offline JWT tokens and online license keys
  • Ed25519 signatures - Using industry-standard elliptic curve cryptography for offline verification
  • JWT-based offline licensing - Standard token format with custom EventCatalog claims
  • Online license key validation - Real-time verification with EventCatalog API
  • Input validation - Secure license key format validation
  • Caching - Verification results cached for performance
  • Machine binding - Optional fingerprint-based license binding (offline mode)
  • Enhanced error handling - Structured error codes for different failure scenarios
  • TypeScript - Full type safety and IntelliSense support

Installation

npm install @eventcatalog/license

Quick Start

Offline JWT Verification

import { verifyOfflineLicense, isFeatureEnabled } from '@eventcatalog/license';

// Verify offline JWT license (auto-locates license file)
try {
  const entitlements = await verifyOfflineLicense();
  console.log('License valid for:', entitlements.org);
} catch (error) {
  console.error('License verification failed:', error.message);
}

// Check if a plugin is enabled
if (isFeatureEnabled('@eventcatalog/generator-asyncapi')) {
  console.log('AsyncAPI generator is licensed');
}

Online License Key Verification

import { verifyOnlineLicense } from '@eventcatalog/license';

// Verify online license key
try {
  const isValid = await verifyOnlineLicense('XXXX-XXXX-XXXX-XXXX-XXXX-XXXX', '@eventcatalog/eventcatalog-scale');
  if (isValid) {
    console.log('License key is valid');
  }
} catch (error) {
  console.error('License key verification failed:', error.message);
}

EventCatalog Enterprise

EventCatalog Enterprise licenses are offline-only. Add @eventcatalog/eventcatalog-enterprise to the JWT license's plugins claim, then use the plan helper:

import { isEventCatalogEnterpriseEnabled } from '@eventcatalog/license';

if (await isEventCatalogEnterpriseEnabled()) {
  console.log('EventCatalog Enterprise is licensed');
}

The helper uses the standard offline license discovery flow and returns false when no offline license is present. It does not use an online license key.

API Reference

verifyOfflineLicense(opts?: VerifyOptions): Promise<Entitlements>

Verifies an offline JWT license and returns entitlements. Results are cached after first successful verification.

Options:

  • licensePath?: string - Custom path to license file (overrides auto-discovery)
  • audience?: string - Expected JWT audience (default: "EventCatalog")
  • issuer?: string - Expected JWT issuer (default: "EventCatalog Ltd")
  • clockTolerance?: string - Clock skew tolerance (default: "12h")
  • currentVersion?: string - EventCatalog version for range validation
  • fingerprintProvider?: () => string | null - Machine fingerprint provider

Example with options:

const entitlements = await verifyOfflineLicense({
  licensePath: '/custom/path/license.jwt',
  audience: 'MyEventCatalog',
  clockTolerance: '24h',
  fingerprintProvider: () => getMachineId(),
});

verifyOnlineLicense(key: string, plugin: string): Promise<boolean>

Verifies a license key online using the EventCatalog API. EventCatalog Enterprise is not supported by this function because it is an offline-only plan.

Parameters:

  • key: string - License key in format XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
  • plugin: string - Plugin identifier to verify against

Supported plugins:

  • @eventcatalog/eventcatalog-starter
  • @eventcatalog/eventcatalog-scale

Example:

const isValid = await verifyOnlineLicense('XXXX-XXXX-XXXX-XXXX-XXXX-XXXX', '@eventcatalog/eventcatalog-scale');

isEventCatalogEnterpriseEnabled(): Promise<boolean>

Verifies the discovered offline JWT and checks for the @eventcatalog/eventcatalog-enterprise entitlement. Returns false without making a network request when no offline license is present.

const isEnterpriseEnabled = await isEventCatalogEnterpriseEnabled();

hasCommercialLicense(): Promise<boolean>

Verifies the discovered offline JWT (signature, issuer, audience, nbf/exp) and returns true only if it has an exp claim that has not passed. Unlike verifyOfflineLicense, the expiry check applies no clock tolerance. Returns false instead of throwing when no license file is found or verification fails.

if (await hasCommercialLicense()) {
  console.log('Commercial license is active');
}

isFeatureEnabled(name: string): boolean

Checks if a plugin or feature is enabled in the current license.

// Check string plugin names
if (isFeatureEnabled('@eventcatalog/generator-openapi')) {
  // Enable OpenAPI generator
}

// Also works with object-style plugin specs in license

getEntitlements(): Entitlements | null

Returns currently cached entitlements without re-verification.

const entitlements = getEntitlements();
if (entitlements?.org) {
  console.log(`License for: ${entitlements.org}`);
}

License Discovery

License files are located in this order:

  1. EC_LICENSE environment variable (file path)
  2. ./license.jwt (current directory)
  3. /etc/eventcatalog/license.jwt (system-wide)

Environment Variables

EC_LICENSE

Path to license file (overrides auto-discovery).

export EC_LICENSE="/path/to/my/license.jwt"

EC_PUBLIC_KEY_PATH

Path to custom public key PEM file (overrides bundled key).

export EC_PUBLIC_KEY_PATH="/path/to/custom/public.pem"

License Format

Licenses are JWT tokens with standard and EventCatalog-specific claims:

Standard Claims:

  • iss - Issuer ("EventCatalog Ltd")
  • aud - Audience ("EventCatalog")
  • iat - Issued at timestamp
  • nbf - Not before timestamp
  • exp - Expiration timestamp

EventCatalog Claims:

  • licenseId - Unique license identifier
  • org - Organization name
  • plugins - Enabled plugins array
  • fingerprint - Machine binding fingerprint (optional)

Example payload:

{
  "iss": "EventCatalog Ltd",
  "aud": "EventCatalog",
  "iat": 1672531200,
  "nbf": 1672531200,
  "exp": 1735689600,
  "licenseId": "ec_2025_000001",
  "org": "Acme Corp",
  "plugins": [
    "@eventcatalog/generator-asyncapi",
    {
      "name": "@eventcatalog/generator-openapi",
      "versionRange": "^1.0.0"
    }
  ]
}

Offline License Errors

Error CodeMessageDescription
LICENSE_EXPIREDLicense has expiredJWT token past expiration time
LICENSE_NOT_YET_VALIDLicense is not yet validJWT token not yet active
LICENSE_VALIDATION_FAILEDLicense validation failed - invalid issuer or audienceJWT claims validation failed
LICENSE_SIGNATURE_INVALIDLicense signature verification failed - invalid or tampered licenseDigital signature verification failed
LICENSE_FILE_NOT_FOUNDLicense file not foundNo license file found in discovery locations
LICENSE_FILE_EMPTYLicense file is emptyLicense file exists but contains no content
LICENSE_FINGERPRINT_MISMATCHLicense fingerprint mismatch - license is bound to a different machineMachine binding violation

Online License Errors

Error CodeMessageDescription
INVALID_LICENSE_KEY_FORMATInvalid license key format. Expected format: XXXX-XXXX-XXXX-XXXX-XXXX-XXXXLicense key doesn't match required format

Building

# Install dependencies
npm install

# Build TypeScript
npm run build

# The compiled package will be in ./dist/

Development

The package structure:

eventcatalog-license/
├── src/
│   ├── index.ts      # Public API exports
│   ├── types.ts      # TypeScript type definitions
│   ├── key.ts        # Public key loading & validation
│   └── verify.ts     # Verification logic (offline & online)
├── assets/
│   └── ec-ed25519-public.pem  # Public key for offline verification
└── dist/             # Compiled output

Testing License Verification

Offline JWT Testing

  1. Create a test license file:

    echo "your.jwt.token.here" > license.jwt
    
  2. Test programmatically:

    import { verifyOfflineLicense } from '@eventcatalog/license';
    
    try {
      const entitlements = await verifyOfflineLicense();
      console.log('✓ Valid license:', entitlements);
    } catch (error) {
      console.error('✗ Invalid license:', error.message);
    }
    

Online License Key Testing

import { verifyOnlineLicense } from '@eventcatalog/license';

try {
  const isValid = await verifyOnlineLicense('XXXX-XXXX-XXXX-XXXX-XXXX-XXXX', '@eventcatalog/eventcatalog-scale');
  console.log('✓ License key valid:', isValid);
} catch (error) {
  console.error('✗ License key invalid:', error.message);
}

License

MIT

版本与发布记录

@eventcatalog/license 共发布 9 个版本,首次发布于 2025/09/04;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.0.9latest2026/09/301 个月前
0.0.82026/08/242 个月前
0.0.72025/10/221.1 年前
0.0.62025/09/041.2 年前
0.0.52025/09/041.2 年前
0.0.42025/09/041.2 年前

关于 @eventcatalog/license 的常见问题

@eventcatalog/license 是什么?

License verification for EventCatalog

如何安装 @eventcatalog/license?

在项目目录运行 npm install @eventcatalog/license,或使用 pnpm add / yarn add / bun add。

@eventcatalog/license 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@eventcatalog/license 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@eventcatalog/license 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@eventcatalog/license 可以商用吗?

@eventcatalog/license 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eventcatalog/license 的下载量有多少?

根据 npm 官方下载统计,@eventcatalog/license 在 2026/10/14 – 2026/11/12 这 30 天内被下载 92,473 次,日均约 3,082 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eventcatalog/license 还在维护吗?

最新版本 0.0.9 发布于 2026/09/30(1 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 2 个;首次发布于 2025/09/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。