public function createSymmetricAuthenticatedRequest(
        string $method,
        string $uri,
        string $body,
        SharedAuthenticationKey $key,
        array $headers = []
    ): RequestInterface {
        /** @var array<string, array<int|string, string>> $headers */
        $mac = \ParagonIE_Sodium_Compat::crypto_auth($body, $key->getString(true));
        if (isset($headers[Sapient::HEADER_SIGNATURE_NAME])) {
            $headers[Sapient::HEADER_AUTH_NAME][] = Base64UrlSafe::encode($mac);
        } else {
            $headers[Sapient::HEADER_AUTH_NAME] = Base64UrlSafe::encode($mac);
        }
        return new Request(
            $method,
            $uri,
            $headers,
            $body
        );
    }
public function createSymmetricAuthenticatedRequest(
        string $method,
        string $uri,
        string $body,
        SharedAuthenticationKey $key,
        array $headers = []
    ): RequestInterface {
        /** @var array<string, array<int|string, string>> $headers */
        $mac = \ParagonIE_Sodium_Compat::crypto_auth($body, $key->getString(true));
        if (isset($headers[Sapient::HEADER_SIGNATURE_NAME])) {
            $headers[Sapient::HEADER_AUTH_NAME][] = Base64UrlSafe::encode($mac);
        } else {
            $headers[Sapient::HEADER_AUTH_NAME] = Base64UrlSafe::encode($mac);
        }
        return new Request(
            $method,
            $uri,
            $headers,
            $body
        );
    }
public function createSymmetricAuthenticatedRequest ( string $ method , string $ uri , string $ body , SharedAuthenticationKey $ key , array $ headers = [ ] ) : RequestInterface { /** @var array<string, array<int|string, string>> $headers */ $ mac = \ ParagonIE_Sodium_Compat :: crypto_auth ( $ body , $ key -> getString ( true ) ) ; if ( isset ( $ headers [ Sapient :: HEADER_SIGNATURE_NAME ] ) ) { $ headers [ Sapient :: HEADER_AUTH_NAME ] [ ] = Base64UrlSafe :: encode ( $ mac ) ; } else { $ headers [ Sapient :: HEADER_AUTH_NAME ] = Base64UrlSafe :: encode ( $ mac ) ; } return new Request ( $ method , $ uri , $ headers , $ body ) ; }
Authenticate your HTTP request with a pre-shared key.

@param string $method
@param string $uri
@param string $body
@param SharedAuthenticationKey $key
@param array $headers
@return RequestInterface
Authenticate your HTTP request with a pre - shared key .