mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-11-19 09:01:23 +01:00
Load signed hosted launcher catalog with offline fallback (#1115)
* Load and verify the signed website catalog with bundled fallback * Preserve signed fixture bytes across platforms and fix web lint * Document the opt-in live catalog integration check
This commit is contained in:
1 parent
5b19f76540
commit
f6409da7f7
28 files changed
+3312
-623
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Signatures verify exact bytes; checkout must not convert signed TOML to CRLF.
|
||||
/crates/core/tests/fixtures/hosted-catalog.toml -text
|
||||
@@ -63,3 +63,11 @@ licensed like those apps. Refresh them from the source path, never redraw them.
|
||||
|---|---|---|---|---|
|
||||
| `docs/brand/` (all files) | ArtCraft name, wordmark and mark | ArtCraft Team | getartcraft.com | Not open source; trademarks of the ArtCraft Team, [`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt) |
|
||||
| README app icons (linked, not copied) | Each Craft app's 64 px icon | ArtCraft Team and each app's contributors | `raw.githubusercontent.com/storytold/<app>/main/assets/app-icon/hicolor/64x64/apps/ai.storyteller.<app>.png` | MIT OR Apache-2.0 (each app's license) |
|
||||
|
||||
## Hosted catalog verification
|
||||
|
||||
| Path | Title | Author | Source | License |
|
||||
| ---------------------------------------------------- | ----------------------------------------- | ------------- | ---------------------------------------------------- | ----------------- |
|
||||
| `crates/core/assets/launcher-catalog-public-key.pem` | Launcher catalog Ed25519 verification key | ArtCraft Team | Maintainer-supplied website catalog signing keypair | MIT OR Apache-2.0 |
|
||||
| `crates/core/catalog.toml` | Bundled launcher catalog | ArtCraft Team | `storytold/artcraft-services` PR #205 | MIT OR Apache-2.0 |
|
||||
| `crates/core/tests/fixtures/hosted-catalog.toml.sig` | Detached catalog signature test fixture | ArtCraft Team | Signature of the bundled catalog with its pinned key | MIT OR Apache-2.0 |
|
||||
Generated
+140
-8
@@ -300,10 +300,14 @@ dependencies = [
|
||||
name = "artcraft-launcher-core"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"ed25519-dalek",
|
||||
"jiff",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"toml 1.1.8+spec-1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -360,6 +364,7 @@ dependencies = [
|
||||
"egui",
|
||||
"js-sys",
|
||||
"log",
|
||||
"serde_json",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
@@ -595,6 +600,12 @@ version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.10.0"
|
||||
@@ -903,6 +914,12 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.4"
|
||||
@@ -1110,6 +1127,33 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "4.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"curve25519-dalek-derive",
|
||||
"digest",
|
||||
"fiat-crypto",
|
||||
"rustc_version",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek-derive"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data-url"
|
||||
version = "0.3.2"
|
||||
@@ -1147,6 +1191,17 @@ dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"pem-rfc7468",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.5.8"
|
||||
@@ -1203,7 +1258,7 @@ dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1281,6 +1336,30 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519"
|
||||
version = "2.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"
|
||||
dependencies = [
|
||||
"pkcs8",
|
||||
"signature",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519-dalek"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"ed25519",
|
||||
"serde",
|
||||
"sha2",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.37.0"
|
||||
@@ -1574,7 +1653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1639,6 +1718,12 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97b65636e5b9ef369943878ac74335ba1c55c1cb6adbf1e2c293c624248d693"
|
||||
|
||||
[[package]]
|
||||
name = "fiat-crypto"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.6"
|
||||
@@ -3538,7 +3623,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3601,6 +3686,15 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peniko"
|
||||
version = "0.6.1"
|
||||
@@ -3717,6 +3811,16 @@ dependencies = [
|
||||
"futures-io",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs8"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
|
||||
dependencies = [
|
||||
"der",
|
||||
"spki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.34"
|
||||
@@ -3970,6 +4074,15 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "range-alloc"
|
||||
version = "0.1.5"
|
||||
@@ -4225,7 +4338,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4282,7 +4395,7 @@ dependencies = [
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"webpki-root-certs",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4482,6 +4595,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.10"
|
||||
@@ -4634,6 +4756,16 @@ dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spki"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"der",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.1"
|
||||
@@ -4782,10 +4914,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.3.4",
|
||||
"getrandom 0.4.3",
|
||||
"once_cell",
|
||||
"rustix 1.1.5",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5788,7 +5920,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -19,6 +19,7 @@ artcraft-launcher-core = { workspace = true }
|
||||
artcraft-launcher-ui-egui = { workspace = true }
|
||||
egui = { workspace = true }
|
||||
log = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
# `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback.
|
||||
@@ -26,4 +27,4 @@ eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
js-sys = "0.3"
|
||||
web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlCanvasElement", "MediaQueryList", "Navigator", "Request", "RequestInit", "RequestMode", "Response", "Headers"] }
|
||||
web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlCanvasElement", "MediaQueryList", "Navigator", "Request", "RequestInit", "RequestMode", "Response", "Headers", "Storage", "AbortSignal", "ReadableStream", "ReadableStreamDefaultReader", "RequestRedirect"] }
|
||||
@@ -0,0 +1,112 @@
|
||||
//! Browser startup catalog refresh. Storage failures leave the compiled fallback usable.
|
||||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use artcraft_launcher_core::hosted_catalog::{
|
||||
CATALOG_URL, MAX_CATALOG_BYTES, MAX_ICON_BYTES, MAX_SIGNATURE_BYTES, SIGNATURE_URL, VerifiedCatalog, valid_icon,
|
||||
};
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
|
||||
const CACHE_KEY: &str = "artcraft-launcher.signed-catalog.v1";
|
||||
static CHECKED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub async fn refresh_once() {
|
||||
if CHECKED.swap(true, Ordering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
let storage = web_sys::window().and_then(|w| w.local_storage().ok().flatten());
|
||||
let remote = fetch_pair().await;
|
||||
let catalog = match remote {
|
||||
Ok((catalog, signature)) => match VerifiedCatalog::verify(&catalog, &signature) {
|
||||
Ok(verified) => {
|
||||
if let (Some(storage), Ok(text), Ok(sig)) = (&storage, String::from_utf8(catalog), String::from_utf8(signature))
|
||||
&& let Ok(json) = serde_json::to_string(&(text, sig))
|
||||
{
|
||||
let _ = storage.set_item(CACHE_KEY, &json);
|
||||
}
|
||||
Some(verified)
|
||||
}
|
||||
Err(why) => {
|
||||
log::warn!("hosted catalog rejected: {why}");
|
||||
None
|
||||
}
|
||||
},
|
||||
Err(why) => {
|
||||
log::warn!("hosted catalog unavailable: {why}");
|
||||
None
|
||||
}
|
||||
}
|
||||
.or_else(|| {
|
||||
let saved = storage.as_ref()?.get_item(CACHE_KEY).ok()??;
|
||||
if saved.len() > MAX_CATALOG_BYTES * 6 + MAX_SIGNATURE_BYTES + 128 {
|
||||
return None;
|
||||
}
|
||||
let (text, sig): (String, String) = serde_json::from_str(&saved).ok()?;
|
||||
VerifiedCatalog::verify(text.as_bytes(), sig.as_bytes()).ok()
|
||||
});
|
||||
if let Some(catalog) = catalog {
|
||||
if catalog.rejected_entries > 0 {
|
||||
log::warn!("ignored {} invalid catalog entries", catalog.rejected_entries);
|
||||
}
|
||||
let mut icons = HashMap::new();
|
||||
for (id, url, digest) in catalog.icons() {
|
||||
if artcraft_launcher_core::catalog::app_icon_png(id).is_some_and(|b| valid_icon(b, digest)) {
|
||||
continue;
|
||||
}
|
||||
// The browser's HTTP cache keeps content-addressed icons; hashes are checked every time.
|
||||
match fetch_bytes(url, MAX_ICON_BYTES).await {
|
||||
Ok(bytes) if valid_icon(&bytes, digest) => {
|
||||
icons.insert(id.to_string(), bytes);
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(_) => break, // An offline browser must not wait one timeout for every icon.
|
||||
}
|
||||
}
|
||||
catalog.activate(icons);
|
||||
}
|
||||
}
|
||||
|
||||
async fn fetch_pair() -> Result<(Vec<u8>, Vec<u8>), String> {
|
||||
let catalog = fetch_bytes(CATALOG_URL, MAX_CATALOG_BYTES).await?;
|
||||
let signature = fetch_bytes(SIGNATURE_URL, MAX_SIGNATURE_BYTES).await?;
|
||||
Ok((catalog, signature))
|
||||
}
|
||||
|
||||
/// Stream and cap the actual body, even if content-length is missing or dishonest.
|
||||
async fn fetch_bytes(url: &str, max: usize) -> Result<Vec<u8>, String> {
|
||||
let window = web_sys::window().ok_or("no browser window")?;
|
||||
let init = web_sys::RequestInit::new();
|
||||
init.set_mode(web_sys::RequestMode::Cors);
|
||||
init.set_redirect(web_sys::RequestRedirect::Error);
|
||||
init.set_signal(Some(&web_sys::AbortSignal::timeout_with_u32(20_000)));
|
||||
let request = web_sys::Request::new_with_str_and_init(url, &init).map_err(|_| "invalid catalog request")?;
|
||||
let response: web_sys::Response = JsFuture::from(window.fetch_with_request(&request))
|
||||
.await
|
||||
.map_err(|_| "catalog request failed")?
|
||||
.dyn_into()
|
||||
.map_err(|_| "invalid catalog response")?;
|
||||
if response.status() != 200 {
|
||||
return Err(format!("catalog server answered {}", response.status()));
|
||||
}
|
||||
let announced = response.headers().get("content-length").ok().flatten().and_then(|v| v.parse::<usize>().ok());
|
||||
if announced.is_some_and(|n| n > max) {
|
||||
return Err("catalog response is too large".into());
|
||||
}
|
||||
let reader: web_sys::ReadableStreamDefaultReader =
|
||||
response.body().ok_or("catalog response has no body")?.get_reader().dyn_into().map_err(|_| "catalog response cannot be streamed")?;
|
||||
let mut bytes = Vec::new();
|
||||
loop {
|
||||
let chunk = JsFuture::from(reader.read()).await.map_err(|_| "catalog stream failed")?;
|
||||
if js_sys::Reflect::get(&chunk, &"done".into()).ok().and_then(|v| v.as_bool()) == Some(true) {
|
||||
return Ok(bytes);
|
||||
}
|
||||
let value = js_sys::Reflect::get(&chunk, &"value".into()).map_err(|_| "invalid catalog stream chunk")?;
|
||||
let chunk = js_sys::Uint8Array::new(&value);
|
||||
if chunk.length() as usize > max.saturating_sub(bytes.len()) {
|
||||
let _ = reader.cancel();
|
||||
return Err("catalog response is too large".into());
|
||||
}
|
||||
bytes.extend_from_slice(&chunk.to_vec());
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod hosted_catalog;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::rc::Rc;
|
||||
use artcraft_launcher_core::details::{AppDetails, MAX_SCREENSHOT_BYTES, looks_like_jpeg};
|
||||
use artcraft_launcher_core::protocol::{Backend, Capabilities, Command, Event, LatestRelease, Origin, Source};
|
||||
use artcraft_launcher_core::release::{self, Release};
|
||||
use artcraft_launcher_core::{Arch, Os, Platform, SUITE, catalog, version};
|
||||
use artcraft_launcher_core::{Arch, Os, Platform, catalog, version};
|
||||
use artcraft_launcher_ui_egui::{Host, LauncherUi, Settings, i18n};
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
@@ -173,8 +173,11 @@ impl WebBackend {
|
||||
let pre = self.prereleases;
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
events.borrow_mut().push(Event::CheckStarted);
|
||||
crate::hosted_catalog::refresh_once().await;
|
||||
events.borrow_mut().push(Event::CatalogUpdated);
|
||||
ctx.request_repaint();
|
||||
let mut limited = None;
|
||||
for app in &SUITE {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps() {
|
||||
let latest = latest(app.repo, pre).await;
|
||||
if let Err(Some(reset)) = &latest {
|
||||
limited = Some(*reset);
|
||||
|
||||
@@ -16,3 +16,13 @@ serde_json = { workspace = true }
|
||||
semver = { workspace = true }
|
||||
# Calendar conversion (jiff); see AGENTS.md. Only civil-date math is used, no time zone.
|
||||
jiff = { workspace = true }
|
||||
|
||||
# Signed website catalog (all dependencies are on the licence allowlist).
|
||||
base64 = "0.22"
|
||||
ed25519-dalek = { version = "2.2", default-features = false, features = ["std", "fast", "pem"] }
|
||||
sha2 = "0.10"
|
||||
toml = { version = "=1.1.8", default-features = false, features = ["parse", "serde", "std"] }
|
||||
|
||||
[build-dependencies]
|
||||
serde = { workspace = true }
|
||||
toml = { version = "=1.1.8", default-features = false, features = ["parse", "serde", "std"] }
|
||||
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEASIYrY9GbHPPdZ/URfx25unSh+FHvcQoayxfVvyga4WY=
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,111 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::{env, error::Error, fmt::Write as _, fs, path::PathBuf};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Manifest {
|
||||
apps: Vec<App>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct App {
|
||||
id: String,
|
||||
name: String,
|
||||
tagline: String,
|
||||
color: [u8; 3],
|
||||
ink_light: [u8; 3],
|
||||
ink_dark: [u8; 3],
|
||||
repo: String,
|
||||
former_ids: Vec<String>,
|
||||
former_names: Vec<String>,
|
||||
kind: String,
|
||||
publisher: String,
|
||||
msi_publisher: Option<String>,
|
||||
bundle: Option<String>,
|
||||
former_bundles: Vec<String>,
|
||||
site: Option<String>,
|
||||
mac_team: Option<String>,
|
||||
mac_bundle_name: Option<String>,
|
||||
details: Option<Details>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Details {
|
||||
headline: String,
|
||||
about: String,
|
||||
platforms: String,
|
||||
#[serde(default)]
|
||||
features: Vec<Feature>,
|
||||
#[serde(default)]
|
||||
shots: Vec<Shot>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Feature {
|
||||
title: String,
|
||||
text: String,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Shot {
|
||||
key: String,
|
||||
caption: String,
|
||||
}
|
||||
fn optional(s: &Option<String>) -> String {
|
||||
s.as_ref().map_or_else(|| "None".to_owned(), |v| format!("Some({v:?})"))
|
||||
}
|
||||
fn slice(items: &[String]) -> String {
|
||||
format!("&{items:?}")
|
||||
}
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("cargo:rerun-if-changed=catalog.toml");
|
||||
let manifest: Manifest = toml::from_str(&fs::read_to_string("catalog.toml")?)?;
|
||||
let mut apps = format!("pub const SUITE: [CraftApp; {}] = [\n", manifest.apps.len());
|
||||
let count = manifest.apps.iter().filter(|a| a.details.is_some()).count();
|
||||
let mut details = format!("pub const DETAILS: [AppDetails; {count}] = [\n");
|
||||
for app in &manifest.apps {
|
||||
let kind = match app.kind.as_str() {
|
||||
"official" => "Official",
|
||||
"community" => "Community",
|
||||
_ => return Err(format!("unknown app kind for {}", app.id).into()),
|
||||
};
|
||||
writeln!(
|
||||
apps,
|
||||
"CraftApp {{ id: {:?}, name: {:?}, tagline: {:?}, color: {:?}, ink_light: {:?}, ink_dark: {:?}, repo: {:?}, former_ids: {}, former_names: {}, kind: AppKind::{kind}, publisher: {:?}, msi_publisher: {}, bundle: {}, former_bundles: {}, site: {}, mac_team: {}, mac_bundle_name: {} }},",
|
||||
app.id,
|
||||
app.name,
|
||||
app.tagline,
|
||||
app.color,
|
||||
app.ink_light,
|
||||
app.ink_dark,
|
||||
app.repo,
|
||||
slice(&app.former_ids),
|
||||
slice(&app.former_names),
|
||||
app.publisher,
|
||||
optional(&app.msi_publisher),
|
||||
optional(&app.bundle),
|
||||
slice(&app.former_bundles),
|
||||
optional(&app.site),
|
||||
optional(&app.mac_team),
|
||||
optional(&app.mac_bundle_name)
|
||||
)?;
|
||||
if let Some(d) = &app.details {
|
||||
write!(
|
||||
details,
|
||||
"AppDetails {{ id: {:?}, headline: {:?}, about: {:?}, platforms: {:?}, features: &[",
|
||||
app.id, d.headline, d.about, d.platforms
|
||||
)?;
|
||||
for f in &d.features {
|
||||
write!(details, "feature({:?}, {:?}),", f.title, f.text)?;
|
||||
}
|
||||
write!(details, "], shots: &[")?;
|
||||
for s in &d.shots {
|
||||
write!(details, "shot({:?}, {:?}),", s.key, s.caption)?;
|
||||
}
|
||||
writeln!(details, "] }},")?;
|
||||
}
|
||||
}
|
||||
apps.push_str("];\n");
|
||||
details.push_str("];\n");
|
||||
let out = PathBuf::from(env::var_os("OUT_DIR").ok_or("OUT_DIR missing")?);
|
||||
fs::write(out.join("catalog.rs"), apps)?;
|
||||
fs::write(out.join("details.rs"), details)?;
|
||||
Ok(())
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+7
-141
@@ -1,4 +1,4 @@
|
||||
//! The Craft App Suite: the eighteen apps the launcher knows about.
|
||||
//! The Craft App Suite: bundled data with a signed hosted startup snapshot.
|
||||
//!
|
||||
//! The list is data so a later version can fetch it from an API; [`SUITE`] is the built-in copy.
|
||||
//!
|
||||
@@ -114,7 +114,7 @@ impl CraftApp {
|
||||
}
|
||||
|
||||
pub fn by_id(id: &str) -> Option<&'static CraftApp> {
|
||||
SUITE.iter().find(|a| a.id == id)
|
||||
crate::hosted_catalog::apps().iter().find(|a| a.id == id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,145 +146,8 @@ const fn app(
|
||||
}
|
||||
}
|
||||
|
||||
/// The Craft App Suite, in display order matching getartcraft.com, then the community apps:
|
||||
pub const SUITE: [CraftApp; 19] = [
|
||||
app("photocraft", "PhotoCraft", "Image editing", [[0x2f, 0x7b, 0xf5], [0x1a, 0x5b, 0xc4], [0x7f, 0xb0, 0xff]], "storytold/photocraft"),
|
||||
app("vectorcraft", "VectorCraft", "Vector illustration", [[0xe8, 0x57, 0x3f], [0xb8, 0x3a, 0x24], [0xff, 0x8a, 0x70]], "storytold/vectorcraft"),
|
||||
app(
|
||||
"filmcraft",
|
||||
"FilmCraft",
|
||||
"Video editing, color and sound",
|
||||
[[0x8b, 0x5c, 0xf6], [0x6a, 0x3f, 0xd6], [0xb6, 0x9c, 0xff]],
|
||||
"storytold/filmcraft",
|
||||
),
|
||||
app(
|
||||
"lightcraft",
|
||||
"LightCraft",
|
||||
"Photo library and raw development",
|
||||
[[0xf2, 0xa5, 0x16], [0x8a, 0x58, 0x00], [0xff, 0xc1, 0x4d]],
|
||||
"storytold/lightcraft",
|
||||
),
|
||||
CraftApp {
|
||||
former_ids: &["printcraft"],
|
||||
former_names: &["PrintCraft"],
|
||||
..app(
|
||||
"pdfcraft",
|
||||
"PdfCraft",
|
||||
"Reading, organizing and protecting PDFs",
|
||||
[[0xe8, 0x20, 0x4f], [0xb7, 0x02, 0x28], [0xf2, 0x3a, 0x62]],
|
||||
"storytold/pdfcraft",
|
||||
)
|
||||
},
|
||||
app(
|
||||
"effectcraft",
|
||||
"EffectCraft",
|
||||
"Motion graphics and visual effects",
|
||||
[[0xe0, 0x36, 0x8f], [0xb0, 0x20, 0x6c], [0xff, 0x7a, 0xb8]],
|
||||
"storytold/effectcraft",
|
||||
),
|
||||
CraftApp {
|
||||
// Use the project repository until its getartcraft.com page is published.
|
||||
site: Some("https://github.com/storytold/anicraft"),
|
||||
..app("anicraft", "AniCraft", "2D vector animation", [[0xda, 0xc6, 0x04], [0x70, 0x65, 0x00], [0xe8, 0xd8, 0x4a]], "storytold/anicraft")
|
||||
},
|
||||
app(
|
||||
"designcraft",
|
||||
"DesignCraft",
|
||||
"Page layout and publishing",
|
||||
[[0x7b, 0xb5, 0x1c], [0x45, 0x70, 0x08], [0xa6, 0xe0, 0x4a]],
|
||||
"storytold/designcraft",
|
||||
),
|
||||
app(
|
||||
"figcraft",
|
||||
"FigCraft",
|
||||
"Interface design and prototyping",
|
||||
[[0x02, 0xda, 0x96], [0x04, 0x7a, 0x56], [0x4f, 0xe8, 0xb6]],
|
||||
"storytold/figcraft",
|
||||
),
|
||||
app(
|
||||
"soundcraft",
|
||||
"SoundCraft",
|
||||
"Recording, editing and mixing audio",
|
||||
[[0x1f, 0xa5, 0xc9], [0x0e, 0x72, 0x90], [0x5f, 0xd0, 0xee]],
|
||||
"storytold/soundcraft",
|
||||
),
|
||||
app("wordcraft", "WordCraft", "Writing and document design", [[0x3f, 0x5f, 0xe0], [0x2a, 0x44, 0xb8], [0x8e, 0xa2, 0xff]], "storytold/wordcraft"),
|
||||
app(
|
||||
"deckcraft",
|
||||
"DeckCraft",
|
||||
"Presentations and slide shows",
|
||||
[[0xf0, 0x7a, 0x1e], [0xa8, 0x4f, 0x0a], [0xff, 0xa0, 0x60]],
|
||||
"storytold/deckcraft",
|
||||
),
|
||||
app(
|
||||
"cadcraft",
|
||||
"CADCraft",
|
||||
"Computer-aided design and drafting",
|
||||
[[0x3e, 0xa6, 0xe8], [0x1a, 0x6f, 0xa8], [0x7c, 0xc8, 0xff]],
|
||||
"storytold/cadcraft",
|
||||
),
|
||||
app("gridcraft", "GridCraft", "Spreadsheets and data", [[0x1f, 0x9d, 0x55], [0x12, 0x70, 0x3a], [0x4f, 0xd6, 0x8a]], "storytold/gridcraft"),
|
||||
app(
|
||||
"texturecraft",
|
||||
"TextureCraft",
|
||||
"3D texture painting",
|
||||
[[0xc2, 0x67, 0x2b], [0x9c, 0x4a, 0x15], [0xe5, 0x8a, 0x4e]],
|
||||
"storytold/texturecraft",
|
||||
),
|
||||
CraftApp {
|
||||
// Use the project repository until its getartcraft.com page is published.
|
||||
site: Some("https://github.com/storytold/materialcraft"),
|
||||
..app(
|
||||
"materialcraft",
|
||||
"MaterialCraft",
|
||||
"Procedural material design",
|
||||
[[0x17, 0x8a, 0x9c], [0x10, 0x65, 0x73], [0x63, 0xc5, 0xd3]],
|
||||
"storytold/materialcraft",
|
||||
)
|
||||
},
|
||||
// The raven's tile blue, with its README's deep (#1659c4) and light (#74aaff) accents for text.
|
||||
app(
|
||||
"craft-anything",
|
||||
"Craft Anything",
|
||||
"Find out how any software works, then craft your own",
|
||||
[[0x4e, 0x7b, 0xfb], [0x16, 0x59, 0xc4], [0x74, 0xaa, 0xff]],
|
||||
"storytold/craft-anything",
|
||||
),
|
||||
CraftApp {
|
||||
kind: AppKind::Community,
|
||||
publisher: "Tangency Labs",
|
||||
msi_publisher: Some("SolidCraft contributors"),
|
||||
bundle: Some("io.tangencylabs.solidcraft"),
|
||||
former_bundles: &["ai.storyteller.solidcraft", "ai.storyteller.solvecraft"],
|
||||
site: Some("https://solidcraft.io"),
|
||||
// Signed by its own developer's team, not ArtCraft's (since 0.27, per its README).
|
||||
mac_team: Some("G5QA5U5X2S"),
|
||||
..app(
|
||||
"solidcraft",
|
||||
"SolidCraft",
|
||||
"Parametric 3D CAD",
|
||||
[[0x46, 0xa1, 0xfb], [0x16, 0x53, 0xae], [0x8c, 0xc4, 0xff]],
|
||||
"tangency-labs/solidcraft",
|
||||
)
|
||||
},
|
||||
CraftApp {
|
||||
kind: AppKind::Community,
|
||||
publisher: "UCS Care Group",
|
||||
msi_publisher: Some("MailCraft contributors"),
|
||||
bundle: Some("io.github.billsecond.mailcraft"),
|
||||
site: Some("https://mailcraft.work"),
|
||||
// ponytail: its macOS builds are unsigned (per its README), so the launcher opens a copy
|
||||
// that's there but installs nothing; set its Developer ID team here once it signs them.
|
||||
mac_team: None,
|
||||
..app(
|
||||
"mailcraft",
|
||||
"MailCraft",
|
||||
"Mail, calendar and contacts",
|
||||
[[0x0f, 0x68, 0xf0], [0x06, 0x34, 0xc4], [0x8f, 0xbf, 0xff]],
|
||||
"UCS-Care-Group/mailcraft",
|
||||
)
|
||||
},
|
||||
];
|
||||
// The bundled suite, in website display order, then the approved community apps.
|
||||
include!(concat!(env!("OUT_DIR"), "/catalog.rs"));
|
||||
|
||||
/// The Apple Developer team that signs every official Craft App and ArtCraft Launcher (Learning
|
||||
/// Machines LLC): the macOS side of the Windows publisher check.
|
||||
@@ -330,6 +193,9 @@ pub const LAUNCHER_ID: &str = "artcraft-launcher";
|
||||
/// A Craft App's 128 px icon (PNG), as copied from its repo into `assets/app-icons`: the UI
|
||||
/// draws it, and the Linux install puts it in the desktop menu.
|
||||
pub fn app_icon_png(id: &str) -> Option<&'static [u8]> {
|
||||
if let Some(icon) = crate::hosted_catalog::icon(id) {
|
||||
return Some(icon);
|
||||
}
|
||||
Some(match id {
|
||||
"artcraft" => include_bytes!("../../../assets/app-icons/artcraft.png"),
|
||||
"photocraft" => include_bytes!("../../../assets/app-icons/photocraft.png"),
|
||||
|
||||
+3
-451
@@ -1,7 +1,6 @@
|
||||
//! Hand-written product pages: what each app is, in the launcher's own words.
|
||||
//!
|
||||
//! The text is compiled in, so it works offline and on the web, and nothing from the network is
|
||||
//! ever shown as page copy. What changes with every release (version, date, size, notes) comes
|
||||
//! Bundled text works offline and on the web; a verified hosted snapshot may replace it. What changes with every release (version, date, size, notes) comes
|
||||
//! from the GitHub release instead. An app without an entry here simply has no details page.
|
||||
//!
|
||||
//! The pictures are not compiled in: they are fetched when a page is opened (see
|
||||
@@ -136,454 +135,7 @@ pub fn screenshot_within_budget(bytes: &[u8]) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where every Craft App runs (getartcraft.com lists the same for each of them).
|
||||
const PLATFORMS: &str = "macOS, Windows, Linux, FreeBSD, web";
|
||||
|
||||
pub const DETAILS: [AppDetails; 19] = [
|
||||
AppDetails {
|
||||
id: "photocraft",
|
||||
headline: "The image editor you already know how to use.",
|
||||
about: "Layers, masks, adjustment layers, layer styles, type, vectors and brushes in a native app. Open source, offline, and yours.\n\n\
|
||||
PhotoCraft keeps the menus, shortcuts and panels your hands already know, so there is \
|
||||
nothing to relearn.",
|
||||
features: &[
|
||||
feature("Native GPU canvas", "No Electron and no web view: a fast native compositor."),
|
||||
feature("Real layered files", "Opens and saves layered PSD and PSB documents."),
|
||||
feature("Non-destructive editing", "Adjustment layers, live-preview filters, smart objects and layer styles."),
|
||||
feature("On-device selection", "Subject and object selection and mask refinement run locally."),
|
||||
feature("Serious color", "8-, 16- and 32-bit RGB, CMYK, Lab and Grayscale, with ICC color management and soft proofing."),
|
||||
],
|
||||
shots: &[
|
||||
shot("demo", "Curves and type layers"),
|
||||
shot("adjustments", "Levels with a live histogram"),
|
||||
shot("layer-styles", "Layer styles on live type"),
|
||||
shot("masks", "Selections and masked adjustments"),
|
||||
],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "vectorcraft",
|
||||
headline: "Vector illustration, with familiar tools and editable effects.",
|
||||
about: "A native vector illustration app with the pen, panels and shortcuts illustrators expect. \
|
||||
Open source, and it also runs in a browser.",
|
||||
features: &[
|
||||
feature(
|
||||
"The workflow you know",
|
||||
"Pen, direct selection, shape booleans, snapping guides and an appearance panel, laid out the way you expect.",
|
||||
),
|
||||
feature("Genuinely fast", "Drawings with thousands of shapes stay responsive on a retina display."),
|
||||
feature(
|
||||
"Booleans that don't fail",
|
||||
"Shape booleans work on the exact curves, so there is no \"cannot perform operation\", and undo is unlimited.",
|
||||
),
|
||||
feature("Live, editable effects", "Blends, envelope distort, gradient mesh, repeats, glows and drop shadows all stay editable."),
|
||||
feature("Image tracing", "Turn raster images into clean vector paths, with presets for the common cases."),
|
||||
feature("Open formats", "Native JSON documents, SVG and PDF import and export, and PNG, JPEG and WebP output."),
|
||||
],
|
||||
shots: &[
|
||||
shot("neon", "The Neon Drive poster"),
|
||||
shot("ribbons", "Live blends"),
|
||||
shot("sheet", "A feature sheet and the Layers panel"),
|
||||
shot("bezier", "Pathfinder and exact booleans"),
|
||||
],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "filmcraft",
|
||||
headline: "Professional video editing, rebuilt from scratch.",
|
||||
about: "A native video editor with source and program monitors, a real timeline and \
|
||||
every trim mode.",
|
||||
features: &[
|
||||
feature("A timeline you already know", "Source and program monitors, three-point editing, every trim mode and J/K/L trimming."),
|
||||
feature("Frame-exact time", "An integer timebase keeps 23.976 and 29.97 drop-frame footage exact, with no drift."),
|
||||
feature("Its own codecs", "No FFmpeg inside: native support for H.264, HEVC, ProRes, VP9, AAC and Opus."),
|
||||
feature("Color grading", "Curves, color wheels, HSL secondaries, LUTs and HDR and log workflows, with scopes to check the result."),
|
||||
feature(
|
||||
"Effects and keyframes",
|
||||
"Video effects and transitions, keyframes with value and velocity graphs, and a linear-light GPU compositor.",
|
||||
),
|
||||
feature("Broadcast-ready audio", "EBU R128 loudness meters, a mixer with automation and native audio effects."),
|
||||
],
|
||||
shots: &[
|
||||
shot("color", "The Color workspace, with scopes"),
|
||||
shot("assembly", "The Assembly workspace"),
|
||||
shot("keyframes", "Keyframes in Effect Controls"),
|
||||
],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "lightcraft",
|
||||
headline: "Your photos. Your pixels. Your machine.",
|
||||
about: "A fast photo library and non-destructive raw developer. \
|
||||
No account, no cloud, no telemetry and no subscription.",
|
||||
features: &[
|
||||
feature("Non-destructive by design", "A wide-gamut, 32-bit float pipeline that never touches your originals."),
|
||||
feature("Every control you reach for", "Light, color, effects, tone curve, a color mixer, color grading wheels and built-in presets."),
|
||||
feature("Precise masking", "Brush, gradient and range masks, plus sky, subject and background masks."),
|
||||
feature("Native raw decoding", "Support for the main camera raw formats: DNG, CR2, ARW, NEF, RAF, RW2, PEF and ORF."),
|
||||
feature("A library that keeps up", "Albums, ratings, flags and search, with grids that stay smooth on large catalogs."),
|
||||
feature("Instant feedback", "The GPU pipeline updates the preview as you move a slider, even on large raw files."),
|
||||
],
|
||||
shots: &[
|
||||
shot("hero", "The Edit view"),
|
||||
shot("curve", "The tone curve"),
|
||||
shot("grading", "Color grading wheels"),
|
||||
shot("masking", "A radial mask over a sky mask"),
|
||||
],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "pdfcraft",
|
||||
headline: "The open-source PDF workbench.",
|
||||
about: "Read, organize, combine, split and secure PDFs in a fast, native app. No account, no telemetry and no cloud.",
|
||||
features: &[
|
||||
feature("Faithful rendering", "World scripts, vertical Japanese, color emoji and transparency."),
|
||||
feature("Search as you type", "Instant find, and text selection that follows the document's real reading order."),
|
||||
feature("Organize like cards", "Rotate, delete, insert and reorder pages, with deep undo behind every change."),
|
||||
feature("Combine, extract, split", "Assemble and break apart documents while keeping links, form fields, layers and bookmarks intact."),
|
||||
feature("Fearless saves", "Incremental, atomic saves with autosave and crash recovery."),
|
||||
feature("Built-in security", "Opens files from RC4 to AES-256 encryption and honors the author's permissions."),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "effectcraft",
|
||||
headline: "Motion graphics and visual effects.",
|
||||
about: "A native compositor with compositions, layers, keyframes, effects, expressions, 3D cameras and \
|
||||
lights, and a render queue. Young, moving fast, and already usable.",
|
||||
features: &[
|
||||
feature(
|
||||
"Animate the way you know",
|
||||
"Familiar panels and keyframes (linear, bezier, hold and eased), with a graph editor for value and speed curves.",
|
||||
),
|
||||
feature(
|
||||
"Layers of every kind",
|
||||
"Solids, shapes, text, footage, nested compositions, nulls and adjustment layers, with parenting, track mattes and blend modes.",
|
||||
),
|
||||
feature(
|
||||
"A large effects library",
|
||||
"Blur, color correction, distortion, generators, keying, particles and simulation, stylize and time effects.",
|
||||
),
|
||||
feature("Real 3D", "3D layers with cameras, depth of field, and lights that cast soft ray-traced shadows."),
|
||||
feature("Expressions", "JavaScript expressions with wiggle, loops and layer references, edited inline."),
|
||||
feature("Export anywhere", "H.264 and ProRes with alpha, PNG, TIFF and EXR sequences, GIF, and Lottie import and export."),
|
||||
],
|
||||
shots: &[
|
||||
shot("hero", "An animated composition"),
|
||||
shot("graph", "The Graph Editor"),
|
||||
shot("effects", "Particles and Effect Controls"),
|
||||
shot("3d", "3D layers with cameras and lights"),
|
||||
],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "anicraft",
|
||||
headline: "Vector animation on a timeline you know.",
|
||||
about: "Open-source 2D vector animation, built in pure Rust.",
|
||||
features: &[
|
||||
feature(
|
||||
"Familiar by design",
|
||||
"Stage, tools, timeline, layers, keyframes, Properties and Library sit where animators expect them, with onion skinning for in-betweening.",
|
||||
),
|
||||
feature(
|
||||
"Tweens that ease",
|
||||
"Classic tweens with eight easing presets and custom ease curves, plus shape tweens that morph one vector contour into another.",
|
||||
),
|
||||
feature(
|
||||
"Symbols and scenes",
|
||||
"Graphic symbols and movie clips with nested timelines and loop modes, mask and guide layers, filters, blend modes and scenes.",
|
||||
),
|
||||
feature(
|
||||
"Real vector tools",
|
||||
"Pen, Pencil with curve fitting, shapes, text, Paint Bucket and Ink Bottle, with Bézier anchors and handles you edit point by point.",
|
||||
),
|
||||
feature(
|
||||
"Open formats",
|
||||
"Opens .fla and .xfl documents and imports SVG. Exports PNG sequences, GIF, SVG frames, sprite sheets, Lottie, and WebM or MP4 through your own FFmpeg.",
|
||||
),
|
||||
feature(
|
||||
"Agent-ready",
|
||||
"Every action is an engine command, so the CLI, a JSON-lines channel and an MCP server can draw, animate and export the way a person does.",
|
||||
),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "designcraft",
|
||||
headline: "Page layout and publishing.",
|
||||
about: "A native layout app with spreads, parent pages, threaded stories, styles, swatches, text wrap and \
|
||||
a paragraph composer. No subscription, no license server and no telemetry.",
|
||||
features: &[
|
||||
feature("The layout tools you know", "Spreads and parent pages, frames and threaded stories, with paragraph and character styles."),
|
||||
feature(
|
||||
"Beautiful type",
|
||||
"A Knuth–Plass paragraph composer, dictionary hyphenation, optical margin alignment and baseline grids, with line breaks that match on screen and in PDF.",
|
||||
),
|
||||
feature("Print-ready PDF", "Real selectable text with embedded fonts, CMYK and spot colors, bleed, crop marks and PDF/A output."),
|
||||
feature("Fast", "Multithreaded rendering, instant undo and cached text composition."),
|
||||
feature("Open formats", "A documented native format, PNG export and layout interchange import and export."),
|
||||
feature("Built for automation", "Every menu item, tool, panel and dialog can be driven over a JSON control channel and an MCP server."),
|
||||
],
|
||||
shots: &[shot("spread", "A magazine spread with a threaded story")],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "wordcraft",
|
||||
headline: "The familiar word processor, native and offline.",
|
||||
about: "A word processor with the ribbon, shortcuts and behavior you already know. \
|
||||
Open source, and built from public specifications.",
|
||||
features: &[
|
||||
feature(
|
||||
"Familiar",
|
||||
"Ribbon tabs and groups, a live Styles gallery and the editing behavior you expect, from list continuation to Format Painter.",
|
||||
),
|
||||
feature(
|
||||
"Your files",
|
||||
"Opens and saves .docx, and also .odt, .rtf, .html, .md, .tex and .txt. Opens older .doc files and exports PDF with real, selectable text.",
|
||||
),
|
||||
feature("Fast", "Paragraph layout is cached, so typing stays responsive even in long documents."),
|
||||
feature("Private", "Spelling, grammar and everything else work offline."),
|
||||
feature("Everywhere", "Work on macOS, Windows, Linux, BSD and the web."),
|
||||
feature(
|
||||
"Built for agents",
|
||||
"Every action is a command, driven from the ribbon, shortcuts, a command-line tool, a JSON control channel or an MCP server.",
|
||||
),
|
||||
],
|
||||
shots: &[
|
||||
shot("hero", "The Home tab and the Navigation pane"),
|
||||
shot("review", "Track Changes and comments"),
|
||||
shot("design", "The Design tab"),
|
||||
shot("layout", "The Layout tab"),
|
||||
],
|
||||
platforms: "macOS, Windows, Linux, BSD, web",
|
||||
},
|
||||
AppDetails {
|
||||
id: "deckcraft",
|
||||
headline: "Create slides, tell stories and present.",
|
||||
about: "A presentation app with slide masters, shapes, animations and a presenter view. \
|
||||
In alpha, heading for beta.",
|
||||
features: &[
|
||||
feature("Make decks", "Slide masters and layouts with placeholders that inherit formatting, themes, sections, notes and comments."),
|
||||
feature(
|
||||
"Draw",
|
||||
"Preset shapes with adjust handles, connectors that stay glued to shapes, freeform tools, merged shapes, gradients, shadows and glow.",
|
||||
),
|
||||
feature("Write", "In-place text editing with full font and paragraph formatting, bullets and numbering, columns and autofit."),
|
||||
feature("Add content", "Pictures with crop and corrections, styled tables, charts, audio and video."),
|
||||
feature(
|
||||
"Present",
|
||||
"Transitions including Morph, animations and motion paths, a full-screen slide show, presenter view and rehearsed timings.",
|
||||
),
|
||||
feature("Exchange files", "Opens and saves .pptx presentation files and exports PDF (slides, notes pages and handouts), PNG and JPEG."),
|
||||
],
|
||||
shots: &[
|
||||
shot("editor", "Editing a slide, with sections and notes"),
|
||||
shot("shape", "The Shape Format tab"),
|
||||
shot("sorter", "The slide sorter"),
|
||||
shot("format", "The Format Shape pane"),
|
||||
],
|
||||
platforms: "macOS, Windows, Linux, BSD, web",
|
||||
},
|
||||
AppDetails {
|
||||
id: "gridcraft",
|
||||
headline: "Spreadsheets you already know how to use.",
|
||||
about: "A spreadsheet with the ribbon, formula bar, sheet tabs and shortcuts you know. No subscription, no license server and no telemetry.",
|
||||
features: &[
|
||||
feature(
|
||||
"Familiar",
|
||||
"The ribbon, formula bar, Name Box, fill handle, point-mode formulas, Format Cells, Paste Special, conditional formatting, tables and charts.",
|
||||
),
|
||||
feature(
|
||||
"Compatible",
|
||||
"XLSX is the native format, with formulas, tables, conditional formats, charts, pivot tables and print settings round-tripping. CSV and TSV too.",
|
||||
),
|
||||
feature(
|
||||
"Capable",
|
||||
"A dependency-graph calculation engine with dynamic arrays, LET and LAMBDA, structured table references, sort, AutoFilter and Flash Fill.",
|
||||
),
|
||||
feature("Fast", "Copy-on-write workbooks, incremental recalculation and a grid that only lays out what is on screen."),
|
||||
feature(
|
||||
"Agent-native",
|
||||
"Every ribbon button, menu item, dialog and keystroke is a command, available over a JSON control channel, an MCP server or the CLI.",
|
||||
),
|
||||
feature("Everywhere", "Work on the desktop and the web."),
|
||||
],
|
||||
shots: &[
|
||||
shot("hero", "A quarterly sales dashboard"),
|
||||
shot("budget", "A household budget"),
|
||||
shot("pivot", "A pivot table"),
|
||||
shot("chart", "Formatting a chart"),
|
||||
],
|
||||
platforms: "macOS, Windows, Linux, BSD, web",
|
||||
},
|
||||
AppDetails {
|
||||
id: "cadcraft",
|
||||
headline: "Computer-aided drafting, with a familiar workflow.",
|
||||
about: "A drafting app with the command line, object snaps and workflow that drafters already know. Free, with no \
|
||||
account and no subscription. In early, fast development.",
|
||||
features: &[
|
||||
feature(
|
||||
"The workflow you know",
|
||||
"Type L, click two points, type @5<45 and press Enter. Prompts with clickable keywords, polar tracking, direct distance entry and grips work the way drafting habit expects.",
|
||||
),
|
||||
feature(
|
||||
"Open files",
|
||||
"Reads and writes DXF natively (R12 through 2018) and opens and saves DWG (R13 through 2018). Exports SVG and PNG.",
|
||||
),
|
||||
feature("Fast and native", "A responsive, native drafting workspace."),
|
||||
feature(
|
||||
"A full drafting toolset",
|
||||
"Draw, modify, dimension, hatch and block commands, layers with a properties manager, paper-space layouts and PDF plotting.",
|
||||
),
|
||||
feature("Built for agents", "Every menu item, tool and prompt is a command, available over MCP, a JSON control channel or the CLI."),
|
||||
],
|
||||
shots: &[shot("apartment", "An apartment floor plan"), shot("bracket", "A mechanical bracket drawing"), shot("layout", "A layout sheet")],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "soundcraft",
|
||||
headline: "Record, edit and mix your audio.",
|
||||
about: "A digital audio workstation that follows the workflow audio engineers already know: an Edit window for \
|
||||
arranging and editing, and a Mix window for balancing. Pre-alpha.",
|
||||
features: &[
|
||||
feature(
|
||||
"Editing",
|
||||
"Shuffle, Slip, Spot and Grid modes, Smart, Grabber, Trim and other tools, fades and crossfades, playlists with comping lanes and clip gain.",
|
||||
),
|
||||
feature(
|
||||
"Mixing",
|
||||
"Faders and pans with automation, sends, busses, aux inputs, VCA masters, routing folders and automatic plugin delay compensation.",
|
||||
),
|
||||
feature(
|
||||
"Automation",
|
||||
"Volume, pan, mute, send and every plugin parameter, with Write, Touch, Latch and Trim passes recorded live from the faders.",
|
||||
),
|
||||
feature(
|
||||
"Plugins",
|
||||
"EQ, dynamics, reverbs, modulation effects, a subtractive synth and a drum synth, all original, and CLAP plugins load too.",
|
||||
),
|
||||
],
|
||||
shots: &[
|
||||
shot("edit", "The Edit window with a nine-track session"),
|
||||
shot("mix", "The Mix window"),
|
||||
shot("automation", "Automation and memory locations"),
|
||||
shot("score", "The Score Editor"),
|
||||
],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "figcraft",
|
||||
headline: "Interface design and prototyping.",
|
||||
about: "Design screens, components and prototypes in a native app that opens instantly and works offline, \
|
||||
with no account and no telemetry. Early alpha.",
|
||||
features: &[
|
||||
feature(
|
||||
"Auto layout",
|
||||
"Rows, columns, wrap and grids with padding, gaps and Hug, Fill or Fixed sizing, plus constraints and layout grids.",
|
||||
),
|
||||
feature(
|
||||
"Components",
|
||||
"Instances with overrides, variants and properties, styles, and variables with modes bound to fills, strokes and effects.",
|
||||
),
|
||||
feature("Vectors", "Real vector networks, the pen and pencil, the shape builder, editable booleans and variable width strokes."),
|
||||
feature(
|
||||
"Prototypes",
|
||||
"Connections, triggers and animated transitions, variables with conditionals, flows and a presentation view with device frames.",
|
||||
),
|
||||
feature(
|
||||
"Hand off",
|
||||
"Inspect mode with measurements, annotations, ready-for-dev status, and code for CSS, HTML, React, SwiftUI and Compose.",
|
||||
),
|
||||
feature(
|
||||
"Your files",
|
||||
"Plain .figcraft files on your own disk. SVG, PNG, JPEG, WebP and PDF in and out, and .fig files open, best effort.",
|
||||
),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "texturecraft",
|
||||
headline: "Paint textures on 3D models.",
|
||||
about: "Paint materials on 3D models and export textures.",
|
||||
features: &[
|
||||
feature("Materials", "Paint materials on 3D models and export textures."),
|
||||
feature("Mesh maps", "Bake mesh maps and use smart materials."),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "materialcraft",
|
||||
headline: "Build materials with node graphs.",
|
||||
about: "Create tileable PBR materials and export texture maps.",
|
||||
features: &[
|
||||
feature("Node graphs", "Combine noises, patterns and filters."),
|
||||
feature("Live previews", "Preview materials in 2D and on 3D models."),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "craft-anything",
|
||||
headline: "See how any website, app or game works, then build your own.",
|
||||
about: "Point it at a target and say what you want. It studies the original with real inspection tools, has a \
|
||||
coding agent build a new project in the stack you ask for, checks the result against the original and \
|
||||
refines it. Open source and clean-room.",
|
||||
features: &[
|
||||
feature(
|
||||
"Study anything",
|
||||
"Websites, desktop apps, phone apps, games and files: find out how they're built, with the evidence behind every answer.",
|
||||
),
|
||||
feature("Build your own", "Say what you want and a coding agent builds a new project in the language or engine you name."),
|
||||
feature(
|
||||
"Checked, not guessed",
|
||||
"Every build is compared with the original, at three screen widths for a page, and refined until it's close.",
|
||||
),
|
||||
feature("Agent-ready", "Every tool is a CLI command and an MCP tool, and no AI is needed just to inspect."),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "solidcraft",
|
||||
headline: "Parametric 3D CAD, with editable sketches and solids.",
|
||||
about: "A parametric solid modeller by Tangency Labs. Sketch, constrain and build solids on an editable feature \
|
||||
timeline: change a dimension and the model rebuilds. Early, but usable for simple parts. Open source, \
|
||||
and it can be driven by AI agents through its MCP server.",
|
||||
features: &[
|
||||
feature(
|
||||
"Sketches and constraints",
|
||||
"Lines, arcs, splines and text, solved by SolidCraft's own constraint solver, with parameter-driven dimensions.",
|
||||
),
|
||||
feature("Features", "Extrude, revolve, sweep, loft, fillet, chamfer, shell, holes, threads and patterns on a parametric timeline."),
|
||||
feature("Files", "STEP, IGES, 3MF, STL, OBJ and glTF in and out where supported, and .sc designs."),
|
||||
feature("Desktop, web and agents", "A desktop app, a browser app, a headless CLI and an MCP server, all running the same commands."),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
AppDetails {
|
||||
id: "mailcraft",
|
||||
headline: "Mail, calendar, contacts and tasks, in one native app.",
|
||||
about: "An open-source mail program by UCS Care Group, written from scratch in Rust: the folder pane, message \
|
||||
list and reading pane people already know, with a calendar, people and to-dos. Works with Microsoft 365, \
|
||||
Outlook.com and IMAP. In public beta, and it can be driven by AI agents through its MCP server.",
|
||||
features: &[
|
||||
feature(
|
||||
"Mail",
|
||||
"Conversations, flags, categories, rules, search with a query language, and HTML mail shown without running anything in it.",
|
||||
),
|
||||
feature("Calendar", "Day, week and month views, recurring meetings, invitations and reminders, kept in step with Microsoft 365."),
|
||||
feature("Files", ".eml, .mbox, .ics and .vcf in and out, and the mail and contacts of an Outlook .pst file in."),
|
||||
feature("Desktop, web and agents", "A desktop app, a browser app, a CLI and an MCP server, all running the same commands."),
|
||||
],
|
||||
shots: &[],
|
||||
platforms: PLATFORMS,
|
||||
},
|
||||
];
|
||||
include!(concat!(env!("OUT_DIR"), "/details.rs"));
|
||||
|
||||
impl AppDetails {
|
||||
/// Where the picture `key` of this app is published, or `None` if the page has no such picture.
|
||||
@@ -593,7 +145,7 @@ impl AppDetails {
|
||||
}
|
||||
|
||||
pub fn by_id(id: &str) -> Option<&'static AppDetails> {
|
||||
DETAILS.iter().find(|d| d.id == id)
|
||||
crate::hosted_catalog::details(id).or_else(|| DETAILS.iter().find(|d| d.id == id))
|
||||
}
|
||||
|
||||
pub fn paragraphs(&self) -> impl Iterator<Item = &'static str> {
|
||||
|
||||
@@ -0,0 +1,498 @@
|
||||
//! Signed website catalog. The bundled catalog remains available without any network.
|
||||
//!
|
||||
//! One bounded, immutable snapshot is activated per process. Its strings are interned only
|
||||
//! inside `OnceLock::get_or_init`, preserving the existing static app handles used by jobs.
|
||||
//! No repeated refresh can leak another snapshot or change a running install's identity.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use base64::{Engine, engine::general_purpose::STANDARD};
|
||||
use ed25519_dalek::{Signature, VerifyingKey, pkcs8::DecodePublicKey};
|
||||
use serde::Deserialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::catalog::{ARTCRAFT_TEAM_ID, AppKind, CraftApp, SUITE};
|
||||
use crate::details::{AppDetails, Feature, Shot};
|
||||
|
||||
pub const CATALOG_URL: &str = "https://getartcraft.com/launcher-catalog.toml";
|
||||
pub const SIGNATURE_URL: &str = "https://getartcraft.com/launcher-catalog.toml.sig";
|
||||
pub const PUBLIC_KEY_PEM: &str = include_str!("../assets/launcher-catalog-public-key.pem");
|
||||
pub const MAX_CATALOG_BYTES: usize = 1 << 20;
|
||||
pub const MAX_SIGNATURE_BYTES: usize = 128;
|
||||
pub const MAX_ICON_BYTES: usize = 256 << 10;
|
||||
const MAX_APPS: usize = 64;
|
||||
|
||||
static ACTIVE: OnceLock<Snapshot> = OnceLock::new();
|
||||
|
||||
struct Snapshot {
|
||||
apps: Vec<CraftApp>,
|
||||
details: Vec<AppDetails>,
|
||||
metadata: HashMap<String, Metadata>,
|
||||
icons: HashMap<String, Vec<u8>>,
|
||||
}
|
||||
|
||||
/// Only desktop metadata consumed by existing integration. Package identities stay pinned.
|
||||
pub struct Metadata {
|
||||
pub desktop_categories: String,
|
||||
pub startup_wm_class: String,
|
||||
pub icon_sha256: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Document {
|
||||
apps: Vec<toml::Value>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Record {
|
||||
id: String,
|
||||
name: String,
|
||||
tagline: String,
|
||||
color: [u8; 3],
|
||||
ink_light: [u8; 3],
|
||||
ink_dark: [u8; 3],
|
||||
repo: String,
|
||||
#[serde(default)]
|
||||
former_ids: Vec<String>,
|
||||
#[serde(default)]
|
||||
former_names: Vec<String>,
|
||||
#[serde(default)]
|
||||
former_bundles: Vec<String>,
|
||||
kind: String,
|
||||
publisher: String,
|
||||
msi_publisher: Option<String>,
|
||||
bundle: Option<String>,
|
||||
site: Option<String>,
|
||||
mac_team: Option<String>,
|
||||
mac_bundle_name: Option<String>,
|
||||
icon_url: String,
|
||||
icon_sha256: String,
|
||||
desktop_categories: Vec<String>,
|
||||
startup_wm_class: String,
|
||||
details: Option<Page>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Page {
|
||||
headline: String,
|
||||
about: String,
|
||||
platforms: String,
|
||||
#[serde(default)]
|
||||
features: Vec<PageFeature>,
|
||||
#[serde(default)]
|
||||
shots: Vec<PageShot>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct PageFeature {
|
||||
title: String,
|
||||
text: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct PageShot {
|
||||
key: String,
|
||||
caption: String,
|
||||
url: String,
|
||||
}
|
||||
|
||||
/// A verified, policy-checked catalog, not yet made visible to running jobs.
|
||||
pub struct VerifiedCatalog {
|
||||
records: Vec<Record>,
|
||||
pub rejected_entries: usize,
|
||||
}
|
||||
|
||||
impl VerifiedCatalog {
|
||||
/// Signature verification always precedes parsing; even cached bytes are reverified.
|
||||
pub fn verify(bytes: &[u8], signature: &[u8]) -> Result<Self, String> {
|
||||
let key = VerifyingKey::from_public_key_pem(PUBLIC_KEY_PEM).map_err(|_| "invalid compiled catalog key")?;
|
||||
Self::verify_with_key(bytes, signature, &key)
|
||||
}
|
||||
|
||||
fn verify_with_key(bytes: &[u8], signature: &[u8], key: &VerifyingKey) -> Result<Self, String> {
|
||||
if bytes.len() > MAX_CATALOG_BYTES || signature.len() > MAX_SIGNATURE_BYTES {
|
||||
return Err("catalog or signature exceeds its byte limit".into());
|
||||
}
|
||||
let encoded = std::str::from_utf8(signature).map_err(|_| "signature is not UTF-8")?.trim();
|
||||
let decoded = STANDARD.decode(encoded).map_err(|_| "invalid base64 catalog signature")?;
|
||||
let signature = Signature::from_slice(&decoded).map_err(|_| "invalid Ed25519 signature length")?;
|
||||
key.verify_strict(bytes, &signature).map_err(|_| "catalog signature does not match the pinned key")?;
|
||||
Self::parse(bytes)
|
||||
}
|
||||
|
||||
fn parse(bytes: &[u8]) -> Result<Self, String> {
|
||||
let text = std::str::from_utf8(bytes).map_err(|_| "catalog is not UTF-8")?;
|
||||
let document: Document = toml::from_str(text).map_err(|e| format!("invalid catalog TOML: {e}"))?;
|
||||
if document.apps.is_empty() || document.apps.len() > MAX_APPS {
|
||||
return Err("catalog app count is outside the limit".into());
|
||||
}
|
||||
let mut records = Vec::new();
|
||||
let mut seen = HashSet::new();
|
||||
let mut rejected_entries = 0;
|
||||
for value in document.apps {
|
||||
let record: Record = match value.try_into() {
|
||||
Ok(record) => record,
|
||||
Err(_) => {
|
||||
rejected_entries += 1;
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if !valid_record(&record) || !seen.insert(record.id.clone()) {
|
||||
rejected_entries += 1;
|
||||
continue;
|
||||
}
|
||||
records.push(record);
|
||||
}
|
||||
if records.is_empty() {
|
||||
return Err("catalog has no acceptable apps".into());
|
||||
}
|
||||
Ok(Self { records, rejected_entries })
|
||||
}
|
||||
|
||||
/// URLs/hashes are already validated. Fetchers may use a cached or bundled matching icon.
|
||||
pub fn icons(&self) -> impl Iterator<Item = (&str, &str, &str)> {
|
||||
self.records.iter().map(|r| (r.id.as_str(), r.icon_url.as_str(), r.icon_sha256.as_str()))
|
||||
}
|
||||
|
||||
/// Publishes once per process; omitted bundled apps stay manageable after a remote removal.
|
||||
pub fn activate(self, icons: HashMap<String, Vec<u8>>) {
|
||||
ACTIVE.get_or_init(|| self.into_snapshot(icons));
|
||||
}
|
||||
|
||||
fn into_snapshot(self, icons: HashMap<String, Vec<u8>>) -> Snapshot {
|
||||
let mut apps = Vec::new();
|
||||
let mut details = Vec::new();
|
||||
let mut metadata = HashMap::new();
|
||||
let mut kept_icons = HashMap::new();
|
||||
for record in self.records {
|
||||
if let Some(icon) = icons.get(&record.id).filter(|b| valid_icon(b, &record.icon_sha256)) {
|
||||
kept_icons.insert(record.id.clone(), icon.clone());
|
||||
}
|
||||
metadata.insert(
|
||||
record.id.clone(),
|
||||
Metadata {
|
||||
desktop_categories: record.desktop_categories.join(";") + ";",
|
||||
startup_wm_class: record.startup_wm_class.clone(),
|
||||
icon_sha256: record.icon_sha256.clone(),
|
||||
},
|
||||
);
|
||||
if let Some(page) = record.details {
|
||||
details.push(AppDetails {
|
||||
id: intern(record.id.clone()),
|
||||
headline: intern(page.headline),
|
||||
about: intern(page.about),
|
||||
platforms: intern(page.platforms),
|
||||
features: Box::leak(
|
||||
page.features
|
||||
.into_iter()
|
||||
.map(|f| Feature { title: intern(f.title), text: intern(f.text) })
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice(),
|
||||
),
|
||||
shots: Box::leak(
|
||||
page.shots
|
||||
.into_iter()
|
||||
.map(|s| Shot { key: intern(s.key), caption: intern(s.caption) })
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice(),
|
||||
),
|
||||
});
|
||||
}
|
||||
apps.push(CraftApp {
|
||||
id: intern(record.id),
|
||||
name: intern(record.name),
|
||||
tagline: intern(record.tagline),
|
||||
color: record.color,
|
||||
ink_light: record.ink_light,
|
||||
ink_dark: record.ink_dark,
|
||||
repo: intern(record.repo),
|
||||
former_ids: intern_list(record.former_ids),
|
||||
former_names: intern_list(record.former_names),
|
||||
former_bundles: intern_list(record.former_bundles),
|
||||
mac_bundle_name: record.mac_bundle_name.map(intern),
|
||||
kind: if record.kind == "official" { AppKind::Official } else { AppKind::Community },
|
||||
publisher: intern(record.publisher),
|
||||
msi_publisher: record.msi_publisher.map(intern),
|
||||
bundle: record.bundle.map(intern),
|
||||
site: record.site.map(intern),
|
||||
mac_team: record.mac_team.map(intern),
|
||||
});
|
||||
}
|
||||
for app in &SUITE {
|
||||
if !apps.iter().any(|a| a.id == app.id) {
|
||||
apps.push(*app);
|
||||
}
|
||||
}
|
||||
Snapshot { apps, details, metadata, icons: kept_icons }
|
||||
}
|
||||
}
|
||||
|
||||
/// Runtime catalog, with the compiled suite as the offline/invalid-response fallback.
|
||||
pub fn apps() -> &'static [CraftApp] {
|
||||
ACTIVE.get().map_or(&SUITE, |s| s.apps.as_slice())
|
||||
}
|
||||
pub fn details(id: &str) -> Option<&'static AppDetails> {
|
||||
ACTIVE.get()?.details.iter().find(|p| p.id == id)
|
||||
}
|
||||
pub fn metadata(id: &str) -> Option<&'static Metadata> {
|
||||
ACTIVE.get()?.metadata.get(id)
|
||||
}
|
||||
pub fn icon(id: &str) -> Option<&'static [u8]> {
|
||||
ACTIVE.get()?.icons.get(id).map(Vec::as_slice)
|
||||
}
|
||||
|
||||
/// Bound decoded allocation before handing an authenticated PNG to an image loader.
|
||||
pub fn valid_icon(bytes: &[u8], digest: &str) -> bool {
|
||||
if bytes.len() > MAX_ICON_BYTES || bytes.get(..8) != Some(b"\x89PNG\r\n\x1a\n") || bytes.get(12..16) != Some(b"IHDR") {
|
||||
return false;
|
||||
}
|
||||
let Some(size) = bytes.get(16..24) else { return false };
|
||||
let Ok(size) = <&[u8; 8]>::try_from(size) else { return false };
|
||||
let [a, b, c, d, e, f, g, h] = *size;
|
||||
let (w, h) = (u32::from_be_bytes([a, b, c, d]), u32::from_be_bytes([e, f, g, h]));
|
||||
w > 0 && h > 0 && w <= 512 && h <= 512 && format!("{:x}", Sha256::digest(bytes)) == digest
|
||||
}
|
||||
|
||||
fn valid_record(r: &Record) -> bool {
|
||||
if !identifier(&r.id)
|
||||
|| r.id.as_bytes().first().is_none_or(|c| !c.is_ascii_lowercase())
|
||||
|| r.id == "artcraft-launcher"
|
||||
|| r.name.is_empty()
|
||||
|| r.name.len() > 128
|
||||
|| r.name.chars().any(char::is_control)
|
||||
|| !r.id.bytes().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == b'-')
|
||||
|| r.name.contains(['/', '\\'])
|
||||
|| !matches!(r.kind.as_str(), "official" | "community")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let bundle = r.bundle.clone().unwrap_or_else(|| format!("ai.storyteller.{}", r.id));
|
||||
if !bundle.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '-' | '_')) || bundle.is_empty() {
|
||||
return false;
|
||||
}
|
||||
// A signature cannot expand the compiled community allowlist or change existing install
|
||||
// identities. These checks keep native detection/uninstall and publisher verification pinned.
|
||||
if let Some(pinned) = SUITE.iter().find(|a| a.id == r.id) {
|
||||
if r.repo != pinned.repo
|
||||
|| (r.kind == "official") != (pinned.kind == AppKind::Official)
|
||||
|| r.publisher != pinned.publisher
|
||||
|| r.msi_publisher.as_deref() != pinned.msi_publisher
|
||||
|| bundle != pinned.bundle_id()
|
||||
|| r.former_ids != pinned.former_ids
|
||||
|| r.former_names != pinned.former_names
|
||||
|| r.former_bundles != pinned.former_bundles
|
||||
|| r.mac_team.as_deref() != pinned.mac_team
|
||||
|| r.mac_bundle_name.as_deref().unwrap_or(&r.name) != pinned.mac_bundle_name()
|
||||
|| r.name != pinned.name
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else if r.kind != "official"
|
||||
|| r.repo != format!("storytold/{}", r.id)
|
||||
|| r.publisher != "ArtCraft"
|
||||
|| r.msi_publisher.is_some()
|
||||
|| r.bundle.is_some()
|
||||
|| r.mac_team.as_deref() != Some(ARTCRAFT_TEAM_ID)
|
||||
|| !r.former_ids.is_empty()
|
||||
|| !r.former_names.is_empty()
|
||||
|| !r.former_bundles.is_empty()
|
||||
|| r.mac_bundle_name.as_deref().is_some_and(|name| name != r.name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if r.desktop_categories.len() > 16
|
||||
|| !r.desktop_categories.iter().all(|c| identifier(c))
|
||||
|| r.startup_wm_class.is_empty()
|
||||
|| r.startup_wm_class.chars().any(char::is_control)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if r.site.as_ref().is_some_and(|s| !s.starts_with("https://") || s.chars().any(char::is_control)) {
|
||||
return false;
|
||||
}
|
||||
if r.icon_sha256.len() != 64
|
||||
|| !r.icon_sha256.bytes().all(|c| c.is_ascii_hexdigit())
|
||||
|| r.icon_url != format!("https://getartcraft.com/launcher-app-icons/{}-{}.png", r.id, r.icon_sha256)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
r.details.as_ref().is_none_or(|p| {
|
||||
p.features.len() <= 16
|
||||
&& p.shots.len() <= 16
|
||||
&& p.shots.iter().all(|s| {
|
||||
identifier(&s.key)
|
||||
&& s.url == format!("{}/{}/{}/{}.jpg", crate::details::SCREENSHOTS_BASE, crate::details::SCREENSHOTS_REV, r.id, s.key)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn identifier(value: &str) -> bool {
|
||||
!value.is_empty() && value.len() <= 80 && value.bytes().all(|c| c.is_ascii_alphanumeric() || matches!(c, b'-' | b'_'))
|
||||
}
|
||||
fn intern(value: String) -> &'static str {
|
||||
Box::leak(value.into_boxed_str())
|
||||
}
|
||||
fn intern_list(values: Vec<String>) -> &'static [&'static str] {
|
||||
Box::leak(values.into_iter().map(intern).collect::<Vec<_>>().into_boxed_slice())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ed25519_dalek::{Signer, SigningKey};
|
||||
|
||||
const BUNDLED: &[u8] = include_bytes!("../catalog.toml");
|
||||
const WEBSITE: &[u8] = include_bytes!("../tests/fixtures/hosted-catalog.toml");
|
||||
const SIGNATURE: &[u8] = include_bytes!("../tests/fixtures/hosted-catalog.toml.sig");
|
||||
|
||||
fn signed(bytes: &[u8]) -> Result<VerifiedCatalog, String> {
|
||||
let key = SigningKey::from_bytes(&[7; 32]);
|
||||
let signature = STANDARD.encode(key.sign(bytes).to_bytes());
|
||||
VerifiedCatalog::verify_with_key(bytes, signature.as_bytes(), &key.verifying_key())
|
||||
}
|
||||
|
||||
fn first_record() -> Record {
|
||||
let document: Document = toml::from_str(std::str::from_utf8(BUNDLED).unwrap()).unwrap();
|
||||
document.apps.into_iter().next().unwrap().try_into().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn website_fixture_verifies_with_the_actual_pinned_public_key() {
|
||||
let catalog = VerifiedCatalog::verify(WEBSITE, SIGNATURE).unwrap();
|
||||
assert_eq!(catalog.records.len(), SUITE.len());
|
||||
assert_eq!(catalog.rejected_entries, 0);
|
||||
for record in &catalog.records {
|
||||
let bundled = SUITE.iter().find(|app| app.id == record.id).unwrap();
|
||||
assert_eq!(record.repo, bundled.repo);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tampered_wrong_key_missing_and_oversized_signatures_are_rejected() {
|
||||
let mut tampered = WEBSITE.to_vec();
|
||||
tampered.push(b'\n');
|
||||
assert!(VerifiedCatalog::verify(&tampered, SIGNATURE).is_err());
|
||||
let wrong = STANDARD.encode(SigningKey::from_bytes(&[7; 32]).sign(WEBSITE).to_bytes());
|
||||
assert!(VerifiedCatalog::verify(WEBSITE, wrong.as_bytes()).is_err());
|
||||
for signature in [b"".as_slice(), b"not-base64", &[b'a'; MAX_SIGNATURE_BYTES + 1]] {
|
||||
assert!(VerifiedCatalog::verify(BUNDLED, signature).is_err());
|
||||
}
|
||||
assert!(VerifiedCatalog::verify(&vec![0; MAX_CATALOG_BYTES + 1], SIGNATURE).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_fixture_keeps_lf_bytes_on_every_platform() {
|
||||
assert!(!WEBSITE.contains(&b'\r'));
|
||||
assert!(VerifiedCatalog::verify(WEBSITE, SIGNATURE).is_ok());
|
||||
let crlf = std::str::from_utf8(WEBSITE).unwrap().replace("\n", "\r\n");
|
||||
assert!(VerifiedCatalog::verify(crlf.as_bytes(), SIGNATURE).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_entries_and_unknown_fields_do_not_spoil_valid_apps() {
|
||||
let text = std::str::from_utf8(BUNDLED).unwrap();
|
||||
let text = format!("unknown_top_level = true\n{text}\n[[apps]]\nid = 42\n");
|
||||
let verified = signed(text.as_bytes()).unwrap();
|
||||
assert_eq!(verified.records.len(), SUITE.len());
|
||||
assert_eq!(verified.rejected_entries, 1);
|
||||
assert!(signed(b"not = [valid").is_err());
|
||||
assert!(signed(b"apps = []").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signature_cannot_expand_community_or_change_pinned_install_identity() {
|
||||
let mut r = first_record();
|
||||
r.repo = "attacker/photocraft".into();
|
||||
assert!(!valid_record(&r));
|
||||
r = first_record();
|
||||
r.mac_team = Some("OTHERTEAM1".into());
|
||||
assert!(!valid_record(&r));
|
||||
r = first_record();
|
||||
r.bundle = Some("other.bundle".into());
|
||||
assert!(!valid_record(&r));
|
||||
r = first_record();
|
||||
r.msi_publisher = Some("Other Publisher".into());
|
||||
assert!(!valid_record(&r));
|
||||
r = first_record();
|
||||
r.former_ids.push("unrelated".into());
|
||||
assert!(!valid_record(&r));
|
||||
r = first_record();
|
||||
r.name = "../other".into();
|
||||
assert!(!valid_record(&r));
|
||||
r = future_app();
|
||||
r.kind = "community".into();
|
||||
r.repo = "unapproved/examplecraft".into();
|
||||
assert!(!valid_record(&r));
|
||||
}
|
||||
|
||||
fn future_app() -> Record {
|
||||
let mut r = first_record();
|
||||
r.id = "examplecraft".into();
|
||||
r.name = "ExampleCraft".into();
|
||||
r.repo = "storytold/examplecraft".into();
|
||||
r.mac_bundle_name = Some(r.name.clone());
|
||||
r.startup_wm_class = "ai.storyteller.examplecraft".into();
|
||||
r.icon_url = format!("https://getartcraft.com/launcher-app-icons/{}-{}.png", r.id, r.icon_sha256);
|
||||
r.details = None;
|
||||
r
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_official_app_needs_no_launcher_release_but_stays_within_policy() {
|
||||
let mut r = future_app();
|
||||
assert!(valid_record(&r));
|
||||
r.id = "../escape".into();
|
||||
assert!(!valid_record(&r));
|
||||
r = future_app();
|
||||
r.id = "-option".into();
|
||||
r.repo = "storytold/-option".into();
|
||||
r.icon_url = format!("https://getartcraft.com/launcher-app-icons/{}-{}.png", r.id, r.icon_sha256);
|
||||
assert!(!valid_record(&r));
|
||||
r = future_app();
|
||||
r.icon_url = "https://other.example/icon.png".into();
|
||||
assert!(!valid_record(&r));
|
||||
r = future_app();
|
||||
r.startup_wm_class = "example\nExec=other".into();
|
||||
assert!(!valid_record(&r));
|
||||
r = future_app();
|
||||
r.desktop_categories.push("Graphics;\nExec=other".into());
|
||||
assert!(!valid_record(&r));
|
||||
r = first_record();
|
||||
r.details.as_mut().unwrap().shots[0].url = "https://other.example/shot.jpg".into();
|
||||
assert!(!valid_record(&r));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn icon_hashes_and_decode_dimensions_are_checked() {
|
||||
let bytes = crate::catalog::app_icon_png("photocraft").unwrap();
|
||||
let digest = format!("{:x}", Sha256::digest(bytes));
|
||||
assert!(valid_icon(bytes, &digest));
|
||||
assert!(!valid_icon(bytes, &"0".repeat(64)));
|
||||
assert!(!valid_icon(&bytes[..20], &digest));
|
||||
let mut huge = bytes.to_vec();
|
||||
huge[16..20].copy_from_slice(&u32::MAX.to_be_bytes());
|
||||
assert!(!valid_icon(&huge, &format!("{:x}", Sha256::digest(&huge))));
|
||||
}
|
||||
#[test]
|
||||
fn runtime_snapshot_adds_apps_details_icons_and_retains_omitted_bundled_apps() {
|
||||
let mut record = future_app();
|
||||
record.details = Some(Page {
|
||||
headline: "New app".into(),
|
||||
about: "Signed copy".into(),
|
||||
platforms: "Linux".into(),
|
||||
features: vec![PageFeature { title: "Feature".into(), text: "Description".into() }],
|
||||
shots: vec![],
|
||||
});
|
||||
let icon = crate::catalog::app_icon_png("photocraft").unwrap().to_vec();
|
||||
let snapshot =
|
||||
VerifiedCatalog { records: vec![record], rejected_entries: 0 }.into_snapshot(HashMap::from([("examplecraft".into(), icon.clone())]));
|
||||
assert_eq!(snapshot.apps.len(), SUITE.len() + 1);
|
||||
assert_eq!(snapshot.apps[0].id, "examplecraft");
|
||||
assert_eq!(snapshot.apps[0].repo, "storytold/examplecraft");
|
||||
assert_eq!(snapshot.details[0].headline, "New app");
|
||||
assert_eq!(snapshot.metadata["examplecraft"].startup_wm_class, "ai.storyteller.examplecraft");
|
||||
assert_eq!(snapshot.icons["examplecraft"], icon);
|
||||
assert!(SUITE.iter().all(|app| snapshot.apps.iter().any(|a| a.id == app.id)));
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ pub mod catalog;
|
||||
pub mod details;
|
||||
pub mod distro;
|
||||
pub mod feed;
|
||||
pub mod hosted_catalog;
|
||||
pub mod platform;
|
||||
pub mod protocol;
|
||||
pub mod release;
|
||||
|
||||
@@ -204,6 +204,8 @@ impl Source {
|
||||
/// Something the backend wants the UI to know.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Event {
|
||||
/// A signed startup catalog has replaced the bundled app list.
|
||||
CatalogUpdated,
|
||||
Latest {
|
||||
app: String,
|
||||
latest: LatestRelease,
|
||||
|
||||
+1045
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
jBP6IMAHVzXER9SxsJRy8NFFD8jJkG9GxLuqJxeNDIOaQFZbmLgEwaFv9PmNFRHW5z+rj4P6rixNKSKX2/NuAg==
|
||||
@@ -13,7 +13,7 @@ use artcraft_launcher_core::protocol::{
|
||||
Source, VersionTrack,
|
||||
};
|
||||
use artcraft_launcher_core::release::{Asset, Release};
|
||||
use artcraft_launcher_core::{CraftApp, Installed, PackageKind, SUITE, version};
|
||||
use artcraft_launcher_core::{CraftApp, Installed, PackageKind, version};
|
||||
|
||||
use crate::feed_throttle::{self, FeedThrottle, Outcome};
|
||||
use crate::http::{self, Http, Stop};
|
||||
@@ -301,7 +301,7 @@ impl NativeBackend {
|
||||
let pre = options.prereleases;
|
||||
let feed = if pre { None } else { load_feed(&self.paths) };
|
||||
let now = crate::now();
|
||||
for app in SUITE.iter().filter(|a| self.platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| self.platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
let answer = match feed.as_ref().map(|f| f.answer(app, now)) {
|
||||
Some(FeedAnswer::Fresh(Some(r))) => Some((LatestRelease::Found(r), Origin::ArtCraftApi)),
|
||||
Some(FeedAnswer::Fresh(None)) => Some((LatestRelease::None, Origin::ArtCraftApi)),
|
||||
@@ -323,7 +323,7 @@ impl NativeBackend {
|
||||
let paths = self.paths.clone();
|
||||
let platform = self.platform;
|
||||
std::thread::spawn(move || {
|
||||
for app in SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
report_partial(app, &shared, &paths, platform);
|
||||
}
|
||||
});
|
||||
@@ -349,12 +349,12 @@ impl NativeBackend {
|
||||
http::clean_downloads(&paths.downloads(), Duration::from_secs(30 * 86_400), Duration::from_secs(7 * 86_400));
|
||||
let snapshot = crate::detect::Snapshot::take();
|
||||
let manifest = shared.manifest.lock().unwrap_or_else(PoisonError::into_inner).clone();
|
||||
for app in SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
let found = crate::detect::detect(app, &manifest, &snapshot);
|
||||
publish_detected(app, found, &shared, platform);
|
||||
}
|
||||
// Downloads paused (or cut off by quitting) in an earlier run.
|
||||
for app in SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
report_partial(app, &shared, &paths, platform);
|
||||
}
|
||||
drop(busy);
|
||||
@@ -366,7 +366,9 @@ impl NativeBackend {
|
||||
/// day old, or no answer at all), at most once an hour per app unless `force`.
|
||||
fn check(&self, force: bool) {
|
||||
let (Some(source), Some(http)) = (self.source.clone(), self.http.clone()) else {
|
||||
for app in SUITE.iter().filter(|a| self.platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
crate::hosted_catalog::load_once(None, &self.paths);
|
||||
self.shared.emit(Event::CatalogUpdated);
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| self.platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
self.shared.emit(Event::Latest {
|
||||
app: app.id.to_string(),
|
||||
latest: LatestRelease::Failed("secure connections aren't available".into()),
|
||||
@@ -390,24 +392,34 @@ impl NativeBackend {
|
||||
std::thread::spawn(move || {
|
||||
let busy = busy;
|
||||
shared.emit(Event::CheckStarted);
|
||||
crate::hosted_catalog::load_once(Some(&http), &paths);
|
||||
shared.emit(Event::CatalogUpdated);
|
||||
let (feed, fallback) = check_plan(&http, mirror.as_ref(), pre, &paths, &shared);
|
||||
if let Some(f) = &feed {
|
||||
shared.emit(Event::Notices { announcements: f.announcements.clone(), alerts: f.alerts.clone() });
|
||||
}
|
||||
let now = crate::now();
|
||||
let queue = Mutex::new(
|
||||
SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))).chain(std::iter::once(&LAUNCHER)).collect::<Vec<&CraftApp>>(),
|
||||
artcraft_launcher_core::hosted_catalog::apps()
|
||||
.iter()
|
||||
.filter(|a| platform.is_none_or(|p| a.runs_on(p.os)))
|
||||
.chain(std::iter::once(&LAUNCHER))
|
||||
.collect::<Vec<&CraftApp>>(),
|
||||
);
|
||||
let sources = sweep(&queue, &mirror, feed.as_ref(), fallback, &source, &shared, &paths, (platform, &options), force, now);
|
||||
source.save();
|
||||
{
|
||||
let answered = shared.answered.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
if SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))).all(|a| answered.contains(a.id)) {
|
||||
if artcraft_launcher_core::hosted_catalog::apps()
|
||||
.iter()
|
||||
.filter(|a| platform.is_none_or(|p| a.runs_on(p.os)))
|
||||
.all(|a| answered.contains(a.id))
|
||||
{
|
||||
shared.loaded.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
// A newer release changes which file an install would use.
|
||||
for app in SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
report_partial(app, &shared, &paths, platform);
|
||||
}
|
||||
let source_used = source_used_of(&sources);
|
||||
|
||||
@@ -18,6 +18,9 @@ pub const MARKER: &str = "X-ArtCraft-Launcher=true";
|
||||
|
||||
/// The menu categories and the window class each app's own `.desktop` file declares.
|
||||
pub fn meta(app: &CraftApp) -> (&'static str, Option<&'static str>) {
|
||||
if let Some(meta) = artcraft_launcher_core::hosted_catalog::metadata(app.id) {
|
||||
return (meta.desktop_categories.as_str(), Some(meta.startup_wm_class.as_str()));
|
||||
}
|
||||
match app.id {
|
||||
"artcraft" => ("Graphics;AudioVideo;2DGraphics;", Some("artcraft")),
|
||||
"photocraft" => ("Graphics;2DGraphics;RasterGraphics;Photography;", Some("photocraft")),
|
||||
|
||||
@@ -465,7 +465,7 @@ pub mod linux {
|
||||
/// pacman, Flatpak). Read once per detection pass.
|
||||
pub fn packages() -> Vec<Package> {
|
||||
let ours = |name: &str| {
|
||||
artcraft_launcher_core::SUITE.iter().any(|a| {
|
||||
artcraft_launcher_core::hosted_catalog::apps().iter().any(|a| {
|
||||
[InstallSource::Deb, InstallSource::Rpm, InstallSource::Pacman, InstallSource::Flatpak]
|
||||
.iter()
|
||||
.any(|m| crate::packages::candidate_names(a, *m).iter().any(|n| n == name))
|
||||
@@ -511,10 +511,9 @@ pub mod linux {
|
||||
user_ids.extend(flatpaks.iter().map(|(id, _, _, _)| id.clone()));
|
||||
}
|
||||
// Bundles built from a release tarball often list no version: ask Flatpak directly.
|
||||
for (id, version, _, installation) in flatpaks
|
||||
.iter_mut()
|
||||
.filter(|(id, v, _, _)| v.is_empty() && artcraft_launcher_core::SUITE.iter().any(|a| a.bundle_ids().any(|b| b == *id)))
|
||||
{
|
||||
for (id, version, _, installation) in flatpaks.iter_mut().filter(|(id, v, _, _)| {
|
||||
v.is_empty() && artcraft_launcher_core::hosted_catalog::apps().iter().any(|a| a.bundle_ids().any(|b| b == *id))
|
||||
}) {
|
||||
let scope_arg = packages::flatpak_scope(if scope.is_empty() { installation.as_deref() } else { Some("user") });
|
||||
let info_args = ["info", &scope_arg, &arch, id];
|
||||
if let Some(v) = crate::process::capture_flatpak(&info_args, t).as_deref().and_then(packages::parse_flatpak_info) {
|
||||
@@ -754,7 +753,7 @@ mod linux_tests {
|
||||
#[test]
|
||||
fn ours_filter_matches_rpm_packages() {
|
||||
let ours = |name: &str| {
|
||||
artcraft_launcher_core::SUITE.iter().any(|a| {
|
||||
artcraft_launcher_core::hosted_catalog::apps().iter().any(|a| {
|
||||
[InstallSource::Deb, InstallSource::Rpm, InstallSource::Pacman, InstallSource::Flatpak]
|
||||
.iter()
|
||||
.any(|m| crate::packages::candidate_names(a, *m).iter().any(|n| n == name))
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
//! Startup-only signed catalog refresh with an atomic, reverified disk fallback.
|
||||
use std::collections::HashMap;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::sync::Once;
|
||||
|
||||
use artcraft_launcher_core::hosted_catalog::{
|
||||
CATALOG_URL, MAX_CATALOG_BYTES, MAX_ICON_BYTES, MAX_SIGNATURE_BYTES, SIGNATURE_URL, VerifiedCatalog, valid_icon,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::http::Http;
|
||||
use crate::paths::{Paths, write_atomic};
|
||||
|
||||
static LOADED: Once = Once::new();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Saved {
|
||||
catalog: String,
|
||||
signature: String,
|
||||
}
|
||||
|
||||
pub fn load_once(http: Option<&Http>, paths: &Paths) {
|
||||
LOADED.call_once(|| {
|
||||
let cache = paths.feed_cache().with_file_name("launcher-catalog.json");
|
||||
let remote = http.ok_or_else(|| "HTTPS unavailable".to_string()).and_then(|h| {
|
||||
let catalog = h.get_catalog_bytes(CATALOG_URL, MAX_CATALOG_BYTES)?.ok_or("hosted catalog is not published")?;
|
||||
let signature = h.get_catalog_bytes(SIGNATURE_URL, MAX_SIGNATURE_BYTES)?.ok_or("catalog signature is not published")?;
|
||||
let verified = VerifiedCatalog::verify(&catalog, &signature)?;
|
||||
let saved = Saved {
|
||||
catalog: String::from_utf8(catalog).map_err(|_| "catalog is not UTF-8")?,
|
||||
signature: String::from_utf8(signature).map_err(|_| "signature is not UTF-8")?,
|
||||
};
|
||||
Ok((verified, saved))
|
||||
});
|
||||
let catalog = match remote {
|
||||
Ok((verified, saved)) => {
|
||||
if let Ok(bytes) = serde_json::to_vec(&saved)
|
||||
&& let Err(why) = write_atomic(&cache, &bytes)
|
||||
{
|
||||
log::warn!("could not cache signed catalog: {why}");
|
||||
}
|
||||
Some(verified)
|
||||
}
|
||||
Err(why) => {
|
||||
log::warn!("hosted catalog unavailable: {why}; trying verified cache, then bundled catalog");
|
||||
saved_catalog(&cache)
|
||||
}
|
||||
};
|
||||
if let Some(catalog) = catalog {
|
||||
if catalog.rejected_entries > 0 {
|
||||
log::warn!("ignored {} invalid catalog entries", catalog.rejected_entries);
|
||||
}
|
||||
let mut icons = HashMap::new();
|
||||
let mut network_available = true;
|
||||
for (id, url, digest) in catalog.icons() {
|
||||
if artcraft_launcher_core::catalog::app_icon_png(id).is_some_and(|b| valid_icon(b, digest)) {
|
||||
continue;
|
||||
}
|
||||
let saved = cache.with_file_name(format!("catalog-icon-{digest}.png"));
|
||||
let icon = read_capped(&saved, MAX_ICON_BYTES).filter(|b| valid_icon(b, digest)).or_else(|| {
|
||||
if !network_available {
|
||||
return None;
|
||||
}
|
||||
let bytes = match http?.get_catalog_bytes(url, MAX_ICON_BYTES) {
|
||||
Ok(bytes) => bytes?,
|
||||
Err(_) => {
|
||||
network_available = false;
|
||||
return None;
|
||||
}
|
||||
};
|
||||
if !valid_icon(&bytes, digest) {
|
||||
return None;
|
||||
}
|
||||
if let Err(why) = write_atomic(&saved, &bytes) {
|
||||
log::warn!("could not cache catalog icon: {why}");
|
||||
}
|
||||
Some(bytes)
|
||||
});
|
||||
if let Some(icon) = icon {
|
||||
icons.insert(id.to_string(), icon);
|
||||
}
|
||||
}
|
||||
catalog.activate(icons);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn saved_catalog(path: &Path) -> Option<VerifiedCatalog> {
|
||||
// JSON escaping can expand a signed TOML byte to six bytes.
|
||||
let bytes = read_capped(path, MAX_CATALOG_BYTES * 6 + MAX_SIGNATURE_BYTES + 128)?;
|
||||
let saved: Saved = serde_json::from_slice(&bytes).ok()?;
|
||||
VerifiedCatalog::verify(saved.catalog.as_bytes(), saved.signature.as_bytes()).ok()
|
||||
}
|
||||
|
||||
fn read_capped(path: &Path, max: usize) -> Option<Vec<u8>> {
|
||||
let file = std::fs::File::open(path).ok()?;
|
||||
if file.metadata().ok()?.len() > max as u64 {
|
||||
return None;
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
file.take(max as u64 + 1).read_to_end(&mut bytes).ok()?;
|
||||
(bytes.len() <= max).then_some(bytes)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires the live signed catalog at getartcraft.com"]
|
||||
fn live_catalog_is_verified_cached_and_activated() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let paths = Paths::under(dir.path());
|
||||
let http = Http::new().unwrap();
|
||||
load_once(Some(&http), &paths);
|
||||
let cache = paths.feed_cache().with_file_name("launcher-catalog.json");
|
||||
let verified = saved_catalog(&cache).expect("live catalog must be cached and verify with the pinned key");
|
||||
assert_eq!(verified.rejected_entries, 0);
|
||||
let icons: Vec<_> = verified.icons().collect();
|
||||
assert!(!icons.is_empty());
|
||||
for (id, _, digest) in icons {
|
||||
assert!(artcraft_launcher_core::hosted_catalog::apps().iter().any(|app| app.id == id));
|
||||
let icon = artcraft_launcher_core::catalog::app_icon_png(id).unwrap();
|
||||
assert!(valid_icon(icon, digest), "invalid live icon for {id}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cached_catalog_is_reverified_and_tampered_cache_is_ignored() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("catalog.json");
|
||||
let mut saved = Saved {
|
||||
catalog: include_str!("../../core/tests/fixtures/hosted-catalog.toml").into(),
|
||||
signature: include_str!("../../core/tests/fixtures/hosted-catalog.toml.sig").into(),
|
||||
};
|
||||
write_atomic(&path, &serde_json::to_vec(&saved).unwrap()).unwrap();
|
||||
assert!(saved_catalog(&path).is_some());
|
||||
saved.catalog.push('\n');
|
||||
write_atomic(&path, &serde_json::to_vec(&saved).unwrap()).unwrap();
|
||||
assert!(saved_catalog(&path).is_none());
|
||||
write_atomic(&path, b"not JSON").unwrap();
|
||||
assert!(saved_catalog(&path).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capped_cache_reads_reject_announced_or_actual_oversize() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("cache");
|
||||
std::fs::write(&path, b"abcd").unwrap();
|
||||
assert_eq!(read_capped(&path, 4).unwrap(), b"abcd");
|
||||
assert!(read_capped(&path, 3).is_none());
|
||||
}
|
||||
}
|
||||
@@ -197,6 +197,18 @@ impl Http {
|
||||
/// on the body when the length wasn't announced or was wrong.
|
||||
pub fn get_bytes(&self, url: &str, max: usize) -> Result<Option<Vec<u8>>, String> {
|
||||
let agent = if is_loopback(url) { &self.direct } else { &self.small };
|
||||
Self::get_bytes_with(agent, url, max)
|
||||
}
|
||||
|
||||
/// Catalog resources remain on the pinned HTTPS website; redirect responses are refused.
|
||||
pub fn get_catalog_bytes(&self, url: &str, max: usize) -> Result<Option<Vec<u8>>, String> {
|
||||
if !url.starts_with("https://getartcraft.com/") {
|
||||
return Err("catalog resources must use the pinned HTTPS website".into());
|
||||
}
|
||||
Self::get_bytes_with(&self.no_redirect, url, max)
|
||||
}
|
||||
|
||||
fn get_bytes_with(agent: &ureq::Agent, url: &str, max: usize) -> Result<Option<Vec<u8>>, String> {
|
||||
let mut resp = agent.get(url).call().map_err(|e| format!("{UNREACHABLE} {} ({e})", host(url)))?;
|
||||
match resp.status().as_u16() {
|
||||
200 => {
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod backend;
|
||||
pub mod desktop_entry;
|
||||
pub mod detect;
|
||||
pub mod feed_throttle;
|
||||
pub mod hosted_catalog;
|
||||
pub mod http;
|
||||
pub mod install;
|
||||
pub mod login;
|
||||
|
||||
@@ -7,7 +7,7 @@ use artcraft_launcher_core::protocol::{
|
||||
};
|
||||
use artcraft_launcher_core::release::Release;
|
||||
use artcraft_launcher_core::status::AppStatus;
|
||||
use artcraft_launcher_core::{Arch, PackageKind, Platform, SUITE};
|
||||
use artcraft_launcher_core::{Arch, PackageKind, Platform};
|
||||
|
||||
use crate::i18n::set_current;
|
||||
use crate::model::AppEntry;
|
||||
@@ -260,7 +260,11 @@ impl LauncherUi {
|
||||
Self {
|
||||
backend,
|
||||
settings,
|
||||
entries: SUITE.iter().filter(|a| platform.is_none_or(|p| a.runs_on(p.os))).map(AppEntry::new).collect(),
|
||||
entries: artcraft_launcher_core::hosted_catalog::apps()
|
||||
.iter()
|
||||
.filter(|a| platform.is_none_or(|p| a.runs_on(p.os)))
|
||||
.map(AppEntry::new)
|
||||
.collect(),
|
||||
caps,
|
||||
platform,
|
||||
checking: false,
|
||||
@@ -554,6 +558,18 @@ impl LauncherUi {
|
||||
/// Returns whether app state changed.
|
||||
fn handle(&mut self, event: Event) -> bool {
|
||||
match event {
|
||||
Event::CatalogUpdated => {
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps().iter().filter(|a| self.platform.is_none_or(|p| a.runs_on(p.os))) {
|
||||
if let Some(entry) = self.entries.iter_mut().find(|e| e.app.id == app.id) {
|
||||
entry.app = app;
|
||||
} else {
|
||||
self.entries.push(AppEntry::new(app));
|
||||
}
|
||||
}
|
||||
self.entries.sort_by_key(|entry| artcraft_launcher_core::hosted_catalog::apps().iter().position(|app| app.id == entry.app.id));
|
||||
self.backend.send(Command::Detect);
|
||||
true
|
||||
}
|
||||
Event::Latest { app, latest, from } => {
|
||||
self.on_latest(app, latest, from);
|
||||
true
|
||||
@@ -1165,6 +1181,22 @@ mod tests {
|
||||
sent.borrow().iter().filter(|command| matches!(command, Command::Install { .. })).count()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_event_adds_entries_in_suite_order_and_keeps_current_state() {
|
||||
let (mut ui, sent, _) = launcher();
|
||||
let id = ui.entries[0].app.id;
|
||||
ui.entries[0].detected = true;
|
||||
ui.entries.pop();
|
||||
ui.entries.reverse();
|
||||
assert!(ui.handle(Event::CatalogUpdated));
|
||||
assert_eq!(
|
||||
ui.entries.iter().map(|e| e.app.id).collect::<Vec<_>>(),
|
||||
artcraft_launcher_core::hosted_catalog::apps().iter().map(|a| a.id).collect::<Vec<_>>()
|
||||
);
|
||||
assert!(ui.entry(id).unwrap().detected);
|
||||
assert_eq!(sent.borrow().as_slice(), &[Command::Detect]);
|
||||
}
|
||||
|
||||
/// A CJK preference is drawable only while that language's own face is installed: having the
|
||||
/// system font cached, or another script's face installed, is not enough.
|
||||
#[test]
|
||||
|
||||
@@ -247,7 +247,7 @@ impl LauncherUi {
|
||||
fn neighbour_apps(&self, id: &str) -> (Option<String>, Option<String>) {
|
||||
let mut ids: Vec<&str> = self.visible_ids().into_iter().filter(|i| AppDetails::by_id(i).is_some()).collect();
|
||||
if !ids.contains(&id) {
|
||||
ids = artcraft_launcher_core::SUITE
|
||||
ids = artcraft_launcher_core::hosted_catalog::apps()
|
||||
.iter()
|
||||
.filter(|a| self.platform.is_none_or(|p| a.runs_on(p.os)))
|
||||
.map(|a| a.id)
|
||||
|
||||
@@ -5,7 +5,12 @@ use egui::ImageSource;
|
||||
/// The 128 px icon of a Craft App ([`catalog::app_icon_png`](artcraft_launcher_core::catalog::app_icon_png)).
|
||||
pub fn app(id: &str) -> Option<ImageSource<'static>> {
|
||||
let png = artcraft_launcher_core::catalog::app_icon_png(id)?;
|
||||
Some(ImageSource::Bytes { uri: format!("bytes://app-icons/{id}.png").into(), bytes: png.into() })
|
||||
let revision = icon_revision(id);
|
||||
Some(ImageSource::Bytes { uri: format!("bytes://app-icons/{id}/{revision}.png").into(), bytes: png.into() })
|
||||
}
|
||||
|
||||
fn icon_revision(id: &str) -> &'static str {
|
||||
artcraft_launcher_core::hosted_catalog::metadata(id).map_or("bundled", |m| m.icon_sha256.as_str())
|
||||
}
|
||||
|
||||
/// A Craft App's icon: in colour, or in greys for an app that is not installed. The grey copy is
|
||||
@@ -20,7 +25,7 @@ pub fn app_image(ctx: &egui::Context, id: &str, in_colour: bool) -> Option<egui:
|
||||
if let Some(colour) = &colour {
|
||||
let _ = colour.load_for_size(ctx, egui::Vec2::splat(64.0));
|
||||
}
|
||||
let key = egui::Id::unique(("grey-app-icon", id));
|
||||
let key = egui::Id::unique(("grey-app-icon", id, icon_revision(id)));
|
||||
if let Some(texture) = ctx.data(|d| d.get_temp::<egui::TextureHandle>(key)) {
|
||||
return Some(egui::Image::new(&texture));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
# Signed hosted catalog
|
||||
|
||||
The launcher bundles `crates/core/catalog.toml`, containing the website's
|
||||
`launcher-catalog.toml` data from storytold/artcraft-services#205 with the latest
|
||||
compiled display order. The signed website fixture is kept separately under
|
||||
`crates/core/tests/fixtures/` with byte-preserving Git attributes for Windows. The core build script
|
||||
generates the existing static app/details types from it, keeping first launch
|
||||
and offline operation independent of the website.
|
||||
|
||||
On the first release check of each process, desktop and web fetch:
|
||||
|
||||
- `https://getartcraft.com/launcher-catalog.toml`
|
||||
- `https://getartcraft.com/launcher-catalog.toml.sig`
|
||||
|
||||
The signature is base64 encoding of a 64-byte Ed25519 signature over the exact
|
||||
TOML bytes, with optional surrounding whitespace. Verification uses the SPKI
|
||||
PEM public key in `crates/core/assets/launcher-catalog-public-key.pem` before
|
||||
parsing. The corresponding private key belongs only in the website's Cloudflare
|
||||
build secret `LAUNCHER_CATALOG_SIGNING_KEY`. It is never read or bundled by the
|
||||
launcher. The checked-in signature fixture is public test data, not a secret.
|
||||
|
||||
Desktop stores the TOML and signature together in an atomic
|
||||
`launcher-catalog.json` beside the release-feed cache. Web uses the browser's
|
||||
local storage (`artcraft-launcher.signed-catalog.v1`). Every cache read verifies
|
||||
the signature again. Network failures, missing signatures, invalid signatures,
|
||||
invalid documents or unavailable storage preserve the verified cache, then the
|
||||
bundled list. The bundled list is visible while the background check runs.
|
||||
|
||||
The active catalog is immutable for the process lifetime. Existing install jobs
|
||||
keep their static handles; restarting refreshes the catalog again. Only one
|
||||
bounded snapshot is interned per process. This avoids accumulating leaked strings
|
||||
on repeated checks. Missing bundled apps are appended to the hosted list so an
|
||||
installed copy remains manageable after the hosted entry disappears.
|
||||
|
||||
The signed file updates app copy, colors, details, desktop categories, window
|
||||
class, icons and display order. Invalid rows are skipped, unknown fields ignored,
|
||||
and a document with no valid rows is rejected. New official apps can be added
|
||||
without a launcher release, within the existing source policy: a lowercase safe
|
||||
ID, its matching `storytold/<id>` repository, ArtCraft publisher/team, default
|
||||
bundle ID and no legacy aliases. Existing app names, aliases, bundle IDs,
|
||||
repositories, publishers and macOS signing teams stay pinned to the bundled
|
||||
entry. A signature cannot add an unapproved community app or change an existing
|
||||
install identity. Community onboarding and identity changes still require
|
||||
maintainer review and a launcher release.
|
||||
|
||||
Icons must use the website's app-ID/hash filenames and pass SHA-256 and PNG
|
||||
size/dimension checks before decoding. Desktop caches them by hash; web uses
|
||||
its HTTP cache. Missing icons do not block a valid catalog. Screenshots remain
|
||||
JPEGs at the launcher's pinned assets tag, with existing byte/pixel checks.
|
||||
The currently supported installer code still derives package/binary IDs from
|
||||
app IDs; arbitrary installer identities in unknown manifest fields do not
|
||||
change installation behavior.
|
||||
|
||||
Limits: 1 MiB catalog, 128-byte encoded signature, 64 hosted apps, 16 features
|
||||
and screenshots per app, 256 KiB/512×512 PNG icons. Desktop HTTP uses its existing
|
||||
bounded reader and timeouts. Browser catalog/icon requests stream with actual
|
||||
byte limits and a 20-second abort signal; redirects are refused on both platforms.
|
||||
|
||||
This is a single pinned key. Rotation requires a launcher update; there is no
|
||||
manifest-authorized next key, signed expiry or rollback counter in this schema.
|
||||
The signature authenticates content, not freshness. The existing package checksum
|
||||
and macOS/Windows publisher checks continue to apply to installations.
|
||||
|
||||
Validation includes a real signed website-format fixture, wrong-key/tampering
|
||||
rejection, malformed rows, install-identity restrictions, new official app policy,
|
||||
icon hashes/dimensions, and reverified cache fallback. The private signing key is
|
||||
not required to run any test.
|
||||
|
||||
To validate the published catalog through the desktop HTTP/cache/activation path
|
||||
without installing any app:
|
||||
|
||||
```sh
|
||||
cargo test -p artcraft-launcher-native live_catalog_is_verified_cached_and_activated -- --ignored
|
||||
```
|
||||
|
||||
This opt-in network test uses temporary storage and checks the pinned signature,
|
||||
all accepted entries, activation and icon hashes. Normal CI stays offline.
|
||||
Reference in new issue
Block a user