matterbridge 3.0.0-edge.7 → 3.0.0
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/CHANGELOG.md +52 -9
- package/README-DEV.md +4 -0
- package/README-DOCKER.md +21 -12
- package/README-SERVICE.md +27 -21
- package/README.md +80 -2
- package/dist/cli.d.ts +29 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +41 -3
- package/dist/cli.js.map +1 -0
- package/dist/cluster/export.d.ts +2 -0
- package/dist/cluster/export.d.ts.map +1 -0
- package/dist/cluster/export.js +2 -0
- package/dist/cluster/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +27 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +23 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +114 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/frontend.d.ts +222 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +443 -35
- package/dist/frontend.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +2 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +2 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +431 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +800 -79
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +34 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1514 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +33 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +494 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +431 -12
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +34 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +943 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +806 -7
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +2706 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +156 -9
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +294 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +227 -9
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +187 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +24 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +271 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +262 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +92 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +146 -6
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +32 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +70 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +61 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +205 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +32 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +37 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +38 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +42 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +31 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +40 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +53 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +65 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts +10 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/isvalid.d.ts +87 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +86 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts +69 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +76 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/parameter.d.ts +58 -0
- package/dist/utils/parameter.d.ts.map +1 -0
- package/dist/utils/parameter.js +92 -7
- package/dist/utils/parameter.js.map +1 -0
- package/dist/utils/wait.d.ts +43 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +50 -5
- package/dist/utils/wait.js.map +1 -0
- package/frontend/build/asset-manifest.json +6 -6
- package/frontend/build/bmc-button.svg +22 -0
- package/frontend/build/discord.svg +5 -0
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/css/{main.ea7910e9.css → main.944b63c3.css} +2 -2
- package/frontend/build/static/css/main.944b63c3.css.map +1 -0
- package/frontend/build/static/js/{main.e11d6bb4.js → main.1d983660.js} +12 -12
- package/frontend/build/static/js/{main.e11d6bb4.js.map → main.1d983660.js.map} +1 -1
- package/npm-shrinkwrap.json +300 -362
- package/package.json +5 -4
- package/tsconfig.jest.json +8 -0
- package/README-EDGE.md +0 -74
- package/frontend/build/static/css/main.ea7910e9.css.map +0 -1
- /package/frontend/build/static/js/{main.e11d6bb4.js.LICENSE.txt → main.1d983660.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepEqual function.
|
|
3
|
+
*
|
|
4
|
+
* @file deepEqual.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
25
|
+
* This comparison includes primitive types, arrays, and objects, allowing for optional
|
|
26
|
+
* exclusion of specific properties from the comparison in objects.
|
|
27
|
+
*
|
|
28
|
+
* @param {any} a The first value to compare.
|
|
29
|
+
* @param {any} b The second value to compare.
|
|
30
|
+
* @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
|
|
31
|
+
* @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
|
|
32
|
+
*
|
|
33
|
+
* Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
|
|
34
|
+
* mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
|
|
35
|
+
* objects do not contain circular references when enabling debug logging to avoid infinite loops.
|
|
36
|
+
*
|
|
37
|
+
* Example usage:
|
|
38
|
+
* ```
|
|
39
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
40
|
+
* const obj2 = { a: 1, b: { c: 2 } };
|
|
41
|
+
* console.log(deepEqual(obj1, obj2)); // true
|
|
42
|
+
*
|
|
43
|
+
* const arr1 = [1, 2, [3, 4]];
|
|
44
|
+
* const arr2 = [1, 2, [3, 4]];
|
|
45
|
+
* console.log(deepEqual(arr1, arr2)); // true
|
|
46
|
+
*
|
|
47
|
+
* const obj3 = { a: 1, b: { c: 2, d: 3 } };
|
|
48
|
+
* const obj4 = { a: 1, b: { c: 2 } };
|
|
49
|
+
* console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function deepEqual(a: any, b: any, excludeProperties?: string[]): boolean;
|
|
53
|
+
//# sourceMappingURL=deepEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.d.ts","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,GAAE,MAAM,EAAO,GAAG,OAAO,CA6EnF"}
|
package/dist/utils/deepEqual.js
CHANGED
|
@@ -1,21 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepEqual function.
|
|
3
|
+
*
|
|
4
|
+
* @file deepEqual.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
24
|
+
/**
|
|
25
|
+
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
26
|
+
* This comparison includes primitive types, arrays, and objects, allowing for optional
|
|
27
|
+
* exclusion of specific properties from the comparison in objects.
|
|
28
|
+
*
|
|
29
|
+
* @param {any} a The first value to compare.
|
|
30
|
+
* @param {any} b The second value to compare.
|
|
31
|
+
* @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
|
|
32
|
+
* @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
|
|
33
|
+
*
|
|
34
|
+
* Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
|
|
35
|
+
* mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
|
|
36
|
+
* objects do not contain circular references when enabling debug logging to avoid infinite loops.
|
|
37
|
+
*
|
|
38
|
+
* Example usage:
|
|
39
|
+
* ```
|
|
40
|
+
* const obj1 = { a: 1, b: { c: 2 } };
|
|
41
|
+
* const obj2 = { a: 1, b: { c: 2 } };
|
|
42
|
+
* console.log(deepEqual(obj1, obj2)); // true
|
|
43
|
+
*
|
|
44
|
+
* const arr1 = [1, 2, [3, 4]];
|
|
45
|
+
* const arr2 = [1, 2, [3, 4]];
|
|
46
|
+
* console.log(deepEqual(arr1, arr2)); // true
|
|
47
|
+
*
|
|
48
|
+
* const obj3 = { a: 1, b: { c: 2, d: 3 } };
|
|
49
|
+
* const obj4 = { a: 1, b: { c: 2 } };
|
|
50
|
+
* console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
1
53
|
export function deepEqual(a, b, excludeProperties = []) {
|
|
54
|
+
// Toggle debugging on or off easily
|
|
2
55
|
const debug = false;
|
|
56
|
+
// Helper function for conditional logging
|
|
3
57
|
const debugLog = (...messages) => {
|
|
4
58
|
if (debug) {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
5
60
|
console.log(...messages);
|
|
6
61
|
}
|
|
7
62
|
};
|
|
63
|
+
// If both are the same instance, return true (handles primitives and same object references)
|
|
8
64
|
if (a === b) {
|
|
9
65
|
return true;
|
|
10
66
|
}
|
|
67
|
+
// If types are different, return false
|
|
11
68
|
if (typeof a !== typeof b) {
|
|
12
69
|
debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
|
|
13
70
|
return false;
|
|
14
71
|
}
|
|
72
|
+
// If one of them is null (and we know they are not equal from the first check), return false
|
|
15
73
|
if (a == null || b == null) {
|
|
16
74
|
debugLog('deepEqual false for == null');
|
|
17
75
|
return false;
|
|
18
76
|
}
|
|
77
|
+
// Handle Arrays
|
|
19
78
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
20
79
|
if (a.length !== b.length) {
|
|
21
80
|
debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
|
|
@@ -31,26 +90,31 @@ export function deepEqual(a, b, excludeProperties = []) {
|
|
|
31
90
|
}
|
|
32
91
|
return true;
|
|
33
92
|
}
|
|
93
|
+
// Handle Objects (and exclude null, functions, and arrays)
|
|
34
94
|
if (typeof a === 'object' && typeof b === 'object') {
|
|
35
95
|
const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
|
|
36
96
|
const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
|
|
97
|
+
// If their property lengths are different, they're different objects
|
|
37
98
|
if (aProps.length !== bProps.length) {
|
|
38
99
|
debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
|
|
39
100
|
debugLog(`- aProps.length(${aProps.length}):`, aProps);
|
|
40
101
|
debugLog(`- bProps.length(${bProps.length}):`, bProps);
|
|
41
102
|
return false;
|
|
42
103
|
}
|
|
104
|
+
// Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
|
|
43
105
|
for (const prop of aProps) {
|
|
44
106
|
if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
|
45
107
|
debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
|
|
46
108
|
return false;
|
|
47
109
|
}
|
|
48
110
|
if (!deepEqual(a[prop], b[prop], excludeProperties)) {
|
|
49
|
-
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
|
|
111
|
+
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
|
|
50
112
|
return false;
|
|
51
113
|
}
|
|
52
114
|
}
|
|
53
115
|
return true;
|
|
54
116
|
}
|
|
117
|
+
// If none of the above, the objects are not equal
|
|
55
118
|
return false;
|
|
56
119
|
}
|
|
120
|
+
//# sourceMappingURL=deepEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.js","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,uDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,SAAS,CAAC,CAAM,EAAE,CAAM,EAAE,oBAA8B,EAAE;IACxE,oCAAoC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC;IAEpB,0CAA0C;IAE1C,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAe,EAAE,EAAE;QACtC,IAAI,KAAK,EAAE,CAAC;YACV,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;IAEF,6FAA6F;IAC7F,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uCAAuC;IACvC,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,iCAAiC,OAAO,CAAC,cAAc,OAAO,CAAC,EAAE,CA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|
+
export * from './network.js';
|
|
2
|
+
export * from './parameter.js';
|
|
3
|
+
export * from './isvalid.js';
|
|
4
|
+
export * from './colorUtils.js';
|
|
5
|
+
export * from './deepCopy.js';
|
|
6
|
+
export * from './deepEqual.js';
|
|
7
|
+
export * from './copyDirectory.js';
|
|
8
|
+
export * from './createZip.js';
|
|
9
|
+
export * from './wait.js';
|
|
10
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
package/dist/utils/export.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepEqual function.
|
|
3
|
+
*
|
|
4
|
+
* @file isvalid.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a given string is a valid IPv4 address.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} ipv4Address - The string to be checked.
|
|
27
|
+
* @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidIpv4Address(ipv4Address: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if a value is a valid number within the specified range.
|
|
32
|
+
*
|
|
33
|
+
* @param {any} value - The value to be checked.
|
|
34
|
+
* @param {number} min - The minimum value allowed (optional).
|
|
35
|
+
* @param {number} max - The maximum value allowed (optional).
|
|
36
|
+
* @returns {boolean} Returns true if the value is a valid number within the specified range, otherwise false.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isValidNumber(value: any, min?: number, max?: number): value is number;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if a value is a valid boolean.
|
|
41
|
+
*
|
|
42
|
+
* @param {any} value - The value to be checked.
|
|
43
|
+
* @returns {boolean} `true` if the value is a valid boolean, `false` otherwise.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isValidBoolean(value: any): value is boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a value is a valid string.
|
|
48
|
+
*
|
|
49
|
+
* @param {any} value - The value to be checked.
|
|
50
|
+
* @param {number} minLength - The min string length (optional).
|
|
51
|
+
* @param {number} maxLength - The max string length (optional).
|
|
52
|
+
* @returns {boolean} A boolean indicating whether the value is a valid string.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isValidString(value: any, minLength?: number, maxLength?: number): value is string;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if a value is a valid object.
|
|
57
|
+
*
|
|
58
|
+
* @param {any} value - The value to be checked.
|
|
59
|
+
* @param {number} minLength - The min number of keys (optional).
|
|
60
|
+
* @param {number} maxLength - The max number of keys (optional).
|
|
61
|
+
* @returns {boolean} A boolean indicating whether the value is a valid object.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isValidObject(value: any, minLength?: number, maxLength?: number): value is object;
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a value is a valid array.
|
|
66
|
+
*
|
|
67
|
+
* @param {any} value - The value to be checked.
|
|
68
|
+
* @param {number} minLength - The min number of elements (optional).
|
|
69
|
+
* @param {number} maxLength - The max number of elements (optional).
|
|
70
|
+
* @returns {boolean} A boolean indicating whether the value is a valid array.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isValidArray(value: any, minLength?: number, maxLength?: number): value is unknown[];
|
|
73
|
+
/**
|
|
74
|
+
* Checks if the given value is null.
|
|
75
|
+
*
|
|
76
|
+
* @param {any} value - The value to check.
|
|
77
|
+
* @returns {boolean} `true` if the value is null, `false` otherwise.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isValidNull(value: any): value is null;
|
|
80
|
+
/**
|
|
81
|
+
* Checks if a value is undefined.
|
|
82
|
+
*
|
|
83
|
+
* @param {any} value - The value to check.
|
|
84
|
+
* @returns {boolean} `true` if the value is undefined, `false` otherwise.
|
|
85
|
+
*/
|
|
86
|
+
export declare function isValidUndefined(value: any): value is undefined;
|
|
87
|
+
//# sourceMappingURL=isvalid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isvalid.d.ts","sourceRoot":"","sources":["../../src/utils/isvalid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqB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 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a given string is a valid IPv4 address.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} ipv4Address - The string to be checked.
|
|
27
|
+
* @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
|
|
28
|
+
*/
|
|
1
29
|
export function isValidIpv4Address(ipv4Address) {
|
|
2
30
|
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
31
|
return ipv4Regex.test(ipv4Address);
|
|
4
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a value is a valid number within the specified range.
|
|
35
|
+
*
|
|
36
|
+
* @param {any} value - The value to be checked.
|
|
37
|
+
* @param {number} min - The minimum value allowed (optional).
|
|
38
|
+
* @param {number} max - The maximum value allowed (optional).
|
|
39
|
+
* @returns {boolean} Returns true if the value is a valid number within the specified range, otherwise false.
|
|
40
|
+
*/
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
42
|
export function isValidNumber(value, min, max) {
|
|
6
43
|
if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value))
|
|
7
44
|
return false;
|
|
@@ -11,9 +48,25 @@ export function isValidNumber(value, min, max) {
|
|
|
11
48
|
return false;
|
|
12
49
|
return true;
|
|
13
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if a value is a valid boolean.
|
|
53
|
+
*
|
|
54
|
+
* @param {any} value - The value to be checked.
|
|
55
|
+
* @returns {boolean} `true` if the value is a valid boolean, `false` otherwise.
|
|
56
|
+
*/
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
58
|
export function isValidBoolean(value) {
|
|
15
59
|
return value !== undefined && value !== null && typeof value === 'boolean';
|
|
16
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Checks if a value is a valid string.
|
|
63
|
+
*
|
|
64
|
+
* @param {any} value - The value to be checked.
|
|
65
|
+
* @param {number} minLength - The min string length (optional).
|
|
66
|
+
* @param {number} maxLength - The max string length (optional).
|
|
67
|
+
* @returns {boolean} A boolean indicating whether the value is a valid string.
|
|
68
|
+
*/
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
70
|
export function isValidString(value, minLength, maxLength) {
|
|
18
71
|
if (value === undefined || value === null || typeof value !== 'string')
|
|
19
72
|
return false;
|
|
@@ -23,6 +76,15 @@ export function isValidString(value, minLength, maxLength) {
|
|
|
23
76
|
return false;
|
|
24
77
|
return true;
|
|
25
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks if a value is a valid object.
|
|
81
|
+
*
|
|
82
|
+
* @param {any} value - The value to be checked.
|
|
83
|
+
* @param {number} minLength - The min number of keys (optional).
|
|
84
|
+
* @param {number} maxLength - The max number of keys (optional).
|
|
85
|
+
* @returns {boolean} A boolean indicating whether the value is a valid object.
|
|
86
|
+
*/
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
88
|
export function isValidObject(value, minLength, maxLength) {
|
|
27
89
|
if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
|
|
28
90
|
return false;
|
|
@@ -33,6 +95,15 @@ export function isValidObject(value, minLength, maxLength) {
|
|
|
33
95
|
return false;
|
|
34
96
|
return true;
|
|
35
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Checks if a value is a valid array.
|
|
100
|
+
*
|
|
101
|
+
* @param {any} value - The value to be checked.
|
|
102
|
+
* @param {number} minLength - The min number of elements (optional).
|
|
103
|
+
* @param {number} maxLength - The max number of elements (optional).
|
|
104
|
+
* @returns {boolean} A boolean indicating whether the value is a valid array.
|
|
105
|
+
*/
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
107
|
export function isValidArray(value, minLength, maxLength) {
|
|
37
108
|
if (value === undefined || value === null || !Array.isArray(value))
|
|
38
109
|
return false;
|
|
@@ -42,9 +113,24 @@ export function isValidArray(value, minLength, maxLength) {
|
|
|
42
113
|
return false;
|
|
43
114
|
return true;
|
|
44
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Checks if the given value is null.
|
|
118
|
+
*
|
|
119
|
+
* @param {any} value - The value to check.
|
|
120
|
+
* @returns {boolean} `true` if the value is null, `false` otherwise.
|
|
121
|
+
*/
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
123
|
export function isValidNull(value) {
|
|
46
124
|
return value === null;
|
|
47
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Checks if a value is undefined.
|
|
128
|
+
*
|
|
129
|
+
* @param {any} value - The value to check.
|
|
130
|
+
* @returns {boolean} `true` if the value is undefined, `false` otherwise.
|
|
131
|
+
*/
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
133
|
export function isValidUndefined(value) {
|
|
49
134
|
return value === undefined;
|
|
50
135
|
}
|
|
136
|
+
//# sourceMappingURL=isvalid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isvalid.js","sourceRoot":"","sources":["../../src/utils/isvalid.ts"],"names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
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the network function.
|
|
3
|
+
*
|
|
4
|
+
* @file network.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-02-17
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the IPv4 address of the first non-internal network interface.
|
|
25
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getIpv4InterfaceAddress(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the IPv6 address of the first non-internal network interface.
|
|
30
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getIpv6InterfaceAddress(): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the mac address of the first non-internal network interface.
|
|
35
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMacAddress(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Logs the available network interfaces and their details.
|
|
40
|
+
* @param {boolean} log - Whether to enable logging of network interface details.
|
|
41
|
+
*/
|
|
42
|
+
export declare function logInterfaces(debug?: boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves the given hostname to an IP address.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} hostname - The hostname to resolve.
|
|
47
|
+
* @param {0 | 4 | 6} [family=4] - The address family to use (0 for any, 4 for IPv4, 6 for IPv6). Default is 4.
|
|
48
|
+
* @returns {Promise<string | null>} - A promise that resolves to the IP address or null if not found.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* This function uses DNS lookup to resolve the hostname, which can take some time to complete.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveHostname(hostname: string, family?: 0 | 4 | 6): Promise<string | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves the version of an npm package from the npm registry.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} packageName - The name of the npm package.
|
|
58
|
+
* @param {string} [tag='latest'] - The tag of the package version to retrieve (default is 'latest').
|
|
59
|
+
* @param {number} [timeout=5000] - The timeout duration in milliseconds (default is 5000ms).
|
|
60
|
+
* @returns {Promise<string>} A promise that resolves to the version string of the package.
|
|
61
|
+
* @throws {Error} If the request fails or the tag is not found.
|
|
62
|
+
*/
|
|
63
|
+
export declare function getNpmPackageVersion(packageName: string, tag?: string, timeout?: number): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves the path to the global Node.js modules directory.
|
|
66
|
+
* @returns A promise that resolves to the path of the global Node.js modules directory.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getGlobalNodeModules(): Promise<string>;
|
|
69
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/utils/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAWH;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAmB5D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAmB5D;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAkBlD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,UAAO,GAAG,IAAI,CAehD;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,CAAC,GAAG,CAAC,GAAG,CAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASrG;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,SAAW,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA+ChH;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAW5D"}
|
package/dist/utils/network.js
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the network function.
|
|
3
|
+
*
|
|
4
|
+
* @file network.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-02-17
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
// Node.js modules
|
|
1
24
|
import os from 'node:os';
|
|
25
|
+
// AnsiLogger module
|
|
2
26
|
import { AnsiLogger, idn, rs } from '../logger/export.js';
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the IPv4 address of the first non-internal network interface.
|
|
29
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
30
|
+
*/
|
|
3
31
|
export function getIpv4InterfaceAddress() {
|
|
4
32
|
let ipv4Address;
|
|
5
33
|
const networkInterfaces = os.networkInterfaces();
|
|
34
|
+
// console.log('Available Network Interfaces:', networkInterfaces);
|
|
6
35
|
for (const interfaceDetails of Object.values(networkInterfaces)) {
|
|
7
36
|
if (!interfaceDetails) {
|
|
8
37
|
break;
|
|
@@ -16,11 +45,17 @@ export function getIpv4InterfaceAddress() {
|
|
|
16
45
|
break;
|
|
17
46
|
}
|
|
18
47
|
}
|
|
48
|
+
// console.log('Selected Network Interfaces:', ipv4Address);
|
|
19
49
|
return ipv4Address;
|
|
20
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the IPv6 address of the first non-internal network interface.
|
|
53
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
54
|
+
*/
|
|
21
55
|
export function getIpv6InterfaceAddress() {
|
|
22
56
|
let ipv6Address;
|
|
23
57
|
const networkInterfaces = os.networkInterfaces();
|
|
58
|
+
// console.log('Available Network Interfaces:', networkInterfaces);
|
|
24
59
|
for (const interfaceDetails of Object.values(networkInterfaces)) {
|
|
25
60
|
if (!interfaceDetails) {
|
|
26
61
|
break;
|
|
@@ -34,11 +69,17 @@ export function getIpv6InterfaceAddress() {
|
|
|
34
69
|
break;
|
|
35
70
|
}
|
|
36
71
|
}
|
|
72
|
+
// console.log('Selected Network Interfaces:', ipv6Address);
|
|
37
73
|
return ipv6Address;
|
|
38
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the mac address of the first non-internal network interface.
|
|
77
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
78
|
+
*/
|
|
39
79
|
export function getMacAddress() {
|
|
40
80
|
let macAddress;
|
|
41
81
|
const networkInterfaces = os.networkInterfaces();
|
|
82
|
+
// console.log('Available Network Interfaces:', networkInterfaces);
|
|
42
83
|
for (const interfaceDetails of Object.values(networkInterfaces)) {
|
|
43
84
|
if (!interfaceDetails) {
|
|
44
85
|
break;
|
|
@@ -54,9 +95,13 @@ export function getMacAddress() {
|
|
|
54
95
|
}
|
|
55
96
|
return macAddress;
|
|
56
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Logs the available network interfaces and their details.
|
|
100
|
+
* @param {boolean} log - Whether to enable logging of network interface details.
|
|
101
|
+
*/
|
|
57
102
|
export function logInterfaces(debug = true) {
|
|
58
|
-
const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4
|
|
59
|
-
log.logLevel = "info"
|
|
103
|
+
const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
104
|
+
log.logLevel = "info" /* LogLevel.INFO */;
|
|
60
105
|
log.logName = 'LogInterfaces';
|
|
61
106
|
const networkInterfaces = os.networkInterfaces();
|
|
62
107
|
if (debug)
|
|
@@ -72,16 +117,36 @@ export function logInterfaces(debug = true) {
|
|
|
72
117
|
}
|
|
73
118
|
}
|
|
74
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Resolves the given hostname to an IP address.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} hostname - The hostname to resolve.
|
|
124
|
+
* @param {0 | 4 | 6} [family=4] - The address family to use (0 for any, 4 for IPv4, 6 for IPv6). Default is 4.
|
|
125
|
+
* @returns {Promise<string | null>} - A promise that resolves to the IP address or null if not found.
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* This function uses DNS lookup to resolve the hostname, which can take some time to complete.
|
|
129
|
+
*/
|
|
75
130
|
export async function resolveHostname(hostname, family = 4) {
|
|
76
131
|
const dns = await import('node:dns');
|
|
77
132
|
try {
|
|
78
|
-
const addresses = await dns.promises.lookup(hostname.toLowerCase()
|
|
133
|
+
const addresses = await dns.promises.lookup(hostname.toLowerCase() /* + '.local'*/, { family });
|
|
79
134
|
return addresses.address;
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
80
136
|
}
|
|
81
137
|
catch (error) {
|
|
82
138
|
return null;
|
|
83
139
|
}
|
|
84
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Retrieves the version of an npm package from the npm registry.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} packageName - The name of the npm package.
|
|
145
|
+
* @param {string} [tag='latest'] - The tag of the package version to retrieve (default is 'latest').
|
|
146
|
+
* @param {number} [timeout=5000] - The timeout duration in milliseconds (default is 5000ms).
|
|
147
|
+
* @returns {Promise<string>} A promise that resolves to the version string of the package.
|
|
148
|
+
* @throws {Error} If the request fails or the tag is not found.
|
|
149
|
+
*/
|
|
85
150
|
export async function getNpmPackageVersion(packageName, tag = 'latest', timeout = 10000) {
|
|
86
151
|
const https = await import('https');
|
|
87
152
|
return new Promise((resolve, reject) => {
|
|
@@ -95,8 +160,8 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
|
|
|
95
160
|
let data = '';
|
|
96
161
|
if (res.statusCode !== 200) {
|
|
97
162
|
clearTimeout(timeoutId);
|
|
98
|
-
res.resume();
|
|
99
|
-
req.destroy();
|
|
163
|
+
res.resume(); // Discard response data to close the socket properly
|
|
164
|
+
req.destroy(); // Forcefully close the request
|
|
100
165
|
reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
|
|
101
166
|
return;
|
|
102
167
|
}
|
|
@@ -107,6 +172,7 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
|
|
|
107
172
|
clearTimeout(timeoutId);
|
|
108
173
|
try {
|
|
109
174
|
const jsonData = JSON.parse(data);
|
|
175
|
+
// console.log(`Package ${packageName} tag ${tag}`, jsonData);
|
|
110
176
|
const version = jsonData['dist-tags']?.[tag];
|
|
111
177
|
if (version) {
|
|
112
178
|
resolve(version);
|
|
@@ -126,6 +192,10 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
|
|
|
126
192
|
});
|
|
127
193
|
});
|
|
128
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Retrieves the path to the global Node.js modules directory.
|
|
197
|
+
* @returns A promise that resolves to the path of the global Node.js modules directory.
|
|
198
|
+
*/
|
|
129
199
|
export async function getGlobalNodeModules() {
|
|
130
200
|
const { exec } = await import('node:child_process');
|
|
131
201
|
return new Promise((resolve, reject) => {
|
|
@@ -139,3 +209,4 @@ export async function getGlobalNodeModules() {
|
|
|
139
209
|
});
|
|
140
210
|
});
|
|
141
211
|
}
|
|
212
|
+
//# sourceMappingURL=network.js.map
|