workato-connector-sdk 1.3.8 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/workato/connector/sdk/action.rb +1 -1
- data/lib/workato/connector/sdk/blank.rb +1 -0
- data/lib/workato/connector/sdk/connector.rb +1 -1
- data/lib/workato/connector/sdk/dsl/workato_package.rb +66 -0
- data/lib/workato/connector/sdk/errors.rb +4 -0
- data/lib/workato/connector/sdk/request.rb +44 -5
- data/lib/workato/connector/sdk/streams.rb +1 -1
- data/lib/workato/extension/string.rb +1 -1
- metadata +24 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4307598e8aa6c86eb54f75b63648f20bc192be58e22a6a5f7c5aa0b4efefd01
|
4
|
+
data.tar.gz: 1db7b500cec4f2e761a2ca3eb9d21c11b14b0a7b67c239f600348bbdac0ec393
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e29f03eed4679751a90297de15988ac154cd83404da08a95484d2651c95c2bdc3aa7bc6a3647225bbb78776de222fe482ef846e21f0d6e8a5cc4d7953be620
|
7
|
+
data.tar.gz: 9d82d01badd7c60f971d3b2bbecf452d6d80314a7833f414b05fd8eb4d6510d7c7328a7c893c99daa6b713c7a66714e4f04d086f4bf2161bfb114e6f08639a47
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.10
|
@@ -40,6 +40,12 @@ module Workato
|
|
40
40
|
ALLOWED_KEY_SIZES = [128, 192, 256].freeze
|
41
41
|
private_constant :ALLOWED_KEY_SIZES
|
42
42
|
|
43
|
+
ALLOWED_INITIALIZATION_VECTOR_SIZE = 96
|
44
|
+
private_constant :ALLOWED_INITIALIZATION_VECTOR_SIZE
|
45
|
+
|
46
|
+
ALLOWED_AUTH_TAG_SIZES = [96, 104, 112, 120, 128].freeze
|
47
|
+
private_constant :ALLOWED_AUTH_TAG_SIZES
|
48
|
+
|
43
49
|
def initialize(streams:, connection:)
|
44
50
|
@streams = streams
|
45
51
|
@connection = connection
|
@@ -163,6 +169,33 @@ module Workato
|
|
163
169
|
Types::Binary.new(cipher.update(string) + cipher.final)
|
164
170
|
end
|
165
171
|
|
172
|
+
def aes_gcm_encrypt(string, key, init_vector, auth_data = '')
|
173
|
+
unless string.is_a?(String) && key.is_a?(String) && init_vector.is_a?(String) && auth_data.is_a?(String)
|
174
|
+
raise Sdk::ArgumentError, 'All arguments must be of type String'
|
175
|
+
end
|
176
|
+
|
177
|
+
unless string.valid_encoding?
|
178
|
+
raise Sdk::ArgumentEncodingError, 'Data to be encrypted must have valid encoding'
|
179
|
+
end
|
180
|
+
|
181
|
+
raise Sdk::ArgumentError, 'Data to be encrypted must not be empty' if string.empty?
|
182
|
+
|
183
|
+
key_size = key.bytesize * 8
|
184
|
+
raise Sdk::ArgumentError, 'Incorrect key size for AES' unless ALLOWED_KEY_SIZES.include?(key_size)
|
185
|
+
|
186
|
+
init_vector_size = init_vector.bytesize * 8
|
187
|
+
unless init_vector_size == ALLOWED_INITIALIZATION_VECTOR_SIZE
|
188
|
+
raise Sdk::ArgumentError, 'Incorrect key size for Initialization Vector'
|
189
|
+
end
|
190
|
+
|
191
|
+
cipher = ::OpenSSL::Cipher.new("AES-#{key_size}-GCM")
|
192
|
+
cipher.encrypt
|
193
|
+
cipher.key = key
|
194
|
+
cipher.iv = init_vector
|
195
|
+
cipher.auth_data = auth_data
|
196
|
+
[cipher.update(string) + cipher.final, cipher.auth_tag].map { |v| Types::Binary.new(v) }
|
197
|
+
end
|
198
|
+
|
166
199
|
def aes_cbc_decrypt(string, key, init_vector = nil)
|
167
200
|
key_size = key.bytesize * 8
|
168
201
|
unless ALLOWED_KEY_SIZES.include?(key_size)
|
@@ -178,6 +211,39 @@ module Workato
|
|
178
211
|
raise Sdk::ArgumentError, e.message
|
179
212
|
end
|
180
213
|
|
214
|
+
def aes_gcm_decrypt(encrypted, key, auth_tag, init_vector, auth_data = '')
|
215
|
+
unless encrypted.is_a?(String) &&
|
216
|
+
key.is_a?(String) &&
|
217
|
+
auth_tag.is_a?(String) &&
|
218
|
+
init_vector.is_a?(String) &&
|
219
|
+
auth_data.is_a?(String)
|
220
|
+
raise Sdk::ArgumentError, 'All arguments must be of type String'
|
221
|
+
end
|
222
|
+
|
223
|
+
unless encrypted.valid_encoding?
|
224
|
+
raise Sdk::ArgumentEncodingError, 'Data to be decrypted must have valid encoding'
|
225
|
+
end
|
226
|
+
|
227
|
+
raise Sdk::ArgumentError, 'Data to be decrypted must not be empty' if encrypted.blank?
|
228
|
+
|
229
|
+
auth_tag_size = auth_tag.bytesize * 8
|
230
|
+
unless ALLOWED_AUTH_TAG_SIZES.include?(auth_tag_size)
|
231
|
+
raise Sdk::ArgumentError, 'Incorrect authentication tag size'
|
232
|
+
end
|
233
|
+
|
234
|
+
key_size = key.bytesize * 8
|
235
|
+
raise Sdk::ArgumentError, 'Incorrect key size for AES' unless ALLOWED_KEY_SIZES.include?(key_size)
|
236
|
+
|
237
|
+
decipher = ::OpenSSL::Cipher.new("AES-#{key_size}-GCM").decrypt
|
238
|
+
decipher.key = key
|
239
|
+
decipher.iv = init_vector
|
240
|
+
decipher.auth_data = auth_data
|
241
|
+
decipher.auth_tag = auth_tag
|
242
|
+
Types::Binary.new(decipher.update(encrypted) + decipher.final)
|
243
|
+
rescue OpenSSL::Cipher::CipherError
|
244
|
+
raise Sdk::ArgumentError, 'Not able to decrypt, please check input values again'
|
245
|
+
end
|
246
|
+
|
181
247
|
def pbkdf2_hmac_sha1(string, salt, iterations = 1000, key_len = 16)
|
182
248
|
Types::Binary.new(::OpenSSL::PKCS5.pbkdf2_hmac_sha1(string, salt, iterations, key_len))
|
183
249
|
end
|
@@ -12,8 +12,12 @@ module Workato
|
|
12
12
|
|
13
13
|
ArgumentError = Class.new(Error)
|
14
14
|
|
15
|
+
ArgumentEncodingError = Class.new(ArgumentError)
|
16
|
+
|
15
17
|
InvalidDefinitionError = Class.new(Error)
|
16
18
|
|
19
|
+
InvalidURIError = Class.new(Error)
|
20
|
+
|
17
21
|
class UnexpectedMethodDefinitionError < InvalidDefinitionError
|
18
22
|
attr_reader :name
|
19
23
|
attr_reader :definition
|
@@ -21,12 +21,14 @@ module Workato
|
|
21
21
|
|
22
22
|
using BlockInvocationRefinements
|
23
23
|
|
24
|
+
ALLOWED_URI_TYPES = [URI::Generic, String].freeze
|
25
|
+
private_constant :ALLOWED_URI_TYPES
|
26
|
+
|
24
27
|
def initialize(uri, method: 'GET', connection: nil, action: nil)
|
25
28
|
super(nil)
|
26
29
|
@uri = uri
|
27
30
|
@method = method
|
28
31
|
@connection = connection
|
29
|
-
@base_uri = connection&.base_uri(connection&.settings || {})
|
30
32
|
@action = action
|
31
33
|
@headers = {}
|
32
34
|
@case_sensitive_headers = {}
|
@@ -153,8 +155,8 @@ module Workato
|
|
153
155
|
self
|
154
156
|
end
|
155
157
|
|
156
|
-
def format_xml(root_element_name, namespaces = {}, strip_response_namespaces: false)
|
157
|
-
request_format_xml(root_element_name, namespaces)
|
158
|
+
def format_xml(root_element_name, namespaces = {}, strip_response_namespaces: false, **kwargs)
|
159
|
+
request_format_xml(root_element_name, namespaces.merge(kwargs))
|
158
160
|
.response_format_xml(strip_response_namespaces: strip_response_namespaces)
|
159
161
|
end
|
160
162
|
|
@@ -273,6 +275,8 @@ module Workato
|
|
273
275
|
begin
|
274
276
|
request = RestClientRequest.new(rest_request_params)
|
275
277
|
response = execute_request(request)
|
278
|
+
rescue URI::InvalidURIError => e
|
279
|
+
Kernel.raise(InvalidURIError, e.message)
|
276
280
|
rescue RestClient::Unauthorized => e
|
277
281
|
Kernel.raise e unless @digest_auth
|
278
282
|
|
@@ -331,8 +335,18 @@ module Workato
|
|
331
335
|
end
|
332
336
|
|
333
337
|
def build_url
|
334
|
-
uri = if @base_uri
|
335
|
-
|
338
|
+
uri = if (base_uri = @connection&.base_uri)
|
339
|
+
unless valid_uri?(@uri)
|
340
|
+
raise_invalid_uri_error(
|
341
|
+
"Expected String or URI as request URL, got: #{@uri.class.name}"
|
342
|
+
)
|
343
|
+
end
|
344
|
+
unless valid_uri?(base_uri)
|
345
|
+
raise_invalid_uri_error(
|
346
|
+
"Expected String or URI as output of base_uri lambda, got: #{base_uri.class.name}"
|
347
|
+
)
|
348
|
+
end
|
349
|
+
merge_uris(base_uri, @uri)
|
336
350
|
else
|
337
351
|
URI.parse(@uri)
|
338
352
|
end
|
@@ -357,6 +371,14 @@ module Workato
|
|
357
371
|
uri.to_s
|
358
372
|
end
|
359
373
|
|
374
|
+
def valid_uri?(path)
|
375
|
+
ALLOWED_URI_TYPES.any? { |type| path.is_a?(type) }
|
376
|
+
end
|
377
|
+
|
378
|
+
def raise_invalid_uri_error(message)
|
379
|
+
Kernel.raise(InvalidURIError, message)
|
380
|
+
end
|
381
|
+
|
360
382
|
def merge_uris(uri1, uri2)
|
361
383
|
(uri1.is_a?(::String) ? URI.parse(uri1) : uri1).merge(uri2)
|
362
384
|
end
|
@@ -549,6 +571,23 @@ module Workato
|
|
549
571
|
net.extra_chain_cert = ssl_extra_chain_cert if ssl_extra_chain_cert
|
550
572
|
net
|
551
573
|
end
|
574
|
+
|
575
|
+
private
|
576
|
+
|
577
|
+
def parse_url_with_auth!(url)
|
578
|
+
# Fix Ruby 2.7 vs 3.0 incompatibility
|
579
|
+
# In ruby 2.7 URI.parse("http:///foo/bar").hostname returns nil
|
580
|
+
# In ruby 3.0 URI.parse("http:///foo/bar").hostname returns ""
|
581
|
+
uri = URI.parse(url)
|
582
|
+
|
583
|
+
if uri.hostname.nil? || uri.hostname.empty?
|
584
|
+
raise URI::InvalidURIError, "bad URI(no host provided): #{url}"
|
585
|
+
end
|
586
|
+
|
587
|
+
super
|
588
|
+
rescue ArgumentError => e
|
589
|
+
raise URI::InvalidURIError, "Invalid URL: #{e.message}"
|
590
|
+
end
|
552
591
|
end
|
553
592
|
|
554
593
|
private_constant :RestClientRequest
|
@@ -35,7 +35,7 @@ module Workato
|
|
35
35
|
|
36
36
|
sig { params(streams_source: SorbetTypes::SourceHash).void }
|
37
37
|
def define_action_methods(streams_source)
|
38
|
-
streams_source.
|
38
|
+
streams_source.each_key do |stream|
|
39
39
|
define_singleton_method(stream) do |input = {}, from = 0, to = nil, frame_size = Stream::DEFAULT_FRAME_SIZE|
|
40
40
|
to ||= from + frame_size
|
41
41
|
self[stream].chunk(input, from, to, frame_size)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workato-connector-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Abolmasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -34,14 +34,20 @@ dependencies:
|
|
34
34
|
name: aws-sigv4
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.2'
|
40
|
+
- - ">="
|
38
41
|
- !ruby/object:Gem::Version
|
39
42
|
version: 1.2.4
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- -
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.2'
|
50
|
+
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
52
|
version: 1.2.4
|
47
53
|
- !ruby/object:Gem::Dependency
|
@@ -90,14 +96,20 @@ dependencies:
|
|
90
96
|
name: gyoku
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
92
98
|
requirements:
|
93
|
-
- -
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.3'
|
102
|
+
- - ">="
|
94
103
|
- !ruby/object:Gem::Version
|
95
104
|
version: 1.3.1
|
96
105
|
type: :runtime
|
97
106
|
prerelease: false
|
98
107
|
version_requirements: !ruby/object:Gem::Requirement
|
99
108
|
requirements:
|
100
|
-
- -
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.3'
|
112
|
+
- - ">="
|
101
113
|
- !ruby/object:Gem::Version
|
102
114
|
version: 1.3.1
|
103
115
|
- !ruby/object:Gem::Dependency
|
@@ -158,16 +170,16 @@ dependencies:
|
|
158
170
|
name: net-http-digest_auth
|
159
171
|
requirement: !ruby/object:Gem::Requirement
|
160
172
|
requirements:
|
161
|
-
- -
|
173
|
+
- - "~>"
|
162
174
|
- !ruby/object:Gem::Version
|
163
|
-
version: 1.4
|
175
|
+
version: '1.4'
|
164
176
|
type: :runtime
|
165
177
|
prerelease: false
|
166
178
|
version_requirements: !ruby/object:Gem::Requirement
|
167
179
|
requirements:
|
168
|
-
- -
|
180
|
+
- - "~>"
|
169
181
|
- !ruby/object:Gem::Version
|
170
|
-
version: 1.4
|
182
|
+
version: '1.4'
|
171
183
|
- !ruby/object:Gem::Dependency
|
172
184
|
name: nokogiri
|
173
185
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +189,7 @@ dependencies:
|
|
177
189
|
version: 1.13.10
|
178
190
|
- - "<"
|
179
191
|
- !ruby/object:Gem::Version
|
180
|
-
version: '1.
|
192
|
+
version: '1.16'
|
181
193
|
type: :runtime
|
182
194
|
prerelease: false
|
183
195
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -187,7 +199,7 @@ dependencies:
|
|
187
199
|
version: 1.13.10
|
188
200
|
- - "<"
|
189
201
|
- !ruby/object:Gem::Version
|
190
|
-
version: '1.
|
202
|
+
version: '1.16'
|
191
203
|
- !ruby/object:Gem::Dependency
|
192
204
|
name: rack
|
193
205
|
requirement: !ruby/object:Gem::Requirement
|