secure-keys 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1c55d0d0f427de2248176c7b637d099d707c49802d6e3ef2b726e0d3e2383a8
4
- data.tar.gz: 6cbc1fcdc0a67dce1101ef372849d11f19e1ce07bd48ac52d9c3c34cf2188fed
3
+ metadata.gz: 419519b083343094f5b375df831c9a6064bc565e24bebf9d82de352e69bfaf3f
4
+ data.tar.gz: 1d252fb2c5d99d84f3495518c74c1b28b1dcc7f04664b324ec9456e4c1e1dcd2
5
5
  SHA512:
6
- metadata.gz: 2a8e5c02474072f96dd7da0b61db861c313d8575e2bca0f42c57576f3081b58b7095fb47e17db01eff9ea5b756fac0be1e7d33351e5e4a143110640850fc6e69
7
- data.tar.gz: f10ab748b3c5a74d4ef3b562ae555f5f6e1e93064fe25dc8a23fcfd185ab51baa08e148169a216d5694007ed8ddc0a760037d0b8c81b1233a4c9083a37ab515a
6
+ metadata.gz: 6dbb0b1a7971879fe3c207477b8407453868f2d19a47cb497f274f460b84c96ea372ac6db58ca004c2e70e92388209866a1f0b1294c2c1d6b7aa7db1e34c0fb2
7
+ data.tar.gz: db29940eceadf08e5ad2d31b8daf83043503bb6b119f444a02872fde9e03514dccb7f21b955ff17b667fff5e569acd7544e04e2e6b31114afd0b74d5e6083faf
data/README.md CHANGED
@@ -18,16 +18,30 @@ Utility to generate a `xcframework` for handling secure keys in iOS projects.
18
18
 
19
19
  ### Installation
20
20
 
21
- Install gems using bundler
21
+ You can install the `SecureKeys` utility using Homebrew using the following command:
22
22
 
23
23
  ```bash
24
- bundle install
24
+ brew tap DerianCordobaPerez/tap https://github.com/DerianCordobaPerez/secure-keys-generator
25
+
26
+ brew install DerianCordobaPerez/tap/secure_keys
25
27
  ```
26
28
 
27
- If you don't have bundler installed, you can install it using:
29
+ Another way, you can install the `SecureKeys` utility using `gem` command:
28
30
 
29
31
  ```bash
30
- gem install bundler
32
+ gem install secure-keys
33
+ ```
34
+
35
+ If you using `bundler` you can add the `secure-keys` gem to the `Gemfile`:
36
+
37
+ ```ruby
38
+ gem 'secure-keys'
39
+ ```
40
+
41
+ Then, you can install the gem using:
42
+
43
+ ```bash
44
+ bundle install
31
45
  ```
32
46
 
33
47
  ## Usage
@@ -95,21 +109,29 @@ export SECURE_KEYS_IDENTIFIER="github-token|api_key|firebaseToken"
95
109
 
96
110
  ### Ruby script
97
111
 
98
- To generate the `Keys.xcframework` use the `keys.rb` script with:
112
+ To generate the `SecureKeys.xcframework` use the `secure-keys` command in the iOS project root directory.
113
+
114
+ Using global gem:
115
+
116
+ ```bash
117
+ secure-keys
118
+ ```
119
+
120
+ Using bundler:
99
121
 
100
122
  ```bash
101
- bundle exec ruby ./bin/keys.rb
123
+ bundle exec secure-keys
102
124
  ```
103
125
 
104
126
  ### iOS project
105
127
 
106
- Within the iOS project, you can use the `Keys` target dependency like:
128
+ Within the iOS project, you can use the `SecureKeys` target dependency like:
107
129
 
108
130
  ```swift
109
- import Keys
131
+ import SecureKeys
110
132
 
111
133
  // Using key directly in the code
112
- let apiKey = Keys.apiKey.decryptedValue
134
+ let apiKey = SecureKey.apiKey.decryptedValue
113
135
 
114
136
  // Using key from `Key` enum
115
137
  let someKey: String = key(for: .someKey)
@@ -118,7 +140,7 @@ let someKey: String = key(for: .someKey)
118
140
  let someKey: String = key(.someKey)
119
141
 
120
142
  // Using raw value from `Key` enum
121
- let apiKey: Keys = "apiKey".secretKey
143
+ let apiKey: SecureKey = "apiKey".secretKey
122
144
 
123
145
  // Using raw value from `Key` enum with decrypted value
124
146
  let apiKey: String = "apiKey".secretKey.decryptedValue
@@ -127,7 +149,7 @@ let apiKey: String = "apiKey".secretKey.decryptedValue
127
149
  let apiKey: String = .key(for: .apiKey)
128
150
  ```
