fix: trying to fix tweetnacl again

This commit is contained in:
Steve Korshakov 2025-08-26 21:52:13 -07:00
parent d92a421259
commit 83ef6a13c2
3 changed files with 8 additions and 5 deletions

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "UploadedFile" ADD COLUMN "reuseKey" TEXT;

View File

@ -212,6 +212,7 @@ model UploadedFile {
accountId String
account Account @relation(fields: [accountId], references: [id])
path String
reuseKey String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

View File

@ -249,7 +249,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
})
}
}, async (request, reply) => {
const tweetnacl = await import("tweetnacl");
const tweetnacl = (await import("tweetnacl")).default;
const publicKey = privacyKit.decodeBase64(request.body.publicKey);
const challenge = privacyKit.decodeBase64(request.body.challenge);
const signature = privacyKit.decodeBase64(request.body.signature);
@ -291,7 +291,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
}
}
}, async (request, reply) => {
const tweetnacl = await import("tweetnacl");
const tweetnacl = (await import("tweetnacl")).default;
const publicKey = privacyKit.decodeBase64(request.body.publicKey);
const isValid = tweetnacl.box.publicKeyLength === publicKey.length;
if (!isValid) {
@ -330,7 +330,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
}
}, async (request, reply) => {
log({ module: 'auth-response' }, `Auth response endpoint hit - user: ${request.userId}, publicKey: ${request.body.publicKey.substring(0, 20)}...`);
const tweetnacl = await import("tweetnacl");
const tweetnacl = (await import("tweetnacl")).default;
const publicKey = privacyKit.decodeBase64(request.body.publicKey);
const isValid = tweetnacl.box.publicKeyLength === publicKey.length;
if (!isValid) {
@ -604,7 +604,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
}
}
}, async (request, reply) => {
const tweetnacl = await import("tweetnacl");
const tweetnacl = (await import("tweetnacl")).default;
const publicKey = privacyKit.decodeBase64(request.body.publicKey);
const isValid = tweetnacl.box.publicKeyLength === publicKey.length;
if (!isValid) {
@ -639,7 +639,7 @@ export async function startApi(): Promise<{ app: FastifyInstance; io: Server }>
})
}
}, async (request, reply) => {
const tweetnacl = await import("tweetnacl");
const tweetnacl = (await import("tweetnacl")).default;
const publicKey = privacyKit.decodeBase64(request.body.publicKey);
const isValid = tweetnacl.box.publicKeyLength === publicKey.length;
if (!isValid) {