@nextera.one/axis-server-sdk 2.3.10 → 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.
@@ -450,6 +450,31 @@ var init_capsule_policy_decorator = __esm({
450
450
 
451
451
  // src/decorators/intent-policy.decorator.ts
452
452
  import "reflect-metadata";
453
+ function appendRequiredProof(target, propertyKey, proof) {
454
+ const existing = propertyKey !== void 0 ? Reflect.getMetadata(
455
+ REQUIRED_PROOF_METADATA_KEY,
456
+ target,
457
+ propertyKey
458
+ ) ?? [] : Reflect.getMetadata(
459
+ REQUIRED_PROOF_METADATA_KEY,
460
+ target
461
+ ) ?? [];
462
+ const merged = existing.includes(proof) ? existing : [...existing, proof];
463
+ if (propertyKey !== void 0) {
464
+ Reflect.defineMetadata(
465
+ REQUIRED_PROOF_METADATA_KEY,
466
+ merged,
467
+ target,
468
+ propertyKey
469
+ );
470
+ return;
471
+ }
472
+ Reflect.defineMetadata(
473
+ REQUIRED_PROOF_METADATA_KEY,
474
+ merged,
475
+ target
476
+ );
477
+ }
453
478
  function Sensitivity(level) {
454
479
  return ((target, propertyKey) => {
455
480
  if (propertyKey !== void 0) {
@@ -498,56 +523,12 @@ function RequiredProof(proofs) {
498
523
  }
499
524
  function Capsule() {
500
525
  return ((target, propertyKey) => {
501
- const existing = propertyKey !== void 0 ? Reflect.getMetadata(
502
- REQUIRED_PROOF_METADATA_KEY,
503
- target,
504
- propertyKey
505
- ) ?? [] : Reflect.getMetadata(
506
- REQUIRED_PROOF_METADATA_KEY,
507
- target
508
- ) ?? [];
509
- const merged = existing.includes("CAPSULE") ? existing : [...existing, "CAPSULE"];
510
- if (propertyKey !== void 0) {
511
- Reflect.defineMetadata(
512
- REQUIRED_PROOF_METADATA_KEY,
513
- merged,
514
- target,
515
- propertyKey
516
- );
517
- } else {
518
- Reflect.defineMetadata(
519
- REQUIRED_PROOF_METADATA_KEY,
520
- merged,
521
- target
522
- );
523
- }
526
+ appendRequiredProof(target, propertyKey, "CAPSULE");
524
527
  });
525
528
  }
526
529
  function Witness() {
527
530
  return ((target, propertyKey) => {
528
- const existing = propertyKey !== void 0 ? Reflect.getMetadata(
529
- REQUIRED_PROOF_METADATA_KEY,
530
- target,
531
- propertyKey
532
- ) ?? [] : Reflect.getMetadata(
533
- REQUIRED_PROOF_METADATA_KEY,
534
- target
535
- ) ?? [];
536
- const merged = existing.includes("WITNESS") ? existing : [...existing, "WITNESS"];
537
- if (propertyKey !== void 0) {
538
- Reflect.defineMetadata(
539
- REQUIRED_PROOF_METADATA_KEY,
540
- merged,
541
- target,
542
- propertyKey
543
- );
544
- } else {
545
- Reflect.defineMetadata(
546
- REQUIRED_PROOF_METADATA_KEY,
547
- merged,
548
- target
549
- );
550
- }
531
+ appendRequiredProof(target, propertyKey, "WITNESS");
551
532
  });
552
533
  }
553
534
  function Axis() {
@@ -557,31 +538,37 @@ function Axis() {
557
538
  }
558
539
  function AxisPublic() {
559
540
  return (target, propertyKey, descriptor) => {
560
- if (descriptor) {
541
+ if (propertyKey !== void 0) {
561
542
  Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target, propertyKey);
543
+ appendRequiredProof(target, propertyKey, "NONE");
562
544
  return descriptor;
563
545
  }
564
546
  Reflect.defineMetadata(AXIS_PUBLIC_KEY, true, target);
547
+ appendRequiredProof(target, void 0, "NONE");
565
548
  return target;
566
549
  };
567
550
  }
568
551
  function AxisAuthorized() {
569
552
  return (target, propertyKey, descriptor) => {
570
- if (descriptor) {
553
+ if (propertyKey !== void 0) {
571
554
  Reflect.defineMetadata(AXIS_AUTHORIZED_KEY, true, target, propertyKey);
555
+ appendRequiredProof(target, propertyKey, "AUTHORIZED");
572
556
  return descriptor;
573
557
  }
574
558
  Reflect.defineMetadata(AXIS_AUTHORIZED_KEY, true, target);
559
+ appendRequiredProof(target, void 0, "AUTHORIZED");
575
560
  return target;
576
561
  };
577
562
  }
578
563
  function AxisAnonymous() {
579
564
  return (target, propertyKey, descriptor) => {
580
- if (descriptor) {
565
+ if (propertyKey !== void 0) {
581
566
  Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target, propertyKey);
567
+ appendRequiredProof(target, propertyKey, "ANONYMOUS");
582
568
  return descriptor;
583
569
  }
584
570
  Reflect.defineMetadata(AXIS_ANONYMOUS_KEY, true, target);
571
+ appendRequiredProof(target, void 0, "ANONYMOUS");
585
572
  return target;
586
573
  };
587
574
  }
@@ -2536,6 +2523,22 @@ function sensorRefKey(ref) {
2536
2523
  function sensorBindingKey(binding) {
2537
2524
  return `${binding.when}:${sensorRefKey(binding.ref)}`;
2538
2525
  }
2526
+ function mergeProofKinds(...proofGroups) {
2527
+ const merged = /* @__PURE__ */ new Set();
2528
+ for (const proofs of proofGroups) {
2529
+ for (const proof of proofs ?? []) {
2530
+ merged.add(proof);
2531
+ }
2532
+ }
2533
+ return Array.from(merged);
2534
+ }
2535
+ function accessProofKinds(isPublic, isAnonymous, isAuthorized) {
2536
+ const proofs = [];
2537
+ if (isPublic) proofs.push("NONE");
2538
+ if (isAnonymous) proofs.push("ANONYMOUS");
2539
+ if (isAuthorized) proofs.push("AUTHORIZED");
2540
+ return proofs;
2541
+ }
2539
2542
  function mergeIntentSensorBindings(...sensorGroups) {
2540
2543
  const merged = /* @__PURE__ */ new Map();
2541
2544
  for (const group of sensorGroups) {
@@ -3070,10 +3073,6 @@ var init_intent_router = __esm({
3070
3073
  REQUIRED_PROOF_METADATA_KEY,
3071
3074
  proto.constructor
3072
3075
  );
3073
- const requiredProof = methodProof ?? classProof;
3074
- if (requiredProof && requiredProof.length > 0) {
3075
- this.intentRequiredProof.set(intent, requiredProof);
3076
- }
3077
3076
  const isPublicMethod = Reflect.getMetadata(
3078
3077
  AXIS_PUBLIC_KEY,
3079
3078
  proto,
@@ -3083,9 +3082,6 @@ var init_intent_router = __esm({
3083
3082
  AXIS_PUBLIC_KEY,
3084
3083
  proto.constructor
3085
3084
  );
3086
- if (isPublicMethod || isPublicClass) {
3087
- this.publicIntents.add(intent);
3088
- }
3089
3085
  const isAnonMethod = Reflect.getMetadata(
3090
3086
  AXIS_ANONYMOUS_KEY,
3091
3087
  proto,
@@ -3095,9 +3091,6 @@ var init_intent_router = __esm({
3095
3091
  AXIS_ANONYMOUS_KEY,
3096
3092
  proto.constructor
3097
3093
  );
3098
- if (isAnonMethod || isAnonClass) {
3099
- this.anonymousIntents.add(intent);
3100
- }
3101
3094
  const isAuthorizedMethod = Reflect.getMetadata(
3102
3095
  AXIS_AUTHORIZED_KEY,
3103
3096
  proto,
@@ -3107,7 +3100,25 @@ var init_intent_router = __esm({
3107
3100
  AXIS_AUTHORIZED_KEY,
3108
3101
  proto.constructor
3109
3102
  );
3110
- if (isAuthorizedMethod || isAuthorizedClass) {
3103
+ const methodPolicyProof = mergeProofKinds(
3104
+ methodProof,
3105
+ accessProofKinds(isPublicMethod, isAnonMethod, isAuthorizedMethod)
3106
+ );
3107
+ const classPolicyProof = mergeProofKinds(
3108
+ classProof,
3109
+ accessProofKinds(isPublicClass, isAnonClass, isAuthorizedClass)
3110
+ );
3111
+ const requiredProof = methodPolicyProof.length ? methodPolicyProof : classPolicyProof;
3112
+ if (requiredProof.length > 0) {
3113
+ this.intentRequiredProof.set(intent, requiredProof);
3114
+ }
3115
+ if (requiredProof.includes("NONE")) {
3116
+ this.publicIntents.add(intent);
3117
+ }
3118
+ if (requiredProof.includes("ANONYMOUS")) {
3119
+ this.anonymousIntents.add(intent);
3120
+ }
3121
+ if (requiredProof.includes("AUTHORIZED")) {
3111
3122
  this.authorizedIntents.add(intent);
3112
3123
  }
3113
3124
  const rateLimit = Reflect.getMetadata(