@sockethub/platform-irc 4.0.0-alpha.18 → 4.0.0-alpha.20

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/dist/index.d.ts CHANGED
@@ -72,7 +72,7 @@ export declare class IRC implements PersistentPlatformInterface {
72
72
  * @param {object} job activity streams object
73
73
  * @param {object} done callback when job is done
74
74
  */
75
- join(job: ActivityStream, done: PlatformCallback): void;
75
+ join(job: ActivityStream, done: PlatformCallback): any;
76
76
  /**
77
77
  * Function leave
78
78
  *
@@ -81,7 +81,7 @@ export declare class IRC implements PersistentPlatformInterface {
81
81
  * @param {object} job activity streams object
82
82
  * @param {object} done callback when job is done
83
83
  */
84
- leave(job: ActivityStream, done: PlatformCallback): void;
84
+ leave(job: ActivityStream, done: PlatformCallback): any;
85
85
  /**
86
86
  * Function: send
87
87
  *
@@ -90,7 +90,7 @@ export declare class IRC implements PersistentPlatformInterface {
90
90
  * @param {object} job activity streams object
91
91
  * @param {object} done callback when job is done
92
92
  */
93
- send(job: ActivityStream, done: PlatformCallback): void;
93
+ send(job: ActivityStream, done: PlatformCallback): any;
94
94
  /**
95
95
  * Function: update
96
96
  *
@@ -100,7 +100,7 @@ export declare class IRC implements PersistentPlatformInterface {
100
100
  * @param {object} credentials credentials to verify this user is the right one
101
101
  * @param {object} done callback when job is done
102
102
  */
103
- update(job: ActivityStream, credentials: PlatformIrcCredentialsObject, done: PlatformCallback): void;
103
+ update(job: ActivityStream, credentials: PlatformIrcCredentialsObject, done: PlatformCallback): any;
104
104
  /**
105
105
  * Function: query
106
106
  *
@@ -109,7 +109,7 @@ export declare class IRC implements PersistentPlatformInterface {
109
109
  * @param {object} job activity streams object
110
110
  * @param {object} done callback when job is done
111
111
  */
112
- query(job: ActivityStream, done: PlatformCallback): void;
112
+ query(job: ActivityStream, done: PlatformCallback): any;
113
113
  /**
114
114
  * Disconnect IRC client
115
115
  * @param {object} job activity streams object
package/dist/index.js CHANGED
@@ -10356,7 +10356,7 @@ var require_core3 = __commonJS((exports) => {
10356
10356
  };
10357
10357
  }
10358
10358
 
10359
- class Ajv {
10359
+ class Ajv2 {
10360
10360
  constructor(opts = {}) {
10361
10361
  this.schemas = {};
10362
10362
  this.refs = {};
@@ -10713,9 +10713,9 @@ var require_core3 = __commonJS((exports) => {
10713
10713
  }
10714
10714
  }
10715
10715
  }
10716
- exports.default = Ajv;
10717
- Ajv.ValidationError = validation_error_1.default;
10718
- Ajv.MissingRefError = ref_error_1.default;
10716
+ exports.default = Ajv2;
10717
+ Ajv2.ValidationError = validation_error_1.default;
10718
+ Ajv2.MissingRefError = ref_error_1.default;
10719
10719
  function checkOptions(checkOpts, options, msg, log = "error") {
10720
10720
  for (const key in checkOpts) {
10721
10721
  const opt = key;
@@ -12676,7 +12676,7 @@ var require_ajv2 = __commonJS((exports, module) => {
12676
12676
  var META_SUPPORT_DATA = ["/properties"];
12677
12677
  var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema";
12678
12678
 
12679
- class Ajv extends core_1.default {
12679
+ class Ajv2 extends core_1.default {
12680
12680
  _addVocabularies() {
12681
12681
  super._addVocabularies();
12682
12682
  draft7_1.default.forEach((v) => this.addVocabulary(v));
@@ -12695,9 +12695,9 @@ var require_ajv2 = __commonJS((exports, module) => {
12695
12695
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined);
12696
12696
  }
12697
12697
  }
12698
- module.exports = exports = Ajv;
12698
+ module.exports = exports = Ajv2;
12699
12699
  Object.defineProperty(exports, "__esModule", { value: true });
12700
- exports.default = Ajv;
12700
+ exports.default = Ajv2;
12701
12701
  var validate_1 = require_validate2();
12702
12702
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
12703
12703
  return validate_1.KeywordCxt;
@@ -12793,9 +12793,9 @@ var require_limit = __commonJS((exports) => {
12793
12793
  },
12794
12794
  dependencies: ["format"]
12795
12795
  };
12796
- var formatLimitPlugin = (ajv) => {
12797
- ajv.addKeyword(exports.formatLimitDefinition);
12798
- return ajv;
12796
+ var formatLimitPlugin = (ajv2) => {
12797
+ ajv2.addKeyword(exports.formatLimitDefinition);
12798
+ return ajv2;
12799
12799
  };
12800
12800
  exports.default = formatLimitPlugin;
12801
12801
  });
@@ -12808,17 +12808,17 @@ var require_dist = __commonJS((exports, module) => {
12808
12808
  var codegen_1 = require_codegen2();
12809
12809
  var fullName = new codegen_1.Name("fullFormats");
12810
12810
  var fastName = new codegen_1.Name("fastFormats");
12811
- var formatsPlugin = (ajv, opts = { keywords: true }) => {
12811
+ var formatsPlugin = (ajv2, opts = { keywords: true }) => {
12812
12812
  if (Array.isArray(opts)) {
12813
- addFormats(ajv, opts, formats_1.fullFormats, fullName);
12814
- return ajv;
12813
+ addFormats(ajv2, opts, formats_1.fullFormats, fullName);
12814
+ return ajv2;
12815
12815
  }
12816
12816
  const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
12817
12817
  const list = opts.formats || formats_1.formatNames;
12818
- addFormats(ajv, list, formats, exportName);
12818
+ addFormats(ajv2, list, formats, exportName);
12819
12819
  if (opts.keywords)
12820
- limit_1.default(ajv);
12821
- return ajv;
12820
+ limit_1.default(ajv2);
12821
+ return ajv2;
12822
12822
  };
12823
12823
  formatsPlugin.get = (name, mode = "full") => {
12824
12824
  const formats = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats;
@@ -12827,12 +12827,12 @@ var require_dist = __commonJS((exports, module) => {
12827
12827
  throw new Error(`Unknown format "${name}"`);
12828
12828
  return f;
12829
12829
  };
12830
- function addFormats(ajv, list, fs, exportName) {
12830
+ function addFormats(ajv2, list, fs, exportName) {
12831
12831
  var _a;
12832
12832
  var _b;
12833
- (_a = (_b = ajv.opts.code).formats) !== null && _a !== undefined || (_b.formats = codegen_1._`require("ajv-formats/dist/formats").${exportName}`);
12833
+ (_a = (_b = ajv2.opts.code).formats) !== null && _a !== undefined || (_b.formats = codegen_1._`require("ajv-formats/dist/formats").${exportName}`);
12834
12834
  for (const f of list)
12835
- ajv.addFormat(f, fs[f]);
12835
+ ajv2.addFormat(f, fs[f]);
12836
12836
  }
12837
12837
  module.exports = exports = formatsPlugin;
12838
12838
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -15743,7 +15743,7 @@ var require_formats2 = __commonJS((exports, module) => {
15743
15743
  // ../../node_modules/ajv-formats-draft2019/index.js
15744
15744
  var require_ajv_formats_draft2019 = __commonJS((exports, module) => {
15745
15745
  var formats = require_formats2();
15746
- module.exports = (ajv, options = {}) => {
15746
+ module.exports = (ajv2, options = {}) => {
15747
15747
  const allFormats = Object.keys(formats);
15748
15748
  let formatsToInstall = allFormats;
15749
15749
  if (options.formats) {
@@ -15752,9 +15752,9 @@ var require_ajv_formats_draft2019 = __commonJS((exports, module) => {
15752
15752
  formatsToInstall = options.formats;
15753
15753
  }
15754
15754
  allFormats.filter((format) => formatsToInstall.includes(format)).forEach((key) => {
15755
- ajv.addFormat(key, formats[key]);
15755
+ ajv2.addFormat(key, formats[key]);
15756
15756
  });
15757
- return ajv;
15757
+ return ajv2;
15758
15758
  };
15759
15759
  });
15760
15760
 
@@ -16794,6 +16794,10 @@ function registerPlatformContext(platformId, platformContextUrl, schemaId, crede
16794
16794
  platformContextToCredentialsSchemaId.set(platformContextUrl, credentialsSchemaId);
16795
16795
  }
16796
16796
 
16797
+ // ../schemas/src/examples-config.ts
16798
+ var import_ajv = __toESM(require_ajv(), 1);
16799
+ var ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
16800
+
16797
16801
  // ../schemas/src/helpers/objects.ts
16798
16802
  var ObjectTypesSchema = {
16799
16803
  feed: {
@@ -16927,6 +16931,19 @@ var ObjectTypesSchema = {
16927
16931
  }
16928
16932
  }
16929
16933
  }
16934
+ },
16935
+ addressBook: {
16936
+ required: ["id", "type"],
16937
+ additionalProperties: false,
16938
+ properties: {
16939
+ id: {
16940
+ type: "string",
16941
+ format: "iri"
16942
+ },
16943
+ type: {
16944
+ enum: ["addressBook"]
16945
+ }
16946
+ }
16930
16947
  }
16931
16948
  };
16932
16949
  var ObjectTypesList = Object.keys(ObjectTypesSchema);
@@ -16946,7 +16963,8 @@ var TargetTypesList = [
16946
16963
  "website",
16947
16964
  "platform",
16948
16965
  "address",
16949
- "calendar"
16966
+ "calendar",
16967
+ "addressBook"
16950
16968
  ];
16951
16969
  var validActorRefs = ActorTypesList.map((type) => ({
16952
16970
  $ref: `#/definitions/type/${type}`
@@ -17015,7 +17033,7 @@ var ActivityStreamSchema = {
17015
17033
  var package_default = {
17016
17034
  name: "@sockethub/schemas",
17017
17035
  description: "JSON schema files for validating Sockethub Activity Streams",
17018
- version: "3.0.0-alpha.18",
17036
+ version: "3.0.0-alpha.20",
17019
17037
  type: "module",
17020
17038
  private: false,
17021
17039
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -17040,8 +17058,17 @@ var package_default = {
17040
17058
  import: "./dist/object-types.js",
17041
17059
  default: "./dist/object-types.js"
17042
17060
  },
17061
+ "./examples-config": {
17062
+ types: "./dist/examples-config.d.ts",
17063
+ bun: "./src/examples-config.ts",
17064
+ import: "./dist/examples-config.js",
17065
+ default: "./dist/examples-config.js"
17066
+ },
17043
17067
  "./schemas/json/sockethub-config.json": {
17044
17068
  default: "./dist/schemas/json/sockethub-config.json"
17069
+ },
17070
+ "./schemas/json/examples-config.json": {
17071
+ default: "./dist/schemas/json/examples-config.json"
17045
17072
  }
17046
17073
  },
17047
17074
  files: [
@@ -17067,7 +17094,7 @@ var package_default = {
17067
17094
  "@types/bun": "latest"
17068
17095
  },
17069
17096
  scripts: {
17070
- build: "bun ./scripts/export-json-schema.ts && bun ./scripts/export-canonical-assets.ts && bun build src/index.ts src/object-types.ts --outdir dist --target node --format esm --sourcemap=external && bun build src/context.ts src/activity-stream-helper.ts --outdir dist --target browser --format esm --sourcemap=external",
17097
+ build: "bun ./scripts/export-json-schema.ts && bun ./scripts/export-canonical-assets.ts && bun build src/index.ts src/object-types.ts --outdir dist --target node --format esm --sourcemap=external && bun build src/context.ts src/activity-stream-helper.ts src/examples-config.ts --outdir dist --target browser --format esm --sourcemap=external",
17071
17098
  clean: "rm -rf dist",
17072
17099
  "clean:deps": "rm -rf node_modules"
17073
17100
  },
@@ -17076,7 +17103,7 @@ var package_default = {
17076
17103
  "ajv-formats": "^2.1.1",
17077
17104
  "ajv-formats-draft2019": "^1.6.1"
17078
17105
  },
17079
- gitHead: "c0a5b3b61f376651fc5184d1072a78c43f5ebb9e",
17106
+ gitHead: "194422de2ffe1a95ffff45063bc988da8594756a",
17080
17107
  types: "./dist/index.d.ts"
17081
17108
  };
17082
17109
 
@@ -17133,6 +17160,7 @@ var SockethubConfigSchema = {
17133
17160
  },
17134
17161
  description: "Platform packages to load",
17135
17162
  default: [
17163
+ "@sockethub/platform-carddav",
17136
17164
  "@sockethub/platform-caldav",
17137
17165
  "@sockethub/platform-dummy",
17138
17166
  "@sockethub/platform-feeds",
@@ -17146,6 +17174,16 @@ var SockethubConfigSchema = {
17146
17174
  default: {},
17147
17175
  description: "Per-platform config keyed by package name, validated against " + "each platform's config schema and forwarded to its child process",
17148
17176
  properties: {
17177
+ "@sockethub/platform-carddav": {
17178
+ type: "object",
17179
+ additionalProperties: false,
17180
+ properties: {
17181
+ connectTimeoutMs: { type: "integer", minimum: 1 },
17182
+ allowPrivateAddresses: { type: "boolean" },
17183
+ allowInsecureHttp: { type: "boolean" },
17184
+ concurrency: { type: "integer", minimum: 1 }
17185
+ }
17186
+ },
17149
17187
  "@sockethub/platform-caldav": {
17150
17188
  type: "object",
17151
17189
  additionalProperties: false,
@@ -17264,7 +17302,7 @@ var SockethubConfigSchema = {
17264
17302
  maxConnectionsPerIp: {
17265
17303
  type: "number",
17266
17304
  minimum: 0,
17267
- default: 0,
17305
+ default: 20,
17268
17306
  description: "Maximum concurrent socket connections per client IP. " + "The per-event rate limiter is keyed by socket id, so " + "without a connection cap a client can bypass it by " + "opening more sockets. 0 disables the cap."
17269
17307
  }
17270
17308
  }
@@ -17276,7 +17314,7 @@ var SockethubConfigSchema = {
17276
17314
  maxPlatformInstances: {
17277
17315
  type: "number",
17278
17316
  minimum: 0,
17279
- default: 0,
17317
+ default: 100,
17280
17318
  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."
17281
17319
  }
17282
17320
  }
@@ -17336,6 +17374,12 @@ var SockethubConfigSchema = {
17336
17374
  type: "string",
17337
17375
  default: "/sockethub"
17338
17376
  },
17377
+ maxPayloadBytes: {
17378
+ type: "integer",
17379
+ minimum: 1,
17380
+ default: 262144,
17381
+ description: "Maximum size in bytes of a single Socket.IO message."
17382
+ },
17339
17383
  cors: {
17340
17384
  type: "object",
17341
17385
  additionalProperties: false,
@@ -17412,28 +17456,28 @@ var SockethubConfigSchema = {
17412
17456
  var SockethubConfigSchemaId = versionedSchemaId(SockethubConfigSchema.$id, package_default.version);
17413
17457
 
17414
17458
  // ../schemas/src/validator.ts
17415
- var import_ajv = __toESM(require_ajv(), 1);
17459
+ var import_ajv2 = __toESM(require_ajv(), 1);
17416
17460
  var import_ajv_formats = __toESM(require_dist(), 1);
17417
17461
  var import_ajv_formats_draft2019 = __toESM(require_ajv_formats_draft2019(), 1);
17418
- var ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
17419
- import_ajv_formats.default(ajv);
17420
- import_ajv_formats_draft2019.default(ajv);
17462
+ var ajv2 = new import_ajv2.default({ strictTypes: false, allErrors: true });
17463
+ import_ajv_formats.default(ajv2);
17464
+ import_ajv_formats_draft2019.default(ajv2);
17421
17465
  var schemaURL = "https://sockethub.org/schemas/v0";
17422
17466
  var schemas = {};
17423
17467
  var systemContextsRegistered = false;
17424
17468
  schemas[`${schemaURL}/activity-stream`] = ActivityStreamSchema;
17425
17469
  for (const uri in schemas) {
17426
- ajv.addSchema(schemas[uri], uri);
17470
+ ajv2.addSchema(schemas[uri], uri);
17427
17471
  }
17428
17472
  function registerSystemContext(platformId, contextUrl) {
17429
17473
  registerPlatformContext(platformId, contextUrl, `${schemaURL}/context/${platformId}/messages`, `${schemaURL}/context/${platformId}/credentials`);
17430
17474
  const messageSchemaRef = `${schemaURL}/context/${platformId}/messages`;
17431
- if (!ajv.getSchema(messageSchemaRef)) {
17432
- ajv.addSchema({}, messageSchemaRef);
17475
+ if (!ajv2.getSchema(messageSchemaRef)) {
17476
+ ajv2.addSchema({}, messageSchemaRef);
17433
17477
  }
17434
17478
  const credentialsSchemaRef = `${schemaURL}/context/${platformId}/credentials`;
17435
- if (!ajv.getSchema(credentialsSchemaRef)) {
17436
- ajv.addSchema({}, credentialsSchemaRef);
17479
+ if (!ajv2.getSchema(credentialsSchemaRef)) {
17480
+ ajv2.addSchema({}, credentialsSchemaRef);
17437
17481
  }
17438
17482
  }
17439
17483
  function registerSystemPlatformContexts() {
@@ -17451,7 +17495,7 @@ var import_irc_socket_sasl = __toESM(require_irc_socket(), 1);
17451
17495
  var package_default2 = {
17452
17496
  name: "@sockethub/platform-irc",
17453
17497
  description: "A sockethub platform module implementing IRC functionality",
17454
- version: "4.0.0-alpha.18",
17498
+ version: "4.0.0-alpha.20",
17455
17499
  private: false,
17456
17500
  author: "Nick Jennings <nick@silverbucket.net>",
17457
17501
  license: "LGPL-3.0+",
@@ -17495,23 +17539,23 @@ var package_default2 = {
17495
17539
  doc: "typedoc --options typedoc.json"
17496
17540
  },
17497
17541
  dependencies: {
17498
- "@sockethub/irc2as": "^4.0.0-alpha.18",
17542
+ "@sockethub/irc2as": "^4.0.0-alpha.20",
17499
17543
  "irc-socket-sasl": "^4.1.2"
17500
17544
  },
17501
17545
  devDependencies: {
17502
- "@sockethub/schemas": "^3.0.0-alpha.18",
17546
+ "@sockethub/schemas": "^3.0.0-alpha.20",
17503
17547
  "@types/bun": "latest",
17504
17548
  typedoc: "^0.28.14"
17505
17549
  },
17506
17550
  peerDependencies: {
17507
- "@sockethub/server": "^5.0.0-alpha.18"
17551
+ "@sockethub/server": "^5.0.0-alpha.20"
17508
17552
  },
17509
17553
  peerDependenciesMeta: {
17510
17554
  "@sockethub/server": {
17511
17555
  optional: true
17512
17556
  }
17513
17557
  },
17514
- gitHead: "c0a5b3b61f376651fc5184d1072a78c43f5ebb9e",
17558
+ gitHead: "194422de2ffe1a95ffff45063bc988da8594756a",
17515
17559
  types: "./dist/index.d.ts"
17516
17560
  };
17517
17561
 
@@ -17827,6 +17871,12 @@ var tlsTransport = {
17827
17871
  return tls.connect(flattenConnectOptions(options), ...rest);
17828
17872
  }
17829
17873
  };
17874
+ var IRC_LINE_BREAK = /[\r\n]/;
17875
+ function ircLineBreakError(values) {
17876
+ if (values.some((value) => typeof value === "string" && IRC_LINE_BREAK.test(value))) {
17877
+ return "IRC values must not contain CR or LF characters";
17878
+ }
17879
+ }
17830
17880
 
17831
17881
  class IRC {
17832
17882
  log;
@@ -17867,6 +17917,12 @@ class IRC {
17867
17917
  }
17868
17918
  join(job, done) {
17869
17919
  this.log.debug(`join() called for ${job.actor.id}`);
17920
+ const lineBreakError = ircLineBreakError([
17921
+ job.actor.name,
17922
+ job.target.name
17923
+ ]);
17924
+ if (lineBreakError)
17925
+ return done(lineBreakError);
17870
17926
  this.getClient(job.actor.id, false, (err, client) => {
17871
17927
  if (err) {
17872
17928
  return done(err);
@@ -17886,6 +17942,9 @@ class IRC {
17886
17942
  }
17887
17943
  leave(job, done) {
17888
17944
  this.log.debug(`leave() called for ${job.actor.name}`);
17945
+ const lineBreakError = ircLineBreakError([job.target.name]);
17946
+ if (lineBreakError)
17947
+ return done(lineBreakError);
17889
17948
  this.getClient(job.actor.id, false, (err, client) => {
17890
17949
  if (err) {
17891
17950
  return done(err);
@@ -17897,6 +17956,13 @@ class IRC {
17897
17956
  }
17898
17957
  send(job, done) {
17899
17958
  this.log.debug(`send() called for ${job.actor.id} target: ${job.target.id}`);
17959
+ const lineBreakError = ircLineBreakError([
17960
+ job.actor.name,
17961
+ job.target.name,
17962
+ job.object?.content
17963
+ ]);
17964
+ if (lineBreakError)
17965
+ return done(lineBreakError);
17900
17966
  this.getClient(job.actor.id, false, async (err, client) => {
17901
17967
  if (err) {
17902
17968
  return done(err);
@@ -17937,6 +18003,13 @@ class IRC {
17937
18003
  }
17938
18004
  update(job, credentials, done) {
17939
18005
  this.log.debug(`update() called for ${job.actor.id}`);
18006
+ const lineBreakError = ircLineBreakError([
18007
+ job.actor.name,
18008
+ job.target.name,
18009
+ job.object?.content
18010
+ ]);
18011
+ if (lineBreakError)
18012
+ return done(lineBreakError);
17940
18013
  this.getClient(job.actor.id, false, (err, client) => {
17941
18014
  if (err) {
17942
18015
  return done(err);
@@ -17968,6 +18041,12 @@ class IRC {
17968
18041
  }
17969
18042
  query(job, done) {
17970
18043
  this.log.debug(`query() called for ${job.actor.id}`);
18044
+ const lineBreakError = ircLineBreakError([
18045
+ job.target?.name,
18046
+ job.target?.id
18047
+ ]);
18048
+ if (lineBreakError)
18049
+ return done(lineBreakError);
17971
18050
  this.getClient(job.actor.id, false, (err, client) => {
17972
18051
  if (err) {
17973
18052
  return done(err);
@@ -18065,6 +18144,13 @@ class IRC {
18065
18144
  });
18066
18145
  }
18067
18146
  ircConnect(credentials, cb) {
18147
+ const lineBreakError = ircLineBreakError([
18148
+ credentials.object.nick,
18149
+ credentials.object.username,
18150
+ credentials.actor.name
18151
+ ]);
18152
+ if (lineBreakError)
18153
+ return cb(lineBreakError);
18068
18154
  this.clientConnecting = true;
18069
18155
  const is_secure = typeof credentials.object.secure === "boolean" ? credentials.object.secure : true;
18070
18156
  const sasl_secret = credentials.object.token || credentials.object.password;
@@ -18178,4 +18264,4 @@ export {
18178
18264
  IRC
18179
18265
  };
18180
18266
 
18181
- //# debugId=712AAF8B8A6CEE9464756E2164756E21
18267
+ //# debugId=AD6355FA1FEF907764756E2164756E21