@a2hmarket/a2hmarket 1.0.9 → 1.0.10
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/install.mjs +20 -12
- package/scripts/setup-tempo-key.mjs +1 -1
- package/src/credentials.ts +15 -13
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/scripts/install.mjs
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
* 2. User opens URL in browser to authorize
|
|
10
10
|
* 3. Poll GET /findu-user/api/v1/public/user/agent/auth?code=xxx
|
|
11
11
|
* 4. Server returns agent_id + secret after user authorizes
|
|
12
|
-
* 5. Save credentials to ~/.openclaw/
|
|
12
|
+
* 5. Save credentials to openclaw.json config + ~/.openclaw/credentials/a2h_credentials.json
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { execSync } from "node:child_process";
|
|
16
16
|
import { createInterface } from "node:readline";
|
|
17
|
-
import { existsSync, mkdirSync, writeFileSync, readFileSync } from "node:fs";
|
|
17
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, unlinkSync } from "node:fs";
|
|
18
18
|
import { join } from "node:path";
|
|
19
19
|
import { homedir } from "node:os";
|
|
20
20
|
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
@@ -23,7 +23,7 @@ import { networkInterfaces } from "node:os";
|
|
|
23
23
|
const OPENCLAW_DIR = join(homedir(), ".openclaw");
|
|
24
24
|
const OPENCLAW_CONFIG = join(OPENCLAW_DIR, "openclaw.json");
|
|
25
25
|
const CREDS_DIR = join(OPENCLAW_DIR, "credentials");
|
|
26
|
-
const CREDS_FILE = join(CREDS_DIR, "
|
|
26
|
+
const CREDS_FILE = join(CREDS_DIR, "a2h_credentials.json");
|
|
27
27
|
const A2H_STORE_DIR = join(homedir(), ".a2h_store");
|
|
28
28
|
const A2H_CONFIG_DIR = join(A2H_STORE_DIR, "a2h_config");
|
|
29
29
|
const A2H_DATA_DIR = join(A2H_STORE_DIR, "a2h_data");
|
|
@@ -512,14 +512,22 @@ async function runUninstall() {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
// 2. Remove runtime data
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
515
|
+
// Only remove a2h_credentials.json from shared credentials dir (other plugins use this dir)
|
|
516
|
+
if (existsSync(CREDS_FILE)) {
|
|
517
|
+
try {
|
|
518
|
+
unlinkSync(CREDS_FILE);
|
|
519
|
+
log(` ${CHECK} Removed: ${CREDS_FILE}`);
|
|
520
|
+
} catch {
|
|
521
|
+
log(` ${WARN} Failed to remove: ${CREDS_FILE}`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
// Remove a2h_store dir entirely (a2hmarket-exclusive)
|
|
525
|
+
if (existsSync(A2H_STORE_DIR)) {
|
|
526
|
+
try {
|
|
527
|
+
execSync(`rm -rf "${A2H_STORE_DIR}"`, { stdio: "pipe" });
|
|
528
|
+
log(` ${CHECK} Removed: ${A2H_STORE_DIR}`);
|
|
529
|
+
} catch {
|
|
530
|
+
log(` ${WARN} Failed to remove: ${A2H_STORE_DIR}`);
|
|
523
531
|
}
|
|
524
532
|
}
|
|
525
533
|
|
|
@@ -876,7 +884,7 @@ async function main() {
|
|
|
876
884
|
log(` ${WARN} Could not write to openclaw.json: ${err.message}`);
|
|
877
885
|
}
|
|
878
886
|
|
|
879
|
-
// Also save fallback file to ~/.openclaw/credentials/
|
|
887
|
+
// Also save fallback file to ~/.openclaw/credentials/a2h_credentials.json
|
|
880
888
|
writeFileSync(CREDS_FILE, JSON.stringify(credsData, null, 2) + "\n");
|
|
881
889
|
log(` ${CHECK} Fallback credentials saved to ${CREDS_DIR}`);
|
|
882
890
|
|
|
@@ -22,7 +22,7 @@ import { createInterface } from 'readline';
|
|
|
22
22
|
|
|
23
23
|
const KEYCHAIN_SERVICE = 'a2hmarket-tempo';
|
|
24
24
|
// Try new path first, fallback to legacy
|
|
25
|
-
const CREDS_NEW = join(homedir(), '.openclaw', 'credentials', '
|
|
25
|
+
const CREDS_NEW = join(homedir(), '.openclaw', 'credentials', 'a2h_credentials.json');
|
|
26
26
|
const CREDS_LEGACY = join(homedir(), '.openclaw', 'a2hmarket', 'credentials.json');
|
|
27
27
|
const CREDS_PATH = existsSync(CREDS_NEW) ? CREDS_NEW : CREDS_LEGACY;
|
|
28
28
|
|
package/src/credentials.ts
CHANGED
|
@@ -54,7 +54,8 @@ export function loadCredentialsFromConfig(
|
|
|
54
54
|
const PLUGIN_DIR = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
55
55
|
const OPENCLAW_CREDS_DIR = join(homedir(), ".openclaw", "credentials");
|
|
56
56
|
const LEGACY_CREDS_DIR = join(homedir(), ".openclaw", "a2hmarket");
|
|
57
|
-
const
|
|
57
|
+
const A2H_CREDENTIALS_FILE = "a2h_credentials.json";
|
|
58
|
+
const LEGACY_CREDENTIALS_FILE = "credentials.json";
|
|
58
59
|
|
|
59
60
|
interface RawCredentials {
|
|
60
61
|
agent_id?: string;
|
|
@@ -70,23 +71,24 @@ interface RawCredentials {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export function loadCredentialsFromFile(configDir?: string): A2HCredentials {
|
|
73
|
-
let
|
|
74
|
+
let filePath: string;
|
|
74
75
|
if (configDir) {
|
|
75
|
-
|
|
76
|
+
// configDir provided: try a2h_credentials.json first, fall back to credentials.json
|
|
77
|
+
const a2hPath = join(configDir, A2H_CREDENTIALS_FILE);
|
|
78
|
+
filePath = existsSync(a2hPath) ? a2hPath : join(configDir, LEGACY_CREDENTIALS_FILE);
|
|
76
79
|
} else {
|
|
77
|
-
// Priority: ~/.openclaw/credentials/ > ~/.openclaw/a2hmarket/ (legacy) > plugin dir
|
|
78
|
-
const credsPath = join(OPENCLAW_CREDS_DIR,
|
|
79
|
-
const legacyPath = join(LEGACY_CREDS_DIR,
|
|
80
|
-
const pluginPath = join(PLUGIN_DIR,
|
|
81
|
-
|
|
82
|
-
?
|
|
80
|
+
// Priority: ~/.openclaw/credentials/a2h_credentials.json > ~/.openclaw/a2hmarket/credentials.json (legacy) > plugin dir credentials.json
|
|
81
|
+
const credsPath = join(OPENCLAW_CREDS_DIR, A2H_CREDENTIALS_FILE);
|
|
82
|
+
const legacyPath = join(LEGACY_CREDS_DIR, LEGACY_CREDENTIALS_FILE);
|
|
83
|
+
const pluginPath = join(PLUGIN_DIR, LEGACY_CREDENTIALS_FILE);
|
|
84
|
+
filePath = existsSync(credsPath)
|
|
85
|
+
? credsPath
|
|
83
86
|
: existsSync(legacyPath)
|
|
84
|
-
?
|
|
87
|
+
? legacyPath
|
|
85
88
|
: existsSync(pluginPath)
|
|
86
|
-
?
|
|
87
|
-
:
|
|
89
|
+
? pluginPath
|
|
90
|
+
: credsPath; // default: will throw with helpful error
|
|
88
91
|
}
|
|
89
|
-
const filePath = join(dir, CREDENTIALS_FILE);
|
|
90
92
|
|
|
91
93
|
let raw: RawCredentials;
|
|
92
94
|
try {
|