matterbridge 3.4.7-dev-20260113-0917d83 → 3.5.0-dev-20260113-96c82db

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/npm-shrinkwrap.json +1500 -11420
  3. package/package.json +2 -7
  4. package/frontend/index.html +0 -15
  5. package/frontend/package-lock.json +0 -7553
  6. package/packages/dgram/LICENSE +0 -202
  7. package/packages/dgram/dist/coap.d.ts +0 -34
  8. package/packages/dgram/dist/coap.js +0 -252
  9. package/packages/dgram/dist/dgram.d.ts +0 -45
  10. package/packages/dgram/dist/dgram.js +0 -255
  11. package/packages/dgram/dist/export.d.ts +0 -5
  12. package/packages/dgram/dist/export.js +0 -5
  13. package/packages/dgram/dist/mdns.d.ts +0 -188
  14. package/packages/dgram/dist/mdns.js +0 -702
  15. package/packages/dgram/dist/multicast.d.ts +0 -18
  16. package/packages/dgram/dist/multicast.js +0 -119
  17. package/packages/dgram/dist/unicast.d.ts +0 -11
  18. package/packages/dgram/dist/unicast.js +0 -40
  19. package/packages/dgram/package.json +0 -110
  20. package/packages/jest-utils/LICENSE +0 -202
  21. package/packages/jest-utils/dist/export.d.ts +0 -1
  22. package/packages/jest-utils/dist/export.js +0 -1
  23. package/packages/jest-utils/dist/jestHelpers.d.ts +0 -21
  24. package/packages/jest-utils/dist/jestHelpers.js +0 -77
  25. package/packages/jest-utils/package.json +0 -109
  26. package/packages/utils/LICENSE +0 -202
  27. package/packages/utils/dist/colorUtils.d.ts +0 -24
  28. package/packages/utils/dist/colorUtils.js +0 -187
  29. package/packages/utils/dist/commandLine.d.ts +0 -6
  30. package/packages/utils/dist/commandLine.js +0 -63
  31. package/packages/utils/dist/copyDirectory.d.ts +0 -2
  32. package/packages/utils/dist/copyDirectory.js +0 -39
  33. package/packages/utils/dist/createDirectory.d.ts +0 -2
  34. package/packages/utils/dist/createDirectory.js +0 -21
  35. package/packages/utils/dist/createZip.d.ts +0 -1
  36. package/packages/utils/dist/createZip.js +0 -69
  37. package/packages/utils/dist/deepCopy.d.ts +0 -1
  38. package/packages/utils/dist/deepCopy.js +0 -40
  39. package/packages/utils/dist/deepEqual.d.ts +0 -1
  40. package/packages/utils/dist/deepEqual.js +0 -58
  41. package/packages/utils/dist/error.d.ts +0 -3
  42. package/packages/utils/dist/error.js +0 -12
  43. package/packages/utils/dist/export.d.ts +0 -15
  44. package/packages/utils/dist/export.js +0 -15
  45. package/packages/utils/dist/format.d.ts +0 -4
  46. package/packages/utils/dist/format.js +0 -29
  47. package/packages/utils/dist/githubVersion.d.ts +0 -11
  48. package/packages/utils/dist/githubVersion.js +0 -37
  49. package/packages/utils/dist/hex.d.ts +0 -4
  50. package/packages/utils/dist/hex.js +0 -118
  51. package/packages/utils/dist/inspector.d.ts +0 -24
  52. package/packages/utils/dist/inspector.js +0 -200
  53. package/packages/utils/dist/isValid.d.ts +0 -10
  54. package/packages/utils/dist/isValid.js +0 -69
  55. package/packages/utils/dist/network.d.ts +0 -12
  56. package/packages/utils/dist/network.js +0 -105
  57. package/packages/utils/dist/npmRoot.d.ts +0 -1
  58. package/packages/utils/dist/npmRoot.js +0 -13
  59. package/packages/utils/dist/npmVersion.d.ts +0 -1
  60. package/packages/utils/dist/npmVersion.js +0 -43
  61. package/packages/utils/dist/tracker.d.ts +0 -52
  62. package/packages/utils/dist/tracker.js +0 -201
  63. package/packages/utils/dist/wait.d.ts +0 -3
  64. package/packages/utils/dist/wait.js +0 -73
  65. package/packages/utils/package.json +0 -110
  66. package/packages/vitest-utils/LICENSE +0 -202
  67. package/packages/vitest-utils/dist/export.d.ts +0 -1
  68. package/packages/vitest-utils/dist/export.js +0 -1
  69. package/packages/vitest-utils/dist/vitestHelpers.d.ts +0 -21
  70. package/packages/vitest-utils/dist/vitestHelpers.js +0 -77
  71. package/packages/vitest-utils/package.json +0 -109
