Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Type safe way defining configurations fed by environment variables, process arguments or json config files (including deserialization and validation)
Type safe way defining configurations fed by environment variables, process arguments or json config files (including deserialization and validation).
npm install type-env --save
type-env requires reflect-metadata
npm install reflect-metadata --save
Your tsconfig.json
needs the following flags:
{
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
import {Config, EnvValue} from 'type-env';
@Config
class DataBaseConfiguration {
@EnvValue('DB_HOST') host: string = 'localhost'; // default value
@EnvValue('DB_NAME') name: string;
@EnvValue('DB_PORT') port: number;
}
import {Config, ArgsValue} from 'type-env';
@Config
class LoggingConfiguration {
@ArgsValue('log-level') level: string;
@ArgsValue('silent') silent: boolean;
}
{
"auth": {
"jwt": {
"issuer": "type-env"
},
"timestamp": "2018-05-27T17:35:54.391Z"
}
}
import {Config, JsonConfiguration, JsonValue} from 'type-env';
@Config
@JsonConfiguration(`${__dirname}/config.json`)
class AuthConfiguration {
@JsonValue('auth.jwt.issuer') jwtIssuer: string = 'type-env';
@JsonValue('auth.timestamp') timestamp: Date;
}
DB_HOST='127.0.0.1' /
DB_NAME='type-env' /
DB_PORT='1234' /
node app.js --log-level info --silent
import {buildDecorators, NodeEnvConfigSource, NodeArgsConfigSource, JsonConfigSource} from 'type-env';
const {Value, EnvValue, ArgsValue, JsonValue} = buildDecorators({
/**
* Enables validation if true. Throws if config value is invalid.
* @default true
*/
validate: true,
/**
* Throws if value does not exist on source.
* @default true
*/
required: true,
/**
* If true, loads config value when property is accessed.
* @default true
*/
lazyLoad: true,
/**
* Do not throw on validation or requirement errors, but logs a warning instead.
* @default false
*/
warnOnly: false,
/**
* Map of decorator key name and config source.
* @default {
Value: NodeEnvConfigSource,
EnvValue: NodeEnvConfigSource,
ArgsValue: NodeArgsConfigSource,
JsonValue: JsonConfigSource,
}
*/
decoratorMeta: {
Value: NodeEnvConfigSource,
EnvValue: NodeEnvConfigSource,
ArgsValue: NodeArgsConfigSource,
JsonValue: JsonConfigSource,
}
})
FAQs
Type safe way defining configurations fed by environment variables, process arguments or json config files (including deserialization and validation)
We found that type-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.