@forgecharts/sdk 1.3.7 → 1.3.9
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -15
- package/dist/index.js.map +1 -1
- package/dist/internal.js +51 -15
- package/dist/internal.js.map +1 -1
- package/dist/licensing/ChartRuntimeResolver.d.ts.map +1 -1
- package/dist/licensing/LicenseManager.d.ts +23 -1
- package/dist/licensing/LicenseManager.d.ts.map +1 -1
- package/dist/licensing/__tests__/lockdownPolicy.test.d.ts +2 -0
- package/dist/licensing/__tests__/lockdownPolicy.test.d.ts.map +1 -0
- package/dist/react/index.js +51 -15
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +51 -15
- package/dist/react/internal.js.map +1 -1
- package/package.json +1 -1
package/dist/react/internal.js
CHANGED
|
@@ -10726,12 +10726,14 @@ function validateLicensePolicy(payload) {
|
|
|
10726
10726
|
}
|
|
10727
10727
|
|
|
10728
10728
|
// src/licensing/LicenseManager.ts
|
|
10729
|
+
var GLOBAL_INSTANCE_KEY = /* @__PURE__ */ Symbol.for("@forgecharts/sdk:LicenseManager");
|
|
10729
10730
|
var DEFAULT_MODE = "unmanaged";
|
|
10730
10731
|
var DEFAULT_PRODUCT_TIER = "core";
|
|
10731
10732
|
var DEFAULT_FEATURES = {};
|
|
10732
10733
|
var LicenseManager = class _LicenseManager {
|
|
10733
10734
|
static instance = null;
|
|
10734
10735
|
payload = null;
|
|
10736
|
+
status = "idle";
|
|
10735
10737
|
subscribers = /* @__PURE__ */ new Set();
|
|
10736
10738
|
constructor() {
|
|
10737
10739
|
}
|
|
@@ -10759,10 +10761,12 @@ var LicenseManager = class _LicenseManager {
|
|
|
10759
10761
|
});
|
|
10760
10762
|
}
|
|
10761
10763
|
static getInstance() {
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
+
const registry = globalThis;
|
|
10765
|
+
if (!registry[GLOBAL_INSTANCE_KEY]) {
|
|
10766
|
+
registry[GLOBAL_INSTANCE_KEY] = _LicenseManager.instance ?? new _LicenseManager();
|
|
10764
10767
|
}
|
|
10765
|
-
|
|
10768
|
+
_LicenseManager.instance = registry[GLOBAL_INSTANCE_KEY];
|
|
10769
|
+
return registry[GLOBAL_INSTANCE_KEY];
|
|
10766
10770
|
}
|
|
10767
10771
|
/**
|
|
10768
10772
|
* Validate a license key against the licensing endpoint.
|
|
@@ -10778,17 +10782,27 @@ var LicenseManager = class _LicenseManager {
|
|
|
10778
10782
|
if (!verifyUrl) {
|
|
10779
10783
|
throw new Error("LicenseManager: verifyUrl is required");
|
|
10780
10784
|
}
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10785
|
+
this.status = "pending";
|
|
10786
|
+
this.notify();
|
|
10787
|
+
let data;
|
|
10788
|
+
try {
|
|
10789
|
+
const res = await fetch(verifyUrl, {
|
|
10790
|
+
method: "POST",
|
|
10791
|
+
headers: { "Content-Type": "application/json" },
|
|
10792
|
+
body: JSON.stringify({ licenseKey: key.trim().toUpperCase() })
|
|
10793
|
+
});
|
|
10794
|
+
if (!res.ok) {
|
|
10795
|
+
throw new Error(`License server error: ${res.status} ${res.statusText}`);
|
|
10796
|
+
}
|
|
10797
|
+
data = await res.json();
|
|
10798
|
+
if (!data.valid) {
|
|
10799
|
+
throw new Error(data.reason ?? "License invalid");
|
|
10800
|
+
}
|
|
10801
|
+
} catch (err) {
|
|
10802
|
+
this.payload = null;
|
|
10803
|
+
this.status = "failed";
|
|
10804
|
+
this.notify();
|
|
10805
|
+
throw err;
|
|
10792
10806
|
}
|
|
10793
10807
|
const raw = {
|
|
10794
10808
|
licenseKey: data.licenseKey ?? key.trim().toUpperCase(),
|
|
@@ -10803,14 +10817,29 @@ var LicenseManager = class _LicenseManager {
|
|
|
10803
10817
|
};
|
|
10804
10818
|
const payload = this.#applyPolicyPipeline(raw);
|
|
10805
10819
|
this.payload = payload;
|
|
10820
|
+
this.status = "valid";
|
|
10806
10821
|
this.notify();
|
|
10807
10822
|
return payload;
|
|
10808
10823
|
}
|
|
10809
10824
|
/** Load a pre-validated payload (e.g. from cache / localStorage). Runs through the same migration + guardrail pipeline as `validateLicense`. */
|
|
10810
10825
|
loadLicense(payload) {
|
|
10811
10826
|
this.payload = this.#applyPolicyPipeline(payload);
|
|
10827
|
+
this.status = "valid";
|
|
10812
10828
|
this.notify();
|
|
10813
10829
|
}
|
|
10830
|
+
/** Where the license is in its validation lifecycle. */
|
|
10831
|
+
getValidationStatus() {
|
|
10832
|
+
return this.status;
|
|
10833
|
+
}
|
|
10834
|
+
/**
|
|
10835
|
+
* True when a validation attempt is pending or has failed — every
|
|
10836
|
+
* license-gated feature must be denied. 'idle' (validation never
|
|
10837
|
+
* attempted) is NOT locked down: dev/test usage keeps the permissive
|
|
10838
|
+
* "omitted = allowed" defaults.
|
|
10839
|
+
*/
|
|
10840
|
+
isLockedDown() {
|
|
10841
|
+
return this.status === "pending" || this.status === "failed";
|
|
10842
|
+
}
|
|
10814
10843
|
/**
|
|
10815
10844
|
* Runs a raw/legacy/partial payload through `migrateLegacyPayload` (fills
|
|
10816
10845
|
* missing productTier/capabilities/schemaVersion, deterministically, with
|
|
@@ -10865,9 +10894,10 @@ var LicenseManager = class _LicenseManager {
|
|
|
10865
10894
|
hasCapability(name) {
|
|
10866
10895
|
return this.getCapabilities()[name] === true;
|
|
10867
10896
|
}
|
|
10868
|
-
/** Clear the current license state (returns to safe unmanaged defaults). */
|
|
10897
|
+
/** Clear the current license state (returns to safe unmanaged defaults and 'idle' status). */
|
|
10869
10898
|
clear() {
|
|
10870
10899
|
this.payload = null;
|
|
10900
|
+
this.status = "idle";
|
|
10871
10901
|
this.notify();
|
|
10872
10902
|
}
|
|
10873
10903
|
};
|
|
@@ -11234,8 +11264,14 @@ var ChartRuntimeResolver = class _ChartRuntimeResolver {
|
|
|
11234
11264
|
* If the active license has an explicit feature flag, use it.
|
|
11235
11265
|
* Otherwise fall back to `defaultValue` (allows capability even without an
|
|
11236
11266
|
* explicit flag, matching the "omitted = allowed" convention).
|
|
11267
|
+
*
|
|
11268
|
+
* Lockdown override: while a validation attempt is pending or has failed,
|
|
11269
|
+
* every gated feature is denied — a failed verify must never yield more
|
|
11270
|
+
* than a valid one. 'idle' (validation never attempted) keeps the
|
|
11271
|
+
* permissive defaults for dev/test usage.
|
|
11237
11272
|
*/
|
|
11238
11273
|
#featureOrDefault(name, defaultValue) {
|
|
11274
|
+
if (this.lm.isLockedDown()) return false;
|
|
11239
11275
|
const features = this.lm.getFeatures();
|
|
11240
11276
|
const flag = features[name];
|
|
11241
11277
|
return flag === void 0 ? defaultValue : flag === true;
|