intgate
v1.0.3
Published
Node.js client library for the IntGate license verification API
Maintainers
Readme
IntGate Node.js/TypeScript Client Library
Node.js and TypeScript client library for the IntGate license verification API.
Installation
npm install intgateOr with yarn:
yarn add intgateQuick Start
TypeScript
import { IntGateClient } from 'intgate';
// Initialize the client with your team ID
const client = new IntGateClient('your-team-uuid-here');
// Verify a license
async function verifyLicense() {
try {
const result = await client.verifyLicense({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
hardwareIdentifier: 'unique-device-id',
version: '1.0.0'
});
if (result.result.valid) {
console.log('License is valid!');
console.log('License data:', result.data);
} else {
console.log('License invalid:', result.result.details);
}
} catch (error) {
console.error('Error:', error);
}
}
verifyLicense();JavaScript
const { IntGateClient } = require('intgate');
// Initialize the client with your team ID
const client = new IntGateClient('your-team-uuid-here');
// Verify a license
async function verifyLicense() {
try {
const result = await client.verifyLicense({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
hardwareIdentifier: 'unique-device-id',
version: '1.0.0'
});
if (result.result.valid) {
console.log('License is valid!');
}
} catch (error) {
console.error('Error:', error);
}
}API Reference
Initialize Client
import { IntGateClient } from 'intgate';
const client = new IntGateClient(
'your-team-uuid', // Required: Your team's UUID from IntGate dashboard
'https://license.intserver.com/api/v1' // Optional: Custom API base URL
);Note: Configure which fields are returned during license verification by navigating to: Dashboard → Team → Settings → Returned Fields (https://license.intserver.com/dashboard/team/settings?tab=security)
If no fields are configured, the
dataobject will be empty but the library will handle this gracefully.
Verify License
Validates a license key and returns license information, customer data, and product details.
const result = await client.verifyLicense({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX', // Required
customerId: 'customer-uuid', // Optional: Required if strict customers enabled
productId: 'product-uuid', // Optional: Required if strict products enabled
challenge: 'random-string', // Optional: For request signing
version: '1.0.0', // Optional: Software version (3-255 chars)
hardwareIdentifier: 'device-id', // Optional: Unique device ID (10-1000 chars)
branch: 'main' // Optional: Product branch (2-255 chars)
});License Heartbeat
Send periodic heartbeats to determine if a device is still active.
const result = await client.licenseHeartbeat({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX', // Required
hardwareIdentifier: 'device-id', // Required: Unique device ID (10-1000 chars)
customerId: 'customer-uuid', // Optional
productId: 'product-uuid', // Optional
challenge: 'random-string', // Optional
version: '1.0.0', // Optional: Software version (3-255 chars)
branch: 'main' // Optional: Product branch (2-255 chars)
});Download Release
Download an encrypted release file.
const encryptedFile = await client.downloadRelease({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX', // Required
productId: 'product-uuid', // Required
sessionKey: 'encrypted-session-key', // Required: Encrypted with team's public key
hardwareIdentifier: 'device-id', // Required: Unique device ID
version: '1.0.0', // Required: Software version
customerId: 'customer-uuid', // Optional
branch: 'main' // Optional: Product branch
});
// Save to file:
import fs from 'fs';
fs.writeFileSync('release.encrypted', encryptedFile);Automatic Heartbeat
Start automatic heartbeat in the background with event-based notifications.
import { IntGateClient } from 'intgate';
const client = new IntGateClient('your-team-uuid');
// Listen for heartbeat events
client.on('heartbeat', (result) => {
console.log(`✓ Heartbeat OK at ${result.result.timestamp}`);
console.log(` License valid: ${result.result.valid}`);
});
client.on('heartbeat-error', (error) => {
console.error('✗ Heartbeat failed:', error);
});
// Start automatic heartbeat (runs with setTimeout)
client.startAutomaticHeartbeat(
{
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
hardwareIdentifier: 'device-12345',
version: '1.0.0'
},
1800 // 30 minutes in seconds
);
console.log('Application running with automatic heartbeat...');
// Get last heartbeat result anytime
const lastResult = client.getLastHeartbeatResult();
if (lastResult?.result.valid) {
console.log('License is active');
}
// Check if heartbeat is running
if (client.isHeartbeatRunning()) {
console.log('Automatic heartbeat is active');
}
// Stop when done
client.stopAutomaticHeartbeat();Error Handling
The library provides specific exception types:
import {
IntGateClient,
IntGateAPIError,
IntGateValidationError
} from 'intgate';
const client = new IntGateClient('your-team-uuid');
try {
const result = await client.verifyLicense({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'
});
} catch (error) {
if (error instanceof IntGateValidationError) {
// Input validation failed
console.error('Validation error:', error.message);
} else if (error instanceof IntGateAPIError) {
// API request failed
console.error('API error:', error.message);
console.error('Status code:', error.statusCode);
console.error('Response data:', error.responseData);
} else {
// Other errors
console.error('Unexpected error:', error);
}
}Complete Example
import { IntGateClient, IntGateAPIError } from 'intgate';
// Initialize client
const client = new IntGateClient('your-team-uuid-here');
async function main() {
try {
// Verify license on startup
console.log('Verifying license...');
const result = await client.verifyLicense({
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
hardwareIdentifier: 'my-device-12345',
version: '1.0.0',
productId: 'your-product-uuid'
});
if (!result.result.valid) {
console.error('License validation failed:', result.result.details);
process.exit(1);
}
console.log('License verified successfully!');
console.log('Expires:', result.data.license.expirationDate || 'Never');
// Setup automatic heartbeat with event listeners
console.log('\nStarting automatic heartbeat...');
client.on('heartbeat', (result) => {
console.log('Heartbeat successful');
});
client.on('heartbeat-error', (error) => {
console.error('Heartbeat failed:', error);
});
client.startAutomaticHeartbeat(
{
licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
hardwareIdentifier: 'my-device-12345',
version: '1.0.0'
},
1800 // Every 30 minutes in seconds
);
console.log('Application running...');
} catch (error) {
if (error instanceof IntGateAPIError) {
console.error('API Error:', error.message);
if (error.statusCode === 404) {
console.error('License not found');
} else if (error.statusCode === 401) {
console.error('Unauthorized - check your team ID');
}
process.exit(1);
}
throw error;
}
}
main();TypeScript Support
This library is written in TypeScript and includes full type definitions:
import {
IntGateClient,
VerifyLicenseOptions,
VerifyLicenseResponse,
LicenseHeartbeatOptions,
HeartbeatResponse,
DownloadReleaseOptions,
License,
Customer,
Product,
VerificationResult
} from 'intgate';Build from Source
# Install dependencies
npm install
# Build TypeScript to JavaScript
npm run build
# The built files will be in the dist/ directoryLicense
MIT License
Support
For API documentation, visit: https://license.intserver.com
For examples, see: AUTOMATIC_HEARTBEAT.md
