@matterbridge/core 3.7.2 → 3.7.3-dev-20260403-2f4f273

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.
@@ -9,6 +9,7 @@ export declare class BackendExpress {
9
9
  private backend;
10
10
  private matterbridge;
11
11
  private readonly server;
12
+ private fileLimiter;
12
13
  constructor(matterbridge: SharedMatterbridge, backend: Frontend);
13
14
  destroy(): void;
14
15
  private broadcastMsgHandler;
@@ -5,7 +5,9 @@ import { MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_BACKUP_FILE, MATTE
5
5
  import { hasParameter } from '@matterbridge/utils/cli';
6
6
  import { getErrorMessage } from '@matterbridge/utils/error';
7
7
  import { formatBytes } from '@matterbridge/utils/format';
8
+ import escapeHtml from 'escape-html';
8
9
  import express from 'express';
10
+ import rateLimit from 'express-rate-limit';
9
11
  import multer from 'multer';
10
12
  import { AnsiLogger, er, nf } from 'node-ansi-logger';
11
13
  if (hasParameter('loader'))
@@ -18,6 +20,10 @@ export class BackendExpress {
18
20
  backend;
19
21
  matterbridge;
20
22
  server;
23
+ fileLimiter = rateLimit({
24
+ windowMs: 60 * 1000,
25
+ max: 20,
26
+ });
21
27
  constructor(matterbridge, backend) {
22
28
  this.debug = hasParameter('debug') || hasParameter('verbose') || hasParameter('debug-frontend') || hasParameter('verbose-frontend');
23
29
  this.verbose = hasParameter('verbose') || hasParameter('verbose-frontend');
@@ -157,7 +163,7 @@ export class BackendExpress {
157
163
  res.status(500).send('Error reading matterbridge log file. Please enable the matterbridge log on file in the settings.');
158
164
  }
159
165
  });
160
- this.expressApp.get('/api/download-mblog', async (req, res) => {
166
+ this.expressApp.get('/api/download-mblog', this.fileLimiter, async (req, res) => {
161
167
  this.log.debug(`The frontend sent /api/download-mblog ${path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_LOGGER_FILE)}`);
162
168
  if (!this.validateReq(req, res))
163
169
  return;
@@ -197,7 +203,7 @@ export class BackendExpress {
197
203
  res.status(500).send('Error reading matter log file. Please enable the matter log on file in the settings.');
198
204
  }
199
205
  });
200
- this.expressApp.get('/api/download-mjlog', async (req, res) => {
206
+ this.expressApp.get('/api/download-mjlog', this.fileLimiter, async (req, res) => {
201
207
  this.log.debug(`The frontend sent /api/download-mjlog ${path.join(this.matterbridge.matterbridgeDirectory, MATTER_LOGGER_FILE)}`);
202
208
  if (!this.validateReq(req, res))
203
209
  return;
@@ -238,7 +244,7 @@ export class BackendExpress {
238
244
  res.status(500).send('Error reading diagnostic log file.');
239
245
  }
240
246
  });
241
- this.expressApp.get('/api/download-diagnostic', async (req, res) => {
247
+ this.expressApp.get('/api/download-diagnostic', this.fileLimiter, async (req, res) => {
242
248
  this.log.debug(`The frontend sent /api/download-diagnostic`);
243
249
  if (!this.validateReq(req, res))
244
250
  return;
@@ -278,7 +284,7 @@ export class BackendExpress {
278
284
  res.status(500).send('Error reading history file.');
279
285
  }
280
286
  });
281
- this.expressApp.get('/api/downloadhistory', async (req, res) => {
287
+ this.expressApp.get('/api/downloadhistory', this.fileLimiter, async (req, res) => {
282
288
  this.log.debug(`The frontend sent /api/downloadhistory`);
283
289
  if (!this.validateReq(req, res))
284
290
  return;
@@ -303,7 +309,7 @@ export class BackendExpress {
303
309
  res.status(500).send('Error reading history file.');
304
310
  }
305
311
  });
306
- this.expressApp.get('/api/download-backup', async (req, res) => {
312
+ this.expressApp.get('/api/download-backup', this.fileLimiter, async (req, res) => {
307
313
  this.log.debug('The frontend sent /api/download-backup');
308
314
  if (!this.validateReq(req, res))
309
315
  return;
@@ -318,7 +324,7 @@ export class BackendExpress {
318
324
  }
319
325
  });
320
326
  });
321
- this.expressApp.get('/api/download-mbstorage', async (req, res) => {
327
+ this.expressApp.get('/api/download-mbstorage', this.fileLimiter, async (req, res) => {
322
328
  this.log.debug('The frontend sent /api/download-mbstorage');
323
329
  if (!this.validateReq(req, res))
324
330
  return;
@@ -333,7 +339,7 @@ export class BackendExpress {
333
339
  }
334
340
  });
335
341
  });
336
- this.expressApp.get('/api/download-mjstorage', async (req, res) => {
342
+ this.expressApp.get('/api/download-mjstorage', this.fileLimiter, async (req, res) => {
337
343
  this.log.debug('The frontend sent /api/download-mjstorage');
338
344
  if (!this.validateReq(req, res))
339
345
  return;
@@ -348,7 +354,7 @@ export class BackendExpress {
348
354
  }
349
355
  });
350
356
  });
351
- this.expressApp.get('/api/download-pluginstorage', async (req, res) => {
357
+ this.expressApp.get('/api/download-pluginstorage', this.fileLimiter, async (req, res) => {
352
358
  this.log.debug('The frontend sent /api/download-pluginstorage');
353
359
  if (!this.validateReq(req, res))
354
360
  return;
@@ -363,7 +369,7 @@ export class BackendExpress {
363
369
  }
364
370
  });
365
371
  });
366
- this.expressApp.get('/api/download-pluginconfig', async (req, res) => {
372
+ this.expressApp.get('/api/download-pluginconfig', this.fileLimiter, async (req, res) => {
367
373
  this.log.debug('The frontend sent /api/download-pluginconfig');
368
374
  if (!this.validateReq(req, res))
369
375
  return;
@@ -378,7 +384,7 @@ export class BackendExpress {
378
384
  }
379
385
  });
380
386
  });
381
- this.expressApp.post('/api/uploadpackage', upload.single('file'), async (req, res) => {
387
+ this.expressApp.post('/api/uploadpackage', this.fileLimiter, upload.single('file'), async (req, res) => {
382
388
  this.log.debug('The frontend sent /api/uploadpackage');
383
389
  if (!this.validateReq(req, res))
384
390
  return;
@@ -412,13 +418,13 @@ export class BackendExpress {
412
418
  },
413
419
  });
414
420
  }
415
- res.send(`File ${filename} uploaded successfully`);
421
+ res.send(`File ${escapeHtml(filename)} uploaded successfully`);
416
422
  }
417
423
  catch (err) {
418
424
  this.log.error(`Error uploading or installing plugin package file ${plg}${filename}${er}:`, err);
419
425
  this.backend.wssSendCloseSnackbarMessage(`Installing package ${filename}...`);
420
426
  this.backend.wssSendSnackbarMessage(`Error uploading or installing plugin package ${filename}`, 10, 'error');
421
- res.status(500).send(`Error uploading or installing plugin package ${filename}`);
427
+ res.status(500).send(`Error uploading or installing plugin package ${escapeHtml(filename)}`);
422
428
  }
423
429
  });
424
430
  this.expressApp.use((req, res) => {
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ export let instance;
12
12
  export const tracker = new Tracker('Cli', false, false);
13
13
  export const inspector = new Inspector('Cli', false, false);
14
14
  const manager = new ThreadsManager();
15
- const colorEnabled = Boolean(process.stdout.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb' && process.env.FORCE_COLOR !== '0' && !hasParameter('no-ansi'));
15
+ const colorEnabled = Boolean(!process.env.NO_COLOR && process.env.TERM !== 'dumb' && process.env.FORCE_COLOR !== '0' && !hasParameter('no-ansi'));
16
16
  if (!colorEnabled)
17
17
  process.env.NO_COLOR = '1';
18
18
  const log = new AnsiLogger({ logName: 'Cli', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
@@ -255,7 +255,7 @@ export async function createMatterbridgeEnvironment(name, createOnly = false) {
255
255
  matterbridge = await Matterbridge.loadInstance(false);
256
256
  expect(matterbridge).toBeDefined();
257
257
  expect(matterbridge).toBeInstanceOf(Matterbridge);
258
- matterbridge.matterbridgeVersion = '3.7.2';
258
+ matterbridge.matterbridgeVersion = '3.7.3';
259
259
  matterbridge.bridgeMode = 'bridge';
260
260
  matterbridge.rootDirectory = path.join(HOMEDIR);
261
261
  matterbridge.homeDirectory = path.join(HOMEDIR);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.7.2",
3
+ "version": "3.7.3-dev-20260403-2f4f273",
4
4
  "description": "Matterbridge core library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -126,11 +126,13 @@
126
126
  ],
127
127
  "dependencies": {
128
128
  "@matter/main": "0.16.10",
129
- "@matterbridge/dgram": "3.7.2",
130
- "@matterbridge/thread": "3.7.2",
131
- "@matterbridge/types": "3.7.2",
132
- "@matterbridge/utils": "3.7.2",
129
+ "@matterbridge/dgram": "3.7.3-dev-20260403-2f4f273",
130
+ "@matterbridge/thread": "3.7.3-dev-20260403-2f4f273",
131
+ "@matterbridge/types": "3.7.3-dev-20260403-2f4f273",
132
+ "@matterbridge/utils": "3.7.3-dev-20260403-2f4f273",
133
+ "escape-html": "1.0.3",
133
134
  "express": "5.2.1",
135
+ "express-rate-limit": "8.3.2",
134
136
  "multer": "2.1.1",
135
137
  "node-ansi-logger": "3.2.1-dev-20260327-7069fd7",
136
138
  "node-persist-manager": "2.0.2-dev-20260327-af13e76",