Skip to content

Commit 209eac7

Browse files
authored
feat(hermes): web integration via static assets (#530)
* feat: enhance Flutter asset serving and HTTP routing security - Fix host header parsing by stripping port numbers for proper routing - Add comprehensive Flutter web asset serving with MIME type detection - Implement security headers (COOP/COEP) for SharedArrayBuffer support - Improve asset caching and fallback logic for navigation routes - Add version configuration and manifest updates - Disable HDF5 compression in tests for debugging * chore: bump catalyst-ci version from v3.5.4 to v3.5.13 - Update all Earthfile imports to use catalyst-ci v3.5.13 - Update build number in hermes http-proxy version.json - Affects WASM modules, integration tests, documentation, and Hermes components * Add additional web asset copying to WASM build pipeline - Copy main.dart.js_1.part.js, sqlite3.wasm, and drift_worker.js to www/ directory - Add fallback logging for missing files to improve build visibility - Support additional Flutter/Drift dependencies in Hermes WASM modules * refactor(routing): improve docs and extract constants - Add comprehensive routing documentation with Flutter web context - Extract magic strings to constants (DEFAULT_INDEX_PATH, DOCUMENT_ROOT) - Refactor routing logic with RouteType enum for better separation - Apply security headers to 404 responses consistently * fix: simplify HTTP routing documentation and headers handling - Remove redundant code comment diagrams from serve_static_web_content - Fix add_security_headers return to use ? operator consistency - Update build number for http-proxy module * fix: simplify HTTP routing documentation and headers handling - Remove redundant code comment diagrams from serve_static_web_content - Fix add_security_headers return to use ? operator consistency - Update build number for http-proxy module * fix: simplify HTTP routing documentation and headers handling - Remove redundant code comment diagrams from serve_static_web_content - Fix add_security_headers return to use ? operator consistency - Update build number for http-proxy module * refactor: streamline routing code and documentation * refactor(http-gateway): streamline routing logic and improve error handling - Better hostname validation and parsing - Simplified WebAssembly request processing - Improved error responses and documentation - Clean up unused imports and optimize header handling * refactor(http-gateway): streamline routing logic and improve error handling - Better hostname validation and parsing - Simplified WebAssembly request processing - Improved error responses and documentation - Clean up unused imports and optimize header handling * - Clean up HTTP gateway routing module formatting - Add COEP and Embedder terms to project dictionary * - Clean up HTTP gateway routing module formatting - Add COEP and Embedder terms to project dictionary * Remove Flutter-specific cache headers from HTTP gateway - Remove add_flutter_cache_headers function and its usage - Remove is_critical_file helper function - Simplify static file serving by removing custom cache control logic - Streamline HTTP gateway routing implementation * Remove unused Dart MIME type mapping Remove dart -> application/dart mapping from content type detection as it's no longer needed in the HTTP gateway routing. * refactor(http-gateway): improve path validation and add documentation - Replace inline regex compilation with LazyLock for performance - Refactor is_valid_path to use functional style with better error handling - Add comprehensive documentation for HTTP routing functions - Extract content-type and cache-control constants for maintainability - Clean up code formatting and improve readability chore: remove trailing empty lines from Earthfiles * refactor(http-gateway): improve path validation and add documentation - Replace inline regex compilation with LazyLock for performance - Refactor is_valid_path to use functional style with better error handling - Add comprehensive documentation for HTTP routing functions - Extract content-type and cache-control constants for maintainability - Clean up code formatting and improve readability chore: remove trailing empty lines from Earthfiles
1 parent 53770aa commit 209eac7

File tree

14 files changed

+520
-119
lines changed

14 files changed

+520
-119
lines changed

.config/dictionaries/project.dic

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,6 @@ xprivate
151151
xprv
152152
xpub
153153
zilla
154+
Embedder
155+
COEP
156+
canvaskit

Earthfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ VERSION 0.8
33
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.5.14 AS mdlint-ci
44
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.5.14 AS cspell-ci
55

6+
67
# cspell: words livedocs sitedocs
78

89
# check-markdown : markdown check using catalyst-ci.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/input-output-hk/hermes/main/hermes/schemas/hermes_app_manifest.schema.json",
3+
"name": "app",
34
"icon": "icon.svg",
45
"metadata": "metadata.json",
56
"modules": [
67
{
78
"package": "modules/http-proxy/lib/http_proxy.hmod",
89
"name": "http_proxy"
910
}
10-
]
11+
],
12+
"www": "modules/http-proxy/lib/www"
1113
}

hermes/apps/athena/modules/Earthfile

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ VERSION 0.8
99
# This includes: rustc, cargo, wasm32-wasip2 target, optimization tools, and build utilities
1010
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.14 AS rust-ci
1111

