Commit graph

206 commits

Author SHA1 Message Date
Simon Ser
db0ef39c6b Add support for soju.im/read 2022-02-11 19:32:26 +01:00
Дамјан Георгиевски
1142145c6d fix ping after reconnect
client.setPingInterval was only called once in app.connect(),
but client.disconnect() disables it, and the ping timer is never again set,
even though the client can reconnect.

the change passes the ping time as a parameter to the client, and the
client calls setPingInterval() after a successful WS open event.
2022-02-04 15:54:23 +01:00
delthas
fab42ba2ee commands: add password param to /join 2022-02-02 20:45:18 +01:00
Simon Ser
bd48f36ade lib/irc: add missing Isupport.chanModes
It was called by forEachChannelModeUpdate, but wasn't implemented.
2022-01-31 18:24:34 +01:00
Simon Ser
4cabae89ff lib/irc: add CapRegistry 2021-12-10 15:34:51 +01:00
Simon Ser
f81c564d23 Implement exponential backoff for reconnections
Closes: https://todo.sr.ht/~emersion/gamja/118
2021-12-07 13:05:42 +01:00
Simon Ser
ab3d4dd661 Refactor ISUPPORT handling
Add a helper class to parse ISUPPORT tokens. Instead of having
manual ISUPPORT handling all over the place, use pre-processed
values.
2021-12-07 12:09:10 +01:00
Simon Ser
31b293fa03 lib/client: use Error objects for error events 2021-12-06 23:09:30 +01:00
Simon Ser
f9ec578fce Handle FAIL ACCOUNT_REQUIRED 2021-12-06 22:54:15 +01:00
Simon Ser
305f510501 Read nickname from RPL_WELCOME
References: https://github.com/ircdocs/modern-irc/pull/146
2021-12-06 17:55:47 +01:00
Simon Ser
05f7c6e9fe Add Client.join, show join errors in popup 2021-12-04 17:44:23 +01:00
Simon Ser
fc8aa30756 lib/client: add generic error handling to roundtrip() 2021-12-04 17:22:36 +01:00
Simon Ser
8c8bd43638 lib/client: introduce IRCError 2021-12-04 17:05:34 +01:00
Simon Ser
93ba0e6443 Disable debug logs in production
console.debug logs cause some performance issues because the browser
is forced to save the logged objects just in case the user opens the
debugging tools.

They can be force-enabled back by adding ?debug=1 to the URL.

Only console.debug is disabled, console.log and other levels are a lot
less verbose and still enabled by default.
2021-12-01 11:40:59 +01:00
Simon Ser
be08302c1f Add support for draft/account-registration
A new UI to register and verify accounts is added.
2021-11-30 14:59:44 +01:00
Simon Ser
3e309e9dfe Ignore RPL_AWAY 2021-11-23 17:58:49 +01:00
Simon Ser
24b50a332c lib/client: make authenticate() return a promise
This lets the caller handle the success/failure.
2021-11-21 16:06:13 +01:00
Simon Ser
adefc620de lib/client: send BOUNCER BIND and CAP END immediately
Don't wait for auth to finish. This reduces the number of roundtrips.
2021-11-21 13:48:41 +01:00
Simon Ser
bc3abbec32 lib/client: catch handleMessage errors 2021-11-21 13:48:07 +01:00
Simon Ser
4f927b5536 lib/client: always request sasl cap when available
This will allow us to issue post-registration SASL commands.
2021-11-21 13:35:32 +01:00
Simon Ser
86b08296a0 lib/client: don't disconnect on SASL error if registered
This will let users try multiple auth attempts when we'll implement
post-registration auth.
2021-11-21 13:23:14 +01:00
Simon Ser
25dd6aabf6 lib/client: remove one roundtrip during SASL auth
Instead of waiting for the server's empty challenge, send two
AUTHENTICATE commands in a row.
2021-11-21 13:21:42 +01:00
Simon Ser
51bf8da3d6 lib/client: don't error out if SASL isn't available on RPL_WELCOME
Some servers (soju) might remove the sasl cap on connection
registration.
2021-11-19 19:32:13 +01:00
Simon Ser
be475026c8 lib/irc: fix handling for prefixes without host
name!user is a valid prefix.
2021-11-15 16:05:51 +01:00
Simon Ser
55361c5a2b Store WHO list in RPL_ENDOFWHO
This allows the state-tracker to figure out whether a WHO query
returned no result.
2021-11-10 10:32:23 +01:00
Simon Ser
c11bf6508a Only allow one WHO command at a time
Closes: https://todo.sr.ht/~emersion/gamja/120
2021-11-10 10:08:47 +01:00
Simon Ser
195e4ca371 Don't stop fetching backlog on error
Some servers allow fetching history from some targets but not
others. Don't completely stop fetching chat history on error.

The root cause was a variable shadowing in Client.fetchBatch.
2021-11-10 09:53:17 +01:00
Simon Ser
1206cfae37 Add support for draft/extended-monitor
References: https://github.com/ircv3/ircv3-specifications/pull/466
2021-11-09 12:50:11 +01:00
Simon Ser
74fe6ee944 Auto-join when adding new network on irc:// link click
Closes: https://todo.sr.ht/~emersion/gamja/111
2021-11-07 19:47:49 +01:00
Simon Ser
eb66045371 lib/client: use Client.isMyNick to handle self-NICK messages
This handles case-mapping.
2021-11-03 21:50:33 +01:00
Simon Ser
08cd94d775 lib/irc: add "fullname" to isMeaningfulRealname 2021-11-02 18:12:18 +01:00
Simon Ser
ac7785aa7f lib/client: fix missing account in WHOX 2021-11-02 17:58:00 +01:00
Simon Ser
92043ded2c lib/client: generalize pendingWHOIS, store list in ENDOF* messages
This allows processing a list of replies atomically and receiving
the ENDOF* marker.
2021-10-23 20:03:57 +02:00
Simon Ser
b059e034e2 lib/client: rename whoisDB to pendingWHOIS, garbage collect 2021-10-23 19:48:04 +02:00
Simon Ser
49a59077b7 lib/irc: extend parseURL to support flags and skip auth + options 2021-10-20 14:33:16 +02:00
Simon Ser
4309cf44d3 Avoid using export * as namespace
This isn't supported by Safari.
2021-10-18 23:59:18 +02:00
Simon Ser
12440691c9 Unescape ISUPPORT values
This allows ISUPPORT values to contain spaces.

References: https://github.com/ircdocs/modern-irc/pull/137
2021-10-18 13:29:11 +02:00
Simon Ser
8bdde589bb lib/irc: "unknown" is not a meaningful realname 2021-10-15 17:44:33 +02:00
Simon Ser
1a8d539c9e Use linkifyjs module 2021-10-14 20:55:55 +02:00
Simon Ser
a120d79585 Handle IRC URLs without channel name 2021-10-13 16:47:01 +02:00
Simon Ser
405bc51c26 Handle click on irc:// channel URLs inside buffers
References: https://todo.sr.ht/~emersion/gamja/71
2021-10-13 16:18:59 +02:00
Simon Ser
631f119061 Switch from anchorme to linkifyjs 2021-10-13 15:33:41 +02:00
Simon Ser
21a4a71542 Add support for SASL EXTERNAL
Can be useful when the server is using e.g. a cookie for
authentication purposes.
2021-10-12 17:29:56 +02:00
Simon Ser
8cc61bf577 lib/client: handle MONITOR without value in ISUPPORT 2021-10-07 21:49:54 +02:00
Simon Ser
4577f0a27f components/buffer: pretty-print RPL_CHANNELMODEIS and RPL_CREATIONTIME 2021-10-06 12:12:49 +02:00
Simon Ser
19ee5553f6 components/buffer: add RPL_UMODEIS pretty-printing 2021-10-05 11:22:20 +02:00
Simon Ser
184b29b6e3 Hide meaningless real names 2021-09-21 17:24:39 +02:00
Simon Ser
329f9063d0 Add support for WHOX
This allows querying the account of the user.
2021-09-21 16:58:00 +02:00
Simon Ser
d12e1109b3 Add support for account-notify 2021-09-21 14:49:32 +02:00
Simon Ser
11878aaaa9 Add support for extended-join 2021-09-21 14:29:31 +02:00
Simon Ser
0b0467f019 lib/irc: drop CRLF for outgoing messages
Trailing CRLF must not be included in WebSocket messages.

Closes: https://todo.sr.ht/~emersion/gamja/104
2021-09-18 12:16:54 +02:00
Hubert Hirtz
f78cb8c23b Fix double space introduced before last param 2021-09-17 14:07:58 +02:00
Simon Ser
f17d61ed86 lib/irc: fix formatMessage when last arg starts with colon
Fixes: a51be5037d ("lib/irc: only add colon to trailing arg when necessary")
2021-09-08 10:42:36 +02:00
Simon Ser
76f097e8a8 lib/client: error out on unsupported WebSocket data type 2021-09-06 17:15:52 +02:00
Simon Ser
beef13d273 lib/client: remove WebSocket error event handler
The error event handler is useless, because the error event is never
emitted without a close event, and doesn't give any details about
the error.
2021-09-06 17:11:28 +02:00
Simon Ser
0137a95268 Add support for chghost
See https://ircv3.net/specs/extensions/chghost
2021-09-06 11:20:33 +02:00
Simon Ser
a51be5037d lib/irc: only add colon to trailing arg when necessary
This mirrors go-irc's behavior:

7ba1a1858f/parser.go (L374)

Closes: https://todo.sr.ht/~emersion/gamja/103
2021-09-06 10:52:06 +02:00
Simon Ser
c65ecd66eb Avoid sending empty MONITOR command on startup
Closes: https://todo.sr.ht/~emersion/gamja/102
2021-08-30 10:14:05 +02:00
Simon Ser
e283d9c7ab Add support for MONITOR 2021-08-24 12:53:46 +02:00
Simon Ser
51883292f9 lib/client: fix caps with equal sign in value
CAP=a=b wouldn't parse correctly.
2021-07-04 22:26:31 +02:00
Simon Ser
429450e060 Handle RPL_INVITING 2021-06-24 18:01:24 +02:00
Simon Ser
bc05fd5c11 Treat server broadcasts as highlights 2021-06-23 19:52:45 +02:00
Simon Ser
c187eac3c8 lib/client: reject Client.roundtrip promise on disconnect 2021-06-21 00:18:17 +02:00
delthas
42e0c939f3 lib/linkify: stop using RegExp indices
Co-authored-by: Simon Ser <contact@emersion.fr>
Closes: https://todo.sr.ht/~emersion/gamja/90
2021-06-20 12:54:20 +02:00
Simon Ser
0b3f5ef88b Add irc.forEachChannelModeUpdate helper 2021-06-11 12:54:42 +02:00
Simon Ser
02ba4be438 Don't try to reconnect if the network is down 2021-06-11 09:36:11 +02:00
Simon Ser
4249da4ba8 Add /quiet and /unquiet 2021-06-11 00:27:19 +02:00
Simon Ser
8972130252 s/var/let/ 2021-06-10 18:11:11 +02:00
Simon Ser
a952742d86 Make Client.roundtripChatHistory return an array of messages 2021-06-10 12:47:28 +02:00
Simon Ser
5b0bb43a24 Make Client.fetchBatch more reliable 2021-06-10 12:43:09 +02:00
Simon Ser
ba92b3f677 lib/client: fix batch cleanup 2021-06-10 12:10:08 +02:00
Simon Ser
dd8eca1cfe Switch to server buffer on server name click
Closes: https://todo.sr.ht/~emersion/gamja/68
2021-06-10 12:03:50 +02:00
Simon Ser
d2e41666ad lib/client: set a default server prefix
Set the default server prefix to "*". This allows the rest of the
code to assume all messages always have a prefix.
2021-06-10 11:53:53 +02:00
Simon Ser
41354d3035 lib/client: gracefully handle null in isMyNick/isChannel 2021-06-10 08:51:59 +02:00
Simon Ser
0705f4b182 lib/client: always populate prefix for incoming messages 2021-06-10 08:49:17 +02:00
Simon Ser
52ca3bb91c lib/linkify: add comma to punctuation in channel regex 2021-06-09 16:28:07 +02:00
Simon Ser
a9c1abb064 Route channel mode and invite/except list to channel buffer 2021-06-07 14:13:00 +02:00
Simon Ser
a419e660c0 Don't match punctuation suffix when linkifying channels 2021-06-06 16:00:37 +02:00
Simon Ser
403d7ec7f7 Add case-mapping support to irc.isHighlight
Closes: https://todo.sr.ht/~emersion/gamja/77
2021-06-06 15:52:58 +02:00
Simon Ser
0dfb7623db Add support for labeled-response
It's just used to avoid mixing up messages coming from the server
so far.
2021-06-04 20:38:01 +02:00
Simon Ser
34078d5da7 Add support for draft/event-playback 2021-06-04 19:45:51 +02:00
Simon Ser
651e255ddb Use ISUPPORT CHANTYPES in Client.isChannel 2021-06-04 19:17:39 +02:00
Simon Ser
2c1bb4ce6a Introduce State.handleMessage
Takes an IRC message, updates the state.

