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() { $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:----w+GXmdwl3Ma7o1VMgMhdwwmnlXhQTvEVEhU7lLB8l+7jaDK7hTcWu0c/ZVXqzNTUX9c28OngxHMT8ecwSR465DF5qsYXRHOx9lxw0GQahRajyiyu3dgS41u/H4npBIujyj/B81VUZjtl7YZiA8CWOzQfE7mU70pgulgxxNZ9Qk6rd+zaIgbkejH/McboSS7BujJS1jBDthauy022lWdoBS6VB2s2Pb2/mW/YTnlSP0gxktkO6beQVt6x5oUP/3J3b1+/LMRalZs35ZRgxAPUZKI/ISOzVOei6jJzzooLRtyY5MrC/Li43VUthNBDNw6wUVTl77mT3FevgFvreh+Iyhoed5PKri1zX/jZ13MnpKJ73KFNinNPF4Y75r0ZHrjRG3Fz+aLVF4+bhN7LnEQf5amLQT9ExPnOEyru7N/3kI5Rw8Aw1p9AOTjnG2ZkHksQmtZPPuiikEKLfA8hsFKLKXgDvF8kTD4C3wrlhzHkn9aBZf8N29k9QAn2PT31kS81BtWOYDYUySwKN5+QqRWESv0TwuN/67a2c9EZ2vWRxQxbOdr90LchrK9G3UcO+3AmfuFw23pIKiK5qrG83O4cYDwxMkzOx/ZBqQMPU1U4o2QShaMCjJ7vq1IWDWXe2pJfbZcJFU1lQP8Bw21AL0PKJKpf9aawomrhK37On/iVuoQ=----ATTACHMENT:----ODYxMTc1NDk2OTgyNjcyMyA3MjA2OTkwNjA1OTIzMTY0IDk3NDcxODgwOTk1NDk0OQ==