12+
1213
# Alternative for local catalyst-ci debugging (uncomment when needed):
1314
# IMPORT ../../../catalyst-ci/earthly/rust AS rust-ci
1415

@@ -122,10 +123,7 @@ gen-bindings:
122123
# Output: http_proxy.wasm - Executable WebAssembly module
123124
# Duration: ~3-5 minutes (Rust compilation to WASM)
124125
local-build-http-proxy:
125-
# Initialize the Rust CI environment with pre-configured toolchain
126126
DO rust-ci+SETUP
127-
128-
# Set working directory for build process
129127
WORKDIR /app
130128

131129
# Copy source code and project configuration
@@ -140,17 +138,35 @@ local-build-http-proxy:
140138
COPY http-proxy/lib/manifest_module.json .
141139
COPY http-proxy/lib/metadata.json .
142140
COPY http-proxy/lib/settings.schema.json .
141+
142+
# Create the missing config.json file (empty JSON object)
143+
RUN echo '{}' > config.json
144+
145+
# Download web assets directly to root level
146+
COPY github.com/input-output-hk/catalyst-voices/catalyst_voices+build-web/web .
143147

144148
# Compile Rust code to WebAssembly
145149
DO rust-ci+CARGO \
146150
--args "build --target wasm32-wasip2 --release" \
147151
--output="wasm32-wasip2/release/http_proxy.wasm"
148152

149-
# Export build artifacts
150-
SAVE ARTIFACT target/wasm32-wasip2/release/http_proxy.wasm http_proxy.wasm
153+
# Create staging directory structure
154+
RUN mkdir -p /staging/www
155+
156+
# Copy WASM module and JSON config files to root of staging
157+
RUN cp target/wasm32-wasip2/release/http_proxy.wasm /staging/
158+
RUN cp *.json /staging/ || true
159+
160+
# Copy web assets to www subdirectory
161+
RUN cp -r assets /staging/www/ || true
162+
RUN cp -r canvaskit /staging/www/ || true
163+
RUN cp -r icons /staging/www/ || true
164+
165+
# Copy all regular files from current directory to staging/www, skip directories
166+
RUN find . -maxdepth 1 -type f -exec cp {} /staging/www/ \; 2>/dev/null || echo "⚠️ Some files may not have been copied"
151167

152-
# Save to local filesystem in expected location for packaging
153-
SAVE ARTIFACT target/wasm32-wasip2/release/http_proxy.wasm AS LOCAL http-proxy/lib/http_proxy.wasm
168+
# Export build artifacts from staging directory
169+
SAVE ARTIFACT /staging AS LOCAL http-proxy/lib
154170

155171
# Future Module Build Targets
156172
# ============================
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "Catalyst Voices",
3+
"short_name": "Catalyst Voices",
4+
"start_url": ".",
5+
"display": "standalone",
6+
"background_color": "#0175C2",
7+
"theme_color": "#0175C2",
8+
"description": "Catalyst Voices",
9+
"orientation": "portrait-primary",
10+
"prefer_related_applications": false,
11+
"icons": [
12+
{
13+
"src": "icons/Icon-192.png",
14+
"sizes": "192x192",
15+
"type": "image/png"
16+
},
17+
{
18+
"src": "icons/Icon-512.png",
19+
"sizes": "512x512",
20+
"type": "image/png"
21+
}
22+
]
23+
}

hermes/apps/athena/modules/http-proxy/lib/manifest_module.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
},
1010
"settings": {
1111
"schema": "settings.schema.json"
12-
}
12+
},
13+
"share": "www"
1314
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"app_name":"catalyst_voices","version":"0.1.0","build_number":"1757006451","package_name":"catalyst_voices"}

hermes/bin/src/logger.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use derive_more::Display;
66
use tracing::level_filters::LevelFilter;
77
use tracing_subscriber::{
88
fmt::{format::FmtSpan, time},
9-
FmtSubscriber,
9+
EnvFilter, FmtSubscriber,
1010
};
1111

1212
use crate::runtime_extensions::bindings::hermes::logging;
@@ -167,6 +167,8 @@ pub(crate) fn init(logger_config: &LoggerConfig) -> anyhow::Result<()> {
167167
.with_timer(time::UtcTime::rfc_3339())
168168
.with_span_events(FmtSpan::CLOSE)
169169
.with_max_level(LevelFilter::from_level(logger_config.log_level.into()))
170+
// Hardcode the filter to always suppress IPFS noise
171+
.with_env_filter(EnvFilter::new("hermes=info,rust_ipfs=error"))
170172
.finish();
171173

172174
Ok(tracing::subscriber::set_global_default(subscriber)?)

0 commit comments

Comments
 (0)