remove unused dependencies

This commit is contained in:
Elio Bischof
2025-07-17 23:28:45 +02:00
parent d5093a4edf
commit 1adf1e73a9
22 changed files with 1087 additions and 6716 deletions

31
apps/login/knip.json Normal file
View File

@@ -0,0 +1,31 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"workspaces": {
".": {
"ignore": [
"acceptance/**",
"integration/**"
]
}
},
"ignoreDependencies": [
"@zitadel/client",
"@zitadel/proto"
],
"rules": {
"optionalPeerDependencies": "error",
"dependencies": "error",
"devDependencies": "error",
"exports": "warn",
"files": "warn",
"binaries": "warn",
"classMembers": "warn",
"duplicates": "warn",
"enumMembers": "warn",
"nsExports": "warn",
"nsTypes": "warn",
"types": "warn",
"unlisted": "warn",
"unresolved": "warn"
}
}

View File

@@ -5,13 +5,17 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "pnpm exec next build", "build": "next build",
"build:standalone": "NEXT_PUBLIC_BASE_PATH=/ui/v2/login NEXT_OUTPUT_MODE=standalone pnpm build", "build:standalone": "NEXT_PUBLIC_BASE_PATH=/ui/v2/login NEXT_OUTPUT_MODE=standalone next build",
"start": "pnpm exec next start", "start": "next start",
"lint": "pnpm exec next lint && pnpm exec prettier --check .", "lint": "pnpm run '/^(lint:next|prettier|knip)$/'",
"lint:fix": "pnpm exec prettier --write .", "lint:fix": "prettier --write .",
"test:unit": "pnpm vitest --run", "lint:next": "next lint",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next" "prettier:fix": "prettier --check .",
"knip:fix": "knip --fix",
"test:unit": "vitest --run",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
"knip": "knip"
}, },
"pnpm": { "pnpm": {
"overrides": { "overrides": {
@@ -27,13 +31,11 @@
"@zitadel/proto": "latest", "@zitadel/proto": "latest",
"clsx": "1.2.1", "clsx": "1.2.1",
"copy-to-clipboard": "^3.3.3", "copy-to-clipboard": "^3.3.3",
"deepmerge": "^4.3.1",
"lucide-react": "0.469.0", "lucide-react": "0.469.0",
"moment": "^2.29.4", "moment": "^2.29.4",
"next": "15.4.0-canary.86", "next": "15.4.0-canary.86",
"next-intl": "^3.25.1", "next-intl": "^3.25.1",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"nice-grpc": "2.0.1",
"qrcode.react": "^3.1.0", "qrcode.react": "^3.1.0",
"react": "19.1.0", "react": "19.1.0",
"react-dom": "19.1.0", "react-dom": "19.1.0",
@@ -44,24 +46,28 @@
"devDependencies": { "devDependencies": {
"@testing-library/jest-dom": "^6.6.3", "@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0", "@testing-library/react": "^16.3.0",
"@types/node": "^22.14.1", "@types/node": "^22.16.4",
"@types/react": "19.1.2", "@types/react": "19.1.2",
"@types/react-dom": "19.1.2", "@types/react-dom": "19.1.2",
"@types/tinycolor2": "1.4.3", "@types/tinycolor2": "1.4.3",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0", "@typescript-eslint/parser": "^7.0.0",
"autoprefixer": "10.4.21",
"@vitejs/plugin-react": "^4.4.1", "@vitejs/plugin-react": "^4.4.1",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-next": "15.4.0-canary.86", "eslint-config-next": "15.4.0-canary.86",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"jsdom": "^26.1.0", "jsdom": "^26.1.0",
"lint-staged": "15.5.1", "knip": "^5.61.3",
"postcss": "8.5.3",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.0",
"prettier-plugin-tailwindcss": "0.6.11",
"sass": "^1.87.0", "sass": "^1.87.0",
"tailwindcss": "3.4.14", "tailwindcss": "3.4.14",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vitest": "^2.0.0", "vite-tsconfig-paths": "^5.1.4",
"vite-tsconfig-paths": "^5.1.4" "vitest": "^2.0.0"
} }
} }

6100
apps/login/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
import { clsx } from "clsx"; import { clsx } from "clsx";
import { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef } from "react"; import { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef } from "react";
export enum ButtonSizes { enum ButtonSizes {
Small = "Small", Small = "Small",
Large = "Large", Large = "Large",
} }
@@ -9,16 +9,15 @@ export enum ButtonSizes {
export enum ButtonVariants { export enum ButtonVariants {
Primary = "Primary", Primary = "Primary",
Secondary = "Secondary", Secondary = "Secondary",
Destructive = "Destructive", }
}
export enum ButtonColors { enum ButtonColors {
Neutral = "Neutral", Neutral = "Neutral",
Primary = "Primary", Primary = "Primary",
Warn = "Warn", Warn = "Warn",
} }
export type ButtonProps = DetailedHTMLProps< type ButtonProps = DetailedHTMLProps<
ButtonHTMLAttributes<HTMLButtonElement>, ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement HTMLButtonElement
> & { > & {
@@ -27,7 +26,7 @@ export type ButtonProps = DetailedHTMLProps<
color?: ButtonColors; color?: ButtonColors;
}; };
export const getButtonClasses = ( const getButtonClasses = (
size: ButtonSizes, size: ButtonSizes,
variant: ButtonVariants, variant: ButtonVariants,
color: ButtonColors, color: ButtonColors,

View File

@@ -7,7 +7,7 @@ import {
useState, useState,
} from "react"; } from "react";
export type CheckboxProps = DetailedHTMLProps< type CheckboxProps = DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>, InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement HTMLInputElement
> & { > & {

View File

@@ -10,7 +10,7 @@ import {
ReactNode, ReactNode,
} from "react"; } from "react";
export type TextInputProps = DetailedHTMLProps< type TextInputProps = DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>, InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement HTMLInputElement
> & { > & {

View File

@@ -17,7 +17,7 @@ import { SignInWithGitlab } from "./idps/sign-in-with-gitlab";
import { SignInWithGoogle } from "./idps/sign-in-with-google"; import { SignInWithGoogle } from "./idps/sign-in-with-google";
import { Translated } from "./translated"; import { Translated } from "./translated";
export interface SignInWithIDPProps { interface SignInWithIDPProps {
children?: ReactNode; children?: ReactNode;
identityProviders: IdentityProvider[]; identityProviders: IdentityProvider[];
requestId?: string; requestId?: string;

View File

@@ -8,7 +8,7 @@ export enum BadgeState {
Alert = "alert", Alert = "alert",
} }
export type StateBadgeProps = { type StateBadgeProps = {
state: BadgeState; state: BadgeState;
children: ReactNode; children: ReactNode;
evenPadding?: boolean; evenPadding?: boolean;

View File

@@ -1,57 +1,30 @@
import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb"; import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb";
import tinycolor from "tinycolor2"; import tinycolor from "tinycolor2";
export interface Color { interface Color {
name: string; name: string;
hex: string; hex: string;
rgb: string; rgb: string;
contrastColor: string; contrastColor: string;
} }
export type MapName = "background" | "primary" | "warn" | "text" | "link"; type MapName = "background" | "primary" | "warn" | "text" | "link";
export type ColorName = type ColorMap = {
| "50" [_key in MapName]: Color[];
| "100"
| "200"
| "300"
| "400"
| "500"
| "600"
| "700"
| "800"
| "C900"
| "A100"
| "A200"
| "A400"
| "A700";
export type ColorMap = {
[key in MapName]: Color[];
}; };
export const DARK_PRIMARY = "#2073c4"; const DARK_PRIMARY = "#2073c4";
export const PRIMARY = "#5469d4"; const PRIMARY = "#5469d4";
export const DARK_WARN = "#ff3b5b"; const DARK_WARN = "#ff3b5b";
export const WARN = "#cd3d56"; const WARN = "#cd3d56";
export const DARK_BACKGROUND = "#111827"; const DARK_BACKGROUND = "#111827";
export const BACKGROUND = "#fafafa"; const BACKGROUND = "#fafafa";
export const DARK_TEXT = "#ffffff"; const DARK_TEXT = "#ffffff";
export const TEXT = "#000000"; const TEXT = "#000000";
export type LabelPolicyColors = {
backgroundColor: string;
backgroundColorDark: string;
fontColor: string;
fontColorDark: string;
warnColor: string;
warnColorDark: string;
primaryColor: string;
primaryColorDark: string;
};
type BrandingColors = { type BrandingColors = {
lightTheme: { lightTheme: {
@@ -182,7 +155,7 @@ function getContrast(color: string): string {
} }
} }
export function computeMap(branding: BrandingColors, dark: boolean): ColorMap { function computeMap(branding: BrandingColors, dark: boolean): ColorMap {
return { return {
background: computeColors( background: computeColors(
dark dark
@@ -213,7 +186,7 @@ export interface ColorShade {
900: string; 900: string;
} }
export const COLORS = [ const COLORS = [
{ {
500: "#ef4444", 500: "#ef4444",
200: "#fecaca", 200: "#fecaca",
@@ -363,7 +336,7 @@ export function getColorHash(value: string): ColorShade {
return COLORS[hash % COLORS.length]; return COLORS[hash % COLORS.length];
} }
export function hashCode(str: string, seed = 0): number { function hashCode(str: string, seed = 0): number {
let h1 = 0xdeadbeef ^ seed, let h1 = 0xdeadbeef ^ seed,
h2 = 0x41c6ce57 ^ seed; h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) { for (let i = 0, ch; i < str.length; i++) {
@@ -379,61 +352,3 @@ export function hashCode(str: string, seed = 0): number {
Math.imul(h1 ^ (h1 >>> 13), 3266489909); Math.imul(h1 ^ (h1 >>> 13), 3266489909);
return 4294967296 * (2097151 & h2) + (h1 >>> 0); return 4294967296 * (2097151 & h2) + (h1 >>> 0);
} }
export function getMembershipColor(role: string): ColorShade {
const hash = hashCode(role);
let color = COLORS[hash % COLORS.length];
switch (role) {
case "IAM_OWNER":
color = COLORS[0];
break;
case "IAM_OWNER_VIEWER":
color = COLORS[14];
break;
case "IAM_ORG_MANAGER":
color = COLORS[11];
break;
case "IAM_USER_MANAGER":
color = COLORS[8];
break;
case "ORG_OWNER":
color = COLORS[16];
break;
case "ORG_USER_MANAGER":
color = COLORS[8];
break;
case "ORG_OWNER_VIEWER":
color = COLORS[14];
break;
case "ORG_USER_PERMISSION_EDITOR":
color = COLORS[7];
break;
case "ORG_PROJECT_PERMISSION_EDITOR":
color = COLORS[11];
break;
case "ORG_PROJECT_CREATOR":
color = COLORS[12];
break;
case "PROJECT_OWNER":
color = COLORS[9];
break;
case "PROJECT_OWNER_VIEWER":
color = COLORS[10];
break;
case "PROJECT_OWNER_GLOBAL":
color = COLORS[11];
break;
case "PROJECT_OWNER_VIEWER_GLOBAL":
color = COLORS[12];
break;
default:
color = COLORS[hash % COLORS.length];
break;
}
return color;
}

View File

@@ -7,11 +7,11 @@ import { cookies, headers } from "next/headers";
import { userAgent } from "next/server"; import { userAgent } from "next/server";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
export async function getFingerprintId() { async function getFingerprintId() {
return uuidv4(); return uuidv4();
} }
export async function setFingerprintIdCookie(fingerprintId: string) { async function setFingerprintIdCookie(fingerprintId: string) {
const cookiesList = await cookies(); const cookiesList = await cookies();
return cookiesList.set({ return cookiesList.set({

View File

@@ -35,4 +35,3 @@ export const LANGS: Lang[] = [
]; ];
export const LANGUAGE_COOKIE_NAME = "NEXT_LOCALE"; export const LANGUAGE_COOKIE_NAME = "NEXT_LOCALE";
export const LANGUAGE_HEADER_NAME = "accept-language";

View File

@@ -19,7 +19,7 @@ type LoginWithSAMLAndSession = {
request: NextRequest; request: NextRequest;
}; };
export async function getSAMLFormUID() { async function getSAMLFormUID() {
return uuidv4(); return uuidv4();
} }

View File

@@ -15,7 +15,6 @@ import {
ErrorDetail, ErrorDetail,
} from "@zitadel/proto/zitadel/message_pb"; } from "@zitadel/proto/zitadel/message_pb";
import { import {
Challenges,
RequestChallenges, RequestChallenges,
} from "@zitadel/proto/zitadel/session/v2/challenge_pb"; } from "@zitadel/proto/zitadel/session/v2/challenge_pb";
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb"; import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
@@ -186,10 +185,6 @@ export async function createSessionForIdpAndUpdateCookie({
}); });
} }
export type SessionWithChallenges = Session & {
challenges: Challenges | undefined;
};
export async function setSessionAndUpdateCookie( export async function setSessionAndUpdateCookie(
recentCookie: CustomCookieData, recentCookie: CustomCookieData,
checks?: Checks, checks?: Checks,

View File

@@ -13,7 +13,7 @@ import { getServiceUrlFromHeaders } from "../service-url";
import { checkEmailVerification } from "../verify-helper"; import { checkEmailVerification } from "../verify-helper";
import { createSessionForIdpAndUpdateCookie } from "./cookie"; import { createSessionForIdpAndUpdateCookie } from "./cookie";
export type RedirectToIdpState = { error?: string | null } | undefined; type RedirectToIdpState = { error?: string | null } | undefined;
export async function redirectToIdp( export async function redirectToIdp(
prevState: RedirectToIdpState, prevState: RedirectToIdpState,
@@ -63,7 +63,7 @@ export async function redirectToIdp(
return { error: "Unexpected response from IDP flow" }; return { error: "Unexpected response from IDP flow" };
} }
export type StartIDPFlowCommand = { type StartIDPFlowCommand = {
serviceUrl: string; serviceUrl: string;
host: string; host: string;
idpId: string; idpId: string;

View File

@@ -81,7 +81,7 @@ export async function resetPassword(command: ResetPasswordCommand) {
}); });
} }
export type UpdateSessionCommand = { type UpdateSessionCommand = {
loginName: string; loginName: string;
organization?: string; organization?: string;
checks: Checks; checks: Checks;

View File

@@ -11,7 +11,6 @@ import {
getUserByID, getUserByID,
} from "@/lib/zitadel"; } from "@/lib/zitadel";
import { create } from "@zitadel/client"; import { create } from "@zitadel/client";
import { Factors } from "@zitadel/proto/zitadel/session/v2/session_pb";
import { import {
ChecksJson, ChecksJson,
ChecksSchema, ChecksSchema,
@@ -30,11 +29,6 @@ type RegisterUserCommand = {
requestId?: string; requestId?: string;
}; };
export type RegisterUserResponse = {
userId: string;
sessionId: string;
factors: Factors | undefined;
};
export async function registerUser(command: RegisterUserCommand) { export async function registerUser(command: RegisterUserCommand) {
const _headers = await headers(); const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers); const { serviceUrl } = getServiceUrlFromHeaders(_headers);
@@ -157,11 +151,6 @@ type RegisterUserAndLinkToIDPommand = {
idpUserName: string; idpUserName: string;
}; };
export type registerUserAndLinkToIDPResponse = {
userId: string;
sessionId: string;
factors: Factors | undefined;
};
export async function registerUserAndLinkToIDP( export async function registerUserAndLinkToIDP(
command: RegisterUserAndLinkToIDPommand, command: RegisterUserAndLinkToIDPommand,
) { ) {

View File

@@ -105,7 +105,7 @@ export async function continueWithSession({
} }
} }
export type UpdateSessionCommand = { type UpdateSessionCommand = {
loginName?: string; loginName?: string;
sessionId?: string; sessionId?: string;
organization?: string; organization?: string;

View File

@@ -47,34 +47,6 @@ export function checkPasswordChangeRequired(
} }
} }
export function checkEmailVerified(
session: Session,
humanUser?: HumanUser,
organization?: string,
requestId?: string,
) {
if (!humanUser?.email?.isVerified) {
const paramsVerify = new URLSearchParams({
loginName: session.factors?.user?.loginName as string,
userId: session.factors?.user?.id as string, // verify needs user id
send: "true", // we request a new email code once the page is loaded
});
if (organization || session.factors?.user?.organizationId) {
paramsVerify.append(
"organization",
organization ?? (session.factors?.user?.organizationId as string),
);
}
if (requestId) {
paramsVerify.append("requestId", requestId);
}
return { redirect: "/verify?" + paramsVerify };
}
}
export function checkEmailVerification( export function checkEmailVerification(
session: Session, session: Session,
humanUser?: HumanUser, humanUser?: HumanUser,

View File

@@ -40,8 +40,6 @@ import { SendInviteCodeSchema } from "@zitadel/proto/zitadel/user/v2/user_pb";
import { import {
AddHumanUserRequest, AddHumanUserRequest,
AddHumanUserRequestSchema, AddHumanUserRequestSchema,
ResendEmailCodeRequest,
ResendEmailCodeRequestSchema,
SendEmailCodeRequestSchema, SendEmailCodeRequestSchema,
SetPasswordRequest, SetPasswordRequest,
SetPasswordRequestSchema, SetPasswordRequestSchema,
@@ -64,41 +62,6 @@ async function cacheWrapper<T>(callback: Promise<T>) {
return callback; return callback;
} }
export async function getHostedLoginTranslation({
serviceUrl,
organization,
locale,
}: {
serviceUrl: string;
organization?: string;
locale?: string;
}) {
const settingsService: Client<typeof SettingsService> =
await createServiceForHost(SettingsService, serviceUrl);
const callback = settingsService
.getHostedLoginTranslation(
{
level: organization
? {
case: "organizationId",
value: organization,
}
: {
case: "instance",
value: true,
},
locale: locale,
},
{},
)
.then((resp) => {
return resp.translations ? resp.translations : undefined;
});
return useCache ? cacheWrapper(callback) : callback;
}
export async function getBrandingSettings({ export async function getBrandingSettings({
serviceUrl, serviceUrl,
organization, organization,
@@ -242,21 +205,6 @@ export async function registerTOTP({
return userService.registerTOTP({ userId }, {}); return userService.registerTOTP({ userId }, {});
} }
export async function getGeneralSettings({
serviceUrl,
}: {
serviceUrl: string;
}) {
const settingsService: Client<typeof SettingsService> =
await createServiceForHost(SettingsService, serviceUrl);
const callback = settingsService
.getGeneralSettings({}, {})
.then((resp) => resp.supportedLanguages);
return useCache ? cacheWrapper(callback) : callback;
}
export async function getLegalAndSupportSettings({ export async function getLegalAndSupportSettings({
serviceUrl, serviceUrl,
organization, organization,
@@ -427,7 +375,7 @@ export async function listSessions({ serviceUrl, ids }: ListSessionsCommand) {
); );
} }
export type AddHumanUserData = { type AddHumanUserData = {
serviceUrl: string; serviceUrl: string;
firstName: string; firstName: string;
lastName: string; lastName: string;
@@ -639,7 +587,7 @@ export async function createInviteCode({
); );
} }
export type ListUsersCommand = { type ListUsersCommand = {
serviceUrl: string; serviceUrl: string;
loginName?: string; loginName?: string;
userName?: string; userName?: string;
@@ -1203,33 +1151,6 @@ export async function verifyEmail({
); );
} }
export async function resendEmailCode({
serviceUrl,
userId,
urlTemplate,
}: {
serviceUrl: string;
userId: string;
urlTemplate: string;
}) {
let request: ResendEmailCodeRequest = create(ResendEmailCodeRequestSchema, {
userId,
});
const medium = create(SendEmailVerificationCodeSchema, {
urlTemplate,
});
request = { ...request, verification: { case: "sendCode", value: medium } };
const userService: Client<typeof UserService> = await createServiceForHost(
UserService,
serviceUrl,
);
return userService.resendEmailCode(request, {});
}
export async function retrieveIDPIntent({ export async function retrieveIDPIntent({
serviceUrl, serviceUrl,
id, id,

View File

@@ -43,9 +43,11 @@
], ],
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"build": "pnpm exec tsup", "build": "tsup",
"test:unit": "pnpm exec vitest --run", "lint": "pnpm run '/eslint|knip/'",
"lint": "eslint \"src/**/*.ts*\"", "eslint": "eslint 'src/**/*.ts*'",
"knip": "knip",
"test:unit": "vitest --run",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"dependencies": { "dependencies": {
@@ -58,10 +60,13 @@
}, },
"devDependencies": { "devDependencies": {
"@bufbuild/protocompile": "^0.0.1", "@bufbuild/protocompile": "^0.0.1",
"@types/node": "^24.0.14",
"@typescript-eslint/eslint-plugin": "^8.15.0", "@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0", "@typescript-eslint/parser": "^8.15.0",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"knip": "^5.61.3",
"tsup": "^8.4.0", "tsup": "^8.4.0",
"typescript": "^5.8.3",
"vitest": "^2.0.0" "vitest": "^2.0.0"
} }
} }

View File

@@ -14,7 +14,7 @@
], ],
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"generate": "pnpm exec buf generate ../../proto --path ../../proto/zitadel", "generate": "buf generate ../../proto --path ../../proto/zitadel",
"clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate" "clean": "rm -rf zitadel .turbo node_modules google protoc-gen-openapiv2 validate"
}, },
"devDependencies": { "devDependencies": {

1351
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff