[build] upgrade eslint to 9.37.0 (#88)

Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88
Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org>
Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
This commit is contained in:
Zoë Bijl
2025-10-12 13:42:02 +02:00
committed by tobi
parent 75d7a62693
commit 1ff70886a1
975 changed files with 22196 additions and 21964 deletions

View File

@@ -1,49 +1,49 @@
// This file will be loaded on admin pages, regardless of theme.
import 'packs/public-path';
import Rails from '@rails/ujs';
import "packs/public-path";
import Rails from "@rails/ujs";
import ready from '../mastodon/ready';
import ready from "../mastodon/ready";
const setAnnouncementEndsAttributes = (target) => {
const valid = target?.value && target?.validity?.valid;
const element = document.querySelector('input[type="datetime-local"]#announcement_ends_at');
const element = document.querySelector("input[type=\"datetime-local\"]#announcement_ends_at");
if (valid) {
element.classList.remove('optional');
element.classList.remove("optional");
element.required = true;
element.min = target.value;
} else {
element.classList.add('optional');
element.removeAttribute('required');
element.removeAttribute('min');
element.classList.add("optional");
element.removeAttribute("required");
element.removeAttribute("min");
}
};
Rails.delegate(document, 'input[type="datetime-local"]#announcement_starts_at', 'change', ({ target }) => {
Rails.delegate(document, "input[type=\"datetime-local\"]#announcement_starts_at", "change", ({ target }) => {
setAnnouncementEndsAttributes(target);
});
const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]';
const batchCheckboxClassName = ".batch-checkbox input[type=\"checkbox\"]";
const showSelectAll = () => {
const selectAllMatchingElement = document.querySelector('.batch-table__select-all');
selectAllMatchingElement.classList.add('active');
const selectAllMatchingElement = document.querySelector(".batch-table__select-all");
selectAllMatchingElement.classList.add("active");
};
const hideSelectAll = () => {
const selectAllMatchingElement = document.querySelector('.batch-table__select-all');
const hiddenField = document.querySelector('#select_all_matching');
const selectedMsg = document.querySelector('.batch-table__select-all .selected');
const notSelectedMsg = document.querySelector('.batch-table__select-all .not-selected');
const selectAllMatchingElement = document.querySelector(".batch-table__select-all");
const hiddenField = document.querySelector("#select_all_matching");
const selectedMsg = document.querySelector(".batch-table__select-all .selected");
const notSelectedMsg = document.querySelector(".batch-table__select-all .not-selected");
selectAllMatchingElement.classList.remove('active');
selectedMsg.classList.remove('active');
notSelectedMsg.classList.add('active');
hiddenField.value = '0';
selectAllMatchingElement.classList.remove("active");
selectedMsg.classList.remove("active");
notSelectedMsg.classList.add("active");
hiddenField.value = "0";
};
Rails.delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
const selectAllMatchingElement = document.querySelector('.batch-table__select-all');
Rails.delegate(document, "#batch_checkbox_all", "change", ({ target }) => {
const selectAllMatchingElement = document.querySelector(".batch-table__select-all");
[].forEach.call(document.querySelectorAll(batchCheckboxClassName), (content) => {
content.checked = target.checked;
@@ -58,26 +58,26 @@ Rails.delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
}
});
Rails.delegate(document, '.batch-table__select-all button', 'click', () => {
const hiddenField = document.querySelector('#select_all_matching');
const active = hiddenField.value === '1';
const selectedMsg = document.querySelector('.batch-table__select-all .selected');
const notSelectedMsg = document.querySelector('.batch-table__select-all .not-selected');
Rails.delegate(document, ".batch-table__select-all button", "click", () => {
const hiddenField = document.querySelector("#select_all_matching");
const active = hiddenField.value === "1";
const selectedMsg = document.querySelector(".batch-table__select-all .selected");
const notSelectedMsg = document.querySelector(".batch-table__select-all .not-selected");
if (active) {
hiddenField.value = '0';
selectedMsg.classList.remove('active');
notSelectedMsg.classList.add('active');
hiddenField.value = "0";
selectedMsg.classList.remove("active");
notSelectedMsg.classList.add("active");
} else {
hiddenField.value = '1';
notSelectedMsg.classList.remove('active');
selectedMsg.classList.add('active');
hiddenField.value = "1";
notSelectedMsg.classList.remove("active");
selectedMsg.classList.add("active");
}
});
Rails.delegate(document, batchCheckboxClassName, 'change', () => {
const checkAllElement = document.querySelector('#batch_checkbox_all');
const selectAllMatchingElement = document.querySelector('.batch-table__select-all');
Rails.delegate(document, batchCheckboxClassName, "change", () => {
const checkAllElement = document.querySelector("#batch_checkbox_all");
const selectAllMatchingElement = document.querySelector(".batch-table__select-all");
if (checkAllElement) {
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
@@ -93,78 +93,78 @@ Rails.delegate(document, batchCheckboxClassName, 'change', () => {
}
});
Rails.delegate(document, '.media-spoiler-show-button', 'click', () => {
[].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => {
Rails.delegate(document, ".media-spoiler-show-button", "click", () => {
[].forEach.call(document.querySelectorAll("button.media-spoiler"), (element) => {
element.click();
});
});
Rails.delegate(document, '.media-spoiler-hide-button', 'click', () => {
[].forEach.call(document.querySelectorAll('.spoiler-button.spoiler-button--visible button'), (element) => {
Rails.delegate(document, ".media-spoiler-hide-button", "click", () => {
[].forEach.call(document.querySelectorAll(".spoiler-button.spoiler-button--visible button"), (element) => {
element.click();
});
});
Rails.delegate(document, '.filter-subset--with-select select', 'change', ({ target }) => {
Rails.delegate(document, ".filter-subset--with-select select", "change", ({ target }) => {
target.form.submit();
});
const onDomainBlockSeverityChange = (target) => {
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports');
const rejectMediaDiv = document.querySelector(".input.with_label.domain_block_reject_media");
const rejectReportsDiv = document.querySelector(".input.with_label.domain_block_reject_reports");
if (rejectMediaDiv) {
rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
rejectMediaDiv.style.display = (target.value === "suspend") ? "none" : "block";
}
if (rejectReportsDiv) {
rejectReportsDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
rejectReportsDiv.style.display = (target.value === "suspend") ? "none" : "block";
}
};
Rails.delegate(document, '#domain_block_severity', 'change', ({ target }) => onDomainBlockSeverityChange(target));
Rails.delegate(document, "#domain_block_severity", "change", ({ target }) => onDomainBlockSeverityChange(target));
const onEnableBootstrapTimelineAccountsChange = (target) => {
const bootstrapTimelineAccountsField = document.querySelector('#form_admin_settings_bootstrap_timeline_accounts');
const bootstrapTimelineAccountsField = document.querySelector("#form_admin_settings_bootstrap_timeline_accounts");
if (bootstrapTimelineAccountsField) {
bootstrapTimelineAccountsField.disabled = !target.checked;
if (target.checked) {
bootstrapTimelineAccountsField.parentElement.classList.remove('disabled');
bootstrapTimelineAccountsField.parentElement.parentElement.classList.remove('disabled');
bootstrapTimelineAccountsField.parentElement.classList.remove("disabled");
bootstrapTimelineAccountsField.parentElement.parentElement.classList.remove("disabled");
} else {
bootstrapTimelineAccountsField.parentElement.classList.add('disabled');
bootstrapTimelineAccountsField.parentElement.parentElement.classList.add('disabled');
bootstrapTimelineAccountsField.parentElement.classList.add("disabled");
bootstrapTimelineAccountsField.parentElement.parentElement.classList.add("disabled");
}
}
};
Rails.delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'change', ({ target }) => onEnableBootstrapTimelineAccountsChange(target));
Rails.delegate(document, "#form_admin_settings_enable_bootstrap_timeline_accounts", "change", ({ target }) => onEnableBootstrapTimelineAccountsChange(target));
const onChangeRegistrationMode = (target) => {
const enabled = target.value === 'approved';
const enabled = target.value === "approved";
[].forEach.call(document.querySelectorAll('#form_admin_settings_require_invite_text'), (input) => {
[].forEach.call(document.querySelectorAll("#form_admin_settings_require_invite_text"), (input) => {
input.disabled = !enabled;
if (enabled) {
let element = input;
do {
element.classList.remove('disabled');
element.classList.remove("disabled");
element = element.parentElement;
} while (element && !element.classList.contains('fields-group'));
} while (element && !element.classList.contains("fields-group"));
} else {
let element = input;
do {
element.classList.add('disabled');
element.classList.add("disabled");
element = element.parentElement;
} while (element && !element.classList.contains('fields-group'));
} while (element && !element.classList.contains("fields-group"));
}
});
};
const convertUTCDateTimeToLocal = (value) => {
const date = new Date(value + 'Z');
const twoChars = (x) => (x.toString().padStart(2, '0'));
const date = new Date(value + "Z");
const twoChars = (x) => (x.toString().padStart(2, "0"));
return `${date.getFullYear()}-${twoChars(date.getMonth()+1)}-${twoChars(date.getDate())}T${twoChars(date.getHours())}:${twoChars(date.getMinutes())}`;
};
@@ -173,38 +173,44 @@ const convertLocalDatetimeToUTC = (value) => {
const match = re.exec(value);
const date = new Date(match[1], match[2] - 1, match[3], match[4], match[5]);
const fullISO8601 = date.toISOString();
return fullISO8601.slice(0, fullISO8601.indexOf('T') + 6);
return fullISO8601.slice(0, fullISO8601.indexOf("T") + 6);
};
Rails.delegate(document, '#form_admin_settings_registrations_mode', 'change', ({ target }) => onChangeRegistrationMode(target));
Rails.delegate(document, "#form_admin_settings_registrations_mode", "change", ({ target }) => onChangeRegistrationMode(target));
ready(() => {
const domainBlockSeverityInput = document.getElementById('domain_block_severity');
if (domainBlockSeverityInput) onDomainBlockSeverityChange(domainBlockSeverityInput);
const domainBlockSeverityInput = document.getElementById("domain_block_severity");
if (domainBlockSeverityInput) {
onDomainBlockSeverityChange(domainBlockSeverityInput);
}
const enableBootstrapTimelineAccounts = document.getElementById('form_admin_settings_enable_bootstrap_timeline_accounts');
if (enableBootstrapTimelineAccounts) onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts);
const enableBootstrapTimelineAccounts = document.getElementById("form_admin_settings_enable_bootstrap_timeline_accounts");
if (enableBootstrapTimelineAccounts) {
onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts);
}
const registrationMode = document.getElementById('form_admin_settings_registrations_mode');
if (registrationMode) onChangeRegistrationMode(registrationMode);
const registrationMode = document.getElementById("form_admin_settings_registrations_mode");
if (registrationMode) {
onChangeRegistrationMode(registrationMode);
}
const checkAllElement = document.querySelector('#batch_checkbox_all');
const checkAllElement = document.querySelector("#batch_checkbox_all");
if (checkAllElement) {
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
}
document.querySelector('a#add-instance-button')?.addEventListener('click', (e) => {
const domain = document.querySelector('input[type="text"]#by_domain')?.value;
document.querySelector("a#add-instance-button")?.addEventListener("click", (e) => {
const domain = document.querySelector("input[type=\"text\"]#by_domain")?.value;
if (domain) {
const url = new URL(event.target.href);
url.searchParams.set('_domain', domain);
url.searchParams.set("_domain", domain);
e.target.href = url;
}
});
[].forEach.call(document.querySelectorAll('input[type="datetime-local"]'), element => {
[].forEach.call(document.querySelectorAll("input[type=\"datetime-local\"]"), element => {
if (element.value) {
element.value = convertUTCDateTimeToLocal(element.value);
}
@@ -213,15 +219,15 @@ ready(() => {
}
});
Rails.delegate(document, 'form', 'submit', ({ target }) => {
[].forEach.call(target.querySelectorAll('input[type="datetime-local"]'), element => {
Rails.delegate(document, "form", "submit", ({ target }) => {
[].forEach.call(target.querySelectorAll("input[type=\"datetime-local\"]"), element => {
if (element.value && element.validity.valid) {
element.value = convertLocalDatetimeToUTC(element.value);
}
});
});
const announcementStartsAt = document.querySelector('input[type="datetime-local"]#announcement_starts_at');
const announcementStartsAt = document.querySelector("input[type=\"datetime-local\"]#announcement_starts_at");
if (announcementStartsAt) {
setAnnouncementEndsAttributes(announcementStartsAt);
}

View File

@@ -1,3 +1,3 @@
import 'packs/public-path';
import './settings';
import './two_factor_authentication';
import "packs/public-path";
import "./settings";
import "./two_factor_authentication";

View File

@@ -1,6 +1,6 @@
// This file will be loaded on all pages, regardless of theme.
import 'packs/public-path';
import 'font-awesome/css/font-awesome.css';
import "packs/public-path";
import "font-awesome/css/font-awesome.css";
require.context('../images/', true);
require.context("../images/", true);

View File

@@ -1,25 +1,25 @@
// This file will be loaded on embed pages, regardless of theme.
import 'packs/public-path';
import "packs/public-path";
window.addEventListener('message', e => {
window.addEventListener("message", e => {
const data = e.data || {};
if (!window.parent || data.type !== 'setHeight') {
if (!window.parent || data.type !== "setHeight") {
return;
}
function setEmbedHeight () {
window.parent.postMessage({
type: 'setHeight',
type: "setHeight",
id: data.id,
height: document.getElementsByTagName('html')[0].scrollHeight,
}, '*');
height: document.getElementsByTagName("html")[0].scrollHeight,
}, "*");
}
if (['interactive', 'complete'].includes(document.readyState)) {
if (["interactive", "complete"].includes(document.readyState)) {
setEmbedHeight();
} else {
document.addEventListener('DOMContentLoaded', setEmbedHeight);
document.addEventListener("DOMContentLoaded", setEmbedHeight);
}
});

View File

@@ -1,3 +1,3 @@
import '../styles/mailer.scss';
import "../styles/mailer.scss";
require.context('../icons');
require.context("../icons");

View File

@@ -8,29 +8,29 @@ and performs no other task.
*/
import 'packs/public-path';
import "packs/public-path";
import axios from 'axios';
import axios from "axios";
interface JRDLink {
rel: string;
template?: string;
href?: string;
rel: string,
template?: string,
href?: string,
}
const isJRDLink = (link: unknown): link is JRDLink =>
typeof link === 'object' &&
typeof link === "object" &&
link !== null &&
'rel' in link &&
typeof link.rel === 'string' &&
(!('template' in link) || typeof link.template === 'string') &&
(!('href' in link) || typeof link.href === 'string');
"rel" in link &&
typeof link.rel === "string" &&
(!("template" in link) || typeof link.template === "string") &&
(!("href" in link) || typeof link.href === "string");
const findLink = (rel: string, data: unknown): JRDLink | undefined => {
if (
typeof data === 'object' &&
typeof data === "object" &&
data !== null &&
'links' in data &&
"links" in data &&
data.links instanceof Array
) {
return data.links.find(
@@ -42,7 +42,7 @@ const findLink = (rel: string, data: unknown): JRDLink | undefined => {
};
const findTemplateLink = (data: unknown) =>
findLink('http://ostatus.org/schema/1.0/subscribe', data)?.template;
findLink("http://ostatus.org/schema/1.0/subscribe", data)?.template;
const fetchInteractionURLSuccess = (
uri_or_domain: string,
@@ -50,7 +50,7 @@ const fetchInteractionURLSuccess = (
) => {
window.parent.postMessage(
{
type: 'fetchInteractionURL-success',
type: "fetchInteractionURL-success",
uri_or_domain,
template,
},
@@ -61,14 +61,14 @@ const fetchInteractionURLSuccess = (
const fetchInteractionURLFailure = () => {
window.parent.postMessage(
{
type: 'fetchInteractionURL-failure',
type: "fetchInteractionURL-failure",
},
window.origin,
);
};
const isValidDomain = (value: string) => {
const url = new URL('https:///path');
const url = new URL("https:///path");
url.hostname = value;
return url.hostname === value;
};
@@ -112,9 +112,9 @@ const fromURL = (url: string) => {
// Attempt to find a remote interaction URL from a `user@domain` string
const fromAcct = (acct: string) => {
acct = acct.replace(/^@/, '');
acct = acct.replace(/^@/, "");
const segments = acct.split('@');
const segments = acct.split("@");
if (segments.length !== 2 || !segments[0] || !isValidDomain(segments[1])) {
fetchInteractionURLFailure();
@@ -140,18 +140,18 @@ const fromAcct = (acct: string) => {
};
const fetchInteractionURL = (uri_or_domain: string) => {
if (uri_or_domain === '') {
if (uri_or_domain === "") {
fetchInteractionURLFailure();
} else if (/^https?:\/\//.test(uri_or_domain)) {
fromURL(uri_or_domain);
} else if (uri_or_domain.includes('@')) {
} else if (uri_or_domain.includes("@")) {
fromAcct(uri_or_domain);
} else {
fromDomain(uri_or_domain);
}
};
window.addEventListener('message', (event: MessageEvent<unknown>) => {
window.addEventListener("message", (event: MessageEvent<unknown>) => {
// Check message origin
if (
!window.origin ||
@@ -163,11 +163,11 @@ window.addEventListener('message', (event: MessageEvent<unknown>) => {
if (
event.data &&
typeof event.data === 'object' &&
'type' in event.data &&
event.data.type === 'fetchInteractionURL' &&
'uri_or_domain' in event.data &&
typeof event.data.uri_or_domain === 'string'
typeof event.data === "object" &&
"type" in event.data &&
event.data.type === "fetchInteractionURL" &&
"uri_or_domain" in event.data &&
typeof event.data.uri_or_domain === "string"
) {
fetchInteractionURL(event.data.uri_or_domain);
}

View File

@@ -1,24 +1,24 @@
// This file will be loaded on settings pages, regardless of theme.
import 'packs/public-path';
import Rails from '@rails/ujs';
import "packs/public-path";
import Rails from "@rails/ujs";
Rails.delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
const avatar = document.getElementById(target.id + '-preview');
Rails.delegate(document, "#edit_profile input[type=file]", "change", ({ target }) => {
const avatar = document.getElementById(target.id + "-preview");
const [file] = target.files || [];
const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
avatar.src = url;
});
Rails.delegate(document, '.input-copy input', 'click', ({ target }) => {
Rails.delegate(document, ".input-copy input", "click", ({ target }) => {
target.focus();
target.select();
target.setSelectionRange(0, target.value.length);
});
Rails.delegate(document, '.input-copy button', 'click', ({ target }) => {
const input = target.parentNode.querySelector('.input-copy__wrapper input');
Rails.delegate(document, ".input-copy button", "click", ({ target }) => {
const input = target.parentNode.querySelector(".input-copy__wrapper input");
const oldReadOnly = input.readonly;
@@ -28,12 +28,12 @@ Rails.delegate(document, '.input-copy button', 'click', ({ target }) => {
input.setSelectionRange(0, input.value.length);
try {
if (document.execCommand('copy')) {
if (document.execCommand("copy")) {
input.blur();
target.parentNode.classList.add('copied');
target.parentNode.classList.add("copied");
setTimeout(() => {
target.parentNode.classList.remove('copied');
target.parentNode.classList.remove("copied");
}, 700);
}
} catch (err) {

View File

@@ -1,40 +1,40 @@
import 'packs/public-path';
import "packs/public-path";
import * as WebAuthnJSON from '@github/webauthn-json';
import axios from 'axios';
import * as WebAuthnJSON from "@github/webauthn-json";
import axios from "axios";
import ready from '../mastodon/ready';
import 'regenerator-runtime/runtime';
import ready from "../mastodon/ready";
import "regenerator-runtime/runtime";
function getCSRFToken() {
var CSRFSelector = document.querySelector('meta[name="csrf-token"]');
var CSRFSelector = document.querySelector("meta[name=\"csrf-token\"]");
if (CSRFSelector) {
return CSRFSelector.getAttribute('content');
return CSRFSelector.getAttribute("content");
} else {
return null;
}
}
function hideFlashMessages() {
Array.from(document.getElementsByClassName('flash-message')).forEach(function(flashMessage) {
flashMessage.classList.add('hidden');
Array.from(document.getElementsByClassName("flash-message")).forEach(function(flashMessage) {
flashMessage.classList.add("hidden");
});
}
function callback(url, body) {
axios.post(url, JSON.stringify(body), {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-Token': getCSRFToken(),
"Content-Type": "application/json",
"Accept": "application/json",
"X-CSRF-Token": getCSRFToken(),
},
credentials: 'same-origin',
credentials: "same-origin",
}).then(function(response) {
window.location.replace(response.data.redirect_path);
}).catch(function(error) {
if (error.response.status === 422) {
const errorMessage = document.getElementById('security-key-error-message');
errorMessage.classList.remove('hidden');
const errorMessage = document.getElementById("security-key-error-message");
errorMessage.classList.remove("hidden");
console.error(error.response.data.error);
} else {
console.error(error);
@@ -44,31 +44,31 @@ function callback(url, body) {
ready(() => {
if (!WebAuthnJSON.supported()) {
const unsupported_browser_message = document.getElementById('unsupported-browser-message');
const unsupported_browser_message = document.getElementById("unsupported-browser-message");
if (unsupported_browser_message) {
unsupported_browser_message.classList.remove('hidden');
document.querySelector('.btn.js-webauthn').disabled = true;
unsupported_browser_message.classList.remove("hidden");
document.querySelector(".btn.js-webauthn").disabled = true;
}
}
const webAuthnCredentialRegistrationForm = document.getElementById('new_webauthn_credential');
const webAuthnCredentialRegistrationForm = document.getElementById("new_webauthn_credential");
if (webAuthnCredentialRegistrationForm) {
webAuthnCredentialRegistrationForm.addEventListener('submit', (event) => {
webAuthnCredentialRegistrationForm.addEventListener("submit", (event) => {
event.preventDefault();
var nickname = event.target.querySelector('input[name="new_webauthn_credential[nickname]"]');
var nickname = event.target.querySelector("input[name=\"new_webauthn_credential[nickname]\"]");
if (nickname.value) {
axios.get('/settings/security_keys/options')
axios.get("/settings/security_keys/options")
.then((response) => {
const credentialOptions = response.data;
WebAuthnJSON.create({ 'publicKey': credentialOptions }).then((credential) => {
var params = { 'credential': credential, 'nickname': nickname.value };
callback('/settings/security_keys', params);
WebAuthnJSON.create({ "publicKey": credentialOptions }).then((credential) => {
var params = { "credential": credential, "nickname": nickname.value };
callback("/settings/security_keys", params);
}).catch((error) => {
const errorMessage = document.getElementById('security-key-error-message');
errorMessage.classList.remove('hidden');
const errorMessage = document.getElementById("security-key-error-message");
errorMessage.classList.remove("hidden");
console.error(error);
});
}).catch((error) => {
@@ -80,21 +80,21 @@ ready(() => {
});
}
const webAuthnCredentialAuthenticationForm = document.getElementById('webauthn-form');
const webAuthnCredentialAuthenticationForm = document.getElementById("webauthn-form");
if (webAuthnCredentialAuthenticationForm) {
webAuthnCredentialAuthenticationForm.addEventListener('submit', (event) => {
webAuthnCredentialAuthenticationForm.addEventListener("submit", (event) => {
event.preventDefault();
axios.get('sessions/security_key_options')
axios.get("sessions/security_key_options")
.then((response) => {
const credentialOptions = response.data;
WebAuthnJSON.get({ 'publicKey': credentialOptions }).then((credential) => {
var params = { 'user': { 'credential': credential } };
callback('sign_in', params);
WebAuthnJSON.get({ "publicKey": credentialOptions }).then((credential) => {
var params = { "user": { "credential": credential } };
callback("sign_in", params);
}).catch((error) => {
const errorMessage = document.getElementById('security-key-error-message');
errorMessage.classList.remove('hidden');
const errorMessage = document.getElementById("security-key-error-message");
errorMessage.classList.remove("hidden");
console.error(error);
});
}).catch((error) => {
@@ -102,19 +102,19 @@ ready(() => {
});
});
const otpAuthenticationForm = document.getElementById('otp-authentication-form');
const otpAuthenticationForm = document.getElementById("otp-authentication-form");
const linkToOtp = document.getElementById('link-to-otp');
linkToOtp.addEventListener('click', () => {
webAuthnCredentialAuthenticationForm.classList.add('hidden');
otpAuthenticationForm.classList.remove('hidden');
const linkToOtp = document.getElementById("link-to-otp");
linkToOtp.addEventListener("click", () => {
webAuthnCredentialAuthenticationForm.classList.add("hidden");
otpAuthenticationForm.classList.remove("hidden");
hideFlashMessages();
});
const linkToWebAuthn = document.getElementById('link-to-webauthn');
linkToWebAuthn.addEventListener('click', () => {
otpAuthenticationForm.classList.add('hidden');
webAuthnCredentialAuthenticationForm.classList.remove('hidden');
const linkToWebAuthn = document.getElementById("link-to-webauthn");
linkToWebAuthn.addEventListener("click", () => {
otpAuthenticationForm.classList.add("hidden");
webAuthnCredentialAuthenticationForm.classList.remove("hidden");
hideFlashMessages();
});
}