sirius-press/tests/run.sh

69 lines
2 KiB
Bash
Raw Normal View History

feat(sirius-press): a WordPress where the account is a key, not a mailbox WordPress makes two assumptions this project cannot accept: that identity comes from an email address, and that a site lives at one server. Both are things somebody else can take away — a mailbox is rented from a provider who can close it or be compelled to open it, and a server is one seizure from being gone. Sirius Press replaces the first and hedges the second. Signing in means signing a challenge with the key that controls a CashAddress. The address is recovered from the signature, so nothing is typed but the signature itself, and the result is an ordinary WordPress session cookie — roles, capabilities, nonces and the REST API never learn the login was different. Three ways to produce one: a wallet the browser already exposes, a phrase used once in the page and wiped, or a signature pasted in from any BIP-137 wallet, which needs no JavaScript and lets the key stay on a machine that never touches the web. There is no password reset, and the recovery page says so plainly rather than offering a form that cannot work. A reset mechanism is by construction a way to take an account from its owner, and it is always easier to attack than the cryptography it bypasses. Publishing a post also exports it as static HTML to the name's storage on Sia, signed by the key that owns the name, so the site keeps answering when the server does not. Email as a feature is untouched. wp_mail() still works, SMTP still sends, and contact forms still deliver to addresses real people typed. Only mail to the site's own unroutable placeholder addresses is diverted to an in-app inbox. The objection was to email as identity, not to email. Core is pinned and patched rather than vendored. WordPress 7.1.1 is 149 MB and 5,008 files; the fork's entire core diff is 75 lines in wp-admin/install.php. Carrying the former to express the latter would bury the patch where nobody reviews it and make every clone of the monorepo pay for it. Upstream releases still merge through tools/update-wordpress.sh, which reapplies the series and says exactly which hunk needs a human. The cryptography is implemented twice — PHP on the server, JavaScript in the page — because the server must verify and the browser must sign. Both are pinned against libauth, the library the Sirius portal wallet and the BNS gateway already use, so a disagreement of one byte fails the test suite rather than presenting as a rejected login at three in the morning. 132 checks, no framework, about a second.
2026-09-21 01:39:38 +02:00
#!/usr/bin/env bash
# Run the Sirius Press test suite.
#
# tests/run.sh
#
# Needs PHP 7.4+ with GMP or BCMath, and Node 18+ for the interop suite. Both
# are optional in the sense that the script says which one is missing and runs
# the rest — but the interop suite is the one that proves a signature made in
# a browser verifies on the server, so a run without it has not checked the
# thing most worth checking.
set -uo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PHP_BIN="${PHP:-php}"
NODE_BIN="${NODE:-node}"
status=0
bar() { printf '\n\033[1m%s\033[0m\n' "$*"; }
if command -v "$PHP_BIN" >/dev/null 2>&1; then
for suite in test-crypto test-identity test-export; do
bar "php ${suite}"
"$PHP_BIN" "$here/$suite.php" || status=1
done
else
printf '\033[33mskipped:\033[0m no PHP on PATH (set PHP=/path/to/php)\n' >&2
status=1
fi
if command -v "$NODE_BIN" >/dev/null 2>&1; then
bar "node interop (browser wallet vs PHP)"
"$NODE_BIN" "$here/interop.mjs" || status=1
else
printf '\033[33mskipped:\033[0m no Node on PATH — the browser wallet was not checked against PHP\n' >&2
status=1
fi
bar "syntax"
syntax_ok=1
if command -v "$PHP_BIN" >/dev/null 2>&1; then
while IFS= read -r file; do
if ! "$PHP_BIN" -l "$file" >/dev/null 2>&1; then
echo " FAIL $file"
"$PHP_BIN" -l "$file" 2>&1 | head -3
syntax_ok=0
status=1
fi
done < <(find "$here/.." -name '*.php' -not -path '*/dist/*' -not -path '*/node_modules/*')
fi
if command -v "$NODE_BIN" >/dev/null 2>&1; then
while IFS= read -r file; do
if ! "$NODE_BIN" --check "$file" >/dev/null 2>&1; then
echo " FAIL $file"
syntax_ok=0
status=1
fi
done < <(find "$here/.." -name '*.js' -not -path '*/dist/*' -not -path '*/node_modules/*')
fi
[ "$syntax_ok" -eq 1 ] && echo " ok every PHP and JS file parses"
echo
if [ "$status" -eq 0 ]; then
printf '\033[32mAll suites passed.\033[0m\n\n'
else
printf '\033[31mSomething failed or was skipped.\033[0m\n\n'
fi
exit "$status"