Sha256: c3efc674f18da613267cb330d72699a5d140daadea53d0326ebf8a8158830d20

Contents?: true

Size: 660 Bytes

Versions: 4

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

require 'base64'
require 'drillbit/tokens/base64s/null'
require 'drillbit/tokens/base64s/invalid'

module  Drillbit
module  Tokens
class   Base64
  attr_accessor :token

  def initialize(token:)
    self.token = token
  end

  def valid?
    true
  end

  def blank?
    false
  end

  def to_h
    [
      {
        'token' => token,
      },
      {
        'typ' => 'base64',
      },
    ]
  end

  def self.convert(raw_token:)
    return Base64s::Null.instance if raw_token.to_s == ''

    ::Base64.strict_decode64(raw_token)

    new(token: raw_token)
  rescue ArgumentError
    Base64s::Invalid.instance
  end
end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
drillbit-3.0.3 lib/drillbit/tokens/base64.rb
drillbit-3.0.2 lib/drillbit/tokens/base64.rb
drillbit-3.0.1 lib/drillbit/tokens/base64.rb
drillbit-3.0.0 lib/drillbit/tokens/base64.rb