@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.
- package/README.md +101 -8
- package/dist/client/index.cjs +28 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +2 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +25 -0
- package/dist/client/index.js.map +1 -1
- package/dist/react/index.cjs +40 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +10 -1
- package/dist/react/index.d.ts +10 -1
- package/dist/react/index.js +38 -1
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.cjs +16 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +10 -1
- package/dist/server/index.d.ts +10 -1
- package/dist/server/index.js +15 -1
- package/dist/server/index.js.map +1 -1
- package/dist/{x402-client-BDaOwfgE.d.cts → sponsored-access-BCB2CxdG.d.cts} +68 -1
- package/dist/{x402-client-DIcp-PvX.d.ts → sponsored-access-H1EX6zpi.d.ts} +68 -1
- package/package.json +2 -6
package/dist/server/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { P as PaymentAccept, V as VerifyResponse, S as SettleResponse, c as PayToProvider, d as PaymentRequired } from '../types-BQvaF8lB.cjs';
|
|
2
2
|
export { g as AccessPassClaims, A as AccessPassClientConfig, b as AccessPassInfo, a as AccessPassTier, B as BASE_MAINNET_NETWORK, D as DEXTER_FACILITATOR_URL, e as PayToContext, f as PayToProviderDefaults, h as SOLANA_MAINNET_NETWORK, i as USDC_BASE, U as USDC_MINT } from '../types-BQvaF8lB.cjs';
|
|
3
3
|
import { Request, RequestHandler } from 'express';
|
|
4
|
+
import { SponsoredRecommendation } from '@dexterai/x402-ads-types';
|
|
5
|
+
export { SPONSORED_ACCESS_EXTENSION_KEY, SponsoredAccessClientConsent, SponsoredAccessPaymentRequiredInfo, SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Facilitator Client
|
|
@@ -354,7 +356,14 @@ interface X402MiddlewareConfig {
|
|
|
354
356
|
* ```
|
|
355
357
|
*/
|
|
356
358
|
sponsoredAccess?: boolean | {
|
|
357
|
-
|
|
359
|
+
/** Custom injection function. Receives the original response body and typed recommendations. */
|
|
360
|
+
inject?: (body: unknown, recommendations: SponsoredRecommendation[]) => unknown;
|
|
361
|
+
/** Called when sponsored recommendations are matched for a settlement. */
|
|
362
|
+
onMatch?: (recommendations: SponsoredRecommendation[], settlement: {
|
|
363
|
+
transaction: string;
|
|
364
|
+
network: string;
|
|
365
|
+
payer: string;
|
|
366
|
+
}) => void;
|
|
358
367
|
};
|
|
359
368
|
}
|
|
360
369
|
/**
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { P as PaymentAccept, V as VerifyResponse, S as SettleResponse, c as PayToProvider, d as PaymentRequired } from '../types-BQvaF8lB.js';
|
|
2
2
|
export { g as AccessPassClaims, A as AccessPassClientConfig, b as AccessPassInfo, a as AccessPassTier, B as BASE_MAINNET_NETWORK, D as DEXTER_FACILITATOR_URL, e as PayToContext, f as PayToProviderDefaults, h as SOLANA_MAINNET_NETWORK, i as USDC_BASE, U as USDC_MINT } from '../types-BQvaF8lB.js';
|
|
3
3
|
import { Request, RequestHandler } from 'express';
|
|
4
|
+
import { SponsoredRecommendation } from '@dexterai/x402-ads-types';
|
|
5
|
+
export { SPONSORED_ACCESS_EXTENSION_KEY, SponsoredAccessClientConsent, SponsoredAccessPaymentRequiredInfo, SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Facilitator Client
|
|
@@ -354,7 +356,14 @@ interface X402MiddlewareConfig {
|
|
|
354
356
|
* ```
|
|
355
357
|
*/
|
|
356
358
|
sponsoredAccess?: boolean | {
|
|
357
|
-
|
|
359
|
+
/** Custom injection function. Receives the original response body and typed recommendations. */
|
|
360
|
+
inject?: (body: unknown, recommendations: SponsoredRecommendation[]) => unknown;
|
|
361
|
+
/** Called when sponsored recommendations are matched for a settlement. */
|
|
362
|
+
onMatch?: (recommendations: SponsoredRecommendation[], settlement: {
|
|
363
|
+
transaction: string;
|
|
364
|
+
network: string;
|
|
365
|
+
payer: string;
|
|
366
|
+
}) => void;
|
|
358
367
|
};
|
|
359
368
|
}
|
|
360
369
|
/**
|
package/dist/server/index.js
CHANGED
|
@@ -510,9 +510,19 @@ function x402Middleware(config) {
|
|
|
510
510
|
res.setHeader("PAYMENT-RESPONSE", encodeBase64Json(paymentResponseData));
|
|
511
511
|
if (config.sponsoredAccess && settleResult.extensions?.["sponsored-access"]) {
|
|
512
512
|
const extData = settleResult.extensions["sponsored-access"];
|
|
513
|
-
const recs = extData?.info?.recommendations;
|
|
513
|
+
const recs = extData?.info?.recommendations ?? extData?.recommendations;
|
|
514
514
|
if (recs && recs.length > 0) {
|
|
515
515
|
log("Injecting sponsored-access recommendations into response");
|
|
516
|
+
if (typeof config.sponsoredAccess === "object" && config.sponsoredAccess.onMatch) {
|
|
517
|
+
try {
|
|
518
|
+
config.sponsoredAccess.onMatch(recs, {
|
|
519
|
+
transaction: settleResult.transaction,
|
|
520
|
+
network: settledNetwork,
|
|
521
|
+
payer: verifyResult.payer ?? ""
|
|
522
|
+
});
|
|
523
|
+
} catch {
|
|
524
|
+
}
|
|
525
|
+
}
|
|
516
526
|
const originalJson = res.json.bind(res);
|
|
517
527
|
res.json = function patchedJson(body) {
|
|
518
528
|
if (typeof config.sponsoredAccess === "object" && config.sponsoredAccess.inject) {
|
|
@@ -2003,6 +2013,9 @@ function stripePayTo(secretKeyOrConfig) {
|
|
|
2003
2013
|
provider._stripeNetwork = caip2Network;
|
|
2004
2014
|
return provider;
|
|
2005
2015
|
}
|
|
2016
|
+
|
|
2017
|
+
// src/server/index.ts
|
|
2018
|
+
import { SPONSORED_ACCESS_EXTENSION_KEY } from "@dexterai/x402-ads-types";
|
|
2006
2019
|
export {
|
|
2007
2020
|
BASE_MAINNET_NETWORK,
|
|
2008
2021
|
DEXTER_FACILITATOR_URL,
|
|
@@ -2011,6 +2024,7 @@ export {
|
|
|
2011
2024
|
MODEL_PRICING_MAP,
|
|
2012
2025
|
MODEL_REGISTRY,
|
|
2013
2026
|
SOLANA_MAINNET_NETWORK,
|
|
2027
|
+
SPONSORED_ACCESS_EXTENSION_KEY,
|
|
2014
2028
|
USDC_BASE,
|
|
2015
2029
|
USDC_MINT,
|
|
2016
2030
|
countTokens,
|