@sockethub/platform-irc 4.0.0-beta.0 → 4.0.0-beta.1

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
@@ -10,11 +10,17 @@ messages.
10
10
 
11
11
  ## Implemented Verbs (`type`)
12
12
 
13
+ * **connect** - Open the IRC connection after credentials are stored
13
14
  * **send** - Send messages to channels or users
14
15
  * **join** - Join IRC channels
15
16
  * **leave** - Leave IRC channels
16
- * **observe** - Monitor channel activity and user events
17
- * **update** - Update user information (nick, etc.)
17
+ * **update** - Change a nick (`address`) or a channel topic (`topic`)
18
+ * **query** - List who is in a channel, or list channels on the server
19
+ * **disconnect** - Close the IRC connection
20
+
21
+ Incoming chat, joins, presence, and nick changes arrive as messages. There is
22
+ no separate observe command. `/me` is a `send` whose `object.content` starts
23
+ with `/me`.
18
24
 
19
25
  ## Usage
20
26
 
@@ -137,7 +143,8 @@ name as it appears on IRC (for example `#general`).
137
143
  },
138
144
  "target": {
139
145
  "id": "newnick@irc.libera.chat",
140
- "type": "person"
146
+ "type": "person",
147
+ "name": "newnick"
141
148
  },
142
149
  "object": {
143
150
  "type": "address"
@@ -145,6 +152,40 @@ name as it appears on IRC (for example `#general`).
145
152
  }
146
153
  ```
147
154
 
155
+ ### Nick changes
156
+
157
+ `target.name` is the nick sent in `NICK`. `target.id` is that nick as a person
158
+ id, `newnick@server`. On success the connection is re-keyed to that actor.
159
+ Later commands must use the new `actor.id`.
160
+
161
+ The client library moves stored credentials, connect, and join entries when
162
+ the update is acknowledged without an error, and when the server reports a
163
+ rename of an actor this session holds. The credential object stays as
164
+ submitted (`nick`, `password`, `token`, and the rest). The live connection is
165
+ selected by a fingerprint of that original object, so a reconnect that also
166
+ rewrites `nick` misses it and opens another session. See the
167
+ [client guide](../../docs/client-guide.md#irc-nick-changes).
168
+
169
+ A callback or message that contains `error` means the nick did not change.
170
+ Keep the previous actor. That includes:
171
+
172
+ * Another account is already stored for the target actor, in this session or
173
+ in another session on the same connection. `NICK` is not sent. The error is
174
+ `cannot rename <old-actor> to <new-actor>: credentials already stored for <new-actor>`.
175
+ The same credential object already stored at the new actor is not a
176
+ collision.
177
+ * The IRC server rejects the nick. The callback `error` is the server's
178
+ reason text. These numeric replies fail the command instead of leaving it
179
+ waiting: 431 (no nickname), 432 (erroneous nickname), 433 (nickname in
180
+ use), 436 (collision), 437 (temporarily unavailable), and 438 (nick change
181
+ too fast; sent by solanum, ircu, and Unreal).
182
+
183
+ A server-forced rename of this connection arrives as an `update` with
184
+ `object.type` `address`, `actor` the previous identity and `target` the new
185
+ one. If Sockethub cannot re-key the worker, that message includes `error`
186
+ and the session stays on the previous actor. Other users' nick changes use
187
+ the same shape and are delivered as ordinary messages.
188
+
148
189
  ### Query Attendance Example
149
190
 
150
191
  ```json
@@ -386,6 +427,23 @@ distinction clear:
386
427
  }
387
428
  ```
388
429
 
430
+ ## Messages and CTCP
431
+
432
+ A normal `send` is a channel or private `PRIVMSG`. The request schema only
433
+ accepts `object.type` `message`; the content decides the IRC command. Content
434
+ starting with `/me` is sent as a CTCP `ACTION` and content starting with
435
+ `/notice` is sent as a `NOTICE`, with the prefix stripped. An incoming
436
+ `ACTION` is delivered with `object.type` `me`. An incoming `NOTICE` is
437
+ delivered as a plain `message`.
438
+
439
+ Other incoming CTCP is not delivered to the application. The platform answers
440
+ `VERSION` with `Sockethub <platform version>` and `PING` by echoing the
441
+ argument. Other requests, and every CTCP reply, are ignored. Sending CTCP
442
+ other than `me` is not supported.
443
+
444
+ Channel and private `send` values, nicks, and topics must not contain CR or
445
+ LF. A value that does is rejected before anything is written to the socket.
446
+
389
447
  ## Features
390
448
 
391
449
  * **Channel communication**: Join and participate in IRC channels
package/dist/index.js CHANGED
@@ -17215,7 +17215,7 @@ var ActivityStreamSchema = {
17215
17215
  var package_default = {
17216
17216
  name: "@sockethub/schemas",
17217
17217
  description: "JSON schema files for validating Sockethub Activity Streams",
17218
- version: "3.0.0-beta.0",
17218
+ version: "3.0.0-beta.1",
17219
17219
  type: "module",
17220
17220
  private: false,
17221
17221
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -17285,7 +17285,7 @@ var package_default = {
17285
17285
  "ajv-formats": "^2.1.1",
17286
17286
  "ajv-formats-draft2019": "^1.6.1"
17287
17287
  },
17288
- gitHead: "75002ae8f15d7679bd58a9327f5a1d7eeaffa237",
17288
+ gitHead: "06c9062f1cb5f0c0599fd979e6e91da79f08eda0",
17289
17289
  types: "./dist/index.d.ts"
17290
17290
  };
17291
17291
 
@@ -17447,7 +17447,8 @@ var SockethubConfigSchema = {
17447
17447
  type: "object",
17448
17448
  additionalProperties: false,
17449
17449
  properties: {
17450
- connectTimeoutMs: { type: "number" }
17450
+ connectTimeoutMs: { type: "number" },
17451
+ allowPrivateAddresses: { type: "boolean" }
17451
17452
  }
17452
17453
  },
17453
17454
  "@sockethub/platform-metadata": {
@@ -17537,11 +17538,23 @@ var SockethubConfigSchema = {
17537
17538
  type: "object",
17538
17539
  additionalProperties: false,
17539
17540
  properties: {
17541
+ maxInstancesPerSession: {
17542
+ type: "integer",
17543
+ minimum: 0,
17544
+ default: 10,
17545
+ description: "Maximum persistent instances per socket session. 0 disables the cap."
17546
+ },
17547
+ maxInstancesPerIp: {
17548
+ type: "integer",
17549
+ minimum: 0,
17550
+ default: 20,
17551
+ description: "Maximum persistent instances per client IP, including HTTP actions. 0 disables the cap."
17552
+ },
17540
17553
  maxPlatformInstances: {
17541
17554
  type: "number",
17542
17555
  minimum: 0,
17543
17556
  default: 100,
17544
- description: "Upper bound on concurrently running platform instances " + "(child processes). Each persistent-platform actor forks " + "its own process, so an unbounded count is a resource " + "exhaustion risk on public instances. 0 disables the cap."
17557
+ description: "Upper bound on concurrently running persistent platform instances " + "(child processes). Each persistent-platform actor forks " + "its own process, so an unbounded count is a resource " + "exhaustion risk on public instances. 0 disables the cap."
17545
17558
  }
17546
17559
  }
17547
17560
  },
@@ -17722,33 +17735,66 @@ var SockethubConfigSchema = {
17722
17735
  };
17723
17736
  var SockethubConfigSchemaId = versionedSchemaId(SockethubConfigSchema.$id, package_default.version);
17724
17737
 
17725
- // ../schemas/src/service-descriptor.ts
17726
- var import_ajv = __toESM(require_ajv(), 1);
17727
- var ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
17738
+ // ../schemas/src/helpers/codegen.ts
17739
+ var available;
17740
+ var warned = false;
17741
+ function isCodegenAvailable() {
17742
+ if (available === undefined) {
17743
+ try {
17744
+ new Function("return true");
17745
+ available = true;
17746
+ } catch {
17747
+ available = false;
17748
+ }
17749
+ }
17750
+ return available;
17751
+ }
17752
+ function warnCodegenUnavailable() {
17753
+ if (warned) {
17754
+ return;
17755
+ }
17756
+ warned = true;
17757
+ console.warn("[@sockethub/schemas] Schema validation is disabled: this environment's Content Security Policy blocks `new Function`, which Ajv needs to compile schemas. The Sockethub server still validates every message.");
17758
+ }
17728
17759
 
17729
17760
  // ../schemas/src/validator.ts
17730
- var import_ajv2 = __toESM(require_ajv(), 1);
17761
+ var import_ajv = __toESM(require_ajv(), 1);
17731
17762
  var import_ajv_formats = __toESM(require_dist(), 1);
17732
17763
  var import_ajv_formats_draft2019 = __toESM(require_ajv_formats_draft2019(), 1);
17733
- var ajv2 = new import_ajv2.default({ strictTypes: false, allErrors: true });
17734
- import_ajv_formats.default(ajv2);
17735
- import_ajv_formats_draft2019.default(ajv2);
17736
17764
  var schemaURL = "https://sockethub.org/schemas/v0";
17737
17765
  var schemas = {};
17738
17766
  var systemContextsRegistered = false;
17739
17767
  schemas[`${schemaURL}/activity-stream`] = ActivityStreamSchema;
17740
- for (const uri in schemas) {
17741
- ajv2.addSchema(schemas[uri], uri);
17768
+ var ajv;
17769
+ function getAjv() {
17770
+ if (!isCodegenAvailable()) {
17771
+ warnCodegenUnavailable();
17772
+ return;
17773
+ }
17774
+ if (!ajv) {
17775
+ const instance = new import_ajv.default({ strictTypes: false, allErrors: true });
17776
+ import_ajv_formats.default(instance);
17777
+ import_ajv_formats_draft2019.default(instance);
17778
+ for (const uri in schemas) {
17779
+ instance.addSchema(schemas[uri], uri);
17780
+ }
17781
+ ajv = instance;
17782
+ }
17783
+ return ajv;
17742
17784
  }
17743
17785
  function registerSystemContext(platformId, contextUrl) {
17744
17786
  registerPlatformContext(platformId, contextUrl, `${schemaURL}/context/${platformId}/messages`, `${schemaURL}/context/${platformId}/credentials`);
17787
+ const instance = getAjv();
17788
+ if (!instance) {
17789
+ return;
17790
+ }
17745
17791
  const messageSchemaRef = `${schemaURL}/context/${platformId}/messages`;
17746
- if (!ajv2.getSchema(messageSchemaRef)) {
17747
- ajv2.addSchema({}, messageSchemaRef);
17792
+ if (!instance.getSchema(messageSchemaRef)) {
17793
+ instance.addSchema({}, messageSchemaRef);
17748
17794
  }
17749
17795
  const credentialsSchemaRef = `${schemaURL}/context/${platformId}/credentials`;
17750
- if (!ajv2.getSchema(credentialsSchemaRef)) {
17751
- ajv2.addSchema({}, credentialsSchemaRef);
17796
+ if (!instance.getSchema(credentialsSchemaRef)) {
17797
+ instance.addSchema({}, credentialsSchemaRef);
17752
17798
  }
17753
17799
  }
17754
17800
  function registerSystemPlatformContexts() {
@@ -17766,7 +17812,7 @@ var import_irc_socket_sasl = __toESM(require_irc_socket(), 1);
17766
17812
  var package_default2 = {
17767
17813
  name: "@sockethub/platform-irc",
17768
17814
  description: "A sockethub platform module implementing IRC functionality",
17769
- version: "4.0.0-beta.0",
17815
+ version: "4.0.0-beta.1",
17770
17816
  private: false,
17771
17817
  author: "Nick Jennings <nick@silverbucket.net>",
17772
17818
  license: "LGPL-3.0+",
@@ -17810,23 +17856,23 @@ var package_default2 = {
17810
17856
  doc: "typedoc --options typedoc.json"
17811
17857
  },
17812
17858
  dependencies: {
17813
- "@sockethub/irc2as": "^4.0.0-beta.0",
17859
+ "@sockethub/irc2as": "^4.0.0-beta.1",
17814
17860
  "irc-socket-sasl": "^4.1.2"
17815
17861
  },
17816
17862
  devDependencies: {
17817
- "@sockethub/schemas": "^3.0.0-beta.0",
17863
+ "@sockethub/schemas": "^3.0.0-beta.1",
17818
17864
  "@types/bun": "latest",
17819
17865
  typedoc: "^0.28.14"
17820
17866
  },
17821
17867
  peerDependencies: {
17822
- "@sockethub/server": "^5.0.0-beta.0"
17868
+ "@sockethub/server": "^5.0.0-beta.1"
17823
17869
  },
17824
17870
  peerDependenciesMeta: {
17825
17871
  "@sockethub/server": {
17826
17872
  optional: true
17827
17873
  }
17828
17874
  },
17829
- gitHead: "75002ae8f15d7679bd58a9327f5a1d7eeaffa237",
17875
+ gitHead: "06c9062f1cb5f0c0599fd979e6e91da79f08eda0",
17830
17876
  types: "./dist/index.d.ts"
17831
17877
  };
17832
17878
 
@@ -18797,4 +18843,4 @@ export {
18797
18843
  flattenConnectOptions
18798
18844
  };
18799
18845
 
18800
- //# debugId=4077B066167B705D64756E2164756E21
18846
+ //# debugId=C2859B68CDFCF01864756E2164756E21