@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.
@@ -104,8 +104,9 @@ var require_access_profile_resolver_sensor = __commonJS({
104
104
  this.name = "AccessProfileResolverSensor";
105
105
  this.order = sensor_bands_1.BAND.IDENTITY + 10;
106
106
  }
107
- supports() {
108
- return true;
107
+ async supports(input) {
108
+ void input;
109
+ return { action: "ALLOW" };
109
110
  }
110
111
  async run(input) {
111
112
  const hasCapsule = !!input.metadata?.capsuleId;
@@ -317,8 +318,12 @@ var require_body_budget_sensor = __commonJS({
317
318
  this.name = "BodyBudgetSensor";
318
319
  this.order = sensor_bands_1.BAND.CONTENT + 10;
319
320
  }
320
- supports(input) {
321
- return !!input.peek && input.peek.length >= 8;
321
+ async supports(input) {
322
+ return !!input.peek && input.peek.length >= 8 ? { action: "ALLOW" } : {
323
+ action: "DENY",
324
+ code: "SENSOR_NOT_APPLICABLE",
325
+ reason: "Insufficient peek data to read headers"
326
+ };
322
327
  }
323
328
  async run(input) {
324
329
  const { peek } = input;
@@ -1645,6 +1650,7 @@ var init_cce_types = __esm({
1645
1650
  CAPSULE_NOT_YET_VALID: "CCE_CAPSULE_NOT_YET_VALID",
1646
1651
  CAPSULE_REVOKED: "CCE_CAPSULE_REVOKED",
1647
1652
  CAPSULE_CONSUMED: "CCE_CAPSULE_CONSUMED",
1653
+ CAPSULE_NOT_VERIFIED: "CCE_CAPSULE_NOT_VERIFIED",
1648
1654
  // Binding errors
1649
1655
  AUDIENCE_MISMATCH: "CCE_AUDIENCE_MISMATCH",
1650
1656
  INTENT_MISMATCH: "CCE_INTENT_MISMATCH",
@@ -8622,9 +8628,37 @@ var init_axis_sensor_chain_service = __esm({
8622
8628
  );
8623
8629
  }
8624
8630
  async evaluateSensors(sensors, input, baseDecision) {
8625
- const relevantSensors = sensors.filter(
8626
- (s) => !s.supports || s.supports(input)
8627
- );
8631
+ const relevantSensors = [];
8632
+ for (const sensor of sensors) {
8633
+ if (!sensor.supports) {
8634
+ relevantSensors.push(sensor);
8635
+ continue;
8636
+ }
8637
+ try {
8638
+ const supportsDecision = normalizeSensorDecision(
8639
+ await sensor.supports(input)
8640
+ );
8641
+ if (supportsDecision.allow) {
8642
+ relevantSensors.push(sensor);
8643
+ }
8644
+ } catch (error) {
8645
+ console.error(
8646
+ `[AXIS][SENSOR] ${sensor.name} supports() failed:`,
8647
+ error
8648
+ );
8649
+ const obs = input.metadata?.observation;
8650
+ if (obs) {
8651
+ recordSensor(obs, sensor.name, false, 100, 0, [
8652
+ `sensor_support_error:${sensor.name}`
8653
+ ]);
8654
+ }
8655
+ return {
8656
+ allow: false,
8657
+ riskScore: 100,
8658
+ reasons: [`sensor_support_error:${sensor.name}`]
8659
+ };
8660
+ }
8661
+ }
8628
8662
  const normalizedBase = baseDecision ? normalizeSensorDecision(baseDecision) : void 0;
8629
8663
  let riskScore = normalizedBase?.riskScore ?? 0;
8630
8664
  const reasons = normalizedBase?.reasons ? [...normalizedBase.reasons] : [];
@@ -10966,8 +11000,9 @@ var require_capability_enforcement_sensor = __commonJS({
10966
11000
  this.name = "CapabilityEnforcementSensor";
10967
11001
  this.order = sensor_bands_1.BAND.POLICY + 10;
10968
11002
  }
10969
- supports(input) {
10970
- return !!input.intent;
11003
+ async supports(input) {
11004
+ void input;
11005
+ return { action: "ALLOW" };
10971
11006
  }
10972
11007
  async run(input) {
10973
11008
  const { intent, packet } = input;
@@ -11033,8 +11068,12 @@ var require_chunk_hash_sensor = __commonJS({
11033
11068
  this.name = "ChunkHashSensor";
11034
11069
  this.order = sensor_bands_1.BAND.CONTENT + 50;
11035
11070
  }
11036
- supports(input) {
11037
- return input.intent === "file.chunk";
11071
+ async supports(input) {
11072
+ return input.intent === "file.chunk" ? { action: "ALLOW" } : {
11073
+ action: "DENY",
11074
+ code: "SENSOR_NOT_APPLICABLE",
11075
+ reason: "Only file.chunk intent is supported"
11076
+ };
11038
11077
  }
11039
11078
  async run(input) {
11040
11079
  const headerTLVs = input.headerTLVs;
@@ -11077,15 +11116,52 @@ var require_chunk_hash_sensor = __commonJS({
11077
11116
  var require_entropy_sensor = __commonJS({
11078
11117
  "src/sensors/entropy.sensor.ts"(exports) {
11079
11118
  "use strict";
11119
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
11120
+ if (k2 === void 0) k2 = k;
11121
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11122
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11123
+ desc = { enumerable: true, get: function() {
11124
+ return m[k];
11125
+ } };
11126
+ }
11127
+ Object.defineProperty(o, k2, desc);
11128
+ }) : (function(o, m, k, k2) {
11129
+ if (k2 === void 0) k2 = k;
11130
+ o[k2] = m[k];
11131
+ }));
11132
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
11133
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11134
+ }) : function(o, v) {
11135
+ o["default"] = v;
11136
+ });
11080
11137
  var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
11081
11138
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11082
11139
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11083
11140
  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;
11084
11141
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11085
11142
  };
11143
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
11144
+ var ownKeys = function(o) {
11145
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
11146
+ var ar = [];
11147
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
11148
+ return ar;
11149
+ };
11150
+ return ownKeys(o);
11151
+ };
11152
+ return function(mod) {
11153
+ if (mod && mod.__esModule) return mod;
11154
+ var result = {};
11155
+ if (mod != null) {
11156
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
11157
+ }
11158
+ __setModuleDefault(result, mod);
11159
+ return result;
11160
+ };
11161
+ })();
11086
11162
  Object.defineProperty(exports, "__esModule", { value: true });
11087
11163
  exports.EntropySensor = void 0;
11088
- var crypto4 = __require("crypto");
11164
+ var crypto4 = __importStar(__require("crypto"));
11089
11165
  var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
11090
11166
  var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
11091
11167
  var constants_1 = (init_constants(), __toCommonJS(constants_exports));
@@ -11224,8 +11300,8 @@ var require_execution_timeout_sensor = __commonJS({
11224
11300
  this.name = "ExecutionTimeoutSensor";
11225
11301
  this.order = sensor_bands_1.BAND.BUSINESS + 10;
11226
11302
  }
11227
- supports(input) {
11228
- return !!input.intent;
11303
+ async supports() {
11304
+ return Promise.resolve({ action: "ALLOW" });
11229
11305
  }
11230
11306
  async run(input) {
11231
11307
  const { intent, context } = input;
@@ -11278,8 +11354,12 @@ var require_frame_budget_sensor = __commonJS({
11278
11354
  this.name = "FrameBudgetSensor";
11279
11355
  this.order = sensor_bands_1.BAND.WIRE + 20;
11280
11356
  }
11281
- supports(input) {
11282
- return typeof input.contentLength === "number";
11357
+ async supports(input) {
11358
+ return typeof input.contentLength === "number" ? { action: "ALLOW" } : {
11359
+ action: "DENY",
11360
+ code: "SENSOR_NOT_APPLICABLE",
11361
+ reason: "Content-Length not available"
11362
+ };
11283
11363
  }
11284
11364
  async run(input) {
11285
11365
  const maxBytes = Number(process.env["AXIS_MAX_FRAME_SIZE"]) || 50 * 1024 * 1024;
@@ -11324,8 +11404,12 @@ var require_frame_header_sanity_sensor = __commonJS({
11324
11404
  this.name = "FrameHeaderSanitySensor";
11325
11405
  this.order = sensor_bands_1.BAND.WIRE + 30;
11326
11406
  }
11327
- supports(input) {
11328
- return !!input.peek && input.peek.length >= 7;
11407
+ async supports(input) {
11408
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
11409
+ action: "DENY",
11410
+ code: "SENSOR_NOT_APPLICABLE",
11411
+ reason: "Insufficient peek data for header sanity checks"
11412
+ };
11329
11413
  }
11330
11414
  async run(input) {
11331
11415
  const peek = input.peek;
@@ -11391,8 +11475,12 @@ var require_header_tlv_limit_sensor = __commonJS({
11391
11475
  this.order = sensor_bands_1.BAND.CONTENT + 0;
11392
11476
  this.MAX_TLVS = 64;
11393
11477
  }
11394
- supports(input) {
11395
- return !!input.headerTLVs || !!input.packet;
11478
+ async supports(input) {
11479
+ return !!input.headerTLVs || !!input.packet ? { action: "ALLOW" } : {
11480
+ action: "DENY",
11481
+ code: "SENSOR_NOT_APPLICABLE",
11482
+ reason: "Header TLV context is not available"
11483
+ };
11396
11484
  }
11397
11485
  async run(input) {
11398
11486
  if (input.headerTLVs && input.headerTLVs.size > this.MAX_TLVS) {
@@ -11448,8 +11536,12 @@ var require_intent_allowlist_sensor = __commonJS({
11448
11536
  this.name = "IntentAllowlistSensor";
11449
11537
  this.order = sensor_bands_1.BAND.IDENTITY + 20;
11450
11538
  }
11451
- supports(input) {
11452
- return !!input.intent;
11539
+ async supports(input) {
11540
+ return !!input.intent ? { action: "ALLOW" } : {
11541
+ action: "DENY",
11542
+ code: "SENSOR_NOT_APPLICABLE",
11543
+ reason: "Intent is not available"
11544
+ };
11453
11545
  }
11454
11546
  async run(input) {
11455
11547
  const profile = input.metadata?.profile || "PUBLIC";
@@ -11499,8 +11591,8 @@ var require_intent_registry_sensor = __commonJS({
11499
11591
  this.name = "IntentRegistrySensor";
11500
11592
  this.order = sensor_bands_1.BAND.IDENTITY + 25;
11501
11593
  }
11502
- supports(input) {
11503
- return !!input.intent;
11594
+ async supports() {
11595
+ return Promise.resolve({ action: "ALLOW" });
11504
11596
  }
11505
11597
  async run(input) {
11506
11598
  const intent = input.intent;
@@ -11549,8 +11641,12 @@ var require_law_evaluation_sensor = __commonJS({
11549
11641
  this.name = "LawEvaluationSensor";
11550
11642
  this.order = sensor_bands_1.BAND.POLICY + 5;
11551
11643
  }
11552
- supports(input) {
11553
- return !!this.options.evaluator && !!input.intent;
11644
+ async supports(input) {
11645
+ return !!this.options.evaluator && !!input.intent ? { action: "ALLOW" } : {
11646
+ action: "DENY",
11647
+ code: "SENSOR_NOT_APPLICABLE",
11648
+ reason: "Law evaluator or intent missing"
11649
+ };
11554
11650
  }
11555
11651
  async run(input) {
11556
11652
  const evaluator = this.options.evaluator;
@@ -11616,7 +11712,9 @@ var require_law_evaluation_sensor = __commonJS({
11616
11712
  return {
11617
11713
  action: "FLAG",
11618
11714
  scoreDelta: 25,
11619
- reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
11715
+ reasons: reasons.length > 0 ? reasons : [
11716
+ "Execution is conditionally permitted pending additional requirements"
11717
+ ],
11620
11718
  meta: result
11621
11719
  };
11622
11720
  }
@@ -11742,10 +11840,15 @@ var init_axis_schemas = __esm({
11742
11840
  ScanBurstDecisionZ = SensorDecisionWithMetadataZ;
11743
11841
  ProofKindZ = z2.enum([
11744
11842
  "NONE",
11745
- "CAPSULE",
11843
+ "ANONYMOUS",
11746
11844
  "PASSPORT",
11845
+ "CAPSULE",
11846
+ "JWT",
11847
+ "CONTRACT",
11848
+ "WITNESS",
11747
11849
  "MTLS",
11748
- "JWT"
11850
+ "DEVICE",
11851
+ "AUTHORIZED"
11749
11852
  ]);
11750
11853
  AccessProfileZ = z2.enum(["PUBLIC", "PARTNER", "INTERNAL", "NODE"]);
11751
11854
  ProofPresenceInputZ = z2.object({
@@ -11867,7 +11970,10 @@ var init_axis_schemas = __esm({
11867
11970
  ip: z2.string().min(1)
11868
11971
  });
11869
11972
  ProtocolStrictInputZ = z2.object({
11870
- rawBytes: z2.union([z2.custom((v) => Buffer.isBuffer(v)), z2.instanceof(Uint8Array)]).optional(),
11973
+ rawBytes: z2.union([
11974
+ z2.custom((v) => Buffer.isBuffer(v)),
11975
+ z2.instanceof(Uint8Array)
11976
+ ]).optional(),
11871
11977
  ip: z2.string().min(1),
11872
11978
  path: z2.string().min(1),
11873
11979
  contentLength: z2.number().int().nonnegative(),
@@ -12007,8 +12113,11 @@ var require_proof_presence_sensor = __commonJS({
12007
12113
  this.name = "ProofPresenceSensor";
12008
12114
  this.order = sensor_bands_1.BAND.IDENTITY + 30;
12009
12115
  }
12010
- supports(input) {
12011
- return !!input.profile && !!input.visibility;
12116
+ async supports(input) {
12117
+ if (!!input.profile && !!input.visibility) {
12118
+ return { action: "ALLOW" };
12119
+ }
12120
+ return { action: "DENY", code: "MISSING_REQUIRED_FIELDS" };
12012
12121
  }
12013
12122
  async run(input) {
12014
12123
  const validatedInput = axis_schemas_1.ProofPresenceInputZ.safeParse(input);
@@ -12302,8 +12411,8 @@ var require_receipt_policy_sensor = __commonJS({
12302
12411
  this.name = "ReceiptPolicySensor";
12303
12412
  this.order = sensor_bands_1.BAND.BUSINESS + 20;
12304
12413
  }
12305
- supports() {
12306
- return true;
12414
+ async supports() {
12415
+ return { action: "ALLOW" };
12307
12416
  }
12308
12417
  async run() {
12309
12418
  return { action: "ALLOW" };
@@ -12463,8 +12572,11 @@ var require_schema_validation_sensor = __commonJS({
12463
12572
  this.name = "SchemaValidationSensor";
12464
12573
  this.order = sensor_bands_1.BAND.CONTENT + 35;
12465
12574
  }
12466
- supports(input) {
12467
- return !!input.metadata?.schema;
12575
+ async supports(input) {
12576
+ if (input.metadata?.schema) {
12577
+ return { action: "ALLOW" };
12578
+ }
12579
+ return { action: "DENY", code: "SCHEMA_NOT_CONFIGURED" };
12468
12580
  }
12469
12581
  async run(input) {
12470
12582
  const schema = input.metadata?.schema;
@@ -12589,8 +12701,8 @@ var require_stream_scope_sensor = __commonJS({
12589
12701
  this.name = "StreamScopeSensor";
12590
12702
  this.order = sensor_bands_1.BAND.BUSINESS + 0;
12591
12703
  }
12592
- supports() {
12593
- return true;
12704
+ async supports() {
12705
+ return { action: "ALLOW" };
12594
12706
  }
12595
12707
  async run() {
12596
12708
  return { action: "ALLOW" };
@@ -12628,8 +12740,12 @@ var require_tickauth_sensor = __commonJS({
12628
12740
  this.matchIntent = options.matchIntent ?? true;
12629
12741
  this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
12630
12742
  }
12631
- supports(input) {
12632
- return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
12743
+ async supports(input) {
12744
+ return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule) ? { action: "ALLOW" } : {
12745
+ action: "DENY",
12746
+ code: "SENSOR_NOT_APPLICABLE",
12747
+ reason: "TickAuth capsule not found"
12748
+ };
12633
12749
  }
12634
12750
  async run(input) {
12635
12751
  const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
@@ -12735,8 +12851,12 @@ var require_tlv_parse_sensor = __commonJS({
12735
12851
  this.name = "TLVParseSensor";
12736
12852
  this.order = sensor_bands_1.BAND.CONTENT + 20;
12737
12853
  }
12738
- supports(input) {
12739
- return !!input.packet;
12854
+ async supports(input) {
12855
+ return !!input.packet ? { action: "ALLOW" } : {
12856
+ action: "DENY",
12857
+ code: "SENSOR_NOT_APPLICABLE",
12858
+ reason: "Packet is not available"
12859
+ };
12740
12860
  }
12741
12861
  async run(input) {
12742
12862
  const packet = input.packet;
@@ -12868,9 +12988,13 @@ var require_tps_sensor = __commonJS({
12868
12988
  this.maxDriftMs = options.maxDriftMs ?? 3e4;
12869
12989
  this.resolver = options.resolver ?? parseINotation;
12870
12990
  }
12871
- supports(input) {
12991
+ async supports(input) {
12872
12992
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
12873
- return typeof tps === "string" && tps.length > 0;
12993
+ return typeof tps === "string" && tps.length > 0 ? { action: "ALLOW" } : {
12994
+ action: "DENY",
12995
+ code: "SENSOR_NOT_APPLICABLE",
12996
+ reason: "TPS coordinate not available"
12997
+ };
12874
12998
  }
12875
12999
  async run(input) {
12876
13000
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
@@ -12936,8 +13060,12 @@ var require_varint_hardening_sensor = __commonJS({
12936
13060
  this.order = sensor_bands_1.BAND.WIRE + 35;
12937
13061
  this.MAX_VARINT_BYTES = 5;
12938
13062
  }
12939
- supports(input) {
12940
- return !!input.peek && input.peek.length >= 7;
13063
+ async supports(input) {
13064
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
13065
+ action: "DENY",
13066
+ code: "SENSOR_NOT_APPLICABLE",
13067
+ reason: "Insufficient peek data for varint hardening"
13068
+ };
12941
13069
  }
12942
13070
  async run(input) {
12943
13071
  const peek = input.peek;