isomorfeus-transport 2.0.22 → 2.1.0

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: b872518d86b0db6ce6e17df0c68430fbe77bda5e72570e5695d08b0ff446214d
4
- data.tar.gz: 81d646f30892009b36c933a3e6776988404f273331edf8b604b3fea247945a3a
3
+ metadata.gz: 3ca90b01b8e0190145be6337a5d426a696d14fdf930d27459580c68b1c79f7e0
4
+ data.tar.gz: 96a02a4bc0c826f8099464c2186c4d43465a22d23acbc7b78427e765453f47b5
5
5
  SHA512:
6
- metadata.gz: 56a070d1175c8c5de03ffccd696d018a3f1181403a230ba65204aec03162748e3c5850ff83df5c6bb098daa6afe3418a82f0643516dd117cf9c214ab28c4b1c0
7
- data.tar.gz: 9a0fc1ab05ba1ccdb919fcb75ef09bc9a5eb9b618d056e0d00b774ee659d7c8cd5bcc37a1c2e57fe07f7f241e013dff9337ffb52a33f3735146348b5b3d66b0c
6
+ metadata.gz: eb3a558d2a4932891262951936b0bfcd58dca2c76dca299bc4d289847070b1fac98deece4714424b727dc6d9545ca500c01a367b057c0eef89c45ddea08b9190
7
+ data.tar.gz: 43d8418632c1e4b848b16146f2e4367e5c0a80ba7e8d2d78a0699942206206bcf4630437733a4e4405440e332da16a9fa2740fad9eaa91a7ebfdc16693106221
@@ -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.22'
3
+ VERSION = '2.1.0'
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'
@@ -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.22
4
+ version: 2.1.0
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-12 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.14.9
89
+ version: 0.14.10
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.9
96
+ version: 0.14.10
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: isomorfeus-hamster
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,28 +114,28 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 10.6.31
117
+ version: 10.6.34
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.31
124
+ version: 10.6.34
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.22
131
+ version: 2.1.0
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.22
138
+ version: 2.1.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: isomorfeus-redux
141
141
  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.22
173
+ version: 2.1.0
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.22
180
+ version: 2.1.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement