class HTTPSignature
{
// See draft-cavage-http-signatures-08
+ /**
+ * @brief Verifies a magic request
+ *
+ * @param $key
+ *
+ * @return array with verification data
+ */
public static function verifyMagic($key)
{
$headers = null;
* Functions for ActivityPub
*/
+ /**
+ * @brief Transmit given data to a target for a user
+ *
+ * @param $data
+ * @param $target
+ * @param $uid
+ */
public static function transmit($data, $target, $uid)
{
$owner = User::getOwnerDataById($uid);
logger('Transmit to ' . $target . ' returned ' . $return_code);
}
+ /**
+ * @brief Gets a signer from a given HTTP request
+ *
+ * @param $content
+ * @param $http_headers
+ *
+ * @return signer string
+ */
public static function getSigner($content, $http_headers)
{
$object = json_decode($content, true);
return $key['url'];
}
+ /**
+ * @brief fetches a key for a given id and actor
+ *
+ * @param $id
+ * @param $actor
+ *
+ * @return array with actor url and public key
+ */
private static function fetchKey($id, $actor)
{
$url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id);
*/
class JsonLD
{
+ /**
+ * @brief Loader for LD-JSON validation
+ *
+ * @param $url
+ *
+ * @return the loaded data
+ */
public static function documentLoader($url)
{
$recursion = 0;
return $data;
}
+ /**
+ * @brief Normalises a given JSON array
+ *
+ * @param array $json
+ *
+ * @return normalized JSON string
+ */
public static function normalize($json)
{
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
return jsonld_normalize($jsonobj, array('algorithm' => 'URDNA2015', 'format' => 'application/nquads'));
}
+ /**
+ * @brief Compacts a given JSON array
+ *
+ * @param array $json
+ *
+ * @return comacted JSON array
+ */
public static function compact($json)
{
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
}
+ /**
+ * @brief Fetches an element from a JSON array
+ *
+ * @param $array
+ * @param $element
+ * @param $key
+ * @param $type
+ * @param $type_value
+ *
+ * @return fetched element
+ */
public static function fetchElement($array, $element, $key, $type = null, $type_value = null)
{
if (empty($array)) {