Merge dev into fix/log-analytics-adjustments

This commit is contained in:
Fred KISSIE
2025-12-10 03:19:14 +01:00
parent 9db2feff77
commit d490cab48c
555 changed files with 9375 additions and 9287 deletions

View File

@@ -10,7 +10,7 @@ import { GetOrgUserResponse } from "@server/routers/user";
import { AxiosResponse } from "axios";
import { redirect } from "next/navigation";
import { cache } from "react";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type BillingSettingsProps = {
children: React.ReactNode;
@@ -19,7 +19,7 @@ type BillingSettingsProps = {
export default async function BillingSettingsPage({
children,
params,
params
}: BillingSettingsProps) {
const { orgId } = await params;
@@ -35,8 +35,8 @@ export default async function BillingSettingsPage({
const getOrgUser = cache(async () =>
internal.get<AxiosResponse<GetOrgUserResponse>>(
`/org/${orgId}/user/${user.userId}`,
await authCookieHeader(),
),
await authCookieHeader()
)
);
const res = await getOrgUser();
orgUser = res.data.data;
@@ -49,8 +49,8 @@ export default async function BillingSettingsPage({
const getOrg = cache(async () =>
internal.get<AxiosResponse<GetOrgResponse>>(
`/org/${orgId}`,
await authCookieHeader(),
),
await authCookieHeader()
)
);
const res = await getOrg();
org = res.data.data;
@@ -65,11 +65,11 @@ export default async function BillingSettingsPage({
<OrgProvider org={org}>
<OrgUserProvider orgUser={orgUser}>
<SettingsSectionTitle
title={t('billing')}
description={t('orgBillingDescription')}
title={t("billing")}
description={t("orgBillingDescription")}
/>
{children}
{children}
</OrgUserProvider>
</OrgProvider>
</>

View File

@@ -64,10 +64,8 @@ export default function Page() {
clientSecret: z
.string()
.min(1, { message: t("idpClientSecretRequired") }),
authUrl: z.url({ message: t("idpErrorAuthUrlInvalid") })
.optional(),
tokenUrl: z.url({ message: t("idpErrorTokenUrlInvalid") })
.optional(),
authUrl: z.url({ message: t("idpErrorAuthUrlInvalid") }).optional(),
tokenUrl: z.url({ message: t("idpErrorTokenUrlInvalid") }).optional(),
identifierPath: z
.string()
.min(1, { message: t("idpPathRequired") })
@@ -379,9 +377,11 @@ export default function Page() {
>
<AutoProvisionConfigWidget
control={form.control}
autoProvision={form.watch(
"autoProvision"
) as boolean} // is this right?
autoProvision={
form.watch(
"autoProvision"
) as boolean
} // is this right?
onAutoProvisionChange={(checked) => {
form.setValue(
"autoProvision",

View File

@@ -19,18 +19,17 @@ export function ExitNodesDataTable<TData, TValue>({
onRefresh,
isRefreshing
}: DataTableProps<TData, TValue>) {
const t = useTranslations();
return (
<DataTable
columns={columns}
data={data}
title={t('remoteExitNodes')}
searchPlaceholder={t('searchRemoteExitNodes')}
title={t("remoteExitNodes")}
searchPlaceholder={t("searchRemoteExitNodes")}
searchColumn="name"
onAdd={createRemoteExitNode}
addButtonText={t('remoteExitNodeAdd')}
addButtonText={t("remoteExitNodeAdd")}
onRefresh={onRefresh}
isRefreshing={isRefreshing}
defaultSort={{

View File

@@ -35,7 +35,7 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
const navItems = [
{
title: t('credentials'),
title: t("credentials"),
href: "/{orgId}/settings/remote-exit-nodes/{remoteExitNodeId}/credentials"
}
];

View File

@@ -86,7 +86,7 @@ export default function CreateRemoteExitNodePage() {
useEffect(() => {
const remoteExitNodeId = searchParams.get("remoteExitNodeId");
const remoteExitNodeSecret = searchParams.get("remoteExitNodeSecret");
if (remoteExitNodeId && remoteExitNodeSecret) {
setStrategy("adopt");
form.setValue("remoteExitNodeId", remoteExitNodeId);

View File

@@ -1,7 +1,9 @@
import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies";
import { AxiosResponse } from "axios";
import InvitationsTable, { InvitationRow } from "../../../../../components/InvitationsTable";
import InvitationsTable, {
InvitationRow
} from "../../../../../components/InvitationsTable";
import { GetOrgResponse } from "@server/routers/org";
import { cache } from "react";
import OrgProvider from "@app/providers/OrgProvider";
@@ -9,7 +11,7 @@ import UserProvider from "@app/providers/UserProvider";
import { verifySession } from "@app/lib/auth/verifySession";
import AccessPageHeaderAndNav from "../../../../../components/AccessPageHeaderAndNav";
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type InvitationsPageProps = {
params: Promise<{ orgId: string }>;
@@ -68,7 +70,7 @@ export default async function InvitationsPage(props: InvitationsPageProps) {
id: invite.inviteId,
email: invite.email,
expiresAt: new Date(Number(invite.expiresAt)).toISOString(),
role: invite.roleName || t('accessRoleUnknown'),
role: invite.roleName || t("accessRoleUnknown"),
roleId: invite.roleId
};
});
@@ -76,8 +78,8 @@ export default async function InvitationsPage(props: InvitationsPageProps) {
return (
<>
<SettingsSectionTitle
title={t('inviteTitle')}
description={t('inviteDescription')}
title={t("inviteTitle")}
description={t("inviteDescription")}
/>
<UserProvider user={user!}>
<OrgProvider org={org}>

View File

@@ -7,7 +7,7 @@ import OrgProvider from "@app/providers/OrgProvider";
import { ListRolesResponse } from "@server/routers/role";
import RolesTable, { RoleRow } from "../../../../../components/RolesTable";
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type RolesPageProps = {
params: Promise<{ orgId: string }>;
@@ -66,8 +66,8 @@ export default async function RolesPage(props: RolesPageProps) {
return (
<>
<SettingsSectionTitle
title={t('accessRolesManage')}
description={t('accessRolesDescription')}
title={t("accessRolesManage")}
description={t("accessRolesDescription")}
/>
<OrgProvider org={org}>
<RolesTable roles={roleRows} />

View File

@@ -106,7 +106,8 @@ export default function Page() {
const genericOidcFormSchema = z.object({
username: z.string().min(1, { message: t("usernameRequired") }),
email: z.email({ message: t("emailInvalid") })
email: z
.email({ message: t("emailInvalid") })
.optional()
.or(z.literal("")),
name: z.string().optional(),

View File

@@ -10,7 +10,7 @@ import UserProvider from "@app/providers/UserProvider";
import { verifySession } from "@app/lib/auth/verifySession";
import AccessPageHeaderAndNav from "../../../../../components/AccessPageHeaderAndNav";
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type UsersPageProps = {
params: Promise<{ orgId: string }>;
@@ -79,9 +79,11 @@ export default async function UsersPage(props: UsersPageProps) {
type: user.type,
idpVariant: user.idpVariant,
idpId: user.idpId,
idpName: user.idpName || t('idpNameInternal'),
status: t('userConfirmed'),
role: user.isOwner ? t('accessRoleOwner') : user.roleName || t('accessRoleMember'),
idpName: user.idpName || t("idpNameInternal"),
status: t("userConfirmed"),
role: user.isOwner
? t("accessRoleOwner")
: user.roleName || t("accessRoleMember"),
isOwner: user.isOwner || false
};
});
@@ -89,8 +91,8 @@ export default async function UsersPage(props: UsersPageProps) {
return (
<>
<SettingsSectionTitle
title={t('accessUsersManage')}
description={t('accessUsersDescription')}
title={t("accessUsersManage")}
description={t("accessUsersDescription")}
/>
<UserProvider user={user!}>
<OrgProvider org={org}>

View File

@@ -6,7 +6,7 @@ import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import { GetApiKeyResponse } from "@server/routers/apiKeys";
import ApiKeyProvider from "@app/providers/ApiKeyProvider";
import { HorizontalTabs } from "@app/components/HorizontalTabs";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
interface SettingsLayoutProps {
children: React.ReactNode;
@@ -33,14 +33,16 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
const navItems = [
{
title: t('apiKeysPermissionsTitle'),
title: t("apiKeysPermissionsTitle"),
href: "/{orgId}/settings/api-keys/{apiKeyId}/permissions"
}
];
return (
<>
<SettingsSectionTitle title={t('apiKeysSettings', {apiKeyName: apiKey?.name})} />
<SettingsSectionTitle
title={t("apiKeysSettings", { apiKeyName: apiKey?.name })}
/>
<ApiKeyProvider apiKey={apiKey}>
<HorizontalTabs items={navItems}>{children}</HorizontalTabs>

View File

@@ -4,5 +4,7 @@ export default async function ApiKeysPage(props: {
params: Promise<{ orgId: string; apiKeyId: string }>;
}) {
const params = await props.params;
redirect(`/${params.orgId}/settings/api-keys/${params.apiKeyId}/permissions`);
redirect(
`/${params.orgId}/settings/api-keys/${params.apiKeyId}/permissions`
);
}

View File

@@ -45,10 +45,10 @@ export default function Page() {
.catch((e) => {
toast({
variant: "destructive",
title: t('apiKeysPermissionsErrorLoadingActions'),
title: t("apiKeysPermissionsErrorLoadingActions"),
description: formatAxiosError(
e,
t('apiKeysPermissionsErrorLoadingActions')
t("apiKeysPermissionsErrorLoadingActions")
)
});
});
@@ -79,18 +79,18 @@ export default function Page() {
)
})
.catch((e) => {
console.error(t('apiKeysErrorSetPermission'), e);
console.error(t("apiKeysErrorSetPermission"), e);
toast({
variant: "destructive",
title: t('apiKeysErrorSetPermission'),
title: t("apiKeysErrorSetPermission"),
description: formatAxiosError(e)
});
});
if (actionsRes && actionsRes.status === 200) {
toast({
title: t('apiKeysPermissionsUpdated'),
description: t('apiKeysPermissionsUpdatedDescription')
title: t("apiKeysPermissionsUpdated"),
description: t("apiKeysPermissionsUpdatedDescription")
});
}
@@ -104,10 +104,12 @@ export default function Page() {
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>
{t('apiKeysPermissionsGeneralSettings')}
{t("apiKeysPermissionsGeneralSettings")}
</SettingsSectionTitle>
<SettingsSectionDescription>
{t('apiKeysPermissionsGeneralSettingsDescription')}
{t(
"apiKeysPermissionsGeneralSettingsDescription"
)}
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionBody>
@@ -124,7 +126,7 @@ export default function Page() {
loading={loadingSavePermissions}
disabled={loadingSavePermissions}
>
{t('apiKeysPermissionsSave')}
{t("apiKeysPermissionsSave")}
</Button>
</SettingsSectionFooter>
</SettingsSectionBody>

View File

@@ -66,10 +66,10 @@ export default function Page() {
name: z
.string()
.min(2, {
message: t('nameMin', {len: 2})
message: t("nameMin", { len: 2 })
})
.max(255, {
message: t('nameMax', {len: 255})
message: t("nameMax", { len: 255 })
})
});
@@ -84,7 +84,7 @@ export default function Page() {
return data.copied;
},
{
message: t('apiKeysConfirmCopy2'),
message: t("apiKeysConfirmCopy2"),
path: ["copied"]
}
);
@@ -119,7 +119,7 @@ export default function Page() {
.catch((e) => {
toast({
variant: "destructive",
title: t('apiKeysErrorCreate'),
title: t("apiKeysErrorCreate"),
description: formatAxiosError(e)
});
});
@@ -140,10 +140,10 @@ export default function Page() {
)
})
.catch((e) => {
console.error(t('apiKeysErrorSetPermission'), e);
console.error(t("apiKeysErrorSetPermission"), e);
toast({
variant: "destructive",
title: t('apiKeysErrorSetPermission'),
title: t("apiKeysErrorSetPermission"),
description: formatAxiosError(e)
});
});
@@ -182,8 +182,8 @@ export default function Page() {
<>
<div className="flex justify-between">
<HeaderTitle
title={t('apiKeysCreate')}
description={t('apiKeysCreateDescription')}
title={t("apiKeysCreate")}
description={t("apiKeysCreateDescription")}
/>
<Button
variant="outline"
@@ -191,7 +191,7 @@ export default function Page() {
router.push(`/${orgId}/settings/api-keys`);
}}
>
{t('apiKeysSeeAll')}
{t("apiKeysSeeAll")}
</Button>
</div>
@@ -203,7 +203,7 @@ export default function Page() {
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>
{t('apiKeysTitle')}
{t("apiKeysTitle")}
</SettingsSectionTitle>
</SettingsSectionHeader>
<SettingsSectionBody>
@@ -224,7 +224,7 @@ export default function Page() {
render={({ field }) => (
<FormItem>
<FormLabel>
{t('name')}
{t("name")}
</FormLabel>
<FormControl>
<Input
@@ -245,10 +245,12 @@ export default function Page() {
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>
{t('apiKeysGeneralSettings')}
{t("apiKeysGeneralSettings")}
</SettingsSectionTitle>
<SettingsSectionDescription>
{t('apiKeysGeneralSettingsDescription')}
{t(
"apiKeysGeneralSettingsDescription"
)}
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionBody>
@@ -267,14 +269,14 @@ export default function Page() {
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>
{t('apiKeysList')}
{t("apiKeysList")}
</SettingsSectionTitle>
</SettingsSectionHeader>
<SettingsSectionBody>
<InfoSections cols={2}>
<InfoSection>
<InfoSectionTitle>
{t('name')}
{t("name")}
</InfoSectionTitle>
<InfoSectionContent>
<CopyToClipboard
@@ -284,7 +286,7 @@ export default function Page() {
</InfoSection>
<InfoSection>
<InfoSectionTitle>
{t('created')}
{t("created")}
</InfoSectionTitle>
<InfoSectionContent>
{moment(
@@ -297,10 +299,10 @@ export default function Page() {
<Alert variant="neutral">
<InfoIcon className="h-4 w-4" />
<AlertTitle className="font-semibold">
{t('apiKeysSave')}
{t("apiKeysSave")}
</AlertTitle>
<AlertDescription>
{t('apiKeysSaveDescription')}
{t("apiKeysSaveDescription")}
</AlertDescription>
</Alert>
@@ -367,7 +369,7 @@ export default function Page() {
router.push(`/${orgId}/settings/api-keys`);
}}
>
{t('cancel')}
{t("cancel")}
</Button>
)}
{!apiKey && (
@@ -379,7 +381,7 @@ export default function Page() {
form.handleSubmit(onSubmit)();
}}
>
{t('generate')}
{t("generate")}
</Button>
)}
@@ -390,7 +392,7 @@ export default function Page() {
copiedForm.handleSubmit(onCopiedSubmit)();
}}
>
{t('done')}
{t("done")}
</Button>
)}
</div>

View File

@@ -2,9 +2,11 @@ import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies";
import { AxiosResponse } from "axios";
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import OrgApiKeysTable, { OrgApiKeyRow } from "../../../../components/OrgApiKeysTable";
import OrgApiKeysTable, {
OrgApiKeyRow
} from "../../../../components/OrgApiKeysTable";
import { ListOrgApiKeysResponse } from "@server/routers/apiKeys";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type ApiKeyPageProps = {
params: Promise<{ orgId: string }>;
@@ -37,8 +39,8 @@ export default async function ApiKeysPage(props: ApiKeyPageProps) {
return (
<>
<SettingsSectionTitle
title={t('apiKeysManage')}
description={t('apiKeysDescription')}
title={t("apiKeysManage")}
description={t("apiKeysDescription")}
/>
<OrgApiKeysTable apiKeys={rows} orgId={params.orgId} />

View File

@@ -21,7 +21,10 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
let client = null;
try {
console.log("making request to ", `/org/${params.orgId}/client/${params.niceId}`);
console.log(
"making request to ",
`/org/${params.orgId}/client/${params.niceId}`
);
const res = await internal.get<AxiosResponse<GetClientResponse>>(
`/org/${params.orgId}/client/${params.niceId}`,
await authCookieHeader()

View File

@@ -10,7 +10,7 @@ import { GetOrgUserResponse } from "@server/routers/user";
import { AxiosResponse } from "axios";
import { redirect } from "next/navigation";
import { cache } from "react";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type GeneralSettingsProps = {
children: React.ReactNode;
@@ -19,7 +19,7 @@ type GeneralSettingsProps = {
export default async function GeneralSettingsPage({
children,
params,
params
}: GeneralSettingsProps) {
const { orgId } = await params;
@@ -35,8 +35,8 @@ export default async function GeneralSettingsPage({
const getOrgUser = cache(async () =>
internal.get<AxiosResponse<GetOrgUserResponse>>(
`/org/${orgId}/user/${user.userId}`,
await authCookieHeader(),
),
await authCookieHeader()
)
);
const res = await getOrgUser();
orgUser = res.data.data;
@@ -49,8 +49,8 @@ export default async function GeneralSettingsPage({
const getOrg = cache(async () =>
internal.get<AxiosResponse<GetOrgResponse>>(
`/org/${orgId}`,
await authCookieHeader(),
),
await authCookieHeader()
)
);
const res = await getOrg();
org = res.data.data;
@@ -62,9 +62,9 @@ export default async function GeneralSettingsPage({
const navItems = [
{
title: t('general'),
href: `/{orgId}/settings/general`,
},
title: t("general"),
href: `/{orgId}/settings/general`
}
];
return (
@@ -72,13 +72,11 @@ export default async function GeneralSettingsPage({
<OrgProvider org={org}>
<OrgUserProvider orgUser={orgUser}>
<SettingsSectionTitle
title={t('orgGeneralSettings')}
description={t('orgSettingsDescription')}
title={t("orgGeneralSettings")}
description={t("orgSettingsDescription")}
/>
<HorizontalTabs items={navItems}>
{children}
</HorizontalTabs>
<HorizontalTabs items={navItems}>{children}</HorizontalTabs>
</OrgUserProvider>
</OrgProvider>
</>

View File

@@ -11,12 +11,13 @@ import { Button } from "@app/components/ui/button";
import { useEnvContext } from "@app/hooks/useEnvContext";
import { toast } from "@app/hooks/useToast";
import { createApiClient } from "@app/lib/api";
import { useParams, useRouter, useSearchParams } from "next/navigation";
import { useTranslations } from "next-intl";
import { getSevenDaysAgo } from "@app/lib/getSevenDaysAgo";
import { ColumnDef } from "@tanstack/react-table";
import { ArrowUpRight, Key, Lock, Unlock, User } from "lucide-react";
import { useTranslations } from "next-intl";
import Link from "next/link";
import { useParams, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
export default function GeneralPage() {

View File

@@ -837,7 +837,9 @@ export default function ResourceAuthenticationPage() {
<Bot size="14" />
<span>
{authInfo.headerAuth
? t("resourceHeaderAuthProtectionEnabled")
? t(
"resourceHeaderAuthProtectionEnabled"
)
: t(
"resourceHeaderAuthProtectionDisabled"
)}
@@ -921,7 +923,8 @@ export default function ResourceAuthenticationPage() {
validateTag={(
tag
) => {
return z.email()
return z
.email()
.or(
z
.string()

View File

@@ -104,7 +104,7 @@ export default function GeneralForm() {
name: z.string().min(1).max(255),
niceId: z.string().min(1).max(255).optional(),
domainId: z.string().optional(),
proxyPort: z.int().min(1).max(65535).optional(),
proxyPort: z.int().min(1).max(65535).optional()
// enableProxy: z.boolean().optional()
})
.refine(
@@ -134,7 +134,7 @@ export default function GeneralForm() {
niceId: resource.niceId,
subdomain: resource.subdomain ? resource.subdomain : undefined,
domainId: resource.domainId || undefined,
proxyPort: resource.proxyPort || undefined,
proxyPort: resource.proxyPort || undefined
// enableProxy: resource.enableProxy || false
},
mode: "onChange"
@@ -168,7 +168,7 @@ export default function GeneralForm() {
const rawDomains = res.data.data.domains as DomainRow[];
const domains = rawDomains.map((domain) => ({
...domain,
baseDomain: toUnicode(domain.baseDomain),
baseDomain: toUnicode(domain.baseDomain)
}));
setBaseDomains(domains);
setFormKey((key) => key + 1);
@@ -195,9 +195,11 @@ export default function GeneralForm() {
enabled: data.enabled,
name: data.name,
niceId: data.niceId,
subdomain: data.subdomain ? toASCII(data.subdomain) : undefined,
subdomain: data.subdomain
? toASCII(data.subdomain)
: undefined,
domainId: data.domainId,
proxyPort: data.proxyPort,
proxyPort: data.proxyPort
// ...(!resource.http && {
// enableProxy: data.enableProxy
// })
@@ -223,7 +225,7 @@ export default function GeneralForm() {
niceId: data.niceId,
subdomain: data.subdomain,
fullDomain: resource.fullDomain,
proxyPort: data.proxyPort,
proxyPort: data.proxyPort
// ...(!resource.http && {
// enableProxy: data.enableProxy
// })
@@ -235,7 +237,9 @@ export default function GeneralForm() {
});
if (data.niceId && data.niceId !== resource?.niceId) {
router.replace(`/${updated.orgId}/settings/resources/proxy/${data.niceId}/general`);
router.replace(
`/${updated.orgId}/settings/resources/proxy/${data.niceId}/general`
);
} else {
router.refresh();
}
@@ -320,11 +324,15 @@ export default function GeneralForm() {
name="niceId"
render={({ field }) => (
<FormItem>
<FormLabel>{t("identifier")}</FormLabel>
<FormLabel>
{t("identifier")}
</FormLabel>
<FormControl>
<Input
{...field}
placeholder={t("enterIdentifier")}
placeholder={t(
"enterIdentifier"
)}
className="flex-1"
/>
</FormControl>
@@ -360,10 +368,10 @@ export default function GeneralForm() {
.target
.value
? parseInt(
e
.target
.value
)
e
.target
.value
)
: undefined
)
}
@@ -498,17 +506,29 @@ export default function GeneralForm() {
<Button
onClick={() => {
if (selectedDomain) {
const sanitizedSubdomain = selectedDomain.subdomain
? finalizeSubdomainSanitize(selectedDomain.subdomain)
: "";
const sanitizedSubdomain =
selectedDomain.subdomain
? finalizeSubdomainSanitize(
selectedDomain.subdomain
)
: "";
const sanitizedFullDomain = sanitizedSubdomain
? `${sanitizedSubdomain}.${selectedDomain.baseDomain}`
: selectedDomain.baseDomain;
const sanitizedFullDomain =
sanitizedSubdomain
? `${sanitizedSubdomain}.${selectedDomain.baseDomain}`
: selectedDomain.baseDomain;
setResourceFullDomain(`${resource.ssl ? "https" : "http"}://${sanitizedFullDomain}`);
form.setValue("domainId", selectedDomain.domainId);
form.setValue("subdomain", sanitizedSubdomain);
setResourceFullDomain(
`${resource.ssl ? "https" : "http"}://${sanitizedFullDomain}`
);
form.setValue(
"domainId",
selectedDomain.domainId
);
form.setValue(
"subdomain",
sanitizedSubdomain
);
setEditDomainOpen(false);
}

View File

@@ -14,7 +14,7 @@ import OrgProvider from "@app/providers/OrgProvider";
import { cache } from "react";
import ResourceInfoBox from "@app/components/ResourceInfoBox";
import { GetSiteResponse } from "@server/routers/site";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
interface ResourceLayoutProps {
children: React.ReactNode;
@@ -76,22 +76,22 @@ export default async function ResourceLayout(props: ResourceLayoutProps) {
const navItems = [
{
title: t('general'),
title: t("general"),
href: `/{orgId}/settings/resources/proxy/{niceId}/general`
},
{
title: t('proxy'),
title: t("proxy"),
href: `/{orgId}/settings/resources/proxy/{niceId}/proxy`
}
];
if (resource.http) {
navItems.push({
title: t('authentication'),
title: t("authentication"),
href: `/{orgId}/settings/resources/proxy/{niceId}/authentication`
});
navItems.push({
title: t('rules'),
title: t("rules"),
href: `/{orgId}/settings/resources/proxy/{niceId}/rules`
});
}
@@ -99,15 +99,12 @@ export default async function ResourceLayout(props: ResourceLayoutProps) {
return (
<>
<SettingsSectionTitle
title={t('resourceSetting', {resourceName: resource?.name})}
description={t('resourceSettingDescription')}
title={t("resourceSetting", { resourceName: resource?.name })}
description={t("resourceSettingDescription")}
/>
<OrgProvider org={org}>
<ResourceProvider
resource={resource}
authInfo={authInfo}
>
<ResourceProvider resource={resource} authInfo={authInfo}>
<div className="space-y-6">
<ResourceInfoBox />
<HorizontalTabs items={navItems}>

View File

@@ -114,23 +114,25 @@ export default function ResourceRules(props: {
const [rulesEnabled, setRulesEnabled] = useState(resource.applyRules);
const [openCountrySelect, setOpenCountrySelect] = useState(false);
const [countrySelectValue, setCountrySelectValue] = useState("");
const [openAddRuleCountrySelect, setOpenAddRuleCountrySelect] = useState(false);
const [openAddRuleCountrySelect, setOpenAddRuleCountrySelect] =
useState(false);
const router = useRouter();
const t = useTranslations();
const { env } = useEnvContext();
const isMaxmindAvailable = env.server.maxmind_db_path && env.server.maxmind_db_path.length > 0;
const isMaxmindAvailable =
env.server.maxmind_db_path && env.server.maxmind_db_path.length > 0;
const RuleAction = {
ACCEPT: t('alwaysAllow'),
DROP: t('alwaysDeny'),
PASS: t('passToAuth')
ACCEPT: t("alwaysAllow"),
DROP: t("alwaysDeny"),
PASS: t("passToAuth")
} as const;
const RuleMatch = {
PATH: t('path'),
PATH: t("path"),
IP: "IP",
CIDR: t('ipAddressRange'),
COUNTRY: t('country')
CIDR: t("ipAddressRange"),
COUNTRY: t("country")
} as const;
const addRuleForm = useForm({
@@ -155,10 +157,10 @@ export default function ResourceRules(props: {
console.error(err);
toast({
variant: "destructive",
title: t('rulesErrorFetch'),
title: t("rulesErrorFetch"),
description: formatAxiosError(
err,
t('rulesErrorFetchDescription')
t("rulesErrorFetchDescription")
)
});
} finally {
@@ -179,8 +181,8 @@ export default function ResourceRules(props: {
if (isDuplicate) {
toast({
variant: "destructive",
title: t('rulesErrorDuplicate'),
description: t('rulesErrorDuplicateDescription')
title: t("rulesErrorDuplicate"),
description: t("rulesErrorDuplicateDescription")
});
return;
}
@@ -188,8 +190,8 @@ export default function ResourceRules(props: {
if (data.match === "CIDR" && !isValidCIDR(data.value)) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidIpAddressRange'),
description: t('rulesErrorInvalidIpAddressRangeDescription')
title: t("rulesErrorInvalidIpAddressRange"),
description: t("rulesErrorInvalidIpAddressRangeDescription")
});
setLoading(false);
return;
@@ -197,8 +199,8 @@ export default function ResourceRules(props: {
if (data.match === "PATH" && !isValidUrlGlobPattern(data.value)) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidUrl'),
description: t('rulesErrorInvalidUrlDescription')
title: t("rulesErrorInvalidUrl"),
description: t("rulesErrorInvalidUrlDescription")
});
setLoading(false);
return;
@@ -206,17 +208,22 @@ export default function ResourceRules(props: {
if (data.match === "IP" && !isValidIP(data.value)) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidIpAddress'),
description: t('rulesErrorInvalidIpAddressDescription')
title: t("rulesErrorInvalidIpAddress"),
description: t("rulesErrorInvalidIpAddressDescription")
});
setLoading(false);
return;
}
if (data.match === "COUNTRY" && !COUNTRIES.some(c => c.code === data.value)) {
if (
data.match === "COUNTRY" &&
!COUNTRIES.some((c) => c.code === data.value)
) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidCountry'),
description: t('rulesErrorInvalidCountryDescription') || "Invalid country code."
title: t("rulesErrorInvalidCountry"),
description:
t("rulesErrorInvalidCountryDescription") ||
"Invalid country code."
});
setLoading(false);
return;
@@ -265,13 +272,13 @@ export default function ResourceRules(props: {
function getValueHelpText(type: string) {
switch (type) {
case "CIDR":
return t('rulesMatchIpAddressRangeDescription');
return t("rulesMatchIpAddressRangeDescription");
case "IP":
return t('rulesMatchIpAddress');
return t("rulesMatchIpAddress");
case "PATH":
return t('rulesMatchUrl');
return t("rulesMatchUrl");
case "COUNTRY":
return t('rulesMatchCountry');
return t("rulesMatchCountry");
}
}
@@ -288,10 +295,10 @@ export default function ResourceRules(props: {
console.error(err);
toast({
variant: "destructive",
title: t('rulesErrorUpdate'),
title: t("rulesErrorUpdate"),
description: formatAxiosError(
err,
t('rulesErrorUpdateDescription')
t("rulesErrorUpdateDescription")
)
});
throw err;
@@ -314,8 +321,10 @@ export default function ResourceRules(props: {
if (rule.match === "CIDR" && !isValidCIDR(rule.value)) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidIpAddressRange'),
description: t('rulesErrorInvalidIpAddressRangeDescription')
title: t("rulesErrorInvalidIpAddressRange"),
description: t(
"rulesErrorInvalidIpAddressRangeDescription"
)
});
setLoading(false);
return;
@@ -326,8 +335,8 @@ export default function ResourceRules(props: {
) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidUrl'),
description: t('rulesErrorInvalidUrlDescription')
title: t("rulesErrorInvalidUrl"),
description: t("rulesErrorInvalidUrlDescription")
});
setLoading(false);
return;
@@ -335,8 +344,8 @@ export default function ResourceRules(props: {
if (rule.match === "IP" && !isValidIP(rule.value)) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidIpAddress'),
description: t('rulesErrorInvalidIpAddressDescription')
title: t("rulesErrorInvalidIpAddress"),
description: t("rulesErrorInvalidIpAddressDescription")
});
setLoading(false);
return;
@@ -345,8 +354,8 @@ export default function ResourceRules(props: {
if (rule.priority === undefined) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidPriority'),
description: t('rulesErrorInvalidPriorityDescription')
title: t("rulesErrorInvalidPriority"),
description: t("rulesErrorInvalidPriorityDescription")
});
setLoading(false);
return;
@@ -357,8 +366,8 @@ export default function ResourceRules(props: {
if (priorities.length !== new Set(priorities).size) {
toast({
variant: "destructive",
title: t('rulesErrorDuplicatePriority'),
description: t('rulesErrorDuplicatePriorityDescription')
title: t("rulesErrorDuplicatePriority"),
description: t("rulesErrorDuplicatePriorityDescription")
});
setLoading(false);
return;
@@ -397,8 +406,8 @@ export default function ResourceRules(props: {
}
toast({
title: t('ruleUpdated'),
description: t('ruleUpdatedDescription')
title: t("ruleUpdated"),
description: t("ruleUpdatedDescription")
});
setRulesToRemove([]);
@@ -407,10 +416,10 @@ export default function ResourceRules(props: {
console.error(err);
toast({
variant: "destructive",
title: t('ruleErrorUpdate'),
title: t("ruleErrorUpdate"),
description: formatAxiosError(
err,
t('ruleErrorUpdateDescription')
t("ruleErrorUpdateDescription")
)
});
}
@@ -428,7 +437,7 @@ export default function ResourceRules(props: {
column.toggleSorting(column.getIsSorted() === "asc")
}
>
{t('rulesPriority')}
{t("rulesPriority")}
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
@@ -440,15 +449,18 @@ export default function ResourceRules(props: {
type="number"
onClick={(e) => e.currentTarget.focus()}
onBlur={(e) => {
const parsed = z.int()
const parsed = z
.int()
.optional()
.safeParse(e.target.value);
if (!parsed.data) {
toast({
variant: "destructive",
title: t('rulesErrorInvalidIpAddress'), // correct priority or IP?
description: t('rulesErrorInvalidPriorityDescription')
title: t("rulesErrorInvalidIpAddress"), // correct priority or IP?
description: t(
"rulesErrorInvalidPriorityDescription"
)
});
setLoading(false);
return;
@@ -463,7 +475,7 @@ export default function ResourceRules(props: {
},
{
accessorKey: "action",
header: () => (<span className="p-3">{t('rulesAction')}</span>),
header: () => <span className="p-3">{t("rulesAction")}</span>,
cell: ({ row }) => (
<Select
defaultValue={row.original.action}
@@ -486,12 +498,18 @@ export default function ResourceRules(props: {
},
{
accessorKey: "match",
header: () => (<span className="p-3">{t('rulesMatchType')}</span>),
header: () => <span className="p-3">{t("rulesMatchType")}</span>,
cell: ({ row }) => (
<Select
defaultValue={row.original.match}
onValueChange={(value: "CIDR" | "IP" | "PATH" | "COUNTRY") =>
updateRule(row.original.ruleId, { match: value, value: value === "COUNTRY" ? "US" : row.original.value })
onValueChange={(
value: "CIDR" | "IP" | "PATH" | "COUNTRY"
) =>
updateRule(row.original.ruleId, {
match: value,
value:
value === "COUNTRY" ? "US" : row.original.value
})
}
>
<SelectTrigger className="min-w-[125px]">
@@ -502,7 +520,9 @@ export default function ResourceRules(props: {
<SelectItem value="IP">{RuleMatch.IP}</SelectItem>
<SelectItem value="CIDR">{RuleMatch.CIDR}</SelectItem>
{isMaxmindAvailable && (
<SelectItem value="COUNTRY">{RuleMatch.COUNTRY}</SelectItem>
<SelectItem value="COUNTRY">
{RuleMatch.COUNTRY}
</SelectItem>
)}
</SelectContent>
</Select>
@@ -510,8 +530,8 @@ export default function ResourceRules(props: {
},
{
accessorKey: "value",
header: () => (<span className="p-3">{t('value')}</span>),
cell: ({ row }) => (
header: () => <span className="p-3">{t("value")}</span>,
cell: ({ row }) =>
row.original.match === "COUNTRY" ? (
<Popover>
<PopoverTrigger asChild>
@@ -521,29 +541,43 @@ export default function ResourceRules(props: {
className="min-w-[200px] justify-between"
>
{row.original.value
? COUNTRIES.find((country) => country.code === row.original.value)?.name +
" (" + row.original.value + ")"
: t('selectCountry')}
? COUNTRIES.find(
(country) =>
country.code ===
row.original.value
)?.name +
" (" +
row.original.value +
")"
: t("selectCountry")}
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="min-w-[200px] p-0">
<Command>
<CommandInput placeholder={t('searchCountries')} />
<CommandInput
placeholder={t("searchCountries")}
/>
<CommandList>
<CommandEmpty>{t('noCountryFound')}</CommandEmpty>
<CommandEmpty>
{t("noCountryFound")}
</CommandEmpty>
<CommandGroup>
{COUNTRIES.map((country) => (
<CommandItem
key={country.code}
value={country.name}
onSelect={() => {
updateRule(row.original.ruleId, { value: country.code });
updateRule(
row.original.ruleId,
{ value: country.code }
);
}}
>
<Check
className={`mr-2 h-4 w-4 ${
row.original.value === country.code
row.original.value ===
country.code
? "opacity-100"
: "opacity-0"
}`}
@@ -567,11 +601,10 @@ export default function ResourceRules(props: {
}
/>
)
)
},
{
accessorKey: "enabled",
header: () => (<span className="p-3">{t('enabled')}</span>),
header: () => <span className="p-3">{t("enabled")}</span>,
cell: ({ row }) => (
<Switch
defaultChecked={row.original.enabled}
@@ -583,14 +616,14 @@ export default function ResourceRules(props: {
},
{
id: "actions",
header: () => (<span className="p-3">{t('actions')}</span>),
header: () => <span className="p-3">{t("actions")}</span>,
cell: ({ row }) => (
<div className="flex items-center space-x-2">
<Button
variant="outline"
onClick={() => removeRule(row.original.ruleId)}
>
{t('delete')}
{t("delete")}
</Button>
</div>
)
@@ -664,10 +697,10 @@ export default function ResourceRules(props: {
<SettingsSection>
<SettingsSectionHeader>
<SettingsSectionTitle>
{t('rulesResource')}
{t("rulesResource")}
</SettingsSectionTitle>
<SettingsSectionDescription>
{t('rulesResourceDescription')}
{t("rulesResourceDescription")}
</SettingsSectionDescription>
</SettingsSectionHeader>
<SettingsSectionBody>
@@ -675,7 +708,7 @@ export default function ResourceRules(props: {
<div className="flex items-center space-x-2">
<SwitchInput
id="rules-toggle"
label={t('rulesEnable')}
label={t("rulesEnable")}
defaultChecked={rulesEnabled}
onCheckedChange={(val) => setRulesEnabled(val)}
/>
@@ -692,7 +725,9 @@ export default function ResourceRules(props: {
name="action"
render={({ field }) => (
<FormItem>
<FormLabel>{t('rulesAction')}</FormLabel>
<FormLabel>
{t("rulesAction")}
</FormLabel>
<FormControl>
<Select
value={field.value}
@@ -705,13 +740,19 @@ export default function ResourceRules(props: {
</SelectTrigger>
<SelectContent>
<SelectItem value="ACCEPT">
{RuleAction.ACCEPT}
{
RuleAction.ACCEPT
}
</SelectItem>
<SelectItem value="DROP">
{RuleAction.DROP}
{
RuleAction.DROP
}
</SelectItem>
<SelectItem value="PASS">
{RuleAction.PASS}
{
RuleAction.PASS
}
</SelectItem>
</SelectContent>
</Select>
@@ -725,11 +766,15 @@ export default function ResourceRules(props: {
name="match"
render={({ field }) => (
<FormItem>
<FormLabel>{t('rulesMatchType')}</FormLabel>
<FormLabel>
{t("rulesMatchType")}
</FormLabel>
<FormControl>
<Select
value={field.value}
onValueChange={field.onChange}
onValueChange={
field.onChange
}
>
<SelectTrigger className="w-full">
<SelectValue />
@@ -737,7 +782,9 @@ export default function ResourceRules(props: {
<SelectContent>
{resource.http && (
<SelectItem value="PATH">
{RuleMatch.PATH}
{
RuleMatch.PATH
}
</SelectItem>
)}
<SelectItem value="IP">
@@ -748,7 +795,9 @@ export default function ResourceRules(props: {
</SelectItem>
{isMaxmindAvailable && (
<SelectItem value="COUNTRY">
{RuleMatch.COUNTRY}
{
RuleMatch.COUNTRY
}
</SelectItem>
)}
</SelectContent>
@@ -764,7 +813,7 @@ export default function ResourceRules(props: {
render={({ field }) => (
<FormItem className="gap-1">
<InfoPopup
text={t('value')}
text={t("value")}
info={
getValueHelpText(
addRuleForm.watch(
@@ -774,47 +823,100 @@ export default function ResourceRules(props: {
}
/>
<FormControl>
{addRuleForm.watch("match") === "COUNTRY" ? (
<Popover open={openAddRuleCountrySelect} onOpenChange={setOpenAddRuleCountrySelect}>
<PopoverTrigger asChild>
{addRuleForm.watch(
"match"
) === "COUNTRY" ? (
<Popover
open={
openAddRuleCountrySelect
}
onOpenChange={
setOpenAddRuleCountrySelect
}
>
<PopoverTrigger
asChild
>
<Button
variant="outline"
role="combobox"
aria-expanded={openAddRuleCountrySelect}
aria-expanded={
openAddRuleCountrySelect
}
className="w-full justify-between"
>
{field.value
? COUNTRIES.find((country) => country.code === field.value)?.name +
" (" + field.value + ")"
: t('selectCountry')}
? COUNTRIES.find(
(
country
) =>
country.code ===
field.value
)
?.name +
" (" +
field.value +
")"
: t(
"selectCountry"
)}
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-full p-0">
<Command>
<CommandInput placeholder={t('searchCountries')} />
<CommandInput
placeholder={t(
"searchCountries"
)}
/>
<CommandList>
<CommandEmpty>{t('noCountryFound')}</CommandEmpty>
<CommandEmpty>
{t(
"noCountryFound"
)}
</CommandEmpty>
<CommandGroup>
{COUNTRIES.map((country) => (
<CommandItem
key={country.code}
value={country.name}
onSelect={() => {
field.onChange(country.code);
setOpenAddRuleCountrySelect(false);
}}
>
<Check
className={`mr-2 h-4 w-4 ${
field.value === country.code
? "opacity-100"
: "opacity-0"
}`}
/>
{country.name} ({country.code})
</CommandItem>
))}
{COUNTRIES.map(
(
country
) => (
<CommandItem
key={
country.code
}
value={
country.name
}
onSelect={() => {
field.onChange(
country.code
);
setOpenAddRuleCountrySelect(
false
);
}}
>
<Check
className={`mr-2 h-4 w-4 ${
field.value ===
country.code
? "opacity-100"
: "opacity-0"
}`}
/>
{
country.name
}{" "}
(
{
country.code
}
)
</CommandItem>
)
)}
</CommandGroup>
</CommandList>
</Command>
@@ -833,7 +935,7 @@ export default function ResourceRules(props: {
variant="outline"
disabled={!rulesEnabled}
>
{t('ruleSubmit')}
{t("ruleSubmit")}
</Button>
</div>
</form>
@@ -843,16 +945,22 @@ export default function ResourceRules(props: {
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
const isActionsColumn = header.column.id === "actions";
const isActionsColumn =
header.column.id === "actions";
return (
<TableHead
key={header.id}
className={isActionsColumn ? "sticky right-0 z-10 w-auto min-w-fit bg-card" : ""}
className={
isActionsColumn
? "sticky right-0 z-10 w-auto min-w-fit bg-card"
: ""
}
>
{header.isPlaceholder
? null
: flexRender(
header.column.columnDef
header.column
.columnDef
.header,
header.getContext()
)}
@@ -866,20 +974,30 @@ export default function ResourceRules(props: {
{table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow key={row.id}>
{row.getVisibleCells().map((cell) => {
const isActionsColumn = cell.column.id === "actions";
return (
<TableCell
key={cell.id}
className={isActionsColumn ? "sticky right-0 z-10 w-auto min-w-fit bg-card" : ""}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
)}
</TableCell>
);
})}
{row
.getVisibleCells()
.map((cell) => {
const isActionsColumn =
cell.column.id ===
"actions";
return (
<TableCell
key={cell.id}
className={
isActionsColumn
? "sticky right-0 z-10 w-auto min-w-fit bg-card"
: ""
}
>
{flexRender(
cell.column
.columnDef
.cell,
cell.getContext()
)}
</TableCell>
);
})}
</TableRow>
))
) : (
@@ -888,7 +1006,7 @@ export default function ResourceRules(props: {
colSpan={columns.length}
className="h-24 text-center"
>
{t('rulesNoOne')}
{t("rulesNoOne")}
</TableCell>
</TableRow>
)}
@@ -907,7 +1025,7 @@ export default function ResourceRules(props: {
loading={loading}
disabled={loading}
>
{t('saveAllSettings')}
{t("saveAllSettings")}
</Button>
</div>
</SettingsContainer>

View File

@@ -7,7 +7,9 @@ import { cache } from "react";
import { GetOrgResponse } from "@server/routers/org";
import OrgProvider from "@app/providers/OrgProvider";
import { ListAccessTokensResponse } from "@server/routers/accessToken";
import ShareLinksTable, { ShareLinkRow } from "../../../../components/ShareLinksTable";
import ShareLinksTable, {
ShareLinkRow
} from "../../../../components/ShareLinksTable";
import { getTranslations } from "next-intl/server";
type ShareLinksPageProps = {
@@ -58,8 +60,8 @@ export default async function ShareLinksPage(props: ShareLinksPageProps) {
{/* <ShareableLinksSplash /> */}
<SettingsSectionTitle
title={t('shareTitle')}
description={t('shareDescription')}
title={t("shareTitle")}
description={t("shareDescription")}
/>
<OrgProvider org={org}>

View File

@@ -37,7 +37,7 @@ import Link from "next/link";
const GeneralFormSchema = z.object({
name: z.string().nonempty("Name is required"),
niceId: z.string().min(1).max(255).optional(),
dockerSocketEnabled: z.boolean().optional(),
dockerSocketEnabled: z.boolean().optional()
});
type GeneralFormValues = z.infer<typeof GeneralFormSchema>;
@@ -52,14 +52,16 @@ export default function GeneralPage() {
const { toast } = useToast();
const [loading, setLoading] = useState(false);
const [activeCidrTagIndex, setActiveCidrTagIndex] = useState<number | null>(null);
const [activeCidrTagIndex, setActiveCidrTagIndex] = useState<number | null>(
null
);
const form = useForm({
resolver: zodResolver(GeneralFormSchema),
defaultValues: {
name: site?.name,
niceId: site?.niceId || "",
dockerSocketEnabled: site?.dockerSocketEnabled ?? false,
dockerSocketEnabled: site?.dockerSocketEnabled ?? false
},
mode: "onChange"
});
@@ -71,17 +73,19 @@ export default function GeneralPage() {
await api.post(`/site/${site?.siteId}`, {
name: data.name,
niceId: data.niceId,
dockerSocketEnabled: data.dockerSocketEnabled,
dockerSocketEnabled: data.dockerSocketEnabled
});
updateSite({
name: data.name,
niceId: data.niceId,
dockerSocketEnabled: data.dockerSocketEnabled,
dockerSocketEnabled: data.dockerSocketEnabled
});
if (data.niceId && data.niceId !== site?.niceId) {
router.replace(`/${site?.orgId}/settings/sites/${data.niceId}/general`);
router.replace(
`/${site?.orgId}/settings/sites/${data.niceId}/general`
);
}
toast({
@@ -92,7 +96,10 @@ export default function GeneralPage() {
toast({
variant: "destructive",
title: t("siteErrorUpdate"),
description: formatAxiosError(e, t("siteErrorUpdateDescription"))
description: formatAxiosError(
e,
t("siteErrorUpdateDescription")
)
});
}
@@ -140,11 +147,15 @@ export default function GeneralPage() {
name="niceId"
render={({ field }) => (
<FormItem>
<FormLabel>{t("identifier")}</FormLabel>
<FormLabel>
{t("identifier")}
</FormLabel>
<FormControl>
<Input
{...field}
placeholder={t("enterIdentifier")}
placeholder={t(
"enterIdentifier"
)}
className="flex-1"
/>
</FormControl>

View File

@@ -6,16 +6,16 @@
function gf(init: number[] | undefined = undefined) {
var r = new Float64Array(16);
if (init) {
for (var i = 0; i < init.length; ++i)
r[i] = init[i];
for (var i = 0; i < init.length; ++i) r[i] = init[i];
}
return r;
}
function pack(o: Uint8Array, n: Float64Array) {
var b, m = gf(), t = gf();
for (var i = 0; i < 16; ++i)
t[i] = n[i];
var b,
m = gf(),
t = gf();
for (var i = 0; i < 16; ++i) t[i] = n[i];
carry(t);
carry(t);
carry(t);
@@ -45,7 +45,8 @@ function carry(o: Float64Array) {
}
function cswap(p: Float64Array, q: Float64Array, b: number) {
var t, c = ~(b - 1);
var t,
c = ~(b - 1);
for (var i = 0; i < 16; ++i) {
t = c & (p[i] ^ q[i]);
p[i] ^= t;
@@ -54,40 +55,32 @@ function cswap(p: Float64Array, q: Float64Array, b: number) {
}
function add(o: Float64Array, a: Float64Array, b: Float64Array) {
for (var i = 0; i < 16; ++i)
o[i] = (a[i] + b[i]) | 0;
for (var i = 0; i < 16; ++i) o[i] = (a[i] + b[i]) | 0;
}
function subtract(o: Float64Array, a: Float64Array, b: Float64Array) {
for (var i = 0; i < 16; ++i)
o[i] = (a[i] - b[i]) | 0;
for (var i = 0; i < 16; ++i) o[i] = (a[i] - b[i]) | 0;
}
function multmod(o: Float64Array, a: Float64Array, b: Float64Array) {
var t = new Float64Array(31);
for (var i = 0; i < 16; ++i) {
for (var j = 0; j < 16; ++j)
t[i + j] += a[i] * b[j];
for (var j = 0; j < 16; ++j) t[i + j] += a[i] * b[j];
}
for (var i = 0; i < 15; ++i)
t[i] += 38 * t[i + 16];
for (var i = 0; i < 16; ++i)
o[i] = t[i];
for (var i = 0; i < 15; ++i) t[i] += 38 * t[i + 16];
for (var i = 0; i < 16; ++i) o[i] = t[i];
carry(o);
carry(o);
}
function invert(o: Float64Array, i: Float64Array) {
var c = gf();
for (var a = 0; a < 16; ++a)
c[a] = i[a];
for (var a = 0; a < 16; ++a) c[a] = i[a];
for (var a = 253; a >= 0; --a) {
multmod(c, c, c);
if (a !== 2 && a !== 4)
multmod(c, c, i);
if (a !== 2 && a !== 4) multmod(c, c, i);
}
for (var a = 0; a < 16; ++a)
o[a] = c[a];
for (var a = 0; a < 16; ++a) o[a] = c[a];
}
function clamp(z: Uint8Array) {
@@ -96,7 +89,8 @@ function clamp(z: Uint8Array) {
}
function generatePublicKey(privateKey: Uint8Array) {
var r, z = new Uint8Array(32);
var r,
z = new Uint8Array(32);
var a = gf([1]),
b = gf([9]),
c = gf(),
@@ -105,8 +99,7 @@ function generatePublicKey(privateKey: Uint8Array) {
f = gf(),
_121665 = gf([0xdb41, 1]),
_9 = gf([9]);
for (var i = 0; i < 32; ++i)
z[i] = privateKey[i];
for (var i = 0; i < 32; ++i) z[i] = privateKey[i];
clamp(z);
for (var i = 254; i >= 0; --i) {
r = (z[i >>> 3] >>> (i & 7)) & 1;
@@ -152,9 +145,16 @@ function generatePrivateKey() {
}
function encodeBase64(dest: Uint8Array, src: Uint8Array) {
var input = Uint8Array.from([(src[0] >> 2) & 63, ((src[0] << 4) | (src[1] >> 4)) & 63, ((src[1] << 2) | (src[2] >> 6)) & 63, src[2] & 63]);
var input = Uint8Array.from([
(src[0] >> 2) & 63,
((src[0] << 4) | (src[1] >> 4)) & 63,
((src[1] << 2) | (src[2] >> 6)) & 63,
src[2] & 63
]);
for (var i = 0; i < 4; ++i)
dest[i] = input[i] + 65 +
dest[i] =
input[i] +
65 +
(((25 - input[i]) >> 8) & 6) -
(((51 - input[i]) >> 8) & 75) -
(((61 - input[i]) >> 8) & 15) +
@@ -162,10 +162,14 @@ function encodeBase64(dest: Uint8Array, src: Uint8Array) {
}
function keyToBase64(key: Uint8Array) {
var i, base64 = new Uint8Array(44);
var i,
base64 = new Uint8Array(44);
for (i = 0; i < 32 / 3; ++i)
encodeBase64(base64.subarray(i * 4), key.subarray(i * 3));
encodeBase64(base64.subarray(i * 4), Uint8Array.from([key[i * 3 + 0], key[i * 3 + 1], 0]));
encodeBase64(
base64.subarray(i * 4),
Uint8Array.from([key[i * 3 + 0], key[i * 3 + 1], 0])
);
base64[43] = 61;
return String.fromCharCode.apply(null, base64 as any);
}
@@ -177,4 +181,4 @@ export function generateKeypair() {
publicKey: keyToBase64(publicKey),
privateKey: keyToBase64(privateKey)
};
}
}

View File

@@ -215,7 +215,6 @@ export default function Page() {
string | undefined
>();
const hydrateCommands = (
id: string,
secret: string,
@@ -753,7 +752,9 @@ WantedBy=default.target`
{tunnelTypes.length > 1 && (
<>
<div className="mb-2">
<span className="text-sm font-medium">{t("type")}</span>
<span className="text-sm font-medium">
{t("type")}
</span>
</div>
<StrategySelect
options={tunnelTypes}

View File

@@ -31,11 +31,11 @@ export default async function SitesPage(props: SitesPageProps) {
return "-"; // because we are not able to track the data use in a local site right now
}
if (mb >= 1024 * 1024) {
return t('terabytes', {count: (mb / (1024 * 1024)).toFixed(2)});
return t("terabytes", { count: (mb / (1024 * 1024)).toFixed(2) });
} else if (mb >= 1024) {
return t('gigabytes', {count: (mb / 1024).toFixed(2)});
return t("gigabytes", { count: (mb / 1024).toFixed(2) });
} else {
return t('megabytes', {count: mb.toFixed(2)});
return t("megabytes", { count: mb.toFixed(2) });
}
}
@@ -53,7 +53,7 @@ export default async function SitesPage(props: SitesPageProps) {
newtVersion: site.newtVersion || undefined,
newtUpdateAvailable: site.newtUpdateAvailable || false,
exitNodeName: site.exitNodeName || undefined,
exitNodeEndpoint: site.exitNodeEndpoint || undefined,
exitNodeEndpoint: site.exitNodeEndpoint || undefined
};
});
@@ -62,8 +62,8 @@ export default async function SitesPage(props: SitesPageProps) {
{/* <SitesSplashCard /> */}
<SettingsSectionTitle
title={t('siteManageSites')}
description={t('siteDescription')}
title={t("siteManageSites")}
description={t("siteDescription")}
/>
<SitesTable sites={siteRows} orgId={params.orgId} />