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

oauth2orize

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oauth2orize - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

lib/middleware/authorizationErrorHandler.js

28

lib/grant/code.js

@@ -188,3 +188,30 @@ /**

function errorHandler(err, txn, res, next) {
var mode = 'query'
, params = {}
, respond;
if (txn.req && txn.req.responseMode) {
mode = txn.req.responseMode;
}
respond = modes[mode];
if (!respond) {
return next(err);
}
if (respond && respond.validate) {
try {
respond.validate(txn);
} catch(ex) {
return next(err);
}
}
params.error = err.code || 'server_error';
if (err.message) { params.error_description = err.message; }
if (err.uri) { params.error_uri = err.uri; }
if (txn.req && txn.req.state) { params.state = txn.req.state; }
return respond(txn, res, params);
}
/**

@@ -197,3 +224,4 @@ * Return `code` approval module.

mod.response = response;
mod.error = errorHandler;
return mod;
};

@@ -190,3 +190,30 @@ /**

function errorHandler(err, txn, res, next) {
var mode = 'fragment'
, params = {}
, respond;
if (txn.req && txn.req.responseMode) {
mode = txn.req.responseMode;
}
respond = modes[mode];
if (!respond) {
return next(err);
}
if (respond && respond.validate) {
try {
respond.validate(txn);
} catch(ex) {
return next(err);
}
}
params.error = err.code || 'server_error';
if (err.message) { params.error_description = err.message; }
if (err.uri) { params.error_uri = err.uri; }
if (txn.req && txn.req.state) { params.state = txn.req.state; }
return respond(txn, res, params);
}
/**

@@ -199,3 +226,4 @@ * Return `token` approval module.

mod.response = response;
mod.error = errorHandler;
return mod;
};

5

lib/middleware/authorization.js

@@ -130,2 +130,4 @@ /**

if (redirectURI) { req.oauth2.redirectURI = redirectURI; }
req.oauth2.req = areq;
req.oauth2.user = req[userProperty];

@@ -135,5 +137,2 @@ if (err) { return next(err); }

req.oauth2.req = areq;
req.oauth2.user = req[userProperty];
function immediated(err, allow, info, locals) {

@@ -140,0 +139,0 @@ if (err) { return next(err); }

1

lib/middleware/decision.js

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

};
req.oauth2._endProxied = true;

@@ -114,0 +115,0 @@ server._respond(req.oauth2, res, function(err) {

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

};
req.oauth2._endProxied = true;

@@ -51,0 +52,0 @@ server._respond(req.oauth2, res, function(err) {

@@ -33,2 +33,4 @@ /**

return function transactionLoader(req, res, next) {
if (req.oauth2) { return next(); }
function loaded(err, txn) {

@@ -35,0 +37,0 @@ if (err) { return next(err); }

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

, token = require('./middleware/token')
, authorizationErrorHandler = require('./middleware/authorizationErrorHandler')
, errorHandler = require('./middleware/errorHandler')

@@ -26,2 +27,3 @@ , utils = require('./utils')

this._resHandlers = [];
this._errHandlers = [];
this._exchanges = [];

@@ -66,2 +68,3 @@

if (mod.response) { this.grant(mod.name, 'response', mod.response); }
if (mod.error) { this.grant(mod.name, 'error', mod.error); }
return this;

@@ -74,2 +77,3 @@ }

if (mod.response) { this.grant(type, 'response', mod.response); }
if (mod.error) { this.grant(type, 'error', mod.error); }
return this;

@@ -92,2 +96,5 @@ }

this._resHandlers.push({ type: type, handle: fn });
} else if (phase == 'error') {
debug('register error handler %s %s', type || '*', fn.name || 'anonymous');
this._errHandlers.push({ type: type, handle: fn });
}

@@ -157,2 +164,17 @@ return this;

Server.prototype.authorizeError =
Server.prototype.authorizationError =
Server.prototype.authorizationErrorHandler = function(options) {
var loader = transactionLoader(this, options);
return [
function transactionLoaderErrorWrapper(err, req, res, next) {
loader(req, res, function(ierr) {
return next(err);
});
},
authorizationErrorHandler(this, options)
];
};
/**

@@ -338,2 +360,25 @@ * Handle requests to exchange an authorization grant for an access token.

Server.prototype._respondError = function(err, txn, res, cb) {
var ultype = new UnorderedList(txn.req.type)
, stack = this._errHandlers
, idx = 0;
function next(err) {
var layer = stack[idx++];
if (!layer) { return cb(err); }
try {
debug('error:%s', layer.handle.name || 'anonymous');
if (layer.type === null || layer.type.equalTo(ultype)) {
layer.handle(err, txn, res, next);
} else {
next(err);
}
} catch (ex) {
return cb(ex);
}
}
next(err);
}
/**

@@ -340,0 +385,0 @@ * Process token request using registered exchange middleware.

{
"name": "oauth2orize",
"version": "1.4.1",
"version": "1.5.0",
"description": "OAuth 2.0 authorization server toolkit for Node.js.",

@@ -5,0 +5,0 @@ "keywords": [

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