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