mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 03:03:31 +01:00
Supports custom entitlements when fetching provisioning profiles
This commit is contained in:
@@ -478,7 +478,7 @@ private extension AppManager
|
|||||||
return group
|
return group
|
||||||
}
|
}
|
||||||
|
|
||||||
private func _install(_ app: AppProtocol, operation: AppOperation, group: RefreshGroup, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
private func _install(_ app: AppProtocol, operation: AppOperation, group: RefreshGroup, additionalEntitlements: [ALTEntitlement: Any]? = nil, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
||||||
{
|
{
|
||||||
let progress = Progress.discreteProgress(totalUnitCount: 100)
|
let progress = Progress.discreteProgress(totalUnitCount: 100)
|
||||||
|
|
||||||
@@ -542,6 +542,7 @@ private extension AppManager
|
|||||||
|
|
||||||
/* Fetch Provisioning Profiles */
|
/* Fetch Provisioning Profiles */
|
||||||
let fetchProvisioningProfilesOperation = FetchProvisioningProfilesOperation(context: context)
|
let fetchProvisioningProfilesOperation = FetchProvisioningProfilesOperation(context: context)
|
||||||
|
fetchProvisioningProfilesOperation.additionalEntitlements = additionalEntitlements
|
||||||
fetchProvisioningProfilesOperation.resultHandler = { (result) in
|
fetchProvisioningProfilesOperation.resultHandler = { (result) in
|
||||||
switch result
|
switch result
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class FetchProvisioningProfilesOperation: ResultOperation<[String: ALTProvisioni
|
|||||||
{
|
{
|
||||||
let context: AppOperationContext
|
let context: AppOperationContext
|
||||||
|
|
||||||
|
var additionalEntitlements: [ALTEntitlement: Any]?
|
||||||
|
|
||||||
private let appGroupsLock = NSLock()
|
private let appGroupsLock = NSLock()
|
||||||
|
|
||||||
init(context: AppOperationContext)
|
init(context: AppOperationContext)
|
||||||
@@ -300,14 +302,20 @@ extension FetchProvisioningProfilesOperation
|
|||||||
|
|
||||||
func updateFeatures(for appID: ALTAppID, app: ALTApplication, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTAppID, Error>) -> Void)
|
func updateFeatures(for appID: ALTAppID, app: ALTApplication, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTAppID, Error>) -> Void)
|
||||||
{
|
{
|
||||||
let requiredFeatures = app.entitlements.compactMap { (entitlement, value) -> (ALTFeature, Any)? in
|
var entitlements = app.entitlements
|
||||||
|
for (key, value) in additionalEntitlements ?? [:]
|
||||||
|
{
|
||||||
|
entitlements[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
let requiredFeatures = entitlements.compactMap { (entitlement, value) -> (ALTFeature, Any)? in
|
||||||
guard let feature = ALTFeature(entitlement: entitlement) else { return nil }
|
guard let feature = ALTFeature(entitlement: entitlement) else { return nil }
|
||||||
return (feature, value)
|
return (feature, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
var features = requiredFeatures.reduce(into: [ALTFeature: Any]()) { $0[$1.0] = $1.1 }
|
var features = requiredFeatures.reduce(into: [ALTFeature: Any]()) { $0[$1.0] = $1.1 }
|
||||||
|
|
||||||
if let applicationGroups = app.entitlements[.appGroups] as? [String], !applicationGroups.isEmpty
|
if let applicationGroups = entitlements[.appGroups] as? [String], !applicationGroups.isEmpty
|
||||||
{
|
{
|
||||||
features[.appGroups] = true
|
features[.appGroups] = true
|
||||||
}
|
}
|
||||||
@@ -348,8 +356,14 @@ extension FetchProvisioningProfilesOperation
|
|||||||
|
|
||||||
func updateAppGroups(for appID: ALTAppID, app: ALTApplication, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTAppID, Error>) -> Void)
|
func updateAppGroups(for appID: ALTAppID, app: ALTApplication, team: ALTTeam, session: ALTAppleAPISession, completionHandler: @escaping (Result<ALTAppID, Error>) -> Void)
|
||||||
{
|
{
|
||||||
|
var entitlements = app.entitlements
|
||||||
|
for (key, value) in additionalEntitlements ?? [:]
|
||||||
|
{
|
||||||
|
entitlements[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Handle apps belonging to more than one app group.
|
// TODO: Handle apps belonging to more than one app group.
|
||||||
guard let applicationGroups = app.entitlements[.appGroups] as? [String], let groupIdentifier = applicationGroups.first else {
|
guard let applicationGroups = entitlements[.appGroups] as? [String], let groupIdentifier = applicationGroups.first else {
|
||||||
return completionHandler(.success(appID))
|
return completionHandler(.success(appID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user