@astermind/astermind-premium
Version:
Astermind Premium - Premium ML Toolkit
89 lines • 4.1 kB
TypeScript
/**
* License management for Astermind Premium
* Wraps @astermindai/license-runtime with convenience functions
* Also propagates license to Astermind Pro and Astermind Synth for unified licensing
*
* SECURITY FEATURES:
* - Cryptographic JWT signature validation using JWKS from license server
* - Token format validation (JWT structure, required claims)
* - Issuer validation (must match https://license.astermind.ai)
* - Expiration checking
* - Fake token rejection (invalid signatures are rejected even if payload looks valid)
* - Multiple validation layers to prevent bypass attempts
*
* The license-runtime library validates tokens using ES256 signatures and public keys
* fetched from the license server's JWKS endpoint. Fake tokens cannot bypass this validation.
*/
import { type LicenseState } from '@astermindai/license-runtime';
/**
* Initialize the license runtime singleton for Astermind Premium.
* Must be called before any other license functions.
* Automatically loads token from ASTERMIND_LICENSE_TOKEN environment variable if present.
*
* This initializes the license runtime for:
* - astermind-premium (primary)
* - astermind-pro (fallback)
* - astermind-elm (fallback)
* - astermind-synth (propagated automatically)
*
* PROFESSIONAL LICENSING APPROACH:
* - Always requires a valid license key (strict mode)
* - Trial keys are obtained from the license server and have expiration dates
* - No "eval mode" bypass - all usage requires a valid key
* - For testing, use a test/dev key or mock the license runtime
*/
export declare function initializeLicense(): void;
/**
* Require a valid license (throws if not available).
* Accepts astermind-premium, astermind-pro, and astermind-elm licenses.
* Use this before accessing premium features.
*
* SECURITY: This function performs multiple validation checks to prevent bypass attempts.
* Do not modify or wrap this function in a way that suppresses errors.
*/
export declare function requireLicense(): void;
/**
* Check if license is valid and astermind-premium feature is available (non-blocking).
* Also accepts astermind-pro and astermind-elm licenses as valid for Premium.
* @returns true if astermind-premium, astermind-pro, or astermind-elm feature is available
*/
export declare function checkLicense(): boolean;
/**
* Check if astermind-synth feature is available (included with Premium subscription).
* @returns true if astermind-synth feature is available
*/
export declare function checkSynthLicense(): boolean;
/**
* Get detailed license status.
* If token has audience "astermind-pro" or "astermind-elm", we'll check if it has valid features
* even if the runtime marks it as invalid due to audience mismatch.
* @returns LicenseState object with status, reason, payload, etc.
*/
export declare function getLicenseStatus(): LicenseState;
/**
* Set license token from a string.
* This will propagate the license to astermind-pro and astermind-synth.
* Accepts tokens with audience "astermind-premium", "astermind-pro", or "astermind-elm".
*
* SECURITY: This function validates the JWT token cryptographically using the license server's
* public keys. Fake tokens will be rejected even if they have valid-looking payloads.
*
* Note: Even if the license-runtime marks tokens as "invalid" due to audience mismatch,
* we still accept them for Premium usage IF they pass cryptographic validation. The checkLicense() and
* requireLicense() functions will check for all valid features.
*
* Useful for dynamic token loading from backend services or user input.
* @param token The license token string (JWT format)
*/
export declare function setLicenseTokenFromString(token: string): Promise<void>;
/**
* Get the current license token (if set).
* @returns The current license token or null
*/
export declare function getCurrentLicenseToken(): string | null;
/**
* Check if license runtime has been initialized.
* @returns true if initializeLicense() has been called
*/
export declare function isLicenseInitialized(): boolean;
//# sourceMappingURL=license.d.ts.map