Socket
Socket
Sign inDemoInstall

@soundworks/core

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soundworks/core - npm Package Compare versions

Comparing version 3.1.0-beta.4 to 3.1.0-beta.5

2

package.json
{
"name": "@soundworks/core",
"version": "3.1.0-beta.4",
"version": "3.1.0-beta.5",
"description": "full-stack javascript framework for distributed audio visual experiences on the web",

@@ -5,0 +5,0 @@ "authors": [

@@ -267,3 +267,33 @@ "use strict";

this._clientConfigFunction = clientConfigFunction;
this._clientConfigFunction = clientConfigFunction; // basic http authentication
if (this.config.env.auth) {
this.router.use((req, res, next) => {
const isProtected = this.config.env.auth.clients.map(type => req.path.endsWith(`/${type}`)).reduce((acc, value) => acc || value, false);
if (isProtected) {
// authentication middleware
const auth = this.config.env.auth; // parse login and password from headers
const b64auth = (req.headers.authorization || '').split(' ')[1] || '';
const [login, password] = Buffer.from(b64auth, 'base64').toString().split(':'); // verify login and password are set and correct
if (login && password && login === auth.login && password === auth.password) {
// -> access granted...
return next();
} // -> access denied...
res.writeHead(401, {
'WWW-Authenticate': 'Basic',
'Content-Type': 'text/plain'
});
res.end('Authentication required.');
} else {
// route not protected
return next();
}
});
}
return Promise.resolve();

@@ -418,3 +448,3 @@ }

_logger.default.clientConfigAndRouting(routes, this.config.app.clients, this.config.env.serverIp);
_logger.default.clientConfigAndRouting(routes, this.config);

@@ -517,4 +547,12 @@ return Promise.resolve();

data.env.subpath = this.config.env.subpath;
}
} // cors / coop / coep headers for `crossOriginIsolated pages, enables
// sharedArrayBuffers and high precision timers
// cf. https://web.dev/why-coop-coep/
res.writeHead(200, {
'Cross-Origin-Resource-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin'
});
const appIndex = tmpl(data);

@@ -521,0 +559,0 @@ res.end(appIndex);

@@ -22,3 +22,6 @@ "use strict";

clientConfigAndRouting(routes, clientsConfig, serverIp) {
clientConfigAndRouting(routes, config) {
const clientsConfig = config.app.clients;
const servIp = config.env.serverIp;
const auth = config.env.auth;
const table = [];

@@ -31,6 +34,7 @@

const line = {
clientType: `${clientType}`,
client_type: `> ${clientType}`,
target: _chalk.default.red(client.target),
path: `server ip: ${_chalk.default.green(serverIp)}`,
default: undefined
default: undefined,
auth: undefined
};

@@ -40,6 +44,7 @@ table.push(line);

const line = {
clientType: `${clientType}`,
client_type: `> ${clientType}`,
target: _chalk.default.red(client.target),
path: routes.find(r => r.clientType === clientType) ? _chalk.default.green(routes.find(r => r.clientType === clientType).path) : _chalk.default.red('no route defined'),
default: client.default ? 'default' : undefined
default: client.default ? 'x' : undefined,
auth: auth && auth.clients.indexOf(clientType) !== -1 ? 'x' : undefined
};

@@ -52,6 +57,17 @@ table.push(line);

console.log(``);
console.log((0, _columnify.default)(table, {
showHeaders: false,
minWidth: 14
})); // check if a route is defined but not in config
showHeaders: true,
minWidth: 6,
columnSplitter: ' | ',
config: {
default: {
align: 'center'
},
auth: {
align: 'center'
}
}
}));
console.log(``); // check if a route is defined but not in config

@@ -58,0 +74,0 @@ const configClientTypes = Object.keys(clientsConfig);

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