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 Stripe from 'stripe';
import debug from 'debug'; import debug from 'debug';
import crypto from 'crypto';
import { isEmail, isNumeric } from 'validator'; import { isEmail, isNumeric } from 'validator';
import { 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) { function addDonation(req, res) {
const { user, body } = req; const { user, body } = req;
@ -304,7 +264,6 @@ export default function donateBoot(app, done) {
const secKey = keys.stripe.secret; const secKey = keys.stripe.secret;
const paypalKey = keys.paypal.client; const paypalKey = keys.paypal.client;
const paypalSec = keys.paypal.secret; const paypalSec = keys.paypal.secret;
const hmacKey = keys.servicebot.hmacKey;
const stripeSecretInvalid = !secKey || secKey === 'sk_from_stripe_dashboard'; const stripeSecretInvalid = !secKey || secKey === 'sk_from_stripe_dashboard';
const stripPublicInvalid = const stripPublicInvalid =
!stripeKey || stripeKey === 'pk_from_stripe_dashboard'; !stripeKey || stripeKey === 'pk_from_stripe_dashboard';
@ -313,12 +272,11 @@ export default function donateBoot(app, done) {
!paypalKey || paypalKey === 'id_from_paypal_dashboard'; !paypalKey || paypalKey === 'id_from_paypal_dashboard';
const paypalPublicInvalid = const paypalPublicInvalid =
!paypalSec || paypalSec === 'secret_from_paypal_dashboard'; !paypalSec || paypalSec === 'secret_from_paypal_dashboard';
const hmacKeyInvalid =
!hmacKey || hmacKey === 'secret_key_from_servicebot_dashboard';
const paypalInvalid = paypalPublicInvalid || paypalSecretInvalid; const paypalInvalid = paypalPublicInvalid || paypalSecretInvalid;
const stripeInvalid = stripeSecretInvalid || stripPublicInvalid; const stripeInvalid = stripeSecretInvalid || stripPublicInvalid;
if (stripeInvalid || paypalInvalid || hmacKeyInvalid) { if (stripeInvalid || paypalInvalid) {
if (process.env.FREECODECAMP_NODE_ENV === 'production') { if (process.env.FREECODECAMP_NODE_ENV === 'production') {
throw new Error('Donation API keys are required to boot the server!'); throw new Error('Donation API keys are required to boot the server!');
} }
@ -326,7 +284,6 @@ export default function donateBoot(app, done) {
done(); done();
} else { } else {
api.post('/charge-stripe', createStripeDonation); api.post('/charge-stripe', createStripeDonation);
api.post('/create-hmac-hash', createHmacHash);
api.post('/add-donation', addDonation); api.post('/add-donation', addDonation);
hooks.post('/update-paypal', updatePaypal); hooks.post('/update-paypal', updatePaypal);
donateRouter.use('/donate', api); 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') { if (process.env.FREECODECAMP_NODE_ENV === 'production') {
throw new Error( throw new Error('Stripe public key is required to start the client!');
'Stripe public key and Servicebot id are required to start the client!'
);
} else { } else {
reporter.info( reporter.info(
'Stripe public key or Servicebot id missing or invalid. Required for' + 'Stripe public key missing or invalid. Required for donations.'
' donations.'
); );
} }
} }

View File

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

View File

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

View File

@ -26,14 +26,6 @@ export const stripeScriptLoader = onload =>
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 = () => export const mathJaxScriptLoader = () =>
scriptLoader( scriptLoader(
'mathjax', 'mathjax',

View File

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

View File

@ -31,9 +31,6 @@ const {
STRIPE_PUBLIC_KEY, STRIPE_PUBLIC_KEY,
STRIPE_SECRET_KEY, STRIPE_SECRET_KEY,
SERVICEBOT_ID,
SERVICEBOT_HMAC_SECRET_KEY,
PAYPAL_CLIENT_ID, PAYPAL_CLIENT_ID,
PAYPAL_SECRET, PAYPAL_SECRET,
@ -109,10 +106,5 @@ module.exports = {
verifyWebhookURL: PAYPAL_VERIFY_WEBHOOK_URL, verifyWebhookURL: PAYPAL_VERIFY_WEBHOOK_URL,
tokenUrl: PAYPAL_API_TOKEN_URL, tokenUrl: PAYPAL_API_TOKEN_URL,
webhookId: PAYPAL_WEBHOOK_ID 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_CREATE_PLANS=true
STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard
STRIPE_SECRET_KEY=sk_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
PAYPAL_SUPPORTERS=1703 PAYPAL_SUPPORTERS=1703
PAYPAL_CLIENT_ID=id_from_paypal_dashboard PAYPAL_CLIENT_ID=id_from_paypal_dashboard