@astrasyncai/verification-gateway 5.15.0 → 5.17.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 (96) hide show
  1. package/README.md +9 -1
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +17 -2
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +17 -2
  7. package/dist/adapters/express.mjs.map +1 -1
  8. package/dist/adapters/mcp.d.mts +1 -1
  9. package/dist/adapters/mcp.d.ts +1 -1
  10. package/dist/adapters/mcp.js +4 -1
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +4 -1
  13. package/dist/adapters/mcp.mjs.map +1 -1
  14. package/dist/adapters/nextjs.d.mts +1 -1
  15. package/dist/adapters/nextjs.d.ts +1 -1
  16. package/dist/adapters/nextjs.js +17 -2
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +17 -2
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +1 -1
  21. package/dist/adapters/sdk.d.ts +1 -1
  22. package/dist/adapters/sdk.js +4 -1
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +4 -1
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.d.mts +69 -54
  27. package/dist/agent/index.d.ts +69 -54
  28. package/dist/agent/index.js +24 -14
  29. package/dist/agent/index.js.map +1 -1
  30. package/dist/agent/index.mjs +24 -14
  31. package/dist/agent/index.mjs.map +1 -1
  32. package/dist/bin/astrasync-claude-hook.js +4 -1
  33. package/dist/bin/astrasync-codex-hook.js +4 -1
  34. package/dist/bin/astrasync-guard.js +544 -25
  35. package/dist/bin/astrasync.js +590 -33
  36. package/dist/browser/background.js +4 -1
  37. package/dist/browser/background.js.map +1 -1
  38. package/dist/browser/background.mjs +4 -1
  39. package/dist/browser/background.mjs.map +1 -1
  40. package/dist/cli/index.js +1 -1
  41. package/dist/cli/index.js.map +1 -1
  42. package/dist/cli/index.mjs +1 -1
  43. package/dist/cli/index.mjs.map +1 -1
  44. package/dist/codex/index.js +4 -1
  45. package/dist/codex/index.js.map +1 -1
  46. package/dist/codex/index.mjs +4 -1
  47. package/dist/codex/index.mjs.map +1 -1
  48. package/dist/cursor/extension.js +4 -1
  49. package/dist/cursor/extension.js.map +1 -1
  50. package/dist/cursor/extension.mjs +4 -1
  51. package/dist/cursor/extension.mjs.map +1 -1
  52. package/dist/edge-config.d.mts +1 -1
  53. package/dist/edge-config.d.ts +1 -1
  54. package/dist/edge-config.js +1 -1
  55. package/dist/edge-config.js.map +1 -1
  56. package/dist/edge-config.mjs +1 -1
  57. package/dist/edge-config.mjs.map +1 -1
  58. package/dist/edge-core/index.d.mts +1 -1
  59. package/dist/edge-core/index.d.ts +1 -1
  60. package/dist/edge-core/index.js +5 -2
  61. package/dist/edge-core/index.js.map +1 -1
  62. package/dist/edge-core/index.mjs +5 -2
  63. package/dist/edge-core/index.mjs.map +1 -1
  64. package/dist/gateway/gateway.js +4 -1
  65. package/dist/gateway/gateway.js.map +1 -1
  66. package/dist/gateway/gateway.mjs +4 -1
  67. package/dist/gateway/gateway.mjs.map +1 -1
  68. package/dist/git-trigger/git-hooks.d.mts +1 -1
  69. package/dist/git-trigger/git-hooks.d.ts +1 -1
  70. package/dist/index.d.mts +96 -57
  71. package/dist/index.d.ts +96 -57
  72. package/dist/index.js +43 -15
  73. package/dist/index.js.map +1 -1
  74. package/dist/index.mjs +42 -15
  75. package/dist/index.mjs.map +1 -1
  76. package/dist/registration/index.js +1 -1
  77. package/dist/registration/index.js.map +1 -1
  78. package/dist/registration/index.mjs +1 -1
  79. package/dist/registration/index.mjs.map +1 -1
  80. package/dist/transport/index.js +1 -1
  81. package/dist/transport/index.js.map +1 -1
  82. package/dist/transport/index.mjs +1 -1
  83. package/dist/transport/index.mjs.map +1 -1
  84. package/dist/{types-Dxf9DBpr.d.mts → types-Blz520bR.d.mts} +10 -0
  85. package/dist/{types-Dxf9DBpr.d.ts → types-Blz520bR.d.ts} +10 -0
  86. package/dist/{types-DtJjlW4O.d.ts → types-Bm1QvGqI.d.ts} +10 -0
  87. package/dist/{types-Eg6VoBNH.d.mts → types-DBe4hgfT.d.mts} +10 -0
  88. package/dist/ui/index.d.mts +1 -1
  89. package/dist/ui/index.d.ts +1 -1
  90. package/dist/verify.d.mts +1 -1
  91. package/dist/verify.d.ts +1 -1
  92. package/dist/verify.js +4 -1
  93. package/dist/verify.js.map +1 -1
  94. package/dist/verify.mjs +4 -1
  95. package/dist/verify.mjs.map +1 -1
  96. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -4,6 +4,17 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
