Refactor environment variable handling and initialization

This commit is contained in:
netkas 2025-01-03 13:59:46 -05:00
parent 9b33890b10
commit 25dcf66755
4 changed files with 266 additions and 169 deletions

View file

@ -52,7 +52,7 @@
*/
public static function validatePublicEncryptionKey(string $publicKey): bool
{
if(!str_starts_with($publicKey, 'enc:'))
if(!str_starts_with($publicKey, self::KEY_TYPE_ENCRYPTION))
{
return false;
}
@ -112,12 +112,11 @@
*
* @param string $publicKey The base64-encoded public signing key to be validated.
* @return bool Returns true if the key is valid, or false if it is invalid.
* @throws CryptographyException If the public key is incorrectly formatted or its length is invalid.
*/
public static function validatePublicSigningKey(string $publicKey): bool
{
// Check if the key is prefixed with "sig:"
if (!str_starts_with($publicKey, 'sig:'))
if (!str_starts_with($publicKey, self::KEY_TYPE_SIGNING))
{
// If it doesn't start with "sig:", consider it invalid
return false;