fastlane-plugin-samsungknox 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 687b05c8ca644f58b824440eb3432392a52c5fa773de88bfe372c736568b5cf8
4
- data.tar.gz: '08b1eede7d6c7141ce4e503c8417d77a5ab6ee91c1de7a9890f7a28fec80f450'
3
+ metadata.gz: a54952079f4f11fcee99287b11a0ebd08c8828671e2cd71a0266cdb3af286d7a
4
+ data.tar.gz: fe1ad89fa1f341bfd0c1cb040fede24a143b0d95c8657e09151d2b60b6b8e7f5
5
5
  SHA512:
6
- metadata.gz: 1c7a159f8251cac45b64f7b34a64064dabbc7154c6ce85562aa8324000bfa765b87b4b04d286e1405d09ba27dec76ae89dcaa19ef4a6130a16a47c068a9630d0
7
- data.tar.gz: 0c636b4e3f83bea1cd84d3b9163800db4aadca4b4a5b2d3fb02866c88215ea3c4fa97b36def2a245448bc9841377666b2a420adb0b02cf0e2d28c46bf04057b3
6
+ metadata.gz: 6c14c149b851b5755ecbe5a429a6f0fe590f0666047c2c234c80f274e4f612ad94a9feedd2ae188a2edd0f4d8d687e695b0388cd4dabe1a58a4383fa4de8d86c
7
+ data.tar.gz: a0f21411d2e4410266834e8991026f4709bfaf323f65377892c56bedbd4037c6ed20516d3afdaba508f70ca815a473adf8a64ceeec67448416c58e4f3eeabaf8
@@ -7,16 +7,14 @@ module Fastlane
7
7
  module Actions
8
8
  class KnoxConfigureLibraryUploadAppAction < Action
9
9
  def self.run(params)
10
- UI.message("Welcome to Knox Configure Library Application Upload Fastlane!")
10
+ UI.header("Step: KC Upload App")
11
11
 
