@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.
package/dist/index.mjs CHANGED
@@ -673,7 +673,8 @@ var require_dto_schema_util = __commonJS({
673
673
  required: m.options.required,
674
674
  maxLen: m.options.maxLen,
675
675
  max: m.options.max,
676
- scope: m.options.scope
676
+ scope: m.options.scope,
677
+ encode: m.options.encode
677
678
  };
678
679
  });
679
680
  const validatorMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_VALIDATORS_KEY, dto) || [];
@@ -3731,7 +3732,8 @@ var init_intent_router = __esm({
3731
3732
  required: f.required,
3732
3733
  maxLen: f.maxLen,
3733
3734
  max: f.max,
3734
- scope: f.scope
3735
+ scope: f.scope,
3736
+ ...f.encode !== void 0 ? { encode: f.encode } : {}
3735
3737
  }))
3736
3738
  };
3737
3739
  this.intentSchemas.set(meta.intent, schema2);
@@ -3755,7 +3757,8 @@ var init_intent_router = __esm({
3755
3757
  required: f.required,
3756
3758
  maxLen: f.maxLen,
3757
3759
  max: f.max,
3758
- scope: f.scope
3760
+ scope: f.scope,
3761
+ ...f.encode !== void 0 ? { encode: f.encode } : {}
3759
3762
  }))
3760
3763
  };
3761
3764
  this.intentSchemas.set(meta.intent, schema);
@@ -8883,9 +8886,11 @@ var init_axis_observation = __esm({
8883
8886
  });
8884
8887
 
8885
8888
  // src/security/axis-sensor-chain.service.ts
8889
+ import "reflect-metadata";
8886
8890
  var AxisSensorChainService;
8887
8891
  var init_axis_sensor_chain_service = __esm({
8888
8892
  "src/security/axis-sensor-chain.service.ts"() {
8893
+ init_sensor_decorator();
8889
8894
  init_axis_sensor();
8890
8895
  init_axis_observation();
8891
8896
  AxisSensorChainService = class {
@@ -8928,6 +8933,9 @@ var init_axis_sensor_chain_service = __esm({
8928
8933
  async evaluateSensors(sensors, input, baseDecision) {
8929
8934
  const relevantSensors = [];
8930
8935
  for (const sensor of sensors) {
8936
+ if (!this.matchesProofKind(sensor, input)) {
8937
+ continue;
8938
+ }
8931
8939
  if (!sensor.supports) {
8932
8940
  relevantSensors.push(sensor);
8933
8941
  continue;
@@ -9027,6 +9035,28 @@ var init_axis_sensor_chain_service = __esm({
9027
9035
  } : void 0
9028
9036
  };
9029
9037
  }
9038
+ matchesProofKind(sensor, input) {
9039
+ const meta = Reflect.getMetadata(
9040
+ SENSOR_METADATA_KEY,
9041
+ sensor.constructor
9042
+ );
9043
+ if (!meta || meta === true) return true;
9044
+ const currentProofKinds = this.normalizeProofKinds(
9045
+ input.metadata?.proofKind ?? input.requiredProof
9046
+ );
9047
+ const excludedProofKinds = this.normalizeProofKinds(meta.excludeProofKind);
9048
+ if (excludedProofKinds.length > 0 && currentProofKinds.some((kind) => excludedProofKinds.includes(kind))) {
9049
+ return false;
9050
+ }
9051
+ const requiredProofKinds = this.normalizeProofKinds(meta.proofKind);
9052
+ if (requiredProofKinds.length === 0) return true;
9053
+ return currentProofKinds.some((kind) => requiredProofKinds.includes(kind));
9054
+ }
9055
+ normalizeProofKinds(value) {
9056
+ if (value === void 0 || value === null) return [];
9057
+ const items = Array.isArray(value) ? value : [value];
9058
+ return items.map((item) => String(item).trim().toUpperCase()).filter(Boolean);
9059
+ }
9030
9060
  };
9031
9061
  }
9032
9062
  });
@@ -9400,10 +9430,11 @@ var init_timeline_store = __esm({
9400
9430
  });
9401
9431
 
9402
9432
  // src/utils/axis-tlv-codec.ts
9403
- function encodeAxisTlvDto(dtoClass, data) {
9433
+ function encodeAxisTlvDto(dtoClass, data, context = {}) {
9404
9434
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9405
9435
  const items = schema.fields.flatMap((field) => {
9406
9436
  const value = data[field.name];
9437
+ if (!shouldEncodeField(field, value, data, context)) return [];
9407
9438
  if (value === void 0 || value === null) {
9408
9439
  if (field.required) {
9409
9440
  throw new Error(`Missing required TLV response field: ${field.name}`);
@@ -9414,6 +9445,42 @@ function encodeAxisTlvDto(dtoClass, data) {
9414
9445
  });
9415
9446
  return buildTLVs(items);
9416
9447
  }
9448
+ function projectAxisTlvDto(dtoClass, data, context = {}) {
9449
+ const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9450
+ const result = {};
9451
+ for (const field of schema.fields) {
9452
+ const value = data[field.name];
9453
+ if (!shouldEncodeField(field, value, data, context)) continue;
9454
+ if (value === void 0 || value === null) continue;
9455
+ result[field.name] = value;
9456
+ }
9457
+ return result;
9458
+ }
9459
+ function shouldEncodeField(field, value, data, context) {
9460
+ const rule = field.encode;
9461
+ if (rule === void 0) return true;
9462
+ if (rule === false) return false;
9463
+ if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
9464
+ return false;
9465
+ }
9466
+ if (rule.exceptRoles?.length && hasAnyRole(context, rule.exceptRoles)) {
9467
+ return false;
9468
+ }
9469
+ if (rule.policy) {
9470
+ const policy = context.policies?.[rule.policy];
9471
+ if (!policy) {
9472
+ throw new Error(`Missing TLV encode policy: ${rule.policy}`);
9473
+ }
9474
+ if (!policy({ field, value, data, context })) {
9475
+ return false;
9476
+ }
9477
+ }
9478
+ return true;
9479
+ }
9480
+ function hasAnyRole(context, expectedRoles) {
9481
+ const actualRoles = context.roles ?? [];
9482
+ return expectedRoles.some((role) => actualRoles.includes(role));
9483
+ }
9417
9484
  function encodeField(field, value) {
9418
9485
  switch (field.kind) {
9419
9486
  case "utf8":
@@ -13428,6 +13495,7 @@ __export(index_exports, {
13428
13495
  parseScope: () => parseScope,
13429
13496
  parseStreamEntries: () => parseStreamEntries,
13430
13497
  projectAt: () => projectAt,
13498
+ projectAxisTlvDto: () => projectAxisTlvDto,
13431
13499
  queryFabric: () => queryFabric,
13432
13500
  recordOccurrence: () => recordOccurrence,
13433
13501
  recordSensor: () => recordSensor,
@@ -13834,6 +13902,7 @@ export {
13834
13902
  parseScope,
13835
13903
  parseStreamEntries,
13836
13904
  projectAt,
13905
+ projectAxisTlvDto,
13837
13906
  queryFabric,
13838
13907
  recordOccurrence,
13839
13908
  recordSensor,