@fased/fased 0.1.60 → 0.1.62
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/CHANGELOG.md +22 -0
- package/dist/acp/client.js +2 -2
- package/dist/acp/secret-file.js +2 -2
- package/dist/agents/agent-scope.js +2 -2
- package/dist/agents/apply-patch.js +8 -8
- package/dist/agents/auth-profiles/paths.js +2 -2
- package/dist/agents/auth-profiles/store.js +2 -2
- package/dist/agents/bash-tools.shared.js +2 -2
- package/dist/agents/cli-credentials.js +4 -4
- package/dist/agents/docs-path.js +3 -3
- package/dist/agents/embedded-pi-mcp.js +4 -4
- package/dist/agents/identity-avatar.js +3 -3
- package/dist/agents/identity-file.js +2 -2
- package/dist/agents/openai-codex-app-server.js +5 -5
- package/dist/agents/pi-embedded-subscribe.raw-stream.js +3 -3
- package/dist/agents/pi-extensions/compaction-safeguard.js +3 -3
- package/dist/agents/pi-model-discovery.js +6 -6
- package/dist/agents/pi-project-settings.js +3 -3
- package/dist/agents/sandbox/fs-bridge.js +2 -2
- package/dist/agents/session-dirs.js +4 -4
- package/dist/agents/session-write-lock.js +13 -13
- package/dist/agents/shell-utils.js +5 -5
- package/dist/agents/skills/bundled-dir.js +4 -4
- package/dist/agents/skills/local-loader.js +6 -6
- package/dist/agents/skills/plugin-skills.js +2 -2
- package/dist/agents/skills/workspace.js +13 -13
- package/dist/agents/skills-install-download.js +7 -7
- package/dist/agents/skills-install-plan.js +2 -2
- package/dist/agents/skills-install.js +2 -2
- package/dist/agents/skills-status.js +2 -2
- package/dist/agents/subagent-depth.js +2 -2
- package/dist/agents/system-prompt-params.js +2 -2
- package/dist/agents/workspace.js +22 -22
- package/dist/auto-reply/reply/agent-runner-execution.js +2 -2
- package/dist/auto-reply/reply/agent-runner.js +2 -2
- package/dist/auto-reply/reply/commands-export-session.js +7 -7
- package/dist/auto-reply/reply/post-compaction-audit.js +3 -3
- package/dist/auto-reply/reply/post-compaction-context.js +3 -3
- package/dist/auto-reply/reply/session.js +3 -3
- package/dist/auto-reply/skill-commands.js +3 -3
- package/dist/auto-reply/status.js +6 -6
- package/dist/brand.js +1 -1
- package/dist/browser/chrome.executables.js +3 -3
- package/dist/browser/chrome.js +3 -3
- package/dist/browser/chrome.profile-decoration.js +6 -6
- package/dist/browser/profiles-service.js +2 -2
- package/dist/browser/server-context.js +2 -2
- package/dist/browser/trash.js +4 -4
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/canvas-host/server.js +4 -4
- package/dist/capabilities/catalog.js +3 -3
- package/dist/channels/plugins/catalog.js +3 -3
- package/dist/cli/browser-cli-extension.js +6 -6
- package/dist/cli/command-format.js +2 -2
- package/dist/cli/cron-cli/register.cron-simple.js +2 -2
- package/dist/cli/dns-cli.js +9 -9
- package/dist/cli/gateway-cli/dev.js +5 -5
- package/dist/cli/gateway-cli/run.js +2 -2
- package/dist/cli/hooks-cli.js +5 -5
- package/dist/cli/lightweight/gateway-runtime-probe.js +2 -2
- package/dist/cli/memory-cli.js +7 -7
- package/dist/cli/nodes-media-utils.js +2 -2
- package/dist/cli/plugins-cli.js +2 -2
- package/dist/cli/secrets-cli.js +3 -3
- package/dist/cli/windows-argv.js +2 -2
- package/dist/commands/dashboard-link.js +3 -3
- package/dist/commands/doctor-install.js +5 -5
- package/dist/commands/doctor-memory-search.js +2 -2
- package/dist/commands/doctor-platform-notes.js +2 -2
- package/dist/commands/doctor-sandbox.js +2 -2
- package/dist/commands/doctor-state-integrity.js +23 -23
- package/dist/commands/doctor-workspace.js +3 -3
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/managed-up.js +2 -2
- package/dist/commands/onboard-auth.credentials.js +3 -3
- package/dist/commands/onboarding/plugin-install.js +2 -2
- package/dist/commands/sessions-cleanup.js +2 -2
- package/dist/commands/signal-install.js +6 -6
- package/dist/commands/status-all/channels.js +2 -2
- package/dist/commands/wallet.js +47 -47
- package/dist/config/cache-utils.js +2 -2
- package/dist/config/includes.js +5 -5
- package/dist/config/io.js +2 -2
- package/dist/config/paths.js +3 -3
- package/dist/config/sat-runtime-ids.js +3 -3
- package/dist/config/sessions/disk-budget.js +6 -6
- package/dist/config/sessions/paths.js +2 -2
- package/dist/config/sessions/store.js +17 -17
- package/dist/config/sessions/transcript.js +4 -4
- package/dist/config/talk.js +2 -2
- package/dist/control-ui/assets/{app-CqF4Tc9n.js → app-DLil9VO1.js} +3 -3
- package/dist/control-ui/assets/{index-DYggPSfy.js → index-DdE_NIXo.js} +3 -3
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/version.json +1 -1
- package/dist/cron/service/store.js +2 -2
- package/dist/cron/store.js +6 -6
- package/dist/daemon/systemd-system.js +5 -5
- package/dist/discord/monitor/thread-bindings.state.js +2 -2
- package/dist/extensions/sat-mining/src/sat-bond-layout.js +9 -9
- package/dist/gateway/control-ui-boot-check.js +6 -6
- package/dist/gateway/control-ui-login.js +7 -7
- package/dist/gateway/control-ui.js +9 -9
- package/dist/gateway/hooks-mapping.js +4 -4
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http.js +4 -4
- package/dist/gateway/server-methods/chat.js +3 -3
- package/dist/gateway/server-methods/sessions.js +6 -6
- package/dist/gateway/server-methods/usage.js +2 -2
- package/dist/gateway/server.impl.js +3 -3
- package/dist/gateway/session-compaction-checkpoints.js +4 -4
- package/dist/gateway/session-utils.fs.js +24 -24
- package/dist/gateway/session-utils.js +6 -6
- package/dist/hooks/bundled-dir.js +4 -4
- package/dist/hooks/gmail-setup-utils.js +6 -6
- package/dist/hooks/import-url.js +2 -2
- package/dist/hooks/loader.js +4 -4
- package/dist/hooks/workspace.js +7 -7
- package/dist/infra/archive.js +17 -17
- package/dist/infra/boundary-file-read.js +2 -2
- package/dist/infra/boundary-path.js +15 -15
- package/dist/infra/brew.js +2 -2
- package/dist/infra/control-ui-assets.js +14 -14
- package/dist/infra/device-auth-store.js +8 -8
- package/dist/infra/device-identity.js +8 -8
- package/dist/infra/dotenv.js +2 -2
- package/dist/infra/exec-approvals.js +8 -8
- package/dist/infra/exec-command-resolution.js +4 -4
- package/dist/infra/exec-safe-bin-trust.js +2 -2
- package/dist/infra/fased-root.js +5 -5
- package/dist/infra/fs-safe.js +14 -14
- package/dist/infra/gateway-lock.js +11 -11
- package/dist/infra/git-commit.js +5 -5
- package/dist/infra/git-root.js +4 -4
- package/dist/infra/hosted-runtime-artifact.js +3 -3
- package/dist/infra/is-main.js +2 -2
- package/dist/infra/json-file.js +7 -7
- package/dist/infra/managed-runtime-bootstrap.js +6 -6
- package/dist/infra/outbound/delivery-queue.js +16 -16
- package/dist/infra/path-env.js +3 -3
- package/dist/infra/ports-lsof.js +4 -4
- package/dist/infra/provider-usage.auth.js +3 -3
- package/dist/infra/safe-open-sync.js +2 -2
- package/dist/infra/session-cost-usage.js +9 -9
- package/dist/infra/shell-env.js +2 -2
- package/dist/infra/state-migrations.fs.js +6 -6
- package/dist/infra/state-migrations.js +23 -23
- package/dist/infra/tmp-fased-dir.js +6 -6
- package/dist/infra/widearea-dns.js +3 -3
- package/dist/infra/wsl.js +2 -2
- package/dist/line/accounts.js +2 -2
- package/dist/line/download.js +2 -2
- package/dist/logging/config.js +3 -3
- package/dist/logging/logger.js +7 -7
- package/dist/managed/federation.js +3 -3
- package/dist/managed/tunnel.js +3 -3
- package/dist/media/store.js +13 -13
- package/dist/media-understanding/runner.js +3 -3
- package/dist/memory/embeddings.js +2 -2
- package/dist/memory/internal.js +10 -10
- package/dist/memory/manager-sync-ops.js +7 -7
- package/dist/memory/repair-executor.js +17 -17
- package/dist/node-host/invoke-system-run-plan.js +8 -8
- package/dist/node-host/invoke.js +2 -2
- package/dist/node-host/runner.js +3 -3
- package/dist/pairing/pairing-store.js +3 -3
- package/dist/plugin-sdk/{audio-preflight-C2QXh5Ml.js → audio-preflight-Bwi2Oq03.js} +2 -2
- package/dist/plugin-sdk/channel-plugin-common.d.ts +2 -2
- package/dist/plugin-sdk/{chunk-items-3ZyiGiff.js → chunk-items-DzT4L4Ty.js} +1 -1
- package/dist/plugin-sdk/command-status.js +2 -2
- package/dist/plugin-sdk/{config-schema-C9tx1Lyz.js → config-schema-BrkmtFxB.js} +16 -16
- package/dist/plugin-sdk/device-pair.d.ts +1 -1
- package/dist/plugin-sdk/discord.d.ts +4 -4
- package/dist/plugin-sdk/index.d.ts +20 -20
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{monitor-Xgx6vGcg.js → monitor-M_ta2lMc.js} +4 -4
- package/dist/plugin-sdk/{monitor-XbunF2-r.js → monitor-wYVncM9w.js} +6 -6
- package/dist/plugin-sdk/{openresponses-http-BRUr0JLE.js → openresponses-http-B2GmeSt4.js} +2 -2
- package/dist/plugin-sdk/{pairing-message-C403mq4K.d.ts → pairing-message-B3bHYGaw.d.ts} +1 -1
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +1 -1
- package/dist/plugin-sdk/{pw-ai-BzV0f18N.js → pw-ai-AFUqn-tQ.js} +1 -1
- package/dist/plugin-sdk/{runtime-dependency-Ch7J9a0d.js → runtime-dependency-DLDmB94f.js} +9 -9
- package/dist/plugin-sdk/sat-runtime.d.ts +2 -2
- package/dist/plugin-sdk/sat-runtime.js +2 -2
- package/dist/plugin-sdk/{slack-BzJfCWjq.js → slack-CxE1mfzj.js} +4 -4
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/{sticker-cache-Dex-XpRj.js → sticker-cache-CGzGWu00.js} +2 -2
- package/dist/plugin-sdk/{telegram-actions-DoFTGX4z.js → telegram-actions-DaEcYQ8r.js} +3 -3
- package/dist/plugin-sdk/telegram.d.ts +4 -4
- package/dist/plugin-sdk/{tmp-fased-dir-Ouj58axY.d.ts → tmp-fased-dir-CS6zsYEE.d.ts} +1 -1
- package/dist/plugin-sdk/{types-B4hj6HgR.d.ts → types-DFAW-n1J.d.ts} +1 -1
- package/dist/plugin-sdk/{types-dWZFX1fk.d.ts → types-vcJrC_uv.d.ts} +2 -2
- package/dist/plugin-sdk/{web--wC3ZfVl.js → web-CInY-lCv.js} +2 -2
- package/dist/plugin-sdk/whatsapp.d.ts +13 -13
- package/dist/plugin-sdk/{zod-schema.providers-core-FaYR6KdD.d.ts → zod-schema.providers-core-BEbNizPe.d.ts} +78 -78
- package/dist/plugins/bundled-dir.js +3 -3
- package/dist/plugins/discovery.js +11 -11
- package/dist/plugins/loader.js +13 -13
- package/dist/plugins/manifest-registry.js +2 -2
- package/dist/plugins/manifest.js +4 -4
- package/dist/plugins/path-safety.js +3 -3
- package/dist/plugins/status-cache.js +9 -9
- package/dist/plugins/update.js +3 -3
- package/dist/plugins/web-search-install-catalog.js +3 -3
- package/dist/secrets/apply.js +16 -16
- package/dist/secrets/audit.js +11 -11
- package/dist/secrets/shared.js +9 -9
- package/dist/security/scan-paths.js +2 -2
- package/dist/shared/config-eval.js +2 -2
- package/dist/shared/pid-alive.js +2 -2
- package/dist/tasks/standing-orders.js +5 -5
- package/dist/tasks/task-flow-registry.js +5 -5
- package/dist/tasks/task-registry.js +5 -5
- package/dist/tasks/workflow-definitions.js +6 -6
- package/dist/telegram/token.js +5 -5
- package/dist/utils.js +5 -5
- package/dist/wallet/local-socket-signer-broker.js +16 -16
- package/dist/wallet/providers/embedded-keystore-adapter.js +5 -5
- package/dist/wallet/providers/local-socket-signer-adapter.js +2 -2
- package/dist/wallet/wallet-approval-auth.js +5 -5
- package/dist/wallet/wallet-audit-log.js +5 -5
- package/dist/wallet/wallet-custody.js +21 -21
- package/dist/wallet/wallet-inbound-events.js +5 -5
- package/dist/wallet/wallet-observability.js +5 -5
- package/dist/wallet/wallet-policy.js +9 -9
- package/dist/wallet/wallet-provider-registry.js +7 -7
- package/dist/wallet/wallet-runtime-config.js +3 -3
- package/dist/wallet/wallet-secrets-store.js +22 -22
- package/dist/wallet/wallet-send-approvals.js +5 -5
- package/dist/wallet/wallet-settlement-links.js +5 -5
- package/dist/web/accounts.js +3 -3
- package/dist/web/auth-store.js +18 -18
- package/dist/web/session.js +4 -4
- package/dist/wizard/host-security-capability.js +2 -2
- package/dist/wizard/onboarding.host-security.js +7 -7
- package/dist/wizard/onboarding.js +11 -28
- package/dist/wizard/onboarding.wallet.js +132 -85
- package/extensions/acpx/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/fased-federation/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +12 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +2 -2
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +12 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +12 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/sat-mining/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +12 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +12 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +12 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +12 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +2 -1
- package/scripts/install-fased-signerd.sh +142 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { resolveAgentIdFromSessionKey } from "../routing/session-key.js";
|
|
3
3
|
import { findTaskRecord, markTaskTerminal, updateTaskRecord } from "./task-registry.js";
|
|
4
|
-
import
|
|
4
|
+
import syncFs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
7
|
//#region src/tasks/task-flow-registry.ts
|
|
@@ -85,7 +85,7 @@ function loadStore(filePath = resolveTaskFlowRegistryPath()) {
|
|
|
85
85
|
return cachedStore;
|
|
86
86
|
}
|
|
87
87
|
try {
|
|
88
|
-
cachedStore = sanitizeStore(JSON.parse(
|
|
88
|
+
cachedStore = sanitizeStore(JSON.parse(syncFs.readFileSync(filePath, "utf8")));
|
|
89
89
|
} catch {
|
|
90
90
|
cachedStore = defaultStore();
|
|
91
91
|
}
|
|
@@ -93,10 +93,10 @@ function loadStore(filePath = resolveTaskFlowRegistryPath()) {
|
|
|
93
93
|
return cachedStore;
|
|
94
94
|
}
|
|
95
95
|
function saveStore(store, filePath = resolveTaskFlowRegistryPath()) {
|
|
96
|
-
|
|
96
|
+
syncFs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
97
97
|
const tmpPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
syncFs.writeFileSync(tmpPath, `${JSON.stringify(store, null, 2)}\n`, "utf8");
|
|
99
|
+
syncFs.renameSync(tmpPath, filePath);
|
|
100
100
|
cachedStore = store;
|
|
101
101
|
loadedPath = filePath;
|
|
102
102
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { resolveAgentIdFromSessionKey } from "../routing/session-key.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/tasks/task-registry.ts
|
|
@@ -41,7 +41,7 @@ function loadStore(filePath = resolveTaskRegistryPath()) {
|
|
|
41
41
|
return cachedStore;
|
|
42
42
|
}
|
|
43
43
|
try {
|
|
44
|
-
const raw =
|
|
44
|
+
const raw = syncFs.readFileSync(filePath, "utf8");
|
|
45
45
|
cachedStore = sanitizeStore(JSON.parse(raw));
|
|
46
46
|
} catch {
|
|
47
47
|
cachedStore = defaultStore();
|
|
@@ -50,10 +50,10 @@ function loadStore(filePath = resolveTaskRegistryPath()) {
|
|
|
50
50
|
return cachedStore;
|
|
51
51
|
}
|
|
52
52
|
function saveStore(store, filePath = resolveTaskRegistryPath()) {
|
|
53
|
-
|
|
53
|
+
syncFs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
54
54
|
const tmpPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
syncFs.writeFileSync(tmpPath, `${JSON.stringify(store, null, 2)}\n`, "utf8");
|
|
56
|
+
syncFs.renameSync(tmpPath, filePath);
|
|
57
57
|
cachedStore = store;
|
|
58
58
|
loadedPath = filePath;
|
|
59
59
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { normalizeTaskWorkflowGraphInput } from "./workflow-graph.js";
|
|
3
3
|
import { normalizeSimpleTaskWorkflowInput } from "./workflow.js";
|
|
4
|
-
import
|
|
4
|
+
import syncFs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
|
|
@@ -154,7 +154,7 @@ function auditTaskWorkflowDefinitions(params) {
|
|
|
154
154
|
const filePath = params?.filePath ?? resolveTaskWorkflowDefinitionsPath();
|
|
155
155
|
let raw;
|
|
156
156
|
try {
|
|
157
|
-
raw = JSON.parse(
|
|
157
|
+
raw = JSON.parse(syncFs.readFileSync(filePath, "utf8"));
|
|
158
158
|
} catch (err) {
|
|
159
159
|
if (err.code === "ENOENT") {
|
|
160
160
|
return { findings: [] };
|
|
@@ -197,7 +197,7 @@ function loadStore(filePath = resolveTaskWorkflowDefinitionsPath()) {
|
|
|
197
197
|
return cachedStore;
|
|
198
198
|
}
|
|
199
199
|
try {
|
|
200
|
-
cachedStore = sanitizeStore(JSON.parse(
|
|
200
|
+
cachedStore = sanitizeStore(JSON.parse(syncFs.readFileSync(filePath, "utf8")));
|
|
201
201
|
} catch {
|
|
202
202
|
cachedStore = defaultStore();
|
|
203
203
|
}
|
|
@@ -205,10 +205,10 @@ function loadStore(filePath = resolveTaskWorkflowDefinitionsPath()) {
|
|
|
205
205
|
return cachedStore;
|
|
206
206
|
}
|
|
207
207
|
function saveStore(store, filePath = resolveTaskWorkflowDefinitionsPath()) {
|
|
208
|
-
|
|
208
|
+
syncFs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
209
209
|
const tmpPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
syncFs.writeFileSync(tmpPath, `${JSON.stringify(store, null, 2)}\n`, "utf8");
|
|
211
|
+
syncFs.renameSync(tmpPath, filePath);
|
|
212
212
|
cachedStore = store;
|
|
213
213
|
loadedPath = filePath;
|
|
214
214
|
}
|
package/dist/telegram/token.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/account-id.js";
|
|
2
2
|
import "../routing/session-key.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
|
|
5
5
|
//#region src/telegram/token.ts
|
|
6
6
|
function resolveTelegramToken(cfg, opts = {}) {
|
|
@@ -21,7 +21,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
21
21
|
const accountCfg = resolveAccountCfg(accountId !== DEFAULT_ACCOUNT_ID ? accountId : DEFAULT_ACCOUNT_ID);
|
|
22
22
|
const accountTokenFile = accountCfg?.tokenFile?.trim();
|
|
23
23
|
if (accountTokenFile) {
|
|
24
|
-
if (!
|
|
24
|
+
if (!syncFs.existsSync(accountTokenFile)) {
|
|
25
25
|
opts.logMissingFile?.(`channels.telegram.accounts.${accountId}.tokenFile not found: ${accountTokenFile}`);
|
|
26
26
|
return {
|
|
27
27
|
token: "",
|
|
@@ -29,7 +29,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
|
-
const token =
|
|
32
|
+
const token = syncFs.readFileSync(accountTokenFile, "utf-8").trim();
|
|
33
33
|
if (token) {
|
|
34
34
|
return {
|
|
35
35
|
token,
|
|
@@ -58,7 +58,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
58
58
|
const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
|
|
59
59
|
const tokenFile = telegramCfg?.tokenFile?.trim();
|
|
60
60
|
if (tokenFile && allowEnv) {
|
|
61
|
-
if (!
|
|
61
|
+
if (!syncFs.existsSync(tokenFile)) {
|
|
62
62
|
opts.logMissingFile?.(`channels.telegram.tokenFile not found: ${tokenFile}`);
|
|
63
63
|
return {
|
|
64
64
|
token: "",
|
|
@@ -66,7 +66,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
try {
|
|
69
|
-
const token =
|
|
69
|
+
const token = syncFs.readFileSync(tokenFile, "utf-8").trim();
|
|
70
70
|
if (token) {
|
|
71
71
|
return {
|
|
72
72
|
token,
|
package/dist/utils.js
CHANGED
|
@@ -2,20 +2,20 @@ import { expandHomePrefix, resolveEffectiveHomeDir, resolveRequiredHomeDir } fro
|
|
|
2
2
|
import { resolveOAuthDir } from "./config/paths.js";
|
|
3
3
|
import { logVerbose, shouldLogVerbose } from "./globals.js";
|
|
4
4
|
import { isPlainObject } from "./infra/plain-object.js";
|
|
5
|
-
import
|
|
5
|
+
import syncFs from "node:fs";
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
9
|
//#region src/utils.ts
|
|
10
10
|
async function ensureDir(dir) {
|
|
11
|
-
await
|
|
11
|
+
await syncFs.promises.mkdir(dir, { recursive: true });
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Check if a file or directory exists at the given path.
|
|
15
15
|
*/
|
|
16
16
|
async function pathExists(targetPath) {
|
|
17
17
|
try {
|
|
18
|
-
await
|
|
18
|
+
await syncFs.promises.access(targetPath);
|
|
19
19
|
return true;
|
|
20
20
|
} catch {
|
|
21
21
|
return false;
|
|
@@ -129,7 +129,7 @@ function readLidReverseMapping(lid, opts) {
|
|
|
129
129
|
for (const dir of mappingDirs) {
|
|
130
130
|
const mappingPath = path.join(dir, mappingFilename);
|
|
131
131
|
try {
|
|
132
|
-
const data =
|
|
132
|
+
const data = syncFs.readFileSync(mappingPath, "utf8");
|
|
133
133
|
const phone = JSON.parse(data);
|
|
134
134
|
if (phone === null || phone === undefined) {
|
|
135
135
|
continue;
|
|
@@ -250,7 +250,7 @@ function resolveConfigDir(env = process.env, homedir = os.homedir) {
|
|
|
250
250
|
}
|
|
251
251
|
const newDir = path.join(resolveRequiredHomeDir(env, homedir), ".fased");
|
|
252
252
|
try {
|
|
253
|
-
const hasNew =
|
|
253
|
+
const hasNew = syncFs.existsSync(newDir);
|
|
254
254
|
if (hasNew) {
|
|
255
255
|
return newDir;
|
|
256
256
|
}
|
|
@@ -2,7 +2,7 @@ import { resolveLocalSignerBackendSocketPath, resolveLocalSignerSidecarPaths, re
|
|
|
2
2
|
import { redactWalletDiagnosticText, walletDiagnosticErrorMessage } from "./wallet-redaction.js";
|
|
3
3
|
import { parseLocalSocketSignerRequest, parseLocalSocketSignerResponseEnvelope } from "./local-socket-signer-protocol.js";
|
|
4
4
|
import { requestJsonlSocket } from "../infra/jsonl-socket.js";
|
|
5
|
-
import
|
|
5
|
+
import syncFs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import net from "node:net";
|
|
8
8
|
|
|
@@ -34,15 +34,15 @@ function appendAuditLine(auditLog, entry, fileMode) {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
syncFs.mkdirSync(path.dirname(auditLog), {
|
|
38
38
|
recursive: true,
|
|
39
39
|
mode: fileMode === 432 ? 504 : 448
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
syncFs.appendFileSync(auditLog, `${JSON.stringify(entry)}\n`, {
|
|
42
42
|
encoding: "utf8",
|
|
43
43
|
mode: 384
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
syncFs.chmodSync(auditLog, fileMode);
|
|
46
46
|
} catch {}
|
|
47
47
|
}
|
|
48
48
|
function writeJsonLine(socket, payload) {
|
|
@@ -138,12 +138,12 @@ function handleConnection(socket, options) {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
function ensurePidLock(pidFile, fileMode) {
|
|
141
|
-
|
|
141
|
+
syncFs.mkdirSync(path.dirname(pidFile), {
|
|
142
142
|
recursive: true,
|
|
143
143
|
mode: 448
|
|
144
144
|
});
|
|
145
|
-
if (
|
|
146
|
-
const raw =
|
|
145
|
+
if (syncFs.existsSync(pidFile)) {
|
|
146
|
+
const raw = syncFs.readFileSync(pidFile, "utf8").trim();
|
|
147
147
|
const pid = Number.parseInt(raw, 10);
|
|
148
148
|
if (Number.isFinite(pid) && pid > 1) {
|
|
149
149
|
try {
|
|
@@ -151,20 +151,20 @@ function ensurePidLock(pidFile, fileMode) {
|
|
|
151
151
|
throw new Error(`signer broker already running (pid=${pid})`);
|
|
152
152
|
} catch (err) {
|
|
153
153
|
if (!(err instanceof Error) || !String(err.message).includes("already running")) {
|
|
154
|
-
|
|
154
|
+
syncFs.rmSync(pidFile, { force: true });
|
|
155
155
|
} else {
|
|
156
156
|
throw err;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
} else {
|
|
160
|
-
|
|
160
|
+
syncFs.rmSync(pidFile, { force: true });
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
syncFs.writeFileSync(pidFile, `${process.pid}\n`, {
|
|
164
164
|
encoding: "utf8",
|
|
165
165
|
mode: fileMode
|
|
166
166
|
});
|
|
167
|
-
|
|
167
|
+
syncFs.chmodSync(pidFile, fileMode);
|
|
168
168
|
}
|
|
169
169
|
async function startLocalSocketSignerBroker(params) {
|
|
170
170
|
const env = process.env;
|
|
@@ -183,11 +183,11 @@ async function startLocalSocketSignerBroker(params) {
|
|
|
183
183
|
readOnly,
|
|
184
184
|
fileMode
|
|
185
185
|
};
|
|
186
|
-
|
|
186
|
+
syncFs.mkdirSync(path.dirname(socketPath), {
|
|
187
187
|
recursive: true,
|
|
188
188
|
mode: fileMode === 432 ? 504 : 448
|
|
189
189
|
});
|
|
190
|
-
|
|
190
|
+
syncFs.rmSync(socketPath, { force: true });
|
|
191
191
|
ensurePidLock(pidFile, fileMode);
|
|
192
192
|
const server = net.createServer((socket) => {
|
|
193
193
|
handleConnection(socket, options);
|
|
@@ -196,13 +196,13 @@ async function startLocalSocketSignerBroker(params) {
|
|
|
196
196
|
server.once("error", reject);
|
|
197
197
|
server.listen(socketPath, () => resolve());
|
|
198
198
|
});
|
|
199
|
-
|
|
199
|
+
syncFs.chmodSync(socketPath, fileMode);
|
|
200
200
|
const close = async () => {
|
|
201
201
|
await new Promise((resolve) => {
|
|
202
202
|
server.close(() => resolve());
|
|
203
203
|
});
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
syncFs.rmSync(socketPath, { force: true });
|
|
205
|
+
syncFs.rmSync(pidFile, { force: true });
|
|
206
206
|
};
|
|
207
207
|
const shutdown = () => {
|
|
208
208
|
void close().finally(() => process.exit(0));
|
|
@@ -3,7 +3,7 @@ import { WalletProviderError } from "../wallet-provider-adapter.js";
|
|
|
3
3
|
import { buildCreateAssociatedTokenAccountIdempotentInstruction, buildTransferCheckedInstruction, deriveAssociatedTokenAddress, toTransactionInstruction } from "../solana-spl-transfer.js";
|
|
4
4
|
import { walletDiagnosticErrorString } from "../wallet-redaction.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
|
-
import
|
|
6
|
+
import syncFs from "node:fs";
|
|
7
7
|
import { createDecipheriv, randomUUID, scryptSync } from "node:crypto";
|
|
8
8
|
|
|
9
9
|
//#region src/wallet/providers/embedded-keystore-adapter.ts
|
|
@@ -118,7 +118,7 @@ var EmbeddedKeystoreAdapter = class {
|
|
|
118
118
|
details: "missing embedded keystore config (FASED_WALLET_KEYSTORE_PATH, FASED_WALLET_PASSPHRASE, FASED_WALLET_[EMBEDDED_KEYSTORE_]RPC_URL)"
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
if (!
|
|
121
|
+
if (!syncFs.existsSync(this.keystorePath)) {
|
|
122
122
|
return {
|
|
123
123
|
ok: false,
|
|
124
124
|
provider: this.id,
|
|
@@ -128,7 +128,7 @@ var EmbeddedKeystoreAdapter = class {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
try {
|
|
131
|
-
const raw = await
|
|
131
|
+
const raw = await syncFs.promises.readFile(this.keystorePath, "utf8");
|
|
132
132
|
if (detectKeystoreType(raw) !== "solana-envelope") {
|
|
133
133
|
throw new Error("keystore file is not a Solana keystore envelope");
|
|
134
134
|
}
|
|
@@ -165,7 +165,7 @@ var EmbeddedKeystoreAdapter = class {
|
|
|
165
165
|
return result;
|
|
166
166
|
}
|
|
167
167
|
try {
|
|
168
|
-
const raw = await
|
|
168
|
+
const raw = await syncFs.promises.readFile(this.keystorePath, "utf8");
|
|
169
169
|
const type = detectKeystoreType(raw);
|
|
170
170
|
if (type === "solana-envelope") {
|
|
171
171
|
if (this.supportsChain("solana")) {
|
|
@@ -375,7 +375,7 @@ var EmbeddedKeystoreAdapter = class {
|
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
377
|
this.solanaKeypairPromise ??= (async () => {
|
|
378
|
-
const raw = await
|
|
378
|
+
const raw = await syncFs.promises.readFile(this.keystorePath, "utf8");
|
|
379
379
|
const envelope = parseSolanaKeystoreEnvelope(raw);
|
|
380
380
|
if (!envelope) {
|
|
381
381
|
throw new WalletProviderError({
|
|
@@ -4,7 +4,7 @@ import { WalletProviderError } from "../wallet-provider-adapter.js";
|
|
|
4
4
|
import { buildCreateAssociatedTokenAccountIdempotentInstruction, buildTransferCheckedInstruction, deriveAssociatedTokenAddress } from "../solana-spl-transfer.js";
|
|
5
5
|
import { redactWalletDiagnosticText, walletDiagnosticErrorMessage, walletDiagnosticErrorString } from "../wallet-redaction.js";
|
|
6
6
|
import { parseLocalSocketSignerResponseEnvelope, validateLocalSocketSignerResult } from "../local-socket-signer-protocol.js";
|
|
7
|
-
import
|
|
7
|
+
import syncFs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import net from "node:net";
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ function signerTimeoutFor(payload) {
|
|
|
29
29
|
function assertSecureLocalSignerSocket(socketPath) {
|
|
30
30
|
let stat;
|
|
31
31
|
try {
|
|
32
|
-
stat =
|
|
32
|
+
stat = syncFs.lstatSync(socketPath);
|
|
33
33
|
} catch (err) {
|
|
34
34
|
throw new WalletProviderError({
|
|
35
35
|
code: "wallet_provider_unavailable",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureWalletStateDir } from "./wallet-runtime-config.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, createPublicKey, randomBytes, timingSafeEqual, verify } from "node:crypto";
|
|
5
5
|
|
|
@@ -163,7 +163,7 @@ function normalizeState(input) {
|
|
|
163
163
|
}
|
|
164
164
|
function loadState(env = process.env) {
|
|
165
165
|
const statePath = resolveStatePath(env);
|
|
166
|
-
if (!
|
|
166
|
+
if (!syncFs.existsSync(statePath)) {
|
|
167
167
|
return {
|
|
168
168
|
version: 2,
|
|
169
169
|
passkeys: [],
|
|
@@ -172,7 +172,7 @@ function loadState(env = process.env) {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
try {
|
|
175
|
-
const raw =
|
|
175
|
+
const raw = syncFs.readFileSync(statePath, "utf8");
|
|
176
176
|
return normalizeState(JSON.parse(raw));
|
|
177
177
|
} catch {
|
|
178
178
|
return {
|
|
@@ -185,12 +185,12 @@ function loadState(env = process.env) {
|
|
|
185
185
|
}
|
|
186
186
|
function saveState(state, env = process.env) {
|
|
187
187
|
const statePath = resolveStatePath(env);
|
|
188
|
-
|
|
188
|
+
syncFs.writeFileSync(statePath, `${JSON.stringify(state, null, 2)}\n`, {
|
|
189
189
|
encoding: "utf8",
|
|
190
190
|
mode: 384
|
|
191
191
|
});
|
|
192
192
|
try {
|
|
193
|
-
|
|
193
|
+
syncFs.chmodSync(statePath, 384);
|
|
194
194
|
} catch {}
|
|
195
195
|
}
|
|
196
196
|
function pruneState(state) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureWalletStateDir } from "./wallet-runtime-config.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
|
|
5
5
|
//#region src/wallet/wallet-audit-log.ts
|
|
@@ -15,22 +15,22 @@ function appendWalletAuditEntry(params) {
|
|
|
15
15
|
actor: params.actor?.trim() || "system",
|
|
16
16
|
details: params.details ?? {}
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
syncFs.appendFileSync(paths.auditLogPath, `${JSON.stringify(entry)}\n`, {
|
|
19
19
|
encoding: "utf8",
|
|
20
20
|
mode: 384
|
|
21
21
|
});
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
syncFs.chmodSync(paths.auditLogPath, 384);
|
|
24
24
|
} catch {}
|
|
25
25
|
return entry;
|
|
26
26
|
}
|
|
27
27
|
function readWalletAuditEntries(params) {
|
|
28
28
|
const paths = ensureWalletStateDir(params?.env ?? process.env);
|
|
29
|
-
if (!
|
|
29
|
+
if (!syncFs.existsSync(paths.auditLogPath)) {
|
|
30
30
|
return [];
|
|
31
31
|
}
|
|
32
32
|
const limit = Math.max(1, Math.min(500, params?.limit ?? 100));
|
|
33
|
-
const raw =
|
|
33
|
+
const raw = syncFs.readFileSync(paths.auditLogPath, "utf8");
|
|
34
34
|
const lines = raw.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
35
35
|
const out = [];
|
|
36
36
|
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
@@ -6,7 +6,7 @@ import { walletDiagnosticErrorMessage } from "./wallet-redaction.js";
|
|
|
6
6
|
import { resolveWalletProviderId } from "./wallet-provider-resolver.js";
|
|
7
7
|
import { consumeWalletApprovalGrant, resolveWalletApprovalAuthMode } from "./wallet-approval-auth.js";
|
|
8
8
|
import { lockLocalSignerCustody, unlockLocalSignerCustody } from "./local-socket-signer-custody.js";
|
|
9
|
-
import
|
|
9
|
+
import syncFs from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
12
12
|
|
|
@@ -164,33 +164,33 @@ function resolveCustodyShareStatePath(walletId, env = process.env) {
|
|
|
164
164
|
}
|
|
165
165
|
function locateCustodyStatePath(walletId, env = process.env) {
|
|
166
166
|
const scopedPath = resolveCustodyStatePath(walletId, env);
|
|
167
|
-
if (
|
|
167
|
+
if (syncFs.existsSync(scopedPath)) {
|
|
168
168
|
return scopedPath;
|
|
169
169
|
}
|
|
170
170
|
const legacyPath = resolveLegacyCustodyStatePath(env);
|
|
171
|
-
return
|
|
171
|
+
return syncFs.existsSync(legacyPath) ? legacyPath : scopedPath;
|
|
172
172
|
}
|
|
173
173
|
function locateCustodyShareStatePath(walletId, env = process.env) {
|
|
174
174
|
const scopedPath = resolveCustodyShareStatePath(walletId, env);
|
|
175
|
-
if (
|
|
175
|
+
if (syncFs.existsSync(scopedPath)) {
|
|
176
176
|
return scopedPath;
|
|
177
177
|
}
|
|
178
178
|
const legacyPath = resolveLegacyCustodyShareStatePath(env);
|
|
179
|
-
return
|
|
179
|
+
return syncFs.existsSync(legacyPath) ? legacyPath : scopedPath;
|
|
180
180
|
}
|
|
181
181
|
function listCustodyStateTargets(env = process.env) {
|
|
182
182
|
const walletPaths = ensureWalletStateDir(env);
|
|
183
183
|
const custodyRoot = path.join(walletPaths.rootDir, "custody");
|
|
184
184
|
const targets = new Set();
|
|
185
|
-
if (
|
|
186
|
-
for (const entry of
|
|
185
|
+
if (syncFs.existsSync(custodyRoot)) {
|
|
186
|
+
for (const entry of syncFs.readdirSync(custodyRoot, { withFileTypes: true })) {
|
|
187
187
|
if (entry.isDirectory() && entry.name.trim()) {
|
|
188
188
|
targets.add(entry.name.trim());
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
const out = [...targets];
|
|
193
|
-
if (
|
|
193
|
+
if (syncFs.existsSync(resolveLegacyCustodyStatePath(env)) || out.length === 0) {
|
|
194
194
|
out.push(undefined);
|
|
195
195
|
}
|
|
196
196
|
return out;
|
|
@@ -525,11 +525,11 @@ function resolveWalletCustodyScope(params) {
|
|
|
525
525
|
}
|
|
526
526
|
function loadShareState(walletId, env = process.env) {
|
|
527
527
|
const filePath = locateCustodyShareStatePath(walletId, env);
|
|
528
|
-
if (!
|
|
528
|
+
if (!syncFs.existsSync(filePath)) {
|
|
529
529
|
return null;
|
|
530
530
|
}
|
|
531
531
|
try {
|
|
532
|
-
const parsed = JSON.parse(
|
|
532
|
+
const parsed = JSON.parse(syncFs.readFileSync(filePath, "utf8"));
|
|
533
533
|
if (parsed.version === 1 && parsed.scheme === "xor-3of3-v1" && typeof parsed.secretBytes === "number" && parsed.secretBytes > 0 && typeof parsed.hotShare === "string" && typeof parsed.coldShare === "string" && typeof parsed.deviceShareHash === "string" && typeof parsed.secretChecksum === "string" && typeof parsed.createdAt === "string" && typeof parsed.updatedAt === "string") {
|
|
534
534
|
const hot = decodeBase64Share(parsed.hotShare);
|
|
535
535
|
const cold = decodeBase64Share(parsed.coldShare);
|
|
@@ -596,16 +596,16 @@ function loadShareState(walletId, env = process.env) {
|
|
|
596
596
|
}
|
|
597
597
|
function saveShareState(state, walletId, env = process.env) {
|
|
598
598
|
const filePath = resolveCustodyShareStatePath(walletId, env);
|
|
599
|
-
|
|
599
|
+
syncFs.mkdirSync(path.dirname(filePath), {
|
|
600
600
|
recursive: true,
|
|
601
601
|
mode: 448
|
|
602
602
|
});
|
|
603
|
-
|
|
603
|
+
syncFs.writeFileSync(filePath, `${JSON.stringify(state, null, 2)}\n`, {
|
|
604
604
|
encoding: "utf8",
|
|
605
605
|
mode: 384
|
|
606
606
|
});
|
|
607
607
|
try {
|
|
608
|
-
|
|
608
|
+
syncFs.chmodSync(filePath, 384);
|
|
609
609
|
} catch {}
|
|
610
610
|
}
|
|
611
611
|
function deleteWalletCustodyCeremony(params) {
|
|
@@ -620,11 +620,11 @@ function deleteWalletCustodyCeremony(params) {
|
|
|
620
620
|
role: "vault"
|
|
621
621
|
};
|
|
622
622
|
const statePath = locateCustodyShareStatePath(scope.walletId, env);
|
|
623
|
-
const existed =
|
|
623
|
+
const existed = syncFs.existsSync(statePath);
|
|
624
624
|
if (existed) {
|
|
625
|
-
|
|
625
|
+
syncFs.rmSync(statePath, { force: true });
|
|
626
626
|
try {
|
|
627
|
-
|
|
627
|
+
syncFs.rmdirSync(path.dirname(statePath));
|
|
628
628
|
} catch {}
|
|
629
629
|
}
|
|
630
630
|
return {
|
|
@@ -1015,14 +1015,14 @@ function revokeWalletCustodyDevice(params) {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
function loadState(walletId, env = process.env) {
|
|
1017
1017
|
const filePath = locateCustodyStatePath(walletId, env);
|
|
1018
|
-
if (!
|
|
1018
|
+
if (!syncFs.existsSync(filePath)) {
|
|
1019
1019
|
return {
|
|
1020
1020
|
version: 1,
|
|
1021
1021
|
unlockSessions: []
|
|
1022
1022
|
};
|
|
1023
1023
|
}
|
|
1024
1024
|
try {
|
|
1025
|
-
const parsed = JSON.parse(
|
|
1025
|
+
const parsed = JSON.parse(syncFs.readFileSync(filePath, "utf8"));
|
|
1026
1026
|
if (parsed.version !== 1 || !Array.isArray(parsed.unlockSessions)) {
|
|
1027
1027
|
return {
|
|
1028
1028
|
version: 1,
|
|
@@ -1065,16 +1065,16 @@ function loadState(walletId, env = process.env) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
function saveState(state, walletId, env = process.env) {
|
|
1067
1067
|
const filePath = resolveCustodyStatePath(walletId, env);
|
|
1068
|
-
|
|
1068
|
+
syncFs.mkdirSync(path.dirname(filePath), {
|
|
1069
1069
|
recursive: true,
|
|
1070
1070
|
mode: 448
|
|
1071
1071
|
});
|
|
1072
|
-
|
|
1072
|
+
syncFs.writeFileSync(filePath, `${JSON.stringify(state, null, 2)}\n`, {
|
|
1073
1073
|
encoding: "utf8",
|
|
1074
1074
|
mode: 384
|
|
1075
1075
|
});
|
|
1076
1076
|
try {
|
|
1077
|
-
|
|
1077
|
+
syncFs.chmodSync(filePath, 384);
|
|
1078
1078
|
} catch {}
|
|
1079
1079
|
}
|
|
1080
1080
|
function pruneState(state) {
|
|
@@ -4,7 +4,7 @@ import { buildWalletProviderCapabilityMatrix, providerSupportsChainOperation } f
|
|
|
4
4
|
import { walletDiagnosticErrorString } from "./wallet-redaction.js";
|
|
5
5
|
import { createWalletProviderAdapter, resolveWalletProviderId } from "./wallet-provider-resolver.js";
|
|
6
6
|
import { appendWalletAuditEntry, readWalletAuditEntries } from "./wallet-audit-log.js";
|
|
7
|
-
import
|
|
7
|
+
import syncFs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { randomBytes } from "node:crypto";
|
|
10
10
|
|
|
@@ -174,11 +174,11 @@ function normalizeLedger(raw) {
|
|
|
174
174
|
}
|
|
175
175
|
function readLedger(env = process.env) {
|
|
176
176
|
const filePath = inboundLedgerPath(env);
|
|
177
|
-
if (!
|
|
177
|
+
if (!syncFs.existsSync(filePath)) {
|
|
178
178
|
return defaultLedger();
|
|
179
179
|
}
|
|
180
180
|
try {
|
|
181
|
-
const parsed = JSON.parse(
|
|
181
|
+
const parsed = JSON.parse(syncFs.readFileSync(filePath, "utf8"));
|
|
182
182
|
return normalizeLedger(parsed);
|
|
183
183
|
} catch {
|
|
184
184
|
return defaultLedger();
|
|
@@ -191,12 +191,12 @@ function writeLedger(ledger, env = process.env) {
|
|
|
191
191
|
version: 1,
|
|
192
192
|
updatedAt: nowIso()
|
|
193
193
|
};
|
|
194
|
-
|
|
194
|
+
syncFs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
195
195
|
encoding: "utf8",
|
|
196
196
|
mode: 384
|
|
197
197
|
});
|
|
198
198
|
try {
|
|
199
|
-
|
|
199
|
+
syncFs.chmodSync(filePath, 384);
|
|
200
200
|
} catch {}
|
|
201
201
|
}
|
|
202
202
|
function findWalletById(env, walletId) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureWalletStateDir } from "./wallet-runtime-config.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/wallet/wallet-observability.ts
|
|
5
5
|
const OBSERVABILITY_FILENAME = "observability.v1.json";
|
|
@@ -37,11 +37,11 @@ function sanitizeBucket(input) {
|
|
|
37
37
|
}
|
|
38
38
|
function readSnapshot(env) {
|
|
39
39
|
const file = observabilityPath(env);
|
|
40
|
-
if (!
|
|
40
|
+
if (!syncFs.existsSync(file)) {
|
|
41
41
|
return makeDefaultSnapshot();
|
|
42
42
|
}
|
|
43
43
|
try {
|
|
44
|
-
const parsed = JSON.parse(
|
|
44
|
+
const parsed = JSON.parse(syncFs.readFileSync(file, "utf8"));
|
|
45
45
|
if (parsed?.version !== 1) {
|
|
46
46
|
return makeDefaultSnapshot();
|
|
47
47
|
}
|
|
@@ -60,12 +60,12 @@ function readSnapshot(env) {
|
|
|
60
60
|
}
|
|
61
61
|
function writeSnapshot(env, snapshot) {
|
|
62
62
|
const file = observabilityPath(env);
|
|
63
|
-
|
|
63
|
+
syncFs.writeFileSync(file, `${JSON.stringify(snapshot, null, 2)}\n`, {
|
|
64
64
|
mode: 384,
|
|
65
65
|
encoding: "utf8"
|
|
66
66
|
});
|
|
67
67
|
try {
|
|
68
|
-
|
|
68
|
+
syncFs.chmodSync(file, 384);
|
|
69
69
|
} catch {}
|
|
70
70
|
}
|
|
71
71
|
function incrementWalletObservabilityCounter(params) {
|