Skip to content

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ovx committed Oct 19, 2024
1 parent 746fb2b commit fd1695c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 13 deletions.
6 changes: 3 additions & 3 deletions dist/altcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ function Zn(n, e, t) {
ln(() => {
Et(), v && (v.removeEventListener("submit", Fe), v.removeEventListener("reset", De), v.removeEventListener("focusin", Xe), v = null), B && (clearTimeout(B), B = null), document.removeEventListener("click", He), document.removeEventListener("scroll", Ye), window.removeEventListener("resize", Pe);
}), on(() => {
k("mounted", "1.0.5"), k("workers", le), Nt(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), S && ke(S), f !== void 0 && k("auto", f), N !== void 0 && We(N), v = E.closest("form"), v && (v.addEventListener("submit", Fe, { capture: !0 }), v.addEventListener("reset", De), f === "onfocus" && v.addEventListener("focusin", Xe)), f === "onload" && (x ? ge() : ne()), i && (G || A) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => {
k("mounted", "1.0.6"), k("workers", le), Nt(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), S && ke(S), f !== void 0 && k("auto", f), N !== void 0 && We(N), v = E.closest("form"), v && (v.addEventListener("submit", Fe, { capture: !0 }), v.addEventListener("reset", De), f === "onfocus" && v.addEventListener("focusin", Xe)), f === "onload" && (x ? ge() : ne()), i && (G || A) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => {
de("load");
});
});
Expand Down Expand Up @@ -1391,8 +1391,8 @@ function Zn(n, e, t) {
} else
throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
}).then(() => {
cn().then(() => {
t(7, R = m.VERIFIED), k("verified"), de("verified", { payload: oe });
t(7, R = m.VERIFIED), k("verified"), cn().then(() => {
de("verified", { payload: oe });
});
}).catch((r) => {
k(r), t(7, R = m.ERROR), t(5, he = r.message);
Expand Down
4 changes: 2 additions & 2 deletions dist/altcha.umd.cjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist_external/altcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ function An(n, e, t) {
Kt(() => {
kt(), _ && (_.removeEventListener("submit", He), _.removeEventListener("reset", Oe), _.removeEventListener("focusin", $e), _ = null), W && (clearTimeout(W), W = null), document.removeEventListener("click", Ve), document.removeEventListener("scroll", je), window.removeEventListener("resize", Be);
}), zt(() => {
k("mounted", "1.0.4"), k("workers", le), It(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), D && ke(D), u !== void 0 && k("auto", u), R !== void 0 && qe(R), _ = x.closest("form"), _ && (_.addEventListener("submit", He, { capture: !0 }), _.addEventListener("reset", Oe), u === "onfocus" && _.addEventListener("focusin", $e)), u === "onload" && (v ? ge() : ne()), i && (N || T) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => {
k("mounted", "1.0.6"), k("workers", le), It(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), D && ke(D), u !== void 0 && k("auto", u), R !== void 0 && qe(R), _ = x.closest("form"), _ && (_.addEventListener("submit", He, { capture: !0 }), _.addEventListener("reset", Oe), u === "onfocus" && _.addEventListener("focusin", $e)), u === "onload" && (v ? ge() : ne()), i && (N || T) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => {
he("load");
});
});
Expand Down Expand Up @@ -1343,8 +1343,8 @@ function An(n, e, t) {
} else
throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
}).then(() => {
en().then(() => {
t(7, C = m.VERIFIED), k("verified"), he("verified", { payload: oe });
t(7, C = m.VERIFIED), k("verified"), en().then(() => {
he("verified", { payload: oe });
});
}).catch((r) => {
k(r), t(7, C = m.ERROR), t(5, de = r.message);
Expand Down
4 changes: 2 additions & 2 deletions dist_external/altcha.umd.cjs

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions e2e/altcha.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,23 @@ test('should set options via configure()', async ({ page }) => {
expect(await page.locator('#test-configure .altcha-logo').first().count()).toBe(0);
});

test('should trigger verification and emit verified event', async ({ page }) => {
await page.goto('./e2e/index.html');
const cmp = page.locator('#test-verification-altcha').first();
const ok = await cmp.evaluate(cmpElement => {
return new Promise((resolve) => {
cmpElement.addEventListener('verified', () => {
const form = cmpElement.closest('form');
const formData = new FormData(form!);
const solution = formData.get('alctha-verification');
resolve(!!solution);
});
// @ts-expect-error typings
cmpElement.verify();
setTimeout(() => resolve(false), 5000);
})
});
expect(ok).toBe(true);
});


17 changes: 17 additions & 0 deletions e2e/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@
</script>
</div>

<div id="test-verification">
<form method="post">
<altcha-widget
id="test-verification-altcha"
name="alctha-verification"
></altcha-widget>
</form>

<script>
window.addEventListener('load', () => {
document.querySelector('#test-verification-altcha').configure({
test: 10,
});
});
</script>
</div>

</main>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "altcha",
"description": "GDPR compliant, self-hosted CAPTCHA alternative.",
"version": "1.0.5",
"version": "1.0.6",
"license": "MIT",
"author": {
"name": "Daniel Regeci",
Expand Down
4 changes: 2 additions & 2 deletions src/Altcha.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,9 @@
}
})
.then(() => {
state = State.VERIFIED;
log('verified');
tick().then(() => {
state = State.VERIFIED;
log('verified');
dispatch('verified', { payload });
});
})
Expand Down

0 comments on commit fd1695c

Please sign in to comment.