@sockethub/irc2as 4.0.0-alpha.11 → 4.0.0-alpha.12

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 CHANGED
@@ -11,8 +11,15 @@ of them, and as time goes on hopefully become more compliant (PRs & feedback wel
11
11
  ## Usage
12
12
 
13
13
  ```javascript
14
- var IRC2AS = require('irc2as');
15
- var irc2as = new IRC2AS({server: 'irc.freenode.net'});
14
+ import { IrcToActivityStreams } from '@sockethub/irc2as';
15
+ const irc2as = new IrcToActivityStreams({
16
+ server: 'irc.freenode.net',
17
+ contexts: [
18
+ 'https://www.w3.org/ns/activitystreams',
19
+ 'https://sockethub.org/ns/context/v1.jsonld',
20
+ 'https://sockethub.org/ns/context/platform/irc/v1.jsonld'
21
+ ]
22
+ });
16
23
 
17
24
  irc2as.events.on('incoming', function (asObject) {
18
25
  console.log('activity stream: ', asObject);
package/dist/index.js CHANGED
@@ -6,9 +6,13 @@ var EVENT_INCOMING = "incoming";
6
6
  var EVENT_ERROR = "error";
7
7
 
8
8
  class ASEmitter {
9
- constructor(events, server) {
9
+ constructor(events, server, contexts) {
10
+ if (!Array.isArray(contexts) || contexts.length === 0) {
11
+ throw new Error("ASEmitter requires a non-empty contexts array from the caller");
12
+ }
10
13
  this.server = server;
11
14
  this.events = events;
15
+ this.contexts = [...contexts];
12
16
  }
13
17
  emitEvent(code, asObject) {
14
18
  if (typeof asObject === "object" && !asObject.published) {
@@ -18,7 +22,7 @@ class ASEmitter {
18
22
  }
19
23
  __generalError(nick, content) {
20
24
  return {
21
- context: "irc",
25
+ "@context": this.contexts,
22
26
  type: "update",
23
27
  actor: {
24
28
  type: "person",
@@ -34,7 +38,7 @@ class ASEmitter {
34
38
  }
35
39
  presence(nick, role, channel) {
36
40
  this.emitEvent(EVENT_INCOMING, {
37
- context: "irc",
41
+ "@context": this.contexts,
38
42
  type: "update",
39
43
  actor: {
40
44
  type: "person",
@@ -54,7 +58,7 @@ class ASEmitter {
54
58
  }
55
59
  channelError(channel, nick, content) {
56
60
  this.emitEvent(EVENT_ERROR, {
57
- context: "irc",
61
+ "@context": this.contexts,
58
62
  type: "update",
59
63
  actor: {
60
64
  type: "person",
@@ -72,7 +76,7 @@ class ASEmitter {
72
76
  }
73
77
  notice(nick, content) {
74
78
  this.emitEvent(EVENT_INCOMING, {
75
- context: "irc",
79
+ "@context": this.contexts,
76
80
  type: "send",
77
81
  actor: {
78
82
  type: "service",
@@ -94,7 +98,7 @@ class ASEmitter {
94
98
  }
95
99
  joinError(nick) {
96
100
  this.emitEvent(EVENT_ERROR, {
97
- context: "irc",
101
+ "@context": this.contexts,
98
102
  type: "join",
99
103
  actor: {
100
104
  id: this.server,
@@ -109,7 +113,7 @@ class ASEmitter {
109
113
  }
110
114
  topicChange(channel, nick, content) {
111
115
  this.emitEvent(EVENT_INCOMING, {
112
- context: "irc",
116
+ "@context": this.contexts,
113
117
  type: "update",
114
118
  actor: {
115
119
  type: "person",
@@ -129,7 +133,7 @@ class ASEmitter {
129
133
  }
130
134
  joinRoom(channel, nick) {
131
135
  this.emitEvent(EVENT_INCOMING, {
132
- context: "irc",
136
+ "@context": this.contexts,
133
137
  type: "join",
134
138
  actor: {
135
139
  type: "person",
@@ -145,7 +149,7 @@ class ASEmitter {
145
149
  }
146
150
  userQuit(nick) {
147
151
  this.emitEvent(EVENT_INCOMING, {
148
- context: "irc",
152
+ "@context": this.contexts,
149
153
  type: "leave",
150
154
  actor: {
151
155
  type: "person",
@@ -164,7 +168,7 @@ class ASEmitter {
164
168
  }
165
169
  userPart(channel, nick) {
166
170
  this.emitEvent(EVENT_INCOMING, {
167
- context: "irc",
171
+ "@context": this.contexts,
168
172
  type: "leave",
169
173
  actor: {
170
174
  type: "person",
@@ -193,7 +197,7 @@ class ASEmitter {
193
197
  message = content;
194
198
  }
195
199
  this.emitEvent(EVENT_INCOMING, {
196
- context: "irc",
200
+ "@context": this.contexts,
197
201
  type: "send",
198
202
  actor: {
199
203
  type: "person",
@@ -213,7 +217,7 @@ class ASEmitter {
213
217
  }
214
218
  role(type, nick, target, role, channel) {
215
219
  this.emitEvent(EVENT_INCOMING, {
216
- context: "irc",
220
+ "@context": this.contexts,
217
221
  type,
218
222
  actor: {
219
223
  type: "person",
@@ -242,7 +246,7 @@ class ASEmitter {
242
246
  }
243
247
  nickChange(nick, content) {
244
248
  this.emitEvent(EVENT_INCOMING, {
245
- context: "irc",
249
+ "@context": this.contexts,
246
250
  type: "update",
247
251
  actor: {
248
252
  type: "person",
@@ -314,6 +318,10 @@ class IrcToActivityStreams {
314
318
  constructor(cfg) {
315
319
  const config = cfg || {};
316
320
  this.server = config.server;
321
+ if (!Array.isArray(config.contexts) || config.contexts.length === 0) {
322
+ throw new Error("IrcToActivityStreams requires a non-empty contexts array");
323
+ }
324
+ this.contexts = [...config.contexts];
317
325
  this.events = new events.EventEmitter;
318
326
  this.__buffer = {};
319
327
  this.__buffer[NAMES] = {};
@@ -336,7 +344,7 @@ class IrcToActivityStreams {
336
344
  this.__processIRCCodes(code, server, channel, pos1, pos2, pos3, content, msg, incoming);
337
345
  }
338
346
  __processIRCCodes(code, server, channel, pos1, pos2, pos3, content, msg, incoming) {
339
- const ase = new ASEmitter(this.events, this.server);
347
+ const ase = new ASEmitter(this.events, this.server, this.contexts);
340
348
  let nick;
341
349
  let type;
342
350
  let role;
@@ -384,7 +392,7 @@ class IrcToActivityStreams {
384
392
  case MOTD:
385
393
  if (!this.__buffer[MOTD]) {
386
394
  this.__buffer[MOTD] = {
387
- context: "irc",
395
+ "@context": this.contexts,
388
396
  type: "update",
389
397
  actor: {
390
398
  type: "service",
@@ -441,7 +449,7 @@ class IrcToActivityStreams {
441
449
  break;
442
450
  case TOPIC_IS:
443
451
  this.__buffer[TOPIC_IS] = {
444
- context: "irc",
452
+ "@context": this.contexts,
445
453
  type: "update",
446
454
  actor: undefined,
447
455
  target: {
@@ -488,4 +496,4 @@ export {
488
496
  IrcToActivityStreams
489
497
  };
490
498
 
491
- //# debugId=5327FF84B5B5443164756E2164756E21
499
+ //# debugId=4861334B3E0B639464756E2164756E21
package/dist/index.js.map CHANGED
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.js", "../src/as-emitter.js"],
4
4
  "sourcesContent": [
5
- "import events from \"node:events\";\nimport { ASEmitter } from \"./as-emitter.js\";\n\nconst EVENT_INCOMING = \"incoming\";\n// EVENT_ERROR = 'error',\nconst EVENT_PONG = \"pong\";\nconst EVENT_PING = \"ping\";\nconst EVENT_UNPROCESSED = \"unprocessed\";\n\nconst ERR_BAD_NICK = \"432\";\nconst ERR_CHAN_PRIVS = \"482\";\nconst ERR_NICK_IN_USE = \"433\";\nconst ERR_TEMP_UNAVAIL = \"437\";\nconst ERR_NO_CHANNEL = \"403\";\nconst ERR_NOT_INVITED = \"471\";\nconst ERR_BADMODE = \"472\";\nconst ERR_INVITE_ONLY = \"473\";\nconst ERR_BANNED = \"474\";\nconst ERR_BADKEY = \"475\";\nconst ERR_BADMASK = \"476\";\nconst ERR_NOCHANMODES = \"477\";\nconst ERR_BANLISTFULL = \"478\";\nconst JOIN = \"JOIN\";\nconst MODE = \"MODE\";\nconst MOTD = \"372\";\nconst MOTD_END = \"376\";\nconst NAMES = \"353\";\n// NAMES_END = \"366\",\nconst NICK = \"NICK\";\nconst NOTICE = \"NOTICE\";\nconst PART = \"PART\";\nconst PING = \"PING\";\nconst PONG = \"PONG\";\nconst PRIVMSG = \"PRIVMSG\";\nconst QUIT = \"QUIT\";\nconst TOPIC_CHANGE = \"TOPIC\";\nconst TOPIC_IS = \"332\";\nconst TOPIC_SET_BY = \"333\";\nconst WHO = \"352\";\nconst WHO_OLD = \"354\";\n// WHO_END = \"315\";\n\nconst ROLE = {\n \"@\": \"owner\",\n \"%\": \"admin\",\n \"*\": \"participant\",\n};\n\nconst MODES = {\n o: \"owner\",\n h: \"admin\",\n v: \"participant\",\n};\n\nfunction getNickFromServer(server) {\n return server.split(/^:/)[1].split(\"!\")[0];\n}\n\nexport class IrcToActivityStreams {\n constructor(cfg) {\n const config = cfg || {};\n this.server = config.server;\n this.events = new events.EventEmitter();\n this.__buffer = {};\n this.__buffer[NAMES] = {};\n }\n\n input(payload) {\n if (typeof payload !== \"string\") {\n return false;\n }\n if (payload.length < 3) {\n return false;\n }\n const incoming = payload.trim();\n const [metadata, content] = incoming.split(\" :\");\n const [server, code, pos1, pos2, pos3, ...msg] = metadata.split(\" \");\n const channel =\n typeof pos1 === \"string\" && pos1.startsWith(\"#\")\n ? pos1\n : typeof pos2 === \"string\" && pos2.startsWith(\"#\")\n ? pos2\n : typeof pos3 === \"string\" && pos3.startsWith(\"#\")\n ? pos3\n : undefined;\n if (metadata === PING) {\n this.events.emit(EVENT_PING, `${Date.now()}`);\n return true;\n }\n this.__processIRCCodes(\n code,\n server,\n channel,\n pos1,\n pos2,\n pos3,\n content,\n msg,\n incoming,\n );\n }\n\n __processIRCCodes(\n code,\n server,\n channel,\n pos1,\n pos2,\n pos3,\n content,\n msg,\n incoming,\n ) {\n const ase = new ASEmitter(this.events, this.server);\n let nick;\n let type;\n let role;\n\n switch (code) {\n /** */\n case ERR_CHAN_PRIVS:\n case ERR_NOT_INVITED:\n case ERR_BADMODE:\n case ERR_INVITE_ONLY:\n case ERR_BANNED:\n case ERR_BADKEY:\n case ERR_BADMASK:\n case ERR_NOCHANMODES:\n case ERR_BANLISTFULL:\n ase.channelError(channel, pos1, content);\n break;\n\n /** */\n case ERR_NICK_IN_USE: // nick conflict\n case ERR_BAD_NICK:\n ase.serviceError(pos2, content);\n break;\n\n /** */\n case ERR_NO_CHANNEL: // no such channel\n ase.joinError(pos2);\n break;\n\n /** */\n case ERR_TEMP_UNAVAIL: // nick conflict\n ase.nickError(pos2, content);\n break;\n\n /** */\n case JOIN: // room join\n ase.joinRoom(channel, getNickFromServer(server));\n break;\n\n // custom event indicating a channel mode has been updated, used to re-query user or channel\n case MODE: {\n const user_mode = pos2 || content;\n if (!channel) {\n break;\n } // don't handle cases with no channel defined\n if (!pos3) {\n break;\n } // we need target user\n role = MODES[user_mode[1]] || \"member\";\n type = \"add\";\n if (user_mode[0] === \"-\") {\n type = \"remove\";\n }\n ase.role(type, getNickFromServer(server), pos3, role, channel);\n break;\n }\n\n /** */\n case MOTD: // MOTD\n if (!this.__buffer[MOTD]) {\n this.__buffer[MOTD] = {\n context: \"irc\",\n type: \"update\",\n actor: {\n type: \"service\",\n id: this.server,\n name: this.server,\n },\n object: {\n type: \"topic\",\n content: content,\n },\n };\n } else {\n this.__buffer[MOTD].object.content += ` ${content}`;\n }\n break;\n case MOTD_END: // end of MOTD\n if (!this.__buffer[MOTD]) {\n break;\n }\n ase.emitEvent(EVENT_INCOMING, this.__buffer[MOTD]);\n delete this.__buffer[MOTD];\n break;\n\n /** */\n case NAMES: // user list\n for (const entry of content.split(\" \")) {\n role = \"member\";\n let username = entry;\n if (ROLE[entry[0]]) {\n username = entry.substr(1);\n role = ROLE[entry[0]];\n }\n ase.presence(username, role, channel);\n }\n break;\n\n /** */\n case NICK: // nick change\n // log(`- 2 nick: ${nick} from content: ${content}`);\n ase.nickChange(getNickFromServer(server), content);\n break;\n\n /** */\n case NOTICE: // notice\n ase.notice(pos1, content);\n break;\n\n /** */\n case PART: // leaving\n ase.userPart(channel, getNickFromServer(server));\n break;\n\n /** */\n case PONG: // ping response received\n this.events.emit(EVENT_PONG, `${Date.now()}`);\n break;\n\n /** */\n case PRIVMSG: // msg\n ase.privMsg(getNickFromServer(server), pos1, content);\n break;\n\n /** */\n case QUIT: // quit user\n ase.userQuit(getNickFromServer(server));\n break;\n\n /** */\n case TOPIC_CHANGE: // topic changed now\n ase.topicChange(channel, getNickFromServer(server), content);\n break;\n\n /** */\n case TOPIC_IS: // topic currently set to\n this.__buffer[TOPIC_IS] = {\n context: \"irc\",\n type: \"update\",\n actor: undefined,\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"topic\",\n content: content,\n },\n };\n break;\n case TOPIC_SET_BY: // current topic set by\n if (!this.__buffer[TOPIC_IS]) {\n break;\n }\n nick = pos3.split(\"!\")[0];\n this.__buffer[TOPIC_IS].actor = {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n };\n this.__buffer[TOPIC_IS].published = msg[0];\n ase.emitEvent(EVENT_INCOMING, this.__buffer[TOPIC_IS]);\n delete this.__buffer[TOPIC_IS];\n break;\n\n /** */\n case WHO:\n case WHO_OLD:\n nick = msg[3].length <= 2 ? msg[2] : msg[3];\n if (nick === \"undefined\") {\n break;\n }\n role = MODES[pos2[1]] || \"member\";\n ase.presence(nick, role, channel);\n break;\n\n /** */\n default:\n this.events.emit(EVENT_UNPROCESSED, incoming);\n break;\n }\n }\n}\n",
6
- "const EVENT_INCOMING = \"incoming\";\nconst EVENT_ERROR = \"error\";\n\nexport class ASEmitter {\n constructor(events, server) {\n this.server = server;\n this.events = events;\n }\n\n emitEvent(code, asObject) {\n if (typeof asObject === \"object\" && !asObject.published) {\n asObject.published = `${Date.now()}`;\n }\n this.events.emit(code, asObject);\n }\n\n __generalError(nick, content) {\n return {\n context: \"irc\",\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"service\",\n id: this.server,\n },\n error: content,\n };\n }\n\n presence(nick, role, channel) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"presence\",\n role: role,\n },\n });\n }\n\n channelError(channel, nick, content) {\n this.emitEvent(EVENT_ERROR, {\n context: \"irc\",\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n },\n error: content,\n });\n }\n\n nickError(nick, content) {\n this.emitEvent(EVENT_ERROR, this.__generalError(nick, content));\n }\n\n notice(nick, content) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"send\",\n actor: {\n type: \"service\",\n id: this.server,\n },\n object: {\n type: \"message\",\n content: content,\n },\n target: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n });\n }\n\n serviceError(nick, content) {\n this.emitEvent(EVENT_ERROR, this.__generalError(nick, content));\n }\n\n joinError(nick) {\n this.emitEvent(EVENT_ERROR, {\n context: \"irc\",\n type: \"join\",\n actor: {\n id: this.server,\n type: \"service\",\n },\n error: `no such channel ${nick}`,\n target: {\n id: `${nick}@${this.server}`,\n type: \"person\",\n },\n });\n }\n\n topicChange(channel, nick, content) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"topic\",\n content: content,\n },\n });\n }\n\n joinRoom(channel, nick) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"join\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n });\n }\n\n userQuit(nick) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"leave\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"service\",\n id: this.server,\n },\n object: {\n type: \"message\",\n content: \"user has quit\",\n },\n });\n }\n\n userPart(channel, nick) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"leave\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"message\",\n content: \"user has left the channel\",\n },\n });\n }\n\n privMsg(nick, target, content) {\n let type;\n let message;\n if (content.startsWith(\"+\\u0001ACTION \")) {\n type = \"me\";\n message = content\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>\n .split(/^\\+\\u0001ACTION\\s+/)[1]\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>\n .split(/\\u0001$/)[0];\n } else {\n type = \"message\";\n message = content;\n }\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"send\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: target.startsWith(\"#\") ? \"room\" : \"person\",\n id: `${this.server}/${target}`,\n name: target,\n },\n object: {\n type: type,\n content: message,\n },\n });\n }\n\n role(type, nick, target, role, channel) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: type,\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"person\",\n id: `${target}@${this.server}`,\n name: target,\n },\n object: {\n type: \"relationship\",\n relationship: \"role\",\n subject: {\n type: \"presence\",\n role: role,\n },\n object: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n },\n });\n }\n\n nickChange(nick, content) {\n this.emitEvent(EVENT_INCOMING, {\n context: \"irc\",\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"person\",\n id: `${content}@${this.server}`,\n name: content,\n },\n object: {\n type: \"address\",\n },\n });\n }\n}\n"
5
+ "import events from \"node:events\";\nimport { ASEmitter } from \"./as-emitter.js\";\n\nconst EVENT_INCOMING = \"incoming\";\n// EVENT_ERROR = 'error',\nconst EVENT_PONG = \"pong\";\nconst EVENT_PING = \"ping\";\nconst EVENT_UNPROCESSED = \"unprocessed\";\n\nconst ERR_BAD_NICK = \"432\";\nconst ERR_CHAN_PRIVS = \"482\";\nconst ERR_NICK_IN_USE = \"433\";\nconst ERR_TEMP_UNAVAIL = \"437\";\nconst ERR_NO_CHANNEL = \"403\";\nconst ERR_NOT_INVITED = \"471\";\nconst ERR_BADMODE = \"472\";\nconst ERR_INVITE_ONLY = \"473\";\nconst ERR_BANNED = \"474\";\nconst ERR_BADKEY = \"475\";\nconst ERR_BADMASK = \"476\";\nconst ERR_NOCHANMODES = \"477\";\nconst ERR_BANLISTFULL = \"478\";\nconst JOIN = \"JOIN\";\nconst MODE = \"MODE\";\nconst MOTD = \"372\";\nconst MOTD_END = \"376\";\nconst NAMES = \"353\";\n// NAMES_END = \"366\",\nconst NICK = \"NICK\";\nconst NOTICE = \"NOTICE\";\nconst PART = \"PART\";\nconst PING = \"PING\";\nconst PONG = \"PONG\";\nconst PRIVMSG = \"PRIVMSG\";\nconst QUIT = \"QUIT\";\nconst TOPIC_CHANGE = \"TOPIC\";\nconst TOPIC_IS = \"332\";\nconst TOPIC_SET_BY = \"333\";\nconst WHO = \"352\";\nconst WHO_OLD = \"354\";\n// WHO_END = \"315\";\n\nconst ROLE = {\n \"@\": \"owner\",\n \"%\": \"admin\",\n \"*\": \"participant\",\n};\n\nconst MODES = {\n o: \"owner\",\n h: \"admin\",\n v: \"participant\",\n};\n\nfunction getNickFromServer(server) {\n return server.split(/^:/)[1].split(\"!\")[0];\n}\n\nexport class IrcToActivityStreams {\n constructor(cfg) {\n const config = cfg || {};\n this.server = config.server;\n if (!Array.isArray(config.contexts) || config.contexts.length === 0) {\n throw new Error(\n \"IrcToActivityStreams requires a non-empty contexts array\",\n );\n }\n this.contexts = [...config.contexts];\n this.events = new events.EventEmitter();\n this.__buffer = {};\n this.__buffer[NAMES] = {};\n }\n\n input(payload) {\n if (typeof payload !== \"string\") {\n return false;\n }\n if (payload.length < 3) {\n return false;\n }\n const incoming = payload.trim();\n const [metadata, content] = incoming.split(\" :\");\n const [server, code, pos1, pos2, pos3, ...msg] = metadata.split(\" \");\n const channel =\n typeof pos1 === \"string\" && pos1.startsWith(\"#\")\n ? pos1\n : typeof pos2 === \"string\" && pos2.startsWith(\"#\")\n ? pos2\n : typeof pos3 === \"string\" && pos3.startsWith(\"#\")\n ? pos3\n : undefined;\n if (metadata === PING) {\n this.events.emit(EVENT_PING, `${Date.now()}`);\n return true;\n }\n this.__processIRCCodes(\n code,\n server,\n channel,\n pos1,\n pos2,\n pos3,\n content,\n msg,\n incoming,\n );\n }\n\n __processIRCCodes(\n code,\n server,\n channel,\n pos1,\n pos2,\n pos3,\n content,\n msg,\n incoming,\n ) {\n const ase = new ASEmitter(this.events, this.server, this.contexts);\n let nick;\n let type;\n let role;\n\n switch (code) {\n /** */\n case ERR_CHAN_PRIVS:\n case ERR_NOT_INVITED:\n case ERR_BADMODE:\n case ERR_INVITE_ONLY:\n case ERR_BANNED:\n case ERR_BADKEY:\n case ERR_BADMASK:\n case ERR_NOCHANMODES:\n case ERR_BANLISTFULL:\n ase.channelError(channel, pos1, content);\n break;\n\n /** */\n case ERR_NICK_IN_USE: // nick conflict\n case ERR_BAD_NICK:\n ase.serviceError(pos2, content);\n break;\n\n /** */\n case ERR_NO_CHANNEL: // no such channel\n ase.joinError(pos2);\n break;\n\n /** */\n case ERR_TEMP_UNAVAIL: // nick conflict\n ase.nickError(pos2, content);\n break;\n\n /** */\n case JOIN: // room join\n ase.joinRoom(channel, getNickFromServer(server));\n break;\n\n // custom event indicating a channel mode has been updated, used to re-query user or channel\n case MODE: {\n const user_mode = pos2 || content;\n if (!channel) {\n break;\n } // don't handle cases with no channel defined\n if (!pos3) {\n break;\n } // we need target user\n role = MODES[user_mode[1]] || \"member\";\n type = \"add\";\n if (user_mode[0] === \"-\") {\n type = \"remove\";\n }\n ase.role(type, getNickFromServer(server), pos3, role, channel);\n break;\n }\n\n /** */\n case MOTD: // MOTD\n if (!this.__buffer[MOTD]) {\n this.__buffer[MOTD] = {\n \"@context\": this.contexts,\n type: \"update\",\n actor: {\n type: \"service\",\n id: this.server,\n name: this.server,\n },\n object: {\n type: \"topic\",\n content: content,\n },\n };\n } else {\n this.__buffer[MOTD].object.content += ` ${content}`;\n }\n break;\n case MOTD_END: // end of MOTD\n if (!this.__buffer[MOTD]) {\n break;\n }\n ase.emitEvent(EVENT_INCOMING, this.__buffer[MOTD]);\n delete this.__buffer[MOTD];\n break;\n\n /** */\n case NAMES: // user list\n for (const entry of content.split(\" \")) {\n role = \"member\";\n let username = entry;\n if (ROLE[entry[0]]) {\n username = entry.substr(1);\n role = ROLE[entry[0]];\n }\n ase.presence(username, role, channel);\n }\n break;\n\n /** */\n case NICK: // nick change\n // log(`- 2 nick: ${nick} from content: ${content}`);\n ase.nickChange(getNickFromServer(server), content);\n break;\n\n /** */\n case NOTICE: // notice\n ase.notice(pos1, content);\n break;\n\n /** */\n case PART: // leaving\n ase.userPart(channel, getNickFromServer(server));\n break;\n\n /** */\n case PONG: // ping response received\n this.events.emit(EVENT_PONG, `${Date.now()}`);\n break;\n\n /** */\n case PRIVMSG: // msg\n ase.privMsg(getNickFromServer(server), pos1, content);\n break;\n\n /** */\n case QUIT: // quit user\n ase.userQuit(getNickFromServer(server));\n break;\n\n /** */\n case TOPIC_CHANGE: // topic changed now\n ase.topicChange(channel, getNickFromServer(server), content);\n break;\n\n /** */\n case TOPIC_IS: // topic currently set to\n this.__buffer[TOPIC_IS] = {\n \"@context\": this.contexts,\n type: \"update\",\n actor: undefined,\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"topic\",\n content: content,\n },\n };\n break;\n case TOPIC_SET_BY: // current topic set by\n if (!this.__buffer[TOPIC_IS]) {\n break;\n }\n nick = pos3.split(\"!\")[0];\n this.__buffer[TOPIC_IS].actor = {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n };\n this.__buffer[TOPIC_IS].published = msg[0];\n ase.emitEvent(EVENT_INCOMING, this.__buffer[TOPIC_IS]);\n delete this.__buffer[TOPIC_IS];\n break;\n\n /** */\n case WHO:\n case WHO_OLD:\n nick = msg[3].length <= 2 ? msg[2] : msg[3];\n if (nick === \"undefined\") {\n break;\n }\n role = MODES[pos2[1]] || \"member\";\n ase.presence(nick, role, channel);\n break;\n\n /** */\n default:\n this.events.emit(EVENT_UNPROCESSED, incoming);\n break;\n }\n }\n}\n",
6
+ "const EVENT_INCOMING = \"incoming\";\nconst EVENT_ERROR = \"error\";\n\nexport class ASEmitter {\n constructor(events, server, contexts) {\n if (!Array.isArray(contexts) || contexts.length === 0) {\n throw new Error(\n \"ASEmitter requires a non-empty contexts array from the caller\",\n );\n }\n this.server = server;\n this.events = events;\n this.contexts = [...contexts];\n }\n\n emitEvent(code, asObject) {\n if (typeof asObject === \"object\" && !asObject.published) {\n asObject.published = `${Date.now()}`;\n }\n this.events.emit(code, asObject);\n }\n\n __generalError(nick, content) {\n return {\n \"@context\": this.contexts,\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"service\",\n id: this.server,\n },\n error: content,\n };\n }\n\n presence(nick, role, channel) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"presence\",\n role: role,\n },\n });\n }\n\n channelError(channel, nick, content) {\n this.emitEvent(EVENT_ERROR, {\n \"@context\": this.contexts,\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n },\n error: content,\n });\n }\n\n nickError(nick, content) {\n this.emitEvent(EVENT_ERROR, this.__generalError(nick, content));\n }\n\n notice(nick, content) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"send\",\n actor: {\n type: \"service\",\n id: this.server,\n },\n object: {\n type: \"message\",\n content: content,\n },\n target: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n });\n }\n\n serviceError(nick, content) {\n this.emitEvent(EVENT_ERROR, this.__generalError(nick, content));\n }\n\n joinError(nick) {\n this.emitEvent(EVENT_ERROR, {\n \"@context\": this.contexts,\n type: \"join\",\n actor: {\n id: this.server,\n type: \"service\",\n },\n error: `no such channel ${nick}`,\n target: {\n id: `${nick}@${this.server}`,\n type: \"person\",\n },\n });\n }\n\n topicChange(channel, nick, content) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"topic\",\n content: content,\n },\n });\n }\n\n joinRoom(channel, nick) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"join\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n });\n }\n\n userQuit(nick) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"leave\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"service\",\n id: this.server,\n },\n object: {\n type: \"message\",\n content: \"user has quit\",\n },\n });\n }\n\n userPart(channel, nick) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"leave\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n object: {\n type: \"message\",\n content: \"user has left the channel\",\n },\n });\n }\n\n privMsg(nick, target, content) {\n let type;\n let message;\n if (content.startsWith(\"+\\u0001ACTION \")) {\n type = \"me\";\n message = content\n // biome-ignore lint/suspicious/noControlCharactersInRegex: IRC ACTION framing uses control chars\n .split(/^\\+\\u0001ACTION\\s+/)[1]\n // biome-ignore lint/suspicious/noControlCharactersInRegex: IRC ACTION framing uses control chars\n .split(/\\u0001$/)[0];\n } else {\n type = \"message\";\n message = content;\n }\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"send\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: target.startsWith(\"#\") ? \"room\" : \"person\",\n id: `${this.server}/${target}`,\n name: target,\n },\n object: {\n type: type,\n content: message,\n },\n });\n }\n\n role(type, nick, target, role, channel) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: type,\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"person\",\n id: `${target}@${this.server}`,\n name: target,\n },\n object: {\n type: \"relationship\",\n relationship: \"role\",\n subject: {\n type: \"presence\",\n role: role,\n },\n object: {\n type: \"room\",\n id: `${this.server}/${channel}`,\n name: channel,\n },\n },\n });\n }\n\n nickChange(nick, content) {\n this.emitEvent(EVENT_INCOMING, {\n \"@context\": this.contexts,\n type: \"update\",\n actor: {\n type: \"person\",\n id: `${nick}@${this.server}`,\n name: nick,\n },\n target: {\n type: \"person\",\n id: `${content}@${this.server}`,\n name: content,\n },\n object: {\n type: \"address\",\n },\n });\n }\n}\n"
7
7
  ],
8
- "mappings": ";AAAA;;;ACAA,IAAM,iBAAiB;AACvB,IAAM,cAAc;AAAA;AAEb,MAAM,UAAU;AAAA,EACnB,WAAW,CAAC,QAAQ,QAAQ;AAAA,IACxB,KAAK,SAAS;AAAA,IACd,KAAK,SAAS;AAAA;AAAA,EAGlB,SAAS,CAAC,MAAM,UAAU;AAAA,IACtB,IAAI,OAAO,aAAa,YAAY,CAAC,SAAS,WAAW;AAAA,MACrD,SAAS,YAAY,GAAG,KAAK,IAAI;AAAA,IACrC;AAAA,IACA,KAAK,OAAO,KAAK,MAAM,QAAQ;AAAA;AAAA,EAGnC,cAAc,CAAC,MAAM,SAAS;AAAA,IAC1B,OAAO;AAAA,MACH,SAAS;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,QACH,MAAM;AAAA,QACN,IAAI,GAAG,QAAQ,KAAK;A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C3D;AAAA,WAGC;AAAA,QACD,KAAK,SAAS,YAAY;AAAA,UACtB,YAAY,KAAK;AAAA,UACjB,MAAM;AAAA,UACN,OAAO;AAAA,UACP,QAAQ;AAAA,YACJ,MAAM;AAAA,YACN,IAAI,GAAG,KAAK,UAAU;AAAA,YACtB,MAAM;AAAA,UACV;AAAA,UACA,QAAQ;AAAA,YACJ,MAAM;AAAA,YACN;AAAA,UACJ;AAAA,QACJ;AAAA,QACA;AAAA,WACC;AAAA,QACD,IAAI,CAAC,KAAK,SAAS,WAAW;AAAA,UAC1B;AAAA,QACJ;AAAA,QACA,OAAO,KAAK,MAAM,GAAG,EAAE;AAAA,QACvB,KAAK,SAAS,UAAU,QAAQ;AAAA,UAC5B,MAAM;AAAA,UACN,IAAI,GAAG,QAAQ,KAAK;AAAA,UACpB,MAAM;AAAA,QACV;AAAA,QACA,KAAK,SAAS,UAAU,YAAY,IAAI;AAAA,QACxC,IAAI,UAAU,iBAAgB,KAAK,SAAS,SAAS;AAAA,QACrD,OAAO,KAAK,SAAS;AAAA,QACrB;AAAA,WAGC;AAAA,WACA;AAAA,QACD,OAAO,IAAI,GAAG,UAAU,IAAI,IAAI,KAAK,IAAI;AAAA,QACzC,IAAI,SAAS,aAAa;AAAA,UACtB;AAAA,QACJ;AAAA,QACA,OAAO,MAAM,KAAK,OAAO;AAAA,QACzB,IAAI,SAAS,MAAM,MAAM,OAAO;AAAA,QAChC;AAAA;AAAA,QAIA,KAAK,OAAO,KAAK,mBAAmB,QAAQ;AAAA,QAC5C;AAAA;AAAA;AAGhB;",
9
+ "debugId": "4861334B3E0B639464756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sockethub/irc2as",
3
- "version": "4.0.0-alpha.11",
3
+ "version": "4.0.0-alpha.12",
4
4
  "description": "IRC to ActivityStreams objects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -46,7 +46,7 @@
46
46
  "fast-deep-equal": "^3.1.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@sockethub/schemas": "^3.0.0-alpha.11"
49
+ "@sockethub/schemas": "^3.0.0-alpha.12"
50
50
  },
51
- "gitHead": "c243fa9e76c688ce5ffcf524400b1dd27dcce615"
51
+ "gitHead": "f039dab3c3f67cbbf204476fc397532e973f82a8"
52
52
  }
package/src/as-emitter.js CHANGED
@@ -2,9 +2,15 @@ const EVENT_INCOMING = "incoming";
2
2
  const EVENT_ERROR = "error";
3
3
 
4
4
  export class ASEmitter {
5
- constructor(events, server) {
5
+ constructor(events, server, contexts) {
6
+ if (!Array.isArray(contexts) || contexts.length === 0) {
7
+ throw new Error(
8
+ "ASEmitter requires a non-empty contexts array from the caller",
9
+ );
10
+ }
6
11
  this.server = server;
7
12
  this.events = events;
13
+ this.contexts = [...contexts];
8
14
  }
9
15
 
10
16
  emitEvent(code, asObject) {
@@ -16,7 +22,7 @@ export class ASEmitter {
16
22
 
17
23
  __generalError(nick, content) {
18
24
  return {
19
- context: "irc",
25
+ "@context": this.contexts,
20
26
  type: "update",
21
27
  actor: {
22
28
  type: "person",
@@ -33,7 +39,7 @@ export class ASEmitter {
33
39
 
34
40
  presence(nick, role, channel) {
35
41
  this.emitEvent(EVENT_INCOMING, {
36
- context: "irc",
42
+ "@context": this.contexts,
37
43
  type: "update",
38
44
  actor: {
39
45
  type: "person",
@@ -54,7 +60,7 @@ export class ASEmitter {
54
60
 
55
61
  channelError(channel, nick, content) {
56
62
  this.emitEvent(EVENT_ERROR, {
57
- context: "irc",
63
+ "@context": this.contexts,
58
64
  type: "update",
59
65
  actor: {
60
66
  type: "person",
@@ -74,7 +80,7 @@ export class ASEmitter {
74
80
 
75
81
  notice(nick, content) {
76
82
  this.emitEvent(EVENT_INCOMING, {
77
- context: "irc",
83
+ "@context": this.contexts,
78
84
  type: "send",
79
85
  actor: {
80
86
  type: "service",
@@ -98,7 +104,7 @@ export class ASEmitter {
98
104
 
99
105
  joinError(nick) {
100
106
  this.emitEvent(EVENT_ERROR, {
101
- context: "irc",
107
+ "@context": this.contexts,
102
108
  type: "join",
103
109
  actor: {
104
110
  id: this.server,
@@ -114,7 +120,7 @@ export class ASEmitter {
114
120
 
115
121
  topicChange(channel, nick, content) {
116
122
  this.emitEvent(EVENT_INCOMING, {
117
- context: "irc",
123
+ "@context": this.contexts,
118
124
  type: "update",
119
125
  actor: {
120
126
  type: "person",
@@ -135,7 +141,7 @@ export class ASEmitter {
135
141
 
136
142
  joinRoom(channel, nick) {
137
143
  this.emitEvent(EVENT_INCOMING, {
138
- context: "irc",
144
+ "@context": this.contexts,
139
145
  type: "join",
140
146
  actor: {
141
147
  type: "person",
@@ -152,7 +158,7 @@ export class ASEmitter {
152
158
 
153
159
  userQuit(nick) {
154
160
  this.emitEvent(EVENT_INCOMING, {
155
- context: "irc",
161
+ "@context": this.contexts,
156
162
  type: "leave",
157
163
  actor: {
158
164
  type: "person",
@@ -172,7 +178,7 @@ export class ASEmitter {
172
178
 
173
179
  userPart(channel, nick) {
174
180
  this.emitEvent(EVENT_INCOMING, {
175
- context: "irc",
181
+ "@context": this.contexts,
176
182
  type: "leave",
177
183
  actor: {
178
184
  type: "person",
@@ -197,16 +203,16 @@ export class ASEmitter {
197
203
  if (content.startsWith("+\u0001ACTION ")) {
198
204
  type = "me";
199
205
  message = content
200
- // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
206
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: IRC ACTION framing uses control chars
201
207
  .split(/^\+\u0001ACTION\s+/)[1]
202
- // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
208
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: IRC ACTION framing uses control chars
203
209
  .split(/\u0001$/)[0];
204
210
  } else {
205
211
  type = "message";
206
212
  message = content;
207
213
  }
208
214
  this.emitEvent(EVENT_INCOMING, {
209
- context: "irc",
215
+ "@context": this.contexts,
210
216
  type: "send",
211
217
  actor: {
212
218
  type: "person",
@@ -227,7 +233,7 @@ export class ASEmitter {
227
233
 
228
234
  role(type, nick, target, role, channel) {
229
235
  this.emitEvent(EVENT_INCOMING, {
230
- context: "irc",
236
+ "@context": this.contexts,
231
237
  type: type,
232
238
  actor: {
233
239
  type: "person",
@@ -257,7 +263,7 @@ export class ASEmitter {
257
263
 
258
264
  nickChange(nick, content) {
259
265
  this.emitEvent(EVENT_INCOMING, {
260
- context: "irc",
266
+ "@context": this.contexts,
261
267
  type: "update",
262
268
  actor: {
263
269
  type: "person",
package/src/index.js CHANGED
@@ -60,6 +60,12 @@ export class IrcToActivityStreams {
60
60
  constructor(cfg) {
61
61
  const config = cfg || {};
62
62
  this.server = config.server;
63
+ if (!Array.isArray(config.contexts) || config.contexts.length === 0) {
64
+ throw new Error(
65
+ "IrcToActivityStreams requires a non-empty contexts array",
66
+ );
67
+ }
68
+ this.contexts = [...config.contexts];
63
69
  this.events = new events.EventEmitter();
64
70
  this.__buffer = {};
65
71
  this.__buffer[NAMES] = {};
@@ -111,7 +117,7 @@ export class IrcToActivityStreams {
111
117
  msg,
112
118
  incoming,
113
119
  ) {
114
- const ase = new ASEmitter(this.events, this.server);
120
+ const ase = new ASEmitter(this.events, this.server, this.contexts);
115
121
  let nick;
116
122
  let type;
117
123
  let role;
@@ -173,7 +179,7 @@ export class IrcToActivityStreams {
173
179
  case MOTD: // MOTD
174
180
  if (!this.__buffer[MOTD]) {
175
181
  this.__buffer[MOTD] = {
176
- context: "irc",
182
+ "@context": this.contexts,
177
183
  type: "update",
178
184
  actor: {
179
185
  type: "service",
@@ -249,7 +255,7 @@ export class IrcToActivityStreams {
249
255
  /** */
250
256
  case TOPIC_IS: // topic currently set to
251
257
  this.__buffer[TOPIC_IS] = {
252
- context: "irc",
258
+ "@context": this.contexts,
253
259
  type: "update",
254
260
  actor: undefined,
255
261
  target: {
@@ -1,6 +1,10 @@
1
1
  export const TestData = [
2
2
  {
3
- context: "irc",
3
+ "@context": [
4
+ "https://www.w3.org/ns/activitystreams",
5
+ "https://sockethub.org/ns/context/v1.jsonld",
6
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
7
+ ],
4
8
  type: "update",
5
9
  actor: {
6
10
  type: "service",
@@ -13,7 +17,11 @@ export const TestData = [
13
17
  },
14
18
  },
15
19
  {
16
- context: "irc",
20
+ "@context": [
21
+ "https://www.w3.org/ns/activitystreams",
22
+ "https://sockethub.org/ns/context/v1.jsonld",
23
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
24
+ ],
17
25
  type: "update",
18
26
  actor: {
19
27
  type: "service",
@@ -29,7 +37,11 @@ export const TestData = [
29
37
  },
30
38
  },
31
39
  {
32
- context: "irc",
40
+ "@context": [
41
+ "https://www.w3.org/ns/activitystreams",
42
+ "https://sockethub.org/ns/context/v1.jsonld",
43
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
44
+ ],
33
45
  type: "update",
34
46
  actor: {
35
47
  type: "person",
@@ -40,7 +52,11 @@ export const TestData = [
40
52
  object: { type: "address" },
41
53
  },
42
54
  {
43
- context: "irc",
55
+ "@context": [
56
+ "https://www.w3.org/ns/activitystreams",
57
+ "https://sockethub.org/ns/context/v1.jsonld",
58
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
59
+ ],
44
60
  type: "update",
45
61
  actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
46
62
  target: {
@@ -51,28 +67,44 @@ export const TestData = [
51
67
  object: { type: "address" },
52
68
  },
53
69
  {
54
- context: "irc",
70
+ "@context": [
71
+ "https://www.w3.org/ns/activitystreams",
72
+ "https://sockethub.org/ns/context/v1.jsonld",
73
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
74
+ ],
55
75
  type: "leave",
56
76
  actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
57
77
  target: { type: "room", id: "localhost/#debian", name: "#debian" },
58
78
  object: { type: "message", content: "user has left the channel" },
59
79
  },
60
80
  {
61
- context: "irc",
81
+ "@context": [
82
+ "https://www.w3.org/ns/activitystreams",
83
+ "https://sockethub.org/ns/context/v1.jsonld",
84
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
85
+ ],
62
86
  type: "leave",
63
87
  actor: { type: "person", id: "jarlaxl_@localhost", name: "jarlaxl_" },
64
88
  target: { type: "service", id: "localhost" },
65
89
  object: { type: "message", content: "user has quit" },
66
90
  },
67
91
  {
68
- context: "irc",
92
+ "@context": [
93
+ "https://www.w3.org/ns/activitystreams",
94
+ "https://sockethub.org/ns/context/v1.jsonld",
95
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
96
+ ],
69
97
  type: "join",
70
98
  actor: { id: "localhost", type: "service" },
71
99
  error: "no such channel sdfsdfsdfsdfsdf",
72
100
  target: { id: "sdfsdfsdfsdfsdf@localhost", type: "person" },
73
101
  },
74
102
  {
75
- context: "irc",
103
+ "@context": [
104
+ "https://www.w3.org/ns/activitystreams",
105
+ "https://sockethub.org/ns/context/v1.jsonld",
106
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
107
+ ],
76
108
  type: "update",
77
109
  actor: { type: "person", id: "lio17@localhost", name: "lio17" },
78
110
  target: {
@@ -83,7 +115,11 @@ export const TestData = [
83
115
  object: { type: "topic", content: "testing123" },
84
116
  },
85
117
  {
86
- context: "irc",
118
+ "@context": [
119
+ "https://www.w3.org/ns/activitystreams",
120
+ "https://sockethub.org/ns/context/v1.jsonld",
121
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
122
+ ],
87
123
  type: "send",
88
124
  actor: {
89
125
  type: "person",
@@ -98,7 +134,11 @@ export const TestData = [
98
134
  object: { type: "message", content: "-ssssssss" },
99
135
  },
100
136
  {
101
- context: "irc",
137
+ "@context": [
138
+ "https://www.w3.org/ns/activitystreams",
139
+ "https://sockethub.org/ns/context/v1.jsonld",
140
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
141
+ ],
102
142
  type: "update",
103
143
  actor: { type: "person", id: "lio17@localhost", name: "lio17" },
104
144
  target: {
@@ -109,7 +149,11 @@ export const TestData = [
109
149
  object: { type: "topic", content: "no longer boating in senegal" },
110
150
  },
111
151
  {
112
- context: "irc",
152
+ "@context": [
153
+ "https://www.w3.org/ns/activitystreams",
154
+ "https://sockethub.org/ns/context/v1.jsonld",
155
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
156
+ ],
113
157
  type: "send",
114
158
  actor: { type: "person", id: "raucao@localhost", name: "raucao" },
115
159
  target: {
@@ -123,7 +167,11 @@ export const TestData = [
123
167
  },
124
168
  },
125
169
  {
126
- context: "irc",
170
+ "@context": [
171
+ "https://www.w3.org/ns/activitystreams",
172
+ "https://sockethub.org/ns/context/v1.jsonld",
173
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
174
+ ],
127
175
  type: "update",
128
176
  object: { type: "presence", role: "member" },
129
177
  actor: {
@@ -138,7 +186,11 @@ export const TestData = [
138
186
  },
139
187
  },
140
188
  {
141
- context: "irc",
189
+ "@context": [
190
+ "https://www.w3.org/ns/activitystreams",
191
+ "https://sockethub.org/ns/context/v1.jsonld",
192
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
193
+ ],
142
194
  type: "update",
143
195
  object: { type: "presence", role: "member" },
144
196
  actor: {
@@ -153,7 +205,11 @@ export const TestData = [
153
205
  },
154
206
  },
155
207
  {
156
- context: "irc",
208
+ "@context": [
209
+ "https://www.w3.org/ns/activitystreams",
210
+ "https://sockethub.org/ns/context/v1.jsonld",
211
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
212
+ ],
157
213
  type: "update",
158
214
  object: { type: "presence", role: "member" },
159
215
  actor: {
@@ -168,7 +224,11 @@ export const TestData = [
168
224
  },
169
225
  },
170
226
  {
171
- context: "irc",
227
+ "@context": [
228
+ "https://www.w3.org/ns/activitystreams",
229
+ "https://sockethub.org/ns/context/v1.jsonld",
230
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
231
+ ],
172
232
  type: "update",
173
233
  object: { type: "presence", role: "member" },
174
234
  actor: {
@@ -183,7 +243,11 @@ export const TestData = [
183
243
  },
184
244
  },
185
245
  {
186
- context: "irc",
246
+ "@context": [
247
+ "https://www.w3.org/ns/activitystreams",
248
+ "https://sockethub.org/ns/context/v1.jsonld",
249
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
250
+ ],
187
251
  type: "update",
188
252
  actor: {
189
253
  type: "person",
@@ -198,7 +262,11 @@ export const TestData = [
198
262
  object: { type: "presence", role: "member" },
199
263
  },
200
264
  {
201
- context: "irc",
265
+ "@context": [
266
+ "https://www.w3.org/ns/activitystreams",
267
+ "https://sockethub.org/ns/context/v1.jsonld",
268
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
269
+ ],
202
270
  type: "update",
203
271
  actor: { type: "person", id: "gregkare@localhost", name: "gregkare" },
204
272
  target: {
@@ -209,21 +277,33 @@ export const TestData = [
209
277
  object: { type: "presence", role: "member" },
210
278
  },
211
279
  {
212
- context: "irc",
280
+ "@context": [
281
+ "https://www.w3.org/ns/activitystreams",
282
+ "https://sockethub.org/ns/context/v1.jsonld",
283
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
284
+ ],
213
285
  type: "update",
214
286
  actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
215
287
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
216
288
  object: { type: "presence", role: "member" },
217
289
  },
218
290
  {
219
- context: "irc",
291
+ "@context": [
292
+ "https://www.w3.org/ns/activitystreams",
293
+ "https://sockethub.org/ns/context/v1.jsonld",
294
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
295
+ ],
220
296
  type: "update",
221
297
  actor: { type: "person", id: "lio17@localhost", name: "lio17" },
222
298
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
223
299
  object: { type: "presence", role: "member" },
224
300
  },
225
301
  {
226
- context: "irc",
302
+ "@context": [
303
+ "https://www.w3.org/ns/activitystreams",
304
+ "https://sockethub.org/ns/context/v1.jsonld",
305
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
306
+ ],
227
307
  type: "update",
228
308
  actor: {
229
309
  type: "person",
@@ -234,35 +314,55 @@ export const TestData = [
234
314
  object: { type: "presence", role: "member" },
235
315
  },
236
316
  {
237
- context: "irc",
317
+ "@context": [
318
+ "https://www.w3.org/ns/activitystreams",
319
+ "https://sockethub.org/ns/context/v1.jsonld",
320
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
321
+ ],
238
322
  type: "update",
239
323
  actor: { type: "person", id: "botka1@localhost", name: "botka1" },
240
324
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
241
325
  object: { type: "presence", role: "member" },
242
326
  },
243
327
  {
244
- context: "irc",
328
+ "@context": [
329
+ "https://www.w3.org/ns/activitystreams",
330
+ "https://sockethub.org/ns/context/v1.jsonld",
331
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
332
+ ],
245
333
  type: "update",
246
334
  actor: { type: "person", id: "derbumi@localhost", name: "derbumi" },
247
335
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
248
336
  object: { type: "presence", role: "member" },
249
337
  },
250
338
  {
251
- context: "irc",
339
+ "@context": [
340
+ "https://www.w3.org/ns/activitystreams",
341
+ "https://sockethub.org/ns/context/v1.jsonld",
342
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
343
+ ],
252
344
  type: "update",
253
345
  actor: { type: "person", id: "ChanServ@localhost", name: "ChanServ" },
254
346
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
255
347
  object: { type: "presence", role: "member" },
256
348
  },
257
349
  {
258
- context: "irc",
350
+ "@context": [
351
+ "https://www.w3.org/ns/activitystreams",
352
+ "https://sockethub.org/ns/context/v1.jsonld",
353
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
354
+ ],
259
355
  type: "update",
260
356
  actor: { type: "person", id: "gregkare@localhost", name: "gregkare" },
261
357
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
262
358
  object: { type: "presence", role: "member" },
263
359
  },
264
360
  {
265
- context: "irc",
361
+ "@context": [
362
+ "https://www.w3.org/ns/activitystreams",
363
+ "https://sockethub.org/ns/context/v1.jsonld",
364
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
365
+ ],
266
366
  type: "update",
267
367
  actor: { type: "person", id: "hal8000@localhost", name: "hal8000" },
268
368
  target: {
@@ -273,63 +373,99 @@ export const TestData = [
273
373
  object: { type: "presence", role: "member" },
274
374
  },
275
375
  {
276
- context: "irc",
376
+ "@context": [
377
+ "https://www.w3.org/ns/activitystreams",
378
+ "https://sockethub.org/ns/context/v1.jsonld",
379
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
380
+ ],
277
381
  type: "update",
278
382
  actor: { type: "person", id: "bkero-@localhost", name: "bkero-" },
279
383
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
280
384
  object: { type: "presence", role: "member" },
281
385
  },
282
386
  {
283
- context: "irc",
387
+ "@context": [
388
+ "https://www.w3.org/ns/activitystreams",
389
+ "https://sockethub.org/ns/context/v1.jsonld",
390
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
391
+ ],
284
392
  type: "update",
285
393
  actor: { type: "person", id: "galfert@localhost", name: "galfert" },
286
394
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
287
395
  object: { type: "presence", role: "member" },
288
396
  },
289
397
  {
290
- context: "irc",
398
+ "@context": [
399
+ "https://www.w3.org/ns/activitystreams",
400
+ "https://sockethub.org/ns/context/v1.jsonld",
401
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
402
+ ],
291
403
  type: "update",
292
404
  actor: { type: "person", id: "raucao@localhost", name: "raucao" },
293
405
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
294
406
  object: { type: "presence", role: "member" },
295
407
  },
296
408
  {
297
- context: "irc",
409
+ "@context": [
410
+ "https://www.w3.org/ns/activitystreams",
411
+ "https://sockethub.org/ns/context/v1.jsonld",
412
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
413
+ ],
298
414
  type: "update",
299
415
  actor: { type: "person", id: "hal8000@localhost", name: "hal8000" },
300
416
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
301
417
  object: { type: "presence", role: "member" },
302
418
  },
303
419
  {
304
- context: "irc",
420
+ "@context": [
421
+ "https://www.w3.org/ns/activitystreams",
422
+ "https://sockethub.org/ns/context/v1.jsonld",
423
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
424
+ ],
305
425
  type: "update",
306
426
  actor: { type: "person", id: "bkero@localhost", name: "bkero" },
307
427
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
308
428
  object: { type: "presence", role: "member" },
309
429
  },
310
430
  {
311
- context: "irc",
431
+ "@context": [
432
+ "https://www.w3.org/ns/activitystreams",
433
+ "https://sockethub.org/ns/context/v1.jsonld",
434
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
435
+ ],
312
436
  type: "update",
313
437
  actor: { type: "person", id: "bumi[m]@localhost", name: "bumi[m]" },
314
438
  target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
315
439
  object: { type: "presence", role: "member" },
316
440
  },
317
441
  {
318
- context: "irc",
442
+ "@context": [
443
+ "https://www.w3.org/ns/activitystreams",
444
+ "https://sockethub.org/ns/context/v1.jsonld",
445
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
446
+ ],
319
447
  type: "update",
320
448
  actor: { type: "person", id: "slvrbckt@localhost" },
321
449
  target: { type: "room", id: "localhost/#debian" },
322
450
  error: "You're not a channel operator",
323
451
  },
324
452
  {
325
- context: "irc",
453
+ "@context": [
454
+ "https://www.w3.org/ns/activitystreams",
455
+ "https://sockethub.org/ns/context/v1.jsonld",
456
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
457
+ ],
326
458
  type: "update",
327
459
  actor: { type: "person", id: "slvrbckt@localhost" },
328
460
  target: { type: "room", id: "localhost/#kosmos-random" },
329
461
  error: "You're not a channel operator",
330
462
  },
331
463
  {
332
- context: "irc",
464
+ "@context": [
465
+ "https://www.w3.org/ns/activitystreams",
466
+ "https://sockethub.org/ns/context/v1.jsonld",
467
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
468
+ ],
333
469
  type: "add",
334
470
  actor: { type: "person", id: "alice@localhost", name: "alice" },
335
471
  target: { type: "person", id: "Kilroy@localhost", name: "Kilroy" },
@@ -345,7 +481,11 @@ export const TestData = [
345
481
  },
346
482
  },
347
483
  {
348
- context: "irc",
484
+ "@context": [
485
+ "https://www.w3.org/ns/activitystreams",
486
+ "https://sockethub.org/ns/context/v1.jsonld",
487
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
488
+ ],
349
489
  type: "add",
350
490
  actor: { type: "person", id: "bob@localhost", name: "bob" },
351
491
  target: { type: "person", id: "alice@localhost", name: "alice" },
@@ -357,7 +497,11 @@ export const TestData = [
357
497
  },
358
498
  },
359
499
  {
360
- context: "irc",
500
+ "@context": [
501
+ "https://www.w3.org/ns/activitystreams",
502
+ "https://sockethub.org/ns/context/v1.jsonld",
503
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
504
+ ],
361
505
  type: "add",
362
506
  actor: { type: "person", id: "alice@localhost", name: "alice" },
363
507
  target: { type: "person", id: "bob@localhost", name: "bob" },
@@ -369,28 +513,44 @@ export const TestData = [
369
513
  },
370
514
  },
371
515
  {
372
- context: "irc",
516
+ "@context": [
517
+ "https://www.w3.org/ns/activitystreams",
518
+ "https://sockethub.org/ns/context/v1.jsonld",
519
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
520
+ ],
373
521
  type: "update",
374
522
  target: { type: "room", id: "localhost/#freenode-sponsors" },
375
523
  actor: { type: "person", id: "hyper_slvrbckt@localhost" },
376
524
  error: "Cannot join channel (+i) - you must be invited",
377
525
  },
378
526
  {
379
- context: "irc",
527
+ "@context": [
528
+ "https://www.w3.org/ns/activitystreams",
529
+ "https://sockethub.org/ns/context/v1.jsonld",
530
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
531
+ ],
380
532
  type: "update",
381
533
  target: { type: "service", id: "localhost" },
382
534
  error: "Nickname is already in use.",
383
535
  actor: { type: "person", id: "nkj@localhost", name: "nkj" },
384
536
  },
385
537
  {
386
- context: "irc",
538
+ "@context": [
539
+ "https://www.w3.org/ns/activitystreams",
540
+ "https://sockethub.org/ns/context/v1.jsonld",
541
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
542
+ ],
387
543
  type: "update",
388
544
  target: { type: "service", id: "localhost" },
389
545
  error: "Nickname is already in use.",
390
546
  actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
391
547
  },
392
548
  {
393
- context: "irc",
549
+ "@context": [
550
+ "https://www.w3.org/ns/activitystreams",
551
+ "https://sockethub.org/ns/context/v1.jsonld",
552
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
553
+ ],
394
554
  type: "send",
395
555
  actor: { type: "service", id: "localhost" },
396
556
  object: {
@@ -401,7 +561,11 @@ export const TestData = [
401
561
  target: { type: "person", id: "boo@localhost", name: "boo" },
402
562
  },
403
563
  {
404
- context: "irc",
564
+ "@context": [
565
+ "https://www.w3.org/ns/activitystreams",
566
+ "https://sockethub.org/ns/context/v1.jsonld",
567
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
568
+ ],
405
569
  type: "send",
406
570
  actor: { type: "service", id: "localhost" },
407
571
  object: {
@@ -412,7 +576,11 @@ export const TestData = [
412
576
  target: { type: "person", id: "boo@localhost", name: "boo" },
413
577
  },
414
578
  {
415
- context: "irc",
579
+ "@context": [
580
+ "https://www.w3.org/ns/activitystreams",
581
+ "https://sockethub.org/ns/context/v1.jsonld",
582
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
583
+ ],
416
584
  type: "send",
417
585
  actor: { type: "service", id: "localhost" },
418
586
  object: {
@@ -422,21 +590,33 @@ export const TestData = [
422
590
  target: { type: "person", id: "boo@localhost", name: "boo" },
423
591
  },
424
592
  {
425
- context: "irc",
593
+ "@context": [
594
+ "https://www.w3.org/ns/activitystreams",
595
+ "https://sockethub.org/ns/context/v1.jsonld",
596
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
597
+ ],
426
598
  type: "update",
427
599
  target: { type: "service", id: "localhost" },
428
600
  error: "Nick/channel is temporarily unavailable",
429
601
  actor: { type: "person", id: "boo@localhost", name: "boo" },
430
602
  },
431
603
  {
432
- context: "irc",
604
+ "@context": [
605
+ "https://www.w3.org/ns/activitystreams",
606
+ "https://sockethub.org/ns/context/v1.jsonld",
607
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
608
+ ],
433
609
  type: "update",
434
610
  actor: { type: "person", id: "sh-WjwOE@localhost", name: "sh-WjwOE" },
435
611
  target: { type: "person", id: "woooo@localhost", name: "woooo" },
436
612
  object: { type: "address" },
437
613
  },
438
614
  {
439
- context: "irc",
615
+ "@context": [
616
+ "https://www.w3.org/ns/activitystreams",
617
+ "https://sockethub.org/ns/context/v1.jsonld",
618
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
619
+ ],
440
620
  type: "send",
441
621
  actor: { type: "service", id: "localhost" },
442
622
  object: {
@@ -447,7 +627,11 @@ export const TestData = [
447
627
  target: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
448
628
  },
449
629
  {
450
- context: "irc",
630
+ "@context": [
631
+ "https://www.w3.org/ns/activitystreams",
632
+ "https://sockethub.org/ns/context/v1.jsonld",
633
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
634
+ ],
451
635
  type: "join",
452
636
  actor: { type: "person", id: "myuser@localhost", name: "myuser" },
453
637
  target: {
@@ -457,7 +641,11 @@ export const TestData = [
457
641
  },
458
642
  },
459
643
  {
460
- context: "irc",
644
+ "@context": [
645
+ "https://www.w3.org/ns/activitystreams",
646
+ "https://sockethub.org/ns/context/v1.jsonld",
647
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
648
+ ],
461
649
  type: "update",
462
650
  actor: { type: "person", id: "myuser@localhost", name: "myuser" },
463
651
  target: {
@@ -468,7 +656,11 @@ export const TestData = [
468
656
  object: { type: "presence", role: "member" },
469
657
  },
470
658
  {
471
- context: "irc",
659
+ "@context": [
660
+ "https://www.w3.org/ns/activitystreams",
661
+ "https://sockethub.org/ns/context/v1.jsonld",
662
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
663
+ ],
472
664
  type: "update",
473
665
  actor: { type: "person", id: "botka@localhost", name: "botka" },
474
666
  target: {
@@ -479,7 +671,11 @@ export const TestData = [
479
671
  object: { type: "presence", role: "owner" },
480
672
  },
481
673
  {
482
- context: "irc",
674
+ "@context": [
675
+ "https://www.w3.org/ns/activitystreams",
676
+ "https://sockethub.org/ns/context/v1.jsonld",
677
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
678
+ ],
483
679
  type: "update",
484
680
  actor: { type: "person", id: "foouser@localhost", name: "foouser" },
485
681
  target: {
package/src/index.test.js CHANGED
@@ -1,12 +1,22 @@
1
1
  import { beforeEach, describe, expect, it } from "bun:test";
2
2
  import { readFileSync } from "fs";
3
- import { validateActivityStream } from "@sockethub/schemas";
3
+ import {
4
+ addPlatformContext,
5
+ addPlatformSchema,
6
+ getPlatformSchema,
7
+ validateActivityStream,
8
+ } from "@sockethub/schemas";
4
9
  import equal from "fast-deep-equal";
5
10
 
6
11
  import { IrcToActivityStreams } from "./index.js";
7
12
  import { TestData } from "./index.test.data.js";
8
13
  const ircdata = readFileSync(__dirname + "/index.test.data.irc.txt", "utf-8");
9
14
  const inputs = ircdata.split("\n");
15
+ const IRC_CONTEXTS = [
16
+ "https://www.w3.org/ns/activitystreams",
17
+ "https://sockethub.org/ns/context/v1.jsonld",
18
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
19
+ ];
10
20
 
11
21
  function matchStream(done) {
12
22
  return (stream) => {
@@ -39,7 +49,23 @@ describe("IrcToActivityStreams", () => {
39
49
  pongs = 0,
40
50
  pings = 0;
41
51
  beforeEach(() => {
42
- irc2as = new IrcToActivityStreams({ server: "localhost" });
52
+ if (!getPlatformSchema("irc/messages")) {
53
+ addPlatformSchema(
54
+ {
55
+ type: "object",
56
+ additionalProperties: true,
57
+ },
58
+ "irc/messages",
59
+ );
60
+ }
61
+ addPlatformContext(
62
+ "irc",
63
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
64
+ );
65
+ irc2as = new IrcToActivityStreams({
66
+ server: "localhost",
67
+ contexts: IRC_CONTEXTS,
68
+ });
43
69
  expect(irc2as).toHaveProperty("events");
44
70
  expect(typeof irc2as.events.on).toEqual("function");
45
71
  irc2as.events.on("unprocessed", (string) => {