feat: remove recaptcha

(unused)
This commit is contained in:
Xmader 2020-11-12 02:55:42 -05:00
parent d79651a751
commit df6bfaf22c
No known key found for this signature in database
GPG key ID: A20B97FB9EB730E4
2 changed files with 0 additions and 53 deletions

View file

@ -6,15 +6,10 @@ import { downloadMscz } from './mscz'
import { getFileUrl } from './file'
import { WebMscore, loadSoundFont } from './mscore'
import { getDownloadBtn, BtnList, BtnAction, BtnListMode } from './btn'
import * as recaptcha from './recaptcha'
import scoreinfo from './scoreinfo'
import i18n from './i18n'
const main = (): void => {
// init recaptcha
// eslint-disable-next-line @typescript-eslint/no-floating-promises
recaptcha.init()
const btnList = new BtnList(getDownloadBtn)
const filename = scoreinfo.fileName

View file

@ -1,48 +0,0 @@
/**
* the site key for Google reCAPTCHA v3
*/
const SITE_KEY = '6Ldxtt8UAAAAALvcRqWTlVOVIB7MmEWwN-zw_9fM'
type token = string;
interface GRecaptcha {
ready (cb: () => any): void;
execute (siteKey: string, opts: { action: string }): Promise<token>;
}
let gr: GRecaptcha | Promise<GRecaptcha>
/**
* load reCAPTCHA
*/
const load = (): Promise<GRecaptcha> => {
// load script
const script = document.createElement('script')
script.src = `https://www.recaptcha.net/recaptcha/api.js?render=${SITE_KEY}`
script.async = true
document.body.appendChild(script)
// add css
const style = document.createElement('style')
style.innerHTML = '.grecaptcha-badge { display: none !important; }'
document.head.appendChild(style)
return new Promise((resolve) => {
script.onload = (): void => {
const grecaptcha: GRecaptcha = window['grecaptcha']
grecaptcha.ready(() => resolve(grecaptcha))
}
})
}
export const init = (): GRecaptcha | Promise<GRecaptcha> => {
if (!gr) {
gr = load()
}
return gr
}
export const execute = async (): Promise<token> => {
const captcha = await init()
return captcha.execute(SITE_KEY, { action: 'downloadmscz' })
}