From 659f7d603de1c807a4a4af8750a1b6c26fca22ec Mon Sep 17 00:00:00 2001 From: n3wk Date: Thu, 15 Oct 2026 14:43:44 +0200 Subject: [PATCH] Add credentials support so key/secret persist in Node-RED UI --- nodes/woocommerce-config.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nodes/woocommerce-config.js b/nodes/woocommerce-config.js index 735fb30..2b4382a 100644 --- a/nodes/woocommerce-config.js +++ b/nodes/woocommerce-config.js @@ -9,8 +9,8 @@ module.exports = function (RED) { const node = this; node.baseUrl = (config.baseUrl || "https://example.com/wp-json/wc/v3").replace(/\/+$/, ""); - node.consumerKey = config.consumerKey || ""; - node.consumerSecret = config.consumerSecret || ""; + node.consumerKey = (this.credentials && this.credentials.consumerKey) || config.consumerKey || ""; + node.consumerSecret = (this.credentials && this.credentials.consumerSecret) || config.consumerSecret || ""; node.sendRequest = function (method, path, body, msgHeaders, callback) { const url = new URL(node.baseUrl + path); @@ -48,5 +48,10 @@ module.exports = function (RED) { }; } - RED.nodes.registerType("woocommerce-config", WooCommerceConfigNode); + RED.nodes.registerType("woocommerce-config", WooCommerceConfigNode, { + credentials: { + consumerKey: { type: "text" }, + consumerSecret: { type: "password" } + } + }); };