chore(release): v2.7.0 — Silicon Valley OAuth 2.1 + Aura SSO/Google Sign-In, Antigravity Plugin & Glama parity

This commit is contained in:
Amirul Islam Redwan71
2026-11-24 05:05:07 +06:00
parent eeba92042c
commit 8aa306bf63
21 changed files with 1534 additions and 723 deletions
+193 -124
View File
@@ -1,11 +1,12 @@
import test from "node:test";
import assert from "node:assert/strict";
import http from "node:http";
import { createHash, randomBytes } from "node:crypto";
import { createHash, createHmac, randomBytes } from "node:crypto";
process.env.NODE_ENV = "test";
process.env.AURA_API_KEY = "aura_test_master_key_oauth21";
process.env.AURA_READONLY_KEY = "aura_ro_test_reader_oauth21";
process.env.AURA_SSO_JWT_SECRET = "aura_test_sso_jwt_secret_2026";
process.env.STEADFAST_API_KEY = "sf_test_key";
process.env.STEADFAST_SECRET_KEY = "sf_test_secret";
@@ -30,6 +31,21 @@ function makePkcePair() {
return { verifier, challenge };
}
function makeAuraSsoCookie(payload) {
const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" })).toString("base64url");
const body = Buffer.from(
JSON.stringify({
...payload,
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 900,
})
).toString("base64url");
const sig = createHmac("sha256", Buffer.from(process.env.AURA_SSO_JWT_SECRET, "utf8"))
.update(`${header}.${body}`)
.digest("base64url");
return `aura_access=${header}.${body}.${sig}`;
}
function extractHiddenInput(html, name) {
const re = new RegExp(`name="${name}"\\s+value="([^"]*)"`, "i");
const m = html.match(re);
@@ -49,7 +65,7 @@ test.after(async () => {
}
});
test("OAuth 1: 401 on unauthenticated POST /mcp (initialize & tools/call) and GET /mcp includes RFC 9728 WWW-Authenticate header", async () => {
test("OAuth 1: 401 on unauthenticated POST /mcp (initialize) and GET /mcp includes RFC 9728 WWW-Authenticate header", async () => {
const initRes = await fetch(`${baseUrl}/mcp`, {
method: "POST",
headers: { "Content-Type": "application/json" },
@@ -103,7 +119,7 @@ test("OAuth 3: RFC 7591 Dynamic Client Registration allows Google googleusercont
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
client_name: "Google Gemini MCP",
client_name: "Google Gemini",
redirect_uris: ["https://oauth-redirect.googleusercontent.com/r/gemini-aura-test"],
token_endpoint_auth_method: "none",
}),
@@ -126,7 +142,117 @@ test("OAuth 3: RFC 7591 Dynamic Client Registration allows Google googleusercont
assert.equal(badBody.error, "invalid_redirect_uri");
});
test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rotating Refresh -> Static Dual-Auth -> Revocation", async () => {
test("OAuth 4: Consent UI is global Silicon Valley grade (inline SVG logo, Google SSO, zero internal Snehalata/test-key leaks)", async () => {
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-ui-audit";
const { challenge } = makePkcePair();
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
authUrl.searchParams.set("response_type", "code");
authUrl.searchParams.set("client_id", "google-gemini");
authUrl.searchParams.set("redirect_uri", redirectUri);
authUrl.searchParams.set("scope", "read write");
authUrl.searchParams.set("state", "st_ui");
authUrl.searchParams.set("code_challenge", challenge);
authUrl.searchParams.set("code_challenge_method", "S256");
const res = await fetch(authUrl.toString());
assert.equal(res.status, 200);
const html = await res.text();
// Inline SVG logo (no external img tag that can break)
assert.ok(html.includes("<svg") && html.includes('aria-label="Aura Courier MCP"'));
assert.ok(!html.includes("/assets/courier-logo.jpg"));
// Global SSO + Google Sign-In present
assert.ok(html.includes("Continue with Google"));
assert.ok(html.includes("https://auth.auraajenticai.cloud/login/google"));
assert.ok(html.includes("Continue in Read-Only Sandbox"));
// Zero internal brand or raw test-key leaks
assert.ok(!/snehalata/i.test(html));
assert.ok(!html.includes("snl_mcp_"));
assert.ok(!html.includes("aura_ro_public_inspector_2026"));
assert.ok(!html.includes("Master Key"));
});
test("OAuth 5: 1-Click Aura SSO cookie (aura_access) authorizes owner with full master access & zero key typing", async () => {
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-sso-owner";
const { verifier, challenge } = makePkcePair();
const ssoCookie = makeAuraSsoCookie({
sub: "11111111-2222-3333-4444-555555555555",
email: "ceo@auraajenticai.cloud",
role: "owner",
});
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
authUrl.searchParams.set("response_type", "code");
authUrl.searchParams.set("client_id", "google-gemini");
authUrl.searchParams.set("redirect_uri", redirectUri);
authUrl.searchParams.set("scope", "read write");
authUrl.searchParams.set("state", "st_sso");
authUrl.searchParams.set("code_challenge", challenge);
authUrl.searchParams.set("code_challenge_method", "S256");
const consentRes = await fetch(authUrl.toString(), { headers: { Cookie: ssoCookie } });
assert.equal(consentRes.status, 200);
const consentHtml = await consentRes.text();
assert.ok(consentHtml.includes("ceo@auraajenticai.cloud"));
assert.ok(consentHtml.includes("Allow Access"));
const csrfToken = extractHiddenInput(consentHtml, "csrf_token");
const approveRes = await fetch(`${baseUrl}/oauth/authorize`, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Cookie: ssoCookie,
},
body: new URLSearchParams({
client_id: "google-gemini",
redirect_uri: redirectUri,
state: "st_sso",
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
auth_mode: "sso",
decision: "approve",
}).toString(),
redirect: "manual",
});
assert.equal(approveRes.status, 302);
const code = new URL(approveRes.headers.get("location")).searchParams.get("code");
const tokRes = await fetch(`${baseUrl}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "authorization_code",
code,
client_id: "google-gemini",
redirect_uri: redirectUri,
code_verifier: verifier,
}).toString(),
});
assert.equal(tokRes.status, 200);
const tokens = await tokRes.json();
assert.equal(tokens.scope, "read write");
const mcpCall = await fetch(`${baseUrl}/mcp`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${tokens.access_token}`,
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 50,
method: "tools/call",
params: { name: "get_balance", arguments: { courier: "steadfast" } },
}),
});
assert.equal(mcpCall.status, 200);
const body = await mcpCall.json();
assert.equal(body.result.isError, false);
assert.equal(JSON.parse(body.result.content[0].text).data.amount_bdt, 14250);
});
test("OAuth 6: End-to-End API Key PKCE S256 flow -> Non-Rotating Refresh -> Static Dual-Auth -> Revocation", async () => {
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-live-flow";
const regRes = await fetch(`${baseUrl}/oauth/register`, {
method: "POST",
@@ -143,7 +269,6 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
const { verifier, challenge } = makePkcePair();
const state = "gemini_state_xyz_991";
// Step 4a: GET /oauth/authorize consent screen
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
authUrl.searchParams.set("response_type", "code");
authUrl.searchParams.set("client_id", clientId);
@@ -153,85 +278,73 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
authUrl.searchParams.set("code_challenge", challenge);
authUrl.searchParams.set("code_challenge_method", "S256");
const consentRes = await fetch(authUrl.toString());
assert.equal(consentRes.status, 200);
const consentHtml = await consentRes.text();
assert.ok(consentHtml.includes("Google Gemini"));
assert.ok(consentHtml.includes("oauth-redirect.googleusercontent.com"));
const consentHtml = await (await fetch(authUrl.toString())).text();
const csrfToken = extractHiddenInput(consentHtml, "csrf_token");
assert.ok(csrfToken.length > 10);
// Step 4b: Deny redirects with error=access_denied
const denyForm = new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
state,
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
decision: "deny",
});
// Deny -> error=access_denied
const denyRes = await fetch(`${baseUrl}/oauth/authorize`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: denyForm.toString(),
body: new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
state,
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
auth_mode: "apikey",
decision: "deny",
}).toString(),
redirect: "manual",
});
assert.equal(denyRes.status, 302);
const denyLoc = new URL(denyRes.headers.get("location"));
assert.equal(denyLoc.searchParams.get("error"), "access_denied");
assert.equal(denyLoc.searchParams.get("state"), state);
assert.equal(new URL(denyRes.headers.get("location")).searchParams.get("error"), "access_denied");
// Step 4c: Invalid API key stays on consent form with error message
const badKeyForm = new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
state,
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
decision: "approve",
api_key: "totally_wrong_key_123",
});
// Invalid API key stays on form with clean error
const badKeyRes = await fetch(`${baseUrl}/oauth/authorize`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: badKeyForm.toString(),
body: new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
state,
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
auth_mode: "apikey",
decision: "approve",
api_key: "totally_wrong_key_123",
}).toString(),
redirect: "manual",
});
assert.equal(badKeyRes.status, 200);
const badKeyHtml = await badKeyRes.text();
assert.ok(badKeyHtml.includes("Invalid API Key"));
assert.ok((await badKeyRes.text()).includes("Invalid API key"));
// Step 4d: Valid Master Key redirects 302 with single-use authorization code
const okForm = new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
state,
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
decision: "approve",
api_key: process.env.AURA_API_KEY,
});
// Valid API key -> 302 with code
const approveRes = await fetch(`${baseUrl}/oauth/authorize`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: okForm.toString(),
body: new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
state,
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
auth_mode: "apikey",
decision: "approve",
api_key: process.env.AURA_API_KEY,
}).toString(),
redirect: "manual",
});
assert.equal(approveRes.status, 302);
const cbUrl = new URL(approveRes.headers.get("location"));
assert.equal(cbUrl.origin + cbUrl.pathname, redirectUri);
assert.equal(cbUrl.searchParams.get("state"), state);
const authCode = cbUrl.searchParams.get("code");
assert.ok(authCode && authCode.split(".").length === 3);
const authCode = new URL(approveRes.headers.get("location")).searchParams.get("code");
// Step 4e: Wrong PKCE code_verifier is rejected
const wrongPkceRes = await fetch(`${baseUrl}/oauth/token`, {
// Wrong PKCE rejected
const wrongPkce = await fetch(`${baseUrl}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
@@ -242,10 +355,9 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
code_verifier: "wrong_verifier_abcdefghijklmnopqrstuvwxyz_0123456789",
}).toString(),
});
assert.equal(wrongPkceRes.status, 400);
assert.equal((await wrongPkceRes.json()).error, "invalid_grant");
assert.equal(wrongPkce.status, 400);
// Step 4f: Correct PKCE code_verifier issues access_token + refresh_token
// Correct PKCE -> tokens
const tokRes = await fetch(`${baseUrl}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
@@ -260,12 +372,8 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
assert.equal(tokRes.status, 200);
const tokens = await tokRes.json();
assert.equal(tokens.token_type, "Bearer");
assert.equal(tokens.expires_in, 3600);
assert.ok(tokens.access_token && tokens.access_token.startsWith("eyJ"));
assert.ok(tokens.refresh_token && tokens.refresh_token.startsWith("eyJ"));
assert.equal(tokens.scope, "read write");
// Step 4g: Authorization code replay is rejected
// Replay rejected
const replayRes = await fetch(`${baseUrl}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
@@ -278,48 +386,9 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
}).toString(),
});
assert.equal(replayRes.status, 400);
assert.equal((await replayRes.json()).error, "invalid_grant");
// Step 4h: Call /mcp initialize & tools/call with OAuth Bearer token
const mcpInit = await fetch(`${baseUrl}/mcp`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",
Authorization: `Bearer ${tokens.access_token}`,
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 10,
method: "initialize",
params: { protocolVersion: "2025-03-26", capabilities: {}, clientInfo: { name: "Google Gemini", version: "1.0" } },
}),
});
assert.equal(mcpInit.status, 200);
assert.ok(mcpInit.headers.get("mcp-session-id"));
const mcpCall = await fetch(`${baseUrl}/mcp`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",
Authorization: `Bearer ${tokens.access_token}`,
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 11,
method: "tools/call",
params: { name: "get_balance", arguments: { courier: "steadfast" } },
}),
});
assert.equal(mcpCall.status, 200);
const mcpBody = await mcpCall.json();
assert.equal(mcpBody.result.isError, false);
const env = JSON.parse(mcpBody.result.content[0].text);
assert.equal(env.data.amount_bdt, 14250);
// Step 4i: Refresh token returns fresh access_token AND keeps refresh_token NON-ROTATING for Gemini
const refreshRes = await fetch(`${baseUrl}/oauth/token`, {
// Non-rotating refresh token
const refRes = await fetch(`${baseUrl}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
@@ -328,12 +397,12 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
client_id: clientId,
}).toString(),
});
assert.equal(refreshRes.status, 200);
const refreshed = await refreshRes.json();
assert.ok(refreshed.access_token && refreshed.access_token !== tokens.access_token);
assert.equal(refRes.status, 200);
const refreshed = await refRes.json();
assert.equal(refreshed.refresh_token, tokens.refresh_token);
assert.notEqual(refreshed.access_token, tokens.access_token);
// Step 4j: Existing static Bearer API Key still works identically (Dual-Auth)
// Static Dual-Auth still works
const staticRes = await fetch(`${baseUrl}/mcp`, {
method: "POST",
headers: {
@@ -349,7 +418,7 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
});
assert.equal(staticRes.status, 200);
// Step 4k: Revoke OAuth access_token -> subsequent /mcp returns 401 with error="invalid_token"
// Revocation
const revRes = await fetch(`${baseUrl}/oauth/revoke`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
@@ -374,16 +443,16 @@ test("OAuth 4: End-to-End Gemini PKCE S256 flow -> OAuth Bearer /mcp -> Non-Rota
assert.ok((afterRev.headers.get("www-authenticate") || "").includes('error="invalid_token"'));
});
test("OAuth 5: Read-Only key authorization strictly limits OAuth JWT to read scope", async () => {
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-ro-check";
test("OAuth 7: 1-Click Read-Only Sandbox strictly limits scope to read without exposing any raw API key", async () => {
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-sandbox";
const { verifier, challenge } = makePkcePair();
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
authUrl.searchParams.set("response_type", "code");
authUrl.searchParams.set("client_id", "gemini-ro-client");
authUrl.searchParams.set("client_id", "gemini-sandbox");
authUrl.searchParams.set("redirect_uri", redirectUri);
authUrl.searchParams.set("scope", "read write");
authUrl.searchParams.set("state", "st_ro");
authUrl.searchParams.set("state", "st_sbx");
authUrl.searchParams.set("code_challenge", challenge);
authUrl.searchParams.set("code_challenge_method", "S256");
@@ -394,15 +463,15 @@ test("OAuth 5: Read-Only key authorization strictly limits OAuth JWT to read sco
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
client_id: "gemini-ro-client",
client_id: "gemini-sandbox",
redirect_uri: redirectUri,
state: "st_ro",
state: "st_sbx",
scope: "read write",
code_challenge: challenge,
code_challenge_method: "S256",
csrf_token: csrfToken,
decision: "approve",
api_key: process.env.AURA_READONLY_KEY,
auth_mode: "sandbox",
decision: "sandbox",
}).toString(),
redirect: "manual",
});
@@ -415,7 +484,7 @@ test("OAuth 5: Read-Only key authorization strictly limits OAuth JWT to read sco
body: new URLSearchParams({
grant_type: "authorization_code",
code,
client_id: "gemini-ro-client",
client_id: "gemini-sandbox",
redirect_uri: redirectUri,
code_verifier: verifier,
}).toString(),