@sdux-vault/engine 0.1.2 → 0.2.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.2';
14
+ const SDUX_VERSION = '0.2.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
@@ -1577,6 +1658,12 @@ class VaultCoreInstance {
1577
1658
  getLicensePayload(licenseId) {
1578
1659
  return this.#licenseMap.get(licenseId);
1579
1660
  }
1661
+ isAuthorizedKey(key) {
1662
+ return KNOWN_VAULT_KEYS.has(key);
1663
+ }
1664
+ hasVaultLicense() {
1665
+ return this.#licenseMap.has(VAULT_LICENSE_ID);
1666
+ }
1580
1667
  //#endregion
1581
1668
  //#region private Methods
1582
1669
  #initializeLicenses(licenses) {
@@ -1590,7 +1677,13 @@ class VaultCoreInstance {
1590
1677
  }
1591
1678
  #registerEntities(entities) {
1592
1679
  return new Map(entities.map((entity) => {
1593
- const needsLicense = entity.needsLicense ?? false;
1680
+ let needsLicense;
1681
+ if (DevMode.active) {
1682
+ needsLicense = false;
1683
+ }
1684
+ else {
1685
+ needsLicense = entity.needsLicense ?? false;
1686
+ }
1594
1687
  const frozen = {
1595
1688
  key: entity.key,
1596
1689
  type: entity.type,
@@ -1743,9 +1836,9 @@ class VaultCoreInstance {
1743
1836
  return;
1744
1837
  // Must match exactly
1745
1838
  if (entity.licenseId !== licenseId) {
1746
- if (DevMode.active) {
1747
- vaultWarn(`[vault] License key mismatch for "${key}".`);
1748
- }
1839
+ // if (DevMode.active) {
1840
+ vaultWarn(`[vault] License key mismatch for "${key}".`);
1841
+ //}
1749
1842
  return;
1750
1843
  }
1751
1844
  entities.set(key, Object.freeze({
@@ -1913,10 +2006,22 @@ function getVaultRegistryForTests() {
1913
2006
  if (!instance) {
1914
2007
  throw new Error('[vault] Vault not initialized.');
1915
2008
  }
1916
- if (!DevMode.active)
1917
- return;
1918
2009
  return instance.getRegistrySnapshot();
1919
2010
  }
2011
+ function isAuthorizedKey(key) {
2012
+ if (!instance)
2013
+ return false;
2014
+ if (DevMode.active)
2015
+ return true;
2016
+ return instance.isAuthorizedKey(key);
2017
+ }
2018
+ function hasVaultLicense() {
2019
+ if (!instance)
2020
+ return false;
2021
+ if (DevMode.active)
2022
+ return true;
2023
+ return instance.hasVaultLicense();
2024
+ }
1920
2025
 
1921
2026
  // projects/core/src/lib/services/vault-behavior-lifecycle.service.ts
1922
2027
  /**
@@ -1976,6 +2081,12 @@ class BehaviorInitializationClass {
1976
2081
  isCritical = true;
1977
2082
  throw new Error(`[vault] Behavior metadata missing "key".`);
1978
2083
  }
2084
+ if (!hasVaultLicense()) {
2085
+ if (!isAuthorizedKey(behaviorKey)) {
2086
+ vaultDebug(`[vault] Unlicensed behavior "${behaviorKey}" skipped during initialization.`);
2087
+ return;
2088
+ }
2089
+ }
1979
2090
  if (!behaviorType) {
1980
2091
  isCritical = true;
1981
2092
  throw new Error(`[vault] Behavior metadata missing "type" for "${behaviorKey}".`);
@@ -3015,6 +3126,12 @@ class ControllerInitializationClass {
3015
3126
  isCritical = true;
3016
3127
  throw new Error(`[vault] Controller metadata missing "key".`);
3017
3128
  }
3129
+ if (!hasVaultLicense()) {
3130
+ if (!isAuthorizedKey(controllerKey)) {
3131
+ vaultDebug(`[vault] Unlicensed controller "${controllerKey}" skipped during initialization.`);
3132
+ return;
3133
+ }
3134
+ }
3018
3135
  if (!controllerType) {
3019
3136
  isCritical = true;
3020
3137
  throw new Error(`[vault] Controller metadata missing "type" for "${controllerKey}".`);
@@ -3507,12 +3624,21 @@ class Conductor extends Orchestrator {
3507
3624
  controllers.unshift(withCoreErrorController);
3508
3625
  }
3509
3626
  }
3627
+ #filterRestrictedControllers(controllers) {
3628
+ return controllers.filter((controller) => {
3629
+ if (controller.type === ControllerTypes.License || controller.type === ControllerTypes.CoreAbstain) {
3630
+ vaultDebug(`${this.cellKey} Conductor: Filtering out controller "${controller.key}" of type "${controller.type}" as it is reserved for internal use.`);
3631
+ return false;
3632
+ }
3633
+ return true;
3634
+ });
3635
+ }
3510
3636
  // ---------------------------------------------------------------------------
3511
3637
  // INTERNAL SCHEDULING
3512
3638
  // ---------------------------------------------------------------------------
3513
3639
  #registerControllers(config) {
3514
3640
  config.controllers = config.controllers ?? [];
3515
- const allControllers = config.controllers.filter(Boolean);
3641
+ const allControllers = this.#filterRestrictedControllers(config.controllers);
3516
3642
  this.#addDefaultErrorController(allControllers, config);
3517
3643
  allControllers.unshift(withCoreLicenseController);
3518
3644
  allControllers.unshift(withCoreAbstainController);
@@ -4074,5 +4200,5 @@ function resetFeatureCellToken() {
4074
4200
  * Generated bundle index. Do not edit.
4075
4201
  */
4076
4202
 
4077
- export { Conductor, FeatureCellClass, LicensingAbstract, VaultCore, createFeatureCellToken, getFeatureCellToken, getLicensePayload, getVaultRegistryForTests, isPipelineTerminal, registerFeatureCell, registerVaultSettled, resetFeatureCellRegistry, resetVaultForTests, vaultAllSettled, vaultSettled };
4203
+ export { Conductor, FeatureCellClass, LicensingAbstract, VAULT_LICENSE_ID, VaultCore, createFeatureCellToken, getFeatureCellToken, getLicensePayload, getVaultRegistryForTests, hasVaultLicense, isAuthorizedKey, isPipelineTerminal, registerFeatureCell, registerVaultSettled, resetFeatureCellRegistry, resetVaultForTests, vaultAllSettled, vaultSettled };
4078
4204
  //# sourceMappingURL=sdux-vault-engine.mjs.map