Use Prettier JS (#5017)

* Adds prettier

* Run lint before tests
This commit is contained in:
Florent Vilmart
2018-09-01 13:58:06 -04:00
committed by GitHub
parent 189cd259ee
commit d83a0b6808
240 changed files with 41098 additions and 29020 deletions

View File

@@ -1,16 +1,20 @@
const crypto = require('crypto');
const httpsRequest = require('./httpsRequest');
const Parse = require('parse/node').Parse;
const Parse = require('parse/node').Parse;
const graphRequest = (path) => {
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;
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}`
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}`;
}
@@ -20,36 +24,37 @@ function validateAppId(appIds, authData, options) {
return Promise.reject(
new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Facebook app id for Account Kit is not configured.')
)
'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.');
})
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.');
})
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
validateAuthData,
};