mirror of
https://github.com/vitorpamplona/Nostryfied.git
synced 2025-06-06 18:31:07 +00:00
hosts authentication state
This commit is contained in:
parent
a0096ca9b3
commit
eda7ef2346
@ -119,7 +119,8 @@ const fetchFromRelay = async (relay, filters, pubkey, events, relayStatus) =>
|
|||||||
lastEvent: null,
|
lastEvent: null,
|
||||||
done: false,
|
done: false,
|
||||||
filter: filter,
|
filter: filter,
|
||||||
eventIds: new Set()
|
eventIds: new Set(),
|
||||||
|
isAuthenticating: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}))
|
}))
|
||||||
@ -209,6 +210,7 @@ const fetchFromRelay = async (relay, filters, pubkey, events, relayStatus) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msgType === 'AUTH') {
|
if (msgType === 'AUTH') {
|
||||||
|
subscriptions[subscriptionId].isAuthenticating = true
|
||||||
signNostrAuthEvent(relay, subscriptionId).then(
|
signNostrAuthEvent(relay, subscriptionId).then(
|
||||||
(event) => {
|
(event) => {
|
||||||
if (event) {
|
if (event) {
|
||||||
@ -227,7 +229,7 @@ const fetchFromRelay = async (relay, filters, pubkey, events, relayStatus) =>
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgType === 'CLOSED') {
|
if (msgType === 'CLOSED' && !subscriptions[subscriptionId].isAuthenticating) {
|
||||||
subscriptions[subscriptionId].done = true
|
subscriptions[subscriptionId].done = true
|
||||||
|
|
||||||
let alldone = Object.values(subscriptions).every(filter => filter.done === true);
|
let alldone = Object.values(subscriptions).every(filter => filter.done === true);
|
||||||
@ -239,6 +241,7 @@ const fetchFromRelay = async (relay, filters, pubkey, events, relayStatus) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msgType === 'OK') {
|
if (msgType === 'OK') {
|
||||||
|
subscriptions[subscriptionId].isAuthenticating = false
|
||||||
// auth ok.
|
// auth ok.
|
||||||
for (const [key, sub] of Object.entries(subscriptions)) {
|
for (const [key, sub] of Object.entries(subscriptions)) {
|
||||||
ws.send(JSON.stringify(['REQ', sub.id, sub.filter]))
|
ws.send(JSON.stringify(['REQ', sub.id, sub.filter]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user