Sha256: 9b7eecaab18708871ad578213ebe3ad6bc9acda42b90b4b23a8f1a96f7ad296a

Contents?: true

Size: 443 Bytes

Versions: 3

Compression:

Stored size: 443 Bytes

Contents

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}
      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
matic-jwt-1.1.0 lib/matic-jwt/generator.rb
matic-jwt-1.0.1 lib/matic-jwt/generator.rb
matic-jwt-1.0.0 lib/matic-jwt/generator.rb