|
@@ -1,40 +1,40 @@
|
|
|
const toolButtons = document.querySelectorAll(".tool-button");
|
|
const toolButtons = document.querySelectorAll(".tool-button");
|
|
|
const panels = document.querySelectorAll(".panel");
|
|
const panels = document.querySelectorAll(".panel");
|
|
|
|
|
+let currentTSLTemplate = null;
|
|
|
|
|
|
|
|
document.addEventListener("click", async (event) => {
|
|
document.addEventListener("click", async (event) => {
|
|
|
const button = event.target.closest("[data-copy-value]");
|
|
const button = event.target.closest("[data-copy-value]");
|
|
|
- if (!button) {
|
|
|
|
|
|
|
+ if (button) {
|
|
|
|
|
+ const value = button.dataset.copyValue || "";
|
|
|
|
|
+ const originalLabel = button.textContent;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ await copyText(value);
|
|
|
|
|
+ button.textContent = "Copied";
|
|
|
|
|
+ button.classList.add("copied");
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ button.textContent = originalLabel;
|
|
|
|
|
+ button.classList.remove("copied");
|
|
|
|
|
+ }, 1500);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ button.textContent = "Copy failed";
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ button.textContent = originalLabel;
|
|
|
|
|
+ }, 1500);
|
|
|
|
|
+ }
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const value = button.dataset.copyValue || "";
|
|
|
|
|
- const originalLabel = button.textContent;
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- await copyText(value);
|
|
|
|
|
- button.textContent = "Copied";
|
|
|
|
|
- button.classList.add("copied");
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- button.textContent = originalLabel;
|
|
|
|
|
- button.classList.remove("copied");
|
|
|
|
|
- }, 1500);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- button.textContent = "Copy failed";
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- button.textContent = originalLabel;
|
|
|
|
|
- }, 1500);
|
|
|
|
|
|
|
+ const prefillButton = event.target.closest("[data-action='prefill-tls']");
|
|
|
|
|
+ if (prefillButton && currentTSLTemplate) {
|
|
|
|
|
+ populateTLSForm(currentTSLTemplate);
|
|
|
|
|
+ activateTool("tls-generator");
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
toolButtons.forEach((button) => {
|
|
toolButtons.forEach((button) => {
|
|
|
button.addEventListener("click", () => {
|
|
button.addEventListener("click", () => {
|
|
|
- const target = button.dataset.tool;
|
|
|
|
|
-
|
|
|
|
|
- toolButtons.forEach((item) => item.classList.remove("active"));
|
|
|
|
|
- panels.forEach((panel) => panel.classList.remove("active"));
|
|
|
|
|
-
|
|
|
|
|
- button.classList.add("active");
|
|
|
|
|
- document.getElementById(target).classList.add("active");
|
|
|
|
|
|
|
+ activateTool(button.dataset.tool);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -69,13 +69,15 @@ document.getElementById("dns-form").addEventListener("submit", async (event) =>
|
|
|
}, renderDNSResult, document.getElementById("dns-result"));
|
|
}, renderDNSResult, document.getElementById("dns-result"));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-document.getElementById("ssl-form").addEventListener("submit", async (event) => {
|
|
|
|
|
|
|
+document.getElementById("tsl-form").addEventListener("submit", async (event) => {
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
const form = new FormData(event.currentTarget);
|
|
const form = new FormData(event.currentTarget);
|
|
|
|
|
|
|
|
- await submitJSON("/api/ssl/check", {
|
|
|
|
|
|
|
+ await submitJSON("/api/tsl/check", {
|
|
|
url: form.get("url"),
|
|
url: form.get("url"),
|
|
|
- }, renderSSLResult, document.getElementById("ssl-result"));
|
|
|
|
|
|
|
+ }, renderTSLResult, document.getElementById("tsl-result"), (data) => {
|
|
|
|
|
+ currentTSLTemplate = data.leafTemplate || null;
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("pem-form").addEventListener("submit", async (event) => {
|
|
document.getElementById("pem-form").addEventListener("submit", async (event) => {
|
|
@@ -160,7 +162,7 @@ function renderDNSResult(data) {
|
|
|
`;
|
|
`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function renderSSLResult(data) {
|
|
|
|
|
|
|
+function renderTSLResult(data) {
|
|
|
const leaf = (data.chain || [])[0] || {};
|
|
const leaf = (data.chain || [])[0] || {};
|
|
|
|
|
|
|
|
return `
|
|
return `
|
|
@@ -174,6 +176,9 @@ function renderSSLResult(data) {
|
|
|
["Leaf Issuer", escapeHTML(leaf.issuer || "")],
|
|
["Leaf Issuer", escapeHTML(leaf.issuer || "")],
|
|
|
["Leaf Valid Until", escapeHTML(leaf.notAfter || "")],
|
|
["Leaf Valid Until", escapeHTML(leaf.notAfter || "")],
|
|
|
])}
|
|
])}
|
|
|
|
|
+ <div class="record-block">
|
|
|
|
|
+ <button type="button" class="secondary-button prefill-button" data-action="prefill-tls">Use In TLS Generator</button>
|
|
|
|
|
+ </div>
|
|
|
<div class="record-block">
|
|
<div class="record-block">
|
|
|
<h3>Certificate Chain</h3>
|
|
<h3>Certificate Chain</h3>
|
|
|
<pre>${escapeHTML(JSON.stringify(data.chain, null, 2))}</pre>
|
|
<pre>${escapeHTML(JSON.stringify(data.chain, null, 2))}</pre>
|
|
@@ -185,6 +190,38 @@ function renderSSLResult(data) {
|
|
|
`;
|
|
`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function activateTool(target) {
|
|
|
|
|
+ toolButtons.forEach((item) => item.classList.remove("active"));
|
|
|
|
|
+ panels.forEach((panel) => panel.classList.remove("active"));
|
|
|
|
|
+
|
|
|
|
|
+ document.querySelector(`.tool-button[data-tool="${target}"]`)?.classList.add("active");
|
|
|
|
|
+ document.getElementById(target)?.classList.add("active");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function populateTLSForm(template) {
|
|
|
|
|
+ const form = document.getElementById("tls-form");
|
|
|
|
|
+ if (!form || !template) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ setFormValue(form, "commonName", template.commonName);
|
|
|
|
|
+ setFormValue(form, "organization", template.organization);
|
|
|
|
|
+ setFormValue(form, "organizationalUnit", template.organizationalUnit);
|
|
|
|
|
+ setFormValue(form, "locality", template.locality);
|
|
|
|
|
+ setFormValue(form, "state", template.state);
|
|
|
|
|
+ setFormValue(form, "country", template.country);
|
|
|
|
|
+ setFormValue(form, "dnsNames", template.dnsNames);
|
|
|
|
|
+ setFormValue(form, "validDays", template.validDays);
|
|
|
|
|
+ setFormValue(form, "keySize", template.keySize);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function setFormValue(form, name, value) {
|
|
|
|
|
+ const field = form.elements.namedItem(name);
|
|
|
|
|
+ if (field) {
|
|
|
|
|
+ field.value = value ?? "";
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function renderPEMResult(data) {
|
|
function renderPEMResult(data) {
|
|
|
return `
|
|
return `
|
|
|
${renderMetaGrid([
|
|
${renderMetaGrid([
|