Verifies downloaded app’s build version matches source (if provided)

This commit is contained in:
Riley Testut
2023-05-18 15:55:26 -05:00
committed by Magesh K
parent 3aa041d2ad
commit 07bc34ae7a
2 changed files with 15 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ extension VerificationError
case mismatchedHash = 3
case mismatchedVersion = 4
case mismatchedBuildVersion = 5
case undeclaredPermissions = 6
case addedPermissions = 7
@@ -44,6 +45,10 @@ extension VerificationError
VerificationError(code: .mismatchedVersion, app: app, version: version, expectedVersion: expectedVersion)
}
static func mismatchedBuildVersion(_ version: String, expectedVersion: String, app: AppProtocol) -> VerificationError {
VerificationError(code: .mismatchedBuildVersion, app: app, version: version, expectedVersion: expectedVersion)
}
static func undeclaredPermissions(_ permissions: [any ALTAppPermission], app: AppProtocol) -> VerificationError {
VerificationError(code: .undeclaredPermissions, app: app, permissions: permissions)
}
@@ -144,6 +149,10 @@ struct VerificationError: ALTLocalizedError
let appName = self.$app.name ?? NSLocalizedString("the app", comment: "")
return String(format: NSLocalizedString("The downloaded version of %@ does not match the version specified by the source.", comment: ""), appName)
case .mismatchedBuildVersion:
let appName = self.$app.name ?? NSLocalizedString("the app", comment: "")
return String(format: NSLocalizedString("The downloaded version of %@ does not match the build number specified by the source.", comment: ""), appName)
case .undeclaredPermissions:
let appName = self.$app.name ?? NSLocalizedString("The app", comment: "")
return String(format: NSLocalizedString("%@ requires additional permissions not specified by the source.", comment: ""), appName)