matterbridge 3.5.0-dev-20260119-f9ea00e → 3.5.1-dev-20260121-22e98b4

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 +133 -117
  2. package/bin/mb_coap.js +1 -1
  3. package/bin/mb_mdns.js +1 -1
  4. package/dist/broadcastServer.js +1 -2
  5. package/dist/cli.d.ts +1 -2
  6. package/dist/cli.js +1 -5
  7. package/dist/cliHistory.js +1 -1
  8. package/dist/deviceManager.js +1 -1
  9. package/dist/frontend.js +2 -7
  10. package/dist/helpers.js +1 -1
  11. package/dist/matterNode.js +1 -5
  12. package/dist/matterbridge.js +14 -18
  13. package/dist/matterbridgeEndpoint.d.ts +2 -0
  14. package/dist/matterbridgeEndpoint.js +41 -2
  15. package/dist/matterbridgeEndpointHelpers.js +1 -3
  16. package/dist/matterbridgePlatform.js +1 -2
  17. package/dist/{dgram/mb_mdns.js → mb_mdns.js} +13 -1
  18. package/dist/pluginManager.js +3 -4
  19. package/dist/{utils/spawn.js → spawn.js} +2 -2
  20. package/dist/update.js +6 -7
  21. package/dist/utils/export.d.ts +1 -12
  22. package/dist/utils/export.js +1 -12
  23. package/dist/workerGlobalPrefix.js +1 -3
  24. package/frontend/build/assets/index.js +4 -4
  25. package/frontend/package.json +1 -1
  26. package/npm-shrinkwrap.json +2 -2
  27. package/package.json +5 -5
  28. package/dist/dgram/coap.d.ts +0 -34
  29. package/dist/dgram/coap.js +0 -252
  30. package/dist/dgram/dgram.d.ts +0 -45
  31. package/dist/dgram/dgram.js +0 -251
  32. package/dist/dgram/mdns.d.ts +0 -188
  33. package/dist/dgram/mdns.js +0 -702
  34. package/dist/dgram/multicast.d.ts +0 -18
  35. package/dist/dgram/multicast.js +0 -118
  36. package/dist/dgram/unicast.d.ts +0 -11
  37. package/dist/dgram/unicast.js +0 -40
  38. package/dist/utils/colorUtils.d.ts +0 -24
  39. package/dist/utils/colorUtils.js +0 -187
  40. package/dist/utils/commandLine.d.ts +0 -6
  41. package/dist/utils/commandLine.js +0 -63
  42. package/dist/utils/copyDirectory.d.ts +0 -2
  43. package/dist/utils/copyDirectory.js +0 -39
  44. package/dist/utils/createDirectory.d.ts +0 -2
  45. package/dist/utils/createDirectory.js +0 -21
  46. package/dist/utils/createZip.d.ts +0 -1
  47. package/dist/utils/createZip.js +0 -69
  48. package/dist/utils/deepCopy.d.ts +0 -1
  49. package/dist/utils/deepCopy.js +0 -40
  50. package/dist/utils/deepEqual.d.ts +0 -1
  51. package/dist/utils/deepEqual.js +0 -58
  52. package/dist/utils/error.d.ts +0 -3
  53. package/dist/utils/error.js +0 -12
  54. package/dist/utils/format.d.ts +0 -4
  55. package/dist/utils/format.js +0 -29
  56. package/dist/utils/hex.d.ts +0 -4
  57. package/dist/utils/hex.js +0 -118
  58. package/dist/utils/inspector.d.ts +0 -24
  59. package/dist/utils/inspector.js +0 -200
  60. package/dist/utils/isValid.d.ts +0 -10
  61. package/dist/utils/isValid.js +0 -69
  62. package/dist/utils/network.d.ts +0 -25
  63. package/dist/utils/network.js +0 -193
  64. package/dist/utils/tracker.d.ts +0 -52
  65. package/dist/utils/tracker.js +0 -201
  66. package/dist/utils/wait.d.ts +0 -3
  67. package/dist/utils/wait.js +0 -73
  68. /package/dist/{dgram/mb_coap.d.ts → mb_coap.d.ts} +0 -0
  69. /package/dist/{dgram/mb_coap.js → mb_coap.js} +0 -0
  70. /package/dist/{dgram/mb_mdns.d.ts → mb_mdns.d.ts} +0 -0
  71. /package/dist/{utils/spawn.d.ts → spawn.d.ts} +0 -0
