Class: AppInfo::MobileProvision

Inherits:
File
  • Object
show all
Defined in:
lib/app_info/mobile_provision.rb

Overview

Apple code signing: provisioning profile parser

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods inherited from File

#device, #format, #initialize, #not_implemented_error!, #size

Constructor Details

This class inherits a constructor from AppInfo::File

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



264
265
266
267
268
# File 'lib/app_info/mobile_provision.rb', line 264

def method_missing(method_name, *args, &block)
  mobileprovision.try(:[], method_name.to_s.ai_camelcase) ||
    mobileprovision.send(method_name) ||
    super
end

Instance Method Details

#[](key) ⇒ String?

Returns:

  • (String, nil)


243
244
245
# File 'lib/app_info/mobile_provision.rb', line 243

def [](key)
  mobileprovision.try(:[], key.to_s)
end

#adhoc?Boolea

Returns:

  • (Boolea)


143
144
145
146
147
# File 'lib/app_info/mobile_provision.rb', line 143

def adhoc?
  return false if platform == Platform::MACOS # macOS no need adhoc

  !development? && !devices.nil?
end

#app_nameString?

Returns:

  • (String, nil)


35
36
37
# File 'lib/app_info/mobile_provision.rb', line 35

def app_name
  mobileprovision.try(:[], 'AppIDName')
end

#appstore?Boolea

Detect app store type



131
132
133
134
135
136
137
138
139
140
# File 'lib/app_info/mobile_provision.rb', line 131

def appstore?
  case platform
  when Platform::IOS, Platform::APPLETV
    !development? && entitlements.key?('beta-reports-active')
  when Platform::MACOS
    !development?
  else
    raise NotImplementedError, "Unknown platform: #{platform}"
  end
end

#certificatesArray<Certificate>

return developer certificates.

Returns:



103
104
105
106
107
108
109
110
# File 'lib/app_info/mobile_provision.rb', line 103

def certificates
  certs = mobileprovision.try(:[], 'DeveloperCertificates')
  return if certs.empty?

  certs.each_with_object([]) do |cert_data, obj|
    obj << Certificate.parse(cert_data)
  end
end

#created_dateString?

Returns:

  • (String, nil)


79
80
81
# File 'lib/app_info/mobile_provision.rb', line 79

def created_date
  mobileprovision.try(:[], 'CreationDate')
end

#developer_certsObject

Deprecated.

Use #certificates instead of this method.

return developer certificates.



96
97
98
# File 'lib/app_info/mobile_provision.rb', line 96

def developer_certs
  certificates
end

#development?Boolea

Detect is development type of mobileprovision



116
117
118
119
120
121
122
123
124
125
# File 'lib/app_info/mobile_provision.rb', line 116

def development?
  case platform
  when Platform::IOS, Platform::APPLETV
    entitlements['get-task-allow'] == true
  when Platform::MACOS
    !devices.nil?
  else
    raise NotImplementedError, "Unknown platform: #{platform}"
  end
end

#devicesArray<String>?

Returns:

  • (Array<String>, nil)


59
60
61
# File 'lib/app_info/mobile_provision.rb', line 59

def devices
  mobileprovision.try(:[], 'ProvisionedDevices')
end

#empty?Boolea

Returns:

  • (Boolea)


248
249
250
# File 'lib/app_info/mobile_provision.rb', line 248

def empty?
  mobileprovision.nil?
end

#enabled_capabilitiesArray<String>

Enabled Capabilites

Returns:

  • (Array<String>)

See Also:



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/app_info/mobile_provision.rb', line 161

def enabled_capabilities
  capabilities = []
  capabilities << 'In-App Purchase' << 'GameKit' if adhoc? || appstore?

  entitlements.each_key do |key|
    case key
    when 'aps-environment'
      capabilities << 'Push Notifications'
    when 'com.apple.developer.applesignin'
      capabilities << 'Sign In with Apple'
    when 'com.apple.developer.siri'
      capabilities << 'SiriKit'
    when 'com.apple.security.application-groups'
      capabilities << 'App Groups'
    when 'com.apple.developer.associated-domains'
      capabilities << 'Associated Domains'
    when 'com.apple.developer.default-data-protection'
      capabilities << 'Data Protection'
    when 'com.apple.developer.networking.networkextension'
      capabilities << 'Network Extensions'
    when 'com.apple.developer.networking.vpn.api'
      capabilities << 'Personal VPN'
    when 'com.apple.developer.healthkit',
        'com.apple.developer.healthkit.access'
      capabilities << 'HealthKit' unless capabilities.include?('HealthKit')
    when 'com.apple.developer.icloud-services',
        'com.apple.developer.icloud-container-identifiers'
      capabilities << 'iCloud: CloudKit' unless capabilities.include?('iCloud: CloudKit')
    when 'com.apple.developer.ubiquity-kvstore-identifier'
      capabilities << 'iCloud: iCloud key-value storage'
    when 'com.apple.developer.in-app-payments'
      capabilities << 'Apple Pay'
    when 'com.apple.developer.homekit'
      capabilities << 'HomeKit'
    when 'com.apple.developer.user-fonts'
      capabilities << 'Fonts'
    when 'com.apple.developer.pass-type-identifiers'
      capabilities << 'Wallet'
    when 'inter-app-audio'
      capabilities << 'Inter-App Audio'
    when 'com.apple.developer.networking.multipath'
      capabilities << 'Multipath'
    when 'com.apple.developer.authentication-services.autofill-credential-provider'
      capabilities << 'AutoFill Credential Provider'
    when 'com.apple.developer.networking.wifi-info'
      capabilities << 'Access WiFi Information'
    when 'com.apple.external-accessory.wireless-configuration'
      capabilities << 'Wireless Accessory Configuration'
    when 'com.apple.developer.kernel.extended-virtual-addressing'
      capabilities << 'Extended Virtual Address Space'
    when 'com.apple.developer.nfc.readersession.formats'
      capabilities << 'NFC Tag Reading'
    when 'com.apple.developer.ClassKit-environment'
      capabilities << 'ClassKit'
    when 'com.apple.developer.networking.HotspotConfiguration'
      capabilities << 'Hotspot'
    when 'com.apple.developer.devicecheck.appattest-environment'
      capabilities << 'App Attest'
    when 'com.apple.developer.coremedia.hls.low-latency'
      capabilities << 'Low Latency HLS'
    when 'com.apple.developer.associated-domains.mdm-managed'
      capabilities << 'MDM Managed Associated Domains'
    when 'keychain-access-groups'
      capabilities << 'Keychain Sharing'
    when 'com.apple.developer.usernotifications.time-sensitive'
      capabilities << 'Time Sensitive Notifications'
    when 'com.apple.developer.game-center'
      capabilities << 'Game Center'
    # macOS Only
    when 'com.apple.developer.maps'
      capabilities << 'Maps'
    when 'com.apple.developer.system-extension.install'
      capabilities << 'System Extension'
    when 'com.apple.developer.networking.custom-protocol'
      capabilities << 'Custom Network Protocol'
    end
  end

  capabilities
