mobius-client 0.4.0 → 0.5.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
  SHA1:
3
- metadata.gz: bb3a779d514fea2f8482f7843d4c2e78ce01902a
4
- data.tar.gz: bf92f3da028fc789bb158f81318239d66ee84add
3
+ metadata.gz: a684d298e256ef48ac6444bf5c5332d916782599
4
+ data.tar.gz: ea6423937edabcb334ae694050c9d801307119c3
5
5
  SHA512:
6
- metadata.gz: 7f6a32e7302f77b8530e6b8f79ef84091cf69ff1902721f928bbb1392227fef2a18d9563250fb178062359e0788f97d082de26d670aa7edf485c0d476afa9794
7
- data.tar.gz: b6af2c669c2a6311fe6a5ddadf55a78a9eb98d33938dd720cbdbb5d0f715b1de4320fd02a5bc7a9496e98e9921b9a7e13acadcee72fc82cba8e410540a633ed8
6
+ metadata.gz: c1b6871824d70a6145b64dc602cee22f4056e7d66c815ac7eaffbb559ebeb5821def7c8651b69484259b11a518e629313c743ceb7fdb7484f8a7f00fa15e6809
7
+ data.tar.gz: 9d5fc04dbf0a28ced1639082be72426c444e4386cefb9c2c750ea9e2079caa774e45ce2fcf16b3721c3043a73ab159b15cac4f96e52b5a76f809d446a911def4
data/README.md CHANGED
@@ -194,13 +194,13 @@ class AppController < ApplicationController
194
194
 
195
195
  # GET /balance
196
196
  def balance
197
- render plain: app.balance
197
+ render plain: app.user_balance
198
198
  end
199
199
 
200
200
  # POST /charge
201
201
  def charge
202
202
  app.charge(ROUND_PRICE)
203
- render plain: app.balance
203
+ render plain: app.user_balance
204
204
  rescue Mobius::Client::Error::InsufficientFunds
205
205
  render :gone
206
206
  end
@@ -56,7 +56,7 @@ class Mobius::Client::App
56
56
  def charge(amount, target_address: nil)
57
57
  amount = cast_amount(amount)
58
58
 
59
- raise Mobius::Client::Error::InsufficientFunds if balance < amount
59
+ raise Mobius::Client::Error::InsufficientFunds if user_balance < amount
60
60
 
61
61
  submit_tx do |operations|
62
62
  operations << payment_op(amount, dest: app_keypair, src: user_keypair)
@@ -10,13 +10,13 @@ class Mobius::Client::Auth::Jwt
10
10
  # Returns JWT token.
11
11
  # @param token [Mobius::Client::Auth::Token] Valid auth token
12
12
  # @return [String] JWT token
13
- def encode(token)
13
+ def encode(token, options = {})
14
14
  payload = {
15
- hash: token.hash(:hex),
16
- public_key: token.address,
17
- min_time: token.time_bounds.min_time,
18
- max_time: token.time_bounds.max_time
19
- }
15
+ jti: token.hash(:hex),
16
+ sub: token.address,
17
+ iat: token.time_bounds.min_time,
18
+ exp: token.time_bounds.max_time
19
+ }.merge(options)
20
20
 
21
21
  JWT.encode(payload, secret, ALG)
22
22
  end
@@ -25,11 +25,9 @@ class Mobius::Client::Auth::Jwt
25
25
  # @param jwt [String] JWT token
26
26
  # @return [Hash] Decoded token params
27
27
  def decode!(jwt)
28
- OpenStruct.new(
29
- JWT.decode(jwt, secret, true, algorithm: ALG).first
30
- ).tap do |payload|
31
- raise TokenExpired unless (payload.min_time..payload.max_time).cover?(Time.now.to_i)
32
- end
28
+ OpenStruct.new(JWT.decode(jwt, secret, true, algorithm: ALG).first)
29
+ rescue JWT::ExpiredSignature => _
30
+ raise TokenExpired
33
31
  end
34
32
 
35
33
  # Used JWT algorithm
@@ -1,5 +1,5 @@
1
1
  module Mobius
2
2
  module Client
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.5.0".freeze
4
4
  end
5
5
  end
data/lib/mobius/client.rb CHANGED
@@ -9,8 +9,6 @@ require "jwt"
9
9
 
10
10
  require "mobius/client/version"
11
11
 
12
- require "pry-byebug" rescue LoadError
13
-
14
12
  module Mobius
15
13
  module Cli
16
14
  autoload :Base, "mobius/cli/base"
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler", "~> 1.16"
29
29
  spec.add_development_dependency "bundler-audit", "~> 0.6.0"
30
30
  spec.add_development_dependency "httplog", "~> 1.0", ">= 1.0.2"
31
- spec.add_development_dependency "pry-byebug"
32
31
  spec.add_development_dependency "rake", "~> 12.0"
33
32
  spec.add_development_dependency "rspec", "~> 3.0"
34
33
  spec.add_development_dependency "rubocop", "~> 0.53"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobius-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sokolov
@@ -58,20 +58,6 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 1.0.2
61
- - !ruby/object:Gem::Dependency
62
- name: pry-byebug
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
61
  - !ruby/object:Gem::Dependency
76
62
  name: rake
77
63
  requirement: !ruby/object:Gem::Requirement