Sha256: 4fbec74d0d97eadc37a31514d730aa40dd30b0a50c77d843cd7c847225d6ec51

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

require 'jwt'
require 'time'

module AsyncRequest
  class JsonWebToken
    def self.encode(job_id, expiration = AsyncRequest.config[:token_expiration].to_i)
      JWT.encode(
        {
          job_id: job_id,
          expires_in: (Time.zone.now + expiration).to_i
        },
        AsyncRequest.config[:encode_key],
        AsyncRequest.config[:sign_algorithm]
      )
    end

    def self.decode(token)
      JWT.decode(
        token,
        AsyncRequest.config[:decode_key],
        true,
        algorithm: AsyncRequest.config[:sign_algorithm]
      ).first
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
async_request-1.0.0 app/poros/async_request/json_web_token.rb