class JSON::JWT

def decode_json_serialized(input, key_or_secret, algorithms = nil, encryption_methods = nil, allow_blank_payload = false)

def decode_json_serialized(input, key_or_secret, algorithms = nil, encryption_methods = nil, allow_blank_payload = false)
  input = input.with_indifferent_access
  if (input[:signatures] || input[:signature]).present?
    JWS.decode_json_serialized input, key_or_secret, algorithms, allow_blank_payload
  elsif input[:ciphertext].present?
    JWE.decode_json_serialized input, key_or_secret, algorithms, encryption_methods
  else
    raise InvalidFormat.new("Unexpected JOSE JSON Serialization Format.")
  end
end