secure-keys 1.1.1 → 1.1.3
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 +4 -4
- data/README.md +57 -6
- data/lib/core/console/arguments/handler.rb +33 -0
- data/lib/core/console/arguments/parser.rb +48 -0
- data/lib/core/console/logger.rb +123 -0
- data/lib/core/console/shell.rb +61 -0
- data/lib/core/globals/globals.rb +35 -7
- data/lib/core/utils/swift/package.rb +2 -1
- data/lib/core/utils/swift/xcframework.rb +25 -4
- data/lib/core/utils/swift/xcodeproj.rb +69 -0
- data/lib/keys.rb +3 -2
- data/lib/version.rb +2 -2
- metadata +139 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6946af00c20082e078ea40c755f0738199bc46640496cf42eb95fa57c9c87483
|
4
|
+
data.tar.gz: bb59bb065970abcd05a903030d48c8cd0164b5b8ee74b4f43b7368877abde082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7b7aab488356cbc4afa09de94c9f36de7911820d10aaa52b7896f5edf645051c245fb8eb89866fae9a0ac32c0eecf450fd473423698346a17609f9faf07cf9a
|
7
|
+
data.tar.gz: ccb083a8d120236864b12557205f28c4798d264cdc8008605c0899e23590dbd98dee1b32a93277b46bd867eb5c4293ff1c48796d7567c3122daf03e5713dd0bf
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<div style="display: flex; gap: 10px; padding-bottom: 20px;">
|
2
|
-
<img src="https://img.shields.io/badge/version-1.
|
2
|
+
<img src="https://img.shields.io/badge/version-1.1.3-cyan" alt="SecureKeys Version 1.1.3">
|
3
3
|
|
4
4
|
<img src="https://img.shields.io/badge/iOS-^13.0-blue" alt="iOS version 13.0">
|
5
5
|
|
@@ -128,6 +128,36 @@ Using bundler:
|
|
128
128
|
bundle exec secure-keys
|
129
129
|
```
|
130
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
|
+
--add-xcframework-to-target TARGET Add the xcframework to the target
|
142
|
+
-d, --delimiter DELIMITER The delimiter to use for the key access (default: ",")
|
143
|
+
-i, --identifier IDENTIFIER The identifier to use for the key access (default: "secure-keys")
|
144
|
+
--verbose Enable verbose mode (default: false)
|
145
|
+
-v, --version Show the secure-keys version
|
146
|
+
-x, --xcodeproj XCODEPROJ The Xcode project path (default: the first found Xcode project)
|
147
|
+
```
|
148
|
+
|
149
|
+
To avoid defining the `SECURE_KEYS_IDENTIFIER` and `SECURE_KEYS_DELIMITER` env variables, you can use the `--identifier` and `--delimiter` options.
|
150
|
+
|
151
|
+
```bash
|
152
|
+
secure-keys --identifier "your-keychain-or-env-variable-identifier" --delimiter "|"
|
153
|
+
```
|
154
|
+
|
155
|
+
Also, you can use the short options:
|
156
|
+
|
157
|
+
```bash
|
158
|
+
secure-keys -i "your-keychain-or-env-variable-identifier" -d "|"
|
159
|
+
```
|
160
|
+
|
131
161
|
### iOS project
|
132
162
|
|
133
163
|
Within the iOS project, you can use the `SecureKeys` target dependency like:
|
@@ -138,16 +168,16 @@ import SecureKeys
|
|
138
168
|
// Using key directly in the code
|
139
169
|
let apiKey = SecureKey.apiKey.decryptedValue
|
140
170
|
|
141
|
-
// Using key from `
|
171
|
+
// Using key from `SecureKey` enum
|
142
172
|
let someKey: String = key(for: .someKey)
|
143
173
|
|
144
|
-
// Alternative way to use key from `
|
174
|
+
// Alternative way to use key from `SecureKey` enum
|
145
175
|
let someKey: String = key(.someKey)
|
146
176
|
|
147
|
-
// Using raw value from `
|
177
|
+
// Using raw value from `SecureKey` enum
|
148
178
|
let apiKey: SecureKey = "apiKey".secretKey
|
149
179
|
|
150
|
-
// Using raw value from `
|
180
|
+
// Using raw value from `SecureKey` enum with decrypted value
|
151
181
|
let apiKey: String = "apiKey".secretKey.decryptedValue
|
152
182
|
|
153
183
|
// Using `key` method to get the key
|
@@ -156,6 +186,27 @@ let apiKey: String = .key(for: .apiKey)
|
|
156
186
|
|
157
187
|
## How to install the `SecureKeys.xcframework` in the iOS project
|
158
188
|
|
189
|
+
### Automatically
|
190
|
+
|
191
|
+
From the `secure-keys` command, you can use the `--add-xcframework-to-target` option to add the `SecureKeys.xcframework` to the iOS project.
|
192
|
+
|
193
|
+
```bash
|
194
|
+
secure-keys --add-xcframework-to-target "YourTargetName"
|
195
|
+
```
|
196
|
+
|
197
|
+
Also, you can specify your Xcode project path using the `--xcodeproj` option.
|
198
|
+
|
199
|
+
```bash
|
200
|
+
secure-keys --add-xcframework-to-target "YourTargetName" --xcodeproj "/path/to/your/project.xcodeproj"
|
201
|
+
```
|
202
|
+
|
203
|
+
> [!IMPORTANT]
|
204
|
+
> By default, the xcodeproj path would be the first found Xcode project.
|
205
|
+
|
206
|
+
This command will generate the `SecureKeys.xcframework` and add it to the iOS project.
|
207
|
+
|
208
|
+
### Manually
|
209
|
+
|
159
210
|
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.
|
160
211
|
|
161
212
|

