Socket
Socket
Sign inDemoInstall

boom

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boom - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

59

lib/index.js

@@ -91,39 +91,44 @@ // Load modules

internals.Error.unauthorized = function (message, scheme, attributes) {
internals.Error.unauthorized = function (error, scheme, attributes) {
var err = new internals.Error(401, message);
var err = new internals.Error(401, error);
if (scheme) {
var wwwAuthenticate = scheme;
if (attributes) {
var names = Object.keys(attributes);
for (var i = 0, il = names.length; i < il; ++i) {
if (i) {
wwwAuthenticate += ',';
}
if (!scheme) {
return err;
}
var value = attributes[names[i]];
if (value === null ||
value === undefined) { // Value can be zero
var wwwAuthenticate = scheme;
if (attributes) {
var names = Object.keys(attributes);
for (var i = 0, il = names.length; i < il; ++i) {
if (i) {
wwwAuthenticate += ',';
}
value = '';
}
wwwAuthenticate += ' ' + names[i] + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"';
var value = attributes[names[i]];
if (value === null ||
value === undefined) { // Value can be zero
value = '';
}
wwwAuthenticate += ' ' + names[i] + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"';
}
}
if (message) {
if (attributes) {
wwwAuthenticate += ',';
}
wwwAuthenticate += ' error="' + Hoek.escapeHeaderAttribute(message) + '"';
if (error) {
if (attributes) {
wwwAuthenticate += ',';
}
wwwAuthenticate += ' error="' + Hoek.escapeHeaderAttribute(error) + '"';
}
else {
err.isMissing = true;
}
err.toResponse = function () {
err.toResponse = function () {
var response = internals.toResponse.call(this);
response.headers = { 'WWW-Authenticate': wwwAuthenticate };
return response;
};
}
var response = internals.toResponse.call(this);
response.headers = { 'WWW-Authenticate': wwwAuthenticate };
return response;
};

@@ -130,0 +135,0 @@ return err;

{
"name": "boom",
"description": "HTTP-friendly error objects",
"version": "0.0.2",
"version": "0.1.0",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",

@@ -6,0 +6,0 @@ "contributors": [],

@@ -87,2 +87,16 @@ // Load modules

});
it('sets the isMissing flag when error message is empty', function (done) {
var err = Boom.unauthorized('', 'Basic');
expect(err.isMissing).to.equal(true);
done();
});
it('does not set the isMissing flag when error message is not empty', function (done) {
var err = Boom.unauthorized('message', 'Basic');
expect(err.isMissing).to.equal(undefined);
done();
});
});

@@ -89,0 +103,0 @@

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