Fix Antigravity OAuth

This commit is contained in:
decolua
2026-03-03 16:01:10 +07:00
parent f2306e6962
commit 11b2fcd643
5 changed files with 41 additions and 49 deletions
+5 -15
View File
@@ -8,7 +8,7 @@
* This significantly reduces the risk of being flagged by Google's anti-abuse systems.
*/
import {ANTIGRAVITY_HEADERS, CLIENT_METADATA, CLOUD_CODE_API, getPlatformUserAgent} from "../config/constants.js";
import {CLOUD_CODE_API, LOAD_CODE_ASSIST_HEADERS, LOAD_CODE_ASSIST_METADATA} from "../config/constants.js";
// ─── Cache ────────────────────────────────────────────────────────────────────
// connectionId -> { projectId: string, fetchedAt: number }
@@ -159,13 +159,8 @@ export function removeConnection(connectionId) {
async function fetchProjectId(accessToken, signal) {
const response = await fetch(CLOUD_CODE_API.loadCodeAssist, {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
"User-Agent": getPlatformUserAgent(),
...ANTIGRAVITY_HEADERS
},
body: JSON.stringify({metadata: CLIENT_METADATA, mode: 1}),
headers: { ...LOAD_CODE_ASSIST_HEADERS, "Authorization": `Bearer ${accessToken}` },
body: JSON.stringify({ metadata: LOAD_CODE_ASSIST_METADATA }),
signal
});
@@ -205,7 +200,7 @@ async function fetchProjectId(accessToken, signal) {
async function onboardUser(accessToken, tierID, externalSignal) {
console.log(`[ProjectId] Onboarding user with tier: ${tierID}`);
const reqBody = {tierId: tierID, metadata: CLIENT_METADATA, mode: 1};
const reqBody = { tierId: tierID, metadata: LOAD_CODE_ASSIST_METADATA };
const MAX_ATTEMPTS = 5;
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
@@ -221,12 +216,7 @@ async function onboardUser(accessToken, tierID, externalSignal) {
try {
const response = await fetch(CLOUD_CODE_API.onboardUser, {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
"User-Agent": getPlatformUserAgent(),
...ANTIGRAVITY_HEADERS
},
headers: { ...LOAD_CODE_ASSIST_HEADERS, "Authorization": `Bearer ${accessToken}` },
body: JSON.stringify(reqBody),
signal: localCtrl.signal
});