@nextera.one/axis-server-sdk 2.3.9 → 2.3.12

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.
@@ -1,4 +1,4 @@
1
- export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawEvaluationSensor, av as ProofPresenceSensor, aw as ProtocolStrictSensor, ay as ReceiptPolicySensor, aD as RiskGateSensor, aE as RiskGateSensorOptions, aG as RiskSignalCollector, aI as SchemaValidationSensor, aK as StreamScopeSensor, aL as TLVParseSensor, aO as TickAuthCapsuleRef, aP as TickAuthSensor, aQ as TickAuthSensorOptions, aR as TickAuthVerifier, b0 as TpsSensor, b1 as TpsSensorOptions, b2 as VarintHardeningSensor } from '../index-DfG00R_f.mjs';
1
+ export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-DZdmfbDZ.mjs';
2
2
  import '../axis-sensor-BLUemDiZ.mjs';
3
3
  import 'zod';
4
4
  import '@nextera.one/axis-protocol';
@@ -1,4 +1,4 @@
1
- export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawEvaluationSensor, av as ProofPresenceSensor, aw as ProtocolStrictSensor, ay as ReceiptPolicySensor, aD as RiskGateSensor, aE as RiskGateSensorOptions, aG as RiskSignalCollector, aI as SchemaValidationSensor, aK as StreamScopeSensor, aL as TLVParseSensor, aO as TickAuthCapsuleRef, aP as TickAuthSensor, aQ as TickAuthSensorOptions, aR as TickAuthVerifier, b0 as TpsSensor, b1 as TpsSensorOptions, b2 as VarintHardeningSensor } from '../index-DPQEO0Qh.js';
1
+ export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-D_6djkZB.js';
2
2
  import '../axis-sensor-BLUemDiZ.js';
3
3
  import 'zod';
4
4
  import '@nextera.one/axis-protocol';
@@ -381,6 +381,31 @@ var init_capsule_policy_decorator = __esm({
381
381
  });
382
382
 
383
383
  // src/decorators/intent-policy.decorator.ts
