From 784175fe9bfd5bdb07dff50963dd181d79f56ecc Mon Sep 17 00:00:00 2001 From: insxa Date: Thu, 26 Nov 2026 20:04:17 +0100 Subject: [PATCH 1/7] Enhance Subreg adapter for WHOIS privacy support Updated Subreg adapter to support WHOIS privacy and EPP-code email requests. --- src/library/Registrar/Adapter/Subreg.php | 43 ++++++++++++++++++------ 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/library/Registrar/Adapter/Subreg.php b/src/library/Registrar/Adapter/Subreg.php index 5eeb20ca5..ef1603b3e 100644 --- a/src/library/Registrar/Adapter/Subreg.php +++ b/src/library/Registrar/Adapter/Subreg.php @@ -11,7 +11,7 @@ * * Uses the Subreg SOAP API (non-WSDL, needs the PHP soap extension): Login gives a session token (ssid) that every * other call carries; registrations, transfers, renewals and changes are Make_Order orders. Test mode sends every call - * to the Subreg OT&E system (demoreg.net), never to the live registry. Privacy protection is not supported. + * to the Subreg OT&E system (demoreg.net), never to the live registry. Supports WHOIS privacy and EPP-code email requests. */ class Registrar_Adapter_Subreg extends Registrar_AdapterAbstract implements Registrar_TldPrices, Registrar_TransferStatus { @@ -38,13 +38,13 @@ public function __construct($options) public static function getUnsupportedActions(): array { - return ['enablePrivacyProtection', 'disablePrivacyProtection']; + return []; } public static function getConfig(): array { return [ - 'label' => __trans('Registers and manages domains through your Subreg.CZ account over the Subreg API (needs the PHP soap extension). Test mode sends every call to the Subreg OT&E test system (demoreg.net) instead of the live registry. Privacy protection is not supported.'), + 'label' => __trans('Registers and manages domains through your Subreg.CZ account over the Subreg API (needs the PHP soap extension). Test mode sends every call to the Subreg OT&E test system (demoreg.net) instead of the live registry. Supports WHOIS privacy protection and emailing the EPP transfer code to the domain contact.'), 'form' => [ 'login' => ['text', [ 'label' => __trans('Username'), @@ -174,14 +174,22 @@ public function modifyContact(Registrar_Domain $domain): bool return true; } + /** + * Subreg may redact authid in Info_Domain. SendAuthID_Domain requests that Subreg + * email the actual transfer code to the domain's registered contact. + * + * ClientFence expects getEpp() to return a string, so return a confirmation message + * after the Make_Order request succeeds; do not return the redacted authid value. + */ public function getEpp(Registrar_Domain $domain): string { - $code = trim((string) ($this->info($domain)['authid'] ?? '')); - if ($code === '') { - throw new Registrar_Exception('The transfer code could not be retrieved automatically. Please contact support to receive it.'); - } + $this->order($domain, 'SendAuthID_Domain', [ + 'params' => [ + 'whmcs' => 1, + ], + ]); - return $code; + return __trans('Subreg has been asked to email the transfer code to the domain\'s registered contact.'); } public function lock(Registrar_Domain $domain): bool @@ -196,12 +204,27 @@ public function unlock(Registrar_Domain $domain): bool public function enablePrivacyProtection(Registrar_Domain $domain): bool { - throw new Registrar_Exception(':registrar does not support this action.', [':registrar' => 'Subreg']); + $this->setWhoisPrivacy($domain, true); + + return true; } public function disablePrivacyProtection(Registrar_Domain $domain): bool { - throw new Registrar_Exception(':registrar does not support this action.', [':registrar' => 'Subreg']); + $this->setWhoisPrivacy($domain, false); + + return true; + } + + /** Subreg's WHMCS-compatible Modify_Domain structure for WHOIS privacy. */ + private function setWhoisPrivacy(Registrar_Domain $domain, bool $enabled): void + { + $this->order($domain, 'Modify_Domain', [ + 'params' => [ + 'whoisproxy' => $enabled ? 1 : 0, + 'whmcs' => 1, + ], + ]); } public function deleteDomain(Registrar_Domain $domain): bool From 9ed74e3b04d156b1d923aa3485914ed9615ac252 Mon Sep 17 00:00:00 2001 From: insxa Date: Thu, 26 Nov 2026 20:07:48 +0100 Subject: [PATCH 2/7] Add files via upload --- .../Registrar/Adapter/Domainnameapi.php | 577 ++++++++++++++++++ 1 file changed, 577 insertions(+) create mode 100644 src/library/Registrar/Adapter/Domainnameapi.php diff --git a/src/library/Registrar/Adapter/Domainnameapi.php b/src/library/Registrar/Adapter/Domainnameapi.php new file mode 100644 index 000000000..534b9271b --- /dev/null +++ b/src/library/Registrar/Adapter/Domainnameapi.php @@ -0,0 +1,577 @@ + */ + private array $options; + + private string $baseUrl = self::LIVE_URL; + + /** @var array> */ + private array $tldCatalogue = []; + + private ?string $resellerGroupName = null; + + private ?string $catalogueCurrency = null; + + public function __construct(array $options) + { + $this->options = $options; + + if (empty($options['reseller_id']) || empty($options['api_key'])) { + throw new Registrar_Exception('Enter your DomainNameApi Reseller ID and API Key.'); + } + } + + public static function getConfig(): array + { + return [ + 'label' => 'DomainNameApi REST registrar. Uses a Reseller ID and API key.', + 'form' => [ + 'reseller_id' => ['text', [ + 'label' => 'Reseller ID', + 'required' => true, + ]], + 'api_key' => ['password', [ + 'label' => 'API Key', + 'required' => true, + ]], + ], + ]; + } + + public function isDomainAvailable(Registrar_Domain $domain): bool + { + $result = $this->request('POST', 'domains/search', [ + 'domainName' => $domain->getName(), + ]); + + $status = strtoupper((string)($result['info']['status'] ?? '')); + + if ($status === 'AVAILABLE' && !empty($result['info']['isPremium'])) { + throw new Registrar_Exception('Premium domains are not supported by this adapter checkout flow.'); + } + + return $status === 'AVAILABLE'; + } + + public function isDomaincanBeTransferred(Registrar_Domain $domain): bool + { + $tld = strtolower((string)$domain->getTld()); + $catalogue = $this->getTldEntry($tld); + + if ($catalogue !== null && empty($catalogue['isSupportTransfer'])) { + return false; + } + + // Some TLDs do not support a pre-transfer check. + // In that case, rely on the transfer request itself. + if ($catalogue !== null && empty($catalogue['isTransferCheckSupported'])) { + return true; + } + + try { + $this->request('POST', 'domains/transfers/check', [ + 'domainName' => $domain->getName(), + 'authCode' => (string)$domain->getEpp(), + ]); + + return true; + } catch (Registrar_Exception $e) { + if (str_contains($e->getMessage(), '10025')) { + return true; + } + + return false; + } + } + + public function registerDomain(Registrar_Domain $domain): bool + { + $this->request('POST', 'domains/register-with-contacts', [ + 'domainName' => $domain->getName(), + 'period' => max(1, (int)$domain->getRegistrationPeriod()), + 'nameServers' => $this->getNameservers($domain), + 'contacts' => $this->getContacts($domain), + 'useTrusteeContact' => false, + ]); + + return true; + } + + public function transferDomain(Registrar_Domain $domain): bool + { + $authCode = trim((string)$domain->getEpp()); + + if ($authCode === '') { + throw new Registrar_Exception('An EPP/auth code is required to transfer this domain.'); + } + + $tld = strtolower((string)$domain->getTld()); + $catalogue = $this->getTldEntry($tld); + + if ($catalogue !== null && !empty($catalogue['isTransferCheckSupported'])) { + $this->request('POST', 'domains/transfers/check', [ + 'domainName' => $domain->getName(), + 'authCode' => $authCode, + ]); + } + + $this->request('POST', 'domains/transfer', [ + 'domainName' => $domain->getName(), + 'authCode' => $authCode, + 'period' => max(1, (int)$domain->getRegistrationPeriod()), + ]); + + // The transfer is normally accepted as pending. + // ClientFence should poll getTransferStatus(). + return true; + } + + public function renewDomain(Registrar_Domain $domain): bool + { + $payload = [ + 'domainName' => $domain->getName(), + 'period' => max(1, (int)$domain->getRegistrationPeriod()), + ]; + + $this->request('POST', 'domains/renew/check', $payload); + $this->request('POST', 'domains/renew', $payload); + + return true; + } + + public function getDomainDetails(Registrar_Domain $domain): Registrar_Domain + { + $details = $this->request('GET', 'domains/info', null, [ + 'domainName' => $domain->getName(), + ]); + + if (!empty($details['expirationDate'])) { + $expires = strtotime((string)$details['expirationDate']); + + if ($expires !== false) { + $domain->setExpirationTime($expires); + } + } + + if (array_key_exists('authCode', $details) && method_exists($domain, 'setEpp')) { + $domain->setEpp((string)$details['authCode']); + } + + if (array_key_exists('lockStatus', $details) && method_exists($domain, 'setLocked')) { + $domain->setLocked((bool)$details['lockStatus']); + } + + $nameservers = $details['nameservers'] ?? []; + + if (is_array($nameservers)) { + foreach (array_slice($nameservers, 0, 4) as $index => $nameserver) { + $name = is_array($nameserver) ? ($nameserver['name'] ?? '') : $nameserver; + $setter = 'setNs' . ($index + 1); + + if ($name !== '' && method_exists($domain, $setter)) { + $domain->{$setter}((string)$name); + } + } + } + + return $domain; + } + + public function modifyNs(Registrar_Domain $domain): bool + { + $this->request('PUT', 'domains/dns/name-server', [ + 'domainName' => $domain->getName(), + 'nameServers' => $this->getNameservers($domain), + ]); + + return true; + } + + public function getEpp(Registrar_Domain $domain): string + { + $result = $this->request('PUT', 'domains/auth', [ + 'domainName' => $domain->getName(), + ]); + + $code = $result['authCode'] ?? $result['info']['authCode'] ?? null; + + if (!is_string($code) || $code === '') { + throw new Registrar_Exception('DomainNameApi did not return an EPP/auth code.'); + } + + return $code; + } + + public function modifyContact(Registrar_Domain $domain): bool + { + $this->request('PUT', 'domains/contacts/update', [ + 'domainName' => $domain->getName(), + 'contacts' => $this->getContacts($domain), + ]); + + return true; + } + + public function enablePrivacyProtection(Registrar_Domain $domain): bool + { + $this->setPrivacy($domain, true); + + return true; + } + + public function disablePrivacyProtection(Registrar_Domain $domain): bool + { + $this->setPrivacy($domain, false); + + return true; + } + + public function lock(Registrar_Domain $domain): bool + { + $this->request('POST', 'domains/lock', [ + 'domainName' => $domain->getName(), + ]); + + return true; + } + + public function unlock(Registrar_Domain $domain): bool + { + $this->request('POST', 'domains/unlock', [ + 'domainName' => $domain->getName(), + ]); + + return true; + } + + public function deleteDomain(Registrar_Domain $domain): bool + { + throw new Registrar_Exception('Domain deletion is not supported by DomainNameApi.'); + } + + /** + * ClientFence optional price-list interface. + * + * The reseller price group is read automatically from the account API. + * Catalogue currency is taken from the returned catalogue price data. + */ + public function getTldPrices(array $tlds = []): array + { + $account = $this->request('GET', 'deposit/accounts/me'); + + $groupName = trim((string)($account['resellerGroupName'] ?? '')); + + if ($groupName === '') { + throw new Registrar_Exception( + 'DomainNameApi did not return the reseller price group.' + ); + } + + $this->resellerGroupName = $groupName; + + // Currency is not forced through a configuration field or query + // parameter. The API returns the currency with each catalogue price. + $result = $this->request('GET', 'products/tlds', null, [ + 'maxResultCount' => 500, + ]); + + $items = $result['items'] ?? []; + + $wanted = []; + + foreach ($tlds as $tld) { + $wanted[] = strtolower(ltrim((string)$tld, '.')); + } + + $prices = []; + $notPriced = []; + + foreach ($items as $item) { + $name = strtolower((string)($item['name'] ?? '')); + + if ($name === '' || ($wanted !== [] && !in_array($name, $wanted, true))) { + continue; + } + + $group = null; + + foreach (($item['prices'] ?? []) as $candidate) { + if (strcasecmp((string)($candidate['priceGroup'] ?? ''), $groupName) === 0) { + $group = $candidate; + break; + } + } + + if ($group === null) { + $notPriced[] = '.' . $name; + continue; + } + + if ($this->catalogueCurrency === null) { + $this->catalogueCurrency = $this->findPriceCurrency($group); + } + + $prices['.' . $name] = [ + 'register' => $this->getOneYearPrice($group['register'] ?? []), + 'renew' => $this->getOneYearPrice($group['renew'] ?? []), + 'transfer' => $this->getOneYearPrice($group['transfer'] ?? []), + ]; + } + + if ($wanted !== []) { + $found = array_map( + static fn($key) => ltrim($key, '.'), + array_keys($prices) + ); + + foreach ($wanted as $requested) { + if ( + !in_array($requested, $found, true) + && !in_array('.' . $requested, $notPriced, true) + ) { + $notPriced[] = '.' . $requested; + } + } + } + + return [ + 'currency' => $this->catalogueCurrency ?? 'USD', + 'prices' => $prices, + 'remaining' => array_values(array_unique($notPriced)), + ]; + } + + /** + * ClientFence optional transfer-status interface. + */ + public function getTransferStatus(Registrar_Domain $domain): array + { + $result = $this->request('POST', 'domains/transfers/query', [ + 'domainName' => $domain->getName(), + ]); + + $status = (string)($result['status'] ?? 'pending'); + $normalised = strtolower($status); + + // Confirm the domain is readable before reporting completion. + if (in_array($normalised, ['clientapproved', 'serverapproved'], true)) { + try { + $this->getDomainDetails($domain); + $mapped = Registrar_TransferStatus::COMPLETED; + } catch (Throwable $e) { + $mapped = Registrar_TransferStatus::PENDING; + } + } elseif ( + in_array( + $normalised, + ['clientrejected', 'clientcancelled', 'servercancelled'], + true + ) + ) { + $mapped = Registrar_TransferStatus::FAILED; + } else { + $mapped = Registrar_TransferStatus::PENDING; + } + + $message = $status; + + if (!empty($result['finalDate'])) { + $message .= ' (registry auto-approval date: ' . $result['finalDate'] . ')'; + } + + return [ + 'status' => $mapped, + 'message' => $message, + ]; + } + + private function setPrivacy(Registrar_Domain $domain, bool $enabled): void + { + $this->request('POST', 'domains/privacy', [ + 'domainName' => $domain->getName(), + 'enable' => $enabled, + ]); + } + + /** @return list */ + private function getNameservers(Registrar_Domain $domain): array + { + return array_values(array_filter([ + $domain->getNs1(), + $domain->getNs2(), + $domain->getNs3(), + $domain->getNs4(), + ], static fn($value) => is_string($value) && trim($value) !== '')); + } + + /** @return list> */ + private function getContacts(Registrar_Domain $domain): array + { + $contact = $domain->getContactRegistrar(); + + $registrant = [ + 'contactType' => 'Registrant', + 'firstName' => (string)$contact->getFirstName(), + 'lastName' => (string)$contact->getLastName(), + 'companyName' => (string)$contact->getCompany(), + 'eMail' => (string)$contact->getEmail(), + 'address' => trim( + (string)$contact->getAddress1() . ' ' . (string)$contact->getAddress2() + ), + 'city' => (string)$contact->getCity(), + 'state' => (string)$contact->getState(), + 'postalCode' => (string)$contact->getZip(), + 'country' => strtoupper((string)$contact->getCountry()), + 'phoneCountryCode' => ltrim((string)$contact->getTelCc(), '+'), + 'phone' => (string)$contact->getTel(), + ]; + + // DNA supports using one contact for all four roles when its + // contact auto-fill behavior is enabled. + return [ + array_filter( + $registrant, + static fn($value) => $value !== '' + ), + ]; + } + + private function getOneYearPrice(array $periodPrices): ?float + { + foreach ($periodPrices as $entry) { + if ((int)($entry['period'] ?? 0) === 1 && isset($entry['price'])) { + return (float)$entry['price']; + } + } + + return null; + } + + private function findPriceCurrency(array $priceGroup): ?string + { + foreach (['register', 'renew', 'transfer'] as $operation) { + foreach (($priceGroup[$operation] ?? []) as $entry) { + $currency = strtoupper(trim((string)($entry['currency'] ?? ''))); + + if ($currency !== '') { + return $currency; + } + } + } + + return null; + } + + /** @return array|null */ + private function getTldEntry(string $tld): ?array + { + $name = strtolower(ltrim($tld, '.')); + + if (!array_key_exists($name, $this->tldCatalogue)) { + $result = $this->request('GET', 'products/tlds', null, [ + 'filterText' => $name, + 'maxResultCount' => 500, + ]); + + foreach (($result['items'] ?? []) as $item) { + $itemName = strtolower((string)($item['name'] ?? '')); + + if ($itemName !== '') { + $this->tldCatalogue[$itemName] = $item; + } + } + + if (!array_key_exists($name, $this->tldCatalogue)) { + return null; + } + } + + return $this->tldCatalogue[$name]; + } + + /** + * Make one authenticated DNA REST request. + * + * @param array|null $body + * @param array $query + * @return array + */ + private function request( + string $method, + string $path, + ?array $body = null, + array $query = [] + ): array { + $url = $this->baseUrl . ltrim($path, '/'); + + if ($query !== []) { + $url .= '?' . http_build_query($query); + } + + $requestOptions = [ + 'headers' => [ + 'X-API-KEY' => (string)$this->options['api_key'], + '__reseller' => (string)$this->options['reseller_id'], + 'Accept' => 'application/json', + ], + ]; + + if ($body !== null) { + $requestOptions['json'] = $body; + } + + try { + $response = $this->getHttpClient()->request( + $method, + $url, + $requestOptions + ); + + $statusCode = $response->getStatusCode(); + $raw = $response->getContent(false); + $data = $raw !== '' ? json_decode($raw, true) : []; + + if (!is_array($data)) { + throw new Registrar_Exception( + 'DomainNameApi returned an invalid JSON response.' + ); + } + + if ($statusCode >= 400 || (($data['success'] ?? true) === false)) { + $code = (string)($data['code'] ?? ''); + $reason = (string)( + $data['reason'] + ?? $data['message'] + ?? $data['error'] + ?? $raw + ); + + throw new Registrar_Exception( + 'DomainNameApi [' . $code . ']: ' + . ($reason !== '' ? $reason : 'HTTP ' . $statusCode) + ); + } + + return $data; + } catch (Registrar_Exception $e) { + throw $e; + } catch (Throwable $e) { + throw new Registrar_Exception( + 'DomainNameApi request failed: ' . $e->getMessage() + ); + } + } +} \ No newline at end of file From 9e642408597e30f224abf5fc82083bf8a0c24c85 Mon Sep 17 00:00:00 2001 From: insxa Date: Thu, 26 Nov 2026 20:10:53 +0100 Subject: [PATCH 3/7] Add files via upload --- src/library/Registrar/Adapter/Osir.php | 649 +++++++++++++++++++++++++ 1 file changed, 649 insertions(+) create mode 100644 src/library/Registrar/Adapter/Osir.php diff --git a/src/library/Registrar/Adapter/Osir.php b/src/library/Registrar/Adapter/Osir.php new file mode 100644 index 000000000..5cf22b8f4 --- /dev/null +++ b/src/library/Registrar/Adapter/Osir.php @@ -0,0 +1,649 @@ + $tlds */ + public function getTldPrices(array $tlds = []): array; + } +} +if (!interface_exists('Registrar_TransferStatus')) { + interface Registrar_TransferStatus + { + public const PENDING = 'pending'; + public const COMPLETED = 'completed'; + public const FAILED = 'failed'; + + public function getTransferStatus(Registrar_Domain $domain): array; + } +} + +require_once __DIR__ . '/Osir/autoload.php'; + +class Registrar_Adapter_Osir extends Registrar_AdapterAbstract implements Registrar_TldPrices, Registrar_TransferStatus +{ + /** A registry expiry this far past ClientFence's means a renewal happened (about half a year). */ + private const int EXPIRY_JUMP_SECONDS = 180 * 86400; + + /** Settings fields that hold credentials; dropped from memory once the service is built. */ + /** + * `api_key_test` is no longer a setting (OSIR has no sandbox), but an earlier version stored it: + * it stays declared secret so such a stored value is still masked and dropped from memory. + */ + private const array SECRET_FIELDS = ['api_key', 'api_key_test']; + + /** @var array */ + private array $options; + + private ?RegistrarService $service = null; + private ?TldPriceList $tldPriceList = null; + private ?Settings $settings = null; + private ?SafeLogger $safeLog = null; + private ?ConfigurationException $configurationError = null; + + /** + * ClientFence constructs the adapter before calling enableTestMode(), so nothing that depends + * on the mode (key selection, environment) may be resolved here; see {@see self::service()}. + * + * @param array|mixed $options stored registrar settings + */ + public function __construct(#[\SensitiveParameter] $options) + { + $this->options = is_array($options) ? $options : []; + } + + /** + * @return array{label: string, form: array}>} + */ + public static function getConfig(): array + { + return [ + 'label' => 'Registers and manages domains through OSIR (osir.com). Create an API key in the OSIR panel under API keys. ' + . 'OSIR has no test environment: keep Test Mode off. For better security, keep the key out of the database: ' + . "add 'osir' => ['api_key' => '…'] to config.php instead (see the adapter documentation).", + 'form' => [ + 'api_key' => ['password', [ + 'label' => 'API key', + 'description' => 'Starts with `osir_live_`. Leave empty if the key is set in config.php.', + 'required' => false, + 'secret' => true, + ]], + 'max_yearly_cost' => ['text', [ + 'label' => 'Maximum cost per year (USD)', + 'description' => 'Optional safety limit. Registrations, renewals and transfers whose OSIR cost per year (including fees) is higher are refused. Leave empty for no limit.', + 'required' => false, + ]], + 'initialize_dns_zone' => ['radio', [ + 'label' => 'Create DNS zone at OSIR', + 'description' => 'Create a DNS zone at OSIR for newly registered domains. Choose Yes only if your domains use OSIR nameservers.', + 'multiOptions' => ['0' => 'No', '1' => 'Yes'], + 'default' => '0', + ]], + 'allow_cheaper_premium' => ['radio', [ + 'label' => 'Allow premium domains within the cost limit', + 'description' => 'Premium domains are normally refused, because ClientFence sells them at your standard TLD price while the registry charges a different one. ' + . 'With Yes, and a maximum cost per year set above, a premium name is allowed as long as OSIR\'s price stays within that limit — at checkout, at registration, and at renewal or transfer. ' + . 'Set the limit at or below what you charge for the TLD. Without a limit this setting changes nothing.', + 'multiOptions' => ['0' => 'No', '1' => 'Yes'], + 'default' => '0', + ]], + 'debug_logging' => ['radio', [ + 'label' => 'Debug logging', + 'description' => 'Log every OSIR request (method, path, status, duration). Request and response bodies are never logged.', + 'multiOptions' => ['0' => 'No', '1' => 'Yes'], + 'default' => '0', + ]], + ], + ]; + } + + /** + * Masked in ClientFence's API and admin UI (ClientFence >= 0.8.7 also honours 'secret' => true). + * + * @return string[] + */ + public static function getSecretFields(): array + { + return self::SECRET_FIELDS; + } + + public function isDomainAvailable(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $name = Map::domainName($domain); + $availability = $this->service()->checkAvailability($name); + + return match ($availability->state) { + AvailabilityState::Unknown => throw new RuleException('Could not check the availability of :domain right now. Please try again in a few minutes.', [':domain' => $name->unicode()]), + // With premium names allowed within the cost limit, the service has already checked + // this one's price against that limit, so anything that arrives here may be sold. + AvailabilityState::Available => $availability->premium && !$this->allowsCheaperPremium() + ? throw new RuleException(':domain is a premium domain. Premium domains cannot be registered through this registrar.', [':domain' => $name->unicode()]) + : true, + AvailabilityState::Registered => false, + }; + }); + } + + public function isDomaincanBeTransferred(Registrar_Domain $domain): bool + { + return $this->guard(fn(): bool => $this->service()->canTransfer(Map::domainName($domain))); + } + + public function modifyNs(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->updateNameservers(Map::domainName($domain), Map::nameservers($domain)); + + return true; + }); + } + + public function modifyContact(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->updateContact(Map::domainName($domain), Map::contact($domain)); + + return true; + }); + } + + public function transferDomain(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->transfer( + Map::domainName($domain), + is_string($epp = $domain->getEpp()) ? $epp : '', + Map::years($domain), + Map::contact($domain), + Map::orderRef($this->_order), + ); + + return true; + }); + } + + /** + * A domain that is no longer in this OSIR account (transferred away, deleted, never registered) + * is returned with ClientFence's own data unchanged and an error in the log, instead of an + * exception: ClientFence's expiry batch sync only records success when EVERY domain synced, so a + * single gone domain would otherwise make it re-sync all domains on every cron tick (web or CLI + * cron alike), burning OSIR's rate limit. The price is that a manual "Sync" of such a domain + * reports success; the log says why. + */ + public function getDomainDetails(Registrar_Domain $domain): Registrar_Domain + { + return $this->guard(function () use ($domain): Registrar_Domain { + $name = Map::domainName($domain); + try { + $info = $this->service()->details($name); + } catch (RuleException $e) { + return $this->unchangedBecauseGone($domain, $name->ascii(), $e->getMessage()); + } + if ($info->status->isGone()) { + return $this->unchangedBecauseGone( + $domain, + $name->ascii(), + $info->status === DomainStatus::TransferredOut ? 'transferred to another registrar' : 'no longer registered', + ); + } + + // While a renewal of this order is unresolved (ClientFence marked it failed_renew), do not + // copy a registry expiry that has jumped ahead: that jump may be our own renewal whose answer + // was lost. Keeping ClientFence's date lets the retry recognise the renewal as already + // applied instead of renewing — and charging — a second time. Normal syncs resume once the + // order is active again. + $order = Map::orderRef($this->_order); + $known = Map::expiry($domain); + $keepExpiry = $order !== null && $order->hasUnresolvedRenewal() + && $known !== null && $info->expiresAt !== null + && $info->expiresAt - $known > self::EXPIRY_JUMP_SECONDS; + if ($keepExpiry) { + $this->log()->warning(sprintf('%s: renewal of order #%s is unresolved; not syncing the registry expiry (%s) until the renewal is retried.', $name, $order->id, gmdate('Y-m-d', (int) $info->expiresAt))); + } + + return Map::applyInfo($domain, $info, $keepExpiry); + }); + } + + public function getEpp(Registrar_Domain $domain): string + { + return $this->guard(fn(): string => $this->service()->authCode(Map::domainName($domain))); + } + + public function registerDomain(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->register( + Map::domainName($domain), + Map::years($domain), + Map::nameservers($domain), + Map::contact($domain), + Map::orderRef($this->_order), + ); + + return true; + }); + } + + public function renewDomain(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->renew( + Map::domainName($domain), + Map::years($domain), + Map::expiry($domain), + Map::orderRef($this->_order), + ); + + return true; + }); + } + + /** + * OSIR does not let API keys delete domains (deletion is an OSIR staff action, because it is + * irreversible). ClientFence calls this when an order is cancelled; refusing would make orders + * impossible to cancel, so the domain is left registered and the administrator is told in the log. + */ + public function deleteDomain(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $name = Map::domainName($domain); + $this->log()->warning(sprintf( + 'ClientFence asked to delete %s (order cancelled). OSIR does not delete domains through the API: ' + . 'the domain stays registered until it expires. Contact OSIR support if it must be deleted within the grace period.', + $name, + )); + + return true; + }); + } + + public function enablePrivacyProtection(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->setPrivacy(Map::domainName($domain), true); + + return true; + }); + } + + public function disablePrivacyProtection(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->setPrivacy(Map::domainName($domain), false); + + return true; + }); + } + + public function lock(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->setTransferLock(Map::domainName($domain), true); + + return true; + }); + } + + public function unlock(Registrar_Domain $domain): bool + { + return $this->guard(function () use ($domain): bool { + $this->service()->setTransferLock(Map::domainName($domain), false); + + return true; + }); + } + + // ----------------------------------------------------------- ClientFence capabilities + // + // ClientFence adds two optional interfaces to the registrar contract, and the generated + // ClientFence build of this adapter declares them (dev/scripts/make-clientfence.sh). The + // methods are here in both builds: ClientFence simply never calls them. + + /** + * OSIR's price list for ClientFence's "TLDs and prices" page, one slice per call: the cost of + * one year per action in USD, fees included. ClientFence applies the markup, the rounding and + * the currency conversion, and asks again for whatever `remaining` names. + * + * The plugin's own import page (Osir module) does the same job on both platforms and adds the + * preview and the domain import; this exists so ClientFence's native page and its scheduled + * price sync work too. + * + * @param list $tlds TLDs to price, with the leading dot; [] = every TLD OSIR sells + * + * @return array{currency: string, prices: array, remaining: list} + */ + public function getTldPrices(array $tlds = []): array + { + return $this->guard(fn(): array => $this->tldPriceList()->slice(array_values(array_filter($tlds, 'is_string')))); + } + + /** + * Where an incoming transfer stands, so ClientFence can keep the order pending until the + * registry has actually moved the domain instead of closing it when OSIR accepts the request. + * + * @return array{status: string, message: string} + */ + public function getTransferStatus(Registrar_Domain $domain): array + { + return $this->guard(function () use ($domain): array { + $progress = $this->service()->transferProgress(Map::domainName($domain)); + + // The values of Registrar_TransferStatus::PENDING / COMPLETED / FAILED, spelled out so + // that the ClientFence build (where that interface does not exist) still compiles. + $status = match ($progress->state) { + TransferState::Completed => 'completed', + TransferState::Failed => 'failed', + TransferState::Pending => 'pending', + }; + $this->log()->info(sprintf('Transfer of %s: %s. %s', $domain->getName(), $status, $progress->message)); + + return ['status' => $status, 'message' => $progress->message]; + }); + } + + /** + * Builds the service on first use. Overridable so tests can inject a mock HTTP client through + * {@see Registrar_AdapterAbstract::getHttpClient()}. + * + * @throws ConfigurationException + */ + protected function service(): RegistrarService + { + if ($this->configurationError !== null) { + throw $this->configurationError; // the raw keys are gone; repeat the real reason, not "no key" + } + self::assertFilesFromOneRelease(); + if ($this->service === null) { + try { + $settings = SettingsResolver::fromRuntime()->resolve($this->options, (bool) $this->_testMode, self::installationSeed()); + } catch (ConfigurationException $e) { + throw $this->configurationError = $e; + } finally { + // The key now lives only inside Settings (as a Secret), or nowhere; drop the raw copies. + foreach (self::SECRET_FIELDS as $field) { + unset($this->options[$field]); + } + } + $this->safeLog = new SafeLogger($this->getLog(), $settings->debug); + $api = new ApiClient($this->getHttpClient(), $settings, $this->safeLog, RetryPolicy::forCurrentSapi()); + $this->service = new RegistrarService($api, $settings, $this->safeLog); + $this->settings = $settings; + } + + return $this->service; + } + + /** + * Half-finished upgrades are the one failure nobody can read: the only symptom is PHP saying + * some class is "not found", which tells an administrator nothing about what to do. + * + * It happens because this adapter is a file (Osir.php) beside a folder of the same name + * (Osir/): a file manager that will not overwrite the file, an opcode cache still serving the + * old one, or an upload that stopped halfway leave the two halves on different releases. + * + * @throws Registrar_Exception naming the paths to delete and upload again + */ + private static function assertFilesFromOneRelease(): void + { + foreach ([SettingsResolver::class, SafeLogger::class, RegistrarService::class, Version::class] as $class) { + if (!class_exists($class)) { + throw new Registrar_Exception( + 'The OSIR adapter\'s files are incomplete or come from two different releases. Delete the file library/Registrar/Adapter/Osir.php, the folder library/Registrar/Adapter/Osir and the folder modules/Osir, upload the archive for this platform again, and restart PHP (or clear the opcode cache).', + ); + } + } + + $module = self::moduleVersion(); + if ($module !== null && $module !== Version::PLUGIN) { + throw new Registrar_Exception( + 'The OSIR registrar adapter is :adapter but the OSIR module is :module. They must come from the same release: delete the file library/Registrar/Adapter/Osir.php, the folder library/Registrar/Adapter/Osir and the folder modules/Osir, upload the archive for this platform again, and restart PHP.', + [':adapter' => Version::PLUGIN, ':module' => $module], + ); + } + } + + /** + * The version of the companion module as its manifest states it, or null when the module is + * not installed (which is fine: the registrar works without it). + */ + public static function moduleVersion(): ?string + { + $manifest = dirname(__DIR__, 3) . '/modules/Osir/manifest.json'; + if (!is_file($manifest)) { + return null; + } + $data = json_decode((string) file_get_contents($manifest), true); + $version = is_array($data) ? ($data['version'] ?? null) : null; + + return is_string($version) && $version !== '' ? $version : null; + } + + /** + * Read-only health checks, used by bin/osir-doctor.php. + * + * @throws ConfigurationException when the adapter cannot even be configured (the doctor reports it) + */ + public function diagnostics(): Diagnostics + { + $service = $this->service(); + assert($this->settings !== null); + + return new Diagnostics($service, $this->settings, self::moduleVersion()); + } + + /** + * Read-only catalog, pricing and domain-listing queries for the "Import from OSIR" admin tools + * (the companion ClientFence module in modules/Osir). + * + * @throws ConfigurationException when the adapter cannot be configured + */ + public function importService(): ImportService + { + $this->service(); + assert($this->settings !== null && $this->safeLog !== null); + + return new ImportService( + new ApiClient($this->getHttpClient(), $this->settings, $this->safeLog, RetryPolicy::forCurrentSapi()), + $this->safeLog, + ); + } + + /** + * The price list, kept for the whole request: ClientFence asks for one slice after another and + * each slice would otherwise fetch the catalog again. + * + * @throws ConfigurationException when the adapter cannot be configured + */ + private function tldPriceList(): TldPriceList + { + $this->service(); + assert($this->safeLog !== null); + + return $this->tldPriceList ??= new TldPriceList($this->importService(), $this->safeLog); + } + + /** + * DNS records for the client area (the companion module in modules/Osir). Ownership of the + * domain is decided there and re-checked by OSIR; this only builds the client. + * + * @throws ConfigurationException when the adapter cannot be configured + */ + public function dnsService(): DnsService + { + $this->service(); + assert($this->settings !== null && $this->safeLog !== null); + + return new DnsService( + new ApiClient($this->getHttpClient(), $this->settings, $this->safeLog, RetryPolicy::forCurrentSapi()), + $this->safeLog, + ); + } + + /** + * The installation-wide id used in idempotency keys, and the environment they carry. + * + * @return array{installation: string, environment: \Osir\ClientFence\Config\Environment} + */ + public function keyScope(): array + { + $this->service(); + assert($this->settings !== null); + + return ['installation' => $this->settings->installationId, 'environment' => $this->settings->environment]; + } + + /** Whether premium names may be registered when they cost less than they sell for. */ + private function allowsCheaperPremium(): bool + { + $this->service(); + assert($this->settings !== null); + + return $this->settings->allowCheaperPremium; + } + + private function unchangedBecauseGone(Registrar_Domain $domain, string $name, string $why): Registrar_Domain + { + $this->log()->error(sprintf('Sync of %s skipped: %s. ClientFence keeps its own data for this domain.', $name, $why)); + // ClientFence serialises this object into its database; never let a transfer code ride along. + $domain->setEpp(null); + + return $domain; + } + + private function log(): SafeLogger + { + return $this->safeLog ??= new SafeLogger($this->getLog()); + } + + /** + * Runs one adapter operation and converts every failure into a Registrar_Exception. + * + * @template T + * + * @param Closure(): T $operation + * + * @return T + * + * @throws Registrar_Exception + */ + private function guard(Closure $operation): mixed + { + try { + return $operation(); + } catch (Registrar_Exception $e) { + throw $e; + } catch (ValidationException|RuleException $e) { + // Written for end users by design; no upstream text inside. + throw new Registrar_Exception($e->getTemplate(), $e->getVariables()); + } catch (ConfigurationException $e) { + // Details for administrators only: availability checks run for anonymous visitors too. + $this->log()->error('Configuration problem: ' . $e->getMessage()); + + throw new Registrar_Exception('The domain registrar is not configured correctly. Administrators: see the system log for details.'); + } catch (TransportException $e) { + $this->log()->error(sprintf('OSIR unreachable (ref %s): %s', $e->getRequestId(), $e->getMessage())); + + throw new Registrar_Exception( + $e->isOutcomeUnknown() + ? 'The domain registrar did not answer in time. The request may still be processed; it is safe to retry in a few minutes. (Reference: :ref)' + : 'The domain registrar could not be reached. Please try again in a few minutes. (Reference: :ref)', + [':ref' => $e->getRequestId()], + ); + } catch (ApiException $e) { + $this->log()->error(sprintf( + 'OSIR error %s (HTTP %d%s, ref %s): %s', + $e->getKind()->value, + $e->getHttpStatus(), + $e->getErrorCode() !== null ? ', ' . $e->getErrorCode() : '', + $e->getRequestId(), + $e->getUpstreamMessage() ?? 'no message', + )); + + throw new Registrar_Exception(self::publicMessage($e->getKind()) . ' (Reference: :ref)', [':ref' => $e->getRequestId()]); + } catch (Throwable $e) { + // Never leak internals (paths, SQL, stack traces) to clients. + $this->log()->error(sprintf('Unexpected %s in OSIR adapter: %s', $e::class, $e->getMessage())); + + throw new Registrar_Exception('The domain registrar reported an unexpected error. Please contact support.'); + } + } + + /** Client-safe wording per error kind. Account-level problems are deliberately vague for clients. */ + private static function publicMessage(ApiErrorKind $kind): string + { + return match ($kind) { + ApiErrorKind::Authentication, ApiErrorKind::Permission, ApiErrorKind::AccountNotVerified, + ApiErrorKind::InsufficientFunds, ApiErrorKind::SpendLimit => 'The domain registrar could not process this request right now. Please contact support.', + ApiErrorKind::NotFound => 'The domain was not found at the registrar.', + ApiErrorKind::Conflict => 'The registrar refused the request because of the domain\'s current state (for example a pending transfer, or an expired domain).', + ApiErrorKind::InProgress => 'This request is still being processed by the registrar. Please check again in a few minutes.', + ApiErrorKind::RateLimited => 'The domain registrar is busy. Please try again in a minute.', + ApiErrorKind::InvalidAuthCode => 'The transfer code was rejected by the registry. Please check it and try again.', + ApiErrorKind::Rejected => 'The domain registrar rejected the request.', + ApiErrorKind::Server, ApiErrorKind::Protocol => 'The domain registrar reported a temporary error. Please try again later.', + }; + } + + /** + * Identifies this ClientFence installation in idempotency keys and contact ids. It must be the + * same in web requests and cron: ClientFence's INSTANCE_ID (config info.instance_id) is, whereas + * SYSTEM_URL is not (its scheme follows the request unless force_https is set). + */ + private static function installationSeed(): string + { + $instance = defined('INSTANCE_ID') ? constant('INSTANCE_ID') : null; + // Ignore ClientFence's defaults: 'Unknown' and the config-sample placeholder of X's. + if (is_string($instance) && $instance !== '' && $instance !== 'Unknown' && preg_match('/^[X-]+$/', $instance) !== 1) { + return 'instance:' . $instance; + } + $root = defined('PATH_ROOT') ? constant('PATH_ROOT') : null; + + return 'path:' . (is_string($root) && $root !== '' ? $root : __DIR__); + } +} From 2354c8f1703161a1b2d00362190d0f6958e196a4 Mon Sep 17 00:00:00 2001 From: insxa Date: Thu, 26 Nov 2026 20:25:53 +0100 Subject: [PATCH 4/7] Add files via upload --- .../Registrar/Adapter/Osir/CHANGELOG.md | 228 +++++ src/library/Registrar/Adapter/Osir/LICENSE | 202 +++++ src/library/Registrar/Adapter/Osir/README.md | 432 ++++++++++ .../Registrar/Adapter/Osir/SECURITY.md | 26 + .../Registrar/Adapter/Osir/autoload.php | 46 + .../Adapter/Osir/bin/osir-doctor.php | 138 +++ .../Adapter/Osir/src/Config/Environment.php | 30 + .../Adapter/Osir/src/Config/Secret.php | 63 ++ .../Adapter/Osir/src/Config/Settings.php | 37 + .../Osir/src/Config/SettingsResolver.php | 199 +++++ .../Adapter/Osir/src/Dns/DnsRecord.php | 313 +++++++ .../Adapter/Osir/src/Dns/DnsService.php | 300 +++++++ .../Adapter/Osir/src/Dns/RecordType.php | 57 ++ .../Adapter/Osir/src/Dns/ZoneStatus.php | 88 ++ .../Adapter/Osir/src/Domain/DomainName.php | 169 ++++ .../Adapter/Osir/src/Domain/Nameservers.php | 68 ++ .../Osir/src/Exception/ApiErrorKind.php | 38 + .../Osir/src/Exception/ApiException.php | 71 ++ .../src/Exception/ConfigurationException.php | 8 + .../Osir/src/Exception/OsirException.php | 39 + .../Osir/src/Exception/RuleException.php | 12 + .../Osir/src/Exception/TransportException.php | 39 + .../src/Exception/ValidationException.php | 11 + .../Adapter/Osir/src/Http/ApiClient.php | 270 ++++++ .../Adapter/Osir/src/Http/ApiRequest.php | 112 +++ .../Adapter/Osir/src/Http/ApiResponse.php | 22 + .../Adapter/Osir/src/Http/ErrorClassifier.php | 115 +++ .../Adapter/Osir/src/Http/RetryPolicy.php | 71 ++ .../Adapter/Osir/src/Import/CatalogTld.php | 86 ++ .../Adapter/Osir/src/Import/ImportService.php | 280 ++++++ .../Adapter/Osir/src/Import/PriceRule.php | 109 +++ .../Adapter/Osir/src/Import/RemoteDomain.php | 47 ++ .../Adapter/Osir/src/Import/Rounding.php | 28 + .../Adapter/Osir/src/Import/TldCost.php | 29 + .../Adapter/Osir/src/Import/TldPriceList.php | 133 +++ .../Adapter/Osir/src/Mapping/Availability.php | 63 ++ .../Osir/src/Mapping/AvailabilityState.php | 13 + .../Adapter/Osir/src/Mapping/ContactData.php | 27 + .../Osir/src/Mapping/ContactMapper.php | 184 ++++ .../Adapter/Osir/src/Mapping/DomainInfo.php | 35 + .../Osir/src/Mapping/DomainInfoParser.php | 85 ++ .../Adapter/Osir/src/Mapping/DomainStatus.php | 35 + .../Osir/src/Mapping/PlatformMapper.php | 147 ++++ .../Osir/src/Mapping/TransferProgress.php | 18 + .../Osir/src/Mapping/TransferState.php | 18 + .../Adapter/Osir/src/Service/Diagnostics.php | 105 +++ .../Osir/src/Service/IdempotencyKeys.php | 72 ++ .../Adapter/Osir/src/Service/OrderRef.php | 35 + .../Osir/src/Service/RegistrarService.php | 797 ++++++++++++++++++ .../Osir/src/Service/RenewalDecision.php | 15 + .../Osir/src/Service/RenewalPolicy.php | 73 ++ .../Adapter/Osir/src/Support/Redactor.php | 79 ++ .../Adapter/Osir/src/Support/SafeLogger.php | 78 ++ .../Adapter/Osir/src/Support/Text.php | 31 + .../Registrar/Adapter/Osir/src/Version.php | 11 + 55 files changed, 5837 insertions(+) create mode 100644 src/library/Registrar/Adapter/Osir/CHANGELOG.md create mode 100644 src/library/Registrar/Adapter/Osir/LICENSE create mode 100644 src/library/Registrar/Adapter/Osir/README.md create mode 100644 src/library/Registrar/Adapter/Osir/SECURITY.md create mode 100644 src/library/Registrar/Adapter/Osir/autoload.php create mode 100644 src/library/Registrar/Adapter/Osir/bin/osir-doctor.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Config/Environment.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Config/Secret.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Config/Settings.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Config/SettingsResolver.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Dns/DnsRecord.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Dns/DnsService.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Dns/RecordType.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Dns/ZoneStatus.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Domain/DomainName.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Domain/Nameservers.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/ApiErrorKind.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/ApiException.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/ConfigurationException.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/OsirException.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/RuleException.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/TransportException.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Exception/ValidationException.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Http/ApiClient.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Http/ApiRequest.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Http/ApiResponse.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Http/ErrorClassifier.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Http/RetryPolicy.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/CatalogTld.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/ImportService.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/PriceRule.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/RemoteDomain.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/Rounding.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/TldCost.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Import/TldPriceList.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/Availability.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/AvailabilityState.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/ContactData.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/ContactMapper.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/DomainInfo.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/DomainInfoParser.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/DomainStatus.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/PlatformMapper.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/TransferProgress.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Mapping/TransferState.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Service/Diagnostics.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Service/IdempotencyKeys.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Service/OrderRef.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Service/RegistrarService.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Service/RenewalDecision.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Service/RenewalPolicy.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Support/Redactor.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Support/SafeLogger.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Support/Text.php create mode 100644 src/library/Registrar/Adapter/Osir/src/Version.php diff --git a/src/library/Registrar/Adapter/Osir/CHANGELOG.md b/src/library/Registrar/Adapter/Osir/CHANGELOG.md new file mode 100644 index 000000000..04f93f416 --- /dev/null +++ b/src/library/Registrar/Adapter/Osir/CHANGELOG.md @@ -0,0 +1,228 @@ +# Changelog + +All notable changes to this project are documented here. The format follows +[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses +[Semantic Versioning](https://semver.org/). + +## [1.5.1] - 2026-11-26 + +### Fixed +- **A half-finished upload now says so, instead of "class not found".** Upgrading to 1.5.0 by uploading over + the old files can leave the two halves of the plugin on different releases, because the adapter is a file + (`library/Registrar/Adapter/Osir.php`) beside a folder of the same name (`library/Registrar/Adapter/Osir/`): + a file manager that will not replace the file, an opcode cache still serving the old one, or an upload that + stopped halfway leaves the old `Osir.php` next to the new library. Since 1.5.0 renamed the plugin's own + namespace in the ClientFence build, the only symptom was PHP reporting + `Class "Osir\FossBilling\Config\SettingsResolver" not found` (or `…\Support\SafeLogger`), which tells an + administrator nothing. + + Three things now catch it and name the paths to delete and upload again: the adapter's autoloader answers a + request for the old namespace with that message, the adapter refuses to start when its own classes are + missing or when the module's version differs from its own, and the module's API does the same when its + `Service.php` is older than the file calling it (the cause of the `undefined method …::dnsOverview()` error + some installs saw after 1.2.1). +- `osir-doctor` lists the **module version** beside the adapter version, and fails when they differ. + +### Changed +- The upgrade instructions now say to delete `library/Registrar/Adapter/Osir.php`, the folder + `library/Registrar/Adapter/Osir` and the folder `modules/Osir` before uploading a new release, rather than + extracting over them. + +## [1.5.0] - 2026-11-26 + +### Fixed +- **The admin import page and the client DNS tab work on ClientFence.** ClientFence sends a + `Content-Security-Policy` with a script nonce, and a browser ignores `'unsafe-inline'` as soon as a nonce + is present: both pages carry their JavaScript inline, so none of it ran. The page looked right and + nothing happened — no TLD catalogue, no domain list, no prices, and a client area DNS form whose buttons + did nothing. Both `