Add bank synchronization features with FinTS support and update dependencies

This commit is contained in:
Matthias
2026-06-15 13:56:32 +02:00
parent fc0a6fb975
commit d65e7681ac
23 changed files with 2609 additions and 150 deletions

View File

@@ -0,0 +1,81 @@
/** Platzhalter bis ZKA-Produktregistrierung vorliegt Bank kann ablehnen, Config-Check bricht nicht ab. */
export const FINTS_PRODUCT_ID_PLACEHOLDER = "XXXXX";
export type FintsConfigStatus = {
ready: boolean;
missing: string[];
warnings: string[];
usesProductIdPlaceholder: boolean;
};
export function getFintsConfigStatus(overrides?: {
blz?: string;
url?: string;
login?: string;
productId?: string;
pin?: string;
}): FintsConfigStatus {
const url = overrides?.url || process.env.FINTS_BANK_URL || "";
const blz = overrides?.blz || process.env.FINTS_BANK_BLZ || "";
const login = overrides?.login || process.env.FINTS_USER_ID || "";
const pin = overrides?.pin || process.env.FINTS_PIN || "";
const productId = overrides?.productId || process.env.FINTS_PRODUCT_ID || "";
const missing: string[] = [];
if (!url) missing.push("FinTS-URL");
if (!blz) missing.push("BLZ");
if (!login) missing.push("Zugangsnummer");
if (!pin) missing.push("PIN");
const warnings: string[] = [];
const usesProductIdPlaceholder = !productId;
if (usesProductIdPlaceholder) {
warnings.push(
"Produkt-ID (ZKA) noch nicht gesetzt Sync wird versucht, die Bank kann die Anfrage ablehnen.",
);
}
return {
ready: missing.length === 0,
missing,
warnings,
usesProductIdPlaceholder,
};
}
export function resolveFintsEnvFields(overrides?: {
blz?: string;
url?: string;
login?: string;
productId?: string;
productVersion?: string;
pin?: string;
}): {
productId: string;
productVersion: string;
url: string;
blz: string;
login: string;
pin: string;
usesProductIdPlaceholder: boolean;
} {
const status = getFintsConfigStatus(overrides);
if (!status.ready) {
throw new Error(
`FinTS-Zugang unvollständig: ${status.missing.join(", ")} fehlt. Bitte in Convex-Env oder Einstellungen ergänzen.`,
);
}
const productId =
overrides?.productId || process.env.FINTS_PRODUCT_ID || FINTS_PRODUCT_ID_PLACEHOLDER;
return {
productId,
productVersion: overrides?.productVersion || process.env.FINTS_PRODUCT_VERSION || "1.0.0",
url: overrides?.url || process.env.FINTS_BANK_URL || "",
blz: overrides?.blz || process.env.FINTS_BANK_BLZ || "",
login: overrides?.login || process.env.FINTS_USER_ID || "",
pin: overrides?.pin || process.env.FINTS_PIN || "",
usesProductIdPlaceholder: status.usesProductIdPlaceholder,
};
}