From cf1964d6521439d19005625cc090626a277f55ef Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 22 Sep 2026 19:04:27 -0700 Subject: [PATCH] Add these private widget options --- src/utils/config/widget-helpers.js | 7 +++++-- src/utils/config/widget-helpers.test.js | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/utils/config/widget-helpers.js b/src/utils/config/widget-helpers.js index 561424c96..d573bc3c8 100644 --- a/src/utils/config/widget-helpers.js +++ b/src/utils/config/widget-helpers.js @@ -31,7 +31,7 @@ export async function cleanWidgetGroups(widgets) { const optionKeys = Object.keys(sanitizedOptions); // delete private options from the sanitized options - ["username", "password", "key", "apiKey"].forEach((pO) => { + ["username", "password", "key", "apiKey", "headers", "requestBody", "method"].forEach((pO) => { if (optionKeys.includes(pO)) { delete sanitizedOptions[pO]; } @@ -57,7 +57,7 @@ export async function getPrivateWidgetOptions(type, widgetIndex) { const privateOptions = widgets.map((widget) => { - const { index, url, username, password, key, apiKey } = widget.options; + const { index, url, username, password, key, apiKey, headers, requestBody, method } = widget.options; return { type: widget.type, @@ -68,6 +68,9 @@ export async function getPrivateWidgetOptions(type, widgetIndex) { password, key, apiKey, + headers, + requestBody, + method, }, }; }) || {}; diff --git a/src/utils/config/widget-helpers.test.js b/src/utils/config/widget-helpers.test.js index 2bec9e517..bcb6474b2 100644 --- a/src/utils/config/widget-helpers.test.js +++ b/src/utils/config/widget-helpers.test.js @@ -60,6 +60,17 @@ describe("utils/config/widget-helpers", () => { expect(cleaned[2].options.apiKey).toBeUndefined(); }); + it("cleanWidgetGroups removes customapi request options", async () => { + const cleaned = await cleanWidgetGroups([ + { + type: "customapi", + options: { index: 0, url: "http://x", headers: { a: "b" }, requestBody: "body", method: "POST", icon: "mdi-x" }, + }, + ]); + + expect(cleaned[0].options).toEqual({ index: 0, icon: "mdi-x" }); + }); + it("getPrivateWidgetOptions returns private options for a specific widget", async () => { fs.readFile.mockResolvedValueOnce("ignored"); yaml.load.mockReturnValueOnce([{ search: { url: "http://x", username: "u", password: "p", key: "k" } }]);