@astrasyncai/verification-gateway 5.16.0 → 5.17.1

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 (94) hide show
  1. package/README.md +94 -18
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +33 -5
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +33 -5
  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 +24 -5
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +24 -5
  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 +24 -5
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +24 -5
  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 +5 -1
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +5 -1
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.js +1 -1
  27. package/dist/agent/index.js.map +1 -1
  28. package/dist/agent/index.mjs +1 -1
  29. package/dist/agent/index.mjs.map +1 -1
  30. package/dist/bin/astrasync-claude-hook.js +5 -1
  31. package/dist/bin/astrasync-codex-hook.js +5 -1
  32. package/dist/bin/astrasync-guard.js +447 -25
  33. package/dist/bin/astrasync.js +470 -28
  34. package/dist/browser/background.js +5 -1
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +5 -1
  37. package/dist/browser/background.mjs.map +1 -1
  38. package/dist/cli/index.js +1 -1
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/cli/index.mjs +1 -1
  41. package/dist/cli/index.mjs.map +1 -1
  42. package/dist/codex/index.js +5 -1
  43. package/dist/codex/index.js.map +1 -1
  44. package/dist/codex/index.mjs +5 -1
  45. package/dist/codex/index.mjs.map +1 -1
  46. package/dist/cursor/extension.js +5 -1
  47. package/dist/cursor/extension.js.map +1 -1
  48. package/dist/cursor/extension.mjs +5 -1
  49. package/dist/cursor/extension.mjs.map +1 -1
  50. package/dist/edge-config.d.mts +1 -1
  51. package/dist/edge-config.d.ts +1 -1
  52. package/dist/edge-config.js +1 -1
  53. package/dist/edge-config.js.map +1 -1
  54. package/dist/edge-config.mjs +1 -1
  55. package/dist/edge-config.mjs.map +1 -1
  56. package/dist/edge-core/index.d.mts +1 -1
  57. package/dist/edge-core/index.d.ts +1 -1
  58. package/dist/edge-core/index.js +5 -1
  59. package/dist/edge-core/index.js.map +1 -1
  60. package/dist/edge-core/index.mjs +5 -1
  61. package/dist/edge-core/index.mjs.map +1 -1
  62. package/dist/gateway/gateway.js +5 -1
  63. package/dist/gateway/gateway.js.map +1 -1
  64. package/dist/gateway/gateway.mjs +5 -1
  65. package/dist/gateway/gateway.mjs.map +1 -1
  66. package/dist/git-trigger/git-hooks.d.mts +1 -1
  67. package/dist/git-trigger/git-hooks.d.ts +1 -1
  68. package/dist/index.d.mts +16 -2
  69. package/dist/index.d.ts +16 -2
  70. package/dist/index.js +33 -5
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +33 -5
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/registration/index.js +1 -1
  75. package/dist/registration/index.js.map +1 -1
  76. package/dist/registration/index.mjs +1 -1
  77. package/dist/registration/index.mjs.map +1 -1
  78. package/dist/transport/index.js +1 -1
  79. package/dist/transport/index.js.map +1 -1
  80. package/dist/transport/index.mjs +1 -1
  81. package/dist/transport/index.mjs.map +1 -1
  82. package/dist/{types-Bm1QvGqI.d.ts → types-DA8LzAOB.d.ts} +6 -0
  83. package/dist/{types-Blz520bR.d.mts → types-DRb_plOh.d.mts} +14 -0
  84. package/dist/{types-Blz520bR.d.ts → types-DRb_plOh.d.ts} +14 -0
  85. package/dist/{types-DBe4hgfT.d.mts → types-vNBvYD7Z.d.mts} +6 -0
  86. package/dist/ui/index.d.mts +1 -1
  87. package/dist/ui/index.d.ts +1 -1
  88. package/dist/verify.d.mts +1 -1
  89. package/dist/verify.d.ts +1 -1
  90. package/dist/verify.js +5 -1
  91. package/dist/verify.js.map +1 -1
  92. package/dist/verify.mjs +5 -1
  93. package/dist/verify.mjs.map +1 -1
  94. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { T as TokenGuidance, b as CounterpartyType } from '../types-DBe4hgfT.mjs';
