feat: add onboarding with oldmarr import (#1606)

This commit is contained in:
Meier Lukas
2024-12-15 15:40:26 +01:00
committed by GitHub
parent 82ec77d2da
commit 6de74d9525
108 changed files with 6045 additions and 312 deletions

View File

@@ -0,0 +1,18 @@
import { decryptSecretWithKey } from "@homarr/common/server";
export const ensureValidTokenOrThrow = (checksum: string | undefined, encryptionToken: string | null) => {
if (!encryptionToken || !checksum) return;
const [first, second] = checksum.split("\n");
if (!first || !second) throw new Error("Malformed checksum");
const key = Buffer.from(encryptionToken, "hex");
let decrypted: string;
try {
decrypted = decryptSecretWithKey(second as `${string}.${string}`, key);
} catch {
throw new Error("Invalid checksum");
}
const isValid = decrypted === first;
if (!isValid) throw new Error("Invalid checksum");
};