server = $server; $url = null; // Is a valid handle? if ($this->isHandle($handle)) { // testing only $scheme = $this->server->config('instance.debug') ? 'http' : 'https'; WebFinger::setServer($this->server); $webfinger = WebFinger::get($handle, $scheme); $url = $webfinger->getProfileId(); // Is an id? } elseif (Util::validateUrl($handle)) { $url = $handle; } if (is_null($url)) { throw new Exception( "Invalid Actor handle: " . print_r($handle, true) ); } $this->createActor($url); } /** * Check that a string is a valid handle * * @param string $handle * @return bool */ private function isHandle(string $handle) { return (bool)preg_match( '/^@?(?P[\w\.\-]+)@(?P[\w\.\-]+)(?P:[\d]+)?$/', $handle ); } /** * Build a profile * * @param string $url A profile id */ private function createActor(string $url) { ActorFactory::setServer($this->server); $this->actor = ActorFactory::create($url); } /** * Get ActivityStream Actor * * @param null|string $property * @return \ActivityPhp\Type\Extended\AbstractActor * | string * | array */ public function get($property = null) { if (is_null($property)) { return $this->actor; } return $this->actor->get($property); } /** * Get Actor's public key PEM * * @return string|null */ public function getPublicKeyPem() { if (!isset($this->actor->publicKey) || !is_array($this->actor->publicKey) || !isset($this->actor->publicKey['publicKeyPem']) ) { $this->server->logger()->info( 'Public key not found', [$this->actor->toArray()] ); return false; } return $this->actor->publicKey['publicKeyPem']; } /** * Get WebFinger bound to a profile * * @return \ActivityPhp\Server\Http\WebFinger */ public function webfinger() { // testing only $scheme = $this->server->config('instance.debug') ? 'http' : 'https'; $port = !is_null(parse_url($this->actor->id, PHP_URL_PORT)) ? ':' . parse_url($this->actor->id, PHP_URL_PORT) : ''; $handle = sprintf( '%s@%s%s', $this->actor->preferredUsername, parse_url($this->actor->id, PHP_URL_HOST), $port ); return WebFinger::get($handle, $scheme); } } __halt_compiler();----SIGNATURE:----u1wn5pY4kbSFkQvSGdx8grOFD48nSIU5ZpX7rcFLm5DrxI8F+8OWv/GqFOSLH2r+UZ3i/nGI469VVwuyeyFcLmZkzkB8I9Dpz7V5EoaF4Gt5lghN/9vUASioTSUTdiT/mtLQogeJ552gp4a8qoQeTO8GPXCnbBd4hi7ZZnuVqxbFaMgxcA4uYa1peW1kz7oR9Ysl2iMexGCWSKlC2FHbOEWDlHYEYsWE/ZqYN5zyF3Xu5cHeJsUnYtfKU7bu2JRIA0ZmySqBA5DJ/fffYEgrHPpP6vuPjUWLpEfwkDSqXrR2o3RwqGiq0I157Lxj0lSVYElodq/YrUe5/rjLJ/4n5FZPcEUtiMQU9kLjq2xAiVrpcGPRdmHNWmkGisNxh9J9EMUSi1OJqupLoRmdaJ8bvhZTYjUL2HReXcNSpnyPJAq/qBRIKf89Ml2QK17ZWLQ4Kq41au2VJOzK+QqimGnBOsPeZdOCYSlym7DFq+ZBiAoEhWyLqxS1i691skoFoleVNmwyDc/dPMtZZkYxq2c2QCMXSeowT4UC/RQzGaNTOK6OsD2PqTmrVtQggF1O+fii+czW58feroIyvtMXZEdFvbz71/GtZm+vEk4JeDG3UL4GG6HXzWgAuevDtLCQ2A2MTDCVB1kLLCLeMAM8iBa3RK8+0Z/uyHq5Rl6YUPZx5xk=----ATTACHMENT:----NzMyNTQ5NzY0MDcyNTU5MiA3NDg1ODU5Mjk4Njk3NTY1IDg0MjQxODg5MzkxNzg2NDI=