mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Fix auth timeout on space join, bump welshman
This commit is contained in:
18
package-lock.json
generated
18
package-lock.json
generated
@@ -34,8 +34,8 @@
|
||||
"@welshman/content": "~0.0.12",
|
||||
"@welshman/dvm": "~0.0.10",
|
||||
"@welshman/feeds": "~0.0.25",
|
||||
"@welshman/lib": "~0.0.24",
|
||||
"@welshman/net": "~0.0.35",
|
||||
"@welshman/lib": "~0.0.26",
|
||||
"@welshman/net": "~0.0.36",
|
||||
"@welshman/signer": "~0.0.14",
|
||||
"@welshman/store": "~0.0.12",
|
||||
"@welshman/util": "~0.0.45",
|
||||
@@ -4117,9 +4117,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@welshman/lib": {
|
||||
"version": "0.0.24",
|
||||
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.24.tgz",
|
||||
"integrity": "sha512-MQxCt02IzenSv2hpe/Y2/Gtki/evBprW4EqV7pwO7h2HAjfr1Lo1OYu0b2t6sSTbiFMdIkKIOOWYyeBEFggXQQ==",
|
||||
"version": "0.0.26",
|
||||
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.26.tgz",
|
||||
"integrity": "sha512-RMOsRBb0YXKfAupx1bmrNxacv13pheYvdc91DxGYbtvraPeP+B5C0RR9cQzLfFkv0neCpMA318fYXeTk1KeXaQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@scure/base": "^1.1.6",
|
||||
@@ -4130,12 +4130,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@welshman/net": {
|
||||
"version": "0.0.35",
|
||||
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.35.tgz",
|
||||
"integrity": "sha512-imPA2DbcQuqMYghhVQiWDf4CfHfgi3f1dn8TYMTw6/gY/9VzUCiquXwkNENR9LfOvhNxm8VZWkIJoqzngWbr8Q==",
|
||||
"version": "0.0.36",
|
||||
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.36.tgz",
|
||||
"integrity": "sha512-ZRYC9Hl45bI/kfnKd+DSX/RnbDIA4VhEGUpQTGikqCjfmbWxvN8zr3ajvkUMQHhe95VyKyjpjQKPpkJn9g6+MQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@welshman/lib": "~0.0.24",
|
||||
"@welshman/lib": "~0.0.25",
|
||||
"@welshman/util": "~0.0.45",
|
||||
"isomorphic-ws": "^5.0.0",
|
||||
"ws": "^8.16.0"
|
||||
|
||||
@@ -60,8 +60,8 @@
|
||||
"@welshman/content": "~0.0.12",
|
||||
"@welshman/dvm": "~0.0.10",
|
||||
"@welshman/feeds": "~0.0.25",
|
||||
"@welshman/lib": "~0.0.24",
|
||||
"@welshman/net": "~0.0.35",
|
||||
"@welshman/lib": "~0.0.26",
|
||||
"@welshman/net": "~0.0.36",
|
||||
"@welshman/signer": "~0.0.14",
|
||||
"@welshman/store": "~0.0.12",
|
||||
"@welshman/util": "~0.0.45",
|
||||
|
||||
@@ -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