Open .kurd sub-pages and a site's own 404; show a suspended name as suspended (#40)

* Open a .kurd page address typed with a path

Tapping the address bar puts the page's full address in the search box,
for example https://dks-news.kurd/kategori/ekonomi. The search only knew
a bare name, and a .kurd address is never a web address or a search, so
such input produced no result at all: the reader could not open, edit or
reload any page below the home page.

KurdName.parseAddress takes the name and the path, query and fragment
after it (printable ASCII, no port or user info), and the .kurd row opens
that page. The look-alike check still runs on the name; choosing the
official name opens its home page, since the typed path belongs to the
other site.

* Show a .kurd site's own 404 page for a page it does not have

A missing page was answered with 404 and an empty body. WebView replaces
such a response with its own "Webpage not available" screen
(ERR_HTTP_RESPONSE_CODE_FAILURE), as if the site could not be reached,
although the gateway had proven the page absent from a site that loads.

For the page's own document the server now serves the site's /404.html
with status 404, as a web server does (dks.news ships one), and a line of
text when the site has none. Missing images and scripts are answered as
before. The fixture is a Kubo-built directory with index.html and
404.html.

* Show a suspended .kurd name as suspended, and open nothing of it

The register can now stop a name: the court for up to 30 days, the emergency
council for 72 hours. The lookup reads Navnisan::Suspensions beside Names, at
the same finalized block and through the same proof path, and applies the
pallet's rule: a suspension of the name, or of a name it sits under as a
subname, for the registration it was made against and not yet run out.

A suspended name resolves to a new Suspended result however it was read,
since a refusal needs no proof. The site server serves nothing (451) and the
browser shows the existing notice with a pause icon, who stopped the name,
until when, and the hash of the written reasons. Strings in English,
Kurmanji and Turkish.

A chain without the Suspensions item stores nothing there, so on today's
runtime nothing changes.
This commit is contained in:
SatoshiQaziMuhammed authored and GitHub committed 2026-11-08 21:35:35 +04:00
1 parent cb74f8cde0
commit f50ca479e0
24 files changed
+476 -21

No files matched your search

