Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
1 change: 0 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
1 change: 0 additions & 1 deletion .env.skylab
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VITE_BN_REGISTRATIONS_URL=
VITE_BN_CUSTOM_DOMAINS_URL=
VITE_JUNO_CDN_URL=
VITE_CYCLE_EXPRESS_URL=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
await deleteCustomDomainService({
satelliteId: satellite.satellite_id,
domainName: customDomain[0],
customDomain: customDomain[1],
deleteCustomDomain: !skipDeleteDomain,
identity: $authIdentity
});
Expand Down
60 changes: 0 additions & 60 deletions src/frontend/src/lib/rest/bn.v0.rest.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
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';
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;
}) => {
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
Expand Down
34 changes: 0 additions & 34 deletions src/frontend/src/lib/types/custom-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,11 @@ export interface CustomDomainDns {
entries: [CustomDomainDnsEntry, ...CustomDomainDnsEntry[]];
}

// BN

export type CustomDomainState = z.infer<typeof CustomDomainStateSchema>;

/**
* @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<typeof GetCustomDomainStateSchema>;

export interface CustomDomainRegistration {
/**
* @deprecated
*/
v0: {
State: CustomDomainRegistrationV0Response;
};
v1: {
State: GetCustomDomainState;
};
Expand Down
35 changes: 2 additions & 33 deletions src/frontend/src/lib/workers/hosting.worker.ts
Original file line number Diff line number Diff line change
@@ -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<PostMessageRequest>) => {
const { msg, data } = dataMsg;
Expand Down Expand Up @@ -55,12 +53,7 @@ const syncCustomDomainRegistration = async ({ customDomain }: { customDomain: Cu

try {
const sync = async (): Promise<CustomDomainState> => {
const [domainName, custom] = customDomain;

if (nonNullish(fromNullable(custom.bn_id))) {
return await syncCustomDomainRegistrationV0({ customDomain: custom });
}

const [domainName] = customDomain;
return await syncCustomDomainRegistrationV1({ domain: domainName });
};

Expand Down Expand Up @@ -100,30 +93,6 @@ const syncCustomDomainRegistrationV1 = async ({
return 'failed';
};

const syncCustomDomainRegistrationV0 = async ({
customDomain
}: {
customDomain: SatelliteDid.CustomDomain;
}): Promise<CustomDomainState> => {
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({
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading