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

facebook-node-sdk

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

facebook-node-sdk - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/basefacebook.test.js

139

lib/basefacebook.js

@@ -28,4 +28,4 @@ var https = require('https');

var state = this.getPersistentData('state');
if (state === null) {
this.state = this.getPersistentData('state');
if (state) {
this.state = state;
}

@@ -63,10 +63,2 @@ }

BaseFacebook.prototype.setCookie = function(key, value) {
if (!this.request || !this.request.cookies) {
throw new Error('Cookie unsupported!');
}
this.request.cookies[key] = value;
return this;
};
BaseFacebook.prototype.appId = null;

@@ -218,25 +210,3 @@

var self = this;
this.getAccessTokenFromCode(code, null, function(err, accessToken) {
if (err) {
callback(err, null);
callback = null;
}
else {
if (accessToken) {
self.setPersistentData('code', code);
self.setPersistentData('access_token', accessToken);
callback(null, accessToken);
callback = null;
}
else {
// signed request states there's no access token, so anything
// stored should be cleared.
self.clearAllPersistentData();
// respect the signed request's data, even
// if there's an authorization code or something else
callback(null, false);
callback = null;
}
}
});
this.getAccessTokenFromCode(code, null, handleAccessTokenFromCode);
}

@@ -258,22 +228,3 @@ else {

var self = this;
this.getAccessTokenFromCode(code, null, function(err, accessToken) {
if (err) {
callback(err, null);
callback = null;
}
else {
if (accessToken) {
self.setPersistentData('code', code);
self.setPersistentData('access_token', accessToken);
callback(null, accessToken);
callback = null;
}
else {
// code was bogus, so everything based on it should be invalidated.
self.clearAllPersistentData();
callback(null, false);
callback = null;
}
}
});
this.getAccessTokenFromCode(code, null, handleAccessTokenFromCode);
}

@@ -289,2 +240,25 @@ else {

}
function handleAccessTokenFromCode(err, accessToken) {
if (err) {
callback(err, null);
callback = null;
}
else {
if (accessToken) {
self.setPersistentData('code', code);
self.setPersistentData('access_token', accessToken);
callback(null, accessToken);
callback = null;
}
else {
// signed request states there's no access token, so anything
// stored should be cleared.
self.clearAllPersistentData();
// respect the signed request's data, even
// if there's an authorization code or something else
callback(null, false);
callback = null;
}
}
}
};

@@ -514,13 +488,26 @@

else {
if (accessToken && accessToken !== self.getApplicationAccessToken() &&
!(user && persistedAccessToken === accessToken)) {
self.getUserFromAccessToken(function(err, user) {
if (user) {
self.setPersistentData('user_id', user);
} else {
self.clearAllPersistentData();
if (accessToken) {
// access_token is not application access_token
if (accessToken !== self.getApplicationAccessToken()) {
// undefined user or access_token is old
if (!user || persistedAccessToken !== accessToken) {
self.getUserFromAccessToken(function(err, user) {
if (user) {
self.setPersistentData('user_id', user);
} else {
self.clearAllPersistentData();
}
callback(null, user);
callback = null;
});
}
else {
callback(null, user);
callback = null;
}
}
else {
callback(null, user);
callback = null;
});
}
}

@@ -780,3 +767,3 @@ else {

var sig = this.base64UrlDecode(encodedSig);
var data = JSON.parse(this.base64UrlDecode(payload));
var data = JSON.parse(this.base64UrlDecode(payload).toString('utf8'));

@@ -833,2 +820,25 @@ if (data.algorithm.toUpperCase() !== 'HMAC-SHA256') {

/**
* Retrieves the UID with the understanding that
* $this->accessToken has already been set and is
* seemingly legitimate. It relies on Facebook's Graph API
* to retrieve user information and then extract
* the user ID.
*
* @return integer Returns the UID of the Facebook user, or 0
* if the Facebook user could not be determined.
*/
BaseFacebook.prototype.getUserFromAccessToken = function(callback) {
this.api('/me', function(err, userInfo) {
if (err) {
callback(null, 0);
callback = null;
}
else {
callback(null, userInfo.id);
callback = null;
}
});
};
/**
* Retrieves an access token for the given authorization code

@@ -883,3 +893,3 @@ * (previously generated from www.facebook.com on behalf of

var responseParams = querystring.parse(responseParams);
if (responseParams.hasOwnProperty('access_token')) {
if (!responseParams.hasOwnProperty('access_token')) {
callback(null, false);

@@ -1122,2 +1132,5 @@ callback = null;

// for test
BaseFacebook.FacebookApiError = FacebookApiError;
module.exports = BaseFacebook;
{
"name": "facebook-node-sdk",
"version": "0.0.1",
"version": "0.1.0",
"description": "Node.js SDK for the Facebook API",

@@ -21,5 +21,6 @@ "tags": ["facebook"],

"devDependencies": {
"nodeunit": ">=0.6.4"
"expresso": ">=0.9.2",
"express": ">=2.5.1"
},
"main": "./lib/facebook"
}

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