3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\WellKnown;
24 use Friendica\BaseModule;
25 use Friendica\Core\System;
27 use Friendica\Module\Response;
28 use Friendica\Protocol\Salmon;
29 use Friendica\Util\Crypto;
30 use Friendica\Util\XML;
33 * Prints the metadata for describing this host
34 * @see https://tools.ietf.org/html/rfc6415
36 class HostMeta extends BaseModule
38 protected function rawContent(array $request = [])
40 $config = DI::config();
42 if (!$config->get('system', 'site_pubkey', false)) {
43 $res = Crypto::newKeypair(1024);
45 $config->set('system', 'site_prvkey', $res['prvkey']);
46 $config->set('system', 'site_pubkey', $res['pubkey']);
49 $domain = DI::baseUrl()->get();
55 'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
57 'hm:Host' => DI::baseUrl()->getHostname(),
61 'type' => 'application/xrd+xml',
62 'template' => $domain . '/xrd?uri={uri}'
68 'type' => 'application/json',
69 'template' => $domain . '/.well-known/webfinger?resource={uri}'
75 'href' => $domain . '/amcd'
80 'rel' => 'http://services.mozilla.com/amcd/0.1',
81 'href' => $domain . '/amcd'
86 'rel' => 'http://oexchange.org/spec/0.8/rel/resident-target',
87 'type' => 'application/xrd+xml',
88 'href' => $domain . '/oexchange/xrd'
93 'type' => 'http://salmon-protocol.org/ns/magic-key',
96 Salmon::salmonKey($config->get('system', 'site_pubkey'))
99 ], $xml, false, ['hm' => 'http://host-meta.net/xrd/1.0', 'mk' => 'http://salmon-protocol.org/ns/magic-key']);
101 System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');