@sockethub/platform-irc 4.0.0-alpha.4 → 4.0.0-alpha.7
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/README.md +68 -73
- package/dist/index.js +2194 -0
- package/dist/index.js.map +23 -0
- package/package.json +32 -24
- package/src/index.test.data.ts +60 -0
- package/src/index.test.ts +277 -0
- package/src/index.ts +764 -0
- package/src/octal-hack.js +4 -0
- package/src/schema.ts +66 -0
- package/src/types.ts +18 -0
- package/API.md +0 -375
- package/index.js +0 -700
- package/index.test.data.js +0 -61
- package/index.test.js +0 -204
package/src/schema.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
2
|
+
const version = packageJson.version;
|
|
3
|
+
|
|
4
|
+
export const PlatformIrcSchema = {
|
|
5
|
+
name: "irc",
|
|
6
|
+
version: version,
|
|
7
|
+
messages: {
|
|
8
|
+
required: ["type"],
|
|
9
|
+
properties: {
|
|
10
|
+
type: {
|
|
11
|
+
enum: [
|
|
12
|
+
"connect",
|
|
13
|
+
"update",
|
|
14
|
+
"join",
|
|
15
|
+
"leave",
|
|
16
|
+
"send",
|
|
17
|
+
"query",
|
|
18
|
+
"announce",
|
|
19
|
+
"disconnect",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
credentials: {
|
|
25
|
+
required: ["object"],
|
|
26
|
+
properties: {
|
|
27
|
+
// TODO platforms shouldn't have to define the actor property
|
|
28
|
+
// if they don't want to, just credential specifics
|
|
29
|
+
actor: {
|
|
30
|
+
type: "object",
|
|
31
|
+
required: ["id"],
|
|
32
|
+
},
|
|
33
|
+
object: {
|
|
34
|
+
type: "object",
|
|
35
|
+
required: ["type", "nick", "server"],
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
properties: {
|
|
38
|
+
type: {
|
|
39
|
+
type: "string",
|
|
40
|
+
},
|
|
41
|
+
nick: {
|
|
42
|
+
type: "string",
|
|
43
|
+
},
|
|
44
|
+
username: {
|
|
45
|
+
type: "string",
|
|
46
|
+
},
|
|
47
|
+
password: {
|
|
48
|
+
type: "string",
|
|
49
|
+
},
|
|
50
|
+
server: {
|
|
51
|
+
type: "string",
|
|
52
|
+
},
|
|
53
|
+
port: {
|
|
54
|
+
type: "number",
|
|
55
|
+
},
|
|
56
|
+
secure: {
|
|
57
|
+
type: "boolean",
|
|
58
|
+
},
|
|
59
|
+
sasl: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActivityActor, CredentialsObject } from "@sockethub/schemas";
|
|
2
|
+
|
|
3
|
+
export interface PlatformIrcCredentialsObject extends CredentialsObject {
|
|
4
|
+
context: "irc";
|
|
5
|
+
type: "credentials";
|
|
6
|
+
actor: ActivityActor;
|
|
7
|
+
target?: ActivityActor;
|
|
8
|
+
object: {
|
|
9
|
+
type: "credentials";
|
|
10
|
+
nick: string;
|
|
11
|
+
server: string;
|
|
12
|
+
username?: string;
|
|
13
|
+
password?: string;
|
|
14
|
+
port?: number;
|
|
15
|
+
secure?: boolean;
|
|
16
|
+
sasl?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
package/API.md
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
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
|
|
43
|
-
JSON schema defining the types this platform accepts.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
In the below example, Sockethub will validate the incoming credentials object
|
|
47
|
-
against whatever is defined in the `credentials` portion of the schema
|
|
48
|
-
object.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
It will also check if the incoming AS object uses a type which exists in the
|
|
52
|
-
`types` portion of the schema object (should be an array of type names).
|
|
53
|
-
|
|
54
|
-
* **NOTE**: For more information on using the credentials object from a client,
|
|
55
|
-
see [Sockethub Client](https://github.com/sockethub/sockethub/wiki/Sockethub-Client)
|
|
56
|
-
|
|
57
|
-
Valid AS object for setting IRC credentials:
|
|
58
|
-
|
|
59
|
-
**Kind**: instance property of [<code>IRC</code>](#IRC)
|
|
60
|
-
**Example**
|
|
61
|
-
```js
|
|
62
|
-
{
|
|
63
|
-
type: 'credentials',
|
|
64
|
-
context: 'irc',
|
|
65
|
-
actor: {
|
|
66
|
-
id: 'testuser@irc.host.net',
|
|
67
|
-
type: 'person',
|
|
68
|
-
name: 'Mr. Test User',
|
|
69
|
-
userName: 'testuser'
|
|
70
|
-
},
|
|
71
|
-
object: {
|
|
72
|
-
type: 'credentials',
|
|
73
|
-
server: 'irc.host.net',
|
|
74
|
-
nick: 'testuser',
|
|
75
|
-
password: 'asdasdasdasd',
|
|
76
|
-
port: 6697,
|
|
77
|
-
secure: true,
|
|
78
|
-
sasl: true
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
<a name="IRC+connect"></a>
|
|
83
|
-
|
|
84
|
-
## irC.connect(job, credentials, done)
|
|
85
|
-
Function: connect
|
|
86
|
-
|
|
87
|
-
Conenct to an IRC server.
|
|
88
|
-
|
|
89
|
-
**Kind**: instance method of [<code>IRC</code>](#IRC)
|
|
90
|
-
<table>
|
|
91
|
-
<thead>
|
|
92
|
-
<tr>
|
|
93
|
-
<th>Param</th><th>Type</th><th>Description</th>
|
|
94
|
-
</tr>
|
|
95
|
-
</thead>
|
|
96
|
-
<tbody>
|
|
97
|
-
<tr>
|
|
98
|
-
<td>job</td><td><code>object</code></td><td><p>activity streams object</p>
|
|
99
|
-
</td>
|
|
100
|
-
</tr><tr>
|
|
101
|
-
<td>credentials</td><td><code>object</code></td><td><p>credentials object</p>
|
|
102
|
-
</td>
|
|
103
|
-
</tr><tr>
|
|
104
|
-
<td>done</td><td><code>object</code></td><td><p>callback when job is done</p>
|
|
105
|
-
</td>
|
|
106
|
-
</tr> </tbody>
|
|
107
|
-
</table>
|
|
108
|
-
|
|
109
|
-
<a name="IRC+join"></a>
|
|
110
|
-
|
|
111
|
-
## irC.join(job, done)
|
|
112
|
-
Function: join
|
|
113
|
-
|
|
114
|
-
Join a room or private conversation.
|
|
115
|
-
|
|
116
|
-
**Kind**: instance method of [<code>IRC</code>](#IRC)
|
|
117
|
-
<table>
|
|
118
|
-
<thead>
|
|
119
|
-
<tr>
|
|
120
|
-
<th>Param</th><th>Type</th><th>Description</th>
|
|
121
|
-
</tr>
|
|
122
|
-
</thead>
|
|
123
|
-
<tbody>
|
|
124
|
-
<tr>
|
|
125
|
-
<td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
|
|
126
|
-
</td>
|
|
127
|
-
</tr><tr>
|
|
128
|
-
<td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
|
|
129
|
-
</td>
|
|
130
|
-
</tr> </tbody>
|
|
131
|
-
</table>
|
|
132
|
-
|
|
133
|
-
**Example**
|
|
134
|
-
```js
|
|
135
|
-
{
|
|
136
|
-
context: 'irc',
|
|
137
|
-
type: 'join',
|
|
138
|
-
actor: {
|
|
139
|
-
id: 'slvrbckt@irc.freenode.net',
|
|
140
|
-
type: 'person',
|
|
141
|
-
name: 'slvrbckt'
|
|
142
|
-
},
|
|
143
|
-
target: {
|
|
144
|
-
id: 'irc.freenode.net/a-room',
|
|
145
|
-
type: 'room',
|
|
146
|
-
name: '#a-room'
|
|
147
|
-
},
|
|
148
|
-
object: {}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
<a name="IRC+leave"></a>
|
|
152
|
-
|
|
153
|
-
## irC.leave(job, done)
|
|
154
|
-
Function leave
|
|
155
|
-
|
|
156
|
-
Leave a room or private conversation.
|
|
157
|
-
|
|
158
|
-
**Kind**: instance method of [<code>IRC</code>](#IRC)
|
|
159
|
-
<table>
|
|
160
|
-
<thead>
|
|
161
|
-
<tr>
|
|
162
|
-
<th>Param</th><th>Type</th><th>Description</th>
|
|
163
|
-
</tr>
|
|
164
|
-
</thead>
|
|
165
|
-
<tbody>
|
|
166
|
-
<tr>
|
|
167
|
-
<td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
|
|
168
|
-
</td>
|
|
169
|
-
</tr><tr>
|
|
170
|
-
<td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
|
|
171
|
-
</td>
|
|
172
|
-
</tr> </tbody>
|
|
173
|
-
</table>
|
|
174
|
-
|
|
175
|
-
**Example**
|
|
176
|
-
```js
|
|
177
|
-
{
|
|
178
|
-
context: 'irc',
|
|
179
|
-
type: 'leave',
|
|
180
|
-
actor: {
|
|
181
|
-
id: 'slvrbckt@irc.freenode.net',
|
|
182
|
-
type: 'person',
|
|
183
|
-
name: 'slvrbckt'
|
|
184
|
-
},
|
|
185
|
-
target: {
|
|
186
|
-
id: 'irc.freenode.net/remotestorage',
|
|
187
|
-
type: 'room',
|
|
188
|
-
name: '#remotestorage'
|
|
189
|
-
},
|
|
190
|
-
object: {}
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
<a name="IRC+send"></a>
|
|
194
|
-
|
|
195
|
-
## irC.send(job, done)
|
|
196
|
-
Function: send
|
|
197
|
-
|
|
198
|
-
Send a message to a room or private conversation.
|
|
199
|
-
|
|
200
|
-
**Kind**: instance method of [<code>IRC</code>](#IRC)
|
|
201
|
-
<table>
|
|
202
|
-
<thead>
|
|
203
|
-
<tr>
|
|
204
|
-
<th>Param</th><th>Type</th><th>Description</th>
|
|
205
|
-
</tr>
|
|
206
|
-
</thead>
|
|
207
|
-
<tbody>
|
|
208
|
-
<tr>
|
|
209
|
-
<td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
|
|
210
|
-
</td>
|
|
211
|
-
</tr><tr>
|
|
212
|
-
<td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
|
|
213
|
-
</td>
|
|
214
|
-
</tr> </tbody>
|
|
215
|
-
</table>
|
|
216
|
-
|
|
217
|
-
**Example**
|
|
218
|
-
```js
|
|
219
|
-
{
|
|
220
|
-
context: 'irc',
|
|
221
|
-
type: 'send',
|
|
222
|
-
actor: {
|
|
223
|
-
id: 'slvrbckt@irc.freenode.net',
|
|
224
|
-
type: 'person',
|
|
225
|
-
name: 'Nick Jennings',
|
|
226
|
-
userName: 'slvrbckt'
|
|
227
|
-
},
|
|
228
|
-
target: {
|
|
229
|
-
id: 'irc.freenode.net/remotestorage',
|
|
230
|
-
type: 'room',
|
|
231
|
-
name: '#remotestorage'
|
|
232
|
-
},
|
|
233
|
-
object: {
|
|
234
|
-
type: 'message',
|
|
235
|
-
content: 'Hello from Sockethub!'
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
```
|
|
239
|
-
<a name="IRC+update"></a>
|
|
240
|
-
|
|
241
|
-
## irC.update(job, done)
|
|
242
|
-
Function: update
|
|
243
|
-
|
|
244
|
-
Indicate a change (ie. room topic update, or nickname change).
|
|
245
|
-
|
|
246
|
-
**Kind**: instance method of [<code>IRC</code>](#IRC)
|
|
247
|
-
<table>
|
|
248
|
-
<thead>
|
|
249
|
-
<tr>
|
|
250
|
-
<th>Param</th><th>Type</th><th>Description</th>
|
|
251
|
-
</tr>
|
|
252
|
-
</thead>
|
|
253
|
-
<tbody>
|
|
254
|
-
<tr>
|
|
255
|
-
<td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
|
|
256
|
-
</td>
|
|
257
|
-
</tr><tr>
|
|
258
|
-
<td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
|
|
259
|
-
</td>
|
|
260
|
-
</tr> </tbody>
|
|
261
|
-
</table>
|
|
262
|
-
|
|
263
|
-
**Example**
|
|
264
|
-
```js
|
|
265
|
-
change topic
|
|
266
|
-
|
|
267
|
-
{
|
|
268
|
-
context: 'irc',
|
|
269
|
-
type: 'update',
|
|
270
|
-
actor: {
|
|
271
|
-
id: 'slvrbckt@irc.freenode.net',
|
|
272
|
-
type: 'person',
|
|
273
|
-
name: 'Nick Jennings',
|
|
274
|
-
userName: 'slvrbckt'
|
|
275
|
-
},
|
|
276
|
-
target: {
|
|
277
|
-
id: 'irc.freenode.net/a-room',
|
|
278
|
-
type: 'room',
|
|
279
|
-
name: '#a-room'
|
|
280
|
-
},
|
|
281
|
-
object: {
|
|
282
|
-
type: 'topic',
|
|
283
|
-
content: 'New version of Socekthub released!'
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
**Example**
|
|
288
|
-
```js
|
|
289
|
-
change nickname
|
|
290
|
-
{
|
|
291
|
-
context: 'irc'
|
|
292
|
-
type: 'udpate',
|
|
293
|
-
actor: {
|
|
294
|
-
id: 'slvrbckt@irc.freenode.net',
|
|
295
|
-
type: 'person',
|
|
296
|
-
name: 'slvrbckt'
|
|
297
|
-
},
|
|
298
|
-
object: {
|
|
299
|
-
type: "address",
|
|
300
|
-
},
|
|
301
|
-
target: {
|
|
302
|
-
id: 'cooldude@irc.freenode.net',
|
|
303
|
-
type: 'person',
|
|
304
|
-
name: cooldude
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
<a name="IRC+query"></a>
|
|
309
|
-
|
|
310
|
-
## irC.query(job, done)
|
|
311
|
-
Function: query
|
|
312
|
-
|
|
313
|
-
Indicate an intent to query something (e.g. get a list of users in a room).
|
|
314
|
-
|
|
315
|
-
**Kind**: instance method of [<code>IRC</code>](#IRC)
|
|
316
|
-
<table>
|
|
317
|
-
<thead>
|
|
318
|
-
<tr>
|
|
319
|
-
<th>Param</th><th>Type</th><th>Description</th>
|
|
320
|
-
</tr>
|
|
321
|
-
</thead>
|
|
322
|
-
<tbody>
|
|
323
|
-
<tr>
|
|
324
|
-
<td>job</td><td><code>object</code></td><td><p>activity streams object // TODO LINK</p>
|
|
325
|
-
</td>
|
|
326
|
-
</tr><tr>
|
|
327
|
-
<td>done</td><td><code>object</code></td><td><p>callback when job is done // TODO LINK</p>
|
|
328
|
-
</td>
|
|
329
|
-
</tr> </tbody>
|
|
330
|
-
</table>
|
|
331
|
-
|
|
332
|
-
**Example**
|
|
333
|
-
```js
|
|
334
|
-
{
|
|
335
|
-
context: 'irc',
|
|
336
|
-
type: 'query',
|
|
337
|
-
actor: {
|
|
338
|
-
id: 'slvrbckt@irc.freenode.net',
|
|
339
|
-
type: 'person',
|
|
340
|
-
name: 'Nick Jennings',
|
|
341
|
-
userName: 'slvrbckt'
|
|
342
|
-
},
|
|
343
|
-
target: {
|
|
344
|
-
id: 'irc.freenode.net/a-room',
|
|
345
|
-
type: 'room',
|
|
346
|
-
name: '#a-room'
|
|
347
|
-
},
|
|
348
|
-
object: {
|
|
349
|
-
type: 'attendance'
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
// The above object might return:
|
|
355
|
-
{
|
|
356
|
-
context: 'irc',
|
|
357
|
-
type: 'query',
|
|
358
|
-
actor: {
|
|
359
|
-
id: 'irc.freenode.net/a-room',
|
|
360
|
-
type: 'room',
|
|
361
|
-
name: '#a-room'
|
|
362
|
-
},
|
|
363
|
-
target: {},
|
|
364
|
-
object: {
|
|
365
|
-
type: 'attendance'
|
|
366
|
-
members: [
|
|
367
|
-
'RyanGosling',
|
|
368
|
-
'PeeWeeHerman',
|
|
369
|
-
'Commando',
|
|
370
|
-
'Smoochie',
|
|
371
|
-
'neo'
|
|
372
|
-
]
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
```
|