feat: Remove ReVanced Integrations

There is no need for them anymore in Patcher v20+
This commit is contained in:
oSumAtrIX 2024-11-01 19:04:22 +01:00
parent a5498aba2b
commit f1c10928ae
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
11 changed files with 32 additions and 90 deletions

1
.gitignore vendored
View File

@ -41,7 +41,6 @@ persistence/
configuration.toml
docker-compose.yml
patches-public-key.asc
integrations-public-key.asc
node_modules/
static/
about.json

View File

@ -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
@ -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
@ -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

View File

@ -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 = [

View File

@ -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:

View File

@ -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<String, String>,

View File

@ -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<ApiRelease<ApiManagerAsset>>()
responseType<ApiRelease>()
}
}
}

View File

@ -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<ApiRelease<ApiPatchesAsset>>()
responseType<ApiRelease>()
}
}
}
@ -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<ApiAssetPublicKeys>()
responseType<ApiAssetPublicKey>()
}
}
}

View File

@ -41,33 +41,14 @@ class APIContributable(
)
@Serializable
class ApiRelease<T>(
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<T>,
)
@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

View File

@ -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<ApiManagerAsset> {
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,
)
}

View File

@ -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<ApiPatchesAsset> {
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())
}

View File

@ -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<ByteArray, Boolean>() // Hash -> Verified.
fun verify(