Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
Store teamID instead of team in SigningContext
kabiroberai305131c3b7a7
diff --git a/Supersign/DeveloperServices/App Groups/DeveloperServicesAssignAppGroupsOperation.swift b/Supersign/DeveloperServices/App Groups/DeveloperServicesAssignAppGroupsOperation.swiftindex ee7cacf..fba52a9 100644--- a/Supersign/DeveloperServices/App Groups/DeveloperServicesAssignAppGroupsOperation.swift+++ b/Supersign/DeveloperServices/App Groups/DeveloperServicesAssignAppGroupsOperation.swift@@ -25,7 +25,7 @@ public struct DeveloperServicesAssignAppGroupsOperation: DeveloperServicesOperatcompletion: @escaping (Result<DeveloperServicesAppGroup.GroupID, Swift.Error>) -> Void) {let request = DeveloperServicesAssignAppGroupRequest(- platform: context.platform, teamID: context.team.id, appIDID: appID.id, groupID: group.id+ platform: context.platform, teamID: context.teamID, appIDID: appID.id, groupID: group.id)context.client.send(request) { result inguard result.get(withErrorHandler: completion) != nil else { return }@@ -48,7 +48,7 @@ public struct DeveloperServicesAssignAppGroupsOperation: DeveloperServicesOperatlet groupID = ProvisioningIdentifiers.groupID(fromSanitized: sanitized)let name = ProvisioningIdentifiers.groupName(fromSanitized: sanitized)let request = DeveloperServicesAddAppGroupRequest(- platform: context.platform, teamID: context.team.id, name: name, groupID: groupID+ platform: context.platform, teamID: context.teamID, name: name, groupID: groupID)context.client.send(request) { result inguard let group = result.get(withErrorHandler: completion) else { return }@@ -58,7 +58,7 @@ public struct DeveloperServicesAssignAppGroupsOperation: DeveloperServicesOperat}public func perform(completion: @escaping (Result<[DeveloperServicesAppGroup.GroupID], Error>) -> Void) {- let request = DeveloperServicesListAppGroupsRequest(platform: context.platform, teamID: context.team.id)+ let request = DeveloperServicesListAppGroupsRequest(platform: context.platform, teamID: context.teamID)context.client.send(request) { result inguard let existingGroups = result.get(withErrorHandler: completion) else { return }diff --git a/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift b/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swiftindex 90f0351..6ebbf47 100644--- a/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift+++ b/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift@@ -12,15 +12,24 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {public enum Error: LocalizedError {case invalidApp(URL)+ case teamNotFound(DeveloperServicesTeam.ID)public var errorDescription: String? {switch self {case .invalidApp(let url):return String.localizedStringWithFormat(NSLocalizedString(- "app_id_request_helper.error.invalid_app", value: "Invalid app: %@", comment: ""+ "add_app_operation.error.invalid_app", value: "Invalid app: %@", comment: ""), url.path)+ case .teamNotFound(let id):+ return String.localizedStringWithFormat(+ NSLocalizedString(+ "add_app_operation.error.team_not_found",+ value: "A team with the ID '%@' could not be found. Please select another team.",+ comment: ""+ ), id.rawValue+ )}}}@@ -36,9 +45,10 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {private func addOrFetchApp(bundleID: String,entitlements: Entitlements,+ team: DeveloperServicesTeam,completion: @escaping (Result<DeveloperServicesAppID, Swift.Error>) -> Void) {- let request = DeveloperServicesListAppIDsRequest(platform: context.platform, teamID: context.team.id)+ let request = DeveloperServicesListAppIDsRequest(platform: context.platform, teamID: context.teamID)context.client.send(request) { result inguard let appIDs = result.get(withErrorHandler: completion) else { return }if let appID = appIDs.first(where: {@@ -46,11 +56,11 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {}) {let request = DeveloperServicesUpdateAppIDRequest(platform: self.context.platform,- teamID: self.context.team.id,+ teamID: self.context.teamID,appIDID: appID.id,entitlements: entitlements,additionalFeatures: [],- isFree: self.context.team.isFree+ isFree: team.isFree)self.context.client.send(request, completion: completion)} else {@@ -58,12 +68,12 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {let name = ProvisioningIdentifiers.appName(fromSanitized: bundleID)let request = DeveloperServicesAddAppIDRequest(platform: self.context.platform,- teamID: self.context.team.id,+ teamID: self.context.teamID,bundleID: newBundleID,appName: name,entitlements: entitlements,additionalFeatures: [],- isFree: self.context.team.isFree+ isFree: team.isFree)self.context.client.send(request, completion: completion)}@@ -73,6 +83,7 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {/// Registers the app and returns the resultant entitlementsprivate func addAppAndGetEntitlements(app: URL,+ team: DeveloperServicesTeam,// old bundle id, app id, entscompletion: @escaping (Result<(DeveloperServicesAppID, Entitlements), Swift.Error>) -> Void) {@@ -91,7 +102,7 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {let decodedEntitlements = try? PropertyListDecoder().decode(Entitlements.self, from: entitlementsData) {entitlements = decodedEntitlements- if context.team.isFree {+ if team.isFree {do {// re-assign rather than using updateEntitlements since the latter will// retain unrecognized entitlements@@ -109,11 +120,11 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {}}- addOrFetchApp(bundleID: bundleID, entitlements: entitlements) { result in+ addOrFetchApp(bundleID: bundleID, entitlements: entitlements, team: team) { result inguard let appID = result.get(withErrorHandler: completion) else { return }do {- try entitlements.update(teamID: self.context.team.id, bundleID: appID.bundleID)+ try entitlements.update(teamID: self.context.teamID, bundleID: appID.bundleID)} catch {return completion(.failure(error))}@@ -150,9 +161,10 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {/// that the app has).private func addApp(_ app: URL,+ with team: DeveloperServicesTeam,completion: @escaping (Result<ProvisioningInfo, Swift.Error>) -> Void) {- addAppAndGetEntitlements(app: app) { result in+ addAppAndGetEntitlements(app: app, team: team) { result inguard let (appID, entitlements) = result.get(withErrorHandler: completion) else { return }DeveloperServicesFetchProfileOperation(context: self.context, appID: appID).perform { result inguard let profile = result.get(withErrorHandler: completion) else { return }@@ -165,8 +177,10 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {}}- /// Registers the app + its extensions, returning the profile and entitlements of each- public func perform(completion: @escaping (Result<[URL: ProvisioningInfo], Swift.Error>) -> Void) {+ private func perform(+ with team: DeveloperServicesTeam,+ completion: @escaping (Result<[URL: ProvisioningInfo], Swift.Error>) -> Void+ ) {var apps: [URL] = [root]let plugins = root.appendingPathComponent("PlugIns")if plugins.dirExists {@@ -176,10 +190,21 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {let grouper = RequestGrouper<(URL, ProvisioningInfo), Swift.Error>()for app in apps {grouper.add { completion in- addApp(app) { completion($0.map { (app, $0) }) }+ addApp(app, with: team) { completion($0.map { (app, $0) }) }}}grouper.onComplete { completion($0.map(Dictionary.init(uniqueKeysWithValues:))) }}+ /// Registers the app + its extensions, returning the profile and entitlements of each+ public func perform(completion: @escaping (Result<[URL: ProvisioningInfo], Swift.Error>) -> Void) {+ let request = DeveloperServicesListTeamsRequest()+ context.client.send(request) { result in+ guard let teams = result.get(withErrorHandler: completion) else { return }+ guard let team = teams.first(where: { $0.id == self.context.teamID })+ else { return completion(.failure(Error.teamNotFound(self.context.teamID))) }+ self.perform(with: team, completion: completion)+ }+ }+}diff --git a/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift b/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swiftindex 7fda131..d0e67c3 100644--- a/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift+++ b/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift@@ -17,7 +17,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperaswitch self {case .csrFailed:return NSLocalizedString(- "certificate_request_helper.error.csr_failed", value: "CSR request failed", comment: ""+ "fetch_certificate_operation.error.csr_failed", value: "CSR request failed", comment: "")}}@@ -43,7 +43,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperalet request = DeveloperServicesSubmitCSRRequest(platform: context.platform,- teamID: context.team.id,+ teamID: context.teamID,csr: csr,machineName: context.deviceName,machineID: context.udid@@ -53,7 +53,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperalet serialNumber = partialCert.serialNumberlet request = DeveloperServicesListCertificatesRequest(- teamID: self.context.team.id, certificateKind: .init(platform: self.context.platform)+ teamID: self.context.teamID, certificateKind: .init(platform: self.context.platform))self.context.client.send(request) { result inguard let certificates = result.get(withErrorHandler: completion) else { return }@@ -69,7 +69,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOpera) {createCertificate { result inguard let value = result.get(withErrorHandler: completion) else { return }- self.context.signingInfoManager[self.context.team.id] = value+ self.context.signingInfoManager[self.context.teamID] = valuecompletion(.success(value))}}@@ -78,7 +78,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperacertificate: DeveloperServicesCertificate,completion: @escaping (Result<SigningInfo, Swift.Error>) -> Void) {- let request = DeveloperServicesRevokeCertificateRequest(teamID: context.team.id, certificateID: certificate.id)+ let request = DeveloperServicesRevokeCertificateRequest(teamID: context.teamID, certificateID: certificate.id)context.client.send(request) { result inguard result.get(withErrorHandler: completion) != nil else { return }self.createAndSaveCertificate(completion: completion)@@ -87,7 +87,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperapublic func perform(completion: @escaping (Result<SigningInfo, Swift.Error>) -> Void) {let request = DeveloperServicesListCertificatesRequest(- teamID: context.team.id, certificateKind: .init(platform: context.platform)+ teamID: context.teamID, certificateKind: .init(platform: context.platform))context.client.send(request) { result inguard let certificates = result.get(withErrorHandler: completion) else { return }@@ -96,7 +96,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperareturn self.createAndSaveCertificate(completion: completion)}- guard let signingInfo = self.context.signingInfoManager[self.context.team.id],+ guard let signingInfo = self.context.signingInfoManager[self.context.teamID],let serialNumber = try? signingInfo.certificate.serialNumber(),certificate.attributes.serialNumber.rawValue == serialNumber,certificate.attributes.expiry > Date()diff --git a/Supersign/DeveloperServices/Devices/DeveloperServicesFetchDeviceOperation.swift b/Supersign/DeveloperServices/Devices/DeveloperServicesFetchDeviceOperation.swiftindex 00e48bd..d3e6d61 100644--- a/Supersign/DeveloperServices/Devices/DeveloperServicesFetchDeviceOperation.swift+++ b/Supersign/DeveloperServices/Devices/DeveloperServicesFetchDeviceOperation.swift@@ -16,7 +16,7 @@ public struct DeveloperServicesFetchDeviceOperation: DeveloperServicesOperation}public func perform(completion: @escaping (Result<DeveloperServicesDevice, Error>) -> Void) {- let request = DeveloperServicesListDevicesRequest(platform: context.platform, teamID: context.team.id)+ let request = DeveloperServicesListDevicesRequest(platform: context.platform, teamID: context.teamID)context.client.send(request) { result inguard let devices = result.get(withErrorHandler: completion) else { return }if let device = devices.first(where: { $0.udid == self.context.udid }) {@@ -25,7 +25,7 @@ public struct DeveloperServicesFetchDeviceOperation: DeveloperServicesOperationlet addRequest = DeveloperServicesAddDeviceRequest(platform: self.context.platform,- teamID: self.context.team.id,+ teamID: self.context.teamID,udid: self.context.udid,name: self.context.deviceName)diff --git a/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift b/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swiftindex eb58ad3..773bacc 100644--- a/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift+++ b/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift@@ -22,18 +22,18 @@ public struct DeveloperServicesFetchProfileOperation: DeveloperServicesOperationcompletion: @escaping (Result<DeveloperServicesProfile, Swift.Error>) -> Void) {let request = DeveloperServicesGetProfileRequest(- platform: context.platform, teamID: context.team.id, appIDID: appID.id+ platform: context.platform, teamID: context.teamID, appIDID: appID.id)context.client.send(request, completion: completion)}public func perform(completion: @escaping (Result<DeveloperServicesProfile, Error>) -> Void) {- let request = DeveloperServicesListProfilesRequest(platform: context.platform, teamID: context.team.id)+ let request = DeveloperServicesListProfilesRequest(platform: context.platform, teamID: context.teamID)context.client.send(request) { result inguard let profiles = result.get(withErrorHandler: completion) else { return }if let profile = profiles.first(where: { $0.appID.id == self.appID.id }) {let request = DeveloperServicesDeleteProfileRequest(- platform: self.context.platform, teamID: self.context.team.id, profileID: profile.id+ platform: self.context.platform, teamID: self.context.teamID, profileID: profile.id)self.context.client.send(request) { result inguard result.get(withErrorHandler: completion) != nil else { return }diff --git a/Supersign/Signer/SigningContext.swift b/Supersign/Signer/SigningContext.swiftindex 96d1bce..2f90296 100644--- a/Supersign/Signer/SigningContext.swift+++ b/Supersign/Signer/SigningContext.swift@@ -11,7 +11,7 @@ import Foundationpublic struct SigningContext {public let udid: String- public let team: DeveloperServicesTeam+ public let teamID: DeveloperServicesTeam.IDpublic let client: DeveloperServicesClientpublic let signingInfoManager: SigningInfoManagerpublic let platform: DeveloperServicesPlatform@@ -19,14 +19,14 @@ public struct SigningContext {public init(udid: String,- team: DeveloperServicesTeam,+ teamID: DeveloperServicesTeam.ID,client: DeveloperServicesClient,signingInfoManager: SigningInfoManager,platform: DeveloperServicesPlatform = .current,signerImpl: SignerImpl? = nil) throws {self.udid = udid- self.team = team+ self.teamID = teamIDself.client = clientself.signingInfoManager = signingInfoManagerself.platform = platformdiff --git a/SupersignTests/Tests/SupersignDeveloperServicesTests.swift b/SupersignTests/Tests/SupersignDeveloperServicesTests.swiftindex 33cb890..de5ad87 100644--- a/SupersignTests/Tests/SupersignDeveloperServicesTests.swift+++ b/SupersignTests/Tests/SupersignDeveloperServicesTests.swift@@ -34,7 +34,7 @@ class SupersignDeveloperServicesTests: XCTestCase {let context = try XCTTry(SigningContext(udid: Config.current.udid,- team: team,+ teamID: team.id,client: client,signingInfoManager: TestSigningInfoManager()))diff --git a/SupersignTests/Tests/SupersignSigningTests.swift b/SupersignTests/Tests/SupersignSigningTests.swiftindex 9102e60..ed774f6 100644--- a/SupersignTests/Tests/SupersignSigningTests.swift+++ b/SupersignTests/Tests/SupersignSigningTests.swift@@ -48,7 +48,7 @@ class SupersignSigningTests: XCTestCase {let context = try XCTTry(SigningContext(udid: Config.current.udid,- team: team,+ teamID: team.id,client: client,signingInfoManager: TestSigningInfoManager(),signerImpl: signerImpl