PageSourceSearch

https://evil-admin.com/authValidator.js

js evil-admin.com collected 2026-10-01 15:30:11 UTC 2,924 bytes, 97 lines download raw bytes

1import { API_URL } from "./config.js";
2import { formatAuthResult } from "./formatters.js";
3
4function showLoadingIndicator(show) {
5  const loadingIndicator = document.getElementById("authLoadingIndicator");
6  if (show) {
7    loadingIndicator.classList.remove("hidden");
8  } else {
9    loadingIndicator.classList.add("hidden");
10  }
11}
12
13async function authenticateProtocol() {
14  showLoadingIndicator(true);
15  const form = document.getElementById("authForm");
16  const username = form.elements.authUsername.value;
17  const password = form.elements.authPassword.value;
18  const hostname = form.elements.authHostname.value;
19  const protocol = form.elements.authProtocol.value;
20
21  // Validate all fields are filled
22  if (!username || !password || !hostname || !protocol) {
23    showLoadingIndicator(false);
24    return { 
25      success: false, 
26      message: "All fields are required: username, password, hostname, and protocol",
27      protocol: protocol || 'none',
28      hostname: hostname || 'none'
29    };
30  }
31
32  const requestData = {
33    username,
34    password,
35    hostname,
36    protocol,
37  };
38
39  try {
40    const response = await fetch(`${API_URL}/auth`, {
41      method: "POST",
42      headers: {
43        "Content-Type": "application/json",
44      },
45      body: JSON.stringify(requestData),
46    });
47
48    if (!response.ok) {
49      const errorData = await response.json().catch(() => ({ message: 'Unknown error' }));
50      throw new Error(errorData.message || `HTTP error! status: ${response.status}`);
51    }
52
53    const resultData = await response.json();
54
55    // Include username, protocol, and hostname in the response data for display
56    resultData.username = username;
57    resultData.protocol = protocol;
58    resultData.hostname = hostname;
59
60    return resultData;
61  } catch (error) {
62    console.error("Authentication error:", error);
63    return { 
64      success: false, 
65      message: error.message || "Error occurred during authentication",
66      protocol: protocol,
67      hostname: hostname
68    };
69  } finally {
70    showLoadingIndicator(false);
71  }
72}
73
74export function initAuthValidator() {
75  // Add an event listener to the auth button to trigger authentication
76  const authButton = document.getElementById("performAuthBtn");
77  authButton.addEventListener("click", async function (event) {
78    event.preventDefault(); // Prevent form submission
79    const resultData = await authenticateProtocol(); // Call the function and get the result
80    updateUI(resultData); // Update the UI with the result
81  });
82
83  // Add Enter key support for form inputs
84  const form = document.getElementById("authForm");
85  form.addEventListener("keypress", function (event) {
86    if (event.key === "Enter") {
87      event.preventDefault();
88      authButton.click();
89    }
90  });
91}
92
93function updateUI(data) {
94  console.log(data);
95  const messageElement = document.getElementById("authResults");
96  messageElement.innerHTML = formatAuthResult(data);
97}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.