@nextera.one/axis-server-sdk 2.2.3 → 2.2.4

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 { k as AccessProfileResolverSensor, R as BodyBudgetSensor, W as CapabilityEnforcementSensor, $ as ChunkHashSensor, a2 as EntropySensor, a4 as ExecutionTimeoutSensor, a6 as FrameBudgetSensor, a7 as FrameHeaderSanitySensor, a8 as HeaderTLVLimitSensor, ac as IntentAllowlistSensor, af as IntentRegistrySensor, ah as LawEvaluationSensor, an as ProofPresenceSensor, ao as ProtocolStrictSensor, aq as ReceiptPolicySensor, aw as RiskGateSensor, ax as RiskGateSensorOptions, az as RiskSignalCollector, aB as SchemaValidationSensor, aD as StreamScopeSensor, aE as TLVParseSensor, aH as TickAuthCapsuleRef, aI as TickAuthSensor, aJ as TickAuthSensorOptions, aK as TickAuthVerifier, aV as TpsSensor, aW as TpsSensorOptions, aX as VarintHardeningSensor } from '../index-B2G6cbRL.mjs';
1
+ export { m as AccessProfileResolverSensor, Y as BodyBudgetSensor, $ as CapabilityEnforcementSensor, a4 as ChunkHashSensor, a7 as EntropySensor, a9 as ExecutionTimeoutSensor, ab as FrameBudgetSensor, ac as FrameHeaderSanitySensor, ad as HeaderTLVLimitSensor, ah as IntentAllowlistSensor, ak as IntentRegistrySensor, am as LawEvaluationSensor, as as ProofPresenceSensor, at as ProtocolStrictSensor, av as ReceiptPolicySensor, aB as RiskGateSensor, aC as RiskGateSensorOptions, aE as RiskSignalCollector, aG as SchemaValidationSensor, aI as StreamScopeSensor, aJ as TLVParseSensor, aM as TickAuthCapsuleRef, aN as TickAuthSensor, aO as TickAuthSensorOptions, aP as TickAuthVerifier, a_ as TpsSensor, a$ as TpsSensorOptions, b0 as VarintHardeningSensor } from '../index-C4ApiXHX.mjs';
2
2
  import '../axis-sensor-GBEI3Fab.mjs';
3
3
  import '../cce-pipeline-B-zUBHo3.mjs';
4
4
  import '@nextera.one/axis-protocol';
@@ -1,4 +1,4 @@
1
- export { k as AccessProfileResolverSensor, R as BodyBudgetSensor, W as CapabilityEnforcementSensor, $ as ChunkHashSensor, a2 as EntropySensor, a4 as ExecutionTimeoutSensor, a6 as FrameBudgetSensor, a7 as FrameHeaderSanitySensor, a8 as HeaderTLVLimitSensor, ac as IntentAllowlistSensor, af as IntentRegistrySensor, ah as LawEvaluationSensor, an as ProofPresenceSensor, ao as ProtocolStrictSensor, aq as ReceiptPolicySensor, aw as RiskGateSensor, ax as RiskGateSensorOptions, az as RiskSignalCollector, aB as SchemaValidationSensor, aD as StreamScopeSensor, aE as TLVParseSensor, aH as TickAuthCapsuleRef, aI as TickAuthSensor, aJ as TickAuthSensorOptions, aK as TickAuthVerifier, aV as TpsSensor, aW as TpsSensorOptions, aX as VarintHardeningSensor } from '../index-DbSxdR0f.js';
1
+ export { m as AccessProfileResolverSensor, Y as BodyBudgetSensor, $ as CapabilityEnforcementSensor, a4 as ChunkHashSensor, a7 as EntropySensor, a9 as ExecutionTimeoutSensor, ab as FrameBudgetSensor, ac as FrameHeaderSanitySensor, ad as HeaderTLVLimitSensor, ah as IntentAllowlistSensor, ak as IntentRegistrySensor, am as LawEvaluationSensor, as as ProofPresenceSensor, at as ProtocolStrictSensor, av as ReceiptPolicySensor, aB as RiskGateSensor, aC as RiskGateSensorOptions, aE as RiskSignalCollector, aG as SchemaValidationSensor, aI as StreamScopeSensor, aJ as TLVParseSensor, aM as TickAuthCapsuleRef, aN as TickAuthSensor, aO as TickAuthSensorOptions, aP as TickAuthVerifier, a_ as TpsSensor, a$ as TpsSensorOptions, b0 as VarintHardeningSensor } from '../index-QGwgvVDY.js';
2
2
  import '../axis-sensor-GBEI3Fab.js';
