isomorfeus-transport 1.0.0.zeta12 → 1.0.0.zeta13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/isomorfeus-transport.rb +0 -1
- data/lib/isomorfeus/transport.rb +4 -4
- data/lib/isomorfeus/transport/config.rb +16 -0
- data/lib/isomorfeus/transport/handler/authentication_handler.rb +9 -7
- data/lib/isomorfeus/transport/server_processor.rb +8 -10
- data/lib/isomorfeus/transport/server_socket_processor.rb +5 -1
- data/lib/isomorfeus/transport/version.rb +1 -1
- data/lib/isomorfeus/transport/websocket.rb +3 -3
- data/lib/lucid_authentication/mixin.rb +18 -13
- data/lib/lucid_channel/mixin.rb +4 -0
- data/lib/lucid_handler/mixin.rb +8 -0
- metadata +8 -9
- data/lib/isomorfeus/transport/props_proxy.rb +0 -95
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5afe07287186efbadeb44399e12872613c72c13754d6c2286f5942d74e399c65
|
4
|
+
data.tar.gz: 43d9ede92dcf3f9abd5dddecdab7721d348095645692a59ca4a8a8349a956e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddf5e798a2ce98f0f1b7c1852e8fde0f9fe3a52f9b7e621bf26128aac82d5d73cb4ba917e693de2b6056126d9fe05e1a1b9f719128053d9825984992e7f868a
|
7
|
+
data.tar.gz: 1af593318aa9a0fff41e0d7adb5e2c4d0895b62e719b5dae783f2a3cac619b94db647d7c11b54210f184613947b4901d4c495aa82c7036dc30ddf8cc7364f560
|
data/README.md
CHANGED
@@ -34,11 +34,11 @@ Server only:
|
|
34
34
|
|
35
35
|
For authentication in isomorfeus there is a class `Anonymous`, so whenever no user is logged in, the anonymous user is passed on to operations
|
36
36
|
or data loads. In my opinion it is more true than no user (nil), because in fact there probably is a user, just the user is unknown.
|
37
|
-
The Anonymous user has a default policy that
|
38
|
-
Of course, the developer can add a Policy easily, to
|
37
|
+
The Anonymous user has a default policy that allows everything, the user will respond to .authorized?(whatever) always with true by default.
|
38
|
+
Of course, the developer can add a Policy easily, to deny certain operations or data loads, or whatever or deny everything:
|
39
39
|
```ruby
|
40
40
|
class AnonymousPolicy < LucidPolicy::Base
|
41
|
-
|
41
|
+
deny all
|
42
42
|
end
|
43
43
|
```
|
44
44
|
For more information about policy see [the policy docs](https://github.com/isomorfeus/isomorfeus-project/blob/master/ruby/isomorfeus-policy/README.md).
|
@@ -47,14 +47,14 @@ A class representing a user should be a LucidNode and include LucidAuthenticatio
|
|
47
47
|
```ruby
|
48
48
|
class User < LucidGenericDocument::Base
|
49
49
|
include LucidAuthentication::Mixin
|
50
|
-
authentication do |
|
50
|
+
authentication do |user:, pass:|
|
51
51
|
# should return either a User instance or a Promise which reselves to a User instance
|
52
52
|
end
|
53
53
|
end
|
54
54
|
```
|
55
55
|
With that its possible to do on the client (or server):
|
56
56
|
```ruby
|
57
|
-
User.promise_login(user_identifier, user_password_or_token).then do |user|
|
57
|
+
User.promise_login(user: user_identifier, pass: user_password_or_token).then do |user|
|
58
58
|
# do something with user
|
59
59
|
end
|
60
60
|
```
|
@@ -64,13 +64,13 @@ user.promise_logout
|
|
64
64
|
```
|
65
65
|
The authentication in isomorfeus is prepared for external or alternate authentication schemes, example:
|
66
66
|
```ruby
|
67
|
-
User.promise_login(user_identifier, token, :facebook).then do |user|
|
67
|
+
User.promise_login(user: user_identifier, pass: token, :facebook).then do |user|
|
68
68
|
# do something with user
|
69
69
|
end
|
70
70
|
```
|
71
71
|
will call:
|
72
72
|
```ruby
|
73
|
-
User.promise_authentication_with_facebook(user_identifier, token)
|
73
|
+
User.promise_authentication_with_facebook(user: user_identifier, pass: token)
|
74
74
|
```
|
75
75
|
which would have to be implemented.
|
76
76
|
|
data/lib/isomorfeus-transport.rb
CHANGED
data/lib/isomorfeus/transport.rb
CHANGED
@@ -95,7 +95,7 @@ module Isomorfeus
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
register_request_in_progress(request, agent.id)
|
98
|
-
|
98
|
+
Isomorfeus.raise_error(message: 'No socket!') unless @socket
|
99
99
|
begin
|
100
100
|
@socket.send(`JSON.stringify(#{{request: { agent_ids: { agent.id => request }}}.to_n})`)
|
101
101
|
agent.sent = true
|
@@ -115,7 +115,7 @@ module Isomorfeus
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def send_notification(channel_class, channel, message)
|
118
|
-
|
118
|
+
Isomorfeus.raise_error(message: 'No socket!') unless @socket
|
119
119
|
@socket.send(`JSON.stringify(#{{notification: { class: channel_class.name, channel: channel, message: message}}.to_n})`)
|
120
120
|
true
|
121
121
|
end
|
@@ -127,7 +127,7 @@ module Isomorfeus
|
|
127
127
|
else
|
128
128
|
agent = Isomorfeus::Transport::RequestAgent.new(request)
|
129
129
|
register_request_in_progress(request, agent.id)
|
130
|
-
|
130
|
+
Isomorfeus.raise_error(message: 'No socket!') unless @socket
|
131
131
|
@socket.send(`JSON.stringify(#{{subscribe: { agent_ids: { agent.id => request }}}.to_n})`)
|
132
132
|
end
|
133
133
|
result_promise = agent.promise.then do |agent|
|
@@ -148,7 +148,7 @@ module Isomorfeus
|
|
148
148
|
else
|
149
149
|
agent = Isomorfeus::Transport::RequestAgent.new(request)
|
150
150
|
register_request_in_progress(request, agent.id)
|
151
|
-
|
151
|
+
Isomorfeus.raise_error(message: 'No socket!') unless @socket
|
152
152
|
@socket.send(`JSON.stringify(#{{unsubscribe: { agent_ids: { agent.id => request }}}.to_n})`)
|
153
153
|
end
|
154
154
|
result_promise = agent.promise.then do |agent|
|
@@ -8,6 +8,14 @@ module Isomorfeus
|
|
8
8
|
def self.add_transport_init_class_name(init_class_name)
|
9
9
|
transport_init_class_names << init_class_name
|
10
10
|
end
|
11
|
+
|
12
|
+
def self.current_user
|
13
|
+
@current_user ||= Anonymous.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.set_current_user(user)
|
17
|
+
@current_user = user ? user : Anonymous.new
|
18
|
+
end
|
11
19
|
else
|
12
20
|
class << self
|
13
21
|
attr_accessor :api_websocket_path
|
@@ -113,6 +121,14 @@ module Isomorfeus
|
|
113
121
|
class_name = class_name.split('>::').last if class_name.start_with?('#<')
|
114
122
|
class_name
|
115
123
|
end
|
124
|
+
|
125
|
+
def current_user
|
126
|
+
Thread.current[:isomorfeus_user]
|
127
|
+
end
|
128
|
+
|
129
|
+
def pub_sub_client
|
130
|
+
Thread.current[:isomorfeus_pub_sub_client]
|
131
|
+
end
|
116
132
|
end
|
117
133
|
end
|
118
134
|
|
@@ -4,7 +4,7 @@ module Isomorfeus
|
|
4
4
|
class AuthenticationHandler < LucidHandler::Base
|
5
5
|
TIMEOUT = 30
|
6
6
|
|
7
|
-
on_request do |
|
7
|
+
on_request do |response_agent|
|
8
8
|
result = { error: 'Authentication failed' }
|
9
9
|
# promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', user_class_name, user_identifier, user_password)
|
10
10
|
response_agent.request.each_key do |login_or_logout|
|
@@ -13,13 +13,13 @@ module Isomorfeus
|
|
13
13
|
tries = 0 unless tries
|
14
14
|
tries += 1
|
15
15
|
sleep(5) if tries > 3 # TODO, this needs a better solution (store data in user/session)
|
16
|
-
pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, tries)
|
16
|
+
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, tries)
|
17
17
|
response_agent.request['login'].each_key do |user_class_name|
|
18
18
|
user = nil
|
19
19
|
if Isomorfeus.valid_user_class_name?(user_class_name)
|
20
20
|
user_class = Isomorfeus.cached_user_class(user_class_name)
|
21
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])
|
22
|
+
promise = user_class.promise_login(user: user_identifier, pass: response_agent.request['login'][user_class_name][user_identifier])
|
23
23
|
unless promise.realized?
|
24
24
|
start = Time.now
|
25
25
|
until promise.realized?
|
@@ -32,15 +32,17 @@ module Isomorfeus
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
if user
|
35
|
-
pub_sub_client.instance_variable_set(:@isomorfeus_user, user)
|
36
|
-
pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, nil)
|
35
|
+
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_user, user)
|
36
|
+
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, nil)
|
37
37
|
# TODO store session in db and supply session cookie: session_cookie: uuid or so
|
38
38
|
response_agent.agent_result = { success: 'ok', data: user.to_transport }
|
39
39
|
end
|
40
40
|
end
|
41
41
|
elsif login_or_logout == 'logout'
|
42
42
|
begin
|
43
|
-
promise = current_user.promise_logout
|
43
|
+
promise = Isomorfeus.current_user.promise_logout
|
44
|
+
# TODO remove session from db
|
45
|
+
# response_agent.agent_result = { success: 'ok', data: user.to_transport }
|
44
46
|
unless promise.realized?
|
45
47
|
start = Time.now
|
46
48
|
until promise.realized?
|
@@ -49,7 +51,7 @@ module Isomorfeus
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
ensure
|
52
|
-
pub_sub_client.instance_variable_set(:@isomorfeus_user, nil)
|
54
|
+
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_user, nil)
|
53
55
|
response_agent.agent_result = { success: 'ok' }
|
54
56
|
end
|
55
57
|
end
|
@@ -3,9 +3,7 @@
|
|
3
3
|
module Isomorfeus
|
4
4
|
module Transport
|
5
5
|
module ServerProcessor
|
6
|
-
def process_request(
|
7
|
-
Thread.current[:isomorfeus_pub_sub_client] = client
|
8
|
-
|
6
|
+
def process_request(request, handler_instance_cache, response_agent_array)
|
9
7
|
if request.key?('request') && request['request'].key?('agent_ids')
|
10
8
|
request['request']['agent_ids'].each_key do |agent_id|
|
11
9
|
request['request']['agent_ids'][agent_id].each_key do |handler_class_name|
|
@@ -19,7 +17,7 @@ module Isomorfeus
|
|
19
17
|
handler_instance_cache[handler_class_name] = handler_class.new if handler_class
|
20
18
|
end
|
21
19
|
if handler
|
22
|
-
handler.process_request(
|
20
|
+
handler.process_request(response_agent)
|
23
21
|
else
|
24
22
|
response_agent.error = { error: { handler_class_name => 'No such handler!'}}
|
25
23
|
end
|
@@ -35,8 +33,8 @@ module Isomorfeus
|
|
35
33
|
|
36
34
|
if Isomorfeus.valid_channel_class_name?(class_name) && channel
|
37
35
|
channel_class = Isomorfeus.cached_channel_class(class_name)
|
38
|
-
if channel_class && current_user.authorized?(channel_class, :send_message, channel)
|
39
|
-
|
36
|
+
if channel_class && Isomorfeus.current_user.authorized?(channel_class, :send_message, channel)
|
37
|
+
Isomorfeus.pub_sub_client.publish(request['notification']['channel'], Oj.dump({ 'notification' => request['notification'] }, mode: :strict))
|
40
38
|
else
|
41
39
|
response_agent = OpenStruct.new
|
42
40
|
response_agent_array << response_agent
|
@@ -61,8 +59,8 @@ module Isomorfeus
|
|
61
59
|
class_name = response_agent.request['class']
|
62
60
|
if Isomorfeus.valid_channel_class_name?(class_name) && channel
|
63
61
|
channel_class = Isomorfeus.cached_channel_class(class_name)
|
64
|
-
if channel_class && current_user.authorized?(channel_class, :subscribe, channel)
|
65
|
-
|
62
|
+
if channel_class && Isomorfeus.current_user.authorized?(channel_class, :subscribe, channel)
|
63
|
+
Isomorfeus.pub_sub_client.subscribe(channel)
|
66
64
|
response_agent.agent_result = { success: channel }
|
67
65
|
else
|
68
66
|
response_agent.error = { error: "Not authorized!"}
|
@@ -82,8 +80,8 @@ module Isomorfeus
|
|
82
80
|
class_name = response_agent.request['class']
|
83
81
|
if Isomorfeus.valid_channel_class_name?(class_name) && channel
|
84
82
|
channel_class = Isomorfeus.cached_channel_class(class_name)
|
85
|
-
if channel_class && current_user.authorized?(channel_class, :unsubscribe, channel)
|
86
|
-
|
83
|
+
if channel_class && Isomorfeus.current_user.authorized?(channel_class, :unsubscribe, channel)
|
84
|
+
Isomorfeus.pub_sub_client.unsubscribe(channel)
|
87
85
|
response_agent.agent_result = { success: channel }
|
88
86
|
else
|
89
87
|
response_agent.error = { error: "Not authorized!"}
|
@@ -15,7 +15,9 @@ module Isomorfeus
|
|
15
15
|
request_hash = Oj.load(data, mode: :strict)
|
16
16
|
handler_instance_cache = {}
|
17
17
|
response_agent_array = []
|
18
|
-
|
18
|
+
Thread.current[:isomorfeus_user] = user(client)
|
19
|
+
Thread.current[:isomorfeus_pub_sub_client] = client
|
20
|
+
process_request(request_hash, handler_instance_cache, response_agent_array)
|
19
21
|
handler_instance_cache.each_value do |handler|
|
20
22
|
handler.resolve if handler.resolving?
|
21
23
|
end
|
@@ -25,6 +27,8 @@ module Isomorfeus
|
|
25
27
|
end
|
26
28
|
client.write Oj.dump(result, mode: :strict)
|
27
29
|
ensure
|
30
|
+
Thread.current[:isomorfeus_user] = nil
|
31
|
+
Thread.current[:isomorfeus_pub_sub_client] = nil
|
28
32
|
Isomorfeus.zeitwerk_lock.release_read_lock if Isomorfeus.development?
|
29
33
|
end
|
30
34
|
|
@@ -49,8 +49,8 @@ module Isomorfeus
|
|
49
49
|
case ready_state
|
50
50
|
when OPEN then @native_websocket.JS.send(data)
|
51
51
|
when CONNECTING then Isomorfeus::Transport.delay(50) { send(data) }
|
52
|
-
when CLOSING then
|
53
|
-
when CLOSED then
|
52
|
+
when CLOSING then Isomorfeus.raise_error(error_class: SendError, message: 'Cant send, connection is closing!')
|
53
|
+
when CLOSED then Isomorfeus.raise_error(error_class: SendError.new, message: 'Cant send, connection is closed!')
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -120,4 +120,4 @@ module Isomorfeus
|
|
120
120
|
alias_method :write, :send
|
121
121
|
end
|
122
122
|
end
|
123
|
-
end
|
123
|
+
end
|
@@ -7,17 +7,17 @@ module LucidAuthentication
|
|
7
7
|
def authentication(&block)
|
8
8
|
end
|
9
9
|
|
10
|
-
def promise_login(
|
11
|
-
send("promise_authentication_with_#{scheme}",
|
10
|
+
def promise_login(user: nil, pass: nil, scheme: :isomorfeus)
|
11
|
+
send("promise_authentication_with_#{scheme}",user: user, pass: pass)
|
12
12
|
end
|
13
13
|
|
14
|
-
def promise_authentication_with_isomorfeus(
|
14
|
+
def promise_authentication_with_isomorfeus(user: nil, pass: nil)
|
15
15
|
if Isomorfeus.production?
|
16
|
-
|
16
|
+
Isomorfeus.raise_error(message: "Connection not secure, can't login") unless Isomorfeus::Transport.socket.url.start_with?('wss:')
|
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', self.name,
|
20
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', self.name, user, pass).then do |agent|
|
21
21
|
if agent.processed
|
22
22
|
agent.result
|
23
23
|
else
|
@@ -29,11 +29,13 @@ module LucidAuthentication
|
|
29
29
|
|
30
30
|
# TODO set session cookie
|
31
31
|
# agent.response[:session_cookie]
|
32
|
-
|
32
|
+
logged_in_user = Isomorfeus.cached_data_class(class_name).new(key: key)
|
33
|
+
Isomorfeus.set_current_user(logged_in_user)
|
34
|
+
agent.result = logged_in_user
|
33
35
|
else
|
34
36
|
error = agent.response[:error]
|
35
37
|
`console.err(error)` if error
|
36
|
-
|
38
|
+
Isomorfeus.raise_error(message: 'Login failed!') # triggers .fail
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -41,12 +43,15 @@ module LucidAuthentication
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
def promise_logout(scheme
|
46
|
+
def promise_logout(scheme: :isomorfeus)
|
45
47
|
send("promise_deauthentication_with_#{scheme}")
|
46
48
|
end
|
47
49
|
|
48
50
|
def promise_deauthentication_with_isomorfeus
|
49
51
|
Isomorfeus::Transport.promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'logout', 'logout').then do |agent|
|
52
|
+
# TODO unset session cookie
|
53
|
+
# agent.response[:session_cookie]
|
54
|
+
Isomorfeus.set_current_user(nil)
|
50
55
|
agent.processed = true
|
51
56
|
agent.response.key?(:success) ? true : raise('Logout failed!')
|
52
57
|
end
|
@@ -60,12 +65,12 @@ module LucidAuthentication
|
|
60
65
|
@authentication_block = block
|
61
66
|
end
|
62
67
|
|
63
|
-
def promise_login(
|
64
|
-
send("promise_authentication_with_#{scheme}",
|
68
|
+
def promise_login(user: nil, pass: nil, scheme: :isomorfeus)
|
69
|
+
send("promise_authentication_with_#{scheme}", user: user, pass: pass)
|
65
70
|
end
|
66
71
|
|
67
|
-
def promise_authentication_with_isomorfeus(
|
68
|
-
promise_or_user = @authentication_block.call(
|
72
|
+
def promise_authentication_with_isomorfeus(user: nil, pass: nil)
|
73
|
+
promise_or_user = @authentication_block.call(user: user, pass: pass)
|
69
74
|
if promise_or_user.class == Promise
|
70
75
|
promise_or_user
|
71
76
|
else
|
@@ -75,7 +80,7 @@ module LucidAuthentication
|
|
75
80
|
end
|
76
81
|
end
|
77
82
|
|
78
|
-
def promise_logout(scheme
|
83
|
+
def promise_logout(scheme: :isomorfeus)
|
79
84
|
send("promise_deauthentication_with_#{scheme}")
|
80
85
|
end
|
81
86
|
|
data/lib/lucid_channel/mixin.rb
CHANGED
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.zeta13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 16.12.
|
89
|
+
version: 16.12.14
|
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.12.
|
96
|
+
version: 16.12.14
|
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.zeta13
|
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.zeta13
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: websocket-driver
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.0.
|
131
|
+
version: 1.0.0.zeta13
|
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.zeta13
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: opal-webpack-loader
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,7 +192,6 @@ files:
|
|
192
192
|
- lib/isomorfeus/transport/config.rb
|
193
193
|
- lib/isomorfeus/transport/handler/authentication_handler.rb
|
194
194
|
- lib/isomorfeus/transport/middlewares.rb
|
195
|
-
- lib/isomorfeus/transport/props_proxy.rb
|
196
195
|
- lib/isomorfeus/transport/rack_middleware.rb
|
197
196
|
- lib/isomorfeus/transport/request_agent.rb
|
198
197
|
- lib/isomorfeus/transport/response_agent.rb
|
@@ -1,95 +0,0 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module Transport
|
3
|
-
class PropsProxy
|
4
|
-
def initialize(props_hash)
|
5
|
-
props_hash = {} unless props_hash
|
6
|
-
@props_hash = props_hash
|
7
|
-
end
|
8
|
-
|
9
|
-
def any?
|
10
|
-
@props_hash.keys.size > 0
|
11
|
-
end
|
12
|
-
|
13
|
-
if RUBY_ENGINE == 'opal'
|
14
|
-
def [](prop_name)
|
15
|
-
@props_hash[prop_name]
|
16
|
-
end
|
17
|
-
|
18
|
-
def []=(prop_name, value)
|
19
|
-
@props_hash[prop_name] = value
|
20
|
-
end
|
21
|
-
|
22
|
-
def key?(prop_name)
|
23
|
-
@props_hash.key?(prop_name)
|
24
|
-
end
|
25
|
-
|
26
|
-
def keys
|
27
|
-
@props_hash.keys
|
28
|
-
end
|
29
|
-
|
30
|
-
def method_missing(prop_name, *args, &block)
|
31
|
-
return @props_hash[prop_name] if @props_hash.key?(prop_name)
|
32
|
-
super(prop_name, *args, &block)
|
33
|
-
end
|
34
|
-
|
35
|
-
def set(prop_name, value)
|
36
|
-
@props_hash[prop_name] = value
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_json
|
40
|
-
JSON.dump(to_transport)
|
41
|
-
end
|
42
|
-
|
43
|
-
def to_transport
|
44
|
-
transport_hash = {}.merge(@props_hash)
|
45
|
-
transport_hash
|
46
|
-
end
|
47
|
-
else # RUBY_ENGINE
|
48
|
-
def [](prop_name)
|
49
|
-
name = prop_name.to_sym
|
50
|
-
return @props_hash[name] if @props_hash.key?(name)
|
51
|
-
name = prop_name.to_s
|
52
|
-
return @props_hash[name] if @props_hash.key?(name)
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
|
56
|
-
def []=(prop_name, value)
|
57
|
-
@props_hash[prop_name.to_sym] = value
|
58
|
-
end
|
59
|
-
|
60
|
-
def key?(prop_name)
|
61
|
-
@props_hash.key?(prop_name.to_sym) || @props_hash.key?(prop_name.to_s)
|
62
|
-
end
|
63
|
-
|
64
|
-
def keys
|
65
|
-
@props_hash.keys.map(&:to_sym)
|
66
|
-
end
|
67
|
-
|
68
|
-
def method_missing(prop_name, *args, &block)
|
69
|
-
name = prop_name.to_sym
|
70
|
-
return @props_hash[name] if @props_hash.key?(name)
|
71
|
-
name = prop_name.to_s
|
72
|
-
return @props_hash[name] if @props_hash.key?(name)
|
73
|
-
super(prop_name, *args, &block)
|
74
|
-
end
|
75
|
-
|
76
|
-
def set(prop_name, value)
|
77
|
-
@props_hash[prop_name.to_sym] = value
|
78
|
-
end
|
79
|
-
|
80
|
-
def to_json
|
81
|
-
Oj.dump(to_transport, mode: :strict)
|
82
|
-
end
|
83
|
-
|
84
|
-
def to_transport
|
85
|
-
transport_hash = {}.merge(@props_hash)
|
86
|
-
transport_hash.delete(:pub_sub_client)
|
87
|
-
transport_hash.delete(:current_user)
|
88
|
-
transport_hash
|
89
|
-
end
|
90
|
-
end # RUBY_ENGINE
|
91
|
-
|
92
|
-
alias_method :has_key?, :key?
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|