Apply Werkzeug logo and add optional node settings and mini navigation

This commit is contained in:
waozi committed 2026-10-15 02:14:17 -03:00
1 parent 4286940564
commit 9396dfe752
41 files changed
+563 -52

No files matched your search

+3
View File
@@ -2,6 +2,9 @@
## [0.4.0] - 2026-10-13
- Give Werkzeug a purple modular W logo across the app, Android launcher and website.
- Reach every Werkzeug tool from the embedded mini app, including its home screen and profile.
- Choose your own Daochi node in Profile and pause optional sync without forgetting your account or local records.
- Add a Scientific mode to Calculator: sin, cos and tan in degrees or radians with their inverses and hyperbolic forms, powers and roots, ln and log, factorials, π, e, Ans and E notation.
- Fix the web version freezing when Clock opens, and count the stopwatch's tenths of a second there again.
- Show π, √, Greek, Cyrillic and other characters on phones older than Android 10, which showed them as question marks.
+7
View File
@@ -144,6 +144,13 @@ android-emulator: apps
python3 scripts/android_apk_check.py build/werk-android-emulator.apk
android-release: apps
cd droid && env WERK_ZIRAN_COMMAND="$(ZIRAN)" KRYON_DIR="$(KRYON_DIR)" ZIRAN_ROOT="$(ZIRAN_ROOT)" RAYLIB_DIR="$(RAYLIB_DIR)" LIBOQS_DIR="$(LIBOQS_DIR)" MONOCYPHER_DIR="$(MONOCYPHER_DIR)" ./gradlew assembleRelease -Pabi=$(ANDROID_ABIS) -PsplitApks=true $(GRADLE_ARGS)
.PHONY: android-fdroid
# F-Droid owns signing and updates. Keep the same package/version as the
# reference release; the suffix belongs to the unsigned output filename.
android-fdroid:
$(MAKE) android-release GRADLE_ARGS="$(GRADLE_ARGS) -PfDroidBuild=true"
cp droid/app/build/outputs/apk/release/app-universal-release-unsigned.apk build/werk-$(shell cat VERSION)-fdroid-unsigned.apk
python3 scripts/android_apk_check.py build/werk-$(shell cat VERSION)-fdroid-unsigned.apk
android-smoke:
bash scripts/android_smoke.sh
android-input-test:
+21
View File
@@ -52,6 +52,17 @@ Profile → Sync keeps Auth's accounts on all your devices through a
[Daochi](https://github.com/kryonlabs/daochi) account, `api.waozi.xyz` by
default. Sync is off until you create or connect an account.
Every tool works without Daochi. Set your own HTTPS node in Profile → Sync
before creating or connecting an account; HTTP is supported for a local node
on localhost. Both devices must use the same node to connect. With an account
connected, the sync switch pauses all sync and device linking, preserves your
keys and local records, and stays off after restarting. Forget the account on
this device to choose a different node; local records remain available.
The embedded web app (`/app/?mini`) also provides Home and Profile, so all
four tools are reachable. Use `?mini&app=auth`, `calculator` or `clock` to
open a particular tool first. Browser sync is currently unavailable.
- Each record is sealed on the device with XChaCha20-Poly1305 under a random
vault key that never leaves your devices unencrypted. The seal covers the
account, the record and the time of the change, so the server can neither
@@ -94,9 +105,19 @@ make gui-test # every tool, clipboard and profile on a private display
make site # build/site: browser app and offline worker
make web-smoke # private headless Chromium
make android-debug # ARM32, ARM64 and universal APKs
make android-fdroid # unsigned F-Droid candidate, same Android ID and version
make android-emulator # the x86_64 APK for a private emulator
```
F-Droid metadata is maintained in `packaging/fdroid`. The `android-fdroid`
target disables developer signing even when a release keystore is configured
and writes `build/werk-VERSION-fdroid-unsigned.apk`. It adds no version or
package suffix, preserving existing installations and reference-APK checks.
The unsigned candidate is for builders, not installation. Werkzeug currently
has no built-in updater: F-Droid or your chosen installer handles updates.
Android requires the same signing certificate for an in-place update; the
F-Droid recipe retains the developer-signature reproducibility requirement.
For development with the real project repositories, create an ignored
`ziran.local.toml`:
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 208 KiB

-7
View File
@@ -1,7 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
<title>Werkzeug — a wrench with a keyhole</title>
<g fill="#8254ff" fill-rule="evenodd" transform="translate(-10 10)">
<path d="M425.9 145.5A118 118 0 1 1 366.5 86.1L288.5 164.1A42 42 0 0 0 347.9 223.5Z"/>
<path d="M239.0 202.3L309.7 273.0L181.0 401.7A50 50 0 0 1 110.3 331.0ZM159.8 324.2a21 21 0 0 0 -11.2 38.7l-5.2 23.0h32.8l-5.2 -23.0a21 21 0 0 0 -11.2 -38.7Z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 20 KiB

+2 -1
View File
@@ -23,7 +23,8 @@ android {
// Sign release builds only when a keystore is actually available: CI and
// local release builds pass -Pkeystore.* properties, while clean checkouts
// (for example an F-Droid builder) produce an unsigned APK instead.
def signRelease = !project.hasProperty('fDroidBuild') \
def fdroidBuild = (project.findProperty('fDroidBuild') ?: 'false').toString().toBoolean()
def signRelease = !fdroidBuild \
&& releaseKeystore != null && releaseKeystore.exists() \
&& releasePassword != ""
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 25 KiB

@@ -1,3 +1,4 @@
- Give Werkzeug a purple modular W logo across the app, Android launcher and website.
- Reach every Werkzeug tool from the embedded mini app, including its home screen and profile.
- Choose your own Daochi node in Profile and pause optional sync without forgetting your account or local records.
- Add a Scientific mode to Calculator: sin, cos and tan in degrees or radians with their inverses and hyperbolic forms, powers and roots, ln and log, factorials, π, e, Ans and E notation.
- Fix the web version freezing when Clock opens, and count the stopwatch's tenths of a second there again.
- Show π, √, Greek, Cyrillic and other characters on phones older than Android 10, which showed them as question marks.
@@ -7,6 +7,8 @@ Werkzeug holds small private tools in one app. Everything is computed on your de
A profile with your name and picture sets the appearance every tool shares. Werkzeug was previously called Pass; updating keeps your profiles, settings and saved master password.
Every tool works without a Daochi account. In Profile → Sync you can choose your own node before connecting an account, or pause sync without forgetting your keys and local records. Sync stays off after restarting until you turn it on again.
Pass is an independent implementation of the LessPass algorithm. Compatibility does not imply endorsement by or affiliation with the LessPass project.
Source code: https://github.com/waozixyz/werk
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 208 KiB

+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""Check real F-Droid/debug artifacts without installing anything."""
from pathlib import Path
import re
import subprocess
import sys
from zipfile import ZipFile
root = Path(__file__).resolve().parents[1]
fdroid, debug, emulator = map(Path, sys.argv[1:])
identity = None
for path, expected_abis in [(fdroid, {"armeabi-v7a", "arm64-v8a"}),
(debug, {"armeabi-v7a", "arm64-v8a"}),
(emulator, {"x86_64"})]:
badging = subprocess.check_output(["aapt", "dump", "badging", str(path)], text=True)
package = re.search(r"package: name='([^']+)' versionCode='([^']+)' versionName='([^']+)'", badging)
assert package, f"{path}: no package identity"
current = package.groups()
assert current[0] == "xyz.waozi.pass", "Updating must preserve Pass's Android ID"
assert current[2] == (root / "VERSION").read_text().strip(), "Channel added a version suffix"
if identity is None:
identity = current
assert current == identity, "F-Droid and direct builds have different identities"
assert "application-label:'Werkzeug'" in badging
permissions = subprocess.check_output(["aapt", "dump", "permissions", str(path)], text=True)
assert not any(name in permissions for name in
["REQUEST_INSTALL_PACKAGES", "INSTALL_PACKAGES", "DELETE_PACKAGES"]), "App can compete with its installer"
with ZipFile(path) as archive:
abis = {name.split('/')[1] for name in archive.namelist()
if name.startswith('lib/') and name.endswith('/libmain.so')}
assert abis == expected_abis, f"{path}: wrong ABIs {abis}"
assert archive.read("assets/icon.png") == (root / "assets/app/icon.png").read_bytes(), "Stale app logo"
signature = subprocess.run(["apksigner", "verify", str(path)], capture_output=True)
assert (signature.returncode != 0) == (path == fdroid), "F-Droid must be unsigned; debug must be signed"
print("Android distribution: matching package/version, Werkzeug label/logo, correct ABIs, builder signing and no installer permissions")
+33 -1
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
"""Drive only a private emulator; never choose a connected phone implicitly."""
from pathlib import Path
import csv
import io
import os
import re
import subprocess
@@ -27,6 +29,17 @@ def shell(*arguments, check=True):
def shot(name):
(output / f"{name}.png").write_bytes(adb("exec-out", "screencap", "-p").stdout)
def tap_label(word):
shot("label")
data = subprocess.check_output(["tesseract", str(output / "label.png"), "stdout", "--psm", "11", "-c", "tessedit_create_tsv=1"],
stderr=subprocess.DEVNULL, text=True)
for item in csv.DictReader(io.StringIO(data), delimiter="\t"):
if item["text"].strip().lower() == word.lower():
tap(int(item["left"]) + int(item["width"]) // 2,
int(item["top"]) + int(item["height"]) // 2)
return
raise AssertionError(f"Could not find {word!r} in the private emulator")
def alive():
if not shell("pidof", package, check=False).strip():
details = adb("logcat", "-d", "-b", "crash").stdout.decode()
@@ -118,7 +131,26 @@ try:
tap(int(28 * zoom), top + int(28 * zoom)); time.sleep(0.5); alive()
settings = shell("run-as", package, "cat", "files/profile/settings.txt")
assert "name=Ada Lovelace\n" in settings, f"Profile name typed out of order: {settings!r}"
print("Werkzeug Android: home, Pass keyboard, masked master, profiles, generation, restart and profile name pass")
tap(width - int(60 * zoom), top + int(28 * zoom)); time.sleep(0.5)
tap(width // 2, top + int(694 * zoom))
shell("input", "keycombination", "113", "29")
type_text("https://sync.example.invalid:8443/")
shell("input", "keyevent", "4"); time.sleep(0.5)
tap_label("Save")
settings = shell("run-as", package, "cat", "files/profile/settings.txt")
assert "node=https://sync.example.invalid:8443\n" in settings, "Custom node was not saved"
assert adb("shell", "run-as", package, "test", "-f", "files/account/keys.txt", check=False).returncode != 0
shot("custom-node")
# Updating this same package preserves both the tool's files and the
# profile. No owner phone is selected by this harness.
shell("am", "force-stop", package)
adb("install", "-r", str(apk))
shell("am", "start", "-n", package + "/android.app.NativeActivity")
time.sleep(1); alive()
assert shell("run-as", package, "cat", "files/profile/settings.txt") == settings
assert shell("run-as", package, "cat", "files/apps/pass/profiles.tsv") == expected
shot("updated")
print("Werkzeug Android: input, profiles, custom node and in-place package update preserved private data")
except BaseException:
shot("failure")
raise
+4 -6
View File
@@ -1,13 +1,11 @@
#!/usr/bin/env python3
"""Render the Werkzeug mark, a wrench with a keyhole, from the canonical vector for all distribution sizes."""
"""Resize the owner-selected modular W bitmap for all distribution sizes."""
from pathlib import Path
import io
import cairosvg
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(__file__).resolve().parents[1]
SVG = ROOT / 'assets/app/icon.svg'
SOURCE = ROOT / 'assets/app/logo.png'
def render(size, background=None):
image = Image.open(io.BytesIO(cairosvg.svg2png(url=str(SVG), output_width=size, output_height=size))).convert('RGBA')
image = Image.open(SOURCE).convert('RGBA').resize((size, size), Image.Resampling.LANCZOS)
if background:
base = Image.new('RGBA', image.size, background); base.alpha_composite(image); image = base
return image
@@ -29,7 +27,7 @@ for path, size in [('assets/app/readme-banner.png',(1536,512)), ('assets/app/rea
box=d.textbbox((0,0),name,font=font); tw=box[2]; gap=icon_size*.18
if icon_size+gap+tw <= w*.86: break
icon_size-=2
mark=render(int(icon_size*1.5)); mark=mark.crop(mark.getbbox()) # the mark without the icon's padding
mark=render(icon_size)
left=int((w-mark.width-gap-tw)/2); top=int((h-mark.height)/2)
image.paste(mark,(left,top),mark)
d.text((left+mark.width+gap, (h-(box[3]-box[1]))/2-box[1]),name,font=font,fill='#291747')
+6
View File
@@ -30,6 +30,12 @@ ${CC:-cc} -std=c99 -O2 -Wno-unused-variable -I"$("$ziran" pkg path ziran)/includ
$(pkg-config --libs sdl2 cairo freetype2 fontconfig pangocairo) -l:libcurl.so.4 -lm -lpthread \
-o "$work/sync_e2e"
mkdir -p "$work/preferences"
for mode in preferences paused; do
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS -u WERK_SYNC_SERVER \
WERK_DATA="$work/preferences" "$work/sync_e2e" "$mode"
done
port=$((20000 + $$ % 20000))
server=http://127.0.0.1:$port
secret=$(od -An -tx1 -N32 /dev/urandom | tr -d ' \n')
+35 -4
View File
@@ -1,7 +1,7 @@
// Exercise the built site's Werkzeug app in a private headless browser with a
// disposable profile: the home screen, a tool opened by ?app=, Calculator
// typing, Clock, and Pass alone by ?mini as embedding pages use it.
import {spawn} from 'node:child_process';
// typing, Clock, and every tool plus navigation in embedded mini mode.
import {spawn, spawnSync} from 'node:child_process';
import {readFile, writeFile, mkdir, mkdtemp} from 'node:fs/promises';
import {createServer} from 'node:http';
import {resolve, join, extname} from 'node:path';
@@ -93,6 +93,19 @@ try {
const shot = await command('Page.captureScreenshot', {format: 'png'});
await writeFile(join(output, name + '.png'), Buffer.from(shot.data, 'base64'));
};
const expectText = async (name, expected) => {
await screenshot(name);
const result = spawnSync('tesseract', [join(output, name + '.png'), 'stdout', '--psm', '11'],
{env: environment, encoding: 'utf8', timeout: 20000});
if (result.status !== 0) throw Error('Screenshot OCR failed: ' + result.stderr);
if (!result.stdout.toLowerCase().includes(expected.toLowerCase()))
throw Error(`${name}: expected ${expected}, saw ${result.stdout}`);
};
const click = async (x, y) => {
await command('Input.dispatchMouseEvent', {type: 'mousePressed', x, y, button: 'left', clickCount: 1});
await command('Input.dispatchMouseEvent', {type: 'mouseReleased', x, y, button: 'left', clickCount: 1});
await delay(350);
};
// The canvas has drawn a frame with something besides the background.
const painted = `(() => {
const canvas = document.querySelector('canvas');
@@ -127,17 +140,35 @@ try {
};
await command('Runtime.enable');
await command('Page.enable');
await command('Emulation.setDeviceMetricsOverride', {width: 420, height: 760, deviceScaleFactor: 1, mobile: false});
await open('', 'home');
await open('?app=calculator', 'calculator');
await type('12+30*2=');
await delay(400);
await screenshot('calculator-typed');
await expectText('calculator-typed', '72');
// Clock reads the local time zone every frame; a broken time binding
// froze the page here.
await open('?app=clock', 'clock');
await open('?mini', 'pass-mini');
await expectText('pass-mini', 'Pass');
for (const [index, app] of ['pass', 'auth', 'calculator', 'clock'].entries()) {
await open('?mini&app=' + app, app + '-mini-direct');
await expectText(app + '-mini-direct', app);
await click(28, 28);
await expectText(app + '-mini-home', 'Werkzeug');
await click(142 + (index % 2) * 136, 132 + Math.floor(index / 2) * 136);
await expectText(app + '-mini-reopened', app);
}
await command('Emulation.setDeviceMetricsOverride', {width: 280, height: 480, deviceScaleFactor: 1, mobile: false});
await open('?mini&app=unknown', 'mini-narrow-home');
await expectText('mini-narrow-home', 'Werkzeug');
await click(206, 264);
await expectText('mini-narrow-clock', 'Clock');
await click(28, 28);
await click(250, 28);
await expectText('mini-narrow-profile', 'Profile');
if (exceptions.length) throw Error('Page exceptions: ' + exceptions.join(' '));
console.log('Werkzeug web: home, Calculator, Clock and Pass in mini mode drew in a private headless browser');
console.log('Werkzeug web: Calculator result, every mini tool, Home, Profile and narrow navigation verified in private Chromium');
} finally {
socket?.close();
try {
+61
View File
@@ -5,6 +5,8 @@ Uses disposable data and cache folders and fixture secrets only. Run
through scripts/werk_gui_test.sh, which starts the private display.
"""
from pathlib import Path
import csv
import io
import base64
import hashlib
import hmac
@@ -84,6 +86,24 @@ def capture(name):
command("import", "-window", window, str(output / f"{name}.png"))
def click_word(word, toggle=False):
capture("control")
text = command("tesseract", str(output / "control.png"), "stdout", "--psm", "11",
"-c", "tessedit_create_tsv=1")
for item in csv.DictReader(io.StringIO(text), delimiter="\t"):
if item["text"].strip().lower() == word.lower():
click(350 if toggle else int(item["left"]) + int(item["width"]) // 2,
int(item["top"]) + int(item["height"]) // 2)
return
raise AssertionError(f"Could not find {word!r} in the private test window")
def scroll_down():
command("xdotool", "mousemove", "--window", window, "210", "650")
command("xdotool", "click", "--window", window, "--repeat", "12", "--delay", "70", "5")
time.sleep(0.4)
def clipboard():
return command("xclip", "-selection", "clipboard", "-out")
@@ -171,6 +191,47 @@ try:
settings = (data / "profile/settings.txt").read_text()
assert "name=Fixture Person\n" in settings and "theme_mode=2\n" in settings, settings
assert (data / "profile/settings.txt").stat().st_mode & 0o077 == 0
# Optional sync needs no account. Invalid origins are rejected before
# any connection; the chosen node survives restarting the application.
click(210, 694)
key("ctrl+a")
type_text("https://example.invalid/path")
click(210, 744)
assert "node=https://api.waozi.xyz\n" in (data / "profile/settings.txt").read_text()
capture("node-invalid")
click(210, 694)
key("ctrl+a")
type_text("https://sync.example.invalid:8443/")
click(210, 744)
assert "node=https://sync.example.invalid:8443\n" in (data / "profile/settings.txt").read_text()
assert not (data / "account/keys.txt").exists(), "Choosing a node created an account"
capture("node-saved")
stop()
start()
click(390, 28)
capture("node-restarted")
assert "node=https://sync.example.invalid:8443\n" in (data / "profile/settings.txt").read_text()
assert not (data / "account/keys.txt").exists()
# OCR uses light controls; the dark appearance was checked above.
click(210, 324)
scroll_down()
click_word("Create")
account_file = data / "account/keys.txt"
assert account_file.exists() and "paused=0\n" in account_file.read_text()
click_word("Daochi", toggle=True)
assert "paused=1\n" in account_file.read_text(), "Profile's sync switch did not pause"
capture("sync-paused")
stop()
start()
assert "paused=1\n" in account_file.read_text()
click(390, 28)
capture("sync-paused-restarted")
scroll_down()
click_word("Forget")
click_word("forget")
assert not account_file.exists()
assert records.read_text() == saved, "Forgetting an account changed local Auth records"
capture("account-forgotten")
stop()
print("Werkzeug GUI test: home, Pass, Calculator, Clock, Auth and Profile ran on a private display")
finally:
Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 105 KiB

+31 -6
View File
@@ -15,6 +15,8 @@
#import "files"
#import "platform"
#import "sync_keys"
#import "profile"
#import "node_url"
ACCOUNT_SERVER :: "https://api.waozi.xyz"
// Daochi identifiers keep the full name, werkzeug, where files use werk: the
@@ -24,6 +26,7 @@ ACCOUNT_FILE_LIMIT :: 12288
Account :: struct {
ready: bool
paused: bool
server: [256]u8
keys: AccountKeys
client_id: [40]u8
@@ -48,13 +51,31 @@ DefaultServer :: () -> string {
return override
}
}
return ACCOUNT_SERVER
return ProfileNode()
}
AccountReady :: () -> bool {
return account.ready
}
AccountSyncEnabled :: () -> bool {
return account.ready && !account.paused
}
SetAccountSyncEnabled :: (enabled: bool) -> bool {
if !account.ready {
return false
}
previous := account.paused
account.paused = !enabled
if !SaveAccount() {
account.paused = previous
return false
}
account_generation += 1
return true
}
AccountId :: () -> string {
return TextUntilNul(account.keys.public_id[:])
}
@@ -131,9 +152,9 @@ SaveAccount :: () -> bool {
lines: [7]string = .["server=", AccountServer(), "\nclient=", TextUntilNul(account.client_id[:]),
"\ndevice=", HexOf(account.device_seed[:], seed_hex[:]), "\nvault="]
used := Append(text[:], 0, lines[:])
rest: [6]string = .[HexOf(account.vault[:], vault_hex[:]), "\npublic=",
rest: [8]string = .[HexOf(account.vault[:], vault_hex[:]), "\npublic=",
TextUntilNul(account.keys.public_key_hex[:]), "\nprivate=",
TextUntilNul(account.keys.private_key_hex[:]), "\n"]
TextUntilNul(account.keys.private_key_hex[:]), "\npaused=", ifx account.paused then "1\n" else "0\n"]
used = Append(text[:], used, rest[:])
saved := used > 0 && WritePrivate(path, TextView(text[0:used]))
Wipe(text[:])
@@ -159,9 +180,12 @@ AccountFromText :: (text: string, target: *Account) -> bool {
if index == text.count || text[index] == cast(u8)10 {
line := text[start:index]
value := LineValue(line, "server=")
if value != "" && CopyCString(value, target.server[:]) {
if NodeOrigin(value) != "" && CopyCString(NodeOrigin(value), target.server[:]) {
found |= 1
}
if line == "paused=1" {
target.paused = true
}
value = LineValue(line, "client=")
if value != "" && CopyCString(value, target.client_id[:]) {
found |= 2
@@ -226,7 +250,8 @@ NewClientId :: (output: []u8) {
// A new account with fresh keys, saved on this device.
CreateAccount :: () -> bool {
created: Account
if CreateAccountKeys(*created.keys) == 0 || !CopyCString(DefaultServer(), created.server[:]) {
server := NodeOrigin(DefaultServer())
if server == "" || CreateAccountKeys(*created.keys) == 0 || !CopyCString(server, created.server[:]) {
return false
}
NewClientId(created.client_id[:])
@@ -249,7 +274,7 @@ CreateAccount :: () -> bool {
// device's own key and client id.
JoinAccount :: (server: string, public_hex: string, private_hex: string, vault: []u8) -> bool {
joined: Account
if !CopyCString(server, joined.server[:]) || !CopyCString(public_hex, joined.keys.public_key_hex[:]) ||
if NodeOrigin(server) == "" || !CopyCString(NodeOrigin(server), joined.server[:]) || !CopyCString(public_hex, joined.keys.public_key_hex[:]) ||
!CopyCString(private_hex, joined.keys.private_key_hex[:]) || vault.count != 32 {
return false
}
+7 -3
View File
@@ -1,5 +1,5 @@
// The browser host. ?app=ID opens that tool at start; ?mini opens Pass on
// its own, for pages that embed it.
// The browser host. ?app=ID opens a tool at start. Embedded ?mini opens
// Pass first unless ?app selects another, with navigation to every tool.
#import "werk"
#import "browser_storage"
#import "std/text_buffer"
@@ -43,7 +43,11 @@ main :: () -> s32 {
WerkStart()
query := BrowserQuery()
if QueryValue(query, "mini") != "" {
unused WerkOpen("pass", true)
selected := QueryValue(query, "app")
if selected == "" {
selected = "pass"
}
unused WerkOpen(selected, true)
} else if QueryValue(query, "app") != "" {
unused WerkOpen(QueryValue(query, "app"), false)
}
+5 -1
View File
@@ -196,7 +196,7 @@ CloseLink :: () -> bool {
// On the connected device: shows a new code and waits for the new device.
LinkShow :: () {
if !AccountReady() {
if !AccountSyncEnabled() {
return
}
LinkReset()
@@ -369,6 +369,10 @@ LinkData :: (output: []u8) -> string {
// Advances the connection; call once per frame.
LinkFrame :: () {
if AccountReady() && !AccountSyncEnabled() {
LinkCancel()
return
}
if link_phase != LinkPhase.LinkShowing && link_phase != LinkPhase.LinkJoining {
return
}
+71
View File
@@ -0,0 +1,71 @@
// A Daochi node is an origin, without credentials or request parameters.
// Plain HTTP is restricted to loopback for a locally hosted node.
NodeOrigin :: (text: string) -> string {
end := text.count
if end > 0 && text[end - 1] == cast(u8)47 {
end -= 1
}
value := text[0:end]
start: s64 = 0
secure := false
if value.count > 8 && value[0:8] == "https://" {
start = 8
secure = true
} else if value.count > 7 && value[0:7] == "http://" {
start = 7
} else {
return ""
}
host_end := start
if value[start] == cast(u8)91 {
host_end += 1
while host_end < value.count && value[host_end] != cast(u8)93 {
ch := value[host_end]
if !(ch >= cast(u8)48 && ch <= cast(u8)57 || ch >= cast(u8)97 && ch <= cast(u8)102 ||
ch >= cast(u8)65 && ch <= cast(u8)70 || ch == cast(u8)58) {
return ""
}
host_end += 1
}
if host_end >= value.count || host_end <= start + 2 {
return ""
}
host_end += 1
} else {
while host_end < value.count && value[host_end] != cast(u8)58 {
ch := value[host_end]
if !(ch >= cast(u8)48 && ch <= cast(u8)57 || ch >= cast(u8)97 && ch <= cast(u8)122 ||
ch >= cast(u8)65 && ch <= cast(u8)90 || ch == cast(u8)45 || ch == cast(u8)46) {
return ""
}
host_end += 1
}
}
if host_end == start || value[start] == cast(u8)46 || value[start] == cast(u8)45 ||
value[host_end - 1] == cast(u8)46 || value[host_end - 1] == cast(u8)45 {
return ""
}
host := value[start:host_end]
if !secure && host != "localhost" && host != "127.0.0.1" && host != "[::1]" {
return ""
}
if host_end < value.count {
if value[host_end] != cast(u8)58 || host_end + 1 == value.count {
return ""
}
port: s64 = 0
index := host_end + 1
while index < value.count {
ch := value[index]
if ch < cast(u8)48 || ch > cast(u8)57 || port > 65535 {
return ""
}
port = port * 10 + cast(s64)(ch - cast(u8)48)
index += 1
}
if port < 1 || port > 65535 {
return ""
}
}
return value
}
+19
View File
@@ -9,6 +9,9 @@ using UI :: #import "kryon/Widgets";
#import "kryon/SystemTheme"
#import "platform"
#import "files"
#import "node_url"
DEFAULT_NODE :: "https://api.waozi.xyz"
PROFILE_NAME_LIMIT :: 40
// Pictures of Kryon's profile picture atlas, five to a row.
@@ -22,6 +25,7 @@ Profile :: struct {
theme_mode: s32
accent: s32
material: bool
node: [256]u8
}
profile: Profile;
@@ -32,6 +36,11 @@ ProfileName :: () -> string {
return TextUntilNul(profile.name[:])
}
ProfileNode :: () -> string {
value := TextUntilNul(profile.node[:])
return ifx value == "" then DEFAULT_NODE else value
}
Accent :: (index: s32) -> u32 {
accents: [ACCENTS]u32 = .[0x7355d9ff, 0x2563ebff, 0x059669ff, 0xdb2777ff, 0xd97706ff, 0x0891b2ff,
0xdc2626ff, 0x7c3aedff, 0x4f46e5ff, 0x0d9488ff, 0x65a30dff, 0xc026d3ff, 0xea580cff,
@@ -78,6 +87,13 @@ ParseInteger :: (text: string) -> s32 {
}
ApplyProfileSetting :: (key: string, value: string) {
if key == "node" {
normalized := NodeOrigin(value)
if normalized != "" {
unused CopyCString(normalized, profile.node[:])
}
return
}
if key == "name" {
count := value.count
if count > PROFILE_NAME_LIMIT {
@@ -160,6 +176,9 @@ SaveProfile :: () -> bool {
used: s64 = 0
// A name never holds a line break: the field keeps one line.
used = AppendLine(text[:], used, "name", ProfileName())
if used >= 0 {
used = AppendLine(text[:], used, "node", ProfileNode())
}
if used >= 0 {
used = AppendLine(text[:], used, "picture", FormatInteger(cast(s64)profile.picture, number[:]))
}
+3 -2
View File
@@ -329,7 +329,7 @@ StartRound :: () -> bool {
// Starts a sync unless one is running.
SyncNow :: () {
if !AccountReady() || SyncRunning() {
if !AccountSyncEnabled() || SyncRunning() {
return
}
if sync_since == 0 && sync_rounds == 0 {
@@ -459,7 +459,8 @@ FailureText :: (result: AuthResult, status: s32) -> string {
// Advances a running sync; call once per frame. Starts one when due.
SyncFrame :: () {
if !AccountReady() {
if !AccountSyncEnabled() {
CancelSyncNow()
return
}
now := WallClock()
+121 -17
View File
@@ -2,6 +2,7 @@
// above the app that is open.
#import "std/byte_text_linux"
#import "std/text_buffer"
#import "std/c_string"
using UI :: #import "kryon/Widgets";
#import "kryon/key_input"
#import "kryon/ScrollDevice"
@@ -10,6 +11,7 @@ using UI :: #import "kryon/Widgets";
#import "profile"
#import "platform"
#import "migrate"
#import "node_url"
#if #defined(ANDROID_BUILD) {
#import "android_fields"
}
@@ -34,11 +36,14 @@ FieldState :: struct {
screen: s32;
open_app: s32 = -1;
// One app on its own, without Werkzeug's bar, as in a page that embeds it.
// Started in a page embedding the toolkit, with navigation still available.
mini: bool;
name_field: FieldState;
code_field: FieldState;
code_text: [32]u8;
node_field: FieldState;
node_text: [256]u8;
node_error: bool;
// Stop syncing was tapped once; a second tap forgets the account here.
forget_pending: bool;
choosing_picture: bool;
@@ -51,10 +56,10 @@ revealed_field: s32;
profile_height: float32;
typed: [256]u8;
keyboard_wanted: bool;
WerkStart :: () {
MigratePassData()
LoadProfile()
unused CopyCString(ProfileNode(), node_text[:])
LoadApps()
#if !#defined(PLATFORM_WEB) {
LoadAccount()
@@ -62,7 +67,7 @@ WerkStart :: () {
}
// Opens an app by id at start, such as from the page address. In mini mode
// it fills the window and there is no way home.
// the host keeps navigation so every tool remains available.
WerkOpen :: (id: string, alone: bool) -> bool {
index: s32 = 0
while index < AppCount() {
@@ -101,6 +106,7 @@ OpenHome :: () {
if screen == SCREEN_PROFILE {
name_field.focused = false
code_field.focused = false
node_field.focused = false
forget_pending = false
unused SaveProfile()
}
@@ -282,6 +288,9 @@ RevealFocusedField :: (area: Rectangle) {
if code_field.focused {
field = 31
}
if node_field.focused {
field = 32
}
if field != 0 && (field != revealed_field || area.height != profile_height) {
margin: float32 = 16.0
if focused_bottom + margin > area.y + area.height {
@@ -303,7 +312,7 @@ ProfileScreen :: (session: Session, area: Rectangle, input: TextFieldInput) {
width = 480.0
}
left := area.x + (area.width - width) * 0.5
content_height: s32 = 620 + 300
content_height: s32 = 620 + 500
if choosing_picture {
content_height += cast(s32)((PROFILE_PICTURES + 5) / 6) * 56 + 16
}
@@ -445,6 +454,69 @@ CodeField :: (session: Session, bounds: Rectangle, input: TextFieldInput, buffer
code_field.focused = focused && !finished
}
NodeField :: (session: Session, bounds: Rectangle, input: TextFieldInput) {
edit: TextFieldEdit
focused := false
finished := false
snapshot: [256]u8
#if #defined(ANDROID_BUILD) {
if node_field.focused {
AndroidFieldRead(32, node_text[:], *node_field.cursor, *node_field.anchor)
}
}
{
snapshot = node_text
props := TextFieldProps.{.key = cast(u64)32, .focus_id = 32, .bounds = bounds,
.label = "Daochi node", .placeholder = "https://your-node.example", .value = TextUntilNul(snapshot[:]),
.cursor = node_field.cursor, .anchor = node_field.anchor, .scroll_x = node_field.scroll_x,
.focused = node_field.focused, .max_bytes = 255, .max_codepoints = 255}
if node_field.focused {
props.input = input
}
#if #defined(ANDROID_BUILD) {
if node_field.focused {
props.input = TextFieldInput.{}
}
}
result := TextField(session, props)
if result.focused {
focused_top = bounds.y
focused_bottom = bounds.y + bounds.height
}
edit = result.edit
node_field.cursor = result.cursor
node_field.anchor = result.anchor
node_field.scroll_x = result.scroll_x
focused = result.focused
finished = result.escaped || result.committed
}
ApplyEdit(node_text[:], edit)
#if #defined(ANDROID_BUILD) {
if focused {
AndroidFieldSubmit(32, node_text[:], node_field.cursor, node_field.anchor)
}
}
node_field.focused = focused && !finished
}
SaveNode :: () -> bool {
snapshot := node_text
value := NodeOrigin(TextUntilNul(snapshot[:]))
node_error = value == ""
if node_error {
return false
}
previous := profile.node
unused CopyCString(value, profile.node[:])
if !SaveProfile() {
profile.node = previous
node_error = true
return false
}
node_field.focused = false
return true
}
// The account that syncs Auth: create one, connect to one, or connect
// another device to it.
SyncSection :: (session: Session, x: float32, y: float32, width: float32, input: TextFieldInput) {
@@ -457,7 +529,7 @@ SyncSection :: (session: Session, x: float32, y: float32, width: float32, input:
phase := LinkPhaseNow()
if !AccountReady() {
Note(session, cast(u64)47,
"Keep Auth's accounts on all your devices. They are encrypted here; the server never sees them.",
"Sync is optional and off. Every tool works locally. Choose a node before creating or connecting an account.",
x, y, width)
y += 48.0
if phase == LinkPhase.LinkJoining {
@@ -467,8 +539,19 @@ SyncSection :: (session: Session, x: float32, y: float32, width: float32, input:
}
return
}
NodeField(session, Rectangle.{x, y, width, 44.0}, input)
y += 52.0
if Action(session, 78, "Save node", Rectangle.{x, y, width, 40.0}, false) {
unused SaveNode()
}
y += 48.0
if node_error {
Note(session, cast(u64)79, "Enter an HTTPS node address. HTTP works for localhost. Check that settings can be saved.",
x, y, width)
y += 48.0
}
if Action(session, 70, "Create account", Rectangle.{x, y, width, 40.0}, false) {
if !CreateAccount() {
if !SaveNode() || !CreateAccount() {
Label(session, cast(u64)48, "Could not create the account", Rectangle.{x, y + 104.0, width, 20.0}, 14)
} else {
SyncNow()
@@ -480,7 +563,9 @@ SyncSection :: (session: Session, x: float32, y: float32, width: float32, input:
CodeField(session, Rectangle.{x, y, width - 120.0, 40.0}, input, code_text[:])
if Action(session, 71, "Connect", Rectangle.{x + width - 112.0, y, 112.0, 40.0}, false) {
code_field.focused = false
LinkJoin(TextUntilNul(code_text[:]))
if SaveNode() {
LinkJoin(TextUntilNul(code_text[:]))
}
}
y += 48.0
if phase == LinkPhase.LinkFailed {
@@ -488,13 +573,34 @@ SyncSection :: (session: Session, x: float32, y: float32, width: float32, input:
}
return
}
Label(session, cast(u64)80, AccountServer(), Rectangle.{x, y, width, 24.0}, 14)
y += 32.0
enabled := AccountSyncEnabled()
Label(session, cast(u64)83, "Sync with Daochi", Rectangle.{x, y + 8.0, width - 80.0, 24.0}, 14)
toggle := Toggle(session, ToggleProps.{.key = cast(u64)81, .id = 81,
.bounds = Rectangle.{x + width - 64.0, y, 64.0, 40.0}, .label = "Sync with Daochi", .value = enabled})
if toggle.changed && SetAccountSyncEnabled(toggle.value) {
if !toggle.value {
CancelSyncNow()
LinkCancel()
} else {
SyncNow()
}
}
y += 48.0
if !AccountSyncEnabled() {
Note(session, cast(u64)82, "Sync is off. Your account and records stay on this device.", x, y, width)
y += 48.0
}
status := ifx SyncStatus() == "" then "Sync is on" else SyncStatus()
Label(session, cast(u64)47, status, Rectangle.{x, y, width, 20.0}, 14)
y += 28.0
if Action(session, 73, "Sync now", Rectangle.{x, y, half, 40.0}, false) {
if AccountSyncEnabled() {
Label(session, cast(u64)47, status, Rectangle.{x, y, width, 20.0}, 14)
y += 28.0
}
if AccountSyncEnabled() && Action(session, 73, "Sync now", Rectangle.{x, y, half, 40.0}, false) {
SyncNow()
}
if Action(session, 74, "Connect a device", Rectangle.{x + half + 8.0, y, half, 40.0},
if AccountSyncEnabled() && Action(session, 74, "Connect a device", Rectangle.{x + half + 8.0, y, half, 40.0},
phase == LinkPhase.LinkShowing) {
if phase == LinkPhase.LinkShowing {
LinkCancel()
@@ -516,7 +622,7 @@ SyncSection :: (session: Session, x: float32, y: float32, width: float32, input:
Label(session, cast(u64)76, LinkStatus(), Rectangle.{x, y, width, 20.0}, 14)
y += 28.0
}
if Action(session, 77, ifx forget_pending then "Tap again to stop syncing here" else "Stop syncing on this device",
if Action(session, 77, ifx forget_pending then "Tap again to forget account here" else "Forget account on this device",
Rectangle.{x, y, width, 40.0}, false) {
if forget_pending {
CancelSyncNow()
@@ -569,15 +675,13 @@ WerkFrame :: (session: Session, viewport: Rectangle) -> s32 {
Box(session, background)
keyboard_wanted = false
content := viewport
if !mini {
TopBar(session, viewport)
content = Rectangle.{viewport.x, viewport.y + BAR_HEIGHT, viewport.width, viewport.height - BAR_HEIGHT}
}
TopBar(session, viewport)
content = Rectangle.{viewport.x, viewport.y + BAR_HEIGHT, viewport.width, viewport.height - BAR_HEIGHT}
if screen == SCREEN_HOME {
Home(session, content)
} else if screen == SCREEN_PROFILE {
ProfileScreen(session, content, input)
keyboard_wanted = name_field.focused || code_field.focused
keyboard_wanted = name_field.focused || code_field.focused || node_field.focused
} else if screen == SCREEN_APP && open_app >= 0 {
AppScreen(session, content, key, modifiers, input)
}
+6
View File
@@ -90,6 +90,12 @@ AppNowHost :: () -> float64 { return 0.0 }
#program_export
AppLocalOffsetHost :: () -> s32 { return 0 }
#program_export
AppZoneOffsetHost :: (zone: string, utc: float64) -> s32 { return 0 }
#program_export
AppAlertHost :: (ringing: bool) {}
#program_export
AppScheduleWakeHost :: (id: s32, utc: float64) -> bool { return true }
#program_export
AppAssetPathHost :: (name: string) -> string { return "" }
#program_export
AppPbkdf2Sha256Host :: (password: string, salt: string, iterations: s32) -> string { return "" }
+86
View File
@@ -12,6 +12,8 @@
#import "records"
#import "sync"
#import "device_link"
#import "profile"
#import "node_url"
RECORD_ID :: "e2e0000000000000000000000000000a"
// RFC 6238's test key; never a real secret.
@@ -158,13 +160,97 @@ Remove :: () -> s32 {
return ifx SyncUntilDone() then 0 else 1
}
// Offline preferences use a reserved, unreachable origin. No operation in
// these modes may start a network request.
Preferences :: () -> s32 {
invalid: [12]string = .["", "sync.example", "ftp://sync.example", "https://user:[email protected]",
"https://sync.example/path", "https://sync.example?x=1", "https://sync.example#fragment",
"https://sync.example:0", "https://sync.example:65536", "https://sync.example:abc",
"http://sync.example", "https://sync.example\n"]
for index: 0..11 {
if NodeOrigin(invalid[index]) != "" {
Say("accepted an invalid node")
return 1
}
}
if NodeOrigin("https://sync.example:8443/") != "https://sync.example:8443" ||
NodeOrigin("http://localhost:8989") == "" || NodeOrigin("http://[::1]:8989") == "" {
Say("rejected a valid node")
return 1
}
LoadAccount()
SyncNow()
SyncFrame()
if AccountReady() || SyncRunning() {
Say("a fresh profile started syncing")
return 1
}
unused CopyCString("https://sync.example.invalid", profile.node[:])
if !SaveProfile() {
return 1
}
LoadProfile()
if DefaultServer() != "https://sync.example.invalid" || !CreateAccount() ||
AccountServer() != "https://sync.example.invalid" || !AccountSyncEnabled() {
Say("the selected node was not used")
return 1
}
if !RecordPut("auth", RECORD_ID, RECORD_LINK, Now()) || !SetAccountSyncEnabled(false) {
return 1
}
Say("custom node saved and account paused")
return 0
}
Paused :: () -> s32 {
LoadAccount()
if !AccountReady() || AccountSyncEnabled() || AccountServer() != "https://sync.example.invalid" {
Say("paused account did not survive restart")
return 1
}
SyncSoon()
SyncNow()
SyncFrame()
LinkShow()
LinkFrame()
if SyncRunning() || LinkPhaseNow() != LinkPhase.LinkIdle {
Say("paused account started a request")
return 1
}
record: [1024]u8
if RecordValue("auth", RECORD_ID, record[:]) < 0 {
Say("pausing lost a local record")
return 1
}
if !SetAccountSyncEnabled(true) {
return 1
}
LoadAccount()
if !AccountSyncEnabled() {
return 1
}
if !ForgetAccount() || AccountReady() || RecordValue("auth", RECORD_ID, record[:]) < 0 {
Say("forgetting lost a local record")
return 1
}
Say("pause survived restart, blocked sync and linking, and retained local records")
return 0
}
#program_export
main :: (argc: s32, argv: **u8) -> s32 {
if argc < 2 {
Say("usage: sync_e2e create|show FILE|join FILE|add|remove|present|absent")
return 2
}
LoadProfile()
mode := TextFromCString(argv[1])
if mode == "preferences" {
return Preferences()
}
if mode == "paused" {
return Paused()
}
path := ifx argc >= 3 then TextFromCString(argv[2]) else ""
if mode == "create" {
return Create()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 105 KiB

+2 -2
View File
@@ -14,7 +14,7 @@
<meta property="og:image" content="https://werk.waozi.xyz/images/social.png">
<meta property="og:image:width" content="1536">
<meta property="og:image:height" content="1024">
<meta property="og:image:alt" content="Werkzeug logo: a purple wrench with a keyhole.">
<meta property="og:image:alt" content="Werkzeug logo: a purple modular W with symbols for its private tools.">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Werkzeug — Small private tools">
<meta name="twitter:description" content="Passwords, two-factor codes, a calculator and a clock, on your device.">
@@ -81,7 +81,7 @@
<div class="download-platform-icon"><img src="/icons/display.png" alt=""></div>
<div class="download-platform-body">
<h3>Desktop GUI</h3>
<p>Visual controls, secure masked input, built-in self-updates, and clipboard clearing.</p>
<p>Visual controls, secure masked input, and clipboard clearing.</p>
<nav class="download-pills" aria-label="Desktop downloads">
<a class="is-primary" href="https://github.com/waozixyz/werk/releases/latest/download/werk-${version}-x86_64.AppImage">AppImage x86_64</a>
<a href="https://github.com/waozixyz/werk/releases/latest/download/werk-${version}-aarch64.AppImage">AppImage ARM64</a>