@@ -12,11 +12,14 @@ sealed interface DappSearchResult {
override val isTrustedByNova: Boolean = false
}
/** A `.kurd` name: resolved on chain when opened, never looked up on the web. */
class KurdName(val name: io.novafoundation.nova.runtime.names.KurdName) : DappSearchResult {
/** A page under a `.kurd` name: resolved on chain when opened, never looked up on the web. */
class KurdName(
val name: io.novafoundation.nova.runtime.names.KurdName,
val path: String = "/"
) : DappSearchResult {
override val isTrustedByNova: Boolean = true
val url: String get() = "https://${name.name}/"
val url: String get() = "https://${name.name}$path"
}
class Dapp(val dapp: DApp) : DappSearchResult {
@@ -34,7 +34,7 @@ class SearchDappInteractor(
.map(DappSearchResult::Dapp)
// A .kurd name is resolved on chain by the wallet: never a web address, never a search query
val kurdName = KurdName.parse(query).takeIf { KurdName.mentionsKurd(query) }
val kurdAddress = KurdName.parseAddress(query).takeIf { KurdName.mentionsKurd(query) }
val searchGroupContent = when {
query.isEmpty() -> null
@@ -50,8 +50,8 @@ class SearchDappInteractor(
}
buildMap {
kurdName?.let {
put(DappSearchGroup.KURD_NAME, listOf(DappSearchResult.KurdName(it)))
kurdAddress?.let { (name, path) ->
put(DappSearchGroup.KURD_NAME, listOf(DappSearchResult.KurdName(name, path)))
}
searchGroupContent?.let {
@@ -26,6 +26,7 @@ import io.novafoundation.nova.common.utils.insets.applyNavigationBarInsets
import io.novafoundation.nova.common.utils.insets.applyStatusBarInsets
import io.novafoundation.nova.common.utils.makeGone
import io.novafoundation.nova.common.utils.makeVisible
import io.novafoundation.nova.common.utils.formatting.formatDateTime
import io.novafoundation.nova.common.utils.setImageTintRes
import io.novafoundation.nova.common.utils.setVisible
import io.novafoundation.nova.common.utils.webView.WebViewRequestInterceptor
@@ -51,6 +52,7 @@ import io.novafoundation.nova.feature_dapp_impl.web3.webview.Web3WebViewClient
import io.novafoundation.nova.feature_dapp_impl.web3.webview.WebViewHolder
import io.novafoundation.nova.feature_external_sign_api.presentation.externalSign.AuthorizeDappBottomSheet
import io.novafoundation.nova.runtime.names.KurdName
import io.novafoundation.nova.runtime.names.NameSuspension
import javax.inject.Inject
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
@@ -445,6 +447,22 @@ class DAppBrowserFragment : BaseFragment<DAppBrowserViewModel, FragmentDappBrows
R.string.dapp_kurd_back,
viewModel::kurdBack
)
KurdPageUi.NoticeKind.SUSPENDED -> {
val suspension = requireNotNull(page.suspension) { "A suspended notice without its suspension" }
val until = suspension.until.formatDateTime()
val message = when (suspension.by) {
NameSuspension.By.COURT -> R.string.dapp_kurd_suspended_court_message
NameSuspension.By.EMERGENCY -> R.string.dapp_kurd_suspended_emergency_message
}
Look(
R.drawable.ic_kurd_suspended,
R.color.icon_negative,
R.string.dapp_kurd_suspended_title,
getString(message, until),
R.string.dapp_kurd_back,
viewModel::kurdBack
)
}
KurdPageUi.NoticeKind.NO_SITE -> Look(
R.drawable.ic_info,
R.color.icon_secondary,
@@ -471,9 +489,25 @@ class DAppBrowserFragment : BaseFragment<DAppBrowserViewModel, FragmentDappBrows
notice.kurdNoticePrimary.setText(look.primary)
notice.kurdNoticePrimary.setOnClickListener { look.primaryAction() }
notice.kurdNoticeSecondary.setVisible(kind == KurdPageUi.NoticeKind.NEEDS_CONSENT)
showKurdSuspension(page.suspension.takeIf { kind == KurdPageUi.NoticeKind.SUSPENDED })
notice.kurdNoticeSecondary.setText(R.string.dapp_kurd_open_anyway)
}
private fun showKurdSuspension(suspension: NameSuspension?) {
val details = binder.dappBrowserKurdNotice
details.kurdNoticeSuspension.setVisible(suspension != null)
if (suspension == null) return
details.kurdNoticeSuspensionBy.setText(
when (suspension.by) {
NameSuspension.By.COURT -> R.string.dapp_kurd_suspended_by_court
NameSuspension.By.EMERGENCY -> R.string.dapp_kurd_suspended_by_emergency
}
)
details.kurdNoticeSuspensionUntil.text = suspension.until.formatDateTime()
details.kurdNoticeSuspensionReason.text = suspension.reason.let { "${it.take(6)}…${it.takeLast(4)}" }
}
/** Storage, cookies and permissions the page kept under its name; then it loads afresh. */
private fun clearKurdSiteData(name: KurdName) {
val origin = "https://${name.name}"
@@ -2,6 +2,7 @@ package io.novafoundation.nova.feature_dapp_impl.presentation.browser.main.kurd
import io.novafoundation.nova.runtime.names.KurdName
import io.novafoundation.nova.runtime.names.NameRecord
import io.novafoundation.nova.runtime.names.NameSuspension
import io.novafoundation.nova.runtime.names.content.KurdSiteServer.PageState
import java.net.URI
@@ -13,7 +14,8 @@ sealed interface KurdPageUi {
/** [onChainVersion]: a feed showing the release the chain names, as no newer one could be confirmed. */
class Open(override val name: KurdName, val badge: Badge, val details: Details, val onChainVersion: Boolean = false) : KurdPageUi
class Notice(override val name: KurdName, val kind: NoticeKind) : KurdPageUi
/** [suspension]: who stopped the name and until when, for [NoticeKind.SUSPENDED]. */
class Notice(override val name: KurdName, val kind: NoticeKind, val suspension: NameSuspension? = null) : KurdPageUi
enum class Badge {
/** Granted by Parliament, or under such a name: the state's own. */
@@ -26,7 +28,7 @@ sealed interface KurdPageUi {
UNVERIFIED,
}
enum class NoticeKind { REFUSED, NEEDS_CONSENT, NOT_REGISTERED, NO_SITE, UNAVAILABLE }
enum class NoticeKind { REFUSED, NEEDS_CONSENT, NOT_REGISTERED, SUSPENDED, NO_SITE, UNAVAILABLE }
class Details(
val badge: Badge,
@@ -72,6 +74,7 @@ sealed interface KurdPageUi {
is PageState.NeedsConsent -> Notice(name, NoticeKind.NEEDS_CONSENT)
PageState.Refused -> Notice(name, NoticeKind.REFUSED)
PageState.NotRegistered -> Notice(name, NoticeKind.NOT_REGISTERED)
is PageState.Suspended -> Notice(name, NoticeKind.SUSPENDED, state.suspension)
PageState.NoSite -> Notice(name, NoticeKind.NO_SITE)
PageState.Unavailable -> Notice(name, NoticeKind.UNAVAILABLE)
}
@@ -23,7 +23,6 @@ import io.novafoundation.nova.feature_dapp_impl.presentation.DAppRouter
import io.novafoundation.nova.feature_dapp_impl.presentation.common.dappCategoryToUi
import io.novafoundation.nova.feature_dapp_impl.presentation.search.model.DappSearchModel
import io.novafoundation.nova.runtime.names.KurdLookalikes
import io.novafoundation.nova.runtime.names.KurdName
import io.novafoundation.nova.runtime.names.KurdNameResolver
import io.novafoundation.nova.runtime.names.KurdResolution
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -128,7 +127,7 @@ class DAppSearchViewModel(
)
is DappSearchResult.KurdName -> DappSearchModel(
title = searchResult.name.name,
title = searchResult.name.name + searchResult.path.takeIf { it != "/" }.orEmpty(),
description = resourceManager.getString(R.string.dapp_search_kurd_name_subtitle),
iconRes = R.drawable.shield_checkmark_outline,
searchResult = searchResult,
@@ -143,7 +142,7 @@ class DAppSearchViewModel(
is DappSearchResult.Dapp -> searchResult.dapp.url
is DappSearchResult.Search -> searchResult.searchUrl
is DappSearchResult.Url -> searchResult.url
is DappSearchResult.KurdName -> urlAfterLookalikeCheck(searchResult.name)
is DappSearchResult.KurdName -> urlAfterLookalikeCheck(searchResult)
}
if (!searchResult.isTrustedByNova) {
@@ -166,17 +165,18 @@ class DAppSearchViewModel(
* chooses that one. Looked up only when the typed name has such a candidate, and for a few
* seconds at most: the opened page still shows by its badge whether it is official.
*/
private suspend fun urlAfterLookalikeCheck(typed: KurdName): String {
private suspend fun urlAfterLookalikeCheck(typed: DappSearchResult.KurdName): String {
val official = withTimeoutOrNull(LOOKALIKE_CHECK_MILLIS) {
KurdLookalikes.candidates(typed).firstOrNull { candidate ->
KurdLookalikes.candidates(typed.name).firstOrNull { candidate ->
val resolution = kurdNameResolver.resolve(candidate)
resolution is KurdResolution.Resolved && resolution.verified && resolution.official
}
} ?: return DappSearchResult.KurdName(typed).url
} ?: return typed.url
return when (kurdLookalikeWarning.awaitAction(KurdLookalikeWarning(typed, official))) {
return when (kurdLookalikeWarning.awaitAction(KurdLookalikeWarning(typed.name, official))) {
// The official site's home page: the typed path belongs to a different site
KurdLookalikeChoice.GO_OFFICIAL -> DappSearchResult.KurdName(official).url
KurdLookalikeChoice.OPEN_TYPED -> DappSearchResult.KurdName(typed).url
KurdLookalikeChoice.OPEN_TYPED -> typed.url
}
}
@@ -50,6 +50,86 @@
android:lineSpacingMultiplier="1.2"
tools:text="@string/dapp_kurd_refused_message" />
<!-- Who stopped the name, until when, and the hash of their written reasons (D23) -->
<LinearLayout
android:id="@+id/kurdNoticeSuspension"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:background="@drawable/bg_block_12"
android:orientation="vertical"
android:paddingHorizontal="14dp"
android:paddingVertical="12dp"
android:visibility="gone"
tools:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/TextAppearance.NovaFoundation.Regular.Caption1.Secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dapp_kurd_suspended_by" />
<TextView
android:id="@+id/kurdNoticeSuspensionBy"
style="@style/TextAppearance.NovaFoundation.Regular.Caption1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/text_primary" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<TextView
style="@style/TextAppearance.NovaFoundation.Regular.Caption1.Secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dapp_kurd_suspended_until" />
<TextView
android:id="@+id/kurdNoticeSuspensionUntil"
style="@style/TextAppearance.NovaFoundation.Regular.Caption1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/text_primary" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<TextView
style="@style/TextAppearance.NovaFoundation.Regular.Caption1.Secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dapp_kurd_suspended_reason" />
<TextView
android:id="@+id/kurdNoticeSuspensionReason"
style="@style/TextAppearance.NovaFoundation.Regular.Caption1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/text_primary"
android:fontFamily="monospace" />
</LinearLayout>
</LinearLayout>
<io.novafoundation.nova.common.view.PrimaryButton
android:id="@+id/kurdNoticePrimary"
style="@style/Widget.Nova.Button.Primary"
@@ -37,6 +37,13 @@ class SearchDappInteractorTest {
assertEquals("https://serok.gov.kurd/", (offered as DappSearchResult.KurdName).url)
}
@Test
fun `a kurd page address is offered with its path`() = runBlocking {
val offered = interactor.searchDapps("https://dks-news.kurd/a/missing", categoryId = null)[DappSearchGroup.KURD_NAME]!!.single()
assertEquals("https://dks-news.kurd/a/missing", (offered as DappSearchResult.KurdName).url)
}
@Test
fun `an invalid kurd name is offered nowhere`() = runBlocking {
listOf("uni-x--edu.kurd", "dks_news.kurd", "a.b.c.d.e.kurd").forEach { query ->
@@ -4,6 +4,7 @@ import io.novafoundation.nova.runtime.names.KurdName
import io.novafoundation.nova.runtime.names.KurdResolution
import io.novafoundation.nova.runtime.names.NameRecord
import io.novafoundation.nova.runtime.names.NameStatus
import io.novafoundation.nova.runtime.names.NameSuspension
import io.novafoundation.nova.runtime.names.content.Cid
import io.novafoundation.nova.runtime.names.content.KurdSiteServer.PageState
import org.junit.Assert.assertEquals
@@ -51,6 +52,15 @@ class KurdPageUiTest {
assertNull(KurdPageUi.from(name, null))
}
@Test
fun `a suspended name is a notice that carries who stopped it and until when`() {
val suspension = NameSuspension(until = 1_800_000_000_000, reg = 1, reason = "0x00", by = NameSuspension.By.EMERGENCY)
val notice = KurdPageUi.from(name, PageState.Suspended(suspension)) as KurdPageUi.Notice
assertEquals(KurdPageUi.NoticeKind.SUSPENDED, notice.kind)
assertEquals(suspension, notice.suspension)
}
@Test
fun `a feed showing the chain's version says so`() {
val resolution = KurdResolution.Resolved(name, leased(), NameStatus.ACTIVE, verified = true)