node-red-contrib-unifi-ultimate 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,6 +54,8 @@ In Node-RED:
54
54
 
55
55
  > **Custom port:** Each config node has an optional **Port** field. Leave it empty to use the default (`443` for Network/Protect, `12445` for Access). Set it when your controller listens on a custom port — for example a **UniFi OS server** that uses `11443`. A port written directly in the controller address (`host:port`) takes precedence over this field.
56
56
 
57
+ > **Self-signed certificates:** Each config node has an **Allow self-signed certificate** option, enabled by default. UniFi controllers almost always present a self-signed certificate, so keep it checked for UniFi OS / UXG setups. Uncheck it only if your controller uses a certificate signed by a trusted certificate authority and you want strict verification.
58
+
57
59
  <br/>
58
60
  <br/>
59
61
  <p align="left">
@@ -29,12 +29,18 @@
29
29
  const $hostInput = $("#node-config-input-host");
30
30
  const $port = $("#node-config-input-port");
31
31
  const $apiToken = $("#node-config-input-apiToken");
32
- const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
32
+ const $allowSelfSigned = $("#node-config-input-allowSelfSigned");
33
33
  const $portRow = $port.closest(".form-row");
34
34
  const $apiTokenRow = $apiToken.closest(".form-row");
35
- const $securityRow = $rejectUnauthorized.closest(".form-row");
35
+ const $securityRow = $allowSelfSigned.closest(".form-row");
36
36
  const $advancedRow = $("#node-config-row-advanced");
37
37
 
38
+ // The stored field is rejectUnauthorized, but the checkbox is shown as
39
+ // its inverse ("Allow self-signed certificate") because UniFi
40
+ // controllers almost always use self-signed certificates. Default to
41
+ // allowing them when no explicit strict value was saved.
42
+ $allowSelfSigned.prop("checked", node.rejectUnauthorized !== true && node.rejectUnauthorized !== "true");
43
+
38
44
  function syncProgressiveRows() {
39
45
  const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
40
46
  $portRow.toggle(hasHost);
@@ -55,6 +61,10 @@
55
61
  $hostInput.on("change input", function () {
56
62
  syncProgressiveRows();
57
63
  });
64
+ },
65
+ oneditsave: function () {
66
+ // Persist the inverse of the "Allow self-signed certificate" checkbox.
67
+ this.rejectUnauthorized = !$("#node-config-input-allowSelfSigned").prop("checked");
58
68
  }
59
69
  });
60
70
  </script>
@@ -82,9 +92,9 @@
82
92
  <input type="password" id="node-config-input-apiToken" placeholder="Paste your UniFi Access token">
83
93
  </div>
84
94
  <div class="form-row">
85
- <label for="node-config-input-rejectUnauthorized"><i class="fa fa-lock"></i> Security</label>
86
- <input type="checkbox" id="node-config-input-rejectUnauthorized" style="display:inline-block; width:auto; vertical-align:top;">
87
- <span style="margin-left:8px;">Secure connection only</span>
95
+ <label for="node-config-input-allowSelfSigned"><i class="fa fa-lock"></i> Security</label>
96
+ <input type="checkbox" id="node-config-input-allowSelfSigned" style="display:inline-block; width:auto; vertical-align:top;">
97
+ <span style="margin-left:8px;">Allow self-signed certificate</span>
88
98
  </div>
89
99
  <div id="node-config-row-advanced" class="unifi-ultimate-advanced">
90
100
  <div class="form-row">
@@ -103,7 +113,7 @@
103
113
  <p><b>Controller</b> accepts the UniFi Access host or <code>host:port</code>. If you omit the port, the node uses the default UniFi Access port automatically.</p>
104
114
  <p><b>Port</b> is optional. Leave it empty to use the default <code>12445</code>. Set it when your UniFi Access controller listens on a custom port. A port embedded directly in the Controller field (<code>host:port</code>) takes precedence over this field.</p>
105
115
  <p><b>API Token</b> is the bearer token used for authentication.</p>
106
- <p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
116
+ <p><b>Security</b> &mdash; <b>Allow self-signed certificate</b> is enabled by default because UniFi controllers almost always present a self-signed certificate. Leave it checked for UniFi Access setups. Uncheck it only if your controller serves a certificate signed by a trusted certificate authority and you want strict verification.</p>
107
117
  <p><b>Name</b> is the config node name shown in the editor.</p>
108
118
 
109
119
  <h3>Usage</h3>
