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
6 changes: 5 additions & 1 deletion src/oauth/google-antigravity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const REFRESH_SKEW_MS = 5 * 60 * 1000;
const REQUEST_TIMEOUT_MS = 30_000;
const ONBOARD_ATTEMPTS = 5;
const ONBOARD_POLL_MS = 2_000;
// A person without a local browser copies the redirect URL from the address bar and pastes it back by
// hand, which takes far longer than the callback base class's default wait.
const ANTIGRAVITY_LOGIN_TIMEOUT_MS = 20 * 60 * 1000;

function requestSignal(signal: AbortSignal | undefined): AbortSignal {
const timeout = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
Expand Down Expand Up @@ -159,7 +162,7 @@ function credentialsFromPayload(payload: GoogleTokenPayload, refreshFallback = "
};
}

class AntigravityOAuthFlow extends OAuthCallbackFlow {
export class AntigravityOAuthFlow extends OAuthCallbackFlow {
#verifier = "";
#forceAccountSelect: boolean;

Expand All @@ -170,6 +173,7 @@ class AntigravityOAuthFlow extends OAuthCallbackFlow {
callbackHostname: "127.0.0.1",
callbackBindHostname: "127.0.0.1",
redirectUri: `http://127.0.0.1:${CALLBACK_PORT}${CALLBACK_PATH}`,
timeoutMs: ANTIGRAVITY_LOGIN_TIMEOUT_MS,
} satisfies OAuthCallbackFlowOptions);
this.#forceAccountSelect = opts?.forceAccountSelect === true;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/oauth/oauth-callback-server.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test } from "bun:test";
import { AntigravityOAuthFlow } from "../../src/oauth/google-antigravity";
import { OAuthCallbackFlow, type OAuthCallbackFlowOptions } from "../../src/oauth/callback-server";
import type { OAuthController, OAuthCredentials } from "../../src/oauth/types";

Expand Down Expand Up @@ -89,6 +90,12 @@ describe("OAuth callback server defaults", () => {
}
});

test("Google Antigravity sign-in waits 20 minutes for the pasted redirect URL, not the 5-minute default", () => {
// A person without a local browser copies the redirect URL from the address bar and pastes it back by hand.
const flow = new AntigravityOAuthFlow({ onAuth: () => {} } as unknown as OAuthController);
expect(flow.timeoutMs).toBe(20 * 60 * 1000);
});

test("manual-input loop rejects a code#state paste with a foreign suffix and re-prompts", async () => {
let prompts = 0;
const flow = new ManualFallbackFlow(
Expand Down
Loading