@astrasyncai/verification-gateway 4.5.1 → 5.0.0

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.
Files changed (140) hide show
  1. package/README.md +1 -1
  2. package/dist/adapter-interface/interface.d.mts +2 -2
  3. package/dist/adapter-interface/interface.d.ts +2 -2
  4. package/dist/adapters/express.d.mts +2 -2
  5. package/dist/adapters/express.d.ts +2 -2
  6. package/dist/adapters/express.js +11 -33
  7. package/dist/adapters/express.js.map +1 -1
  8. package/dist/adapters/express.mjs +11 -33
  9. package/dist/adapters/express.mjs.map +1 -1
  10. package/dist/adapters/mcp.d.mts +2 -2
  11. package/dist/adapters/mcp.d.ts +2 -2
  12. package/dist/adapters/mcp.js +28 -65
  13. package/dist/adapters/mcp.js.map +1 -1
  14. package/dist/adapters/mcp.mjs +27 -64
  15. package/dist/adapters/mcp.mjs.map +1 -1
  16. package/dist/adapters/nextjs.d.mts +2 -2
  17. package/dist/adapters/nextjs.d.ts +2 -2
  18. package/dist/adapters/nextjs.js +9 -30
  19. package/dist/adapters/nextjs.js.map +1 -1
  20. package/dist/adapters/nextjs.mjs +9 -30
  21. package/dist/adapters/nextjs.mjs.map +1 -1
  22. package/dist/adapters/sdk.d.mts +2 -2
  23. package/dist/adapters/sdk.d.ts +2 -2
  24. package/dist/adapters/sdk.js +8 -124
  25. package/dist/adapters/sdk.js.map +1 -1
  26. package/dist/adapters/sdk.mjs +8 -122
  27. package/dist/adapters/sdk.mjs.map +1 -1
  28. package/dist/agent/index.d.mts +2 -2
  29. package/dist/agent/index.d.ts +2 -2
  30. package/dist/agent/index.js +1 -1
  31. package/dist/agent/index.js.map +1 -1
  32. package/dist/agent/index.mjs +1 -1
  33. package/dist/agent/index.mjs.map +1 -1
  34. package/dist/bin/astrasync-claude-hook.js +63 -41
  35. package/dist/bin/astrasync-codex-hook.js +63 -41
  36. package/dist/bin/astrasync-guard.js +63 -41
  37. package/dist/bin/astrasync.js +75 -48
  38. package/dist/browser/background.js +63 -41
  39. package/dist/browser/background.js.map +1 -1
  40. package/dist/browser/background.mjs +63 -41
  41. package/dist/browser/background.mjs.map +1 -1
  42. package/dist/browser/browser-adapter.d.mts +2 -2
  43. package/dist/browser/browser-adapter.d.ts +2 -2
  44. package/dist/claude-code/claude-code-adapter.d.mts +2 -2
  45. package/dist/claude-code/claude-code-adapter.d.ts +2 -2
  46. package/dist/cli/index.d.mts +2 -2
  47. package/dist/cli/index.d.ts +2 -2
  48. package/dist/cli/index.js +33 -6
  49. package/dist/cli/index.js.map +1 -1
  50. package/dist/cli/index.mjs +33 -6
  51. package/dist/cli/index.mjs.map +1 -1
  52. package/dist/codex/index.d.mts +2 -2
  53. package/dist/codex/index.d.ts +2 -2
  54. package/dist/codex/index.js +63 -41
  55. package/dist/codex/index.js.map +1 -1
  56. package/dist/codex/index.mjs +63 -41
  57. package/dist/codex/index.mjs.map +1 -1
  58. package/dist/cursor/cursor-adapter.d.mts +2 -2
  59. package/dist/cursor/cursor-adapter.d.ts +2 -2
  60. package/dist/cursor/extension.d.mts +2 -2
  61. package/dist/cursor/extension.d.ts +2 -2
  62. package/dist/cursor/extension.js +63 -41
  63. package/dist/cursor/extension.js.map +1 -1
  64. package/dist/cursor/extension.mjs +63 -41
  65. package/dist/cursor/extension.mjs.map +1 -1
  66. package/dist/edge-config.d.mts +1 -1
  67. package/dist/edge-config.d.ts +1 -1
  68. package/dist/edge-config.js +1 -1
  69. package/dist/edge-config.js.map +1 -1
  70. package/dist/edge-config.mjs +1 -1
  71. package/dist/edge-config.mjs.map +1 -1
  72. package/dist/edge-core/index.d.mts +1 -3
  73. package/dist/edge-core/index.d.ts +1 -3
  74. package/dist/edge-core/index.js +11 -33
  75. package/dist/edge-core/index.js.map +1 -1
  76. package/dist/edge-core/index.mjs +11 -33
  77. package/dist/edge-core/index.mjs.map +1 -1
  78. package/dist/{express-DaqL11tx.d.ts → express-B5lWuemA.d.ts} +1 -1
  79. package/dist/{express-CR6F3njD.d.mts → express-Dm-snUuY.d.mts} +1 -1
  80. package/dist/gateway/gateway.d.mts +2 -2
  81. package/dist/gateway/gateway.d.ts +2 -2
  82. package/dist/gateway/gateway.js +63 -41
  83. package/dist/gateway/gateway.js.map +1 -1
  84. package/dist/gateway/gateway.mjs +63 -41
  85. package/dist/gateway/gateway.mjs.map +1 -1
  86. package/dist/git-trigger/git-hooks.d.mts +2 -2
  87. package/dist/git-trigger/git-hooks.d.ts +2 -2
  88. package/dist/{index-Cub7lK-T.d.mts → index-B5k_vUmK.d.mts} +1 -1
  89. package/dist/{index-BfIxCYIZ.d.ts → index-BOzM6xUq.d.mts} +1 -2
  90. package/dist/{index-CwAh7Tln.d.mts → index-dRfxUdFA.d.ts} +1 -2
  91. package/dist/{index-B5Ts1WtM.d.ts → index-y8xToocF.d.ts} +1 -1
  92. package/dist/index.d.mts +10 -10
  93. package/dist/index.d.ts +10 -10
  94. package/dist/index.js +30 -217
  95. package/dist/index.js.map +1 -1
  96. package/dist/index.mjs +30 -210
  97. package/dist/index.mjs.map +1 -1
  98. package/dist/local-evaluator/evaluator.d.mts +2 -2
  99. package/dist/local-evaluator/evaluator.d.ts +2 -2
  100. package/dist/local-evaluator/evaluator.js +22 -7
  101. package/dist/local-evaluator/evaluator.js.map +1 -1
  102. package/dist/local-evaluator/evaluator.mjs +22 -7
  103. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  104. package/dist/{mcp-BgBJu4Jl.d.mts → mcp-DgsyQiQq.d.mts} +53 -52
  105. package/dist/{mcp--DgKOwfu.d.ts → mcp-OosmAcKf.d.ts} +53 -52
  106. package/dist/{nextjs-DlX6xwbU.d.mts → nextjs-B1sBdEav.d.mts} +1 -1
  107. package/dist/{nextjs-DL6uE1ye.d.ts → nextjs-DoRmhV_Z.d.ts} +1 -1
  108. package/dist/registration/index.d.mts +5 -1
  109. package/dist/registration/index.d.ts +5 -1
  110. package/dist/registration/index.js +1 -1
  111. package/dist/registration/index.js.map +1 -1
  112. package/dist/registration/index.mjs +1 -1
  113. package/dist/registration/index.mjs.map +1 -1
  114. package/dist/sdk-B83N3xKc.d.mts +142 -0
  115. package/dist/sdk-H_9BTNBS.d.ts +142 -0
  116. package/dist/transport/index.d.mts +2 -2
  117. package/dist/transport/index.d.ts +2 -2
  118. package/dist/transport/index.js +1 -1
  119. package/dist/transport/index.js.map +1 -1
  120. package/dist/transport/index.mjs +1 -1
  121. package/dist/transport/index.mjs.map +1 -1
  122. package/dist/{types-DwSfO7Sb.d.ts → types-BK2POWNc.d.ts} +23 -50
  123. package/dist/{types-C0zfSXMB.d.mts → types-CJjZvPr9.d.mts} +23 -50
  124. package/dist/{types-C7Rb-w0d.d.mts → types-CXf3q4kZ.d.ts} +14 -3
  125. package/dist/{types-nIh3HtuA.d.ts → types-DQmop7ZW.d.mts} +14 -3
  126. package/dist/ui/index.d.mts +2 -17
  127. package/dist/ui/index.d.ts +2 -17
  128. package/dist/ui/index.js +1 -43
  129. package/dist/ui/index.js.map +1 -1
  130. package/dist/ui/index.mjs +1 -42
  131. package/dist/ui/index.mjs.map +1 -1
  132. package/dist/verify.d.mts +3 -4
  133. package/dist/verify.d.ts +3 -4
  134. package/dist/verify.js +8 -28
  135. package/dist/verify.js.map +1 -1
  136. package/dist/verify.mjs +8 -28
  137. package/dist/verify.mjs.map +1 -1
  138. package/package.json +1 -1
  139. package/dist/sdk-Bbh9B_dw.d.mts +0 -215
  140. package/dist/sdk-C6SASmsh.d.ts +0 -215
