@astrasyncai/verification-gateway 3.11.0 → 3.12.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 (103) hide show
  1. package/dist/adapter-interface/interface.d.mts +2 -2
  2. package/dist/adapter-interface/interface.d.ts +2 -2
  3. package/dist/adapters/express.d.mts +2 -2
  4. package/dist/adapters/express.d.ts +2 -2
  5. package/dist/adapters/express.js +22 -3
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +22 -3
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +1 -1
  10. package/dist/adapters/mcp.d.ts +1 -1
  11. package/dist/adapters/mcp.js +22 -3
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +22 -3
  14. package/dist/adapters/mcp.mjs.map +1 -1
  15. package/dist/adapters/nextjs.d.mts +2 -2
  16. package/dist/adapters/nextjs.d.ts +2 -2
  17. package/dist/adapters/nextjs.js +22 -3
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +22 -3
  20. package/dist/adapters/nextjs.mjs.map +1 -1
  21. package/dist/adapters/sdk.d.mts +2 -2
  22. package/dist/adapters/sdk.d.ts +2 -2
  23. package/dist/adapters/sdk.js +22 -3
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +22 -3
  26. package/dist/adapters/sdk.mjs.map +1 -1
  27. package/dist/agent/index.d.mts +2 -2
  28. package/dist/agent/index.d.ts +2 -2
  29. package/dist/bin/astrasync-claude-hook.js +84 -21
  30. package/dist/bin/astrasync-codex-hook.js +84 -21
  31. package/dist/bin/astrasync-guard.js +84 -21
  32. package/dist/bin/astrasync.js +85 -21
  33. package/dist/browser/background.js +84 -21
  34. package/dist/browser/background.js.map +1 -1
  35. package/dist/browser/background.mjs +84 -21
  36. package/dist/browser/background.mjs.map +1 -1
  37. package/dist/browser/browser-adapter.d.mts +2 -2
  38. package/dist/browser/browser-adapter.d.ts +2 -2
  39. package/dist/claude-code/claude-code-adapter.d.mts +2 -2
  40. package/dist/claude-code/claude-code-adapter.d.ts +2 -2
  41. package/dist/cli/index.d.mts +2 -2
  42. package/dist/cli/index.d.ts +2 -2
  43. package/dist/codex/index.d.mts +2 -2
  44. package/dist/codex/index.d.ts +2 -2
  45. package/dist/codex/index.js +84 -21
  46. package/dist/codex/index.js.map +1 -1
  47. package/dist/codex/index.mjs +84 -21
  48. package/dist/codex/index.mjs.map +1 -1
  49. package/dist/cursor/cursor-adapter.d.mts +2 -2
  50. package/dist/cursor/cursor-adapter.d.ts +2 -2
  51. package/dist/cursor/extension.d.mts +2 -2
  52. package/dist/cursor/extension.d.ts +2 -2
  53. package/dist/cursor/extension.js +84 -21
  54. package/dist/cursor/extension.js.map +1 -1
  55. package/dist/cursor/extension.mjs +84 -21
  56. package/dist/cursor/extension.mjs.map +1 -1
  57. package/dist/edge-config.d.mts +1 -1
  58. package/dist/edge-config.d.ts +1 -1
  59. package/dist/{express-DCXa1oqj.d.mts → express-B39o89gf.d.mts} +1 -1
  60. package/dist/{express-ClNtDhhc.d.ts → express-BuxKNO_q.d.ts} +1 -1
  61. package/dist/gateway/gateway.d.mts +2 -2
  62. package/dist/gateway/gateway.d.ts +2 -2
  63. package/dist/gateway/gateway.js +84 -21
  64. package/dist/gateway/gateway.js.map +1 -1
  65. package/dist/gateway/gateway.mjs +84 -21
  66. package/dist/gateway/gateway.mjs.map +1 -1
  67. package/dist/git-trigger/git-hooks.d.mts +2 -2
  68. package/dist/git-trigger/git-hooks.d.ts +2 -2
  69. package/dist/{index-CfHurO1P.d.ts → index-BG62SXso.d.ts} +1 -1
  70. package/dist/{index-D2ztkumS.d.ts → index-CLHdqs2M.d.ts} +1 -1
  71. package/dist/{index-Dr_XiN65.d.mts → index-CqydB4ks.d.mts} +1 -1
  72. package/dist/{index-BrNKDmiR.d.mts → index-DME3w3lf.d.mts} +1 -1
  73. package/dist/index.d.mts +9 -9
  74. package/dist/index.d.ts +9 -9
  75. package/dist/index.js +42 -3
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +41 -3
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/local-evaluator/evaluator.d.mts +11 -2
  80. package/dist/local-evaluator/evaluator.d.ts +11 -2
  81. package/dist/local-evaluator/evaluator.js +20 -9
  82. package/dist/local-evaluator/evaluator.js.map +1 -1
  83. package/dist/local-evaluator/evaluator.mjs +20 -9
  84. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  85. package/dist/{nextjs-DcQIk6Zj.d.mts → nextjs-D74W7wt-.d.mts} +1 -1
  86. package/dist/{nextjs-CEBVBsdi.d.ts → nextjs-Ddlw_J1J.d.ts} +1 -1
  87. package/dist/{sdk-CZkbSOeO.d.mts → sdk-Bn6bj7kt.d.mts} +1 -1
  88. package/dist/{sdk-H0JCLW2y.d.ts → sdk-CT7gdkfR.d.ts} +1 -1
  89. package/dist/transport/index.d.mts +2 -2
  90. package/dist/transport/index.d.ts +2 -2
  91. package/dist/{types-sy3tq8lp.d.mts → types-BntuzEEn.d.mts} +103 -1
  92. package/dist/{types-BV6abBnF.d.mts → types-DHu7m9HI.d.ts} +7 -2
  93. package/dist/{types-C23_uaY8.d.ts → types-Djw4GLtz.d.mts} +7 -2
  94. package/dist/{types-9tns4wyl.d.ts → types-SDu4Llbe.d.ts} +103 -1
  95. package/dist/ui/index.d.mts +1 -1
  96. package/dist/ui/index.d.ts +1 -1
  97. package/dist/verify.d.mts +13 -2
  98. package/dist/verify.d.ts +13 -2
  99. package/dist/verify.js +42 -3
  100. package/dist/verify.js.map +1 -1
  101. package/dist/verify.mjs +41 -3
  102. package/dist/verify.mjs.map +1 -1
  103. package/package.json +1 -1
