feat: fetch signed catalog and assets from getartcraft.com with GitHub fallback
No files matched your search
@@ -0,0 +1,39 @@
|
||||
name: Notify Services on Release Change
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
- unpublished
|
||||
- created
|
||||
- edited
|
||||
- deleted
|
||||
- prereleased
|
||||
- released
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
dispatch:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Dispatch release-changed event to artcraft-services
|
||||
env:
|
||||
DISPATCH_TOKEN: ${{ secrets.ARTCRAFT_SERVICES_DISPATCH_TOKEN }}
|
||||
EVENT_ACTION: ${{ github.event.action }}
|
||||
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
||||
RELEASE_PRERELEASE: ${{ github.event.release.prerelease }}
|
||||
run: |
|
||||
if [ -z "$DISPATCH_TOKEN" ]; then
|
||||
echo "::warning::ARTCRAFT_SERVICES_DISPATCH_TOKEN is not configured; skipping artcraft-services rebuild dispatch."
|
||||
exit 0
|
||||
fi
|
||||
curl --fail --silent --show-error \
|
||||
--connect-timeout 10 --max-time 30 \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "Authorization: Bearer ${DISPATCH_TOKEN}" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
"https://api.github.com/repos/storytold/artcraft-services/dispatches" \
|
||||
-d "{\"event_type\":\"craft-release-changed\",\"client_payload\":{\"repo\":\"${GITHUB_REPOSITORY}\",\"action\":\"${EVENT_ACTION}\",\"tag\":\"${RELEASE_TAG}\",\"prerelease\":${RELEASE_PRERELEASE}}}"
|
||||
@@ -332,6 +332,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"toml 1.1.8+spec-1.1.0",
|
||||
"ureq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -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,197 @@ 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");
|
||||
|
||||
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)?;
|
||||
|
||||
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 +291,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))
|
||||
}
|
||||
@@ -181,6 +188,10 @@ mod tests {
|
||||
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_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;
|
||||
@@ -46,9 +49,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,7 +101,40 @@ 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, 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 {
|
||||
@@ -159,6 +199,58 @@ 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)
|
||||
{
|
||||
match app.former_repo.filter(|former| feed_repo.eq_ignore_ascii_case(former)) {
|
||||
Some(former) => repo = former.to_string(),
|
||||
None => return None,
|
||||
}
|
||||
}
|
||||
Some((entry, repo))
|
||||
}
|
||||
}
|
||||
|
||||
impl FeedRelease {
|
||||
@@ -201,6 +293,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 +457,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 +642,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 +791,76 @@ mod tests {
|
||||
assert_eq!(Feed::parse(&feed).unwrap().answer(app("photocraft"), NOW), FeedAnswer::AskGitHub, "{odd:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[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,8 @@ 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 +360,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)),
|
||||
@@ -2373,7 +2373,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.
|
||||
@@ -2462,6 +2462,11 @@ 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 +2547,22 @@ 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,
|
||||
}
|
||||
|
||||
/// 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 +2578,60 @@ 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 sig_url = format!("{url}.sig");
|
||||
let fetched = http
|
||||
.get_catalog_bytes(url, artcraft_launcher_core::hosted_catalog::MAX_CATALOG_BYTES)
|
||||
.and_then(|c| c.ok_or_else(|| "hosted catalog is not published".to_string()))
|
||||
.and_then(|catalog| {
|
||||
let signature = http
|
||||
.get_catalog_bytes(&sig_url, artcraft_launcher_core::hosted_catalog::MAX_SIGNATURE_BYTES)?
|
||||
.ok_or_else(|| "catalog signature is not published".to_string())?;
|
||||
let feed = Feed::parse_signed_catalog(&catalog, &signature)?;
|
||||
let saved = SignedFeedCache {
|
||||
catalog: String::from_utf8(catalog).map_err(|_| "catalog is not UTF-8".to_string())?,
|
||||
signature: String::from_utf8(signature).map_err(|_| "signature is not UTF-8".to_string())?,
|
||||
};
|
||||
Ok((feed, saved))
|
||||
});
|
||||
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 +2721,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
|
||||
|
||||
@@ -131,8 +131,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());
|
||||
|
||||
@@ -67,7 +67,12 @@ 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(http, &url, &saved).or_else(|primary_err| {
|
||||
match details.screenshot_fallback_url(shot.key) {
|
||||
Some(fallback) => download(http, &fallback, &saved).map_err(|_| primary_err),
|
||||
None => Err(primary_err),
|
||||
}
|
||||
}),
|
||||
(None, _) => Err(Failure::Network("HTTPS isn't available".into())),
|
||||
(_, None) => Err(Failure::Picture("this page has no such picture".into())),
|
||||
};
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Build, sign and package ArtCraft Launcher for Windows.
|
||||
|
||||
@@ -126,7 +126,24 @@ function New-InstallerArt([string] $BannerOut, [string] $DialogOut) {
|
||||
'anicraft', 'designcraft', 'figcraft', 'wordcraft', 'soundcraft', 'deckcraft', 'cadcraft', 'gridcraft', 'craft-anything', 'texturecraft', 'materialcraft'
|
||||
$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")) }
|
||||
# Fetch app icons from the live signed website catalog (cached in TEMP for repeated builds).
|
||||
$iconCache = Join-Path $env:TEMP 'artcraft-launcher-icon-cache'
|
||||
New-Item -ItemType Directory -Force -Path $iconCache | Out-Null
|
||||
$catalogText = (Invoke-WebRequest -UseBasicParsing -Uri 'https://getartcraft.com/launcher-catalog.toml').Content
|
||||
$iconUrls = @{}
|
||||
$currentId = $null
|
||||
foreach ($line in ($catalogText -split "`r?`n")) {
|
||||
if ($line -match '^id\s*=\s*"([^"]+)"') { $currentId = $Matches[1] }
|
||||
elseif ($currentId -and $line -match '^icon_url\s*=\s*"([^"]+)"') { $iconUrls[$currentId] = $Matches[1] }
|
||||
}
|
||||
$icons = $apps | ForEach-Object {
|
||||
$url = $iconUrls[$_]
|
||||
if (-not $url) { throw "Missing icon_url in launcher-catalog.toml for $_" }
|
||||
$fileName = [System.IO.Path]::GetFileName(([System.Uri]$url).AbsolutePath)
|
||||
$cached = Join-Path $iconCache $fileName
|
||||
if (-not (Test-Path $cached)) { Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $cached }
|
||||
[System.Drawing.Image]::FromFile($cached)
|
||||
}
|
||||
# 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'))
|
||||
|
||||