Skip to content

LicenseService ​

Validates and tracks an XVR1 ES256-signed license token. Gates plugin and feature availability. The viewer constructs and registers this service only after the configured license key passes signature, issuer, audience, expiry, and (optionally) domain checks. Optional background revocation poll.

Access ​

Registered under the name "license". No service dependencies.

LicenseStatus is exported from the SDK entry point. The LicenseService class is not; reach it by its registered name and use the class only as a type.

ts
import { LicenseStatus } from "@optellix/xviewr-sdk";
import type { LicenseService } from "@optellix/xviewr-sdk";

await viewer.ready();
const license = viewer.getService<LicenseService>("license");
if (license?.getLicenseStatus() !== LicenseStatus.Valid) {
  // viewer would have thrown on init; this is just defensive
}
console.log(license?.getDaysRemaining());

License config is passed at viewer construction:

ts
const viewer = new ViewerCore(container, {
  viewer: {
    licensing: {
      key: "XVR1.<header>.<payload>.<signature>",
      revocationMode: "background", // "off" | "background" | "strict"
      revocationEndpoint: "https://license.optellix.com/revoke",
    },
    // ...
  },
  // ...
});

Public API ​

Lifecycle ​

  • init(context: ServiceContext): Promise<void> — emits license:validated, plus license:expiring when under 30 days.
  • destroy(): Promise<void>
  • getStatus(): ServiceStatus

Inspection ​

  • getLicenseStatus(): LicenseStatus — Uninitialized, Valid, Invalid, or Revoked.
  • getDaysRemaining(): number | null — null for perpetual (enterprise) tokens.
  • getCustomerName(): string | undefined
  • getTier(): LicenseTier
  • isPluginLicensed(pluginName: string): boolean — core plugins (camera, loader, rendering, selection, grid, environment, viewcube, transformControls) are always allowed when the license is valid.
  • isFeatureLicensed(featureName: string): boolean

Types ​

LicenseStatus ​

ts
enum LicenseStatus {
  Uninitialized = "uninitialized",
  Valid = "valid",
  Invalid = "invalid",
  Revoked = "revoked",
}

LicenseTier ​

ts
type LicenseTier = "trial" | "standard" | "professional" | "enterprise";

LicensedPlugin, LicensedFeature ​

Type aliases for string.

Events ​

EventPayload
license:validated{ claims: LicenseClaims; daysRemaining: number | null }
license:expiring{ claims: LicenseClaims; daysRemaining: number }
license:invalid{ claims?: LicenseClaims; reason?: string; error?: Error }
license:revocation-check{ endpoint?: string; jti?: string; mode?: string }
license:revocation-check-failed{ error: unknown }

Example ​

ts
const license = viewer.getService<LicenseService>("license");
if (!license) return;

if (!license.isFeatureLicensed("technical-drawing")) {
  hideTechnicalDrawingUI();
}

const days = license.getDaysRemaining();
if (days !== null && days < 14) {
  showRenewalBanner(days);
}

console.log(license.getTier());        // "enterprise"
console.log(license.getCustomerName()); // "Acme Corp"

This SDK and its license tokens are proprietary to Optellix Pvt. Ltd. Use is governed by the applicable license agreement.

XViewr SDK and xConvert CLI documentation.