@nextera.one/axis-server-sdk 2.2.6 → 2.2.7

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
@@ -1502,6 +1502,7 @@ var init_cce_types = __esm({
1502
1502
  CAPSULE_NOT_YET_VALID: "CCE_CAPSULE_NOT_YET_VALID",
1503
1503
  CAPSULE_REVOKED: "CCE_CAPSULE_REVOKED",
1504
1504
  CAPSULE_CONSUMED: "CCE_CAPSULE_CONSUMED",
1505
+ CAPSULE_NOT_VERIFIED: "CCE_CAPSULE_NOT_VERIFIED",
1505
1506
  // Binding errors
1506
1507
  AUDIENCE_MISMATCH: "CCE_AUDIENCE_MISMATCH",
1507
1508
  INTENT_MISMATCH: "CCE_INTENT_MISMATCH",
@@ -8519,9 +8520,37 @@ var init_axis_sensor_chain_service = __esm({
8519
8520
  );
8520
8521
  }
8521
8522
  async evaluateSensors(sensors, input, baseDecision) {
8522
- const relevantSensors = sensors.filter(
8523
- (s) => !s.supports || s.supports(input)
8524
- );
8523
+ const relevantSensors = [];
8524
+ for (const sensor of sensors) {
8525
+ if (!sensor.supports) {
8526
+ relevantSensors.push(sensor);
8527
+ continue;
8528
+ }
8529
+ try {
8530
+ const supportsDecision = normalizeSensorDecision(
8531
+ await sensor.supports(input)
8532
+ );
8533
+ if (supportsDecision.allow) {
8534
+ relevantSensors.push(sensor);
8535
+ }
8536
+ } catch (error) {
8537
+ console.error(
8538
+ `[AXIS][SENSOR] ${sensor.name} supports() failed:`,
8539
+ error
8540
+ );
8541
+ const obs = input.metadata?.observation;
8542
+ if (obs) {
8543
+ recordSensor(obs, sensor.name, false, 100, 0, [
8544
+ `sensor_support_error:${sensor.name}`
8545
+ ]);
8546
+ }
8547
+ return {
8548
+ allow: false,
8549
+ riskScore: 100,
8550
+ reasons: [`sensor_support_error:${sensor.name}`]
8551
+ };
8552
+ }
8553
+ }
8525
8554
  const normalizedBase = baseDecision ? normalizeSensorDecision(baseDecision) : void 0;
8526
8555
  let riskScore = normalizedBase?.riskScore ?? 0;
8527
8556
  const reasons = normalizedBase?.reasons ? [...normalizedBase.reasons] : [];
@@ -10473,8 +10502,9 @@ var require_access_profile_resolver_sensor = __commonJS({
10473
10502
  this.name = "AccessProfileResolverSensor";
10474
10503
  this.order = sensor_bands_1.BAND.IDENTITY + 10;
10475
10504
  }
10476
- supports() {
10477
- return true;
10505
+ async supports(input) {
10506
+ void input;
10507
+ return { action: "ALLOW" };
10478
10508
  }
10479
10509
  async run(input) {
10480
10510
  const hasCapsule = !!input.metadata?.capsuleId;
@@ -10515,8 +10545,12 @@ var require_body_budget_sensor = __commonJS({
10515
10545
  this.name = "BodyBudgetSensor";
10516
10546
  this.order = sensor_bands_1.BAND.CONTENT + 10;
10517
10547
  }
10518
- supports(input) {
10519
- return !!input.peek && input.peek.length >= 8;
10548
+ async supports(input) {
10549
+ return !!input.peek && input.peek.length >= 8 ? { action: "ALLOW" } : {
10550
+ action: "DENY",
10551
+ code: "SENSOR_NOT_APPLICABLE",
10552
+ reason: "Insufficient peek data to read headers"
10553
+ };
10520
10554
  }
10521
10555
  async run(input) {
10522
10556
  const { peek } = input;
@@ -10580,8 +10614,9 @@ var require_capability_enforcement_sensor = __commonJS({
10580
10614
  this.name = "CapabilityEnforcementSensor";
10581
10615
  this.order = sensor_bands_1.BAND.POLICY + 10;
10582
10616
  }
10583
- supports(input) {
10584
- return !!input.intent;
10617
+ async supports(input) {
10618
+ void input;
10619
+ return { action: "ALLOW" };
10585
10620
  }
10586
10621
  async run(input) {
10587
10622
  const { intent, packet } = input;
@@ -10647,8 +10682,12 @@ var require_chunk_hash_sensor = __commonJS({
10647
10682
  this.name = "ChunkHashSensor";
10648
10683
  this.order = sensor_bands_1.BAND.CONTENT + 50;
10649
10684
  }
10650
- supports(input) {
10651
- return input.intent === "file.chunk";
10685
+ async supports(input) {
10686
+ return input.intent === "file.chunk" ? { action: "ALLOW" } : {
10687
+ action: "DENY",
10688
+ code: "SENSOR_NOT_APPLICABLE",
10689
+ reason: "Only file.chunk intent is supported"
10690
+ };
10652
10691
  }
10653
10692
  async run(input) {
10654
10693
  const headerTLVs = input.headerTLVs;
@@ -10838,8 +10877,8 @@ var require_execution_timeout_sensor = __commonJS({
10838
10877
  this.name = "ExecutionTimeoutSensor";
10839
10878
  this.order = sensor_bands_1.BAND.BUSINESS + 10;
10840
10879
  }
10841
- supports(input) {
10842
- return !!input.intent;
10880
+ async supports() {
10881
+ return Promise.resolve({ action: "ALLOW" });
10843
10882
  }
10844
10883
  async run(input) {
10845
10884
  const { intent, context } = input;
@@ -10892,8 +10931,12 @@ var require_frame_budget_sensor = __commonJS({
10892
10931
  this.name = "FrameBudgetSensor";
10893
10932
  this.order = sensor_bands_1.BAND.WIRE + 20;
10894
10933
  }
10895
- supports(input) {
10896
- return typeof input.contentLength === "number";
10934
+ async supports(input) {
10935
+ return typeof input.contentLength === "number" ? { action: "ALLOW" } : {
10936
+ action: "DENY",
10937
+ code: "SENSOR_NOT_APPLICABLE",
10938
+ reason: "Content-Length not available"
10939
+ };
10897
10940
  }
10898
10941
  async run(input) {
10899
10942
  const maxBytes = Number(process.env["AXIS_MAX_FRAME_SIZE"]) || 50 * 1024 * 1024;
@@ -10938,8 +10981,12 @@ var require_frame_header_sanity_sensor = __commonJS({
10938
10981
  this.name = "FrameHeaderSanitySensor";
10939
10982
  this.order = sensor_bands_1.BAND.WIRE + 30;
10940
10983
  }
10941
- supports(input) {
10942
- return !!input.peek && input.peek.length >= 7;
10984
+ async supports(input) {
10985
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
10986
+ action: "DENY",
10987
+ code: "SENSOR_NOT_APPLICABLE",
10988
+ reason: "Insufficient peek data for header sanity checks"
10989
+ };
10943
10990
  }
10944
10991
  async run(input) {
10945
10992
  const peek = input.peek;
@@ -11005,8 +11052,12 @@ var require_header_tlv_limit_sensor = __commonJS({
11005
11052
  this.order = sensor_bands_1.BAND.CONTENT + 0;
11006
11053
  this.MAX_TLVS = 64;
11007
11054
  }
11008
- supports(input) {
11009
- return !!input.headerTLVs || !!input.packet;
11055
+ async supports(input) {
11056
+ return !!input.headerTLVs || !!input.packet ? { action: "ALLOW" } : {
11057
+ action: "DENY",
11058
+ code: "SENSOR_NOT_APPLICABLE",
11059
+ reason: "Header TLV context is not available"
11060
+ };
11010
11061
  }
11011
11062
  async run(input) {
11012
11063
  if (input.headerTLVs && input.headerTLVs.size > this.MAX_TLVS) {
@@ -11062,8 +11113,12 @@ var require_intent_allowlist_sensor = __commonJS({
11062
11113
  this.name = "IntentAllowlistSensor";
11063
11114
  this.order = sensor_bands_1.BAND.IDENTITY + 20;
11064
11115
  }
11065
- supports(input) {
11066
- return !!input.intent;
11116
+ async supports(input) {
11117
+ return !!input.intent ? { action: "ALLOW" } : {
11118
+ action: "DENY",
11119
+ code: "SENSOR_NOT_APPLICABLE",
11120
+ reason: "Intent is not available"
11121
+ };
11067
11122
  }
11068
11123
  async run(input) {
11069
11124
  const profile = input.metadata?.profile || "PUBLIC";
@@ -11113,8 +11168,8 @@ var require_intent_registry_sensor = __commonJS({
11113
11168
  this.name = "IntentRegistrySensor";
11114
11169
  this.order = sensor_bands_1.BAND.IDENTITY + 25;
11115
11170
  }
11116
- supports(input) {
11117
- return !!input.intent;
11171
+ async supports() {
11172
+ return Promise.resolve({ action: "ALLOW" });
11118
11173
  }
11119
11174
  async run(input) {
11120
11175
  const intent = input.intent;
@@ -11163,8 +11218,12 @@ var require_law_evaluation_sensor = __commonJS({
11163
11218
  this.name = "LawEvaluationSensor";
11164
11219
  this.order = sensor_bands_1.BAND.POLICY + 5;
11165
11220
  }
11166
- supports(input) {
11167
- return !!this.options.evaluator && !!input.intent;
11221
+ async supports(input) {
11222
+ return !!this.options.evaluator && !!input.intent ? { action: "ALLOW" } : {
11223
+ action: "DENY",
11224
+ code: "SENSOR_NOT_APPLICABLE",
11225
+ reason: "Law evaluator or intent missing"
11226
+ };
11168
11227
  }
11169
11228
  async run(input) {
11170
11229
  const evaluator = this.options.evaluator;
@@ -11230,7 +11289,9 @@ var require_law_evaluation_sensor = __commonJS({
11230
11289
  return {
11231
11290
  action: "FLAG",
11232
11291
  scoreDelta: 25,
11233
- reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
11292
+ reasons: reasons.length > 0 ? reasons : [
11293
+ "Execution is conditionally permitted pending additional requirements"
11294
+ ],
11234
11295
  meta: result
11235
11296
  };
11236
11297
  }
@@ -11621,8 +11682,11 @@ var require_proof_presence_sensor = __commonJS({
11621
11682
  this.name = "ProofPresenceSensor";
11622
11683
  this.order = sensor_bands_1.BAND.IDENTITY + 30;
11623
11684
  }
11624
- supports(input) {
11625
- return !!input.profile && !!input.visibility;
11685
+ async supports(input) {
11686
+ if (!!input.profile && !!input.visibility) {
11687
+ return { action: "ALLOW" };
11688
+ }
11689
+ return { action: "DENY", code: "MISSING_REQUIRED_FIELDS" };
11626
11690
  }
11627
11691
  async run(input) {
11628
11692
  const validatedInput = axis_schemas_1.ProofPresenceInputZ.safeParse(input);
@@ -11916,8 +11980,8 @@ var require_receipt_policy_sensor = __commonJS({
11916
11980
  this.name = "ReceiptPolicySensor";
11917
11981
  this.order = sensor_bands_1.BAND.BUSINESS + 20;
11918
11982
  }
11919
- supports() {
11920
- return true;
11983
+ async supports() {
11984
+ return { action: "ALLOW" };
11921
11985
  }
11922
11986
  async run() {
11923
11987
  return { action: "ALLOW" };
@@ -12077,8 +12141,11 @@ var require_schema_validation_sensor = __commonJS({
12077
12141
  this.name = "SchemaValidationSensor";
12078
12142
  this.order = sensor_bands_1.BAND.CONTENT + 35;
12079
12143
  }
12080
- supports(input) {
12081
- return !!input.metadata?.schema;
12144
+ async supports(input) {
12145
+ if (input.metadata?.schema) {
12146
+ return { action: "ALLOW" };
12147
+ }
12148
+ return { action: "DENY", code: "SCHEMA_NOT_CONFIGURED" };
12082
12149
  }
12083
12150
  async run(input) {
12084
12151
  const schema = input.metadata?.schema;
@@ -12203,8 +12270,8 @@ var require_stream_scope_sensor = __commonJS({
12203
12270
  this.name = "StreamScopeSensor";
12204
12271
  this.order = sensor_bands_1.BAND.BUSINESS + 0;
12205
12272
  }
12206
- supports() {
12207
- return true;
12273
+ async supports() {
12274
+ return { action: "ALLOW" };
12208
12275
  }
12209
12276
  async run() {
12210
12277
  return { action: "ALLOW" };
@@ -12242,8 +12309,12 @@ var require_tickauth_sensor = __commonJS({
12242
12309
  this.matchIntent = options.matchIntent ?? true;
12243
12310
  this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
12244
12311
  }
12245
- supports(input) {
12246
- return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
12312
+ async supports(input) {
12313
+ return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule) ? { action: "ALLOW" } : {
12314
+ action: "DENY",
12315
+ code: "SENSOR_NOT_APPLICABLE",
12316
+ reason: "TickAuth capsule not found"
12317
+ };
12247
12318
  }
12248
12319
  async run(input) {
12249
12320
  const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
@@ -12349,8 +12420,12 @@ var require_tlv_parse_sensor = __commonJS({
12349
12420
  this.name = "TLVParseSensor";
12350
12421
  this.order = sensor_bands_1.BAND.CONTENT + 20;
12351
12422
  }
12352
- supports(input) {
12353
- return !!input.packet;
12423
+ async supports(input) {
12424
+ return !!input.packet ? { action: "ALLOW" } : {
12425
+ action: "DENY",
12426
+ code: "SENSOR_NOT_APPLICABLE",
12427
+ reason: "Packet is not available"
12428
+ };
12354
12429
  }
12355
12430
  async run(input) {
12356
12431
  const packet = input.packet;
@@ -12482,9 +12557,13 @@ var require_tps_sensor = __commonJS({
12482
12557
  this.maxDriftMs = options.maxDriftMs ?? 3e4;
12483
12558
  this.resolver = options.resolver ?? parseINotation;
12484
12559
  }
12485
- supports(input) {
12560
+ async supports(input) {
12486
12561
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
12487
- return typeof tps === "string" && tps.length > 0;
12562
+ return typeof tps === "string" && tps.length > 0 ? { action: "ALLOW" } : {
12563
+ action: "DENY",
12564
+ code: "SENSOR_NOT_APPLICABLE",
12565
+ reason: "TPS coordinate not available"
12566
+ };
12488
12567
  }
12489
12568
  async run(input) {
12490
12569
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
@@ -12550,8 +12629,12 @@ var require_varint_hardening_sensor = __commonJS({
12550
12629
  this.order = sensor_bands_1.BAND.WIRE + 35;
12551
12630
  this.MAX_VARINT_BYTES = 5;
12552
12631
  }
12553
- supports(input) {
12554
- return !!input.peek && input.peek.length >= 7;
12632
+ async supports(input) {
12633
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
12634
+ action: "DENY",
12635
+ code: "SENSOR_NOT_APPLICABLE",
12636
+ reason: "Insufficient peek data for varint hardening"
12637
+ };
12555
12638
  }
12556
12639
  async run(input) {
12557
12640
  const peek = input.peek;