@astrasyncai/verification-gateway 2.4.8 → 2.4.9

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 (89) 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 +29 -15
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +29 -15
  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 +30 -14
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +30 -14
  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 +37 -16
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +37 -16
  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 +31 -13
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +31 -13
  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/browser/background.js +25 -12
  30. package/dist/browser/background.js.map +1 -1
  31. package/dist/browser/background.mjs +25 -12
  32. package/dist/browser/background.mjs.map +1 -1
  33. package/dist/browser/browser-adapter.d.mts +2 -2
  34. package/dist/browser/browser-adapter.d.ts +2 -2
  35. package/dist/cli/index.d.mts +2 -2
  36. package/dist/cli/index.d.ts +2 -2
  37. package/dist/cursor/cursor-adapter.d.mts +2 -2
  38. package/dist/cursor/cursor-adapter.d.ts +2 -2
  39. package/dist/cursor/extension.d.mts +2 -2
  40. package/dist/cursor/extension.d.ts +2 -2
  41. package/dist/cursor/extension.js +25 -12
  42. package/dist/cursor/extension.js.map +1 -1
  43. package/dist/cursor/extension.mjs +25 -12
  44. package/dist/cursor/extension.mjs.map +1 -1
  45. package/dist/{express-DvVjR2H4.d.mts → express-4WStX3PV.d.mts} +1 -1
  46. package/dist/{express-714gJbaW.d.ts → express-C1ePFB7n.d.ts} +1 -1
  47. package/dist/gateway/gateway.d.mts +2 -2
  48. package/dist/gateway/gateway.d.ts +2 -2
  49. package/dist/gateway/gateway.js +25 -12
  50. package/dist/gateway/gateway.js.map +1 -1
  51. package/dist/gateway/gateway.mjs +25 -12
  52. package/dist/gateway/gateway.mjs.map +1 -1
  53. package/dist/git-trigger/git-hooks.d.mts +2 -2
  54. package/dist/git-trigger/git-hooks.d.ts +2 -2
  55. package/dist/{index-DYFS9QVb.d.mts → index-ChPX4WHl.d.mts} +1 -1
  56. package/dist/{index-DO0oG8ED.d.ts → index-Cjm-zBeZ.d.ts} +1 -1
  57. package/dist/{index-2WAlxs2G.d.ts → index-CzJMCgEy.d.ts} +1 -1
  58. package/dist/{index-P9t7M_dJ.d.mts → index-D8IEntil.d.mts} +1 -1
  59. package/dist/index.d.mts +22 -11
  60. package/dist/index.d.ts +22 -11
  61. package/dist/index.js +80 -25
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +79 -25
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/local-evaluator/evaluator.d.mts +2 -2
  66. package/dist/local-evaluator/evaluator.d.ts +2 -2
  67. package/dist/{nextjs-CZ-MwSOT.d.ts → nextjs-BIORS__0.d.ts} +1 -1
  68. package/dist/{nextjs-BCoH7EqF.d.mts → nextjs-CjzHdaXA.d.mts} +1 -1
  69. package/dist/registration/index.d.mts +76 -1
  70. package/dist/registration/index.d.ts +76 -1
  71. package/dist/registration/index.js +27 -2
  72. package/dist/registration/index.js.map +1 -1
  73. package/dist/registration/index.mjs +25 -1
  74. package/dist/registration/index.mjs.map +1 -1
  75. package/dist/{sdk-wwhFDXWX.d.mts → sdk-Chhz-FcT.d.mts} +9 -4
  76. package/dist/{sdk-kiA49vqJ.d.ts → sdk-CqTEQAc6.d.ts} +9 -4
  77. package/dist/transport/index.d.mts +2 -2
  78. package/dist/transport/index.d.ts +2 -2
  79. package/dist/{types-DOAb89cm.d.mts → types-DNK2BgIf.d.mts} +1 -1
  80. package/dist/{types-aucqzfUa.d.ts → types-DoWIuzfj.d.ts} +1 -1
  81. package/dist/{types-BwDmjIdr.d.mts → types-L15pYd2c.d.mts} +21 -4
  82. package/dist/{types-BwDmjIdr.d.ts → types-L15pYd2c.d.ts} +21 -4
  83. package/dist/ui/index.d.mts +1 -1
  84. package/dist/ui/index.d.ts +1 -1
  85. package/dist/ui/index.js +1 -1
  86. package/dist/ui/index.js.map +1 -1
  87. package/dist/ui/index.mjs +1 -1
  88. package/dist/ui/index.mjs.map +1 -1
  89. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -126,7 +126,7 @@ function getCapabilities(accessLevel) {
126
126
  }