@@ -404,8 +404,9 @@ function extractBacktickSubstitutions(text, collect) {
404
404
  return kept.join(" ");
405
405
  }
406
406
  function basename(token) {
407
- const slash = token.lastIndexOf("/");
408
- return slash === -1 ? token : token.slice(slash + 1);
407
+ const slash = Math.max(token.lastIndexOf("/"), token.lastIndexOf("\\"));
408
+ const name = slash === -1 ? token : token.slice(slash + 1);
409
+ return name.replace(/\.(exe|cmd|bat|ps1)$/i, "");
409
410
  }
410
411
  function matchSegment(segment, list) {
411
412
  const tokens = segment.split(/\s+/).filter((t) => /[a-z0-9]/.test(t));
@@ -538,7 +539,9 @@ var LocalEvaluator = class {
538
539
  }
539
540
  return {
540
541
  recommendation: "ALLOW",
541
- reason: "All PDLSS checks passed",
542
+ // "evaluated": dimensions absent from the policy are skipped, not
543
+ // failed — evaluatedDimensions below records which ones ran.
544
+ reason: "All evaluated PDLSS checks passed",
542
545
  evaluatedDimensions: {
543
546
  purpose: true,
544
547
  scope: !!this.policy.scope,
@@ -637,7 +640,7 @@ var LocalEvaluator = class {
637
640
  }
638
641
  }
639
642
  if ((context.purpose === "file.read" || context.purpose === "file.write" || context.purpose === "file.delete") && context.target) {
640
- const targetLower = context.target.toLowerCase();
643
+ const targetLower = context.target.toLowerCase().replace(/\\/g, "/");
641
644
  for (const sensitivePath of SENSITIVE_PATHS) {
642
645
  if (targetLower.includes(sensitivePath.toLowerCase())) {
643
646
  score = Math.max(score, 50);
@@ -666,12 +669,20 @@ var LocalEvaluator = class {
666
669
  matchesAnyPattern(value, patterns) {
667
670
  return patterns.some((pattern) => this.matchGlob(value, pattern));
668
671
  }
669
- /**
670
- * Simple glob pattern matching.
671
- * Supports * (matches any characters including / and spaces) and ? (single char).
672
- * Uses the same approach as the backend's matchGlobPattern.
673
- */
672
+ homePrefix() {
673
+ if (this.cachedHomePrefix !== void 0) return this.cachedHomePrefix;
674
+ const env = typeof process !== "undefined" ? process.env : void 0;
675
+ const home = env?.HOME || env?.USERPROFILE;
676
+ this.cachedHomePrefix = home ? home.replace(/\\/g, "/") : null;
677
+ return this.cachedHomePrefix;
678
+ }
674
679
  matchGlob(value, pattern) {
680
+ value = value.replace(/\\/g, "/");
681
+ pattern = pattern.replace(/\\/g, "/");
682
+ if (pattern === "~" || pattern.startsWith("~/")) {
683
+ const home = this.homePrefix();
684
+ if (home) pattern = home + pattern.slice(1);
685
+ }
675
686
  if (pattern === value) return true;
676
687
  const starCount = (pattern.match(/\*/g) ?? []).length;
677
688
  if (starCount > 8) {
@@ -3944,7 +3955,7 @@ function getTrustLevel(score) {
3944
3955
  }
3945
3956
 
3946
3957
  // src/version.ts
3947
- var SDK_VERSION = "3.11.0";
3958
+ var SDK_VERSION = "3.12.0";
3948
3959
 
3949
3960
  // src/well-known.ts
3950
3961
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4111,6 +4122,7 @@ function createGuidanceResponse(_config, reason, options = {}) {
4111
4122
  }
4112
4123
  ] : void 0,
4113
4124
  correlationId: options.correlationId,
4125
+ attemptId: options.attemptId,
4114
4126
  verifiedAt: /* @__PURE__ */ new Date()
4115
4127
  };
4116
4128
  }
@@ -4140,6 +4152,8 @@ async function callVerifyAccessAPI(config, request) {
4140
4152
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
4141
4153
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4142
4154
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4155
+ if (requestData.attemptId) body.attemptId = requestData.attemptId;
4156
+ if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4143
4157
  body.sdkVersion = SDK_VERSION;
4144
4158
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
4145
4159
  const meta = {
@@ -4167,6 +4181,9 @@ async function callVerifyAccessAPI(config, request) {
4167
4181
  if (response.status === 410) {
4168
4182
  return {
4169
4183
  success: true,
4184
+ // 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
4185
+ // the synthesised 410 deny shape (echoed on every branch).
4186
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
4170
4187
  access: {
4171
4188
  allowed: false,
4172
4189
  accessLevel: "none",
@@ -4185,7 +4202,8 @@ async function callVerifyAccessAPI(config, request) {
4185
4202
  return {
4186
4203
  success: false,
4187
4204
  error: data.message || data.error || `API returned ${response.status}`,
4188
- correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
4205
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4206
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4189
4207
  };
4190
4208
  }
4191
4209
  return data;
@@ -4219,7 +4237,13 @@ async function verify(config, request, options) {
4219
4237
  if (mergedConfig.debug) {
4220
4238
  console.log("[VerificationGateway] Returning cached result");
4221
4239
  }
4222
- return cached;
4240
+ const hit = { ...cached };
4241
+ if (request.attemptId) {
4242
+ hit.attemptId = request.attemptId;
4243
+ } else {
4244
+ delete hit.attemptId;
4245
+ }
4246
+ return hit;
4223
4247
  }
4224
4248
  }
4225
4249
  const enrichedRequest = { ...request };
@@ -4239,6 +4263,7 @@ async function verify(config, request, options) {
4239
4263
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
4240
4264
  source: "api_error",
4241
4265
  correlationId: apiResponse.correlationId,
4266
+ attemptId: apiResponse.attemptId,
4242
4267
  urls
4243
4268
  });
4244
4269
  }
@@ -4274,6 +4299,9 @@ async function verify(config, request, options) {
4274
4299
  // Anonymous traffic has no session → correlationId is the per-attempt
4275
4300
  // linking key (the sessionId-equivalent for anonymous callers).
4276
4301
  correlationId: apiResponse.correlationId,
4302
+ // 3.12.0 (Trust Record): server echoes the attempt-chain handle on
4303
+ // every branch — denials included (the funnel outlives one deny).
4304
+ attemptId: apiResponse.attemptId,
4277
4305
  recommendation: apiResponse.recommendation,
4278
4306
  recommendationReasons: apiResponse.recommendationReasons,
4279
4307
  stepUpApproval: apiResponse.stepUpApproval,
@@ -4325,6 +4353,8 @@ async function verify(config, request, options) {
4325
4353
  // v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
4326
4354
  // (no session row exists for unverified callers).
4327
4355
  correlationId: apiResponse.correlationId,
4356
+ // 3.12.0 (Trust Record): server-echoed attempt-chain handle.
4357
+ attemptId: apiResponse.attemptId,
4328
4358
  runtimeChallenge: apiResponse.runtimeChallenge,
4329
4359
  tokenGuidance: apiResponse.tokenGuidance,
4330
4360
  recommendation: apiResponse.recommendation,
@@ -4711,13 +4741,29 @@ var TraceLogger = class {
4711
4741
  */
4712
4742
  logEvaluation(context, decision) {
4713
4743
  if (!this.enabled) return;
4714
- this.write({
4715
- id: this.generateId(),
4716
- timestamp: /* @__PURE__ */ new Date(),
4717
- type: "evaluation",
4718
- context: redactDeep(context),
4719
- decision: redactDeep(decision)
4720
- });
4744
+ let event;
4745
+ try {
4746
+ event = {
4747
+ id: this.generateId(),
4748
+ timestamp: /* @__PURE__ */ new Date(),
4749
+ type: "evaluation",
4750
+ context: redactDeep(context),
4751
+ decision: redactDeep(decision)
4752
+ };
4753
+ } catch (err) {
4754
+ event = {
4755
+ id: this.generateId(),
4756
+ timestamp: /* @__PURE__ */ new Date(),
4757
+ type: "error",
4758
+ metadata: {
4759
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4760
+ recommendation: decision.recommendation,
4761
+ purpose: context.purpose,
4762
+ action: context.action
4763
+ }
4764
+ };
4765
+ }
4766
+ this.write(event);
4721
4767
  }
4722
4768
  /**
4723
4769
  * Log a tool call the guard saw but did not govern. One line per skip
@@ -4759,17 +4805,34 @@ var TraceLogger = class {
4759
4805
  });
4760
4806
  }
4761
4807
  write(event) {
4808
+ let line;
4809
+ try {
4810
+ line = JSON.stringify(event) + "\n";
4811
+ } catch {
4812
+ return;
4813
+ }
4762
4814
  try {
4763
4815
  const filePath = this.getCurrentFilePath();
4764
- const line = JSON.stringify(event) + "\n";
4765
4816
  if (existsSync2(filePath)) {
4766
4817
  const stats = statSync(filePath);
4767
4818
  if (stats.size > MAX_FILE_SIZE) {
4768
4819
  this.rotate();
4769
4820
  }
4770
4821
  }
4771
- appendFileSync(filePath, line);
4822
+ for (let attempt = 0; attempt < 3; attempt++) {
4823
+ try {
4824
+ appendFileSync(filePath, line);
4825
+ return;
4826
+ } catch {
4827
+ }
4828
+ }
4829
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4830
+ appendFileSync(fallbackPath, line);
4772
4831
  } catch {
4832
+ try {
4833
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4834
+ } catch {
4835
+ }
4773
4836
  }
4774
4837
  }
4775
4838
  getCurrentFilePath() {