Skip to content

Commit

Permalink
add fingerprint botd as well
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs committed Dec 16, 2024
1 parent 1a9a838 commit b42e329
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 117 deletions.
1 change: 1 addition & 0 deletions frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@dfinity/candid": "^2.1.1",
"@dfinity/identity": "^2.1.1",
"@dfinity/principal": "^2.1.1",
"@fingerprintjs/botd": "^1.9.1",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@memefighter/maker-core": "^0.0.17",
"@metamask/sdk": "^0.28.4",
Expand Down
8 changes: 7 additions & 1 deletion frontend/app/src/components/SecureButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { onMount } from "svelte";
import type { ButtonProps } from "./Button.svelte";
import Button from "./Button.svelte";
import { suspectedAutomationBot } from "../stores/automation";
let { children, onClick, ...rest }: ButtonProps & { onClick: (ev: MouseEvent) => void } =
$props();
Expand All @@ -24,7 +25,12 @@
function probablyBot(ev: MouseEvent): boolean {
const pause = Date.now() - lastMoved;
return pause < PAUSE_TRESHOLD || document.activeElement !== ev.target || !ev.isTrusted;
return (
pause < PAUSE_TRESHOLD ||
document.activeElement !== ev.target ||
!ev.isTrusted ||
$suspectedAutomationBot
);
}
function internalOnclick(ev: MouseEvent) {
Expand Down
7 changes: 7 additions & 0 deletions frontend/app/src/components/landingpages/Launch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
import { routeForScope } from "../../routes";
import SecureButton from "../SecureButton.svelte";
const client = getContext<OpenChat>("client");
Expand All @@ -13,8 +14,14 @@
$: url = $identityState.kind === "logged_in" ? rootPath : "/communities";
$: busy = $identityState.kind === "logging_in" || $identityState.kind === "loading_user";
function onClick(_: MouseEvent) {
console.log("You are a real user!");
}
</script>

<SecureButton cls="launch-button" {onClick}>Testing testing 123</SecureButton>

{#if login}
<div
class:loading={busy}
Expand Down
9 changes: 9 additions & 0 deletions frontend/app/src/stores/automation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { load as botCheck } from "@fingerprintjs/botd";
import { writable } from "svelte/store";

export const suspectedAutomationBot = writable<boolean>(false);

botCheck()
.then((botd) => botd.detect())
.then((result) => suspectedAutomationBot.set(result.bot))
.catch((err) => console.error(`Error during bot detection: `, err));
130 changes: 14 additions & 116 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b42e329

Please sign in to comment.