workato-connector-sdk 1.3.2 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fe38da4979356285b7bd535a889ce87324c0c9e79af94ab64bbfbabff03f104
4
- data.tar.gz: 12ae318a25eaf1fddc7c31f22f9870d4af28e736781ef32ff766c32ae14876d2
3
+ metadata.gz: '04149c3903c23d8e7e6a02b0f76928d08bd4aeeab5f6fa2602e039a3e1adcb92'
4
+ data.tar.gz: ad69735af0f602cc35a82507d2479cc5ae3057f0423322aaaa42e7f70c0ad2d2
5
5
  SHA512:
6
- metadata.gz: 2737cef0c57c48dc215dba1f3077669935fceb940be5484469e3901f6d848bee8af5bc408595a14a330bc96e3e553f088c25323867dc8d43d1b95930275c79af
7
- data.tar.gz: 066b30f5e052e1dbd91c697b3e978ec548f0ffc76db9298168758e4b60f8ada8f1a13c1a603e0603d347e22fcca2e945fa3eeaedaa74139cef07b09b98b7c9ea
6
+ metadata.gz: 9c9d9ecafec79226a203c838395303be2619d602be8d3645bdce7215397d19a628a946ac4ef87efbeb887183fe4fbdaf4ea74797a0a1063198c2c12a60186ce7
7
+ data.tar.gz: 28da7967c46441234a655bd32c498a04400ed6a26f7d7d5481154c7167ce18bf5f05f0a9e289805132c97b5cc45477eae7b4127a890aa331ee8f8ab04ee3c5c1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.3.3
@@ -101,6 +101,7 @@ module Workato
101
101
  return unless @thread
102
102
 
103
103
  Rack::Handler::WEBrick.shutdown
104
+ @thread.join
104
105
  @thread.exit
105
106
  end
106
107
 
@@ -0,0 +1,4 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file is intentionally left blank. Do not remove
@@ -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 = {}, **options)
160
- request_format_xml(root_element_name, namespaces).response_format_xml(**options)
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
- WebhookSubscribeOutputHash = T.type_alias { T::Hash[T.any(String, Symbol), T.untyped] }
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::WebhookSubscribeOutputHash)
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::WebhookSubscribeOutputHash).returns(T.untyped) }
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::WebhookSubscribeOutputHash)
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.2
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-02-23 00:00:00.000000000 Z
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