style updates

This commit is contained in:
Mark Gregory
2026-07-24 14:59:44 +01:00
parent 24ab771cd3
commit dd23205d0b
482 changed files with 7173 additions and 1435 deletions
@@ -1,16 +1,28 @@
<?php
namespace Modules\Marketplace\Services;
use RuntimeException;
final class PackageVerifier
{
public function verify(string $path,array $manifest,?string $expectedChecksum=null): array
public function verify(string $path, array $manifest, ?string $expectedChecksum = null): array
{
if (!is_file($path)) throw new RuntimeException("Package archive [$path] does not exist.");
$actual=hash_file('sha256',$path);
$expected=$expectedChecksum ?: ($manifest['checksum'] ?? null);
if (config('marketplace.require_checksum',true) && blank($expected)) throw new RuntimeException('A SHA-256 checksum is required.');
if (filled($expected) && !hash_equals(strtolower((string)$expected),strtolower($actual))) throw new RuntimeException('Package checksum verification failed.');
if (config('marketplace.require_signature',false) && blank($manifest['signature'] ?? null)) throw new RuntimeException('A package signature is required.');
return ['verified'=>true,'checksum'=>$actual,'signature_present'=>filled($manifest['signature'] ?? null)];
if (! is_file($path)) {
throw new RuntimeException("Package archive [$path] does not exist.");
}
$actual = hash_file('sha256', $path);
$expected = $expectedChecksum ?: ($manifest['checksum'] ?? null);
if (config('marketplace.require_checksum', true) && blank($expected)) {
throw new RuntimeException('A SHA-256 checksum is required.');
}
if (filled($expected) && ! hash_equals(strtolower((string) $expected), strtolower($actual))) {
throw new RuntimeException('Package checksum verification failed.');
}
if (config('marketplace.require_signature', false) && blank($manifest['signature'] ?? null)) {
throw new RuntimeException('A package signature is required.');
}
return ['verified' => true, 'checksum' => $actual, 'signature_present' => filled($manifest['signature'] ?? null)];
}
}