@nextera.one/axis-server-sdk 2.1.3 → 2.1.4
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.d.mts +985 -955
- package/dist/index.d.ts +985 -955
- package/dist/index.js +225 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +225 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1733,6 +1733,163 @@ var init_axis_error = __esm({
|
|
|
1733
1733
|
}
|
|
1734
1734
|
});
|
|
1735
1735
|
|
|
1736
|
+
// src/decorators/intent-policy.decorator.ts
|
|
1737
|
+
var intent_policy_decorator_exports = {};
|
|
1738
|
+
__export(intent_policy_decorator_exports, {
|
|
1739
|
+
AXIS_ANONYMOUS_KEY: () => AXIS_ANONYMOUS_KEY,
|
|
1740
|
+
AXIS_PUBLIC_KEY: () => AXIS_PUBLIC_KEY,
|
|
1741
|
+
AXIS_RATE_LIMIT_KEY: () => AXIS_RATE_LIMIT_KEY,
|
|
1742
|
+
AxisAnonymous: () => AxisAnonymous,
|
|
1743
|
+
AxisPublic: () => AxisPublic,
|
|
1744
|
+
AxisRateLimit: () => AxisRateLimit,
|
|
1745
|
+
CONTRACT_METADATA_KEY: () => CONTRACT_METADATA_KEY,
|
|
1746
|
+
Capsule: () => Capsule,
|
|
1747
|
+
Contract: () => Contract,
|
|
1748
|
+
REQUIRED_PROOF_METADATA_KEY: () => REQUIRED_PROOF_METADATA_KEY,
|
|
1749
|
+
RequiredProof: () => RequiredProof,
|
|
1750
|
+
SENSITIVITY_METADATA_KEY: () => SENSITIVITY_METADATA_KEY,
|
|
1751
|
+
Sensitivity: () => Sensitivity,
|
|
1752
|
+
Witness: () => Witness
|
|
1753
|
+
});
|
|
1754
|
+
function Sensitivity(level) {
|
|
1755
|
+
return ((target, propertyKey) => {
|
|
1756
|
+
if (propertyKey !== void 0) {
|
|
1757
|
+
Reflect.defineMetadata(
|
|
1758
|
+
SENSITIVITY_METADATA_KEY,
|
|
1759
|
+
level,
|
|
1760
|
+
target,
|
|
1761
|
+
propertyKey
|
|
1762
|
+
);
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
Reflect.defineMetadata(SENSITIVITY_METADATA_KEY, level, target);
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
function Contract(options) {
|
|
1769
|
+
return ((target, propertyKey) => {
|
|
1770
|
+
if (propertyKey !== void 0) {
|
|
1771
|
+
Reflect.defineMetadata(
|
|
1772
|
+
CONTRACT_METADATA_KEY,
|
|
1773
|
+
options,
|
|
1774
|
+
target,
|
|
1775
|
+
propertyKey
|
|
1776
|
+
);
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
Reflect.defineMetadata(CONTRACT_METADATA_KEY, options, target);
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
function RequiredProof(proofs) {
|
|
1783
|
+
return ((target, propertyKey) => {
|
|
1784
|
+
if (propertyKey !== void 0) {
|
|
1785
|
+
Reflect.defineMetadata(
|
|
1786
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1787
|
+
proofs,
|
|
1788
|
+
target,
|
|
1789
|
+
propertyKey
|
|
1790
|
+
);
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
Reflect.defineMetadata(
|
|
1794
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1795
|
+
proofs,
|
|
1796
|
+
target
|
|
1797
|
+
);
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
function Capsule() {
|
|
1801
|
+
return ((target, propertyKey) => {
|
|
1802
|
+
const existing = propertyKey !== void 0 ? Reflect.getMetadata(
|
|
1803
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1804
|
+
target,
|
|
1805
|
+
propertyKey
|
|
1806
|
+
) ?? [] : Reflect.getMetadata(
|
|
1807
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1808
|
+
target
|
|
1809
|
+
) ?? [];
|
|
1810
|
+
const merged = existing.includes("CAPSULE") ? existing : [...existing, "CAPSULE"];
|
|
1811
|
+
if (propertyKey !== void 0) {
|
|
1812
|
+
Reflect.defineMetadata(
|
|
1813
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1814
|
+
merged,
|
|
1815
|
+
target,
|
|
1816
|
+
propertyKey
|
|
1817
|
+
);
|
|
1818
|
+
} else {
|
|
1819
|
+
Reflect.defineMetadata(
|
|
1820
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1821
|
+
merged,
|
|
1822
|
+
target
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
function Witness() {
|
|
1828
|
+
return ((target, propertyKey) => {
|
|
1829
|
+
const existing = propertyKey !== void 0 ? Reflect.getMetadata(
|
|
1830
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1831
|
+
target,
|
|
1832
|
+
propertyKey
|
|
1833
|
+
) ?? [] : Reflect.getMetadata(
|
|
1834
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1835
|
+
target
|
|
1836
|
+
) ?? [];
|
|
1837
|
+
const merged = existing.includes("WITNESS") ? existing : [...existing, "WITNESS"];
|
|
1838
|
+
if (propertyKey !== void 0) {
|
|
1839
|
+
Reflect.defineMetadata(
|
|
1840
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1841
|
+
merged,
|
|
1842
|
+
target,
|
|
1843
|
+
propertyKey
|
|
1844
|
+
);
|
|
1845
|
+
} else {
|
|
1846
|
+
Reflect.defineMetadata(
|
|
1847
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1848
|
+
merged,
|
|
1849
|
+
target
|
|
1850
|
+
);
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
function AxisPublic() {
|
|
1855
|
+
return (target, propertyKey, descriptor) => {
|
|
1856
|
+
if (descriptor) {
|
|
1857
|
+
Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target, propertyKey);
|
|
1858
|
+
return descriptor;
|
|
1859
|
+
}
|
|
1860
|
+
Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target);
|
|
1861
|
+
return target;
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
function AxisAnonymous() {
|
|
1865
|
+
return (target, propertyKey, descriptor) => {
|
|
1866
|
+
if (descriptor) {
|
|
1867
|
+
Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target, propertyKey);
|
|
1868
|
+
return descriptor;
|
|
1869
|
+
}
|
|
1870
|
+
Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target);
|
|
1871
|
+
return target;
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
function AxisRateLimit(config) {
|
|
1875
|
+
return (target, propertyKey, descriptor) => {
|
|
1876
|
+
Reflect.defineMetadata(AXIS_RATE_LIMIT_KEY, config, target, propertyKey);
|
|
1877
|
+
return descriptor;
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
var import_reflect_metadata10, SENSITIVITY_METADATA_KEY, CONTRACT_METADATA_KEY, REQUIRED_PROOF_METADATA_KEY, AXIS_PUBLIC_KEY, AXIS_ANONYMOUS_KEY, AXIS_RATE_LIMIT_KEY;
|
|
1881
|
+
var init_intent_policy_decorator = __esm({
|
|
1882
|
+
"src/decorators/intent-policy.decorator.ts"() {
|
|
1883
|
+
import_reflect_metadata10 = require("reflect-metadata");
|
|
1884
|
+
SENSITIVITY_METADATA_KEY = "axis:sensitivity";
|
|
1885
|
+
CONTRACT_METADATA_KEY = "axis:contract";
|
|
1886
|
+
REQUIRED_PROOF_METADATA_KEY = "axis:required_proof";
|
|
1887
|
+
AXIS_PUBLIC_KEY = "axis:public";
|
|
1888
|
+
AXIS_ANONYMOUS_KEY = "axis:anonymous";
|
|
1889
|
+
AXIS_RATE_LIMIT_KEY = "axis:rateLimit";
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
|
|
1736
1893
|
// src/security/scopes.ts
|
|
1737
1894
|
function hasScope(scopes, required) {
|
|
1738
1895
|
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
@@ -1937,6 +2094,7 @@ var require_intent_router = __commonJS({
|
|
|
1937
2094
|
var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
|
|
1938
2095
|
var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
|
|
1939
2096
|
var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
|
|
2097
|
+
var intent_policy_decorator_1 = (init_intent_policy_decorator(), __toCommonJS(intent_policy_decorator_exports));
|
|
1940
2098
|
var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
|
|
1941
2099
|
var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
|
|
1942
2100
|
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
@@ -1998,6 +2156,12 @@ var require_intent_router = __commonJS({
|
|
|
1998
2156
|
this.intentChains = /* @__PURE__ */ new Map();
|
|
1999
2157
|
this.intentObservers = /* @__PURE__ */ new Map();
|
|
2000
2158
|
this.intentCapsulePolicies = /* @__PURE__ */ new Map();
|
|
2159
|
+
this.intentSensitivity = /* @__PURE__ */ new Map();
|
|
2160
|
+
this.intentContracts = /* @__PURE__ */ new Map();
|
|
2161
|
+
this.intentRequiredProof = /* @__PURE__ */ new Map();
|
|
2162
|
+
this.publicIntents = /* @__PURE__ */ new Set();
|
|
2163
|
+
this.anonymousIntents = /* @__PURE__ */ new Set();
|
|
2164
|
+
this.intentRateLimits = /* @__PURE__ */ new Map();
|
|
2001
2165
|
this.cceHandlers = /* @__PURE__ */ new Map();
|
|
2002
2166
|
this.ccePipelineConfig = null;
|
|
2003
2167
|
}
|
|
@@ -2253,6 +2417,56 @@ var require_intent_router = __commonJS({
|
|
|
2253
2417
|
this.intentChains.set(intent, chainConfig);
|
|
2254
2418
|
}
|
|
2255
2419
|
}
|
|
2420
|
+
const methodSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto, methodName);
|
|
2421
|
+
const classSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto.constructor);
|
|
2422
|
+
const sensitivity = methodSensitivity ?? classSensitivity;
|
|
2423
|
+
if (sensitivity) {
|
|
2424
|
+
this.intentSensitivity.set(intent, sensitivity);
|
|
2425
|
+
}
|
|
2426
|
+
const methodContract = Reflect.getMetadata(intent_policy_decorator_1.CONTRACT_METADATA_KEY, proto, methodName);
|
|
2427
|
+
const classContract = Reflect.getMetadata(intent_policy_decorator_1.CONTRACT_METADATA_KEY, proto.constructor);
|
|
2428
|
+
const contract = methodContract ?? classContract;
|
|
2429
|
+
if (contract) {
|
|
2430
|
+
this.intentContracts.set(intent, contract);
|
|
2431
|
+
}
|
|
2432
|
+
const methodProof = Reflect.getMetadata(intent_policy_decorator_1.REQUIRED_PROOF_METADATA_KEY, proto, methodName);
|
|
2433
|
+
const classProof = Reflect.getMetadata(intent_policy_decorator_1.REQUIRED_PROOF_METADATA_KEY, proto.constructor);
|
|
2434
|
+
const requiredProof = methodProof ?? classProof;
|
|
2435
|
+
if (requiredProof && requiredProof.length > 0) {
|
|
2436
|
+
this.intentRequiredProof.set(intent, requiredProof);
|
|
2437
|
+
}
|
|
2438
|
+
const isPublicMethod = Reflect.getMetadata(intent_policy_decorator_1.AXIS_PUBLIC_KEY, proto, methodName);
|
|
2439
|
+
const isPublicClass = Reflect.getMetadata(intent_policy_decorator_1.AXIS_PUBLIC_KEY, proto.constructor);
|
|
2440
|
+
if (isPublicMethod || isPublicClass) {
|
|
2441
|
+
this.publicIntents.add(intent);
|
|
2442
|
+
}
|
|
2443
|
+
const isAnonMethod = Reflect.getMetadata(intent_policy_decorator_1.AXIS_ANONYMOUS_KEY, proto, methodName);
|
|
2444
|
+
const isAnonClass = Reflect.getMetadata(intent_policy_decorator_1.AXIS_ANONYMOUS_KEY, proto.constructor);
|
|
2445
|
+
if (isAnonMethod || isAnonClass) {
|
|
2446
|
+
this.anonymousIntents.add(intent);
|
|
2447
|
+
}
|
|
2448
|
+
const rateLimit = Reflect.getMetadata(intent_policy_decorator_1.AXIS_RATE_LIMIT_KEY, proto, methodName);
|
|
2449
|
+
if (rateLimit) {
|
|
2450
|
+
this.intentRateLimits.set(intent, rateLimit);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
getSensitivity(intent) {
|
|
2454
|
+
return this.intentSensitivity.get(intent);
|
|
2455
|
+
}
|
|
2456
|
+
getContract(intent) {
|
|
2457
|
+
return this.intentContracts.get(intent);
|
|
2458
|
+
}
|
|
2459
|
+
getRequiredProof(intent) {
|
|
2460
|
+
return this.intentRequiredProof.get(intent);
|
|
2461
|
+
}
|
|
2462
|
+
isPublic(intent) {
|
|
2463
|
+
return this.publicIntents.has(intent);
|
|
2464
|
+
}
|
|
2465
|
+
isAnonymous(intent) {
|
|
2466
|
+
return this.anonymousIntents.has(intent);
|
|
2467
|
+
}
|
|
2468
|
+
getRateLimit(intent) {
|
|
2469
|
+
return this.intentRateLimits.get(intent);
|
|
2256
2470
|
}
|
|
2257
2471
|
async emitIntentObservers(bindings, context) {
|
|
2258
2472
|
if (!this.observerDispatcher || bindings.length === 0)
|
|
@@ -2453,7 +2667,11 @@ var require_intent_router = __commonJS({
|
|
|
2453
2667
|
envelope: (0, axis_protocol_1.decodeChainEnvelope)(bytes2)
|
|
2454
2668
|
};
|
|
2455
2669
|
} catch (envelopeError) {
|
|
2456
|
-
const reason = [
|
|
2670
|
+
const reason = [
|
|
2671
|
+
jsonError?.message,
|
|
2672
|
+
requestError.message,
|
|
2673
|
+
envelopeError.message
|
|
2674
|
+
].filter(Boolean).join(" | ");
|
|
2457
2675
|
throw new Error(`CHAIN.EXEC decode failed: ${reason}`);
|
|
2458
2676
|
}
|
|
2459
2677
|
}
|
|
@@ -7069,120 +7287,15 @@ var init_crypto = __esm({
|
|
|
7069
7287
|
}
|
|
7070
7288
|
});
|
|
7071
7289
|
|
|
7072
|
-
// src/decorators/intent-policy.decorator.ts
|
|
7073
|
-
function Sensitivity(level) {
|
|
7074
|
-
return ((target, propertyKey) => {
|
|
7075
|
-
if (propertyKey !== void 0) {
|
|
7076
|
-
Reflect.defineMetadata(
|
|
7077
|
-
SENSITIVITY_METADATA_KEY,
|
|
7078
|
-
level,
|
|
7079
|
-
target,
|
|
7080
|
-
propertyKey
|
|
7081
|
-
);
|
|
7082
|
-
return;
|
|
7083
|
-
}
|
|
7084
|
-
Reflect.defineMetadata(SENSITIVITY_METADATA_KEY, level, target);
|
|
7085
|
-
});
|
|
7086
|
-
}
|
|
7087
|
-
function Contract(options) {
|
|
7088
|
-
return ((target, propertyKey) => {
|
|
7089
|
-
if (propertyKey !== void 0) {
|
|
7090
|
-
Reflect.defineMetadata(
|
|
7091
|
-
CONTRACT_METADATA_KEY,
|
|
7092
|
-
options,
|
|
7093
|
-
target,
|
|
7094
|
-
propertyKey
|
|
7095
|
-
);
|
|
7096
|
-
return;
|
|
7097
|
-
}
|
|
7098
|
-
Reflect.defineMetadata(CONTRACT_METADATA_KEY, options, target);
|
|
7099
|
-
});
|
|
7100
|
-
}
|
|
7101
|
-
function RequiredProof(proofs) {
|
|
7102
|
-
return ((target, propertyKey) => {
|
|
7103
|
-
if (propertyKey !== void 0) {
|
|
7104
|
-
Reflect.defineMetadata(
|
|
7105
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7106
|
-
proofs,
|
|
7107
|
-
target,
|
|
7108
|
-
propertyKey
|
|
7109
|
-
);
|
|
7110
|
-
return;
|
|
7111
|
-
}
|
|
7112
|
-
Reflect.defineMetadata(
|
|
7113
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7114
|
-
proofs,
|
|
7115
|
-
target
|
|
7116
|
-
);
|
|
7117
|
-
});
|
|
7118
|
-
}
|
|
7119
|
-
function Capsule() {
|
|
7120
|
-
return ((target, propertyKey) => {
|
|
7121
|
-
const existing = propertyKey !== void 0 ? Reflect.getMetadata(
|
|
7122
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7123
|
-
target,
|
|
7124
|
-
propertyKey
|
|
7125
|
-
) ?? [] : Reflect.getMetadata(
|
|
7126
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7127
|
-
target
|
|
7128
|
-
) ?? [];
|
|
7129
|
-
const merged = existing.includes("CAPSULE") ? existing : [...existing, "CAPSULE"];
|
|
7130
|
-
if (propertyKey !== void 0) {
|
|
7131
|
-
Reflect.defineMetadata(
|
|
7132
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7133
|
-
merged,
|
|
7134
|
-
target,
|
|
7135
|
-
propertyKey
|
|
7136
|
-
);
|
|
7137
|
-
} else {
|
|
7138
|
-
Reflect.defineMetadata(
|
|
7139
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7140
|
-
merged,
|
|
7141
|
-
target
|
|
7142
|
-
);
|
|
7143
|
-
}
|
|
7144
|
-
});
|
|
7145
|
-
}
|
|
7146
|
-
function Witness() {
|
|
7147
|
-
return ((target, propertyKey) => {
|
|
7148
|
-
const existing = propertyKey !== void 0 ? Reflect.getMetadata(
|
|
7149
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7150
|
-
target,
|
|
7151
|
-
propertyKey
|
|
7152
|
-
) ?? [] : Reflect.getMetadata(
|
|
7153
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7154
|
-
target
|
|
7155
|
-
) ?? [];
|
|
7156
|
-
const merged = existing.includes("WITNESS") ? existing : [...existing, "WITNESS"];
|
|
7157
|
-
if (propertyKey !== void 0) {
|
|
7158
|
-
Reflect.defineMetadata(
|
|
7159
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7160
|
-
merged,
|
|
7161
|
-
target,
|
|
7162
|
-
propertyKey
|
|
7163
|
-
);
|
|
7164
|
-
} else {
|
|
7165
|
-
Reflect.defineMetadata(
|
|
7166
|
-
REQUIRED_PROOF_METADATA_KEY,
|
|
7167
|
-
merged,
|
|
7168
|
-
target
|
|
7169
|
-
);
|
|
7170
|
-
}
|
|
7171
|
-
});
|
|
7172
|
-
}
|
|
7173
|
-
var import_reflect_metadata10, SENSITIVITY_METADATA_KEY, CONTRACT_METADATA_KEY, REQUIRED_PROOF_METADATA_KEY;
|
|
7174
|
-
var init_intent_policy_decorator = __esm({
|
|
7175
|
-
"src/decorators/intent-policy.decorator.ts"() {
|
|
7176
|
-
import_reflect_metadata10 = require("reflect-metadata");
|
|
7177
|
-
SENSITIVITY_METADATA_KEY = "axis:sensitivity";
|
|
7178
|
-
CONTRACT_METADATA_KEY = "axis:contract";
|
|
7179
|
-
REQUIRED_PROOF_METADATA_KEY = "axis:required_proof";
|
|
7180
|
-
}
|
|
7181
|
-
});
|
|
7182
|
-
|
|
7183
7290
|
// src/decorators/index.ts
|
|
7184
7291
|
var decorators_exports = {};
|
|
7185
7292
|
__export(decorators_exports, {
|
|
7293
|
+
AXIS_ANONYMOUS_KEY: () => AXIS_ANONYMOUS_KEY,
|
|
7294
|
+
AXIS_PUBLIC_KEY: () => AXIS_PUBLIC_KEY,
|
|
7295
|
+
AXIS_RATE_LIMIT_KEY: () => AXIS_RATE_LIMIT_KEY,
|
|
7296
|
+
AxisAnonymous: () => AxisAnonymous,
|
|
7297
|
+
AxisPublic: () => AxisPublic,
|
|
7298
|
+
AxisRateLimit: () => AxisRateLimit,
|
|
7186
7299
|
CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
|
|
7187
7300
|
CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
|
|
7188
7301
|
CONTRACT_METADATA_KEY: () => CONTRACT_METADATA_KEY,
|