129
151
 
130
- ## How to install the `Keys.xcframework` in the iOS project
152
+ ## How to install the `SecureKeys.xcframework` in the iOS project
131
153
 
132
154
  1. From the iOS project, click on the project target, select the `General` tab, and scroll down to the `Frameworks, Libraries, and Embedded Content` section.
133
155
 
@@ -137,35 +159,35 @@ let apiKey: String = .key(for: .apiKey)
137
159
 
138
160
  ![Add Files](/docs/assets/add-xcframework-to-ios-project/second-step.png)
139
161
 
140
- 3. Navigate to the `keys` directory and select the `Keys.xcframework` folder.
162
+ 3. Navigate to the `keys` directory and select the `SecureKeys.xcframework` folder.
141
163
 
142
- ![Select Keys.xcframework](/docs/assets/add-xcframework-to-ios-project/third-step.png)
164
+ ![Select SecureKeys.xcframework](/docs/assets/add-xcframework-to-ios-project/third-step.png)
143
165
 
144
- > Now the `Keys.xcframework` is added to the iOS project.
166
+ > Now the `SecureKeys.xcframework` is added to the iOS project.
145
167
 
146
- ![Select Keys.xcframework](/docs/assets/add-xcframework-to-ios-project/third-step-result.png)
168
+ ![Select SecureKeys.xcframework](/docs/assets/add-xcframework-to-ios-project/third-step-result.png)
147
169
 
148
170
  4. Click on the `Build settings` tab and search for the `Search Paths` section.
149
171
 
150
172
  ![Search Paths](/docs/assets/add-xcframework-to-ios-project/fourth-step.png)
151
173
 
152
- > Add the path to the `Keys.xcframework` in the `Framework Search Paths` section.
174
+ > Add the path to the `SecureKeys.xcframework` in the `Framework Search Paths` section.
153
175
 
154
176
  ```bash
155
177
  $(inherited)
156
- $(SRCROOT)/.keys
178
+ $(SRCROOT)/.secure-keys
157
179
  ```
158
180
 
159
181
  ## How it works
160
182
 
161
183
  The process when the script is executed is:
162
184
 
163
- 1. Create a `.keys` directory.
164
- 2. Create a temporary `Swift Package` in the `.keys` directory.
185
+ 1. Create a `.secure-keys` directory.
186
+ 2. Create a temporary `Swift Package` in the `.secure-keys` directory.
165
187
  3. Copy the `Keys` source code to the temporary `Swift Package`.
166
188
 
167
189
  ```swift
168
- public enum Keys {
190
+ public enum SecureKey {
169
191
 
170
192
  // MARK: - Cases
171
193
 
@@ -185,7 +207,7 @@ The process when the script is executed is:
185
207
  }
186
208
  }
187
209
  ```
188
- 4. Generate the `Keys.xcframework` using the temporary `Swift Package`.
210
+ 4. Generate the `SecureKeys.xcframework` using the temporary `Swift Package`.
189
211
  5. Remove the temporary `Swift Package`.
190
212
 
191
213
  ## License
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'bundler/setup'
4
+ require 'dotenv/load'
4
5
  require_relative '../lib/keys'
5
6
 
6
7
  # Generate the keys
7
- Keys::Generator.new.setup
8
+ SecureKeys::Generator.new.setup
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- module Keys
3
+ module SecureKeys
4
4
  module Core
5
5
  module Environment
6
6
  class CI
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'osx_keychain'
4
4
 
5
- module Keys
5
+ module SecureKeys
6
6
  module Core
7
7
  module Environment
8
8
  class Keychain
@@ -20,7 +20,7 @@ module Keys
20
20
  # @param key [String] the key of the keychain access item to fetch
21
21
  # @return [String] the value of the keychain access item
22
22
  def fetch(key:)
23
- keychain[key, Keys::Globals.key_access_identifier]
23
+ keychain[key, SecureKeys::Globals.key_access_identifier]
24
24
  rescue StandardError
25
25
  puts "❌ Error fetching the key: #{key} from Keychain."
26
26
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- module Keys
3
+ module SecureKeys
4
4
  module Globals
5
5
  module_function
6
6
 
@@ -4,7 +4,7 @@ require 'openssl'
4
4
  require 'base64'
