Airship\Engine\Hail::getSignedJSON PHP Method

getSignedJSON() public method

Internally verifies an Ed25519 signature.
public getSignedJSON ( string $url, SignaturePublicKey $publicKey, array $params = [] ) : mixed
$url string
$publicKey SignaturePublicKey
$params array
return mixed
    public function getSignedJSON(string $url, SignaturePublicKey $publicKey, array $params = [])
    {
        $response = $this->client->get($url, $this->params($params, $url));
        if ($response instanceof Response) {
            return $this->parseSignedJSON($response, $publicKey);
        }
        return null;
    }

Usage Example

Example #1
0
 /**
  * Fetch all of the updates from the remote server.
  *
  * @param Channel $chan
  * @param string $url
  * @param string $root Which Merkle root are we starting at?
  * @return TreeUpdate[]
  */
 protected function fetchTreeUpdates(Channel $chan, string $url, string $root) : array
 {
     try {
         return $this->parseTreeUpdateResponse($chan, $this->hail->getSignedJSON($url . API::get('fetch_keys') . '/' . $root, $chan->getPublicKey()));
     } catch (SignatureFailed $ex) {
         $state = State::instance();
         if (IDE_HACKS) {
             $state->logger = new Ledger();
         }
         $state->logger->alert('Signature failed!', \Airship\throwableToArray($ex));
     }
     return [];
 }