@astrasyncai/verification-gateway 3.2.0 → 3.2.1

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.
@@ -7,7 +7,7 @@ function getTrustLevel(score) {
7
7
  }
8
8
 
9
9
  // src/version.ts
10
- var SDK_VERSION = "3.2.0";
10
+ var SDK_VERSION = "3.2.1";
11
11
 
12
12
  // src/well-known.ts
13
13
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -664,6 +664,19 @@ function resolveHttpPdlss(input) {
664
664
  return { purpose, action, purposeSource, actionSource };
665
665
  }
666
666
 
667
+ // src/adapters/approval-gate.ts
668
+ var APPROVAL_REASON = "Transaction is above the autonomous limit and requires human approval, which is not yet available \u2014 it cannot be completed automatically.";
669
+ function requiresHumanApproval(result) {
670
+ return result.requiresStepUp === true || result.requiresApproval === true;
671
+ }
672
+ function annotateApprovalRequired(result) {
673
+ result.failures = [
674
+ ...result.failures ?? [],
675
+ { dimension: "commerce.intent.approval_required", message: APPROVAL_REASON }
676
+ ];
677
+ result.denialReasons = [APPROVAL_REASON, ...result.denialReasons ?? []];
678
+ }
679
+
667
680
  // src/pdlss-pre-check.ts
668
681
  function performCounterpartyPreCheck(routeConfig, astraCreds, purpose) {
669
682
  const failures = [];
@@ -971,6 +984,16 @@ function createMiddleware(options) {
971
984
  onDenied(result, req, res);
972
985
  return;
973
986
  }
987
+ if (requiresHumanApproval(result)) {
988
+ annotateApprovalRequired(result);
989
+ if (shouldRecordDecisions && sessionId) {
990
+ recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
991
+ });
992
+ }
993
+ dedupeFailures(result);
994
+ onDenied(result, req, res);
995
+ return;
996
+ }
974
997
  if (!shouldEnforce) {
975
998
  if (config.setPassThroughHeader) {
976
999
  res.setHeader("X-Astra-Gateway-Mode", "enforced");