Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
More DS data
Kabir Oberaifb80c3b525e4
diff --git a/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swiftindex eb6a55b..69e4b2a 100644--- a/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swift+++ b/Sources/SupersignCLISupport/DSCommands/DSCertificatesCommand.swift@@ -53,8 +53,11 @@ struct DSCertificatesListCommand: AsyncParsableCommand {print(" expiry: \(expirationDate.formatted(.dateTime))")}- if let contentString = attributes.certificateContent,- let content = Data(base64Encoded: contentString) {+ if let contentString = attributes.certificateContent {+ guard let content = Data(base64Encoded: contentString) else {+ print(" content: error: bad base64")+ continue+ }do {let certificate = try Certificate(data: content)print(" content:")diff --git a/Sources/SupersignCLISupport/DSCommands/DSCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSCommand.swiftindex 02e1ac9..3246516 100644--- a/Sources/SupersignCLISupport/DSCommands/DSCommand.swift+++ b/Sources/SupersignCLISupport/DSCommands/DSCommand.swift@@ -55,8 +55,10 @@ struct DSCommand: AsyncParsableCommand {abstract: "Interact with Apple Developer Services",subcommands: [DSTeamsCommand.self,- DSIdentifiersCommand.self,DSCertificatesCommand.self,+ DSIdentifiersCommand.self,+ DSDevicesCommand.self,+ DSProfilesCommand.self,DSAnisetteCommand.self,])diff --git a/Sources/SupersignCLISupport/DSCommands/DSDevicesCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSDevicesCommand.swiftnew file mode 100644index 0000000..4e76d61--- /dev/null+++ b/Sources/SupersignCLISupport/DSCommands/DSDevicesCommand.swift@@ -0,0 +1,61 @@+import Foundation+import ArgumentParser+import Supersign+import DeveloperAPI++struct DSDevicesCommand: AsyncParsableCommand {+ static let configuration = CommandConfiguration(+ commandName: "devices",+ abstract: "Interact with devices",+ subcommands: [+ DSDevicesListCommand.self,+ ],+ defaultSubcommand: DSDevicesListCommand.self+ )+}++struct DSDevicesListCommand: AsyncParsableCommand {+ static let configuration = CommandConfiguration(+ commandName: "list",+ abstract: "List devices"+ )++ func run() async throws {+ let client = DeveloperAPIClient(auth: try AuthToken.saved().authData())+ let devices = try await client.devicesGetCollection().ok.body.json.data+ for device in devices {+ print("- id: \(device.id)")+ guard let attributes = device.attributes else {+ continue+ }++ if let name = attributes.name {+ print(" name: \(name)")+ }++ if let platform = attributes.platform {+ print(" platform: \(platform.rawValue)")+ }++ if let udid = attributes.udid {+ print(" udid: \(udid)")+ }++ if let deviceClass = attributes.deviceClass {+ print(" device class: \(deviceClass.rawValue)")+ }++ if let status = attributes.status {+ print(" status: \(status.rawValue)")+ }++ if let model = attributes.model {+ print(" model: \(model)")+ }++ if let addedDate = attributes.addedDate {+ print(" added date: \(addedDate.formatted(.dateTime))")+ }+ }+ }+}diff --git a/Sources/SupersignCLISupport/DSCommands/DSProfilesCommand.swift b/Sources/SupersignCLISupport/DSCommands/DSProfilesCommand.swiftnew file mode 100644index 0000000..e37559b--- /dev/null+++ b/Sources/SupersignCLISupport/DSCommands/DSProfilesCommand.swift@@ -0,0 +1,100 @@+import Foundation+import ArgumentParser+import Supersign+import DeveloperAPI++struct DSProfilesCommand: AsyncParsableCommand {+ static let configuration = CommandConfiguration(+ commandName: "profiles",+ abstract: "Interact with profiles",+ subcommands: [+ DSProfilesListCommand.self,+ ],+ defaultSubcommand: DSProfilesListCommand.self+ )+}++struct DSProfilesListCommand: AsyncParsableCommand {+ static let configuration = CommandConfiguration(+ commandName: "list",+ abstract: "List profiles"+ )++ private static let encoder = JSONEncoder()++ func run() async throws {+ let client = DeveloperAPIClient(auth: try AuthToken.saved().authData())+ let profiles = try await client.profilesGetCollection().ok.body.json.data+ for profile in profiles {+ print("- id: \(profile.id)")+ guard let attributes = profile.attributes else {+ continue+ }++ /// - name:+ /// - platform:+ /// - profileType:+ /// - profileState:+ /// - profileContent:+ /// - uuid:+ /// - createdDate:+ /// - expirationDate:++ if let name = attributes.name {+ print(" name: \(name)")+ }++ if let platform = attributes.platform {+ print(" platform: \(platform.rawValue)")+ }++ if let profileType = attributes.profileType {+ print(" profile type: \(profileType.rawValue)")+ }++ if let profileState = attributes.profileState {+ print(" profile state: \(profileState.rawValue)")+ }++ if let uuid = attributes.uuid {+ print(" uuid: \(uuid)")+ }++ if let createdDate = attributes.createdDate {+ print(" created date: \(createdDate.formatted(.dateTime))")+ }++ if let expirationDate = attributes.expirationDate {+ print(" expiration date: \(expirationDate.formatted(.dateTime))")+ }++ if let contentString = attributes.profileContent {+ guard let contentData = Data(base64Encoded: contentString) else {+ print(" content: error: bad base64")+ continue+ }++ do {+ let profile = try Mobileprovision(data: contentData)+ let digest = try profile.digest()+ print(" team identifiers:")+ for teamID in digest.teamIdentifiers {+ print(" - \(teamID.rawValue)")+ }+ print(" certificates:")+ for certificate in digest.certificates {+ print(" - \(certificate.serialNumber())")+ }+ print(" devices:")+ for device in digest.devices {+ print(" - \(device)")+ }+ let entitlements = try? String(decoding: Self.encoder.encode(digest.entitlements), as: UTF8.self)+ print(" entitlements: \(entitlements ?? "<error>")")+ } catch {+ print(" content: error: \(error)")+ }+ }+ }+ }+}