@candledottv/cli 0.13.13 → 0.13.14
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/index.js +216 -119
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -526,7 +526,7 @@ var init_terminal_theme = __esm(() => {
|
|
|
526
526
|
});
|
|
527
527
|
|
|
528
528
|
// src/version.ts
|
|
529
|
-
var CLI_VERSION = "0.13.
|
|
529
|
+
var CLI_VERSION = "0.13.14";
|
|
530
530
|
|
|
531
531
|
// src/presentation.ts
|
|
532
532
|
function terminalStyle(deps, stream, machine = false) {
|
|
@@ -13886,6 +13886,7 @@ __export(exports_store, {
|
|
|
13886
13886
|
readVaultRaw: () => readVaultRaw,
|
|
13887
13887
|
ownSecret: () => ownSecret,
|
|
13888
13888
|
legacyWalletsPath: () => legacyWalletsPath,
|
|
13889
|
+
inspectConfigDir: () => inspectConfigDir,
|
|
13889
13890
|
freshVaultId: () => freshVaultId,
|
|
13890
13891
|
freshKeyId: () => freshKeyId,
|
|
13891
13892
|
freshEnvelopeId: () => freshEnvelopeId,
|
|
@@ -13900,8 +13901,8 @@ __export(exports_store, {
|
|
|
13900
13901
|
candleConfigDir: () => candleConfigDir,
|
|
13901
13902
|
CONFIG_DIR_ENV: () => CONFIG_DIR_ENV
|
|
13902
13903
|
});
|
|
13903
|
-
import { chmod as chmod3, mkdir as mkdir3, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
13904
|
-
import { join as join3 } from "node:path";
|
|
13904
|
+
import { access, chmod as chmod3, constants, mkdir as mkdir3, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
13905
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
13905
13906
|
function candleConfigDir(env, home) {
|
|
13906
13907
|
const configured = env.CANDLE_CONFIG_DIR?.trim();
|
|
13907
13908
|
if (configured) {
|
|
@@ -13935,6 +13936,48 @@ async function fileExists(path) {
|
|
|
13935
13936
|
return false;
|
|
13936
13937
|
}
|
|
13937
13938
|
}
|
|
13939
|
+
function errnoOf(error) {
|
|
13940
|
+
return error?.code ?? "UNKNOWN";
|
|
13941
|
+
}
|
|
13942
|
+
async function writableDir(path) {
|
|
13943
|
+
try {
|
|
13944
|
+
await access(path, constants.W_OK | constants.X_OK);
|
|
13945
|
+
return;
|
|
13946
|
+
} catch (error) {
|
|
13947
|
+
return errnoOf(error);
|
|
13948
|
+
}
|
|
13949
|
+
}
|
|
13950
|
+
async function inspectConfigDir(path) {
|
|
13951
|
+
try {
|
|
13952
|
+
const stats = await stat2(path);
|
|
13953
|
+
if (!stats.isDirectory())
|
|
13954
|
+
return { state: "unwritable", errno: "ENOTDIR" };
|
|
13955
|
+
const errno = await writableDir(path);
|
|
13956
|
+
return errno === undefined ? { state: "present" } : { state: "unwritable", errno };
|
|
13957
|
+
} catch (error) {
|
|
13958
|
+
const code = errnoOf(error);
|
|
13959
|
+
if (code !== "ENOENT" && code !== "ENOTDIR")
|
|
13960
|
+
return { state: "unwritable", errno: code };
|
|
13961
|
+
}
|
|
13962
|
+
let ancestor = path;
|
|
13963
|
+
for (;; ) {
|
|
13964
|
+
const parent = dirname3(ancestor);
|
|
13965
|
+
if (parent === ancestor)
|
|
13966
|
+
return { state: "unwritable", errno: "ENOENT", ancestor };
|
|
13967
|
+
ancestor = parent;
|
|
13968
|
+
try {
|
|
13969
|
+
const stats = await stat2(ancestor);
|
|
13970
|
+
if (!stats.isDirectory())
|
|
13971
|
+
return { state: "unwritable", errno: "ENOTDIR", ancestor };
|
|
13972
|
+
const errno = await writableDir(ancestor);
|
|
13973
|
+
return errno === undefined ? { state: "missing", ancestor } : { state: "unwritable", errno, ancestor };
|
|
13974
|
+
} catch (error) {
|
|
13975
|
+
const code = errnoOf(error);
|
|
13976
|
+
if (code !== "ENOENT" && code !== "ENOTDIR")
|
|
13977
|
+
return { state: "unwritable", errno: code };
|
|
13978
|
+
}
|
|
13979
|
+
}
|
|
13980
|
+
}
|
|
13938
13981
|
function closeVault(vault) {
|
|
13939
13982
|
wipe(vault.dek);
|
|
13940
13983
|
}
|
|
@@ -14336,8 +14379,20 @@ var init_ownership = __esm(() => {
|
|
|
14336
14379
|
});
|
|
14337
14380
|
|
|
14338
14381
|
// src/file-lock.ts
|
|
14339
|
-
import { open as open2, rm as rm2, stat as stat4 } from "node:fs/promises";
|
|
14382
|
+
import { chmod as chmod5, mkdir as mkdir5, open as open2, rm as rm2, stat as stat4 } from "node:fs/promises";
|
|
14383
|
+
import { dirname as dirname4 } from "node:path";
|
|
14384
|
+
function unwritable(dir, error) {
|
|
14385
|
+
return new ConfigDirUnwritableError(dir, error?.code ?? "UNKNOWN", error);
|
|
14386
|
+
}
|
|
14340
14387
|
async function withFileLock(target, fn) {
|
|
14388
|
+
const dir = dirname4(target);
|
|
14389
|
+
try {
|
|
14390
|
+
const created = await mkdir5(dir, { recursive: true });
|
|
14391
|
+
if (created !== undefined)
|
|
14392
|
+
await chmod5(dir, 448);
|
|
14393
|
+
} catch (error) {
|
|
14394
|
+
throw unwritable(dir, error);
|
|
14395
|
+
}
|
|
14341
14396
|
const lockPath = `${target}.lock`;
|
|
14342
14397
|
const deadline = Date.now() + TIMEOUT_MS;
|
|
14343
14398
|
for (;; ) {
|
|
@@ -14346,7 +14401,7 @@ async function withFileLock(target, fn) {
|
|
|
14346
14401
|
break;
|
|
14347
14402
|
} catch (error) {
|
|
14348
14403
|
if (error.code !== "EEXIST")
|
|
14349
|
-
throw error;
|
|
14404
|
+
throw unwritable(dir, error);
|
|
14350
14405
|
const age = await stat4(lockPath).then((s) => Date.now() - s.mtimeMs).catch(() => 0);
|
|
14351
14406
|
if (age > STALE_MS) {
|
|
14352
14407
|
await rm2(lockPath, { force: true });
|
|
@@ -14364,13 +14419,27 @@ async function withFileLock(target, fn) {
|
|
|
14364
14419
|
await rm2(lockPath, { force: true });
|
|
14365
14420
|
}
|
|
14366
14421
|
}
|
|
14367
|
-
var STALE_MS = 30000, RETRY_MS = 25, TIMEOUT_MS = 1e4;
|
|
14368
|
-
var init_file_lock = () => {
|
|
14422
|
+
var STALE_MS = 30000, RETRY_MS = 25, TIMEOUT_MS = 1e4, CONFIG_DIR_UNWRITABLE = "CONFIG_DIR_UNWRITABLE", ConfigDirUnwritableError;
|
|
14423
|
+
var init_file_lock = __esm(() => {
|
|
14424
|
+
ConfigDirUnwritableError = class ConfigDirUnwritableError extends Error {
|
|
14425
|
+
path;
|
|
14426
|
+
errno;
|
|
14427
|
+
code = CONFIG_DIR_UNWRITABLE;
|
|
14428
|
+
suggestion;
|
|
14429
|
+
constructor(path, errno, cause) {
|
|
14430
|
+
super(errno === "ENOTDIR" || errno === "EEXIST" ? `${path} or one of its parents is not a directory (${errno}).` : `Cannot write the Candle config directory ${path} (${errno}).`, { cause });
|
|
14431
|
+
this.path = path;
|
|
14432
|
+
this.errno = errno;
|
|
14433
|
+
this.name = "ConfigDirUnwritableError";
|
|
14434
|
+
this.suggestion = `Fix: as the user that runs candle, run mkdir -m 700 ${path}, or set CANDLE_CONFIG_DIR to a directory that user can write.`;
|
|
14435
|
+
}
|
|
14436
|
+
};
|
|
14437
|
+
});
|
|
14369
14438
|
|
|
14370
14439
|
// src/secret-store.ts
|
|
14371
|
-
import { chmod as
|
|
14440
|
+
import { chmod as chmod6, mkdir as mkdir6, readFile as readFile5, rename as rename3, writeFile as writeFile3 } from "node:fs/promises";
|
|
14372
14441
|
import { homedir } from "node:os";
|
|
14373
|
-
import { dirname as
|
|
14442
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
14374
14443
|
function walletSignerRef(walletId) {
|
|
14375
14444
|
return `wallet_signer_${walletId}`;
|
|
14376
14445
|
}
|
|
@@ -14488,12 +14557,12 @@ class EncryptedFileSecretStore {
|
|
|
14488
14557
|
}
|
|
14489
14558
|
}
|
|
14490
14559
|
async writeContents(contents) {
|
|
14491
|
-
const dir =
|
|
14492
|
-
await
|
|
14493
|
-
await
|
|
14560
|
+
const dir = dirname5(this.path);
|
|
14561
|
+
await mkdir6(dir, { recursive: true });
|
|
14562
|
+
await chmod6(dir, 448);
|
|
14494
14563
|
const tmpPath = `${this.path}.${crypto.randomUUID()}.tmp`;
|
|
14495
14564
|
await writeFile3(tmpPath, JSON.stringify(contents, null, 2), { encoding: "utf8", mode: 384 });
|
|
14496
|
-
await
|
|
14565
|
+
await chmod6(tmpPath, 384);
|
|
14497
14566
|
await rename3(tmpPath, this.path);
|
|
14498
14567
|
}
|
|
14499
14568
|
}
|
|
@@ -15075,7 +15144,7 @@ var init_solana_endpoint = __esm(() => {
|
|
|
15075
15144
|
|
|
15076
15145
|
// src/trading.ts
|
|
15077
15146
|
import { createHash as createHash2, sign as sign2 } from "node:crypto";
|
|
15078
|
-
import { mkdir as
|
|
15147
|
+
import { mkdir as mkdir7, open as open3, readFile as readFile6, rename as rename4, writeFile as writeFile4 } from "node:fs/promises";
|
|
15079
15148
|
import { homedir as homedir2 } from "node:os";
|
|
15080
15149
|
import { join as join6 } from "node:path";
|
|
15081
15150
|
function baseAsset(value) {
|
|
@@ -15537,7 +15606,7 @@ async function savedOperation(ctx, key, id) {
|
|
|
15537
15606
|
}
|
|
15538
15607
|
async function claimOperation(ctx, key, id, kind) {
|
|
15539
15608
|
const path = operationPath(ctx, key, id);
|
|
15540
|
-
await
|
|
15609
|
+
await mkdir7(join6(path, ".."), { recursive: true, mode: 448 });
|
|
15541
15610
|
let file;
|
|
15542
15611
|
try {
|
|
15543
15612
|
file = await open3(path, "wx", 384);
|
|
@@ -19767,8 +19836,8 @@ var init_ecies = __esm(() => {
|
|
|
19767
19836
|
});
|
|
19768
19837
|
|
|
19769
19838
|
// src/vault/enclave.ts
|
|
19770
|
-
import { access, constants } from "node:fs/promises";
|
|
19771
|
-
import { dirname as
|
|
19839
|
+
import { access as access2, constants as constants2 } from "node:fs/promises";
|
|
19840
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
19772
19841
|
function parseReleasePolicy(value) {
|
|
19773
19842
|
const bad = (detail) => {
|
|
19774
19843
|
throw new Error(`release-policy.json is malformed: ${detail}`);
|
|
@@ -19795,7 +19864,7 @@ function parseReleasePolicy(value) {
|
|
|
19795
19864
|
}
|
|
19796
19865
|
async function isExecutable(path) {
|
|
19797
19866
|
try {
|
|
19798
|
-
await
|
|
19867
|
+
await access2(path, constants2.X_OK);
|
|
19799
19868
|
return true;
|
|
19800
19869
|
} catch {
|
|
19801
19870
|
return false;
|
|
@@ -19824,10 +19893,10 @@ async function locateEnclaveHelper(deps) {
|
|
|
19824
19893
|
reason: `this CLI is running from the npm package (or a source checkout), which ships no ${ENCLAVE_BUNDLE_NAME}`
|
|
19825
19894
|
};
|
|
19826
19895
|
}
|
|
19827
|
-
const beside = await asBundle(join7(
|
|
19896
|
+
const beside = await asBundle(join7(dirname6(realExec), ENCLAVE_BUNDLE_NAME));
|
|
19828
19897
|
if (beside)
|
|
19829
19898
|
return { state: "ready", ...beside, source: "beside-binary" };
|
|
19830
|
-
const libexec = await asBundle(join7(
|
|
19899
|
+
const libexec = await asBundle(join7(dirname6(dirname6(realExec)), "libexec", ENCLAVE_BUNDLE_NAME));
|
|
19831
19900
|
if (libexec)
|
|
19832
19901
|
return { state: "ready", ...libexec, source: "libexec" };
|
|
19833
19902
|
return { state: "absent", reason: `no ${ENCLAVE_BUNDLE_NAME} beside ${realExec} or in its libexec` };
|
|
@@ -20352,11 +20421,11 @@ var init_platform = __esm(() => {
|
|
|
20352
20421
|
});
|
|
20353
20422
|
|
|
20354
20423
|
// src/vault/fido2.ts
|
|
20355
|
-
import { access as
|
|
20356
|
-
import { dirname as
|
|
20424
|
+
import { access as access3, constants as constants3 } from "node:fs/promises";
|
|
20425
|
+
import { dirname as dirname7, join as join8 } from "node:path";
|
|
20357
20426
|
async function isExecutable2(path) {
|
|
20358
20427
|
try {
|
|
20359
|
-
await
|
|
20428
|
+
await access3(path, constants3.X_OK);
|
|
20360
20429
|
return true;
|
|
20361
20430
|
} catch {
|
|
20362
20431
|
return false;
|
|
@@ -20381,7 +20450,7 @@ async function locateFido2Helper(deps) {
|
|
|
20381
20450
|
installable: false
|
|
20382
20451
|
};
|
|
20383
20452
|
}
|
|
20384
|
-
const beside = join8(
|
|
20453
|
+
const beside = join8(dirname7(realExec), HELPER_NAME);
|
|
20385
20454
|
if (await isExecutable2(beside))
|
|
20386
20455
|
return { state: "ready", path: beside, source: "beside-binary" };
|
|
20387
20456
|
return { state: "absent", reason: `no ${HELPER_NAME} executable beside ${realExec}`, installable: true };
|
|
@@ -28923,7 +28992,7 @@ __export(exports_vault_support, {
|
|
|
28923
28992
|
askForOwnPassphrase: () => askForOwnPassphrase,
|
|
28924
28993
|
PASSPHRASE_ONLY_PREFIX: () => PASSPHRASE_ONLY_PREFIX
|
|
28925
28994
|
});
|
|
28926
|
-
import { dirname as
|
|
28995
|
+
import { dirname as dirname8, resolve as resolvePath } from "node:path";
|
|
28927
28996
|
function refuseEnvPassphrase(ctx) {
|
|
28928
28997
|
if (ctx.deps.env.CANDLE_KEYSTORE_PASSPHRASE === undefined)
|
|
28929
28998
|
return true;
|
|
@@ -29012,7 +29081,7 @@ function nonDefaultVaultFooter(resolved) {
|
|
|
29012
29081
|
if (resolved.source !== "flag")
|
|
29013
29082
|
return;
|
|
29014
29083
|
return `
|
|
29015
|
-
This vault is at ${resolved.path}, not the default location. Every vault command needs -k ${resolved.path}, or set it once: export ${CONFIG_DIR_ENV}=${
|
|
29084
|
+
This vault is at ${resolved.path}, not the default location. Every vault command needs -k ${resolved.path}, or set it once: export ${CONFIG_DIR_ENV}=${dirname8(resolved.path)}
|
|
29016
29085
|
`;
|
|
29017
29086
|
}
|
|
29018
29087
|
async function requireVaultRaw(ctx, resolved) {
|
|
@@ -29933,7 +30002,7 @@ var init_tee_lookup = __esm(() => {
|
|
|
29933
30002
|
});
|
|
29934
30003
|
|
|
29935
30004
|
// src/vault/tee-resolve.ts
|
|
29936
|
-
async function resolveTeeAddress(ctx, _parsed, address, openLegacy,
|
|
30005
|
+
async function resolveTeeAddress(ctx, _parsed, address, openLegacy, access4 = "read") {
|
|
29937
30006
|
try {
|
|
29938
30007
|
const hit = await findTeeInVault(ctx, address);
|
|
29939
30008
|
if (hit.hit) {
|
|
@@ -29949,7 +30018,7 @@ async function resolveTeeAddress(ctx, _parsed, address, openLegacy, access3 = "r
|
|
|
29949
30018
|
closeVault(hit.vault);
|
|
29950
30019
|
return { ok: false, code: 1 };
|
|
29951
30020
|
}
|
|
29952
|
-
if (
|
|
30021
|
+
if (access4 === "sign")
|
|
29953
30022
|
privateKeyBase58 = base58.encode(secret);
|
|
29954
30023
|
} finally {
|
|
29955
30024
|
wipe(secret);
|
|
@@ -35331,8 +35400,8 @@ async function commitActiveTee(active, mutate) {
|
|
|
35331
35400
|
};
|
|
35332
35401
|
}
|
|
35333
35402
|
}
|
|
35334
|
-
async function openActiveTee(ctx, parsed, address,
|
|
35335
|
-
const resolved = await resolveTeeAddress(ctx, parsed, address, () => openExistingTeeStore(ctx, parsed),
|
|
35403
|
+
async function openActiveTee(ctx, parsed, address, access4) {
|
|
35404
|
+
const resolved = await resolveTeeAddress(ctx, parsed, address, () => openExistingTeeStore(ctx, parsed), access4);
|
|
35336
35405
|
if (!resolved.ok)
|
|
35337
35406
|
return { ok: false, code: resolved.code };
|
|
35338
35407
|
if (resolved.resolved.source === "vault")
|
|
@@ -37935,10 +38004,10 @@ function labelCell(label) {
|
|
|
37935
38004
|
return cleaned.replace(/\s+/g, " ").trim();
|
|
37936
38005
|
}
|
|
37937
38006
|
function accessCell(scopes, missing = "–") {
|
|
37938
|
-
const
|
|
37939
|
-
if (
|
|
37940
|
-
return
|
|
37941
|
-
const words = agentKeyAccessWords(
|
|
38007
|
+
const access4 = agentKeyAccess(scopes);
|
|
38008
|
+
if (access4.kind === "preset")
|
|
38009
|
+
return access4.label;
|
|
38010
|
+
const words = agentKeyAccessWords(access4);
|
|
37942
38011
|
return words.length > 0 ? words.join(", ") : missing;
|
|
37943
38012
|
}
|
|
37944
38013
|
async function keysList(args, ctx) {
|
|
@@ -38575,9 +38644,9 @@ var init_convert = __esm(() => {
|
|
|
38575
38644
|
});
|
|
38576
38645
|
|
|
38577
38646
|
// ../mcp/src/image.ts
|
|
38578
|
-
import { constants as
|
|
38647
|
+
import { constants as constants4 } from "node:fs";
|
|
38579
38648
|
import { lstat, open as open5, realpath } from "node:fs/promises";
|
|
38580
|
-
import { dirname as
|
|
38649
|
+
import { dirname as dirname9, isAbsolute, relative, sep } from "node:path";
|
|
38581
38650
|
function configuredImageDir(env) {
|
|
38582
38651
|
return env.CANDLE_IMAGE_DIR?.trim() || undefined;
|
|
38583
38652
|
}
|
|
@@ -38606,7 +38675,7 @@ async function realImageDir(imageDir, fs) {
|
|
|
38606
38675
|
throw invalid();
|
|
38607
38676
|
try {
|
|
38608
38677
|
const real = await fs.realpath(imageDir);
|
|
38609
|
-
if (
|
|
38678
|
+
if (dirname9(real) === real || !(await fs.lstat(real, { bigint: true })).isDirectory())
|
|
38610
38679
|
throw invalid();
|
|
38611
38680
|
return real;
|
|
38612
38681
|
} catch {
|
|
@@ -38623,7 +38692,7 @@ async function missingInside(dirReal, path, fs) {
|
|
|
38623
38692
|
if (!absent(error))
|
|
38624
38693
|
return false;
|
|
38625
38694
|
}
|
|
38626
|
-
const parent =
|
|
38695
|
+
const parent = dirname9(current);
|
|
38627
38696
|
if (parent === current)
|
|
38628
38697
|
return false;
|
|
38629
38698
|
try {
|
|
@@ -38653,7 +38722,7 @@ async function readImageInDir(imageDir, imagePath, fs = nodeFs, field = "imagePa
|
|
|
38653
38722
|
throw outside();
|
|
38654
38723
|
let handle;
|
|
38655
38724
|
try {
|
|
38656
|
-
handle = await fs.open(fileReal,
|
|
38725
|
+
handle = await fs.open(fileReal, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0) | (constants4.O_NONBLOCK ?? 0));
|
|
38657
38726
|
} catch (error) {
|
|
38658
38727
|
throw errno(error) === "ELOOP" ? outside() : unreadable2("it could not be opened");
|
|
38659
38728
|
}
|
|
@@ -47312,11 +47381,11 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47312
47381
|
const rhs = this.rhs === undefined ? "" : ` = ${this.rhs}`;
|
|
47313
47382
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
47314
47383
|
}
|
|
47315
|
-
optimizeNames(names,
|
|
47384
|
+
optimizeNames(names, constants5) {
|
|
47316
47385
|
if (!names[this.name.str])
|
|
47317
47386
|
return;
|
|
47318
47387
|
if (this.rhs)
|
|
47319
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
47388
|
+
this.rhs = optimizeExpr(this.rhs, names, constants5);
|
|
47320
47389
|
return this;
|
|
47321
47390
|
}
|
|
47322
47391
|
get names() {
|
|
@@ -47334,10 +47403,10 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47334
47403
|
render({ _n }) {
|
|
47335
47404
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
47336
47405
|
}
|
|
47337
|
-
optimizeNames(names,
|
|
47406
|
+
optimizeNames(names, constants5) {
|
|
47338
47407
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
47339
47408
|
return;
|
|
47340
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
47409
|
+
this.rhs = optimizeExpr(this.rhs, names, constants5);
|
|
47341
47410
|
return this;
|
|
47342
47411
|
}
|
|
47343
47412
|
get names() {
|
|
@@ -47403,8 +47472,8 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47403
47472
|
optimizeNodes() {
|
|
47404
47473
|
return `${this.code}` ? this : undefined;
|
|
47405
47474
|
}
|
|
47406
|
-
optimizeNames(names,
|
|
47407
|
-
this.code = optimizeExpr(this.code, names,
|
|
47475
|
+
optimizeNames(names, constants5) {
|
|
47476
|
+
this.code = optimizeExpr(this.code, names, constants5);
|
|
47408
47477
|
return this;
|
|
47409
47478
|
}
|
|
47410
47479
|
get names() {
|
|
@@ -47434,12 +47503,12 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47434
47503
|
}
|
|
47435
47504
|
return nodes.length > 0 ? this : undefined;
|
|
47436
47505
|
}
|
|
47437
|
-
optimizeNames(names,
|
|
47506
|
+
optimizeNames(names, constants5) {
|
|
47438
47507
|
const { nodes } = this;
|
|
47439
47508
|
let i = nodes.length;
|
|
47440
47509
|
while (i--) {
|
|
47441
47510
|
const n = nodes[i];
|
|
47442
|
-
if (n.optimizeNames(names,
|
|
47511
|
+
if (n.optimizeNames(names, constants5))
|
|
47443
47512
|
continue;
|
|
47444
47513
|
subtractNames(names, n.names);
|
|
47445
47514
|
nodes.splice(i, 1);
|
|
@@ -47496,12 +47565,12 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47496
47565
|
return;
|
|
47497
47566
|
return this;
|
|
47498
47567
|
}
|
|
47499
|
-
optimizeNames(names,
|
|
47568
|
+
optimizeNames(names, constants5) {
|
|
47500
47569
|
var _a;
|
|
47501
|
-
this.else = (_a = this.else) === null || _a === undefined ? undefined : _a.optimizeNames(names,
|
|
47502
|
-
if (!(super.optimizeNames(names,
|
|
47570
|
+
this.else = (_a = this.else) === null || _a === undefined ? undefined : _a.optimizeNames(names, constants5);
|
|
47571
|
+
if (!(super.optimizeNames(names, constants5) || this.else))
|
|
47503
47572
|
return;
|
|
47504
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
47573
|
+
this.condition = optimizeExpr(this.condition, names, constants5);
|
|
47505
47574
|
return this;
|
|
47506
47575
|
}
|
|
47507
47576
|
get names() {
|
|
@@ -47526,10 +47595,10 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47526
47595
|
render(opts) {
|
|
47527
47596
|
return `for(${this.iteration})` + super.render(opts);
|
|
47528
47597
|
}
|
|
47529
|
-
optimizeNames(names,
|
|
47530
|
-
if (!super.optimizeNames(names,
|
|
47598
|
+
optimizeNames(names, constants5) {
|
|
47599
|
+
if (!super.optimizeNames(names, constants5))
|
|
47531
47600
|
return;
|
|
47532
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
47601
|
+
this.iteration = optimizeExpr(this.iteration, names, constants5);
|
|
47533
47602
|
return this;
|
|
47534
47603
|
}
|
|
47535
47604
|
get names() {
|
|
@@ -47567,10 +47636,10 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47567
47636
|
render(opts) {
|
|
47568
47637
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
47569
47638
|
}
|
|
47570
|
-
optimizeNames(names,
|
|
47571
|
-
if (!super.optimizeNames(names,
|
|
47639
|
+
optimizeNames(names, constants5) {
|
|
47640
|
+
if (!super.optimizeNames(names, constants5))
|
|
47572
47641
|
return;
|
|
47573
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
47642
|
+
this.iterable = optimizeExpr(this.iterable, names, constants5);
|
|
47574
47643
|
return this;
|
|
47575
47644
|
}
|
|
47576
47645
|
get names() {
|
|
@@ -47615,11 +47684,11 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47615
47684
|
(_b = this.finally) === null || _b === undefined || _b.optimizeNodes();
|
|
47616
47685
|
return this;
|
|
47617
47686
|
}
|
|
47618
|
-
optimizeNames(names,
|
|
47687
|
+
optimizeNames(names, constants5) {
|
|
47619
47688
|
var _a, _b;
|
|
47620
|
-
super.optimizeNames(names,
|
|
47621
|
-
(_a = this.catch) === null || _a === undefined || _a.optimizeNames(names,
|
|
47622
|
-
(_b = this.finally) === null || _b === undefined || _b.optimizeNames(names,
|
|
47689
|
+
super.optimizeNames(names, constants5);
|
|
47690
|
+
(_a = this.catch) === null || _a === undefined || _a.optimizeNames(names, constants5);
|
|
47691
|
+
(_b = this.finally) === null || _b === undefined || _b.optimizeNames(names, constants5);
|
|
47623
47692
|
return this;
|
|
47624
47693
|
}
|
|
47625
47694
|
get names() {
|
|
@@ -47893,7 +47962,7 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47893
47962
|
function addExprNames(names, from) {
|
|
47894
47963
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
47895
47964
|
}
|
|
47896
|
-
function optimizeExpr(expr, names,
|
|
47965
|
+
function optimizeExpr(expr, names, constants5) {
|
|
47897
47966
|
if (expr instanceof code_1.Name)
|
|
47898
47967
|
return replaceName(expr);
|
|
47899
47968
|
if (!canOptimize(expr))
|
|
@@ -47908,14 +47977,14 @@ var require_codegen = __commonJS((exports) => {
|
|
|
47908
47977
|
return items;
|
|
47909
47978
|
}, []));
|
|
47910
47979
|
function replaceName(n) {
|
|
47911
|
-
const c =
|
|
47980
|
+
const c = constants5[n.str];
|
|
47912
47981
|
if (c === undefined || names[n.str] !== 1)
|
|
47913
47982
|
return n;
|
|
47914
47983
|
delete names[n.str];
|
|
47915
47984
|
return c;
|
|
47916
47985
|
}
|
|
47917
47986
|
function canOptimize(e) {
|
|
47918
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
47987
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants5[c.str] !== undefined);
|
|
47919
47988
|
}
|
|
47920
47989
|
}
|
|
47921
47990
|
function subtractNames(names, from) {
|
|
@@ -73303,7 +73372,7 @@ Full reference, error catalogue and end-to-end recipes: https://docs.candle.tv
|
|
|
73303
73372
|
init_client();
|
|
73304
73373
|
import { spawn as spawn3 } from "node:child_process";
|
|
73305
73374
|
import { realpathSync } from "node:fs";
|
|
73306
|
-
import { chmod as
|
|
73375
|
+
import { chmod as chmod17, readFile as readFile20, realpath as realpath2, rename as rename16, unlink, writeFile as writeFile16 } from "node:fs/promises";
|
|
73307
73376
|
import { homedir as homedir6, hostname } from "node:os";
|
|
73308
73377
|
import { pathToFileURL } from "node:url";
|
|
73309
73378
|
|
|
@@ -79742,7 +79811,7 @@ async function acquireInstanceLock(input) {
|
|
|
79742
79811
|
}
|
|
79743
79812
|
|
|
79744
79813
|
// src/core/journal.ts
|
|
79745
|
-
import { chmod as
|
|
79814
|
+
import { chmod as chmod7, open as open7, readFile as readFile11 } from "node:fs/promises";
|
|
79746
79815
|
var RESERVED = new Set(["seq", "at", "environment", "profile"]);
|
|
79747
79816
|
|
|
79748
79817
|
class Journal {
|
|
@@ -79769,7 +79838,7 @@ class Journal {
|
|
|
79769
79838
|
throw new JournalIdentityError(`This journal holds rows for profile "${foreign.profile}" on ${foreign.environment}; this core is profile "${input.profile}" on ${input.environment}.`);
|
|
79770
79839
|
}
|
|
79771
79840
|
const handle = await open7(input.path, "a", 384);
|
|
79772
|
-
await
|
|
79841
|
+
await chmod7(input.path, 384);
|
|
79773
79842
|
const journal = new Journal(handle, input.redactor, { environment: input.environment, profile: input.profile }, input.now, history2);
|
|
79774
79843
|
if (history2.tornTail) {
|
|
79775
79844
|
await journal.raw(`
|
|
@@ -80488,7 +80557,7 @@ function withoutFactorValue(factor) {
|
|
|
80488
80557
|
// src/core/server.ts
|
|
80489
80558
|
init_render();
|
|
80490
80559
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
80491
|
-
import { chmod as
|
|
80560
|
+
import { chmod as chmod9, readFile as readFile13, rename as rename9, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
80492
80561
|
import { createServer } from "node:net";
|
|
80493
80562
|
|
|
80494
80563
|
// src/core/events.ts
|
|
@@ -80607,7 +80676,7 @@ class EventHub {
|
|
|
80607
80676
|
// src/core/tokens.ts
|
|
80608
80677
|
init_render();
|
|
80609
80678
|
import { createHash as createHash4, randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
|
|
80610
|
-
import { chmod as
|
|
80679
|
+
import { chmod as chmod8, readFile as readFile12, rename as rename8, writeFile as writeFile7 } from "node:fs/promises";
|
|
80611
80680
|
var HARNESS_PREFIX = "cht_";
|
|
80612
80681
|
var TOKEN_ID = /^[A-Za-z0-9]{12}$/;
|
|
80613
80682
|
function b64u2(bytes) {
|
|
@@ -80702,7 +80771,7 @@ class TokenBook {
|
|
|
80702
80771
|
const temp = `${this.path}.tmp-${b64u2(randomBytes7(6))}`;
|
|
80703
80772
|
await writeFile7(temp, `${JSON.stringify({ version: 1, harness: records }, null, 2)}
|
|
80704
80773
|
`, { mode: 384, flag: "wx" });
|
|
80705
|
-
await
|
|
80774
|
+
await chmod8(temp, 384);
|
|
80706
80775
|
await rename8(temp, this.path);
|
|
80707
80776
|
this.records = records;
|
|
80708
80777
|
}
|
|
@@ -80812,7 +80881,7 @@ class CoreServer {
|
|
|
80812
80881
|
resolve2();
|
|
80813
80882
|
});
|
|
80814
80883
|
});
|
|
80815
|
-
await
|
|
80884
|
+
await chmod9(path, 384);
|
|
80816
80885
|
this.server = server;
|
|
80817
80886
|
}
|
|
80818
80887
|
async close() {
|
|
@@ -80954,10 +81023,10 @@ class CoreServer {
|
|
|
80954
81023
|
const roles = Object.hasOwn(METHOD_ROLES, method) ? METHOD_ROLES[method] : undefined;
|
|
80955
81024
|
if (roles === undefined)
|
|
80956
81025
|
throw new RpcError(RPC_METHOD_NOT_FOUND2, "METHOD_NOT_FOUND", `No method ${terminalText(method).slice(0, 64)}.`);
|
|
80957
|
-
const
|
|
81026
|
+
const access4 = roles[client.role];
|
|
80958
81027
|
client.lastCall = method;
|
|
80959
81028
|
client.lastCallAt = new Date(this.options.now()).toISOString();
|
|
80960
|
-
if (
|
|
81029
|
+
if (access4 === "no") {
|
|
80961
81030
|
await this.options.journal.append({
|
|
80962
81031
|
type: "call.forbidden",
|
|
80963
81032
|
clientId: client.clientId,
|
|
@@ -80978,7 +81047,7 @@ class CoreServer {
|
|
|
80978
81047
|
const handler = this.handlers.get(method);
|
|
80979
81048
|
if (handler === undefined)
|
|
80980
81049
|
throw refused("METHOD_NOT_AVAILABLE", `${method} is not in this build of the core yet.`);
|
|
80981
|
-
return handler(params, { client, access:
|
|
81050
|
+
return handler(params, { client, access: access4, server: this });
|
|
80982
81051
|
}
|
|
80983
81052
|
async detach(clientId2, reason) {
|
|
80984
81053
|
const connection = this.connections.get(clientId2);
|
|
@@ -81603,7 +81672,7 @@ init_evm_lite();
|
|
|
81603
81672
|
init_solana_lite();
|
|
81604
81673
|
init_token_2022();
|
|
81605
81674
|
init_evm_transfer();
|
|
81606
|
-
import { chmod as
|
|
81675
|
+
import { chmod as chmod10, mkdir as mkdir8, readFile as readFile15, rename as rename11, rm as rm6, writeFile as writeFile9 } from "node:fs/promises";
|
|
81607
81676
|
import { join as join10 } from "node:path";
|
|
81608
81677
|
|
|
81609
81678
|
// src/vault/vault-transfer-sign.ts
|
|
@@ -82179,8 +82248,8 @@ function createTransferChain(chainDeps) {
|
|
|
82179
82248
|
}
|
|
82180
82249
|
},
|
|
82181
82250
|
async keepPending(opId, signed) {
|
|
82182
|
-
await
|
|
82183
|
-
await
|
|
82251
|
+
await mkdir8(deps.pendingDir, { recursive: true, mode: 448 });
|
|
82252
|
+
await chmod10(deps.pendingDir, 448);
|
|
82184
82253
|
const path = pendingPath(opId);
|
|
82185
82254
|
const temp = `${path}.tmp`;
|
|
82186
82255
|
await writeFile9(temp, `${JSON.stringify(signed)}
|
|
@@ -83021,17 +83090,17 @@ Socket: ${paths.socket}
|
|
|
83021
83090
|
}
|
|
83022
83091
|
}
|
|
83023
83092
|
function registerCardHandlers(server, cards, trading, journal, agents) {
|
|
83024
|
-
const own = (
|
|
83093
|
+
const own = (access4) => access4 === "own";
|
|
83025
83094
|
server.handle("cards.propose", async (params, { client }) => cards.propose(params, {
|
|
83026
83095
|
clientId: client.clientId,
|
|
83027
83096
|
role: client.role,
|
|
83028
83097
|
clientName: client.clientName,
|
|
83029
83098
|
...client.harnessKind !== undefined ? { harnessKind: client.harnessKind } : {}
|
|
83030
83099
|
}));
|
|
83031
|
-
server.handle("cards.list", async (_params, { client, access:
|
|
83032
|
-
cards: cards.list(client.clientId, own(
|
|
83100
|
+
server.handle("cards.list", async (_params, { client, access: access4 }) => ({
|
|
83101
|
+
cards: cards.list(client.clientId, own(access4))
|
|
83033
83102
|
}));
|
|
83034
|
-
server.handle("cards.get", async (params, { client, access:
|
|
83103
|
+
server.handle("cards.get", async (params, { client, access: access4 }) => cards.get(params.cardId, client.clientId, own(access4)));
|
|
83035
83104
|
server.handle("cards.approve", async (params, { client }) => cards.approve({
|
|
83036
83105
|
cardId: params.cardId,
|
|
83037
83106
|
cardHash: params.cardHash,
|
|
@@ -83040,10 +83109,10 @@ function registerCardHandlers(server, cards, trading, journal, agents) {
|
|
|
83040
83109
|
}, client.clientId));
|
|
83041
83110
|
server.handle("cards.reject", async (params, { client }) => cards.reject(params.cardId, client.clientId));
|
|
83042
83111
|
server.handle("cards.withdraw", async (params, { client }) => cards.withdraw(params.cardId, client.clientId));
|
|
83043
|
-
server.handle("operations.list", async (_params, { client, access:
|
|
83044
|
-
operations: cards.operationsFor(client.clientId, own(
|
|
83112
|
+
server.handle("operations.list", async (_params, { client, access: access4 }) => ({
|
|
83113
|
+
operations: cards.operationsFor(client.clientId, own(access4))
|
|
83045
83114
|
}));
|
|
83046
|
-
server.handle("operations.get", async (params, { client, access:
|
|
83115
|
+
server.handle("operations.get", async (params, { client, access: access4 }) => cards.operation(params.opId, client.clientId, own(access4)));
|
|
83047
83116
|
server.handle("operations.resolve", async (params, { client }) => cards.resolve({ opId: params.opId, action: params.action, factor: parseFactor(params.factor) }, client.clientId));
|
|
83048
83117
|
const agentSettings = () => agents ? { agents: agents.list(), ...agents.refusedWith ? { agentsRefused: agents.refusedWith } : {} } : {};
|
|
83049
83118
|
server.handle("settings.get", async () => ({
|
|
@@ -85276,6 +85345,25 @@ function renderDoctorReport(rows, role, style) {
|
|
|
85276
85345
|
function displayMarkWidth(state, sym) {
|
|
85277
85346
|
return { PASS: sym.ok, WARN: sym.warning, FAIL: sym.danger, SKIP: sym.missing }[state].length;
|
|
85278
85347
|
}
|
|
85348
|
+
async function configDirRow(deps, configDir2) {
|
|
85349
|
+
const shown = deps.env[CONFIG_DIR_ENV]?.trim() ? `${configDir2} (from ${CONFIG_DIR_ENV})` : `${configDir2} (the default)`;
|
|
85350
|
+
const found = await deps.inspectConfigDir(configDir2);
|
|
85351
|
+
if (found.state === "present")
|
|
85352
|
+
return { check: "Config directory", state: "PASS", detail: shown };
|
|
85353
|
+
if (found.state === "missing") {
|
|
85354
|
+
return {
|
|
85355
|
+
check: "Config directory",
|
|
85356
|
+
state: "WARN",
|
|
85357
|
+
detail: `${shown} does not exist yet. The first credential or signer write creates it (mode 0700). If this machine should already hold credentials or signers, check the user and ${CONFIG_DIR_ENV}.`
|
|
85358
|
+
};
|
|
85359
|
+
}
|
|
85360
|
+
const parent = found.ancestor === undefined ? "" : `; nearest existing parent: ${found.ancestor}`;
|
|
85361
|
+
return {
|
|
85362
|
+
check: "Config directory",
|
|
85363
|
+
state: "FAIL",
|
|
85364
|
+
detail: `${shown} cannot be written (${found.errno}${parent}). Fix: as the user that runs candle, run mkdir -m 700 ${configDir2}, or set ${CONFIG_DIR_ENV} to a directory that user can write.`
|
|
85365
|
+
};
|
|
85366
|
+
}
|
|
85279
85367
|
async function doctor(args, ctx) {
|
|
85280
85368
|
const { deps, apiUrl, json } = ctx;
|
|
85281
85369
|
const parsed = parseArgs(args, { valueFlags: ["--role"] });
|
|
@@ -85306,11 +85394,6 @@ async function doctor(args, ctx) {
|
|
|
85306
85394
|
let configDir2;
|
|
85307
85395
|
try {
|
|
85308
85396
|
configDir2 = candleConfigDir(deps.env, deps.homedir());
|
|
85309
|
-
rows.push({
|
|
85310
|
-
check: "Config directory",
|
|
85311
|
-
state: "PASS",
|
|
85312
|
-
detail: deps.env[CONFIG_DIR_ENV]?.trim() ? `${configDir2} (from ${CONFIG_DIR_ENV})` : `${configDir2} (the default)`
|
|
85313
|
-
});
|
|
85314
85397
|
} catch (error) {
|
|
85315
85398
|
rows.push({
|
|
85316
85399
|
check: "Config directory",
|
|
@@ -85321,6 +85404,7 @@ async function doctor(args, ctx) {
|
|
|
85321
85404
|
if (configDir2 === undefined) {
|
|
85322
85405
|
rows.push({ check: "Vault", state: "SKIP", detail: `${CONFIG_DIR_ENV} is not usable, so no path to check` });
|
|
85323
85406
|
} else {
|
|
85407
|
+
rows.push(await configDirRow(deps, configDir2));
|
|
85324
85408
|
const vaultPath = defaultVaultPath(deps.env, deps.homedir());
|
|
85325
85409
|
hasVault = await fileExists(vaultPath);
|
|
85326
85410
|
rows.push(hasVault ? { check: "Vault", state: "PASS", detail: vaultPath } : {
|
|
@@ -85631,7 +85715,7 @@ init_solana_endpoint();
|
|
|
85631
85715
|
// src/vault/domains.ts
|
|
85632
85716
|
init_errors2();
|
|
85633
85717
|
import { homedir as homedir4 } from "node:os";
|
|
85634
|
-
import { basename as basename2, dirname as
|
|
85718
|
+
import { basename as basename2, dirname as dirname10, isAbsolute as isAbsolute2, join as join12, resolve as resolve2, sep as sep2 } from "node:path";
|
|
85635
85719
|
var ICLOUD_DRIVE_SEGMENTS = ["Library", "Mobile Documents", "com~apple~CloudDocs"];
|
|
85636
85720
|
var ICLOUD_SHORTHAND = "icloud";
|
|
85637
85721
|
var ICLOUD_BACKUP_FOLDER = "Candle";
|
|
@@ -85690,7 +85774,7 @@ async function classifyDestination(path, opts) {
|
|
|
85690
85774
|
}
|
|
85691
85775
|
let parent;
|
|
85692
85776
|
try {
|
|
85693
|
-
parent = await opts.realpath(
|
|
85777
|
+
parent = await opts.realpath(dirname10(absolute));
|
|
85694
85778
|
} catch {
|
|
85695
85779
|
return "unknown";
|
|
85696
85780
|
}
|
|
@@ -97787,7 +97871,7 @@ function encodePaymentPayload(args) {
|
|
|
97787
97871
|
|
|
97788
97872
|
// src/x402/plan-state.ts
|
|
97789
97873
|
init_file_lock();
|
|
97790
|
-
import { chmod as
|
|
97874
|
+
import { chmod as chmod11, mkdir as mkdir9, readFile as readFile16, rename as rename13, writeFile as writeFile11 } from "node:fs/promises";
|
|
97791
97875
|
function signupSignerRef(spkiSha256) {
|
|
97792
97876
|
return `x402_signup_signer_${spkiSha256}`;
|
|
97793
97877
|
}
|
|
@@ -97879,11 +97963,11 @@ async function writePlanState(paths, state) {
|
|
|
97879
97963
|
await writeFile11(temp, `${JSON.stringify({ v: 1, ...state })}
|
|
97880
97964
|
`, { encoding: "utf8", mode: 384 });
|
|
97881
97965
|
await rename13(temp, path);
|
|
97882
|
-
await
|
|
97966
|
+
await chmod11(path, 384).catch(() => {});
|
|
97883
97967
|
}
|
|
97884
97968
|
async function updatePlanState(paths, change) {
|
|
97885
|
-
await
|
|
97886
|
-
await
|
|
97969
|
+
await mkdir9(paths.dir, { recursive: true, mode: 448 });
|
|
97970
|
+
await chmod11(paths.dir, 448).catch(() => {});
|
|
97887
97971
|
const path = planStatePath(paths);
|
|
97888
97972
|
return withFileLock(path, async () => {
|
|
97889
97973
|
const { state, result } = change(parsePlanState(await readText(path)));
|
|
@@ -98048,7 +98132,7 @@ function serializePartiallySigned(transfer, payerSignature2) {
|
|
|
98048
98132
|
// src/x402/spend-log.ts
|
|
98049
98133
|
init_file_lock();
|
|
98050
98134
|
init_store();
|
|
98051
|
-
import { appendFile as appendFile2, chmod as
|
|
98135
|
+
import { appendFile as appendFile2, chmod as chmod12, mkdir as mkdir10, readFile as readFile17, rename as rename14, writeFile as writeFile12 } from "node:fs/promises";
|
|
98052
98136
|
import { join as join13 } from "node:path";
|
|
98053
98137
|
var DEFAULT_DAILY_LIMIT_USD_MICROS = 5000000n;
|
|
98054
98138
|
var DEFAULT_MAX_PER_CALL_USD_MICROS = 1000000n;
|
|
@@ -98060,8 +98144,8 @@ function spendPaths(env, home, profile) {
|
|
|
98060
98144
|
return { dir, log: join13(dir, `${name2}.jsonl`), limits: join13(dir, `${name2}.limits.json`) };
|
|
98061
98145
|
}
|
|
98062
98146
|
async function ensureDir(dir) {
|
|
98063
|
-
await
|
|
98064
|
-
await
|
|
98147
|
+
await mkdir10(dir, { recursive: true, mode: 448 });
|
|
98148
|
+
await chmod12(dir, 448).catch(() => {});
|
|
98065
98149
|
}
|
|
98066
98150
|
async function readIfPresent2(path) {
|
|
98067
98151
|
try {
|
|
@@ -98132,7 +98216,7 @@ async function appendSpendLines(paths, lines) {
|
|
|
98132
98216
|
encoding: "utf8",
|
|
98133
98217
|
mode: 384
|
|
98134
98218
|
});
|
|
98135
|
-
await
|
|
98219
|
+
await chmod12(paths.log, 384).catch(() => {});
|
|
98136
98220
|
}
|
|
98137
98221
|
function foldSpendLog(lines) {
|
|
98138
98222
|
const entries = new Map;
|
|
@@ -99667,7 +99751,7 @@ init_human_output();
|
|
|
99667
99751
|
|
|
99668
99752
|
// src/plugins.ts
|
|
99669
99753
|
import { spawn as spawn2 } from "node:child_process";
|
|
99670
|
-
import { accessSync, constants as
|
|
99754
|
+
import { accessSync, constants as constants5, readdirSync, statSync } from "node:fs";
|
|
99671
99755
|
import { delimiter, join as join14 } from "node:path";
|
|
99672
99756
|
var PLUGIN_PREFIX = "candle-";
|
|
99673
99757
|
var RESERVED_HELPER_NAMES = ["fido2", "enclave"];
|
|
@@ -99678,7 +99762,7 @@ function executableAt(path) {
|
|
|
99678
99762
|
try {
|
|
99679
99763
|
if (!statSync(path).isFile())
|
|
99680
99764
|
return false;
|
|
99681
|
-
accessSync(path,
|
|
99765
|
+
accessSync(path, constants5.X_OK);
|
|
99682
99766
|
return true;
|
|
99683
99767
|
} catch {
|
|
99684
99768
|
return false;
|
|
@@ -106193,8 +106277,8 @@ async function discard(deps, path) {
|
|
|
106193
106277
|
init_args();
|
|
106194
106278
|
init_human_output();
|
|
106195
106279
|
init_presentation();
|
|
106196
|
-
import { chmod as
|
|
106197
|
-
import nodePath, { dirname as
|
|
106280
|
+
import { chmod as chmod13, copyFile, mkdir as mkdir11, stat as stat5 } from "node:fs/promises";
|
|
106281
|
+
import nodePath, { dirname as dirname11, resolve as resolve4 } from "node:path";
|
|
106198
106282
|
init_crypto();
|
|
106199
106283
|
init_errors2();
|
|
106200
106284
|
init_evm_record();
|
|
@@ -106378,11 +106462,11 @@ async function vaultBackup(args, ctx) {
|
|
|
106378
106462
|
assertOutsideConfigDir(destination, deps.env, deps.homedir());
|
|
106379
106463
|
const file = parseVaultFile(raw);
|
|
106380
106464
|
if (target.requires !== undefined) {
|
|
106381
|
-
const folder =
|
|
106465
|
+
const folder = dirname11(destination);
|
|
106382
106466
|
try {
|
|
106383
|
-
const created = await
|
|
106467
|
+
const created = await mkdir11(folder, { recursive: true });
|
|
106384
106468
|
if (created !== undefined)
|
|
106385
|
-
await
|
|
106469
|
+
await chmod13(folder, 448).catch(() => {});
|
|
106386
106470
|
} catch (error) {
|
|
106387
106471
|
throw copyWriteFailed(destination, error, "copy");
|
|
106388
106472
|
}
|
|
@@ -107307,8 +107391,8 @@ init_errors2();
|
|
|
107307
107391
|
init_promote_support();
|
|
107308
107392
|
init_store();
|
|
107309
107393
|
init_vault_support();
|
|
107310
|
-
import { access as
|
|
107311
|
-
import { dirname as
|
|
107394
|
+
import { access as access4, chmod as chmod14, constants as constants6, lstat as lstat2, writeFile as writeFile13 } from "node:fs/promises";
|
|
107395
|
+
import { dirname as dirname12, resolve as resolve5 } from "node:path";
|
|
107312
107396
|
async function vaultExportKey(args, ctx) {
|
|
107313
107397
|
const parsed = parseArgs(args, {
|
|
107314
107398
|
valueFlags: ["--keystore", "--to"],
|
|
@@ -107420,7 +107504,7 @@ async function assertExportTargetWritable(destination) {
|
|
|
107420
107504
|
if (error.code !== "ENOENT")
|
|
107421
107505
|
throw error;
|
|
107422
107506
|
}
|
|
107423
|
-
const parent =
|
|
107507
|
+
const parent = dirname12(destination);
|
|
107424
107508
|
try {
|
|
107425
107509
|
const parentInfo = await lstat2(parent);
|
|
107426
107510
|
if (parentInfo.isSymbolicLink()) {
|
|
@@ -107442,7 +107526,7 @@ async function assertExportTargetWritable(destination) {
|
|
|
107442
107526
|
throw error;
|
|
107443
107527
|
}
|
|
107444
107528
|
try {
|
|
107445
|
-
await
|
|
107529
|
+
await access4(parent, constants6.W_OK);
|
|
107446
107530
|
} catch {
|
|
107447
107531
|
throw new VaultError("VAULT_WRITE_FAILED", `${parent} is not writable.`, {
|
|
107448
107532
|
suggestion: "Choose a directory you can write to, or fix its permissions, then retry."
|
|
@@ -107452,7 +107536,7 @@ async function assertExportTargetWritable(destination) {
|
|
|
107452
107536
|
async function writeExportFile(destination, body) {
|
|
107453
107537
|
try {
|
|
107454
107538
|
await writeFile13(destination, body, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
107455
|
-
await
|
|
107539
|
+
await chmod14(destination, 384);
|
|
107456
107540
|
} catch (error) {
|
|
107457
107541
|
const code = error.code;
|
|
107458
107542
|
if (code === "EEXIST") {
|
|
@@ -113361,7 +113445,7 @@ async function vaultTransfer(args, ctx) {
|
|
|
113361
113445
|
init_args();
|
|
113362
113446
|
init_human_output();
|
|
113363
113447
|
init_release();
|
|
113364
|
-
import { dirname as
|
|
113448
|
+
import { dirname as dirname13, join as join15 } from "node:path";
|
|
113365
113449
|
init_key_output();
|
|
113366
113450
|
var USAGE16 = "Usage: candle verify <file> --bundle <path> [--identity <uri>] [--issuer <url>]";
|
|
113367
113451
|
async function resolveIdentity(deps, bundlePath, flag) {
|
|
@@ -113369,7 +113453,7 @@ async function resolveIdentity(deps, bundlePath, flag) {
|
|
|
113369
113453
|
return { kind: "ok", uri: flag, provenance: "identity from --identity" };
|
|
113370
113454
|
let version;
|
|
113371
113455
|
try {
|
|
113372
|
-
const manifest = JSON.parse(await deps.readFile(join15(
|
|
113456
|
+
const manifest = JSON.parse(await deps.readFile(join15(dirname13(bundlePath), "latest.json")));
|
|
113373
113457
|
if (typeof manifest.version !== "string" || manifest.version.length === 0)
|
|
113374
113458
|
return { kind: "absent" };
|
|
113375
113459
|
version = manifest.version;
|
|
@@ -114161,7 +114245,7 @@ function walletsUntrust(args, ctx) {
|
|
|
114161
114245
|
}
|
|
114162
114246
|
|
|
114163
114247
|
// src/config.ts
|
|
114164
|
-
import { chmod as
|
|
114248
|
+
import { chmod as chmod15, mkdir as mkdir12, readFile as readFile19, rm as rm8, writeFile as writeFile14 } from "node:fs/promises";
|
|
114165
114249
|
import { homedir as homedir5 } from "node:os";
|
|
114166
114250
|
import { join as join16 } from "node:path";
|
|
114167
114251
|
function configDir2() {
|
|
@@ -114184,8 +114268,8 @@ async function writeConfig(patch) {
|
|
|
114184
114268
|
const current = await readConfig();
|
|
114185
114269
|
const next = { ...current, ...patch };
|
|
114186
114270
|
const dir = configDir2();
|
|
114187
|
-
await
|
|
114188
|
-
await
|
|
114271
|
+
await mkdir12(dir, { recursive: true });
|
|
114272
|
+
await chmod15(dir, 448);
|
|
114189
114273
|
await writeFile14(configFilePath(), JSON.stringify(next, null, 2), "utf8");
|
|
114190
114274
|
}
|
|
114191
114275
|
async function updateProfile(name2, patch) {
|
|
@@ -114205,6 +114289,7 @@ async function clearConfig() {
|
|
|
114205
114289
|
|
|
114206
114290
|
// src/index.ts
|
|
114207
114291
|
init_ownership();
|
|
114292
|
+
init_file_lock();
|
|
114208
114293
|
|
|
114209
114294
|
// src/guard.ts
|
|
114210
114295
|
init_profiles();
|
|
@@ -114248,10 +114333,10 @@ async function verifyProfileAccount(ctx, config) {
|
|
|
114248
114333
|
init_presentation();
|
|
114249
114334
|
|
|
114250
114335
|
// src/private-file.ts
|
|
114251
|
-
import { chmod as
|
|
114336
|
+
import { chmod as chmod16, writeFile as writeFile15 } from "node:fs/promises";
|
|
114252
114337
|
async function writeOwnerOnlyFile(path, content) {
|
|
114253
114338
|
await writeFile15(path, content, { mode: 384 });
|
|
114254
|
-
await
|
|
114339
|
+
await chmod16(path, 384);
|
|
114255
114340
|
}
|
|
114256
114341
|
|
|
114257
114342
|
// src/index.ts
|
|
@@ -114316,6 +114401,7 @@ init_enclave();
|
|
|
114316
114401
|
var RELEASE_POLICY = parseReleasePolicy(release_policy_default);
|
|
114317
114402
|
|
|
114318
114403
|
// src/index.ts
|
|
114404
|
+
init_store();
|
|
114319
114405
|
function extractGlobalFlags(argv) {
|
|
114320
114406
|
const rest = [];
|
|
114321
114407
|
const flags2 = { json: false, help: false, version: false, noVerifyAccount: false };
|
|
@@ -114602,6 +114688,16 @@ async function run2(argv, deps) {
|
|
|
114602
114688
|
writeLocalFailure(deps, { code: PROFILE_CORE_OWNED, message: error2.message, suggestion: CORE_OWNED_SUGGESTION }, !("error" in parsed2) && parsed2.flags.json);
|
|
114603
114689
|
return 1;
|
|
114604
114690
|
}
|
|
114691
|
+
if (error2 instanceof ConfigDirUnwritableError) {
|
|
114692
|
+
const parsed2 = extractGlobalFlags(argv);
|
|
114693
|
+
writeLocalFailure(deps, {
|
|
114694
|
+
code: error2.code,
|
|
114695
|
+
message: error2.message,
|
|
114696
|
+
suggestion: error2.suggestion,
|
|
114697
|
+
details: { path: error2.path, errno: error2.errno }
|
|
114698
|
+
}, !("error" in parsed2) && parsed2.flags.json);
|
|
114699
|
+
return 1;
|
|
114700
|
+
}
|
|
114605
114701
|
if (!(error2 instanceof SecretStoreLockedError) && !(error2 instanceof SecretStoreReadError))
|
|
114606
114702
|
throw error2;
|
|
114607
114703
|
const parsed = extractGlobalFlags(argv);
|
|
@@ -114877,6 +114973,7 @@ async function buildRealDeps() {
|
|
|
114877
114973
|
nodeVersion: process.versions.node,
|
|
114878
114974
|
hostname: hostname(),
|
|
114879
114975
|
homedir: homedir6,
|
|
114976
|
+
inspectConfigDir,
|
|
114880
114977
|
appendEvmRecord: appendEvmRecordForTrade,
|
|
114881
114978
|
runMcpServer: async (env) => {
|
|
114882
114979
|
const { runStdioServer: runStdioServer2 } = await Promise.resolve().then(() => (init_server3(), exports_server));
|
|
@@ -114911,7 +115008,7 @@ async function buildRealDeps() {
|
|
|
114911
115008
|
releasePolicy: RELEASE_POLICY,
|
|
114912
115009
|
writeBytes: async (path, bytes) => {
|
|
114913
115010
|
await writeFile16(path, bytes, { flag: "wx", mode: 493 });
|
|
114914
|
-
await
|
|
115011
|
+
await chmod17(path, 493);
|
|
114915
115012
|
},
|
|
114916
115013
|
rename: (from, to) => rename16(from, to),
|
|
114917
115014
|
unlink: (path) => unlink(path),
|
package/package.json
CHANGED