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:----Uc6FhpgRk7G3niSwe+KnpwosrxdrlpQbvzWMxR3VX71F/Fmh4nbpSNDhfLmqx1VQzoXdGRtqbCrNLl8Rbk0BbwEkq2W6FS755wOiCXZYwy/CMGsbggpn8p2vR5cncfqE5e/x215EImd2KifTJNMS+5HVgnDDlbqxMnh+yZMb7x2XpSOg94oxbMm1VhYoOsXPY3avvV20rSGRySiHHOZyOkw6eIByFUMfL7gfqT2Yt5RcEe9U+3xJY1a8JP2tJ8o++FPThru+RRGHPUENpKOS5S82tEZiuJBBYuvHf9U1TO4eFn5eAhfBUsH3Ae2KvFLqX6nPDYeHyIXptCg8a3vkH8wWWxhSj81KdbIxIh95riEGnhCTYJoIrfqh4TWnEzPNQf+AD2o/FM+Ds9dbCHNDwpqPAc+7+B59reO2z0yBA+G63wDeVEp03yZON62jwTzjtlmMvHJzBjlPdeyPS5FfhTJkPah4f7dYsEkAPbI/jiMw9+wtFldRFdYdwl9mwf4bNyD9lDD4JoWAh9i8gwFJsWlapKwPsvjBIk3Oe/Ac5ljEerSczioSMpV5YXBODH1FAM4mPV3s43wCEqJCHLLis41TTNWqRq1u5gx+BI4VglZZkobwZ71fStAxDazoJkhtbUo4o8kjOxqehv47fWyh2bpVPJYFFs9oQ95qKr62cOc=----ATTACHMENT:----NjEzNDI0MzU0NjAzMjc1MSAzNjMzNzE2NjIwNjA3NSAzOTQwNzU3MzcyMzYwNzYz