diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 8cde4ce77..2aa86c4ec 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -8048,9 +8048,8 @@ function asTyped() { // provider of the user's own body.insecureTLS = !!draft.insecureTLS; body.http1 = !!draft.http1; - // a client certificate typed (#5596) is tried as it would be saved - for (const k of CERT_FIELDS) if (draft[k] != null) body[k] = draft[k].trim(); - if (draft.resolve) body.resolve = draft.resolve; // connect addresses (tlscerts.js) + // a client certificate typed (#5596) and connect addresses are tried as they would be saved + window.tlsTyped?.(draft, body); return body; } const CERT_FIELDS = ["clientCert", "clientKey", "serverCA", "serverPin"]; @@ -9278,7 +9277,7 @@ function baseAPIOf(p) { // draftOf is a saved provider as its editor's form holds it. function draftOf(p) { - return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), passHeaders: (p.passHeaders || []).join(", "), icon: p.icon || "", iconFrom: p.iconFrom || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], hiddenVideomakers: [...(p.hiddenVideomakers || [])], searches: !!p.searches, unredacted: !!p.unredacted, countFree: !!p.countFree, billing: p.billing || "", insecureTLS: !!p.insecureTLS, http1: !!p.http1, clientCert: p.clientCert || "", clientKey: p.clientKey || "", serverCA: p.serverCA || "", serverPin: p.serverPin || "", resolve: p.resolve || null, socket: p.socket || "", limitRestOff: !!p.limitRestOff, noBalanceProbe: !!p.noBalanceProbe, upstreamProviders: !!p.upstreamProviders, passErrors: !!p.passErrors, imageFilesOff: !!p.imageFilesOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: p.passUserAgent !== false, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", listOff: !!p.listOff, contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p), rateWindows: (p.rateWindows || []).map((w) => ({ ...w })) }; + return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), passHeaders: (p.passHeaders || []).join(", "), icon: p.icon || "", iconFrom: p.iconFrom || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], hiddenVideomakers: [...(p.hiddenVideomakers || [])], searches: !!p.searches, unredacted: !!p.unredacted, countFree: !!p.countFree, billing: p.billing || "", insecureTLS: !!p.insecureTLS, http1: !!p.http1, clientCert: p.clientCert || "", clientKey: p.clientKey || "", serverCA: p.serverCA || "", serverPin: p.serverPin || "", resolve: p.resolve, socket: p.socket || "", limitRestOff: !!p.limitRestOff, noBalanceProbe: !!p.noBalanceProbe, upstreamProviders: !!p.upstreamProviders, passErrors: !!p.passErrors, imageFilesOff: !!p.imageFilesOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: p.passUserAgent !== false, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", listOff: !!p.listOff, contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p), rateWindows: (p.rateWindows || []).map((w) => ({ ...w })) }; } // duplicateProvider opens the Add form on a copy of p, its key p's unless another is pasted (#268). @@ -10307,8 +10306,7 @@ function drawEditor(p, presetID) { body.billing = draft.billing || ""; if (tlsTakes()) { body.insecureTLS = !!draft.insecureTLS && onHTTPS(); body.http1 = !!draft.http1 && onHTTPS(); } if (certTakes()) for (const k of CERT_FIELDS) body[k] = onHTTPS() ? (draft[k] || "").trim() : ""; - else pinBody(body); - if (draft.resolve) body.resolve = draft.resolve; + pinBody(body, certTakes()); if (socketable()) body.socket = draft.socket || ""; if (custom) body.limitRestOff = !!draft.limitRestOff; body.noBalanceProbe = !!draft.noBalanceProbe; diff --git a/internal/gui/assets/tlscerts.js b/internal/gui/assets/tlscerts.js index 7c827f958..8934c4ceb 100644 --- a/internal/gui/assets/tlscerts.js +++ b/internal/gui/assets/tlscerts.js @@ -54,11 +54,18 @@ function drawPin(pin, draft, peek, seen) { // every one of theirs and Remote magpie's, and a preset's pointed at their // own server, never the vendor's own hosts; save has the Save body carry // the pin. The client certificate's fields are saved by app.js itself. +window.tlsTyped = (draft, body) => { + for (const k of ["clientCert", "clientKey", "serverCA", "serverPin"]) if (draft[k] != null) body[k] = draft[k].trim(); + if (draft.resolve) body.resolve = draft.resolve; +}; + window.tlsCertRows = function ({ p, pr, draft, at, certTakes, onHTTPS, addressOf, asTyped, show, save }) { if (!at.isConnected) return; - const rows = []; + const rows = [], saves = []; + const keep = (f) => saves.push(f); + save((body, own) => { if (!own) for (const f of saves) f(body); if (draft.resolve) body.resolve = draft.resolve; }); const takes = certTakes() || (p ? !!p.takesServerPin || (!!p.preset && !p.account) : !!pr) && (p?.preset || pr?.id) !== "google-vertex"; - if (takes) rows.push(pinRow({ p, pr, draft, certTakes, addressOf, asTyped, show, save })); + if (takes) rows.push(pinRow({ p, pr, draft, certTakes, addressOf, asTyped, show, save: keep })); if (certTakes()) { const box = el("div", "client-cert"); for (const [k, label, hold] of [["clientCert", t("Certificate"), "client.pem"], ["clientKey", t("Key"), "client-key.pem"], ["serverCA", t("Server CA"), "ca.pem"]]) {