sign: only add stream if nostr=true on the user stream (still subject to change)

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

View File

@ -6,6 +6,9 @@ const streamingController: AppController = (c) => {
const upgrade = c.req.headers.get('upgrade');
const token = c.req.headers.get('sec-websocket-protocol');
const stream = c.req.query('stream');
const nostr = c.req.query('nostr');
if (upgrade?.toLowerCase() !== 'websocket') {
return c.text('Please use websocket protocol', 400);
}
@ -24,8 +27,9 @@ const streamingController: AppController = (c) => {
socket.addEventListener('close', () => console.log('websocket: connection closed'));
socket.addEventListener('message', (e) => console.log('websocket message: ', e.data));
// FIXME: Only do this for nostr.sign events.
signStreams.set(token, socket);
if (stream === 'user' && nostr === 'true') {
signStreams.set(token, socket);
}
return response;
};

View File

@ -34,7 +34,7 @@ async function signEvent<K extends number = number>(event: EventTemplate<K>, c:
}
});
stream.send(JSON.stringify({ event: 'nostr.sign', payload: JSON.stringify(event) }));
setTimeout(reject, 30000);
setTimeout(reject, 60000);
});
} catch (_e) {
throw new HTTPException(504, {