spaceship/lib/spaceship/connect_api/token.rb in fastlane-2.126.0.beta.20190623200100 vs spaceship/lib/spaceship/connect_api/token.rb in fastlane-2.126.0
- old
+ new
@@ -6,17 +6,29 @@
# compute public key
# openssl ec -in key.pem -pubout -out public_key.pem -aes256
module Spaceship
- module ConnectAPI
+ class ConnectAPI
class Token
# maximum expiration supported by AppStore (20 minutes)
MAX_TOKEN_DURATION = 1200
attr_reader :key_id
attr_reader :issuer_id
attr_reader :text
+
+ def self.create(key_id: nil, issuer_id: nil, filepath: nil)
+ key_id ||= ENV['SPACESHIP_CONNECT_API_KEY_ID']
+ issuer_id ||= ENV['SPACESHIP_CONNECT_API_ISSUER_ID']
+ filepath ||= ENV['SPACESHIP_CONNECT_API_KEY_FILEPATH']
+
+ self.new(
+ key_id: key_id,
+ issuer_id: issuer_id,
+ key: OpenSSL::PKey::EC.new(File.read(filepath))
+ )
+ end
def initialize(key_id: nil, issuer_id: nil, key: nil)
@expiration = Time.now + MAX_TOKEN_DURATION
@key_id = key_id
@key = key