pax_global_header00006660000000000000000000000064130664635370014527gustar00rootroot0000000000000052 comment=3d30c69faf6733a1604b400df71ed4781799a032 boom-4.3.1/000077500000000000000000000000001306646353700124705ustar00rootroot00000000000000boom-4.3.1/.gitignore000066400000000000000000000002621306646353700144600ustar00rootroot00000000000000.idea *.iml npm-debug.log dump.rdb node_modules results.tap results.xml npm-shrinkwrap.json config.json .DS_Store */.DS_Store */*/.DS_Store ._* */._* */*/._* coverage.* lib-cov boom-4.3.1/.npmignore000066400000000000000000000000111306646353700144570ustar00rootroot00000000000000* !lib/**boom-4.3.1/.travis.yml000077500000000000000000000001141306646353700146000ustar00rootroot00000000000000language: node_js node_js: - "4" - "6" - "7" - "node" sudo: false boom-4.3.1/CONTRIBUTING.md000066400000000000000000000001611306646353700147170ustar00rootroot00000000000000Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/.github/CONTRIBUTING.md). boom-4.3.1/LICENSE000077500000000000000000000032141306646353700135000ustar00rootroot00000000000000Copyright (c) 2012-2017, Project contributors. Copyright (c) 2012-2014, Walmart. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * The complete list of contributors can be found at: https://github.com/hapijs/boom/graphs/contributors boom-4.3.1/README.md000077500000000000000000000454251306646353700137640ustar00rootroot00000000000000![boom Logo](https://raw.github.com/hapijs/boom/master/images/boom.png) HTTP-friendly error objects [![Build Status](https://secure.travis-ci.org/hapijs/boom.svg)](http://travis-ci.org/hapijs/boom) [![Current Version](https://img.shields.io/npm/v/boom.svg)](https://www.npmjs.com/package/boom) Lead Maintainer: [Adam Bretz](https://github.com/arb) - [Boom](#boom) - [Helper Methods](#helper-methods) - [`wrap(error, [statusCode], [message])`](#wraperror-statuscode-message) - [`create(statusCode, [message], [data])`](#createstatuscode-message-data) - [HTTP 4xx Errors](#http-4xx-errors) - [`Boom.badRequest([message], [data])`](#boombadrequestmessage-data) - [`Boom.unauthorized([message], [scheme], [attributes])`](#boomunauthorizedmessage-scheme-attributes) - [`Boom.paymentRequired([message], [data])`](#boompaymentrequiredmessage-data) - [`Boom.forbidden([message], [data])`](#boomforbiddenmessage-data) - [`Boom.notFound([message], [data])`](#boomnotfoundmessage-data) - [`Boom.methodNotAllowed([message], [data], [allow])`](#boommethodnotallowedmessage-data-allow) - [`Boom.notAcceptable([message], [data])`](#boomnotacceptablemessage-data) - [`Boom.proxyAuthRequired([message], [data])`](#boomproxyauthrequiredmessage-data) - [`Boom.clientTimeout([message], [data])`](#boomclienttimeoutmessage-data) - [`Boom.conflict([message], [data])`](#boomconflictmessage-data) - [`Boom.resourceGone([message], [data])`](#boomresourcegonemessage-data) - [`Boom.lengthRequired([message], [data])`](#boomlengthrequiredmessage-data) - [`Boom.preconditionFailed([message], [data])`](#boompreconditionfailedmessage-data) - [`Boom.entityTooLarge([message], [data])`](#boomentitytoolargemessage-data) - [`Boom.uriTooLong([message], [data])`](#boomuritoolongmessage-data) - [`Boom.unsupportedMediaType([message], [data])`](#boomunsupportedmediatypemessage-data) - [`Boom.rangeNotSatisfiable([message], [data])`](#boomrangenotsatisfiablemessage-data) - [`Boom.expectationFailed([message], [data])`](#boomexpectationfailedmessage-data) - [`Boom.teapot([message], [data])`](#boomteapotmessage-data) - [`Boom.badData([message], [data])`](#boombaddatamessage-data) - [`Boom.locked([message], [data])`](#boomlockedmessage-data) - [`Boom.preconditionRequired([message], [data])`](#boompreconditionrequiredmessage-data) - [`Boom.tooManyRequests([message], [data])`](#boomtoomanyrequestsmessage-data) - [`Boom.illegal([message], [data])`](#boomillegalmessage-data) - [HTTP 5xx Errors](#http-5xx-errors) - [`Boom.badImplementation([message], [data])` - (*alias: `internal`*)](#boombadimplementationmessage-data---alias-internal) - [`Boom.notImplemented([message], [data])`](#boomnotimplementedmessage-data) - [`Boom.badGateway([message], [data])`](#boombadgatewaymessage-data) - [`Boom.serverUnavailable([message], [data])`](#boomserverunavailablemessage-data) - [`Boom.gatewayTimeout([message], [data])`](#boomgatewaytimeoutmessage-data) - [F.A.Q.](#faq) # Boom **boom** provides a set of utilities for returning HTTP errors. Each utility returns a `Boom` error response object (instance of `Error`) which includes the following properties: - `isBoom` - if `true`, indicates this is a `Boom` object instance. - `isServer` - convenience bool indicating status code >= 500. - `message` - the error message. - `output` - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: - `statusCode` - the HTTP status code (typically 4xx or 5xx). - `headers` - an object containing any HTTP headers where each key is a header name and value is the header content. - `payload` - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if `reformat()` is called. Any content allowed and by default includes the following content: - `statusCode` - the HTTP status code, derived from `error.output.statusCode`. - `error` - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from `statusCode`. - `message` - the error message derived from `error.message`. - inherited `Error` properties. The `Boom` object also supports the following method: - `reformat()` - rebuilds `error.output` using the other object properties. ## Helper Methods ### `wrap(error, [statusCode], [message])` Decorates an error with the **boom** properties where: - `error` - the error object to wrap. If `error` is already a **boom** object, returns back the same object. - `statusCode` - optional HTTP status code. Defaults to `500`. - `message` - optional message string. If the error already has a message, it adds the message as a prefix. Defaults to no message. ```js var error = new Error('Unexpected input'); Boom.wrap(error, 400); ``` ### `create(statusCode, [message], [data])` Generates an `Error` object with the **boom** decorations where: - `statusCode` - an HTTP error code number. Must be greater or equal 400. - `message` - optional message string. - `data` - additional error data set to `error.data` property. ```js var error = Boom.create(400, 'Bad request', { timestamp: Date.now() }); ``` ## HTTP 4xx Errors ### `Boom.badRequest([message], [data])` Returns a 400 Bad Request error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.badRequest('invalid query'); ``` Generates the following response payload: ```json { "statusCode": 400, "error": "Bad Request", "message": "invalid query" } ``` ### `Boom.unauthorized([message], [scheme], [attributes])` Returns a 401 Unauthorized error where: - `message` - optional message. - `scheme` can be one of the following: - an authentication scheme name - an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header. - `attributes` - an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when `scheme` is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the `attributes` key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. `null` and `undefined` will be replaced with an empty string. If `attributes` is set, `message` will be used as the 'error' segment of the 'WWW-Authenticate' header. If `message` is unset, the 'error' segment of the header will not be present and `isMissing` will be true on the error object. If either `scheme` or `attributes` are set, the resultant `Boom` object will have the 'WWW-Authenticate' header set for the response. ```js Boom.unauthorized('invalid password'); ``` Generates the following response: ```json "payload": { "statusCode": 401, "error": "Unauthorized", "message": "invalid password" }, "headers" {} ``` ```js Boom.unauthorized('invalid password', 'sample'); ``` Generates the following response: ```json "payload": { "statusCode": 401, "error": "Unauthorized", "message": "invalid password", "attributes": { "error": "invalid password" } }, "headers" { "WWW-Authenticate": "sample error=\"invalid password\"" } ``` ```js Boom.unauthorized(null, 'Negotiate', 'VGhpcyBpcyBhIHRlc3QgdG9rZW4='); ``` Generates the following response: ```json "payload": { "statusCode": 401, "error": "Unauthorized", "attributes": "VGhpcyBpcyBhIHRlc3QgdG9rZW4=" }, "headers" { "WWW-Authenticate": "Negotiate VGhpcyBpcyBhIHRlc3QgdG9rZW4=" } ``` ```js Boom.unauthorized('invalid password', 'sample', { ttl: 0, cache: null, foo: 'bar' }); ``` Generates the following response: ```json "payload": { "statusCode": 401, "error": "Unauthorized", "message": "invalid password", "attributes": { "error": "invalid password", "ttl": 0, "cache": "", "foo": "bar" } }, "headers" { "WWW-Authenticate": "sample ttl=\"0\", cache=\"\", foo=\"bar\", error=\"invalid password\"" } ``` ### `Boom.paymentRequired([message], [data])` Returns a 402 Payment Required error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.paymentRequired('bandwidth used'); ``` Generates the following response payload: ```json { "statusCode": 402, "error": "Payment Required", "message": "bandwidth used" } ``` ### `Boom.forbidden([message], [data])` Returns a 403 Forbidden error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.forbidden('try again some time'); ``` Generates the following response payload: ```json { "statusCode": 403, "error": "Forbidden", "message": "try again some time" } ``` ### `Boom.notFound([message], [data])` Returns a 404 Not Found error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.notFound('missing'); ``` Generates the following response payload: ```json { "statusCode": 404, "error": "Not Found", "message": "missing" } ``` ### `Boom.methodNotAllowed([message], [data], [allow])` Returns a 405 Method Not Allowed error where: - `message` - optional message. - `data` - optional additional error data. - `allow` - optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header. ```js Boom.methodNotAllowed('that method is not allowed'); ``` Generates the following response payload: ```json { "statusCode": 405, "error": "Method Not Allowed", "message": "that method is not allowed" } ``` ### `Boom.notAcceptable([message], [data])` Returns a 406 Not Acceptable error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.notAcceptable('unacceptable'); ``` Generates the following response payload: ```json { "statusCode": 406, "error": "Not Acceptable", "message": "unacceptable" } ``` ### `Boom.proxyAuthRequired([message], [data])` Returns a 407 Proxy Authentication Required error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.proxyAuthRequired('auth missing'); ``` Generates the following response payload: ```json { "statusCode": 407, "error": "Proxy Authentication Required", "message": "auth missing" } ``` ### `Boom.clientTimeout([message], [data])` Returns a 408 Request Time-out error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.clientTimeout('timed out'); ``` Generates the following response payload: ```json { "statusCode": 408, "error": "Request Time-out", "message": "timed out" } ``` ### `Boom.conflict([message], [data])` Returns a 409 Conflict error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.conflict('there was a conflict'); ``` Generates the following response payload: ```json { "statusCode": 409, "error": "Conflict", "message": "there was a conflict" } ``` ### `Boom.resourceGone([message], [data])` Returns a 410 Gone error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.resourceGone('it is gone'); ``` Generates the following response payload: ```json { "statusCode": 410, "error": "Gone", "message": "it is gone" } ``` ### `Boom.lengthRequired([message], [data])` Returns a 411 Length Required error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.lengthRequired('length needed'); ``` Generates the following response payload: ```json { "statusCode": 411, "error": "Length Required", "message": "length needed" } ``` ### `Boom.preconditionFailed([message], [data])` Returns a 412 Precondition Failed error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.preconditionFailed(); ``` Generates the following response payload: ```json { "statusCode": 412, "error": "Precondition Failed" } ``` ### `Boom.entityTooLarge([message], [data])` Returns a 413 Request Entity Too Large error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.entityTooLarge('too big'); ``` Generates the following response payload: ```json { "statusCode": 413, "error": "Request Entity Too Large", "message": "too big" } ``` ### `Boom.uriTooLong([message], [data])` Returns a 414 Request-URI Too Large error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.uriTooLong('uri is too long'); ``` Generates the following response payload: ```json { "statusCode": 414, "error": "Request-URI Too Large", "message": "uri is too long" } ``` ### `Boom.unsupportedMediaType([message], [data])` Returns a 415 Unsupported Media Type error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.unsupportedMediaType('that media is not supported'); ``` Generates the following response payload: ```json { "statusCode": 415, "error": "Unsupported Media Type", "message": "that media is not supported" } ``` ### `Boom.rangeNotSatisfiable([message], [data])` Returns a 416 Requested Range Not Satisfiable error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.rangeNotSatisfiable(); ``` Generates the following response payload: ```json { "statusCode": 416, "error": "Requested Range Not Satisfiable" } ``` ### `Boom.expectationFailed([message], [data])` Returns a 417 Expectation Failed error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.expectationFailed('expected this to work'); ``` Generates the following response payload: ```json { "statusCode": 417, "error": "Expectation Failed", "message": "expected this to work" } ``` ### `Boom.teapot([message], [data])` Returns a 418 I'm a Teapot error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.teapot('sorry, no coffee...'); ``` Generates the following response payload: ```json { "statusCode": 418, "error": "I'm a Teapot", "message": "Sorry, no coffee..." } ``` ### `Boom.badData([message], [data])` Returns a 422 Unprocessable Entity error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.badData('your data is bad and you should feel bad'); ``` Generates the following response payload: ```json { "statusCode": 422, "error": "Unprocessable Entity", "message": "your data is bad and you should feel bad" } ``` ### `Boom.locked([message], [data])` Returns a 423 Locked error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.locked('this resource has been locked'); ``` Generates the following response payload: ```json { "statusCode": 423, "error": "Locked", "message": "this resource has been locked" } ``` ### `Boom.preconditionRequired([message], [data])` Returns a 428 Precondition Required error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.preconditionRequired('you must supply an If-Match header'); ``` Generates the following response payload: ```json { "statusCode": 428, "error": "Precondition Required", "message": "you must supply an If-Match header" } ``` ### `Boom.tooManyRequests([message], [data])` Returns a 429 Too Many Requests error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.tooManyRequests('you have exceeded your request limit'); ``` Generates the following response payload: ```json { "statusCode": 429, "error": "Too Many Requests", "message": "you have exceeded your request limit" } ``` ### `Boom.illegal([message], [data])` Returns a 451 Unavailable For Legal Reasons error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.illegal('you are not permitted to view this resource for legal reasons'); ``` Generates the following response payload: ```json { "statusCode": 451, "error": "Unavailable For Legal Reasons", "message": "you are not permitted to view this resource for legal reasons" } ``` ## HTTP 5xx Errors All 500 errors hide your message from the end user. Your message is recorded in the server log. ### `Boom.badImplementation([message], [data])` - (*alias: `internal`*) Returns a 500 Internal Server Error error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.badImplementation('terrible implementation'); ``` Generates the following response payload: ```json { "statusCode": 500, "error": "Internal Server Error", "message": "An internal server error occurred" } ``` ### `Boom.notImplemented([message], [data])` Returns a 501 Not Implemented error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.notImplemented('method not implemented'); ``` Generates the following response payload: ```json { "statusCode": 501, "error": "Not Implemented", "message": "method not implemented" } ``` ### `Boom.badGateway([message], [data])` Returns a 502 Bad Gateway error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.badGateway('that is a bad gateway'); ``` Generates the following response payload: ```json { "statusCode": 502, "error": "Bad Gateway", "message": "that is a bad gateway" } ``` ### `Boom.serverUnavailable([message], [data])` Returns a 503 Service Unavailable error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.serverUnavailable('unavailable'); ``` Generates the following response payload: ```json { "statusCode": 503, "error": "Service Unavailable", "message": "unavailable" } ``` ### `Boom.gatewayTimeout([message], [data])` Returns a 504 Gateway Time-out error where: - `message` - optional message. - `data` - optional additional error data. ```js Boom.gatewayTimeout(); ``` Generates the following response payload: ```json { "statusCode": 504, "error": "Gateway Time-out" } ``` ## F.A.Q. **Q** How do I include extra information in my responses? `output.payload` is missing `data`, what gives? **A** There is a reason the values passed back in the response payloads are pretty locked down. It's mostly for security and to not leak any important information back to the client. This means you will need to put in a little more effort to include extra information about your custom error. Check out the ["Error transformation"](https://github.com/hapijs/hapi/blob/master/API.md#error-transformation) section in the hapi documentation. --- boom-4.3.1/generate-toc.js000066400000000000000000000011411306646353700154000ustar00rootroot00000000000000'use strict'; // Load modules const Toc = require('markdown-toc'); const Fs = require('fs'); // Declare internals const internals = { filename: './README.md' }; internals.generate = function () { const api = Fs.readFileSync(internals.filename, 'utf8'); const tocOptions = { bullets: '-', slugify: function (text) { return text.toLowerCase() .replace(/\s/g, '-') .replace(/[^\w-]/g, ''); } }; const output = Toc.insert(api, tocOptions); Fs.writeFileSync(internals.filename, output); }; internals.generate(); boom-4.3.1/images/000077500000000000000000000000001306646353700137355ustar00rootroot00000000000000boom-4.3.1/images/boom.png000077500000000000000000000714471306646353700154170ustar00rootroot00000000000000PNG  IHDR9vZ=B pHYs+ OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.k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error.hasOwnProperty('data')) { error.data = null; } error.output = { statusCode: numberCode, payload: {}, headers: {} }; error.reformat = internals.reformat; error.reformat(); if (!message && !error.message) { message = error.output.payload.error; } if (message) { error.message = (message + (error.message ? ': ' + error.message : '')); } return error; }; internals.reformat = function () { this.output.payload.statusCode = this.output.statusCode; this.output.payload.error = internals.STATUS_CODES[this.output.statusCode] || 'Unknown'; if (this.output.statusCode === 500) { this.output.payload.message = 'An internal server error occurred'; // Hide actual error from user } else if (this.message) { this.output.payload.message = this.message; } }; // 4xx Client Errors exports.badRequest = function (message, data) { return internals.create(400, message, data, exports.badRequest); }; exports.unauthorized = function (message, scheme, attributes) { // Or function (message, wwwAuthenticate[]) const err = internals.create(401, message, undefined, exports.unauthorized); if (!scheme) { return err; } let wwwAuthenticate = ''; if (typeof scheme === 'string') { // function (message, scheme, attributes) wwwAuthenticate = scheme; if (attributes || message) { err.output.payload.attributes = {}; } if (attributes) { if (typeof attributes === 'string') { wwwAuthenticate = wwwAuthenticate + ' ' + Hoek.escapeHeaderAttribute(attributes); err.output.payload.attributes = attributes; } else { const names = Object.keys(attributes); for (let i = 0; i < names.length; ++i) { const name = names[i]; if (i) { wwwAuthenticate = wwwAuthenticate + ','; } let value = attributes[name]; if (value === null || value === undefined) { // Value can be zero value = ''; } wwwAuthenticate = wwwAuthenticate + ' ' + name + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"'; err.output.payload.attributes[name] = value; } } } if (message) { if (attributes) { wwwAuthenticate = wwwAuthenticate + ','; } wwwAuthenticate = wwwAuthenticate + ' error="' + Hoek.escapeHeaderAttribute(message) + '"'; err.output.payload.attributes.error = message; } else { err.isMissing = true; } } else { // function (message, wwwAuthenticate[]) const wwwArray = scheme; for (let i = 0; i < wwwArray.length; ++i) { if (i) { wwwAuthenticate = wwwAuthenticate + ', '; } wwwAuthenticate = wwwAuthenticate + wwwArray[i]; } } err.output.headers['WWW-Authenticate'] = wwwAuthenticate; return err; }; exports.paymentRequired = function (message, data) { return internals.create(402, message, data, exports.paymentRequired); }; exports.forbidden = function (message, data) { return internals.create(403, message, data, exports.forbidden); }; exports.notFound = function (message, data) { return internals.create(404, message, data, exports.notFound); }; exports.methodNotAllowed = function (message, data, allow) { const err = internals.create(405, message, data, exports.methodNotAllowed); if (typeof allow === 'string') { allow = [allow]; } if (Array.isArray(allow)) { err.output.headers.Allow = allow.join(', '); } return err; }; exports.notAcceptable = function (message, data) { return internals.create(406, message, data, exports.notAcceptable); }; exports.proxyAuthRequired = function (message, data) { return internals.create(407, message, data, exports.proxyAuthRequired); }; exports.clientTimeout = function (message, data) { return internals.create(408, message, data, exports.clientTimeout); }; exports.conflict = function (message, data) { return internals.create(409, message, data, exports.conflict); }; exports.resourceGone = function (message, data) { return internals.create(410, message, data, exports.resourceGone); }; exports.lengthRequired = function (message, data) { return internals.create(411, message, data, exports.lengthRequired); }; exports.preconditionFailed = function (message, data) { return internals.create(412, message, data, exports.preconditionFailed); }; exports.entityTooLarge = function (message, data) { return internals.create(413, message, data, exports.entityTooLarge); }; exports.uriTooLong = function (message, data) { return internals.create(414, message, data, exports.uriTooLong); }; exports.unsupportedMediaType = function (message, data) { return internals.create(415, message, data, exports.unsupportedMediaType); }; exports.rangeNotSatisfiable = function (message, data) { return internals.create(416, message, data, exports.rangeNotSatisfiable); }; exports.expectationFailed = function (message, data) { return internals.create(417, message, data, exports.expectationFailed); }; exports.teapot = function (message, data) { return internals.create(418, message, data, exports.teapot); }; exports.badData = function (message, data) { return internals.create(422, message, data, exports.badData); }; exports.locked = function (message, data) { return internals.create(423, message, data, exports.locked); }; exports.preconditionRequired = function (message, data) { return internals.create(428, message, data, exports.preconditionRequired); }; exports.tooManyRequests = function (message, data) { return internals.create(429, message, data, exports.tooManyRequests); }; exports.illegal = function (message, data) { return internals.create(451, message, data, exports.illegal); }; // 5xx Server Errors exports.internal = function (message, data, statusCode) { return internals.serverError(message, data, statusCode, exports.internal); }; internals.serverError = function (message, data, statusCode, ctor) { let error; if (data instanceof Error) { error = exports.wrap(data, statusCode, message); } else { error = internals.create(statusCode || 500, message, undefined, ctor); error.data = data; } return error; }; exports.notImplemented = function (message, data) { return internals.serverError(message, data, 501, exports.notImplemented); }; exports.badGateway = function (message, data) { return internals.serverError(message, data, 502, exports.badGateway); }; exports.serverUnavailable = function (message, data) { return internals.serverError(message, data, 503, exports.serverUnavailable); }; exports.gatewayTimeout = function (message, data) { return internals.serverError(message, data, 504, exports.gatewayTimeout); }; exports.badImplementation = function (message, data) { const err = internals.serverError(message, data, 500, exports.badImplementation); err.isDeveloperError = true; return err; }; boom-4.3.1/package.json000066400000000000000000000011721306646353700147570ustar00rootroot00000000000000{ "name": "boom", "description": "HTTP-friendly error objects", "version": "4.3.1", "repository": "git://github.com/hapijs/boom", "main": "lib/index.js", "keywords": [ "error", "http" ], "engines": { "node": ">=4.0.0" }, "dependencies": { "hoek": "4.x.x" }, "devDependencies": { "code": "4.x.x", "lab": "13.x.x", "markdown-toc": "0.12.x" }, "scripts": { "test": "lab -a code -t 100 -L -v", "test-cov-html": "lab -a code -r html -o coverage.html -L", "toc": "node generate-toc.js", "version": "npm run toc && git add README.md" }, "license": "BSD-3-Clause" } boom-4.3.1/test/000077500000000000000000000000001306646353700134475ustar00rootroot00000000000000boom-4.3.1/test/index.js000077500000000000000000000520351306646353700151240ustar00rootroot00000000000000'use strict'; // Load modules const Code = require('code'); const Boom = require('../lib'); const Lab = require('lab'); // Declare internals const internals = {}; // Test shortcuts const lab = exports.lab = Lab.script(); const describe = lab.describe; const it = lab.it; const expect = Code.expect; it('returns the same object when already boom', (done) => { const error = Boom.badRequest(); expect(error).to.equal(Boom.wrap(error)); expect(error).to.equal(Boom.wrap(error, null, null)); done(); }); it('errors on wrap with boom error and additional arguments', (done) => { const error = Boom.badRequest('Something'); expect(() => Boom.wrap(error, 401)).to.throw('Cannot provide statusCode or message with boom error'); expect(() => Boom.wrap(error, 402, 'Else')).to.throw('Cannot provide statusCode or message with boom error'); expect(() => Boom.wrap(error, undefined, 'Else')).to.throw('Cannot provide statusCode or message with boom error'); done(); }); it('returns an error with info when constructed using another error', (done) => { const error = new Error('ka-boom'); error.xyz = 123; const err = Boom.wrap(error); expect(err.xyz).to.equal(123); expect(err.message).to.equal('ka-boom'); expect(err.output).to.equal({ statusCode: 500, payload: { statusCode: 500, error: 'Internal Server Error', message: 'An internal server error occurred' }, headers: {} }); expect(err.data).to.equal(null); done(); }); it('does not override data when constructed using another error', (done) => { const error = new Error('ka-boom'); error.data = { useful: 'data' }; const err = Boom.wrap(error); expect(err.data).to.equal(error.data); done(); }); it('sets new message when none exists', (done) => { const error = new Error(); const wrapped = Boom.wrap(error, 400, 'something bad'); expect(wrapped.message).to.equal('something bad'); done(); }); it('throws when statusCode is not a number', (done) => { expect(() => { Boom.create('x'); }).to.throw('First argument must be a number (400+): x'); done(); }); it('will cast a number-string to an integer', (done) => { const codes = [ { input: '404', result: 404 }, { input: '404.1', result: 404 }, { input: 400, result: 400 }, { input: 400.123, result: 400 } ]; for (let i = 0; i < codes.length; ++i) { const code = codes[i]; const err = Boom.create(code.input); expect(err.output.statusCode).to.equal(code.result); } done(); }); it('throws when statusCode is not finite', (done) => { expect(() => { Boom.create(1 / 0); }).to.throw('First argument must be a number (400+): null'); done(); }); it('sets error code to unknown', (done) => { const err = Boom.create(999); expect(err.output.payload.error).to.equal('Unknown'); done(); }); describe('create()', () => { it('does not sets null message', (done) => { const error = Boom.unauthorized(null); expect(error.output.payload.message).to.not.exist(); expect(error.isServer).to.be.false(); done(); }); it('sets message and data', (done) => { const error = Boom.badRequest('Missing data', { type: 'user' }); expect(error.data.type).to.equal('user'); expect(error.output.payload.message).to.equal('Missing data'); done(); }); }); describe('isBoom()', () => { it('returns true for Boom object', (done) => { expect(Boom.badRequest().isBoom).to.equal(true); done(); }); it('returns false for Error object', (done) => { expect((new Error()).isBoom).to.not.exist(); done(); }); }); describe('badRequest()', () => { it('returns a 400 error statusCode', (done) => { const error = Boom.badRequest(); expect(error.output.statusCode).to.equal(400); expect(error.isServer).to.be.false(); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.badRequest('my message').message).to.equal('my message'); done(); }); it('sets the message to HTTP status if none provided', (done) => { expect(Boom.badRequest().message).to.equal('Bad Request'); done(); }); }); describe('unauthorized()', () => { it('returns a 401 error statusCode', (done) => { const err = Boom.unauthorized(); expect(err.output.statusCode).to.equal(401); expect(err.output.headers).to.equal({}); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.unauthorized('my message').message).to.equal('my message'); done(); }); it('returns a WWW-Authenticate header when passed a scheme', (done) => { const err = Boom.unauthorized('boom', 'Test'); expect(err.output.statusCode).to.equal(401); expect(err.output.headers['WWW-Authenticate']).to.equal('Test error="boom"'); done(); }); it('returns a WWW-Authenticate header set to the schema array value', (done) => { const err = Boom.unauthorized(null, ['Test', 'one', 'two']); expect(err.output.statusCode).to.equal(401); expect(err.output.headers['WWW-Authenticate']).to.equal('Test, one, two'); done(); }); it('returns a WWW-Authenticate header when passed a scheme and attributes', (done) => { const err = Boom.unauthorized('boom', 'Test', { a: 1, b: 'something', c: null, d: 0 }); expect(err.output.statusCode).to.equal(401); expect(err.output.headers['WWW-Authenticate']).to.equal('Test a="1", b="something", c="", d="0", error="boom"'); expect(err.output.payload.attributes).to.equal({ a: 1, b: 'something', c: '', d: 0, error: 'boom' }); done(); }); it('returns a WWW-Authenticate header from string input instead of object', (done) => { const err = Boom.unauthorized(null, 'Negotiate', 'VGhpcyBpcyBhIHRlc3QgdG9rZW4='); expect(err.output.statusCode).to.equal(401); expect(err.output.headers['WWW-Authenticate']).to.equal('Negotiate VGhpcyBpcyBhIHRlc3QgdG9rZW4='); expect(err.output.payload.attributes).to.equal('VGhpcyBpcyBhIHRlc3QgdG9rZW4='); done(); }); it('returns a WWW-Authenticate header when passed attributes, missing error', (done) => { const err = Boom.unauthorized(null, 'Test', { a: 1, b: 'something', c: null, d: 0 }); expect(err.output.statusCode).to.equal(401); expect(err.output.headers['WWW-Authenticate']).to.equal('Test a="1", b="something", c="", d="0"'); expect(err.isMissing).to.equal(true); done(); }); it('sets the isMissing flag when error message is empty', (done) => { const err = Boom.unauthorized('', 'Basic'); expect(err.isMissing).to.equal(true); done(); }); it('does not set the isMissing flag when error message is not empty', (done) => { const err = Boom.unauthorized('message', 'Basic'); expect(err.isMissing).to.equal(undefined); done(); }); it('sets a WWW-Authenticate when passed as an array', (done) => { const err = Boom.unauthorized('message', ['Basic', 'Example e="1"', 'Another x="3", y="4"']); expect(err.output.headers['WWW-Authenticate']).to.equal('Basic, Example e="1", Another x="3", y="4"'); done(); }); }); describe('paymentRequired()', () => { it('returns a 402 error statusCode', (done) => { expect(Boom.paymentRequired().output.statusCode).to.equal(402); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.paymentRequired('my message').message).to.equal('my message'); done(); }); it('sets the message to HTTP status if none provided', (done) => { expect(Boom.paymentRequired().message).to.equal('Payment Required'); done(); }); }); describe('methodNotAllowed()', () => { it('returns a 405 error statusCode', (done) => { expect(Boom.methodNotAllowed().output.statusCode).to.equal(405); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.methodNotAllowed('my message').message).to.equal('my message'); done(); }); it('returns an Allow header when passed a string', (done) => { const err = Boom.methodNotAllowed('my message', null, 'GET'); expect(err.output.statusCode).to.equal(405); expect(err.output.headers.Allow).to.equal('GET'); done(); }); it('returns an Allow header when passed an array', (done) => { const err = Boom.methodNotAllowed('my message', null, ['GET', 'POST']); expect(err.output.statusCode).to.equal(405); expect(err.output.headers.Allow).to.equal('GET, POST'); done(); }); }); describe('notAcceptable()', () => { it('returns a 406 error statusCode', (done) => { expect(Boom.notAcceptable().output.statusCode).to.equal(406); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.notAcceptable('my message').message).to.equal('my message'); done(); }); }); describe('proxyAuthRequired()', () => { it('returns a 407 error statusCode', (done) => { expect(Boom.proxyAuthRequired().output.statusCode).to.equal(407); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.proxyAuthRequired('my message').message).to.equal('my message'); done(); }); }); describe('clientTimeout()', () => { it('returns a 408 error statusCode', (done) => { expect(Boom.clientTimeout().output.statusCode).to.equal(408); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.clientTimeout('my message').message).to.equal('my message'); done(); }); }); describe('conflict()', () => { it('returns a 409 error statusCode', (done) => { expect(Boom.conflict().output.statusCode).to.equal(409); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.conflict('my message').message).to.equal('my message'); done(); }); }); describe('resourceGone()', () => { it('returns a 410 error statusCode', (done) => { expect(Boom.resourceGone().output.statusCode).to.equal(410); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.resourceGone('my message').message).to.equal('my message'); done(); }); }); describe('lengthRequired()', () => { it('returns a 411 error statusCode', (done) => { expect(Boom.lengthRequired().output.statusCode).to.equal(411); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.lengthRequired('my message').message).to.equal('my message'); done(); }); }); describe('preconditionFailed()', () => { it('returns a 412 error statusCode', (done) => { expect(Boom.preconditionFailed().output.statusCode).to.equal(412); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.preconditionFailed('my message').message).to.equal('my message'); done(); }); }); describe('entityTooLarge()', () => { it('returns a 413 error statusCode', (done) => { expect(Boom.entityTooLarge().output.statusCode).to.equal(413); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.entityTooLarge('my message').message).to.equal('my message'); done(); }); }); describe('uriTooLong()', () => { it('returns a 414 error statusCode', (done) => { expect(Boom.uriTooLong().output.statusCode).to.equal(414); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.uriTooLong('my message').message).to.equal('my message'); done(); }); }); describe('unsupportedMediaType()', () => { it('returns a 415 error statusCode', (done) => { expect(Boom.unsupportedMediaType().output.statusCode).to.equal(415); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.unsupportedMediaType('my message').message).to.equal('my message'); done(); }); }); describe('rangeNotSatisfiable()', () => { it('returns a 416 error statusCode', (done) => { expect(Boom.rangeNotSatisfiable().output.statusCode).to.equal(416); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.rangeNotSatisfiable('my message').message).to.equal('my message'); done(); }); }); describe('expectationFailed()', () => { it('returns a 417 error statusCode', (done) => { expect(Boom.expectationFailed().output.statusCode).to.equal(417); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.expectationFailed('my message').message).to.equal('my message'); done(); }); }); describe('teapot()', () => { it('returns a 418 error statusCode', (done) => { expect(Boom.teapot().output.statusCode).to.equal(418); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.teapot('Sorry, no coffee...').message).to.equal('Sorry, no coffee...'); done(); }); }); describe('badData()', () => { it('returns a 422 error statusCode', (done) => { expect(Boom.badData().output.statusCode).to.equal(422); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.badData('my message').message).to.equal('my message'); done(); }); }); describe('locked()', () => { it('returns a 423 error statusCode', (done) => { expect(Boom.locked().output.statusCode).to.equal(423); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.locked('my message').message).to.equal('my message'); done(); }); }); describe('preconditionRequired()', () => { it('returns a 428 error statusCode', (done) => { expect(Boom.preconditionRequired().output.statusCode).to.equal(428); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.preconditionRequired('my message').message).to.equal('my message'); done(); }); }); describe('tooManyRequests()', () => { it('returns a 429 error statusCode', (done) => { expect(Boom.tooManyRequests().output.statusCode).to.equal(429); done(); }); it('sets the message with the passed-in message', (done) => { expect(Boom.tooManyRequests('my message').message).to.equal('my message'); done(); }); }); describe('illegal()', () => { it('returns a 451 error statusCode', (done) => { expect(Boom.illegal().output.statusCode).to.equal(451); done(); }); it('sets the message with the passed-in message', (done) => { expect(Boom.illegal('my message').message).to.equal('my message'); done(); }); }); describe('serverUnavailable()', () => { it('returns a 503 error statusCode', (done) => { expect(Boom.serverUnavailable().output.statusCode).to.equal(503); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.serverUnavailable('my message').message).to.equal('my message'); done(); }); }); describe('forbidden()', () => { it('returns a 403 error statusCode', (done) => { expect(Boom.forbidden().output.statusCode).to.equal(403); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.forbidden('my message').message).to.equal('my message'); done(); }); }); describe('notFound()', () => { it('returns a 404 error statusCode', (done) => { expect(Boom.notFound().output.statusCode).to.equal(404); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.notFound('my message').message).to.equal('my message'); done(); }); }); describe('internal()', () => { it('returns a 500 error statusCode', (done) => { expect(Boom.internal().output.statusCode).to.equal(500); done(); }); it('sets the message with the passed in message', (done) => { const err = Boom.internal('my message'); expect(err.message).to.equal('my message'); expect(err.isServer).to.true(); expect(err.output.payload.message).to.equal('An internal server error occurred'); done(); }); it('passes data on the callback if its passed in', (done) => { expect(Boom.internal('my message', { my: 'data' }).data.my).to.equal('data'); done(); }); it('returns an error with composite message', (done) => { try { x.foo(); } catch (err) { const boom = Boom.internal('Someting bad', err); expect(boom.message).to.equal('Someting bad: x is not defined'); expect(boom.isServer).to.be.true(); done(); } }); }); describe('notImplemented()', () => { it('returns a 501 error statusCode', (done) => { expect(Boom.notImplemented().output.statusCode).to.equal(501); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.notImplemented('my message').message).to.equal('my message'); done(); }); }); describe('badGateway()', () => { it('returns a 502 error statusCode', (done) => { expect(Boom.badGateway().output.statusCode).to.equal(502); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.badGateway('my message').message).to.equal('my message'); done(); }); }); describe('gatewayTimeout()', () => { it('returns a 504 error statusCode', (done) => { expect(Boom.gatewayTimeout().output.statusCode).to.equal(504); done(); }); it('sets the message with the passed in message', (done) => { expect(Boom.gatewayTimeout('my message').message).to.equal('my message'); done(); }); }); describe('badImplementation()', () => { it('returns a 500 error statusCode', (done) => { const err = Boom.badImplementation(); expect(err.output.statusCode).to.equal(500); expect(err.isDeveloperError).to.equal(true); expect(err.isServer).to.be.true(); done(); }); }); describe('stack trace', () => { it('should omit lib', (done) => { ['badRequest', 'unauthorized', 'forbidden', 'notFound', 'methodNotAllowed', 'notAcceptable', 'proxyAuthRequired', 'clientTimeout', 'conflict', 'resourceGone', 'lengthRequired', 'preconditionFailed', 'entityTooLarge', 'uriTooLong', 'unsupportedMediaType', 'rangeNotSatisfiable', 'expectationFailed', 'badData', 'preconditionRequired', 'tooManyRequests', // 500s 'internal', 'notImplemented', 'badGateway', 'serverUnavailable', 'gatewayTimeout', 'badImplementation' ].forEach((name) => { const err = Boom[name](); expect(err.stack).to.not.match(/\/lib\/index\.js/); }); done(); }); }); describe('method with error object instead of message', () => { [ 'badRequest', 'unauthorized', 'forbidden', 'notFound', 'methodNotAllowed', 'notAcceptable', 'proxyAuthRequired', 'clientTimeout', 'conflict', 'resourceGone', 'lengthRequired', 'preconditionFailed', 'entityTooLarge', 'uriTooLong', 'unsupportedMediaType', 'rangeNotSatisfiable', 'expectationFailed', 'badData', 'preconditionRequired', 'tooManyRequests', 'internal', 'notImplemented', 'badGateway', 'serverUnavailable', 'gatewayTimeout', 'badImplementation' ].forEach((name) => { it(`should allow \`Boom${name}(err)\` and preserve the error`, (done) => { const error = new Error('An example mongoose validation error'); error.name = 'ValidationError'; const err = Boom[name](error); expect(err.name).to.equal('ValidationError'); expect(err.message).to.equal('An example mongoose validation error'); done(); }); // exclude unauthorized if (name !== 'unauthorized') { it(`should allow \`Boom.${name}(err, data)\` and preserve the data`, (done) => { const error = new Error(); const err = Boom[name](error, { foo: 'bar' }); expect(err.data).to.equal({ foo: 'bar' }); done(); }); } }); });