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

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;
@@ -10691,15 +10730,52 @@ var require_chunk_hash_sensor = __commonJS({
10691
10730
  var require_entropy_sensor = __commonJS({
10692
10731
  "src/sensors/entropy.sensor.ts"(exports) {
10693
10732
  "use strict";
10733
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
10734
+ if (k2 === void 0) k2 = k;
10735
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10736
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10737
+ desc = { enumerable: true, get: function() {
10738
+ return m[k];
10739
+ } };
10740
+ }
10741
+ Object.defineProperty(o, k2, desc);
10742
+ }) : (function(o, m, k, k2) {
10743
+ if (k2 === void 0) k2 = k;
10744
+ o[k2] = m[k];
10745
+ }));
10746
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
10747
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
10748
+ }) : function(o, v) {
10749
+ o["default"] = v;
10750
+ });
10694
10751
  var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
10695
10752
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10696
10753
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10697
10754
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10698
10755
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10699
10756
  };
10757
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
10758
+ var ownKeys = function(o) {
10759
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
10760
+ var ar = [];
10761
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
10762
+ return ar;
10763
+ };
10764
+ return ownKeys(o);
10765
+ };
10766
+ return function(mod) {
10767
+ if (mod && mod.__esModule) return mod;
10768
+ var result = {};
10769
+ if (mod != null) {
10770
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
10771
+ }
10772
+ __setModuleDefault(result, mod);
10773
+ return result;
10774
+ };
10775
+ })();
10700
10776
  Object.defineProperty(exports, "__esModule", { value: true });
10701
10777
  exports.EntropySensor = void 0;
10702
- var crypto4 = __require("crypto");
10778
+ var crypto4 = __importStar(__require("crypto"));
10703
10779
  var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
10704
10780
  var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
10705
10781
  var constants_1 = (init_constants(), __toCommonJS(constants_exports));
@@ -10838,8 +10914,8 @@ var require_execution_timeout_sensor = __commonJS({
10838
10914
  this.name = "ExecutionTimeoutSensor";
10839
10915
  this.order = sensor_bands_1.BAND.BUSINESS + 10;
10840
10916
  }
10841
- supports(input) {
10842
- return !!input.intent;
10917
+ async supports() {
10918
+ return Promise.resolve({ action: "ALLOW" });
10843
10919
  }
10844
10920
  async run(input) {
10845
10921
  const { intent, context } = input;
@@ -10892,8 +10968,12 @@ var require_frame_budget_sensor = __commonJS({
10892
10968
  this.name = "FrameBudgetSensor";
10893
10969
  this.order = sensor_bands_1.BAND.WIRE + 20;
10894
10970
  }
10895
- supports(input) {
10896
- return typeof input.contentLength === "number";
10971
+ async supports(input) {
10972
+ return typeof input.contentLength === "number" ? { action: "ALLOW" } : {
10973
+ action: "DENY",
10974
+ code: "SENSOR_NOT_APPLICABLE",
10975
+ reason: "Content-Length not available"
10976
+ };
10897
10977
  }
10898
10978
  async run(input) {
10899
10979
  const maxBytes = Number(process.env["AXIS_MAX_FRAME_SIZE"]) || 50 * 1024 * 1024;
@@ -10938,8 +11018,12 @@ var require_frame_header_sanity_sensor = __commonJS({
10938
11018
  this.name = "FrameHeaderSanitySensor";
10939
11019
  this.order = sensor_bands_1.BAND.WIRE + 30;
10940
11020
  }
10941
- supports(input) {
10942
- return !!input.peek && input.peek.length >= 7;
11021
+ async supports(input) {
11022
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
11023
+ action: "DENY",
11024
+ code: "SENSOR_NOT_APPLICABLE",
11025
+ reason: "Insufficient peek data for header sanity checks"
11026
+ };
10943
11027
  }
10944
11028
  async run(input) {
10945
11029
  const peek = input.peek;
@@ -11005,8 +11089,12 @@ var require_header_tlv_limit_sensor = __commonJS({
11005
11089
  this.order = sensor_bands_1.BAND.CONTENT + 0;
11006
11090
  this.MAX_TLVS = 64;
11007
11091
  }
11008
- supports(input) {
11009
- return !!input.headerTLVs || !!input.packet;
11092
+ async supports(input) {
11093
+ return !!input.headerTLVs || !!input.packet ? { action: "ALLOW" } : {
11094
+ action: "DENY",
11095
+ code: "SENSOR_NOT_APPLICABLE",
11096
+ reason: "Header TLV context is not available"
11097
+ };
11010
11098
  }
11011
11099
  async run(input) {
11012
11100
  if (input.headerTLVs && input.headerTLVs.size > this.MAX_TLVS) {
@@ -11062,8 +11150,12 @@ var require_intent_allowlist_sensor = __commonJS({
11062
11150
  this.name = "IntentAllowlistSensor";
11063
11151
  this.order = sensor_bands_1.BAND.IDENTITY + 20;
11064
11152
  }
11065
- supports(input) {
11066
- return !!input.intent;
11153
+ async supports(input) {
11154
+ return !!input.intent ? { action: "ALLOW" } : {
11155
+ action: "DENY",
11156
+ code: "SENSOR_NOT_APPLICABLE",
11157
+ reason: "Intent is not available"
11158
+ };
11067
11159
  }
11068
11160
  async run(input) {
11069
11161
  const profile = input.metadata?.profile || "PUBLIC";
@@ -11113,8 +11205,8 @@ var require_intent_registry_sensor = __commonJS({
11113
11205
  this.name = "IntentRegistrySensor";
11114
11206
  this.order = sensor_bands_1.BAND.IDENTITY + 25;
11115
11207
  }
11116
- supports(input) {
11117
- return !!input.intent;
11208
+ async supports() {
11209
+ return Promise.resolve({ action: "ALLOW" });
11118
11210
  }
11119
11211
  async run(input) {
11120
11212
  const intent = input.intent;
@@ -11163,8 +11255,12 @@ var require_law_evaluation_sensor = __commonJS({
11163
11255
  this.name = "LawEvaluationSensor";
11164
11256
  this.order = sensor_bands_1.BAND.POLICY + 5;
11165
11257
  }
11166
- supports(input) {
11167
- return !!this.options.evaluator && !!input.intent;
11258
+ async supports(input) {
11259
+ return !!this.options.evaluator && !!input.intent ? { action: "ALLOW" } : {
11260
+ action: "DENY",
11261
+ code: "SENSOR_NOT_APPLICABLE",
11262
+ reason: "Law evaluator or intent missing"
11263
+ };
11168
11264
  }
11169
11265
  async run(input) {
11170
11266
  const evaluator = this.options.evaluator;
@@ -11230,7 +11326,9 @@ var require_law_evaluation_sensor = __commonJS({
11230
11326
  return {
11231
11327
  action: "FLAG",
11232
11328
  scoreDelta: 25,
11233
- reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
11329
+ reasons: reasons.length > 0 ? reasons : [
11330
+ "Execution is conditionally permitted pending additional requirements"
11331
+ ],
11234
11332
  meta: result
11235
11333
  };
11236
11334
  }
@@ -11356,10 +11454,15 @@ var init_axis_schemas = __esm({
11356
11454
  ScanBurstDecisionZ = SensorDecisionWithMetadataZ;
11357
11455
  ProofKindZ = z2.enum([
11358
11456
  "NONE",
11359
- "CAPSULE",
11457
+ "ANONYMOUS",
11360
11458
  "PASSPORT",
11459
+ "CAPSULE",
11460
+ "JWT",
11461
+ "CONTRACT",
11462
+ "WITNESS",
11361
11463
  "MTLS",
11362
- "JWT"
11464
+ "DEVICE",
11465
+ "AUTHORIZED"
11363
11466
  ]);
11364
11467
  AccessProfileZ = z2.enum(["PUBLIC", "PARTNER", "INTERNAL", "NODE"]);
11365
11468
  ProofPresenceInputZ = z2.object({
@@ -11481,7 +11584,10 @@ var init_axis_schemas = __esm({
11481
11584
  ip: z2.string().min(1)
11482
11585
  });
11483
11586
  ProtocolStrictInputZ = z2.object({
11484
- rawBytes: z2.union([z2.custom((v) => Buffer.isBuffer(v)), z2.instanceof(Uint8Array)]).optional(),
11587
+ rawBytes: z2.union([
11588
+ z2.custom((v) => Buffer.isBuffer(v)),
11589
+ z2.instanceof(Uint8Array)
11590
+ ]).optional(),
11485
11591
  ip: z2.string().min(1),
11486
11592
  path: z2.string().min(1),
11487
11593
  contentLength: z2.number().int().nonnegative(),
@@ -11621,8 +11727,11 @@ var require_proof_presence_sensor = __commonJS({
11621
11727
  this.name = "ProofPresenceSensor";
11622
11728
  this.order = sensor_bands_1.BAND.IDENTITY + 30;
11623
11729
  }
11624
- supports(input) {
11625
- return !!input.profile && !!input.visibility;
11730
+ async supports(input) {
11731
+ if (!!input.profile && !!input.visibility) {
11732
+ return { action: "ALLOW" };
11733
+ }
11734
+ return { action: "DENY", code: "MISSING_REQUIRED_FIELDS" };
11626
11735
  }
11627
11736
  async run(input) {
11628
11737
  const validatedInput = axis_schemas_1.ProofPresenceInputZ.safeParse(input);
@@ -11916,8 +12025,8 @@ var require_receipt_policy_sensor = __commonJS({
11916
12025
  this.name = "ReceiptPolicySensor";
11917
12026
  this.order = sensor_bands_1.BAND.BUSINESS + 20;
11918
12027
  }
11919
- supports() {
11920
- return true;
12028
+ async supports() {
12029
+ return { action: "ALLOW" };
11921
12030
  }
11922
12031
  async run() {
11923
12032
  return { action: "ALLOW" };
@@ -12077,8 +12186,11 @@ var require_schema_validation_sensor = __commonJS({
12077
12186
  this.name = "SchemaValidationSensor";
12078
12187
  this.order = sensor_bands_1.BAND.CONTENT + 35;
12079
12188
  }
12080
- supports(input) {
12081
- return !!input.metadata?.schema;
12189
+ async supports(input) {
12190
+ if (input.metadata?.schema) {
12191
+ return { action: "ALLOW" };
12192
+ }
12193
+ return { action: "DENY", code: "SCHEMA_NOT_CONFIGURED" };
12082
12194
  }
12083
12195
  async run(input) {
12084
12196
  const schema = input.metadata?.schema;
@@ -12203,8 +12315,8 @@ var require_stream_scope_sensor = __commonJS({
12203
12315
  this.name = "StreamScopeSensor";
12204
12316
  this.order = sensor_bands_1.BAND.BUSINESS + 0;
12205
12317
  }
12206
- supports() {
12207
- return true;
12318
+ async supports() {
12319
+ return { action: "ALLOW" };
12208
12320
  }
12209
12321
  async run() {
12210
12322
  return { action: "ALLOW" };
@@ -12242,8 +12354,12 @@ var require_tickauth_sensor = __commonJS({
12242
12354
  this.matchIntent = options.matchIntent ?? true;
12243
12355
  this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
12244
12356
  }
12245
- supports(input) {
12246
- return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
12357
+ async supports(input) {
12358
+ return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule) ? { action: "ALLOW" } : {
12359
+ action: "DENY",
12360
+ code: "SENSOR_NOT_APPLICABLE",
12361
+ reason: "TickAuth capsule not found"
12362
+ };
12247
12363
  }
12248
12364
  async run(input) {
12249
12365
  const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
@@ -12349,8 +12465,12 @@ var require_tlv_parse_sensor = __commonJS({
12349
12465
  this.name = "TLVParseSensor";
12350
12466
  this.order = sensor_bands_1.BAND.CONTENT + 20;
12351
12467
  }
12352
- supports(input) {
12353
- return !!input.packet;
12468
+ async supports(input) {
12469
+ return !!input.packet ? { action: "ALLOW" } : {
12470
+ action: "DENY",
12471
+ code: "SENSOR_NOT_APPLICABLE",
12472
+ reason: "Packet is not available"
12473
+ };
12354
12474
  }
12355
12475
  async run(input) {
12356
12476
  const packet = input.packet;
@@ -12482,9 +12602,13 @@ var require_tps_sensor = __commonJS({
12482
12602
  this.maxDriftMs = options.maxDriftMs ?? 3e4;
12483
12603
  this.resolver = options.resolver ?? parseINotation;
12484
12604
  }
12485
- supports(input) {
12605
+ async supports(input) {
12486
12606
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
12487
- return typeof tps === "string" && tps.length > 0;
12607
+ return typeof tps === "string" && tps.length > 0 ? { action: "ALLOW" } : {
12608
+ action: "DENY",
12609
+ code: "SENSOR_NOT_APPLICABLE",
12610
+ reason: "TPS coordinate not available"
12611
+ };
12488
12612
  }
12489
12613
  async run(input) {
12490
12614
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
@@ -12550,8 +12674,12 @@ var require_varint_hardening_sensor = __commonJS({
12550
12674
  this.order = sensor_bands_1.BAND.WIRE + 35;
12551
12675
  this.MAX_VARINT_BYTES = 5;
12552
12676
  }
12553
- supports(input) {
12554
- return !!input.peek && input.peek.length >= 7;
12677
+ async supports(input) {
12678
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
12679
+ action: "DENY",
12680
+ code: "SENSOR_NOT_APPLICABLE",
12681
+ reason: "Insufficient peek data for varint hardening"
12682
+ };
12555
12683
  }
12556
12684
  async run(input) {
12557
12685
  const peek = input.peek;