@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
@@ -1,7 +1,7 @@
1
1
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.mjs';
2
- import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-BV6abBnF.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-Djw4GLtz.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-sy3tq8lp.mjs';
4
+ import '../types-BntuzEEn.mjs';
5
5
  import '../metadata-capture.mjs';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.js';
2
- import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-C23_uaY8.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-DHu7m9HI.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-9tns4wyl.js';
4
+ import '../types-SDu4Llbe.js';
5
5
  import '../metadata-capture.js';
6
6
 
7
7
  /**
@@ -1,8 +1,8 @@
1
1
  import { VSCodeAPI } from './cursor-adapter.mjs';
2
2
  import '../adapter-interface/interface.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-BV6abBnF.mjs';
5
- import '../types-sy3tq8lp.mjs';
4
+ import '../types-Djw4GLtz.mjs';
5
+ import '../types-BntuzEEn.mjs';
6
6
  import '../metadata-capture.mjs';
7
7
 
8
8
  /**
@@ -1,8 +1,8 @@
1
1
  import { VSCodeAPI } from './cursor-adapter.js';
2
2
  import '../adapter-interface/interface.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-C23_uaY8.js';
5
- import '../types-9tns4wyl.js';
4
+ import '../types-DHu7m9HI.js';
5
+ import '../types-SDu4Llbe.js';
6
6
  import '../metadata-capture.js';
7
7
 
8
8
  /**
@@ -391,8 +391,9 @@ function extractBacktickSubstitutions(text, collect) {
391
391
  return kept.join(" ");
392
392
  }
393
393
  function basename(token) {
394
- const slash = token.lastIndexOf("/");
395
- return slash === -1 ? token : token.slice(slash + 1);
394
+ const slash = Math.max(token.lastIndexOf("/"), token.lastIndexOf("\\"));
395
+ const name = slash === -1 ? token : token.slice(slash + 1);
396
+ return name.replace(/\.(exe|cmd|bat|ps1)$/i, "");
396
397
  }
397
398
  function matchSegment(segment, list) {
398
399
  const tokens = segment.split(/\s+/).filter((t) => /[a-z0-9]/.test(t));
@@ -525,7 +526,9 @@ var LocalEvaluator = class {
525
526
  }
526
527
  return {
527
528
  recommendation: "ALLOW",
528
- reason: "All PDLSS checks passed",
529
+ // "evaluated": dimensions absent from the policy are skipped, not
530
+ // failed — evaluatedDimensions below records which ones ran.
531
+ reason: "All evaluated PDLSS checks passed",
529
532
  evaluatedDimensions: {
530
533
  purpose: true,
531
534
  scope: !!this.policy.scope,
@@ -624,7 +627,7 @@ var LocalEvaluator = class {
624
627
  }
625
628
  }
626
629
  if ((context.purpose === "file.read" || context.purpose === "file.write" || context.purpose === "file.delete") && context.target) {
627
- const targetLower = context.target.toLowerCase();
630
+ const targetLower = context.target.toLowerCase().replace(/\\/g, "/");
628
631
  for (const sensitivePath of SENSITIVE_PATHS) {
629
632
  if (targetLower.includes(sensitivePath.toLowerCase())) {
630
633
  score = Math.max(score, 50);
@@ -653,12 +656,20 @@ var LocalEvaluator = class {
653
656
  matchesAnyPattern(value, patterns) {
654
657
  return patterns.some((pattern) => this.matchGlob(value, pattern));
655
658
  }
656
- /**
657
- * Simple glob pattern matching.
658
- * Supports * (matches any characters including / and spaces) and ? (single char).
659
- * Uses the same approach as the backend's matchGlobPattern.
660
- */
659
+ homePrefix() {
660
+ if (this.cachedHomePrefix !== void 0) return this.cachedHomePrefix;
661
+ const env = typeof process !== "undefined" ? process.env : void 0;
662
+ const home = env?.HOME || env?.USERPROFILE;
663
+ this.cachedHomePrefix = home ? home.replace(/\\/g, "/") : null;
664
+ return this.cachedHomePrefix;
665
+ }
661
666
  matchGlob(value, pattern) {
667
+ value = value.replace(/\\/g, "/");
668
+ pattern = pattern.replace(/\\/g, "/");
669
+ if (pattern === "~" || pattern.startsWith("~/")) {
670
+ const home = this.homePrefix();
671
+ if (home) pattern = home + pattern.slice(1);
672
+ }
662
673
  if (pattern === value) return true;
663
674
  const starCount = (pattern.match(/\*/g) ?? []).length;
664
675
  if (starCount > 8) {
@@ -3931,7 +3942,7 @@ function getTrustLevel(score) {
3931
3942
  }
3932
3943
 
3933
3944
  // src/version.ts
3934
- var SDK_VERSION = "3.11.0";
3945
+ var SDK_VERSION = "3.12.0";
3935
3946
 
3936
3947
  // src/well-known.ts
3937
3948
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4098,6 +4109,7 @@ function createGuidanceResponse(_config, reason, options = {}) {
4098
4109
  }
4099
4110
  ] : void 0,
4100
4111
  correlationId: options.correlationId,
4112
+ attemptId: options.attemptId,
4101
4113
  verifiedAt: /* @__PURE__ */ new Date()
4102
4114
  };
4103
4115
  }
