@forgecharts/sdk 1.3.7 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/internal.js CHANGED
@@ -10798,6 +10798,7 @@ var DEFAULT_FEATURES = {};
10798
10798
  var LicenseManager = class _LicenseManager {
10799
10799
  static instance = null;
10800
10800
  payload = null;
10801
+ status = "idle";
10801
10802
  subscribers = /* @__PURE__ */ new Set();
10802
10803
  constructor() {
10803
10804
  }
@@ -10844,17 +10845,27 @@ var LicenseManager = class _LicenseManager {
10844
10845
  if (!verifyUrl) {
10845
10846
  throw new Error("LicenseManager: verifyUrl is required");
10846
10847
  }
10847
- const res = await fetch(verifyUrl, {
10848
- method: "POST",
10849
- headers: { "Content-Type": "application/json" },
10850
- body: JSON.stringify({ licenseKey: key.trim().toUpperCase() })
10851
- });
10852
- if (!res.ok) {
10853
- throw new Error(`License server error: ${res.status} ${res.statusText}`);
10854
- }
10855
- const data = await res.json();
10856
- if (!data.valid) {
10857
- throw new Error(data.reason ?? "License invalid");
10848
+ this.status = "pending";
10849
+ this.notify();
10850
+ let data;
10851
+ try {
10852
+ const res = await fetch(verifyUrl, {
10853
+ method: "POST",
10854
+ headers: { "Content-Type": "application/json" },
10855
+ body: JSON.stringify({ licenseKey: key.trim().toUpperCase() })
10856
+ });
10857
+ if (!res.ok) {
10858
+ throw new Error(`License server error: ${res.status} ${res.statusText}`);
10859
+ }
10860
+ data = await res.json();
10861
+ if (!data.valid) {
10862
+ throw new Error(data.reason ?? "License invalid");
10863
+ }
10864
+ } catch (err) {
10865
+ this.payload = null;
10866
+ this.status = "failed";
10867
+ this.notify();
10868
+ throw err;
10858
10869
  }
10859
10870
  const raw = {
10860
10871
  licenseKey: data.licenseKey ?? key.trim().toUpperCase(),
@@ -10869,14 +10880,29 @@ var LicenseManager = class _LicenseManager {
10869
10880
  };
10870
10881
  const payload = this.#applyPolicyPipeline(raw);
10871
10882
  this.payload = payload;
10883
+ this.status = "valid";
10872
10884
  this.notify();
10873
10885
  return payload;
10874
10886
  }
10875
10887
  /** Load a pre-validated payload (e.g. from cache / localStorage). Runs through the same migration + guardrail pipeline as `validateLicense`. */
10876
10888
  loadLicense(payload) {
10877
10889
  this.payload = this.#applyPolicyPipeline(payload);
10890
+ this.status = "valid";
10878
10891
  this.notify();
10879
10892
  }
10893
+ /** Where the license is in its validation lifecycle. */
10894
+ getValidationStatus() {
10895
+ return this.status;
10896
+ }
10897
+ /**
10898
+ * True when a validation attempt is pending or has failed — every
10899
+ * license-gated feature must be denied. 'idle' (validation never
10900
+ * attempted) is NOT locked down: dev/test usage keeps the permissive
10901
+ * "omitted = allowed" defaults.
10902
+ */
10903
+ isLockedDown() {
10904
+ return this.status === "pending" || this.status === "failed";
10905
+ }
10880
10906
  /**
10881
10907
  * Runs a raw/legacy/partial payload through `migrateLegacyPayload` (fills
10882
10908
  * missing productTier/capabilities/schemaVersion, deterministically, with
@@ -10931,9 +10957,10 @@ var LicenseManager = class _LicenseManager {
10931
10957
  hasCapability(name) {
10932
10958
  return this.getCapabilities()[name] === true;
10933
10959
  }
10934
- /** Clear the current license state (returns to safe unmanaged defaults). */
10960
+ /** Clear the current license state (returns to safe unmanaged defaults and 'idle' status). */
10935
10961
  clear() {
10936
10962
  this.payload = null;
10963
+ this.status = "idle";
10937
10964
  this.notify();
10938
10965
  }
10939
10966
  };
@@ -11300,8 +11327,14 @@ var ChartRuntimeResolver = class _ChartRuntimeResolver {
11300
11327
  * If the active license has an explicit feature flag, use it.
11301
11328
  * Otherwise fall back to `defaultValue` (allows capability even without an
11302
11329
  * explicit flag, matching the "omitted = allowed" convention).
11330
+ *
11331
+ * Lockdown override: while a validation attempt is pending or has failed,
11332
+ * every gated feature is denied — a failed verify must never yield more
11333
+ * than a valid one. 'idle' (validation never attempted) keeps the
11334
+ * permissive defaults for dev/test usage.
11303
11335
  */
11304
11336
  #featureOrDefault(name, defaultValue) {
11337
+ if (this.lm.isLockedDown()) return false;
11305
11338
  const features = this.lm.getFeatures();
11306
11339
  const flag = features[name];
11307
11340
  return flag === void 0 ? defaultValue : flag === true;