@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.js CHANGED
@@ -1427,6 +1427,7 @@ var init_cce_types = __esm({
1427
1427
  CAPSULE_NOT_YET_VALID: "CCE_CAPSULE_NOT_YET_VALID",
1428
1428
  CAPSULE_REVOKED: "CCE_CAPSULE_REVOKED",
1429
1429
  CAPSULE_CONSUMED: "CCE_CAPSULE_CONSUMED",
1430
+ CAPSULE_NOT_VERIFIED: "CCE_CAPSULE_NOT_VERIFIED",
1430
1431
  // Binding errors
1431
1432
  AUDIENCE_MISMATCH: "CCE_AUDIENCE_MISMATCH",
1432
1433
  INTENT_MISMATCH: "CCE_INTENT_MISMATCH",
@@ -2874,8 +2875,11 @@ var init_intent_router = __esm({
2874
2875
  return this.intentRateLimits.get(intent);
2875
2876
  }
2876
2877
  async emitIntentObservers(bindings, context) {
2877
- if (!this.observerDispatcher || bindings.length === 0) return;
2878
- await this.observerDispatcher.dispatch(bindings, context);
2878
+ if (!this.observerDispatcher) return;
2879
+ await this.observerDispatcher.dispatch(
2880
+ bindings.length > 0 ? bindings : void 0,
2881
+ context
2882
+ );
2879
2883
  }
2880
2884
  async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
2881
2885
  for (const binding of sensorBindings) {
@@ -8444,9 +8448,37 @@ var init_axis_sensor_chain_service = __esm({
8444
8448
  );
8445
8449
  }
8446
8450
  async evaluateSensors(sensors, input, baseDecision) {
8447
- const relevantSensors = sensors.filter(
8448
- (s) => !s.supports || s.supports(input)
8449
- );
8451
+ const relevantSensors = [];
8452
+ for (const sensor of sensors) {
8453
+ if (!sensor.supports) {
8454
+ relevantSensors.push(sensor);
8455
+ continue;
8456
+ }
8457
+ try {
8458
+ const supportsDecision = normalizeSensorDecision(
8459
+ await sensor.supports(input)
8460
+ );
8461
+ if (supportsDecision.allow) {
8462
+ relevantSensors.push(sensor);
8463
+ }
8464
+ } catch (error) {
8465
+ console.error(
8466
+ `[AXIS][SENSOR] ${sensor.name} supports() failed:`,
8467
+ error
8468
+ );
8469
+ const obs = input.metadata?.observation;
8470
+ if (obs) {
8471
+ recordSensor(obs, sensor.name, false, 100, 0, [
8472
+ `sensor_support_error:${sensor.name}`
8473
+ ]);
8474
+ }
8475
+ return {
8476
+ allow: false,
8477
+ riskScore: 100,
8478
+ reasons: [`sensor_support_error:${sensor.name}`]
8479
+ };
8480
+ }
8481
+ }
8450
8482
  const normalizedBase = baseDecision ? normalizeSensorDecision(baseDecision) : void 0;
8451
8483
  let riskScore = normalizedBase?.riskScore ?? 0;
8452
8484
  const reasons = normalizedBase?.reasons ? [...normalizedBase.reasons] : [];
@@ -10401,8 +10433,9 @@ var require_access_profile_resolver_sensor = __commonJS({
10401
10433
  this.name = "AccessProfileResolverSensor";
10402
10434
  this.order = sensor_bands_1.BAND.IDENTITY + 10;
10403
10435
  }
10404
- supports() {
10405
- return true;
10436
+ async supports(input) {
10437
+ void input;
10438
+ return { action: "ALLOW" };
10406
10439
  }
10407
10440
  async run(input) {
10408
10441
  const hasCapsule = !!input.metadata?.capsuleId;
@@ -10443,8 +10476,12 @@ var require_body_budget_sensor = __commonJS({
10443
10476
  this.name = "BodyBudgetSensor";
10444
10477
  this.order = sensor_bands_1.BAND.CONTENT + 10;
10445
10478
  }
10446
- supports(input) {
10447
- return !!input.peek && input.peek.length >= 8;
10479
+ async supports(input) {
10480
+ return !!input.peek && input.peek.length >= 8 ? { action: "ALLOW" } : {
10481
+ action: "DENY",
10482
+ code: "SENSOR_NOT_APPLICABLE",
10483
+ reason: "Insufficient peek data to read headers"
10484
+ };
10448
10485
  }
10449
10486
  async run(input) {
10450
10487
  const { peek } = input;
@@ -10508,8 +10545,9 @@ var require_capability_enforcement_sensor = __commonJS({
10508
10545
  this.name = "CapabilityEnforcementSensor";
10509
10546
  this.order = sensor_bands_1.BAND.POLICY + 10;
10510
10547
  }
10511
- supports(input) {
10512
- return !!input.intent;
10548
+ async supports(input) {
10549
+ void input;
10550
+ return { action: "ALLOW" };
10513
10551
  }
10514
10552
  async run(input) {
10515
10553
  const { intent, packet } = input;
@@ -10575,8 +10613,12 @@ var require_chunk_hash_sensor = __commonJS({
10575
10613
  this.name = "ChunkHashSensor";
10576
10614
  this.order = sensor_bands_1.BAND.CONTENT + 50;
10577
10615
  }
10578
- supports(input) {
10579
- return input.intent === "file.chunk";
10616
+ async supports(input) {
10617
+ return input.intent === "file.chunk" ? { action: "ALLOW" } : {
10618
+ action: "DENY",
10619
+ code: "SENSOR_NOT_APPLICABLE",
10620
+ reason: "Only file.chunk intent is supported"
10621
+ };
10580
10622
  }
10581
10623
  async run(input) {
10582
10624
  const headerTLVs = input.headerTLVs;
@@ -10766,8 +10808,8 @@ var require_execution_timeout_sensor = __commonJS({
10766
10808
  this.name = "ExecutionTimeoutSensor";
10767
10809
  this.order = sensor_bands_1.BAND.BUSINESS + 10;
10768
10810
  }
10769
- supports(input) {
10770
- return !!input.intent;
10811
+ async supports() {
10812
+ return Promise.resolve({ action: "ALLOW" });
10771
10813
  }
10772
10814
  async run(input) {
10773
10815
  const { intent, context } = input;
@@ -10820,8 +10862,12 @@ var require_frame_budget_sensor = __commonJS({
10820
10862
  this.name = "FrameBudgetSensor";
10821
10863
  this.order = sensor_bands_1.BAND.WIRE + 20;
10822
10864
  }
10823
- supports(input) {
10824
- return typeof input.contentLength === "number";
10865
+ async supports(input) {
10866
+ return typeof input.contentLength === "number" ? { action: "ALLOW" } : {
10867
+ action: "DENY",
10868
+ code: "SENSOR_NOT_APPLICABLE",
10869
+ reason: "Content-Length not available"
10870
+ };
10825
10871
  }
10826
10872
  async run(input) {
10827
10873
  const maxBytes = Number(process.env["AXIS_MAX_FRAME_SIZE"]) || 50 * 1024 * 1024;
@@ -10866,8 +10912,12 @@ var require_frame_header_sanity_sensor = __commonJS({
10866
10912
  this.name = "FrameHeaderSanitySensor";
10867
10913
  this.order = sensor_bands_1.BAND.WIRE + 30;
10868
10914
  }
10869
- supports(input) {
10870
- return !!input.peek && input.peek.length >= 7;
10915
+ async supports(input) {
10916
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
10917
+ action: "DENY",
10918
+ code: "SENSOR_NOT_APPLICABLE",
10919
+ reason: "Insufficient peek data for header sanity checks"
10920
+ };
10871
10921
  }
10872
10922
  async run(input) {
10873
10923
  const peek = input.peek;
@@ -10933,8 +10983,12 @@ var require_header_tlv_limit_sensor = __commonJS({
10933
10983
  this.order = sensor_bands_1.BAND.CONTENT + 0;
10934
10984
  this.MAX_TLVS = 64;
10935
10985
  }
10936
- supports(input) {
10937
- return !!input.headerTLVs || !!input.packet;
10986
+ async supports(input) {
10987
+ return !!input.headerTLVs || !!input.packet ? { action: "ALLOW" } : {
10988
+ action: "DENY",
10989
+ code: "SENSOR_NOT_APPLICABLE",
10990
+ reason: "Header TLV context is not available"
10991
+ };
10938
10992
  }
10939
10993
  async run(input) {
10940
10994
  if (input.headerTLVs && input.headerTLVs.size > this.MAX_TLVS) {
@@ -10990,8 +11044,12 @@ var require_intent_allowlist_sensor = __commonJS({
10990
11044
  this.name = "IntentAllowlistSensor";
10991
11045
  this.order = sensor_bands_1.BAND.IDENTITY + 20;
10992
11046
  }
10993
- supports(input) {
10994
- return !!input.intent;
11047
+ async supports(input) {
11048
+ return !!input.intent ? { action: "ALLOW" } : {
11049
+ action: "DENY",
11050
+ code: "SENSOR_NOT_APPLICABLE",
11051
+ reason: "Intent is not available"
11052
+ };
10995
11053
  }
10996
11054
  async run(input) {
10997
11055
  const profile = input.metadata?.profile || "PUBLIC";
@@ -11041,8 +11099,8 @@ var require_intent_registry_sensor = __commonJS({
11041
11099
  this.name = "IntentRegistrySensor";
11042
11100
  this.order = sensor_bands_1.BAND.IDENTITY + 25;
11043
11101
  }
11044
- supports(input) {
11045
- return !!input.intent;
11102
+ async supports() {
11103
+ return Promise.resolve({ action: "ALLOW" });
11046
11104
  }
11047
11105
  async run(input) {
11048
11106
  const intent = input.intent;
@@ -11091,8 +11149,12 @@ var require_law_evaluation_sensor = __commonJS({
11091
11149
  this.name = "LawEvaluationSensor";
11092
11150
  this.order = sensor_bands_1.BAND.POLICY + 5;
11093
11151
  }
11094
- supports(input) {
11095
- return !!this.options.evaluator && !!input.intent;
11152
+ async supports(input) {
11153
+ return !!this.options.evaluator && !!input.intent ? { action: "ALLOW" } : {
11154
+ action: "DENY",
11155
+ code: "SENSOR_NOT_APPLICABLE",
11156
+ reason: "Law evaluator or intent missing"
11157
+ };
11096
11158
  }
11097
11159
  async run(input) {
11098
11160
  const evaluator = this.options.evaluator;
@@ -11158,7 +11220,9 @@ var require_law_evaluation_sensor = __commonJS({
11158
11220
  return {
11159
11221
  action: "FLAG",
11160
11222
  scoreDelta: 25,
11161
- reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
11223
+ reasons: reasons.length > 0 ? reasons : [
11224
+ "Execution is conditionally permitted pending additional requirements"
11225
+ ],
11162
11226
  meta: result
11163
11227
  };
11164
11228
  }
@@ -11549,8 +11613,11 @@ var require_proof_presence_sensor = __commonJS({
11549
11613
  this.name = "ProofPresenceSensor";
11550
11614
  this.order = sensor_bands_1.BAND.IDENTITY + 30;
11551
11615
  }
11552
- supports(input) {
11553
- return !!input.profile && !!input.visibility;
11616
+ async supports(input) {
11617
+ if (!!input.profile && !!input.visibility) {
11618
+ return { action: "ALLOW" };
11619
+ }
11620
+ return { action: "DENY", code: "MISSING_REQUIRED_FIELDS" };
11554
11621
  }
11555
11622
  async run(input) {
11556
11623
  const validatedInput = axis_schemas_1.ProofPresenceInputZ.safeParse(input);
@@ -11844,8 +11911,8 @@ var require_receipt_policy_sensor = __commonJS({
11844
11911
  this.name = "ReceiptPolicySensor";
11845
11912
  this.order = sensor_bands_1.BAND.BUSINESS + 20;
11846
11913
  }
11847
- supports() {
11848
- return true;
11914
+ async supports() {
11915
+ return { action: "ALLOW" };
11849
11916
  }
11850
11917
  async run() {
11851
11918
  return { action: "ALLOW" };
@@ -12005,8 +12072,11 @@ var require_schema_validation_sensor = __commonJS({
12005
12072
  this.name = "SchemaValidationSensor";
12006
12073
  this.order = sensor_bands_1.BAND.CONTENT + 35;
12007
12074
  }
12008
- supports(input) {
12009
- return !!input.metadata?.schema;
12075
+ async supports(input) {
12076
+ if (input.metadata?.schema) {
12077
+ return { action: "ALLOW" };
12078
+ }
12079
+ return { action: "DENY", code: "SCHEMA_NOT_CONFIGURED" };
12010
12080
  }
12011
12081
  async run(input) {
12012
12082
  const schema = input.metadata?.schema;
@@ -12131,8 +12201,8 @@ var require_stream_scope_sensor = __commonJS({
12131
12201
  this.name = "StreamScopeSensor";
12132
12202
  this.order = sensor_bands_1.BAND.BUSINESS + 0;
12133
12203
  }
12134
- supports() {
12135
- return true;
12204
+ async supports() {
12205
+ return { action: "ALLOW" };
12136
12206
  }
12137
12207
  async run() {
12138
12208
  return { action: "ALLOW" };
@@ -12170,8 +12240,12 @@ var require_tickauth_sensor = __commonJS({
12170
12240
  this.matchIntent = options.matchIntent ?? true;
12171
12241
  this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
12172
12242
  }
12173
- supports(input) {
12174
- return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
12243
+ async supports(input) {
12244
+ return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule) ? { action: "ALLOW" } : {
12245
+ action: "DENY",
12246
+ code: "SENSOR_NOT_APPLICABLE",
12247
+ reason: "TickAuth capsule not found"
12248
+ };
12175
12249
  }
12176
12250
  async run(input) {
12177
12251
  const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
@@ -12277,8 +12351,12 @@ var require_tlv_parse_sensor = __commonJS({
12277
12351
  this.name = "TLVParseSensor";
12278
12352
  this.order = sensor_bands_1.BAND.CONTENT + 20;
12279
12353
  }
12280
- supports(input) {
12281
- return !!input.packet;
12354
+ async supports(input) {
12355
+ return !!input.packet ? { action: "ALLOW" } : {
12356
+ action: "DENY",
12357
+ code: "SENSOR_NOT_APPLICABLE",
12358
+ reason: "Packet is not available"
12359
+ };
12282
12360
  }
12283
12361
  async run(input) {
12284
12362
  const packet = input.packet;
@@ -12410,9 +12488,13 @@ var require_tps_sensor = __commonJS({
12410
12488
  this.maxDriftMs = options.maxDriftMs ?? 3e4;
12411
12489
  this.resolver = options.resolver ?? parseINotation;
12412
12490
  }
12413
- supports(input) {
12491
+ async supports(input) {
12414
12492
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
12415
- return typeof tps === "string" && tps.length > 0;
12493
+ return typeof tps === "string" && tps.length > 0 ? { action: "ALLOW" } : {
12494
+ action: "DENY",
12495
+ code: "SENSOR_NOT_APPLICABLE",
12496
+ reason: "TPS coordinate not available"
12497
+ };
12416
12498
  }
12417
12499
  async run(input) {
12418
12500
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
@@ -12478,8 +12560,12 @@ var require_varint_hardening_sensor = __commonJS({
12478
12560
  this.order = sensor_bands_1.BAND.WIRE + 35;
12479
12561
  this.MAX_VARINT_BYTES = 5;
12480
12562
  }
12481
- supports(input) {
12482
- return !!input.peek && input.peek.length >= 7;
12563
+ async supports(input) {
12564
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
12565
+ action: "DENY",
12566
+ code: "SENSOR_NOT_APPLICABLE",
12567
+ reason: "Insufficient peek data for varint hardening"
12568
+ };
12483
12569
  }
12484
12570
  async run(input) {
12485
12571
  const peek = input.peek;