end

#enterprise?Boolea Also known as: inhouse?

Returns:

  • (Boolea)


150
151
152
153
154
# File 'lib/app_info/mobile_provision.rb', line 150

def enterprise?
  return false if platform == Platform::MACOS # macOS no need adhoc

  !development? && !adhoc? && !appstore?
end

#entitlementsArray<String>?

Returns:

  • (Array<String>, nil)


89
90
91
# File 'lib/app_info/mobile_provision.rb', line 89

def entitlements
  mobileprovision.try(:[], 'Entitlements')
end

#expired_dateString?

Returns:

  • (String, nil)


84
85
86
# File 'lib/app_info/mobile_provision.rb', line 84

def expired_date
  mobileprovision.try(:[], 'ExpirationDate')
end

#manufacturerSymbol

Returns:



11
12
13
# File 'lib/app_info/mobile_provision.rb', line 11

def manufacturer
  Manufacturer::APPLE
end

#mobileprovisionCFPropertyList

Returns:

  • (CFPropertyList)


253
254
255
256
257
258
259
260
261
262
# File 'lib/app_info/mobile_provision.rb', line 253

def mobileprovision
  return @mobileprovision = nil unless ::File.exist?(@file)

  data = ::File.read(@file)
  data = strip_plist_wrapper(data) unless bplist?(data)
  list = CFPropertyList::List.new(data: data).value
  @mobileprovision = CFPropertyList.native_types(list)
rescue CFFormatError
  @mobileprovision = nil
end

#nameString?

Returns:

  • (String, nil)


30
31
32
# File 'lib/app_info/mobile_provision.rb', line 30

def name
  mobileprovision.try(:[], 'Name')
end

#platformSymbol

Returns Platform.

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/app_info/mobile_provision.rb', line 16

def platform
  case platforms[0]
  when :macos
    Platform::MACOS
  when :ios
    Platform::IOS
  when :tvos
    Platform::APPLETV
  else
    raise NotImplementedError, "Unkonwn platform: #{platforms[0]}"
  end
end

#platformsArray<Symbol>

Returns:

  • (Array<Symbol>)


49
50
51
52
53
54
55
56
# File 'lib/app_info/mobile_provision.rb', line 49

def platforms
  return unless platforms = mobileprovision.try(:[], 'Platform')

  platforms.map do |v|
    v = 'macOS' if v == 'OSX'
    v.downcase.to_sym
  end
end

#profile_nameString?

Returns:

  • (String, nil)


74
75
76
# File 'lib/app_info/mobile_provision.rb', line 74

def profile_name
  mobileprovision.try(:[], 'Name')
end

#respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


270
271
272
273
274
# File 'lib/app_info/mobile_provision.rb', line 270

def respond_to_missing?(method_name, *args)
  mobileprovision.key?(method_name.to_s.ai_camelcase) ||
    mobileprovision.respond_to?(method_name) ||
    super
end

#team_identifierString?

Returns:

  • (String, nil)


64
65
66
# File 'lib/app_info/mobile_provision.rb', line 64

def team_identifier
  mobileprovision.try(:[], 'TeamIdentifier')
end

#team_nameString?

Returns:

  • (String, nil)


69
70
71
# File 'lib/app_info/mobile_provision.rb', line 69

def team_name
  mobileprovision.try(:[], 'TeamName')
end

#typeSymbol?

Returns:

  • (Symbol, nil)


40
41
42
43
44
45
46
# File 'lib/app_info/mobile_provision.rb', line 40

def type
  return :development if development?
  return :adhoc if adhoc?
  return :appstore if appstore?

  :enterprise if enterprise?
end