Removed that blasted hCaptcha
This commit is contained in:
parent
f7e79704f3
commit
7c312871e0
|
@ -31,9 +31,6 @@ MONERO_PRICE_LEEWAY="0.02"
|
|||
MONERO_PRICECHECK_SEC="600"
|
||||
|
||||
# API keys
|
||||
HCAPTCHA_SECRET="0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
HCAPTCHA_SITEKEY_BUGS="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
|
||||
HCAPTCHA_SITEKEY_CONTACT="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
|
||||
STRIPE_PUB="pk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
STRIPE_SEC="sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
STRIPE_RES="sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||
|
|
|
@ -5,8 +5,6 @@ module.exports = {
|
|||
SITE_DOMAIN: process.env.SITE_DOMAIN,
|
||||
ADMIN_EMAIL: process.env.ADMIN_EMAIL,
|
||||
SALES_EMAIL: process.env.SALES_EMAIL,
|
||||
HCAPTCHA_SITEKEY_CONTACT: process.env.HCAPTCHA_SITEKEY_CONTACT,
|
||||
HCAPTCHA_SITEKEY_BUGS: process.env.HCAPTCHA_SITEKEY_BUGS,
|
||||
MONERO_PRICECHECK_SEC: process.env.MONERO_PRICECHECK_SEC,
|
||||
MONERO_CHECKOUT_POLL_SECS: process.env.MONERO_CHECKOUT_POLL_SECS,
|
||||
}
|
||||
|
|
|
@ -42,15 +42,7 @@
|
|||
|
||||
<p><button id="send-button" data-bind="click:sendMsg, disable:isSending, text:sendBtnText">📨 Send</button></p>
|
||||
|
||||
<p><div class="h-captcha"
|
||||
data-sitekey="{{env.HCAPTCHA_SITEKEY_BUGS}}"
|
||||
data-size="invisible" data-theme="dark">
|
||||
</div></p>
|
||||
|
||||
<p>This form is protected by <a href="https://www.hcaptcha.com/">hCaptcha</a> so their <a href="https://hcaptcha.com/privacy">Privacy Policy</a> and <a href="https://hcaptcha.com/terms">Terms of Service</a> apply.</p>
|
||||
|
||||
<script>const API_URL = '{{env.API_DOMAIN}}'</script>
|
||||
<script src="https://js.hcaptcha.com/1/api.js"></script>
|
||||
<script src="/assets/scripts/lib/openpgp.min.js" integrity="sha256-S63N8dxnD281SQwEG6VyI+B1RDnp9lAF5Q17Ks7G2jA="></script>
|
||||
<script src="/assets/scripts/lib/knockout-3.5.1.min.js" integrity="sha256-6JV7sYKlBHsHvqCkn9IrEWFLGrmsW4KG/LIln0hljnM="></script>
|
||||
<script src="/assets/scripts/bug-disclosure-form.js" integrity="{{'/assets/scripts/bug-disclosure-form.js'|srintegrity}}"></script>
|
||||
|
|
|
@ -22,14 +22,6 @@
|
|||
|
||||
<p><button id="send-button" data-bind="click:sendMsg, disable:isSending, text:sendBtnText">📨 Send</button></p>
|
||||
|
||||
<p><div class="h-captcha"
|
||||
data-sitekey="{{env.HCAPTCHA_SITEKEY_CONTACT}}"
|
||||
data-size="invisible" data-theme="dark">
|
||||
</div></p>
|
||||
|
||||
<p>This form is protected by <a href="https://www.hcaptcha.com/">hCaptcha</a> so their <a href="https://hcaptcha.com/privacy">Privacy Policy</a> and <a href="https://hcaptcha.com/terms">Terms of Service</a> apply.</p>
|
||||
|
||||
<script>const API_URL = '{{env.API_DOMAIN}}/contact'</script>
|
||||
<script src="https://js.hcaptcha.com/1/api.js"></script>
|
||||
<script src="/assets/scripts/knockout-3.5.1.min.js" integrity="sha256-6JV7sYKlBHsHvqCkn9IrEWFLGrmsW4KG/LIln0hljnM="></script>
|
||||
<script src="/assets/scripts/contact-form.js" integrity="{{'/assets/scripts/contact-form.js'|srintegrity}}"></script>
|
||||
|
|
|
@ -106,24 +106,12 @@ class Form {
|
|||
|
||||
self.sendMsg = async () => {
|
||||
self.isSending(true)
|
||||
let capRes; try {
|
||||
capRes = await hcaptcha.execute(
|
||||
null, {async: true}
|
||||
)
|
||||
}
|
||||
catch (err) {
|
||||
alert(`Failed to submit hCaptcha. Try again later.`)
|
||||
console.error('Failed to run hCaptcha')
|
||||
if (err)
|
||||
console.error(err)
|
||||
}
|
||||
let res; try {
|
||||
res = await fetch(`${API_URL}/bug`, {
|
||||
method: 'POST',
|
||||
cache: 'no-cache',
|
||||
headers: {'content-type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
token: capRes.response,
|
||||
msg: await openpgp.encrypt({
|
||||
message: await openpgp.createMessage(
|
||||
{text: `\nBUG REPORT FOR WWW.SLVIT.US\n\nFiled: ${new Date()}\nEmail: ${self.email()}\nXMR: ${self.xmr()}\nChecksum: ${checksumElem.value}\nSignature: ${self.sig()}\nMay publish? ${self.mayPublish()}\n\n${self.bug()}\n\nPGP:${self.pgp()}\n`}
|
||||
|
@ -141,9 +129,7 @@ class Form {
|
|||
if (res.status === 200) {
|
||||
alert('Your bug report was sent successfully.')
|
||||
self.name(''); self.email(''); self.subj(''); self.body('')
|
||||
} else if (res.status === 403)
|
||||
alert(`hCaptcha failed! Please try again.`)
|
||||
else if (res.status === 500)
|
||||
} else if (res.status === 500)
|
||||
alert(`Backend failed! Please try again. If the problem persists, please email hostmaster@slvit.us.`)
|
||||
else
|
||||
alert(`Unknown error! Please try again. If the problem persists, please email hostmaster@slvit.us.`)
|
||||
|
|
|
@ -9,23 +9,12 @@ function Form() {
|
|||
|
||||
self.sendMsg = async () => {
|
||||
self.isSending(true)
|
||||
let capRes; try {
|
||||
capRes = await hcaptcha.execute(
|
||||
null, {async:true}
|
||||
)
|
||||
}
|
||||
catch (err) {
|
||||
alert(`Failed to submit hCaptcha. Try again later.`)
|
||||
console.error('Failed to run hCaptcha')
|
||||
if (err) console.error(err)
|
||||
}
|
||||
let res; try {
|
||||
res = await fetch(API_URL, {
|
||||
method: 'POST',
|
||||
cache: 'no-cache',
|
||||
headers: {'content-type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
token: capRes.response,
|
||||
name: self.name(),
|
||||
subj: self.subj(),
|
||||
email: self.email(),
|
||||
|
@ -51,9 +40,7 @@ function Form() {
|
|||
if (res.status===200) {
|
||||
alert('Your message was sent successfully.')
|
||||
self.name(''); self.email(''); self.subj(''); self.body('')
|
||||
} else if (res.status===403)
|
||||
alert(`hCaptcha failed! Please try again.`)
|
||||
else if (res.status===500)
|
||||
} else if (res.status===500)
|
||||
alert(`Backend failed! Please try again. If the problem persists, please email hostmaster@[this domain].`)
|
||||
else alert(`Unknown error! Please try again. If the problem persists, please email hostmaster@[this domain].`)
|
||||
|
||||
|
|
|
@ -18,11 +18,4 @@ We don't set these policies, but if you make a credit/debit card payment, you ar
|
|||
|
||||
- [**Stripe's End User Terms of Service >**](https://stripe.com/legal/end-users)
|
||||
- [**Stripe's Privacy Policy >**](https://stripe.com/privacy)
|
||||
|
||||
## 🪶 hcaptcha
|
||||
|
||||
Our contact forms use [hcaptcha](https://www.hcaptcha.com/) to protect from spam. The data from your form are not sent to them.
|
||||
|
||||
- [hcaptcha's Privacy Policy](https://hcaptcha.com/privacy)
|
||||
- [hcaptcha's Terms of Service](https://hcaptcha.com/terms)
|
||||
|
42
api/bug.js
42
api/bug.js
|
@ -1,38 +1,20 @@
|
|||
'use strict'
|
||||
require('dotenv').config()
|
||||
|
||||
const {verify} = require('hcaptcha')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
|
||||
// Check token
|
||||
let data; try {
|
||||
data = await verify(process.env.HCAPTCHA_SECRET, req.body['token'])
|
||||
// Send email
|
||||
let mail_res; try {
|
||||
console.log(`Sending email from to ${process.env.BUGS_MAIL_FROM}...`)
|
||||
mail_res = await require('../lib/mailer').sendMail({
|
||||
from: process.env.BUGS_MAIL_FROM,
|
||||
to: process.env.ADMIN_EMAIL,
|
||||
subject: 'Bug found!',
|
||||
text: req.body['msg'],
|
||||
})
|
||||
console.log(`Sent email ${mail_res.messageId}`)
|
||||
return res.sendStatus(200)
|
||||
} catch (err) {
|
||||
console.error(`Failed to check hcaptcha\n${err}`)
|
||||
console.error(err)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
if (data.success === true) {
|
||||
// Send email
|
||||
let mail_res; try {
|
||||
console.log(`Sending email from to ${process.env.BUGS_MAIL_FROM}...`)
|
||||
mail_res = await require('../lib/mailer').sendMail({
|
||||
from: process.env.BUGS_MAIL_FROM,
|
||||
to: process.env.ADMIN_EMAIL,
|
||||
subject: 'Bug found!',
|
||||
text: req.body['msg'],
|
||||
})
|
||||
console.log(`Sent email ${mail_res.messageId}`)
|
||||
return res.sendStatus(200)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
// hcaptcha failed
|
||||
} else {
|
||||
console.log(`Failed hCaptcha with errors: ${data['error-codes']}`)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,30 @@
|
|||
'use strict'
|
||||
require('dotenv').config()
|
||||
|
||||
const {verify} = require('hcaptcha')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
// console.log(`Received token: ${req.body['token']}`)
|
||||
|
||||
// Check token
|
||||
let data; try {
|
||||
data = await verify(process.env.HCAPTCHA_SECRET, req.body['token'])
|
||||
} catch (err) {
|
||||
console.error(`Failed to check hcaptcha\n${err}`)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
if (data.success === true) {
|
||||
|
||||
// Parse from address
|
||||
let from
|
||||
if (req.body['name'] && req.body['email']) from = `${req.body['name']} <${req.body['email']}>`
|
||||
else if (req.body['name']) from = req.body['name']
|
||||
else if (req.body['email']) from = req.body['email']
|
||||
else from = 'Anonymous'
|
||||
|
||||
// Send email
|
||||
let mail_res; try {
|
||||
console.log(`Sending email from ${from} to ${process.env.CONTACT_EMAIL}...`)
|
||||
mail_res = await require('../lib/mailer').sendMail({
|
||||
from: process.env.CONTACT_MAIL_FROM,
|
||||
replyTo: from,
|
||||
to: process.env.CONTACT_EMAIL,
|
||||
subject: req.body['subj'],
|
||||
text: req.body['msg'],
|
||||
})
|
||||
console.log(`Sent email ${mail_res.messageId}`)
|
||||
return res.sendStatus(200)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
// hcaptcha failed
|
||||
} else {
|
||||
console.log(`Failed hCaptcha with errors: ${data['error-codes']}`)
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
// Parse from address
|
||||
let from
|
||||
if (req.body['name'] && req.body['email']) from = `${req.body['name']} <${req.body['email']}>`
|
||||
else if (req.body['name']) from = req.body['name']
|
||||
else if (req.body['email']) from = req.body['email']
|
||||
else from = 'Anonymous'
|
||||
|
||||
// Send email
|
||||
let mail_res; try {
|
||||
console.log(`Sending email from ${from} to ${process.env.CONTACT_EMAIL}...`)
|
||||
mail_res = await require('../lib/mailer').sendMail({
|
||||
from: process.env.CONTACT_MAIL_FROM,
|
||||
replyTo: from,
|
||||
to: process.env.CONTACT_EMAIL,
|
||||
subject: req.body['subj'],
|
||||
text: req.body['msg'],
|
||||
})
|
||||
console.log(`Sent email ${mail_res.messageId}`)
|
||||
return res.sendStatus(200)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ services:
|
|||
- SALES_EMAIL=${SALES_EMAIL}
|
||||
- CONTACT_MAIL_FROM=${CONTACT_MAIL_FROM}
|
||||
- BUGS_MAIL_FROM=${BUGS_MAIL_FROM}
|
||||
- HCAPTCHA_SITEKEY_BUGS=${HCAPTCHA_SITEKEY_BUGS}
|
||||
- HCAPTCHA_SITEKEY_CONTACT=${HCAPTCHA_SITEKEY_CONTACT}
|
||||
- MONERO_PRICECHECK_SEC=${MONERO_PRICECHECK_SEC}
|
||||
- MONERO_CHECKOUT_POLL_SECS=${MONERO_CHECKOUT_POLL_SECS}
|
||||
volumes:
|
||||
|
@ -45,9 +43,6 @@ services:
|
|||
- API_PORT=${API_PORT}
|
||||
- ADMIN_EMAIL=${ADMIN_EMAIL}
|
||||
- SALES_EMAIL=${SALES_EMAIL}
|
||||
- HCAPTCHA_SECRET=${HCAPTCHA_SECRET}
|
||||
- HCAPTCHA_SITEKEY_BUGS=${HCAPTCHA_SITEKEY_BUGS}
|
||||
- HCAPTCHA_SITEKEY_CONTACT=${HCAPTCHA_SITEKEY_CONTACT}
|
||||
- MAIL_SERVER=${MAIL_SERVER}
|
||||
- CONTACT_MAIL_FROM=${CONTACT_MAIL_FROM}
|
||||
- SALES_MAIL_FROM=${SALES_MAIL_FROM}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"gray-matter": "^4.0.3",
|
||||
"hcaptcha": "^0.1.1",
|
||||
"luxon": "^3.3.0",
|
||||
"markdown-it": "^13.0.1",
|
||||
"nodemailer": "^6.9.1",
|
||||
|
@ -1458,11 +1457,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hcaptcha": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/hcaptcha/-/hcaptcha-0.1.1.tgz",
|
||||
"integrity": "sha512-iMrDmH2VpIEKOrcKWidVjI89FdDKTEdZ7PfPWkP27sTazIIkob8YfdY2ezaufAnWBiUUcvzsn0qF+dyXtBH2Vw=="
|
||||
},
|
||||
"node_modules/html-escaper": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
|
||||
|
@ -4168,11 +4162,6 @@
|
|||
"has-symbols": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"hcaptcha": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/hcaptcha/-/hcaptcha-0.1.1.tgz",
|
||||
"integrity": "sha512-iMrDmH2VpIEKOrcKWidVjI89FdDKTEdZ7PfPWkP27sTazIIkob8YfdY2ezaufAnWBiUUcvzsn0qF+dyXtBH2Vw=="
|
||||
},
|
||||
"html-escaper": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"gray-matter": "^4.0.3",
|
||||
"hcaptcha": "^0.1.1",
|
||||
"luxon": "^3.3.0",
|
||||
"markdown-it": "^13.0.1",
|
||||
"nodemailer": "^6.9.1",
|
||||
|
|
Loading…
Reference in New Issue