@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as ChainAdapter, W as WalletSet } from './types-DmqH9yD8.cjs';
|
|
2
2
|
import { A as AccessPassClientConfig } from './types-BQvaF8lB.cjs';
|
|
3
|
+
import { SponsoredRecommendation, SponsoredAccessSettlementInfo } from '@dexterai/x402-ads-types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* x402 v2 Client
|
|
@@ -109,4 +110,70 @@ interface X402Client {
|
|
|
109
110
|
*/
|
|
110
111
|
declare function createX402Client(config: X402ClientConfig): X402Client;
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Sponsored Access (Ads for Agents) — Client Helpers
|
|
115
|
+
*
|
|
116
|
+
* Extract sponsored recommendations from x402 payment receipts and
|
|
117
|
+
* fire impression beacons to confirm delivery to the ad network.
|
|
118
|
+
*
|
|
119
|
+
* Recommendations are injected by the facilitator after settlement
|
|
120
|
+
* via the `extensions["sponsored-access"]` field. Publishers who enable
|
|
121
|
+
* `sponsoredAccess: true` in their middleware also inject them into
|
|
122
|
+
* the JSON response body as `_x402_sponsored`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* import { wrapFetch, getSponsoredRecommendations, fireImpressionBeacon } from '@dexterai/x402/client';
|
|
127
|
+
*
|
|
128
|
+
* const x402Fetch = wrapFetch(fetch, { walletPrivateKey: key });
|
|
129
|
+
* const response = await x402Fetch('https://api.example.com/data');
|
|
130
|
+
*
|
|
131
|
+
* const recs = getSponsoredRecommendations(response);
|
|
132
|
+
* if (recs) {
|
|
133
|
+
* console.log('Sponsored:', recs.map(r => `${r.sponsor}: ${r.description}`));
|
|
134
|
+
* await fireImpressionBeacon(response); // Confirm delivery to ad network
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Extract the full sponsored-access extension data from a payment receipt.
|
|
141
|
+
* Returns undefined if no sponsored-access extension is present.
|
|
142
|
+
*/
|
|
143
|
+
declare function getSponsoredAccessInfo(response: Response): SponsoredAccessSettlementInfo | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Extract sponsored recommendations from an x402 payment response.
|
|
146
|
+
* Returns the recommendations array, or undefined if none present.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const recs = getSponsoredRecommendations(response);
|
|
151
|
+
* if (recs) {
|
|
152
|
+
* for (const rec of recs) {
|
|
153
|
+
* console.log(`${rec.sponsor}: ${rec.description} — ${rec.resourceUrl}`);
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function getSponsoredRecommendations(response: Response): SponsoredRecommendation[] | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Fire the impression beacon to confirm recommendation delivery to the ad network.
|
|
161
|
+
* This is a fire-and-forget GET request — failures are silently ignored.
|
|
162
|
+
*
|
|
163
|
+
* Call this after you've read the recommendations to help the ad network
|
|
164
|
+
* track delivery rates and verify impressions.
|
|
165
|
+
*
|
|
166
|
+
* @returns true if the beacon was fired (regardless of response), false if no beacon URL
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const recs = getSponsoredRecommendations(response);
|
|
171
|
+
* if (recs) {
|
|
172
|
+
* // Process recommendations...
|
|
173
|
+
* await fireImpressionBeacon(response);
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function fireImpressionBeacon(response: Response): Promise<boolean>;
|
|
178
|
+
|
|
179
|
+
export { type PaymentReceipt as P, type X402ClientConfig as X, type X402Client as a, getSponsoredRecommendations as b, createX402Client as c, getSponsoredAccessInfo as d, fireImpressionBeacon as f, getPaymentReceipt as g };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as ChainAdapter, W as WalletSet } from './types-ENcnkof8.js';
|
|
2
2
|
import { A as AccessPassClientConfig } from './types-BQvaF8lB.js';
|
|
3
|
+
import { SponsoredRecommendation, SponsoredAccessSettlementInfo } from '@dexterai/x402-ads-types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* x402 v2 Client
|
|
@@ -109,4 +110,70 @@ interface X402Client {
|
|
|
109
110
|
*/
|
|
110
111
|
declare function createX402Client(config: X402ClientConfig): X402Client;
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Sponsored Access (Ads for Agents) — Client Helpers
|
|
115
|
+
*
|
|
116
|
+
* Extract sponsored recommendations from x402 payment receipts and
|
|
117
|
+
* fire impression beacons to confirm delivery to the ad network.
|
|
118
|
+
*
|
|
119
|
+
* Recommendations are injected by the facilitator after settlement
|
|
120
|
+
* via the `extensions["sponsored-access"]` field. Publishers who enable
|
|
121
|
+
* `sponsoredAccess: true` in their middleware also inject them into
|
|
122
|
+
* the JSON response body as `_x402_sponsored`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* import { wrapFetch, getSponsoredRecommendations, fireImpressionBeacon } from '@dexterai/x402/client';
|
|
127
|
+
*
|
|
128
|
+
* const x402Fetch = wrapFetch(fetch, { walletPrivateKey: key });
|
|
129
|
+
* const response = await x402Fetch('https://api.example.com/data');
|
|
130
|
+
*
|
|
131
|
+
* const recs = getSponsoredRecommendations(response);
|
|
132
|
+
* if (recs) {
|
|
133
|
+
* console.log('Sponsored:', recs.map(r => `${r.sponsor}: ${r.description}`));
|
|
134
|
+
* await fireImpressionBeacon(response); // Confirm delivery to ad network
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Extract the full sponsored-access extension data from a payment receipt.
|
|
141
|
+
* Returns undefined if no sponsored-access extension is present.
|
|
142
|
+
*/
|
|
143
|
+
declare function getSponsoredAccessInfo(response: Response): SponsoredAccessSettlementInfo | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Extract sponsored recommendations from an x402 payment response.
|
|
146
|
+
* Returns the recommendations array, or undefined if none present.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const recs = getSponsoredRecommendations(response);
|
|
151
|
+
* if (recs) {
|
|
152
|
+
* for (const rec of recs) {
|
|
153
|
+
* console.log(`${rec.sponsor}: ${rec.description} — ${rec.resourceUrl}`);
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function getSponsoredRecommendations(response: Response): SponsoredRecommendation[] | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Fire the impression beacon to confirm recommendation delivery to the ad network.
|
|
161
|
+
* This is a fire-and-forget GET request — failures are silently ignored.
|
|
162
|
+
*
|
|
163
|
+
* Call this after you've read the recommendations to help the ad network
|
|
164
|
+
* track delivery rates and verify impressions.
|
|
165
|
+
*
|
|
166
|
+
* @returns true if the beacon was fired (regardless of response), false if no beacon URL
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const recs = getSponsoredRecommendations(response);
|
|
171
|
+
* if (recs) {
|
|
172
|
+
* // Process recommendations...
|
|
173
|
+
* await fireImpressionBeacon(response);
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function fireImpressionBeacon(response: Response): Promise<boolean>;
|
|
178
|
+
|
|
179
|
+
export { type PaymentReceipt as P, type X402ClientConfig as X, type X402Client as a, getSponsoredRecommendations as b, createX402Client as c, getSponsoredAccessInfo as d, fireImpressionBeacon as f, getPaymentReceipt as g };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexterai/x402",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Full-stack x402 SDK - add paid API monetization to any endpoint. Express middleware, React hooks, Access Pass, dynamic pricing. Solana, Base, Polygon, Arbitrum, Optimism, Avalanche, SKALE.",
|
|
5
5
|
"author": "Dexter",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@solana/spl-token": "^0.4.9",
|
|
55
|
+
"@dexterai/x402-ads-types": "^0.1.0",
|
|
55
56
|
"@solana/web3.js": "^1.98.0",
|
|
56
57
|
"tiktoken": "^1.0.22"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@dexterai/x402-ads-types": "^0.1.0",
|
|
60
60
|
"@types/aws-lambda": "^8.10.161",
|
|
61
61
|
"@types/express": "^5.0.6",
|
|
62
62
|
"@types/node": "^22.10.0",
|
|
@@ -70,16 +70,12 @@
|
|
|
70
70
|
"vitest": "^2.1.8"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@dexterai/x402-ads-types": ">=0.1.0",
|
|
74
73
|
"@solana/wallet-adapter-base": "^0.9.0",
|
|
75
74
|
"react": "^18.0.0 || ^19.0.0",
|
|
76
75
|
"stripe": "^20.0.0",
|
|
77
76
|
"viem": "^2.0.0"
|
|
78
77
|
},
|
|
79
78
|
"peerDependenciesMeta": {
|
|
80
|
-
"@dexterai/x402-ads-types": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
79
|
"@solana/wallet-adapter-base": {
|
|
84
80
|
"optional": true
|
|
85
81
|
},
|