/** * Get or create the shared singleton instance * @param {import('./types.js').LicenseSeatConfig} [config] - Configuration (only used on first call) * @returns {LicenseSeatSDK} The shared instance */ export function getSharedInstance(config?: import("./types.js").LicenseSeatConfig): LicenseSeatSDK; /** * Configure the shared singleton instance * @param {import('./types.js').LicenseSeatConfig} config - Configuration options * @param {boolean} [force=false] - Force reconfiguration even if already configured * @returns {LicenseSeatSDK} The configured shared instance */ export function configure(config: import("./types.js").LicenseSeatConfig, force?: boolean): LicenseSeatSDK; /** * Reset the shared singleton instance * @returns {void} */ export function resetSharedInstance(): void; /** * SDK version constant * @type {string} */ export const SDK_VERSION: string; /** * LicenseSeat SDK Main Class * * Provides license activation, validation, and entitlement checking * for client-side JavaScript applications. * * @example * ```js * const sdk = new LicenseSeatSDK({ * apiKey: 'your-api-key', * debug: true * }); * * // Activate a license * await sdk.activate('LICENSE-KEY-HERE'); * * // Check entitlements * if (sdk.hasEntitlement('pro-features')) { * // Enable pro features * } * ``` */ export class LicenseSeatSDK { /** * SDK version (static property for easy access) * @type {string} */ static VERSION: string; /** * Create a new LicenseSeat SDK instance * @param {import('./types.js').LicenseSeatConfig} [config={}] - Configuration options */ constructor(config?: import("./types.js").LicenseSeatConfig); /** * SDK configuration * @type {import('./types.js').LicenseSeatConfig} */ config: import("./types.js").LicenseSeatConfig; /** * Event listeners map * @type {Object} * @private */ private eventListeners; /** * Auto-validation timer ID * @type {ReturnType|null} * @private */ private validationTimer; /** * Heartbeat timer ID (separate from auto-validation) * @type {ReturnType|null} * @private */ private heartbeatTimer; /** * License cache manager * @type {LicenseCache} * @private */ private cache; /** * Current online status * @type {boolean} * @private */ private online; /** * Current license key being auto-validated * @type {string|null} * @private */ private currentAutoLicenseKey; /** * Connectivity polling timer ID * @type {ReturnType|null} * @private */ private connectivityTimer; /** * Offline license refresh timer ID * @type {ReturnType|null} * @private */ private offlineRefreshTimer; /** * Last offline validation result (to avoid duplicate emits) * @type {import('./types.js').ValidationResult|null} * @private */ private lastOfflineValidation; /** * Flag to prevent concurrent syncOfflineAssets calls * @type {boolean} * @private */ private syncingOfflineAssets; /** * Flag indicating if SDK has been destroyed * @type {boolean} * @private */ private destroyed; /** * Initialize the SDK * Loads cached license and starts auto-validation if configured. * Called automatically unless autoInitialize is set to false. * @returns {void} */ initialize(): void; /** * Activate a license * @param {string} licenseKey - The license key to activate * @param {import('./types.js').ActivationOptions} [options={}] - Activation options * @returns {Promise} Activation result with cached license data * @throws {ConfigurationError} When productSlug is not configured * @throws {APIError} When the API request fails */ activate(licenseKey: string, options?: import("./types.js").ActivationOptions): Promise; /** * Deactivate the current license * @returns {Promise} Deactivation result from the API * @throws {ConfigurationError} When productSlug is not configured * @throws {LicenseError} When no active license is found * @throws {APIError} When the API request fails */ deactivate(): Promise; /** * Validate a license * @param {string} licenseKey - License key to validate * @param {import('./types.js').ValidationOptions} [options={}] - Validation options * @returns {Promise} Validation result * @throws {ConfigurationError} When productSlug is not configured * @throws {APIError} When the API request fails and offline fallback is not available */ validateLicense(licenseKey: string, options?: import("./types.js").ValidationOptions): Promise; /** * Check if a specific entitlement is active (detailed version) * @param {string} entitlementKey - The entitlement key to check * @returns {import('./types.js').EntitlementCheckResult} Entitlement status with details */ checkEntitlement(entitlementKey: string): import("./types.js").EntitlementCheckResult; /** * Check if a specific entitlement is active (simple boolean version) * This is a convenience method that returns a simple boolean. * Use checkEntitlement() for detailed status information. * @param {string} entitlementKey - The entitlement key to check * @returns {boolean} True if the entitlement is active, false otherwise */ hasEntitlement(entitlementKey: string): boolean; /** * Get offline token data from the server * @param {Object} [options={}] - Options for offline token generation * @param {string} [options.deviceId] - Device ID to bind the token to (required for hardware_locked mode) * @param {number} [options.ttlDays] - Token lifetime in days (default: 30, max: 90) * @returns {Promise} Offline token data * @throws {ConfigurationError} When productSlug is not configured * @throws {LicenseError} When no active license is found * @throws {APIError} When the API request fails */ getOfflineToken(options?: { deviceId?: string; ttlDays?: number; }): Promise; /** * Fetch a signing key from the server by key ID * @param {string} keyId - The Key ID (kid) for which to fetch the signing key * @returns {Promise} Signing key data * @throws {Error} When keyId is not provided or the key is not found */ getSigningKey(keyId: string): Promise; /** * Verify a signed offline token client-side using Ed25519 * @param {import('./types.js').OfflineToken} offlineTokenData - The offline token data * @param {string} publicKeyB64 - Base64-encoded public Ed25519 key * @returns {Promise} True if verification is successful * @throws {CryptoError} When crypto library is not available * @throws {Error} When inputs are invalid */ verifyOfflineToken(offlineTokenData: import("./types.js").OfflineToken, publicKeyB64: string): Promise; /** * Get current license status * @returns {import('./types.js').LicenseStatus} Current license status */ getStatus(): import("./types.js").LicenseStatus; /** * Test API connectivity * Makes a request to the health endpoint to verify connectivity. * Note: To fully verify API key validity, attempt an actual operation like activate() or validateLicense(). * @returns {Promise<{authenticated: boolean, healthy: boolean, api_version: string}>} * @throws {ConfigurationError} If API key is not configured * @throws {APIError} If the health check fails */ testAuth(): Promise<{ authenticated: boolean; healthy: boolean; api_version: string; }>; /** * Send a heartbeat for the current license. * Heartbeats let the server know the device is still active. * @returns {Promise} Heartbeat response, or undefined if no active license * @throws {ConfigurationError} When productSlug is not configured * @throws {APIError} When the API request fails */ heartbeat(): Promise; /** * Clear all data and reset SDK state * @returns {void} */ reset(): void; /** * Destroy the SDK instance and release all resources * Call this when you no longer need the SDK to prevent memory leaks. * After calling destroy(), the SDK instance should not be used. * @returns {void} */ destroy(): void; /** * Subscribe to an event * @param {string} event - Event name * @param {import('./types.js').EventCallback} callback - Event handler * @returns {import('./types.js').EventUnsubscribe} Unsubscribe function */ on(event: string, callback: import("./types.js").EventCallback): import("./types.js").EventUnsubscribe; /** * Unsubscribe from an event * @param {string} event - Event name * @param {import('./types.js').EventCallback} callback - Event handler to remove * @returns {void} */ off(event: string, callback: import("./types.js").EventCallback): void; /** * Emit an event * @param {string} event - Event name * @param {*} data - Event data * @returns {void} * @private */ private emit; /** * Start automatic license validation * @param {string} licenseKey - License key to validate * @returns {void} * @private */ private startAutoValidation; /** * Stop automatic validation * @returns {void} * @private */ private stopAutoValidation; /** * Start separate heartbeat timer * Sends periodic heartbeats between auto-validation cycles. * @returns {void} * @private */ private startHeartbeat; /** * Stop the separate heartbeat timer * @returns {void} * @private */ private stopHeartbeat; /** * Start connectivity polling (when offline) * @returns {void} * @private */ private startConnectivityPolling; /** * Stop connectivity polling * @returns {void} * @private */ private stopConnectivityPolling; /** * Download and cache the offline token and its corresponding public signing key. * Emits `offlineToken:ready` on success. Safe to call multiple times — concurrent * calls are deduplicated automatically. * @returns {Promise} */ syncOfflineAssets(): Promise; /** * Schedule periodic offline license refresh * @returns {void} * @private */ private scheduleOfflineRefresh; /** * Verify the cached offline token and return a validation result. * Use this to validate the license when the device is offline. * The offline token must have been previously downloaded via {@link syncOfflineAssets}. * @returns {Promise} */ verifyCachedOffline(): Promise; /** * Quick offline verification using only local data (no network) * Performs signature verification plus basic validity checks (expiry, license key match) * @returns {Promise} * @private */ private quickVerifyCachedOfflineLocal; /** * Make an API call with retry logic * @param {string} endpoint - API endpoint (will be appended to apiBaseUrl) * @param {Object} [options={}] - Fetch options * @param {string} [options.method="GET"] - HTTP method * @param {Object} [options.body] - Request body (will be JSON-stringified) * @param {Object} [options.headers] - Additional headers * @returns {Promise} API response data * @throws {APIError} When the request fails after all retries * @private */ private apiCall; /** * Determine if an error should be retried * @param {Error} error - The error to check * @returns {boolean} True if the error should trigger a retry * @private */ private shouldRetryError; /** * Get CSRF token from meta tag * @returns {string} CSRF token or empty string */ getCsrfToken(): string; /** * Log a message (if debug mode is enabled) * @param {...*} args - Arguments to log * @returns {void} * @private */ private log; } //# sourceMappingURL=LicenseSeat.d.ts.map