You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-8Lines changed: 49 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,9 +102,11 @@ The configuration options are as follows.
102
102
103
103
-`password`: Password used to connect to the network. Most networks don't have one.
104
104
105
-
-`saslPassword`: Will be used for SASL authentication if the sasl property is also true.
105
+
-`saslMechanism`: SASL mechanism to use. Either `"PLAIN"` (default) or `"OAUTHBEARER"`.
106
106
107
-
-`saslUsername`: Will be used for SASL authentication. (Defaults to username if not set).
107
+
-`saslPassword`: The credential sent during SASL. For `PLAIN`, this is the account password. For `OAUTHBEARER`, this is the OAuth 2.0 access token.
108
+
109
+
-`saslUsername`: Account name sent during SASL authentication. Defaults to `username` if not set. Required for `PLAIN`; sent but not used on the wire for `OAUTHBEARER`.
108
110
109
111
-`proxy`: WEBIRC details if your connection is acting as a (probably web-based) proxy.
-**`OAUTHBEARER`** — sends an OAuth 2.0 access token, base64-encoded per [RFC 7628](https://datatracker.ietf.org/doc/html/rfc7628).
175
+
176
+
Providing `saslPassword` triggers SASL. Always request the `sasl` capability so the server negotiates it:
177
+
178
+
```javascript
179
+
capabilities: { requires: ["sasl"] }
180
+
```
181
+
182
+
### PLAIN
169
183
170
184
```javascript
171
185
constclient=IrcSocket({
172
-
capabilities: {
173
-
requires: ["sasl"]
174
-
},
175
-
saslUsername:'exampleuser', // will default to `username` if not specified
176
-
saslPassword:'foo bar'
186
+
capabilities: { requires: ["sasl"] },
187
+
saslUsername:'exampleuser', // defaults to `username` if omitted
188
+
saslPassword:'correct horse battery staple'
177
189
});
178
190
```
179
191
192
+
### OAUTHBEARER
193
+
194
+
Supported by networks such as SourceHut's `chat.sr.ht`. Use this when you have an OAuth 2.0 access token rather than a password:
195
+
196
+
```javascript
197
+
constclient=IrcSocket({
198
+
capabilities: { requires: ["sasl"] },
199
+
saslMechanism:'OAUTHBEARER',
200
+
saslUsername:'exampleuser',
201
+
saslPassword:ACCESS_TOKEN// your OAuth 2.0 access token
202
+
});
203
+
```
204
+
205
+
### Security
206
+
207
+
The bearer token (or password) is sent over the wire. Connect over TLS — typically port `6697` with a `tls.Socket` as the underlying socket — so credentials are not exposed in transit.
208
+
209
+
### Failure handling
210
+
211
+
If the server rejects authentication (numerics `902`, `904`, `905`, `906`, or `907`), the connect promise resolves with `Fail(IrcSocket.connectFailures.saslAuthenticationFailed)` and the socket is closed with `QUIT`. The handshake finalizes on `903` (RPL_SASLSUCCESS); `900` (RPL_LOGGEDIN) is informational. For OAUTHBEARER, when the server responds with an RFC 7628 error challenge instead of the `+` prompt, the client acknowledges with `AUTHENTICATE AQ==` so the server can emit the failure numeric.
212
+
213
+
### Large payloads
214
+
215
+
`AUTHENTICATE` payloads are automatically split into 400-byte chunks per IRCv3 SASL 3.1. You don't need to size credentials manually — long OAuth access tokens are handled transparently.
216
+
217
+
### Unsupported mechanism
218
+
219
+
Passing any `saslMechanism` other than `"PLAIN"` or `"OAUTHBEARER"` throws synchronously at construction.
220
+
180
221
## Writing to the Server ##
181
222
To send messages to the server, use socket.raw(). It accepts either a
182
223
string or an array of Strings. The message '''must''' follow the
0 commit comments