@nextera.one/axis-server-sdk 2.3.15 → 2.3.17

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.
@@ -450,15 +450,19 @@ var init_capsule_policy_decorator = __esm({
450
450
 
451
451
  // src/decorators/intent-policy.decorator.ts
452
452
  import "reflect-metadata";
453
+ function normalizeRequiredProof(proofs) {
454
+ if (proofs === void 0) return void 0;
455
+ const normalized = Array.from(
456
+ new Set(Array.isArray(proofs) ? proofs : [proofs])
457
+ );
458
+ return normalized.length > 0 ? normalized : void 0;
459
+ }
453
460
  function appendRequiredProof(target, propertyKey, proof) {
454
461
  const existing = propertyKey !== void 0 ? Reflect.getMetadata(
455
462
  REQUIRED_PROOF_METADATA_KEY,
456
463
  target,
457
464
  propertyKey
458
- ) ?? [] : Reflect.getMetadata(
459
- REQUIRED_PROOF_METADATA_KEY,
460
- target
461
- ) ?? [];
465
+ ) ?? [] : Reflect.getMetadata(REQUIRED_PROOF_METADATA_KEY, target) ?? [];
462
466
  const merged = existing.includes(proof) ? existing : [...existing, proof];
463
467
  if (propertyKey !== void 0) {
464
468
  Reflect.defineMetadata(
@@ -698,7 +702,12 @@ function toIntentSensorBinding(input) {
698
702
  }
699
703
  function Intent(action, options) {
700
704
  return (target, propertyKey) => {
701
- const metadata = { intent: action, ...options };
705
+ const requiredProof = normalizeRequiredProof(options?.requiredProof);
706
+ const metadata = {
707
+ intent: action,
708
+ ...options,
709
+ ...requiredProof ? { requiredProof } : {}
710
+ };
702
711
  Reflect.defineMetadata(INTENT_METADATA_KEY, metadata, target, propertyKey);
703
712
  if (options?.decoder) {
704
713
  Reflect.defineMetadata(
@@ -716,6 +725,14 @@ function Intent(action, options) {
716
725
  propertyKey
717
726
  );
718
727
  }
728
+ if (requiredProof) {
729
+ Reflect.defineMetadata(
730
+ REQUIRED_PROOF_METADATA_KEY,
731
+ requiredProof,
732
+ target,
733
+ propertyKey
734
+ );
735
+ }
719
736
  const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
720
737
  routes.push({
721
738
  action,
@@ -724,6 +741,7 @@ function Intent(action, options) {
724
741
  frame: options?.frame,
725
742
  kind: options?.kind,
726
743
  sensitivity: options?.sensitivity,
744
+ requiredProof,
727
745
  chain: options?.chain,
728
746
  bodyProfile: options?.bodyProfile,
729
747
  tlv: options?.tlv,
@@ -2653,7 +2671,10 @@ var intent_router_exports = {};
2653
2671
  __export(intent_router_exports, {
2654
2672
  IntentRouter: () => IntentRouter
2655
2673
  });
2656
- import { decodeChainEnvelope, decodeChainRequest } from "@nextera.one/axis-protocol";
2674
+ import {
2675
+ decodeChainEnvelope,
2676
+ decodeChainRequest
2677
+ } from "@nextera.one/axis-protocol";
2657
2678
  function observerRefKey(ref) {
2658
2679
  return typeof ref === "string" ? ref : ref.name;
2659
2680
  }
@@ -2845,7 +2866,9 @@ var init_intent_router = __esm({
2845
2866
  */
2846
2867
  register(intent, handler) {
2847
2868
  if (this.handlers.has(intent)) {
2848
- this.logger.warn(`Intent ${intent} is already registered; replacing handler`);
2869
+ this.logger.warn(
2870
+ `Intent ${intent} is already registered; replacing handler`
2871
+ );
2849
2872
  }
2850
2873
  this.handlers.set(intent, handler);
2851
2874
  if (typeof handler === "function" && handler.name) {
@@ -3116,7 +3139,9 @@ var init_intent_router = __esm({
3116
3139
  body: bodyRes
3117
3140
  };
3118
3141
  }
3119
- throw new Error(`Handler for ${intent} does not implement handle or execute`);
3142
+ throw new Error(
3143
+ `Handler for ${intent} does not implement handle or execute`
3144
+ );
3120
3145
  }
3121
3146
  logIntent(intent, start, ok, error) {
3122
3147
  const diff = process.hrtime(start);
@@ -3211,9 +3236,11 @@ var init_intent_router = __esm({
3211
3236
  if (contract) {
3212
3237
  this.intentContracts.set(intent, contract);
3213
3238
  }
3239
+ const inlineRequiredProof = normalizeRequiredProof(meta?.requiredProof);
3214
3240
  const proofPolicy = resolveIntentProofPolicy(proto, methodName);
3215
- if (proofPolicy.requiredProof.length > 0) {
3216
- this.intentRequiredProof.set(intent, proofPolicy.requiredProof);
3241
+ const requiredProof = inlineRequiredProof ?? proofPolicy.requiredProof;
3242
+ if (requiredProof.length > 0) {
3243
+ this.intentRequiredProof.set(intent, requiredProof);
3217
3244
  }
3218
3245
  const rateLimit = Reflect.getMetadata(
3219
3246
  AXIS_RATE_LIMIT_KEY,
@@ -3822,6 +3849,7 @@ var init_intent_router = __esm({
3822
3849
  intent: meta.intent,
3823
3850
  version: 1,
3824
3851
  bodyProfile: meta.bodyProfile || "TLV_MAP",
3852
+ dtoName: meta.dto.name || void 0,
3825
3853
  fields: extracted.fields.map((f) => ({
3826
3854
  name: f.name,
3827
3855
  tlv: f.tag,