@tanakayuto/intmax402-express 0.3.0 → 0.3.1
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/middleware.js +15 -0
- package/package.json +2 -2
package/dist/middleware.js
CHANGED
|
@@ -5,8 +5,23 @@ const intmax402_core_1 = require("@tanakayuto/intmax402-core");
|
|
|
5
5
|
const crypto_1 = require("./crypto");
|
|
6
6
|
const verify_payment_1 = require("./verify-payment");
|
|
7
7
|
function intmax402(config) {
|
|
8
|
+
// Auto-initialize payment verifier if ethPrivateKey is provided
|
|
9
|
+
let initPromise = null;
|
|
10
|
+
if (config.mode === "payment" && config.ethPrivateKey) {
|
|
11
|
+
console.log("[intmax402] Payment verifier initializing...");
|
|
12
|
+
initPromise = (0, verify_payment_1.initPaymentVerifier)({
|
|
13
|
+
eth_private_key: config.ethPrivateKey,
|
|
14
|
+
environment: config.environment ?? "mainnet",
|
|
15
|
+
l1_rpc_url: config.l1RpcUrl,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
8
18
|
return async (req, res, next) => {
|
|
9
19
|
try {
|
|
20
|
+
// Wait for payment verifier initialization if in progress
|
|
21
|
+
if (initPromise) {
|
|
22
|
+
await initPromise;
|
|
23
|
+
initPromise = null;
|
|
24
|
+
}
|
|
10
25
|
const authHeader = req.headers.authorization;
|
|
11
26
|
if (!authHeader) {
|
|
12
27
|
const ip = req.ip || req.socket.remoteAddress || "unknown";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanakayuto/intmax402-express",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@tanakayuto/intmax402-core": "0.3.
|
|
29
|
+
"@tanakayuto/intmax402-core": "0.3.1",
|
|
30
30
|
"ethers": "^6.16.0",
|
|
31
31
|
"intmax2-server-sdk": "^1.5.2"
|
|
32
32
|
},
|