5
5
  require 'securerandom'
6
6
 
7
- module Keys
7
+ module SecureKeys
8
8
  module OpenSSL
9
9
  class Cipher
10
10
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative './swift'
4
4
 
5
- module Keys
5
+ module SecureKeys
6
6
  module Swift
7
7
  class Package
8
8
  # Generate the Swift Package using the configured path
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- module Keys
3
+ module SecureKeys
4
4
  module Swift
5
5
  # Constants
6
6
 
7
7
  # The name of the directory that contains the keys
8
- KEYS_DIRECTORY = '.keys'.freeze
8
+ KEYS_DIRECTORY = '.secure-keys'.freeze
9
9
 
10
10
  # The name of the directory that contains the generated build
11
11
  BUILD_DIRECTORY = 'Build'.freeze
12
12
 
13
13
  # The name of the Swift Package
14
- SWIFT_PACKAGE_NAME = 'Keys'.freeze
14
+ SWIFT_PACKAGE_NAME = 'SecureKeys'.freeze
15
15
 
16
16
  # The name of the directory that contains the generated Swift package
17
17
  SWIFT_PACKAGE_DIRECTORY = "#{KEYS_DIRECTORY}/Package".freeze
@@ -3,7 +3,7 @@
3
3
 
4
4
  require_relative './swift'
5
5
 
6
- module Keys
6
+ module SecureKeys
7
7
  module Swift
8
8
  class Writer
9
9
  private
@@ -70,7 +70,7 @@ module Keys
70
70
  ///
71
71
  /// - Returns: The decrypted value of the key
72
72
  @available(iOS 13.0, *)
73
- public func key(for key: Keys) -> String { key.decryptedValue }
73
+ public func key(for key: SecureKey) -> String { key.decryptedValue }
74
74
 
75
75
  /// Fetch the decrypted value of the key
76
76
  ///
@@ -79,13 +79,13 @@ module Keys
79
79
  ///
80
80
  /// - Returns: The decrypted value of the key
81
81
  @available(iOS 13.0, *)
82
- public func key(_ key: Keys) -> String { key.decryptedValue }
82
+ public func key(_ key: SecureKey) -> String { key.decryptedValue }
83
83
 
84
- // MARK: - Keys enum
84
+ // MARK: - SecureKey enum
85
85
 
86
86
  /// Keys is a class that contains all the keys that are used in the application.
87
87
  @available(iOS 13.0, *)
88
- public enum Keys: String {
88
+ public enum SecureKey: String {
89
89
 
90
90
  // MARK: - Cases
91
91
 
@@ -111,15 +111,15 @@ module Keys
111
111
  }
112
112
  }
113
113
 
114
- // MARK: - String extension for keys
114
+ // MARK: - String extension for secure keys
115
115
 
116
116
  @available(iOS 13.0, *)
117
117
  extension String {
118
118
 
119
119
  // MARK: - Methods
120
120
 
121
- /// Fetch the key from the keys enum
122
- public var secretKey: Keys { Keys(rawValue: self) ?? .unknown }
121
+ /// Fetch the key from the secure keys enum
122
+ public var secretKey: SecureKey { SecureKey(rawValue: self) ?? .unknown }
123
123
 
124
124
  /// Fetch the decrypted value of the key
125
125
  ///
@@ -127,7 +127,7 @@ module Keys
127
127
  /// - key: The key to fetch the decrypted value for
128
128
  ///
129
129
  /// - Returns: The decrypted value of the key
130
- public static func key(for key: Keys) -> String { key.decryptedValue }
130
+ public static func key(for key: SecureKey) -> String { key.decryptedValue }
131
131
  }
132
132
 
133
133
  // swiftlint:enable all
@@ -3,7 +3,7 @@
3
3
  require_relative './swift'
4
4
  require_relative '../../globals/globals'
5
5
 
6
- module Keys
6
+ module SecureKeys
7
7
  module Swift
8
8
  class XCFramework
9
9
  # Generate the XCFramework from the Swift package
@@ -12,7 +12,7 @@ module Keys
12
12
  # Currently this is failling with the following error:
13
13
  # "library with the identifier 'ios-arm64' already exists."
14
14
  %w[Release].each do |configuration|
15
- Keys::Globals.ios_platforms.each do |platform|
15
+ SecureKeys::Globals.ios_platforms.each do |platform|
16
16
  generate_key_modules(configuration:, platform:)
