Class: LightJWT::JWT

Inherits:
Object
  • Object
show all
Defined in:
lib/light_jwt/jwt.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(claims = {}) ⇒ JWT

Returns a new instance of JWT.



39
40
41
# File 'lib/light_jwt/jwt.rb', line 39

def initialize(claims = {})
  @claims = claims
end

Instance Attribute Details

#claimsObject

Returns the value of attribute claims.



5
6
7
# File 'lib/light_jwt/jwt.rb', line 5

def claims
  @claims
end

Class Method Details

.decode(input, key_or_options = {}) ⇒ Object



8
9
10
11
12
# File 'lib/light_jwt/jwt.rb', line 8

def decode(input, key_or_options = {})
  key, options = parse_key_and_options(key_or_options)
  handler = handler_for(input)
  handler.decode(input, key, options)
end

Instance Method Details

#encrypt(alg, enc, public_key) ⇒ Object



47
48
49
# File 'lib/light_jwt/jwt.rb', line 47

def encrypt(alg, enc, public_key)
  JWEHandler.new.encrypt(claims, alg, enc, public_key)
end

#sign(alg, signing_key) ⇒ Object



43
44
45
# File 'lib/light_jwt/jwt.rb', line 43

def sign(alg, signing_key)
  JWSHandler.new.sign(claims, alg, signing_key)
end