@astrasyncai/verification-gateway 2.2.3 → 2.3.7

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 (79) 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 +62 -30
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +61 -27
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +245 -0
  10. package/dist/adapters/mcp.d.ts +245 -0
  11. package/dist/adapters/mcp.js +589 -0
  12. package/dist/adapters/mcp.js.map +1 -0
  13. package/dist/adapters/mcp.mjs +555 -0
  14. package/dist/adapters/mcp.mjs.map +1 -0
  15. package/dist/adapters/nextjs.d.mts +2 -2
  16. package/dist/adapters/nextjs.d.ts +2 -2
  17. package/dist/adapters/nextjs.js +60 -12
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +60 -12
  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 +6 -10
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +6 -10
  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 +12 -10
  30. package/dist/browser/background.js.map +1 -1
  31. package/dist/browser/background.mjs +12 -10
  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 +12 -10
  42. package/dist/cursor/extension.js.map +1 -1
  43. package/dist/cursor/extension.mjs +12 -10
  44. package/dist/cursor/extension.mjs.map +1 -1
  45. package/dist/{express-DgwpS8Ha.d.mts → express-D9oRsseg.d.mts} +17 -14
  46. package/dist/{express-BtKlLI8U.d.ts → express-DMSIl20m.d.ts} +17 -14
  47. package/dist/gateway/gateway.d.mts +2 -2
  48. package/dist/gateway/gateway.d.ts +2 -2
  49. package/dist/gateway/gateway.js +12 -10
  50. package/dist/gateway/gateway.js.map +1 -1
  51. package/dist/gateway/gateway.mjs +12 -10
  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-AzhK20t0.d.mts → index-Bn_7eGjb.d.mts} +1 -1
  56. package/dist/{index-Ba0Lvsjo.d.ts → index-BtU9yFda.d.ts} +1 -1
  57. package/dist/{index-DpJS1JEI.d.ts → index-EwUWXC5T.d.ts} +1 -1
  58. package/dist/{index-BaxpmTGA.d.mts → index-YNPs800Z.d.mts} +1 -1
  59. package/dist/index.d.mts +7 -7
  60. package/dist/index.d.ts +7 -7
  61. package/dist/index.js +96 -29
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +96 -29
  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-B2kg19c1.d.ts → nextjs-B5ZBpHra.d.ts} +8 -2
  68. package/dist/{nextjs-ZymQ8jDh.d.mts → nextjs-BLtjRbc-.d.mts} +8 -2
  69. package/dist/{sdk-B7id0VFS.d.mts → sdk-BhkxvqnK.d.mts} +1 -1
  70. package/dist/{sdk-Bso0FSI0.d.ts → sdk-YmE3RG8n.d.ts} +1 -1
  71. package/dist/transport/index.d.mts +2 -2
  72. package/dist/transport/index.d.ts +2 -2
  73. package/dist/{types-BYKAY6Cc.d.ts → types-BecRpozv.d.ts} +1 -1
  74. package/dist/{types-DOrqNMgy.d.mts → types-Bxqj1sKY.d.mts} +134 -24
  75. package/dist/{types-DOrqNMgy.d.ts → types-Bxqj1sKY.d.ts} +134 -24
  76. package/dist/{types-CgXPKUwi.d.mts → types-DxY5zt4z.d.mts} +1 -1
  77. package/dist/ui/index.d.mts +1 -1
  78. package/dist/ui/index.d.ts +1 -1
  79. package/package.json +6 -1
@@ -1,6 +1,6 @@
1
1
  import { AstraSyncGateway } from '../gateway/gateway.mjs';
2
- import { V as VerificationDecision, P as PDLSSContext } from '../types-CgXPKUwi.mjs';
3
- import '../types-DOrqNMgy.mjs';
2
+ import { V as VerificationDecision, P as PDLSSContext } from '../types-DxY5zt4z.mjs';
3
+ import '../types-Bxqj1sKY.mjs';
4
4
 
5
5
  /**
6
6
  * Git Trigger — Enterprise git push / PR verification
@@ -1,6 +1,6 @@
1
1
  import { AstraSyncGateway } from '../gateway/gateway.js';
2
- import { V as VerificationDecision, P as PDLSSContext } from '../types-BYKAY6Cc.js';
3
- import '../types-DOrqNMgy.js';
2
+ import { V as VerificationDecision, P as PDLSSContext } from '../types-BecRpozv.js';
3
+ import '../types-Bxqj1sKY.js';
4
4
 
5
5
  /**
6
6
  * Git Trigger — Enterprise git push / PR verification
@@ -1,4 +1,4 @@
1
- import { A as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-DOrqNMgy.mjs';
1
+ import { A as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-Bxqj1sKY.mjs';
2
2
 
3
3
  /**
4
4
  * AgentClient — Credential Presentation
@@ -1,4 +1,4 @@
1
- import { A as AstraSyncCredentials, g as ProtocolTransport } from './types-DOrqNMgy.js';
1
+ import { A as AstraSyncCredentials, g as ProtocolTransport } from './types-Bxqj1sKY.js';
2
2
  import { JWK } from 'jose';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { A as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-DOrqNMgy.js';
1
+ import { A as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-Bxqj1sKY.js';
2
2
 
3
3
  /**
4
4
  * AgentClient — Credential Presentation
@@ -1,4 +1,4 @@
1
- import { A as AstraSyncCredentials, g as ProtocolTransport } from './types-DOrqNMgy.mjs';
1
+ import { A as AstraSyncCredentials, g as ProtocolTransport } from './types-Bxqj1sKY.mjs';
2
2
  import { JWK } from 'jose';
3
3
 
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-DOrqNMgy.mjs';
2
- export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-DOrqNMgy.mjs';
3
- export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-B7id0VFS.mjs';
4
- export { e as express } from './express-DgwpS8Ha.mjs';
5
- export { n as nextjs } from './nextjs-ZymQ8jDh.mjs';
6
- export { i as transport } from './index-BaxpmTGA.mjs';
7
- export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-AzhK20t0.mjs';
1
+ import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-Bxqj1sKY.mjs';
2
+ export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-Bxqj1sKY.mjs';
3
+ export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-BhkxvqnK.mjs';
4
+ export { e as express } from './express-D9oRsseg.mjs';
5
+ export { n as nextjs } from './nextjs-BLtjRbc-.mjs';
6
+ export { i as transport } from './index-YNPs800Z.mjs';
7
+ export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-Bn_7eGjb.mjs';
8
8
  import 'express';
9
9
  import 'next/server';
10
10
  import 'jose';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-DOrqNMgy.js';
2
- export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-DOrqNMgy.js';
3
- export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-Bso0FSI0.js';
4
- export { e as express } from './express-BtKlLI8U.js';
5
- export { n as nextjs } from './nextjs-B2kg19c1.js';
6
- export { i as transport } from './index-Ba0Lvsjo.js';
7
- export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-DpJS1JEI.js';
1
+ import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-Bxqj1sKY.js';
2
+ export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-Bxqj1sKY.js';
3
+ export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-YmE3RG8n.js';
4
+ export { e as express } from './express-DMSIl20m.js';
5
+ export { n as nextjs } from './nextjs-B5ZBpHra.js';
6
+ export { i as transport } from './index-BtU9yFda.js';
7
+ export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-EwUWXC5T.js';
8
8
  import 'express';
9
9
  import 'next/server';
10
10
  import 'jose';
package/dist/index.js CHANGED
@@ -386,10 +386,12 @@ async function verify(config, request) {
386
386
  return createGuidanceResponse(mergedConfig, apiResponse.error);
387
387
  }
388
388
  if (!apiResponse.access?.allowed) {
389
+ const aggregatedFailures = apiResponse.access?.failures;
389
390
  const result2 = {
390
391
  verified: false,
391
392
  accessLevel: "guidance",
392
- denialReasons: apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
393
+ denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
394
+ failures: aggregatedFailures,
393
395
  requiresStepUp: apiResponse.access?.requiresStepUp,
394
396
  requiresApproval: apiResponse.access?.requiresApproval,
395
397
  guidance: {
@@ -424,14 +426,7 @@ async function verify(config, request) {
424
426
  verified: apiResponse.organization.verified,
425
427
  trustScore: apiResponse.organization.trustScore
426
428
  } : void 0;
427
- const pdlss = apiResponse.access?.pdlss ? {
428
- purposeAllowed: apiResponse.access.pdlss.purposeAllowed,
429
- withinDuration: apiResponse.access.pdlss.withinDuration,
430
- withinLimits: apiResponse.access.pdlss.withinLimits,
431
- scopeAllowed: apiResponse.access.pdlss.scopeAllowed,
432
- selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
433
- appliedPolicy: apiResponse.access.appliedPolicy
434
- } : void 0;
429
+ const verificationContext = apiResponse.verificationContext;
435
430
  const accessLevel = apiResponse.access?.accessLevel ?? "standard";
436
431
  const result = {
437
432
  verified: true,
@@ -439,7 +434,8 @@ async function verify(config, request) {
439
434
  agent,
440
435
  developer,
441
436
  organization,
442
- pdlss,
437
+ appliedPolicy: apiResponse.access?.appliedPolicy,
438
+ verificationContext,
443
439
  requiresStepUp: apiResponse.access?.requiresStepUp,
444
440
  requiresApproval: apiResponse.access?.requiresApproval,
445
441
  verifiedAt: /* @__PURE__ */ new Date(),
