mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-10 09:12:27 +03:00
Compare commits
1 Commits
maint/cher
...
maint/cher
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c29920d6c |
@@ -80,16 +80,7 @@ export class GeminiBusinessExecutor extends BaseExecutor {
|
||||
// Extract cookies from credentials — check apiKey/cookie first, then
|
||||
// try each __Secure-1PSID* key in providerSpecificData individually.
|
||||
// A user with only __Secure-1PSID (no PSIDTS) is still valid.
|
||||
const directCookie =
|
||||
readCredentialString(credentials?.apiKey) || readCredentialString(credentials?.cookie);
|
||||
const psid = readProviderSpecificString(credentials?.providerSpecificData, [
|
||||
"__Secure-1PSID",
|
||||
"cookie",
|
||||
]);
|
||||
const psidts = readProviderSpecificString(credentials?.providerSpecificData, [
|
||||
"__Secure-1PSIDTS",
|
||||
]);
|
||||
const cookie = directCookie || [psid, psidts].filter(Boolean).join("; ");
|
||||
const cookie = resolveGeminiBusinessCookie(credentials);
|
||||
|
||||
if (!cookie) {
|
||||
return makeErrorResult(
|
||||
@@ -380,6 +371,15 @@ function readProviderSpecificString(providerSpecificData: unknown, keys: string[
|
||||
return "";
|
||||
}
|
||||
|
||||
export function resolveGeminiBusinessCookie(credentials: unknown): string {
|
||||
if (!credentials || typeof credentials !== "object") return "";
|
||||
const data = credentials as Record<string, unknown>;
|
||||
const directCookie = readCredentialString(data.apiKey) || readCredentialString(data.cookie);
|
||||
const psid = readProviderSpecificString(data.providerSpecificData, ["__Secure-1PSID", "cookie"]);
|
||||
const psidts = readProviderSpecificString(data.providerSpecificData, ["__Secure-1PSIDTS"]);
|
||||
return directCookie || [psid, psidts].filter(Boolean).join("; ");
|
||||
}
|
||||
|
||||
function extractTextContent(content: unknown): string {
|
||||
if (typeof content === "string") return content.trim();
|
||||
if (Array.isArray(content)) {
|
||||
|
||||
@@ -6,9 +6,8 @@ const { WEB_COOKIE_PROVIDERS } = await import("../../src/shared/constants/provid
|
||||
const { WEB_SESSION_CREDENTIAL_REQUIREMENTS } = await import(
|
||||
"../../src/shared/providers/webSessionCredentials.ts"
|
||||
);
|
||||
const { GeminiBusinessExecutor, parseStreamResponse } = await import(
|
||||
"../../open-sse/executors/gemini-business.ts"
|
||||
);
|
||||
const { GeminiBusinessExecutor, parseStreamResponse, resolveGeminiBusinessCookie } =
|
||||
await import("../../open-sse/executors/gemini-business.ts");
|
||||
|
||||
// ─── Provider metadata ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -49,6 +48,22 @@ test("GeminiBusinessExecutor constructs with the correct provider", () => {
|
||||
assert.equal((ex as unknown as { provider: string }).provider, "gemini-business");
|
||||
});
|
||||
|
||||
test("Gemini Business preserves supported legacy cookie credential placements", () => {
|
||||
assert.equal(
|
||||
resolveGeminiBusinessCookie({ cookie: " __Secure-1PSID=legacy " }),
|
||||
"__Secure-1PSID=legacy"
|
||||
);
|
||||
assert.equal(
|
||||
resolveGeminiBusinessCookie({
|
||||
providerSpecificData: {
|
||||
"__Secure-1PSID": "__Secure-1PSID=psid",
|
||||
"__Secure-1PSIDTS": "__Secure-1PSIDTS=psidts",
|
||||
},
|
||||
}),
|
||||
"__Secure-1PSID=psid; __Secure-1PSIDTS=psidts"
|
||||
);
|
||||
});
|
||||
|
||||
test("GeminiBusinessExecutor.execute returns 401 when no cookies are provided", async () => {
|
||||
const ex = new GeminiBusinessExecutor();
|
||||
const result = await ex.execute({
|
||||
|
||||
Reference in New Issue
Block a user