3
3
  import '../cce-pipeline-DbGBSsCG.js';
4
4
  import '@nextera.one/axis-protocol';
@@ -525,17 +525,76 @@ var init_intent_policy_decorator = __esm({
525
525
  }
526
526
  });
527
527
 
528
- // src/decorators/handler.decorator.ts
529
- function Handler(intent) {
528
+ // src/decorators/handler-sensors.decorator.ts
529
+ function HandlerSensors(sensors) {
530
530
  return (target) => {
531
- Reflect.defineMetadata(HANDLER_METADATA_KEY, { intent }, target);
531
+ Reflect.defineMetadata(HANDLER_SENSORS_KEY, sensors, target);
532
532
  };
533
533
  }
534
- var import_reflect_metadata5, HANDLER_METADATA_KEY;
535
- var init_handler_decorator = __esm({
536
- "src/decorators/handler.decorator.ts"() {
534
+ var import_reflect_metadata5, HANDLER_SENSORS_KEY;
535
+ var init_handler_sensors_decorator = __esm({
536
+ "src/decorators/handler-sensors.decorator.ts"() {
537
537
  import_reflect_metadata5 = require("reflect-metadata");
538
- HANDLER_METADATA_KEY = "axis:handler";
538
+ HANDLER_SENSORS_KEY = "axis:handler:sensors";
539
+ }
540
+ });
541
+
542
+ // src/decorators/observer.decorator.ts
543
+ function isBindingOptions(value) {
544
+ return !!value && typeof value === "object" && "use" in value;
545
+ }
546
+ function isDefinitionOptions(value) {
547
+ return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
548
+ }
549
+ function toObserverBinding(input) {
550
+ if (!input) return null;
551
+ if (isBindingOptions(input)) {
552
+ const refs = Array.isArray(input.use) ? input.use : [input.use];
553
+ return { refs, tags: input.tags, events: input.events };
554
+ }
555
+ if (Array.isArray(input)) {
556
+ return { refs: input };
557
+ }
558
+ if (typeof input === "function" || typeof input === "string") {
559
+ return { refs: [input] };
560
+ }
561
+ return null;
562
+ }
563
+ function Observer(input) {
564
+ return ((target, propertyKey) => {
565
+ const binding = toObserverBinding(input);
566
+ if (binding) {
567
+ if (propertyKey !== void 0) {
568
+ const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
569
+ existing2.push(binding);
570
+ Reflect.defineMetadata(
571
+ OBSERVER_BINDINGS_KEY,
572
+ existing2,
573
+ target,
574
+ propertyKey
575
+ );
576
+ return;
577
+ }
578
+ const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
579
+ existing.push(binding);
580
+ Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
581
+ return;
582
+ }
583
+ if (propertyKey !== void 0) {
584
+ throw new Error(
585
+ "@Observer method usage must reference one or more observer classes or names"
586
+ );
587
+ }
588
+ const definition = isDefinitionOptions(input) ? input : {};
589
+ Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
590
+ });
591
+ }
592
+ var import_reflect_metadata6, OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
593
+ var init_observer_decorator = __esm({
594
+ "src/decorators/observer.decorator.ts"() {
595
+ import_reflect_metadata6 = require("reflect-metadata");
596
+ OBSERVER_METADATA_KEY = "axis:observer";
597
+ OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
539
598
  }
540
599
  });
541
600
 
@@ -545,15 +604,30 @@ function IntentBody(decoder) {
545
604
  Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
546
605
  };
547
606
  }
548
- var import_reflect_metadata6, INTENT_BODY_KEY;
607
+ var import_reflect_metadata7, INTENT_BODY_KEY;
549
608
  var init_intent_body_decorator = __esm({
550
609
  "src/decorators/intent-body.decorator.ts"() {
551
- import_reflect_metadata6 = require("reflect-metadata");
610
+ import_reflect_metadata7 = require("reflect-metadata");
552
611
  INTENT_BODY_KEY = "axis:intent:body";
553
612
  }
554
613
  });
555
614
 
556
615
  // src/decorators/intent.decorator.ts
616
+ function isIntentSensorBindingOptions(value) {
617
+ return !!value && typeof value === "object" && !Array.isArray(value) && "use" in value;
618
+ }
619
+ function toIntentSensorBinding(input) {
620
+ if (isIntentSensorBindingOptions(input)) {
621
+ return {
622
+ ref: input.use,
623
+ when: input.when || "before"
624
+ };
625
+ }
626
+ return {
627
+ ref: input,
628
+ when: "before"
629
+ };
630
+ }
557
631
  function Intent(action, options) {
558
632
  return (target, propertyKey) => {
559
633
  const metadata = { intent: action, ...options };
@@ -591,10 +665,10 @@ function Intent(action, options) {
591
665
  Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
592
666
  };
593
667
  }
594
- var import_reflect_metadata7, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
668
+ var import_reflect_metadata8, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
595
669
  var init_intent_decorator = __esm({
596
670
  "src/decorators/intent.decorator.ts"() {
597
- import_reflect_metadata7 = require("reflect-metadata");
671
+ import_reflect_metadata8 = require("reflect-metadata");
598
672
  init_intent_body_decorator();
599
673
  init_intent_policy_decorator();
600
674
  INTENT_METADATA_KEY = "axis:intent";
@@ -602,90 +676,62 @@ var init_intent_decorator = __esm({
602
676
  }
603
677
  });
604
678
 
605
- // src/decorators/intent-sensors.decorator.ts
606
- function IntentSensors(sensors) {
607
- return (target, propertyKey) => {
608
- Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
609
- };
610
- }
611
- var import_reflect_metadata8, INTENT_SENSORS_KEY;
612
- var init_intent_sensors_decorator = __esm({
613
- "src/decorators/intent-sensors.decorator.ts"() {
614
- import_reflect_metadata8 = require("reflect-metadata");
615
- INTENT_SENSORS_KEY = "axis:intent:sensors";
616
- }
617
- });
618
-
619
- // src/decorators/observer.decorator.ts
620
- function isBindingOptions(value) {
621
- return !!value && typeof value === "object" && "use" in value;
622
- }
623
- function isDefinitionOptions(value) {
624
- return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
625
- }
626
- function toBinding(input) {
627
- if (!input) return null;
628
- if (isBindingOptions(input)) {
629
- const refs = Array.isArray(input.use) ? input.use : [input.use];
630
- return { refs, tags: input.tags, events: input.events };
631
- }
632
- if (Array.isArray(input)) {
633
- return { refs: input };
634
- }
635
- if (typeof input === "function" || typeof input === "string") {
636
- return { refs: [input] };
637
- }
638
- return null;
639
- }
640
- function Observer(input) {
641
- return ((target, propertyKey) => {
642
- const binding = toBinding(input);
643
- if (binding) {
644
- if (propertyKey !== void 0) {
645
- const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
646
- existing2.push(binding);
647
- Reflect.defineMetadata(
648
- OBSERVER_BINDINGS_KEY,
649
- existing2,
650
- target,
651
- propertyKey
652
- );
653
- return;
654
- }
655
- const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
656
- existing.push(binding);
657
- Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
658
- return;
679
+ // src/decorators/handler.decorator.ts
680
+ function Handler(intentOrOptions, options) {
681
+ return (target) => {
682
+ const intent = typeof intentOrOptions === "string" ? intentOrOptions : void 0;
683
+ const handlerOptions = typeof intentOrOptions === "string" ? options : intentOrOptions;
684
+ const sensorBindings = Array.isArray(handlerOptions?.is) ? handlerOptions.is.map(
685
+ (input) => toIntentSensorBinding(input)
686
+ ) : [];
687
+ const observerBindings = Array.isArray(
688
+ handlerOptions?.observe
689
+ ) ? handlerOptions.observe.map((input) => toObserverBinding(input)).filter((binding) => !!binding) : [];
690
+ Reflect.defineMetadata(
691
+ HANDLER_METADATA_KEY,
692
+ { intent, ...handlerOptions || {} },
693
+ target
694
+ );
695
+ if (sensorBindings.length > 0) {
696
+ const existing = Reflect.getMetadata(HANDLER_SENSORS_KEY, target) || [];
697
+ Reflect.defineMetadata(
698
+ HANDLER_SENSORS_KEY,
699
+ [...existing, ...sensorBindings],
700
+ target
701
+ );
659
702
  }
660
- if (propertyKey !== void 0) {
661
- throw new Error(
662
- "@Observer method usage must reference one or more observer classes or names"
703
+ if (observerBindings.length > 0) {
704
+ const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
705
+ Reflect.defineMetadata(
706
+ OBSERVER_BINDINGS_KEY,
707
+ [...existing, ...observerBindings],
708
+ target
663
709
  );
664
710
  }
665
- const definition = isDefinitionOptions(input) ? input : {};
666
- Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
667
- });
711
+ };
668
712
  }
669
- var import_reflect_metadata9, OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
670
- var init_observer_decorator = __esm({
671
- "src/decorators/observer.decorator.ts"() {
713
+ var import_reflect_metadata9, HANDLER_METADATA_KEY;
714
+ var init_handler_decorator = __esm({
715
+ "src/decorators/handler.decorator.ts"() {
672
716
  import_reflect_metadata9 = require("reflect-metadata");
673
- OBSERVER_METADATA_KEY = "axis:observer";
674
- OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
717
+ init_handler_sensors_decorator();
718
+ init_observer_decorator();
719
+ init_intent_decorator();
720
+ HANDLER_METADATA_KEY = "axis:handler";
675
721
  }
676
722
  });
677
723
 
678
- // src/decorators/handler-sensors.decorator.ts
679
- function HandlerSensors(sensors) {
680
- return (target) => {
681
- Reflect.defineMetadata(HANDLER_SENSORS_KEY, sensors, target);
724
+ // src/decorators/intent-sensors.decorator.ts
725
+ function IntentSensors(sensors) {
726
+ return (target, propertyKey) => {
727
+ Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
682
728
  };
683
729
  }
684
- var import_reflect_metadata10, HANDLER_SENSORS_KEY;
685
- var init_handler_sensors_decorator = __esm({
686
- "src/decorators/handler-sensors.decorator.ts"() {
730
+ var import_reflect_metadata10, INTENT_SENSORS_KEY;
731
+ var init_intent_sensors_decorator = __esm({
732
+ "src/decorators/intent-sensors.decorator.ts"() {
687
733
  import_reflect_metadata10 = require("reflect-metadata");
688
- HANDLER_SENSORS_KEY = "axis:handler:sensors";
734
+ INTENT_SENSORS_KEY = "axis:intent:sensors";
689
735
  }
690
736
  });
691
737
 
@@ -2398,15 +2444,19 @@ function observerRefKey(ref) {
2398
2444
  function sensorRefKey(ref) {
2399
2445
  return typeof ref === "string" ? ref : ref.name;
2400
2446
  }
2401
- function mergeIntentSensorRefs(...sensorGroups) {
2447
+ function sensorBindingKey(binding) {
2448
+ return `${binding.when}:${sensorRefKey(binding.ref)}`;
2449
+ }
2450
+ function mergeIntentSensorBindings(...sensorGroups) {
2402
2451
  const merged = /* @__PURE__ */ new Map();
2403
2452
  for (const group of sensorGroups) {
2404
2453
  if (!Array.isArray(group)) continue;
2405
- for (const ref of group) {
2406
- const key = sensorRefKey(ref);
2454
+ for (const input of group) {
2455
+ const binding = toIntentSensorBinding(input);
2456
+ const key = sensorBindingKey(binding);
2407
2457
  const existing = merged.get(key);
2408
- if (!existing || typeof existing === "string" && typeof ref !== "string") {
2409
- merged.set(key, ref);
2458
+ if (!existing || typeof existing.ref === "string" && typeof binding.ref !== "string") {
2459
+ merged.set(key, binding);
2410
2460
  }
2411
2461
  }
2412
2462
  }
@@ -2710,9 +2760,9 @@ var init_intent_router = __esm({
2710
2760
  if (!handler) {
2711
2761
  throw new Error(`Intent not found: ${intent}`);
2712
2762
  }
2713
- const sensorRefs = this.intentSensors.get(intent);
2714
- if (sensorRefs && sensorRefs.length > 0) {
2715
- await this.runIntentSensors(sensorRefs, intent, frame);
2763
+ const sensorBindings = this.intentSensors.get(intent);
2764
+ if (sensorBindings && sensorBindings.length > 0) {
2765
+ await this.runIntentSensors(sensorBindings, intent, frame, "before");
2716
2766
  }
2717
2767
  const decoder = this.intentDecoders.get(intent);
2718
2768
  let decodedBody = frame.body;
@@ -2754,6 +2804,12 @@ var init_intent_router = __esm({
2754
2804
  );
2755
2805
  }
2756
2806
  }
2807
+ if (sensorBindings && sensorBindings.length > 0) {
2808
+ await this.runIntentSensors(sensorBindings, intent, frame, "after", {
2809
+ decodedBody,
2810
+ effect
2811
+ });
2812
+ }
2757
2813
  }
2758
2814
  await this.emitIntentObservers(observerBindings, {
2759
2815
  event: "intent.completed",
@@ -2797,7 +2853,7 @@ var init_intent_router = __esm({
2797
2853
  methodName
2798
2854
  );
2799
2855
  const meta = Reflect.getMetadata(INTENT_METADATA_KEY, proto, methodName);
2800
- const combined = mergeIntentSensorRefs(
2856
+ const combined = mergeIntentSensorBindings(
2801
2857
  handlerSensors,
2802
2858
  Array.isArray(intentSensors) ? intentSensors : void 0,
2803
2859
  Array.isArray(meta?.is) ? meta.is : void 0
@@ -2939,8 +2995,10 @@ var init_intent_router = __esm({
2939
2995
  if (!this.observerDispatcher || bindings.length === 0) return;
2940
2996
  await this.observerDispatcher.dispatch(bindings, context);
2941
2997
  }
2942
- async runIntentSensors(sensorRefs, intent, frame) {
2943
- for (const sensorRef of sensorRefs) {
2998
+ async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
2999
+ for (const binding of sensorBindings) {
3000
+ if (binding.when !== stage && binding.when !== "both") continue;
3001
+ const sensorRef = binding.ref;
2944
3002
  const sensor = this.resolveIntentSensor(sensorRef);
2945
3003
  const sensorName = sensorRefKey(sensorRef);
2946
3004
  if (!sensor) {
@@ -2957,9 +3015,12 @@ var init_intent_router = __esm({
2957
3015
  frameBody: frame.body,
2958
3016
  metadata: {
2959
3017
  phase: "intent",
3018
+ stage,
2960
3019
  intent,
2961
3020
  schema: this.getSchema(intent),
2962
- validators: this.getValidators(intent)
3021
+ validators: this.getValidators(intent),
3022
+ decodedBody: extras?.decodedBody,
3023
+ effect: extras?.effect
2963
3024
  }
2964
3025
  };
2965
3026
  if (sensor.supports && !sensor.supports(sensorInput)) continue;
@@ -10607,6 +10668,8 @@ __export(index_exports, {
10607
10668
  startStage: () => startStage,
10608
10669
  tieKnot: () => tieKnot,
10609
10670
  tlv: () => tlv,
10671
+ toIntentSensorBinding: () => toIntentSensorBinding,
10672
+ toObserverBinding: () => toObserverBinding,
10610
10673
  u64be: () => u64be,
10611
10674
  unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
10612
10675
  unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
@@ -10638,6 +10701,7 @@ var init_index = __esm({
10638
10701
  init_intent_body_decorator();
10639
10702
  init_intent_sensors_decorator();
10640
10703
  init_observer_decorator();
10704
+ init_observer_decorator();
10641
10705
  init_handler_sensors_decorator();
10642
10706
  init_sensor_decorator();
10643
10707
  import_tlv_field2 = __toESM(require_tlv_field_decorator());