@nextera.one/axis-server-sdk 2.2.8 → 2.2.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-DEh3s2yx.d.ts → index-Dci5tlZE.d.ts} +4 -2
- package/dist/{index-CZ3RXsBC.d.mts → index-DypvaTKs.d.mts} +4 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +308 -290
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +308 -290
- package/dist/index.mjs.map +1 -1
- package/dist/sensors/index.d.mts +3 -3
- package/dist/sensors/index.d.ts +3 -3
- package/dist/sensors/index.js +308 -290
- package/dist/sensors/index.js.map +1 -1
- package/dist/sensors/index.mjs +308 -290
- package/dist/sensors/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/sensors/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { m as AccessProfileResolverSensor, Y as BodyBudgetSensor, $ as CapabilityEnforcementSensor, a4 as ChunkHashSensor, a7 as EntropySensor, a9 as ExecutionTimeoutSensor, ab as FrameBudgetSensor, ac as FrameHeaderSanitySensor, ad as HeaderTLVLimitSensor, ah as IntentAllowlistSensor, ak as IntentRegistrySensor, am as LawEvaluationSensor, as as ProofPresenceSensor, at as ProtocolStrictSensor, av as ReceiptPolicySensor, aB as RiskGateSensor, aC as RiskGateSensorOptions, aE as RiskSignalCollector, aG as SchemaValidationSensor, aI as StreamScopeSensor, aJ as TLVParseSensor, aM as TickAuthCapsuleRef, aN as TickAuthSensor, aO as TickAuthSensorOptions, aP as TickAuthVerifier, a_ as TpsSensor, a$ as TpsSensorOptions, b0 as VarintHardeningSensor } from '../index-
|
|
1
|
+
export { m as AccessProfileResolverSensor, Y as BodyBudgetSensor, $ as CapabilityEnforcementSensor, a4 as ChunkHashSensor, a7 as EntropySensor, a9 as ExecutionTimeoutSensor, ab as FrameBudgetSensor, ac as FrameHeaderSanitySensor, ad as HeaderTLVLimitSensor, ah as IntentAllowlistSensor, ak as IntentRegistrySensor, am as LawEvaluationSensor, as as ProofPresenceSensor, at as ProtocolStrictSensor, av as ReceiptPolicySensor, aB as RiskGateSensor, aC as RiskGateSensorOptions, aE as RiskSignalCollector, aG as SchemaValidationSensor, aI as StreamScopeSensor, aJ as TLVParseSensor, aM as TickAuthCapsuleRef, aN as TickAuthSensor, aO as TickAuthSensorOptions, aP as TickAuthVerifier, a_ as TpsSensor, a$ as TpsSensorOptions, b0 as VarintHardeningSensor } from '../index-DypvaTKs.mjs';
|
|
2
2
|
import '../axis-sensor-DMW4rfRg.mjs';
|
|
3
|
-
import '../cce-pipeline-CBt56guN.mjs';
|
|
4
|
-
import '@nextera.one/axis-protocol';
|
|
5
3
|
import 'zod';
|
|
4
|
+
import '@nextera.one/axis-protocol';
|
|
5
|
+
import '../cce-pipeline-CBt56guN.mjs';
|
package/dist/sensors/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { m as AccessProfileResolverSensor, Y as BodyBudgetSensor, $ as CapabilityEnforcementSensor, a4 as ChunkHashSensor, a7 as EntropySensor, a9 as ExecutionTimeoutSensor, ab as FrameBudgetSensor, ac as FrameHeaderSanitySensor, ad as HeaderTLVLimitSensor, ah as IntentAllowlistSensor, ak as IntentRegistrySensor, am as LawEvaluationSensor, as as ProofPresenceSensor, at as ProtocolStrictSensor, av as ReceiptPolicySensor, aB as RiskGateSensor, aC as RiskGateSensorOptions, aE as RiskSignalCollector, aG as SchemaValidationSensor, aI as StreamScopeSensor, aJ as TLVParseSensor, aM as TickAuthCapsuleRef, aN as TickAuthSensor, aO as TickAuthSensorOptions, aP as TickAuthVerifier, a_ as TpsSensor, a$ as TpsSensorOptions, b0 as VarintHardeningSensor } from '../index-
|
|
1
|
+
export { m as AccessProfileResolverSensor, Y as BodyBudgetSensor, $ as CapabilityEnforcementSensor, a4 as ChunkHashSensor, a7 as EntropySensor, a9 as ExecutionTimeoutSensor, ab as FrameBudgetSensor, ac as FrameHeaderSanitySensor, ad as HeaderTLVLimitSensor, ah as IntentAllowlistSensor, ak as IntentRegistrySensor, am as LawEvaluationSensor, as as ProofPresenceSensor, at as ProtocolStrictSensor, av as ReceiptPolicySensor, aB as RiskGateSensor, aC as RiskGateSensorOptions, aE as RiskSignalCollector, aG as SchemaValidationSensor, aI as StreamScopeSensor, aJ as TLVParseSensor, aM as TickAuthCapsuleRef, aN as TickAuthSensor, aO as TickAuthSensorOptions, aP as TickAuthVerifier, a_ as TpsSensor, a$ as TpsSensorOptions, b0 as VarintHardeningSensor } from '../index-Dci5tlZE.js';
|
|
2
2
|
import '../axis-sensor-DMW4rfRg.js';
|
|
3
|
-
import '../cce-pipeline-BJ-F1isr.js';
|
|
4
|
-
import '@nextera.one/axis-protocol';
|
|
5
3
|
import 'zod';
|
|
4
|
+
import '@nextera.one/axis-protocol';
|
|
5
|
+
import '../cce-pipeline-BJ-F1isr.js';
|
package/dist/sensors/index.js
CHANGED
|
@@ -516,7 +516,7 @@ function AxisRateLimit(config) {
|
|
|
516
516
|
return descriptor;
|
|
517
517
|
};
|
|
518
518
|
}
|
|
519
|
-
var import_reflect_metadata4, AXIS_META_KEY, SENSITIVITY_METADATA_KEY, CONTRACT_METADATA_KEY, REQUIRED_PROOF_METADATA_KEY, AXIS_PUBLIC_KEY, AXIS_ANONYMOUS_KEY, AXIS_RATE_LIMIT_KEY;
|
|
519
|
+
var import_reflect_metadata4, AXIS_META_KEY, SENSITIVITY_METADATA_KEY, CONTRACT_METADATA_KEY, REQUIRED_PROOF_METADATA_KEY, AXIS_PUBLIC_KEY, AXIS_ANONYMOUS_KEY, AXIS_AUTHORIZED_KEY, AXIS_RATE_LIMIT_KEY;
|
|
520
520
|
var init_intent_policy_decorator = __esm({
|
|
521
521
|
"src/decorators/intent-policy.decorator.ts"() {
|
|
522
522
|
import_reflect_metadata4 = require("reflect-metadata");
|
|
@@ -526,6 +526,7 @@ var init_intent_policy_decorator = __esm({
|
|
|
526
526
|
REQUIRED_PROOF_METADATA_KEY = "axis:required_proof";
|
|
527
527
|
AXIS_PUBLIC_KEY = "axis:public";
|
|
528
528
|
AXIS_ANONYMOUS_KEY = "axis:anonymous";
|
|
529
|
+
AXIS_AUTHORIZED_KEY = "axis:authorized";
|
|
529
530
|
AXIS_RATE_LIMIT_KEY = "axis:rateLimit";
|
|
530
531
|
}
|
|
531
532
|
});
|
|
@@ -1545,6 +1546,271 @@ var init_axis_chain_executor = __esm({
|
|
|
1545
1546
|
}
|
|
1546
1547
|
});
|
|
1547
1548
|
|
|
1549
|
+
// src/security/scopes.ts
|
|
1550
|
+
function hasScope(scopes, required) {
|
|
1551
|
+
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
1552
|
+
return false;
|
|
1553
|
+
}
|
|
1554
|
+
if (scopes.includes(required)) {
|
|
1555
|
+
return true;
|
|
1556
|
+
}
|
|
1557
|
+
const [resource, id] = required.split(":");
|
|
1558
|
+
if (resource && id) {
|
|
1559
|
+
const wildcard = `${resource}:*`;
|
|
1560
|
+
if (scopes.includes(wildcard)) {
|
|
1561
|
+
return true;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
return false;
|
|
1565
|
+
}
|
|
1566
|
+
function parseScope(scope) {
|
|
1567
|
+
const parts = scope.split(":");
|
|
1568
|
+
if (parts.length !== 2) return null;
|
|
1569
|
+
return { resource: parts[0], id: parts[1] };
|
|
1570
|
+
}
|
|
1571
|
+
function canAccessResource(scopes, resourceType, resourceId) {
|
|
1572
|
+
const required = `${resourceType}:${resourceId}`;
|
|
1573
|
+
return hasScope(scopes, required);
|
|
1574
|
+
}
|
|
1575
|
+
var init_scopes = __esm({
|
|
1576
|
+
"src/security/scopes.ts"() {
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1580
|
+
// src/security/inline-capsule.ts
|
|
1581
|
+
function normalizeInlineCapsule(input) {
|
|
1582
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
const raw = input;
|
|
1586
|
+
const scopes = normalizeStringList(raw.scopes ?? raw.scope);
|
|
1587
|
+
return {
|
|
1588
|
+
id: normalizeScalar(raw.id),
|
|
1589
|
+
actorId: normalizeScalar(raw.actorId),
|
|
1590
|
+
intents: normalizeStringList(raw.intents),
|
|
1591
|
+
issuedAt: normalizeTimestamp(raw.issuedAt ?? raw.iat),
|
|
1592
|
+
expiresAt: normalizeTimestamp(raw.expiresAt ?? raw.exp),
|
|
1593
|
+
realm: normalizeScalar(raw.realm),
|
|
1594
|
+
node: normalizeScalar(raw.node),
|
|
1595
|
+
scopes,
|
|
1596
|
+
raw
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
function inlineCapsuleAllowsIntent(capsule, intent) {
|
|
1600
|
+
if (!capsule.intents || capsule.intents.length === 0) {
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
for (const pattern of capsule.intents) {
|
|
1604
|
+
if (pattern === "*" || pattern === intent) {
|
|
1605
|
+
return true;
|
|
1606
|
+
}
|
|
1607
|
+
if (pattern.endsWith(".*")) {
|
|
1608
|
+
const prefix = pattern.slice(0, -1);
|
|
1609
|
+
if (intent.startsWith(prefix)) {
|
|
1610
|
+
return true;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
return false;
|
|
1615
|
+
}
|
|
1616
|
+
function isInlineCapsuleExpired(capsule, clockSkewMs = 3e4) {
|
|
1617
|
+
if (capsule.expiresAt === void 0) {
|
|
1618
|
+
return false;
|
|
1619
|
+
}
|
|
1620
|
+
return BigInt(Date.now()) > capsule.expiresAt + BigInt(clockSkewMs);
|
|
1621
|
+
}
|
|
1622
|
+
function resolvePolicyScopes(scopes, context) {
|
|
1623
|
+
return scopes.map(
|
|
1624
|
+
(scope) => scope.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
|
|
1625
|
+
const resolved = resolveTemplateExpression(expression.trim(), context);
|
|
1626
|
+
if (resolved === void 0 || resolved === null || resolved === "") {
|
|
1627
|
+
throw new Error(`CAPSULE_SCOPE_TEMPLATE_UNRESOLVED:${expression}`);
|
|
1628
|
+
}
|
|
1629
|
+
return String(resolved);
|
|
1630
|
+
})
|
|
1631
|
+
);
|
|
1632
|
+
}
|
|
1633
|
+
function inlineCapsuleSatisfiesScopes(capsule, requiredScopes, mode = "all") {
|
|
1634
|
+
if (!capsule.scopes || capsule.scopes.length === 0) {
|
|
1635
|
+
return false;
|
|
1636
|
+
}
|
|
1637
|
+
if (mode === "any") {
|
|
1638
|
+
return requiredScopes.some((scope) => hasScope(capsule.scopes, scope));
|
|
1639
|
+
}
|
|
1640
|
+
return requiredScopes.every((scope) => hasScope(capsule.scopes, scope));
|
|
1641
|
+
}
|
|
1642
|
+
function resolveTemplateExpression(expression, context) {
|
|
1643
|
+
if (expression === "intent") {
|
|
1644
|
+
return context.intent;
|
|
1645
|
+
}
|
|
1646
|
+
if (expression === "actorId") {
|
|
1647
|
+
return context.actorId;
|
|
1648
|
+
}
|
|
1649
|
+
if (expression === "chainId") {
|
|
1650
|
+
return context.chainId;
|
|
1651
|
+
}
|
|
1652
|
+
if (expression === "stepId") {
|
|
1653
|
+
return context.stepId;
|
|
1654
|
+
}
|
|
1655
|
+
if (expression.startsWith("body.")) {
|
|
1656
|
+
return getNestedValue(context.body, expression.slice(5));
|
|
1657
|
+
}
|
|
1658
|
+
return void 0;
|
|
1659
|
+
}
|
|
1660
|
+
function getNestedValue(value, path2) {
|
|
1661
|
+
if (!value || typeof value !== "object") {
|
|
1662
|
+
return void 0;
|
|
1663
|
+
}
|
|
1664
|
+
return path2.split(".").reduce((current, segment) => {
|
|
1665
|
+
if (!current || typeof current !== "object") {
|
|
1666
|
+
return void 0;
|
|
1667
|
+
}
|
|
1668
|
+
return current[segment];
|
|
1669
|
+
}, value);
|
|
1670
|
+
}
|
|
1671
|
+
function normalizeScalar(value) {
|
|
1672
|
+
if (typeof value === "string") {
|
|
1673
|
+
return value;
|
|
1674
|
+
}
|
|
1675
|
+
if (value instanceof Uint8Array) {
|
|
1676
|
+
return Buffer.from(value).toString("hex");
|
|
1677
|
+
}
|
|
1678
|
+
return void 0;
|
|
1679
|
+
}
|
|
1680
|
+
function normalizeStringList(value) {
|
|
1681
|
+
if (!value) {
|
|
1682
|
+
return void 0;
|
|
1683
|
+
}
|
|
1684
|
+
const list = Array.isArray(value) ? value : [value];
|
|
1685
|
+
const normalized = list.map((entry) => typeof entry === "string" ? entry : void 0).filter((entry) => !!entry && entry.trim().length > 0);
|
|
1686
|
+
return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
|
|
1687
|
+
}
|
|
1688
|
+
function normalizeTimestamp(value) {
|
|
1689
|
+
if (typeof value === "bigint") {
|
|
1690
|
+
return value;
|
|
1691
|
+
}
|
|
1692
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1693
|
+
return BigInt(Math.trunc(value));
|
|
1694
|
+
}
|
|
1695
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
1696
|
+
try {
|
|
1697
|
+
return BigInt(value);
|
|
1698
|
+
} catch {
|
|
1699
|
+
return void 0;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
return void 0;
|
|
1703
|
+
}
|
|
1704
|
+
var init_inline_capsule = __esm({
|
|
1705
|
+
"src/security/inline-capsule.ts"() {
|
|
1706
|
+
init_scopes();
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1710
|
+
// src/sensor/axis-sensor.ts
|
|
1711
|
+
function normalizeSensorDecision(sensorDecision) {
|
|
1712
|
+
if ("action" in sensorDecision) {
|
|
1713
|
+
switch (sensorDecision.action) {
|
|
1714
|
+
case "ALLOW":
|
|
1715
|
+
return {
|
|
1716
|
+
allow: true,
|
|
1717
|
+
riskScore: 0,
|
|
1718
|
+
reasons: [],
|
|
1719
|
+
meta: sensorDecision.meta
|
|
1720
|
+
};
|
|
1721
|
+
case "DENY":
|
|
1722
|
+
return {
|
|
1723
|
+
allow: false,
|
|
1724
|
+
riskScore: 100,
|
|
1725
|
+
reasons: [sensorDecision.code, sensorDecision.reason].filter(
|
|
1726
|
+
Boolean
|
|
1727
|
+
),
|
|
1728
|
+
meta: sensorDecision.meta,
|
|
1729
|
+
retryAfterMs: sensorDecision.retryAfterMs
|
|
1730
|
+
};
|
|
1731
|
+
case "THROTTLE":
|
|
1732
|
+
return {
|
|
1733
|
+
allow: false,
|
|
1734
|
+
riskScore: 50,
|
|
1735
|
+
reasons: ["RATE_LIMIT"],
|
|
1736
|
+
retryAfterMs: sensorDecision.retryAfterMs,
|
|
1737
|
+
meta: sensorDecision.meta
|
|
1738
|
+
};
|
|
1739
|
+
case "FLAG":
|
|
1740
|
+
return {
|
|
1741
|
+
allow: true,
|
|
1742
|
+
riskScore: sensorDecision.scoreDelta,
|
|
1743
|
+
reasons: sensorDecision.reasons,
|
|
1744
|
+
meta: sensorDecision.meta
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return {
|
|
1749
|
+
allow: sensorDecision.allow,
|
|
1750
|
+
riskScore: sensorDecision.riskScore,
|
|
1751
|
+
reasons: sensorDecision.reasons,
|
|
1752
|
+
tags: sensorDecision.tags,
|
|
1753
|
+
meta: sensorDecision.meta,
|
|
1754
|
+
tighten: sensorDecision.tighten,
|
|
1755
|
+
retryAfterMs: sensorDecision.retryAfterMs
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
var Decision, SensorDecisions;
|
|
1759
|
+
var init_axis_sensor = __esm({
|
|
1760
|
+
"src/sensor/axis-sensor.ts"() {
|
|
1761
|
+
Decision = /* @__PURE__ */ ((Decision2) => {
|
|
1762
|
+
Decision2["ALLOW"] = "ALLOW";
|
|
1763
|
+
Decision2["DENY"] = "DENY";
|
|
1764
|
+
Decision2["THROTTLE"] = "THROTTLE";
|
|
1765
|
+
Decision2["FLAG"] = "FLAG";
|
|
1766
|
+
return Decision2;
|
|
1767
|
+
})(Decision || {});
|
|
1768
|
+
SensorDecisions = {
|
|
1769
|
+
allow(meta, tags) {
|
|
1770
|
+
return {
|
|
1771
|
+
decision: "ALLOW" /* ALLOW */,
|
|
1772
|
+
allow: true,
|
|
1773
|
+
riskScore: 0,
|
|
1774
|
+
reasons: [],
|
|
1775
|
+
tags,
|
|
1776
|
+
meta
|
|
1777
|
+
};
|
|
1778
|
+
},
|
|
1779
|
+
deny(code, reason, meta) {
|
|
1780
|
+
return {
|
|
1781
|
+
decision: "DENY" /* DENY */,
|
|
1782
|
+
allow: false,
|
|
1783
|
+
riskScore: 100,
|
|
1784
|
+
code,
|
|
1785
|
+
reasons: [code, reason].filter(Boolean),
|
|
1786
|
+
meta
|
|
1787
|
+
};
|
|
1788
|
+
},
|
|
1789
|
+
throttle(retryAfterMs, meta) {
|
|
1790
|
+
return {
|
|
1791
|
+
decision: "THROTTLE" /* THROTTLE */,
|
|
1792
|
+
allow: false,
|
|
1793
|
+
riskScore: 50,
|
|
1794
|
+
retryAfterMs,
|
|
1795
|
+
code: "RATE_LIMIT",
|
|
1796
|
+
reasons: ["RATE_LIMIT"],
|
|
1797
|
+
meta
|
|
1798
|
+
};
|
|
1799
|
+
},
|
|
1800
|
+
flag(scoreDelta, reasons, meta) {
|
|
1801
|
+
return {
|
|
1802
|
+
decision: "FLAG" /* FLAG */,
|
|
1803
|
+
allow: true,
|
|
1804
|
+
riskScore: scoreDelta,
|
|
1805
|
+
scoreDelta,
|
|
1806
|
+
reasons,
|
|
1807
|
+
meta
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
|
|
1548
1814
|
// src/cce/cce.types.ts
|
|
1549
1815
|
var CCE_PROTOCOL_VERSION, CCE_DERIVATION, CCE_AES_KEY_BYTES, CCE_IV_BYTES, CCE_NONCE_BYTES, CCE_ERROR, CceError;
|
|
1550
1816
|
var init_cce_types = __esm({
|
|
@@ -1914,124 +2180,20 @@ function computeExecutionContextHash(axisLocalSecret, capsule, requestNonce) {
|
|
|
1914
2180
|
return hash;
|
|
1915
2181
|
}
|
|
1916
2182
|
function hexToBytes2(hex) {
|
|
1917
|
-
const bytes2 = new Uint8Array(hex.length / 2);
|
|
1918
|
-
for (let i = 0; i < bytes2.length; i++) {
|
|
1919
|
-
bytes2[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
1920
|
-
}
|
|
1921
|
-
return bytes2;
|
|
1922
|
-
}
|
|
1923
|
-
var import_utils4, import_hkdf2, import_sha23;
|
|
1924
|
-
var init_cce_witness_observer = __esm({
|
|
1925
|
-
"src/cce/cce-witness.observer.ts"() {
|
|
1926
|
-
import_utils4 = require("@noble/hashes/utils.js");
|
|
1927
|
-
import_hkdf2 = require("@noble/hashes/hkdf.js");
|
|
1928
|
-
import_sha23 = require("@noble/hashes/sha2.js");
|
|
1929
|
-
init_cce_crypto();
|
|
1930
|
-
init_cce_types();
|
|
1931
|
-
}
|
|
1932
|
-
});
|
|
1933
|
-
|
|
1934
|
-
// src/sensor/axis-sensor.ts
|
|
1935
|
-
function normalizeSensorDecision(sensorDecision) {
|
|
1936
|
-
if ("action" in sensorDecision) {
|
|
1937
|
-
switch (sensorDecision.action) {
|
|
1938
|
-
case "ALLOW":
|
|
1939
|
-
return {
|
|
1940
|
-
allow: true,
|
|
1941
|
-
riskScore: 0,
|
|
1942
|
-
reasons: [],
|
|
1943
|
-
meta: sensorDecision.meta
|
|
1944
|
-
};
|
|
1945
|
-
case "DENY":
|
|
1946
|
-
return {
|
|
1947
|
-
allow: false,
|
|
1948
|
-
riskScore: 100,
|
|
1949
|
-
reasons: [sensorDecision.code, sensorDecision.reason].filter(
|
|
1950
|
-
Boolean
|
|
1951
|
-
),
|
|
1952
|
-
meta: sensorDecision.meta,
|
|
1953
|
-
retryAfterMs: sensorDecision.retryAfterMs
|
|
1954
|
-
};
|
|
1955
|
-
case "THROTTLE":
|
|
1956
|
-
return {
|
|
1957
|
-
allow: false,
|
|
1958
|
-
riskScore: 50,
|
|
1959
|
-
reasons: ["RATE_LIMIT"],
|
|
1960
|
-
retryAfterMs: sensorDecision.retryAfterMs,
|
|
1961
|
-
meta: sensorDecision.meta
|
|
1962
|
-
};
|
|
1963
|
-
case "FLAG":
|
|
1964
|
-
return {
|
|
1965
|
-
allow: true,
|
|
1966
|
-
riskScore: sensorDecision.scoreDelta,
|
|
1967
|
-
reasons: sensorDecision.reasons,
|
|
1968
|
-
meta: sensorDecision.meta
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
return {
|
|
1973
|
-
allow: sensorDecision.allow,
|
|
1974
|
-
riskScore: sensorDecision.riskScore,
|
|
1975
|
-
reasons: sensorDecision.reasons,
|
|
1976
|
-
tags: sensorDecision.tags,
|
|
1977
|
-
meta: sensorDecision.meta,
|
|
1978
|
-
tighten: sensorDecision.tighten,
|
|
1979
|
-
retryAfterMs: sensorDecision.retryAfterMs
|
|
1980
|
-
};
|
|
2183
|
+
const bytes2 = new Uint8Array(hex.length / 2);
|
|
2184
|
+
for (let i = 0; i < bytes2.length; i++) {
|
|
2185
|
+
bytes2[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
2186
|
+
}
|
|
2187
|
+
return bytes2;
|
|
1981
2188
|
}
|
|
1982
|
-
var
|
|
1983
|
-
var
|
|
1984
|
-
"src/
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
return Decision2;
|
|
1991
|
-
})(Decision || {});
|
|
1992
|
-
SensorDecisions = {
|
|
1993
|
-
allow(meta, tags) {
|
|
1994
|
-
return {
|
|
1995
|
-
decision: "ALLOW" /* ALLOW */,
|
|
1996
|
-
allow: true,
|
|
1997
|
-
riskScore: 0,
|
|
1998
|
-
reasons: [],
|
|
1999
|
-
tags,
|
|
2000
|
-
meta
|
|
2001
|
-
};
|
|
2002
|
-
},
|
|
2003
|
-
deny(code, reason, meta) {
|
|
2004
|
-
return {
|
|
2005
|
-
decision: "DENY" /* DENY */,
|
|
2006
|
-
allow: false,
|
|
2007
|
-
riskScore: 100,
|
|
2008
|
-
code,
|
|
2009
|
-
reasons: [code, reason].filter(Boolean),
|
|
2010
|
-
meta
|
|
2011
|
-
};
|
|
2012
|
-
},
|
|
2013
|
-
throttle(retryAfterMs, meta) {
|
|
2014
|
-
return {
|
|
2015
|
-
decision: "THROTTLE" /* THROTTLE */,
|
|
2016
|
-
allow: false,
|
|
2017
|
-
riskScore: 50,
|
|
2018
|
-
retryAfterMs,
|
|
2019
|
-
code: "RATE_LIMIT",
|
|
2020
|
-
reasons: ["RATE_LIMIT"],
|
|
2021
|
-
meta
|
|
2022
|
-
};
|
|
2023
|
-
},
|
|
2024
|
-
flag(scoreDelta, reasons, meta) {
|
|
2025
|
-
return {
|
|
2026
|
-
decision: "FLAG" /* FLAG */,
|
|
2027
|
-
allow: true,
|
|
2028
|
-
riskScore: scoreDelta,
|
|
2029
|
-
scoreDelta,
|
|
2030
|
-
reasons,
|
|
2031
|
-
meta
|
|
2032
|
-
};
|
|
2033
|
-
}
|
|
2034
|
-
};
|
|
2189
|
+
var import_utils4, import_hkdf2, import_sha23;
|
|
2190
|
+
var init_cce_witness_observer = __esm({
|
|
2191
|
+
"src/cce/cce-witness.observer.ts"() {
|
|
2192
|
+
import_utils4 = require("@noble/hashes/utils.js");
|
|
2193
|
+
import_hkdf2 = require("@noble/hashes/hkdf.js");
|
|
2194
|
+
import_sha23 = require("@noble/hashes/sha2.js");
|
|
2195
|
+
init_cce_crypto();
|
|
2196
|
+
init_cce_types();
|
|
2035
2197
|
}
|
|
2036
2198
|
});
|
|
2037
2199
|
|
|
@@ -2283,167 +2445,6 @@ var init_axis_error = __esm({
|
|
|
2283
2445
|
}
|
|
2284
2446
|
});
|
|
2285
2447
|
|
|
2286
|
-
// src/security/scopes.ts
|
|
2287
|
-
function hasScope(scopes, required) {
|
|
2288
|
-
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
2289
|
-
return false;
|
|
2290
|
-
}
|
|
2291
|
-
if (scopes.includes(required)) {
|
|
2292
|
-
return true;
|
|
2293
|
-
}
|
|
2294
|
-
const [resource, id] = required.split(":");
|
|
2295
|
-
if (resource && id) {
|
|
2296
|
-
const wildcard = `${resource}:*`;
|
|
2297
|
-
if (scopes.includes(wildcard)) {
|
|
2298
|
-
return true;
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
return false;
|
|
2302
|
-
}
|
|
2303
|
-
function parseScope(scope) {
|
|
2304
|
-
const parts = scope.split(":");
|
|
2305
|
-
if (parts.length !== 2) return null;
|
|
2306
|
-
return { resource: parts[0], id: parts[1] };
|
|
2307
|
-
}
|
|
2308
|
-
function canAccessResource(scopes, resourceType, resourceId) {
|
|
2309
|
-
const required = `${resourceType}:${resourceId}`;
|
|
2310
|
-
return hasScope(scopes, required);
|
|
2311
|
-
}
|
|
2312
|
-
var init_scopes = __esm({
|
|
2313
|
-
"src/security/scopes.ts"() {
|
|
2314
|
-
}
|
|
2315
|
-
});
|
|
2316
|
-
|
|
2317
|
-
// src/security/inline-capsule.ts
|
|
2318
|
-
function normalizeInlineCapsule(input) {
|
|
2319
|
-
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
2320
|
-
return null;
|
|
2321
|
-
}
|
|
2322
|
-
const raw = input;
|
|
2323
|
-
const scopes = normalizeStringList(raw.scopes ?? raw.scope);
|
|
2324
|
-
return {
|
|
2325
|
-
id: normalizeScalar(raw.id),
|
|
2326
|
-
actorId: normalizeScalar(raw.actorId),
|
|
2327
|
-
intents: normalizeStringList(raw.intents),
|
|
2328
|
-
issuedAt: normalizeTimestamp(raw.issuedAt ?? raw.iat),
|
|
2329
|
-
expiresAt: normalizeTimestamp(raw.expiresAt ?? raw.exp),
|
|
2330
|
-
realm: normalizeScalar(raw.realm),
|
|
2331
|
-
node: normalizeScalar(raw.node),
|
|
2332
|
-
scopes,
|
|
2333
|
-
raw
|
|
2334
|
-
};
|
|
2335
|
-
}
|
|
2336
|
-
function inlineCapsuleAllowsIntent(capsule, intent) {
|
|
2337
|
-
if (!capsule.intents || capsule.intents.length === 0) {
|
|
2338
|
-
return false;
|
|
2339
|
-
}
|
|
2340
|
-
for (const pattern of capsule.intents) {
|
|
2341
|
-
if (pattern === "*" || pattern === intent) {
|
|
2342
|
-
return true;
|
|
2343
|
-
}
|
|
2344
|
-
if (pattern.endsWith(".*")) {
|
|
2345
|
-
const prefix = pattern.slice(0, -1);
|
|
2346
|
-
if (intent.startsWith(prefix)) {
|
|
2347
|
-
return true;
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
return false;
|
|
2352
|
-
}
|
|
2353
|
-
function isInlineCapsuleExpired(capsule, clockSkewMs = 3e4) {
|
|
2354
|
-
if (capsule.expiresAt === void 0) {
|
|
2355
|
-
return false;
|
|
2356
|
-
}
|
|
2357
|
-
return BigInt(Date.now()) > capsule.expiresAt + BigInt(clockSkewMs);
|
|
2358
|
-
}
|
|
2359
|
-
function resolvePolicyScopes(scopes, context) {
|
|
2360
|
-
return scopes.map(
|
|
2361
|
-
(scope) => scope.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
|
|
2362
|
-
const resolved = resolveTemplateExpression(expression.trim(), context);
|
|
2363
|
-
if (resolved === void 0 || resolved === null || resolved === "") {
|
|
2364
|
-
throw new Error(`CAPSULE_SCOPE_TEMPLATE_UNRESOLVED:${expression}`);
|
|
2365
|
-
}
|
|
2366
|
-
return String(resolved);
|
|
2367
|
-
})
|
|
2368
|
-
);
|
|
2369
|
-
}
|
|
2370
|
-
function inlineCapsuleSatisfiesScopes(capsule, requiredScopes, mode = "all") {
|
|
2371
|
-
if (!capsule.scopes || capsule.scopes.length === 0) {
|
|
2372
|
-
return false;
|
|
2373
|
-
}
|
|
2374
|
-
if (mode === "any") {
|
|
2375
|
-
return requiredScopes.some((scope) => hasScope(capsule.scopes, scope));
|
|
2376
|
-
}
|
|
2377
|
-
return requiredScopes.every((scope) => hasScope(capsule.scopes, scope));
|
|
2378
|
-
}
|
|
2379
|
-
function resolveTemplateExpression(expression, context) {
|
|
2380
|
-
if (expression === "intent") {
|
|
2381
|
-
return context.intent;
|
|
2382
|
-
}
|
|
2383
|
-
if (expression === "actorId") {
|
|
2384
|
-
return context.actorId;
|
|
2385
|
-
}
|
|
2386
|
-
if (expression === "chainId") {
|
|
2387
|
-
return context.chainId;
|
|
2388
|
-
}
|
|
2389
|
-
if (expression === "stepId") {
|
|
2390
|
-
return context.stepId;
|
|
2391
|
-
}
|
|
2392
|
-
if (expression.startsWith("body.")) {
|
|
2393
|
-
return getNestedValue(context.body, expression.slice(5));
|
|
2394
|
-
}
|
|
2395
|
-
return void 0;
|
|
2396
|
-
}
|
|
2397
|
-
function getNestedValue(value, path2) {
|
|
2398
|
-
if (!value || typeof value !== "object") {
|
|
2399
|
-
return void 0;
|
|
2400
|
-
}
|
|
2401
|
-
return path2.split(".").reduce((current, segment) => {
|
|
2402
|
-
if (!current || typeof current !== "object") {
|
|
2403
|
-
return void 0;
|
|
2404
|
-
}
|
|
2405
|
-
return current[segment];
|
|
2406
|
-
}, value);
|
|
2407
|
-
}
|
|
2408
|
-
function normalizeScalar(value) {
|
|
2409
|
-
if (typeof value === "string") {
|
|
2410
|
-
return value;
|
|
2411
|
-
}
|
|
2412
|
-
if (value instanceof Uint8Array) {
|
|
2413
|
-
return Buffer.from(value).toString("hex");
|
|
2414
|
-
}
|
|
2415
|
-
return void 0;
|
|
2416
|
-
}
|
|
2417
|
-
function normalizeStringList(value) {
|
|
2418
|
-
if (!value) {
|
|
2419
|
-
return void 0;
|
|
2420
|
-
}
|
|
2421
|
-
const list = Array.isArray(value) ? value : [value];
|
|
2422
|
-
const normalized = list.map((entry) => typeof entry === "string" ? entry : void 0).filter((entry) => !!entry && entry.trim().length > 0);
|
|
2423
|
-
return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
|
|
2424
|
-
}
|
|
2425
|
-
function normalizeTimestamp(value) {
|
|
2426
|
-
if (typeof value === "bigint") {
|
|
2427
|
-
return value;
|
|
2428
|
-
}
|
|
2429
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
2430
|
-
return BigInt(Math.trunc(value));
|
|
2431
|
-
}
|
|
2432
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
2433
|
-
try {
|
|
2434
|
-
return BigInt(value);
|
|
2435
|
-
} catch {
|
|
2436
|
-
return void 0;
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
return void 0;
|
|
2440
|
-
}
|
|
2441
|
-
var init_inline_capsule = __esm({
|
|
2442
|
-
"src/security/inline-capsule.ts"() {
|
|
2443
|
-
init_scopes();
|
|
2444
|
-
}
|
|
2445
|
-
});
|
|
2446
|
-
|
|
2447
2448
|
// src/engine/intent.router.ts
|
|
2448
2449
|
var intent_router_exports = {};
|
|
2449
2450
|
__export(intent_router_exports, {
|
|
@@ -2517,23 +2518,23 @@ var import_axis_protocol4, import_dto_schema, _IntentRouter, IntentRouter;
|
|
|
2517
2518
|
var init_intent_router = __esm({
|
|
2518
2519
|
"src/engine/intent.router.ts"() {
|
|
2519
2520
|
import_axis_protocol4 = require("@nextera.one/axis-protocol");
|
|
2520
|
-
init_cce_pipeline();
|
|
2521
|
-
init_axis_error();
|
|
2522
|
-
init_constants();
|
|
2523
|
-
init_capsule_policy_decorator();
|
|
2524
|
-
init_chain_decorator();
|
|
2525
|
-
import_dto_schema = __toESM(require_dto_schema_util());
|
|
2526
2521
|
init_handler_sensors_decorator();
|
|
2527
|
-
|
|
2528
|
-
init_intent_body_decorator();
|
|
2529
|
-
init_intent_policy_decorator();
|
|
2522
|
+
init_capsule_policy_decorator();
|
|
2530
2523
|
init_intent_sensors_decorator();
|
|
2531
|
-
|
|
2524
|
+
init_intent_policy_decorator();
|
|
2525
|
+
init_intent_body_decorator();
|
|
2532
2526
|
init_observer_decorator();
|
|
2527
|
+
init_handler_decorator();
|
|
2528
|
+
init_intent_decorator();
|
|
2529
|
+
init_chain_decorator();
|
|
2530
|
+
import_dto_schema = __toESM(require_dto_schema_util());
|
|
2533
2531
|
init_inline_capsule();
|
|
2534
|
-
init_axis_sensor();
|
|
2535
2532
|
init_axis_execution_context();
|
|
2533
|
+
init_axis_sensor();
|
|
2536
2534
|
init_axis_logger();
|
|
2535
|
+
init_cce_pipeline();
|
|
2536
|
+
init_axis_error();
|
|
2537
|
+
init_constants();
|
|
2537
2538
|
_IntentRouter = class _IntentRouter {
|
|
2538
2539
|
constructor(dependencyResolver, observerDispatcher, sensorRegistry) {
|
|
2539
2540
|
this.logger = createAxisLogger(_IntentRouter.name);
|
|
@@ -2569,6 +2570,8 @@ var init_intent_router = __esm({
|
|
|
2569
2570
|
this.publicIntents = /* @__PURE__ */ new Set();
|
|
2570
2571
|
/** Intents flagged as anonymous-session accessible */
|
|
2571
2572
|
this.anonymousIntents = /* @__PURE__ */ new Set();
|
|
2573
|
+
/** Intents flagged as authorized-session accessible */
|
|
2574
|
+
this.authorizedIntents = /* @__PURE__ */ new Set();
|
|
2572
2575
|
/** Per-intent rate limit config */
|
|
2573
2576
|
this.intentRateLimits = /* @__PURE__ */ new Map();
|
|
2574
2577
|
/** CCE handler registry */
|
|
@@ -2995,6 +2998,18 @@ var init_intent_router = __esm({
|
|
|
2995
2998
|
if (isAnonMethod || isAnonClass) {
|
|
2996
2999
|
this.anonymousIntents.add(intent);
|
|
2997
3000
|
}
|
|
3001
|
+
const isAuthorizedMethod = Reflect.getMetadata(
|
|
3002
|
+
AXIS_AUTHORIZED_KEY,
|
|
3003
|
+
proto,
|
|
3004
|
+
methodName
|
|
3005
|
+
);
|
|
3006
|
+
const isAuthorizedClass = Reflect.getMetadata(
|
|
3007
|
+
AXIS_AUTHORIZED_KEY,
|
|
3008
|
+
proto.constructor
|
|
3009
|
+
);
|
|
3010
|
+
if (isAuthorizedMethod || isAuthorizedClass) {
|
|
3011
|
+
this.authorizedIntents.add(intent);
|
|
3012
|
+
}
|
|
2998
3013
|
const rateLimit = Reflect.getMetadata(
|
|
2999
3014
|
AXIS_RATE_LIMIT_KEY,
|
|
3000
3015
|
proto,
|
|
@@ -3020,6 +3035,9 @@ var init_intent_router = __esm({
|
|
|
3020
3035
|
isAnonymous(intent) {
|
|
3021
3036
|
return this.anonymousIntents.has(intent);
|
|
3022
3037
|
}
|
|
3038
|
+
isAuthorized(intent) {
|
|
3039
|
+
return this.authorizedIntents.has(intent);
|
|
3040
|
+
}
|
|
3023
3041
|
getRateLimit(intent) {
|
|
3024
3042
|
return this.intentRateLimits.get(intent);
|
|
3025
3043
|
}
|