@paynodelabs/paynode-402-cli 2.5.0 → 2.5.2
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/package.json +4 -4
- package/utils.ts +28 -9
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paynodelabs/paynode-402-cli",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "The official command-line interface for the PayNode protocol. Designed for AI Agents to execute stateless micro-payments via HTTP 402.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
7
7
|
"bin": {
|
|
8
|
-
"paynode-402": "
|
|
8
|
+
"paynode-402": "index.ts"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"paynode",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
|
-
"url": "https://github.com/PayNodeLabs/paynode-402-cli.git"
|
|
34
|
+
"url": "git+https://github.com/PayNodeLabs/paynode-402-cli.git"
|
|
35
35
|
},
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/PayNodeLabs/paynode-402-cli/issues"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/PayNodeLabs/paynode-402-cli#readme"
|
|
40
|
-
}
|
|
40
|
+
}
|
package/utils.ts
CHANGED
|
@@ -16,15 +16,33 @@ if (!process.env.CLIENT_PRIVATE_KEY) {
|
|
|
16
16
|
/**
|
|
17
17
|
* Centralized Configuration Loader
|
|
18
18
|
* [SECURITY] Consolidates environment variable access for better auditing.
|
|
19
|
+
* Priority: 1. System Environment Variable (B) | 2. XDG Config File (A)
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
function loadConfig() {
|
|
22
|
+
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
23
|
+
const xdgConfigHome = process.env.XDG_CONFIG_HOME || join(home, '.config');
|
|
24
|
+
const xdgConfigPath = join(xdgConfigHome, 'paynode', 'config.json');
|
|
25
|
+
|
|
26
|
+
let localConfig: Record<string, string> = {};
|
|
27
|
+
if (fs.existsSync(xdgConfigPath)) {
|
|
28
|
+
try {
|
|
29
|
+
localConfig = JSON.parse(fs.readFileSync(xdgConfigPath, 'utf8'));
|
|
30
|
+
} catch { /* ignore invalid json */ }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
MARKETPLACE_URL: process.env.PAYNODE_MARKET_URL || localConfig.PAYNODE_MARKET_URL || 'https://mk.paynode.dev',
|
|
35
|
+
PRIVATE_KEY: process.env.CLIENT_PRIVATE_KEY || localConfig.CLIENT_PRIVATE_KEY,
|
|
36
|
+
CUSTOM_ROUTER: process.env.CUSTOM_ROUTER_ADDRESS || localConfig.CUSTOM_ROUTER_ADDRESS,
|
|
37
|
+
CUSTOM_USDC: process.env.CUSTOM_USDC_ADDRESS || localConfig.CUSTOM_USDC_ADDRESS,
|
|
38
|
+
RPC_URL_OVERRIDE: process.env.PAYNODE_RPC_URL || process.env.RPC_URL || localConfig.PAYNODE_RPC_URL,
|
|
39
|
+
RPC_TIMEOUT: Number(process.env.PAYNODE_RPC_TIMEOUT || localConfig.PAYNODE_RPC_TIMEOUT) || 15_000,
|
|
40
|
+
configSource: process.env.CLIENT_PRIVATE_KEY ? 'env' : (localConfig.CLIENT_PRIVATE_KEY ? 'file' : 'missing'),
|
|
41
|
+
configFilePath: xdgConfigPath
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const GLOBAL_CONFIG = loadConfig();
|
|
28
46
|
|
|
29
47
|
/**
|
|
30
48
|
* Skill version for JSON output metadata.
|
|
@@ -240,7 +258,8 @@ export function cleanupOldTasks(taskDir: string, maxAgeSeconds: number): number
|
|
|
240
258
|
export function getPrivateKey(isJson: boolean): string {
|
|
241
259
|
const pk: string | undefined = GLOBAL_CONFIG.PRIVATE_KEY;
|
|
242
260
|
if (!pk || typeof pk !== 'string') {
|
|
243
|
-
|
|
261
|
+
const msg = `CLIENT_PRIVATE_KEY not found. Please set environment (B) or create config file (A) at: ${GLOBAL_CONFIG.configFilePath}`;
|
|
262
|
+
reportError(msg, isJson, EXIT_CODES.AUTH_FAILURE);
|
|
244
263
|
}
|
|
245
264
|
const pkRegex = /^0x[0-9a-fA-F]{64}$/;
|
|
246
265
|
if (!pkRegex.test(pk)) {
|