From 0b3a6ef062a4ff1616e9f396d78bef665426b404 Mon Sep 17 00:00:00 2001
From: Wiktor Kwapisiewicz <wiktor@metacode.biz>
Date: Mon, 24 Mar 2025 14:11:56 +0100
Subject: [PATCH] Add support for verifying OFTC IRC accounts

OFTC IRC server does not support `TAXONOMY` feature that is used by
Libera Chat. As a fallback this patch introduces checking the `URL`
INFO field that can be set with `SET URL ...` message to `NickServ`.

Tested using the following code:

```js
doip = require('.')
doip.fetcher.irc.fn({nick: 'wiktor', domain: 'irc.oftc.net'}, { claims: { irc: { nick: 'fgafbyuaer' }}}).then(console.log.bind(console), console.error.bind(console))
```

which prints:

```json
[ 'aspe:metacode.biz:CK7LM6VO32K2AGIDXC7LYFRBSA' ]
```

Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
---
 src/fetcher/irc.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/fetcher/irc.js b/src/fetcher/irc.js
index 024b914..f2bed98 100644
--- a/src/fetcher/irc.js
+++ b/src/fetcher/irc.js
@@ -68,6 +68,7 @@ export async function fn (data, opts) {
       })
       const reKey = /[a-zA-Z0-9\-_]+\s+:\s((?:openpgp4fpr|aspe):.*)/
       const reEnd = /End\sof\s.*\staxonomy./
+      const reUrl = /[^a-zA-Z0-9\-_]((?:openpgp4fpr|aspe):[a-zA-Z0-9:\-.]+)/
       const keys = []
 
       // @ts-ignore
@@ -88,6 +89,16 @@ export async function fn (data, opts) {
           client.disconnect()
           resolve(keys)
         }
+        /// OFTC does not support TAXONOMY but supports URL in INFO
+        if (text.includes('Unknown command') && text.includes('TAXONOMY')) {
+          client.send(`PRIVMSG NickServ INFO ${data.nick}`)
+        } else {
+          const match = text.match(reUrl)
+          if (match) {
+            client.disconnect()
+            resolve([match[1]])
+          }
+        }
       })
     } catch (error) {
       reject(error)