node-red-contrib-homekit-bridged 1.7.0-dev.6 → 1.7.0-dev.8

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Node-RED Contribution - HomeKit Bridged
3
+ Copyright (c) 2024 Node-RED Contribution - HomeKit Bridged
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -170,14 +170,17 @@ module.exports = function (node) {
170
170
  Object.keys(msg.payload).map((key) => {
171
171
  var _a, _b, _c, _d;
172
172
  if (node.supported.indexOf(key) < 0) {
173
- if (key === 'AdaptiveLightingController') {
173
+ if (key === 'AdaptiveLightingController' &&
174
+ node.adaptiveLightingController) {
174
175
  const value = (_a = msg.payload) === null || _a === void 0 ? void 0 : _a[key];
175
176
  const event = value === null || value === void 0 ? void 0 : value.event;
176
177
  if (event === 'disable') {
177
178
  (_b = node.adaptiveLightingController) === null || _b === void 0 ? void 0 : _b.disableAdaptiveLighting();
178
179
  }
179
180
  }
180
- log.error(`Instead of '${key}' try one of these characteristics: '${node.supported.join("', '")}'`);
181
+ else {
182
+ log.error(`Instead of '${key}' try one of these characteristics: '${node.supported.join("', '")}'`);
183
+ }
181
184
  }
182
185
  else {
183
186
  const value = (_c = msg.payload) === null || _c === void 0 ? void 0 : _c[key];
@@ -152,7 +152,7 @@ module.exports = function (node) {
152
152
  }
153
153
  node.topic_in = (_b = msg.topic) !== null && _b !== void 0 ? _b : '';
154
154
  Object.keys(msg.payload).map((key) => {
155
- var _a, _b, _c;
155
+ var _a, _b, _c, _d, _e;
156
156
  if (node.supported.indexOf(key) < 0) {
157
157
  if (node.config.useEventCallback &&
158
158
  Storage_1.Storage.uuid4Validate(key)) {
@@ -167,13 +167,21 @@ module.exports = function (node) {
167
167
  log.error(`Callback ${callbackID} timeout`);
168
168
  }
169
169
  }
170
+ else if (key === 'AdaptiveLightingController' &&
171
+ node.adaptiveLightingController) {
172
+ const value = (_b = msg.payload) === null || _b === void 0 ? void 0 : _b[key];
173
+ const event = value === null || value === void 0 ? void 0 : value.event;
174
+ if (event === 'disable') {
175
+ (_c = node.adaptiveLightingController) === null || _c === void 0 ? void 0 : _c.disableAdaptiveLighting();
176
+ }
177
+ }
170
178
  else {
171
179
  log.error(`Instead of '${key}' try one of these characteristics: '${node.supported.join("', '")}'`);
172
180
  }
173
181
  }
174
182
  else {
175
- const value = (_b = msg.payload) === null || _b === void 0 ? void 0 : _b[key];
176
- const parentNode = (_c = node.parentNode) !== null && _c !== void 0 ? _c : node;
183
+ const value = (_d = msg.payload) === null || _d === void 0 ? void 0 : _d[key];
184
+ const parentNode = (_e = node.parentNode) !== null && _e !== void 0 ? _e : node;
177
185
  parentNode.reachable = value !== NO_RESPONSE_MSG;
178
186
  const characteristic = node.service.getCharacteristic(Characteristic[key]);
179
187
  if (context !== null) {
@@ -95,7 +95,7 @@
95
95
 
96
96
  <script data-help-name="homekit-bridge" type="text/x-red">
97
97
  <h3 id="toc_4">Bridge</h3>
98
- <p>The Bridge node is a configuration node, specifying the <em>bridge</em> that iOS sees, i.e. the device that is manually being added by the user. All accessories behind a bridge noded are then automatically added by iOS.
98
+ <p>The Bridge node is a configuration node, specifying the <em>bridge</em> that iOS sees, i.e. the device that is manually being added by the user. All accessories behind a bridge node are then automatically added by iOS.
99
99
  </p>
100
100
  <ul>
101
101
  <li><strong>Pin Code</strong>: Specify the Pin for the pairing process.</li>
@@ -107,7 +107,7 @@
107
107
  <li><strong>Hardware Revision</strong>: Should be a version number string in the form of <em>MAJOR.MINOR.REVISION</em> e.g. <em>1.2.0</em>. Other types of strings are ignored and won't be displayed.</li>
108
108
  <li><strong>Software Revision</strong>: Should be a version number string in the form of <em>MAJOR.MINOR.REVISION</em> e.g. <em>1.2.0</em>. Other types of strings are ignored and won't be displayed.</li>
109
109
  <li><strong>Name</strong>: If you intend to simulate a rocket, then why don&#39;t you call it <em>Rocket</em>. Name should be maximum 64 chars long and not contain <pre>.</pre></li>
110
- <li><strong>Allow Message Passthrough</strong>: If you allow then message from node input will be send to node output.</li>
110
+ <li><strong>Allow Message Passthrough</strong>: If you allow then message from node input will be sent to node output.</li>
111
111
  <li><strong>Custom MDNS Configuration</strong>: Check if you would like to use custom mdns configuration.</li>
112
112
  <ul>
113
113
  <li><strong>Multicast</strong>: Use udp multicasting. Optional. Default true.</li>
@@ -137,7 +137,7 @@
137
137
  },
138
138
  pinCode: {
139
139
  required: true,
140
- validate: pinCodeRegex,
140
+ validate: validatePinCode,
141
141
  },
142
142
  port: {
143
143
  required: false,
@@ -229,7 +229,7 @@
229
229
  return this.bridgeName ? 'node_label_italic' : ''
230
230
  },
231
231
  oneditprepare: function () {
232
- if (!pinCodeRegex(this.pinCode)) {
232
+ if (!validatePinCode(this.pinCode)) {
233
233
  this.pinCode = generatePinCode()
234
234
  $("#node-config-input-pinCode").val(this.pinCode)
235
235
  }
@@ -414,12 +414,38 @@
414
414
  return Math.floor(Math.random() * (max - min + 1) + min);
415
415
  }
416
416
 
417
+ const forbiddenPinCodes = [
418
+ '00000000',
419
+ '11111111',
420
+ '22222222',
421
+ '33333333',
422
+ '44444444',
423
+ '55555555',
424
+ '66666666',
425
+ '77777777',
426
+ '88888888',
427
+ '99999999',
428
+ '12345678',
429
+ '87654321'
430
+ ]
431
+
417
432
  const generatePinCode = function () {
418
433
  const [a, b, c, d, e, f, g, h] = Array.from({length: 9}, () => getRandomIntInclusive(0, 9));
434
+
435
+ if (forbiddenPinCodes.includes(`${a}${b}${c}${d}${e}${f}${g}${h}`)) {
436
+ return generatePinCode()
437
+ }
438
+
419
439
  return `${a}${b}${c}${d}-${e}${f}${g}${h}`
420
440
  }
421
441
 
422
- const pinCodeRegex = RED.validators.regex(/([0-9]{3}-[0-9]{2}-[0-9]{3}|[0-9]{4}-[0-9]{4})/)
442
+ const validatePinCode = function (value) {
443
+ if (!RED.validators.regex(/([0-9]{3}-[0-9]{2}-[0-9]{3}|[0-9]{4}-[0-9]{4})/)) {
444
+ return false
445
+ }
446
+
447
+ return !forbiddenPinCodes.includes(value.replaceAll("-", ""));
448
+ }
423
449
  </script>
424
450
 
425
451
  <script data-template-name="nrchkb" type="text/x-red">
@@ -114,7 +114,7 @@
114
114
  <li><strong>Hardware Revision</strong>: Should be a version number string in the form of <em>MAJOR.MINOR.REVISION</em> e.g. <em>1.2.0</em>. Other types of strings are ignored and won't be displayed.</li>
115
115
  <li><strong>Software Revision</strong>: Should be a version number string in the form of <em>MAJOR.MINOR.REVISION</em> e.g. <em>1.2.0</em>. Other types of strings are ignored and won't be displayed.</li>
116
116
  <li><strong>Name</strong>: If you intend to simulate a rocket, then why don&#39;t you call it <em>Rocket</em>. Name should be maximum 64 chars long and not contain <pre>.</pre></li>
117
- <li><strong>Allow Message Passthrough</strong>: If you allow then message from node input will be send to node output.</li>
117
+ <li><strong>Allow Message Passthrough</strong>: If you allow then message from node input will be sent to node output.</li>
118
118
  <li><strong>Custom MDNS Configuration</strong>: Check if you would like to use custom mdns configuration.</li>
119
119
  <ul>
120
120
  <li><strong>Multicast</strong>: Use udp multicasting. Optional. Default true.</li>
@@ -146,7 +146,7 @@
146
146
  },
147
147
  pinCode: {
148
148
  required: true,
149
- validate: pinCodeRegex,
149
+ validate: validatePinCode,
150
150
  },
151
151
  port: {
152
152
  required: false,
@@ -240,7 +240,7 @@
240
240
  oneditprepare: function () {
241
241
  const node = this
242
242
 
243
- if (!pinCodeRegex(node.pinCode)) {
243
+ if (!validatePinCode(node.pinCode)) {
244
244
  node.pinCode = generatePinCode()
245
245
  $("#node-config-input-pinCode").val(node.pinCode)
246
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homekit-bridged",
3
- "version": "1.7.0-dev.6",
3
+ "version": "1.7.0-dev.8",
4
4
  "description": "Node-RED nodes to simulate Apple HomeKit devices.",
5
5
  "main": "build/nodes/nrchkb.js",
6
6
  "scripts": {
@@ -58,8 +58,8 @@
58
58
  "@types/node-red-node-test-helper": "^0.3.4",
59
59
  "@types/semver": "^7.5.8",
60
60
  "@types/uuid": "^10.0.0",
61
- "@typescript-eslint/eslint-plugin": "^7.13.1",
62
- "@typescript-eslint/parser": "^7.13.1",
61
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
62
+ "@typescript-eslint/parser": "^7.14.1",
63
63
  "babel-eslint": "^10.1.0",
64
64
  "del-cli": "^5.1.0",
65
65
  "eslint": "^8",
@@ -67,7 +67,7 @@
67
67
  "eslint-plugin-prettier": "^5.1.3",
68
68
  "eslint-plugin-simple-import-sort": "^12.1.0",
69
69
  "husky": "^9.0.11",
70
- "mocha": "^10.4.0",
70
+ "mocha": "^10.5.1",
71
71
  "node-red": "^4.0.0",
72
72
  "node-red-node-test-helper": "^0.3.4",
73
73
  "prettier": "^3.3.2",