@nextera.one/axis-server-sdk 2.2.5 → 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",
@@ -2948,8 +2949,11 @@ var init_intent_router = __esm({
2948
2949
  return this.intentRateLimits.get(intent);
2949
2950
  }
2950
2951
  async emitIntentObservers(bindings, context) {
2951
- if (!this.observerDispatcher || bindings.length === 0) return;
2952
- await this.observerDispatcher.dispatch(bindings, context);
2952
+ if (!this.observerDispatcher) return;
2953
+ await this.observerDispatcher.dispatch(
2954
+ bindings.length > 0 ? bindings : void 0,
2955
+ context
2956
+ );
2953
2957
  }
2954
2958
  async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
2955
2959
  for (const binding of sensorBindings) {
@@ -8516,9 +8520,37 @@ var init_axis_sensor_chain_service = __esm({
8516
8520
  );
8517
8521
  }
8518
8522
  async evaluateSensors(sensors, input, baseDecision) {
8519
- const relevantSensors = sensors.filter(
8520
- (s) => !s.supports || s.supports(input)
8521
- );
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
+ }
8522
8554
  const normalizedBase = baseDecision ? normalizeSensorDecision(baseDecision) : void 0;
8523
8555
  let riskScore = normalizedBase?.riskScore ?? 0;
8524
8556
  const reasons = normalizedBase?.reasons ? [...normalizedBase.reasons] : [];
@@ -10470,8 +10502,9 @@ var require_access_profile_resolver_sensor = __commonJS({
10470
10502
  this.name = "AccessProfileResolverSensor";
10471
10503
  this.order = sensor_bands_1.BAND.IDENTITY + 10;
10472
10504
  }
10473
- supports() {
10474
- return true;
10505
+ async supports(input) {
10506
+ void input;
10507
+ return { action: "ALLOW" };
10475
10508
  }
10476
10509
  async run(input) {
10477
10510
  const hasCapsule = !!input.metadata?.capsuleId;
@@ -10512,8 +10545,12 @@ var require_body_budget_sensor = __commonJS({
10512
10545
  this.name = "BodyBudgetSensor";
10513
10546
  this.order = sensor_bands_1.BAND.CONTENT + 10;
10514
10547
  }
10515
- supports(input) {
10516
- 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
+ };
10517
10554
  }
10518
10555
  async run(input) {
10519
10556
  const { peek } = input;
@@ -10577,8 +10614,9 @@ var require_capability_enforcement_sensor = __commonJS({
10577
10614
  this.name = "CapabilityEnforcementSensor";
10578
10615
  this.order = sensor_bands_1.BAND.POLICY + 10;
10579
10616
  }
10580
- supports(input) {
10581
- return !!input.intent;
10617
+ async supports(input) {
10618
+ void input;
10619
+ return { action: "ALLOW" };
10582
10620
  }
10583
10621
  async run(input) {
10584
10622
  const { intent, packet } = input;
@@ -10644,8 +10682,12 @@ var require_chunk_hash_sensor = __commonJS({
10644
10682
  this.name = "ChunkHashSensor";
10645
10683
  this.order = sensor_bands_1.BAND.CONTENT + 50;
10646
10684
  }
10647
- supports(input) {
10648
- 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
+ };
10649
10691
  }
10650
10692
  async run(input) {
10651
10693
  const headerTLVs = input.headerTLVs;
@@ -10835,8 +10877,8 @@ var require_execution_timeout_sensor = __commonJS({
10835
10877
  this.name = "ExecutionTimeoutSensor";
10836
10878
  this.order = sensor_bands_1.BAND.BUSINESS + 10;
10837
10879
  }
10838
- supports(input) {
10839
- return !!input.intent;
10880
+ async supports() {
10881
+ return Promise.resolve({ action: "ALLOW" });
10840
10882
  }
10841
10883
  async run(input) {
10842
10884
  const { intent, context } = input;
@@ -10889,8 +10931,12 @@ var require_frame_budget_sensor = __commonJS({
10889
10931
  this.name = "FrameBudgetSensor";
10890
10932
  this.order = sensor_bands_1.BAND.WIRE + 20;
10891
10933
  }
10892
- supports(input) {
10893
- 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
+ };
10894
10940
  }
10895
10941
  async run(input) {
10896
10942
  const maxBytes = Number(process.env["AXIS_MAX_FRAME_SIZE"]) || 50 * 1024 * 1024;
@@ -10935,8 +10981,12 @@ var require_frame_header_sanity_sensor = __commonJS({
10935
10981
  this.name = "FrameHeaderSanitySensor";
10936
10982
  this.order = sensor_bands_1.BAND.WIRE + 30;
10937
10983
  }
10938
- supports(input) {
10939
- 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
+ };
10940
10990
  }
10941
10991
  async run(input) {
10942
10992
  const peek = input.peek;
@@ -11002,8 +11052,12 @@ var require_header_tlv_limit_sensor = __commonJS({
11002
11052
  this.order = sensor_bands_1.BAND.CONTENT + 0;
11003
11053
  this.MAX_TLVS = 64;
11004
11054
  }
11005
- supports(input) {
11006
- 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
+ };
11007
11061
  }
11008
11062
  async run(input) {
11009
11063
  if (input.headerTLVs && input.headerTLVs.size > this.MAX_TLVS) {
@@ -11059,8 +11113,12 @@ var require_intent_allowlist_sensor = __commonJS({
11059
11113
  this.name = "IntentAllowlistSensor";
11060
11114
  this.order = sensor_bands_1.BAND.IDENTITY + 20;
11061
11115
  }
11062
- supports(input) {
11063
- 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
+ };
11064
11122
  }
11065
11123
  async run(input) {
11066
11124
  const profile = input.metadata?.profile || "PUBLIC";
@@ -11110,8 +11168,8 @@ var require_intent_registry_sensor = __commonJS({
11110
11168
  this.name = "IntentRegistrySensor";
11111
11169
  this.order = sensor_bands_1.BAND.IDENTITY + 25;
11112
11170
  }
11113
- supports(input) {
11114
- return !!input.intent;
11171
+ async supports() {
11172
+ return Promise.resolve({ action: "ALLOW" });
11115
11173
  }
11116
11174
  async run(input) {
11117
11175
  const intent = input.intent;
@@ -11160,8 +11218,12 @@ var require_law_evaluation_sensor = __commonJS({
11160
11218
  this.name = "LawEvaluationSensor";
11161
11219
  this.order = sensor_bands_1.BAND.POLICY + 5;
11162
11220
  }
11163
- supports(input) {
11164
- 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
+ };
11165
11227
  }
11166
11228
  async run(input) {
11167
11229
  const evaluator = this.options.evaluator;
@@ -11227,7 +11289,9 @@ var require_law_evaluation_sensor = __commonJS({
11227
11289
  return {
11228
11290
  action: "FLAG",
11229
11291
  scoreDelta: 25,
11230
- 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
+ ],
11231
11295
  meta: result
11232
11296
  };
11233
11297
  }
@@ -11618,8 +11682,11 @@ var require_proof_presence_sensor = __commonJS({
11618
11682
  this.name = "ProofPresenceSensor";
11619
11683
  this.order = sensor_bands_1.BAND.IDENTITY + 30;
11620
11684
  }
11621
- supports(input) {
11622
- 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" };
11623
11690
  }
11624
11691
  async run(input) {
11625
11692
  const validatedInput = axis_schemas_1.ProofPresenceInputZ.safeParse(input);
@@ -11913,8 +11980,8 @@ var require_receipt_policy_sensor = __commonJS({
11913
11980
  this.name = "ReceiptPolicySensor";
11914
11981
  this.order = sensor_bands_1.BAND.BUSINESS + 20;
11915
11982
  }
11916
- supports() {
11917
- return true;
11983
+ async supports() {
11984
+ return { action: "ALLOW" };
11918
11985
  }
11919
11986
  async run() {
11920
11987
  return { action: "ALLOW" };
@@ -12074,8 +12141,11 @@ var require_schema_validation_sensor = __commonJS({
12074
12141
  this.name = "SchemaValidationSensor";
12075
12142
  this.order = sensor_bands_1.BAND.CONTENT + 35;
12076
12143
  }
12077
- supports(input) {
12078
- 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" };
12079
12149
  }
12080
12150
  async run(input) {
12081
12151
  const schema = input.metadata?.schema;
@@ -12200,8 +12270,8 @@ var require_stream_scope_sensor = __commonJS({
12200
12270
  this.name = "StreamScopeSensor";
12201
12271
  this.order = sensor_bands_1.BAND.BUSINESS + 0;
12202
12272
  }
12203
- supports() {
12204
- return true;
12273
+ async supports() {
12274
+ return { action: "ALLOW" };
12205
12275
  }
12206
12276
  async run() {
12207
12277
  return { action: "ALLOW" };
@@ -12239,8 +12309,12 @@ var require_tickauth_sensor = __commonJS({
12239
12309
  this.matchIntent = options.matchIntent ?? true;
12240
12310
  this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
12241
12311
  }
12242
- supports(input) {
12243
- 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
+ };
12244
12318
  }
12245
12319
  async run(input) {
12246
12320
  const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
@@ -12346,8 +12420,12 @@ var require_tlv_parse_sensor = __commonJS({
12346
12420
  this.name = "TLVParseSensor";
12347
12421
  this.order = sensor_bands_1.BAND.CONTENT + 20;
12348
12422
  }
12349
- supports(input) {
12350
- 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
+ };
12351
12429
  }
12352
12430
  async run(input) {
12353
12431
  const packet = input.packet;
@@ -12479,9 +12557,13 @@ var require_tps_sensor = __commonJS({
12479
12557
  this.maxDriftMs = options.maxDriftMs ?? 3e4;
12480
12558
  this.resolver = options.resolver ?? parseINotation;
12481
12559
  }
12482
- supports(input) {
12560
+ async supports(input) {
12483
12561
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
12484
- 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
+ };
12485
12567
  }
12486
12568
  async run(input) {
12487
12569
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
@@ -12547,8 +12629,12 @@ var require_varint_hardening_sensor = __commonJS({
12547
12629
  this.order = sensor_bands_1.BAND.WIRE + 35;
12548
12630
  this.MAX_VARINT_BYTES = 5;
12549
12631
  }
12550
- supports(input) {
12551
- 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
+ };
12552
12638
  }
12553
12639
  async run(input) {
12554
12640
  const peek = input.peek;