upd: add FriendlyCaptcha as a captcha solution
FriendlyCaptcha is a german captcha solution which is GDPR compliant and has a non-commerical free license
This commit is contained in:
parent
8824422cb5
commit
d786e96c2b
18 changed files with 175 additions and 7 deletions
|
|
@ -27,9 +27,12 @@ export type Captcha = {
|
|||
execute(id: string): void;
|
||||
reset(id?: string): void;
|
||||
getResponse(id: string): string;
|
||||
WidgetInstance(container: string | Node, options: {
|
||||
readonly [_ in 'sitekey' | 'doneCallback' | 'errorCallback' | 'puzzleEndpoint']?: unknown;
|
||||
}): void;
|
||||
};
|
||||
|
||||
export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile' | 'mcaptcha';
|
||||
export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile' | 'mcaptcha' | 'fc';
|
||||
|
||||
type CaptchaContainer = {
|
||||
readonly [_ in CaptchaProvider]?: Captcha;
|
||||
|
|
@ -60,6 +63,7 @@ const variable = computed(() => {
|
|||
case 'recaptcha': return 'grecaptcha';
|
||||
case 'turnstile': return 'turnstile';
|
||||
case 'mcaptcha': return 'mcaptcha';
|
||||
case 'fc': return 'friendlyChallenge';
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -70,6 +74,7 @@ const src = computed(() => {
|
|||
case 'hcaptcha': return 'https://js.hcaptcha.com/1/api.js?render=explicit&recaptchacompat=off';
|
||||
case 'recaptcha': return 'https://www.recaptcha.net/recaptcha/api.js?render=explicit';
|
||||
case 'turnstile': return 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
|
||||
case 'fc': return 'https://cdn.jsdelivr.net/npm/friendly-challenge@0.9.18/widget.min.js';
|
||||
case 'mcaptcha': return null;
|
||||
}
|
||||
});
|
||||
|
|
@ -110,6 +115,14 @@ async function requestRender() {
|
|||
key: props.sitekey,
|
||||
},
|
||||
});
|
||||
} else if (variable.value === 'friendlyChallenge' && captchaEl.value instanceof Element) {
|
||||
new captcha.value.WidgetInstance(captchaEl.value, {
|
||||
sitekey: props.sitekey,
|
||||
doneCallback: callback,
|
||||
errorCallback: callback,
|
||||
});
|
||||
// The following line is needed so that the design gets applied without it the captcha will look broken
|
||||
captchaEl.value.className = 'frc-captcha';
|
||||
} else {
|
||||
window.setTimeout(requestRender, 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue