@matterbridge/dgram 3.9.1-dev-20260614-18d1a2e → 3.9.1-dev-20260617-b1e1b99

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
@@ -6,10 +6,12 @@
6
6
  [![Docker Pulls](https://img.shields.io/docker/pulls/luligu/matterbridge?label=docker%20pulls)](https://hub.docker.com/r/luligu/matterbridge)
7
7
  ![Node.js CI](https://github.com/Luligu/matterbridge/actions/workflows/build.yml/badge.svg)
8
8
  ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
- [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
10
- [![styled with prettier](https://img.shields.io/badge/styled_with-Prettier-f8bc45.svg?logo=prettier)](https://prettier.io/)
11
- [![linted with eslint](https://img.shields.io/badge/linted_with-ES_Lint-4B32C3.svg?logo=eslint)](https://eslint.org/)
9
+ [![Codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
10
+ [![tested with Vitest](https://img.shields.io/badge/tested_with-Vitest-6E9F18.svg?logo=vitest&logoColor=white)](https://vitest.dev)
11
+ [![styled with Oxc](https://img.shields.io/badge/styled_with-Oxc-9BE4E0.svg?logo=oxc&logoColor=white)](https://oxc.rs/docs/guide/usage/formatter.html)
12
+ [![linted with Oxc](https://img.shields.io/badge/linted_with-Oxc-9BE4E0.svg?logo=oxc&logoColor=white)](https://oxc.rs/docs/guide/usage/linter.html)
12
13
  [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
14
+ [![TypeScript Native](https://img.shields.io/badge/TypeScript_Native-3178C6?logo=typescript&logoColor=white)](https://github.com/microsoft/typescript-go)
13
15
  [![ESM](https://img.shields.io/badge/ESM-Node.js-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
14
16
  [![matterbridge.io](https://img.shields.io/badge/matterbridge.io-online-brightgreen)](https://matterbridge.io)
15
17
 
package/dist/coap.js CHANGED
@@ -215,14 +215,14 @@ export class Coap extends Multicast {
215
215
  `options ${MAGENTA}${msg.options.length}${nf} payload ${MAGENTA}${msg.payload ? msg.payload.length + ' bytes' : undefined}${nf}`);
216
216
  msg.options.forEach((option) => {
217
217
  if (option.number === COAP_OPTION_URI_PATH) {
218
- this.log.info(`Option: COAP_OPTION_URI_PATH => ${GREEN}${option.value}${nf}`);
218
+ this.log.info(`Option: COAP_OPTION_URI_PATH => ${GREEN}${option.value.toString()}${nf}`);
219
219
  }
220
220
  else if (option.number === COIOT_OPTION_DEVID) {
221
221
  const parts = option.value.toString().split('#');
222
222
  const deviceModel = parts[0];
223
223
  const deviceMac = parts[1];
224
224
  const protocolRevision = parts[2];
225
- this.log.info(`Option: COIOT_OPTION_DEVID => ${option.value} => Model: ${GREEN}${deviceModel}${nf}, MAC: ${GREEN}${deviceMac}${nf}, Protocol: ${GREEN}${protocolRevision}${nf}`);
225
+ this.log.info(`Option: COIOT_OPTION_DEVID => ${option.value.toString()} => Model: ${GREEN}${deviceModel}${nf}, MAC: ${GREEN}${deviceMac}${nf}, Protocol: ${GREEN}${protocolRevision}${nf}`);
226
226
  }
227
227
  else if (option.number === COIOT_OPTION_SERIAL) {
228
228
  const serial = option.value.readUInt16BE(0);
package/dist/dgram.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import dgram from 'node:dgram';
2
2
  import EventEmitter from 'node:events';
3
- import { type AddressInfo } from 'node:net';
3
+ import type { AddressInfo } from 'node:net';
4
4
  import { AnsiLogger } from 'node-ansi-logger';
5
5
  export interface DgramEvents {
6
6
  error: [error: Error];
package/dist/dgram.js CHANGED
@@ -27,7 +27,7 @@ export class Dgram extends EventEmitter {
27
27
  this.socketType = socketType;
28
28
  this.interfaceName = interfaceName;
29
29
  this.interfaceAddress = interfaceAddress;
30
- this.log.debug(`Created socket of type ${BLUE}${socketType}${db} on interface ${BLUE}${interfaceName || 'any'}${db} with address ${BLUE}${interfaceAddress || 'any'}${db} reuseAddr=${BLUE}${reuseAddr}${db}`);
30
+ this.log.debug(`Created socket of type ${BLUE}${socketType}${db} on interface ${BLUE}${interfaceName ?? 'any'}${db} with address ${BLUE}${interfaceAddress ?? 'any'}${db} reuseAddr=${BLUE}${reuseAddr}${db}`);
31
31
  this.socket.on('error', (error) => {
32
32
  this.log.debug(`Socket error: ${getErrorMessage(error)}`);
33
33
  this.emit('error', error);
@@ -159,7 +159,7 @@ export class Dgram extends EventEmitter {
159
159
  const linkLocalAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fe80'));
160
160
  if (linkLocalAddress) {
161
161
  this.log.debug('Found IPv6 link-local address');
162
- return linkLocalAddress.scopeid ? `${linkLocalAddress.address}%${process.platform !== 'win32' ? networkInterface : linkLocalAddress.scopeid}` : linkLocalAddress.address;
162
+ return linkLocalAddress.scopeid ? `${linkLocalAddress.address}%${process.platform === 'win32' ? linkLocalAddress.scopeid : networkInterface}` : linkLocalAddress.address;
163
163
  }
164
164
  this.log.debug('No IPv6 link-local address found');
165
165
  const ulaAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fd') && addr.netmask === 'ffff:ffff:ffff:ffff::');
@@ -206,7 +206,7 @@ export class Dgram extends EventEmitter {
206
206
  getInterfaceNameFromScopeId(scopeId) {
207
207
  const nets = os.networkInterfaces();
208
208
  for (const ifaceName in nets) {
209
- const addresses = nets[ifaceName] || [];
209
+ const addresses = nets[ifaceName] ?? [];
210
210
  for (const addr of addresses) {
211
211
  if (addr.family === 'IPv6' && addr.scopeid === scopeId) {
212
212
  return ifaceName;
package/dist/mdns.d.ts CHANGED
@@ -129,8 +129,8 @@ interface DnsQuestion {
129
129
  }
130
130
  interface MdnsRecord {
131
131
  name: string;
132
- type: number;
133
- class: number;
132
+ type: DnsRecordType;
133
+ class: DnsClass;
134
134
  ttl: number;
135
135
  data: string;
136
136
  }
package/dist/mdns.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { hasParameter } from '@matterbridge/utils/cli';
2
+ import { getErrorMessage } from '@matterbridge/utils/error';
2
3
  import { BLUE, CYAN, db, GREEN, idn, MAGENTA, nf, rs } from 'node-ansi-logger';
3
4
  import { Multicast } from './multicast.js';
4
5
  export var DnsRecordType;
@@ -186,7 +187,7 @@ export class Mdns extends Multicast {
186
187
  this.logMdnsMessage(result);
187
188
  }
188
189
  catch (error) {
189
- this.log.error(`Error decoding mDNS message: ${error instanceof Error ? error.message : error}`);
190
+ this.log.error(`Error decoding mDNS message: ${getErrorMessage(error)}`);
190
191
  }
191
192
  }
192
193
  decodeMdnsMessage(msg) {
@@ -509,7 +510,7 @@ export class Mdns extends Multicast {
509
510
  }
510
511
  this.socket.send(response, 0, response.length, this.multicastPort, this.multicastAddress, (error) => {
511
512
  if (error) {
512
- this.log.error(`Dgram mDNS server failed to send response message: ${error instanceof Error ? error.message : error}`);
513
+ this.log.error(`Dgram mDNS server failed to send response message: ${getErrorMessage(error)}`);
513
514
  this.emit('error', error);
514
515
  }
515
516
  else {
@@ -1,4 +1,4 @@
1
- import { type AddressInfo } from 'node:net';
1
+ import type { AddressInfo } from 'node:net';
2
2
  import { Dgram } from './dgram.js';
3
3
  export declare const MDNS_MULTICAST_IPV4_ADDRESS = "224.0.0.251";
4
4
  export declare const MDNS_MULTICAST_IPV6_ADDRESS = "ff02::fb";
package/dist/multicast.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import os from 'node:os';
2
+ import { getErrorMessage } from '@matterbridge/utils/error';
2
3
  import { BLUE, CYAN, db, RED, YELLOW } from 'node-ansi-logger';
3
4
  import { Dgram } from './dgram.js';
4
5
  export const MDNS_MULTICAST_IPV4_ADDRESS = '224.0.0.251';
@@ -85,20 +86,25 @@ export class Multicast extends Dgram {
85
86
  this.log.debug(`Dgram multicast socket joined multicast group ${BLUE}${this.multicastAddress}${db} on interface ${CYAN}${name}${db} ${BLUE}${iface.family}${db} ${BLUE}${iface.address}${db} ${BLUE}${iface.scopeid}${db} >>> ${YELLOW}${membershipInterface}${db}`);
86
87
  }
87
88
  catch (error) {
88
- this.log.debug(`Dgram multicast socket failed to join multicast group ${BLUE}${this.multicastAddress}${db} on interface ${CYAN}${name}${db} ${BLUE}${iface.family}${db} ${BLUE}${iface.address}${db} ${BLUE}${iface.scopeid}${db} >>> ${RED}${membershipInterface}${db}: ${error instanceof Error ? error.message : error}`);
89
+ this.log.debug(`Dgram multicast socket failed to join multicast group ${BLUE}${this.multicastAddress}${db} on interface ${CYAN}${name}${db} ${BLUE}${iface.family}${db} ${BLUE}${iface.address}${db} ${BLUE}${iface.scopeid}${db} >>> ${RED}${membershipInterface}${db}: ${getErrorMessage(error)}`);
89
90
  }
90
91
  }
91
92
  });
92
- let interfaceAddress = this.outgoingInterfaceAddress || this.interfaceAddress;
93
+ let interfaceAddress = this.outgoingInterfaceAddress ?? this.interfaceAddress;
93
94
  if (!this.outgoingInterfaceAddress && this.socketType === 'udp4' && this.interfaceAddress === '0.0.0.0') {
94
95
  interfaceAddress = this.getIpv4InterfaceAddress(this.interfaceName);
95
96
  }
96
97
  if (!this.outgoingInterfaceAddress && this.socketType === 'udp6' && this.interfaceAddress === '::') {
97
98
  interfaceAddress = '::' + this.getIpv6ScopeId(this.interfaceName);
98
99
  }
99
- this.log.debug(`Dgram multicast socket setting multicastInterface to ${BLUE}${interfaceAddress}${db} for ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
100
- this.socket.setMulticastInterface(interfaceAddress);
101
- this.log.debug(`Dgram multicast socket multicastInterface set to ${BLUE}${interfaceAddress}${db}`);
100
+ if (interfaceAddress) {
101
+ this.log.debug(`Dgram multicast socket setting multicastInterface to ${BLUE}${interfaceAddress}${db} for ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
102
+ this.socket.setMulticastInterface(interfaceAddress);
103
+ this.log.debug(`Dgram multicast socket multicastInterface set to ${BLUE}${interfaceAddress}${db}`);
104
+ }
105
+ else {
106
+ this.log.debug(`Dgram multicast socket no outgoing interface address resolved; using system default multicast interface`);
107
+ }
102
108
  this.emit('ready', address);
103
109
  }
104
110
  stop() {
@@ -109,7 +115,7 @@ export class Multicast extends Dgram {
109
115
  this.log.debug(`Dgram multicast socket dropped multicast group ${BLUE}${this.multicastAddress}${db} on interface ${YELLOW}${membershipInterface}${db}`);
110
116
  }
111
117
  catch (error) {
112
- this.log.debug(`Dgram multicast socket failed to drop multicast group ${BLUE}${this.multicastAddress}${db} on interface ${RED}${membershipInterface}${db}: ${error}`);
118
+ this.log.debug(`Dgram multicast socket failed to drop multicast group ${BLUE}${this.multicastAddress}${db} on interface ${RED}${membershipInterface}${db}: ${getErrorMessage(error)}`);
113
119
  }
114
120
  });
115
121
  this.joinedInterfaces = [];
package/dist/unicast.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type RemoteInfo } from 'node:dgram';
2
- import { type AddressInfo } from 'node:net';
1
+ import type { RemoteInfo } from 'node:dgram';
2
+ import type { AddressInfo } from 'node:net';
3
3
  import { Dgram } from './dgram.js';
4
4
  export declare class Unicast extends Dgram {
5
5
  port: number | undefined;
package/dist/unicast.js CHANGED
@@ -16,7 +16,7 @@ export class Unicast extends Dgram {
16
16
  this.interfaceAddress = this.interfaceAddress ?? (this.interfaceName ? this.getIpv6InterfaceAddress(this.interfaceName) : undefined);
17
17
  }
18
18
  this.interfaceNetmask = this.interfaceAddress ? this.getNetmask(this.interfaceAddress) : undefined;
19
- this.log.debug(`Binding dgram unicast socket to ${BLUE}${this.interfaceAddress || 'all available addresses'}${db} on port ${BLUE}${this.port || 'any available port'}${db}...`);
19
+ this.log.debug(`Binding dgram unicast socket to ${BLUE}${this.interfaceAddress ?? 'all available addresses'}${db} on port ${BLUE}${this.port ?? 'any available port'}${db}...`);
20
20
  this.socket.bind(this.port, this.interfaceAddress, () => {
21
21
  const address = this.socket.address();
22
22
  this.log.debug(`Dgram unicast socket bound to ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/dgram",
3
- "version": "3.9.1-dev-20260614-18d1a2e",
3
+ "version": "3.9.1-dev-20260617-b1e1b99",
4
4
  "description": "Matterbridge dgram library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -61,7 +61,7 @@
61
61
  "CHANGELOG.md"
62
62
  ],
63
63
  "dependencies": {
64
- "@matterbridge/utils": "3.9.1-dev-20260614-18d1a2e",
64
+ "@matterbridge/utils": "3.9.1-dev-20260617-b1e1b99",
65
65
  "node-ansi-logger": "3.3.0-dev-20260607-585945a"
66
66
  }
67
67
  }