workato-connector-sdk 1.3.17 → 1.3.18
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/VERSION +1 -1
- data/lib/workato/cli/exec_command.rb +1 -0
- data/lib/workato/cli/main.rb +1 -0
- data/lib/workato/cli/oauth2_command.rb +14 -12
- data/lib/workato/connector/sdk/connection.rb +21 -4
- data/lib/workato/connector/sdk.rb +1 -0
- data/lib/workato/web/app.rb +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9202cc307610e92052b8b4b08c6df5d24f96d516049fb6207ba7770be2db2bb
|
|
4
|
+
data.tar.gz: b323fed88946da8c880eb8fd0e6a28a94005a88693ae1e3a20b39753c9344b37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1c39ccf934b4f433a024fa8299210b1dcc69d32942bbe63409cc63b60a4c1e6533d05f0d8e060190426919e43f638264f095b7b36815ddf81bbffff42ccf040
|
|
7
|
+
data.tar.gz: 3fb9a5e525830bafb0857e33d0561f14b8f85b9494d728ad1f7ecdc3575a2b029e8ead225dc7915a327febbfdc4fc77a60a72c1e88390c79fb3a096c6a39dfe2
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.3.
|
|
1
|
+
1.3.18
|
|
@@ -67,6 +67,7 @@ module Workato
|
|
|
67
67
|
webhook_url: options[:webhook_url],
|
|
68
68
|
oauth2_code: options[:oauth2_code],
|
|
69
69
|
redirect_url: options[:redirect_url],
|
|
70
|
+
query_params: from_json(options[:query_params]),
|
|
70
71
|
refresh_token: options[:refresh_token],
|
|
71
72
|
from: options[:from].to_i,
|
|
72
73
|
frame_size: options[:frame_size]&.to_i || Workato::Connector::Sdk::Stream::DEFAULT_FRAME_SIZE,
|
data/lib/workato/cli/main.rb
CHANGED
|
@@ -60,6 +60,7 @@ module Workato
|
|
|
60
60
|
method_option :output, type: :string, aliases: '-o', desc: 'Write output to JSON file'
|
|
61
61
|
method_option :oauth2_code, type: :string, desc: 'OAuth2 code exchange to tokens pair'
|
|
62
62
|
method_option :redirect_url, type: :string, desc: 'OAuth2 callback url'
|
|
63
|
+
method_option :query_params, type: :string, desc: 'Path to file with OAuth2 query params'
|
|
63
64
|
method_option :refresh_token, type: :string, desc: 'OAuth2 refresh token'
|
|
64
65
|
method_option :from, type: :numeric, desc: 'Stream byte offset to read from'
|
|
65
66
|
method_option :frame_size, type: :numeric, desc: 'Stream chunk read size in bytes. Should be positive'
|
|
@@ -12,8 +12,8 @@ module Workato
|
|
|
12
12
|
include Thor::Shell
|
|
13
13
|
include MultiAuthSelectedFallback
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
AWAIT_CALLBACK_TIMEOUT_INTERVAL = 180 # seconds
|
|
16
|
+
AWAIT_CALLBACK_SLEEP_INTERVAL = 5 # seconds
|
|
17
17
|
|
|
18
18
|
DEFAULT_ADDRESS = '127.0.0.1'
|
|
19
19
|
DEFAULT_PORT = '45555'
|
|
@@ -41,17 +41,17 @@ module Workato
|
|
|
41
41
|
raise "Attempted to open #{authorize_url} and failed because #{exception}"
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
say_status :success, "Receive OAuth2 code=#{code}"
|
|
44
|
+
callback_params = await_callback
|
|
45
|
+
say_status :success, "Receive OAuth2 code=#{callback_params['code']}, state=#{callback_params['state']}"
|
|
46
46
|
|
|
47
|
-
tokens = acquire_token(
|
|
47
|
+
tokens = acquire_token(callback_params)
|
|
48
48
|
say_status :success, 'Receive OAuth2 tokens'
|
|
49
49
|
say JSON.pretty_generate(tokens) if verbose?
|
|
50
50
|
|
|
51
51
|
settings_store.update(tokens)
|
|
52
52
|
say_status :success, 'Update settings file'
|
|
53
53
|
rescue Timeout::Error
|
|
54
|
-
raise "Have not received callback from OAuth2 provider in #{
|
|
54
|
+
raise "Have not received callback from OAuth2 provider in #{AWAIT_CALLBACK_TIMEOUT_INTERVAL} seconds. Aborting!"
|
|
55
55
|
rescue Errno::EADDRINUSE
|
|
56
56
|
raise "Port #{port} already in use. Try to use different port with --port=#{rand(10_000..65_664)}"
|
|
57
57
|
ensure
|
|
@@ -165,22 +165,24 @@ module Workato
|
|
|
165
165
|
)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
-
def
|
|
168
|
+
def await_callback
|
|
169
169
|
code_uri = URI("#{base_url}#{Workato::Web::App::CODE_PATH}")
|
|
170
170
|
|
|
171
|
-
Timeout.timeout(
|
|
171
|
+
Timeout.timeout(AWAIT_CALLBACK_TIMEOUT_INTERVAL) do
|
|
172
172
|
loop do
|
|
173
173
|
response = get(code_uri) rescue nil
|
|
174
|
-
break response if response.present?
|
|
174
|
+
break JSON.parse(response).to_hash if response.present?
|
|
175
175
|
|
|
176
|
-
sleep(
|
|
176
|
+
sleep(AWAIT_CALLBACK_SLEEP_INTERVAL)
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
end
|
|
180
180
|
|
|
181
|
-
def acquire_token(
|
|
181
|
+
def acquire_token(callback_params)
|
|
182
|
+
code = callback_params["code"]
|
|
183
|
+
callback_params.except!("code", "state")
|
|
182
184
|
if connector.connection.authorization.source[:acquire]
|
|
183
|
-
tokens, _, extra_settings = connector.connection.authorization.acquire(nil, code, redirect_url)
|
|
185
|
+
tokens, _, extra_settings = connector.connection.authorization.acquire(nil, code, redirect_url, nil, callback_params)
|
|
184
186
|
tokens ||= {}
|
|
185
187
|
extra_settings ||= {}
|
|
186
188
|
extra_settings.merge(tokens)
|
|
@@ -250,10 +250,12 @@ module Workato
|
|
|
250
250
|
params(
|
|
251
251
|
settings: T.nilable(SorbetTypes::SettingsHash),
|
|
252
252
|
oauth2_code: T.nilable(String),
|
|
253
|
-
redirect_url: T.nilable(String)
|
|
253
|
+
redirect_url: T.nilable(String),
|
|
254
|
+
pkce_verifier: T.nilable(String),
|
|
255
|
+
query_params: T.nilable(T::Hash[T.untyped, T.untyped])
|
|
254
256
|
).returns(T.nilable(SorbetTypes::AcquireOutput))
|
|
255
257
|
end
|
|
256
|
-
def acquire(settings = nil, oauth2_code = nil, redirect_url = nil)
|
|
258
|
+
def acquire(settings = nil, oauth2_code = nil, redirect_url = nil, pkce_verifier = nil, query_params = nil)
|
|
257
259
|
@connection.merge_settings!(settings) if settings
|
|
258
260
|
acquire_proc = source[:acquire]
|
|
259
261
|
raise InvalidDefinitionError, "Expect 'acquire' block" unless acquire_proc
|
|
@@ -269,8 +271,23 @@ module Workato
|
|
|
269
271
|
settings: @connection.settings!
|
|
270
272
|
),
|
|
271
273
|
methods: methods_source
|
|
272
|
-
).execute(
|
|
273
|
-
|
|
274
|
+
).execute(
|
|
275
|
+
settings,
|
|
276
|
+
{
|
|
277
|
+
auth_code: oauth2_code,
|
|
278
|
+
redirect_url: redirect_url,
|
|
279
|
+
pkce_verifier: pkce_verifier,
|
|
280
|
+
query_params: query_params || {}
|
|
281
|
+
}
|
|
282
|
+
) do |connection, input|
|
|
283
|
+
instance_exec(
|
|
284
|
+
connection,
|
|
285
|
+
input[:auth_code],
|
|
286
|
+
input[:redirect_url],
|
|
287
|
+
input[:pkce_verifier],
|
|
288
|
+
input[:query_params],
|
|
289
|
+
&acquire_proc
|
|
290
|
+
)
|
|
274
291
|
end
|
|
275
292
|
end
|
|
276
293
|
|
data/lib/workato/web/app.rb
CHANGED
|
@@ -11,9 +11,9 @@ module Workato
|
|
|
11
11
|
req = Rack::Request.new(env)
|
|
12
12
|
case req.path_info
|
|
13
13
|
when /#{CODE_PATH}/
|
|
14
|
-
[200, { 'Content-Type' => 'text/plain' }, [@
|
|
14
|
+
[200, { 'Content-Type' => 'text/plain' }, [@params&.to_json.to_s]]
|
|
15
15
|
when /#{CALLBACK_PATH}/
|
|
16
|
-
@
|
|
16
|
+
@params = req.params
|
|
17
17
|
[200, { 'Content-Type' => 'text/plain' }, ['We stored response code. Now you can close the browser window']]
|
|
18
18
|
else
|
|
19
19
|
[404, { 'Content-Type' => 'text/plain' }, ['404: Not Found']]
|
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.18
|
|
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: 2026-01-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -54,16 +54,22 @@ dependencies:
|
|
|
54
54
|
name: bundler
|
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
|
-
- - "
|
|
57
|
+
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '2.0'
|
|
60
|
+
- - "<"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '5.0'
|
|
60
63
|
type: :runtime
|
|
61
64
|
prerelease: false
|
|
62
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
63
66
|
requirements:
|
|
64
|
-
- - "
|
|
67
|
+
- - ">="
|
|
65
68
|
- !ruby/object:Gem::Version
|
|
66
69
|
version: '2.0'
|
|
70
|
+
- - "<"
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '5.0'
|
|
67
73
|
- !ruby/object:Gem::Dependency
|
|
68
74
|
name: charlock_holmes
|
|
69
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -91,9 +97,6 @@ dependencies:
|
|
|
91
97
|
- - "~>"
|
|
92
98
|
- !ruby/object:Gem::Version
|
|
93
99
|
version: '1.0'
|
|
94
|
-
- - "!="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: 1.3.5
|
|
97
100
|
type: :runtime
|
|
98
101
|
prerelease: false
|
|
99
102
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -101,9 +104,6 @@ dependencies:
|
|
|
101
104
|
- - "~>"
|
|
102
105
|
- !ruby/object:Gem::Version
|
|
103
106
|
version: '1.0'
|
|
104
|
-
- - "!="
|
|
105
|
-
- !ruby/object:Gem::Version
|
|
106
|
-
version: 1.3.5
|
|
107
107
|
- !ruby/object:Gem::Dependency
|
|
108
108
|
name: em-http-request
|
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -515,7 +515,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
515
515
|
- !ruby/object:Gem::Version
|
|
516
516
|
version: '0'
|
|
517
517
|
requirements: []
|
|
518
|
-
rubygems_version: 3.
|
|
518
|
+
rubygems_version: 3.4.19
|
|
519
519
|
signing_key:
|
|
520
520
|
specification_version: 4
|
|
521
521
|
summary: Gem for running adapter's code outside Workato infrastructure
|