Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/adapters/client-fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export function claudeCodeSessionId(token: string | undefined): string {
export const ANTIGRAVITY_IDE_VERSION = "2.5.5";
const ANTIGRAVITY_IDE_CLIENT_NAME = "aidev_client";
const ANTIGRAVITY_IDE_PLATFORM = "windows/amd64";
/** Secondary Google API client UA the Antigravity client library reports. */
export const ANTIGRAVITY_GOOG_API_CLIENT_UA = "google-api-nodejs-client/10.3.0";

/**
* The real Antigravity IDE User-Agent, e.g.
Expand Down
6 changes: 3 additions & 3 deletions src/oauth/google-antigravity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { OAuthCallbackFlow, type OAuthCallbackFlowOptions } from "./callback-server";
import { generatePKCE } from "./pkce";
import type { OAuthController, OAuthCredentials } from "./types";
import { antigravityUserAgent, ANTIGRAVITY_GOOG_API_CLIENT_UA } from "../adapters/client-fingerprint";
import { ANTIGRAVITY_IDE_VERSION, antigravityUserAgent } from "../adapters/client-fingerprint";

const CLIENT_ID = process.env.GOOGLE_ANTIGRAVITY_CLIENT_ID
|| "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com";
Expand Down Expand Up @@ -110,8 +110,8 @@ async function onboardProject(accessToken: string, signal?: AbortSignal): Promis
if (signal?.aborted) throw signal.reason ?? new Error("Antigravity onboarding aborted");
const response = await fetch(`${DAILY_API}/${API_VERSION}:onboardUser`, {
method: "POST",
headers: { Authorization: `Bearer ${accessToken}`, Accept: "*/*", "Content-Type": "application/json", "User-Agent": antigravityUserAgent(), "x-goog-api-client": ANTIGRAVITY_GOOG_API_CLIENT_UA },
body: JSON.stringify({ tier_id: "free-tier", metadata: { ide_type: "ANTIGRAVITY", ide_name: "antigravity", ide_version: antigravityUserAgent() } }),
headers: { Authorization: `Bearer ${accessToken}`, Accept: "*/*", "Content-Type": "application/json", "User-Agent": antigravityUserAgent() },
body: JSON.stringify({ tier_id: "free-tier", metadata: { ide_type: "ANTIGRAVITY", ide_name: "antigravity", ide_version: ANTIGRAVITY_IDE_VERSION } }),
signal: requestSignal(signal),
});
if (!response.ok) {
Expand Down
5 changes: 0 additions & 5 deletions tests/client-fingerprint.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, expect, test } from "bun:test";
import {
ANTIGRAVITY_IDE_VERSION,
ANTIGRAVITY_GOOG_API_CLIENT_UA,
CLAUDE_CODE_HEADERS,
antigravityUserAgent,
claudeCodeSessionId,
Expand Down Expand Up @@ -42,10 +41,6 @@ describe("client fingerprint — helpers", () => {
}
});

test("secondary google api client UA is pinned", async () => {
expect(ANTIGRAVITY_GOOG_API_CLIENT_UA).toMatch(/^google-api-nodejs-client\/[\d.]+$/);
});

test("claude session id is a stable v4-shaped uuid per token", async () => {
const a = claudeCodeSessionId("tok-abc");
const b = claudeCodeSessionId("tok-abc");
Expand Down
10 changes: 9 additions & 1 deletion tests/google-antigravity-oauth.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { afterEach, describe, expect, spyOn, test } from "bun:test";
import { ANTIGRAVITY_IDE_VERSION } from "../src/adapters/client-fingerprint";
import { discoverAntigravityProject, refreshAntigravityToken } from "../src/oauth/google-antigravity";
import { mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
Expand Down Expand Up @@ -37,7 +38,14 @@ describe("antigravity project discovery", () => {

test("falls back to onboardUser poll loop (not-done then done)", async () => {
let onboardCalls = 0;
routeFetch((url) => {
routeFetch((url, init) => {
if (url.includes(":onboardUser")) {
const headers = (init?.headers ?? {}) as Record<string, string>;
expect(headers["x-goog-api-client"]).toBeUndefined();
expect(headers["User-Agent"]).toMatch(/^antigravity\/ide\//);
const body = JSON.parse(String(init?.body ?? "{}"));
expect(body.metadata?.ide_version).toBe(ANTIGRAVITY_IDE_VERSION);
}
if (url.includes(":loadCodeAssist")) return new Response(JSON.stringify({}), { status: 200 }); // no project
if (url.includes(":onboardUser")) {
onboardCalls++;
Expand Down
Loading