diff --git a/README.md b/README.md
index 722fd386..fdef2ff6 100644
--- a/README.md
+++ b/README.md
@@ -81,10 +81,11 @@ Configuration takes place in the environment variables that are defined in ecosy
| USE_PROXYCHECK | Check users for Proxies | 0 |
| APISOCKET_KEY | Key for API Socket for SpecialAccess™ | "SDfasife3" |
| ADMIN_IDS | Ids of users with Admin rights | "1,12,3" |
-| RECAPTCHA_SECRET | reCaptcha secret key | "asdieewff" |
-| RECAPTCHA_SITEKEY | reCaptcha site key | "23ksdfssd" |
-| RECAPTCHA_TIME | time in minutes between captchas | 30 |
-| SESSION_SECRET | random sting for expression sessions | "ayylmao" |
+| CAPTCHA_METHOD | 0: none, 1: reCaptcha, 2: hCaptcha | 2 |
+| CAPTCHA_SECRET | re/hCaptcha secret key | "asdieewff" |
+| CAPTCHA_SITEKEY | re/hCaptcha site key | "23ksdfssd" |
+| CAPTCHA_TIME | time in minutes between captchas | 30 |
+| SESSION_SECRET | random sting for express sessions | "ayylmao" |
| LOG_MYSQL | if sql queries should get logged | 0 |
| USE_XREALIP | see cloudflare section | 1 |
| BACKUP_URL | url of backup server (see Backup) | "http://localhost" |
diff --git a/src/:wq b/src/:wq
new file mode 100644
index 00000000..6d41b730
--- /dev/null
+++ b/src/:wq
@@ -0,0 +1,145 @@
+/**
+ *
+ * @flow
+ */
+
+import fetch from 'isomorphic-fetch';
+import logger from '../core/logger';
+import redis from '../data/redis';
+
+import {
+ CAPTCHA_METHOD,
+ CAPTCHA_SECRET,
+ CAPTCHA_TIME,
+} from '../core/config';
+
+const TTL_CACHE = CAPTCHA_TIME * 60; // seconds
+// eslint-disable-next-line max-len
+const RECAPTCHA_ENDPOINT = `https://www.google.com/recaptcha/api/siteverify?secret=${CAPTCHA_SECRET}`;
+const HCAPTCHA_ENDPOINT = 'https://hcaptcha.com/siteverify';
+
+/**
+ * https://stackoverflow.com/questions/27297067/google-recaptcha-how-to-get-user-response-and-validate-in-the-server-side
+ *
+ * @param token
+ * @param ip
+ * @returns {Promise. Credit for the Palette of the Moon goes to
+ Credit for the Palette of the Moon goes to
starhouse.
Left Click or tap to place a pixel
Right Click of double tap to remove a pixel
Partners: crazygames.com
-- This site is protected by reCAPTCHA and the Google - Privacy Policy and - Terms of Service apply. - -
+ { (typeof window.hcaptcha === 'undefined') + ? ( ++ This site is protected by reCAPTCHA and the Google + Privacy Policy and + Terms of Service apply. + +
+ ) : ( ++ This site is protected by hCAPTCHA and its + Privacy Policyand + Terms of Serviceapply. + +
+ )} ); diff --git a/src/components/Html.jsx b/src/components/Html.jsx index a6ffa3a7..5adf5cc9 100644 --- a/src/components/Html.jsx +++ b/src/components/Html.jsx @@ -11,7 +11,7 @@ /* eslint-disable max-len */ import React from 'react'; -import { CAPTCHA_SITEKEY } from '../core/config'; +import { CAPTCHA_METHOD, CAPTCHA_SITEKEY } from '../core/config'; const Html = ({ title, @@ -26,7 +26,7 @@ const Html = ({ // code as string code, // if recaptcha should get loaded - useRecaptcha, + useCaptcha, }) => ( @@ -48,7 +48,7 @@ const Html = ({ dangerouslySetInnerHTML={{ __html: style.cssText }} /> ))} - {CAPTCHA_SITEKEY && useRecaptcha + {(CAPTCHA_METHOD === 1) && CAPTCHA_SITEKEY && useCaptcha && ( )} - {CAPTCHA_SITEKEY && useRecaptcha && } + {(CAPTCHA_METHOD === 1) && CAPTCHA_SITEKEY && useCaptcha + && } + {(CAPTCHA_METHOD === 2) && CAPTCHA_SITEKEY && useCaptcha + && ( + + )} + {(CAPTCHA_METHOD === 2) && CAPTCHA_SITEKEY && useCaptcha + && } {code && ( , ); diff --git a/src/core/config.js b/src/core/config.js index 524894b7..67f40716 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -82,13 +82,10 @@ export const auth = { }, }; - -export const ads = { - adsense: { - id: 'ca-pub-41116611299745444', - }, -}; - +// o: none +// 1: reCaptcha +// 2: hCaptcha +export const CAPTCHA_METHOD = Number(process.env.CAPTCHA_METHOD || 0); export const CAPTCHA_SECRET = process.env.CAPTCHA_SECRET || false; export const CAPTCHA_SITEKEY = process.env.CAPTCHA_SITEKEY || false; // time on which to display captcha in minutes diff --git a/src/socket/ProtocolClient.js b/src/socket/ProtocolClient.js index 7f9435b8..5f200341 100644 --- a/src/socket/ProtocolClient.js +++ b/src/socket/ProtocolClient.js @@ -164,6 +164,7 @@ class ProtocolClient extends EventEmitter { } catch (err) { console.log( `An error occured while parsing websocket message ${message}`, + err, ); } } diff --git a/src/utils/captcha.js b/src/utils/captcha.js index 109d737c..6d41b730 100644 --- a/src/utils/captcha.js +++ b/src/utils/captcha.js @@ -8,13 +8,15 @@ import logger from '../core/logger'; import redis from '../data/redis'; import { + CAPTCHA_METHOD, CAPTCHA_SECRET, CAPTCHA_TIME, } from '../core/config'; const TTL_CACHE = CAPTCHA_TIME * 60; // seconds -const BASE_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify'; -const ENDPOINT = `${BASE_ENDPOINT}?secret=${CAPTCHA_SECRET}`; +// eslint-disable-next-line max-len +const RECAPTCHA_ENDPOINT = `https://www.google.com/recaptcha/api/siteverify?secret=${CAPTCHA_SECRET}`; +const HCAPTCHA_ENDPOINT = 'https://hcaptcha.com/siteverify'; /** * https://stackoverflow.com/questions/27297067/google-recaptcha-how-to-get-user-response-and-validate-in-the-server-side @@ -27,11 +29,7 @@ async function verifyReCaptcha( token: string, ip: string, ): Promise