@@ -495,9 +495,9 @@ var LocalEvaluator = class {
495
495
  if (scopeBlock) {
496
496
  return { recommendation: "DENY", reason: scopeBlock };
497
497
  }
498
- const limitViolation = this.checkLimits(context);
499
- if (limitViolation) {
500
- return { recommendation: "DENY", reason: limitViolation };
498
+ const limitDecision = this.checkLimits(context);
499
+ if (limitDecision) {
500
+ return limitDecision;
501
501
  }
502
502
  if (context.purpose === "sub_agent.spawn" && this.policy.selfInstantiation) {
503
503
  if (!this.policy.selfInstantiation.allowed) {
@@ -562,9 +562,21 @@ var LocalEvaluator = class {
562
562
  checkLimits(context) {
563
563
  const limits = this.policy.limits;
564
564
  if (!limits) return null;
565
- if (limits.maxTransactionAmount !== void 0 && context.transactionValue !== void 0) {
566
- if (context.transactionValue > limits.maxTransactionAmount) {
567
- return `Transaction value ${context.transactionValue} exceeds limit ${limits.maxTransactionAmount}`;
565
+ const value = context.transactionValue;
566
+ if (value !== void 0 && value > 0 && (limits.autonomousThreshold !== void 0 || limits.maxTransactionAmount !== void 0)) {
567
+ const autonomousThreshold = limits.autonomousThreshold ?? 0;
568
+ const hardLimit = limits.maxTransactionAmount ?? limits.autonomousThreshold ?? 0;
569
+ if (value > autonomousThreshold) {
570
+ if (value >= hardLimit) {
571
+ return {
572
+ recommendation: "DENY",
573
+ reason: `Transaction value ${value} at or above Hard Limit ${hardLimit}`
574
+ };
575
+ }
576
+ return {
577
+ recommendation: "MANUAL_REVIEW",
578
+ reason: `Transaction value ${value} is in the human-approval band (${autonomousThreshold}, ${hardLimit})`
579
+ };
568
580
  }
569
581
  }
570
582
  if (limits.maxRequestsPerHour !== void 0) {
@@ -577,7 +589,10 @@ var LocalEvaluator = class {
577
589
  } else {
578
590
  entry.count++;
579
591
  if (entry.count > limits.maxRequestsPerHour) {
580
- return `Rate limit exceeded: ${entry.count}/${limits.maxRequestsPerHour} requests per hour`;
592
+ return {
593
+ recommendation: "DENY",
594
+ reason: `Rate limit exceeded: ${entry.count}/${limits.maxRequestsPerHour} requests per hour`
595
+ };
581
596
  }
582
597
  }
583
598
  }
@@ -3786,10 +3801,16 @@ function validatePurpose(purpose, path) {
3786
3801
  errors.push({ path: `${path}.targets`, message: "targets must be an array of strings" });
3787
3802
  }
3788
3803
  if (p.blockedPatterns !== void 0 && !isStringArray(p.blockedPatterns)) {
3789
- errors.push({ path: `${path}.blockedPatterns`, message: "blockedPatterns must be an array of strings" });
3804
+ errors.push({
3805
+ path: `${path}.blockedPatterns`,
3806
+ message: "blockedPatterns must be an array of strings"
3807
+ });
3790
3808
  }
3791
3809
  if (p.requiresApproval !== void 0 && typeof p.requiresApproval !== "boolean") {
3792
- errors.push({ path: `${path}.requiresApproval`, message: "requiresApproval must be a boolean" });
3810
+ errors.push({
3811
+ path: `${path}.requiresApproval`,
3812
+ message: "requiresApproval must be a boolean"
3813
+ });
3793
3814
  }
3794
3815
  return errors;
3795
3816
  }
@@ -3812,11 +3833,29 @@ function validateLimits(limits, path) {
3812
3833
  return [{ path, message: "limits must be an object" }];
3813
3834
  }
3814
3835
  const l = limits;
3836
+ if (l.autonomousThreshold !== void 0 && typeof l.autonomousThreshold !== "number") {
3837
+ errors.push({
3838
+ path: `${path}.autonomousThreshold`,
3839
+ message: "autonomousThreshold must be a number"
3840
+ });
3841
+ }
3815
3842
  if (l.maxTransactionAmount !== void 0 && typeof l.maxTransactionAmount !== "number") {
3816
- errors.push({ path: `${path}.maxTransactionAmount`, message: "maxTransactionAmount must be a number" });
3843
+ errors.push({
3844
+ path: `${path}.maxTransactionAmount`,
3845
+ message: "maxTransactionAmount must be a number"
3846
+ });
3847
+ }
3848
+ if (typeof l.autonomousThreshold === "number" && typeof l.maxTransactionAmount === "number" && l.autonomousThreshold > l.maxTransactionAmount) {
3849
+ errors.push({
3850
+ path: `${path}.autonomousThreshold`,
3851
+ message: "autonomousThreshold (Autonomous Limit) must be <= maxTransactionAmount (Hard Limit)"
3852
+ });
3817
3853
  }
3818
3854
  if (l.maxRequestsPerHour !== void 0 && typeof l.maxRequestsPerHour !== "number") {
3819
- errors.push({ path: `${path}.maxRequestsPerHour`, message: "maxRequestsPerHour must be a number" });
3855
+ errors.push({
3856
+ path: `${path}.maxRequestsPerHour`,
3857
+ message: "maxRequestsPerHour must be a number"
3858
+ });
3820
3859
  }
3821
3860
  if (l.currency !== void 0 && typeof l.currency !== "string") {
3822
3861
  errors.push({ path: `${path}.currency`, message: "currency must be a string" });
@@ -3831,7 +3870,10 @@ function validateRiskThresholds(thresholds, path) {
3831
3870
  const t = thresholds;
3832
3871
  for (const range of ["autoAllow", "requireApproval", "autoBlock"]) {
3833
3872
  if (!t[range] || typeof t[range] !== "object") {
3834
- errors.push({ path: `${path}.${range}`, message: `${range} is required and must be an object with min and max` });
3873
+ errors.push({
3874
+ path: `${path}.${range}`,
3875
+ message: `${range} is required and must be an object with min and max`
3876
+ });
3835
3877
  continue;
3836
3878
  }
3837
3879
  const r = t[range];
@@ -3927,7 +3969,7 @@ function verifyLocal(evaluator, context) {
3927
3969
  return evaluator.evaluate(context);
3928
3970
  }
3929
3971
 
3930
- // src/access-levels.ts
3972
+ // src/trust-levels.ts
3931
3973
  function getTrustLevel(score) {
3932
3974
  if (score >= 80) return "PLATINUM";
3933
3975
  if (score >= 60) return "GOLD";
@@ -3936,7 +3978,7 @@ function getTrustLevel(score) {
3936
3978
  }
3937
3979
 
3938
3980
  // src/version.ts
3939
- var SDK_VERSION = "4.5.1";
3981
+ var SDK_VERSION = "5.0.0";
3940
3982
 
3941
3983
  // src/http.ts
3942
3984
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -3966,11 +4008,6 @@ function getCachedWellKnownUrls(apiBaseUrl) {
3966
4008
  // src/verify.ts
3967
4009
  var DEFAULT_CONFIG = {
3968
4010
  apiBaseUrl: "https://astrasync.ai/api",
3969
- // v2.3.9 (defect #30): default for unconfigured callers is `'none'` (no
3970
- // access). Pre-rename this defaulted to `'guidance'`, which combined with
3971
- // a route gated at `'guidance'` to silently let unverified traffic
3972
- // through (`hasMinimumAccess('guidance', 'guidance') === true`).
3973
- defaultAccessLevel: "none",
3974
4011
  // minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
3975
4012
  // cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
3976
4013
  // default; the caller's explicit value is honoured for cacheable results.
@@ -4131,13 +4168,6 @@ function createGuidanceResponse(_config, reason, options = {}) {
4131
4168
  // policy is not evaluated (we never reached the gate).
4132
4169
  identityVerified: false,
4133
4170
  policyAllowed: false,
4134
- // v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
4135
- // Adapters additionally short-circuit on `!identityVerified ||
4136
- // !policyAllowed` before the gate check, but the access level still has
4137
- // to be honest at the data layer so downstream consumers (SDK adapters
4138
- // in other languages, custom integrations) inherit the correct
4139
- // semantics.
4140
- accessLevel: "none",
4141
4171
  guidance,
4142
4172
  denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
4143
4173
  // Round-10 (#47, O5): on API-error fallback, surface a typed failure so
@@ -4160,6 +4190,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
4160
4190
  // 4.0.0: typed marker so adapters render the misconfig envelope (503 +
4161
4191
  // MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
4162
4192
  ...isMisconfig && { misconfigured: true },
4193
+ // 4.6.0: a transient api_error is retryable — mark it so consumers surface
4194
+ // "temporarily unavailable, retry" (recommendation 'error') instead of
4195
+ // coercing the absent recommendation to a policy 'deny'. Misconfig is
4196
+ // deterministic and intentionally NOT marked retryable.
4197
+ ...isApiError && { retryable: true },
4163
4198
  correlationId: options.correlationId,
4164
4199
  attemptId: options.attemptId,
4165
4200
  verifiedAt: /* @__PURE__ */ new Date()
@@ -4226,7 +4261,6 @@ async function callVerifyAccessAPI(config, request) {
4226
4261
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
4227
4262
  access: {
4228
4263
  allowed: false,
4229
- accessLevel: "none",
4230
4264
  reason: "endpoint_deactivated",
4231
4265
  failures: [
4232
4266
  {
@@ -4289,7 +4323,7 @@ async function verify(config, request, options) {
4289
4323
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
4290
4324
  deprecationWarningShown = true;
4291
4325
  console.warn(
4292
- "[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access-level decisions (the SDK reads access.accessLevel from the verify-access response). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
4326
+ "[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access decisions (verified ID + runtime challenge + PDLSS + trust score). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
4293
4327
  );
4294
4328
  }
4295
4329
  if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
@@ -4335,14 +4369,6 @@ async function verify(config, request, options) {
4335
4369
  const result2 = {
4336
4370
  identityVerified: idVerifiedFromBackend,
4337
4371
  policyAllowed: false,
4338
- // v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
4339
- // Pre-rename this hardcoded `'guidance'`, which conflated with the
4340
- // colocated `guidance: {...}` help-payload object below and let
4341
- // denied requests pass any route gated at `'guidance'` because
4342
- // `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
4343
- // ALSO short-circuit on `!identityVerified || !policyAllowed` before
4344
- // the gate check — belt-and-braces.
4345
- accessLevel: "none",
4346
4372
  // 3.6.0: the server now emits top-level denialReasons on every deny
4347
4373
  // path — prefer it verbatim; the failure-message reconstruction remains
4348
4374
  // as the fallback for older backends.
@@ -4391,7 +4417,6 @@ async function verify(config, request, options) {
4391
4417
  trustScore: apiResponse.organization.trustScore
4392
4418
  } : void 0;
4393
4419
  const verificationContext = apiResponse.verificationContext;
4394
- const accessLevel = apiResponse.access?.accessLevel ?? "standard";
4395
4420
  const result = {
4396
4421
  // 4.5.0 (probe F1): read idVerified from verificationContext with the
4397
4422
  // SAME absent⇒false default as the deny branch. The previous `!== false`
@@ -4403,7 +4428,6 @@ async function verify(config, request, options) {
4403
4428
  // this load-bearing must never be defaulted on.
4404
4429
  identityVerified: apiResponse.verificationContext?.idVerified === true,
4405
4430
  policyAllowed: true,
4406
- accessLevel,
4407
4431
  agent,
4408
4432
  developer,
4409
4433
  organization,
@@ -4430,7 +4454,6 @@ async function verify(config, request, options) {
4430
4454
  };
4431
4455
  if (result.recommendation === "deny") {
4432
4456
  result.policyAllowed = false;
4433
- result.accessLevel = "none";
4434
4457
  result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
4435
4458
  result.guidance = result.runtimeChallenge ? {
4436
4459
  message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
@@ -4546,7 +4569,6 @@ function toGatewayConfig(config) {
4546
4569
  return {
4547
4570
  apiBaseUrl: config.apiBaseUrl || "https://api.astrasync.ai",
4548
4571
  apiKey: config.apiKey,
4549
- defaultAccessLevel: config.defaultAccessLevel,
4550
4572
  minTrustScore: config.minTrustScore,
4551
4573
  minTrustScoreForFull: config.minTrustScoreForFull,
4552
4574
  cacheTtl: config.cacheTtl,
@@ -4574,7 +4596,7 @@ function toDecision(result) {
4574
4596
  if (result.identityVerified && result.policyAllowed) {
4575
4597
  return {
4576
4598
  recommendation: "ALLOW",
4577
- reason: `Verified with access level: ${result.accessLevel}`,
4599
+ reason: result.agent?.trustScore ? `Verified (trust score ${result.agent.trustScore})` : "Verified",
4578
4600
  trustScore: result.agent?.trustScore,
4579
4601
  sessionId: "sessionId" in result ? result.sessionId : void 0
4580
4602
  };