|
@@ -189,7 +240,7 @@ The process when the script is executed is:
|
|
189
240
|
|
190
241
|
1. Create a `.secure-keys` directory.
|
191
242
|
2. Create a temporary `Swift Package` in the `.secure-keys` directory.
|
192
|
-
3. Copy the `
|
243
|
+
3. Copy the `SecureKeys` source code to the temporary `Swift Package`.
|
193
244
|
|
194
245
|
```swift
|
195
246
|
public enum SecureKey {
|
@@ -0,0 +1,33 @@
|
|
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
|
+
target: nil,
|
15
|
+
verbose: false,
|
16
|
+
xcodeproj: nil,
|
17
|
+
}
|
18
|
+
|
19
|
+
# Fetch the argument value by key
|
20
|
+
# from CLI arguments or environment variables
|
21
|
+
#
|
22
|
+
# @param key [Symbol] the argument key
|
23
|
+
# @param default [String] the default value
|
24
|
+
#
|
25
|
+
# @return [String] the argument value
|
26
|
+
def self.fetch(key:, default: nil)
|
27
|
+
@arguments[key.to_sym] || ENV.fetch("secure_keys_#{key}".upcase, nil) || default
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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('--add-xcframework-to-target TARGET', String, 'Add the xcframework to the target') do |target|
|
32
|
+
Handler.arguments[:target] = target
|
33
|
+
end
|
34
|
+
on('-d', '--delimiter DELIMITER', String, "The delimiter to use for the key access (default: \"#{Globals.default_key_delimiter}\")")
|
35
|
+
on('-i', '--identifier IDENTIFIER', String, "The identifier to use for the key access (default: \"#{Globals.default_key_access_identifier}\")")
|
36
|
+
on('--verbose', TrueClass, 'Enable verbose mode (default: false)')
|
37
|
+
|
38
|
+
on('-v', '--version', 'Show the secure-keys version') do
|
39
|
+
puts "secure-keys version: v#{SecureKeys::VERSION}"
|
40
|
+
exit(0)
|
41
|
+
end
|
42
|
+
on('-x', '--xcodeproj XCODEPROJ', String, 'The Xcode project path (default: the first found Xcode project)')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'logger'
|
3
|
+
require 'tty-screen'
|
4
|
+
require_relative '../globals/globals'
|
5
|
+
|
6
|
+
module SecureKeys
|
7
|
+
module Core
|
8
|
+
module Console
|
9
|
+
module Logger
|
10
|
+
module_function
|
11
|
+
|
12
|
+
# Log a success message
|
13
|
+
# @param message [String] the message to log
|
14
|
+
def success(message:)
|
15
|
+
logger.info(message.to_s.green)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Log an error message
|
19
|
+
# @param message [String] the message to log
|
20
|
+
def error(message:)
|
21
|
+
logger.warn(message.to_s.red)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Log an important message
|
25
|
+
# @param message [String] the message to log
|
26
|
+
def important(message:)
|
27
|
+
logger.info(message.to_s.blue)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Log a warning message
|
31
|
+
# @param message [String] the message to log
|
32
|
+
def warning(message:)
|
33
|
+
logger.info(message.to_s.yellow)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Log a message without any formatting
|
37
|
+
# @param message [String] the message to log
|
38
|
+
def message(message:)
|
39
|
+
logger.info(message.to_s)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Log a deprecated message
|
43
|
+
# @param message [String] the message to log
|
44
|
+
def deprecated(message:)
|
45
|
+
logger.error(message.to_s.deprecated)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Log a command message
|
49
|
+
# @param command [String] the command to log
|
50
|
+
def command(command:)
|
51
|
+
logger.info("$ #{command}".cyan)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Log a verbose message
|
55
|
+
# @param message [String] the message to log
|
56
|
+
def verbose(message:)
|
57
|
+
logger.debug(message.to_s) if AWSTracker::Global.verbose?
|
58
|
+
end
|
59
|
+
|
60
|
+
# Crash the terminal with a message
|
61
|
+
# @param message [String] the message to log
|
62
|
+
def crash!(message:)
|
63
|
+
raise(StandardError.new, message)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Kill the terminal with a message
|
67
|
+
# @param message [String] the message to log
|
68
|
+
def kill!(message:)
|
69
|
+
error(message:)
|
70
|
+
exit(1)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Log a command output
|
74
|
+
# @param command [String] the command to log
|
75
|
+
def command_output(command:)
|
76
|
+
actual = encode_as_utf_8_if_possible(message: command).split("\r")
|
77
|
+
.last || ''
|
78
|
+
actual.split("\n").each do |cmd|
|
79
|
+
prefix = cmd.include?('▸') ? '' : '▸ '
|
80
|
+
logger.info("#{prefix} #{cmd.magenta}")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Create a logger instance if needed
|
85
|
+
# @return [Logger] the logger instance
|
86
|
+
def logger
|
87
|
+
return @log unless @log.nil?
|
88
|
+
|
89
|
+
$stdout.sync = true
|
90
|
+
@log ||= ::Logger.new($stdout)
|
91
|
+
@log.formatter = proc do |severity, datetime, _, message|
|
92
|
+
"#{format_string(datetime:, severity:)} #{message}\n"
|
93
|
+
end
|
94
|
+
|
95
|
+
@log
|
96
|
+
end
|
97
|
+
|
98
|
+
# Format the log string
|
99
|
+
# @param datetime [Time] the datetime to format
|
100
|
+
# @param severity [String] the severity of the log
|
101
|
+
# @return [String] the formatted string
|
102
|
+
def format_string(datetime: Time.now, severity: '')
|
103
|
+
return "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: " if Globals.verbose?
|
104
|
+
|
105
|
+
"[#{datetime.strftime('%H:%M:%S')}]: "
|
106
|
+
end
|
107
|
+
|
108
|
+
# Encode a message as UTF-8 if possible
|
109
|
+
# @param message [String] the message to encode
|
110
|
+
# @return [String] the encoded message
|
111
|
+
def encode_as_utf_8_if_possible(message:)
|
112
|
+
return message if message.valid_encoding?
|
113
|
+
|
114
|
+
return message.encode(Encoding::UTF_8, Encoding::UTF_16) if message.dup
|
115
|
+
.force_encoding(Encoding::UTF_16)
|
116
|
+
.valid_encoding?
|
117
|
+
|
118
|
+
message.encode(Encoding::UTF_8, invalid: :replace)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
require_relative './logger'
|
5
|
+
require_relative '../globals/globals'
|
6
|
+
|
7
|
+
module SecureKeys
|
8
|
+
module Core
|
9
|
+
module Console
|
10
|
+
module Shell
|
11
|
+
module_function
|
12
|
+
|
13
|
+
# Source: https://github.com/fastlane/fastlane/blob/5b2106db41be2ca272dfe5b99360f29879c707bb/fastlane/lib/fastlane/helper/sh_helper.rb#L28
|
14
|
+
# Executes a shell command
|
15
|
+
# All commands will be executed in the given block
|
16
|
+
# @param command [String] The command that should be executed
|
17
|
+
# @param error_handler [Block] A block that will be called with the output of the command if the command exists with a non-zero exit status
|
18
|
+
# @return [Array] An array containing the output of the command, the exit status and the command
|
19
|
+
def sh(command:, error_handler: nil)
|
20
|
+
previous_encoding = [Encoding.default_external, Encoding.default_internal]
|
21
|
+
Encoding.default_external = Encoding::UTF_8
|
22
|
+
Encoding.default_internal = Encoding::UTF_8
|
23
|
+
Logger.command(command:)
|
24
|
+
|
25
|
+
output = ''
|
26
|
+
exit_status = nil
|
27
|
+
Open3.popen2e(command) do |_stdin, io, thread|
|
28
|
+
io.sync = true
|
29
|
+
io.each do |line|
|
30
|
+
Logger.command_output(command: line.strip)
|
31
|
+
output << line
|
32
|
+
end
|
33
|
+
exit_status = thread.value
|
34
|
+
end
|
35
|
+
|
36
|
+
if exit_status.exitstatus.zero?
|
37
|
+
output << command
|
38
|
+
else
|
39
|
+
message = "Exit status of command '#{command}' was #{exit_status.exitstatus} instead of 0.\n#{output}"
|
40
|
+
|
41
|
+
if error_handler || block_given?
|
42
|
+
Logger.error(message:)
|
43
|
+
error_handler&.call(output)
|
44
|
+
else
|
45
|
+
Logger.crash!(message:)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
return yield(exit_status || $CHILD_STATUS, output, command) if block_given?
|
50
|
+
|
51
|
+
[output, exit_status || $CHILD_STATUS, command]
|
52
|
+
rescue StandardError => e
|
53
|
+
raise e
|
54
|
+
ensure
|
55
|
+
Encoding.default_external = previous_encoding.first
|
56
|
+
Encoding.default_internal = previous_encoding.last
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/core/globals/globals.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require_relative '../console/arguments/handler'
|
4
|
+
require_relative '../utils/swift/swift'
|
5
|
+
|
3
6
|
module SecureKeys
|
4
7
|
module Globals
|
5
8
|
module_function
|
@@ -22,6 +25,29 @@ module SecureKeys
|
|
22
25
|
ENV.key?('CIRCLECI')
|
23
26
|
end
|
24
27
|
|
28
|
+
# Check if the current instance is verbose
|
29
|
+
# @return [Bool] true if the current instance is verbose
|
30
|
+
def verbose?
|
31
|
+
Core::Console::Argument::Handler.fetch(key: :verbose,
|
32
|
+
default: ENV.fetch('VERBOSE', false))
|
33
|
+
.to_s
|
34
|
+
.downcase
|
35
|
+
.eql?('true')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the Xcode project path
|
39
|
+
# @return [String] Xcode project path
|
40
|
+
def xcodeproj_path
|
41
|
+
Core::Console::Argument::Handler.fetch(key: :xcodeproj,
|
42
|
+
default: Dir.glob('**/*.xcodeproj').first)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns the secure keys XCFramework path
|
46
|
+
# @return [String] secure keys XCFramework path
|
47
|
+
def secure_keys_xcframework_path
|
48
|
+
Dir.glob("**/#{Swift::KEYS_DIRECTORY}/#{Swift::XCFRAMEWORK_DIRECTORY}").first
|
49
|
+
end
|
50
|
+
|
25
51
|
# Returns the supported iOS platforms
|
26
52
|
# @return [Array] supported iOS platforms
|
27
53
|
def ios_platforms
|
@@ -40,7 +66,15 @@ module SecureKeys
|
|
40
66
|
# Returns the identifier to get all the key names
|
41
67
|
# @return [String] key access identifier
|
42
68
|
def key_access_identifier
|
43
|
-
|
69
|
+
Core::Console::Argument::Handler.fetch(key: :identifier,
|
70
|
+
default: default_key_access_identifier)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns the keys delimiter
|
74
|
+
# @return [String] keys delimiter
|
75
|
+
def key_delimiter
|
76
|
+
Core::Console::Argument::Handler.fetch(key: :delimiter,
|
77
|
+
default: default_key_delimiter)
|
44
78
|
end
|
45
79
|
|
46
80
|
# Returns the default key access identifier
|
@@ -49,12 +83,6 @@ module SecureKeys
|
|
49
83
|
'secure-keys'
|
50
84
|
end
|
51
85
|
|
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
86
|
# Returns the default keys delimiter
|
59
87
|
# @return [String] default keys delimiter
|
60
88
|
def default_key_delimiter
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative './swift'
|
4
|
+
require_relative '../../console/shell'
|
4
5
|
|
5
6
|
module SecureKeys
|
6
7
|
module Swift
|
@@ -14,7 +15,7 @@ module SecureKeys
|
|
14
15
|
swift package init --name #{SWIFT_PACKAGE_NAME} --type library
|
15
16
|
BASH
|
16
17
|
|
17
|
-
|
18
|
+
Core::Console::Shell.sh(command:)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require_relative './swift'
|
4
4
|
require_relative '../../globals/globals'
|
5
|
+
require_relative '../../console/shell'
|
6
|
+
require_relative '../../console/logger'
|
7
|
+
require_relative '../../console/arguments/handler'
|
8
|
+
require_relative '../swift/xcodeproj'
|
5
9
|
|
6
10
|
module SecureKeys
|
7
11
|
module Swift
|
@@ -12,12 +16,13 @@ module SecureKeys
|
|
12
16
|
# Currently this is failling with the following error:
|
13
17
|
# "library with the identifier 'ios-arm64' already exists."
|
14
18
|
%w[Release].each do |configuration|
|
15
|
-
|
19
|
+
Globals.ios_platforms.each do |platform|
|
16
20
|
generate_key_modules(configuration:, platform:)
|
17
21
|
generate_key_libraries(configuration:, platform: platform[:path])
|
18
22
|
end
|
19
23
|
end
|
20
24
|
generate_key_xcframework
|
25
|
+
add_xcframework_to_xcodeproj_target_if_needed
|
21
26
|
end
|
22
27
|
|
23
28
|
private
|
@@ -35,7 +40,7 @@ module SecureKeys
|
|
35
40
|
ARCHS="arm64" BUILD_DIR="../#{BUILD_DIRECTORY}"
|
36
41
|
BASH
|
37
42
|
|
38
|
-
|
43
|
+
Core::Console::Shell.sh(command:)
|
39
44
|
end
|
40
45
|
|
41
46
|
# Generate the Swift package libraries
|
@@ -48,7 +53,7 @@ module SecureKeys
|
|
48
53
|
#{BUILD_DIRECTORY}/#{configuration}-#{platform}/#{SWIFT_PACKAGE_NAME}.o
|
49
54
|
BASH
|
50
55
|
|
51
|
-
|
56
|
+
Core::Console::Shell.sh(command:)
|
52
57
|
end
|
53
58
|
|
54
59
|
# Generate the XCFramework from the Swift package libraries
|
@@ -61,7 +66,7 @@ module SecureKeys
|
|
61
66
|
-output #{XCFRAMEWORK_DIRECTORY}
|
62
67
|
BASH
|
63
68
|
|
64
|
-
|
69
|
+
Core::Console::Shell.sh(command:)
|
65
70
|
end
|
66
71
|
|
67
72
|
# Generate the XCFramework library command
|
@@ -76,6 +81,22 @@ module SecureKeys
|
|
76
81
|
end.join(' ')
|
77
82
|
end.join(' ')
|
78
83
|
end
|
84
|
+
|
85
|
+
# Add the XCFramework to the Xcode project target if needed
|
86
|
+
# @param target_name [String] The target name to add the XCFramework
|
87
|
+
def add_xcframework_to_xcodeproj_target_if_needed(target_name: nil)
|
88
|
+
target_name ||= Core::Console::Argument::Handler.fetch(key: :target)
|
89
|
+
return if target_name.to_s.empty?
|
90
|
+
|
91
|
+
Core::Console::Logger.important(message: "Adding the XCFramework to the target '#{target_name}'")
|
92
|
+
xcodeproj = Xcodeproj.xcodeproj
|
93
|
+
xcodeproj_target = Xcodeproj.xcodeproj_target_by_target_name(xcodeproj:, target_name:)
|
94
|
+
Xcodeproj.add_framework_search_path(xcodeproj_target:)
|
95
|
+
Xcodeproj.add_xcframework_to_build_phases(xcodeproj:, xcodeproj_target:)
|
96
|
+
|
97
|
+
xcodeproj.save
|
98
|
+
Core::Console::Logger.success(message: "The XCFramework was added to the target '#{target_name}'")
|
99
|
+
end
|
79
100
|
end
|
80
101
|
end
|
81
102
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require_relative '../../globals/globals'
|
3
|
+
require_relative '../../utils/swift/swift'
|
4
|
+
require_relative '../../console/logger'
|
5
|
+
|
6
|
+
module SecureKeys
|
7
|
+
module Swift
|
8
|
+
module Xcodeproj
|
9
|
+
module_function
|
10
|
+
|
11
|
+
# Add the SecureKeys XCFramework to the Xcodeproj target build settings
|
12
|
+
# @param target_name [String] The target name to add the XCFramework
|
13
|
+
# @param configurations [Array<String>] The configurations to add the XCFramework
|
14
|
+
def add_framework_search_path(xcodeproj_target:, configurations: %w[Debug Release])
|
15
|
+
configurations.each do |config|
|
16
|
+
paths = ['$(inherited)', "$(SRCROOT)/#{xcframework_relative_path}"]
|
17
|
+
xcodeproj_target.build_settings(config)['FRAMEWORK_SEARCH_PATHS'] = paths
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add the SecureKeys XCFramework to the Xcodeproj target build phases
|
22
|
+
# @param xcodeproj [Xcodeproj::Project] The Xcodeproj to add the XCFramework
|
23
|
+
# @param xcodeproj_target [Xcodeproj] The Xcodeproj target to add the XCFramework
|
24
|
+
def add_xcframework_to_build_phases(xcodeproj:, xcodeproj_target:)
|
25
|
+
Core::Console::Logger.crash!(message: "The xcodeproj #{xcodeproj} already have the #{XCFRAMEWORK_DIRECTORY}") if xcodeproj_has_secure_keys_xcframework?(xcodeproj:)
|
26
|
+
xcframework_reference = xcodeproj.frameworks_group.new_file(xcframework_relative_path)
|
27
|
+
xcodeproj_target.frameworks_build_phase.add_file_reference(xcframework_reference)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get the Xcodeproj target by target name
|
31
|
+
# @param xcodeproj [Xcodeproj::Project] The Xcodeproj to get the target
|
32
|
+
# @param target_name [String] The target name to get
|
33
|
+
# @return [Xcodeproj] The Xcodeproj target
|
34
|
+
# @raise [StandardError] If the target was not found
|
35
|
+
def xcodeproj_target_by_target_name(xcodeproj:, target_name:)
|
36
|
+
xcodeproj_target = xcodeproj.targets.find { |target| target.name.eql?(target_name) }
|
37
|
+
Core::Console::Logger.crash!(message: "The target #{target_name} was not found") if xcodeproj_target.nil?
|
38
|
+
|
39
|
+
xcodeproj_target
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get the Xcodeproj
|
43
|
+
# @return [Xcodeproj] The Xcodeproj
|
44
|
+
def xcodeproj
|
45
|
+
::Xcodeproj::Project.open(SecureKeys::Globals.xcodeproj_path)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Get the XCFramework relative path
|
49
|
+
# @return [Pathname] The XCFramework relative path
|
50
|
+
def xcframework_relative_path
|
51
|
+
Pathname.new(SecureKeys::Globals.secure_keys_xcframework_path)
|
52
|
+
.relative_path_from(Pathname.new(SecureKeys::Globals.xcodeproj_path).dirname)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check if the Xcode project has the secure keys XCFramework
|
56
|
+
# @param xcodeproj [Xcodeproj::Project] The Xcode project
|
57
|
+
# @return [Bool] true if the Xcode project has the secure keys XCFramework
|
58
|
+
def xcodeproj_has_secure_keys_xcframework?(xcodeproj:)
|
59
|
+
xcodeproj.targets.any? do |target|
|
60
|
+
target.frameworks_build_phase.files.any? do |file|
|
61
|
+
return false if file.file_ref.nil?
|
62
|
+
|
63
|
+
file.file_ref.path.include?(SecureKeys::Globals.secure_keys_xcframework_path)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
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
|
-
#
|
22
|
-
|
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,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
module SecureKeys
|
4
|
-
VERSION = '1.1.
|
4
|
+
VERSION = '1.1.3'.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
|
-
HOMEPAGE_URI = 'https://github.com/
|
7
|
+
HOMEPAGE_URI = 'https://github.com/derian-cordoba/secure-keys'.freeze
|
8
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.1.
|
4
|
+
version: 1.1.3
|
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-
|
11
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: digest
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,48 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 2.10.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: logger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.6.6
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.6.6
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: open3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.2.1
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.2.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: optparse
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.6.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.6.0
|
69
125
|
- !ruby/object:Gem::Dependency
|
70
126
|
name: osx_keychain
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +136,48 @@ dependencies:
|
|
80
136
|
- - "~>"
|
81
137
|
- !ruby/object:Gem::Version
|
82
138
|
version: 1.0.2
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: tty-screen
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.8.2
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.8.2
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: xcodeproj
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.27.0
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.27.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rspec
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 3.13.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 3.13.0
|
83
181
|
- !ruby/object:Gem::Dependency
|
84
182
|
name: rubocop
|
85
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +192,34 @@ dependencies:
|
|
94
192
|
- - "~>"
|
95
193
|
- !ruby/object:Gem::Version
|
96
194
|
version: 1.71.2
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: ruby-debug-ide
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 0.7.5
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 0.7.5
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: simplecov
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 0.22.0
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 0.22.0
|
97
223
|
description: Secure Keys is a simple tool to manage your secret keys in your iOS project
|
98
224
|
email:
|
99
225
|
- derianricardo451@gmail.com
|
@@ -102,6 +228,10 @@ executables:
|
|
102
228
|
extensions: []
|
103
229
|
extra_rdoc_files: []
|
104
230
|
files:
|
231
|
+
- "./lib/core/console/arguments/handler.rb"
|
232
|
+
- "./lib/core/console/arguments/parser.rb"
|
233
|
+
- "./lib/core/console/logger.rb"
|
234
|
+
- "./lib/core/console/shell.rb"
|
105
235
|
- "./lib/core/environment/ci.rb"
|
106
236
|
- "./lib/core/environment/keychain.rb"
|
107
237
|
- "./lib/core/globals/globals.rb"
|
@@ -110,19 +240,20 @@ files:
|
|
110
240
|
- "./lib/core/utils/swift/swift.rb"
|
111
241
|
- "./lib/core/utils/swift/writer.rb"
|
112
242
|
- "./lib/core/utils/swift/xcframework.rb"
|
243
|
+
- "./lib/core/utils/swift/xcodeproj.rb"
|
113
244
|
- "./lib/keys.rb"
|
114
245
|
- "./lib/version.rb"
|
115
246
|
- README.md
|
116
247
|
- bin/secure-keys
|
117
|
-
homepage: https://github.com/
|
248
|
+
homepage: https://github.com/derian-cordoba/secure-keys
|
118
249
|
licenses:
|
119
250
|
- MIT
|
120
251
|
metadata:
|
121
|
-
bug_tracker_uri: https://github.com/
|
122
|
-
documentation_uri: https://github.com/
|
123
|
-
homepage_uri: https://github.com/
|
124
|
-
source_code_uri: https://github.com/
|
125
|
-
changelog_uri: https://github.com/
|
252
|
+
bug_tracker_uri: https://github.com/derian-cordoba/secure-keys/issues
|
253
|
+
documentation_uri: https://github.com/derian-cordoba/secure-keys/blob/main/README.md
|
254
|
+
homepage_uri: https://github.com/derian-cordoba/secure-keys
|
255
|
+
source_code_uri: https://github.com/derian-cordoba/secure-keys
|
256
|
+
changelog_uri: https://github.com/derian-cordoba/secure-keys/releases
|
126
257
|
post_install_message:
|
127
258
|
rdoc_options: []
|
128
259
|
require_paths:
|