Sha256: 690805aadaf24f4a203f2b1c610a4413096f848bd27ac48f8b849f49ffd9a782

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

require "aws-sdk-kms"
require "jwt"

require_relative "kms/version"
require_relative "kms/hmac_key"
require_relative "kms/sign_verify_key"

module JWT
  # :nodoc:
  module Aws
    # :nodoc:
    module KMS
      def self.client
        @client ||= ::Aws::KMS::Client.new
      end

      def self.for(algorithm:)
        if HmacKey::MAPPINGS.key?(algorithm)
          HmacKey
        elsif SignVerifyKey::MAPPINGS.key?(algorithm)
          SignVerifyKey
        else
          raise ArgumentError, "Algorithm #{algorithm} not supported"
        end.new(algorithm: algorithm)
      end

      def self.replace_defaults!
        [HmacKey, SignVerifyKey].each do |type|
          type::MAPPINGS.each_key do |algorithm|
            type.register_algorithm(type.new(algorithm: algorithm))
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jwt-aws-kms-1.1.0 lib/jwt/aws/kms.rb