PelindaJS

A JavaScript client library for interacting with the Panda Development API service.

PelindaJS provides a simple and efficient way to manage license keys, validate users, and track executions for your software applications. Created by @spxnso on discord.

Installation

npm install pelindajs

Usage

First, import the PelindaJS class and create a new instance with your API key:

import { PelindaJS } from "pelindajs";

async function main() {
  try {
    const pelinda = await PelindaJS.new("your-api-key-here");
    // Now you can use the pelinda instance
    console.log("PelindaJS initialized successfully!");
  } catch (error) {
    console.error("Failed to initialize PelindaJS:", error.message);
  }
}

main();

API Reference

Initialization

Creates a new PelindaJS instance with the provided API key. This method validates the API key before creating the instance.

Signature:

const pelinda = await PelindaJS.new(apiKey);

Parameters:

  • apiKey (string, required): Your Panda Development API key.

Example:

import { PelindaJS } from "pelindajs";

async function init() {
  try {
    const pelinda = await PelindaJS.new("your-api-key");
    console.log("PelindaJS initialized successfully");
  } catch (error) {
    console.error("Failed to initialize:", error.message);
  }
}

init();

Get Execution Count

Retrieves the current execution count associated with your API key.

Signature:

const result = await pelinda.getExecutionCount();

Example:

async function checkExecutionCount() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.getExecutionCount();

  if (result.success) {
    console.log(`Current execution count: ${result.executionCount}`);
  } else {
    console.error(`Failed to get execution count: ${result.message}`);
  }
}

Increment Execution Count

Increments the execution count associated with your API key.

Signature:

const result = await pelinda.incrementExecutionCount();

Example:

async function incrementCount() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.incrementExecutionCount();

  if (result.success) {
    console.log(result.message); // e.g., "Execution count incremented successfully."
  } else {
    console.error(`Failed to increment execution count: ${result.message}`);
  }
}

Generate Key

Generates new license keys with the specified parameters.

Signature:

const result = await pelinda.generateKey({ /* options */ });

Parameters (object):

Parameter
Type
Required?
Description

expire

string

Yes

Expiration date in YYYY-MM-DD format.

note

string

No

An optional note to attach to the key.

count

number

Yes

Number of keys to generate.

isPremium

boolean

Yes

Whether the key is for premium features.

expiresByDaysKey

boolean

No (defaults to false)

Whether the key expires by days.

daysKeys

number

Yes (if expiresByDaysKey is true)

Number of days before expiration.

Example:

async function generateLicenseKeys() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.generateKey({
    expire: "2025-12-31",
    note: "Test license keys",
    count: 5,
    isPremium: true,
    expiresByDaysKey: true,
    daysKeys: 30, // Corrected from daysKey to daysKeys based on npm docs
  });

  if (result.success) {
    console.log(`Generated keys:`, result.generatedKeys);
    // Example: console.log(`First generated key: ${result.generatedKeys[0].value}`);
  } else {
    console.error(`Failed to generate keys: ${result.message}`);
  }
}

Note: The npm documentation had a typo daysKey in the parameter description, but daysKeys in the example. I've used daysKeys based on the example, please verify the correct parameter name.


Delete Key

Deletes an activated key from the system.

Signature:

const result = await pelinda.deleteKey({ keyValue });

Parameters (object):

  • keyValue (string, required): The license key value to delete.

Example:

async function deleteUserKey() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.deleteKey({
    keyValue: "user-key-to-delete",
  });

  if (result.success) {
    console.log(`Key deleted: ${result.deletedKey}`); // or use result.message
  } else {
    console.error(`Failed to delete key: ${result.message}`);
  }
}

Check Identifier

Checks if an identifier exists in the system and returns service information.

Signature:

const result = await pelinda.checkIdentifier(identifier);

Parameters:

  • identifier (string, required): The identifier to check.

Example:

async function checkUserIdentifier() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.checkIdentifier("identifier-123");

  if (result.success) {
    console.log(`Identifier status: ${result.message}`);
    console.log(`Service: ${result.service}`);
  } else {
    console.error(`Failed to check identifier: ${result.message}`);
  }
}

Extend Key Expiration

Extends the expiration date of a key by a specified number of days. (Note: expendKeyExpiration from npm docs, likely meant extendKeyExpiration).

Signature:

const result = await pelinda.expendKeyExpiration({ keyValue, days });

Parameters (object):

  • keyValue (string, required): The license key value to extend.

  • days (number, required): The number of days to extend the expiration by.

Example:

async function extendKeyValidity() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.expendKeyExpiration({ // Using 'expend' as per npm doc
    keyValue: "user-key-to-extend",
    days: 60,
  });

  if (result.success) {
    console.log(`Key extended: ${result.message}`);
    console.log(`Updated key info:`, result.key);
  } else {
    console.error(`Failed to extend key: ${result.message}`);
  }
}

Fetch Key

Searches for and retrieves information about a specific key.

Signature:

const result = await pelinda.fetchKey(searchTerm);

Parameters:

  • searchTerm (string, required): The key value or other term to search for the key.

Example:

async function lookupKey() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.fetchKey("user-key-to-fetch");

  if (result.success) {
    console.log(`Key details:`, result.key); // The npm docs say result.key, but example says result.result.key
                                          // Assuming result.key is directly available
  } else {
    console.error(`Failed to fetch key: ${result.message}`);
  }
}

Delete Keyless

Deletes a keyless authentication entry by hardware ID (HWID).

Signature:

const result = await pelinda.deleteKeyless({ hwid });

Parameters (object):

  • hwid (string, required): The hardware ID associated with the keyless entry to delete.

Example:

async function removeKeylessAuth() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.deleteKeyless({
    hwid: "user-hardware-id",
  });

  if (result.success) {
    console.log(result.message); // e.g., "Keyless entry deleted successfully."
  } else {
    console.error(`Failed to delete keyless entry: ${result.message}`);
  }
}

Fetch Generated Key

Searches for and retrieves information about a specific generated key (likely before activation/use).

Signature:

const result = await pelinda.fetchGeneratedKey(searchTerm);

Parameters:

  • searchTerm (string, required): The key value or other term to search for the generated key.

Example:

async function findGeneratedKey() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.fetchGeneratedKey("generated-key-value");

  if (result.success) {
    console.log(`Generated key details:`, result.generatedKey);
  } else {
    console.error(`Failed to fetch generated key: ${result.message}`);
  }
}

Validate Key

Validates a license key against the service, optionally with a hardware ID (HWID).

Signature:

const result = await pelinda.validateKey({ options }, keylessEnabled);

Parameters:

  1. options (object, required):

    • keyValue (string, required): The license key to validate.

    • service (string, required): The name of your service this key is for.

    • hwid (string, optional): The hardware ID of the user. If not provided, PelindaJS might attempt to use a system-derived HWID (behavior depends on the library's internal implementation or the API).

  2. keylessEnabled (boolean, optional, defaults to false): Whether keyless authentication is enabled for this validation attempt.

Example:

async function validateUserKey() {
  // Assuming pelinda is already initialized
  // const pelinda = await PelindaJS.new("your-api-key");
  const result = await pelinda.validateKey(
    {
      service: "your-service-name",
      keyValue: "user-key-to-validate",
      hwid: "user-specific-hwid", // This is good practice to provide
    }
    // keylessEnabled defaults to false if not provided
  );

  if (result.success) {
    console.log(`Validation successful. Result:`, result.result);
    // Access specific parts of the result, e.g.,
    // console.log(`Authentication status: ${result.result.V2_Authentication}`);
  } else {
    console.error(`Failed to validate key: ${result.message}`);
  }
}

Examples

Complete Example - Key Management Workflow

import { PelindaJS } from "pelindajs";

async function licenseManagementDemo() {
  try {
    // Initialize PelindaJS
    const pelinda = await PelindaJS.new("YOUR_API_KEY_HERE");
    console.log("PelindaJS Initialized.");

    // Generate new license keys
    const genResult = await pelinda.generateKey({
      expire: "2025-06-30",
      note: "Demo keys",
      count: 2,
      isPremium: true,
      // Not specifying expiresByDaysKey or daysKeys, so it uses the 'expire' date.
    });

    if (genResult.success && genResult.generatedKeys && genResult.generatedKeys.length > 0) {
      console.log(`Generated keys. First key: ${genResult.generatedKeys[0].value}`);

      // Validate one of the generated keys
      const keyToValidate = genResult.generatedKeys[0]; // This is an object with 'value', 'note', etc.
      const validateResult = await pelinda.validateKey({
        keyValue: keyToValidate.value,
        service: "YOUR_SERVICE_NAME", // Replace with your actual service name
        // hwid: "optional-demo-hwid" // Optionally provide a HWID
      });

      if (validateResult.success) {
        console.log(`Key validation successful for ${keyToValidate.value}.`);
        console.log("Validation Details:", validateResult.result);

        // Extend the key's expiration
        const extendResult = await pelinda.expendKeyExpiration({ // Using 'expend' as per docs
          keyValue: keyToValidate.value,
          days: 30,
        });

        if (extendResult.success) {
          console.log(`Key expiration extended by 30 days for ${keyToValidate.value}.`);
          console.log("Extended Key Info:", extendResult.key);

          // Fetch the updated key information
          const fetchResult = await pelinda.fetchKey(keyToValidate.value);
          if (fetchResult.success) {
            console.log(`Fetched updated key information:`, fetchResult.key); // Assuming .key from npm docs
          } else {
            console.error(`Failed to fetch updated key: ${fetchResult.message}`);
          }
        } else {
          console.error(`Failed to extend key expiration: ${extendResult.message}`);
        }
      } else {
        console.error(`Key validation failed for ${keyToValidate.value}: ${validateResult.message}`);
      }
    } else {
      console.error(`Failed to generate keys: ${genResult.message}`);
    }

    // Check the execution count
    const countResult = await pelinda.getExecutionCount();
    if (countResult.success) {
      console.log(`Current execution count: ${countResult.executionCount}`);

      // Increment the execution count
      const incrementResult = await pelinda.incrementExecutionCount();
      if (incrementResult.success) {
        console.log(`Execution count incremented: ${incrementResult.message}`);
        // Check count again
        const newCountResult = await pelinda.getExecutionCount();
        if (newCountResult.success) {
           console.log(`New execution count: ${newCountResult.executionCount}`);
        }
      } else {
        console.error(`Failed to increment execution count: ${incrementResult.message}`);
      }
    } else {
      console.error(`Failed to get execution count: ${countResult.message}`);
    }

  } catch (error) {
    console.error(`Demo failed: ${error.message}`);
  }
}

licenseManagementDemo();

Error Handling

Standard Response Object

All methods in PelindaJS return a promise that resolves to a standard response object with the following structure:

{
  "success": true, // or false
  "message": "Descriptive message about the operation outcome.",
  // Additional properties specific to the method, e.g.:
  // "executionCount": 123, (for getExecutionCount)
  // "generatedKeys": [ ... ], (for generateKey)
  // "key": { ... }, (for fetchKey, expendKeyExpiration)
  // "result": { ... } (for validateKey)
}

When a request fails (e.g., API error, validation error, network issue), the success property will be false, and the message property will contain details about the error. Always check the success property before attempting to use other data in the response.

License

MIT License

Package: https://www.npmjs.com/package/pelindajs

Source: https://github.com/spxnso/pelindajs

Last updated