diff options
Diffstat (limited to 'crates')
| -rwxr-xr-x | crates/wipfel/build-release.sh | 2 | ||||
| -rwxr-xr-x | crates/wipfel/serve-here.sh | 2 | ||||
| -rw-r--r-- | crates/wipfel/www/index.html | 15 | ||||
| -rw-r--r-- | crates/wipfel/www/loader.js | 4 |
4 files changed, 17 insertions, 6 deletions
diff --git a/crates/wipfel/build-release.sh b/crates/wipfel/build-release.sh index 1ee09b7..4375491 100755 --- a/crates/wipfel/build-release.sh +++ b/crates/wipfel/build-release.sh @@ -15,7 +15,7 @@ mkdir -p "$DIST" wasm-bindgen --remove-name-section --target web --out-dir "$DIST" target/wasm32-unknown-unknown/release/wipfel.wasm # the loader page (not the trunk entry point, which is dev-only) rm -f "$DIST"/wipfel.d.ts "$DIST"/wipfel_bg.wasm.d.ts -cp crates/wipfel/www/index.html crates/wipfel/www/style.css "$DIST/" +cp crates/wipfel/www/index.html crates/wipfel/www/style.css crates/wipfel/www/loader.js "$DIST/" gzip -9 -n -c gipfel.dat > "$DIST/gipfel.dat.gz" echo "site assembled in $DIST ($(du -sh "$DIST" | cut -f1)):" ls "$DIST" diff --git a/crates/wipfel/serve-here.sh b/crates/wipfel/serve-here.sh index 2accdb9..c43fbd8 100755 --- a/crates/wipfel/serve-here.sh +++ b/crates/wipfel/serve-here.sh @@ -7,6 +7,6 @@ cargo build -p wipfel --target wasm32-unknown-unknown --release DIST=/tmp/wipfel-dist mkdir -p "$DIST" wasm-bindgen --target web --out-dir "$DIST" target/wasm32-unknown-unknown/release/wipfel.wasm -cp crates/wipfel/www/index.html crates/wipfel/www/style.css "$DIST/" +cp crates/wipfel/www/index.html crates/wipfel/www/style.css crates/wipfel/www/loader.js "$DIST/" gzip -9 -n -c gipfel.dat > "$DIST/gipfel.dat.gz" echo "dist refreshed: $(ls -la "$DIST" | awk '{s+=$5} END {print s" bytes"}')" diff --git a/crates/wipfel/www/index.html b/crates/wipfel/www/index.html index 67d0378..e56de5c 100644 --- a/crates/wipfel/www/index.html +++ b/crates/wipfel/www/index.html @@ -2,6 +2,16 @@ <html lang="en"> <head> <meta charset="utf-8" /> + <!-- + Content-Security-Policy (ships with the page so it applies on any + static host). Scripts only from this origin, no inline JS; wasm + compilation is the one scoped exception. Inline style *attributes* + are used by the Yew views, hence style-src unsafe-inline. + --> + <meta + http-equiv="Content-Security-Policy" + content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; img-src 'self' blob: data:; connect-src 'self' blob: data:; style-src 'self' 'unsafe-inline'" + /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="theme-color" content="#101014" media="(prefers-color-scheme: dark)" /> <meta name="theme-color" content="#e9eaf0" media="(prefers-color-scheme: light)" /> @@ -9,9 +19,6 @@ <link rel="stylesheet" href="style.css" /> </head> <body> - <script type="module"> - import init from './wipfel.js'; - init(); - </script> + <script type="module" src="loader.js"></script> </body> </html> diff --git a/crates/wipfel/www/loader.js b/crates/wipfel/www/loader.js new file mode 100644 index 0000000..8880478 --- /dev/null +++ b/crates/wipfel/www/loader.js @@ -0,0 +1,4 @@ +// External loader so the page needs no inline <script>, keeping +// `script-src 'self'` in the Content-Security-Policy sufficient. +import init from './wipfel.js'; +init(); |
