Getting Started

Aloscaptcha is a drop-in bot challenge for any website. Grab your keys, add one script tag and one element, and verify on your server. No SDK required.

How It Works

Aloscaptcha protects a form in three moves:

  • The widget renders an “I’m not a robot” challenge on your page using your public site key.
  • When the user solves it, the widget drops a token into a hidden input in your form.
  • Your server sends that token plus your secret key to the verify endpoint and only proceeds if it comes back success: true.

The token is meaningless until your server confirms it. Never trust the front end alone. Always call siteverify before granting access.

Get Your Keys

Open your dashboard’s API page and find the Aloscaptcha Keys card. You get two:

  • aloscap_pub_…: the site key. Public; goes in your HTML.
  • aloscap_sec_…: the secret key. Keep it on your server only.

Never put your secret key in front-end code. If it leaks, regenerate it from the API page. The old one stops working immediately.

Add the Widget

No file to host and nothing to configure. Paste this widget code once on your page exactly as-is (it already points at alos.gg). It registers the <aloscaptcha-widget> element, which pulls the encrypted challenge itself.

1

Paste the widget code

html
<script>
(function () {
  var ALOSCAPTCHA_API = "https://alos.gg";
  var enginePromise = null;

  function loadEngine() {
    if (enginePromise) return enginePromise;
    enginePromise = fetch(ALOSCAPTCHA_API + "/aloscaptcha-engine.js")
      .then(function (r) { return r.text(); })
      .then(function (js) {
        var factory = new Function("self", js + "\nreturn self.__aloscapChallenge;");
        var challenge = factory({});
        if (!challenge || typeof challenge.run !== "function") throw new Error("invalid engine");
        return challenge;
      });
    enginePromise.catch(function () { enginePromise = null; });
    return enginePromise;
  }

  function fetchChallenge(sitekey) {
    return fetch(ALOSCAPTCHA_API + "/api/aloscaptcha/challenge", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ sitekey: sitekey })
    }).then(function (r) { return r.json(); });
  }

  class AloscaptchaWidget extends HTMLElement {
    connectedCallback() {
      if (this._started) return;
      this._started = true;
      this._sitekey = this.getAttribute("data-sitekey") || this.getAttribute("sitekey") || "";
      this._root = this.attachShadow({ mode: "closed" });
      if (!this._sitekey) { this._root.textContent = "aloscaptcha: missing data-sitekey"; return; }
      this._start();
    }
    disconnectedCallback() {
      this._destroyed = true;
      if (this._timer) { clearTimeout(this._timer); this._timer = null; }
    }
    _scheduleRetry() {
      var self = this;
      if (self._destroyed) return;
      self._retry = (self._retry || 0) + 1;
      var delay = Math.min(1500 * Math.pow(2, Math.min(self._retry - 1, 4)), 30000);
      self._root.textContent = "captcha loading…";
      if (self._timer) clearTimeout(self._timer);
      self._timer = setTimeout(function () { self._start(); }, delay);
    }
    _start() {
      var self = this;
      if (self._destroyed) return;
      Promise.all([loadEngine(), fetchChallenge(this._sitekey)]).then(function (vals) {
        var challenge = vals[0], data = vals[1];
        if (!data || data.status !== 200 || !data.ticket || !data.sealed) throw new Error("challenge unavailable");
        self._retry = 0;
        self._handle = challenge.run({
          host: self._root,
          el: self,
          sitekey: self._sitekey,
          origin: ALOSCAPTCHA_API,
          cid: data.cid,
          sealed: data.sealed,
          ks: data.ks,
          ticket: data.ticket,
          serverTime: data.serverTime,
          totpStepMs: data.totpStepMs,
          epochSeed: data.epochSeed,
          stageHashes: data.stageHashes,
          debug: data.debug,
          canvasRender: data.canvasRender,
          wasm: data.wasm,
          wasmEngine: data.wasmEngine,
          worker: data.worker,
          onFail: function () { self._onFail(); }
        });
      }).catch(function () { self._scheduleRetry(); });
    }
    _onFail() {
      if (this._handle && this._handle.destroy) { try { this._handle.destroy(); } catch (e) {} }
      this._handle = null;
      this._start();
    }
    reset() {
      if (this._timer) { clearTimeout(this._timer); this._timer = null; }
      if (this._handle && this._handle.destroy) { try { this._handle.destroy(); } catch (e) {} }
      this._handle = null;
      this._retry = 0;
      var name = this.getAttribute("data-input-name") || "aloscaptcha-token";
      var form = this.closest("form");
      if (form) {
        var input = form.querySelector('input[name="' + name + '"]');
        if (input) { input.value = ""; }
      }
      this.dispatchEvent(new CustomEvent("aloscaptcha-reset", { bubbles: true, composed: true }));
      if (!this._destroyed) { this._start(); }
    }
  }

  if (!customElements.get("aloscaptcha-widget")) {
    customElements.define("aloscaptcha-widget", AloscaptchaWidget);
  }
})();
</script>
2

Add the element to your form

html
<form action="/login" method="POST">
    <input name="username">
    <input name="password" type="password">

    <aloscaptcha-widget data-sitekey="aloscap_pub_XXXXXXXX"></aloscaptcha-widget>

    <button>Sign In</button>
</form>

On success the widget adds a hidden input named aloscaptcha-token to the surrounding form, and it is submitted automatically with the rest of your fields.

That’s the entire front end. See Integration for callbacks, custom field names, and resetting the widget after a failed submit.

Verify on Your Server

When the form arrives, send the token and your secret key to the verify endpoint from your backend. Here in Python (standard library only):

python
import json, urllib.request

payload = json.dumps({"secret": SECRET, "token": token}).encode()
req = urllib.request.Request(
    "https://alos.gg/api/aloscaptcha/siteverify",
    data=payload, headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req) as r:
    ok = json.load(r).get("success", False)

A valid solve returns:

json
{ "success": true }

Only continue with login/registration when success is true. Full reference and error codes are in Server Verify.

Data & retention. Each solve is scored server-side from the visitor’s interaction (pointer path, timing, and device signals). The last 50 passed solves for your site key, including this telemetry, are retained transiently and shown to you in your dashboard.