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

hapi

Package Overview
Dependencies
Maintainers
1
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi - npm Package Compare versions

Comparing version 17.5.4 to 17.5.5

26

lib/auth.js

@@ -79,4 +79,4 @@ 'use strict';

const routes = this._core.router.table();
for (let i = 0; i < routes.length; ++i) {
routes[i].rebuild();
for (const route of routes) {
route.rebuild();
}

@@ -154,4 +154,3 @@ }

if (options.access) {
for (let i = 0; i < options.access.length; ++i) {
const access = options.access[i];
for (const access of options.access) {
access.scope = internals.setupScope(access);

@@ -166,4 +165,3 @@ }

let hasAuthenticatePayload = false;
for (let i = 0; i < options.strategies.length; ++i) {
const name = options.strategies[i];
for (const name of options.strategies) {
const strategy = this._strategies[name];

@@ -206,4 +204,3 @@ Hoek.assert(strategy, 'Unknown authentication strategy', name, 'in', path);

for (let i = 0; i < config.strategies.length; ++i) {
const name = config.strategies[i];
for (const name of config.strategies) {
const strategy = this._strategies[name];

@@ -240,4 +237,3 @@ if (strategy.methods[type]) {

for (let i = 0; i < config.strategies.length; ++i) {
const name = config.strategies[i];
for (const name of config.strategies) {
const strategy = this._strategies[name];

@@ -299,4 +295,3 @@

const scopeErrors = [];
for (let i = 0; i < config.access.length; ++i) {
const access = config.access[i];
for (const access of config.access) {

@@ -418,4 +413,3 @@ // Check entity

const scope = {};
for (let i = 0; i < access.scope.length; ++i) {
const value = access.scope[i];
for (const value of access.scope) {
const prefix = value[0];

@@ -516,4 +510,4 @@ const type = (prefix === '+' ? 'required' : (prefix === '!' ? 'forbidden' : 'selection'));

for (let i = 0; i < scope[type].length; ++i) {
expanded.push(Hoek.reachTemplate(context, scope[type][i]));
for (const template of scope[type]) {
expanded.push(Hoek.reachTemplate(context, template));
}

@@ -520,0 +514,0 @@

@@ -178,4 +178,3 @@ 'use strict';

const added = [];
for (let i = 0; i < options.length; ++i) {
let config = options[i];
for (let config of options) {
if (typeof config === 'function') {

@@ -343,6 +342,4 @@ config = { engine: config };

for (let i = 0; i < this.dependencies.length; ++i) {
const dependency = this.dependencies[i];
for (let j = 0; j < dependency.deps.length; ++j) {
const dep = dependency.deps[j];
for (const dependency of this.dependencies) {
for (const dep of dependency.deps) {
if (!this.registrations[dep]) {

@@ -444,4 +441,3 @@ throw new Error('Plugin ' + dependency.plugin + ' missing dependency ' + dep);

for (let i = 0; i < exts.nodes.length; ++i) {
const ext = exts.nodes[i];
for (const ext of exts.nodes) {
const bind = (ext.bind || ext.realm.settings.bind);

@@ -448,0 +444,0 @@ await ext.func.call(bind, ext.server, bind);

@@ -48,4 +48,3 @@ 'use strict';

for (let i = 0; i < settings.origin.length; ++i) {
const origin = settings.origin[i];
for (const origin of settings.origin) {
if (origin.indexOf('*') !== -1) {

@@ -206,4 +205,4 @@ settings._origin.wildcards.push(new RegExp('^' + Hoek.escapeRegex(origin).replace(/\\\*/g, '.*').replace(/\\\?/g, '.') + '$'));

for (let i = 0; i < settings._origin.wildcards.length; ++i) {
if (origin.match(settings._origin.wildcards[i])) {
for (const wildcard of settings._origin.wildcards) {
if (origin.match(wildcard)) {
return true;

@@ -210,0 +209,0 @@ }

@@ -31,3 +31,3 @@ 'use strict';

for (let i = 0; i < methods.length; ++i) {
for (const method of methods) {
const settings = {

@@ -41,3 +41,3 @@ before: options.before,

const node = {
func: methods[i], // Request: function (request, h), Server: function (server)
func: method, // Request: function (request, h), Server: function (server)
bind: options.bind,

@@ -55,4 +55,4 @@ server: event.server, // Server event

for (let i = 0; i < this._routes.length; ++i) {
this._routes[i].rebuild(event);
for (const route of this._routes) {
route.rebuild(event);
}

@@ -64,4 +64,4 @@ }

const merge = [];
for (let i = 0; i < others.length; ++i) {
merge.push(others[i]._topo);
for (const other of others) {
merge.push(other._topo);
}

@@ -84,4 +84,4 @@

if (events) {
for (let i = 0; i < events.length; ++i) {
const event = Hoek.shallow(events[i]);
for (let event of events) {
event = Hoek.shallow(event);
Hoek.assert(!event.options.sandbox, 'Cannot specify sandbox option for route extension');

@@ -88,0 +88,0 @@ event.realm = route.realm;

@@ -18,14 +18,12 @@ 'use strict';

if (request._route._prerequisites) {
for (let i = 0; i < request._route._prerequisites.length; ++i) { // Serial execution of each set
const set = request._route._prerequisites[i];
for (const set of request._route._prerequisites) { // Serial execution of each set
const pres = [];
for (let j = 0; j < set.length; ++j) {
pres.push(internals.handler(request, set[j].method, set[j]));
for (const item of set) {
pres.push(internals.handler(request, item.method, item));
}
const responses = await Promise.all(pres); // Parallel execution within sets
for (let j = 0; j < responses.length; ++j) {
if (responses[j] !== undefined) {
return responses[j];
for (const response of responses) {
if (response !== undefined) {
return response;
}

@@ -150,8 +148,7 @@ }

for (let i = 0; i < config.length; ++i) {
const pres = [].concat(config[i]);
for (let pres of config) {
pres = [].concat(pres);
const set = [];
for (let j = 0; j < pres.length; ++j) {
let pre = pres[j];
for (let pre of pres) {
if (typeof pre !== 'object') {

@@ -158,0 +155,0 @@ pre = { method: pre };

@@ -87,4 +87,3 @@ 'use strict';

const requestStates = Object.keys(request._states);
for (let i = 0; i < requestStates.length; ++i) {
const stateName = requestStates[i];
for (const stateName of requestStates) {
names[stateName] = true;

@@ -96,4 +95,3 @@ states.push(request._states[stateName]);

const keys = Object.keys(request._core.states.cookies);
for (let i = 0; i < keys.length; ++i) {
const name = keys[i];
for (const name of keys) {
const autoValue = request._core.states.cookies[name].autoValue;

@@ -100,0 +98,0 @@ if (!autoValue || names[name]) {

@@ -14,2 +14,3 @@ 'use strict';

exports.Server = Server;
exports.server = Server;

@@ -35,4 +35,4 @@ 'use strict';

const items = [].concat(name);
for (let i = 0; i < items.length; ++i) {
const item = Config.apply('methodObject', items[i]);
for (let item of items) {
item = Config.apply('methodObject', item);
this._add(item.name, item.method, item.options || {}, realm);

@@ -39,0 +39,0 @@ }

@@ -88,4 +88,3 @@ 'use strict';

const properties = Object.keys(server._core._decorations.requestApply);
for (let i = 0; i < properties.length; ++i) {
const property = properties[i];
for (const property of properties) {
const assignment = server._core._decorations.requestApply[property];

@@ -168,3 +167,3 @@ request[property] = assignment(request);

this._setTimeouts();
await this._lifecycle(this._route._cycle, false);
await this._lifecycle();
this._reply();

@@ -252,6 +251,6 @@ }

async _lifecycle(cycle, postCycle) {
async _lifecycle() {
for (let i = 0; i < cycle.length; ++i) {
if ((this._isReplied && !postCycle) ||
for (const func of this._route._cycle) {
if (this._isReplied ||
!this._eventContext.request) {

@@ -262,4 +261,2 @@

const func = cycle[i];
try {

@@ -282,15 +279,8 @@ var response = (typeof func === 'function' ? func(this) : this._invoke(func));

if (internals.skip(response) &&
(!postCycle || !response._takeover)) {
this._setResponse(response);
return;
if (!internals.skip(response)) {
response = Boom.badImplementation('Lifecycle methods called before the handler can only return an error, a takeover response, or a continue signal');
}
if (this.response === null) {
this._setResponse(Boom.badImplementation('Lifecycle methods called before the handler can only return an error, a takeover response, or a continue signal'));
return;
}
this._setResponse(response);
return;
}

@@ -301,4 +291,3 @@ }

for (let i = 0; i < event.nodes.length; ++i) {
const ext = event.nodes[i];
for (const ext of event.nodes) {
const bind = (ext.bind || ext.realm.settings.bind);

@@ -348,3 +337,3 @@ const realm = ext.realm;

await this._lifecycle(this._route._postCycle, true);
await this._postCycle();

@@ -360,2 +349,25 @@ if (typeof this.response === 'symbol') { // close or abandon

async _postCycle() {
for (const func of this._route._postCycle) {
if (!this._eventContext.request) {
return;
}
try {
var response = await (typeof func === 'function' ? func(this) : this._invoke(func));
}
catch (err) {
Bounce.rethrow(err, 'system');
response = Response.wrap(err, this);
}
if (response &&
response !== this._core.toolkit.continue) { // Continue
this._setResponse(response);
}
}
}
_abort() {

@@ -362,0 +374,0 @@

@@ -171,4 +171,4 @@ 'use strict';

const values = existing.split(separator);
for (let i = 0; i < values.length; ++i) {
if (values[i] === value) {
for (const v of values) {
if (v === value) {
return this;

@@ -234,4 +234,3 @@ }

const ifNoneMatch = request.headers['if-none-match'].split(/\s*,\s*/);
for (let i = 0; i < ifNoneMatch.length; ++i) {
const etag = ifNoneMatch[i];
for (const etag of ifNoneMatch) {
if (etag === options.etag) {

@@ -244,4 +243,4 @@ return true;

const encoders = request._core.compression.encodings;
for (let j = 0; j < encoders.length; ++j) {
if (etag === etagBase + `-${encoders[j]}"`) {
for (const encoder of encoders) {
if (etag === etagBase + `-${encoder}"`) {
return true;

@@ -497,4 +496,3 @@ }

for (let i = 0; i < headerKeys.length; ++i) {
const key = headerKeys[i];
for (const key of headerKeys) {
const lower = key.toLowerCase();

@@ -509,4 +507,3 @@ if (!internals.hopByHop[lower] &&

headerKeys = Object.keys(localHeaders);
for (let i = 0; i < headerKeys.length; ++i) {
const key = headerKeys[i];
for (const key of headerKeys) {
this.header(key, localHeaders[key], { append: key === 'set-cookie' });

@@ -513,0 +510,0 @@ }

@@ -151,4 +151,3 @@ 'use strict';

this.settings.response.schema = Validation.compile(rule);
for (let i = 0; i < statuses.length; ++i) {
const code = statuses[i];
for (const code of statuses) {
this.settings.response.status[code] = Validation.compile(this.settings.response.status[code]);

@@ -374,5 +373,3 @@ }

for (let i = 0; i < failed.length; ++i) {
const item = failed[i];
for (const item of failed) {
if (item.settings.clearInvalid) {

@@ -471,5 +468,4 @@ request._clearState(item.name);

let config = chain[0];
for (let i = 1; i < chain.length; ++i) {
config = Hoek.applyToDefaultsWithShallow(config, chain[i], ['bind', 'validate.headers', 'validate.payload', 'validate.params', 'validate.query']);
for (const item of chain) {
config = Hoek.applyToDefaultsWithShallow(config, item, ['bind', 'validate.headers', 'validate.payload', 'validate.params', 'validate.query']);
}

@@ -476,0 +472,0 @@

@@ -30,2 +30,3 @@ 'use strict';

}
if (security.hsts.preload) {

@@ -32,0 +33,0 @@ security._hsts = security._hsts + '; preload';

@@ -83,4 +83,3 @@ 'use strict';

for (let i = 0; i < core.decorations.server.length; ++i) {
const method = core.decorations.server[i];
for (const method of core.decorations.server) {
this[method] = core._decorations.server[method];

@@ -231,5 +230,4 @@ }

events = Config.apply('exts', events);
for (let i = 0; i < events.length; ++i) {
this._ext(events[i]);
for (const event of events) {
this._ext(event);
}

@@ -375,4 +373,3 @@ }

const items = [].concat(plugins);
for (let i = 0; i < items.length; ++i) {
let item = items[i];
for (let item of items) {

@@ -453,9 +450,5 @@ /*

options = [].concat(options);
for (let i = 0; i < options.length; ++i) {
const config = options[i];
for (const config of options) {
if (Array.isArray(config.method)) {
for (let j = 0; j < config.method.length; ++j) {
const method = config.method[j];
for (const method of config.method) {
const settings = Hoek.shallow(config);

@@ -477,4 +470,3 @@ settings.method = method;

for (let i = 0; i < vhosts.length; ++i) {
const vhost = vhosts[i];
for (const vhost of vhosts) {
const record = this._core.router.add({ method: route.method, path: route.path, vhost, analysis: route._analysis, id: route.settings.id }, route);

@@ -481,0 +473,0 @@ route.fingerprint = record.fingerprint;

@@ -137,4 +137,3 @@ 'use strict';

for (let i = 0; i < request._core.decorations.toolkit.length; ++i) {
const method = request._core.decorations.toolkit[i];
for (const method of request._core.decorations.toolkit) {
this[method] = request._core._decorations.toolkit[method];

@@ -141,0 +140,0 @@ }

@@ -44,4 +44,3 @@ 'use strict';

for (let i = 0; i < request._route._marshalCycle.length; ++i) {
const func = request._route._marshalCycle[i];
for (const func of request._route._marshalCycle) {
const result = func(request);

@@ -48,0 +47,0 @@ if (result && typeof result.then === 'function') { // Skip await if no reason to

@@ -106,4 +106,4 @@ 'use strict';

if (validationError.details) {
for (let i = 0; i < validationError.details.length; ++i) {
const path = validationError.details[i].path;
for (const details of validationError.details) {
const path = details.path;
detailedError.output.payload.validation.keys.push(Hoek.escapeHtml(path.join('.')));

@@ -115,4 +115,3 @@ }

const fields = Object.keys(request.route.settings.validate.errorFields);
for (let i = 0; i < fields.length; ++i) {
const field = fields[i];
for (const field of fields) {
detailedError.output.payload[field] = request.route.settings.validate.errorFields[field];

@@ -119,0 +118,0 @@ }

@@ -5,3 +5,3 @@ {

"homepage": "https://hapijs.com",
"version": "17.5.4",
"version": "17.5.5",
"repository": {

@@ -45,3 +45,3 @@ "type": "git",

"inert": "5.x.x",
"lab": "15.x.x",
"lab": "16.x.x",
"vision": "5.x.x",

@@ -48,0 +48,0 @@ "wreck": "14.x.x"

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