chainlesschain 0.145.0 → 0.152.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.
- package/package.json +1 -1
- package/src/commands/activitypub.js +207 -0
- package/src/commands/agent-network.js +217 -0
- package/src/commands/automation.js +201 -0
- package/src/commands/bi.js +203 -0
- package/src/commands/browse.js +213 -0
- package/src/commands/codegen.js +207 -0
- package/src/commands/collab.js +211 -0
- package/src/commands/compliance.js +410 -0
- package/src/commands/cowork.js +203 -0
- package/src/commands/dbevo.js +227 -0
- package/src/commands/dev.js +207 -0
- package/src/commands/did-v2.js +217 -0
- package/src/commands/did.js +221 -0
- package/src/commands/dlp.js +213 -0
- package/src/commands/evomap.js +205 -0
- package/src/commands/export.js +213 -0
- package/src/commands/federation.js +209 -0
- package/src/commands/fusion.js +205 -0
- package/src/commands/governance.js +209 -0
- package/src/commands/hook.js +209 -0
- package/src/commands/import.js +209 -0
- package/src/commands/infra.js +203 -0
- package/src/commands/instinct.js +209 -0
- package/src/commands/ipfs.js +207 -0
- package/src/commands/llm.js +217 -0
- package/src/commands/matrix.js +207 -0
- package/src/commands/mcp.js +217 -0
- package/src/commands/memory.js +209 -0
- package/src/commands/multimodal.js +203 -0
- package/src/commands/nlprog.js +225 -0
- package/src/commands/nostr.js +209 -0
- package/src/commands/note.js +205 -0
- package/src/commands/ops.js +219 -0
- package/src/commands/org.js +209 -0
- package/src/commands/p2p.js +209 -0
- package/src/commands/perception.js +209 -0
- package/src/commands/permmem.js +203 -0
- package/src/commands/plugin-ecosystem.js +209 -0
- package/src/commands/pqc.js +213 -0
- package/src/commands/quantization.js +207 -0
- package/src/commands/rcache.js +205 -0
- package/src/commands/recommend.js +233 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/scim.js +209 -0
- package/src/commands/session.js +209 -0
- package/src/commands/skill.js +207 -0
- package/src/commands/social.js +201 -0
- package/src/commands/sso.js +209 -0
- package/src/commands/sync.js +209 -0
- package/src/commands/tech.js +209 -0
- package/src/commands/tenant.js +217 -0
- package/src/commands/tokens.js +209 -0
- package/src/commands/trust.js +217 -0
- package/src/commands/wallet.js +209 -0
- package/src/commands/workflow.js +203 -0
- package/src/index.js +140 -0
- package/src/lib/activitypub-bridge.js +334 -0
- package/src/lib/agent-network.js +341 -0
- package/src/lib/aiops.js +346 -0
- package/src/lib/automation-engine.js +335 -0
- package/src/lib/autonomous-developer.js +332 -0
- package/src/lib/bi-engine.js +333 -0
- package/src/lib/browser-automation.js +334 -0
- package/src/lib/code-agent.js +339 -0
- package/src/lib/collaboration-governance.js +334 -0
- package/src/lib/community-governance.js +346 -0
- package/src/lib/content-recommendation.js +351 -0
- package/src/lib/cowork-share.js +338 -0
- package/src/lib/dbevo.js +351 -0
- package/src/lib/decentral-infra.js +330 -0
- package/src/lib/did-manager.js +341 -0
- package/src/lib/did-v2-manager.js +341 -0
- package/src/lib/dlp-engine.js +339 -0
- package/src/lib/evomap-governance.js +334 -0
- package/src/lib/federation-hardening.js +340 -0
- package/src/lib/hook-manager.js +341 -0
- package/src/lib/instinct-manager.js +346 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/knowledge-exporter.js +341 -0
- package/src/lib/knowledge-importer.js +341 -0
- package/src/lib/llm-providers.js +346 -0
- package/src/lib/matrix-bridge.js +339 -0
- package/src/lib/mcp-registry.js +346 -0
- package/src/lib/memory-manager.js +336 -0
- package/src/lib/multimodal.js +330 -0
- package/src/lib/nl-programming.js +341 -0
- package/src/lib/nostr-bridge.js +336 -0
- package/src/lib/note-versioning.js +339 -0
- package/src/lib/org-manager.js +336 -0
- package/src/lib/p2p-manager.js +341 -0
- package/src/lib/perception.js +346 -0
- package/src/lib/permanent-memory.js +327 -0
- package/src/lib/plugin-ecosystem.js +346 -0
- package/src/lib/pqc-manager.js +346 -0
- package/src/lib/protocol-fusion.js +338 -0
- package/src/lib/quantization.js +337 -0
- package/src/lib/response-cache.js +333 -0
- package/src/lib/scim-manager.js +346 -0
- package/src/lib/session-manager.js +334 -0
- package/src/lib/skill-loader.js +334 -0
- package/src/lib/social-manager.js +330 -0
- package/src/lib/sso-manager.js +340 -0
- package/src/lib/sync-manager.js +336 -0
- package/src/lib/tech-learning-engine.js +341 -0
- package/src/lib/tenant-saas.js +341 -0
- package/src/lib/threat-intel.js +330 -0
- package/src/lib/token-tracker.js +336 -0
- package/src/lib/trust-security.js +343 -0
- package/src/lib/ueba.js +340 -0
- package/src/lib/universal-runtime.js +330 -0
- package/src/lib/wallet-manager.js +336 -0
- package/src/lib/workflow-engine.js +330 -0
package/src/lib/tenant-saas.js
CHANGED
|
@@ -1289,3 +1289,344 @@ export function _resetStateV2() {
|
|
|
1289
1289
|
_tenantIdleMsV2 = SAAS_DEFAULT_TENANT_IDLE_MS;
|
|
1290
1290
|
_pastDueGraceMsV2 = SAAS_DEFAULT_PAST_DUE_GRACE_MS;
|
|
1291
1291
|
}
|
|
1292
|
+
|
|
1293
|
+
// =====================================================================
|
|
1294
|
+
// tenant-saas V2 governance overlay (iter18)
|
|
1295
|
+
// =====================================================================
|
|
1296
|
+
export const TNSGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
1297
|
+
PENDING: "pending",
|
|
1298
|
+
ACTIVE: "active",
|
|
1299
|
+
SUSPENDED: "suspended",
|
|
1300
|
+
ARCHIVED: "archived",
|
|
1301
|
+
});
|
|
1302
|
+
export const TNSGOV_ALLOCATION_LIFECYCLE_V2 = Object.freeze({
|
|
1303
|
+
QUEUED: "queued",
|
|
1304
|
+
PROVISIONING: "provisioning",
|
|
1305
|
+
PROVISIONED: "provisioned",
|
|
1306
|
+
FAILED: "failed",
|
|
1307
|
+
CANCELLED: "cancelled",
|
|
1308
|
+
});
|
|
1309
|
+
const _tnsgovPTrans = new Map([
|
|
1310
|
+
[
|
|
1311
|
+
TNSGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1312
|
+
new Set([
|
|
1313
|
+
TNSGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1314
|
+
TNSGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1315
|
+
]),
|
|
1316
|
+
],
|
|
1317
|
+
[
|
|
1318
|
+
TNSGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1319
|
+
new Set([
|
|
1320
|
+
TNSGOV_PROFILE_MATURITY_V2.SUSPENDED,
|
|
1321
|
+
TNSGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1322
|
+
]),
|
|
1323
|
+
],
|
|
1324
|
+
[
|
|
1325
|
+
TNSGOV_PROFILE_MATURITY_V2.SUSPENDED,
|
|
1326
|
+
new Set([
|
|
1327
|
+
TNSGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1328
|
+
TNSGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1329
|
+
]),
|
|
1330
|
+
],
|
|
1331
|
+
[TNSGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
1332
|
+
]);
|
|
1333
|
+
const _tnsgovPTerminal = new Set([TNSGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
1334
|
+
const _tnsgovJTrans = new Map([
|
|
1335
|
+
[
|
|
1336
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.QUEUED,
|
|
1337
|
+
new Set([
|
|
1338
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONING,
|
|
1339
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.CANCELLED,
|
|
1340
|
+
]),
|
|
1341
|
+
],
|
|
1342
|
+
[
|
|
1343
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONING,
|
|
1344
|
+
new Set([
|
|
1345
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONED,
|
|
1346
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.FAILED,
|
|
1347
|
+
TNSGOV_ALLOCATION_LIFECYCLE_V2.CANCELLED,
|
|
1348
|
+
]),
|
|
1349
|
+
],
|
|
1350
|
+
[TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONED, new Set()],
|
|
1351
|
+
[TNSGOV_ALLOCATION_LIFECYCLE_V2.FAILED, new Set()],
|
|
1352
|
+
[TNSGOV_ALLOCATION_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
1353
|
+
]);
|
|
1354
|
+
const _tnsgovPsV2 = new Map();
|
|
1355
|
+
const _tnsgovJsV2 = new Map();
|
|
1356
|
+
let _tnsgovMaxActive = 10,
|
|
1357
|
+
_tnsgovMaxPending = 25,
|
|
1358
|
+
_tnsgovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
1359
|
+
_tnsgovStuckMs = 60 * 1000;
|
|
1360
|
+
function _tnsgovPos(n, label) {
|
|
1361
|
+
const v = Math.floor(Number(n));
|
|
1362
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
1363
|
+
throw new Error(`${label} must be positive integer`);
|
|
1364
|
+
return v;
|
|
1365
|
+
}
|
|
1366
|
+
function _tnsgovCheckP(from, to) {
|
|
1367
|
+
const a = _tnsgovPTrans.get(from);
|
|
1368
|
+
if (!a || !a.has(to))
|
|
1369
|
+
throw new Error(`invalid tnsgov profile transition ${from} → ${to}`);
|
|
1370
|
+
}
|
|
1371
|
+
function _tnsgovCheckJ(from, to) {
|
|
1372
|
+
const a = _tnsgovJTrans.get(from);
|
|
1373
|
+
if (!a || !a.has(to))
|
|
1374
|
+
throw new Error(`invalid tnsgov allocation transition ${from} → ${to}`);
|
|
1375
|
+
}
|
|
1376
|
+
function _tnsgovCountActive(owner) {
|
|
1377
|
+
let c = 0;
|
|
1378
|
+
for (const p of _tnsgovPsV2.values())
|
|
1379
|
+
if (p.owner === owner && p.status === TNSGOV_PROFILE_MATURITY_V2.ACTIVE)
|
|
1380
|
+
c++;
|
|
1381
|
+
return c;
|
|
1382
|
+
}
|
|
1383
|
+
function _tnsgovCountPending(profileId) {
|
|
1384
|
+
let c = 0;
|
|
1385
|
+
for (const j of _tnsgovJsV2.values())
|
|
1386
|
+
if (
|
|
1387
|
+
j.profileId === profileId &&
|
|
1388
|
+
(j.status === TNSGOV_ALLOCATION_LIFECYCLE_V2.QUEUED ||
|
|
1389
|
+
j.status === TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONING)
|
|
1390
|
+
)
|
|
1391
|
+
c++;
|
|
1392
|
+
return c;
|
|
1393
|
+
}
|
|
1394
|
+
export function setMaxActiveTnsgovProfilesPerOwnerV2(n) {
|
|
1395
|
+
_tnsgovMaxActive = _tnsgovPos(n, "maxActiveTnsgovProfilesPerOwner");
|
|
1396
|
+
}
|
|
1397
|
+
export function getMaxActiveTnsgovProfilesPerOwnerV2() {
|
|
1398
|
+
return _tnsgovMaxActive;
|
|
1399
|
+
}
|
|
1400
|
+
export function setMaxPendingTnsgovAllocationsPerProfileV2(n) {
|
|
1401
|
+
_tnsgovMaxPending = _tnsgovPos(n, "maxPendingTnsgovAllocationsPerProfile");
|
|
1402
|
+
}
|
|
1403
|
+
export function getMaxPendingTnsgovAllocationsPerProfileV2() {
|
|
1404
|
+
return _tnsgovMaxPending;
|
|
1405
|
+
}
|
|
1406
|
+
export function setTnsgovProfileIdleMsV2(n) {
|
|
1407
|
+
_tnsgovIdleMs = _tnsgovPos(n, "tnsgovProfileIdleMs");
|
|
1408
|
+
}
|
|
1409
|
+
export function getTnsgovProfileIdleMsV2() {
|
|
1410
|
+
return _tnsgovIdleMs;
|
|
1411
|
+
}
|
|
1412
|
+
export function setTnsgovAllocationStuckMsV2(n) {
|
|
1413
|
+
_tnsgovStuckMs = _tnsgovPos(n, "tnsgovAllocationStuckMs");
|
|
1414
|
+
}
|
|
1415
|
+
export function getTnsgovAllocationStuckMsV2() {
|
|
1416
|
+
return _tnsgovStuckMs;
|
|
1417
|
+
}
|
|
1418
|
+
export function _resetStateTenantSaasGovV2() {
|
|
1419
|
+
_tnsgovPsV2.clear();
|
|
1420
|
+
_tnsgovJsV2.clear();
|
|
1421
|
+
_tnsgovMaxActive = 10;
|
|
1422
|
+
_tnsgovMaxPending = 25;
|
|
1423
|
+
_tnsgovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
1424
|
+
_tnsgovStuckMs = 60 * 1000;
|
|
1425
|
+
}
|
|
1426
|
+
export function registerTnsgovProfileV2({ id, owner, plan, metadata } = {}) {
|
|
1427
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
1428
|
+
if (_tnsgovPsV2.has(id))
|
|
1429
|
+
throw new Error(`tnsgov profile ${id} already exists`);
|
|
1430
|
+
const now = Date.now();
|
|
1431
|
+
const p = {
|
|
1432
|
+
id,
|
|
1433
|
+
owner,
|
|
1434
|
+
plan: plan || "free",
|
|
1435
|
+
status: TNSGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1436
|
+
createdAt: now,
|
|
1437
|
+
updatedAt: now,
|
|
1438
|
+
lastTouchedAt: now,
|
|
1439
|
+
activatedAt: null,
|
|
1440
|
+
archivedAt: null,
|
|
1441
|
+
metadata: { ...(metadata || {}) },
|
|
1442
|
+
};
|
|
1443
|
+
_tnsgovPsV2.set(id, p);
|
|
1444
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1445
|
+
}
|
|
1446
|
+
export function activateTnsgovProfileV2(id) {
|
|
1447
|
+
const p = _tnsgovPsV2.get(id);
|
|
1448
|
+
if (!p) throw new Error(`tnsgov profile ${id} not found`);
|
|
1449
|
+
const isInitial = p.status === TNSGOV_PROFILE_MATURITY_V2.PENDING;
|
|
1450
|
+
_tnsgovCheckP(p.status, TNSGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
1451
|
+
if (isInitial && _tnsgovCountActive(p.owner) >= _tnsgovMaxActive)
|
|
1452
|
+
throw new Error(`max active tnsgov profiles for owner ${p.owner} reached`);
|
|
1453
|
+
const now = Date.now();
|
|
1454
|
+
p.status = TNSGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
1455
|
+
p.updatedAt = now;
|
|
1456
|
+
p.lastTouchedAt = now;
|
|
1457
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
1458
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1459
|
+
}
|
|
1460
|
+
export function suspendTnsgovProfileV2(id) {
|
|
1461
|
+
const p = _tnsgovPsV2.get(id);
|
|
1462
|
+
if (!p) throw new Error(`tnsgov profile ${id} not found`);
|
|
1463
|
+
_tnsgovCheckP(p.status, TNSGOV_PROFILE_MATURITY_V2.SUSPENDED);
|
|
1464
|
+
p.status = TNSGOV_PROFILE_MATURITY_V2.SUSPENDED;
|
|
1465
|
+
p.updatedAt = Date.now();
|
|
1466
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1467
|
+
}
|
|
1468
|
+
export function archiveTnsgovProfileV2(id) {
|
|
1469
|
+
const p = _tnsgovPsV2.get(id);
|
|
1470
|
+
if (!p) throw new Error(`tnsgov profile ${id} not found`);
|
|
1471
|
+
_tnsgovCheckP(p.status, TNSGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
1472
|
+
const now = Date.now();
|
|
1473
|
+
p.status = TNSGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
1474
|
+
p.updatedAt = now;
|
|
1475
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
1476
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1477
|
+
}
|
|
1478
|
+
export function touchTnsgovProfileV2(id) {
|
|
1479
|
+
const p = _tnsgovPsV2.get(id);
|
|
1480
|
+
if (!p) throw new Error(`tnsgov profile ${id} not found`);
|
|
1481
|
+
if (_tnsgovPTerminal.has(p.status))
|
|
1482
|
+
throw new Error(`cannot touch terminal tnsgov profile ${id}`);
|
|
1483
|
+
const now = Date.now();
|
|
1484
|
+
p.lastTouchedAt = now;
|
|
1485
|
+
p.updatedAt = now;
|
|
1486
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1487
|
+
}
|
|
1488
|
+
export function getTnsgovProfileV2(id) {
|
|
1489
|
+
const p = _tnsgovPsV2.get(id);
|
|
1490
|
+
if (!p) return null;
|
|
1491
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1492
|
+
}
|
|
1493
|
+
export function listTnsgovProfilesV2() {
|
|
1494
|
+
return [..._tnsgovPsV2.values()].map((p) => ({
|
|
1495
|
+
...p,
|
|
1496
|
+
metadata: { ...p.metadata },
|
|
1497
|
+
}));
|
|
1498
|
+
}
|
|
1499
|
+
export function createTnsgovAllocationV2({
|
|
1500
|
+
id,
|
|
1501
|
+
profileId,
|
|
1502
|
+
resource,
|
|
1503
|
+
metadata,
|
|
1504
|
+
} = {}) {
|
|
1505
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
1506
|
+
if (_tnsgovJsV2.has(id))
|
|
1507
|
+
throw new Error(`tnsgov allocation ${id} already exists`);
|
|
1508
|
+
if (!_tnsgovPsV2.has(profileId))
|
|
1509
|
+
throw new Error(`tnsgov profile ${profileId} not found`);
|
|
1510
|
+
if (_tnsgovCountPending(profileId) >= _tnsgovMaxPending)
|
|
1511
|
+
throw new Error(
|
|
1512
|
+
`max pending tnsgov allocations for profile ${profileId} reached`,
|
|
1513
|
+
);
|
|
1514
|
+
const now = Date.now();
|
|
1515
|
+
const j = {
|
|
1516
|
+
id,
|
|
1517
|
+
profileId,
|
|
1518
|
+
resource: resource || "",
|
|
1519
|
+
status: TNSGOV_ALLOCATION_LIFECYCLE_V2.QUEUED,
|
|
1520
|
+
createdAt: now,
|
|
1521
|
+
updatedAt: now,
|
|
1522
|
+
startedAt: null,
|
|
1523
|
+
settledAt: null,
|
|
1524
|
+
metadata: { ...(metadata || {}) },
|
|
1525
|
+
};
|
|
1526
|
+
_tnsgovJsV2.set(id, j);
|
|
1527
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1528
|
+
}
|
|
1529
|
+
export function provisioningTnsgovAllocationV2(id) {
|
|
1530
|
+
const j = _tnsgovJsV2.get(id);
|
|
1531
|
+
if (!j) throw new Error(`tnsgov allocation ${id} not found`);
|
|
1532
|
+
_tnsgovCheckJ(j.status, TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONING);
|
|
1533
|
+
const now = Date.now();
|
|
1534
|
+
j.status = TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONING;
|
|
1535
|
+
j.updatedAt = now;
|
|
1536
|
+
if (!j.startedAt) j.startedAt = now;
|
|
1537
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1538
|
+
}
|
|
1539
|
+
export function completeAllocationTnsgovV2(id) {
|
|
1540
|
+
const j = _tnsgovJsV2.get(id);
|
|
1541
|
+
if (!j) throw new Error(`tnsgov allocation ${id} not found`);
|
|
1542
|
+
_tnsgovCheckJ(j.status, TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONED);
|
|
1543
|
+
const now = Date.now();
|
|
1544
|
+
j.status = TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONED;
|
|
1545
|
+
j.updatedAt = now;
|
|
1546
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1547
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1548
|
+
}
|
|
1549
|
+
export function failTnsgovAllocationV2(id, reason) {
|
|
1550
|
+
const j = _tnsgovJsV2.get(id);
|
|
1551
|
+
if (!j) throw new Error(`tnsgov allocation ${id} not found`);
|
|
1552
|
+
_tnsgovCheckJ(j.status, TNSGOV_ALLOCATION_LIFECYCLE_V2.FAILED);
|
|
1553
|
+
const now = Date.now();
|
|
1554
|
+
j.status = TNSGOV_ALLOCATION_LIFECYCLE_V2.FAILED;
|
|
1555
|
+
j.updatedAt = now;
|
|
1556
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1557
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
1558
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1559
|
+
}
|
|
1560
|
+
export function cancelTnsgovAllocationV2(id, reason) {
|
|
1561
|
+
const j = _tnsgovJsV2.get(id);
|
|
1562
|
+
if (!j) throw new Error(`tnsgov allocation ${id} not found`);
|
|
1563
|
+
_tnsgovCheckJ(j.status, TNSGOV_ALLOCATION_LIFECYCLE_V2.CANCELLED);
|
|
1564
|
+
const now = Date.now();
|
|
1565
|
+
j.status = TNSGOV_ALLOCATION_LIFECYCLE_V2.CANCELLED;
|
|
1566
|
+
j.updatedAt = now;
|
|
1567
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1568
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
1569
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1570
|
+
}
|
|
1571
|
+
export function getTnsgovAllocationV2(id) {
|
|
1572
|
+
const j = _tnsgovJsV2.get(id);
|
|
1573
|
+
if (!j) return null;
|
|
1574
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1575
|
+
}
|
|
1576
|
+
export function listTnsgovAllocationsV2() {
|
|
1577
|
+
return [..._tnsgovJsV2.values()].map((j) => ({
|
|
1578
|
+
...j,
|
|
1579
|
+
metadata: { ...j.metadata },
|
|
1580
|
+
}));
|
|
1581
|
+
}
|
|
1582
|
+
export function autoSuspendIdleTnsgovProfilesV2({ now } = {}) {
|
|
1583
|
+
const t = now ?? Date.now();
|
|
1584
|
+
const flipped = [];
|
|
1585
|
+
for (const p of _tnsgovPsV2.values())
|
|
1586
|
+
if (
|
|
1587
|
+
p.status === TNSGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
1588
|
+
t - p.lastTouchedAt >= _tnsgovIdleMs
|
|
1589
|
+
) {
|
|
1590
|
+
p.status = TNSGOV_PROFILE_MATURITY_V2.SUSPENDED;
|
|
1591
|
+
p.updatedAt = t;
|
|
1592
|
+
flipped.push(p.id);
|
|
1593
|
+
}
|
|
1594
|
+
return { flipped, count: flipped.length };
|
|
1595
|
+
}
|
|
1596
|
+
export function autoFailStuckTnsgovAllocationsV2({ now } = {}) {
|
|
1597
|
+
const t = now ?? Date.now();
|
|
1598
|
+
const flipped = [];
|
|
1599
|
+
for (const j of _tnsgovJsV2.values())
|
|
1600
|
+
if (
|
|
1601
|
+
j.status === TNSGOV_ALLOCATION_LIFECYCLE_V2.PROVISIONING &&
|
|
1602
|
+
j.startedAt != null &&
|
|
1603
|
+
t - j.startedAt >= _tnsgovStuckMs
|
|
1604
|
+
) {
|
|
1605
|
+
j.status = TNSGOV_ALLOCATION_LIFECYCLE_V2.FAILED;
|
|
1606
|
+
j.updatedAt = t;
|
|
1607
|
+
if (!j.settledAt) j.settledAt = t;
|
|
1608
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
1609
|
+
flipped.push(j.id);
|
|
1610
|
+
}
|
|
1611
|
+
return { flipped, count: flipped.length };
|
|
1612
|
+
}
|
|
1613
|
+
export function getTenantSaasGovStatsV2() {
|
|
1614
|
+
const profilesByStatus = {};
|
|
1615
|
+
for (const v of Object.values(TNSGOV_PROFILE_MATURITY_V2))
|
|
1616
|
+
profilesByStatus[v] = 0;
|
|
1617
|
+
for (const p of _tnsgovPsV2.values()) profilesByStatus[p.status]++;
|
|
1618
|
+
const allocationsByStatus = {};
|
|
1619
|
+
for (const v of Object.values(TNSGOV_ALLOCATION_LIFECYCLE_V2))
|
|
1620
|
+
allocationsByStatus[v] = 0;
|
|
1621
|
+
for (const j of _tnsgovJsV2.values()) allocationsByStatus[j.status]++;
|
|
1622
|
+
return {
|
|
1623
|
+
totalTnsgovProfilesV2: _tnsgovPsV2.size,
|
|
1624
|
+
totalTnsgovAllocationsV2: _tnsgovJsV2.size,
|
|
1625
|
+
maxActiveTnsgovProfilesPerOwner: _tnsgovMaxActive,
|
|
1626
|
+
maxPendingTnsgovAllocationsPerProfile: _tnsgovMaxPending,
|
|
1627
|
+
tnsgovProfileIdleMs: _tnsgovIdleMs,
|
|
1628
|
+
tnsgovAllocationStuckMs: _tnsgovStuckMs,
|
|
1629
|
+
profilesByStatus,
|
|
1630
|
+
allocationsByStatus,
|
|
1631
|
+
};
|
|
1632
|
+
}
|
package/src/lib/threat-intel.js
CHANGED
|
@@ -601,3 +601,333 @@ export function _resetStateThreatIntelV2() {
|
|
|
601
601
|
_feedIdleMsV2 = TI_DEFAULT_FEED_IDLE_MS;
|
|
602
602
|
_indicatorStaleMsV2 = TI_DEFAULT_INDICATOR_STALE_MS;
|
|
603
603
|
}
|
|
604
|
+
|
|
605
|
+
// =====================================================================
|
|
606
|
+
// threat-intel V2 governance overlay (iter24)
|
|
607
|
+
// =====================================================================
|
|
608
|
+
export const TIGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
609
|
+
PENDING: "pending",
|
|
610
|
+
ACTIVE: "active",
|
|
611
|
+
STALE: "stale",
|
|
612
|
+
ARCHIVED: "archived",
|
|
613
|
+
});
|
|
614
|
+
export const TIGOV_FEED_LIFECYCLE_V2 = Object.freeze({
|
|
615
|
+
QUEUED: "queued",
|
|
616
|
+
INGESTING: "ingesting",
|
|
617
|
+
INGESTED: "ingested",
|
|
618
|
+
FAILED: "failed",
|
|
619
|
+
CANCELLED: "cancelled",
|
|
620
|
+
});
|
|
621
|
+
const _tigovPTrans = new Map([
|
|
622
|
+
[
|
|
623
|
+
TIGOV_PROFILE_MATURITY_V2.PENDING,
|
|
624
|
+
new Set([
|
|
625
|
+
TIGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
626
|
+
TIGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
627
|
+
]),
|
|
628
|
+
],
|
|
629
|
+
[
|
|
630
|
+
TIGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
631
|
+
new Set([
|
|
632
|
+
TIGOV_PROFILE_MATURITY_V2.STALE,
|
|
633
|
+
TIGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
634
|
+
]),
|
|
635
|
+
],
|
|
636
|
+
[
|
|
637
|
+
TIGOV_PROFILE_MATURITY_V2.STALE,
|
|
638
|
+
new Set([
|
|
639
|
+
TIGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
640
|
+
TIGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
641
|
+
]),
|
|
642
|
+
],
|
|
643
|
+
[TIGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
644
|
+
]);
|
|
645
|
+
const _tigovPTerminal = new Set([TIGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
646
|
+
const _tigovJTrans = new Map([
|
|
647
|
+
[
|
|
648
|
+
TIGOV_FEED_LIFECYCLE_V2.QUEUED,
|
|
649
|
+
new Set([
|
|
650
|
+
TIGOV_FEED_LIFECYCLE_V2.INGESTING,
|
|
651
|
+
TIGOV_FEED_LIFECYCLE_V2.CANCELLED,
|
|
652
|
+
]),
|
|
653
|
+
],
|
|
654
|
+
[
|
|
655
|
+
TIGOV_FEED_LIFECYCLE_V2.INGESTING,
|
|
656
|
+
new Set([
|
|
657
|
+
TIGOV_FEED_LIFECYCLE_V2.INGESTED,
|
|
658
|
+
TIGOV_FEED_LIFECYCLE_V2.FAILED,
|
|
659
|
+
TIGOV_FEED_LIFECYCLE_V2.CANCELLED,
|
|
660
|
+
]),
|
|
661
|
+
],
|
|
662
|
+
[TIGOV_FEED_LIFECYCLE_V2.INGESTED, new Set()],
|
|
663
|
+
[TIGOV_FEED_LIFECYCLE_V2.FAILED, new Set()],
|
|
664
|
+
[TIGOV_FEED_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
665
|
+
]);
|
|
666
|
+
const _tigovPsV2 = new Map();
|
|
667
|
+
const _tigovJsV2 = new Map();
|
|
668
|
+
let _tigovMaxActive = 6,
|
|
669
|
+
_tigovMaxPending = 15,
|
|
670
|
+
_tigovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
671
|
+
_tigovStuckMs = 60 * 1000;
|
|
672
|
+
function _tigovPos(n, label) {
|
|
673
|
+
const v = Math.floor(Number(n));
|
|
674
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
675
|
+
throw new Error(`${label} must be positive integer`);
|
|
676
|
+
return v;
|
|
677
|
+
}
|
|
678
|
+
function _tigovCheckP(from, to) {
|
|
679
|
+
const a = _tigovPTrans.get(from);
|
|
680
|
+
if (!a || !a.has(to))
|
|
681
|
+
throw new Error(`invalid tigov profile transition ${from} → ${to}`);
|
|
682
|
+
}
|
|
683
|
+
function _tigovCheckJ(from, to) {
|
|
684
|
+
const a = _tigovJTrans.get(from);
|
|
685
|
+
if (!a || !a.has(to))
|
|
686
|
+
throw new Error(`invalid tigov feed transition ${from} → ${to}`);
|
|
687
|
+
}
|
|
688
|
+
function _tigovCountActive(owner) {
|
|
689
|
+
let c = 0;
|
|
690
|
+
for (const p of _tigovPsV2.values())
|
|
691
|
+
if (p.owner === owner && p.status === TIGOV_PROFILE_MATURITY_V2.ACTIVE) c++;
|
|
692
|
+
return c;
|
|
693
|
+
}
|
|
694
|
+
function _tigovCountPending(profileId) {
|
|
695
|
+
let c = 0;
|
|
696
|
+
for (const j of _tigovJsV2.values())
|
|
697
|
+
if (
|
|
698
|
+
j.profileId === profileId &&
|
|
699
|
+
(j.status === TIGOV_FEED_LIFECYCLE_V2.QUEUED ||
|
|
700
|
+
j.status === TIGOV_FEED_LIFECYCLE_V2.INGESTING)
|
|
701
|
+
)
|
|
702
|
+
c++;
|
|
703
|
+
return c;
|
|
704
|
+
}
|
|
705
|
+
export function setMaxActiveTigovProfilesPerOwnerV2(n) {
|
|
706
|
+
_tigovMaxActive = _tigovPos(n, "maxActiveTigovProfilesPerOwner");
|
|
707
|
+
}
|
|
708
|
+
export function getMaxActiveTigovProfilesPerOwnerV2() {
|
|
709
|
+
return _tigovMaxActive;
|
|
710
|
+
}
|
|
711
|
+
export function setMaxPendingTigovFeedsPerProfileV2(n) {
|
|
712
|
+
_tigovMaxPending = _tigovPos(n, "maxPendingTigovFeedsPerProfile");
|
|
713
|
+
}
|
|
714
|
+
export function getMaxPendingTigovFeedsPerProfileV2() {
|
|
715
|
+
return _tigovMaxPending;
|
|
716
|
+
}
|
|
717
|
+
export function setTigovProfileIdleMsV2(n) {
|
|
718
|
+
_tigovIdleMs = _tigovPos(n, "tigovProfileIdleMs");
|
|
719
|
+
}
|
|
720
|
+
export function getTigovProfileIdleMsV2() {
|
|
721
|
+
return _tigovIdleMs;
|
|
722
|
+
}
|
|
723
|
+
export function setTigovFeedStuckMsV2(n) {
|
|
724
|
+
_tigovStuckMs = _tigovPos(n, "tigovFeedStuckMs");
|
|
725
|
+
}
|
|
726
|
+
export function getTigovFeedStuckMsV2() {
|
|
727
|
+
return _tigovStuckMs;
|
|
728
|
+
}
|
|
729
|
+
export function _resetStateThreatIntelGovV2() {
|
|
730
|
+
_tigovPsV2.clear();
|
|
731
|
+
_tigovJsV2.clear();
|
|
732
|
+
_tigovMaxActive = 6;
|
|
733
|
+
_tigovMaxPending = 15;
|
|
734
|
+
_tigovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
735
|
+
_tigovStuckMs = 60 * 1000;
|
|
736
|
+
}
|
|
737
|
+
export function registerTigovProfileV2({ id, owner, source, metadata } = {}) {
|
|
738
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
739
|
+
if (_tigovPsV2.has(id)) throw new Error(`tigov profile ${id} already exists`);
|
|
740
|
+
const now = Date.now();
|
|
741
|
+
const p = {
|
|
742
|
+
id,
|
|
743
|
+
owner,
|
|
744
|
+
source: source || "otx",
|
|
745
|
+
status: TIGOV_PROFILE_MATURITY_V2.PENDING,
|
|
746
|
+
createdAt: now,
|
|
747
|
+
updatedAt: now,
|
|
748
|
+
lastTouchedAt: now,
|
|
749
|
+
activatedAt: null,
|
|
750
|
+
archivedAt: null,
|
|
751
|
+
metadata: { ...(metadata || {}) },
|
|
752
|
+
};
|
|
753
|
+
_tigovPsV2.set(id, p);
|
|
754
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
755
|
+
}
|
|
756
|
+
export function activateTigovProfileV2(id) {
|
|
757
|
+
const p = _tigovPsV2.get(id);
|
|
758
|
+
if (!p) throw new Error(`tigov profile ${id} not found`);
|
|
759
|
+
const isInitial = p.status === TIGOV_PROFILE_MATURITY_V2.PENDING;
|
|
760
|
+
_tigovCheckP(p.status, TIGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
761
|
+
if (isInitial && _tigovCountActive(p.owner) >= _tigovMaxActive)
|
|
762
|
+
throw new Error(`max active tigov profiles for owner ${p.owner} reached`);
|
|
763
|
+
const now = Date.now();
|
|
764
|
+
p.status = TIGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
765
|
+
p.updatedAt = now;
|
|
766
|
+
p.lastTouchedAt = now;
|
|
767
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
768
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
769
|
+
}
|
|
770
|
+
export function staleTigovProfileV2(id) {
|
|
771
|
+
const p = _tigovPsV2.get(id);
|
|
772
|
+
if (!p) throw new Error(`tigov profile ${id} not found`);
|
|
773
|
+
_tigovCheckP(p.status, TIGOV_PROFILE_MATURITY_V2.STALE);
|
|
774
|
+
p.status = TIGOV_PROFILE_MATURITY_V2.STALE;
|
|
775
|
+
p.updatedAt = Date.now();
|
|
776
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
777
|
+
}
|
|
778
|
+
export function archiveTigovProfileV2(id) {
|
|
779
|
+
const p = _tigovPsV2.get(id);
|
|
780
|
+
if (!p) throw new Error(`tigov profile ${id} not found`);
|
|
781
|
+
_tigovCheckP(p.status, TIGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
782
|
+
const now = Date.now();
|
|
783
|
+
p.status = TIGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
784
|
+
p.updatedAt = now;
|
|
785
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
786
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
787
|
+
}
|
|
788
|
+
export function touchTigovProfileV2(id) {
|
|
789
|
+
const p = _tigovPsV2.get(id);
|
|
790
|
+
if (!p) throw new Error(`tigov profile ${id} not found`);
|
|
791
|
+
if (_tigovPTerminal.has(p.status))
|
|
792
|
+
throw new Error(`cannot touch terminal tigov profile ${id}`);
|
|
793
|
+
const now = Date.now();
|
|
794
|
+
p.lastTouchedAt = now;
|
|
795
|
+
p.updatedAt = now;
|
|
796
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
797
|
+
}
|
|
798
|
+
export function getTigovProfileV2(id) {
|
|
799
|
+
const p = _tigovPsV2.get(id);
|
|
800
|
+
if (!p) return null;
|
|
801
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
802
|
+
}
|
|
803
|
+
export function listTigovProfilesV2() {
|
|
804
|
+
return [..._tigovPsV2.values()].map((p) => ({
|
|
805
|
+
...p,
|
|
806
|
+
metadata: { ...p.metadata },
|
|
807
|
+
}));
|
|
808
|
+
}
|
|
809
|
+
export function createTigovFeedV2({ id, profileId, indicator, metadata } = {}) {
|
|
810
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
811
|
+
if (_tigovJsV2.has(id)) throw new Error(`tigov feed ${id} already exists`);
|
|
812
|
+
if (!_tigovPsV2.has(profileId))
|
|
813
|
+
throw new Error(`tigov profile ${profileId} not found`);
|
|
814
|
+
if (_tigovCountPending(profileId) >= _tigovMaxPending)
|
|
815
|
+
throw new Error(`max pending tigov feeds for profile ${profileId} reached`);
|
|
816
|
+
const now = Date.now();
|
|
817
|
+
const j = {
|
|
818
|
+
id,
|
|
819
|
+
profileId,
|
|
820
|
+
indicator: indicator || "",
|
|
821
|
+
status: TIGOV_FEED_LIFECYCLE_V2.QUEUED,
|
|
822
|
+
createdAt: now,
|
|
823
|
+
updatedAt: now,
|
|
824
|
+
startedAt: null,
|
|
825
|
+
settledAt: null,
|
|
826
|
+
metadata: { ...(metadata || {}) },
|
|
827
|
+
};
|
|
828
|
+
_tigovJsV2.set(id, j);
|
|
829
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
830
|
+
}
|
|
831
|
+
export function ingestingTigovFeedV2(id) {
|
|
832
|
+
const j = _tigovJsV2.get(id);
|
|
833
|
+
if (!j) throw new Error(`tigov feed ${id} not found`);
|
|
834
|
+
_tigovCheckJ(j.status, TIGOV_FEED_LIFECYCLE_V2.INGESTING);
|
|
835
|
+
const now = Date.now();
|
|
836
|
+
j.status = TIGOV_FEED_LIFECYCLE_V2.INGESTING;
|
|
837
|
+
j.updatedAt = now;
|
|
838
|
+
if (!j.startedAt) j.startedAt = now;
|
|
839
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
840
|
+
}
|
|
841
|
+
export function completeFeedTigovV2(id) {
|
|
842
|
+
const j = _tigovJsV2.get(id);
|
|
843
|
+
if (!j) throw new Error(`tigov feed ${id} not found`);
|
|
844
|
+
_tigovCheckJ(j.status, TIGOV_FEED_LIFECYCLE_V2.INGESTED);
|
|
845
|
+
const now = Date.now();
|
|
846
|
+
j.status = TIGOV_FEED_LIFECYCLE_V2.INGESTED;
|
|
847
|
+
j.updatedAt = now;
|
|
848
|
+
if (!j.settledAt) j.settledAt = now;
|
|
849
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
850
|
+
}
|
|
851
|
+
export function failTigovFeedV2(id, reason) {
|
|
852
|
+
const j = _tigovJsV2.get(id);
|
|
853
|
+
if (!j) throw new Error(`tigov feed ${id} not found`);
|
|
854
|
+
_tigovCheckJ(j.status, TIGOV_FEED_LIFECYCLE_V2.FAILED);
|
|
855
|
+
const now = Date.now();
|
|
856
|
+
j.status = TIGOV_FEED_LIFECYCLE_V2.FAILED;
|
|
857
|
+
j.updatedAt = now;
|
|
858
|
+
if (!j.settledAt) j.settledAt = now;
|
|
859
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
860
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
861
|
+
}
|
|
862
|
+
export function cancelTigovFeedV2(id, reason) {
|
|
863
|
+
const j = _tigovJsV2.get(id);
|
|
864
|
+
if (!j) throw new Error(`tigov feed ${id} not found`);
|
|
865
|
+
_tigovCheckJ(j.status, TIGOV_FEED_LIFECYCLE_V2.CANCELLED);
|
|
866
|
+
const now = Date.now();
|
|
867
|
+
j.status = TIGOV_FEED_LIFECYCLE_V2.CANCELLED;
|
|
868
|
+
j.updatedAt = now;
|
|
869
|
+
if (!j.settledAt) j.settledAt = now;
|
|
870
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
871
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
872
|
+
}
|
|
873
|
+
export function getTigovFeedV2(id) {
|
|
874
|
+
const j = _tigovJsV2.get(id);
|
|
875
|
+
if (!j) return null;
|
|
876
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
877
|
+
}
|
|
878
|
+
export function listTigovFeedsV2() {
|
|
879
|
+
return [..._tigovJsV2.values()].map((j) => ({
|
|
880
|
+
...j,
|
|
881
|
+
metadata: { ...j.metadata },
|
|
882
|
+
}));
|
|
883
|
+
}
|
|
884
|
+
export function autoStaleIdleTigovProfilesV2({ now } = {}) {
|
|
885
|
+
const t = now ?? Date.now();
|
|
886
|
+
const flipped = [];
|
|
887
|
+
for (const p of _tigovPsV2.values())
|
|
888
|
+
if (
|
|
889
|
+
p.status === TIGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
890
|
+
t - p.lastTouchedAt >= _tigovIdleMs
|
|
891
|
+
) {
|
|
892
|
+
p.status = TIGOV_PROFILE_MATURITY_V2.STALE;
|
|
893
|
+
p.updatedAt = t;
|
|
894
|
+
flipped.push(p.id);
|
|
895
|
+
}
|
|
896
|
+
return { flipped, count: flipped.length };
|
|
897
|
+
}
|
|
898
|
+
export function autoFailStuckTigovFeedsV2({ now } = {}) {
|
|
899
|
+
const t = now ?? Date.now();
|
|
900
|
+
const flipped = [];
|
|
901
|
+
for (const j of _tigovJsV2.values())
|
|
902
|
+
if (
|
|
903
|
+
j.status === TIGOV_FEED_LIFECYCLE_V2.INGESTING &&
|
|
904
|
+
j.startedAt != null &&
|
|
905
|
+
t - j.startedAt >= _tigovStuckMs
|
|
906
|
+
) {
|
|
907
|
+
j.status = TIGOV_FEED_LIFECYCLE_V2.FAILED;
|
|
908
|
+
j.updatedAt = t;
|
|
909
|
+
if (!j.settledAt) j.settledAt = t;
|
|
910
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
911
|
+
flipped.push(j.id);
|
|
912
|
+
}
|
|
913
|
+
return { flipped, count: flipped.length };
|
|
914
|
+
}
|
|
915
|
+
export function getThreatIntelGovStatsV2() {
|
|
916
|
+
const profilesByStatus = {};
|
|
917
|
+
for (const v of Object.values(TIGOV_PROFILE_MATURITY_V2))
|
|
918
|
+
profilesByStatus[v] = 0;
|
|
919
|
+
for (const p of _tigovPsV2.values()) profilesByStatus[p.status]++;
|
|
920
|
+
const feedsByStatus = {};
|
|
921
|
+
for (const v of Object.values(TIGOV_FEED_LIFECYCLE_V2)) feedsByStatus[v] = 0;
|
|
922
|
+
for (const j of _tigovJsV2.values()) feedsByStatus[j.status]++;
|
|
923
|
+
return {
|
|
924
|
+
totalTigovProfilesV2: _tigovPsV2.size,
|
|
925
|
+
totalTigovFeedsV2: _tigovJsV2.size,
|
|
926
|
+
maxActiveTigovProfilesPerOwner: _tigovMaxActive,
|
|
927
|
+
maxPendingTigovFeedsPerProfile: _tigovMaxPending,
|
|
928
|
+
tigovProfileIdleMs: _tigovIdleMs,
|
|
929
|
+
tigovFeedStuckMs: _tigovStuckMs,
|
|
930
|
+
profilesByStatus,
|
|
931
|
+
feedsByStatus,
|
|
932
|
+
};
|
|
933
|
+
}
|