@nextera.one/axis-server-sdk 2.3.22 → 2.3.24

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.
@@ -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) || [];
@@ -3875,7 +3876,8 @@ var init_intent_router = __esm({
3875
3876
  required: f.required,
3876
3877
  maxLen: f.maxLen,
3877
3878
  max: f.max,
3878
- scope: f.scope
3879
+ scope: f.scope,
3880
+ ...f.encode !== void 0 ? { encode: f.encode } : {}
3879
3881
  }))
3880
3882
  };
3881
3883
  this.intentSchemas.set(meta.intent, schema2);
@@ -3899,7 +3901,8 @@ var init_intent_router = __esm({
3899
3901
  required: f.required,
3900
3902
  maxLen: f.maxLen,
3901
3903
  max: f.max,
3902
- scope: f.scope
3904
+ scope: f.scope,
3905
+ ...f.encode !== void 0 ? { encode: f.encode } : {}
3903
3906
  }))
3904
3907
  };
3905
3908
  this.intentSchemas.set(meta.intent, schema);
@@ -8987,9 +8990,11 @@ var init_axis_observation = __esm({
8987
8990
  });
8988
8991
 
8989
8992
  // src/security/axis-sensor-chain.service.ts
8993
+ import "reflect-metadata";
8990
8994
  var AxisSensorChainService;
8991
8995
  var init_axis_sensor_chain_service = __esm({
8992
8996
  "src/security/axis-sensor-chain.service.ts"() {
8997
+ init_sensor_decorator();
8993
8998
  init_axis_sensor();
8994
8999
  init_axis_observation();
8995
9000
  AxisSensorChainService = class {
@@ -9032,6 +9037,9 @@ var init_axis_sensor_chain_service = __esm({
9032
9037
  async evaluateSensors(sensors, input, baseDecision) {
9033
9038
  const relevantSensors = [];
9034
9039
  for (const sensor of sensors) {
9040
+ if (!this.matchesProofKind(sensor, input)) {
9041
+ continue;
9042
+ }
9035
9043
  if (!sensor.supports) {
9036
9044
  relevantSensors.push(sensor);
9037
9045
  continue;
@@ -9131,6 +9139,28 @@ var init_axis_sensor_chain_service = __esm({
9131
9139
  } : void 0
9132
9140
  };
9133
9141
  }
9142
+ matchesProofKind(sensor, input) {
9143
+ const meta = Reflect.getMetadata(
9144
+ SENSOR_METADATA_KEY,
9145
+ sensor.constructor
9146
+ );
9147
+ if (!meta || meta === true) return true;
9148
+ const currentProofKinds = this.normalizeProofKinds(
9149
+ input.metadata?.proofKind ?? input.requiredProof
9150
+ );
9151
+ const excludedProofKinds = this.normalizeProofKinds(meta.excludeProofKind);
9152
+ if (excludedProofKinds.length > 0 && currentProofKinds.some((kind) => excludedProofKinds.includes(kind))) {
9153
+ return false;
9154
+ }
9155
+ const requiredProofKinds = this.normalizeProofKinds(meta.proofKind);
9156
+ if (requiredProofKinds.length === 0) return true;
9157
+ return currentProofKinds.some((kind) => requiredProofKinds.includes(kind));
9158
+ }
9159
+ normalizeProofKinds(value) {
9160
+ if (value === void 0 || value === null) return [];
9161
+ const items = Array.isArray(value) ? value : [value];
9162
+ return items.map((item) => String(item).trim().toUpperCase()).filter(Boolean);
9163
+ }
9134
9164
  };
9135
9165
  }
9136
9166
  });
@@ -9504,10 +9534,11 @@ var init_timeline_store = __esm({
9504
9534
  });
9505
9535
 
9506
9536
  // src/utils/axis-tlv-codec.ts
9507
- function encodeAxisTlvDto(dtoClass, data) {
9537
+ function encodeAxisTlvDto(dtoClass, data, context = {}) {
9508
9538
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9509
9539
  const items = schema.fields.flatMap((field) => {
9510
9540
  const value = data[field.name];
9541
+ if (!shouldEncodeField(field, value, data, context)) return [];
9511
9542
  if (value === void 0 || value === null) {
9512
9543
  if (field.required) {
9513
9544
  throw new Error(`Missing required TLV response field: ${field.name}`);
@@ -9518,6 +9549,42 @@ function encodeAxisTlvDto(dtoClass, data) {
9518
9549
  });
9519
9550
  return buildTLVs(items);
9520
9551
  }
9552
+ function projectAxisTlvDto(dtoClass, data, context = {}) {
9553
+ const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9554
+ const result = {};
9555
+ for (const field of schema.fields) {
9556
+ const value = data[field.name];
9557
+ if (!shouldEncodeField(field, value, data, context)) continue;
9558
+ if (value === void 0 || value === null) continue;
9559
+ result[field.name] = value;
9560
+ }
9561
+ return result;
9562
+ }
9563
+ function shouldEncodeField(field, value, data, context) {
9564
+ const rule = field.encode;
9565
+ if (rule === void 0) return true;
9566
+ if (rule === false) return false;
9567
+ if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
9568
+ return false;
9569
+ }
9570
+ if (rule.exceptRoles?.length && hasAnyRole(context, rule.exceptRoles)) {
9571
+ return false;
9572
+ }
9573
+ if (rule.policy) {
9574
+ const policy = context.policies?.[rule.policy];
9575
+ if (!policy) {
9576
+ throw new Error(`Missing TLV encode policy: ${rule.policy}`);
9577
+ }
9578
+ if (!policy({ field, value, data, context })) {
9579
+ return false;
9580
+ }
9581
+ }
9582
+ return true;
9583
+ }
9584
+ function hasAnyRole(context, expectedRoles) {
9585
+ const actualRoles = context.roles ?? [];
9586
+ return expectedRoles.some((role) => actualRoles.includes(role));
9587
+ }
9521
9588
  function encodeField(field, value) {
9522
9589
  switch (field.kind) {
9523
9590
  case "utf8":
@@ -11261,6 +11328,7 @@ __export(index_exports, {
11261
11328
  parseScope: () => parseScope,
11262
11329
  parseStreamEntries: () => parseStreamEntries,
11263
11330
  projectAt: () => projectAt,
11331
+ projectAxisTlvDto: () => projectAxisTlvDto,
11264
11332
  queryFabric: () => queryFabric,
11265
11333
  recordOccurrence: () => recordOccurrence,
11266
11334
  recordSensor: () => recordSensor,