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

keynexus

v1.0.1

Published

Official JavaScript/TypeScript SDK for KeyNexus License Management System

Downloads

7

Readme

KeyNexus JavaScript/TypeScript SDK

Official JavaScript/TypeScript SDK for KeyNexus License Management System.

Works in:

  • ✅ Node.js (12+)
  • ✅ Browsers (Modern browsers with fetch API)
  • ✅ React
  • ✅ Next.js
  • ✅ Vue
  • ✅ Angular
  • ✅ Electron
  • ✅ React Native (with polyfills)

Installation

From NPM (Recommended)

npm install keynexus

or with yarn:

yarn add keynexus

or with pnpm:

pnpm add keynexus

From Source

# Clone repository
git clone https://github.com/keynexus/keynexus-js
cd keynexus-js

# Install and build
npm install
npm run build

# Use locally
npm link

Quick Start

Node.js / TypeScript

import KeyNexusClient from 'keynexus';

const client = new KeyNexusClient({
  appId: 'app_xxxxxxxxxxxx',
  secretKey: 'sk_xxxxxxxxxxxxxxxxxxxx'
});

// Validate license
const result = await client.validateLicense('XXXXX-XXXXX-XXXXX-XXXXX');

if (result.success) {
  console.log('✅ License valid!');
  console.log('Type:', result.license?.type);
  console.log('Expires:', result.license?.expiresAt);
}

Browser / JavaScript

<script type="module">
  import KeyNexusClient from 'https://cdn.jsdelivr.net/npm/keynexus@latest/dist/index.mjs';
  
  const client = new KeyNexusClient({
    appId: 'app_xxxxxxxxxxxx',
    secretKey: 'sk_xxxxxxxxxxxxxxxxxxxx'
  });
  
  const result = await client.validateLicense('XXXXX-XXXXX-XXXXX-XXXXX');
  console.log(result);
</script>

React

import { useState, useEffect } from 'react';
import KeyNexusClient from 'keynexus';

function App() {
  const [client] = useState(() => new KeyNexusClient({
    appId: 'app_xxxxxxxxxxxx',
    secretKey: 'sk_xxxxxxxxxxxxxxxxxxxx'
  }));

  const handleValidate = async (licenseKey) => {
    try {
      const result = await client.validateLicense(licenseKey);
      
      if (result.success) {
        alert('License valid!');
      }
    } catch (error) {
      alert(error.message);
    }
  };

  return (
    <div>
      <button onClick={() => handleValidate('XXXXX-XXXXX-XXXXX-XXXXX')}>
        Validate License
      </button>
    </div>
  );
}

Features

  • TypeScript Support - Full type definitions included
  • Automatic HWID Generation - Browser fingerprinting & Node.js machine ID
  • License Validation - Verify license keys with HWID binding
  • Authentication - Username/password login
  • Session Management - Get and manage active sessions
  • Error Handling - Specific error types for different scenarios
  • Zero Dependencies - Uses native fetch API
  • ESM & CJS - Works with both module systems

API Reference

Constructor

new KeyNexusClient(config: KeyNexusConfig)

