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

node-freeagent2

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-freeagent2 - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

25

lib/freeagent.js

@@ -16,2 +16,3 @@ // Generated by CoffeeScript 1.4.0

FreeAgent = (function() {
var refreshToken;

@@ -76,3 +77,3 @@ function FreeAgent(access_token, sandboxMode) {

} else {
throw new Error("No callback defined!");
throw new Error('No callback defined!');
}

@@ -82,2 +83,24 @@ }

refreshToken = function(refresh_token, client_id, client_secret, callback) {
return request.post({
url: this.baseUri + 'token_endpoint',
headers: {
'Accept': 'application/json',
'User-Agent': 'node-freeagent2',
'Authorization': 'Basic ' + new Buffer("" + client_id + ":" + client_secret).toString('base64')
},
json: {
grant_type: 'refresh_token',
refresh_token: refresh_token
}
}, function(error, response, body) {
if (!error && response && response.access_token) {
this.access_token = body.access_token;
return callback(null, body.access_token);
} else {
return callback(error);
}
});
};
FreeAgent.prototype.getCompany = function(optionsOrCallback, callback) {

@@ -84,0 +107,0 @@ var params;

42

lib/passport/strategy.js

@@ -13,18 +13,18 @@ // Generated by CoffeeScript 1.4.0

baseUri = "https://api.freeagent.com/v2/";
baseUri = 'https://api.freeagent.com/v2/';
Strategy = function(options, verify) {
options = options || {};
options.authorizationURL = options.authorizationURL || baseUri + "approve_app";
options.tokenURL = options.tokenURL || baseUri + "token_endpoint";
options.scopeSeparator = options.scopeSeparator || ",";
options.authorizationURL = options.authorizationURL || baseUri + 'approve_app';
options.tokenURL = options.tokenURL || baseUri + 'token_endpoint';
options.scopeSeparator = options.scopeSeparator || ',';
OAuth2Strategy.call(this, options, verify);
return this.name = "freeagent";
return this.name = 'freeagent';
};
util = require("util");
util = require('util');
OAuth2Strategy = require("passport-oauth").OAuth2Strategy;
OAuth2Strategy = require('passport-oauth').OAuth2Strategy;
InternalOAuthError = require("passport-oauth").InternalOAuthError;
InternalOAuthError = require('passport-oauth').InternalOAuthError;

@@ -34,18 +34,18 @@ util.inherits(Strategy, OAuth2Strategy);

Strategy.prototype.userProfile = function(accessToken, done) {
return this._oauth2._request("GET", baseUri + "users/me", {
"User-Agent": "passport-freeagent2",
"Authorization": "Bearer " + accessToken
return this._oauth2._request('GET', baseUri + 'users/me', {
'User-Agent': 'passport-freeagent2',
'Authorization': "Bearer " + accessToken
}, null, accessToken, function(err, body, res) {
var json;
json = void 0;
if (err) {
return done(new InternalOAuthError("failed to fetch user profile", err));
if (!err) {
try {
json = JSON.parse(body);
json.provider = 'FreeAgent';
return done(null, json.user);
} catch (e) {
return done(e);
}
} else {
return done(new InternalOAuthError('failed to fetch user profile', err));
}
try {
json = JSON.parse(body);
json.provider = "FreeAgent";
return done(null, json.user);
} catch (e) {
return done(e);
}
});

@@ -52,0 +52,0 @@ };

{
"name": "node-freeagent2",
"version": "0.0.7",
"version": "0.0.8",
"description": "Node.js OAuth2 REST Library for use with the FreeAgent v2 API, with Passport Authentication Strategy",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

"type": "git",
"url": "https://github.com/JoeStanton/Node-FreeAgent2"
"url": "https://github.com/JoeStanton/node-freeagent2"
},

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

Sorry, the diff of this file is not supported yet

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