@dcentralab/d402-client 0.1.1 → 0.1.3
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/LICENSE +22 -0
- package/README.md +8 -8
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -349,11 +349,11 @@ async function signD402Payment(params) {
|
|
|
349
349
|
const {
|
|
350
350
|
operatorAccount,
|
|
351
351
|
paymentRequirement,
|
|
352
|
-
|
|
352
|
+
iatpWalletAddress,
|
|
353
353
|
requestPath,
|
|
354
354
|
d402Version = 1
|
|
355
355
|
} = params;
|
|
356
|
-
const consumerWallet =
|
|
356
|
+
const consumerWallet = iatpWalletAddress || operatorAccount.address;
|
|
357
357
|
let finalRequestPath = requestPath || paymentRequirement.resource || "/mcp";
|
|
358
358
|
if (!finalRequestPath || finalRequestPath.trim() === "") {
|
|
359
359
|
finalRequestPath = "/mcp";
|
|
@@ -543,7 +543,7 @@ var D402Client = class {
|
|
|
543
543
|
*/
|
|
544
544
|
constructor(config) {
|
|
545
545
|
this.operatorAccount = config.operatorAccount;
|
|
546
|
-
this.
|
|
546
|
+
this.iatpWalletAddress = config.iatpWalletAddress || config.operatorAccount.address;
|
|
547
547
|
this.maxValue = config.maxValue;
|
|
548
548
|
this.networkFilter = config.networkFilter;
|
|
549
549
|
this.schemeFilter = config.schemeFilter || "exact";
|
|
@@ -565,12 +565,12 @@ var D402Client = class {
|
|
|
565
565
|
});
|
|
566
566
|
}
|
|
567
567
|
/**
|
|
568
|
-
* Get the wallet address used for payments.
|
|
568
|
+
* Get the IATP wallet address used for payments.
|
|
569
569
|
*
|
|
570
570
|
* @returns IATPWallet contract address or operator EOA address
|
|
571
571
|
*/
|
|
572
|
-
|
|
573
|
-
return this.
|
|
572
|
+
getIATPWalletAddress() {
|
|
573
|
+
return this.iatpWalletAddress;
|
|
574
574
|
}
|
|
575
575
|
/**
|
|
576
576
|
* Get the operator account used for signing.
|
|
@@ -607,7 +607,7 @@ var D402Client = class {
|
|
|
607
607
|
*
|
|
608
608
|
* @example
|
|
609
609
|
* ```ts
|
|
610
|
-
* const client = new D402Client({ operatorAccount,
|
|
610
|
+
* const client = new D402Client({ operatorAccount, iatpWalletAddress })
|
|
611
611
|
*
|
|
612
612
|
* const response = await client.fetch('http://api.example.com/analyze', {
|
|
613
613
|
* method: 'POST',
|
|
@@ -632,7 +632,7 @@ var D402Client = class {
|
|
|
632
632
|
const signedPayment = await signD402Payment2({
|
|
633
633
|
operatorAccount: this.operatorAccount,
|
|
634
634
|
paymentRequirement: selectedRequirement,
|
|
635
|
-
|
|
635
|
+
iatpWalletAddress: this.iatpWalletAddress
|
|
636
636
|
});
|
|
637
637
|
const paymentHeader = encodePayment2(signedPayment);
|
|
638
638
|
response = await fetch(url, {
|