@astrasyncai/verification-gateway 5.13.0 → 5.15.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 (98) hide show
  1. package/README.md +27 -17
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +504 -249
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +504 -249
  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 +20 -6
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +20 -6
  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 +487 -248
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +487 -248
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +18 -10
  21. package/dist/adapters/sdk.d.ts +18 -10
  22. package/dist/adapters/sdk.js +80 -23
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +80 -23
  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 +82 -20
  31. package/dist/bin/astrasync-codex-hook.js +82 -20
  32. package/dist/bin/astrasync-guard.js +82 -20
  33. package/dist/bin/astrasync.js +316 -43
  34. package/dist/browser/background.js +77 -15
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +87 -15
  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 +82 -20
  43. package/dist/codex/index.js.map +1 -1
  44. package/dist/codex/index.mjs +92 -20
  45. package/dist/codex/index.mjs.map +1 -1
  46. package/dist/cursor/extension.js +82 -20
  47. package/dist/cursor/extension.js.map +1 -1
  48. package/dist/cursor/extension.mjs +92 -20
  49. package/dist/cursor/extension.mjs.map +1 -1
  50. package/dist/edge-config.d.mts +31 -2
  51. package/dist/edge-config.d.ts +31 -2
  52. package/dist/edge-config.js +35 -5
  53. package/dist/edge-config.js.map +1 -1
  54. package/dist/edge-config.mjs +32 -4
  55. package/dist/edge-config.mjs.map +1 -1
  56. package/dist/edge-core/index.d.mts +43 -6
  57. package/dist/edge-core/index.d.ts +43 -6
  58. package/dist/edge-core/index.js +120 -19
  59. package/dist/edge-core/index.js.map +1 -1
  60. package/dist/edge-core/index.mjs +118 -19
  61. package/dist/edge-core/index.mjs.map +1 -1
  62. package/dist/gateway/gateway.js +77 -15
  63. package/dist/gateway/gateway.js.map +1 -1
  64. package/dist/gateway/gateway.mjs +87 -15
  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 +1314 -34
  69. package/dist/index.d.ts +1314 -34
  70. package/dist/index.js +5143 -2621
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +5090 -2623
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/registration/index.d.mts +28 -2
  75. package/dist/registration/index.d.ts +28 -2
  76. package/dist/registration/index.js +18 -3
  77. package/dist/registration/index.js.map +1 -1
  78. package/dist/registration/index.mjs +15 -2
  79. package/dist/registration/index.mjs.map +1 -1
  80. package/dist/transport/index.d.mts +7 -5
  81. package/dist/transport/index.d.ts +7 -5
  82. package/dist/transport/index.js +61 -5
  83. package/dist/transport/index.js.map +1 -1
  84. package/dist/transport/index.mjs +67 -11
  85. package/dist/transport/index.mjs.map +1 -1
  86. package/dist/{types-C_b4QTyO.d.ts → types-DtJjlW4O.d.ts} +104 -10
  87. package/dist/{types-BCkwBA84.d.mts → types-Dxf9DBpr.d.mts} +106 -12
  88. package/dist/{types-BCkwBA84.d.ts → types-Dxf9DBpr.d.ts} +106 -12
  89. package/dist/{types-DlshIIR-.d.mts → types-Eg6VoBNH.d.mts} +104 -10
  90. package/dist/ui/index.d.mts +1 -1
  91. package/dist/ui/index.d.ts +1 -1
  92. package/dist/verify.d.mts +1 -1
  93. package/dist/verify.d.ts +1 -1
  94. package/dist/verify.js +20 -6
  95. package/dist/verify.js.map +1 -1
  96. package/dist/verify.mjs +20 -6
  97. package/dist/verify.mjs.map +1 -1
  98. package/package.json +1 -1
@@ -3969,7 +3969,7 @@ function getTrustLevel(score) {
3969
3969
  }
3970
3970
 
3971
3971
  // src/version.ts
