Improve feed loader, wait for db before executing reads/updates, make taskQueue subscribable, add race, rename auth methods, fix failed wasm verify, fix localhost urls
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import EventEmitter from "events"
|
||||
import {on, call} from "@welshman/lib"
|
||||
import {on, poll, call} from "@welshman/lib"
|
||||
import {SignedEvent, StampedEvent} from "@welshman/util"
|
||||
import {makeEvent, CLIENT_AUTH} from "@welshman/util"
|
||||
import {isRelayAuth, isClientAuth, isRelayOk, RelayMessage} from "./message.js"
|
||||
@@ -97,7 +97,7 @@ export class AuthState extends EventEmitter {
|
||||
this.emit(AuthStateEvent.Status, status)
|
||||
}
|
||||
|
||||
async authenticate(sign: (event: StampedEvent) => Promise<SignedEvent>) {
|
||||
async doAuth(sign: (event: StampedEvent) => Promise<SignedEvent>) {
|
||||
if (!this.challenge) {
|
||||
throw new Error("Attempted to authenticate with no challenge")
|
||||
}
|
||||
@@ -119,6 +119,24 @@ export class AuthState extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
async attemptAuth(sign: (event: StampedEvent) => Promise<SignedEvent>) {
|
||||
this.socket.attemptToOpen()
|
||||
|
||||
await poll({
|
||||
signal: AbortSignal.timeout(800),
|
||||
condition: () => this.status === AuthStatus.Requested,
|
||||
})
|
||||
|
||||
if (this.status === AuthStatus.Requested) {
|
||||
await this.doAuth(sign)
|
||||
}
|
||||
|
||||
await poll({
|
||||
signal: AbortSignal.timeout(800),
|
||||
condition: () => this.status !== AuthStatus.PendingResponse,
|
||||
})
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
this.removeAllListeners()
|
||||
this._unsubscribers.forEach(call)
|
||||
|
||||
Reference in New Issue
Block a user