Compare commits

...

1 Commits

Author SHA1 Message Date
abeatrix 1d504df0f2 feat(auth): add User-Agent header with extension version to Auth requests
Add User-Agent header containing the extension version to all HTTP requests
made by ClineAuthProvider, including token refresh, and authorization calls.
This enables better client identification and version tracking on the API side
for debugging and analytics purposes.

Changes:
- Import extension version from package.json
- Include User-Agent header in refresh token endpoint request
- Include User-Agent header in user info endpoint request
- Include User-Agent header in authorization code exchange request
2025-12-01 19:23:04 -08:00
@@ -6,6 +6,7 @@ import { AuthInvalidTokenError, AuthNetworkError } from "@/services/error/ClineE
import { Logger } from "@/services/logging/Logger"
import { CLINE_API_ENDPOINT } from "@/shared/cline/api"
import { fetch, getAxiosSettings } from "@/shared/net"
import { version as extensionVersion } from "../../../../package.json"
import { type ClineAccountUserInfo, type ClineAuthInfo } from "../AuthService"
import { IAuthProvider } from "./IAuthProvider"
@@ -224,7 +225,7 @@ export class ClineAuthProvider implements IAuthProvider {
const endpoint = new URL(CLINE_API_ENDPOINT.REFRESH_TOKEN, this.config.apiBaseUrl)
const response = await fetch(endpoint.toString(), {
method: "POST",
headers: { "Content-Type": "application/json" },
headers: { "Content-Type": "application/json", "User-Agent": extensionVersion },
body: JSON.stringify({
refreshToken,
grantType: "refresh_token",
@@ -287,6 +288,7 @@ export class ClineAuthProvider implements IAuthProvider {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
"User-Agent": extensionVersion,
},
})
@@ -327,6 +329,7 @@ export class ClineAuthProvider implements IAuthProvider {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"User-Agent": extensionVersion,
},
body: JSON.stringify({
grant_type: "authorization_code",