JSPM

lycento-sdk

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 2
    • Score
      100M100P100Q37017F
    • License MIT

    Official Lycento SDK for software licensing

    Package Exports

    • lycento-sdk

    Readme

    @lycento/sdk

    npm version License: MIT

    A JavaScript/TypeScript client library for software licensing with Lycento. Works with Node.js and browsers, with full TypeScript support.

    Installation

    npm install @lycento/sdk axios
    yarn add @lycento/sdk axios
    pnpm add @lycento/sdk axios

    Quick Start

    import { createClient, LycentoError } from '@lycento/sdk';
    
    const client = createClient({
        baseUrl: 'https://api.lycento.com',
        timeout: 10000,
    });
    
    async function checkLicense() {
        try {
            const result = await client.activate({
                licenseKey: 'LYC-XXXXXXXX-XXXXXXXX',
            });
    
            console.log('License activated:', result.success);
            console.log('Expires at:', result.license.expiresAt);
        } catch (error) {
            if (error instanceof LycentoError) {
                console.error('Error:', error.message);
            }
        }
    }
    
    checkLicense();

    Features

    • License Activation & Deactivation - Activate licenses on devices and deactivate when needed
    • License Validation - Verify license validity and status
    • Device Information Management - Automatic device detection and identification
    • Automatic Device ID Generation - Deterministic device IDs from machine characteristics
    • Node.js & Browser Support - Works in both environments
    • Full TypeScript Support - Complete type definitions included

    API Reference

    LycentoClient

    The main client class for interacting with the Lycento API.

    import { LycentoClient, createClient } from '@lycento/sdk';
    
    const client = createClient({
        baseUrl: 'https://api.lycento.com',
        apiKey: 'optional-api-key',
        timeout: 10000,
    });

    Methods

    Method Description
    activate(options) Activate a license on a device
    validate(options) Validate a license
    deactivate(options) Deactivate a license on a device
    getInfo(licenseKey) Get detailed license information
    isValid(licenseKey, deviceId?) Quick boolean check if license is valid

    LycentoConfig

    Configuration options for the client.

    interface LycentoConfig {
        baseUrl: string;
        apiKey?: string;
        timeout?: number;
    }
    Property Type Required Default Description
    baseUrl string Yes - Your Lycento API URL
    apiKey string No - Optional API key for authenticated endpoints
    timeout number No 10000 Request timeout in milliseconds

    ActivateOptions

    Options for license activation.

    interface ActivateOptions {
        licenseKey: string;
        deviceId?: string;
        deviceName?: string;
        devicePlatform?: Platform;
        ipAddress?: string;
    }
    Property Type Required Description
    licenseKey string Yes The license key to activate
    deviceId string No Device ID (auto-detected if omitted)
    deviceName string No Human-readable device name (auto-detected)
    devicePlatform Platform No Platform type (auto-detected)
    ipAddress string No Optional IP address

    ValidateOptions

    Options for license validation.

    interface ValidateOptions {
        licenseKey: string;
        deviceId?: string;
    }
    Property Type Required Description
    licenseKey string Yes The license key to validate
    deviceId string No Device ID (auto-detected if omitted)

    DeactivateOptions

    Options for license deactivation.

    interface DeactivateOptions {
        licenseKey: string;
        deviceId: string;
    }
    Property Type Required Description
    licenseKey string Yes The license key
    deviceId string Yes The device ID to deactivate

    Response Types

    ActivateResponse

    interface ActivateResponse {
        success: boolean;
        license: {
            key: string;
            status: string;
            type: string;
            expiresAt: string | null;
            maxDevices: number;
        };
        activation: {
            id: number;
            deviceId: string;
            deviceName: string;
            devicePlatform: string;
            activatedAt: string;
        };
    }

    ValidateResponse

    interface ValidateResponse {
        valid: boolean;
        license: {
            key: string;
            status: string;
            type: string;
            expiresAt: string | null;
            maxDevices: number;
        };
        activation: {
            id: number;
            deviceId: string;
            deviceName: string;
            devicePlatform: string;
            lastValidatedAt: string;
        } | null;
    }

    DeactivateResponse

    interface DeactivateResponse {
        success: boolean;
        message: string;
        activation: {
            id: number;
            deviceId: string;
            deactivatedAt: string;
        };
    }

    Error Handling

    The SDK provides specific error types for different scenarios:

    import {
        LycentoError,
        ActivationError,
        ValidationError,
        DeactivationError,
        NetworkError,
    } from '@lycento/sdk';
    Error Class Description
    LycentoError Base error class for all SDK errors
    ActivationError Errors during license activation
    ValidationError Errors during license validation
    DeactivationError Errors during license deactivation
    NetworkError Network connectivity issues

    Example

    import {
        createClient,
        ActivationError,
        ValidationError,
        NetworkError,
    } from '@lycento/sdk';
    
    const client = createClient({ baseUrl: 'https://api.lycento.com' });
    
    try {
        await client.activate({ licenseKey: 'LYC-XXXX' });
    } catch (error) {
        if (error instanceof ActivationError) {
            console.error('Activation failed:', error.message);
        } else if (error instanceof NetworkError) {
            console.error('Connection failed:', error.message);
        }
    }

    TypeScript Support

    The SDK is written in TypeScript and provides full type definitions:

    import type {
        LycentoConfig,
        ActivateOptions,
        ActivateResponse,
        ValidateOptions,
        ValidateResponse,
        DeactivateOptions,
        DeactivateResponse,
        LicenseInfo,
    } from '@lycento/sdk';
    
    import {
        LycentoClient,
        createClient,
        DeviceInfo,
        Platform,
        getDeviceId,
        getDeviceInfo,
    } from '@lycento/sdk';

    Platform Type

    type Platform = 'windows' | 'macos' | 'linux' | 'android' | 'ios' | 'unknown';

    DeviceInfo Type

    interface DeviceInfo {
        deviceId: string;
        deviceName: string;
        platform: Platform;
        platformVersion: string;
        architecture: string;
    }

    Device Utilities

    import { getDeviceId, getDeviceInfo } from '@lycento/sdk';
    
    const deviceId = getDeviceId();
    const deviceInfo = await getDeviceInfo();
    
    console.log(deviceInfo.deviceId);
    console.log(deviceInfo.deviceName);
    console.log(deviceInfo.platform);

    Examples

    See examples/basic-usage.ts for comprehensive usage examples including:

    • License activation
    • License validation
    • License deactivation
    • License info retrieval
    • Error handling patterns

    License

    MIT © Lycento