peatio1.9 0.4.5 → 0.4.6

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: 9c27f83d3d8bcd476b619d1935c563452c4b7290300907326c651d4a24bcc0b0
4
- data.tar.gz: 45a725ae726b661d0a787db208a03b02864c3079863ba4aa5516fa339d3cfede
3
+ metadata.gz: 0f5ab1f88fc0487521a71471f00c2e28b177bc238369d21a4d8db06972510fa5
4
+ data.tar.gz: c23b852b70ec0d82262933657f16a940c1fed3427e56e6cd1205a4d7611cdc54
5
5
  SHA512:
6
- metadata.gz: ef2e5cea2866ffc70d4fb0498da9ba8d26ad3120f9dac860f7a8402c93d37fe4d176eee0f485a1923b73ba938636f951d70844bf284df02143f306e526a99a80
7
- data.tar.gz: 76aaf1deab676935b9ebb52a81966682963497c17ea7010d8aed09ae92259fbcec94717e6e5b604162f943d826c792a1751eae023853561752ba8b63070d01c1
6
+ metadata.gz: 9aae070516e3960bd77c929730776e6530e1b9fab4bb069b820ff12cd4c3a0a476efc6fbf2044fe682284c0703f2ae3b2250e87dc17ae1604b60b0cf5d2e7ff5
7
+ data.tar.gz: 0341c2e90e7c00d647e41c4419d4c6889e2d8e237d89d57933a586737924ff86ba85c5319c0a62bc37d4c6bd19444965e695fe5c8682896a51e28252abac9f75
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio1.9 (0.4.5)
4
+ peatio1.9 (0.4.6)
5
5
  amqp
6
6
  bunny
7
7
  clamp
@@ -115,13 +115,14 @@ module Peatio::Auth
115
115
  private
116
116
 
117
117
  def decode_and_verify_token(token)
118
+ p JWT.decode(token, @public_key, false, @verify_options), Time.now.to_i
118
119
  payload, header = JWT.decode(token, @public_key, true, @verify_options)
119
120
 
120
121
  payload.keys.each { |k| payload[k.to_sym] = payload.delete(k) }
121
122
 
122
123
  payload
123
124
  rescue JWT::DecodeError => e
124
- raise(Peatio::Auth::Error, "Failed to decode and verify JWT")
125
+ raise(Peatio::Auth::Error, "Failed to decode and verify JWT: #{e.message}")
125
126
  end
126
127
  end
127
128
  end
@@ -34,9 +34,8 @@ module Peatio::Ranger
34
34
  send :success, message: "unsubscribed", streams: @client.streams.keys
35
35
  end
36
36
 
37
- def authenticate(jwt)
37
+ def authenticate(token)
38
38
  begin
39
- token = data["jwt"]
40
39
  payload = @authenticator.authenticate!(token)
41
40
  authorized = true
42
41
  rescue => error
@@ -78,21 +77,13 @@ module Peatio::Ranger
78
77
  def handshake(hs)
79
78
  @client = Peatio::MQ::Events::Client.new(@socket)
80
79
  query = URI::decode_www_form(hs.query_string)
81
- subscribe(query.map {|item| item.last if item.first == "stream"})
80
+ subscribe(query.map { |item| item.last if item.first == "stream" })
82
81
  @logger.info "ranger: WebSocket connection openned"
83
82
 
84
83
  if hs.headers_downcased.key?("authorization")
85
- authorized, payload = authenticate(hs.headers["authorization"])
86
-
87
- if !authorized
88
- @logger.info "ranger: #{@client.user} authentication failed"
89
- raise EM::WebSocket::HandshakeError, "Authorization failed"
90
- else
91
- @logger.info [authorized, payload].inspect
92
- @client.user = payload[:uid]
93
- @client.authorized = true
94
- @logger.info "ranger: user #{@client.user} authenticated #{@client.streams}"
95
- end
84
+ authenticate(hs.headers["authorization"])
85
+
86
+ @logger.info "ranger: user #{@client.user} authenticated #{@client.streams}"
96
87
  end
97
88
  end
98
89
  end
@@ -114,9 +105,9 @@ module Peatio::Ranger
114
105
  Peatio::MQ::Events.subscribe!
115
106
 
116
107
  EM::WebSocket.start(
117
- host: host,
118
- port: port,
119
- secure: false,
108
+ host: host,
109
+ port: port,
110
+ secure: false,
120
111
  ) do |socket|
121
112
  connection = Connection.new(authenticator, socket, logger)
122
113
 
@@ -1,3 +1,3 @@
1
1
  module Peatio
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peatio1.9
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - topdev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp