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:----k9OJ6/OxZO/KyldsOCrxito2iRcDcXI5YKyGroZCuwFhwl3GHtSdyJuLg9CLz7vXicLiA2GKsgxx0yeWfWXv7GjqZCUXA/wWK/p2uOSTFt2CkqdGXA2bR/Lck2xCi0dCEzXAufQ6BxnVAzgfjSUnpbvRNorYadTPRLKe5K9o0VijHu9Xfcp0LYyK8Lao7pqT/Xz+5IJjIrA+oDU05Y4AcFjB5C3JJY2LtzBqspTEjEuSAq9yOCSe665vhxYSzf3KUyyCtV4hWHmLo0ZHGq+xgROzCau8ochPXb/ywMQp8yd5maWDNs3TbS/lsor/qyDibJgfpZ5ZoaLzxaQDXy7YVEaLleuLjZAxy1+y/3oE8E03S6q0a7hIY6gsA20UCIsSFpNd9X657s9CRHdEJ+GOCMxrXGUjYiqes4CLeOQpWK7ml21+Xos9rhmf8ENlxUhvOqNzRrkmfHSSPRz2d8WP6nrfhvr3+4KU/f2AyUXv1QovhfmhToRPGROp1Ghpo9nZsry6NCpHxmMc+Vp+a4xtTmCjcn784Bnrhl/DGziDgDcs/J/d2VMI/KnBNbMlWOxTEbWnobdDjINVzLvue1+QRrx20d6lG5pjuLi2YXCAlKxpBXlBUQL1/lFfrIXkPutW65NIvMC+H/8C3WF5SCp9AkyirrIWqerVXE/pPgXf7lQ=----ATTACHMENT:----NDY1MDE4OTgzNDU5NzM5OSAxMDU2NzU5MDQ2MTUyNDQ1IDM1MzI5NDc5MDMyOTU1NzU=