From 3ecb62622214d5d7d34c1457269af4e4664dbe51 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Wed, 13 May 2026 07:21:16 +0900 Subject: [PATCH] feat(frontend): deprecate custom domains boundary nodes v0 --- .env.development | 1 - .env.production | 1 - .env.skylab | 1 - .../hosting/CustomDomainActions.svelte | 1 - src/frontend/src/lib/rest/bn.v0.rest.ts | 60 ------------------- .../hosting/custom-domain.services.ts | 21 +------ src/frontend/src/lib/types/custom-domain.ts | 34 ----------- .../src/lib/workers/hosting.worker.ts | 35 +---------- src/frontend/src/vite-env.d.ts | 1 - 9 files changed, 4 insertions(+), 151 deletions(-) delete mode 100644 src/frontend/src/lib/rest/bn.v0.rest.ts diff --git a/.env.development b/.env.development index 759f23b18..b0330868b 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,3 @@ -VITE_BN_REGISTRATIONS_URL=https://icp0.io/registrations VITE_BN_CUSTOM_DOMAINS_URL=https://icp0.io/custom-domains/v1 VITE_JUNO_CDN_URL= VITE_CYCLE_EXPRESS_URL=https://cycle.express/ diff --git a/.env.production b/.env.production index f61b7543d..65fd9bee4 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,3 @@ -VITE_BN_REGISTRATIONS_URL=https://icp0.io/registrations VITE_BN_CUSTOM_DOMAINS_URL=https://icp0.io/custom-domains/v1 VITE_JUNO_CDN_URL=https://cdn.juno.build VITE_CYCLE_EXPRESS_URL=https://cycle.express/ diff --git a/.env.skylab b/.env.skylab index a69e2f4c8..8e0da89e7 100644 --- a/.env.skylab +++ b/.env.skylab @@ -1,4 +1,3 @@ -VITE_BN_REGISTRATIONS_URL= VITE_BN_CUSTOM_DOMAINS_URL= VITE_JUNO_CDN_URL= VITE_CYCLE_EXPRESS_URL= diff --git a/src/frontend/src/lib/components/satellites/hosting/CustomDomainActions.svelte b/src/frontend/src/lib/components/satellites/hosting/CustomDomainActions.svelte index 30e75233c..1ccfa739e 100644 --- a/src/frontend/src/lib/components/satellites/hosting/CustomDomainActions.svelte +++ b/src/frontend/src/lib/components/satellites/hosting/CustomDomainActions.svelte @@ -86,7 +86,6 @@ await deleteCustomDomainService({ satelliteId: satellite.satellite_id, domainName: customDomain[0], - customDomain: customDomain[1], deleteCustomDomain: !skipDeleteDomain, identity: $authIdentity }); diff --git a/src/frontend/src/lib/rest/bn.v0.rest.ts b/src/frontend/src/lib/rest/bn.v0.rest.ts deleted file mode 100644 index 11505b663..000000000 --- a/src/frontend/src/lib/rest/bn.v0.rest.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { SatelliteDid } from '$declarations'; -import type { CustomDomainRegistration } from '$lib/types/custom-domain'; -import { assertNonNullish, fromNullable, isNullish } from '@dfinity/utils'; - -const BN_REGISTRATIONS_URL = import.meta.env.VITE_BN_REGISTRATIONS_URL; - -/** - * @deprecated - */ -export const getCustomDomainRegistrationV0 = async ({ - bn_id -}: SatelliteDid.CustomDomain): Promise => { - const id = fromNullable(bn_id); - - if (isNullish(id) || id === '') { - return undefined; - } - - if (isNullish(BN_REGISTRATIONS_URL)) { - return undefined; - } - - const response = await fetch(`${BN_REGISTRATIONS_URL}/${id}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json' - } - }); - - if (!response.ok) { - const text = await response.text(); - throw new Error(`Fetching custom domain state from the boundary nodes failed. ${text}`); - } - - const result: CustomDomainRegistration['v0']['State'] = await response.json(); - - return result; -}; - -/** - * @deprecated - */ -export const deleteDomainV0 = async ({ bnId }: { bnId: string }): Promise => { - assertNonNullish( - BN_REGISTRATIONS_URL, - 'Boundary Node API URL not defined. This service is unavailable.' - ); - - const response = await fetch(`${BN_REGISTRATIONS_URL}/${bnId}`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json' - } - }); - - if (!response.ok) { - const text = await response.text(); - throw new Error(`Deleting custom domain in the boundary nodes failed. ${text}`); - } -}; diff --git a/src/frontend/src/lib/services/satellite/hosting/custom-domain.services.ts b/src/frontend/src/lib/services/satellite/hosting/custom-domain.services.ts index 8165d0b0c..b1d9e6a86 100644 --- a/src/frontend/src/lib/services/satellite/hosting/custom-domain.services.ts +++ b/src/frontend/src/lib/services/satellite/hosting/custom-domain.services.ts @@ -1,9 +1,7 @@ -import type { SatelliteDid } from '$declarations'; import { deleteCustomDomain as deleteCustomDomainApi, listCustomDomains as listCustomDomainsApi } from '$lib/api/satellites.api'; -import { deleteDomainV0 } from '$lib/rest/bn.v0.rest'; import { deleteDomain } from '$lib/rest/bn.v1.rest'; import { i18n } from '$lib/stores/app/i18n.store'; import { toasts } from '$lib/stores/app/toasts.store'; @@ -11,19 +9,17 @@ import { authStore } from '$lib/stores/auth.store'; import { customDomainsStore } from '$lib/stores/satellite/custom-domains.store'; import type { CustomDomainName } from '$lib/types/custom-domain'; import type { NullishIdentity } from '$lib/types/itentity'; -import { assertNonNullish, fromNullable, nonNullish } from '@dfinity/utils'; +import { assertNonNullish, nonNullish } from '@dfinity/utils'; import type { Principal } from '@icp-sdk/core/principal'; import { get } from 'svelte/store'; export const deleteCustomDomain = async ({ satelliteId, - customDomain, domainName, deleteCustomDomain, identity }: { satelliteId: Principal; - customDomain: SatelliteDid.CustomDomain; domainName: CustomDomainName; deleteCustomDomain: boolean; identity: NullishIdentity; @@ -31,20 +27,7 @@ export const deleteCustomDomain = async ({ assertNonNullish(identity, get(i18n).core.not_logged_in); if (deleteCustomDomain) { - // Delete domain name in BN - const unregisterCustomDomain = async () => { - const bnId = fromNullable(customDomain.bn_id); - if (nonNullish(bnId)) { - await deleteDomainV0({ - bnId - }); - return; - } - - await deleteDomain({ domainName }); - }; - - await unregisterCustomDomain(); + await deleteDomain({ domainName }); } // Remove custom domain from satellite diff --git a/src/frontend/src/lib/types/custom-domain.ts b/src/frontend/src/lib/types/custom-domain.ts index 8ba9c3d87..670e067e4 100644 --- a/src/frontend/src/lib/types/custom-domain.ts +++ b/src/frontend/src/lib/types/custom-domain.ts @@ -23,45 +23,11 @@ export interface CustomDomainDns { entries: [CustomDomainDnsEntry, ...CustomDomainDnsEntry[]]; } -// BN - export type CustomDomainState = z.infer; -/** - * @deprecated - */ -type CustomDomainRegistrationV0State = - | 'PendingOrder' - | 'PendingChallengeResponse' - | 'PendingAcmeApproval' - | 'Available' - | 'Failed'; - -/** - * @deprecated - */ -interface CustomDomainRegistrationV0StateFailed { - Failed: string; -} - -/** - * @deprecated - */ -interface CustomDomainRegistrationV0Response { - name: string; - canister: string; - state: CustomDomainRegistrationV0State | CustomDomainRegistrationV0StateFailed; -} - export type GetCustomDomainState = z.infer; export interface CustomDomainRegistration { - /** - * @deprecated - */ - v0: { - State: CustomDomainRegistrationV0Response; - }; v1: { State: GetCustomDomainState; }; diff --git a/src/frontend/src/lib/workers/hosting.worker.ts b/src/frontend/src/lib/workers/hosting.worker.ts index a38b9fb1e..5d555efaf 100644 --- a/src/frontend/src/lib/workers/hosting.worker.ts +++ b/src/frontend/src/lib/workers/hosting.worker.ts @@ -1,10 +1,8 @@ -import type { SatelliteDid } from '$declarations'; import { SYNC_CUSTOM_DOMAIN_TIMER_INTERVAL } from '$lib/constants/app.constants'; -import { getCustomDomainRegistrationV0 } from '$lib/rest/bn.v0.rest'; import { getCustomDomainRegistration } from '$lib/rest/bn.v1.rest'; import type { CustomDomain, CustomDomainName, CustomDomainState } from '$lib/types/custom-domain'; import type { PostMessageDataRequest, PostMessageRequest } from '$lib/types/post-message'; -import { fromNullable, isNullish, nonNullish } from '@dfinity/utils'; +import { isNullish } from '@dfinity/utils'; export const onHostingMessage = async ({ data: dataMsg }: MessageEvent) => { const { msg, data } = dataMsg; @@ -55,12 +53,7 @@ const syncCustomDomainRegistration = async ({ customDomain }: { customDomain: Cu try { const sync = async (): Promise => { - const [domainName, custom] = customDomain; - - if (nonNullish(fromNullable(custom.bn_id))) { - return await syncCustomDomainRegistrationV0({ customDomain: custom }); - } - + const [domainName] = customDomain; return await syncCustomDomainRegistrationV1({ domain: domainName }); }; @@ -100,30 +93,6 @@ const syncCustomDomainRegistrationV1 = async ({ return 'failed'; }; -const syncCustomDomainRegistrationV0 = async ({ - customDomain -}: { - customDomain: SatelliteDid.CustomDomain; -}): Promise => { - const registration = await getCustomDomainRegistrationV0(customDomain); - const registrationState = nonNullish(registration) - ? typeof registration.state !== 'string' && 'Failed' in registration.state - ? 'Failed' - : registration.state - : null; - - switch (registrationState) { - case 'PendingOrder': - case 'PendingChallengeResponse': - case 'PendingAcmeApproval': - return 'registering'; - case 'Available': - return 'registered'; - default: - return 'failed'; - } -}; - // Update ui with registration state const emit = (registrationState: CustomDomainState | null) => postMessage({ diff --git a/src/frontend/src/vite-env.d.ts b/src/frontend/src/vite-env.d.ts index 70bba9ece..398cd3657 100644 --- a/src/frontend/src/vite-env.d.ts +++ b/src/frontend/src/vite-env.d.ts @@ -13,7 +13,6 @@ interface ImportMetaEnv { readonly VITE_JUNO_API_URL: string | undefined; // .env - readonly VITE_BN_REGISTRATIONS_URL: string | '' | undefined; readonly VITE_BN_CUSTOM_DOMAINS_URL: string | '' | undefined; readonly VITE_JUNO_CDN_URL: string | '' | undefined; readonly VITE_CYCLE_EXPRESS_URL: string | '' | undefined;