@hyperse-hub/hps-plugin-hub-client
Vendure plugin that registers LicenseService for validating commercial / licensed npm-style packages against remote HTTP endpoints. It encrypts { licenseKey, packageName } with a shared cipherKey (same contract as @hyperse-hub/hps-plugin-hub’s POST /license/check) and tries each configured URL until one returns { valid: true } or all fail.
Pair this package with a running Hyperse Hub (@hyperse-hub/hps-plugin-hub) or any compatible license API that accepts the encrypted body and responds with { valid: boolean, message?: string }.
Requirements
- Node.js ≥ 20
- Vendure ^3.5 (plugin declares compatibility
>=3.0.0)
- Peers:
@nestjs/common, @vendure/core (see package.json)
Install
yarn add @hyperse-hub/hps-plugin-hub-client
Register in VendureConfig
cipherKey must be exactly 64 hexadecimal characters (32 bytes). It must match the key on the license server that decrypts the request (see @hyperse-hub/hps-common encrypt / decrypt).
Default merged options (before init) use licenseCheckEndpoints: ['https://oss.hyperse.net/license/check'] and an empty cipherKey; init must supply a valid key or LicenseService construction will throw.
Configuration (HpsPluginHubClient.init)
| Option | Required | Description |
|---|
cipherKey | Yes | 64-char hex string (randomBytes(32).toString('hex')). Same as Hub’s license check crypto. |
licenseCheckEndpoints | Yes* | URLs tried in order until valid: true or all fail. Default list includes Hyperse OSS endpoint; override for self-hosted Hub. |
licenseCheckRequestTimeoutMs | No | Per-request timeout (default 30000 ms). |
*If you omit licenseCheckEndpoints in init, previously merged defaults apply; pass [] only if you intentionally disable remote checks (e.g. tests).
Using LicenseService
Inject LicenseService in your plugin or service, then call checkLicenseKey(licenseKey, packageName) where packageName is the npm package name your license is bound to (e.g. @hyperse-hub/hps-plugin-storage).
checkLicenseKey returns Promise<LicenseKeyCheckResult>: { valid: boolean; message: string }. On network or parse errors it logs and returns { valid: false, message: ... }.
The client POSTs JSON { "data": "<encrypted payload>" }. Decrypted payload is JSON { "licenseKey", "packageName" }. The remote response must include a boolean valid; optional message is surfaced in logs and in LicenseKeyCheckResult.message.
See @hyperse-hub/hps-plugin-hub README section REST: POST /license/check for the full server contract.
Package exports
Public entry (@hyperse-hub/hps-plugin-hub-client) exports:
HpsPluginHubClient — Vendure plugin class; use HpsPluginHubClient.init(...).
LicenseService — Injectable service with checkLicenseKey.
- Types:
PluginInitOptions, LicenseKeyCheckResult, RemoteLicenseCheckResponse.
- Constants:
loggerCtx, PLUGIN_INIT_OPTIONS (Nest DI token for merged options).
Scripts (package)
| Script | Purpose |
|---|
yarn build | Compile dist/ |
yarn test | Unit + e2e |
yarn lint | ESLint |
@hyperse-hub/hps-plugin-hub — Server-side licenses, admin CRUD, and POST /license/check.
@hyperse-hub/hps-plugin-hub-verdaccio — Registry-side flows (see its README).