isomorfeus-transport 2.0.6 → 2.0.10

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: 8dba29abd51b27cfd59713a705738f47ecbe7bfb7f936f5b6005c71a2003eff8
4
- data.tar.gz: b502a4e8e8dce5506c6322bf675cfe086374582f45dfa2024f7f05b0873518f5
3
+ metadata.gz: c29793870992bcb4911f64a8566a4eb6ad8741e159c6d6b46829048d8402be75
4
+ data.tar.gz: a1ce9f82f0539be983d046b11c5c6f6f5bc611861599ca457803a3f29f36ce22
5
5
  SHA512:
6
- metadata.gz: e39da08f06daefb9a6d3cdd7444448dac79468623e754b574119fb72129d3db0ce3982b00e849b92b6e6bbafcdf7cb991ab025d66236cd3ea14309172d578b19
7
- data.tar.gz: f838fe50066ea6f030ca030ad981c66539e9643bbcbd69d1d223d1a9fa2ea7985a09293d35c28b0641e70c2c7ec7755e9c81d7fcc7cdf805697942979ae91122
6
+ metadata.gz: 9a83d32f80b58c8a10c965e81693a475b8e48ba1c3799e4525714f2a579fae518d512765f6a95015c32e9919dfff2e8a63dd7f0fbce34e0ad77f1192cfd71f42
7
+ data.tar.gz: 81dea7ee8204d0cdb521c8b542172fa222a91c97877374975514720ab2e09e9052f006d2cdc41a64b4dfd661a5d2b5c5e61bea27eb1b1bae0515f85ea230559c
@@ -16,6 +16,7 @@ module Isomorfeus
16
16
  cookie = cookies.detect { |c| c.start_with?('session=') }
17
17
  if cookie
18
18
  session_id = cookie[8..-1]
19
+ return [Anonymous.new, nil] if session_id.nil? || session_id.empty?
19
20
  user = Isomorfeus.session_store.get_user(session_id: session_id)
20
21
  [user, session_id]
21
22
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Transport
3
- VERSION = '2.0.6'
3
+ VERSION = '2.0.10'
4
4
  end
5
5
  end
@@ -11,10 +11,14 @@ module Isomorfeus
11
11
 
12
12
  class SendError < StandardError; end
13
13
 
14
- def initialize(url, protocols = nil)
14
+ def initialize(url, protocols = nil, headers = nil)
15
15
  @url = url
16
- @native_websocket = if protocols
16
+ @native_websocket = if protocols && headers
17
+ `new Opal.global.WebSocket(url, protocols, {headers: #{headers.to_n}})`
18
+ elsif protocols
17
19
  `new Opal.global.WebSocket(url, protocols)`
20
+ elsif headers
21
+ `new Opal.global.WebSocket(url, {headers: #{headers.to_n}})`
18
22
  else
19
23
  `new Opal.global.WebSocket(url)`
20
24
  end
@@ -11,7 +11,7 @@ module Isomorfeus
11
11
  true
12
12
  end
13
13
 
14
- def promise_connect
14
+ def promise_connect(session_id = nil)
15
15
  promise = Promise.new
16
16
  if @socket && @socket.ready_state < 2
17
17
  promise.resolve(true)
@@ -24,7 +24,8 @@ module Isomorfeus
24
24
  else
25
25
  ws_url = "#{Isomorfeus::TopLevel.transport_ws_url}"
26
26
  end
27
- @socket = Isomorfeus::Transport::WebsocketClient.new(ws_url)
27
+ headers = (session_id.nil? || session_id.empty?) ? nil : { 'Cookie': "session=#{session_id}" }
28
+ @socket = Isomorfeus::Transport::WebsocketClient.new(ws_url, nil, headers)
28
29
  @socket.on_error do |error|
29
30
  if Isomorfeus.on_browser?
30
31
  `console.warn('Isomorfeus::Transport: Will try again, but so far error connecting:', error)`
@@ -1,27 +1,27 @@
1
- {
2
- "name": "isomorfeus-transport",
3
- "lockfileVersion": 2,
4
- "requires": true,
5
- "packages": {
6
- "node_modules/ws": {
7
- "version": "8.2.1",
8
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.1.tgz",
9
- "integrity": "sha512-XkgWpJU3sHU7gX8f13NqTn6KQ85bd1WU7noBHTT8fSohx7OS1TPY8k+cyRPCzFkia7C4mM229yeHr1qK9sM4JQ==",
10
- "engines": {
11
- "node": ">=10.0.0"
12
- },
13
- "peerDependencies": {
14
- "bufferutil": "^4.0.1",
15
- "utf-8-validate": "^5.0.2"
16
- },
17
- "peerDependenciesMeta": {
18
- "bufferutil": {
19
- "optional": true
20
- },
21
- "utf-8-validate": {
22
- "optional": true
23
- }
24
- }
25
- }
26
- }
27
- }
1
+ {
2
+ "name": "isomorfeus-transport",
3
+ "lockfileVersion": 2,
4
+ "requires": true,
5
+ "packages": {
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==",
10
+ "engines": {
11
+ "node": ">=10.0.0"
12
+ },
13
+ "peerDependencies": {
14
+ "bufferutil": "^4.0.1",
15
+ "utf-8-validate": "^5.0.2"
16
+ },
17
+ "peerDependenciesMeta": {
18
+ "bufferutil": {
19
+ "optional": true
20
+ },
21
+ "utf-8-validate": {
22
+ "optional": true
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
@@ -1,19 +1,19 @@
1
- Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
1
+ Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.