@dcentralab/d402-client 0.3.14 → 0.3.15
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 +0 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -56,8 +56,6 @@ interface PaymentAuthorization {
|
|
|
56
56
|
validBefore: string;
|
|
57
57
|
/** Unique nonce */
|
|
58
58
|
nonce: `0x${string}`;
|
|
59
|
-
/** Request path/resource */
|
|
60
|
-
requestPath: string;
|
|
61
59
|
}
|
|
62
60
|
/**
|
|
63
61
|
* Signed payment ready to send
|
|
@@ -448,7 +446,6 @@ declare class D402Client {
|
|
|
448
446
|
* @param params.walletClient - Optional wallet client for signing (wagmi). If provided, uses walletClient.signTypedData
|
|
449
447
|
* @param params.paymentRequirement - Payment requirements from 402 response
|
|
450
448
|
* @param params.iatpWalletAddress - IATPWallet contract address (optional)
|
|
451
|
-
* @param params.requestPath - API request path (optional, uses payment_requirements.resource if not provided)
|
|
452
449
|
* @returns Signed payment ready to encode and send
|
|
453
450
|
*
|
|
454
451
|
* @example
|
|
@@ -473,7 +470,6 @@ declare function signD402Payment(params: {
|
|
|
473
470
|
walletClient?: WalletClient;
|
|
474
471
|
paymentRequirement: PaymentRequirement;
|
|
475
472
|
iatpWalletAddress: `0x${string}`;
|
|
476
|
-
requestPath?: string;
|
|
477
473
|
d402Version?: number;
|
|
478
474
|
}): Promise<SignedPayment>;
|
|
479
475
|
|
package/dist/index.d.ts
CHANGED
|
@@ -56,8 +56,6 @@ interface PaymentAuthorization {
|
|
|
56
56
|
validBefore: string;
|
|
57
57
|
/** Unique nonce */
|
|
58
58
|
nonce: `0x${string}`;
|
|
59
|
-
/** Request path/resource */
|
|
60
|
-
requestPath: string;
|
|
61
59
|
}
|
|
62
60
|
/**
|
|
63
61
|
* Signed payment ready to send
|
|
@@ -448,7 +446,6 @@ declare class D402Client {
|
|
|
448
446
|
* @param params.walletClient - Optional wallet client for signing (wagmi). If provided, uses walletClient.signTypedData
|
|
449
447
|
* @param params.paymentRequirement - Payment requirements from 402 response
|
|
450
448
|
* @param params.iatpWalletAddress - IATPWallet contract address (optional)
|
|
451
|
-
* @param params.requestPath - API request path (optional, uses payment_requirements.resource if not provided)
|
|
452
449
|
* @returns Signed payment ready to encode and send
|
|
453
450
|
*
|
|
454
451
|
* @example
|
|
@@ -473,7 +470,6 @@ declare function signD402Payment(params: {
|
|
|
473
470
|
walletClient?: WalletClient;
|
|
474
471
|
paymentRequirement: PaymentRequirement;
|
|
475
472
|
iatpWalletAddress: `0x${string}`;
|
|
476
|
-
requestPath?: string;
|
|
477
473
|
d402Version?: number;
|
|
478
474
|
}): Promise<SignedPayment>;
|
|
479
475
|
|
package/dist/index.js
CHANGED
|
@@ -97,8 +97,7 @@ var init_constants = __esm({
|
|
|
97
97
|
{ name: "provider", type: "address" },
|
|
98
98
|
{ name: "token", type: "address" },
|
|
99
99
|
{ name: "amount", type: "uint256" },
|
|
100
|
-
{ name: "deadline", type: "uint256" }
|
|
101
|
-
{ name: "requestPath", type: "string" }
|
|
100
|
+
{ name: "deadline", type: "uint256" }
|
|
102
101
|
]
|
|
103
102
|
};
|
|
104
103
|
}
|
|
@@ -301,13 +300,8 @@ async function signD402Payment(params) {
|
|
|
301
300
|
walletClient,
|
|
302
301
|
paymentRequirement,
|
|
303
302
|
iatpWalletAddress,
|
|
304
|
-
requestPath,
|
|
305
303
|
d402Version = 1
|
|
306
304
|
} = params;
|
|
307
|
-
let finalRequestPath = requestPath || paymentRequirement.resource || "/mcp";
|
|
308
|
-
if (!finalRequestPath || finalRequestPath.trim() === "") {
|
|
309
|
-
finalRequestPath = "/mcp";
|
|
310
|
-
}
|
|
311
305
|
const nonce = generateNonce();
|
|
312
306
|
const now = getCurrentTimestamp();
|
|
313
307
|
const validAfter = (now - 60).toString();
|
|
@@ -327,8 +321,7 @@ async function signD402Payment(params) {
|
|
|
327
321
|
provider: paymentRequirement.payTo,
|
|
328
322
|
token: paymentRequirement.asset,
|
|
329
323
|
amount: BigInt(paymentRequirement.maxAmountRequired),
|
|
330
|
-
deadline: BigInt(validBefore)
|
|
331
|
-
requestPath: finalRequestPath
|
|
324
|
+
deadline: BigInt(validBefore)
|
|
332
325
|
};
|
|
333
326
|
let signature;
|
|
334
327
|
if (walletClient) {
|
|
@@ -365,8 +358,7 @@ async function signD402Payment(params) {
|
|
|
365
358
|
value: paymentRequirement.maxAmountRequired,
|
|
366
359
|
validAfter,
|
|
367
360
|
validBefore,
|
|
368
|
-
nonce
|
|
369
|
-
requestPath: finalRequestPath
|
|
361
|
+
nonce
|
|
370
362
|
}
|
|
371
363
|
}
|
|
372
364
|
};
|