@@ -70,7 +70,9 @@ module.exports = function(RED) {
70
70
  node.host = String(config.host || "").trim();
71
71
  node.port = normalizePort(config.port);
72
72
  node.baseUrl = buildBaseUrlFromHost(node.host, node.port);
73
- node.rejectUnauthorized = config.rejectUnauthorized !== false && config.rejectUnauthorized !== "false";
73
+ // UniFi controllers almost always use self-signed certificates, so accept
74
+ // them unless the user explicitly opted into strict verification.
75
+ node.rejectUnauthorized = config.rejectUnauthorized === true || config.rejectUnauthorized === "true";
74
76
  node.nodeClients = [];
75
77
  node.wsNotifications = null;
76
78
  node.reconnectTimer = null;
@@ -40,14 +40,20 @@
40
40
  const $hostInput = $("#node-config-input-host");
41
41
  const $port = $("#node-config-input-port");
42
42
  const $apiKey = $("#node-config-input-apiKey");
43
- const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
43
+ const $allowSelfSigned = $("#node-config-input-allowSelfSigned");
44
44
  const $powerObservationIntervalSeconds = $("#node-config-input-powerObservationIntervalSeconds");
45
45
  const $portRow = $port.closest(".form-row");
46
46
  const $apiKeyRow = $apiKey.closest(".form-row");
47
- const $securityRow = $rejectUnauthorized.closest(".form-row");
47
+ const $securityRow = $allowSelfSigned.closest(".form-row");
48
48
  const $powerObservationRow = $powerObservationIntervalSeconds.closest(".form-row");
49
49
  const $advancedRow = $("#node-config-row-advanced");
50
50
 
51
+ // The stored field is rejectUnauthorized, but the checkbox is shown as
52
+ // its inverse ("Allow self-signed certificate") because UniFi
53
+ // controllers almost always use self-signed certificates. Default to
54
+ // allowing them when no explicit strict value was saved.
55
+ $allowSelfSigned.prop("checked", node.rejectUnauthorized !== true && node.rejectUnauthorized !== "true");
56
+
51
57
  function syncProgressiveRows() {
52
58
  const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
53
59
  $portRow.toggle(hasHost);
@@ -68,6 +74,10 @@
68
74
  $hostInput.on("change input", function () {
69
75
  syncProgressiveRows();
70
76
  });
77
+ },
78
+ oneditsave: function () {
79
+ // Persist the inverse of the "Allow self-signed certificate" checkbox.
80
+ this.rejectUnauthorized = !$("#node-config-input-allowSelfSigned").prop("checked");
71
81
  }
72
82
  });
73
83
  </script>
@@ -95,9 +105,9 @@
95
105
  <input type="password" id="node-config-input-apiKey" placeholder="Paste your UniFi Network API key">
96
106
  </div>
97
107
  <div class="form-row">
98
- <label for="node-config-input-rejectUnauthorized"><i class="fa fa-lock"></i> Security</label>
99
- <input type="checkbox" id="node-config-input-rejectUnauthorized" style="display:inline-block; width:auto; vertical-align:top;">
100
- <span style="margin-left:8px;">Secure connection only</span>
108
+ <label for="node-config-input-allowSelfSigned"><i class="fa fa-lock"></i> Security</label>
109
+ <input type="checkbox" id="node-config-input-allowSelfSigned" style="display:inline-block; width:auto; vertical-align:top;">
110
+ <span style="margin-left:8px;">Allow self-signed certificate</span>
101
111
  </div>
102
112
  <div class="form-row">
103
113
  <label for="node-config-input-powerObservationIntervalSeconds"><i class="fa fa-repeat"></i> Power Poll (s)</label>
@@ -120,7 +130,7 @@
120
130
  <p><b>Controller</b> accepts the UniFi OS host or IP address. The node builds the local UniFi Network proxy URL automatically.</p>
121
131
  <p><b>Port</b> is optional. Leave it empty to use the default <code>443</code>. Set it when your UniFi OS server listens on a custom port (for example <code>11443</code>). A port embedded directly in the Controller field (<code>host:port</code>) takes precedence over this field.</p>
122
132
  <p><b>API Key</b> is required for authentication and is sent as <code>X-API-Key</code>.</p>
123
- <p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
133
+ <p><b>Security</b> &mdash; <b>Allow self-signed certificate</b> is enabled by default because UniFi controllers almost always present a self-signed certificate. Leave it checked for UniFi OS / UXG setups. Uncheck it only if your controller serves a certificate signed by a trusted certificate authority and you want strict verification.</p>
124
134
  <p><b>Power Poll (s)</b> is the global polling interval used by all <code>Control POE</code> nodes when action is <code>Emit Power Consumption</code>. It is optional and defaults to 15 seconds.</p>
125
135
  <p><b>Name</b> is the config node name shown in the editor.</p>
126
136
 
