From f1c10928ae3be1c6b1d675819755b3046fad70d8 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 1 Nov 2024 19:04:22 +0100 Subject: [PATCH] feat: Remove ReVanced Integrations There is no need for them anymore in Patcher v20+ --- .gitignore | 1 - README.md | 17 ++++---- configuration.example.toml | 1 - docker-compose.example.yml | 1 - .../repository/ConfigurationRepository.kt | 4 +- .../api/configuration/routes/ManagerRoute.kt | 3 +- .../api/configuration/routes/PatchesRoute.kt | 13 +++--- .../api/configuration/schema/APISchema.kt | 26 ++--------- .../configuration/services/ManagerService.kt | 11 ++--- .../configuration/services/PatchesService.kt | 43 +++---------------- .../services/SignatureService.kt | 2 +- 11 files changed, 32 insertions(+), 90 deletions(-) diff --git a/.gitignore b/.gitignore index d376259..c777613 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,6 @@ persistence/ configuration.toml docker-compose.yml patches-public-key.asc -integrations-public-key.asc node_modules/ static/ about.json \ No newline at end of file diff --git a/README.md b/README.md index fc2e854..f3c5fac 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,8 @@ API server for ReVanced. ## ❓ About ReVanced API is a server that is used as the backend for ReVanced. -ReVanced API acts as the data source for [ReVanced Website](https://github.com/ReVanced/revanced-website) and powers [ReVanced Manager](https://github.com/ReVanced/revanced-manager) +ReVanced API acts as the data source for [ReVanced Website](https://github.com/ReVanced/revanced-website) and +powers [ReVanced Manager](https://github.com/ReVanced/revanced-manager) with updates and ReVanced Patches. ## đŸ’Ē Features @@ -76,8 +77,8 @@ with updates and ReVanced Patches. Some of the features ReVanced API include: - đŸ“ĸ **Announcements**: Post and get announcements -- â„šī¸ **About**: Get more information such as a description, ways to donate to, -and links of the hoster of ReVanced API +- â„šī¸ **About**: Get more information such as a description, ways to donate to, + and links of the hoster of ReVanced API - 🧩 **Patches**: Get the latest updates of ReVanced Patches, directly from ReVanced API - đŸ‘Ĩ **Contributors**: List all contributors involved in the project - 🔄 **Backwards compatibility**: Proxy an old API for migration purposes and backwards compatibility @@ -90,7 +91,8 @@ ReVanced API can be deployed as a Docker container or used standalone. To deploy ReVanced API as a Docker container, you can use Docker Compose or Docker CLI. The Docker image is published on GitHub Container registry, -so before you can pull the image, you need to [authenticate to the Container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). +so before you can pull the image, you need +to [authenticate to the Container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). ### đŸ—„ī¸ Docker Compose @@ -114,8 +116,6 @@ so before you can pull the image, you need to [authenticate to the Container reg -v $(pwd)/configuration.toml:/app/configuration.toml \ # Mount the patches public key -v $(pwd)/patches-public-key.asc:/app/patches-public-key.asc \ - # Mount the integrations public key - -v $(pwd)/integrations-public-key.asc:/app/integrations-public-key.asc \ # Mount the static folder -v $(pwd)/static:/app/static \ # Mount the about.json file @@ -141,7 +141,7 @@ A Java Runtime Environment (JRE) must be installed. 1. [Download](https://github.com/ReVanced/revanced-api/releases/latest) ReVanced API to a folder 2. In the same folder, create an `.env` file using [.env.example](.env.example) as a template 3. In the same folder, create a `configuration.toml` file -using [configuration.example.toml](configuration.example.toml) as a template + using [configuration.example.toml](configuration.example.toml) as a template 4. In the same folder, create an `about.json` file using [about.example.json](about.example.json) as a template 5. Run `java -jar revanced-api.jar start` to start the server @@ -159,7 +159,8 @@ A Java Development Kit (JDK) and Git must be installed. ### 📙 Contributing -Thank you for considering contributing to ReVanced API. You can find the contribution guidelines [here](CONTRIBUTING.md). +Thank you for considering contributing to ReVanced API. You can find the contribution +guidelines [here](CONTRIBUTING.md). ### đŸ› ī¸ Building diff --git a/configuration.example.toml b/configuration.example.toml index 60369f8..5314b96 100644 --- a/configuration.example.toml +++ b/configuration.example.toml @@ -1,6 +1,5 @@ organization = "revanced" patches = { repository = "revanced-patches", asset-regex = "jar$", signature-asset-regex = "asc$", public-key-file = "patches-public-key.asc", public-key-id = 0 } -integrations = { repository = "revanced-integrations", asset-regex = "apk$", signature-asset-regex = "asc$", public-key-file = "integrations-public-key.asc", public-key-id = 0 } manager = { repository = "revanced-manager", asset-regex = "apk$" } api-version = 1 cors-allowed-hosts = [ diff --git a/docker-compose.example.yml b/docker-compose.example.yml index db40175..5609eae 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -7,7 +7,6 @@ services: - /data/revanced-api/.env:/app/.env - /data/revanced-api/configuration.toml:/app/configuration.toml - /data/revanced-api/patches-public-key.asc:/app/patches-public-key.asc - - /data/revanced-api/integrations-public-key.asc:/app/integrations-public-key.asc - /data/revanced-api/static:/app/static - /data/revanced-api/about.json:/app/about.json environment: diff --git a/src/main/kotlin/app/revanced/api/configuration/repository/ConfigurationRepository.kt b/src/main/kotlin/app/revanced/api/configuration/repository/ConfigurationRepository.kt index fea5663..4e78c71 100644 --- a/src/main/kotlin/app/revanced/api/configuration/repository/ConfigurationRepository.kt +++ b/src/main/kotlin/app/revanced/api/configuration/repository/ConfigurationRepository.kt @@ -22,9 +22,8 @@ import kotlin.io.path.createDirectories /** * The repository storing the configuration for the API. * - * @property organization The API backends organization name where the repositories for the patches and integrations are. + * @property organization The API backends organization name where the repositories are. * @property patches The source of the patches. - * @property integrations The source of the integrations. * @property manager The source of the manager. * @property contributorsRepositoryNames The friendly name of repos mapped to the repository names to get contributors from. * @property backendServiceName The name of the backend service to use for the repositories, contributors, etc. @@ -41,7 +40,6 @@ import kotlin.io.path.createDirectories internal class ConfigurationRepository( val organization: String, val patches: SignedAssetConfiguration, - val integrations: SignedAssetConfiguration, val manager: AssetConfiguration, @SerialName("contributors-repositories") val contributorsRepositoryNames: Map, diff --git a/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt b/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt index 9485137..04f217f 100644 --- a/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt +++ b/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt @@ -1,7 +1,6 @@ package app.revanced.api.configuration.routes import app.revanced.api.configuration.installNotarizedRoute -import app.revanced.api.configuration.schema.ApiManagerAsset import app.revanced.api.configuration.schema.ApiRelease import app.revanced.api.configuration.schema.ApiReleaseVersion import app.revanced.api.configuration.services.ManagerService @@ -53,7 +52,7 @@ private fun Route.installManagerRouteDocumentation(deprecated: Boolean) = instal description("The latest manager release") mediaTypes("application/json") responseCode(HttpStatusCode.OK) - responseType>() + responseType() } } } diff --git a/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt b/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt index 7932f0b..ccf3529 100644 --- a/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt +++ b/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt @@ -2,8 +2,7 @@ package app.revanced.api.configuration.routes import app.revanced.api.configuration.installCache import app.revanced.api.configuration.installNotarizedRoute -import app.revanced.api.configuration.schema.ApiAssetPublicKeys -import app.revanced.api.configuration.schema.ApiPatchesAsset +import app.revanced.api.configuration.schema.ApiAssetPublicKey import app.revanced.api.configuration.schema.ApiRelease import app.revanced.api.configuration.schema.ApiReleaseVersion import app.revanced.api.configuration.services.PatchesService @@ -61,7 +60,7 @@ private fun Route.configure(deprecated: Boolean = false) { installPatchesPublicKeyRouteDocumentation(deprecated) get { - call.respond(patchesService.publicKeys()) + call.respond(patchesService.publicKey()) } } } @@ -78,7 +77,7 @@ private fun Route.installPatchesRouteDocumentation(deprecated: Boolean) = instal description("The current patches release") mediaTypes("application/json") responseCode(HttpStatusCode.OK) - responseType>() + responseType() } } } @@ -120,13 +119,13 @@ private fun Route.installPatchesPublicKeyRouteDocumentation(deprecated: Boolean) get = GetInfo.builder { if (deprecated) isDeprecated() - description("Get the public keys for verifying patches and integrations assets") - summary("Get patches and integrations public keys") + description("Get the public keys for verifying patches assets") + summary("Get patches public keys") response { description("The public keys") mediaTypes("application/json") responseCode(HttpStatusCode.OK) - responseType() + responseType() } } } diff --git a/src/main/kotlin/app/revanced/api/configuration/schema/APISchema.kt b/src/main/kotlin/app/revanced/api/configuration/schema/APISchema.kt index 0294a9b..369dc16 100644 --- a/src/main/kotlin/app/revanced/api/configuration/schema/APISchema.kt +++ b/src/main/kotlin/app/revanced/api/configuration/schema/APISchema.kt @@ -41,33 +41,14 @@ class APIContributable( ) @Serializable -class ApiRelease( +class ApiRelease( val version: String, val createdAt: LocalDateTime, val description: String, - // Using a list instead of a set because set semantics are unnecessary here. - val assets: List, -) - -@Serializable -class ApiManagerAsset( val downloadUrl: String, + val signatureDownloadUrl: String? = null, ) -@Serializable -class ApiPatchesAsset( - val downloadUrl: String, - val signatureDownloadUrl: String, - // TODO: Remove this eventually when integrations are merged into patches. - val name: ApiAssetName, -) - -@Serializable -enum class ApiAssetName { - PATCHES, - INTEGRATION, -} - @Serializable class ApiReleaseVersion( val version: String, @@ -125,9 +106,8 @@ class ApiRateLimit( ) @Serializable -class ApiAssetPublicKeys( +class ApiAssetPublicKey( val patchesPublicKey: String, - val integrationsPublicKey: String, ) @Serializable diff --git a/src/main/kotlin/app/revanced/api/configuration/services/ManagerService.kt b/src/main/kotlin/app/revanced/api/configuration/services/ManagerService.kt index d844684..c180043 100644 --- a/src/main/kotlin/app/revanced/api/configuration/services/ManagerService.kt +++ b/src/main/kotlin/app/revanced/api/configuration/services/ManagerService.kt @@ -3,27 +3,24 @@ package app.revanced.api.configuration.services import app.revanced.api.configuration.repository.BackendRepository import app.revanced.api.configuration.repository.BackendRepository.BackendOrganization.BackendRepository.BackendRelease.Companion.first import app.revanced.api.configuration.repository.ConfigurationRepository -import app.revanced.api.configuration.schema.* +import app.revanced.api.configuration.schema.ApiRelease +import app.revanced.api.configuration.schema.ApiReleaseVersion internal class ManagerService( private val backendRepository: BackendRepository, private val configurationRepository: ConfigurationRepository, ) { - suspend fun latestRelease(): ApiRelease { + suspend fun latestRelease(): ApiRelease { val managerRelease = backendRepository.release( configurationRepository.organization, configurationRepository.manager.repository, ) - val managerAsset = ApiManagerAsset( - managerRelease.assets.first(configurationRepository.manager.assetRegex).downloadUrl, - ) - return ApiRelease( managerRelease.tag, managerRelease.createdAt, managerRelease.releaseNote, - listOf(managerAsset), + managerRelease.assets.first(configurationRepository.manager.assetRegex).downloadUrl, ) } diff --git a/src/main/kotlin/app/revanced/api/configuration/services/PatchesService.kt b/src/main/kotlin/app/revanced/api/configuration/services/PatchesService.kt index 235536f..08b1fb9 100644 --- a/src/main/kotlin/app/revanced/api/configuration/services/PatchesService.kt +++ b/src/main/kotlin/app/revanced/api/configuration/services/PatchesService.kt @@ -3,7 +3,9 @@ package app.revanced.api.configuration.services import app.revanced.api.configuration.repository.BackendRepository import app.revanced.api.configuration.repository.BackendRepository.BackendOrganization.BackendRepository.BackendRelease.Companion.first import app.revanced.api.configuration.repository.ConfigurationRepository -import app.revanced.api.configuration.schema.* +import app.revanced.api.configuration.schema.ApiAssetPublicKey +import app.revanced.api.configuration.schema.ApiRelease +import app.revanced.api.configuration.schema.ApiReleaseVersion import app.revanced.library.serializeTo import app.revanced.patcher.patch.loadPatchesFromJar import com.github.benmanes.caffeine.cache.Caffeine @@ -17,40 +19,18 @@ internal class PatchesService( private val backendRepository: BackendRepository, private val configurationRepository: ConfigurationRepository, ) { - suspend fun latestRelease(): ApiRelease { + suspend fun latestRelease(): ApiRelease { val patchesRelease = backendRepository.release( configurationRepository.organization, configurationRepository.patches.repository, ) - val integrationsRelease = backendRepository.release( - configurationRepository.organization, - configurationRepository.integrations.repository, - ) - - fun ConfigurationRepository.SignedAssetConfiguration.asset( - release: BackendRepository.BackendOrganization.BackendRepository.BackendRelease, - assetName: ApiAssetName, - ) = ApiPatchesAsset( - release.assets.first(assetRegex).downloadUrl, - release.assets.first(signatureAssetRegex).downloadUrl, - assetName, - ) - - val patchesAsset = configurationRepository.patches.asset( - patchesRelease, - ApiAssetName.PATCHES, - ) - val integrationsAsset = configurationRepository.integrations.asset( - integrationsRelease, - ApiAssetName.INTEGRATION, - ) - return ApiRelease( patchesRelease.tag, patchesRelease.createdAt, patchesRelease.releaseNote, - listOf(patchesAsset, integrationsAsset), + patchesRelease.assets.first(configurationRepository.patches.assetRegex).downloadUrl, + patchesRelease.assets.first(configurationRepository.patches.signatureAssetRegex).downloadUrl, ) } @@ -111,14 +91,5 @@ internal class PatchesService( } } - fun publicKeys(): ApiAssetPublicKeys { - fun readPublicKey( - getSignedAssetConfiguration: ConfigurationRepository.() -> ConfigurationRepository.SignedAssetConfiguration, - ) = configurationRepository.getSignedAssetConfiguration().publicKeyFile.readText() - - return ApiAssetPublicKeys( - readPublicKey { patches }, - readPublicKey { integrations }, - ) - } + fun publicKey() = ApiAssetPublicKey(configurationRepository.patches.publicKeyFile.readText()) } diff --git a/src/main/kotlin/app/revanced/api/configuration/services/SignatureService.kt b/src/main/kotlin/app/revanced/api/configuration/services/SignatureService.kt index 80eb2d1..fc69005 100644 --- a/src/main/kotlin/app/revanced/api/configuration/services/SignatureService.kt +++ b/src/main/kotlin/app/revanced/api/configuration/services/SignatureService.kt @@ -12,7 +12,7 @@ import java.security.MessageDigest internal class SignatureService { private val signatureCache = Caffeine .newBuilder() - .maximumSize(2) // Assuming this is enough for patches and integrations. + .maximumSize(1) // 1 because currently only the latest patches is needed. .build() // Hash -> Verified. fun verify(