Use new welshman auth

This commit is contained in:
Jon Staab
2024-10-14 15:29:30 -07:00
parent 5e221d803e
commit d8a0b31d3a
+11 -7
View File
@@ -190,7 +190,10 @@ export const setInboxRelayPolicy = (url: string, enabled: boolean) => {
// Relay access // Relay access
export const checkRelayAccess = async (url: string, claim = "") => { export const checkRelayAccess = async (url: string, claim = "") => {
await ctx.net.pool.get(url).ensureAuth() const connection = ctx.net.pool.get(url)
await connection.auth.attemptIfRequested()
await connection.auth.waitIfPending()
const result = await publishThunk({ const result = await publishThunk({
event: createEvent(28934, {tags: [["claim", claim]]}), event: createEvent(28934, {tags: [["claim", claim]]}),
@@ -214,23 +217,24 @@ export const checkRelayProfile = async (url: string) => {
export const checkRelayConnection = async (url: string) => { export const checkRelayConnection = async (url: string) => {
const connection = ctx.net.pool.get(url) const connection = ctx.net.pool.get(url)
const okStatuses = [ConnectionStatus.Ok, ConnectionStatus.Slow, ConnectionStatus.Unauthorized] const okStatuses = [ConnectionStatus.Ok, ConnectionStatus.Slow]
await connection.ensureConnected() await connection.ensureConnected()
if (!okStatuses.includes(connection.meta.getStatus())) { if (!okStatuses.includes(connection.meta.getStatus())) {
return `Failed to connect: "${connection.meta.getDescription()}"` return `Failed to connect`
} }
} }
export const checkRelayAuth = async (url: string) => { export const checkRelayAuth = async (url: string) => {
const connection = ctx.net.pool.get(url) const connection = ctx.net.pool.get(url)
const okStatuses = [AuthStatus.Ok, AuthStatus.Pending] const okStatuses = [AuthStatus.None, AuthStatus.Ok]
await connection.ensureAuth() await connection.auth.attemptIfRequested()
await connection.auth.waitIfPending()
if (!okStatuses.includes(connection.meta.authStatus)) { if (!okStatuses.includes(connection.auth.status)) {
return `Failed to authenticate: "${connection.meta.authStatus}"` return `Failed to authenticate: "${connection.auth.message}"`
} }
} }