Class: RippleToken::Token
- Inherits:
-
Object
- Object
- RippleToken::Token
- Defined in:
- lib/ripple_token/token.rb
Instance Method Summary collapse
- #decode(token) ⇒ Object
-
#initialize(public_key) ⇒ Token
constructor
A new instance of Token.
- #public_path?(method, path) ⇒ Boolean
Constructor Details
#initialize(public_key) ⇒ Token
Returns a new instance of Token.
5 6 7 |
# File 'lib/ripple_token/token.rb', line 5 def initialize(public_key) @public_key = public_key end |
Instance Method Details
#decode(token) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ripple_token/token.rb', line 9 def decode(token) decoded_token = JWT.decode(token, public_key, true, { algorithm: 'RS256' })[0] raise ExpiredTokenError if expired? decoded_token decoded_token rescue JWT::DecodeError => e raise TokenDecodeError, e. rescue JWT::ExpiredSignature => e raise ExpiredTokenError, e. end |