@@ -1,255 +0,0 @@
1
- import dgram from 'node:dgram';
2
- import EventEmitter from 'node:events';
3
- import os from 'node:os';
4
- import { AnsiLogger, BLUE, db, idn, nf, rs } from 'node-ansi-logger';
5
- import { hasParameter } from '@matterbridge/utils';
6
- export class Dgram extends EventEmitter {
7
- verbose = hasParameter('v') || hasParameter('verbose');
8
- debug = hasParameter('d') || hasParameter('debug') || hasParameter('v') || hasParameter('verbose');
9
- silent = hasParameter('s') || hasParameter('silent');
10
- log;
11
- socket;
12
- bound = false;
13
- socketType;
14
- interfaceName;
15
- interfaceAddress;
16
- interfaceNetmask;
17
- excludedInterfaceNamePattern = /(tailscale|wireguard|wintun|openvpn|\bwg\d*\b|\btun\d*\b|\btap\d*\b|\butun\d*\b|zerotier|hamachi|hyper-?v|v\s*ethernet|wsl|default switch|vmware|vmnet|vbox|virtualbox|virbr|docker|podman|\bveth\b|\bbr-\b|cni|kube|flannel|calico|teredo|isatap)/i;
18
- constructor(name, socketType, reuseAddr = true, interfaceName, interfaceAddress) {
19
- super();
20
- this.log = new AnsiLogger({
21
- logName: name,
22
- logTimestampFormat: 4,
23
- logLevel: this.debug ? "debug" : this.silent ? "notice" : "info",
24
- });
25
- this.socket = dgram.createSocket({ type: socketType, reuseAddr });
26
- this.socketType = socketType;
27
- this.interfaceName = interfaceName;
28
- this.interfaceAddress = interfaceAddress;
29
- 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.socket.on('error', (error) => {
31
- this.log.debug(`Socket error: ${error instanceof Error ? error.message : error}`);
32
- this.emit('error', error);
33
- this.onError(error);
34
- });
35
- this.socket.on('close', () => {
36
- this.log.debug('Socket closed');
37
- this.bound = false;
38
- this.emit('close');
39
- this.onClose();
40
- });
41
- this.socket.on('connect', () => {
42
- this.log.info('Socket connected');
43
- this.emit('connect');
44
- this.onConnect();
45
- });
46
- this.socket.on('message', (msg, rinfo) => {
47
- this.log.debug(`Socket received a message from ${BLUE}${rinfo.family}${db} ${BLUE}${rinfo.address}${db}:${BLUE}${rinfo.port}${db}`);
48
- this.emit('message', msg, rinfo);
49
- this.onMessage(msg, rinfo);
50
- });
51
- this.socket.on('listening', () => {
52
- this.bound = true;
53
- const address = this.socket.address();
54
- this.log.debug(`Socket listening on ${BLUE}${address.family}${db} ${BLUE}${address.address}${db}:${BLUE}${address.port}${db}`);
55
- this.emit('listening', address);
56
- this.onListening(address);
57
- });
58
- }
59
- send(msg, serverAddress, serverPort) {
60
- this.socket.send(msg, 0, msg.length, serverPort, serverAddress, (error) => {
61
- if (error) {
62
- this.log.error(`Socket failed to send a message: ${error instanceof Error ? error.message : error}`);
63
- this.emit('error', error);
64
- this.onError(error);
65
- }
66
- else {
67
- this.log.debug(`Socket sent a message to ${BLUE}${serverAddress}${db}:${BLUE}${serverPort}${db}`);
68
- this.emit('sent', msg, serverAddress, serverPort);
69
- this.onSent(msg, serverAddress, serverPort);
70
- }
71
- });
72
- }
73
- onError(error) {
74
- this.log.error(`Socket error: ${error instanceof Error ? error.message : error}`);
75
- }
76
- onClose() {
77
- this.log.info(`Socket closed`);
78
- }
79
- onConnect() {
80
- this.log.info(`Socket connected`);
81
- }
82
- onSent(msg, serverAddress, serverPort) {
83
- this.log.info(`Socket sent a message to ${BLUE}${serverAddress}${db}:${BLUE}${serverPort}${db}`);
84
- }
85
- onMessage(msg, rinfo) {
86
- this.log.info(`Socket received a message from ${BLUE}${rinfo.family}${nf} ${BLUE}${rinfo.address}${nf}:${BLUE}${rinfo.port}${nf}`);
87
- }
88
- onListening(address) {
89
- this.log.info(`Socket listening on ${BLUE}${address.family}${nf} ${BLUE}${address.address}${nf}:${BLUE}${address.port}${nf}`);
90
- this.onReady(address);
91
- }
92
- onReady(address) {
93
- this.log.info(`Socket ready on ${BLUE}${address.family}${nf} ${BLUE}${address.address}${nf}:${BLUE}${address.port}${nf}`);
94
- this.emit('ready', address);
95
- }
96
- getIpv4InterfaceAddress(networkInterface) {
97
- if (networkInterface === '')
98
- networkInterface = undefined;
99
- const interfaces = os.networkInterfaces();
100
- if (networkInterface && !interfaces[networkInterface]) {
101
- this.log.warn(`Interface "${networkInterface}" not found. Using first external IPv4 interface.`);
102
- networkInterface = undefined;
103
- }
104
- if (!networkInterface) {
105
- for (const [interfaceName, interfaceDetails] of Object.entries(interfaces)) {
106
- if (!networkInterface && this.excludedInterfaceNamePattern.test(interfaceName))
107
- continue;
108
- if (!interfaceDetails)
109
- continue;
110
- for (const detail of interfaceDetails) {
111
- if (detail.family === 'IPv4' && !detail.internal) {
112
- networkInterface = interfaceName;
113
- break;
114
- }
115
- }
116
- if (networkInterface)
117
- break;
118
- }
119
- }
120
- if (!networkInterface) {
121
- throw new Error(`Didn't find an external IPv4 network interface`);
122
- }
123
- const addresses = interfaces[networkInterface];
124
- const ipv4Address = addresses?.find((addr) => addr.family === 'IPv4' && !addr.internal);
125
- if (!ipv4Address) {
126
- throw new Error(`Interface ${networkInterface} does not have an external IPv4 address`);
127
- }
128
- return ipv4Address.address;
129
- }
130
- getIpv6InterfaceAddress(networkInterface) {
131
- if (networkInterface === '')
132
- networkInterface = undefined;
133
- const interfaces = os.networkInterfaces();
134
- if (networkInterface && !interfaces[networkInterface]) {
135
- this.log.warn(`Interface "${networkInterface}" not found. Using first external IPv6 interface.`);
136
- networkInterface = undefined;
137
- }
138
- if (!networkInterface) {
139
- for (const [interfaceName, interfaceDetails] of Object.entries(interfaces)) {
140
- if (!networkInterface && this.excludedInterfaceNamePattern.test(interfaceName))
141
- continue;
142
- if (!interfaceDetails)
143
- continue;
144
- for (const detail of interfaceDetails) {
145
- if (detail.family === 'IPv6' && !detail.internal) {
146
- networkInterface = interfaceName;
147
- break;
148
- }
149
- }
150
- if (networkInterface)
151
- break;
152
- }
153
- }
154
- if (!networkInterface) {
155
- throw new Error(`Didn't find an external IPv6 network interface`);
156
- }
157
- const addresses = interfaces[networkInterface];
158
- const linkLocalAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fe80'));
159
- if (linkLocalAddress) {
160
- this.log.debug('Found IPv6 link-local address');
161
- return linkLocalAddress.scopeid ? `${linkLocalAddress.address}%${process.platform !== 'win32' ? networkInterface : linkLocalAddress.scopeid}` : linkLocalAddress.address;
162
- }
163
- this.log.debug('No IPv6 link-local address found');
164
- const ulaAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fd') && addr.netmask === 'ffff:ffff:ffff:ffff::');
165
- if (ulaAddress) {
166
- this.log.debug('Found IPv6 Unique Local Addresses (ULA) unicast address');
167
- return ulaAddress.address;
168
- }
169
- this.log.debug('No IPv6 Unique Local Addresses (ULA) unicast address found');
170
- const uniqueLocalAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fd'));
171
- if (uniqueLocalAddress) {
172
- this.log.debug('Found IPv6 Unique Local Addresses (ULA) address');
173
- return uniqueLocalAddress.address;
174
- }
175
- this.log.debug('No IPv6 Unique Local Addresses (ULA) address found');
176
- throw new Error(`Interface ${networkInterface} does not have a suitable external IPv6 address`);
177
- }
178
- getInterfacesNames() {
179
- const interfaces = os.networkInterfaces();
180
- const interfaceNames = [];
181
- for (const name in interfaces) {
182
- if (interfaces[name]) {
183
- interfaceNames.push(name);
184
- }
185
- }
186
- return interfaceNames;
187
- }
188
- getIpv6ScopeId(interfaceName) {
189
- const interfaces = os.networkInterfaces();
190
- for (const name in interfaces) {
191
- if (interfaceName && name !== interfaceName)
192
- continue;
193
- if (!interfaceName && this.excludedInterfaceNamePattern.test(name))
194
- continue;
195
- const iface = interfaces[name];
196
- if (iface) {
197
- const ipv6Address = iface.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.scopeid);
198
- if (ipv6Address) {
199
- return process.platform === 'win32' ? '%' + String(ipv6Address.scopeid) : '%' + name;
200
- }
201
- }
202
- }
203
- return '';
204
- }
205
- getInterfaceNameFromScopeId(scopeId) {
206
- const nets = os.networkInterfaces();
207
- for (const ifaceName in nets) {
208
- const addresses = nets[ifaceName] || [];
209
- for (const addr of addresses) {
210
- if (addr.family === 'IPv6' && addr.scopeid === scopeId) {
211
- return ifaceName;
212
- }
213
- }
214
- }
215
- return undefined;
216
- }
217
- getNetmask(interfaceAddress) {
218
- const noZoneAddress = interfaceAddress.includes('%') ? interfaceAddress.split('%')[0] : interfaceAddress;
219
- const nets = os.networkInterfaces();
220
- for (const ifaceName in nets) {
221
- const ifaceAddresses = nets[ifaceName];
222
- if (!ifaceAddresses)
223
- continue;
224
- for (const addr of ifaceAddresses) {
225
- if (addr.address === noZoneAddress) {
226
- return addr.netmask;
227
- }
228
- }
229
- }
230
- return undefined;
231
- }
232
- getIpv4BroadcastAddress(ipAddress, netmask) {
233
- if (!ipAddress || !netmask) {
234
- return undefined;
235
- }
236
- const ipParts = ipAddress.split('.').map(Number);
237
- const maskParts = netmask.split('.').map(Number);
238
- const broadcastParts = ipParts.map((octet, i) => (octet & maskParts[i]) | (255 - maskParts[i]));
239
- return broadcastParts.join('.');
240
- }
241
- getIpv6BroadcastAddress() {
242
- return 'ff02::1';
243
- }
244
- listNetworkInterfaces() {
245
- const interfaces = os.networkInterfaces();
246
- for (const [name, addresses] of Object.entries(interfaces)) {
247
- if (!addresses)
248
- continue;
249
- this.log.debug(`Interface: ${idn}${name}${rs}${db}`);
250
- for (const address of addresses) {
251
- this.log.debug(`- address ${BLUE}${address.address}${db} netmask ${BLUE}${address.netmask}${db} ${address.mac ? 'MAC: ' + BLUE + address.mac + db : ''} type: ${BLUE}${address.family}${db} ${BLUE}${address.internal ? 'internal' : 'external'}${db} ${address.scopeid !== undefined ? 'scopeid: ' + BLUE + address.scopeid + db : ''} cidr: ${BLUE}${address.cidr}${db}`);
252
- }
253
- }
254
- }
255
- }
@@ -1,5 +0,0 @@
1
- export * from './dgram.js';
2
- export * from './multicast.js';
3
- export * from './unicast.js';
4
- export * from './mdns.js';
5
- export * from './coap.js';
@@ -1,5 +0,0 @@
1
- export * from './dgram.js';
2
- export * from './multicast.js';
3
- export * from './unicast.js';
4
- export * from './mdns.js';
5
- export * from './coap.js';
@@ -1,188 +0,0 @@
1
- import dgram from 'node:dgram';
2
- import { AnsiLogger } from 'node-ansi-logger';
3
- import { Multicast } from './multicast.js';
4
- export declare const enum DnsRecordType {
5
- A = 1,
6
- NS = 2,
7
- MD = 3,
8
- MF = 4,
9
- CNAME = 5,
10
- SOA = 6,
11
- MB = 7,
12
- MG = 8,
13
- MR = 9,
14
- NULL = 10,
15
- WKS = 11,
16
- PTR = 12,
17
- HINFO = 13,
18
- MINFO = 14,
19
- MX = 15,
20
- TXT = 16,
21
- RP = 17,
22
- AFSDB = 18,
23
- X25 = 19,
24
- ISDN = 20,
25
- RT = 21,
26
- NSAP = 22,
27
- NSAP_PTR = 23,
28
- SIG = 24,
29
- KEY = 25,
30
- PX = 26,
31
- GPOS = 27,
32
- AAAA = 28,
33
- LOC = 29,
34
- NXT = 30,
35
- EID = 31,
36
- NIMLOC = 32,
37
- SRV = 33,
38
- ATMA = 34,
39
- NAPTR = 35,
40
- KX = 36,
41
- CERT = 37,
42
- A6 = 38,
43
- DNAME = 39,
44
- SINK = 40,
45
- OPT = 41,
46
- APL = 42,
47
- DS = 43,
48
- SSHFP = 44,
49
- IPSECKEY = 45,
50
- RRSIG = 46,
51
- NSEC = 47,
52
- DNSKEY = 48,
53
- DHCID = 49,
54
- NSEC3 = 50,
55
- NSEC3PARAM = 51,
56
- TLSA = 52,
57
- SMIMEA = 53,
58
- HIP = 55,
59
- NINFO = 56,
60
- RKEY = 57,
61
- TALINK = 58,
62
- CDS = 59,
63
- CDNSKEY = 60,
64
- OPENPGPKEY = 61,
65
- CSYNC = 62,
66
- ZONEMD = 63,
67
- SVCB = 64,
68
- HTTPS = 65,
69
- SPF = 99,
70
- UINFO = 100,
71
- UID = 101,
72
- GID = 102,
73
- UNSPEC = 103,
74
- NID = 104,
75
- L32 = 105,
76
- L64 = 106,
77
- LP = 107,
78
- EUI48 = 108,
79
- EUI64 = 109,
80
- TKEY = 249,
81
- TSIG = 250,
82
- IXFR = 251,
83
- AXFR = 252,
84
- MAILB = 253,
85
- MAILA = 254,
86
- ANY = 255,
87
- URI = 256,
88
- CAA = 257,
89
- AVC = 258,
90
- DOA = 259,
91
- AMTRELAY = 260,
92
- ZONEVERSION = 261,
93
- TA = 32768,
94
- DLV = 32769
95
- }
96
- export declare const enum DnsClass {
97
- IN = 1,
98
- CH = 3,
99
- HS = 4,
100
- ANY = 255
101
- }
102
- export declare const enum DnsClassFlag {
103
- FLUSH = 32768,
104
- QU = 32768
105
- }
106
- export interface MdnsMessage {
107
- id: number;
108
- qr: number;
109
- opcode: number;
110
- aa: boolean;
111
- tc: boolean;
112
- rd: boolean;
113
- ra: boolean;
114
- z: number;
115
- rcode: number;
116
- qdCount: number;
117
- anCount: number;
118
- nsCount: number;
119
- arCount: number;
120
- questions?: DnsQuestion[];
121
- answers?: MdnsRecord[];
122
- authorities?: MdnsRecord[];
123
- additionals?: MdnsRecord[];
124
- }
125
- interface DnsQuestion {
126
- name: string;
127
- type: number;
128
- class: number;
129
- }
130
- interface MdnsRecord {
131
- name: string;
132
- type: number;
133
- class: number;
134
- ttl: number;
135
- data: string;
136
- }
137
- export declare function isMdns(message: Buffer): boolean;
138
- export declare function isMdnsQuery(message: Buffer): boolean;
139
- export declare function isMdnsResponse(message: Buffer): boolean;
140
- export declare class Mdns extends Multicast {
141
- deviceQueries: Map<string, {
142
- rinfo: dgram.RemoteInfo;
143
- query: MdnsMessage;
144
- }>;
145
- deviceResponses: Map<string, {
146
- rinfo: dgram.RemoteInfo;
147
- response: MdnsMessage;
148
- dataPTR?: string;
149
- }>;
150
- filters: string[];
151
- constructor(name: string, multicastAddress: string, multicastPort: number, socketType: 'udp4' | 'udp6', reuseAddr?: boolean | undefined, interfaceName?: string, interfaceAddress?: string, outgoingInterfaceAddress?: string);
152
- onQuery(rinfo: dgram.RemoteInfo, _query: MdnsMessage): void;
153
- onResponse(rinfo: dgram.RemoteInfo, _response: MdnsMessage): void;
154
- onMessage(msg: Buffer, rinfo: dgram.RemoteInfo): void;
155
- decodeMdnsMessage(msg: Buffer): MdnsMessage;
156
- decodeDnsName(msg: Buffer, offset: number): {
157
- name: string;
158
- newOffset: number;
159
- };
160
- encodeDnsName(name: string): Buffer;
161
- encodeTxtRdata(txt: string[]): Buffer;
162
- encodeSrvRdata(priority: number, weight: number, port: number, target: string): Buffer;
163
- encodeA(ipv4: string): Buffer;
164
- encodeAAAA(ipv6WithOptionalScope: string): Buffer;
165
- decodeResourceRecord(msg: Buffer, offset: number): {
166
- record: MdnsRecord;
167
- newOffset: number;
168
- };
169
- sendQuery(questions: {
170
- name: string;
171
- type: number;
172
- class: number;
173
- unicastResponse?: boolean;
174
- }[]): Buffer<ArrayBuffer>;
175
- sendResponse(answers: {
176
- name: string;
177
- rtype: number;
178
- rclass: number;
179
- ttl: number;
180
- rdata: Buffer;
181
- }[]): Buffer<ArrayBuffer>;
182
- dnsTypeToString(type: number): string;
183
- dnsResponseClassToString(cls: number): string;
184
- dnsQuestionClassToString(cls: number): string;
185
- logMdnsMessage(msg: MdnsMessage, log?: AnsiLogger, text?: string): void;
186
- logDevices(): void;
187
- }
188
- export {};