17
17
  generate_key_libraries(configuration:, platform: platform[:path])
18
18
  end
@@ -44,8 +44,8 @@ module Keys
44
44
  def generate_key_libraries(configuration:, platform:)
45
45
  command = <<~BASH
46
46
  cd #{KEYS_DIRECTORY} &&
47
- ar -crs #{BUILD_DIRECTORY}/#{configuration}-#{platform}/libKeys.a \
48
- #{BUILD_DIRECTORY}/#{configuration}-#{platform}/Keys.o
47
+ ar -crs #{BUILD_DIRECTORY}/#{configuration}-#{platform}/lib#{SWIFT_PACKAGE_NAME}.a \
48
+ #{BUILD_DIRECTORY}/#{configuration}-#{platform}/#{SWIFT_PACKAGE_NAME}.o
49
49
  BASH
50
50
 
51
51
  system(command)
@@ -71,8 +71,8 @@ module Keys
71
71
  # Currently this is failling with the following error:
72
72
  # "library with the identifier 'ios-arm64' already exists."
73
73
  %w[Release].map do |configuration|
74
- Keys::Globals.ios_platforms.map do |platform|
75
- "-library #{BUILD_DIRECTORY}/#{configuration}-#{platform[:path]}/libKeys.a"
74
+ SecureKeys::Globals.ios_platforms.map do |platform|
75
+ "-library #{BUILD_DIRECTORY}/#{configuration}-#{platform[:path]}/lib#{SWIFT_PACKAGE_NAME}.a"
76
76
  end.join(' ')
77
77
  end.join(' ')
78
78
  end
data/lib/keys.rb CHANGED
@@ -9,7 +9,7 @@ require_relative './core/utils/swift/swift'
9
9
  require_relative './core/utils/swift/xcframework'
10
10
  require_relative './core/utils/openssl/cipher'
11
11
 
12
- module Keys
12
+ module SecureKeys
13
13
  class Generator
14
14
  private
15
15
 
@@ -21,23 +21,23 @@ module Keys
21
21
  # If the secure keys identifier is not set, set it to 'secure-keys'
22
22
  ENV['SECURE_KEYS_IDENTIFIER'] = 'secure-keys' unless ENV.key?('SECURE_KEYS_IDENTIFIER')
23
23
 
24
- puts "🔔 You're using a custom delimiter '#{Keys::Globals.key_delimiter}'" unless Keys::Globals.key_delimiter.eql?(Keys::Globals.default_key_delimiter)
25
- puts "🔔 You're using a custom key access identifier '#{Keys::Globals.key_access_identifier}'" unless Keys::Globals.key_access_identifier.eql?(Keys::Globals.default_key_access_identifier)
24
+ puts "🔔 You're using a custom delimiter '#{SecureKeys::Globals.key_delimiter}'" unless SecureKeys::Globals.key_delimiter.eql?(SecureKeys::Globals.default_key_delimiter)
25
+ puts "🔔 You're using a custom key access identifier '#{SecureKeys::Globals.key_access_identifier}'" unless SecureKeys::Globals.key_access_identifier.eql?(SecureKeys::Globals.default_key_access_identifier)
26
26
 
27
27
  # Configure cipher
28
- self.cipher = Keys::OpenSSL::Cipher.new
28
+ self.cipher = SecureKeys::OpenSSL::Cipher.new
29
29
 
30
30
  # Configure the secret source based on the environment
31
- if Keys::Globals.ci?
32
- self.secrets_source = Keys::Core::Environment::CI.new
31
+ if SecureKeys::Globals.ci?
32
+ self.secrets_source = SecureKeys::Core::Environment::CI.new
33
33
  else
34
- self.secrets_source = Keys::Core::Environment::Keychain.new
34
+ self.secrets_source = SecureKeys::Core::Environment::Keychain.new
35
35
  end
36
36
 
37
37
  # Define the keys that we want to map
38
- self.secret_keys = secrets_source.fetch(key: Keys::Globals.key_access_identifier)
38
+ self.secret_keys = secrets_source.fetch(key: SecureKeys::Globals.key_access_identifier)
39
39
  .to_s
40
- .split(Keys::Globals.key_delimiter)
40
+ .split(SecureKeys::Globals.key_delimiter)
41
41
  .map(&:strip)
42
42
 
43
43
  # Add the keys that we want to map
@@ -52,14 +52,14 @@ module Keys
52
52
  def setup
53
53
  pre_actions
54
54
 
