@sockethub/platform-irc 4.0.0-alpha.3 → 4.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/API.md CHANGED
@@ -1,45 +1,56 @@
1
- <a name="IRC"></a>
2
-
3
- # IRC
4
- IRC
5
-
6
- **Kind**: global class
7
-
8
- * [IRC](#IRC)
9
- * [new IRC(cfg)](#new_IRC_new)
10
- * [.schema](#IRC+schema)
11
- * [.connect(job, credentials, done)](#IRC+connect)
12
- * [.join(job, done)](#IRC+join)
13
- * [.leave(job, done)](#IRC+leave)
14
- * [.send(job, done)](#IRC+send)
15
- * [.update(job, done)](#IRC+update)
16
- * [.query(job, done)](#IRC+query)
17
-
18
- <a name="new_IRC_new"></a>
19
-
20
- ## new IRC(cfg)
21
- Handles all actions related to communication via. the IRC protocol.
22
-
23
- Uses the `irc-factory` node module as a base tool for interacting with IRC.
24
-
25
- [https://github.com/ircanywhere/irc-factory](https://github.com/ircanywhere/irc-factory)
26
-
27
- <table>
28
- <thead>
29
- <tr>
30
- <th>Param</th><th>Type</th><th>Description</th>
31
- </tr>
32
- </thead>
33
- <tbody>
34
- <tr>
35
- <td>cfg</td><td><code>object</code></td><td><p>a unique config object for this instance // TODO LINK</p>
36
- </td>
37
- </tr> </tbody>
38
- </table>
39
-
40
- <a name="IRC+schema"></a>
41
-
42
- ## irC.schema
1
+ # Members
2
+
3
+ <dl>
4
+ <dt><a href="#schema">schema</a></dt>
5
+ <dd><p>JSON schema defining the types this platform accepts.</p>
6
+ <p>In the below example, Sockethub will validate the incoming credentials object
7
+ against whatever is defined in the <code>credentials</code> portion of the schema
8
+ object.</p>
9
+ <p>It will also check if the incoming AS object uses a type which exists in the
10
+ <code>types</code> portion of the schema object (should be an array of type names).</p>
11
+ <ul>
12
+ <li><strong>NOTE</strong>: For more information on using the credentials object from a client,
13
+ see <a href="https://github.com/sockethub/sockethub/wiki/Sockethub-Client">Sockethub Client</a></li>
14
+ </ul>
15
+ <p>Valid AS object for setting IRC credentials:</p>
16
+ </dd>
17
+ </dl>
18
+
19
+ # Functions
20
+
21
+ <dl>
22
+ <dt><a href="#connect">connect(job, credentials, done)</a></dt>
23
+ <dd><p>Function: connect</p>
24
+ <p>Connect to an IRC server.</p>
25
+ </dd>
26
+ <dt><a href="#join">join(job, done)</a></dt>
27
+ <dd><p>Function: join</p>
28
+ <p>Join a room or private conversation.</p>
29
+ </dd>
30
+ <dt><a href="#leave">leave(job, done)</a></dt>
31
+ <dd><p>Function leave</p>
32
+ <p>Leave a room or private conversation.</p>
33
+ </dd>
34
+ <dt><a href="#send">send(job, done)</a></dt>
35
+ <dd><p>Function: send</p>
36
+ <p>Send a message to a room or private conversation.</p>
37
+ </dd>
38
+ <dt><a href="#update">update(job, credentials, done)</a></dt>
39
+ <dd><p>Function: update</p>
40
+ <p>Indicate a change (i.e. room topic update, or nickname change).</p>
41
+ </dd>
42
+ <dt><a href="#query">query(job, done)</a></dt>
43
+ <dd><p>Function: query</p>
44
+ <p>Indicate an intent to query something (e.g. get a list of users in a room).</p>
45
+ </dd>
46
+ <dt><a href="#disconnect">disconnect(job, done)</a></dt>
47
+ <dd><p>Disconnect IRC client</p>
48
+ </dd>
49
+ </dl>
50
+
51
+ <a name="schema"></a>
52
+
53
+ # schema
43
54
  JSON schema defining the types this platform accepts.
44
55
 
45
56
 
@@ -56,7 +67,7 @@ see [Sockethub Client](https://github.com/sockethub/sockethub/wiki/Sockethub-Cli
56
67
 
57
68
  Valid AS object for setting IRC credentials:
58
69
 
59
- **Kind**: instance property of [<code>IRC</code>](#IRC)
70
+ **Kind**: global variable
60
71
  **Example**
61
72
  ```js
62
73
  {
@@ -72,21 +83,21 @@ Valid AS object for setting IRC credentials:
72
83
  type: 'credentials',
73
84
  server: 'irc.host.net',
74
85
  nick: 'testuser',
75
- password: 'asdasdasdasd',
86
+ password: 'secret',
76
87
  port: 6697,
77
88
  secure: true,
78
89
  sasl: true
79
90
  }
80
91
  }
81
92
  ```
82
- <a name="IRC+connect"></a>
93
+ <a name="connect"></a>
83
94
 
84
- ## irC.connect(job, credentials, done)
95
+ # connect(job, credentials, done)
85
96
  Function: connect
86
97
 
87
- Conenct to an IRC server.
98
+ Connect to an IRC server.
88
99
 
89
- **Kind**: instance method of [<code>IRC</code>](#IRC)
100
+ **Kind**: global function
90
101
  <table>
91
102
  <thead>
92
103
  <tr>
@@ -106,14 +117,14 @@ Conenct to an IRC server.
106
117
  </tr> </tbody>
107
118
  </table>
108
119
 
109
- <a name="IRC+join"></a>
120
+ <a name="join"></a>
110
121
 
111
- ## irC.join(job, done)
122
+ # join(job, done)
112
123
  Function: join
113
124
 
114
125
  Join a room or private conversation.
115
126
 
116
- **Kind**: instance method of [<code>IRC</code>](#IRC)
127
+ **Kind**: global function
117
128
  <table>
118
129
  <thead>
119
130
  <tr>
@@ -122,10 +133,10 @@ Join a room or private conversation.
122
133
  </thead>
123
134
  <tbody>
124
135
  <tr>
125
- <td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
136
+ <td>job</td><td><code>object</code></td><td><p>activity streams object</p>
126
137
  </td>
127
138
  </tr><tr>
128
- <td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
139
+ <td>done</td><td><code>object</code></td><td><p>callback when job is done</p>
129
140
  </td>
130
141
  </tr> </tbody>
131
142
  </table>
@@ -148,14 +159,14 @@ Join a room or private conversation.
148
159
  object: {}
149
160
  }
150
161
  ```
151
- <a name="IRC+leave"></a>
162
+ <a name="leave"></a>
152
163
 
153
- ## irC.leave(job, done)
164
+ # leave(job, done)
154
165
  Function leave
155
166
 
156
167
  Leave a room or private conversation.
157
168
 
158
- **Kind**: instance method of [<code>IRC</code>](#IRC)
169
+ **Kind**: global function
159
170
  <table>
160
171
  <thead>
161
172
  <tr>
@@ -164,10 +175,10 @@ Leave a room or private conversation.
164
175
  </thead>
165
176
  <tbody>
166
177
  <tr>
167
- <td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
178
+ <td>job</td><td><code>object</code></td><td><p>activity streams object</p>
168
179
  </td>
169
180
  </tr><tr>
170
- <td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
181
+ <td>done</td><td><code>object</code></td><td><p>callback when job is done</p>
171
182
  </td>
172
183
  </tr> </tbody>
173
184
  </table>
@@ -190,14 +201,14 @@ Leave a room or private conversation.
190
201
  object: {}
191
202
  }
192
203
  ```
193
- <a name="IRC+send"></a>
204
+ <a name="send"></a>
194
205
 
195
- ## irC.send(job, done)
206
+ # send(job, done)
196
207
  Function: send
197
208
 
198
209
  Send a message to a room or private conversation.
199
210
 
200
- **Kind**: instance method of [<code>IRC</code>](#IRC)
211
+ **Kind**: global function
201
212
  <table>
202
213
  <thead>
203
214
  <tr>
@@ -206,10 +217,10 @@ Send a message to a room or private conversation.
206
217
  </thead>
207
218
  <tbody>
208
219
  <tr>
209
- <td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
220
+ <td>job</td><td><code>object</code></td><td><p>activity streams object</p>
210
221
  </td>
211
222
  </tr><tr>
212
- <td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
223
+ <td>done</td><td><code>object</code></td><td><p>callback when job is done</p>
213
224
  </td>
214
225
  </tr> </tbody>
215
226
  </table>
@@ -236,14 +247,14 @@ Send a message to a room or private conversation.
236
247
  }
237
248
  }
238
249
  ```
239
- <a name="IRC+update"></a>
250
+ <a name="update"></a>
240
251
 
241
- ## irC.update(job, done)
252
+ # update(job, credentials, done)
242
253
  Function: update
243
254
 
244
- Indicate a change (ie. room topic update, or nickname change).
255
+ Indicate a change (i.e. room topic update, or nickname change).
245
256
 
246
- **Kind**: instance method of [<code>IRC</code>](#IRC)
257
+ **Kind**: global function
247
258
  <table>
248
259
  <thead>
249
260
  <tr>
@@ -252,10 +263,13 @@ Indicate a change (ie. room topic update, or nickname change).
252
263
  </thead>
253
264
  <tbody>
254
265
  <tr>
255
- <td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
266
+ <td>job</td><td><code>object</code></td><td><p>activity streams object</p>
267
+ </td>
268
+ </tr><tr>
269
+ <td>credentials</td><td><code>object</code></td><td><p>credentials to verify this user is the right one</p>
256
270
  </td>
257
271
  </tr><tr>
258
- <td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
272
+ <td>done</td><td><code>object</code></td><td><p>callback when job is done</p>
259
273
  </td>
260
274
  </tr> </tbody>
261
275
  </table>
@@ -280,7 +294,7 @@ change topic
280
294
  },
281
295
  object: {
282
296
  type: 'topic',
283
- content: 'New version of Socekthub released!'
297
+ content: 'New version of Sockethub released!'
284
298
  }
285
299
  }
286
300
  ```
@@ -289,7 +303,7 @@ change topic
289
303
  change nickname
290
304
  {
291
305
  context: 'irc'
292
- type: 'udpate',
306
+ type: 'update',
293
307
  actor: {
294
308
  id: 'slvrbckt@irc.freenode.net',
295
309
  type: 'person',
@@ -301,18 +315,18 @@ change nickname
301
315
  target: {
302
316
  id: 'cooldude@irc.freenode.net',
303
317
  type: 'person',
304
- name: cooldude
318
+ name: 'cooldude'
305
319
  }
306
320
  }
307
321
  ```
308
- <a name="IRC+query"></a>
322
+ <a name="query"></a>
309
323
 
310
- ## irC.query(job, done)
324
+ # query(job, done)
311
325
  Function: query
312
326
 
313
327
  Indicate an intent to query something (e.g. get a list of users in a room).
314
328
 
315
- **Kind**: instance method of [<code>IRC</code>](#IRC)
329
+ **Kind**: global function
316
330
  <table>
317
331
  <thead>
318
332
  <tr>
@@ -321,10 +335,10 @@ Indicate an intent to query something (e.g. get a list of users in a room).
321
335
  </thead>
322
336
  <tbody>
323
337
  <tr>
324
- <td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
338
+ <td>job</td><td><code>object</code></td><td><p>activity streams object</p>
325
339
  </td>
326
340
  </tr><tr>
327
- <td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
341
+ <td>done</td><td><code>object</code></td><td><p>callback when job is done</p>
328
342
  </td>
329
343
  </tr> </tbody>
330
344
  </table>
@@ -373,3 +387,35 @@ Indicate an intent to query something (e.g. get a list of users in a room).
373
387
  }
374
388
  }
375
389
  ```
390
+ <a name="disconnect"></a>
391
+
392
+ # disconnect(job, done)
393
+ Disconnect IRC client
394
+
395
+ **Kind**: global function
396
+ <table>
397
+ <thead>
398
+ <tr>
399
+ <th>Param</th><th>Type</th><th>Description</th>
400
+ </tr>
401
+ </thead>
402
+ <tbody>
403
+ <tr>
404
+ <td>job</td><td><code>object</code></td><td><p>activity streams object</p>
405
+ </td>
406
+ </tr><tr>
407
+ <td>done</td><td></td><td></td>
408
+ </tr> </tbody>
409
+ </table>
410
+
411
+ **Example**
412
+ ```js
413
+ {
414
+ context: 'irc',
415
+ type: 'disconnect',
416
+ actor: {
417
+ id: 'slvrbckt@irc.freenode.net',
418
+ type: 'person'
419
+ }
420
+ }
421
+ ```
package/README.md CHANGED
@@ -1,96 +1,91 @@
1
- # sockethub-platform-irc
1
+ # @sockethub/platform-irc
2
2
 
3
- A sockethub platform module implementing IRC functionality.
3
+ A Sockethub platform module implementing IRC (Internet Relay Chat) functionality.
4
4
 
5
5
  ## About
6
6
 
7
- This module contains all of the implementation details of an IRC client and is
8
- used as a sockethub platform.
7
+ This platform provides IRC client functionality, allowing web applications to connect to
8
+ IRC servers, join channels, send messages, and handle IRC events through ActivityStreams
9
+ messages.
9
10
 
10
- ## Implemented (`@type`)
11
- <kbd>![completed](http://sockethub.org/res/img/checkmark.png) send</kbd>
12
- <kbd>![completed](http://sockethub.org/res/img/checkmark.png) join</kbd>
13
- <kbd>![completed](http://sockethub.org/res/img/checkmark.png) leave</kbd>
14
- <kbd>![completed](http://sockethub.org/res/img/checkmark.png) observe</kbd>
15
- <kbd>![completed](http://sockethub.org/res/img/checkmark.png) update</kbd>
11
+ ## Implemented Verbs (`@type`)
16
12
 
17
- ## Example
13
+ * **send** - Send messages to channels or users
14
+ * **join** - Join IRC channels
15
+ * **leave** - Leave IRC channels
16
+ * **observe** - Monitor channel activity and user events
17
+ * **update** - Update user information (nick, etc.)
18
18
 
19
- Each sockethub platform uses JSON Activity Streams 2.0 which are received from and sent to clients, through the Sockethub service.
19
+ ## Usage
20
20
 
21
- ### Incoming
22
- Connected to IRC
21
+ ### Send Message Example
23
22
 
24
23
  ```json
25
24
  {
26
- "@type": "announce",
25
+ "@type": "send",
27
26
  "context": "irc",
28
27
  "actor": {
29
- "@id": "irc.freenode.net",
30
- "@type": "service"
28
+ "@id": "mynick@irc.libera.chat"
31
29
  },
32
- "published": "2015-05-20T22:32:06.212Z",
33
30
  "target": {
34
- "@id": "foobar@irc.freenode.net",
35
- "@type": "person",
36
- "displayName": "Foobar McUser"
31
+ "@id": "#general@irc.libera.chat"
37
32
  },
38
33
  "object": {
39
- "@type": "content",
40
- "content": {
41
- "network":{
42
- "name":"freenode",
43
- "hostname":"orwell.freenode.net",
44
- "ircd":"ircd-seven-1.1.3",
45
- "nicklength":16,
46
- "maxtargets":{
47
- "NAMES":1,
48
- "LIST":1,
49
- "KICK":1,
50
- "WHOIS":1,
51
- "PRIVMSG":4,
52
- "NOTICE":4,
53
- "ACCEPT":0,
54
- "MONITOR":0
55
- }
56
- },
57
- "channel":{
58
- "idlength":{
59
-
60
- },
61
- "limit":{
62
- "#":120
63
- },
64
- "length":50,
65
- "modes":4,
66
- "types":"#",
67
- "kicklength":0,
68
- "topiclength":390
69
- },
70
- "modes":{
71
- "user":"DOQRSZaghilopswz",
72
- "channel":"CFILMPQSbcefgijklmnopqrstvz",
73
- "param":"bkloveqjfI",
74
- "types":{
75
- "a":"eIbq",
76
- "b":"kov",
77
- "c":"flj",
78
- "d":"CFLMPQScgimnprstz"
79
- },
80
- "prefixes":"@+",
81
- "prefixmodes":{
82
- "o":"@",
83
- "v":"+"
84
- },
85
- "maxlist":{
86
- "bqeI":100
87
- }
88
- }
89
- }
34
+ "@type": "Note",
35
+ "content": "Hello IRC channel!"
90
36
  }
91
37
  }
92
38
  ```
93
39
 
40
+ ### Join Channel Example
41
+
42
+ ```json
43
+ {
44
+ "@type": "join",
45
+ "context": "irc",
46
+ "actor": {
47
+ "@id": "mynick@irc.libera.chat"
48
+ },
49
+ "target": {
50
+ "@id": "#general@irc.libera.chat"
51
+ }
52
+ }
53
+ ```
54
+
55
+ ### Private Message Example
56
+
57
+ ```json
58
+ {
59
+ "@type": "send",
60
+ "context": "irc",
61
+ "actor": {
62
+ "@id": "mynick@irc.libera.chat"
63
+ },
64
+ "target": {
65
+ "@id": "friend@irc.libera.chat"
66
+ },
67
+ "object": {
68
+ "@type": "Note",
69
+ "content": "Hello friend!"
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## Features
75
+
76
+ * **Channel communication**: Join and participate in IRC channels
77
+ * **Private messaging**: Send direct messages to other users
78
+ * **User management**: Handle nick changes and user information
79
+ * **Network support**: Connect to various IRC networks
80
+ * **Event handling**: Process IRC events and convert to ActivityStreams
81
+
82
+ ## Use Cases
83
+
84
+ * **Web IRC clients**: Build browser-based IRC chat applications
85
+ * **Chatbots**: Create IRC bots that integrate with web services
86
+ * **Notification systems**: Send alerts to IRC channels
87
+ * **Community integration**: Connect web platforms to IRC communities
88
+
94
89
  ## API
95
90
 
96
- API docs can be found [here](API.md)
91
+ Detailed API documentation can be found [here](API.md)
package/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "@sockethub/platform-irc",
3
3
  "description": "A sockethub platform module implementing IRC functionality",
4
- "version": "4.0.0-alpha.3",
4
+ "version": "4.0.0-alpha.6",
5
5
  "private": false,
6
6
  "author": "Nick Jennings <nick@silverbucket.net>",
7
7
  "license": "LGPL-3.0+",
8
- "main": "index.js",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "type": "module",
12
+ "main": "src/index.ts",
13
+ "engines": {
14
+ "bun": ">=1.2"
15
+ },
9
16
  "keywords": [
10
17
  "sockethub",
11
18
  "messaging",
@@ -22,20 +29,16 @@
22
29
  },
23
30
  "homepage": "https://github.com/sockethub/sockethub/tree/master/packages/platform-irc",
24
31
  "dependencies": {
25
- "@sockethub/irc2as": "^4.0.0-alpha.3",
32
+ "@sockethub/irc2as": "4.0.0-alpha.6",
26
33
  "irc-socket-sasl": "4.0.0"
27
34
  },
28
35
  "devDependencies": {
29
- "@sockethub/schemas": "^3.0.0-alpha.3",
30
- "c8": "7.11.0",
31
- "chai": "4.3.6",
32
- "eslint": "8.9.0",
33
- "jsdoc-to-markdown": "7.1.1",
34
- "proxyquire": "2.1.3",
35
- "sinon": "13.0.1"
36
+ "@sockethub/schemas": "3.0.0-alpha.6",
37
+ "@types/bun": "latest",
38
+ "typedoc": "^0.28.14"
36
39
  },
37
40
  "peerDependencies": {
38
- "@sockethub/server": ">=5.0.0-alpha.2"
41
+ "@sockethub/server": "5.0.0-alpha.6"
39
42
  },
40
43
  "peerDependenciesMeta": {
41
44
  "@sockethub/server": {
@@ -43,15 +46,7 @@
43
46
  }
44
47
  },
45
48
  "scripts": {
46
- "build": "true",
47
- "clean": "npx rimraf coverage",
48
- "clean:deps": "npx rimraf coverage node_modules",
49
- "compliance": "yarn run lint && yarn run test && yarn run coverage",
50
- "test": "c8 mocha *.test.js",
51
- "coverage": "c8 check-coverage --statements 80 --branches 55 --functions 85 --lines 80",
52
- "doc": "jsdoc2md --no-gfm --heading-depth 1 index.js > API.md",
53
- "lint": "eslint \"**/*.js\"",
54
- "lint:fix": "eslint --fix \"**/*.js\""
55
- },
56
- "gitHead": "f02238a478b7ffd3f31d8deea292eb67e630a86b"
49
+ "doc": "typedoc --options typedoc.json"
50
+ },
51
+ "gitHead": "f8a937e071e7a209f94b94f63e68faa27784e00e"
57
52
  }
@@ -0,0 +1,60 @@
1
+ export default [
2
+ {
3
+ name: "irc credentials",
4
+ valid: true,
5
+ type: "credentials",
6
+ input: {
7
+ context: "irc",
8
+ type: "credentials",
9
+ actor: {
10
+ id: "sh-9K3Vk@irc.freenode.net",
11
+ type: "person",
12
+ name: "sh-9K3Vk",
13
+ image: {
14
+ height: 250,
15
+ mediaType: "image/jpeg",
16
+ url: "http://example.org/image.jpg",
17
+ width: 250,
18
+ },
19
+ url: "http://sockethub.org",
20
+ },
21
+ object: {
22
+ type: "credentials",
23
+ nick: "sh-9K3Vk",
24
+ port: 6667,
25
+ secure: false,
26
+ server: "irc.freenode.net",
27
+ },
28
+ },
29
+ output: "same",
30
+ },
31
+ {
32
+ name: "bad irc credentials: user/nick host/server",
33
+ valid: false,
34
+ type: "credentials",
35
+ input: {
36
+ context: "irc",
37
+ type: "credentials",
38
+ actor: {
39
+ id: "sh-9K3Vk@irc.freenode.net",
40
+ type: "person",
41
+ name: "sh-9K3Vk",
42
+ image: {
43
+ height: 250,
44
+ mediaType: "image/jpeg",
45
+ url: "http://example.org/image.jpg",
46
+ width: 250,
47
+ },
48
+ url: "http://sockethub.org",
49
+ },
50
+ object: {
51
+ type: "credentials",
52
+ user: "sh-9K3Vk",
53
+ port: 6667,
54
+ secure: false,
55
+ host: "irc.freenode.net",
56
+ },
57
+ },
58
+ error: "Error: [irc] /object: must NOT have additional properties: host",
59
+ },
60
+ ];