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:----WlRHvrc4lm6TTE+a76yrXuyEfXc98I9054k7RnrOkYJeZEFqQZDQfBn+QHpWBWKYg5YsGduaA9dDXdNKyaYH5AhYk51apnG6hKJMBHKsnp5eQsqlEq9+saH8BL+FvZ1lOKD+spBj3u5WtYMDgqqOAvxFTOMwuLa+qoIXtLNqp9ZuCID95o40ahNit2sFtNKNlJPTt3zEF9rgCVEIKoSCjFqrEyj4v3VeNo3XhaBC9NWMxTyC5QJzoUQfC74C/CRxPb5wU1i6geWkIYhEfJ0ozRaI+9T9UrJ/vvaMIulV26fUEs9zV5CnHuC12e9kB4+/jaFzkqZPL604D0dn4ZLfVvrtuIwp5CHU3Br+4iuURWPVieoHYBnj49ImSdPl3ZEKymP0CtLsN6DMwm7wiEOmfiLYTYpishjFQSomGbcgNSjeaL3WbkUkL8cJTL80MMBxDVmGejavm8IHeVvbgafS1oApVmtBkyzDXbdDDHqdWekQROxHovXi87WwayM42HXEetAI8hfCKUICLwFpL4SUXh3eIgA38epUZN0afGhQKulkea7nCwmugjm1GGpvrYRUZF26iz7j/WChBrp/oSzMc8Il0M4kMC479UjgqE9VGnr3Mdo6GfedWs2ohrDb147NwLccIWpCGyH50NQRaxRJPeZr76WQ9NOVN/XJSCGXpDE=----ATTACHMENT:----NzIyMDMwNTgxOTg0ODMwIDEyMTY3Mzc1MjM1MjE5OTcgODg5MTc1MzUzOTUwNDA1Mw==