@@ -4127,6 +4139,8 @@ async function callVerifyAccessAPI(config, request) {
4127
4139
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
4128
4140
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4129
4141
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4142
+ if (requestData.attemptId) body.attemptId = requestData.attemptId;
4143
+ if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4130
4144
  body.sdkVersion = SDK_VERSION;
4131
4145
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
4132
4146
  const meta = {
@@ -4154,6 +4168,9 @@ async function callVerifyAccessAPI(config, request) {
4154
4168
  if (response.status === 410) {
4155
4169
  return {
4156
4170
  success: true,
4171
+ // 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
4172
+ // the synthesised 410 deny shape (echoed on every branch).
4173
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
4157
4174
  access: {
4158
4175
  allowed: false,
4159
4176
  accessLevel: "none",
@@ -4172,7 +4189,8 @@ async function callVerifyAccessAPI(config, request) {
4172
4189
  return {
4173
4190
  success: false,
4174
4191
  error: data.message || data.error || `API returned ${response.status}`,
4175
- correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
4192
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4193
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4176
4194
  };
4177
4195
  }
4178
4196
  return data;
@@ -4206,7 +4224,13 @@ async function verify(config, request, options) {
4206
4224
  if (mergedConfig.debug) {
4207
4225
  console.log("[VerificationGateway] Returning cached result");
4208
4226
  }
4209
- return cached;
4227
+ const hit = { ...cached };
4228
+ if (request.attemptId) {
4229
+ hit.attemptId = request.attemptId;
4230
+ } else {
4231
+ delete hit.attemptId;
4232
+ }
4233
+ return hit;
4210
4234
  }
4211
4235
  }
4212
4236
  const enrichedRequest = { ...request };
@@ -4226,6 +4250,7 @@ async function verify(config, request, options) {
4226
4250
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
4227
4251
  source: "api_error",
4228
4252
  correlationId: apiResponse.correlationId,
4253
+ attemptId: apiResponse.attemptId,
4229
4254
  urls
4230
4255
  });
4231
4256
  }
@@ -4261,6 +4286,9 @@ async function verify(config, request, options) {
4261
4286
  // Anonymous traffic has no session → correlationId is the per-attempt
4262
4287
  // linking key (the sessionId-equivalent for anonymous callers).
4263
4288
  correlationId: apiResponse.correlationId,
4289
+ // 3.12.0 (Trust Record): server echoes the attempt-chain handle on
4290
+ // every branch — denials included (the funnel outlives one deny).
4291
+ attemptId: apiResponse.attemptId,
4264
4292
  recommendation: apiResponse.recommendation,
4265
4293
  recommendationReasons: apiResponse.recommendationReasons,
4266
4294
  stepUpApproval: apiResponse.stepUpApproval,
@@ -4312,6 +4340,8 @@ async function verify(config, request, options) {
4312
4340
  // v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
4313
4341
  // (no session row exists for unverified callers).
4314
4342
  correlationId: apiResponse.correlationId,
4343
+ // 3.12.0 (Trust Record): server-echoed attempt-chain handle.
4344
+ attemptId: apiResponse.attemptId,
4315
4345
  runtimeChallenge: apiResponse.runtimeChallenge,
4316
4346
  tokenGuidance: apiResponse.tokenGuidance,
4317
4347
  recommendation: apiResponse.recommendation,
@@ -4695,13 +4725,29 @@ var TraceLogger = class {
4695
4725
  */
4696
4726
  logEvaluation(context, decision) {
4697
4727
  if (!this.enabled) return;
4698
- this.write({
4699
- id: this.generateId(),
4700
- timestamp: /* @__PURE__ */ new Date(),
4701
- type: "evaluation",
4702
- context: redactDeep(context),
4703
- decision: redactDeep(decision)
4704
- });
4728
+ let event;
4729
+ try {
4730
+ event = {
4731
+ id: this.generateId(),
4732
+ timestamp: /* @__PURE__ */ new Date(),
4733
+ type: "evaluation",
4734
+ context: redactDeep(context),
4735
+ decision: redactDeep(decision)
4736
+ };
4737
+ } catch (err) {
4738
+ event = {
4739
+ id: this.generateId(),
4740
+ timestamp: /* @__PURE__ */ new Date(),
4741
+ type: "error",
4742
+ metadata: {
4743
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4744
+ recommendation: decision.recommendation,
4745
+ purpose: context.purpose,
4746
+ action: context.action
4747
+ }
4748
+ };
4749
+ }
4750
+ this.write(event);
4705
4751
  }
4706
4752
  /**
4707
4753
  * Log a tool call the guard saw but did not govern. One line per skip
@@ -4743,17 +4789,34 @@ var TraceLogger = class {
4743
4789
  });
4744
4790
  }
4745
4791
  write(event) {
4792
+ let line;
4793
+ try {
4794
+ line = JSON.stringify(event) + "\n";
4795
+ } catch {
4796
+ return;
4797
+ }
4746
4798
  try {
4747
4799
  const filePath = this.getCurrentFilePath();
4748
- const line = JSON.stringify(event) + "\n";
4749
4800
  if ((0, import_fs3.existsSync)(filePath)) {
4750
4801
  const stats = (0, import_fs3.statSync)(filePath);
4751
4802
  if (stats.size > MAX_FILE_SIZE) {
4752
4803
  this.rotate();
4753
4804
  }
4754
4805
  }
4755
- (0, import_fs3.appendFileSync)(filePath, line);
4806
+ for (let attempt = 0; attempt < 3; attempt++) {
4807
+ try {
4808
+ (0, import_fs3.appendFileSync)(filePath, line);
4809
+ return;
4810
+ } catch {
4811
+ }
4812
+ }
4813
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4814
+ (0, import_fs3.appendFileSync)(fallbackPath, line);
4756
4815
  } catch {
4816
+ try {
4817
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4818
+ } catch {
4819
+ }
4757
4820
  }
4758
4821
  }
4759
4822
  getCurrentFilePath() {