@matterbridge/core 3.10.13-dev-20261008-55d98fb → 3.10.13-dev-20261009-7fc645a
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/dist/backend.js +1 -0
- package/dist/backendExpress.js +5 -0
- package/dist/backendWsServer.js +16 -0
- package/dist/cli.js +1 -1
- package/dist/cliEmitter.d.ts +0 -4
- package/dist/cliEmitter.js +0 -8
- package/dist/frontend.js +8 -7
- package/package.json +5 -5
package/dist/backend.js
CHANGED
|
@@ -182,6 +182,7 @@ export class Backend extends EventEmitter {
|
|
|
182
182
|
try {
|
|
183
183
|
const upgrade = (req.headers.upgrade || '').toLowerCase();
|
|
184
184
|
if (upgrade !== 'websocket') {
|
|
185
|
+
this.log.error(`WebSocket upgrade error: Invalid upgrade header ${req.headers.upgrade}`);
|
|
185
186
|
socket.write('HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n');
|
|
186
187
|
socket.destroy();
|
|
187
188
|
return;
|
package/dist/backendExpress.js
CHANGED
|
@@ -82,6 +82,11 @@ export class BackendExpress {
|
|
|
82
82
|
this.expressApp.post('/api/login', express.json(), (req, res) => {
|
|
83
83
|
const { password } = req.body;
|
|
84
84
|
this.log.debug(`The frontend sent /api/login with password ${password ? '[redacted]' : '(empty)'}`);
|
|
85
|
+
if (this.backend.storedPassword === undefined) {
|
|
86
|
+
this.log.error('/api/login stored password not loaded');
|
|
87
|
+
res.status(500).json({ valid: false });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
85
90
|
if (this.backend.storedPassword === '' || password === this.backend.storedPassword) {
|
|
86
91
|
this.log.debug('/api/login password valid');
|
|
87
92
|
res.json({ valid: true });
|
package/dist/backendWsServer.js
CHANGED
|
@@ -163,6 +163,22 @@ export class BackendWsServer {
|
|
|
163
163
|
if (data.method === 'ping') {
|
|
164
164
|
sendResponse({ id: data.id, method: 'pong', src: 'Matterbridge', dst: data.src, success: true, response: 'pong' });
|
|
165
165
|
}
|
|
166
|
+
else if (data.method === '/api/login') {
|
|
167
|
+
const storedPassword = this.backend.storedPassword;
|
|
168
|
+
if (storedPassword === undefined) {
|
|
169
|
+
this.log.error('Login stored password not loaded');
|
|
170
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Internal error: stored password not loaded' });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (storedPassword === '' || storedPassword === data.params.password) {
|
|
174
|
+
this.log.debug('Login password valid');
|
|
175
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
this.log.debug('Error wrong password');
|
|
179
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong password' });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
166
182
|
else if (data.method === '/api/restart') {
|
|
167
183
|
this.wssSendSnackbarMessage('Restarting matterbridge...', 0);
|
|
168
184
|
await this.server.fetch({ type: 'matterbridge_restart', src: 'frontend', dst: 'matterbridge', params: undefined });
|
package/dist/cli.js
CHANGED
|
@@ -175,7 +175,7 @@ function help() {
|
|
|
175
175
|
--novirtual: disable the creation of the virtual devices Restart, Update and Reboot Matterbridge
|
|
176
176
|
--root-power-source: add a Power Source cluster for the mains power feed on the Root endpoint
|
|
177
177
|
--ssl: enable SSL for the frontend and the WebSocketServer (the server will use the certificates and switch to https)
|
|
178
|
-
--mtls: enable mTLS for the frontend and the WebSocketServer (both server and client will use and require the certificates and switch to https)
|
|
178
|
+
--mtls: enable mTLS for the frontend and the WebSocketServer (both server and client will use and require the certificates and switch to https); it also enables https, so --ssl --tls is not needed
|
|
179
179
|
--vendorId: override the default vendorId 0xfff1
|
|
180
180
|
--vendorName: override the default vendorName "Matterbridge"
|
|
181
181
|
--productId: override the default productId 0x8000
|
package/dist/cliEmitter.d.ts
CHANGED
|
@@ -7,8 +7,4 @@ interface CliEvents {
|
|
|
7
7
|
ready: [];
|
|
8
8
|
}
|
|
9
9
|
export declare const cliEmitter: EventEmitter<CliEvents>;
|
|
10
|
-
export declare let lastOsCpuUsage: number;
|
|
11
|
-
export declare let lastProcessCpuUsage: number;
|
|
12
|
-
export declare function setLastOsCpuUsage(val: number): void;
|
|
13
|
-
export declare function setLastProcessCpuUsage(val: number): void;
|
|
14
10
|
export {};
|
package/dist/cliEmitter.js
CHANGED
|
@@ -2,11 +2,3 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import { logModuleLoaded } from '@matterbridge/utils/loader';
|
|
3
3
|
logModuleLoaded('CliEmitter');
|
|
4
4
|
export const cliEmitter = new EventEmitter();
|
|
5
|
-
export let lastOsCpuUsage = 0;
|
|
6
|
-
export let lastProcessCpuUsage = 0;
|
|
7
|
-
export function setLastOsCpuUsage(val) {
|
|
8
|
-
lastOsCpuUsage = val;
|
|
9
|
-
}
|
|
10
|
-
export function setLastProcessCpuUsage(val) {
|
|
11
|
-
lastProcessCpuUsage = val;
|
|
12
|
-
}
|
package/dist/frontend.js
CHANGED
|
@@ -8,7 +8,7 @@ import { FabricIndex } from '@matter/types/datatype';
|
|
|
8
8
|
import { BroadcastServer } from '@matterbridge/thread/server';
|
|
9
9
|
import { MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_DIAGNOSTIC_FILE, MATTERBRIDGE_HISTORY_FILE, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg, } from '@matterbridge/types';
|
|
10
10
|
import { isBun, memoryFootprint } from '@matterbridge/utils/bun';
|
|
11
|
-
import { getParameter, hasParameter } from '@matterbridge/utils/cli';
|
|
11
|
+
import { getParameter, hasAnyParameter, hasParameter } from '@matterbridge/utils/cli';
|
|
12
12
|
import { writeDiagnostic } from '@matterbridge/utils/diagnostic';
|
|
13
13
|
import { getErrorMessage, inspectError, logError } from '@matterbridge/utils/error';
|
|
14
14
|
import { formatBytes, formatPercent, formatUptime } from '@matterbridge/utils/format';
|
|
@@ -16,7 +16,7 @@ import { logModuleLoaded } from '@matterbridge/utils/loader';
|
|
|
16
16
|
import { isValidArray, isValidBoolean, isValidNumber, isValidObject, isValidString } from '@matterbridge/utils/validate';
|
|
17
17
|
import { fireAndForget, wait, withTimeout } from '@matterbridge/utils/wait';
|
|
18
18
|
import { AnsiLogger, bgHex, CYAN, db, debugStringify, er, GREEN, nf, nt, rs, stringify, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from 'node-ansi-logger';
|
|
19
|
-
import { cliEmitter
|
|
19
|
+
import { cliEmitter } from './cliEmitter.js';
|
|
20
20
|
import { generateHistoryPage } from './cliHistory.js';
|
|
21
21
|
import { capitalizeFirstLetter } from './matterbridgeEndpointHelpers.js';
|
|
22
22
|
import { deleteAdvertisingNode, getBatteryLevel, getClusterTextFromDevice, getPowerSource, getReachability, getServerNodeData, setAdvertisingNode } from './matterNodeHelpers.js';
|
|
@@ -209,7 +209,8 @@ export class Frontend extends EventEmitter {
|
|
|
209
209
|
async start(port = 8283) {
|
|
210
210
|
this.port = port;
|
|
211
211
|
this.storedPassword = await this.matterbridge.nodeContext?.get('password', '');
|
|
212
|
-
|
|
212
|
+
const secure = hasAnyParameter('ssl', 'tls', 'mtls');
|
|
213
|
+
this.log.debug(`Initializing the frontend ${secure ? 'https' : 'http'} server on port ${YELLOW}${this.port}${db}`);
|
|
213
214
|
const multer = await import('multer');
|
|
214
215
|
const uploadDir = path.join(this.matterbridge.matterbridgeDirectory, 'uploads');
|
|
215
216
|
const upload = multer.default({ dest: uploadDir });
|
|
@@ -219,7 +220,7 @@ export class Frontend extends EventEmitter {
|
|
|
219
220
|
this.log.debug(`Creating WebSocketServer...`);
|
|
220
221
|
const ws = await import('ws');
|
|
221
222
|
this.webSocketServer = new ws.WebSocketServer({ noServer: true });
|
|
222
|
-
this.emit('websocket_server_listening',
|
|
223
|
+
this.emit('websocket_server_listening', secure ? 'wss' : 'ws');
|
|
223
224
|
this.webSocketServer.on('connection', (ws, request) => {
|
|
224
225
|
const clientIp = request.socket.remoteAddress;
|
|
225
226
|
let callbackLogLevel = "notice";
|
|
@@ -264,7 +265,7 @@ export class Frontend extends EventEmitter {
|
|
|
264
265
|
this.webSocketServer.on('error', (ws, error) => {
|
|
265
266
|
this.log.error(`WebSocketServer error: ${error}`);
|
|
266
267
|
});
|
|
267
|
-
if (!
|
|
268
|
+
if (!secure) {
|
|
268
269
|
const http = await import('node:http');
|
|
269
270
|
try {
|
|
270
271
|
this.log.debug(`Creating HTTP server...`);
|
|
@@ -929,8 +930,8 @@ export class Frontend extends EventEmitter {
|
|
|
929
930
|
this.matterbridge.systemInformation.freeMemory = formatBytes(os.freemem());
|
|
930
931
|
this.matterbridge.systemInformation.systemUptime = formatUptime(os.uptime());
|
|
931
932
|
this.matterbridge.systemInformation.processUptime = formatUptime(Math.floor(process.uptime()));
|
|
932
|
-
this.matterbridge.systemInformation.cpuUsage = formatPercent(
|
|
933
|
-
this.matterbridge.systemInformation.processCpuUsage = formatPercent(
|
|
933
|
+
this.matterbridge.systemInformation.cpuUsage = formatPercent(0);
|
|
934
|
+
this.matterbridge.systemInformation.processCpuUsage = formatPercent(0);
|
|
934
935
|
this.matterbridge.systemInformation.rss = formatBytes(memoryFootprint());
|
|
935
936
|
this.matterbridge.systemInformation.heapTotal = formatBytes(process.memoryUsage().heapTotal);
|
|
936
937
|
this.matterbridge.systemInformation.heapUsed = formatBytes(process.memoryUsage().heapUsed);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/core",
|
|
3
|
-
"version": "3.10.13-dev-
|
|
3
|
+
"version": "3.10.13-dev-20261009-7fc645a",
|
|
4
4
|
"description": "Matterbridge core library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -136,10 +136,10 @@
|
|
|
136
136
|
},
|
|
137
137
|
"dependencies": {
|
|
138
138
|
"@matter/main": "0.17.9",
|
|
139
|
-
"@matterbridge/dgram": "3.10.13-dev-
|
|
140
|
-
"@matterbridge/thread": "3.10.13-dev-
|
|
141
|
-
"@matterbridge/types": "3.10.13-dev-
|
|
142
|
-
"@matterbridge/utils": "3.10.13-dev-
|
|
139
|
+
"@matterbridge/dgram": "3.10.13-dev-20261009-7fc645a",
|
|
140
|
+
"@matterbridge/thread": "3.10.13-dev-20261009-7fc645a",
|
|
141
|
+
"@matterbridge/types": "3.10.13-dev-20261009-7fc645a",
|
|
142
|
+
"@matterbridge/utils": "3.10.13-dev-20261009-7fc645a",
|
|
143
143
|
"escape-html": "1.0.3",
|
|
144
144
|
"express": "5.2.1",
|
|
145
145
|
"express-rate-limit": "8.7.0",
|