12
- credential = {
12
+ access_token = KnoxTokenGenerator.generate_knox_access_token({
13
13
  path: params[:credential_path],
14
14
  key: params[:credential_key]
15
- }
16
-
17
- access_token = KnoxTokenGenerator.generate_knox_access_token(
18
- credential,
19
- params[:clientIdentifierJwtToken]
15
+ },
16
+ params[:clientIdentifierJwtToken],
17
+ params[:api_region].downcase
20
18
  )
21
19
 
22
20
  # application_info = KnoxConfigureLibraryAlreadyExistsAppVersionCheck.search_by_package_name(
@@ -26,11 +24,10 @@ module Fastlane
26
24
 
27
25
  KnoxConfigureLibraryUploadApp.upload_app(
28
26
  access_token[:token],
29
- params[:app_file_path]
27
+ params[:app_file_path],
28
+ params[:app_description],
29
+ params[:api_region].downcase
30
30
  )
31
-
32
- UI.success(access_token)
33
-
34
31
  end
35
32
 
36
33
  def self.description
@@ -42,7 +39,6 @@ module Fastlane
42
39
  end
43
40
 
44
41
  def self.return_value
45
- # If your method provides a return value, you can describe here what it does
46
42
  end
47
43
 
48
44
  def self.details
@@ -59,7 +55,9 @@ module Fastlane
59
55
  # env_name: "KC_PACKAGE_NAME",
60
56
  # description: "",
61
57
  # optional: false),
62
- FastlaneCore::ConfigItem.new(key: :description,
58
+
59
+ # App Configuretion
60
+ FastlaneCore::ConfigItem.new(key: :app_description,
63
61
  env_name: "KC_APP_DESCRIPTION",
64
62
  description: "",
65
63
  optional: true),
@@ -67,6 +65,16 @@ module Fastlane
67
65
  env_name: "KC_APP_FILE_PATH",
68
66
  description: "Path to your APK file",
69
67
  optional: true),
68
+
69
+ # Knox Credential Configuration
70
+ FastlaneCore::ConfigItem.new(key: :api_region,
71
+ env_name: "KC_API_REGION",
72
+ description: "",
73
+ optional: false,
74
+ verify_block: proc do |value|
75
+ UI.user_error!("No API region for Knox Credential given, pass using `api_region: 'value'`") unless (value and not value.empty?)
76
+ end
77
+ ),
70
78
  FastlaneCore::ConfigItem.new(key: :credential_key,
71
79
  env_name: "KNOX_CREDENTIAL_KEY",
72
80
  description: "",
@@ -5,8 +5,10 @@ module Fastlane
5
5
  UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
6
 
7
7
  module KnoxConfigureLibraryUploadApp
8
- def self.upload_app(access_token, app_file_path)
9
- uri = URI('https://eu-kcs-api.samsungknox.com/kcs/v1/kc/applications/upload')
8
+ def self.upload_app(access_token, app_file_path, app_description, api_region)
9
+ UI.header('Step: 📲 Upload Application to Knox Configure Library 📲 ')
10
+
11
+ uri = URI("https://#{api_region}-kcs-api.samsungknox.com/kcs/v1/kc/applications/upload")
10
12
 
11
13
  File.open(app_file_path) do |file|
12
14
  request = Net::HTTP::Post::Multipart.new uri,
@@ -14,17 +16,24 @@ module Fastlane
14
16
 
15
17
  request['X-KNOX-APITOKEN'] = access_token
16
18
 
17
- UI.message("⌛ Uploading the #{'APP'}.")
19
+ UI.message("⌛ Uploading the Application. Please wait a moment...")
18
20
  response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
19
21
  http.request(request)
20
22
  end
21
23
 
22
24
  if response.is_a?(Net::HTTPSuccess)
23
- data = JSON.parse(response.body)
24
- UI.success(data)
25
+ uploadResponseBody = JSON.parse(response.body)
26
+ successResponse = uploadResponseBody['successResponse'][0]
27
+ appInfo = successResponse['appInfo'][0]
28
+ UI.success("🎉 Uploaded Application [#{appInfo['name']}] v#{appInfo['packageVersion']} successfully!")
25
29
  else
26
- raise "Request failed with response: #{response.body}"
27
- end
30
+ uploadResponseBody = JSON.parse(response.body)
31
+ if uploadResponseBody['data'].strip == 'APP_BINARY_EXISTS'
32
+ UI.success("✅ The same Application was found in release with no changes, skipping.")
33
+ else
34
+ raise "Request failed with response: #{response.body}"
35
+ end
36
+ end
28
37
  end
29
38
  end
30
39
  end
@@ -54,8 +54,8 @@ module Fastlane
54
54
  base64_public_key
55
55
  end
56
56
 
57
- def self.get_access_token(validity_for_access_token_in_minutes, base64_encoded_string_public_key, client_identifier_jwt)
58
- uri = URI('https://eu-kcs-api.samsungknox.com/ams/v1/users/accesstoken')
57
+ def self.get_access_token(validity_for_access_token_in_minutes, base64_encoded_string_public_key, client_identifier_jwt, api_region)
58
+ uri = URI("https://#{api_region}-kcs-api.samsungknox.com/ams/v1/users/accesstoken")
59
59
 
60
60
  request_body = {
61
61
  base64EncodedStringPublicKey: base64_encoded_string_public_key,
@@ -67,25 +67,25 @@ module Fastlane
67
67
 
68
68
  if response.is_a?(Net::HTTPSuccess)
69
69
  data = JSON.parse(response.body)
70
- UI.success('✅ ams accessToken generated successfully!')
70
+ UI.success('✅ ams accessToken generated successfully')
71
71
  return data["accessToken"]
72
72
  else
73
73
  raise "Request failed with response: #{response.body}"
74
74
  end
75
75
  end
76
76
 
77
- def self.generate_knox_access_token(credential, clientIdentifierJwtToken)
78
- UI.header('Step: 🔐 KNOX ACCESS TOKEN GENERATE STEP 🔐 ')
77
+ def self.generate_knox_access_token(credential, clientIdentifierJwtToken, api_region)
78
+ UI.header('Step: 🔐 KNOX ACCESS TOKEN GENERATE 🔐 ')
79
79
 
80
- UI.message(' Sign the knox token using the credential...')
80
+ UI.message('🔐 Sign in the knox token using the credential...')
81
81
  generate_signed_jwt_result = generate_signed_jwt(credential, clientIdentifierJwtToken, true)
82
82
 
83
83
  base64_encoding_public_Key = generate_signed_jwt_result[:public_key]
84
84
  sign_by_client_identifier_jwt_token = generate_signed_jwt_result[:token]
85
85
 
86
- UI.message('⏳ Request the knox client identifier jwt ams access token...')
87
- ams_access_token = get_access_token(30, base64_encoding_public_Key, sign_by_client_identifier_jwt_token)
88
- UI.message(' Sign the knox token using the ams access token and private key...')
86
+ UI.message('⏳ Request the knox client identifier jwt ams access token.')
87
+ ams_access_token = get_access_token(30, base64_encoding_public_Key, sign_by_client_identifier_jwt_token, api_region)
88
+ UI.message('🔐 Sign the knox token using the ams access token and private key.')
89
89
  token = generate_signed_jwt(credential, ams_access_token, false)
90
90
 
91
91
  return { token: token[:token] }
@@ -114,7 +114,7 @@ module Fastlane
114
114
 
115
115
  token = JWT.encode(payload, private_key, 'RS512')
116
116
 
117
- UI.success('✅ token generated successfully!')
117
+ UI.success('✅ token generated successfully')
118
118
  return { public_key: public_key, token: token }
119
119
  end
120
120
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Samsungknox
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-samsungknox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jieey1140
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,7 +163,6 @@ files:
163
163
  - lib/fastlane/plugin/samsungknox/helper/knox_configure_error_message.rb
164
164
  - lib/fastlane/plugin/samsungknox/helper/knox_configure_library_already_exists_app_version_check.rb
165
165
  - lib/fastlane/plugin/samsungknox/helper/knox_configure_library_upload_app.rb
166
- - lib/fastlane/plugin/samsungknox/helper/knox_configure_upload_application_to_library.rb
167
166
  - lib/fastlane/plugin/samsungknox/helper/knox_token_generator.rb
168
167
  - lib/fastlane/plugin/samsungknox/version.rb
169
168
  homepage: https://github.com/REDREDGROUP/samsungknox