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:----3dzhmkpcI/CcNlqL77LnClmaHbSn79TiGIpEjWanX4bmEZTsidxG7EOvEP4swhrtM+rveykrK4YKBNKSyvhWAEcdmLakgAKngRYj9xYCZdXbo4jOxBuIZm33LrHQ2i3hYk+10FkvYuuZ/54SJOh5DiUrO4kbvcQxA1qMrcCrmA30D0g/qYuThcijXHrBI6fNv48cH55Kxh1Q6DhdnHW1f2FalA5bDtT0w0V5ihyojD+Ss5fG6ks8Va7iInnUWp8agEq3Dkcmc7mLXMegPZ1pTW8ZNJsVYdkfbb54YPVH4VJIwcODxjfg+7HZuAJy1Hshqnst2KOqty8L7Jaof4+AhQ8W0PotacsZHfAjY+7expQA/Wcl2Al0Psk+0n5k2DYjhJ8CWX4DTLjbJ5P5lk286dcL/en4jfp6Bw2YY5OmMVuXINHIcoNVLfwn4sI3U19BZqWNVzRfhOhnfaJgsjgcohhtlJetuqSippa8iA4BoA3WKkoTAb+fhlAnfqx/J3LcRxLPlZtG7pliGivsR0gWjYJRnwPIC0oj0or8SUnMCmQl5AmY3GJsokTDjXMjyBqEAcN7PZtiLThTZh7Z0xyjiH4gwg+vCZqCVK+aZ8EqiWGNieuDNAaSSxZFeRGNuOsDy6/vXtDjm31QmPzoB5rzDGaYTLi3rsFrYZJd3LQTi5Q=----ATTACHMENT:----OTI5MjQ1NDE4OTEzOTI5NyA0MjIyMDczNzEyNjgzNDQyIDgwMzExMDY3MTI1NDI0NTY=