diff --git a/package-lock.json b/package-lock.json index 092d5d2..6dbb612 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" diff --git a/package.json b/package.json index 15e9820..996eef9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/app/commands.ts b/src/app/commands.ts index 7142459..45b876d 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -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 diff --git a/src/routes/spaces/[relay]/+layout.svelte b/src/routes/spaces/[relay]/+layout.svelte index 08e77ee..7ea020e 100644 --- a/src/routes/spaces/[relay]/+layout.svelte +++ b/src/routes/spaces/[relay]/+layout.svelte @@ -1,6 +1,7 @@