1
+ import { T as TokenGuidance, b as CounterpartyType } from '../types-vNBvYD7Z.mjs';
2
2
  import '../metadata-capture.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { T as TokenGuidance, b as CounterpartyType } from '../types-Bm1QvGqI.js';
1
+ import { T as TokenGuidance, b as CounterpartyType } from '../types-DA8LzAOB.js';
2
2
  import '../metadata-capture.js';
3
3
 
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -963,6 +963,12 @@ interface VerificationRequest {
963
963
  enableRuntimeChallenge?: boolean;
964
964
  /** 5.16.0: the matched route's policy for verify-access to enforce. */
965
965
  routePolicy?: RoutePolicy;
966
+ /**
967
+ * 5.17.1: the route itself holds a request that needs the owner's approval
968
+ * (see ExpressMiddlewareOptions.approvalHeldByRoute), so verify-access
969
+ * reports the hold but creates no approval of its own.
970
+ */
971
+ approvalHeldByRoute?: boolean;
966
972
  /** Create a verification session (returns sessionId) */
967
973
  createSession?: boolean;
968
974
  /** Counterparty type */
@@ -1281,6 +1287,14 @@ interface ExpressMiddlewareOptions extends GatewayConfig {
1281
1287
  recordDecisions?: boolean;
1282
1288
  /** Ask for a runtime challenge on every verify-access call (default: false — opt-in, round 27.8) */
1283
1289
  enableRuntimeChallenge?: boolean;
1290
+ /**
1291
+ * 5.17.1: return true for requests whose route asks the owner for approval
1292
+ * itself (it creates its own hold and answers 202 while it waits). For those
1293
+ * requests a result that only needs the owner's approval is passed to the
1294
+ * route instead of refused, and verify-access creates no approval, so the
1295
+ * owner approves once. Any deny is still refused. Default: none.
1296
+ */
1297
+ approvalHeldByRoute?: (req: unknown) => boolean;
1284
1298
  /**
1285
1299
  * Refresh interval (ms) for the remote-fetched route policy. Default:
1286
1300
  * 5 minutes. Operators can shorten this to test policy edits faster, or
@@ -5134,7 +5148,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
5134
5148
  * silently (never throwing), so this is a no-op there — which is correct:
5135
5149
  * in a browser the page's real UA is the honest identity.
5136
5150
  */
5137
- declare const SDK_USER_AGENT = "astrasync-sdk/5.16.0";
5151
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.17.1";
5138
5152
  declare const sdkFetch: typeof fetch;
5139
5153
 
5140
5154
  interface LocalPolicy {
@@ -5252,7 +5266,7 @@ declare function parseYaml(yamlContent: string): ParseResult;
5252
5266
  * is fine — bumping both in the release-ceremony commit keeps them
5253
5267
  * lockstep.
5254
5268
  */
5255
- declare const SDK_VERSION = "5.16.0";
5269
+ declare const SDK_VERSION = "5.17.1";
5256
5270
 
5257
5271
  /**
5258
5272
  * 5.15.0 — the `UCP-Agent` request header (UCP 2026-08-25): an RFC 8941
package/dist/index.d.ts CHANGED
@@ -963,6 +963,12 @@ interface VerificationRequest {
963
963
  enableRuntimeChallenge?: boolean;
964
964
  /** 5.16.0: the matched route's policy for verify-access to enforce. */
965
965
  routePolicy?: RoutePolicy;
966
+ /**
967
+ * 5.17.1: the route itself holds a request that needs the owner's approval
968
+ * (see ExpressMiddlewareOptions.approvalHeldByRoute), so verify-access
969
+ * reports the hold but creates no approval of its own.
970
+ */
971
+ approvalHeldByRoute?: boolean;
966
972
  /** Create a verification session (returns sessionId) */
967
973
  createSession?: boolean;
968
974
  /** Counterparty type */
@@ -1281,6 +1287,14 @@ interface ExpressMiddlewareOptions extends GatewayConfig {
1281
1287
  recordDecisions?: boolean;
1282
1288
  /** Ask for a runtime challenge on every verify-access call (default: false — opt-in, round 27.8) */
1283
1289
  enableRuntimeChallenge?: boolean;
1290
+ /**
1291
+ * 5.17.1: return true for requests whose route asks the owner for approval
1292
+ * itself (it creates its own hold and answers 202 while it waits). For those
1293
+ * requests a result that only needs the owner's approval is passed to the
1294
+ * route instead of refused, and verify-access creates no approval, so the
1295
+ * owner approves once. Any deny is still refused. Default: none.
1296
+ */
1297
+ approvalHeldByRoute?: (req: unknown) => boolean;
1284
1298
  /**
1285
1299
  * Refresh interval (ms) for the remote-fetched route policy. Default:
1286
1300
  * 5 minutes. Operators can shorten this to test policy edits faster, or
@@ -5134,7 +5148,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
5134
5148
  * silently (never throwing), so this is a no-op there — which is correct:
5135
5149
  * in a browser the page's real UA is the honest identity.
5136
5150
  */
5137
- declare const SDK_USER_AGENT = "astrasync-sdk/5.16.0";
5151
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.17.1";
5138
5152
  declare const sdkFetch: typeof fetch;
5139
5153
 
5140
5154
  interface LocalPolicy {
@@ -5252,7 +5266,7 @@ declare function parseYaml(yamlContent: string): ParseResult;
5252
5266
  * is fine — bumping both in the release-ceremony commit keeps them
5253
5267
  * lockstep.
5254
5268
  */
5255
- declare const SDK_VERSION = "5.16.0";
5269
+ declare const SDK_VERSION = "5.17.1";
5256
5270
 
5257
5271
  /**
5258
5272
  * 5.15.0 — the `UCP-Agent` request header (UCP 2026-08-25): an RFC 8941
package/dist/index.js CHANGED
@@ -205,7 +205,7 @@ function getTrustLevel(score) {
205
205
  }
206
206
 
207
207
  // src/version.ts
208
- var SDK_VERSION = "5.16.0";
208
+ var SDK_VERSION = "5.17.1";
209
209
 
210
210
  // src/http.ts
211
211
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -441,6 +441,7 @@ function getCacheKey(request, counterpartyId) {
441
441
  request.enableRuntimeChallenge ? "1" : "0",
442
442
  // 5.16.0: route policy changes the verdict (owners / challenge).
443
443
  request.routePolicy ? JSON.stringify(request.routePolicy) : "",
444
+ request.approvalHeldByRoute ? "1" : "0",
444
445
  // callerMetadata fields contribute to risk model; include the ones
445
446
  // backend reads. sourceIp/userAgent/forwardedFor change per-request
446
447
  // so their inclusion effectively forces a re-check for any varying
@@ -654,6 +655,7 @@ async function callVerifyAccessAPI(config, request) {
654
655
  if (requestData.enableRuntimeChallenge)
655
656
  body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
656
657
  if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
658
+ if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
657
659
  if (requestData.createSession) body.createSession = requestData.createSession;
658
660
  if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
659
661
  if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
@@ -985,6 +987,8 @@ async function verify(config, request, options) {
985
987
  } else if (result.recommendation === "step_up_required" && result.identityVerified) {
986
988
  result.requiresStepUp = true;
987
989
  result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Step-up verification required"];
990
+ const stepUpFailures = apiResponse.access?.failures;
991
+ if (stepUpFailures?.length) result.failures = stepUpFailures;
988
992
  }
989
993
  const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
990
994
  if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
@@ -1184,12 +1188,31 @@ function requiresHumanApproval(result) {
1184
1188
  return result.requiresStepUp === true || result.requiresApproval === true;
1185
1189
  }
1186
1190
  function annotateApprovalRequired(result) {
1187
- result.failures = [
1188
- ...result.failures ?? [],
1189
- { dimension: "commerce.intent.approval_required", message: APPROVAL_REASON }
1190
- ];
1191
+ if (isDimensionApproval(result)) {
1192
+ result.denialReasons = [DIMENSION_APPROVAL_REASON, ...result.denialReasons ?? []];
1193
+ return;
1194
+ }
1195
+ const named = (result.failures ?? []).some(
1196
+ (f) => f.dimension === "commerce.intent.approval_required"
1197
+ );
1198
+ if (!named) {
1199
+ result.failures = [
1200
+ ...result.failures ?? [],
1201
+ { dimension: "commerce.intent.approval_required", message: APPROVAL_REASON }
1202
+ ];
1203
+ }
1191
1204
  result.denialReasons = [APPROVAL_REASON, ...result.denialReasons ?? []];
1192
1205
  }
1206
+ var DIMENSION_APPROVAL_REASON = "The agent's owner asked to approve this kind of request. The owner can approve or deny it in the AstraSync dashboard.";
1207
+ var DIMENSION_APPROVAL = /^pdlss\.[a-z_]+\.approval_required$/;
1208
+ function isDimensionApproval(result) {
1209
+ const f = result.failures ?? [];
1210
+ return f.some((x) => DIMENSION_APPROVAL.test(x.dimension)) && !f.some((x) => x.dimension === "commerce.intent.approval_required");
1211
+ }
1212
+ function onlyNeedsApproval(result) {
1213
+ if (!result.policyAllowed || !requiresHumanApproval(result)) return false;
1214
+ return (result.failures ?? []).every((f) => /\.approval_required$/.test(f.dimension));
1215
+ }
1193
1216
 
1194
1217
  // src/settlement.ts
1195
1218
  async function authorizeSettlement(config, req) {
@@ -2865,6 +2888,7 @@ function createMiddleware(options) {
2865
2888
  const attemptHeader = req.headers["x-astra-attempt-id"];
2866
2889
  const inboundAttemptId = typeof attemptHeader === "string" && /^att_[0-9a-f]{32}$/.test(attemptHeader) ? attemptHeader : void 0;
2867
2890
  const commerceArtifacts = detectExpressCommerce(req);
2891
+ const heldByRoute = options.approvalHeldByRoute?.(req) === true;
2868
2892
  const verificationRequest = {
2869
2893
  credentials,
2870
2894
  ...commerceArtifacts && { commerceArtifacts },
@@ -2876,6 +2900,7 @@ function createMiddleware(options) {
2876
2900
  counterpartyType: config.counterpartyType || "api",
2877
2901
  enableRuntimeChallenge,
2878
2902
  ...routePolicyOf(routeConfig) && { routePolicy: routePolicyOf(routeConfig) },
2903
+ ...heldByRoute && { approvalHeldByRoute: true },
2879
2904
  durationRequired: astraCreds?.pdlss?.duration?.maxSessionDuration,
2880
2905
  ...txValue !== void 0 && { transactionValue: txValue },
2881
2906
  ...txCurrency && { currency: txCurrency },
@@ -2932,6 +2957,9 @@ function createMiddleware(options) {
2932
2957
  onDenied(result, req, res);
2933
2958
  return;
2934
2959
  }
2960
+ if (heldByRoute && !result.stepUpApproval && onlyNeedsApproval(result)) {
2961
+ return next();
2962
+ }
2935
2963
  if (requiresHumanApproval(result)) {
2936
2964
  annotateApprovalRequired(result);
2937
2965
  if (shouldRecordDecisions && sessionId) {