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:----ZZGChX1AGhQKp5yL1QLyvArEITD3o3TOsK7E4N50VA/KoxNp28klsUDPxVblopIelqtwYnLU/T33hFc3W1P6cKcUHrddNbPVZtc/hSXjf0MWm9l1N508u8SrCS/8BzRYhjLOLGP3Nu1Nhh7Wg0nwPLxQlw8npAzYIlSxpnaYRDPQ1e7Kk/QcK4vaVNDsU6c1ITLx/EhN/VQ2xxTerKuglshIHTmzf2WWucLmoBeEgsiAr4ReYNhO4dPEBnRCyshukh9PsUe2Pp9f2bFfqlyTSFiYKLrUmqHV7hPqQk55Bbufp+xD1DME1ho6SKRmJ6orU8qCn02U8fnilXhqSnehO0GpYDhIk89g8hLvrHpEMJqOdxOFZDtoXWqegtOaDqe++rKN8DCKR+K4Z8IJwXdpyqW2q8m654xJ2Nsyqw5/ENK1lBXKlSj38veRZqb5KhZNnTIG0h6VnSyZoKChjFZdCrh9W2IN9LIARqdPLDimCF4OPdWsZO0d965gjKfJED05pYqgbN8xaJnlGrwU69f+gW9qFZAiUKkL33a80PBifOfv0HlZ8CzP8gDrN4IlI0O1kCqY8CVe6ryDNNOkseFtlic7KqjbOvVGt3v2hG11mcofa+pzbcLTjfvs//gJ5Rb/4HnOahZTgn9HVewASfYfSKQos+GICoDWpJNX5H+tPag=----ATTACHMENT:----NjUwMTc1MTI0MjAyODUwMCA5NTY0MDA3OTkyMTA1NjYwIDUwOTYzMzQ5ODA3NTk4NDA=