lib/matic-jwt/generator.rb in matic-jwt-0.3.0 vs lib/matic-jwt/generator.rb in matic-jwt-1.0.0

- old
+ new

@@ -1,8 +1,17 @@ module MaticJWT class Generator + def initialize(expiration: EXPIRATION) + @expiration = expiration + end + def token_for(client_name, secret) - payload = {client_name: client_name, exp: EXPIRATION.since.to_i} + payload = {client_name: client_name, exp: @expiration.since.to_i} JWT.encode(payload, secret, ALGORITHM) + end + + def authentication_header_for(client_name, secret, scheme: SCHEME) + token = token_for(client_name, secret) + "#{scheme} #{token}" end end end