isomorfeus-transport 1.0.0.zeta5 → 1.0.0.zeta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/isomorfeus/transport/config.rb +28 -10
- data/lib/isomorfeus/transport/handler/authentication_handler.rb +21 -18
- data/lib/isomorfeus/transport/rack_middleware.rb +1 -0
- data/lib/isomorfeus/transport/response_agent.rb +23 -0
- data/lib/isomorfeus/transport/server_processor.rb +48 -40
- data/lib/isomorfeus/transport/server_socket_processor.rb +25 -2
- data/lib/isomorfeus/transport/version.rb +1 -1
- data/lib/isomorfeus/transport.rb +2 -2
- data/lib/isomorfeus-transport.rb +7 -17
- data/lib/lucid_authentication/mixin.rb +9 -4
- data/lib/lucid_handler/mixin.rb +4 -0
- metadata +22 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d33b9c8242c8486569c7155b5b8536b2ce3e3009562c96cfe8dc8288bfab4812
|
4
|
+
data.tar.gz: adfb72fc04f445680a90531a8ce963654a26cbada3e1550464f1fc648280d08c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb4334ed3ae139724acf6b8fe962bf79fec2b50e0a323215e22e964abd069e9ae95b01d3b7dd6f1eedfaf97eed8f7638cb374e30dd519d75192ce57e75d210ad
|
7
|
+
data.tar.gz: d52f27c934a43e782502f23e0b1606eb311a0affc8ac734c444730f907286ae04c9d25a20a46245b14d3905dca4142362363c932fd4a9718c867a847b0b625b2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# isomorfeus-transport
|
2
2
|
|
3
|
-
Transport and PubSub for
|
3
|
+
Transport and PubSub for Isomorfeus.
|
4
4
|
|
5
5
|
### Community and Support
|
6
6
|
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
@@ -43,7 +43,7 @@ end
|
|
43
43
|
|
44
44
|
A class representing a user should be a LucidNode and include LucidAuthentication::Mixin:
|
45
45
|
```ruby
|
46
|
-
class User <
|
46
|
+
class User < LucidGenericDocument::Base
|
47
47
|
include LucidAuthentication::Mixin
|
48
48
|
authentication do |user_identifier, user_password_or token|
|
49
49
|
# should return either a User instance or a Promise which reselves to a User instance
|
@@ -47,6 +47,7 @@ module Isomorfeus
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def cached_channel_class(class_name)
|
50
|
+
return "::#{class_name}".constantize if Isomorfeus.development?
|
50
51
|
return cached_channel_classes[class_name] if cached_channel_classes.key?(class_name)
|
51
52
|
cached_channel_classes[class_name] = "::#{class_name}".constantize
|
52
53
|
end
|
@@ -60,9 +61,7 @@ module Isomorfeus
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def add_valid_channel_class(klass)
|
63
|
-
|
64
|
-
class_name = class_name.split('>::').last if class_name.start_with?('#<')
|
65
|
-
valid_channel_class_names << class_name
|
64
|
+
valid_channel_class_names << raw_class_name(klass)
|
66
65
|
end
|
67
66
|
|
68
67
|
def valid_handler_class_names
|
@@ -74,9 +73,7 @@ module Isomorfeus
|
|
74
73
|
end
|
75
74
|
|
76
75
|
def add_valid_handler_class(klass)
|
77
|
-
|
78
|
-
class_name = class_name.split('>::').last if class_name.start_with?('#<')
|
79
|
-
valid_handler_class_names << class_name
|
76
|
+
valid_handler_class_names << raw_class_name(klass)
|
80
77
|
end
|
81
78
|
|
82
79
|
def cached_handler_classes
|
@@ -84,16 +81,37 @@ module Isomorfeus
|
|
84
81
|
end
|
85
82
|
|
86
83
|
def cached_handler_class(class_name)
|
84
|
+
return "::#{class_name}".constantize if Isomorfeus.development?
|
87
85
|
return cached_handler_classes[class_name] if cached_handler_classes.key?(class_name)
|
88
86
|
cached_handler_classes[class_name] = "::#{class_name}".constantize
|
89
87
|
end
|
90
88
|
|
91
|
-
def
|
92
|
-
@
|
89
|
+
def valid_user_class_names
|
90
|
+
@valid_user_class_names ||= Set.new
|
91
|
+
end
|
92
|
+
|
93
|
+
def valid_user_class_name?(class_name)
|
94
|
+
valid_user_class_names.include?(class_name)
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_valid_user_class(klass)
|
98
|
+
valid_user_class_names << raw_class_name(klass)
|
99
|
+
end
|
100
|
+
|
101
|
+
def cached_user_classes
|
102
|
+
@cached_user_classes ||= {}
|
93
103
|
end
|
94
104
|
|
95
|
-
def
|
96
|
-
|
105
|
+
def cached_user_class(class_name)
|
106
|
+
return "::#{class_name}".constantize if Isomorfeus.development?
|
107
|
+
return cached_user_classes[class_name] if cached_user_classes.key?(class_name)
|
108
|
+
cached_user_classes[class_name] = "::#{class_name}".constantize
|
109
|
+
end
|
110
|
+
|
111
|
+
def raw_class_name(klass)
|
112
|
+
class_name = klass.name
|
113
|
+
class_name = class_name.split('>::').last if class_name.start_with?('#<')
|
114
|
+
class_name
|
97
115
|
end
|
98
116
|
end
|
99
117
|
end
|
@@ -4,34 +4,38 @@ module Isomorfeus
|
|
4
4
|
class AuthenticationHandler < LucidHandler::Base
|
5
5
|
TIMEOUT = 30
|
6
6
|
|
7
|
-
on_request do |pub_sub_client, current_user,
|
7
|
+
on_request do |pub_sub_client, current_user, response_agent|
|
8
8
|
result = { error: 'Authentication failed' }
|
9
|
-
# promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', user_identifier, user_password)
|
10
|
-
request.each_key do |login_or_logout|
|
9
|
+
# promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', user_class_name, user_identifier, user_password)
|
10
|
+
response_agent.request.each_key do |login_or_logout|
|
11
11
|
if login_or_logout == 'login'
|
12
12
|
tries = pub_sub_client.instance_variable_get(:@isomorfeus_authentication_tries)
|
13
13
|
tries = 0 unless tries
|
14
14
|
tries += 1
|
15
|
-
sleep(5) if tries > 3
|
15
|
+
sleep(5) if tries > 3 # TODO, this needs a better solution (store data in user/session)
|
16
16
|
pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, tries)
|
17
|
-
request['login'].each_key do |
|
17
|
+
response_agent.request['login'].each_key do |user_class_name|
|
18
18
|
user = nil
|
19
|
-
Isomorfeus.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
if Isomorfeus.valid_user_class_name?(user_class_name)
|
20
|
+
user_class = Isomorfeus.cached_user_class(user_class_name)
|
21
|
+
response_agent.request['login'][user_class_name].each_key do |user_identifier|
|
22
|
+
promise = user_class.promise_login(user_identifier, response_agent.request['login'][user_class_name][user_identifier])
|
23
|
+
unless promise.realized?
|
24
|
+
start = Time.now
|
25
|
+
until promise.realized?
|
26
|
+
break if (Time.now - start) > TIMEOUT
|
27
|
+
sleep 0.01
|
28
|
+
end
|
26
29
|
end
|
30
|
+
user = promise.value
|
31
|
+
break if user
|
27
32
|
end
|
28
|
-
user = promise.value
|
29
|
-
break if user
|
30
33
|
end
|
31
34
|
if user
|
32
35
|
pub_sub_client.instance_variable_set(:@isomorfeus_user, user)
|
33
36
|
pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, nil)
|
34
|
-
|
37
|
+
# TODO store session in db and supply session cookie: session_cookie: uuid or so
|
38
|
+
response_agent.agent_result = { success: 'ok', data: user.to_transport }
|
35
39
|
end
|
36
40
|
end
|
37
41
|
elsif login_or_logout == 'logout'
|
@@ -46,13 +50,12 @@ module Isomorfeus
|
|
46
50
|
end
|
47
51
|
ensure
|
48
52
|
pub_sub_client.instance_variable_set(:@isomorfeus_user, nil)
|
49
|
-
|
53
|
+
response_agent.agent_result = { success: 'ok' }
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
53
|
-
result
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
58
|
-
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Transport
|
3
|
+
class ResponseAgent
|
4
|
+
attr_reader :agent_id
|
5
|
+
attr_reader :request
|
6
|
+
attr_accessor :agent_result
|
7
|
+
attr_accessor :outer_result
|
8
|
+
attr_accessor :error
|
9
|
+
|
10
|
+
def initialize(agent_id, request)
|
11
|
+
@agent_id = agent_id
|
12
|
+
@request = request
|
13
|
+
end
|
14
|
+
|
15
|
+
def result
|
16
|
+
return { response: { agent_ids: { @agent_id => @error }}} if @error
|
17
|
+
response = { response: { agent_ids: { @agent_id => @agent_result }}}
|
18
|
+
response.deep_merge!(@outer_result) if @outer_result
|
19
|
+
return response
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,98 +3,106 @@
|
|
3
3
|
module Isomorfeus
|
4
4
|
module Transport
|
5
5
|
module ServerProcessor
|
6
|
-
def process_request(client, current_user, request)
|
6
|
+
def process_request(client, current_user, request, handler_instance_cache, response_agent_array)
|
7
7
|
Thread.current[:isomorfeus_pub_sub_client] = client
|
8
8
|
|
9
|
-
response = { response: { agent_ids: {}} }
|
10
|
-
|
11
9
|
if request.key?('request') && request['request'].key?('agent_ids')
|
12
10
|
request['request']['agent_ids'].each_key do |agent_id|
|
13
11
|
request['request']['agent_ids'][agent_id].each_key do |handler_class_name|
|
12
|
+
response_agent = Isomorfeus::Transport::ResponseAgent.new(agent_id, request['request']['agent_ids'][agent_id][handler_class_name])
|
13
|
+
response_agent_array << response_agent
|
14
14
|
begin
|
15
|
-
handler =
|
15
|
+
handler = if handler_instance_cache.key?(handler_class_name)
|
16
|
+
handler_instance_cache[handler_class_name]
|
17
|
+
else
|
18
|
+
handler_class = Isomorfeus.cached_handler_class(handler_class_name) if Isomorfeus.valid_handler_class_name?(handler_class_name)
|
19
|
+
handler_instance_cache[handler_class_name] = handler_class.new if handler_class
|
20
|
+
end
|
16
21
|
if handler
|
17
|
-
|
18
|
-
response[:response][:agent_ids][agent_id] = result
|
22
|
+
handler.process_request(client, current_user, response_agent)
|
19
23
|
else
|
20
|
-
|
24
|
+
response_agent.error = { error: { handler_class_name => 'No such handler!'}}
|
21
25
|
end
|
22
|
-
rescue
|
23
|
-
|
26
|
+
rescue Exception => e
|
27
|
+
response_agent.error = if Isomorfeus.production? then { error: { handler_class_name => 'No such handler!'}}
|
28
|
+
else { response: { error: "#{handler_class_name}: #{e.message}\n#{e.backtrace.join("\n")}" }}
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
27
33
|
elsif request.key?('notification')
|
28
34
|
begin
|
29
35
|
channel = request['notification']['channel']
|
30
|
-
class_name =
|
36
|
+
class_name = request['notification']['class']
|
37
|
+
|
31
38
|
if Isomorfeus.valid_channel_class_name?(class_name) && channel
|
32
39
|
channel_class = Isomorfeus.cached_channel_class(class_name)
|
33
40
|
if channel_class && current_user.authorized?(channel_class, :send_message, channel)
|
34
41
|
client.publish(request['notification']['channel'], Oj.dump({ 'notification' => request['notification'] }, mode: :strict))
|
35
42
|
else
|
36
|
-
|
43
|
+
response_agent = OpenStruct.new
|
44
|
+
response_agent_array << response_agent
|
45
|
+
response_agent.result = { response: { error: 'Not authorized!' }}
|
37
46
|
end
|
38
47
|
else
|
39
|
-
|
48
|
+
response_agent = OpenStruct.new
|
49
|
+
response_agent_array << response_agent
|
50
|
+
response_agent.result = { response: { error: 'No such thing!' }}
|
40
51
|
end
|
41
52
|
rescue Exception => e
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
{ error: "Isomorfeus::Transport::ServerProcessor: #{e.message}" }
|
46
|
-
|
53
|
+
response_agent = OpenStruct.new
|
54
|
+
response_agent_array << response_agent
|
55
|
+
response_agent.result = if Isomorfeus.production? then { response: { error: 'No such thing!' }}
|
56
|
+
else { response: { error: "Isomorfeus::Transport::ServerProcessor: #{e.message}\n#{e.backtrace.join("\n")}" }}
|
57
|
+
end
|
47
58
|
end
|
48
59
|
elsif request.key?('subscribe') && request['subscribe'].key?('agent_ids')
|
49
60
|
begin
|
50
61
|
agent_id = request['subscribe']['agent_ids'].keys.first
|
51
|
-
|
52
|
-
|
62
|
+
response_agent = Isomorfeus::Transport::ResponseAgent.new(agent_id, request['subscribe']['agent_ids'][agent_id])
|
63
|
+
response_agent_array << response_agent
|
64
|
+
channel = response_agent.request['channel']
|
65
|
+
class_name = response_agent.request['class']
|
53
66
|
if Isomorfeus.valid_channel_class_name?(class_name) && channel
|
54
67
|
channel_class = Isomorfeus.cached_channel_class(class_name)
|
55
68
|
if channel_class && current_user.authorized?(channel_class, :subscribe, channel)
|
56
69
|
client.subscribe(channel)
|
57
|
-
|
70
|
+
response_agent.agent_result = { success: channel }
|
58
71
|
else
|
59
|
-
|
72
|
+
response_agent.error = { error: "Not authorized!"}
|
60
73
|
end
|
61
74
|
else
|
62
|
-
|
75
|
+
response_agent.error = { error: "No such thing!"}
|
63
76
|
end
|
64
77
|
rescue Exception => e
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
{ error: "Isomorfeus::Transport::ServerProcessor: #{e.message}" }
|
69
|
-
end
|
78
|
+
response_agent.error = if Isomorfeus.production? then { error: 'No such thing!' }
|
79
|
+
else { error: "Isomorfeus::Transport::ServerProcessor: #{e.message}\n#{e.backtrace.join("\n")}" }
|
80
|
+
end
|
70
81
|
end
|
71
82
|
elsif request.key?('unsubscribe') && request['unsubscribe'].key?('agent_ids')
|
72
83
|
begin
|
73
84
|
agent_id = request['unsubscribe']['agent_ids'].keys.first
|
74
|
-
|
75
|
-
|
85
|
+
response_agent = Isomorfeus::Transport::ResponseAgent.new(agent_id, request['unsubscribe']['agent_ids'][agent_id])
|
86
|
+
response_agent_array << response_agent
|
87
|
+
channel = response_agent.request['channel']
|
88
|
+
class_name = response_agent.request['class']
|
76
89
|
if Isomorfeus.valid_channel_class_name?(class_name) && channel
|
77
90
|
channel_class = Isomorfeus.cached_channel_class(class_name)
|
78
91
|
if channel_class && current_user.authorized?(channel_class, :unsubscribe, channel)
|
79
92
|
client.unsubscribe(channel)
|
80
|
-
|
93
|
+
response_agent.agent_result = { success: channel }
|
81
94
|
else
|
82
|
-
|
95
|
+
response_agent.error = { error: "Not authorized!"}
|
83
96
|
end
|
84
97
|
else
|
85
|
-
|
98
|
+
response_agent.error = { error: 'No such thing!'}
|
86
99
|
end
|
87
100
|
rescue Exception => e
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
{ error: "Isomorfeus::Transport::ServerProcessor: #{e.message}" }
|
92
|
-
end
|
101
|
+
response_agent.error = if Isomorfeus.production? then { error: 'No such thing!' }
|
102
|
+
else { error: "Isomorfeus::Transport::ServerProcessor: #{e.message}\n#{e.backtrace.join("\n")}" }
|
103
|
+
end
|
93
104
|
end
|
94
|
-
else
|
95
|
-
response[:response] = { error: 'No such thing!'}
|
96
105
|
end
|
97
|
-
response
|
98
106
|
end
|
99
107
|
end
|
100
108
|
end
|
@@ -4,9 +4,28 @@ module Isomorfeus
|
|
4
4
|
include Isomorfeus::Transport::ServerProcessor
|
5
5
|
|
6
6
|
def on_message(client, data)
|
7
|
+
if Isomorfeus.development?
|
8
|
+
write_lock = Isomorfeus.zeitwerk_lock.try_write_lock
|
9
|
+
if write_lock
|
10
|
+
Isomorfeus.zeitwerk.reload
|
11
|
+
Isomorfeus.zeitwerk_lock.release_write_lock
|
12
|
+
end
|
13
|
+
Isomorfeus.zeitwerk_lock.acquire_read_lock
|
14
|
+
end
|
7
15
|
request_hash = Oj.load(data, mode: :strict)
|
8
|
-
|
16
|
+
handler_instance_cache = {}
|
17
|
+
response_agent_array = []
|
18
|
+
process_request(client, user(client), request_hash, handler_instance_cache, response_agent_array)
|
19
|
+
handler_instance_cache.each_value do |handler|
|
20
|
+
handler.resolve if handler.resolving?
|
21
|
+
end
|
22
|
+
result = {}
|
23
|
+
response_agent_array.each do |response_agent|
|
24
|
+
result.deep_merge!(response_agent.result)
|
25
|
+
end
|
9
26
|
client.write Oj.dump(result, mode: :strict)
|
27
|
+
ensure
|
28
|
+
Isomorfeus.zeitwerk_lock.release_read_lock if Isomorfeus.development?
|
10
29
|
end
|
11
30
|
|
12
31
|
def on_close(client)
|
@@ -22,7 +41,11 @@ module Isomorfeus
|
|
22
41
|
end
|
23
42
|
|
24
43
|
def user(client)
|
25
|
-
|
44
|
+
# TODO get session cooke and load user from session
|
45
|
+
current_user = client.instance_variable_get(:@isomorfeus_user)
|
46
|
+
return current_user if current_user
|
47
|
+
# TODO get session cooke and load user from session
|
48
|
+
Anonymous.new
|
26
49
|
end
|
27
50
|
end
|
28
51
|
end
|
data/lib/isomorfeus/transport.rb
CHANGED
@@ -24,7 +24,7 @@ module Isomorfeus
|
|
24
24
|
if Isomorfeus.on_browser?
|
25
25
|
window_protocol = `window.location.protocol`
|
26
26
|
ws_protocol = window_protocol == 'https:' ? 'wss:' : 'ws:'
|
27
|
-
ws_url = "#{ws_protocol}
|
27
|
+
ws_url = "#{ws_protocol}//#{`window.location.host`}#{Isomorfeus.api_websocket_path}"
|
28
28
|
else
|
29
29
|
ws_url = Isomorfeus::TopLevel.transport_ws_url
|
30
30
|
end
|
@@ -192,4 +192,4 @@ module Isomorfeus
|
|
192
192
|
end # RUBY_ENGINE
|
193
193
|
end
|
194
194
|
end
|
195
|
-
end
|
195
|
+
end
|
data/lib/isomorfeus-transport.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'opal'
|
2
|
-
require 'opal-autoloader'
|
3
|
-
require 'opal-activesupport'
|
4
|
-
require 'isomorfeus-react'
|
5
1
|
require 'isomorfeus-policy'
|
6
2
|
require 'lucid_authentication/mixin'
|
7
3
|
if RUBY_ENGINE == 'opal'
|
@@ -16,11 +12,12 @@ if RUBY_ENGINE == 'opal'
|
|
16
12
|
require 'isomorfeus/transport'
|
17
13
|
require 'lucid_channel/mixin'
|
18
14
|
require 'lucid_channel/base'
|
19
|
-
|
15
|
+
Isomorfeus.zeitwerk.push_dir('channels')
|
20
16
|
Isomorfeus.add_client_init_class_name('Isomorfeus::Transport')
|
21
17
|
else
|
22
18
|
require 'base64'
|
23
19
|
require 'digest'
|
20
|
+
require 'ostruct'
|
24
21
|
require 'socket'
|
25
22
|
require 'oj'
|
26
23
|
require 'websocket/driver'
|
@@ -29,6 +26,7 @@ else
|
|
29
26
|
require 'isomorfeus/config'
|
30
27
|
require 'isomorfeus/promise'
|
31
28
|
require 'isomorfeus/transport/version'
|
29
|
+
require 'isomorfeus/transport/response_agent'
|
32
30
|
require 'isomorfeus/transport/config'
|
33
31
|
require 'isomorfeus/transport/middlewares'
|
34
32
|
require 'isomorfeus/transport/request_agent'
|
@@ -40,7 +38,6 @@ else
|
|
40
38
|
require 'isomorfeus/transport/middlewares'
|
41
39
|
|
42
40
|
Isomorfeus.add_middleware(Isomorfeus::Transport::RackMiddleware)
|
43
|
-
Isomorfeus.valid_channel_class_names
|
44
41
|
|
45
42
|
require 'lucid_handler/mixin'
|
46
43
|
require 'lucid_handler/base'
|
@@ -51,17 +48,10 @@ else
|
|
51
48
|
|
52
49
|
Opal.append_path(__dir__.untaint) unless Opal.paths.include?(__dir__.untaint)
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
path = Dir.exist?(File.join('isomorfeus')) ? File.expand_path(File.join('isomorfeus', dir)) : nil
|
59
|
-
if path
|
60
|
-
ActiveSupport::Dependencies.autoload_paths << path
|
61
|
-
# we also need to require them all, so classes are registered accordingly
|
62
|
-
Dir.glob("#{path}/**/*.rb").each do |file|
|
63
|
-
require file
|
64
|
-
end
|
51
|
+
%w[channels handlers server].each do |dir|
|
52
|
+
path = File.expand_path(File.join('isomorfeus', dir))
|
53
|
+
if Dir.exist?(path)
|
54
|
+
Isomorfeus.zeitwerk.push_dir(path)
|
65
55
|
end
|
66
56
|
end
|
67
57
|
end
|
@@ -17,17 +17,22 @@ module LucidAuthentication
|
|
17
17
|
else
|
18
18
|
`console.warn("Connection not secure, ensure a secure connection in production, otherwise login will fail!")` unless Isomorfeus::Transport.socket.url.start_with?('wss:')
|
19
19
|
end
|
20
|
-
Isomorfeus::Transport.promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', user_identifier, user_password).then do |agent|
|
20
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', self.name, user_identifier, user_password).then do |agent|
|
21
21
|
if agent.processed
|
22
22
|
agent.result
|
23
23
|
else
|
24
24
|
agent.processed = true
|
25
25
|
if agent.response.key?(:success)
|
26
26
|
Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: agent.response[:data])
|
27
|
-
class_name = agent.response[:data]
|
28
|
-
|
29
|
-
|
27
|
+
class_name = agent.response[:data].keys.first
|
28
|
+
key = agent.response[:data][class_name].keys.first
|
29
|
+
|
30
|
+
# TODO set session cookie
|
31
|
+
# agent.response[:session_cookie]
|
32
|
+
agent.result = Isomorfeus.cached_data_class(class_name).new(key: key)
|
30
33
|
else
|
34
|
+
error = agent.response[:error]
|
35
|
+
`console.err(error)` if error
|
31
36
|
raise 'Login failed!' # calls .fail
|
32
37
|
end
|
33
38
|
end
|
data/lib/lucid_handler/mixin.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.zeta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,98 +16,98 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: iodine
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.7.
|
33
|
+
version: 0.7.38
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.7.
|
40
|
+
version: 0.7.38
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: oj
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.10.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.10.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: opal
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 1.0.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 1.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: isomorfeus-redux
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.0.
|
75
|
+
version: 4.0.16
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.0.
|
82
|
+
version: 4.0.16
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: isomorfeus-react
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 16.
|
89
|
+
version: 16.12.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 16.
|
96
|
+
version: 16.12.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isomorfeus-policy
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.0.0.
|
103
|
+
version: 1.0.0.zeta6
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.0.0.
|
110
|
+
version: 1.0.0.zeta6
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: websocket-driver
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,33 +123,33 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.7.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: isomorfeus
|
126
|
+
name: isomorfeus
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.0.
|
131
|
+
version: 1.0.0.zeta6
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.0.0.
|
138
|
+
version: 1.0.0.zeta6
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: opal-webpack-loader
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.9.
|
145
|
+
version: 0.9.9
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.9.
|
152
|
+
version: 0.9.9
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- lib/isomorfeus/transport/middlewares.rb
|
195
195
|
- lib/isomorfeus/transport/rack_middleware.rb
|
196
196
|
- lib/isomorfeus/transport/request_agent.rb
|
197
|
+
- lib/isomorfeus/transport/response_agent.rb
|
197
198
|
- lib/isomorfeus/transport/server_processor.rb
|
198
199
|
- lib/isomorfeus/transport/server_socket_processor.rb
|
199
200
|
- lib/isomorfeus/transport/version.rb
|