UNPKG

@trustcomponent/trustcaptcha-frontend

Version:

TrustCaptcha – Privacy-first CAPTCHA solution. GDPR-compliant, bot protection made in Europe.

28 lines (27 loc) 1.11 kB
export class ApiService { static async verifyUser(config, body, signal) { const url = `${config.trustcaptchaApi}/verifications?siteKey=${config.sitekey}`; return await this.post(url, body, signal); } static async sendSolutions(config, verificationId, startSolvingTimestamp, solvedTimestamp, tasks, honeypotField, userEvents, signal) { const url = `${config.trustcaptchaApi}/verifications/${verificationId}/challenges`; const body = { startSolvingTimestamp, solvedTimestamp, tasks, honeypotField, userEvents }; return await this.post(url, body, signal); } static async post(url = '', body = {}, signal) { return await fetch(url, { method: 'POST', mode: 'cors', cache: 'no-cache', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, redirect: 'follow', referrerPolicy: 'no-referrer', body: JSON.stringify(body), signal, }); } } //# sourceMappingURL=api-service.js.map