+ // src/types.ts
8
+ function routePolicyOf(route) {
9
+ if (!route) return void 0;
10
+ const owners = route.allowedOwners?.filter(Boolean) ?? [];
11
+ const policy = {
12
+ ...owners.length > 0 && { allowedOwners: owners },
13
+ ...route.requiresRuntimeChallenge === true && { requiresRuntimeChallenge: true }
14
+ };
15
+ return Object.keys(policy).length > 0 ? policy : void 0;
16
+ }
17
+
7
18
  // src/trust-levels.ts
8
19
  var TRUST_LEVEL_RANGES = {
9
20
  BRONZE: { min: 0, max: 39 },
@@ -19,7 +30,7 @@ function getTrustLevel(score) {
19
30
  }
20
31
 
21
32
  // src/version.ts
22
- var SDK_VERSION = "5.15.0";
33
+ var SDK_VERSION = "5.17.0";
23
34
 
24
35
  // src/http.ts
25
36
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -253,6 +264,8 @@ function getCacheKey(request, counterpartyId) {
253
264
  request.durationRequired ?? "",
254
265
  request.invocationProtocol || "",
255
266
  request.enableRuntimeChallenge ? "1" : "0",
267
+ // 5.16.0: route policy changes the verdict (owners / challenge).
268
+ request.routePolicy ? JSON.stringify(request.routePolicy) : "",
256
269
  // callerMetadata fields contribute to risk model; include the ones
257
270
  // backend reads. sourceIp/userAgent/forwardedFor change per-request
258
271
  // so their inclusion effectively forces a re-check for any varying
@@ -465,6 +478,7 @@ async function callVerifyAccessAPI(config, request) {
465
478
  if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
466
479
  if (requestData.enableRuntimeChallenge)
467
480
  body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
481
+ if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
468
482
  if (requestData.createSession) body.createSession = requestData.createSession;
469
483
  if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
470
484
  if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
@@ -1397,7 +1411,7 @@ function detectCommerce(req, host) {
1397
1411
  evidence: { hasTimestamp: Boolean(acpTimestamp), ...truncated }
1398
1412
  };
1399
1413
  }
1400
- if (/\/checkout[-_]sessions(\/|$)/.test(req.uri)) {
1414
+ if (/\/checkout[-_]sessions(\/|$)/.test(req.uri) && headerValue(req, "ucp-agent")) {
1401
1415
  return {
1402
1416
  protocol: "ucp",
1403
1417
  artifacts: { ucpRequest: { method, url, ...jsonBody && { body: jsonBody } } },
@@ -2686,6 +2700,7 @@ function createMiddleware(options) {
2686
2700
  counterpartyUrl,
2687
2701
  counterpartyType: config.counterpartyType || "api",
2688
2702
  enableRuntimeChallenge,
2703
+ ...routePolicyOf(routeConfig) && { routePolicy: routePolicyOf(routeConfig) },
2689
2704
  durationRequired: astraCreds?.pdlss?.duration?.maxSessionDuration,
2690
2705
  ...txValue !== void 0 && { transactionValue: txValue },
2691
2706
  ...txCurrency && { currency: txCurrency },
@@ -3201,6 +3216,7 @@ function createMiddleware2(options) {
3201
3216
  counterpartyUrl,
3202
3217
  counterpartyType: config.counterpartyType || "website",
3203
3218
  enableRuntimeChallenge,
3219
+ ...routePolicyOf(routeConfig) && { routePolicy: routePolicyOf(routeConfig) },
3204
3220
  durationRequired: astraCreds?.pdlss?.duration?.maxSessionDuration,
3205
3221
  ...inboundAttemptId && { attemptId: inboundAttemptId },
3206
3222
  callerMetadata: {
@@ -7060,6 +7076,7 @@ var OwnershipMismatchError = class extends AstraSyncSdkError {
7060
7076
  // src/agent/client.ts
7061
7077
  var AgentClient = class _AgentClient {
7062
7078
  constructor(config) {
7079
+ this.challengeHandler = config.challengeHandler;
7063
7080
  this.credentials = {
7064
7081
  agentId: config.agentId,
7065
7082
  verifyUrl: config.verifyUrl ?? "https://astrasync.ai/api/agents/verify-access",
@@ -7114,7 +7131,7 @@ var AgentClient = class _AgentClient {
7114
7131
  * Make an HTTP request with AstraSync headers automatically injected.
7115
7132
  */
7116
7133
  async fetch(url, options) {
7117
- const { purpose, action, ...fetchOptions } = options ?? {};
7134
+ const { purpose, action, counterpartyId, ...fetchOptions } = options ?? {};
7118
7135
  const creds = { ...this.credentials };
7119
7136
  if (purpose) {
7120
7137
  creds.pdlss = {
@@ -7137,10 +7154,16 @@ var AgentClient = class _AgentClient {
7137
7154
  }
7138
7155
  }
7139
7156
  const enrichedHeaders = setHttpHeaders(existingHeaders, creds);
7140
- return sdkFetch(url, {
7141
- ...fetchOptions,
7142
- headers: enrichedHeaders
7143
- });
7157
+ const pending = this.challengeHandler ? [counterpartyId, new URL(url).origin].filter((v) => Boolean(v)) : [];
7158
+ pending.forEach((p) => this.challengeHandler.registerPending(p));
7159
+ try {
7160
+ return await sdkFetch(url, {
7161
+ ...fetchOptions,
7162
+ headers: enrichedHeaders
7163
+ });
7164
+ } finally {
7165
+ pending.forEach((p) => this.challengeHandler.removePending(p));
7166
+ }
7144
7167
  }
7145
7168
  /**
7146
7169
  * Prepare A2A task metadata with AstraSync credentials.
@@ -7178,26 +7201,32 @@ var AgentClient = class _AgentClient {
7178
7201
  // src/agent/challenge-handler.ts
7179
7202
  var ChallengeHandler = class {
7180
7203
  constructor(config) {
7181
- this.pendingCounterparties = /* @__PURE__ */ new Set();
7204
+ /** Counterparty → in-flight interactions (two concurrent calls to one counterparty both count). */
7205
+ this.pendingCounterparties = /* @__PURE__ */ new Map();
7182
7206
  this.agentId = config.agentId;
7183
7207
  }
7184
7208
  /**
7185
7209
  * Register a counterparty as pending (before initiating contact).
7186
7210
  */
7187
7211
  registerPending(counterpartyId) {
7188
- this.pendingCounterparties.add(counterpartyId);
7212
+ this.pendingCounterparties.set(
7213
+ counterpartyId,
7214
+ (this.pendingCounterparties.get(counterpartyId) ?? 0) + 1
7215
+ );
7189
7216
  }
7190
7217
  /**
7191
7218
  * Remove a counterparty from pending list (after interaction complete).
7192
7219
  */
7193
7220
  removePending(counterpartyId) {
7194
- this.pendingCounterparties.delete(counterpartyId);
7221
+ const n = (this.pendingCounterparties.get(counterpartyId) ?? 0) - 1;
7222
+ if (n > 0) this.pendingCounterparties.set(counterpartyId, n);
7223
+ else this.pendingCounterparties.delete(counterpartyId);
7195
7224
  }
7196
7225
  /**
7197
7226
  * Get current pending counterparties list.
7198
7227
  */
7199
7228
  getPendingList() {
7200
- return [...this.pendingCounterparties];
7229
+ return [...this.pendingCounterparties.keys()];
7201
7230
  }
7202
7231
  /**
7203
7232
  * Express middleware for the challenge endpoint.
@@ -7253,10 +7282,7 @@ var ChallengeHandler = class {
7253
7282
  }
7254
7283
  };
7255
7284
  }
7256
- const explicitList = this.getPendingList();
7257
- const pendingCounterparties = explicitList.length > 0 ? explicitList : [payload.counterpartyId, payload.counterpartyUrl].filter(
7258
- (v) => typeof v === "string" && v.length > 0
7259
- );
7285
+ const pendingCounterparties = this.getPendingList();
7260
7286
  return {
7261
7287
  status: 200,
7262
7288
  body: {
@@ -12783,6 +12809,7 @@ export {
12783
12809
  requestFingerprint,
12784
12810
  rootMandateDigest,
12785
12811
  routePatternToRegExp,
12812
+ routePolicyOf,
12786
12813
  sanitizeHeaders,
12787
12814
  sdk_exports as sdk,
12788
12815
  sdkFetch,