diff --git a/bun.lock b/bun.lock old mode 100755 new mode 100644 index 57b54b5..1a69048 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { - "lockfileVersion": 0, + "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "dependencies": { @@ -8,6 +9,7 @@ "applesauce-core": "^5.1.0", "applesauce-relay": "^5.1.0", "commander": "^14.0.2", + "nostr-tools": "^2.12.0", "qrcode": "^1.5.4", "rxjs": "^7.8.1", "zustand": "^5.0.5", diff --git a/src/cli.ts b/src/cli.ts index be65236..13297b6 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -7,7 +7,6 @@ import { isDaemonRunning, loadConfig, getDaemonBaseUrl, - getNpubSuffix, getUserNpub, } from "./utils/daemon-client"; import { diff --git a/src/tui/usage/data.ts b/src/tui/usage/data.ts index 8aade1f..cdcfa53 100644 --- a/src/tui/usage/data.ts +++ b/src/tui/usage/data.ts @@ -1,5 +1,5 @@ import type { UsageTrackingEntry } from "../../daemon/types.ts"; -import { callDaemon, getNpubSuffix, isDaemonRunning, loadConfig } from "../../utils/daemon-client.ts"; +import { callDaemon, isDaemonRunning } from "../../utils/daemon-client.ts"; import type { ClientStats, DayStats, ModelStats, ProviderStats, UsageStats } from "./types.ts"; export interface BalanceKey { @@ -82,21 +82,10 @@ export async function fetchUsage(limit = 10000): Promise { const result = await callDaemon(`/usage?limit=${limit}`); if (result.error) return null; - // The daemon returns { output: [...] } where output is the entries array directly. - // In remote daemon mode, client IDs are suffixed with the last 7 chars of our npub. - // Fetch the full daemon result, but only display/aggregate entries for our clients. + // The auth proxy filters usage to the authenticated npub's clients and + // returns client IDs without the owner suffix. const entries = result.output as UsageTrackingEntry[] | undefined; - const entriesArray = Array.isArray(entries) ? entries : []; - const suffix = getNpubSuffix(await loadConfig()); - const suffixStr = suffix ? `-${suffix}` : null; - const visibleEntries = suffixStr - ? entriesArray - .filter((entry) => entry.client?.endsWith(suffixStr)) - .map((entry) => ({ - ...entry, - client: entry.client?.slice(0, -suffixStr.length), - })) - : entriesArray; + const visibleEntries = Array.isArray(entries) ? entries : []; // Calculate totals from visible entries const totals = visibleEntries.reduce(