hue-node-dtls 0.6.4-alpha.4 → 0.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hue-node-dtls",
3
- "version": "0.6.4-alpha.4",
3
+ "version": "0.6.4",
4
4
  "description": "Secure UDP communications using DTLS.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -68,7 +68,12 @@ class Timer extends Emitter {
68
68
  restart(ms) {
69
69
  this.stop();
70
70
 
71
- this[_onTimeout] = setTimeout(ontimeout, ms, this).unref();
71
+ const timeout = setTimeout(ontimeout, ms, this);
72
+ // unref() is only available in Node.js, not in browser environments
73
+ if (timeout.unref && typeof timeout.unref === 'function') {
74
+ timeout.unref();
75
+ }
76
+ this[_onTimeout] = timeout;
72
77
  }
73
78
  }
74
79
 
@@ -183,6 +183,7 @@ class Socket extends Duplex {
183
183
  // Map DTLS alert codes to descriptive messages
184
184
  const alertMessages = {
185
185
  0: 'close_notify - Server will disconnect (e.g. streaming disabled)',
186
+ 1: 'Non-standard alert code 1 - May indicate protocol issue or bridge firmware bug',
186
187
  10: 'unexpected_message - Protocol failure',
187
188
  20: 'bad_record_mac - Protocol failure or invalid PSK',
188
189
  21: 'decryption_failed - Decryption failed',
@@ -210,7 +211,7 @@ class Socket extends Duplex {
210
211
  115: 'unknown_psk_identity - Unknown identity',
211
212
  };
212
213
 
213
- const message = alertMessages[code] || `Unknown alert`;
214
+ const message = alertMessages[code] || `Unknown alert code (${code}) - Not defined in DTLS RFC`;
214
215
  const detailedError = new Error(`DTLS Alert ${code}: ${message}`);
215
216
  debug('DTLS error - code: %d, message: %s', code, message);
216
217
  this.emit('error', detailedError);