Class: Mobius::Client::Auth::Token
- Inherits:
-
Object
- Object
- Mobius::Client::Auth::Token
- Extended by:
- Dry::Initializer
- Defined in:
- lib/mobius/client/auth/token.rb
Overview
Checks challenge transaction signed by user on developer’s side.
Instance Method Summary collapse
-
#hash(format = :binary) ⇒ String
Transaction hash.
- #initialize(seed, xdr, address) ⇒ Object constructor
-
#time_bounds ⇒ Stellar::TimeBounds
Returns time bounds for given transaction.
-
#validate!(strict = true) ⇒ Boolean
Validates transaction signed by developer and user.
Constructor Details
#initialize(seed, xdr, address) ⇒ Object
10 |
# File 'lib/mobius/client/auth/token.rb', line 10 param :seed |
Instance Method Details
#hash(format = :binary) ⇒ String
Returns transaction hash.
43 44 45 46 47 48 |
# File 'lib/mobius/client/auth/token.rb', line 43 def hash(format = :binary) validate! # Guard! h = envelope.tx.hash return h if format == :binary h.unpack("H*").first end |
#time_bounds ⇒ Stellar::TimeBounds
Returns time bounds for given transaction.
19 20 21 22 23 24 25 26 |
# File 'lib/mobius/client/auth/token.rb', line 19 def time_bounds bounds = envelope.tx.time_bounds raise Mobius::Client::Error::Unauthorized unless signed_correctly? raise Mobius::Client::Error::MalformedTransaction if bounds.nil? bounds end |
#validate!(strict = true) ⇒ Boolean
Validates transaction signed by developer and user.
35 36 37 38 39 40 |
# File 'lib/mobius/client/auth/token.rb', line 35 def validate!(strict = true) bounds = time_bounds raise Mobius::Client::Error::TokenExpired unless time_now_covers?(bounds) raise Mobius::Client::Error::TokenTooOld if strict && too_old?(bounds) true end |