workato-connector-sdk 1.3.2 → 1.3.3
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/cli/oauth2_command.rb +1 -0
- data/lib/workato/connector/sdk/blank.rb +4 -0
- data/lib/workato/connector/sdk/dsl/csv_package.rb +9 -2
- data/lib/workato/connector/sdk/dsl/net_package.rb +58 -0
- data/lib/workato/connector/sdk/dsl/workato_package.rb +29 -1
- data/lib/workato/connector/sdk/request.rb +3 -2
- data/lib/workato/connector/sdk/trigger.rb +12 -7
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04149c3903c23d8e7e6a02b0f76928d08bd4aeeab5f6fa2602e039a3e1adcb92'
|
4
|
+
data.tar.gz: ad69735af0f602cc35a82507d2479cc5ae3057f0423322aaaa42e7f70c0ad2d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9d9ecafec79226a203c838395303be2619d602be8d3645bdce7215397d19a628a946ac4ef87efbeb887183fe4fbdaf4ea74797a0a1063198c2c12a60186ce7
|
7
|
+
data.tar.gz: 28da7967c46441234a655bd32c498a04400ed6a26f7d7d5481154c7167ce18bf5f05f0a9e289805132c97b5cc45477eae7b4127a890aa331ee8f8ab04ee3c5c1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
@@ -65,6 +65,13 @@ module Workato
|
|
65
65
|
end
|
66
66
|
def parse(str, headers:, col_sep: nil, row_sep: nil, quote_char: nil, skip_blanks: nil,
|
67
67
|
skip_first_line: false)
|
68
|
+
if headers.is_a?(FalseClass)
|
69
|
+
raise Sdk::ArgumentError,
|
70
|
+
'Headers are required. ' \
|
71
|
+
'Pass headers: true to implicitly use the first line or array/string for explicit headers'
|
72
|
+
|
73
|
+
end
|
74
|
+
|
68
75
|
if str.bytesize > MAX_FILE_SIZE_FOR_PARSE
|
69
76
|
raise CsvFileTooBigError.new(str.bytesize, MAX_FILE_SIZE_FOR_PARSE)
|
70
77
|
end
|
@@ -88,7 +95,7 @@ module Workato
|
|
88
95
|
end.to_a
|
89
96
|
rescue CSV::MalformedCSVError => e
|
90
97
|
raise CsvFormatError, e
|
91
|
-
rescue ArgumentError => e
|
98
|
+
rescue ::ArgumentError => e
|
92
99
|
raise Sdk::ArgumentError, e.message
|
93
100
|
end
|
94
101
|
|
@@ -111,7 +118,7 @@ module Workato
|
|
111
118
|
options[:write_headers] = options[:headers].present?
|
112
119
|
|
113
120
|
::CSV.generate(str || String.new, **options, &blk)
|
114
|
-
rescue ArgumentError => e
|
121
|
+
rescue ::ArgumentError => e
|
115
122
|
raise Sdk::ArgumentError, e.message
|
116
123
|
end
|
117
124
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'resolv'
|
5
|
+
|
6
|
+
module Workato
|
7
|
+
module Connector
|
8
|
+
module Sdk
|
9
|
+
NetLookupError = Class.new(Error)
|
10
|
+
|
11
|
+
module Dsl
|
12
|
+
class NetPackage
|
13
|
+
extend T::Sig
|
14
|
+
|
15
|
+
sig { params(name: String, record: String).returns(T::Array[T::Hash[Symbol, T.untyped]]) }
|
16
|
+
def lookup(name, record)
|
17
|
+
case record.upcase
|
18
|
+
when 'A'
|
19
|
+
records = dns_resolver.getresources(name, Resolv::DNS::Resource::IN::A)
|
20
|
+
records.map { |d| { address: d.address.to_s } }
|
21
|
+
when 'SRV'
|
22
|
+
records = dns_resolver.getresources(name, Resolv::DNS::Resource::IN::SRV)
|
23
|
+
records.map do |d|
|
24
|
+
{
|
25
|
+
port: d.port,
|
26
|
+
priority: d.priority,
|
27
|
+
target: d.target.to_s,
|
28
|
+
weight: d.weight
|
29
|
+
}
|
30
|
+
end
|
31
|
+
else
|
32
|
+
raise Sdk::ArgumentError, 'Record type not supported, Supported types: "A", "SRV"'
|
33
|
+
end
|
34
|
+
rescue Resolv::ResolvError, Resolv::ResolvTimeout => e
|
35
|
+
raise NetLookupError, e
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
sig { returns(Resolv::DNS) }
|
41
|
+
def dns_resolver
|
42
|
+
@dns_resolver ||= T.let(Resolv::DNS.new, T.nilable(Resolv::DNS))
|
43
|
+
end
|
44
|
+
|
45
|
+
T::Sig::WithoutRuntime.sig { params(symbol: T.any(String, Symbol), _args: T.untyped).void }
|
46
|
+
def method_missing(symbol, *_args)
|
47
|
+
raise UndefinedStdLibMethodError.new(symbol.to_s, 'workato.net')
|
48
|
+
end
|
49
|
+
|
50
|
+
T::Sig::WithoutRuntime.sig { params(_args: T.untyped).returns(T::Boolean) }
|
51
|
+
def respond_to_missing?(*_args)
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'jwt'
|
5
5
|
require_relative './csv_package'
|
6
|
+
require_relative './net_package'
|
6
7
|
require_relative './stream_package'
|
7
8
|
|
8
9
|
using Workato::Extension::HashWithIndifferentAccess
|
@@ -20,7 +21,7 @@ module Workato
|
|
20
21
|
JWT_RSA_KEY_MIN_LENGTH = 2048
|
21
22
|
private_constant :JWT_RSA_KEY_MIN_LENGTH
|
22
23
|
|
23
|
-
JWT_HMAC_ALGORITHMS = %w[HS256].freeze
|
24
|
+
JWT_HMAC_ALGORITHMS = %w[HS256 HS384 HS512].freeze
|
24
25
|
private_constant :JWT_HMAC_ALGORITHMS
|
25
26
|
|
26
27
|
JWT_ECDSA_ALGORITHMS = %w[ES256 ES384 ES512].freeze
|
@@ -79,6 +80,29 @@ module Workato
|
|
79
80
|
raise Sdk::ArgumentError, 'Invalid key'
|
80
81
|
end
|
81
82
|
|
83
|
+
def jwt_decode(jwt, key, algorithm)
|
84
|
+
algorithm = algorithm.to_s.upcase
|
85
|
+
|
86
|
+
unless JWT_ALGORITHMS.include?(algorithm)
|
87
|
+
raise Sdk::ArgumentError,
|
88
|
+
'Unsupported verification algorithm. ' \
|
89
|
+
"Supports only #{JWT_ALGORITHMS.join(', ')}. Got: '#{algorithm}'"
|
90
|
+
end
|
91
|
+
|
92
|
+
if JWT_RSA_ALGORITHMS.include?(algorithm)
|
93
|
+
key = OpenSSL::PKey::RSA.new(key)
|
94
|
+
elsif JWT_ECDSA_ALGORITHMS.include?(algorithm)
|
95
|
+
key = OpenSSL::PKey::EC.new(key)
|
96
|
+
end
|
97
|
+
|
98
|
+
payload, header = ::JWT.decode(jwt, key, true, { algorithm: algorithm })
|
99
|
+
{ payload: payload, header: header }.with_indifferent_access
|
100
|
+
rescue JWT::IncorrectAlgorithm
|
101
|
+
raise Sdk::ArgumentError, 'Mismatched algorithm and key'
|
102
|
+
rescue OpenSSL::PKey::PKeyError
|
103
|
+
raise Sdk::ArgumentError, 'Invalid key'
|
104
|
+
end
|
105
|
+
|
82
106
|
def verify_rsa(payload, certificate, signature, algorithm = 'SHA256')
|
83
107
|
algorithm = algorithm.to_s.upcase
|
84
108
|
unless VERIFY_RCA_ALGORITHMS.include?(algorithm)
|
@@ -157,6 +181,10 @@ module Workato
|
|
157
181
|
@csv ||= CsvPackage.new
|
158
182
|
end
|
159
183
|
|
184
|
+
def net
|
185
|
+
@net ||= NetPackage.new
|
186
|
+
end
|
187
|
+
|
160
188
|
def stream
|
161
189
|
@stream ||= StreamPackage.new(streams: streams, connection: connection)
|
162
190
|
end
|
@@ -156,8 +156,9 @@ module Workato
|
|
156
156
|
self
|
157
157
|
end
|
158
158
|
|
159
|
-
def format_xml(root_element_name, namespaces = {},
|
160
|
-
request_format_xml(root_element_name, namespaces)
|
159
|
+
def format_xml(root_element_name, namespaces = {}, strip_response_namespaces: false)
|
160
|
+
request_format_xml(root_element_name, namespaces)
|
161
|
+
.response_format_xml(strip_response_namespaces: strip_response_namespaces)
|
161
162
|
end
|
162
163
|
|
163
164
|
def request_format_xml(root_element_name, namespaces = {})
|
@@ -9,7 +9,14 @@ module Workato
|
|
9
9
|
module Connector
|
10
10
|
module Sdk
|
11
11
|
module SorbetTypes
|
12
|
-
|
12
|
+
WebhookSubscribeClosureHash = T.type_alias { T::Hash[T.any(String, Symbol), T.untyped] }
|
13
|
+
|
14
|
+
WebhookSubscribeOutput = T.type_alias do
|
15
|
+
T.any(
|
16
|
+
WebhookSubscribeClosureHash,
|
17
|
+
[WebhookSubscribeClosureHash, T.nilable(T.any(Time, ActiveSupport::TimeWithZone))]
|
18
|
+
)
|
19
|
+
end
|
13
20
|
|
14
21
|
WebhookNotificationPayload = T.type_alias { T.untyped }
|
15
22
|
|
@@ -121,7 +128,7 @@ module Workato
|
|
121
128
|
headers: T::Hash[T.any(String, Symbol), T.untyped],
|
122
129
|
params: T::Hash[T.any(String, Symbol), T.untyped],
|
123
130
|
settings: T.nilable(SorbetTypes::SettingsHash),
|
124
|
-
webhook_subscribe_output: T.nilable(SorbetTypes::
|
131
|
+
webhook_subscribe_output: T.nilable(SorbetTypes::WebhookSubscribeClosureHash)
|
125
132
|
).returns(
|
126
133
|
SorbetTypes::WebhookNotificationOutputHash
|
127
134
|
)
|
@@ -161,9 +168,7 @@ module Workato
|
|
161
168
|
settings: T.nilable(SorbetTypes::SettingsHash),
|
162
169
|
input: SorbetTypes::OperationInputHash,
|
163
170
|
recipe_id: String
|
164
|
-
).returns(
|
165
|
-
SorbetTypes::WebhookSubscribeOutputHash
|
166
|
-
)
|
171
|
+
).returns(SorbetTypes::WebhookSubscribeOutput)
|
167
172
|
end
|
168
173
|
def webhook_subscribe(webhook_url = '', settings = nil, input = {}, recipe_id = recipe_id!)
|
169
174
|
webhook_subscribe_proc = trigger[:webhook_subscribe]
|
@@ -178,7 +183,7 @@ module Workato
|
|
178
183
|
end
|
179
184
|
end
|
180
185
|
|
181
|
-
sig { params(webhook_subscribe_output: SorbetTypes::
|
186
|
+
sig { params(webhook_subscribe_output: SorbetTypes::WebhookSubscribeClosureHash).returns(T.untyped) }
|
182
187
|
def webhook_unsubscribe(webhook_subscribe_output = {})
|
183
188
|
webhook_unsubscribe_proc = trigger[:webhook_unsubscribe]
|
184
189
|
execute(nil, webhook_subscribe_output) do |_connection, input|
|
@@ -192,7 +197,7 @@ module Workato
|
|
192
197
|
payload: T::Hash[T.any(String, Symbol), T.untyped],
|
193
198
|
headers: T::Hash[T.any(String, Symbol), T.untyped],
|
194
199
|
params: T::Hash[T.any(String, Symbol), T.untyped],
|
195
|
-
webhook_subscribe_output: T.nilable(SorbetTypes::
|
200
|
+
webhook_subscribe_output: T.nilable(SorbetTypes::WebhookSubscribeClosureHash)
|
196
201
|
).returns(
|
197
202
|
T.any(SorbetTypes::WebhookNotificationOutputHash, SorbetTypes::PollOutputHash)
|
198
203
|
)
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Abolmasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -154,16 +154,22 @@ dependencies:
|
|
154
154
|
name: nokogiri
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: 1.13.10
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '1.15'
|
160
163
|
type: :runtime
|
161
164
|
prerelease: false
|
162
165
|
version_requirements: !ruby/object:Gem::Requirement
|
163
166
|
requirements:
|
164
|
-
- -
|
167
|
+
- - ">="
|
165
168
|
- !ruby/object:Gem::Version
|
166
169
|
version: 1.13.10
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1.15'
|
167
173
|
- !ruby/object:Gem::Dependency
|
168
174
|
name: rack
|
169
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,14 +188,14 @@ dependencies:
|
|
182
188
|
name: rails-html-sanitizer
|
183
189
|
requirement: !ruby/object:Gem::Requirement
|
184
190
|
requirements:
|
185
|
-
- -
|
191
|
+
- - "~>"
|
186
192
|
- !ruby/object:Gem::Version
|
187
193
|
version: 1.4.3
|
188
194
|
type: :runtime
|
189
195
|
prerelease: false
|
190
196
|
version_requirements: !ruby/object:Gem::Requirement
|
191
197
|
requirements:
|
192
|
-
- -
|
198
|
+
- - "~>"
|
193
199
|
- !ruby/object:Gem::Version
|
194
200
|
version: 1.4.3
|
195
201
|
- !ruby/object:Gem::Dependency
|
@@ -401,6 +407,7 @@ files:
|
|
401
407
|
- lib/workato/connector/sdk.rb
|
402
408
|
- lib/workato/connector/sdk/account_properties.rb
|
403
409
|
- lib/workato/connector/sdk/action.rb
|
410
|
+
- lib/workato/connector/sdk/blank.rb
|
404
411
|
- lib/workato/connector/sdk/block_invocation_refinements.rb
|
405
412
|
- lib/workato/connector/sdk/connection.rb
|
406
413
|
- lib/workato/connector/sdk/connector.rb
|
@@ -414,6 +421,7 @@ files:
|
|
414
421
|
- lib/workato/connector/sdk/dsl/execution_context.rb
|
415
422
|
- lib/workato/connector/sdk/dsl/http.rb
|
416
423
|
- lib/workato/connector/sdk/dsl/lookup_table.rb
|
424
|
+
- lib/workato/connector/sdk/dsl/net_package.rb
|
417
425
|
- lib/workato/connector/sdk/dsl/reinvoke_after.rb
|
418
426
|
- lib/workato/connector/sdk/dsl/stream_package.rb
|
419
427
|
- lib/workato/connector/sdk/dsl/time.rb
|