3972
- var SDK_VERSION = "5.13.0";
3972
+ var SDK_VERSION = "5.15.0";
3973
3973
 
3974
3974
  // src/http.ts
3975
3975
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4288,6 +4288,7 @@ async function callVerifyAccessAPI(config, request) {
4288
4288
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4289
4289
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
4290
4290
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
4291
+ if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
4291
4292
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
4292
4293
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
4293
4294
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
@@ -4438,7 +4439,8 @@ async function verify(config, request, options) {
4438
4439
  "[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access decisions (verified ID + runtime challenge + PDLSS + trust score). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
4439
4440
  );
4440
4441
  }
4441
- if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
4442
+ const uncacheable = Boolean(request.commerceArtifacts);
4443
+ if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
4442
4444
  const cached = getCachedResult(request, mergedConfig.counterpartyId);
4443
4445
  if (cached) {
4444
4446
  if (mergedConfig.debug) {
@@ -4519,7 +4521,10 @@ async function verify(config, request, options) {
4519
4521
  // MERCHANT caller only (bridge callers strip it before the agent plane).
4520
4522
  settlementToken: apiResponse.settlementToken,
4521
4523
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
4522
- fulfilment: apiResponse.fulfilment
4524
+ fulfilment: apiResponse.fulfilment,
4525
+ mandates: apiResponse.mandates,
4526
+ kyaToken: apiResponse.kyaToken,
4527
+ aep: apiResponse.aep
4523
4528
  };
4524
4529
  return result2;
4525
4530
  }
@@ -4529,7 +4534,10 @@ async function verify(config, request, options) {
4529
4534
  trustScore: apiResponse.agent.trustScore,
4530
4535
  trustLevel: getTrustLevel(apiResponse.agent.trustScore),
4531
4536
  blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
4532
- status: apiResponse.agent.agentStatus
4537
+ status: apiResponse.agent.agentStatus,
4538
+ ...apiResponse.agent.protocolIdentities && {
4539
+ protocolIdentities: apiResponse.agent.protocolIdentities
4540
+ }
4533
4541
  } : void 0;
4534
4542
  const developer = apiResponse.developer ? {
4535
4543
  astradId: apiResponse.developer.kyaOwnerId,
@@ -4580,7 +4588,11 @@ async function verify(config, request, options) {
4580
4588
  settlementOutcome: apiResponse.settlementOutcome,
4581
4589
  settlementToken: apiResponse.settlementToken,
4582
4590
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
4583
- fulfilment: apiResponse.fulfilment
4591
+ fulfilment: apiResponse.fulfilment,
4592
+ // 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
4593
+ mandates: apiResponse.mandates,
4594
+ kyaToken: apiResponse.kyaToken,
4595
+ aep: apiResponse.aep
4584
4596
  };
4585
4597
  if (result.recommendation === "deny") {
4586
4598
  result.policyAllowed = false;
@@ -4600,7 +4612,9 @@ async function verify(config, request, options) {
4600
4612
  }
4601
4613
  const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
4602
4614
  if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
4603
- cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
4615
+ if (!uncacheable) {
4616
+ cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
4617
+ }
4604
4618
  }
4605
4619
  return result;
4606
4620
  }
@@ -4611,6 +4625,9 @@ var FALLBACK_MAX_WAIT_MS = 5 * 60 * 1e3;
4611
4625
  // src/metadata-capture.ts
4612
4626
  var MAX_TOTAL_BYTES = 16 * 1024;
4613
4627
 
4628
+ // src/adapters/commerce-detect.ts
4629
+ var MAX_BODY_BYTES = 64 * 1024;
4630
+
4614
4631
  // src/edge-config.ts
4615
4632
  var DEFAULT_EDGE_CONFIG = Object.freeze({
4616
4633
  version: 1,
@@ -4639,6 +4656,11 @@ async function withBudget(promise, ms) {
4639
4656
  if (timer) clearTimeout(timer);
4640
4657
  }
4641
4658
  }
4659
+ var CONTAINER_ID = (() => {
4660
+ const c = globalThis.crypto;
4661
+ if (c?.randomUUID) return c.randomUUID();
4662
+ return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
4663
+ })();
4642
4664
  var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
4643
4665
  var BeaconBuffer = class {
4644
4666
  constructor(options = {}) {
@@ -4646,6 +4668,7 @@ var BeaconBuffer = class {
4646
4668
  this.droppedSinceLast = 0;
4647
4669
  this.droppedTotal = 0;
4648
4670
  this.deliveredTotal = 0;
4671
+ this.enqueuedTotal = 0;
4649
4672
  this.backoffUntil = 0;
4650
4673
  this.collapse = /* @__PURE__ */ new Map();
4651
4674
  /** Keys the backend answered 401 for — later batches go unauthenticated. */
@@ -4658,13 +4681,16 @@ var BeaconBuffer = class {
4658
4681
  collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
4659
4682
  requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
4660
4683
  retryBackoffMs: options.retryBackoffMs ?? 1e3,
4684
+ holdRepeats: options.holdRepeats ?? false,
4685
+ containerId: options.containerId ?? CONTAINER_ID,
4661
4686
  now: options.now ?? Date.now
4662
4687
  };
4663
4688
  }
4664
4689
  /**
4665
4690
  * Queue one beacon. With a `collapseKey`, a repeat inside the window is
4666
- * merged into a held aggregate (sent when the window closes) instead of
4667
- * becoming its own item.
4691
+ * merged into this key's item while that item is still queued (not yet in
4692
+ * flight). Once it has left, the repeat becomes a new item, sendable on
4693
+ * this flush — nothing waits for a later invocation (round 27.6).
4668
4694
  */
4669
4695
  enqueue(dest, item, collapseKey) {
4670
4696
  const now = this.opts.now();
@@ -4677,12 +4703,15 @@ var BeaconBuffer = class {
4677
4703
  return;
4678
4704
  }
4679
4705
  }
4680
- const held = this.push(
4681
- dest,
4682
- { ...item, repeatCount: 1 },
4683
- entry.firstSeenAt + this.opts.collapseWindowMs
4684
- );
4685
- entry.held = held;
4706
+ if (this.opts.holdRepeats) {
4707
+ entry.held = this.push(
4708
+ dest,
4709
+ { ...item, repeatCount: 1 },
4710
+ entry.firstSeenAt + this.opts.collapseWindowMs
4711
+ );
4712
+ return;
4713
+ }
4714
+ entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
4686
4715
  return;
4687
4716
  }
4688
4717
  this.collapse.delete(collapseKey);
@@ -4718,6 +4747,7 @@ var BeaconBuffer = class {
4718
4747
  droppedSinceLast: this.droppedSinceLast,
4719
4748
  droppedTotal: this.droppedTotal,
4720
4749
  deliveredTotal: this.deliveredTotal,
4750
+ enqueuedTotal: this.enqueuedTotal,
4721
4751
  flushing: this.inFlight !== void 0
4722
4752
  };
4723
4753
  }
@@ -4732,6 +4762,7 @@ var BeaconBuffer = class {
4732
4762
  inFlight: false
4733
4763
  };
4734
4764
  this.queue.push(entry);
4765
+ this.enqueuedTotal += 1;
4735
4766
  return entry;
4736
4767
  }
4737
4768
  dropOldest() {
@@ -4777,7 +4808,11 @@ var BeaconBuffer = class {
4777
4808
  droppedSinceLast: reportedDropped,
4778
4809
  queueDepth: this.queue.length,
4779
4810
  adapter: dest.adapter ?? "edge-core",
4780
- version: SDK_VERSION
4811
+ version: SDK_VERSION,
4812
+ containerId: this.opts.containerId,
4813
+ enqueuedTotal: this.enqueuedTotal,
4814
+ deliveredTotal: this.deliveredTotal,
4815
+ droppedTotal: this.droppedTotal
4781
4816
  };
4782
4817
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
4783
4818
  const response = await withBudget(
@@ -4905,6 +4940,43 @@ import { createHash as createHash3, webcrypto } from "crypto";
4905
4940
  // src/transport/registry/visa.ts
4906
4941
  import { createRemoteJWKSet } from "jose";
4907
4942
 
4943
+ // src/ucp/profile.ts
4944
+ var UCP_VERSION = "2026-08-25";
4945
+ var SPEC = `https://ucp.dev/${UCP_VERSION}/specification`;
4946
+ var SCHEMAS = `https://ucp.dev/${UCP_VERSION}/schemas`;
4947
+
4948
+ // src/ucp/signatures.ts
4949
+ import { httpbis as httpbis3, createSigner as createSigner2 } from "http-message-signatures";
4950
+
4951
+ // src/http-signatures/sign.ts
4952
+ import { httpbis as httpbis2, createSigner } from "http-message-signatures";
4953
+
4954
+ // src/ucp/checkout-kit.ts
4955
+ import { CompactSign as CompactSign2 } from "jose";
4956
+
4957
+ // src/mandates/sd-jwt.ts
4958
+ import {
4959
+ CompactSign,
4960
+ compactVerify,
4961
+ importJWK,
4962
+ decodeProtectedHeader
4963
+ } from "jose";
4964
+
4965
+ // src/idempotency/index.ts
4966
+ var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
4967
+
4968
+ // src/payments/kyapay.ts
4969
+ import {
4970
+ createLocalJWKSet,
4971
+ createRemoteJWKSet as createRemoteJWKSet2,
4972
+ decodeProtectedHeader as decodeProtectedHeader2,
4973
+ jwtVerify
4974
+ } from "jose";
4975
+
4976
+ // src/aep/core.ts
4977
+ var ED25519_PKCS8_PREFIX = Buffer.from("302e020100300506032b657004220420", "hex");
4978
+ var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
4979
+
4908
4980
  // src/gateway/modes/online.ts
4909
4981
  function toGatewayConfig(config) {
4910
4982
  return {
@@ -5616,7 +5688,7 @@ async function sendHeartbeat(enrolment, request, timeoutMs = 1500) {
5616
5688
 
5617
5689
  // src/fleet/policy-verify.ts
5618
5690
  import { createHash as createHash4 } from "crypto";
5619
- import { compactVerify, createLocalJWKSet } from "jose";
5691
+ import { compactVerify as compactVerify2, createLocalJWKSet as createLocalJWKSet2 } from "jose";
5620
5692
 
5621
5693
  // src/fleet/types.ts
5622
5694
  var FLEET_POLICY_TYP = "fleet-policy+jwt";
@@ -5665,8 +5737,8 @@ async function verifyFleetPolicy(jws, jwks, options) {
5665
5737
  let payloadBytes;
5666
5738
  let header;
5667
5739
  try {
5668
- const keySet = createLocalJWKSet(jwks);
5669
- const result = await compactVerify(jws, keySet, { algorithms: ["ES256"] });
5740
+ const keySet = createLocalJWKSet2(jwks);
5741
+ const result = await compactVerify2(jws, keySet, { algorithms: ["ES256"] });
5670
5742
  payloadBytes = result.payload;
5671
5743
  header = result.protectedHeader;
5672
5744
  } catch (err) {
@@ -5712,9 +5784,9 @@ async function resolveFleetJwks(pinned, chain, ownerId) {
5712
5784
  let lastSeq = 0;
5713
5785
  for (const link of chain) {
5714
5786
  try {
5715
- const { payload, protectedHeader } = await compactVerify(
5787
+ const { payload, protectedHeader } = await compactVerify2(
5716
5788
  link,
5717
- createLocalJWKSet(trusted),
5789
+ createLocalJWKSet2(trusted),
5718
5790
  { algorithms: ["ES256"] }
5719
5791
  );
5720
5792
  if (protectedHeader.typ !== FLEET_KEYS_TYP) continue;