fix: remove remnants of servicebot

None of the code was still in use.
This commit is contained in:
Oliver Eyton-Williams
2020-08-26 15:51:56 +02:00
committed by Mrugesh Mohapatra
parent 5ce8abc131
commit c772382d59
8 changed files with 5 additions and 81 deletions

View File

@ -1,6 +1,5 @@
import Stripe from 'stripe';
import debug from 'debug';
import crypto from 'crypto';
import { isEmail, isNumeric } from 'validator';
import {
@ -223,45 +222,6 @@ export default function donateBoot(app, done) {
});
}
function createHmacHash(req, res) {
const { user, body } = req;
if (!user || !body) {
return res
.status(500)
.send({ error: 'User must be signed in for this request.' });
}
const { email } = body;
if (!isEmail('' + email)) {
return res
.status(500)
.send({ error: 'The email is invalid for this request.' });
}
if (!user.donationEmails.includes(email)) {
return res.status(500).send({
error: `User does not have the email: ${email} associated with their donations.`
});
}
log(`creating HMAC hash for ${email}`);
return Promise.resolve(email)
.then(email =>
crypto
.createHmac('sha256', keys.servicebot.hmacKey)
.update(email)
.digest('hex')
)
.then(hash => res.status(200).json({ hash }))
.catch(() =>
res
.status(500)
.send({ error: 'Donation failed due to a server error.' })
);
}
function addDonation(req, res) {
const { user, body } = req;
@ -304,7 +264,6 @@ export default function donateBoot(app, done) {
const secKey = keys.stripe.secret;
const paypalKey = keys.paypal.client;
const paypalSec = keys.paypal.secret;
const hmacKey = keys.servicebot.hmacKey;
const stripeSecretInvalid = !secKey || secKey === 'sk_from_stripe_dashboard';
const stripPublicInvalid =
!stripeKey || stripeKey === 'pk_from_stripe_dashboard';
@ -313,12 +272,11 @@ export default function donateBoot(app, done) {
!paypalKey || paypalKey === 'id_from_paypal_dashboard';
const paypalPublicInvalid =
!paypalSec || paypalSec === 'secret_from_paypal_dashboard';
const hmacKeyInvalid =
!hmacKey || hmacKey === 'secret_key_from_servicebot_dashboard';
const paypalInvalid = paypalPublicInvalid || paypalSecretInvalid;
const stripeInvalid = stripeSecretInvalid || stripPublicInvalid;
if (stripeInvalid || paypalInvalid || hmacKeyInvalid) {
if (stripeInvalid || paypalInvalid) {
if (process.env.FREECODECAMP_NODE_ENV === 'production') {
throw new Error('Donation API keys are required to boot the server!');
}
@ -326,7 +284,6 @@ export default function donateBoot(app, done) {
done();
} else {
api.post('/charge-stripe', createStripeDonation);
api.post('/create-hmac-hash', createHmacHash);
api.post('/add-donation', addDonation);
hooks.post('/update-paypal', updatePaypal);
donateRouter.use('/donate', api);

View File

@ -52,15 +52,12 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
}
}
if (!env.stripePublicKey || !env.servicebotId) {
if (!env.stripePublicKey) {
if (process.env.FREECODECAMP_NODE_ENV === 'production') {
throw new Error(
'Stripe public key and Servicebot id are required to start the client!'
);
throw new Error('Stripe public key is required to start the client!');
} else {
reporter.info(
'Stripe public key or Servicebot id missing or invalid. Required for' +
' donations.'
'Stripe public key missing or invalid. Required for donations.'
);
}
}

View File

@ -177,9 +177,6 @@ li.disabled > a {
[name='payment-method'] {
font-family: 'Lato', sans-serif;
}
.servicebot-embed-panel .panel {
padding: 20px;
}
@media (max-width: 991px) {
.donate-text {

View File

@ -66,10 +66,6 @@ export function verifySubscriptionPaypal(body) {
return post('/donate/add-donation', body);
}
export function postCreateHmacHash(body) {
return post(`/donate/create-hmac-hash`, body);
}
export function putUpdateLegacyCert(body) {
return post('/update-my-projects', body);
}

View File

@ -26,14 +26,6 @@ export const stripeScriptLoader = onload =>
onload
);
export const servicebotScriptLoader = () =>
scriptLoader(
'servicebot-billing-settings-embed.js',
'servicebot-billing-settings-embed.js',
true,
'https://js.servicebot.io/embeds/servicebot-billing-settings-embed.js'
);
export const mathJaxScriptLoader = () =>
scriptLoader(
'mathjax',

View File

@ -16,7 +16,6 @@ const {
NEWS_LOCATION: news,
LOCALE: locale,
STRIPE_PUBLIC_KEY: stripePublicKey,
SERVICEBOT_ID: servicebotId,
ALGOLIA_APP_ID: algoliaAppId,
ALGOLIA_API_KEY: algoliaAPIKey,
PAYPAL_CLIENT_ID: paypalClientId,
@ -38,10 +37,6 @@ module.exports = Object.assign(locations, {
!stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard'
? null
: stripePublicKey,
servicebotId:
!servicebotId || servicebotId === 'servicebot_id_from_servicebot_dashboard'
? null
: servicebotId,
algoliaAppId:
!algoliaAppId || algoliaAppId === 'Algolia app id from dashboard'
? null

View File

@ -31,9 +31,6 @@ const {
STRIPE_PUBLIC_KEY,
STRIPE_SECRET_KEY,
SERVICEBOT_ID,
SERVICEBOT_HMAC_SECRET_KEY,
PAYPAL_CLIENT_ID,
PAYPAL_SECRET,
@ -109,10 +106,5 @@ module.exports = {
verifyWebhookURL: PAYPAL_VERIFY_WEBHOOK_URL,
tokenUrl: PAYPAL_API_TOKEN_URL,
webhookId: PAYPAL_WEBHOOK_ID
},
servicebot: {
servicebotId: SERVICEBOT_ID,
hmacKey: SERVICEBOT_HMAC_SECRET_KEY
}
};

View File

@ -35,8 +35,6 @@ ALGOLIA_API_KEY=api_key_from_algolia_dashboard
STRIPE_CREATE_PLANS=true
STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard
STRIPE_SECRET_KEY=sk_from_stripe_dashboard
SERVICEBOT_ID=servicebot_id_from_servicebot_dashboard
SERVICEBOT_HMAC_SECRET_KEY=secret_key_from_servicebot_dashboard
# PayPal
PAYPAL_SUPPORTERS=1703
PAYPAL_CLIENT_ID=id_from_paypal_dashboard