@astrasyncai/verification-gateway 3.10.1 → 3.11.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.
Files changed (77) hide show
  1. package/dist/adapter-interface/interface.d.mts +1 -1
  2. package/dist/adapter-interface/interface.d.ts +1 -1
  3. package/dist/adapters/express.js +1 -1
  4. package/dist/adapters/express.js.map +1 -1
  5. package/dist/adapters/express.mjs +1 -1
  6. package/dist/adapters/express.mjs.map +1 -1
  7. package/dist/adapters/mcp.js +1 -1
  8. package/dist/adapters/mcp.js.map +1 -1
  9. package/dist/adapters/mcp.mjs +1 -1
  10. package/dist/adapters/mcp.mjs.map +1 -1
  11. package/dist/adapters/nextjs.js +1 -1
  12. package/dist/adapters/nextjs.js.map +1 -1
  13. package/dist/adapters/nextjs.mjs +1 -1
  14. package/dist/adapters/nextjs.mjs.map +1 -1
  15. package/dist/adapters/sdk.js +1 -1
  16. package/dist/adapters/sdk.js.map +1 -1
  17. package/dist/adapters/sdk.mjs +1 -1
  18. package/dist/adapters/sdk.mjs.map +1 -1
  19. package/dist/bin/astrasync-claude-hook.js +105 -27
  20. package/dist/bin/astrasync-codex-hook.js +5151 -0
  21. package/dist/bin/astrasync-guard.js +234 -32
  22. package/dist/bin/astrasync.js +242 -32
  23. package/dist/browser/background.js +84 -17
  24. package/dist/browser/background.js.map +1 -1
  25. package/dist/browser/background.mjs +84 -17
  26. package/dist/browser/background.mjs.map +1 -1
  27. package/dist/browser/browser-adapter.d.mts +1 -1
  28. package/dist/browser/browser-adapter.d.ts +1 -1
  29. package/dist/claude-code/claude-code-adapter.d.mts +1 -1
  30. package/dist/claude-code/claude-code-adapter.d.ts +1 -1
  31. package/dist/claude-code/claude-code-adapter.js +9 -1
  32. package/dist/claude-code/claude-code-adapter.js.map +1 -1
  33. package/dist/claude-code/claude-code-adapter.mjs +9 -1
  34. package/dist/claude-code/claude-code-adapter.mjs.map +1 -1
  35. package/dist/cli/index.d.mts +1 -1
  36. package/dist/cli/index.d.ts +1 -1
  37. package/dist/codex/index.d.mts +230 -0
  38. package/dist/codex/index.d.ts +230 -0
  39. package/dist/codex/index.js +5269 -0
  40. package/dist/codex/index.js.map +1 -0
  41. package/dist/codex/index.mjs +5241 -0
  42. package/dist/codex/index.mjs.map +1 -0
  43. package/dist/cursor/cursor-adapter.d.mts +1 -1
  44. package/dist/cursor/cursor-adapter.d.ts +1 -1
  45. package/dist/cursor/extension.d.mts +1 -1
  46. package/dist/cursor/extension.d.ts +1 -1
  47. package/dist/cursor/extension.js +84 -17
  48. package/dist/cursor/extension.js.map +1 -1
  49. package/dist/cursor/extension.mjs +84 -17
  50. package/dist/cursor/extension.mjs.map +1 -1
  51. package/dist/gateway/gateway.d.mts +6 -1
  52. package/dist/gateway/gateway.d.ts +6 -1
  53. package/dist/gateway/gateway.js +84 -17
  54. package/dist/gateway/gateway.js.map +1 -1
  55. package/dist/gateway/gateway.mjs +84 -17
  56. package/dist/gateway/gateway.mjs.map +1 -1
  57. package/dist/git-trigger/git-hooks.d.mts +1 -1
  58. package/dist/git-trigger/git-hooks.d.ts +1 -1
  59. package/dist/index.d.mts +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +1 -1
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/local-evaluator/evaluator.d.mts +10 -1
  66. package/dist/local-evaluator/evaluator.d.ts +10 -1
  67. package/dist/local-evaluator/evaluator.js +20 -9
  68. package/dist/local-evaluator/evaluator.js.map +1 -1
  69. package/dist/local-evaluator/evaluator.mjs +20 -9
  70. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  71. package/dist/{types-C23_uaY8.d.ts → types-DhFPiZ3t.d.ts} +6 -1
  72. package/dist/{types-BV6abBnF.d.mts → types-cQVCMeNV.d.mts} +6 -1
  73. package/dist/verify.js +1 -1
  74. package/dist/verify.js.map +1 -1
  75. package/dist/verify.mjs +1 -1
  76. package/dist/verify.mjs.map +1 -1
  77. package/package.json +8 -2
