@mastra/core
Version:
65 lines • 2.36 kB
TypeScript
import type { IMastraLogger } from '../logger/index.js';
export interface LicenseValidationSuccess {
valid: true;
/** Feature entitlements granted by the license (e.g. 'rbac', 'sso', 'fga') */
entitlements: string[];
/** Plan tier the license was issued for (e.g. 'teams', 'enterprise') */
planTier: string;
expiresAt: string | null;
leaseTtlSeconds: number;
}
export interface LicenseValidationError {
valid: false;
code: 'INVALID_KEY' | 'LICENSE_EXPIRED' | 'LICENSE_REVOKED' | 'RATE_LIMITED';
reason: string;
}
export type LicenseValidationResponse = LicenseValidationSuccess | LicenseValidationError;
export type LicenseMode = 'enterprise' | 'open-source';
export type LicenseStatus = 'pending' | 'valid' | 'invalid';
export interface LicenseSnapshot {
mode: LicenseMode;
status: LicenseStatus;
entitlements: string[] | null;
planTier: string | null;
expiresAt: string | null;
}
export declare class LicenseClient {
private static instance;
private logger?;
private licenseKey?;
private licenseUrl?;
private mode;
private status;
private cachedResult;
private cacheExpiry;
private gracePeriodEnd;
private revalidationTimeout;
private readonly GRACE_PERIOD_MS;
private readonly DEFAULT_TTL_MS;
private constructor();
static getInstance(logger?: IMastraLogger): LicenseClient;
/**
* Reset the singleton so the next getInstance() re-reads env vars.
* Intended for tests.
*/
static resetInstance(): void;
private readonly REQUEST_TIMEOUT_MS;
private fetchWithRetry;
private validationPromise;
validate(): Promise<boolean>;
/**
* Contact the server regardless of cache freshness, coalescing concurrent
* callers (e.g. the Mastra constructor and the auth/ee helpers both kicking
* off validation at startup) into a single in-flight request so the server
* is contacted — and the outcome logged — only once. Used directly by the
* background revalidation timer, which must bypass the cache check.
*/
private revalidate;
private performValidation;
private scheduleRevalidation;
private clearCache;
hasFeature(featureName: string): boolean;
getEntitlements(): string[] | null;
getSnapshot(): LicenseSnapshot;
}
//# sourceMappingURL=index.d.ts.map