feat: add self-contained link composer
Build and Push Docker Container / build-and-push (push) Successful in 1m36s

- Add structured URL codec with compact alphabets and dictionary support.
- Add public decode, redirect, and QR endpoints for composed links.
- Add authenticated encode API and link composer UI.
- Generate PNG QR codes via qrcode with Pillow support.
- Register the new blueprint and navigation entry.
- Cover public decode, auth gating, redirect URL parsing, and QR output.
- Bump NanoShare to 1.27.0 and lock new dependencies.
This commit is contained in:
2026-08-14 08:56:42 +02:00
parent d3e5e11f8d
commit ed62837f6d
18 changed files with 1139 additions and 163 deletions
+59
View File
@@ -0,0 +1,59 @@
PAYLOAD_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._~!$&'()*+,;=:@"
QR_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"
SEGMENT_ALPHABETS = {
0: "0123456789",
1: "abcdefghijklmnopqrstuvwxyz",
2: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
3: "abcdefghijklmnopqrstuvwxyz0123456789-",
4: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
5: "0123456789ABCDEFabcdef",
6: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&'()*+,;=:@",
7: None, # raw UTF-8 bytes fallback
}
ALPHABET_NAMES = {
0: "decimal",
1: "lowercase",
2: "uppercase",
3: "domain-like",
4: "base64url-like",
5: "hex",
6: "url-safe",
7: "utf8-raw",
}
CODE_VERSION = 2
SUPPORTED_CODE_VERSIONS = {1, 2}
TLD_CODE_WIDTH = 6
DOMAIN_CODE_WIDTH = 6
LEGACY_DICTIONARY_CODE_WIDTH = 4
CODE_PREFIX_PAYLOAD = "u"
CODE_PREFIX_QR = "Q"
MODE_STRUCTURED = "structured"
MODE_QR_STRUCTURED = "qr-structured"
MODE_DECODED = "decoded"
SCHEME_CODES = {"http": 0, "https": 1}
CODE_SCHEMES = {value: key for key, value in SCHEME_CODES.items()}
ALLOWED_REDIRECT_SCHEMES = {"http", "https"}
COMMON_TLDS = [
"", "com", "org", "net", "io", "dev", "at", "de", "edu", "gov", "co", "uk",
"app", "ai", "me", "info", "biz", "xyz", "online", "site", "shop", "store",
"blog", "tech", "cloud", "digital", "tools", "software", "systems", "network",
"eu", "us", "ca", "au", "ch", "fr", "it", "es", "nl", "se", "no", "fi",
"dk", "pl", "cz", "jp", "cn", "in", "br", "ru", "tv", "fm", "to", "gg",
]
COMMON_DOMAINS = [
"", "google", "youtube", "github", "reddit", "wikipedia", "twitter", "x",
"facebook", "instagram", "amazon", "microsoft", "apple", "cloudflare", "stackoverflow",
"linkedin", "tiktok", "whatsapp", "telegram", "discord", "slack", "notion", "medium",
"wordpress", "openai", "anthropic", "claude", "chatgpt", "docker", "kubernetes", "terraform",
"githubusercontent", "gitlab", "bitbucket", "npmjs", "pypi", "python", "nodejs", "mozilla",
"cloudfront", "aws", "azure", "googleapis", "gstatic", "vercel", "netlify", "heroku",
"paypal", "stripe", "shopify", "ebay", "etsy", "twitch", "spotify", "netflix",
"adobe", "figma", "canva", "atlassian", "jira", "confluence", "zoom", "dropbox",
]
SEPARATORS = "/?&=#.:-_~%+"