@dexterai/x402 1.9.0 → 1.9.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.
@@ -37,6 +37,7 @@ __export(server_exports, {
37
37
  MODEL_PRICING_MAP: () => MODEL_PRICING_MAP,
38
38
  MODEL_REGISTRY: () => MODEL_REGISTRY,
39
39
  SOLANA_MAINNET_NETWORK: () => SOLANA_MAINNET_NETWORK,
40
+ SPONSORED_ACCESS_EXTENSION_KEY: () => import_x402_ads_types.SPONSORED_ACCESS_EXTENSION_KEY,
40
41
  USDC_BASE: () => USDC_BASE,
41
42
  USDC_MINT: () => USDC_MINT,
42
43
  countTokens: () => countTokens,
@@ -577,9 +578,19 @@ function x402Middleware(config) {
577
578
  res.setHeader("PAYMENT-RESPONSE", encodeBase64Json(paymentResponseData));
578
579
  if (config.sponsoredAccess && settleResult.extensions?.["sponsored-access"]) {
579
580
  const extData = settleResult.extensions["sponsored-access"];
580
- const recs = extData?.info?.recommendations;
581
+ const recs = extData?.info?.recommendations ?? extData?.recommendations;
581
582
  if (recs && recs.length > 0) {
582
583
  log("Injecting sponsored-access recommendations into response");
584
+ if (typeof config.sponsoredAccess === "object" && config.sponsoredAccess.onMatch) {
585
+ try {
586
+ config.sponsoredAccess.onMatch(recs, {
587
+ transaction: settleResult.transaction,
588
+ network: settledNetwork,
589
+ payer: verifyResult.payer ?? ""
590
+ });
591
+ } catch {
592
+ }
593
+ }
583
594
  const originalJson = res.json.bind(res);
584
595
  res.json = function patchedJson(body) {
585
596
  if (typeof config.sponsoredAccess === "object" && config.sponsoredAccess.inject) {
@@ -2070,6 +2081,9 @@ function stripePayTo(secretKeyOrConfig) {
2070
2081
  provider._stripeNetwork = caip2Network;
2071
2082
  return provider;
2072
2083
  }
2084
+
2085
+ // src/server/index.ts
2086
+ var import_x402_ads_types = require("@dexterai/x402-ads-types");
2073
2087
  // Annotate the CommonJS export names for ESM import in node:
2074
2088
  0 && (module.exports = {
2075
2089
  BASE_MAINNET_NETWORK,
@@ -2079,6 +2093,7 @@ function stripePayTo(secretKeyOrConfig) {
2079
2093
  MODEL_PRICING_MAP,
2080
2094
  MODEL_REGISTRY,
2081
2095
  SOLANA_MAINNET_NETWORK,
2096
+ SPONSORED_ACCESS_EXTENSION_KEY,
2082
2097
  USDC_BASE,
2083
2098
  USDC_MINT,
2084
2099
  countTokens,