commit 9baf999e82ef44369f6b8658c2ac80e52360fdfc Author: Tomasz Kapias Date: Thu Apr 27 23:27:02 2023 +0700 v1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..9665645 --- /dev/null +++ b/README.md @@ -0,0 +1,141 @@ +# [stilde][stilde_repo] + +![Bash](https://img.shields.io/badge/bash-1f425f.svg?style=for-the-badge&logo=image%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTExIDc5LjE1ODMyNSwgMjAxNS8wOS8xMC0wMToxMDoyMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkE3MDg2QTAyQUZCMzExRTVBMkQxRDMzMkJDMUQ4RDk3IiB4bXBNTTpEb2N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zoFJNxP2HjyIQho4PewK6hBktoDcUwtIln4PjOWzflQ%2Be5yl0yCCYgYikTclGlxadio%2BBQCSiW1UXoVGrKYwH4RgMrjU1HAB4vR6LzWYfFUCKxfS8Ftk5qxHoCUQAUkRJaSEokkV6Y%2F%2BJUOC4hn6A39NVXVBYeNP8piH6HeA4fPbpdBQV5KOx0QaL1YppX3Jgk0TwH2Vg6S3u%2BdB91%2B%2FpuNYPYFl5uP5V7ZqvsrX7jxqMXR6ff3gCQSTzFI0a1TX3wIs8ul%2Bq4HuWAAiM39vhOuR1O1fQ2gT%2F26Z8Z5vrl2OHi9OXZn995nLV9aFfS6UC9JeJPfuK0NBohWpCHMSAAsFe74WWP%2BvT25wtP9Bpob6uGqqyDnOtaeumjRu%2ByFu36VntK%2FPA5umTJeUtPWZSU9BCgud661odVp3DZtkc7AnYR33RRC708PrVi1larW7XwZIjLnd7R6SgSqWSNjU1B3F72pz5TZbXmX5vV81Yb7Lg7XT%2FUXriu8XLVqw6c6XqWnBKiiYU%2BMt3wWF7u7i91XlSEITwSAZ%2FCzAAHsJVbwXYFFEAAAAASUVORK5CYII%3D) +https://img.shields.io/badge/staticrypt-v3.3.0-brightgreen + +**stilde** is the template for my personal startpage. + +The startpage by itself is a lightly modified version of the **[tilde][tilde_repo]** project by [cade](https://github.com/xvvvyz). + +I use it both locally (localhost file) and self-hosted (https), that's why I wanted a way to protect the page that would still stay light, static and bypassable by an action-less uri. + +Stilde include **[staticrypt][staticrypt_repo]** for that purpose and provide an authentification form to decrypt the page locally by password or by a decryption uri without any other input. + +[Staticrypt Form](assets/screenshots/startpage.png) +[Stilde Startpage](assets/screenshots/staticrypt.png) + +---- + +## Features + +- All tilde features. + - Redirect to a bookmarked website. + - Run a search on a bookmarked website. + - Get search suggestions from DuckDuckGo. + - Redirect to a specific path or uri for a bookmarked website. + - Access any other url. + - Lauch a search on a customized DuckDuckGo session for anything outside the scope. +- WebCrypto html encryption with password prompt. +- Direct decryption by secret hash uri. +- Deployment and re-deployment with one command. +- New: custom logo on both form and startpage. + +## License + +UNLICENCED : like the original tilde project. + +## Requirements + +- npm@lts (I use v18.16.0 with nvm) +- Bash (for the `build.sh` script) + +## Installation + +- Clone this repo in a parent directory outside of your webroot (the webroot is the destination of the build): + +``` bash +git clone --depth=1 https://git.tkapias.net/tkapias/stilde +cd stilde +``` + +## Preparation (optional) + +- Edit french strings for the staticrypt form in `build.sh`: + +``` bash + 85 │ --template-button "DECRYPTER" \ + 86 │ --template-instructions "Crypté avec StatiCrypt." \ + 87 │ --template-error "Mot de passe incorrect !" \ + 88 │ --template-placeholder "Mot de passe" \ + 89 │ --template-remember "Se souvenir de moi" \ +``` + +- Edit graphical asset in `assets/root/`: + - favicon.ico (`convert icon-512.png -define icon:auto-resize="48,32,16" favicon.ico`) + - favicon.svg (square logo, width 192px) + - icon-192.png (generated from favicon.svg) + - icon-512.png (generated from favicon.svg) + - logo.svg (trimmed favicon.svg, width 200px) + +- Replace the svg logo in the startpage `assets/source/index.html`: + +I exported mines from inkscape, cleaned it's code and renamed paths to use them in css and scripts. + +``` html + 622 │
+ 623 │ + 624 │ " Desination webroot path or directory + -p "" Password for decryption >= 12 characters + -s "" Salt string = 32 hexadecimal characters + -t "" Title for the staticrypt form page + -u "" Https or localhost Url for the destination root + +Example: ./build.sh -u https://start.domain.tld -d static -t "STILDE - StartPage" +``` + +---- + +[//]: # (LINKS) +[stilde_repo]: https://git.tkapias.net/tkapias/stilde +[tilde_repo]: https://github.com/xvvvyz/tilde +[staticrypt_repo]: https://github.com/robinmoisson/staticrypt diff --git a/assets/root/favicon.ico b/assets/root/favicon.ico new file mode 100644 index 0000000..106aa32 Binary files /dev/null and b/assets/root/favicon.ico differ diff --git a/assets/root/favicon.svg b/assets/root/favicon.svg new file mode 100644 index 0000000..9b8a290 --- /dev/null +++ b/assets/root/favicon.svg @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + diff --git a/assets/root/icon-192.png b/assets/root/icon-192.png new file mode 100644 index 0000000..59a0b85 Binary files /dev/null and b/assets/root/icon-192.png differ diff --git a/assets/root/icon-512.png b/assets/root/icon-512.png new file mode 100644 index 0000000..f269ed3 Binary files /dev/null and b/assets/root/icon-512.png differ diff --git a/assets/root/logo.svg b/assets/root/logo.svg new file mode 100644 index 0000000..7a1d23b --- /dev/null +++ b/assets/root/logo.svg @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + diff --git a/assets/root/manifest.webmanifest b/assets/root/manifest.webmanifest new file mode 100644 index 0000000..a893e5b --- /dev/null +++ b/assets/root/manifest.webmanifest @@ -0,0 +1,6 @@ +{ + "icons": [ + { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" }, + { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" } + ] +} diff --git a/assets/root/robots.txt b/assets/root/robots.txt new file mode 100644 index 0000000..c6742d8 --- /dev/null +++ b/assets/root/robots.txt @@ -0,0 +1,2 @@ +User-Agent: * +Disallow: / diff --git a/assets/screenshots/startpage.png b/assets/screenshots/startpage.png new file mode 100644 index 0000000..a51d4d3 Binary files /dev/null and b/assets/screenshots/startpage.png differ diff --git a/assets/screenshots/staticrypt.png b/assets/screenshots/staticrypt.png new file mode 100644 index 0000000..4aec486 Binary files /dev/null and b/assets/screenshots/staticrypt.png differ diff --git a/assets/source/index.html b/assets/source/index.html new file mode 100644 index 0000000..c59b32e --- /dev/null +++ b/assets/source/index.html @@ -0,0 +1,662 @@ + + + + + + + + + + +TKA - Start Page + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + +
+ +
diff --git a/assets/templates/password_template.html b/assets/templates/password_template.html new file mode 100644 index 0000000..81a52db --- /dev/null +++ b/assets/templates/password_template.html @@ -0,0 +1,235 @@ + + + + + /*[|template_title|]*/0 + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b09240b --- /dev/null +++ b/build.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +# locale +export LC_ALL="C.UTF-8" +export TZ=:/etc/localtime + +Help() +{ + cat <<- 'HEREDOC' + + Generate static website with encrypted code by staticrypt. + The first pass requires -t, -d and -u options, re-run it with -c option only. + + Syntax: ./build.sh [-h] [Options...] + + options: + -h Print this Help + -c Fetch options from ".staticrypt.conf" + -d "" Desination webroot path or directory + -p "" Password for decryption >= 12 characters + -s "" Salt string = 32 hexadecimal characters + -t "" Title for the staticrypt form page + -u "" Https or localhost Url for the destination root + + Example: ./build.sh -u https://start.domain.tld -d static -t "STILDE - StartPage" + + HEREDOC +} + +cd "$(dirname $0)" + +# install staticrypt package +if ! [[ -s ./node_modules/.bin/staticrypt ]]; then + npm install +fi + +# options +while getopts ":hcd:p:s:t:u:" option; do + case $option in + h ) Help; exit 0 ;; + c ) _CONF=.staticrypt.conf ;; + d ) _DEST="${OPTARG}" ;; + p ) _PASS="${OPTARG}" ;; + s ) _SALT="${OPTARG}" ;; + t ) _TITLE="${OPTARG}" ;; + u ) _URL="${OPTARG}" ;; + \?) echo -e "Unknown option: -$OPTARG \n" >&2; Help; exit 1;; + : ) echo -e "Missing argument for -$OPTARG \n" >&2; Help; exit 1;; + esac +done + +# use config file or input options +if [[ -z $_CONF ]]; then + if [[ -z $_DEST ]] || [[ -z $_URL ]] || [[ -z $_TITLE ]]; then + echo -e "Error: options -d and -u are mandatory.\n" >&2; Help; exit 1 + fi + if [[ -z $_PASS ]]; then + _PASS=$(openssl rand -base64 12) + fi + if [[ -z $_SALT ]]; then + _SALT=$(openssl rand -hex 16) + fi +else + _DEST=$(sed -n '/STATIC=/ s/STATIC=//p;' $_CONF | tr -d '\n') + _PASS=$(sed -n '/PASSWORD=/ s/PASSWORD=//p;' $_CONF | tr -d '\n') + _SALT=$(sed -n '/SALT=/ s/SALT=//p;' $_CONF | tr -d '\n') + _URL=$(sed -n '/URL=/ s/URL=//p;' $_CONF | tr -d '\n') + _TITLE=$(sed -n '/TITLE=/ s/TITLE=//p;' $_CONF | tr -d '\n') +fi + +# create directories +mkdir -p --verbose assets/{root,source,templates} encrypted $_DEST + +# generate an url hash for the decrypted form-less page +_URLHASH=$(STATICRYPT_PASSWORD=${_PASS} ./node_modules/.bin/staticrypt --config false --salt ${_SALT} --share) + +# encrypt files & update config file +STATICRYPT_PASSWORD=${_PASS} \ + ./node_modules/.bin/staticrypt assets/source/ \ + --config false \ + --recursive true \ + --remember 7 \ + --salt ${_SALT} \ + --template assets/templates/password_template.html \ + --template-button "DECRYPTER" \ + --template-instructions "Crypté avec StatiCrypt." \ + --template-error "Mot de passe incorrect !" \ + --template-placeholder "Mot de passe" \ + --template-remember "Se souvenir de moi" \ + --template-title "${_TITLE}" && \ + cat <<- HEREDOC > .staticrypt.conf + STATIC=$_DEST + PASSWORD=$_PASS + SALT=$_SALT + URL=$_URL + TITLE=$_TITLE + DECRYPTURL=$_URL$_URLHASH + LOGOUTURL=$_URL#staticrypt_logout + HEREDOC + +# copy assets and encrypted files to the webroot +cp -r assets/root/* $_DEST/ +cp -r encrypted/source/* $_DEST/ + +cat .staticrypt.conf diff --git a/package.json b/package.json new file mode 100644 index 0000000..70eafdc --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "stilde", + "version": "1.0.0", + "description": "Secure start page powered by staticrypt and tilde", + "repository": { + "type": "git", + "url": "https://git.tkapias.net/tkapias/stilde" + }, + "keywords": [ + "startpage", + "homepage", + "minimal", + "encrypted" + ], + "author": "Tomasz Kapias (https://tkapias.net)", + "license": "UNLICENSED", + "dependencies": { + "staticrypt": "^3.3.0" + } +}