def create_signature!(req, key_id:, algorithm:, headers: %w[date])
      signable_req = @adapter.call(req)

      headers = normalize_headers(headers)
      key = get_key(key_id)
      alg = get_algorithm(algorithm)
      string_for_signing = RequestSigning.make_string_for_signing(headers, signable_req)
      signature = alg.create_signature(key, string_for_signing)
      SignatureParameters.new(
        key_id:    key_id,
        algorithm: algorithm,
        headers:   headers,
        signature: encode_signature(signature)
      )
    end
def create_signature!(req, key_id:, algorithm:, headers: %w[date])
      signable_req = @adapter.call(req)

      headers = normalize_headers(headers)
      key = get_key(key_id)
      alg = get_algorithm(algorithm)
      string_for_signing = RequestSigning.make_string_for_signing(headers, signable_req)
      signature = alg.create_signature(key, string_for_signing)
      SignatureParameters.new(
        key_id:    key_id,
        algorithm: algorithm,
        headers:   headers,
        signature: encode_signature(signature)
      )
    end
@param adapter [Symbol] name of the library adapter.
 @param key_store [#fetch, #key?] signature verification key store

 @raise [RequestSigning::UnsupportedAdapter] when the adapter is not registered

 @see RequestSigning::Adapters
 @see RequestSigning::KeyStores::Static


 Creates a signature string

 @example
   keyId="hmac",algorithm="hmac-sha256",headers="date",signature="id0KmonZJTY53n+fk27Q5CtroeQ5UyRY/tbotiuhob4="

 @param req an http request object from the library specified via :adapter; see {RequestSigning::Adapters}
 @param key_id [String] key id to use for signing
 @param algorithm [String] algorithm to use for signing, e.g. `"rsa-sha256"`
 @param headers [Array<String>] headers to sign

   May include special `(request-target)` header.

   The recommendation is to sign:
   - for HTTPS requests - `["(request-target"), "host", "date"]`
   - for HTTP requests - all headers

   See {https://tools.ietf.org/html/draft-cavage-http-signatures-08#section-2.3}

 @return [String] signature components string. See example above.

 @raise [RequestSigning::KeyNotFound] when the key store does not contain the key
   referenced in the :key_id parameter
 @raise [RequestSigning::UnsupportedAlgorithm] when the algorithm referenced
   in :algorithm parameter is not supported
 @raise [RequestSigning::InvalidKey] when the key in key store can not be used
   to create the signature
 @raise [RequestSigning::HeaderNotInRequest] when one of the headers specified
   in `headers` signature component is not present in the request