isomorfeus-transport 2.0.8 → 2.0.12

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: ab4b1f12d2e4f8f86744d97301bc46bc61eb9ada2bfbdfd0c67a153012ffe8c9
4
- data.tar.gz: d7681201d6ea58d69250d68afd1a3a85bd928ea06657df6f6568ae60e89bf251
3
+ metadata.gz: dfb989717bad2a539ded3af16503ed5f693636af32b333427743963072610113
4
+ data.tar.gz: 3bf8e1c7ed7647b81f19c738e4547ff2f04d04c4b0de217c645f46d3f108d484
5
5
  SHA512:
6
- metadata.gz: b724c1a8f0ff3db0e6dcf60c8fc6b651116b8603edd2d0b806f1f774c017652077abe7c49b63ef4e070b67559b4a0addf057fe4cc1d7eb20b521511d6dee9074
7
- data.tar.gz: ca3daa5c4de3b0c0a721bbe23bf9f5c5e7b1e288a57cf30e87ee119bfa945c08cb246cf9b392402804e998d945028b129adbc148d268784a1cb27a2cc05e5a8a
6
+ metadata.gz: e6371968f720d463006b807925dc1799f2de8ee8f68888c2c888bd9b81a5ef5f011d7f82f8d239508fba390fe965030e61ebe8230bfd994ffef12f1bb1c0173d
7
+ data.tar.gz: ba702e433883347fc630ac2c9ef916c69aaaa77b9c4834375c8e7fd640429f1167e38d296b9d20825b33b555a837b3561f956a534327918a5650a16a65a9378f
@@ -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.8'
3
+ VERSION = '2.0.12'
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.