Doesn't yet handle all messages, this will be a step-by-step process.
2021-06-04 18:27:21 +02:00
Simon Ser
6e20ad872e Add support for STATUSMSG
Closes: https://todo.sr.ht/~emersion/gamja/65
2021-06-03 13:31:43 +02:00
Simon Ser
283f8af4b1 lib/irc: rename IRC prefix utilities 2021-06-03 13:18:28 +02:00
Simon Ser
63a71e5f5d Add support for incoming INVITE messages 2021-06-03 11:04:32 +02:00
Simon Ser
a4294975a2 Add support for /ban without argument 2021-06-03 10:19:09 +02:00
Simon Ser
91208a6d47 Add support for CHATHISTORY TARGETS
The main motivation is to avoid missing direct messages coming from
other users.

A nice side-effect is that we no longer need to issue CHATHISTORY
queries for each channel we JOIN: instead, we can only fetch
history for targets known to have new messages available (as indicated
by CHATHISTORY TARGETS).

We use read receipts instead of delivery receipts, so that reloading
the webapp restores the exact same state (ie, unread messages are
re-fetched).

References: https://github.com/ircv3/ircv3-specifications/pull/450
2021-06-02 20:37:20 +02:00
Simon Ser
74d9dea5bb Use RegExp match indices in linkifyChannel 2021-06-01 09:53:11 +02:00
Tom Lebreux
0bcd044f10 Linkify channel names 2021-06-01 09:37:35 +02:00
Simon Ser
06ca812d06 Simplify Client.roundtrip callback arg 2021-05-31 17:14:46 +02:00
Simon Ser
619f1db08f Introduce Client.who 2021-05-31 17:11:42 +02:00
Simon Ser
02145b45ad Remove unused arg from Client.whois 2021-05-31 17:04:52 +02:00
Drew DeVault
be1ecf607d Display prefixes in member list
Closes: https://todo.sr.ht/~emersion/gamja/43
2021-05-31 15:56:08 +02:00
Simon Ser
e080e87cb7 Pretty-print MOTD 2021-05-28 10:50:42 +02:00
Simon Ser
5a3edf4769 Fix WHOIS DB not using case-mapping fallback
In case the server advertises an unsupported case-mapping, we have
a fallback.
2021-05-28 09:59:51 +02:00
Simon Ser
7b762b3e8a Unregister PING timer when destroying client 2021-05-28 09:58:06 +02:00
Simon Ser
24fe62f1de Ensure msg.prefix is always populated 2021-05-28 09:49:21 +02:00
Simon Ser
e9d90d4927 Fix TypeError in isHighlight
TypeError: msg.prefix is null
2021-05-28 09:49:21 +02:00
Simon Ser
fc9dfa2dca Implement case-mapping for buffers and message handler 2021-05-27 23:40:08 +02:00