secure-keys 1.1.0 → 1.1.2

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: 419519b083343094f5b375df831c9a6064bc565e24bebf9d82de352e69bfaf3f
4
- data.tar.gz: 1d252fb2c5d99d84f3495518c74c1b28b1dcc7f04664b324ec9456e4c1e1dcd2
3
+ metadata.gz: 8cd5c377f201fdb4fd22802645629371e0846768d444398b5fc8de07152edb58
4
+ data.tar.gz: 845e7fb862ec80987753479bfba9b978336c3090123c41b7dac765ec20a1465b
5
5
  SHA512:
6
- metadata.gz: 6dbb0b1a7971879fe3c207477b8407453868f2d19a47cb497f274f460b84c96ea372ac6db58ca004c2e70e92388209866a1f0b1294c2c1d6b7aa7db1e34c0fb2
7
- data.tar.gz: db29940eceadf08e5ad2d31b8daf83043503bb6b119f444a02872fde9e03514dccb7f21b955ff17b667fff5e569acd7544e04e2e6b31114afd0b74d5e6083faf
6
+ metadata.gz: 301b39d752b908b2f8817223a74ee84d8f08a9e3da3f7c41be022d03f392af2a0cb0dd2a320ed73e0c643536826606dad87a9c384da4c3c58c2e2e1af8149c6c
7
+ data.tar.gz: bd83843339d9169c06e80e31ed3b0fb98f574cd2367001158e668ae38534cc287f8f959b57fbadf343da89e9ddd216f89952c2289a489a9843dbd6ab2bff80ba
data/README.md CHANGED
@@ -15,17 +15,20 @@ Utility to generate a `xcframework` for handling secure keys in iOS projects.
15
15
 
16
16
  - Ruby 3.3.6 or higher
17
17
  - iOS 13.0 or higher
18
+ - macOS 11.0 or higher
18
19
 
19
20
  ### Installation
20
21
 
21
22
  You can install the `SecureKeys` utility using Homebrew using the following command:
22
23
 
23
24
  ```bash
24
- brew tap DerianCordobaPerez/tap https://github.com/DerianCordobaPerez/secure-keys-generator
25
+ brew tap derian-cordoba/secure-keys
25
26
 
26
- brew install DerianCordobaPerez/tap/secure_keys
27
+ brew install derian-cordoba/secure-keys/secure-keys
27
28
  ```
28
29
 
