infisical-sdk 2.3.9 → 3.0.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 +4 -4
- data/.rspec +3 -0
- data/.rubocop.yml +37 -0
- data/.ruby-version +1 -0
- data/.yardopts +5 -0
- data/LICENSE +201 -0
- data/README.md +134 -0
- data/Rakefile +5 -5
- data/infisical-sdk.gemspec +21 -38
- data/lib/infisical/auth.rb +50 -0
- data/lib/infisical/client.rb +67 -0
- data/lib/infisical/errors.rb +82 -0
- data/lib/infisical/http_client.rb +212 -0
- data/lib/infisical/models/machine_identity_credential.rb +34 -0
- data/lib/infisical/models/secret.rb +93 -0
- data/lib/infisical/secrets.rb +213 -0
- data/lib/infisical/version.rb +6 -0
- data/lib/infisical-sdk.rb +3 -43
- data/lib/infisical.rb +9 -0
- metadata +35 -124
- data/Steepfile +0 -46
- data/lib/clients/auth.rb +0 -100
- data/lib/clients/cryptography.rb +0 -90
- data/lib/clients/secrets.rb +0 -171
- data/lib/command_runner.rb +0 -16
- data/lib/extended_schemas/schemas.rb +0 -38
- data/lib/infisical_error.rb +0 -10
- data/lib/infisical_lib.rb +0 -44
- data/lib/linux-arm64/libinfisical_c.so +0 -0
- data/lib/linux-x64/libinfisical_c.so +0 -0
- data/lib/macos-arm64/libinfisical_c.dylib +0 -0
- data/lib/macos-x64/libinfisical_c.dylib +0 -0
- data/lib/schemas.rb +0 -1674
- data/lib/version.rb +0 -5
- data/lib/windows-x64/infisical_c.dll +0 -0
- data/sig/infisical_sdk/auth_client.rbs +0 -20
- data/sig/infisical_sdk/command_runner.rbs +0 -10
- data/sig/infisical_sdk/cryptography_client.rbs +0 -15
- data/sig/infisical_sdk/infisical_client.rbs +0 -30
- data/sig/infisical_sdk/infisical_lib.rbs +0 -7
- data/sig/infisical_sdk/sdk.rbs +0 -3
- data/sig/infisical_sdk/secrets_client.rbs +0 -56
- data/sig/infisical_sdk/structs.rbs +0 -37
data/lib/infisical.rb
ADDED
metadata
CHANGED
|
@@ -1,139 +1,50 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: infisical-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Infisical
|
|
8
|
-
autorequire:
|
|
7
|
+
- Infisical
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
name: dry-struct
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.6'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.6'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: dry-types
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.7'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.7'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: ffi
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '1.15'
|
|
48
|
-
type: :runtime
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '1.15'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: json
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '2.6'
|
|
62
|
-
type: :runtime
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '2.6'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rake
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '13.0'
|
|
76
|
-
type: :runtime
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '13.0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rubocop
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - "~>"
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.21'
|
|
90
|
-
type: :runtime
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - "~>"
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '1.21'
|
|
97
|
-
description: The official Infisical Ruby SDK.
|
|
11
|
+
date: 2026-07-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Native Ruby SDK for fetching and managing secrets with Infisical.
|
|
98
14
|
email:
|
|
99
|
-
-
|
|
15
|
+
- support@infisical.com
|
|
100
16
|
executables: []
|
|
101
17
|
extensions: []
|
|
102
18
|
extra_rdoc_files: []
|
|
103
19
|
files:
|
|
20
|
+
- ".rspec"
|
|
21
|
+
- ".rubocop.yml"
|
|
22
|
+
- ".ruby-version"
|
|
23
|
+
- ".yardopts"
|
|
24
|
+
- LICENSE
|
|
25
|
+
- README.md
|
|
104
26
|
- Rakefile
|
|
105
|
-
- Steepfile
|
|
106
27
|
- infisical-sdk.gemspec
|
|
107
|
-
- lib/clients/auth.rb
|
|
108
|
-
- lib/clients/cryptography.rb
|
|
109
|
-
- lib/clients/secrets.rb
|
|
110
|
-
- lib/command_runner.rb
|
|
111
|
-
- lib/extended_schemas/schemas.rb
|
|
112
28
|
- lib/infisical-sdk.rb
|
|
113
|
-
- lib/
|
|
114
|
-
- lib/
|
|
115
|
-
- lib/
|
|
116
|
-
- lib/
|
|
117
|
-
- lib/
|
|
118
|
-
- lib/
|
|
119
|
-
- lib/
|
|
120
|
-
- lib/
|
|
121
|
-
- lib/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
-
|
|
125
|
-
- sig/infisical_sdk/infisical_client.rbs
|
|
126
|
-
- sig/infisical_sdk/infisical_lib.rbs
|
|
127
|
-
- sig/infisical_sdk/sdk.rbs
|
|
128
|
-
- sig/infisical_sdk/secrets_client.rbs
|
|
129
|
-
- sig/infisical_sdk/structs.rbs
|
|
130
|
-
homepage: https://infisical.com
|
|
131
|
-
licenses: []
|
|
29
|
+
- lib/infisical.rb
|
|
30
|
+
- lib/infisical/auth.rb
|
|
31
|
+
- lib/infisical/client.rb
|
|
32
|
+
- lib/infisical/errors.rb
|
|
33
|
+
- lib/infisical/http_client.rb
|
|
34
|
+
- lib/infisical/models/machine_identity_credential.rb
|
|
35
|
+
- lib/infisical/models/secret.rb
|
|
36
|
+
- lib/infisical/secrets.rb
|
|
37
|
+
- lib/infisical/version.rb
|
|
38
|
+
homepage: https://github.com/Infisical/ruby-sdk
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
132
41
|
metadata:
|
|
133
|
-
homepage_uri: https://
|
|
134
|
-
source_code_uri: https://github.com/
|
|
135
|
-
changelog_uri: https://
|
|
136
|
-
|
|
42
|
+
homepage_uri: https://github.com/Infisical/ruby-sdk
|
|
43
|
+
source_code_uri: https://github.com/Infisical/ruby-sdk
|
|
44
|
+
changelog_uri: https://github.com/Infisical/ruby-sdk/releases
|
|
45
|
+
documentation_uri: https://rubydoc.info/gems/infisical-sdk
|
|
46
|
+
rubygems_mfa_required: 'true'
|
|
47
|
+
post_install_message:
|
|
137
48
|
rdoc_options: []
|
|
138
49
|
require_paths:
|
|
139
50
|
- lib
|
|
@@ -141,15 +52,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
141
52
|
requirements:
|
|
142
53
|
- - ">="
|
|
143
54
|
- !ruby/object:Gem::Version
|
|
144
|
-
version:
|
|
55
|
+
version: 3.0.0
|
|
145
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
57
|
requirements:
|
|
147
58
|
- - ">="
|
|
148
59
|
- !ruby/object:Gem::Version
|
|
149
60
|
version: '0'
|
|
150
61
|
requirements: []
|
|
151
|
-
rubygems_version: 3.
|
|
152
|
-
signing_key:
|
|
62
|
+
rubygems_version: 3.5.22
|
|
63
|
+
signing_key:
|
|
153
64
|
specification_version: 4
|
|
154
|
-
summary:
|
|
65
|
+
summary: Official Infisical SDK for Ruby
|
|
155
66
|
test_files: []
|
data/Steepfile
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
D = Steep::Diagnostic
|
|
2
|
-
#
|
|
3
|
-
# target :lib do
|
|
4
|
-
# signature "sig"
|
|
5
|
-
#
|
|
6
|
-
# check "lib" # Directory name
|
|
7
|
-
# check "Gemfile" # File name
|
|
8
|
-
# check "app/models/**/*.rb" # Glob
|
|
9
|
-
# # ignore "lib/templates/*.rb"
|
|
10
|
-
#
|
|
11
|
-
# # library "pathname" # Standard libraries
|
|
12
|
-
# # library "strong_json" # Gems
|
|
13
|
-
#
|
|
14
|
-
# # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
|
|
15
|
-
# # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
|
|
16
|
-
# # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
|
|
17
|
-
# # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
|
|
18
|
-
# # configure_code_diagnostics do |hash| # You can setup everything yourself
|
|
19
|
-
# # hash[D::Ruby::NoMethod] = :information
|
|
20
|
-
# # end
|
|
21
|
-
# end
|
|
22
|
-
|
|
23
|
-
# target :test do
|
|
24
|
-
# signature "sig", "sig-private"
|
|
25
|
-
#
|
|
26
|
-
# check "test"
|
|
27
|
-
#
|
|
28
|
-
# # library "pathname" # Standard libraries
|
|
29
|
-
# end
|
|
30
|
-
|
|
31
|
-
target :app do
|
|
32
|
-
check 'lib'
|
|
33
|
-
signature 'sig'
|
|
34
|
-
|
|
35
|
-
library 'set', 'pathname'
|
|
36
|
-
ignore(
|
|
37
|
-
'lib/schemas.rb',
|
|
38
|
-
'lib/infisical_lib.rb',
|
|
39
|
-
'lib/extended_schemas/schemas.rb'
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
configure_code_diagnostics do |hash| # You can setup everything yourself
|
|
43
|
-
|
|
44
|
-
hash[D::Ruby::UnknownConstant] = :information
|
|
45
|
-
end
|
|
46
|
-
end
|
data/lib/clients/auth.rb
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'json'
|
|
4
|
-
require_relative '../extended_schemas/schemas'
|
|
5
|
-
|
|
6
|
-
module InfisicalSDK
|
|
7
|
-
# Manage Infisical secrets.
|
|
8
|
-
class AuthClient
|
|
9
|
-
def initialize(command_runner)
|
|
10
|
-
@command_runner = command_runner
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def universal_auth(client_id:, client_secret:)
|
|
14
|
-
response = infisical_execute_command(universal_auth_login: UniversalAuthMethod.new(
|
|
15
|
-
client_id: client_id,
|
|
16
|
-
client_secret: client_secret
|
|
17
|
-
))
|
|
18
|
-
|
|
19
|
-
handle_auth_response(response)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def kubernetes_auth(identity_id:, service_account_token_path:)
|
|
23
|
-
|
|
24
|
-
response = infisical_execute_command(kubernetes_auth_login: KubernetesAuthMethod.new(
|
|
25
|
-
identity_id: identity_id,
|
|
26
|
-
service_account_token_path: service_account_token_path
|
|
27
|
-
))
|
|
28
|
-
|
|
29
|
-
handle_auth_response(response)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def azure_auth(identity_id:)
|
|
33
|
-
|
|
34
|
-
response = infisical_execute_command(azure_auth_login: AzureAuthMethod.new(
|
|
35
|
-
identity_id: identity_id
|
|
36
|
-
))
|
|
37
|
-
|
|
38
|
-
handle_auth_response(response)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def gcp_id_token_auth(identity_id:)
|
|
42
|
-
|
|
43
|
-
response = infisical_execute_command(gcp_id_token_auth_login: GCPIDTokenAuthMethod.new(
|
|
44
|
-
identity_id: identity_id
|
|
45
|
-
))
|
|
46
|
-
|
|
47
|
-
handle_auth_response(response)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def gcp_iam_auth(identity_id:, service_account_key_file_path:)
|
|
51
|
-
|
|
52
|
-
response = infisical_execute_command(gcp_iam_auth_login: GCPIamAuthMethod.new(
|
|
53
|
-
identity_id: identity_id,
|
|
54
|
-
service_account_key_file_path: service_account_key_file_path
|
|
55
|
-
))
|
|
56
|
-
|
|
57
|
-
handle_auth_response(response)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def aws_iam_auth(identity_id:)
|
|
61
|
-
|
|
62
|
-
response = infisical_execute_command(aws_iam_auth_login: AWSIamAuthMethod.new(
|
|
63
|
-
identity_id: identity_id
|
|
64
|
-
))
|
|
65
|
-
|
|
66
|
-
handle_auth_response(response)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
private
|
|
70
|
-
|
|
71
|
-
def error_handler(response)
|
|
72
|
-
|
|
73
|
-
# If the response is successful, we return without raising errors.
|
|
74
|
-
if response.key?('status') && response['status'] == true && response.key?('data')
|
|
75
|
-
return
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
if response['message']
|
|
79
|
-
raise InfisicalError, response['message'] if response.key?('message')
|
|
80
|
-
else
|
|
81
|
-
raise InfisicalError, 'Error while getting response'
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def handle_auth_response(response)
|
|
86
|
-
auth_response = APIResultForAccessTokenSuccessResponse.from_json!(response).to_dynamic
|
|
87
|
-
error_handler(auth_response)
|
|
88
|
-
|
|
89
|
-
auth_response['data']
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def infisical_execute_command(command)
|
|
93
|
-
response = @command_runner.run(InfisicalCommands.new(command))
|
|
94
|
-
raise InfisicalError, 'Error getting response' if response.nil?
|
|
95
|
-
|
|
96
|
-
response
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
data/lib/clients/cryptography.rb
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
|
4
|
-
# rubocop:disable Naming/MethodParameterName
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require 'json'
|
|
9
|
-
require_relative '../extended_schemas/schemas'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
module InfisicalSDK
|
|
13
|
-
# Perform encryption
|
|
14
|
-
class CryptographyClient
|
|
15
|
-
def initialize(command_runner)
|
|
16
|
-
@command_runner = command_runner
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def encrypt_symmetric(data:, key:)
|
|
20
|
-
response = infisical_execute_command(encrypt_symmetric: EncryptSymmetricOptions.new(
|
|
21
|
-
key: key,
|
|
22
|
-
plaintext: data,
|
|
23
|
-
))
|
|
24
|
-
|
|
25
|
-
encrypt_response = APIResultForEncryptSymmetricResponse.from_json!(response).to_dynamic
|
|
26
|
-
error_handler(encrypt_response)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
encrypt_response['data']
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def decrypt_symmetric(
|
|
33
|
-
ciphertext:,
|
|
34
|
-
iv:,
|
|
35
|
-
tag:,
|
|
36
|
-
key:
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
response = infisical_execute_command(decrypt_symmetric: DecryptSymmetricOptions.new(
|
|
40
|
-
ciphertext: ciphertext,
|
|
41
|
-
iv: iv,
|
|
42
|
-
tag: tag,
|
|
43
|
-
key: key
|
|
44
|
-
))
|
|
45
|
-
|
|
46
|
-
decrypt_response = APIResultForDecryptSymmetricResponse.from_json!(response).to_dynamic
|
|
47
|
-
error_handler(decrypt_response)
|
|
48
|
-
|
|
49
|
-
decrypt_response['data']['decrypted']
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def create_symmetric_key
|
|
53
|
-
response = infisical_execute_command(create_symmetric_key: ArbitraryOptions.new(
|
|
54
|
-
data: ''
|
|
55
|
-
))
|
|
56
|
-
|
|
57
|
-
key_response = APIResultForCreateSymmetricKeyResponse.from_json!(response).to_dynamic
|
|
58
|
-
error_handler(key_response)
|
|
59
|
-
|
|
60
|
-
key_response['data']['key']
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
private
|
|
64
|
-
|
|
65
|
-
def error_handler(response)
|
|
66
|
-
|
|
67
|
-
# If the response is successful, we return without raising errors.
|
|
68
|
-
if response.key?('status') && response['status'] == true && response.key?('data')
|
|
69
|
-
return
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
if response['message']
|
|
73
|
-
raise InfisicalError, response['message'] if response.key?('message')
|
|
74
|
-
else
|
|
75
|
-
raise InfisicalError, 'Error while getting response'
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def infisical_execute_command(command)
|
|
80
|
-
response = @command_runner.run(InfisicalCommands.new(command))
|
|
81
|
-
raise InfisicalError, 'Error getting response' if response.nil?
|
|
82
|
-
|
|
83
|
-
response
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# rubocop:enable Metrics/MethodLength
|
|
89
|
-
# rubocop:enable Naming/MethodParameterName
|
|
90
|
-
|
data/lib/clients/secrets.rb
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'json'
|
|
4
|
-
|
|
5
|
-
require_relative '../extended_schemas/schemas'
|
|
6
|
-
|
|
7
|
-
module InfisicalSDK
|
|
8
|
-
# Manage Infisical secrets.
|
|
9
|
-
class SecretsClient
|
|
10
|
-
def initialize(command_runner)
|
|
11
|
-
@command_runner = command_runner
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# rubocop:disable Metrics/ParameterLists
|
|
15
|
-
# rubocop:disable Metrics/MethodLength
|
|
16
|
-
def get(
|
|
17
|
-
secret_name:,
|
|
18
|
-
project_id:,
|
|
19
|
-
environment:,
|
|
20
|
-
expand_secret_references: true,
|
|
21
|
-
path: nil,
|
|
22
|
-
include_imports: nil,
|
|
23
|
-
type: nil
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
response = infisical_execute_command(get_secret: GetSecretOptions.new(
|
|
27
|
-
secret_name: secret_name,
|
|
28
|
-
project_id: project_id,
|
|
29
|
-
environment: environment,
|
|
30
|
-
path: path,
|
|
31
|
-
include_imports: include_imports,
|
|
32
|
-
expand_secret_references: expand_secret_references,
|
|
33
|
-
get_secret_options_type: type
|
|
34
|
-
))
|
|
35
|
-
|
|
36
|
-
secrets_response = APIResultForGetSecretResponse.from_json!(response).to_dynamic
|
|
37
|
-
error_handler(secrets_response)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
secrets_response['data']['secret']
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def list(
|
|
44
|
-
project_id:,
|
|
45
|
-
environment:,
|
|
46
|
-
path: nil ,
|
|
47
|
-
attach_to_process_env: nil,
|
|
48
|
-
expand_secret_references: nil,
|
|
49
|
-
recursive: nil,
|
|
50
|
-
include_imports: nil
|
|
51
|
-
)
|
|
52
|
-
response = infisical_execute_command(list_secrets: ListSecretsOptions.new(
|
|
53
|
-
project_id: project_id,
|
|
54
|
-
environment: environment,
|
|
55
|
-
path: path,
|
|
56
|
-
include_imports: include_imports,
|
|
57
|
-
recursive: recursive,
|
|
58
|
-
attach_to_process_env: attach_to_process_env,
|
|
59
|
-
expand_secret_references: expand_secret_references,
|
|
60
|
-
))
|
|
61
|
-
|
|
62
|
-
secrets_response = APIResultForListSecretsResponse.from_json!(response).to_dynamic
|
|
63
|
-
error_handler(secrets_response)
|
|
64
|
-
|
|
65
|
-
secrets_response['data']['secrets']
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def update(
|
|
69
|
-
secret_name:,
|
|
70
|
-
secret_value:,
|
|
71
|
-
project_id:,
|
|
72
|
-
environment:,
|
|
73
|
-
path: nil,
|
|
74
|
-
skip_multiline_encoding: nil,
|
|
75
|
-
type: nil
|
|
76
|
-
)
|
|
77
|
-
response = infisical_execute_command(update_secret: UpdateSecretOptions.new(
|
|
78
|
-
secret_name: secret_name,
|
|
79
|
-
secret_value: secret_value,
|
|
80
|
-
project_id: project_id,
|
|
81
|
-
environment: environment,
|
|
82
|
-
path: path,
|
|
83
|
-
skip_multiline_encoding: skip_multiline_encoding,
|
|
84
|
-
update_secret_options_type: type
|
|
85
|
-
))
|
|
86
|
-
|
|
87
|
-
secrets_response = APIResultForUpdateSecretResponse.from_json!(response).to_dynamic
|
|
88
|
-
error_handler(secrets_response)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
secrets_response['data']['secret']
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def create(
|
|
95
|
-
secret_name:,
|
|
96
|
-
secret_value:,
|
|
97
|
-
project_id:,
|
|
98
|
-
environment:,
|
|
99
|
-
secret_comment: nil,
|
|
100
|
-
path: nil,
|
|
101
|
-
skip_multiline_encoding: nil,
|
|
102
|
-
type: nil
|
|
103
|
-
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
response = infisical_execute_command(create_secret: CreateSecretOptions.new(
|
|
107
|
-
secret_name: secret_name,
|
|
108
|
-
secret_value: secret_value,
|
|
109
|
-
secret_comment: secret_comment,
|
|
110
|
-
project_id: project_id,
|
|
111
|
-
environment: environment,
|
|
112
|
-
skip_multiline_encoding: skip_multiline_encoding,
|
|
113
|
-
path: path,
|
|
114
|
-
create_secret_options_type: type
|
|
115
|
-
))
|
|
116
|
-
|
|
117
|
-
secrets_response = APIResultForCreateSecretResponse.from_json!(response).to_dynamic
|
|
118
|
-
error_handler(secrets_response)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
secrets_response['data']['secret']
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def delete(
|
|
125
|
-
secret_name:,
|
|
126
|
-
project_id:,
|
|
127
|
-
environment:,
|
|
128
|
-
path: nil,
|
|
129
|
-
type: nil
|
|
130
|
-
)
|
|
131
|
-
response = infisical_execute_command(delete_secret: DeleteSecretOptions.new(
|
|
132
|
-
secret_name: secret_name,
|
|
133
|
-
project_id: project_id,
|
|
134
|
-
environment: environment,
|
|
135
|
-
path: path,
|
|
136
|
-
delete_secret_options_type: type
|
|
137
|
-
))
|
|
138
|
-
|
|
139
|
-
secrets_response = APIResultForDeleteSecretResponse.from_json!(response).to_dynamic
|
|
140
|
-
error_handler(secrets_response)
|
|
141
|
-
|
|
142
|
-
secrets_response['data']['secret']
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
private
|
|
146
|
-
|
|
147
|
-
def error_handler(response)
|
|
148
|
-
|
|
149
|
-
# If the response is successful, we return without raising errors.
|
|
150
|
-
if response.key?('status') && response['status'] == true && response.key?('data')
|
|
151
|
-
return
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
if response['message']
|
|
155
|
-
raise InfisicalError, response['message'] if response.key?('message')
|
|
156
|
-
else
|
|
157
|
-
raise InfisicalError, 'Error while getting response'
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def infisical_execute_command(command)
|
|
162
|
-
response = @command_runner.run(InfisicalCommands.new(command))
|
|
163
|
-
raise InfisicalError, 'Error getting response' if response.nil?
|
|
164
|
-
|
|
165
|
-
response
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# rubocop:enable Metrics/ParameterLists
|
|
171
|
-
# rubocop:enable Metrics/MethodLength
|
data/lib/command_runner.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module InfisicalSDK
|
|
4
|
-
# Run base SDK commands
|
|
5
|
-
class CommandRunner
|
|
6
|
-
def initialize(infisical_sdk, handle)
|
|
7
|
-
@infisical_sdk = infisical_sdk
|
|
8
|
-
@handle = handle
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# @param [Dry-Struct] cmd
|
|
12
|
-
def run(cmd)
|
|
13
|
-
@infisical_sdk.infisical_execute_command(cmd.to_json, @handle)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module InfisicalSDK
|
|
2
|
-
# Command mapper
|
|
3
|
-
class InfisicalCommands < CommandList
|
|
4
|
-
attribute :get_secret, Types.Constructor(GetSecretOptions).optional.default(nil)
|
|
5
|
-
attribute :list_secrets, Types.Constructor(ListSecretsOptions).optional.default(nil)
|
|
6
|
-
attribute :create_secret, Types.Constructor(CreateSecretOptions).optional.default(nil)
|
|
7
|
-
attribute :update_secret, Types.Constructor(UpdateSecretOptions).optional.default(nil)
|
|
8
|
-
attribute :delete_secret, Types.Constructor(DeleteSecretOptions).optional.default(nil)
|
|
9
|
-
attribute :create_symmetric_key, Types.Constructor(ArbitraryOptions).optional.default(nil)
|
|
10
|
-
attribute :encrypt_symmetric, Types.Constructor(EncryptSymmetricOptions).optional.default(nil)
|
|
11
|
-
attribute :decrypt_symmetric, Types.Constructor(DecryptSymmetricOptions).optional.default(nil)
|
|
12
|
-
attribute :universal_auth_login, Types.Constructor(UniversalAuthLoginClass).optional.default(nil)
|
|
13
|
-
attribute :kubernetes_auth_login, Types.Constructor(KubernetesAuthLoginClass).optional.default(nil)
|
|
14
|
-
attribute :azure_auth_login, Types.Constructor(AzureAuthLoginClass).optional.default(nil)
|
|
15
|
-
attribute :gcp_id_token_auth_login, Types.Constructor(GcpIDTokenAuthLoginClass).optional.default(nil)
|
|
16
|
-
attribute :gcp_iam_auth_login, Types.Constructor(GcpIamAuthLoginClass).optional.default(nil)
|
|
17
|
-
attribute :aws_iam_auth_login, Types.Constructor(AwsIamAuthLoginClass).optional.default(nil)
|
|
18
|
-
|
|
19
|
-
def to_dynamic
|
|
20
|
-
{
|
|
21
|
-
"getSecret" => get_secret&.to_dynamic,
|
|
22
|
-
"listSecrets" => list_secrets&.to_dynamic,
|
|
23
|
-
"createSecret" => create_secret&.to_dynamic,
|
|
24
|
-
"updateSecret" => update_secret&.to_dynamic,
|
|
25
|
-
"deleteSecret" => delete_secret&.to_dynamic,
|
|
26
|
-
"createSymmetricKey" => create_symmetric_key&.to_dynamic,
|
|
27
|
-
"encryptSymmetric" => encrypt_symmetric&.to_dynamic,
|
|
28
|
-
"decryptSymmetric" => decrypt_symmetric&.to_dynamic,
|
|
29
|
-
"universalAuthLogin" => universal_auth_login&.to_dynamic,
|
|
30
|
-
"kubernetesAuthLogin" => kubernetes_auth_login&.to_dynamic,
|
|
31
|
-
"azureAuthLogin" => azure_auth_login&.to_dynamic,
|
|
32
|
-
"gcpIdTokenAuthLogin" => gcp_id_token_auth_login&.to_dynamic,
|
|
33
|
-
"gcpIamAuthLogin" => gcp_iam_auth_login&.to_dynamic,
|
|
34
|
-
"awsIamAuthLogin" => aws_iam_auth_login&.to_dynamic,
|
|
35
|
-
}.compact
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|