Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mashroom/mashroom

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mashroom/mashroom - npm Package Compare versions

Comparing version 1.7.10 to 1.8.0

dist/modules.d.js

4

dist/config/mashroom_default_config.js

@@ -15,5 +15,9 @@ "use strict";

port: 5050,
httpsPort: null,
tlsOptions: null,
enableHttp2: false,
xPowerByHeader: 'Mashroom Server',
serverRootFolder: '.',
tmpFolder: _os.default.tmpdir(),
externalPluginConfigFileNames: ['mashroom'],
pluginPackageFolders: [{

@@ -20,0 +24,0 @@ path: './node_modules/@mashroom'

32

dist/context/mashroom_server_context_factory.js

@@ -14,4 +14,2 @@ "use strict";

var _http = _interopRequireDefault(require("http"));
var _MashroomPluginContextHolder = _interopRequireDefault(require("./MashroomPluginContextHolder"));

@@ -61,2 +59,4 @@

var _MashroomHttpUpgradeService = _interopRequireDefault(require("../services/MashroomHttpUpgradeService"));
var _XPoweredByHeaderMiddleware = _interopRequireDefault(require("../server/XPoweredByHeaderMiddleware"));

@@ -88,5 +88,5 @@

const scanner = new _MashroomPluginPackageScanner.default(serverConfig, loggerFactory);
const builder = devMode ? createBuilder(serverConfig, loggerFactory, logger) : null;
const builder = devMode ? createBuilder(serverConfig, loggerFactory) : null;
const pluginPackageFactory = (path, connector) => new _MashroomPluginPackage.default(path, serverConfig.ignorePlugins, connector, isPackageInDevMode(path) ? builder : null, loggerFactory);
const pluginPackageFactory = (path, connector) => new _MashroomPluginPackage.default(path, serverConfig.ignorePlugins, serverConfig.externalPluginConfigFileNames, connector, isPackageInDevMode(path) ? builder : null, loggerFactory);

@@ -101,12 +101,11 @@ const pluginFactory = (pluginDefinition, pluginPackage, connector) => new _MashroomPlugin.default(pluginDefinition, pluginPackage, connector, loggerFactory);

setExpressConfig(expressApp, devMode, logger);
const httpServer = _http.default.createServer(expressApp);
const middlewarePluginDelegate = new _MiddlewarePluginDelegate.default();
addDefaultMiddleware(expressApp, pluginContextHolder, middlewarePluginDelegate);
addDefaultPluginLoaders(pluginRegistry, expressApp, httpServer, serviceRegistry, middlewarePluginDelegate, loggerFactory, pluginContextHolder);
addCoreServices(serviceRegistry, pluginRegistry, middlewarePluginDelegate, loggerFactory);
addDefaultPluginLoaders(pluginRegistry, expressApp, serviceRegistry, middlewarePluginDelegate, loggerFactory, pluginContextHolder);
const {
httpUpgradeService
} = addCoreServices(serviceRegistry, pluginRegistry, middlewarePluginDelegate, loggerFactory, pluginContextHolder);
const serverInfo = createServerInfo(devMode);
const globalNodeErrorHandler = new _GlobalNodeErrorHandler.default(loggerFactory);
const server = new _MashroomServer.default(expressApp, httpServer, serverInfo, serverConfig, scanner, globalNodeErrorHandler, loggerFactory);
const server = new _MashroomServer.default(expressApp, serverInfo, serverConfig, scanner, globalNodeErrorHandler, httpUpgradeService, loggerFactory);
const serverContext = {

@@ -148,10 +147,10 @@ serverInfo,

const createBuilder = (config, loggerFactory, logger) => {
const createBuilder = (config, loggerFactory) => {
return new _MashroomPluginPackageBuilder.default(config, loggerFactory);
};
const addDefaultPluginLoaders = (pluginRegistry, expressApplication, httpServer, serviceRegistry, middlewarePluginDelegate, loggerFactory, pluginContextHolder) => {
const addDefaultPluginLoaders = (pluginRegistry, expressApplication, serviceRegistry, middlewarePluginDelegate, loggerFactory, pluginContextHolder) => {
pluginRegistry.registerPluginLoader('plugin-loader', new _MashroomPluginLoaderLoader.default(pluginRegistry, loggerFactory));
pluginRegistry.registerPluginLoader('api', new _MashroomApiPluginLoader.default(expressApplication, loggerFactory));
pluginRegistry.registerPluginLoader('web-app', new _MashroomWebAppPluginLoader.default(expressApplication, httpServer, loggerFactory, pluginContextHolder));
pluginRegistry.registerPluginLoader('web-app', new _MashroomWebAppPluginLoader.default(expressApplication, loggerFactory, pluginContextHolder));
pluginRegistry.registerPluginLoader('static', new _MashroomStaticDocumentsPluginLoader.default(expressApplication, loggerFactory));

@@ -163,10 +162,13 @@ pluginRegistry.registerPluginLoader('middleware', new _MashroomMiddlewarePluginLoader.default(middlewarePluginDelegate, loggerFactory));

const addCoreServices = (serviceNamespacesRegistry, pluginRegistry, middlewareDelegate, loggerFactory) => {
const addCoreServices = (serviceNamespacesRegistry, pluginRegistry, middlewareDelegate, loggerFactory, pluginContextHolder) => {
const pluginService = new _MashroomPluginService.default(pluginRegistry, loggerFactory);
const middlewareStackService = new _MashroomMiddlewareStackService.default(middlewareDelegate, loggerFactory);
const httpUpgradeService = new _MashroomHttpUpgradeService.default(pluginContextHolder);
const coreService = {
pluginService,
middlewareStackService
middlewareStackService,
httpUpgradeService
};
serviceNamespacesRegistry.registerServices('core', coreService);
return coreService;
};

@@ -173,0 +175,0 @@

@@ -18,3 +18,3 @@ "use strict";

var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
var _ansiRegex = _interopRequireDefault(require("ansi-regex"));

@@ -31,3 +31,2 @@ var _lucyDirsum = _interopRequireDefault(require("lucy-dirsum"));

// @ts-ignore
const readFile = (0, _util.promisify)(_fs.default.readFile);

@@ -219,3 +218,3 @@ const writeFile = (0, _util.promisify)(_fs.default.writeFile);

const errorMessage = (0, _stripAnsi.default)(error.toString());
const errorMessage = error.toString().replace((0, _ansiRegex.default)(), '');

@@ -222,0 +221,0 @@ if (buildInfo) {

@@ -8,4 +8,2 @@ "use strict";

var _request_plugin_context = _interopRequireDefault(require("../../context/request_plugin_context"));
var _ExpressRequestHandlerBasePluginLoader = _interopRequireDefault(require("./ExpressRequestHandlerBasePluginLoader"));

@@ -16,3 +14,3 @@

class MashroomWebAppPluginLoader extends _ExpressRequestHandlerBasePluginLoader.default {
constructor(expressApplication, httpServer, loggerFactory, _pluginContextHolder) {
constructor(expressApplication, loggerFactory, _pluginContextHolder) {
super(expressApplication, loggerFactory);

@@ -22,6 +20,2 @@ this._pluginContextHolder = _pluginContextHolder;

this._upgradeHandlers = [];
const upgradeHandler = this._upgradeHandler.bind(this);
httpServer.on('upgrade', upgradeHandler);
}

@@ -36,7 +30,16 @@

const bootstrapResult = await webAppBootstrap(plugin.name, pluginConfig, contextHolder);
const webapp = bootstrapResult.expressApp ? bootstrapResult.expressApp : bootstrapResult;
const upgradeHandler = bootstrapResult.upgradeHandler ? bootstrapResult.upgradeHandler : null;
const webapp = bootstrapResult.expressApp || bootstrapResult;
const upgradeHandler = bootstrapResult.upgradeHandler || null;
if (upgradeHandler) {
this._installUpgradeHandler(plugin, pluginConfig, upgradeHandler);
if (pluginConfig.path && pluginConfig.path !== '/') {
this._upgradeHandlers.push({
pluginName: plugin.name,
upgradeHandler
});
this.getHttpUpgradeService().registerUpgradeHandler(upgradeHandler, `^${pluginConfig.path}`);
} else {
this._logger2.error(`Ignoring upgrade handler of webapp ${plugin.name} because a valid path is missing in the config`);
}
}

@@ -60,46 +63,16 @@

beforeUnload(plugin) {
this._uninstallUpgradeHandler(plugin);
}
const handler = this._upgradeHandlers.find(uh => uh.pluginName === plugin.name);
_upgradeHandler(req, socket, head) {
const path = req.url;
const entry = path && this._upgradeHandlers.find(ul => path.startsWith(ul.path));
if (entry) {
const reqWithContext = { ...req,
pluginContext: (0, _request_plugin_context.default)(req, this._pluginContextHolder)
};
entry.handler(reqWithContext, socket, head);
} else {
this._logger2.warn(`No upgrade handler found for path ${path}. Ignoring request.`);
socket.end(`HTTP/1.1 403 Forbidden\r\n\r\n`, 'ascii');
if (handler) {
this.getHttpUpgradeService().unregisterUpgradeHandler(handler.upgradeHandler);
this._upgradeHandlers = this._upgradeHandlers.filter(uh => uh.pluginName !== plugin.name);
}
}
_installUpgradeHandler(plugin, pluginConfig, handler) {
this._uninstallUpgradeHandler(plugin);
if (!pluginConfig.path || pluginConfig.path === '/') {
this._logger2.error(`Ignoring upgrade handler of webapp ${plugin.name} because a valid path is missing in the config`);
return;
}
this._logger2.info(`Installing HTTP upgrade handler for path: ${pluginConfig.path}`);
this._upgradeHandlers.push({
pluginName: plugin.name,
path: pluginConfig.path,
handler
});
getHttpUpgradeService() {
return this._pluginContextHolder.getPluginContext().services.core.httpUpgradeService;
}
_uninstallUpgradeHandler(plugin) {
this._upgradeHandlers = this._upgradeHandlers.filter(uh => uh.pluginName !== plugin.name);
}
}
exports.default = MashroomWebAppPluginLoader;

@@ -8,5 +8,5 @@ "use strict";

var _fs = _interopRequireDefault(require("fs"));
var _fs = require("fs");
var _path = _interopRequireDefault(require("path"));
var _path = require("path");

@@ -23,10 +23,11 @@ var _util = require("util");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _plugin_utils = require("../utils/plugin_utils");
const readFile = (0, _util.promisify)(_fs.default.readFile);
const readFile = (0, _util.promisify)(_fs.readFile);
class MashroomPackagePlugin {
constructor(_pluginPackagePath, _ignorePlugins, _registryConnector, _builder, loggerFactory) {
constructor(_pluginPackagePath, _ignorePlugins, _externalPluginConfigFileNames, _registryConnector, _builder, loggerFactory) {
this._pluginPackagePath = _pluginPackagePath;
this._ignorePlugins = _ignorePlugins;
this._externalPluginConfigFileNames = _externalPluginConfigFileNames;
this._registryConnector = _registryConnector;

@@ -98,7 +99,13 @@ this._builder = _builder;

if (!packageJson.mashroom) {
this._logger.error(`Error processing package.json in: ${this._pluginPackagePath}: No 'mashroom' property found!`);
let pluginDefinition = this._readExternalPluginConfigFile();
if (!pluginDefinition && packageJson.mashroom) {
pluginDefinition = packageJson.mashroom;
}
if (!pluginDefinition) {
this._logger.error(`No plugin definition found in: ${this._pluginPackagePath}. Neither does package.json contain a "mashroom" property nor does an external plugin definition file exist.`);
this._status = 'error';
this._errorMessage = `No 'mashroom' property found in package.json`;
this._errorMessage = `No plugin definition found`;

@@ -110,7 +117,7 @@ this._emitError();

if (!packageJson.mashroom.plugins || !Array.isArray(packageJson.mashroom.plugins)) {
this._logger.error(`Error processing package.json in: ${this._pluginPackagePath}: mashroom.plugins is either not defined or no array!`);
if (!pluginDefinition.plugins || !Array.isArray(pluginDefinition.plugins)) {
this._logger.error(`Error processing plugin definition in: ${this._pluginPackagePath}: "plugins" is either not defined or no array!`);
this._status = 'error';
this._errorMessage = `mashroom.plugins in package.json is either not defined or no array`;
this._errorMessage = `Invalid plugin definition: "plugins" is either not defined or no array`;

@@ -122,5 +129,5 @@ this._emitError();

this._pluginPackageDefinition = packageJson.mashroom;
this._pluginPackageDefinition = pluginDefinition;
let plugins = this._checkPluginDefinitions(packageJson.mashroom.plugins); // Check ignore list
let plugins = this._checkPluginDefinitions(this._pluginPackageDefinition.plugins); // Check ignore list

@@ -152,6 +159,20 @@

async _readPackageJson() {
const fileData = await readFile(_path.default.resolve(this._pluginPackagePath, 'package.json'), 'utf-8');
const fileData = await readFile((0, _path.resolve)(this._pluginPackagePath, 'package.json'), 'utf-8');
return JSON.parse(fileData.toString());
}
_readExternalPluginConfigFile() {
const externalPluginConfigFile = (0, _plugin_utils.getExternalPluginDefinitionFilePath)(this._pluginPackagePath, this._externalPluginConfigFileNames);
if (!externalPluginConfigFile) {
return;
}
this._logger.debug('Loading plugin config file:', externalPluginConfigFile); // Reload
delete require.cache[externalPluginConfigFile];
return require(externalPluginConfigFile);
}
_onBuildFinished(event) {

@@ -158,0 +179,0 @@ if (event.pluginPackageName === this._name) {

@@ -20,2 +20,4 @@ "use strict";

var _plugin_utils = require("../../utils/plugin_utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -28,4 +30,2 @@

const DEFAULT_DEFER_UPDATE_MS = 2000;
exports.DEFAULT_DEFER_UPDATE_MS = DEFAULT_DEFER_UPDATE_MS;
/**

@@ -35,2 +35,5 @@ * The plugin scanner.

*/
exports.DEFAULT_DEFER_UPDATE_MS = DEFAULT_DEFER_UPDATE_MS;
class MashroomPluginPackageScanner {

@@ -40,2 +43,3 @@ constructor(config, loggerFactory) {

this._serverRootFolder = config.serverRootFolder;
this._externalPluginConfigFileNames = config.externalPluginConfigFileNames;
this._pluginPackageFolders = config.pluginPackageFolders.filter(folder => {

@@ -239,2 +243,8 @@ if (!_fs.default.existsSync(folder.path)) {

_isMashroomPluginPackage(pluginPackagePath) {
const externalPluginConfigFile = (0, _plugin_utils.getExternalPluginDefinitionFilePath)(pluginPackagePath, this._externalPluginConfigFileNames);
if (externalPluginConfigFile) {
return true;
}
const packageFile = _path.default.resolve(pluginPackagePath, 'package.json');

@@ -241,0 +251,0 @@

@@ -8,2 +8,10 @@ "use strict";

var _http = _interopRequireDefault(require("http"));
var _https = _interopRequireDefault(require("https"));
var _spdy = _interopRequireDefault(require("spdy"));
var _tls_utils = require("@mashroom/mashroom-utils/lib/tls_utils");
var _index_route = _interopRequireDefault(require("./routes/index_route"));

@@ -16,10 +24,10 @@

class MashroomServer {
constructor(expressApp, httpServer, serverInfo, config, scanner, errorHandler, loggerFactory) {
this._expressApp = expressApp;
this._httpServer = httpServer;
this._serverInfo = serverInfo;
this._config = config;
this._scanner = scanner;
this._errorHandler = errorHandler;
this._log = loggerFactory('mashroom.server');
constructor(_expressApp, _serverInfo, _config, _scanner, _errorHandler, _httpUpgradeService, loggerFactory) {
this._expressApp = _expressApp;
this._serverInfo = _serverInfo;
this._config = _config;
this._scanner = _scanner;
this._errorHandler = _errorHandler;
this._httpUpgradeService = _httpUpgradeService;
this._logger = loggerFactory('mashroom.server');

@@ -30,3 +38,3 @@ this._addServerRoutes();

async start() {
this._log.info(`
this._logger.info(`
Starting

@@ -39,8 +47,34 @@ __ ___ __ ____

Version ${this._serverInfo.version}
Pid ${process.pid}
`);
return Promise.all([this._startHttpServer(), this._startHttpsServer()]).then(() => {
return;
});
}
async stop() {
this._logger.info('Stopping Mashroom server...');
this._errorHandler.uninstall();
await this._scanner.stop();
return Promise.all([this._stopHttpServer(), this._stopHttpsServer()]).then(() => {
return;
});
}
_addServerRoutes() {
this._expressApp.get('/', _index_route.default);
this._expressApp.use('/mashroom', _mashroom.default);
}
async _startHttpServer() {
return new Promise((resolve, reject) => {
this._httpServer.listen(this._config.port, () => {
this._log.info(`Mashroom server started with pid ${process.pid} and at port ${this._config.port}`);
const httpServer = _http.default.createServer(this._expressApp);
httpServer.listen(this._config.port, () => {
this._logger.info(`Mashroom HTTP server available at http://localhost:${this._config.port}`);
this._scanner.start();

@@ -50,8 +84,11 @@

this._httpServer = httpServer;
this._httpUpgradeService.addServer(httpServer);
resolve();
});
httpServer.once('error', error => {
this._logger.error('Failed to start HTTP server!', error);
this._httpServer.once('error', error => {
this._log.error('Failed to start Mashroom server!', error);
reject(error);

@@ -62,31 +99,94 @@ });

async stop() {
this._log.info('Stopping Mashroom server...');
async _startHttpsServer() {
if (!this._config.httpsPort) {
return;
}
this._errorHandler.uninstall();
if (!this._config.tlsOptions) {
this._logger.error('Cannot enable TLS because no tlsOptions are defined');
await this._scanner.stop();
return;
}
const fixedTlsOptions = (0, _tls_utils.fixTlsOptions)(this._config.tlsOptions, this._config.serverRootFolder, this._logger);
this._logger.debug('Using TLS options: ', fixedTlsOptions);
return new Promise((resolve, reject) => {
this._httpServer.close(error => {
if (error) {
this._log.error('Failed to stop Mashroom server!', error);
let httpsServer;
reject(error);
} else {
this._log.info('Mashroom server stopped');
if (this._config.enableHttp2) {
httpsServer = _spdy.default.createServer({ ...fixedTlsOptions,
spdy: {
protocols: ['h2', 'http/1.1']
}
}, this._expressApp);
} else {
httpsServer = _https.default.createServer({ ...fixedTlsOptions
}, this._expressApp);
}
resolve();
}
httpsServer.listen(this._config.httpsPort, () => {
this._logger.info(`Mashroom HTTPS server available at https://localhost:${this._config.httpsPort}`);
this._scanner.start();
this._errorHandler.install();
this._httpsServer = httpsServer;
this._httpUpgradeService.addServer(httpsServer);
resolve();
});
httpsServer.once('error', error => {
this._logger.error('Failed to start HTTPS server!', error);
reject(error);
});
});
}
_addServerRoutes() {
this._expressApp.get('/', _index_route.default);
async _stopHttpServer() {
return new Promise((resolve, reject) => {
if (this._httpServer) {
this._httpServer.close(error => {
if (error) {
this._logger.error('Failed to stop HTTP server!', error);
this._expressApp.use('/mashroom', _mashroom.default);
reject(error);
} else {
this._logger.info('HTTP server stopped');
resolve();
}
});
} else {
resolve();
}
});
}
async _stopHttpsServer() {
return new Promise((resolve, reject) => {
if (this._httpsServer) {
this._httpsServer.close(error => {
if (error) {
this._logger.error('Failed to stop HTTPS server!', error);
reject(error);
} else {
this._logger.info('HTTPS server stopped');
resolve();
}
});
} else {
resolve();
}
});
}
}
exports.default = MashroomServer;

@@ -32,3 +32,3 @@ "use strict";

</div>
<h2>Overview Plugins</h2>
<h2>Plugins Overview</h2>
${pluginOverviewTable(pluginContext)}

@@ -35,0 +35,0 @@ `;

@@ -6,4 +6,8 @@ "use strict";

});
exports.createPluginConfig = void 0;
exports.getExternalPluginDefinitionFilePath = exports.createPluginConfig = void 0;
var _path = require("path");
var _fs = require("fs");
var _model_utils = require("@mashroom/mashroom-utils/lib/model_utils");

@@ -17,2 +21,19 @@

exports.createPluginConfig = createPluginConfig;
exports.createPluginConfig = createPluginConfig;
const getExternalPluginDefinitionFilePath = (pluginPackagePath, externalPluginConfigFileNames) => {
const possiblePluginConfigFiles = [];
externalPluginConfigFileNames.forEach(name => {
possiblePluginConfigFiles.push((0, _path.resolve)(pluginPackagePath, `${name}.json`));
possiblePluginConfigFiles.push((0, _path.resolve)(pluginPackagePath, `${name}.js`));
});
const existingPluginConfigFiles = possiblePluginConfigFiles.filter(path => (0, _fs.existsSync)(path));
if (existingPluginConfigFiles.length === 0) {
return;
}
return existingPluginConfigFiles[0];
};
exports.getExternalPluginDefinitionFilePath = getExternalPluginDefinitionFilePath;

@@ -7,3 +7,3 @@ {

"license": "MIT",
"version": "1.7.10",
"version": "1.8.0",
"main": "dist",

@@ -15,3 +15,3 @@ "files": [

"engines": {
"node": ">=10.0.0"
"node": ">=12"
},

@@ -22,21 +22,23 @@ "bin": {

"dependencies": {
"@mashroom/mashroom-utils": "1.7.10",
"@types/express": "^4.17.11",
"anymatch": "^3.1.1",
"chokidar": "^3.5.1",
"@mashroom/mashroom-utils": "1.8.0",
"@types/express": "^4.17.13",
"ansi-regex": "^5.0.0",
"anymatch": "^3.1.2",
"chokidar": "^3.5.2",
"express": "^4.17.1",
"fs-extra": "^9.1.0",
"fs-extra": "^10.0.0",
"log4js": "^6.3.0",
"lucy-dirsum": "^0.1.1",
"minimist": "^1.2.5",
"strip-ansi": "^6.0.0"
"spdy": "^4.0.2"
},
"devDependencies": {
"@babel/cli": "^7.12.16",
"@types/fs-extra": "^9.0.7",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.28",
"eslint": "^7.20.0",
"jest": "^26.6.3",
"typescript": "^4.1.5"
"@babel/cli": "^7.14.8",
"@types/fs-extra": "^9.0.12",
"@types/jest": "^26.0.24",
"@types/node": "^14.17.7",
"@types/spdy": "^3.4.5",
"eslint": "^7.32.0",
"jest": "^27.0.6",
"typescript": "^4.3.5"
},

@@ -43,0 +45,0 @@ "jest": {

@@ -88,2 +88,24 @@

### MashroomHttpUpgradeService
Accessible through _pluginContext.services.core.websocketUpgradeService_
Interface:
```ts
/**
* A services to add and remove HTTP/1 upgrade listeners
*/
export interface MashroomHttpUpgradeService {
/**
* Register an upgrade handler for given path
*/
registerUpgradeHandler(handler: MashroomHttpUpgradeHandler, pathExpression: string | RegExp): void;
/**
* Unregister an upgrade handler
*/
unregisterUpgradeHandler(handler: MashroomHttpUpgradeHandler): void;
}
```
## Plugin Types

@@ -195,3 +217,3 @@

It is also possible to return handlers in the bootstrap. Currently there is only one:
* _upgradeHandler_: Handle HTTP Upgrades (e.g. upgrade to WebSocket)
* _upgradeHandler_: Handle HTTP Upgrades (e.g. upgrade to WebSocket). Alternatively you could use *MashroomWebsocketUpgradeService* directly

@@ -280,3 +302,3 @@ Example:

* _defaultConfig.order_: the weight of the middleware in the stack - the higher it is the **later** it will be executed (default: 1000)
* _defaultConfig.order_: The weight of the middleware in the stack - the higher it is the **later** it will be executed (Default: 1000)

@@ -395,3 +417,3 @@ And the bootstrap just returns the *Express* middleware:

* _defaultConfig.path_: The path in the Admin UI (full path will be /mashroom/admin/ext/\<your path>)
* _defaultConfig.height_: The height of the iframe that will contain the target webapp.
* _defaultConfig.height_: The height of the iframe that will contain the target webapp (Default: 80vh)
If you want that the iframe has the full height of the webapp you have to post the height periodically to

@@ -402,2 +424,2 @@ the parent, like so

```
* _defaultConfig.weight_: The weight of the menu entry, the higher the number the lower will be menu entry be.
* _defaultConfig.weight_: The weight of the menu entry, the higher the number the lower will be menu entry be (Default: 100)

@@ -5,2 +5,3 @@

import type {Socket} from 'net';
import type {TlsOptions} from 'tls';

@@ -30,3 +31,3 @@ // Extends Express Request

/*
* @deprecated use http.IncomingMessage
* @deprecated use IncomingMessageWithContext
* Will be removed in 2.0

@@ -367,5 +368,9 @@ */

readonly port: number;
readonly httpsPort: number | null | undefined;
readonly tlsOptions: TlsOptions | null | undefined;
readonly enableHttp2: boolean;
readonly xPowerByHeader: string | null | undefined;
readonly serverRootFolder: string;
readonly tmpFolder: string;
readonly externalPluginConfigFileNames: Array<string>;
readonly pluginPackageFolders: Array<PluginPackageFolder>;

@@ -386,2 +391,3 @@ readonly ignorePlugins: Array<string>;

readonly middlewareStackService: MashroomMiddlewareStackService;
readonly httpUpgradeService: MashroomHttpUpgradeService;
};

@@ -448,2 +454,25 @@

/**
* Http/1 Upgrade Handler
*/
export type MashroomHttpUpgradeHandler = (
request: IncomingMessageWithContext,
socket: Socket,
head: Buffer,
) => void;
/**
* A services to add and remove HTTP/1 upgrade listeners
*/
export interface MashroomHttpUpgradeService {
/**
* Register an upgrade handler for given path expression
*/
registerUpgradeHandler(handler: MashroomHttpUpgradeHandler, pathExpression: string | RegExp): void;
/**
* Unregister an upgrade handler
*/
unregisterUpgradeHandler(handler: MashroomHttpUpgradeHandler): void;
}
/**
* Mashroom plugin context

@@ -468,11 +497,2 @@ *

/**
* WebSocket support
*/
export type MashroomHttpUpgradeHandler = (
request: IncomingMessageWithContext,
socket: Socket,
head: Buffer,
) => void;
export type ExpressApplicationWithUpgradeHandler = {

@@ -479,0 +499,0 @@ expressApp: Application;

@@ -5,17 +5,25 @@ // @flow

export type HttpServerRequest = $Subtype<http$IncomingMessage<>> & {
pluginContext: MashroomPluginContext
};
export type ExpressRequest = $Subtype<$Request> & {
export type ExpressRequestWithContext = $Subtype<$Request> & {
pluginContext: MashroomPluginContext,
session?: any;
};
export type IncomingMessageWithContext = http$IncomingMessage<> & {
pluginContext: MashroomPluginContext;
session?: any;
}
export type ExpressRequest = ExpressRequestWithContext;
export type ExpressResponse = $Response;
export type ExpressNextFunction = NextFunction;
export type ExpressApplication = $Application<ExpressRequest, ExpressResponse>;
export type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => mixed;
export type ExpressErrorHandler = (error: Error, req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => mixed;
export type ExpressRouter = Router<ExpressRequest, ExpressResponse>;
export type ExpressApplication = $Application<ExpressRequestWithContext, ExpressResponse>;
export type ExpressMiddleware = (req: ExpressRequestWithContext, res: ExpressResponse, next: ExpressNextFunction) => mixed;
export type ExpressErrorHandler = (error: Error, req: ExpressRequestWithContext, res: ExpressResponse, next: ExpressNextFunction) => mixed;
export type ExpressRouter = Router<ExpressRequestWithContext, ExpressResponse>;
export type ExpressRequestHandler = ExpressApplication | ExpressRouter | ExpressMiddleware | ExpressErrorHandler;
/*
* @deprecated use IncomingMessageWithContext
*/
export type HttpServerRequest = IncomingMessageWithContext;
export type I18NString = string | {

@@ -276,2 +284,5 @@ [lang: string]: string

+port: number,
+httpsPort: ?number;
+tlsOptions: ?any;
+enableHttp2: boolean;
+xPowerByHeader: ?string,

@@ -294,2 +305,3 @@ +serverRootFolder: string,

+middlewareStackService: MashroomMiddlewareStackService,
+httpUpgradeService: MashroomHttpUpgradeService,
}

@@ -346,2 +358,21 @@

/**
* Http/1 Upgrade Handler
*/
export type MashroomHttpUpgradeHandler = (request: HttpServerRequest, socket: net$Socket, head: Buffer) => void;
/**
* A services to add and remove HTTP/1 upgrade listeners
*/
export interface MashroomHttpUpgradeService {
/**
* Register an upgrade handler for given path expression
*/
registerUpgradeHandler(handler: MashroomHttpUpgradeHandler, pathExpression: string | RegExp): void;
/**
* Unregister an upgrade handler
*/
unregisterUpgradeHandler(handler: MashroomHttpUpgradeHandler): void;
}
/**
* Mashroom plugin context

@@ -366,7 +397,2 @@ *

/**
* WebSocket support
*/
export type MashroomHttpUpgradeHandler = (request: HttpServerRequest, socket: net$Socket, head: Buffer) => void;
export type ExpressApplicationWithUpgradeHandler = {

@@ -373,0 +399,0 @@ expressApp: ExpressApplication,

import type {Server} from 'net';
import type {RequestHandler, Application} from 'express';

@@ -19,3 +20,4 @@ import type {

MashroomPluginContextHolder,
MashroomCoreServices
MashroomCoreServices,
MashroomHttpUpgradeService
} from './api';

@@ -226,1 +228,4 @@

export interface InternalMashroomHttpUpgradeService extends MashroomHttpUpgradeService {
addServer(server: Server): void;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc