@sdux-vault/engine 0.1.3 → 0.3.0

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.
@@ -11,7 +11,7 @@ import { EventBus, initDevtoolsWidget } from '@sdux-vault/devtools';
11
11
  // cmd+alt+j (see .vscode/keybindings.json)
12
12
  // --- END AI MODEL FILE PATH ---
13
13
  const SDUX_PACKAGE = '@sdux-vault/engine';
14
- const SDUX_VERSION = '0.1.3';
14
+ const SDUX_VERSION = '0.3.0';
15
15
  registerVersion(SDUX_PACKAGE, SDUX_VERSION);
16
16
 
17
17
  /**
@@ -1486,6 +1486,87 @@ const VaultRegistrationLicenseStatusTypes = {
1486
1486
  Valid: 'valid'
1487
1487
  };
1488
1488
 
1489
+ /**
1490
+ * Set of all known behavior and controller keys shipped with the core,
1491
+ * addon, and engine packages. Keys in this set are always permitted
1492
+ * during behavior and controller initialization regardless of license
1493
+ * status.
1494
+ *
1495
+ * Any key not present in this set is treated as a custom extension and
1496
+ * requires a valid Vault license to be registered.
1497
+ *
1498
+ * Entries follow the canonical key format produced by
1499
+ * `defineBehaviorKey()` and `defineControllerKey()`:
1500
+ *
1501
+ * `SDUX::Behavior::<Domain>::<Name>`
1502
+ * `SDUX::Controller::<Domain>::<Name>`
1503
+ */
1504
+ const KNOWN_VAULT_KEYS = new Set([
1505
+ // ---------------------------------------------------------------------------
1506
+ // Core Behaviors (libs/core)
1507
+ // ---------------------------------------------------------------------------
1508
+ 'SDUX::Behavior::Core::Error',
1509
+ 'SDUX::Behavior::Core::ErrorCallback',
1510
+ 'SDUX::Behavior::Core::Filter',
1511
+ 'SDUX::Behavior::Core::Reducer',
1512
+ 'SDUX::Behavior::Core::BeforeTap',
1513
+ 'SDUX::Behavior::Core::AfterTap',
1514
+ 'SDUX::Behavior::Core::EmitState',
1515
+ 'SDUX::Behavior::Core::State',
1516
+ 'SDUX::Behavior::Core::Value',
1517
+ 'SDUX::Behavior::Core::Observable',
1518
+ 'SDUX::Behavior::Core::Promise',
1519
+ 'SDUX::Behavior::Core::FromStream',
1520
+ 'SDUX::Behavior::Core::FromPromise',
1521
+ 'SDUX::Behavior::Core::FromObservable',
1522
+ 'SDUX::Behavior::Core::ObjectMerge',
1523
+ 'SDUX::Behavior::Core::ArrayMerge',
1524
+ // ---------------------------------------------------------------------------
1525
+ // Addon Behaviors (libs/addons)
1526
+ // ---------------------------------------------------------------------------
1527
+ 'SDUX::Behavior::Persist::SessionStorage',
1528
+ 'SDUX::Behavior::Persist::LocalStorage',
1529
+ 'SDUX::Behavior::Persist::CookieStorage',
1530
+ 'SDUX::Behavior::Encrypt::Aes256',
1531
+ 'SDUX::Behavior::Policy::StepwiseFilter',
1532
+ 'SDUX::Behavior::Policy::StepwiseReducer',
1533
+ 'SDUX::Behavior::Policy::StepwiseResolve',
1534
+ 'SDUX::Behavior::Addon::DistinctUntilChanged',
1535
+ 'SDUX::Behavior::Interceptor::GlobalErrorPause',
1536
+ 'SDUX::Behavior::Merge::ArrayAppend',
1537
+ 'SDUX::Behavior::Merge::ArrayPush',
1538
+ 'SDUX::Behavior::Merge::Deep',
1539
+ 'SDUX::Behavior::Core::Query',
1540
+ 'SDUX::Behavior::Core::Lookup',
1541
+ 'SDUX::Behavior::Cache::State',
1542
+ // ---------------------------------------------------------------------------
1543
+ // Engine Behaviors (vault-engine)
1544
+ // ---------------------------------------------------------------------------
1545
+ 'SDUX::Behavior::Core::License',
1546
+ // ---------------------------------------------------------------------------
1547
+ // Engine Controllers (vault-engine)
1548
+ // ---------------------------------------------------------------------------
1549
+ 'SDUX::Controller::Policy::CoreAbstain',
1550
+ 'SDUX::Controller::Policy::CoreError',
1551
+ 'SDUX::Controller::Policy::CoreLicense',
1552
+ // ---------------------------------------------------------------------------
1553
+ // Addon Controllers (libs/addons)
1554
+ // ---------------------------------------------------------------------------
1555
+ 'SDUX::Controller::Policy::ReplayGlobalError',
1556
+ 'SDUX::Controller::Policy::Stepwise',
1557
+ 'SDUX::Controller::Policy::MaxFailures',
1558
+ 'SDUX::Controller::Policy::Delay',
1559
+ 'SDUX::Controller::Policy::Throttle'
1560
+ ]);
1561
+
1562
+ /**
1563
+ * Canonical license identifier for the SDuX Vault engine license.
1564
+ *
1565
+ * This value must match the `licenseId` field in the `VaultLicensingShape`
1566
+ * payload supplied via `provideVault({ licenses: [...] })`.
1567
+ */
1568
+ const VAULT_LICENSE_ID = 'sdux-vault';
1569
+
1489
1570
  // --- AI Model File Path (DO NOT DELETE) ---