55
- package = Keys::Swift::Package.new
55
+ package = SecureKeys::Swift::Package.new
56
56
  package.generate
57
57
 
58
- writer = Keys::Swift::Writer.new(mapped_keys: mapped_keys,
59
- secure_key_bytes: cipher.secure_key_bytes)
58
+ writer = SecureKeys::Swift::Writer.new(mapped_keys: mapped_keys,
59
+ secure_key_bytes: cipher.secure_key_bytes)
60
60
  writer.write
61
61
 
62
- xcframework = Keys::Swift::XCFramework.new
62
+ xcframework = SecureKeys::Swift::XCFramework.new
63
63
  xcframework.generate
64
64
 
65
65
  post_actions
@@ -69,15 +69,15 @@ module Keys
69
69
 
70
70
  def pre_actions
71
71
  # Remove the keys directory
72
- system("rm -rf #{Keys::Swift::KEYS_DIRECTORY}")
72
+ system("rm -rf #{SecureKeys::Swift::KEYS_DIRECTORY}")
73
73
  end
74
74
 
75
75
  def post_actions
76
76
  # Remove the keys directory
77
- system("rm -rf #{Keys::Swift::SWIFT_PACKAGE_DIRECTORY}")
77
+ system("rm -rf #{SecureKeys::Swift::SWIFT_PACKAGE_DIRECTORY}")
78
78
 
79
79
  # Remove the build directory
80
- system("rm -rf #{Keys::Swift::KEYS_DIRECTORY}/#{Keys::Swift::BUILD_DIRECTORY}")
80
+ system("rm -rf #{SecureKeys::Swift::KEYS_DIRECTORY}/#{SecureKeys::Swift::BUILD_DIRECTORY}")
81
81
  end
82
82
  end
83
83
  end
data/lib/version.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- module Keys
4
- VERSION = '1.0.0'.freeze
5
- SUMMARY = 'Keys is a simple tool for managing your secret keys'.freeze
6
- DESCRIPTION = 'Keys is a simple tool to manage your secret keys in iOS your project'.freeze
3
+ module SecureKeys
4
+ VERSION = '1.1.0'.freeze
5
+ SUMMARY = 'Secure Keys is a simple tool for managing your secret keys'.freeze
6
+ DESCRIPTION = 'Secure Keys is a simple tool to manage your secret keys in your iOS project'.freeze
7
+ HOMEPAGE_URI = 'https://github.com/DerianCordobaPerez/secure-keys-generator'.freeze
7
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secure-keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derian Córdoba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-16 00:00:00.000000000 Z
11
+ date: 2025-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.7
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: json
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,11 +94,11 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: 1.71.2
83
- description: Keys is a simple tool to manage your secret keys in iOS your project
97
+ description: Secure Keys is a simple tool to manage your secret keys in your iOS project
84
98
  email:
85
99
  - derianricardo451@gmail.com
86
100
  executables:
87
- - keys.rb
101
+ - secure-keys
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
@@ -99,15 +113,20 @@ files:
99
113
  - "./lib/keys.rb"
100
114
  - "./lib/version.rb"
101
115
  - README.md
102
- - bin/keys.rb
116
+ - bin/secure-keys
103
117
  homepage: https://github.com/DerianCordobaPerez/secure-keys-generator
104
118
  licenses:
105
119
  - MIT
106
- metadata: {}
120
+ metadata:
121
+ bug_tracker_uri: https://github.com/DerianCordobaPerez/secure-keys-generator/issues
122
+ documentation_uri: https://github.com/DerianCordobaPerez/secure-keys-generator/blob/main/README.md
123
+ homepage_uri: https://github.com/DerianCordobaPerez/secure-keys-generator
124
+ source_code_uri: https://github.com/DerianCordobaPerez/secure-keys-generator
125
+ changelog_uri: https://github.com/DerianCordobaPerez/secure-keys-generator/releases
107
126
  post_install_message:
108
127
  rdoc_options: []
109
128
  require_paths:
110
- - lib
129
+ - "*/lib"
111
130
  required_ruby_version: !ruby/object:Gem::Requirement
112
131
  requirements:
113
132
  - - ">="
@@ -122,5 +141,5 @@ requirements: []
122
141
  rubygems_version: 3.5.22
123
142
  signing_key:
124
143
  specification_version: 4
125
- summary: Keys is a simple tool for managing your secret keys
144
+ summary: Secure Keys is a simple tool for managing your secret keys
126
145
  test_files: []