@@ -1,58 +0,0 @@
1
- export function deepEqual(a, b, excludeProperties = []) {
2
- const debugLog = (...messages) => {
3
- };
4
- if (a === b) {
5
- return true;
6
- }
7
- if (typeof a !== typeof b) {
8
- debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
9
- return false;
10
- }
11
- if (a == null || b == null) {
12
- debugLog('deepEqual false for == null');
13
- return false;
14
- }
15
- if (a instanceof Date && b instanceof Date) {
16
- return a.getTime() === b.getTime();
17
- }
18
- if (a instanceof RegExp && b instanceof RegExp) {
19
- return a.source === b.source && a.flags === b.flags;
20
- }
21
- if (Array.isArray(a) && Array.isArray(b)) {
22
- if (a.length !== b.length) {
23
- debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
24
- return false;
25
- }
26
- for (let i = 0; i < a.length; i++) {
27
- if (!deepEqual(a[i], b[i], excludeProperties)) {
28
- debugLog('deepEqual false for array !deepEqual(a[i], b[i])');
29
- debugLog(`- aProps.length(${a[i]}):`, a[i]);
30
- debugLog(`- bProps.length(${b[i]}):`, b[i]);
31
- return false;
32
- }
33
- }
34
- return true;
35
- }
36
- if (typeof a === 'object' && typeof b === 'object') {
37
- const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
38
- const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
39
- if (aProps.length !== bProps.length) {
40
- debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
41
- debugLog(`- aProps.length(${aProps.length}):`, aProps);
42
- debugLog(`- bProps.length(${bProps.length}):`, bProps);
43
- return false;
44
- }
45
- for (const prop of aProps) {
46
- if (!Object.prototype.hasOwnProperty.call(b, prop)) {
47
- debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
48
- return false;
49
- }
50
- if (!deepEqual(a[prop], b[prop], excludeProperties)) {
51
- debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
52
- return false;
53
- }
54
- }
55
- return true;
56
- }
57
- return false;
58
- }
@@ -1,3 +0,0 @@
1
- import { type AnsiLogger } from 'node-ansi-logger';
2
- export declare function logError(log: AnsiLogger, message: string, error: unknown): void;
3
- export declare function inspectError(log: AnsiLogger, message: string, error: unknown): string;
@@ -1,12 +0,0 @@
1
- import { inspect } from 'node:util';
2
- import { RESET } from 'node-ansi-logger';
3
- export function logError(log, message, error) {
4
- log.error(`${message}: ${error instanceof Error ? error.message + ' \nStack: \n' + error.stack : error}`);
5
- }
6
- export function inspectError(log, message, error) {
7
- const errorMessage = error instanceof Error ? `${error.message} \n` : '';
8
- const inspectedError = inspect(error, { depth: 10, colors: true, showHidden: false });
9
- const fullMessage = `${message}: ${errorMessage}${RESET}${inspectedError}`;
10
- log.error(fullMessage);
11
- return fullMessage;
12
- }
@@ -1,4 +0,0 @@
1
- export declare function formatTimeStamp(timestamp: number): string;
2
- export declare function formatPercent(percent: number, digits?: number): string;
3
- export declare function formatBytes(bytes: number, digits?: number): string;
4
- export declare function formatUptime(seconds: number): string;
@@ -1,29 +0,0 @@
1
- export function formatTimeStamp(timestamp) {
2
- return `${new Date(timestamp).toLocaleString()}`;
3
- }
4
- export function formatPercent(percent, digits = 2) {
5
- return `${percent.toFixed(digits)} %`;
6
- }
7
- export function formatBytes(bytes, digits = 2) {
8
- if (bytes === 0)
9
- return `${bytes.toFixed(digits)} B`;
10
- const units = ['B', 'KB', 'MB', 'GB', 'TB'];
11
- const idx = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
12
- const value = bytes / Math.pow(1024, idx);
13
- return `${value.toFixed(digits)} ${units[idx]}`;
14
- }
15
- export function formatUptime(seconds) {
16
- if (seconds >= 86400) {
17
- const days = Math.floor(seconds / 86400);
18
- return `${days} day${days !== 1 ? 's' : ''}`;
19
- }
20
- if (seconds >= 3600) {
21
- const hours = Math.floor(seconds / 3600);
22
- return `${hours} hour${hours !== 1 ? 's' : ''}`;
23
- }
24
- if (seconds >= 60) {
25
- const minutes = Math.floor(seconds / 60);
26
- return `${minutes} minute${minutes !== 1 ? 's' : ''}`;
27
- }
28
- return `${seconds} second${seconds !== 1 ? 's' : ''}`;
29
- }
@@ -1,4 +0,0 @@
1
- export declare function bufferToHex(buffer: ArrayBufferLike): string;
2
- export declare function hexToBuffer(hex: string): Uint8Array;
3
- export declare function pemToBuffer(pem: string, validate?: boolean): Uint8Array;
4
- export declare function extractPrivateKeyRaw(pemPrivateKey: string): Uint8Array;
package/dist/utils/hex.js DELETED
@@ -1,118 +0,0 @@
1
- import { createPublicKey, createPrivateKey, X509Certificate } from 'node:crypto';
2
- export function bufferToHex(buffer) {
3
- if (!(buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer))) {
4
- throw new TypeError('Expected input to be an ArrayBuffer or ArrayBufferView');
5
- }
6
- const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
7
- return Array.from(bytes)
8
- .map((byte) => byte.toString(16).padStart(2, '0'))
9
- .join('');
10
- }
11
- export function hexToBuffer(hex) {
12
- if (typeof hex !== 'string') {
13
- throw new TypeError('Expected a string for hex input');
14
- }
15
- const cleaned = hex.trim();
16
- if (cleaned.length % 2 !== 0) {
17
- throw new Error('Invalid hex string length, must be even');
18
- }
19
- if (!/^[0-9a-fA-F]*$/.test(cleaned)) {
20
- throw new Error('Invalid hex string, contains non-hex characters');
21
- }
22
- const length = cleaned.length / 2;
23
- const result = new Uint8Array(length);
24
- for (let i = 0; i < length; i++) {
25
- result[i] = parseInt(cleaned.substr(i * 2, 2), 16);
26
- }
27
- return result;
28
- }
29
- export function pemToBuffer(pem, validate = false) {
30
- if (typeof pem !== 'string') {
31
- throw new TypeError('Expected a string for PEM input');
32
- }
33
- const cleaned = pem.trim();
34
- if (!cleaned.includes('-----BEGIN') || !cleaned.includes('-----END')) {
35
- throw new Error('Invalid PEM format: missing BEGIN/END markers');
36
- }
37
- const lines = cleaned.split('\n');
38
- const base64Lines = [];
39
- let inContent = false;
40
- for (const line of lines) {
41
- const trimmedLine = line.trim();
42
- if (trimmedLine.startsWith('-----BEGIN')) {
43
- inContent = true;
44
- continue;
45
- }
46
- if (trimmedLine.startsWith('-----END')) {
47
- inContent = false;
48
- break;
49
- }
50
- if (inContent && trimmedLine.length > 0) {
51
- base64Lines.push(trimmedLine);
52
- }
53
- }
54
- if (base64Lines.length === 0) {
55
- throw new Error('Invalid PEM format: no content found between BEGIN/END markers');
56
- }
57
- const base64String = base64Lines.join('');
58
- if (!/^[A-Za-z0-9+/]*={0,2}$/.test(base64String)) {
59
- throw new Error('Invalid PEM format: contains invalid base64 characters');
60
- }
61
- try {
62
- const buffer = Buffer.from(base64String, 'base64');
63
- const result = new Uint8Array(buffer);
64
- if (validate) {
65
- try {
66
- const pemType = cleaned.match(/-----BEGIN\s+([^-]+)-----/)?.[1]?.trim();
67
- if (pemType?.includes('CERTIFICATE')) {
68
- const cert = new X509Certificate(pem);
69
- if (cert.validFrom && cert.validTo) {
70
- const now = Date.now();
71
- const from = Date.parse(cert.validFrom);
72
- const to = Date.parse(cert.validTo);
73
- if (now < from || now > to) {
74
- throw new Error('Certificate is not currently valid');
75
- }
76
- }
77
- if (!cert.subject || !cert.issuer) {
78
- throw new Error('Certificate missing subject or issuer');
79
- }
80
- }
81
- else if (pemType?.includes('PRIVATE KEY')) {
82
- createPrivateKey({ key: pem, format: 'pem' });
83
- }
84
- else if (pemType?.includes('PUBLIC KEY')) {
85
- createPublicKey({ key: pem, format: 'pem' });
86
- }
87
- }
88
- catch (validationError) {
89
- throw new Error(`PEM validation failed: ${validationError instanceof Error ? validationError.message : String(validationError)}`);
90
- }
91
- }
92
- return result;
93
- }
94
- catch (error) {
95
- throw new Error(`Failed to decode base64 content: ${error instanceof Error ? error.message : String(error)}`);
96
- }
97
- }
98
- export function extractPrivateKeyRaw(pemPrivateKey) {
99
- if (typeof pemPrivateKey !== 'string') {
100
- throw new TypeError('Expected a string for PEM private key input');
101
- }
102
- const keyBlock = /-----BEGIN (?:EC )?PRIVATE KEY-----[^-]+-----END (?:EC )?PRIVATE KEY-----/s.exec(pemPrivateKey);
103
- if (!keyBlock) {
104
- throw new Error('No EC PRIVATE KEY block found in the supplied PEM');
105
- }
106
- try {
107
- const privateKey = createPrivateKey(keyBlock[0]);
108
- const pkcs8Der = privateKey.export({ format: 'der', type: 'pkcs8' });
109
- if (pkcs8Der.length < 32) {
110
- throw new Error('Invalid private key: DER data too short');
111
- }
112
- const rawPrivateKey = pkcs8Der.subarray(pkcs8Der.length - 32);
113
- return new Uint8Array(rawPrivateKey);
114
- }
115
- catch (error) {
116
- throw new Error(`Failed to extract private key: ${error instanceof Error ? error.message : String(error)}`);
117
- }
118
- }
@@ -1,24 +0,0 @@
1
- import EventEmitter from 'node:events';
2
- interface InspectorEvents {
3
- start: [];
4
- stop: [];
5
- snapshot: [];
6
- snapshot_done: [];
7
- gc: [type?: 'major' | 'minor', execution?: 'sync' | 'async'];
8
- gc_done: [type: 'major' | 'minor', execution: 'sync' | 'async'];
9
- }
10
- export declare class Inspector extends EventEmitter<InspectorEvents> {
11
- private readonly name;
12
- private readonly debug;
13
- private readonly verbose;
14
- private session;
15
- private snapshotInterval?;
16
- private snapshotInProgress;
17
- private log;
18
- constructor(name?: string, debug?: boolean, verbose?: boolean);
19
- start(): Promise<void>;
20
- stop(): Promise<void>;
21
- takeHeapSnapshot(): Promise<void>;
22
- runGarbageCollector(type?: 'major' | 'minor', execution?: 'sync' | 'async'): void;
23
- }
24
- export {};
@@ -1,200 +0,0 @@
1
- if (process.argv.includes('--loader') || process.argv.includes('-loader'))
2
- console.log('\u001B[32mInspector loaded.\u001B[40;0m');
3
- import EventEmitter from 'node:events';
4
- import { AnsiLogger, BRIGHT, CYAN, RESET, YELLOW, db } from 'node-ansi-logger';
5
- export class Inspector extends EventEmitter {
6
- name;
7
- debug;
8
- verbose;
9
- session;
10
- snapshotInterval;
11
- snapshotInProgress = false;
12
- log;
13
- constructor(name = 'Inspector', debug = false, verbose = false) {
14
- super();
15
- this.name = name;
16
- this.debug = debug;
17
- this.verbose = verbose;
18
- if (process.argv.includes('--debug') || process.argv.includes('-debug')) {
19
- this.debug = true;
20
- }
21
- if (process.argv.includes('--verbose') || process.argv.includes('-verbose')) {
22
- this.verbose = true;
23
- }
24
- this.log = new AnsiLogger({ logName: this.name, logTimestampFormat: 4, logLevel: this.debug ? "debug" : "info" });
25
- this.log.logNameColor = YELLOW;
26
- this.on('start', () => {
27
- this.start();
28
- });
29
- this.on('stop', () => {
30
- this.stop();
31
- });
32
- this.on('snapshot', () => {
33
- this.takeHeapSnapshot();
34
- });
35
- this.on('gc', () => {
36
- this.runGarbageCollector();
37
- });
38
- }
39
- async start() {
40
- if (this.session) {
41
- this.log.warn('Inspector session already active.');
42
- return;
43
- }
44
- const { Session } = await import('node:inspector');
45
- const { mkdirSync } = await import('node:fs');
46
- this.log.debug(`Starting heap sampling...`);
47
- mkdirSync('heap_profiles', { recursive: true });
48
- mkdirSync('heap_snapshots', { recursive: true });
49
- try {
50
- this.session = new Session();
51
- this.session.connect();
52
- await new Promise((resolve, reject) => {
53
- this.session?.post('HeapProfiler.startSampling', (err) => (err ? reject(err) : resolve()));
54
- });
55
- this.log.debug(`Started heap sampling`);
56
- const { getIntParameter } = await import('./commandLine.js');
57
- const interval = getIntParameter('snapshotinterval');
58
- if (interval && interval >= 30000) {
59
- this.log.debug(`Started heap snapshot interval of ${CYAN}${interval}${db} ms`);
60
- clearInterval(this.snapshotInterval);
61
- this.snapshotInterval = setInterval(async () => {
62
- try {
63
- if (this.snapshotInProgress) {
64
- if (this.debug)
65
- this.log.debug(`Skip heap snapshot: previous snapshot still in progress`);
66
- return;
67
- }
68
- this.log.debug(`Run heap snapshot interval`);
69
- await this.takeHeapSnapshot();
70
- }
71
- catch (err) {
72
- this.log.error(`Error during scheduled heap snapshot: ${err instanceof Error ? err.message : err}`);
73
- }
74
- }, interval).unref();
75
- }
76
- }
77
- catch (err) {
78
- this.log.error(`Failed to start heap sampling: ${err instanceof Error ? err.message : err}`);
79
- this.session?.disconnect();
80
- this.session = undefined;
81
- return;
82
- }
83
- }
84
- async stop() {
85
- if (!this.session) {
86
- this.log.warn('No active inspector session.');
87
- return;
88
- }
89
- const { writeFileSync } = await import('node:fs');
90
- const path = await import('node:path');
91
- this.log.debug(`Stopping heap sampling...`);
92
- if (this.snapshotInterval) {
93
- this.log.debug(`Clearing heap snapshot interval...`);
94
- clearInterval(this.snapshotInterval);
95
- await this.takeHeapSnapshot();
96
- }
97
- try {
98
- const result = await new Promise((resolve, reject) => {
99
- this.session?.post('HeapProfiler.stopSampling', (err, result) => (err ? reject(err) : resolve(result)));
100
- });
101
- const profile = JSON.stringify(result.profile);
102
- const safeTimestamp = new Date().toISOString().replace(/[<>:"/\\|?*]/g, '-');
103
- const filename = path.join('heap_profiles', `${safeTimestamp}.heapprofile`);
104
- writeFileSync(filename, profile);
105
- this.log.debug(`Heap sampling profile saved to ${CYAN}${filename}${db}`);
106
- }
107
- catch (err) {
108
- this.log.error(`Failed to stop heap sampling: ${err instanceof Error ? err.message : err}`);
109
- }
110
- finally {
111
- this.session.disconnect();
112
- this.session = undefined;
113
- this.log.debug(`Stopped heap sampling`);
114
- }
115
- }
116
- async takeHeapSnapshot() {
117
- if (!this.session) {
118
- this.log.warn('No active inspector session.');
119
- return;
120
- }
121
- if (this.snapshotInProgress) {
122
- if (this.debug)
123
- this.log.debug('Heap snapshot already in progress, skipping.');
124
- return;
125
- }
126
- this.snapshotInProgress = true;
127
- const { createWriteStream } = await import('node:fs');
128
- const path = await import('node:path');
129
- const safeTimestamp = new Date().toISOString().replace(/[<>:"/\\|?*]/g, '-');
130
- const filename = path.join('heap_snapshots', `${safeTimestamp}.heapsnapshot`);
131
- this.runGarbageCollector('minor', 'async');
132
- this.runGarbageCollector('major', 'async');
133
- if (this.debug)
134
- this.log.debug(`Taking heap snapshot to ${CYAN}${filename}${db}...`);
135
- const stream = createWriteStream(filename, { flags: 'w' });
136
- let streamErrored = false;
137
- const onStreamError = (err) => {
138
- streamErrored = true;
139
- this.log.error(`Heap snapshot stream error: ${err instanceof Error ? err.message : err}`);
140
- };
141
- stream.once('error', onStreamError);
142
- const chunksListener = (notification) => {
143
- if (!stream.write(notification.params.chunk)) {
144
- }
145
- };
146
- this.session.on('HeapProfiler.addHeapSnapshotChunk', chunksListener);
147
- try {
148
- await new Promise((resolve) => {
149
- this.session?.post('HeapProfiler.takeHeapSnapshot', (err) => {
150
- this.session?.off('HeapProfiler.addHeapSnapshotChunk', chunksListener);
151
- const finalize = () => {
152
- if (!err && !streamErrored) {
153
- if (this.debug)
154
- this.log.debug(`Heap sampling snapshot saved to ${CYAN}${filename}${db}`);
155
- this.runGarbageCollector('minor', 'async');
156
- this.runGarbageCollector('major', 'async');
157
- this.emit('snapshot_done');
158
- }
159
- else if (err) {
160
- this.log.error(`Failed to take heap snapshot: ${err instanceof Error ? err.message : err}`);
161
- this.runGarbageCollector('minor', 'async');
162
- this.runGarbageCollector('major', 'async');
163
- }
164
- resolve();
165
- };
166
- try {
167
- stream.end(() => finalize());
168
- }
169
- catch (e) {
170
- this.log.error(`Error finalizing heap snapshot stream: ${e instanceof Error ? e.message : e}`);
171
- finalize();
172
- }
173
- });
174
- });
175
- }
176
- finally {
177
- this.snapshotInProgress = false;
178
- }
179
- }
180
- runGarbageCollector(type = 'major', execution = 'async') {
181
- if (global.gc && typeof global.gc === 'function') {
182
- try {
183
- global.gc({ type, execution });
184
- if (this.debug)
185
- this.log.debug(`${CYAN}${BRIGHT}Garbage collection (${type}-${execution}) triggered at ${new Date(Date.now()).toLocaleString()}.${RESET}${db}`);
186
- this.emit('gc_done', type, execution);
187
- }
188
- catch {
189
- global.gc();
190
- if (this.debug)
191
- this.log.debug(`${CYAN}${BRIGHT}Garbage collection (minor-async) triggered at ${new Date(Date.now()).toLocaleString()}.${RESET}${db}`);
192
- this.emit('gc_done', 'minor', 'async');
193
- }
194
- }
195
- else {
196
- if (this.debug)
197
- this.log.debug(`${CYAN}${BRIGHT}Garbage collection not exposed. Start Node.js with --expose-gc to enable manual garbage collection.${RESET}${db}`);
198
- }
199
- }
200
- }
@@ -1,10 +0,0 @@
1
- export declare function isValidIpv4Address(ipv4Address: string): boolean;
2
- export declare function isValidNumber(value: unknown, min?: number, max?: number): value is number;
3
- export declare function isValidBoolean(value: unknown): value is boolean;
4
- export declare function isValidString(value: unknown, minLength?: number, maxLength?: number): value is string;
5
- export declare function isValidRegExp(value: unknown): value is RegExp;
6
- export declare function isValidObject(value: unknown, minLength?: number, maxLength?: number): value is object;
7
- export declare function isValidArray(value: unknown, minLength?: number, maxLength?: number): value is unknown[];
8
- export declare function isValidNull(value: unknown): value is null;
9
- export declare function isValidUndefined(value: unknown): value is undefined;
10
- export declare function parseVersionString(versionString: string): number | undefined;
@@ -1,69 +0,0 @@
1
- export function isValidIpv4Address(ipv4Address) {
2
- const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
3
- return ipv4Regex.test(ipv4Address);
4
- }
5
- export function isValidNumber(value, min, max) {
6
- if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value))
7
- return false;
8
- if (min !== undefined && value < min)
9
- return false;
10
- if (max !== undefined && value > max)
11
- return false;
12
- return true;
13
- }
14
- export function isValidBoolean(value) {
15
- return value !== undefined && value !== null && typeof value === 'boolean';
16
- }
17
- export function isValidString(value, minLength, maxLength) {
18
- if (value === undefined || value === null || typeof value !== 'string')
19
- return false;
20
- if (minLength !== undefined && value.length < minLength)
21
- return false;
22
- if (maxLength !== undefined && value.length > maxLength)
23
- return false;
24
- return true;
25
- }
26
- export function isValidRegExp(value) {
27
- return value !== undefined && value !== null && value instanceof RegExp;
28
- }
29
- export function isValidObject(value, minLength, maxLength) {
30
- if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
31
- return false;
32
- const keys = Object.keys(value);
33
- if (minLength !== undefined && keys.length < minLength)
34
- return false;
35
- if (maxLength !== undefined && keys.length > maxLength)
36
- return false;
37
- return true;
38
- }
39
- export function isValidArray(value, minLength, maxLength) {
40
- if (value === undefined || value === null || !Array.isArray(value))
41
- return false;
42
- if (minLength !== undefined && value.length < minLength)
43
- return false;
44
- if (maxLength !== undefined && value.length > maxLength)
45
- return false;
46
- return true;
47
- }
48
- export function isValidNull(value) {
49
- return value === null;
50
- }
51
- export function isValidUndefined(value) {
52
- return value === undefined;
53
- }
54
- export function parseVersionString(versionString) {
55
- if (!isValidString(versionString))
56
- return undefined;
57
- versionString = versionString.trim();
58
- const match = versionString.match(/^(\d+)\.(\d+)\.(\d+)/);
59
- if (!match)
60
- return undefined;
61
- const [, majorStr, minorStr, patchStr] = match;
62
- const major = parseInt(majorStr, 10);
63
- const minor = parseInt(minorStr, 10);
64
- const patch = parseInt(patchStr, 10);
65
- if ([major, minor, patch].some((n) => !Number.isFinite(n)) || major > 99 || minor > 99 || patch > 99) {
66
- return undefined;
67
- }
68
- return major * 10000 + minor * 100 + patch;
69
- }
@@ -1,25 +0,0 @@
1
- export declare function getInterfaceDetails(): {
2
- interfaceName: string;
3
- ipv4Address: string | undefined;
4
- ipv6Address: string | undefined;
5
- macAddress: string | undefined;
6
- } | undefined;
7
- export declare function getInterfaceName(): string | undefined;
8
- export declare function getIpv4InterfaceAddress(): string | undefined;
9
- export declare function getIpv6InterfaceAddress(scope?: boolean): string | undefined;
10
- export declare function getMacAddress(): string | undefined;
11
- export declare function logInterfaces(): void;
12
- export declare function resolveHostname(hostname: string, family?: 0 | 4 | 6): Promise<string | null>;
13
- export declare function getNpmPackageVersion(packageName: string, tag?: string, timeout?: number): Promise<string>;
14
- export type UpdateJson = {
15
- latest: string;
16
- latestDate: string;
17
- dev: string;
18
- devDate: string;
19
- latestMessage: string;
20
- latestMessageSeverity: 'info' | 'warning' | 'error' | 'success';
21
- devMessage: string;
22
- devMessageSeverity: 'info' | 'warning' | 'error' | 'success';
23
- };
24
- export declare function getGitHubUpdate(branch: 'main' | 'dev', file: string, timeout?: number): Promise<UpdateJson>;
25
- export declare function getGlobalNodeModules(): Promise<string>;