Remove Facebook AccountKit auth (#6870)
* Remove Facebook AccountKit auth Account Kit services are no longer available. https://developers.facebook.com/blog/post/2019/09/09/account-kit-services-no-longer-available-starting-march/ https://www.sinch.com/blog/facebook-account-kit-is-closing-down-are-your-apps-covered/ * remove flaky test
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
const crypto = require('crypto');
|
||||
const httpsRequest = require('./httpsRequest');
|
||||
const Parse = require('parse/node').Parse;
|
||||
|
||||
const graphRequest = path => {
|
||||
return httpsRequest.get(`https://graph.accountkit.com/v1.1/${path}`);
|
||||
};
|
||||
|
||||
function getRequestPath(authData, options) {
|
||||
const access_token = authData.access_token,
|
||||
appSecret = options && options.appSecret;
|
||||
if (appSecret) {
|
||||
const appsecret_proof = crypto
|
||||
.createHmac('sha256', appSecret)
|
||||
.update(access_token)
|
||||
.digest('hex');
|
||||
return `me?access_token=${access_token}&appsecret_proof=${appsecret_proof}`;
|
||||
}
|
||||
return `me?access_token=${access_token}`;
|
||||
}
|
||||
|
||||
function validateAppId(appIds, authData, options) {
|
||||
if (!appIds.length) {
|
||||
return Promise.reject(
|
||||
new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'Facebook app id for Account Kit is not configured.'
|
||||
)
|
||||
);
|
||||
}
|
||||
return graphRequest(getRequestPath(authData, options)).then(data => {
|
||||
if (data && data.application && appIds.indexOf(data.application.id) != -1) {
|
||||
return;
|
||||
}
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'Facebook app id for Account Kit is invalid for this user.'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function validateAuthData(authData, options) {
|
||||
return graphRequest(getRequestPath(authData, options)).then(data => {
|
||||
if (data && data.error) {
|
||||
throw data.error;
|
||||
}
|
||||
if (data && data.id == authData.id) {
|
||||
return;
|
||||
}
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'Facebook Account Kit auth is invalid for this user.'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
validateAppId,
|
||||
validateAuthData,
|
||||
};
|
||||
@@ -4,7 +4,6 @@ const apple = require('./apple');
|
||||
const gcenter = require('./gcenter');
|
||||
const gpgames = require('./gpgames');
|
||||
const facebook = require('./facebook');
|
||||
const facebookaccountkit = require('./facebookaccountkit');
|
||||
const instagram = require('./instagram');
|
||||
const linkedin = require('./linkedin');
|
||||
const meetup = require('./meetup');
|
||||
@@ -39,7 +38,6 @@ const providers = {
|
||||
gcenter,
|
||||
gpgames,
|
||||
facebook,
|
||||
facebookaccountkit,
|
||||
instagram,
|
||||
linkedin,
|
||||
meetup,
|
||||
@@ -62,7 +60,7 @@ const providers = {
|
||||
};
|
||||
|
||||
function authDataValidator(adapter, appIds, options) {
|
||||
return function(authData) {
|
||||
return function (authData) {
|
||||
return adapter.validateAuthData(authData, options).then(() => {
|
||||
if (appIds) {
|
||||
return adapter.validateAppId(appIds, authData, options);
|
||||
@@ -117,13 +115,13 @@ function loadAuthAdapter(provider, authOptions) {
|
||||
return { adapter, appIds, providerOptions };
|
||||
}
|
||||
|
||||
module.exports = function(authOptions = {}, enableAnonymousUsers = true) {
|
||||
module.exports = function (authOptions = {}, enableAnonymousUsers = true) {
|
||||
let _enableAnonymousUsers = enableAnonymousUsers;
|
||||
const setEnableAnonymousUsers = function(enable) {
|
||||
const setEnableAnonymousUsers = function (enable) {
|
||||
_enableAnonymousUsers = enable;
|
||||
};
|
||||
// To handle the test cases on configuration
|
||||
const getValidatorForProvider = function(provider) {
|
||||
const getValidatorForProvider = function (provider) {
|
||||
if (provider === 'anonymous' && !_enableAnonymousUsers) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user