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

http-auth

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-auth - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

.eslintrc.json

7

package.json
{
"name": "http-auth",
"description": "Node.js package for HTTP basic and digest access authentication.",
"version": "4.0.0",
"version": "4.0.1",
"author": "Gevorg Harutyunyan (http://github.com/gevorg)",

@@ -36,2 +36,4 @@ "maintainers": [

"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-plugin-node": "^11.0.0",
"mocha": "^7.0.1",

@@ -44,3 +46,4 @@ "request": "^2.88.0"

"scripts": {
"test": "mocha"
"test": "mocha",
"pretest": "eslint --ignore-path .gitignore ."
},

@@ -47,0 +50,0 @@ "keywords": [

# http-auth
[Node.js](http://nodejs.org/) package for HTTP basic and digest access authentication.
![Node.js CI](https://github.com/http-auth/http-auth/workflows/Node.js%20CI/badge.svg)
[![build](https://github.com/http-auth/http-auth/workflows/build/badge.svg)](https://github.com/http-auth/http-auth/actions?query=workflow%3Abuild)

@@ -29,5 +29,5 @@ ## Installation

// Creating new HTTP server.
http.createServer(basic, (req, res) => {
http.createServer(basic.check((req, res) => {
res.end(`Welcome to private area - ${req.user}!`);
}).listen(1337);
})).listen(1337);

@@ -49,5 +49,5 @@ ```

// Creating new HTTP server.
http.createServer(basic, (req, res) => {
http.createServer(basic.check((req, res) => {
res.end(`Welcome to private area - ${req.user}!`);
}).listen(1337);
})).listen(1337);
```

@@ -130,8 +130,2 @@

## Development dependencies
- **[mocha](https://mochajs.org/)** - simple, flexible, fun javascript test framework for node.js & the browser.
- **[chai](http://chaijs.com/)** - BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
- **[request](https://github.com/request/request/)** - Simplified HTTP request client.
## License

@@ -138,0 +132,0 @@

@@ -44,2 +44,3 @@ "use strict";

// Processing user line.
// eslint-disable-next-line no-unused-vars
processLine(userLine) {

@@ -50,2 +51,3 @@ throw new Error('Not defined!');

// Parse auth header.
// eslint-disable-next-line no-unused-vars
parseAuthorization(header) {

@@ -56,2 +58,3 @@ throw new Error('Not defined!');

// Find user.
// eslint-disable-next-line no-unused-vars
findUser(req, clientOptions, callback) {

@@ -62,2 +65,3 @@ throw new Error('Not defined!');

// Generates header.
// eslint-disable-next-line no-unused-vars
generateHeader(result) {

@@ -84,26 +88,28 @@ throw new Error('Not defined!');

// Checking if user is authenticated.
check(req, res, callback) {
check(callback) {
let self = this;
this.isAuthenticated(req, (result) => {
if (result instanceof Error) {
self.emit('error', result, req);
if (callback) {
callback.apply(self, [req, res, result]);
return (req, res) => {
this.isAuthenticated(req, (result) => {
if (result instanceof Error) {
self.emit('error', result, req);
res.statusCode = 400;
res.end(result.message);
} else if (!result.pass) {
self.emit('fail', result, req);
self.ask(res, result);
} else {
self.emit('success', result, req);
if (!self.options.skipUser) {
req.user = result.user;
}
if (callback) {
callback.apply(self, [req, res]);
}
}
} else if (!result.pass) {
self.emit('fail', result, req);
self.ask(res, result);
} else {
self.emit('success', result, req);
if (!this.options.skipUser) {
req.user = result.user;
}
if (callback) {
callback.apply(self, [req, res]);
}
}
});
});
}
}

@@ -110,0 +116,0 @@

@@ -44,3 +44,3 @@ "use strict";

return crypto.timingSafeEqual ?
crypto.timingSafeEqual(new Buffer(hash), new Buffer(password)) : hash === password;
crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(password)) : hash === password;
}

@@ -61,3 +61,3 @@ }

generateHeader () {
return `Basic realm=\"${this.options.realm}\"`;
return `Basic realm="${this.options.realm}"`;
}

@@ -64,0 +64,0 @@

@@ -195,3 +195,3 @@ "use strict";

// Returning it.
return `Digest realm=\"${this.options.realm}\", qop=\"${this.options.qop}\", nonce=\"${nonce}\", algorithm=\"${this.options.algorithm}\", stale=\"${stale}\"`;
return `Digest realm="${this.options.realm}", qop="${this.options.qop}", nonce="${nonce}", algorithm="${this.options.algorithm}", stale="${stale}"`;
}

@@ -198,0 +198,0 @@ }

@@ -33,12 +33,3 @@ "use strict";

// Check if module is available.
utils.isAvailable = (path) => {
try {
return !!require.resolve(path);
} catch (err) {
return false;
}
};
// Export utils.
module.exports = utils;
"use strict";
// Utils.
const utils = require('./auth/utils');
// http integration.
require('./server/http');
// https integration.
require('./server/https');
// Exports.

@@ -13,0 +3,0 @@ module.exports = {

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