| ... | ... | @@ -1,5 +1,9 @@ |
| 1 | import * as NodeModule from "node:module"; |
| 2 | |
| 1 | 3 | const CACHE_MS = 5 * 60_000; |
| 2 | 4 | |
| 5 | const requireForKeyring = NodeModule.createRequire(import.meta.url); |
| 6 | |
| 3 | 7 | /** Share one Keychain request across usage history and limits in this server process. */ |
| 4 | 8 | export function makeCachedCursorAccessTokenReader( |
| 5 | 9 | read: () => Promise<string | null>, |
| ... | ... | @@ -24,6 +28,6 @@ export function makeCachedCursorAccessTokenReader( |
| 24 | 28 | |
| 25 | 29 | /** Read the Cursor CLI's default macOS credential without invoking the shared security binary. */ |
| 26 | 30 | export const readMacCursorAccessToken = makeCachedCursorAccessTokenReader(async () => { |
| 27 | | const { AsyncEntry } = await import("@napi-rs/keyring"); |
| 31 | const { AsyncEntry } = requireForKeyring("@napi-rs/keyring") as typeof import("@napi-rs/keyring"); |
| 28 | 32 | return (await new AsyncEntry("cursor-access-token", "cursor-user").getPassword()) ?? null; |
| 29 | 33 | }); |