30
+ For more details, you can visit the [homebrew-secure-keys](https://github.com/derian-cordoba/homebrew-secure-keys) repository.
31
+
29
32
  Another way, you can install the `SecureKeys` utility using `gem` command:
30
33
 
31
34
  ```bash
@@ -44,6 +47,8 @@ Then, you can install the gem using:
44
47
  bundle install
45
48
  ```
46
49
 
50
+ For more information about the gem, you can visit the [secure-keys](https://rubygems.org/gems/secure-keys) page.
51
+
47
52
  ## Usage
48
53
 
49
54
  As first step, you need to determine the keys that you want to use in your iOS project. You can define the keys from Keychain or env variables.
@@ -123,6 +128,33 @@ Using bundler:
123
128
  bundle exec secure-keys
124
129
  ```
125
130
 
131
+ To get more information about the command, you can use the `--help` option.
132
+
133
+ ```bash
134
+ secure-keys --help
135
+
136
+ # Output
137
+
138
+ Usage: secure-keys [--options]
139
+
140
+ -h, --help Use the provided commands to select the params
141
+ -d, --delimiter DELIMITER The delimiter to use for the key access (default: ",")
142
+ -i, --identifier IDENTIFIER The identifier to use for the key access (default: "secure-keys")
143
+ -v, --version Show the secure-keys version
144
+ ```
145
+
146
+ To avoid defining the `SECURE_KEYS_IDENTIFIER` and `SECURE_KEYS_DELIMITER` env variables, you can use the `--identifier` and `--delimiter` options.
147
+
148
+ ```bash
149
+ secure-keys --identifier "your-keychain-or-env-variable-identifier" --delimiter "|"
150
+ ```
151
+
152
+ Also, you can use the short options:
153
+
154
+ ```bash
155
+ secure-keys -i "your-keychain-or-env-variable-identifier" -d "|"
156
+ ```
157
+
126
158
  ### iOS project
127
159
 
128
160
  Within the iOS project, you can use the `SecureKeys` target dependency like:
@@ -184,29 +216,30 @@ The process when the script is executed is:
184
216
 
185
217
  1. Create a `.secure-keys` directory.
186
218
  2. Create a temporary `Swift Package` in the `.secure-keys` directory.
187
- 3. Copy the `Keys` source code to the temporary `Swift Package`.
219
+ 3. Copy the `SecureKeys` source code to the temporary `Swift Package`.
220
+
221
+ ```swift
222
+ public enum SecureKey {
188
223
 
189
- ```swift
190
- public enum SecureKey {
224
+ // MARK: - Cases
191
225
 
192
- // MARK: - Cases
226
+ case apiKey
227
+ case someKey
228
+ case unknown
193
229
 
194
- case apiKey
195
- case someKey
196
- case unknown
230
+ // MARK: - Properties
197
231
 
198
- // MARK: - Properties
232
+ /// The decrypted value of the key
233
+ public var decryptedValue: String {
234
+ switch self {
235
+ case .apiKey: [1, 2, 4].decrypt(key: [248, 53, 26], iv: [148, 55, 47], tag: [119, 81])
236
+ case .someKey: [1, 2, 4].decrypt(key: [248, 53, 26], iv: [148, 55, 47], tag: [119, 81])
237
+ case .unknown: fatalError("Unknown key \(rawValue)")
238
+ }
239
+ }
240
+ }
241
+ ```
199
242
 
200
- /// The decrypted value of the key
201
- public var decryptedValue: String {
202
- switch self {
203
- case .apiKey: [1, 2, 4].decrypt(key: [248, 53, 26], iv: [148, 55, 47], tag: [119, 81])
204
- case .someKey: [1, 2, 4].decrypt(key: [248, 53, 26], iv: [148, 55, 47], tag: [119, 81])
205
- case .unknown: fatalError("Unknown key \(rawValue)")
206
- }
207
- }
208
- }
209
- ```
210
243
  4. Generate the `SecureKeys.xcframework` using the temporary `Swift Package`.
211
244
  5. Remove the temporary `Swift Package`.
212
245
 
@@ -0,0 +1,30 @@
1
+ module SecureKeys
2
+ module Core
3
+ module Console
4
+ module Argument
5
+ class Handler
6
+ class << self
7
+ attr_reader :arguments
8
+ end
9
+
10
+ # Configure the default arguments
11
+ @arguments = {
12
+ delimiter: nil,
13
+ identifier: nil,
14
+ }
15
+
16
+ # Fetch the argument value by key
17
+ # from CLI arguments or environment variables
18
+ #
19
+ # @param key [Symbol] the argument key
20
+ # @param default [String] the default value
21
+ #
22
+ # @return [String] the argument value
23
+ def self.fetch(key:, default: nil)
24
+ @arguments[key.to_sym] || ENV.fetch("secure_keys_#{key}".upcase, nil) || default
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../../globals/globals'
5
+ require_relative './handler'
6
+
7
+ module SecureKeys
8
+ module Core
9
+ module Console
10
+ module Argument
11
+ class Parser < OptionParser
12
+ # Initialize the argument parser with the default options
13
+ def initialize
14
+ super('Usage: secure-keys [--options]')
15
+ separator('')
16
+
17
+ # Configure the arguement parser
18
+ configure!
19
+ parse!(into: Handler.arguments)
20
+ end
21
+
22
+ private
23
+
24
+ # Configure the argument parser
25
+ def configure!
26
+ on('-h', '--help', 'Use the provided commands to select the params') do
27
+ puts self
28
+ exit(0)
29
+ end
30
+
31
+ on('-d', '--delimiter DELIMITER', String, "The delimiter to use for the key access (default: \"#{Globals.default_key_delimiter}\")")
32
+ on('-i', '--identifier IDENTIFIER', String, "The identifier to use for the key access (default: \"#{Globals.default_key_access_identifier}\")")
33
+
34
+ on('-v', '--version', 'Show the secure-keys version') do
35
+ puts "secure-keys version: v#{SecureKeys::VERSION}"
36
+ exit(0)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require_relative '../console/arguments/handler'
4
+
3
5
  module SecureKeys
4
6
  module Globals
5
7
  module_function
@@ -40,7 +42,15 @@ module SecureKeys
40
42
  # Returns the identifier to get all the key names
41
43
  # @return [String] key access identifier
42
44
  def key_access_identifier
43
- ENV['SECURE_KEYS_IDENTIFIER'] || default_key_access_identifier
45
+ Core::Console::Argument::Handler.fetch(key: :identifier,
46
+ default: default_key_access_identifier)
47
+ end
48
+
49
+ # Returns the keys delimiter
50
+ # @return [String] keys delimiter
51
+ def key_delimiter
52
+ Core::Console::Argument::Handler.fetch(key: :delimiter,
53
+ default: default_key_delimiter)
44
54
  end
45
55
 
46
56
  # Returns the default key access identifier
@@ -49,12 +59,6 @@ module SecureKeys
49
59
  'secure-keys'
50
60
  end
51
61
 
52
- # Returns the keys delimiter
53
- # @return [String] keys delimiter
54
- def key_delimiter
55
- ENV['SECURE_KEYS_DELIMITER'] || default_key_delimiter
56
- end
57
-
58
62
  # Returns the default keys delimiter
59
63
  # @return [String] default keys delimiter
60
64
  def default_key_delimiter
data/lib/keys.rb CHANGED
@@ -8,6 +8,7 @@ require_relative './core/utils/swift/package'
8
8
  require_relative './core/utils/swift/swift'
9
9
  require_relative './core/utils/swift/xcframework'
10
10
  require_relative './core/utils/openssl/cipher'
11
+ require_relative './core/console/arguments/parser'
11
12
 
12
13
  module SecureKeys
13
14
  class Generator
@@ -18,8 +19,8 @@ module SecureKeys
18
19
  public
19
20
 
20
21
  def initialize
21
- # If the secure keys identifier is not set, set it to 'secure-keys'
22
- ENV['SECURE_KEYS_IDENTIFIER'] = 'secure-keys' unless ENV.key?('SECURE_KEYS_IDENTIFIER')
22
+ # Configure the argument parser
23
+ SecureKeys::Core::Console::Argument::Parser.new
23
24
 
24
25
  puts "🔔 You're using a custom delimiter '#{SecureKeys::Globals.key_delimiter}'" unless SecureKeys::Globals.key_delimiter.eql?(SecureKeys::Globals.default_key_delimiter)
25
26
  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)
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module SecureKeys
4
- VERSION = '1.1.0'.freeze
4
+ VERSION = '1.1.2'.freeze
5
5
  SUMMARY = 'Secure Keys is a simple tool for managing your secret keys'.freeze
6
6
  DESCRIPTION = 'Secure Keys is a simple tool to manage your secret keys in your iOS project'.freeze
7
7
  HOMEPAGE_URI = 'https://github.com/DerianCordobaPerez/secure-keys-generator'.freeze
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.1.0
4
+ version: 1.1.2
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-18 00:00:00.000000000 Z
11
+ date: 2025-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.10.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: optparse
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: osx_keychain
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +116,8 @@ executables:
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
119
+ - "./lib/core/console/arguments/handler.rb"
120
+ - "./lib/core/console/arguments/parser.rb"
105
121
  - "./lib/core/environment/ci.rb"
106
122
  - "./lib/core/environment/keychain.rb"
107
123
  - "./lib/core/globals/globals.rb"