127
127
 
128
128
  // src/version.ts
129
- var SDK_VERSION = "2.4.7";
129
+ var SDK_VERSION = "2.4.9";
130
130
 
131
131
  // src/verify.ts
132
132
  var DEFAULT_CONFIG = {
@@ -243,12 +243,17 @@ function createGuidanceResponse(config, reason, options = {}) {
243
243
  ]
244
244
  };
245
245
  return {
246
- verified: false,
246
+ // Round-18 G4: createGuidanceResponse fires for unverified-agent path or
247
+ // API-error fallback. Identity is not verified (no agent resolved);
248
+ // policy is not evaluated (we never reached the gate).
249
+ identityVerified: false,
250
+ policyAllowed: false,
247
251
  // v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
248
- // Adapters additionally short-circuit on `verified === false` before
249
- // the gate check, but the access level still has to be honest at the
250
- // data layer so downstream consumers (SDK adapters in other languages,
251
- // custom integrations) inherit the correct semantics.
252
+ // Adapters additionally short-circuit on `!identityVerified ||
253
+ // !policyAllowed` before the gate check, but the access level still has
254
+ // to be honest at the data layer so downstream consumers (SDK adapters
255
+ // in other languages, custom integrations) inherit the correct
256
+ // semantics.
252
257
  accessLevel: "none",
253
258
  guidance,
254
259
  denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
@@ -392,15 +397,17 @@ async function verify(config, request) {
392
397
  }
393
398
  if (!apiResponse.access?.allowed) {
394
399
  const aggregatedFailures = apiResponse.access?.failures;
400
+ const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
395
401
  const result2 = {
396
- verified: false,
402
+ identityVerified: idVerifiedFromBackend,
403
+ policyAllowed: false,
397
404
  // v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
398
405
  // Pre-rename this hardcoded `'guidance'`, which conflated with the
399
406
  // colocated `guidance: {...}` help-payload object below and let
400
407
  // denied requests pass any route gated at `'guidance'` because
401
408
  // `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
402
- // ALSO short-circuit on `verified === false` before the gate check —
403
- // belt-and-braces.
409
+ // ALSO short-circuit on `!identityVerified || !policyAllowed` before
410
+ // the gate check — belt-and-braces.
404
411
  accessLevel: "none",
405
412
  denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
406
413
  failures: aggregatedFailures,
@@ -444,7 +451,13 @@ async function verify(config, request) {
444
451
  const verificationContext = apiResponse.verificationContext;
445
452
  const accessLevel = apiResponse.access?.accessLevel ?? "standard";
446
453
  const result = {
447
- verified: true,
454
+ // Round-18 G4: backend allowed access. Identity is verified (we resolved
455
+ // the caller to an agent) and policy passed all gates. Read idVerified
456
+ // from verificationContext for symmetry with the deny branch; default true
457
+ // on success path since `access.allowed === true` implies identity was
458
+ // resolvable (anonymous-allow paths flow through createGuidanceResponse).
459
+ identityVerified: apiResponse.verificationContext?.idVerified !== false,
460
+ policyAllowed: true,
448
461
  accessLevel,
449
462
  agent,
450
463
  developer,
@@ -467,7 +480,7 @@ async function verify(config, request) {
467
480
  warningHeader: apiResponse.warningHeader
468
481
  };
469
482
  if (result.recommendation === "deny") {
470
- result.verified = false;
483
+ result.policyAllowed = false;
471
484
  result.accessLevel = "none";
472
485
  result.denialReasons = result.recommendationReasons || [
473
486
  "Access denied by AstraSync recommendation"
@@ -567,7 +580,8 @@ async function quickVerify(config, credentials) {
567
580
  purpose: "verification"
568
581
  });
569
582
  return {
570
- verified: result.verified,
583
+ identityVerified: result.identityVerified,
584
+ policyAllowed: result.policyAllowed,
571
585
  accessLevel: result.accessLevel,
572
586
  reason: result.denialReasons?.[0]
573
587
  };
@@ -739,12 +753,12 @@ function findRouteConfig(routes, path, method) {
739
753
  });
740
754
  }
741
755
  function defaultOnDenied(result, _req, res) {
742
- const statusCode = result.verified ? 403 : 401;
756
+ const statusCode = !result.identityVerified ? 401 : 403;
743
757
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
744
758
  res.status(statusCode).json({
745
759
  success: false,
746
760
  error: {
747
- code: result.verified ? "INSUFFICIENT_ACCESS" : "UNAUTHORIZED",
761
+ code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
748
762
  message: result.denialReasons?.[0] || "Access denied",
749
763
  accessLevel: result.accessLevel,
750
764
  guidance: result.guidance,
@@ -838,7 +852,8 @@ function createMiddleware(options) {
838
852
  const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
839
853
  if (preCheckFailures.length > 0) {
840
854
  const result2 = {
841
- verified: false,
855
+ identityVerified: false,
856
+ policyAllowed: false,
842
857
  accessLevel: "none",
843
858
  denialReasons: preCheckFailures.map((f) => f.message),
844
859
  guidance: {
@@ -887,7 +902,7 @@ function createMiddleware(options) {
887
902
  });
888
903
  req.agentVerification = result;
889
904
  const sessionId = result.sessionId;
890
- if (!result.verified) {
905
+ if (!result.identityVerified || !result.policyAllowed) {
891
906
  if (shouldRecordDecisions && sessionId) {
892
907
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
893
908
  });
@@ -1238,7 +1253,8 @@ function createMiddleware2(options) {
1238
1253
  const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
1239
1254
  if (preCheckFailures.length > 0) {
1240
1255
  const preCheckResult = {
1241
- verified: false,
1256
+ identityVerified: false,
1257
+ policyAllowed: false,
1242
1258
  accessLevel: "none",
1243
1259
  denialReasons: preCheckFailures.map((f) => f.message),
1244
1260
  guidance: {
@@ -1301,20 +1317,22 @@ function createMiddleware2(options) {
1301
1317
  agentCardUrl: request.headers.get("x-astrasync-agent-card") || void 0
1302
1318
  }
1303
1319
  });
1304
- if (!result.verified || !hasMinimumAccess(result.accessLevel, routeConfig.minAccessLevel)) {
1320
+ if (!result.identityVerified || !result.policyAllowed || !hasMinimumAccess(result.accessLevel, routeConfig.minAccessLevel)) {
1305
1321
  if (pathname.startsWith("/api/")) {
1306
1322
  return NextResponse.json(
1307
1323
  {
1308
1324
  success: false,
1309
1325
  error: {
1310
- code: result.verified ? "INSUFFICIENT_ACCESS" : "UNAUTHORIZED",
1326
+ // Round-18 G4: 401 identity missing (re-auth); 403 → identity
1327
+ // OK, policy denied (update PDLSS / step up).
1328
+ code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
1311
1329
  message: result.denialReasons?.[0] || "Access denied",
1312
1330
  accessLevel: result.accessLevel,
1313
1331
  required: routeConfig.minAccessLevel,
1314
1332
  guidance: result.guidance
1315
1333
  }
1316
1334
  },
1317
- { status: result.verified ? 403 : 401 }
1335
+ { status: !result.identityVerified ? 401 : 403 }
1318
1336
  );
1319
1337
  }
1320
1338
  if (showCommerceShield) {
@@ -1329,7 +1347,12 @@ function createMiddleware2(options) {
1329
1347
  return NextResponse.redirect(new URL("/unauthorized", request.url));
1330
1348
  }
1331
1349
  const response = NextResponse.next();
1332
- response.headers.set("X-AstraSync-Verified", result.verified.toString());
1350
+ response.headers.set(
1351
+ "X-AstraSync-Verified",
1352
+ (result.identityVerified && result.policyAllowed).toString()
1353
+ );
1354
+ response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
1355
+ response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
1333
1356
  response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
1334
1357
  if (result.agent) {
1335
1358
  response.headers.set("X-AstraSync-Agent-Id", result.agent.astraId);
@@ -1397,7 +1420,11 @@ var VerificationGatewayClient = class {
1397
1420
  );
1398
1421
  }
1399
1422
  /**
1400
- * Quick verification - just check if credentials are valid
1423
+ * Quick verification checks credentials and policy in one call.
1424
+ *
1425
+ * Round-18 G4: return shape mirrors `VerificationResult`'s identity/policy
1426
+ * split. Map to HTTP status the same way: `!identityVerified` → 401,
1427
+ * `identityVerified && !policyAllowed` → 403.
1401
1428
  */
1402
1429
  async quickVerify(credentials) {
1403
1430
  return this.executeWithRetry(() => quickVerify(this.config, credentials));
@@ -4043,13 +4070,16 @@ function readSingleHeader(value) {
4043
4070
  }
4044
4071
  function defaultMcpDenied(result, req, res) {
4045
4072
  const id = req.body?.id ?? null;
4046
- const status = result.verified ? 403 : 401;
4073
+ const status = !result.identityVerified ? 401 : 403;
4047
4074
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
4048
4075
  res.status(status).json({
4049
4076
  jsonrpc: "2.0",
4050
4077
  id,
4051
4078
  error: {
4052
- code: result.verified ? -32001 : -32e3,
4079
+ // JSON-RPC error codes:
4080
+ // -32000 → unauthorized (no identity resolved)
4081
+ // -32001 → insufficient access (identity OK, policy denied)
4082
+ code: !result.identityVerified ? -32e3 : -32001,
4053
4083
  message: result.denialReasons?.[0] ?? "Access denied",
4054
4084
  data: {
4055
4085
  accessLevel: result.accessLevel,
@@ -4183,7 +4213,7 @@ function createMcpMiddleware(options) {
4183
4213
  req.agentVerification = result;
4184
4214
  const sessionId = result.sessionId;
4185
4215
  const correlationId = result.correlationId;
4186
- if (!result.verified) {
4216
+ if (!result.identityVerified || !result.policyAllowed) {
4187
4217
  if (shouldRecordDecisions && sessionId) {
4188
4218
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
4189
4219
  });
@@ -4600,6 +4630,29 @@ var AstraSync = class {
4600
4630
  }
4601
4631
  };
4602
4632
 
4633
+ // src/registration/guidance.ts
4634
+ function buildGuidance(params) {
4635
+ const origin = params.origin.replace(/\/+$/, "");
4636
+ const docsPath = params.documentationPath ?? "/docs/agent-access";
4637
+ const message = params.message ?? "AstraSync registration requires credentials.";
4638
+ return {
4639
+ status: "credentials_required",
4640
+ message,
4641
+ guidance: {
4642
+ message: "AstraSync registration requires credentials. Get an account + API key, then call register_agent again.",
4643
+ registrationUrl: `${origin}/register`,
4644
+ documentationUrl: `${origin}${docsPath.startsWith("/") ? docsPath : `/${docsPath}`}`,
4645
+ steps: [
4646
+ "Visit registrationUrl and create an AstraSync account (or log in if you have one).",
4647
+ "Generate an API key from Settings \u2192 API Keys.",
4648
+ "Re-call register_agent with the apiKey populated.",
4649
+ "After registration returns status: pending_approval, the owner approves via email.",
4650
+ "Use poll_registration({ requestId }) to retrieve the astraId once approved."
4651
+ ]
4652
+ }
4653
+ };
4654
+ }
4655
+
4603
4656
  // src/agent/index.ts
4604
4657
  var agent_exports = {};
4605
4658
  __export(agent_exports, {
@@ -4932,6 +4985,7 @@ export {
4932
4985
  TRUST_LEVEL_RANGES,
4933
4986
  VERSION,
4934
4987
  agent_exports as agent,
4988
+ buildGuidance,
4935
4989
  clearCache,
4936
4990
  createMcpMiddleware,
4937
4991
  determineAccessLevel,