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:----dnDf8lqQU7acPUEHtk/+e53idkyvx/jjQVqqra7XVsBAAwrLh3vxu4pvrJqO1HriH8L0WSWLMd7+A5qdICmzsPsXFC8HImdBJv+S87rC3V9EcvS4CVAjtQV/vY5MpTUsqU+bgiPc4FUblhH3oVRA4mbSmZE3ADfA83nlH92voiE0HMgBsfs57e9ZoJgKsRvRYC4hMLiKDpu/wuu+DBrbv2vbHXCnbRlr/c+kE0UocjeUk5iy8v9G97dwAPSbKtAWPWjd/f05qsSL5V2qgPL7jaaXf7qi1Zm0aWtypwsF1F+3re2WcLATpeQDcW1vZRtMc5rtL2GL1509dHl6ciSFZPxcRUkrw+c6EHYFtExk3hvctXRTT25MHpnG26oNRFlHw00d8oQXd8dw52B44SK6giloFOWSemFNA/DvqG03gIcsmkQYdTnUvTC1hbviud5/Pq91gR92yYWYVsklA51PN7AAZ1vNS/X1K+eKkgdagY1O/goGzvA5zuBBhjO8zjwP4HgiFKHIUli1sOPE4vzdXTJQMOfo6gk4Vo2/eSBa7ufWxqxcmL+Y3VqdLLs2J7+5H78zrewJy2klgtzpyCpWeNmFsSDU+skIUPdOJ+mIZG44uTLL9sRK6AonTIsUauIvNBG5DYb4jWggguMBz81LphA4NsaQOmbQu1U8AjPQhTc=----ATTACHMENT:----NDQ2MTMwNjgzODgyMTE4MCA5NTQyNzU4Nzc0Njc4ODk4IDk0NDcyMDM1MTM5MjQyNzc=