fix(server): load Cursor keyring with createRequire (#13678)

This commit is contained in:
Yash Singh authored and GitHub committed 2026-09-25 15:17:22 -05:00
1 parent 1a0c915c41
commit f5bd2fddbf
1 file changed
+5 -1
@@ -1,5 +1,9 @@
import * as NodeModule from "node:module";
const CACHE_MS = 5 * 60_000;
const requireForKeyring = NodeModule.createRequire(import.meta.url);
/** Share one Keychain request across usage history and limits in this server process. */
export function makeCachedCursorAccessTokenReader(
read: () => Promise<string | null>,
@@ -24,6 +28,6 @@ export function makeCachedCursorAccessTokenReader(
/** 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;
});