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

http-auth-utils

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-auth-utils - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.codeclimate.yml

14

dist/index.js

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

function parseWWWAuthenticateHeader(header) {
var authMecanisms = arguments.length <= 1 || arguments[1] === undefined ? mecanisms : arguments[1];
var authMecanisms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : mecanisms;

@@ -91,8 +91,10 @@ var result = null;

};
return true;
}
return false;
});
if (result) {
return result;
if (!result) {
throw new _yerror2.default('E_UNKNOWN_AUTH_MECANISM', header);
}
throw new _yerror2.default('E_UNKNOWN_AUTH_MECANISM', header);
return result;
}

@@ -118,3 +120,3 @@

function parseAuthorizationHeader(header) {
var authMecanisms = arguments.length <= 1 || arguments[1] === undefined ? mecanisms : arguments[1];
var authMecanisms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : mecanisms;

@@ -129,3 +131,5 @@ var result = null;

};
return true;
}
return false;
});

@@ -132,0 +136,0 @@ if (result) {

@@ -16,5 +16,3 @@ 'use strict';

describe('index', function () {
describe('parseWWWAuthenticateHeader', function () {
it('should parse Basic headers', function () {

@@ -31,3 +29,2 @@ (0, _neatequal2.default)((0, _index.parseWWWAuthenticateHeader)('Basic realm="test"'), {

describe('parseAuthorizationHeader', function () {
it('should parse Basic headers', function () {

@@ -65,3 +62,2 @@ (0, _neatequal2.default)((0, _index.parseAuthorizationHeader)('Basic QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {

describe('mecanisms', function () {
it('should export bot DIGEST and BASIC mecanisms', function () {

@@ -68,0 +64,0 @@ _assert2.default.equal(_index.mecanisms.length, 3);

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

var BASIC = {
/**

@@ -87,8 +86,6 @@ * The Basic auth mecanism prefix.

var _BASIC$decodeHash = BASIC.decodeHash(rest);
var _BASIC$decodeHash = BASIC.decodeHash(rest),
username = _BASIC$decodeHash.username,
password = _BASIC$decodeHash.password;
var username = _BASIC$decodeHash.username;
var password = _BASIC$decodeHash.password;
return {

@@ -115,10 +112,12 @@ hash: rest,

buildAuthorizationRest: function buildAuthorizationRest() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
hash = _ref.hash,
username = _ref.username,
password = _ref.password;
var hash = _ref.hash;
var username = _ref.username;
var password = _ref.password;
if (username && password) {
return BASIC.computeHash({ username: username, password: password });
return BASIC.computeHash({
username: username,
password: password
});
}

@@ -146,4 +145,4 @@ if (!hash) {

computeHash: function computeHash(_ref2) {
var username = _ref2.username;
var password = _ref2.password;
var username = _ref2.username,
password = _ref2.password;

@@ -167,10 +166,7 @@ return new Buffer(username + ':' + password).toString('base64');

decodeHash: function decodeHash(hash) {
var _toString$split = new Buffer(hash, 'base64').toString().split(':');
var _toString$split = new Buffer(hash, 'base64').toString().split(':'),
_toString$split2 = _toArray(_toString$split),
username = _toString$split2[0],
passwordParts = _toString$split2.slice(1);
var _toString$split2 = _toArray(_toString$split);
var username = _toString$split2[0];
var passwordParts = _toString$split2.slice(1);
return {

@@ -177,0 +173,0 @@ username: username,

@@ -18,5 +18,3 @@ 'use strict';

describe('BASIC', function () {
describe('type', function () {
it('should be the basic auth prefix', function () {

@@ -28,3 +26,2 @@ _assert2.default.equal(_basic2.default.type, 'Basic');

describe('parseWWWAuthenticateRest', function () {
it('should work', function () {

@@ -38,3 +35,2 @@ (0, _neatequal2.default)(_basic2.default.parseWWWAuthenticateRest('realm="perlinpinpin"'), {

describe('buildWWWAuthenticateRest', function () {
it('should work', function () {

@@ -56,3 +52,2 @@ _assert2.default.equal(_basic2.default.buildWWWAuthenticateRest({

describe('parseAuthorizationRest', function () {
it('should work', function () {

@@ -73,3 +68,2 @@ (0, _neatequal2.default)(_basic2.default.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {

describe('buildAuthorizationRest', function () {
it('should work with credentials', function () {

@@ -102,3 +96,2 @@ _assert2.default.equal(_basic2.default.buildAuthorizationRest({

describe('computeHash', function () {
it('should work', function () {

@@ -113,3 +106,2 @@ _assert2.default.equal(_basic2.default.computeHash({

describe('decodeHash', function () {
it('should work', function () {

@@ -116,0 +108,0 @@ (0, _neatequal2.default)(_basic2.default.decodeHash('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {

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

var BEARER = {
/**

@@ -116,6 +115,5 @@ * The Digest auth mecanism prefix.

buildAuthorizationRest: function buildAuthorizationRest() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
hash = _ref.hash;
var hash = _ref.hash;
if (!hash) {

@@ -122,0 +120,0 @@ throw new _yerror2.default('E_NO_HASH');

@@ -18,5 +18,3 @@ 'use strict';

describe('BEARER', function () {
describe('type', function () {
it('should be the basic auth prefix', function () {

@@ -28,3 +26,2 @@ _assert2.default.equal(_bearer2.default.type, 'Bearer');

describe('parseWWWAuthenticateRest', function () {
it('should work', function () {

@@ -38,3 +35,2 @@ (0, _neatequal2.default)(_bearer2.default.parseWWWAuthenticateRest('realm="perlinpinpin"'), {

describe('buildWWWAuthenticateRest', function () {
it('should work', function () {

@@ -56,3 +52,2 @@ _assert2.default.equal(_bearer2.default.buildWWWAuthenticateRest({

describe('parseAuthorizationRest', function () {
it('should work', function () {

@@ -66,3 +61,2 @@ (0, _neatequal2.default)(_bearer2.default.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {

describe('buildAuthorizationRest', function () {
it('should work', function () {

@@ -69,0 +63,0 @@ _assert2.default.equal(_bearer2.default.buildAuthorizationRest({

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

var DIGEST = {
/**

@@ -32,0 +31,0 @@ * The Digest auth mecanism prefix.

@@ -18,5 +18,3 @@ 'use strict';

describe('digest', function () {
describe('type', function () {
it('should be the digest auth prefix', function () {

@@ -28,3 +26,2 @@ _assert2.default.equal(_digest2.default.type, 'Digest');

describe('parseWWWAuthenticateRest', function () {
it('should work', function () {

@@ -41,3 +38,2 @@ (0, _neatequal2.default)(_digest2.default.parseWWWAuthenticateRest('realm="testrealm@host.com", ' + 'qop="auth, auth-int", ' + 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' + 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'), {

describe('buildWWWAuthenticateRest', function () {
it('should work', function () {

@@ -62,3 +58,2 @@ _assert2.default.equal(_digest2.default.buildWWWAuthenticateRest({

describe('parseAuthorizationRest', function () {
it('should work', function () {

@@ -80,3 +75,2 @@ (0, _neatequal2.default)(_digest2.default.parseAuthorizationRest('username="Mufasa",' + 'realm="testrealm@host.com",' + 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",' + 'uri="/dir/index.html",' + 'qop="auth",' + 'nc="00000001",' + 'cnonce="0a4f113b",' + 'response="6629fae49393a05397450978507c4ef1",' + 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'), {

describe('buildAuthorizationRest', function () {
it('should work', function () {

@@ -122,3 +116,2 @@ _assert2.default.equal(_digest2.default.buildAuthorizationRest({

describe('computeHash', function () {
it('should work', function () {

@@ -125,0 +118,0 @@ _assert2.default.equal(_digest2.default.computeHash({

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

function parseHTTPHeadersQuotedKeyValueSet(contents, authorizedKeys) {
var requiredKeys = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
var requiredKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

@@ -36,7 +36,6 @@ var data = contents.split(SEPARATOR_REGEXP).map(function (part, partPosition, parts) {

}).reduce(function (parsedValues, _ref, valuePosition) {
var _ref2 = _slicedToArray(_ref, 2);
var _ref2 = _slicedToArray(_ref, 2),
name = _ref2[0],
value = _ref2[1];
var name = _ref2[0];
var value = _ref2[1];
if (-1 === authorizedKeys.indexOf(name)) {

@@ -58,3 +57,3 @@ throw new _yerror2.default('E_UNAUTHORIZED_KEY', valuePosition, name);

function buildHTTPHeadersQuotedKeyValueSet(data, authorizedKeys) {
var requiredKeys = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
var requiredKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

@@ -61,0 +60,0 @@ _checkRequiredKeys(requiredKeys, data);

@@ -16,5 +16,3 @@ 'use strict';

describe('utils', function () {
describe('parseHTTPHeadersQuotedKeyValueSet', function () {
it('should work with good datas', function () {

@@ -31,3 +29,2 @@ (0, _neatequal2.default)((0, _utils.parseHTTPHeadersQuotedKeyValueSet)('realm="testrealm@host.com", ' + 'qop="auth, auth-int", ' + 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' + 'opaque="5ccc069c403ebaf9f0171e9517f40e41"', ['realm', 'qop', 'nonce', 'opaque']), {

describe('buildHTTPHeadersQuotedKeyValueSet', function () {
it('should work with good datas', function () {

@@ -34,0 +31,0 @@ _assert2.default.equal((0, _utils.buildHTTPHeadersQuotedKeyValueSet)({

{
"name": "http-auth-utils",
"version": "1.0.0",
"version": "1.0.1",
"description": "Parse, build and deal with HTTP auth headers.",
"main": "dist/index.js",
"metapak": {
"data": {
"files": "src/*.js src/**/*.js",
"testsFiles": "src/*.mocha.js"
},
"configs": [
"readme",
"eslint",
"mocha",
"jsdocs",
"codeclimate",
"babel",
"travis"
]
},
"scripts": {
"test": "mocha --compilers js:babel-register src/**/*.mocha.js src/*.mocha.js src/**/*.mocha.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"cli": "env NODE_ENV=${NODE_ENV:-cli}",
"compile": "babel src --out-dir=dist",
"cli": "env NPM_CLI=1",
"cover": "istanbul cover _mocha --report html -- --compilers js:babel-register src/*.mocha.js -R spec -t 5000",
"coveralls": "istanbul cover _mocha --report lcovonly -- --compilers js:babel-register src/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz",
"doc": "mkdir -p .readme; echo \"# API\" > .readme/API.md; jsdoc2md src/*.js src/**/*.js >> .readme/API.md",
"lint": "eslint src/*.js src/**/*.js",
"preversion": "npm run compile && npm run lint && npm test",
"doc": "cat src/index.js | jsdoc2md > API.md",
"coveralls": "istanbul cover _mocha --report lcovonly -- --compilers js:babel-register src/*.mocha.js src/**/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"cover": "istanbul cover --report html _mochai-- --compilers js:babel-register src/*.mocha.js src/**/*.mocha.js -R spec -t 5000"
"metapak": "metapak",
"mocha": "mocha --compilers js:babel-register src/*.mocha.js",
"prettier": "prettier --write src/*.js src/**/*.js",
"preversion": "npm t && npm run lint && npm run metapak -s && npm run compile",
"test": "npm run mocha",
"version": "npm run changelog && git add CHANGELOG.md"
},

@@ -36,17 +57,51 @@ "keywords": [

"devDependencies": {
"babel-cli": "^6.4.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^7.1.0",
"babel-plugin-transform-async-to-module-method": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.4.3",
"coveralls": "^2.11.11",
"eslint": "^3.1.1",
"eslint-config-simplifield": "^3.0.0",
"babel-register": "^6.9.0",
"commitizen": "^2.9.6",
"conventional-changelog-cli": "^1.3.5",
"coveralls": "^2.13.3",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^4.12.1",
"eslint-plugin-prettier": "^2.3.1",
"istanbul": "^1.0.0-alpha.2",
"jsdoc-to-markdown": "^1.1.1",
"mocha": "^2.2.4",
"jsdoc-to-markdown": "^3.1.0-0",
"metapak": "^1.0.2",
"metapak-nfroidure": "^2.0.2",
"mocha": "^3.5.3",
"mocha-lcov-reporter": "^1.3.0",
"neatequal": "^1.0.0",
"prettier": "^1.8.2",
"sinon": "^1.14.1"
},
"dependencies": {
"yerror": "^1.0.0"
"yerror": "^2.1.0"
},
"engines": {
"node": ">=6.9.5"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"greenkeeper": {
"ignore": [
"commitizen",
"cz-conventional-changelog",
"conventional-changelog-cli",
"eslint",
"eslint-config-prettier",
"prettier",
"mocha",
"mocha-lcov-reporter",
"coveralls",
"istanbul",
"jsdoc-to-markdown"
]
}
}

@@ -0,38 +1,26 @@

<!--
# This file is automatically generated by a `metapak`
# module. Do not change it elsewhere, changes would
# be overridden.
-->
# http-auth-utils
> Parse, build and deal with HTTP auth headers.
> This library provide several utils to parse and build WWW-Authenticate and
Authorization headers as described per the HTTP RFC.
[![NPM version](https://img.shields.io/npm/v/http-auth-utils.svg)](https://www.npmjs.com/package/http-auth-utils)
[![Build Status](https://travis-ci.org/nfroidure/http-auth-utils.svg?branch=master)](https://travis-ci.org/nfroidure/http-auth-utils)
[![NPM version](https://badge.fury.io/js/http-auth-utils.svg)](https://npmjs.org/package/http-auth-utils)
[![Build status](https://secure.travis-ci.org/nfroidure/http-auth-utils.svg)](https://travis-ci.org/nfroidure/http-auth-utils)
[![Dependency Status](https://david-dm.org/nfroidure/http-auth-utils.svg)](https://david-dm.org/nfroidure/http-auth-utils)
[![devDependency Status](https://david-dm.org/nfroidure/http-auth-utils/dev-status.svg)](https://david-dm.org/nfroidure/http-auth-utils#info=devDependencies)
[![Coverage Status](https://coveralls.io/repos/nfroidure/http-auth-utils/badge.svg?branch=master)](https://coveralls.io/r/nfroidure/http-auth-utils?branch=master)
[![Code Climate](https://codeclimate.com/github/nfroidure/http-auth-utils/badges/gpa.svg)](https://codeclimate.com/github/nfroidure/http-auth-utils)
[![Code Climate](https://codeclimate.com/github/nfroidure/http-auth-utils.svg)](https://codeclimate.com/github/nfroidure/http-auth-utils)
[![Dependency Status](https://dependencyci.com/github/nfroidure/http-auth-utils/badge)](https://dependencyci.com/github/nfroidure/http-auth-utils)
This library is intended to be framework agnostic and could be used either on
This library provide several utilities to parse and build WWW-Authenticate and
Authorization headers as described per the HTTP RFC.
It is intended to be framework agnostic and could be used either on
the server and the client side.
Since this library is in an early development stage, please don't use it until
you really not care of API changes.
# API
## Modules
## Development
Running tests:
```sh
npm test
```
Generating docs:
```sh
cat src/index.js src/mecanisms/basic.js src/mecanisms/digest.js | npm run cli -- jsdoc2md > API.md
```
## Contributing
To contribute to this project, you must accept to publish it under the MIT
Licence.
## Modules
<dl>

@@ -43,25 +31,31 @@ <dt><a href="#module_http-auth-utils">http-auth-utils</a></dt>

<dd></dd>
<dt><a href="#module_http-auth-utils/mecanisms/bearer">http-auth-utils/mecanisms/bearer</a></dt>
<dd></dd>
<dt><a href="#module_http-auth-utils/mecanisms/digest">http-auth-utils/mecanisms/digest</a></dt>
<dd></dd>
</dl>
<a name="module_http-auth-utils"></a>
## http-auth-utils
* [http-auth-utils](#module_http-auth-utils)
* [.mecanisms](#module_http-auth-utils.mecanisms) : <code>Array</code>
* [.parseWWWAuthenticateHeader](#module_http-auth-utils.parseWWWAuthenticateHeader) ⇒ <code>Object</code>
* [.parseAuthorizationHeader](#module_http-auth-utils.parseAuthorizationHeader) ⇒ <code>Object</code>
* [.mecanisms](#module_http-auth-utils.mecanisms) : <code>Array</code>
* [.parseWWWAuthenticateHeader(header, [authMecanisms])](#module_http-auth-utils.parseWWWAuthenticateHeader) ⇒ <code>Object</code>
* [.parseAuthorizationHeader(header, [authMecanisms])](#module_http-auth-utils.parseAuthorizationHeader) ⇒ <code>Object</code>
<a name="module_http-auth-utils.mecanisms"></a>
### http-auth-utils.mecanisms : <code>Array</code>
Natively supported authentication mecanisms.
**Kind**: static constant of <code>[http-auth-utils](#module_http-auth-utils)</code>
**Kind**: static constant of [<code>http-auth-utils</code>](#module_http-auth-utils)
<a name="module_http-auth-utils.parseWWWAuthenticateHeader"></a>
### http-auth-utils.parseWWWAuthenticateHeader ⇒ <code>Object</code>
### http-auth-utils.parseWWWAuthenticateHeader(header, [authMecanisms]) ⇒ <code>Object</code>
Parse HTTP WWW-Authenticate header contents.
**Kind**: static constant of <code>[http-auth-utils](#module_http-auth-utils)</code>
**Returns**: <code>Object</code> - Result of the contents parse.
**Api**: public
**Kind**: static method of [<code>http-auth-utils</code>](#module_http-auth-utils)
**Returns**: <code>Object</code> - Result of the contents parse.
**Api**: public

@@ -73,3 +67,3 @@ | Param | Type | Default | Description |

**Example**
**Example**
```js

@@ -86,8 +80,9 @@ assert.equal(

<a name="module_http-auth-utils.parseAuthorizationHeader"></a>
### http-auth-utils.parseAuthorizationHeader ⇒ <code>Object</code>
### http-auth-utils.parseAuthorizationHeader(header, [authMecanisms]) ⇒ <code>Object</code>
Parse HTTP Authorization header contents.
**Kind**: static constant of <code>[http-auth-utils](#module_http-auth-utils)</code>
**Returns**: <code>Object</code> - Result of the contents parse.
**Api**: public
**Kind**: static method of [<code>http-auth-utils</code>](#module_http-auth-utils)
**Returns**: <code>Object</code> - Result of the contents parse.
**Api**: public

@@ -97,11 +92,11 @@ | Param | Type | Default | Description |

| header | <code>string</code> | | The Authorization header contents |
| [authMecanisms] | <code>Array</code> | <code>[BASIC, DIGEST]</code> | Allow providing custom authentication mecanisms. |
| [authMecanisms] | <code>Array</code> | <code>[BASIC, DIGEST, BEARER]</code> | Allow custom authentication mecanisms. |
**Example**
**Example**
```js
assert.equal(
parseAuthorizationHeader('Basic QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
parseAuthorizationHeader('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
type: 'Basic',
data: {
hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
}

@@ -112,48 +107,52 @@ }

<a name="module_http-auth-utils/mecanisms/basic"></a>
## http-auth-utils/mecanisms/basic
* [http-auth-utils/mecanisms/basic](#module_http-auth-utils/mecanisms/basic)
* [~BASIC](#module_http-auth-utils/mecanisms/basic..BASIC) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/basic..BASIC.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(content)](#module_http-auth-utils/mecanisms/basic..BASIC.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/basic..BASIC.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(credentials)](#module_http-auth-utils/mecanisms/basic..BASIC.computeHash) ⇒ <code>String</code>
* [.decodeHash(hash)](#module_http-auth-utils/mecanisms/basic..BASIC.decodeHash) ⇒ <code>Object</code>
* [~BASIC](#module_http-auth-utils/mecanisms/basic..BASIC) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/basic..BASIC.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mecanisms/basic..BASIC.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/basic..BASIC.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(credentials)](#module_http-auth-utils/mecanisms/basic..BASIC.computeHash) ⇒ <code>String</code>
* [.decodeHash(hash)](#module_http-auth-utils/mecanisms/basic..BASIC.decodeHash) ⇒ <code>Object</code>
<a name="module_http-auth-utils/mecanisms/basic..BASIC"></a>
### http-auth-utils/mecanisms/basic~BASIC : <code>Object</code>
Basic authentication mecanism.
**Kind**: inner constant of <code>[http-auth-utils/mecanisms/basic](#module_http-auth-utils/mecanisms/basic)</code>
**See**: http://tools.ietf.org/html/rfc2617#section-2
**Kind**: inner constant of [<code>http-auth-utils/mecanisms/basic</code>](#module_http-auth-utils/mecanisms/basic)
**See**: http://tools.ietf.org/html/rfc2617#section-2
* [~BASIC](#module_http-auth-utils/mecanisms/basic..BASIC) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/basic..BASIC.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(content)](#module_http-auth-utils/mecanisms/basic..BASIC.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/basic..BASIC.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(credentials)](#module_http-auth-utils/mecanisms/basic..BASIC.computeHash) ⇒ <code>String</code>
* [.decodeHash(hash)](#module_http-auth-utils/mecanisms/basic..BASIC.decodeHash) ⇒ <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/basic..BASIC.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mecanisms/basic..BASIC.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/basic..BASIC.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/basic..BASIC.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(credentials)](#module_http-auth-utils/mecanisms/basic..BASIC.computeHash) ⇒ <code>String</code>
* [.decodeHash(hash)](#module_http-auth-utils/mecanisms/basic..BASIC.decodeHash) ⇒ <code>Object</code>
<a name="module_http-auth-utils/mecanisms/basic..BASIC.type"></a>
#### BASIC.type : <code>String</code>
The Basic auth mecanism prefix.
**Kind**: static property of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Kind**: static property of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
<a name="module_http-auth-utils/mecanisms/basic..BASIC.parseWWWAuthenticateRest"></a>
#### BASIC.parseWWWAuthenticateRest(rest) ⇒ <code>Object</code>
Parse the WWW Authenticate header rest.
**Kind**: static method of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Returns**: <code>Object</code> - Object representing the result of the parse operation.
**Api**: public
**Kind**: static method of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
**Returns**: <code>Object</code> - Object representing the result of the parse operation.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| rest | <code>String</code> | The header rest (string got after removing the authentication mecanism prefix). |
| rest | <code>String</code> | The header rest (string after the authentication mecanism prefix). |
**Example**
**Example**
```js

@@ -167,14 +166,15 @@ assert.deepEqual(

<a name="module_http-auth-utils/mecanisms/basic..BASIC.buildWWWAuthenticateRest"></a>
#### BASIC.buildWWWAuthenticateRest(content) ⇒ <code>String</code>
#### BASIC.buildWWWAuthenticateRest(data) ⇒ <code>String</code>
Build the WWW Authenticate header rest.
**Kind**: static method of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Returns**: <code>String</code> - The built rest.
**Api**: public
**Kind**: static method of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
**Returns**: <code>String</code> - The built rest.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| content | <code>Object</code> | The content from wich to build the rest. |
| data | <code>Object</code> | The content from wich to build the rest. |
**Example**
**Example**
```js

@@ -189,18 +189,21 @@ assert.equal(

<a name="module_http-auth-utils/mecanisms/basic..BASIC.parseAuthorizationRest"></a>
#### BASIC.parseAuthorizationRest(rest) ⇒ <code>Object</code>
Parse the Authorization header rest.
**Kind**: static method of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Returns**: <code>Object</code> - Object representing the result of the parse operation {hash}.
**Api**: public
**Kind**: static method of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
**Returns**: <code>Object</code> - Object representing the result of the parse operation {hash}.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| rest | <code>String</code> | The header rest (string got after removing the authentication mecanism prefix).) |
| rest | <code>String</code> | The header rest (string after the authentication mecanism prefix).) |
**Example**
**Example**
```js
assert.deepEqual(
BASIC.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
username: 'Ali Baba',
password: 'open sesame'
}

@@ -210,8 +213,9 @@ );

<a name="module_http-auth-utils/mecanisms/basic..BASIC.buildAuthorizationRest"></a>
#### BASIC.buildAuthorizationRest(content) ⇒ <code>String</code>
Build the Authorization header rest.
**Kind**: static method of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Returns**: <code>String</code> - The rest built.
**Api**: public
**Kind**: static method of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
**Returns**: <code>String</code> - The rest built.
**Api**: public

@@ -222,3 +226,3 @@ | Param | Type | Description |

**Example**
**Example**
```js

@@ -233,8 +237,9 @@ assert.equal(

<a name="module_http-auth-utils/mecanisms/basic..BASIC.computeHash"></a>
#### BASIC.computeHash(credentials) ⇒ <code>String</code>
Compute the Basic authentication hash from the given credentials.
**Kind**: static method of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Returns**: <code>String</code> - The hash representing the credentials.
**Api**: public
**Kind**: static method of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
**Returns**: <code>String</code> - The hash representing the credentials.
**Api**: public

@@ -245,3 +250,3 @@ | Param | Type | Description |

**Example**
**Example**
```js

@@ -257,8 +262,9 @@ assert.equal(

<a name="module_http-auth-utils/mecanisms/basic..BASIC.decodeHash"></a>
#### BASIC.decodeHash(hash) ⇒ <code>Object</code>
Decode the Basic hash and return the corresponding credentials.
**Kind**: static method of <code>[BASIC](#module_http-auth-utils/mecanisms/basic..BASIC)</code>
**Returns**: <code>Object</code> - Object representing the credentials {username, password}.
**Api**: public
**Kind**: static method of [<code>BASIC</code>](#module_http-auth-utils/mecanisms/basic..BASIC)
**Returns**: <code>Object</code> - Object representing the credentials {username, password}.
**Api**: public

@@ -269,3 +275,3 @@ | Param | Type | Description |

**Example**
**Example**
```js

@@ -279,19 +285,148 @@ assert.deepEqual(

```
<a name="module_http-auth-utils/mecanisms/bearer"></a>
## http-auth-utils/mecanisms/bearer
* [http-auth-utils/mecanisms/bearer](#module_http-auth-utils/mecanisms/bearer)
* [~BEARER](#module_http-auth-utils/mecanisms/bearer..BEARER) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/bearer..BEARER.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/bearer..BEARER.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mecanisms/bearer..BEARER.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/bearer..BEARER.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/bearer..BEARER.buildAuthorizationRest) ⇒ <code>String</code>
<a name="module_http-auth-utils/mecanisms/bearer..BEARER"></a>
### http-auth-utils/mecanisms/bearer~BEARER : <code>Object</code>
Bearer authentication mecanism.
**Kind**: inner constant of [<code>http-auth-utils/mecanisms/bearer</code>](#module_http-auth-utils/mecanisms/bearer)
**See**: https://tools.ietf.org/html/rfc6750#section-3
* [~BEARER](#module_http-auth-utils/mecanisms/bearer..BEARER) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/bearer..BEARER.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/bearer..BEARER.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mecanisms/bearer..BEARER.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/bearer..BEARER.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/bearer..BEARER.buildAuthorizationRest) ⇒ <code>String</code>
<a name="module_http-auth-utils/mecanisms/bearer..BEARER.type"></a>
#### BEARER.type : <code>String</code>
The Digest auth mecanism prefix.
**Kind**: static property of [<code>BEARER</code>](#module_http-auth-utils/mecanisms/bearer..BEARER)
<a name="module_http-auth-utils/mecanisms/bearer..BEARER.parseWWWAuthenticateRest"></a>
#### BEARER.parseWWWAuthenticateRest(rest) ⇒ <code>Object</code>
Parse the WWW Authenticate header rest.
**Kind**: static method of [<code>BEARER</code>](#module_http-auth-utils/mecanisms/bearer..BEARER)
**Returns**: <code>Object</code> - Object representing the result of the parse operation.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| rest | <code>String</code> | The header rest (string after the authentication mecanism prefix). |
**Example**
```js
assert.deepEqual(
BEARER.parseWWWAuthenticateRest(
'realm="testrealm@host.com", ' +
'scope="openid profile email"'
), {
realm: 'testrealm@host.com',
scope: 'openid profile email',
}
);
```
<a name="module_http-auth-utils/mecanisms/bearer..BEARER.buildWWWAuthenticateRest"></a>
#### BEARER.buildWWWAuthenticateRest(data) ⇒ <code>String</code>
Build the WWW Authenticate header rest.
**Kind**: static method of [<code>BEARER</code>](#module_http-auth-utils/mecanisms/bearer..BEARER)
**Returns**: <code>String</code> - The built rest.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| data | <code>Object</code> | The content from wich to build the rest. |
**Example**
```js
assert.equal(
BEARER.buildWWWAuthenticateRest({
realm: 'testrealm@host.com',
error: 'invalid_request',
error_description: 'The access token expired',
}),
'realm="testrealm@host.com", ' +
'error="invalid_request", ' +
'error_description="The access token expired"'
);
```
<a name="module_http-auth-utils/mecanisms/bearer..BEARER.parseAuthorizationRest"></a>
#### BEARER.parseAuthorizationRest(rest) ⇒ <code>Object</code>
Parse the Authorization header rest.
**Kind**: static method of [<code>BEARER</code>](#module_http-auth-utils/mecanisms/bearer..BEARER)
**Returns**: <code>Object</code> - Object representing the result of the parse operation {hash}.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| rest | <code>String</code> | The header rest (string after the authentication mecanism prefix).) |
**Example**
```js
assert.deepEqual(
BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {
hash: 'mF_9.B5f-4.1JqM',
}
);
```
<a name="module_http-auth-utils/mecanisms/bearer..BEARER.buildAuthorizationRest"></a>
#### BEARER.buildAuthorizationRest(content) ⇒ <code>String</code>
Build the Authorization header rest.
**Kind**: static method of [<code>BEARER</code>](#module_http-auth-utils/mecanisms/bearer..BEARER)
**Returns**: <code>String</code> - The rest built.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| content | <code>Object</code> | The content from wich to build the rest. |
**Example**
```js
assert.equal(
BEARER.buildAuthorizationRest({
hash: 'mF_9.B5f-4.1JqM'
}),
'mF_9.B5f-4.1JqM=='
);
```
<a name="module_http-auth-utils/mecanisms/digest"></a>
## http-auth-utils/mecanisms/digest
* [http-auth-utils/mecanisms/digest](#module_http-auth-utils/mecanisms/digest)
* [~DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/digest..DIGEST.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(content)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(credentials)](#module_http-auth-utils/mecanisms/digest..DIGEST.computeHash) ⇒ <code>String</code>
* [~DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/digest..DIGEST.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(data)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(data)](#module_http-auth-utils/mecanisms/digest..DIGEST.computeHash) ⇒ <code>String</code>
<a name="module_http-auth-utils/mecanisms/digest..DIGEST"></a>
### http-auth-utils/mecanisms/digest~DIGEST : <code>Object</code>
Digest authentication mecanism.
**Kind**: inner constant of <code>[http-auth-utils/mecanisms/digest](#module_http-auth-utils/mecanisms/digest)</code>
**Kind**: inner constant of [<code>http-auth-utils/mecanisms/digest</code>](#module_http-auth-utils/mecanisms/digest)
**See**

@@ -304,27 +439,29 @@

* [~DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST) : <code>Object</code>
* [.type](#module_http-auth-utils/mecanisms/digest..DIGEST.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(content)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(content)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(credentials)](#module_http-auth-utils/mecanisms/digest..DIGEST.computeHash) ⇒ <code>String</code>
* [.type](#module_http-auth-utils/mecanisms/digest..DIGEST.type) : <code>String</code>
* [.parseWWWAuthenticateRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseWWWAuthenticateRest) ⇒ <code>Object</code>
* [.buildWWWAuthenticateRest(data)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildWWWAuthenticateRest) ⇒ <code>String</code>
* [.parseAuthorizationRest(rest)](#module_http-auth-utils/mecanisms/digest..DIGEST.parseAuthorizationRest) ⇒ <code>Object</code>
* [.buildAuthorizationRest(data)](#module_http-auth-utils/mecanisms/digest..DIGEST.buildAuthorizationRest) ⇒ <code>String</code>
* [.computeHash(data)](#module_http-auth-utils/mecanisms/digest..DIGEST.computeHash) ⇒ <code>String</code>
<a name="module_http-auth-utils/mecanisms/digest..DIGEST.type"></a>
#### DIGEST.type : <code>String</code>
The Digest auth mecanism prefix.
**Kind**: static property of <code>[DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST)</code>
**Kind**: static property of [<code>DIGEST</code>](#module_http-auth-utils/mecanisms/digest..DIGEST)
<a name="module_http-auth-utils/mecanisms/digest..DIGEST.parseWWWAuthenticateRest"></a>
#### DIGEST.parseWWWAuthenticateRest(rest) ⇒ <code>Object</code>
Parse the WWW Authenticate header rest.
**Kind**: static method of <code>[DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST)</code>
**Returns**: <code>Object</code> - Object representing the result of the parse operation.
**Api**: public
**Kind**: static method of [<code>DIGEST</code>](#module_http-auth-utils/mecanisms/digest..DIGEST)
**Returns**: <code>Object</code> - Object representing the result of the parse operation.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| rest | <code>String</code> | The header rest (string got after removing the authentication mecanism prefix). |
| rest | <code>String</code> | The header rest (string after the authentication mecanism prefix). |
**Example**
**Example**
```js

@@ -346,14 +483,15 @@ assert.deepEqual(

<a name="module_http-auth-utils/mecanisms/digest..DIGEST.buildWWWAuthenticateRest"></a>
#### DIGEST.buildWWWAuthenticateRest(content) ⇒ <code>String</code>
#### DIGEST.buildWWWAuthenticateRest(data) ⇒ <code>String</code>
Build the WWW Authenticate header rest.
**Kind**: static method of <code>[DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST)</code>
**Returns**: <code>String</code> - The built rest.
**Api**: public
**Kind**: static method of [<code>DIGEST</code>](#module_http-auth-utils/mecanisms/digest..DIGEST)
**Returns**: <code>String</code> - The built rest.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| content | <code>Object</code> | The content from wich to build the rest. |
| data | <code>Object</code> | The content from wich to build the rest. |
**Example**
**Example**
```js

@@ -374,14 +512,15 @@ assert.equal(

<a name="module_http-auth-utils/mecanisms/digest..DIGEST.parseAuthorizationRest"></a>
#### DIGEST.parseAuthorizationRest(rest) ⇒ <code>Object</code>
Parse the Authorization header rest.
**Kind**: static method of <code>[DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST)</code>
**Returns**: <code>Object</code> - Object representing the result of the parse operation {hash}.
**Api**: public
**Kind**: static method of [<code>DIGEST</code>](#module_http-auth-utils/mecanisms/digest..DIGEST)
**Returns**: <code>Object</code> - Object representing the result of the parse operation {hash}.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| rest | <code>String</code> | The header rest (string got after removing the authentication mecanism prefix).) |
| rest | <code>String</code> | The header rest (string after the authentication mecanism prefix).) |
**Example**
**Example**
```js

@@ -413,14 +552,15 @@ assert.deepEqual(

<a name="module_http-auth-utils/mecanisms/digest..DIGEST.buildAuthorizationRest"></a>
#### DIGEST.buildAuthorizationRest(content) ⇒ <code>String</code>
#### DIGEST.buildAuthorizationRest(data) ⇒ <code>String</code>
Build the Authorization header rest.
**Kind**: static method of <code>[DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST)</code>
**Returns**: <code>String</code> - The rest built.
**Api**: public
**Kind**: static method of [<code>DIGEST</code>](#module_http-auth-utils/mecanisms/digest..DIGEST)
**Returns**: <code>String</code> - The rest built.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| content | <code>Object</code> | The content from wich to build the rest. |
| data | <code>Object</code> | The content from wich to build the rest. |
**Example**
**Example**
```js

@@ -451,14 +591,15 @@ assert.equal(

<a name="module_http-auth-utils/mecanisms/digest..DIGEST.computeHash"></a>
#### DIGEST.computeHash(credentials) ⇒ <code>String</code>
#### DIGEST.computeHash(data) ⇒ <code>String</code>
Compute the Digest authentication hash from the given credentials.
**Kind**: static method of <code>[DIGEST](#module_http-auth-utils/mecanisms/digest..DIGEST)</code>
**Returns**: <code>String</code> - The hash representing the credentials.
**Api**: public
**Kind**: static method of [<code>DIGEST</code>](#module_http-auth-utils/mecanisms/digest..DIGEST)
**Returns**: <code>String</code> - The hash representing the credentials.
**Api**: public
| Param | Type | Description |
| --- | --- | --- |
| credentials | <code>Object</code> | The credentials to encode and other encoding details. |
| data | <code>Object</code> | The credentials to encode and other encoding details. |
**Example**
**Example**
```js

@@ -481,1 +622,4 @@ assert.equal(

```
# License
[MIT](https://github.com/nfroidure/http-auth-utils/blob/master/LICENSE)

@@ -16,3 +16,3 @@ import YError from 'yerror';

*/
export { BASIC as BASIC };
export { BASIC };

@@ -24,3 +24,3 @@ /**

*/
export { DIGEST as DIGEST };
export { DIGEST };

@@ -32,3 +32,3 @@ /**

*/
export { BEARER as BEARER };
export { BEARER };

@@ -61,16 +61,18 @@ /**

authMecanisms.some((authMecanism) => {
if(0 === header.indexOf(authMecanism.type + ' ')) {
authMecanisms.some(authMecanism => {
if (0 === header.indexOf(authMecanism.type + ' ')) {
result = {
type: authMecanism.type,
data: authMecanism.parseWWWAuthenticateRest(
header.substr(authMecanism.type.length + 1)
header.substr(authMecanism.type.length + 1),
),
};
return true;
}
return false;
});
if(result) {
return result;
if (!result) {
throw new YError('E_UNKNOWN_AUTH_MECANISM', header);
}
throw new YError('E_UNKNOWN_AUTH_MECANISM', header);
return result;
}

@@ -99,12 +101,14 @@

authMecanisms.some(function(authMecanism) {
if(0 === header.indexOf(authMecanism.type + ' ')) {
if (0 === header.indexOf(authMecanism.type + ' ')) {
result = {
type: authMecanism.type,
data: authMecanism.parseAuthorizationRest(
header.substr(authMecanism.type.length + 1)
header.substr(authMecanism.type.length + 1),
),
};
return true;
}
return false;
});
if(result) {
if (result) {
return result;

@@ -111,0 +115,0 @@ }

@@ -13,23 +13,18 @@ import assert from 'assert';

describe('index', () => {
describe('parseWWWAuthenticateHeader', () => {
it('should parse Basic headers', () => {
neatequal(
parseWWWAuthenticateHeader('Basic realm="test"'), {
type: 'Basic',
data: {
realm: 'test',
},
}
);
neatequal(parseWWWAuthenticateHeader('Basic realm="test"'), {
type: 'Basic',
data: {
realm: 'test',
},
});
});
});
describe('parseAuthorizationHeader', () => {
it('should parse Basic headers', () => {
neatequal(
parseAuthorizationHeader('Basic QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
parseAuthorizationHeader('Basic QWxpIEJhYmE6b3BlbiBzZXNhbWU='),
{
type: 'Basic',

@@ -41,6 +36,9 @@ data: {

},
}
},
);
neatequal(
parseAuthorizationHeader('Basic bmljb2xhcy5mcm9pZHVyZUBzaW1wbGlmaWVsZC5jb206dGVzdA=='), {
parseAuthorizationHeader(
'Basic bmljb2xhcy5mcm9pZHVyZUBzaW1wbGlmaWVsZC5jb206dGVzdA==',
),
{
type: 'Basic',

@@ -52,3 +50,3 @@ data: {

},
}
},
);

@@ -58,23 +56,16 @@ });

it('should parse Basic headers with a ":" char in the password', () => {
neatequal(
parseAuthorizationHeader('Basic Sm9objpSOlU6a2lkZGluZz8='), {
type: 'Basic',
data: {
username: 'John',
password: 'R:U:kidding?',
hash: 'Sm9objpSOlU6a2lkZGluZz8=',
},
}
);
neatequal(parseAuthorizationHeader('Basic Sm9objpSOlU6a2lkZGluZz8='), {
type: 'Basic',
data: {
username: 'John',
password: 'R:U:kidding?',
hash: 'Sm9objpSOlU6a2lkZGluZz8=',
},
});
});
});
describe('mecanisms', () => {
it('should export bot DIGEST and BASIC mecanisms', () => {
assert.equal(
mecanisms.length,
3
);
assert.equal(mecanisms.length, 3);
});

@@ -87,5 +78,3 @@

});
});
});

@@ -20,3 +20,2 @@ /**

const BASIC = {
/**

@@ -41,3 +40,7 @@ * The Basic auth mecanism prefix.

parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
return parseHTTPHeadersQuotedKeyValueSet(rest, AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
return parseHTTPHeadersQuotedKeyValueSet(
rest,
AUTHORIZED_WWW_AUTHENTICATE_KEYS,
[],
);
},

@@ -59,3 +62,7 @@

buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
return buildHTTPHeadersQuotedKeyValueSet(data, AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
return buildHTTPHeadersQuotedKeyValueSet(
data,
AUTHORIZED_WWW_AUTHENTICATE_KEYS,
[],
);
},

@@ -78,3 +85,3 @@

parseAuthorizationRest: function parseAuthorizationRest(rest) {
if(!rest) {
if (!rest) {
throw new YError('E_EMPTY_AUTH');

@@ -104,7 +111,12 @@ }

*/
buildAuthorizationRest: function buildAuthorizationRest({ hash, username, password } = {}) {
if(username && password) {
return BASIC.computeHash({ username, password });
buildAuthorizationRest: function buildAuthorizationRest(
{ hash, username, password } = {},
) {
if (username && password) {
return BASIC.computeHash({
username,
password,
});
}
if(!hash) {
if (!hash) {
throw new YError('E_NO_HASH');

@@ -130,3 +142,3 @@ }

computeHash: function computeHash({ username, password }) {
return (new Buffer(username + ':' + password)).toString('base64');
return new Buffer(username + ':' + password).toString('base64');
},

@@ -148,3 +160,5 @@

decodeHash: function decodeHash(hash) {
let [username, ...passwordParts] = ((new Buffer(hash, 'base64')).toString()).split(':');
let [username, ...passwordParts] = new Buffer(hash, 'base64')
.toString()
.split(':');
return {

@@ -151,0 +165,0 @@ username,

@@ -6,25 +6,17 @@ import assert from 'assert';

describe('BASIC', () => {
describe('type', () => {
it('should be the basic auth prefix', () => {
assert.equal(BASIC.type, 'Basic');
});
});
describe('parseWWWAuthenticateRest', () => {
it('should work', () => {
neatequal(
BASIC.parseWWWAuthenticateRest('realm="perlinpinpin"'), {
realm: 'perlinpinpin',
}
);
neatequal(BASIC.parseWWWAuthenticateRest('realm="perlinpinpin"'), {
realm: 'perlinpinpin',
});
});
});
describe('buildWWWAuthenticateRest', () => {
it('should work', () => {

@@ -35,3 +27,3 @@ assert.equal(

}),
'realm="perlinpinpin"'
'realm="perlinpinpin"',
);

@@ -45,34 +37,32 @@ });

realm: 'perlinpinpin',
})
), {
}),
),
{
realm: 'perlinpinpin',
}
},
);
});
});
describe('parseAuthorizationRest', () => {
it('should work', () => {
neatequal(BASIC.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
username: 'Ali Baba',
password: 'open sesame',
});
neatequal(
BASIC.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
username: 'Ali Baba',
password: 'open sesame',
}
);
neatequal(
BASIC.parseAuthorizationRest('bmljb2xhcy5mcm9pZHVyZUBzaW1wbGlmaWVsZC5jb206dGVzdA=='), {
BASIC.parseAuthorizationRest(
'bmljb2xhcy5mcm9pZHVyZUBzaW1wbGlmaWVsZC5jb206dGVzdA==',
),
{
hash: 'bmljb2xhcy5mcm9pZHVyZUBzaW1wbGlmaWVsZC5jb206dGVzdA==',
username: 'nicolas.froidure@simplifield.com',
password: 'test',
}
},
);
});
});
describe('buildAuthorizationRest', () => {
it('should work with credentials', () => {

@@ -84,3 +74,3 @@ assert.equal(

}),
'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
);

@@ -94,3 +84,3 @@ });

}),
'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
);

@@ -106,15 +96,14 @@ });

password: 'open sesame',
})
), {
}),
),
{
hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
username: 'Ali Baba',
password: 'open sesame',
}
},
);
});
});
describe('computeHash', () => {
it('should work', () => {

@@ -126,21 +115,15 @@ assert.equal(

}),
'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
);
});
});
describe('decodeHash', () => {
it('should work', () => {
neatequal(
BASIC.decodeHash('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
username: 'Ali Baba',
password: 'open sesame',
}
);
neatequal(BASIC.decodeHash('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
username: 'Ali Baba',
password: 'open sesame',
});
});
});
});

@@ -13,7 +13,12 @@ /**

const AUTHORIZED_WWW_AUTHENTICATE_KEYS = [
'realm', 'scope', 'error', 'error_description',
'realm',
'scope',
'error',
'error_description',
];
const AUTHORIZED_ERROR_CODES = [
'invalid_request', 'invalid_token', 'insufficient_scope',
'invalid_request',
'invalid_token',
'insufficient_scope',
];

@@ -27,3 +32,2 @@

const BEARER = {
/**

@@ -52,3 +56,7 @@ * The Digest auth mecanism prefix.

parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
return parseHTTPHeadersQuotedKeyValueSet(rest, AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
return parseHTTPHeadersQuotedKeyValueSet(
rest,
AUTHORIZED_WWW_AUTHENTICATE_KEYS,
[],
);
},

@@ -74,6 +82,10 @@

buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
if(data.error && -1 === AUTHORIZED_ERROR_CODES.indeOf(data.error)) {
if (data.error && -1 === AUTHORIZED_ERROR_CODES.indeOf(data.error)) {
throw new YError('E_INVALID_ERROR', data.error, AUTHORIZED_ERROR_CODES);
}
return buildHTTPHeadersQuotedKeyValueSet(data, AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
return buildHTTPHeadersQuotedKeyValueSet(
data,
AUTHORIZED_WWW_AUTHENTICATE_KEYS,
[],
);
},

@@ -94,3 +106,3 @@

parseAuthorizationRest: function parseAuthorizationRest(rest) {
if(!rest) {
if (!rest) {
throw new YError('E_EMPTY_AUTH');

@@ -117,3 +129,3 @@ }

buildAuthorizationRest: function buildAuthorizationRest({ hash } = {}) {
if(!hash) {
if (!hash) {
throw new YError('E_NO_HASH');

@@ -120,0 +132,0 @@ }

@@ -6,25 +6,17 @@ import assert from 'assert';

describe('BEARER', () => {
describe('type', () => {
it('should be the basic auth prefix', () => {
assert.equal(BEARER.type, 'Bearer');
});
});
describe('parseWWWAuthenticateRest', () => {
it('should work', () => {
neatequal(
BEARER.parseWWWAuthenticateRest('realm="perlinpinpin"'), {
realm: 'perlinpinpin',
}
);
neatequal(BEARER.parseWWWAuthenticateRest('realm="perlinpinpin"'), {
realm: 'perlinpinpin',
});
});
});
describe('buildWWWAuthenticateRest', () => {
it('should work', () => {

@@ -35,3 +27,3 @@ assert.equal(

}),
'realm="perlinpinpin"'
'realm="perlinpinpin"',
);

@@ -45,25 +37,20 @@ });

realm: 'perlinpinpin',
})
), {
}),
),
{
realm: 'perlinpinpin',
}
},
);
});
});
describe('parseAuthorizationRest', () => {
it('should work', () => {
neatequal(
BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {
hash: 'mF_9.B5f-4.1JqM',
}
);
neatequal(BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {
hash: 'mF_9.B5f-4.1JqM',
});
});
});
describe('buildAuthorizationRest', () => {
it('should work', () => {

@@ -74,3 +61,3 @@ assert.equal(

}),
'mF_9.B5f-4.1JqM'
'mF_9.B5f-4.1JqM',
);

@@ -84,11 +71,10 @@ });

hash: 'mF_9.B5f-4.1JqM',
})
), {
}),
),
{
hash: 'mF_9.B5f-4.1JqM',
}
},
);
});
});
});

@@ -13,7 +13,21 @@ /**

const AUTHORIZED_WWW_AUTHENTICATE_KEYS = [
'realm', 'domain', 'qop', 'nonce', 'opaque', 'stale', 'algorithm',
'realm',
'domain',
'qop',
'nonce',
'opaque',
'stale',
'algorithm',
];
const AUTHORIZED_AUTHORIZATION_KEYS = [
'username', 'realm', 'nonce', 'uri', 'response', 'algorithm', 'cnonce',
'opaque', 'qop', 'nc',
'username',
'realm',
'nonce',
'uri',
'response',
'algorithm',
'cnonce',
'opaque',
'qop',
'nc',
];

@@ -28,3 +42,2 @@

const DIGEST = {
/**

@@ -57,3 +70,7 @@ * The Digest auth mecanism prefix.

parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
return parseHTTPHeadersQuotedKeyValueSet(rest, AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
return parseHTTPHeadersQuotedKeyValueSet(
rest,
AUTHORIZED_WWW_AUTHENTICATE_KEYS,
[],
);
},

@@ -81,3 +98,7 @@

buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
return buildHTTPHeadersQuotedKeyValueSet(data, AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
return buildHTTPHeadersQuotedKeyValueSet(
data,
AUTHORIZED_WWW_AUTHENTICATE_KEYS,
[],
);
},

@@ -116,3 +137,7 @@

parseAuthorizationRest: function parseAuthorizationRest(rest) {
return parseHTTPHeadersQuotedKeyValueSet(rest, AUTHORIZED_AUTHORIZATION_KEYS, []);
return parseHTTPHeadersQuotedKeyValueSet(
rest,
AUTHORIZED_AUTHORIZATION_KEYS,
[],
);
},

@@ -150,3 +175,7 @@

buildAuthorizationRest: function buildAuthorizationRest(data) {
return buildHTTPHeadersQuotedKeyValueSet(data, AUTHORIZED_AUTHORIZATION_KEYS, []);
return buildHTTPHeadersQuotedKeyValueSet(
data,
AUTHORIZED_AUTHORIZATION_KEYS,
[],
);
},

@@ -177,12 +206,14 @@

computeHash: function computeHash(data) {
const ha1 = data.ha1 || _computeHash(data.algorithm, [
data.username, data.realm, data.password,
].join(':'));
const ha2 = _computeHash(data.algorithm, [
data.method, data.uri,
].join(':'));
const ha1 =
data.ha1 ||
_computeHash(
data.algorithm,
[data.username, data.realm, data.password].join(':'),
);
const ha2 = _computeHash(data.algorithm, [data.method, data.uri].join(':'));
return _computeHash(data.algorithm, [
ha1, data.nonce, data.nc, data.cnonce, data.qop, ha2,
].join(':'));
return _computeHash(
data.algorithm,
[ha1, data.nonce, data.nc, data.cnonce, data.qop, ha2].join(':'),
);
},

@@ -189,0 +220,0 @@ };

@@ -6,13 +6,9 @@ import assert from 'assert';

describe('digest', () => {
describe('type', () => {
it('should be the digest auth prefix', () => {
assert.equal(DIGEST.type, 'Digest');
});
});
describe('parseWWWAuthenticateRest', () => {
it('should work', () => {

@@ -22,6 +18,7 @@ neatequal(

'realm="testrealm@host.com", ' +
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
), {
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"',
),
{
realm: 'testrealm@host.com',

@@ -31,10 +28,8 @@ qop: 'auth, auth-int',

opaque: '5ccc069c403ebaf9f0171e9517f40e41',
}
},
);
});
});
describe('buildWWWAuthenticateRest', () => {
it('should work', () => {

@@ -49,5 +44,5 @@ assert.equal(

'realm="testrealm@host.com", ' +
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"',
);

@@ -61,13 +56,12 @@ });

realm: 'perlinpinpin',
})
), {
}),
),
{
realm: 'perlinpinpin',
}
},
);
});
});
describe('parseAuthorizationRest', () => {
it('should work', () => {

@@ -77,11 +71,12 @@ neatequal(

'username="Mufasa",' +
'realm="testrealm@host.com",' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",' +
'uri="/dir/index.html",' +
'qop="auth",' +
'nc="00000001",' +
'cnonce="0a4f113b",' +
'response="6629fae49393a05397450978507c4ef1",' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
), {
'realm="testrealm@host.com",' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",' +
'uri="/dir/index.html",' +
'qop="auth",' +
'nc="00000001",' +
'cnonce="0a4f113b",' +
'response="6629fae49393a05397450978507c4ef1",' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"',
),
{
username: 'Mufasa',

@@ -96,10 +91,8 @@ realm: 'testrealm@host.com',

opaque: '5ccc069c403ebaf9f0171e9517f40e41',
}
},
);
});
});
describe('buildAuthorizationRest', () => {
it('should work', () => {

@@ -119,10 +112,10 @@ assert.equal(

'username="Mufasa", ' +
'realm="testrealm@host.com", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'uri="/dir/index.html", ' +
'response="6629fae49393a05397450978507c4ef1", ' +
'cnonce="0a4f113b", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41", ' +
'qop="auth", ' +
'nc="00000001"'
'realm="testrealm@host.com", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'uri="/dir/index.html", ' +
'response="6629fae49393a05397450978507c4ef1", ' +
'cnonce="0a4f113b", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41", ' +
'qop="auth", ' +
'nc="00000001"',
);

@@ -144,4 +137,5 @@ });

opaque: '5ccc069c403ebaf9f0171e9517f40e41',
})
), {
}),
),
{
username: 'Mufasa',

@@ -156,10 +150,8 @@ realm: 'testrealm@host.com',

opaque: '5ccc069c403ebaf9f0171e9517f40e41',
}
},
);
});
});
describe('computeHash', () => {
it('should work', () => {

@@ -179,8 +171,6 @@ assert.equal(

}),
'6629fae49393a05397450978507c4ef1'
'6629fae49393a05397450978507c4ef1',
);
});
});
});

@@ -9,20 +9,32 @@ import YError from 'yerror';

// FIXME: Create a real parser
export function parseHTTPHeadersQuotedKeyValueSet(contents, authorizedKeys, requiredKeys = []) {
const data = contents.split(SEPARATOR_REGEXP).map((part, partPosition, parts) => {
part = parts.length - 1 === partPosition ? part : part + '"';
let pair = part.split(EQUAL);
if(2 !== pair.length) {
throw new YError('E_MALFORMED_QUOTEDKEYVALUE', partPosition, part, pair.length);
}
return pair;
}).reduce(function(parsedValues, [name, value], valuePosition) {
if(-1 === authorizedKeys.indexOf(name)) {
throw new YError('E_UNAUTHORIZED_KEY', valuePosition, name);
}
if(QUOTE !== value[0] || QUOTE !== value[value.length - 1]) {
throw new YError('E_UNQUOTED_VALUE', valuePosition, name, value);
}
parsedValues[name] = value.substr(1, value.length - 2);
return parsedValues;
}, {});
export function parseHTTPHeadersQuotedKeyValueSet(
contents,
authorizedKeys,
requiredKeys = [],
) {
const data = contents
.split(SEPARATOR_REGEXP)
.map((part, partPosition, parts) => {
part = parts.length - 1 === partPosition ? part : part + '"';
let pair = part.split(EQUAL);
if (2 !== pair.length) {
throw new YError(
'E_MALFORMED_QUOTEDKEYVALUE',
partPosition,
part,
pair.length,
);
}
return pair;
})
.reduce(function(parsedValues, [name, value], valuePosition) {
if (-1 === authorizedKeys.indexOf(name)) {
throw new YError('E_UNAUTHORIZED_KEY', valuePosition, name);
}
if (QUOTE !== value[0] || QUOTE !== value[value.length - 1]) {
throw new YError('E_UNQUOTED_VALUE', valuePosition, name, value);
}
parsedValues[name] = value.substr(1, value.length - 2);
return parsedValues;
}, {});

@@ -34,8 +46,19 @@ _checkRequiredKeys(requiredKeys, data);

export function buildHTTPHeadersQuotedKeyValueSet(data, authorizedKeys, requiredKeys = []) {
export function buildHTTPHeadersQuotedKeyValueSet(
data,
authorizedKeys,
requiredKeys = [],
) {
_checkRequiredKeys(requiredKeys, data);
return authorizedKeys.reduce(function(contents, key) {
if(data[key]) {
return contents + (contents ? SEPARATOR : '') + key + EQUAL +
QUOTE + data[key] + QUOTE;
if (data[key]) {
return (
contents +
(contents ? SEPARATOR : '') +
key +
EQUAL +
QUOTE +
data[key] +
QUOTE
);
}

@@ -47,4 +70,4 @@ return contents;

function _checkRequiredKeys(requiredKeys, data) {
requiredKeys.forEach((name) => {
if('undefined' !== typeof data[name]) {
requiredKeys.forEach(name => {
if ('undefined' !== typeof data[name]) {
throw new YError('E_REQUIRED_KEY', name);

@@ -51,0 +74,0 @@ }

@@ -9,40 +9,41 @@ import assert from 'assert';

describe('utils', () => {
describe('parseHTTPHeadersQuotedKeyValueSet', () => {
it('should work with good datas', () => {
neatequal(parseHTTPHeadersQuotedKeyValueSet(
'realm="testrealm@host.com", ' +
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"',
['realm', 'qop', 'nonce', 'opaque']
), {
realm: 'testrealm@host.com',
qop: 'auth, auth-int',
nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
opaque: '5ccc069c403ebaf9f0171e9517f40e41',
});
neatequal(
parseHTTPHeadersQuotedKeyValueSet(
'realm="testrealm@host.com", ' +
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"',
['realm', 'qop', 'nonce', 'opaque'],
),
{
realm: 'testrealm@host.com',
qop: 'auth, auth-int',
nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
opaque: '5ccc069c403ebaf9f0171e9517f40e41',
},
);
});
});
describe('buildHTTPHeadersQuotedKeyValueSet', () => {
it('should work with good datas', () => {
assert.equal(buildHTTPHeadersQuotedKeyValueSet({
realm: 'testrealm@host.com',
qop: 'auth, auth-int',
nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
opaque: '5ccc069c403ebaf9f0171e9517f40e41',
}, ['realm', 'qop', 'nonce', 'opaque']),
assert.equal(
buildHTTPHeadersQuotedKeyValueSet(
{
realm: 'testrealm@host.com',
qop: 'auth, auth-int',
nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
opaque: '5ccc069c403ebaf9f0171e9517f40e41',
},
['realm', 'qop', 'nonce', 'opaque'],
),
'realm="testrealm@host.com", ' +
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
'qop="auth, auth-int", ' +
'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
'opaque="5ccc069c403ebaf9f0171e9517f40e41"',
);
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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