@tanakayuto/intmax402-core 0.2.6 → 0.3.0

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,16 @@
1
- # @intmax402/core
1
+ # @tanakayuto/intmax402-core
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
+ By default, intmax402 operates on **Ethereum mainnet** via INTMAX ZK L2 (Scroll).
10
+
11
+ | Environment | L1 Chain | L2 Chain | L1 Chain ID |
12
+ |---|---|---|---|
13
+ | `mainnet` (default) | Ethereum mainnet | Scroll | `1` |
14
+ | `testnet` | Sepolia | Scroll Sepolia | `11155111` |
15
+
16
+ The `chainId` is automatically included in `WWW-Authenticate` headers based on the configured environment, so clients always know which chain to use.
package/dist/types.d.ts CHANGED
@@ -20,8 +20,21 @@ export interface INTMAX402Config {
20
20
  serverAddress?: string;
21
21
  amount?: string;
22
22
  tokenAddress?: string;
23
+ /**
24
+ * L1 chain ID for the INTMAX network.
25
+ * - Mainnet (default): `"1"` (Ethereum mainnet, INTMAX ZK L2 on Scroll)
26
+ * - Testnet: `"11155111"` (Sepolia, INTMAX ZK L2 on Scroll Sepolia)
27
+ * If omitted, chainId is auto-derived from the `environment` field.
28
+ */
23
29
  chainId?: string;
30
+ /**
31
+ * Network environment. Defaults to `"mainnet"`.
32
+ * - `"mainnet"`: Ethereum mainnet + Scroll (chain IDs: L1=1, L2=534352)
33
+ * - `"testnet"`: Sepolia + Scroll Sepolia (chain IDs: L1=11155111, L2=534351)
34
+ */
24
35
  environment?: "mainnet" | "testnet";
36
+ /** Optional L1 RPC URL override. If not set, uses the INTMAX public RPC. */
37
+ l1RpcUrl?: string;
25
38
  allowList?: string[];
26
39
  pricing?: Record<string, string>;
27
40
  /** Bind nonce to client IP. Default false (recommended for AI agents). */
@@ -5,6 +5,11 @@ exports.buildWWWAuthenticate = buildWWWAuthenticate;
5
5
  function sanitize(value) {
6
6
  return value.replace(/["\\]|\r|\n/g, "");
7
7
  }
8
+ /** Default L1 chain IDs per environment */
9
+ const DEFAULT_CHAIN_IDS = {
10
+ mainnet: "1", // Ethereum mainnet (INTMAX ZK L2 on Scroll)
11
+ testnet: "11155111", // Sepolia (INTMAX ZK L2 on Scroll Sepolia)
12
+ };
8
13
  function buildWWWAuthenticate(nonce, config) {
9
14
  let header = `INTMAX402 realm="intmax402", nonce="${nonce}", mode="${config.mode}"`;
10
15
  if (config.serverAddress)
@@ -13,7 +18,9 @@ function buildWWWAuthenticate(nonce, config) {
13
18
  header += `, amount="${sanitize(config.amount)}"`;
14
19
  if (config.tokenAddress)
15
20
  header += `, tokenAddress="${sanitize(config.tokenAddress)}"`;
16
- if (config.chainId)
17
- header += `, chainId="${sanitize(config.chainId)}"`;
21
+ // Include chainId: explicit config takes priority, otherwise derive from environment
22
+ const chainId = config.chainId ?? DEFAULT_CHAIN_IDS[config.environment ?? "mainnet"];
23
+ if (chainId)
24
+ header += `, chainId="${sanitize(chainId)}"`;
18
25
  return header;
19
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanakayuto/intmax402-core",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {