sign: 504 --> 408

This commit is contained in:
Alex Gleason 2023-05-13 21:25:43 -05:00
parent c14ebe6631
commit 91bc0549c7
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 3 additions and 2 deletions

View File

@ -28,6 +28,7 @@ async function signEvent<K extends number = number>(event: EventTemplate<K>, c:
try { try {
return await new Promise<SignedEvent<K>>((resolve, reject) => { return await new Promise<SignedEvent<K>>((resolve, reject) => {
stream.addEventListener('message', (e) => { stream.addEventListener('message', (e) => {
// TODO: parse and validate with zod
const data = JSON.parse(e.data); const data = JSON.parse(e.data);
if (data.event === 'nostr.sign') { if (data.event === 'nostr.sign') {
resolve(JSON.parse(data.payload)); resolve(JSON.parse(data.payload));
@ -37,8 +38,8 @@ async function signEvent<K extends number = number>(event: EventTemplate<K>, c:
setTimeout(reject, 60000); setTimeout(reject, 60000);
}); });
} catch (_e) { } catch (_e) {
throw new HTTPException(504, { throw new HTTPException(408, {
res: c.json({ id: 'ditto.timeout', error: 'Signing timeout' }, 504), res: c.json({ id: 'ditto.timeout', error: 'Signing timeout' }, 408),
}); });
} }
} }