New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi

Package Overview
Dependencies
Maintainers
2
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 0.11.2 to 0.11.3

4

lib/auth/hawk.js

@@ -32,6 +32,6 @@ // Load modules

Hawk.authenticate(request.raw.req, this.settings.getCredentialsFunc, { hostHeaderName: this.settings.hostHeaderName }, function (err, credentials, ext) {
Hawk.authenticate(request.raw.req, this.settings.getCredentialsFunc, { hostHeaderName: this.settings.hostHeaderName }, function (err, credentials, attributes) {
if (credentials) {
credentials.authExt = ext;
credentials.authExt = attributes.ext;
}

@@ -38,0 +38,0 @@

// Load modules
var Http = require('http');
var NodeUtil = require('util');
var Utils = require('./utils');
var Boom = require('boom');

@@ -13,153 +11,2 @@

exports = module.exports = internals.Error = function (code, message) {
var self = this;
Utils.assert(this.constructor === internals.Error, 'Error must be instantiated using new');
Utils.assert(code instanceof Error || (!isNaN(parseFloat(code)) && isFinite(code) && code >= 400), 'code must be an Error or a number (400+)');
Error.call(this);
if (code instanceof Error) {
for (var d in code) {
if (code.hasOwnProperty(d)) {
this[d] = code[d];
}
}
this.code = this.code || 500;
this.name = code.name;
this.message = code.message || message;
if (code.message && message) {
this.info = message;
}
this.toResponse = code.toResponse; // Required if toRepsonse is a prototype function
}
else {
this.code = code;
this.message = message;
}
// Response format
if (!this.toResponse ||
typeof this.toResponse !== 'function') {
this.toResponse = internals.toResponse;
}
return this;
};
NodeUtil.inherits(internals.Error, Error);
internals.toResponse = function () {
// { code, payload, type, headers }
var response = {
code: this.code,
payload: {
error: Http.STATUS_CODES[this.code] || 'Unknown',
code: this.code,
message: this.message
}
};
for (var d in this) {
if (['error', 'code', 'message'].indexOf(d) === -1 &&
this.hasOwnProperty(d) &&
typeof this[d] !== 'function') {
response.payload[d] = this[d];
}
}
return response;
};
// Utilities
internals.Error.badRequest = function (message) {
return new internals.Error(400, message);
};
internals.Error.unauthorized = function (message, scheme) {
var err = new internals.Error(401, message);
if (scheme) {
var headers = { 'WWW-Authenticate': scheme };
err.toResponse = function () {
var response = internals.toResponse.call(this);
response.headers = headers;
return response;
};
}
return err;
};
internals.Error.forbidden = function (message) {
return new internals.Error(403, message);
};
internals.Error.notFound = function (message) {
return new internals.Error(404, message);
};
internals.Error.internal = function (message, data) {
var err = new internals.Error(500, message);
err.trace = Utils.displayStack(1);
err.data = data;
err.toResponse = function () {
var response = internals.toResponse.call(this);
response.payload.message = 'An internal server error occurred'; // Hide actual error from user
return response;
};
return err;
};
internals.Error.passThrough = function (code, payload, contentType, headers) {
var err = new internals.Error(500, 'Pass-through'); // 500 code is only used internally and is not exposed when sent
err.passThrough = {
code: code,
payload: payload,
type: contentType
};
err.toResponse = function () {
var response = {
code: code,
payload: payload,
type: contentType,
headers: headers
};
return response;
};
return err;
};
exports = module.exports = Boom;

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

"homepage": "http://hapijs.com",
"version": "0.11.2",
"version": "0.11.3",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",

@@ -26,2 +26,3 @@ "contributors": [

"hoek": "0.0.x",
"boom": "0.0.x",
"joi": "0.0.x",

@@ -31,3 +32,3 @@ "lout": "0.0.x",

"hapi-log": "0.0.x",
"hawk": "0.3.x",
"hawk": "0.5.x",
"shot": "0.0.x",

@@ -34,0 +35,0 @@ "oz": "0.0.x",

@@ -214,3 +214,3 @@ // Load modules

});
it('should not ask for credentials if no server auth configured', function (done) {

@@ -231,3 +231,3 @@

var options = { method: 'GET', url: '/noauth' };
server.inject(options, function (res) {

@@ -240,3 +240,3 @@

});
it('should ask for credentials if server has one default strategy', function (done) {

@@ -261,4 +261,4 @@

});
var validOptions = { method: 'GET', url: '/noauth', headers: { authorization: basicHeader('john', '12345') }};
var validOptions = { method: 'GET', url: '/noauth', headers: { authorization: basicHeader('john', '12345') } };
server.inject(validOptions, function (res) {

@@ -268,3 +268,3 @@

expect(res.statusCode).to.equal(200);
var invalidOptions = { method: 'GET', url: '/noauth' };

@@ -291,5 +291,5 @@ server.inject(invalidOptions, function (res) {

var server = new Hapi.Server('0.0.0.0', 8080, config);
var fn = function () {
server.addRoute({

@@ -306,7 +306,7 @@ path: '/noauth',

};
expect(fn).to.throw();
done();
});
it('should throw if server has strategies route refers to nonexistent strategy', function (done) {

@@ -327,5 +327,5 @@

var server = new Hapi.Server('0.0.0.0', 8080, config);
var fn = function () {
server.addRoute({

@@ -346,3 +346,3 @@ path: '/noauth',

};
expect(fn).to.throw();

@@ -506,3 +506,3 @@ done();

key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
algorithm: 'hmac-sha-256'
algorithm: 'sha256'
}

@@ -509,0 +509,0 @@ },

@@ -412,3 +412,3 @@ // Load modules

scheme: 'basic',
loadUserFunc: function () {}
loadUserFunc: function () { }
}

@@ -465,3 +465,3 @@ }

return callback(null, {id: 'walmart', password: 'walmart'})
return callback(null, { id: 'walmart', password: 'walmart' })
}

@@ -523,3 +523,3 @@ }

return callback(null, {id: 'walmart', password: 'walmart'})
return callback(null, { id: 'walmart', password: 'walmart' })
}

@@ -526,0 +526,0 @@ }

Sorry, the diff of this file is too big to display

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