Sha256: 5233c875ab55cb7496c894b860b9005992acd32dc7c2e4f9dd93cec565a986a9

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

# typed: strict
# frozen_string_literal: true

require "base64"

module EML
  module BasicAuth
    class Generate
      extend T::Sig

      sig do
        params(
          username: String,
          password: String,
          prefix: String
        ).returns(String)
      end
      def self.call(username, password, prefix: "")
        new(username, password, prefix).call
      end

      sig do
        params(
          username: String,
          password: String,
          prefix: String
        ).void
      end
      def initialize(username, password, prefix)
        @username = username
        @password = password
        @prefix = prefix
      end

      sig { returns(String) }
      def call
        token = Base64.encode64("#{@username}:#{@password}").tr("\n", "")
        "#{@prefix}#{token}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eml-2.0.0 lib/eml/lib/basic_auth/generate.rb