add custom fetch and docs improvements

This commit is contained in:
Tiago
2025-04-22 13:42:58 +01:00
parent 4dd0ef3a13
commit 1ccad71f43
8 changed files with 120 additions and 6 deletions
+80
View File
@@ -0,0 +1,80 @@
# Benchmark
Coming soon!
<!--
Press the button below to run a simple benchmark.
<style>
.benchmark-form {
display: flex;
flex-direction: column;
gap: 1rem;
max-width: 300px;
padding: 16px;
border-radius: 12px;
border: 1px solid var(--vp-c-divider);
}
.benchmark-field {
display: flex;
flex-direction: column;
}
.benchmark-field label {
margin: 0;
font-size: 0.9rem;
margin-bottom: 0.2rem;
opacity: .9;
}
.benchmark-field input {
padding: 0.5rem .8rem;
border-radius: 6px;
background-color: var(--vp-sidebar-bg-color);
border: 1px solid var(--vp-c-divider);
font-size: 16px;
font-family: inherit;
}
.benchmark-field input:focus {
border-color: var(--vp-c-brand-1);
outline: none;
}
.benchmark-form button {
background-color: var(--vp-c-brand-1);
font-size: 14px;
font-weight: 500;
color: white;
padding: 0.5rem 1rem;
border-radius: 6px;
transition: background-color 0.2s ease;
}
.benchmark-form button:hover {
background-color: var(--vp-c-brand-2);
}
</style>
<div class="benchmark-form">
<div class="benchmark-field">
<label for="difficulty">Challenge difficulty</label>
<input type="number" id="difficulty" name="difficulty" min="1" max="10" value="4">
</div>
<div class="benchmark-field">
<label for="challenges">Number of challenges</label>
<input type="number" id="challenges" name="challenges" min="1" max="100" value="5">
</div>
<div class="benchmark-field">
<label for="workers">Number of workers</label>
<input type="number" id="workers" name="workers" min="1" max="28" value="8">
</div>
<button>Run</button>
</div>
<script>
window.window.CAP_CUSTOM_FETCH = function (a, b) {
console.log({ a, b});
return fetch(a, b);
}
console.log("hi");
</script>
-->
+15
View File
@@ -0,0 +1,15 @@
# Philosophy
Most CAPTCHA systems today are built around surveillance — tracking users, fingerprinting browsers, and collecting data in exchange for access. Cap rejects that model.
Cap is designed around a few core ideas:
- **Privacy by default** — no trackers, no third-party requests, no hidden profiling.
- **Simplicity over complexity** — no image labeling, no click-the-fire-hydrant puzzles.
- **Speed matters** — fast to render, fast to solve, fast to validate.
- **User-first** — designed to be unintrusive and accessible, with invisible and floating modes.
- **Self-hostable, not centralized** — you control the infra, tokens, and behavior.
By using proof-of-work instead of user behavior analysis, Cap shifts the burden from identity to computation. That means anyone can prove theyre human — no cookies, no accounts, no friction.
Cap is what a CAPTCHA shouldve been all along: **simple, honest, and yours.**
+10
View File
@@ -59,3 +59,13 @@ The following custom events are supported:
- `error`: Triggered when an error occurs.
- `reset`: Triggered when the widget is reset.
- `progress`: Triggered when the there's a progress update while in verification.
## Custom fetch
You can override the default fetch implementation by setting `window.CAP_CUSTOM_FETCH` to a custom function. This function will receive the URL and options as arguments and should return a promise that resolves to the response.
```js
window.CAP_CUSTOM_FETCH = function (url, options) {
// Custom fetch implementation
return fetch(url, options);
};
```