forked from coracle/flotilla
Fix auth timeout on space join, bump welshman
This commit is contained in:
Generated
+9
-9
@@ -34,8 +34,8 @@
|
|||||||
"@welshman/content": "~0.0.12",
|
"@welshman/content": "~0.0.12",
|
||||||
"@welshman/dvm": "~0.0.10",
|
"@welshman/dvm": "~0.0.10",
|
||||||
"@welshman/feeds": "~0.0.25",
|
"@welshman/feeds": "~0.0.25",
|
||||||
"@welshman/lib": "~0.0.24",
|
"@welshman/lib": "~0.0.26",
|
||||||
"@welshman/net": "~0.0.35",
|
"@welshman/net": "~0.0.36",
|
||||||
"@welshman/signer": "~0.0.14",
|
"@welshman/signer": "~0.0.14",
|
||||||
"@welshman/store": "~0.0.12",
|
"@welshman/store": "~0.0.12",
|
||||||
"@welshman/util": "~0.0.45",
|
"@welshman/util": "~0.0.45",
|
||||||
@@ -4117,9 +4117,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@welshman/lib": {
|
"node_modules/@welshman/lib": {
|
||||||
"version": "0.0.24",
|
"version": "0.0.26",
|
||||||
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.24.tgz",
|
"resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.26.tgz",
|
||||||
"integrity": "sha512-MQxCt02IzenSv2hpe/Y2/Gtki/evBprW4EqV7pwO7h2HAjfr1Lo1OYu0b2t6sSTbiFMdIkKIOOWYyeBEFggXQQ==",
|
"integrity": "sha512-RMOsRBb0YXKfAupx1bmrNxacv13pheYvdc91DxGYbtvraPeP+B5C0RR9cQzLfFkv0neCpMA318fYXeTk1KeXaQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@scure/base": "^1.1.6",
|
"@scure/base": "^1.1.6",
|
||||||
@@ -4130,12 +4130,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@welshman/net": {
|
"node_modules/@welshman/net": {
|
||||||
"version": "0.0.35",
|
"version": "0.0.36",
|
||||||
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.35.tgz",
|
"resolved": "https://registry.npmjs.org/@welshman/net/-/net-0.0.36.tgz",
|
||||||
"integrity": "sha512-imPA2DbcQuqMYghhVQiWDf4CfHfgi3f1dn8TYMTw6/gY/9VzUCiquXwkNENR9LfOvhNxm8VZWkIJoqzngWbr8Q==",
|
"integrity": "sha512-ZRYC9Hl45bI/kfnKd+DSX/RnbDIA4VhEGUpQTGikqCjfmbWxvN8zr3ajvkUMQHhe95VyKyjpjQKPpkJn9g6+MQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@welshman/lib": "~0.0.24",
|
"@welshman/lib": "~0.0.25",
|
||||||
"@welshman/util": "~0.0.45",
|
"@welshman/util": "~0.0.45",
|
||||||
"isomorphic-ws": "^5.0.0",
|
"isomorphic-ws": "^5.0.0",
|
||||||
"ws": "^8.16.0"
|
"ws": "^8.16.0"
|
||||||
|
|||||||
+2
-2
@@ -60,8 +60,8 @@
|
|||||||
"@welshman/content": "~0.0.12",
|
"@welshman/content": "~0.0.12",
|
||||||
"@welshman/dvm": "~0.0.10",
|
"@welshman/dvm": "~0.0.10",
|
||||||
"@welshman/feeds": "~0.0.25",
|
"@welshman/feeds": "~0.0.25",
|
||||||
"@welshman/lib": "~0.0.24",
|
"@welshman/lib": "~0.0.26",
|
||||||
"@welshman/net": "~0.0.35",
|
"@welshman/net": "~0.0.36",
|
||||||
"@welshman/signer": "~0.0.14",
|
"@welshman/signer": "~0.0.14",
|
||||||
"@welshman/store": "~0.0.12",
|
"@welshman/store": "~0.0.12",
|
||||||
"@welshman/util": "~0.0.45",
|
"@welshman/util": "~0.0.45",
|
||||||
|
|||||||
+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 connection = ctx.net.pool.get(url)
|
||||||
const okStatuses = [AuthStatus.None, AuthStatus.Ok]
|
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.
|
// Only raise an error if it's not a timeout.
|
||||||
// If it is, odds are the problem is with our signer, not the relay
|
// 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 = "") =>
|
export const attemptRelayAccess = async (url: string, claim = "") => {
|
||||||
(await checkRelayProfile(url)) ||
|
const checks = [checkRelayProfile, checkRelayConnection, checkRelayAccess, checkRelayAuth]
|
||||||
(await checkRelayConnection(url)) ||
|
|
||||||
(await checkRelayAccess(url, claim)) ||
|
for (const check of checks) {
|
||||||
(await checkRelayAuth(url))
|
const error = await check(url)
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
|
import {ifLet} from "@welshman/lib"
|
||||||
import Page from "@lib/components/Page.svelte"
|
import Page from "@lib/components/Page.svelte"
|
||||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||||
@@ -14,14 +15,12 @@
|
|||||||
|
|
||||||
const notification = deriveNotification($page.url.pathname, SPACE_FILTERS, url)
|
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 () => {
|
const checkConnection = async () => {
|
||||||
ifLet(await checkRelayConnection(url), error => {
|
ifLet(await checkRelayConnection(url), error => {
|
||||||
pushToast({theme: "error", message: error})
|
pushToast({theme: "error", message: error})
|
||||||
})
|
})
|
||||||
|
|
||||||
ifLet(await checkRelayAuth(url), error => {
|
ifLet(await checkRelayAuth(url, 30_000), error => {
|
||||||
pushToast({theme: "error", message: error})
|
pushToast({theme: "error", message: error})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user