@dcentralab/d402-client 0.3.4 → 0.3.5
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -423,7 +423,7 @@ declare class D402Client {
|
|
|
423
423
|
declare function signD402Payment(params: {
|
|
424
424
|
operatorAccount: Account;
|
|
425
425
|
paymentRequirement: PaymentRequirement;
|
|
426
|
-
iatpWalletAddress
|
|
426
|
+
iatpWalletAddress: `0x${string}`;
|
|
427
427
|
requestPath?: string;
|
|
428
428
|
d402Version?: number;
|
|
429
429
|
}): Promise<SignedPayment>;
|
package/dist/index.d.ts
CHANGED
|
@@ -423,7 +423,7 @@ declare class D402Client {
|
|
|
423
423
|
declare function signD402Payment(params: {
|
|
424
424
|
operatorAccount: Account;
|
|
425
425
|
paymentRequirement: PaymentRequirement;
|
|
426
|
-
iatpWalletAddress
|
|
426
|
+
iatpWalletAddress: `0x${string}`;
|
|
427
427
|
requestPath?: string;
|
|
428
428
|
d402Version?: number;
|
|
429
429
|
}): Promise<SignedPayment>;
|
package/dist/index.js
CHANGED
|
@@ -304,7 +304,6 @@ async function signD402Payment(params) {
|
|
|
304
304
|
requestPath,
|
|
305
305
|
d402Version = 1
|
|
306
306
|
} = params;
|
|
307
|
-
const consumerWallet = iatpWalletAddress || operatorAccount.address;
|
|
308
307
|
let finalRequestPath = requestPath || paymentRequirement.resource || "/mcp";
|
|
309
308
|
if (!finalRequestPath || finalRequestPath.trim() === "") {
|
|
310
309
|
finalRequestPath = "/mcp";
|
|
@@ -321,10 +320,10 @@ async function signD402Payment(params) {
|
|
|
321
320
|
name: walletName,
|
|
322
321
|
version: walletVersion,
|
|
323
322
|
chainId,
|
|
324
|
-
verifyingContract:
|
|
323
|
+
verifyingContract: iatpWalletAddress
|
|
325
324
|
};
|
|
326
325
|
const message = {
|
|
327
|
-
wallet:
|
|
326
|
+
wallet: iatpWalletAddress,
|
|
328
327
|
provider: paymentRequirement.payTo,
|
|
329
328
|
token: paymentRequirement.asset,
|
|
330
329
|
amount: BigInt(paymentRequirement.maxAmountRequired),
|
|
@@ -349,7 +348,7 @@ async function signD402Payment(params) {
|
|
|
349
348
|
payload: {
|
|
350
349
|
signature,
|
|
351
350
|
authorization: {
|
|
352
|
-
from:
|
|
351
|
+
from: iatpWalletAddress,
|
|
353
352
|
to: paymentRequirement.payTo,
|
|
354
353
|
value: paymentRequirement.maxAmountRequired,
|
|
355
354
|
validAfter,
|
|
@@ -5390,7 +5389,15 @@ var D402Client = class {
|
|
|
5390
5389
|
const { parseAllPaymentRequirements: parseAllPaymentRequirements2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
|
|
5391
5390
|
const { signD402Payment: signD402Payment2 } = await Promise.resolve().then(() => (init_signer(), signer_exports));
|
|
5392
5391
|
const { encodePayment: encodePayment2 } = await Promise.resolve().then(() => (init_encoder(), encoder_exports));
|
|
5393
|
-
|
|
5392
|
+
const enhancedInit = {
|
|
5393
|
+
...init,
|
|
5394
|
+
headers: {
|
|
5395
|
+
...init?.headers,
|
|
5396
|
+
// Preserve existing Accept header or set default for MCP compatibility
|
|
5397
|
+
"Accept": init?.headers?.["Accept"] || "application/json, text/event-stream"
|
|
5398
|
+
}
|
|
5399
|
+
};
|
|
5400
|
+
let response = await fetch(url, enhancedInit);
|
|
5394
5401
|
if (response.status !== 402) {
|
|
5395
5402
|
return response;
|
|
5396
5403
|
}
|
|
@@ -5404,9 +5411,9 @@ var D402Client = class {
|
|
|
5404
5411
|
});
|
|
5405
5412
|
const paymentHeader = encodePayment2(signedPayment);
|
|
5406
5413
|
response = await fetch(url, {
|
|
5407
|
-
...
|
|
5414
|
+
...enhancedInit,
|
|
5408
5415
|
headers: {
|
|
5409
|
-
...
|
|
5416
|
+
...enhancedInit.headers,
|
|
5410
5417
|
"X-Payment": paymentHeader,
|
|
5411
5418
|
"Access-Control-Expose-Headers": "X-Payment-Response"
|
|
5412
5419
|
}
|