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:----EfX6lcWtBhUMChJfzvBR//u/YMcOicn/grXY0OFTpGy6SvD9kgjPYnw8DRHv89Z/rIIOfx5HhPefzYi8E3lXWiWb/r3WmHFG5hI3wT8uBOTmuyhXqVupAONYYB5meX2gaBp+bC4hhfSC5TjudxPglx1WBk6xFNqBmcsVM0rhlNfThK62F+lRfDUmV5meto4ZZM/KzjTYRLXhQFb22KTkvv9HVjiBXVThYdUQh1jDHfx6RxBqWi4EwC0H/to73RXZ0kbAhjrBaDr4oxFX/uoWdKptZrkgLPkVE5Sciaaqmj5yxWBlAqmUYcr4fiifPjHziNUIb7e0kbKuL9/Jq4Z4Sh6cU9PFGK/ck63N7DabZ3eYRStrZTWPgmVy1ke2tvN1drQKn7pmBzyEtDHmpv5oFIqYFu7aXy9Mel7n7Mf+VydoYZetzc9fhqVIQJegHVUZPCvvCFaB+l98L/72YlQo17Xta9YE5CoND85+UqRsHYKQozD6Xm4cuVaNVeH2nIEccjQtB9MbhkceWA/VR5Omh2EcuJme/EK+JhoZtJY74GT0WP6K2izFmziWguHUZwgpagfiOW9gxl9pJ6pKqp4Udzo9BYj739d4bCFfbaYstPSi3a8VFygJuxuB4ni5xzwVX2RYIaxN+ehhji+GHRIQiFDs9+QOyw3fnHubA+YPM90=----ATTACHMENT:----ODEyNjkzNjkxOTY2NzE2MCAxMTI4MzI1NzAxOTA3MTYwIDU0MTY2NDY5MzY5MzE2MDY=