Skip to content

AuthCordDev/authcord-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AuthCord Node.js SDK

AuthCord - Sell, authenticate, and manage your software. All in one place. Replace your auth system, payment platform, and Discord bots with a single dashboard.

Official AuthCord SDK for Node.js 18+. Zero dependencies.

Installation

npm install @authcord/sdk

Usage

import { AuthCordClient } from '@authcord/sdk';

const client = new AuthCordClient('dax_your_api_key');

// Validate a user
const result = await client.validate({
  discord_id: '123456789',
  app_id: 'your_app_id',
  hwid: 'HWID-ABC',
});

if (result.valid) {
  console.log(`Welcome ${result.user?.username}!`);
  for (const product of result.products ?? []) {
    console.log(`  Product: ${product.name} (lifetime: ${product.is_lifetime})`);
  }
} else {
  console.log(`Access denied: ${result.reason}`);
}

// Session-based validation
const session = await client.createSession({
  discord_id: '123456789',
  app_id: 'your_app_id',
  hwid: 'HWID-ABC',
  device_name: 'Work PC',
});

Email-Based Validation

AuthCord supports validating users by Discord ID, user ID, or email:

// Validate by email
const result = await client.validate({
  email: 'user@example.com',
  app_id: 'your_app_id',
  hwid: 'HWID-ABC',
});

// Validate by custom user ID
const result2 = await client.validate({
  user_id: 'user123',
  app_id: 'your_app_id',
});

// Create a session with email
const session = await client.createSession({
  email: 'user@example.com',
  app_id: 'your_app_id',
  hwid: 'HWID-ABC',
});

// Get offline token with email
const token = await client.getOfflineToken(null, 'your_app_id', {
  email: 'user@example.com',
});

Error Handling

import { AuthenticationError, RateLimitError, ApiError } from '@authcord/sdk';

try {
  const result = await client.validate({ discord_id: '123', app_id: 'abc' });
} catch (err) {
  if (err instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (err instanceof RateLimitError) {
    console.log(`Rate limited. Retry after: ${err.retryAfter}s`);
  } else if (err instanceof ApiError) {
    console.log(`API error (${err.statusCode}): ${err.message}`);
  }
}

About

Official Node.js/TypeScript SDK for AuthCord. Zero dependencies, native fetch, full type definitions. Validate licenses, manage device sessions, and verify offline tokens locally with Ed25519. Built for Node 18+ with ESM support. Complete API coverage for software licensing and auth.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors