aether-agent-sdk 3.1.2 → 3.2.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.
- package/README.md +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/paygate/PayGateClient.d.ts +92 -0
- package/dist/src/paygate/PayGateClient.d.ts.map +1 -0
- package/dist/src/paygate/PayGateClient.js +396 -0
- package/dist/src/paygate/PayGateClient.js.map +1 -0
- package/dist/src/paygate/index.d.ts +7 -0
- package/dist/src/paygate/index.d.ts.map +1 -0
- package/dist/src/paygate/index.js +11 -0
- package/dist/src/paygate/index.js.map +1 -0
- package/dist/src/paygate/types.d.ts +180 -0
- package/dist/src/paygate/types.d.ts.map +1 -0
- package/dist/src/paygate/types.js +7 -0
- package/dist/src/paygate/types.js.map +1 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ Aether is a production-ready SDK for building autonomous agent-to-agent systems
|
|
|
46
46
|
### Agent Framework
|
|
47
47
|
|
|
48
48
|
- **SettlementAgent**: Executes x402 payments and settlement on-chain
|
|
49
|
+
- **PayGateClient**: Client for purchasing x402-protected content from PayGate
|
|
49
50
|
- **x402 Facilitator**: Payment verification and USDC transfers
|
|
50
51
|
- **Protocol Support**: A2A and AP2 protocol implementations
|
|
51
52
|
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,cAAc,UAAU,CAAA;AAGxB,cAAc,eAAe,CAAA;AAG7B,cAAc,eAAe,CAAA;AAG7B,cAAc,SAAS,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,OAAO,QAAc,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,cAAc,UAAU,CAAA;AAGxB,cAAc,eAAe,CAAA;AAG7B,cAAc,eAAe,CAAA;AAG7B,cAAc,WAAW,CAAA;AAGzB,cAAc,SAAS,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,OAAO,QAAc,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAW,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -43,6 +43,8 @@ __exportStar(require("./agents"), exports);
|
|
|
43
43
|
__exportStar(require("./facilitator"), exports);
|
|
44
44
|
// Marketplace
|
|
45
45
|
__exportStar(require("./marketplace"), exports);
|
|
46
|
+
// PayGate
|
|
47
|
+
__exportStar(require("./paygate"), exports);
|
|
46
48
|
// Utils
|
|
47
49
|
__exportStar(require("./utils"), exports);
|
|
48
50
|
/**
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;AAEH,gDAAuB;AAEvB,SAAS,sBAAsB;IAC7B,IAAI,CAAC;QACH,kDAAkD;QAClD,MAAM,GAAG,GAAG,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAA;QACxE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAc,EAAE,OAAO,EAAE,GAAG,CAAC,OAAiB,EAAE,CAAA;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;IACzD,CAAC;AACH,CAAC;AAED,MAAM,GAAG,GAAG,sBAAsB,EAAE,CAAA;AAEpC,SAAS;AACT,2CAAwB;AAExB,cAAc;AACd,gDAA6B;AAE7B,cAAc;AACd,gDAA6B;AAE7B,QAAQ;AACR,0CAAuB;AAEvB;;GAEG;AACU,QAAA,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;AAElC;;GAEG;AACU,QAAA,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;AAEH,gDAAuB;AAEvB,SAAS,sBAAsB;IAC7B,IAAI,CAAC;QACH,kDAAkD;QAClD,MAAM,GAAG,GAAG,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAA;QACxE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAc,EAAE,OAAO,EAAE,GAAG,CAAC,OAAiB,EAAE,CAAA;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;IACzD,CAAC;AACH,CAAC;AAED,MAAM,GAAG,GAAG,sBAAsB,EAAE,CAAA;AAEpC,SAAS;AACT,2CAAwB;AAExB,cAAc;AACd,gDAA6B;AAE7B,cAAc;AACd,gDAA6B;AAE7B,UAAU;AACV,4CAAyB;AAEzB,QAAQ;AACR,0CAAuB;AAEvB;;GAEG;AACU,QAAA,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;AAElC;;GAEG;AACU,QAAA,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayGate Client
|
|
3
|
+
* Client for interacting with PayGate x402 payment protocol
|
|
4
|
+
*/
|
|
5
|
+
import { Keypair } from '@solana/web3.js';
|
|
6
|
+
import { PayGateClientConfig, PaymentCurrency, Product, PaymentRequirements, PricingResponse, VerifyResponse, PurchaseOptions, PurchaseResult, ContentResult, PurchaseHistoryResponse } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Error class for PayGate-specific errors
|
|
9
|
+
*/
|
|
10
|
+
export declare class PayGateError extends Error {
|
|
11
|
+
readonly statusCode: number | undefined;
|
|
12
|
+
readonly code: string | undefined;
|
|
13
|
+
constructor(message: string, statusCode?: number, code?: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* PayGate client for purchasing and retrieving x402-protected content
|
|
17
|
+
*/
|
|
18
|
+
export declare class PayGateClient {
|
|
19
|
+
private baseUrl;
|
|
20
|
+
private wallet;
|
|
21
|
+
private defaultCurrency;
|
|
22
|
+
private timeout;
|
|
23
|
+
private http;
|
|
24
|
+
private settlementAgent;
|
|
25
|
+
private logger;
|
|
26
|
+
constructor(config: PayGateClientConfig);
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the client with a wallet for signing payments
|
|
29
|
+
* @param wallet Optional wallet keypair (loads from env if not provided)
|
|
30
|
+
*/
|
|
31
|
+
init(wallet?: Keypair): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Fetch product information
|
|
34
|
+
* @param productId The product ID
|
|
35
|
+
* @returns Product information
|
|
36
|
+
*/
|
|
37
|
+
fetchProduct(productId: string): Promise<Product>;
|
|
38
|
+
/**
|
|
39
|
+
* Get full payment requirements from x402 402 response
|
|
40
|
+
* @param productId The product ID
|
|
41
|
+
* @returns Payment requirements
|
|
42
|
+
*/
|
|
43
|
+
getPaymentRequirements(productId: string): Promise<PaymentRequirements>;
|
|
44
|
+
/**
|
|
45
|
+
* Get pricing options for a product (USDC/ATHR)
|
|
46
|
+
* @param productId The product ID
|
|
47
|
+
* @returns Pricing options
|
|
48
|
+
*/
|
|
49
|
+
getPricing(productId: string): Promise<PricingResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Verify payment details before purchase
|
|
52
|
+
* @param productId The product ID
|
|
53
|
+
* @param amount The payment amount
|
|
54
|
+
* @param currency The payment currency
|
|
55
|
+
* @returns Verification result
|
|
56
|
+
*/
|
|
57
|
+
verify(productId: string, amount: string, currency?: PaymentCurrency): Promise<VerifyResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Purchase a product using the x402 flow
|
|
60
|
+
* @param productId The product ID
|
|
61
|
+
* @param options Purchase options
|
|
62
|
+
* @returns Purchase result with transaction hash and delivery URL
|
|
63
|
+
*/
|
|
64
|
+
purchase(productId: string, options?: PurchaseOptions): Promise<PurchaseResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Get content for a purchased product
|
|
67
|
+
* @param productId The product ID
|
|
68
|
+
* @returns Content delivery result
|
|
69
|
+
*/
|
|
70
|
+
getContent(productId: string): Promise<ContentResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Get purchase history for the current wallet
|
|
73
|
+
* @returns Purchase history
|
|
74
|
+
*/
|
|
75
|
+
getPurchaseHistory(): Promise<PurchaseHistoryResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Check if the current wallet has already purchased a product
|
|
78
|
+
* @param productId The product ID
|
|
79
|
+
* @returns True if already purchased
|
|
80
|
+
*/
|
|
81
|
+
hasPurchased(productId: string): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Get the current wallet public key
|
|
84
|
+
* @returns Wallet public key as base58 string, or undefined if not initialized
|
|
85
|
+
*/
|
|
86
|
+
getWalletAddress(): string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Handle and log errors consistently
|
|
89
|
+
*/
|
|
90
|
+
private handleError;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=PayGateClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayGateClient.d.ts","sourceRoot":"","sources":["../../../src/paygate/PayGateClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM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,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IA6EzF;;;;OAIG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA6B3D;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAmB5D;;;;OAIG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBvD;;;OAGG;IACH,gBAAgB,IAAI,MAAM,GAAG,SAAS;IAItC;;OAEG;IACH,OAAO,CAAC,WAAW;CAepB"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PayGate Client
|
|
4
|
+
* Client for interacting with PayGate x402 payment protocol
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.PayGateClient = exports.PayGateError = void 0;
|
|
41
|
+
const axios_1 = __importStar(require("axios"));
|
|
42
|
+
const SettlementAgent_1 = require("../agents/SettlementAgent");
|
|
43
|
+
const wallet_1 = require("../utils/wallet");
|
|
44
|
+
const logger_1 = require("../utils/logger");
|
|
45
|
+
/**
|
|
46
|
+
* Error class for PayGate-specific errors
|
|
47
|
+
*/
|
|
48
|
+
class PayGateError extends Error {
|
|
49
|
+
statusCode;
|
|
50
|
+
code;
|
|
51
|
+
constructor(message, statusCode, code) {
|
|
52
|
+
super(message);
|
|
53
|
+
this.name = 'PayGateError';
|
|
54
|
+
this.statusCode = statusCode;
|
|
55
|
+
this.code = code;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.PayGateError = PayGateError;
|
|
59
|
+
/**
|
|
60
|
+
* PayGate client for purchasing and retrieving x402-protected content
|
|
61
|
+
*/
|
|
62
|
+
class PayGateClient {
|
|
63
|
+
baseUrl;
|
|
64
|
+
wallet;
|
|
65
|
+
defaultCurrency;
|
|
66
|
+
timeout;
|
|
67
|
+
http;
|
|
68
|
+
settlementAgent;
|
|
69
|
+
logger = (0, logger_1.createLogger)('PayGateClient');
|
|
70
|
+
constructor(config) {
|
|
71
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
72
|
+
this.wallet = config.wallet;
|
|
73
|
+
this.defaultCurrency = config.defaultCurrency || 'USDC';
|
|
74
|
+
this.timeout = config.timeout || 30000;
|
|
75
|
+
this.http = axios_1.default.create({
|
|
76
|
+
baseURL: this.baseUrl,
|
|
77
|
+
timeout: this.timeout,
|
|
78
|
+
headers: {
|
|
79
|
+
'Content-Type': 'application/json'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
this.logger.info(`PayGateClient initialized for ${this.baseUrl}`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Initialize the client with a wallet for signing payments
|
|
86
|
+
* @param wallet Optional wallet keypair (loads from env if not provided)
|
|
87
|
+
*/
|
|
88
|
+
async init(wallet) {
|
|
89
|
+
try {
|
|
90
|
+
if (wallet) {
|
|
91
|
+
this.wallet = wallet;
|
|
92
|
+
this.logger.info(`Initialized with provided wallet: ${wallet.publicKey.toBase58()}`);
|
|
93
|
+
}
|
|
94
|
+
else if (!this.wallet) {
|
|
95
|
+
const { keypair } = (0, wallet_1.loadKeypairFromEnv)();
|
|
96
|
+
if (keypair) {
|
|
97
|
+
this.wallet = keypair;
|
|
98
|
+
this.logger.info(`Initialized with wallet from env: ${keypair.publicKey.toBase58()}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.logger.warn('No wallet configured. Purchase functionality will be unavailable.');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (this.wallet) {
|
|
105
|
+
this.settlementAgent = new SettlementAgent_1.SettlementAgent();
|
|
106
|
+
await this.settlementAgent.init(this.wallet);
|
|
107
|
+
this.logger.info('SettlementAgent initialized');
|
|
108
|
+
}
|
|
109
|
+
this.logger.info('PayGateClient ready');
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
this.logger.error('Failed to initialize PayGateClient', error);
|
|
113
|
+
throw new PayGateError(`Initialization failed: ${error.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Fetch product information
|
|
118
|
+
* @param productId The product ID
|
|
119
|
+
* @returns Product information
|
|
120
|
+
*/
|
|
121
|
+
async fetchProduct(productId) {
|
|
122
|
+
try {
|
|
123
|
+
this.logger.info(`Fetching product: ${productId}`);
|
|
124
|
+
const response = await this.http.get(`/pay/${productId}`, {
|
|
125
|
+
validateStatus: (status) => status === 200 || status === 402
|
|
126
|
+
});
|
|
127
|
+
if (response.status === 402) {
|
|
128
|
+
const data = response.data;
|
|
129
|
+
if (data.accepts && data.accepts.length > 0) {
|
|
130
|
+
const req = data.accepts[0];
|
|
131
|
+
if (req) {
|
|
132
|
+
return {
|
|
133
|
+
id: req.productId || productId,
|
|
134
|
+
title: req.description || productId,
|
|
135
|
+
description: req.description || '',
|
|
136
|
+
type: 'content_link',
|
|
137
|
+
price: req.amount,
|
|
138
|
+
currency: req.currency,
|
|
139
|
+
network: req.network,
|
|
140
|
+
status: 'active'
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return response.data;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.handleError('fetchProduct', error);
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get full payment requirements from x402 402 response
|
|
154
|
+
* @param productId The product ID
|
|
155
|
+
* @returns Payment requirements
|
|
156
|
+
*/
|
|
157
|
+
async getPaymentRequirements(productId) {
|
|
158
|
+
try {
|
|
159
|
+
this.logger.info(`Getting payment requirements for: ${productId}`);
|
|
160
|
+
const response = await this.http.get(`/pay/${productId}`, {
|
|
161
|
+
validateStatus: (status) => status === 402
|
|
162
|
+
});
|
|
163
|
+
if (response.status !== 402) {
|
|
164
|
+
throw new PayGateError('Expected 402 Payment Required response', response.status);
|
|
165
|
+
}
|
|
166
|
+
const data = response.data;
|
|
167
|
+
if (!data.accepts || data.accepts.length === 0) {
|
|
168
|
+
throw new PayGateError('No payment requirements in response');
|
|
169
|
+
}
|
|
170
|
+
const requirements = data.accepts[0];
|
|
171
|
+
if (!requirements) {
|
|
172
|
+
throw new PayGateError('No payment requirements in response');
|
|
173
|
+
}
|
|
174
|
+
this.logger.info(`Payment requirements received for ${productId}`);
|
|
175
|
+
return requirements;
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
this.handleError('getPaymentRequirements', error);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get pricing options for a product (USDC/ATHR)
|
|
184
|
+
* @param productId The product ID
|
|
185
|
+
* @returns Pricing options
|
|
186
|
+
*/
|
|
187
|
+
async getPricing(productId) {
|
|
188
|
+
try {
|
|
189
|
+
this.logger.info(`Getting pricing for: ${productId}`);
|
|
190
|
+
const response = await this.http.get(`/x402/pricing/${productId}`);
|
|
191
|
+
this.logger.info(`Pricing received for ${productId}`);
|
|
192
|
+
return response.data;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
this.handleError('getPricing', error);
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Verify payment details before purchase
|
|
201
|
+
* @param productId The product ID
|
|
202
|
+
* @param amount The payment amount
|
|
203
|
+
* @param currency The payment currency
|
|
204
|
+
* @returns Verification result
|
|
205
|
+
*/
|
|
206
|
+
async verify(productId, amount, currency = this.defaultCurrency) {
|
|
207
|
+
try {
|
|
208
|
+
if (!this.wallet) {
|
|
209
|
+
throw new PayGateError('Wallet not initialized. Call init() first.');
|
|
210
|
+
}
|
|
211
|
+
this.logger.info(`Verifying payment: ${amount} ${currency} for ${productId}`);
|
|
212
|
+
const response = await this.http.post('/x402/verify', {
|
|
213
|
+
productId,
|
|
214
|
+
amount,
|
|
215
|
+
currency,
|
|
216
|
+
payerWallet: this.wallet.publicKey.toBase58()
|
|
217
|
+
});
|
|
218
|
+
const result = response.data;
|
|
219
|
+
if (result.isValid) {
|
|
220
|
+
this.logger.info('Payment verification successful');
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.logger.warn(`Payment verification failed: ${result.invalidReason}`);
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
this.handleError('verify', error);
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Purchase a product using the x402 flow
|
|
234
|
+
* @param productId The product ID
|
|
235
|
+
* @param options Purchase options
|
|
236
|
+
* @returns Purchase result with transaction hash and delivery URL
|
|
237
|
+
*/
|
|
238
|
+
async purchase(productId, options = {}) {
|
|
239
|
+
try {
|
|
240
|
+
if (!this.wallet) {
|
|
241
|
+
throw new PayGateError('Wallet not initialized. Call init() first.');
|
|
242
|
+
}
|
|
243
|
+
if (!this.settlementAgent) {
|
|
244
|
+
throw new PayGateError('SettlementAgent not initialized. Call init() first.');
|
|
245
|
+
}
|
|
246
|
+
const currency = options.currency || this.defaultCurrency;
|
|
247
|
+
this.logger.info(`Starting purchase flow for ${productId} with ${currency}`);
|
|
248
|
+
// Step 1: Get payment requirements
|
|
249
|
+
this.logger.info('Step 1: Getting payment requirements');
|
|
250
|
+
const requirements = await this.getPaymentRequirements(productId);
|
|
251
|
+
// Get pricing for selected currency if different from requirements
|
|
252
|
+
let amount = requirements.amount;
|
|
253
|
+
let tokenMint = requirements.tokenMint;
|
|
254
|
+
if (currency !== requirements.currency) {
|
|
255
|
+
const pricing = await this.getPricing(productId);
|
|
256
|
+
const option = pricing.options.find((o) => o.currency === currency);
|
|
257
|
+
if (option) {
|
|
258
|
+
amount = option.amount;
|
|
259
|
+
tokenMint = option.tokenMint;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (options.amount !== undefined) {
|
|
263
|
+
amount = (options.amount * 1_000_000).toString();
|
|
264
|
+
}
|
|
265
|
+
// Step 2: Verify payment
|
|
266
|
+
this.logger.info('Step 2: Verifying payment');
|
|
267
|
+
const verification = await this.verify(productId, amount, currency);
|
|
268
|
+
if (!verification.isValid) {
|
|
269
|
+
throw new PayGateError(`Payment verification failed: ${verification.invalidReason}`);
|
|
270
|
+
}
|
|
271
|
+
// Step 3: Create signed payment via SettlementAgent
|
|
272
|
+
this.logger.info('Step 3: Creating signed payment');
|
|
273
|
+
const paymentToken = currency.toLowerCase();
|
|
274
|
+
const amountDecimal = Number(amount) / 1_000_000;
|
|
275
|
+
const paymentHeader = await this.settlementAgent.createSignedPayment(requirements.recipient, amountDecimal, { token: paymentToken });
|
|
276
|
+
// Step 4: Settle payment
|
|
277
|
+
this.logger.info('Step 4: Settling payment');
|
|
278
|
+
const settleResponse = await this.http.post('/x402/settle', {
|
|
279
|
+
paymentHeader,
|
|
280
|
+
productId
|
|
281
|
+
});
|
|
282
|
+
const settle = settleResponse.data;
|
|
283
|
+
if (!settle.success) {
|
|
284
|
+
throw new PayGateError(`Settlement failed: ${settle.error}`);
|
|
285
|
+
}
|
|
286
|
+
this.logger.info(`Purchase successful! TX: ${settle.txHash}`);
|
|
287
|
+
return {
|
|
288
|
+
transactionHash: settle.txHash,
|
|
289
|
+
productId,
|
|
290
|
+
amount,
|
|
291
|
+
currency,
|
|
292
|
+
deliveryUrl: settle.deliveryUrl
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
this.handleError('purchase', error);
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get content for a purchased product
|
|
302
|
+
* @param productId The product ID
|
|
303
|
+
* @returns Content delivery result
|
|
304
|
+
*/
|
|
305
|
+
async getContent(productId) {
|
|
306
|
+
try {
|
|
307
|
+
if (!this.wallet) {
|
|
308
|
+
throw new PayGateError('Wallet not initialized. Call init() first.');
|
|
309
|
+
}
|
|
310
|
+
this.logger.info(`Getting content for: ${productId}`);
|
|
311
|
+
const response = await this.http.get(`/deliver/${productId}`, {
|
|
312
|
+
headers: {
|
|
313
|
+
'X-Wallet-Address': this.wallet.publicKey.toBase58()
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
const delivery = response.data;
|
|
317
|
+
this.logger.info(`Content retrieved for ${productId}`);
|
|
318
|
+
return {
|
|
319
|
+
product: delivery.product,
|
|
320
|
+
downloadUrl: delivery.downloadUrl,
|
|
321
|
+
accessToken: delivery.accessToken,
|
|
322
|
+
purchaseDate: delivery.purchaseDate
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
this.handleError('getContent', error);
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Get purchase history for the current wallet
|
|
332
|
+
* @returns Purchase history
|
|
333
|
+
*/
|
|
334
|
+
async getPurchaseHistory() {
|
|
335
|
+
try {
|
|
336
|
+
if (!this.wallet) {
|
|
337
|
+
throw new PayGateError('Wallet not initialized. Call init() first.');
|
|
338
|
+
}
|
|
339
|
+
const walletAddress = this.wallet.publicKey.toBase58();
|
|
340
|
+
this.logger.info(`Getting purchase history for: ${walletAddress}`);
|
|
341
|
+
const response = await this.http.get(`/deliver/wallet/${walletAddress}`);
|
|
342
|
+
this.logger.info('Purchase history retrieved');
|
|
343
|
+
return response.data;
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
this.handleError('getPurchaseHistory', error);
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Check if the current wallet has already purchased a product
|
|
352
|
+
* @param productId The product ID
|
|
353
|
+
* @returns True if already purchased
|
|
354
|
+
*/
|
|
355
|
+
async hasPurchased(productId) {
|
|
356
|
+
try {
|
|
357
|
+
if (!this.wallet) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
this.logger.info(`Checking purchase status for: ${productId}`);
|
|
361
|
+
const history = await this.getPurchaseHistory();
|
|
362
|
+
const purchased = history.purchases.some((p) => p.productId === productId && p.status === 'completed');
|
|
363
|
+
this.logger.info(`Product ${productId} purchased: ${purchased}`);
|
|
364
|
+
return purchased;
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
this.logger.warn('Error checking purchase status', error);
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Get the current wallet public key
|
|
373
|
+
* @returns Wallet public key as base58 string, or undefined if not initialized
|
|
374
|
+
*/
|
|
375
|
+
getWalletAddress() {
|
|
376
|
+
return this.wallet?.publicKey.toBase58();
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Handle and log errors consistently
|
|
380
|
+
*/
|
|
381
|
+
handleError(method, error) {
|
|
382
|
+
if (error instanceof PayGateError) {
|
|
383
|
+
this.logger.error(`${method} failed: ${error.message}`);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (error instanceof axios_1.AxiosError) {
|
|
387
|
+
const status = error.response?.status;
|
|
388
|
+
const message = error.response?.data?.error || error.message;
|
|
389
|
+
this.logger.error(`${method} failed: HTTP ${status} - ${message}`);
|
|
390
|
+
throw new PayGateError(message, status);
|
|
391
|
+
}
|
|
392
|
+
this.logger.error(`${method} failed: ${error.message}`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
exports.PayGateClient = PayGateClient;
|
|
396
|
+
//# sourceMappingURL=PayGateClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayGateClient.js","sourceRoot":"","sources":["../../../src/paygate/PayGateClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,+CAAwD;AACxD,+DAA2D;AAC3D,4CAAoD;AACpD,4CAA8C;AAiB9C;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrB,UAAU,CAAoB;IAC9B,IAAI,CAAoB;IAExC,YAAY,OAAe,EAAE,UAAmB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AE,CAAA;IAC1C,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,MAAc,EAAE,KAAc;QAChD,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACvD,OAAM;QACR,CAAC;QAED,IAAI,KAAK,YAAY,kBAAU,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAA;YACrC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC,OAAO,CAAA;YAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,iBAAiB,MAAM,MAAM,OAAO,EAAE,CAAC,CAAA;YAClE,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QACzC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,YAAa,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;IACpE,CAAC;CACF;AA/XD,sCA+XC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayGate Module
|
|
3
|
+
* Client for interacting with PayGate x402 payment protocol
|
|
4
|
+
*/
|
|
5
|
+
export { PayGateClient, PayGateError } from './PayGateClient';
|
|
6
|
+
export type { PayGateClientConfig, PaymentCurrency, ProductType, Product, PaymentRequirements, X402Response, PricingOption, PricingResponse, VerifyRequest, VerifyResponse, SettleRequest, SettleResponse, PurchaseOptions, PurchaseResult, ContentResult, DeliveryResponse, PurchaseHistoryEntry, PurchaseHistoryResponse } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/paygate/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE7D,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PayGate Module
|
|
4
|
+
* Client for interacting with PayGate x402 payment protocol
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PayGateError = exports.PayGateClient = void 0;
|
|
8
|
+
var PayGateClient_1 = require("./PayGateClient");
|
|
9
|
+
Object.defineProperty(exports, "PayGateClient", { enumerable: true, get: function () { return PayGateClient_1.PayGateClient; } });
|
|
10
|
+
Object.defineProperty(exports, "PayGateError", { enumerable: true, get: function () { return PayGateClient_1.PayGateError; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/paygate/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAA6D;AAApD,8GAAA,aAAa,OAAA;AAAE,6GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayGate Client Types
|
|
3
|
+
* Type definitions for the PayGate x402 payment client
|
|
4
|
+
*/
|
|
5
|
+
import { Keypair } from '@solana/web3.js';
|
|
6
|
+
/**
|
|
7
|
+
* Supported payment currencies
|
|
8
|
+
*/
|
|
9
|
+
export type PaymentCurrency = 'USDC' | 'ATHR';
|
|
10
|
+
/**
|
|
11
|
+
* Product types available on PayGate
|
|
12
|
+
*/
|
|
13
|
+
export type ProductType = 'content_link' | 'api_proxy' | 'feature_unlock' | 'iot_endpoint';
|
|
14
|
+
/**
|
|
15
|
+
* PayGate client configuration
|
|
16
|
+
*/
|
|
17
|
+
export interface PayGateClientConfig {
|
|
18
|
+
/** Base URL of the PayGate server */
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
/** Optional wallet keypair for signing payments */
|
|
21
|
+
wallet?: Keypair;
|
|
22
|
+
/** Default currency for purchases (defaults to USDC) */
|
|
23
|
+
defaultCurrency?: PaymentCurrency;
|
|
24
|
+
/** Request timeout in milliseconds (defaults to 30000) */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Product information returned from PayGate
|
|
29
|
+
*/
|
|
30
|
+
export interface Product {
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
description: string;
|
|
34
|
+
type: ProductType;
|
|
35
|
+
price: string;
|
|
36
|
+
currency: string;
|
|
37
|
+
network: string;
|
|
38
|
+
status: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Payment requirements from x402 402 response
|
|
42
|
+
*/
|
|
43
|
+
export interface PaymentRequirements {
|
|
44
|
+
scheme: string;
|
|
45
|
+
network: string;
|
|
46
|
+
recipient: string;
|
|
47
|
+
amount: string;
|
|
48
|
+
currency: string;
|
|
49
|
+
tokenMint: string;
|
|
50
|
+
productId: string;
|
|
51
|
+
maxTimeoutSeconds?: number;
|
|
52
|
+
resource?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Full x402 payment response (402 status)
|
|
57
|
+
*/
|
|
58
|
+
export interface X402Response {
|
|
59
|
+
status: 402;
|
|
60
|
+
accepts: PaymentRequirements[];
|
|
61
|
+
error?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Pricing option for a product
|
|
65
|
+
*/
|
|
66
|
+
export interface PricingOption {
|
|
67
|
+
currency: PaymentCurrency;
|
|
68
|
+
amount: string;
|
|
69
|
+
tokenMint: string;
|
|
70
|
+
discount?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Pricing response from PayGate
|
|
74
|
+
*/
|
|
75
|
+
export interface PricingResponse {
|
|
76
|
+
productId: string;
|
|
77
|
+
options: PricingOption[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Verification request payload
|
|
81
|
+
*/
|
|
82
|
+
export interface VerifyRequest {
|
|
83
|
+
productId: string;
|
|
84
|
+
amount: string;
|
|
85
|
+
currency: PaymentCurrency;
|
|
86
|
+
payerWallet: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Verification response from PayGate
|
|
90
|
+
*/
|
|
91
|
+
export interface VerifyResponse {
|
|
92
|
+
isValid: boolean;
|
|
93
|
+
invalidReason?: string;
|
|
94
|
+
requirements?: PaymentRequirements;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Settlement request payload
|
|
98
|
+
*/
|
|
99
|
+
export interface SettleRequest {
|
|
100
|
+
paymentHeader: string;
|
|
101
|
+
productId: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Settlement response from PayGate
|
|
105
|
+
*/
|
|
106
|
+
export interface SettleResponse {
|
|
107
|
+
success: boolean;
|
|
108
|
+
txHash?: string;
|
|
109
|
+
deliveryUrl?: string;
|
|
110
|
+
error?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Purchase options
|
|
114
|
+
*/
|
|
115
|
+
export interface PurchaseOptions {
|
|
116
|
+
/** Currency to use for payment */
|
|
117
|
+
currency?: PaymentCurrency;
|
|
118
|
+
/** Custom amount (overrides product price) */
|
|
119
|
+
amount?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Result of a successful purchase
|
|
123
|
+
*/
|
|
124
|
+
export interface PurchaseResult {
|
|
125
|
+
transactionHash: string;
|
|
126
|
+
productId: string;
|
|
127
|
+
amount: string;
|
|
128
|
+
currency: string;
|
|
129
|
+
deliveryUrl: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Content delivery result
|
|
133
|
+
*/
|
|
134
|
+
export interface ContentResult {
|
|
135
|
+
product: {
|
|
136
|
+
id: string;
|
|
137
|
+
title: string;
|
|
138
|
+
type: ProductType;
|
|
139
|
+
};
|
|
140
|
+
downloadUrl: string | null;
|
|
141
|
+
accessToken: string | undefined;
|
|
142
|
+
purchaseDate: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Delivery response from PayGate
|
|
146
|
+
*/
|
|
147
|
+
export interface DeliveryResponse {
|
|
148
|
+
productId: string;
|
|
149
|
+
product: {
|
|
150
|
+
id: string;
|
|
151
|
+
title: string;
|
|
152
|
+
type: ProductType;
|
|
153
|
+
};
|
|
154
|
+
downloadUrl: string | null;
|
|
155
|
+
accessToken?: string;
|
|
156
|
+
purchaseDate: string;
|
|
157
|
+
expiresAt?: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Purchase history entry
|
|
161
|
+
*/
|
|
162
|
+
export interface PurchaseHistoryEntry {
|
|
163
|
+
productId: string;
|
|
164
|
+
title: string;
|
|
165
|
+
type: ProductType;
|
|
166
|
+
amount: string;
|
|
167
|
+
currency: string;
|
|
168
|
+
transactionHash: string;
|
|
169
|
+
purchaseDate: string;
|
|
170
|
+
status: 'completed' | 'pending' | 'failed';
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Purchase history response
|
|
174
|
+
*/
|
|
175
|
+
export interface PurchaseHistoryResponse {
|
|
176
|
+
wallet: string;
|
|
177
|
+
purchases: PurchaseHistoryEntry[];
|
|
178
|
+
total: number;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/payg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E,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,WAAW,CAAA;KAClB,CAAA;IACD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,WAAW,CAAA;KAClB,CAAA;IACD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,WAAW,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAA;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,oBAAoB,EAAE,CAAA;IACjC,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/paygate/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aether-agent-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Autonomous Agent Ecosystem SDK for Solana - A2A Protocol, x402 Payment Standard, and Agent-to-Agent Communication",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"import": "./dist/src/marketplace/index.js",
|
|
30
30
|
"require": "./dist/src/marketplace/index.js",
|
|
31
31
|
"types": "./dist/src/marketplace/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./paygate": {
|
|
34
|
+
"import": "./dist/src/paygate/index.js",
|
|
35
|
+
"require": "./dist/src/paygate/index.js",
|
|
36
|
+
"types": "./dist/src/paygate/index.d.ts"
|
|
32
37
|
}
|
|
33
38
|
},
|
|
34
39
|
"files": [
|