type LicenseState = { status: 'valid' | 'invalid' | 'missing' | 'expired'; reason?: string; payload?: any; }; interface TokenInfo { token: string; audience: string; features: string[]; expiry: number; validated: boolean; } interface UnifiedLicenseRegistry { features: Set; tokens: Map; initialized: boolean; } /** * Get the unified license registry from globalThis. * Creates the registry if it doesn't exist. * This registry is shared across all @astermind packages. */ export declare function getUnifiedRegistry(): UnifiedLicenseRegistry; /** * Clear the unified license registry. * Used when resetting all licenses or during setLicenseKeys(). */ export declare function clearUnifiedRegistry(): void; export declare function initializeLicense(): void; export declare function initializeLicenseAsync(): Promise; export declare const 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; /** * 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; /** * Verify that a license token is valid and usable after setting it. * This is a convenience function that sets the token and verifies it's usable. * Use this instead of setLicenseTokenFromString() if you want to ensure the license is usable. * * SECURITY: This function provides an extra layer of verification and is recommended * for production use to ensure license errors are caught immediately during initialization. * * @param token The license token string (JWT format) * @returns Promise that resolves if license is valid and usable * @throws Error if license is invalid, expired, or not usable */ export declare function setAndVerifyLicenseToken(token: string): Promise; /** * SECURITY: Clear license token and reset security state. * Useful for logout or security events. * WARNING: This function is for internal use only. Exposing it in client-side code * allows users to bypass license checks. Only use this server-side or in secure contexts. */ export declare function clearLicenseToken(): void; /** * SECURITY: Force immediate re-validation of current token. * This can help detect if a token has been revoked. * @returns Promise that resolves when re-validation is complete */ export declare function revalidateLicense(): Promise; /** * Add a single license token to the unified registry. * This validates the token and merges its features (including audience) with existing features. * * Use this when you want to ADD a token without clearing existing tokens. * For replacing all tokens, use setLicenseKeys() instead. * * Feature Extraction Rule: * Full Features = [token.aud] + token.features (deduplicated) * * Example: * If aud = "astermind-premium" and features = ["astermind-elm", "astermind-pro"] * Then registry gets: ["astermind-premium", "astermind-elm", "astermind-pro"] * * @param token - The license token string (JWT format) * @returns Promise that resolves when token is validated and added to registry * @throws Error if token is invalid, expired, or fails cryptographic validation */ export declare function addLicenseToken(token: string): Promise; /** * Set multiple license tokens at once. * This CLEARS the existing registry first, then adds all provided tokens. * * Use this when you want to replace all licenses with a new set. * For adding a single token without clearing, use addLicenseToken() instead. * * The resulting unified registry will contain all features from all tokens, * including each token's audience as a feature. * * Example: * setLicenseKeys([token1, token2]) * - token1: aud="astermind-premium", features=["astermind-elm"] * - token2: aud="astermind-synth", features=["omega-full"] * - Registry gets: ["astermind-premium", "astermind-elm", "astermind-synth", "omega-full"] * * @param tokens - Array of license token strings (JWT format) * @returns Promise that resolves when all tokens are validated and registry is populated * @throws Error if any token is invalid (all tokens must be valid) */ export declare function setLicenseKeys(tokens: string[]): Promise; /** * Check if a specific feature/product code is available in the unified registry. * This checks across ALL loaded license tokens. * * Use this to check if any of the loaded licenses grant access to a specific feature. * * @param productCode - The product code or feature to check (e.g., "astermind-premium", "astermind-elm") * @returns true if the feature is available in any loaded license */ export declare function hasFeature(productCode: string): boolean; /** * Get all licensed features/product codes from the unified registry. * This returns features from ALL loaded license tokens. * * The returned list includes: * - Each token's audience (aud) as a feature * - All features from each token's features array * - Deduplicated across all tokens * * @returns Array of all licensed feature/product codes */ export declare function getAllFeatures(): string[]; /** * Get information about all loaded license tokens. * Useful for debugging and displaying license status. * * @returns Map of audience to token info (token string, features, expiry, validated status) */ export declare function getLoadedTokens(): Map; /** * Check if the unified license registry has been initialized with at least one token. * * @returns true if at least one token has been loaded into the registry */ export declare function isRegistryInitialized(): boolean; /** * Clear all licenses and reset the unified registry. * This is an alias for clearLicenseToken() that also clears the registry. * * Use this when logging out or when you need to reset all license state. */ export declare function clearLicenses(): void; /** * Add a token to the unified registry synchronously (without crypto validation). * This is for MUI-style loading - fast and synchronous. * * @param token - JWT token string * @returns true if added successfully, false if invalid/expired */ export declare function addTokenToRegistrySync(token: string): boolean; /** * Add multiple license tokens to the unified registry. * Unlike setLicenseKeys(), this does NOT clear existing licenses. * Use this to merge tokens from multiple sources. * * @param tokens - Array of JWT license tokens to add * @returns Number of tokens successfully added */ export declare function addLicenseKeys(tokens: string[]): number; export {}; //# sourceMappingURL=license.d.ts.map