remove old stuff

This commit is contained in:
counterweight 2025-02-13 00:05:35 +01:00
parent fb9832fabb
commit d4f01ea843
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
4 changed files with 2 additions and 198 deletions

View file

@ -2,7 +2,6 @@ const uuid = require('uuid');
const nostrService = require('./nostrService');
const AppInviteCreated = require('../models/AppInviteCreated');
const PublicKeySignedUp = require('../models/PublicKeySignedUp');
const SignUpChallengeCreated = require('../models/SignUpChallengeCreated');
const SignUpChallengeCompleted = require('../models/SignUpChallengeCompleted');
@ -67,16 +66,6 @@ async function createSignUpChallenge(appInviteUuid) {
)
}
async function hasSignUpChallengeBeenCompleted(nostrChallengeCompletedUuid) {
const signUpChallengeCompleted = await SignUpChallengeCompleted.findOne(
{
where:
{
}
}
)
}
async function verifySignUpChallenge(signedEvent) {
@ -119,38 +108,11 @@ async function verifySignUpChallenge(signedEvent) {
return completedSignUpChallenge;
}
async function signUpPublicKey(inviteUuid, publicKey) {
if (await isAppInviteSpent(inviteUuid)) {
throw new Error("Can't invite npub, invite is already spent.");
}
await PublicKeySignedUp.create({
uuid: uuid.v7(),
app_invite_uuid: inviteUuid,
public_key: publicKey,
created_at: new Date().toISOString()
});
}
async function isPublicKeySignedUp(publicKey) {
if (await PublicKeySignedUp.findOne({
where: { public_key: publicKey }
})) {
return true;
}
return false;
}
module.exports = {
appInviteExists,
getAppInvite,
isAppInviteSpent,
createAppInvite,
createSignUpChallenge,
verifySignUpChallenge,
signUpPublicKey,
isPublicKeySignedUp
verifySignUpChallenge
};

View file

@ -1,9 +1,6 @@
const uuid = require("uuid");
const SessionCreated = require('../models/SessionCreated');
const SessionNpubbed = require('../models/SessionNpubbed');
const invitesService = require('./invitesService');
const constants = require('../constants');
@ -37,54 +34,5 @@ async function isSessionExpired(sessionUuid) {
return false;
}
async function relateSessionToNpub(sessionUuid, npub) {
await SessionNpubbed.create({
session_npubbed_uuid: uuid.v7(),
session_uuid: sessionUuid,
npub,
created_at: new Date().toISOString()
});
}
async function isSessionAlreadyRelatedToNpub(sessionUuid, npub) {
if (await SessionNpubbed.findOne({ where: { 'session_uuid': sessionUuid, npub } })) {
return true;
}
return false;
}
async function getNpubRelatedToSession(sessionUuid) {
const mostRecentSession = await SessionNpubbed.findOne({
where: { 'session_uuid': sessionUuid },
order: [['created_at', 'DESC']]
});
if (!mostRecentSession) {
return null;
}
return mostRecentSession.npub;
}
async function isSessionAuthorized(sessionUuid) {
if (await isSessionExpired(sessionUuid)) {
return false;
}
const npub = await getNpubRelatedToSession(sessionUuid);
if (await invitesService.isPublicKeySignedUp(npub)) {
return true;
}
return false;
}
exports.createSession = createSession;
exports.isSessionExpired = isSessionExpired;
exports.relateSessionToNpub = relateSessionToNpub;
exports.isSessionAlreadyRelatedToNpub = isSessionAlreadyRelatedToNpub;
exports.isSessionAuthorized = isSessionAuthorized;