@@ -79,7 +79,9 @@ module.exports = function(RED) {
79
79
  node.host = String(config.host || "").trim();
80
80
  node.port = normalizePort(config.port);
81
81
  node.baseUrl = buildBaseUrlFromHost(node.host, node.port);
82
- node.rejectUnauthorized = config.rejectUnauthorized !== false && config.rejectUnauthorized !== "false";
82
+ // UniFi controllers almost always use self-signed certificates, so accept
83
+ // them unless the user explicitly opted into strict verification.
84
+ node.rejectUnauthorized = config.rejectUnauthorized === true || config.rejectUnauthorized === "true";
83
85
  node.powerObservationIntervalSeconds = normalizePowerObserverIntervalSeconds(config.powerObservationIntervalSeconds);
84
86
  node.nodeClients = [];
85
87
  node.wsNetworkEvents = null;
@@ -31,12 +31,18 @@
31
31
  const $hostInput = $("#node-config-input-host");
32
32
  const $port = $("#node-config-input-port");
33
33
  const $apiKey = $("#node-config-input-apiKey");
34
- const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
34
+ const $allowSelfSigned = $("#node-config-input-allowSelfSigned");
35
35
  const $portRow = $port.closest(".form-row");
36
36
  const $apiKeyRow = $apiKey.closest(".form-row");
37
- const $securityRow = $rejectUnauthorized.closest(".form-row");
37
+ const $securityRow = $allowSelfSigned.closest(".form-row");
38
38
  const $advancedRow = $("#node-config-row-advanced");
39
39
 
40
+ // The stored field is rejectUnauthorized, but the checkbox is shown as
41
+ // its inverse ("Allow self-signed certificate") because UniFi
42
+ // controllers almost always use self-signed certificates. Default to
43
+ // allowing them when no explicit strict value was saved.
44
+ $allowSelfSigned.prop("checked", node.rejectUnauthorized !== true && node.rejectUnauthorized !== "true");
45
+
40
46
  function syncProgressiveRows() {
41
47
  const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
42
48
  $portRow.toggle(hasHost);
@@ -58,6 +64,10 @@
58
64
  syncProgressiveRows();
59
65
  });
60
66
 
67
+ },
68
+ oneditsave: function () {
69
+ // Persist the inverse of the "Allow self-signed certificate" checkbox.
70
+ this.rejectUnauthorized = !$("#node-config-input-allowSelfSigned").prop("checked");
61
71
  }
62
72
  });
63
73
  </script>
@@ -85,9 +95,9 @@
85
95
  <input type="password" id="node-config-input-apiKey" placeholder="Paste your UniFi Protect API key">
86
96
  </div>
87
97
  <div class="form-row">
88
- <label for="node-config-input-rejectUnauthorized"><i class="fa fa-lock"></i> Security</label>
89
- <input type="checkbox" id="node-config-input-rejectUnauthorized" style="display:inline-block; width:auto; vertical-align:top;">
90
- <span style="margin-left:8px;">Secure connection only</span>
98
+ <label for="node-config-input-allowSelfSigned"><i class="fa fa-lock"></i> Security</label>
99
+ <input type="checkbox" id="node-config-input-allowSelfSigned" style="display:inline-block; width:auto; vertical-align:top;">
100
+ <span style="margin-left:8px;">Allow self-signed certificate</span>
91
101
  </div>
92
102
  <div id="node-config-row-advanced" class="unifi-ultimate-advanced">
93
103
  <div class="form-row">
@@ -110,7 +120,7 @@
110
120
  <p><b>Controller</b> accepts the UniFi OS host or IP address. The node builds the Protect integration URL automatically.</p>
111
121
  <p><b>Port</b> is optional. Leave it empty to use the default <code>443</code>. Set it when your UniFi OS server listens on a custom port (for example <code>11443</code>). A port embedded directly in the Controller field (<code>host:port</code>) takes precedence over this field.</p>
112
122
  <p><b>API Key</b> is required for authentication.</p>
113
- <p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
123
+ <p><b>Security</b> &mdash; <b>Allow self-signed certificate</b> is enabled by default because UniFi controllers almost always present a self-signed certificate. Leave it checked for UniFi OS setups. Uncheck it only if your controller serves a certificate signed by a trusted certificate authority and you want strict verification.</p>
114
124
  <p><b>Name</b> is the config node name shown in the editor.</p>
115
125
  <p><b>API Header</b> is an advanced field. Leave the default value unless your UniFi Protect setup expects a different header name.</p>
116
126
 
@@ -28,7 +28,9 @@ module.exports = function(RED) {
28
28
  node.port = normalizePort(config.port);
29
29
  node.baseUrl = buildBaseUrlFromHost(node.host, node.port);
30
30
  node.authHeader = (config.authHeader || "X-API-Key").trim() || "X-API-Key";
31
- node.rejectUnauthorized = config.rejectUnauthorized !== false && config.rejectUnauthorized !== "false";
31
+ // UniFi controllers almost always use self-signed certificates, so accept
32
+ // them unless the user explicitly opted into strict verification.
33
+ node.rejectUnauthorized = config.rejectUnauthorized === true || config.rejectUnauthorized === "true";
32
34
  node.nodeClients = [];
33
35
  node.wsDevices = null;
34
36
  node.wsEvents = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-unifi-ultimate",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Node-RED nodes for Ubiquiti UniFi integrations, including UniFi Protect, UniFi Access, and UniFi Network.",
5
5
  "files": [
6
6
  "nodes/",