Class: Fastlane::Actions::RustoreGetAuthTokenAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



41
42
43
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 41

def self.authors
  ["apohodun"]
end

.available_optionsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 49

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :key_id,
                            env_name: "RUSTORE_KEY_ID",
                         description: "The ID of the private key from RuStore Console",
                       default_value: ENV['RUSTORE_KEY_ID'] || CredentialsManager::AppfileConfig.try_fetch_value(:rustore_key_id),
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :private_key_path,
                            env_name: "RUSTORE_PRIVATE_KEY_PATH",
                         description: "Path to the RSA private key (.pem) file",
                       default_value: ENV['RUSTORE_PRIVATE_KEY_PATH'] || CredentialsManager::AppfileConfig.try_fetch_value(:rustore_private_key_path),
                            optional: true,
                                type: String,
                       conflicting_options: [:private_key_data]),
    FastlaneCore::ConfigItem.new(key: :private_key_data,
                            env_name: "RUSTORE_PRIVATE_KEY_DATA",
                         description: "The content of the RSA private key (.pem)",
                            optional: true,
                                type: String,
                           sensitive: true,
                       conflicting_options: [:private_key_path])
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 37

def self.description
  "Get RuStore Auth Token using RSA private key"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 80

def self.is_supported?(platform)
  [:android].include?(platform)
end

.outputObject



74
75
76
77
78
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 74

def self.output
  [
    ['RUSTORE_AUTH_TOKEN', 'The RuStore Auth Token']
  ]
end

.return_valueObject



45
46
47
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 45

def self.return_value
  "The RuStore Auth Token (JWE)"
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/rustore_sdk/actions/rustore_get_auth_token_action.rb', line 11

def self.run(params)
  key_id = params[:key_id]
  private_key_path = params[:private_key_path]
  private_key_data = params[:private_key_data]

  UI.message("RuStore Auth Config:")
  UI.message("  Key ID: #{key_id[0..3]}***")
  UI.message("  Private Key Path: #{private_key_path}") if private_key_path
  UI.message("  Private Key Data: [PROVIDED]") if private_key_data

  UI.user_error!("You must provide either 'private_key_path' or 'private_key_data' (or set RUSTORE_PRIVATE_KEY_PATH / RUSTORE_PRIVATE_KEY_DATA env vars)") if private_key_path.nil? && private_key_data.nil?

  UI.message("Fetching auth token from RuStore...")
  token = Helper::RustoreSdkHelper.get_auth_token(
    key_id: key_id,
    private_key_path: private_key_path,
    private_key_data: private_key_data
  )

  UI.success("Successfully obtained RuStore auth token")

  # Save token in shared_values for use in other actions
  Actions.lane_context[SharedValues::RUSTORE_AUTH_TOKEN] = token
  token
end