384
+ function appendRequiredProof(target, propertyKey, proof) {
385
+ const existing = propertyKey !== void 0 ? Reflect.getMetadata(
386
+ REQUIRED_PROOF_METADATA_KEY,
387
+ target,
388
+ propertyKey
389
+ ) ?? [] : Reflect.getMetadata(
390
+ REQUIRED_PROOF_METADATA_KEY,
391
+ target
392
+ ) ?? [];
393
+ const merged = existing.includes(proof) ? existing : [...existing, proof];
394
+ if (propertyKey !== void 0) {
395
+ Reflect.defineMetadata(
396
+ REQUIRED_PROOF_METADATA_KEY,
397
+ merged,
398
+ target,
399
+ propertyKey
400
+ );
401
+ return;
402
+ }
403
+ Reflect.defineMetadata(
404
+ REQUIRED_PROOF_METADATA_KEY,
405
+ merged,
406
+ target
407
+ );
408
+ }
384
409
  function Sensitivity(level) {
385
410
  return ((target, propertyKey) => {
386
411
  if (propertyKey !== void 0) {
@@ -429,56 +454,12 @@ function RequiredProof(proofs) {
429
454
  }
430
455
  function Capsule() {
431
456
  return ((target, propertyKey) => {
432
- const existing = propertyKey !== void 0 ? Reflect.getMetadata(
433
- REQUIRED_PROOF_METADATA_KEY,
434
- target,
435
- propertyKey
436
- ) ?? [] : Reflect.getMetadata(
437
- REQUIRED_PROOF_METADATA_KEY,
438
- target
439
- ) ?? [];
440
- const merged = existing.includes("CAPSULE") ? existing : [...existing, "CAPSULE"];
441
- if (propertyKey !== void 0) {
442
- Reflect.defineMetadata(
443
- REQUIRED_PROOF_METADATA_KEY,
444
- merged,
445
- target,
446
- propertyKey
447
- );
448
- } else {
449
- Reflect.defineMetadata(
450
- REQUIRED_PROOF_METADATA_KEY,
451
- merged,
452
- target
453
- );
454
- }
457
+ appendRequiredProof(target, propertyKey, "CAPSULE");
455
458
  });
456
459
  }
457
460
  function Witness() {
458
461
  return ((target, propertyKey) => {
459
- const existing = propertyKey !== void 0 ? Reflect.getMetadata(
460
- REQUIRED_PROOF_METADATA_KEY,
461
- target,
462
- propertyKey
463
- ) ?? [] : Reflect.getMetadata(
464
- REQUIRED_PROOF_METADATA_KEY,
465
- target
466
- ) ?? [];
467
- const merged = existing.includes("WITNESS") ? existing : [...existing, "WITNESS"];
468
- if (propertyKey !== void 0) {
469
- Reflect.defineMetadata(
470
- REQUIRED_PROOF_METADATA_KEY,
471
- merged,
472
- target,
473
- propertyKey
474
- );
475
- } else {
476
- Reflect.defineMetadata(
477
- REQUIRED_PROOF_METADATA_KEY,
478
- merged,
479
- target
480
- );
481
- }
462
+ appendRequiredProof(target, propertyKey, "WITNESS");
482
463
  });
483
464
  }
484
465
  function Axis() {
@@ -488,31 +469,37 @@ function Axis() {
488
469
  }
489
470
  function AxisPublic() {
490
471
  return (target, propertyKey, descriptor) => {
491
- if (descriptor) {
472
+ if (propertyKey !== void 0) {
492
473
  Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target, propertyKey);
474
+ appendRequiredProof(target, propertyKey, "NONE");
493
475
  return descriptor;
494
476
  }
495
477
  Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target);
478
+ appendRequiredProof(target, void 0, "NONE");
496
479
  return target;
497
480
  };
498
481
  }
499
482
  function AxisAuthorized() {
500
483
  return (target, propertyKey, descriptor) => {
501
- if (descriptor) {
484
+ if (propertyKey !== void 0) {
502
485
  Reflect.defineMetadata(AXIS_AUTHORIZED_KEY, true, target, propertyKey);
486
+ appendRequiredProof(target, propertyKey, "AUTHORIZED");
503
487
  return descriptor;
504
488
  }
505
489
  Reflect.defineMetadata(AXIS_AUTHORIZED_KEY, true, target);
490
+ appendRequiredProof(target, void 0, "AUTHORIZED");
506
491
  return target;
507
492
  };
508
493
  }
509
494
  function AxisAnonymous() {
510
495
  return (target, propertyKey, descriptor) => {
511
- if (descriptor) {
496
+ if (propertyKey !== void 0) {
512
497
  Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target, propertyKey);
498
+ appendRequiredProof(target, propertyKey, "ANONYMOUS");
513
499
  return descriptor;
514
500
  }
515
501
  Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target);
502
+ appendRequiredProof(target, void 0, "ANONYMOUS");
516
503
  return target;
517
504
  };
518
505
  }
@@ -2465,6 +2452,22 @@ function sensorRefKey(ref) {
2465
2452
  function sensorBindingKey(binding) {
2466
2453
  return `${binding.when}:${sensorRefKey(binding.ref)}`;
2467
2454
  }
2455
+ function mergeProofKinds(...proofGroups) {
2456
+ const merged = /* @__PURE__ */ new Set();
2457
+ for (const proofs of proofGroups) {
2458
+ for (const proof of proofs ?? []) {
2459
+ merged.add(proof);
2460
+ }
2461
+ }
2462
+ return Array.from(merged);
2463
+ }
2464
+ function accessProofKinds(isPublic, isAnonymous, isAuthorized) {
2465
+ const proofs = [];
2466
+ if (isPublic) proofs.push("NONE");
2467
+ if (isAnonymous) proofs.push("ANONYMOUS");
2468
+ if (isAuthorized) proofs.push("AUTHORIZED");
2469
+ return proofs;
2470
+ }
2468
2471
  function mergeIntentSensorBindings(...sensorGroups) {
2469
2472
  const merged = /* @__PURE__ */ new Map();
2470
2473
  for (const group of sensorGroups) {
@@ -3000,10 +3003,6 @@ var init_intent_router = __esm({
3000
3003
  REQUIRED_PROOF_METADATA_KEY,
3001
3004
  proto.constructor
3002
3005
  );
3003
- const requiredProof = methodProof ?? classProof;
3004
- if (requiredProof && requiredProof.length > 0) {
3005
- this.intentRequiredProof.set(intent, requiredProof);
3006
- }
3007
3006
  const isPublicMethod = Reflect.getMetadata(
3008
3007
  AXIS_PUBLIC_KEY,
3009
3008
  proto,
@@ -3013,9 +3012,6 @@ var init_intent_router = __esm({
3013
3012
  AXIS_PUBLIC_KEY,
3014
3013
  proto.constructor
3015
3014
  );
3016
- if (isPublicMethod || isPublicClass) {
3017
- this.publicIntents.add(intent);
3018
- }
3019
3015
  const isAnonMethod = Reflect.getMetadata(
3020
3016
  AXIS_ANONYMOUS_KEY,
3021
3017
  proto,
@@ -3025,9 +3021,6 @@ var init_intent_router = __esm({
3025
3021
  AXIS_ANONYMOUS_KEY,
3026
3022
  proto.constructor
3027
3023
  );
3028
- if (isAnonMethod || isAnonClass) {
3029
- this.anonymousIntents.add(intent);
3030
- }
3031
3024
  const isAuthorizedMethod = Reflect.getMetadata(
3032
3025
  AXIS_AUTHORIZED_KEY,
3033
3026
  proto,
@@ -3037,7 +3030,25 @@ var init_intent_router = __esm({
3037
3030
  AXIS_AUTHORIZED_KEY,
3038
3031
  proto.constructor
3039
3032
  );
3040
- if (isAuthorizedMethod || isAuthorizedClass) {
3033
+ const methodPolicyProof = mergeProofKinds(
3034
+ methodProof,
3035
+ accessProofKinds(isPublicMethod, isAnonMethod, isAuthorizedMethod)
3036
+ );
3037
+ const classPolicyProof = mergeProofKinds(
3038
+ classProof,
3039
+ accessProofKinds(isPublicClass, isAnonClass, isAuthorizedClass)
3040
+ );
3041
+ const requiredProof = methodPolicyProof.length ? methodPolicyProof : classPolicyProof;
3042
+ if (requiredProof.length > 0) {
3043
+ this.intentRequiredProof.set(intent, requiredProof);
3044
+ }
3045
+ if (requiredProof.includes("NONE")) {
3046
+ this.publicIntents.add(intent);
3047
+ }
3048
+ if (requiredProof.includes("ANONYMOUS")) {
3049
+ this.anonymousIntents.add(intent);
3050
+ }
3051
+ if (requiredProof.includes("AUTHORIZED")) {
3041
3052
  this.authorizedIntents.add(intent);
3042
3053
  }
3043
3054
  const rateLimit = Reflect.getMetadata(
@@ -11745,6 +11756,80 @@ var require_intent_registry_sensor = __commonJS({
11745
11756
  }
11746
11757
  });
11747
11758
 
11759
+ // src/sensors/law-article-presence.sensor.ts
11760
+ var require_law_article_presence_sensor = __commonJS({
11761
+ "src/sensors/law-article-presence.sensor.ts"(exports2) {
11762
+ "use strict";
11763
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
11764
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11765
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11766
+ 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;
11767
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11768
+ };
11769
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
11770
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11771
+ };
11772
+ Object.defineProperty(exports2, "__esModule", { value: true });
11773
+ exports2.LawArticlePresenceSensor = void 0;
11774
+ var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
11775
+ var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
11776
+ var LawArticlePresenceSensor = class LawArticlePresenceSensor {
11777
+ constructor(options) {
11778
+ this.options = options;
11779
+ this.name = "LawArticlePresenceSensor";
11780
+ this.order = sensor_bands_1.BAND.IDENTITY + 27;
11781
+ }
11782
+ supports(input) {
11783
+ if (this.mode() === "off")
11784
+ return false;
11785
+ if (!input.intent)
11786
+ return false;
11787
+ if (this.exemptIntents().includes(input.intent))
11788
+ return false;
11789
+ return true;
11790
+ }
11791
+ async run(input) {
11792
+ const intent = input.intent;
11793
+ const count = await this.options.getLawArticleCount(intent, input);
11794
+ if (count > 0) {
11795
+ return {
11796
+ action: "ALLOW",
11797
+ meta: { lawArticles: count }
11798
+ };
11799
+ }
11800
+ const reason = `Intent '${intent}' has no law article mapping`;
11801
+ if (this.mode() === "strict") {
11802
+ return {
11803
+ action: "DENY",
11804
+ code: this.options.missingCode ?? "CAPSULE_NOT_LAWFUL",
11805
+ reason
11806
+ };
11807
+ }
11808
+ return {
11809
+ action: "FLAG",
11810
+ scoreDelta: this.options.auditScoreDelta ?? 5,
11811
+ reasons: ["LAW_ARTICLE_MISSING", reason],
11812
+ meta: { lawArticles: 0 }
11813
+ };
11814
+ }
11815
+ mode() {
11816
+ const configured = this.options.mode;
11817
+ if (typeof configured === "function")
11818
+ return configured();
11819
+ return configured ?? "audit";
11820
+ }
11821
+ exemptIntents() {
11822
+ return this.options.exemptIntents ?? ["system.ping"];
11823
+ }
11824
+ };
11825
+ exports2.LawArticlePresenceSensor = LawArticlePresenceSensor;
11826
+ exports2.LawArticlePresenceSensor = LawArticlePresenceSensor = __decorate([
11827
+ (0, sensor_decorator_1.Sensor)({ phase: "POST_DECODE" }),
11828
+ __metadata("design:paramtypes", [Object])
11829
+ ], LawArticlePresenceSensor);
11830
+ }
11831
+ });
11832
+
11748
11833
  // src/sensors/law-evaluation.sensor.ts
11749
11834
  var require_law_evaluation_sensor = __commonJS({
11750
11835
  "src/sensors/law-evaluation.sensor.ts"(exports2) {
@@ -13217,6 +13302,7 @@ var init_sensors = __esm({
13217
13302
  __reExport(sensors_exports, __toESM(require_header_tlv_limit_sensor()), module.exports);
13218
13303
  __reExport(sensors_exports, __toESM(require_intent_allowlist_sensor()), module.exports);
13219
13304
  __reExport(sensors_exports, __toESM(require_intent_registry_sensor()), module.exports);
13305
+ __reExport(sensors_exports, __toESM(require_law_article_presence_sensor()), module.exports);
13220
13306
  __reExport(sensors_exports, __toESM(require_law_evaluation_sensor()), module.exports);
13221
13307
  __reExport(sensors_exports, __toESM(require_proof_presence_sensor()), module.exports);
13222
13308
  __reExport(sensors_exports, __toESM(require_protocol_strict_sensor()), module.exports);