Skip to content

LicenseChain/LicenseChain-CPP-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LicenseChain C++ SDK

License C++ CMake

Official C++ SDK for LicenseChain - Secure license management for C++ applications.

🚀 Features

  • ðŸ”� Secure Authentication - User registration, login, and session management
  • 📜 License Management - Create, validate, update, and revoke licenses
  • 🛡ï¸� Hardware ID Validation - Prevent license sharing and unauthorized access
  • 🔔 Webhook Support - Real-time license events and notifications
  • 📊 Analytics Integration - Track license usage and performance metrics
  • âš¡ High Performance - Optimized for production workloads
  • 🔄 Async Operations - Non-blocking HTTP requests and data processing
  • 🛠ï¸� Easy Integration - Simple API with comprehensive documentation

License assertion JWT (RS256 + JWKS)

The C++ SDK exposes licensechain::LICENSE_TOKEN_USE_CLAIM in include/licensechain/license_assertion.h for claim-name parity with the Core API. Fetch GET /v1/licenses/jwks, select the JWK by JWT kid, and verify RS256 with your preferred crypto stack (OpenSSL, etc.), or delegate verification to a backend. Default API base: https://api.licensechain.app/v1.

📦 Installation

Method 1: CMake (Recommended)

# Clone the repository
git clone https://github.com/LicenseChain/LicenseChain-CPP-SDK.git
cd LicenseChain-CPP-SDK

# Create build directory
mkdir build && cd build

# Configure with CMake
cmake ..

# Build the library
make -j$(nproc)

# Install (optional)
sudo make install

Method 2: Package Manager

Add to your CMakeLists.txt:

find_package(LicenseChain REQUIRED)
target_link_libraries(your_target LicenseChain::LicenseChain)

Method 3: Manual Installation

  1. Download the latest release from GitHub Releases
  2. Extract the headers and libraries to your project
  3. Link against the LicenseChain library

🚀 Quick Start

Basic Setup

#include <licensechain/licensechain_client.h>
#include <iostream>

int main() {
    // Initialize API client
    licensechain::LicenseChainClient client(
        "your-api-key",
        "https://api.licensechain.app",
        30
    );

    // Example: health endpoint (via GetHealthCheckAsync)
    auto healthFuture = client.GetHealthCheckAsync();
    auto health = healthFuture.get();
    std::cout << "Health status request completed." << std::endl;

    return 0;
}

User Authentication

LicenseChain::UserRegistrationRequest registerRequest;
registerRequest.email = "email@example.com";
registerRequest.password = "strong-password";
registerRequest.name = "Example User";
auto user = client.RegisterUserAsync(registerRequest).get();
std::cout << "User registered: " << user.email << std::endl;

License Management

auto validation = client.ValidateLicenseAsync("LICENSE-KEY-HERE").get();
std::cout << "Valid: " << (validation.valid ? "true" : "false") << std::endl;

auto stats = client.GetAnalyticsAsync(LicenseChain::AnalyticsRequest{}).get();
std::cout << "Analytics request completed." << std::endl;

📚 API Reference

licensechain::LicenseChainClient

Constructor

licensechain::LicenseChainClient client(
    "your-api-key",
    "https://api.licensechain.app",
    30
);

Methods

User Authentication
// Register a new user
auto result = client.RegisterUserAsync(request).get();

// Get current user info
auto user = client.GetUserProfileAsync().get();
License Management
// Validate a license
auto result = client.ValidateLicenseAsync(licenseKey).get();

// Create a new license
auto result = client.CreateLicenseAsync(request).get();

// Update a license
auto result = client.UpdateLicenseAsync(licenseId, request).get();

// Revoke a license
client.RevokeLicenseAsync(licenseId).get();

// Extend a license
client.ExtendLicenseAsync(licenseId, "2027-01-01T00:00:00Z").get();
Analytics
// Get analytics data
auto result = client.GetAnalyticsAsync(request).get();

🔧 Configuration

Environment Variables

Set these in your environment or through your build process:

# Required
export LICENSECHAIN_API_KEY=your-api-key

# Optional
export LICENSECHAIN_BASE_URL=https://api.licensechain.app
export LICENSECHAIN_DEBUG=true

Advanced Configuration

licensechain::LicenseChainClient client(
    "your-api-key",
    "https://api.licensechain.app",
    30
);

🛡� Security Features

Secure Communication

  • All API requests use HTTPS
  • API keys are securely stored and transmitted
  • Webhook signatures are verified

License Validation

  • Real-time license validation
  • Expiration checking

📊 Analytics and Monitoring

Statistics

auto analytics = client.GetAnalyticsAsync(request).get();
auto usage = client.GetUsageStatsAsync(request).get();

🔄 Error Handling

Custom Error Types

try {
    auto result = client.ValidateLicenseAsync("invalid-key").get();
    (void)result;
} catch (const LicenseChain::ValidationException& e) {
    std::cerr << "Validation error: " << e.what() << std::endl;
} catch (const LicenseChain::NetworkException& e) {
    std::cerr << "Network error: " << e.what() << std::endl;
} catch (const LicenseChain::LicenseChainException& e) {
    std::cerr << "LicenseChain error: " << e.what() << std::endl;
} catch (const std::exception& e) {
    std::cerr << "Exception: " << e.what() << std::endl;
}

Retry Logic

// Configure timeout at client construction
licensechain::LicenseChainClient client(
    "your-api-key",
    "https://api.licensechain.app",
    30
);

🧪 Testing

Unit Tests

# Run tests
cd build
ctest --output-on-failure

Integration Tests

Integration tests are repository-specific and may not be present in all snapshots.

� Examples

See the examples/ directory for complete examples:

  • basic_usage.cpp - Basic SDK usage
  • advanced_features.cpp - Advanced features and configuration
  • webhook_integration.cpp - Webhook handling

� Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

  1. Clone the repository
  2. Install dependencies: sudo apt-get install libcurl4-openssl-dev
  3. Build: mkdir build && cd build && cmake .. && make
  4. Test: ctest

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

🔗 Related Projects


Made with �� for the C++ community

API Endpoints

All endpoints automatically use the /v1 prefix when connecting to https://api.licensechain.app.

Base URL

Available Endpoints

Method Endpoint Description
GET /v1/health Health check
POST /v1/auth/register User registration
GET /v1/auth/me Current authenticated user
GET /v1/apps List applications
POST /v1/apps/:id/licenses Create license for app
POST /v1/licenses/verify Verify license
PATCH /v1/licenses/:id/revoke Revoke license
PATCH /v1/licenses/:id/activate Activate license
PATCH /v1/licenses/:id/extend Extend license
GET /v1/webhooks List webhooks
POST /v1/webhooks Create webhook
GET /v1/analytics/stats Get analytics

Note: The SDK automatically prepends /v1 to all endpoints.

LicenseChain API (v1)

This SDK targets the LicenseChain HTTP API v1 implemented by the open-source API service.

  • Production base URL: https://api.licensechain.app/v1
  • API repository (source of routes & behavior): https://github.com/LicenseChain/api
  • Baseline REST mapping (documented for integrators):
    • GET /health
    • POST /auth/register
    • POST /licenses/verify
    • PATCH /licenses/:id/revoke
    • PATCH /licenses/:id/activate
    • PATCH /licenses/:id/extend
    • GET /analytics/stats

About

Official C++ SDK for LicenseChain - Secure license management for C++ applications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors