protected function getPackageMetadata(string $type, string $supplier, string $pkg) : array
{
$state = State::instance();
if (IDE_HACKS) {
$state->hail = new Hail(new Client());
}
$channels = \Airship\loadJSON(ROOT . "/config/channels.json");
$ch = $state->universal['airship']['trusted-supplier'] ?? 'paragonie';
if (empty($channels[$ch])) {
return [];
}
$publicKey = new SignaturePublicKey(\Sodium\hex2bin($channels[$ch]['publickey']));
foreach ($channels[$ch]['urls'] as $url) {
try {
$response = $state->hail->postSignedJSON($url, $publicKey, ['type' => $type, 'supplier' => $supplier, 'name' => $pkg]);
} catch (NoAPIResponse $ex) {
// Continue
}
}
if (empty($response)) {
return [];
}
if ($response['status'] !== 'success') {
return [];
}
return $response['packageMetadata'];
}