1490
1571
  // FilePath: projects > engine > src > lib > factories > vault > vault-core.function.ts
1491
1572
  // Updated: 2026-03-02 19:52
@@ -1503,6 +1584,7 @@ class VaultCoreInstance {
1503
1584
  #validaionSub;
1504
1585
  #licenseMap = new Map();
1505
1586
  #terminalStatus = new Map();
1587
+ #bypassLicensing = true;
1506
1588
  #licenseTimeoutMs;
1507
1589
  // eslint-disable-next-line
1508
1590
  #licenseTimers = new Map();
@@ -1541,6 +1623,7 @@ class VaultCoreInstance {
1541
1623
  this.#vaultConfig = Object.freeze(vaultConfig);
1542
1624
  DevMode.setDevMode(this.#vaultConfig.devMode);
1543
1625
  setVaultLogLevel(this.#vaultConfig.logLevel);
1626
+ this.#bypassLicensing = config.devMode ? (config.bypassLicensing ?? true) : false;
1544
1627
  this.#licenseTimeoutMs = config.licenseTimeoutMs ?? 15_000;
1545
1628
  this.#warnIfAccidentalDevMode();
1546
1629
  }
@@ -1577,6 +1660,15 @@ class VaultCoreInstance {
1577
1660
  getLicensePayload(licenseId) {
1578
1661
  return this.#licenseMap.get(licenseId);
1579
1662
  }
1663
+ isBypassLicensing() {
1664
+ return this.#bypassLicensing;
1665
+ }
1666
+ isAuthorizedKey(key) {
1667
+ return KNOWN_VAULT_KEYS.has(key);
1668
+ }
1669
+ hasVaultLicense() {
1670
+ return this.#licenseMap.has(VAULT_LICENSE_ID);
1671
+ }
1580
1672
  //#endregion
1581
1673
  //#region private Methods
1582
1674
  #initializeLicenses(licenses) {
@@ -1590,7 +1682,13 @@ class VaultCoreInstance {
1590
1682
  }
1591
1683
  #registerEntities(entities) {
1592
1684
  return new Map(entities.map((entity) => {
1593
- const needsLicense = entity.needsLicense ?? false;
1685
+ let needsLicense;
1686
+ if (this.#bypassLicensing) {
1687
+ needsLicense = false;
1688
+ }
1689
+ else {
1690
+ needsLicense = entity.needsLicense ?? false;
1691
+ }
1594
1692
  const frozen = {
1595
1693
  key: entity.key,
1596
1694
  type: entity.type,
@@ -1743,9 +1841,9 @@ class VaultCoreInstance {
1743
1841
  return;
1744
1842
  // Must match exactly
1745
1843
  if (entity.licenseId !== licenseId) {
1746
- if (DevMode.active) {
1747
- vaultWarn(`[vault] License key mismatch for "${key}".`);
1748
- }
1844
+ // if (DevMode.active) {
1845
+ vaultWarn(`[vault] License key mismatch for "${key}".`);
1846
+ //}
1749
1847
  return;
1750
1848
  }
1751
1849
  entities.set(key, Object.freeze({
@@ -1913,10 +2011,22 @@ function getVaultRegistryForTests() {
1913
2011
  if (!instance) {
1914
2012
  throw new Error('[vault] Vault not initialized.');
1915
2013
  }
1916
- if (!DevMode.active)
1917
- return;
1918
2014
  return instance.getRegistrySnapshot();
1919
2015
  }
2016
+ function isAuthorizedKey(key) {
2017
+ if (!instance)
2018
+ return false;
2019
+ if (instance.isBypassLicensing())
2020
+ return true;
2021
+ return instance.isAuthorizedKey(key);
2022
+ }
2023
+ function hasVaultLicense() {
2024
+ if (!instance)
2025
+ return false;
2026
+ if (instance.isBypassLicensing())
2027
+ return true;
2028
+ return instance.hasVaultLicense();
2029
+ }
1920
2030
 
1921
2031
  // projects/core/src/lib/services/vault-behavior-lifecycle.service.ts
1922
2032
  /**
@@ -1976,6 +2086,12 @@ class BehaviorInitializationClass {
1976
2086
  isCritical = true;
1977
2087
  throw new Error(`[vault] Behavior metadata missing "key".`);
1978
2088
  }
2089
+ if (!hasVaultLicense()) {
2090
+ if (!isAuthorizedKey(behaviorKey)) {
2091
+ vaultDebug(`[vault] Unlicensed behavior "${behaviorKey}" skipped during initialization.`);
2092
+ return;
2093
+ }
2094
+ }
1979
2095
  if (!behaviorType) {
1980
2096
  isCritical = true;
1981
2097
  throw new Error(`[vault] Behavior metadata missing "type" for "${behaviorKey}".`);
@@ -3015,6 +3131,12 @@ class ControllerInitializationClass {
3015
3131
  isCritical = true;
3016
3132
  throw new Error(`[vault] Controller metadata missing "key".`);
3017
3133
  }
3134
+ if (!hasVaultLicense()) {
3135
+ if (!isAuthorizedKey(controllerKey)) {
3136
+ vaultDebug(`[vault] Unlicensed controller "${controllerKey}" skipped during initialization.`);
3137
+ return;
3138
+ }
3139
+ }
3018
3140
  if (!controllerType) {
3019
3141
  isCritical = true;
3020
3142
  throw new Error(`[vault] Controller metadata missing "type" for "${controllerKey}".`);
@@ -3507,12 +3629,21 @@ class Conductor extends Orchestrator {
3507
3629
  controllers.unshift(withCoreErrorController);
3508
3630
  }
3509
3631
  }
3632
+ #filterRestrictedControllers(controllers) {
3633
+ return controllers.filter((controller) => {
3634
+ if (controller.type === ControllerTypes.License || controller.type === ControllerTypes.CoreAbstain) {
3635
+ vaultDebug(`${this.cellKey} Conductor: Filtering out controller "${controller.key}" of type "${controller.type}" as it is reserved for internal use.`);
3636
+ return false;
3637
+ }
3638
+ return true;
3639
+ });
3640
+ }
3510
3641
  // ---------------------------------------------------------------------------
3511
3642
  // INTERNAL SCHEDULING
3512
3643
  // ---------------------------------------------------------------------------
3513
3644
  #registerControllers(config) {
3514
3645
  config.controllers = config.controllers ?? [];
3515
- const allControllers = config.controllers.filter(Boolean);
3646
+ const allControllers = this.#filterRestrictedControllers(config.controllers);
3516
3647
  this.#addDefaultErrorController(allControllers, config);
3517
3648
  allControllers.unshift(withCoreLicenseController);
3518
3649
  allControllers.unshift(withCoreAbstainController);
@@ -4074,5 +4205,5 @@ function resetFeatureCellToken() {
4074
4205
  * Generated bundle index. Do not edit.
4075
4206
  */
4076
4207
 
4077
- export { Conductor, FeatureCellClass, LicensingAbstract, VaultCore, createFeatureCellToken, getFeatureCellToken, getLicensePayload, getVaultRegistryForTests, isPipelineTerminal, registerFeatureCell, registerVaultSettled, resetFeatureCellRegistry, resetVaultForTests, vaultAllSettled, vaultSettled };
4208
+ export { Conductor, FeatureCellClass, LicensingAbstract, VAULT_LICENSE_ID, VaultCore, createFeatureCellToken, getFeatureCellToken, getLicensePayload, getVaultRegistryForTests, hasVaultLicense, isAuthorizedKey, isPipelineTerminal, registerFeatureCell, registerVaultSettled, resetFeatureCellRegistry, resetVaultForTests, vaultAllSettled, vaultSettled };
4078
4209
  //# sourceMappingURL=sdux-vault-engine.mjs.map