Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/server/src/provider/cursorCredentialStore.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as NodeModule from "node:module";

const CACHE_MS = 5 * 60_000;

/** Share one Keychain request across usage history and limits in this server process. */
Expand All @@ -22,8 +24,12 @@ export function makeCachedCursorAccessTokenReader(
};
}

// `import()` cannot load file-backed packages inside the single-executable CLI;
// `require` reads the real filesystem.
const requireForKeyring = NodeModule.createRequire(import.meta.url);

/** Read the Cursor CLI's default macOS credential without invoking the shared security binary. */
export const readMacCursorAccessToken = makeCachedCursorAccessTokenReader(async () => {
const { AsyncEntry } = await import("@napi-rs/keyring");
const { AsyncEntry } = requireForKeyring("@napi-rs/keyring") as typeof import("@napi-rs/keyring");
return (await new AsyncEntry("cursor-access-token", "cursor-user").getPassword()) ?? null;
});
Loading