fix(cline): use workos auth token shape
Made-with: Cursor
This commit is contained in:
parent
89405125e6
commit
29f3e1894e
4 changed files with 50 additions and 13 deletions
37
src/shared/utils/clineAuth.js
Normal file
37
src/shared/utils/clineAuth.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import pkg from "../../../package.json" with { type: "json" };
|
||||
|
||||
const APP_VERSION = pkg.version || "0.0.0";
|
||||
|
||||
export function getClineAccessToken(token) {
|
||||
if (typeof token !== "string") return "";
|
||||
const trimmed = token.trim();
|
||||
if (!trimmed) return "";
|
||||
return trimmed.startsWith("workos:") ? trimmed : `workos:${trimmed}`;
|
||||
}
|
||||
|
||||
export function getClineAuthorizationHeader(token) {
|
||||
const accessToken = getClineAccessToken(token);
|
||||
return accessToken ? `Bearer ${accessToken}` : "";
|
||||
}
|
||||
|
||||
export function buildClineHeaders(token, extraHeaders = {}) {
|
||||
const authorization = getClineAuthorizationHeader(token);
|
||||
const headers = {
|
||||
"HTTP-Referer": "https://cline.bot",
|
||||
"X-Title": "Cline",
|
||||
"User-Agent": `9Router/${APP_VERSION}`,
|
||||
"X-PLATFORM": process.platform || "unknown",
|
||||
"X-PLATFORM-VERSION": process.version || "unknown",
|
||||
"X-CLIENT-TYPE": "9router",
|
||||
"X-CLIENT-VERSION": APP_VERSION,
|
||||
"X-CORE-VERSION": APP_VERSION,
|
||||
"X-IS-MULTIROOT": "false",
|
||||
...extraHeaders,
|
||||
};
|
||||
|
||||
if (authorization) {
|
||||
headers.Authorization = authorization;
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue