isomorfeus-transport 2.0.20 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da6a608ce2fb13f818a80f38262675029502d83a08b41d72be22d149e1e70ab3
4
- data.tar.gz: d9176cc9c9a7706ad22a566b1be275597ca1cca6066ceeef70ef10bd9fc78ff1
3
+ metadata.gz: 248d55d33e660304657af70d2cff956e834bea7b1fc79004c6f0922e9ac5ce14
4
+ data.tar.gz: 125ddf417c613bdeec962604212db44a71bf37f940bbf9b35b56feb2385c7b10
5
5
  SHA512:
6
- metadata.gz: 12a4409412126e591a639bff36938c0954114b3b672bdaed91e62de70980a7cd7e52cd90bb5c29169da85797f76042ed6e6ce8b34d65fbd51f86e34e7bc334b2
7
- data.tar.gz: baccf03ee49a0f827213f42061468fc8b33a573192a952d658189dc63f6492c3757fcc3fdc6f9a7e7a42dc8b90227e92d65d6b2b3a2eb7b2feb38c6a501507f8
6
+ metadata.gz: a9f11baa08314ac284180432ec36ff641e2544c5f592ef17cd6832ce408dbddec51d401a278067f9f2fe68cdd5bebccad974143fa5416179c7cdca6b04ba7ede
7
+ data.tar.gz: 7fd94cf7fcec1fdb3c0b81c755b6c39330fe437cd2c4a9d9673fa0bc45025ddba6863d88871563234aea59d754d980af88b616f698d03bc39abd44b4d02a2052
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Transport and PubSub for Isomorfeus.
4
4
 
5
5
  ### Community and Support
6
- At the [Isomorfeus Framework Project](http://isomorfeus.com)
6
+ At the [Isomorfeus Framework Project](https://isomorfeus.com)
7
7
 
8
8
  ## Installation
9
9
  isomorfeus-transport is usually installed with the installer.
@@ -78,8 +78,8 @@ module Isomorfeus
78
78
  valid_channel_class_names.include?(class_name)
79
79
  end
80
80
 
81
- def add_middleware(middleware)
82
- Isomorfeus.middlewares << middleware
81
+ def add_middleware(new_middleware)
82
+ Isomorfeus.middlewares.push(new_middleware) unless Isomorfeus.middlewares.include?(new_middleware)
83
83
  end
84
84
 
85
85
  def insert_middleware_after(existing_middleware, new_middleware)
@@ -88,7 +88,7 @@ module Isomorfeus
88
88
  if index_of_existing
89
89
  Isomorfeus.middlewares.insert(index_of_existing + 1, new_middleware)
90
90
  else
91
- Isomorfeus.middlewares << new_middleware
91
+ Isomorfeus.middlewares.push(new_middleware)
92
92
  end
93
93
  end
94
94
  end
@@ -99,13 +99,13 @@ module Isomorfeus
99
99
  if index_of_existing
100
100
  Isomorfeus.middlewares.insert(index_of_existing, new_middleware)
101
101
  else
102
- Isomorfeus.middlewares << new_middleware
102
+ Isomorfeus.middlewares.push(new_middleware)
103
103
  end
104
104
  end
105
105
  end
106
106
 
107
107
  def middlewares
108
- @middlewares ||= Set.new
108
+ @middlewares ||= []
109
109
  end
110
110
 
111
111
  def valid_handler_class_names
@@ -170,7 +170,7 @@ module Isomorfeus
170
170
  end
171
171
 
172
172
  self.session_store_init do
173
- store_path = File.expand_path(File.join(Isomorfeus.root, 'data', Isomorfeus.env, 'session_store'))
173
+ store_path = File.expand_path(File.join(Isomorfeus.root, 'storage', Isomorfeus.env, 'session_store'))
174
174
  Isomorfeus::Transport::HamsterSessionStore.new(store_path)
175
175
  end
176
176
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Transport
3
- VERSION = '2.0.20'
3
+ VERSION = '2.1.1'
4
4
  end
5
5
  end
@@ -6,7 +6,6 @@ module Isomorfeus
6
6
 
7
7
  def init
8
8
  @socket = nil
9
- @initialized = false
10
9
  promise_connect if Isomorfeus.on_browser? || Isomorfeus.on_mobile?
11
10
  true
12
11
  end
@@ -42,23 +41,16 @@ module Isomorfeus
42
41
  Isomorfeus::Transport::ClientProcessor.process(json_hash)
43
42
  end
44
43
  @socket.on_open do |event|
45
- if @initialized
46
- requests_in_progress[:requests].each_key do |request|
47
- agent = get_agent_for_request_in_progress(request)
48
- promise_send_request(request) if agent && !agent.sent
49
- end
50
- promise.resolve(true)
51
- else
52
- @initialized = true
53
- init_promises = []
54
- Isomorfeus.transport_init_class_names.each do |constant|
55
- result = constant.constantize.send(:init)
56
- init_promises << result if result.class == Promise
57
- end
58
- if init_promises.size > 0
59
- Promise.when(*init_promises).then { promise.resolve(true) }
60
- end
44
+ open_promise = Promise.new.resolve(true)
45
+ Isomorfeus.transport_init_class_names.each do |constant|
46
+ result_promise = constant.constantize.send(:init)
47
+ open_promise.then { result_promise } if result_promise.class == Promise
48
+ end
49
+ requests_in_progress[:requests].each_key do |request|
50
+ agent = get_agent_for_request_in_progress(request)
51
+ open_promise.then { promise_send_request(request) } if agent && !agent.sent
61
52
  end
53
+ open_promise.then { promise.resolve(true) }
62
54
  end
63
55
  promise
64
56
  end
@@ -100,14 +92,15 @@ module Isomorfeus
100
92
  begin
101
93
  @socket.send(`JSON.stringify(#{{request: { agent_ids: { agent.id => request }}}.to_n})`)
102
94
  agent.sent = true
103
- after(Isomorfeus.on_ssr? ? 8000 : 20000) do
95
+ after(Isomorfeus.on_ssr? ? 5000 : 20000) do
104
96
  unless agent.promise.realized?
105
97
  agent.promise.reject({agent_response: { error: 'Request timeout!' }, full_response: {}})
106
98
  end
107
99
  end
108
100
  rescue
109
101
  @socket.close
110
- after 5000 do
102
+ after (Isomorfeus.on_ssr? ? 10 : 3000) do
103
+ @reconnect = true
111
104
  Isomorfeus::Transport.promise_connect
112
105
  end
113
106
  end
@@ -8,12 +8,15 @@ if RUBY_ENGINE == 'opal'
8
8
  require 'isomorfeus/transport/client_processor'
9
9
  require 'isomorfeus/transport/websocket_client'
10
10
  require 'isomorfeus/transport'
11
- require 'isomorfeus/transport/ssr_login'
11
+
12
12
  require 'lucid_channel/mixin'
13
13
  require 'lucid_channel/base'
14
14
  Isomorfeus.zeitwerk.push_dir('channels')
15
15
  Isomorfeus.add_client_init_class_name('Isomorfeus::Transport')
16
- Isomorfeus.add_transport_init_class_name('Isomorfeus::Transport::SsrLogin') if Isomorfeus.on_ssr?
16
+ if Isomorfeus.on_ssr?
17
+ require 'isomorfeus/transport/ssr_login'
18
+ Isomorfeus.add_transport_init_class_name('Isomorfeus::Transport::SsrLogin')
19
+ end
17
20
  else
18
21
  require 'base64'
19
22
  require 'digest'
@@ -26,6 +29,7 @@ else
26
29
  require 'oj'
27
30
  require 'active_support'
28
31
  require 'isomorfeus-asset-manager'
32
+ require 'isomorfeus-hamster'
29
33
  require 'isomorfeus/transport/hamster_session_store'
30
34
  opal_path = Gem::Specification.find_by_name('opal').full_gem_path
31
35
  promise_path = File.join(opal_path, 'stdlib', 'promise.rb')
@@ -4,9 +4,9 @@
4
4
  "requires": true,
5
5
  "packages": {
6
6
  "node_modules/ws": {
7
- "version": "8.4.2",
8
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
9
- "integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
7
+ "version": "8.5.0",
8
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
9
+ "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
10
10
  "engines": {
11
11
  "node": ">=10.0.0"
12
12
  },
@@ -49,6 +49,8 @@ class WebSocketServer extends EventEmitter {
49
49
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
50
50
  * not to skip UTF-8 validation for text and close messages
51
51
  * @param {Function} [options.verifyClient] A hook to reject connections
52
+ * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
53
+ * class to use. It must be the `WebSocket` class or class that extends it
52
54
  * @param {Function} [callback] A listener for the `listening` event
53
55
  */
54
56
  constructor(options, callback) {
@@ -67,6 +69,7 @@ class WebSocketServer extends EventEmitter {
67
69
  host: null,
68
70
  path: null,
69
71
  port: null,
72
+ WebSocket,
70
73
  ...options
71
74
  };
72
75
 
@@ -356,7 +359,7 @@ class WebSocketServer extends EventEmitter {
356
359
  `Sec-WebSocket-Accept: ${digest}`
357
360
  ];
358
361
 
359
- const ws = new WebSocket(null);
362
+ const ws = new this.options.WebSocket(null);
360
363
 
361
364
  if (protocols.size) {
362
365
  //
@@ -766,6 +766,45 @@ function initAsClient(websocket, address, protocols, options) {
766
766
  opts.path = parts[1];
767
767
  }
768
768
 
769
+ if (opts.followRedirects) {
770
+ if (websocket._redirects === 0) {
771
+ websocket._originalHost = parsedUrl.host;
772
+
773
+ const headers = options && options.headers;
774
+
775
+ //
776
+ // Shallow copy the user provided options so that headers can be changed
777
+ // without mutating the original object.
778
+ //
779
+ options = { ...options, headers: {} };
780
+
781
+ if (headers) {
782
+ for (const [key, value] of Object.entries(headers)) {
783
+ options.headers[key.toLowerCase()] = value;
784
+ }
785
+ }
786
+ } else if (parsedUrl.host !== websocket._originalHost) {
787
+ //
788
+ // Match curl 7.77.0 behavior and drop the following headers. These
789
+ // headers are also dropped when following a redirect to a subdomain.
790
+ //
791
+ delete opts.headers.authorization;
792
+ delete opts.headers.cookie;
793
+ delete opts.headers.host;
794
+ opts.auth = undefined;
795
+ }
796
+
797
+ //
798
+ // Match curl 7.77.0 behavior and make the first `Authorization` header win.
799
+ // If the `Authorization` header is set, then there is nothing to do as it
800
+ // will take precedence.
801
+ //
802
+ if (opts.auth && !options.headers.authorization) {
803
+ options.headers.authorization =
804
+ 'Basic ' + Buffer.from(opts.auth).toString('base64');
805
+ }
806
+ }
807
+
769
808
  let req = (websocket._req = get(opts));
770
809
 
771
810
  if (opts.timeout) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws",
3
- "version": "8.4.2",
3
+ "version": "8.5.0",
4
4
  "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
5
5
  "keywords": [
6
6
  "HyBi",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isomorfeus-transport",
3
3
  "dependencies": {
4
- "ws": "8.4.2"
4
+ "ws": "8.5.0"
5
5
  }
6
6
  }
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: 2.0.20
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.1
19
+ version: 7.0.2
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: 7.0.1
26
+ version: 7.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bcrypt
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.46
47
+ version: 0.7.47
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: 0.7.46
54
+ version: 0.7.47
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: oj
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,70 +86,70 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.14.8
89
+ version: 0.14.12
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: 0.14.8
96
+ version: 0.14.12
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: isomorfeus-hamster
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.6.3
103
+ version: 0.6.4
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: 0.6.3
110
+ version: 0.6.4
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: isomorfeus-preact
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 10.6.30
117
+ version: 10.6.36
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 10.6.30
124
+ version: 10.6.36
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: isomorfeus-policy
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 2.0.20
131
+ version: 2.1.1
132
132
  type: :runtime
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: 2.0.20
138
+ version: 2.1.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: isomorfeus-redux
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 4.1.11
145
+ version: 4.1.17
146
146
  type: :runtime
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: 4.1.11
152
+ version: 4.1.17
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: sorted_set
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 2.0.20
173
+ version: 2.1.1
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 2.0.20
180
+ version: 2.1.1
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: 3.10.0
209
- description: Various transport options for Isomorfeus.
209
+ description: Channels, authetication and various transport options for Isomorfeus.
210
210
  email: jan@kursator.de
211
211
  executables: []
212
212
  extensions: []
@@ -256,11 +256,12 @@ files:
256
256
  - node_modules/ws/package.json
257
257
  - node_modules/ws/wrapper.mjs
258
258
  - package.json
259
- homepage: http://isomorfeus.com
259
+ homepage: https://isomorfeus.com
260
260
  licenses:
261
261
  - MIT
262
262
  metadata:
263
263
  github_repo: ssh://github.com/isomorfeus/gems
264
+ source_code_uri: https://github.com/isomorfeus/isomorfeus-project/isomorfeus-transport
264
265
  post_install_message:
265
266
  rdoc_options: []
266
267
  require_paths:
@@ -279,5 +280,5 @@ requirements: []
279
280
  rubygems_version: 3.3.3
280
281
  signing_key:
281
282
  specification_version: 4
282
- summary: Various transport options for Isomorfeus.
283
+ summary: Channels, authetication and various transport options for Isomorfeus.
283
284
  test_files: []