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

moneypenny-client

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moneypenny-client - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

89

app/moneypenny-client/__test__/indexTests.js

@@ -155,2 +155,30 @@ var should = require('should');

it('adds passport function that calls bacj with no user if it fails to deseralize user from JWT', ()=>{
var deseralizeFn;
var OAuthClient = proxyquire('../index', {
passport : {
use : () => {},
serializeUser : () => {},
deserializeUser : (fn) => {
deseralizeFn = fn;
}
}
});
new OAuthClient({
jwtSecret: 'top secret',
providerHost: 'testProviderHost',
serverHost: 'testServerHost',
oAuthClientID: 'testClientID',
oAuthClientSecret: 'testSecret.'
});
var user = {
name: 'Test User'
}
var token = jwt.sign(user, 'top secret1');
deseralizeFn(token, (err, retUser)=>{
retUser.name.should.equal(false);
should.not.exist(err);
});
});
describe('OAuth2Strategy added', ()=> {

@@ -317,5 +345,61 @@ var deseralizeFunction;

describe('route setup', ()=> {
describe('logout route', ()=>{
var OAuth2Strategy = function(options, callback){
};
var OAuthClient = proxyquire('../index', {
'passport-oauth' : {
OAuth2Strategy : OAuth2Strategy
}
});
var oauthClient = new OAuthClient({
jwtSecret: 'top secret',
providerHost: 'testProviderHost',
serverHost: 'testServerHost',
oAuthClientID: 'testClientID',
oAuthClientSecret: 'testSecret.',
loginUri: 'loginUri',
logoutUri: 'logoutUri',
callbackURI: 'callbackUri'
});
var getLst = {};
var app = {
use : sinon.stub(),
get : (url, fn1, fn2) => {
getLst[url] = fn1;
}
};
oauthClient.initialize(app);
it('Logs user out of session', () => {
var req = {
logout: sinon.stub(),
query : {}
}
var res = {
redirect : sinon.stub()
}
getLst.logoutUri(req, res);
req.logout.called.should.equal(true);
});
it('Redirects to the moneypenny server, appending the redirect URI', ()=>{
var req = {
logout: sinon.stub(),
query : {
redirect_uri : 'redirect'
}
}
var res = {
redirect : sinon.stub()
}
getLst.logoutUri(req, res);
res.redirect.calledWith('http://testProviderHost:443/logout?redirect_uri=redirect');
});
});
describe('callback route', ()=>{
var OAuth2Strategy = function(options, callback){
};

@@ -335,2 +419,3 @@ var OAuthClient = proxyquire('../index', {

loginUri: 'loginUri',
logoutUri: 'logoutUri',
callbackURI: 'callbackUri'

@@ -346,4 +431,4 @@ });

};
oauthClient.initialize(app);
oauthClient.initialize(app);
it('returns redirects the user to their previous url.', (done) => {

@@ -350,0 +435,0 @@ var req = {

@@ -15,2 +15,3 @@ var passport = require('passport');

var DEFAULT_CALLBACK_URI = '/auth/provider/callback';
var DEFAULT_LOGOUT_URI = '/logout';
var DEFAULT_PROVIDER_NAME = 'auth-server';

@@ -39,3 +40,3 @@ var DEFAULT_PROVIDER_PORT = 443;

* * providerName - name of the provider, unimportant only used internally
* * providerHost - web accessable host name of the authentication server.
* * provithanksderHost - web accessable host name of the authentication server.
* *

@@ -61,5 +62,8 @@ */

var callbackURI = setOptionOrDefault('callbackURI', DEFAULT_CALLBACK_URI);
var logoutUriAuthServer = setOptionOrDefault('logoutUriAuthServer', DEFAULT_LOGOUT_URI);
var loginUri = setOptionOrDefault('loginUri', LOGIN_URI);
var logoutUri = setOptionOrDefault('logoutUri', DEFAULT_LOGOUT_URI);
//APIKeyStrategy and extract users from JWT.
// APIKeyStrategy and extract users from JWT.
var apiKeyStrategy = new LocalAPIKeyStrategy(userFromJwt(jwtSecret));

@@ -81,2 +85,10 @@

var logout = function(req, res){
req.logout();
var url = util.format('http://%s:%d%s', providerHost, providerPort, logoutUriAuthServer);
if (req.query.redirect_uri){
url = util.format('%s?redirect_uri=', encodeURIComponent(req.query.redirect_uri));
}
res.redirect(url);
}

@@ -94,2 +106,3 @@ var setupRoutes = function(app){

app.get(loginUri, passport.authenticate(providerName));
app.get(logoutUri, logout);
}

@@ -162,3 +175,2 @@

} else {
console.log('USING API TOKEN !!!');
return passport.authenticate(['localapikey'], { session: false })(req, res, next);

@@ -165,0 +177,0 @@ }

2

package.json
{
"name": "moneypenny-client",
"version": "0.0.4",
"version": "0.0.5",
"description": "Moneypenny authentication client, allows node js applications to authenticate using moneypenny",

@@ -5,0 +5,0 @@ "main": "app.js",

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