forked from coracle/flotilla
Fix auth timeout on space join, bump welshman
This commit is contained in:
+13
-7
@@ -305,11 +305,11 @@ export const checkRelayConnection = async (url: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const checkRelayAuth = async (url: string) => {
|
||||
export const checkRelayAuth = async (url: string, timeout = 3000) => {
|
||||
const connection = ctx.net.pool.get(url)
|
||||
const okStatuses = [AuthStatus.None, AuthStatus.Ok]
|
||||
|
||||
await connection.auth.attempt(30_000)
|
||||
await connection.auth.attempt(timeout)
|
||||
|
||||
// Only raise an error if it's not a timeout.
|
||||
// If it is, odds are the problem is with our signer, not the relay
|
||||
@@ -318,11 +318,17 @@ export const checkRelayAuth = async (url: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const attemptRelayAccess = async (url: string, claim = "") =>
|
||||
(await checkRelayProfile(url)) ||
|
||||
(await checkRelayConnection(url)) ||
|
||||
(await checkRelayAccess(url, claim)) ||
|
||||
(await checkRelayAuth(url))
|
||||
export const attemptRelayAccess = async (url: string, claim = "") => {
|
||||
const checks = [checkRelayProfile, checkRelayConnection, checkRelayAccess, checkRelayAuth]
|
||||
|
||||
for (const check of checks) {
|
||||
const error = await check(url)
|
||||
|
||||
if (error) {
|
||||
return error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {ifLet} from "@welshman/lib"
|
||||
import Page from "@lib/components/Page.svelte"
|
||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||
@@ -14,14 +15,12 @@
|
||||
|
||||
const notification = deriveNotification($page.url.pathname, SPACE_FILTERS, url)
|
||||
|
||||
const ifLet = <T,>(x: T | undefined, f: (x: T) => void) => (x === undefined ? undefined : f(x))
|
||||
|
||||
const checkConnection = async () => {
|
||||
ifLet(await checkRelayConnection(url), error => {
|
||||
pushToast({theme: "error", message: error})
|
||||
})
|
||||
|
||||
ifLet(await checkRelayAuth(url), error => {
|
||||
ifLet(await checkRelayAuth(url, 30_000), error => {
|
||||
pushToast({theme: "error", message: error})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user