@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
@@ -364,8 +364,9 @@ function extractBacktickSubstitutions(text, collect) {
364
364
  return kept.join(" ");
365
365
  }
366
366
  function basename(token) {
367
- const slash = token.lastIndexOf("/");
368
- return slash === -1 ? token : token.slice(slash + 1);
367
+ const slash = Math.max(token.lastIndexOf("/"), token.lastIndexOf("\\"));
368
+ const name = slash === -1 ? token : token.slice(slash + 1);
369
+ return name.replace(/\.(exe|cmd|bat|ps1)$/i, "");
369
370
  }
370
371
  function matchSegment(segment, list) {
371
372
  const tokens = segment.split(/\s+/).filter((t) => /[a-z0-9]/.test(t));
@@ -498,7 +499,9 @@ var LocalEvaluator = class {
498
499
  }
499
500
  return {
500
501
  recommendation: "ALLOW",
501
- reason: "All PDLSS checks passed",
502
+ // "evaluated": dimensions absent from the policy are skipped, not
503
+ // failed — evaluatedDimensions below records which ones ran.
504
+ reason: "All evaluated PDLSS checks passed",
502
505
  evaluatedDimensions: {
503
506
  purpose: true,
504
507
  scope: !!this.policy.scope,
@@ -597,7 +600,7 @@ var LocalEvaluator = class {
597
600
  }
598
601
  }
599
602
  if ((context.purpose === "file.read" || context.purpose === "file.write" || context.purpose === "file.delete") && context.target) {
600
- const targetLower = context.target.toLowerCase();
603
+ const targetLower = context.target.toLowerCase().replace(/\\/g, "/");
601
604
  for (const sensitivePath of SENSITIVE_PATHS) {
602
605
  if (targetLower.includes(sensitivePath.toLowerCase())) {
603
606
  score = Math.max(score, 50);
@@ -626,12 +629,20 @@ var LocalEvaluator = class {
626
629
  matchesAnyPattern(value, patterns) {
627
630
  return patterns.some((pattern) => this.matchGlob(value, pattern));
628
631
  }
629
- /**
630
- * Simple glob pattern matching.
631
- * Supports * (matches any characters including / and spaces) and ? (single char).
632
- * Uses the same approach as the backend's matchGlobPattern.
633
- */
632
+ homePrefix() {
633
+ if (this.cachedHomePrefix !== void 0) return this.cachedHomePrefix;
634
+ const env = typeof process !== "undefined" ? process.env : void 0;
635
+ const home = env?.HOME || env?.USERPROFILE;
636
+ this.cachedHomePrefix = home ? home.replace(/\\/g, "/") : null;
637
+ return this.cachedHomePrefix;
638
+ }
634
639
  matchGlob(value, pattern) {
640
+ value = value.replace(/\\/g, "/");
641
+ pattern = pattern.replace(/\\/g, "/");
642
+ if (pattern === "~" || pattern.startsWith("~/")) {
643
+ const home = this.homePrefix();
644
+ if (home) pattern = home + pattern.slice(1);
645
+ }
635
646
  if (pattern === value) return true;
636
647
  const starCount = (pattern.match(/\*/g) ?? []).length;
637
648
  if (starCount > 8) {
@@ -3904,7 +3915,7 @@ function getTrustLevel(score) {
3904
3915
  }
3905
3916
 
3906
3917
  // src/version.ts
3907
- var SDK_VERSION = "3.11.0";
3918
+ var SDK_VERSION = "3.12.0";
3908
3919
 
3909
3920
  // src/well-known.ts
3910
3921
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4071,6 +4082,7 @@ function createGuidanceResponse(_config, reason, options = {}) {
4071
4082
  }
4072
4083
  ] : void 0,
4073
4084
  correlationId: options.correlationId,
4085
+ attemptId: options.attemptId,
4074
4086
  verifiedAt: /* @__PURE__ */ new Date()
4075
4087
  };
4076
4088
  }
@@ -4100,6 +4112,8 @@ async function callVerifyAccessAPI(config, request) {
4100
4112
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
4101
4113
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4102
4114
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4115
+ if (requestData.attemptId) body.attemptId = requestData.attemptId;
4116
+ if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4103
4117
  body.sdkVersion = SDK_VERSION;
4104
4118
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
4105
4119
  const meta = {
@@ -4127,6 +4141,9 @@ async function callVerifyAccessAPI(config, request) {
4127
4141
  if (response.status === 410) {
4128
4142
  return {
4129
4143
  success: true,
4144
+ // 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
4145
+ // the synthesised 410 deny shape (echoed on every branch).
4146
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
4130
4147
  access: {
4131
4148
  allowed: false,
4132
4149
  accessLevel: "none",
@@ -4145,7 +4162,8 @@ async function callVerifyAccessAPI(config, request) {
4145
4162
  return {
4146
4163
  success: false,
4147
4164
  error: data.message || data.error || `API returned ${response.status}`,
4148
- correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
4165
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4166
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4149
4167
  };
4150
4168
  }
4151
4169
  return data;
@@ -4179,7 +4197,13 @@ async function verify(config, request, options) {
4179
4197
  if (mergedConfig.debug) {
4180
4198
  console.log("[VerificationGateway] Returning cached result");
4181
4199
  }
4182
- return cached;
4200
+ const hit = { ...cached };
4201
+ if (request.attemptId) {
4202
+ hit.attemptId = request.attemptId;
4203
+ } else {
4204
+ delete hit.attemptId;
4205
+ }
4206
+ return hit;
4183
4207
  }
4184
4208
  }
4185
4209
  const enrichedRequest = { ...request };
@@ -4199,6 +4223,7 @@ async function verify(config, request, options) {
4199
4223
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
4200
4224
  source: "api_error",
4201
4225
  correlationId: apiResponse.correlationId,
4226
+ attemptId: apiResponse.attemptId,
4202
4227
  urls
4203
4228
  });
4204
4229
  }
@@ -4234,6 +4259,9 @@ async function verify(config, request, options) {
4234
4259
  // Anonymous traffic has no session → correlationId is the per-attempt
4235
4260
  // linking key (the sessionId-equivalent for anonymous callers).
4236
4261
  correlationId: apiResponse.correlationId,
4262
+ // 3.12.0 (Trust Record): server echoes the attempt-chain handle on
4263
+ // every branch — denials included (the funnel outlives one deny).
4264
+ attemptId: apiResponse.attemptId,
4237
4265
  recommendation: apiResponse.recommendation,
4238
4266
  recommendationReasons: apiResponse.recommendationReasons,
4239
4267
  stepUpApproval: apiResponse.stepUpApproval,
@@ -4285,6 +4313,8 @@ async function verify(config, request, options) {
4285
4313
  // v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
4286
4314
  // (no session row exists for unverified callers).
4287
4315
  correlationId: apiResponse.correlationId,
4316
+ // 3.12.0 (Trust Record): server-echoed attempt-chain handle.
4317
+ attemptId: apiResponse.attemptId,
4288
4318
  runtimeChallenge: apiResponse.runtimeChallenge,
4289
4319
  tokenGuidance: apiResponse.tokenGuidance,
4290
4320
  recommendation: apiResponse.recommendation,
@@ -4671,13 +4701,29 @@ var TraceLogger = class {
4671
4701
  */
4672
4702
  logEvaluation(context, decision) {
4673
4703
  if (!this.enabled) return;
4674
- this.write({
4675
- id: this.generateId(),
4676
- timestamp: /* @__PURE__ */ new Date(),
4677
- type: "evaluation",
4678
- context: redactDeep(context),
4679
- decision: redactDeep(decision)
4680
- });
4704
+ let event;
4705
+ try {
4706
+ event = {
4707
+ id: this.generateId(),
4708
+ timestamp: /* @__PURE__ */ new Date(),
4709
+ type: "evaluation",
4710
+ context: redactDeep(context),
4711
+ decision: redactDeep(decision)
4712
+ };
4713
+ } catch (err) {
4714
+ event = {
4715
+ id: this.generateId(),
4716
+ timestamp: /* @__PURE__ */ new Date(),
4717
+ type: "error",
4718
+ metadata: {
4719
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4720
+ recommendation: decision.recommendation,
4721
+ purpose: context.purpose,
4722
+ action: context.action
4723
+ }
4724
+ };
4725
+ }
4726
+ this.write(event);
4681
4727
  }
4682
4728
  /**
4683
4729
  * Log a tool call the guard saw but did not govern. One line per skip
@@ -4719,17 +4765,34 @@ var TraceLogger = class {
4719
4765
  });
4720
4766
  }
4721
4767
  write(event) {
4768
+ let line;
4769
+ try {
4770
+ line = JSON.stringify(event) + "\n";
4771
+ } catch {
4772
+ return;
4773
+ }
4722
4774
  try {
4723
4775
  const filePath = this.getCurrentFilePath();
4724
- const line = JSON.stringify(event) + "\n";
4725
4776
  if (existsSync2(filePath)) {
4726
4777
  const stats = statSync(filePath);
4727
4778
  if (stats.size > MAX_FILE_SIZE) {
4728
4779
  this.rotate();
4729
4780
  }
4730
4781
  }
4731
- appendFileSync(filePath, line);
4782
+ for (let attempt = 0; attempt < 3; attempt++) {
4783
+ try {
4784
+ appendFileSync(filePath, line);
4785
+ return;
4786
+ } catch {
4787
+ }
4788
+ }
4789
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4790
+ appendFileSync(fallbackPath, line);
4732
4791
  } catch {
4792
+ try {
4793
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4794
+ } catch {
4795
+ }
4733
4796
  }
4734
4797
  }
4735
4798
  getCurrentFilePath() {