@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
@@ -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.11.0";
3939
+ var SDK_VERSION = "3.12.0";
3929
3940
 
3930
3941
  // src/well-known.ts
3931
3942
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4092,6 +4103,7 @@ function createGuidanceResponse(_config, reason, options = {}) {
4092
4103
  }
4093
4104
  ] : void 0,
4094
4105
  correlationId: options.correlationId,
4106
+ attemptId: options.attemptId,
4095
4107
  verifiedAt: /* @__PURE__ */ new Date()
4096
4108
  };
4097
4109
  }
@@ -4121,6 +4133,8 @@ async function callVerifyAccessAPI(config, request) {
4121
4133
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
4122
4134
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4123
4135
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4136
+ if (requestData.attemptId) body.attemptId = requestData.attemptId;
4137
+ if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4124
4138
  body.sdkVersion = SDK_VERSION;
4125
4139
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
4126
4140
  const meta = {
@@ -4148,6 +4162,9 @@ async function callVerifyAccessAPI(config, request) {
4148
4162
  if (response.status === 410) {
4149
4163
  return {
4150
4164
  success: true,
4165
+ // 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
4166
+ // the synthesised 410 deny shape (echoed on every branch).
4167
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
4151
4168
  access: {
4152
4169
  allowed: false,
4153
4170
  accessLevel: "none",
@@ -4166,7 +4183,8 @@ async function callVerifyAccessAPI(config, request) {
4166
4183
  return {
4167
4184
  success: false,
4168
4185
  error: data.message || data.error || `API returned ${response.status}`,
4169
- correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
4186
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4187
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4170
4188
  };
4171
4189
  }
4172
4190
  return data;
@@ -4200,7 +4218,13 @@ async function verify(config, request, options) {
4200
4218
  if (mergedConfig.debug) {
4201
4219
  console.log("[VerificationGateway] Returning cached result");
4202
4220
  }
4203
- return cached;
4221
+ const hit = { ...cached };
4222
+ if (request.attemptId) {
4223
+ hit.attemptId = request.attemptId;
4224
+ } else {
4225
+ delete hit.attemptId;
4226
+ }
4227
+ return hit;
4204
4228
  }
4205
4229
  }
4206
4230
  const enrichedRequest = { ...request };
@@ -4220,6 +4244,7 @@ async function verify(config, request, options) {
4220
4244
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
4221
4245
  source: "api_error",
4222
4246
  correlationId: apiResponse.correlationId,
4247
+ attemptId: apiResponse.attemptId,
4223
4248
  urls
4224
4249
  });
4225
4250
  }
@@ -4255,6 +4280,9 @@ async function verify(config, request, options) {
4255
4280
  // Anonymous traffic has no session → correlationId is the per-attempt
4256
4281
  // linking key (the sessionId-equivalent for anonymous callers).
4257
4282
  correlationId: apiResponse.correlationId,
4283
+ // 3.12.0 (Trust Record): server echoes the attempt-chain handle on
4284
+ // every branch — denials included (the funnel outlives one deny).
4285
+ attemptId: apiResponse.attemptId,
4258
4286
  recommendation: apiResponse.recommendation,
4259
4287
  recommendationReasons: apiResponse.recommendationReasons,
4260
4288
  stepUpApproval: apiResponse.stepUpApproval,
@@ -4306,6 +4334,8 @@ async function verify(config, request, options) {
4306
4334
  // v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
4307
4335
  // (no session row exists for unverified callers).
4308
4336
  correlationId: apiResponse.correlationId,
4337
+ // 3.12.0 (Trust Record): server-echoed attempt-chain handle.
4338
+ attemptId: apiResponse.attemptId,
4309
4339
  runtimeChallenge: apiResponse.runtimeChallenge,
4310
4340
  tokenGuidance: apiResponse.tokenGuidance,
4311
4341
  recommendation: apiResponse.recommendation,
@@ -4692,13 +4722,29 @@ var TraceLogger = class {
4692
4722
  */
4693
4723
  logEvaluation(context, decision) {
4694
4724
  if (!this.enabled) return;
4695
- this.write({
4696
- id: this.generateId(),
4697
- timestamp: /* @__PURE__ */ new Date(),
4698
- type: "evaluation",
4699
- context: redactDeep(context),
4700
- decision: redactDeep(decision)
4701
- });
4725
+ let event;
4726
+ try {
4727
+ event = {
4728
+ id: this.generateId(),
4729
+ timestamp: /* @__PURE__ */ new Date(),
4730
+ type: "evaluation",
4731
+ context: redactDeep(context),
4732
+ decision: redactDeep(decision)
4733
+ };
4734
+ } catch (err) {
4735
+ event = {
4736
+ id: this.generateId(),
4737
+ timestamp: /* @__PURE__ */ new Date(),
4738
+ type: "error",
4739
+ metadata: {
4740
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4741
+ recommendation: decision.recommendation,
4742
+ purpose: context.purpose,
4743
+ action: context.action
4744
+ }
4745
+ };
4746
+ }
4747
+ this.write(event);
4702
4748
  }
4703
4749
  /**
4704
4750
  * Log a tool call the guard saw but did not govern. One line per skip
@@ -4740,17 +4786,34 @@ var TraceLogger = class {
4740
4786
  });
4741
4787
  }
4742
4788
  write(event) {
4789
+ let line;
4790
+ try {
4791
+ line = JSON.stringify(event) + "\n";
4792
+ } catch {
4793
+ return;
4794
+ }
4743
4795
  try {
4744
4796
  const filePath = this.getCurrentFilePath();
4745
- const line = JSON.stringify(event) + "\n";
4746
4797
  if (existsSync2(filePath)) {
4747
4798
  const stats = statSync(filePath);
4748
4799
  if (stats.size > MAX_FILE_SIZE) {
4749
4800
  this.rotate();
4750
4801
  }
4751
4802
  }
4752
- appendFileSync(filePath, line);
4803
+ for (let attempt = 0; attempt < 3; attempt++) {
4804
+ try {
4805
+ appendFileSync(filePath, line);
4806
+ return;
4807
+ } catch {
4808
+ }
4809
+ }
4810
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4811
+ appendFileSync(fallbackPath, line);
4753
4812
  } catch {
4813
+ try {
4814
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4815
+ } catch {
4816
+ }
4754
4817
  }
4755
4818
  }
4756
4819
  getCurrentFilePath() {