@@ -489,6 +485,25 @@ async function recordDecision(config, sessionId, decision, reason) {
489
485
  }).catch(() => {
490
486
  });
491
487
  }
488
+ async function fetchRoutes(config, counterpartyId) {
489
+ if (!counterpartyId) return null;
490
+ const headers = { "Content-Type": "application/json" };
491
+ if (config.apiKey) {
492
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
493
+ headers["X-API-Key"] = config.apiKey;
494
+ }
495
+ try {
496
+ const response = await fetch(
497
+ `${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
498
+ { method: "GET", headers }
499
+ );
500
+ if (!response.ok) return null;
501
+ const body = await response.json();
502
+ return body.data?.routes ?? [];
503
+ } catch {
504
+ return null;
505
+ }
506
+ }
492
507
  async function reportCounterpartyPreCheckFailure(config, data) {
493
508
  const apiBaseUrl = config.apiBaseUrl || DEFAULT_CONFIG.apiBaseUrl;
494
509
  await fetch(`${apiBaseUrl}/verification-activity/counterparty-pre-check-failure`, {
@@ -514,9 +529,7 @@ async function quickVerify(config, credentials) {
514
529
  var express_exports = {};
515
530
  __export(express_exports, {
516
531
  createMiddleware: () => createMiddleware,
517
- extractAstraSyncCredentials: () => extractAstraSyncCredentials,
518
- requireAccess: () => requireAccess,
519
- verifyOnly: () => verifyOnly
532
+ extractAstraSyncCredentials: () => extractAstraSyncCredentials
520
533
  });
521
534
 
522
535
  // src/transport/http.ts
@@ -689,24 +702,57 @@ function defaultOnDenied(result, _req, res) {
689
702
  }
690
703
  });
691
704
  }
705
+ var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
692
706
  function createMiddleware(options) {
693
707
  const {
694
- routes = [],
695
708
  extractCredentials: customExtractCredentials,
696
709
  extractPurpose: customExtractPurpose,
697
710
  skipPaths = [],
698
711
  onDenied = defaultOnDenied,
699
712
  recordDecisions,
700
713
  enableRuntimeChallenge = true,
714
+ routesRefreshMs = DEFAULT_ROUTES_REFRESH_MS,
701
715
  ...config
702
716
  } = options;
717
+ let cachedRoutes = [];
718
+ let lastFetchAt = 0;
719
+ let refreshing = null;
720
+ let warnedNoCounterparty = false;
721
+ async function refreshRoutes() {
722
+ if (!config.counterpartyId) {
723
+ if (!warnedNoCounterparty) {
724
+ console.warn(
725
+ "[VerificationGateway] No counterpartyId configured \u2014 falling through (allow all). Per-route policy lives in the AstraSync dashboard now; register the endpoint and set counterpartyId in your middleware config to enforce policy."
726
+ );
727
+ warnedNoCounterparty = true;
728
+ }
729
+ return;
730
+ }
731
+ const fetched = await fetchRoutes(config, config.counterpartyId);
732
+ if (fetched) {
733
+ cachedRoutes = fetched;
734
+ lastFetchAt = Date.now();
735
+ }
736
+ }
737
+ refreshing = refreshRoutes().finally(() => {
738
+ refreshing = null;
739
+ });
703
740
  return async (req, res, next) => {
704
741
  try {
705
742
  const shouldSkip = skipPaths.some((pattern) => matchRoute(pattern, req.path));
706
743
  if (shouldSkip) {
707
744
  return next();
708
745
  }
709
- const routeConfig = findRouteConfig(routes, req.path, req.method);
746
+ if (refreshing) {
747
+ await refreshing.catch(() => {
748
+ });
749
+ }
750
+ if (config.counterpartyId && Date.now() - lastFetchAt > routesRefreshMs) {
751
+ refreshing = refreshRoutes().finally(() => {
752
+ refreshing = null;
753
+ });
754
+ }
755
+ const routeConfig = findRouteConfig(cachedRoutes, req.path, req.method);
710
756
  if (!routeConfig) {
711
757
  return next();
712
758
  }
@@ -801,18 +847,6 @@ function createMiddleware(options) {
801
847
  }
802
848
  };
803
849
  }
804
- function requireAccess(minAccessLevel, options) {
805
- return createMiddleware({
806
- ...options,
807
- routes: [{ pattern: "*", method: "*", minAccessLevel }]
808
- });
809
- }
810
- function verifyOnly(options) {
811
- return createMiddleware({
812
- ...options,
813
- routes: [{ pattern: "*", method: "*", minAccessLevel: "none" }]
814
- });
815
- }
816
850
 
817
851
  // src/adapters/nextjs.ts
818
852
  var nextjs_exports = {};
@@ -1036,14 +1070,38 @@ function generateCommerceShieldHtml(result, options) {
1036
1070
  </html>
1037
1071
  `.trim();
1038
1072
  }
1073
+ var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
1039
1074
  function createMiddleware2(options) {
1040
1075
  const {
1041
- routes = [],
1042
1076
  skipPaths = [],
1043
1077
  showCommerceShield = true,
1044
1078
  enableRuntimeChallenge = true,
1079
+ routesRefreshMs = DEFAULT_ROUTES_REFRESH_MS2,
1045
1080
  ...config
1046
1081
  } = options;
1082
+ let cachedRoutes = [];
1083
+ let lastFetchAt = 0;
1084
+ let refreshing = null;
1085
+ let warnedNoCounterparty = false;
1086
+ async function refreshRoutes() {
1087
+ if (!config.counterpartyId) {
1088
+ if (!warnedNoCounterparty) {
1089
+ console.warn(
1090
+ "[VerificationGateway/Next.js] No counterpartyId configured \u2014 falling through (allow all). Per-route policy lives in the AstraSync dashboard now; register the endpoint and set counterpartyId in your middleware config to enforce policy."
1091
+ );
1092
+ warnedNoCounterparty = true;
1093
+ }
1094
+ return;
1095
+ }
1096
+ const fetched = await fetchRoutes(config, config.counterpartyId);
1097
+ if (fetched) {
1098
+ cachedRoutes = fetched;
1099
+ lastFetchAt = Date.now();
1100
+ }
1101
+ }
1102
+ refreshing = refreshRoutes().finally(() => {
1103
+ refreshing = null;
1104
+ });
1047
1105
  return async function middleware(request) {
1048
1106
  const { NextResponse } = await import("next/server");
1049
1107
  const pathname = request.nextUrl.pathname;
@@ -1051,7 +1109,16 @@ function createMiddleware2(options) {
1051
1109
  if (shouldSkip) {
1052
1110
  return NextResponse.next();
1053
1111
  }
1054
- const routeConfig = findRouteConfig2(routes, pathname, request.method);
1112
+ if (refreshing) {
1113
+ await refreshing.catch(() => {
1114
+ });
1115
+ }
1116
+ if (config.counterpartyId && Date.now() - lastFetchAt > routesRefreshMs) {
1117
+ refreshing = refreshRoutes().finally(() => {
1118
+ refreshing = null;
1119
+ });
1120
+ }
1121
+ const routeConfig = findRouteConfig2(cachedRoutes, pathname, request.method);
1055
1122
  if (!routeConfig) {
1056
1123
  return NextResponse.next();
1057
1124
  }