oportunistic linting stuff

This commit is contained in:
counterweight 2025-03-14 16:24:53 +01:00
parent 983c9644bf
commit 4c28cebdce
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
6 changed files with 143 additions and 113 deletions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
public/javascript/*

View file

@ -1,7 +1,5 @@
'use strict'; 'use strict';
const { query } = require('express');
module.exports = { module.exports = {
up: (queryInterface, Sequelize) => { up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => { return queryInterface.sequelize.transaction((t) => {

View file

@ -3,7 +3,9 @@ module.exports = {
up: (queryInterface, Sequelize) => { up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => { return queryInterface.sequelize.transaction((t) => {
return Promise.all([ return Promise.all([
queryInterface.addConstraint('login_challenge_created', { queryInterface.addConstraint(
'login_challenge_created',
{
fields: ['nostr_challenge_uuid'], fields: ['nostr_challenge_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -12,8 +14,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('nostr_challenge_completed', { { transaction: t }
),
queryInterface.addConstraint(
'nostr_challenge_completed',
{
fields: ['challenge'], fields: ['challenge'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -22,8 +28,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('login_challenge_completed', { { transaction: t }
),
queryInterface.addConstraint(
'login_challenge_completed',
{
fields: ['nostr_challenge_completed_uuid'], fields: ['nostr_challenge_completed_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -32,8 +42,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('offer_deleted', { { transaction: t }
),
queryInterface.addConstraint(
'offer_deleted',
{
fields: ['offer_uuid'], fields: ['offer_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -42,8 +56,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('offer_details_set', { { transaction: t }
),
queryInterface.addConstraint(
'offer_details_set',
{
fields: ['offer_uuid'], fields: ['offer_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -52,8 +70,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('session_related_to_public_key', { { transaction: t }
),
queryInterface.addConstraint(
'session_related_to_public_key',
{
fields: ['session_uuid'], fields: ['session_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -62,8 +84,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('sign_up_challenge_created', { { transaction: t }
),
queryInterface.addConstraint(
'sign_up_challenge_created',
{
fields: ['nostr_challenge_uuid'], fields: ['nostr_challenge_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -72,8 +98,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('sign_up_challenge_created', { { transaction: t }
),
queryInterface.addConstraint(
'sign_up_challenge_created',
{
fields: ['app_invite_uuid'], fields: ['app_invite_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -82,8 +112,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('sign_up_challenge_completed', { { transaction: t }
),
queryInterface.addConstraint(
'sign_up_challenge_completed',
{
fields: ['nostr_challenge_completed_uuid'], fields: ['nostr_challenge_completed_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -92,8 +126,12 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
queryInterface.addConstraint('sign_up_challenge_completed', { { transaction: t }
),
queryInterface.addConstraint(
'sign_up_challenge_completed',
{
fields: ['app_invite_uuid'], fields: ['app_invite_uuid'],
type: 'foreign key', type: 'foreign key',
references: { references: {
@ -102,7 +140,9 @@ module.exports = {
}, },
onDelete: 'cascade', onDelete: 'cascade',
onUpdate: 'cascade', onUpdate: 'cascade',
}), },
{ transaction: t }
),
]); ]);
}); });
}, },

View file

@ -5,7 +5,6 @@ const NostrSignupButton = require('../components/NostrSignupButton');
const warningsContainer = document.getElementById('warnings-container'); const warningsContainer = document.getElementById('warnings-container');
const nostrSignupArea = document.getElementById('nostr-signup-area'); const nostrSignupArea = document.getElementById('nostr-signup-area');
const noExtensionNudges = document.getElementById('no-extension-nudges');
const signUpSuccessNotification = document.getElementById('sign-up-success'); const signUpSuccessNotification = document.getElementById('sign-up-success');
class WarningDiv { class WarningDiv {
@ -120,8 +119,13 @@ const invitesFunction = () => {
} }
async function acceptInvite() { async function acceptInvite() {
const verifyResponse = const verifyResponse = await signupService.requestAndRespondSignUpChallenge(
await signupService.requestAndRespondSignUpChallenge(); {
onNostrErrorCallback: () => {
rejectedNostrWarning.display();
},
}
);
if (verifyResponse.ok) { if (verifyResponse.ok) {
showConfirmationAndRedirect(); showConfirmationAndRedirect();

View file

@ -1,4 +1,4 @@
const requestAndRespondSignUpChallenge = async () => { const requestAndRespondSignUpChallenge = async ({ onNostrErrorCallback }) => {
let challengeResponse; let challengeResponse;
try { try {
challengeResponse = await fetch('/api/signup/nostr-challenge', { challengeResponse = await fetch('/api/signup/nostr-challenge', {
@ -18,7 +18,7 @@ const requestAndRespondSignUpChallenge = async () => {
try { try {
pubkey = await window.nostr.getPublicKey(); pubkey = await window.nostr.getPublicKey();
} catch (error) { } catch (error) {
document.querySelector('#rejected-nostr-nudges').style.display = 'block'; onNostrErrorCallback();
return; return;
} }
const event = { const event = {
@ -33,7 +33,7 @@ const requestAndRespondSignUpChallenge = async () => {
try { try {
signedEvent = await window.nostr.signEvent(event); signedEvent = await window.nostr.signEvent(event);
} catch (error) { } catch (error) {
document.querySelector('#rejected-nostr-nudges').style.display = 'block'; onNostrErrorCallback();
return; return;
} }

View file

@ -21,21 +21,8 @@
/> />
</figure> </figure>
<p>Usa tu extensión de Nostr para darte de alta:</p> <p>Usa tu extensión de Nostr para darte de alta:</p>
<div id="nostr-signup-area"> <div id="nostr-signup-area"></div>
</div> <div id="warnings-container"></div>
<div id="warnings-container">
<div
id="rejected-nostr-nudges"
class="card-secondary"
style="display: none"
>
<p>
Ups, parece que no has aceptado que usemos tus claves. Si te has
equivocado, puedes intentarlo de nuevo.
</p>
</div>
</div>
<div id="sign-up-success" class="top-notification-good"> <div id="sign-up-success" class="top-notification-good">
<img src="/img/circle-check-white.svg" /> <img src="/img/circle-check-white.svg" />
<p> <p>