Update to Anubis v1.28.2 (#1)

This upgrades the Masyunis fork from Anubis v1.25.0 to the latest stable release, **v1.28.2** (“Wuk Lamat Echo 2”), while keeping the fork’s custom styling and removals.

## Approach

The Gitea repo is a tree snapshot of v1.25.0, not a git-level fork of [TecharoHQ/anubis](https://github.com/TecharoHQ/anubis). The histories share no commits, so a merge or rebase onto the upstream tag is not usable.

The first commit on this branch replaces the tree with a snapshot of the **v1.28.2** tag (`git rm -r` plus `git checkout v1.28.2 -- .`; the import tree is identical to the tag). A short patch series on top restores the Masyunis customizations.

## Customizations kept

- Masyunya mascots (`web/static/img/{happy,pensive,reject}.webp`), hashes match current `master`.
- `web/static/img/ATTRIBUTIONS.txt` stays deleted.
- Challenge footer: drop the `made_with` (Canada / maple-leaf) line and the CELPHASE mascot credit; keep “Protected by Anubis from Techaro”. The generated `web/index_templ.go` matches `go generate ./web`.
- Short README (the old `anubisc` typo is fixed).
- Version stamped `v1.28.2/masyunis` via Makefile ldflags. `anubis.go` `init()` does not overwrite a link-time version; `go run` / `go test` still report `devel` on purpose.
- Upstream `.github`, `.devcontainer`, `.husky`, and `.vscode` stay deleted.
- `"uk"` is removed from `lib/localization/locales/manifest.json` **on purpose**, because of Alpine locale problems. `uk.json` and its test entry stay; the served manifest lists 27 languages.
- `package.json` `prepare` no longer runs `husky` (the hooks directory is gone). The rest of the script is unchanged. `husky` remains in devDependencies, as upstream left it.

## Deploy notes

- **Cookie rename (v1.27):** with the default `DYNAMIC_COOKIE_SUFFIX=true`, cookie names become e.g. `techaro.lol-anubis-auth-<hash>`. Existing clients get a **one-time re-challenge**. That is expected, not a loop.
- **Docker / ko / yeet builds** skip the Makefile ldflags, so the displayed version is `<git-version>/masyunis`. It is `v1.28.2/masyunis` only when built from a `v1.28.2` tag (or via `make build` / `make prebaked-build`).
- Go 1.27.3 is required (upstream bump in v1.28.2). Thoth (`THOTH_URL` / `THOTH_TOKEN`) was removed upstream; those settings now warn and do nothing. New WASM challenge methods stay disabled unless opted in.

## Verification

- `make build` succeeds. `./var/anubis --version` prints `Anubis v1.28.2/masyunis`.
- `SKIP_INTEGRATION=1 go test ./...` passes (unit tests; integration package is skipped).
- Local challenge/reject pages (en and ru) show Masyunya, version `v1.28.2/masyunis`, and no Canada / CELPHASE / mascot-credit text. Screenshots:

![Challenge page (en)](https://git.unvr.site/attachments/36112ff0-5155-495c-8bd2-59606ee3bd64)
![Reject page (en)](https://git.unvr.site/attachments/2cad0256-1b0e-4f71-8d06-d1a447fd5263)

- Upstream Playwright tests (`make test` without `SKIP_INTEGRATION`) fail on this box because the browser download fails. A clean v1.28.2 tree fails the same three Playwright tests here, so this is not a fork regression.
- `npm audit` reports **4** findings in upstream’s lockfile (2 moderate, 2 high: `brace-expansion`, `fast-uri`, `lodash.trim`, `source-map-js`). Left alone.

Please review and merge when ready. I will not merge this myself.

Reviewed-on: #1
Co-authored-by: Lead <3+lead_bot@noreply.git.unvr.site>
This commit was merged in pull request #1.
This commit is contained in:
sol_bot Bot authored and matiashik committed 2026-11-28 12:10:27 +00:00
1 parent eb3e46d8d0
commit caf4d72880
529 files changed
+33015 -6659

No files matched your search

+62 -71
View File
@@ -1,81 +1,64 @@
import { waitForExtensions } from "@lib/extensions";
import algorithms from "./algorithms";
import { fetchWithBackoff } from "./lib/backoff";
import { g, u, j } from "@lib/xeact.mjs";
// from Xeact
const u = (url: string = "", params: Record<string, any> = {}) => {
let result = new URL(url, window.location.href);
Object.entries(params).forEach(([k, v]) => result.searchParams.set(k, v));
return result.toString();
};
// Tell the inline bootstrap in the challenge page that this script made it off
// the wire and started running.
const j = (id: string): any | null => {
const elem = document.getElementById(id);
if (elem === null) {
return null;
declare global {
interface Window {
__anubisBooted?: boolean;
}
}
return JSON.parse(elem.textContent);
};
const alreadyBooted = window.__anubisBooted === true;
window.__anubisBooted = true;
const imageURL = (mood, cacheBuster, basePrefix) =>
const imageURL = (
mood: string,
cacheBuster: string,
basePrefix: string,
): string =>
u(`${basePrefix}/.within.website/x/cmd/anubis/static/img/${mood}.webp`, {
cacheBuster,
});
// Detect available languages by loading the manifest
const getAvailableLanguages = async () => {
const basePrefix = j("anubis_base_prefix");
if (basePrefix === null) {
return;
}
try {
const response = await fetch(
`${basePrefix}/.within.website/x/cmd/anubis/static/locales/manifest.json`,
);
if (response.ok) {
const manifest = await response.json();
return manifest.supportedLanguages || ["en"];
}
} catch (error) {
console.warn(
"Failed to load language manifest, falling back to default languages",
);
}
// Fallback to default languages if manifest loading fails
return ["en"];
};
// Use the browser language from the HTML lang attribute which is set by the server settings or request headers
const getBrowserLanguage = async () => document.documentElement.lang;
// Load translations from JSON files
const loadTranslations = async (lang) => {
//
// This runs before anything else on the challenge page, so it must never throw:
// an unhandled rejection here leaves the user staring at "Loading..." forever.
// An untranslated challenge page still passes challenges, so the last resort is
// an empty table, which makes t() fall through to the raw key.
const loadTranslations = async (
lang: string,
): Promise<Record<string, string>> => {
const basePrefix = j("anubis_base_prefix");
if (basePrefix === null) {
return;
return {};
}
try {
const response = await fetch(
const response = await fetchWithBackoff(
`${basePrefix}/.within.website/x/cmd/anubis/static/locales/${lang}.json`,
);
return await response.json();
return (await response.json()) as Record<string, string>;
} catch (error) {
console.warn(
`Failed to load translations for ${lang}, falling back to English`,
);
console.warn(`Failed to load translations for ${lang}`, error);
if (lang !== "en") {
return await loadTranslations("en");
}
throw error;
return {};
}
};
const getRedirectUrl = () => {
const getRedirectUrl = (): string | null => {
const publicUrl = j("anubis_public_url");
if (publicUrl === null) {
return;
return "/";
}
if (publicUrl && window.location.href.startsWith(publicUrl)) {
const urlParams = new URLSearchParams(window.location.search);
@@ -84,7 +67,7 @@ const getRedirectUrl = () => {
return window.location.href;
};
let translations = {};
let translations: Record<string, string> = {};
let currentLang;
// Initialize translations
@@ -93,9 +76,23 @@ const initTranslations = async () => {
translations = await loadTranslations(currentLang);
};
const t = (key) => translations[`js_${key}`] || translations[key] || key;
const t = (key: string): string =>
translations[`js_${key}`] ||
translations[key] ||
`unknown translatable string: ${key}`;
interface OhNoesParams {
titleMsg: string;
statusMsg: string;
imageSrc: string;
}
(async () => {
if (alreadyBooted) {
console.debug("anubis: main.mjs already running, ignoring duplicate load");
return;
}
// Initialize translations first
await initTranslations();
@@ -112,18 +109,10 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
},
];
const status: HTMLParagraphElement = document.getElementById(
"status",
) as HTMLParagraphElement;
const image: HTMLImageElement = document.getElementById(
"image",
) as HTMLImageElement;
const title: HTMLHeadingElement = document.getElementById(
"title",
) as HTMLHeadingElement;
const progress: HTMLDivElement = document.getElementById(
"progress",
) as HTMLDivElement;
const status: HTMLParagraphElement = g("status") as HTMLParagraphElement;
const image: HTMLImageElement = g("image") as HTMLImageElement;
const title: HTMLHeadingElement = g("title") as HTMLHeadingElement;
const progress: HTMLDivElement = g("progress") as HTMLDivElement;
const anubisVersion = j("anubis_version");
const basePrefix = j("anubis_base_prefix");
@@ -138,7 +127,7 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
});
}
const ohNoes = ({ titleMsg, statusMsg, imageSrc }) => {
const ohNoes = ({ titleMsg, statusMsg, imageSrc }: OhNoesParams) => {
title.innerHTML = titleMsg;
status.innerHTML = statusMsg;
image.src = imageSrc;
@@ -186,11 +175,11 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
try {
const t0 = Date.now();
const { hash, nonce } = await process(
{ basePrefix, version: anubisVersion },
{ basePrefix, version: anubisVersion, algorithm: rules.algorithm },
challenge.randomData,
rules.difficulty,
null,
(iters) => {
(iters: number) => {
const delta = Date.now() - t0;
// only update the speed every second so it's less visually distracting
if (delta - lastSpeedUpdate > 1000) {
@@ -205,7 +194,7 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
const probability = Math.pow(1 - likelihood, iters);
const distance = (1 - Math.pow(probability, 2)) * 100;
progress["aria-valuenow"] = distance;
progress.ariaValueNow = `${distance}`;
if (progress.firstElementChild !== null) {
(progress.firstElementChild as HTMLElement).style.width =
`${distance}%`;
@@ -223,6 +212,8 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
const t1 = Date.now();
console.log({ hash, nonce });
await waitForExtensions();
if (userReadDetails) {
const container: HTMLDivElement = document.getElementById(
"progress",
@@ -245,14 +236,14 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
container.innerHTML = t("finished_reading");
function onDetailsExpand() {
const redir = getRedirectUrl();
const redir = getRedirectUrl() ?? "/";
window.location.replace(
u(`${basePrefix}/.within.website/x/cmd/anubis/api/pass-challenge`, {
id: challenge.id,
response: hash,
nonce,
redir,
elapsedTime: t1 - t0,
elapsedTime: `${t1 - t0}`,
}),
);
}
@@ -260,18 +251,18 @@ const t = (key) => translations[`js_${key}`] || translations[key] || key;
container.onclick = onDetailsExpand;
setTimeout(onDetailsExpand, 30000);
} else {
const redir = getRedirectUrl();
const redir = getRedirectUrl() ?? "/";
window.location.replace(
u(`${basePrefix}/.within.website/x/cmd/anubis/api/pass-challenge`, {
id: challenge.id,
response: hash,
nonce,
redir,
elapsedTime: t1 - t0,
elapsedTime: `${t1 - t0}`,
}),
);
}
} catch (err) {
} catch (err: any) {
ohNoes({
titleMsg: t("calculation_error"),
statusMsg: `${t("calculation_error_msg")} ${err.message}`,