@sockethub/server 5.0.0-beta.1 → 5.0.0-beta.3

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.
@@ -58,6 +58,7 @@ export declare function beginCredentialScope(sessionId: string, platform: string
58
58
  /** Drops a session's scopes. Called when the session ends. */
59
59
  export declare function clearSessionScopes(sessionId: string): void;
60
60
  export interface ScopeRequest {
61
+ shareConnections?: boolean;
61
62
  /**
62
63
  * Session the credentials were submitted under. Over a socket this is the
63
64
  * socket id; over HTTP it is the request's single-use session, which is
package/dist/index.js CHANGED
@@ -11057,7 +11057,7 @@ var init_package = __esm(() => {
11057
11057
  package_default = {
11058
11058
  name: "@sockethub/schemas",
11059
11059
  description: "JSON schema files for validating Sockethub Activity Streams",
11060
- version: "3.0.0-beta.1",
11060
+ version: "3.0.0-beta.3",
11061
11061
  type: "module",
11062
11062
  private: false,
11063
11063
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -11127,7 +11127,7 @@ var init_package = __esm(() => {
11127
11127
  "ajv-formats": "^2.1.1",
11128
11128
  "ajv-formats-draft2019": "^1.6.1"
11129
11129
  },
11130
- gitHead: "06c9062f1cb5f0c0599fd979e6e91da79f08eda0",
11130
+ gitHead: "bc04522d60d1e2fa1b3098b339897de62c3b0549",
11131
11131
  types: "./dist/index.d.ts"
11132
11132
  };
11133
11133
  });
@@ -11236,8 +11236,12 @@ var init_sockethub_config = __esm(() => {
11236
11236
  "@sockethub/platform-caldav",
11237
11237
  "@sockethub/platform-dummy",
11238
11238
  "@sockethub/platform-feeds",
11239
+ "@sockethub/platform-email",
11239
11240
  "@sockethub/platform-irc",
11240
11241
  "@sockethub/platform-metadata",
11242
+ "@sockethub/platform-messenger",
11243
+ "@sockethub/platform-instagram",
11244
+ "@sockethub/platform-whatsapp",
11241
11245
  "@sockethub/platform-xmpp"
11242
11246
  ]
11243
11247
  },
@@ -11253,7 +11257,8 @@ var init_sockethub_config = __esm(() => {
11253
11257
  connectTimeoutMs: { type: "integer", minimum: 1 },
11254
11258
  allowPrivateAddresses: { type: "boolean" },
11255
11259
  allowInsecureHttp: { type: "boolean" },
11256
- concurrency: { type: "integer", minimum: 1 }
11260
+ concurrency: { type: "integer", minimum: 1 },
11261
+ discoveryCacheTtlMs: { type: "integer", minimum: 0 }
11257
11262
  }
11258
11263
  },
11259
11264
  "@sockethub/platform-caldav": {
@@ -11263,7 +11268,20 @@ var init_sockethub_config = __esm(() => {
11263
11268
  connectTimeoutMs: { type: "integer", minimum: 1 },
11264
11269
  allowPrivateAddresses: { type: "boolean" },
11265
11270
  allowInsecureHttp: { type: "boolean" },
11266
- concurrency: { type: "integer", minimum: 1 }
11271
+ concurrency: { type: "integer", minimum: 1 },
11272
+ discoveryCacheTtlMs: { type: "integer", minimum: 0 }
11273
+ }
11274
+ },
11275
+ "@sockethub/platform-email": {
11276
+ type: "object",
11277
+ additionalProperties: false,
11278
+ properties: {
11279
+ connectTimeoutMs: {
11280
+ type: "integer",
11281
+ minimum: 5000,
11282
+ maximum: 120000
11283
+ },
11284
+ allowPrivateAddresses: { type: "boolean" }
11267
11285
  }
11268
11286
  },
11269
11287
  "@sockethub/platform-dummy": {
@@ -11286,7 +11304,8 @@ var init_sockethub_config = __esm(() => {
11286
11304
  type: "object",
11287
11305
  additionalProperties: false,
11288
11306
  properties: {
11289
- connectTimeoutMs: { type: "number" }
11307
+ connectTimeoutMs: { type: "number" },
11308
+ allowPrivateAddresses: { type: "boolean" }
11290
11309
  }
11291
11310
  },
11292
11311
  "@sockethub/platform-xmpp": {
@@ -11396,6 +11415,12 @@ var init_sockethub_config = __esm(() => {
11396
11415
  default: 20,
11397
11416
  description: "Maximum persistent instances per client IP, including HTTP actions. 0 disables the cap."
11398
11417
  },
11418
+ maxStartsPerIpPerMinute: {
11419
+ type: "integer",
11420
+ minimum: 0,
11421
+ default: 60,
11422
+ description: "Maximum new persistent instances a client IP may start per minute, " + "including HTTP actions. Bounds fork/teardown churn that the " + "concurrent caps allow. Reusing a running instance does not count. " + "0 disables the cap."
11423
+ },
11399
11424
  maxPlatformInstances: {
11400
11425
  type: "number",
11401
11426
  minimum: 0,
@@ -27650,9 +27675,8 @@ function addPlatformSchema(schema, platform_type) {
27650
27675
  return;
27651
27676
  }
27652
27677
  const schemaRef = `${schemaURL}/context/${platform_type}`;
27653
- if (!instance.getSchema(schemaRef)) {
27654
- instance.addSchema(schema, schemaRef);
27655
- }
27678
+ instance.removeSchema(schemaRef);
27679
+ instance.addSchema(schema, schemaRef);
27656
27680
  }
27657
27681
  function addPlatformContext(platformId, platformContextUrl) {
27658
27682
  registerPlatformContext(platformId, platformContextUrl, `${schemaURL}/context/${platformId}/messages`, `${schemaURL}/context/${platformId}/credentials`);
@@ -30000,6 +30024,7 @@ var init_config_schema = __esm(() => {
30000
30024
  "rateLimiter.maxConnectionsPerIp": { format: "nat" },
30001
30025
  "limits.maxInstancesPerSession": { format: "nat" },
30002
30026
  "limits.maxInstancesPerIp": { format: "nat" },
30027
+ "limits.maxStartsPerIpPerMinute": { format: "nat" },
30003
30028
  "limits.maxPlatformInstances": { format: "nat" },
30004
30029
  "credentials.ttlMs": {
30005
30030
  format: "nat",
@@ -99068,7 +99093,7 @@ var require_package2 = __commonJS(function(exports, module) {
99068
99093
  module.exports = {
99069
99094
  name: "@sockethub/server",
99070
99095
  description: "A polyglot messaging service, server libraries",
99071
- version: "5.0.0-beta.1",
99096
+ version: "5.0.0-beta.3",
99072
99097
  type: "module",
99073
99098
  private: false,
99074
99099
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -99093,7 +99118,7 @@ var require_package2 = __commonJS(function(exports, module) {
99093
99118
  bin: "bin/sockethub",
99094
99119
  preferGlobal: true,
99095
99120
  engines: {
99096
- node: ">=20"
99121
+ node: ">=20.19"
99097
99122
  },
99098
99123
  keywords: [
99099
99124
  "sockethub",
@@ -99120,11 +99145,11 @@ var require_package2 = __commonJS(function(exports, module) {
99120
99145
  dependencies: {
99121
99146
  "@sentry/node": "^10.36.0",
99122
99147
  "@sentry/profiling-node": "10.36.0",
99123
- "@sockethub/client": "^5.0.0-beta.1",
99124
- "@sockethub/data-layer": "^1.0.0-beta.1",
99125
- "@sockethub/logger": "^1.0.0-beta.1",
99126
- "@sockethub/schemas": "^3.0.0-beta.1",
99127
- "@sockethub/util": "^1.0.0-beta.1",
99148
+ "@sockethub/client": "^5.0.0-beta.3",
99149
+ "@sockethub/data-layer": "^1.0.0-beta.3",
99150
+ "@sockethub/logger": "^1.0.0-beta.3",
99151
+ "@sockethub/schemas": "^3.0.0-beta.3",
99152
+ "@sockethub/util": "^1.0.0-beta.3",
99128
99153
  chalk: "^5.6.2",
99129
99154
  convict: "^6.2.5",
99130
99155
  debug: "^4.4.3",
@@ -99158,16 +99183,20 @@ var require_package2 = __commonJS(function(exports, module) {
99158
99183
  "web-streams-polyfill": "^3.3.3"
99159
99184
  },
99160
99185
  optionalDependencies: {
99161
- "@sockethub/examples": "^1.0.0-beta.1",
99162
- "@sockethub/platform-caldav": "^1.0.0-beta.1",
99163
- "@sockethub/platform-carddav": "^1.0.0-beta.1",
99164
- "@sockethub/platform-dummy": "^3.0.0-beta.1",
99165
- "@sockethub/platform-feeds": "^4.0.0-beta.1",
99166
- "@sockethub/platform-irc": "^4.0.0-beta.1",
99167
- "@sockethub/platform-metadata": "^1.0.1-beta.1",
99168
- "@sockethub/platform-xmpp": "^5.0.0-beta.1"
99169
- },
99170
- gitHead: "06c9062f1cb5f0c0599fd979e6e91da79f08eda0",
99186
+ "@sockethub/examples": "^1.0.0-beta.3",
99187
+ "@sockethub/platform-caldav": "^1.0.0-beta.3",
99188
+ "@sockethub/platform-carddav": "^1.0.0-beta.3",
99189
+ "@sockethub/platform-dummy": "^3.0.0-beta.3",
99190
+ "@sockethub/platform-email": "^1.0.0-beta.3",
99191
+ "@sockethub/platform-feeds": "^4.0.0-beta.3",
99192
+ "@sockethub/platform-instagram": "^1.0.0-beta.3",
99193
+ "@sockethub/platform-irc": "^4.0.0-beta.3",
99194
+ "@sockethub/platform-messenger": "^1.0.0-beta.3",
99195
+ "@sockethub/platform-metadata": "^1.0.1-beta.3",
99196
+ "@sockethub/platform-whatsapp": "^1.0.0-beta.3",
99197
+ "@sockethub/platform-xmpp": "^5.0.0-beta.3"
99198
+ },
99199
+ gitHead: "bc04522d60d1e2fa1b3098b339897de62c3b0549",
99171
99200
  types: "./dist/index.d.ts"
99172
99201
  };
99173
99202
  });
@@ -100111,7 +100140,7 @@ var require_safer = __commonJS(function(exports, module) {
100111
100140
  module.exports = safer;
100112
100141
  });
100113
100142
 
100114
- // ../../node_modules/iconv-lite/lib/bom-handling.js
100143
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/lib/bom-handling.js
100115
100144
  var require_bom_handling = __commonJS(function(exports) {
100116
100145
  var BOMChar = "\uFEFF";
100117
100146
  exports.PrependBOM = PrependBOMWrapper;
@@ -100154,7 +100183,7 @@ var require_bom_handling = __commonJS(function(exports) {
100154
100183
  };
100155
100184
  });
100156
100185
 
100157
- // ../../node_modules/iconv-lite/lib/helpers/merge-exports.js
100186
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/lib/helpers/merge-exports.js
100158
100187
  var require_merge_exports = __commonJS(function(exports, module) {
100159
100188
  var hasOwn = typeof Object.hasOwn === "undefined" ? Function.call.bind(Object.prototype.hasOwnProperty) : Object.hasOwn;
100160
100189
  function mergeModules(target, module2) {
@@ -100167,7 +100196,7 @@ var require_merge_exports = __commonJS(function(exports, module) {
100167
100196
  module.exports = mergeModules;
100168
100197
  });
100169
100198
 
100170
- // ../../node_modules/iconv-lite/encodings/internal.js
100199
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/internal.js
100171
100200
  var require_internal = __commonJS(function(exports, module) {
100172
100201
  var Buffer2 = require_safer().Buffer;
100173
100202
  module.exports = {
@@ -100340,7 +100369,7 @@ var require_internal = __commonJS(function(exports, module) {
100340
100369
  };
100341
100370
  });
100342
100371
 
100343
- // ../../node_modules/iconv-lite/encodings/utf32.js
100372
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/utf32.js
100344
100373
  var require_utf32 = __commonJS(function(exports) {
100345
100374
  var Buffer2 = require_safer().Buffer;
100346
100375
  exports._utf32 = Utf32Codec;
@@ -100574,7 +100603,7 @@ var require_utf32 = __commonJS(function(exports) {
100574
100603
  }
100575
100604
  });
100576
100605
 
100577
- // ../../node_modules/iconv-lite/encodings/utf16.js
100606
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/utf16.js
100578
100607
  var require_utf16 = __commonJS(function(exports) {
100579
100608
  var Buffer2 = require_safer().Buffer;
100580
100609
  exports.utf16be = Utf16BECodec;
@@ -100717,7 +100746,7 @@ var require_utf16 = __commonJS(function(exports) {
100717
100746
  }
100718
100747
  });
100719
100748
 
100720
- // ../../node_modules/iconv-lite/encodings/utf7.js
100749
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/utf7.js
100721
100750
  var require_utf7 = __commonJS(function(exports) {
100722
100751
  var Buffer2 = require_safer().Buffer;
100723
100752
  exports.utf7 = Utf7Codec;
@@ -100931,7 +100960,7 @@ var require_utf7 = __commonJS(function(exports) {
100931
100960
  };
100932
100961
  });
100933
100962
 
100934
- // ../../node_modules/iconv-lite/encodings/sbcs-codec.js
100963
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-codec.js
100935
100964
  var require_sbcs_codec = __commonJS(function(exports) {
100936
100965
  var Buffer2 = require_safer().Buffer;
100937
100966
  exports._sbcs = SBCSCodec;
@@ -100988,7 +101017,7 @@ var require_sbcs_codec = __commonJS(function(exports) {
100988
101017
  SBCSDecoder.prototype.end = function() {};
100989
101018
  });
100990
101019
 
100991
- // ../../node_modules/iconv-lite/encodings/sbcs-data.js
101020
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-data.js
100992
101021
  var require_sbcs_data = __commonJS(function(exports, module) {
100993
101022
  module.exports = {
100994
101023
  10029: "maccenteuro",
@@ -101136,7 +101165,7 @@ var require_sbcs_data = __commonJS(function(exports, module) {
101136
101165
  };
101137
101166
  });
101138
101167
 
101139
- // ../../node_modules/iconv-lite/encodings/sbcs-data-generated.js
101168
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-data-generated.js
101140
101169
  var require_sbcs_data_generated = __commonJS(function(exports, module) {
101141
101170
  module.exports = {
101142
101171
  "437": "cp437",
@@ -101593,7 +101622,7 @@ var require_sbcs_data_generated = __commonJS(function(exports, module) {
101593
101622
  };
101594
101623
  });
101595
101624
 
101596
- // ../../node_modules/iconv-lite/encodings/dbcs-codec.js
101625
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/dbcs-codec.js
101597
101626
  var require_dbcs_codec = __commonJS(function(exports) {
101598
101627
  var Buffer2 = require_safer().Buffer;
101599
101628
  exports._dbcs = DBCSCodec;
@@ -102051,7 +102080,7 @@ var require_dbcs_codec = __commonJS(function(exports) {
102051
102080
  }
102052
102081
  });
102053
102082
 
102054
- // ../../node_modules/iconv-lite/encodings/tables/shiftjis.json
102083
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/shiftjis.json
102055
102084
  var require_shiftjis = __commonJS(function(exports, module) {
102056
102085
  module.exports = [
102057
102086
  ["0", "\x00", 128],
@@ -102180,7 +102209,7 @@ var require_shiftjis = __commonJS(function(exports, module) {
102180
102209
  ];
102181
102210
  });
102182
102211
 
102183
- // ../../node_modules/iconv-lite/encodings/tables/eucjp.json
102212
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/eucjp.json
102184
102213
  var require_eucjp = __commonJS(function(exports, module) {
102185
102214
  module.exports = [
102186
102215
  ["0", "\x00", 127],
@@ -102366,7 +102395,7 @@ var require_eucjp = __commonJS(function(exports, module) {
102366
102395
  ];
102367
102396
  });
102368
102397
 
102369
- // ../../node_modules/iconv-lite/encodings/tables/cp936.json
102398
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/cp936.json
102370
102399
  var require_cp936 = __commonJS(function(exports, module) {
102371
102400
  module.exports = [
102372
102401
  ["0", "\x00", 127, "€"],
@@ -102634,7 +102663,7 @@ var require_cp936 = __commonJS(function(exports, module) {
102634
102663
  ];
102635
102664
  });
102636
102665
 
102637
- // ../../node_modules/iconv-lite/encodings/tables/gbk-added.json
102666
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/gbk-added.json
102638
102667
  var require_gbk_added = __commonJS(function(exports, module) {
102639
102668
  module.exports = [
102640
102669
  ["a140", "", 62],
@@ -102694,12 +102723,12 @@ var require_gbk_added = __commonJS(function(exports, module) {
102694
102723
  ];
102695
102724
  });
102696
102725
 
102697
- // ../../node_modules/iconv-lite/encodings/tables/gb18030-ranges.json
102726
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json
102698
102727
  var require_gb18030_ranges = __commonJS(function(exports, module) {
102699
102728
  module.exports = { uChars: [128, 165, 169, 178, 184, 216, 226, 235, 238, 244, 248, 251, 253, 258, 276, 284, 300, 325, 329, 334, 364, 463, 465, 467, 469, 471, 473, 475, 477, 506, 594, 610, 712, 716, 730, 930, 938, 962, 970, 1026, 1104, 1106, 8209, 8215, 8218, 8222, 8231, 8241, 8244, 8246, 8252, 8365, 8452, 8454, 8458, 8471, 8482, 8556, 8570, 8596, 8602, 8713, 8720, 8722, 8726, 8731, 8737, 8740, 8742, 8748, 8751, 8760, 8766, 8777, 8781, 8787, 8802, 8808, 8816, 8854, 8858, 8870, 8896, 8979, 9322, 9372, 9548, 9588, 9616, 9622, 9634, 9652, 9662, 9672, 9676, 9680, 9702, 9735, 9738, 9793, 9795, 11906, 11909, 11913, 11917, 11928, 11944, 11947, 11951, 11956, 11960, 11964, 11979, 12284, 12292, 12312, 12319, 12330, 12351, 12436, 12447, 12535, 12543, 12586, 12842, 12850, 12964, 13200, 13215, 13218, 13253, 13263, 13267, 13270, 13384, 13428, 13727, 13839, 13851, 14617, 14703, 14801, 14816, 14964, 15183, 15471, 15585, 16471, 16736, 17208, 17325, 17330, 17374, 17623, 17997, 18018, 18212, 18218, 18301, 18318, 18760, 18811, 18814, 18820, 18823, 18844, 18848, 18872, 19576, 19620, 19738, 19887, 40870, 59244, 59336, 59367, 59413, 59417, 59423, 59431, 59437, 59443, 59452, 59460, 59478, 59493, 63789, 63866, 63894, 63976, 63986, 64016, 64018, 64021, 64025, 64034, 64037, 64042, 65074, 65093, 65107, 65112, 65127, 65132, 65375, 65510, 65536], gbChars: [0, 36, 38, 45, 50, 81, 89, 95, 96, 100, 103, 104, 105, 109, 126, 133, 148, 172, 175, 179, 208, 306, 307, 308, 309, 310, 311, 312, 313, 341, 428, 443, 544, 545, 558, 741, 742, 749, 750, 805, 819, 820, 7922, 7924, 7925, 7927, 7934, 7943, 7944, 7945, 7950, 8062, 8148, 8149, 8152, 8164, 8174, 8236, 8240, 8262, 8264, 8374, 8380, 8381, 8384, 8388, 8390, 8392, 8393, 8394, 8396, 8401, 8406, 8416, 8419, 8424, 8437, 8439, 8445, 8482, 8485, 8496, 8521, 8603, 8936, 8946, 9046, 9050, 9063, 9066, 9076, 9092, 9100, 9108, 9111, 9113, 9131, 9162, 9164, 9218, 9219, 11329, 11331, 11334, 11336, 11346, 11361, 11363, 11366, 11370, 11372, 11375, 11389, 11682, 11686, 11687, 11692, 11694, 11714, 11716, 11723, 11725, 11730, 11736, 11982, 11989, 12102, 12336, 12348, 12350, 12384, 12393, 12395, 12397, 12510, 12553, 12851, 12962, 12973, 13738, 13823, 13919, 13933, 14080, 14298, 14585, 14698, 15583, 15847, 16318, 16434, 16438, 16481, 16729, 17102, 17122, 17315, 17320, 17402, 17418, 17859, 17909, 17911, 17915, 17916, 17936, 17939, 17961, 18664, 18703, 18814, 18962, 19043, 33469, 33470, 33471, 33484, 33485, 33490, 33497, 33501, 33505, 33513, 33520, 33536, 33550, 37845, 37921, 37948, 38029, 38038, 38064, 38065, 38066, 38069, 38075, 38076, 38078, 39108, 39109, 39113, 39114, 39115, 39116, 39265, 39394, 189000] };
102700
102729
  });
102701
102730
 
102702
- // ../../node_modules/iconv-lite/encodings/tables/cp949.json
102731
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/cp949.json
102703
102732
  var require_cp949 = __commonJS(function(exports, module) {
102704
102733
  module.exports = [
102705
102734
  ["0", "\x00", 127],
@@ -102976,7 +103005,7 @@ var require_cp949 = __commonJS(function(exports, module) {
102976
103005
  ];
102977
103006
  });
102978
103007
 
102979
- // ../../node_modules/iconv-lite/encodings/tables/cp950.json
103008
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/cp950.json
102980
103009
  var require_cp950 = __commonJS(function(exports, module) {
102981
103010
  module.exports = [
102982
103011
  ["0", "\x00", 127],
@@ -103157,7 +103186,7 @@ var require_cp950 = __commonJS(function(exports, module) {
103157
103186
  ];
103158
103187
  });
103159
103188
 
103160
- // ../../node_modules/iconv-lite/encodings/tables/big5-added.json
103189
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/big5-added.json
103161
103190
  var require_big5_added = __commonJS(function(exports, module) {
103162
103191
  module.exports = [
103163
103192
  ["8740", "䏰䰲䘃䖦䕸𧉧䵷䖳𧲱䳢𧳅㮕䜶䝄䱇䱀𤊿𣘗𧍒𦺋𧃒䱗𪍑䝏䗚䲅𧱬䴇䪤䚡𦬣爥𥩔𡩣𣸆𣽡晍囻"],
@@ -103283,7 +103312,7 @@ var require_big5_added = __commonJS(function(exports, module) {
103283
103312
  ];
103284
103313
  });
103285
103314
 
103286
- // ../../node_modules/iconv-lite/encodings/dbcs-data.js
103315
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/dbcs-data.js
103287
103316
  var require_dbcs_data = __commonJS(function(exports, module) {
103288
103317
  module.exports = {
103289
103318
  shiftjis: {
@@ -103454,7 +103483,7 @@ var require_dbcs_data = __commonJS(function(exports, module) {
103454
103483
  };
103455
103484
  });
103456
103485
 
103457
- // ../../node_modules/iconv-lite/encodings/index.js
103486
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/encodings/index.js
103458
103487
  var require_encodings = __commonJS(function(exports, module) {
103459
103488
  var mergeModules = require_merge_exports();
103460
103489
  var modules = [
@@ -103476,7 +103505,7 @@ var require_encodings = __commonJS(function(exports, module) {
103476
103505
  var i;
103477
103506
  });
103478
103507
 
103479
- // ../../node_modules/iconv-lite/lib/streams.js
103508
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/lib/streams.js
103480
103509
  var require_streams = __commonJS(function(exports, module) {
103481
103510
  var Buffer2 = require_safer().Buffer;
103482
103511
  module.exports = function(streamModule) {
@@ -103574,7 +103603,7 @@ var require_streams = __commonJS(function(exports, module) {
103574
103603
  };
103575
103604
  });
103576
103605
 
103577
- // ../../node_modules/iconv-lite/lib/index.js
103606
+ // ../../node_modules/express/node_modules/body-parser/node_modules/iconv-lite/lib/index.js
103578
103607
  var require_lib6 = __commonJS(function(exports, module) {
103579
103608
  var Buffer2 = require_safer().Buffer;
103580
103609
  var bomHandling = require_bom_handling();
@@ -155687,9 +155716,12 @@ function fingerprint(credentials) {
155687
155716
  if (!object) {
155688
155717
  return null;
155689
155718
  }
155690
- const password = object.password;
155691
- const token = object.token;
155692
- const hasSecret = typeof password === "string" && password.length > 0 || typeof token === "string" && token.length > 0;
155719
+ const hasSecret = [object, object.imap, object.smtp].some((candidate) => {
155720
+ if (!candidate || typeof candidate !== "object")
155721
+ return false;
155722
+ const { password, token } = candidate;
155723
+ return typeof password === "string" && password.length > 0 || typeof token === "string" && token.length > 0;
155724
+ });
155693
155725
  if (!hasSecret) {
155694
155726
  return null;
155695
155727
  }
@@ -155737,10 +155769,21 @@ async function resolveConnectionScope(platform, actorId, request = {}) {
155737
155769
  if (pending) {
155738
155770
  const resolved = await pending;
155739
155771
  if (resolved) {
155740
- return { scope: resolved };
155772
+ return {
155773
+ scope: request.shareConnections === false ? crypto.objectHash({
155774
+ credentials: resolved,
155775
+ session: socketSessionId ?? credentialSessionId
155776
+ }) : resolved
155777
+ };
155741
155778
  }
155742
155779
  }
155743
155780
  }
155781
+ if (request.shareConnections === false) {
155782
+ const session = socketSessionId ?? credentialSessionId;
155783
+ if (!session)
155784
+ throw new Error("session required for private connection");
155785
+ return { scope: crypto.objectHash({ session }) };
155786
+ }
155744
155787
  return anonymousScope(platform, actorId, {
155745
155788
  credentialSessionId,
155746
155789
  socketSessionId,
@@ -157016,7 +157059,11 @@ class PlatformInstance {
157016
157059
  heartbeatFailureHandled = false;
157017
157060
  replaced = false;
157018
157061
  shutdownResult;
157062
+ retirementError;
157019
157063
  actor;
157064
+ get actorId() {
157065
+ return this.actor;
157066
+ }
157020
157067
  constructor(params) {
157021
157068
  this.id = params.identifier;
157022
157069
  this.queueId = params.queueId ?? crypto.randId(16);
@@ -157091,7 +157138,15 @@ class PlatformInstance {
157091
157138
  this.replaced = true;
157092
157139
  this.flaggedForTermination = true;
157093
157140
  }
157094
- shutdown() {
157141
+ shutdown(pendingJobError) {
157142
+ if (pendingJobError && !this.retirementError) {
157143
+ this.retirementError = pendingJobError;
157144
+ const pending = [...this.completedJobHandlers.values()];
157145
+ this.completedJobHandlers.clear();
157146
+ this.completedJobHandlerTimestamps.clear();
157147
+ for (const handler of pending)
157148
+ this.failRetiredJob(handler);
157149
+ }
157095
157150
  if (!this.shutdownResult) {
157096
157151
  this.shutdownResult = this.teardown();
157097
157152
  }
@@ -157140,10 +157195,26 @@ class PlatformInstance {
157140
157195
  });
157141
157196
  }
157142
157197
  registerCompletedJobHandler(title, handler) {
157198
+ if (this.retirementError) {
157199
+ this.failRetiredJob(handler);
157200
+ return;
157201
+ }
157143
157202
  this.pruneExpiredJobHandlers();
157144
157203
  this.completedJobHandlers.set(title, handler);
157145
157204
  this.completedJobHandlerTimestamps.set(title, Date.now());
157146
157205
  }
157206
+ failRetiredJob(handler) {
157207
+ try {
157208
+ handler({
157209
+ "@context": buildCanonicalContext(this.contextUrl ?? INTERNAL_PLATFORM_CONTEXT_URL),
157210
+ type: "error",
157211
+ actor: { id: this.actor ?? this.name, type: "service" },
157212
+ error: this.retirementError
157213
+ });
157214
+ } catch (error) {
157215
+ this.log.error(`failed to acknowledge retired job: ${errorMessage(error)}`);
157216
+ }
157217
+ }
157147
157218
  takeCompletedJobHandler(title) {
157148
157219
  const handler = this.completedJobHandlers.get(title);
157149
157220
  if (handler) {
@@ -157218,6 +157289,8 @@ class PlatformInstance {
157218
157289
  return payload;
157219
157290
  }
157220
157291
  async handleJobResult(state, job, result) {
157292
+ if (this.retirementError)
157293
+ return;
157221
157294
  let payload = result;
157222
157295
  if (state === "failed") {
157223
157296
  payload = job.msg;
@@ -157563,6 +157636,8 @@ class ProcessManager {
157563
157636
  parentSecret2;
157564
157637
  init;
157565
157638
  ensureChains = new Map;
157639
+ startsPerIp = new Map;
157640
+ startsWindowBegan = 0;
157566
157641
  constructor(parentId, parentSecret1, parentSecret2, init) {
157567
157642
  this.parentId = parentId;
157568
157643
  this.parentSecret1 = parentSecret1;
@@ -157574,7 +157649,8 @@ class ProcessManager {
157574
157649
  const connectionScope = platformDetails.config.persist ? await resolveConnectionScope(platform, actorId, {
157575
157650
  credentialSessionId: credentialSessionId ?? sessionId,
157576
157651
  socketSessionId: sessionId,
157577
- sessionIp
157652
+ sessionIp,
157653
+ shareConnections: platformDetails.config.shareConnections
157578
157654
  }) : undefined;
157579
157655
  const pi = platformDetails.config.persist ? await this.ensureProcess(platform, sessionId, actorId, sessionIp, connectionScope) : await this.ensureProcess(platform);
157580
157656
  pi.config = platformDetails.config;
@@ -157605,23 +157681,38 @@ class ProcessManager {
157605
157681
  }
157606
157682
  ensureProcess(platform, sessionId, actor, sessionIp, connectionScope) {
157607
157683
  const identifier = getPlatformId(platform, actor, connectionScope?.scope);
157608
- const prior = this.ensureChains.get(identifier) ?? Promise.resolve();
157684
+ const platformConfig = this.init.platforms.get(platform).config;
157685
+ const privateSession = platformConfig.persist && platformConfig.shareConnections === false && sessionId;
157686
+ const chainKey = privateSession ? JSON.stringify([platform, actor, sessionId]) : identifier;
157687
+ const prior = this.ensureChains.get(chainKey) ?? Promise.resolve();
157609
157688
  const run = prior.then(() => this.ensureProcessNow(identifier, platform, sessionId, actor, sessionIp, connectionScope));
157610
157689
  const settled = run.then(() => {
157611
157690
  return;
157612
157691
  }, () => {
157613
157692
  return;
157614
157693
  });
157615
- this.ensureChains.set(identifier, settled);
157694
+ this.ensureChains.set(chainKey, settled);
157616
157695
  settled.then(() => {
157617
- if (this.ensureChains.get(identifier) === settled) {
157618
- this.ensureChains.delete(identifier);
157696
+ if (this.ensureChains.get(chainKey) === settled) {
157697
+ this.ensureChains.delete(chainKey);
157619
157698
  }
157620
157699
  });
157621
157700
  return run;
157622
157701
  }
157623
157702
  async ensureProcessNow(identifier, platform, sessionId, actor, sessionIp, connectionScope) {
157703
+ const platformConfig = this.init.platforms.get(platform).config;
157624
157704
  const existing = platformInstances.get(identifier);
157705
+ if (actor !== undefined && !(existing && this.isProcessAlive(existing)))
157706
+ this.assertStartRate(sessionIp, false);
157707
+ if (platformConfig.persist && platformConfig.shareConnections === false && sessionId) {
157708
+ for (const previous of platformInstances.values()) {
157709
+ if (previous.id === identifier || previous.name !== platform || previous.actorId !== actor || !previous.sessions.has(sessionId))
157710
+ continue;
157711
+ previous.deregisterSession(sessionId);
157712
+ if (!previous.sessions.size)
157713
+ await previous.shutdown("credentials replaced; pending operation interrupted; message submission may already have succeeded; do not automatically retry sends");
157714
+ }
157715
+ }
157625
157716
  const reusable = existing && this.isProcessAlive(existing);
157626
157717
  this.assertInstanceCapacity(platform, identifier, actor === undefined, sessionId, sessionIp, !!reusable);
157627
157718
  let inheritedQueueId;
@@ -157631,6 +157722,8 @@ class ProcessManager {
157631
157722
  await existing.shutdown();
157632
157723
  this.assertInstanceCapacity(platform, identifier, actor === undefined, sessionId, sessionIp, !!reusable);
157633
157724
  }
157725
+ if (!reusable && actor !== undefined)
157726
+ this.assertStartRate(sessionIp, true);
157634
157727
  const platformInstance = reusable ? existing : this.createPlatformInstance(identifier, platform, actor, connectionScope?.scope, inheritedQueueId);
157635
157728
  if (sessionIp && !platformInstance.global) {
157636
157729
  platformInstance.ownerIps.add(sessionIp);
@@ -157661,6 +157754,22 @@ class ProcessManager {
157661
157754
  throw new Error(`per-address platform instance limit reached (${perIp})`);
157662
157755
  }
157663
157756
  }
157757
+ assertStartRate(sessionIp, charge) {
157758
+ const max = Number(config_default.get("limits:maxStartsPerIpPerMinute") ?? 0);
157759
+ if (!(max > 0) || !sessionIp)
157760
+ return;
157761
+ const now = Date.now();
157762
+ if (now - this.startsWindowBegan >= 60000) {
157763
+ this.startsPerIp.clear();
157764
+ this.startsWindowBegan = now;
157765
+ }
157766
+ const starts = this.startsPerIp.get(sessionIp) ?? 0;
157767
+ if (starts >= max) {
157768
+ throw new Error(`per-address platform start rate limit reached (${max} per minute)`);
157769
+ }
157770
+ if (charge)
157771
+ this.startsPerIp.set(sessionIp, starts + 1);
157772
+ }
157664
157773
  isProcessAlive(platformInstance) {
157665
157774
  const pid = platformInstance.process?.pid;
157666
157775
  if (!pid) {
@@ -64,12 +64,14 @@ export default class PlatformInstance {
64
64
  private heartbeatFailureHandled;
65
65
  private replaced;
66
66
  private shutdownResult?;
67
+ private retirementError?;
67
68
  /**
68
69
  * Actor this instance was opened for. Updated when the platform re-keys
69
70
  * (IRC nick change) so a later rename moves the credential scope off the
70
71
  * actor the client is using now, not the one from process start.
71
72
  */
72
73
  private actor?;
74
+ get actorId(): string | undefined;
73
75
  constructor(params: PlatformInstanceParams);
74
76
  createQueue(): void;
75
77
  resolveSentryEnv(): string | undefined;
@@ -98,7 +100,7 @@ export default class PlatformInstance {
98
100
  * independent run would resolve while the first is still obliterating
99
101
  * the queue name the replacement is about to reuse.
100
102
  */
101
- shutdown(): Promise<void>;
103
+ shutdown(pendingJobError?: string): Promise<void>;
102
104
  private teardown;
103
105
  /**
104
106
  * When jobs are completed or failed, we prepare the results and send them to the client socket
@@ -111,6 +113,7 @@ export default class PlatformInstance {
111
113
  * mid-job) don't leak handlers for the lifetime of the instance.
112
114
  */
113
115
  registerCompletedJobHandler(title: string, handler: CompletedJobHandler): void;
116
+ private failRetiredJob;
114
117
  private takeCompletedJobHandler;
115
118
  private pruneExpiredJobHandlers;
116
119
  /**