mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-18 19:25:13 +00:00
chore: standardised the eslint config structure accross the project (#11814)
This commit is contained in:
@@ -46,6 +46,8 @@ export async function loginServiceKeyToken() {
|
||||
key: key,
|
||||
});
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to read login service key file "${keyFile}": ${err instanceof Error ? err.message : err}`);
|
||||
throw new Error(`Failed to read login service key file "${keyFile}": ${err instanceof Error ? err.message : err}`, {
|
||||
cause: err,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,24 +374,26 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
};
|
||||
}
|
||||
|
||||
const paramsPassword = new URLSearchParams({
|
||||
loginName: command.ignoreUnknownUsernames
|
||||
? command.loginName
|
||||
: (session?.factors?.user?.loginName ?? user.preferredLoginName),
|
||||
});
|
||||
{
|
||||
const paramsPassword = new URLSearchParams({
|
||||
loginName: command.ignoreUnknownUsernames
|
||||
? command.loginName
|
||||
: (session?.factors?.user?.loginName ?? user.preferredLoginName),
|
||||
});
|
||||
|
||||
if (organization) {
|
||||
paramsPassword.append("organization", organization);
|
||||
if (organization) {
|
||||
paramsPassword.append("organization", organization);
|
||||
}
|
||||
|
||||
if (command.requestId) {
|
||||
paramsPassword.append("requestId", command.requestId);
|
||||
}
|
||||
|
||||
return {
|
||||
redirect: "/password?" + paramsPassword,
|
||||
};
|
||||
}
|
||||
|
||||
if (command.requestId) {
|
||||
paramsPassword.append("requestId", command.requestId);
|
||||
}
|
||||
|
||||
return {
|
||||
redirect: "/password?" + paramsPassword,
|
||||
};
|
||||
|
||||
case AuthenticationMethodType.PASSKEY: // AuthenticationMethodType.AUTHENTICATION_METHOD_TYPE_PASSKEY
|
||||
if (userLoginSettings?.passkeysType === PasskeysType.NOT_ALLOWED || !userLoginSettings?.allowLocalAuthentication) {
|
||||
if (command.ignoreUnknownUsernames) {
|
||||
@@ -402,22 +404,24 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
};
|
||||
}
|
||||
|
||||
const paramsPasskey = new URLSearchParams({
|
||||
loginName: command.ignoreUnknownUsernames
|
||||
? command.loginName
|
||||
: (session?.factors?.user?.loginName ?? user.preferredLoginName),
|
||||
});
|
||||
if (command.requestId) {
|
||||
paramsPasskey.append("requestId", command.requestId);
|
||||
{
|
||||
const paramsPasskey = new URLSearchParams({
|
||||
loginName: command.ignoreUnknownUsernames
|
||||
? command.loginName
|
||||
: (session?.factors?.user?.loginName ?? user.preferredLoginName),
|
||||
});
|
||||
if (command.requestId) {
|
||||
paramsPasskey.append("requestId", command.requestId);
|
||||
}
|
||||
|
||||
if (organization) {
|
||||
paramsPasskey.append("organization", organization);
|
||||
}
|
||||
|
||||
return { redirect: "/passkey?" + paramsPasskey };
|
||||
}
|
||||
|
||||
if (organization) {
|
||||
paramsPasskey.append("organization", organization);
|
||||
}
|
||||
|
||||
return { redirect: "/passkey?" + paramsPasskey };
|
||||
|
||||
case AuthenticationMethodType.IDP:
|
||||
case AuthenticationMethodType.IDP: {
|
||||
const resp = await redirectUserToIDP(userId, organization);
|
||||
|
||||
if (resp?.error) {
|
||||
@@ -425,6 +429,7 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// prefer passkey in favor of other methods
|
||||
|
||||
@@ -317,7 +317,6 @@ describe("sendPassword", () => {
|
||||
const { completeFlowOrGetUrl } = await import("../client");
|
||||
vi.mocked(completeFlowOrGetUrl).mockResolvedValue({ redirect: "https://example.com" });
|
||||
|
||||
// eslint-disable-next-line
|
||||
const verifyHelper = await import("../verify-helper");
|
||||
vi.mocked(verifyHelper.checkPasswordChangeRequired).mockReturnValue(undefined);
|
||||
vi.mocked(verifyHelper.checkEmailVerification).mockReturnValue(undefined);
|
||||
|
||||
@@ -293,7 +293,7 @@ export async function sendPassword(
|
||||
return {
|
||||
error: t(messageKey, {
|
||||
failedAttempts: error.failedAttempts,
|
||||
maxPasswordAttempts: hasLimit ? (lockoutSettings?.maxPasswordAttempts).toString() : "?",
|
||||
maxPasswordAttempts: hasLimit ? String(lockoutSettings?.maxPasswordAttempts ?? 0) : "?",
|
||||
lockoutMessage: locked ? t("errors.accountLockedContactAdmin") : "",
|
||||
}),
|
||||
};
|
||||
@@ -565,7 +565,7 @@ export async function checkSessionAndSetPassword({
|
||||
return {
|
||||
error: t(messageKey, {
|
||||
failedAttempts: error.failedAttempts,
|
||||
maxPasswordAttempts: hasLimit ? (lockoutSettings?.maxPasswordAttempts).toString() : "?",
|
||||
maxPasswordAttempts: hasLimit ? String(lockoutSettings?.maxPasswordAttempts ?? 0) : "?",
|
||||
lockoutMessage: locked ? t("errors.accountLockedContactAdmin") : "",
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -164,6 +164,7 @@ export async function checkMFAFactors(
|
||||
|
||||
// TODO: provide a way to setup passkeys on mfa page?
|
||||
return { redirect: `/mfa/set?` + params };
|
||||
/* eslint-disable no-dupe-else-if -- TODO: this branch is unreachable, conditions overlap with the previous branch */
|
||||
} else if (
|
||||
loginSettings?.mfaInitSkipLifetime &&
|
||||
(loginSettings.mfaInitSkipLifetime.nanos > 0 || loginSettings.mfaInitSkipLifetime.seconds > 0) &&
|
||||
@@ -171,6 +172,7 @@ export async function checkMFAFactors(
|
||||
session?.factors?.user?.id &&
|
||||
shouldEnforceMFA(session, loginSettings)
|
||||
) {
|
||||
/* eslint-enable no-dupe-else-if */
|
||||
const userResponse = await getUserByID({ serviceConfig, userId: session.factors?.user?.id });
|
||||
|
||||
const humanUser = userResponse?.user?.type.case === "human" ? userResponse?.user.type.value : undefined;
|
||||
|
||||
@@ -1237,20 +1237,18 @@ export interface ServiceConfig {
|
||||
/**
|
||||
* Base type that all function parameters must extend to ensure serviceConfig is always required
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
export type WithServiceConfig<T = {}> = T & {
|
||||
serviceConfig: ServiceConfig;
|
||||
};
|
||||
|
||||
export function createServerTransport(token: string, serviceConfig: ServiceConfig) {
|
||||
// Build interceptors list - OTEL interceptor is always included for trace propagation
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const interceptors: any[] = [otelGrpcInterceptor];
|
||||
|
||||
// Add custom headers interceptor if needed
|
||||
if (process.env.CUSTOM_REQUEST_HEADERS || serviceConfig.instanceHost || serviceConfig.publicHost) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
interceptors.push((next: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (req: any) => {
|
||||
// Apply headers from serviceConfig
|
||||
if (serviceConfig.instanceHost) {
|
||||
|
||||
Reference in New Issue
Block a user