@tanakayuto/intmax402-express 0.2.6 → 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/README.md CHANGED
@@ -1,5 +1,23 @@
1
- # @intmax402/express
1
+ # @tanakayuto/intmax402-express
2
2
 
3
3
  Part of [intmax402](https://github.com/zaq2989/intmax402) — HTTP 402, reimagined for AI agents.
4
4
 
5
5
  See [main README](https://github.com/zaq2989/intmax402) for full documentation.
6
+
7
+ ## Network
8
+
9
+ intmax402 operates on **Ethereum mainnet** by default (via INTMAX ZK L2 on Scroll). Use `environment: "testnet"` for development against Sepolia.
10
+
11
+ ```typescript
12
+ // Payment verification — mainnet (default)
13
+ await initPaymentVerifier({
14
+ eth_private_key: process.env.ETH_PRIVATE_KEY as `0x${string}`,
15
+ environment: 'mainnet',
16
+ })
17
+
18
+ // Payment verification — testnet (development)
19
+ await initPaymentVerifier({
20
+ eth_private_key: process.env.ETH_PRIVATE_KEY as `0x${string}`,
21
+ environment: 'testnet',
22
+ })
23
+ ```
@@ -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.2.6",
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.2.6",
29
+ "@tanakayuto/intmax402-core": "0.3.1",
30
30
  "ethers": "^6.16.0",
31
31
  "intmax2-server-sdk": "^1.5.2"
32
32
  },