Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Declare Internals
const internals = {};
internals.defaults = {
accessTokenName: 'access_token',
allowQueryToken: false,
allowCookieToken: false,
allowMultipleHeaders: false,
allowChaining: false,
tokenType: 'Bearer',
unauthorized: Boom.unauthorized
};
internals.schema = Joi.object().keys({
validate: Joi.func().required(),
accessTokenName: Joi.string().required(),
allowQueryToken: Joi.boolean(),
allowCookieToken: Joi.boolean(),
allowMultipleHeaders: Joi.boolean(),
allowChaining: Joi.boolean(),
tokenType: Joi.string().required(),
unauthorized: Joi.func()
});
internals.implementation = (server, options) => {
Hoek.assert(options, 'Missing bearer auth strategy options');
const settings = Hoek.applyToDefaults(internals.defaults, options);
Joi.assert(settings, internals.schema);
request: Wreck.request.bind(Wreck),
parseCacheControl: Wreck.parseCacheControl.bind(Wreck)
},
xforward: false,
passThrough: false,
redirects: false,
timeout: 1000 * 60 * 3, // Timeout request after 3 minutes
localStatePassThrough: false, // Pass cookies defined by the server upstream
maxSockets: Infinity,
downstreamResponseTime: false
};
internals.schema = Joi.object({
httpClient: Joi.object({
request: Joi.func(),
parseCacheControl: Joi.func()
}),
host: Joi.string(),
port: Joi.number().integer(),
protocol: Joi.string().valid('http', 'https', 'http:', 'https:'),
uri: Joi.string(),
passThrough: Joi.boolean(),
localStatePassThrough: Joi.boolean(),
acceptEncoding: Joi.boolean().when('passThrough', { is: true, otherwise: Joi.forbidden() }),
rejectUnauthorized: Joi.boolean(),
xforward: Joi.boolean(),
redirects: Joi.number().min(0).integer().allow(false),
timeout: Joi.number().integer(),
mapUri: Joi.func(),
onResponse: Joi.func(),
onRequest: Joi.func(),
params: t
.array()
.items(
t.object({
name: t.string(),
type: t.string(),
message: t.string(),
}),
)
.default([]),
})
.default(),
platforms: map(
t.string(),
t.object({
dependencyConfig: t.func(),
projectConfig: t.func(),
linkConfig: t.func(),
}),
).default({}),
commands: t
.array()
.items(command)
.default([]),
})
.unknown(true)
.default();
/**
* Schema for ProjectConfigT
*/
export const projectConfig = t
const handler = others.handler || options.handler;
delete options.handler;
lambdas.set(id, {
id,
handler,
server,
settings: options
});
});
};
internals.lambdaSchema = Joi.object({
id: Joi.string().required(),
handler: Joi.func(),
options: Joi.object().default({}).unknown().keys({
handler: Joi.func()
})
})
.xor('handler', 'options.handler');
internals.maybeLambdaifyRoute = (server, route) => {
const {
method,
path,
params,
fingerprint,
public: {
settings: { id, plugins, cors }
}
'use strict';
const { Severity } = require('@sentry/node');
const joi = require('@hapi/joi');
const levels = Object.values(Severity).filter(level => typeof level === 'string')
|| ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
const sentryClient = joi.object().keys({
configureScope: joi.func().minArity(1),
Scope: joi.func().required(),
Handlers: joi.object().keys({
parseRequest: joi.func().minArity(2).required(),
}).unknown().required(),
withScope: joi.func().minArity(1).required(),
captureException: joi.func().minArity(1).required(),
}).unknown();
const sentryOptions = joi.object().keys({
dsn: joi.string().uri().allow(false).required(),
}).unknown();
module.exports = joi.object().keys({
baseUri: joi.string().uri(),
trackUser: joi.boolean().default(true),
scope: joi.object().keys({
tags: joi.array().items(joi.object().keys({
type: Joi.any().valid('autoRollup').required(),
maxPreAggregations: Joi.number()
})),
Joi.object().keys(Object.assign({}, BasePreAggregation, {
type: Joi.any().valid('originalSql').required()
})),
Joi.object().keys(Object.assign({}, BasePreAggregation, {
type: Joi.any().valid('rollup').required(),
measureReferences: Joi.func(),
dimensionReferences: Joi.func(),
segmentReferences: Joi.func()
})),
Joi.object().keys(Object.assign({}, BasePreAggregation, {
type: Joi.any().valid('rollup').required(),
measureReferences: Joi.func(),
dimensionReferences: Joi.func(),
segmentReferences: Joi.func(),
timeDimensionReference: Joi.func().required(),
granularity: Joi.any().valid(
'second', 'minute', 'hour', 'day', 'week', 'month', 'year'
).required()
}))
))
});
class CubeValidator {
constructor(cubeSymbols) {
this.cubeSymbols = cubeSymbols;
this.validCubes = {};
}
compile(cubes, errorReporter) {
import {SchemaLike} from '@hapi/joi';
const map = (key: RegExp | SchemaLike, value: SchemaLike) =>
t
.object()
.unknown(true)
.pattern(key, value);
/**
* Schema for CommandT
*/
const command = t.object({
name: t.string().required(),
description: t.string(),
usage: t.string(),
func: t.func().required(),
options: t.array().items(
t
.object({
name: t.string().required(),
description: t.string(),
parse: t.func(),
default: t
.alternatives()
.try([t.bool(), t.number(), t.string().allow(''), t.func()]),
})
.rename('command', 'name', {ignoreUndefined: true}),
),
examples: t.array().items(
t.object({
desc: t.string().required(),
cmd: t.string().required(),
"use strict";
const Joi = require("@hapi/joi");
const schema = Joi.object().keys(
{
owner: Joi.string(),
dynamodb: Joi.object().keys(
{
delete: Joi.func().required(),
get: Joi.func().required(),
put: Joi.func().required()
}
).unknown().required(),
lockTable: Joi.string().required(),
partitionKey: Joi.string().invalid("fencingToken", "leaseDurationMs", "owner", "guid").required(),
heartbeatPeriodMs: Joi.number().integer().min(0),
leaseDurationMs: Joi.number().integer().min(0).required(),
trustLocalTime: Joi.boolean(),
retryCount: Joi.number().integer().min(0)
}
).required();
module.exports = schema;
'use strict';
const { Severity } = require('@sentry/node');
const joi = require('@hapi/joi');
const levels = Object.values(Severity).filter(level => typeof level === 'string')
|| ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
const sentryClient = joi.object().keys({
configureScope: joi.func().minArity(1),
Scope: joi.func().required(),
Handlers: joi.object().keys({
parseRequest: joi.func().minArity(2).required(),
}).unknown().required(),
withScope: joi.func().minArity(1).required(),
captureException: joi.func().minArity(1).required(),
}).unknown();
const sentryOptions = joi.object().keys({
dsn: joi.string().uri().allow(false).required(),
}).unknown();
module.exports = joi.object().keys({
baseUri: joi.string().uri(),
trackUser: joi.boolean().default(true),
scope: joi.object().keys({
tags: joi.array().items(joi.object().keys({
name: joi.string().required(),
value: joi.any().required(),
})),
level: joi.string().only(levels),
'use strict'
const Joi = require('@hapi/joi')
module.exports = Joi.object({
signals: Joi.alternatives(
Joi.array().items(
Joi.string().description('Shutdown signal')
).min(1).description('Shutdown signals to listen on for gracefully stop the hapi server'),
Joi.string().description('Shutdown signal')
),
logger: Joi.object(),
preServerStop: Joi.func(),
postServerStop: Joi.func(),
preShutdown: Joi.func()
}).unknown(true)