xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Sources / XKit / Model / Entitlements / EntitlementTypes.swift
EntitlementTypes.swift202 lines · 6.8 KiBRaw
| 1 | // |
| 2 | // EntitlementTypes.swift |
| 3 | // Supercharge |
| 4 | // |
| 5 | // Created by Kabir Oberai on 29/07/19. |
| 6 | // Copyright © 2019 Kabir Oberai. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | import Foundation |
| 10 | import ProtoCodable |
| 11 | |
| 12 | // swiftlint:disable type_name |
| 13 | |
| 14 | extension EntitlementContainer { |
| 15 | public static let supportedTypes: [ProtoCodable.Type] = [ |
| 16 | ApplicationIdentifierEntitlement.self, |
| 17 | TeamIdentifierEntitlement.self, |
| 18 | KeychainAccessGroupsEntitlement.self, |
| 19 | GetTaskAllowEntitlement.self, |
| 20 | // AssociatedDomainsEntitlement.self, |
| 21 | APSEnvironmentEntitlement.self, |
| 22 | AppGroupEntitlement.self, |
| 23 | // NetworkExtensionEntitlement.self, |
| 24 | MultipathEntitlement.self, |
| 25 | VPNConfigurationEntitlement.self, |
| 26 | SiriKitEntitlement.self, |
| 27 | InterAppAudioEntitlement.self, |
| 28 | WirelessAccessoryEntitlement.self, |
| 29 | WiFiAwareEntitlement.self, |
| 30 | HomeKitEntitlement.self, |
| 31 | HealthKitEntitlement.self, |
| 32 | AppleSignInEntitlement.self, |
| 33 | ] |
| 34 | } |
| 35 | |
| 36 | public struct ApplicationIdentifierEntitlement: Entitlement, RawRepresentable { |
| 37 | public static let identifier = "application-identifier" |
| 38 | |
| 39 | public var rawValue: String |
| 40 | public init(rawValue: String) { self.rawValue = rawValue } |
| 41 | } |
| 42 | |
| 43 | public struct TeamIdentifierEntitlement: Entitlement, RawRepresentable { |
| 44 | public static let identifier = "com.apple.developer.team-identifier" |
| 45 | |
| 46 | public var rawValue: String |
| 47 | public init(rawValue: String) { self.rawValue = rawValue } |
| 48 | } |
| 49 | |
| 50 | public struct KeychainAccessGroupsEntitlement: Entitlement, RawRepresentable { |
| 51 | public static let identifier = "keychain-access-groups" |
| 52 | |
| 53 | public var rawValue: [String] |
| 54 | public init(rawValue: [String]) { self.rawValue = rawValue } |
| 55 | |
| 56 | // weird bug – the auto-generated implementation treats rawValue like a regular key for some reason |
| 57 | public init(from decoder: Decoder) throws { |
| 58 | rawValue = try decoder.singleValueContainer().decode([String].self) |
| 59 | } |
| 60 | public func encode(to encoder: Encoder) throws { |
| 61 | var container = encoder.singleValueContainer() |
| 62 | try container.encode(rawValue) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | public struct AppGroupEntitlement: Entitlement, RawRepresentable { |
| 67 | public static let identifier = "com.apple.security.application-groups" |
| 68 | |
| 69 | public var rawValue: [DeveloperServicesAppGroup.GroupID] |
| 70 | public init(rawValue: [DeveloperServicesAppGroup.GroupID]) { self.rawValue = rawValue } |
| 71 | |
| 72 | public init(from decoder: Decoder) throws { |
| 73 | rawValue = try decoder.singleValueContainer().decode([DeveloperServicesAppGroup.GroupID].self) |
| 74 | } |
| 75 | public func encode(to encoder: Encoder) throws { |
| 76 | var container = encoder.singleValueContainer() |
| 77 | try container.encode(rawValue) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | public struct GetTaskAllowEntitlement: Entitlement, RawRepresentable { |
| 82 | public static let identifier = "get-task-allow" |
| 83 | |
| 84 | public var rawValue: Bool |
| 85 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 86 | } |
| 87 | |
| 88 | public struct AssociatedDomainsEntitlement: Entitlement, RawRepresentable { |
| 89 | public static let identifier = "com.apple.developer.associated-domains" |
| 90 | |
| 91 | public var rawValue: [String] |
| 92 | public init(rawValue: [String]) { self.rawValue = rawValue } |
| 93 | |
| 94 | public init(from decoder: Decoder) throws { |
| 95 | rawValue = try decoder.singleValueContainer().decode([String].self) |
| 96 | } |
| 97 | public func encode(to encoder: Encoder) throws { |
| 98 | var container = encoder.singleValueContainer() |
| 99 | try container.encode(rawValue) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | public struct AppleSignInEntitlement: Entitlement, RawRepresentable { |
| 104 | public static let identifier = "com.apple.developer.applesignin" |
| 105 | |
| 106 | public var rawValue: [String] |
| 107 | public init(rawValue: [String]) { self.rawValue = rawValue } |
| 108 | |
| 109 | public init(from decoder: Decoder) throws { |
| 110 | rawValue = try decoder.singleValueContainer().decode([String].self) |
| 111 | } |
| 112 | public func encode(to encoder: Encoder) throws { |
| 113 | var container = encoder.singleValueContainer() |
| 114 | try container.encode(rawValue) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | public enum APSEnvironmentEntitlement: String, Entitlement { |
| 119 | public static let identifier = "aps-environment" |
| 120 | |
| 121 | case development |
| 122 | case production |
| 123 | } |
| 124 | |
| 125 | public enum DataProtectionEntitlement: String, Entitlement { |
| 126 | public static let identifier = "com.apple.developer.default-data-protection" |
| 127 | |
| 128 | case complete = "NSFileProtectionComplete" |
| 129 | case unlessOpen = "NSFileProtectionCompleteUnlessOpen" |
| 130 | case untilFirstAuth = "NSFileProtectionCompleteUntilFirstUserAuthentication" |
| 131 | } |
| 132 | |
| 133 | public struct NetworkExtensionEntitlement: Entitlement, RawRepresentable { |
| 134 | public static let identifier = "com.apple.developer.networking.networkextension" |
| 135 | |
| 136 | public var rawValue: Bool |
| 137 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 138 | } |
| 139 | |
| 140 | public struct MultipathEntitlement: Entitlement, RawRepresentable { |
| 141 | public static let identifier = "com.apple.developer.networking.multipath" |
| 142 | |
| 143 | public var rawValue: Bool |
| 144 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 145 | } |
| 146 | |
| 147 | public struct VPNConfigurationEntitlement: Entitlement, RawRepresentable { |
| 148 | public static let identifier = "com.apple.networking.vpn.configuration" |
| 149 | |
| 150 | public var rawValue: Bool |
| 151 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 152 | } |
| 153 | |
| 154 | public struct SiriKitEntitlement: Entitlement, RawRepresentable { |
| 155 | public static let identifier = "com.apple.developer.siri" |
| 156 | |
| 157 | public var rawValue: Bool |
| 158 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 159 | } |
| 160 | |
| 161 | public struct InterAppAudioEntitlement: Entitlement, RawRepresentable { |
| 162 | public static let identifier = "inter-app-audio" |
| 163 | |
| 164 | public var rawValue: Bool |
| 165 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 166 | } |
| 167 | |
| 168 | public struct WirelessAccessoryEntitlement: Entitlement, RawRepresentable { |
| 169 | public static let identifier = "com.apple.external-accessory.wireless-configuration" |
| 170 | |
| 171 | public var rawValue: Bool |
| 172 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 173 | } |
| 174 | |
| 175 | public struct WiFiAwareEntitlement: Entitlement, RawRepresentable { |
| 176 | public static let identifier = "com.apple.developer.wifi-aware" |
| 177 | |
| 178 | public var rawValue: [String] |
| 179 | public init(rawValue: [String]) { self.rawValue = rawValue } |
| 180 | |
| 181 | public init(from decoder: Decoder) throws { |
| 182 | rawValue = try decoder.singleValueContainer().decode([String].self) |
| 183 | } |
| 184 | public func encode(to encoder: Encoder) throws { |
| 185 | var container = encoder.singleValueContainer() |
| 186 | try container.encode(rawValue) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | public struct HomeKitEntitlement: Entitlement, RawRepresentable { |
| 191 | public static let identifier = "com.apple.developer.homekit" |
| 192 | |
| 193 | public var rawValue: Bool |
| 194 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 195 | } |
| 196 | |
| 197 | public struct HealthKitEntitlement: Entitlement, RawRepresentable { |
| 198 | public static let identifier = "com.apple.developer.healthkit" |
| 199 | |
| 200 | public var rawValue: Bool |
| 201 | public init(rawValue: Bool) { self.rawValue = rawValue } |
| 202 | } |