Config:

  • appId (string, required) - Your application ID from KeyNexus dashboard
  • secretKey (string, required) - Your secret key
  • apiUrl (string, optional) - API base URL (default: https://keynexus.es/api)
  • autoHwid (boolean, optional) - Auto-generate HWID (default: true)

Methods

initialize(version?: string)

Initialize the application and verify it's active.

const result = await client.initialize('1.0.0');
console.log(result.success); // true

validateLicense(licenseKey: string, hwid?: string)

Validate a license key.

try {
  const result = await client.validateLicense('XXXXX-XXXXX-XXXXX-XXXXX');
  
  console.log(result.license?.type); // "lifetime" | "time-based" | "subscription"
  console.log(result.license?.expiresAt); // Date or null
  console.log(result.license?.daysLeft); // Number or null
} catch (error) {
  if (error instanceof InvalidLicenseError) {
    console.log('Invalid license key');
  } else if (error instanceof HWIDMismatchError) {
    console.log('License locked to different device');
  } else if (error instanceof ExpiredLicenseError) {
    console.log('License has expired');
  }
}

loginWithPassword(username: string, password: string, hwid?: string)

Login with username and password.

const result = await client.loginWithPassword('myusername', 'mypassword');

if (result.success) {
  console.log('Welcome', result.user?.username);
  console.log('Token:', result.token);
}

getUserInfo(token?: string)

Get information about the current user.

const userInfo = await client.getUserInfo();

console.log(userInfo.user?.email);
console.log(userInfo.user?.subscriptionExpiry);

logout()

Logout the current session.

await client.logout();
console.log('Logged out successfully');

getSessions()

Get all active sessions for the current user.

const result = await client.getSessions();

result.sessions?.forEach(session => {
  console.log('Session:', session.id);
  console.log('IP:', session.ip);
  console.log('Location:', session.location?.city, session.location?.country);
});

getHWID()

Get the current hardware ID.

const hwid = client.getHWID();
console.log('HWID:', hwid);

setHWID(hwid: string)

Set a custom hardware ID.

client.setHWID('my-custom-hwid');

Error Handling

The SDK provides specific error types:

import { 
  KeyNexusError,
  InvalidLicenseError,
  HWIDMismatchError,
  ExpiredLicenseError 
} from 'keynexus';

try {
  await client.validateLicense(key);
} catch (error) {
  if (error instanceof InvalidLicenseError) {
    // License doesn't exist or is invalid
  } else if (error instanceof HWIDMismatchError) {
    // License is locked to another device
  } else if (error instanceof ExpiredLicenseError) {
    // License has expired
  } else if (error instanceof KeyNexusError) {
    // Generic KeyNexus error
  }
}

Examples

Check License Expiration

const result = await client.validateLicense(licenseKey);

if (result.success && result.license) {
  if (result.license.type === 'lifetime') {
    console.log('✅ Lifetime license - never expires');
  } else if (result.license.daysLeft !== null) {
    if (result.license.daysLeft <= 0) {
      console.log('❌ License expired');
    } else if (result.license.daysLeft <= 7) {
      console.log(`⚠️  License expires in ${result.license.daysLeft} days`);
    } else {
      console.log(`✅ License valid for ${result.license.daysLeft} more days`);
    }
  }
}

Store Session Token

// After login
const result = await client.loginWithPassword(username, password);
if (result.token) {
  // Store in localStorage (browser)
  localStorage.setItem('keynexus_token', result.token);
  
  // Or store in secure storage (Node.js)
  // fs.writeFileSync('.token', result.token);
}

// Later, restore session
const savedToken = localStorage.getItem('keynexus_token');
if (savedToken) {
  client.setSessionToken(savedToken);
  
  // Verify it's still valid
  try {
    await client.getUserInfo();
  } catch {
    // Token expired, need to login again
    localStorage.removeItem('keynexus_token');
  }
}

React Hook Example

import { useState, useEffect } from 'react';
import KeyNexusClient from 'keynexus';

export function useKeyNexus() {
  const [client] = useState(() => new KeyNexusClient({
    appId: process.env.KEYNEXUS_APP_ID,
    secretKey: process.env.KEYNEXUS_SECRET_KEY
  }));
  
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(false);

  const validateLicense = async (key) => {
    setLoading(true);
    try {
      const result = await client.validateLicense(key);
      if (result.success) {
        const userInfo = await client.getUserInfo();
        setUser(userInfo.user);
      }
      return result;
    } finally {
      setLoading(false);
    }
  };

  const logout = async () => {
    await client.logout();
    setUser(null);
  };

  return { client, user, loading, validateLicense, logout };
}

Browser Compatibility

  • Chrome 42+
  • Firefox 39+
  • Safari 10.1+
  • Edge 14+

For older browsers, you may need to polyfill the fetch API.

Node.js Compatibility

  • Node.js 12+

For better HWID generation in Node.js, the SDK will use the os and crypto modules if available.

Documentation

Full documentation: https://keynexus.es/docs

Support

  • Email: [email protected]
  • Documentation: https://keynexus.es/docs
  • GitHub Issues: https://github.com/keynexus/keynexus-js/issues

License

MIT License - see LICENSE file for details