Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import environmentIsNode from 'detect-node';
import {
createLogger,
createMockLogger,
createRoarrInititialGlobalState,
} from './factories';
const globalThis = createGlobalThis();
globalThis.ROARR = createRoarrInititialGlobalState(globalThis.ROARR || {});
let logFactory = createLogger;
if (environmentIsNode) {
// eslint-disable-next-line no-process-env
const enabled = boolean(process.env.ROARR_LOG || '');
if (!enabled) {
logFactory = createMockLogger;
}
}
export type {
LoggerType,
MessageType,
TranslateMessageFunctionType,
} from './types';
export default logFactory((message) => {
if (globalThis.ROARR.write) {
// Stringify message as soon as it is received to prevent
// properties of the context from being modified by reference.
Array.isArray(this.dnsbl.domains) &&
Array.isArray(this.dnsbl.removals) &&
this.dnsbl.domains.length !== this.dnsbl.removals.length
)
throw new Error('DNSBL_DOMAINS length must be equal to DNSBL_REMOVALS');
if (this.config.ssl) {
this.config.ssl.minVersion = 'TLSv1';
this.config.ssl.ciphers = tls
.getCiphers()
.map(cipher => cipher.toUpperCase())
.join(':');
this.config.ssl.secureOptions =
crypto.constants.SSL_OP_NO_SSLv3 | crypto.constants.SSL_OP_NO_SSLv2;
delete this.config.ssl.allowHTTP1;
if (boolean(process.env.IS_NOT_SECURE)) this.config.ssl.secure = false;
else this.config.ssl.secure = true;
}
this.config.smtp = {
...this.config.smtp,
...this.config.ssl
};
// set up DKIM instance for signing messages
this.dkim = new DKIM(this.config.dkim);
// initialize redis
const client = new Redis(
this.config.redis,
logger,
this.config.redisMonitor
.get(
'/:provider/ok',
policies.ensureLoggedOut,
web.auth.catchError,
(ctx, next) => {
const redirect = ctx.session.returnTo
? ctx.session.returnTo
: `/${ctx.locale}${config.passportCallbackOptions.successReturnToOrRedirect}`;
return passport.authenticate(ctx.params.provider, {
...config.passportCallbackOptions,
successReturnToOrRedirect: redirect
})(ctx, next);
}
);
if (boolean(process.env.AUTH_GOOGLE_ENABLED)) {
router.get(
'/google/consent',
policies.ensureLoggedOut,
web.auth.catchError,
passport.authenticate('google', {
accessType: 'offline',
prompt: 'consent', // See google strategy in passport helper
scope: [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile'
]
})
);
}
module.exports = router;
const createConfiguration = (configurationInput: ProxyAgentConfigurationInputType): ProxyAgentConfigurationType => {
// eslint-disable-next-line no-process-env
const environment = process.env;
const defaultConfiguration = {
environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_',
forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? parseBoolean(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true,
socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout,
};
// $FlowFixMe
return {
...defaultConfiguration,
...omitUndefined(configurationInput),
};
};
this.opts.baseURI ? ` from ${this.opts.baseURI}` : ''
}`
)
});
if (opts.arrayFormat) {
this.opts.parse.arrayFormat = 'indices';
delete opts.arrayFormat;
}
if (Array.isArray(opts.preventBodyOnMethods))
this.opts.preventBodyOnMethods = this.opts.preventBodyOnMethods.map(
method => method.toUpperCase().trim()
);
this.opts.raw = boolean(this.opts.raw);
if (this.opts.auth) this.auth(this.opts.auth);
METHODS.forEach(method => {
this[method.toLowerCase()] = this._setup(method.toLowerCase());
});
// alias for `this.del` -> `this.delete`
this.del = this._setup('delete');
// interceptor should be initialized after methods setup
this.interceptor = new Interceptor(this, this.opts.interceptableMethods);
// bind scope to method
this.setOptions = this.setOptions.bind(this);
this.auth = this.auth.bind(this);
endpoint,
headers: {},
timeout: 5000,
retry: 3,
showStack: process.env.SHOW_STACK
? boolean(process.env.SHOW_STACK)
: true,
showMeta: process.env.SHOW_META ? boolean(process.env.SHOW_META) : true,
silent: false,
logger: console,
name: false,
level: 'info',
levels: ['info', 'warn', 'error', 'fatal'],
capture: process.browser ? false : env === 'production',
callback: false,
appInfo: process.env.APP_INFO ? boolean(process.env.APP_INFO) : true
},
config
);
this.appInfo = this.config.appInfo
? isFunction(parseAppInfo)
? parseAppInfo()
: false
: false;
this.log = this.log.bind(this);
// inherit methods from parent logger
const methods = Object.keys(this.config.logger).filter(
key => !omittedLoggerKeys.includes(key)
);
constructor(config = {}) {
this.config = Object.assign(
{
key: '',
endpoint,
headers: {},
timeout: 5000,
retry: 3,
showStack: process.env.SHOW_STACK
? boolean(process.env.SHOW_STACK)
: true,
showMeta: process.env.SHOW_META ? boolean(process.env.SHOW_META) : true,
silent: false,
logger: console,
name: false,
level: 'info',
levels: ['info', 'warn', 'error', 'fatal'],
capture: process.browser ? false : env === 'production',
callback: false,
appInfo: process.env.APP_INFO ? boolean(process.env.APP_INFO) : true
},
config
);
this.appInfo = this.config.appInfo
? isFunction(parseAppInfo)
User.virtual(config.userFields.verificationPinHasExpired).get(function() {
return boolean(
!this[config.userFields.verificationPinExpiresAt] ||
new Date(this[config.userFields.verificationPinExpiresAt]).getTime() <
Date.now()
);
});
constructor(config = {}) {
this.config = Object.assign(
{
key: '',
endpoint,
headers: {},
timeout: 5000,
retry: 3,
showStack: process.env.SHOW_STACK
? boolean(process.env.SHOW_STACK)
: true,
showMeta: process.env.SHOW_META ? boolean(process.env.SHOW_META) : true,
silent: false,
logger: console,
name: false,
level: 'info',
levels: ['info', 'warn', 'error', 'fatal'],
capture: process.browser ? false : env === 'production',
callback: false,
appInfo: process.env.APP_INFO ? boolean(process.env.APP_INFO) : true
},
config
);
this.appInfo = this.config.appInfo
? isFunction(parseAppInfo)
? parseAppInfo()
: false