xgen-dex-cli 1.2.1 → 1.2.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/dist/chunks/{chunk-QXSCKZEG.js → chunk-GS2Q7ZZA.js} +101 -27
- package/dist/chunks/{chunk-QXSCKZEG.js.map → chunk-GS2Q7ZZA.js.map} +3 -3
- package/dist/chunks/{tui-DMHUMWPG.js → tui-PNFWGJTJ.js} +2 -2
- package/dist/cli.js +18 -11
- package/dist/cli.js.map +2 -2
- package/package.json +4 -2
- /package/dist/chunks/{tui-DMHUMWPG.js.map → tui-PNFWGJTJ.js.map} +0 -0
|
@@ -4437,21 +4437,103 @@ var DexEngine = class {
|
|
|
4437
4437
|
};
|
|
4438
4438
|
|
|
4439
4439
|
// ../../packages/engine/src/credential-store.ts
|
|
4440
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4441
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
4440
4442
|
var SERVICE = "xgen-dex-cli";
|
|
4441
4443
|
var ACCOUNT_PREFIX = "profile:";
|
|
4444
|
+
var activeBackend = "file";
|
|
4445
|
+
function credentialBackend() {
|
|
4446
|
+
return activeBackend;
|
|
4447
|
+
}
|
|
4448
|
+
var keytarProbe = null;
|
|
4449
|
+
var KEYCHAIN_TIMEOUT_MS = 2e3;
|
|
4450
|
+
async function withTimeout2(work) {
|
|
4451
|
+
let timer;
|
|
4452
|
+
try {
|
|
4453
|
+
return await Promise.race([
|
|
4454
|
+
work,
|
|
4455
|
+
new Promise((_, reject) => {
|
|
4456
|
+
timer = setTimeout(() => reject(new Error("keychain timeout")), KEYCHAIN_TIMEOUT_MS);
|
|
4457
|
+
timer.unref?.();
|
|
4458
|
+
})
|
|
4459
|
+
]);
|
|
4460
|
+
} finally {
|
|
4461
|
+
if (timer) clearTimeout(timer);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4442
4464
|
async function loadKeytar() {
|
|
4465
|
+
keytarProbe ??= (async () => {
|
|
4466
|
+
if (process.env.DEX_NO_KEYCHAIN === "1") return null;
|
|
4467
|
+
try {
|
|
4468
|
+
const loaded = await import("keytar");
|
|
4469
|
+
const keytar2 = loaded.default ?? loaded;
|
|
4470
|
+
if (!keytar2.getPassword || !keytar2.setPassword || !keytar2.deletePassword) return null;
|
|
4471
|
+
await withTimeout2(keytar2.getPassword(SERVICE, "__probe__"));
|
|
4472
|
+
return keytar2;
|
|
4473
|
+
} catch {
|
|
4474
|
+
return null;
|
|
4475
|
+
}
|
|
4476
|
+
})();
|
|
4477
|
+
const keytar = await keytarProbe;
|
|
4478
|
+
activeBackend = keytar ? "keychain" : "file";
|
|
4479
|
+
return keytar;
|
|
4480
|
+
}
|
|
4481
|
+
function filePath() {
|
|
4482
|
+
return join3(dataDirectory(), "credentials.json");
|
|
4483
|
+
}
|
|
4484
|
+
function readFileStore() {
|
|
4443
4485
|
try {
|
|
4444
|
-
const
|
|
4445
|
-
const
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4486
|
+
const raw = readFileSync(filePath(), "utf8");
|
|
4487
|
+
const parsed = JSON.parse(raw);
|
|
4488
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
4489
|
+
} catch {
|
|
4490
|
+
return {};
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
function writeFileStore(values) {
|
|
4494
|
+
const path = filePath();
|
|
4495
|
+
mkdirSync(dirname3(path), { recursive: true });
|
|
4496
|
+
const tmp = `${path}.tmp`;
|
|
4497
|
+
writeFileSync(tmp, JSON.stringify(values, null, 2), { encoding: "utf8", mode: 384 });
|
|
4498
|
+
try {
|
|
4499
|
+
chmodSync(tmp, 384);
|
|
4500
|
+
} catch {
|
|
4501
|
+
}
|
|
4502
|
+
renameSync(tmp, path);
|
|
4503
|
+
}
|
|
4504
|
+
async function secretGet(account) {
|
|
4505
|
+
const keytar = await loadKeytar();
|
|
4506
|
+
if (keytar) {
|
|
4507
|
+
try {
|
|
4508
|
+
return await withTimeout2(keytar.getPassword(SERVICE, account));
|
|
4509
|
+
} catch {
|
|
4510
|
+
}
|
|
4454
4511
|
}
|
|
4512
|
+
return readFileStore()[account] ?? null;
|
|
4513
|
+
}
|
|
4514
|
+
async function secretSet(account, value) {
|
|
4515
|
+
const keytar = await loadKeytar();
|
|
4516
|
+
if (keytar) {
|
|
4517
|
+
try {
|
|
4518
|
+
if (value === null) await withTimeout2(keytar.deletePassword(SERVICE, account));
|
|
4519
|
+
else await withTimeout2(keytar.setPassword(SERVICE, account, value));
|
|
4520
|
+
return;
|
|
4521
|
+
} catch {
|
|
4522
|
+
activeBackend = "file";
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
const values = readFileStore();
|
|
4526
|
+
if (value === null) delete values[account];
|
|
4527
|
+
else values[account] = value;
|
|
4528
|
+
if (Object.keys(values).length === 0 && existsSync(filePath())) {
|
|
4529
|
+
try {
|
|
4530
|
+
unlinkSync(filePath());
|
|
4531
|
+
} catch {
|
|
4532
|
+
writeFileStore(values);
|
|
4533
|
+
}
|
|
4534
|
+
return;
|
|
4535
|
+
}
|
|
4536
|
+
writeFileStore(values);
|
|
4455
4537
|
}
|
|
4456
4538
|
function parseSession(raw) {
|
|
4457
4539
|
if (!raw) return null;
|
|
@@ -4463,7 +4545,7 @@ function parseSession(raw) {
|
|
|
4463
4545
|
return null;
|
|
4464
4546
|
}
|
|
4465
4547
|
}
|
|
4466
|
-
var
|
|
4548
|
+
var SystemCredentialStore = class {
|
|
4467
4549
|
/**
|
|
4468
4550
|
* 엔진의 `SecretPort` 로 내보내는 두 함수 — 프로파일 세션 말고 **임의의 비밀**
|
|
4469
4551
|
* (MCP 서버 시크릿 · OAuth 상태)을 같은 백엔드에 둔다.
|
|
@@ -4472,29 +4554,20 @@ var KeytarCredentialStore = class {
|
|
|
4472
4554
|
* 하나의 질문이고, 두 곳에 나뉘면 로그아웃할 때 한쪽이 남는다.
|
|
4473
4555
|
*/
|
|
4474
4556
|
async getRaw(name) {
|
|
4475
|
-
|
|
4476
|
-
return keytar.getPassword(SERVICE, name);
|
|
4557
|
+
return secretGet(name);
|
|
4477
4558
|
}
|
|
4478
4559
|
async setRaw(name, value) {
|
|
4479
|
-
|
|
4480
|
-
if (value === null) {
|
|
4481
|
-
await keytar.deletePassword(SERVICE, name);
|
|
4482
|
-
return true;
|
|
4483
|
-
}
|
|
4484
|
-
await keytar.setPassword(SERVICE, name, value);
|
|
4560
|
+
await secretSet(name, value);
|
|
4485
4561
|
return true;
|
|
4486
4562
|
}
|
|
4487
4563
|
async get(profile) {
|
|
4488
|
-
|
|
4489
|
-
return parseSession(await keytar.getPassword(SERVICE, ACCOUNT_PREFIX + profile));
|
|
4564
|
+
return parseSession(await secretGet(ACCOUNT_PREFIX + profile));
|
|
4490
4565
|
}
|
|
4491
4566
|
async set(profile, session) {
|
|
4492
|
-
|
|
4493
|
-
await keytar.setPassword(SERVICE, ACCOUNT_PREFIX + profile, JSON.stringify(session));
|
|
4567
|
+
await secretSet(ACCOUNT_PREFIX + profile, JSON.stringify(session));
|
|
4494
4568
|
}
|
|
4495
4569
|
async delete(profile) {
|
|
4496
|
-
|
|
4497
|
-
await keytar.deletePassword(SERVICE, ACCOUNT_PREFIX + profile);
|
|
4570
|
+
await secretSet(ACCOUNT_PREFIX + profile, null);
|
|
4498
4571
|
}
|
|
4499
4572
|
};
|
|
4500
4573
|
|
|
@@ -4555,6 +4628,7 @@ export {
|
|
|
4555
4628
|
dataDirectory,
|
|
4556
4629
|
FileConfigStore,
|
|
4557
4630
|
DexEngine,
|
|
4558
|
-
|
|
4631
|
+
credentialBackend,
|
|
4632
|
+
SystemCredentialStore
|
|
4559
4633
|
};
|
|
4560
|
-
//# sourceMappingURL=chunk-
|
|
4634
|
+
//# sourceMappingURL=chunk-GS2Q7ZZA.js.map
|