@pandaauth/api
v1.0.1
Published
Panda Pelican Development LLC API Wrapper
Maintainers
Readme
@pandaauth/api
A TypeScript/JavaScript SDK for integrating PandaAuth into your applications. This package serves as an API wrapper for Panda Pelican Development's authentication and licensing system, providing a simple and type-safe way to interact with the PandaAuth services.
Table of Contents
Installation
# using npm
npm install @pandaauth/api
# using yarn
yarn add @pandaauth/api
# using pnpm
pnpm add @pandaauth/apiGetting Started
Prerequisites
Before you begin, ensure you have:
- Node.js version 12 or higher
- An API key from Panda Pelican Development
npm,yarn, orpnpmpackage manager
Authentication
- Obtain your API key from the Panda Pelican Development dashboard.
- Keep your API key secure and never expose it in client-side code.
- Use environment variables or secure configuration management for API key storage.
Basic Usage
import { PandaAuth } from "@pandaauth/api";
// Initialize client
const client = new PandaAuth({
apiKey: process.env.PANDA_AUTH_API_KEY, // Recommended: Use environment variables
});
// Example: Get revenue mode
async function getRevenueMode() {
try {
const response = await client.getRevenueMode({ service: "your-service" });
console.log(response);
} catch (error) {
console.error("Error fetching revenue mode:", error);
}
}
getRevenueMode();API Reference
PandaAuth Class
The PandaAuth class is the main entry point for interacting with the PandaAuth API.
getRevenueMode
Retrieves the revenue mode for a specific service.
- Parameters:
service(string, required): The name of the service.
- Returns:
Promise<GetRevenueModeResponse>
Example:
const response = await client.getRevenueMode({ service: "your-service" });
console.log(response);Response:
{
"revenueMode": "enabled"
}checkIdentifier
Validates an identifier against the PandaAuth system.
- Parameters:
identifier(string, required): The identifier to validate.
- Returns:
Promise<IdentifierCheckResponse>
Example:
const response = await client.checkIdentifier({
identifier: "user-identifier",
});
console.log(response);Response:
{
"message": "Identifier is valid.",
"service": "your-service"
}resetHwid
Resets the Hardware ID (HWID) for a given key.
- Parameters:
service(string, required): The service name.key(string, required): The key for which to reset the HWID.
- Returns:
Promise<ResetHwidResponse>
Example:
const response = await client.resetHwid({
service: "your-service",
key: "user-key",
});
console.log(response);Response:
{
"message": "HWID reset successfully."
}generateKeyGet
Generates a new key using the GET method.
- Parameters:
count(number, required): The number of keys to generate.isPremium(boolean, required): Whether the key is for premium access.- Other optional parameters as defined in
GenerateKeyQuery.
- Returns:
Promise<GenerateKeyGetResponse>
Example:
const response = await client.generateKeyGet({ count: 1, isPremium: true });
console.log(response);Response:
{
"message": "Keys generated successfully.",
"generatedKeys": [
{
"value": "PREMIUM-KEY-123",
"expiresAt": "2025-12-31T23:59:59.000Z",
"note": "Generated for testing",
"isPremium": true,
"expiresByDaysKey": false,
"daysKey": 0,
"noHwidValidation": false
}
]
}generateKeyPost
Generates a new key using the POST method.
- Parameters:
count(number, required): The number of keys to generate.isPremium(boolean, required): Whether the key is for premium access.- Other optional parameters as defined in
GenerateKeyQuery.
- Returns:
Promise<GenerateKeyGetResponse>
Example:
const response = await client.generateKeyPost({ count: 1, isPremium: false });
console.log(response);Response:
{
"message": "Keys generated successfully.",
"generatedKeys": [
{
"value": "STANDARD-KEY-456",
"expiresAt": "2025-12-31T23:59:59.000Z",
"note": "Generated for testing",
"isPremium": false,
"expiresByDaysKey": false,
"daysKey": 0,
"noHwidValidation": false
}
]
}fetchKey
Fetches details for a specific key.
- Parameters:
fetch(string, required): The key to fetch.
- Returns:
Promise<FetchKeyResponse>
Example:
const response = await client.fetchKey({ fetch: "user-key" });
console.log(response);Response:
{
"key": {
"id": "key-id-123",
"value": "user-key",
"note": "User's primary key",
"isPremium": true,
"expiresAt": "2025-12-31T23:59:59.000Z",
"hwid": "user-hwid-123",
"noHwidValidation": false
}
}keyEdit
Edits an existing key.
- Parameters:
keyValue(string, required): The value of the key to edit.- Other optional parameters as defined in
KeyEditBody.
- Returns:
Promise<KeyEditResponse>
Example:
const response = await client.keyEdit({
keyValue: "user-key",
note: "Updated note",
});
console.log(response);Response:
{
"message": "Key updated successfully.",
"key": {
"id": "key-id-123",
"value": "user-key",
"note": "Updated note",
"isPremium": true,
"expiresAt": "2025-12-31T23:59:59.000Z",
"hwid": "user-hwid-123",
"noHwidValidation": false
}
}keyDelete
Deletes a key.
- Parameters:
keyValue(string, required): The value of the key to delete.
- Returns:
Promise<KeyDeleteResponse>
Example:
const response = await client.keyDelete({ keyValue: "user-key" });
console.log(response);Response:
{
"message": "Key deleted successfully."
}generatedKeyEdit
Edits a generated key.
- Parameters:
keyValue(string, required): The value of the generated key to edit.
- Returns:
Promise<KeyEditResponse>
Example:
const response = await client.generatedKeyEdit({
keyValue: "generated-key-123",
note: "New note for generated key",
});
console.log(response);Response:
{
"message": "Key updated successfully.",
"key": {
"id": "gen-key-id-456",
"value": "generated-key-123",
"note": "New note for generated key",
"isPremium": false,
"expiresAt": "2025-12-31T23:59:59.000Z",
"hwid": null,
"noHwidValidation": true
}
}generatedKeyDelete
Deletes a generated key.
- Parameters:
keyValue(string, required): The value of the generated key to delete.
- Returns:
Promise<KeyDeleteResponse>
Example:
const response = await client.generatedKeyDelete({
keyValue: "generated-key-123",
});
console.log(response);Response:
{
"message": "Key deleted successfully."
}executionFetch
Fetches execution details.
- Returns:
Promise<FetchExecutionResponse>
Example:
const response = await client.executionFetch();
console.log(response);Response:
{
"executionCount": 125
}executionPush
Pushes execution data.
- Returns:
Promise<ExecutionPushResponse>
Example:
const response = await client.executionPush();
console.log(response);Response:
{
"success": true,
"message": "Execution data pushed successfully."
}V2Validation Class
The V2Validation class provides an enhanced security validation system.
validate
Validates a key using the V2 validation system.
- Parameters:
key(string, required): The key to validate.hwid(string, required): The Hardware ID to validate against.
- Returns:
Promise<V2_ValidationResponse>
Example:
const validation = new V2Validation({ service: "your-service" });
const response = await validation.validate({
key: "user-key",
hwid: "user-hwid",
});
console.log(response);Response:
{
"status": true,
"message": "Validation successful."
}TypeScript Support
This package is written in TypeScript and includes type definitions. You'll get full IntelliSense and type-checking out of the box when using TypeScript.
Error Handling
The package includes proper error handling and will throw appropriate errors for:
- Invalid API keys
- Network issues
- Invalid parameters
- Server errors
Example:
try {
const response = await client.generateKeyGet({
count: 1,
isPremium: false,
});
} catch (error) {
// Handle error appropriately
console.error(error);
}License
This project is licensed under the MIT License.
