Skip to content

Node.js SDK

Official Node.js SDK for SSH-KLM.

Terminal window
npm install @qcecuring/ssh-sdk
# or
yarn add @qcecuring/ssh-sdk
  • Node.js 18.x or later
  • TypeScript 5.x (optional, types included)
import { QcClient } from '@qcecuring/ssh-sdk';
const client = new QcClient({
apiKey: process.env.SSHKLM_API_KEY,
baseUrl: 'https://api.qcecuring.com' // Optional
});
// List hosts
const hosts = await client.ssh.listHosts();
console.log(hosts);
const client = new QcClient({
apiKey: 'sk_live_...',
baseUrl: 'https://api.qcecuring.com',
timeout: 30000, // 30 seconds
retries: 3,
debug: false
});

Full TypeScript support with type definitions:

import { QcClient, Host, SshKey, RotationPolicy } from '@qcecuring/ssh-sdk';
const client = new QcClient({ apiKey: process.env.API_KEY! });
const hosts: Host[] = await client.ssh.listHosts();
const keys: SshKey[] = await client.ssh.listKeys({ hostId: hosts[0].id });
// Start discovery
const scan = await client.ssh.startDiscovery({
hosts: ['*.example.com']
});
// Wait for completion
const result = await client.ssh.waitForScan(scan.id, {
timeout: 300000,
pollInterval: 5000
});
// Rotate key
await client.ssh.rotateKey({
keyId: 'key_123',
algorithm: 'ed25519'
});
const creds = await client.ssh.requestEphemeral({
host: 'server.example.com',
username: 'admin',
ttl: 300
});
// Use credentials
console.log(creds.privateKey);
import { QcClient, QcError, RateLimitError } from '@qcecuring/ssh-sdk';
try {
await client.ssh.rotateKey({ keyId: 'invalid' });
} catch (error) {
if (error instanceof RateLimitError) {
await sleep(error.retryAfter);
// Retry...
} else if (error instanceof QcError) {
console.error(`Error: ${error.code} - ${error.message}`);
}
}