@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
@@ -4006,7 +4006,7 @@ function getTrustLevel(score) {
4006
4006
  }
4007
4007
 
4008
4008
  // src/version.ts
4009
- var SDK_VERSION = "5.13.0";
4009
+ var SDK_VERSION = "5.15.0";
4010
4010
 
4011
4011
  // src/http.ts
4012
4012
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4325,6 +4325,7 @@ async function callVerifyAccessAPI(config, request) {
4325
4325
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4326
4326
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
4327
4327
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
4328
+ if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
4328
4329
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
4329
4330
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
4330
4331
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
@@ -4475,7 +4476,8 @@ async function verify(config, request, options) {
4475
4476
  "[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."
4476
4477
  );
4477
4478
  }
4478
- if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
4479
+ const uncacheable = Boolean(request.commerceArtifacts);
4480
+ if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
4479
4481
  const cached = getCachedResult(request, mergedConfig.counterpartyId);
4480
4482
  if (cached) {
4481
4483
  if (mergedConfig.debug) {
@@ -4556,7 +4558,10 @@ async function verify(config, request, options) {
4556
4558
  // MERCHANT caller only (bridge callers strip it before the agent plane).
4557
4559
  settlementToken: apiResponse.settlementToken,
4558
4560
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
4559
- fulfilment: apiResponse.fulfilment
4561
+ fulfilment: apiResponse.fulfilment,
4562
+ mandates: apiResponse.mandates,
4563
+ kyaToken: apiResponse.kyaToken,
4564
+ aep: apiResponse.aep
4560
4565
  };
4561
4566
  return result2;
4562
4567
  }
@@ -4566,7 +4571,10 @@ async function verify(config, request, options) {
4566
4571
  trustScore: apiResponse.agent.trustScore,
4567
4572
  trustLevel: getTrustLevel(apiResponse.agent.trustScore),
4568
4573
  blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
4569
- status: apiResponse.agent.agentStatus
4574
+ status: apiResponse.agent.agentStatus,
4575
+ ...apiResponse.agent.protocolIdentities && {
4576
+ protocolIdentities: apiResponse.agent.protocolIdentities
4577
+ }
4570
4578
  } : void 0;
4571
4579
  const developer = apiResponse.developer ? {
4572
4580
  astradId: apiResponse.developer.kyaOwnerId,
@@ -4617,7 +4625,11 @@ async function verify(config, request, options) {
4617
4625
  settlementOutcome: apiResponse.settlementOutcome,
4618
4626
  settlementToken: apiResponse.settlementToken,
4619
4627
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
4620
- fulfilment: apiResponse.fulfilment
4628
+ fulfilment: apiResponse.fulfilment,
4629
+ // 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
4630
+ mandates: apiResponse.mandates,
4631
+ kyaToken: apiResponse.kyaToken,
4632
+ aep: apiResponse.aep
4621
4633
  };
4622
4634
  if (result.recommendation === "deny") {
4623
4635
  result.policyAllowed = false;
@@ -4637,7 +4649,9 @@ async function verify(config, request, options) {
4637
4649
  }
4638
4650
  const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
4639
4651
  if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
4640
- cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
4652
+ if (!uncacheable) {
4653
+ cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
4654
+ }
4641
4655
  }
4642
4656
  return result;
4643
4657
  }
@@ -4648,6 +4662,9 @@ var FALLBACK_MAX_WAIT_MS = 5 * 60 * 1e3;
4648
4662
  // src/metadata-capture.ts
4649
4663
  var MAX_TOTAL_BYTES = 16 * 1024;
4650
4664
 
4665
+ // src/adapters/commerce-detect.ts
4666
+ var MAX_BODY_BYTES = 64 * 1024;
4667
+
4651
4668
  // src/edge-config.ts
4652
4669
  var DEFAULT_EDGE_CONFIG = Object.freeze({
4653
4670
  version: 1,
@@ -4676,6 +4693,11 @@ async function withBudget(promise, ms) {
4676
4693
  if (timer) clearTimeout(timer);
4677
4694
  }
4678
4695
  }
4696
+ var CONTAINER_ID = (() => {
4697
+ const c = globalThis.crypto;
4698
+ if (c?.randomUUID) return c.randomUUID();
4699
+ return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
4700
+ })();
4679
4701
  var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
4680
4702
  var BeaconBuffer = class {
4681
4703
  constructor(options = {}) {
@@ -4683,6 +4705,7 @@ var BeaconBuffer = class {
4683
4705
  this.droppedSinceLast = 0;
4684
4706
  this.droppedTotal = 0;
4685
4707
  this.deliveredTotal = 0;
4708
+ this.enqueuedTotal = 0;
4686
4709
  this.backoffUntil = 0;
4687
4710
  this.collapse = /* @__PURE__ */ new Map();
4688
4711
  /** Keys the backend answered 401 for — later batches go unauthenticated. */
@@ -4695,13 +4718,16 @@ var BeaconBuffer = class {
4695
4718
  collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
4696
4719
  requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
4697
4720
  retryBackoffMs: options.retryBackoffMs ?? 1e3,
4721
+ holdRepeats: options.holdRepeats ?? false,
4722
+ containerId: options.containerId ?? CONTAINER_ID,
4698
4723
  now: options.now ?? Date.now
4699
4724
  };
4700
4725
  }
4701
4726
  /**
4702
4727
  * Queue one beacon. With a `collapseKey`, a repeat inside the window is
4703
- * merged into a held aggregate (sent when the window closes) instead of
4704
- * becoming its own item.
4728
+ * merged into this key's item while that item is still queued (not yet in
4729
+ * flight). Once it has left, the repeat becomes a new item, sendable on
4730
+ * this flush — nothing waits for a later invocation (round 27.6).
4705
4731
  */
4706
4732
  enqueue(dest, item, collapseKey) {
4707
4733
  const now = this.opts.now();
@@ -4714,12 +4740,15 @@ var BeaconBuffer = class {
4714
4740
  return;
4715
4741
  }
4716
4742
  }
4717
- const held = this.push(
4718
- dest,
4719
- { ...item, repeatCount: 1 },
4720
- entry.firstSeenAt + this.opts.collapseWindowMs
4721
- );
4722
- entry.held = held;
4743
+ if (this.opts.holdRepeats) {
4744
+ entry.held = this.push(
4745
+ dest,
4746
+ { ...item, repeatCount: 1 },
4747
+ entry.firstSeenAt + this.opts.collapseWindowMs
4748
+ );
4749
+ return;
4750
+ }
4751
+ entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
4723
4752
  return;
4724
4753
  }
4725
4754
  this.collapse.delete(collapseKey);
@@ -4755,6 +4784,7 @@ var BeaconBuffer = class {
4755
4784
  droppedSinceLast: this.droppedSinceLast,
4756
4785
  droppedTotal: this.droppedTotal,
4757
4786
  deliveredTotal: this.deliveredTotal,
4787
+ enqueuedTotal: this.enqueuedTotal,
4758
4788
  flushing: this.inFlight !== void 0
4759
4789
  };
4760
4790
  }
@@ -4769,6 +4799,7 @@ var BeaconBuffer = class {
4769
4799
  inFlight: false
4770
4800
  };
4771
4801
  this.queue.push(entry);
4802
+ this.enqueuedTotal += 1;
4772
4803
  return entry;
4773
4804
  }
4774
4805
  dropOldest() {
@@ -4814,7 +4845,11 @@ var BeaconBuffer = class {
4814
4845
  droppedSinceLast: reportedDropped,
4815
4846
  queueDepth: this.queue.length,
4816
4847
  adapter: dest.adapter ?? "edge-core",
4817
- version: SDK_VERSION
4848
+ version: SDK_VERSION,
4849
+ containerId: this.opts.containerId,
4850
+ enqueuedTotal: this.enqueuedTotal,
4851
+ deliveredTotal: this.deliveredTotal,
4852
+ droppedTotal: this.droppedTotal
4818
4853
  };
4819
4854
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
4820
4855
  const response = await withBudget(
@@ -4942,6 +4977,43 @@ import { createHash as createHash3, webcrypto } from "crypto";
4942
4977
  // src/transport/registry/visa.ts
4943
4978
  import { createRemoteJWKSet } from "jose";
4944
4979
 
4980
+ // src/ucp/profile.ts
4981
+ var UCP_VERSION = "2026-08-25";
4982
+ var SPEC = `https://ucp.dev/${UCP_VERSION}/specification`;
4983
+ var SCHEMAS = `https://ucp.dev/${UCP_VERSION}/schemas`;
4984
+
4985
+ // src/ucp/signatures.ts
4986
+ import { httpbis as httpbis3, createSigner as createSigner2 } from "http-message-signatures";
4987
+
4988
+ // src/http-signatures/sign.ts
4989
+ import { httpbis as httpbis2, createSigner } from "http-message-signatures";
4990
+
4991
+ // src/ucp/checkout-kit.ts
4992
+ import { CompactSign as CompactSign2 } from "jose";
4993
+
4994
+ // src/mandates/sd-jwt.ts
4995
+ import {
4996
+ CompactSign,
4997
+ compactVerify,
4998
+ importJWK,
4999
+ decodeProtectedHeader
5000
+ } from "jose";
5001
+
5002
+ // src/idempotency/index.ts
5003
+ var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
5004
+
5005
+ // src/payments/kyapay.ts
5006
+ import {
5007
+ createLocalJWKSet,
5008
+ createRemoteJWKSet as createRemoteJWKSet2,
5009
+ decodeProtectedHeader as decodeProtectedHeader2,
5010
+ jwtVerify
5011
+ } from "jose";
5012
+
5013
+ // src/aep/core.ts
5014
+ var ED25519_PKCS8_PREFIX = Buffer.from("302e020100300506032b657004220420", "hex");
5015
+ var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
5016
+
4945
5017
  // src/gateway/modes/online.ts
4946
5018
  function toGatewayConfig(config) {
4947
5019
  return {
@@ -5679,7 +5751,7 @@ async function sendHeartbeat(enrolment, request, timeoutMs = 1500) {
5679
5751
 
5680
5752
  // src/fleet/policy-verify.ts
5681
5753
  import { createHash as createHash4 } from "crypto";
5682
- import { compactVerify, createLocalJWKSet } from "jose";
5754
+ import { compactVerify as compactVerify2, createLocalJWKSet as createLocalJWKSet2 } from "jose";
5683
5755
 
5684
5756
  // src/fleet/types.ts
5685
5757
  var FLEET_POLICY_TYP = "fleet-policy+jwt";
@@ -5728,8 +5800,8 @@ async function verifyFleetPolicy(jws, jwks, options) {
5728
5800
  let payloadBytes;
5729
5801
  let header;
5730
5802
  try {
5731
- const keySet = createLocalJWKSet(jwks);
5732
- const result = await compactVerify(jws, keySet, { algorithms: ["ES256"] });
5803
+ const keySet = createLocalJWKSet2(jwks);
5804
+ const result = await compactVerify2(jws, keySet, { algorithms: ["ES256"] });
5733
5805
  payloadBytes = result.payload;
5734
5806
  header = result.protectedHeader;
5735
5807
  } catch (err) {
@@ -5775,9 +5847,9 @@ async function resolveFleetJwks(pinned, chain, ownerId) {
5775
5847
  let lastSeq = 0;
5776
5848
  for (const link of chain) {
5777
5849
  try {
5778
- const { payload, protectedHeader } = await compactVerify(
5850
+ const { payload, protectedHeader } = await compactVerify2(
5779
5851
  link,
5780
- createLocalJWKSet(trusted),
5852
+ createLocalJWKSet2(trusted),
5781
5853
  { algorithms: ["ES256"] }
5782
5854
  );
5783
5855
  if (protectedHeader.typ !== FLEET_KEYS_TYP) continue;