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';
const { query } = require('express');
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {

View file

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

View file

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

View file

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

View file

@ -21,21 +21,8 @@
/>
</figure>
<p>Usa tu extensión de Nostr para darte de alta:</p>
<div id="nostr-signup-area">
</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="nostr-signup-area"></div>
<div id="warnings-container"></div>
<div id="sign-up-success" class="top-notification-good">
<img src="/img/circle-check-white.svg" />
<p>