New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

faithlife-oauth

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faithlife-oauth - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

81

lib/consumer.js

@@ -9,5 +9,3 @@ /*!

var express = require('express');
var rest = require('rest');
var restMime = require('rest/interceptor/mime');
var restError = require('rest/interceptor/errorCode');
var superagent = require('superagent');
var utils = require('./utils');

@@ -34,4 +32,2 @@

this.secret = options.secret || process.env.FAITHLIFE_CONSUMER_SECRET || null;
this.request = rest.wrap(restMime).wrap(restError);
}

@@ -86,3 +82,3 @@ FaithlifeOAuthConsumer.createConsumer = FaithlifeOAuthConsumer;

*/
FaithlifeOAuthConsumer.prototype.generateSubapp = function generateSubapp(location) {
FaithlifeOAuthConsumer.prototype.subapp = function subapp(location) {
var self = this;

@@ -105,19 +101,18 @@ var app = express();

app.get('/signin', function (request, response, next) {
self.request({
method: 'POST',
path: self.rootUrl + '/v1/temporarytoken',
headers: {
Authorization: self.generateAuthHeader({
// TODO(schoon) - Use HTTP(S) based on environment.
oauth_callback: 'http://' + request.header('host') + location + '/verify'
})
}
})
.then(function (data) {
request.session.oauth_token_secret = data.entity.oauth_token_secret;
superagent.post(self.rootUrl + '/v1/temporarytoken')
.set('Authorization', self.generateAuthHeader({
// TODO(schoon) - Use HTTP(S) based on environment.
oauth_callback: 'http://' + request.header('host') + request.baseUrl + '/verify'
}))
.on('error', next)
.end(function (data) {
if (data.status !== 200) {
return next(new Error('Failed to get temporary token with ' + data.status + ': ' + data.body.message));
}
request.session.oauth_token_secret = data.body.oauth_token_secret;
request.session.original_url = request.header('referer') || request.param('original_url');
response.redirect(302, self.rootUrl + '/v1/authorize?' + querystring.stringify(data.entity));
})
.then(null, next);
response.redirect(302, self.rootUrl + '/v1/authorize?' + querystring.stringify(data.body));
});
});

@@ -128,14 +123,14 @@

app.get('/verify', function (request, response, next) {
self.request({
method: 'POST',
path: self.rootUrl + '/v1/accesstoken',
headers: {
Authorization: self.generateAuthHeader({
oauth_token_secret: request.session.oauth_token_secret,
oauth_token: request.param('oauth_token'),
oauth_verifier: request.param('oauth_verifier')
})
}
})
.then(function (data) {
superagent.post(self.rootUrl + '/v1/accesstoken')
.set('Authorization', self.generateAuthHeader({
oauth_token_secret: request.session.oauth_token_secret,
oauth_token: request.param('oauth_token'),
oauth_verifier: request.param('oauth_verifier')
}))
.on('error', next)
.end(function (data) {
if (data.status !== 200) {
return next(new Error('Failed to get access token with ' + data.status + ': ' + data.body.message));
}
var original_url = request.session.original_url;

@@ -146,10 +141,7 @@

request.session.oauth_token = data.entity.oauth_token;
request.session.oauth_token_secret = data.entity.oauth_token_secret;
request.session.oauth_token = data.body.oauth_token;
request.session.oauth_token_secret = data.body.oauth_token_secret;
response.redirect(302, original_url || '/');
}, function (data) {
console.log('BRV:', data);
})
.then(null, next);
});
});

@@ -170,9 +162,2 @@

/**
* Mounts a subapp on `app` at the specified `location`.
*/
FaithlifeOAuthConsumer.prototype.mountRoutes = function mountRoutes(app, location) {
return app.use(location, this.generateSubapp(location));
};
/**
* Generates a Single-Sign-On request URL, which should be used as the `src`

@@ -197,3 +182,3 @@ * attribute in a script tag after `methodName` has been defined.

*/
FaithlifeOAuthConsumer.prototype.authorizationHandler = function authorizationHandler() {
FaithlifeOAuthConsumer.prototype.authorization = function authorization() {
var self = this;

@@ -204,4 +189,2 @@

console.log('AUTH:', request.authorization);
next();

@@ -208,0 +191,0 @@ };

{
"name": "faithlife-oauth",
"version": "0.4.0",
"version": "0.4.1",
"description": "Middleware and Consumers for authenticating with the Faithlife API via OAuth.",

@@ -16,4 +16,4 @@ "main": "lib/index.js",

"express": "~4.9.4",
"rest": "~1.1.1"
"superagent": "~0.18.2"
}
}
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