Initial upload to Gitea

This commit is contained in:
antonn committed 2026-11-30 16:32:37 +00:00
1 parent 78193254ad
commit 8478998cae
1485 files changed
+461025 -42348

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
"use strict";
// adpanel:stepup-credential-types - only string credentials may reach a
// verifier; limiter admission and verification share this classification.
function parseDestructiveActionCredentials(body) {
const input = body && typeof body === "object" && !Array.isArray(body) ? body : {};
const invalidType = ["currentPassword", "twoFactorCode"].some((key) =>
input[key] !== undefined && typeof input[key] !== "string"
);
const currentPassword = typeof input.currentPassword === "string" ? input.currentPassword : "";
const rawCode = typeof input.twoFactorCode === "string" ? input.twoFactorCode.replace(/\s+/g, "") : "";
const twoFactorCode = /^\d{6}$/.test(rawCode) ? rawCode : "";
return { currentPassword, twoFactorCode, invalidType };
}
function hasDestructiveActionCredentialPayload(req) {
const credentials = parseDestructiveActionCredentials(req?.body);
return !credentials.invalidType && !!(credentials.currentPassword || credentials.twoFactorCode);
}
module.exports = { parseDestructiveActionCredentials, hasDestructiveActionCredentialPayload };