@dcentralab/d402-client 0.3.14 → 0.3.16

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
@@ -95,8 +95,7 @@ var init_constants = __esm({
95
95
  { name: "provider", type: "address" },
96
96
  { name: "token", type: "address" },
97
97
  { name: "amount", type: "uint256" },
98
- { name: "deadline", type: "uint256" },
99
- { name: "requestPath", type: "string" }
98
+ { name: "deadline", type: "uint256" }
100
99
  ]
101
100
  };
102
101
  }
@@ -299,13 +298,8 @@ async function signD402Payment(params) {
299
298
  walletClient,
300
299
  paymentRequirement,
301
300
  iatpWalletAddress,
302
- requestPath,
303
301
  d402Version = 1
304
302
  } = params;
305
- let finalRequestPath = requestPath || paymentRequirement.resource || "/mcp";
306
- if (!finalRequestPath || finalRequestPath.trim() === "") {
307
- finalRequestPath = "/mcp";
308
- }
309
303
  const nonce = generateNonce();
310
304
  const now = getCurrentTimestamp();
311
305
  const validAfter = (now - 60).toString();
@@ -325,8 +319,7 @@ async function signD402Payment(params) {
325
319
  provider: paymentRequirement.payTo,
326
320
  token: paymentRequirement.asset,
327
321
  amount: BigInt(paymentRequirement.maxAmountRequired),
328
- deadline: BigInt(validBefore),
329
- requestPath: finalRequestPath
322
+ deadline: BigInt(validBefore)
330
323
  };
331
324
  let signature;
332
325
  if (walletClient) {
@@ -363,8 +356,7 @@ async function signD402Payment(params) {
363
356
  value: paymentRequirement.maxAmountRequired,
364
357
  validAfter,
365
358
  validBefore,
366
- nonce,
367
- requestPath: finalRequestPath
359
+ nonce
368
360
  }
369
361
  }
370
362
  };
@@ -1189,19 +1181,6 @@ var sepolia_default = {
1189
1181
  stateMutability: "view",
1190
1182
  type: "function"
1191
1183
  },
1192
- {
1193
- inputs: [],
1194
- name: "MAX_REQUEST_PATH_LENGTH",
1195
- outputs: [
1196
- {
1197
- internalType: "uint256",
1198
- name: "",
1199
- type: "uint256"
1200
- }
1201
- ],
1202
- stateMutability: "view",
1203
- type: "function"
1204
- },
1205
1184
  {
1206
1185
  inputs: [],
1207
1186
  name: "PROVIDER_ATTESTATION_TYPEHASH",
@@ -1514,11 +1493,6 @@ var sepolia_default = {
1514
1493
  name: "deadline",
1515
1494
  type: "uint256"
1516
1495
  },
1517
- {
1518
- internalType: "string",
1519
- name: "requestPath",
1520
- type: "string"
1521
- },
1522
1496
  {
1523
1497
  internalType: "bytes",
1524
1498
  name: "signature",
@@ -1610,11 +1584,6 @@ var sepolia_default = {
1610
1584
  name: "deadline",
1611
1585
  type: "uint256"
1612
1586
  },
1613
- {
1614
- internalType: "string",
1615
- name: "requestPath",
1616
- type: "string"
1617
- },
1618
1587
  {
1619
1588
  internalType: "bytes",
1620
1589
  name: "signature",
@@ -1759,11 +1728,6 @@ var sepolia_default = {
1759
1728
  name: "deadline",
1760
1729
  type: "uint256"
1761
1730
  },
1762
- {
1763
- internalType: "string",
1764
- name: "requestPath",
1765
- type: "string"
1766
- },
1767
1731
  {
1768
1732
  internalType: "bytes",
1769
1733
  name: "signature",
@@ -1784,14 +1748,14 @@ var sepolia_default = {
1784
1748
  {
1785
1749
  inputs: [
1786
1750
  {
1787
- internalType: "bytes",
1788
- name: "consumerSignature",
1789
- type: "bytes"
1751
+ internalType: "bytes32",
1752
+ name: "consumerSignatureHash",
1753
+ type: "bytes32"
1790
1754
  },
1791
1755
  {
1792
- internalType: "bytes",
1756
+ internalType: "bytes32",
1793
1757
  name: "outputHash",
1794
- type: "bytes"
1758
+ type: "bytes32"
1795
1759
  },
1796
1760
  {
1797
1761
  internalType: "uint256",
@@ -1850,24 +1814,6 @@ var sepolia_default = {
1850
1814
  stateMutability: "nonpayable",
1851
1815
  type: "function"
1852
1816
  },
1853
- {
1854
- inputs: [
1855
- {
1856
- internalType: "uint256",
1857
- name: "epoch",
1858
- type: "uint256"
1859
- },
1860
- {
1861
- internalType: "address",
1862
- name: "token",
1863
- type: "address"
1864
- }
1865
- ],
1866
- name: "withdrawEpochFromSettlement",
1867
- outputs: [],
1868
- stateMutability: "nonpayable",
1869
- type: "function"
1870
- },
1871
1817
  {
1872
1818
  inputs: [],
1873
1819
  name: "withdrawalLockupPeriod",
@@ -10683,6 +10629,20 @@ async function getWalletEIP712Domain(params) {
10683
10629
  };
10684
10630
  }
10685
10631
  }
10632
+ async function validateConsumerSignature(params) {
10633
+ const { publicClient, walletAddress, tokenAddress, amount, providerAddress, deadline, signature, network = "sepolia" } = params;
10634
+ const walletAbi = getContractAbi("IATPWallet" /* IATP_WALLET */, network);
10635
+ if (!walletAbi) {
10636
+ throw new Error(`IATPWallet ABI not found for network: ${network}`);
10637
+ }
10638
+ const isValid = await publicClient.readContract({
10639
+ address: walletAddress,
10640
+ abi: walletAbi,
10641
+ functionName: "validateConsumerSignature",
10642
+ args: [tokenAddress, amount, providerAddress, deadline, signature]
10643
+ });
10644
+ return isValid;
10645
+ }
10686
10646
 
10687
10647
  // src/wallet/withdrawals.ts
10688
10648
  async function getWithdrawalRequest(params) {
@@ -11152,6 +11112,6 @@ async function withdrawAllAvailableEpochs(params) {
11152
11112
  init_utils();
11153
11113
  init_errors();
11154
11114
 
11155
- export { ContractName, D402Client, Invalid402ResponseError, MissingRequestConfigError, PaymentAlreadyAttemptedError, PaymentAmountExceededError, PaymentError, PaymentVerificationError, UnsupportedNetworkError, UnsupportedSchemeError, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChain, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletEIP712Domain, getWalletInfo, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs, withdrawAllFromSettlement };
11115
+ export { ContractName, D402Client, Invalid402ResponseError, MissingRequestConfigError, PaymentAlreadyAttemptedError, PaymentAmountExceededError, PaymentError, PaymentVerificationError, UnsupportedNetworkError, UnsupportedSchemeError, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChain, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletEIP712Domain, getWalletInfo, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, validateConsumerSignature, withdrawAllAvailableEpochs, withdrawAllFromSettlement };
11156
11116
  //# sourceMappingURL=index.mjs.map
11157
11117
  //# sourceMappingURL=index.mjs.map