@sdux-vault/engine 0.4.0 → 0.9.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { registerVersion, vaultDebug, ControllerVotes, ControllerMessageTypes, OperationTypes, vaultWarn, VaultController, defineControllerKey, ControllerTypes, DevMode, DecisionOutcomeTypes, vaultError, defineBehaviorKey, DEVTOOLS_LOGGING_KEY_CONSTANT, DEVTOOLS_AGGREGATE_KEY_CONSTANT, createVaultError, EventTypes, EventBoundaryTypes, setVaultLogLevel, isTestEnv, BEHAVIOR_META, validateBehaviorKey, BehaviorTypes, VAULT_STOP, isVaultNoop, VaultPrivateErrorService, isHttpResourceRef, isFunction, isStateInputShape, isolateValue, isVaultClearState, VAULT_CLEAR_STATE, VAULT_NOOP, VAULT_CONTINUE, isVaultContinue, isUndefined, isDefined, isNullish, ResolveTypes, isPromise, VaultUsagePromiseError, CONTROLLER_META, validateControllerKey
|
|
1
|
+
import { registerVersion, vaultDebug, ControllerVotes, ControllerMessageTypes, OperationTypes, vaultWarn, VaultController, defineControllerKey, ControllerTypes, DevMode, DecisionOutcomeTypes, vaultError, defineBehaviorKey, DEVTOOLS_LOGGING_KEY_CONSTANT, DEVTOOLS_AGGREGATE_KEY_CONSTANT, createVaultError, EventTypes, EventBoundaryTypes, setVaultLogLevel, isTestEnv, BEHAVIOR_META, validateBehaviorKey, BehaviorTypes, VAULT_STOP, isVaultNoop, VaultLicenseError, VaultBehavior, VaultPrivateErrorService, isHttpResourceRef, isFunction, isStateInputShape, isolateValue, isVaultClearState, VAULT_CLEAR_STATE, VAULT_NOOP, VAULT_CONTINUE, isVaultContinue, isUndefined, isDefined, isNullish, ResolveTypes, isPromise, VaultUsagePromiseError, CONTROLLER_META, validateControllerKey } from '@sdux-vault/shared';
|
|
2
2
|
import { of, map, catchError, forkJoin, Subject, ReplaySubject, isObservable, firstValueFrom, tap } from 'rxjs';
|
|
3
3
|
import { __decorate } from 'tslib';
|
|
4
4
|
import { filter } from 'rxjs/operators';
|
|
@@ -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.
|
|
14
|
+
const SDUX_VERSION = '0.9.0';
|
|
15
15
|
registerVersion(SDUX_PACKAGE, SDUX_VERSION);
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -1505,40 +1505,40 @@ const KNOWN_VAULT_KEYS = new Set([
|
|
|
1505
1505
|
// ---------------------------------------------------------------------------
|
|
1506
1506
|
// Core Behaviors (libs/core)
|
|
1507
1507
|
// ---------------------------------------------------------------------------
|
|
1508
|
+
'SDUX::Behavior::Core::AfterTap',
|
|
1509
|
+
'SDUX::Behavior::Core::ArrayMerge',
|
|
1510
|
+
'SDUX::Behavior::Core::BeforeTap',
|
|
1511
|
+
'SDUX::Behavior::Core::EmitState',
|
|
1508
1512
|
'SDUX::Behavior::Core::Error',
|
|
1509
1513
|
'SDUX::Behavior::Core::ErrorCallback',
|
|
1510
1514
|
'SDUX::Behavior::Core::Filter',
|
|
1515
|
+
'SDUX::Behavior::Core::FromObservable',
|
|
1516
|
+
'SDUX::Behavior::Core::FromPromise',
|
|
1517
|
+
'SDUX::Behavior::Core::FromStream',
|
|
1518
|
+
'SDUX::Behavior::Core::ObjectMerge',
|
|
1519
|
+
'SDUX::Behavior::Core::Observable',
|
|
1520
|
+
'SDUX::Behavior::Core::Promise',
|
|
1511
1521
|
'SDUX::Behavior::Core::Reducer',
|
|
1512
|
-
'SDUX::Behavior::Core::BeforeTap',
|
|
1513
|
-
'SDUX::Behavior::Core::AfterTap',
|
|
1514
|
-
'SDUX::Behavior::Core::EmitState',
|
|
1515
1522
|
'SDUX::Behavior::Core::State',
|
|
1516
1523
|
'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
1524
|
// ---------------------------------------------------------------------------
|
|
1525
1525
|
// Addon Behaviors (libs/addons)
|
|
1526
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
1527
|
'SDUX::Behavior::Addon::DistinctUntilChanged',
|
|
1528
|
+
'SDUX::Behavior::Cache::State',
|
|
1529
|
+
'SDUX::Behavior::Core::Lookup',
|
|
1530
|
+
'SDUX::Behavior::Core::Query',
|
|
1531
|
+
'SDUX::Behavior::Encrypt::Aes256',
|
|
1535
1532
|
'SDUX::Behavior::Interceptor::GlobalErrorPause',
|
|
1536
1533
|
'SDUX::Behavior::Merge::ArrayAppend',
|
|
1537
1534
|
'SDUX::Behavior::Merge::ArrayPush',
|
|
1538
1535
|
'SDUX::Behavior::Merge::Deep',
|
|
1539
|
-
'SDUX::Behavior::
|
|
1540
|
-
'SDUX::Behavior::
|
|
1541
|
-
'SDUX::Behavior::
|
|
1536
|
+
'SDUX::Behavior::Persist::CookieStorage',
|
|
1537
|
+
'SDUX::Behavior::Persist::LocalStorage',
|
|
1538
|
+
'SDUX::Behavior::Persist::SessionStorage',
|
|
1539
|
+
'SDUX::Behavior::Policy::StepwiseFilter',
|
|
1540
|
+
'SDUX::Behavior::Policy::StepwiseReducer',
|
|
1541
|
+
'SDUX::Behavior::Policy::StepwiseResolve',
|
|
1542
1542
|
// ---------------------------------------------------------------------------
|
|
1543
1543
|
// Engine Behaviors (vault-engine)
|
|
1544
1544
|
// ---------------------------------------------------------------------------
|
|
@@ -1552,10 +1552,10 @@ const KNOWN_VAULT_KEYS = new Set([
|
|
|
1552
1552
|
// ---------------------------------------------------------------------------
|
|
1553
1553
|
// Addon Controllers (libs/addons)
|
|
1554
1554
|
// ---------------------------------------------------------------------------
|
|
1555
|
+
'SDUX::Controller::Policy::Delay',
|
|
1556
|
+
'SDUX::Controller::Policy::MaxFailures',
|
|
1555
1557
|
'SDUX::Controller::Policy::ReplayGlobalError',
|
|
1556
1558
|
'SDUX::Controller::Policy::Stepwise',
|
|
1557
|
-
'SDUX::Controller::Policy::MaxFailures',
|
|
1558
|
-
'SDUX::Controller::Policy::Delay',
|
|
1559
1559
|
'SDUX::Controller::Policy::Throttle'
|
|
1560
1560
|
]);
|
|
1561
1561
|
|
|
@@ -1573,6 +1573,7 @@ const VAULT_LICENSE_ID = 'sdux-vault';
|
|
|
1573
1573
|
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
1574
1574
|
// cmd+alt+j (see .vscode/keybindings.json)
|
|
1575
1575
|
// --- END AI MODEL FILE PATH ---
|
|
1576
|
+
const CORE_LICENSE_BEHAVIOR_KEY = 'SDUX::Behavior::Core::License';
|
|
1576
1577
|
let instance = null;
|
|
1577
1578
|
function VaultCore(config = {}) {
|
|
1578
1579
|
if (!instance) {
|
|
@@ -1584,6 +1585,7 @@ class VaultCoreInstance {
|
|
|
1584
1585
|
#validaionSub;
|
|
1585
1586
|
#licenseMap = new Map();
|
|
1586
1587
|
#terminalStatus = new Map();
|
|
1588
|
+
#aiAssistEnabled = false;
|
|
1587
1589
|
#bypassLicensing = true;
|
|
1588
1590
|
#licenseTimeoutMs;
|
|
1589
1591
|
// eslint-disable-next-line
|
|
@@ -1623,7 +1625,7 @@ class VaultCoreInstance {
|
|
|
1623
1625
|
this.#vaultConfig = Object.freeze(vaultConfig);
|
|
1624
1626
|
DevMode.setDevMode(this.#vaultConfig.devMode);
|
|
1625
1627
|
setVaultLogLevel(this.#vaultConfig.logLevel);
|
|
1626
|
-
this.#bypassLicensing = config.devMode ? (config.bypassLicensing ??
|
|
1628
|
+
this.#bypassLicensing = config.devMode ? (config.bypassLicensing ?? false) : false;
|
|
1627
1629
|
this.#licenseTimeoutMs = config.licenseTimeoutMs ?? 15_000;
|
|
1628
1630
|
this.#warnIfAccidentalDevMode();
|
|
1629
1631
|
}
|
|
@@ -1828,6 +1830,9 @@ class VaultCoreInstance {
|
|
|
1828
1830
|
return;
|
|
1829
1831
|
this.#applyLicenseValidation(record.behaviors, key, licenseToken, valid);
|
|
1830
1832
|
this.#applyLicenseValidation(record.controllers, key, licenseToken, valid);
|
|
1833
|
+
if (valid && key === CORE_LICENSE_BEHAVIOR_KEY) {
|
|
1834
|
+
this.#enableAiAssist();
|
|
1835
|
+
}
|
|
1831
1836
|
}
|
|
1832
1837
|
#applyLicenseValidation(entities, key, licenseId, valid) {
|
|
1833
1838
|
if (!entities?.has(key))
|
|
@@ -1906,6 +1911,20 @@ class VaultCoreInstance {
|
|
|
1906
1911
|
}
|
|
1907
1912
|
return this.#registry.get(key);
|
|
1908
1913
|
}
|
|
1914
|
+
#enableAiAssist() {
|
|
1915
|
+
if (this.#aiAssistEnabled)
|
|
1916
|
+
return;
|
|
1917
|
+
if (!DevMode.active)
|
|
1918
|
+
return;
|
|
1919
|
+
// istanbul ignore next -- SSR guard; document is always defined in browser tests
|
|
1920
|
+
if (typeof document === 'undefined')
|
|
1921
|
+
return;
|
|
1922
|
+
this.#aiAssistEnabled = true;
|
|
1923
|
+
globalThis.sdux ??= {};
|
|
1924
|
+
globalThis.sdux.debugWidget ??= {};
|
|
1925
|
+
globalThis.sdux.debugWidget.aiAssistEnabled = true;
|
|
1926
|
+
document.dispatchEvent(new CustomEvent('sdux-license-resolved'));
|
|
1927
|
+
}
|
|
1909
1928
|
#injectDebugWidget() {
|
|
1910
1929
|
if (!DevMode.active)
|
|
1911
1930
|
return;
|
|
@@ -2023,8 +2042,6 @@ function isAuthorizedKey(key) {
|
|
|
2023
2042
|
function hasVaultLicense() {
|
|
2024
2043
|
if (!instance)
|
|
2025
2044
|
return false;
|
|
2026
|
-
if (instance.isBypassLicensing())
|
|
2027
|
-
return true;
|
|
2028
2045
|
return instance.hasVaultLicense();
|
|
2029
2046
|
}
|
|
2030
2047
|
|
|
@@ -2295,6 +2312,210 @@ const assignTraceId = () => {
|
|
|
2295
2312
|
*/
|
|
2296
2313
|
const isPipelineTerminal = (current) => isVaultNoop(current) || isSignalStop(current);
|
|
2297
2314
|
|
|
2315
|
+
/**
|
|
2316
|
+
* The public keys
|
|
2317
|
+
*/
|
|
2318
|
+
const PublicKeys = {
|
|
2319
|
+
/**
|
|
2320
|
+
* the pro public key
|
|
2321
|
+
*/
|
|
2322
|
+
pro: `
|
|
2323
|
+
-----BEGIN PUBLIC KEY-----
|
|
2324
|
+
-----END PUBLIC KEY-----
|
|
2325
|
+
`,
|
|
2326
|
+
/**
|
|
2327
|
+
* the enterprise public key
|
|
2328
|
+
*/
|
|
2329
|
+
enterprise: `
|
|
2330
|
+
-----BEGIN PUBLIC KEY-----
|
|
2331
|
+
-----END PUBLIC KEY-----
|
|
2332
|
+
`,
|
|
2333
|
+
/**
|
|
2334
|
+
* the development public key
|
|
2335
|
+
*/
|
|
2336
|
+
development: `
|
|
2337
|
+
-----BEGIN PUBLIC KEY-----
|
|
2338
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6RDckQGY38NrlPq70YfI
|
|
2339
|
+
hIpBFmc9baNLS2HIeyKIU2m+Vvnt3AYcQJlQnzmO4ZLDOUkIP+VxAjaSCaUBeTOx
|
|
2340
|
+
KDYXAK8ds0xEur0cRV4Kn26jhLveLZVpfVzhkOjJ6I9ggLeh5JRt7kj3NPgKwnSm
|
|
2341
|
+
t5DxLh4JPyLfZdBDtW8tU2tCgCfEs2cArrVo/fg7Dei8FJ8w83PDhsKmX5UazSfj
|
|
2342
|
+
MC57gkTZ/cZmKBvVoIhnqaWVXcRRL+wZPArIsO801DRiMAhROyQYyC3EKpGLyUc1
|
|
2343
|
+
1VSKqdmQLIUE1pt151EnmStB+VOsMzCLZH4TyU7cd1Afs2Siqu947W2w4Qpm5+Y/
|
|
2344
|
+
FwIDAQAB
|
|
2345
|
+
-----END PUBLIC KEY-----
|
|
2346
|
+
`
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
/**
|
|
2350
|
+
* Static license verification utility used to validate signed license tokens
|
|
2351
|
+
* against tier-specific public keys. Tokens use a dot-separated format:
|
|
2352
|
+
* `base64(payload).base64(signature)`.
|
|
2353
|
+
*
|
|
2354
|
+
* The verification process:
|
|
2355
|
+
* - Splits the token on `.` to extract the encoded payload and signature
|
|
2356
|
+
* - Decodes the payload from base64 to determine the license tier
|
|
2357
|
+
* - Rejects tokens with missing or unrecognized tier
|
|
2358
|
+
* - Loads the appropriate PEM-encoded public key for the tier
|
|
2359
|
+
* - Uses `crypto.subtle.verify()` (RSA-SHA256) to validate the signature
|
|
2360
|
+
* against the raw base64-encoded payload string
|
|
2361
|
+
*
|
|
2362
|
+
* Verification failures return `false` rather than throwing.
|
|
2363
|
+
*/
|
|
2364
|
+
const VerifyLicenseToken = {
|
|
2365
|
+
/**
|
|
2366
|
+
* Verifies the supplied signed license token using the public key associated
|
|
2367
|
+
* with its declared tier.
|
|
2368
|
+
*
|
|
2369
|
+
* @param token - A dot-separated token in the format
|
|
2370
|
+
* `base64(payload).base64(signature)`.
|
|
2371
|
+
* @returns A promise resolving to `true` if the signature validates;
|
|
2372
|
+
* otherwise `false`.
|
|
2373
|
+
*/
|
|
2374
|
+
verify: async (token) => {
|
|
2375
|
+
try {
|
|
2376
|
+
const dotIndex = token.indexOf('.');
|
|
2377
|
+
if (dotIndex === -1) {
|
|
2378
|
+
return false;
|
|
2379
|
+
}
|
|
2380
|
+
const encodedPayload = token.substring(0, dotIndex);
|
|
2381
|
+
const signatureB64 = token.substring(dotIndex + 1);
|
|
2382
|
+
const payloadJson = atob(encodedPayload);
|
|
2383
|
+
const payload = JSON.parse(payloadJson);
|
|
2384
|
+
const signature = Uint8Array.from(atob(signatureB64), (c) => c.charCodeAt(0));
|
|
2385
|
+
const licenseType = payload?.licenseType;
|
|
2386
|
+
if (!licenseType) {
|
|
2387
|
+
return false;
|
|
2388
|
+
}
|
|
2389
|
+
const keyPem = PublicKeys[licenseType];
|
|
2390
|
+
if (!keyPem)
|
|
2391
|
+
return false;
|
|
2392
|
+
const key = await importPublicKey(keyPem);
|
|
2393
|
+
const verified = await crypto.subtle.verify({
|
|
2394
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
2395
|
+
hash: 'SHA-256'
|
|
2396
|
+
}, key, signature, new TextEncoder().encode(encodedPayload));
|
|
2397
|
+
return verified;
|
|
2398
|
+
}
|
|
2399
|
+
catch {
|
|
2400
|
+
return false;
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
/**
|
|
2405
|
+
* Imports an RSA public key from PEM format into a WebCrypto `CryptoKey`
|
|
2406
|
+
* configured for signature verification.
|
|
2407
|
+
*
|
|
2408
|
+
* @param pem - A PEM-encoded public key in subjectPublicKeyInfo format.
|
|
2409
|
+
* @returns A promise resolving to a usable verification `CryptoKey`.
|
|
2410
|
+
*/
|
|
2411
|
+
async function importPublicKey(pem) {
|
|
2412
|
+
const binaryDer = str2ab(pemToDer(pem));
|
|
2413
|
+
return crypto.subtle.importKey('spki', binaryDer, {
|
|
2414
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
2415
|
+
hash: 'SHA-256'
|
|
2416
|
+
}, false, ['verify']);
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* Converts a PEM-encoded public key into its raw DER body.
|
|
2420
|
+
*
|
|
2421
|
+
* @param pem - The PEM string containing header/footer markers.
|
|
2422
|
+
* @returns A base64-decoded DER binary string.
|
|
2423
|
+
*/
|
|
2424
|
+
function pemToDer(pem) {
|
|
2425
|
+
const b64 = pem.replace(/-----.*KEY-----/g, '').replace(/\s+/g, '');
|
|
2426
|
+
return atob(b64);
|
|
2427
|
+
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Converts a binary string into an `ArrayBuffer`, suitable for WebCrypto key
|
|
2430
|
+
* import operations.
|
|
2431
|
+
*
|
|
2432
|
+
* @param str - A binary string.
|
|
2433
|
+
* @returns An `ArrayBuffer` containing the same byte values.
|
|
2434
|
+
*/
|
|
2435
|
+
function str2ab(str) {
|
|
2436
|
+
const buf = new ArrayBuffer(str.length);
|
|
2437
|
+
const arr = new Uint8Array(buf);
|
|
2438
|
+
for (let i = 0; i < str.length; i++)
|
|
2439
|
+
arr[i] = str.charCodeAt(i);
|
|
2440
|
+
return buf;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
class LicensingAbstract {
|
|
2444
|
+
static needsLicense;
|
|
2445
|
+
static key;
|
|
2446
|
+
#licenseToken;
|
|
2447
|
+
#featureCellKey;
|
|
2448
|
+
#key;
|
|
2449
|
+
#licenseService;
|
|
2450
|
+
constructor(ctx) {
|
|
2451
|
+
const ctor = this.constructor;
|
|
2452
|
+
if (typeof ctor.key !== 'string' || !ctor.key.trim()) {
|
|
2453
|
+
throw new VaultLicenseError(`LicensingClass requires a static "key". Did you forget @VaultBehavior?`);
|
|
2454
|
+
}
|
|
2455
|
+
this.#licenseService = LicensingService();
|
|
2456
|
+
this.#key = ctor.key;
|
|
2457
|
+
this.#featureCellKey = ctx.featureCellKey;
|
|
2458
|
+
if (ctor.needsLicense) {
|
|
2459
|
+
this.#requestLicense();
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
#requestLicense() {
|
|
2463
|
+
this.#licenseToken = this.#licenseService.requestLicense(this.#featureCellKey, this.#key);
|
|
2464
|
+
}
|
|
2465
|
+
validateLicense(valid) {
|
|
2466
|
+
if (!this.#licenseToken) {
|
|
2467
|
+
throw new VaultLicenseError(`validateLicense() called but no license was requested for "${this.#featureCellKey}" and "${this.#key}".`);
|
|
2468
|
+
}
|
|
2469
|
+
this.#licenseService.validateLicense(this.#featureCellKey, this.#key, this.#licenseToken, valid);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
let withCoreLicenseBehavior = class withCoreLicenseBehavior extends LicensingAbstract {
|
|
2474
|
+
behaviorCtx;
|
|
2475
|
+
static type;
|
|
2476
|
+
static key;
|
|
2477
|
+
static critical;
|
|
2478
|
+
static needsLicense;
|
|
2479
|
+
type = BehaviorTypes.CoreLicense;
|
|
2480
|
+
critical = true;
|
|
2481
|
+
key;
|
|
2482
|
+
constructor(key, behaviorCtx) {
|
|
2483
|
+
super(behaviorCtx);
|
|
2484
|
+
this.behaviorCtx = behaviorCtx;
|
|
2485
|
+
this.key = key;
|
|
2486
|
+
this.#performLicenseValidation();
|
|
2487
|
+
}
|
|
2488
|
+
async #performLicenseValidation() {
|
|
2489
|
+
try {
|
|
2490
|
+
const payload = this.behaviorCtx.licensePayload;
|
|
2491
|
+
if (!payload?.token) {
|
|
2492
|
+
this.validateLicense(false);
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
const isValid = await VerifyLicenseToken.verify(payload.token);
|
|
2496
|
+
this.validateLicense(isValid);
|
|
2497
|
+
}
|
|
2498
|
+
catch {
|
|
2499
|
+
this.validateLicense(false);
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
destroy() {
|
|
2503
|
+
vaultWarn(`${this.key} - destroy noop`);
|
|
2504
|
+
}
|
|
2505
|
+
reset() {
|
|
2506
|
+
vaultWarn(`${this.key} - reset noop`);
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
withCoreLicenseBehavior = __decorate([
|
|
2510
|
+
VaultBehavior({
|
|
2511
|
+
type: BehaviorTypes.CoreLicense,
|
|
2512
|
+
key: defineBehaviorKey('Core', 'License'),
|
|
2513
|
+
critical: true,
|
|
2514
|
+
needsLicense: true,
|
|
2515
|
+
licenseId: 'sdux-vault'
|
|
2516
|
+
})
|
|
2517
|
+
], withCoreLicenseBehavior);
|
|
2518
|
+
|
|
2298
2519
|
// --- AI Model File Path (DO NOT DELETE) ---
|
|
2299
2520
|
// FilePath: lib > src > orchestrator > orchestrator.ts
|
|
2300
2521
|
// Updated: 2026-04-07 16:30
|
|
@@ -2436,6 +2657,7 @@ class Orchestrator {
|
|
|
2436
2657
|
defaultBehaviors = this.#determineCoreCallbackErrorBehavior(defaultBehaviors, config);
|
|
2437
2658
|
defaultBehaviors = this.#addDefaultMergeBehavior(defaultBehaviors, config);
|
|
2438
2659
|
defaultBehaviors = this.#addCoreEmitStateCallbackBehavior(defaultBehaviors, config);
|
|
2660
|
+
defaultBehaviors = this.#addCoreLicenseBehavior(defaultBehaviors);
|
|
2439
2661
|
return defaultBehaviors;
|
|
2440
2662
|
}
|
|
2441
2663
|
#determineCoreCallbackErrorBehavior(behaviors, config) {
|
|
@@ -2450,6 +2672,13 @@ class Orchestrator {
|
|
|
2450
2672
|
}
|
|
2451
2673
|
return behaviors;
|
|
2452
2674
|
}
|
|
2675
|
+
#addCoreLicenseBehavior(behaviors) {
|
|
2676
|
+
behaviors = behaviors?.filter((behavior) => behavior.type !== BehaviorTypes.CoreLicense);
|
|
2677
|
+
if (hasVaultLicense()) {
|
|
2678
|
+
behaviors.push(withCoreLicenseBehavior);
|
|
2679
|
+
}
|
|
2680
|
+
return behaviors;
|
|
2681
|
+
}
|
|
2453
2682
|
#registerBehaviorsWithVault(behaviors) {
|
|
2454
2683
|
// eslint-disable-next-line
|
|
2455
2684
|
const behaviorMetadata = behaviors.map((behavior) => {
|
|
@@ -2474,8 +2703,9 @@ class Orchestrator {
|
|
|
2474
2703
|
behavior.type === BehaviorTypes.CoreBeforeTap ||
|
|
2475
2704
|
behavior.type === BehaviorTypes.CoreError ||
|
|
2476
2705
|
behavior.type === BehaviorTypes.CoreErrorCallback ||
|
|
2477
|
-
behavior.type === BehaviorTypes.CoreState ||
|
|
2478
2706
|
behavior.type === BehaviorTypes.CoreEmitState ||
|
|
2707
|
+
behavior.type === BehaviorTypes.CoreLicense ||
|
|
2708
|
+
behavior.type === BehaviorTypes.CoreState ||
|
|
2479
2709
|
behavior.type === BehaviorTypes.Filter ||
|
|
2480
2710
|
behavior.type === BehaviorTypes.FromObservable ||
|
|
2481
2711
|
behavior.type === BehaviorTypes.FromPromise ||
|
|
@@ -4084,36 +4314,6 @@ class FeatureCellClass extends FeatureCellBuilder {
|
|
|
4084
4314
|
}
|
|
4085
4315
|
}
|
|
4086
4316
|
|
|
4087
|
-
class LicensingAbstract {
|
|
4088
|
-
static needsLicense;
|
|
4089
|
-
static key;
|
|
4090
|
-
#licenseToken;
|
|
4091
|
-
#featureCellKey;
|
|
4092
|
-
#key;
|
|
4093
|
-
#licenseService;
|
|
4094
|
-
constructor(ctx) {
|
|
4095
|
-
const ctor = this.constructor;
|
|
4096
|
-
if (typeof ctor.key !== 'string' || !ctor.key.trim()) {
|
|
4097
|
-
throw new VaultLicenseError(`LicensingClass requires a static "key". Did you forget @VaultBehavior?`);
|
|
4098
|
-
}
|
|
4099
|
-
this.#licenseService = LicensingService();
|
|
4100
|
-
this.#key = ctor.key;
|
|
4101
|
-
this.#featureCellKey = ctx.featureCellKey;
|
|
4102
|
-
if (ctor.needsLicense) {
|
|
4103
|
-
this.#requestLicense();
|
|
4104
|
-
}
|
|
4105
|
-
}
|
|
4106
|
-
#requestLicense() {
|
|
4107
|
-
this.#licenseToken = this.#licenseService.requestLicense(this.#featureCellKey, this.#key);
|
|
4108
|
-
}
|
|
4109
|
-
validateLicense(valid) {
|
|
4110
|
-
if (!this.#licenseToken) {
|
|
4111
|
-
throw new VaultLicenseError(`validateLicense() called but no license was requested for "${this.#featureCellKey}" and "${this.#key}".`);
|
|
4112
|
-
}
|
|
4113
|
-
this.#licenseService.validateLicense(this.#featureCellKey, this.#key, this.#licenseToken, valid);
|
|
4114
|
-
}
|
|
4115
|
-
}
|
|
4116
|
-
|
|
4117
4317
|
/**
|
|
4118
4318
|
* The feature cell tokens map
|
|
4119
4319
|
*/
|
|
@@ -4205,5 +4405,5 @@ function resetFeatureCellToken() {
|
|
|
4205
4405
|
* Generated bundle index. Do not edit.
|
|
4206
4406
|
*/
|
|
4207
4407
|
|
|
4208
|
-
export { Conductor, FeatureCellClass, LicensingAbstract, VAULT_LICENSE_ID, VaultCore, createFeatureCellToken, getFeatureCellToken, getLicensePayload, getVaultRegistryForTests, hasVaultLicense, isAuthorizedKey, registerFeatureCell, registerVaultSettled, resetFeatureCellRegistry, resetVaultForTests, vaultAllSettled, vaultSettled };
|
|
4408
|
+
export { Conductor, FeatureCellClass, LicensingAbstract, VAULT_LICENSE_ID, VaultCore, createFeatureCellToken, getFeatureCellToken, getLicensePayload, getVaultRegistryForTests, hasVaultLicense, isAuthorizedKey, isPipelineTerminal, registerFeatureCell, registerVaultSettled, resetFeatureCellRegistry, resetVaultForTests, vaultAllSettled, vaultSettled };
|
|
4209
4409
|
//# sourceMappingURL=sdux-vault-engine.mjs.map
|