@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.mjs CHANGED
@@ -302,7 +302,6 @@ async function signD402Payment(params) {
302
302
  requestPath,
303
303
  d402Version = 1
304
304
  } = params;
305
- const consumerWallet = iatpWalletAddress || operatorAccount.address;
306
305
  let finalRequestPath = requestPath || paymentRequirement.resource || "/mcp";
307
306
  if (!finalRequestPath || finalRequestPath.trim() === "") {
308
307
  finalRequestPath = "/mcp";
@@ -319,10 +318,10 @@ async function signD402Payment(params) {
319
318
  name: walletName,
320
319
  version: walletVersion,
321
320
  chainId,
322
- verifyingContract: consumerWallet
321
+ verifyingContract: iatpWalletAddress
323
322
  };
324
323
  const message = {
325
- wallet: consumerWallet,
324
+ wallet: iatpWalletAddress,
326
325
  provider: paymentRequirement.payTo,
327
326
  token: paymentRequirement.asset,
328
327
  amount: BigInt(paymentRequirement.maxAmountRequired),
@@ -347,7 +346,7 @@ async function signD402Payment(params) {
347
346
  payload: {
348
347
  signature,
349
348
  authorization: {
350
- from: consumerWallet,
349
+ from: iatpWalletAddress,
351
350
  to: paymentRequirement.payTo,
352
351
  value: paymentRequirement.maxAmountRequired,
353
352
  validAfter,
@@ -5388,7 +5387,15 @@ var D402Client = class {
5388
5387
  const { parseAllPaymentRequirements: parseAllPaymentRequirements2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
5389
5388
  const { signD402Payment: signD402Payment2 } = await Promise.resolve().then(() => (init_signer(), signer_exports));
5390
5389
  const { encodePayment: encodePayment2 } = await Promise.resolve().then(() => (init_encoder(), encoder_exports));
5391
- let response = await fetch(url, init);
5390
+ const enhancedInit = {
5391
+ ...init,
5392
+ headers: {
5393
+ ...init?.headers,
5394
+ // Preserve existing Accept header or set default for MCP compatibility
5395
+ "Accept": init?.headers?.["Accept"] || "application/json, text/event-stream"
5396
+ }
5397
+ };
5398
+ let response = await fetch(url, enhancedInit);
5392
5399
  if (response.status !== 402) {
5393
5400
  return response;
5394
5401
  }
@@ -5402,9 +5409,9 @@ var D402Client = class {
5402
5409
  });
5403
5410
  const paymentHeader = encodePayment2(signedPayment);
5404
5411
  response = await fetch(url, {
5405
- ...init,
5412
+ ...enhancedInit,
5406
5413
  headers: {
5407
- ...init?.headers,
5414
+ ...enhancedInit.headers,
5408
5415
  "X-Payment": paymentHeader,
5409
5416
  "Access-Control-Expose-Headers": "X-Payment-Response"
5410
5417
  }