- if (Array.isArray(webfingerData.links) === false) throw new Error('WebFinger links is not an array.')
-
- const selfLink = webfingerData.links.find(l => l.rel === 'self')
- if (selfLink === undefined || isActivityPubUrlValid(selfLink.href) === false) {
- throw new Error('Cannot find self link or href is not a valid URL.')
- }
-
- const account = await fetchRemoteAccount(selfLink.href)
- if (account === undefined) throw new Error('Cannot fetch remote account ' + selfLink.href)