@nextera.one/axis-server-sdk 2.1.2 → 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 +995 -947
- package/dist/index.d.ts +995 -947
- package/dist/index.js +234 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +234 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1805,6 +1805,163 @@ var init_axis_error = __esm({
|
|
|
1805
1805
|
}
|
|
1806
1806
|
});
|
|
1807
1807
|
|
|
1808
|
+
// src/decorators/intent-policy.decorator.ts
|
|
1809
|
+
var intent_policy_decorator_exports = {};
|
|
1810
|
+
__export(intent_policy_decorator_exports, {
|
|
1811
|
+
AXIS_ANONYMOUS_KEY: () => AXIS_ANONYMOUS_KEY,
|
|
1812
|
+
AXIS_PUBLIC_KEY: () => AXIS_PUBLIC_KEY,
|
|
1813
|
+
AXIS_RATE_LIMIT_KEY: () => AXIS_RATE_LIMIT_KEY,
|
|
1814
|
+
AxisAnonymous: () => AxisAnonymous,
|
|
1815
|
+
AxisPublic: () => AxisPublic,
|
|
1816
|
+
AxisRateLimit: () => AxisRateLimit,
|
|
1817
|
+
CONTRACT_METADATA_KEY: () => CONTRACT_METADATA_KEY,
|
|
1818
|
+
Capsule: () => Capsule,
|
|
1819
|
+
Contract: () => Contract,
|
|
1820
|
+
REQUIRED_PROOF_METADATA_KEY: () => REQUIRED_PROOF_METADATA_KEY,
|
|
1821
|
+
RequiredProof: () => RequiredProof,
|
|
1822
|
+
SENSITIVITY_METADATA_KEY: () => SENSITIVITY_METADATA_KEY,
|
|
1823
|
+
Sensitivity: () => Sensitivity,
|
|
1824
|
+
Witness: () => Witness
|
|
1825
|
+
});
|
|
1826
|
+
import "reflect-metadata";
|
|
1827
|
+
function Sensitivity(level) {
|
|
1828
|
+
return ((target, propertyKey) => {
|
|
1829
|
+
if (propertyKey !== void 0) {
|
|
1830
|
+
Reflect.defineMetadata(
|
|
1831
|
+
SENSITIVITY_METADATA_KEY,
|
|
1832
|
+
level,
|
|
1833
|
+
target,
|
|
1834
|
+
propertyKey
|
|
1835
|
+
);
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
Reflect.defineMetadata(SENSITIVITY_METADATA_KEY, level, target);
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
function Contract(options) {
|
|
1842
|
+
return ((target, propertyKey) => {
|
|
1843
|
+
if (propertyKey !== void 0) {
|
|
1844
|
+
Reflect.defineMetadata(
|
|
1845
|
+
CONTRACT_METADATA_KEY,
|
|
1846
|
+
options,
|
|
1847
|
+
target,
|
|
1848
|
+
propertyKey
|
|
1849
|
+
);
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
Reflect.defineMetadata(CONTRACT_METADATA_KEY, options, target);
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
function RequiredProof(proofs) {
|
|
1856
|
+
return ((target, propertyKey) => {
|
|
1857
|
+
if (propertyKey !== void 0) {
|
|
1858
|
+
Reflect.defineMetadata(
|
|
1859
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1860
|
+
proofs,
|
|
1861
|
+
target,
|
|
1862
|
+
propertyKey
|
|
1863
|
+
);
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
Reflect.defineMetadata(
|
|
1867
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1868
|
+
proofs,
|
|
1869
|
+
target
|
|
1870
|
+
);
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
function Capsule() {
|
|
1874
|
+
return ((target, propertyKey) => {
|
|
1875
|
+
const existing = propertyKey !== void 0 ? Reflect.getMetadata(
|
|
1876
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1877
|
+
target,
|
|
1878
|
+
propertyKey
|
|
1879
|
+
) ?? [] : Reflect.getMetadata(
|
|
1880
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1881
|
+
target
|
|
1882
|
+
) ?? [];
|
|
1883
|
+
const merged = existing.includes("CAPSULE") ? existing : [...existing, "CAPSULE"];
|
|
1884
|
+
if (propertyKey !== void 0) {
|
|
1885
|
+
Reflect.defineMetadata(
|
|
1886
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1887
|
+
merged,
|
|
1888
|
+
target,
|
|
1889
|
+
propertyKey
|
|
1890
|
+
);
|
|
1891
|
+
} else {
|
|
1892
|
+
Reflect.defineMetadata(
|
|
1893
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1894
|
+
merged,
|
|
1895
|
+
target
|
|
1896
|
+
);
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
function Witness() {
|
|
1901
|
+
return ((target, propertyKey) => {
|
|
1902
|
+
const existing = propertyKey !== void 0 ? Reflect.getMetadata(
|
|
1903
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1904
|
+
target,
|
|
1905
|
+
propertyKey
|
|
1906
|
+
) ?? [] : Reflect.getMetadata(
|
|
1907
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1908
|
+
target
|
|
1909
|
+
) ?? [];
|
|
1910
|
+
const merged = existing.includes("WITNESS") ? existing : [...existing, "WITNESS"];
|
|
1911
|
+
if (propertyKey !== void 0) {
|
|
1912
|
+
Reflect.defineMetadata(
|
|
1913
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1914
|
+
merged,
|
|
1915
|
+
target,
|
|
1916
|
+
propertyKey
|
|
1917
|
+
);
|
|
1918
|
+
} else {
|
|
1919
|
+
Reflect.defineMetadata(
|
|
1920
|
+
REQUIRED_PROOF_METADATA_KEY,
|
|
1921
|
+
merged,
|
|
1922
|
+
target
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
function AxisPublic() {
|
|
1928
|
+
return (target, propertyKey, descriptor) => {
|
|
1929
|
+
if (descriptor) {
|
|
1930
|
+
Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target, propertyKey);
|
|
1931
|
+
return descriptor;
|
|
1932
|
+
}
|
|
1933
|
+
Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target);
|
|
1934
|
+
return target;
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
function AxisAnonymous() {
|
|
1938
|
+
return (target, propertyKey, descriptor) => {
|
|
1939
|
+
if (descriptor) {
|
|
1940
|
+
Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target, propertyKey);
|
|
1941
|
+
return descriptor;
|
|
1942
|
+
}
|
|
1943
|
+
Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target);
|
|
1944
|
+
return target;
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
function AxisRateLimit(config) {
|
|
1948
|
+
return (target, propertyKey, descriptor) => {
|
|
1949
|
+
Reflect.defineMetadata(AXIS_RATE_LIMIT_KEY, config, target, propertyKey);
|
|
1950
|
+
return descriptor;
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
var SENSITIVITY_METADATA_KEY, CONTRACT_METADATA_KEY, REQUIRED_PROOF_METADATA_KEY, AXIS_PUBLIC_KEY, AXIS_ANONYMOUS_KEY, AXIS_RATE_LIMIT_KEY;
|
|
1954
|
+
var init_intent_policy_decorator = __esm({
|
|
1955
|
+
"src/decorators/intent-policy.decorator.ts"() {
|
|
1956
|
+
SENSITIVITY_METADATA_KEY = "axis:sensitivity";
|
|
1957
|
+
CONTRACT_METADATA_KEY = "axis:contract";
|
|
1958
|
+
REQUIRED_PROOF_METADATA_KEY = "axis:required_proof";
|
|
1959
|
+
AXIS_PUBLIC_KEY = "axis:public";
|
|
1960
|
+
AXIS_ANONYMOUS_KEY = "axis:anonymous";
|
|
1961
|
+
AXIS_RATE_LIMIT_KEY = "axis:rateLimit";
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
|
|
1808
1965
|
// src/security/scopes.ts
|
|
1809
1966
|
function hasScope(scopes, required) {
|
|
1810
1967
|
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
@@ -2009,6 +2166,7 @@ var require_intent_router = __commonJS({
|
|
|
2009
2166
|
var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
|
|
2010
2167
|
var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
|
|
2011
2168
|
var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
|
|
2169
|
+
var intent_policy_decorator_1 = (init_intent_policy_decorator(), __toCommonJS(intent_policy_decorator_exports));
|
|
2012
2170
|
var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
|
|
2013
2171
|
var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
|
|
2014
2172
|
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
@@ -2070,6 +2228,12 @@ var require_intent_router = __commonJS({
|
|
|
2070
2228
|
this.intentChains = /* @__PURE__ */ new Map();
|
|
2071
2229
|
this.intentObservers = /* @__PURE__ */ new Map();
|
|
2072
2230
|
this.intentCapsulePolicies = /* @__PURE__ */ new Map();
|
|
2231
|
+
this.intentSensitivity = /* @__PURE__ */ new Map();
|
|
2232
|
+
this.intentContracts = /* @__PURE__ */ new Map();
|
|
2233
|
+
this.intentRequiredProof = /* @__PURE__ */ new Map();
|
|
2234
|
+
this.publicIntents = /* @__PURE__ */ new Set();
|
|
2235
|
+
this.anonymousIntents = /* @__PURE__ */ new Set();
|
|
2236
|
+
this.intentRateLimits = /* @__PURE__ */ new Map();
|
|
2073
2237
|
this.cceHandlers = /* @__PURE__ */ new Map();
|
|
2074
2238
|
this.ccePipelineConfig = null;
|
|
2075
2239
|
}
|
|
@@ -2325,6 +2489,56 @@ var require_intent_router = __commonJS({
|
|
|
2325
2489
|
this.intentChains.set(intent, chainConfig);
|
|
2326
2490
|
}
|
|
2327
2491
|
}
|
|
2492
|
+
const methodSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto, methodName);
|
|
2493
|
+
const classSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto.constructor);
|
|
2494
|
+
const sensitivity = methodSensitivity ?? classSensitivity;
|
|
2495
|
+
if (sensitivity) {
|
|
2496
|
+
this.intentSensitivity.set(intent, sensitivity);
|
|
2497
|
+
}
|
|
2498
|
+
const methodContract = Reflect.getMetadata(intent_policy_decorator_1.CONTRACT_METADATA_KEY, proto, methodName);
|
|
2499
|
+
const classContract = Reflect.getMetadata(intent_policy_decorator_1.CONTRACT_METADATA_KEY, proto.constructor);
|
|
2500
|
+
const contract = methodContract ?? classContract;
|
|
2501
|
+
if (contract) {
|
|
2502
|
+
this.intentContracts.set(intent, contract);
|
|
2503
|
+
}
|
|
2504
|
+
const methodProof = Reflect.getMetadata(intent_policy_decorator_1.REQUIRED_PROOF_METADATA_KEY, proto, methodName);
|
|
2505
|
+
const classProof = Reflect.getMetadata(intent_policy_decorator_1.REQUIRED_PROOF_METADATA_KEY, proto.constructor);
|
|
2506
|
+
const requiredProof = methodProof ?? classProof;
|
|
2507
|
+
if (requiredProof && requiredProof.length > 0) {
|
|
2508
|
+
this.intentRequiredProof.set(intent, requiredProof);
|
|
2509
|
+
}
|
|
2510
|
+
const isPublicMethod = Reflect.getMetadata(intent_policy_decorator_1.AXIS_PUBLIC_KEY, proto, methodName);
|
|
2511
|
+
const isPublicClass = Reflect.getMetadata(intent_policy_decorator_1.AXIS_PUBLIC_KEY, proto.constructor);
|
|
2512
|
+
if (isPublicMethod || isPublicClass) {
|
|
2513
|
+
this.publicIntents.add(intent);
|
|
2514
|
+
}
|
|
2515
|
+
const isAnonMethod = Reflect.getMetadata(intent_policy_decorator_1.AXIS_ANONYMOUS_KEY, proto, methodName);
|
|
2516
|
+
const isAnonClass = Reflect.getMetadata(intent_policy_decorator_1.AXIS_ANONYMOUS_KEY, proto.constructor);
|
|
2517
|
+
if (isAnonMethod || isAnonClass) {
|
|
2518
|
+
this.anonymousIntents.add(intent);
|
|
2519
|
+
}
|
|
2520
|
+
const rateLimit = Reflect.getMetadata(intent_policy_decorator_1.AXIS_RATE_LIMIT_KEY, proto, methodName);
|
|
2521
|
+
if (rateLimit) {
|
|
2522
|
+
this.intentRateLimits.set(intent, rateLimit);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
getSensitivity(intent) {
|
|
2526
|
+
return this.intentSensitivity.get(intent);
|
|
2527
|
+
}
|
|
2528
|
+
getContract(intent) {
|
|
2529
|
+
return this.intentContracts.get(intent);
|
|
2530
|
+
}
|
|
2531
|
+
getRequiredProof(intent) {
|
|
2532
|
+
return this.intentRequiredProof.get(intent);
|
|
2533
|
+
}
|
|
2534
|
+
isPublic(intent) {
|
|
2535
|
+
return this.publicIntents.has(intent);
|
|
2536
|
+
}
|
|
2537
|
+
isAnonymous(intent) {
|
|
2538
|
+
return this.anonymousIntents.has(intent);
|
|
2539
|
+
}
|
|
2540
|
+
getRateLimit(intent) {
|
|
2541
|
+
return this.intentRateLimits.get(intent);
|
|
2328
2542
|
}
|
|
2329
2543
|
async emitIntentObservers(bindings, context) {
|
|
2330
2544
|
if (!this.observerDispatcher || bindings.length === 0)
|
|
@@ -2525,7 +2739,11 @@ var require_intent_router = __commonJS({
|
|
|
2525
2739
|
envelope: (0, axis_protocol_1.decodeChainEnvelope)(bytes2)
|
|
2526
2740
|
};
|
|
2527
2741
|
} catch (envelopeError) {
|
|
2528
|
-
const reason = [
|
|
2742
|
+
const reason = [
|
|
2743
|
+
jsonError?.message,
|
|
2744
|
+
requestError.message,
|
|
2745
|
+
envelopeError.message
|
|
2746
|
+
].filter(Boolean).join(" | ");
|
|
2529
2747
|
throw new Error(`CHAIN.EXEC decode failed: ${reason}`);
|
|
2530
2748
|
}
|
|
2531
2749
|
}
|
|
@@ -7138,10 +7356,19 @@ var init_crypto = __esm({
|
|
|
7138
7356
|
// src/decorators/index.ts
|
|
7139
7357
|
var decorators_exports = {};
|
|
7140
7358
|
__export(decorators_exports, {
|
|
7359
|
+
AXIS_ANONYMOUS_KEY: () => AXIS_ANONYMOUS_KEY,
|
|
7360
|
+
AXIS_PUBLIC_KEY: () => AXIS_PUBLIC_KEY,
|
|
7361
|
+
AXIS_RATE_LIMIT_KEY: () => AXIS_RATE_LIMIT_KEY,
|
|
7362
|
+
AxisAnonymous: () => AxisAnonymous,
|
|
7363
|
+
AxisPublic: () => AxisPublic,
|
|
7364
|
+
AxisRateLimit: () => AxisRateLimit,
|
|
7141
7365
|
CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
|
|
7142
7366
|
CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
|
|
7367
|
+
CONTRACT_METADATA_KEY: () => CONTRACT_METADATA_KEY,
|
|
7368
|
+
Capsule: () => Capsule,
|
|
7143
7369
|
CapsulePolicy: () => CapsulePolicy,
|
|
7144
7370
|
Chain: () => Chain,
|
|
7371
|
+
Contract: () => Contract,
|
|
7145
7372
|
HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
|
|
7146
7373
|
Handler: () => Handler,
|
|
7147
7374
|
INTENT_BODY_KEY: () => INTENT_BODY_KEY,
|
|
@@ -7154,7 +7381,11 @@ __export(decorators_exports, {
|
|
|
7154
7381
|
OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
|
|
7155
7382
|
OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
|
|
7156
7383
|
Observer: () => Observer,
|
|
7384
|
+
REQUIRED_PROOF_METADATA_KEY: () => REQUIRED_PROOF_METADATA_KEY,
|
|
7385
|
+
RequiredProof: () => RequiredProof,
|
|
7386
|
+
SENSITIVITY_METADATA_KEY: () => SENSITIVITY_METADATA_KEY,
|
|
7157
7387
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
7388
|
+
Sensitivity: () => Sensitivity,
|
|
7158
7389
|
Sensor: () => Sensor,
|
|
7159
7390
|
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
7160
7391
|
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
@@ -7164,6 +7395,7 @@ __export(decorators_exports, {
|
|
|
7164
7395
|
TlvRange: () => TlvRange,
|
|
7165
7396
|
TlvUtf8Pattern: () => TlvUtf8Pattern,
|
|
7166
7397
|
TlvValidate: () => TlvValidate,
|
|
7398
|
+
Witness: () => Witness,
|
|
7167
7399
|
mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
|
|
7168
7400
|
normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
|
|
7169
7401
|
});
|
|
@@ -7171,6 +7403,7 @@ var init_decorators = __esm({
|
|
|
7171
7403
|
"src/decorators/index.ts"() {
|
|
7172
7404
|
__reExport(decorators_exports, __toESM(require_axis_request_decorator()));
|
|
7173
7405
|
init_capsule_policy_decorator();
|
|
7406
|
+
init_intent_policy_decorator();
|
|
7174
7407
|
init_chain_decorator();
|
|
7175
7408
|
__reExport(decorators_exports, __toESM(require_dto_schema_util()));
|
|
7176
7409
|
init_handler_decorator();
|