Skip to content

Commit 9b7428d

Browse files
committed
refactor(cursor): API key exchange always uses the default endpoint
1 parent d340b12 commit 9b7428d

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎packages/provider-cursor/src/server/accountUsage.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const readCursorAccountUsage = Effect.fn("readCursorAccountUsage")(functi
123123
Effect.map((credentials) => object(credentials).accessToken),
124124
)
125125
: credentialSource.kind === "apiKey"
126-
? exchangeCursorApiKey(DEFAULT_CURSOR_API_ENDPOINT, credentialSource.apiKey).pipe(
126+
? exchangeCursorApiKey(credentialSource.apiKey).pipe(
127127
Effect.provideService(HttpClient.HttpClient, httpClient),
128128
Effect.mapError(
129129
() => new CursorAccountUsageInvalidError({ reason: "Invalid API key" }),

‎packages/provider-cursor/src/server/apiKey.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ export const DEFAULT_CURSOR_API_ENDPOINT = "https://api2.cursor.sh";
99
const ApiKeyExchange = Schema.Struct({ accessToken: Schema.NonEmptyString });
1010

1111
/** Trades a user API key for the access token Cursor's RPCs accept, as `@cursor/sdk` does. */
12-
export const exchangeCursorApiKey = Effect.fn("exchangeCursorApiKey")(function* (
13-
endpoint: string,
14-
apiKey: string,
15-
) {
12+
export const exchangeCursorApiKey = Effect.fn("exchangeCursorApiKey")(function* (apiKey: string) {
1613
const client = yield* HttpClient.HttpClient;
1714
const response = yield* client.execute(
18-
HttpClientRequest.post(`${endpoint}/auth/exchange_user_api_key`).pipe(
15+
HttpClientRequest.post(`${DEFAULT_CURSOR_API_ENDPOINT}/auth/exchange_user_api_key`).pipe(
1916
HttpClientRequest.bearerToken(apiKey),
2017
HttpClientRequest.bodyJsonUnsafe({}),
2118
),

‎packages/provider-cursor/src/server/usageLimits.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const readCursorUsageLimits = Effect.fn("readCursorUsageLimits")(function
8888
message: "Cursor usage for an API key requires the default Cursor endpoint.",
8989
});
9090
}
91-
token = yield* exchangeCursorApiKey(endpoint, apiKey);
91+
token = yield* exchangeCursorApiKey(apiKey);
9292
} else if (!token && credentialStore === "memory") {
9393
return makeUnavailableUsageLimits({
9494
checkedAt,

0 commit comments

Comments
 (0)