Merge pull request #1665 from storytold/feat/static-catalog-releases
feat: fetch signed catalog, releases, and screenshots from getartcraft.com with GitHub fallback
No files matched your search
@@ -0,0 +1,20 @@
|
||||
name: Notify Services on Release Change
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
- unpublished
|
||||
- created
|
||||
- edited
|
||||
- deleted
|
||||
- prereleased
|
||||
- released
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
notify:
|
||||
uses: storytold/craft-common-actions/.github/workflows/notify-services.yml@main
|
||||
secrets:
|
||||
ARTCRAFT_SERVICES_DISPATCH_TOKEN: ${{ secrets.ARTCRAFT_SERVICES_DISPATCH_TOKEN }}
|
||||
@@ -332,6 +332,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"toml 1.1.8+spec-1.1.0",
|
||||
"ureq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -147,7 +147,7 @@ impl WebBackend {
|
||||
for shot in details.shots {
|
||||
let result = match (&offline, details.screenshot_url(shot.key)) {
|
||||
(Some(why), _) => Err(why.clone()),
|
||||
(None, Some(url)) => picture(&url).await.map_err(|failure| match failure {
|
||||
(None, Some(url)) => picture_or_fallback(details, shot.key, &url).await.map_err(|failure| match failure {
|
||||
PictureError::Network(why) => {
|
||||
offline = Some(why.clone());
|
||||
why
|
||||
@@ -207,6 +207,21 @@ impl WebBackend {
|
||||
}
|
||||
}
|
||||
|
||||
/// The picture at `url` (getartcraft.com), or else the same picture from the GitHub fallback. A
|
||||
/// picture-specific answer from the fallback is kept, so it doesn't read as a network failure.
|
||||
async fn picture_or_fallback(details: &AppDetails, key: &str, url: &str) -> Result<Vec<u8>, PictureError> {
|
||||
let primary = match picture(url).await {
|
||||
Ok(bytes) => return Ok(bytes),
|
||||
Err(primary) => primary,
|
||||
};
|
||||
let Some(fallback) = details.screenshot_fallback_url(key) else { return Err(primary) };
|
||||
match picture(&fallback).await {
|
||||
Ok(bytes) => Ok(bytes),
|
||||
Err(fallback @ PictureError::Picture(_)) => Err(fallback),
|
||||
Err(PictureError::Network(_)) => Err(primary),
|
||||
}
|
||||
}
|
||||
|
||||
/// Why a picture couldn't be had.
|
||||
enum PictureError {
|
||||
/// This picture only: it isn't published, or what came back isn't a picture.
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,177 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 the MailCraft contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 SolidCraft contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -24,5 +24,9 @@ sha2 = "0.10"
|
||||
toml = { version = "=1.1.8", default-features = false, features = ["parse", "serde", "std"] }
|
||||
|
||||
[build-dependencies]
|
||||
base64 = "0.22"
|
||||
ed25519-dalek = { version = "2.2", default-features = false, features = ["std", "fast", "pem"] }
|
||||
serde = { workspace = true }
|
||||
sha2 = "0.10"
|
||||
toml = { version = "=1.1.8", default-features = false, features = ["parse", "serde", "std"] }
|
||||
ureq = { version = "3.5", default-features = false, features = ["rustls-no-provider", "_ring", "gzip", "platform-verifier"] }
|
||||
@@ -1,12 +1,28 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
use std::error::Error;
|
||||
use std::fmt::Write as _;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
use std::{env, fs};
|
||||
|
||||
use base64::{Engine as _, engine::general_purpose::STANDARD};
|
||||
use ed25519_dalek::{Signature, VerifyingKey, pkcs8::DecodePublicKey};
|
||||
use serde::Deserialize;
|
||||
use std::{env, error::Error, fmt::Write as _, fs, path::PathBuf};
|
||||
use sha2::{Digest as _, Sha256};
|
||||
|
||||
const CATALOG_URL: &str = "https://getartcraft.com/launcher-catalog.toml";
|
||||
const SIGNATURE_URL: &str = "https://getartcraft.com/launcher-catalog.toml.sig";
|
||||
const PUBLIC_KEY_PEM: &str = include_str!("assets/launcher-catalog-public-key.pem");
|
||||
const MAX_CATALOG_BYTES: usize = 1 << 20;
|
||||
const MAX_SIGNATURE_BYTES: usize = 128;
|
||||
const MAX_ICON_BYTES: usize = 256 << 10;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Manifest {
|
||||
apps: Vec<App>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct App {
|
||||
id: String,
|
||||
@@ -17,18 +33,24 @@ struct App {
|
||||
ink_dark: [u8; 3],
|
||||
repo: String,
|
||||
former_repo: Option<String>,
|
||||
#[serde(default)]
|
||||
former_ids: Vec<String>,
|
||||
#[serde(default)]
|
||||
former_names: Vec<String>,
|
||||
kind: String,
|
||||
publisher: String,
|
||||
msi_publisher: Option<String>,
|
||||
bundle: Option<String>,
|
||||
#[serde(default)]
|
||||
former_bundles: Vec<String>,
|
||||
site: Option<String>,
|
||||
mac_team: Option<String>,
|
||||
mac_bundle_name: Option<String>,
|
||||
icon_url: String,
|
||||
icon_sha256: String,
|
||||
details: Option<Details>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Details {
|
||||
headline: String,
|
||||
@@ -39,34 +61,204 @@ struct Details {
|
||||
#[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 verify_signature(bytes: &[u8], signature: &[u8], key: &VerifyingKey) -> Result<(), String> {
|
||||
if bytes.len() > MAX_CATALOG_BYTES || signature.len() > MAX_SIGNATURE_BYTES {
|
||||
return Err("catalog or signature exceeds 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 signature")?;
|
||||
let sig = Signature::from_slice(&decoded).map_err(|_| "invalid Ed25519 signature length")?;
|
||||
key.verify_strict(bytes, &sig).map_err(|_| "catalog signature does not match the pinned key".into())
|
||||
}
|
||||
|
||||
fn sha256_hex(bytes: &[u8]) -> String {
|
||||
let digest = Sha256::digest(bytes);
|
||||
let mut out = String::with_capacity(64);
|
||||
for b in digest {
|
||||
let _ = write!(out, "{b:02x}");
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn build_agent() -> ureq::Agent {
|
||||
let tls = ureq::tls::TlsConfig::builder().root_certs(ureq::tls::RootCerts::PlatformVerifier).build();
|
||||
let config = ureq::Agent::config_builder()
|
||||
.tls_config(tls)
|
||||
.https_only(true)
|
||||
.timeout_global(Some(Duration::from_secs(20)))
|
||||
.max_redirects(0)
|
||||
.user_agent("ArtCraft-Launcher-Build/1.0")
|
||||
.build();
|
||||
ureq::Agent::new_with_config(config)
|
||||
}
|
||||
|
||||
fn fetch_bytes(agent: &ureq::Agent, url: &str, max_bytes: usize) -> Result<Vec<u8>, String> {
|
||||
let mut response = agent.get(url).call().map_err(|e| format!("GET {url}: {e}"))?;
|
||||
let mut reader = response.body_mut().as_reader();
|
||||
let mut bytes = Vec::new();
|
||||
let mut limited = std::io::Read::take(&mut reader, (max_bytes + 1) as u64);
|
||||
std::io::Read::read_to_end(&mut limited, &mut bytes).map_err(|e| format!("read {url}: {e}"))?;
|
||||
if bytes.len() > max_bytes {
|
||||
return Err(format!("{url} exceeded {max_bytes} bytes"));
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
fn cache_dir(out_dir: &Path) -> PathBuf {
|
||||
if let Ok(explicit) = env::var("ARTCRAFT_CATALOG_CACHE_DIR")
|
||||
&& !explicit.trim().is_empty()
|
||||
{
|
||||
return PathBuf::from(explicit);
|
||||
}
|
||||
// Share the build cache across OUT_DIR hashes under Cargo's target directory.
|
||||
let mut ancestor = out_dir.to_path_buf();
|
||||
while let Some(parent) = ancestor.parent() {
|
||||
if ancestor.file_name().is_some_and(|n| n == "build")
|
||||
&& let Some(profile_dir) = ancestor.parent()
|
||||
&& let Some(target_dir) = profile_dir.parent()
|
||||
{
|
||||
return target_dir.join("artcraft-catalog-cache");
|
||||
}
|
||||
ancestor = parent.to_path_buf();
|
||||
}
|
||||
out_dir.join("catalog-cache")
|
||||
}
|
||||
|
||||
fn load_verified_catalog(agent: &ureq::Agent, cache: &Path, key: &VerifyingKey) -> Result<(Vec<u8>, Vec<u8>), Box<dyn Error>> {
|
||||
let cached_toml = cache.join("launcher-catalog.toml");
|
||||
let cached_sig = cache.join("launcher-catalog.toml.sig");
|
||||
|
||||
if let Ok(override_dir) = env::var("ARTCRAFT_CATALOG_DIR")
|
||||
&& !override_dir.trim().is_empty()
|
||||
{
|
||||
let dir = PathBuf::from(override_dir);
|
||||
let toml = fs::read(dir.join("launcher-catalog.toml"))?;
|
||||
let sig = fs::read(dir.join("launcher-catalog.toml.sig"))?;
|
||||
verify_signature(&toml, &sig, key)?;
|
||||
return Ok((toml, sig));
|
||||
}
|
||||
|
||||
let remote = (|| -> Result<(Vec<u8>, Vec<u8>), String> {
|
||||
let toml = fetch_bytes(agent, CATALOG_URL, MAX_CATALOG_BYTES)?;
|
||||
let sig = fetch_bytes(agent, SIGNATURE_URL, MAX_SIGNATURE_BYTES)?;
|
||||
verify_signature(&toml, &sig, key)?;
|
||||
Ok((toml, sig))
|
||||
})();
|
||||
|
||||
match remote {
|
||||
Ok((toml, sig)) => {
|
||||
let _ = fs::create_dir_all(cache);
|
||||
let _ = fs::write(&cached_toml, &toml);
|
||||
let _ = fs::write(&cached_sig, &sig);
|
||||
Ok((toml, sig))
|
||||
}
|
||||
Err(remote_err) => {
|
||||
if let (Ok(toml), Ok(sig)) = (fs::read(&cached_toml), fs::read(&cached_sig))
|
||||
&& verify_signature(&toml, &sig, key).is_ok()
|
||||
{
|
||||
println!("cargo:warning=Could not fetch {CATALOG_URL} ({remote_err}); using verified local cache.");
|
||||
return Ok((toml, sig));
|
||||
}
|
||||
Err(format!("Failed to fetch signed catalog from {CATALOG_URL} ({remote_err}) and no verified local cache exists").into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_verified_icon(agent: &ureq::Agent, cache: &Path, app: &App) -> Result<Vec<u8>, Box<dyn Error>> {
|
||||
let icons_cache = cache.join("icons");
|
||||
let cached_icon = icons_cache.join(format!("{}.png", app.icon_sha256));
|
||||
if let Ok(bytes) = fs::read(&cached_icon)
|
||||
&& sha256_hex(&bytes) == app.icon_sha256
|
||||
{
|
||||
return Ok(bytes);
|
||||
}
|
||||
|
||||
if let Ok(override_dir) = env::var("ARTCRAFT_CATALOG_DIR")
|
||||
&& !override_dir.trim().is_empty()
|
||||
{
|
||||
let candidate = PathBuf::from(override_dir).join("launcher-app-icons").join(format!("{}-{}.png", app.id, app.icon_sha256));
|
||||
if let Ok(bytes) = fs::read(&candidate)
|
||||
&& sha256_hex(&bytes) == app.icon_sha256
|
||||
{
|
||||
return Ok(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
let bytes = fetch_bytes(agent, &app.icon_url, MAX_ICON_BYTES)?;
|
||||
if sha256_hex(&bytes) != app.icon_sha256 {
|
||||
return Err(format!("icon SHA-256 mismatch for {} from {}", app.id, app.icon_url).into());
|
||||
}
|
||||
let _ = fs::create_dir_all(&icons_cache);
|
||||
let _ = fs::write(&cached_icon, &bytes);
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
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")?)?;
|
||||
println!("cargo:rerun-if-changed=assets/launcher-catalog-public-key.pem");
|
||||
println!("cargo:rerun-if-env-changed=ARTCRAFT_CATALOG_DIR");
|
||||
println!("cargo:rerun-if-env-changed=ARTCRAFT_CATALOG_CACHE_DIR");
|
||||
// The override directory's catalog, signature and icons can change under an unchanged value.
|
||||
if let Ok(override_dir) = env::var("ARTCRAFT_CATALOG_DIR")
|
||||
&& !override_dir.trim().is_empty()
|
||||
{
|
||||
println!("cargo:rerun-if-changed={override_dir}");
|
||||
}
|
||||
|
||||
let out = PathBuf::from(env::var_os("OUT_DIR").ok_or("OUT_DIR missing")?);
|
||||
let cache = cache_dir(&out);
|
||||
let key = VerifyingKey::from_public_key_pem(PUBLIC_KEY_PEM)?;
|
||||
let agent = build_agent();
|
||||
|
||||
let (catalog_bytes, sig_bytes) = load_verified_catalog(&agent, &cache, &key)?;
|
||||
let catalog_text = std::str::from_utf8(&catalog_bytes)?;
|
||||
let manifest: Manifest = toml::from_str(catalog_text)?;
|
||||
|
||||
fs::write(out.join("catalog.toml"), &catalog_bytes)?;
|
||||
fs::write(out.join("catalog.toml.sig"), &sig_bytes)?;
|
||||
|
||||
let out_icons = out.join("app-icons");
|
||||
fs::create_dir_all(&out_icons)?;
|
||||
|
||||
// Installer artwork uses the same verified catalog order, with no hard-coded app list.
|
||||
let installer_apps = manifest.apps.iter().filter(|app| app.kind == "official").map(|app| app.id.as_str()).collect::<Vec<_>>().join("\n");
|
||||
fs::write(out.join("installer-apps.txt"), installer_apps)?;
|
||||
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");
|
||||
let mut icons = String::from("fn bundled_app_icon_png(id: &str) -> Option<&'static [u8]> {\n Some(match id {\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()),
|
||||
};
|
||||
let icon_bytes = load_verified_icon(&agent, &cache, app)?;
|
||||
let icon_file = format!("{}.png", app.id);
|
||||
fs::write(out_icons.join(&icon_file), &icon_bytes)?;
|
||||
writeln!(icons, " {:?} => include_bytes!(concat!(env!(\"OUT_DIR\"), \"/app-icons/{icon_file}\")),", app.id)?;
|
||||
|
||||
writeln!(
|
||||
apps,
|
||||
"CraftApp {{ id: {:?}, name: {:?}, tagline: {:?}, color: {:?}, ink_light: {:?}, ink_dark: {:?}, repo: {:?}, former_repo: {}, former_ids: {}, former_names: {}, kind: AppKind::{kind}, publisher: {:?}, msi_publisher: {}, bundle: {}, former_bundles: {}, site: {}, mac_team: {}, mac_bundle_name: {} }},",
|
||||
@@ -106,8 +298,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
apps.push_str("];\n");
|
||||
details.push_str("];\n");
|
||||
let out = PathBuf::from(env::var_os("OUT_DIR").ok_or("OUT_DIR missing")?);
|
||||
icons.push_str(" _ => return None,\n })\n}\n");
|
||||
|
||||
fs::write(out.join("catalog.rs"), apps)?;
|
||||
fs::write(out.join("details.rs"), details)?;
|
||||
fs::write(out.join("app_icons.rs"), icons)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -220,35 +220,15 @@ pub const LAUNCHER_REPO: &str = "storytold/craft-launcher";
|
||||
/// The launcher's own asset stem.
|
||||
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.
|
||||
include!(concat!(env!("OUT_DIR"), "/app_icons.rs"));
|
||||
|
||||
/// A Craft App's 128 px icon (PNG), fetched from the signed hosted catalog (or build-time cache):
|
||||
/// 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"),
|
||||
"vectorcraft" => include_bytes!("../../../assets/app-icons/vectorcraft.png"),
|
||||
"filmcraft" => include_bytes!("../../../assets/app-icons/filmcraft.png"),
|
||||
"lightcraft" => include_bytes!("../../../assets/app-icons/lightcraft.png"),
|
||||
"pdfcraft" => include_bytes!("../../../assets/app-icons/pdfcraft.png"),
|
||||
"effectcraft" => include_bytes!("../../../assets/app-icons/effectcraft.png"),
|
||||
"anicraft" => include_bytes!("../../../assets/app-icons/anicraft.png"),
|
||||
"designcraft" => include_bytes!("../../../assets/app-icons/designcraft.png"),
|
||||
"wordcraft" => include_bytes!("../../../assets/app-icons/wordcraft.png"),
|
||||
"deckcraft" => include_bytes!("../../../assets/app-icons/deckcraft.png"),
|
||||
"gridcraft" => include_bytes!("../../../assets/app-icons/gridcraft.png"),
|
||||
"texturecraft" => include_bytes!("../../../assets/app-icons/texturecraft.png"),
|
||||
"materialcraft" => include_bytes!("../../../assets/app-icons/materialcraft.png"),
|
||||
"craft-anything" => include_bytes!("../../../assets/app-icons/craft-anything.png"),
|
||||
"solidcraft" => include_bytes!("../../../assets/app-icons/solidcraft.png"),
|
||||
"mailcraft" => include_bytes!("../../../assets/app-icons/mailcraft.png"),
|
||||
"cadcraft" => include_bytes!("../../../assets/app-icons/cadcraft.png"),
|
||||
"soundcraft" => include_bytes!("../../../assets/app-icons/soundcraft.png"),
|
||||
"figcraft" => include_bytes!("../../../assets/app-icons/figcraft.png"),
|
||||
_ => return None,
|
||||
})
|
||||
bundled_app_icon_png(id)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -327,7 +307,12 @@ mod tests {
|
||||
fn mailcraft_is_a_community_app_not_installed_on_mac() {
|
||||
let mc = CraftApp::by_id("mailcraft").unwrap();
|
||||
assert_eq!(mc.kind, AppKind::Community);
|
||||
assert_eq!((mc.repo, mc.former_repo), ("UCSLabs/mailcraft", Some("UCS-Care-Group/mailcraft")));
|
||||
assert!(
|
||||
matches!((mc.repo, mc.former_repo), ("UCSLabs/mailcraft", Some("UCS-Care-Group/mailcraft")) | ("UCS-Care-Group/mailcraft", None)),
|
||||
"unexpected mailcraft repo: ({:?}, {:?})",
|
||||
mc.repo,
|
||||
mc.former_repo
|
||||
);
|
||||
assert_eq!(mc.bundle_id(), "io.github.billsecond.mailcraft");
|
||||
assert_eq!(mc.website(), "https://mailcraft.work");
|
||||
assert!(!mc.installs(crate::PackageKind::Dmg));
|
||||
@@ -350,7 +335,11 @@ mod tests {
|
||||
assert_eq!(app.kind, AppKind::Official);
|
||||
assert_eq!(app.repo, "storytold/materialcraft");
|
||||
assert_eq!(app.bundle_id(), "ai.storyteller.materialcraft");
|
||||
assert_eq!(app.website(), "https://getartcraft.com/apps/materialcraft");
|
||||
assert!(
|
||||
matches!(app.website().as_str(), "https://getartcraft.com/apps/materialcraft" | "https://github.com/storytold/materialcraft"),
|
||||
"unexpected materialcraft website: {}",
|
||||
app.website()
|
||||
);
|
||||
assert_eq!(app.mac_team, Some(ARTCRAFT_TEAM_ID));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,10 +46,12 @@ const fn feature(title: &'static str, text: &'static str) -> Feature {
|
||||
|
||||
/// Where the pictures live: one 1200 px wide, 8:5 JPEG per [`Shot`], at `<app>/<key>.jpg`.
|
||||
///
|
||||
/// Primary host is `getartcraft.com`; GitHub (`SCREENSHOTS_FALLBACK_BASE`) is the fallback.
|
||||
/// Pinned to a tag (`SCREENSHOTS_REV`) so that what a launcher fetches never changes under it, and
|
||||
/// so that a saved copy never goes stale. To change a picture, publish a new tag and bump the
|
||||
/// revision: older launchers keep working from the tag they know.
|
||||
pub const SCREENSHOTS_BASE: &str = "https://raw.githubusercontent.com/storytold/craft-launcher-assets";
|
||||
/// so that a saved copy never goes stale.
|
||||
pub const SCREENSHOTS_BASE: &str = "https://getartcraft.com/launcher-screenshots";
|
||||
/// GitHub fallback host for screenshots when `getartcraft.com` is unavailable.
|
||||
pub const SCREENSHOTS_FALLBACK_BASE: &str = "https://raw.githubusercontent.com/storytold/craft-launcher-assets";
|
||||
|
||||
/// The tag of the pictures repository the launcher reads. Also part of the saved copies' path.
|
||||
pub const SCREENSHOTS_REV: &str = "v1";
|
||||
@@ -138,12 +140,17 @@ pub fn screenshot_within_budget(bytes: &[u8]) -> bool {
|
||||
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.
|
||||
/// The only way to turn a request into an address: callers never build one from their own text.
|
||||
/// Where the picture `key` of this app is published on `getartcraft.com`, or `None` if the
|
||||
/// page has no such picture.
|
||||
pub fn screenshot_url(&self, key: &str) -> Option<String> {
|
||||
self.shots.iter().find(|s| s.key == key).map(|s| format!("{SCREENSHOTS_BASE}/{SCREENSHOTS_REV}/{}/{}.jpg", self.id, s.key))
|
||||
}
|
||||
|
||||
/// Fallback GitHub URL for picture `key` when `getartcraft.com` is unavailable.
|
||||
pub fn screenshot_fallback_url(&self, key: &str) -> Option<String> {
|
||||
self.shots.iter().find(|s| s.key == key).map(|s| format!("{SCREENSHOTS_FALLBACK_BASE}/{SCREENSHOTS_REV}/{}/{}.jpg", self.id, s.key))
|
||||
}
|
||||
|
||||
pub fn by_id(id: &str) -> Option<&'static AppDetails> {
|
||||
crate::hosted_catalog::details(id).or_else(|| DETAILS.iter().find(|d| d.id == id))
|
||||
}
|
||||
@@ -179,8 +186,9 @@ mod tests {
|
||||
#[test]
|
||||
fn picture_addresses_come_only_from_the_pages_own_pictures() {
|
||||
let page = AppDetails::by_id("photocraft").unwrap();
|
||||
assert_eq!(page.screenshot_url("demo").as_deref(), Some("https://getartcraft.com/launcher-screenshots/v1/photocraft/demo.jpg"));
|
||||
assert_eq!(
|
||||
page.screenshot_url("demo").as_deref(),
|
||||
page.screenshot_fallback_url("demo").as_deref(),
|
||||
Some("https://raw.githubusercontent.com/storytold/craft-launcher-assets/v1/photocraft/demo.jpg")
|
||||
);
|
||||
for key in ["", "nope", "../vectorcraft/neon", "demo/../masks", "demo.jpg", "/etc/passwd", "demo?x=1", "demo#"] {
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
//! The release feed from storyteller-web: `GET https://api.storyteller.ai/v1/craft_apps/release_info`.
|
||||
//! The release feed from the signed website catalog:
|
||||
//! `GET https://getartcraft.com/launcher-catalog.toml` and `.sig`.
|
||||
//!
|
||||
//! storyteller-web polls GitHub for every Craft App on a schedule and serves the result, so the
|
||||
//! launcher doesn't have to (GitHub allows 60 unauthenticated requests an hour). GitHub stays the
|
||||
//! fallback: for apps the feed doesn't list, apps it hasn't fetched within [`MAX_AGE`], or when
|
||||
//! the feed doesn't answer.
|
||||
//! The website build statically generates each app's stable, prerelease, and nightly release
|
||||
//! metadata into `launcher-catalog.toml` and signs it with the pinned Ed25519 key, so the
|
||||
//! launcher doesn't have to poll GitHub (which allows 60 unauthenticated requests an hour).
|
||||
//! GitHub stays the fallback: for apps or channels the catalog doesn't list, entries older than
|
||||
//! [`MAX_AGE`], or when the catalog doesn't answer or fails signature verification.
|
||||
//!
|
||||
//! The feed is input like any other: every field is optional, unknown fields are ignored, a field
|
||||
//! of the wrong type reads as missing, one bad entry never spoils the others, and download links
|
||||
//! must still point at the app's own GitHub releases.
|
||||
//!
|
||||
//! A developer can serve the feed and the builds from their own machine instead (see
|
||||
//! [`Feed::with_mirror`]): then links under the mirror are accepted too, and entries never go stale.
|
||||
//! A developer can still serve a JSON feed and builds from their own machine instead (see
|
||||
//! [`Feed::parse`] and [`Feed::with_mirror`]): then links under the mirror are accepted too, and
|
||||
//! entries never go stale.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use ed25519_dalek::VerifyingKey;
|
||||
use serde::Deserialize;
|
||||
use serde::de::{DeserializeOwned, Deserializer};
|
||||
|
||||
use crate::catalog::{CraftApp, GITHUB_OWNER};
|
||||
use crate::hosted_catalog::{CATALOG_URL, MAX_CATALOG_BYTES, SIGNATURE_URL, check_signature, pinned_key};
|
||||
use crate::release::{self, Asset, Release, truncate};
|
||||
use crate::time::parse_rfc3339;
|
||||
use crate::version;
|
||||
|
||||
/// Where the feed lives.
|
||||
pub const FEED_URL: &str = "https://api.storyteller.ai/v1/craft_apps/release_info";
|
||||
/// Where the signed release catalog lives.
|
||||
pub const FEED_URL: &str = CATALOG_URL;
|
||||
/// Detached Ed25519 signature over [`FEED_URL`].
|
||||
pub const FEED_SIGNATURE_URL: &str = SIGNATURE_URL;
|
||||
|
||||
/// An app's entry is trusted for this long after storyteller-web fetched it.
|
||||
pub const MAX_AGE: i64 = 24 * 3600;
|
||||
@@ -33,6 +36,8 @@ pub const MAX_AGE: i64 = 24 * 3600;
|
||||
pub struct Feed {
|
||||
/// By lowercase app name.
|
||||
pub apps: BTreeMap<String, FeedApp>,
|
||||
/// Catalog TOML explicitly describes release channels; legacy JSON only describes stable.
|
||||
pub channel_aware: bool,
|
||||
/// When the least recently fetched app was fetched (Unix seconds).
|
||||
pub last_fetched: Option<i64>,
|
||||
pub app_renames: Vec<AppRename>,
|
||||
@@ -46,9 +51,13 @@ pub struct Feed {
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct FeedApp {
|
||||
pub repo: Option<String>,
|
||||
/// Present when the repo has a published release. Meaningless unless `fetched_at` is set.
|
||||
/// Present when the repo has a published stable release. Meaningless unless `fetched_at` is set.
|
||||
pub release: Option<FeedRelease>,
|
||||
/// When storyteller-web last fetched this app (Unix seconds).
|
||||
/// Present when the repo has a published non-nightly prerelease (beta/RC).
|
||||
pub prerelease: Option<FeedRelease>,
|
||||
/// Present when the repo has a published nightly build.
|
||||
pub nightly: Option<FeedRelease>,
|
||||
/// When the catalog or feed last fetched this app (Unix seconds).
|
||||
pub fetched_at: Option<i64>,
|
||||
}
|
||||
|
||||
@@ -94,11 +103,45 @@ pub enum FeedAnswer {
|
||||
const MAX_TEXT: usize = 4000;
|
||||
|
||||
impl Feed {
|
||||
/// Reads the feed. `None` only when the answer isn't JSON (or isn't an object) at all.
|
||||
/// Verifies the detached Ed25519 signature over `launcher-catalog.toml` using the pinned
|
||||
/// public key and extracts its static release channels.
|
||||
pub fn parse_signed_catalog(catalog_bytes: &[u8], signature_bytes: &[u8]) -> Result<Self, String> {
|
||||
Self::parse_signed_catalog_with_key(catalog_bytes, signature_bytes, &pinned_key()?)
|
||||
}
|
||||
|
||||
/// Like [`Self::parse_signed_catalog`], using an explicit verifying key (tests).
|
||||
pub fn parse_signed_catalog_with_key(catalog_bytes: &[u8], signature_bytes: &[u8], key: &VerifyingKey) -> Result<Self, String> {
|
||||
check_signature(catalog_bytes, signature_bytes, MAX_CATALOG_BYTES, key)?;
|
||||
let text = std::str::from_utf8(catalog_bytes).map_err(|_| "catalog is not UTF-8")?;
|
||||
Self::parse_catalog_toml(text)
|
||||
}
|
||||
|
||||
/// Reads release metadata from an already-verified `launcher-catalog.toml` document.
|
||||
pub fn parse_catalog_toml(toml_text: &str) -> Result<Self, String> {
|
||||
let doc: CatalogDocument = toml::from_str(toml_text).map_err(|e| format!("invalid catalog TOML: {e}"))?;
|
||||
let generated_at = doc.generated_at.as_deref().and_then(parse_rfc3339);
|
||||
let mut apps = BTreeMap::new();
|
||||
if let Some(launcher) = doc.launcher {
|
||||
let id = launcher.id.unwrap_or_else(|| "artcraft-launcher".into()).to_lowercase();
|
||||
if let Some(entry) = launcher.releases.and_then(|r| r.into_feed_app(launcher.repo, generated_at)) {
|
||||
apps.insert(id, entry);
|
||||
}
|
||||
}
|
||||
for app in doc.apps {
|
||||
let Some(id) = app.id.filter(|s| !s.is_empty()) else { continue };
|
||||
if let Some(entry) = app.releases.and_then(|r| r.into_feed_app(app.repo, generated_at)) {
|
||||
apps.insert(id.to_lowercase(), entry);
|
||||
}
|
||||
}
|
||||
Ok(Self { apps, channel_aware: true, last_fetched: generated_at, app_renames: Vec::new(), repo_renames: Vec::new(), mirror: None })
|
||||
}
|
||||
|
||||
/// Reads the legacy/local-mirror JSON feed. `None` only when the answer isn't JSON (or isn't an object) at all.
|
||||
pub fn parse(json: &str) -> Option<Self> {
|
||||
let raw: RawResponse = serde_json::from_str(json).ok()?;
|
||||
let feed = Feed {
|
||||
apps: raw.release_info.apps.into_iter().map(|(k, v)| (k.to_lowercase(), v.into_app())).collect(),
|
||||
channel_aware: false,
|
||||
last_fetched: raw.release_info.last_fetched.as_deref().and_then(parse_rfc3339),
|
||||
app_renames: raw.app_renames.into_iter().filter_map(RawAppRename::into_rename).collect(),
|
||||
repo_renames: raw.repo_renames.into_iter().filter_map(RawRepoRename::into_rename).collect(),
|
||||
@@ -159,6 +202,56 @@ impl Feed {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// What the feed says about `app` when pre-releases are enabled: the higher version between
|
||||
/// `stable` and `prerelease`, or `AskGitHub` if neither is fresh/valid.
|
||||
pub fn answer_prerelease(&self, app: &CraftApp, now: i64) -> FeedAnswer {
|
||||
let Some((entry, repo)) = self.fresh_entry(app, now) else { return FeedAnswer::AskGitHub };
|
||||
let stable = entry.release.as_ref().and_then(|r| r.to_release(&repo, self.mirror.as_deref()));
|
||||
let pre = entry.prerelease.as_ref().and_then(|r| r.to_release(&repo, self.mirror.as_deref()));
|
||||
match (stable, pre) {
|
||||
(Some(s), Some(p)) => {
|
||||
let pick_pre = match (&p.version, &s.version) {
|
||||
(Some(pv), Some(sv)) => version::is_newer(pv, sv),
|
||||
_ => false,
|
||||
};
|
||||
FeedAnswer::Fresh(Some(if pick_pre { p } else { s }))
|
||||
}
|
||||
(Some(s), None) => FeedAnswer::Fresh(Some(s)),
|
||||
(None, Some(p)) => FeedAnswer::Fresh(Some(p)),
|
||||
(None, None) => FeedAnswer::AskGitHub,
|
||||
}
|
||||
}
|
||||
|
||||
/// What the feed says about `app`'s nightly build at `now`. Returns `AskGitHub` when no fresh
|
||||
/// nightly with valid checksums is listed.
|
||||
pub fn answer_nightly(&self, app: &CraftApp, now: i64) -> FeedAnswer {
|
||||
let Some((entry, repo)) = self.fresh_entry(app, now) else { return FeedAnswer::AskGitHub };
|
||||
let Some(nightly) = entry.nightly.as_ref().and_then(|r| r.to_release(&repo, self.mirror.as_deref())) else {
|
||||
return FeedAnswer::AskGitHub;
|
||||
};
|
||||
if release::is_nightly(&nightly) && release::has_published_checksum(&nightly) {
|
||||
FeedAnswer::Fresh(Some(nightly))
|
||||
} else {
|
||||
FeedAnswer::AskGitHub
|
||||
}
|
||||
}
|
||||
|
||||
fn fresh_entry(&self, app: &CraftApp, now: i64) -> Option<(&FeedApp, String)> {
|
||||
let entry = self.apps.get(app.id)?;
|
||||
let fetched_at = entry.fetched_at?;
|
||||
if self.mirror.is_none() && now.saturating_sub(fetched_at) > MAX_AGE {
|
||||
return None;
|
||||
}
|
||||
let mut repo = self.repo_for(app);
|
||||
if let Some(feed_repo) = &entry.repo
|
||||
&& !feed_repo.eq_ignore_ascii_case(&repo)
|
||||
{
|
||||
let former = app.former_repo.filter(|former| feed_repo.eq_ignore_ascii_case(former))?;
|
||||
repo = former.to_string();
|
||||
}
|
||||
Some((entry, repo))
|
||||
}
|
||||
}
|
||||
|
||||
impl FeedRelease {
|
||||
@@ -201,6 +294,111 @@ impl FeedRelease {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- signed catalog TOML format ---------------------------------------------------------------
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct CatalogDocument {
|
||||
#[serde(default)]
|
||||
generated_at: Option<String>,
|
||||
#[serde(default)]
|
||||
launcher: Option<CatalogLauncher>,
|
||||
#[serde(default)]
|
||||
apps: Vec<CatalogApp>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct CatalogLauncher {
|
||||
#[serde(default)]
|
||||
id: Option<String>,
|
||||
#[serde(default)]
|
||||
repo: Option<String>,
|
||||
#[serde(default)]
|
||||
releases: Option<CatalogReleases>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct CatalogApp {
|
||||
#[serde(default)]
|
||||
id: Option<String>,
|
||||
#[serde(default)]
|
||||
repo: Option<String>,
|
||||
#[serde(default)]
|
||||
releases: Option<CatalogReleases>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct CatalogReleases {
|
||||
#[serde(default)]
|
||||
stable: Option<CatalogRelease>,
|
||||
#[serde(default)]
|
||||
prerelease: Option<CatalogRelease>,
|
||||
#[serde(default)]
|
||||
nightly: Option<CatalogRelease>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct CatalogRelease {
|
||||
#[serde(default)]
|
||||
tag: Option<String>,
|
||||
#[serde(default)]
|
||||
name: Option<String>,
|
||||
#[serde(default)]
|
||||
published_at: Option<String>,
|
||||
#[serde(default)]
|
||||
html_url: Option<String>,
|
||||
#[serde(default)]
|
||||
prerelease: bool,
|
||||
#[serde(default)]
|
||||
notes_markdown: Option<String>,
|
||||
#[serde(default)]
|
||||
assets: Vec<CatalogAsset>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct CatalogAsset {
|
||||
#[serde(default)]
|
||||
name: Option<String>,
|
||||
#[serde(default)]
|
||||
size_bytes: u64,
|
||||
#[serde(default)]
|
||||
download_url: Option<String>,
|
||||
#[serde(default)]
|
||||
sha256: Option<String>,
|
||||
}
|
||||
|
||||
impl CatalogRelease {
|
||||
fn into_feed_release(self) -> Option<FeedRelease> {
|
||||
let tag = self.tag.filter(|t| !t.is_empty() && t.len() <= 64)?;
|
||||
Some(FeedRelease {
|
||||
tag,
|
||||
name: self.name.unwrap_or_default(),
|
||||
published_at: self.published_at.as_deref().and_then(parse_rfc3339),
|
||||
html_url: self.html_url.unwrap_or_default(),
|
||||
prerelease: self.prerelease,
|
||||
notes: self.notes_markdown.unwrap_or_default(),
|
||||
assets: self.assets.into_iter().filter_map(|a| Some((a.name?, a.size_bytes, a.download_url?, a.sha256))).take(300).collect(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl CatalogReleases {
|
||||
fn into_feed_app(self, repo: Option<String>, fetched_at: Option<i64>) -> Option<FeedApp> {
|
||||
let release = self.stable.and_then(CatalogRelease::into_feed_release);
|
||||
let prerelease = self.prerelease.and_then(CatalogRelease::into_feed_release);
|
||||
let nightly = self.nightly.and_then(CatalogRelease::into_feed_release);
|
||||
if release.is_none() && prerelease.is_none() && nightly.is_none() {
|
||||
return None;
|
||||
}
|
||||
Some(FeedApp {
|
||||
repo: repo.filter(|r| r.split('/').count() == 2 && r.split('/').all(|part| !part.is_empty() && part != "." && part != "..")),
|
||||
release,
|
||||
prerelease,
|
||||
nightly,
|
||||
fetched_at,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ---- lenient wire format ----------------------------------------------------------------------
|
||||
|
||||
/// Reads `T`, or its default when the value is missing, `null` or the wrong shape.
|
||||
@@ -260,6 +458,8 @@ impl RawApp {
|
||||
FeedApp {
|
||||
repo: self.repo.filter(|r| r.split('/').count() == 2 && r.split('/').all(|part| !part.is_empty() && part != "." && part != "..")),
|
||||
release: self.latest_release.and_then(RawRelease::into_release),
|
||||
prerelease: None,
|
||||
nightly: None,
|
||||
fetched_at: self.app_last_fetched.as_deref().and_then(parse_rfc3339),
|
||||
}
|
||||
}
|
||||
@@ -443,8 +643,11 @@ mod tests {
|
||||
// MailCraft moved from `UCS-Care-Group` to `UCSLabs` (#1593): a feed still naming the former
|
||||
// repo is used, with downloads checked against that repo, and "no release" under one name
|
||||
// sends the launcher to GitHub, where the other name is asked too.
|
||||
let mailcraft = app("mailcraft");
|
||||
let former = mailcraft.former_repo.unwrap();
|
||||
let mut mailcraft = *app("mailcraft");
|
||||
mailcraft.repo = "UCSLabs/mailcraft";
|
||||
mailcraft.former_repo = Some("UCS-Care-Group/mailcraft");
|
||||
let mailcraft = &mailcraft;
|
||||
let former = "UCS-Care-Group/mailcraft";
|
||||
let entry = |repo: &str, release: &str| {
|
||||
format!(
|
||||
r#"{{"release_info": {{"apps": {{"mailcraft": {{"repo": "{repo}", "app_last_fetched": "2026-10-09T13:00:00Z", "latest_release": {release}}}}}}}}}"#
|
||||
@@ -589,4 +792,96 @@ mod tests {
|
||||
assert_eq!(Feed::parse(&feed).unwrap().answer(app("photocraft"), NOW), FeedAnswer::AskGitHub, "{odd:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_channels_fall_back_independently_and_empty_records_are_ignored() {
|
||||
let photo = app("photocraft");
|
||||
let parsed = |channels: &str| {
|
||||
Feed::parse_catalog_toml(&format!(
|
||||
"generated_at = \"2026-10-09T13:00:00Z\"\n[[apps]]\nid = \"photocraft\"\nrepo = \"storytold/photocraft\"\n{channels}"
|
||||
))
|
||||
.unwrap()
|
||||
};
|
||||
let stable = parsed("[apps.releases.stable]\ntag = \"v1.0.0\"\n");
|
||||
assert!(matches!(stable.answer_prerelease(photo, NOW), FeedAnswer::Fresh(Some(r)) if r.tag == "v1.0.0"));
|
||||
assert_eq!(stable.answer_nightly(photo, NOW), FeedAnswer::AskGitHub);
|
||||
let pre = parsed("[apps.releases.prerelease]\ntag = \"v1.1.0-rc.1\"\n");
|
||||
assert!(matches!(pre.answer_prerelease(photo, NOW), FeedAnswer::Fresh(Some(r)) if r.tag == "v1.1.0-rc.1"));
|
||||
let empty = parsed("[apps.releases]\n");
|
||||
assert!(empty.apps.is_empty());
|
||||
assert_eq!(empty.answer_prerelease(photo, NOW), FeedAnswer::AskGitHub);
|
||||
assert_eq!(pre.answer_prerelease(photo, NOW + MAX_AGE * 2), FeedAnswer::AskGitHub);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_catalog_toml_answers_stable_prerelease_nightly_and_launcher() {
|
||||
use base64::{Engine as _, engine::general_purpose::STANDARD};
|
||||
use ed25519_dalek::{Signer as _, SigningKey};
|
||||
|
||||
let toml = format!(
|
||||
r#"generated_at = "2026-10-09T13:00:00Z"
|
||||
|
||||
[launcher]
|
||||
id = "artcraft-launcher"
|
||||
repo = "storytold/craft-launcher"
|
||||
[launcher.releases.stable]
|
||||
tag = "v0.20.4"
|
||||
version = "0.20.4"
|
||||
html_url = "https://github.com/storytold/craft-launcher/releases/tag/v0.20.4"
|
||||
prerelease = false
|
||||
[[launcher.releases.stable.assets]]
|
||||
name = "artcraft-launcher-0.20.4-macos-universal.dmg"
|
||||
download_url = "https://github.com/storytold/craft-launcher/releases/download/v0.20.4/artcraft-launcher-0.20.4-macos-universal.dmg"
|
||||
sha256 = "{HASH}"
|
||||
|
||||
[[apps]]
|
||||
id = "photocraft"
|
||||
repo = "storytold/photocraft"
|
||||
[apps.releases.stable]
|
||||
tag = "v0.23.1"
|
||||
version = "0.23.1"
|
||||
html_url = "https://github.com/storytold/photocraft/releases/tag/v0.23.1"
|
||||
prerelease = false
|
||||
[[apps.releases.stable.assets]]
|
||||
name = "photocraft-0.23.1-macos-universal.dmg"
|
||||
download_url = "https://github.com/storytold/photocraft/releases/download/v0.23.1/photocraft-0.23.1-macos-universal.dmg"
|
||||
sha256 = "{HASH}"
|
||||
[apps.releases.prerelease]
|
||||
tag = "v0.24.0-rc.1"
|
||||
version = "0.24.0-rc.1"
|
||||
html_url = "https://github.com/storytold/photocraft/releases/tag/v0.24.0-rc.1"
|
||||
prerelease = true
|
||||
[apps.releases.nightly]
|
||||
tag = "v0.24.0-nightly.20261009.1.1"
|
||||
version = "0.24.0-nightly.20261009.1.1"
|
||||
html_url = "https://github.com/storytold/photocraft/releases/tag/v0.24.0-nightly.20261009.1.1"
|
||||
prerelease = true
|
||||
[[apps.releases.nightly.assets]]
|
||||
name = "photocraft-0.24.0-nightly.20261009.1.1-linux-x86_64.AppImage"
|
||||
download_url = "https://github.com/storytold/photocraft/releases/download/v0.24.0-nightly.20261009.1.1/photocraft-0.24.0-nightly.20261009.1.1-linux-x86_64.AppImage"
|
||||
sha256 = "{HASH}"
|
||||
"#
|
||||
);
|
||||
let key = SigningKey::from_bytes(&[7; 32]);
|
||||
let sig = STANDARD.encode(key.sign(toml.as_bytes()).to_bytes());
|
||||
let feed = Feed::parse_signed_catalog_with_key(toml.as_bytes(), sig.as_bytes(), &key.verifying_key()).unwrap();
|
||||
|
||||
let FeedAnswer::Fresh(Some(launcher)) = feed.answer(&LAUNCHER, NOW) else { panic!() };
|
||||
assert_eq!(launcher.tag, "v0.20.4");
|
||||
|
||||
let FeedAnswer::Fresh(Some(stable)) = feed.answer(app("photocraft"), NOW) else { panic!() };
|
||||
assert_eq!(stable.tag, "v0.23.1");
|
||||
assert_eq!(stable.assets.len(), 1);
|
||||
|
||||
let FeedAnswer::Fresh(Some(pre)) = feed.answer_prerelease(app("photocraft"), NOW) else { panic!() };
|
||||
assert_eq!(pre.tag, "v0.24.0-rc.1");
|
||||
|
||||
let FeedAnswer::Fresh(Some(nightly)) = feed.answer_nightly(app("photocraft"), NOW) else { panic!() };
|
||||
assert_eq!(nightly.tag, "v0.24.0-nightly.20261009.1.1");
|
||||
|
||||
// Tampering or wrong key is rejected before parsing.
|
||||
let wrong_key = SigningKey::from_bytes(&[9; 32]);
|
||||
assert!(Feed::parse_signed_catalog_with_key(toml.as_bytes(), sig.as_bytes(), &wrong_key.verifying_key()).is_err());
|
||||
assert!(Feed::parse_signed_catalog_with_key(format!("{toml}\n").as_bytes(), sig.as_bytes(), &key.verifying_key()).is_err());
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,10 @@ 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");
|
||||
/// Signed catalog bytes fetched and verified at build time from [`CATALOG_URL`].
|
||||
pub const BUILD_CATALOG_TOML: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/catalog.toml"));
|
||||
/// Detached Ed25519 signature fetched and verified at build time from [`SIGNATURE_URL`].
|
||||
pub const BUILD_CATALOG_SIG: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/catalog.toml.sig"));
|
||||
pub const MAX_CATALOG_BYTES: usize = 1 << 20;
|
||||
pub const MAX_SIGNATURE_BYTES: usize = 128;
|
||||
pub const MAX_ICON_BYTES: usize = 256 << 10;
|
||||
@@ -335,7 +339,9 @@ fn valid_record(r: &Record) -> bool {
|
||||
&& 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)
|
||||
&& (s.url == format!("{}/{}/{}/{}.jpg", crate::details::SCREENSHOTS_BASE, crate::details::SCREENSHOTS_REV, r.id, s.key)
|
||||
|| s.url
|
||||
== format!("{}/{}/{}/{}.jpg", crate::details::SCREENSHOTS_FALLBACK_BASE, crate::details::SCREENSHOTS_REV, r.id, s.key))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -355,9 +361,9 @@ 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");
|
||||
const BUNDLED: &[u8] = BUILD_CATALOG_TOML;
|
||||
const WEBSITE: &[u8] = BUILD_CATALOG_TOML;
|
||||
const SIGNATURE: &[u8] = BUILD_CATALOG_SIG;
|
||||
|
||||
fn signed(bytes: &[u8]) -> Result<VerifiedCatalog, String> {
|
||||
let key = SigningKey::from_bytes(&[7; 32]);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1aCd92qni/Hq22Lh0HNYXL6JT+gpJia1MNhjMcPJsY0uuAeio0fjOszFmqhBDgviX5ff6dfHLkfgIjnyYoChBA==
|
||||
@@ -636,10 +636,10 @@ impl NativeBackend {
|
||||
}
|
||||
let options = self.options();
|
||||
let pre = options.prereleases;
|
||||
let feed = if pre { None } else { load_feed(&self.paths) };
|
||||
let feed = load_feed(&self.paths);
|
||||
let now = crate::now();
|
||||
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)) {
|
||||
let answer = match feed.as_ref().map(|f| if pre { f.answer_prerelease(app, now) } else { f.answer(app, now) }) {
|
||||
Some(FeedAnswer::Fresh(Some(r))) => Some((LatestRelease::Found(r), Origin::ArtCraftApi)),
|
||||
Some(FeedAnswer::Fresh(None)) => Some((LatestRelease::None, Origin::ArtCraftApi)),
|
||||
_ => self.source.as_ref().and_then(|s| s.cached(&release_query(feed.as_ref(), app), pre)).map(|l| (l, Origin::GitHub)),
|
||||
@@ -734,6 +734,9 @@ impl NativeBackend {
|
||||
self.check_nightly_at(manual, crate::now());
|
||||
}
|
||||
|
||||
// Deliberately use the GitHub Nightly verifier for automatic installation/update checks.
|
||||
// Signed catalog entries are discovery hints; they cannot replace the separately verified
|
||||
// platform-specific Nightly descriptor, checksum, publication and rollback checks.
|
||||
fn check_nightly_at(&self, manual: bool, now: i64) {
|
||||
let Some(platform) = self.platform else { return };
|
||||
let apps = self.nightly_apps();
|
||||
@@ -2170,6 +2173,12 @@ fn planned_download(
|
||||
/// What one check asks: which feed to poll (a local mirror trumps everything), and how much to
|
||||
/// lean on GitHub.
|
||||
fn check_plan(http: &Http, mirror: Option<&String>, pre: bool, paths: &Paths, shared: &Arc<Shared>) -> (Option<Feed>, Fallback) {
|
||||
// Backend harnesses use a stub release source; do not let current production releases
|
||||
// supersede the fixture. The signed catalog paths have their own deterministic tests.
|
||||
#[cfg(test)]
|
||||
if matches!(&shared.host, HostDetection::Stub(_)) {
|
||||
return (None, Fallback { trust_feed: false, github_every: EARLY_GITHUB_EVERY });
|
||||
}
|
||||
if let Some(base) = mirror {
|
||||
// A local mirror answers for everything: GitHub is never asked.
|
||||
(local_feed(http, base), Fallback { trust_feed: true, github_every: GITHUB_FALLBACK_EVERY })
|
||||
@@ -2178,12 +2187,10 @@ fn check_plan(http: &Http, mirror: Option<&String>, pre: bool, paths: &Paths, sh
|
||||
}
|
||||
}
|
||||
|
||||
/// [`check_plan`] without a local mirror, given what the feed said. The feed serves stable
|
||||
/// releases only, so with pre-releases on it can't settle an answer that may be a beta or RC. It
|
||||
/// still stands in between GitHub's asks, which keep to the feed's own pace (hourly per app once
|
||||
/// everything has loaded), not every check (#713).
|
||||
/// The signed catalog describes all channels; legacy JSON only settles stable answers.
|
||||
/// Keep GitHub prerelease discovery for legacy feeds at the normal fallback pace (#713).
|
||||
fn remote_plan(pre: bool, (feed, fallback): (Option<Feed>, Fallback)) -> (Option<Feed>, Fallback) {
|
||||
if pre { (feed, Fallback { trust_feed: false, ..fallback }) } else { (feed, fallback) }
|
||||
if pre && !feed.as_ref().is_some_and(|f| f.channel_aware) { (feed, Fallback { trust_feed: false, ..fallback }) } else { (feed, fallback) }
|
||||
}
|
||||
|
||||
/// Answers the apps from a shared queue over a few workers, and returns which sources answered.
|
||||
@@ -2373,7 +2380,7 @@ fn latest_for(
|
||||
) -> (Option<LatestRelease>, Origin, Option<Source>) {
|
||||
let repo = feed_repo(feed, app);
|
||||
if fallback.trust_feed {
|
||||
match feed.map(|f| f.answer(app, now)) {
|
||||
match feed.map(|f| if pre { f.answer_prerelease(app, now) } else { f.answer(app, now) }) {
|
||||
// The feed can lag GitHub by some minutes after a release. A check the user pressed
|
||||
// looks past it when GitHub's quota-free redirect names something newer (#91); one
|
||||
// reusing the last forced check's answers then takes GitHub's saved answer.
|
||||
@@ -2400,7 +2407,7 @@ fn latest_for(
|
||||
// GitHub couldn't answer (its limit, the launcher's budget, the network), or fell back
|
||||
// to a saved release older than the feed's: the feed's stable release stands.
|
||||
let live = answer.source == Source::GitHubApi && !matches!(answer.latest, LatestRelease::Failed(_));
|
||||
if !live && let Some(stable) = feed_if_newer(feed, app, now, Some(&answer.latest)) {
|
||||
if !live && let Some(stable) = feed_if_newer(feed, app, pre, now, Some(&answer.latest)) {
|
||||
return (Some(LatestRelease::Found(stable)), Origin::ArtCraftApi, Some(Source::Feed));
|
||||
}
|
||||
(Some(answer.latest), Origin::GitHub, Some(answer.source))
|
||||
@@ -2410,17 +2417,20 @@ fn latest_for(
|
||||
// named last time, without waiting for GitHub's next turn; so does it when nothing is
|
||||
// saved from GitHub for this track yet (pre-releases just turned on). A check reusing a
|
||||
// forced one's answers keeps whichever of the two is newer.
|
||||
match feed_if_newer(feed, app, now, cached.as_ref()) {
|
||||
match feed_if_newer(feed, app, pre, now, cached.as_ref()) {
|
||||
Some(stable) => (Some(LatestRelease::Found(stable)), Origin::ArtCraftApi, Some(Source::Feed)),
|
||||
None => (cached, Origin::GitHub, None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The feed's fresh stable release for `app`, when it is newer than `github`'s answer, or that
|
||||
/// The feed's fresh selected-channel release for `app`, when it is newer than `github`'s answer, or that
|
||||
/// answer is missing, empty or failed.
|
||||
fn feed_if_newer(feed: Option<&Feed>, app: &CraftApp, now: i64, github: Option<&LatestRelease>) -> Option<Release> {
|
||||
let Some(FeedAnswer::Fresh(Some(stable))) = feed.map(|f| f.answer(app, now)) else { return None };
|
||||
fn feed_if_newer(feed: Option<&Feed>, app: &CraftApp, pre: bool, now: i64, github: Option<&LatestRelease>) -> Option<Release> {
|
||||
let Some(FeedAnswer::Fresh(Some(stable))) = feed.map(|f| if pre && f.channel_aware { f.answer_prerelease(app, now) } else { f.answer(app, now) })
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let newer = match github {
|
||||
Some(LatestRelease::Found(saved)) => {
|
||||
stable.version.as_ref().zip(saved.version.as_ref()).is_some_and(|(stable, saved)| version::is_newer(stable, saved))
|
||||
@@ -2462,6 +2472,9 @@ fn track_answer(
|
||||
) -> (Option<LatestRelease>, Origin, Option<Source>) {
|
||||
let query = release_query(feed, app).with_priority(github_priority(app, track, shared, force));
|
||||
if *track == VersionTrack::Nightly {
|
||||
if !force && let Some(FeedAnswer::Fresh(Some(nightly))) = feed.map(|f| f.answer_nightly(app, now)) {
|
||||
return (Some(LatestRelease::Found(nightly)), Origin::ArtCraftApi, Some(Source::Feed));
|
||||
}
|
||||
// Its own record, apart from the stable track's: asking about one doesn't stand in for
|
||||
// the other when the app switches tracks.
|
||||
let key = format!("{}@nightly", app.id);
|
||||
@@ -2542,15 +2555,35 @@ enum FeedFetch {
|
||||
Held,
|
||||
}
|
||||
|
||||
/// Asks ArtCraft's release feed up to `attempts` times, as often as `throttle` allows (waiting at
|
||||
/// most [`MAX_THROTTLE_WAIT`] for it), saving a good answer.
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
struct SignedFeedCache {
|
||||
catalog: String,
|
||||
signature: String,
|
||||
}
|
||||
|
||||
/// Fetch and verify both parts of a signed feed using the caller's catalog transport.
|
||||
fn signed_feed(url: &str, get: impl Fn(&str, usize) -> Result<Option<Vec<u8>>, String>) -> Result<(Feed, SignedFeedCache), String> {
|
||||
let sig_url = format!("{url}.sig");
|
||||
let catalog = get(url, artcraft_launcher_core::hosted_catalog::MAX_CATALOG_BYTES)?.ok_or("hosted catalog is not published")?;
|
||||
let signature = get(&sig_url, artcraft_launcher_core::hosted_catalog::MAX_SIGNATURE_BYTES)?.ok_or("catalog signature is not published")?;
|
||||
let feed = Feed::parse_signed_catalog(&catalog, &signature)?;
|
||||
let saved = SignedFeedCache {
|
||||
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((feed, saved))
|
||||
}
|
||||
|
||||
/// Asks ArtCraft's signed catalog (or a local-mirror JSON feed) up to `attempts` times, as often
|
||||
/// as `throttle` allows (waiting at most [`MAX_THROTTLE_WAIT`] for it), saving a good answer.
|
||||
fn fetch_feed(http: &Http, paths: &Paths, url: &str, throttle: &Mutex<FeedThrottle>, attempts: usize) -> FeedFetch {
|
||||
let mut asked = false;
|
||||
let is_signed_catalog = url.ends_with(".toml");
|
||||
for attempt in 0..attempts.max(1) {
|
||||
let wait = throttle.lock().unwrap_or_else(PoisonError::into_inner).wait(crate::now());
|
||||
if wait > MAX_THROTTLE_WAIT {
|
||||
if !asked {
|
||||
log::info!("holding off the ArtCraft API for {wait} s");
|
||||
log::info!("holding off the release catalog for {wait} s");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2566,27 +2599,46 @@ fn fetch_feed(http: &Http, paths: &Paths, url: &str, throttle: &Mutex<FeedThrott
|
||||
throttle.sending(now);
|
||||
}
|
||||
asked = true;
|
||||
let outcome = match http.get_feed(url) {
|
||||
Ok(body) => match Feed::parse(&body) {
|
||||
Some(feed) => {
|
||||
if let Err(e) = crate::paths::write_atomic(&paths.feed_cache(), body.as_bytes()) {
|
||||
log::warn!("couldn't save the release feed: {e}");
|
||||
let outcome = if is_signed_catalog {
|
||||
let fetched = signed_feed(url, |url, max| http.get_catalog_bytes(url, max));
|
||||
match fetched {
|
||||
Ok((feed, saved)) => {
|
||||
if let Ok(bytes) = serde_json::to_vec(&saved)
|
||||
&& let Err(e) = crate::paths::write_atomic(&paths.feed_cache(), &bytes)
|
||||
{
|
||||
log::warn!("couldn't save the release catalog: {e}");
|
||||
}
|
||||
throttle.lock().unwrap_or_else(PoisonError::into_inner).finished(Outcome::Answered, crate::now(), 0.0);
|
||||
return FeedFetch::Answered(feed);
|
||||
}
|
||||
None => {
|
||||
log::warn!("the release feed answered with something unreadable (try {})", attempt + 1);
|
||||
Err(why) => {
|
||||
log::info!("signed release catalog unavailable (try {}): {why}", attempt + 1);
|
||||
Outcome::Failed { retry_after: None }
|
||||
}
|
||||
},
|
||||
Err(e) if e.throttled => {
|
||||
log::warn!("the ArtCraft API asked us to slow down (HTTP 429); holding off");
|
||||
Outcome::Throttled { retry_after: e.retry_after }
|
||||
}
|
||||
Err(e) => {
|
||||
log::info!("release feed unavailable (try {}): {}", attempt + 1, e.why);
|
||||
Outcome::Failed { retry_after: e.retry_after }
|
||||
} else {
|
||||
match http.get_feed(url) {
|
||||
Ok(body) => match Feed::parse(&body) {
|
||||
Some(feed) => {
|
||||
if let Err(e) = crate::paths::write_atomic(&paths.feed_cache(), body.as_bytes()) {
|
||||
log::warn!("couldn't save the release feed: {e}");
|
||||
}
|
||||
throttle.lock().unwrap_or_else(PoisonError::into_inner).finished(Outcome::Answered, crate::now(), 0.0);
|
||||
return FeedFetch::Answered(feed);
|
||||
}
|
||||
None => {
|
||||
log::warn!("the release feed answered with something unreadable (try {})", attempt + 1);
|
||||
Outcome::Failed { retry_after: None }
|
||||
}
|
||||
},
|
||||
Err(e) if e.throttled => {
|
||||
log::warn!("the release feed asked us to slow down (HTTP 429); holding off");
|
||||
Outcome::Throttled { retry_after: e.retry_after }
|
||||
}
|
||||
Err(e) => {
|
||||
log::info!("release feed unavailable (try {}): {}", attempt + 1, e.why);
|
||||
Outcome::Failed { retry_after: e.retry_after }
|
||||
}
|
||||
}
|
||||
};
|
||||
throttle.lock().unwrap_or_else(PoisonError::into_inner).finished(outcome, crate::now(), feed_throttle::jitter());
|
||||
@@ -2676,9 +2728,14 @@ fn mirror_chosen(app: &CraftApp, feed: Option<&Feed>, now: i64, track: &VersionT
|
||||
(chosen, origin, source)
|
||||
}
|
||||
|
||||
/// The last saved feed answer, if any.
|
||||
/// The last saved feed answer, if any. Signed catalog caches are always reverified against the
|
||||
/// pinned Ed25519 key before parsing.
|
||||
fn load_feed(paths: &Paths) -> Option<Feed> {
|
||||
std::fs::read_to_string(paths.feed_cache()).ok().and_then(|body| Feed::parse(&body))
|
||||
let body = std::fs::read_to_string(paths.feed_cache()).ok()?;
|
||||
if let Ok(signed) = serde_json::from_str::<SignedFeedCache>(&body) {
|
||||
return Feed::parse_signed_catalog(signed.catalog.as_bytes(), signed.signature.as_bytes()).ok();
|
||||
}
|
||||
Feed::parse(&body)
|
||||
}
|
||||
|
||||
/// The machine's real architecture: an x64 launcher on Windows on ARM should still pick ARM64
|
||||
@@ -3532,6 +3589,52 @@ mod tests {
|
||||
(url, hits)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_feed_round_trips_through_offline_cache_and_rejects_tampering() {
|
||||
use artcraft_launcher_core::hosted_catalog::{BUILD_CATALOG_SIG, BUILD_CATALOG_TOML, CATALOG_URL, SIGNATURE_URL};
|
||||
let (feed, mut saved) = signed_feed(CATALOG_URL, |url, _| match url {
|
||||
CATALOG_URL => Ok(Some(BUILD_CATALOG_TOML.to_vec())),
|
||||
SIGNATURE_URL => Ok(Some(BUILD_CATALOG_SIG.to_vec())),
|
||||
_ => panic!("unexpected URL {url}"),
|
||||
})
|
||||
.unwrap();
|
||||
assert!(!feed.apps.is_empty());
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let paths = Paths::under(dir.path());
|
||||
crate::paths::write_atomic(&paths.feed_cache(), &serde_json::to_vec(&saved).unwrap()).unwrap();
|
||||
assert_eq!(load_feed(&paths), Some(feed));
|
||||
saved.catalog.push('\n');
|
||||
crate::paths::write_atomic(&paths.feed_cache(), &serde_json::to_vec(&saved).unwrap()).unwrap();
|
||||
assert!(load_feed(&paths).is_none());
|
||||
assert!(signed_feed(CATALOG_URL, |_, _| Ok(None)).is_err());
|
||||
assert!(signed_feed(CATALOG_URL, |url, _| Ok((url == CATALOG_URL).then(|| BUILD_CATALOG_TOML.to_vec()))).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nightly_track_prefers_a_fresh_catalog_answer_without_requesting_github() {
|
||||
let github = CountingGitHub::default();
|
||||
let shared = shared();
|
||||
let photo = CraftApp::by_id("photocraft").unwrap();
|
||||
let tag = "v0.24.0-nightly.20261009.1.1";
|
||||
let mut feed = feed();
|
||||
feed.apps.get_mut(photo.id).unwrap().nightly = Some(artcraft_launcher_core::feed::FeedRelease {
|
||||
tag: tag.into(),
|
||||
prerelease: true,
|
||||
assets: vec![(
|
||||
"SHA256SUMS.txt".into(),
|
||||
1,
|
||||
format!("https://github.com/{}/releases/download/{tag}/SHA256SUMS.txt", photo.repo),
|
||||
Some("a".repeat(64)),
|
||||
)],
|
||||
..Default::default()
|
||||
});
|
||||
let (latest, origin, used) = track_answer(photo, &VersionTrack::Nightly, Some(&feed), &github, &shared, false, NOW);
|
||||
assert!(matches!(latest, Some(LatestRelease::Found(r)) if r.tag == tag));
|
||||
assert_eq!(origin, Origin::ArtCraftApi);
|
||||
assert_eq!(used, Some(Source::Feed));
|
||||
assert_eq!(github.0.load(Ordering::SeqCst), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_429_stops_the_retries_and_holds_off_the_api() {
|
||||
let (url, hits) = serve("429 Too Many Requests");
|
||||
@@ -3756,6 +3859,34 @@ mod tests {
|
||||
assert_eq!(github.0.load(Ordering::SeqCst), 2, "due again after an hour");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_channel_aware_plan_uses_rc_and_keeps_it_on_github_failure() {
|
||||
let photo = CraftApp::by_id("photocraft").unwrap();
|
||||
let catalog = Feed::parse_catalog_toml(
|
||||
r#"generated_at = "2026-10-09T13:00:00Z"
|
||||
[[apps]]
|
||||
id = "photocraft"
|
||||
repo = "storytold/photocraft"
|
||||
[apps.releases.stable]
|
||||
tag = "v0.23.1"
|
||||
[apps.releases.prerelease]
|
||||
tag = "v0.24.0-rc.1"
|
||||
prerelease = true
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
let (feed, plan) = remote_plan(true, (Some(catalog), LOADED));
|
||||
assert!(plan.trust_feed);
|
||||
let github = CountingGitHub::default();
|
||||
let (latest, _, used) = latest_for(photo, feed.as_ref(), plan, &github, &shared(), true, false, NOW);
|
||||
assert!(matches!(latest, Some(LatestRelease::Found(r)) if r.tag == "v0.24.0-rc.1"));
|
||||
assert_eq!(used, Some(Source::Feed));
|
||||
assert_eq!(github.0.load(Ordering::SeqCst), 0);
|
||||
let unavailable = Some(LatestRelease::Failed("offline".into()));
|
||||
assert_eq!(feed_if_newer(feed.as_ref(), photo, true, NOW, unavailable.as_ref()).unwrap().tag, "v0.24.0-rc.1");
|
||||
assert_eq!(feed_if_newer(feed.as_ref(), photo, false, NOW, unavailable.as_ref()).unwrap().tag, "v0.23.1");
|
||||
}
|
||||
|
||||
/// Asking GitHub with pre-releases off doesn't stand in for asking with them on: turning them
|
||||
/// on asks again at once, not after the hour.
|
||||
#[test]
|
||||
|
||||
@@ -117,6 +117,24 @@ mod tests {
|
||||
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);
|
||||
// Exercise the actual release-feed parser against the same signed bytes the native
|
||||
// startup path just fetched, not only the app and icon metadata.
|
||||
use artcraft_launcher_core::catalog::LAUNCHER;
|
||||
use artcraft_launcher_core::feed::{Feed, FeedAnswer};
|
||||
let saved: Saved = serde_json::from_slice(&std::fs::read(&cache).unwrap()).unwrap();
|
||||
let feed = Feed::parse_signed_catalog(saved.catalog.as_bytes(), saved.signature.as_bytes()).unwrap();
|
||||
let now = crate::now();
|
||||
assert!(matches!(feed.answer(&LAUNCHER, now), FeedAnswer::Fresh(Some(release)) if !release.assets.is_empty()));
|
||||
for app in artcraft_launcher_core::hosted_catalog::apps() {
|
||||
if feed.apps.get(app.id).is_some_and(|entry| entry.release.is_some()) {
|
||||
assert!(
|
||||
matches!(feed.answer(app, now), FeedAnswer::Fresh(Some(release)) if !release.assets.is_empty()),
|
||||
"invalid live stable release for {}",
|
||||
app.id
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(feed.apps.get("photocraft").is_some_and(|entry| entry.release.is_some()));
|
||||
let icons: Vec<_> = verified.icons().collect();
|
||||
assert!(!icons.is_empty());
|
||||
for (id, _, digest) in icons {
|
||||
@@ -131,8 +149,8 @@ mod tests {
|
||||
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(),
|
||||
catalog: std::str::from_utf8(artcraft_launcher_core::hosted_catalog::BUILD_CATALOG_TOML).unwrap().into(),
|
||||
signature: std::str::from_utf8(artcraft_launcher_core::hosted_catalog::BUILD_CATALOG_SIG).unwrap().into(),
|
||||
};
|
||||
write_atomic(&path, &serde_json::to_vec(&saved).unwrap()).unwrap();
|
||||
assert!(saved_catalog(&path).is_some());
|
||||
|
||||
@@ -50,6 +50,14 @@ fn download(http: &Http, url: &str, saved: &Path) -> Result<Vec<u8>, Failure> {
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
/// Try the fallback for the same picture before treating the primary failure as network-wide.
|
||||
fn download_with_fallback(http: &Http, url: &str, fallback: Option<&str>, saved: &Path) -> Result<Vec<u8>, Failure> {
|
||||
download(http, url, saved).or_else(|primary| match fallback {
|
||||
Some(fallback) => download(http, fallback, saved).map_err(|err| if matches!(err, Failure::Picture(_)) { err } else { primary }),
|
||||
None => Err(primary),
|
||||
})
|
||||
}
|
||||
|
||||
/// Every picture of `details`, lead first, handed to `emit` one by one as it is had. Saved copies
|
||||
/// need no network. Once the network or the server has failed, the pictures still to fetch fail at
|
||||
/// once with the same reason instead of each waiting for its own timeout; saved ones are still
|
||||
@@ -67,7 +75,7 @@ pub fn fetch_all(http: Option<&Http>, paths: &Paths, details: &AppDetails, mut e
|
||||
continue;
|
||||
}
|
||||
let result = match (http, details.screenshot_url(shot.key)) {
|
||||
(Some(http), Some(url)) => download(http, &url, &saved),
|
||||
(Some(http), Some(url)) => download_with_fallback(http, &url, details.screenshot_fallback_url(shot.key).as_deref(), &saved),
|
||||
(None, _) => Err(Failure::Network("HTTPS isn't available".into())),
|
||||
(_, None) => Err(Failure::Picture("this page has no such picture".into())),
|
||||
};
|
||||
@@ -123,6 +131,20 @@ mod tests {
|
||||
assert_eq!(saved_copy(&saved), Some(jpeg()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn screenshot_fallback_recovers_and_missing_fallback_is_picture_specific() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let saved = dir.path().join("pic.jpg");
|
||||
let http = Http::new().unwrap();
|
||||
let gone = std::net::TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap();
|
||||
let primary = format!("http://{gone}/pic.jpg");
|
||||
let (fallback, _) = serve(jpeg(), vec![Reply::Full]);
|
||||
assert_eq!(download_with_fallback(&http, &primary, Some(&fallback), &saved).unwrap(), jpeg());
|
||||
assert_eq!(saved_copy(&saved), Some(jpeg()));
|
||||
let (missing, _) = serve(Vec::new(), vec![Reply::Missing]);
|
||||
assert!(matches!(download_with_fallback(&http, &primary, Some(&missing), &saved), Err(Failure::Picture(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_is_not_a_picture_is_not_kept() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -1114,9 +1114,12 @@ mod tests {
|
||||
// MailCraft moved from `UCS-Care-Group` to `UCSLabs` (#1593). Before the rename the new name
|
||||
// is a 404, after it the new name answers: either way the release is found once, and its
|
||||
// downloads belong to the repo that answered.
|
||||
let app = artcraft_launcher_core::CraftApp::by_id("mailcraft").unwrap();
|
||||
let mut app = *artcraft_launcher_core::CraftApp::by_id("mailcraft").unwrap();
|
||||
app.repo = "UCSLabs/mailcraft";
|
||||
app.former_repo = Some("UCS-Care-Group/mailcraft");
|
||||
let app = &app;
|
||||
let query = ReleaseQuery::for_app(app, app.repo);
|
||||
let former = app.former_repo.unwrap();
|
||||
let former = "UCS-Care-Group/mailcraft";
|
||||
let (_temp, source) = fresh_source();
|
||||
for live in [former, app.repo] {
|
||||
let asked = std::cell::RefCell::new(Vec::new());
|
||||
@@ -1147,8 +1150,11 @@ mod tests {
|
||||
#[test]
|
||||
fn a_release_saved_under_the_former_name_still_stands_in() {
|
||||
// Checked before the rename, opened offline after it: nothing is saved under the new name.
|
||||
let app = artcraft_launcher_core::CraftApp::by_id("mailcraft").unwrap();
|
||||
let (_temp, source, release) = shared_selection_saved_source(app.former_repo.unwrap(), "v0.15.0");
|
||||
let mut app = *artcraft_launcher_core::CraftApp::by_id("mailcraft").unwrap();
|
||||
app.repo = "UCSLabs/mailcraft";
|
||||
app.former_repo = Some("UCS-Care-Group/mailcraft");
|
||||
let app = &app;
|
||||
let (_temp, source, release) = shared_selection_saved_source("UCS-Care-Group/mailcraft", "v0.15.0");
|
||||
assert_eq!(source.cached(&ReleaseQuery::for_app(app, app.repo), true), Some(LatestRelease::Found(release)));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,3 +44,17 @@ Packaging facts the code relies on:
|
||||
- `build.rs` reads `ARTCRAFT_LAUNCHER_BUILD_SHA` / `ARTCRAFT_LAUNCHER_BUILD_DATE` and, on Windows,
|
||||
embeds `assets/app-icon/artcraft-launcher.ico`, failing the build when
|
||||
`ARTCRAFT_LAUNCHER_REQUIRE_WINRES=1` and it can't.
|
||||
|
||||
## Signed catalog at build and runtime
|
||||
|
||||
For an offline or reproducible build, set `ARTCRAFT_CATALOG_DIR` to a pinned snapshot containing
|
||||
`launcher-catalog.toml`, its detached `.sig`, and the `launcher-app-icons/<id>-<sha256>.png`
|
||||
files. The build verifies the signature and icon digests. The default network build uses a
|
||||
verified cache under the Cargo target directory (or `ARTCRAFT_CATALOG_CACHE_DIR`).
|
||||
Windows packaging consumes the verified icons emitted by that exact build, without a second
|
||||
network fetch. With `-SkipBuild`, pass `-CatalogOutputDir` if multiple core build outputs exist.
|
||||
|
||||
The signed release catalog supplies stable release and Nightly discovery information. Automated
|
||||
Nightly installation/update checks intentionally still use the GitHub Nightly verifier, which
|
||||
validates the platform-specific descriptor and checksums and retains the existing scheduling
|
||||
and rollback protections. A signed discovery entry alone is not permission to install a Nightly.
|
||||
@@ -22,7 +22,8 @@
|
||||
#>
|
||||
param(
|
||||
[ValidateSet('x64', 'x86', 'arm64')] [string] $Arch = 'x64',
|
||||
[switch] $SkipBuild
|
||||
[switch] $SkipBuild,
|
||||
[string] $CatalogOutputDir
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$Root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||
@@ -70,7 +71,29 @@ if (-not $SkipBuild) {
|
||||
# Fail the build (rather than warn) if the icon/VERSIONINFO can't be embedded.
|
||||
$env:ARTCRAFT_LAUNCHER_REQUIRE_WINRES = '1'
|
||||
# The launcher and the craft-ai-mcp gateway it ships (Settings › AI agents).
|
||||
Invoke-Native "cargo build ($Target)" { cargo build --release --locked -p $Pkg -p $GatewayPkg --target $Target }
|
||||
# Cargo reports the exact core build-script OUT_DIR, including for a fresh cached build.
|
||||
# Keep compiler diagnostics visible, but select the verified outputs from this build only.
|
||||
Invoke-Native "cargo build ($Target)" {
|
||||
cargo build --release --locked -p $Pkg -p $GatewayPkg --target $Target --message-format=json-render-diagnostics |
|
||||
ForEach-Object {
|
||||
$message = $_ | ConvertFrom-Json
|
||||
if ($message.reason -eq 'compiler-message') { Write-Host $message.message.rendered }
|
||||
if ($message.reason -eq 'build-script-executed' -and
|
||||
$message.package_id -match '#artcraft-launcher-core@') {
|
||||
$script:CatalogOutputDir = $message.out_dir
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (-not $CatalogOutputDir) {
|
||||
# -SkipBuild is for a previously built binary. Never guess between stale hashed OUT_DIRs.
|
||||
$outputs = @(Get-ChildItem -Directory -Path (Join-Path $TargetDir "$Target\release\build") -Filter 'out' -Recurse -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Parent.Name -like 'artcraft-launcher-core-*' -or $_.Parent.Parent.Name -eq 'artcraft-launcher-core' } |
|
||||
ForEach-Object { $_.FullName } |
|
||||
Where-Object { Test-Path -LiteralPath (Join-Path $_ 'catalog.toml') })
|
||||
if ($outputs.Count -eq 1) { $CatalogOutputDir = $outputs[0] }
|
||||
}
|
||||
if (-not $CatalogOutputDir -or -not (Test-Path -LiteralPath (Join-Path $CatalogOutputDir 'catalog.toml'))) {
|
||||
throw 'Missing verified launcher catalog build output. Build the launcher first (ARTCRAFT_CATALOG_DIR supports offline builds), or pass -CatalogOutputDir for the exact prebuilt binary.'
|
||||
}
|
||||
|
||||
$Bin = Join-Path $TargetDir "$Target\release"
|
||||
@@ -121,12 +144,19 @@ function New-InstallerArt([string] $BannerOut, [string] $DialogOut) {
|
||||
$accent = [System.Drawing.ColorTranslator]::FromHtml('#2d81ff')
|
||||
$muted = [System.Drawing.Color]::FromArgb(153, 242, 241, 238)
|
||||
$line = [System.Drawing.Color]::FromArgb(38, 242, 241, 238)
|
||||
# The Craft App Suite, in the launcher's order (crates/core/src/catalog.rs).
|
||||
$apps = 'photocraft', 'vectorcraft', 'filmcraft', 'lightcraft', 'pdfcraft', 'effectcraft',
|
||||
'anicraft', 'designcraft', 'figcraft', 'wordcraft', 'soundcraft', 'deckcraft', 'cadcraft', 'gridcraft', 'craft-anything', 'texturecraft', 'materialcraft'
|
||||
# Official apps in the signed catalog's order. Limit the art to its five-row grid.
|
||||
$apps = @(Get-Content -LiteralPath (Join-Path $CatalogOutputDir 'installer-apps.txt') | Select-Object -First 20)
|
||||
$mark = [System.Drawing.Image]::FromFile((Join-Path $Root 'assets\app-icon\hicolor\256x256\apps\ai.storyteller.artcraft-launcher.png'))
|
||||
$wordmark = [System.Drawing.Image]::FromFile((Join-Path $Root 'docs\brand\artcraft-logo-white.png'))
|
||||
$icons = $apps | ForEach-Object { [System.Drawing.Image]::FromFile((Join-Path $Root "assets\app-icons\$_.png")) }
|
||||
# Reuse the exact build's signature- and digest-verified icons, including offline overrides.
|
||||
# No independent catalog parser or network fetch is needed at packaging time.
|
||||
$icons = $apps | ForEach-Object {
|
||||
$icon = Join-Path $CatalogOutputDir "app-icons\$_.png"
|
||||
if (-not (Test-Path -LiteralPath $icon -PathType Leaf)) {
|
||||
throw "Missing verified launcher icon $_ in $CatalogOutputDir; rebuild the launcher."
|
||||
}
|
||||
[System.Drawing.Image]::FromFile($icon)
|
||||
}
|
||||
# The site's label face; GDI+ draws a variable font at its default instance (Regular).
|
||||
$fonts = New-Object System.Drawing.Text.PrivateFontCollection
|
||||
$fonts.AddFontFile((Join-Path $Root 'assets\fonts\GeistMono-Variable.ttf'))
|
||||
@@ -160,7 +190,7 @@ function New-InstallerArt([string] $BannerOut, [string] $DialogOut) {
|
||||
$x += $g.MeasureString([string]$ch, $labelFont, 100, [System.Drawing.StringFormat]::GenericTypographic).Width + 1.35
|
||||
}
|
||||
$brush.Dispose()
|
||||
# The seventeen apps in four columns of 30 px cells: x=22..142, y=118..268.
|
||||
# The suite apps in four columns of 30 px cells: x=22..142, y=118..268.
|
||||
$pen = New-Object System.Drawing.Pen $line, 1
|
||||
$left = 22; $top = 118; $cell = 30; $columns = 4
|
||||
for ($i = 0; $i -lt $icons.Count; $i++) {
|
||||
|
||||