@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.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",
@@ -8447,9 +8448,37 @@ var init_axis_sensor_chain_service = __esm({
8447
8448
  );
8448
8449
  }
8449
8450
  async evaluateSensors(sensors, input, baseDecision) {
8450
- const relevantSensors = sensors.filter(
8451
- (s) => !s.supports || s.supports(input)
8452
- );
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
+ }
8453
8482
  const normalizedBase = baseDecision ? normalizeSensorDecision(baseDecision) : void 0;
8454
8483
  let riskScore = normalizedBase?.riskScore ?? 0;
8455
8484
  const reasons = normalizedBase?.reasons ? [...normalizedBase.reasons] : [];
@@ -10404,8 +10433,9 @@ var require_access_profile_resolver_sensor = __commonJS({
10404
10433
  this.name = "AccessProfileResolverSensor";
10405
10434
  this.order = sensor_bands_1.BAND.IDENTITY + 10;
10406
10435
  }
10407
- supports() {
10408
- return true;
10436
+ async supports(input) {
10437
+ void input;
10438
+ return { action: "ALLOW" };
10409
10439
  }
10410
10440
  async run(input) {
10411
10441
  const hasCapsule = !!input.metadata?.capsuleId;
@@ -10446,8 +10476,12 @@ var require_body_budget_sensor = __commonJS({
10446
10476
  this.name = "BodyBudgetSensor";
10447
10477
  this.order = sensor_bands_1.BAND.CONTENT + 10;
10448
10478
  }
10449
- supports(input) {
10450
- 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
+ };
10451
10485
  }
10452
10486
  async run(input) {
10453
10487
  const { peek } = input;
@@ -10511,8 +10545,9 @@ var require_capability_enforcement_sensor = __commonJS({
10511
10545
  this.name = "CapabilityEnforcementSensor";
10512
10546
  this.order = sensor_bands_1.BAND.POLICY + 10;
10513
10547
  }
10514
- supports(input) {
10515
- return !!input.intent;
10548
+ async supports(input) {
10549
+ void input;
10550
+ return { action: "ALLOW" };
10516
10551
  }
10517
10552
  async run(input) {
10518
10553
  const { intent, packet } = input;
@@ -10578,8 +10613,12 @@ var require_chunk_hash_sensor = __commonJS({
10578
10613
  this.name = "ChunkHashSensor";
10579
10614
  this.order = sensor_bands_1.BAND.CONTENT + 50;
10580
10615
  }
10581
- supports(input) {
10582
- 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
+ };
10583
10622
  }
10584
10623
  async run(input) {
10585
10624
  const headerTLVs = input.headerTLVs;
@@ -10622,15 +10661,52 @@ var require_chunk_hash_sensor = __commonJS({
10622
10661
  var require_entropy_sensor = __commonJS({
10623
10662
  "src/sensors/entropy.sensor.ts"(exports2) {
10624
10663
  "use strict";
10664
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
10665
+ if (k2 === void 0) k2 = k;
10666
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10667
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10668
+ desc = { enumerable: true, get: function() {
10669
+ return m[k];
10670
+ } };
10671
+ }
10672
+ Object.defineProperty(o, k2, desc);
10673
+ }) : (function(o, m, k, k2) {
10674
+ if (k2 === void 0) k2 = k;
10675
+ o[k2] = m[k];
10676
+ }));
10677
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
10678
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
10679
+ }) : function(o, v) {
10680
+ o["default"] = v;
10681
+ });
10625
10682
  var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
10626
10683
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10627
10684
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10628
10685
  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;
10629
10686
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10630
10687
  };
10688
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
10689
+ var ownKeys = function(o) {
10690
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
10691
+ var ar = [];
10692
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
10693
+ return ar;
10694
+ };
10695
+ return ownKeys(o);
10696
+ };
10697
+ return function(mod) {
10698
+ if (mod && mod.__esModule) return mod;
10699
+ var result = {};
10700
+ if (mod != null) {
10701
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
10702
+ }
10703
+ __setModuleDefault(result, mod);
10704
+ return result;
10705
+ };
10706
+ })();
10631
10707
  Object.defineProperty(exports2, "__esModule", { value: true });
10632
10708
  exports2.EntropySensor = void 0;
10633
- var crypto4 = require("crypto");
10709
+ var crypto4 = __importStar(require("crypto"));
10634
10710
  var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
10635
10711
  var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
10636
10712
  var constants_1 = (init_constants(), __toCommonJS(constants_exports));
@@ -10769,8 +10845,8 @@ var require_execution_timeout_sensor = __commonJS({
10769
10845
  this.name = "ExecutionTimeoutSensor";
10770
10846
  this.order = sensor_bands_1.BAND.BUSINESS + 10;
10771
10847
  }
10772
- supports(input) {
10773
- return !!input.intent;
10848
+ async supports() {
10849
+ return Promise.resolve({ action: "ALLOW" });
10774
10850
  }
10775
10851
  async run(input) {
10776
10852
  const { intent, context } = input;
@@ -10823,8 +10899,12 @@ var require_frame_budget_sensor = __commonJS({
10823
10899
  this.name = "FrameBudgetSensor";
10824
10900
  this.order = sensor_bands_1.BAND.WIRE + 20;
10825
10901
  }
10826
- supports(input) {
10827
- return typeof input.contentLength === "number";
10902
+ async supports(input) {
10903
+ return typeof input.contentLength === "number" ? { action: "ALLOW" } : {
10904
+ action: "DENY",
10905
+ code: "SENSOR_NOT_APPLICABLE",
10906
+ reason: "Content-Length not available"
10907
+ };
10828
10908
  }
10829
10909
  async run(input) {
10830
10910
  const maxBytes = Number(process.env["AXIS_MAX_FRAME_SIZE"]) || 50 * 1024 * 1024;
@@ -10869,8 +10949,12 @@ var require_frame_header_sanity_sensor = __commonJS({
10869
10949
  this.name = "FrameHeaderSanitySensor";
10870
10950
  this.order = sensor_bands_1.BAND.WIRE + 30;
10871
10951
  }
10872
- supports(input) {
10873
- return !!input.peek && input.peek.length >= 7;
10952
+ async supports(input) {
10953
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
10954
+ action: "DENY",
10955
+ code: "SENSOR_NOT_APPLICABLE",
10956
+ reason: "Insufficient peek data for header sanity checks"
10957
+ };
10874
10958
  }
10875
10959
  async run(input) {
10876
10960
  const peek = input.peek;
@@ -10936,8 +11020,12 @@ var require_header_tlv_limit_sensor = __commonJS({
10936
11020
  this.order = sensor_bands_1.BAND.CONTENT + 0;
10937
11021
  this.MAX_TLVS = 64;
10938
11022
  }
10939
- supports(input) {
10940
- return !!input.headerTLVs || !!input.packet;
11023
+ async supports(input) {
11024
+ return !!input.headerTLVs || !!input.packet ? { action: "ALLOW" } : {
11025
+ action: "DENY",
11026
+ code: "SENSOR_NOT_APPLICABLE",
11027
+ reason: "Header TLV context is not available"
11028
+ };
10941
11029
  }
10942
11030
  async run(input) {
10943
11031
  if (input.headerTLVs && input.headerTLVs.size > this.MAX_TLVS) {
@@ -10993,8 +11081,12 @@ var require_intent_allowlist_sensor = __commonJS({
10993
11081
  this.name = "IntentAllowlistSensor";
10994
11082
  this.order = sensor_bands_1.BAND.IDENTITY + 20;
10995
11083
  }
10996
- supports(input) {
10997
- return !!input.intent;
11084
+ async supports(input) {
11085
+ return !!input.intent ? { action: "ALLOW" } : {
11086
+ action: "DENY",
11087
+ code: "SENSOR_NOT_APPLICABLE",
11088
+ reason: "Intent is not available"
11089
+ };
10998
11090
  }
10999
11091
  async run(input) {
11000
11092
  const profile = input.metadata?.profile || "PUBLIC";
@@ -11044,8 +11136,8 @@ var require_intent_registry_sensor = __commonJS({
11044
11136
  this.name = "IntentRegistrySensor";
11045
11137
  this.order = sensor_bands_1.BAND.IDENTITY + 25;
11046
11138
  }
11047
- supports(input) {
11048
- return !!input.intent;
11139
+ async supports() {
11140
+ return Promise.resolve({ action: "ALLOW" });
11049
11141
  }
11050
11142
  async run(input) {
11051
11143
  const intent = input.intent;
@@ -11094,8 +11186,12 @@ var require_law_evaluation_sensor = __commonJS({
11094
11186
  this.name = "LawEvaluationSensor";
11095
11187
  this.order = sensor_bands_1.BAND.POLICY + 5;
11096
11188
  }
11097
- supports(input) {
11098
- return !!this.options.evaluator && !!input.intent;
11189
+ async supports(input) {
11190
+ return !!this.options.evaluator && !!input.intent ? { action: "ALLOW" } : {
11191
+ action: "DENY",
11192
+ code: "SENSOR_NOT_APPLICABLE",
11193
+ reason: "Law evaluator or intent missing"
11194
+ };
11099
11195
  }
11100
11196
  async run(input) {
11101
11197
  const evaluator = this.options.evaluator;
@@ -11161,7 +11257,9 @@ var require_law_evaluation_sensor = __commonJS({
11161
11257
  return {
11162
11258
  action: "FLAG",
11163
11259
  scoreDelta: 25,
11164
- reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
11260
+ reasons: reasons.length > 0 ? reasons : [
11261
+ "Execution is conditionally permitted pending additional requirements"
11262
+ ],
11165
11263
  meta: result
11166
11264
  };
11167
11265
  }
@@ -11287,10 +11385,15 @@ var init_axis_schemas = __esm({
11287
11385
  ScanBurstDecisionZ = SensorDecisionWithMetadataZ;
11288
11386
  ProofKindZ = z2.enum([
11289
11387
  "NONE",
11290
- "CAPSULE",
11388
+ "ANONYMOUS",
11291
11389
  "PASSPORT",
11390
+ "CAPSULE",
11391
+ "JWT",
11392
+ "CONTRACT",
11393
+ "WITNESS",
11292
11394
  "MTLS",
11293
- "JWT"
11395
+ "DEVICE",
11396
+ "AUTHORIZED"
11294
11397
  ]);
11295
11398
  AccessProfileZ = z2.enum(["PUBLIC", "PARTNER", "INTERNAL", "NODE"]);
11296
11399
  ProofPresenceInputZ = z2.object({
@@ -11412,7 +11515,10 @@ var init_axis_schemas = __esm({
11412
11515
  ip: z2.string().min(1)
11413
11516
  });
11414
11517
  ProtocolStrictInputZ = z2.object({
11415
- rawBytes: z2.union([z2.custom((v) => Buffer.isBuffer(v)), z2.instanceof(Uint8Array)]).optional(),
11518
+ rawBytes: z2.union([
11519
+ z2.custom((v) => Buffer.isBuffer(v)),
11520
+ z2.instanceof(Uint8Array)
11521
+ ]).optional(),
11416
11522
  ip: z2.string().min(1),
11417
11523
  path: z2.string().min(1),
11418
11524
  contentLength: z2.number().int().nonnegative(),
@@ -11552,8 +11658,11 @@ var require_proof_presence_sensor = __commonJS({
11552
11658
  this.name = "ProofPresenceSensor";
11553
11659
  this.order = sensor_bands_1.BAND.IDENTITY + 30;
11554
11660
  }
11555
- supports(input) {
11556
- return !!input.profile && !!input.visibility;
11661
+ async supports(input) {
11662
+ if (!!input.profile && !!input.visibility) {
11663
+ return { action: "ALLOW" };
11664
+ }
11665
+ return { action: "DENY", code: "MISSING_REQUIRED_FIELDS" };
11557
11666
  }
11558
11667
  async run(input) {
11559
11668
  const validatedInput = axis_schemas_1.ProofPresenceInputZ.safeParse(input);
@@ -11847,8 +11956,8 @@ var require_receipt_policy_sensor = __commonJS({
11847
11956
  this.name = "ReceiptPolicySensor";
11848
11957
  this.order = sensor_bands_1.BAND.BUSINESS + 20;
11849
11958
  }
11850
- supports() {
11851
- return true;
11959
+ async supports() {
11960
+ return { action: "ALLOW" };
11852
11961
  }
11853
11962
  async run() {
11854
11963
  return { action: "ALLOW" };
@@ -12008,8 +12117,11 @@ var require_schema_validation_sensor = __commonJS({
12008
12117
  this.name = "SchemaValidationSensor";
12009
12118
  this.order = sensor_bands_1.BAND.CONTENT + 35;
12010
12119
  }
12011
- supports(input) {
12012
- return !!input.metadata?.schema;
12120
+ async supports(input) {
12121
+ if (input.metadata?.schema) {
12122
+ return { action: "ALLOW" };
12123
+ }
12124
+ return { action: "DENY", code: "SCHEMA_NOT_CONFIGURED" };
12013
12125
  }
12014
12126
  async run(input) {
12015
12127
  const schema = input.metadata?.schema;
@@ -12134,8 +12246,8 @@ var require_stream_scope_sensor = __commonJS({
12134
12246
  this.name = "StreamScopeSensor";
12135
12247
  this.order = sensor_bands_1.BAND.BUSINESS + 0;
12136
12248
  }
12137
- supports() {
12138
- return true;
12249
+ async supports() {
12250
+ return { action: "ALLOW" };
12139
12251
  }
12140
12252
  async run() {
12141
12253
  return { action: "ALLOW" };
@@ -12173,8 +12285,12 @@ var require_tickauth_sensor = __commonJS({
12173
12285
  this.matchIntent = options.matchIntent ?? true;
12174
12286
  this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
12175
12287
  }
12176
- supports(input) {
12177
- return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
12288
+ async supports(input) {
12289
+ return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule) ? { action: "ALLOW" } : {
12290
+ action: "DENY",
12291
+ code: "SENSOR_NOT_APPLICABLE",
12292
+ reason: "TickAuth capsule not found"
12293
+ };
12178
12294
  }
12179
12295
  async run(input) {
12180
12296
  const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
@@ -12280,8 +12396,12 @@ var require_tlv_parse_sensor = __commonJS({
12280
12396
  this.name = "TLVParseSensor";
12281
12397
  this.order = sensor_bands_1.BAND.CONTENT + 20;
12282
12398
  }
12283
- supports(input) {
12284
- return !!input.packet;
12399
+ async supports(input) {
12400
+ return !!input.packet ? { action: "ALLOW" } : {
12401
+ action: "DENY",
12402
+ code: "SENSOR_NOT_APPLICABLE",
12403
+ reason: "Packet is not available"
12404
+ };
12285
12405
  }
12286
12406
  async run(input) {
12287
12407
  const packet = input.packet;
@@ -12413,9 +12533,13 @@ var require_tps_sensor = __commonJS({
12413
12533
  this.maxDriftMs = options.maxDriftMs ?? 3e4;
12414
12534
  this.resolver = options.resolver ?? parseINotation;
12415
12535
  }
12416
- supports(input) {
12536
+ async supports(input) {
12417
12537
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
12418
- return typeof tps === "string" && tps.length > 0;
12538
+ return typeof tps === "string" && tps.length > 0 ? { action: "ALLOW" } : {
12539
+ action: "DENY",
12540
+ code: "SENSOR_NOT_APPLICABLE",
12541
+ reason: "TPS coordinate not available"
12542
+ };
12419
12543
  }
12420
12544
  async run(input) {
12421
12545
  const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
@@ -12481,8 +12605,12 @@ var require_varint_hardening_sensor = __commonJS({
12481
12605
  this.order = sensor_bands_1.BAND.WIRE + 35;
12482
12606
  this.MAX_VARINT_BYTES = 5;
12483
12607
  }
12484
- supports(input) {
12485
- return !!input.peek && input.peek.length >= 7;
12608
+ async supports(input) {
12609
+ return !!input.peek && input.peek.length >= 7 ? { action: "ALLOW" } : {
12610
+ action: "DENY",
12611
+ code: "SENSOR_NOT_APPLICABLE",
12612
+ reason: "Insufficient peek data for varint hardening"
12613
+ };
12486
12614
  }
12487
12615
  async run(input) {
12488
12616
  const peek = input.peek;