{t("Подключите свои сервисы и решите, какие агенты и что в них могут делать. Агенты не видят ключ доступа: запросы выполняет FORGE и записывает их в журнал. Без вашего разрешения агент ничего не сделает, а «Отозвать доступ» действует сразу.")}
diff --git a/apps/web/lib/auth.ts b/apps/web/lib/auth.ts
index 886eda9d..3e12d01e 100644
--- a/apps/web/lib/auth.ts
+++ b/apps/web/lib/auth.ts
@@ -49,6 +49,9 @@ export const egovCookieOptions = (maxAgeSec: number) => ({ httpOnly: true, sameS
export const GOOGLE_COOKIE = "peppa_google";
export const googleCookieOptions = (maxAgeSec: number) => ({ httpOnly: true, sameSite: "lax" as const, secure: isHttps(), path: "/auth/google", maxAge: maxAgeSec });
+/** PEP-252: Access Hub sign-in state — the service's answer must come back to the browser that started it. */
+export const connOAuthCookieOptions = (maxAgeSec: number) => ({ httpOnly: true, sameSite: "lax" as const, secure: isHttps(), path: "/connections/oauth", maxAge: maxAgeSec });
+
const isHttps = () => loadEnv().PEPPA_WEB_URL.startsWith("https://");
/**
diff --git a/packages/core/src/connection-catalog.ts b/packages/core/src/connection-catalog.ts
index e072642d..258033ce 100644
--- a/packages/core/src/connection-catalog.ts
+++ b/packages/core/src/connection-catalog.ts
@@ -105,7 +105,7 @@ export const CONNECTION_CATALOG: CatalogService[] = [
// GitHub OAuth apps have no read-only scope for private repositories: «только чтение» is kept by the gateway's read rule.
read: ["repo", "read:org"],
write: ["repo", "read:org"],
- note: tr("У GitHub нет отдельного права «только чтение» для закрытых репозиториев: GitHub покажет полный доступ к коду, а читать или менять — решает разрешение в FORGE."),
+ note: tr("У GitHub нет отдельного права «только чтение» для закрытого кода: GitHub покажет полный доступ к коду, а читать или менять — решает разрешение в FORGE."),
},
},
{
diff --git a/packages/core/src/connections.ts b/packages/core/src/connections.ts
index 96ec6a9c..8fb0f656 100644
--- a/packages/core/src/connections.ts
+++ b/packages/core/src/connections.ts
@@ -953,14 +953,24 @@ async function runCheck(db: Db, conn: typeof connections.$inferSelect, o: { fetc
const started = Date.now();
let relogin = false;
try {
- const cred = await connectionCredential(db, conn, { now, notify: o.notify });
- if (!cred.ok) relogin = cred.reason === "needs_login";
- const built = cred.ok ? buildRequest(conn, cred.secret, clean, null, null) : null;
- if (built) {
+ let cred = await connectionCredential(db, conn, { now, notify: o.notify });
+ const send = async (c: ConnectionCredential & { ok: true }) => {
+ const built = buildRequest(conn, c.secret, clean, null, null);
+ if (!built) return null;
// Own service: the check is the base address itself (no trailing «/» added).
if (!check) built.url.pathname = built.url.pathname.replace(/\/$/, "") || "/";
const r = await (o.fetch ?? defaultConnectionFetch)({ url: built.url, method, headers: built.headers, body: null });
- res = r.status >= 300 && r.status < 400 && r.location ? null : { status: r.status, body: r.body.toString("utf8") };
+ return r.status >= 300 && r.status < 400 && r.location ? null : { status: r.status, body: r.body.toString("utf8") };
+ };
+ if (!cred.ok) relogin = cred.reason === "needs_login";
+ else {
+ res = await send(cred);
+ // PEP-252: a sign-in token the service no longer takes — refresh once, like the gateway.
+ if (res?.status === 401 && cred.refreshable && !cred.refreshed) {
+ cred = await connectionCredential(db, conn, { now, force: true, notify: o.notify });
+ if (!cred.ok) relogin = cred.reason === "needs_login";
+ else res = await send(cred);
+ }
}
} catch {
res = null;
diff --git a/packages/shared/src/i18n/en/access-hub.ts b/packages/shared/src/i18n/en/access-hub.ts
index ed68b521..6a9cc9ff 100644
--- a/packages/shared/src/i18n/en/access-hub.ts
+++ b/packages/shared/src/i18n/en/access-hub.ts
@@ -163,4 +163,51 @@ export const accessHub: Record