@nextera.one/axis-server-sdk 2.3.22 → 2.3.23
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-CjHt1HEv.d.ts → index-BOTVLcqR.d.ts} +37 -29
- package/dist/{index-OpaG6R6E.d.mts → index-dMZDesmq.d.mts} +37 -29
- package/dist/index.d.mts +20 -4
- package/dist/index.d.ts +20 -4
- package/dist/index.js +70 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -2
- package/dist/index.mjs.map +1 -1
- package/dist/sensors/index.d.mts +1 -1
- package/dist/sensors/index.d.ts +1 -1
- package/dist/sensors/index.js +69 -3
- package/dist/sensors/index.js.map +1 -1
- package/dist/sensors/index.mjs +68 -2
- package/dist/sensors/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/sensors/index.mjs
CHANGED
|
@@ -977,7 +977,8 @@ var require_dto_schema_util = __commonJS({
|
|
|
977
977
|
required: m.options.required,
|
|
978
978
|
maxLen: m.options.maxLen,
|
|
979
979
|
max: m.options.max,
|
|
980
|
-
scope: m.options.scope
|
|
980
|
+
scope: m.options.scope,
|
|
981
|
+
encode: m.options.encode
|
|
981
982
|
};
|
|
982
983
|
});
|
|
983
984
|
const validatorMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_VALIDATORS_KEY, dto) || [];
|
|
@@ -8987,9 +8988,11 @@ var init_axis_observation = __esm({
|
|
|
8987
8988
|
});
|
|
8988
8989
|
|
|
8989
8990
|
// src/security/axis-sensor-chain.service.ts
|
|
8991
|
+
import "reflect-metadata";
|
|
8990
8992
|
var AxisSensorChainService;
|
|
8991
8993
|
var init_axis_sensor_chain_service = __esm({
|
|
8992
8994
|
"src/security/axis-sensor-chain.service.ts"() {
|
|
8995
|
+
init_sensor_decorator();
|
|
8993
8996
|
init_axis_sensor();
|
|
8994
8997
|
init_axis_observation();
|
|
8995
8998
|
AxisSensorChainService = class {
|
|
@@ -9032,6 +9035,9 @@ var init_axis_sensor_chain_service = __esm({
|
|
|
9032
9035
|
async evaluateSensors(sensors, input, baseDecision) {
|
|
9033
9036
|
const relevantSensors = [];
|
|
9034
9037
|
for (const sensor of sensors) {
|
|
9038
|
+
if (!this.matchesProofKind(sensor, input)) {
|
|
9039
|
+
continue;
|
|
9040
|
+
}
|
|
9035
9041
|
if (!sensor.supports) {
|
|
9036
9042
|
relevantSensors.push(sensor);
|
|
9037
9043
|
continue;
|
|
@@ -9131,6 +9137,28 @@ var init_axis_sensor_chain_service = __esm({
|
|
|
9131
9137
|
} : void 0
|
|
9132
9138
|
};
|
|
9133
9139
|
}
|
|
9140
|
+
matchesProofKind(sensor, input) {
|
|
9141
|
+
const meta = Reflect.getMetadata(
|
|
9142
|
+
SENSOR_METADATA_KEY,
|
|
9143
|
+
sensor.constructor
|
|
9144
|
+
);
|
|
9145
|
+
if (!meta || meta === true) return true;
|
|
9146
|
+
const currentProofKinds = this.normalizeProofKinds(
|
|
9147
|
+
input.metadata?.proofKind ?? input.requiredProof
|
|
9148
|
+
);
|
|
9149
|
+
const excludedProofKinds = this.normalizeProofKinds(meta.excludeProofKind);
|
|
9150
|
+
if (excludedProofKinds.length > 0 && currentProofKinds.some((kind) => excludedProofKinds.includes(kind))) {
|
|
9151
|
+
return false;
|
|
9152
|
+
}
|
|
9153
|
+
const requiredProofKinds = this.normalizeProofKinds(meta.proofKind);
|
|
9154
|
+
if (requiredProofKinds.length === 0) return true;
|
|
9155
|
+
return currentProofKinds.some((kind) => requiredProofKinds.includes(kind));
|
|
9156
|
+
}
|
|
9157
|
+
normalizeProofKinds(value) {
|
|
9158
|
+
if (value === void 0 || value === null) return [];
|
|
9159
|
+
const items = Array.isArray(value) ? value : [value];
|
|
9160
|
+
return items.map((item) => String(item).trim().toUpperCase()).filter(Boolean);
|
|
9161
|
+
}
|
|
9134
9162
|
};
|
|
9135
9163
|
}
|
|
9136
9164
|
});
|
|
@@ -9504,10 +9532,11 @@ var init_timeline_store = __esm({
|
|
|
9504
9532
|
});
|
|
9505
9533
|
|
|
9506
9534
|
// src/utils/axis-tlv-codec.ts
|
|
9507
|
-
function encodeAxisTlvDto(dtoClass, data) {
|
|
9535
|
+
function encodeAxisTlvDto(dtoClass, data, context = {}) {
|
|
9508
9536
|
const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
|
|
9509
9537
|
const items = schema.fields.flatMap((field) => {
|
|
9510
9538
|
const value = data[field.name];
|
|
9539
|
+
if (!shouldEncodeField(field, value, data, context)) return [];
|
|
9511
9540
|
if (value === void 0 || value === null) {
|
|
9512
9541
|
if (field.required) {
|
|
9513
9542
|
throw new Error(`Missing required TLV response field: ${field.name}`);
|
|
@@ -9518,6 +9547,42 @@ function encodeAxisTlvDto(dtoClass, data) {
|
|
|
9518
9547
|
});
|
|
9519
9548
|
return buildTLVs(items);
|
|
9520
9549
|
}
|
|
9550
|
+
function projectAxisTlvDto(dtoClass, data, context = {}) {
|
|
9551
|
+
const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
|
|
9552
|
+
const result = {};
|
|
9553
|
+
for (const field of schema.fields) {
|
|
9554
|
+
const value = data[field.name];
|
|
9555
|
+
if (!shouldEncodeField(field, value, data, context)) continue;
|
|
9556
|
+
if (value === void 0 || value === null) continue;
|
|
9557
|
+
result[field.name] = value;
|
|
9558
|
+
}
|
|
9559
|
+
return result;
|
|
9560
|
+
}
|
|
9561
|
+
function shouldEncodeField(field, value, data, context) {
|
|
9562
|
+
const rule = field.encode;
|
|
9563
|
+
if (rule === void 0) return true;
|
|
9564
|
+
if (rule === false) return false;
|
|
9565
|
+
if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
|
|
9566
|
+
return false;
|
|
9567
|
+
}
|
|
9568
|
+
if (rule.exceptRoles?.length && hasAnyRole(context, rule.exceptRoles)) {
|
|
9569
|
+
return false;
|
|
9570
|
+
}
|
|
9571
|
+
if (rule.policy) {
|
|
9572
|
+
const policy = context.policies?.[rule.policy];
|
|
9573
|
+
if (!policy) {
|
|
9574
|
+
throw new Error(`Missing TLV encode policy: ${rule.policy}`);
|
|
9575
|
+
}
|
|
9576
|
+
if (!policy({ field, value, data, context })) {
|
|
9577
|
+
return false;
|
|
9578
|
+
}
|
|
9579
|
+
}
|
|
9580
|
+
return true;
|
|
9581
|
+
}
|
|
9582
|
+
function hasAnyRole(context, expectedRoles) {
|
|
9583
|
+
const actualRoles = context.roles ?? [];
|
|
9584
|
+
return expectedRoles.some((role) => actualRoles.includes(role));
|
|
9585
|
+
}
|
|
9521
9586
|
function encodeField(field, value) {
|
|
9522
9587
|
switch (field.kind) {
|
|
9523
9588
|
case "utf8":
|
|
@@ -11261,6 +11326,7 @@ __export(index_exports, {
|
|
|
11261
11326
|
parseScope: () => parseScope,
|
|
11262
11327
|
parseStreamEntries: () => parseStreamEntries,
|
|
11263
11328
|
projectAt: () => projectAt,
|
|
11329
|
+
projectAxisTlvDto: () => projectAxisTlvDto,
|
|
11264
11330
|
queryFabric: () => queryFabric,
|
|
11265
11331
|
recordOccurrence: () => recordOccurrence,
|
|
11266
11332
|
recordSensor: () => recordSensor,
|