@@ -385,8 +385,9 @@ function extractBacktickSubstitutions(text, collect) {
385
385
  return kept.join(" ");
386
386
  }
387
387
  function basename(token) {
388
- const slash = token.lastIndexOf("/");
389
- return slash === -1 ? token : token.slice(slash + 1);
388
+ const slash = Math.max(token.lastIndexOf("/"), token.lastIndexOf("\\"));
389
+ const name = slash === -1 ? token : token.slice(slash + 1);
390
+ return name.replace(/\.(exe|cmd|bat|ps1)$/i, "");
390
391
  }
391
392
  function matchSegment(segment, list) {
392
393
  const tokens = segment.split(/\s+/).filter((t) => /[a-z0-9]/.test(t));
@@ -519,7 +520,9 @@ var LocalEvaluator = class {
519
520
  }
520
521
  return {
521
522
  recommendation: "ALLOW",
522
- reason: "All PDLSS checks passed",
523
+ // "evaluated": dimensions absent from the policy are skipped, not
524
+ // failed — evaluatedDimensions below records which ones ran.
525
+ reason: "All evaluated PDLSS checks passed",
523
526
  evaluatedDimensions: {
524
527
  purpose: true,
525
528
  scope: !!this.policy.scope,
@@ -618,7 +621,7 @@ var LocalEvaluator = class {
618
621
  }
619
622
  }
620
623
  if ((context.purpose === "file.read" || context.purpose === "file.write" || context.purpose === "file.delete") && context.target) {
621
- const targetLower = context.target.toLowerCase();
624
+ const targetLower = context.target.toLowerCase().replace(/\\/g, "/");
622
625
  for (const sensitivePath of SENSITIVE_PATHS) {
623
626
  if (targetLower.includes(sensitivePath.toLowerCase())) {
624
627
  score = Math.max(score, 50);
@@ -647,12 +650,20 @@ var LocalEvaluator = class {
647
650
  matchesAnyPattern(value, patterns) {
648
651
  return patterns.some((pattern) => this.matchGlob(value, pattern));
649
652
  }
650
- /**
651
- * Simple glob pattern matching.
652
- * Supports * (matches any characters including / and spaces) and ? (single char).
653
- * Uses the same approach as the backend's matchGlobPattern.
654
- */
653
+ homePrefix() {
654
+ if (this.cachedHomePrefix !== void 0) return this.cachedHomePrefix;
655
+ const env = typeof process !== "undefined" ? process.env : void 0;
656
+ const home = env?.HOME || env?.USERPROFILE;
657
+ this.cachedHomePrefix = home ? home.replace(/\\/g, "/") : null;
658
+ return this.cachedHomePrefix;
659
+ }
655
660
  matchGlob(value, pattern) {
661
+ value = value.replace(/\\/g, "/");
662
+ pattern = pattern.replace(/\\/g, "/");
663
+ if (pattern === "~" || pattern.startsWith("~/")) {
664
+ const home = this.homePrefix();
665
+ if (home) pattern = home + pattern.slice(1);
666
+ }
656
667
  if (pattern === value) return true;
657
668
  const starCount = (pattern.match(/\*/g) ?? []).length;
658
669
  if (starCount > 8) {
@@ -3925,7 +3936,7 @@ function getTrustLevel(score) {
3925
3936
  }
3926
3937
 
3927
3938
  // src/version.ts
3928
- var SDK_VERSION = "3.10.1";
3939
+ var SDK_VERSION = "3.11.1";
3929
3940
 
3930
3941
  // src/well-known.ts
3931
3942
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4443,10 +4454,12 @@ function toGatewayConfig(config) {
4443
4454
  };
4444
4455
  }
4445
4456
  function toVerificationRequest(context, astraId) {
4457
+ const dotIndex = context.purpose.indexOf(".");
4458
+ const dotted = dotIndex > 0;
4446
4459
  return {
4447
4460
  credentials: { astraId },
4448
- purpose: context.purpose,
4449
- action: context.action,
4461
+ purpose: dotted ? context.purpose.slice(0, dotIndex) : context.purpose,
4462
+ action: dotted ? context.purpose : context.action,
4450
4463
  resourceType: context.resourceType,
4451
4464
  resource: context.target,
4452
4465
  transactionValue: context.transactionValue,
@@ -4689,13 +4702,43 @@ var TraceLogger = class {
4689
4702
  * Log an evaluation event.
4690
4703
  */
4691
4704
  logEvaluation(context, decision) {
4705
+ if (!this.enabled) return;
4706
+ let event;
4707
+ try {
4708
+ event = {
4709
+ id: this.generateId(),
4710
+ timestamp: /* @__PURE__ */ new Date(),
4711
+ type: "evaluation",
4712
+ context: redactDeep(context),
4713
+ decision: redactDeep(decision)
4714
+ };
4715
+ } catch (err) {
4716
+ event = {
4717
+ id: this.generateId(),
4718
+ timestamp: /* @__PURE__ */ new Date(),
4719
+ type: "error",
4720
+ metadata: {
4721
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4722
+ recommendation: decision.recommendation,
4723
+ purpose: context.purpose,
4724
+ action: context.action
4725
+ }
4726
+ };
4727
+ }
4728
+ this.write(event);
4729
+ }
4730
+ /**
4731
+ * Log a tool call the guard saw but did not govern. One line per skip
4732
+ * keeps coverage holes (unmapped platform tools) visible in the traces
4733
+ * instead of silently indistinguishable from ALLOW.
4734
+ */
4735
+ logSkipped(toolName, reason) {
4692
4736
  if (!this.enabled) return;
4693
4737
  this.write({
4694
4738
  id: this.generateId(),
4695
4739
  timestamp: /* @__PURE__ */ new Date(),
4696
- type: "evaluation",
4697
- context: redactDeep(context),
4698
- decision: redactDeep(decision)
4740
+ type: "skipped",
4741
+ metadata: { toolName, reason }
4699
4742
  });
4700
4743
  }
4701
4744
  /**
@@ -4724,17 +4767,34 @@ var TraceLogger = class {
4724
4767
  });
4725
4768
  }
4726
4769
  write(event) {
4770
+ let line;
4771
+ try {
4772
+ line = JSON.stringify(event) + "\n";
4773
+ } catch {
4774
+ return;
4775
+ }
4727
4776
  try {
4728
4777
  const filePath = this.getCurrentFilePath();
4729
- const line = JSON.stringify(event) + "\n";
4730
4778
  if (existsSync2(filePath)) {
4731
4779
  const stats = statSync(filePath);
4732
4780
  if (stats.size > MAX_FILE_SIZE) {
4733
4781
  this.rotate();
4734
4782
  }
4735
4783
  }
4736
- appendFileSync(filePath, line);
4784
+ for (let attempt = 0; attempt < 3; attempt++) {
4785
+ try {
4786
+ appendFileSync(filePath, line);
4787
+ return;
4788
+ } catch {
4789
+ }
4790
+ }
4791
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4792
+ appendFileSync(fallbackPath, line);
4737
4793
  } catch {
4794
+ try {
4795
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4796
+ } catch {
4797
+ }
4738
4798
  }
4739
4799
  }
4740
4800
  getCurrentFilePath() {
@@ -4895,6 +4955,13 @@ var AstraSyncGateway = class {
4895
4955
  getSyncStatus() {
4896
4956
  return this.syncQueue?.getStatus() || null;
4897
4957
  }
4958
+ /**
4959
+ * Record a tool call the calling adapter saw but did not govern
4960
+ * (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
4961
+ */
4962
+ logSkippedTool(toolName, reason) {
4963
+ this.traceLogger?.logSkipped(toolName, reason);
4964
+ }
4898
4965
  };
4899
4966
 
4900
4967
  // src/browser/background.ts