New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 0.0.1 to 0.0.2

API.md

15

dist/index.js

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

/**
* Basic authentication mecanism.
* @type {Object}
* @see {@link module:http-auth-utils/mecanisms/basic}
*/
exports.BASIC = _mecanismsBasic2['default'];
/**
* Digest authentication mecanism.
* @type {Object}
* @see {@link module:http-auth-utils/mecanisms/digest}
*/
exports.DIGEST = _mecanismsDigest2['default'];
/**
* Natively supported authentication mecanisms.
* @type {Array}
* @see The Basic {@link module:http-auth-utils/mecanisms/basic} and Digest {@link module:http-auth-utils/mecanisms/digest}
*/

@@ -31,0 +44,0 @@ var mecanisms = [_mecanismsBasic2['default'], _mecanismsDigest2['default']];

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

data: {
username: 'Aladdin',
password: 'open sesame',
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='

@@ -47,3 +49,8 @@ }

});
it('should export bot DIGEST and BASIC mecanisms', function () {
(0, _assert2['default'])(_index.BASIC);
(0, _assert2['default'])(_index.DIGEST);
});
});
});

@@ -75,3 +75,5 @@ /**

* BASIC.parseAuthorizationRest('QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
* hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
* hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
* username: 'Aladdin',
* password: 'open sesame'
* }

@@ -85,4 +87,12 @@ * );

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

@@ -104,5 +114,15 @@ },

*/
buildAuthorizationRest: function buildAuthorizationRest(_ref) {
buildAuthorizationRest: function buildAuthorizationRest() {
var _ref = arguments[0] === undefined ? {} : arguments[0];
var hash = _ref.hash;
var username = _ref.username;
var password = _ref.password;
if (username && password) {
return BASIC.computeHash({ username: username, password: password });
}
if (!hash) {
throw new _yerror2['default']('E_NO_HASH');
}
return hash;

@@ -109,0 +129,0 @@ },

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

(0, _neatequal2['default'])(_basic2['default'].parseAuthorizationRest('QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
username: 'Aladdin',
password: 'open sesame'
});

@@ -64,4 +66,11 @@ });

it('should work', function () {
it('should work with credentials', function () {
_assert2['default'].equal(_basic2['default'].buildAuthorizationRest({
username: 'Aladdin',
password: 'open sesame'
}), 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==');
});
it('should work with just the hash', function () {
_assert2['default'].equal(_basic2['default'].buildAuthorizationRest({
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='

@@ -73,5 +82,9 @@ }), 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==');

(0, _neatequal2['default'])(_basic2['default'].parseAuthorizationRest(_basic2['default'].buildAuthorizationRest({
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
username: 'Aladdin',
password: 'open sesame'
})), {
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
username: 'Aladdin',
password: 'open sesame'
});

@@ -78,0 +91,0 @@ });

2

package.json
{
"name": "http-auth-utils",
"version": "0.0.1",
"version": "0.0.2",
"description": "Parse, build and deal with HTTP auth headers.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -51,3 +51,2 @@ # http-auth-utils

**Kind**: static constant of <code>[http-auth-utils](#module_http-auth-utils)</code>
**See**: The Basic [http-auth-utils/mecanisms/basic](#module_http-auth-utils/mecanisms/basic) and Digest [http-auth-utils/mecanisms/digest](#module_http-auth-utils/mecanisms/digest)
<a name="module_http-auth-utils.parseWWWAuthenticateHeader"></a>

@@ -54,0 +53,0 @@ ### http-auth-utils.parseWWWAuthenticateHeader ⇒ <code>Object</code>

@@ -11,5 +11,18 @@ import YError from 'yerror';

/**
* Basic authentication mecanism.
* @type {Object}
* @see {@link module:http-auth-utils/mecanisms/basic}
*/
export {BASIC as BASIC};
/**
* Digest authentication mecanism.
* @type {Object}
* @see {@link module:http-auth-utils/mecanisms/digest}
*/
export {DIGEST as DIGEST};
/**
* Natively supported authentication mecanisms.
* @type {Array}
* @see The Basic {@link module:http-auth-utils/mecanisms/basic} and Digest {@link module:http-auth-utils/mecanisms/digest}
*/

@@ -16,0 +29,0 @@ export const mecanisms = [BASIC, DIGEST];

@@ -6,3 +6,5 @@ import assert from 'assert';

parseAuthorizationHeader,
mecanisms
mecanisms,
BASIC,
DIGEST
} from './index';

@@ -34,2 +36,4 @@

data: {
username: 'Aladdin',
password: 'open sesame',
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='

@@ -52,4 +56,9 @@ }

it('should export bot DIGEST and BASIC mecanisms', function() {
assert(BASIC);
assert(DIGEST);
});
});
});

@@ -66,3 +66,5 @@ /**

* BASIC.parseAuthorizationRest('QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
* hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
* hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
* username: 'Aladdin',
* password: 'open sesame'
* }

@@ -76,4 +78,7 @@ * );

}
let {username, password} = BASIC.decodeHash(rest);
return {
hash: rest
hash: rest,
username,
password
};

@@ -95,3 +100,9 @@ },

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

@@ -98,0 +109,0 @@ },

@@ -56,3 +56,5 @@ import assert from 'assert';

BASIC.parseAuthorizationRest('QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
username: 'Aladdin',
password: 'open sesame'
}

@@ -66,5 +68,15 @@ );

it('should work', function() {
it('should work with credentials', function() {
assert.equal(
BASIC.buildAuthorizationRest({
username: 'Aladdin',
password: 'open sesame'
}),
'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
);
});
it('should work with just the hash', function() {
assert.equal(
BASIC.buildAuthorizationRest({
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='

@@ -80,6 +92,10 @@ }),

BASIC.buildAuthorizationRest({
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
username: 'Aladdin',
password: 'open sesame'
})
), {
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
username: 'Aladdin',
password: 'open sesame'
});

@@ -86,0 +102,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc